]> git.localhorst.tv Git - l2e.git/commitdiff
added party menu state stub
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 21 Oct 2012 14:08:32 +0000 (16:08 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 21 Oct 2012 15:53:44 +0000 (17:53 +0200)
16 files changed:
Debug/makefile
Debug/sources.mk
Debug/src/menu/subdir.mk [new file with mode: 0644]
Release/makefile
Release/sources.mk
Release/src/menu/subdir.mk [new file with mode: 0644]
src/common/GameConfig.cpp
src/common/GameConfig.h
src/main.cpp
src/map/MapState.cpp
src/menu/PartyMenu.cpp [new file with mode: 0644]
src/menu/PartyMenu.h [new file with mode: 0644]
src/menu/Resources.cpp [new file with mode: 0644]
src/menu/Resources.h [new file with mode: 0644]
src/menu/fwd.h [new file with mode: 0644]
test-data/menubg.png [new file with mode: 0644]

index fb78d77000c341cfe3be76ba5c445c9aa748eea4..97088f518ad3284d090f3bf26eb6bdc07a232eb5 100644 (file)
@@ -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
index ccb0eebe5d0f5e4132e4e8157d776dc6722fd187..df0fd4e86d632e2553a5cff647c5b43c2c1ba23d 100644 (file)
@@ -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 (file)
index 0000000..cdf7f21
--- /dev/null
@@ -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 ' '
+
+
index fb78d77000c341cfe3be76ba5c445c9aa748eea4..97088f518ad3284d090f3bf26eb6bdc07a232eb5 100644 (file)
@@ -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
index ccb0eebe5d0f5e4132e4e8157d776dc6722fd187..df0fd4e86d632e2553a5cff647c5b43c2c1ba23d 100644 (file)
@@ -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 (file)
index 0000000..a289eae
--- /dev/null
@@ -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 ' '
+
+
index b35e99161d437b19ff05c2888e97831be641d3c3..6673a326686a90200ae10f9c370add18233dc0c2 100644 (file)
@@ -12,7 +12,8 @@ namespace common {
 GameConfig::GameConfig()
 : state(0)
 , battleResources(0)
-, heroesLayout(0) {
+, heroesLayout(0)
+, menuResources(0) {
 
 }
 
index 16b0142b426e058aca16564c648bd61f7f06b619..c13b4ab3efc60609684c9af47499ca45bdf3196d 100644 (file)
@@ -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;
+
 };
 
 }
index f70103a0dd411da6755c9cd85240f320855a5ee8..73b42740180cc7f5727fe506da1847bdc3a5422f 100644 (file)
@@ -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<int>(64, 64));
+               menuResources.menubg = &menubg;
+
                InitScreen screen(width, height);
 
                app::State *state(0);
index 5ec95071963cbfccac3f3920b3ffc0c1ca56343d..af156304b9412c6523e7aec39f7b0547e6fadd3f 100644 (file)
@@ -17,6 +17,7 @@
 #include "../common/GameConfig.h"
 #include "../common/GameState.h"
 #include "../graphics/ColorFade.h"
+#include "../menu/PartyMenu.h"
 
 #include <algorithm>
 
@@ -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 (file)
index 0000000..1243df9
--- /dev/null
@@ -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<int>(), Vector<int>(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 (file)
index 0000000..ee84239
--- /dev/null
@@ -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 (file)
index 0000000..98787f6
--- /dev/null
@@ -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 (file)
index 0000000..8969eb8
--- /dev/null
@@ -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 (file)
index 0000000..642eae3
--- /dev/null
@@ -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 (file)
index 0000000..1b42927
Binary files /dev/null and b/test-data/menubg.png differ