Update GUDButtonListener.cpp

This commit is contained in:
KeyboardCombination
2023-06-11 18:16:36 -04:00
parent 2a17185cc0
commit 00b165c208

View File

@@ -7,12 +7,12 @@
void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button) void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{ {
SelectionService* getSelectionService = g_dataModel->getSelectionService(); SelectionService* selectionService = g_dataModel->getSelectionService();
SoundService* getSoundService = g_dataModel->getSoundService(); SoundService* soundService = g_dataModel->getSoundService();
bool cont = false; bool cont = false;
for(size_t i = 0; i < getSelectionService->getSelection().size(); i++) for(size_t i = 0; i < selectionService->getSelection().size(); i++)
if(getSelectionService->getSelection()[i]->canDelete) if(selectionService->getSelection()[i]->canDelete)
{ {
cont = true; cont = true;
break; break;
@@ -21,19 +21,19 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
if (cont) if (cont)
{ {
if(button->disabled == false){ if(button->disabled == false){
getSoundService->playSound(getSoundService->findFirstChild("Ping")); soundService->playSound(soundService->findFirstChild("Ping"));
} }
if(button->name == "Duplicate") if(button->name == "Duplicate")
{ {
std::vector<Instance*> newinst; std::vector<Instance*> newinst;
for(size_t i = 0; i < getSelectionService->getSelection().size(); i++) for(size_t i = 0; i < selectionService->getSelection().size(); i++)
{ {
if(getSelectionService->getSelection()[i]->canDelete) if(selectionService->getSelection()[i]->canDelete)
{ {
Instance* tempinst = getSelectionService->getSelection()[i]; Instance* tempinst = selectionService->getSelection()[i];
Instance* clonedInstance = getSelectionService->getSelection()[i]->clone(); Instance* clonedInstance = selectionService->getSelection()[i]->clone();
if (clonedInstance->getClassName() == "PVInstance"){ if (clonedInstance->getClassName() == "PVInstance"){
PartInstance* Part = dynamic_cast<PartInstance*>(clonedInstance); PartInstance* Part = dynamic_cast<PartInstance*>(clonedInstance);
@@ -43,35 +43,35 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
newinst.push_back(clonedInstance); newinst.push_back(clonedInstance);
} }
} }
getSelectionService->clearSelection(); selectionService->clearSelection();
getSelectionService->addSelected(newinst); selectionService->addSelected(newinst);
} }
else if(button->name == "Group") else if(button->name == "Group")
{ {
if (getSelectionService->getSelection().size() > 1){ if (selectionService->getSelection().size() > 1){
GroupInstance * inst = new GroupInstance(); GroupInstance * inst = new GroupInstance();
inst->setParent(g_dataModel->getWorkspace()); inst->setParent(g_dataModel->getWorkspace());
for(size_t i = 0; i < getSelectionService->getSelection().size(); i++) for(size_t i = 0; i < selectionService->getSelection().size(); i++)
{ {
if(getSelectionService->getSelection()[i]->canDelete) if(selectionService->getSelection()[i]->canDelete)
{ {
getSelectionService->getSelection()[i]->setParent(inst); selectionService->getSelection()[i]->setParent(inst);
if(PartInstance* part = dynamic_cast<PartInstance*>(getSelectionService->getSelection()[i])) if(PartInstance* part = dynamic_cast<PartInstance*>(selectionService->getSelection()[i]))
{ {
inst->primaryPart = part; inst->primaryPart = part;
} }
} }
} }
getSelectionService->clearSelection(); selectionService->clearSelection();
getSelectionService->addSelected(inst); selectionService->addSelected(inst);
} }
} }
else if(button->name == "UnGroup") else if(button->name == "UnGroup")
{ {
std::vector<Instance*> newinst; std::vector<Instance*> newinst;
for(size_t i = 0; i < getSelectionService->getSelection().size(); i++) for(size_t i = 0; i < selectionService->getSelection().size(); i++)
{ {
Instance* selection = getSelectionService->getSelection()[i]; Instance* selection = selectionService->getSelection()[i];
if(GroupInstance* model = dynamic_cast<GroupInstance*>(selection)) if(GroupInstance* model = dynamic_cast<GroupInstance*>(selection))
{ {
@@ -81,8 +81,8 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
model = NULL; model = NULL;
} }
} }
getSelectionService->clearSelection(); selectionService->clearSelection();
getSelectionService->addSelected(newinst); selectionService->addSelected(newinst);
} }
} }
} }