From: Daniel Karbach Date: Sun, 21 Oct 2012 14:08:32 +0000 (+0200) Subject: added party menu state stub X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;h=e4f678d8cce5408590178bc873fde1754c037d0d;p=l2e.git added party menu state stub --- diff --git a/Debug/makefile b/Debug/makefile index fb78d77..97088f5 100644 --- a/Debug/makefile +++ b/Debug/makefile @@ -9,6 +9,7 @@ RM := rm -rf # All of the sources participating in the build are defined here -include sources.mk -include src/sdl/subdir.mk +-include src/menu/subdir.mk -include src/map/subdir.mk -include src/loader/subdir.mk -include src/graphics/subdir.mk diff --git a/Debug/sources.mk b/Debug/sources.mk index ccb0eeb..df0fd4e 100644 --- a/Debug/sources.mk +++ b/Debug/sources.mk @@ -24,6 +24,7 @@ C_UPPER_DEPS := # Every subdirectory with source files must be described here SUBDIRS := \ src/sdl \ +src/menu \ src/map \ src \ src/loader \ diff --git a/Debug/src/menu/subdir.mk b/Debug/src/menu/subdir.mk new file mode 100644 index 0000000..cdf7f21 --- /dev/null +++ b/Debug/src/menu/subdir.mk @@ -0,0 +1,27 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +CPP_SRCS += \ +../src/menu/PartyMenu.cpp \ +../src/menu/Resources.cpp + +OBJS += \ +./src/menu/PartyMenu.o \ +./src/menu/Resources.o + +CPP_DEPS += \ +./src/menu/PartyMenu.d \ +./src/menu/Resources.d + + +# Each subdirectory must supply rules for building sources it contributes +src/menu/%.o: ../src/menu/%.cpp + @echo 'Building file: $<' + @echo 'Invoking: GCC C++ Compiler' + g++ -I/usr/include/SDL -O0 -g3 -Wall -Werror -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/Release/makefile b/Release/makefile index fb78d77..97088f5 100644 --- a/Release/makefile +++ b/Release/makefile @@ -9,6 +9,7 @@ RM := rm -rf # All of the sources participating in the build are defined here -include sources.mk -include src/sdl/subdir.mk +-include src/menu/subdir.mk -include src/map/subdir.mk -include src/loader/subdir.mk -include src/graphics/subdir.mk diff --git a/Release/sources.mk b/Release/sources.mk index ccb0eeb..df0fd4e 100644 --- a/Release/sources.mk +++ b/Release/sources.mk @@ -24,6 +24,7 @@ C_UPPER_DEPS := # Every subdirectory with source files must be described here SUBDIRS := \ src/sdl \ +src/menu \ src/map \ src \ src/loader \ diff --git a/Release/src/menu/subdir.mk b/Release/src/menu/subdir.mk new file mode 100644 index 0000000..a289eae --- /dev/null +++ b/Release/src/menu/subdir.mk @@ -0,0 +1,27 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +CPP_SRCS += \ +../src/menu/PartyMenu.cpp \ +../src/menu/Resources.cpp + +OBJS += \ +./src/menu/PartyMenu.o \ +./src/menu/Resources.o + +CPP_DEPS += \ +./src/menu/PartyMenu.d \ +./src/menu/Resources.d + + +# Each subdirectory must supply rules for building sources it contributes +src/menu/%.o: ../src/menu/%.cpp + @echo 'Building file: $<' + @echo 'Invoking: GCC C++ Compiler' + g++ -DNDEBUG -I/usr/include/SDL -O3 -Wall -Werror -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/src/common/GameConfig.cpp b/src/common/GameConfig.cpp index b35e991..6673a32 100644 --- a/src/common/GameConfig.cpp +++ b/src/common/GameConfig.cpp @@ -12,7 +12,8 @@ namespace common { GameConfig::GameConfig() : state(0) , battleResources(0) -, heroesLayout(0) { +, heroesLayout(0) +, menuResources(0) { } diff --git a/src/common/GameConfig.h b/src/common/GameConfig.h index 16b0142..c13b4ab 100644 --- a/src/common/GameConfig.h +++ b/src/common/GameConfig.h @@ -10,6 +10,7 @@ #include "fwd.h" #include "../battle/fwd.h" +#include "../menu/fwd.h" namespace common { @@ -22,6 +23,8 @@ struct GameConfig { battle::Resources *battleResources; battle::PartyLayout *heroesLayout; + menu::Resources *menuResources; + }; } diff --git a/src/main.cpp b/src/main.cpp index f70103a..73b4274 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,7 @@ #include "graphics/Menu.h" #include "graphics/SimpleAnimation.h" #include "graphics/Sprite.h" +#include "graphics/Texture.h" #include "loader/Caster.h" #include "loader/Interpreter.h" #include "loader/ParsedSource.h" @@ -41,6 +42,7 @@ #include "map/MapState.h" #include "map/Tile.h" #include "map/Trigger.h" +#include "menu/Resources.h" #include "sdl/InitImage.h" #include "sdl/InitScreen.h" #include "sdl/InitSDL.h" @@ -64,6 +66,7 @@ using common::GameConfig; using common::GameState; using common::Spell; using geometry::Vector; +using graphics::Texture; using loader::Caster; using loader::Interpreter; using loader::ParsedSource; @@ -268,6 +271,14 @@ int main(int argc, char **argv) { gameState.heroes[3].MapEntity().SetFlags(Entity::FLAG_NONBLOCKING); gameState.heroes[2].MapEntity().AddFollower(&gameState.heroes[3].MapEntity()); + menu::Resources menuResources; + gameConfig.menuResources = &menuResources; + + Texture menubg; + menubg.SetSurface(IMG_Load("test-data/menubg.png")); + menubg.SetSize(Vector(64, 64)); + menuResources.menubg = &menubg; + InitScreen screen(width, height); app::State *state(0); diff --git a/src/map/MapState.cpp b/src/map/MapState.cpp index 5ec9507..af15630 100644 --- a/src/map/MapState.cpp +++ b/src/map/MapState.cpp @@ -17,6 +17,7 @@ #include "../common/GameConfig.h" #include "../common/GameState.h" #include "../graphics/ColorFade.h" +#include "../menu/PartyMenu.h" #include @@ -26,6 +27,7 @@ using battle::BattleState; using common::GameConfig; using geometry::Vector; using graphics::ColorFade; +using menu::PartyMenu; namespace map { @@ -69,6 +71,11 @@ void MapState::OnResize(int width, int height) { void MapState::HandleEvents(const Input &input) { + if (input.JustPressed(Input::ACTION_X)) { + Ctrl().PushState(new PartyMenu(game)); + return; + } + if (!controlled) return; if (input.IsDown(Input::PAD_UP)) { diff --git a/src/menu/PartyMenu.cpp b/src/menu/PartyMenu.cpp new file mode 100644 index 0000000..1243df9 --- /dev/null +++ b/src/menu/PartyMenu.cpp @@ -0,0 +1,79 @@ +/* + * PartyMenu.cpp + * + * Created on: Oct 21, 2012 + * Author: holy + */ + +#include "PartyMenu.h" + +#include "Resources.h" +#include "../app/Application.h" +#include "../app/Input.h" +#include "../common/GameConfig.h" +#include "../geometry/Vector.h" +#include "../graphics/Texture.h" + +using app::Input; +using common::GameConfig; +using geometry::Vector; + +namespace menu { + +PartyMenu::PartyMenu(GameConfig *game) +: game(game) { + +} + +PartyMenu::~PartyMenu() { + +} + + +void PartyMenu::OnEnterState(SDL_Surface *) { + +} + +void PartyMenu::OnExitState(SDL_Surface *) { + +} + +void PartyMenu::OnResumeState(SDL_Surface *) { + +} + +void PartyMenu::OnPauseState(SDL_Surface *) { + +} + + +void PartyMenu::OnResize(int width, int height) { + +} + + +void PartyMenu::HandleEvents(const Input &input) { + if (input.JustPressed(Input::ACTION_B)) { + Ctrl().PopState(); + return; + } +} + +void PartyMenu::UpdateWorld(float deltaT) { + +} + +void PartyMenu::Render(SDL_Surface *screen) { + Res().menubg->Render(screen, Vector(), Vector(screen->w, screen->h)); +} + + +Resources &PartyMenu::Res() { + return *game->menuResources; +} + +const Resources &PartyMenu::Res() const { + return *game->menuResources; +} + +} diff --git a/src/menu/PartyMenu.h b/src/menu/PartyMenu.h new file mode 100644 index 0000000..ee84239 --- /dev/null +++ b/src/menu/PartyMenu.h @@ -0,0 +1,48 @@ +/* + * PartyMenu.h + * + * Created on: Oct 21, 2012 + * Author: holy + */ + +#ifndef MENU_PARTYMENU_H_ +#define MENU_PARTYMENU_H_ + +#include "Resources.h" +#include "../app/State.h" +#include "../common/GameConfig.h" + +namespace menu { + +class PartyMenu +: public app::State { + +public: + explicit PartyMenu(common::GameConfig *); + virtual ~PartyMenu(); + +public: + virtual void HandleEvents(const app::Input &); + virtual void UpdateWorld(float deltaT); + virtual void Render(SDL_Surface *); + +public: + Resources &Res(); + const Resources &Res() const; + +private: + virtual void OnEnterState(SDL_Surface *screen); + virtual void OnExitState(SDL_Surface *screen); + virtual void OnResumeState(SDL_Surface *screen); + virtual void OnPauseState(SDL_Surface *screen); + + virtual void OnResize(int width, int height); + +private: + common::GameConfig *game; + +}; + +} + +#endif /* MENU_PARTYMENU_H_ */ diff --git a/src/menu/Resources.cpp b/src/menu/Resources.cpp new file mode 100644 index 0000000..98787f6 --- /dev/null +++ b/src/menu/Resources.cpp @@ -0,0 +1,17 @@ +/* + * Resources.cpp + * + * Created on: Oct 21, 2012 + * Author: holy + */ + +#include "Resources.h" + +namespace menu { + +Resources::Resources() +: menubg(0) { + +} + +} diff --git a/src/menu/Resources.h b/src/menu/Resources.h new file mode 100644 index 0000000..8969eb8 --- /dev/null +++ b/src/menu/Resources.h @@ -0,0 +1,25 @@ +/* + * Resources.h + * + * Created on: Oct 21, 2012 + * Author: holy + */ + +#ifndef MENU_RESOURCES_H_ +#define MENU_RESOURCES_H_ + +#include "../graphics/fwd.h" + +namespace menu { + +struct Resources { + + graphics::Texture *menubg; + + Resources(); + +}; + +} + +#endif /* MENU_RESOURCES_H_ */ diff --git a/src/menu/fwd.h b/src/menu/fwd.h new file mode 100644 index 0000000..642eae3 --- /dev/null +++ b/src/menu/fwd.h @@ -0,0 +1,18 @@ +/* + * fwd.h + * + * Created on: Oct 21, 2012 + * Author: holy + */ + +#ifndef MENU_FWD_H_ +#define MENU_FWD_H_ + +namespace menu { + +class PartyMenu; +struct Resources; + +} + +#endif /* MENU_FWD_H_ */ diff --git a/test-data/menubg.png b/test-data/menubg.png new file mode 100644 index 0000000..1b42927 Binary files /dev/null and b/test-data/menubg.png differ