summaryrefslogtreecommitdiff
path: root/src/game/PropertyTool.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-03 11:52:07 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-03 11:52:07 (GMT)
commit347c382e9964ef7954246399ab9d96df43dcbff0 (patch)
treef720da533d4b129290e29d7e4c935ace41b68c57 /src/game/PropertyTool.cpp
parenta3ebfb0ffde9c4ec9db5ace2e15968065c744cde (diff)
downloadpowder-347c382e9964ef7954246399ab9d96df43dcbff0.zip
powder-347c382e9964ef7954246399ab9d96df43dcbff0.tar.gz
Allow PROP to set types from element name, fixes issue #48
Diffstat (limited to 'src/game/PropertyTool.cpp')
-rw-r--r--src/game/PropertyTool.cpp45
1 files changed, 38 insertions, 7 deletions
diff --git a/src/game/PropertyTool.cpp b/src/game/PropertyTool.cpp
index bddce44..4a04996 100644
--- a/src/game/PropertyTool.cpp
+++ b/src/game/PropertyTool.cpp
@@ -49,11 +49,13 @@ position(position_)
ui::Label * messageLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "Edit property");
messageLabel->SetTextColour(style::Colour::InformationTitle);
- messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
+ messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
+ messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
AddComponent(messageLabel);
ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 17), "OK");
- okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; okayButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
+ okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
+ okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
okayButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);
okayButton->SetActionCallback(new OkayAction(this));
AddComponent(okayButton);
@@ -66,15 +68,16 @@ position(position_)
}
property->SetOption(0);
- textField = new ui::Textbox(ui::Point(8, 46), ui::Point(Size.X-16, 16), "");
- textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; textField->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
+ textField = new ui::Textbox(ui::Point(8, 46), ui::Point(Size.X-16, 16), "", "[value]");
+ textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
+ textField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(textField);
ui::Engine::Ref().ShowWindow(this);
}
void PropertyWindow::SetProperty()
{
- if(property->GetOption().second!=-1)
+ if(property->GetOption().second!=-1 && textField->GetText().length() > 0)
{
void * propValue;
int tempInt;
@@ -102,8 +105,29 @@ void PropertyWindow::SetProperty()
}
else
{
- istringstream(value) >> tempInt;
+ if(properties[property->GetOption().second].Type == StructProperty::ParticleType)
+ {
+ int type = sim->GetParticleType(value);
+ if(type != -1)
+ {
+#ifdef DEBUG
+ std::cout << "Got type from particle name" << std::endl;
+#endif
+ tempInt = type;
+ }
+ else
+ {
+ stringstream(value) >> tempInt;
+ }
+ }
+ else
+ {
+ stringstream(value) >> tempInt;
+ }
}
+#ifdef DEBUG
+ std::cout << "Got int value " << tempInt << std::endl;
+#endif
propValue = &tempInt;
break;
case StructProperty::UInteger:
@@ -123,12 +147,18 @@ void PropertyWindow::SetProperty()
}
else
{
- istringstream(value) >> tempUInt;
+ stringstream(value) >> tempUInt;
}
+#ifdef DEBUG
+ std::cout << "Got uint value " << tempUInt << std::endl;
+#endif
propValue = &tempUInt;
break;
case StructProperty::Float:
istringstream(value) >> tempFloat;
+#ifdef DEBUG
+ std::cout << "Got float value " << tempFloat << std::endl;
+#endif
propValue = &tempFloat;
break;
default:
@@ -146,6 +176,7 @@ void PropertyWindow::SetProperty()
}
}
}
+
void PropertyWindow::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;