2 Copyright (c) 2001, Loki software, inc.
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
8 Redistributions of source code must retain the above copyright notice, this list
9 of conditions and the following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this
12 list of conditions and the following disclaimer in the documentation and/or
13 other materials provided with the distribution.
15 Neither the name of Loki software nor the names of its contributors may be used
16 to endorse or promote products derived from this software without specific prior
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
23 DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // Some small dialogs that don't need much
34 // Leonardo Zide (leo@lokigames.com)
38 #include <gdk/gdkkeysyms.h>
42 #include <gdk/gdkwin32.h>
49 // =============================================================================
50 // Color selection dialog
52 qboolean DoColor (int iIndex)
54 static bool bColorOpen = false;
58 Sys_FPrintf(SYS_WRN, "DoColor dialog is already open\n");
64 if (color_dialog (g_pParentWnd->m_pWidget, g_qeglobals.d_savedinfo.colors[iIndex]))
67 ** scale colors so that at least one component is at 1.0F
68 ** if this is meant to select an entity color
70 if (iIndex == COLOR_ENTITY)
74 if ( g_qeglobals.d_savedinfo.colors[iIndex][0] > largest )
75 largest = g_qeglobals.d_savedinfo.colors[iIndex][0];
76 if ( g_qeglobals.d_savedinfo.colors[iIndex][1] > largest )
77 largest = g_qeglobals.d_savedinfo.colors[iIndex][1];
78 if ( g_qeglobals.d_savedinfo.colors[iIndex][2] > largest )
79 largest = g_qeglobals.d_savedinfo.colors[iIndex][2];
81 if ( largest == 0.0F )
83 g_qeglobals.d_savedinfo.colors[iIndex][0] = 1.0F;
84 g_qeglobals.d_savedinfo.colors[iIndex][1] = 1.0F;
85 g_qeglobals.d_savedinfo.colors[iIndex][2] = 1.0F;
89 float scaler = 1.0F / largest;
91 g_qeglobals.d_savedinfo.colors[iIndex][0] *= scaler;
92 g_qeglobals.d_savedinfo.colors[iIndex][1] *= scaler;
93 g_qeglobals.d_savedinfo.colors[iIndex][2] *= scaler;
97 Sys_UpdateWindows (W_ALL);
107 // =============================================================================
108 // Project settings dialog
110 static void UpdateBSPCommandList (GtkWidget *dialog);
112 static void DoProjectAddEdit (bool edit, GtkWidget *parent)
114 GtkWidget *dlg, *vbox, *hbox, *label, *table, *button;
115 GtkWidget *cmd, *text;
116 int loop = 1, ret = IDCANCEL;
118 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
120 gtk_window_set_title (GTK_WINDOW (dlg), "Edit Command");
122 gtk_window_set_title (GTK_WINDOW (dlg), "Add Command");
123 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
124 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
125 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
126 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
127 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
128 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
130 vbox = gtk_vbox_new (FALSE, 5);
131 gtk_widget_show (vbox);
132 gtk_container_add (GTK_CONTAINER (dlg), vbox);
133 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
135 table = gtk_table_new (2, 2, FALSE);
136 gtk_widget_show (table);
137 gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0);
138 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
139 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
141 label = gtk_label_new ("Menu text");
142 gtk_widget_show (label);
143 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
144 (GtkAttachOptions) (GTK_FILL),
145 (GtkAttachOptions) (0), 0, 0);
146 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
148 label = gtk_label_new ("Command");
149 gtk_widget_show (label);
150 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
151 (GtkAttachOptions) (GTK_FILL),
152 (GtkAttachOptions) (0), 0, 0);
153 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
155 text = gtk_entry_new ();
156 g_object_set_data (G_OBJECT (dlg), "text", text);
157 gtk_widget_show (text);
158 gtk_table_attach (GTK_TABLE (table), text, 1, 2, 0, 1,
159 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
160 (GtkAttachOptions) (0), 0, 0);
161 gtk_widget_set_usize (text, 300, -2);
163 cmd = gtk_entry_new ();
164 g_object_set_data (G_OBJECT (dlg), "cmd", cmd);
165 gtk_widget_show (cmd);
166 gtk_table_attach (GTK_TABLE (table), cmd, 1, 2, 1, 2,
167 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
168 (GtkAttachOptions) (0), 0, 0);
169 gtk_widget_set_usize (cmd, 300, -2);
171 hbox = gtk_hbox_new (FALSE, 5);
172 gtk_widget_show (hbox);
173 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
175 button = gtk_button_new_with_label ("OK");
176 gtk_widget_show (button);
177 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
178 gtk_signal_connect (GTK_OBJECT (button), "clicked",
179 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
180 gtk_widget_set_usize (button, 60, -2);
182 button = gtk_button_new_with_label ("Cancel");
183 gtk_widget_show (button);
184 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
185 gtk_signal_connect (GTK_OBJECT (button), "clicked",
186 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
187 gtk_widget_set_usize (button, 60, -2);
191 GtkTreeView* view = GTK_TREE_VIEW (g_object_get_data (G_OBJECT(parent), "view"));
192 GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
195 if(gtk_tree_selection_get_selected(selection, &model, &iter))
198 gtk_tree_model_get(model, &iter, 0, &key, -1);
199 const char* value = ValueForKey (g_qeglobals.d_project_entity, key);
200 gtk_entry_set_text (GTK_ENTRY (text), key);
201 gtk_entry_set_text (GTK_ENTRY (cmd), value);
207 gtk_widget_show (dlg);
210 gtk_main_iteration ();
214 const char* key = gtk_entry_get_text (GTK_ENTRY (text));
215 const char* value = gtk_entry_get_text (GTK_ENTRY (cmd));
217 if (strlen (key) <= 0 || strlen (value) <= 0)
219 Sys_Printf ("Command not added\n");
225 SetKeyValue (g_qeglobals.d_project_entity, key, value);
230 if (key[0] == 'b' && key[1] == 's' && key[2] == 'p')
232 SetKeyValue (g_qeglobals.d_project_entity, key, value);
236 Sys_Printf ("BSP commands must be preceded by \"bsp\"");
239 UpdateBSPCommandList (parent);
243 gtk_grab_remove (dlg);
244 gtk_widget_destroy (dlg);
247 static void UpdateBSPCommandList (GtkWidget *dialog)
249 GtkListStore* store = GTK_LIST_STORE (g_object_get_data (G_OBJECT(dialog), "bsp_commands"));
251 gtk_list_store_clear(store);
253 for(epair_t* ep = g_qeglobals.d_project_entity->epairs; ep != NULL; ep = ep->next)
255 if(ep->key[0] == 'b' && ep->key[1] == 's' && ep->key[2] == 'p')
258 gtk_list_store_append(store, &iter);
259 gtk_list_store_set(store, &iter, 0, ep->key, -1);
264 static void project_add (GtkWidget *widget, gpointer data)
266 GtkWidget *dlg = GTK_WIDGET (data);
267 DoProjectAddEdit (false, dlg);
268 UpdateBSPCommandList (dlg);
271 static void project_change (GtkWidget *widget, gpointer data)
273 GtkWidget *dlg = GTK_WIDGET (data);
274 DoProjectAddEdit (true, dlg);
275 UpdateBSPCommandList (dlg);
278 static void project_remove (GtkWidget *widget, gpointer data)
280 GtkWidget* project = GTK_WIDGET(data);
282 GtkTreeView* view = GTK_TREE_VIEW (g_object_get_data (G_OBJECT(project), "view"));
283 GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
286 if(gtk_tree_selection_get_selected(selection, &model, &iter))
289 gtk_tree_model_get(model, &iter, 0, &key, -1);
290 DeleteKey (g_qeglobals.d_project_entity, key);
293 char* index = gtk_tree_model_get_string_from_iter(model, &iter);
294 Sys_Printf ("Selected %s\n", index);
297 UpdateBSPCommandList(project);
302 static const char* sQ3ComboItem = "Quake III Arena";
303 static const char* sTAComboItem = "Quake III: Team Arena";
304 static const char* sModComboItem = "Custom Quake III modification";
305 static const char* sWolfComboItem = "Return To Castle Wolfenstein";
306 static const char* sWolfModComboItem = "Custom RTCW modification";
307 static const char* sHLComboItem = "Half-life";
308 static const char* sHLModComboItem = "Custom Half-life modification";
310 static const char* sWolfSPCombo = "Single Player mapping mode";
311 static const char* sWolfMPCombo = "Multiplayer mapping mode";
314 // HARD-CODED ET HACK
315 static const char* sETComboItem = "Wolfenstein: Enemy Territory";
316 static const char* sETModComboItem = "Custom ET modification";
319 // HARD-CODED JK2 HACK
320 static const char* sJK2ComboItem = "Jedi Knight II Outcast";
321 static const char* sJK2ModComboItem = "Custom JK2 modification";
322 static const char* sJK2SPCombo = "Single Player mapping mode";
323 static const char* sJK2MPCombo = "Multiplayer mapping mode";
326 // HARD-CODED JA HACK
327 static const char* sJAComboItem = "Jedi Knight Jedi Academy";
328 static const char* sJAModComboItem = "Custom JA modification";
329 static const char* sJASPCombo = "Single Player mapping mode";
330 static const char* sJAMPCombo = "Multiplayer mapping mode";
333 // HARD-CODED STVEF2 HACK
334 static const char* sSTVEFComboItem = "Star Trek Voyager : Elite Force";
335 static const char* sSTVEFModComboItem = "Custom Elite Force modification";
336 static const char* sSTVEFSPCombo = "Single Player mapping mode";
337 static const char* sSTVEFMPCombo = "Holo Match mapping mode";
340 // HARD-CODED SOF2 HACK
341 static const char* sSOF2ComboItem = "Soldier of Fortune II - Double Helix";
342 static const char* sSOF2ModComboItem = "Custom Sof2 modification";
343 static const char* sSOF2SPCombo = "Single Player mapping mode";
344 static const char* sSOF2MPCombo = "Multiplayer mapping mode";
346 static GtkWidget* game_select; // GTK_COMBO
347 static GtkEntry* fsgame_entry;
349 gint OnSelchangeComboWhatgame (GtkWidget *widget, GdkEvent* event, gpointer data)
351 const char *dir = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(game_select)->entry));
353 if (g_pGameDescription->mGameFile == "wolf.game")
355 if (!strcmp(dir,sWolfComboItem))
357 // disable the fs_game text entry
358 gtk_entry_set_text (fsgame_entry, "");
359 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), false);
363 gtk_entry_set_text (fsgame_entry, "");
364 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), true);
369 else if (g_pGameDescription->mGameFile == "et.game")
371 if (!strcmp(dir,sETComboItem))
373 // disable the fs_game text entry
374 gtk_entry_set_text (fsgame_entry, "");
375 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), false);
379 gtk_entry_set_text (fsgame_entry, "");
380 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), true);
384 else if (g_pGameDescription->mGameFile == "hl.game")
386 if (!strcmp(dir,sHLComboItem))
388 // disable the fs_game text entry
389 gtk_entry_set_text (fsgame_entry, "");
390 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), false);
394 gtk_entry_set_text (fsgame_entry, "");
395 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), true);
401 else if (g_pGameDescription->mGameFile == "jk2.game")
403 if (!strcmp(dir,sJK2ComboItem))
405 // disable the fs_game text entry
406 gtk_entry_set_text (fsgame_entry, "");
407 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), false);
411 gtk_entry_set_text (fsgame_entry, "");
412 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), true);
417 else if (g_pGameDescription->mGameFile == "ja.game")
419 if (!strcmp(dir,sJAComboItem))
421 // disable the fs_game text entry
422 gtk_entry_set_text (fsgame_entry, "");
423 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), false);
427 gtk_entry_set_text (fsgame_entry, "");
428 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), true);
433 else if (g_pGameDescription->mGameFile == "stvef.game")
435 if (!strcmp(dir,sSTVEFComboItem))
437 // disable the fs_game text entry
438 gtk_entry_set_text (fsgame_entry, "");
439 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), false);
443 gtk_entry_set_text (fsgame_entry, "");
444 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), true);
449 else if (g_pGameDescription->mGameFile == "sof2.game")
451 if (!strcmp(dir,sSOF2ComboItem))
453 // disable the fs_game text entry
454 gtk_entry_set_text (fsgame_entry, "");
455 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), false);
459 gtk_entry_set_text (fsgame_entry, "");
460 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), true);
466 if (!strcmp(dir,sQ3ComboItem))
468 // disable the fs_game text entry
469 gtk_entry_set_text (fsgame_entry, "");
470 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), false);
472 else if (!strcmp(dir,sTAComboItem))
474 gtk_entry_set_text (fsgame_entry, "missionpack");
475 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), false);
479 gtk_entry_set_text (fsgame_entry, "");
480 gtk_widget_set_sensitive(GTK_WIDGET(fsgame_entry), true);
487 void DoProjectSettings ()
490 GtkWidget *frame, *label, *vbox, *table1, *table2, *button;
493 GtkWidget *base, *game;
494 GtkWidget *gamemode_combo;
495 GList *combo_list = (GList*)NULL;
497 int loop = 1, ret = IDCANCEL;
499 project = gtk_window_new (GTK_WINDOW_TOPLEVEL);
500 gtk_window_set_title (GTK_WINDOW (project), "Project Settings");
501 gtk_signal_connect (GTK_OBJECT (project), "delete_event",
502 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
503 gtk_signal_connect (GTK_OBJECT (project), "destroy",
504 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
505 g_object_set_data (G_OBJECT (project), "loop", &loop);
506 g_object_set_data (G_OBJECT (project), "ret", &ret);
507 gtk_window_set_default_size (GTK_WINDOW (project), 550, 400);
509 table1 = gtk_table_new (3, 2, FALSE);
510 gtk_widget_show (table1);
511 gtk_container_add (GTK_CONTAINER (project), table1);
512 gtk_container_set_border_width (GTK_CONTAINER (table1), 5);
513 gtk_table_set_row_spacings (GTK_TABLE (table1), 5);
514 gtk_table_set_col_spacings (GTK_TABLE (table1), 5);
516 vbox = gtk_vbox_new (FALSE, 5);
517 gtk_widget_show (vbox);
518 gtk_table_attach (GTK_TABLE (table1), vbox, 1, 2, 0, 1,
519 (GtkAttachOptions) (GTK_FILL),
520 (GtkAttachOptions) (GTK_FILL), 0, 0);
522 button = gtk_button_new_with_label ("OK");
523 gtk_widget_show (button);
524 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
525 gtk_signal_connect (GTK_OBJECT (button), "clicked",
526 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
527 gtk_widget_set_usize (button, 60, -2);
529 button = gtk_button_new_with_label ("Cancel");
530 gtk_widget_show (button);
531 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
532 gtk_signal_connect (GTK_OBJECT (button), "clicked",
533 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
534 gtk_widget_set_usize (button, 60, -2);
536 vbox = gtk_vbox_new (FALSE, 5);
537 gtk_widget_show (vbox);
538 gtk_table_attach (GTK_TABLE (table1), vbox, 1, 2, 1, 2,
539 (GtkAttachOptions) (GTK_FILL),
540 (GtkAttachOptions) (GTK_FILL), 0, 0);
542 button = gtk_button_new_with_label ("Add...");
543 gtk_widget_show (button);
544 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
545 gtk_signal_connect (GTK_OBJECT (button), "clicked",
546 GTK_SIGNAL_FUNC (project_add), project);
547 gtk_widget_set_usize (button, 60, -2);
549 button = gtk_button_new_with_label ("Change...");
550 gtk_widget_show (button);
551 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
552 gtk_signal_connect (GTK_OBJECT (button), "clicked",
553 GTK_SIGNAL_FUNC (project_change), project);
554 gtk_widget_set_usize (button, 60, -2);
556 button = gtk_button_new_with_label ("Remove");
557 gtk_widget_show (button);
558 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
559 gtk_signal_connect (GTK_OBJECT (button), "clicked",
560 GTK_SIGNAL_FUNC (project_remove), project);
561 gtk_widget_set_usize (button, 60, -2);
563 frame = gtk_frame_new ("Misc settings");
564 gtk_widget_show (frame);
565 gtk_table_attach (GTK_TABLE (table1), frame, 0, 1, 2, 3,
566 (GtkAttachOptions) (GTK_FILL),
567 (GtkAttachOptions) (GTK_FILL), 0, 0);
569 brush = gtk_check_button_new_with_label ("Use brush primitives in MAP files (NOTE: experimental feature,\n"
570 "required by the texture tools plugin)");
571 gtk_widget_show (brush);
572 gtk_container_add (GTK_CONTAINER (frame), brush);
573 gtk_container_set_border_width (GTK_CONTAINER (brush), 5);
575 frame = gtk_frame_new ("Menu commands");
576 gtk_widget_show (frame);
577 gtk_table_attach (GTK_TABLE (table1), frame, 0, 1, 1, 2,
578 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
579 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
581 scr = gtk_scrolled_window_new ((GtkAdjustment*)NULL, (GtkAdjustment*)NULL);
582 gtk_widget_show (scr);
583 gtk_container_add (GTK_CONTAINER (frame), scr);
584 gtk_container_set_border_width (GTK_CONTAINER (scr), 5);
585 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
586 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scr), GTK_SHADOW_IN);
590 GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);
592 GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
593 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
595 GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
596 GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, NULL);
597 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
599 GtkTreeSelection* selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
600 gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
602 gtk_widget_show(view);
604 g_object_set_data(G_OBJECT (project), "view", view);
605 g_object_set_data(G_OBJECT (project), "bsp_commands", store);
606 gtk_container_add(GTK_CONTAINER (scr), view);
608 g_object_unref(G_OBJECT(store));
611 frame = gtk_frame_new ("Project settings");
612 gtk_widget_show (frame);
613 gtk_table_attach (GTK_TABLE (table1), frame, 0, 1, 0, 1,
614 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
615 (GtkAttachOptions) (GTK_FILL), 0, 0);
617 // HACK: hardcoded game stuff
618 if (g_pGameDescription->mGameFile == "wolf.game" ||
619 g_pGameDescription->mGameFile == "et.game" ||
620 g_pGameDescription->mGameFile == "jk2.game" ||
621 g_pGameDescription->mGameFile == "stvef.game" ||
622 g_pGameDescription->mGameFile == "sof2.game" ||
623 g_pGameDescription->mGameFile == "ja.game" )
625 table2 = gtk_table_new (9, 2, FALSE);
629 table2 = gtk_table_new (8, 2, FALSE);
631 gtk_widget_show (table2);
632 gtk_container_add (GTK_CONTAINER (frame), table2);
633 gtk_container_set_border_width (GTK_CONTAINER (table2), 5);
634 gtk_table_set_row_spacings (GTK_TABLE (table2), 5);
635 gtk_table_set_col_spacings (GTK_TABLE (table2), 5);
638 fill in the game selection combo
639 HACK: hardcoded Q3/Wolf/HL switch
640 \todo that stuff would be faster to write with implementation of property bags and associated code to edit
642 if (g_pGameDescription->mGameFile == "wolf.game")
644 combo_list = g_list_append (combo_list, (void *)sWolfComboItem);
645 combo_list = g_list_append (combo_list, (void *)sWolfModComboItem);
647 else if (g_pGameDescription->mGameFile == "et.game")
649 combo_list = g_list_append (combo_list, (void *)sETComboItem);
650 combo_list = g_list_append (combo_list, (void *)sETModComboItem);
652 else if (g_pGameDescription->mGameFile == "hl.game")
654 combo_list = g_list_append (combo_list, (void *)sHLComboItem);
655 combo_list = g_list_append (combo_list, (void *)sHLModComboItem);
659 else if (g_pGameDescription->mGameFile == "jk2.game")
661 combo_list = g_list_append (combo_list, (void *)sJK2ComboItem);
662 combo_list = g_list_append (combo_list, (void *)sJK2ModComboItem);
666 else if (g_pGameDescription->mGameFile == "ja.game")
668 combo_list = g_list_append (combo_list, (void *)sJAComboItem);
669 combo_list = g_list_append (combo_list, (void *)sJAModComboItem);
673 else if (g_pGameDescription->mGameFile == "stvef.game")
675 combo_list = g_list_append (combo_list, (void *)sSTVEFComboItem);
676 combo_list = g_list_append (combo_list, (void *)sSTVEFModComboItem);
679 // SOF2 HACK A LA JK2 A LA WOLF
680 else if (g_pGameDescription->mGameFile == "sof2.game")
682 combo_list = g_list_append (combo_list, (void *)sSOF2ComboItem);
683 combo_list = g_list_append (combo_list, (void *)sSOF2ModComboItem);
688 combo_list = g_list_append (combo_list, (void *)sQ3ComboItem);
689 combo_list = g_list_append (combo_list, (void *)sTAComboItem);
690 combo_list = g_list_append (combo_list, (void *)sModComboItem);
693 game_select = gtk_combo_new ();
694 gtk_combo_set_popdown_strings (GTK_COMBO (game_select), combo_list);
695 gtk_widget_show (game_select);
696 gtk_table_attach (GTK_TABLE (table2), game_select, 1, 2, 6, 7,
697 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
698 (GtkAttachOptions) (0), 0, 0);
700 gtk_signal_connect (GTK_OBJECT(GTK_COMBO (game_select)->entry), "changed",
701 GTK_SIGNAL_FUNC (OnSelchangeComboWhatgame), NULL);
703 g_list_free (combo_list);
704 gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (game_select)->entry), FALSE);
706 game = gtk_entry_new();
707 fsgame_entry = GTK_ENTRY(game);
708 gtk_widget_show(game);
709 gtk_table_attach(GTK_TABLE(table2), game, 1, 2, 7, 8,
710 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
711 (GtkAttachOptions) (0), 0, 0);
714 wolf specific: select MP or SP mode
716 if (g_pGameDescription->mGameFile == "wolf.game")
719 combo_list = g_list_append (combo_list, (void *)sWolfSPCombo);
720 combo_list = g_list_append (combo_list, (void *)sWolfMPCombo);
722 gamemode_combo = gtk_combo_new ();
723 gtk_combo_set_popdown_strings (GTK_COMBO (gamemode_combo), combo_list);
724 gtk_widget_show(gamemode_combo);
725 gtk_table_attach (GTK_TABLE (table2), gamemode_combo, 1, 2, 8, 9,
726 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
727 (GtkAttachOptions) (0), 0, 0);
729 g_list_free (combo_list);
732 label = gtk_label_new ("Mapping mode");
733 gtk_widget_show (label);
734 gtk_table_attach (GTK_TABLE (table2), label, 0, 1, 8, 9,
735 (GtkAttachOptions) (GTK_FILL),
736 (GtkAttachOptions) (0), 0, 0);
737 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
742 if (g_pGameDescription->mGameFile == "jk2.game")
745 combo_list = g_list_append (combo_list, (void *)sJK2SPCombo);
746 combo_list = g_list_append (combo_list, (void *)sJK2MPCombo);
748 gamemode_combo = gtk_combo_new ();
749 gtk_combo_set_popdown_strings (GTK_COMBO (gamemode_combo), combo_list);
750 gtk_widget_show(gamemode_combo);
751 gtk_table_attach (GTK_TABLE (table2), gamemode_combo, 1, 2, 8, 9,
752 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
753 (GtkAttachOptions) (0), 0, 0);
755 g_list_free (combo_list);
758 label = gtk_label_new ("Mapping mode");
759 gtk_widget_show (label);
760 gtk_table_attach (GTK_TABLE (table2), label, 0, 1, 8, 9,
761 (GtkAttachOptions) (GTK_FILL),
762 (GtkAttachOptions) (0), 0, 0);
763 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
767 if (g_pGameDescription->mGameFile == "ja.game")
770 combo_list = g_list_append (combo_list, (void *)sJASPCombo);
771 combo_list = g_list_append (combo_list, (void *)sJAMPCombo);
773 gamemode_combo = gtk_combo_new ();
774 gtk_combo_set_popdown_strings (GTK_COMBO (gamemode_combo), combo_list);
775 gtk_widget_show(gamemode_combo);
776 gtk_table_attach (GTK_TABLE (table2), gamemode_combo, 1, 2, 8, 9,
777 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
778 (GtkAttachOptions) (0), 0, 0);
780 g_list_free (combo_list);
783 label = gtk_label_new ("Mapping mode");
784 gtk_widget_show (label);
785 gtk_table_attach (GTK_TABLE (table2), label, 0, 1, 8, 9,
786 (GtkAttachOptions) (GTK_FILL),
787 (GtkAttachOptions) (0), 0, 0);
788 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
792 if (g_pGameDescription->mGameFile == "stvef.game")
795 combo_list = g_list_append (combo_list, (void *)sSTVEFSPCombo);
796 combo_list = g_list_append (combo_list, (void *)sSTVEFMPCombo);
798 gamemode_combo = gtk_combo_new ();
799 gtk_combo_set_popdown_strings (GTK_COMBO (gamemode_combo), combo_list);
800 gtk_widget_show(gamemode_combo);
801 gtk_table_attach (GTK_TABLE (table2), gamemode_combo, 1, 2, 8, 9,
802 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
803 (GtkAttachOptions) (0), 0, 0);
805 g_list_free (combo_list);
808 label = gtk_label_new ("Mapping mode");
809 gtk_widget_show (label);
810 gtk_table_attach (GTK_TABLE (table2), label, 0, 1, 8, 9,
811 (GtkAttachOptions) (GTK_FILL),
812 (GtkAttachOptions) (0), 0, 0);
813 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
817 if (g_pGameDescription->mGameFile == "sof2.game")
820 combo_list = g_list_append (combo_list, (void *)sSOF2SPCombo);
821 combo_list = g_list_append (combo_list, (void *)sSOF2MPCombo);
823 gamemode_combo = gtk_combo_new ();
824 gtk_combo_set_popdown_strings (GTK_COMBO (gamemode_combo), combo_list);
825 gtk_widget_show(gamemode_combo);
826 gtk_table_attach (GTK_TABLE (table2), gamemode_combo, 1, 2, 8, 9,
827 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
828 (GtkAttachOptions) (0), 0, 0);
830 g_list_free (combo_list);
833 label = gtk_label_new ("Mapping mode");
834 gtk_widget_show (label);
835 gtk_table_attach (GTK_TABLE (table2), label, 0, 1, 8, 9,
836 (GtkAttachOptions) (GTK_FILL),
837 (GtkAttachOptions) (0), 0, 0);
838 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
845 base = gtk_entry_new ();
846 g_object_set_data (G_OBJECT (project), "base", base);
847 gtk_widget_show (base);
848 gtk_table_attach (GTK_TABLE (table2), base, 1, 2, 0, 1,
849 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
850 (GtkAttachOptions) (0), 0, 0);
853 label = gtk_label_new ("basepath");
854 gtk_widget_show (label);
855 gtk_table_attach (GTK_TABLE (table2), label, 0, 1, 0, 1,
856 (GtkAttachOptions) (GTK_FILL),
857 (GtkAttachOptions) (0), 0, 0);
858 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
861 label = gtk_label_new ("Select mod");
862 gtk_widget_show (label);
863 gtk_table_attach (GTK_TABLE (table2), label, 0, 1, 6, 7,
864 (GtkAttachOptions) (GTK_FILL),
865 (GtkAttachOptions) (0), 0, 0);
866 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
868 label = gtk_label_new ("fs_game");
869 gtk_widget_show (label);
870 gtk_table_attach (GTK_TABLE (table2), label, 0, 1, 7, 8,
871 (GtkAttachOptions) (GTK_FILL),
872 (GtkAttachOptions) (0), 0, 0);
873 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
876 gtk_entry_set_text (GTK_ENTRY (base), ValueForKey (g_qeglobals.d_project_entity, "basepath"));
877 UpdateBSPCommandList (project);
878 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (brush), (g_qeglobals.m_bBrushPrimitMode) ? TRUE : FALSE);
880 // initialise the fs_game selection from the project settings into the dialog
881 const char *dir = ValueForKey (g_qeglobals.d_project_entity, "gamename");
882 // HACK: hardcoded wolf stuff
883 if (g_pGameDescription->mGameFile == "wolf.game")
885 if ((strlen(dir) == 0) || !stricmp(dir,"main"))
887 // no fs_game set, we are running stock Quake III Arena editing
888 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sWolfComboItem);
889 gtk_entry_set_text (GTK_ENTRY (game), "");
890 gtk_widget_set_sensitive(game, false);
894 // this is a custom mod
895 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sWolfModComboItem);
896 gtk_entry_set_text (GTK_ENTRY (game), dir);
897 gtk_widget_set_sensitive(game, true);
900 // HACK: hardcoded et stuff
901 if (g_pGameDescription->mGameFile == "et.game")
903 if ((strlen(dir) == 0) || !stricmp(dir,"etmain"))
905 // no fs_game set, we are running stock Quake III Arena editing
906 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sETComboItem);
907 gtk_entry_set_text (GTK_ENTRY (game), "");
908 gtk_widget_set_sensitive(game, false);
912 // this is a custom mod
913 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sETModComboItem);
914 gtk_entry_set_text (GTK_ENTRY (game), dir);
915 gtk_widget_set_sensitive(game, true);
918 // HACK: hardcoded half-life stuff
919 else if (g_pGameDescription->mGameFile == "hl.game")
921 if ((strlen(dir) == 0) || !stricmp(dir,"valve"))
923 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sHLComboItem);
924 gtk_entry_set_text (GTK_ENTRY (game), "");
925 gtk_widget_set_sensitive(game, false);
929 // this is a custom mod
930 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sHLModComboItem);
931 gtk_entry_set_text (GTK_ENTRY (game), dir);
932 gtk_widget_set_sensitive(game, true);
937 else if (g_pGameDescription->mGameFile == "jk2.game")
939 if ((strlen(dir) == 0) || !stricmp(dir,"base"))
941 // no fs_game set, we are running stock Quake III Arena editing
942 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sJK2ComboItem);
943 gtk_entry_set_text (GTK_ENTRY (game), "");
944 gtk_widget_set_sensitive(game, false);
948 // this is a custom mod
949 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sJK2ModComboItem);
950 gtk_entry_set_text (GTK_ENTRY (game), dir);
951 gtk_widget_set_sensitive(game, true);
956 else if (g_pGameDescription->mGameFile == "ja.game")
958 if ((strlen(dir) == 0) || !stricmp(dir,"base"))
960 // no fs_game set, we are running stock editing
961 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sJAComboItem);
962 gtk_entry_set_text (GTK_ENTRY (game), "");
963 gtk_widget_set_sensitive(game, false);
967 // this is a custom mod
968 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sJAModComboItem);
969 gtk_entry_set_text (GTK_ENTRY (game), dir);
970 gtk_widget_set_sensitive(game, true);
975 else if (g_pGameDescription->mGameFile == "stvef.game")
977 if ((strlen(dir) == 0) || !stricmp(dir,"baseEf"))
979 // no fs_game set, we are running stock Quake III Arena editing
980 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sSTVEFComboItem);
981 gtk_entry_set_text (GTK_ENTRY (game), "");
982 gtk_widget_set_sensitive(game, false);
986 // this is a custom mod
987 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sSTVEFModComboItem);
988 gtk_entry_set_text (GTK_ENTRY (game), dir);
989 gtk_widget_set_sensitive(game, true);
994 else if (g_pGameDescription->mGameFile == "sof2.game")
996 if ((strlen(dir) == 0) || !stricmp(dir,"base"))
998 // no fs_game set, we are running stock Quake III Arena editing
999 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sSOF2ComboItem);
1000 gtk_entry_set_text (GTK_ENTRY (game), "");
1001 gtk_widget_set_sensitive(game, false);
1005 // this is a custom mod
1006 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sSOF2ModComboItem);
1007 gtk_entry_set_text (GTK_ENTRY (game), dir);
1008 gtk_widget_set_sensitive(game, true);
1013 if ((strlen(dir) == 0) || !strcmp(dir,"baseq3"))
1015 // no fs_game set, we are running stock Quake III Arena editing
1016 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sQ3ComboItem);
1017 gtk_entry_set_text (GTK_ENTRY (game), "");
1018 gtk_widget_set_sensitive(game, false);
1020 else if (!strcmp(dir,"missionpack"))
1022 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sTAComboItem);
1023 gtk_entry_set_text (GTK_ENTRY (game), "missionpack");
1024 gtk_widget_set_sensitive(game, false);
1028 // this is a custom mod
1029 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (game_select)->entry), sModComboItem);
1030 gtk_entry_set_text (GTK_ENTRY (game), dir);
1031 gtk_widget_set_sensitive(game, true);
1035 // HACK: hardcoded wolf stuff
1036 if (g_pGameDescription->mGameFile == "wolf.game")
1038 const char *gamemode = ValueForKey (g_qeglobals.d_project_entity, "gamemode");
1039 if ((strlen(gamemode) == 0) || !strcmp(gamemode,"sp"))
1041 // nothing set yet, or single player
1042 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sWolfSPCombo);
1046 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sWolfMPCombo);
1051 else if (g_pGameDescription->mGameFile == "jk2.game")
1053 const char *gamemode = ValueForKey (g_qeglobals.d_project_entity, "gamemode");
1054 if ((strlen(gamemode) == 0) || !strcmp(gamemode,"sp"))
1056 // nothing set yet, or single player
1057 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sJK2SPCombo);
1061 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sJK2MPCombo);
1065 else if (g_pGameDescription->mGameFile == "ja.game")
1067 const char *gamemode = ValueForKey (g_qeglobals.d_project_entity, "gamemode");
1068 if ((strlen(gamemode) == 0) || !strcmp(gamemode,"sp"))
1070 // nothing set yet, or single player
1071 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sJASPCombo);
1075 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sJAMPCombo);
1079 else if (g_pGameDescription->mGameFile == "stvef.game")
1081 const char *gamemode = ValueForKey (g_qeglobals.d_project_entity, "gamemode");
1082 if ((strlen(gamemode) == 0) || !strcmp(gamemode,"sp"))
1084 // nothing set yet, or single player
1085 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sSTVEFSPCombo);
1089 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sSTVEFMPCombo);
1093 else if (g_pGameDescription->mGameFile == "sof2.game")
1095 const char *gamemode = ValueForKey (g_qeglobals.d_project_entity, "gamemode");
1096 if ((strlen(gamemode) == 0) || !strcmp(gamemode,"sp"))
1098 // nothing set yet, or single player
1099 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sSOF2SPCombo);
1103 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (gamemode_combo)->entry), sSOF2MPCombo);
1107 gtk_grab_add (project);
1108 gtk_widget_show (project);
1110 g_pGameDescription->Dump();
1113 gtk_main_iteration ();
1121 // convert path to unix format
1122 for(r = gtk_entry_get_text (GTK_ENTRY (base)), w=buf; *r != '\0'; r++, w++)
1123 *w = (*r == '\\') ? '/' : *r;
1125 if(w != buf && *(w-1) != '/') *(w++) = '/';
1128 SetKeyValue (g_qeglobals.d_project_entity, "basepath", buf);
1130 dir = gtk_entry_get_text (GTK_ENTRY (game));
1131 // Hack: hard coded wolf stuff
1132 if (g_pGameDescription->mGameFile == "wolf.game")
1134 if (!strlen(dir) || !stricmp(dir,"main"))
1136 DeleteKey (g_qeglobals.d_project_entity, "gamename");
1140 SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
1143 // Hack: hard coded ET stuff
1144 else if (g_pGameDescription->mGameFile == "et.game")
1146 if (!strlen(dir) || !stricmp(dir,"etmain"))
1148 DeleteKey (g_qeglobals.d_project_entity, "gamename");
1152 SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
1155 // Hack: hard coded Half-life stuff
1156 else if (g_pGameDescription->mGameFile == "hl.game")
1158 if (!strlen(dir) || !stricmp(dir,"valve"))
1160 DeleteKey (g_qeglobals.d_project_entity, "gamename");
1164 SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
1167 else if (g_pGameDescription->mGameFile == "jk2.game" || g_pGameDescription->mGameFile == "ja.game")
1169 if (!strlen(dir) || !stricmp(dir,"base"))
1171 DeleteKey (g_qeglobals.d_project_entity, "gamename");
1175 SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
1180 else if (g_pGameDescription->mGameFile == "stvef.game")
1182 if (!strlen(dir) || !stricmp(dir,"baseEf"))
1184 DeleteKey (g_qeglobals.d_project_entity, "gamename");
1188 SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
1193 if (!strlen(dir) || !strcmp(dir,"baseq3"))
1195 DeleteKey (g_qeglobals.d_project_entity, "gamename");
1199 SetKeyValue (g_qeglobals.d_project_entity, "gamename", dir);
1203 // HACK: hardcoded wolf stuff
1204 if (g_pGameDescription->mGameFile == "wolf.game")
1206 // read from gamemode_combo
1207 const char *gamemode = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(gamemode_combo)->entry));
1208 if (!strlen(gamemode) || !strcmp(gamemode, sWolfSPCombo))
1210 SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "sp");
1214 SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "mp");
1220 if (g_pGameDescription->mGameFile == "jk2.game")
1222 // read from gamemode_combo
1223 const char *gamemode = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(gamemode_combo)->entry));
1224 if (!strlen(gamemode) || !strcmp(gamemode, sJK2SPCombo))
1226 SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "sp");
1230 SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "mp");
1235 if (g_pGameDescription->mGameFile == "ja.game")
1237 // read from gamemode_combo
1238 const char *gamemode = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(gamemode_combo)->entry));
1239 if (!strlen(gamemode) || !strcmp(gamemode, sJASPCombo))
1241 SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "sp");
1245 SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "mp");
1251 if (g_pGameDescription->mGameFile == "stvef.game")
1253 // read from gamemode_combo
1254 const char *gamemode = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(gamemode_combo)->entry));
1255 if (!strlen(gamemode) || !strcmp(gamemode, sSTVEFSPCombo))
1257 SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "sp");
1261 SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "mp");
1265 g_qeglobals.m_strHomeMaps = g_qeglobals.m_strHomeGame;
1266 const char* str = ValueForKey(g_qeglobals.d_project_entity, "gamename");
1267 if(str[0] == '\0') str = g_pGameDescription->mBaseGame.GetBuffer();
1268 g_qeglobals.m_strHomeMaps += str;
1269 g_qeglobals.m_strHomeMaps += '/';
1273 if (g_pGameDescription->mGameFile == "sof2.game")
1275 // read from gamemode_combo
1276 const char *gamemode = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO(gamemode_combo)->entry));
1277 if (!strlen(gamemode) || !strcmp(gamemode, sSOF2SPCombo))
1279 SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "sp");
1283 SetKeyValue (g_qeglobals.d_project_entity, "gamemode", "mp");
1287 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (brush)))
1288 g_qeglobals.m_bBrushPrimitMode = TRUE;
1290 g_qeglobals.m_bBrushPrimitMode = FALSE;
1292 SetKeyValue(g_qeglobals.d_project_entity, "brush_primit", (g_qeglobals.m_bBrushPrimitMode ? "1" : "0" ));
1294 QE_SaveProject( g_PrefsDlg.m_strLastProject.GetBuffer() );
1297 gtk_grab_remove (project);
1298 gtk_widget_destroy (project);
1301 // =============================================================================
1306 static GtkWidget *dlg;
1307 GtkWidget *vbox, *vbox2, *hbox, *table, *button, *label, *scr;
1308 GtkWidget *brushes_entry, *entities_entry, *net_entry;
1309 int loop = 1, ret = IDCANCEL;
1314 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1316 load_window_pos(dlg, g_PrefsDlg.mWindowInfo.posMapInfoWnd);
1318 gtk_window_set_title (GTK_WINDOW (dlg), "Map Info");
1319 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
1320 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
1321 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
1322 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
1323 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
1324 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
1326 vbox = gtk_vbox_new (FALSE, 5);
1327 gtk_widget_show (vbox);
1328 gtk_container_add (GTK_CONTAINER (dlg), vbox);
1329 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
1331 hbox = gtk_hbox_new (FALSE, 5);
1332 gtk_widget_show (hbox);
1333 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
1335 table = gtk_table_new (3, 2, FALSE);
1336 gtk_widget_show (table);
1337 gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
1338 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
1339 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
1341 brushes_entry = gtk_entry_new ();
1342 gtk_widget_show (brushes_entry);
1343 gtk_table_attach (GTK_TABLE (table), brushes_entry, 1, 2, 0, 1,
1344 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1345 (GtkAttachOptions) (0), 0, 0);
1346 gtk_entry_set_editable (GTK_ENTRY (brushes_entry), FALSE);
1348 entities_entry = gtk_entry_new ();
1349 gtk_widget_show (entities_entry);
1350 gtk_table_attach (GTK_TABLE (table), entities_entry, 1, 2, 1, 2,
1351 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1352 (GtkAttachOptions) (0), 0, 0);
1353 gtk_entry_set_editable (GTK_ENTRY (entities_entry), FALSE);
1355 net_entry = gtk_entry_new ();
1356 gtk_widget_show (net_entry);
1357 gtk_table_attach (GTK_TABLE (table), net_entry, 1, 2, 2, 3,
1358 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1359 (GtkAttachOptions) (0), 0, 0);
1360 gtk_entry_set_editable (GTK_ENTRY (net_entry), FALSE);
1362 label = gtk_label_new ("Total Brushes");
1363 gtk_widget_show (label);
1364 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
1365 (GtkAttachOptions) (GTK_FILL),
1366 (GtkAttachOptions) (0), 0, 0);
1367 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1369 label = gtk_label_new ("Total Entities");
1370 gtk_widget_show (label);
1371 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
1372 (GtkAttachOptions) (GTK_FILL),
1373 (GtkAttachOptions) (0), 0, 0);
1374 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1376 label = gtk_label_new ("Net brush count\n(non entity)");
1377 gtk_widget_show (label);
1378 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
1379 (GtkAttachOptions) (GTK_FILL),
1380 (GtkAttachOptions) (0), 0, 0);
1381 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1383 vbox2 = gtk_vbox_new (FALSE, 5);
1384 gtk_widget_show (vbox2);
1385 gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
1387 button = gtk_button_new_with_label ("Close");
1388 gtk_widget_show (button);
1389 gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
1390 gtk_signal_connect (GTK_OBJECT (button), "clicked",
1391 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
1392 gtk_widget_set_usize (button, 60, -2);
1394 label = gtk_label_new ("Entity breakdown");
1395 gtk_widget_show (label);
1396 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
1397 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1399 scr = gtk_scrolled_window_new ((GtkAdjustment*)NULL, (GtkAdjustment*)NULL);
1400 gtk_widget_show (scr);
1401 gtk_box_pack_start (GTK_BOX (vbox), scr, TRUE, TRUE, 0);
1402 gtk_container_set_border_width (GTK_CONTAINER (scr), 5);
1403 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1405 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scr), GTK_SHADOW_IN);
1407 GtkListStore* store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
1410 GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1411 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(view), TRUE);
1414 GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
1415 GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Entity", renderer, "text", 0, NULL);
1416 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
1417 gtk_tree_view_column_set_sort_column_id(column, 0);
1421 GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
1422 GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Count", renderer, "text", 1, NULL);
1423 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
1424 gtk_tree_view_column_set_sort_column_id(column, 1);
1427 gtk_widget_show(view);
1429 gtk_container_add(GTK_CONTAINER (scr), view);
1432 // Initialize fields
1433 int TotalBrushes = 0, TotalEntities = 0, Net = 0;
1435 for (brush_t* pBrush = active_brushes.next; pBrush != &active_brushes; pBrush = pBrush->next)
1438 if (pBrush->owner == world_entity)
1448 GSList *l, *entitymap = NULL;
1451 for (entity_t* pEntity = entities.next; pEntity != &entities; pEntity=pEntity->next)
1456 for (l = entitymap; l; l = g_slist_next (l))
1458 entry = (map_t*)l->data;
1460 if (strcmp (entry->name, pEntity->eclass->name) == 0)
1470 entry = (map_t*)qmalloc (sizeof (map_t));
1471 entry->name = pEntity->eclass->name;
1473 entitymap = g_slist_append (entitymap, entry);
1479 entry = (map_t*)entitymap->data;
1481 sprintf (tmp, "%d", entry->count);
1483 gtk_list_store_append(GTK_LIST_STORE(store), &iter);
1484 gtk_list_store_set(GTK_LIST_STORE(store), &iter, 0, entry->name, 1, tmp, -1);
1486 entitymap = g_slist_remove (entitymap, entry);
1489 g_object_unref(G_OBJECT(store));
1492 sprintf (tmp, "%d", TotalBrushes);
1493 gtk_entry_set_text (GTK_ENTRY (brushes_entry), tmp);
1494 sprintf (tmp, "%d", TotalEntities);
1495 gtk_entry_set_text (GTK_ENTRY (entities_entry), tmp);
1496 sprintf (tmp, "%d", Net);
1497 gtk_entry_set_text (GTK_ENTRY (net_entry), tmp);
1500 gtk_widget_show (dlg);
1503 gtk_main_iteration ();
1506 save_window_pos(dlg, g_PrefsDlg.mWindowInfo.posMapInfoWnd);
1508 gtk_grab_remove (dlg);
1509 gtk_widget_destroy (dlg);
1513 // =============================================================================
1514 // Entity List dialog
1516 static void entitylist_select (GtkWidget *widget, gpointer data)
1518 GtkTreeView* view = GTK_TREE_VIEW(g_object_get_data (G_OBJECT (data), "entities"));
1520 GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
1522 GtkTreeModel* model;
1523 GtkTreeIter selected;
1524 if(gtk_tree_selection_get_selected(selection, &model, &selected))
1527 gtk_tree_model_get(model, &selected, 1, &pEntity, -1);
1531 for (epair_t* pEpair = pEntity->epairs; pEpair; pEpair = pEpair->next)
1534 Select_Brush (pEntity->brushes.onext);
1535 Sys_UpdateWindows(W_ALL);
1541 static gint entitylist_click (GtkWidget *widget, GdkEventButton *event, gpointer data)
1543 if (event->type == GDK_2BUTTON_PRESS)
1545 entitylist_select (NULL, data);
1551 static void entitylist_selection_changed(GtkTreeSelection* selection, gpointer data)
1553 GtkListStore* store = GTK_LIST_STORE (g_object_get_data (G_OBJECT (data), "keyvalues"));
1555 gtk_list_store_clear(store);
1557 GtkTreeModel* model;
1558 GtkTreeIter selected;
1559 if(gtk_tree_selection_get_selected(selection, &model, &selected))
1562 gtk_tree_model_get(model, &selected, 1, &pEntity, -1);
1566 for (epair_t* pEpair = pEntity->epairs; pEpair; pEpair = pEpair->next)
1568 GtkTreeIter appended;
1569 gtk_list_store_append(store, &appended);
1570 gtk_list_store_set(store, &appended, 0, pEpair->key, 1, pEpair->value, -1);
1576 void DoEntityList ()
1578 static GtkWidget *dlg;
1579 GtkWidget *vbox, *hbox, *hbox2, *button, *scr;
1580 int loop = 1, ret = IDCANCEL;
1585 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1587 load_window_pos (dlg, g_PrefsDlg.mWindowInfo.posEntityInfoWnd);
1589 gtk_window_set_title (GTK_WINDOW (dlg), "Entities");
1590 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
1591 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
1592 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
1593 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
1594 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
1595 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
1597 hbox = gtk_hbox_new (TRUE, 5);
1598 gtk_widget_show (hbox);
1599 gtk_container_add (GTK_CONTAINER (dlg), hbox);
1600 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
1602 scr = gtk_scrolled_window_new ((GtkAdjustment*)NULL, (GtkAdjustment*)NULL);
1603 gtk_widget_show (scr);
1604 gtk_box_pack_start (GTK_BOX (hbox), scr, TRUE, TRUE, 0);
1605 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1606 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scr), GTK_SHADOW_IN);
1609 GtkTreeStore* store = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
1611 GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1612 g_signal_connect(G_OBJECT(view), "button_press_event", G_CALLBACK(entitylist_click), dlg);
1613 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
1616 GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
1617 GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, NULL);
1618 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
1622 GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1623 g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(entitylist_selection_changed), dlg);
1626 gtk_widget_show(view);
1628 gtk_container_add(GTK_CONTAINER (scr), view);
1629 g_object_set_data (G_OBJECT (dlg), "entities", view);
1634 gtk_tree_store_append(store, &child, NULL);
1635 gtk_tree_store_set(store, &child, 0, world_entity->eclass->name, 1, world_entity, -1);
1638 GSList *l, *entitymap = NULL;
1646 for (entity_t* pEntity=entities.next; pEntity != &entities; pEntity=pEntity->next)
1651 for (l = entitymap; l; l = g_slist_next (l))
1653 entry = (map_t*)l->data;
1655 if (strcmp (entry->name, pEntity->eclass->name) == 0)
1657 parent = entry->node;
1665 gtk_tree_store_append(store, &parent, NULL);
1666 gtk_tree_store_set(store, &parent, 0, pEntity->eclass->name, 1, NULL, -1);
1668 entry = (map_t*)malloc (sizeof(map_t));
1669 entitymap = g_slist_append (entitymap, entry);
1670 entry->name = pEntity->eclass->name;
1671 entry->node = parent;
1675 gtk_tree_store_append(store, &child, &parent);
1676 gtk_tree_store_set(store, &child, 0, pEntity->eclass->name, 1, pEntity, -1);
1681 free (entitymap->data);
1682 entitymap = g_slist_remove (entitymap, entitymap->data);
1686 g_object_unref(G_OBJECT(store));
1689 vbox = gtk_vbox_new (FALSE, 5);
1690 gtk_widget_show (vbox);
1691 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
1693 scr = gtk_scrolled_window_new ((GtkAdjustment*)NULL, (GtkAdjustment*)NULL);
1694 gtk_widget_show (scr);
1695 gtk_box_pack_start (GTK_BOX (vbox), scr, TRUE, TRUE, 0);
1696 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1697 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scr), GTK_SHADOW_IN);
1700 GtkListStore* store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
1702 GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1705 GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
1706 GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Key", renderer, "text", 0, NULL);
1707 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
1711 GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
1712 GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Value", renderer, "text", 1, NULL);
1713 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
1716 gtk_widget_show(view);
1718 g_object_set_data(G_OBJECT(dlg), "keyvalues", store);
1719 gtk_container_add(GTK_CONTAINER (scr), view);
1721 g_object_unref(G_OBJECT(store));
1724 hbox2 = gtk_hbox_new (FALSE, 5);
1725 gtk_widget_show (hbox2);
1726 gtk_box_pack_start (GTK_BOX (vbox), hbox2, TRUE, TRUE, 0);
1728 button = gtk_button_new_with_label ("Select");
1729 gtk_widget_show (button);
1730 gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
1731 gtk_signal_connect (GTK_OBJECT (button), "clicked",
1732 GTK_SIGNAL_FUNC (entitylist_select), dlg);
1733 gtk_widget_set_usize (button, 60, -2);
1735 button = gtk_button_new_with_label ("Close");
1736 gtk_widget_show (button);
1737 gtk_box_pack_end (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
1738 gtk_signal_connect (GTK_OBJECT (button), "clicked",
1739 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
1740 gtk_widget_set_usize (button, 60, -2);
1743 gtk_widget_show (dlg);
1746 gtk_main_iteration ();
1748 save_window_pos (dlg, g_PrefsDlg.mWindowInfo.posMapInfoWnd);
1750 gtk_grab_remove (dlg);
1751 gtk_widget_destroy (dlg);
1756 // =============================================================================
1759 static void rotatedlg_apply (GtkWidget *widget, gpointer data)
1761 GtkSpinButton *spin;
1764 spin = GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (data), "x"));
1765 f = gtk_spin_button_get_value_as_float (spin);
1767 Select_RotateAxis(0,f);
1768 gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), 0.0f); // reset to 0 on Apply
1770 spin = GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (data), "y"));
1771 f = gtk_spin_button_get_value_as_float (spin);
1773 Select_RotateAxis(1,f);
1774 gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), 0.0f);
1776 spin = GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (data), "z"));
1777 f = gtk_spin_button_get_value_as_float (spin);
1779 Select_RotateAxis(2,f);
1780 gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), 0.0f);
1785 GtkWidget *dlg, *hbox, *vbox, *table, *label, *button;
1786 GtkWidget *x, *y, *z;
1788 int loop = 1, ret = IDCANCEL;
1790 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1791 gtk_window_set_title (GTK_WINDOW (dlg), "Arbitrary rotation");
1792 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
1793 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
1794 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
1795 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
1796 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
1797 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
1799 hbox = gtk_hbox_new (FALSE, 5);
1800 gtk_widget_show (hbox);
1801 gtk_container_add (GTK_CONTAINER (dlg), hbox);
1802 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
1804 table = gtk_table_new (3, 2, FALSE);
1805 gtk_widget_show (table);
1806 gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
1807 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
1808 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
1810 label = gtk_label_new (" X ");
1811 gtk_widget_show (label);
1812 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
1813 (GtkAttachOptions) (0),
1814 (GtkAttachOptions) (0), 0, 0);
1816 label = gtk_label_new (" Y ");
1817 gtk_widget_show (label);
1818 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
1819 (GtkAttachOptions) (0),
1820 (GtkAttachOptions) (0), 0, 0);
1822 label = gtk_label_new (" Z ");
1824 gtk_widget_show (label);
1825 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
1826 (GtkAttachOptions) (0),
1827 (GtkAttachOptions) (0), 0, 0);
1829 adj = gtk_adjustment_new (0, -359, 359, 1, 10, 10);
1830 x = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1, 0);
1831 g_object_set_data (G_OBJECT (dlg), "x", x);
1832 gtk_widget_show (x);
1833 gtk_table_attach (GTK_TABLE (table), x, 1, 2, 0, 1,
1834 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1835 (GtkAttachOptions) (0), 0, 0);
1836 gtk_widget_set_usize (x, 60, -2);
1837 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (x), TRUE);
1839 adj = gtk_adjustment_new (0, -359, 359, 1, 10, 10);
1840 y = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1, 0);
1841 g_object_set_data (G_OBJECT (dlg), "y", y);
1842 gtk_widget_show (y);
1843 gtk_table_attach (GTK_TABLE (table), y, 1, 2, 1, 2,
1844 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1845 (GtkAttachOptions) (0), 0, 0);
1846 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (y), TRUE);
1848 adj = gtk_adjustment_new (0, -359, 359, 1, 10, 10);
1849 z = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1, 0);
1850 g_object_set_data (G_OBJECT (dlg), "z", z);
1851 gtk_widget_show (z);
1852 gtk_table_attach (GTK_TABLE (table), z, 1, 2, 2, 3,
1853 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
1854 (GtkAttachOptions) (0), 0, 0);
1855 gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (z), TRUE);
1857 vbox = gtk_vbox_new (FALSE, 5);
1858 gtk_widget_show (vbox);
1859 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
1861 button = gtk_button_new_with_label ("OK");
1862 gtk_widget_show (button);
1863 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1864 gtk_signal_connect (GTK_OBJECT (button), "clicked",
1865 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
1866 gtk_widget_set_usize (button, 60, -2);
1868 button = gtk_button_new_with_label ("Cancel");
1869 gtk_widget_show (button);
1870 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1871 gtk_signal_connect (GTK_OBJECT (button), "clicked",
1872 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
1874 button = gtk_button_new_with_label ("Apply");
1875 gtk_widget_show (button);
1876 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1877 gtk_signal_connect (GTK_OBJECT (button), "clicked",
1878 GTK_SIGNAL_FUNC (rotatedlg_apply), dlg);
1881 gtk_widget_show (dlg);
1884 gtk_main_iteration ();
1887 rotatedlg_apply (button, dlg);
1889 gtk_grab_remove (dlg);
1890 gtk_widget_destroy (dlg);
1893 // =============================================================================
1898 GtkWidget *dlg, *vbox, *hbox, *label, *button, *entry;
1899 int loop = 1, ret = IDCANCEL;
1901 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1902 gtk_window_set_title (GTK_WINDOW (dlg), "Gamma");
1903 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
1904 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
1905 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
1906 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
1907 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
1908 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
1910 hbox = gtk_hbox_new (FALSE, 5);
1911 gtk_widget_show (hbox);
1912 gtk_container_add (GTK_CONTAINER (dlg), hbox);
1913 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
1915 vbox = gtk_vbox_new (FALSE, 5);
1916 gtk_widget_show (vbox);
1917 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
1919 entry = gtk_entry_new ();
1920 gtk_widget_show (entry);
1921 gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
1923 label = gtk_label_new ("0.0 is brightest\n1.0 is darkest");
1924 gtk_widget_show (label);
1925 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
1927 label = gtk_label_new ("You must restart for the\nsettings to take effect");
1928 gtk_widget_show (label);
1929 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
1931 vbox = gtk_vbox_new (FALSE, 5);
1932 gtk_widget_show (vbox);
1933 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
1935 button = gtk_button_new_with_label ("OK");
1936 gtk_widget_show (button);
1937 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1938 gtk_signal_connect (GTK_OBJECT (button), "clicked",
1939 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
1940 gtk_widget_set_usize (button, 60, -2);
1942 button = gtk_button_new_with_label ("Cancel");
1943 gtk_widget_show (button);
1944 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
1945 gtk_signal_connect (GTK_OBJECT (button), "clicked",
1946 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
1948 // Initialize dialog
1950 sprintf (buf, "%1.1f", g_qeglobals.d_savedinfo.fGamma);
1951 gtk_entry_set_text (GTK_ENTRY (entry), buf);
1954 gtk_widget_show (dlg);
1957 gtk_main_iteration ();
1960 g_qeglobals.d_savedinfo.fGamma = g_strtod (gtk_entry_get_text (GTK_ENTRY (entry)), NULL);
1962 gtk_grab_remove (dlg);
1963 gtk_widget_destroy (dlg);
1966 // =============================================================================
1967 // Find Brush Dialog
1969 // helper function to walk through the active brushes only and drop the regioned out ones
1970 bool WalkRegionBrush (brush_t **b, entity_t *e)
1975 for(b2=active_brushes.next ; b2 != &active_brushes ; b2=b2->next)
1978 break; // this is an active brush
1980 if (b2==&active_brushes)
1982 // this is a regioned out brush
1984 if (*b == &e->brushes)
1986 Sys_Status ("No such brush", 0);
1990 } while (b2==&active_brushes);
1994 void SelectBrush (int entitynum, int brushnum)
2000 // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=503
2001 // making this work when regioning is on too
2013 Sys_Status ("No such entity", 0);
2018 // we need to make sure we walk to the next 'active' entity to have a valid --entitynum
2019 // that is, find a brush that belongs to this entity in the active brushes
2022 for (b = active_brushes.next ; b != &active_brushes ; b=b->next)
2025 break; // this is an active entity
2027 if (b==&active_brushes)
2029 // this is a regioned out entity
2031 // don't walk past the end either
2034 Sys_Status ("No such entity", 0);
2038 } while(b==&active_brushes);
2043 b = e->brushes.onext;
2044 if (b == &e->brushes)
2046 Sys_Status ("No such brush", 0);
2051 if (!WalkRegionBrush(&b, e))
2058 if (b == &e->brushes)
2060 Sys_Status ("No such brush", 0);
2065 if (!WalkRegionBrush(&b, e))
2070 Brush_RemoveFromList (b);
2071 Brush_AddToList (b, &selected_brushes);
2073 Sys_UpdateWindows (W_ALL);
2074 for (i = 0; i < 3; i++)
2076 if (g_pParentWnd->GetXYWnd())
2077 g_pParentWnd->GetXYWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
2079 if (g_pParentWnd->GetXZWnd())
2080 g_pParentWnd->GetXZWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
2082 if (g_pParentWnd->GetYZWnd())
2083 g_pParentWnd->GetYZWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
2086 Sys_Status ("Selected", 0);
2089 static void GetSelectionIndex (int *ent, int *brush)
2096 b = selected_brushes.next;
2097 if (b == &selected_brushes)
2101 if (b->owner != world_entity)
2104 for (entity = entities.next; entity != &entities; entity=entity->next, (*ent)++)
2109 for (b2=b->owner->brushes.onext; b2 != b && b2 != &b->owner->brushes; b2=b2->onext, (*brush)++)
2115 GtkWidget *dlg, *vbox, *hbox, *table, *label, *button, *entity, *brush;
2116 int loop = 1, ret = IDCANCEL;
2118 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2119 gtk_window_set_title (GTK_WINDOW (dlg), "Find Brush");
2120 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
2121 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
2122 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
2123 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
2124 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
2125 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
2127 vbox = gtk_vbox_new (FALSE, 5);
2128 gtk_widget_show (vbox);
2129 gtk_container_add (GTK_CONTAINER (dlg), vbox);
2130 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
2132 table = gtk_table_new (2, 2, FALSE);
2133 gtk_widget_show (table);
2134 gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);
2135 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
2136 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2138 label = gtk_label_new ("Entity number");
2139 gtk_widget_show (label);
2140 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
2141 (GtkAttachOptions) (0),
2142 (GtkAttachOptions) (0), 0, 0);
2144 label = gtk_label_new ("Brush number");
2145 gtk_widget_show (label);
2146 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
2147 (GtkAttachOptions) (0),
2148 (GtkAttachOptions) (0), 0, 0);
2150 entity = gtk_entry_new ();
2151 gtk_widget_show (entity);
2152 gtk_table_attach (GTK_TABLE (table), entity, 1, 2, 0, 1,
2153 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
2154 (GtkAttachOptions) (0), 0, 0);
2156 brush = gtk_entry_new ();
2157 gtk_widget_show (brush);
2158 gtk_table_attach (GTK_TABLE (table), brush, 1, 2, 1, 2,
2159 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
2160 (GtkAttachOptions) (0), 0, 0);
2162 hbox = gtk_hbox_new (FALSE, 5);
2163 gtk_widget_show (hbox);
2164 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
2166 button = gtk_button_new_with_label ("OK");
2167 gtk_widget_show (button);
2168 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
2169 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2170 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
2171 gtk_widget_set_usize (button, 60, -2);
2173 button = gtk_button_new_with_label ("Cancel");
2174 gtk_widget_show (button);
2175 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
2176 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2177 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
2179 // Initialize dialog
2183 GetSelectionIndex (&ent, &br);
2184 sprintf (buf, "%i", ent);
2185 gtk_entry_set_text (GTK_ENTRY (entity), buf);
2186 sprintf (buf, "%i", br);
2187 gtk_entry_set_text (GTK_ENTRY (brush), buf);
2190 gtk_widget_show (dlg);
2193 gtk_main_iteration ();
2197 const char *entstr = gtk_entry_get_text (GTK_ENTRY (entity));
2198 const char *brushstr = gtk_entry_get_text (GTK_ENTRY (brush));
2199 SelectBrush (atoi(entstr), atoi(brushstr));
2202 gtk_grab_remove (dlg);
2203 gtk_widget_destroy (dlg);
2206 // =============================================================================
2207 // Arbitrary Sides dialog
2209 void DoSides (bool bCone, bool bSphere, bool bTorus)
2211 GtkWidget *dlg, *vbox, *hbox, *button, *label, *entry;
2212 int loop = 1, ret = IDCANCEL;
2214 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2215 gtk_window_set_title (GTK_WINDOW (dlg), "Arbitrary sides");
2216 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
2217 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
2218 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
2219 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
2220 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
2221 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
2223 hbox = gtk_hbox_new (FALSE, 5);
2224 gtk_widget_show (hbox);
2225 gtk_container_add (GTK_CONTAINER (dlg), hbox);
2226 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
2228 label = gtk_label_new ("Sides:");
2229 gtk_widget_show (label);
2230 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2232 entry = gtk_entry_new ();
2233 gtk_widget_show (entry);
2234 gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
2236 vbox = gtk_vbox_new (FALSE, 5);
2237 gtk_widget_show (vbox);
2238 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, TRUE, 0);
2240 button = gtk_button_new_with_label ("OK");
2241 gtk_widget_show (button);
2242 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
2243 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2244 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
2245 gtk_widget_set_usize (button, 60, -2);
2247 button = gtk_button_new_with_label ("Cancel");
2248 gtk_widget_show (button);
2249 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
2250 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2251 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
2254 gtk_widget_show (dlg);
2257 gtk_main_iteration ();
2261 const char *str = gtk_entry_get_text (GTK_ENTRY (entry));
2264 Brush_MakeSidedCone(atoi(str));
2266 Brush_MakeSidedSphere(atoi(str));
2268 Brush_MakeSided (atoi(str));
2271 gtk_grab_remove (dlg);
2272 gtk_widget_destroy (dlg);
2275 // =============================================================================
2278 void DoNewPatchDlg ()
2280 GtkWidget *dlg, *hbox, *table, *vbox, *label, *button, *combo;
2281 GtkWidget *width, *height;
2282 GList *combo_list = (GList*)NULL;
2283 int loop = 1, ret = IDCANCEL;
2285 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2286 gtk_window_set_title (GTK_WINDOW (dlg), "Patch density");
2287 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
2288 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
2289 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
2290 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
2291 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
2292 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
2294 hbox = gtk_hbox_new (FALSE, 5);
2295 gtk_widget_show (hbox);
2296 gtk_container_add (GTK_CONTAINER (dlg), hbox);
2297 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
2299 table = gtk_table_new (2, 2, FALSE);
2300 gtk_widget_show (table);
2301 gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
2302 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
2303 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2305 label = gtk_label_new ("Width:");
2306 gtk_widget_show (label);
2307 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
2308 (GtkAttachOptions) (GTK_FILL),
2309 (GtkAttachOptions) (0), 0, 0);
2310 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2312 label = gtk_label_new ("Height:");
2313 gtk_widget_show (label);
2314 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
2315 (GtkAttachOptions) (GTK_FILL),
2316 (GtkAttachOptions) (0), 0, 0);
2317 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2319 combo_list = g_list_append (combo_list, (void *)"3");
2320 combo_list = g_list_append (combo_list, (void *)"5");
2321 combo_list = g_list_append (combo_list, (void *)"7");
2322 combo_list = g_list_append (combo_list, (void *)"9");
2323 combo_list = g_list_append (combo_list, (void *)"11");
2324 combo_list = g_list_append (combo_list, (void *)"13");
2325 combo_list = g_list_append (combo_list, (void *)"15");
2327 combo = gtk_combo_new ();
2328 width = GTK_COMBO (combo)->entry;
2329 gtk_combo_set_popdown_strings (GTK_COMBO (combo), combo_list);
2330 gtk_widget_show (combo);
2331 gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 0, 1,
2332 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
2333 (GtkAttachOptions) (0), 0, 0);
2335 combo = gtk_combo_new ();
2336 height = GTK_COMBO (combo)->entry;
2337 gtk_combo_set_popdown_strings (GTK_COMBO (combo), combo_list);
2338 gtk_widget_show (combo);
2339 gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 1, 2,
2340 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
2341 (GtkAttachOptions) (0), 0, 0);
2343 vbox = gtk_vbox_new (FALSE, 5);
2344 gtk_widget_show (vbox);
2345 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2347 button = gtk_button_new_with_label ("OK");
2348 gtk_widget_show (button);
2349 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
2350 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2351 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
2352 gtk_widget_set_usize (button, 60, -2);
2354 button = gtk_button_new_with_label ("Cancel");
2355 gtk_widget_show (button);
2356 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
2357 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2358 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
2360 // Initialize dialog
2361 g_list_free (combo_list);
2362 gtk_entry_set_text (GTK_ENTRY (width), "3");
2363 gtk_entry_set_editable (GTK_ENTRY (width), FALSE);
2364 gtk_entry_set_text (GTK_ENTRY (height), "3");
2365 gtk_entry_set_editable (GTK_ENTRY (height), FALSE);
2368 gtk_widget_show (dlg);
2371 gtk_main_iteration ();
2375 const char* w = gtk_entry_get_text (GTK_ENTRY (width));
2376 const char* h = gtk_entry_get_text (GTK_ENTRY (height));
2378 Patch_GenericMesh(atoi (w), atoi (h), g_pParentWnd->ActiveXY ()->GetViewType ());
2379 Sys_UpdateWindows (W_ALL);
2382 gtk_grab_remove (dlg);
2383 gtk_widget_destroy (dlg);
2386 // =============================================================================
2391 GtkWidget *dlg, *hbox, *table, *vbox, *label, *button;
2392 GtkWidget *x, *y, *z;
2393 int loop = 1, ret = IDCANCEL;
2395 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2396 gtk_window_set_title (GTK_WINDOW (dlg), "Scale");
2397 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
2398 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
2399 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
2400 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
2401 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
2402 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
2404 hbox = gtk_hbox_new (FALSE, 5);
2405 gtk_widget_show (hbox);
2406 gtk_container_add (GTK_CONTAINER (dlg), hbox);
2407 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
2409 table = gtk_table_new (3, 2, FALSE);
2410 gtk_widget_show (table);
2411 gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
2412 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
2413 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2415 label = gtk_label_new ("X:");
2416 gtk_widget_show (label);
2417 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
2418 (GtkAttachOptions) (GTK_FILL),
2419 (GtkAttachOptions) (0), 0, 0);
2420 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2422 label = gtk_label_new ("Y:");
2423 gtk_widget_show (label);
2424 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
2425 (GtkAttachOptions) (GTK_FILL),
2426 (GtkAttachOptions) (0), 0, 0);
2427 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2429 label = gtk_label_new ("Z:");
2430 gtk_widget_show (label);
2431 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
2432 (GtkAttachOptions) (GTK_FILL),
2433 (GtkAttachOptions) (0), 0, 0);
2434 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2436 x = gtk_entry_new ();
2437 gtk_widget_show (x);
2438 gtk_table_attach (GTK_TABLE (table), x, 1, 2, 0, 1,
2439 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
2440 (GtkAttachOptions) (0), 0, 0);
2442 y = gtk_entry_new ();
2443 gtk_widget_show (y);
2444 gtk_table_attach (GTK_TABLE (table), y, 1, 2, 1, 2,
2445 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
2446 (GtkAttachOptions) (0), 0, 0);
2448 z = gtk_entry_new ();
2449 gtk_widget_show (z);
2450 gtk_table_attach (GTK_TABLE (table), z, 1, 2, 2, 3,
2451 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
2452 (GtkAttachOptions) (0), 0, 0);
2454 vbox = gtk_vbox_new (FALSE, 5);
2455 gtk_widget_show (vbox);
2456 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
2458 button = gtk_button_new_with_label ("OK");
2459 gtk_widget_show (button);
2460 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
2461 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2462 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
2463 gtk_widget_set_usize (button, 60, -2);
2465 button = gtk_button_new_with_label ("Cancel");
2466 gtk_widget_show (button);
2467 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
2468 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2469 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
2471 // Initialize dialog
2472 gtk_entry_set_text (GTK_ENTRY (x), "1.0");
2473 gtk_entry_set_text (GTK_ENTRY (y), "1.0");
2474 gtk_entry_set_text (GTK_ENTRY (z), "1.0");
2477 gtk_widget_show (dlg);
2480 gtk_main_iteration ();
2485 sx = atof (gtk_entry_get_text (GTK_ENTRY (x)));
2486 sy = atof (gtk_entry_get_text (GTK_ENTRY (y)));
2487 sz = atof (gtk_entry_get_text (GTK_ENTRY (z)));
2489 if (sx > 0 && sy > 0 && sz > 0)
2491 Select_Scale(sx, sy, sz);
2492 Sys_UpdateWindows (W_ALL);
2495 Sys_Printf("Warning.. Tried to scale by a zero value.");
2498 gtk_grab_remove (dlg);
2499 gtk_widget_destroy (dlg);
2502 // =============================================================================
2503 // Thicken Patch dialog
2505 void DoThickenDlg ()
2507 GtkWidget *dlg, *vbox, *hbox, *vbox2, *button, *label;
2508 GtkWidget *amount, *seams, *group;
2509 int loop = 1, ret = IDCANCEL;
2510 static qboolean bGroupResult = true;
2512 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2513 gtk_window_set_title (GTK_WINDOW (dlg), "Thicken Patch");
2514 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
2515 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
2516 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
2517 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
2518 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
2519 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
2521 vbox = gtk_vbox_new (FALSE, 5);
2522 gtk_widget_show (vbox);
2523 gtk_container_add (GTK_CONTAINER (dlg), vbox);
2524 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
2526 hbox = gtk_hbox_new (FALSE, 5);
2527 gtk_widget_show (hbox);
2528 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
2530 label = gtk_label_new ("This produces a set of patches\n"
2531 "that contains the original patch along with the\n"
2532 "'thick' patch and an optimal set of seam patches.");
2533 gtk_widget_show (label);
2534 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2536 vbox2 = gtk_vbox_new (FALSE, 5);
2537 gtk_widget_show (vbox2);
2538 gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 0);
2540 button = gtk_button_new_with_label ("OK");
2541 gtk_widget_show (button);
2542 gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
2543 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2544 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
2545 gtk_widget_set_usize (button, 60, -2);
2547 button = gtk_button_new_with_label ("Cancel");
2548 gtk_widget_show (button);
2549 gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
2550 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2551 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
2553 hbox = gtk_hbox_new (FALSE, 5);
2554 gtk_widget_show (hbox);
2555 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
2557 label = gtk_label_new ("Amount:");
2558 gtk_widget_show (label);
2559 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2561 amount = gtk_entry_new ();
2562 gtk_widget_show (amount);
2563 gtk_box_pack_start (GTK_BOX (hbox), amount, FALSE, FALSE, 0);
2565 seams = gtk_check_button_new_with_label ("Seams");
2566 gtk_widget_show (seams);
2567 gtk_box_pack_start (GTK_BOX (hbox), seams, FALSE, FALSE, 0);
2570 group = gtk_check_button_new_with_label("Result to func_group");
2571 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(group), bGroupResult);
2572 gtk_box_pack_start(GTK_BOX(vbox), group, FALSE, FALSE, 0);
2573 gtk_widget_show(group);
2576 // Initialize dialog
2577 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (seams), TRUE);
2578 gtk_entry_set_text (GTK_ENTRY (amount), "8");
2581 gtk_widget_show (dlg);
2584 gtk_main_iteration ();
2588 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(group)))
2589 bGroupResult = true;
2591 bGroupResult = false;
2592 Patch_Thicken (atoi (gtk_entry_get_text (GTK_ENTRY (amount))),
2593 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (seams)), bGroupResult);
2594 Sys_UpdateWindows (W_ALL);
2597 gtk_grab_remove (dlg);
2598 gtk_widget_destroy (dlg);
2601 // =============================================================================
2602 // About dialog (no program is complete without one)
2604 void about_button_changelog (GtkWidget *widget, gpointer data)
2608 log += "changelog.txt";
2609 OpenURL(log.GetBuffer());
2612 void about_button_credits (GtkWidget *widget, gpointer data)
2615 cred = g_strAppPath;
2616 cred += "credits.html";
2617 OpenURL(cred.GetBuffer());
2622 GtkWidget *dlg, *vbox, *vbox2, *hbox, *frame, *table, *label, *pixmap, *button, *sc_extensions, *text_extensions;
2623 int loop = 1, ret = IDCANCEL;
2625 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2626 gtk_window_set_title (GTK_WINDOW (dlg), "About GtkRadiant");
2627 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
2628 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
2629 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
2630 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
2631 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
2632 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
2634 vbox = gtk_vbox_new (FALSE, 10);
2635 gtk_widget_show (vbox);
2636 gtk_container_add (GTK_CONTAINER (dlg), vbox);
2637 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
2639 hbox = gtk_hbox_new (FALSE, 5);
2640 gtk_widget_show (hbox);
2641 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
2643 vbox2 = gtk_vbox_new (FALSE, 5);
2644 gtk_widget_show (vbox2);
2645 gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, FALSE, 0);
2647 frame = gtk_frame_new ((char*)NULL);
2648 gtk_widget_show (frame);
2649 gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
2650 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
2652 pixmap = new_pixmap (g_pParentWnd->m_pWidget, "logo.bmp");
2653 gtk_widget_show (pixmap);
2654 gtk_container_add (GTK_CONTAINER (frame), pixmap);
2656 label = gtk_label_new ("GtkRadiant " RADIANT_VERSION "\n"
2658 RADIANT_ABOUTMSG "\n\n"
2659 "By qeradiant.com\n\n"
2660 "This product contains software technology\n"
2661 "from id Software, Inc. ('id Technology').\n"
2662 "id Technology 2000 id Software,Inc.\n\n"
2663 "GtkRadiant is unsupported, however\n"
2664 "you may report your problems at\n"
2665 "http://zerowing.idsoftware.com/bugzilla"
2668 gtk_widget_show (label);
2669 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2670 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
2671 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2673 vbox2 = gtk_vbox_new (FALSE, 5);
2674 gtk_widget_show (vbox2);
2675 gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 0);
2677 button = gtk_button_new_with_label ("OK");
2678 gtk_widget_show (button);
2679 gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
2680 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2681 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
2683 button = gtk_button_new_with_label ("Credits");
2684 gtk_widget_show (button);
2685 gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
2686 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2687 GTK_SIGNAL_FUNC (about_button_credits), NULL);
2689 button = gtk_button_new_with_label ("Changelog");
2690 gtk_widget_show (button);
2691 gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
2692 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2693 GTK_SIGNAL_FUNC (about_button_changelog), NULL);
2695 frame = gtk_frame_new ("OpenGL Properties");
2696 gtk_widget_show (frame);
2697 gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
2699 table = gtk_table_new (3, 2, FALSE);
2700 gtk_widget_show (table);
2701 gtk_container_add (GTK_CONTAINER (frame), table);
2702 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
2703 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2704 gtk_container_set_border_width (GTK_CONTAINER (table), 5);
2706 label = gtk_label_new ("Vendor:");
2707 gtk_widget_show (label);
2708 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
2709 (GtkAttachOptions) (GTK_FILL),
2710 (GtkAttachOptions) (0), 0, 0);
2711 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2713 label = gtk_label_new ("Version:");
2714 gtk_widget_show (label);
2715 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
2716 (GtkAttachOptions) (GTK_FILL),
2717 (GtkAttachOptions) (0), 0, 0);
2718 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2720 label = gtk_label_new ("Renderer:");
2721 gtk_widget_show (label);
2722 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
2723 (GtkAttachOptions) (GTK_FILL),
2724 (GtkAttachOptions) (0), 0, 0);
2725 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2727 label = gtk_label_new ((char*)qglGetString (GL_VENDOR));
2728 gtk_widget_show (label);
2729 gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1,
2730 (GtkAttachOptions) (GTK_FILL),
2731 (GtkAttachOptions) (0), 0, 0);
2732 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2734 label = gtk_label_new ((char*)qglGetString (GL_VERSION));
2735 gtk_widget_show (label);
2736 gtk_table_attach (GTK_TABLE (table), label, 1, 2, 1, 2,
2737 (GtkAttachOptions) (GTK_FILL),
2738 (GtkAttachOptions) (0), 0, 0);
2739 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2741 label = gtk_label_new ((char*)qglGetString (GL_RENDERER));
2742 gtk_widget_show (label);
2743 gtk_table_attach (GTK_TABLE (table), label, 1, 2, 2, 3,
2744 (GtkAttachOptions) (GTK_FILL),
2745 (GtkAttachOptions) (0), 0, 0);
2746 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2748 frame = gtk_frame_new ("OpenGL Extensions");
2749 gtk_widget_show (frame);
2750 gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
2752 hbox = gtk_hbox_new (FALSE, 5);
2753 gtk_widget_show (hbox);
2754 gtk_container_add (GTK_CONTAINER (frame), hbox);
2755 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
2757 sc_extensions = gtk_scrolled_window_new(NULL, NULL);
2758 gtk_box_pack_start(GTK_BOX(hbox), sc_extensions, TRUE, TRUE, 0);
2759 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sc_extensions), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
2760 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sc_extensions), GTK_SHADOW_IN);
2761 gtk_widget_show(sc_extensions);
2763 text_extensions = gtk_text_view_new();
2764 gtk_text_view_set_editable(GTK_TEXT_VIEW(text_extensions), FALSE);
2765 gtk_container_add (GTK_CONTAINER (sc_extensions), text_extensions);
2766 GtkTextBuffer* buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_extensions));
2767 gtk_text_buffer_set_text(buffer, (char *)qglGetString(GL_EXTENSIONS), -1);
2768 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_extensions), GTK_WRAP_WORD);;
2769 gtk_widget_show(text_extensions);
2772 gtk_widget_show (dlg);
2775 gtk_main_iteration ();
2777 gtk_grab_remove (dlg);
2778 gtk_widget_destroy (dlg);
2781 // =============================================================================
2782 // Command List dialog
2784 void DoCommandListDlg ()
2786 GtkWidget *dlg, *vbox, *hbox, *scr, *button;
2787 int loop = 1, ret = IDCANCEL;
2789 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2790 gtk_window_set_title (GTK_WINDOW (dlg), "Mapped Commands");
2791 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
2792 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
2793 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
2794 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
2795 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
2796 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
2797 gtk_window_set_default_size (GTK_WINDOW (dlg), 400, 400);
2799 hbox = gtk_hbox_new (FALSE, 5);
2800 gtk_widget_show (hbox);
2801 gtk_container_add (GTK_CONTAINER (dlg), hbox);
2802 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
2804 scr = gtk_scrolled_window_new ((GtkAdjustment*)NULL, (GtkAdjustment*)NULL);
2805 gtk_widget_show (scr);
2806 gtk_box_pack_start (GTK_BOX (hbox), scr, TRUE, TRUE, 0);
2807 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
2808 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scr), GTK_SHADOW_IN);
2811 GtkListStore* store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
2813 GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2816 GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
2817 GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Command", renderer, "text", 0, NULL);
2818 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
2822 GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
2823 GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Key", renderer, "text", 1, NULL);
2824 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
2827 gtk_widget_show(view);
2828 gtk_container_add(GTK_CONTAINER (scr), view);
2831 // Initialize dialog
2833 path = g_strTempPath;
2834 path += "commandlist.txt";
2836 GSList *cmds = NULL;
2839 for (n = 0; n < g_nCommandCount; n++)
2840 cmds = g_slist_append (cmds, g_Commands[n].m_strCommand);
2841 cmds = g_slist_sort (cmds, (gint (*)(const void *, const void *))strcmp);
2843 Sys_Printf("Writing the command list to %s", path.GetBuffer() );
2844 FILE* fileout = fopen (path.GetBuffer (), "wt");
2848 for (n = 0; n < g_nCommandCount; n++)
2849 if (cmds->data == g_Commands[n].m_strCommand)
2852 char c = g_Commands[n].m_nKey;
2853 CString strLine, strMod(""), strKeys (c);
2855 for (int k = 0; k < g_nKeyCount; k++)
2857 if (g_Keys[k].m_nVKKey == g_Commands[n].m_nKey)
2859 strKeys = g_Keys[k].m_strName;
2864 if (g_Commands[n].m_nModifiers & RAD_SHIFT)
2866 if (g_Commands[n].m_nModifiers & RAD_ALT)
2867 strMod += (strMod.GetLength() > 0) ? " + Alt" : "Alt";
2868 if (g_Commands[n].m_nModifiers & RAD_CONTROL)
2869 strMod += (strMod.GetLength() > 0) ? " + Control" : "Control";
2870 if (strMod.GetLength() > 0)
2876 gtk_list_store_append(store, &iter);
2877 gtk_list_store_set(store, &iter, 0, g_Commands[n].m_strCommand, 1, strMod.GetBuffer (), -1);
2880 if (fileout != NULL)
2882 strLine.Format("%-25s %s\r\n", g_Commands[n].m_strCommand, strMod.GetBuffer ());
2883 fputs (strLine.GetBuffer (), fileout);
2886 cmds = g_slist_remove (cmds, cmds->data);
2889 if (fileout != NULL)
2893 g_object_unref(G_OBJECT(store));
2896 vbox = gtk_vbox_new (FALSE, 5);
2897 gtk_widget_show (vbox);
2898 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
2900 button = gtk_button_new_with_label ("Close");
2901 gtk_widget_show (button);
2902 gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
2903 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2904 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
2905 gtk_widget_set_usize (button, 60, -2);
2908 gtk_widget_show (dlg);
2911 gtk_main_iteration ();
2913 gtk_grab_remove (dlg);
2914 gtk_widget_destroy (dlg);
2917 // =============================================================================
2918 // Texture List dialog
2920 void DoTextureListDlg ()
2922 GtkWidget *dlg, *vbox, *hbox, *scr, *button;
2923 int loop = 1, ret = IDCANCEL;
2925 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
2926 gtk_window_set_title (GTK_WINDOW (dlg), "Textures");
2927 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
2928 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
2929 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
2930 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
2931 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
2932 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
2933 gtk_window_set_default_size (GTK_WINDOW (dlg), 400, 400);
2935 hbox = gtk_hbox_new (FALSE, 5);
2936 gtk_widget_show (hbox);
2937 gtk_container_add (GTK_CONTAINER (dlg), hbox);
2938 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
2940 scr = gtk_scrolled_window_new ((GtkAdjustment*)NULL, (GtkAdjustment*)NULL);
2941 gtk_widget_show (scr);
2942 gtk_box_pack_start (GTK_BOX (hbox), scr, TRUE, TRUE, 0);
2943 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
2944 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scr), GTK_SHADOW_IN);
2946 GtkWidget* texture_list;
2949 GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);
2951 GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
2952 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
2955 GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
2956 GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, NULL);
2957 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
2960 gtk_widget_show(view);
2961 gtk_container_add(GTK_CONTAINER (scr), view);
2964 // Initialize dialog
2965 GSList *textures = (GSList*)NULL;
2966 FillTextureMenu(&textures);
2967 while (textures != NULL)
2971 gtk_list_store_append(store, &iter);
2972 gtk_list_store_set(store, &iter, 0, (gchar*)textures->data, -1);
2974 free (textures->data);
2975 textures = g_slist_remove (textures, textures->data);
2979 g_object_unref(G_OBJECT(store));
2981 texture_list = view;
2984 vbox = gtk_vbox_new (FALSE, 5);
2985 gtk_widget_show (vbox);
2986 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
2988 button = gtk_button_new_with_label ("Load");
2989 gtk_widget_show (button);
2990 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
2991 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2992 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
2993 gtk_widget_set_usize (button, 60, -2);
2995 button = gtk_button_new_with_label ("Close");
2996 gtk_widget_show (button);
2997 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
2998 gtk_signal_connect (GTK_OBJECT (button), "clicked",
2999 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
3000 gtk_widget_set_usize (button, 60, -2);
3003 gtk_widget_show (dlg);
3006 gtk_main_iteration ();
3010 GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(texture_list));
3012 GtkTreeModel* model;
3014 if(gtk_tree_selection_get_selected(selection, &model, &iter))
3016 GtkTreePath* path = gtk_tree_model_get_path(model, &iter);
3017 if(gtk_tree_path_get_depth(path) == 1)
3018 Texture_ShowDirectory(gtk_tree_path_get_indices(path)[0] + CMD_TEXTUREWAD);
3019 gtk_tree_path_free(path);
3023 gtk_grab_remove (dlg);
3024 gtk_widget_destroy (dlg);
3027 // =============================================================================
3030 int DoCapDlg (int *type, bool *b_GroupResult)
3032 GtkWidget *dlg, *vbox, *hbox, *table, *pixmap, *button, *group_toggle, *radio_vbox;
3033 GtkWidget *bevel, *endcap, *ibevel, *iendcap;
3034 GSList *group = (GSList*)NULL;
3035 int loop = 1, ret = IDCANCEL;
3037 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3038 gtk_window_set_title (GTK_WINDOW (dlg), "Cap");
3039 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
3040 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
3041 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
3042 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
3043 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
3044 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
3046 hbox = gtk_hbox_new (FALSE, 5);
3047 gtk_widget_show (hbox);
3048 gtk_container_add (GTK_CONTAINER (dlg), hbox);
3049 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
3051 // Gef: Added a vbox to contain the toggle buttons
3052 radio_vbox = gtk_vbox_new(FALSE, 4);
3053 gtk_container_add(GTK_CONTAINER(hbox), radio_vbox);
3054 gtk_widget_show(radio_vbox);
3056 table = gtk_table_new (4, 2, FALSE);
3057 gtk_widget_show (table);
3058 gtk_box_pack_start (GTK_BOX (radio_vbox), table, TRUE, TRUE, 0);
3059 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
3060 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
3062 pixmap = new_pixmap (g_pParentWnd->m_pWidget, "cap_bevel.bmp");
3063 gtk_widget_show (pixmap);
3064 gtk_table_attach (GTK_TABLE (table), pixmap, 0, 1, 0, 1,
3065 (GtkAttachOptions) (GTK_FILL),
3066 (GtkAttachOptions) (0), 0, 0);
3068 pixmap = new_pixmap (g_pParentWnd->m_pWidget, "cap_endcap.bmp");
3069 gtk_widget_show (pixmap);
3070 gtk_table_attach (GTK_TABLE (table), pixmap, 0, 1, 1, 2,
3071 (GtkAttachOptions) (GTK_FILL),
3072 (GtkAttachOptions) (0), 0, 0);
3074 pixmap = new_pixmap (g_pParentWnd->m_pWidget, "cap_ibevel.bmp");
3075 gtk_widget_show (pixmap);
3076 gtk_table_attach (GTK_TABLE (table), pixmap, 0, 1, 2, 3,
3077 (GtkAttachOptions) (GTK_FILL),
3078 (GtkAttachOptions) (0), 0, 0);
3080 pixmap = new_pixmap (g_pParentWnd->m_pWidget, "cap_iendcap.bmp");
3081 gtk_widget_show (pixmap);
3082 gtk_table_attach (GTK_TABLE (table), pixmap, 0, 1, 3, 4,
3083 (GtkAttachOptions) (GTK_FILL),
3084 (GtkAttachOptions) (0), 0, 0);
3086 bevel = gtk_radio_button_new_with_label (group, "Bevel");
3087 gtk_widget_show (bevel);
3088 gtk_table_attach (GTK_TABLE (table), bevel, 1, 2, 0, 1,
3089 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
3090 (GtkAttachOptions) (0), 0, 0);
3091 group = gtk_radio_button_group (GTK_RADIO_BUTTON (bevel));
3093 endcap = gtk_radio_button_new_with_label (group, "Endcap");
3094 gtk_widget_show (endcap);
3095 gtk_table_attach (GTK_TABLE (table), endcap, 1, 2, 1, 2,
3096 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
3097 (GtkAttachOptions) (0), 0, 0);
3098 group = gtk_radio_button_group (GTK_RADIO_BUTTON (endcap));
3100 ibevel = gtk_radio_button_new_with_label (group, "Inverted Bevel");
3101 gtk_widget_show (ibevel);
3102 gtk_table_attach (GTK_TABLE (table), ibevel, 1, 2, 2, 3,
3103 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
3104 (GtkAttachOptions) (0), 0, 0);
3105 group = gtk_radio_button_group (GTK_RADIO_BUTTON (ibevel));
3107 iendcap = gtk_radio_button_new_with_label (group, "Inverted Endcap");
3108 gtk_widget_show (iendcap);
3109 gtk_table_attach (GTK_TABLE (table), iendcap, 1, 2, 3, 4,
3110 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
3111 (GtkAttachOptions) (0), 0, 0);
3112 group = gtk_radio_button_group (GTK_RADIO_BUTTON (iendcap));
3114 // Gef: added radio toggle for func_grouping capped patches
3115 group_toggle = gtk_check_button_new_with_label("Result to func_group");
3116 gtk_container_add(GTK_CONTAINER(radio_vbox), group_toggle);
3117 gtk_widget_show(group_toggle);
3119 vbox = gtk_vbox_new (FALSE, 5);
3120 gtk_widget_show (vbox);
3121 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
3123 button = gtk_button_new_with_label ("OK");
3124 gtk_widget_show (button);
3125 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
3126 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3127 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
3128 gtk_widget_set_usize (button, 60, -2);
3130 button = gtk_button_new_with_label ("Cancel");
3131 gtk_widget_show (button);
3132 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
3133 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3134 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
3135 gtk_widget_set_usize (button, 60, -2);
3137 // Gef: Set the state of the func_group toggle
3138 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (group_toggle), *b_GroupResult);
3140 // Initialize dialog
3141 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bevel), TRUE);
3144 gtk_widget_show (dlg);
3147 gtk_main_iteration ();
3151 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (bevel)))
3152 *type = BEVEL; //*type = CapDialog::BEVEL;
3153 else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (endcap)))
3154 *type = ENDCAP; //*type = CapDialog::ENDCAP;
3155 else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ibevel)))
3156 *type = IBEVEL; // *type = CapDialog::IBEVEL;
3157 else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (iendcap)))
3158 *type = IENDCAP; // *type = CapDialog::IENDCAP;
3160 // Gef: Added toggle for optional cap func_grouping
3161 *b_GroupResult = (bool *)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(group_toggle));
3164 gtk_grab_remove (dlg);
3165 gtk_widget_destroy (dlg);
3170 // =============================================================================
3173 void DoScriptsDlg ()
3175 GtkWidget *dlg, *vbox, *vbox2, *hbox, *label, *button, *scr;
3176 int loop = 1, ret = IDCANCEL;
3178 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3179 gtk_window_set_title (GTK_WINDOW (dlg), "Available Scripts - Not Implemented Yet");
3180 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
3181 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
3182 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
3183 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
3184 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
3185 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
3187 vbox = gtk_vbox_new (FALSE, 5);
3188 gtk_widget_show (vbox);
3189 gtk_container_add (GTK_CONTAINER (dlg), vbox);
3190 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
3192 label = gtk_label_new ("WARNING: BrushScripting is in a highly experimental state and is\n"
3193 "far from complete. If you attempt to use them it is VERY LIKELY\n"
3194 "that Radiant will crash. Save your work before attempting to\n"
3195 "make use of any scripting features.");
3196 gtk_widget_show (label);
3197 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
3198 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
3199 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
3201 hbox = gtk_hbox_new (FALSE, 5);
3202 gtk_widget_show (hbox);
3203 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
3205 scr = gtk_scrolled_window_new ((GtkAdjustment*)NULL, (GtkAdjustment*)NULL);
3206 gtk_widget_show (scr);
3207 gtk_box_pack_start (GTK_BOX (hbox), scr, TRUE, TRUE, 0);
3208 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
3209 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scr), GTK_SHADOW_IN);
3211 GtkWidget* scripts_list;
3214 GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);
3216 GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
3217 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
3220 GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
3221 GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("", renderer, "text", 0, NULL);
3222 gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
3225 gtk_widget_show(view);
3226 gtk_container_add(GTK_CONTAINER (scr), view);
3229 // Initialize dialog
3231 strINI = g_strGameToolsPath;
3232 strINI += "/scripts.ini";
3235 f = fopen (strINI.GetBuffer(), "rt");
3238 char line[1024], *ptr;
3240 // read section names
3241 while (fgets (line, 1024, f) != 0)
3246 ptr = strchr (line, ']');
3251 gtk_list_store_append(store, &iter);
3252 gtk_list_store_set(store, &iter, 0, line, -1);
3259 g_object_unref(G_OBJECT(store));
3261 scripts_list = view;
3264 vbox2 = gtk_vbox_new (FALSE, 5);
3265 gtk_widget_show (vbox2);
3266 gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
3268 button = gtk_button_new_with_label ("Run");
3269 gtk_widget_show (button);
3270 gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
3271 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3272 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
3273 gtk_widget_set_usize (button, 60, -2);
3275 button = gtk_button_new_with_label ("New...");
3276 gtk_widget_show (button);
3277 gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
3278 gtk_widget_set_sensitive (button, FALSE);
3279 gtk_widget_set_usize (button, 60, -2);
3281 button = gtk_button_new_with_label ("Edit...");
3282 gtk_widget_show (button);
3283 gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
3284 gtk_widget_set_sensitive (button, FALSE);
3285 gtk_widget_set_usize (button, 60, -2);
3287 button = gtk_button_new_with_label ("Close");
3288 gtk_widget_show (button);
3289 gtk_box_pack_end (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
3290 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3291 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
3292 gtk_widget_set_usize (button, 60, -2);
3295 gtk_widget_show (dlg);
3298 gtk_main_iteration ();
3302 GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(scripts_list));
3304 GtkTreeModel* model;
3306 if(gtk_tree_selection_get_selected(selection, &model, &iter))
3309 gtk_tree_model_get(model, &iter, 0, &script, -1);
3310 RunScriptByName(script, true);
3315 gtk_grab_remove (dlg);
3316 gtk_widget_destroy (dlg);
3319 // =============================================================================
3322 int DoBSInputDlg (const char *fields[5], float values[5])
3324 GtkWidget *dlg, *vbox, *hbox, *label, *button;
3325 GtkWidget *entries[5];
3326 int i, loop = 1, ret = IDCANCEL;
3328 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3329 gtk_window_set_title (GTK_WINDOW (dlg), "BrushScript Input");
3330 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
3331 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
3332 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
3333 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
3334 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
3335 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
3337 hbox = gtk_hbox_new (FALSE, 5);
3338 gtk_widget_show (hbox);
3339 gtk_container_add (GTK_CONTAINER (dlg), hbox);
3340 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
3342 vbox = gtk_vbox_new (FALSE, 5);
3343 gtk_widget_show (vbox);
3344 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
3346 // Create entries and initialize them
3347 for (i = 0; i < 5; i++)
3349 if (strlen (fields[i]) == 0)
3352 label = gtk_label_new (fields[i]);
3353 gtk_widget_show (label);
3354 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
3355 gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
3356 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
3358 entries[i] = gtk_entry_new ();
3359 gtk_widget_show (entries[i]);
3360 gtk_box_pack_start (GTK_BOX (vbox), entries[i], TRUE, TRUE, 0);
3363 sprintf (buf, "%f", values[i]);
3364 gtk_entry_set_text (GTK_ENTRY (entries[i]), buf);
3367 vbox = gtk_vbox_new (FALSE, 5);
3368 gtk_widget_show (vbox);
3369 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
3371 button = gtk_button_new_with_label ("OK");
3372 gtk_widget_show (button);
3373 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
3374 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3375 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
3376 gtk_widget_set_usize (button, 60, -2);
3378 button = gtk_button_new_with_label ("Cancel");
3379 gtk_widget_show (button);
3380 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
3381 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3382 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
3383 gtk_widget_set_usize (button, 60, -2);
3386 gtk_widget_show (dlg);
3389 gtk_main_iteration ();
3391 for (i = 0; i < 5; i++)
3393 if (strlen (fields[i]) == 0)
3396 values[i] = atof (gtk_entry_get_text (GTK_ENTRY (entries[i])));
3399 gtk_grab_remove (dlg);
3400 gtk_widget_destroy (dlg);
3405 // =============================================================================
3406 // TextureLayout dialog
3408 int DoTextureLayout (float *fx, float *fy)
3410 GtkWidget *dlg, *vbox, *hbox, *table, *label, *button;
3412 int loop = 1, ret = IDCANCEL;
3414 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3415 gtk_window_set_title (GTK_WINDOW (dlg), "Patch texture layout");
3416 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
3417 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
3418 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
3419 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
3420 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
3421 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
3423 hbox = gtk_hbox_new (FALSE, 5);
3424 gtk_widget_show (hbox);
3425 gtk_container_add (GTK_CONTAINER (dlg), hbox);
3426 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
3428 vbox = gtk_vbox_new (FALSE, 5);
3429 gtk_widget_show (vbox);
3430 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
3432 label = gtk_label_new ("Texture will be fit across the patch based\n"
3433 "on the x and y values given. Values of 1x1\n"
3434 "will \"fit\" the texture. 2x2 will repeat\n"
3436 gtk_widget_show (label);
3437 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
3438 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
3440 table = gtk_table_new (2, 2, FALSE);
3441 gtk_widget_show (table);
3442 gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);
3443 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
3444 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
3446 label = gtk_label_new ("Texture x:");
3447 gtk_widget_show (label);
3448 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
3449 (GtkAttachOptions) (GTK_FILL),
3450 (GtkAttachOptions) (0), 0, 0);
3451 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
3453 label = gtk_label_new ("Texture y:");
3454 gtk_widget_show (label);
3455 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
3456 (GtkAttachOptions) (GTK_FILL),
3457 (GtkAttachOptions) (0), 0, 0);
3458 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
3460 x = gtk_entry_new ();
3461 gtk_widget_show (x);
3462 gtk_table_attach (GTK_TABLE (table), x, 1, 2, 0, 1,
3463 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
3464 (GtkAttachOptions) (0), 0, 0);
3466 y = gtk_entry_new ();
3467 gtk_widget_show (y);
3468 gtk_table_attach (GTK_TABLE (table), y, 1, 2, 1, 2,
3469 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
3470 (GtkAttachOptions) (0), 0, 0);
3472 vbox = gtk_vbox_new (FALSE, 5);
3473 gtk_widget_show (vbox);
3474 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
3476 button = gtk_button_new_with_label ("OK");
3477 gtk_widget_show (button);
3478 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
3479 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3480 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
3481 gtk_widget_set_usize (button, 60, -2);
3483 button = gtk_button_new_with_label ("Cancel");
3484 gtk_widget_show (button);
3485 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
3486 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3487 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
3488 gtk_widget_set_usize (button, 60, -2);
3491 gtk_entry_set_text (GTK_ENTRY (x), "4.0");
3492 gtk_entry_set_text (GTK_ENTRY (y), "4.0");
3495 gtk_widget_show (dlg);
3498 gtk_main_iteration ();
3502 *fx = atof (gtk_entry_get_text (GTK_ENTRY (x)));
3503 *fy = atof (gtk_entry_get_text (GTK_ENTRY (y)));
3506 gtk_grab_remove (dlg);
3507 gtk_widget_destroy (dlg);
3512 // =============================================================================
3515 char* DoNameDlg (const char* title)
3517 GtkWidget *dlg, *vbox, *hbox, *label, *button, *entry;
3518 int loop = 1, ret = IDCANCEL;
3521 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3522 gtk_window_set_title (GTK_WINDOW (dlg), title);
3523 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
3524 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
3525 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
3526 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
3527 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
3528 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
3530 hbox = gtk_hbox_new (FALSE, 5);
3531 gtk_widget_show (hbox);
3532 gtk_container_add (GTK_CONTAINER (dlg), hbox);
3533 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
3535 label = gtk_label_new ("Name:");
3536 gtk_widget_show (label);
3537 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
3539 entry = gtk_entry_new ();
3540 gtk_widget_show (entry);
3541 gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
3543 vbox = gtk_vbox_new (FALSE, 5);
3544 gtk_widget_show (vbox);
3545 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
3547 button = gtk_button_new_with_label ("OK");
3548 gtk_widget_show (button);
3549 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
3550 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3551 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
3552 gtk_widget_set_usize (button, 60, -2);
3554 button = gtk_button_new_with_label ("Cancel");
3555 gtk_widget_show (button);
3556 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
3557 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3558 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
3559 gtk_widget_set_usize (button, 60, -2);
3562 gtk_widget_show (dlg);
3565 gtk_main_iteration ();
3568 str = strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
3572 gtk_grab_remove (dlg);
3573 gtk_widget_destroy (dlg);
3578 // =============================================================================
3579 // NewProject dialog
3581 char* DoNewProjectDlg ()
3583 GtkWidget *dlg, *vbox, *hbox, *label, *button, *entry, *check;
3584 int loop = 1, ret = IDCANCEL;
3587 // start by a warning message
3588 // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=459
3590 msg = "Are you sure you want a new project?\n";
3591 msg += "Please note that creating a new project is not the prefered way to setup GtkRadiant for mod editing.\n";
3592 msg += "Check http://www.qeradiant.com/faq/index.cgi?file=220 for more information";
3593 if (gtk_MessageBox(NULL, msg.GetBuffer(), "Confirm", MB_YESNO, "http://www.qeradiant.com/faq/index.cgi?file=220" ) == IDNO)
3598 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3599 gtk_window_set_title (GTK_WINDOW (dlg), "New Project");
3600 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
3601 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
3602 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
3603 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
3604 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
3605 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
3607 hbox = gtk_hbox_new (FALSE, 10);
3608 gtk_widget_show (hbox);
3609 gtk_container_add (GTK_CONTAINER (dlg), hbox);
3610 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
3612 vbox = gtk_vbox_new (FALSE, 5);
3613 gtk_widget_show (vbox);
3614 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
3616 label = gtk_label_new ("This will create a new directory beneath your\n"
3617 "game path based on the project name you give.");
3618 gtk_widget_show (label);
3619 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
3620 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
3622 label = gtk_label_new ("Project name:");
3623 gtk_widget_show (label);
3624 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
3625 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
3626 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
3628 entry = gtk_entry_new ();
3629 gtk_widget_show (entry);
3630 gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
3632 check = gtk_check_button_new_with_label ("Include game dll files");
3633 gtk_widget_show (check);
3634 gtk_box_pack_start (GTK_BOX (vbox), check, TRUE, TRUE, 0);
3635 gtk_widget_set_sensitive (check, FALSE);
3637 vbox = gtk_vbox_new (FALSE, 5);
3638 gtk_widget_show (vbox);
3639 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
3641 button = gtk_button_new_with_label ("OK");
3642 gtk_widget_show (button);
3643 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
3644 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3645 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
3646 gtk_widget_set_usize (button, 60, -2);
3648 button = gtk_button_new_with_label ("Cancel");
3649 gtk_widget_show (button);
3650 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
3651 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3652 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
3653 gtk_widget_set_usize (button, 60, -2);
3656 gtk_widget_show (dlg);
3659 gtk_main_iteration ();
3662 str = strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
3666 gtk_grab_remove (dlg);
3667 gtk_widget_destroy (dlg);
3672 // =============================================================================
3673 // Text Editor dialog
3675 // master window widget
3676 static GtkWidget *text_editor = NULL;
3677 static GtkWidget *text_widget; // slave, text widget from the gtk editor
3679 static gint editor_delete (GtkWidget *widget, gpointer data)
3681 if (gtk_MessageBox (widget, "Close the shader editor ?", "Radiant", MB_YESNO) == IDNO)
3684 gtk_widget_hide (text_editor);
3689 static void editor_save (GtkWidget *widget, gpointer data)
3691 FILE *f = fopen ((char*)g_object_get_data (G_OBJECT (data), "filename"), "w");
3692 gpointer text = g_object_get_data (G_OBJECT (data), "text");
3696 gtk_MessageBox (GTK_WIDGET(data), "Error saving file !");
3700 char *str = gtk_editable_get_chars (GTK_EDITABLE (text), 0, -1);
3701 fwrite (str, 1, strlen (str), f);
3705 static void editor_close (GtkWidget *widget, gpointer data)
3707 if (gtk_MessageBox (text_editor, "Close the shader editor ?", "Radiant", MB_YESNO) == IDNO)
3710 gtk_widget_hide (text_editor);
3714 // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=355
3718 HWND FindEditWindow()
3720 return FindWindow("TFormEditPadLite", NULL);
3723 HWND FindEditWindow()
3725 HWND hwnd = FindWindow("TFormEditPadLite", NULL);
3728 hwnd = FindWindowEx(hwnd, NULL, "TPanel", NULL);
3731 hwnd = FindWindowEx(hwnd, NULL, "TPanel", NULL);
3734 hwnd = FindWindowEx(hwnd, NULL, "TEditPadEditor", NULL);
3737 hwnd = FindWindowEx(hwnd, NULL, "TWinControlProxy", NULL);
3746 HWND FindEditWindow()
3748 HWND hwnd = FindWindow("TFormEditPadLite", NULL);
3751 hwnd = FindWindowEx(hwnd, NULL, "TPanel", NULL);
3754 hwnd = FindWindowEx(hwnd, NULL, "TPanel", NULL);
3757 hwnd = FindWindowEx(hwnd, NULL, "TPanel", NULL);
3760 hwnd = FindWindowEx(hwnd, NULL, "TFrameSearchReplace", NULL);
3763 hwnd = FindWindowEx(hwnd, NULL, "TJGStringEditorControl", NULL);
3773 HWND FindEditWindow()
3775 HWND hwnd = FindWindow("TEditPadForm", NULL);
3776 HWND hwndEdit = NULL;
3779 HWND hwndTab = FindWindowEx(hwnd, NULL, "TTabControl", NULL);
3780 if (hwndTab != NULL)
3782 hwndEdit = FindWindowEx(hwndTab, NULL, "TRicherEdit", NULL);
3790 static void CreateGtkTextEditor ()
3793 GtkWidget *vbox, *hbox, *button, *scr, *text;
3795 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3797 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
3798 GTK_SIGNAL_FUNC (editor_delete), NULL);
3799 gtk_window_set_default_size (GTK_WINDOW (dlg), 600, 300);
3801 vbox = gtk_vbox_new (FALSE, 5);
3802 gtk_widget_show (vbox);
3803 gtk_container_add (GTK_CONTAINER (dlg), vbox);
3804 gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
3806 scr = gtk_scrolled_window_new (NULL, NULL);
3807 gtk_widget_show (scr);
3808 gtk_box_pack_start (GTK_BOX (vbox), scr, TRUE, TRUE, 0);
3809 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
3810 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scr), GTK_SHADOW_IN);
3812 text = gtk_text_view_new();
3813 gtk_container_add (GTK_CONTAINER (scr), text);
3814 gtk_widget_show (text);
3815 g_object_set_data (G_OBJECT (dlg), "text", text);
3816 gtk_text_view_set_editable (GTK_TEXT_VIEW(text), TRUE);
3818 hbox = gtk_hbox_new (FALSE, 5);
3819 gtk_widget_show (hbox);
3820 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
3822 button = gtk_button_new_with_label ("Close");
3823 gtk_widget_show (button);
3824 gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
3825 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3826 GTK_SIGNAL_FUNC (editor_close), dlg);
3827 gtk_widget_set_usize (button, 60, -2);
3829 button = gtk_button_new_with_label ("Save");
3830 gtk_widget_show (button);
3831 gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
3832 gtk_signal_connect (GTK_OBJECT (button), "clicked",
3833 GTK_SIGNAL_FUNC (editor_save), dlg);
3834 gtk_widget_set_usize (button, 60, -2);
3840 static void DoGtkTextEditor (const char* filename, guint cursorpos)
3843 CreateGtkTextEditor(); // build it the first time we need it
3846 FILE *f = fopen (filename, "r");
3850 Sys_Printf("Unable to load file %s in shader editor.\n", filename);
3851 gtk_widget_hide (text_editor);
3855 fseek (f, 0, SEEK_END);
3856 int len = ftell (f);
3857 void *buf = qmalloc (len);
3861 fread (buf, 1, len, f);
3863 gtk_window_set_title (GTK_WINDOW (text_editor), filename);
3865 GtkTextBuffer* text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_widget));
3866 gtk_text_buffer_set_text(text_buffer, (char*)buf, len);
3868 old_filename = g_object_get_data (G_OBJECT (text_editor), "filename");
3871 g_object_set_data (G_OBJECT (text_editor), "filename", strdup (filename));
3873 // trying to show later
3874 gtk_widget_show (text_editor);
3877 while (gtk_events_pending ())
3878 gtk_main_iteration ();
3881 // only move the cursor if it's not exceeding the size..
3882 // NOTE: this is erroneous, cursorpos is the offset in bytes, not in characters
3883 // len is the max size in bytes, not in characters either, but the character count is below that limit..
3884 // thinking .. the difference between character count and byte count would be only because of CR/LF?
3886 GtkTextIter text_iter;
3887 // character offset, not byte offset
3888 gtk_text_buffer_get_iter_at_offset(text_buffer, &text_iter, cursorpos);
3889 gtk_text_buffer_place_cursor(text_buffer, &text_iter);
3893 gtk_widget_queue_draw(text_widget);
3901 void DoTextEditor (const char* filename, int cursorpos)
3903 CString strEditCommand;
3905 if (g_PrefsDlg.m_bUseWin32Editor)
3907 Sys_Printf("opening file '%s' (line %d info ignored)\n", filename);
3908 ShellExecute((HWND)GDK_WINDOW_HWND (g_pParentWnd->m_pWidget->window), "open", filename, NULL, NULL, SW_SHOW );
3912 // check if a custom editor is set
3913 if((g_PrefsDlg.m_bUseCustomEditor) && (g_PrefsDlg.m_strEditorCommand.GetLength() > 0))
3915 strEditCommand = g_PrefsDlg.m_strEditorCommand;
3916 strEditCommand += " \"";
3917 strEditCommand += filename;
3918 strEditCommand += "\"";
3920 Sys_Printf("Launching: %s\n", strEditCommand.GetBuffer());
3921 // note: linux does not return false if the command failed so it will assume success
3922 if (Q_Exec(NULL, (char *)strEditCommand.GetBuffer(), NULL, true) == false)
3924 Sys_FPrintf(SYS_WRN, "Warning: Failed to execute %s, using default\n", strEditCommand.GetBuffer());
3928 // the command (appeared) to run successfully, no need to do anything more
3934 DoGtkTextEditor (filename, cursorpos);
3936 // old win32 code with EditPad bindings, broken
3937 // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=355
3939 strEditCommand = g_strAppPath.GetBuffer();
3940 strEditCommand += "editpad.exe";
3941 strEditCommand += " \"";
3942 strEditCommand += filename;
3943 strEditCommand += "\"";
3944 if (Q_Exec(NULL, (char *)strEditCommand.GetBuffer(), NULL, true) == false)
3946 Sys_FPrintf(SYS_WRN, "WARNING: Gtk shader editor is not fully functional on windows in general and unstable on win98 in particular.\n");
3947 Sys_FPrintf(SYS_WRN, " you can use EditPad instead (install it in Radiant's directory): http://www.qeradiant.com/?data=files&files_dir=18\n");
3948 DoGtkTextEditor (filename, cursorpos);
3952 // TTimo: we used to call Delay here, to continue processing messages. But it seems to induce a lot of instabilities.
3953 // so now the user will simply have to wait.
3956 // now grab the edit window and scroll to the shader we want to edit
3957 HWND hwndEdit = FindEditWindow();
3959 if (hwndEdit != NULL)
3960 PostMessage(hwndEdit, EM_SETSEL, cursorpos, cursorpos);
3962 Sys_Printf("Unable to load shader editor.\n");
3967 // =============================================================================
3968 // Light Intensity dialog
3970 int DoLightIntensityDlg (int *intensity)
3972 GtkWidget *dlg, *vbox, *hbox, *label, *button, *entry;
3973 int loop = 1, ret = IDCANCEL;
3975 dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
3976 gtk_window_set_title (GTK_WINDOW (dlg), "Light intensity");
3977 gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
3978 GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
3979 gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
3980 GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
3981 g_object_set_data (G_OBJECT (dlg), "loop", &loop);
3982 g_object_set_data (G_OBJECT (dlg), "ret", &ret);
3984 GtkAccelGroup *accel_group = gtk_accel_group_new ();
3985 gtk_window_add_accel_group (GTK_WINDOW (dlg), accel_group);
3987 hbox = gtk_hbox_new (FALSE, 5);
3988 gtk_widget_show (hbox);
3989 gtk_container_add (GTK_CONTAINER (dlg), hbox);
3990 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
3992 vbox = gtk_vbox_new (FALSE, 5);
3993 gtk_widget_show (vbox);
3994 gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
3996 label = gtk_label_new ("ESC for default, ENTER to validate");
3997 gtk_widget_show (label);
3998 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
4000 entry = gtk_entry_new ();
4001 gtk_widget_show (entry);
4002 gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);
4004 vbox = gtk_vbox_new (FALSE, 5);
4005 gtk_widget_show (vbox);
4006 gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
4008 button = gtk_button_new_with_label ("OK");
4009 gtk_widget_show (button);
4010 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
4011 gtk_signal_connect (GTK_OBJECT (button), "clicked",
4012 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
4013 gtk_widget_add_accelerator (button, "clicked", accel_group,
4014 GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE);
4015 gtk_widget_set_usize (button, 60, -2);
4017 button = gtk_button_new_with_label ("Cancel");
4018 gtk_widget_show (button);
4019 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
4020 gtk_signal_connect (GTK_OBJECT (button), "clicked",
4021 GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
4022 gtk_widget_add_accelerator (button, "clicked", accel_group,
4023 GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE);
4024 gtk_widget_set_usize (button, 60, -2);
4027 sprintf (buf, "%d", *intensity);
4028 gtk_entry_set_text (GTK_ENTRY (entry), buf);
4031 gtk_widget_show (dlg);
4034 gtk_main_iteration ();
4037 *intensity = atoi (gtk_entry_get_text (GTK_ENTRY (entry)));
4039 gtk_grab_remove (dlg);
4040 gtk_widget_destroy (dlg);