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"
61 #include "signal/isignal.h"
64 #include "eclasslib.h"
65 #include "moduleobservers.h"
67 #include "gtkutil/clipboard.h"
68 #include "gtkutil/container.h"
69 #include "gtkutil/frame.h"
70 #include "gtkutil/glfont.h"
71 #include "gtkutil/glwidget.h"
72 #include "gtkutil/image.h"
73 #include "gtkutil/menu.h"
74 #include "gtkutil/paned.h"
75 #include "gtkutil/widget.h"
79 #include "brushmanip.h"
80 #include "brushmodule.h"
81 #include "camwindow.h"
86 #include "entityinspector.h"
87 #include "entitylist.h"
89 #include "findtexturedialog.h"
91 #include "groupdialog.h"
98 #include "patchdialog.h"
99 #include "patchmanip.h"
101 #include "pluginmanager.h"
102 #include "pluginmenu.h"
103 #include "plugintoolbar.h"
105 #include "preferences.h"
110 #include "surfacedialog.h"
111 #include "textures.h"
112 #include "texwindow.h"
114 #include "xywindow.h"
115 #include "windowobservers.h"
116 #include "renderstate.h"
117 #include "feedback.h"
118 #include "referencecache.h"
120 #include "filterbar.h"
121 #include "gtktheme.h"
124 struct layout_globals_t
126 WindowPosition m_position;
136 m_position( -1, -1, 640, 480 ),
146 layout_globals_t g_layout_globals;
147 //glwindow_globals_t g_glwindow_globals;
151 class VFSModuleObserver : public ModuleObserver
153 std::size_t m_unrealised;
155 VFSModuleObserver() : m_unrealised( 1 ){
158 if ( --m_unrealised == 0 ) {
160 GlobalFileSystem().initialise();
164 if ( ++m_unrealised == 1 ) {
165 GlobalFileSystem().shutdown();
170 VFSModuleObserver g_VFSModuleObserver;
172 void VFS_Construct(){
173 Radiant_attachHomePathsObserver( g_VFSModuleObserver );
176 Radiant_detachHomePathsObserver( g_VFSModuleObserver );
184 const GUID qFOLDERID_SavedGames = {0x4C5C32FF, 0xBB9D, 0x43b0, {0xB5, 0xB4, 0x2D, 0x72, 0xE5, 0x4E, 0xAA, 0xA4}};
185 #define qREFKNOWNFOLDERID GUID
186 #define qKF_FLAG_CREATE 0x8000
187 #define qKF_FLAG_NO_ALIAS 0x1000
188 typedef HRESULT ( WINAPI qSHGetKnownFolderPath_t )( qREFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath );
189 static qSHGetKnownFolderPath_t *qSHGetKnownFolderPath;
191 void HomePaths_Realise(){
194 const char* prefix = g_pGameDescription->getKeyValue( "prefix" );
195 if ( !string_empty( prefix ) ) {
196 StringOutputStream path( 256 );
198 #if defined( __APPLE__ )
200 path << DirectoryCleaned( g_get_home_dir() ) << "Library/Application Support" << ( prefix + 1 ) << "/";
201 if ( file_is_directory( path.c_str() ) ) {
202 g_qeglobals.m_userEnginePath = path.c_str();
208 TCHAR mydocsdir[MAX_PATH + 1];
210 HMODULE shfolder = LoadLibrary( "shfolder.dll" );
212 qSHGetKnownFolderPath = (qSHGetKnownFolderPath_t *) GetProcAddress( shfolder, "SHGetKnownFolderPath" );
215 qSHGetKnownFolderPath = NULL;
217 CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
218 if ( qSHGetKnownFolderPath && qSHGetKnownFolderPath( qFOLDERID_SavedGames, qKF_FLAG_CREATE | qKF_FLAG_NO_ALIAS, NULL, &mydocsdirw ) == S_OK ) {
219 memset( mydocsdir, 0, sizeof( mydocsdir ) );
220 wcstombs( mydocsdir, mydocsdirw, sizeof( mydocsdir ) - 1 );
221 CoTaskMemFree( mydocsdirw );
223 path << DirectoryCleaned( mydocsdir ) << ( prefix + 1 ) << "/";
224 if ( file_is_directory( path.c_str() ) ) {
225 g_qeglobals.m_userEnginePath = path.c_str();
227 FreeLibrary( shfolder );
233 FreeLibrary( shfolder );
235 if ( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir ) ) ) {
237 path << DirectoryCleaned( mydocsdir ) << "My Games/" << ( prefix + 1 ) << "/";
238 // win32: only add it if it already exists
239 if ( file_is_directory( path.c_str() ) ) {
240 g_qeglobals.m_userEnginePath = path.c_str();
248 path << DirectoryCleaned( g_get_home_dir() ) << prefix << "/";
249 g_qeglobals.m_userEnginePath = path.c_str();
254 g_qeglobals.m_userEnginePath = EnginePath_get();
258 Q_mkdir( g_qeglobals.m_userEnginePath.c_str() );
261 StringOutputStream path( 256 );
262 path << g_qeglobals.m_userEnginePath.c_str() << gamename_get() << '/';
263 g_qeglobals.m_userGamePath = path.c_str();
265 ASSERT_MESSAGE( !string_empty( g_qeglobals.m_userGamePath.c_str() ), "HomePaths_Realise: user-game-path is empty" );
266 Q_mkdir( g_qeglobals.m_userGamePath.c_str() );
269 ModuleObservers g_homePathObservers;
271 void Radiant_attachHomePathsObserver( ModuleObserver& observer ){
272 g_homePathObservers.attach( observer );
275 void Radiant_detachHomePathsObserver( ModuleObserver& observer ){
276 g_homePathObservers.detach( observer );
279 class HomePathsModuleObserver : public ModuleObserver
281 std::size_t m_unrealised;
283 HomePathsModuleObserver() : m_unrealised( 1 ){
286 if ( --m_unrealised == 0 ) {
288 g_homePathObservers.realise();
292 if ( ++m_unrealised == 1 ) {
293 g_homePathObservers.unrealise();
298 HomePathsModuleObserver g_HomePathsModuleObserver;
300 void HomePaths_Construct(){
301 Radiant_attachEnginePathObserver( g_HomePathsModuleObserver );
303 void HomePaths_Destroy(){
304 Radiant_detachEnginePathObserver( g_HomePathsModuleObserver );
310 CopiedString g_strEnginePath;
311 ModuleObservers g_enginePathObservers;
312 std::size_t g_enginepath_unrealised = 1;
314 void Radiant_attachEnginePathObserver( ModuleObserver& observer ){
315 g_enginePathObservers.attach( observer );
318 void Radiant_detachEnginePathObserver( ModuleObserver& observer ){
319 g_enginePathObservers.detach( observer );
323 void EnginePath_Realise(){
324 if ( --g_enginepath_unrealised == 0 ) {
325 g_enginePathObservers.realise();
330 const char* EnginePath_get(){
331 ASSERT_MESSAGE( g_enginepath_unrealised == 0, "EnginePath_get: engine path not realised" );
332 return g_strEnginePath.c_str();
335 void EnginePath_Unrealise(){
336 if ( ++g_enginepath_unrealised == 1 ) {
337 g_enginePathObservers.unrealise();
341 void setEnginePath( const char* path ){
342 StringOutputStream buffer( 256 );
343 buffer << DirectoryCleaned( path );
344 if ( !path_equal( buffer.c_str(), g_strEnginePath.c_str() ) ) {
346 while ( !ConfirmModified( "Paths Changed" ) )
348 if ( Map_Unnamed( g_map ) ) {
359 ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Changing Engine Path" );
361 EnginePath_Unrealise();
363 g_strEnginePath = buffer.c_str();
365 EnginePath_Realise();
372 CopiedString g_strAppPath; ///< holds the full path of the executable
374 const char* AppPath_get(){
375 return g_strAppPath.c_str();
378 /// the path to the local rc-dir
379 const char* LocalRcPath_get( void ){
380 static CopiedString rc_path;
381 if ( rc_path.empty() ) {
382 StringOutputStream stream( 256 );
383 stream << GlobalRadiant().getSettingsPath() << g_pGameDescription->mGameFile.c_str() << "/";
384 rc_path = stream.c_str();
386 return rc_path.c_str();
389 /// directory for temp files
390 /// NOTE: on *nix this is were we check for .pid
391 CopiedString g_strSettingsPath;
392 const char* SettingsPath_get(){
393 return g_strSettingsPath.c_str();
398 points to the game tools directory, for instance
399 C:/Program Files/Quake III Arena/GtkRadiant
401 this is one of the main variables that are configured by the game selection on startup
402 [GameToolsPath]/plugins
403 [GameToolsPath]/modules
406 CopiedString g_strGameToolsPath; ///< this is set by g_GamesDialog
408 const char* GameToolsPath_get(){
409 return g_strGameToolsPath.c_str();
412 void EnginePathImport( CopiedString& self, const char* value ){
413 setEnginePath( value );
415 typedef ReferenceCaller1<CopiedString, const char*, EnginePathImport> EnginePathImportCaller;
417 void Paths_constructPreferences( PreferencesPage& page ){
418 page.appendPathEntry( "Engine Path", true,
419 StringImportCallback( EnginePathImportCaller( g_strEnginePath ) ),
420 StringExportCallback( StringExportCaller( g_strEnginePath ) )
423 void Paths_constructPage( PreferenceGroup& group ){
424 PreferencesPage page( group.createPage( "Paths", "Path Settings" ) );
425 Paths_constructPreferences( page );
427 void Paths_registerPreferencesPage(){
428 PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Paths_constructPage>() );
432 class PathsDialog : public Dialog
435 GtkWindow* BuildDialog(){
436 GtkFrame* frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN );
438 GtkVBox* vbox2 = create_dialog_vbox( 0, 4 );
439 gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) );
442 PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) );
443 Paths_constructPreferences( preferencesPage );
446 return create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, GTK_WIDGET( frame ) );
450 PathsDialog g_PathsDialog;
452 bool g_strEnginePath_was_empty_1st_start = false;
454 void EnginePath_verify(){
455 if ( !file_exists( g_strEnginePath.c_str() ) || g_strEnginePath_was_empty_1st_start ) {
456 g_PathsDialog.Create();
457 g_PathsDialog.DoModal();
458 g_PathsDialog.Destroy();
464 CopiedString g_gamename;
465 CopiedString g_gamemode;
466 ModuleObservers g_gameNameObservers;
467 ModuleObservers g_gameModeObservers;
470 void Radiant_attachGameNameObserver( ModuleObserver& observer ){
471 g_gameNameObservers.attach( observer );
474 void Radiant_detachGameNameObserver( ModuleObserver& observer ){
475 g_gameNameObservers.detach( observer );
478 const char* basegame_get(){
479 return g_pGameDescription->getRequiredKeyValue( "basegame" );
482 const char* gamename_get(){
483 const char* gamename = g_gamename.c_str();
484 if ( string_empty( gamename ) ) {
485 return basegame_get();
490 void gamename_set( const char* gamename ){
491 if ( !string_equal( gamename, g_gamename.c_str() ) ) {
492 g_gameNameObservers.unrealise();
493 g_gamename = gamename;
494 g_gameNameObservers.realise();
498 void Radiant_attachGameModeObserver( ModuleObserver& observer ){
499 g_gameModeObservers.attach( observer );
502 void Radiant_detachGameModeObserver( ModuleObserver& observer ){
503 g_gameModeObservers.detach( observer );
506 const char* gamemode_get(){
507 return g_gamemode.c_str();
510 void gamemode_set( const char* gamemode ){
511 if ( !string_equal( gamemode, g_gamemode.c_str() ) ) {
512 g_gameModeObservers.unrealise();
513 g_gamemode = gamemode;
514 g_gameModeObservers.realise();
524 CLoadModule( const char* path ) : m_path( path ){
526 void operator()( const char* name ) const {
528 ASSERT_MESSAGE( strlen( m_path ) + strlen( name ) < 1024, "" );
529 strcpy( fullname, m_path );
530 strcat( fullname, name );
531 globalOutputStream() << "Found '" << fullname << "'\n";
532 GlobalModuleServer_loadModule( fullname );
536 const char* const c_library_extension =
539 #elif defined ( __APPLE__ )
541 #elif defined( __linux__ ) || defined ( __FreeBSD__ )
546 void Radiant_loadModules( const char* path ){
547 Directory_forEach( path, MatchFileExtension<CLoadModule>( c_library_extension, CLoadModule( path ) ) );
550 void Radiant_loadModulesFromRoot( const char* directory ){
552 StringOutputStream path( 256 );
553 path << directory << g_pluginsDir;
554 Radiant_loadModules( path.c_str() );
557 if ( !string_equal( g_pluginsDir, g_modulesDir ) ) {
558 StringOutputStream path( 256 );
559 path << directory << g_modulesDir;
560 Radiant_loadModules( path.c_str() );
564 //! Make COLOR_BRUSHES override worldspawn eclass colour.
565 void SetWorldspawnColour( const Vector3& colour ){
566 EntityClass* worldspawn = GlobalEntityClassManager().findOrInsert( "worldspawn", true );
567 eclass_release_state( worldspawn );
568 worldspawn->color = colour;
569 eclass_capture_state( worldspawn );
573 class WorldspawnColourEntityClassObserver : public ModuleObserver
575 std::size_t m_unrealised;
577 WorldspawnColourEntityClassObserver() : m_unrealised( 1 ){
580 if ( --m_unrealised == 0 ) {
581 SetWorldspawnColour( g_xywindow_globals.color_brushes );
585 if ( ++m_unrealised == 1 ) {
590 WorldspawnColourEntityClassObserver g_WorldspawnColourEntityClassObserver;
593 ModuleObservers g_gameToolsPathObservers;
595 void Radiant_attachGameToolsPathObserver( ModuleObserver& observer ){
596 g_gameToolsPathObservers.attach( observer );
599 void Radiant_detachGameToolsPathObserver( ModuleObserver& observer ){
600 g_gameToolsPathObservers.detach( observer );
603 void Radiant_Initialise(){
604 GlobalModuleServer_Initialise();
606 Radiant_loadModulesFromRoot( AppPath_get() );
610 bool success = Radiant_Construct( GlobalModuleServer_get() );
611 ASSERT_MESSAGE( success, "module system failed to initialise - see radiant.log for error messages" );
613 g_gameToolsPathObservers.realise();
614 g_gameModeObservers.realise();
615 g_gameNameObservers.realise();
618 void Radiant_Shutdown(){
619 g_gameNameObservers.unrealise();
620 g_gameModeObservers.unrealise();
621 g_gameToolsPathObservers.unrealise();
623 if ( !g_preferences_globals.disable_ini ) {
624 globalOutputStream() << "Start writing prefs\n";
626 globalOutputStream() << "Done prefs\n";
631 GlobalModuleServer_Shutdown();
635 if ( ConfirmModified( "Exit Radiant" ) ) {
642 GlobalUndoSystem().undo();
647 GlobalUndoSystem().redo();
651 void deleteSelection(){
652 UndoableCommand undo( "deleteSelected" );
656 void Map_ExportSelected( TextOutputStream& ostream ){
657 Map_ExportSelected( ostream, Map_getFormat( g_map ) );
660 void Map_ImportSelected( TextInputStream& istream ){
661 Map_ImportSelected( istream, Map_getFormat( g_map ) );
664 void Selection_Copy(){
665 clipboard_copy( Map_ExportSelected );
668 void Selection_Paste(){
669 clipboard_paste( Map_ImportSelected );
673 if ( SelectedFaces_empty() ) {
678 SelectedFaces_copyTexture();
683 if ( SelectedFaces_empty() ) {
684 UndoableCommand undo( "paste" );
686 GlobalSelectionSystem().setSelectedAll( false );
691 SelectedFaces_pasteTexture();
695 void PasteToCamera(){
696 CamWnd& camwnd = *g_pParentWnd->GetCamWnd();
697 GlobalSelectionSystem().setSelectedAll( false );
699 UndoableCommand undo( "pasteToCamera" );
703 // Work out the delta
705 Select_GetMid( mid );
706 Vector3 delta = vector3_subtracted( vector3_snapped( Camera_getOrigin( camwnd ), GetSnapGridSize() ), mid );
709 GlobalSelectionSystem().translateSelected( delta );
713 void ColorScheme_Original(){
714 TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), Vector3( 0.25f, 0.25f, 0.25f ) );
716 g_camwindow_globals.color_selbrushes3d = Vector3( 1.0f, 0.0f, 0.0f );
717 g_camwindow_globals.color_cameraback = Vector3( 0.25f, 0.25f, 0.25f );
718 CamWnd_Update( *g_pParentWnd->GetCamWnd() );
720 g_xywindow_globals.color_gridback = Vector3( 1.0f, 1.0f, 1.0f );
721 g_xywindow_globals.color_gridminor = Vector3( 0.75f, 0.75f, 0.75f );
722 g_xywindow_globals.color_gridmajor = Vector3( 0.5f, 0.5f, 0.5f );
723 g_xywindow_globals.color_gridblock = Vector3( 0.0f, 0.0f, 1.0f );
724 g_xywindow_globals.color_gridtext = Vector3( 0.0f, 0.0f, 0.0f );
725 g_xywindow_globals.color_selbrushes = Vector3( 1.0f, 0.0f, 0.0f );
726 g_xywindow_globals.color_clipper = Vector3( 0.0f, 0.0f, 1.0f );
727 g_xywindow_globals.color_brushes = Vector3( 0.0f, 0.0f, 0.0f );
728 SetWorldspawnColour( g_xywindow_globals.color_brushes );
729 g_xywindow_globals.color_viewname = Vector3( 0.5f, 0.0f, 0.75f );
730 XY_UpdateAllWindows();
733 void ColorScheme_QER(){
734 TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), Vector3( 0.25f, 0.25f, 0.25f ) );
736 g_camwindow_globals.color_cameraback = Vector3( 0.25f, 0.25f, 0.25f );
737 g_camwindow_globals.color_selbrushes3d = Vector3( 1.0f, 0.0f, 0.0f );
738 CamWnd_Update( *g_pParentWnd->GetCamWnd() );
740 g_xywindow_globals.color_gridback = Vector3( 1.0f, 1.0f, 1.0f );
741 g_xywindow_globals.color_gridminor = Vector3( 1.0f, 1.0f, 1.0f );
742 g_xywindow_globals.color_gridmajor = Vector3( 0.5f, 0.5f, 0.5f );
743 g_xywindow_globals.color_gridblock = Vector3( 0.0f, 0.0f, 1.0f );
744 g_xywindow_globals.color_gridtext = Vector3( 0.0f, 0.0f, 0.0f );
745 g_xywindow_globals.color_selbrushes = Vector3( 1.0f, 0.0f, 0.0f );
746 g_xywindow_globals.color_clipper = Vector3( 0.0f, 0.0f, 1.0f );
747 g_xywindow_globals.color_brushes = Vector3( 0.0f, 0.0f, 0.0f );
748 SetWorldspawnColour( g_xywindow_globals.color_brushes );
749 g_xywindow_globals.color_viewname = Vector3( 0.5f, 0.0f, 0.75f );
750 XY_UpdateAllWindows();
753 void ColorScheme_Black(){
754 TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), Vector3( 0.25f, 0.25f, 0.25f ) );
756 g_camwindow_globals.color_cameraback = Vector3( 0.25f, 0.25f, 0.25f );
757 g_camwindow_globals.color_selbrushes3d = Vector3( 1.0f, 0.0f, 0.0f );
758 CamWnd_Update( *g_pParentWnd->GetCamWnd() );
760 g_xywindow_globals.color_gridback = Vector3( 0.0f, 0.0f, 0.0f );
761 g_xywindow_globals.color_gridminor = Vector3( 0.2f, 0.2f, 0.2f );
762 g_xywindow_globals.color_gridmajor = Vector3( 0.3f, 0.5f, 0.5f );
763 g_xywindow_globals.color_gridblock = Vector3( 0.0f, 0.0f, 1.0f );
764 g_xywindow_globals.color_gridtext = Vector3( 1.0f, 1.0f, 1.0f );
765 g_xywindow_globals.color_selbrushes = Vector3( 1.0f, 0.0f, 0.0f );
766 g_xywindow_globals.color_clipper = Vector3( 0.0f, 0.0f, 1.0f );
767 g_xywindow_globals.color_brushes = Vector3( 1.0f, 1.0f, 1.0f );
768 SetWorldspawnColour( g_xywindow_globals.color_brushes );
769 g_xywindow_globals.color_viewname = Vector3( 0.7f, 0.7f, 0.0f );
770 XY_UpdateAllWindows();
773 /* ydnar: to emulate maya/max/lightwave color schemes */
774 void ColorScheme_Ydnar(){
775 TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), Vector3( 0.25f, 0.25f, 0.25f ) );
777 g_camwindow_globals.color_cameraback = Vector3( 0.25f, 0.25f, 0.25f );
778 g_camwindow_globals.color_selbrushes3d = Vector3( 1.0f, 0.0f, 0.0f );
779 CamWnd_Update( *g_pParentWnd->GetCamWnd() );
781 g_xywindow_globals.color_gridback = Vector3( 0.77f, 0.77f, 0.77f );
782 g_xywindow_globals.color_gridminor = Vector3( 0.83f, 0.83f, 0.83f );
783 g_xywindow_globals.color_gridmajor = Vector3( 0.89f, 0.89f, 0.89f );
784 g_xywindow_globals.color_gridblock = Vector3( 1.0f, 1.0f, 1.0f );
785 g_xywindow_globals.color_gridtext = Vector3( 0.0f, 0.0f, 0.0f );
786 g_xywindow_globals.color_selbrushes = Vector3( 1.0f, 0.0f, 0.0f );
787 g_xywindow_globals.color_clipper = Vector3( 0.0f, 0.0f, 1.0f );
788 g_xywindow_globals.color_brushes = Vector3( 0.0f, 0.0f, 0.0f );
789 SetWorldspawnColour( g_xywindow_globals.color_brushes );
790 g_xywindow_globals.color_viewname = Vector3( 0.5f, 0.0f, 0.75f );
791 XY_UpdateAllWindows();
794 typedef Callback1<Vector3&> GetColourCallback;
795 typedef Callback1<const Vector3&> SetColourCallback;
799 GetColourCallback m_get;
800 SetColourCallback m_set;
802 ChooseColour( const GetColourCallback& get, const SetColourCallback& set )
803 : m_get( get ), m_set( set ){
808 color_dialog( GTK_WIDGET( MainFrame_getWindow() ), colour );
815 void Colour_get( const Vector3& colour, Vector3& other ){
818 typedef ConstReferenceCaller1<Vector3, Vector3&, Colour_get> ColourGetCaller;
820 void Colour_set( Vector3& colour, const Vector3& other ){
824 typedef ReferenceCaller1<Vector3, const Vector3&, Colour_set> ColourSetCaller;
826 void BrushColour_set( const Vector3& other ){
827 g_xywindow_globals.color_brushes = other;
828 SetWorldspawnColour( g_xywindow_globals.color_brushes );
831 typedef FreeCaller1<const Vector3&, BrushColour_set> BrushColourSetCaller;
833 void ClipperColour_set( const Vector3& other ){
834 g_xywindow_globals.color_clipper = other;
835 Brush_clipperColourChanged();
838 typedef FreeCaller1<const Vector3&, ClipperColour_set> ClipperColourSetCaller;
840 void TextureBrowserColour_get( Vector3& other ){
841 other = TextureBrowser_getBackgroundColour( GlobalTextureBrowser() );
843 typedef FreeCaller1<Vector3&, TextureBrowserColour_get> TextureBrowserColourGetCaller;
845 void TextureBrowserColour_set( const Vector3& other ){
846 TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), other );
848 typedef FreeCaller1<const Vector3&, TextureBrowserColour_set> TextureBrowserColourSetCaller;
854 ChooseColour m_textureback;
855 ChooseColour m_xyback;
856 ChooseColour m_gridmajor;
857 ChooseColour m_gridminor;
858 ChooseColour m_gridtext;
859 ChooseColour m_gridblock;
860 ChooseColour m_cameraback;
861 ChooseColour m_brush;
862 ChooseColour m_selectedbrush;
863 ChooseColour m_selectedbrush3d;
864 ChooseColour m_clipper;
865 ChooseColour m_viewname;
868 m_textureback( TextureBrowserColourGetCaller(), TextureBrowserColourSetCaller() ),
869 m_xyback( ColourGetCaller( g_xywindow_globals.color_gridback ), ColourSetCaller( g_xywindow_globals.color_gridback ) ),
870 m_gridmajor( ColourGetCaller( g_xywindow_globals.color_gridmajor ), ColourSetCaller( g_xywindow_globals.color_gridmajor ) ),
871 m_gridminor( ColourGetCaller( g_xywindow_globals.color_gridminor ), ColourSetCaller( g_xywindow_globals.color_gridminor ) ),
872 m_gridtext( ColourGetCaller( g_xywindow_globals.color_gridtext ), ColourSetCaller( g_xywindow_globals.color_gridtext ) ),
873 m_gridblock( ColourGetCaller( g_xywindow_globals.color_gridblock ), ColourSetCaller( g_xywindow_globals.color_gridblock ) ),
874 m_cameraback( ColourGetCaller( g_camwindow_globals.color_cameraback ), ColourSetCaller( g_camwindow_globals.color_cameraback ) ),
875 m_brush( ColourGetCaller( g_xywindow_globals.color_brushes ), BrushColourSetCaller() ),
876 m_selectedbrush( ColourGetCaller( g_xywindow_globals.color_selbrushes ), ColourSetCaller( g_xywindow_globals.color_selbrushes ) ),
877 m_selectedbrush3d( ColourGetCaller( g_camwindow_globals.color_selbrushes3d ), ColourSetCaller( g_camwindow_globals.color_selbrushes3d ) ),
878 m_clipper( ColourGetCaller( g_xywindow_globals.color_clipper ), ClipperColourSetCaller() ),
879 m_viewname( ColourGetCaller( g_xywindow_globals.color_viewname ), ColourSetCaller( g_xywindow_globals.color_viewname ) ){
883 ColoursMenu g_ColoursMenu;
885 GtkMenuItem* create_colours_menu(){
886 GtkMenuItem* colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" );
887 GtkMenu* menu_in_menu = GTK_MENU( gtk_menu_item_get_submenu( colours_menu_item ) );
888 if ( g_Layout_enableDetachableMenus.m_value ) {
889 menu_tearoff( menu_in_menu );
892 GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Themes" );
893 if ( g_Layout_enableDetachableMenus.m_value ) {
894 menu_tearoff( menu_3 );
897 create_menu_item_with_mnemonic( menu_3, "QE4 Original", "ColorSchemeOriginal" );
898 create_menu_item_with_mnemonic( menu_3, "Q3Radiant Original", "ColorSchemeQER" );
899 create_menu_item_with_mnemonic( menu_3, "Black and Green", "ColorSchemeBlackAndGreen" );
900 create_menu_item_with_mnemonic( menu_3, "Maya/Max/Lightwave Emulation", "ColorSchemeYdnar" );
902 create_menu_item_with_mnemonic( menu_in_menu, "GTK Theme...", "gtkThemeDlg" );
904 menu_separator( menu_in_menu );
906 create_menu_item_with_mnemonic( menu_in_menu, "_Texture Background...", "ChooseTextureBackgroundColor" );
907 create_menu_item_with_mnemonic( menu_in_menu, "Camera Background...", "ChooseCameraBackgroundColor" );
908 create_menu_item_with_mnemonic( menu_in_menu, "Grid Background...", "ChooseGridBackgroundColor" );
909 create_menu_item_with_mnemonic( menu_in_menu, "Grid Major...", "ChooseGridMajorColor" );
910 create_menu_item_with_mnemonic( menu_in_menu, "Grid Minor...", "ChooseGridMinorColor" );
911 create_menu_item_with_mnemonic( menu_in_menu, "Grid Text...", "ChooseGridTextColor" );
912 create_menu_item_with_mnemonic( menu_in_menu, "Grid Block...", "ChooseGridBlockColor" );
913 create_menu_item_with_mnemonic( menu_in_menu, "Default Brush (2D)...", "ChooseBrushColor" );
914 create_menu_item_with_mnemonic( menu_in_menu, "Selected Brush and Sizing (2D)...", "ChooseSelectedBrushColor" );
915 create_menu_item_with_mnemonic( menu_in_menu, "Selected Brush (Camera)...", "ChooseCameraSelectedBrushColor" );
916 create_menu_item_with_mnemonic( menu_in_menu, "Clipper...", "ChooseClipperColor" );
917 create_menu_item_with_mnemonic( menu_in_menu, "Active View Name and Outline...", "ChooseOrthoViewNameColor" );
919 return colours_menu_item;
925 PluginToolbar_clear();
928 Radiant_Initialise();
930 PluginsMenu_populate();
932 PluginToolbar_populate();
936 void thunk_OnSleep(){
937 g_pParentWnd->OnSleep();
940 void OpenUpdateURL(){
942 StringOutputStream URL( 256 );
943 URL << "http://www.icculus.org/netradiant/?cmd=update&data=dlupdate&query_dlup=1";
946 #elif defined( __APPLE__ )
951 URL << "&Version_dlup=" RADIANT_VERSION;
952 g_GamesDialog.AddPacksURL( URL );
953 OpenURL( URL.c_str() );
956 // open the Q3Rad manual
958 // at least on win32, AppPath + "docs/index.html"
959 StringOutputStream help( 256 );
960 help << AppPath_get() << "docs/index.html";
961 OpenURL( help.c_str() );
964 void OpenBugReportURL(){
965 OpenURL( "http://www.icculus.org/netradiant/?cmd=bugs" );
969 GtkWidget* g_page_console;
971 void Console_ToggleShow(){
972 GroupDialog_showPage( g_page_console );
975 GtkWidget* g_page_entity;
977 void EntityInspector_ToggleShow(){
978 GroupDialog_showPage( g_page_entity );
983 void SetClipMode( bool enable );
984 void ModeChangeNotify();
986 typedef void ( *ToolMode )();
987 ToolMode g_currentToolMode = 0;
988 bool g_currentToolModeSupportsComponentEditing = false;
989 ToolMode g_defaultToolMode = 0;
993 void SelectionSystem_DefaultMode(){
994 GlobalSelectionSystem().SetMode( SelectionSystem::ePrimitive );
995 GlobalSelectionSystem().SetComponentMode( SelectionSystem::eDefault );
1001 return GlobalSelectionSystem().Mode() == SelectionSystem::eComponent
1002 && GlobalSelectionSystem().ComponentMode() == SelectionSystem::eEdge;
1006 return GlobalSelectionSystem().Mode() == SelectionSystem::eComponent
1007 && GlobalSelectionSystem().ComponentMode() == SelectionSystem::eVertex;
1011 return GlobalSelectionSystem().Mode() == SelectionSystem::eComponent
1012 && GlobalSelectionSystem().ComponentMode() == SelectionSystem::eFace;
1015 template<bool( *BoolFunction ) ( )>
1016 class BoolFunctionExport
1019 static void apply( const BoolImportCallback& importCallback ){
1020 importCallback( BoolFunction() );
1024 typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<EdgeMode>::apply> EdgeModeApplyCaller;
1025 EdgeModeApplyCaller g_edgeMode_button_caller;
1026 BoolExportCallback g_edgeMode_button_callback( g_edgeMode_button_caller );
1027 ToggleItem g_edgeMode_button( g_edgeMode_button_callback );
1029 typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<VertexMode>::apply> VertexModeApplyCaller;
1030 VertexModeApplyCaller g_vertexMode_button_caller;
1031 BoolExportCallback g_vertexMode_button_callback( g_vertexMode_button_caller );
1032 ToggleItem g_vertexMode_button( g_vertexMode_button_callback );
1034 typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<FaceMode>::apply> FaceModeApplyCaller;
1035 FaceModeApplyCaller g_faceMode_button_caller;
1036 BoolExportCallback g_faceMode_button_callback( g_faceMode_button_caller );
1037 ToggleItem g_faceMode_button( g_faceMode_button_callback );
1039 void ComponentModeChanged(){
1040 g_edgeMode_button.update();
1041 g_vertexMode_button.update();
1042 g_faceMode_button.update();
1045 void ComponentMode_SelectionChanged( const Selectable& selectable ){
1046 if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent
1047 && GlobalSelectionSystem().countSelected() == 0 ) {
1048 SelectionSystem_DefaultMode();
1049 ComponentModeChanged();
1053 void SelectEdgeMode(){
1055 if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) {
1056 GlobalSelectionSystem().Select( false );
1061 SelectionSystem_DefaultMode();
1063 else if ( GlobalSelectionSystem().countSelected() != 0 ) {
1064 if ( !g_currentToolModeSupportsComponentEditing ) {
1065 g_defaultToolMode();
1068 GlobalSelectionSystem().SetMode( SelectionSystem::eComponent );
1069 GlobalSelectionSystem().SetComponentMode( SelectionSystem::eEdge );
1072 ComponentModeChanged();
1077 void SelectVertexMode(){
1079 if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) {
1080 GlobalSelectionSystem().Select( false );
1084 if ( VertexMode() ) {
1085 SelectionSystem_DefaultMode();
1087 else if ( GlobalSelectionSystem().countSelected() != 0 ) {
1088 if ( !g_currentToolModeSupportsComponentEditing ) {
1089 g_defaultToolMode();
1092 GlobalSelectionSystem().SetMode( SelectionSystem::eComponent );
1093 GlobalSelectionSystem().SetComponentMode( SelectionSystem::eVertex );
1096 ComponentModeChanged();
1101 void SelectFaceMode(){
1103 if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) {
1104 GlobalSelectionSystem().Select( false );
1109 SelectionSystem_DefaultMode();
1111 else if ( GlobalSelectionSystem().countSelected() != 0 ) {
1112 if ( !g_currentToolModeSupportsComponentEditing ) {
1113 g_defaultToolMode();
1116 GlobalSelectionSystem().SetMode( SelectionSystem::eComponent );
1117 GlobalSelectionSystem().SetComponentMode( SelectionSystem::eFace );
1120 ComponentModeChanged();
1126 class CloneSelected : public scene::Graph::Walker
1129 NodeSmartReference worldspawn;
1131 CloneSelected( bool d ) : doMakeUnique( d ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
1133 bool pre( const scene::Path& path, scene::Instance& instance ) const {
1134 if ( path.size() == 1 ) {
1138 // ignore worldspawn, but keep checking children
1139 NodeSmartReference me( path.top().get() );
1140 if ( me == worldspawn ) {
1144 if ( !path.top().get().isRoot() ) {
1145 Selectable* selectable = Instance_getSelectable( instance );
1146 if ( selectable != 0
1147 && selectable->isSelected() ) {
1154 void post( const scene::Path& path, scene::Instance& instance ) const {
1155 if ( path.size() == 1 ) {
1159 // ignore worldspawn, but keep checking children
1160 NodeSmartReference me( path.top().get() );
1161 if ( me == worldspawn ) {
1165 if ( !path.top().get().isRoot() ) {
1166 Selectable* selectable = Instance_getSelectable( instance );
1167 if ( selectable != 0
1168 && selectable->isSelected() ) {
1169 NodeSmartReference clone( Node_Clone( path.top() ) );
1170 if ( doMakeUnique ) {
1171 Map_gatherNamespaced( clone );
1173 Node_getTraversable( path.parent().get() )->insert( clone );
1179 void Scene_Clone_Selected( scene::Graph& graph, bool doMakeUnique ){
1180 graph.traverse( CloneSelected( doMakeUnique ) );
1182 Map_mergeClonedNames();
1185 enum ENudgeDirection
1198 AxisBase( const Vector3& x_, const Vector3& y_, const Vector3& z_ )
1199 : x( x_ ), y( y_ ), z( z_ ){
1203 AxisBase AxisBase_forViewType( VIEWTYPE viewtype ){
1207 return AxisBase( g_vector3_axis_x, g_vector3_axis_y, g_vector3_axis_z );
1209 return AxisBase( g_vector3_axis_x, g_vector3_axis_z, g_vector3_axis_y );
1211 return AxisBase( g_vector3_axis_y, g_vector3_axis_z, g_vector3_axis_x );
1214 ERROR_MESSAGE( "invalid viewtype" );
1215 return AxisBase( Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ) );
1218 Vector3 AxisBase_axisForDirection( const AxisBase& axes, ENudgeDirection direction ){
1219 switch ( direction )
1222 return vector3_negated( axes.x );
1228 return vector3_negated( axes.y );
1231 ERROR_MESSAGE( "invalid direction" );
1232 return Vector3( 0, 0, 0 );
1235 bool g_bNudgeAfterClone = false;
1237 void Nudge_constructPreferences( PreferencesPage& page ){
1238 page.appendCheckBox( "", "Nudge selected after duplication", g_bNudgeAfterClone );
1241 void NudgeSelection( ENudgeDirection direction, float fAmount, VIEWTYPE viewtype ){
1242 AxisBase axes( AxisBase_forViewType( viewtype ) );
1243 Vector3 view_direction( vector3_negated( axes.z ) );
1244 Vector3 nudge( vector3_scaled( AxisBase_axisForDirection( axes, direction ), fAmount ) );
1245 GlobalSelectionSystem().NudgeManipulator( nudge, view_direction );
1248 void Selection_Clone(){
1249 if ( GlobalSelectionSystem().Mode() == SelectionSystem::ePrimitive ) {
1250 UndoableCommand undo( "cloneSelected" );
1252 Scene_Clone_Selected( GlobalSceneGraph(), false );
1254 if( g_bNudgeAfterClone ){
1255 NudgeSelection(eNudgeRight, GetGridSize(), GlobalXYWnd_getCurrentViewType());
1256 NudgeSelection(eNudgeDown, GetGridSize(), GlobalXYWnd_getCurrentViewType());
1261 void Selection_Clone_MakeUnique(){
1262 if ( GlobalSelectionSystem().Mode() == SelectionSystem::ePrimitive ) {
1263 UndoableCommand undo( "cloneSelectedMakeUnique" );
1265 Scene_Clone_Selected( GlobalSceneGraph(), true );
1267 if( g_bNudgeAfterClone ){
1268 NudgeSelection(eNudgeRight, GetGridSize(), GlobalXYWnd_getCurrentViewType());
1269 NudgeSelection(eNudgeDown, GetGridSize(), GlobalXYWnd_getCurrentViewType());
1274 // called when the escape key is used (either on the main window or on an inspector)
1275 void Selection_Deselect(){
1276 if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) {
1277 if ( GlobalSelectionSystem().countSelectedComponents() != 0 ) {
1278 GlobalSelectionSystem().setSelectedAllComponents( false );
1282 SelectionSystem_DefaultMode();
1283 ComponentModeChanged();
1288 if ( GlobalSelectionSystem().countSelectedComponents() != 0 ) {
1289 GlobalSelectionSystem().setSelectedAllComponents( false );
1293 GlobalSelectionSystem().setSelectedAll( false );
1299 void Selection_NudgeUp(){
1300 UndoableCommand undo( "nudgeSelectedUp" );
1301 NudgeSelection( eNudgeUp, GetGridSize(), GlobalXYWnd_getCurrentViewType() );
1304 void Selection_NudgeDown(){
1305 UndoableCommand undo( "nudgeSelectedDown" );
1306 NudgeSelection( eNudgeDown, GetGridSize(), GlobalXYWnd_getCurrentViewType() );
1309 void Selection_NudgeLeft(){
1310 UndoableCommand undo( "nudgeSelectedLeft" );
1311 NudgeSelection( eNudgeLeft, GetGridSize(), GlobalXYWnd_getCurrentViewType() );
1314 void Selection_NudgeRight(){
1315 UndoableCommand undo( "nudgeSelectedRight" );
1316 NudgeSelection( eNudgeRight, GetGridSize(), GlobalXYWnd_getCurrentViewType() );
1320 void TranslateToolExport( const BoolImportCallback& importCallback ){
1321 importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eTranslate );
1324 void RotateToolExport( const BoolImportCallback& importCallback ){
1325 importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eRotate );
1328 void ScaleToolExport( const BoolImportCallback& importCallback ){
1329 importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eScale );
1332 void DragToolExport( const BoolImportCallback& importCallback ){
1333 importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eDrag );
1336 void ClipperToolExport( const BoolImportCallback& importCallback ){
1337 importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eClip );
1340 FreeCaller1<const BoolImportCallback&, TranslateToolExport> g_translatemode_button_caller;
1341 BoolExportCallback g_translatemode_button_callback( g_translatemode_button_caller );
1342 ToggleItem g_translatemode_button( g_translatemode_button_callback );
1344 FreeCaller1<const BoolImportCallback&, RotateToolExport> g_rotatemode_button_caller;
1345 BoolExportCallback g_rotatemode_button_callback( g_rotatemode_button_caller );
1346 ToggleItem g_rotatemode_button( g_rotatemode_button_callback );
1348 FreeCaller1<const BoolImportCallback&, ScaleToolExport> g_scalemode_button_caller;
1349 BoolExportCallback g_scalemode_button_callback( g_scalemode_button_caller );
1350 ToggleItem g_scalemode_button( g_scalemode_button_callback );
1352 FreeCaller1<const BoolImportCallback&, DragToolExport> g_dragmode_button_caller;
1353 BoolExportCallback g_dragmode_button_callback( g_dragmode_button_caller );
1354 ToggleItem g_dragmode_button( g_dragmode_button_callback );
1356 FreeCaller1<const BoolImportCallback&, ClipperToolExport> g_clipper_button_caller;
1357 BoolExportCallback g_clipper_button_callback( g_clipper_button_caller );
1358 ToggleItem g_clipper_button( g_clipper_button_callback );
1361 g_translatemode_button.update();
1362 g_rotatemode_button.update();
1363 g_scalemode_button.update();
1364 g_dragmode_button.update();
1365 g_clipper_button.update();
1368 const char* const c_ResizeMode_status = "QE4 Drag Tool: move and resize objects";
1371 if ( g_currentToolMode == DragMode && g_defaultToolMode != DragMode ) {
1372 g_defaultToolMode();
1376 g_currentToolMode = DragMode;
1377 g_currentToolModeSupportsComponentEditing = true;
1379 OnClipMode( false );
1381 Sys_Status( c_ResizeMode_status );
1382 GlobalSelectionSystem().SetManipulatorMode( SelectionSystem::eDrag );
1389 const char* const c_TranslateMode_status = "Translate Tool: translate objects and components";
1391 void TranslateMode(){
1392 if ( g_currentToolMode == TranslateMode && g_defaultToolMode != TranslateMode ) {
1393 g_defaultToolMode();
1397 g_currentToolMode = TranslateMode;
1398 g_currentToolModeSupportsComponentEditing = true;
1400 OnClipMode( false );
1402 Sys_Status( c_TranslateMode_status );
1403 GlobalSelectionSystem().SetManipulatorMode( SelectionSystem::eTranslate );
1409 const char* const c_RotateMode_status = "Rotate Tool: rotate objects and components";
1412 if ( g_currentToolMode == RotateMode && g_defaultToolMode != RotateMode ) {
1413 g_defaultToolMode();
1417 g_currentToolMode = RotateMode;
1418 g_currentToolModeSupportsComponentEditing = true;
1420 OnClipMode( false );
1422 Sys_Status( c_RotateMode_status );
1423 GlobalSelectionSystem().SetManipulatorMode( SelectionSystem::eRotate );
1429 const char* const c_ScaleMode_status = "Scale Tool: scale objects and components";
1432 if ( g_currentToolMode == ScaleMode && g_defaultToolMode != ScaleMode ) {
1433 g_defaultToolMode();
1437 g_currentToolMode = ScaleMode;
1438 g_currentToolModeSupportsComponentEditing = true;
1440 OnClipMode( false );
1442 Sys_Status( c_ScaleMode_status );
1443 GlobalSelectionSystem().SetManipulatorMode( SelectionSystem::eScale );
1450 const char* const c_ClipperMode_status = "Clipper Tool: apply clip planes to objects";
1454 if ( g_currentToolMode == ClipperMode && g_defaultToolMode != ClipperMode ) {
1455 g_defaultToolMode();
1459 g_currentToolMode = ClipperMode;
1460 g_currentToolModeSupportsComponentEditing = false;
1462 SelectionSystem_DefaultMode();
1466 Sys_Status( c_ClipperMode_status );
1467 GlobalSelectionSystem().SetManipulatorMode( SelectionSystem::eClip );
1474 void ToggleRotateScaleModes(){
1475 if ( g_currentToolMode == RotateMode ) {
1484 void ToggleDragScaleModes(){
1485 if ( g_currentToolMode == DragMode ) {
1495 void Texdef_Rotate( float angle ){
1496 StringOutputStream command;
1497 command << "brushRotateTexture -angle " << angle;
1498 UndoableCommand undo( command.c_str() );
1499 Select_RotateTexture( angle );
1502 void Texdef_RotateClockwise(){
1503 Texdef_Rotate( static_cast<float>( fabs( g_si_globals.rotate ) ) );
1506 void Texdef_RotateAntiClockwise(){
1507 Texdef_Rotate( static_cast<float>( -fabs( g_si_globals.rotate ) ) );
1510 void Texdef_Scale( float x, float y ){
1511 StringOutputStream command;
1512 command << "brushScaleTexture -x " << x << " -y " << y;
1513 UndoableCommand undo( command.c_str() );
1514 Select_ScaleTexture( x, y );
1517 void Texdef_ScaleUp(){
1518 Texdef_Scale( 0, g_si_globals.scale[1] );
1521 void Texdef_ScaleDown(){
1522 Texdef_Scale( 0, -g_si_globals.scale[1] );
1525 void Texdef_ScaleLeft(){
1526 Texdef_Scale( -g_si_globals.scale[0],0 );
1529 void Texdef_ScaleRight(){
1530 Texdef_Scale( g_si_globals.scale[0],0 );
1533 void Texdef_Shift( float x, float y ){
1534 StringOutputStream command;
1535 command << "brushShiftTexture -x " << x << " -y " << y;
1536 UndoableCommand undo( command.c_str() );
1537 Select_ShiftTexture( x, y );
1540 void Texdef_ShiftLeft(){
1541 Texdef_Shift( -g_si_globals.shift[0], 0 );
1544 void Texdef_ShiftRight(){
1545 Texdef_Shift( g_si_globals.shift[0], 0 );
1548 void Texdef_ShiftUp(){
1549 Texdef_Shift( 0, g_si_globals.shift[1] );
1552 void Texdef_ShiftDown(){
1553 Texdef_Shift( 0, -g_si_globals.shift[1] );
1558 class SnappableSnapToGridSelected : public scene::Graph::Walker
1562 SnappableSnapToGridSelected( float snap )
1565 bool pre( const scene::Path& path, scene::Instance& instance ) const {
1566 if ( path.top().get().visible() ) {
1567 Snappable* snappable = Node_getSnappable( path.top() );
1569 && Instance_getSelectable( instance )->isSelected() ) {
1570 snappable->snapto( m_snap );
1577 void Scene_SnapToGrid_Selected( scene::Graph& graph, float snap ){
1578 graph.traverse( SnappableSnapToGridSelected( snap ) );
1581 class ComponentSnappableSnapToGridSelected : public scene::Graph::Walker
1585 ComponentSnappableSnapToGridSelected( float snap )
1588 bool pre( const scene::Path& path, scene::Instance& instance ) const {
1589 if ( path.top().get().visible() ) {
1590 ComponentSnappable* componentSnappable = Instance_getComponentSnappable( instance );
1591 if ( componentSnappable != 0
1592 && Instance_getSelectable( instance )->isSelected() ) {
1593 componentSnappable->snapComponents( m_snap );
1600 void Scene_SnapToGrid_Component_Selected( scene::Graph& graph, float snap ){
1601 graph.traverse( ComponentSnappableSnapToGridSelected( snap ) );
1604 void Selection_SnapToGrid(){
1605 StringOutputStream command;
1606 command << "snapSelected -grid " << GetGridSize();
1607 UndoableCommand undo( command.c_str() );
1609 if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) {
1610 Scene_SnapToGrid_Component_Selected( GlobalSceneGraph(), GetGridSize() );
1614 Scene_SnapToGrid_Selected( GlobalSceneGraph(), GetGridSize() );
1619 static gint qe_every_second( gpointer data ){
1620 GdkModifierType mask;
1622 gdk_window_get_pointer( 0, 0, 0, &mask );
1624 if ( ( mask & ( GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK ) ) == 0 ) {
1631 guint s_qe_every_second_id = 0;
1633 void EverySecondTimer_enable(){
1634 if ( s_qe_every_second_id == 0 ) {
1635 s_qe_every_second_id = gtk_timeout_add( 1000, qe_every_second, 0 );
1639 void EverySecondTimer_disable(){
1640 if ( s_qe_every_second_id != 0 ) {
1641 gtk_timeout_remove( s_qe_every_second_id );
1642 s_qe_every_second_id = 0;
1646 gint window_realize_remove_decoration( GtkWidget* widget, gpointer data ){
1647 gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) );
1654 GtkWindow* m_window;
1658 WaitDialog create_wait_dialog( const char* title, const char* text ){
1661 dialog.m_window = create_floating_window( title, MainFrame_getWindow() );
1662 gtk_window_set_resizable( dialog.m_window, FALSE );
1663 gtk_container_set_border_width( GTK_CONTAINER( dialog.m_window ), 0 );
1664 gtk_window_set_position( dialog.m_window, GTK_WIN_POS_CENTER_ON_PARENT );
1666 g_signal_connect( G_OBJECT( dialog.m_window ), "realize", G_CALLBACK( window_realize_remove_decoration ), 0 );
1669 dialog.m_label = GTK_LABEL( gtk_label_new( text ) );
1670 gtk_misc_set_alignment( GTK_MISC( dialog.m_label ), 0.0, 0.5 );
1671 gtk_label_set_justify( dialog.m_label, GTK_JUSTIFY_LEFT );
1672 gtk_widget_show( GTK_WIDGET( dialog.m_label ) );
1673 gtk_widget_set_size_request( GTK_WIDGET( dialog.m_label ), 200, -1 );
1675 gtk_container_add( GTK_CONTAINER( dialog.m_window ), GTK_WIDGET( dialog.m_label ) );
1682 clock_t g_lastRedrawTime = 0;
1683 const clock_t c_redrawInterval = clock_t( CLOCKS_PER_SEC / 10 );
1685 bool redrawRequired(){
1686 clock_t currentTime = std::clock();
1687 if ( currentTime - g_lastRedrawTime >= c_redrawInterval ) {
1688 g_lastRedrawTime = currentTime;
1695 bool MainFrame_isActiveApp(){
1696 //globalOutputStream() << "listing\n";
1697 GList* list = gtk_window_list_toplevels();
1698 for ( GList* i = list; i != 0; i = g_list_next( i ) )
1700 //globalOutputStream() << "toplevel.. ";
1701 if ( gtk_window_is_active( GTK_WINDOW( i->data ) ) ) {
1702 //globalOutputStream() << "is active\n";
1705 //globalOutputStream() << "not active\n";
1710 typedef std::list<CopiedString> StringStack;
1711 StringStack g_wait_stack;
1714 bool ScreenUpdates_Enabled(){
1715 return g_wait_stack.empty();
1718 void ScreenUpdates_process(){
1719 if ( redrawRequired() && GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
1725 void ScreenUpdates_Disable( const char* message, const char* title ){
1726 if ( g_wait_stack.empty() ) {
1727 EverySecondTimer_disable();
1731 bool isActiveApp = MainFrame_isActiveApp();
1733 g_wait = create_wait_dialog( title, message );
1734 gtk_grab_add( GTK_WIDGET( g_wait.m_window ) );
1736 if ( isActiveApp ) {
1737 gtk_widget_show( GTK_WIDGET( g_wait.m_window ) );
1738 ScreenUpdates_process();
1741 else if ( GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
1742 gtk_label_set_text( g_wait.m_label, message );
1743 ScreenUpdates_process();
1745 g_wait_stack.push_back( message );
1748 void ScreenUpdates_Enable(){
1749 ASSERT_MESSAGE( !ScreenUpdates_Enabled(), "screen updates already enabled" );
1750 g_wait_stack.pop_back();
1751 if ( g_wait_stack.empty() ) {
1752 EverySecondTimer_enable();
1753 //gtk_widget_set_sensitive(GTK_WIDGET(MainFrame_getWindow()), TRUE);
1755 gtk_grab_remove( GTK_WIDGET( g_wait.m_window ) );
1756 destroy_floating_window( g_wait.m_window );
1757 g_wait.m_window = 0;
1759 //gtk_window_present(MainFrame_getWindow());
1761 else if ( GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
1762 gtk_label_set_text( g_wait.m_label, g_wait_stack.back().c_str() );
1763 ScreenUpdates_process();
1769 void GlobalCamera_UpdateWindow(){
1770 if ( g_pParentWnd != 0 ) {
1771 CamWnd_Update( *g_pParentWnd->GetCamWnd() );
1775 void XY_UpdateWindow( MainFrame& mainframe ){
1776 if ( mainframe.GetXYWnd() != 0 ) {
1777 XYWnd_Update( *mainframe.GetXYWnd() );
1781 void XZ_UpdateWindow( MainFrame& mainframe ){
1782 if ( mainframe.GetXZWnd() != 0 ) {
1783 XYWnd_Update( *mainframe.GetXZWnd() );
1787 void YZ_UpdateWindow( MainFrame& mainframe ){
1788 if ( mainframe.GetYZWnd() != 0 ) {
1789 XYWnd_Update( *mainframe.GetYZWnd() );
1793 void XY_UpdateAllWindows( MainFrame& mainframe ){
1794 XY_UpdateWindow( mainframe );
1795 XZ_UpdateWindow( mainframe );
1796 YZ_UpdateWindow( mainframe );
1799 void XY_UpdateAllWindows(){
1800 if ( g_pParentWnd != 0 ) {
1801 XY_UpdateAllWindows( *g_pParentWnd );
1805 void UpdateAllWindows(){
1806 GlobalCamera_UpdateWindow();
1807 XY_UpdateAllWindows();
1811 void ModeChangeNotify(){
1812 SceneChangeNotify();
1815 void ClipperChangeNotify(){
1816 GlobalCamera_UpdateWindow();
1817 XY_UpdateAllWindows();
1821 LatchedInt g_Layout_viewStyle( 0, "Window Layout" );
1822 LatchedBool g_Layout_enableDetachableMenus( true, "Detachable Menus" );
1823 LatchedBool g_Layout_enableMainToolbar( true, "Main Toolbar" );
1824 LatchedBool g_Layout_enablePatchToolbar( true, "Patch Toolbar" );
1825 LatchedBool g_Layout_enablePluginToolbar( true, "Plugin Toolbar" );
1826 LatchedBool g_Layout_enableFilterToolbar( true, "Filter Toolbar" );
1830 GtkMenuItem* create_file_menu(){
1832 GtkMenuItem* file_menu_item = new_sub_menu_item_with_mnemonic( "_File" );
1833 GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( file_menu_item ) );
1834 if ( g_Layout_enableDetachableMenus.m_value ) {
1835 menu_tearoff( menu );
1838 create_menu_item_with_mnemonic( menu, "_New Map", "NewMap" );
1839 menu_separator( menu );
1842 //++timo temporary experimental stuff for sleep mode..
1843 create_menu_item_with_mnemonic( menu, "_Sleep", "Sleep" );
1844 menu_separator( menu );
1848 create_menu_item_with_mnemonic( menu, "_Open...", "OpenMap" );
1849 create_menu_item_with_mnemonic( menu, "_Import...", "ImportMap" );
1850 menu_separator( menu );
1851 create_menu_item_with_mnemonic( menu, "_Save", "SaveMap" );
1852 create_menu_item_with_mnemonic( menu, "Save _as...", "SaveMapAs" );
1853 create_menu_item_with_mnemonic( menu, "Save s_elected...", "SaveSelected" );
1854 create_menu_item_with_mnemonic( menu, "Save re_gion...", "SaveRegion" );
1855 menu_separator( menu );
1856 // menu_separator( menu );
1857 // create_menu_item_with_mnemonic( menu, "_Refresh models", "RefreshReferences" );
1858 // menu_separator( menu );
1859 create_menu_item_with_mnemonic( menu, "Pro_ject settings...", "ProjectSettings" );
1860 //menu_separator( menu );
1861 create_menu_item_with_mnemonic( menu, "_Pointfile", "TogglePointfile" );
1862 menu_separator( menu );
1863 MRU_constructMenu( menu );
1864 menu_separator( menu );
1865 // create_menu_item_with_mnemonic( menu, "Check for NetRadiant update (web)", "CheckForUpdate" ); // FIXME
1866 create_menu_item_with_mnemonic( menu, "E_xit", "Exit" );
1868 return file_menu_item;
1871 GtkMenuItem* create_edit_menu(){
1873 GtkMenuItem* edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" );
1874 GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( edit_menu_item ) );
1875 if ( g_Layout_enableDetachableMenus.m_value ) {
1876 menu_tearoff( menu );
1878 create_menu_item_with_mnemonic( menu, "_Undo", "Undo" );
1879 create_menu_item_with_mnemonic( menu, "_Redo", "Redo" );
1880 menu_separator( menu );
1881 create_menu_item_with_mnemonic( menu, "_Copy", "Copy" );
1882 create_menu_item_with_mnemonic( menu, "_Paste", "Paste" );
1883 create_menu_item_with_mnemonic( menu, "P_aste To Camera", "PasteToCamera" );
1884 menu_separator( menu );
1885 create_menu_item_with_mnemonic( menu, "_Duplicate", "CloneSelection" );
1886 create_menu_item_with_mnemonic( menu, "Duplicate, make uni_que", "CloneSelectionAndMakeUnique" );
1887 create_menu_item_with_mnemonic( menu, "D_elete", "DeleteSelection" );
1888 //create_menu_item_with_mnemonic( menu, "Pa_rent", "ParentSelection" );
1889 menu_separator( menu );
1890 create_menu_item_with_mnemonic( menu, "C_lear Selection", "UnSelectSelection" );
1891 create_menu_item_with_mnemonic( menu, "_Invert Selection", "InvertSelection" );
1892 create_menu_item_with_mnemonic( menu, "Select i_nside", "SelectInside" );
1893 create_menu_item_with_mnemonic( menu, "Select _touching", "SelectTouching" );
1895 menu_separator( menu );
1897 // GtkMenu* convert_menu = create_sub_menu_with_mnemonic( menu, "E_xpand Selection" );
1898 // if ( g_Layout_enableDetachableMenus.m_value ) {
1899 // menu_tearoff( convert_menu );
1901 create_menu_item_with_mnemonic( menu, "Select All Of Type", "SelectAllOfType" );
1902 create_menu_item_with_mnemonic( menu, "_Expand Selection To Entities", "ExpandSelectionToEntities" );
1904 menu_separator( menu );
1905 create_menu_item_with_mnemonic( menu, "Pre_ferences...", "Preferences" );
1907 return edit_menu_item;
1911 GtkWidget* g_toggle_z_item = 0;
1912 GtkWidget* g_toggle_console_item = 0;
1913 GtkWidget* g_toggle_entity_item = 0;
1914 GtkWidget* g_toggle_entitylist_item = 0;
1916 GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){
1918 GtkMenuItem* view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" );
1919 GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( view_menu_item ) );
1920 if ( g_Layout_enableDetachableMenus.m_value ) {
1921 menu_tearoff( menu );
1924 if ( style == MainFrame::eFloating ) {
1925 create_check_menu_item_with_mnemonic( menu, "Camera View", "ToggleCamera" );
1926 create_check_menu_item_with_mnemonic( menu, "XY (Top) View", "ToggleView" );
1927 create_check_menu_item_with_mnemonic( menu, "XZ (Front) View", "ToggleFrontView" );
1928 create_check_menu_item_with_mnemonic( menu, "YZ (Side) View", "ToggleSideView" );
1930 if ( style == MainFrame::eFloating || style == MainFrame::eSplit ) {
1931 create_menu_item_with_mnemonic( menu, "Console", "ToggleConsole" );
1932 create_menu_item_with_mnemonic( menu, "Texture Browser", "ToggleTextures" );
1933 create_menu_item_with_mnemonic( menu, "Entity Inspector", "ToggleEntityInspector" );
1937 create_menu_item_with_mnemonic( menu, "Entity Inspector", "ViewEntityInfo" );
1939 create_menu_item_with_mnemonic( menu, "_Surface Inspector", "SurfaceInspector" );
1940 create_menu_item_with_mnemonic( menu, "_Patch Inspector", "PatchInspector" );
1941 create_menu_item_with_mnemonic( menu, "Entity List", "EntityList" );
1943 menu_separator( menu );
1945 GtkMenu* camera_menu = create_sub_menu_with_mnemonic( menu, "Camera" );
1946 if ( g_Layout_enableDetachableMenus.m_value ) {
1947 menu_tearoff( camera_menu );
1949 create_menu_item_with_mnemonic( camera_menu, "Focus on Selected", "CameraFocusOnSelected" );
1950 create_menu_item_with_mnemonic( camera_menu, "_Center", "CenterView" );
1951 create_menu_item_with_mnemonic( camera_menu, "_Up Floor", "UpFloor" );
1952 create_menu_item_with_mnemonic( camera_menu, "_Down Floor", "DownFloor" );
1953 menu_separator( camera_menu );
1954 create_menu_item_with_mnemonic( camera_menu, "Far Clip Plane In", "CubicClipZoomIn" );
1955 create_menu_item_with_mnemonic( camera_menu, "Far Clip Plane Out", "CubicClipZoomOut" );
1956 menu_separator( camera_menu );
1957 create_menu_item_with_mnemonic( camera_menu, "Next leak spot", "NextLeakSpot" );
1958 create_menu_item_with_mnemonic( camera_menu, "Previous leak spot", "PrevLeakSpot" );
1959 //cameramodel is not implemented in instances, thus useless
1960 // menu_separator( camera_menu );
1961 // create_menu_item_with_mnemonic( camera_menu, "Look Through Selected", "LookThroughSelected" );
1962 // create_menu_item_with_mnemonic( camera_menu, "Look Through Camera", "LookThroughCamera" );
1964 menu_separator( menu );
1966 GtkMenu* orthographic_menu = create_sub_menu_with_mnemonic( menu, "Orthographic" );
1967 if ( g_Layout_enableDetachableMenus.m_value ) {
1968 menu_tearoff( orthographic_menu );
1970 if ( style == MainFrame::eRegular || style == MainFrame::eRegularLeft || style == MainFrame::eFloating ) {
1971 create_menu_item_with_mnemonic( orthographic_menu, "_Next (XY, YZ, XY)", "NextView" );
1972 create_menu_item_with_mnemonic( orthographic_menu, "XY (Top)", "ViewTop" );
1973 create_menu_item_with_mnemonic( orthographic_menu, "XZ (Front)", "ViewFront" );
1974 create_menu_item_with_mnemonic( orthographic_menu, "YZ (Side)", "ViewSide" );
1975 menu_separator( orthographic_menu );
1978 create_menu_item_with_mnemonic( orthographic_menu, "Center on Selected", "NextView" );
1981 create_menu_item_with_mnemonic( orthographic_menu, "Center on Selected", "CenterXYView" );
1982 menu_separator( orthographic_menu );
1983 create_menu_item_with_mnemonic( orthographic_menu, "_XY 100%", "Zoom100" );
1984 create_menu_item_with_mnemonic( orthographic_menu, "XY Zoom _In", "ZoomIn" );
1985 create_menu_item_with_mnemonic( orthographic_menu, "XY Zoom _Out", "ZoomOut" );
1988 menu_separator( menu );
1991 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Show" );
1992 if ( g_Layout_enableDetachableMenus.m_value ) {
1993 menu_tearoff( menu_in_menu );
1995 create_check_menu_item_with_mnemonic( menu_in_menu, "Show Entity _Angles", "ShowAngles" );
1996 create_check_menu_item_with_mnemonic( menu_in_menu, "Show Entity _Names", "ShowNames" );
1997 create_check_menu_item_with_mnemonic( menu_in_menu, "Show Light Radiuses", "ShowLightRadiuses" );
1999 menu_separator( menu_in_menu );
2001 create_check_menu_item_with_mnemonic( menu_in_menu, "Show Size Info", "ToggleSizePaint" );
2002 create_check_menu_item_with_mnemonic( menu_in_menu, "Show Crosshair", "ToggleCrosshairs" );
2003 create_check_menu_item_with_mnemonic( menu_in_menu, "Show Grid", "ToggleGrid" );
2004 create_check_menu_item_with_mnemonic( menu_in_menu, "Show Blocks", "ShowBlocks" );
2005 create_check_menu_item_with_mnemonic( menu_in_menu, "Show C_oordinates", "ShowCoordinates" );
2006 create_check_menu_item_with_mnemonic( menu_in_menu, "Show Window Outline", "ShowWindowOutline" );
2007 create_check_menu_item_with_mnemonic( menu_in_menu, "Show Axes", "ShowAxes" );
2008 create_check_menu_item_with_mnemonic( menu_in_menu, "Show Workzone", "ShowWorkzone" );
2009 create_check_menu_item_with_mnemonic( menu_in_menu, "Show Camera Stats", "ShowStats" );
2013 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Filter" );
2014 if ( g_Layout_enableDetachableMenus.m_value ) {
2015 menu_tearoff( menu_in_menu );
2017 Filters_constructMenu( menu_in_menu );
2019 menu_separator( menu );
2021 create_check_menu_item_with_mnemonic( menu, "Hide Selected", "HideSelected" );
2022 create_menu_item_with_mnemonic( menu, "Show Hidden", "ShowHidden" );
2024 menu_separator( menu );
2026 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Region" );
2027 if ( g_Layout_enableDetachableMenus.m_value ) {
2028 menu_tearoff( menu_in_menu );
2030 create_menu_item_with_mnemonic( menu_in_menu, "_Off", "RegionOff" );
2031 create_menu_item_with_mnemonic( menu_in_menu, "_Set XY", "RegionSetXY" );
2032 create_menu_item_with_mnemonic( menu_in_menu, "Set _Brush", "RegionSetBrush" );
2033 create_check_menu_item_with_mnemonic( menu_in_menu, "Set Se_lected Brushes", "RegionSetSelection" );
2036 //command_connect_accelerator( "CenterXYView" );
2038 return view_menu_item;
2041 GtkMenuItem* create_selection_menu(){
2043 GtkMenuItem* selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" );
2044 GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( selection_menu_item ) );
2045 if ( g_Layout_enableDetachableMenus.m_value ) {
2046 menu_tearoff( menu );
2050 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Components" );
2051 if ( g_Layout_enableDetachableMenus.m_value ) {
2052 menu_tearoff( menu_in_menu );
2054 create_check_menu_item_with_mnemonic( menu_in_menu, "_Edges", "DragEdges" );
2055 create_check_menu_item_with_mnemonic( menu_in_menu, "_Vertices", "DragVertices" );
2056 create_check_menu_item_with_mnemonic( menu_in_menu, "_Faces", "DragFaces" );
2059 menu_separator( menu );
2060 create_menu_item_with_mnemonic( menu, "Snap To Grid", "SnapToGrid" );
2062 menu_separator( menu );
2065 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Nudge" );
2066 if ( g_Layout_enableDetachableMenus.m_value ) {
2067 menu_tearoff( menu_in_menu );
2069 create_menu_item_with_mnemonic( menu_in_menu, "Nudge Left", "SelectNudgeLeft" );
2070 create_menu_item_with_mnemonic( menu_in_menu, "Nudge Right", "SelectNudgeRight" );
2071 create_menu_item_with_mnemonic( menu_in_menu, "Nudge Up", "SelectNudgeUp" );
2072 create_menu_item_with_mnemonic( menu_in_menu, "Nudge Down", "SelectNudgeDown" );
2073 menu_separator( menu_in_menu );
2074 create_menu_item_with_mnemonic( menu_in_menu, "Nudge +Z", "MoveSelectionUP" );
2075 create_menu_item_with_mnemonic( menu_in_menu, "Nudge -Z", "MoveSelectionDOWN" );
2078 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Rotate" );
2079 if ( g_Layout_enableDetachableMenus.m_value ) {
2080 menu_tearoff( menu_in_menu );
2082 create_menu_item_with_mnemonic( menu_in_menu, "Rotate X", "RotateSelectionX" );
2083 create_menu_item_with_mnemonic( menu_in_menu, "Rotate Y", "RotateSelectionY" );
2084 create_menu_item_with_mnemonic( menu_in_menu, "Rotate Z", "RotateSelectionZ" );
2085 menu_separator( menu_in_menu );
2086 create_menu_item_with_mnemonic( menu_in_menu, "Rotate Clockwise", "RotateSelectionClockwise" );
2087 create_menu_item_with_mnemonic( menu_in_menu, "Rotate Anticlockwise", "RotateSelectionAnticlockwise" );
2090 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Flip" );
2091 if ( g_Layout_enableDetachableMenus.m_value ) {
2092 menu_tearoff( menu_in_menu );
2094 create_menu_item_with_mnemonic( menu_in_menu, "Flip _X", "MirrorSelectionX" );
2095 create_menu_item_with_mnemonic( menu_in_menu, "Flip _Y", "MirrorSelectionY" );
2096 create_menu_item_with_mnemonic( menu_in_menu, "Flip _Z", "MirrorSelectionZ" );
2097 menu_separator( menu_in_menu );
2098 create_menu_item_with_mnemonic( menu_in_menu, "Flip Horizontally", "MirrorSelectionHorizontally" );
2099 create_menu_item_with_mnemonic( menu_in_menu, "Flip Vertically", "MirrorSelectionVertically" );
2101 menu_separator( menu );
2102 create_menu_item_with_mnemonic( menu, "Arbitrary rotation...", "ArbitraryRotation" );
2103 create_menu_item_with_mnemonic( menu, "Arbitrary scale...", "ArbitraryScale" );
2105 return selection_menu_item;
2108 GtkMenuItem* create_bsp_menu(){
2110 GtkMenuItem* bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" );
2111 GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( bsp_menu_item ) );
2113 if ( g_Layout_enableDetachableMenus.m_value ) {
2114 menu_tearoff( menu );
2117 create_menu_item_with_mnemonic( menu, "Customize...", "BuildMenuCustomize" );
2118 create_menu_item_with_mnemonic( menu, "Run recent build", "Build_runRecentExecutedBuild" );
2120 menu_separator( menu );
2122 Build_constructMenu( menu );
2126 return bsp_menu_item;
2129 GtkMenuItem* create_grid_menu(){
2131 GtkMenuItem* grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" );
2132 GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( grid_menu_item ) );
2133 if ( g_Layout_enableDetachableMenus.m_value ) {
2134 menu_tearoff( menu );
2137 Grid_constructMenu( menu );
2139 return grid_menu_item;
2142 GtkMenuItem* create_misc_menu(){
2144 GtkMenuItem* misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" );
2145 GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( misc_menu_item ) );
2146 if ( g_Layout_enableDetachableMenus.m_value ) {
2147 menu_tearoff( menu );
2151 create_menu_item_with_mnemonic( menu, "_Benchmark", FreeCaller<GlobalCamera_Benchmark>() );
2153 gtk_container_add( GTK_CONTAINER( menu ), GTK_WIDGET( create_colours_menu() ) );
2155 create_menu_item_with_mnemonic( menu, "Find brush...", "FindBrush" );
2156 create_menu_item_with_mnemonic( menu, "Map Info...", "MapInfo" );
2157 // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394
2158 // create_menu_item_with_mnemonic(menu, "_Print XY View", FreeCaller<WXY_Print>());
2159 create_menu_item_with_mnemonic( menu, "_Background image...", FreeCaller<WXY_BackgroundSelect>() );
2160 create_menu_item_with_mnemonic( menu, "Fullscreen", "Fullscreen" );
2161 create_menu_item_with_mnemonic( menu, "Maximize view", "MaximizeView" );
2162 return misc_menu_item;
2165 GtkMenuItem* create_entity_menu(){
2167 GtkMenuItem* entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" );
2168 GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( entity_menu_item ) );
2169 if ( g_Layout_enableDetachableMenus.m_value ) {
2170 menu_tearoff( menu );
2173 Entity_constructMenu( menu );
2175 return entity_menu_item;
2178 GtkMenuItem* create_brush_menu(){
2180 GtkMenuItem* brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" );
2181 GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( brush_menu_item ) );
2182 if ( g_Layout_enableDetachableMenus.m_value ) {
2183 menu_tearoff( menu );
2186 Brush_constructMenu( menu );
2188 return brush_menu_item;
2191 GtkMenuItem* create_patch_menu(){
2193 GtkMenuItem* patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" );
2194 GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( patch_menu_item ) );
2195 if ( g_Layout_enableDetachableMenus.m_value ) {
2196 menu_tearoff( menu );
2199 Patch_constructMenu( menu );
2201 return patch_menu_item;
2204 GtkMenuItem* create_help_menu(){
2206 GtkMenuItem* help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" );
2207 GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( help_menu_item ) );
2208 if ( g_Layout_enableDetachableMenus.m_value ) {
2209 menu_tearoff( menu );
2212 // create_menu_item_with_mnemonic( menu, "Manual", "OpenManual" );
2214 // this creates all the per-game drop downs for the game pack helps
2215 // it will take care of hooking the Sys_OpenURL calls etc.
2216 create_game_help_menu( menu );
2218 // create_menu_item_with_mnemonic( menu, "Bug report", FreeCaller<OpenBugReportURL>() );
2219 create_menu_item_with_mnemonic( menu, "Shortcuts", FreeCaller<DoCommandListDlg>() );
2220 create_menu_item_with_mnemonic( menu, "_About", FreeCaller<DoAbout>() );
2222 return help_menu_item;
2225 GtkMenuBar* create_main_menu( MainFrame::EViewStyle style ){
2226 GtkMenuBar* menu_bar = GTK_MENU_BAR( gtk_menu_bar_new() );
2227 gtk_widget_show( GTK_WIDGET( menu_bar ) );
2229 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_file_menu() ) );
2230 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_edit_menu() ) );
2231 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_view_menu( style ) ) );
2232 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_selection_menu() ) );
2233 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_bsp_menu() ) );
2234 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_grid_menu() ) );
2235 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_misc_menu() ) );
2236 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_entity_menu() ) );
2237 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_brush_menu() ) );
2238 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_patch_menu() ) );
2239 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_plugins_menu() ) );
2240 gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_help_menu() ) );
2246 void PatchInspector_registerShortcuts(){
2247 command_connect_accelerator( "PatchInspector" );
2250 void Patch_registerShortcuts(){
2251 // command_connect_accelerator( "InvertCurveTextureX" );
2252 // command_connect_accelerator( "InvertCurveTextureY" );
2253 // command_connect_accelerator( "PatchInsertInsertColumn" );
2254 // command_connect_accelerator( "PatchInsertInsertRow" );
2255 // command_connect_accelerator( "PatchDeleteLastColumn" );
2256 // command_connect_accelerator( "PatchDeleteLastRow" );
2257 // command_connect_accelerator( "NaturalizePatch" );
2258 //command_connect_accelerator("CapCurrentCurve");
2261 void Manipulators_registerShortcuts(){
2262 toggle_add_accelerator( "MouseRotate" );
2263 toggle_add_accelerator( "MouseTranslate" );
2264 toggle_add_accelerator( "MouseScale" );
2265 toggle_add_accelerator( "MouseDrag" );
2266 toggle_add_accelerator( "ToggleClipper" );
2269 void TexdefNudge_registerShortcuts(){
2270 command_connect_accelerator( "TexRotateClock" );
2271 command_connect_accelerator( "TexRotateCounter" );
2272 command_connect_accelerator( "TexScaleUp" );
2273 command_connect_accelerator( "TexScaleDown" );
2274 command_connect_accelerator( "TexScaleLeft" );
2275 command_connect_accelerator( "TexScaleRight" );
2276 command_connect_accelerator( "TexShiftUp" );
2277 command_connect_accelerator( "TexShiftDown" );
2278 command_connect_accelerator( "TexShiftLeft" );
2279 command_connect_accelerator( "TexShiftRight" );
2282 void SelectNudge_registerShortcuts(){
2283 //command_connect_accelerator( "MoveSelectionDOWN" );
2284 //command_connect_accelerator( "MoveSelectionUP" );
2285 //command_connect_accelerator("SelectNudgeLeft");
2286 //command_connect_accelerator("SelectNudgeRight");
2287 //command_connect_accelerator("SelectNudgeUp");
2288 //command_connect_accelerator("SelectNudgeDown");
2289 command_connect_accelerator( "UnSelectSelection2" );
2290 command_connect_accelerator( "DeleteSelection2" );
2293 void SnapToGrid_registerShortcuts(){
2294 command_connect_accelerator( "SnapToGrid" );
2297 void SelectByType_registerShortcuts(){
2298 command_connect_accelerator( "SelectAllOfType" );
2301 void SurfaceInspector_registerShortcuts(){
2302 command_connect_accelerator( "FitTexture" );
2305 void TexBro_registerShortcuts(){
2306 command_connect_accelerator( "FindReplaceTextures" );
2307 command_connect_accelerator( "RefreshShaders" );
2310 void Misc_registerShortcuts(){
2312 command_connect_accelerator( "RefreshReferences" );
2313 command_connect_accelerator( "MouseRotateOrScale" );
2314 command_connect_accelerator( "MouseDragOrScale" );
2318 void register_shortcuts(){
2319 // PatchInspector_registerShortcuts();
2320 //Patch_registerShortcuts();
2321 Grid_registerShortcuts();
2322 // XYWnd_registerShortcuts();
2323 CamWnd_registerShortcuts();
2324 Manipulators_registerShortcuts();
2325 SurfaceInspector_registerShortcuts();
2326 TexdefNudge_registerShortcuts();
2327 SelectNudge_registerShortcuts();
2328 // SnapToGrid_registerShortcuts();
2329 // SelectByType_registerShortcuts();
2330 TexBro_registerShortcuts();
2331 Misc_registerShortcuts();
2334 void File_constructToolbar( GtkToolbar* toolbar ){
2335 toolbar_append_button( toolbar, "Open an existing map (CTRL + O)", "file_open.png", "OpenMap" );
2336 toolbar_append_button( toolbar, "Save the active map (CTRL + S)", "file_save.png", "SaveMap" );
2339 void UndoRedo_constructToolbar( GtkToolbar* toolbar ){
2340 toolbar_append_button( toolbar, "Undo (CTRL + Z)", "undo.png", "Undo" );
2341 toolbar_append_button( toolbar, "Redo (CTRL + Y)", "redo.png", "Redo" );
2344 void RotateFlip_constructToolbar( GtkToolbar* toolbar ){
2345 // toolbar_append_button( toolbar, "x-axis Flip", "brush_flipx.png", "MirrorSelectionX" );
2346 // toolbar_append_button( toolbar, "x-axis Rotate", "brush_rotatex.png", "RotateSelectionX" );
2347 // toolbar_append_button( toolbar, "y-axis Flip", "brush_flipy.png", "MirrorSelectionY" );
2348 // toolbar_append_button( toolbar, "y-axis Rotate", "brush_rotatey.png", "RotateSelectionY" );
2349 // toolbar_append_button( toolbar, "z-axis Flip", "brush_flipz.png", "MirrorSelectionZ" );
2350 // toolbar_append_button( toolbar, "z-axis Rotate", "brush_rotatez.png", "RotateSelectionZ" );
2351 toolbar_append_button( toolbar, "Flip Horizontally", "brush_flip_hor.png", "MirrorSelectionHorizontally" );
2352 toolbar_append_button( toolbar, "Flip Vertically", "brush_flip_vert.png", "MirrorSelectionVertically" );
2354 toolbar_append_button( toolbar, "Rotate Clockwise", "brush_rotate_clock.png", "RotateSelectionClockwise" );
2355 toolbar_append_button( toolbar, "Rotate Anticlockwise", "brush_rotate_anti.png", "RotateSelectionAnticlockwise" );
2358 void Select_constructToolbar( GtkToolbar* toolbar ){
2359 toolbar_append_button( toolbar, "Select touching", "selection_selecttouching.png", "SelectTouching" );
2360 toolbar_append_button( toolbar, "Select inside", "selection_selectinside.png", "SelectInside" );
2363 void CSG_constructToolbar( GtkToolbar* toolbar ){
2364 toolbar_append_button( toolbar, "CSG Subtract (SHIFT + U)", "selection_csgsubtract.png", "CSGSubtract" );
2365 toolbar_append_button( toolbar, "CSG Merge (CTRL + U)", "selection_csgmerge.png", "CSGMerge" );
2366 toolbar_append_button( toolbar, "Room", "selection_makeroom.png", "CSGroom" );
2367 toolbar_append_button( toolbar, "CSG Tool", "ellipsis.png", "CSGTool" );
2370 void ComponentModes_constructToolbar( GtkToolbar* toolbar ){
2371 toolbar_append_toggle_button( toolbar, "Select Vertices (V)", "modify_vertices.png", "DragVertices" );
2372 toolbar_append_toggle_button( toolbar, "Select Edges (E)", "modify_edges.png", "DragEdges" );
2373 toolbar_append_toggle_button( toolbar, "Select Faces (F)", "modify_faces.png", "DragFaces" );
2376 void Clipper_constructToolbar( GtkToolbar* toolbar ){
2378 toolbar_append_toggle_button( toolbar, "Clipper (X)", "view_clipper.png", "ToggleClipper" );
2381 void XYWnd_constructToolbar( GtkToolbar* toolbar ){
2382 toolbar_append_button( toolbar, "Change views (CTRL + TAB)", "view_change.png", "NextView" );
2385 void Manipulators_constructToolbar( GtkToolbar* toolbar ){
2386 toolbar_append_toggle_button( toolbar, "Translate (W)", "select_mousetranslate.png", "MouseTranslate" );
2387 toolbar_append_toggle_button( toolbar, "Rotate (R)", "select_mouserotate.png", "MouseRotate" );
2388 toolbar_append_toggle_button( toolbar, "Scale (Q)", "select_mousescale.png", "MouseScale" );
2389 toolbar_append_toggle_button( toolbar, "Resize (Q)", "select_mouseresize.png", "MouseDrag" );
2391 Clipper_constructToolbar( toolbar );
2394 GtkToolbar* create_main_toolbar( MainFrame::EViewStyle style ){
2395 GtkToolbar* toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
2396 gtk_toolbar_set_orientation( toolbar, GTK_ORIENTATION_HORIZONTAL );
2397 gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS );
2398 // gtk_toolbar_set_show_arrow( toolbar, TRUE );
2399 //gtk_orientable_set_orientation( GTK_ORIENTABLE( toolbar ), GTK_ORIENTATION_HORIZONTAL );
2400 //toolbar_append_space( toolbar );
2401 gtk_widget_show( GTK_WIDGET( toolbar ) );
2403 File_constructToolbar( toolbar );
2404 gtk_toolbar_append_space( toolbar );
2406 UndoRedo_constructToolbar( toolbar );
2407 gtk_toolbar_append_space( toolbar );
2409 RotateFlip_constructToolbar( toolbar );
2410 gtk_toolbar_append_space( toolbar );
2412 Select_constructToolbar( toolbar );
2413 gtk_toolbar_append_space( toolbar );
2415 CSG_constructToolbar( toolbar );
2416 gtk_toolbar_append_space( toolbar );
2418 ComponentModes_constructToolbar( toolbar );
2419 gtk_toolbar_append_space( toolbar );
2421 if ( style != MainFrame::eSplit ) {
2422 XYWnd_constructToolbar( toolbar );
2423 gtk_toolbar_append_space( toolbar );
2426 CamWnd_constructToolbar( toolbar );
2427 gtk_toolbar_append_space( toolbar );
2429 Manipulators_constructToolbar( toolbar );
2430 gtk_toolbar_append_space( toolbar );
2432 if ( g_Layout_enablePatchToolbar.m_value ) {
2433 Patch_constructToolbar( toolbar );
2434 gtk_toolbar_append_space( toolbar );
2437 toolbar_append_toggle_button( toolbar, "Texture Lock (SHIFT + T)", "texture_lock.png", "TogTexLock" );
2438 gtk_toolbar_append_space( toolbar );
2440 toolbar_append_button( toolbar, "Entities (N)", "entities.png", "ToggleEntityInspector" );
2441 // disable the console and texture button in the regular layouts
2442 if ( style != MainFrame::eRegular && style != MainFrame::eRegularLeft ) {
2443 toolbar_append_button( toolbar, "Console (O)", "console.png", "ToggleConsole" );
2444 toolbar_append_button( toolbar, "Texture Browser (T)", "texture_browser.png", "ToggleTextures" );
2447 // TODO: call light inspector
2448 //GtkButton* g_view_lightinspector_button = toolbar_append_button(toolbar, "Light Inspector", "lightinspector.png", "ToggleLightInspector");
2450 gtk_toolbar_append_space( toolbar );
2451 toolbar_append_button( toolbar, "Refresh Models", "refresh_models.png", "RefreshReferences" );
2456 GtkWidget* create_main_statusbar( GtkWidget *pStatusLabel[c_count_status] ){
2457 GtkTable* table = GTK_TABLE( gtk_table_new( 1, c_count_status, FALSE ) );
2458 gtk_widget_show( GTK_WIDGET( table ) );
2461 GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) );
2462 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
2463 gtk_misc_set_padding( GTK_MISC( label ), 4, 2 );
2464 gtk_widget_show( GTK_WIDGET( label ) );
2465 gtk_table_attach_defaults( table, GTK_WIDGET( label ), 0, 1, 0, 1 );
2466 pStatusLabel[c_command_status] = GTK_WIDGET( label );
2469 for ( int i = 1; i < c_count_status; ++i )
2471 GtkFrame* frame = GTK_FRAME( gtk_frame_new( 0 ) );
2472 gtk_widget_show( GTK_WIDGET( frame ) );
2473 gtk_table_attach_defaults( table, GTK_WIDGET( frame ), i, i + 1, 0, 1 );
2474 gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN );
2476 GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) );
2477 gtk_label_set_ellipsize( label, PANGO_ELLIPSIZE_END );
2478 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
2479 gtk_misc_set_padding( GTK_MISC( label ), 4, 2 );
2480 gtk_widget_show( GTK_WIDGET( label ) );
2481 gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( label ) );
2482 pStatusLabel[i] = GTK_WIDGET( label );
2485 return GTK_WIDGET( table );
2491 WidgetFocusPrinter g_mainframeWidgetFocusPrinter( "mainframe" );
2493 class WindowFocusPrinter
2497 static gboolean frame_event( GtkWidget *widget, GdkEvent* event, WindowFocusPrinter* self ){
2498 globalOutputStream() << self->m_name << " frame_event\n";
2501 static gboolean keys_changed( GtkWidget *widget, WindowFocusPrinter* self ){
2502 globalOutputStream() << self->m_name << " keys_changed\n";
2505 static gboolean notify( GtkWindow* window, gpointer dummy, WindowFocusPrinter* self ){
2506 if ( gtk_window_is_active( window ) ) {
2507 globalOutputStream() << self->m_name << " takes toplevel focus\n";
2511 globalOutputStream() << self->m_name << " loses toplevel focus\n";
2516 WindowFocusPrinter( const char* name ) : m_name( name ){
2518 void connect( GtkWindow* toplevel_window ){
2519 g_signal_connect( G_OBJECT( toplevel_window ), "notify::has_toplevel_focus", G_CALLBACK( notify ), this );
2520 g_signal_connect( G_OBJECT( toplevel_window ), "notify::is_active", G_CALLBACK( notify ), this );
2521 g_signal_connect( G_OBJECT( toplevel_window ), "keys_changed", G_CALLBACK( keys_changed ), this );
2522 g_signal_connect( G_OBJECT( toplevel_window ), "frame_event", G_CALLBACK( frame_event ), this );
2526 WindowFocusPrinter g_mainframeFocusPrinter( "mainframe" );
2530 class MainWindowActive
2532 static gboolean notify( GtkWindow* window, gpointer dummy, MainWindowActive* self ){
2533 if ( g_wait.m_window != 0 && gtk_window_is_active( window ) && !GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
2534 gtk_widget_show( GTK_WIDGET( g_wait.m_window ) );
2540 void connect( GtkWindow* toplevel_window ){
2541 g_signal_connect( G_OBJECT( toplevel_window ), "notify::is-active", G_CALLBACK( notify ), this );
2545 MainWindowActive g_MainWindowActive;
2547 SignalHandlerId XYWindowDestroyed_connect( const SignalHandler& handler ){
2548 return g_pParentWnd->GetXYWnd()->onDestroyed.connectFirst( handler );
2551 void XYWindowDestroyed_disconnect( SignalHandlerId id ){
2552 g_pParentWnd->GetXYWnd()->onDestroyed.disconnect( id );
2555 MouseEventHandlerId XYWindowMouseDown_connect( const MouseEventHandler& handler ){
2556 return g_pParentWnd->GetXYWnd()->onMouseDown.connectFirst( handler );
2559 void XYWindowMouseDown_disconnect( MouseEventHandlerId id ){
2560 g_pParentWnd->GetXYWnd()->onMouseDown.disconnect( id );
2563 // =============================================================================
2566 MainFrame* g_pParentWnd = 0;
2568 GtkWindow* MainFrame_getWindow(){
2569 if ( g_pParentWnd == 0 ) {
2572 return g_pParentWnd->m_window;
2575 std::vector<GtkWidget*> g_floating_windows;
2577 MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusTextCaller( *this ) ){
2585 for ( int n = 0; n < c_count_status; n++ )
2587 m_pStatusLabel[n] = 0;
2590 m_bSleeping = false;
2595 MainFrame::~MainFrame(){
2598 gtk_widget_hide( GTK_WIDGET( m_window ) );
2602 for ( std::vector<GtkWidget*>::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i )
2604 gtk_widget_destroy( *i );
2607 gtk_widget_destroy( GTK_WIDGET( m_window ) );
2610 void MainFrame::SetActiveXY( XYWnd* p ){
2611 if ( m_pActiveXY ) {
2612 m_pActiveXY->SetActive( false );
2617 if ( m_pActiveXY ) {
2618 m_pActiveXY->SetActive( true );
2623 void MainFrame::ReleaseContexts(){
2626 m_pXYWnd->DestroyContext();
2629 m_pYZWnd->DestroyContext();
2632 m_pXZWnd->DestroyContext();
2635 m_pCamWnd->DestroyContext();
2638 m_pTexWnd->DestroyContext();
2641 m_pZWnd->DestroyContext();
2646 void MainFrame::CreateContexts(){
2649 m_pCamWnd->CreateContext();
2652 m_pXYWnd->CreateContext();
2655 m_pYZWnd->CreateContext();
2658 m_pXZWnd->CreateContext();
2661 m_pTexWnd->CreateContext();
2664 m_pZWnd->CreateContext();
2673 void MainFrame::OnSleep(){
2676 if ( m_bSleeping ) {
2677 // useful when trying to debug crashes in the sleep code
2678 globalOutputStream() << "Going into sleep mode..\n";
2680 globalOutputStream() << "Dispatching sleep msg...";
2681 DispatchRadiantMsg( RADIANT_SLEEP );
2682 globalOutputStream() << "Done.\n";
2684 gtk_window_iconify( m_window );
2685 GlobalSelectionSystem().setSelectedAll( false );
2687 GlobalShaderCache().unrealise();
2689 GlobalOpenGL_debugAssertNoErrors();
2690 ScreenUpdates_Disable();
2693 globalOutputStream() << "Releasing contexts...";
2695 globalOutputStream() << "Done.\n";
2699 globalOutputStream() << "Waking up\n";
2701 gtk_window_deiconify( m_window );
2704 globalOutputStream() << "Creating contexts...";
2706 globalOutputStream() << "Done.\n";
2708 globalOutputStream() << "Making current on camera...";
2709 m_pCamWnd->MakeCurrent();
2710 globalOutputStream() << "Done.\n";
2712 globalOutputStream() << "Reloading shaders...";
2714 GlobalShaderCache().realise();
2715 globalOutputStream() << "Done.\n";
2717 ScreenUpdates_Enable();
2719 globalOutputStream() << "Dispatching wake msg...";
2720 DispatchRadiantMsg( RADIANT_WAKEUP );
2721 globalOutputStream() << "Done\n";
2727 GtkWindow* create_splash(){
2728 GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) );
2729 gtk_window_set_decorated( window, FALSE );
2730 gtk_window_set_resizable( window, FALSE );
2731 gtk_window_set_modal( window, TRUE );
2732 gtk_window_set_default_size( window, -1, -1 );
2733 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
2734 gtk_container_set_border_width( GTK_CONTAINER( window ), 0 );
2736 GtkImage* image = new_local_image( "splash.png" );
2737 gtk_widget_show( GTK_WIDGET( image ) );
2738 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( image ) );
2740 if( gtk_image_get_storage_type( image ) == GTK_IMAGE_PIXBUF ){
2742 GdkPixbuf* pix = gtk_image_get_pixbuf( image );
2743 gdk_pixbuf_render_pixmap_and_mask( pix, NULL, &mask, 255 );
2744 gtk_widget_shape_combine_mask ( GTK_WIDGET( window ), mask, 0, 0 );
2747 gtk_widget_set_size_request( GTK_WIDGET( window ), -1, -1 );
2748 gtk_widget_show( GTK_WIDGET( window ) );
2753 static GtkWindow *splash_screen = 0;
2756 splash_screen = create_splash();
2762 gtk_widget_destroy( GTK_WIDGET( splash_screen ) );
2765 WindowPositionTracker g_posCamWnd;
2766 WindowPositionTracker g_posXYWnd;
2767 WindowPositionTracker g_posXZWnd;
2768 WindowPositionTracker g_posYZWnd;
2770 static gint mainframe_delete( GtkWidget *widget, GdkEvent *event, gpointer data ){
2771 if ( ConfirmModified( "Exit Radiant" ) ) {
2778 void MainFrame::Create(){
2779 GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) );
2781 GlobalWindowObservers_connectTopLevel( window );
2783 gtk_window_set_transient_for( splash_screen, window );
2785 #if !defined( WIN32 )
2787 GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.png" );
2788 if ( pixbuf != 0 ) {
2789 gtk_window_set_icon( window, pixbuf );
2790 g_object_unref( pixbuf );
2795 gtk_widget_add_events( GTK_WIDGET( window ), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK );
2796 g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( mainframe_delete ), this );
2798 m_position_tracker.connect( window );
2801 g_mainframeWidgetFocusPrinter.connect( window );
2802 g_mainframeFocusPrinter.connect( window );
2805 g_MainWindowActive.connect( window );
2807 GetPlugInMgr().Init( GTK_WIDGET( window ) );
2809 GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
2810 gtk_container_add( GTK_CONTAINER( window ), vbox );
2811 gtk_widget_show( vbox );
2812 gtk_container_set_focus_chain( GTK_CONTAINER( vbox ), NULL );
2814 global_accel_connect_window( window );
2816 m_nCurrentStyle = (EViewStyle)g_Layout_viewStyle.m_value;
2818 register_shortcuts();
2820 GtkMenuBar* main_menu = create_main_menu( CurrentStyle() );
2821 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_menu ), FALSE, FALSE, 0 );
2823 if( g_Layout_enableMainToolbar.m_value ){
2824 GtkToolbar* main_toolbar = create_main_toolbar( CurrentStyle() );
2825 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_toolbar ), FALSE, FALSE, 0 );
2829 if ( g_Layout_enablePluginToolbar.m_value || g_Layout_enableFilterToolbar.m_value ){
2830 GtkWidget* PFbox = gtk_hbox_new( FALSE, 3 );
2831 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( PFbox ), FALSE, FALSE, 0 );
2832 gtk_widget_show( PFbox );
2833 if ( g_Layout_enablePluginToolbar.m_value ){
2834 GtkToolbar* plugin_toolbar = create_plugin_toolbar();
2835 if ( g_Layout_enableFilterToolbar.m_value ){
2836 gtk_box_pack_start( GTK_BOX( PFbox ), GTK_WIDGET( plugin_toolbar ), FALSE, FALSE, 0 );
2839 gtk_box_pack_start( GTK_BOX( PFbox ), GTK_WIDGET( plugin_toolbar ), TRUE, TRUE, 0 );
2842 if ( g_Layout_enableFilterToolbar.m_value ){
2843 GtkToolbar* filter_toolbar = create_filter_toolbar();
2844 gtk_box_pack_start( GTK_BOX( PFbox ), GTK_WIDGET( filter_toolbar ), TRUE, TRUE, 0 );
2848 /*GtkToolbar* plugin_toolbar = create_plugin_toolbar();
2849 if ( !g_Layout_enablePluginToolbar.m_value ) {
2850 gtk_widget_hide( GTK_WIDGET( plugin_toolbar ) );
2856 GtkWidget* main_statusbar = create_main_statusbar( m_pStatusLabel );
2857 gtk_box_pack_end( GTK_BOX( vbox ), main_statusbar, FALSE, TRUE, 2 );
2859 GroupDialog_constructWindow( window );
2861 /* want to realize it immediately; otherwise gtk paned splits positions wont be set correctly for floating group dlg */
2862 gtk_widget_realize ( GTK_WIDGET( GroupDialog_getWindow() ) );
2864 g_page_entity = GroupDialog_addPage( "Entities", EntityInspector_constructWindow( GroupDialog_getWindow() ), RawStringExportCaller( "Entities" ) );
2866 if ( FloatingGroupDialog() ) {
2867 g_page_console = GroupDialog_addPage( "Console", Console_constructWindow( GroupDialog_getWindow() ), RawStringExportCaller( "Console" ) );
2871 if ( g_multimon_globals.m_bStartOnPrimMon ) {
2872 PositionWindowOnPrimaryScreen( g_layout_globals.m_position );
2875 window_set_position( window, g_layout_globals.m_position );
2879 gtk_widget_show( GTK_WIDGET( window ) );
2881 if ( CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft ) {
2883 GtkWidget* hsplit = gtk_hpaned_new();
2885 gtk_box_pack_start( GTK_BOX( vbox ), hsplit, TRUE, TRUE, 0 );
2886 gtk_widget_show( hsplit );
2888 GtkWidget* vsplit = gtk_vpaned_new();
2889 gtk_widget_show( vsplit );
2891 GtkWidget* vsplit2 = gtk_vpaned_new();
2892 gtk_widget_show( vsplit2 );
2893 m_vSplit2 = vsplit2;
2894 if ( CurrentStyle() == eRegular ){
2895 gtk_paned_pack1( GTK_PANED( hsplit ), vsplit, TRUE, TRUE );
2896 gtk_paned_pack2( GTK_PANED( hsplit ), vsplit2, TRUE, TRUE );
2899 gtk_paned_pack2( GTK_PANED( hsplit ), vsplit, TRUE, TRUE );
2900 gtk_paned_pack1( GTK_PANED( hsplit ), vsplit2, TRUE, TRUE );
2903 GtkWidget* console_window = Console_constructWindow( window );
2904 gtk_paned_pack2( GTK_PANED( vsplit ), console_window, TRUE, TRUE );
2907 m_pXYWnd = new XYWnd();
2908 m_pXYWnd->SetViewType( XY );
2909 GtkWidget* xy_window = GTK_WIDGET( create_framed_widget( m_pXYWnd->GetWidget() ) );
2910 gtk_paned_pack1( GTK_PANED( vsplit ), xy_window, TRUE, TRUE );
2913 m_pCamWnd = NewCamWnd();
2914 GlobalCamera_setCamWnd( *m_pCamWnd );
2915 CamWnd_setParent( *m_pCamWnd, window );
2916 GtkFrame* camera_window = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) );
2918 gtk_paned_pack1( GTK_PANED( vsplit2 ), GTK_WIDGET( camera_window ), TRUE, TRUE );
2921 GtkFrame* texture_window = create_framed_widget( TextureBrowser_constructWindow( window ) );
2923 gtk_paned_pack2( GTK_PANED( vsplit2 ), GTK_WIDGET( texture_window ), TRUE, TRUE );
2928 else if ( CurrentStyle() == eFloating ) {
2930 GtkWindow* window = create_persistent_floating_window( "Camera", m_window );
2931 global_accel_connect_window( window );
2932 g_posCamWnd.connect( window );
2934 gtk_widget_show( GTK_WIDGET( window ) );
2936 m_pCamWnd = NewCamWnd();
2937 GlobalCamera_setCamWnd( *m_pCamWnd );
2940 GtkFrame* frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) );
2941 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
2943 CamWnd_setParent( *m_pCamWnd, window );
2944 /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
2945 g_object_set_data( G_OBJECT( window ), "glwidget", CamWnd_getWidget( *m_pCamWnd ) );
2947 g_floating_windows.push_back( GTK_WIDGET( window ) );
2951 GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XY ), m_window );
2952 global_accel_connect_window( window );
2953 g_posXYWnd.connect( window );
2955 m_pXYWnd = new XYWnd();
2956 m_pXYWnd->m_parent = window;
2957 m_pXYWnd->SetViewType( XY );
2961 GtkFrame* frame = create_framed_widget( m_pXYWnd->GetWidget() );
2962 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
2964 XY_Top_Shown_Construct( window );
2965 /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
2966 g_object_set_data( G_OBJECT( window ), "glwidget", m_pXYWnd->GetWidget() );
2968 g_floating_windows.push_back( GTK_WIDGET( window ) );
2972 GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XZ ), m_window );
2973 global_accel_connect_window( window );
2974 g_posXZWnd.connect( window );
2976 m_pXZWnd = new XYWnd();
2977 m_pXZWnd->m_parent = window;
2978 m_pXZWnd->SetViewType( XZ );
2981 GtkFrame* frame = create_framed_widget( m_pXZWnd->GetWidget() );
2982 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
2985 XZ_Front_Shown_Construct( window );
2986 /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
2987 g_object_set_data( G_OBJECT( window ), "glwidget", m_pXZWnd->GetWidget() );
2989 g_floating_windows.push_back( GTK_WIDGET( window ) );
2993 GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( YZ ), m_window );
2994 global_accel_connect_window( window );
2995 g_posYZWnd.connect( window );
2997 m_pYZWnd = new XYWnd();
2998 m_pYZWnd->m_parent = window;
2999 m_pYZWnd->SetViewType( YZ );
3002 GtkFrame* frame = create_framed_widget( m_pYZWnd->GetWidget() );
3003 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
3006 YZ_Side_Shown_Construct( window );
3007 /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
3008 g_object_set_data( G_OBJECT( window ), "glwidget", m_pYZWnd->GetWidget() );
3010 g_floating_windows.push_back( GTK_WIDGET( window ) );
3014 GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
3015 g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() );
3016 /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
3017 g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() );
3028 m_pCamWnd = NewCamWnd();
3029 GlobalCamera_setCamWnd( *m_pCamWnd );
3030 CamWnd_setParent( *m_pCamWnd, window );
3032 GtkWidget* camera = CamWnd_getWidget( *m_pCamWnd );
3034 m_pYZWnd = new XYWnd();
3035 m_pYZWnd->SetViewType( YZ );
3037 GtkWidget* yz = m_pYZWnd->GetWidget();
3039 m_pXYWnd = new XYWnd();
3040 m_pXYWnd->SetViewType( XY );
3042 GtkWidget* xy = m_pXYWnd->GetWidget();
3044 m_pXZWnd = new XYWnd();
3045 m_pXZWnd->SetViewType( XZ );
3047 GtkWidget* xz = m_pXZWnd->GetWidget();
3049 m_hSplit = create_split_views( camera, yz, xy, xz, m_vSplit, m_vSplit2 );
3050 gtk_box_pack_start( GTK_BOX( vbox ), m_hSplit, TRUE, TRUE, 0 );
3053 GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
3054 g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() );
3055 /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
3056 g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() );
3060 EntityList_constructWindow( window );
3061 PreferencesDialog_constructWindow( window );
3062 FindTextureDialog_constructWindow( window );
3063 SurfaceInspector_constructWindow( window );
3064 PatchInspector_constructWindow( window );
3066 SetActiveXY( m_pXYWnd );
3068 AddGridChangeCallback( SetGridStatusCaller( *this ) );
3069 AddGridChangeCallback( ReferenceCaller<MainFrame, XY_UpdateAllWindows>( *this ) );
3071 g_defaultToolMode = DragMode;
3072 g_defaultToolMode();
3073 SetStatusText( m_command_status, c_TranslateMode_status );
3075 EverySecondTimer_enable();
3077 if ( g_layout_globals.nState & GDK_WINDOW_STATE_MAXIMIZED ) {
3078 gtk_window_maximize( window );
3080 if ( g_layout_globals.nState & GDK_WINDOW_STATE_FULLSCREEN ) {
3081 gtk_window_fullscreen( window );
3083 if ( !FloatingGroupDialog() ) {
3084 gtk_paned_set_position( GTK_PANED( m_vSplit ), g_layout_globals.nXYHeight );
3086 if ( CurrentStyle() == eRegular ) {
3087 gtk_paned_set_position( GTK_PANED( m_hSplit ), g_layout_globals.nXYWidth );
3091 gtk_paned_set_position( GTK_PANED( m_hSplit ), g_layout_globals.nCamWidth );
3094 gtk_paned_set_position( GTK_PANED( m_vSplit2 ), g_layout_globals.nCamHeight );
3096 //GlobalShortcuts_reportUnregistered();
3099 void MainFrame::SaveWindowInfo(){
3100 if ( !FloatingGroupDialog() ) {
3101 g_layout_globals.nXYHeight = gtk_paned_get_position( GTK_PANED( m_vSplit ) );
3103 if ( CurrentStyle() != eRegular ) {
3104 g_layout_globals.nCamWidth = gtk_paned_get_position( GTK_PANED( m_hSplit ) );
3108 g_layout_globals.nXYWidth = gtk_paned_get_position( GTK_PANED( m_hSplit ) );
3111 g_layout_globals.nCamHeight = gtk_paned_get_position( GTK_PANED( m_vSplit2 ) );
3114 if( gdk_window_get_state( GTK_WIDGET( m_window )->window ) == 0 ){
3115 g_layout_globals.m_position = m_position_tracker.getPosition();
3118 g_layout_globals.nState = gdk_window_get_state( GTK_WIDGET( m_window )->window );
3121 void MainFrame::Shutdown(){
3122 EverySecondTimer_disable();
3124 EntityList_destroyWindow();
3133 TextureBrowser_destroyWindow();
3135 DeleteCamWnd( m_pCamWnd );
3138 PreferencesDialog_destroyWindow();
3139 SurfaceInspector_destroyWindow();
3140 FindTextureDialog_destroyWindow();
3141 PatchInspector_destroyWindow();
3143 g_DbgDlg.destroyWindow();
3145 // destroying group-dialog last because it may contain texture-browser
3146 GroupDialog_destroyWindow();
3149 void MainFrame::RedrawStatusText(){
3150 gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_command_status] ), m_command_status.c_str() );
3151 gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_position_status] ), m_position_status.c_str() );
3152 gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_brushcount_status] ), m_brushcount_status.c_str() );
3153 gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_texture_status] ), m_texture_status.c_str() );
3154 gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_grid_status] ), m_grid_status.c_str() );
3157 void MainFrame::UpdateStatusText(){
3158 m_idleRedrawStatusText.queueDraw();
3161 void MainFrame::SetStatusText( CopiedString& status_text, const char* pText ){
3162 status_text = pText;
3166 void Sys_Status( const char* status ){
3167 if ( g_pParentWnd != 0 ) {
3168 g_pParentWnd->SetStatusText( g_pParentWnd->m_command_status, status );
3172 int getRotateIncrement(){
3173 return static_cast<int>( g_si_globals.rotate );
3176 int getFarClipDistance(){
3177 return g_camwindow_globals.m_nCubicScale;
3180 float ( *GridStatus_getGridSize )() = GetGridSize;
3181 int ( *GridStatus_getRotateIncrement )() = getRotateIncrement;
3182 int ( *GridStatus_getFarClipDistance )() = getFarClipDistance;
3183 bool ( *GridStatus_getTextureLockEnabled )();
3185 void MainFrame::SetGridStatus(){
3186 StringOutputStream status( 64 );
3187 const char* lock = ( GridStatus_getTextureLockEnabled() ) ? "ON" : "OFF";
3188 status << ( GetSnapGridSize() > 0 ? "G:" : "g:" ) << GridStatus_getGridSize()
3189 << " R:" << GridStatus_getRotateIncrement()
3190 << " C:" << GridStatus_getFarClipDistance()
3192 SetStatusText( m_grid_status, status.c_str() );
3195 void GridStatus_onTextureLockEnabledChanged(){
3196 if ( g_pParentWnd != 0 ) {
3197 g_pParentWnd->SetGridStatus();
3201 void GlobalGL_sharedContextCreated(){
3202 GLFont *g_font = NULL;
3204 // report OpenGL information
3205 globalOutputStream() << "GL_VENDOR: " << reinterpret_cast<const char*>( glGetString( GL_VENDOR ) ) << "\n";
3206 globalOutputStream() << "GL_RENDERER: " << reinterpret_cast<const char*>( glGetString( GL_RENDERER ) ) << "\n";
3207 globalOutputStream() << "GL_VERSION: " << reinterpret_cast<const char*>( glGetString( GL_VERSION ) ) << "\n";
3208 globalOutputStream() << "GL_EXTENSIONS: " << reinterpret_cast<const char*>( glGetString( GL_EXTENSIONS ) ) << "\n";
3210 QGL_sharedContextCreated( GlobalOpenGL() );
3212 ShaderCache_extensionsInitialised();
3214 GlobalShaderCache().realise();
3218 /* win32 is dodgy here, just use courier new then */
3219 g_font = glfont_create( "arial 9" );
3221 GtkSettings *settings = gtk_settings_get_default();
3223 g_object_get( settings, "gtk-font-name", &fontname, NULL );
3224 g_font = glfont_create( fontname );
3227 GlobalOpenGL().m_font = g_font;
3230 void GlobalGL_sharedContextDestroyed(){
3231 Textures_Unrealise();
3232 GlobalShaderCache().unrealise();
3234 QGL_sharedContextDestroyed( GlobalOpenGL() );
3238 void Layout_constructPreferences( PreferencesPage& page ){
3240 const char* layouts[] = { "window1.png", "window2.png", "window3.png", "window4.png" };
3241 page.appendRadioIcons(
3243 STRING_ARRAY_RANGE( layouts ),
3244 LatchedIntImportCaller( g_Layout_viewStyle ),
3245 IntExportCaller( g_Layout_viewStyle.m_latched )
3248 page.appendCheckBox(
3249 "", "Detachable Menus",
3250 LatchedBoolImportCaller( g_Layout_enableDetachableMenus ),
3251 BoolExportCaller( g_Layout_enableDetachableMenus.m_latched )
3253 page.appendCheckBox(
3255 LatchedBoolImportCaller( g_Layout_enableMainToolbar ),
3256 BoolExportCaller( g_Layout_enableMainToolbar.m_latched )
3258 if ( !string_empty( g_pGameDescription->getKeyValue( "no_patch" ) ) ) {
3259 page.appendCheckBox(
3260 "", "Patch Toolbar",
3261 LatchedBoolImportCaller( g_Layout_enablePatchToolbar ),
3262 BoolExportCaller( g_Layout_enablePatchToolbar.m_latched )
3265 page.appendCheckBox(
3266 "", "Plugin Toolbar",
3267 LatchedBoolImportCaller( g_Layout_enablePluginToolbar ),
3268 BoolExportCaller( g_Layout_enablePluginToolbar.m_latched )
3270 page.appendCheckBox(
3271 "", "Filter Toolbar",
3272 LatchedBoolImportCaller( g_Layout_enableFilterToolbar ),
3273 BoolExportCaller( g_Layout_enableFilterToolbar.m_latched )
3277 void Layout_constructPage( PreferenceGroup& group ){
3278 PreferencesPage page( group.createPage( "Layout", "Layout Preferences" ) );
3279 Layout_constructPreferences( page );
3282 void Layout_registerPreferencesPage(){
3283 PreferencesDialog_addInterfacePage( FreeCaller1<PreferenceGroup&, Layout_constructPage>() );
3286 void MainFrame_toggleFullscreen(){
3287 GtkWindow* wnd = MainFrame_getWindow();
3288 if( gdk_window_get_state( GTK_WIDGET( wnd )->window ) & GDK_WINDOW_STATE_FULLSCREEN ){
3289 //some portion of buttsex, because gtk_window_unfullscreen doesn't work correctly after calling some modal window
3290 bool maximize = ( gdk_window_get_state( GTK_WIDGET( wnd )->window ) & GDK_WINDOW_STATE_MAXIMIZED );
3291 gtk_window_unfullscreen( wnd );
3293 gtk_window_unmaximize( wnd );
3294 gtk_window_maximize( wnd );
3297 gtk_window_move( wnd, g_layout_globals.m_position.x, g_layout_globals.m_position.y );
3298 gtk_window_resize( wnd, g_layout_globals.m_position.w, g_layout_globals.m_position.h );
3302 gtk_window_fullscreen( wnd );
3309 MaximizeView(): m_maximized( false ){
3312 return m_maximized ? restore() : maximize();
3321 m_maximized = false;
3322 gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), m_vSplitPos );
3323 gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), m_vSplit2Pos );
3324 gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), m_hSplitPos );
3329 m_vSplitPos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_vSplit ) );
3330 m_vSplit2Pos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_vSplit2 ) );
3331 m_hSplitPos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_hSplit ) );
3333 int vSplitX, vSplitY, vSplit2X, vSplit2Y, hSplitX, hSplitY;
3334 gdk_window_get_origin( g_pParentWnd->m_vSplit->window, &vSplitX, &vSplitY );
3335 gdk_window_get_origin( g_pParentWnd->m_vSplit2->window, &vSplit2X, &vSplit2Y );
3336 gdk_window_get_origin( g_pParentWnd->m_hSplit->window, &hSplitX, &hSplitY );
3338 vSplitY += m_vSplitPos;
3339 vSplit2Y += m_vSplit2Pos;
3340 hSplitX += m_hSplitPos;
3343 Sys_GetCursorPos( MainFrame_getWindow(), &cur_x, &cur_y );
3345 if( cur_x > hSplitX ){
3346 gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), 0 );
3349 gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), 9999 );
3351 if( cur_y > vSplitY ){
3352 gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), 0 );
3355 gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), 9999 );
3357 if( cur_y > vSplit2Y ){
3358 gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), 0 );
3361 gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), 9999 );
3366 MaximizeView g_maximizeview;
3368 void Maximize_View(){
3369 if( g_pParentWnd != 0 && g_pParentWnd->m_vSplit != 0 && g_pParentWnd->m_vSplit2 != 0 && g_pParentWnd->m_hSplit != 0 )
3370 g_maximizeview.toggle();
3374 #include "preferencesystem.h"
3375 #include "stringio.h"
3377 void MainFrame_Construct(){
3378 GlobalCommands_insert( "OpenManual", FreeCaller<OpenHelpURL>(), Accelerator( GDK_F1 ) );
3380 GlobalCommands_insert( "Sleep", FreeCaller<thunk_OnSleep>(), Accelerator( 'P', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
3381 GlobalCommands_insert( "NewMap", FreeCaller<NewMap>() );
3382 GlobalCommands_insert( "OpenMap", FreeCaller<OpenMap>(), Accelerator( 'O', (GdkModifierType)GDK_CONTROL_MASK ) );
3383 GlobalCommands_insert( "ImportMap", FreeCaller<ImportMap>() );
3384 GlobalCommands_insert( "SaveMap", FreeCaller<SaveMap>(), Accelerator( 'S', (GdkModifierType)GDK_CONTROL_MASK ) );
3385 GlobalCommands_insert( "SaveMapAs", FreeCaller<SaveMapAs>() );
3386 GlobalCommands_insert( "SaveSelected", FreeCaller<ExportMap>() );
3387 GlobalCommands_insert( "SaveRegion", FreeCaller<SaveRegion>() );
3388 GlobalCommands_insert( "RefreshReferences", FreeCaller<RefreshReferences>() );
3389 GlobalCommands_insert( "ProjectSettings", FreeCaller<DoProjectSettings>() );
3390 GlobalCommands_insert( "CheckForUpdate", FreeCaller<OpenUpdateURL>() );
3391 GlobalCommands_insert( "Exit", FreeCaller<Exit>() );
3393 GlobalCommands_insert( "Undo", FreeCaller<Undo>(), Accelerator( 'Z', (GdkModifierType)GDK_CONTROL_MASK ) );
3394 GlobalCommands_insert( "Redo", FreeCaller<Redo>(), Accelerator( 'Y', (GdkModifierType)GDK_CONTROL_MASK ) );
3395 GlobalCommands_insert( "Copy", FreeCaller<Copy>(), Accelerator( 'C', (GdkModifierType)GDK_CONTROL_MASK ) );
3396 GlobalCommands_insert( "Paste", FreeCaller<Paste>(), Accelerator( 'V', (GdkModifierType)GDK_CONTROL_MASK ) );
3397 GlobalCommands_insert( "PasteToCamera", FreeCaller<PasteToCamera>(), Accelerator( 'V', (GdkModifierType)GDK_SHIFT_MASK ) );
3398 GlobalCommands_insert( "CloneSelection", FreeCaller<Selection_Clone>(), Accelerator( GDK_space ) );
3399 GlobalCommands_insert( "CloneSelectionAndMakeUnique", FreeCaller<Selection_Clone_MakeUnique>(), Accelerator( GDK_space, (GdkModifierType)GDK_SHIFT_MASK ) );
3400 // GlobalCommands_insert( "DeleteSelection", FreeCaller<deleteSelection>(), Accelerator( GDK_BackSpace ) );
3401 GlobalCommands_insert( "DeleteSelection2", FreeCaller<deleteSelection>(), Accelerator( GDK_BackSpace ) );
3402 GlobalCommands_insert( "DeleteSelection", FreeCaller<deleteSelection>(), Accelerator( 'Z' ) );
3403 GlobalCommands_insert( "ParentSelection", FreeCaller<Scene_parentSelected>() );
3404 // GlobalCommands_insert( "UnSelectSelection", FreeCaller<Selection_Deselect>(), Accelerator( GDK_Escape ) );
3405 GlobalCommands_insert( "UnSelectSelection2", FreeCaller<Selection_Deselect>(), Accelerator( GDK_Escape ) );
3406 GlobalCommands_insert( "UnSelectSelection", FreeCaller<Selection_Deselect>(), Accelerator( 'C' ) );
3407 GlobalCommands_insert( "InvertSelection", FreeCaller<Select_Invert>(), Accelerator( 'I' ) );
3408 GlobalCommands_insert( "SelectInside", FreeCaller<Select_Inside>() );
3409 GlobalCommands_insert( "SelectTouching", FreeCaller<Select_Touching>() );
3410 GlobalCommands_insert( "ExpandSelectionToEntities", FreeCaller<Scene_ExpandSelectionToEntities>(), Accelerator( 'E', (GdkModifierType)GDK_SHIFT_MASK ) );
3411 GlobalCommands_insert( "Preferences", FreeCaller<PreferencesDialog_showDialog>(), Accelerator( 'P' ) );
3413 GlobalCommands_insert( "ToggleConsole", FreeCaller<Console_ToggleShow>(), Accelerator( 'O' ) );
3414 GlobalCommands_insert( "ToggleEntityInspector", FreeCaller<EntityInspector_ToggleShow>(), Accelerator( 'N' ) );
3415 GlobalCommands_insert( "EntityList", FreeCaller<EntityList_toggleShown>(), Accelerator( 'L' ) );
3417 // GlobalCommands_insert( "ShowHidden", FreeCaller<Select_ShowAllHidden>(), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) );
3418 // GlobalCommands_insert( "HideSelected", FreeCaller<HideSelected>(), Accelerator( 'H' ) );
3419 Select_registerCommands();
3421 GlobalToggles_insert( "DragVertices", FreeCaller<SelectVertexMode>(), ToggleItem::AddCallbackCaller( g_vertexMode_button ), Accelerator( 'V' ) );
3422 GlobalToggles_insert( "DragEdges", FreeCaller<SelectEdgeMode>(), ToggleItem::AddCallbackCaller( g_edgeMode_button ), Accelerator( 'E' ) );
3423 GlobalToggles_insert( "DragFaces", FreeCaller<SelectFaceMode>(), ToggleItem::AddCallbackCaller( g_faceMode_button ), Accelerator( 'F' ) );
3425 GlobalCommands_insert( "ArbitraryRotation", FreeCaller<DoRotateDlg>(), Accelerator( 'R', (GdkModifierType)GDK_SHIFT_MASK ) );
3426 GlobalCommands_insert( "ArbitraryScale", FreeCaller<DoScaleDlg>(), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
3428 GlobalCommands_insert( "BuildMenuCustomize", FreeCaller<DoBuildMenu>() );
3429 GlobalCommands_insert( "Build_runRecentExecutedBuild", FreeCaller<Build_runRecentExecutedBuild>(), Accelerator( GDK_F5 ) );
3431 GlobalCommands_insert( "FindBrush", FreeCaller<DoFind>() );
3433 GlobalCommands_insert( "MapInfo", FreeCaller<DoMapInfo>(), Accelerator( 'M' ) );
3436 GlobalToggles_insert( "ToggleClipper", FreeCaller<ClipperMode>(), ToggleItem::AddCallbackCaller( g_clipper_button ), Accelerator( 'X' ) );
3438 GlobalToggles_insert( "MouseTranslate", FreeCaller<TranslateMode>(), ToggleItem::AddCallbackCaller( g_translatemode_button ), Accelerator( 'W' ) );
3439 GlobalToggles_insert( "MouseRotate", FreeCaller<RotateMode>(), ToggleItem::AddCallbackCaller( g_rotatemode_button ), Accelerator( 'R' ) );
3440 GlobalToggles_insert( "MouseScale", FreeCaller<ScaleMode>(), ToggleItem::AddCallbackCaller( g_scalemode_button ) );
3441 GlobalToggles_insert( "MouseDrag", FreeCaller<DragMode>(), ToggleItem::AddCallbackCaller( g_dragmode_button ) );
3442 GlobalCommands_insert( "MouseRotateOrScale", FreeCaller<ToggleRotateScaleModes>() );
3443 GlobalCommands_insert( "MouseDragOrScale", FreeCaller<ToggleDragScaleModes>(), Accelerator( 'Q' ) );
3445 GlobalCommands_insert( "gtkThemeDlg", FreeCaller<gtkThemeDlg>() );
3446 GlobalCommands_insert( "ColorSchemeOriginal", FreeCaller<ColorScheme_Original>() );
3447 GlobalCommands_insert( "ColorSchemeQER", FreeCaller<ColorScheme_QER>() );
3448 GlobalCommands_insert( "ColorSchemeBlackAndGreen", FreeCaller<ColorScheme_Black>() );
3449 GlobalCommands_insert( "ColorSchemeYdnar", FreeCaller<ColorScheme_Ydnar>() );
3450 GlobalCommands_insert( "ChooseTextureBackgroundColor", makeCallback( g_ColoursMenu.m_textureback ) );
3451 GlobalCommands_insert( "ChooseGridBackgroundColor", makeCallback( g_ColoursMenu.m_xyback ) );
3452 GlobalCommands_insert( "ChooseGridMajorColor", makeCallback( g_ColoursMenu.m_gridmajor ) );
3453 GlobalCommands_insert( "ChooseGridMinorColor", makeCallback( g_ColoursMenu.m_gridminor ) );
3454 GlobalCommands_insert( "ChooseGridTextColor", makeCallback( g_ColoursMenu.m_gridtext ) );
3455 GlobalCommands_insert( "ChooseGridBlockColor", makeCallback( g_ColoursMenu.m_gridblock ) );
3456 GlobalCommands_insert( "ChooseBrushColor", makeCallback( g_ColoursMenu.m_brush ) );
3457 GlobalCommands_insert( "ChooseCameraBackgroundColor", makeCallback( g_ColoursMenu.m_cameraback ) );
3458 GlobalCommands_insert( "ChooseSelectedBrushColor", makeCallback( g_ColoursMenu.m_selectedbrush ) );
3459 GlobalCommands_insert( "ChooseCameraSelectedBrushColor", makeCallback( g_ColoursMenu.m_selectedbrush3d ) );
3460 GlobalCommands_insert( "ChooseClipperColor", makeCallback( g_ColoursMenu.m_clipper ) );
3461 GlobalCommands_insert( "ChooseOrthoViewNameColor", makeCallback( g_ColoursMenu.m_viewname ) );
3463 GlobalCommands_insert( "Fullscreen", FreeCaller<MainFrame_toggleFullscreen>(), Accelerator( GDK_F11 ) );
3464 GlobalCommands_insert( "MaximizeView", FreeCaller<Maximize_View>(), Accelerator( GDK_F12 ) );
3467 GlobalCommands_insert( "CSGSubtract", FreeCaller<CSG_Subtract>(), Accelerator( 'U', (GdkModifierType)GDK_SHIFT_MASK ) );
3468 GlobalCommands_insert( "CSGMerge", FreeCaller<CSG_Merge>(), Accelerator( 'U', (GdkModifierType)GDK_CONTROL_MASK ) );
3469 GlobalCommands_insert( "CSGroom", FreeCaller<CSG_MakeRoom>() );
3470 GlobalCommands_insert( "CSGTool", FreeCaller<CSG_Tool>() );
3472 Grid_registerCommands();
3474 GlobalCommands_insert( "SnapToGrid", FreeCaller<Selection_SnapToGrid>(), Accelerator( 'G', (GdkModifierType)GDK_CONTROL_MASK ) );
3476 GlobalCommands_insert( "SelectAllOfType", FreeCaller<Select_AllOfType>(), Accelerator( 'A', (GdkModifierType)GDK_SHIFT_MASK ) );
3478 GlobalCommands_insert( "TexRotateClock", FreeCaller<Texdef_RotateClockwise>(), Accelerator( GDK_Next, (GdkModifierType)GDK_SHIFT_MASK ) );
3479 GlobalCommands_insert( "TexRotateCounter", FreeCaller<Texdef_RotateAntiClockwise>(), Accelerator( GDK_Prior, (GdkModifierType)GDK_SHIFT_MASK ) );
3480 GlobalCommands_insert( "TexScaleUp", FreeCaller<Texdef_ScaleUp>(), Accelerator( GDK_Up, (GdkModifierType)GDK_CONTROL_MASK ) );
3481 GlobalCommands_insert( "TexScaleDown", FreeCaller<Texdef_ScaleDown>(), Accelerator( GDK_Down, (GdkModifierType)GDK_CONTROL_MASK ) );
3482 GlobalCommands_insert( "TexScaleLeft", FreeCaller<Texdef_ScaleLeft>(), Accelerator( GDK_Left, (GdkModifierType)GDK_CONTROL_MASK ) );
3483 GlobalCommands_insert( "TexScaleRight", FreeCaller<Texdef_ScaleRight>(), Accelerator( GDK_Right, (GdkModifierType)GDK_CONTROL_MASK ) );
3484 GlobalCommands_insert( "TexShiftUp", FreeCaller<Texdef_ShiftUp>(), Accelerator( GDK_Up, (GdkModifierType)GDK_SHIFT_MASK ) );
3485 GlobalCommands_insert( "TexShiftDown", FreeCaller<Texdef_ShiftDown>(), Accelerator( GDK_Down, (GdkModifierType)GDK_SHIFT_MASK ) );
3486 GlobalCommands_insert( "TexShiftLeft", FreeCaller<Texdef_ShiftLeft>(), Accelerator( GDK_Left, (GdkModifierType)GDK_SHIFT_MASK ) );
3487 GlobalCommands_insert( "TexShiftRight", FreeCaller<Texdef_ShiftRight>(), Accelerator( GDK_Right, (GdkModifierType)GDK_SHIFT_MASK ) );
3489 GlobalCommands_insert( "MoveSelectionDOWN", FreeCaller<Selection_MoveDown>(), Accelerator( GDK_KP_Subtract ) );
3490 GlobalCommands_insert( "MoveSelectionUP", FreeCaller<Selection_MoveUp>(), Accelerator( GDK_KP_Add ) );
3492 GlobalCommands_insert( "SelectNudgeLeft", FreeCaller<Selection_NudgeLeft>(), Accelerator( GDK_Left, (GdkModifierType)GDK_MOD1_MASK ) );
3493 GlobalCommands_insert( "SelectNudgeRight", FreeCaller<Selection_NudgeRight>(), Accelerator( GDK_Right, (GdkModifierType)GDK_MOD1_MASK ) );
3494 GlobalCommands_insert( "SelectNudgeUp", FreeCaller<Selection_NudgeUp>(), Accelerator( GDK_Up, (GdkModifierType)GDK_MOD1_MASK ) );
3495 GlobalCommands_insert( "SelectNudgeDown", FreeCaller<Selection_NudgeDown>(), Accelerator( GDK_Down, (GdkModifierType)GDK_MOD1_MASK ) );
3497 Patch_registerCommands();
3498 XYShow_registerCommands();
3500 typedef FreeCaller1<const Selectable&, ComponentMode_SelectionChanged> ComponentModeSelectionChangedCaller;
3501 GlobalSelectionSystem().addSelectionChangeCallback( ComponentModeSelectionChangedCaller() );
3503 GlobalPreferenceSystem().registerPreference( "DetachableMenus", BoolImportStringCaller( g_Layout_enableDetachableMenus.m_latched ), BoolExportStringCaller( g_Layout_enableDetachableMenus.m_latched ) );
3504 GlobalPreferenceSystem().registerPreference( "MainToolBar", BoolImportStringCaller( g_Layout_enableMainToolbar.m_latched ), BoolExportStringCaller( g_Layout_enableMainToolbar.m_latched ) );
3505 GlobalPreferenceSystem().registerPreference( "PatchToolBar", BoolImportStringCaller( g_Layout_enablePatchToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePatchToolbar.m_latched ) );
3506 GlobalPreferenceSystem().registerPreference( "PluginToolBar", BoolImportStringCaller( g_Layout_enablePluginToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePluginToolbar.m_latched ) );
3507 GlobalPreferenceSystem().registerPreference( "FilterToolBar", BoolImportStringCaller( g_Layout_enableFilterToolbar.m_latched ), BoolExportStringCaller( g_Layout_enableFilterToolbar.m_latched ) );
3508 GlobalPreferenceSystem().registerPreference( "QE4StyleWindows", IntImportStringCaller( g_Layout_viewStyle.m_latched ), IntExportStringCaller( g_Layout_viewStyle.m_latched ) );
3509 GlobalPreferenceSystem().registerPreference( "XYHeight", IntImportStringCaller( g_layout_globals.nXYHeight ), IntExportStringCaller( g_layout_globals.nXYHeight ) );
3510 GlobalPreferenceSystem().registerPreference( "XYWidth", IntImportStringCaller( g_layout_globals.nXYWidth ), IntExportStringCaller( g_layout_globals.nXYWidth ) );
3511 GlobalPreferenceSystem().registerPreference( "CamWidth", IntImportStringCaller( g_layout_globals.nCamWidth ), IntExportStringCaller( g_layout_globals.nCamWidth ) );
3512 GlobalPreferenceSystem().registerPreference( "CamHeight", IntImportStringCaller( g_layout_globals.nCamHeight ), IntExportStringCaller( g_layout_globals.nCamHeight ) );
3514 GlobalPreferenceSystem().registerPreference( "State", IntImportStringCaller( g_layout_globals.nState ), IntExportStringCaller( g_layout_globals.nState ) );
3515 GlobalPreferenceSystem().registerPreference( "PositionX", IntImportStringCaller( g_layout_globals.m_position.x ), IntExportStringCaller( g_layout_globals.m_position.x ) );
3516 GlobalPreferenceSystem().registerPreference( "PositionY", IntImportStringCaller( g_layout_globals.m_position.y ), IntExportStringCaller( g_layout_globals.m_position.y ) );
3517 GlobalPreferenceSystem().registerPreference( "Width", IntImportStringCaller( g_layout_globals.m_position.w ), IntExportStringCaller( g_layout_globals.m_position.w ) );
3518 GlobalPreferenceSystem().registerPreference( "Height", IntImportStringCaller( g_layout_globals.m_position.h ), IntExportStringCaller( g_layout_globals.m_position.h ) );
3520 GlobalPreferenceSystem().registerPreference( "CamWnd", WindowPositionTrackerImportStringCaller( g_posCamWnd ), WindowPositionTrackerExportStringCaller( g_posCamWnd ) );
3521 GlobalPreferenceSystem().registerPreference( "XYWnd", WindowPositionTrackerImportStringCaller( g_posXYWnd ), WindowPositionTrackerExportStringCaller( g_posXYWnd ) );
3522 GlobalPreferenceSystem().registerPreference( "YZWnd", WindowPositionTrackerImportStringCaller( g_posYZWnd ), WindowPositionTrackerExportStringCaller( g_posYZWnd ) );
3523 GlobalPreferenceSystem().registerPreference( "XZWnd", WindowPositionTrackerImportStringCaller( g_posXZWnd ), WindowPositionTrackerExportStringCaller( g_posXZWnd ) );
3525 GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) );
3527 GlobalPreferenceSystem().registerPreference( "NudgeAfterClone", BoolImportStringCaller( g_bNudgeAfterClone ), BoolExportStringCaller( g_bNudgeAfterClone ) );
3528 if ( g_strEnginePath.empty() )
3530 g_strEnginePath_was_empty_1st_start = true;
3531 const char* ENGINEPATH_ATTRIBUTE =
3532 #if defined( WIN32 )
3534 #elif defined( __linux__ ) || defined ( __FreeBSD__ )
3536 #elif defined( __APPLE__ )
3539 #error "unknown platform"
3542 StringOutputStream path( 256 );
3543 path << DirectoryCleaned( g_pGameDescription->getRequiredKeyValue( ENGINEPATH_ATTRIBUTE ) );
3544 g_strEnginePath = path.c_str();
3545 GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) );
3550 g_Layout_viewStyle.useLatched();
3551 g_Layout_enableDetachableMenus.useLatched();
3552 g_Layout_enableMainToolbar.useLatched();
3553 g_Layout_enablePatchToolbar.useLatched();
3554 g_Layout_enablePluginToolbar.useLatched();
3555 g_Layout_enableFilterToolbar.useLatched();
3557 Layout_registerPreferencesPage();
3558 Paths_registerPreferencesPage();
3559 PreferencesDialog_addSettingsPreferences( FreeCaller1<PreferencesPage&, Nudge_constructPreferences>() );
3561 g_brushCount.setCountChangedCallback( FreeCaller<QE_brushCountChanged>() );
3562 g_entityCount.setCountChangedCallback( FreeCaller<QE_entityCountChanged>() );
3563 GlobalEntityCreator().setCounter( &g_entityCount );
3565 GLWidget_sharedContextCreated = GlobalGL_sharedContextCreated;
3566 GLWidget_sharedContextDestroyed = GlobalGL_sharedContextDestroyed;
3568 GlobalEntityClassManager().attach( g_WorldspawnColourEntityClassObserver );
3571 void MainFrame_Destroy(){
3572 GlobalEntityClassManager().detach( g_WorldspawnColourEntityClassObserver );
3574 GlobalEntityCreator().setCounter( 0 );
3575 g_entityCount.setCountChangedCallback( Callback() );
3576 g_brushCount.setCountChangedCallback( Callback() );
3580 void GLWindow_Construct(){
3581 // GlobalPreferenceSystem().registerPreference( "MouseButtons", IntImportStringCaller( g_glwindow_globals.m_nMouseType ), IntExportStringCaller( g_glwindow_globals.m_nMouseType ) );
3584 void GLWindow_Destroy(){