PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
pge_menuboxbase.h
1 #ifndef PGE_MENUBOXBASE_H
2 #define PGE_MENUBOXBASE_H
3 
4 
5 /*
6  * Platformer Game Engine by Wohlstand, a free platform for game making
7  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include "pge_boxbase.h"
24 #include "../scenes/scene.h"
25 
26 #include <graphics/gl_renderer.h>
27 #include <graphics/gl_color.h>
28 #include <common_features/rect.h>
29 #include <common_features/point.h>
30 #include <common_features/pointf.h>
31 #include <common_features/size.h>
32 #include <common_features/sizef.h>
33 
34 #include <QColor>
35 #include <QString>
36 #include <QStringList>
37 
38 #include "pge_menu.h"
39 #include "pge_msgbox.h"
40 
41 class Controller;
42 
44 {
45 public:
46  PGE_MenuBoxBase(Scene * _parentScene=NULL, PGE_Menu::menuAlignment alignment=PGE_Menu::menuAlignment::VERTICLE, int gapSpace=0, QString _title="Menu is works!",
47  msgType _type=msg_info, PGE_Point boxCenterPos=PGE_Point(-1,-1), float _padding=-1, QString texture="");
49 
50  void construct(QString _title="Menu is works!",
51  msgType _type=msg_info, PGE_Point pos=PGE_Point(-1,-1), float _padding=-1, QString texture="");
52 
53  ~PGE_MenuBoxBase();
54 
55  void setParentScene(Scene * _parentScene);
56  void setType(msgType _type);
57  void setTitleFont(QString fontName);
58  void setTitleFontColor(GlColor color);
59  void setTitleText(QString text);
60  void setPadding(int _padding);
61 
62  void clearMenu();
63  void addMenuItem(QString &menuitem);
64  void addMenuItems(QStringList &menuitems);
65 
66  void setPos(float x, float y);
67  void setMaxMenuItems(int items);
68  void setBoxSize(float _Width, float _Height, float _padding);
69  void update(float ticks);
70  void render();
71  void restart();
72  bool isRunning();
73  void exec();
74  void setRejectSnd(long sndRole);
75  int answer();
76 
77  void reject();
78 
79  void processKeyEvent(SDL_Keycode &key);
80 
81  void processLoader(float ticks);
82  void processBox(float);
83  void processUnLoader(float ticks);
84 
85  static void info(QString msg);
86  //static void info(std::string msg);
87  static void warn(QString msg);
88  //static void warn(std::string msg);
89  static void error(QString msg);
90  //static void error(std::string msg);
91  static void fatal(QString msg);
92  //static void fatal(std::string msg);
93 
94 protected:
95  PGE_Menu _menu;
96 
97 private:
98  void updateSize();
99  int _page;
100  bool running;
101  int fontID;
102  GlColor fontRgba;
103  int _answer_id;
104 
105  long reject_snd;
106  PGE_Point _pos;
107  Controller *_ctrl1;
108  Controller *_ctrl2;
109  msgType type;
110 
111  PGE_Rect _sizeRect;
112  QString title;
113  PGE_Size title_size;
114 
115  float width;
116  float height;
117  float padding;
118  QColor bg_color;
119  void initControllers();
120  void updateControllers();
121 
122  virtual void onUpButton() {}
123  virtual void onDownButton() {}
124  virtual void onLeftButton() {}
125  virtual void onRightButton() {}
126  virtual void onJumpButton() {}
127  virtual void onAltJumpButton() {}
128  virtual void onRunButton() {}
129  virtual void onAltRunButton() {}
130  virtual void onStartButton() {}
131  virtual void onDropButton() {}
132 };
133 
134 #endif // PGE_MENUBOXBASE_H
Definition: rect.h:26
Definition: size.h:23
The PGE_BoxBase class.
Definition: pge_boxbase.h:16
The Controller class provides proxy interface between controllable objects array and physical control...
Definition: controller.h:32
Definition: scene.h:36
Definition: point.h:23
Definition: pge_menuboxbase.h:43
Definition: gl_color.h:7
Definition: pge_menu.h:40