2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 // Main Window for Q3Radiant
25 // Leonardo Zide (leo@lokigames.com)
28 #include "mainframe.h"
30 #include "debugging/debugging.h"
33 #include "ifilesystem.h"
41 #include "moduleobserver.h"
45 #include <gdk/gdkkeysyms.h>
46 #include <gtk/gtkhbox.h>
47 #include <gtk/gtkvbox.h>
48 #include <gtk/gtkframe.h>
49 #include <gtk/gtklabel.h>
50 #include <gtk/gtkhpaned.h>
51 #include <gtk/gtkvpaned.h>
52 #include <gtk/gtktoolbar.h>
53 #include <gtk/gtkmenubar.h>
54 #include <gtk/gtkimage.h>
55 #include <gtk/gtktable.h>
60 #include "stream/stringstream.h"
63 #include "eclasslib.h"
64 #include "moduleobservers.h"
66 #include "gtkutil/clipboard.h"
67 #include "gtkutil/container.h"
68 #include "gtkutil/frame.h"
69 #include "gtkutil/glfont.h"
70 #include "gtkutil/glwidget.h"
71 #include "gtkutil/image.h"
72 #include "gtkutil/menu.h"
73 #include "gtkutil/paned.h"
74 #include "gtkutil/widget.h"
78 #include "brushmanip.h"
79 #include "brushmodule.h"
80 #include "camwindow.h"
85 #include "entityinspector.h"
86 #include "entitylist.h"
88 #include "findtexturedialog.h"
90 #include "groupdialog.h"
97 #include "patchdialog.h"
98 #include "patchmanip.h"
100 #include "pluginmanager.h"
101 #include "pluginmenu.h"
102 #include "plugintoolbar.h"
104 #include "preferences.h"
109 #include "surfacedialog.h"
110 #include "textures.h"
111 #include "texwindow.h"
113 #include "xywindow.h"
114 #include "windowobservers.h"
115 #include "renderstate.h"
116 #include "feedback.h"
117 #include "referencecache.h"
121 struct layout_globals_t
123 WindowPosition m_position;
133 m_position(-1, -1, 640, 480),
139 nState(GDK_WINDOW_STATE_MAXIMIZED)
144 layout_globals_t g_layout_globals;
145 glwindow_globals_t g_glwindow_globals;
149 class VFSModuleObserver : public ModuleObserver
151 std::size_t m_unrealised;
153 VFSModuleObserver() : m_unrealised(1)
158 if(--m_unrealised == 0)
161 GlobalFileSystem().initialise();
166 if(++m_unrealised == 1)
168 GlobalFileSystem().shutdown();
173 VFSModuleObserver g_VFSModuleObserver;
177 Radiant_attachHomePathsObserver(g_VFSModuleObserver);
181 Radiant_detachHomePathsObserver(g_VFSModuleObserver);
187 void HomePaths_Realise()
189 #if defined (__linux__) || defined (__APPLE__)
190 const char* prefix = g_pGameDescription->getKeyValue("prefix");
191 if(!string_empty(prefix))
193 StringOutputStream path(256);
194 path << DirectoryCleaned(g_get_home_dir()) << prefix << "/";
195 g_qeglobals.m_userEnginePath = path.c_str();
196 Q_mkdir(g_qeglobals.m_userEnginePath.c_str());
201 g_qeglobals.m_userEnginePath = EnginePath_get();
205 StringOutputStream path(256);
206 path << g_qeglobals.m_userEnginePath.c_str() << gamename_get() << '/';
207 g_qeglobals.m_userGamePath = path.c_str();
209 ASSERT_MESSAGE(!string_empty(g_qeglobals.m_userGamePath.c_str()), "HomePaths_Realise: user-game-path is empty");
210 Q_mkdir(g_qeglobals.m_userGamePath.c_str());
213 ModuleObservers g_homePathObservers;
215 void Radiant_attachHomePathsObserver(ModuleObserver& observer)
217 g_homePathObservers.attach(observer);
220 void Radiant_detachHomePathsObserver(ModuleObserver& observer)
222 g_homePathObservers.detach(observer);
225 class HomePathsModuleObserver : public ModuleObserver
227 std::size_t m_unrealised;
229 HomePathsModuleObserver() : m_unrealised(1)
234 if(--m_unrealised == 0)
237 g_homePathObservers.realise();
242 if(++m_unrealised == 1)
244 g_homePathObservers.unrealise();
249 HomePathsModuleObserver g_HomePathsModuleObserver;
251 void HomePaths_Construct()
253 Radiant_attachEnginePathObserver(g_HomePathsModuleObserver);
255 void HomePaths_Destroy()
257 Radiant_detachEnginePathObserver(g_HomePathsModuleObserver);
263 CopiedString g_strEnginePath;
264 ModuleObservers g_enginePathObservers;
265 std::size_t g_enginepath_unrealised = 1;
267 void Radiant_attachEnginePathObserver(ModuleObserver& observer)
269 g_enginePathObservers.attach(observer);
272 void Radiant_detachEnginePathObserver(ModuleObserver& observer)
274 g_enginePathObservers.detach(observer);
278 void EnginePath_Realise()
280 if(--g_enginepath_unrealised == 0)
282 g_enginePathObservers.realise();
287 const char* EnginePath_get()
289 ASSERT_MESSAGE(g_enginepath_unrealised == 0, "EnginePath_get: engine path not realised");
290 return g_strEnginePath.c_str();
293 void EnginePath_Unrealise()
295 if(++g_enginepath_unrealised == 1)
297 g_enginePathObservers.unrealise();
301 void setEnginePath(const char* path)
303 StringOutputStream buffer(256);
304 buffer << DirectoryCleaned(path);
305 if(!path_equal(buffer.c_str(), g_strEnginePath.c_str()))
308 while(!ConfirmModified("Paths Changed"))
310 if(Map_Unnamed(g_map))
322 ScopeDisableScreenUpdates disableScreenUpdates("Processing...", "Changing Engine Path");
324 EnginePath_Unrealise();
326 g_strEnginePath = buffer.c_str();
328 EnginePath_Realise();
335 CopiedString g_strAppPath; ///< holds the full path of the executable
337 const char* AppPath_get()
339 return g_strAppPath.c_str();
342 /// directory for temp files
343 /// NOTE: on *nix this is were we check for .pid
344 CopiedString g_strSettingsPath;
345 const char* SettingsPath_get()
347 return g_strSettingsPath.c_str();
352 points to the game tools directory, for instance
353 C:/Program Files/Quake III Arena/GtkRadiant
355 this is one of the main variables that are configured by the game selection on startup
356 [GameToolsPath]/plugins
357 [GameToolsPath]/modules
360 CopiedString g_strGameToolsPath; ///< this is set by g_GamesDialog
362 const char* GameToolsPath_get()
364 return g_strGameToolsPath.c_str();
367 void EnginePathImport(CopiedString& self, const char* value)
369 setEnginePath(value);
371 typedef ReferenceCaller1<CopiedString, const char*, EnginePathImport> EnginePathImportCaller;
373 void Paths_constructPreferences(PreferencesPage& page)
375 page.appendPathEntry("Engine Path", true,
376 StringImportCallback(EnginePathImportCaller(g_strEnginePath)),
377 StringExportCallback(StringExportCaller(g_strEnginePath))
380 void Paths_constructPage(PreferenceGroup& group)
382 PreferencesPage page(group.createPage("Paths", "Path Settings"));
383 Paths_constructPreferences(page);
385 void Paths_registerPreferencesPage()
387 PreferencesDialog_addSettingsPage(FreeCaller1<PreferenceGroup&, Paths_constructPage>());
391 class PathsDialog : public Dialog
394 GtkWindow* BuildDialog()
396 GtkFrame* frame = create_dialog_frame("Path settings", GTK_SHADOW_ETCHED_IN);
398 GtkVBox* vbox2 = create_dialog_vbox(0, 4);
399 gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(vbox2));
402 PreferencesPage preferencesPage(*this, GTK_WIDGET(vbox2));
403 Paths_constructPreferences(preferencesPage);
406 return create_simple_modal_dialog_window("Engine Path Not Found", m_modal, GTK_WIDGET(frame));
410 PathsDialog g_PathsDialog;
412 void EnginePath_verify()
414 if(!file_exists(g_strEnginePath.c_str()))
416 g_PathsDialog.Create();
417 g_PathsDialog.DoModal();
418 g_PathsDialog.Destroy();
424 CopiedString g_gamename;
425 CopiedString g_gamemode;
426 ModuleObservers g_gameNameObservers;
427 ModuleObservers g_gameModeObservers;
430 void Radiant_attachGameNameObserver(ModuleObserver& observer)
432 g_gameNameObservers.attach(observer);
435 void Radiant_detachGameNameObserver(ModuleObserver& observer)
437 g_gameNameObservers.detach(observer);
440 const char* basegame_get()
442 return g_pGameDescription->getRequiredKeyValue("basegame");
445 const char* gamename_get()
447 const char* gamename = g_gamename.c_str();
448 if(string_empty(gamename))
450 return basegame_get();
455 void gamename_set(const char* gamename)
457 if(!string_equal(gamename, g_gamename.c_str()))
459 g_gameNameObservers.unrealise();
460 g_gamename = gamename;
461 g_gameNameObservers.realise();
465 void Radiant_attachGameModeObserver(ModuleObserver& observer)
467 g_gameModeObservers.attach(observer);
470 void Radiant_detachGameModeObserver(ModuleObserver& observer)
472 g_gameModeObservers.detach(observer);
475 const char* gamemode_get()
477 return g_gamemode.c_str();
480 void gamemode_set(const char* gamemode)
482 if(!string_equal(gamemode, g_gamemode.c_str()))
484 g_gameModeObservers.unrealise();
485 g_gamemode = gamemode;
486 g_gameModeObservers.realise();
496 LoadModule(const char* path) : m_path(path)
499 void operator()(const char* name) const
502 ASSERT_MESSAGE(strlen(m_path) + strlen(name) < 1024, "");
503 strcpy(fullname, m_path);
504 strcat(fullname, name);
505 globalOutputStream() << "Found '" << fullname << "'\n";
506 GlobalModuleServer_loadModule(fullname);
510 const char* const c_library_extension =
513 #elif defined(__linux__)
515 #elif defined (__APPLE__)
520 void Radiant_loadModules(const char* path)
522 Directory_forEach(path, MatchFileExtension<LoadModule>(c_library_extension, LoadModule(path)));
525 void Radiant_loadModulesFromRoot(const char* directory)
528 StringOutputStream path(256);
529 path << directory << g_pluginsDir;
530 Radiant_loadModules(path.c_str());
533 if(!string_equal(g_pluginsDir, g_modulesDir))
535 StringOutputStream path(256);
536 path << directory << g_modulesDir;
537 Radiant_loadModules(path.c_str());
541 //! Make COLOR_BRUSHES override worldspawn eclass colour.
542 void SetWorldspawnColour(const Vector3& colour)
544 EntityClass* worldspawn = GlobalEntityClassManager().findOrInsert("worldspawn", true);
545 eclass_release_state(worldspawn);
546 worldspawn->color = colour;
547 eclass_capture_state(worldspawn);
551 class WorldspawnColourEntityClassObserver : public ModuleObserver
553 std::size_t m_unrealised;
555 WorldspawnColourEntityClassObserver() : m_unrealised(1)
560 if(--m_unrealised == 0)
562 SetWorldspawnColour(g_xywindow_globals.color_brushes);
567 if(++m_unrealised == 1)
573 WorldspawnColourEntityClassObserver g_WorldspawnColourEntityClassObserver;
576 ModuleObservers g_gameToolsPathObservers;
578 void Radiant_attachGameToolsPathObserver(ModuleObserver& observer)
580 g_gameToolsPathObservers.attach(observer);
583 void Radiant_detachGameToolsPathObserver(ModuleObserver& observer)
585 g_gameToolsPathObservers.detach(observer);
588 void Radiant_Initialise()
590 GlobalModuleServer_Initialise();
592 Radiant_loadModulesFromRoot(AppPath_get());
596 bool success = Radiant_Construct(GlobalModuleServer_get());
597 ASSERT_MESSAGE(success, "module system failed to initialise - see radiant.log for error messages");
599 g_gameToolsPathObservers.realise();
600 g_gameModeObservers.realise();
601 g_gameNameObservers.realise();
604 void Radiant_Shutdown()
606 g_gameNameObservers.unrealise();
607 g_gameModeObservers.unrealise();
608 g_gameToolsPathObservers.unrealise();
610 if (!g_preferences_globals.disable_ini)
612 globalOutputStream() << "Start writing prefs\n";
614 globalOutputStream() << "Done prefs\n";
619 GlobalModuleServer_Shutdown();
624 if(ConfirmModified("Exit Radiant"))
633 GlobalUndoSystem().undo();
639 GlobalUndoSystem().redo();
643 void deleteSelection()
645 UndoableCommand undo("deleteSelected");
649 void Map_ExportSelected(TextOutputStream& ostream)
651 Map_ExportSelected(ostream, Map_getFormat(g_map));
654 void Map_ImportSelected(TextInputStream& istream)
656 Map_ImportSelected(istream, Map_getFormat(g_map));
659 void Selection_Copy()
661 clipboard_copy(Map_ExportSelected);
664 void Selection_Paste()
666 clipboard_paste(Map_ImportSelected);
671 if(GlobalSelectionSystem().Mode() == SelectionSystem::ePrimitive)
677 SelectedFaces_copyTexture();
683 if(GlobalSelectionSystem().Mode() == SelectionSystem::ePrimitive)
685 UndoableCommand undo("paste");
687 GlobalSelectionSystem().setSelectedAll(false);
692 SelectedFaces_pasteTexture();
698 CamWnd& camwnd = *g_pParentWnd->GetCamWnd();
699 GlobalSelectionSystem().setSelectedAll(false);
701 UndoableCommand undo("pasteToCamera");
705 // Work out the delta
708 Vector3 delta = vector3_subtracted(vector3_snapped(Camera_getOrigin(camwnd), GetGridSize()), mid);
711 GlobalSelectionSystem().translateSelected(delta);
715 void ColorScheme_Original()
717 TextureBrowser_setBackgroundColour(GlobalTextureBrowser(), Vector3(0.25f, 0.25f, 0.25f));
719 g_camwindow_globals.color_selbrushes3d = Vector3(1.0f, 0.0f, 0.0f);
720 g_camwindow_globals.color_cameraback = Vector3(0.25f, 0.25f, 0.25f);
721 CamWnd_Update(*g_pParentWnd->GetCamWnd());
723 g_xywindow_globals.color_gridback = Vector3(1.0f, 1.0f, 1.0f);
724 g_xywindow_globals.color_gridminor = Vector3(0.75f, 0.75f, 0.75f);
725 g_xywindow_globals.color_gridmajor = Vector3(0.5f, 0.5f, 0.5f);
726 g_xywindow_globals.color_gridminor_alt = Vector3(0.5f, 0.0f, 0.0f);
727 g_xywindow_globals.color_gridmajor_alt = Vector3(1.0f, 0.0f, 0.0f);
728 g_xywindow_globals.color_gridblock = Vector3(0.0f, 0.0f, 1.0f);
729 g_xywindow_globals.color_gridtext = Vector3(0.0f, 0.0f, 0.0f);
730 g_xywindow_globals.color_selbrushes = Vector3(1.0f, 0.0f, 0.0f);
731 g_xywindow_globals.color_clipper = Vector3(0.0f, 0.0f, 1.0f);
732 g_xywindow_globals.color_brushes = Vector3(0.0f, 0.0f, 0.0f);
733 SetWorldspawnColour(g_xywindow_globals.color_brushes);
734 g_xywindow_globals.color_viewname = Vector3(0.5f, 0.0f, 0.75f);
735 XY_UpdateAllWindows();
738 void ColorScheme_QER()
740 TextureBrowser_setBackgroundColour(GlobalTextureBrowser(), Vector3(0.25f, 0.25f, 0.25f));
742 g_camwindow_globals.color_cameraback = Vector3(0.25f, 0.25f, 0.25f);
743 g_camwindow_globals.color_selbrushes3d = Vector3(1.0f, 0.0f, 0.0f);
744 CamWnd_Update(*g_pParentWnd->GetCamWnd());
746 g_xywindow_globals.color_gridback = Vector3(1.0f, 1.0f, 1.0f);
747 g_xywindow_globals.color_gridminor = Vector3(1.0f, 1.0f, 1.0f);
748 g_xywindow_globals.color_gridmajor = Vector3(0.5f, 0.5f, 0.5f);
749 g_xywindow_globals.color_gridblock = Vector3(0.0f, 0.0f, 1.0f);
750 g_xywindow_globals.color_gridtext = Vector3(0.0f, 0.0f, 0.0f);
751 g_xywindow_globals.color_selbrushes = Vector3(1.0f, 0.0f, 0.0f);
752 g_xywindow_globals.color_clipper = Vector3(0.0f, 0.0f, 1.0f);
753 g_xywindow_globals.color_brushes = Vector3(0.0f, 0.0f, 0.0f);
754 SetWorldspawnColour(g_xywindow_globals.color_brushes);
755 g_xywindow_globals.color_viewname = Vector3(0.5f, 0.0f, 0.75f);
756 XY_UpdateAllWindows();
759 void ColorScheme_Black()
761 TextureBrowser_setBackgroundColour(GlobalTextureBrowser(), Vector3(0.25f, 0.25f, 0.25f));
763 g_camwindow_globals.color_cameraback = Vector3(0.25f, 0.25f, 0.25f);
764 g_camwindow_globals.color_selbrushes3d = Vector3(1.0f, 0.0f, 0.0f);
765 CamWnd_Update(*g_pParentWnd->GetCamWnd());
767 g_xywindow_globals.color_gridback = Vector3(0.0f, 0.0f, 0.0f);
768 g_xywindow_globals.color_gridminor = Vector3(0.2f, 0.2f, 0.2f);
769 g_xywindow_globals.color_gridmajor = Vector3(0.3f, 0.5f, 0.5f);
770 g_xywindow_globals.color_gridblock = Vector3(0.0f, 0.0f, 1.0f);
771 g_xywindow_globals.color_gridtext = Vector3(1.0f, 1.0f, 1.0f);
772 g_xywindow_globals.color_selbrushes = Vector3(1.0f, 0.0f, 0.0f);
773 g_xywindow_globals.color_clipper = Vector3(0.0f, 0.0f, 1.0f);
774 g_xywindow_globals.color_brushes = Vector3(1.0f, 1.0f, 1.0f);
775 SetWorldspawnColour(g_xywindow_globals.color_brushes);
776 g_xywindow_globals.color_viewname = Vector3(0.7f, 0.7f, 0.0f);
777 XY_UpdateAllWindows();
780 /* ydnar: to emulate maya/max/lightwave color schemes */
781 void ColorScheme_Ydnar()
783 TextureBrowser_setBackgroundColour(GlobalTextureBrowser(), Vector3(0.25f, 0.25f, 0.25f));
785 g_camwindow_globals.color_cameraback = Vector3(0.25f, 0.25f, 0.25f);
786 g_camwindow_globals.color_selbrushes3d = Vector3(1.0f, 0.0f, 0.0f);
787 CamWnd_Update(*g_pParentWnd->GetCamWnd());
789 g_xywindow_globals.color_gridback = Vector3(0.77f, 0.77f, 0.77f);
790 g_xywindow_globals.color_gridminor = Vector3(0.83f, 0.83f, 0.83f);
791 g_xywindow_globals.color_gridmajor = Vector3(0.89f, 0.89f, 0.89f);
792 g_xywindow_globals.color_gridblock = Vector3(1.0f, 1.0f, 1.0f);
793 g_xywindow_globals.color_gridtext = Vector3(0.0f, 0.0f, 0.0f);
794 g_xywindow_globals.color_selbrushes = Vector3(1.0f, 0.0f, 0.0f);
795 g_xywindow_globals.color_clipper = Vector3(0.0f, 0.0f, 1.0f);
796 g_xywindow_globals.color_brushes = Vector3(0.0f, 0.0f, 0.0f);
797 SetWorldspawnColour(g_xywindow_globals.color_brushes);
798 g_xywindow_globals.color_viewname = Vector3(0.5f, 0.0f, 0.75f);
799 XY_UpdateAllWindows();
802 typedef Callback1<Vector3&> GetColourCallback;
803 typedef Callback1<const Vector3&> SetColourCallback;
807 GetColourCallback m_get;
808 SetColourCallback m_set;
810 ChooseColour(const GetColourCallback& get, const SetColourCallback& set)
811 : m_get(get), m_set(set)
818 color_dialog(GTK_WIDGET(MainFrame_getWindow()), colour);
825 void Colour_get(const Vector3& colour, Vector3& other)
829 typedef ConstReferenceCaller1<Vector3, Vector3&, Colour_get> ColourGetCaller;
831 void Colour_set(Vector3& colour, const Vector3& other)
836 typedef ReferenceCaller1<Vector3, const Vector3&, Colour_set> ColourSetCaller;
838 void BrushColour_set(const Vector3& other)
840 g_xywindow_globals.color_brushes = other;
841 SetWorldspawnColour(g_xywindow_globals.color_brushes);
844 typedef FreeCaller1<const Vector3&, BrushColour_set> BrushColourSetCaller;
846 void ClipperColour_set(const Vector3& other)
848 g_xywindow_globals.color_clipper = other;
849 Brush_clipperColourChanged();
852 typedef FreeCaller1<const Vector3&, ClipperColour_set> ClipperColourSetCaller;
854 void TextureBrowserColour_get(Vector3& other)
856 other = TextureBrowser_getBackgroundColour(GlobalTextureBrowser());
858 typedef FreeCaller1<Vector3&, TextureBrowserColour_get> TextureBrowserColourGetCaller;
860 void TextureBrowserColour_set(const Vector3& other)
862 TextureBrowser_setBackgroundColour(GlobalTextureBrowser(), other);
864 typedef FreeCaller1<const Vector3&, TextureBrowserColour_set> TextureBrowserColourSetCaller;
870 ChooseColour m_textureback;
871 ChooseColour m_xyback;
872 ChooseColour m_gridmajor;
873 ChooseColour m_gridminor;
874 ChooseColour m_gridmajor_alt;
875 ChooseColour m_gridminor_alt;
876 ChooseColour m_gridtext;
877 ChooseColour m_gridblock;
878 ChooseColour m_cameraback;
879 ChooseColour m_brush;
880 ChooseColour m_selectedbrush;
881 ChooseColour m_selectedbrush3d;
882 ChooseColour m_clipper;
883 ChooseColour m_viewname;
886 m_textureback(TextureBrowserColourGetCaller(), TextureBrowserColourSetCaller()),
887 m_xyback(ColourGetCaller(g_xywindow_globals.color_gridback), ColourSetCaller(g_xywindow_globals.color_gridback)),
888 m_gridmajor(ColourGetCaller(g_xywindow_globals.color_gridmajor), ColourSetCaller(g_xywindow_globals.color_gridmajor)),
889 m_gridminor(ColourGetCaller(g_xywindow_globals.color_gridminor), ColourSetCaller(g_xywindow_globals.color_gridminor)),
890 m_gridmajor_alt(ColourGetCaller(g_xywindow_globals.color_gridmajor_alt), ColourSetCaller(g_xywindow_globals.color_gridmajor_alt)),
891 m_gridminor_alt(ColourGetCaller(g_xywindow_globals.color_gridminor_alt), ColourSetCaller(g_xywindow_globals.color_gridminor_alt)),
892 m_gridtext(ColourGetCaller(g_xywindow_globals.color_gridtext), ColourSetCaller(g_xywindow_globals.color_gridtext)),
893 m_gridblock(ColourGetCaller(g_xywindow_globals.color_gridblock), ColourSetCaller(g_xywindow_globals.color_gridblock)),
894 m_cameraback(ColourGetCaller(g_camwindow_globals.color_cameraback), ColourSetCaller(g_camwindow_globals.color_cameraback)),
895 m_brush(ColourGetCaller(g_xywindow_globals.color_brushes), BrushColourSetCaller()),
896 m_selectedbrush(ColourGetCaller(g_xywindow_globals.color_selbrushes), ColourSetCaller(g_xywindow_globals.color_selbrushes)),
897 m_selectedbrush3d(ColourGetCaller(g_camwindow_globals.color_selbrushes3d), ColourSetCaller(g_camwindow_globals.color_selbrushes3d)),
898 m_clipper(ColourGetCaller(g_xywindow_globals.color_clipper), ClipperColourSetCaller()),
899 m_viewname(ColourGetCaller(g_xywindow_globals.color_viewname), ColourSetCaller(g_xywindow_globals.color_viewname))
904 ColoursMenu g_ColoursMenu;
906 GtkMenuItem* create_colours_menu()
908 GtkMenuItem* colours_menu_item = new_sub_menu_item_with_mnemonic("Colors");
909 GtkMenu* menu_in_menu = GTK_MENU(gtk_menu_item_get_submenu(colours_menu_item));
911 GtkMenu* menu_3 = create_sub_menu_with_mnemonic(menu_in_menu, "Themes");
913 create_menu_item_with_mnemonic(menu_3, "QE4 Original", "ColorSchemeOriginal");
914 create_menu_item_with_mnemonic(menu_3, "Q3Radiant Original", "ColorSchemeQER");
915 create_menu_item_with_mnemonic(menu_3, "Black and Green", "ColorSchemeBlackAndGreen");
916 create_menu_item_with_mnemonic(menu_3, "Maya/Max/Lightwave Emulation", "ColorSchemeYdnar");
918 menu_separator(menu_in_menu);
920 create_menu_item_with_mnemonic(menu_in_menu, "_Texture Background...", "ChooseTextureBackgroundColor");
921 create_menu_item_with_mnemonic(menu_in_menu, "Grid Background...", "ChooseGridBackgroundColor");
922 create_menu_item_with_mnemonic(menu_in_menu, "Grid Major...", "ChooseGridMajorColor");
923 create_menu_item_with_mnemonic(menu_in_menu, "Grid Minor...", "ChooseGridMinorColor");
924 create_menu_item_with_mnemonic(menu_in_menu, "Grid Major Small...", "ChooseSmallGridMajorColor");
925 create_menu_item_with_mnemonic(menu_in_menu, "Grid Minor Small...", "ChooseSmallGridMinorColor");
926 create_menu_item_with_mnemonic(menu_in_menu, "Grid Text...", "ChooseGridTextColor");
927 create_menu_item_with_mnemonic(menu_in_menu, "Grid Block...", "ChooseGridBlockColor");
928 create_menu_item_with_mnemonic(menu_in_menu, "Default Brush...", "ChooseBrushColor");
929 create_menu_item_with_mnemonic(menu_in_menu, "Camera Background...", "ChooseCameraBackgroundColor");
930 create_menu_item_with_mnemonic(menu_in_menu, "Selected Brush...", "ChooseSelectedBrushColor");
931 create_menu_item_with_mnemonic(menu_in_menu, "Selected Brush (Camera)...", "ChooseCameraSelectedBrushColor");
932 create_menu_item_with_mnemonic(menu_in_menu, "Clipper...", "ChooseClipperColor");
933 create_menu_item_with_mnemonic(menu_in_menu, "Active View name...", "ChooseOrthoViewNameColor");
935 return colours_menu_item;
942 PluginToolbar_clear();
945 Radiant_Initialise();
947 PluginsMenu_populate();
949 PluginToolbar_populate();
955 g_pParentWnd->OnSleep();
961 StringOutputStream URL(256);
962 URL << "http://www.qeradiant.com/index.php?data=dlupdate&query_dlup=1";
968 URL << "&Version_dlup=" RADIANT_VERSION;
969 g_GamesDialog.AddPacksURL(URL);
970 OpenURL(URL.c_str());
973 // open the Q3Rad manual
976 // at least on win32, AppPath + "Q3Rad_Manual/index.htm"
977 StringOutputStream help(256);
978 help << AppPath_get() << "Q3Rad_Manual/index.htm";
979 OpenURL(help.c_str());
982 void OpenBugReportURL()
984 OpenURL("http://www.qeradiant.com/?data=bugreport");
988 GtkWidget* g_page_console;
990 void Console_ToggleShow()
992 GroupDialog_showPage(g_page_console);
995 GtkWidget* g_page_entity;
997 void EntityInspector_ToggleShow()
999 GroupDialog_showPage(g_page_entity);
1004 void SetClipMode(bool enable);
1005 void ModeChangeNotify();
1007 typedef void(*ToolMode)();
1008 ToolMode g_currentToolMode = 0;
1009 bool g_currentToolModeSupportsComponentEditing = false;
1010 ToolMode g_defaultToolMode = 0;
1014 void SelectionSystem_DefaultMode()
1016 GlobalSelectionSystem().SetMode(SelectionSystem::ePrimitive);
1017 GlobalSelectionSystem().SetComponentMode(SelectionSystem::eDefault);
1024 return GlobalSelectionSystem().Mode() == SelectionSystem::eComponent
1025 && GlobalSelectionSystem().ComponentMode() == SelectionSystem::eEdge;
1030 return GlobalSelectionSystem().Mode() == SelectionSystem::eComponent
1031 && GlobalSelectionSystem().ComponentMode() == SelectionSystem::eVertex;
1036 return GlobalSelectionSystem().Mode() == SelectionSystem::eComponent
1037 && GlobalSelectionSystem().ComponentMode() == SelectionSystem::eFace;
1040 template<bool (*BoolFunction)()>
1041 class BoolFunctionExport
1044 static void apply(const BoolImportCallback& importCallback)
1046 importCallback(BoolFunction());
1050 FreeCaller1<const BoolImportCallback&, BoolFunctionExport<EdgeMode>::apply> g_edgeMode_button_caller;
1051 BoolExportCallback g_edgeMode_button_callback(g_edgeMode_button_caller);
1052 ToggleItem g_edgeMode_button(g_edgeMode_button_callback);
1054 FreeCaller1<const BoolImportCallback&, BoolFunctionExport<VertexMode>::apply> g_vertexMode_button_caller;
1055 BoolExportCallback g_vertexMode_button_callback(g_vertexMode_button_caller);
1056 ToggleItem g_vertexMode_button(g_vertexMode_button_callback);
1058 FreeCaller1<const BoolImportCallback&, BoolFunctionExport<FaceMode>::apply> g_faceMode_button_caller;
1059 BoolExportCallback g_faceMode_button_callback(g_faceMode_button_caller);
1060 ToggleItem g_faceMode_button(g_faceMode_button_callback);
1062 void ComponentModeChanged()
1064 g_edgeMode_button.update();
1065 g_vertexMode_button.update();
1066 g_faceMode_button.update();
1069 void ComponentMode_SelectionChanged(const Selectable& selectable)
1071 if(GlobalSelectionSystem().Mode() == SelectionSystem::eComponent
1072 && GlobalSelectionSystem().countSelected() == 0)
1074 SelectionSystem_DefaultMode();
1075 ComponentModeChanged();
1079 void SelectEdgeMode()
1082 if(GlobalSelectionSystem().Mode() == SelectionSystem::eComponent)
1084 GlobalSelectionSystem().Select(false);
1090 SelectionSystem_DefaultMode();
1092 else if(GlobalSelectionSystem().countSelected() != 0)
1094 if(!g_currentToolModeSupportsComponentEditing)
1096 g_defaultToolMode();
1099 GlobalSelectionSystem().SetMode(SelectionSystem::eComponent);
1100 GlobalSelectionSystem().SetComponentMode(SelectionSystem::eEdge);
1103 ComponentModeChanged();
1108 void SelectVertexMode()
1111 if(GlobalSelectionSystem().Mode() == SelectionSystem::eComponent)
1113 GlobalSelectionSystem().Select(false);
1119 SelectionSystem_DefaultMode();
1121 else if(GlobalSelectionSystem().countSelected() != 0)
1123 if(!g_currentToolModeSupportsComponentEditing)
1125 g_defaultToolMode();
1128 GlobalSelectionSystem().SetMode(SelectionSystem::eComponent);
1129 GlobalSelectionSystem().SetComponentMode(SelectionSystem::eVertex);
1132 ComponentModeChanged();
1137 void SelectFaceMode()
1140 if(GlobalSelectionSystem().Mode() == SelectionSystem::eComponent)
1142 GlobalSelectionSystem().Select(false);
1148 SelectionSystem_DefaultMode();
1150 else if(GlobalSelectionSystem().countSelected() != 0)
1152 if(!g_currentToolModeSupportsComponentEditing)
1154 g_defaultToolMode();
1157 GlobalSelectionSystem().SetMode(SelectionSystem::eComponent);
1158 GlobalSelectionSystem().SetComponentMode(SelectionSystem::eFace);
1161 ComponentModeChanged();
1167 class CloneSelected : public scene::Graph::Walker
1170 bool pre(const scene::Path& path, scene::Instance& instance) const
1172 if(path.size() == 1)
1175 if(!path.top().get().isRoot())
1177 Selectable* selectable = Instance_getSelectable(instance);
1179 && selectable->isSelected())
1187 void post(const scene::Path& path, scene::Instance& instance) const
1189 if(path.size() == 1)
1192 if(!path.top().get().isRoot())
1194 Selectable* selectable = Instance_getSelectable(instance);
1196 && selectable->isSelected())
1198 NodeSmartReference clone(Node_Clone(path.top()));
1199 Map_gatherNamespaced(clone);
1200 Node_getTraversable(path.parent().get())->insert(clone);
1206 void Scene_Clone_Selected(scene::Graph& graph)
1208 graph.traverse(CloneSelected());
1210 Map_mergeClonedNames();
1213 enum ENudgeDirection
1226 AxisBase(const Vector3& x_, const Vector3& y_, const Vector3& z_)
1227 : x(x_), y(y_), z(z_)
1232 AxisBase AxisBase_forViewType(VIEWTYPE viewtype)
1237 return AxisBase(g_vector3_axis_x, g_vector3_axis_y, g_vector3_axis_z);
1239 return AxisBase(g_vector3_axis_x, g_vector3_axis_z, g_vector3_axis_y);
1241 return AxisBase(g_vector3_axis_y, g_vector3_axis_z, g_vector3_axis_x);
1244 ERROR_MESSAGE("invalid viewtype");
1245 return AxisBase(Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(0, 0, 0));
1248 Vector3 AxisBase_axisForDirection(const AxisBase& axes, ENudgeDirection direction)
1253 return vector3_negated(axes.x);
1259 return vector3_negated(axes.y);
1262 ERROR_MESSAGE("invalid direction");
1263 return Vector3(0, 0, 0);
1266 void NudgeSelection(ENudgeDirection direction, float fAmount, VIEWTYPE viewtype)
1268 AxisBase axes(AxisBase_forViewType(viewtype));
1269 Vector3 view_direction(vector3_negated(axes.z));
1270 Vector3 nudge(vector3_scaled(AxisBase_axisForDirection(axes, direction), fAmount));
1271 GlobalSelectionSystem().NudgeManipulator(nudge, view_direction);
1274 void Selection_Clone()
1276 if(GlobalSelectionSystem().Mode() == SelectionSystem::ePrimitive)
1278 UndoableCommand undo("cloneSelected");
1280 Scene_Clone_Selected(GlobalSceneGraph());
1282 //NudgeSelection(eNudgeRight, GetGridSize(), GlobalXYWnd_getCurrentViewType());
1283 //NudgeSelection(eNudgeDown, GetGridSize(), GlobalXYWnd_getCurrentViewType());
1287 // called when the escape key is used (either on the main window or on an inspector)
1288 void Selection_Deselect()
1290 if(GlobalSelectionSystem().Mode() == SelectionSystem::eComponent)
1292 if(GlobalSelectionSystem().countSelectedComponents() != 0)
1294 GlobalSelectionSystem().setSelectedAllComponents(false);
1298 SelectionSystem_DefaultMode();
1299 ComponentModeChanged();
1304 if(GlobalSelectionSystem().countSelectedComponents() != 0)
1306 GlobalSelectionSystem().setSelectedAllComponents(false);
1310 GlobalSelectionSystem().setSelectedAll(false);
1316 void Selection_NudgeUp()
1318 UndoableCommand undo("nudgeSelectedUp");
1319 NudgeSelection(eNudgeUp, GetGridSize(), GlobalXYWnd_getCurrentViewType());
1322 void Selection_NudgeDown()
1324 UndoableCommand undo("nudgeSelectedDown");
1325 NudgeSelection(eNudgeDown, GetGridSize(), GlobalXYWnd_getCurrentViewType());
1328 void Selection_NudgeLeft()
1330 UndoableCommand undo("nudgeSelectedLeft");
1331 NudgeSelection(eNudgeLeft, GetGridSize(), GlobalXYWnd_getCurrentViewType());
1334 void Selection_NudgeRight()
1336 UndoableCommand undo("nudgeSelectedRight");
1337 NudgeSelection(eNudgeRight, GetGridSize(), GlobalXYWnd_getCurrentViewType());
1341 void TranslateToolExport(const BoolImportCallback& importCallback)
1343 importCallback(GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eTranslate);
1346 void RotateToolExport(const BoolImportCallback& importCallback)
1348 importCallback(GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eRotate);
1351 void ScaleToolExport(const BoolImportCallback& importCallback)
1353 importCallback(GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eScale);
1356 void DragToolExport(const BoolImportCallback& importCallback)
1358 importCallback(GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eDrag);
1361 void ClipperToolExport(const BoolImportCallback& importCallback)
1363 importCallback(GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eClip);
1366 FreeCaller1<const BoolImportCallback&, TranslateToolExport> g_translatemode_button_caller;
1367 BoolExportCallback g_translatemode_button_callback(g_translatemode_button_caller);
1368 ToggleItem g_translatemode_button(g_translatemode_button_callback);
1370 FreeCaller1<const BoolImportCallback&, RotateToolExport> g_rotatemode_button_caller;
1371 BoolExportCallback g_rotatemode_button_callback(g_rotatemode_button_caller);
1372 ToggleItem g_rotatemode_button(g_rotatemode_button_callback);
1374 FreeCaller1<const BoolImportCallback&, ScaleToolExport> g_scalemode_button_caller;
1375 BoolExportCallback g_scalemode_button_callback(g_scalemode_button_caller);
1376 ToggleItem g_scalemode_button(g_scalemode_button_callback);
1378 FreeCaller1<const BoolImportCallback&, DragToolExport> g_dragmode_button_caller;
1379 BoolExportCallback g_dragmode_button_callback(g_dragmode_button_caller);
1380 ToggleItem g_dragmode_button(g_dragmode_button_callback);
1382 FreeCaller1<const BoolImportCallback&, ClipperToolExport> g_clipper_button_caller;
1383 BoolExportCallback g_clipper_button_callback(g_clipper_button_caller);
1384 ToggleItem g_clipper_button(g_clipper_button_callback);
1388 g_translatemode_button.update();
1389 g_rotatemode_button.update();
1390 g_scalemode_button.update();
1391 g_dragmode_button.update();
1392 g_clipper_button.update();
1395 const char* const c_ResizeMode_status = "QE4 Drag Tool: move and resize objects";
1399 if(g_currentToolMode == DragMode && g_defaultToolMode != DragMode)
1401 g_defaultToolMode();
1405 g_currentToolMode = DragMode;
1406 g_currentToolModeSupportsComponentEditing = true;
1410 Sys_Status(c_ResizeMode_status);
1411 GlobalSelectionSystem().SetManipulatorMode(SelectionSystem::eDrag);
1418 const char* const c_TranslateMode_status = "Translate Tool: translate objects and components";
1420 void TranslateMode()
1422 if(g_currentToolMode == TranslateMode && g_defaultToolMode != TranslateMode)
1424 g_defaultToolMode();
1428 g_currentToolMode = TranslateMode;
1429 g_currentToolModeSupportsComponentEditing = true;
1433 Sys_Status(c_TranslateMode_status);
1434 GlobalSelectionSystem().SetManipulatorMode(SelectionSystem::eTranslate);
1440 const char* const c_RotateMode_status = "Rotate Tool: rotate objects and components";
1444 if(g_currentToolMode == RotateMode && g_defaultToolMode != RotateMode)
1446 g_defaultToolMode();
1450 g_currentToolMode = RotateMode;
1451 g_currentToolModeSupportsComponentEditing = true;
1455 Sys_Status(c_RotateMode_status);
1456 GlobalSelectionSystem().SetManipulatorMode(SelectionSystem::eRotate);
1462 const char* const c_ScaleMode_status = "Scale Tool: scale objects and components";
1466 if(g_currentToolMode == ScaleMode && g_defaultToolMode != ScaleMode)
1468 g_defaultToolMode();
1472 g_currentToolMode = ScaleMode;
1473 g_currentToolModeSupportsComponentEditing = true;
1477 Sys_Status(c_ScaleMode_status);
1478 GlobalSelectionSystem().SetManipulatorMode(SelectionSystem::eScale);
1485 const char* const c_ClipperMode_status = "Clipper Tool: apply clip planes to objects";
1490 if(g_currentToolMode == ClipperMode && g_defaultToolMode != ClipperMode)
1492 g_defaultToolMode();
1496 g_currentToolMode = ClipperMode;
1497 g_currentToolModeSupportsComponentEditing = false;
1499 SelectionSystem_DefaultMode();
1503 Sys_Status(c_ClipperMode_status);
1504 GlobalSelectionSystem().SetManipulatorMode(SelectionSystem::eClip);
1511 void Texdef_Rotate(float angle)
1513 StringOutputStream command;
1514 command << "brushRotateTexture -angle " << angle;
1515 UndoableCommand undo(command.c_str());
1516 Select_RotateTexture(angle);
1519 void Texdef_RotateClockwise()
1521 Texdef_Rotate(static_cast<float>(fabs(g_si_globals.rotate)));
1524 void Texdef_RotateAntiClockwise()
1526 Texdef_Rotate(static_cast<float>(-fabs(g_si_globals.rotate)));
1529 void Texdef_Scale(float x, float y)
1531 StringOutputStream command;
1532 command << "brushScaleTexture -x " << x << " -y " << y;
1533 UndoableCommand undo(command.c_str());
1534 Select_ScaleTexture(x, y);
1537 void Texdef_ScaleUp()
1539 Texdef_Scale(0, g_si_globals.scale[1]);
1542 void Texdef_ScaleDown()
1544 Texdef_Scale(0, -g_si_globals.scale[1]);
1547 void Texdef_ScaleLeft()
1549 Texdef_Scale(-g_si_globals.scale[0],0);
1552 void Texdef_ScaleRight()
1554 Texdef_Scale(g_si_globals.scale[0],0);
1557 void Texdef_Shift(float x, float y)
1559 StringOutputStream command;
1560 command << "brushShiftTexture -x " << x << " -y " << y;
1561 UndoableCommand undo(command.c_str());
1562 Select_ShiftTexture(x, y);
1565 void Texdef_ShiftLeft()
1567 Texdef_Shift(-g_si_globals.shift[0], 0);
1570 void Texdef_ShiftRight()
1572 Texdef_Shift(g_si_globals.shift[0], 0);
1575 void Texdef_ShiftUp()
1577 Texdef_Shift(0, g_si_globals.shift[1]);
1580 void Texdef_ShiftDown()
1582 Texdef_Shift(0, -g_si_globals.shift[1]);
1587 class SnappableSnapToGridSelected : public scene::Graph::Walker
1591 SnappableSnapToGridSelected(float snap)
1595 bool pre(const scene::Path& path, scene::Instance& instance) const
1597 if(path.top().get().visible())
1599 Snappable* snappable = Node_getSnappable(path.top());
1601 && Instance_getSelectable(instance)->isSelected())
1603 snappable->snapto(m_snap);
1610 void Scene_SnapToGrid_Selected(scene::Graph& graph, float snap)
1612 graph.traverse(SnappableSnapToGridSelected(snap));
1615 class ComponentSnappableSnapToGridSelected : public scene::Graph::Walker
1619 ComponentSnappableSnapToGridSelected(float snap)
1623 bool pre(const scene::Path& path, scene::Instance& instance) const
1625 if(path.top().get().visible())
1627 ComponentSnappable* componentSnappable = Instance_getComponentSnappable(instance);
1628 if(componentSnappable != 0
1629 && Instance_getSelectable(instance)->isSelected())
1631 componentSnappable->snapComponents(m_snap);
1638 void Scene_SnapToGrid_Component_Selected(scene::Graph& graph, float snap)
1640 graph.traverse(ComponentSnappableSnapToGridSelected(snap));
1643 void Selection_SnapToGrid()
1645 StringOutputStream command;
1646 command << "snapSelected -grid " << GetGridSize();
1647 UndoableCommand undo(command.c_str());
1649 if(GlobalSelectionSystem().Mode() == SelectionSystem::eComponent)
1651 Scene_SnapToGrid_Component_Selected(GlobalSceneGraph(), GetGridSize());
1655 Scene_SnapToGrid_Selected(GlobalSceneGraph(), GetGridSize());
1660 static gint qe_every_second(gpointer data)
1662 GdkModifierType mask;
1664 gdk_window_get_pointer (0, 0, 0, &mask);
1666 if ((mask & (GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK)) == 0)
1674 guint s_qe_every_second_id = 0;
1676 void EverySecondTimer_enable()
1678 if(s_qe_every_second_id == 0)
1680 s_qe_every_second_id = gtk_timeout_add(1000, qe_every_second, 0);
1684 void EverySecondTimer_disable()
1686 if(s_qe_every_second_id != 0)
1688 gtk_timeout_remove(s_qe_every_second_id);
1689 s_qe_every_second_id = 0;
1693 gint window_realize_remove_decoration(GtkWidget* widget, gpointer data)
1695 gdk_window_set_decorations(widget->window, (GdkWMDecoration)(GDK_DECOR_ALL|GDK_DECOR_MENU|GDK_DECOR_MINIMIZE|GDK_DECOR_MAXIMIZE));
1702 GtkWindow* m_window;
1706 WaitDialog create_wait_dialog(const char* title, const char* text)
1710 dialog.m_window = create_floating_window(title, MainFrame_getWindow());
1711 gtk_window_set_resizable(dialog.m_window, FALSE);
1712 gtk_container_set_border_width(GTK_CONTAINER(dialog.m_window), 0);
1713 gtk_window_set_position(dialog.m_window, GTK_WIN_POS_CENTER_ON_PARENT);
1715 g_signal_connect(G_OBJECT(dialog.m_window), "realize", G_CALLBACK(window_realize_remove_decoration), 0);
1718 dialog.m_label = GTK_LABEL(gtk_label_new(text));
1719 gtk_misc_set_alignment(GTK_MISC(dialog.m_label), 0.0, 0.5);
1720 gtk_label_set_justify(dialog.m_label, GTK_JUSTIFY_LEFT);
1721 gtk_widget_show(GTK_WIDGET(dialog.m_label));
1722 gtk_widget_set_size_request(GTK_WIDGET(dialog.m_label), 200, -1);
1724 gtk_container_add(GTK_CONTAINER(dialog.m_window), GTK_WIDGET(dialog.m_label));
1731 clock_t g_lastRedrawTime = 0;
1732 const clock_t c_redrawInterval = clock_t(CLOCKS_PER_SEC / 10);
1734 bool redrawRequired()
1736 clock_t currentTime = std::clock();
1737 if(currentTime - g_lastRedrawTime >= c_redrawInterval)
1739 g_lastRedrawTime = currentTime;
1746 bool MainFrame_isActiveApp()
1748 //globalOutputStream() << "listing\n";
1749 GList* list = gtk_window_list_toplevels();
1750 for(GList* i = list; i != 0; i = g_list_next(i))
1752 //globalOutputStream() << "toplevel.. ";
1753 if(gtk_window_is_active(GTK_WINDOW(i->data)))
1755 //globalOutputStream() << "is active\n";
1758 //globalOutputStream() << "not active\n";
1763 typedef std::list<CopiedString> StringStack;
1764 StringStack g_wait_stack;
1767 bool ScreenUpdates_Enabled()
1769 return g_wait_stack.empty();
1772 void ScreenUpdates_process()
1774 if(redrawRequired() && GTK_WIDGET_VISIBLE(g_wait.m_window))
1781 void ScreenUpdates_Disable(const char* message, const char* title)
1783 if(g_wait_stack.empty())
1785 EverySecondTimer_disable();
1789 bool isActiveApp = MainFrame_isActiveApp();
1791 g_wait = create_wait_dialog(title, message);
1792 gtk_grab_add(GTK_WIDGET(g_wait.m_window));
1796 gtk_widget_show(GTK_WIDGET(g_wait.m_window));
1797 ScreenUpdates_process();
1800 else if(GTK_WIDGET_VISIBLE(g_wait.m_window))
1802 gtk_label_set_text(g_wait.m_label, message);
1803 ScreenUpdates_process();
1805 g_wait_stack.push_back(message);
1808 void ScreenUpdates_Enable()
1810 ASSERT_MESSAGE(!ScreenUpdates_Enabled(), "screen updates already enabled");
1811 g_wait_stack.pop_back();
1812 if(g_wait_stack.empty())
1814 EverySecondTimer_enable();
1815 //gtk_widget_set_sensitive(GTK_WIDGET(MainFrame_getWindow()), TRUE);
1817 gtk_grab_remove(GTK_WIDGET(g_wait.m_window));
1818 destroy_floating_window(g_wait.m_window);
1819 g_wait.m_window = 0;
1821 //gtk_window_present(MainFrame_getWindow());
1823 else if(GTK_WIDGET_VISIBLE(g_wait.m_window))
1825 gtk_label_set_text(g_wait.m_label, g_wait_stack.back().c_str());
1826 ScreenUpdates_process();
1832 void GlobalCamera_UpdateWindow()
1834 if(g_pParentWnd != 0)
1836 CamWnd_Update(*g_pParentWnd->GetCamWnd());
1840 void XY_UpdateWindow(MainFrame& mainframe)
1842 if(mainframe.GetXYWnd() != 0)
1844 XYWnd_Update(*mainframe.GetXYWnd());
1848 void XZ_UpdateWindow(MainFrame& mainframe)
1850 if(mainframe.GetXZWnd() != 0)
1852 XYWnd_Update(*mainframe.GetXZWnd());
1856 void YZ_UpdateWindow(MainFrame& mainframe)
1858 if(mainframe.GetYZWnd() != 0)
1860 XYWnd_Update(*mainframe.GetYZWnd());
1864 void XY_UpdateAllWindows(MainFrame& mainframe)
1866 XY_UpdateWindow(mainframe);
1867 XZ_UpdateWindow(mainframe);
1868 YZ_UpdateWindow(mainframe);
1871 void XY_UpdateAllWindows()
1873 if(g_pParentWnd != 0)
1875 XY_UpdateAllWindows(*g_pParentWnd);
1879 void UpdateAllWindows()
1881 GlobalCamera_UpdateWindow();
1882 XY_UpdateAllWindows();
1886 void ModeChangeNotify()
1888 SceneChangeNotify();
1891 void ClipperChangeNotify()
1893 GlobalCamera_UpdateWindow();
1894 XY_UpdateAllWindows();
1898 LatchedInt g_Layout_viewStyle(0, "Window Layout");
1899 LatchedBool g_Layout_enableDetachableMenus(true, "Detachable Menus");
1900 LatchedBool g_Layout_enablePatchToolbar(true, "Patch Toolbar");
1901 LatchedBool g_Layout_enablePluginToolbar(true, "Plugin Toolbar");
1905 GtkMenuItem* create_file_menu()
1908 GtkMenuItem* file_menu_item = new_sub_menu_item_with_mnemonic("_File");
1909 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(file_menu_item));
1910 if (g_Layout_enableDetachableMenus.m_value)
1911 menu_tearoff (menu);
1913 create_menu_item_with_mnemonic(menu, "_New Map", "NewMap");
1914 menu_separator(menu);
1917 //++timo temporary experimental stuff for sleep mode..
1918 create_menu_item_with_mnemonic(menu, "_Sleep", "Sleep");
1919 menu_separator(menu);
1923 create_menu_item_with_mnemonic(menu, "_Open...", "OpenMap");
1925 create_menu_item_with_mnemonic(menu, "_Import...", "ImportMap");
1926 create_menu_item_with_mnemonic(menu, "_Save", "SaveMap");
1927 create_menu_item_with_mnemonic(menu, "Save _as...", "SaveMapAs");
1928 create_menu_item_with_mnemonic(menu, "Save s_elected...", "SaveSelected");
1929 menu_separator(menu);
1930 create_menu_item_with_mnemonic(menu, "Save re_gion...", "SaveRegion");
1931 menu_separator(menu);
1932 create_menu_item_with_mnemonic(menu, "_Refresh models", "RefreshReferences");
1933 menu_separator(menu);
1934 create_menu_item_with_mnemonic(menu, "Pro_ject settings...", "ProjectSettings");
1935 menu_separator(menu);
1936 create_menu_item_with_mnemonic(menu, "_Pointfile...", "TogglePointfile");
1937 menu_separator(menu);
1938 MRU_constructMenu(menu);
1939 menu_separator(menu);
1940 create_menu_item_with_mnemonic(menu, "Check for GtkRadiant update (web)", "CheckForUpdate");
1941 create_menu_item_with_mnemonic(menu, "E_xit", "Exit");
1943 return file_menu_item;
1946 GtkMenuItem* create_edit_menu()
1949 GtkMenuItem* edit_menu_item = new_sub_menu_item_with_mnemonic("_Edit");
1950 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(edit_menu_item));
1951 if (g_Layout_enableDetachableMenus.m_value)
1952 menu_tearoff (menu);
1953 create_menu_item_with_mnemonic(menu, "_Undo", "Undo");
1954 create_menu_item_with_mnemonic(menu, "_Redo", "Redo");
1955 menu_separator(menu);
1956 create_menu_item_with_mnemonic(menu, "_Copy", "Copy");
1957 create_menu_item_with_mnemonic(menu, "_Paste", "Paste");
1958 create_menu_item_with_mnemonic(menu, "P_aste To Camera", "PasteToCamera");
1959 menu_separator(menu);
1960 create_menu_item_with_mnemonic(menu, "_Duplicate", "CloneSelection");
1961 create_menu_item_with_mnemonic(menu, "D_elete", "DeleteSelection");
1962 menu_separator(menu);
1963 create_menu_item_with_mnemonic(menu, "Pa_rent", "ParentSelection");
1964 menu_separator(menu);
1965 create_menu_item_with_mnemonic(menu, "C_lear Selection", "UnSelectSelection");
1966 create_menu_item_with_mnemonic(menu, "_Invert Selection", "InvertSelection");
1968 GtkMenu* convert_menu = create_sub_menu_with_mnemonic(menu, "E_xpand Selection");
1969 create_menu_item_with_mnemonic(convert_menu, "To Whole _Entities", "ExpandSelectionToEntities");
1971 menu_separator(menu);
1972 create_menu_item_with_mnemonic(menu, "Pre_ferences...", "Preferences");
1974 return edit_menu_item;
1977 void fill_view_xy_top_menu(GtkMenu* menu)
1979 create_check_menu_item_with_mnemonic(menu, "XY (Top) View", "ToggleView");
1983 void fill_view_yz_side_menu(GtkMenu* menu)
1985 create_check_menu_item_with_mnemonic(menu, "YZ (Side) View", "ToggleSideView");
1989 void fill_view_xz_front_menu(GtkMenu* menu)
1991 create_check_menu_item_with_mnemonic(menu, "XZ (Front) View", "ToggleFrontView");
1995 GtkWidget* g_toggle_z_item = 0;
1996 GtkWidget* g_toggle_console_item = 0;
1997 GtkWidget* g_toggle_entity_item = 0;
1998 GtkWidget* g_toggle_entitylist_item = 0;
2000 GtkMenuItem* create_view_menu(MainFrame::EViewStyle style)
2003 GtkMenuItem* view_menu_item = new_sub_menu_item_with_mnemonic("_View");
2004 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(view_menu_item));
2005 if (g_Layout_enableDetachableMenus.m_value)
2006 menu_tearoff (menu);
2008 if(style == MainFrame::eFloating)
2010 fill_view_camera_menu(menu);
2011 fill_view_xy_top_menu(menu);
2012 fill_view_yz_side_menu(menu);
2013 fill_view_xz_front_menu(menu);
2015 if(style == MainFrame::eFloating || style == MainFrame::eSplit)
2017 create_menu_item_with_mnemonic(menu, "Console View", "ToggleConsole");
2018 create_menu_item_with_mnemonic(menu, "Texture Browser", "ViewTextures");
2019 create_menu_item_with_mnemonic(menu, "Entity Inspector", "ToggleEntityInspector");
2023 create_menu_item_with_mnemonic(menu, "Entity Inspector", "ViewEntityInfo");
2025 create_menu_item_with_mnemonic(menu, "_Surface Inspector", "SurfaceInspector");
2026 create_menu_item_with_mnemonic(menu, "Entity List", "EntityList");
2028 menu_separator(menu);
2030 GtkMenu* camera_menu = create_sub_menu_with_mnemonic (menu, "Camera");
2031 create_menu_item_with_mnemonic(camera_menu, "_Center", "CenterView");
2032 create_menu_item_with_mnemonic(camera_menu, "_Up Floor", "UpFloor");
2033 create_menu_item_with_mnemonic(camera_menu, "_Down Floor", "DownFloor");
2034 menu_separator(camera_menu);
2035 create_menu_item_with_mnemonic(camera_menu, "Far Clip Plane In", "CubicClipZoomIn");
2036 create_menu_item_with_mnemonic(camera_menu, "Far Clip Plane Out", "CubicClipZoomOut");
2037 menu_separator(camera_menu);
2038 create_menu_item_with_mnemonic(camera_menu, "Next leak spot", "NextLeakSpot");
2039 create_menu_item_with_mnemonic(camera_menu, "Previous leak spot", "PrevLeakSpot");
2040 menu_separator(camera_menu);
2041 create_menu_item_with_mnemonic(camera_menu, "Look Through Selected", "LookThroughSelected");
2042 create_menu_item_with_mnemonic(camera_menu, "Look Through Camera", "LookThroughCamera");
2044 menu_separator(menu);
2046 GtkMenu* orthographic_menu = create_sub_menu_with_mnemonic(menu, "Orthographic");
2047 if(style == MainFrame::eRegular || style == MainFrame::eRegularLeft || style == MainFrame::eFloating)
2049 create_menu_item_with_mnemonic(orthographic_menu, "_Next (XY, YZ, XY)", "NextView");
2050 create_menu_item_with_mnemonic(orthographic_menu, "XY (Top)", "ViewTop");
2051 create_menu_item_with_mnemonic(orthographic_menu, "YZ", "ViewSide");
2052 create_menu_item_with_mnemonic(orthographic_menu, "XZ", "ViewFront");
2053 menu_separator(orthographic_menu);
2056 create_menu_item_with_mnemonic(orthographic_menu, "_XY 100%", "Zoom100");
2057 create_menu_item_with_mnemonic(orthographic_menu, "XY Zoom _In", "ZoomIn");
2058 create_menu_item_with_mnemonic(orthographic_menu, "XY Zoom _Out", "ZoomOut");
2061 menu_separator(menu);
2064 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Show");
2065 create_check_menu_item_with_mnemonic(menu_in_menu, "Show _Angles", "ShowAngles");
2066 create_check_menu_item_with_mnemonic(menu_in_menu, "Show _Names", "ShowNames");
2067 create_check_menu_item_with_mnemonic(menu_in_menu, "Show Blocks", "ShowBlocks");
2068 create_check_menu_item_with_mnemonic(menu_in_menu, "Show C_oordinates", "ShowCoordinates");
2069 create_check_menu_item_with_mnemonic(menu_in_menu, "Show Window Outline", "ShowWindowOutline");
2070 create_check_menu_item_with_mnemonic(menu_in_menu, "Show Axes", "ShowAxes");
2071 create_check_menu_item_with_mnemonic(menu_in_menu, "Show Workzone", "ShowWorkzone");
2075 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Filter");
2076 Filters_constructMenu(menu_in_menu);
2078 menu_separator(menu);
2080 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Hide/Show");
2081 create_menu_item_with_mnemonic(menu_in_menu, "Hide Selected", "HideSelected");
2082 create_menu_item_with_mnemonic(menu_in_menu, "Show Hidden", "ShowHidden");
2084 menu_separator(menu);
2086 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Region");
2087 create_menu_item_with_mnemonic(menu_in_menu, "_Off", "RegionOff");
2088 create_menu_item_with_mnemonic(menu_in_menu, "_Set XY", "RegionSetXY");
2089 create_menu_item_with_mnemonic(menu_in_menu, "Set _Brush", "RegionSetBrush");
2090 create_menu_item_with_mnemonic(menu_in_menu, "Set Se_lected Brushes", "RegionSetSelection");
2093 if(style == MainFrame::eSplit || style == MainFrame::eFloating)
2095 command_connect_accelerator("CenterXYViews");
2099 command_connect_accelerator("CenterXYView");
2102 return view_menu_item;
2105 GtkMenuItem* create_selection_menu()
2108 GtkMenuItem* selection_menu_item = new_sub_menu_item_with_mnemonic("_Modify");
2109 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(selection_menu_item));
2110 if (g_Layout_enableDetachableMenus.m_value)
2111 menu_tearoff (menu);
2114 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Components");
2115 create_check_menu_item_with_mnemonic(menu_in_menu, "_Edges", "DragEdges");
2116 create_check_menu_item_with_mnemonic(menu_in_menu, "_Vertices", "DragVertices");
2117 create_check_menu_item_with_mnemonic(menu_in_menu, "_Faces", "DragFaces");
2120 menu_separator(menu);
2123 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic(menu, "Nudge");
2124 create_menu_item_with_mnemonic(menu_in_menu, "Nudge Left", "SelectNudgeLeft");
2125 create_menu_item_with_mnemonic(menu_in_menu, "Nudge Right", "SelectNudgeRight");
2126 create_menu_item_with_mnemonic(menu_in_menu, "Nudge Up", "SelectNudgeUp");
2127 create_menu_item_with_mnemonic(menu_in_menu, "Nudge Down", "SelectNudgeDown");
2130 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Rotate");
2131 create_menu_item_with_mnemonic(menu_in_menu, "Rotate X", "RotateSelectionX");
2132 create_menu_item_with_mnemonic(menu_in_menu, "Rotate Y", "RotateSelectionY");
2133 create_menu_item_with_mnemonic(menu_in_menu, "Rotate Z", "RotateSelectionZ");
2136 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Flip");
2137 create_menu_item_with_mnemonic(menu_in_menu, "Flip _X", "MirrorSelectionX");
2138 create_menu_item_with_mnemonic(menu_in_menu, "Flip _Y", "MirrorSelectionY");
2139 create_menu_item_with_mnemonic(menu_in_menu, "Flip _Z", "MirrorSelectionZ");
2141 menu_separator(menu);
2142 create_menu_item_with_mnemonic(menu, "Arbitrary rotation...", "ArbitraryRotation");
2143 create_menu_item_with_mnemonic(menu, "Arbitrary scale...", "ArbitraryScale");
2145 return selection_menu_item;
2148 GtkMenuItem* create_bsp_menu()
2151 GtkMenuItem* bsp_menu_item = new_sub_menu_item_with_mnemonic("_Build");
2152 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(bsp_menu_item));
2154 if (g_Layout_enableDetachableMenus.m_value)
2159 create_menu_item_with_mnemonic(menu, "Customize...", "BuildMenuCustomize");
2161 menu_separator(menu);
2163 Build_constructMenu(menu);
2167 return bsp_menu_item;
2170 GtkMenuItem* create_grid_menu()
2173 GtkMenuItem* grid_menu_item = new_sub_menu_item_with_mnemonic("_Grid");
2174 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(grid_menu_item));
2175 if (g_Layout_enableDetachableMenus.m_value)
2176 menu_tearoff (menu);
2178 Grid_constructMenu(menu);
2180 return grid_menu_item;
2183 void RefreshShaders()
2185 ScopeDisableScreenUpdates disableScreenUpdates("Processing...", "Loading Shaders");
2186 GlobalShaderSystem().refresh();
2191 GtkMenuItem* create_textures_menu()
2194 GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic("_Textures");
2195 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(textures_menu_item));
2196 g_textures_menu = menu;
2197 if (g_Layout_enableDetachableMenus.m_value)
2198 menu_tearoff (menu);
2200 create_check_menu_item_with_mnemonic(menu, "Hide _Unused", "ShowInUse");
2201 create_menu_item_with_mnemonic(menu, "Show All", "ShowAllTextures");
2203 menu_separator(menu);
2204 create_check_menu_item_with_mnemonic(menu, "Show shaders", "ToggleShowShaders");
2205 create_menu_item_with_mnemonic(menu, "Flush & Reload Shaders", "RefreshShaders");
2206 create_menu_item_with_mnemonic(menu, "Directory list...", "TextureDirectoryList");
2207 menu_separator(menu);
2209 create_menu_item_with_mnemonic(menu, "Find / Replace...", "FindReplaceTextures");
2212 menu_separator(menu);
2213 create_check_menu_item_with_mnemonic (menu, "Shaders Only", "ToggleShowShaderlistOnly");
2214 g_textures_menu_separator = menu_separator(menu);
2216 TextureGroupsMenu_Construct();
2218 return textures_menu_item;
2221 GtkMenuItem* create_misc_menu()
2224 GtkMenuItem* misc_menu_item = new_sub_menu_item_with_mnemonic("M_isc");
2225 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(misc_menu_item));
2226 if (g_Layout_enableDetachableMenus.m_value)
2227 menu_tearoff (menu);
2230 create_menu_item_with_mnemonic(menu, "_Benchmark", FreeCaller<GlobalCamera_Benchmark>());
2232 gtk_container_add(GTK_CONTAINER(menu), GTK_WIDGET(create_colours_menu()));
2234 create_menu_item_with_mnemonic(menu, "Find brush...", "FindBrush");
2235 create_menu_item_with_mnemonic(menu, "Map Info...", "MapInfo");
2236 // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394
2237 // create_menu_item_with_mnemonic(menu, "_Print XY View", FreeCaller<WXY_Print>());
2239 return misc_menu_item;
2242 GtkMenuItem* create_entity_menu()
2245 GtkMenuItem* entity_menu_item = new_sub_menu_item_with_mnemonic("E_ntity");
2246 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(entity_menu_item));
2247 if (g_Layout_enableDetachableMenus.m_value)
2248 menu_tearoff (menu);
2250 Entity_constructMenu(menu);
2252 return entity_menu_item;
2255 GtkMenuItem* create_brush_menu()
2258 GtkMenuItem* brush_menu_item = new_sub_menu_item_with_mnemonic("B_rush");
2259 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(brush_menu_item));
2260 if (g_Layout_enableDetachableMenus.m_value)
2261 menu_tearoff (menu);
2263 Brush_constructMenu(menu);
2265 return brush_menu_item;
2268 GtkMenuItem* create_patch_menu()
2271 GtkMenuItem* patch_menu_item = new_sub_menu_item_with_mnemonic("_Curve");
2272 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(patch_menu_item));
2273 if (g_Layout_enableDetachableMenus.m_value)
2278 Patch_constructMenu(menu);
2280 return patch_menu_item;
2283 GtkMenuItem* create_help_menu()
2286 GtkMenuItem* help_menu_item = new_sub_menu_item_with_mnemonic("_Help");
2287 GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(help_menu_item));
2288 if (g_Layout_enableDetachableMenus.m_value)
2289 menu_tearoff (menu);
2291 create_menu_item_with_mnemonic(menu, "Manual", "OpenManual");
2293 // this creates all the per-game drop downs for the game pack helps
2294 // it will take care of hooking the Sys_OpenURL calls etc.
2295 create_game_help_menu(menu);
2297 create_menu_item_with_mnemonic(menu, "Bug report", FreeCaller<OpenBugReportURL>());
2298 create_menu_item_with_mnemonic(menu, "Shortcuts list", FreeCaller<DoCommandListDlg>());
2299 create_menu_item_with_mnemonic(menu, "_About", FreeCaller<DoAbout>());
2301 return help_menu_item;
2304 GtkMenuBar* create_main_menu(MainFrame::EViewStyle style)
2306 GtkMenuBar* menu_bar = GTK_MENU_BAR(gtk_menu_bar_new());
2307 gtk_widget_show(GTK_WIDGET(menu_bar));
2309 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_file_menu()));
2310 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_edit_menu()));
2311 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_view_menu(style)));
2312 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_selection_menu()));
2313 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_bsp_menu()));
2314 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_grid_menu()));
2315 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_textures_menu()));
2316 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_misc_menu()));
2317 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_entity_menu()));
2318 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_brush_menu()));
2319 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_patch_menu()));
2320 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_plugins_menu()));
2321 gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_help_menu()));
2327 void PatchInspector_registerShortcuts()
2329 command_connect_accelerator("PatchInspector");
2332 void Patch_registerShortcuts()
2334 command_connect_accelerator("InvertCurveTextureX");
2335 command_connect_accelerator("InvertCurveTextureY");
2336 command_connect_accelerator("IncPatchColumn");
2337 command_connect_accelerator("IncPatchRow");
2338 command_connect_accelerator("DecPatchColumn");
2339 command_connect_accelerator("DecPatchRow");
2340 command_connect_accelerator("NaturalizePatch");
2341 //command_connect_accelerator("CapCurrentCurve");
2344 void Manipulators_registerShortcuts()
2346 toggle_add_accelerator("MouseRotate");
2347 toggle_add_accelerator("MouseTranslate");
2348 toggle_add_accelerator("MouseScale");
2349 toggle_add_accelerator("MouseDrag");
2350 toggle_add_accelerator("ToggleClipper");
2353 void TexdefNudge_registerShortcuts()
2355 command_connect_accelerator("TexRotateClock");
2356 command_connect_accelerator("TexRotateCounter");
2357 command_connect_accelerator("TexScaleUp");
2358 command_connect_accelerator("TexScaleDown");
2359 command_connect_accelerator("TexScaleLeft");
2360 command_connect_accelerator("TexScaleRight");
2361 command_connect_accelerator("TexShiftUp");
2362 command_connect_accelerator("TexShiftDown");
2363 command_connect_accelerator("TexShiftLeft");
2364 command_connect_accelerator("TexShiftRight");
2367 void SelectNudge_registerShortcuts()
2369 command_connect_accelerator("MoveSelectionDOWN");
2370 command_connect_accelerator("MoveSelectionUP");
2371 //command_connect_accelerator("SelectNudgeLeft");
2372 //command_connect_accelerator("SelectNudgeRight");
2373 //command_connect_accelerator("SelectNudgeUp");
2374 //command_connect_accelerator("SelectNudgeDown");
2377 void SnapToGrid_registerShortcuts()
2379 command_connect_accelerator("SnapToGrid");
2382 void SelectByType_registerShortcuts()
2384 command_connect_accelerator("SelectAllOfType");
2387 void SurfaceInspector_registerShortcuts()
2389 command_connect_accelerator("FitTexture");
2393 void register_shortcuts()
2395 PatchInspector_registerShortcuts();
2396 Patch_registerShortcuts();
2397 Grid_registerShortcuts();
2398 XYWnd_registerShortcuts();
2399 CamWnd_registerShortcuts();
2400 Manipulators_registerShortcuts();
2401 SurfaceInspector_registerShortcuts();
2402 TexdefNudge_registerShortcuts();
2403 SelectNudge_registerShortcuts();
2404 SnapToGrid_registerShortcuts();
2405 SelectByType_registerShortcuts();
2408 void File_constructToolbar(GtkToolbar* toolbar)
2410 toolbar_append_button(toolbar, "Open an existing map", "file_open.bmp", "OpenMap");
2411 toolbar_append_button(toolbar, "Save the active map", "file_save.bmp", "SaveMap");
2414 void RotateFlip_constructToolbar(GtkToolbar* toolbar)
2416 toolbar_append_button(toolbar, "x-axis Flip", "brush_flipx.bmp", "MirrorSelectionX");
2417 toolbar_append_button(toolbar, "x-axis Rotate", "brush_rotatex.bmp", "RotateSelectionX");
2418 toolbar_append_button(toolbar, "y-axis Flip", "brush_flipy.bmp", "MirrorSelectionY");
2419 toolbar_append_button(toolbar, "y-axis Rotate", "brush_rotatey.bmp", "RotateSelectionY");
2420 toolbar_append_button(toolbar, "z-axis Flip", "brush_flipz.bmp", "MirrorSelectionZ");
2421 toolbar_append_button(toolbar, "z-axis Rotate", "brush_rotatez.bmp", "RotateSelectionZ");
2424 void CSG_constructToolbar(GtkToolbar* toolbar)
2426 toolbar_append_button(toolbar, "CSG Subtract", "selection_csgsubtract.bmp", "CSGSubtract");
2427 toolbar_append_button(toolbar, "CSG Merge", "selection_csgmerge.bmp", "CSGMerge");
2428 toolbar_append_button(toolbar, "Hollow", "selection_makehollow.bmp", "CSGHollow");
2431 void ComponentModes_constructToolbar(GtkToolbar* toolbar)
2433 toolbar_append_toggle_button(toolbar, "Select Vertices", "modify_vertices.bmp", "DragVertices");
2434 toolbar_append_toggle_button(toolbar, "Select Edges", "modify_edges.bmp", "DragEdges");
2435 toolbar_append_toggle_button(toolbar, "Select Faces", "modify_faces.bmp", "DragFaces");
2438 void Clipper_constructToolbar(GtkToolbar* toolbar)
2441 toolbar_append_toggle_button(toolbar, "Clipper", "view_clipper.bmp", "ToggleClipper");
2444 void XYWnd_constructToolbar(GtkToolbar* toolbar)
2446 toolbar_append_button(toolbar, "Change views", "view_change.bmp", "NextView");
2449 void Manipulators_constructToolbar(GtkToolbar* toolbar)
2451 toolbar_append_toggle_button(toolbar, "Translate", "select_mousetranslate.bmp", "MouseTranslate");
2452 toolbar_append_toggle_button(toolbar, "Rotate", "select_mouserotate.bmp", "MouseRotate");
2453 toolbar_append_toggle_button(toolbar, "Scale", "select_mousescale.bmp", "MouseScale");
2454 toolbar_append_toggle_button(toolbar, "Resize", "select_mouseresize.bmp", "MouseDrag");
2456 Clipper_constructToolbar(toolbar);
2459 GtkToolbar* create_main_toolbar(MainFrame::EViewStyle style)
2461 GtkToolbar* toolbar = GTK_TOOLBAR(gtk_toolbar_new());
2462 gtk_toolbar_set_orientation(toolbar, GTK_ORIENTATION_HORIZONTAL);
2463 gtk_toolbar_set_style(toolbar, GTK_TOOLBAR_ICONS);
2465 gtk_widget_show(GTK_WIDGET(toolbar));
2467 File_constructToolbar(toolbar);
2469 gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
2471 RotateFlip_constructToolbar(toolbar);
2473 gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
2475 CSG_constructToolbar(toolbar);
2477 gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
2479 ComponentModes_constructToolbar(toolbar);
2481 if(style == MainFrame::eRegular || style == MainFrame::eRegularLeft || style == MainFrame::eFloating)
2483 gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
2485 XYWnd_constructToolbar(toolbar);
2488 gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
2490 CamWnd_constructToolbar(toolbar);
2492 gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
2494 Manipulators_constructToolbar(toolbar);
2496 if (g_Layout_enablePatchToolbar.m_value)
2498 gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
2500 Patch_constructToolbar(toolbar);
2503 gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
2505 toolbar_append_toggle_button(toolbar, "Texture Lock", "texture_lock.bmp", "TogTexLock");
2510 GtkWidget* create_main_statusbar(GtkWidget *pStatusLabel[c_count_status])
2512 GtkTable* table = GTK_TABLE(gtk_table_new(1, c_count_status, FALSE));
2513 gtk_widget_show(GTK_WIDGET(table));
2516 GtkLabel* label = GTK_LABEL(gtk_label_new ("Label"));
2517 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
2518 gtk_misc_set_padding(GTK_MISC(label), 4, 2);
2519 gtk_widget_show(GTK_WIDGET(label));
2520 gtk_table_attach_defaults(table, GTK_WIDGET(label), 0, 1, 0, 1);
2521 pStatusLabel[c_command_status] = GTK_WIDGET(label);
2524 for(int i = 1; i < c_count_status; ++i)
2526 GtkFrame* frame = GTK_FRAME(gtk_frame_new(0));
2527 gtk_widget_show(GTK_WIDGET(frame));
2528 gtk_table_attach_defaults(table, GTK_WIDGET(frame), i, i + 1, 0, 1);
2529 gtk_frame_set_shadow_type(frame, GTK_SHADOW_IN);
2531 GtkLabel* label = GTK_LABEL(gtk_label_new ("Label"));
2532 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
2533 gtk_misc_set_padding(GTK_MISC(label), 4, 2);
2534 gtk_widget_show(GTK_WIDGET(label));
2535 gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(label));
2536 pStatusLabel[i] = GTK_WIDGET(label);
2539 return GTK_WIDGET(table);
2544 class WidgetFocusPrinter
2548 static gboolean focus_in(GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self)
2550 globalOutputStream() << self->m_name << " takes focus\n";
2553 static gboolean focus_out(GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self)
2555 globalOutputStream() << self->m_name << " loses focus\n";
2559 WidgetFocusPrinter(const char* name) : m_name(name)
2562 void connect(GtkWindow* window)
2564 g_signal_connect(G_OBJECT(window), "focus_in_event", G_CALLBACK(focus_in), this);
2565 g_signal_connect(G_OBJECT(window), "focus_out_event", G_CALLBACK(focus_out), this);
2569 WidgetFocusPrinter g_mainframeWidgetFocusPrinter("mainframe");
2571 class WindowFocusPrinter
2575 static gboolean frame_event(GtkWidget *widget, GdkEvent* event, WindowFocusPrinter* self)
2577 globalOutputStream() << self->m_name << " frame_event\n";
2580 static gboolean keys_changed(GtkWidget *widget, WindowFocusPrinter* self)
2582 globalOutputStream() << self->m_name << " keys_changed\n";
2585 static gboolean notify(GtkWindow* window, gpointer dummy, WindowFocusPrinter* self)
2587 if(gtk_window_is_active(window))
2589 globalOutputStream() << self->m_name << " takes toplevel focus\n";
2593 globalOutputStream() << self->m_name << " loses toplevel focus\n";
2598 WindowFocusPrinter(const char* name) : m_name(name)
2601 void connect(GtkWindow* toplevel_window)
2603 g_signal_connect(G_OBJECT(toplevel_window), "notify::has_toplevel_focus", G_CALLBACK(notify), this);
2604 g_signal_connect(G_OBJECT(toplevel_window), "notify::is_active", G_CALLBACK(notify), this);
2605 g_signal_connect(G_OBJECT(toplevel_window), "keys_changed", G_CALLBACK(keys_changed), this);
2606 g_signal_connect(G_OBJECT(toplevel_window), "frame_event", G_CALLBACK(frame_event), this);
2610 WindowFocusPrinter g_mainframeFocusPrinter("mainframe");
2614 class MainWindowActive
2616 static gboolean notify(GtkWindow* window, gpointer dummy, MainWindowActive* self)
2618 if(g_wait.m_window != 0 && gtk_window_is_active(window) && !GTK_WIDGET_VISIBLE(g_wait.m_window))
2620 gtk_widget_show(GTK_WIDGET(g_wait.m_window));
2626 void connect(GtkWindow* toplevel_window)
2628 g_signal_connect(G_OBJECT(toplevel_window), "notify::is-active", G_CALLBACK(notify), this);
2632 MainWindowActive g_MainWindowActive;
2634 // =============================================================================
2637 MainFrame* g_pParentWnd = 0;
2639 GtkWindow* MainFrame_getWindow()
2641 if(g_pParentWnd == 0)
2645 return g_pParentWnd->m_window;
2648 std::vector<GtkWidget*> g_floating_windows;
2650 MainFrame::MainFrame() : m_window(0), m_idleRedrawStatusText(RedrawStatusTextCaller(*this))
2659 for (int n = 0;n < c_count_status;n++)
2661 m_pStatusLabel[n] = 0;
2664 m_bSleeping = false;
2669 MainFrame::~MainFrame()
2673 gtk_widget_hide(GTK_WIDGET(m_window));
2677 for(std::vector<GtkWidget*>::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i)
2679 gtk_widget_destroy(*i);
2682 gtk_widget_destroy(GTK_WIDGET(m_window));
2685 void MainFrame::SetActiveXY(XYWnd* p)
2688 m_pActiveXY->SetActive(false);
2693 m_pActiveXY->SetActive(true);
2697 void MainFrame::ReleaseContexts()
2701 m_pXYWnd->DestroyContext();
2703 m_pYZWnd->DestroyContext();
2705 m_pXZWnd->DestroyContext();
2707 m_pCamWnd->DestroyContext();
2709 m_pTexWnd->DestroyContext();
2711 m_pZWnd->DestroyContext();
2715 void MainFrame::CreateContexts()
2719 m_pCamWnd->CreateContext();
2721 m_pXYWnd->CreateContext();
2723 m_pYZWnd->CreateContext();
2725 m_pXZWnd->CreateContext();
2727 m_pTexWnd->CreateContext();
2729 m_pZWnd->CreateContext();
2737 void MainFrame::OnSleep()
2743 // useful when trying to debug crashes in the sleep code
2744 globalOutputStream() << "Going into sleep mode..\n";
2746 globalOutputStream() << "Dispatching sleep msg...";
2747 DispatchRadiantMsg (RADIANT_SLEEP);
2748 globalOutputStream() << "Done.\n";
2750 gtk_window_iconify(m_window);
2751 GlobalSelectionSystem().setSelectedAll(false);
2753 GlobalShaderCache().unrealise();
2755 GlobalOpenGL_debugAssertNoErrors();
2756 ScreenUpdates_Disable();
2759 globalOutputStream() << "Releasing contexts...";
2761 globalOutputStream() << "Done.\n";
2765 globalOutputStream() << "Waking up\n";
2767 gtk_window_deiconify(m_window);
2770 globalOutputStream() << "Creating contexts...";
2772 globalOutputStream() << "Done.\n";
2774 globalOutputStream() << "Making current on camera...";
2775 m_pCamWnd->MakeCurrent();
2776 globalOutputStream() << "Done.\n";
2778 globalOutputStream() << "Reloading shaders...";
2780 GlobalShaderCache().realise();
2781 globalOutputStream() << "Done.\n";
2783 ScreenUpdates_Enable();
2785 globalOutputStream() << "Dispatching wake msg...";
2786 DispatchRadiantMsg (RADIANT_WAKEUP);
2787 globalOutputStream() << "Done\n";
2793 GtkWindow* create_splash()
2795 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
2796 gtk_window_set_decorated(window, FALSE);
2797 gtk_window_set_resizable(window, FALSE);
2798 gtk_window_set_modal(window, TRUE);
2799 gtk_window_set_default_size(window, -1, -1);
2800 gtk_window_set_position(window, GTK_WIN_POS_CENTER);
2801 gtk_container_set_border_width(GTK_CONTAINER(window), 0);
2803 GtkImage* image = new_local_image("splash.bmp");
2804 gtk_widget_show(GTK_WIDGET(image));
2805 gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(image));
2807 gtk_widget_set_size_request(GTK_WIDGET(window), -1, -1);
2808 gtk_widget_show(GTK_WIDGET(window));
2813 static GtkWindow *splash_screen = 0;
2817 splash_screen = create_splash();
2824 gtk_widget_destroy(GTK_WIDGET(splash_screen));
2827 WindowPositionTracker g_posCamWnd;
2828 WindowPositionTracker g_posXYWnd;
2829 WindowPositionTracker g_posXZWnd;
2830 WindowPositionTracker g_posYZWnd;
2832 static gint mainframe_delete (GtkWidget *widget, GdkEvent *event, gpointer data)
2834 if(ConfirmModified("Exit Radiant"))
2842 void MainFrame::Create()
2844 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
2846 GlobalWindowObservers_connectTopLevel(window);
2848 gtk_window_set_transient_for(splash_screen, window);
2852 GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask("icon.bmp");
2855 gtk_window_set_icon(window, pixbuf);
2856 gdk_pixbuf_unref(pixbuf);
2861 gtk_widget_add_events(GTK_WIDGET(window), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK);
2862 g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(mainframe_delete), this);
2864 m_position_tracker.connect(window);
2867 g_mainframeWidgetFocusPrinter.connect(window);
2868 g_mainframeFocusPrinter.connect(window);
2871 g_MainWindowActive.connect(window);
2873 GetPlugInMgr().Init(GTK_WIDGET(window));
2875 GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
2876 gtk_container_add(GTK_CONTAINER(window), vbox);
2877 gtk_widget_show(vbox);
2879 global_accel_connect_window(window);
2881 m_nCurrentStyle = (EViewStyle)g_Layout_viewStyle.m_value;
2883 register_shortcuts();
2885 GtkMenuBar* main_menu = create_main_menu(CurrentStyle());
2886 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(main_menu), FALSE, FALSE, 0);
2888 GtkToolbar* main_toolbar = create_main_toolbar(CurrentStyle());
2889 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(main_toolbar), FALSE, FALSE, 0);
2891 GtkToolbar* plugin_toolbar = create_plugin_toolbar();
2892 if (!g_Layout_enablePluginToolbar.m_value)
2894 gtk_widget_hide(GTK_WIDGET(plugin_toolbar));
2896 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(plugin_toolbar), FALSE, FALSE, 0);
2898 GtkWidget* main_statusbar = create_main_statusbar(m_pStatusLabel);
2899 gtk_box_pack_end(GTK_BOX(vbox), main_statusbar, FALSE, TRUE, 2);
2901 GroupDialog_constructWindow(window);
2902 g_page_entity = GroupDialog_addPage("Entities", EntityInspector_constructWindow(GroupDialog_getWindow()), RawStringExportCaller("Entities"));
2904 if(FloatingGroupDialog())
2906 g_page_console = GroupDialog_addPage("Console", Console_constructWindow(GroupDialog_getWindow()), RawStringExportCaller("Console"));
2910 if( g_multimon_globals.m_bStartOnPrimMon )
2912 PositionWindowOnPrimaryScreen(g_layout_globals.m_position);
2913 window_set_position(window, g_layout_globals.m_position);
2917 if(g_layout_globals.nState & GDK_WINDOW_STATE_MAXIMIZED)
2919 gtk_window_maximize(window);
2920 WindowPosition default_position(-1, -1, 640, 480);
2921 window_set_position(window, default_position);
2925 window_set_position(window, g_layout_globals.m_position);
2930 gtk_widget_show(GTK_WIDGET(window));
2932 if (CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft)
2935 GtkWidget* vsplit = gtk_vpaned_new();
2937 gtk_box_pack_start(GTK_BOX(vbox), vsplit, TRUE, TRUE, 0);
2938 gtk_widget_show (vsplit);
2941 GtkWidget* console_window = Console_constructWindow(window);
2942 gtk_paned_pack2(GTK_PANED(vsplit), console_window, FALSE, TRUE);
2945 GtkWidget* hsplit = gtk_hpaned_new();
2946 gtk_widget_show (hsplit);
2948 gtk_paned_add1(GTK_PANED(vsplit), hsplit);
2951 m_pXYWnd = new XYWnd();
2952 m_pXYWnd->SetViewType(XY);
2953 GtkWidget* xy_window = GTK_WIDGET(create_framed_widget(m_pXYWnd->GetWidget()));
2956 GtkWidget* vsplit2 = gtk_vpaned_new();
2957 gtk_widget_show(vsplit2);
2958 m_vSplit2 = vsplit2;
2960 if (CurrentStyle() == eRegular)
2962 gtk_paned_add1(GTK_PANED(hsplit), xy_window);
2963 gtk_paned_add2(GTK_PANED(hsplit), vsplit2);
2967 gtk_paned_add1(GTK_PANED(hsplit), vsplit2);
2968 gtk_paned_add2(GTK_PANED(hsplit), xy_window);
2973 m_pCamWnd = NewCamWnd();
2974 GlobalCamera_setCamWnd(*m_pCamWnd);
2975 CamWnd_setParent(*m_pCamWnd, window);
2976 GtkFrame* camera_window = create_framed_widget(CamWnd_getWidget(*m_pCamWnd));
2978 gtk_paned_add1(GTK_PANED(vsplit2), GTK_WIDGET(camera_window));
2981 GtkFrame* texture_window = create_framed_widget(TextureBrowser_constructWindow(window));
2983 gtk_paned_add2(GTK_PANED(vsplit2), GTK_WIDGET(texture_window));
2989 gtk_paned_set_position(GTK_PANED(m_vSplit), g_layout_globals.nXYHeight);
2991 if (CurrentStyle() == eRegular)
2993 gtk_paned_set_position(GTK_PANED(m_hSplit), g_layout_globals.nXYWidth);
2997 gtk_paned_set_position(GTK_PANED(m_hSplit), g_layout_globals.nCamWidth);
3000 gtk_paned_set_position(GTK_PANED(m_vSplit2), g_layout_globals.nCamHeight);
3002 else if (CurrentStyle() == eFloating)
3005 GtkWindow* window = create_persistent_floating_window("Camera", m_window);
3006 global_accel_connect_window(window);
3007 g_posCamWnd.connect(window);
3009 gtk_widget_show(GTK_WIDGET(window));
3011 m_pCamWnd = NewCamWnd();
3012 GlobalCamera_setCamWnd(*m_pCamWnd);
3015 GtkFrame* frame = create_framed_widget(CamWnd_getWidget(*m_pCamWnd));
3016 gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(frame));
3018 CamWnd_setParent(*m_pCamWnd, window);
3020 g_floating_windows.push_back(GTK_WIDGET(window));
3024 GtkWindow* window = create_persistent_floating_window(ViewType_getTitle(XY), m_window);
3025 global_accel_connect_window(window);
3026 g_posXYWnd.connect(window);
3028 m_pXYWnd = new XYWnd();
3029 m_pXYWnd->m_parent = window;
3030 m_pXYWnd->SetViewType(XY);
3034 GtkFrame* frame = create_framed_widget(m_pXYWnd->GetWidget());
3035 gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(frame));
3037 XY_Top_Shown_Construct(window);
3039 g_floating_windows.push_back(GTK_WIDGET(window));
3043 GtkWindow* window = create_persistent_floating_window(ViewType_getTitle(XZ), m_window);
3044 global_accel_connect_window(window);
3045 g_posXZWnd.connect(window);
3047 m_pXZWnd = new XYWnd();
3048 m_pXZWnd->m_parent = window;
3049 m_pXZWnd->SetViewType(XZ);
3052 GtkFrame* frame = create_framed_widget(m_pXZWnd->GetWidget());
3053 gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(frame));
3056 XZ_Front_Shown_Construct(window);
3058 g_floating_windows.push_back(GTK_WIDGET(window));
3062 GtkWindow* window = create_persistent_floating_window(ViewType_getTitle(YZ), m_window);
3063 global_accel_connect_window(window);
3064 g_posYZWnd.connect(window);
3066 m_pYZWnd = new XYWnd();
3067 m_pYZWnd->m_parent = window;
3068 m_pYZWnd->SetViewType(YZ);
3071 GtkFrame* frame = create_framed_widget(m_pYZWnd->GetWidget());
3072 gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(frame));
3075 YZ_Side_Shown_Construct(window);
3077 g_floating_windows.push_back(GTK_WIDGET(window));
3081 GtkFrame* frame = create_framed_widget(TextureBrowser_constructWindow(GroupDialog_getWindow()));
3082 g_page_textures = GroupDialog_addPage("Textures", GTK_WIDGET(frame), TextureBrowserExportTitleCaller());
3089 m_pCamWnd = NewCamWnd();
3090 GlobalCamera_setCamWnd(*m_pCamWnd);
3091 CamWnd_setParent(*m_pCamWnd, window);
3093 GtkWidget* camera = CamWnd_getWidget(*m_pCamWnd);
3095 m_pYZWnd = new XYWnd();
3096 m_pYZWnd->SetViewType(YZ);
3098 GtkWidget* yz = m_pYZWnd->GetWidget();
3100 m_pXYWnd = new XYWnd();
3101 m_pXYWnd->SetViewType(XY);
3103 GtkWidget* xy = m_pXYWnd->GetWidget();
3105 m_pXZWnd = new XYWnd();
3106 m_pXZWnd->SetViewType(XZ);
3108 GtkWidget* xz = m_pXZWnd->GetWidget();
3110 GtkHPaned* split = create_split_views(camera, yz, xy, xz);
3111 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(split), TRUE, TRUE, 0);
3114 GtkFrame* frame = create_framed_widget(TextureBrowser_constructWindow(window));
3115 g_page_textures = GroupDialog_addPage("Textures", GTK_WIDGET(frame), TextureBrowserExportTitleCaller());
3119 EntityList_constructWindow(window);
3120 PreferencesDialog_constructWindow(window);
3121 FindTextureDialog_constructWindow(window);
3122 SurfaceInspector_constructWindow(window);
3123 PatchInspector_constructWindow(window);
3125 SetActiveXY(m_pXYWnd);
3127 AddGridChangeCallback(SetGridStatusCaller(*this));
3128 AddGridChangeCallback(ReferenceCaller<MainFrame, XY_UpdateAllWindows>(*this));
3130 g_defaultToolMode = DragMode;
3131 g_defaultToolMode();
3132 SetStatusText(m_command_status, c_TranslateMode_status);
3134 EverySecondTimer_enable();
3136 //GlobalShortcuts_reportUnregistered();
3139 void MainFrame::SaveWindowInfo()
3141 if (!FloatingGroupDialog())
3143 g_layout_globals.nXYHeight = gtk_paned_get_position(GTK_PANED(m_vSplit));
3145 if(CurrentStyle() != eRegular)
3147 g_layout_globals.nCamWidth = gtk_paned_get_position(GTK_PANED(m_hSplit));
3151 g_layout_globals.nXYWidth = gtk_paned_get_position(GTK_PANED(m_hSplit));
3154 g_layout_globals.nCamHeight = gtk_paned_get_position(GTK_PANED(m_vSplit2));
3157 g_layout_globals.m_position = m_position_tracker.getPosition();
3159 g_layout_globals.nState = gdk_window_get_state(GTK_WIDGET(m_window)->window);
3162 void MainFrame::Shutdown()
3164 EverySecondTimer_disable();
3166 EntityList_destroyWindow();
3168 g_textures_menu = 0;
3177 TextureBrowser_destroyWindow();
3179 DeleteCamWnd(m_pCamWnd);
3182 PreferencesDialog_destroyWindow();
3183 SurfaceInspector_destroyWindow();
3184 FindTextureDialog_destroyWindow();
3185 PatchInspector_destroyWindow();
3187 g_DbgDlg.destroyWindow();
3189 // destroying group-dialog last because it may contain texture-browser
3190 GroupDialog_destroyWindow();
3193 void MainFrame::RedrawStatusText()
3195 gtk_label_set_text(GTK_LABEL(m_pStatusLabel[c_command_status]), m_command_status.c_str());
3196 gtk_label_set_text(GTK_LABEL(m_pStatusLabel[c_position_status]), m_position_status.c_str());
3197 gtk_label_set_text(GTK_LABEL(m_pStatusLabel[c_brushcount_status]), m_brushcount_status.c_str());
3198 gtk_label_set_text(GTK_LABEL(m_pStatusLabel[c_texture_status]), m_texture_status.c_str());
3199 gtk_label_set_text(GTK_LABEL(m_pStatusLabel[c_grid_status]), m_grid_status.c_str());
3202 void MainFrame::UpdateStatusText()
3204 m_idleRedrawStatusText.queueDraw();
3207 void MainFrame::SetStatusText(CopiedString& status_text, const char* pText)
3209 status_text = pText;
3213 void Sys_Status(const char* status)
3215 if(g_pParentWnd != 0)
3217 g_pParentWnd->SetStatusText (g_pParentWnd->m_command_status, status);
3221 int getRotateIncrement()
3223 return static_cast<int>(g_si_globals.rotate);
3226 int getFarClipDistance()
3228 return g_camwindow_globals.m_nCubicScale;
3231 float (*GridStatus_getGridSize)() = GetGridSize;
3232 int (*GridStatus_getRotateIncrement)() = getRotateIncrement;
3233 int (*GridStatus_getFarClipDistance)() = getFarClipDistance;
3234 bool (*GridStatus_getTextureLockEnabled)();
3236 void MainFrame::SetGridStatus()
3238 StringOutputStream status(64);
3239 const char* lock = (GridStatus_getTextureLockEnabled()) ? "ON" : "OFF";
3240 status << "G:" << GridStatus_getGridSize()
3241 << " R:" << GridStatus_getRotateIncrement()
3242 << " C:" << GridStatus_getFarClipDistance()
3244 SetStatusText(m_grid_status, status.c_str());
3247 void GridStatus_onTextureLockEnabledChanged()
3249 if(g_pParentWnd != 0)
3251 g_pParentWnd->SetGridStatus();
3257 GLFont g_font(0, 0);
3260 void GlobalGL_sharedContextCreated()
3262 // report OpenGL information
3263 globalOutputStream() << "GL_VENDOR: " << reinterpret_cast<const char*>(glGetString (GL_VENDOR)) << "\n";
3264 globalOutputStream() << "GL_RENDERER: " << reinterpret_cast<const char*>(glGetString (GL_RENDERER)) << "\n";
3265 globalOutputStream() << "GL_VERSION: " << reinterpret_cast<const char*>(glGetString (GL_VERSION)) << "\n";
3266 globalOutputStream() << "GL_EXTENSIONS: " << reinterpret_cast<const char*>(glGetString (GL_EXTENSIONS)) << "\n";
3268 QGL_sharedContextCreated(GlobalOpenGL());
3270 ShaderCache_extensionsInitialised();
3272 GlobalShaderCache().realise();
3275 g_font = glfont_create("courier 8");
3276 GlobalOpenGL().m_font = g_font.getDisplayList();
3277 GlobalOpenGL().m_fontHeight = g_font.getPixelHeight();
3280 void GlobalGL_sharedContextDestroyed()
3282 Textures_Unrealise();
3283 GlobalShaderCache().unrealise();
3285 QGL_sharedContextDestroyed(GlobalOpenGL());
3289 void Layout_constructPreferences(PreferencesPage& page)
3292 const char* layouts[] = { "window1.bmp", "window2.bmp", "window3.bmp", "window4.bmp" };
3293 page.appendRadioIcons(
3295 STRING_ARRAY_RANGE(layouts),
3296 LatchedIntImportCaller(g_Layout_viewStyle),
3297 IntExportCaller(g_Layout_viewStyle.m_latched)
3300 page.appendCheckBox(
3301 "", "Detachable Menus",
3302 LatchedBoolImportCaller(g_Layout_enableDetachableMenus),
3303 BoolExportCaller(g_Layout_enableDetachableMenus.m_latched)
3305 if (!string_empty(g_pGameDescription->getKeyValue("no_patch")))
3307 page.appendCheckBox(
3308 "", "Patch Toolbar",
3309 LatchedBoolImportCaller(g_Layout_enablePatchToolbar),
3310 BoolExportCaller(g_Layout_enablePatchToolbar.m_latched)
3313 page.appendCheckBox(
3314 "", "Plugin Toolbar",
3315 LatchedBoolImportCaller(g_Layout_enablePluginToolbar),
3316 BoolExportCaller(g_Layout_enablePluginToolbar.m_latched)
3320 void Layout_constructPage(PreferenceGroup& group)
3322 PreferencesPage page(group.createPage("Layout", "Layout Preferences"));
3323 Layout_constructPreferences(page);
3326 void Layout_registerPreferencesPage()
3328 PreferencesDialog_addInterfacePage(FreeCaller1<PreferenceGroup&, Layout_constructPage>());
3332 #include "preferencesystem.h"
3333 #include "stringio.h"
3335 void MainFrame_Construct()
3337 GlobalCommands_insert("OpenManual", FreeCaller<OpenHelpURL>(), Accelerator(GDK_F1));
3339 GlobalCommands_insert("Sleep", FreeCaller<thunk_OnSleep>(), Accelerator('P', (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK)));
3340 GlobalCommands_insert("NewMap", FreeCaller<NewMap>());
3341 GlobalCommands_insert("OpenMap", FreeCaller<OpenMap>(), Accelerator('O', (GdkModifierType)GDK_CONTROL_MASK));
3342 GlobalCommands_insert("ImportMap", FreeCaller<ImportMap>());
3343 GlobalCommands_insert("SaveMap", FreeCaller<SaveMap>(), Accelerator('S', (GdkModifierType)GDK_CONTROL_MASK));
3344 GlobalCommands_insert("SaveMapAs", FreeCaller<SaveMapAs>());
3345 GlobalCommands_insert("SaveSelected", FreeCaller<ExportMap>());
3346 GlobalCommands_insert("SaveRegion", FreeCaller<SaveRegion>());
3347 GlobalCommands_insert("RefreshReferences", FreeCaller<RefreshReferences>());
3348 GlobalCommands_insert("ProjectSettings", FreeCaller<DoProjectSettings>());
3349 GlobalCommands_insert("CheckForUpdate", FreeCaller<OpenUpdateURL>());
3350 GlobalCommands_insert("Exit", FreeCaller<Exit>());
3352 GlobalCommands_insert("Undo", FreeCaller<Undo>(), Accelerator('Z', (GdkModifierType)GDK_CONTROL_MASK));
3353 GlobalCommands_insert("Redo", FreeCaller<Redo>(), Accelerator('Y', (GdkModifierType)GDK_CONTROL_MASK));
3354 GlobalCommands_insert("Copy", FreeCaller<Copy>(), Accelerator('C', (GdkModifierType)GDK_CONTROL_MASK));
3355 GlobalCommands_insert("Paste", FreeCaller<Paste>(), Accelerator('V', (GdkModifierType)GDK_CONTROL_MASK));
3356 GlobalCommands_insert("PasteToCamera", FreeCaller<PasteToCamera>(), Accelerator('V', (GdkModifierType)GDK_MOD1_MASK));
3357 GlobalCommands_insert("CloneSelection", FreeCaller<Selection_Clone>(), Accelerator(GDK_space));
3358 GlobalCommands_insert("DeleteSelection", FreeCaller<deleteSelection>(), Accelerator(GDK_BackSpace));
3359 GlobalCommands_insert("ParentSelection", FreeCaller<Scene_parentSelected>());
3360 GlobalCommands_insert("UnSelectSelection", FreeCaller<Selection_Deselect>(), Accelerator(GDK_Escape));
3361 GlobalCommands_insert("InvertSelection", FreeCaller<Select_Invert>(), Accelerator('I'));
3362 GlobalCommands_insert("ExpandSelectionToEntities", FreeCaller<Scene_ExpandSelectionToEntities>(), Accelerator('E', (GdkModifierType)(GDK_MOD1_MASK|GDK_CONTROL_MASK)));
3363 GlobalCommands_insert("Preferences", FreeCaller<PreferencesDialog_showDialog>(), Accelerator('P'));
3365 GlobalCommands_insert("ToggleConsole", FreeCaller<Console_ToggleShow>(), Accelerator('O'));
3366 GlobalCommands_insert("ToggleEntityInspector", FreeCaller<EntityInspector_ToggleShow>(), Accelerator('N'));
3367 GlobalCommands_insert("EntityList", FreeCaller<EntityList_toggleShown>(), Accelerator('L'));
3369 GlobalCommands_insert("ShowHidden", FreeCaller<Select_ShowAllHidden>(), Accelerator('H', (GdkModifierType)GDK_SHIFT_MASK));
3370 GlobalCommands_insert("HideSelected", FreeCaller<HideSelected>(), Accelerator('H'));
3372 GlobalToggles_insert("DragVertices", FreeCaller<SelectVertexMode>(), ToggleItem::AddCallbackCaller(g_vertexMode_button), Accelerator('V'));
3373 GlobalToggles_insert("DragEdges", FreeCaller<SelectEdgeMode>(), ToggleItem::AddCallbackCaller(g_edgeMode_button), Accelerator('E'));
3374 GlobalToggles_insert("DragFaces", FreeCaller<SelectFaceMode>(), ToggleItem::AddCallbackCaller(g_faceMode_button), Accelerator('F'));
3376 GlobalCommands_insert("MirrorSelectionX", FreeCaller<Selection_Flipx>());
3377 GlobalCommands_insert("RotateSelectionX", FreeCaller<Selection_Rotatex>());
3378 GlobalCommands_insert("MirrorSelectionY", FreeCaller<Selection_Flipy>());
3379 GlobalCommands_insert("RotateSelectionY", FreeCaller<Selection_Rotatey>());
3380 GlobalCommands_insert("MirrorSelectionZ", FreeCaller<Selection_Flipz>());
3381 GlobalCommands_insert("RotateSelectionZ", FreeCaller<Selection_Rotatez>());
3383 GlobalCommands_insert("ArbitraryRotation", FreeCaller<DoRotateDlg>());
3384 GlobalCommands_insert("ArbitraryScale", FreeCaller<DoScaleDlg>());
3386 GlobalCommands_insert("BuildMenuCustomize", FreeCaller<DoBuildMenu>());
3388 GlobalCommands_insert("FindBrush", FreeCaller<DoFind>());
3390 GlobalCommands_insert("MapInfo", FreeCaller<DoMapInfo>(), Accelerator('M'));
3393 GlobalToggles_insert("ToggleClipper", FreeCaller<ClipperMode>(), ToggleItem::AddCallbackCaller(g_clipper_button), Accelerator('X'));
3395 GlobalToggles_insert("MouseTranslate", FreeCaller<TranslateMode>(), ToggleItem::AddCallbackCaller(g_translatemode_button), Accelerator('W'));
3396 GlobalToggles_insert("MouseRotate", FreeCaller<RotateMode>(), ToggleItem::AddCallbackCaller(g_rotatemode_button), Accelerator('R'));
3397 GlobalToggles_insert("MouseScale", FreeCaller<ScaleMode>(), ToggleItem::AddCallbackCaller(g_scalemode_button));
3398 GlobalToggles_insert("MouseDrag", FreeCaller<DragMode>(), ToggleItem::AddCallbackCaller(g_dragmode_button), Accelerator('Q'));
3400 GlobalCommands_insert("ColorSchemeOriginal", FreeCaller<ColorScheme_Original>());
3401 GlobalCommands_insert("ColorSchemeQER", FreeCaller<ColorScheme_QER>());
3402 GlobalCommands_insert("ColorSchemeBlackAndGreen", FreeCaller<ColorScheme_Black>());
3403 GlobalCommands_insert("ColorSchemeYdnar", FreeCaller<ColorScheme_Ydnar>());
3404 GlobalCommands_insert("ChooseTextureBackgroundColor", makeCallback(g_ColoursMenu.m_textureback));
3405 GlobalCommands_insert("ChooseGridBackgroundColor", makeCallback(g_ColoursMenu.m_xyback));
3406 GlobalCommands_insert("ChooseGridMajorColor", makeCallback(g_ColoursMenu.m_gridmajor));
3407 GlobalCommands_insert("ChooseGridMinorColor", makeCallback(g_ColoursMenu.m_gridminor));
3408 GlobalCommands_insert("ChooseSmallGridMajorColor", makeCallback(g_ColoursMenu.m_gridmajor_alt));
3409 GlobalCommands_insert("ChooseSmallGridMinorColor", makeCallback(g_ColoursMenu.m_gridminor_alt));
3410 GlobalCommands_insert("ChooseGridTextColor", makeCallback(g_ColoursMenu.m_gridtext));
3411 GlobalCommands_insert("ChooseGridBlockColor", makeCallback(g_ColoursMenu.m_gridblock));
3412 GlobalCommands_insert("ChooseBrushColor", makeCallback(g_ColoursMenu.m_brush));
3413 GlobalCommands_insert("ChooseCameraBackgroundColor", makeCallback(g_ColoursMenu.m_cameraback));
3414 GlobalCommands_insert("ChooseSelectedBrushColor", makeCallback(g_ColoursMenu.m_selectedbrush));
3415 GlobalCommands_insert("ChooseCameraSelectedBrushColor", makeCallback(g_ColoursMenu.m_selectedbrush3d));
3416 GlobalCommands_insert("ChooseClipperColor", makeCallback(g_ColoursMenu.m_clipper));
3417 GlobalCommands_insert("ChooseOrthoViewNameColor", makeCallback(g_ColoursMenu.m_viewname));
3420 GlobalCommands_insert("CSGSubtract", FreeCaller<CSG_Subtract>(), Accelerator('U', (GdkModifierType)GDK_SHIFT_MASK));
3421 GlobalCommands_insert("CSGMerge", FreeCaller<CSG_Merge>(), Accelerator('U', (GdkModifierType)GDK_CONTROL_MASK));
3422 GlobalCommands_insert("CSGHollow", FreeCaller<CSG_MakeHollow>());
3424 GlobalCommands_insert("TextureDirectoryList", FreeCaller<DoTextureListDlg>());
3426 GlobalCommands_insert("RefreshShaders", FreeCaller<RefreshShaders>());
3428 Grid_registerCommands();
3430 GlobalCommands_insert("SnapToGrid", FreeCaller<Selection_SnapToGrid>(), Accelerator('G', (GdkModifierType)GDK_CONTROL_MASK));
3432 GlobalCommands_insert("SelectAllOfType", FreeCaller<Select_AllOfType>(), Accelerator('A', (GdkModifierType)GDK_SHIFT_MASK));
3434 GlobalCommands_insert("TexRotateClock", FreeCaller<Texdef_RotateClockwise>(), Accelerator(GDK_Next, (GdkModifierType)GDK_SHIFT_MASK));
3435 GlobalCommands_insert("TexRotateCounter", FreeCaller<Texdef_RotateAntiClockwise>(), Accelerator(GDK_Prior, (GdkModifierType)GDK_SHIFT_MASK));
3436 GlobalCommands_insert("TexScaleUp", FreeCaller<Texdef_ScaleUp>(), Accelerator(GDK_Up, (GdkModifierType)GDK_CONTROL_MASK));
3437 GlobalCommands_insert("TexScaleDown", FreeCaller<Texdef_ScaleDown>(), Accelerator(GDK_Down, (GdkModifierType)GDK_CONTROL_MASK));
3438 GlobalCommands_insert("TexScaleLeft", FreeCaller<Texdef_ScaleLeft>(), Accelerator(GDK_Left, (GdkModifierType)GDK_CONTROL_MASK));
3439 GlobalCommands_insert("TexScaleRight", FreeCaller<Texdef_ScaleRight>(), Accelerator(GDK_Right, (GdkModifierType)GDK_CONTROL_MASK));
3440 GlobalCommands_insert("TexShiftUp", FreeCaller<Texdef_ShiftUp>(), Accelerator(GDK_Up, (GdkModifierType)GDK_SHIFT_MASK));
3441 GlobalCommands_insert("TexShiftDown", FreeCaller<Texdef_ShiftDown>(), Accelerator(GDK_Down, (GdkModifierType)GDK_SHIFT_MASK));
3442 GlobalCommands_insert("TexShiftLeft", FreeCaller<Texdef_ShiftLeft>(), Accelerator(GDK_Left, (GdkModifierType)GDK_SHIFT_MASK));
3443 GlobalCommands_insert("TexShiftRight", FreeCaller<Texdef_ShiftRight>(), Accelerator(GDK_Right, (GdkModifierType)GDK_SHIFT_MASK));
3445 GlobalCommands_insert("MoveSelectionDOWN", FreeCaller<Selection_MoveDown>(), Accelerator(GDK_KP_Subtract));
3446 GlobalCommands_insert("MoveSelectionUP", FreeCaller<Selection_MoveUp>(), Accelerator(GDK_KP_Add));
3448 GlobalCommands_insert("SelectNudgeLeft", FreeCaller<Selection_NudgeLeft>(), Accelerator(GDK_Left, (GdkModifierType)GDK_MOD1_MASK));
3449 GlobalCommands_insert("SelectNudgeRight", FreeCaller<Selection_NudgeRight>(), Accelerator(GDK_Right, (GdkModifierType)GDK_MOD1_MASK));
3450 GlobalCommands_insert("SelectNudgeUp", FreeCaller<Selection_NudgeUp>(), Accelerator(GDK_Up, (GdkModifierType)GDK_MOD1_MASK));
3451 GlobalCommands_insert("SelectNudgeDown", FreeCaller<Selection_NudgeDown>(), Accelerator(GDK_Down, (GdkModifierType)GDK_MOD1_MASK));
3453 Patch_registerCommands();
3454 XYShow_registerCommands();
3456 GlobalSelectionSystem().addSelectionChangeCallback(FreeCaller1<const Selectable&, ComponentMode_SelectionChanged>());
3458 GlobalPreferenceSystem().registerPreference("DetachableMenus", BoolImportStringCaller(g_Layout_enableDetachableMenus.m_latched), BoolExportStringCaller(g_Layout_enableDetachableMenus.m_latched));
3459 GlobalPreferenceSystem().registerPreference("PatchToolBar", BoolImportStringCaller(g_Layout_enablePatchToolbar.m_latched), BoolExportStringCaller(g_Layout_enablePatchToolbar.m_latched));
3460 GlobalPreferenceSystem().registerPreference("PluginToolBar", BoolImportStringCaller(g_Layout_enablePluginToolbar.m_latched), BoolExportStringCaller(g_Layout_enablePluginToolbar.m_latched));
3461 GlobalPreferenceSystem().registerPreference("QE4StyleWindows", IntImportStringCaller(g_Layout_viewStyle.m_latched), IntExportStringCaller(g_Layout_viewStyle.m_latched));
3462 GlobalPreferenceSystem().registerPreference("XYHeight", IntImportStringCaller(g_layout_globals.nXYHeight), IntExportStringCaller(g_layout_globals.nXYHeight));
3463 GlobalPreferenceSystem().registerPreference("XYWidth", IntImportStringCaller(g_layout_globals.nXYWidth), IntExportStringCaller(g_layout_globals.nXYWidth));
3464 GlobalPreferenceSystem().registerPreference("CamWidth", IntImportStringCaller(g_layout_globals.nCamWidth), IntExportStringCaller(g_layout_globals.nCamWidth));
3465 GlobalPreferenceSystem().registerPreference("CamHeight", IntImportStringCaller(g_layout_globals.nCamHeight), IntExportStringCaller(g_layout_globals.nCamHeight));
3467 GlobalPreferenceSystem().registerPreference("State", IntImportStringCaller(g_layout_globals.nState), IntExportStringCaller(g_layout_globals.nState));
3468 GlobalPreferenceSystem().registerPreference("PositionX", IntImportStringCaller(g_layout_globals.m_position.x), IntExportStringCaller(g_layout_globals.m_position.x));
3469 GlobalPreferenceSystem().registerPreference("PositionY", IntImportStringCaller(g_layout_globals.m_position.y), IntExportStringCaller(g_layout_globals.m_position.y));
3470 GlobalPreferenceSystem().registerPreference("Width", IntImportStringCaller(g_layout_globals.m_position.w), IntExportStringCaller(g_layout_globals.m_position.w));
3471 GlobalPreferenceSystem().registerPreference("Height", IntImportStringCaller(g_layout_globals.m_position.h), IntExportStringCaller(g_layout_globals.m_position.h));
3473 GlobalPreferenceSystem().registerPreference("CamWnd", WindowPositionTrackerImportStringCaller(g_posCamWnd), WindowPositionTrackerExportStringCaller(g_posCamWnd));
3474 GlobalPreferenceSystem().registerPreference("XYWnd", WindowPositionTrackerImportStringCaller(g_posXYWnd), WindowPositionTrackerExportStringCaller(g_posXYWnd));
3475 GlobalPreferenceSystem().registerPreference("YZWnd", WindowPositionTrackerImportStringCaller(g_posYZWnd), WindowPositionTrackerExportStringCaller(g_posYZWnd));
3476 GlobalPreferenceSystem().registerPreference("XZWnd", WindowPositionTrackerImportStringCaller(g_posXZWnd), WindowPositionTrackerExportStringCaller(g_posXZWnd));
3479 const char* ENGINEPATH_ATTRIBUTE =
3482 #elif defined(__linux__)
3484 #elif defined(__APPLE__)
3487 #error "unknown platform"
3490 StringOutputStream path(256);
3491 path << DirectoryCleaned(g_pGameDescription->getRequiredKeyValue(ENGINEPATH_ATTRIBUTE));
3492 g_strEnginePath = path.c_str();
3495 GlobalPreferenceSystem().registerPreference("EnginePath", CopiedStringImportStringCaller(g_strEnginePath), CopiedStringExportStringCaller(g_strEnginePath));
3497 g_Layout_viewStyle.useLatched();
3498 g_Layout_enableDetachableMenus.useLatched();
3499 g_Layout_enablePatchToolbar.useLatched();
3500 g_Layout_enablePluginToolbar.useLatched();
3502 Layout_registerPreferencesPage();
3503 Paths_registerPreferencesPage();
3505 g_brushCount.setCountChangedCallback(FreeCaller<QE_brushCountChanged>());
3506 g_entityCount.setCountChangedCallback(FreeCaller<QE_entityCountChanged>());
3507 GlobalEntityCreator().setCounter(&g_entityCount);
3509 GLWidget_sharedContextCreated = GlobalGL_sharedContextCreated;
3510 GLWidget_sharedContextDestroyed = GlobalGL_sharedContextDestroyed;
3512 GlobalEntityClassManager().attach(g_WorldspawnColourEntityClassObserver);
3515 void MainFrame_Destroy()
3517 GlobalEntityClassManager().detach(g_WorldspawnColourEntityClassObserver);
3519 GlobalEntityCreator().setCounter(0);
3520 g_entityCount.setCountChangedCallback(Callback());
3521 g_brushCount.setCountChangedCallback(Callback());
3525 void GLWindow_Construct()
3527 GlobalPreferenceSystem().registerPreference("MouseButtons", IntImportStringCaller(g_glwindow_globals.m_nMouseType), IntExportStringCaller(g_glwindow_globals.m_nMouseType));
3530 void GLWindow_Destroy()