PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
scene_title.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef SCENE_TITLE_H
20 #define SCENE_TITLE_H
21 
22 #include <QMap>
23 #include <QPair>
24 #include <QStack>
25 #include "scene.h"
26 #include <gui/pge_menu.h>
27 #include <common_features/pge_texture.h>
28 #include <common_features/simple_animator.h>
29 #include <common_features/point.h>
30 #include <controls/controller.h>
31 #include <SDL2/SDL_thread.h>
32 
33 #include <script/lua_titlescreen_engine.h>
34 
35 typedef QPair<int, int > menustate;
36 
38 {
39  int x;
40  int y;
41  PGE_Texture t;
43  int frmH;
44 };
45 
47 {
48  QString levelfile;
49 };
50 
52 {
53  QString worldfile;
54  QString savefile;
55  int character;
56 };
57 
58 class TitleScene : public Scene
59 {
60 public:
61  TitleScene();
62  ~TitleScene();
63 
64  bool init();
65 
66  void onKeyboardPressed(SDL_Scancode scancode);
67  void onKeyboardPressedSDL(SDL_Keycode sdl_key, Uint16 modifier);
68  void onMouseMoved(SDL_MouseMotionEvent &mmevent);
69  void onMousePressed(SDL_MouseButtonEvent &mbevent);
70  void onMouseWheel(SDL_MouseWheelEvent &wheelevent);
71  LuaEngine* getLuaEngine();
72 
73  void processEvents();
74 
75  void update();
76  void render();
77  void renderMouse();
78 
79  void processMenu();
80 
81  int exec();
82  void resetController();
83  PGE_Menu menu;
84 
85  enum CurrentMenu
86  {
87  menu_main=0,
88  menu_options,
89  menu_playlevel,
90  menu_playlevel_wait,
91  menu_playepisode,
92  menu_playepisode_wait,
93  menu_playbattle,
94  menu_playbattle_wait,
95  menu_opensave,
96  menu_tests,
97  menu_testboxes,
98  menu_controls,
99  menu_controls_plr1,
100  menu_controls_plr2,
101  menu_videosettings,
102  menu_player,
103  menu_volume,
104  menu_dummy_and_big,//leave it!
105  //For fetching
106  menuFirst=menu_main,
107  menuLast=menu_dummy_and_big
108  };
109 
110  enum menuAnswer
111  {
112  ANSWER_EXIT=0,
113  ANSWER_PLAYLEVEL,
114  ANSWER_PLAYEPISODE,
115  ANSWER_PLAYEPISODE_2P,
116  ANSWER_PLAYBATTLE,
117  ANSWER_CREDITS,
118  ANSWER_LOADING,
119  ANSWER_GAMEOVER
120  };
121 
122  int numOfPlayers;
123  PlayEpisodeResult result_episode; //play episode
124  PlayLevelResult result_level; //Play level/battle
125 
126  Controller *controller;
127 
128  /**********************file_finder************************/
129  static int findEpisodes(void *);
130  static int findLevels(void *);
131  static SDL_Thread * filefind_thread;
132  static QString filefind_folder;
133  static QList<QPair<QString, QString > > filefind_found_files;
134  static bool filefind_finished;
135  /**********************file_finder************************/
136 
137 private:
138  int ret;
139  PGE_Point mousePos;
140  CurrentMenu _currentMenu;
141  void setMenu(CurrentMenu _menu);
142  QMap<CurrentMenu, menustate> menustates;
143  QStack<int > menuChain;
144 
145  PGE_Texture background;
146  bool _bgIsLoaded;
147  PGEColor bgcolor;
148  QVector<TitleScene_misc_img > imgs;
149 
150  PGE_Texture cursor;
151  bool _cursorIsLoaded;
152 
153  int debug_joy_keyval;
154  int debug_joy_keyid;
155  int debug_joy_keytype;
156 
157  LuaTitleScreenEngine luaEngine;
158 };
159 
160 #endif // SCENE_TITLE_H
Definition: pge_texture.h:32
void onKeyboardPressed(SDL_Scancode scancode)
Triggering when pressed any key on keyboard.
Definition: scene_title.cpp:191
Definition: pge_texture.h:25
Definition: scene_title.h:46
Definition: scene_title.h:51
The Controller class provides proxy interface between controllable objects array and physical control...
Definition: controller.h:32
Definition: scene.h:36
This class should have basic functions for interacting with lua To run the lua engine you have to con...
Definition: lua_engine.h:27
Definition: simple_animator.h:28
Definition: point.h:23
Definition: scene_title.h:37
Definition: lua_titlescreen_engine.h:10
void onKeyboardPressedSDL(SDL_Keycode sdl_key, Uint16 modifier)
Triggering when pressed any key on keyboard.
Definition: scene_title.cpp:206
Definition: scene_title.h:58
Definition: pge_menu.h:40