WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
Menu_Options.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef WORLDSIM_MENU_OPTIONS_HPP
3 #define WORLDSIM_MENU_OPTIONS_HPP
4 
5 class Menu_Options: public GUI_Interface
6 {
7  public:
8  //GUI_TextBox menuHeading;
9  Texture* backgroundTexture;
10  /* Colours / theme. */
11  ColourRGB <unsigned char> cNormal;
12  ColourRGB <unsigned char> cSelected;
13  ColourRGB <unsigned char> cDropPanel;
14  ColourRGB <unsigned char> cHighlight;
15  /* Button: Back to main menu. */
16  GUI_Button buttonBack;
17  /* GUI manager. Manages all GUI controls. */
18  GUI_Manager guiManager;
19 
21  {
22  }
24  {
25  }
26 
27  void render()
28  {
29  /* Render background image. */
30  Renderer::placeTexture4(panelX1,panelY1,panelX2,panelY2,backgroundTexture,true);
31 
32  guiManager.render();
33  }
34 
35  void setFont(Wildcat::Font* _font)
36  {
37  font = _font;
38  guiManager.setFont(_font);
39  }
40 
41  void eventResize()
42  {
43  /* Update control positions. */
44  buttonBack.setPanel(panelCenterX-60, panelY2-20, panelCenterX+60, panelY2-40);
45  }
46 
47  void init()
48  {
49  backgroundTexture=&TEX_OPTIONS_BACKGROUND;
50  active=false;
51 
52 
53  /* Initialise theme. */
54  cNormal.set(220,220,220);
55  cSelected.set(180,180,180);
56  cDropPanel.set(170,170,170);
57  cHighlight.set(255,160,160);
58 
59  /* Update control positions. */
60  buttonBack.setPanel(panelCenterX-60, panelY2-20, panelCenterX+60, panelY2-40);
61  buttonBack.text="Back";
62  buttonBack.setColours(cNormal,cHighlight,0);
63 
64 
65  guiManager.add(&buttonBack);
66 
67  guiManager.setFont(font);
68  }
69 
70  bool mouseEvent (Mouse* _mouse)
71  {
72  /* If the guiManager did something with the mouse event. */
73  if(guiManager.mouseEvent(_mouse)==true)
74  {
75 
76  if(buttonBack.clicked==true)
77  {
78  buttonBack.unclick();
79  //std::cout<<"Back.\n";
80  //active=false;
82  }
83  }
84 
85  return false;
86  }
87 
88 };
89 
90 #endif
Texture * backgroundTexture
Definition: Menu_Options.hpp:9
~Menu_Options()
Definition: Menu_Options.hpp:23
void render()
Definition: Menu_Options.hpp:27
ColourRGB< unsigned char > cNormal
Definition: Menu_Options.hpp:11
void init()
Definition: Menu_Options.hpp:47
void eventResize()
Definition: Menu_Options.hpp:41
ColourRGB< unsigned char > cHighlight
Definition: Menu_Options.hpp:14
GUI_Button buttonBack
Definition: Menu_Options.hpp:16
Definition: Driver_Settings.cpp:111
bool mouseEvent(Mouse *_mouse)
Definition: Menu_Options.hpp:70
Menu_Options()
Definition: Menu_Options.hpp:20
Definition: Menu_Options.hpp:5
enumMenu activeMenu
Definition: Driver_Settings.cpp:113
ColourRGB< unsigned char > cSelected
Definition: Menu_Options.hpp:12
GUI_Manager guiManager
Definition: Menu_Options.hpp:18
ColourRGB< unsigned char > cDropPanel
Definition: Menu_Options.hpp:13
void setFont(Wildcat::Font *_font)
Definition: Menu_Options.hpp:35