diff --git a/Blocks3D.exe.manifest b/Blocks3D.exe.manifest index a8c2b78..c560b3b 100644 --- a/Blocks3D.exe.manifest +++ b/Blocks3D.exe.manifest @@ -1,7 +1,7 @@ + + @@ -840,6 +844,10 @@ RelativePath=".\src\include\DataModelV2\PVInstance.h" > + + diff --git a/Dialogs.rc b/Dialogs.rc index 781658b..2c1a4da 100644 --- a/Dialogs.rc +++ b/Dialogs.rc @@ -16,7 +16,39 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_CAN IDB_BITMAP1 BITMAP "Parts.bmp" - +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +1 VERSIONINFO + FILEVERSION 0,0,106,0 + PRODUCTVERSION 0,0,106,0 + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN + FILEFLAGSMASK 0 + FILEFLAGS 0 +{ + BLOCK "StringFileInfo" + { + BLOCK "100901B5" + { + VALUE "Comments", "" + VALUE "CompanyName", "Blocks3D Team" + VALUE "FileDescription", "Blocks 3D" + VALUE "FileVersion", "v0.0.106.0" + VALUE "InternalName", "Blocks3D" + VALUE "LegalCopyright", "Blocks3D Team - 2022" + VALUE "LegalTrademarks", "" + VALUE "OriginalFilename", "Blocks3D.exe" + VALUE "PrivateBuild", "" + VALUE "ProductName", "Blocks3D" + VALUE "ProductVersion", "v0.0.106.0" + VALUE "SpecialBuild", "" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x1009, 0x01B5 + } +} // // Dialog resources @@ -49,5 +81,5 @@ IDI_ICON1 ICON "FatB3dIcon.ico" // #ifndef _DEBUG LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -1 RT_MANIFEST ".\\Blocks3D.exe.manifest" +1 MANIFEST ".\\Blocks3D.exe.manifest" #endif \ No newline at end of file diff --git a/Installer/install_script.iss b/Installer/install_script.iss index a41c80a..e033253 100644 --- a/Installer/install_script.iss +++ b/Installer/install_script.iss @@ -1,14 +1,15 @@ ;InnoSetupVersion=5.4.3 +#define AppVer GetFileVersion('..\Blocks3D.exe') [Setup] -AppName=Blocks3D +AppName=Blocks3D +AppVersion=v{#AppVer} AppId={{4C5DF268-0208-4CDE-A7F0-65F7E2CB5067} -AppVersion=v0.0.105.2 AppPublisherURL=http://blocks3d.com/ AppSupportURL=http://blocks3d.com/ AppUpdatesURL=http://blocks3d.com/ DefaultDirName={%localappdata}\Blocks3D -OutputBaseFilename=Blocks3D_Setup_{#SetupSetting("AppVersion")} +OutputBaseFilename=Blocks3D_Setup_v{#AppVer} Compression=lzma2 PrivilegesRequired=lowest WizardImageFile=setup.bmp diff --git a/src/include/Application.h b/src/include/Application.h index 50a4598..b2a45b1 100644 --- a/src/include/Application.h +++ b/src/include/Application.h @@ -32,7 +32,6 @@ class Application { // : public GApp { PartInstance* makePart(); void drawButtons(RenderDevice* rd); void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c); - std::vector getSelection(); void deleteInstance(); void run(); void QuitApp(); @@ -60,6 +59,7 @@ class Application { // : public GApp { Tool * tool; void changeTool(Tool *); Mouse mouse; + bool viewportHasFocus(); private: bool mouseMoveState; RenderDevice* renderDevice; diff --git a/src/include/DataModelV2/DataModelInstance.h b/src/include/DataModelV2/DataModelInstance.h index f894c20..8dab766 100644 --- a/src/include/DataModelV2/DataModelInstance.h +++ b/src/include/DataModelV2/DataModelInstance.h @@ -2,6 +2,7 @@ #include "WorkspaceInstance.h" #include "LevelInstance.h" #include "PartInstance.h" +#include "SelectionService.h" #include "rapidxml/rapidxml.hpp" #include "GuiRootInstance.h" #include "XplicitNgine/XplicitNgine.h" @@ -30,12 +31,7 @@ public: bool showMessage; G3D::GFontRef font; GuiRootInstance* getGuiRoot(); - //float mousex; - //float mousey; - //Vector2 getMousePos(); - //void setMousePos(int x,int y); - //void setMousePos(Vector2 pos); - //bool mouseButton1Down; + SelectionService* getSelectionService(); PartInstance* makePart(); void clearLevel(); void toggleRun(); @@ -56,6 +52,7 @@ private: WorkspaceInstance* workspace; LevelInstance * level; GuiRootInstance* guiRoot; + SelectionService* selectionService; bool running; XplicitNgine * xplicitNgine; }; diff --git a/src/include/DataModelV2/SelectionService.h b/src/include/DataModelV2/SelectionService.h new file mode 100644 index 0000000..963be02 --- /dev/null +++ b/src/include/DataModelV2/SelectionService.h @@ -0,0 +1,21 @@ +#pragma once +#include "Instance.h" +#include "PropertyWindow.h" + +class SelectionService : public Instance +{ +public: + SelectionService(void); + ~SelectionService(void); + SelectionService(const SelectionService &oinst); + std::vector getSelection(); + void clearSelection(); + bool isSelected(Instance * instance); + void addSelected(Instance * instance); + void removeSelected(Instance * instance); + void addSelected(const std::vector &instances); + void setPropertyWindow(PropertyWindow * propertyWindow); +private: + std::vector selection; + PropertyWindow * propertyWindow; +}; diff --git a/src/include/Globals.h b/src/include/Globals.h index 1bb249b..d01fb67 100644 --- a/src/include/Globals.h +++ b/src/include/Globals.h @@ -25,7 +25,6 @@ public: }; extern std::vector postRenderStack; -extern std::vector g_selectedInstances; extern bool running; extern DataModelInstance* g_dataModel; extern XplicitNgine* g_xplicitNgine; diff --git a/src/include/PropertyWindow.h b/src/include/PropertyWindow.h index a4285aa..3500e49 100644 --- a/src/include/PropertyWindow.h +++ b/src/include/PropertyWindow.h @@ -1,14 +1,15 @@ #pragma once #include "DataModelV2/Instance.h" +#include class PropertyWindow { public: PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance); bool onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance); - void UpdateSelected(Instance *); + void UpdateSelected(std::vector selection); void ClearProperties(); void onResize(); - void refreshExplorer(Instance* selectedInstance); + void refreshExplorer(std::vector selection); HWND _hwndProp; private: HWND _propGrid; diff --git a/src/source/Application.cpp b/src/source/Application.cpp index 453a062..c349d45 100644 --- a/src/source/Application.cpp +++ b/src/source/Application.cpp @@ -143,6 +143,11 @@ Application::Application(HWND parentWindow) : _propWindow(NULL) { //: GApp(setti } +bool Application::viewportHasFocus() +{ + return GetActiveWindow() == this->_hWndMain; +} + void Application::navigateToolbox(std::string path) { int len = path.size() + 1; @@ -154,19 +159,19 @@ void Application::navigateToolbox(std::string path) void Application::deleteInstance() { - if(g_selectedInstances.size() > 0) + if(_dataModel->getSelectionService()->getSelection().size() > 0) { size_t undeletable = 0; - while(g_selectedInstances.size() > undeletable) + while(_dataModel->getSelectionService()->getSelection().size() > undeletable) { - if(g_selectedInstances.at(0)->canDelete) + if(_dataModel->getSelectionService()->getSelection()[0]->canDelete) { AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav")); - Instance* selectedInstance = g_selectedInstances.at(0); + Instance* selectedInstance = g_dataModel->getSelectionService()->getSelection()[0]; + _dataModel->getSelectionService()->removeChild(selectedInstance); selectedInstance->setParent(NULL); delete selectedInstance; selectedInstance = NULL; - g_selectedInstances.erase(g_selectedInstances.begin()); } else { @@ -174,8 +179,8 @@ void Application::deleteInstance() } } } - if(g_selectedInstances.size() == 0) - g_usableApp->_propWindow->UpdateSelected(g_dataModel); + if(_dataModel->getSelectionService()->getSelection().size() == 0) + _dataModel->getSelectionService()->addSelected(_dataModel); } @@ -280,6 +285,8 @@ void Application::onInit() { _dataModel->debugGetOpen(); #endif + _dataModel->getSelectionService()->clearSelection(); + _dataModel->getSelectionService()->addSelected(_dataModel); @@ -311,10 +318,6 @@ void Application::onNetwork() { // return pow(pow((double)vector1.x - (double)vector2.x, 2) + pow((double)vector1.y - (double)vector2.y, 2) + pow((double)vector1.z - (double)vector2.z, 2), 0.5); //} -std::vector Application::getSelection() -{ - return g_selectedInstances; -} void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) { if(_dataModel->isRunning()) @@ -331,25 +334,13 @@ void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) { else _dataModel->getEngine()->createBody(partInstance); } - bool a = false; while(toDelete.size() > 0) { PartInstance * p = toDelete.back(); toDelete.pop_back(); - if(std::find(g_selectedInstances.begin(), g_selectedInstances.end(), p) != g_selectedInstances.end()) - { - g_selectedInstances.erase(std::remove(g_selectedInstances.begin(), g_selectedInstances.end(), p), g_selectedInstances.end()); - a = true; - } + g_dataModel->getSelectionService()->removeSelected(p); p->setParent(NULL); delete p; - } - if(a) - { - if(g_selectedInstances.size() == 0) - g_usableApp->_propWindow->UpdateSelected(g_dataModel); - else if(g_selectedInstances.size() == 1) - g_usableApp->_propWindow->UpdateSelected(g_selectedInstances[0]); } for(int i = 0; i < 6; i++) { @@ -603,17 +594,15 @@ void Application::onGraphics(RenderDevice* rd) { //Draw::box(G3D::Box(mouse.getPosition()-Vector3(2,0.5F,1),mouse.getPosition()+Vector3(2,0.5F,1)), rd, Color3::cyan(), Color4::clear()); - if(g_selectedInstances.size() > 0) + + for(size_t i = 0; i < _dataModel->getSelectionService()->getSelection().size(); i++) { - for(size_t i = 0; i < g_selectedInstances.size(); i++) + if(PartInstance* part = dynamic_cast(g_dataModel->getSelectionService()->getSelection()[i])) { - if(PartInstance* part = dynamic_cast(g_selectedInstances.at(i))) - { - Vector3 size = part->getSize(); - Vector3 pos = part->getPosition(); - drawOutline(Vector3(0+size.x/2, 0+size.y/2, 0+size.z/2) ,Vector3(0-size.x/2,0-size.y/2,0-size.z/2), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x, pos.y, pos.z), part->getCFrame()); - } - } + Vector3 size = part->getSize(); + Vector3 pos = part->getPosition(); + drawOutline(Vector3(0+size.x/2, 0+size.y/2, 0+size.z/2) ,Vector3(0-size.x/2,0-size.y/2,0-size.z/2), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x, pos.y, pos.z), part->getCFrame()); + } } @@ -702,12 +691,6 @@ void Application::onKeyUp(int key) void Application::onMouseLeftPressed(HWND hwnd,int x,int y) { - //Removed set focus - - - //std::cout << "Click: " << x << "," << y << std::endl; - - bool onGUI = _dataModel->getGuiRoot()->mouseInGUI(renderDevice, x, y); @@ -717,19 +700,6 @@ void Application::onMouseLeftPressed(HWND hwnd,int x,int y) } } -void Application::selectInstance(Instance* selectedInstance, PropertyWindow* propWindow) -{ - if(!GetHoldKeyState(VK_RCONTROL) && !GetHoldKeyState(VK_LCONTROL)) - { - printf("No control key hold \n"); - g_selectedInstances.clear(); - } - else printf("Control held\n"); - if(std::find(g_selectedInstances.begin(), g_selectedInstances.end(),selectedInstance)==g_selectedInstances.end()) - g_selectedInstances.push_back(selectedInstance); - propWindow->UpdateSelected(selectedInstance); - -} G3D::RenderDevice* Application::getRenderDevice() { return renderDevice; @@ -737,13 +707,9 @@ G3D::RenderDevice* Application::getRenderDevice() void Application::onMouseLeftUp(G3D::RenderDevice* renderDevice, int x, int y) { - //std::cout << "Release: " << x << "," << y << std::endl; _dataModel->getGuiRoot()->onMouseLeftUp(renderDevice, x, y); _dragging = false; tool->onButton1MouseUp(mouse); - //_message = "Dragging = false."; - //_messageTime = System::time(); - } void Application::onMouseRightPressed(int x,int y) @@ -763,8 +729,6 @@ void Application::onMouseMoved(int x,int y) mouse.y = y; //tool->onMouseMoved(mouse); mouseMoveState = true; - //_dataModel->mousex = x; - //_dataModel->mousey = y; } void Application::onMouseWheel(int x,int y,short delta) diff --git a/src/source/CameraController.cpp b/src/source/CameraController.cpp index 30654e0..7338b24 100644 --- a/src/source/CameraController.cpp +++ b/src/source/CameraController.cpp @@ -193,6 +193,8 @@ void CameraController::update(Application* app) Vector3 cameraPos = g3dCamera.getCoordinateFrame().translation; CoordinateFrame frame = g3dCamera.getCoordinateFrame(); bool moving=false; + if(!app->viewportHasFocus()) + return; if(GetHoldKeyState('U')) { forwards = true; moving=true; diff --git a/src/source/DataModel/SelectionService.cpp b/src/source/DataModel/SelectionService.cpp new file mode 100644 index 0000000..882b1c8 --- /dev/null +++ b/src/source/DataModel/SelectionService.cpp @@ -0,0 +1,53 @@ +#include "DataModelV2/SelectionService.h" + +SelectionService::SelectionService(void){ + Instance::Instance(); + propertyWindow = NULL; +} + +SelectionService::~SelectionService(void){ +} + +SelectionService::SelectionService(const SelectionService &oinst){ + Instance::Instance(oinst); + propertyWindow = NULL; +} + + +std::vector SelectionService::getSelection(){ + return this->selection; +} +void SelectionService::clearSelection(){ + this->selection.clear(); + if(propertyWindow != NULL) + propertyWindow->ClearProperties(); +} +bool SelectionService::isSelected(Instance * instance){ + return std::find(selection.begin(), selection.end(), instance) != selection.end(); +} +void SelectionService::addSelected(Instance * instance){ + if(!isSelected(instance)) + this->selection.push_back(instance); + if(propertyWindow != NULL) + propertyWindow->UpdateSelected(selection); +} +void SelectionService::removeSelected(Instance * instance){ + selection.erase(std::remove(selection.begin(), selection.end(), instance), selection.end()); + if(propertyWindow != NULL) + propertyWindow->UpdateSelected(selection); +} +void SelectionService::addSelected(const std::vector &instances){ + for(size_t i = 0; i < instances.size(); i++) + { + if(!isSelected(instances[i])) + this->selection.push_back(instances[i]); + } + if(propertyWindow != NULL) + propertyWindow->UpdateSelected(selection); +} +void SelectionService::setPropertyWindow(PropertyWindow * propertyWindow) +{ + this->propertyWindow = propertyWindow; + if(propertyWindow != NULL) + propertyWindow->ClearProperties(); +} diff --git a/src/source/DataModelV2/DataModelInstance.cpp b/src/source/DataModelV2/DataModelInstance.cpp index 3add80d..162e16a 100644 --- a/src/source/DataModelV2/DataModelInstance.cpp +++ b/src/source/DataModelV2/DataModelInstance.cpp @@ -1,5 +1,6 @@ #include #include "DataModelV2/GuiRootInstance.h" +#include "DataModelV2/ToggleImageButtonInstance.h" #include "DataModelV2/DataModelInstance.h" #include #include @@ -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(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() { diff --git a/src/source/DataModelV2/GuiRootInstance.cpp b/src/source/DataModelV2/GuiRootInstance.cpp index 7efdbd9..45c1762 100644 --- a/src/source/DataModelV2/GuiRootInstance.cpp +++ b/src/source/DataModelV2/GuiRootInstance.cpp @@ -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; diff --git a/src/source/DataModelV2/LevelInstance.cpp b/src/source/DataModelV2/LevelInstance.cpp index 21c7e66..1be61d9 100644 --- a/src/source/DataModelV2/LevelInstance.cpp +++ b/src/source/DataModelV2/LevelInstance.cpp @@ -40,12 +40,12 @@ std::vector LevelInstance::getProperties() sprintf_s(scoreTxt, "%d", score); properties.push_back(createPGI("Gameplay", "InitialTimerValue", - "The ammount of time in seconds the player has to complete this level.\r\n\r\nPut 0 if time is limitless.", + "The amount of time in seconds the player has to complete this level.\r\n\r\nPut 0 if time is limitless.", (LPARAM)timerTxt, PIT_EDIT)); properties.push_back(createPGI("Gameplay", "InitialScoreValue", - "The ammount of points the player starts with.", + "The amount of points the player starts with.", (LPARAM)scoreTxt, PIT_EDIT)); return properties; diff --git a/src/source/Globals.cpp b/src/source/Globals.cpp index ce771d7..f120eb4 100644 --- a/src/source/Globals.cpp +++ b/src/source/Globals.cpp @@ -6,7 +6,6 @@ int Globals::surfaceId = 2; bool Globals::useMousePoint = false; std::vector postRenderStack = std::vector(); -std::vector g_selectedInstances = std::vector(); DataModelInstance* g_dataModel = NULL; XplicitNgine* g_xplicitNgine = NULL; diff --git a/src/source/IEBrowser.cpp b/src/source/IEBrowser.cpp index 848c50b..6d72313 100644 --- a/src/source/IEBrowser.cpp +++ b/src/source/IEBrowser.cpp @@ -43,9 +43,9 @@ HRESULT IEBrowser::doExternal(std::wstring funcName, if(pDispParams->rgvarg->intVal < 0 || pDispParams->rgvarg->intVal > 7) return S_OK; Enum::Controller::Value cont = (Enum::Controller::Value)pDispParams->rgvarg->intVal; - for(size_t i = 0; i < g_selectedInstances.size(); i++) + for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++) { - if(PVInstance* part = dynamic_cast(g_selectedInstances.at(i))) + if(PVInstance* part = dynamic_cast(g_dataModel->getSelectionService()->getSelection()[i])) { ding = true; part->controller = cont; diff --git a/src/source/Listener/CameraButtonListener.cpp b/src/source/Listener/CameraButtonListener.cpp index 08c3dd7..6007ef6 100644 --- a/src/source/Listener/CameraButtonListener.cpp +++ b/src/source/Listener/CameraButtonListener.cpp @@ -7,8 +7,8 @@ void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button) { AudioPlayer::playSound(cameraSound); CoordinateFrame frame = g_usableApp->cameraController.getCamera()->getCoordinateFrame(); - if(button->name == "CenterCam" && g_selectedInstances.size() > 0) - g_usableApp->cameraController.centerCamera(g_selectedInstances.at(0)); + if(button->name == "CenterCam" && g_dataModel->getSelectionService()->getSelection().size() > 0) + g_usableApp->cameraController.centerCamera(g_dataModel->getSelectionService()->getSelection()[0]); else if(button->name == "ZoomIn") g_usableApp->cameraController.Zoom(1); else if(button->name == "ZoomOut") diff --git a/src/source/Listener/GUDButtonListener.cpp b/src/source/Listener/GUDButtonListener.cpp index 0195b0d..b0b3413 100644 --- a/src/source/Listener/GUDButtonListener.cpp +++ b/src/source/Listener/GUDButtonListener.cpp @@ -2,13 +2,14 @@ #include "Application.h" #include "Globals.h" #include "AudioPlayer.h" +#include "DataModelV2/SelectionService.h" #include "Listener/GUDButtonListener.h" void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button) { bool cont = false; - 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) { cont = true; break; @@ -19,53 +20,46 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button) if(button->name == "Duplicate") { std::vector newinst; - for(size_t i = 0; i < g_selectedInstances.size(); i++) + for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++) { - if(g_selectedInstances.at(i)->canDelete) + if(g_dataModel->getSelectionService()->getSelection()[i]->canDelete) { - Instance* tempinst = g_selectedInstances.at(i); + Instance* tempinst = g_dataModel->getSelectionService()->getSelection()[i]; - Instance* clonedInstance = g_selectedInstances.at(i)->clone(); + Instance* clonedInstance = g_dataModel->getSelectionService()->getSelection()[i]->clone(); newinst.push_back(tempinst); } - /*tempinst->setPosition(Vector3(tempPos.x, tempPos.y + tempSize.y, tempPos.z)); - g_usableApp->cameraController.centerCamera(g_selectedInstances.at(0));*/ } - g_selectedInstances = newinst; - if(g_selectedInstances.size() > 0) - g_usableApp->_propWindow->UpdateSelected(newinst.at(0)); + g_dataModel->getSelectionService()->clearSelection(); + g_dataModel->getSelectionService()->addSelected(newinst); } else if(button->name == "Group") { GroupInstance * inst = new GroupInstance(); inst->setParent(g_dataModel->getWorkspace()); - for(size_t i = 0; i < g_selectedInstances.size(); i++) + for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++) { - if(g_selectedInstances.at(i)->canDelete) + if(g_dataModel->getSelectionService()->getSelection()[i]->canDelete) { - g_selectedInstances.at(i)->setParent(inst); - if(PartInstance* part = dynamic_cast(g_selectedInstances.at(i))) + g_dataModel->getSelectionService()->getSelection()[i]->setParent(inst); + if(PartInstance* part = dynamic_cast(g_dataModel->getSelectionService()->getSelection()[i])) { inst->primaryPart = part; } } - /*tempinst->setPosition(Vector3(tempPos.x, tempPos.y + tempSize.y, tempPos.z)); - g_usableApp->cameraController.centerCamera(g_selectedInstances.at(0));*/ } - g_selectedInstances.clear(); - g_selectedInstances.push_back(inst); - if(g_selectedInstances.size() > 0) - g_usableApp->_propWindow->UpdateSelected(g_selectedInstances.at(0)); + g_dataModel->getSelectionService()->clearSelection(); + g_dataModel->getSelectionService()->addSelected(inst); } else if(button->name == "UnGroup") { std::vector newinst; - for(size_t i = 0; i < g_selectedInstances.size(); i++) + for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++) { - if(g_selectedInstances.at(i)->canDelete) + if(g_dataModel->getSelectionService()->getSelection()[i]->canDelete) { - if(GroupInstance* model = dynamic_cast(g_selectedInstances.at(i))) + if(GroupInstance* model = dynamic_cast(g_dataModel->getSelectionService()->getSelection()[i])) { newinst = model->unGroup(); model->setParent(NULL); @@ -73,13 +67,9 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button) model = NULL; } } - /*tempinst->setPosition(Vector3(tempPos.x, tempPos.y + tempSize.y, tempPos.z)); - g_usableApp->cameraController.centerCamera(g_selectedInstances.at(0));*/ } - g_selectedInstances.clear(); - g_selectedInstances = newinst; - if(g_selectedInstances.size() > 0) - g_usableApp->_propWindow->UpdateSelected(newinst.at(0)); + g_dataModel->getSelectionService()->clearSelection(); + g_dataModel->getSelectionService()->addSelected(newinst); } } } \ No newline at end of file diff --git a/src/source/Listener/RotateButtonListener.cpp b/src/source/Listener/RotateButtonListener.cpp index d2d1b6b..2c143bd 100644 --- a/src/source/Listener/RotateButtonListener.cpp +++ b/src/source/Listener/RotateButtonListener.cpp @@ -5,9 +5,9 @@ void RotateButtonListener::onButton1MouseClick(BaseButtonInstance* button) { - if(g_selectedInstances.size() > 0) + if(g_dataModel->getSelectionService()->getSelection().size() > 0) { - Instance* selectedInstance = g_selectedInstances.at(0); + Instance* selectedInstance = g_dataModel->getSelectionService()->getSelection()[0]; AudioPlayer::playSound(clickSound); if(PartInstance* part = dynamic_cast(selectedInstance)) { diff --git a/src/source/Mouse.cpp b/src/source/Mouse.cpp index 61bd19e..de551ed 100644 --- a/src/source/Mouse.cpp +++ b/src/source/Mouse.cpp @@ -112,31 +112,3 @@ void Mouse::setMouseDown(bool bval) { mouseDown = bval; } - - - - //bool found = false; - /*for(size_t i = 0; i < g_selectedInstances.size(); i++) - { - if(g_selectedInstances.at(i) == test) - { - found = true; - //ShowWindow(_propWindow->_hwndProp, SW_SHOW); - //SetActiveWindow(_propWindow->_hwndProp); - //SetForegroundWindow(_propWindow->_hwndProp); - break; - } - } - if(!found) - { - selectedInstance = test; - //if(!GetHoldKeyState(VK_RCONTROL) && !GetHoldKeyState(VK_LCONTROL)) - //g_selectedInstances.clear(); - //if(std::find(g_selectedInstances.begin(), g_selectedInstances.end(),test)==g_selectedInstances.end()) - //g_selectedInstances.push_back(test); - } - //selectInstance(test, _propWindow); - //_message = "Dragging = true."; - //_messageTime = System::time(); - //_dragging = true;*/ - diff --git a/src/source/PropertyWindow.cpp b/src/source/PropertyWindow.cpp index bf72075..928886d 100644 --- a/src/source/PropertyWindow.cpp +++ b/src/source/PropertyWindow.cpp @@ -172,8 +172,8 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int ItemIndex = SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); CHAR ListItem[256]; SendMessage((HWND) lParam, (UINT) CB_GETLBTEXT, (WPARAM) ItemIndex, (LPARAM) ListItem); - propWind->ClearProperties(); - g_usableApp->selectInstance(children.at(ItemIndex),propWind); + g_dataModel->getSelectionService()->clearSelection(); + g_dataModel->getSelectionService()->addSelected(children.at(ItemIndex)); } } break; @@ -203,13 +203,12 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; } -void PropertyWindow::refreshExplorer(Instance* selectedInstance) +void PropertyWindow::refreshExplorer(std::vector selectedInstances) { + Instance * instance = selectedInstances[0]; SendMessage(_explorerComboBox,CB_RESETCONTENT,0,0); parent = NULL; children.clear(); - //g_selectedInstances.clear(); - //for (unsigned int i=0;iname.c_str()); if(selectedInstance->getParent() != NULL) @@ -221,7 +220,6 @@ void PropertyWindow::refreshExplorer(Instance* selectedInstance) parent = selectedInstance->getParent(); children.push_back(selectedInstance->getParent()); } - //children = g_selectedInstances[i]->getChildren(); std::vector selectedChildren = selectedInstance->getChildren(); for(size_t z = 0; z < selectedChildren.size(); z++) @@ -338,8 +336,14 @@ void PropertyWindow::_resize() SetWindowPos(_explorerComboBox, NULL, 0, 0, rect.right, 400, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); } -void PropertyWindow::UpdateSelected(Instance * instance) +void PropertyWindow::UpdateSelected(std::vector instances) { + if(instances.size() < 0) + { + ClearProperties(); + return; + } + Instance * instance = instances[0]; PropGrid_ResetContent(_propGrid); prop = instance->getProperties(); //if (selectedInstance != instance) @@ -356,7 +360,7 @@ void PropertyWindow::UpdateSelected(Instance * instance) PropGrid_ExpandAllCatalogs(_propGrid); //SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this); - refreshExplorer(instance); + refreshExplorer(instances); _resize(); } } diff --git a/src/source/Tool/ArrowTool.cpp b/src/source/Tool/ArrowTool.cpp index 9bbd1b4..a446bf8 100644 --- a/src/source/Tool/ArrowTool.cpp +++ b/src/source/Tool/ArrowTool.cpp @@ -1,5 +1,6 @@ #include "Tool/ArrowTool.h" #include "Application.h" +#include "DataModelV2/SelectionService.h" ArrowTool::ArrowTool(void) { @@ -21,13 +22,12 @@ void ArrowTool::onButton1MouseDown(Mouse mouse) mouseDownStarty = mouse.y; mouseDown = true; if(!lctrlDown && !rctrlDown) - g_selectedInstances.clear(); + g_dataModel->getSelectionService()->clearSelection(); PartInstance * target = mouse.getTarget(); - if(target != NULL && std::find(g_selectedInstances.begin(), g_selectedInstances.end(), target) == g_selectedInstances.end()) - g_selectedInstances.push_back(target); - if(g_selectedInstances.size() == 0) - g_selectedInstances.push_back(g_dataModel); - g_usableApp->_propWindow->UpdateSelected(g_selectedInstances[0]); + if(target != NULL) + g_dataModel->getSelectionService()->addSelected(target); + if(g_dataModel->getSelectionService()->getSelection().size() == 0) + g_dataModel->getSelectionService()->addSelected(g_dataModel); } void ArrowTool::onButton1MouseUp(Mouse mouse) { @@ -47,11 +47,11 @@ void ArrowTool::onMouseMoved(Mouse mouse) } else return; } - for(size_t i = 0; i < g_selectedInstances.size(); i++) //This will later decide primary and move all parts according to primary + for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++) //This will later decide primary and move all parts according to primary { - if(PartInstance * part = dynamic_cast(g_selectedInstances[i])) + if(PartInstance * part = dynamic_cast(g_dataModel->getSelectionService()->getSelection()[i])) { - part->setPosition(mouse.getPosition(g_selectedInstances)); + part->setPosition(mouse.getPosition(g_dataModel->getSelectionService()->getSelection())); } } return;