Merge pull request #78 from Vulpovile/bugfix/fix-broken-delete
Fix broken delete
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
version="0.0.106.1"
|
||||
version="0.0.106.2"
|
||||
processorArchitecture="*"
|
||||
name="Blocks3D.Blocks3D.Blocks3D"
|
||||
type="win32"
|
||||
|
||||
19
Dialogs.rc
19
Dialogs.rc
@@ -7,6 +7,17 @@
|
||||
#include <richedit.h>
|
||||
#include "src/include/resource.h"
|
||||
|
||||
#define APP_GENER 0
|
||||
#define APP_MAJOR 0
|
||||
#define APP_MINOR 106
|
||||
#define APP_PATCH 2
|
||||
#define APP_VER_STRING APP_GENER.APP_MAJOR.APP_MINOR.APP_PATCH
|
||||
|
||||
#define VER_PREFIX( N ) v##N
|
||||
#define HSTR( N ) #N
|
||||
#define STR( N ) HSTR( N )
|
||||
#define VER_STR( N ) STR( VER_PREFIX( N ) )
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,8 +29,8 @@ IDB_BITMAP1 BITMAP "Parts.bmp"
|
||||
|
||||
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 0,0,106,1
|
||||
PRODUCTVERSION 0,0,106,1
|
||||
FILEVERSION APP_GENER,APP_MAJOR,APP_MINOR,APP_PATCH
|
||||
PRODUCTVERSION APP_GENER,APP_MAJOR,APP_MINOR,APP_PATCH
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
@@ -33,14 +44,14 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||
VALUE "Comments", ""
|
||||
VALUE "CompanyName", "Blocks3D Team"
|
||||
VALUE "FileDescription", "Blocks 3D"
|
||||
VALUE "FileVersion", "v0.0.106.1"
|
||||
VALUE "FileVersion", VER_STR(APP_VER_STRING)
|
||||
VALUE "InternalName", "Blocks3D"
|
||||
VALUE "LegalCopyright", "Blocks3D Team - 2022"
|
||||
VALUE "LegalTrademarks", ""
|
||||
VALUE "OriginalFilename", "Blocks3D.exe"
|
||||
VALUE "PrivateBuild", ""
|
||||
VALUE "ProductName", "Blocks3D"
|
||||
VALUE "ProductVersion", "v0.0.106.1"
|
||||
VALUE "ProductVersion", VER_STR(APP_VER_STRING)
|
||||
VALUE "SpecialBuild", ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "DataModelV2/Instance.h"
|
||||
#include <set>
|
||||
|
||||
class PropertyWindow {
|
||||
public:
|
||||
@@ -15,4 +14,5 @@ private:
|
||||
HWND _propGrid;
|
||||
HWND _explorerComboBox;
|
||||
void _resize();
|
||||
void clearExplorer();
|
||||
};
|
||||
@@ -161,22 +161,23 @@ void Application::deleteInstance()
|
||||
{
|
||||
if(_dataModel->getSelectionService()->getSelection().size() > 0)
|
||||
{
|
||||
size_t undeletable = 0;
|
||||
while(_dataModel->getSelectionService()->getSelection().size() > undeletable)
|
||||
std::vector<Instance *> selection = _dataModel->getSelectionService()->getSelection();
|
||||
std::vector<Instance *> toDelete;
|
||||
for(size_t i = 0; i < selection.size(); i++) {
|
||||
if(selection[i]->canDelete) {
|
||||
toDelete.push_back(selection[i]);
|
||||
}
|
||||
}
|
||||
if(toDelete.size() > 0)
|
||||
{
|
||||
if(_dataModel->getSelectionService()->getSelection()[0]->canDelete)
|
||||
{
|
||||
AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav"));
|
||||
Instance* selectedInstance = g_dataModel->getSelectionService()->getSelection()[0];
|
||||
_dataModel->getSelectionService()->removeChild(selectedInstance);
|
||||
AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav"));
|
||||
for(size_t i = 0; i < toDelete.size(); i++) {
|
||||
Instance* selectedInstance = toDelete[i];
|
||||
_dataModel->getSelectionService()->removeSelected(selectedInstance);
|
||||
selectedInstance->setParent(NULL);
|
||||
delete selectedInstance;
|
||||
selectedInstance = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
undeletable++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_dataModel->getSelectionService()->getSelection().size() == 0)
|
||||
|
||||
@@ -21,6 +21,7 @@ void SelectionService::clearSelection(){
|
||||
this->selection.clear();
|
||||
if(propertyWindow != NULL)
|
||||
propertyWindow->ClearProperties();
|
||||
printf("selectionSize: %d\n", selection.size());
|
||||
}
|
||||
bool SelectionService::isSelected(Instance * instance){
|
||||
return std::find(selection.begin(), selection.end(), instance) != selection.end();
|
||||
@@ -30,11 +31,13 @@ void SelectionService::addSelected(Instance * instance){
|
||||
this->selection.push_back(instance);
|
||||
if(propertyWindow != NULL)
|
||||
propertyWindow->UpdateSelected(selection);
|
||||
printf("selectionSize: %d\n", selection.size());
|
||||
}
|
||||
void SelectionService::removeSelected(Instance * instance){
|
||||
selection.erase(std::remove(selection.begin(), selection.end(), instance), selection.end());
|
||||
if(propertyWindow != NULL)
|
||||
propertyWindow->UpdateSelected(selection);
|
||||
printf("selectionSize: %d\n", selection.size());
|
||||
}
|
||||
void SelectionService::addSelected(const std::vector<Instance *> &instances){
|
||||
for(size_t i = 0; i < instances.size(); i++)
|
||||
@@ -44,10 +47,12 @@ void SelectionService::addSelected(const std::vector<Instance *> &instances){
|
||||
}
|
||||
if(propertyWindow != NULL)
|
||||
propertyWindow->UpdateSelected(selection);
|
||||
printf("selectionSize: %d\n", selection.size());
|
||||
}
|
||||
void SelectionService::setPropertyWindow(PropertyWindow * propertyWindow)
|
||||
{
|
||||
this->propertyWindow = propertyWindow;
|
||||
if(propertyWindow != NULL)
|
||||
propertyWindow->ClearProperties();
|
||||
printf("selectionSize: %d\n", selection.size());
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "WindowFunctions.h"
|
||||
#include "resource.h"
|
||||
#include "PropertyWindow.h"
|
||||
#include "Globals.h"
|
||||
#include "strsafe.h"
|
||||
#include "Application.h"
|
||||
|
||||
@@ -203,6 +202,12 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PropertyWindow::clearExplorer()
|
||||
{
|
||||
SendMessage(_explorerComboBox,CB_RESETCONTENT,0,0);
|
||||
SendMessage(_explorerComboBox,CB_SETCURSEL,0,(LPARAM)0);
|
||||
}
|
||||
|
||||
void PropertyWindow::refreshExplorer(std::vector<Instance*> selectedInstances)
|
||||
{
|
||||
Instance * instance = selectedInstances[0];
|
||||
@@ -367,12 +372,6 @@ void PropertyWindow::UpdateSelected(std::vector<Instance *> instances)
|
||||
|
||||
void PropertyWindow::ClearProperties()
|
||||
{
|
||||
if(g_dataModel != NULL)
|
||||
{
|
||||
g_dataModel->getSelectionService()->addSelected(g_dataModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
PropGrid_ResetContent(_propGrid);
|
||||
}
|
||||
clearExplorer();
|
||||
PropGrid_ResetContent(_propGrid);
|
||||
}
|
||||
Reference in New Issue
Block a user