Fixed CSV Parsing on tools
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include "scene/Scene.hpp"
|
||||
#include "ui/UIComponent.hpp"
|
||||
#include "game/DawnGame.hpp"
|
||||
#include "ui/UIMenu.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
@ -26,6 +27,12 @@ void UICanvas::onRenderTargetResize(float_t w, float_t h){
|
||||
}
|
||||
}
|
||||
|
||||
void UICanvas::onSceneUpdate() {
|
||||
if(this->currentMenu != nullptr) {
|
||||
this->currentMenu->onTick();
|
||||
}
|
||||
}
|
||||
|
||||
void UICanvas::setCamera(Camera *camera) {
|
||||
assertTrue(camera != this->camera);
|
||||
|
||||
@ -58,11 +65,23 @@ float_t UICanvas::getHeight() {
|
||||
return this->camera->getRenderTarget()->getHeight();
|
||||
}
|
||||
|
||||
struct UIMenu * UICanvas::getCurrentMenu() {
|
||||
return this->currentMenu;
|
||||
}
|
||||
|
||||
void UICanvas::setCurrentMenu(struct UIMenu *menu) {
|
||||
if(this->currentMenu != nullptr) this->currentMenu->onInactive();
|
||||
this->currentMenu = menu;
|
||||
if(menu != nullptr) menu->onActive();
|
||||
}
|
||||
|
||||
void UICanvas::onStart() {
|
||||
if(this->camera == nullptr) {
|
||||
auto camera = this->getScene()->findComponent<Camera>();
|
||||
this->setCamera(camera);
|
||||
}
|
||||
|
||||
this->getScene()->eventSceneUpdate.addListener(this, &UICanvas::onSceneUpdate);
|
||||
}
|
||||
|
||||
void UICanvas::onDispose() {
|
||||
@ -71,6 +90,8 @@ void UICanvas::onDispose() {
|
||||
this, &UICanvas::onRenderTargetResize
|
||||
);
|
||||
}
|
||||
|
||||
this->getScene()->eventSceneUpdate.removeListener(this, &UICanvas::onSceneUpdate);
|
||||
|
||||
auto it = this->children.begin();
|
||||
while(it != this->children.end()) {
|
||||
|
@ -16,12 +16,15 @@ namespace Dawn {
|
||||
};
|
||||
|
||||
class UIComponent;
|
||||
struct UIMenu;
|
||||
|
||||
class UICanvas : public SceneItemComponent {
|
||||
protected:
|
||||
Camera *camera = nullptr;
|
||||
struct UIMenu *currentMenu = nullptr;
|
||||
|
||||
void onRenderTargetResize(float_t w, float_t h);
|
||||
void onSceneUpdate();
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -33,7 +36,7 @@ namespace Dawn {
|
||||
*/
|
||||
static UICanvas * create(Scene *scene);
|
||||
|
||||
//
|
||||
//======================================================================//
|
||||
std::vector<UIComponent*> children;
|
||||
UIDrawType drawType = UI_DRAW_TYPE_WORLD_CAMERA_RELATIVE;
|
||||
|
||||
@ -64,6 +67,12 @@ namespace Dawn {
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a UI Element attached to this canvas.
|
||||
*
|
||||
* @tparam Type of the UI item to find.
|
||||
* @return Pointer to first matching element of type T.
|
||||
*/
|
||||
template<class T>
|
||||
T * findElement() {
|
||||
auto it = this->children.begin();
|
||||
@ -90,6 +99,20 @@ namespace Dawn {
|
||||
*/
|
||||
float_t getHeight();
|
||||
|
||||
/**
|
||||
* Returns the currently active menu for this UI Canvas.
|
||||
*
|
||||
* @return The currently active menu, or nullptr if there is none.
|
||||
*/
|
||||
struct UIMenu * getCurrentMenu();
|
||||
|
||||
/**
|
||||
* Sets the currently active menu, and ticks it appropriately.
|
||||
*
|
||||
* @param menu Menu to set as the current active menu.
|
||||
*/
|
||||
void setCurrentMenu(struct UIMenu *menu);
|
||||
|
||||
void onStart() override;
|
||||
void onDispose() override;
|
||||
};
|
||||
|
Reference in New Issue
Block a user