Navigation Menu

Skip to content

Commit

Permalink
FIXED issues with setting scenery action scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ksterker committed Jul 26, 2010
1 parent 550b632 commit 2862194
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/mapedit/entity-properties.glade
Expand Up @@ -75,7 +75,7 @@
<property name="title">Location</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1">
<property name="editable">True</property>
<property name="editable">False</property>
</object>
<attributes>
<attribute name="text">0</attribute>
Expand Down
14 changes: 13 additions & 1 deletion src/mapedit/gui_entity_dialog.cc
Expand Up @@ -556,7 +556,11 @@ void GuiEntityDialog::init_from_scenery (world::chunk_info *location)
{
world::action *act = location->get_action();
Selector->init (act->get_method(), act->get_args());
}
}
else
{
Selector->init (NULL, NULL);
}
}

// init values on character page
Expand Down Expand Up @@ -649,6 +653,14 @@ void GuiEntityDialog::setLocations ()
// update location of the entity being edited
void GuiEntityDialog::setLocation (world::chunk_info *location)
{
// update current location with selected values
world::chunk_info *cur_loc = Entity->getLocation();
if (cur_loc != NULL)
{
set_scenery_data (cur_loc);
}

// set new location
Entity->setLocation (location);
init_from_scenery (location);
}
45 changes: 34 additions & 11 deletions src/mapedit/gui_script_selector.cc
Expand Up @@ -44,31 +44,33 @@ static void on_clear_args (gpointer data)
// user selects a different schedule
static void on_script_changed (GtkComboBox *cbox, gpointer user_data)
{
gchar *scrpt_name = NULL;

GtkTreeIter iter;
if (gtk_combo_box_get_active_iter (cbox, &iter))
{
gchar *scrpt_name;
GtkTreeModel *model = gtk_combo_box_get_model (cbox);
gtk_tree_model_get (model, &iter, 0, &scrpt_name, -1);

GuiScriptSelector *selector = (GuiScriptSelector*) user_data;
selector->script_selected (scrpt_name);
}

GuiScriptSelector *selector = (GuiScriptSelector*) user_data;
selector->script_selected (scrpt_name ? scrpt_name : "");
}

// user selects a different method
static void on_method_changed (GtkComboBox *cbox, gpointer user_data)
{
gchar *met_name = NULL;

GtkTreeIter iter;
if (gtk_combo_box_get_active_iter (cbox, &iter))
{
gchar *met_name;
GtkTreeModel *model = gtk_combo_box_get_model (cbox);
gtk_tree_model_get (model, &iter, 0, &met_name, -1);

GuiScriptSelector *selector = (GuiScriptSelector*) user_data;
selector->method_selected (met_name);
}

GuiScriptSelector *selector = (GuiScriptSelector*) user_data;
selector->method_selected (met_name ? met_name : "");
}

// ctor
Expand Down Expand Up @@ -200,7 +202,13 @@ void GuiScriptSelector::init (const python::script *scrpt)

// set argument value(s)
set_arguments (scrpt->get_args());
}
}
else
{
// clear selection
gtk_combo_box_set_active (Script, -1);
update_arg_table (NULL, 0);
}
}

// init from method and arguments
Expand All @@ -217,6 +225,13 @@ void GuiScriptSelector::init (const python::method *met, PyObject *args)
// set argument value(s)
set_arguments (args);
}
else
{
// clear selection
gtk_combo_box_set_active (Script, -1);
gtk_combo_box_set_active (Method, -1);
update_arg_table (NULL, 0);
}
}

// get argument list
Expand All @@ -235,7 +250,7 @@ PyObject *GuiScriptSelector::get_arguments () const
long num_args = PyTuple_GET_SIZE(args);
if (num_args > 0)
{
printf ("*** info: collecting %i argument(s)\n", num_args);
printf ("*** info: collecting %li argument(s)\n", num_args);

GList *children = gtk_container_get_children (Arguments);
while (children != NULL)
Expand All @@ -259,7 +274,7 @@ PyObject *GuiScriptSelector::get_arguments () const
py_val = PyString_FromString(val);
}

PyTuple_SetItem (args, index, py_val);
PyTuple_SET_ITEM (args, index, py_val);
}
}

Expand All @@ -274,6 +289,10 @@ PyObject *GuiScriptSelector::get_arguments () const
void GuiScriptSelector::script_selected (const std::string & name)
{
CurScript = name;
if (CurScript == "")
{
return;
}

if (Method == NULL)
{
Expand Down Expand Up @@ -306,6 +325,10 @@ void GuiScriptSelector::script_selected (const std::string & name)
void GuiScriptSelector::method_selected (const std::string & name)
{
CurMethod = name;
if (CurMethod == "")
{
return;
}

// When a user selects the method, we need to figure out
// if there are additional arguments required to call it
Expand Down

0 comments on commit 2862194

Please sign in to comment.