forked from Dzejrou/tdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuilderWindow.hpp
More file actions
83 lines (71 loc) · 1.71 KB
/
Copy pathBuilderWindow.hpp
File metadata and controls
83 lines (71 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once
#include <vector>
#include <string>
#include "GUIWindow.hpp"
class EntityPlacer;
/**
* Class representing the building selection window, allows the player to place
* registered (unlocked) buildings.
*/
class BuilderWindow : public GUIWindow
{
public:
/**
* Constructor.
*/
BuilderWindow();
/**
* Destructor.
*/
~BuilderWindow() {}
/**
* Brief: Appends a table name to the vector of all building tables.
* Param: Name of the table to register.
*/
void register_building(const std::string&);
/**
* Brief: Sets the placer that is used to build.
* Param: The new entity placer.
*/
void set_placer(EntityPlacer*);
protected:
/**
* Brief: Initializes the window and subscribes events.
*/
void init_();
private:
/**
* Brief: Decrements selection_number_ by one and updates
* the window.
*/
void dec_selection_();
/**
* Brief: Increments selection_number_ by one and updates
* the window.
*/
void inc_selection_();
/**
* Brief: Range checked buildings_ index access, returns the name
* of the building at a given index or "UNKNOWN" if the
* index is out of bounds.
* Param: Index of the building in the buildings_ vector.
*/
const std::string& get_building_(std::size_t);
/**
* Brief: Updates building names on the buttons.
*/
void update_selection_();
/**
* Names of all registered buildings.
*/
std::vector<std::string> buildings_;
/**
* Number of the current rightmost selection.
* The window shows buildings with indices <selection_number_ - 3, selection_number_>.
*/
std::size_t selection_number_;
/**
* Placer used to build.
*/
EntityPlacer* placer_;
};