/* MOPGIntWithArgsProperty::applyValue * Applies the current property value to all objects currently open * in the parent MapObjectPropsPanel, if a value is specified *******************************************************************/ void MOPGIntWithArgsProperty::applyValue() { // Do nothing if no parent (and thus no object list) if (!parent || noupdate) return; // Do nothing if the value is unspecified if (IsValueUnspecified()) return; // Initialize any unset and meaningful args to 0 const argspec_t argspec = getArgspec(); // Go through objects and set this value vector<MapObject*>& objects = parent->getObjects(); for (unsigned a = 0; a < objects.size(); a++) { objects[a]->setIntProperty(GetName(), m_value.GetInteger()); for (int argn = 0; argn < argspec.count; argn++) { string key = S_FMT("arg%d", argn); if (! objects[a]->hasProp(key)) objects[a]->setIntProperty(key, 0); } } }
/* MOPGIntWithArgsProperty::updateArgs() * Update the UI to show the names of the arguments for the current special or * thing type, and hide those that don't have names. *******************************************************************/ void MOPGIntWithArgsProperty::updateArgs(wxPGProperty* args[5]) { argspec_t argspec = getArgspec(); int default_value = 0; unsigned argcount; if (udmf_prop) default_value = udmf_prop->getDefaultValue().getIntValue(); if (parent->showAll()) argcount = 5; else if (IsValueUnspecified()) argcount = 0; else argcount = argspec.count; for (unsigned a = 0; a < 5; a++) { if (! args[a]) continue; if (IsValueUnspecified()) { args[a]->SetLabel(S_FMT("Arg%d", a+1)); args[a]->SetHelpString(""); } else { args[a]->SetLabel(argspec.getArg(a).name); args[a]->SetHelpString(argspec.getArg(a).desc); } // Show any args that this special uses, hide the others, but never // hide an arg with a value args[a]->Hide( a >= argcount && ! args[a]->IsValueUnspecified() && args[a]->GetValue().GetInteger() == default_value ); } }
void MOPGSectorSpecialProperty::applyValue() { // Do nothing if no parent (and thus no object list) if (!parent || noupdate) return; // Do nothing if the value is unspecified if (IsValueUnspecified()) return; // Go through objects and set this value vector<MapObject*>& objects = parent->getObjects(); for (unsigned a = 0; a < objects.size(); a++) objects[a]->setIntProperty(GetName(), m_value.GetInteger()); }
void MOPGThingFlagProperty::applyValue() { // Do nothing if no parent (and thus no object list) if (!parent || noupdate) return; // Do nothing if the value is unspecified if (IsValueUnspecified()) return; // Go through objects and set this value vector<MapObject*>& objects = parent->getObjects(); for (unsigned a = 0; a < objects.size(); a++) theGameConfiguration->setThingFlag(index, (MapThing*)objects[a], GetValue()); }
/* MOPGAngleProperty::updateVisibility * Default to hiding this property if set to its default value. *******************************************************************/ void MOPGAngleProperty::updateVisibility() { if ( !parent->showAll() && !IsValueUnspecified() && udmf_prop && !udmf_prop->showAlways() && udmf_prop->getDefaultValue().getIntValue() == GetValue().GetInteger() ) Hide(true); else Hide(false); }
void MOPGSPACTriggerProperty::applyValue() { // Do nothing if no parent (and thus no object list) if (!parent || noupdate) return; // Do nothing if the value is unspecified if (IsValueUnspecified()) return; // Go through objects and set this value vector<MapObject*>& objects = parent->getObjects(); for (unsigned a = 0; a < objects.size(); a++) theGameConfiguration->setLineSpacTrigger(GetChoiceSelection(), (MapLine*)objects[a]); //objects[a]->setIntProperty(GetName(), m_value.GetInteger()); }
void MOPGColourProperty::applyValue() { // Do nothing if no parent (and thus no object list) if (!parent || noupdate) return; // Do nothing if the value is unspecified if (IsValueUnspecified()) return; // Go through objects and set this value vector<MapObject*>& objects = parent->getObjects(); wxColor col; col << m_value; col.Set(col.Blue(), col.Green(), col.Red()); for (unsigned a = 0; a < objects.size(); a++) objects[a]->setIntProperty(GetName(), col.GetRGB()); }
bool MOPGTextureProperty::OnEvent(wxPropertyGrid* propgrid, wxWindow* window, wxEvent& e) { if (e.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED) { // Get current texture (if any) string tex_current = ""; if (!IsValueUnspecified()) tex_current = GetValueAsString(); // Open map texture browser MapTextureBrowser browser(theMapEditor, textype, tex_current); if (browser.ShowModal() == wxID_OK && browser.getSelectedItem()) SetValue(browser.getSelectedItem()->getName()); // Refresh text RefreshEditor(); } return wxStringProperty::OnEvent(propgrid, window, e); }
bool MOPGThingTypeProperty::OnEvent(wxPropertyGrid* propgrid, wxWindow* window, wxEvent& e) { if (e.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED) { // Get type to select initially (if any) int init_type = -1; if (!IsValueUnspecified()) init_type = GetValue().GetInteger(); // Open thing browser ThingTypeBrowser browser(theMapEditor, init_type); if (browser.ShowModal() == wxID_OK) { // Set the value if a type was selected int type = browser.getSelectedType(); if (type >= 0) SetValue(type); } } return wxIntProperty::OnEvent(propgrid, window, e); }
/* MOPGTextureProperty::OnEvent * Called when an event is raised for the control *******************************************************************/ bool MOPGTextureProperty::OnEvent(wxPropertyGrid* propgrid, wxWindow* window, wxEvent& e) { // '...' button clicked if (e.GetEventType() == wxEVT_BUTTON) { // Get current texture (if any) string tex_current = ""; if (!IsValueUnspecified()) tex_current = GetValueAsString(); // Open map texture browser MapTextureBrowser browser(theMapEditor, textype, tex_current, &(theMapEditor->mapEditor().getMap())); if (browser.ShowModal() == wxID_OK && browser.getSelectedItem()) GetGrid()->ChangePropertyValue(this, browser.getSelectedItem()->getName()); // Refresh text RefreshEditor(); } return wxStringProperty::OnEvent(propgrid, window, e); }