Moved selection to be a service

This commit is contained in:
Vulpovile
2022-10-03 19:30:24 -07:00
parent b2db375ecf
commit f46e24d8f1
18 changed files with 177 additions and 140 deletions

View File

@@ -1,5 +1,6 @@
#include <string>
#include "DataModelV2/GuiRootInstance.h"
#include "DataModelV2/ToggleImageButtonInstance.h"
#include "DataModelV2/DataModelInstance.h"
#include <fstream>
#include <iostream>
@@ -19,6 +20,8 @@ DataModelInstance::DataModelInstance(void)
workspace = new WorkspaceInstance();
guiRoot = new GuiRootInstance();
level = new LevelInstance();
selectionService = new SelectionService();
selectionService->setPropertyWindow(g_usableApp->_propWindow);
//children.push_back(workspace);
//children.push_back(level);
className = "dataModel";
@@ -61,6 +64,7 @@ void DataModelInstance::toggleRun()
//if(!running)
//resetEngine();
}
bool DataModelInstance::isRunning()
{
return running;
@@ -83,8 +87,17 @@ void DataModelInstance::modXMLLevel(float modY)
void DataModelInstance::clearLevel()
{
running = false;
Instance * goButton = this->getGuiRoot()->findFirstChild("go");
if(goButton != NULL){
if(ToggleImageButtonInstance* goButtonReal = dynamic_cast<ToggleImageButtonInstance*>(goButton))
{
goButtonReal->checked = false;
}
}
selectionService->clearSelection();
selectionService->addSelected(this);
workspace->clearChildren();
g_usableApp->_propWindow->UpdateSelected(this);
}
PartInstance* DataModelInstance::makePart()
{
@@ -480,6 +493,8 @@ bool DataModelInstance::load(const char* filename, bool clearObjects)
std::string tname = hname.substr(0, hname.length() - 5);
name = tname;
resetEngine();
selectionService->clearSelection();
selectionService->addSelected(this);
return true;
}
else
@@ -622,25 +637,16 @@ WorkspaceInstance* DataModelInstance::getWorkspace()
{
return workspace;
}
/*Vector2 DataModelInstance::getMousePos()
{
return Vector2(mousex,mousey);
}
void DataModelInstance::setMousePos(int x,int y)
{
mousex=x;
mousey=y;
}
void DataModelInstance::setMousePos(Vector2 pos)
{
mousex=pos.x;
mousey=pos.y;
}*/
GuiRootInstance* DataModelInstance::getGuiRoot()
{
return guiRoot;
}
SelectionService* DataModelInstance::getSelectionService()
{
return selectionService;
}
LevelInstance* DataModelInstance::getLevel()
{