Made instances call parent function on properties, Deselecting everything opens Datamodel in the property grid

Instances now call the parent method after setting/getting properties,
Made delete no longer delete workspace
This commit is contained in:
andreja6
2018-10-24 09:55:49 -07:00
parent 1159be9b1b
commit 70fba67b6e
3 changed files with 27 additions and 26 deletions

View File

@@ -45,7 +45,7 @@ void Instance::PropUpdate(LPPROPGRIDITEM &item)
{
if(strcmp(item->lpszPropName, "Name") == 0)
{
name = item->lpCurValue;
name = (LPSTR)item->lpCurValue;
}
}

View File

@@ -218,11 +218,7 @@ char pto2[512];
void PhysicalInstance::PropUpdate(LPPROPGRIDITEM &item)
{
if(strcmp(item->lpszPropName, "Name") == 0)
{
name = (LPTSTR)item->lpCurValue;
}
else if(strcmp(item->lpszPropName, "Color3") == 0)
if(strcmp(item->lpszPropName, "Color3") == 0)
{
color = Color3(GetRValue(item->lpCurValue)/255.0F,GetGValue(item->lpCurValue)/255.0F,GetBValue(item->lpCurValue)/255.0F);
}
@@ -283,21 +279,15 @@ void PhysicalInstance::PropUpdate(LPPROPGRIDITEM &item)
setSize(size);
}
}
else Instance::PropUpdate(item);
}
std::vector<PROPGRIDITEM> PhysicalInstance::getProperties()
{
std::vector<PROPGRIDITEM> properties;
std::vector<PROPGRIDITEM> properties = Instance::getProperties();
properties.push_back(createPGI(
"Properties",
"Name",
"The name of this instance",
(LPARAM)name.c_str(),
PIT_EDIT
));
properties.push_back(createPGI(
"Properties",
"Color3",

View File

@@ -295,17 +295,26 @@ void deleteInstance()
{
if(g_selectedInstances.size() > 0)
{
while(g_selectedInstances.size() > 0)
int undeletable = 0;
while(g_selectedInstances.size() > undeletable)
{
if(g_selectedInstances.at(0) != dataModel && g_selectedInstances.at(0) != dataModel->getWorkspace())
{
AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav"));
Instance* selectedInstance = g_selectedInstances.at(0);
if(selectedInstance->getParent() != NULL)
selectedInstance->getParent()->removeChild(selectedInstance);
delete selectedInstance;
selectedInstance = NULL;
g_selectedInstances.erase(g_selectedInstances.begin());
AudioPlayer::playSound(GetFileInPath("/content/sounds/pageturn.wav"));
}
else
{
undeletable++;
}
}
}
if(g_selectedInstances.size() == 0)
usableApp->_propWindow->ClearProperties();
}
@@ -829,7 +838,7 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
if(obj != NULL)
{
ImageButtonInstance* button = (ImageButtonInstance*)obj;
if(g_selectedInstances.size() <= 0)
if(g_selectedInstances.size() <= 0 || g_selectedInstances.at(0) == dataModel->getWorkspace())
button->disabled = true;
else
button->disabled = false;
@@ -1308,7 +1317,9 @@ void Demo::onMouseLeftPressed(HWND hwnd,int x,int y)
{
while(g_selectedInstances.size() > 0)
g_selectedInstances.erase(g_selectedInstances.begin());
_propWindow->ClearProperties();
g_selectedInstances.push_back(dataModel->getWorkspace());
_propWindow->SetProperties(dataModel->getWorkspace());
}
}
}