WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
Menu_EventDetails.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef WORLDSIM_MENU_EVENT_DETAILS_CPP
3 #define WORLDSIM_MENU_EVENT_DETAILS_CPP
4 
5 /* WorldSim: Menu_EventDetails.cpp
6  #include "Menu_EventDetails.cpp"
7 
8  Menu listing the details of the particular event.
9 
10 */
11 
12 #include <Graphics/GUI/GUI_Table.hpp>
13 #include <Container/Table/Table.hpp>
14 
15 class Menu_EventDetails: public GUI_Interface
16 {
17  public:
18  GUI_Manager guiManager;
19 
20  /* Colours / theme. */
21  ColourRGB <unsigned char> cNormal;
22  ColourRGB <unsigned char> cSelected;
23  ColourRGB <unsigned char> cDropPanel;
24  ColourRGB <unsigned char> cHighlight;
25 
26  Wildcat::Font* font;
27 
28  GUI_Button buttonClose;
29 
31 
32 
34  {
35  selectedEvent=0;
36  }
37 
38  void setFont(Wildcat::Font* _font)
39  {
40  font = _font;
41  guiManager.setFont(_font);
42  }
43 
44 
45  // This is some bad overloading.
46  void init()
47  {
48  init(0);
49  }
50 
51  void init(Event* _event)
52  {
53  if ( _event != 0 || selectedEvent== 0)
54  {
55  selectedEvent=_event;
56  }
57 
58  /* Initialise theme. */
59  cNormal.set(220,220,220);
60  cSelected.set(180,180,180);
61  cDropPanel.set(170,170,170);
62  cHighlight.set(255,160,160);
63 
64  buttonClose.text="X";
65  buttonClose.setColours(cNormal,cHighlight,0);
66  buttonClose.active=true;
67 
68  guiManager.clear();
69 
70  guiManager.add(&buttonClose);
71 
72  guiManager.setFont(font);
73 
74  eventResize();
75  }
76 
77  void render()
78  {
79  if (selectedEvent==0)
80  {
81  active=false;
82  return;
83  }
84 
85  if ( active )
86  {
87  Renderer::placeColour4a(150,150,150,220,panelX1,panelY1,panelX2,panelY2);
88  font8x8.drawText("Event details",panelX1,panelY2-20,panelX2,panelY2-5, true, true);
89 
90  int yOffset=35;
91  int vSpacing=12;
92  int xBuffer = 50;
93 
94  font8x8.drawText(selectedEvent->getLongDescription(),panelX1+xBuffer,panelY2-yOffset,panelX2-xBuffer,panelY1, false, false);
95  yOffset+=vSpacing;
96 
97  guiManager.render();
98  }
99  }
100 
101  bool keyboardEvent (Keyboard* _keyboard)
102  {
103  if ( active )
104  {
105  return guiManager.keyboardEvent(_keyboard);
106  }
107  return false;
108  }
109 
110  bool mouseEvent (Mouse* _mouse)
111  {
112  if ( active )
113  {
114  /* If the guiManager did something with the mouse event. */
115  if(guiManager.mouseEvent(_mouse)==true)
116  {
117 
118  }
119 
120  if (buttonClose.clicked==true)
121  {
122  active=false;
123  buttonClose.unclick();
124  }
125 
126  }
127 
128  return false;
129  }
130 
131  void eventResize()
132  {
133  buttonClose.setPanel(panelX2-40, panelY2-40, panelX2-20, panelY2-20);
134  }
135 
136 };
137 
138 
139 #endif
void setFont(Wildcat::Font *_font)
Definition: Menu_EventDetails.hpp:38
Wildcat::Font * font
Definition: Menu_EventDetails.hpp:26
ColourRGB< unsigned char > cDropPanel
Definition: Menu_EventDetails.hpp:23
Definition: World_Event.hpp:17
void init(Event *_event)
Definition: Menu_EventDetails.hpp:51
void init()
Definition: Menu_EventDetails.hpp:46
ColourRGB< unsigned char > cSelected
Definition: Menu_EventDetails.hpp:22
GUI_Manager guiManager
Definition: Menu_EventDetails.hpp:18
Wildcat::Font font8x8
Definition: Driver_GlobalObjects.hpp:55
Menu_EventDetails()
Definition: Menu_EventDetails.hpp:33
GUI_Button buttonClose
Definition: Menu_EventDetails.hpp:28
bool keyboardEvent(Keyboard *_keyboard)
Definition: Menu_EventDetails.hpp:101
void render()
Definition: Menu_EventDetails.hpp:77
Event * selectedEvent
Definition: Menu_EventDetails.hpp:30
Definition: Menu_EventDetails.hpp:15
ColourRGB< unsigned char > cNormal
Definition: Menu_EventDetails.hpp:21
void eventResize()
Definition: Menu_EventDetails.hpp:131
bool mouseEvent(Mouse *_mouse)
Definition: Menu_EventDetails.hpp:110
ColourRGB< unsigned char > cHighlight
Definition: Menu_EventDetails.hpp:24
virtual std::string getLongDescription()
Definition: World_Events.cpp:75