WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
Menu_SpeciesDetails.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef WORLDSIM_MENU_SPECIES_DETAILS_CPP
3 #define WORLDSIM_MENU_SPECIES_DETAILS_CPP
4 
5 /* WorldSim: Menu_SpeciesDetails.hpp
6  #include "Menu_SpeciesDetails.hpp"
7 
8  Submenu with specific details for this Species. Should contain:
9  * Name
10  * Description (It is X with Y Z).
11  * Location found (It can be found in the X biome)
12  * Rarity
13  * Harvestable ingredient (cooking, alchemy, crafting)
14  * Ingredient effects (Max 4?)
15 
16 */
17 
18 #include <Graphics/GUI/GUI_Table.hpp>
19 #include <Container/Table/Table.hpp>
20 
21 class Menu_SpeciesDetails: public GUI_Interface
22 {
23  public:
24  GUI_Manager guiManager;
25 
26  /* Colours / theme. */
27  ColourRGB <unsigned char> cNormal;
28  ColourRGB <unsigned char> cSelected;
29  ColourRGB <unsigned char> cDropPanel;
30  ColourRGB <unsigned char> cHighlight;
31 
32  Wildcat::Font* font;
33 
34  GUI_Button buttonClose;
35 
37 
39  {
40  selectedSpecies=0;
41  active=false;
42  }
43 
44  void setFont(Wildcat::Font* _font)
45  {
46  font = _font;
47  guiManager.setFont(_font);
48  }
49 
50  // This is some bad overloading.
51  void init()
52  {
53  init(0);
54  }
55 
56  void init(Creature_Species* _species)
57  {
58  if ( _species != 0 || selectedSpecies== 0)
59  {
60  selectedSpecies=_species;
61  }
62 
63  /* Initialise theme. */
64  cNormal.set(220,220,220);
65  cSelected.set(180,180,180);
66  cDropPanel.set(170,170,170);
67  cHighlight.set(255,160,160);
68 
69  buttonClose.text="X";
70  buttonClose.setColours(cNormal,cHighlight,0);
71  buttonClose.active=true;
72 
73  guiManager.add(&buttonClose);
74  guiManager.setFont(font);
75  eventResize();
76  }
77 
78  void render()
79  {
80  if (selectedSpecies==0)
81  { return; }
82 
83  if ( active )
84  {
85  Renderer::placeColour4a(150,150,150,220,panelX1,panelY1,panelX2,panelY2);
86  font8x8.drawText("Species details",panelX1,panelY2-20,panelX2,panelY2-5, true, true);
87 
88  int yOffset=35;
89  int vSpacing=12;
90 
91  std::string mainText="This is the "+selectedSpecies->name+".\n";
92 
93  if (selectedSpecies->biome)
94  { // all Flora should have a parent Biome
95  mainText += "It comes from the "+selectedSpecies->biome->name+".\n";
96  }
97  else
98  {
99  mainText+= "Biome unknown.\n";
100  }
101 
102  //mainText+="\n\nIt can be harvested for its "+selectedSpecies->ingredient->name+" which causes "
103  //+selectedSpecies->ingredient->effect->name+"\n";
104 
105  font8x8.drawText(mainText,panelX1,panelY1,panelX2,panelY2-25, false, false, false, 0, 0, 0, 255, 2);
106  guiManager.render();
107  }
108  }
109 
110  bool keyboardEvent (Keyboard* _keyboard)
111  {
112  if ( active )
113  {
114  return guiManager.keyboardEvent(_keyboard);
115  }
116  return false;
117  }
118 
119  bool mouseEvent (Mouse* _mouse)
120  {
121  if ( active )
122  {
123  /* If the guiManager did something with the mouse event. */
124  if(guiManager.mouseEvent(_mouse)==true)
125  {
126 
127  }
128 
129  if (buttonClose.clicked==true)
130  {
131  active=false;
132  buttonClose.unclick();
133  }
134  }
135  return false;
136  }
137 
138  void eventResize()
139  {
140  buttonClose.setPanel(panelX2-40, panelY2-40, panelX2-20, panelY2-20);
141  }
142 
143 };
144 
145 
146 #endif
bool mouseEvent(Mouse *_mouse)
Definition: Menu_SpeciesDetails.hpp:119
void init()
Definition: Menu_SpeciesDetails.hpp:51
Wildcat::Font * font
Definition: Menu_SpeciesDetails.hpp:32
ColourRGB< unsigned char > cSelected
Definition: Menu_SpeciesDetails.hpp:28
Wildcat::Font font8x8
Definition: Driver_GlobalObjects.hpp:55
ColourRGB< unsigned char > cNormal
Definition: Menu_SpeciesDetails.hpp:27
Creature_Species * selectedSpecies
Definition: Menu_SpeciesDetails.hpp:36
World_Biome * biome
Definition: Creature_Species.hpp:27
void render()
Definition: Menu_SpeciesDetails.hpp:78
ColourRGB< unsigned char > cHighlight
Definition: Menu_SpeciesDetails.hpp:30
std::string name
Definition: Creature_Species.hpp:29
bool keyboardEvent(Keyboard *_keyboard)
Definition: Menu_SpeciesDetails.hpp:110
ColourRGB< unsigned char > cDropPanel
Definition: Menu_SpeciesDetails.hpp:29
void init(Creature_Species *_species)
Definition: Menu_SpeciesDetails.hpp:56
GUI_Button buttonClose
Definition: Menu_SpeciesDetails.hpp:34
Definition: Menu_SpeciesDetails.hpp:21
GUI_Manager guiManager
Definition: Menu_SpeciesDetails.hpp:24
void setFont(Wildcat::Font *_font)
Definition: Menu_SpeciesDetails.hpp:44
Definition: Creature_Species.hpp:23
std::string name
Definition: World_Biome.hpp:61
Menu_SpeciesDetails()
Definition: Menu_SpeciesDetails.hpp:38
void eventResize()
Definition: Menu_SpeciesDetails.hpp:138