Moved selection to be a service
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
@@ -507,8 +507,8 @@ void GuiRootInstance::update()
|
||||
button4->disabled = true;
|
||||
button5->disabled = true;
|
||||
button6->disabled = true;
|
||||
for(size_t i = 0; i < g_selectedInstances.size(); i++)
|
||||
if(g_selectedInstances.at(i)->canDelete)
|
||||
for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++)
|
||||
if(g_dataModel->getSelectionService()->getSelection()[i]->canDelete)
|
||||
{
|
||||
button->disabled = false;
|
||||
button2->disabled = false;
|
||||
|
||||
Reference in New Issue
Block a user