+ if ((strlen(dir) == 0) || !stricmp(dir,"valve"))
+ {
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sHLComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), "");
+ gtk_widget_set_sensitive(game, false);
+ }
+ else
+ {
+ // this is a custom mod
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sHLModComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), dir);
+ gtk_widget_set_sensitive(game, true);
+ }
+ }
+ // RIANT
+ // JK2 HACK
+ else if (g_pGameDescription->mGameFile == "jk2.game")
+ {
+ if ((strlen(dir) == 0) || !stricmp(dir,"base"))
+ {
+ // no fs_game set, we are running stock Quake III Arena editing
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sJK2ComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), "");
+ gtk_widget_set_sensitive(game, false);
+ }
+ else
+ {
+ // this is a custom mod
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sJK2ModComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), dir);
+ gtk_widget_set_sensitive(game, true);
+ }
+ }
+ // TTimo
+ // JA HACK
+ else if (g_pGameDescription->mGameFile == "ja.game")
+ {
+ if ((strlen(dir) == 0) || !stricmp(dir,"base"))
+ {
+ // no fs_game set, we are running stock editing
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sJAComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), "");
+ gtk_widget_set_sensitive(game, false);
+ }
+ else
+ {
+ // this is a custom mod
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sJAModComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), dir);
+ gtk_widget_set_sensitive(game, true);
+ }
+ }
+ // RIANT
+ // STVEF2 HACK
+ else if (g_pGameDescription->mGameFile == "stvef.game")
+ {
+ if ((strlen(dir) == 0) || !stricmp(dir,"baseEf"))
+ {
+ // no fs_game set, we are running stock Quake III Arena editing
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sSTVEFComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), "");
+ gtk_widget_set_sensitive(game, false);
+ }
+ else
+ {
+ // this is a custom mod
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sSTVEFModComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), dir);
+ gtk_widget_set_sensitive(game, true);
+ }
+ }
+ // RIANT
+ // SOF2 HACK
+ else if (g_pGameDescription->mGameFile == "sof2.game")
+ {
+ if ((strlen(dir) == 0) || !stricmp(dir,"base"))
+ {
+ // no fs_game set, we are running stock Quake III Arena editing
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sSOF2ComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), "");
+ gtk_widget_set_sensitive(game, false);
+ }
+ else
+ {
+ // this is a custom mod
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sSOF2ModComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), dir);
+ gtk_widget_set_sensitive(game, true);
+ }
+ }
+ else
+ {
+ if ((strlen(dir) == 0) || !strcmp(dir,"baseq3"))
+ {
+ // no fs_game set, we are running stock Quake III Arena editing
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sQ3ComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), "");
+ gtk_widget_set_sensitive(game, false);
+ }
+ else if (!strcmp(dir,"missionpack"))
+ {
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sTAComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), "missionpack");
+ gtk_widget_set_sensitive(game, false);
+ }
+ else
+ {
+ // this is a custom mod
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sModComboItem);
+ gtk_entry_set_text (GTK_ENTRY (game), dir);
+ gtk_widget_set_sensitive(game, true);
+ }
+ }
+
+ // HACK: hardcoded wolf stuff
+ if (g_pGameDescription->mGameFile == "wolf.game")
+ {
+ const char *gamemode = ValueForKey (g_qeglobals.d_project_entity, "gamemode");
+ if ((strlen(gamemode) == 0) || !strcmp(gamemode,"sp"))
+ {
+ // nothing set yet, or single player
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sWolfSPCombo);
+ }
+ else
+ {
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sWolfMPCombo);
+ }
+ }
+
+ // JK2 HACK
+ else if (g_pGameDescription->mGameFile == "jk2.game")
+ {
+ const char *gamemode = ValueForKey (g_qeglobals.d_project_entity, "gamemode");
+ if ((strlen(gamemode) == 0) || !strcmp(gamemode,"sp"))
+ {
+ // nothing set yet, or single player
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sJK2SPCombo);
+ }
+ else
+ {
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sJK2MPCombo);
+ }
+ }
+ // JA HACK
+ else if (g_pGameDescription->mGameFile == "ja.game")
+ {
+ const char *gamemode = ValueForKey (g_qeglobals.d_project_entity, "gamemode");
+ if ((strlen(gamemode) == 0) || !strcmp(gamemode,"sp"))
+ {
+ // nothing set yet, or single player
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sJASPCombo);
+ }
+ else
+ {
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sJAMPCombo);
+ }
+ }
+ // STVEF HACK
+ else if (g_pGameDescription->mGameFile == "stvef.game")
+ {
+ const char *gamemode = ValueForKey (g_qeglobals.d_project_entity, "gamemode");
+ if ((strlen(gamemode) == 0) || !strcmp(gamemode,"sp"))
+ {
+ // nothing set yet, or single player
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sSTVEFSPCombo);
+ }
+ else
+ {
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sSTVEFMPCombo);
+ }
+ }
+ // SOF2 HACK
+ else if (g_pGameDescription->mGameFile == "sof2.game")
+ {
+ const char *gamemode = ValueForKey (g_qeglobals.d_project_entity, "gamemode");
+ if ((strlen(gamemode) == 0) || !strcmp(gamemode,"sp"))
+ {
+ // nothing set yet, or single player
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sSOF2SPCombo);
+ }
+ else
+ {
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sSOF2MPCombo);
+ }
+ }
+
+ gtk_grab_add (project);
+ gtk_widget_show (project);
+
+ g_pGameDescription->Dump();
+
+ while (loop)
+ gtk_main_iteration ();
+
+ if (ret == IDOK)
+ {
+ char buf[1024];
+ const char *r;
+ char *w;
+
+ // convert path to unix format
+ for(r = gtk_entry_get_text (GTK_ENTRY (base)), w=buf; *r != '\0'; r++, w++)
+ *w = (*r == '\\') ? '/' : *r;
+ // add last slash
+ if(w != buf && *(w-1) != '/') *(w++) = '/';
+ // terminate string
+ *w = '\0';
+ SetKeyValue (g_qeglobals.d_project_entity, "basepath", buf);
+
+ dir = gtk_entry_get_text (GTK_ENTRY (game));
+ // Hack: hard coded wolf stuff
+ if (g_pGameDescription->mGameFile == "wolf.game")
+ {
+ if (!strlen(dir) || !stricmp(dir,"main"))
+ {
+ DeleteKey (g_qeglobals.d_project_entity, "gamename");
+ }
+ else
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
+ }
+ }
+ // Hack: hard coded ET stuff
+ else if (g_pGameDescription->mGameFile == "et.game")
+ {
+ if (!strlen(dir) || !stricmp(dir,"etmain"))
+ {
+ DeleteKey (g_qeglobals.d_project_entity, "gamename");
+ }
+ else
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
+ }
+ }
+ // Hack: hard coded Half-life stuff
+ else if (g_pGameDescription->mGameFile == "hl.game")
+ {
+ if (!strlen(dir) || !stricmp(dir,"valve"))
+ {
+ DeleteKey (g_qeglobals.d_project_entity, "gamename");
+ }
+ else
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
+ }
+ }
+ else if (g_pGameDescription->mGameFile == "jk2.game" || g_pGameDescription->mGameFile == "ja.game")
+ {
+ if (!strlen(dir) || !stricmp(dir,"base"))
+ {
+ DeleteKey (g_qeglobals.d_project_entity, "gamename");
+ }
+ else
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
+ }
+ }
+ // RIANT
+ // STVEF HACK
+ else if (g_pGameDescription->mGameFile == "stvef.game")
+ {
+ if (!strlen(dir) || !stricmp(dir,"baseEf"))
+ {
+ DeleteKey (g_qeglobals.d_project_entity, "gamename");
+ }
+ else
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
+ }
+ }
+ else
+ {
+ if (!strlen(dir) || !strcmp(dir,"baseq3"))
+ {
+ DeleteKey (g_qeglobals.d_project_entity, "gamename");
+ }
+ else
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
+ }
+ }
+
+ // HACK: hardcoded wolf stuff
+ if (g_pGameDescription->mGameFile == "wolf.game")
+ {
+ // read from gamemode_combo
+ const char *gamemode = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(gamemode_combo)->entry));
+ if (!strlen(gamemode) || !strcmp(gamemode, sWolfSPCombo))
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "sp");
+ }
+ else
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "mp");
+ }
+ }
+
+ // RIANT
+ // JK2 HACK
+ if (g_pGameDescription->mGameFile == "jk2.game")
+ {
+ // read from gamemode_combo
+ const char *gamemode = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(gamemode_combo)->entry));
+ if (!strlen(gamemode) || !strcmp(gamemode, sJK2SPCombo))
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "sp");
+ }
+ else
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "mp");
+ }
+ }
+ // TTimo
+ // JA HACK
+ if (g_pGameDescription->mGameFile == "ja.game")
+ {
+ // read from gamemode_combo
+ const char *gamemode = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(gamemode_combo)->entry));
+ if (!strlen(gamemode) || !strcmp(gamemode, sJASPCombo))
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "sp");
+ }
+ else
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "mp");
+ }
+ }
+
+ // RIANT
+ // STVEF HACK
+ if (g_pGameDescription->mGameFile == "stvef.game")
+ {
+ // read from gamemode_combo
+ const char *gamemode = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(gamemode_combo)->entry));
+ if (!strlen(gamemode) || !strcmp(gamemode, sSTVEFSPCombo))
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "sp");
+ }
+ else
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "mp");
+ }
+ }
+
+ g_qeglobals.m_strHomeMaps = g_qeglobals.m_strHomeGame;
+ const char* str = ValueForKey(g_qeglobals.d_project_entity, "gamename");
+ if(str[0] == '\0') str = g_pGameDescription->mBaseGame.GetBuffer();
+ g_qeglobals.m_strHomeMaps += str;
+ g_qeglobals.m_strHomeMaps += '/';
+
+ // RIANT
+ // SOF2 HACK
+ if (g_pGameDescription->mGameFile == "sof2.game")
+ {
+ // read from gamemode_combo
+ const char *gamemode = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(gamemode_combo)->entry));
+ if (!strlen(gamemode) || !strcmp(gamemode, sSOF2SPCombo))
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "sp");
+ }
+ else
+ {
+ SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "mp");
+ }
+ }
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (brush)))
+ g_qeglobals.m_bBrushPrimitMode = TRUE;
+ else
+ g_qeglobals.m_bBrushPrimitMode = FALSE;
+
+ SetKeyValue(g_qeglobals.d_project_entity, "brush_primit", (g_qeglobals.m_bBrushPrimitMode ? "1" : "0" ));
+
+ QE_SaveProject( g_PrefsDlg.m_strLastProject.GetBuffer() );
+ }
+
+ gtk_grab_remove (project);
+ gtk_widget_destroy (project);
+}
+
+// =============================================================================
+// MapInfo dialog
+
+void DoMapInfo ()
+{
+ static GtkWidget *dlg;
+ GtkWidget *vbox, *vbox2, *hbox, *table, *button, *label, *scr;
+ GtkWidget *brushes_entry, *entities_entry, *net_entry;
+ int loop = 1, ret = IDCANCEL;
+
+ if (dlg != NULL)
+ return;
+
+ dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ load_window_pos(dlg, g_PrefsDlg.mWindowInfo.posMapInfoWnd);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), "Map Info");
+ gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
+ GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
+ gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
+ g_object_set_data (G_OBJECT (dlg), "loop", &loop);
+ g_object_set_data (G_OBJECT (dlg), "ret", &ret);
+
+ vbox = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox);
+ gtk_container_add (GTK_CONTAINER (dlg), vbox);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+
+ table = gtk_table_new (3, 2, FALSE);
+ gtk_widget_show (table);
+ gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
+ gtk_table_set_row_spacings (GTK_TABLE (table), 5);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 5);
+
+ brushes_entry = gtk_entry_new ();
+ gtk_widget_show (brushes_entry);
+ gtk_table_attach (GTK_TABLE (table), brushes_entry, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_editable (GTK_ENTRY (brushes_entry), FALSE);
+
+ entities_entry = gtk_entry_new ();
+ gtk_widget_show (entities_entry);
+ gtk_table_attach (GTK_TABLE (table), entities_entry, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_editable (GTK_ENTRY (entities_entry), FALSE);
+
+ net_entry = gtk_entry_new ();
+ gtk_widget_show (net_entry);
+ gtk_table_attach (GTK_TABLE (table), net_entry, 1, 2, 2, 3,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_editable (GTK_ENTRY (net_entry), FALSE);
+
+ label = gtk_label_new ("Total Brushes");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ label = gtk_label_new ("Total Entities");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ label = gtk_label_new ("Net brush count\n(non entity)");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ vbox2 = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox2);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
+
+ button = gtk_button_new_with_label ("Close");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
+ gtk_widget_set_usize (button, 60, -2);
+
+ label = gtk_label_new ("Entity breakdown");
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ scr = gtk_scrolled_window_new ((GtkAdjustment*)NULL, (GtkAdjustment*)NULL);
+ gtk_widget_show (scr);
+ gtk_box_pack_start (GTK_BOX (vbox), scr, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (scr), 5);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scr), GTK_SHADOW_IN);
+
+ GtkListStore* store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+
+ {
+ GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+ gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(view), TRUE);
+
+ {
+ GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
+ GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Entity", renderer, "text", 0, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
+ gtk_tree_view_column_set_sort_column_id(column, 0);
+ }
+
+ {
+ GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
+ GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Count", renderer, "text", 1, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
+ gtk_tree_view_column_set_sort_column_id(column, 1);
+ }
+
+ gtk_widget_show(view);
+
+ gtk_container_add(GTK_CONTAINER (scr), view);
+ }
+
+ // Initialize fields
+ int TotalBrushes = 0, TotalEntities = 0, Net = 0;
+
+ for (brush_t* pBrush = active_brushes.next; pBrush != &active_brushes; pBrush = pBrush->next)
+ {
+ TotalBrushes++;
+ if (pBrush->owner == world_entity)
+ Net++;
+ }
+
+ typedef struct
+ {
+ const char *name;
+ int count;
+ } map_t;
+
+ GSList *l, *entitymap = NULL;
+ map_t *entry;
+
+ for (entity_t* pEntity = entities.next; pEntity != &entities; pEntity=pEntity->next)
+ {
+ TotalEntities++;
+ bool add = true;
+
+ for (l = entitymap; l; l = g_slist_next (l))
+ {
+ entry = (map_t*)l->data;
+
+ if (strcmp (entry->name, pEntity->eclass->name) == 0)
+ {
+ entry->count++;
+ add = false;
+ break;
+ }
+ }
+
+ if (add)
+ {
+ entry = (map_t*)qmalloc (sizeof (map_t));
+ entry->name = pEntity->eclass->name;
+ entry->count = 1;
+ entitymap = g_slist_append (entitymap, entry);
+ }
+ }
+
+ while (entitymap)
+ {
+ entry = (map_t*)entitymap->data;
+ char tmp[16];
+ sprintf (tmp, "%d", entry->count);
+ GtkTreeIter iter;
+ gtk_list_store_append(GTK_LIST_STORE(store), &iter);
+ gtk_list_store_set(GTK_LIST_STORE(store), &iter, 0, entry->name, 1, tmp, -1);
+ free (entry);
+ entitymap = g_slist_remove (entitymap, entry);
+ }
+
+ g_object_unref(G_OBJECT(store));
+
+ char tmp[16];
+ sprintf (tmp, "%d", TotalBrushes);
+ gtk_entry_set_text (GTK_ENTRY (brushes_entry), tmp);
+ sprintf (tmp, "%d", TotalEntities);
+ gtk_entry_set_text (GTK_ENTRY (entities_entry), tmp);
+ sprintf (tmp, "%d", Net);
+ gtk_entry_set_text (GTK_ENTRY (net_entry), tmp);
+
+ gtk_grab_add (dlg);
+ gtk_widget_show (dlg);
+
+ while (loop)
+ gtk_main_iteration ();
+
+ // save before exit
+ save_window_pos(dlg, g_PrefsDlg.mWindowInfo.posMapInfoWnd);
+
+ gtk_grab_remove (dlg);
+ gtk_widget_destroy (dlg);
+ dlg = NULL;
+}
+
+// =============================================================================
+// Entity List dialog
+
+static void entitylist_select (GtkWidget *widget, gpointer data)
+{
+ GtkTreeView* view = GTK_TREE_VIEW(g_object_get_data (G_OBJECT (data), "entities"));
+
+ GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
+
+ GtkTreeModel* model;
+ GtkTreeIter selected;
+ if(gtk_tree_selection_get_selected(selection, &model, &selected))
+ {
+ entity_t* pEntity;
+ gtk_tree_model_get(model, &selected, 1, &pEntity, -1);
+
+ if (pEntity)
+ {
+ for (epair_t* pEpair = pEntity->epairs; pEpair; pEpair = pEpair->next)
+ {
+ Select_Deselect ();
+ Select_Brush (pEntity->brushes.onext);
+ Sys_UpdateWindows(W_ALL);
+ }
+ }
+ }
+}
+
+static gint entitylist_click (GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+ if (event->type == GDK_2BUTTON_PRESS)
+ {
+ entitylist_select (NULL, data);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void entitylist_selection_changed(GtkTreeSelection* selection, gpointer data)
+{
+ GtkListStore* store = GTK_LIST_STORE (g_object_get_data (G_OBJECT (data), "keyvalues"));
+
+ gtk_list_store_clear(store);
+
+ GtkTreeModel* model;
+ GtkTreeIter selected;
+ if(gtk_tree_selection_get_selected(selection, &model, &selected))
+ {
+ entity_t* pEntity;
+ gtk_tree_model_get(model, &selected, 1, &pEntity, -1);
+
+ if (pEntity)
+ {
+ for (epair_t* pEpair = pEntity->epairs; pEpair; pEpair = pEpair->next)
+ {
+ GtkTreeIter appended;
+ gtk_list_store_append(store, &appended);
+ gtk_list_store_set(store, &appended, 0, pEpair->key, 1, pEpair->value, -1);
+ }
+ }
+ }
+}
+
+void DoEntityList ()
+{
+ static GtkWidget *dlg;
+ GtkWidget *vbox, *hbox, *hbox2, *button, *scr;
+ int loop = 1, ret = IDCANCEL;
+
+ if (dlg != NULL)
+ return;
+
+ dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ load_window_pos (dlg, g_PrefsDlg.mWindowInfo.posEntityInfoWnd);
+
+ gtk_window_set_title (GTK_WINDOW (dlg), "Entities");
+ gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
+ GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
+ gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
+ g_object_set_data (G_OBJECT (dlg), "loop", &loop);
+ g_object_set_data (G_OBJECT (dlg), "ret", &ret);
+
+ hbox = gtk_hbox_new (TRUE, 5);
+ gtk_widget_show (hbox);
+ gtk_container_add (GTK_CONTAINER (dlg), hbox);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+
+ scr = gtk_scrolled_window_new ((GtkAdjustment*)NULL, (GtkAdjustment*)NULL);
+ gtk_widget_show (scr);
+ gtk_box_pack_start (GTK_BOX (hbox), scr, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scr), GTK_SHADOW_IN);
+
+ {
+ GtkTreeStore* store = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
+
+ GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+ g_signal_connect(G_OBJECT(view), "button_press_event", G_CALLBACK(entitylist_click), dlg);
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
+
+ {
+ GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
+ GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
+ }
+
+ {
+ GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+ g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(entitylist_selection_changed), dlg);
+ }
+
+ gtk_widget_show(view);
+
+ gtk_container_add(GTK_CONTAINER (scr), view);
+ g_object_set_data (G_OBJECT (dlg), "entities", view);
+
+ {
+ {
+ GtkTreeIter child;
+ gtk_tree_store_append(store, &child, NULL);
+ gtk_tree_store_set(store, &child, 0, world_entity->eclass->name, 1, world_entity, -1);
+ }
+
+ GSList *l, *entitymap = NULL;
+ typedef struct
+ {
+ GtkTreeIter node;
+ const char *name;
+ } map_t;
+ map_t *entry;
+
+ for (entity_t* pEntity=entities.next; pEntity != &entities; pEntity=pEntity->next)
+ {
+ GtkTreeIter parent;
+ bool found = false;
+
+ for (l = entitymap; l; l = g_slist_next (l))
+ {
+ entry = (map_t*)l->data;
+
+ if (strcmp (entry->name, pEntity->eclass->name) == 0)
+ {
+ parent = entry->node;
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ gtk_tree_store_append(store, &parent, NULL);
+ gtk_tree_store_set(store, &parent, 0, pEntity->eclass->name, 1, NULL, -1);
+
+ entry = (map_t*)malloc (sizeof(map_t));
+ entitymap = g_slist_append (entitymap, entry);
+ entry->name = pEntity->eclass->name;
+ entry->node = parent;
+ }
+
+ GtkTreeIter child;
+ gtk_tree_store_append(store, &child, &parent);
+ gtk_tree_store_set(store, &child, 0, pEntity->eclass->name, 1, pEntity, -1);
+ }
+
+ while (entitymap)
+ {
+ free (entitymap->data);
+ entitymap = g_slist_remove (entitymap, entitymap->data);
+ }
+ }
+
+ g_object_unref(G_OBJECT(store));
+ }
+
+ vbox = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+ scr = gtk_scrolled_window_new ((GtkAdjustment*)NULL, (GtkAdjustment*)NULL);
+ gtk_widget_show (scr);
+ gtk_box_pack_start (GTK_BOX (vbox), scr, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scr), GTK_SHADOW_IN);
+
+ {
+ GtkListStore* store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+
+ GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+
+ {
+ GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
+ GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Key", renderer, "text", 0, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
+ }
+
+ {
+ GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
+ GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Value", renderer, "text", 1, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
+ }
+
+ gtk_widget_show(view);
+
+ g_object_set_data(G_OBJECT(dlg), "keyvalues", store);
+ gtk_container_add(GTK_CONTAINER (scr), view);
+
+ g_object_unref(G_OBJECT(store));
+ }
+
+ hbox2 = gtk_hbox_new (FALSE, 5);
+ gtk_widget_show (hbox2);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox2, TRUE, TRUE, 0);
+
+ button = gtk_button_new_with_label ("Select");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (entitylist_select), dlg);
+ gtk_widget_set_usize (button, 60, -2);
+
+ button = gtk_button_new_with_label ("Close");
+ gtk_widget_show (button);
+ gtk_box_pack_end (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
+ gtk_widget_set_usize (button, 60, -2);
+
+ gtk_grab_add (dlg);
+ gtk_widget_show (dlg);
+
+ while (loop)
+ gtk_main_iteration ();
+
+ save_window_pos (dlg, g_PrefsDlg.mWindowInfo.posMapInfoWnd);
+
+ gtk_grab_remove (dlg);
+ gtk_widget_destroy (dlg);
+
+ dlg = NULL;
+}
+
+// =============================================================================
+// Rotate dialog
+
+static void rotatedlg_apply (GtkWidget *widget, gpointer data)
+{
+ GtkSpinButton *spin;
+ float f;
+
+ spin = GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (data), "x"));
+ f = gtk_spin_button_get_value_as_float (spin);
+ if (f != 0.0)
+ Select_RotateAxis(0,f);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), 0.0f); // reset to 0 on Apply
+
+ spin = GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (data), "y"));
+ f = gtk_spin_button_get_value_as_float (spin);
+ if (f != 0.0)
+ Select_RotateAxis(1,f);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), 0.0f);
+
+ spin = GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (data), "z"));
+ f = gtk_spin_button_get_value_as_float (spin);
+ if (f != 0.0)
+ Select_RotateAxis(2,f);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), 0.0f);
+}
+
+void DoRotateDlg ()
+{
+ GtkWidget *dlg, *hbox, *vbox, *table, *label, *button;
+ GtkWidget *x, *y, *z;
+ GtkObject *adj;
+ int loop = 1, ret = IDCANCEL;
+
+ dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (dlg), "Arbitrary rotation");
+ gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
+ GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
+ gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
+ g_object_set_data (G_OBJECT (dlg), "loop", &loop);
+ g_object_set_data (G_OBJECT (dlg), "ret", &ret);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ gtk_widget_show (hbox);
+ gtk_container_add (GTK_CONTAINER (dlg), hbox);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+
+ table = gtk_table_new (3, 2, FALSE);
+ gtk_widget_show (table);
+ gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
+ gtk_table_set_row_spacings (GTK_TABLE (table), 5);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 5);
+
+ label = gtk_label_new (" X ");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
+ (GtkAttachOptions) (0),
+ (GtkAttachOptions) (0), 0, 0);
+
+ label = gtk_label_new (" Y ");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
+ (GtkAttachOptions) (0),
+ (GtkAttachOptions) (0), 0, 0);
+
+ label = gtk_label_new (" Z ");
+
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
+ (GtkAttachOptions) (0),
+ (GtkAttachOptions) (0), 0, 0);
+
+ adj = gtk_adjustment_new (0, -359, 359, 1, 10, 10);
+ x = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1, 0);
+ g_object_set_data (G_OBJECT (dlg), "x", x);
+ gtk_widget_show (x);
+ gtk_table_attach (GTK_TABLE (table), x, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_widget_set_usize (x, 60, -2);
+ gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (x), TRUE);
+
+ adj = gtk_adjustment_new (0, -359, 359, 1, 10, 10);
+ y = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1, 0);
+ g_object_set_data (G_OBJECT (dlg), "y", y);
+ gtk_widget_show (y);
+ gtk_table_attach (GTK_TABLE (table), y, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (y), TRUE);
+
+ adj = gtk_adjustment_new (0, -359, 359, 1, 10, 10);
+ z = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1, 0);
+ g_object_set_data (G_OBJECT (dlg), "z", z);
+ gtk_widget_show (z);
+ gtk_table_attach (GTK_TABLE (table), z, 1, 2, 2, 3,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (z), TRUE);
+
+ vbox = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+ button = gtk_button_new_with_label ("OK");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
+ gtk_widget_set_usize (button, 60, -2);
+
+ button = gtk_button_new_with_label ("Cancel");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
+
+ button = gtk_button_new_with_label ("Apply");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (rotatedlg_apply), dlg);
+
+ gtk_grab_add (dlg);
+ gtk_widget_show (dlg);
+
+ while (loop)
+ gtk_main_iteration ();
+
+ if (ret == IDOK)
+ rotatedlg_apply (button, dlg);
+
+ gtk_grab_remove (dlg);
+ gtk_widget_destroy (dlg);
+}
+
+// =============================================================================
+// Gamma dialog
+
+void DoGamma ()
+{
+ GtkWidget *dlg, *vbox, *hbox, *label, *button, *entry;
+ int loop = 1, ret = IDCANCEL;
+
+ dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (dlg), "Gamma");
+ gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
+ GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
+ gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
+ g_object_set_data (G_OBJECT (dlg), "loop", &loop);
+ g_object_set_data (G_OBJECT (dlg), "ret", &ret);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ gtk_widget_show (hbox);
+ gtk_container_add (GTK_CONTAINER (dlg), hbox);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+
+ vbox = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+ entry = gtk_entry_new ();
+ gtk_widget_show (entry);
+ gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
+
+ label = gtk_label_new ("0.0 is brightest\n1.0 is darkest");
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
+
+ label = gtk_label_new ("You must restart for the\nsettings to take effect");
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
+
+ vbox = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+ button = gtk_button_new_with_label ("OK");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
+ gtk_widget_set_usize (button, 60, -2);
+
+ button = gtk_button_new_with_label ("Cancel");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
+
+ // Initialize dialog
+ char buf[16];
+ sprintf (buf, "%1.1f", g_qeglobals.d_savedinfo.fGamma);
+ gtk_entry_set_text (GTK_ENTRY (entry), buf);
+
+ gtk_grab_add (dlg);
+ gtk_widget_show (dlg);
+
+ while (loop)
+ gtk_main_iteration ();
+
+ if (ret == IDOK)
+ g_qeglobals.d_savedinfo.fGamma = g_strtod (gtk_entry_get_text (GTK_ENTRY (entry)), NULL);
+
+ gtk_grab_remove (dlg);
+ gtk_widget_destroy (dlg);
+}
+
+// =============================================================================
+// Find Brush Dialog
+
+// helper function to walk through the active brushes only and drop the regioned out ones
+bool WalkRegionBrush (brush_t **b, entity_t *e)
+{
+ brush_t *b2;
+ do
+ {
+ for(b2=active_brushes.next ; b2 != &active_brushes ; b2=b2->next)
+ {
+ if (b2==*b)
+ break; // this is an active brush
+ }
+ if (b2==&active_brushes)
+ {
+ // this is a regioned out brush
+ *b = (*b)->onext;
+ if (*b == &e->brushes)
+ {
+ Sys_Status ("No such brush", 0);
+ return false;
+ }
+ }
+ } while (b2==&active_brushes);
+ return true;
+}
+
+void SelectBrush (int entitynum, int brushnum)
+{
+ entity_t *e;
+ brush_t *b;
+ int i;
+
+ // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=503
+ // making this work when regioning is on too
+
+ if (entitynum == 0)
+ e = world_entity;
+ else
+ {
+ e = entities.next;
+ while (--entitynum)
+ {
+ e = e->next;
+ if (e == &entities)
+ {
+ Sys_Status ("No such entity", 0);
+ return;
+ }
+ if (region_active)
+ {
+ // we need to make sure we walk to the next 'active' entity to have a valid --entitynum
+ // that is, find a brush that belongs to this entity in the active brushes
+ do
+ {
+ for (b = active_brushes.next ; b != &active_brushes ; b=b->next)
+ {
+ if (b->owner == e)
+ break; // this is an active entity
+ }
+ if (b==&active_brushes)
+ {
+ // this is a regioned out entity
+ e = e->next;
+ // don't walk past the end either
+ if (e == &entities)
+ {
+ Sys_Status ("No such entity", 0);
+ return;
+ }
+ }
+ } while(b==&active_brushes);
+ }
+ }
+ }
+
+ b = e->brushes.onext;
+ if (b == &e->brushes)
+ {
+ Sys_Status ("No such brush", 0);
+ return;
+ }
+ if (region_active)
+ {
+ if (!WalkRegionBrush(&b, e))
+ return;
+ }
+
+ while (brushnum--)
+ {
+ b = b->onext;
+ if (b == &e->brushes)
+ {
+ Sys_Status ("No such brush", 0);
+ return;
+ }
+ if (region_active)
+ {
+ if (!WalkRegionBrush(&b, e))
+ return;
+ }
+ }
+
+ Brush_RemoveFromList (b);
+ Brush_AddToList (b, &selected_brushes);
+
+ Sys_UpdateWindows (W_ALL);
+ for (i = 0; i < 3; i++)
+ {
+ if (g_pParentWnd->GetXYWnd())
+ g_pParentWnd->GetXYWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
+
+ if (g_pParentWnd->GetXZWnd())
+ g_pParentWnd->GetXZWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
+
+ if (g_pParentWnd->GetYZWnd())
+ g_pParentWnd->GetYZWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
+ }
+
+ Sys_Status ("Selected", 0);
+}
+
+static void GetSelectionIndex (int *ent, int *brush)
+{
+ brush_t *b, *b2;
+ entity_t *entity;
+
+ *ent = *brush = 0;
+
+ b = selected_brushes.next;
+ if (b == &selected_brushes)
+ return;
+
+ // find entity
+ if (b->owner != world_entity)
+ {
+ (*ent)++;
+ for (entity = entities.next; entity != &entities; entity=entity->next, (*ent)++)
+ ;
+ }
+
+ // find brush
+ for (b2=b->owner->brushes.onext; b2 != b && b2 != &b->owner->brushes; b2=b2->onext, (*brush)++)
+ ;
+}
+
+void DoFind ()
+{
+ GtkWidget *dlg, *vbox, *hbox, *table, *label, *button, *entity, *brush;
+ int loop = 1, ret = IDCANCEL;
+
+ dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (dlg), "Find Brush");
+ gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
+ GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
+ gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
+ g_object_set_data (G_OBJECT (dlg), "loop", &loop);
+ g_object_set_data (G_OBJECT (dlg), "ret", &ret);
+
+ vbox = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox);
+ gtk_container_add (GTK_CONTAINER (dlg), vbox);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+ table = gtk_table_new (2, 2, FALSE);
+ gtk_widget_show (table);
+ gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);
+ gtk_table_set_row_spacings (GTK_TABLE (table), 5);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 5);
+
+ label = gtk_label_new ("Entity number");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
+ (GtkAttachOptions) (0),
+ (GtkAttachOptions) (0), 0, 0);
+
+ label = gtk_label_new ("Brush number");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
+ (GtkAttachOptions) (0),
+ (GtkAttachOptions) (0), 0, 0);
+
+ entity = gtk_entry_new ();
+ gtk_widget_show (entity);
+ gtk_table_attach (GTK_TABLE (table), entity, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ brush = gtk_entry_new ();
+ gtk_widget_show (brush);
+ gtk_table_attach (GTK_TABLE (table), brush, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+
+ button = gtk_button_new_with_label ("OK");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
+ gtk_widget_set_usize (button, 60, -2);
+
+ button = gtk_button_new_with_label ("Cancel");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
+
+ // Initialize dialog
+ char buf[16];
+ int ent, br;
+
+ GetSelectionIndex (&ent, &br);
+ sprintf (buf, "%i", ent);
+ gtk_entry_set_text (GTK_ENTRY (entity), buf);
+ sprintf (buf, "%i", br);
+ gtk_entry_set_text (GTK_ENTRY (brush), buf);
+
+ gtk_grab_add (dlg);
+ gtk_widget_show (dlg);
+
+ while (loop)
+ gtk_main_iteration ();
+
+ if (ret == IDOK)
+ {
+ const char *entstr = gtk_entry_get_text (GTK_ENTRY (entity));
+ const char *brushstr = gtk_entry_get_text (GTK_ENTRY (brush));
+ SelectBrush (atoi(entstr), atoi(brushstr));
+ }
+
+ gtk_grab_remove (dlg);
+ gtk_widget_destroy (dlg);
+}
+
+// =============================================================================
+// Arbitrary Sides dialog
+
+void DoSides (bool bCone, bool bSphere, bool bTorus)
+{
+ GtkWidget *dlg, *vbox, *hbox, *button, *label, *entry;
+ int loop = 1, ret = IDCANCEL;
+
+ dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (dlg), "Arbitrary sides");
+ gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
+ GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
+ gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
+ g_object_set_data (G_OBJECT (dlg), "loop", &loop);
+ g_object_set_data (G_OBJECT (dlg), "ret", &ret);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ gtk_widget_show (hbox);
+ gtk_container_add (GTK_CONTAINER (dlg), hbox);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+
+ label = gtk_label_new ("Sides:");
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ entry = gtk_entry_new ();
+ gtk_widget_show (entry);
+ gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
+
+ vbox = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, TRUE, 0);
+
+ button = gtk_button_new_with_label ("OK");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
+ gtk_widget_set_usize (button, 60, -2);
+
+ button = gtk_button_new_with_label ("Cancel");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
+
+ gtk_grab_add (dlg);
+ gtk_widget_show (dlg);
+
+ while (loop)
+ gtk_main_iteration ();
+
+ if (ret == IDOK)
+ {
+ const char *str = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ if (bCone)
+ Brush_MakeSidedCone(atoi(str));
+ else if (bSphere)
+ Brush_MakeSidedSphere(atoi(str));
+ else
+ Brush_MakeSided (atoi(str));
+ }
+
+ gtk_grab_remove (dlg);
+ gtk_widget_destroy (dlg);
+}
+
+// =============================================================================
+// New Patch dialog
+
+void DoNewPatchDlg ()
+{
+ GtkWidget *dlg, *hbox, *table, *vbox, *label, *button, *combo;
+ GtkWidget *width, *height;
+ GList *combo_list = (GList*)NULL;
+ int loop = 1, ret = IDCANCEL;
+
+ dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (dlg), "Patch density");
+ gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
+ GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
+ gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
+ g_object_set_data (G_OBJECT (dlg), "loop", &loop);
+ g_object_set_data (G_OBJECT (dlg), "ret", &ret);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ gtk_widget_show (hbox);
+ gtk_container_add (GTK_CONTAINER (dlg), hbox);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+
+ table = gtk_table_new (2, 2, FALSE);
+ gtk_widget_show (table);
+ gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
+ gtk_table_set_row_spacings (GTK_TABLE (table), 5);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 5);
+
+ label = gtk_label_new ("Width:");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ label = gtk_label_new ("Height:");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ combo_list = g_list_append (combo_list, (void *)"3");
+ combo_list = g_list_append (combo_list, (void *)"5");
+ combo_list = g_list_append (combo_list, (void *)"7");
+ combo_list = g_list_append (combo_list, (void *)"9");
+ combo_list = g_list_append (combo_list, (void *)"11");
+ combo_list = g_list_append (combo_list, (void *)"13");
+ combo_list = g_list_append (combo_list, (void *)"15");
+
+ combo = gtk_combo_new ();
+ width = GTK_COMBO (combo)->entry;
+ gtk_combo_set_popdown_strings (GTK_COMBO (combo), combo_list);
+ gtk_widget_show (combo);
+ gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ combo = gtk_combo_new ();
+ height = GTK_COMBO (combo)->entry;
+ gtk_combo_set_popdown_strings (GTK_COMBO (combo), combo_list);
+ gtk_widget_show (combo);
+ gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ vbox = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+ button = gtk_button_new_with_label ("OK");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
+ gtk_widget_set_usize (button, 60, -2);
+
+ button = gtk_button_new_with_label ("Cancel");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
+
+ // Initialize dialog
+ g_list_free (combo_list);
+ gtk_entry_set_text (GTK_ENTRY (width), "3");
+ gtk_entry_set_editable (GTK_ENTRY (width), FALSE);
+ gtk_entry_set_text (GTK_ENTRY (height), "3");
+ gtk_entry_set_editable (GTK_ENTRY (height), FALSE);
+
+ gtk_grab_add (dlg);
+ gtk_widget_show (dlg);
+
+ while (loop)
+ gtk_main_iteration ();
+
+ if (ret == IDOK)
+ {
+ const char* w = gtk_entry_get_text (GTK_ENTRY (width));
+ const char* h = gtk_entry_get_text (GTK_ENTRY (height));
+
+ Patch_GenericMesh(atoi (w), atoi (h), g_pParentWnd->ActiveXY ()->GetViewType ());
+ Sys_UpdateWindows (W_ALL);
+ }
+
+ gtk_grab_remove (dlg);
+ gtk_widget_destroy (dlg);
+}
+
+// =============================================================================
+// New Patch dialog
+
+void DoScaleDlg ()
+{
+ GtkWidget *dlg, *hbox, *table, *vbox, *label, *button;
+ GtkWidget *x, *y, *z;
+ int loop = 1, ret = IDCANCEL;
+
+ dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (dlg), "Scale");
+ gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
+ GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
+ gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
+ g_object_set_data (G_OBJECT (dlg), "loop", &loop);
+ g_object_set_data (G_OBJECT (dlg), "ret", &ret);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ gtk_widget_show (hbox);
+ gtk_container_add (GTK_CONTAINER (dlg), hbox);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+
+ table = gtk_table_new (3, 2, FALSE);
+ gtk_widget_show (table);
+ gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
+ gtk_table_set_row_spacings (GTK_TABLE (table), 5);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 5);
+
+ label = gtk_label_new ("X:");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ label = gtk_label_new ("Y:");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ label = gtk_label_new ("Z:");
+ gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+ x = gtk_entry_new ();
+ gtk_widget_show (x);
+ gtk_table_attach (GTK_TABLE (table), x, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ y = gtk_entry_new ();
+ gtk_widget_show (y);
+ gtk_table_attach (GTK_TABLE (table), y, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ z = gtk_entry_new ();
+ gtk_widget_show (z);
+ gtk_table_attach (GTK_TABLE (table), z, 1, 2, 2, 3,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ vbox = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+ button = gtk_button_new_with_label ("OK");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
+ gtk_widget_set_usize (button, 60, -2);
+
+ button = gtk_button_new_with_label ("Cancel");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
+
+ // Initialize dialog
+ gtk_entry_set_text (GTK_ENTRY (x), "1.0");
+ gtk_entry_set_text (GTK_ENTRY (y), "1.0");
+ gtk_entry_set_text (GTK_ENTRY (z), "1.0");
+
+ gtk_grab_add (dlg);
+ gtk_widget_show (dlg);
+
+ while (loop)
+ gtk_main_iteration ();
+
+ if (ret == IDOK)
+ {
+ float sx, sy, sz;
+ sx = atof (gtk_entry_get_text (GTK_ENTRY (x)));
+ sy = atof (gtk_entry_get_text (GTK_ENTRY (y)));
+ sz = atof (gtk_entry_get_text (GTK_ENTRY (z)));
+
+ if (sx > 0 && sy > 0 && sz > 0)
+ {
+ Select_Scale(sx, sy, sz);
+ Sys_UpdateWindows (W_ALL);
+ }
+ else
+ Sys_Printf("Warning.. Tried to scale by a zero value.");
+ }
+
+ gtk_grab_remove (dlg);
+ gtk_widget_destroy (dlg);
+}
+
+// =============================================================================
+// Thicken Patch dialog
+
+void DoThickenDlg ()
+{
+ GtkWidget *dlg, *vbox, *hbox, *vbox2, *button, *label;
+ GtkWidget *amount, *seams, *group;
+ int loop = 1, ret = IDCANCEL;
+ static qboolean bGroupResult = true;
+
+ dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (dlg), "Thicken Patch");
+ gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
+ GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
+ gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
+ g_object_set_data (G_OBJECT (dlg), "loop", &loop);
+ g_object_set_data (G_OBJECT (dlg), "ret", &ret);
+
+ vbox = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox);
+ gtk_container_add (GTK_CONTAINER (dlg), vbox);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+
+ label = gtk_label_new ("This produces a set of patches\n"
+ "that contains the original patch along with the\n"
+ "'thick' patch and an optimal set of seam patches.");
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ vbox2 = gtk_vbox_new (FALSE, 5);
+ gtk_widget_show (vbox2);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 0);
+
+ button = gtk_button_new_with_label ("OK");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
+ gtk_widget_set_usize (button, 60, -2);
+
+ button = gtk_button_new_with_label ("Cancel");
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+
+ label = gtk_label_new ("Amount:");
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ amount = gtk_entry_new ();
+ gtk_widget_show (amount);
+ gtk_box_pack_start (GTK_BOX (hbox), amount, FALSE, FALSE, 0);
+
+ seams = gtk_check_button_new_with_label ("Seams");
+ gtk_widget_show (seams);
+ gtk_box_pack_start (GTK_BOX (hbox), seams, FALSE, FALSE, 0);
+
+ // bGroupResult
+ group = gtk_check_button_new_with_label("Result to func_group");
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(group), bGroupResult);
+ gtk_box_pack_start(GTK_BOX(vbox), group, FALSE, FALSE, 0);
+ gtk_widget_show(group);
+
+
+ // Initialize dialog
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (seams), TRUE);
+ gtk_entry_set_text (GTK_ENTRY (amount), "8");
+
+ gtk_grab_add (dlg);
+ gtk_widget_show (dlg);
+
+ while (loop)
+ gtk_main_iteration ();
+
+ if (ret == IDOK)
+ {
+ if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(group)))
+ bGroupResult = true;
+ else
+ bGroupResult = false;
+ Patch_Thicken (atoi (gtk_entry_get_text (GTK_ENTRY (amount))),
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (seams)), bGroupResult);
+ Sys_UpdateWindows (W_ALL);