TDME2  1.9.200
ProgressBarScreenController.cpp
Go to the documentation of this file.
2 
3 #include <string>
4 
5 #include <tdme/tdme.h>
7 #include <tdme/engine/Engine.h>
13 #include <tdme/gui/GUI.h>
14 #include <tdme/gui/GUIParser.h>
17 #include <tdme/utilities/Console.h>
20 
21 using std::string;
22 
24 
33 using tdme::gui::GUI;
40 
41 ProgressBarScreenController::ProgressBarScreenController(PopUps* popUps): popUps(popUps)
42 {
43 }
44 
46 }
47 
49 {
50  return screenNode;
51 }
52 
54 {
55  try {
56  screenNode = GUIParser::parse("resources/engine/gui", "popup_progressbar.xml");
58  screenNode->setEnabled(false);
59  progressBarNode = dynamic_cast<GUIElementNode*>(screenNode->getNodeById("progressbar"));
60  progressBarParent = dynamic_cast<GUIElementNode*>(screenNode->getNodeById("progressbar_parent"));
61  progressMessageNode = dynamic_cast<GUITextNode*>(screenNode->getNodeById("progress_message"));
62  } catch (Exception& exception) {
63  Console::println("ProgressBarScreenController::initialize(): An error occurred: " + string(exception.what()));
64  }
65 }
66 
68 {
69  screenNode = nullptr;
70 }
71 
72 void ProgressBarScreenController::show(const string& message, bool showProgressBar)
73 {
75  if (showProgressBar == true) {
76  progressBarParent->getActiveConditions().add("show-progressbar");
77  } else {
78  progressBarParent->getActiveConditions().remove("show-progressbar");
79  }
80  screenNode->setEnabled(true);
81  progress2(0.0f);
82 }
83 
86  Engine::getInstance()->display();
87  Engine::getInstance()->getGUI()->render();
88  Engine::getInstance()->getGUI()->handleEvents();
89  Application::swapBuffers();
90 }
91 
94 }
95 
97 {
98  screenNode->setEnabled(false);
99 }
100 
101 void ProgressBarScreenController::onTooltipShowRequest(GUINode* node, int mouseX, int mouseY) {
102  popUps->getTooltipScreenController()->show(mouseX, mouseY, node->getToolTip());
103 }
104 
107 }
Application base class, please make sure to allocate application on heap to have correct application ...
Definition: Application.h:41
Engine main class.
Definition: Engine.h:131
GUI parser.
Definition: GUIParser.h:40
GUI module class.
Definition: GUI.h:64
GUINodeConditions & getActiveConditions()
bool add(const string &condition)
Add a condition.
bool remove(const string &condition)
Remove a condition.
GUI node controller base class.
virtual void setValue(const MutableString &value)=0
Set value.
GUI node base class.
Definition: GUINode.h:64
const string & getToolTip()
Definition: GUINode.h:346
GUINodeController * getController()
Definition: GUINode.h:661
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:72
void setEnabled(bool enabled)
Set enabled.
void addTooltipRequestListener(GUITooltipRequestListener *listener)
Add tooltip request listener.
GUINode * getNodeById(const string &nodeId)
Get GUI node by id.
void setText(const MutableString &text)
Set text.
Definition: GUITextNode.cpp:81
void show(const string &message, bool showProgressBar=true)
Shows the pop up.
void onTooltipShowRequest(GUINode *node, int mouseX, int mouseY) override
On tooltip show request.
void show(int mouseX, int mouseY, const string &tooltip)
Show tooltip.
Pop ups controller accessor class.
Definition: PopUps.h:29
TooltipScreenController * getTooltipScreenController()
Definition: PopUps.h:131
Console class.
Definition: Console.h:29
Mutable utf8 aware string class.
Definition: MutableString.h:23
std::exception Exception
Exception base class.
Definition: Exception.h:18