forked from Dzejrou/tdt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntityCreator.cpp
More file actions
68 lines (61 loc) · 2.11 KB
/
Copy pathEntityCreator.cpp
File metadata and controls
68 lines (61 loc) · 2.11 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
#include "EntityCreator.hpp"
EntityCreator::EntityCreator(EntityPlacer& placer, EntitySystem& ents)
: placer_{placer}, registered_entities_{ents.get_registered_entities()}
{ /* DUMMY BODY */ }
bool EntityCreator::place(const CEGUI::EventArgs& args)
{
auto selected = list_box_->getFirstSelectedItem();
if(selected && !lpp::Script::get_singleton().is_nil(selected->getText().c_str()))
{
placer_.set_current_entity_table(selected->getText().c_str());
placer_.set_visible(true);
return true;
}
return false;
}
bool EntityCreator::change_to_place(const CEGUI::EventArgs& args)
{
// TODO: Place/Create modes.
return false;
}
bool EntityCreator::change_to_create(const CEGUI::EventArgs& args)
{
// TODO: Place/Create modes.
return false;
}
bool EntityCreator::actualize_list(const CEGUI::EventArgs& args)
{
list_box_->resetList();
CEGUI::ListboxTextItem* item;
CEGUI::Colour col{1.f, .5f, .1f};
for(auto& ent : registered_entities_)
{
item = new CEGUI::ListboxTextItem(ent);
item->setTextColours(Console::ORANGE_TEXT);
item->setSelectionBrushImage("AlfiskoSkin/GenericBrush");
item->setSelectionColours(Console::BLUE_TEXT);
list_box_->addItem(item);
}
return true;
}
void EntityCreator::init_()
{
window_->setVisible(false);
window_->getChild("PLACE")->subscribeEvent(CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber(&EntityCreator::change_to_place, this));
window_->getChild("CREATE")->subscribeEvent(CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber(&EntityCreator::change_to_create, this));
window_->getChild("PLACE_BUTT")->subscribeEvent(CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber(&EntityCreator::place, this));
window_->getChild("ACTUALIZE_LIST")->subscribeEvent(CEGUI::PushButton::EventClicked,
CEGUI::Event::Subscriber(&EntityCreator::actualize_list, this));
window_->subscribeEvent(
CEGUI::FrameWindow::EventCloseClicked,
[&](const CEGUI::EventArgs&) -> bool {
this->set_visible(false);
return true;
}
);
list_box_ = (CEGUI::Listbox*)window_->getChild("ENTITY_LIST");
actualize_list(CEGUI::EventArgs{});
}