X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=radiant%2Fmainframe.cpp;h=6858aa2c288d9a525e36a22642dda76dfa92ba9f;hp=2ccd2c385e8093a76d85f82da298eaa5b49ac47a;hb=771bab14ffa4b131540b125aff6554265662f874;hpb=c0f477bd045a11bf3cdd04bb1b6a76674095b076;ds=sidebyside diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 2ccd2c38..6858aa2c 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -1,23 +1,23 @@ /* -Copyright (C) 1999-2007 id Software, Inc. and contributors. -For a list of contributors, see the accompanying CONTRIBUTORS file. + Copyright (C) 1999-2006 Id Software, Inc. and contributors. + For a list of contributors, see the accompanying CONTRIBUTORS file. -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GtkRadiant is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + GtkRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ // // Main Window for Q3Radiant @@ -25,7769 +25,3347 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // Leonardo Zide (leo@lokigames.com) // -#include "stdafx.h" -#ifdef _WIN32 -extern "C" { -#include -#define COMPILE_MULTIMON_STUBS -#include -} -#endif -#include -#include -#include -#include -#include -#if defined (__linux__) || defined (__APPLE__) - #include -#endif -#include "gtkmisc.h" -#include "groupdialog.h" -#include "patchdialog.h" -#include "filters.h" +#include "mainframe.h" -// use this to verbose what happens with the beyboard -#ifdef _DEBUG -// #define DBG_KBD -#endif +#include "debugging/debugging.h" +#include "version.h" -// globals -CString g_strAppPath; ///< holds the full path of the executable -CString g_strDTDPath; ///< path to the DTD files -/*! -see http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=297 for the two below -*/ -CString g_pidFile; ///< the global .pid file (only for global part of the startup) -CString g_pidGameFile; ///< the game-specific .pid file -CString g_strBitmapsPath; // directory where the bitmaps are stored +#include "ifilesystem.h" +#include "iundo.h" +#include "ifilter.h" +#include "itoolbar.h" +#include "editable.h" +#include "ientity.h" +#include "ishaders.h" +#include "igl.h" +#include "moduleobserver.h" -/*! -points to the game tools directory, for instance -C:\Program Files\Quake III Arena\GtkRadiant -(or other games) -this is one of the main variables that are configured by the game selection on startup -/plugins -/modules -and also q3map, bspc -*/ -CString g_strGameToolsPath; ///< this is set by g_PrefsDlg.mGamesDialog -CGameDescription *g_pGameDescription; ///< shortcut to g_PrefsDlg.mGamesDialog.m_pCurrentDescription -CString g_strPluginsDir; ///< name of plugins directory, always sub-directory of toolspath -CString g_strModulesDir; ///< name of modules directory, always sub-directory of toolspath +#include -/*! -directory for temp files -NOTE: on *nix this is were we check for .pid -*/ -CString g_strTempPath; -MainFrame* g_pParentWnd = NULL; // used to precast to CMainFrame -PrefsDlg g_Preferences; // global prefs instance -PrefsDlg& g_PrefsDlg = g_Preferences; // reference used throughout -int g_nUpdateBits = 0; // window update flags -bool g_bScreenUpdates = true; // whether window painting is active, used in a few places - // to disable updates for speed reasons - // both of the above should be made members of CMainFrame -int g_bIgnoreCommands; // Used to ignore commands when checking menus/toolbars -GSList *g_BSPFrontendCommands; // List of commands in the BSP menu - -const int CMD_TEXTUREWAD_END = CMD_TEXTUREWAD + MAX_TEXTUREDIRS - 1; -const int CMD_BSPCOMMAND_END = CMD_BSPCOMMAND + 127; - -extern bool g_bCrossHairs; -extern int g_argc; -extern char** g_argv; -extern PatchDialog g_PatchDialog; - -GtkAccelGroup* global_accel; - -void Select_Ungroup (); - -// command mapping stuff -// -// m_strCommand is the command string -// m_nKey is the GDK_??? equivelant -// m_nModifiers are key states as follows -// bit -// 1 - shift -// 2 - alt -// 4 - control -// 8 - press only -// -#define SPEED_MOVE 32 -#define SPEED_TURN 22.5 +#include -// NOTE: the menu item field is REQUIRED, Gtk uses it to bind the keyboard shortcut -// - if you add a command here and you don't want a menu item, use the "hidden" menu -// - if you decide to add a menu item, check if it's not in the "hidden" menu already -SCommandInfo g_Commands[] = -{ - {"CycleOutlineStyle", 'J', 0x00, ID_SELECTION_OUTLINESTYLE, "menu_selection_outlinestyle"}, - {"CSGMerge", 'U', 0x04, ID_SELECTION_CSGMERGE, "menu_selection_csgmerge"}, - {"CSGSubtract", 'U', 0x01, ID_SELECTION_CSGSUBTRACT, "menu_selection_csgsubstract"}, - // {"ViewGroups", 'G', 0x00, ID_VIEW_GROUPS, "menu_view_groups"}, (temporary disabled) - {"HideSelected", 'H', 0x00, ID_VIEW_HIDESHOW_HIDESELECTED, "menu_view_hideshow_hideselected"}, - {"ShowHidden", 'H', 0x01, ID_VIEW_HIDESHOW_SHOWHIDDEN, "menu_view_hideshow_showhidden"}, - {"BendMode", 'B', 0x00, ID_PATCH_BEND, "menu_patch_bend"}, - {"FitTexture", 'B', 0x01, IDC_BTN_FACEFIT, "menu_idc_btn_facefit"}, - {"ViewTextures", 'T', 0, ID_VIEW_TEXTURE, "menu_view_texture"}, - {"ThickenPatch", 'T', 0x04, ID_CURVE_THICKEN, "menu_curve_thicken"}, - {"MakeOverlayPatch", 'Y', 0, ID_CURVE_OVERLAY_SET, "menu_curve_overlay_set"}, - {"ClearPatchOverlays", 'L', 0x04, ID_CURVE_OVERLAY_CLEAR, "menu_curve_overlay_clear"}, - {"SurfaceInspector", 'S', 0, ID_TEXTURES_INSPECTOR, "menu_textures_inspector"}, - {"PatchInspector", 'S', 0x01, ID_PATCH_INSPECTOR, "menu_patch_inspector"}, - {"RedisperseRows", 'E', 0x04, ID_CURVE_REDISPERSE_ROWS, "menu_curve_redisperse_rows"}, - {"RedisperseIntermediateCols", 'E', 0x05, ID_CURVE_REDISPERSE_INTERMEDIATE_COLS, "menu_curve_redisperse_cols"}, - {"InvertCurveTextureX", 'I', 0x05, ID_CURVE_NEGATIVETEXTUREY, "menu_curve_negativetexturey"}, - {"InvertCurveTextureY", 'I', 0x01, ID_CURVE_NEGATIVETEXTUREX, "menu_curve_negativetexturex"}, - {"InvertCurve", 'I', 0x04, ID_CURVE_NEGATIVE, "menu_curve_negative"}, - {"IncPatchColumn", GDK_KP_Add, 0x05, ID_CURVE_INSERTCOLUMN, "menu_curve_insertcolumn"}, - {"IncPatchRow", GDK_KP_Add, 0x04, ID_CURVE_INSERTROW, "menu_curve_insertrow"}, - {"DecPatchColumn", GDK_KP_Subtract, 0x05, ID_CURVE_DELETECOLUMN, "menu_curve_deletecolumn"}, - {"DecPatchRow", GDK_KP_Subtract, 0x04, ID_CURVE_DELETEROW, "menu_curve_deleterow"}, - {"Patch TAB", GDK_Tab, 0x00, ID_PATCH_TAB, "menu_patch_tab"}, - {"Patch TAB", GDK_Tab, 0x01, ID_PATCH_TAB, "menu_patch_tab"}, - {"SelectNudgeDown", GDK_Down, 0x02, ID_SELECTION_SELECT_NUDGEDOWN, "menu_selection_select_nudgedown"}, - {"EntityColor",'K', 0, ID_MISC_SELECTENTITYCOLOR, "menu_misc_select_entitycolor"}, - {"CameraForward", GDK_Up, 0, ID_CAMERA_FORWARD, "menu_camera_forward"}, - {"CameraBack", GDK_Down, 0, ID_CAMERA_BACK, "menu_camera_back"}, - {"CameraLeft", GDK_Left, 0, ID_CAMERA_LEFT, "menu_camera_left"}, - {"CameraRight", GDK_Right, 0, ID_CAMERA_RIGHT, "menu_camera_right"}, - {"CameraUp", 'D', 0, ID_CAMERA_UP, "menu_camera_up"}, - {"CameraDown", 'C', 0, ID_CAMERA_DOWN, "menu_camera_down"}, - {"CameraAngleUp", 'A', 0, ID_CAMERA_ANGLEUP, "menu_camera_angleup"}, - {"CameraAngleDown", 'Z', 0, ID_CAMERA_ANGLEDOWN, "menu_camera_angledown"}, - {"CameraStrafeRight", GDK_period, 0, ID_CAMERA_STRAFERIGHT, "menu_camera_straferight"}, - {"CameraStrafeLeft", GDK_comma, 0, ID_CAMERA_STRAFELEFT, "menu_camera_strafeleft"}, - {"ToggleGrid", '0', 0, ID_GRID_TOGGLE, "menu_grid_toggle"}, - {"SetGrid1", '1', 0, ID_GRID_1, "menu_grid_1"}, - {"SetGrid2", '2', 0, ID_GRID_2, "menu_grid_2"}, - {"SetGrid4", '3', 0, ID_GRID_4, "menu_grid_4"}, - {"SetGrid8", '4', 0, ID_GRID_8, "menu_grid_8"}, - {"SetGrid16", '5', 0, ID_GRID_16, "menu_grid_16"}, - {"SetGrid32", '6', 0, ID_GRID_32, "menu_grid_32"}, - {"SetGrid64", '7', 0, ID_GRID_64, "menu_grid_64"}, - {"SetGrid128", '8', 0, ID_GRID_128, "menu_grid_128"}, - {"SetGrid256", '9', 0, ID_GRID_256, "menu_grid_256"}, - {"DragEdges", 'E', 0, ID_SELECTION_DRAGEDGES, "menu_selection_dragedges"}, - {"DragVertices", 'V', 0, ID_SELECTION_DRAGVERTECIES, "menu_selection_dragvertecies"}, - {"ViewEntityInfo", 'N', 0, ID_VIEW_ENTITY, "menu_view_entity"}, - // {"ViewConsole", 'O', 0, ID_VIEW_CONSOLE, "menu_0,"}, - {"CloneSelection", GDK_space, 0, ID_SELECTION_CLONE, "menu_selection_clone"}, - {"DeleteSelection", GDK_BackSpace, 0, ID_SELECTION_DELETE, "menu_selection_delete"}, - {"UnSelectSelection", GDK_Escape, 0, ID_SELECTION_DESELECT, "menu_selection_deselect"}, - {"CenterView", GDK_End, 0, ID_VIEW_CENTER, "menu_view_center"}, - {"ZoomOut", GDK_Insert, 0, ID_VIEW_ZOOMOUT, "menu_view_zoomout"}, - {"ZoomIn", GDK_Delete, 0, ID_VIEW_ZOOMIN, "menu_view_zoomin"}, - {"UpFloor", GDK_Prior, 0, ID_VIEW_UPFLOOR, "menu_view_upfloor"}, - {"DownFloor", GDK_Next, 0, ID_VIEW_DOWNFLOOR, "menu_view_downfloor"}, - {"ToggleClipper", 'X', 0, ID_VIEW_CLIPPER, "menu_view_clipper"}, - {"ToggleCrosshairs", 'X', 0x01, ID_VIEW_CROSSHAIR, "menu_view_crosshair"}, - {"TogTexLock", 'T', 0x01, ID_TOGGLE_LOCK, "menu_toggle_lock"}, - {"TogTexRotLock", 'R', 0x01, ID_TOGGLE_ROTATELOCK, "menu_toggle_rotatelock"}, - {"ToggleRealtime", 'R', 0x04, ID_VIEW_CAMERAUPDATE, "menu_view_cameraupdate"}, - {"EntityList", 'L', 0, ID_EDIT_ENTITYINFO, "menu_edit_entityinfo"}, - {"Preferences", 'P', 0, ID_PREFS, "menu_prefs"}, - {"ToggleCamera", 'C', 0x05, ID_TOGGLECAMERA, "menu_togglecamera"}, - {"ToggleConsole", 'O', 0, ID_TOGGLECONSOLE, "menu_toggleconsole"}, - {"ToggleView", 'V', 0x05, ID_TOGGLEVIEW, "menu_toggleview"}, - {"ToggleZ", 'Z', 0x05, ID_TOGGLEZ, "menu_togglez"}, - {"ConnectSelection", 'K', 0x04, ID_SELECTION_CONNECT, "menu_selection_connect"}, - {"Brush3Sided", '3', 0x04, ID_BRUSH_3SIDED, "menu_brush_3sided"}, - {"Brush4Sided", '4', 0x04, ID_BRUSH_4SIDED, "menu_brush_4sided"}, - {"Brush5Sided", '5', 0x04, ID_BRUSH_5SIDED, "menu_brush_5sided"}, - {"Brush6Sided", '6', 0x04, ID_BRUSH_6SIDED, "menu_brush_6sided"}, - {"Brush7Sided", '7', 0x04, ID_BRUSH_7SIDED, "menu_brush_7sided"}, - {"Brush8Sided", '8', 0x04, ID_BRUSH_8SIDED, "menu_brush_8sided"}, - {"Brush9Sided", '9', 0x04, ID_BRUSH_9SIDED, "menu_brush_9sided"}, - {"MatrixTranspose", 'M', 0x05, ID_CURVE_MATRIX_TRANSPOSE, "menu_curve_matrix_transpose"}, - {"MakeDetail", 'M', 0x04, ID_SELECTION_MAKE_DETAIL, "menu_selection_make_detail"}, - {"MapInfo", 'M', 0, ID_EDIT_MAPINFO, "menu_edit_mapinfo"}, - {"NextLeakSpot", 'K', 0x05, ID_MISC_NEXTLEAKSPOT, "menu_misc_nextleakspot"}, - {"PrevLeakSpot", 'L', 0x05, ID_MISC_PREVIOUSLEAKSPOT, "menu_misc_previousleakspot"}, - {"FileOpen", 'O', 0x04, ID_FILE_OPEN, "menu_file_open"}, - {"FileSave", 'S', 0x04, ID_FILE_SAVE, "menu_file_save"}, - //% {"Exit", 'X', 0x04, ID_FILE_EXIT, "menu_file_exit"}, // ydnar: Ctrl+X should be cut - {"CenterXYView", GDK_Tab, 0x05, ID_VIEW_CENTERVIEW, "menu_view_centerview"}, - {"NextView", GDK_Tab, 0x04, ID_VIEW_NEXTVIEW, "menu_view_nextview"}, - {"ClipSelected", GDK_Return, 0x00, ID_CLIP_SELECTED, "menu_clip_selected"}, - {"SplitSelected", GDK_Return, 0x01, ID_SPLIT_SELECTED, "menu_split_selected"}, - {"FlipClip", GDK_Return, 0x04, ID_FLIP_CLIP, "menu_flip_clip"}, - {"MouseRotate", 'R', 0x00, ID_SELECT_MOUSEROTATE, "menu_select_mouserotate"}, - {"Copy", 'C', 0x04, ID_EDIT_COPYBRUSH, "menu_edit_copybrush"}, - {"Paste", 'V', 0x04, ID_EDIT_PASTEBRUSH, "menu_edit_pastebrush"}, - {"PasteToCamera", 'V', RAD_ALT, ID_EDIT_PASTEBRUSHTOCAMERA, "menu_edit_pastebrushtocamera"}, - {"Undo", 'Z', 0x04, ID_EDIT_UNDO, "menu_edit_undo"}, - {"Redo", 'Y', 0x04, ID_EDIT_REDO, "menu_edit_redo"}, - {"ZZoomOut", GDK_Insert, 0x04, ID_VIEW_ZZOOMOUT, "menu_view_zzoomout"}, - {"ZZoomIn", GDK_Delete, 0x04, ID_VIEW_ZZOOMIN, "menu_view_zzoomin"}, - {"TexRotateClock", GDK_Next, 0x01, ID_SELECTION_TEXTURE_ROTATECLOCK, "menu_selection_texture_rotateclock"}, - {"TexRotateCounter", GDK_Prior, 0x01, ID_SELECTION_TEXTURE_ROTATECOUNTER, "menu_selection_texture_rotatecounter"}, - {"TexScaleUp", GDK_Up, 0x04, ID_SELECTION_TEXTURE_SCALEUP, "menu_selection_texture_scaleup"}, - {"TexScaleDown", GDK_Down, 0x04, ID_SELECTION_TEXTURE_SCALEDOWN, "menu_selection_texture_scaledown"}, - {"TexShiftLeft", GDK_Left, 0x01, ID_SELECTION_TEXTURE_SHIFTLEFT, "menu_selection_texture_shiftleft"}, - {"TexShiftRight", GDK_Right, 0x01, ID_SELECTION_TEXTURE_SHIFTRIGHT, "menu_selection_texture_shiftright"}, - {"TexShiftUp", GDK_Up, 0x01, ID_SELECTION_TEXTURE_SHIFTUP, "menu_selection_texture_shiftup"}, - {"TexShiftDown", GDK_Down, 0x01, ID_SELECTION_TEXTURE_SHIFTDOWN, "menu_selection_texture_shiftdown"}, - {"GridDown", '[', 0x00, ID_GRID_PREV, "menu_grid_prev"}, - {"GridUp", ']', 0x00, ID_GRID_NEXT, "menu_grid_next"}, - {"TexScaleLeft", GDK_Left, 0x04, ID_SELECTION_TEXTURE_SCALELEFT, "menu_selection_texture_scaleleft"}, - {"TexScaleRight", GDK_Right, 0x04, ID_SELECTION_TEXTURE_SCALERIGHT, "menu_selection_texture_scaleright"}, - {"CubicClipZoomOut", ']', 0x04, ID_VIEW_CUBEOUT, "menu_view_cubeout"}, - {"CubicClipZoomIn", '[', 0x04, ID_VIEW_CUBEIN, "menu_view_cubein"}, - {"ToggleCubicClip", '\\', 0x04, ID_VIEW_CUBICCLIPPING, "menu_view_cubicclipping"}, - {"MoveSelectionDOWN", GDK_KP_Subtract, 0x00, ID_SELECTION_MOVEDOWN, "menu_selection_movedown"}, - {"MoveSelectionUP", GDK_KP_Add, 0x00, ID_SELECTION_MOVEUP, "menu_selection_moveup"}, - {"DumpSelectedBrush", 'D', 0x01, ID_SELECTION_PRINT, "menu_selection_print"}, - {"ToggleSizePaint", 'Q', 0x00, ID_SELECTION_TOGGLESIZEPAINT, "menu_selection_togglesizepaint"}, - {"SelectNudgeLeft", GDK_Left, 0x02, ID_SELECTION_SELECT_NUDGELEFT, "menu_selection_select_nudgeleft"}, - {"SelectNudgeRight", GDK_Right, 0x02, ID_SELECTION_SELECT_NUDGERIGHT, "menu_selection_select_nudgeright"}, - {"SelectNudgeUp", GDK_Up, 0x02, ID_SELECTION_SELECT_NUDGEUP, "menu_selection_select_nudgeup"}, - {"CycleCapTexturePatch", 'N', 0x05, ID_CURVE_CYCLECAP, "menu_curve_cyclecap"}, - {"NaturalizePatch", 'N', 0x04, ID_PATCH_NATURALIZE, "menu_patch_naturalize"}, - {"SnapToGrid", 'G', 0x04, ID_SELECT_SNAPTOGRID, "menu_select_snaptogrid"}, - {"ShowAllTextures", 'A', 0x04, ID_TEXTURES_SHOWALL, "menu_textures_showall"}, - {"SelectAllOfType", 'A', 0x01, ID_SELECT_ALL, "menu_select_all"}, - {"CapCurrentCurve", 'C', 0x01, ID_CURVE_CAP, "menu_curve_cap"}, - {"MakeStructural", 'S', 0x05, ID_SELECTION_MAKE_STRUCTURAL, "menu_selection_make_structural"}, - {"RegionSetSelection", 'R', 0x05, ID_REGION_SETSELECTION, "menu_region_setselection"}, - {"ShowInUse", 'U', 0, ID_TEXTURES_SHOWINUSE, "menu_textures_showinuse"}, - {"InvertSelection", 'I', 0, ID_SELECTION_INVERT, "menu_selection_invert"}, - {"Sleep", 'P', 0x05, ID_FILE_SLEEP, "menu_file_sleep"}, - {"SimplePatchMesh", 'P', 0x01, ID_CURVE_SIMPLEPATCHMESH, "menu_simplepatchmesh"}, - {"FilterWorldBrushes", '1', RAD_ALT, ID_FILTER_WORLD, "menu_filter_world"}, - {"FilterEntities", '2', RAD_ALT, ID_FILTER_ENTITIES, "menu_filter_entities"}, - {"FilterAreaportals", '3', RAD_ALT, ID_FILTER_AREAPORTALS, "menu_filter_areaportals"}, - {"FilterTranslucent", '4', RAD_ALT, ID_FILTER_TRANSLUCENT, "menu_filter_translucent"}, - {"FilterLiquids", '5', RAD_ALT, ID_FILTER_LIQUIDS, "menu_filter_liquids"}, - {"FilterCaulk", '6', RAD_ALT , ID_FILTER_CAULK, "menu_filter_caulk"}, - {"FilterClips", '7', RAD_ALT, ID_FILTER_CLIPS, "menu_filter_clips"}, - {"FilterBotClips", 'M', RAD_ALT, ID_FILTER_BOTCLIPS, "menu_filter_botclips"}, - {"FilterPaths", '8', RAD_ALT, ID_FILTER_PATHS, "menu_filter_paths"}, - {"FilterClusterportals", '9', RAD_ALT, ID_FILTER_CLUSTERPORTALS, "menu_filter_clusterportals"}, - {"FilterLights", '0', RAD_ALT, ID_FILTER_LIGHTS, "menu_filter_lights"}, - {"FilterPatches", 'P', RAD_CONTROL, ID_FILTER_PATCHES, "menu_filter_patches"}, - {"FilterDetails", 'D', RAD_CONTROL, ID_FILTER_DETAILS, "menu_filter_details"}, - {"FilterStructural", 'D', RAD_CONTROL|RAD_SHIFT, ID_FILTER_STRUCTURAL, "menu_filter_structural"}, - {"FilterHintsSkips", 'H', RAD_CONTROL, ID_FILTER_HINTSSKIPS, "menu_filter_hintsskips"}, - {"FilterModels", 'M', RAD_SHIFT, ID_FILTER_MODELS, "menu_filter_models"}, - {"FilterTriggers", 'T', RAD_CONTROL|RAD_SHIFT, ID_FILTER_TRIGGERS, "menu_filter_triggers"}, - {"LoadPointfile", 'L', RAD_SHIFT, ID_FILE_POINTFILE, "menu_load_pointfile"}, - {"TextureWindowScaledown", GDK_Insert, RAD_ALT, ID_TEXTUREWINDOW_SCALEDOWN, "menu_texturewindow_scaledown"}, - {"TextureWindowScaleup", GDK_Delete, RAD_ALT, ID_TEXTUREWINDOW_SCALEUP, "menu_texturewindow_scaleup"}, + +#include "cmdlib.h" +#include "scenelib.h" +#include "stream/stringstream.h" +#include "signal/isignal.h" +#include "os/path.h" +#include "os/file.h" +#include "eclasslib.h" +#include "moduleobservers.h" + +#include "gtkutil/clipboard.h" +#include "gtkutil/container.h" +#include "gtkutil/frame.h" +#include "gtkutil/glfont.h" +#include "gtkutil/glwidget.h" +#include "gtkutil/image.h" +#include "gtkutil/menu.h" +#include "gtkutil/paned.h" +#include "gtkutil/widget.h" + +#include "autosave.h" +#include "build.h" +#include "brushmanip.h" +#include "brushmodule.h" +#include "camwindow.h" +#include "csg.h" +#include "commands.h" +#include "console.h" +#include "entity.h" +#include "entityinspector.h" +#include "entitylist.h" +#include "filters.h" +#include "findtexturedialog.h" +#include "grid.h" +#include "groupdialog.h" +#include "gtkdlgs.h" +#include "gtkmisc.h" +#include "help.h" +#include "map.h" +#include "mru.h" +#include "multimon.h" +#include "patchdialog.h" +#include "patchmanip.h" +#include "plugin.h" +#include "pluginmanager.h" +#include "pluginmenu.h" +#include "plugintoolbar.h" +#include "points.h" +#include "preferences.h" +#include "qe3.h" +#include "qgl.h" +#include "select.h" +#include "server.h" +#include "surfacedialog.h" +#include "textures.h" +#include "texwindow.h" +#include "url.h" +#include "xywindow.h" +#include "windowobservers.h" +#include "renderstate.h" +#include "feedback.h" +#include "referencecache.h" +#include "texwindow.h" + + +struct layout_globals_t +{ + WindowPosition m_position; + + + int nXYHeight; + int nXYWidth; + int nCamWidth; + int nCamHeight; + int nState; + + layout_globals_t() : + m_position( -1, -1, 640, 480 ), + + nXYHeight( 300 ), + nXYWidth( 300 ), + nCamWidth( 200 ), + nCamHeight( 200 ), + nState( GDK_WINDOW_STATE_MAXIMIZED ){ + } }; -int g_nCommandCount = sizeof(g_Commands) / sizeof(SCommandInfo); +layout_globals_t g_layout_globals; +glwindow_globals_t g_glwindow_globals; -SKeyInfo g_Keys[] = -{ - {"Space", GDK_space}, - {"Backspace", GDK_BackSpace}, - {"Escape", GDK_Escape}, - {"End", GDK_End}, - {"Insert", GDK_Insert}, - {"Delete", GDK_Delete}, - {"PageUp", GDK_Prior}, - {"PageDown", GDK_Next}, - {"Up", GDK_Up}, - {"Down", GDK_Down}, - {"Left", GDK_Left}, - {"Right", GDK_Right}, - {"F1", GDK_F1}, - {"F2", GDK_F2}, - {"F3", GDK_F3}, - {"F4", GDK_F4}, - {"F5", GDK_F5}, - {"F6", GDK_F6}, - {"F7", GDK_F7}, - {"F8", GDK_F8}, - {"F9", GDK_F9}, - {"F10", GDK_F10}, - {"F11", GDK_F11}, - {"F12", GDK_F12}, - {"Tab", GDK_Tab}, - {"Return", GDK_Return}, - {"Comma", GDK_comma}, - {"Period", GDK_period}, - {"Plus", GDK_KP_Add}, - {"Multiply", GDK_multiply}, - {"Subtract", GDK_KP_Subtract}, - {"NumPad0", GDK_KP_0}, - {"NumPad1", GDK_KP_1}, - {"NumPad2", GDK_KP_2}, - {"NumPad3", GDK_KP_3}, - {"NumPad4", GDK_KP_4}, - {"NumPad5", GDK_KP_5}, - {"NumPad6", GDK_KP_6}, - {"NumPad7", GDK_KP_7}, - {"NumPad8", GDK_KP_8}, - {"NumPad9", GDK_KP_9}, - {"[", 219}, - {"]", 221}, - {"\\", 220}, - {"Home", GDK_Home} -}; -int g_nKeyCount = sizeof(g_Keys) / sizeof(SKeyInfo); +// VFS -// ============================================================================= -// global functions +bool g_vfsInitialized = false; -void WINAPI Sys_UpdateWindows (int nBits) -{ - g_nUpdateBits |= nBits; +void VFS_Init(){ + if ( g_vfsInitialized ) return; + QE_InitVFS(); + GlobalFileSystem().initialise(); + g_vfsInitialized = true; +} +void VFS_Shutdown(){ + if ( !g_vfsInitialized ) return; + GlobalFileSystem().shutdown(); + g_vfsInitialized = false; +} +void VFS_Refresh(){ + if ( !g_vfsInitialized ) return; + GlobalFileSystem().clear(); + QE_InitVFS(); + GlobalFileSystem().refresh(); + g_vfsInitialized = true; + // also refresh texture browser + TextureBrowser_RefreshShaders(); +} +void VFS_Restart(){ + VFS_Shutdown(); + VFS_Init(); } -// ============================================================================= -// Static functions - -// Gef: Separate handling for keyup events -void HandleKeyUp (GtkWidget *widget, gpointer data) +class VFSModuleObserver : public ModuleObserver { - int id = GPOINTER_TO_INT (data); -#ifdef DBG_KBD - Sys_Printf("HandleKeyUp: %d\n", id); -#endif +public: +void realise(){ + VFS_Init(); +} +void unrealise(){ + VFS_Shutdown(); +} +}; - if(g_bIgnoreCommands) - return; +VFSModuleObserver g_VFSModuleObserver; - switch (id) - { - case ID_CAMERA_FORWARD: g_pParentWnd->OnCameraForward (FALSE); break; - case ID_CAMERA_BACK: g_pParentWnd->OnCameraBack (FALSE); break; - case ID_CAMERA_LEFT: g_pParentWnd->OnCameraLeft (FALSE); break; - case ID_CAMERA_RIGHT: g_pParentWnd->OnCameraRight (FALSE); break; - case ID_CAMERA_STRAFELEFT: g_pParentWnd->OnCameraStrafeleft (FALSE); break; - case ID_CAMERA_STRAFERIGHT: g_pParentWnd->OnCameraStraferight (FALSE); break; - } +void VFS_Construct(){ + Radiant_attachHomePathsObserver( g_VFSModuleObserver ); +} +void VFS_Destroy(){ + Radiant_detachHomePathsObserver( g_VFSModuleObserver ); } -gint HandleCommand (GtkWidget *widget, gpointer data) -{ - int id = GPOINTER_TO_INT (data); -#ifdef DBG_KBD - Sys_Printf("HandleCommand %d\n", id); -#endif +// Home Paths - if ( g_bIgnoreCommands ) { -#ifdef DBG_KBD - Sys_Printf( "g_bIgnoreCommands %d, returning FALSE\n", g_bIgnoreCommands ); +#ifdef WIN32 +#include +#include +const GUID qFOLDERID_SavedGames = {0x4C5C32FF, 0xBB9D, 0x43b0, {0xB5, 0xB4, 0x2D, 0x72, 0xE5, 0x4E, 0xAA, 0xA4}}; +#define qREFKNOWNFOLDERID GUID +#define qKF_FLAG_CREATE 0x8000 +#define qKF_FLAG_NO_ALIAS 0x1000 +typedef HRESULT ( WINAPI qSHGetKnownFolderPath_t )( qREFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath ); +static qSHGetKnownFolderPath_t *qSHGetKnownFolderPath; +#endif +void HomePaths_Realise(){ + do + { + const char* prefix = g_pGameDescription->getKeyValue( "prefix" ); + if ( !string_empty( prefix ) ) { + StringOutputStream path( 256 ); + +#if defined( __APPLE__ ) + path.clear(); + path << DirectoryCleaned( g_get_home_dir() ) << "Library/Application Support" << ( prefix + 1 ) << "/"; + if ( file_is_directory( path.c_str() ) ) { + g_qeglobals.m_userEnginePath = path.c_str(); + break; + } + path.clear(); + path << DirectoryCleaned( g_get_home_dir() ) << prefix << "/"; #endif - return FALSE; - } - - if (id >= CMD_TEXTUREWAD && id <= CMD_TEXTUREWAD_END) g_pParentWnd->OnTextureWad (id); - else if (id >= CMD_BSPCOMMAND && id <= CMD_BSPCOMMAND_END) g_pParentWnd->OnBspCommand (id); - else if (id >= ID_FILE_RECENT1 && id <= ID_FILE_RECENT4) g_pParentWnd->OnMru (id); - else if (id >= ID_VIEW_NEAREST && id <= ID_TEXTURES_FLATSHADE) - { - if (GTK_CHECK_MENU_ITEM (widget)->active) - g_pParentWnd->OnViewNearest (id); - } else if (id >= ID_GRID_025 && id <= ID_GRID_256) g_pParentWnd->OnGrid (id); - else if (id >= ID_PLUGIN_START && id <= ID_PLUGIN_END) - { - char *str; - gtk_label_get (GTK_LABEL (GTK_BIN (widget)->child), &str); - g_pParentWnd->OnPlugIn (id, str); - } else if (id >= ID_ENTITY_START && id <= ID_ENTITY_END) - { - char *str; - gtk_label_get (GTK_LABEL (GTK_BIN (widget)->child), &str); - g_pParentWnd->ActiveXY()->OnEntityCreate (str); - } - else switch (id) - { - case ID_FILE_NEW: g_pParentWnd->OnFileNew (); break; - case ID_FILE_SLEEP: g_pParentWnd->OnSleep(); break; - case ID_FILE_OPEN: g_pParentWnd->OnFileOpen (); break; - case ID_FILE_SAVE: g_pParentWnd->OnFileSave (); break; - case ID_FILE_SAVEAS: g_pParentWnd->OnFileSaveas (); break; - case ID_FILE_EXPORTMAP: g_pParentWnd->OnFileExportmap (); break; - case ID_FILE_SAVEREGION: g_pParentWnd->OnFileSaveregion (); break; - case ID_FILE_NEWPROJECT: g_pParentWnd->OnFileNewproject (); break; - case ID_FILE_LOADPROJECT: g_pParentWnd->OnFileLoadproject (); break; - case ID_FILE_PROJECTSETTINGS: g_pParentWnd->OnFileProjectsettings (); break; - case ID_FILE_POINTFILE: g_pParentWnd->OnFilePointfile (); break; - case ID_FILE_CHECKUPDATE: g_pParentWnd->OnFileCheckUpdate (); break; - case ID_FILE_EXIT: g_pParentWnd->OnFileExit (); break; - case ID_FILE_IMPORTMAP: g_pParentWnd->OnFileImportmap (); break; - case ID_EDIT_UNDO: g_pParentWnd->OnEditUndo (); break; - case ID_EDIT_REDO: g_pParentWnd->OnEditRedo (); break; - case ID_EDIT_COPYBRUSH: g_pParentWnd->OnEditCopybrush (); break; - case ID_EDIT_PASTEBRUSH: g_pParentWnd->OnEditPastebrush (); break; - case ID_EDIT_PASTEBRUSHTOCAMERA: g_pParentWnd->OnEditPastebrushToCamera (); break; - case ID_SELECTION_DELETE: g_pParentWnd->OnSelectionDelete (); break; - case ID_EDIT_MAPINFO: g_pParentWnd->OnEditMapinfo (); break; - case ID_EDIT_ENTITYINFO: g_pParentWnd->OnEditEntityinfo (); break; - case ID_BRUSH_SCRIPTS: g_pParentWnd->OnBrushScripts (); break; - case ID_EDIT_LOADPREFAB: g_pParentWnd->OnEditLoadprefab (); break; - case ID_EDIT_SAVEPREFAB: g_pParentWnd->OnEditSaveprefab (); break; - case ID_PREFS: g_pParentWnd->OnPrefs (); break; - case ID_TOGGLECAMERA: g_pParentWnd->OnTogglecamera (); break; - case ID_TOGGLECONSOLE: g_pParentWnd->OnToggleconsole (); break; - case ID_VIEW_ENTITY: g_pParentWnd->OnViewEntity (); break; - case ID_VIEW_GROUPS: g_pParentWnd->OnViewGroups (); break; - case ID_TOGGLEVIEW: g_pParentWnd->OnToggleview (); break; - case ID_TOGGLEVIEW_YZ: g_pParentWnd->OnToggleviewYz (); break; - case ID_TOGGLEVIEW_XZ: g_pParentWnd->OnToggleviewXz (); break; - case ID_TOGGLEZ: g_pParentWnd->OnTogglez (); break; - case ID_VIEW_CENTER: g_pParentWnd->OnViewCenter (); break; - case ID_VIEW_UPFLOOR: g_pParentWnd->OnViewUpfloor (); break; - case ID_VIEW_DOWNFLOOR: g_pParentWnd->OnViewDownfloor (); break; - case ID_VIEW_CENTERVIEW: g_pParentWnd->OnViewCenterview (); break; - case ID_VIEW_NEXTVIEW: g_pParentWnd->OnViewNextview (); break; - case ID_VIEW_XY: g_pParentWnd->OnViewXy (); break; - case ID_VIEW_SIDE: g_pParentWnd->OnViewSide (); break; - case ID_VIEW_FRONT: g_pParentWnd->OnViewFront (); break; - case ID_VIEW_100: g_pParentWnd->OnView100 (); break; - case ID_VIEW_ZOOMIN: g_pParentWnd->OnViewZoomin (); break; - case ID_VIEW_ZOOMOUT: g_pParentWnd->OnViewZoomout (); break; - case ID_VIEW_Z100: g_pParentWnd->OnViewZ100 (); break; - case ID_VIEW_ZZOOMIN: g_pParentWnd->OnViewZzoomin (); break; - case ID_VIEW_ZZOOMOUT: g_pParentWnd->OnViewZzoomout (); break; - case ID_VIEW_CUBEIN: g_pParentWnd->OnViewCubein (); break; - case ID_VIEW_CUBEOUT: g_pParentWnd->OnViewCubeout (); break; - case ID_VIEW_SHOWNAMES: g_pParentWnd->OnViewShownames (); break; - case ID_VIEW_SHOWBLOCKS: g_pParentWnd->OnViewShowblocks (); break; - case ID_VIEW_SHOWCOORDINATES: g_pParentWnd->OnViewShowcoordinates (); break; - case ID_VIEW_SHOWOUTLINE: g_pParentWnd->OnViewShowOutline (); break; - case ID_VIEW_SHOWAXES: g_pParentWnd->OnViewShowAxes (); break; - case ID_VIEW_SHOWWORKZONE: g_pParentWnd->OnViewShowWorkzone (); break; - case ID_VIEW_SHOWANGLES: g_pParentWnd->OnViewShowAngles (); break; - case ID_VIEW_HIDESHOW_HIDESELECTED: g_pParentWnd->OnViewHideshowHideselected (); break; - case ID_VIEW_HIDESHOW_SHOWHIDDEN: g_pParentWnd->OnViewHideshowShowhidden (); break; - case ID_VIEW_ENTITIESAS_BOUNDINGBOX: - case ID_VIEW_ENTITIESAS_WIREFRAME: - case ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME: - case ID_VIEW_ENTITIESAS_SELECTEDSKINNED: - case ID_VIEW_ENTITIESAS_SKINNED: - case ID_VIEW_ENTITIESAS_SKINNEDANDBOXED: - g_pParentWnd->OnEntitiesSetViewAs(id); - break; - case ID_VIEW_CUBICCLIPPING: g_pParentWnd->OnViewCubicclipping (); break; - case ID_VIEW_OPENGLLIGHTING: g_pParentWnd->OnViewOpengllighting (); break; - case ID_SELECTION_DRAGEDGES: g_pParentWnd->OnSelectionDragedges (); break; - case ID_SELECTION_DRAGVERTECIES: g_pParentWnd->OnSelectionDragvertecies (); break; - case ID_SELECTION_CLONE: g_pParentWnd->OnSelectionClone (); break; - case ID_SELECTION_DESELECT: g_pParentWnd->OnSelectionDeselect (); break; - case ID_BRUSH_FLIPX: g_pParentWnd->OnBrushFlipx (); break; - case ID_BRUSH_FLIPY: g_pParentWnd->OnBrushFlipy (); break; - case ID_BRUSH_FLIPZ: g_pParentWnd->OnBrushFlipz (); break; - case ID_BRUSH_ROTATEX: g_pParentWnd->OnBrushRotatex (); break; - case ID_BRUSH_ROTATEY: g_pParentWnd->OnBrushRotatey (); break; - case ID_BRUSH_ROTATEZ: g_pParentWnd->OnBrushRotatez (); break; - case ID_SELECTION_ARBITRARYROTATION: g_pParentWnd->OnSelectionArbitraryrotation (); break; - case ID_SELECT_SCALE: g_pParentWnd->OnSelectScale (); break; - case ID_SELECTION_MAKEHOLLOW: g_pParentWnd->OnSelectionMakehollow (); break; - case ID_SELECTION_CSGSUBTRACT: g_pParentWnd->OnSelectionCsgsubtract (); break; - case ID_SELECTION_CSGMERGE: g_pParentWnd->OnSelectionCsgmerge (); break; - case ID_SELECTION_NOOUTLINE: g_pParentWnd->OnSelectionNoOutline (); break; - case ID_SELECTION_OUTLINESTYLE: g_pParentWnd->OnSelectionOutlineStyle (); break; - case ID_SELECTION_SELECTCOMPLETETALL: g_pParentWnd->OnSelectionSelectcompletetall (); break; - case ID_SELECTION_SELECTTOUCHING: g_pParentWnd->OnSelectionSelecttouching (); break; - case ID_SELECTION_SELECTPARTIALTALL: g_pParentWnd->OnSelectionSelectpartialtall (); break; - case ID_SELECTION_SELECTINSIDE: g_pParentWnd->OnSelectionSelectinside (); break; - case ID_SELECTION_SELECT_NUDGELEFT: g_pParentWnd->OnSelectionSelectNudgeleft (); break; - case ID_SELECTION_SELECT_NUDGERIGHT: g_pParentWnd->OnSelectionSelectNudgeright (); break; - case ID_SELECTION_SELECT_NUDGEUP: g_pParentWnd->OnSelectionSelectNudgeup (); break; - case ID_SELECTION_SELECT_NUDGEDOWN: g_pParentWnd->OnSelectionSelectNudgedown (); break; - case ID_VIEW_CLIPPER: g_pParentWnd->OnViewClipper (); break; - case ID_CLIP_SELECTED: g_pParentWnd->OnClipSelected (); break; - case ID_SPLIT_SELECTED: g_pParentWnd->OnSplitSelected (); break; - case ID_FLIP_CLIP: g_pParentWnd->OnFlipClip (); break; - case ID_SELECTION_CONNECT: g_pParentWnd->OnSelectionConnect (); break; - case ID_SELECTION_UNGROUPENTITY: g_pParentWnd->OnSelectionUngroupentity (); break; - case ID_SELECTION_MERGE: Select_MergeEntity(); break; - case ID_SELECTION_SEPERATE: Select_Seperate(); break; - case ID_SELECTION_MAKE_DETAIL: g_pParentWnd->OnSelectionMakeDetail (); break; - case ID_SELECTION_MAKE_STRUCTURAL: g_pParentWnd->OnSelectionMakeStructural (); break; - case ID_SNAPTOGRID: g_pParentWnd->OnSnaptogrid (); break; - case ID_TEXTURES_SHOWINUSE: g_pParentWnd->OnTexturesShowinuse (); break; - case ID_TEXTURES_SHOWALL: g_pParentWnd->OnTexturesShowall (); break; - case ID_TEXTURES_INSPECTOR: g_pParentWnd->OnTexturesInspector (); break; - case ID_TEXTURE_REPLACEALL: g_pParentWnd->OnTextureReplaceall (); break; - case ID_TOGGLE_LOCK: g_pParentWnd->OnToggleLock (); break; - case ID_TOGGLE_ROTATELOCK: g_pParentWnd->OnToggleRotatelock (); break; - case ID_TEXTURES_LOAD: g_pParentWnd->OnTexturesLoad (); break; - case ID_TEXTURES_RELOADSHADERS: g_pParentWnd->OnTexturesReloadshaders (); break; - case ID_TEXTURES_SHADERS_SHOW: g_pParentWnd->OnTexturesShadersShow (); break; - case ID_TEXTURES_TEXTUREWINDOWSCALE_200: - case ID_TEXTURES_TEXTUREWINDOWSCALE_100: - case ID_TEXTURES_TEXTUREWINDOWSCALE_50: - case ID_TEXTURES_TEXTUREWINDOWSCALE_25: - case ID_TEXTURES_TEXTUREWINDOWSCALE_10: - g_pParentWnd->SetTextureScale (id); - break; - case ID_TEXTURES_LOADLIST: g_pParentWnd->OnTexturesLoadlist (); break; - case ID_TEXTURES_SHADERLISTONLY: g_pParentWnd->OnTexturesShaderlistonly (); break; - case ID_TEXTUREWINDOW_SCALEUP: g_pParentWnd->OnTexturewindowScaleup (); break; - case ID_TEXTUREWINDOW_SCALEDOWN: g_pParentWnd->OnTexturewindowScaledown (); break; - case ID_MISC_BENCHMARK: g_pParentWnd->OnMiscBenchmark (); break; - case ID_COLOR_SETORIGINAL: g_pParentWnd->OnColorSetoriginal (); break; - case ID_COLOR_SETQER: g_pParentWnd->OnColorSetqer (); break; - case ID_COLOR_SETBLACK: g_pParentWnd->OnColorSetblack (); break; - case ID_COLOR_SETYDNAR: g_pParentWnd->OnColorSetydnar (); break; /* ydnar */ - case ID_TEXTUREBK: g_pParentWnd->OnTexturebk (); break; - case ID_COLORS_XYBK: g_pParentWnd->OnColorsXybk (); break; - case ID_COLORS_MAJOR: g_pParentWnd->OnColorsMajor (); break; - case ID_COLORS_MINOR: g_pParentWnd->OnColorsMinor (); break; - case ID_COLORS_GRIDTEXT: g_pParentWnd->OnColorsGridtext (); break; - case ID_COLORS_GRIDBLOCK: g_pParentWnd->OnColorsGridblock (); break; - case ID_COLORS_CAMERABACK: g_pParentWnd->OnColorsCameraBack (); break; - case ID_COLORS_BRUSH: g_pParentWnd->OnColorsBrush (); break; - case ID_COLORS_SELECTEDBRUSH: g_pParentWnd->OnColorsSelectedbrush (); break; - case ID_COLORS_SELECTEDBRUSH3D: g_pParentWnd->OnColorsSelectedbrush3D (); break; - case ID_COLORS_CLIPPER: g_pParentWnd->OnColorsClipper (); break; - case ID_COLORS_VIEWNAME: g_pParentWnd->OnColorsViewname (); break; - case ID_MISC_GAMMA: g_pParentWnd->OnMiscGamma (); break; - case ID_MISC_FINDBRUSH: g_pParentWnd->OnMiscFindbrush (); break; - case ID_MISC_NEXTLEAKSPOT: g_pParentWnd->OnMiscNextleakspot (); break; - case ID_MISC_PREVIOUSLEAKSPOT: g_pParentWnd->OnMiscPreviousleakspot (); break; - case ID_MISC_PRINTXY: g_pParentWnd->OnMiscPrintxy (); break; - case ID_MISC_SELECTENTITYCOLOR: g_pParentWnd->OnMiscSelectentitycolor (); break; - case ID_CONVERTCURVES: g_pParentWnd->OnConvertcurves (); break; - case ID_REGION_OFF: g_pParentWnd->OnRegionOff (); break; - case ID_REGION_SETXY: g_pParentWnd->OnRegionSetxy (); break; - case ID_REGION_SETTALLBRUSH: g_pParentWnd->OnRegionSettallbrush (); break; - case ID_REGION_SETBRUSH: g_pParentWnd->OnRegionSetbrush (); break; - case ID_REGION_SETSELECTION: g_pParentWnd->OnRegionSetselection (); break; - case ID_BRUSH_3SIDED: g_pParentWnd->OnBrush3sided (); break; - case ID_BRUSH_4SIDED: g_pParentWnd->OnBrush4sided (); break; - case ID_BRUSH_5SIDED: g_pParentWnd->OnBrush5sided (); break; - case ID_BRUSH_6SIDED: g_pParentWnd->OnBrush6sided (); break; - case ID_BRUSH_7SIDED: g_pParentWnd->OnBrush7sided (); break; - case ID_BRUSH_8SIDED: g_pParentWnd->OnBrush8sided (); break; - case ID_BRUSH_9SIDED: g_pParentWnd->OnBrush9sided (); break; - case ID_BRUSH_ARBITRARYSIDED: g_pParentWnd->OnBrushArbitrarysided (); break; - case ID_BRUSH_MAKECONE: g_pParentWnd->OnBrushMakecone (); break; - case ID_BRUSH_PRIMITIVES_SPHERE: g_pParentWnd->OnBrushPrimitivesSphere (); break; - case ID_CURVE_PATCHTUBE: g_pParentWnd->OnCurvePatchtube (); break; - case ID_CURVE_PATCHDENSETUBE: g_pParentWnd->OnCurvePatchdensetube (); break; - case ID_CURVE_PATCHVERYDENSETUBE: g_pParentWnd->OnCurvePatchverydensetube (); break; - case ID_CURVE_PATCHSQUARE: g_pParentWnd->OnCurvePatchsquare (); break; - case ID_CURVE_PATCHENDCAP: g_pParentWnd->OnCurvePatchendcap (); break; - case ID_CURVE_PATCHBEVEL: g_pParentWnd->OnCurvePatchbevel (); break; - case ID_CURVE_MOREENDCAPSBEVELS_SQUAREBEVEL: g_pParentWnd->OnCurveMoreendcapsbevelsSquarebevel (); break; - case ID_CURVE_MOREENDCAPSBEVELS_SQUAREENDCAP: g_pParentWnd->OnCurveMoreendcapsbevelsSquareendcap();break; - case ID_CURVE_PATCHCONE: g_pParentWnd->OnCurvePatchcone (); break; - case ID_CURVE_SIMPLEPATCHMESH: g_pParentWnd->OnCurveSimplepatchmesh (); break; - case ID_CURVE_INSERT_INSERTCOLUMN: g_pParentWnd->OnCurveInsertInsertcolumn (); break; - case ID_CURVE_INSERT_ADDCOLUMN: g_pParentWnd->OnCurveInsertAddcolumn (); break; - case ID_CURVE_INSERT_INSERTROW: g_pParentWnd->OnCurveInsertInsertrow (); break; - case ID_CURVE_INSERT_ADDROW: g_pParentWnd->OnCurveInsertAddrow (); break; - case ID_CURVE_DELETE_FIRSTCOLUMN: g_pParentWnd->OnCurveDeleteFirstcolumn (); break; - case ID_CURVE_DELETE_LASTCOLUMN: g_pParentWnd->OnCurveDeleteLastcolumn (); break; - case ID_CURVE_DELETE_FIRSTROW: g_pParentWnd->OnCurveDeleteFirstrow (); break; - case ID_CURVE_DELETE_LASTROW: g_pParentWnd->OnCurveDeleteLastrow (); break; - case ID_CURVE_NEGATIVE: g_pParentWnd->OnCurveNegative (); break; - case ID_CURVE_REDISPERSE_ROWS: g_pParentWnd->OnCurveRedisperseRows (); break; - case ID_CURVE_REDISPERSE_INTERMEDIATE_COLS: g_pParentWnd->OnCurveRedisperseIntermediateCols (); break; - case ID_CURVE_REDISPERSE_INTERMEDIATE_ROWS: g_pParentWnd->OnCurveRedisperseIntermediateRows (); break; - case ID_CURVE_MATRIX_TRANSPOSE: g_pParentWnd->OnCurveMatrixTranspose (); break; - case ID_CURVE_CAP: g_pParentWnd->OnCurveCap (); break; - case ID_CURVE_CYCLECAP: g_pParentWnd->OnCurveCyclecap (); break; - case ID_CURVE_OVERLAY_SET: g_pParentWnd->OnCurveOverlaySet (); break; - case ID_CURVE_OVERLAY_CLEAR: g_pParentWnd->OnCurveOverlayClear (); break; - case ID_CURVE_THICKEN: g_pParentWnd->OnCurveThicken (); break; - case ID_PLUGINS_REFRESH: g_pParentWnd->OnPluginsRefresh (); break; - case ID_HELP: g_pParentWnd->OnHelp (); break; - case ID_HELP_LINKS: g_pParentWnd->OnHelpLinks(); break; - case ID_HELP_BUGREPORT: g_pParentWnd->OnHelpBugreport(); break; - case ID_HELP_COMMANDLIST: g_pParentWnd->OnHelpCommandlist (); break; - case ID_HELP_ABOUT: g_pParentWnd->OnHelpAbout (); break; - case ID_DONTSELECTMODEL: g_pParentWnd->OnDontselectmodel (); break; - case ID_FILTER_AREAPORTALS: g_pParentWnd->OnFilterAreaportals (); break; - case ID_FILTER_CAULK: g_pParentWnd->OnFilterCaulk (); break; - case ID_FILTER_STRUCTURAL: g_pParentWnd->OnFilterStructural (); break; - case ID_FILTER_CLIPS: g_pParentWnd->OnFilterClips (); break; - case ID_FILTER_BOTCLIPS: g_pParentWnd->OnFilterBotClips (); break; - case ID_FILTER_DETAILS: g_pParentWnd->OnFilterDetails (); break; - case ID_FILTER_ENTITIES: g_pParentWnd->OnFilterEntities (); break; - case ID_FILTER_HINTSSKIPS: g_pParentWnd->OnFilterHintsskips (); break; - case ID_FILTER_LIGHTS: g_pParentWnd->OnFilterLights (); break; - case ID_FILTER_LIQUIDS: g_pParentWnd->OnFilterLiquids (); break; - case ID_FILTER_MODELS: g_pParentWnd->OnFilterModels (); break; - case ID_FILTER_PATCHES: g_pParentWnd->OnFilterPatches (); break; - case ID_FILTER_TRANSLUCENT: g_pParentWnd->OnFilterTranslucent (); break; - case ID_FILTER_TRIGGERS: g_pParentWnd->OnFilterTriggers (); break; - case ID_FILTER_WORLD: g_pParentWnd->OnFilterWorld (); break; - case ID_FILTER_PATHS: g_pParentWnd->OnFilterPaths (); break; - case ID_FILTER_CLUSTERPORTALS: g_pParentWnd->OnFilterClusterportals (); break; - case ID_FILTER_LIGHTGRID: g_pParentWnd->OnFilterLightgrid (); break; - - case ID_POPUP_SELECTION: g_pParentWnd->OnPopupSelection (); break; - case ID_VIEW_CHANGE: g_pParentWnd->OnViewChange (); break; - case ID_TEXTURES_POPUP: g_pParentWnd->OnTexturesPopup (); break; - case ID_VIEW_CAMERATOGGLE: g_pParentWnd->ToggleCamera (); break; - case ID_VIEW_CAMERAUPDATE: g_pParentWnd->OnViewCameraupdate (); break; - case ID_SELECT_MOUSEROTATE: g_pParentWnd->OnSelectMouserotate (); break; - case ID_SELECT_MOUSESCALE: g_pParentWnd->OnSelectMousescale (); break; - case ID_SCALELOCKX: g_pParentWnd->OnScalelockx (); break; - case ID_SCALELOCKY: g_pParentWnd->OnScalelocky (); break; - case ID_SCALELOCKZ: g_pParentWnd->OnScalelockz (); break; - case ID_DONTSELECTCURVE: g_pParentWnd->OnDontselectcurve (); break; - case ID_PATCH_SHOWBOUNDINGBOX: g_pParentWnd->OnPatchToggleBox (); break; - case ID_PATCH_WIREFRAME: g_pParentWnd->OnPatchWireframe (); break; - case ID_PATCH_BEND: g_pParentWnd->OnPatchBend (); break; - case ID_PATCH_WELD: g_pParentWnd->OnPatchWeld (); break; - case ID_PATCH_DRILLDOWN: g_pParentWnd->OnPatchDrilldown (); break; - case ID_DROP_GROUP_NAME: g_pParentWnd->OnDropGroupName (); break; - case ID_DROP_GROUP_NEWGROUP: g_pParentWnd->OnDropGroupNewgroup (); break; - case ID_DROP_GROUP_REMOVE: g_pParentWnd->OnDropGroupRemove (); break; - case ID_SHOW_ENTITIES: g_pParentWnd->OnShowEntities (); break; - - case IDC_BTN_FACEFIT: g_pParentWnd->OnFaceFit (); break; - case ID_VIEW_TEXTURE: g_pParentWnd->OnViewTexture (); break; - case ID_PATCH_INSPECTOR: g_pParentWnd->OnPatchInspector (); break; - case ID_CURVE_NEGATIVETEXTUREX: g_pParentWnd->OnCurveNegativeTextureX (); break; - case ID_CURVE_NEGATIVETEXTUREY: g_pParentWnd->OnCurveNegativeTextureY (); break; - case ID_CURVE_INSERTCOLUMN: g_pParentWnd->OnCurveInsertcolumn (); break; - case ID_CURVE_INSERTROW: g_pParentWnd->OnCurveInsertrow (); break; - case ID_CURVE_DELETECOLUMN: g_pParentWnd->OnCurveDeletecolumn (); break; - case ID_CURVE_DELETEROW: g_pParentWnd->OnCurveDeleterow (); break; - case ID_PATCH_TAB: g_pParentWnd->OnPatchTab (); break; - case ID_CAMERA_FORWARD: g_pParentWnd->OnCameraForward (TRUE); break; - case ID_CAMERA_BACK: g_pParentWnd->OnCameraBack (TRUE); break; - case ID_CAMERA_LEFT: g_pParentWnd->OnCameraLeft (TRUE); break; - case ID_CAMERA_RIGHT: g_pParentWnd->OnCameraRight (TRUE); break; - case ID_CAMERA_UP: g_pParentWnd->OnCameraUp (); break; - case ID_CAMERA_DOWN: g_pParentWnd->OnCameraDown (); break; - case ID_CAMERA_ANGLEUP: g_pParentWnd->OnCameraAngleup (); break; - case ID_CAMERA_ANGLEDOWN: g_pParentWnd->OnCameraAngledown (); break; - case ID_CAMERA_STRAFELEFT: g_pParentWnd->OnCameraStrafeleft (TRUE); break; - case ID_CAMERA_STRAFERIGHT: g_pParentWnd->OnCameraStraferight (TRUE); break; - case ID_GRID_TOGGLE: g_pParentWnd->OnGridToggle (); break; - case ID_VIEW_CONSOLE: g_pParentWnd->OnViewConsole (); break; - case ID_VIEW_CROSSHAIR: g_pParentWnd->OnViewCrosshair (); break; - case ID_SELECTION_TEXTURE_FIT: g_pParentWnd->OnSelectionTextureFit (); break; - case ID_SELECTION_TEXTURE_ROTATECLOCK: g_pParentWnd->OnSelectionTextureRotateclock (); break; - case ID_SELECTION_TEXTURE_ROTATECOUNTER: g_pParentWnd->OnSelectionTextureRotatecounter (); break; - case ID_SELECTION_TEXTURE_SCALEUP: g_pParentWnd->OnSelectionTextureScaleup (); break; - case ID_SELECTION_TEXTURE_SCALEDOWN: g_pParentWnd->OnSelectionTextureScaledown (); break; - case ID_SELECTION_TEXTURE_SHIFTLEFT: g_pParentWnd->OnSelectionTextureShiftleft (); break; - case ID_SELECTION_TEXTURE_SHIFTRIGHT: g_pParentWnd->OnSelectionTextureShiftright (); break; - case ID_SELECTION_TEXTURE_SHIFTUP: g_pParentWnd->OnSelectionTextureShiftup (); break; - case ID_SELECTION_TEXTURE_SHIFTDOWN: g_pParentWnd->OnSelectionTextureShiftdown (); break; - case ID_GRID_PREV: g_pParentWnd->OnGridPrev (); break; - case ID_GRID_NEXT: g_pParentWnd->OnGridNext (); break; - case ID_SELECTION_TEXTURE_SCALELEFT: g_pParentWnd->OnSelectionTextureScaleLeft (); break; - case ID_SELECTION_TEXTURE_SCALERIGHT: g_pParentWnd->OnSelectionTextureScaleRight (); break; - case ID_SELECTION_MOVEDOWN: g_pParentWnd->OnSelectionMovedown (); break; - case ID_SELECTION_MOVEUP: g_pParentWnd->OnSelectionMoveup (); break; - case ID_SELECTION_PRINT: g_pParentWnd->OnSelectionPrint (); break; - case ID_SELECTION_TOGGLESIZEPAINT: g_pParentWnd->OnSelectionTogglesizepaint (); break; - case ID_PATCH_NATURALIZE: g_pParentWnd->OnPatchNaturalize (); break; - case ID_SELECT_SNAPTOGRID: g_pParentWnd->OnSnapToGrid (); break; - case ID_SELECT_ALL: g_pParentWnd->OnSelectAll (); break; - case ID_SELECTION_INVERT: g_pParentWnd->OnSelectionInvert (); break; - } - - return TRUE; -} - -static gint timer (gpointer data) -{ - MainFrame *wnd = (MainFrame*)data; - wnd->OnTimer (); - return TRUE; -} -static gint mainframe_delete (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - MainFrame *wnd = (MainFrame*)data; +#if defined( WIN32 ) + TCHAR mydocsdir[MAX_PATH + 1]; + wchar_t *mydocsdirw; + HMODULE shfolder = LoadLibrary( "shfolder.dll" ); + if ( shfolder ) { + qSHGetKnownFolderPath = (qSHGetKnownFolderPath_t *) GetProcAddress( shfolder, "SHGetKnownFolderPath" ); + } + else{ + qSHGetKnownFolderPath = NULL; + } + CoInitializeEx( NULL, COINIT_APARTMENTTHREADED ); + if ( qSHGetKnownFolderPath && qSHGetKnownFolderPath( qFOLDERID_SavedGames, qKF_FLAG_CREATE | qKF_FLAG_NO_ALIAS, NULL, &mydocsdirw ) == S_OK ) { + memset( mydocsdir, 0, sizeof( mydocsdir ) ); + wcstombs( mydocsdir, mydocsdirw, sizeof( mydocsdir ) - 1 ); + CoTaskMemFree( mydocsdirw ); + path.clear(); + path << DirectoryCleaned( mydocsdir ) << ( prefix + 1 ) << "/"; + if ( file_is_directory( path.c_str() ) ) { + g_qeglobals.m_userEnginePath = path.c_str(); + CoUninitialize(); + FreeLibrary( shfolder ); + break; + } + } + CoUninitialize(); + if ( shfolder ) { + FreeLibrary( shfolder ); + } + if ( SHGetFolderPath( NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir ) ) { + path.clear(); + path << DirectoryCleaned( mydocsdir ) << "My Games/" << ( prefix + 1 ) << "/"; + // win32: only add it if it already exists + if ( file_is_directory( path.c_str() ) ) { + g_qeglobals.m_userEnginePath = path.c_str(); + break; + } + } +#endif - wnd->OnDelete(); +#if defined( POSIX ) + path.clear(); + path << DirectoryCleaned( g_get_home_dir() ) << prefix << "/"; + g_qeglobals.m_userEnginePath = path.c_str(); + break; +#endif + } - if (ConfirmModified()) - return FALSE; + g_qeglobals.m_userEnginePath = EnginePath_get(); + } + while ( 0 ); - g_qeglobals_gui.d_edit = NULL; + Q_mkdir( g_qeglobals.m_userEnginePath.c_str() ); - return TRUE; + { + StringOutputStream path( 256 ); + path << g_qeglobals.m_userEnginePath.c_str() << gamename_get() << '/'; + g_qeglobals.m_userGamePath = path.c_str(); + } + ASSERT_MESSAGE( !string_empty( g_qeglobals.m_userGamePath.c_str() ), "HomePaths_Realise: user-game-path is empty" ); + Q_mkdir( g_qeglobals.m_userGamePath.c_str() ); } -static void mainframe_destroy (GtkWidget *widget, gpointer data) -{ - MainFrame *wnd = (MainFrame*)data; - - // avoid saving prefs when the app is minimized - if (g_pParentWnd->IsSleeping()) - { - Sys_Printf("Shutdown while sleeping, not saving prefs\n"); - g_qeglobals.disable_ini = true; - } - - // NOTE TTimo this is very clumsy, in MainFrame::OnDestroy we might call SavePrefs again - // we will do more stuff in OnDestroy for window position saving too, so I guess this call is still relevant? - g_PrefsDlg.SavePrefs (); - - wnd->OnDestroy (); +ModuleObservers g_homePathObservers; - // shutdown modules - // NOTE: I've decided to do this before SavePrefs in case we broadcast some shutdown info - // and modules / plugins decide to save some stuff - g_pParentWnd->GetPlugInMgr().Shutdown(); - - delete wnd; - - QGL_Shutdown(); - g_PrefsDlg.Destroy (); - g_dlgSurface.Destroy (); - g_dlgFind.Destroy (); - g_PatchDialog.Destroy (); +void Radiant_attachHomePathsObserver( ModuleObserver& observer ){ + g_homePathObservers.attach( observer ); +} - gtk_main_quit (); +void Radiant_detachHomePathsObserver( ModuleObserver& observer ){ + g_homePathObservers.detach( observer ); } -static gint mainframe_keypress (GtkWidget* widget, GdkEventKey* event, gpointer data) +class HomePathsModuleObserver : public ModuleObserver { - unsigned int code = gdk_keyval_to_upper(event->keyval); - - // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=924 - if(code == GDK_ISO_Left_Tab) { - code = GDK_Tab; - } - -#ifdef DBG_KBD - Sys_Printf("key: %d (keyval: %d) (ctrl: %d)\n", code, event->keyval, event->state & GDK_CONTROL_MASK); -#endif +std::size_t m_unrealised; +public: +HomePathsModuleObserver() : m_unrealised( 1 ){ +} +void realise(){ + if ( --m_unrealised == 0 ) { + HomePaths_Realise(); + g_homePathObservers.realise(); + } +} +void unrealise(){ + if ( ++m_unrealised == 1 ) { + g_homePathObservers.unrealise(); + } +} +}; - // BUG: http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=865 - // return only if Texture Viewport is in main window, otherwise if Tex viewport is in it's own window - // the Filter GtkEntry won't release focus - if ( g_pParentWnd->GetTexWnd()->m_pFilter == gtk_window_get_focus(GTK_WINDOW(widget)) ) - if ( gtk_widget_is_focus( g_pParentWnd->GetTexWnd()->m_pFilter ) ) - return FALSE; +HomePathsModuleObserver g_HomePathsModuleObserver; -#ifdef DBG_KBD - Sys_Printf("mainframe_keypress processing into a command\n"); -#endif - for (int i = 0; i < g_nCommandCount; i++) - { - if (g_Commands[i].m_nKey == code) // find a match? - { - // check modifiers - unsigned int nState = 0; - if (Sys_AltDown ()) - nState |= RAD_ALT; - if ((event->state & GDK_CONTROL_MASK) != 0) - nState |= RAD_CONTROL; - if ((event->state & GDK_SHIFT_MASK) != 0) - nState |= RAD_SHIFT; - if ((g_Commands[i].m_nModifiers & 0x7) == nState) - { - HandleCommand (NULL, GINT_TO_POINTER (g_Commands[i].m_nCommand)); - gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "key_press_event"); - return FALSE; - } - } - } - - return TRUE; -} - -static gint mainframe_keyrelease (GtkWidget* widget, GdkEventKey* event, gpointer data) -{ - unsigned int code = gdk_keyval_to_upper(event->keyval); - - if (gtk_accelerator_valid (event->keyval, (GdkModifierType)0)) - return TRUE; - - for (int i = 0; i < g_nCommandCount; i++) - { - if (g_Commands[i].m_nKey == code) // find a match? - { - if(!g_Commands[i].m_nModifiers) - { - // Gef: Only call the handler if it's a key that needs keyup events - switch (g_Commands[i].m_nCommand) - { - case ID_CAMERA_FORWARD: - case ID_CAMERA_BACK: - case ID_CAMERA_LEFT: - case ID_CAMERA_RIGHT: - case ID_CAMERA_STRAFELEFT: - case ID_CAMERA_STRAFERIGHT: - { - HandleKeyUp (NULL, GINT_TO_POINTER (g_Commands[i].m_nCommand)); - gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "key_release_event"); - } - - } - return FALSE; - } - } - } - - return TRUE; +void HomePaths_Construct(){ + Radiant_attachEnginePathObserver( g_HomePathsModuleObserver ); +} +void HomePaths_Destroy(){ + Radiant_detachEnginePathObserver( g_HomePathsModuleObserver ); } -// ============================================================================= -// Window creation functions +// Engine Path -void AddMenuItem (GtkWidget* item, unsigned int id) -{ - for (int i = 0; i < g_nCommandCount; i++) - if (g_Commands[i].m_nCommand == id) - { - g_object_set_data (G_OBJECT (g_pParentWnd->m_pWidget), g_Commands[i].m_strMenu, item); - break; - } -} +CopiedString g_strEnginePath; +ModuleObservers g_enginePathObservers; +std::size_t g_enginepath_unrealised = 1; -void MainFrame::handle_help_command(int id) -{ - OpenURL(mHelpURLs[id]->GetBuffer()); +void Radiant_attachEnginePathObserver( ModuleObserver& observer ){ + g_enginePathObservers.attach( observer ); } -/*! -needed for hooking in Gtk+ -*/ -void HandleHelpCommand (GtkWidget *widget, gpointer data) -{ - int id = GPOINTER_TO_INT (data); - g_pParentWnd->handle_help_command(id); +void Radiant_detachEnginePathObserver( ModuleObserver& observer ){ + g_enginePathObservers.detach( observer ); } -void MainFrame::process_xlink (Str &FileName, const char *menu_name, const char *base_url, GtkWidget *menu, GtkAccelGroup *accel) -{ - xmlDocPtr pDoc; - pDoc = xmlParseFile(FileName.GetBuffer()); - if (pDoc) - { - Sys_Printf("Processing .xlink file '%s'\n", FileName.GetBuffer()); - // create sub menu - GtkWidget* menu_in_menu = create_menu_in_menu_with_mnemonic(menu, menu_name); - // start walking the nodes, find the 'links' one - xmlNodePtr pNode = pDoc->children; - while (pNode && strcmp((const char*)pNode->name, "links")) - pNode=pNode->next; - if (pNode) - { - pNode = pNode->children; - while(pNode) - { - if (!strcmp((const char*)pNode->name, "item")) - { - // process the URL - Str *url; - if (strstr((char *)xmlGetProp(pNode, (xmlChar *)"url"), "http://")) - { - // complete URL - url = new Str; - *url = (char *)xmlGetProp(pNode, (xmlChar *)"url"); - } - else - { - // relative URL - url = new Str; - *url = base_url; - *url += (char *)xmlGetProp(pNode, (xmlChar *)"url"); - } - mHelpURLs.push_back(url); - create_menu_item_with_mnemonic (menu_in_menu, (char *)xmlGetProp(pNode, (xmlChar *)"name"), GTK_SIGNAL_FUNC(HandleHelpCommand), mHelpURLs.size()-1); - } - pNode=pNode->next; - } - } - xmlFreeDoc(pDoc); - } - else - { - Sys_Printf("'%s' not found / parse failed\n", FileName.GetBuffer()); - } -} - -void MainFrame::create_game_help_menu (GtkWidget *menu, GtkAccelGroup *accel) -{ - Str FileName; - list::iterator iGame; - - // start in the global dir - FileName = g_strAppPath; - FileName += "global.xlink"; - process_xlink(FileName, "General", g_strAppPath.GetBuffer(), menu, accel); - for (iGame = g_PrefsDlg.mGamesDialog.mGames.begin(); iGame != g_PrefsDlg.mGamesDialog.mGames.end(); iGame++) - { - FileName = (*iGame)->mGameToolsPath; - FileName += "game.xlink"; - process_xlink(FileName, (*iGame)->mGameName, (*iGame)->mGameToolsPath.GetBuffer(), menu, accel); - } +void EnginePath_Realise(){ + if ( --g_enginepath_unrealised == 0 ) { + g_enginePathObservers.realise(); + } } -void MainFrame::create_main_menu (GtkWidget *window, GtkWidget *vbox) -{ - GtkWidget *handle_box, *menu_bar, *menu, *menu_in_menu, *menu_3, *item; - GtkAccelGroup *accel; - - g_bIgnoreCommands++; - accel = gtk_accel_group_new (); - global_accel = accel; - gtk_window_add_accel_group (GTK_WINDOW (window), accel); - - handle_box = gtk_handle_box_new (); - gtk_box_pack_start (GTK_BOX (vbox), handle_box, FALSE, FALSE, 0); - gtk_widget_show (handle_box); - - menu_bar = gtk_menu_bar_new (); - gtk_container_add (GTK_CONTAINER (handle_box), menu_bar); - gtk_widget_show (menu_bar); - - // File menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_File")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - create_menu_item_with_mnemonic (menu, _("_New Map"), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_NEW); - menu_separator (menu); - - //++timo temporary experimental stuff for sleep mode.. - item = create_menu_item_with_mnemonic (menu, _("_Sleep"), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_SLEEP); - g_object_set_data (G_OBJECT (window), "menu_file_sleep", item ); - menu_separator (menu); - // end experimental - - item = create_menu_item_with_mnemonic (menu, _("_Open..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_OPEN); - g_object_set_data (G_OBJECT (window), "menu_file_open", item); - create_menu_item_with_mnemonic (menu, _("_Import..."), // Hydra: give it it's proper name - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_IMPORTMAP); - item = create_menu_item_with_mnemonic (menu, _("_Save"), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_SAVE); - g_object_set_data (G_OBJECT (window), "menu_file_save", item); - create_menu_item_with_mnemonic (menu, _("Save _as..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_SAVEAS); - create_menu_item_with_mnemonic (menu, _("Save s_elected..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_EXPORTMAP); - menu_separator (menu); - item = create_menu_item_with_mnemonic (menu, _("Save re_gion..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_SAVEREGION); - g_object_set_data (G_OBJECT (window), "menu_file_saveregion", item); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("New p_roject..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_NEWPROJECT); - create_menu_item_with_mnemonic (menu, _("Load _project..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_LOADPROJECT); - create_menu_item_with_mnemonic (menu, _("Pro_ject settings..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_PROJECTSETTINGS); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("_Pointfile..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_POINTFILE); - menu_separator (menu); - item = create_menu_item_with_mnemonic (menu, _("Recent Files"), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_RECENT1); - g_object_set_data (G_OBJECT (item), "accel", accel); - gtk_widget_set_sensitive (item, FALSE); - MRU_AddWidget (item, 0); - item = create_menu_item_with_mnemonic (menu, "2", - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_RECENT2); - gtk_widget_hide (item); - MRU_AddWidget (item, 1); - item = create_menu_item_with_mnemonic (menu, "3", - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_RECENT3); - gtk_widget_hide (item); - MRU_AddWidget (item, 2); - item = create_menu_item_with_mnemonic (menu, "4", - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_RECENT4); - gtk_widget_hide (item); - MRU_AddWidget (item, 3); - menu_separator (menu); - item = create_menu_item_with_mnemonic (menu, _("Check for GtkRadiant update (web)"), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_CHECKUPDATE); - // disable, the functionality is no longer available - gtk_widget_set_sensitive( item, FALSE ); - - create_menu_item_with_mnemonic (menu, _("E_xit"), - GTK_SIGNAL_FUNC (HandleCommand), ID_FILE_EXIT); - - // Edit menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_Edit")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - item = create_menu_item_with_mnemonic (menu, _("_Undo"), - GTK_SIGNAL_FUNC (HandleCommand), ID_EDIT_UNDO); - g_object_set_data (G_OBJECT (window), "menu_edit_undo", item); - item = create_menu_item_with_mnemonic (menu, _("_Redo"), - GTK_SIGNAL_FUNC (HandleCommand), ID_EDIT_REDO); - g_object_set_data (G_OBJECT (window), "menu_edit_redo", item); - menu_separator (menu); - item = create_menu_item_with_mnemonic (menu, _("_Copy"), GTK_SIGNAL_FUNC (HandleCommand), ID_EDIT_COPYBRUSH); - item = create_menu_item_with_mnemonic (menu, _("_Paste"), GTK_SIGNAL_FUNC (HandleCommand), ID_EDIT_PASTEBRUSH); - item = create_menu_item_with_mnemonic (menu, _("P_aste To Camera"), GTK_SIGNAL_FUNC (HandleCommand), ID_EDIT_PASTEBRUSHTOCAMERA); - item = create_menu_item_with_mnemonic (menu, _("_Delete"), GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_DELETE); - g_object_set_data (G_OBJECT (window), "menu_selection_delete", item); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("Map Info..."), GTK_SIGNAL_FUNC (HandleCommand), ID_EDIT_MAPINFO); - create_menu_item_with_mnemonic (menu, _("Entity Info..."), GTK_SIGNAL_FUNC (HandleCommand), ID_EDIT_ENTITYINFO); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("Brush Scripts..."), GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_SCRIPTS); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("Load Pre_fab..."), GTK_SIGNAL_FUNC (HandleCommand), ID_EDIT_LOADPREFAB); - create_menu_item_with_mnemonic (menu, _("Save Selection as Prefab..."), GTK_SIGNAL_FUNC (HandleCommand), ID_EDIT_SAVEPREFAB); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("Preferences..."), GTK_SIGNAL_FUNC (HandleCommand), ID_PREFS); - - // View menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_View")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Toggle")); - create_menu_item_with_mnemonic (menu_in_menu, _("Camera View"), GTK_SIGNAL_FUNC (HandleCommand), ID_TOGGLECAMERA); - create_menu_item_with_mnemonic (menu_in_menu, _("Console View"), GTK_SIGNAL_FUNC (HandleCommand), ID_TOGGLECONSOLE); - item = create_menu_item_with_mnemonic (menu_in_menu, _("Entity View"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_ENTITY); - g_object_set_data (G_OBJECT (window), "menu_view_entity", item); - // create_menu_item_with_mnemonic (menu_in_menu, "Groups View", GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_GROUPS); - create_menu_item_with_mnemonic (menu_in_menu, _("XY (Top)"), GTK_SIGNAL_FUNC (HandleCommand), ID_TOGGLEVIEW); - create_menu_item_with_mnemonic (menu_in_menu, _("YZ (Side)"), GTK_SIGNAL_FUNC (HandleCommand), ID_TOGGLEVIEW_YZ); - create_menu_item_with_mnemonic (menu_in_menu, _("XZ (Front)"), GTK_SIGNAL_FUNC (HandleCommand), ID_TOGGLEVIEW_XZ); - create_menu_item_with_mnemonic (menu_in_menu, _("Z View"), GTK_SIGNAL_FUNC (HandleCommand), ID_TOGGLEZ); - menu_separator (menu); - item = create_menu_item_with_mnemonic (menu, _("_Center"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_CENTER); - item = create_menu_item_with_mnemonic (menu, _("_Center 2d"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_CENTERVIEW); - item = create_menu_item_with_mnemonic (menu, _("_Up Floor"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_UPFLOOR); - item = create_menu_item_with_mnemonic (menu, _("_Down Floor"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_DOWNFLOOR); - menu_separator (menu); - item = create_menu_item_with_mnemonic (menu, _("_Next (XY, YZ, XY)"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_NEXTVIEW); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Layout")); - create_menu_item_with_mnemonic (menu_in_menu, _("XY (Top)"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_XY); - create_menu_item_with_mnemonic (menu_in_menu, _("YZ"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_SIDE); - create_menu_item_with_mnemonic (menu_in_menu, _("XZ"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_FRONT); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Zoom")); - create_menu_item_with_mnemonic (menu_in_menu, _("_XY 100%"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_100); - item = create_menu_item_with_mnemonic (menu_in_menu, _("XY Zoom _In"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_ZOOMIN); - item = create_menu_item_with_mnemonic (menu_in_menu, _("XY Zoom _Out"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_ZOOMOUT); - menu_separator (menu_in_menu); - create_menu_item_with_mnemonic (menu_in_menu, _("_Z 100%"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_Z100); - item = create_menu_item_with_mnemonic (menu_in_menu, _("Z Zoo_m In"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_ZZOOMIN); - g_object_set_data (G_OBJECT (window), "menu_view_zzoomin", item); - item = create_menu_item_with_mnemonic (menu_in_menu, _("Z Zoom O_ut"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_ZZOOMOUT); - g_object_set_data (G_OBJECT (window), "menu_view_zzoomout", item); - menu_separator (menu_in_menu); - item = create_menu_item_with_mnemonic (menu_in_menu, _("Cubic Clip Zoom In"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_CUBEIN); - item = create_menu_item_with_mnemonic (menu_in_menu, _("Cubic Clip Zoom Out"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_CUBEOUT); - menu_separator (menu); - - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Show")); - item = create_check_menu_item_with_mnemonic (menu_in_menu, _("Show _Angles"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_SHOWANGLES, FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_showangles", item); - item = create_check_menu_item_with_mnemonic (menu_in_menu, _("Show _Names"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_SHOWNAMES, TRUE); - g_object_set_data (G_OBJECT (window), "menu_view_shownames", item); - item = create_check_menu_item_with_mnemonic (menu_in_menu, _("Show Blocks"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_SHOWBLOCKS, FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_showblocks", item); - item = create_check_menu_item_with_mnemonic (menu_in_menu, _("Show C_oordinates"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_SHOWCOORDINATES, TRUE); - g_object_set_data (G_OBJECT (window), "menu_view_showcoordinates", item); - item = create_check_menu_item_with_mnemonic (menu_in_menu, _("Show Window Outline"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_SHOWOUTLINE, TRUE); - g_object_set_data (G_OBJECT (window), "menu_view_showoutline", item); - item = create_check_menu_item_with_mnemonic (menu_in_menu, _("Show ZBuffered Outline"), GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_NOOUTLINE, TRUE); - g_object_set_data (G_OBJECT (window), "menu_selection_nooutline", item); - item = create_check_menu_item_with_mnemonic (menu_in_menu, _("Show Axes"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_SHOWAXES, TRUE); - g_object_set_data (G_OBJECT (window), "menu_view_showaxes", item); - item = create_check_menu_item_with_mnemonic (menu_in_menu, _("Show Workzone"), GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_SHOWWORKZONE, FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_showworkzone", item); - - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Filter")); - create_check_menu_item_with_mnemonic (menu_in_menu, _("World"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_WORLD, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Entities"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_ENTITIES, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Areaportals"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_AREAPORTALS, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Translucent"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_TRANSLUCENT, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Liquids"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_LIQUIDS, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Caulk"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_CAULK, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Clips"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_CLIPS, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Paths"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_PATHS, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Clusterportals"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_CLUSTERPORTALS, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Lights"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_LIGHTS, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Structural"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_STRUCTURAL, FALSE); - item = create_check_menu_item_with_mnemonic (menu_in_menu, _("Lightgrid"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_LIGHTGRID, FALSE); - g_object_set_data (G_OBJECT (window), "menu_filter_lightgrid", item); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Patches"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_PATCHES, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Details"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_DETAILS, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Hints"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_HINTSSKIPS, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Models"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_MODELS, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Triggers"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_TRIGGERS, FALSE); - create_check_menu_item_with_mnemonic (menu_in_menu, _("Botclips"), GTK_SIGNAL_FUNC (HandleCommand), ID_FILTER_BOTCLIPS, FALSE); - - menu_separator (menu); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Hide/Show")); - create_menu_item_with_mnemonic (menu_in_menu, _("Hide Selected"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_HIDESHOW_HIDESELECTED); - create_menu_item_with_mnemonic (menu_in_menu, _("Show Hidden"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_HIDESHOW_SHOWHIDDEN); - menu_separator (menu); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Entities as")); - g_object_set_data (G_OBJECT (window), "view_entitiesas_menu", menu_in_menu); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, NULL, _("Bounding box"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_ENTITIESAS_BOUNDINGBOX,FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_entitiesas_boundingbox", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("Wireframe"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_ENTITIESAS_WIREFRAME,FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_entitiesas_wireframe", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("Selected Wireframe"), - GTK_SIGNAL_FUNC (HandleCommand),ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME,FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_entitiesas_selectedwireframe", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("Selected Skinned"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_ENTITIESAS_SELECTEDSKINNED,FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_entitiesas_selectedskinned", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("Skinned"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_ENTITIESAS_SKINNED,FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_entitiesas_skinned", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("Skinned and Boxed"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_ENTITIESAS_SKINNEDANDBOXED,FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_entitiesas_skinnedandboxed", item); - menu_separator (menu); - item = create_check_menu_item_with_mnemonic (menu, _("Cubic Clipping"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_CUBICCLIPPING, TRUE); - g_object_set_data (G_OBJECT (window), "menu_view_cubicclipping", item); - menu_separator (menu); - item = create_check_menu_item_with_mnemonic (menu, _("OpenGL Lighting"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_OPENGLLIGHTING, FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_opengllighting", item); - - // Selection menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_Selection")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Drag")); - create_menu_item_with_mnemonic (menu_in_menu, _("Drag _Edges"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_DRAGEDGES); - create_menu_item_with_mnemonic (menu_in_menu, _("Drag _Vertices"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_DRAGVERTECIES); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("_Clone"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_CLONE); - item = create_menu_item_with_mnemonic (menu, _("Deselect"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_DESELECT); - item = create_menu_item_with_mnemonic (menu, _("Invert"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_INVERT); -#ifndef QUAKE3 - create_menu_item_with_mnemonic (menu, _("_Delete"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_DELETE); -#endif - menu_separator (menu); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Flip")); - create_menu_item_with_mnemonic (menu_in_menu, _("Flip _X"), - GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_FLIPX); - create_menu_item_with_mnemonic (menu_in_menu, _("Flip _Y"), - GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_FLIPY); - create_menu_item_with_mnemonic (menu_in_menu, _("Flip _Z"), - GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_FLIPZ); - menu_separator (menu); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Rotate")); - create_menu_item_with_mnemonic (menu_in_menu, _("Rotate X"), - GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_ROTATEX); - create_menu_item_with_mnemonic (menu_in_menu, _("Rotate Y"), - GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_ROTATEY); - create_menu_item_with_mnemonic (menu_in_menu, _("Rotate Z"), - GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_ROTATEZ); - create_menu_item_with_mnemonic (menu_in_menu, _("Arbitrary rotation..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_ARBITRARYROTATION); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("Scale..."), GTK_SIGNAL_FUNC (HandleCommand), ID_SELECT_SCALE); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("CSG")); - create_menu_item_with_mnemonic (menu_in_menu, _("Make _Hollow"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_MAKEHOLLOW); - create_menu_item_with_mnemonic (menu_in_menu, _("CSG _Subtract"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_CSGSUBTRACT); - create_menu_item_with_mnemonic (menu_in_menu, _("CSG _Merge"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_CSGMERGE); - menu_separator (menu); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Select")); - create_menu_item_with_mnemonic (menu_in_menu, _("Select Complete _Tall"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECTCOMPLETETALL); - create_menu_item_with_mnemonic (menu_in_menu, _("Select T_ouching"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECTTOUCHING); - create_menu_item_with_mnemonic (menu_in_menu, _("Select _Partial Tall"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECTPARTIALTALL); - create_menu_item_with_mnemonic (menu_in_menu, _("Select _Inside"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECTINSIDE); -#ifndef QUAKE3 - create_menu_item_with_mnemonic (menu_in_menu, _("Nudge Left"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECT_NUDGELEFT); - create_menu_item_with_mnemonic (menu_in_menu, _("Nudge Right"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECT_NUDGERIGHT); - create_menu_item_with_mnemonic (menu_in_menu, _("Nudge Up"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECT_NUDGEUP); - create_menu_item_with_mnemonic (menu_in_menu, _("Nudge Down"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECT_NUDGEDOWN); -#endif - menu_separator (menu); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Clipper")); - create_menu_item_with_mnemonic (menu_in_menu, _("Toggle Clipper"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_CLIPPER); - menu_separator (menu_in_menu); - create_menu_item_with_mnemonic (menu_in_menu, _("Clip selection"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CLIP_SELECTED); - create_menu_item_with_mnemonic (menu_in_menu, _("Split selection"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SPLIT_SELECTED); - create_menu_item_with_mnemonic (menu_in_menu, _("Flip Clip orientation"), - GTK_SIGNAL_FUNC (HandleCommand), ID_FLIP_CLIP); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("Connect entities"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_CONNECT); - create_menu_item_with_mnemonic (menu, _("Ungroup entity"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_UNGROUPENTITY); - create_menu_item_with_mnemonic (menu, _("Make detail"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_MAKE_DETAIL); - create_menu_item_with_mnemonic (menu, _("Make structural"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_MAKE_STRUCTURAL); - - // BSP menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_Bsp")); - - menu_separator (menu); - g_object_set_data (G_OBJECT (window), "menu_bsp", menu); - - // Grid menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_Grid")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - item = create_radio_menu_item_with_mnemonic (menu, NULL, _("Grid0.25"), - GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_025, FALSE); - g_object_set_data (G_OBJECT (window), "menu_grid_025", item); - item = create_radio_menu_item_with_mnemonic (menu, item, _("Grid0.5"), - GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_05, FALSE); - g_object_set_data (G_OBJECT (window), "menu_grid_05", item); - item = create_radio_menu_item_with_mnemonic (menu, item, _("Grid1"), - GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_1, FALSE); - g_object_set_data (G_OBJECT (window), "menu_grid_1", item); - item = create_radio_menu_item_with_mnemonic (menu, item, _("Grid2"), - GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_2, FALSE); - g_object_set_data (G_OBJECT (window), "menu_grid_2", item); - item = create_radio_menu_item_with_mnemonic (menu, item, _("Grid4"), - GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_4, FALSE); - g_object_set_data (G_OBJECT (window), "menu_grid_4", item); - item = create_radio_menu_item_with_mnemonic (menu, item, _("Grid8"), - GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_8, TRUE); - g_object_set_data (G_OBJECT (window), "menu_grid_8", item); - item = create_radio_menu_item_with_mnemonic (menu, item, _("Grid16"), - GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_16, FALSE); - g_object_set_data (G_OBJECT (window), "menu_grid_16", item); - item = create_radio_menu_item_with_mnemonic (menu, item, _("Grid32"), - GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_32, FALSE); - g_object_set_data (G_OBJECT (window), "menu_grid_32", item); - item = create_radio_menu_item_with_mnemonic (menu, item, _("Grid64"), - GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_64, FALSE); - g_object_set_data (G_OBJECT (window), "menu_grid_64", item); - item = create_radio_menu_item_with_mnemonic (menu, item, _("Grid128"), - GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_128, FALSE); - g_object_set_data (G_OBJECT (window), "menu_grid_128", item); - item = create_radio_menu_item_with_mnemonic (menu, item, _("Grid256"), - GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_256, FALSE); - g_object_set_data (G_OBJECT (window), "menu_grid_256", item); - menu_separator (menu); - item = create_check_menu_item_with_mnemonic (menu, _("Snap to grid"), - GTK_SIGNAL_FUNC (HandleCommand), ID_SNAPTOGRID, TRUE); - g_object_set_data (G_OBJECT (window), "menu_snaptogrid", item); - - // Textures menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_Textures")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - item = create_check_menu_item_with_mnemonic (menu, _("Show In _Use"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_SHOWINUSE, FALSE); - g_object_set_data (G_OBJECT (window), "menu_textures_showinuse", item); - item = create_check_menu_item_with_mnemonic (menu, _("Show _All"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_SHOWALL, FALSE); - g_object_set_data (G_OBJECT (window), "menu_textures_showall", item); - menu_separator (menu); - item = create_check_menu_item_with_mnemonic (menu, _("Show shaders"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_SHADERS_SHOW, FALSE); - g_object_set_data (G_OBJECT (window), "menu_textures_shaders_show", item); - item = create_menu_item_with_mnemonic (menu, _("Flush & Reload Shaders"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_RELOADSHADERS); - g_object_set_data (G_OBJECT (window), "menu_textures_reloadshaders", item); - item = create_menu_item_with_mnemonic (menu, _("Load directory..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_LOAD); - g_object_set_data (G_OBJECT (window), "menu_textures_load", item); - item = create_menu_item_with_mnemonic (menu, _("Directory list..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_LOADLIST); - menu_separator (menu); - - item = create_menu_item_with_mnemonic (menu, _("_Surface Inspector"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_INSPECTOR); - menu_separator (menu); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Render Quality")); - g_object_set_data (G_OBJECT (window), "render_quality_menu", menu_in_menu); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, NULL, _("_Wireframe"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_WIREFRAME, FALSE); - g_object_set_data (G_OBJECT (window), "menu_textures_wireframe", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("_Flat shade"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_FLATSHADE, FALSE); - g_object_set_data (G_OBJECT (window), "menu_textures_flatshade", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("_Nearest"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_NEAREST, FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_nearest", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("Nearest _Mipmap"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_NEARESTMIPMAP, FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_nearestmipmap", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("_Linear"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_LINEAR, FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_linear", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("_Bilinear"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_BILINEAR, FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_bilinear", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("B_ilinear Mipmap"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_BILINEARMIPMAP, FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_bilinearmipmap", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("T_rilinear"), - GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_TRILINEAR, FALSE); - g_object_set_data (G_OBJECT (window), "menu_view_trilinear", item); - create_menu_item_with_mnemonic (menu, _("Find / Replace..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURE_REPLACEALL); - - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Texture Lock")); - item = create_check_menu_item_with_mnemonic (menu_in_menu, _("Moves"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TOGGLE_LOCK, TRUE); - g_object_set_data (G_OBJECT (window), "menu_toggle_lock", item); - item = create_check_menu_item_with_mnemonic (menu_in_menu, _("Rotations"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TOGGLE_ROTATELOCK, TRUE); - g_object_set_data (G_OBJECT (window), "menu_toggle_rotatelock", item); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Texture Window Scale")); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, NULL, _("200%"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_TEXTUREWINDOWSCALE_200, FALSE); - g_object_set_data (G_OBJECT (window), "menu_textures_texturewindowscale_200", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("100%"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_TEXTUREWINDOWSCALE_100, FALSE); - g_object_set_data (G_OBJECT (window), "menu_textures_texturewindowscale_100", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("50%"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_TEXTUREWINDOWSCALE_50, FALSE); - g_object_set_data (G_OBJECT (window), "menu_textures_texturewindowscale_50", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("25%"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_TEXTUREWINDOWSCALE_25, FALSE); - g_object_set_data (G_OBJECT (window), "menu_textures_texturewindowscale_25", item); - item = create_radio_menu_item_with_mnemonic (menu_in_menu, item, _("10%"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_TEXTUREWINDOWSCALE_10, FALSE); - g_object_set_data (G_OBJECT (window), "menu_textures_texturewindowscale_10", item); - item = menu_separator (menu); - item = create_check_menu_item_with_mnemonic (menu, _("shaderlist.txt only"), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTURES_SHADERLISTONLY, FALSE); - g_object_set_data (G_OBJECT (window), "menu_textures_shaderlistonly", item); - item = menu_separator (menu); - g_object_set_data (G_OBJECT (window), "menu_textures_separator", item); - g_object_set_data (G_OBJECT (window), "menu_textures", menu); - - // Misc menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_Misc")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - create_menu_item_with_mnemonic (menu, _("_Benchmark"), GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_BENCHMARK); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Colors")); - menu_3 = create_menu_in_menu_with_mnemonic (menu_in_menu, _("Themes")); - create_menu_item_with_mnemonic (menu_3, _("QE4 Original"), GTK_SIGNAL_FUNC (HandleCommand), ID_COLOR_SETORIGINAL); - create_menu_item_with_mnemonic (menu_3, _("Q3Radiant Original"), GTK_SIGNAL_FUNC (HandleCommand), ID_COLOR_SETQER); - create_menu_item_with_mnemonic (menu_3, _("Black and Green"), GTK_SIGNAL_FUNC (HandleCommand), ID_COLOR_SETBLACK); - create_menu_item_with_mnemonic (menu_3, _("Maya/Max/Lightwave Emulation"), GTK_SIGNAL_FUNC (HandleCommand), ID_COLOR_SETYDNAR); - - menu_separator (menu_in_menu); - create_menu_item_with_mnemonic (menu_in_menu, _("_Texture Background..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTUREBK); - create_menu_item_with_mnemonic (menu_in_menu, _("Grid Background..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_XYBK); - create_menu_item_with_mnemonic (menu_in_menu, _("Grid Major..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_MAJOR); - create_menu_item_with_mnemonic (menu_in_menu, _("Grid Minor..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_MINOR); - create_menu_item_with_mnemonic (menu_in_menu, _("Grid Major Small..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_MAJOR_ALT); - create_menu_item_with_mnemonic (menu_in_menu, _("Grid Minor Small..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_MINOR_ALT); - create_menu_item_with_mnemonic (menu_in_menu, _("Grid Text..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_GRIDTEXT); - create_menu_item_with_mnemonic (menu_in_menu, _("Grid Block..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_GRIDBLOCK); - create_menu_item_with_mnemonic (menu_in_menu, _("Default Brush..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_BRUSH); - create_menu_item_with_mnemonic (menu_in_menu, _("Camera Background..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_CAMERABACK); - create_menu_item_with_mnemonic (menu_in_menu, _("Selected Brush..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_SELECTEDBRUSH); - create_menu_item_with_mnemonic (menu_in_menu, _("Selected Brush (Camera)..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_SELECTEDBRUSH3D); - create_menu_item_with_mnemonic (menu_in_menu, _("Clipper..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_CLIPPER); - create_menu_item_with_mnemonic (menu_in_menu, _("Active View name..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_COLORS_VIEWNAME); - - create_menu_item_with_mnemonic (menu, _("_Gamma..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_GAMMA); - create_menu_item_with_mnemonic (menu, _("Find brush..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_FINDBRUSH); - item = create_menu_item_with_mnemonic (menu, _("Next leak spot"), - GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_NEXTLEAKSPOT); - item = create_menu_item_with_mnemonic (menu, _("Previous leak spot"), - GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_PREVIOUSLEAKSPOT); - // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394 -// create_menu_item_with_mnemonic (menu, "_Print XY View", GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_PRINTXY); - item = create_menu_item_with_mnemonic (menu, _("_Select Entity Color..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_SELECTENTITYCOLOR); - g_object_set_data (G_OBJECT (window), "menu_misc_selectentitycolor", item); - - // Region menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_Region")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - create_menu_item_with_mnemonic (menu, _("_Off"), - GTK_SIGNAL_FUNC (HandleCommand), ID_REGION_OFF); - create_menu_item_with_mnemonic (menu, _("_Set XY"), - GTK_SIGNAL_FUNC (HandleCommand), ID_REGION_SETXY); - create_menu_item_with_mnemonic (menu, _("Set _Tall Brush"), - GTK_SIGNAL_FUNC (HandleCommand), ID_REGION_SETTALLBRUSH); - create_menu_item_with_mnemonic (menu, _("Set _Brush"), - GTK_SIGNAL_FUNC (HandleCommand), ID_REGION_SETBRUSH); - create_menu_item_with_mnemonic (menu, _("Set Se_lected Brushes"), - GTK_SIGNAL_FUNC (HandleCommand), ID_REGION_SETSELECTION); - - // Brush menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_Brush")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - item = create_menu_item_with_mnemonic (menu, _("3 sided"), GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_3SIDED); - item = create_menu_item_with_mnemonic (menu, _("4 sided"), GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_4SIDED); - item = create_menu_item_with_mnemonic (menu, _("5 sided"), GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_5SIDED); - item = create_menu_item_with_mnemonic (menu, _("6 sided"), GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_6SIDED); - item = create_menu_item_with_mnemonic (menu, _("7 sided"), GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_7SIDED); - item = create_menu_item_with_mnemonic (menu, _("8 sided"), GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_8SIDED); - item = create_menu_item_with_mnemonic (menu, _("9 sided"), GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_9SIDED); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("Arbitrary sided..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_ARBITRARYSIDED); - menu_separator (menu); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Primitives")); - create_menu_item_with_mnemonic (menu_in_menu, _("Cone..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_MAKECONE); - create_menu_item_with_mnemonic (menu_in_menu, _("Sphere..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_BRUSH_PRIMITIVES_SPHERE); - - // Curve menu - if (!g_pGameDescription->mNoPatch) - { - menu = create_sub_menu_with_mnemonic (menu_bar, _("_Curve")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - create_menu_item_with_mnemonic (menu, _("Cylinder"), GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_PATCHTUBE); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("More Cylinders")); - create_menu_item_with_mnemonic (menu_in_menu, _("Dense Cylinder"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_PATCHDENSETUBE); - create_menu_item_with_mnemonic (menu_in_menu, _("Very Dense Cylinder"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_PATCHVERYDENSETUBE); - create_menu_item_with_mnemonic (menu_in_menu, _("Square Cylinder"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_PATCHSQUARE); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("End cap"), GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_PATCHENDCAP); - create_menu_item_with_mnemonic (menu, _("Bevel"), GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_PATCHBEVEL); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("More End caps, Bevels")); - create_menu_item_with_mnemonic (menu_in_menu, _("Square Endcap"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_MOREENDCAPSBEVELS_SQUAREBEVEL); - create_menu_item_with_mnemonic (menu_in_menu, _("Square Bevel"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_MOREENDCAPSBEVELS_SQUAREENDCAP); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("Cone"), GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_PATCHCONE); - item = create_menu_item_with_mnemonic (menu, _("Sphere"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_PRIMITIVES_SPHERE); - gtk_widget_set_sensitive (item, FALSE); - menu_separator (menu); - item = create_menu_item_with_mnemonic (menu, _("Simple Patch Mesh..."), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_SIMPLEPATCHMESH); - g_object_set_data (G_OBJECT (window), "menu_simplepatchmesh", item); - menu_separator (menu); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Insert")); - create_menu_item_with_mnemonic (menu_in_menu, _("Insert (2) Columns"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_INSERT_INSERTCOLUMN); - create_menu_item_with_mnemonic (menu_in_menu, _("Add (2) Columns"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_INSERT_ADDCOLUMN); - menu_separator (menu_in_menu); - create_menu_item_with_mnemonic (menu_in_menu, _("Insert (2) Rows"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_INSERT_INSERTROW); - create_menu_item_with_mnemonic (menu_in_menu, _("Add (2) Rows"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_INSERT_ADDROW); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Delete")); - create_menu_item_with_mnemonic (menu_in_menu, _("First (2) Columns"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_DELETE_FIRSTCOLUMN); - create_menu_item_with_mnemonic (menu_in_menu, _("Last (2) Columns"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_DELETE_LASTCOLUMN); - menu_separator (menu_in_menu); - create_menu_item_with_mnemonic (menu_in_menu, _("First (2) Rows"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_DELETE_FIRSTROW); - create_menu_item_with_mnemonic (menu_in_menu, _("Last (2) Rows"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_DELETE_LASTROW); - menu_separator (menu); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Matrix")); - create_menu_item_with_mnemonic (menu_in_menu, _("Invert"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_NEGATIVE); - menu_3 = create_menu_in_menu_with_mnemonic (menu_in_menu, _("Re-disperse")); - create_menu_item_with_mnemonic (menu_3, _("Rows"), GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_REDISPERSE_ROWS); - create_menu_item_with_mnemonic (menu_3, _("Cols (Intermediate)"), GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_REDISPERSE_INTERMEDIATE_COLS); - create_menu_item_with_mnemonic (menu_3, _("Rows (Intermediate)"), GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_REDISPERSE_INTERMEDIATE_ROWS); - create_menu_item_with_mnemonic (menu_in_menu, _("Transpose"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_MATRIX_TRANSPOSE); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("Cap Selection"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_CAP); - create_menu_item_with_mnemonic (menu, _("Cycle Cap Texture"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_CYCLECAP); - menu_separator (menu); - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, _("Overlay")); - create_menu_item_with_mnemonic (menu_in_menu, _("Set"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_OVERLAY_SET); - create_menu_item_with_mnemonic (menu_in_menu, _("Clear"), - GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_OVERLAY_CLEAR); - menu_separator (menu); - create_menu_item_with_mnemonic (menu, _("Thicken..."), GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_THICKEN); - } - // Plugins menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_Plugins")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - /* - create_menu_item_with_mnemonic (menu, "Refresh", GTK_SIGNAL_FUNC (HandleCommand), ID_PLUGINS_REFRESH); - */ - // NOTE: the seperator is used when doing a refresh of the list, everything past the seperator is removed - item = menu_separator (menu); - g_object_set_data (G_OBJECT (window), "menu_plugin_separator", item); - g_object_set_data (G_OBJECT (window), "menu_plugin", menu); - - // Help menu - menu = create_sub_menu_with_mnemonic (menu_bar, _("_Help")); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - item = create_menu_item_with_mnemonic (menu, _("Manual"), - GTK_SIGNAL_FUNC (HandleCommand), ID_HELP); - gtk_widget_add_accelerator (item, "activate", accel, GDK_F1, (GdkModifierType)0, GTK_ACCEL_VISIBLE); - - // this creates all the per-game drop downs for the game pack helps - // it will take care of hooking the Sys_OpenURL calls etc. - create_game_help_menu(menu, accel); - - // TTimo: this is in global.xlink now - //create_menu_item_with_mnemonic (menu, "Links", - // GTK_SIGNAL_FUNC (HandleCommand), ID_HELP_LINKS); - create_menu_item_with_mnemonic (menu, _("Bug report"), - GTK_SIGNAL_FUNC (HandleCommand), ID_HELP_BUGREPORT); - create_menu_item_with_mnemonic (menu, _("Shortcuts list"), - GTK_SIGNAL_FUNC (HandleCommand), ID_HELP_COMMANDLIST); - create_menu_item_with_mnemonic (menu, _("_About"), - GTK_SIGNAL_FUNC (HandleCommand), ID_HELP_ABOUT); - - - // leo: Hidden menu to make the accelerators work, - // this is a hack that needs to be changed later if someone has a better idea. - // NOTE TTimo - // maybe the better idea would be NOT to use any such accelerator scheme and do all key listening and interpret ourselves - menu = create_sub_menu_with_mnemonic (menu_bar, "Hidden"); - if (g_PrefsDlg.m_bDetachableMenus) - menu_tearoff (menu); - - gtk_widget_hide (gtk_menu_get_attach_widget (GTK_MENU (menu))); - - create_menu_item_with_mnemonic (menu, "BendMode", GTK_SIGNAL_FUNC (HandleCommand), ID_PATCH_BEND); - create_menu_item_with_mnemonic (menu, "FitTexture", GTK_SIGNAL_FUNC (HandleCommand), IDC_BTN_FACEFIT); - create_menu_item_with_mnemonic (menu, "ViewTextures", GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_TEXTURE); - create_menu_item_with_mnemonic (menu, "PatchInspector", GTK_SIGNAL_FUNC (HandleCommand), ID_PATCH_INSPECTOR); - create_menu_item_with_mnemonic (menu, "InvertCurveTextureX", GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_NEGATIVETEXTUREY); - create_menu_item_with_mnemonic (menu, "InvertCurveTextureY", GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_NEGATIVETEXTUREX); - create_menu_item_with_mnemonic (menu, "IncPatchColumn", GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_INSERTCOLUMN); - create_menu_item_with_mnemonic (menu, "IncPatchRow", GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_INSERTROW); - create_menu_item_with_mnemonic (menu, "DecPatchColumn", GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_DELETECOLUMN); - create_menu_item_with_mnemonic (menu, "DecPatchRow", GTK_SIGNAL_FUNC (HandleCommand), ID_CURVE_DELETEROW); - create_menu_item_with_mnemonic (menu, "Patch TAB", GTK_SIGNAL_FUNC (HandleCommand), ID_PATCH_TAB); - create_menu_item_with_mnemonic (menu, "Patch TAB", GTK_SIGNAL_FUNC (HandleCommand), ID_PATCH_TAB); - create_menu_item_with_mnemonic (menu, "SelectNudgeDown", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECT_NUDGEDOWN); - create_menu_item_with_mnemonic (menu, "CameraForward", GTK_SIGNAL_FUNC (HandleCommand), ID_CAMERA_FORWARD); - create_menu_item_with_mnemonic (menu, "CameraBack", GTK_SIGNAL_FUNC (HandleCommand), ID_CAMERA_BACK); - create_menu_item_with_mnemonic (menu, "CameraLeft", GTK_SIGNAL_FUNC (HandleCommand), ID_CAMERA_LEFT); - create_menu_item_with_mnemonic (menu, "CameraRight", GTK_SIGNAL_FUNC (HandleCommand), ID_CAMERA_RIGHT); - create_menu_item_with_mnemonic (menu, "CameraUp", GTK_SIGNAL_FUNC (HandleCommand), ID_CAMERA_UP); - create_menu_item_with_mnemonic (menu, "CameraDown", GTK_SIGNAL_FUNC (HandleCommand), ID_CAMERA_DOWN); - create_menu_item_with_mnemonic (menu, "CameraAngleUp", GTK_SIGNAL_FUNC (HandleCommand), ID_CAMERA_ANGLEUP); - create_menu_item_with_mnemonic (menu, "CameraAngleDown", GTK_SIGNAL_FUNC (HandleCommand), ID_CAMERA_ANGLEDOWN); - create_menu_item_with_mnemonic (menu, "CameraStrafeRight", GTK_SIGNAL_FUNC (HandleCommand), ID_CAMERA_STRAFERIGHT); - create_menu_item_with_mnemonic (menu, "CameraStrafeLeft", GTK_SIGNAL_FUNC (HandleCommand), ID_CAMERA_STRAFELEFT); - create_menu_item_with_mnemonic (menu, "ToggleGrid", GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_TOGGLE); - create_menu_item_with_mnemonic (menu, "ToggleCrosshairs", GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_CROSSHAIR); - create_menu_item_with_mnemonic (menu, "ToggleRealtime", GTK_SIGNAL_FUNC (HandleCommand), ID_VIEW_CAMERAUPDATE); - create_menu_item_with_mnemonic (menu, "MouseRotate", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECT_MOUSEROTATE); - create_menu_item_with_mnemonic (menu, "TexRotateClock", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_TEXTURE_ROTATECLOCK); - create_menu_item_with_mnemonic (menu, "TexRotateCounter", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_TEXTURE_ROTATECOUNTER); - create_menu_item_with_mnemonic (menu, "TexScaleUp", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_TEXTURE_SCALEUP); - create_menu_item_with_mnemonic (menu, "TexScaleDown", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_TEXTURE_SCALEDOWN); - create_menu_item_with_mnemonic (menu, "TexShiftLeft", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_TEXTURE_SHIFTLEFT); - create_menu_item_with_mnemonic (menu, "TexShiftRight", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_TEXTURE_SHIFTRIGHT); - create_menu_item_with_mnemonic (menu, "TexShiftUp", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_TEXTURE_SHIFTUP); - create_menu_item_with_mnemonic (menu, "TexShiftDown", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_TEXTURE_SHIFTDOWN); - create_menu_item_with_mnemonic (menu, "GridDown", GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_PREV); - create_menu_item_with_mnemonic (menu, "GridUp", GTK_SIGNAL_FUNC (HandleCommand), ID_GRID_NEXT); - create_menu_item_with_mnemonic (menu, "TexScaleLeft", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_TEXTURE_SCALELEFT); - create_menu_item_with_mnemonic (menu, "TexScaleRight", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_TEXTURE_SCALERIGHT); - create_menu_item_with_mnemonic (menu, "MoveSelectionDOWN", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_MOVEDOWN); - create_menu_item_with_mnemonic (menu, "MoveSelectionUP", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_MOVEUP); - create_menu_item_with_mnemonic (menu, "DumpSelectedBrush", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_PRINT); - create_menu_item_with_mnemonic (menu, "ToggleSizePaint", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_TOGGLESIZEPAINT); - create_menu_item_with_mnemonic (menu, "SelectNudgeLeft", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECT_NUDGELEFT); - create_menu_item_with_mnemonic (menu, "SelectNudgeRight", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECT_NUDGERIGHT); - create_menu_item_with_mnemonic (menu, "SelectNudgeUp", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_SELECT_NUDGEUP); - create_menu_item_with_mnemonic (menu, "NaturalizePatch", GTK_SIGNAL_FUNC (HandleCommand), ID_PATCH_NATURALIZE); - create_menu_item_with_mnemonic (menu, "SnapPatchToGrid", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECT_SNAPTOGRID); - create_menu_item_with_mnemonic (menu, "SelectAllOfType", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECT_ALL); - create_menu_item_with_mnemonic (menu, "CycleOutlineStyle", GTK_SIGNAL_FUNC (HandleCommand), ID_SELECTION_OUTLINESTYLE); - create_menu_item_with_mnemonic (menu, "TextureWindowScaleup", GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTUREWINDOW_SCALEUP); - create_menu_item_with_mnemonic (menu, "TextureWindowScaledown", GTK_SIGNAL_FUNC (HandleCommand), ID_TEXTUREWINDOW_SCALEDOWN); - - g_bIgnoreCommands--; -} - -void MainFrame::create_main_toolbar (GtkWidget *window, GtkWidget *vbox) -{ - GtkWidget *handle_box, *toolbar, *w; - - handle_box = gtk_handle_box_new (); - gtk_box_pack_start (GTK_BOX (vbox), handle_box, FALSE, FALSE, 0); - gtk_widget_show (handle_box); - g_object_set_data (G_OBJECT (window), "tb_handle_box", handle_box); - - toolbar = gtk_toolbar_new (); - gtk_toolbar_set_orientation (GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL); - gtk_toolbar_set_style (GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); - // gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), user_rc.toolbar_style); - gtk_container_add (GTK_CONTAINER (handle_box), toolbar); - - gtk_widget_show (toolbar); - - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Open"), _("Open an existing map"), "", - new_pixmap (window, "file_open.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_FILE_OPEN)); - g_object_set_data (G_OBJECT (window), "tb_file_open", w); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Save"), _("Save the active map"), "", - new_pixmap (window, "file_save.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_FILE_SAVE)); - g_object_set_data (G_OBJECT (window), "tb_file_save", w); - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("x-axis Flip"), "", - new_pixmap (window, "brush_flipx.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_BRUSH_FLIPX)); - g_object_set_data (G_OBJECT (window), "tb_brush_flipx", w); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("x-axis Rotate"), "", - new_pixmap (window, "brush_rotatex.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_BRUSH_ROTATEX)); - g_object_set_data (G_OBJECT (window), "tb_brush_rotatex", w); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("y-axis Flip"), "", - new_pixmap (window, "brush_flipy.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_BRUSH_FLIPY)); - g_object_set_data (G_OBJECT (window), "tb_brush_flipy", w); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("y-axis Rotate"), "", - new_pixmap (window, "brush_rotatey.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_BRUSH_ROTATEY)); - g_object_set_data (G_OBJECT (window), "tb_brush_rotatey", w); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("z-axis Flip"), "", - new_pixmap (window, "brush_flipz.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_BRUSH_FLIPZ)); - g_object_set_data (G_OBJECT (window), "tb_brush_flipz", w); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("z-axis Rotate"), "", - new_pixmap (window, "brush_rotatez.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_BRUSH_ROTATEZ)); - g_object_set_data (G_OBJECT (window), "tb_brush_rotatez", w); - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - - if (g_PrefsDlg.m_bWideToolbar) - { - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("Complete Tall"), "", - new_pixmap (window, "selection_selectcompletetall.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_SELECTION_SELECTCOMPLETETALL)); - g_object_set_data (G_OBJECT (window), "tb_selection_selectcompletetall", w); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("Select Touching"), "", - new_pixmap (window, "selection_selecttouching.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_SELECTION_SELECTTOUCHING)); - g_object_set_data (G_OBJECT (window), "tb_selection_selecttouching", w); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("Select Partial Tall"), "", - new_pixmap (window, "selection_selectpartialtall.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_SELECTION_SELECTPARTIALTALL)); - g_object_set_data (G_OBJECT (window), "tb_selection_selectpartialtall", w); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("Select Inside"), "", - new_pixmap (window, "selection_selectinside.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_SELECTION_SELECTINSIDE)); - g_object_set_data (G_OBJECT (window), "tb_selection_selectinside", w); - } else - { - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("Selection"), "", - new_pixmap (window, "popup_selection.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_POPUP_SELECTION)); - g_object_set_data (G_OBJECT (window), "tb_popup_selection", w); - } - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("CSG Subtract"), "", - new_pixmap (window, "selection_csgsubtract.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_SELECTION_CSGSUBTRACT)); - g_object_set_data (G_OBJECT (window), "tb_selection_csgsubtract", w); - - if (g_PrefsDlg.m_bWideToolbar) - { - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("CSG Merge"), "", - new_pixmap (window, "selection_csgmerge.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_SELECTION_CSGMERGE)); - g_object_set_data (G_OBJECT (window), "tb_selection_csgmerge", w); - } - - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("Hollow"), "", - new_pixmap (window, "selection_makehollow.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_SELECTION_MAKEHOLLOW)); - g_object_set_data (G_OBJECT (window), "tb_selection_makehollow", w); - - if (g_PrefsDlg.m_bWideToolbar) - { - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Clipper"), "", new_pixmap (window, "view_clipper.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_VIEW_CLIPPER)); - g_object_set_data (G_OBJECT (window), "tb_view_clipper", w); - } - - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("Change views"), "", - new_pixmap (window, "view_change.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_VIEW_CHANGE)); - g_object_set_data (G_OBJECT (window), "tb_view_change", w); - - if (!g_PrefsDlg.m_bWideToolbar) - { - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - } - - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("Texture view mode"), "", - new_pixmap (window, "textures_popup.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_TEXTURES_POPUP)); - g_object_set_data (G_OBJECT (window), "tb_textures_popup", w); - - if (g_PrefsDlg.m_bWideToolbar) - { - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Cubic clip the camera view"), "", - new_pixmap (window, "view_cubicclipping.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_VIEW_CUBICCLIPPING)); - g_object_set_data (G_OBJECT (window), "tb_view_cubicclipping", w); - } - - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - - if (!g_PrefsDlg.m_bWideToolbar) - { - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Camera preview"), "", new_pixmap (window, "view_cameratoggle.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_VIEW_CAMERATOGGLE)); - g_object_set_data (G_OBJECT (window), "tb_view_cameratoggle", w); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", "Update Camera", "", - new_pixmap (window, "view_cameraupdate.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_VIEW_CAMERAUPDATE)); - g_object_set_data (G_OBJECT (window), "tb_view_cameraupdate", w); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Cubic clip the camera view"), "", - new_pixmap (window, "view_cubicclipping.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_VIEW_CUBICCLIPPING)); - g_object_set_data (G_OBJECT (window), "tb_view_cubicclipping", w); - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Entity inspector"), "", new_pixmap (window, "view_entity.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_VIEW_ENTITY)); - g_object_set_data (G_OBJECT (window), "tb_view_entity", w); - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Clipper"), "", new_pixmap (window, "view_clipper.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_VIEW_CLIPPER)); - g_object_set_data (G_OBJECT (window), "tb_view_clipper", w); - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - } - - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Free Rotation"), "", new_pixmap (window, "select_mouserotate.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_SELECT_MOUSEROTATE)); - g_object_set_data (G_OBJECT (window), "tb_select_mouserotate", w); - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Free Scaling"), "", new_pixmap (window, "select_mousescale.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_SELECT_MOUSESCALE)); - g_object_set_data (G_OBJECT (window), "tb_select_mousescale", w); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Scale X"), "", new_pixmap (window, "scalelockx.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_SCALELOCKX)); - g_object_set_data (G_OBJECT (window), "tb_scalelockx", w); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Scale Y"), "", new_pixmap (window, "scalelocky.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_SCALELOCKY)); - g_object_set_data (G_OBJECT (window), "tb_scalelocky", w); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Scale Z"), "", new_pixmap (window, "scalelockz.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_SCALELOCKZ)); - g_object_set_data (G_OBJECT (window), "tb_scalelockz", w); - - if (g_PrefsDlg.m_bWideToolbar) - { - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Don't select model brushes"), "", - new_pixmap (window, "dontselectmodel.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_DONTSELECTMODEL)); - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - g_object_set_data (G_OBJECT (window), "tb_dontselectmodel", w); - - if (!g_pGameDescription->mNoPatch) - { - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Don't select curved brushes"), "", - new_pixmap (window, "dontselectcurve.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_DONTSELECTCURVE)); - g_object_set_data (G_OBJECT (window), "tb_dontselectcurve", w); - } - } - - // bug #292, patch toolbar option - if (g_PrefsDlg.m_bPatchToolbar) - { - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Show patch bounding box"), "", - new_pixmap (window, "patch_showboundingbox.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_PATCH_SHOWBOUNDINGBOX)); - g_object_set_data (G_OBJECT (window), "tb_patch_showboundingbox", w); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Show patches as wireframes"), "", - new_pixmap (window, "patch_wireframe.bmp"), - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (ID_PATCH_WIREFRAME)); - g_object_set_data (G_OBJECT (window), "tb_patch_wireframe", w); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Patch Bend mode"), "", - new_pixmap (window, "patch_bend.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_PATCH_BEND)); - g_object_set_data (G_OBJECT (window), "tb_patch_bend", w); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("Put caps on the current patch"), "", - new_pixmap (window, "curve_cap.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_CURVE_CAP)); - g_object_set_data (G_OBJECT (window), "tb_curve_cap", w); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Welds equal patch points during moves"), "", - new_pixmap (window, "patch_weld.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_PATCH_WELD)); - g_object_set_data (G_OBJECT (window), "tb_patch_weld", w); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, - "", _("Selects drill down rows and columns"), "", - new_pixmap (window, "patch_drilldown.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_PATCH_DRILLDOWN)); - g_object_set_data (G_OBJECT (window), "tb_patch_drilldown", w); - } - - if (g_PrefsDlg.m_bWideToolbar) - { - gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); - w = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "", _("Show Entities as"), "", - new_pixmap (window, "show_entities.bmp"), GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ID_SHOW_ENTITIES)); - g_object_set_data (G_OBJECT (window), "tb_show_entities", w); - } - - /* - uh? that is OLD -#ifndef QUAKE3 - w = g_object_get_data (G_OBJECT (window), "tb_dontselectcurve"); - gtk_widget_hide (w); - w = g_object_get_data (G_OBJECT (window), "tb_patch_showboundingbox"); - gtk_widget_hide (w); - w = g_object_get_data (G_OBJECT (window), "tb_patch_weld"); - gtk_widget_hide (w); - w = g_object_get_data (G_OBJECT (window), "tb_patch_wireframe"); - gtk_widget_hide (w); -#endif - */ - m_bCamPreview = true; - g_nScaleHow = (SCALE_X | SCALE_Y | SCALE_Z); +const char* EnginePath_get(){ + ASSERT_MESSAGE( g_enginepath_unrealised == 0, "EnginePath_get: engine path not realised" ); + return g_strEnginePath.c_str(); } -void MainFrame::create_plugin_toolbar (GtkWidget *window, GtkWidget *vbox) -{ - GtkWidget *handle_box, *toolbar; +void EnginePath_Unrealise(){ + if ( ++g_enginepath_unrealised == 1 ) { + g_enginePathObservers.unrealise(); + } +} - handle_box = gtk_handle_box_new (); - gtk_box_pack_start (GTK_BOX (vbox), handle_box, FALSE, FALSE, 0); - if (g_PrefsDlg.m_bPluginToolbar) - gtk_widget_show (handle_box); - g_object_set_data (G_OBJECT (window), "tb_handle_box", handle_box); +void setEnginePath( const char* path ){ + StringOutputStream buffer( 256 ); + buffer << DirectoryCleaned( path ); + if ( !path_equal( buffer.c_str(), g_strEnginePath.c_str() ) ) { +#if 0 + while ( !ConfirmModified( "Paths Changed" ) ) + { + if ( Map_Unnamed( g_map ) ) { + Map_SaveAs(); + } + else + { + Map_Save(); + } + } + Map_RegionOff(); +#endif - toolbar = gtk_toolbar_new(); - gtk_toolbar_set_orientation (GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL); - gtk_toolbar_set_style (GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); - // gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), user_rc.toolbar_style); - gtk_container_add (GTK_CONTAINER (handle_box), toolbar); - g_object_set_data (G_OBJECT (window), "toolbar_plugin", toolbar); - gtk_widget_show (toolbar); -} + ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Changing Engine Path" ); -void MainFrame::create_main_statusbar (GtkWidget *window, GtkWidget *vbox) -{ - GtkWidget *hbox, *hbox1; - GtkWidget *frame; - GtkWidget *label; - - hbox = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox); - gtk_widget_set_usize (hbox, -1, 24); - gtk_container_border_width (GTK_CONTAINER (hbox), 1); - gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, TRUE, 2); - - frame = gtk_frame_new ((char*)NULL); - gtk_widget_show (frame); - gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - - hbox1 = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), hbox1); - gtk_container_border_width (GTK_CONTAINER (hbox1), 0); - gtk_widget_show (hbox1); - - label = gtk_label_new (_(" Label ")); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, TRUE, 0); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_misc_set_padding (GTK_MISC (label), 3, 0); - m_pStatusLabel[0] = label; - - for (int i = 1; i < 6; i++) - { - frame = gtk_frame_new ((char*)NULL); - gtk_widget_show (frame); - gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - - label = gtk_label_new (_(" Label ")); - gtk_widget_show (label); - gtk_container_add (GTK_CONTAINER (frame), label); - m_pStatusLabel[i] = label; - } -} - -guint s_idle_id; -static gint mainframe_idle (gpointer user_data) -{ - g_pParentWnd->RoutineProcessing (); - return TRUE; -} + EnginePath_Unrealise(); -static void Sys_Iconify (GtkWidget *w); -static void Sys_Restore (GtkWidget *w); + g_strEnginePath = buffer.c_str(); -inline void CHECK_RESTORE(GtkWidget* w) -{ - if (g_object_get_data (G_OBJECT (w), "was_mapped") != NULL) - gtk_widget_show (w); + EnginePath_Realise(); + } } -// this is called when the window is restored from the iconified state -static void mainframe_map (GtkWidget *widget) -{ - if (g_pParentWnd->IsSleeping ()) - g_pParentWnd->OnSleep (); - - if ((g_pParentWnd->CurrentStyle() == MainFrame::eFloating) && (widget == g_pParentWnd->m_pWidget)) - { - // restore previously visible windows - CHECK_RESTORE (g_pParentWnd->GetCamWnd ()->m_pParent); - if (g_PrefsDlg.m_bFloatingZ) - CHECK_RESTORE (g_pParentWnd->GetZWnd ()->m_pParent); - CHECK_RESTORE (g_pParentWnd->GetXYWnd ()->m_pParent); - CHECK_RESTORE (g_pParentWnd->GetXZWnd ()->m_pParent); - CHECK_RESTORE (g_pParentWnd->GetYZWnd ()->m_pParent); - CHECK_RESTORE (g_pGroupDlg->m_pWidget); - } -} - -inline void CHECK_MINIMIZE(GtkWidget* w) -{ - g_object_set_data (G_OBJECT (w), "was_mapped", (void*)(GTK_WIDGET_VISIBLE (w) != 0)); - gtk_widget_hide (w); -} +// App Path -static void mainframe_unmap (GtkWidget *widget) -{ +CopiedString g_strAppPath; ///< holds the full path of the executable - if ((g_pParentWnd->CurrentStyle() == MainFrame::eFloating) && (widget == g_pParentWnd->m_pWidget)) - { - // minimize all other windows when the main window is minimized - CHECK_MINIMIZE (g_pParentWnd->GetCamWnd ()->m_pParent); - if (g_PrefsDlg.m_bFloatingZ) - CHECK_MINIMIZE (g_pParentWnd->GetZWnd ()->m_pParent); - CHECK_MINIMIZE (g_pParentWnd->GetXYWnd ()->m_pParent); - CHECK_MINIMIZE (g_pParentWnd->GetXZWnd ()->m_pParent); - CHECK_MINIMIZE (g_pParentWnd->GetYZWnd ()->m_pParent); - CHECK_MINIMIZE (g_pGroupDlg->m_pWidget); - } +const char* AppPath_get(){ + return g_strAppPath.c_str(); } -static GtkWidget* create_floating (MainFrame* mainframe) -{ - GtkWidget *wnd = gtk_window_new (GTK_WINDOW_TOPLEVEL); - //if (mainframe->CurrentStyle() != MainFrame::eFloating) - gtk_window_set_transient_for (GTK_WINDOW (wnd), GTK_WINDOW (mainframe->m_pWidget)); - gtk_widget_set_events (wnd, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); - gtk_signal_connect (GTK_OBJECT (wnd), "delete_event", GTK_SIGNAL_FUNC (widget_delete_hide), NULL); - gtk_signal_connect (GTK_OBJECT (wnd), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL); - gtk_signal_connect (GTK_OBJECT (wnd), "key_press_event", - GTK_SIGNAL_FUNC (mainframe_keypress), mainframe); - gtk_signal_connect (GTK_OBJECT (wnd), "key_release_event", - GTK_SIGNAL_FUNC (mainframe_keyrelease), mainframe); - gtk_signal_connect (GTK_OBJECT (wnd), "map_event", - GTK_SIGNAL_FUNC (mainframe_map), mainframe); - - gtk_window_set_default_size (GTK_WINDOW (wnd), 100, 100); - -#ifdef DBG_WINDOWPOS - Sys_Printf("create_floating: %p, gtk_window_set_default_size 100, 100\n", wnd); -#endif +/// the path to the local rc-dir +const char* LocalRcPath_get( void ){ + static CopiedString rc_path; + if ( rc_path.empty() ) { + StringOutputStream stream( 256 ); + stream << GlobalRadiant().getSettingsPath() << g_pGameDescription->mGameFile.c_str() << "/"; + rc_path = stream.c_str(); + } + return rc_path.c_str(); +} - return wnd; +/// directory for temp files +/// NOTE: on *nix this is were we check for .pid +CopiedString g_strSettingsPath; +const char* SettingsPath_get(){ + return g_strSettingsPath.c_str(); } -void console_populate_popup(GtkTextView* textview, GtkMenu* menu, gpointer user_data) -{ - menu_separator(GTK_WIDGET(menu)); - GtkWidget* item = gtk_menu_item_new_with_label (_("Clear")); - gtk_signal_connect (GTK_OBJECT (item), "activate", GTK_SIGNAL_FUNC (Sys_ClearPrintf), NULL); - gtk_widget_show (item); - gtk_menu_append (GTK_MENU (menu), item); -} +/*! + points to the game tools directory, for instance + C:/Program Files/Quake III Arena/GtkRadiant + (or other games) + this is one of the main variables that are configured by the game selection on startup + [GameToolsPath]/plugins + [GameToolsPath]/modules + and also q3map, bspc + */ +CopiedString g_strGameToolsPath; ///< this is set by g_GamesDialog -void console_construct(GtkWidget* textview) -{ - g_signal_connect(G_OBJECT(textview), "populate-popup", G_CALLBACK(console_populate_popup), NULL); +const char* GameToolsPath_get(){ + return g_strGameToolsPath.c_str(); } -extern MemStream g_Clipboard; - -void Clipboard_CopyMap() -{ - g_Clipboard.SetLength(0); - Map_Export (&g_Clipboard, "xmap", false, true); +void EnginePathImport( CopiedString& self, const char* value ){ + setEnginePath( value ); } +typedef ReferenceCaller1 EnginePathImportCaller; -void Clipboard_PasteMap() -{ - if (g_Clipboard.GetLength() > 0) - { - g_Clipboard.Seek(0, SEEK_SET); - Map_Import(&g_Clipboard, "xmap", true); - } +void Paths_constructPreferences( PreferencesPage& page ){ + page.appendPathEntry( "Engine Path", true, + StringImportCallback( EnginePathImportCaller( g_strEnginePath ) ), + StringExportCallback( StringExportCaller( g_strEnginePath ) ) + ); +} +void Paths_constructPage( PreferenceGroup& group ){ + PreferencesPage page( group.createPage( "Paths", "Path Settings" ) ); + Paths_constructPreferences( page ); +} +void Paths_registerPreferencesPage(){ + PreferencesDialog_addSettingsPage( FreeCaller1() ); } -/*! -Platform-independent GTK clipboard support. -\todo Using GDK_SELECTION_CLIPBOARD fails on win32, so we use the win32 API directly for now. -*/ -#if defined (__linux__) || defined (__APPLE__) -enum +class PathsDialog : public Dialog { - RADIANT_CLIPPINGS = 23, -}; - -static const GtkTargetEntry clipboard_targets[] = { - { "RADIANT_CLIPPINGS", 0, RADIANT_CLIPPINGS, }, -}; +public: +ui::Window BuildDialog(){ + auto frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN ); -static void clipboard_get (GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, gpointer user_data_or_owner) -{ - guchar *buffer; - gint len; - GdkAtom type = GDK_NONE; + auto vbox2 = create_dialog_vbox( 0, 4 ); + gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); - len = g_Clipboard.GetLength(); + { + PreferencesPage preferencesPage( *this, ui::Widget(GTK_WIDGET( vbox2 )) ); + Paths_constructPreferences( preferencesPage ); + } - if (!len) - { - buffer = NULL; - } else - { - buffer = g_Clipboard.GetBuffer (); - } + return ui::Window(create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, frame )); +} +}; - if(info == clipboard_targets[0].info) - { - type = gdk_atom_intern(clipboard_targets[0].target, FALSE); - } +PathsDialog g_PathsDialog; - gtk_selection_data_set (selection_data, type, 8, buffer, len); +void EnginePath_verify(){ + if ( !file_exists( g_strEnginePath.c_str() ) ) { + g_PathsDialog.Create(); + g_PathsDialog.DoModal(); + g_PathsDialog.Destroy(); + } } -static void clipboard_clear (GtkClipboard *clipboard, gpointer user_data_or_owner) +namespace { +CopiedString g_gamename; +CopiedString g_gamemode; +ModuleObservers g_gameNameObservers; +ModuleObservers g_gameModeObservers; } -static void clipboard_received (GtkClipboard *clipboard, GtkSelectionData *data, gpointer user_data) -{ - g_Clipboard.SetLength (0); +void Radiant_attachGameNameObserver( ModuleObserver& observer ){ + g_gameNameObservers.attach( observer ); +} - if (data->length < 0) - Sys_FPrintf(SYS_ERR, "Error retrieving selection\n"); - else if(strcmp(gdk_atom_name(data->type), clipboard_targets[0].target) == 0) - g_Clipboard.Write (data->data, data->length); +void Radiant_detachGameNameObserver( ModuleObserver& observer ){ + g_gameNameObservers.detach( observer ); +} - Clipboard_PasteMap(); +const char* basegame_get(){ + return g_pGameDescription->getRequiredKeyValue( "basegame" ); } -void clipboard_copy() -{ - Clipboard_CopyMap(); +const char* gamename_get(){ + const char* gamename = g_gamename.c_str(); + if ( string_empty( gamename ) ) { + return basegame_get(); + } + return gamename; +} - GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); +void gamename_set( const char* gamename ){ + if ( !string_equal( gamename, g_gamename.c_str() ) ) { + g_gameNameObservers.unrealise(); + g_gamename = gamename; + g_gameNameObservers.realise(); + } +} - gtk_clipboard_set_with_data (clipboard, clipboard_targets, 1, clipboard_get, clipboard_clear, NULL); +void Radiant_attachGameModeObserver( ModuleObserver& observer ){ + g_gameModeObservers.attach( observer ); } -void clipboard_paste() -{ - GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); +void Radiant_detachGameModeObserver( ModuleObserver& observer ){ + g_gameModeObservers.detach( observer ); +} + +const char* gamemode_get(){ + return g_gamemode.c_str(); +} - gtk_clipboard_request_contents (clipboard, gdk_atom_intern(clipboard_targets[0].target, FALSE), clipboard_received, NULL); +void gamemode_set( const char* gamemode ){ + if ( !string_equal( gamemode, g_gamemode.c_str() ) ) { + g_gameModeObservers.unrealise(); + g_gamemode = gamemode; + g_gameModeObservers.realise(); + } } -#elif defined(WIN32) +#include "os/dir.h" -void clipboard_copy() -{ - Clipboard_CopyMap(); - - bool bClipped = false; - UINT nClipboard = ::RegisterClipboardFormat("RadiantClippings"); - if (nClipboard > 0) - { - if (::OpenClipboard(NULL)) - { - EmptyClipboard(); - long lSize = g_Clipboard.GetLength(); - HANDLE h = ::GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE | GMEM_DDESHARE, lSize + sizeof(long)); - if (h != NULL) - { - unsigned char *cp = reinterpret_cast(::GlobalLock(h)); - memcpy(cp, &lSize, sizeof(long)); - cp += sizeof(long); - g_Clipboard.Seek(0, SEEK_SET); - g_Clipboard.Read(cp, lSize); - ::GlobalUnlock(h); - ::SetClipboardData(nClipboard, h); - ::CloseClipboard(); - bClipped = true; - } - } - } - - if (!bClipped) - { - Sys_Printf("Unable to register Windows clipboard formats, copy/paste between editors will not be possible\n"); - } -} - -void clipboard_paste() +class CLoadModule { - bool bPasted = false; - UINT nClipboard = ::RegisterClipboardFormat("RadiantClippings"); - if (nClipboard > 0 && ::OpenClipboard(NULL)) - { - if(IsClipboardFormatAvailable(nClipboard)) - { - HANDLE h = ::GetClipboardData(nClipboard); - if (h) - { - g_Clipboard.SetLength(0); - unsigned char *cp = reinterpret_cast(::GlobalLock(h)); - long lSize = 0; - memcpy(&lSize, cp, sizeof(long)); - cp += sizeof(long); - g_Clipboard.Write(cp, lSize); - ::GlobalUnlock(h); - } - } - ::CloseClipboard(); - } - - Clipboard_PasteMap(); +const char* m_path; +public: +CLoadModule( const char* path ) : m_path( path ){ } +void operator()( const char* name ) const { + char fullname[1024]; + ASSERT_MESSAGE( strlen( m_path ) + strlen( name ) < 1024, "" ); + strcpy( fullname, m_path ); + strcat( fullname, name ); + globalOutputStream() << "Found '" << fullname << "'\n"; + GlobalModuleServer_loadModule( fullname ); +} +}; +const char* const c_library_extension = +#if defined( CMAKE_SHARED_MODULE_SUFFIX ) + CMAKE_SHARED_MODULE_SUFFIX +#elif defined( WIN32 ) + "dll" +#elif defined ( __APPLE__ ) + "dylib" +#elif defined( __linux__ ) || defined ( __FreeBSD__ ) + "so" #endif +; -void MainFrame::Copy() -{ - clipboard_copy(); +void Radiant_loadModules( const char* path ){ + Directory_forEach( path, MatchFileExtension( c_library_extension, CLoadModule( path ) ) ); } -void MainFrame::Paste() -{ - clipboard_paste(); - UpdateSurfaceDialog(); +void Radiant_loadModulesFromRoot( const char* directory ){ + { + StringOutputStream path( 256 ); + path << directory << g_pluginsDir; + Radiant_loadModules( path.c_str() ); + } + + if ( !string_equal( g_pluginsDir, g_modulesDir ) ) { + StringOutputStream path( 256 ); + path << directory << g_modulesDir; + Radiant_loadModules( path.c_str() ); + } } +//! Make COLOR_BRUSHES override worldspawn eclass colour. +void SetWorldspawnColour( const Vector3& colour ){ + EntityClass* worldspawn = GlobalEntityClassManager().findOrInsert( "worldspawn", true ); + eclass_release_state( worldspawn ); + worldspawn->color = colour; + eclass_capture_state( worldspawn ); +} -#ifdef DBG_WINDOWPOS -GtkWidget *watchit = NULL; -void CheckWatchit(char *msg) +class WorldspawnColourEntityClassObserver : public ModuleObserver { - static int width = 0; - if ((watchit!=NULL) && (watchit->allocation.width != width)) - { - Sys_Printf("CheckWatchit %s: %d\n", msg, watchit->allocation.width); - width = watchit->allocation.width; - } +std::size_t m_unrealised; +public: +WorldspawnColourEntityClassObserver() : m_unrealised( 1 ){ } -#endif +void realise(){ + if ( --m_unrealised == 0 ) { + SetWorldspawnColour( g_xywindow_globals.color_brushes ); + } +} +void unrealise(){ + if ( ++m_unrealised == 1 ) { + } +} +}; + +WorldspawnColourEntityClassObserver g_WorldspawnColourEntityClassObserver; -#ifdef _WIN32 -BOOL CALLBACK m_pCountMonitor (HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -{ - int *n = (int *) dwData; - (*n)++; +ModuleObservers g_gameToolsPathObservers; - return TRUE; +void Radiant_attachGameToolsPathObserver( ModuleObserver& observer ){ + g_gameToolsPathObservers.attach( observer ); } -struct monitorInfo_s { - GdkRectangle *win_monitors; - int i_win_mon; -}; +void Radiant_detachGameToolsPathObserver( ModuleObserver& observer ){ + g_gameToolsPathObservers.detach( observer ); +} -BOOL CALLBACK m_pEnumMonitor (HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -{ - monitorInfo_s *monitorInfo = (monitorInfo_s *) dwData; - GdkRectangle *monitor; - MONITORINFOEX lpmi; +void Radiant_Initialise(){ + GlobalModuleServer_Initialise(); - monitor = monitorInfo->win_monitors + monitorInfo->i_win_mon; + Radiant_loadModulesFromRoot( AppPath_get() ); - memset(&lpmi, 0, sizeof(MONITORINFOEX)); - lpmi.cbSize = sizeof(MONITORINFOEX); + Preferences_Load(); - GetMonitorInfo( hMonitor, &lpmi ); + bool success = Radiant_Construct( GlobalModuleServer_get() ); + ASSERT_MESSAGE( success, "module system failed to initialise - see radiant.log for error messages" ); - if( lpmi.dwFlags & MONITORINFOF_PRIMARY ) { - RECT rect; + g_gameToolsPathObservers.realise(); + g_gameModeObservers.realise(); + g_gameNameObservers.realise(); +} - SystemParametersInfo (SPI_GETWORKAREA, 0, &rect, 0); - monitor->x = rect.left; - monitor->y = rect.top; - monitor->width = rect.right - rect.left; - monitor->height = rect.bottom - rect.top; +void Radiant_Shutdown(){ + g_gameNameObservers.unrealise(); + g_gameModeObservers.unrealise(); + g_gameToolsPathObservers.unrealise(); - if (monitorInfo->i_win_mon != 0) - { - GdkRectangle temp = *monitor; - *monitor = monitorInfo->win_monitors[0]; - monitorInfo->win_monitors[0] = temp; - } - } else { - monitor->x = lpmi.rcMonitor.left; - monitor->y = lpmi.rcMonitor.top; - monitor->width = lpmi.rcMonitor.right - lpmi.rcMonitor.left; - monitor->height = lpmi.rcMonitor.bottom - lpmi.rcMonitor.top; - } + if ( !g_preferences_globals.disable_ini ) { + globalOutputStream() << "Start writing prefs\n"; + Preferences_Save(); + globalOutputStream() << "Done prefs\n"; + } - monitorInfo->i_win_mon++; + Radiant_Destroy(); - return TRUE; + GlobalModuleServer_Shutdown(); } -void PositionWindowOnPrimaryScreen(window_position_t& position) -{ - const GdkRectangle primaryMonitorRect = g_pParentWnd->GetPrimaryMonitorRect(); +void Exit(){ + if ( ConfirmModified( "Exit Radiant" ) ) { + gtk_main_quit(); + } +} - if( position.x <= primaryMonitorRect.x + 6 ) - position.x = primaryMonitorRect.x + 6; - else if( position.x >= ( primaryMonitorRect.x + primaryMonitorRect.width ) - 6 ) - position.x = primaryMonitorRect.x + 6; - if( position.y <= primaryMonitorRect.y + 6 ) - position.y = primaryMonitorRect.y + 6; - else if( position.y >= ( primaryMonitorRect.y + primaryMonitorRect.height ) - 6 ) - position.y = primaryMonitorRect.y + 6; +void Undo(){ + GlobalUndoSystem().undo(); + SceneChangeNotify(); +} - if( position.x + position.w >= ( primaryMonitorRect.x + primaryMonitorRect.width ) - 18 ) - position.w = primaryMonitorRect.width - 18; - if( position.y + position.h >= ( primaryMonitorRect.y + primaryMonitorRect.height ) - 18 ) - position.h = primaryMonitorRect.height - 18; +void Redo(){ + GlobalUndoSystem().redo(); + SceneChangeNotify(); } -#endif -GtkWidget* create_framed_widget(GtkWidget* widget) -{ - GtkWidget* frame = gtk_frame_new ((char*)NULL); - gtk_widget_show (frame); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (frame), widget); - gtk_widget_show(widget); - return frame; +void deleteSelection(){ + UndoableCommand undo( "deleteSelected" ); + Select_Delete(); } -gboolean entry_focus_in(GtkWidget *widget, GdkEventFocus *event, gpointer user_data) -{ - gtk_window_remove_accel_group (GTK_WINDOW (g_pParentWnd->m_pWidget), global_accel); - return FALSE; +void Map_ExportSelected( TextOutputStream& ostream ){ + Map_ExportSelected( ostream, Map_getFormat( g_map ) ); } -gboolean entry_focus_out(GtkWidget *widget, GdkEventFocus *event, gpointer user_data) -{ - gtk_window_add_accel_group (GTK_WINDOW (g_pParentWnd->m_pWidget), global_accel); - return FALSE; +void Map_ImportSelected( TextInputStream& istream ){ + Map_ImportSelected( istream, Map_getFormat( g_map ) ); } -GtkWidget* create_framed_texwnd(TexWnd* texwnd) -{ - GtkWidget* frame = gtk_frame_new ((char*)NULL); - gtk_widget_show (frame); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); +void Selection_Copy(){ + clipboard_copy( Map_ExportSelected ); +} + +void Selection_Paste(){ + clipboard_paste( Map_ImportSelected ); +} + +void Copy(){ + if ( SelectedFaces_empty() ) { + Selection_Copy(); + } + else + { + SelectedFaces_copyTexture(); + } +} + +void Paste(){ + if ( SelectedFaces_empty() ) { + UndoableCommand undo( "paste" ); - GtkWidget* hbox = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox); - gtk_container_add (GTK_CONTAINER (frame), hbox); + GlobalSelectionSystem().setSelectedAll( false ); + Selection_Paste(); + } + else + { + SelectedFaces_pasteTexture(); + } +} - GtkWidget* w = gtk_vscrollbar_new (GTK_ADJUSTMENT (gtk_adjustment_new (0,0,0,1,1,1))); - gtk_widget_show (w); - gtk_box_pack_end (GTK_BOX (hbox), w, FALSE, TRUE, 0); - g_qeglobals_gui.d_texture_scroll = w; +void PasteToCamera(){ + CamWnd& camwnd = *g_pParentWnd->GetCamWnd(); + GlobalSelectionSystem().setSelectedAll( false ); - GtkWidget* texbox = gtk_vbox_new (FALSE, 0); - gtk_widget_show (texbox); - gtk_box_pack_start (GTK_BOX (hbox), texbox, TRUE, TRUE, 0); + UndoableCommand undo( "pasteToCamera" ); - w = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (texbox), w, FALSE, FALSE, 0); - texwnd->m_pFilter = w; - g_signal_connect(G_OBJECT(w), "focus_in_event", G_CALLBACK(entry_focus_in), NULL); - g_signal_connect(G_OBJECT(w), "focus_out_event", G_CALLBACK(entry_focus_out), NULL); + Selection_Paste(); - w = texwnd->GetWidget (); - gtk_box_pack_start (GTK_BOX (texbox), w, TRUE, TRUE, 0); - gtk_widget_show (w); + // Work out the delta + Vector3 mid; + Select_GetMid( mid ); + Vector3 delta = vector3_subtracted( vector3_snapped( Camera_getOrigin( camwnd ), GetSnapGridSize() ), mid ); - return frame; + // Move to camera + GlobalSelectionSystem().translateSelected( delta ); } -static ZWnd *create_floating_zwnd(MainFrame *mainframe) -{ - ZWnd *pZWnd = new ZWnd (); - GtkWidget* wnd = create_floating (mainframe); - - gtk_window_set_title (GTK_WINDOW (wnd), "Z"); - - pZWnd->m_pParent = wnd; - - { - GtkWidget* frame = create_framed_widget(pZWnd->GetWidget()); - gtk_container_add (GTK_CONTAINER (wnd), frame); - } - - gtk_widget_realize (wnd); - - // turn OFF minimize and maximize boxes. - // Must be *after* realize, or wnd->window is NULL - // should do the right thing on *nix, need to verify. - gdk_window_set_decorations ( wnd->window, - GdkWMDecoration(GDK_DECOR_ALL | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); - //TODO 50 by observation, will vary depending on decoration sizes - { - GdkGeometry geometry; - geometry.min_width = 50; - //we only care about width, but have to set this too, or get nasty bugs - geometry.min_height = 10; - gdk_window_set_geometry_hints( wnd->window,&geometry,GDK_HINT_MIN_SIZE); - } - -#ifdef _WIN32 - if( g_PrefsDlg.m_bStartOnPrimMon ) { - PositionWindowOnPrimaryScreen( g_PrefsDlg.mWindowInfo.posZWnd ); - } -#endif - load_window_pos (wnd, g_PrefsDlg.mWindowInfo.posZWnd); - if (g_PrefsDlg.m_bZVis) - gtk_widget_show (wnd); +void ColorScheme_Original(){ + TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), Vector3( 0.25f, 0.25f, 0.25f ) ); + + g_camwindow_globals.color_selbrushes3d = Vector3( 1.0f, 0.0f, 0.0f ); + g_camwindow_globals.color_cameraback = Vector3( 0.25f, 0.25f, 0.25f ); + CamWnd_Update( *g_pParentWnd->GetCamWnd() ); - return pZWnd; + g_xywindow_globals.color_gridback = Vector3( 1.0f, 1.0f, 1.0f ); + g_xywindow_globals.color_gridminor = Vector3( 0.75f, 0.75f, 0.75f ); + g_xywindow_globals.color_gridmajor = Vector3( 0.5f, 0.5f, 0.5f ); + g_xywindow_globals.color_gridminor_alt = Vector3( 0.5f, 0.0f, 0.0f ); + g_xywindow_globals.color_gridmajor_alt = Vector3( 1.0f, 0.0f, 0.0f ); + g_xywindow_globals.color_gridblock = Vector3( 0.0f, 0.0f, 1.0f ); + g_xywindow_globals.color_gridtext = Vector3( 0.0f, 0.0f, 0.0f ); + g_xywindow_globals.color_selbrushes = Vector3( 1.0f, 0.0f, 0.0f ); + g_xywindow_globals.color_clipper = Vector3( 0.0f, 0.0f, 1.0f ); + g_xywindow_globals.color_brushes = Vector3( 0.0f, 0.0f, 0.0f ); + SetWorldspawnColour( g_xywindow_globals.color_brushes ); + g_xywindow_globals.color_viewname = Vector3( 0.5f, 0.0f, 0.75f ); + XY_UpdateAllWindows(); } -static const int gutter = 12; +void ColorScheme_QER(){ + TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), Vector3( 0.25f, 0.25f, 0.25f ) ); -void MainFrame::Create () -{ - GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - m_pWidget = window; - gtk_widget_set_events (window, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); - gtk_signal_connect (GTK_OBJECT (window), "delete_event", - GTK_SIGNAL_FUNC (mainframe_delete), this); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC (mainframe_destroy), this); - gtk_signal_connect (GTK_OBJECT (window), "key_press_event", - GTK_SIGNAL_FUNC (mainframe_keypress), this); - gtk_signal_connect (GTK_OBJECT (window), "key_release_event", - GTK_SIGNAL_FUNC (mainframe_keyrelease), this); - gtk_signal_connect (GTK_OBJECT (window), "map_event", - GTK_SIGNAL_FUNC (mainframe_map), this); - gtk_signal_connect (GTK_OBJECT (window), "unmap_event", - GTK_SIGNAL_FUNC (mainframe_unmap), this); - - g_qeglobals_gui.d_main_window = window; - -#ifdef _WIN32 - // calculate gdk offset - int n_win_monitors = 0; - - monitorInfo_s monitorInfo; - - // detect multiple monitors - EnumDisplayMonitors (NULL, NULL, m_pCountMonitor, reinterpret_cast(&n_win_monitors)); - - monitorInfo.win_monitors = new GdkRectangle [ n_win_monitors ]; - monitorInfo.i_win_mon = 0; - EnumDisplayMonitors (NULL, NULL, m_pEnumMonitor, reinterpret_cast(&monitorInfo)); - - gdk_offset_x = G_MININT; - gdk_offset_y = G_MININT; - - // calculate offset - for( monitorInfo.i_win_mon = 0; monitorInfo.i_win_mon < n_win_monitors; monitorInfo.i_win_mon++ ) { - gdk_offset_x = MAX (gdk_offset_x, -monitorInfo.win_monitors[monitorInfo.i_win_mon].x); - gdk_offset_y = MAX (gdk_offset_y, -monitorInfo.win_monitors[monitorInfo.i_win_mon].y); - } - - Sys_Printf( "GDK's coordinate system is offset by %d over the x-axis and %d over the y-axis from Windows' coordinate system.\n", gdk_offset_x, gdk_offset_y ); - - if( g_PrefsDlg.m_bStartOnPrimMon ) - { - // get gdk monitors - GdkDisplay *display; - GdkScreen *screen; - gint n_gdk_monitors = 0; - gint i_mon; - GdkRectangle rect; - - // detect multiple monitors - display = gdk_display_get_default (); - Sys_Printf( "GDK detects that server %s manages %d screens\n", gdk_display_get_name (display), gdk_display_get_n_screens (display) ); - - screen = gdk_display_get_screen( display, 1 ); - n_gdk_monitors = gdk_screen_get_n_monitors( screen ); - - Sys_Printf( "GDK detects that screen 1 has %d monitors\n", n_gdk_monitors ); - - for( i_mon = 0; i_mon < n_gdk_monitors; i_mon++ ) { - memset( &rect, 0, sizeof(rect) ); - gdk_screen_get_monitor_geometry( screen, i_mon, &rect ); - Sys_Printf( " monitor %d: x: %d y: %d w: %d h: %d\n", i_mon, rect.x, rect.y, rect.width, rect.height ); - - if( i_mon == 0 ) { - memcpy( &primaryMonitorRect, &rect, sizeof(primaryMonitorRect) ); - } - } - - PositionWindowOnPrimaryScreen( g_PrefsDlg.mWindowInfo.position ); - } - else { - primaryMonitorRect.x = primaryMonitorRect.y = 0; - primaryMonitorRect.width = gdk_screen_width (); - primaryMonitorRect.height = gdk_screen_height (); - } + g_camwindow_globals.color_cameraback = Vector3( 0.25f, 0.25f, 0.25f ); + g_camwindow_globals.color_selbrushes3d = Vector3( 1.0f, 0.0f, 0.0f ); + CamWnd_Update( *g_pParentWnd->GetCamWnd() ); -#endif + g_xywindow_globals.color_gridback = Vector3( 1.0f, 1.0f, 1.0f ); + g_xywindow_globals.color_gridminor = Vector3( 1.0f, 1.0f, 1.0f ); + g_xywindow_globals.color_gridmajor = Vector3( 0.5f, 0.5f, 0.5f ); + g_xywindow_globals.color_gridblock = Vector3( 0.0f, 0.0f, 1.0f ); + g_xywindow_globals.color_gridtext = Vector3( 0.0f, 0.0f, 0.0f ); + g_xywindow_globals.color_selbrushes = Vector3( 1.0f, 0.0f, 0.0f ); + g_xywindow_globals.color_clipper = Vector3( 0.0f, 0.0f, 1.0f ); + g_xywindow_globals.color_brushes = Vector3( 0.0f, 0.0f, 0.0f ); + SetWorldspawnColour( g_xywindow_globals.color_brushes ); + g_xywindow_globals.color_viewname = Vector3( 0.5f, 0.0f, 0.75f ); + XY_UpdateAllWindows(); +} - load_window_pos(window, g_PrefsDlg.mWindowInfo.position); +void ColorScheme_Black(){ + TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), Vector3( 0.25f, 0.25f, 0.25f ) ); - GtkWidget* vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (window), vbox); - gtk_widget_show (vbox); + g_camwindow_globals.color_cameraback = Vector3( 0.25f, 0.25f, 0.25f ); + g_camwindow_globals.color_selbrushes3d = Vector3( 1.0f, 0.0f, 0.0f ); + CamWnd_Update( *g_pParentWnd->GetCamWnd() ); - create_main_menu (window, vbox); - MRU_Load (); - create_main_toolbar (window, vbox); - create_plugin_toolbar (window,vbox); + g_xywindow_globals.color_gridback = Vector3( 0.0f, 0.0f, 0.0f ); + g_xywindow_globals.color_gridminor = Vector3( 0.2f, 0.2f, 0.2f ); + g_xywindow_globals.color_gridmajor = Vector3( 0.3f, 0.5f, 0.5f ); + g_xywindow_globals.color_gridblock = Vector3( 0.0f, 0.0f, 1.0f ); + g_xywindow_globals.color_gridtext = Vector3( 1.0f, 1.0f, 1.0f ); + g_xywindow_globals.color_selbrushes = Vector3( 1.0f, 0.0f, 0.0f ); + g_xywindow_globals.color_clipper = Vector3( 0.0f, 0.0f, 1.0f ); + g_xywindow_globals.color_brushes = Vector3( 1.0f, 1.0f, 1.0f ); + SetWorldspawnColour( g_xywindow_globals.color_brushes ); + g_xywindow_globals.color_viewname = Vector3( 0.7f, 0.7f, 0.0f ); + XY_UpdateAllWindows(); +} - m_nCurrentStyle = g_PrefsDlg.m_nView; +/* ydnar: to emulate maya/max/lightwave color schemes */ +void ColorScheme_Ydnar(){ + TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), Vector3( 0.25f, 0.25f, 0.25f ) ); + + g_camwindow_globals.color_cameraback = Vector3( 0.25f, 0.25f, 0.25f ); + g_camwindow_globals.color_selbrushes3d = Vector3( 1.0f, 0.0f, 0.0f ); + CamWnd_Update( *g_pParentWnd->GetCamWnd() ); + + g_xywindow_globals.color_gridback = Vector3( 0.77f, 0.77f, 0.77f ); + g_xywindow_globals.color_gridminor = Vector3( 0.83f, 0.83f, 0.83f ); + g_xywindow_globals.color_gridmajor = Vector3( 0.89f, 0.89f, 0.89f ); + g_xywindow_globals.color_gridblock = Vector3( 1.0f, 1.0f, 1.0f ); + g_xywindow_globals.color_gridtext = Vector3( 0.0f, 0.0f, 0.0f ); + g_xywindow_globals.color_selbrushes = Vector3( 1.0f, 0.0f, 0.0f ); + g_xywindow_globals.color_clipper = Vector3( 0.0f, 0.0f, 1.0f ); + g_xywindow_globals.color_brushes = Vector3( 0.0f, 0.0f, 0.0f ); + SetWorldspawnColour( g_xywindow_globals.color_brushes ); + g_xywindow_globals.color_viewname = Vector3( 0.5f, 0.0f, 0.75f ); + XY_UpdateAllWindows(); +} + +typedef Callback1 GetColourCallback; +typedef Callback1 SetColourCallback; + +class ChooseColour +{ +GetColourCallback m_get; +SetColourCallback m_set; +public: +ChooseColour( const GetColourCallback& get, const SetColourCallback& set ) + : m_get( get ), m_set( set ){ +} +void operator()(){ + Vector3 colour; + m_get( colour ); + color_dialog( MainFrame_getWindow(), colour ); + m_set( colour ); +} +}; - g_pGroupDlg->Create (); - OnPluginsRefresh(); - CreateQEChildren(); - gtk_widget_show (window); +void Colour_get( const Vector3& colour, Vector3& other ){ + other = colour; +} +typedef ConstReferenceCaller1 ColourGetCaller; - // not needed on win32, it's in the .rc -#ifndef _WIN32 - { - GdkPixmap *pixmap; - GdkBitmap *mask; - load_pixmap ("icon.bmp", window, &pixmap, &mask); - gdk_window_set_icon (window->window, NULL, pixmap, mask); - } -#endif +void Colour_set( Vector3& colour, const Vector3& other ){ + colour = other; + SceneChangeNotify(); +} +typedef ReferenceCaller1 ColourSetCaller; - if (CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft) - { - { - GtkWidget* vsplit = gtk_vpaned_new (); - m_pSplits[0] = vsplit; - gtk_box_pack_start (GTK_BOX (vbox), vsplit, TRUE, TRUE, 0); - gtk_widget_show (vsplit); - - { - GtkWidget* hsplit = gtk_hpaned_new (); - m_pSplits[2] = hsplit; - gtk_paned_add1 (GTK_PANED (vsplit), hsplit); - gtk_widget_show (hsplit); - - { - GtkWidget* hsplit2 = gtk_hpaned_new (); - m_pSplits[3] = hsplit2; - gtk_paned_add2 (GTK_PANED (hsplit), hsplit2); - gtk_widget_show (hsplit2); - - { - GtkWidget* vsplit2 = gtk_vpaned_new (); - m_pSplits[1] = vsplit2; - if (CurrentStyle() == eRegular) - gtk_paned_add2 (GTK_PANED (hsplit2), vsplit2); - else - gtk_paned_add1 (GTK_PANED (hsplit), vsplit2); - gtk_widget_show (vsplit2); - - // camera - m_pCamWnd = new CamWnd (); - { - GtkWidget* frame = create_framed_widget(m_pCamWnd->GetWidget()); - gtk_paned_add1 (GTK_PANED (vsplit2), frame); - } - - // xy - m_pXYWnd = new XYWnd (); - m_pXYWnd->SetViewType(XY); - { - GtkWidget* frame = create_framed_widget(m_pXYWnd->GetWidget ()); - gtk_paned_add1 (GTK_PANED (hsplit2), frame); - } - - // z - m_pZWnd = new ZWnd (); - { - GtkWidget* frame = create_framed_widget(m_pZWnd->GetWidget ()); - if (CurrentStyle() == eRegular) - gtk_paned_add1 (GTK_PANED (hsplit), frame); - else - gtk_paned_add2 (GTK_PANED (hsplit2), frame); - } - - // textures - m_pTexWnd = new TexWnd (); - { - GtkWidget* frame = create_framed_texwnd(m_pTexWnd); - gtk_paned_add2 (GTK_PANED (vsplit2), frame); - } - - // console - { - GtkWidget* scr = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scr), GTK_SHADOW_IN); - gtk_widget_show (scr); - gtk_paned_pack2 (GTK_PANED (vsplit), scr, FALSE, TRUE); - - { - GtkWidget* text = gtk_text_view_new (); - gtk_widget_set_size_request(text, 0, -1); // allow shrinking - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); - gtk_text_view_set_editable (GTK_TEXT_VIEW(text), FALSE); - gtk_container_add (GTK_CONTAINER (scr), text); - gtk_widget_show (text); - g_qeglobals_gui.d_edit = text; - } - } - } - } - } - } - - gtk_paned_set_position (GTK_PANED (m_pSplits[0]), g_PrefsDlg.mWindowInfo.nXYHeight+28); - - if (CurrentStyle() == eRegular) - { - gtk_paned_set_position (GTK_PANED (m_pSplits[2]), g_PrefsDlg.mWindowInfo.nZWidth); - gtk_paned_set_position (GTK_PANED (m_pSplits[3]), g_PrefsDlg.mWindowInfo.nXYWidth); - } - else - { - gtk_paned_set_position (GTK_PANED (m_pSplits[2]), g_PrefsDlg.mWindowInfo.nCamWidth); - while (gtk_events_pending ()) gtk_main_iteration (); - gtk_paned_set_position (GTK_PANED (m_pSplits[3]), g_PrefsDlg.mWindowInfo.nXYWidth); - } - - while (gtk_events_pending ()) gtk_main_iteration (); - - gtk_paned_set_position (GTK_PANED (m_pSplits[1]), g_PrefsDlg.mWindowInfo.nCamHeight); - } - else if (CurrentStyle() == eFloating) - { - { - GtkWidget* wnd = create_floating (this); - gtk_window_set_title (GTK_WINDOW (wnd), "Camera"); - -#ifdef _WIN32 - if( g_PrefsDlg.m_bStartOnPrimMon ) { - PositionWindowOnPrimaryScreen( g_PrefsDlg.mWindowInfo.posCamWnd ); - } -#endif - load_window_pos (wnd, g_PrefsDlg.mWindowInfo.posCamWnd); +void BrushColour_set( const Vector3& other ){ + g_xywindow_globals.color_brushes = other; + SetWorldspawnColour( g_xywindow_globals.color_brushes ); + SceneChangeNotify(); +} +typedef FreeCaller1 BrushColourSetCaller; - gtk_widget_show (wnd); +void ClipperColour_set( const Vector3& other ){ + g_xywindow_globals.color_clipper = other; + Brush_clipperColourChanged(); + SceneChangeNotify(); +} +typedef FreeCaller1 ClipperColourSetCaller; - m_pCamWnd = new CamWnd (); +void TextureBrowserColour_get( Vector3& other ){ + other = TextureBrowser_getBackgroundColour( GlobalTextureBrowser() ); +} +typedef FreeCaller1 TextureBrowserColourGetCaller; - { - GtkWidget* frame = create_framed_widget(m_pCamWnd->GetWidget ()); - gtk_container_add (GTK_CONTAINER (wnd), frame); - } +void TextureBrowserColour_set( const Vector3& other ){ + TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), other ); +} +typedef FreeCaller1 TextureBrowserColourSetCaller; - m_pCamWnd->m_pParent = wnd; - } - if (g_PrefsDlg.m_bFloatingZ) - { - m_pZWnd = create_floating_zwnd(this); +class ColoursMenu +{ +public: +ChooseColour m_textureback; +ChooseColour m_xyback; +ChooseColour m_gridmajor; +ChooseColour m_gridminor; +ChooseColour m_gridmajor_alt; +ChooseColour m_gridminor_alt; +ChooseColour m_gridtext; +ChooseColour m_gridblock; +ChooseColour m_cameraback; +ChooseColour m_brush; +ChooseColour m_selectedbrush; +ChooseColour m_selectedbrush3d; +ChooseColour m_clipper; +ChooseColour m_viewname; - { - GtkWidget* wnd = create_floating (this); - gtk_window_set_title (GTK_WINDOW (wnd), "XY View"); +ColoursMenu() : + m_textureback( TextureBrowserColourGetCaller(), TextureBrowserColourSetCaller() ), + m_xyback( ColourGetCaller( g_xywindow_globals.color_gridback ), ColourSetCaller( g_xywindow_globals.color_gridback ) ), + m_gridmajor( ColourGetCaller( g_xywindow_globals.color_gridmajor ), ColourSetCaller( g_xywindow_globals.color_gridmajor ) ), + m_gridminor( ColourGetCaller( g_xywindow_globals.color_gridminor ), ColourSetCaller( g_xywindow_globals.color_gridminor ) ), + m_gridmajor_alt( ColourGetCaller( g_xywindow_globals.color_gridmajor_alt ), ColourSetCaller( g_xywindow_globals.color_gridmajor_alt ) ), + m_gridminor_alt( ColourGetCaller( g_xywindow_globals.color_gridminor_alt ), ColourSetCaller( g_xywindow_globals.color_gridminor_alt ) ), + m_gridtext( ColourGetCaller( g_xywindow_globals.color_gridtext ), ColourSetCaller( g_xywindow_globals.color_gridtext ) ), + m_gridblock( ColourGetCaller( g_xywindow_globals.color_gridblock ), ColourSetCaller( g_xywindow_globals.color_gridblock ) ), + m_cameraback( ColourGetCaller( g_camwindow_globals.color_cameraback ), ColourSetCaller( g_camwindow_globals.color_cameraback ) ), + m_brush( ColourGetCaller( g_xywindow_globals.color_brushes ), BrushColourSetCaller() ), + m_selectedbrush( ColourGetCaller( g_xywindow_globals.color_selbrushes ), ColourSetCaller( g_xywindow_globals.color_selbrushes ) ), + m_selectedbrush3d( ColourGetCaller( g_camwindow_globals.color_selbrushes3d ), ColourSetCaller( g_camwindow_globals.color_selbrushes3d ) ), + m_clipper( ColourGetCaller( g_xywindow_globals.color_clipper ), ClipperColourSetCaller() ), + m_viewname( ColourGetCaller( g_xywindow_globals.color_viewname ), ColourSetCaller( g_xywindow_globals.color_viewname ) ){ +} +}; -#ifdef _WIN32 - if( g_PrefsDlg.m_bStartOnPrimMon ) { - PositionWindowOnPrimaryScreen( g_PrefsDlg.mWindowInfo.posXYWnd ); - } -#endif - load_window_pos (wnd, g_PrefsDlg.mWindowInfo.posXYWnd); - - m_pXYWnd = new XYWnd (); - m_pXYWnd->SetViewType(XY); - - { - GtkWidget* frame = create_framed_widget(m_pXYWnd->GetWidget()); - gtk_container_add (GTK_CONTAINER (wnd), frame); - } - - m_pXYWnd->m_pParent = wnd; - - gtk_widget_show (wnd); - } - } - else - { - GtkWidget* wnd = create_floating (this); - gtk_window_set_title (GTK_WINDOW (wnd), "XY View"); - -#ifdef _WIN32 - if( g_PrefsDlg.m_bStartOnPrimMon ) { - PositionWindowOnPrimaryScreen( g_PrefsDlg.mWindowInfo.posXYWnd ); - } -#endif - load_window_pos (wnd, g_PrefsDlg.mWindowInfo.posXYWnd); +ColoursMenu g_ColoursMenu; - m_pZWnd = new ZWnd (); - m_pZWnd->m_pParent = wnd; +GtkMenuItem* create_colours_menu(){ + GtkMenuItem* colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" ); + auto menu_in_menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( colours_menu_item ) )); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu_in_menu ); + } - m_pXYWnd = new XYWnd (); - m_pXYWnd->SetViewType(XY); - m_pXYWnd->m_pParent = wnd; + auto menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Themes" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu_3 ); + } + create_menu_item_with_mnemonic( menu_3, "QE4 Original", "ColorSchemeOriginal" ); + create_menu_item_with_mnemonic( menu_3, "Q3Radiant Original", "ColorSchemeQER" ); + create_menu_item_with_mnemonic( menu_3, "Black and Green", "ColorSchemeBlackAndGreen" ); + create_menu_item_with_mnemonic( menu_3, "Maya/Max/Lightwave Emulation", "ColorSchemeYdnar" ); - { - GtkWidget* hsplit = gtk_hpaned_new (); - m_pSplits[0] = hsplit; - gtk_container_add (GTK_CONTAINER (wnd), hsplit); - gtk_widget_show (hsplit); + menu_separator( menu_in_menu ); - { - GtkWidget* frame = create_framed_widget(m_pZWnd->GetWidget()); - gtk_paned_add1 (GTK_PANED (hsplit), frame); - } - { - GtkWidget* frame = create_framed_widget(m_pXYWnd->GetWidget()); - gtk_paned_add2 (GTK_PANED (hsplit), frame); - } - } + create_menu_item_with_mnemonic( menu_in_menu, "_Texture Background...", "ChooseTextureBackgroundColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Grid Background...", "ChooseGridBackgroundColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Grid Major...", "ChooseGridMajorColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Grid Minor...", "ChooseGridMinorColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Grid Major Small...", "ChooseSmallGridMajorColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Grid Minor Small...", "ChooseSmallGridMinorColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Grid Text...", "ChooseGridTextColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Grid Block...", "ChooseGridBlockColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Default Brush...", "ChooseBrushColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Camera Background...", "ChooseCameraBackgroundColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Selected Brush...", "ChooseSelectedBrushColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Selected Brush (Camera)...", "ChooseCameraSelectedBrushColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Clipper...", "ChooseClipperColor" ); + create_menu_item_with_mnemonic( menu_in_menu, "Active View name...", "ChooseOrthoViewNameColor" ); - gtk_widget_show (wnd); + return colours_menu_item; +} - gtk_paned_set_position (GTK_PANED (m_pSplits[0]), g_PrefsDlg.mWindowInfo.nZFloatWidth); - } - { - GtkWidget* wnd = create_floating (this); - gtk_window_set_title (GTK_WINDOW (wnd), _("XZ View")); +void Restart(){ + PluginsMenu_clear(); + PluginToolbar_clear(); -#ifdef _WIN32 - if( g_PrefsDlg.m_bStartOnPrimMon ) { - PositionWindowOnPrimaryScreen( g_PrefsDlg.mWindowInfo.posXZWnd ); - } -#endif - load_window_pos (wnd, g_PrefsDlg.mWindowInfo.posXZWnd); + Radiant_Shutdown(); + Radiant_Initialise(); - m_pXZWnd = new XYWnd (); - m_pXZWnd->m_pParent = wnd; - m_pXZWnd->SetViewType(XZ); + PluginsMenu_populate(); - { - GtkWidget* frame = create_framed_widget(m_pXZWnd->GetWidget()); - gtk_container_add (GTK_CONTAINER (wnd), frame); - } + PluginToolbar_populate(); +} - if (g_PrefsDlg.m_bXZVis) - gtk_widget_show (wnd); - } - { - GtkWidget* wnd = create_floating (this); - gtk_window_set_title (GTK_WINDOW (wnd), _("YZ View")); +void thunk_OnSleep(){ + g_pParentWnd->OnSleep(); +} -#ifdef _WIN32 - if( g_PrefsDlg.m_bStartOnPrimMon ) { - PositionWindowOnPrimaryScreen( g_PrefsDlg.mWindowInfo.posYZWnd ); - } -#endif - load_window_pos (wnd, g_PrefsDlg.mWindowInfo.posYZWnd); - - m_pYZWnd = new XYWnd (); - m_pYZWnd->m_pParent = wnd; - m_pYZWnd->SetViewType(YZ); - - { - GtkWidget* frame = create_framed_widget(m_pYZWnd->GetWidget()); - gtk_container_add (GTK_CONTAINER (wnd), frame); - } - - if (g_PrefsDlg.m_bYZVis) - gtk_widget_show (wnd); - } - - m_pTexWnd = new TexWnd (); - { - GtkWidget* frame = create_framed_texwnd(m_pTexWnd); - m_pTexWnd->m_pParent = g_pGroupDlg->m_pWidget; - - { - GtkWidget* w = gtk_label_new (_("Textures")); - gtk_widget_show (w); - gtk_notebook_insert_page (GTK_NOTEBOOK (g_pGroupDlg->m_pNotebook), frame, w, 1); - } - } - - g_pGroupDlg->Show (); - } - else // 4 way - { - { - GtkWidget* hsplit = gtk_hpaned_new (); - m_pSplits[0] = hsplit; - gtk_box_pack_start (GTK_BOX (vbox), hsplit, TRUE, TRUE, 0); - gtk_widget_show (hsplit); - - { - GtkWidget* vsplit1 = gtk_vpaned_new (); - m_pSplits[1] = vsplit1; - gtk_paned_add1 (GTK_PANED (hsplit), vsplit1); - gtk_widget_show (vsplit1); - - { - GtkWidget* vsplit2 = gtk_vpaned_new (); - m_pSplits[2] = vsplit2; - gtk_paned_add2 (GTK_PANED (hsplit), vsplit2); - gtk_widget_show (vsplit2); - - m_pCamWnd = new CamWnd (); - { - GtkWidget* frame = create_framed_widget(m_pCamWnd->GetWidget()); - gtk_paned_add1 (GTK_PANED (vsplit1), frame); - } - - m_pXYWnd = new XYWnd (); - m_pXYWnd->SetViewType(XY); - { - GtkWidget* frame = create_framed_widget(m_pXYWnd->GetWidget()); - gtk_paned_add1 (GTK_PANED (vsplit2), frame); - } - - m_pYZWnd = new XYWnd (); - m_pYZWnd->SetViewType(YZ); - { - GtkWidget* frame = create_framed_widget(m_pYZWnd->GetWidget()); - gtk_paned_add2 (GTK_PANED (vsplit1), frame); - } - - m_pXZWnd = new XYWnd (); - m_pXZWnd->SetViewType(XZ); - { - GtkWidget* frame = create_framed_widget(m_pXZWnd->GetWidget()); - gtk_paned_add2 (GTK_PANED (vsplit2), frame); - } - } - } - } - - // g_qeglobals_gui.d_edit = NULL; - - { - m_pTexWnd = new TexWnd (); - GtkWidget* frame = create_framed_texwnd(m_pTexWnd); - - { - GtkWidget* w = gtk_label_new (_("Textures")); - gtk_widget_show (w); - gtk_notebook_insert_page (GTK_NOTEBOOK (g_pGroupDlg->m_pNotebook), frame, w, 1); - } - } - - m_pTexWnd->m_pParent = g_pGroupDlg->m_pWidget; -// gtk_widget_realize (m_pTexWnd->GetWidget ()); - m_pZWnd = create_floating_zwnd(this); - - while (gtk_events_pending ()) - gtk_main_iteration (); - - { - int x = GTK_PANED (m_pSplits[0])->max_position/2 - gutter; - gtk_paned_set_position (GTK_PANED (m_pSplits[0]), x); - } - - { - int y = GTK_PANED (m_pSplits[1])->max_position/2 - gutter; - gtk_paned_set_position (GTK_PANED (m_pSplits[1]), y); - gtk_paned_set_position (GTK_PANED (m_pSplits[2]), y); - } - } - - if(g_PrefsDlg.mWindowInfo.nState & GDK_WINDOW_STATE_MAXIMIZED) - gtk_window_maximize(GTK_WINDOW(window)); - - gtk_widget_show (window); - - Texture_Init(); - - if (m_pXYWnd) // this is always true? - { - m_pXYWnd->SetActive(true); - } - m_bSplittersOK = true; - Texture_SetMode(g_qeglobals.d_savedinfo.iTexMenu); - - g_pParentWnd->OnEntitiesSetViewAs(0); - -// m_wndTextureBar.Create (vbox); - create_main_statusbar (window, vbox); - - LoadCommandMap(); - ShowMenuItemKeyBindings(window); +void OpenHelpURL(){ + OpenURL( "https://gitlab.com/xonotic/xonotic/wikis/Mapping" ); +} - if (g_qeglobals_gui.d_edit != NULL) - console_construct(g_qeglobals_gui.d_edit); +void OpenBugReportURL(){ + OpenURL( "https://gitlab.com/xonotic/netradiant/issues" ); +} - // bool load_last = FALSE; - SetGridStatus(); - SetButtonMenuStates(); +ui::Widget g_page_console; - // m_bShowShader and m_bTextureShaderlistOnly have a menu checkbox, update it now - GtkWidget *item; - g_bIgnoreCommands++; - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_textures_shaders_show")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_PrefsDlg.m_bShowShaders ? TRUE : FALSE); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_textures_shaderlistonly")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_PrefsDlg.m_bTexturesShaderlistOnly ? TRUE : FALSE); - g_bIgnoreCommands--; +void Console_ToggleShow(){ + GroupDialog_showPage( g_page_console ); +} -// if (g_PrefsDlg.m_bTextureBar) -// gtk_widget_show (m_wndTextureBar.m_pWidget); +ui::Widget g_page_entity; - SetActiveXY(m_pXYWnd); +void EntityInspector_ToggleShow(){ + GroupDialog_showPage( g_page_entity ); +} - s_idle_id = gtk_timeout_add (25, mainframe_idle, this); - QGL_InitExtensions (); - if (g_PrefsDlg.mLocalPrefs.mbEmpty) - { - g_PrefsDlg.mLocalPrefs.mbEmpty = false; - g_PrefsDlg.SavePrefs(); - } +void SetClipMode( bool enable ); +void ModeChangeNotify(); - // remove the pid file - remove (g_pidGameFile.GetBuffer ()); +typedef void ( *ToolMode )(); +ToolMode g_currentToolMode = 0; +bool g_currentToolModeSupportsComponentEditing = false; +ToolMode g_defaultToolMode = 0; - Sys_Printf ("Entering message loop\n"); - m_bDoLoop = true; - m_nTimer = gtk_timeout_add (1000, timer, this); +void SelectionSystem_DefaultMode(){ + GlobalSelectionSystem().SetMode( SelectionSystem::ePrimitive ); + GlobalSelectionSystem().SetComponentMode( SelectionSystem::eDefault ); + ModeChangeNotify(); } -// ============================================================================= -// MainFrame class -MainFrame::MainFrame() -{ - m_bDoLoop = false; - m_bSplittersOK = false; - g_pParentWnd = this; - m_pXYWnd = (XYWnd*)NULL; - m_pCamWnd = NULL; - m_pTexWnd = (TexWnd*)NULL; - m_pZWnd = (ZWnd*)NULL; - m_pYZWnd = (XYWnd*)NULL; - m_pXZWnd = (XYWnd*)NULL; - m_pActiveXY = (XYWnd*)NULL; - m_bCamPreview = true; - m_pWatchBSP = NULL; - for (int n = 0; n < 6; n++) - m_pStatusLabel[n] = NULL; - m_bNeedStatusUpdate = false; - m_nTimer = 0; - m_bSleeping = false; - Create (); -} - -MainFrame::~MainFrame() -{ - while (g_BSPFrontendCommands) - { - free (g_BSPFrontendCommands->data); - g_BSPFrontendCommands = g_slist_remove (g_BSPFrontendCommands, g_BSPFrontendCommands->data); - } +bool EdgeMode(){ + return GlobalSelectionSystem().Mode() == SelectionSystem::eComponent + && GlobalSelectionSystem().ComponentMode() == SelectionSystem::eEdge; } -void MainFrame::ReleaseContexts () -{ - if (m_pXYWnd) - m_pXYWnd->DestroyContext (); - if (m_pYZWnd) - m_pYZWnd->DestroyContext (); - if (m_pXZWnd) - m_pXZWnd->DestroyContext (); - if (m_pCamWnd) - m_pCamWnd->DestroyContext (); - if (m_pTexWnd) - m_pTexWnd->DestroyContext (); - if (m_pZWnd) - m_pZWnd->DestroyContext (); -} - -void MainFrame::CreateContexts () -{ - if (m_pCamWnd) - m_pCamWnd->CreateContext (); - if (m_pXYWnd) - m_pXYWnd->CreateContext (); - if (m_pYZWnd) - m_pYZWnd->CreateContext (); - if (m_pXZWnd) - m_pXZWnd->CreateContext (); - if (m_pTexWnd) - m_pTexWnd->CreateContext (); - if (m_pZWnd) - m_pZWnd->CreateContext (); -} - -static void Sys_Iconify (GtkWidget *w) -{ - // we might not have been realized yet - if (w->window == NULL) - return; +bool VertexMode(){ + return GlobalSelectionSystem().Mode() == SelectionSystem::eComponent + && GlobalSelectionSystem().ComponentMode() == SelectionSystem::eVertex; +} - if (!GTK_WIDGET_MAPPED (w)) - return; +bool FaceMode(){ + return GlobalSelectionSystem().Mode() == SelectionSystem::eComponent + && GlobalSelectionSystem().ComponentMode() == SelectionSystem::eFace; +} -#if defined (__linux__) || defined (__APPLE__) - Sys_FPrintf(SYS_WRN, "FIXME: Sys_Iconify\n"); -#if 0 - XWindowAttributes xattr; - GdkWindowPrivate *Private; +template +class BoolFunctionExport +{ +public: +static void apply( const BoolImportCallback& importCallback ){ + importCallback( BoolFunction() ); +} +}; - Private = (GdkWindowPrivate*)w->window; - g_object_set_data (G_OBJECT (w), "was_mapped", GINT_TO_POINTER (0)); +typedef FreeCaller1::apply> EdgeModeApplyCaller; +EdgeModeApplyCaller g_edgeMode_button_caller; +BoolExportCallback g_edgeMode_button_callback( g_edgeMode_button_caller ); +ToggleItem g_edgeMode_button( g_edgeMode_button_callback ); - if (!Private->destroyed) - { - xattr.map_state = IsUnmapped; - XGetWindowAttributes(Private->xdisplay, Private->xwindow, &xattr); +typedef FreeCaller1::apply> VertexModeApplyCaller; +VertexModeApplyCaller g_vertexMode_button_caller; +BoolExportCallback g_vertexMode_button_callback( g_vertexMode_button_caller ); +ToggleItem g_vertexMode_button( g_vertexMode_button_callback ); - if (xattr.map_state != IsUnmapped) - g_object_set_data (G_OBJECT (w), "was_mapped", GINT_TO_POINTER (1)); +typedef FreeCaller1::apply> FaceModeApplyCaller; +FaceModeApplyCaller g_faceMode_button_caller; +BoolExportCallback g_faceMode_button_callback( g_faceMode_button_caller ); +ToggleItem g_faceMode_button( g_faceMode_button_callback ); - XIconifyWindow (Private->xdisplay, Private->xwindow, 0); - } -#endif -#endif +void ComponentModeChanged(){ + g_edgeMode_button.update(); + g_vertexMode_button.update(); + g_faceMode_button.update(); +} -#ifdef _WIN32 - ShowWindow ((HWND)GDK_WINDOW_HWND (w->window), SW_MINIMIZE); -#endif +void ComponentMode_SelectionChanged( const Selectable& selectable ){ + if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent + && GlobalSelectionSystem().countSelected() == 0 ) { + SelectionSystem_DefaultMode(); + ComponentModeChanged(); + } } -static void Sys_Restore (GtkWidget *w) -{ - // we might not have been realized yet - if (w->window == NULL) - return; +void SelectEdgeMode(){ +#if 0 + if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) { + GlobalSelectionSystem().Select( false ); + } +#endif - if (!GTK_WIDGET_VISIBLE (w)) - return; + if ( EdgeMode() ) { + SelectionSystem_DefaultMode(); + } + else if ( GlobalSelectionSystem().countSelected() != 0 ) { + if ( !g_currentToolModeSupportsComponentEditing ) { + g_defaultToolMode(); + } -#if defined (__linux__) || defined (__APPLE__) - Sys_FPrintf(SYS_WRN, "FIXME: Sys_Restore\n"); - #if 0 - XWindowAttributes xattr; - GdkWindowPrivate *Private; + GlobalSelectionSystem().SetMode( SelectionSystem::eComponent ); + GlobalSelectionSystem().SetComponentMode( SelectionSystem::eEdge ); + } - Private = (GdkWindowPrivate*)w->window; + ComponentModeChanged(); - xattr.map_state = IsUnmapped; - XGetWindowAttributes(Private->xdisplay, Private->xwindow, &xattr); + ModeChangeNotify(); +} - if (xattr.map_state == IsUnmapped) - XMapRaised (Private->xdisplay, Private->xwindow); - #endif +void SelectVertexMode(){ +#if 0 + if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) { + GlobalSelectionSystem().Select( false ); + } #endif -#ifdef _WIN32 - ShowWindow ((HWND)GDK_WINDOW_HWND (w->window), SW_RESTORE); -#endif -} + if ( VertexMode() ) { + SelectionSystem_DefaultMode(); + } + else if ( GlobalSelectionSystem().countSelected() != 0 ) { + if ( !g_currentToolModeSupportsComponentEditing ) { + g_defaultToolMode(); + } -#ifdef _DEBUG -//#define DBG_SLEEP -#endif + GlobalSelectionSystem().SetMode( SelectionSystem::eComponent ); + GlobalSelectionSystem().SetComponentMode( SelectionSystem::eVertex ); + } -void RefreshModelSkin (GSList **pModels, entitymodel_t *model) -{ - //++timo FIXME: the are some bogus entitymodel_t that appear in the list cause of buggy HasModel - // so we avoid the fucked up ones, assuming they are at the end - if (!model->strSkin) - { -#ifdef DBG_SLEEP - Sys_Printf("Dropping model %p with empty skin in RefreshModelSkin\n", model); -#endif + ComponentModeChanged(); - // and also keeping it so we have an actual count of empty models - g_slist_append (*pModels, model); - return; - } - // do we have this model already? - if (g_slist_find (*pModels, model)) - { -#ifdef DBG_SLEEP - - // looks like we don't have the filename for the model, only the skin name and tris.. so we put the adress - Sys_Printf("Already processed model: %p %s\n", model, ((GString *)model->strSkin)->str); -#endif - return; - } - model->nTextureBind = Texture_LoadSkin(((GString *)model->strSkin)->str, &model->nSkinWidth, &model->nSkinHeight ); - if (model->nTextureBind != -1) - Sys_Printf("LOADED SKIN: %s\n", ((GString *)model->strSkin)->str ); - else - Sys_Printf("Load skin failed: %s\n", ((GString *)model->strSkin)->str ); - *pModels = g_slist_append (*pModels, model); -#ifdef DBG_SLEEP - Sys_Printf("Processed model %p %s\n", model, ((GString *)model->strSkin)->str); -#endif + ModeChangeNotify(); } -void MainFrame::OnSleep() -{ - m_bSleeping ^= 1; - if (m_bSleeping) - { - // useful when trying to debug crashes in the sleep code - Sys_Printf("Going into sleep mode..\n"); - - Sys_Printf("Dispatching sleep msg..."); - DispatchRadiantMsg (RADIANT_SLEEP); - Sys_Printf("Done.\n"); - - if (CurrentStyle() == eSplit) - Sys_Iconify (m_pZWnd->m_pParent); - - Sys_Iconify (m_pWidget); - Select_Deselect(); - QERApp_FreeShaders (); - g_bScreenUpdates = false; - - // release contexts - Sys_Printf("Releasing contexts..."); - ReleaseContexts(); - Sys_Printf("Done.\n"); - - // free all the skins in the caches - // their GL resources have been freed but the structs are not, so Radiant would think they are still valid - g_lstSkinCache.RemoveAll(); - } else - { - Sys_Printf("Waking up\n"); - if (CurrentStyle() == eSplit) - Sys_Restore (m_pZWnd->m_pParent); - - Sys_Restore (m_pWidget); - - // create contexts - Sys_Printf("Creating contexts..."); - CreateContexts(); - Sys_Printf("Done.\n"); - - Sys_Printf("Making current on camera..."); - m_pCamWnd->MakeCurrent (); - Sys_Printf("Done.\n"); - - Sys_Printf("Reloading shaders..."); - // reload the shader scripts and textures - QERApp_ReloadShaders (); - // current shader - // NOTE: we are kinda making it loop on itself, it will update the pShader and scroll the texture window - Texture_SetTexture (&g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, false, NULL, false); - Sys_Printf("Done.\n"); - - // rebuild the patches by setting the bDirty flag on them - for (brush_t* b=active_brushes.next ; b != &active_brushes ; b=b->next) - { - if (b->patchBrush) - b->pPatch->bDirty = true; - } - - Sys_Printf("Reloading skins..."); - // we have purged all the skins before going to sleep - // to rebuild, go through everything that needs a skin and call Texture_LoadSkin - // namely, all entitymodel_t - // since there's no direct list we go through entities to get the eclass_t and from there the entitymodel_t - // (a single eclass_t can reference several entitymodel_t) - // FIXME: and what's up with md3Class then? what is it used for? -/* - eclass_t *e; - entity_t *ent; - GSList *Models = NULL; - for (ent = entities.next; ent != &entities; ent = ent->next) - { - // if it's a model with skin then the fixedsize flag must be on - // only if there IS a model .. we are not trying to load - if (ent->eclass->fixedsize) - { - if (ent->eclass->model) - { -#ifdef DBG_SLEEP - if (ent->md3Class) - Sys_Printf("WARNING: unexpected ent->md3Class!=NULL with ent->eclass->model!=NULL\n"); -#endif - entitymodel_t *model; - for (model = ent->eclass->model; model; model=model->pNext) - RefreshModelSkin (&Models, model); - } else if (ent->md3Class) - { - entitymodel_t *model; - for (model = ent->md3Class->model; model; model=model->pNext) - RefreshModelSkin (&Models, model); - } -#ifdef DBG_SLEEP - else - Sys_Printf("WARNING: entity %p %s with fixedsize and no model no md3Class\n", ent, ent->eclass->name); -#endif - } - } -#ifdef DBG_SLEEP - for (e = g_md3Cache; e ; e = e->next) - { - entitymodel_t *model; - for (model = e->model; model; model=model->pNext) - if (!g_slist_find (Models, model)) - { - Sys_Printf("model %p ", model); - if (model->strSkin) - Sys_Printf("%s not found in main loop\n", ((GString *)model->strSkin)->str); - else - Sys_Printf("not found in main loop (no skin)\n"); - } - } +void SelectFaceMode(){ +#if 0 + if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) { + GlobalSelectionSystem().Select( false ); + } #endif - // clean the model list - g_slist_free (Models); -*/ - Sys_Printf("Done.\n"); - // bring back the GL font - gtk_glwidget_create_font (m_pCamWnd->GetWidget ()); + if ( FaceMode() ) { + SelectionSystem_DefaultMode(); + } + else if ( GlobalSelectionSystem().countSelected() != 0 ) { + if ( !g_currentToolModeSupportsComponentEditing ) { + g_defaultToolMode(); + } + + GlobalSelectionSystem().SetMode( SelectionSystem::eComponent ); + GlobalSelectionSystem().SetComponentMode( SelectionSystem::eFace ); + } + + ComponentModeChanged(); + + ModeChangeNotify(); +} + + +class CloneSelected : public scene::Graph::Walker +{ +bool doMakeUnique; +NodeSmartReference worldspawn; +public: +CloneSelected( bool d ) : doMakeUnique( d ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){ +} +bool pre( const scene::Path& path, scene::Instance& instance ) const { + if ( path.size() == 1 ) { + return true; + } + + // ignore worldspawn, but keep checking children + NodeSmartReference me( path.top().get() ); + if ( me == worldspawn ) { + return true; + } + + if ( !path.top().get().isRoot() ) { + Selectable* selectable = Instance_getSelectable( instance ); + if ( selectable != 0 + && selectable->isSelected() ) { + return false; + } + } + + return true; +} +void post( const scene::Path& path, scene::Instance& instance ) const { + if ( path.size() == 1 ) { + return; + } + + // ignore worldspawn, but keep checking children + NodeSmartReference me( path.top().get() ); + if ( me == worldspawn ) { + return; + } + + if ( !path.top().get().isRoot() ) { + Selectable* selectable = Instance_getSelectable( instance ); + if ( selectable != 0 + && selectable->isSelected() ) { + NodeSmartReference clone( Node_Clone( path.top() ) ); + if ( doMakeUnique ) { + Map_gatherNamespaced( clone ); + } + Node_getTraversable( path.parent().get() )->insert( clone ); + } + } +} +}; - g_bScreenUpdates = true; +void Scene_Clone_Selected( scene::Graph& graph, bool doMakeUnique ){ + graph.traverse( CloneSelected( doMakeUnique ) ); - Sys_Printf("Dispatching wake msg..."); - DispatchRadiantMsg (RADIANT_WAKEUP); - Sys_Printf("Done\n"); - } + Map_mergeClonedNames(); } -void WINAPI QERApp_Sleep() +enum ENudgeDirection { - g_pParentWnd->OnSleep(); -} + eNudgeUp = 1, + eNudgeDown = 3, + eNudgeLeft = 0, + eNudgeRight = 2, +}; -/*! -NOTE TTimo -the exit path is a bit complicated, I guess we have to run the window pos saving in OnDelete -and not in OnDestroy because the info may be lost already? -\todo try sinking OnDelete into OnDestroy and see if it breaks anything -*/ -void MainFrame::OnDelete () +struct AxisBase { - save_window_pos(m_pWidget, g_PrefsDlg.mWindowInfo.position); + Vector3 x; + Vector3 y; + Vector3 z; + AxisBase( const Vector3& x_, const Vector3& y_, const Vector3& z_ ) + : x( x_ ), y( y_ ), z( z_ ){ + } +}; - // surface inspector and patch inspector - save_window_pos (g_dlgSurface.GetWidget(), g_PrefsDlg.mWindowInfo.posSurfaceWnd); - save_window_pos (g_PatchDialog.GetWidget(), g_PrefsDlg.mWindowInfo.posPatchWnd); +AxisBase AxisBase_forViewType( VIEWTYPE viewtype ){ + switch ( viewtype ) + { + case XY: + return AxisBase( g_vector3_axis_x, g_vector3_axis_y, g_vector3_axis_z ); + case XZ: + return AxisBase( g_vector3_axis_x, g_vector3_axis_z, g_vector3_axis_y ); + case YZ: + return AxisBase( g_vector3_axis_y, g_vector3_axis_z, g_vector3_axis_x ); + } - // entity inspector / group dialog - // NOTE TTimo do we have to save a different window depending on the view mode? - save_window_pos (g_pGroupDlg->m_pWidget, g_PrefsDlg.mWindowInfo.posEntityWnd); + ERROR_MESSAGE( "invalid viewtype" ); + return AxisBase( Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ) ); +} - if (g_PrefsDlg.m_bFloatingZ) - save_window_pos (m_pZWnd->m_pParent, g_PrefsDlg.mWindowInfo.posZWnd); - else - g_PrefsDlg.mWindowInfo.nZFloatWidth = GTK_PANED (m_pSplits[0])->child1_size; +Vector3 AxisBase_axisForDirection( const AxisBase& axes, ENudgeDirection direction ){ + switch ( direction ) + { + case eNudgeLeft: + return vector3_negated( axes.x ); + case eNudgeUp: + return axes.y; + case eNudgeRight: + return axes.x; + case eNudgeDown: + return vector3_negated( axes.y ); + } - if (CurrentStyle() == eFloating) - { - save_window_pos (m_pCamWnd->m_pParent, g_PrefsDlg.mWindowInfo.posCamWnd); - save_window_pos (m_pXYWnd->m_pParent, g_PrefsDlg.mWindowInfo.posXYWnd); - save_window_pos (m_pXZWnd->m_pParent, g_PrefsDlg.mWindowInfo.posXZWnd); - save_window_pos (m_pYZWnd->m_pParent, g_PrefsDlg.mWindowInfo.posYZWnd); - } + ERROR_MESSAGE( "invalid direction" ); + return Vector3( 0, 0, 0 ); +} - g_PrefsDlg.mWindowInfo.nState = gdk_window_get_state(g_pParentWnd->m_pWidget->window); +void NudgeSelection( ENudgeDirection direction, float fAmount, VIEWTYPE viewtype ){ + AxisBase axes( AxisBase_forViewType( viewtype ) ); + Vector3 view_direction( vector3_negated( axes.z ) ); + Vector3 nudge( vector3_scaled( AxisBase_axisForDirection( axes, direction ), fAmount ) ); + GlobalSelectionSystem().NudgeManipulator( nudge, view_direction ); } -void MainFrame::OnDestroy () -{ - // shut down console output first - // (we'll still get the info if we are running a log file anyway) - g_qeglobals_gui.d_edit = NULL; +void Selection_Clone(){ + if ( GlobalSelectionSystem().Mode() == SelectionSystem::ePrimitive ) { + UndoableCommand undo( "cloneSelected" ); -#ifdef _DEBUG - Sys_Printf("MainFrame::OnDestroy\n"); -#endif - if (s_idle_id) - gtk_timeout_remove (s_idle_id); - if (m_nTimer) - gtk_timeout_remove (m_nTimer); - - if (!g_qeglobals.disable_ini) - { - Sys_Printf("Start writing prefs\n"); - Sys_Printf("MRU_Save... "); - MRU_Save (); - Sys_Printf("OK\n"); - - gpointer w; - - w = g_object_get_data (G_OBJECT (g_pGroupDlg->m_pWidget), "split1"); - g_PrefsDlg.mWindowInfo.nEntitySplit1 = GTK_PANED (w)->child1_size; - w = g_object_get_data (G_OBJECT (g_pGroupDlg->m_pWidget), "split2"); - g_PrefsDlg.mWindowInfo.nEntitySplit2 = GTK_PANED (w)->child1_size; - - if (!FloatingGroupDialog()) - { - GtkWidget *vsplit, *hsplit, *vsplit2, *hsplit2; - - vsplit = m_pSplits[0]; - vsplit2 = m_pSplits[1]; - hsplit = m_pSplits[2]; - hsplit2 = m_pSplits[3]; - - g_PrefsDlg.mWindowInfo.nXYHeight = GTK_PANED (vsplit)->child1_size; - g_PrefsDlg.mWindowInfo.nXYWidth = GTK_PANED (hsplit2)->child1_size; - - if(CurrentStyle() == eRegular) - g_PrefsDlg.mWindowInfo.nZWidth = GTK_PANED (hsplit)->child1_size; - else - g_PrefsDlg.mWindowInfo.nCamWidth = GTK_PANED (hsplit)->child1_size; - - g_PrefsDlg.mWindowInfo.nCamHeight = GTK_PANED (vsplit2)->child1_size; - } else - { - if (g_PrefsDlg.m_bFloatingZ || CurrentStyle() == eSplit) - { - if (GTK_WIDGET_VISIBLE (m_pZWnd->m_pParent)) - g_PrefsDlg.m_bZVis = TRUE; - else - g_PrefsDlg.m_bZVis = FALSE; - } - } - g_PrefsDlg.SavePrefs(); - Sys_Printf("Done prefs\n"); - } - - // spog - this may be better in another place.. - // deletes filters list and assigns g_qeglobals.d_savedinfo.filters = NULL - g_qeglobals.d_savedinfo.filters = FilterListDelete(g_qeglobals.d_savedinfo.filters); - - delete m_pXYWnd; m_pXYWnd = NULL; - delete m_pYZWnd; m_pYZWnd = NULL; - delete m_pXZWnd; m_pXZWnd = NULL; - delete m_pZWnd; m_pZWnd = NULL; - delete m_pTexWnd; m_pTexWnd = NULL; - delete m_pCamWnd; m_pCamWnd = NULL; - - if (g_pGroupDlg->m_pWidget) - { - //!\todo fix "Gtk-CRITICAL **: file gtknotebook.c: line 4643 (gtk_notebook_get_tab_label): assertion `GTK_IS_WIDGET (child)' failed" - gtk_widget_destroy (g_pGroupDlg->m_pWidget); - g_pGroupDlg->m_pWidget = NULL; - } - - if (strcmpi(currentmap, "unnamed.map") != 0) - { - g_PrefsDlg.m_strLastMap = currentmap; - g_PrefsDlg.SavePrefs (); - } - Sys_Printf("CleanUpEntities..."); - CleanUpEntities(); - Sys_Printf("Done.\n"); - - Sys_Printf("Releasing brushes..."); - while (active_brushes.next != &active_brushes) - Brush_Free (active_brushes.next, false); - while (selected_brushes.next != &selected_brushes) - Brush_Free (selected_brushes.next, false); - while (filtered_brushes.next != &filtered_brushes) - Brush_Free (filtered_brushes.next, false); - Sys_Printf("Done.\n"); - - Sys_Printf("Releasing entities..."); - while (entities.next != &entities) - Entity_Free (entities.next); - Sys_Printf("Done.\n"); - - epair_t* pEPair = g_qeglobals.d_project_entity->epairs; - while (pEPair) - { - epair_t* pNextEPair = pEPair->next; - free (pEPair->key); - free (pEPair->value); - free (pEPair); - pEPair = pNextEPair; - } - - entity_t* pEntity = g_qeglobals.d_project_entity->next; - while (pEntity != NULL && pEntity != g_qeglobals.d_project_entity) - { - entity_t* pNextEntity = pEntity->next; - Entity_Free(pEntity); - pEntity = pNextEntity; - } - - Sys_Printf("Freeing world entity..."); - if (world_entity) - Entity_Free(world_entity); - Sys_Printf("Done.\n"); - - Sys_Printf("Shutdown VFS..."); - vfsShutdown (); - Sys_Printf("Done.\n"); - - Sys_Printf("FreeShaders..."); - QERApp_FreeShaders(); - Sys_Printf("Done.\n"); -} - -// TTimo: now using profile.cpp code -void MainFrame::LoadCommandMap() -{ - FILE *f; - CString strINI; - bool bUserCmdList = false; - int nLen; - // verbose a little: count of user commands we recognized - int iCount = 0; - int iOverrideCount = 0; - int j; - - -#if defined (__linux__) || defined (__APPLE__) - strINI = g_PrefsDlg.m_rc_path->str; -#elif defined(WIN32) - strINI = g_strGameToolsPath; -#else -#error "WTF are you compiling this on" -#endif - AddSlash (strINI); - strINI += "shortcuts.ini"; - - f = fopen (strINI.GetBuffer(), "r"); - if (f != NULL) - { - fclose(f); - // loop through all the commands - for (int i = 0; i < g_nCommandCount; i++) - { - char value[1024]; - if (read_var( strINI.GetBuffer(), "Commands", g_Commands[i].m_strCommand, value )) - { - if (!bUserCmdList) - { - Sys_Printf("Found user's shortcuts list at %s\n", strINI.GetBuffer() ); - bUserCmdList = true; - } - CString strBuff; - strBuff = value; - strBuff.TrimLeft(); - strBuff.TrimRight(); - strBuff.MakeLower(); - int nSpecial = strBuff.Find("+alt"); - g_Commands[i].m_nModifiers = 0; - if (nSpecial >= 0) - { - g_Commands[i].m_nModifiers |= RAD_ALT; - FindReplace(strBuff, "+alt", ""); - } - nSpecial = strBuff.Find("+ctrl"); - if (nSpecial >= 0) - { - g_Commands[i].m_nModifiers |= RAD_CONTROL; - FindReplace(strBuff, "+ctrl", ""); - } - nSpecial = strBuff.Find("+shift"); - if (nSpecial >= 0) - { - g_Commands[i].m_nModifiers |= RAD_SHIFT; - FindReplace(strBuff, "+shift", ""); - } - strBuff.TrimLeft(); - strBuff.TrimRight(); - strBuff.MakeUpper(); - // strBuff has been cleaned of it's modifiers .. switch between a regular key and a virtual one - // based on length - nLen = strBuff.GetLength(); - if (nLen == 1) // most often case.. deal with first - { - g_Commands[i].m_nKey = __toascii(strBuff.GetAt(0)); - iCount++; - } else // special key - { - for (j = 0; j < g_nKeyCount; j++) - { - if (strBuff.CompareNoCase(g_Keys[j].m_strName) == 0) - { - g_Commands[i].m_nKey = g_Keys[j].m_nVKKey; - iCount++; - break; - } - } - if (j == g_nKeyCount) - { - Sys_Printf("WARNING: failed to parse user command %s\n", value); - continue; - } - } - // maybe this new shortcut is overriding another one - // then we need to disable the other binded key - for (j = 0; j < g_nCommandCount; j++) - { - if (j == i) - continue; - if (g_Commands[i].m_nKey == g_Commands[j].m_nKey && g_Commands[i].m_nModifiers == g_Commands[j].m_nModifiers) - { - // found! - g_Commands[j].m_nKey = 0; - // verbose - iOverrideCount++; - // it's the only one - break; - } - } - } - } - if (iOverrideCount) - Sys_Printf("User's command list overrides %d default commands\n", iOverrideCount); - Sys_Printf("Parsed %d custom shortcuts\n", iCount ); - } - else - Sys_Printf("Looked for a '%s' keyboard shortcuts file, not found\n", strINI.GetBuffer()); -} - -// TTimo: an m_nKey can be set to zero if there's no shorcut binded -// we also output the count of commands that are not binded .. dunno if it's much use .. -// (non-binded keys are usually keys that were defined by shortcuts overriden by user prefs) -void MainFrame::ShowMenuItemKeyBindings(GtkWidget* window) -{ - //!\todo Find a better way to get the global accelerator group.. - GtkAccelGroup *accel = GTK_ACCEL_GROUP(gtk_accel_groups_from_object(G_OBJECT(window))->data); - gpointer item; - guint mods; - int i; - int iCount = 0; - - for (i = 0; i < g_nCommandCount; i++) - { - if (g_Commands[i].m_nKey == 0) - { - iCount++; - continue; - } - - item = g_object_get_data (G_OBJECT (m_pWidget), g_Commands[i].m_strMenu); - if (item == NULL) - { - Sys_FPrintf (SYS_WRN, "WARNING: keyboard shortcuts init, no menu item found for command: \"%s\"\n", - g_Commands[i].m_strCommand); - continue; - } - - mods = 0; - if (g_Commands[i].m_nModifiers) // are there modifiers present? - { - if (g_Commands[i].m_nModifiers & RAD_SHIFT) - mods |= GDK_SHIFT_MASK; - if (g_Commands[i].m_nModifiers & RAD_ALT) - mods |= GDK_MOD1_MASK; - if (g_Commands[i].m_nModifiers & RAD_CONTROL) - mods |= GDK_CONTROL_MASK; - } - - // GTK won't add accelerators for some keys (ex.: delete), so we have to do it manually - if (gtk_accelerator_valid (g_Commands[i].m_nKey, (GdkModifierType)mods)) - { -#ifdef DBG_KBD - // NOTE TTimo this is the important place where all the shortcuts are binded - Sys_Printf("Calling gtk_widget_add_accelerator on command: %s menu: %s key: %d mods: %d\n", g_Commands[i].m_strCommand, g_Commands[i].m_strMenu, g_Commands[i].m_nKey, mods); -#endif - gtk_widget_add_accelerator (GTK_WIDGET (item), "activate", accel, g_Commands[i].m_nKey, - (GdkModifierType)mods, GTK_ACCEL_VISIBLE); - } else - { - GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (GTK_BIN (item)->child); - GString *gstring; - gboolean had_mod; - - g_free (accel_label->accel_string); - accel_label->accel_string = NULL; - - gstring = g_string_new (accel_label->accel_string); - g_string_append (gstring, " "); - - had_mod = FALSE; - if (mods & GDK_SHIFT_MASK) - { - g_string_append (gstring, "Shft"); - had_mod = TRUE; - } - if (mods & GDK_CONTROL_MASK) - { - if (had_mod) - g_string_append (gstring, "+"); - g_string_append (gstring, "Ctl"); - had_mod = TRUE; - } - if (mods & GDK_MOD1_MASK) - { - if (had_mod) - g_string_append (gstring, "+"); - g_string_append (gstring, "Alt"); - had_mod = TRUE; - } - - if (had_mod) - g_string_append (gstring, "+"); - if (g_Commands[i].m_nKey < 0x80 || (g_Commands[i].m_nKey > 0x80 && g_Commands[i].m_nKey <= 0xff)) - { - switch (g_Commands[i].m_nKey) - { - case ' ': - g_string_append (gstring, "Space"); - break; - case '\\': - g_string_append (gstring, "Backslash"); - break; - default: - g_string_append_c (gstring, toupper (g_Commands[i].m_nKey)); - break; - } - } else - { - gchar *tmp; - - tmp = gtk_accelerator_name (g_Commands[i].m_nKey, (GdkModifierType)0); - if (tmp[0] != 0 && tmp[1] == 0) - tmp[0] = toupper (tmp[0]); - g_string_append (gstring, tmp); - g_free (tmp); - } - - g_free (accel_label->accel_string); - accel_label->accel_string = gstring->str; - g_string_free (gstring, FALSE); - - if (!accel_label->accel_string) - accel_label->accel_string = g_strdup (""); - - gtk_widget_queue_resize (GTK_WIDGET (accel_label)); - } - } - - if (iCount) - Sys_Printf("%d commands not bound to a key\n", iCount); -} - -void MainFrame::CreateQEChildren() -{ - // load the project file - if (g_argc > 1) - { - Sys_Printf("loading project file from the command line: %s\n", g_argv[1]); - if (!QE_LoadProject(g_argv[1])) - Error("Unable to load project file %s\n", g_argv[1]); - } - else - { - const char* filename = NULL; - char buf[PATH_MAX]; - const char *r; - bool bTriedTemplate = false; - - if (g_PrefsDlg.m_nLastProjectVer != 0 && g_PrefsDlg.m_nLastProjectVer != PROJECT_VERSION) { - // we need to regenerate from template - Sys_Printf("last project has version %d, this binary wants version %d - regenerating from the template\n", g_PrefsDlg.m_nLastProjectVer, PROJECT_VERSION); - g_PrefsDlg.m_strLastProject = ""; - } - - r = g_PrefsDlg.m_strLastProject.GetBuffer(); - - while(r == NULL || *r == '\0' || access(r, R_OK) != 0 || !QE_LoadProject(r)) - { - if(!bTriedTemplate) - { - // try default project location - bTriedTemplate = true; - // for all OSes, we look for the template in the base installation (no homepath here) - strcpy(buf, g_pGameDescription->mEnginePath.GetBuffer()); - strcat(buf, g_pGameDescription->mBaseGame.GetBuffer()); - strcat(buf, "/scripts/"); - strcat(buf, PROJECT_TEMPLATE_NAME); - r = buf; - } - else - { - gtk_MessageBox (NULL, _("Failed to load project file.\nPlease enter a valid project file."), _("Load Project")); - - filename = file_dialog (m_pWidget, TRUE, _("Choose Project File"), buf, "project"); - if (filename != NULL) - r = filename; - else - Error("Cannot continue without loading a project..."); - } - } - } - - QE_Init (); -} - -void MainFrame::OnTimer() -{ - GdkModifierType mask; + Scene_Clone_Selected( GlobalSceneGraph(), false ); - gdk_window_get_pointer (NULL, NULL, NULL, &mask); + //NudgeSelection(eNudgeRight, GetGridSize(), GlobalXYWnd_getCurrentViewType()); + //NudgeSelection(eNudgeDown, GetGridSize(), GlobalXYWnd_getCurrentViewType()); + } +} - if ((mask & (GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK)) == 0) - { - QE_CountBrushesAndUpdateStatusBar(); - QE_CheckAutoSave(); - } +void Selection_Clone_MakeUnique(){ + if ( GlobalSelectionSystem().Mode() == SelectionSystem::ePrimitive ) { + UndoableCommand undo( "cloneSelectedMakeUnique" ); - // see MainFrame::UpdateStatusText below - if (m_bNeedStatusUpdate) - { - for (int n = 0; n < 6; n++) - { - if (m_strStatus[n].GetLength() >= 0 && m_pStatusLabel[n] != NULL) - gtk_label_set_text (GTK_LABEL (m_pStatusLabel[n]), m_strStatus[n]); - } - m_bNeedStatusUpdate = false; - } -} + Scene_Clone_Selected( GlobalSceneGraph(), true ); -void MainFrame::UpdateStatusText() -{ - m_bNeedStatusUpdate = true; + //NudgeSelection(eNudgeRight, GetGridSize(), GlobalXYWnd_getCurrentViewType()); + //NudgeSelection(eNudgeDown, GetGridSize(), GlobalXYWnd_getCurrentViewType()); + } } -void MainFrame::SetStatusText(int nPane, const char* pText) -{ - if (pText && nPane <= 5 && nPane >= 0) - { - m_strStatus[nPane] = pText; - UpdateStatusText(); - } -} -void MainFrame::SetButtonMenuStates() -{ - GtkWidget *item; - g_bIgnoreCommands++; - - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_showangles")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_qeglobals.d_savedinfo.show_angles); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_shownames")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_qeglobals.d_savedinfo.show_names); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_showcoordinates")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_qeglobals.d_savedinfo.show_coordinates); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_showoutline")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_qeglobals.d_savedinfo.show_outline); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_selection_nooutline")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), (g_qeglobals.d_savedinfo.iSelectedOutlinesStyle & OUTLINE_ZBUF)); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_showaxes")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_qeglobals.d_savedinfo.show_axis); - //item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_showpath")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS) ? FALSE : TRUE); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_clusterportals")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CLUSTERPORTALS) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_lightgrid")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_LIGHTGRID) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_world")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_WORLD) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_entities")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_ENT) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_areaportals")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_AREAPORTALS) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_translucent")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_TRANSLUCENT) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_liquids")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_LIQUIDS) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_caulk")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CAULK) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_clips")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CLIP) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_botclips")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_BOTCLIP) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_structural")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_STRUCTURAL) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_paths")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_PATHS) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_clusterportals")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CLUSTERPORTALS) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_lightgrid")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_LIGHTGRID) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_lights")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_LIGHTS) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_patches")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_CURVES) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_details")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_DETAILS) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_hintsskips")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_HINTSSKIPS) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_models")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_MODELS) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_triggers")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (g_qeglobals.d_savedinfo.exclude & EXCLUDE_TRIGGERS) != 0); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_toggle_lock")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), (g_PrefsDlg.m_bTextureLock) ? TRUE : FALSE); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_toggle_rotatelock")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), (g_PrefsDlg.m_bRotateLock) ? TRUE : FALSE); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_cubicclipping")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), (g_PrefsDlg.m_bCubicClipping) ? TRUE : FALSE); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_opengllighting")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), (g_PrefsDlg.m_bGLLighting) ? TRUE : FALSE); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_snaptogrid")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), (!g_PrefsDlg.m_bNoClamp) ? TRUE : FALSE); - - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_view_cubicclipping")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_PrefsDlg.m_bCubicClipping) ? TRUE : FALSE); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_dontselectmodel")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_PrefsDlg.m_bSelectModels) ? FALSE : TRUE); - - if (!g_pGameDescription->mNoPatch) - { - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_dontselectcurve")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_PrefsDlg.m_bSelectCurves) ? FALSE : TRUE); - - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_patch_showboundingbox")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_bPatchShowBounds) ? TRUE : FALSE); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_patch_weld")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_bPatchWeld) ? TRUE : FALSE); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_patch_drilldown")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_bPatchDrillDown) ? TRUE : FALSE); - } - - int id, n = g_PrefsDlg.m_nTextureScale; - switch (n) - { - case 10 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_10; break; - case 25 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_25; break; - case 50 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_50; break; - case 200 : id = ID_TEXTURES_TEXTUREWINDOWSCALE_200; break; - default : id = ID_TEXTURES_TEXTUREWINDOWSCALE_100; break; - } - SetTextureScale (id); - - // FIXME TTimo cleaned up .. the right place to do this in QE_LoadProject? -/* - if (g_qeglobals.d_project_entity) - { - FillTextureMenu(); // redundant but i'll clean it up later.. yeah right.. - FillBSPMenu(); - } - */ - g_bIgnoreCommands--; +// called when the escape key is used (either on the main window or on an inspector) +void Selection_Deselect(){ + if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) { + if ( GlobalSelectionSystem().countSelectedComponents() != 0 ) { + GlobalSelectionSystem().setSelectedAllComponents( false ); + } + else + { + SelectionSystem_DefaultMode(); + ComponentModeChanged(); + } + } + else + { + if ( GlobalSelectionSystem().countSelectedComponents() != 0 ) { + GlobalSelectionSystem().setSelectedAllComponents( false ); + } + else + { + GlobalSelectionSystem().setSelectedAll( false ); + } + } } -void MainFrame::UpdateWindows(int nBits) -{ - if (!g_bScreenUpdates) - return; -#ifdef DBG_WINDOWPOS - static int bean_count = 0; - char bean_buf[100]; - sprintf(bean_buf,"UpdateWindows %d",bean_count); - CheckWatchit(bean_buf); - bean_count++; -#endif - if (nBits & (W_XY | W_XY_OVERLAY)) - { - if (m_pXYWnd) - m_pXYWnd->RedrawWindow (); - if (m_pXZWnd) - m_pXZWnd->RedrawWindow (); - if (m_pYZWnd) - m_pYZWnd->RedrawWindow (); - } - - if (nBits & W_CAMERA || ((nBits & W_CAMERA_IFON) && m_bCamPreview)) - { - if (m_pCamWnd) - m_pCamWnd->RedrawWindow (); - } - - if (nBits & (W_Z | W_Z_OVERLAY)) - { - if (m_pZWnd) - m_pZWnd->RedrawWindow (); - } - - if (nBits & W_TEXTURE) - { - if (m_pTexWnd) - m_pTexWnd->RedrawWindow (); - } -#ifdef DBG_WINDOWPOS - sprintf(bean_buf,"%d (end UpdateWidows)",bean_count); - CheckWatchit(bean_buf); -#endif +void Selection_NudgeUp(){ + UndoableCommand undo( "nudgeSelectedUp" ); + NudgeSelection( eNudgeUp, GetGridSize(), GlobalXYWnd_getCurrentViewType() ); } -void MainFrame::RoutineProcessing() -{ -#ifdef DBG_WINDOWPOS - static int bean_count = 0; - char bean_buf[100]; - sprintf(bean_buf,"RoutineProcessing %d",bean_count); - CheckWatchit(bean_buf); - bean_count++; -#endif +void Selection_NudgeDown(){ + UndoableCommand undo( "nudgeSelectedDown" ); + NudgeSelection( eNudgeDown, GetGridSize(), GlobalXYWnd_getCurrentViewType() ); +} - if (m_bDoLoop) - { - double time = 0.0; - double oldtime = 0.0; - double delta= 0.0; - -/* // checking KeyState works right - static short a1,a2; - a2 = GetKeyState(VK_MENU); - if (a1!=a2) - { - Sys_Printf("VK_MENU: %d\n",a2); - a1 = a2; - } - static short b1,b2; - b2 = GetKeyState(VK_UP); - if (b1!=b2) - { - Sys_Printf("VK_UP: %d\n",b2); - b1 = b2; - } */ - - time = Sys_DoubleTime (); - delta = time - oldtime; - oldtime = time; - if (delta > 0.2) - delta = 0.2; - - // update the BSP process watcher - if (m_pWatchBSP) - m_pWatchBSP->RoutineProcessing(); - - // run time dependant behavior - if (m_pCamWnd) - m_pCamWnd->Cam_MouseControl(delta); - - if (g_nUpdateBits) - { - int nBits = g_nUpdateBits; // this is done to keep this routine from being - g_nUpdateBits = 0; // re-entered due to the paint process.. only - UpdateWindows(nBits); // happens in rare cases but causes a stack overflow - } -/* - // Enable/disable the menu items - GtkWidget *item; - - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_cameraupdate")); - gtk_widget_set_sensitive (item, (m_bCamPreview == false)); - if (!g_PrefsDlg.m_bWideToolbar) - { - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_view_cameraupdate")); - gtk_widget_set_sensitive (item, (m_bCamPreview == false)); - } - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_edit_undo")); - gtk_widget_set_sensitive (item, Undo_UndoAvailable()); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_edit_redo")); - gtk_widget_set_sensitive (item, Undo_RedoAvailable()); - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_file_saveregion")); - gtk_widget_set_sensitive (item, region_active); - g_bIgnoreCommands++; - // update the toolbar before displaying the menu: - // show in use check box - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_textures_showinuse")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), !g_bShowAllShaders); - // show all check box - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_textures_showall")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_bShowAllShaders); - g_bIgnoreCommands--; - */ - } -#ifdef DBG_WINDOWPOS - sprintf(bean_buf,"%d (end RoutineProcessing)",bean_count); - CheckWatchit(bean_buf); -#endif +void Selection_NudgeLeft(){ + UndoableCommand undo( "nudgeSelectedLeft" ); + NudgeSelection( eNudgeLeft, GetGridSize(), GlobalXYWnd_getCurrentViewType() ); } -void MainFrame::DoWatchBSP() -{ - // network monitoring of the BSP process - if (!m_pWatchBSP) - m_pWatchBSP = new CWatchBSP(); +void Selection_NudgeRight(){ + UndoableCommand undo( "nudgeSelectedRight" ); + NudgeSelection( eNudgeRight, GetGridSize(), GlobalXYWnd_getCurrentViewType() ); } -void MainFrame::CleanPlugInMenu() -{ - GtkWidget *menu, *sep; - GList *lst; - // delete everything after the separator - menu = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_plugin")); - sep = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_plugin_separator")); - m_nNextPlugInID = ID_PLUGIN_START; +void TranslateToolExport( const BoolImportCallback& importCallback ){ + importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eTranslate ); +} - lst = g_list_find (gtk_container_children (GTK_CONTAINER (menu)), sep); - while (lst->next) - { - gtk_container_remove (GTK_CONTAINER (menu), GTK_WIDGET (lst->next->data)); - lst = g_list_find (gtk_container_children (GTK_CONTAINER (menu)), sep); - } +void RotateToolExport( const BoolImportCallback& importCallback ){ + importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eRotate ); } -void MainFrame::AddPlugInMenuItem(IPlugIn* pPlugIn) -{ - GtkWidget *menu, *item, *parent; - const char *menuText; - - parent = gtk_menu_item_new_with_label (pPlugIn->getMenuName()); - gtk_widget_show (parent); - gtk_container_add (GTK_CONTAINER (g_object_get_data (G_OBJECT (m_pWidget), "menu_plugin")), parent); - - int nCount = pPlugIn->getCommandCount(); - if (nCount > 0) - { - menu = gtk_menu_new (); - while (nCount > 0) - { - menuText = pPlugIn->getCommand(--nCount); - if (menuText != NULL && strlen(menuText) > 0) - { - if (!strcmp(menuText, "-")) - { - item = gtk_menu_item_new (); - gtk_widget_set_sensitive (item, FALSE); - } else - { - item = gtk_menu_item_new_with_label (menuText); - gtk_signal_connect (GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (HandleCommand), GINT_TO_POINTER (m_nNextPlugInID)); - } - gtk_widget_show (item); - gtk_container_add (GTK_CONTAINER (menu), item); - pPlugIn->addMenuID(m_nNextPlugInID++); - } - } - gtk_menu_item_set_submenu (GTK_MENU_ITEM (parent), menu); - } -} - -void MainFrame::OnPlugIn(unsigned int nID, char* str) -{ - m_PlugInMgr.Dispatch(nID, str); +void ScaleToolExport( const BoolImportCallback& importCallback ){ + importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eScale ); } -inline GtkToolbarChildType gtktoolbarchildtype_for_toolbarbuttontype(IToolbarButton::EType type) -{ - switch(type) - { - case IToolbarButton::eSpace: - return GTK_TOOLBAR_CHILD_SPACE; - case IToolbarButton::eButton: - return GTK_TOOLBAR_CHILD_BUTTON; - case IToolbarButton::eToggleButton: - return GTK_TOOLBAR_CHILD_TOGGLEBUTTON; - case IToolbarButton::eRadioButton: - return GTK_TOOLBAR_CHILD_RADIOBUTTON; - } - Error("invalid toolbar button type"); - return (GtkToolbarChildType)0; -} - -void toolbar_insert(GtkWidget *toolbar, const char* image, const char* text, const char* tooltip, IToolbarButton::EType type, GtkSignalFunc handler, gpointer data) -{ - GtkWidget *w, *pixmap; - GdkPixmap *gdkpixmap; - GdkBitmap *mask; - - load_plugin_bitmap(image, (void **)&gdkpixmap, (void **)&mask); - pixmap = gtk_pixmap_new (gdkpixmap, mask); - gdk_pixmap_unref (gdkpixmap); - gdk_pixmap_unref (mask); - w = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), gtktoolbarchildtype_for_toolbarbuttontype(type), NULL, text, tooltip, "", GTK_WIDGET (pixmap), handler, data); +void DragToolExport( const BoolImportCallback& importCallback ){ + importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eDrag ); } -void SignalToolbarButton(GtkWidget *widget, gpointer data) -{ - const_cast(reinterpret_cast(data))->activate(); +void ClipperToolExport( const BoolImportCallback& importCallback ){ + importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eClip ); } -void MainFrame::AddPlugInToolbarButton(const IToolbarButton* button) -{ - GtkWidget*const toolbar = GTK_WIDGET(g_object_get_data (G_OBJECT (m_pWidget), "toolbar_plugin")); - toolbar_insert(toolbar, button->getImage(), button->getText(), button->getTooltip(), button->getType(), GTK_SIGNAL_FUNC(SignalToolbarButton), reinterpret_cast(const_cast(button))); -} +FreeCaller1 g_translatemode_button_caller; +BoolExportCallback g_translatemode_button_callback( g_translatemode_button_caller ); +ToggleItem g_translatemode_button( g_translatemode_button_callback ); -void MainFrame::OnSelectionSelectNudgedown() -{ - NudgeSelection(3, g_qeglobals.d_gridsize); -} +FreeCaller1 g_rotatemode_button_caller; +BoolExportCallback g_rotatemode_button_callback( g_rotatemode_button_caller ); +ToggleItem g_rotatemode_button( g_rotatemode_button_callback ); -void MainFrame::OnSelectionSelectNudgeleft() -{ - NudgeSelection(0, g_qeglobals.d_gridsize); -} +FreeCaller1 g_scalemode_button_caller; +BoolExportCallback g_scalemode_button_callback( g_scalemode_button_caller ); +ToggleItem g_scalemode_button( g_scalemode_button_callback ); -void MainFrame::OnSelectionSelectNudgeright() -{ - NudgeSelection(2, g_qeglobals.d_gridsize); -} +FreeCaller1 g_dragmode_button_caller; +BoolExportCallback g_dragmode_button_callback( g_dragmode_button_caller ); +ToggleItem g_dragmode_button( g_dragmode_button_callback ); -void MainFrame::OnSelectionSelectNudgeup() -{ - NudgeSelection(1, g_qeglobals.d_gridsize); -} +FreeCaller1 g_clipper_button_caller; +BoolExportCallback g_clipper_button_callback( g_clipper_button_caller ); +ToggleItem g_clipper_button( g_clipper_button_callback ); -void MainFrame::NudgeSelection(int nDirection, float fAmount) -{ - if (ActiveXY()->RotateMode()) - { - int nAxis = 0; - if (ActiveXY()->GetViewType() == XY) - { - nAxis = 2; - } else - if (g_pParentWnd->ActiveXY()->GetViewType() == XZ) - { - nAxis = 1; - fAmount = -fAmount; - } - - if (nDirection == 2 || nDirection == 3) - { - fAmount = -fAmount; - } - - float fDeg = -fAmount; - float fAdj = fAmount; - - g_pParentWnd->ActiveXY()->Rotation()[nAxis] += fAdj; - CString strStatus; - strStatus.Format("Rotation x:: %.1f y:: %.1f z:: %.1f", g_pParentWnd->ActiveXY()->Rotation()[0], - g_pParentWnd->ActiveXY()->Rotation()[1], g_pParentWnd->ActiveXY()->Rotation()[2]); - g_pParentWnd->SetStatusText(2, strStatus); - Select_RotateAxis(nAxis, fDeg, false, true); - Sys_UpdateWindows (W_ALL); - } else - if (ActiveXY()->ScaleMode()) - { - if (nDirection == 0 || nDirection == 3) - { - fAmount = -fAmount; - } - vec3_t v; - v[0] = v[1] = v[2] = 1.0; - if (fAmount > 0) - { - v[0] = 1.1f; - v[1] = 1.1f; - v[2] = 1.1f; - } else - { - v[0] = 0.9f; - v[1] = 0.9f; - v[2] = 0.9f; - } - - Select_Scale((g_nScaleHow & SCALE_X) ? v[0] : 1.0, - (g_nScaleHow & SCALE_Y) ? v[1] : 1.0, - (g_nScaleHow & SCALE_Z) ? v[2] : 1.0); - Sys_UpdateWindows (W_ALL); - } else - { - // 0 - left, 1 - up, 2 - right, 3 - down - int nDim; - if (nDirection == 0) - { - nDim = ActiveXY()->GetViewType() == YZ ? 1 : 0; - fAmount = -fAmount; - } else if (nDirection == 1) - { - nDim = ActiveXY()->GetViewType() == XY ? 1 : 2; - } else if (nDirection == 2) - { - nDim = ActiveXY()->GetViewType() == YZ ? 1 : 0; - } else - { - nDim = ActiveXY()->GetViewType() == XY ? 1 : 2; - fAmount = -fAmount; - } - Nudge(nDim, fAmount); - } -} - -void MainFrame::Nudge(int nDim, float fNudge) -{ - vec3_t vMove; - vMove[0] = vMove[1] = vMove[2] = 0; - vMove[nDim] = fNudge; - - if((g_qeglobals.d_select_mode == sel_vertex || - g_qeglobals.d_select_mode == sel_curvepoint) - && g_qeglobals.d_num_move_points) - Select_NudgePoint(vMove, true); - else - Select_Move(vMove, true); - Sys_UpdateWindows (W_ALL); +void ToolChanged(){ + g_translatemode_button.update(); + g_rotatemode_button.update(); + g_scalemode_button.update(); + g_dragmode_button.update(); + g_clipper_button.update(); } -void MainFrame::SetGridStatus() -{ - CString strStatus; - char c1; - char c2; - c1 = (g_PrefsDlg.m_bTextureLock) ? 'M' : ' '; - c2 = (g_PrefsDlg.m_bRotateLock) ? 'R' : ' '; - strStatus.Format("G:%g R:%i C:%i L:%c%c", g_qeglobals.d_gridsize, - g_PrefsDlg.m_nRotation, g_PrefsDlg.m_nCubicScale, c1, c2); - SetStatusText(4, strStatus); -} +const char* const c_ResizeMode_status = "QE4 Drag Tool: move and resize objects"; -void MainFrame::UpdatePatchToolbarButtons() -{ - GtkWidget *item; - g_bIgnoreCommands++; - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_patch_bend")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_bPatchBendMode) ? TRUE : FALSE); -// item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_patch_insdel")); -// gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_bPatchInsertMode) ? TRUE : FALSE); - g_bIgnoreCommands--; -} +void DragMode(){ + if ( g_currentToolMode == DragMode && g_defaultToolMode != DragMode ) { + g_defaultToolMode(); + } + else + { + g_currentToolMode = DragMode; + g_currentToolModeSupportsComponentEditing = true; -// ============================================================================= -// Command handlers + OnClipMode( false ); -void MainFrame::OnFileNew() -{ - if (ConfirmModified()) - Map_New (); + Sys_Status( c_ResizeMode_status ); + GlobalSelectionSystem().SetManipulatorMode( SelectionSystem::eDrag ); + ToolChanged(); + ModeChangeNotify(); + } } -void MainFrame::OnFileOpen() -{ - if (!ConfirmModified()) - return; - const char *str; - char buf[NAME_MAX]; +const char* const c_TranslateMode_status = "Translate Tool: translate objects and components"; - strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); - strcat(buf, "maps/"); +void TranslateMode(){ + if ( g_currentToolMode == TranslateMode && g_defaultToolMode != TranslateMode ) { + g_defaultToolMode(); + } + else + { + g_currentToolMode = TranslateMode; + g_currentToolModeSupportsComponentEditing = true; - str = file_dialog (m_pWidget, TRUE, _("Open Map"), buf, MAP_MAJOR); + OnClipMode( false ); - if (str != NULL) - { - strcpy(currentmap,str); - MRU_AddFile (str); - Map_LoadFile(str); - } + Sys_Status( c_TranslateMode_status ); + GlobalSelectionSystem().SetManipulatorMode( SelectionSystem::eTranslate ); + ToolChanged(); + ModeChangeNotify(); + } } -void MainFrame::OnFileImportmap() -{ - const char *str; - char buf[NAME_MAX]; +const char* const c_RotateMode_status = "Rotate Tool: rotate objects and components"; - strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); - strcat(buf, "maps/"); +void RotateMode(){ + if ( g_currentToolMode == RotateMode && g_defaultToolMode != RotateMode ) { + g_defaultToolMode(); + } + else + { + g_currentToolMode = RotateMode; + g_currentToolModeSupportsComponentEditing = true; - str = file_dialog (m_pWidget, TRUE, _("Import Map"), buf, MAP_MAJOR); + OnClipMode( false ); - if (str != NULL) - { - Map_ImportFile(str); - } + Sys_Status( c_RotateMode_status ); + GlobalSelectionSystem().SetManipulatorMode( SelectionSystem::eRotate ); + ToolChanged(); + ModeChangeNotify(); + } } -void MainFrame::OnFileSave() -{ - if (!strcmp(currentmap, "unnamed.map")) - OnFileSaveas(); - else - Map_SaveFile (currentmap, false); -} +const char* const c_ScaleMode_status = "Scale Tool: scale objects and components"; -void MainFrame::OnFileSaveas() -{ - const char* str; - char buf[NAME_MAX]; +void ScaleMode(){ + if ( g_currentToolMode == ScaleMode && g_defaultToolMode != ScaleMode ) { + g_defaultToolMode(); + } + else + { + g_currentToolMode = ScaleMode; + g_currentToolModeSupportsComponentEditing = true; - strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); - strcat(buf, "maps/"); + OnClipMode( false ); - str = file_dialog (g_pParentWnd->m_pWidget, FALSE, _("Save Map"), buf, MAP_MAJOR); - - if (str != NULL) - { - strcpy (currentmap, str); - MRU_AddFile (str); - Map_SaveFile (str, false); // ignore region - } + Sys_Status( c_ScaleMode_status ); + GlobalSelectionSystem().SetManipulatorMode( SelectionSystem::eScale ); + ToolChanged(); + ModeChangeNotify(); + } } -void MainFrame::OnFileExportmap() -{ - const char* str; - char buf[NAME_MAX]; - strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); - strcat(buf, "maps/"); +const char* const c_ClipperMode_status = "Clipper Tool: apply clip planes to objects"; + - str = file_dialog (m_pWidget, FALSE, _("Export Selection"), buf, MAP_MAJOR); +void ClipperMode(){ + if ( g_currentToolMode == ClipperMode && g_defaultToolMode != ClipperMode ) { + g_defaultToolMode(); + } + else + { + g_currentToolMode = ClipperMode; + g_currentToolModeSupportsComponentEditing = false; - if (str != NULL) - { - Map_SaveSelected (str); - } + SelectionSystem_DefaultMode(); + + OnClipMode( true ); + + Sys_Status( c_ClipperMode_status ); + GlobalSelectionSystem().SetManipulatorMode( SelectionSystem::eClip ); + ToolChanged(); + ModeChangeNotify(); + } } -void MainFrame::OnFileSaveregion() -{ - const char* str; - char buf[NAME_MAX]; - strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); - strcat(buf, "maps/"); +void Texdef_Rotate( float angle ){ + StringOutputStream command; + command << "brushRotateTexture -angle " << angle; + UndoableCommand undo( command.c_str() ); + Select_RotateTexture( angle ); +} - str = file_dialog (g_pParentWnd->m_pWidget, FALSE, _("Export Region"), buf, MAP_MAJOR); +void Texdef_RotateClockwise(){ + Texdef_Rotate( static_cast( fabs( g_si_globals.rotate ) ) ); +} - if (str != NULL) - { - Map_SaveFile (str, true); // ignore region - } +void Texdef_RotateAntiClockwise(){ + Texdef_Rotate( static_cast( -fabs( g_si_globals.rotate ) ) ); } -void MainFrame::OnFileNewproject() -{ - char* name = DoNewProjectDlg (); - - // create a new project: - // create directories and grab current project, save it in new project tree in scripts/user.qe4 - // on linux we create under ~/.q3a, on win32 under strEnginePath - // NOTE: working on a seperate project file might be broken, never did much experiment with that.. - if ((name != NULL) && (strlen (name) > 0)) - { - CString strNewBasePath; - - // NOTE TTimo this would probably not work right on *nix - strNewBasePath = g_pGameDescription->mEnginePath.GetBuffer(); // assume paths end with '/' - strNewBasePath += name; - strNewBasePath += "/"; - - CString strProjToLoad; - CString strMapToLoad; - - // if the dir exists, ask the user if they want to continue anyway - if (Q_mkdir (strNewBasePath.GetBuffer(), 0755) != 0) - { - CString strMsg; - strMsg.Format("The directory name %s already exists\nContinue anyway ?\n", strNewBasePath.GetBuffer ()); - Sys_Printf(strMsg); - if (gtk_MessageBox(m_pWidget, _(strMsg), _("Error"), MB_YESNO) != IDYES) - { - Sys_Printf("New Project cancelled, directory already exists for project\n"); - free (name); - return; - } - } - - CString strDir; - strDir = strNewBasePath; - strDir += "maps/"; - Q_mkdir (strDir.GetBuffer(), 0755); - - strDir = strNewBasePath; - strDir += "textures/"; - Q_mkdir (strDir.GetBuffer(), 0755); - - strDir = strNewBasePath; - strDir += "scripts/"; - Q_mkdir (strDir.GetBuffer(), 0755); - - // print a warning for total conversions, since setting the basepath when required files are - // not there _will_ break things (ie; textures/radiant/notex.tga, scripts/entities.def) - Sys_FPrintf(SYS_WRN, "*** Note: basepath unchanged\n"); - - SetKeyValue( g_qeglobals.d_project_entity, "gamename", name); - - strDir = strNewBasePath; - strDir += "maps/autosave.map"; - SetKeyValue( g_qeglobals.d_project_entity, "autosave", strDir.GetBuffer() ); - - // state that this is a user project file, no templating - SetKeyValue( g_qeglobals.d_project_entity, "user_project", "1" ); - // create the project file - strProjToLoad = strNewBasePath; - strProjToLoad += "scripts/"; - strProjToLoad += name; - strProjToLoad += "."; - strProjToLoad += PROJECT_FILETYPE; - QE_SaveProject(strProjToLoad.GetBuffer()); - free (name); - } -} - -void MainFrame::OnFileLoadproject() -{ - if (ConfirmModified()) - ProjectDialog (); +void Texdef_Scale( float x, float y ){ + StringOutputStream command; + command << "brushScaleTexture -x " << x << " -y " << y; + UndoableCommand undo( command.c_str() ); + Select_ScaleTexture( x, y ); } -void MainFrame::OnFileProjectsettings() -{ - DoProjectSettings(); +void Texdef_ScaleUp(){ + Texdef_Scale( 0, g_si_globals.scale[1] ); } -void MainFrame::OnFilePointfile() -{ - if (g_qeglobals.d_pointfile_display_list) - Pointfile_Clear (); - else - Pointfile_Check (); +void Texdef_ScaleDown(){ + Texdef_Scale( 0, -g_si_globals.scale[1] ); } -void MainFrame::OnMru(unsigned int nID) -{ - if (ConfirmModified()) - MRU_Activate (nID - ID_FILE_RECENT1); +void Texdef_ScaleLeft(){ + Texdef_Scale( -g_si_globals.scale[0],0 ); } -void MainFrame::OnFileExit() -{ - if (ConfirmModified()) - { - // stop printing during shutdown - // NOTE: we should cleanly release GL contexts and stuff when exiting +void Texdef_ScaleRight(){ + Texdef_Scale( g_si_globals.scale[0],0 ); +} - OnDelete(); +void Texdef_Shift( float x, float y ){ + StringOutputStream command; + command << "brushShiftTexture -x " << x << " -y " << y; + UndoableCommand undo( command.c_str() ); + Select_ShiftTexture( x, y ); +} - g_qeglobals_gui.d_edit = NULL; - gtk_widget_destroy (m_pWidget); - } +void Texdef_ShiftLeft(){ + Texdef_Shift( -g_si_globals.shift[0], 0 ); } -void MainFrame::OnFileCheckUpdate() +void Texdef_ShiftRight(){ + Texdef_Shift( g_si_globals.shift[0], 0 ); +} -{ - // build the URL - Str URL; - URL = "http://www.qeradiant.com/index.php?data=dlupdate&query_dlup=1"; -#ifdef _WIN32 - URL += "&OS_dlup=1"; -#else - URL += "&OS_dlup=2"; -#endif - URL += "&Version_dlup=" RADIANT_VERSION; - g_PrefsDlg.mGamesDialog.AddPacksURL(URL); - OpenURL(URL.GetBuffer()); +void Texdef_ShiftUp(){ + Texdef_Shift( 0, g_si_globals.shift[1] ); } -void MainFrame::OnEditUndo() -{ - Undo_Undo(); +void Texdef_ShiftDown(){ + Texdef_Shift( 0, -g_si_globals.shift[1] ); } -void MainFrame::OnEditRedo() + + +class SnappableSnapToGridSelected : public scene::Graph::Walker { - Undo_Redo(); +float m_snap; +public: +SnappableSnapToGridSelected( float snap ) + : m_snap( snap ){ } +bool pre( const scene::Path& path, scene::Instance& instance ) const { + if ( path.top().get().visible() ) { + Snappable* snappable = Node_getSnappable( path.top() ); + if ( snappable != 0 + && Instance_getSelectable( instance )->isSelected() ) { + snappable->snapto( m_snap ); + } + } + return true; +} +}; -void MainFrame::OnEditCopybrush() -{ - Copy(); +void Scene_SnapToGrid_Selected( scene::Graph& graph, float snap ){ + graph.traverse( SnappableSnapToGridSelected( snap ) ); } -void MainFrame::OnEditPastebrush() +class ComponentSnappableSnapToGridSelected : public scene::Graph::Walker { - Select_Deselect(); +float m_snap; +public: +ComponentSnappableSnapToGridSelected( float snap ) + : m_snap( snap ){ +} +bool pre( const scene::Path& path, scene::Instance& instance ) const { + if ( path.top().get().visible() ) { + ComponentSnappable* componentSnappable = Instance_getComponentSnappable( instance ); + if ( componentSnappable != 0 + && Instance_getSelectable( instance )->isSelected() ) { + componentSnappable->snapComponents( m_snap ); + } + } + return true; +} +}; - Undo_Start("paste"); +void Scene_SnapToGrid_Component_Selected( scene::Graph& graph, float snap ){ + graph.traverse( ComponentSnappableSnapToGridSelected( snap ) ); +} - Paste(); +void Selection_SnapToGrid(){ + StringOutputStream command; + command << "snapSelected -grid " << GetGridSize(); + UndoableCommand undo( command.c_str() ); - Undo_EndBrushList(&selected_brushes); - Undo_End(); + if ( GlobalSelectionSystem().Mode() == SelectionSystem::eComponent ) { + Scene_SnapToGrid_Component_Selected( GlobalSceneGraph(), GetGridSize() ); + } + else + { + Scene_SnapToGrid_Selected( GlobalSceneGraph(), GetGridSize() ); + } } -void MainFrame::OnEditPastebrushToCamera() -{ - Select_Deselect(); - if (ActiveXY()) - { - vec3_t mid, camorigin, delta; - ActiveXY()->Paste(); +static gint qe_every_second( gpointer data ){ + GdkModifierType mask; - // Work out the delta - Select_GetMid( mid ); + gdk_window_get_pointer( 0, 0, 0, &mask ); - // Snap camera origin to grid - VectorCopy( m_pCamWnd->Camera()->origin, camorigin ); - camorigin[0] = floor(camorigin[0] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize; - camorigin[1] = floor(camorigin[1] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize; - camorigin[2] = floor(camorigin[2] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize; + if ( ( mask & ( GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK ) ) == 0 ) { + QE_CheckAutoSave(); + } - VectorSubtract( camorigin, mid, delta ); + return TRUE; +} - // Move to camera - Select_Move( delta, false ); +guint s_qe_every_second_id = 0; - Undo_Start("paste to camera"); - Undo_EndBrushList(&selected_brushes); - Undo_End(); - } +void EverySecondTimer_enable(){ + if ( s_qe_every_second_id == 0 ) { + s_qe_every_second_id = g_timeout_add( 1000, qe_every_second, 0 ); + } } -void MainFrame::OnSelectionDelete() -{ - brush_t *brush; - //if (ActiveXY()) - // ActiveXY()->UndoCopy(); - Undo_Start("delete"); - Undo_AddBrushList(&selected_brushes); - //add all deleted entities to the undo - for (brush = selected_brushes.next; brush != &selected_brushes; brush = brush->next) - { - Undo_AddEntity(brush->owner); - } - // NOTE: Select_Delete does NOT delete entities - Select_Delete(); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} - -void MainFrame::OnEditMapinfo() -{ - DoMapInfo (); +void EverySecondTimer_disable(){ + if ( s_qe_every_second_id != 0 ) { + g_source_remove( s_qe_every_second_id ); + s_qe_every_second_id = 0; + } } -void MainFrame::OnEditEntityinfo() -{ - DoEntityList (); +gint window_realize_remove_decoration( ui::Widget widget, gpointer data ){ + gdk_window_set_decorations( gtk_widget_get_window(widget), (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) ); + return FALSE; } -void MainFrame::OnBrushScripts() +class WaitDialog { - DoScriptsDlg (); -} +public: +ui::Window m_window; +GtkLabel* m_label; +}; -void MainFrame::OnEditLoadprefab() -{ - const char *filename; - CString CurPath; +WaitDialog create_wait_dialog( const char* title, const char* text ){ + WaitDialog dialog; - if (g_PrefsDlg.m_strPrefabPath.GetLength() > 0) - { - CurPath = g_PrefsDlg.m_strPrefabPath; - AddSlash (CurPath); - } + dialog.m_window = MainFrame_getWindow().create_floating_window(title); + gtk_window_set_resizable( dialog.m_window, FALSE ); + gtk_container_set_border_width( GTK_CONTAINER( dialog.m_window ), 0 ); + gtk_window_set_position( dialog.m_window, GTK_WIN_POS_CENTER_ON_PARENT ); - filename = file_dialog (m_pWidget, TRUE, _("Import Prefab"), CurPath.GetBuffer(), MAP_MAJOR); + g_signal_connect( G_OBJECT( dialog.m_window ), "realize", G_CALLBACK( window_realize_remove_decoration ), 0 ); - if (filename != NULL) - { - Map_ImportFile(filename); - } -} + { + dialog.m_label = GTK_LABEL( ui::Label( text ) ); + gtk_misc_set_alignment( GTK_MISC( dialog.m_label ), 0.0, 0.5 ); + gtk_label_set_justify( dialog.m_label, GTK_JUSTIFY_LEFT ); + gtk_widget_show( GTK_WIDGET( dialog.m_label ) ); + gtk_widget_set_size_request( GTK_WIDGET( dialog.m_label ), 200, -1 ); -void MainFrame::OnEditSaveprefab() -{ - const char *filename; - CString CurPath; - - if (g_PrefsDlg.m_strPrefabPath.GetLength() > 0) - { - CurPath = g_PrefsDlg.m_strPrefabPath; - } else - { - char tmp[PATH_MAX]; - getcwd (tmp, PATH_MAX); - CurPath = tmp; - } - AddSlash (CurPath); - - filename = file_dialog (m_pWidget, FALSE, _("Export Prefab"), CurPath.GetBuffer(), MAP_MAJOR); - if (filename != NULL) - { - Map_SaveSelected(filename); - } -} - -void MainFrame::OnPrefs() -{ - int nView = g_PrefsDlg.m_nView; - bool bToolbar = g_PrefsDlg.m_bWideToolbar; - bool bPluginToolbar = g_PrefsDlg.m_bPluginToolbar; - int nShader = g_PrefsDlg.m_nShader; - int nTextureQuality = g_PrefsDlg.m_nTextureQuality; -// int nLightRadiuses = g_PrefsDlg.m_nLightRadiuses; - g_PrefsDlg.LoadPrefs(); - - if (g_PrefsDlg.DoModal() == IDOK) - { - if ((g_PrefsDlg.m_nLatchedView != nView) || - (g_PrefsDlg.m_bLatchedDetachableMenus != g_PrefsDlg.m_bDetachableMenus) || - (g_PrefsDlg.m_bLatchedWideToolbar != bToolbar) || - (g_PrefsDlg.m_bLatchedPatchToolbar != bToolbar) || - (g_PrefsDlg.m_bLatchedPluginToolbar != bPluginToolbar) || - (g_PrefsDlg.m_nLatchedShader != nShader) || - (g_PrefsDlg.m_nLatchedTextureQuality != nTextureQuality) - || (g_PrefsDlg.m_bLatchedFloatingZ != g_PrefsDlg.m_bFloatingZ) - ) - gtk_MessageBox(m_pWidget, _("You must restart Radiant for the changes to take effect.")); - - // if the view mode was switched to floating, set the Z window on by default - // this was originally intended as a bug fix, but the fix is elsewhere .. anyway making sure we force Z on each time is good - // (and we simply hope there will be a SavePrefs before we die) - if ((g_PrefsDlg.m_nView != nView) && ((EViewStyle)g_PrefsDlg.m_nView == (EViewStyle)eFloating)) - { - g_PrefsDlg.m_bZVis = true; - } - - if (m_pTexWnd) - m_pTexWnd->UpdatePrefs(); - - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_snaptogrid")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - (!g_PrefsDlg.m_bNoClamp) ? TRUE : FALSE); - g_bIgnoreCommands--; - } -} - -void MainFrame::OnTogglecamera() -{ - if (CurrentStyle() == eFloating) // floating views - { - if (m_pCamWnd && m_pCamWnd->m_pParent) - { - if (GTK_WIDGET_VISIBLE (m_pCamWnd->m_pParent)) - widget_delete_hide (m_pCamWnd->m_pParent); - else - gtk_widget_show (m_pCamWnd->m_pParent); - } - } else - { - if (GTK_WIDGET_VISIBLE (m_pCamWnd->GetWidget ())) - gtk_widget_hide (m_pCamWnd->GetWidget ()); - else - gtk_widget_show (m_pCamWnd->GetWidget ()); - } -} - -void MainFrame::OnToggleconsole() -{ - if (FloatingGroupDialog()) // QE4 style - { - if (inspector_mode == W_CONSOLE) - { - if (GTK_WIDGET_VISIBLE (g_qeglobals_gui.d_entity)) - widget_delete_hide (g_qeglobals_gui.d_entity); - else - gtk_widget_show (g_qeglobals_gui.d_entity); - } else - { - gtk_widget_show (g_qeglobals_gui.d_entity); - SetInspectorMode(W_CONSOLE); - } - } -} - -// trigger the entity inspector on/off -void MainFrame::OnViewEntity() -{ - // make sure we're working with the current selection (bugzilla #436) - if( ! GTK_WIDGET_VISIBLE (g_qeglobals_gui.d_entity)) - Select_Reselect(); - - if (!FloatingGroupDialog()) - { - if (GTK_WIDGET_VISIBLE (g_qeglobals_gui.d_entity) && inspector_mode == W_ENTITY) - widget_delete_hide (g_qeglobals_gui.d_entity); - else - { - gtk_widget_show (g_qeglobals_gui.d_entity); - SetInspectorMode(W_ENTITY); - } - } else - { - if (inspector_mode == W_ENTITY) - { - if (GTK_WIDGET_VISIBLE (g_qeglobals_gui.d_entity)) - widget_delete_hide (g_qeglobals_gui.d_entity); - else - gtk_widget_show (g_qeglobals_gui.d_entity); - } else - { - gtk_widget_show (g_qeglobals_gui.d_entity); - SetInspectorMode(W_ENTITY); - } - } -} - -void MainFrame::OnViewGroups() -{ - if (!FloatingGroupDialog()) - { - if (GTK_WIDGET_VISIBLE (g_qeglobals_gui.d_entity) && inspector_mode == W_GROUP) - widget_delete_hide (g_qeglobals_gui.d_entity); - else - { - gtk_widget_show (g_qeglobals_gui.d_entity); - SetInspectorMode(W_GROUP); - } - } else - { - if (inspector_mode == W_GROUP && CurrentStyle() != MainFrame::eFloating) - { - if (GTK_WIDGET_VISIBLE (g_qeglobals_gui.d_entity)) - widget_delete_hide (g_qeglobals_gui.d_entity); - else - gtk_widget_show (g_qeglobals_gui.d_entity); - } else - { - gtk_widget_show (g_qeglobals_gui.d_entity); - SetInspectorMode(W_GROUP); - } - } -} - -void MainFrame::OnToggleview() -{ - if (CurrentStyle() == eFloating) // QE4 style - { - if (m_pXYWnd && m_pXYWnd->m_pParent) - { - if (GTK_WIDGET_VISIBLE (m_pXYWnd->m_pParent)) - widget_delete_hide (m_pXYWnd->m_pParent); - else - gtk_widget_show (m_pXYWnd->m_pParent); - } - } -} - -void MainFrame::OnToggleviewXz() -{ - if (CurrentStyle() == eFloating) // QE4 style - { - if (m_pXZWnd && m_pXZWnd->m_pParent) - { - // get windowplacement doesn't actually save this so we will here - g_PrefsDlg.m_bXZVis = GTK_WIDGET_VISIBLE (m_pXZWnd->m_pParent); - if (g_PrefsDlg.m_bXZVis) - widget_delete_hide (m_pXZWnd->m_pParent); - else - gtk_widget_show (m_pXZWnd->m_pParent); - g_PrefsDlg.m_bXZVis ^= 1; - g_PrefsDlg.SavePrefs (); - } - } -} - -void MainFrame::OnToggleviewYz() -{ - if (CurrentStyle() == eFloating) // QE4 style - { - if (m_pYZWnd && m_pYZWnd->m_pParent) - { - g_PrefsDlg.m_bYZVis = GTK_WIDGET_VISIBLE (m_pYZWnd->m_pParent); - if (g_PrefsDlg.m_bYZVis) - widget_delete_hide (m_pYZWnd->m_pParent); - else - gtk_widget_show (m_pYZWnd->m_pParent); - g_PrefsDlg.m_bYZVis ^= 1; - g_PrefsDlg.SavePrefs (); - } - } -} - -void MainFrame::OnTogglez() -{ - if ( g_pParentWnd->FloatingGroupDialog() ) // QE4 style - { - if (m_pZWnd && m_pZWnd->m_pParent) - { - if (GTK_WIDGET_VISIBLE (m_pZWnd->m_pParent)) - widget_delete_hide (m_pZWnd->m_pParent); - else - gtk_widget_show (m_pZWnd->m_pParent); - g_PrefsDlg.m_bZVis ^= 1; - g_PrefsDlg.SavePrefs (); - } - } else { - Sys_FPrintf( SYS_WRN, "Z view toggle is only valid in floating views\n" ); - } -} - -void MainFrame::OnViewCenter() -{ - m_pCamWnd->Camera()->angles[ROLL] = m_pCamWnd->Camera()->angles[PITCH] = 0; - m_pCamWnd->Camera()->angles[YAW] = 22.5 * floor((m_pCamWnd->Camera()->angles[YAW]+11)/22.5); - Sys_UpdateWindows (W_CAMERA | W_XY_OVERLAY); + gtk_container_add( GTK_CONTAINER( dialog.m_window ), GTK_WIDGET( dialog.m_label ) ); + } + return dialog; } -void MainFrame::OnViewUpfloor() +namespace { - m_pCamWnd->Cam_ChangeFloor (true); -} +clock_t g_lastRedrawTime = 0; +const clock_t c_redrawInterval = clock_t( CLOCKS_PER_SEC / 10 ); -void MainFrame::OnViewDownfloor() -{ - m_pCamWnd->Cam_ChangeFloor (false); +bool redrawRequired(){ + clock_t currentTime = std::clock(); + if ( currentTime - g_lastRedrawTime >= c_redrawInterval ) { + g_lastRedrawTime = currentTime; + return true; + } + return false; } - -void MainFrame::OnViewCenterview() -{ - if(CurrentStyle() == eSplit) - { - GetXYWnd()->PositionView(); - GetXZWnd()->PositionView(); - GetYZWnd()->PositionView(); - Sys_UpdateWindows (W_XY|W_XZ|W_YZ); - } - else { - m_pXYWnd->PositionView(); - Sys_UpdateWindows (W_XY); - } -} - -void MainFrame::OnViewNextview() -{ - if (CurrentStyle() == eSplit) - { - GetXYWnd()->PositionView(); - GetXZWnd()->PositionView(); - GetYZWnd()->PositionView(); - Sys_UpdateWindows (W_XY|W_XZ|W_YZ); - } - else { - if (m_pXYWnd->GetViewType() == XY) - m_pXYWnd->SetViewType(XZ); - else - if (m_pXYWnd->GetViewType() == XZ) - m_pXYWnd->SetViewType(YZ); - else - m_pXYWnd->SetViewType(XY); - m_pXYWnd->PositionView(); - Sys_UpdateWindows (W_XY); - } -} - -void MainFrame::OnViewXy() -{ - if(!FloatingGroupDialog()) - { - m_pXYWnd->SetViewType(XY); - m_pXYWnd->PositionView(); - } - Sys_UpdateWindows (W_XY); } -void MainFrame::OnViewSide() -{ - if (!FloatingGroupDialog()) - { - m_pXYWnd->SetViewType(XZ); - m_pXYWnd->PositionView(); - } - Sys_UpdateWindows (W_XY); +bool MainFrame_isActiveApp(){ + //globalOutputStream() << "listing\n"; + GList* list = gtk_window_list_toplevels(); + for ( GList* i = list; i != 0; i = g_list_next( i ) ) + { + //globalOutputStream() << "toplevel.. "; + if ( gtk_window_is_active( GTK_WINDOW( i->data ) ) ) { + //globalOutputStream() << "is active\n"; + return true; + } + //globalOutputStream() << "not active\n"; + } + return false; } -void MainFrame::OnViewFront() -{ - if (!FloatingGroupDialog()) - { - m_pXYWnd->SetViewType(YZ); - m_pXYWnd->PositionView(); - } - Sys_UpdateWindows (W_XY); -} +typedef std::list StringStack; +StringStack g_wait_stack; +WaitDialog g_wait; -void MainFrame::OnView100() -{ - if (m_pXYWnd) - m_pXYWnd->SetScale(1); - if (m_pXZWnd) - m_pXZWnd->SetScale(1); - if (m_pYZWnd) - m_pYZWnd->SetScale(1); - Sys_UpdateWindows (W_XY|W_XY_OVERLAY); +bool ScreenUpdates_Enabled(){ + return g_wait_stack.empty(); } -void MainFrame::OnViewZoomin() -{ - if (m_pXYWnd && m_pXYWnd->Active()) - { - m_pXYWnd->SetScale(m_pXYWnd->Scale() * 5.0 / 4); - if (m_pXYWnd->Scale() > 30) - m_pXYWnd->SetScale(30); - } - - if (m_pXZWnd && m_pXZWnd->Active()) - { - m_pXZWnd->SetScale(m_pXZWnd->Scale() * 5.0 / 4); - if (m_pXZWnd->Scale() > 30) - m_pXZWnd->SetScale(30); - } - - if (m_pYZWnd && m_pYZWnd->Active()) - { - m_pYZWnd->SetScale(m_pYZWnd->Scale() * 5.0 / 4); - if (m_pYZWnd->Scale() > 30) - m_pYZWnd->SetScale(30); - } - - Sys_UpdateWindows (W_XY|W_XY_OVERLAY); -} - -// NOTE: the zoom out factor is 4/5, we could think about customizing it -// we don't go below a zoom factor corresponding to 10% of the max world size -// (this has to be computed against the window size) -void MainFrame::OnViewZoomout() -{ - float min_scale; - if (m_pXYWnd && m_pXYWnd->Active()) - { - m_pXYWnd->SetScale(m_pXYWnd->Scale() * 4.0 / 5); - min_scale = MIN(m_pXYWnd->Width(),m_pXYWnd->Height()) / ( 1.1 * (g_MaxWorldCoord-g_MinWorldCoord)); - if (m_pXYWnd->Scale() < min_scale) m_pXYWnd->SetScale (min_scale); - } - - if (m_pXZWnd && m_pXZWnd->Active()) - { - m_pXZWnd->SetScale(m_pXZWnd->Scale() * 4.0 / 5); - min_scale = MIN(m_pXZWnd->Width(),m_pXZWnd->Height()) / ( 1.1 * (g_MaxWorldCoord-g_MinWorldCoord)); - if (m_pXZWnd->Scale() < min_scale) m_pXZWnd->SetScale (min_scale); - } - - if (m_pYZWnd && m_pYZWnd->Active()) - { - m_pYZWnd->SetScale(m_pYZWnd->Scale() * 4.0 / 5); - min_scale = MIN(m_pYZWnd->Width(),m_pYZWnd->Height()) / ( 1.1 * (g_MaxWorldCoord-g_MinWorldCoord)); - if (m_pYZWnd->Scale() < min_scale) m_pYZWnd->SetScale (min_scale); - } - Sys_UpdateWindows (W_XY|W_XY_OVERLAY); -} - -void MainFrame::OnViewZ100() -{ - z.scale = 1; - Sys_UpdateWindows (W_Z|W_Z_OVERLAY); +void ScreenUpdates_process(){ + if ( redrawRequired() && gtk_widget_get_visible( g_wait.m_window ) ) { + process_gui(); + } } -void MainFrame::OnViewZzoomin() -{ - z.scale *= 5.0/4; - if (z.scale > 4) - z.scale = 4; - Sys_UpdateWindows (W_Z|W_Z_OVERLAY); -} -void MainFrame::OnViewZzoomout() -{ - z.scale *= 4.0f/5; - if (z.scale < 0.125) - z.scale = 0.125; - Sys_UpdateWindows (W_Z|W_Z_OVERLAY); -} +void ScreenUpdates_Disable( const char* message, const char* title ){ + if ( g_wait_stack.empty() ) { + EverySecondTimer_disable(); -void MainFrame::OnViewCubein() -{ - g_PrefsDlg.m_nCubicScale--; - if (g_PrefsDlg.m_nCubicScale < 1) - g_PrefsDlg.m_nCubicScale = 1; - g_PrefsDlg.SavePrefs (); - Sys_UpdateWindows(W_CAMERA); - SetGridStatus(); + process_gui(); + + bool isActiveApp = MainFrame_isActiveApp(); + + g_wait = create_wait_dialog( title, message ); + gtk_grab_add( GTK_WIDGET( g_wait.m_window ) ); + + if ( isActiveApp ) { + gtk_widget_show( GTK_WIDGET( g_wait.m_window ) ); + ScreenUpdates_process(); + } + } + else if ( gtk_widget_get_visible( g_wait.m_window ) ) { + gtk_label_set_text( g_wait.m_label, message ); + ScreenUpdates_process(); + } + g_wait_stack.push_back( message ); } -void MainFrame::OnViewCubeout() -{ - g_PrefsDlg.m_nCubicScale++; - if (g_PrefsDlg.m_nCubicScale > 22) - g_PrefsDlg.m_nCubicScale = 22; - g_PrefsDlg.SavePrefs (); - Sys_UpdateWindows(W_CAMERA); - SetGridStatus(); +void ScreenUpdates_Enable(){ + ASSERT_MESSAGE( !ScreenUpdates_Enabled(), "screen updates already enabled" ); + g_wait_stack.pop_back(); + if ( g_wait_stack.empty() ) { + EverySecondTimer_enable(); + //gtk_widget_set_sensitive(GTK_WIDGET(MainFrame_getWindow()), TRUE); + + gtk_grab_remove( GTK_WIDGET( g_wait.m_window ) ); + destroy_floating_window( g_wait.m_window ); + g_wait.m_window = ui::Window(); + + //gtk_window_present(MainFrame_getWindow()); + } + else if ( gtk_widget_get_visible( g_wait.m_window ) ) { + gtk_label_set_text( g_wait.m_label, g_wait_stack.back().c_str() ); + ScreenUpdates_process(); + } } -void MainFrame::OnViewShownames() -{ - g_qeglobals.d_savedinfo.show_names = !g_qeglobals.d_savedinfo.show_names; - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_shownames")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - g_qeglobals.d_savedinfo.show_names ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows (W_XY); + + +void GlobalCamera_UpdateWindow(){ + if ( g_pParentWnd != 0 ) { + CamWnd_Update( *g_pParentWnd->GetCamWnd() ); + } } -void MainFrame::OnViewShowAngles() -{ - g_qeglobals.d_savedinfo.show_angles = !g_qeglobals.d_savedinfo.show_angles; - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_showangles")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - g_qeglobals.d_savedinfo.show_angles ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows (W_XY); +void XY_UpdateWindow( MainFrame& mainframe ){ + if ( mainframe.GetXYWnd() != 0 ) { + XYWnd_Update( *mainframe.GetXYWnd() ); + } } -void MainFrame::OnViewShowblocks() -{ - g_qeglobals.show_blocks ^= 1; - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_showblocks")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_qeglobals.show_blocks ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows (W_XY); +void XZ_UpdateWindow( MainFrame& mainframe ){ + if ( mainframe.GetXZWnd() != 0 ) { + XYWnd_Update( *mainframe.GetXZWnd() ); + } } -void MainFrame::OnViewShowcoordinates() -{ - g_qeglobals.d_savedinfo.show_coordinates ^= 1; - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_showcoordinates")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - g_qeglobals.d_savedinfo.show_coordinates ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows (W_XY|W_Z); +void YZ_UpdateWindow( MainFrame& mainframe ){ + if ( mainframe.GetYZWnd() != 0 ) { + XYWnd_Update( *mainframe.GetYZWnd() ); + } } -void MainFrame::OnViewShowOutline() -{ - g_qeglobals.d_savedinfo.show_outline ^= 1; - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_showoutline")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - g_qeglobals.d_savedinfo.show_outline ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows (W_XY); +void XY_UpdateAllWindows( MainFrame& mainframe ){ + XY_UpdateWindow( mainframe ); + XZ_UpdateWindow( mainframe ); + YZ_UpdateWindow( mainframe ); } -void MainFrame::OnViewShowAxes() -{ - g_qeglobals.d_savedinfo.show_axis ^= 1; - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_showaxes")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), - g_qeglobals.d_savedinfo.show_axis ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows (W_XY); +void XY_UpdateAllWindows(){ + if ( g_pParentWnd != 0 ) { + XY_UpdateAllWindows( *g_pParentWnd ); + } } -void MainFrame::OnViewShowWorkzone() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_showworkzone")); - g_bIgnoreCommands++; - if (g_qeglobals.d_show_work) - { - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_qeglobals.d_show_work = false; - } else - { - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - g_qeglobals.d_show_work = true; - } - g_bIgnoreCommands--; - Sys_UpdateWindows (W_XY); -} - -void MainFrame::OnViewHideshowHideselected() -{ - Select_Hide(); - Select_Deselect(); +void UpdateAllWindows(){ + GlobalCamera_UpdateWindow(); + XY_UpdateAllWindows(); } -void MainFrame::OnViewHideshowShowhidden() -{ - Select_ShowAllHidden(); -} - -/** -sets the view mode for the entities -called upon LoadPrefs too -NOTE TTimo previous implementation had a SavePrefs call - .. I don't think it is relevant, removed (the prefs are saved upon exit) -NOTE TTimo we activate the menu item, this is only needed when we are called upon a prefs load - (otherwise we are always called following user action on the widget) -*/ -void MainFrame::OnEntitiesSetViewAs(int mode) -{ - gpointer item = NULL; - if (mode == 0) - { - switch (g_PrefsDlg.m_nEntityShowState) - { - case ENTITY_BOX: - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_boundingbox"); - break; - case ENTITY_WIRE: - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_wireframe"); - break; - case ENTITY_SELECTED: - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_selectedwireframe"); - break; - case ENTITY_SELECTED_SKIN: - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_selectedskinned"); - break; - case ENTITY_SKINNED: - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_skinned"); - break; - case ENTITY_SKINNED_BOXED: - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_skinnedandboxed"); - break; - } - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - g_bIgnoreCommands--; - return; - } - - switch (mode) - { - case ID_VIEW_ENTITIESAS_BOUNDINGBOX: - g_PrefsDlg.m_nEntityShowState = ENTITY_BOX; - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_boundingbox"); - break; - case ID_VIEW_ENTITIESAS_WIREFRAME: - g_PrefsDlg.m_nEntityShowState = ENTITY_WIRE; - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_wireframe"); - break; - case ID_VIEW_ENTITIESAS_SELECTEDWIREFRAME: - g_PrefsDlg.m_nEntityShowState = ENTITY_SELECTED; - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_selectedwireframe"); - break; - case ID_VIEW_ENTITIESAS_SELECTEDSKINNED: - g_PrefsDlg.m_nEntityShowState = ENTITY_SELECTED_SKIN; - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_selectedskinned"); - break; - case ID_VIEW_ENTITIESAS_SKINNED: - g_PrefsDlg.m_nEntityShowState = ENTITY_SKINNED; - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_skinned"); - break; - case ID_VIEW_ENTITIESAS_SKINNEDANDBOXED: - g_PrefsDlg.m_nEntityShowState = ENTITY_SKINNED_BOXED; - item = g_object_get_data (G_OBJECT (g_pParentWnd->m_pWidget), "menu_view_entitiesas_skinnedandboxed"); - break; - default: - Sys_FPrintf(SYS_ERR, "Entity mode ID_ not found in MainFrame::Entities_SetViewAs\n"); - return; - } - - if (!item) - { - Sys_FPrintf(SYS_ERR, "menu not found in MainFrame::Entities_SetViewAs\n"); - return; - } - - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - g_bIgnoreCommands--; - - Sys_UpdateWindows(W_ALL); -} - -void MainFrame::OnViewCubicclipping() -{ - GtkWidget *w; - g_PrefsDlg.m_bCubicClipping ^= 1; - g_bIgnoreCommands++; - w = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_cubicclipping")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), g_PrefsDlg.m_bCubicClipping ? TRUE : FALSE); - w = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_view_cubicclipping")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), g_PrefsDlg.m_bCubicClipping ? TRUE : FALSE); - g_bIgnoreCommands--; - g_PrefsDlg.SavePrefs (); - //Map_BuildBrushData (); - Sys_UpdateWindows(W_CAMERA); +void ModeChangeNotify(){ + SceneChangeNotify(); } -void MainFrame::OnViewOpengllighting() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_view_opengllighting")); - g_PrefsDlg.m_bGLLighting ^= 1; - g_PrefsDlg.SavePrefs (); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_PrefsDlg.m_bGLLighting ? TRUE : FALSE); - Sys_UpdateWindows (W_XY|W_CAMERA); - g_bIgnoreCommands--; +void ClipperChangeNotify(){ + GlobalCamera_UpdateWindow(); + XY_UpdateAllWindows(); } -void MainFrame::OnSelectionDragedges() -{ - if (g_qeglobals.d_select_mode == sel_edge) - { - g_qeglobals.d_select_mode = sel_brush; - Sys_UpdateWindows (W_ALL); - } else - { - SetupVertexSelection (); - if (g_qeglobals.d_numpoints) - g_qeglobals.d_select_mode = sel_edge; - Sys_UpdateWindows (W_ALL); - } -} - -void MainFrame::OnSelectionDragvertecies() -{ - if (g_qeglobals.d_select_mode == sel_vertex || g_qeglobals.d_select_mode == sel_curvepoint) - { - g_qeglobals.d_select_mode = sel_brush; - Sys_UpdateWindows (W_ALL); - } else - { - //--if (QE_SingleBrush() && selected_brushes.next->patchBrush) - if (OnlyPatchesSelected()) - { - Patch_EditPatch(); - } else //if (!AnyPatchesSelected()) // allows vertex mode when patches are selected - { - SetupVertexSelection (); - if (g_qeglobals.d_numpoints) - g_qeglobals.d_select_mode = sel_vertex; - } - Sys_UpdateWindows (W_ALL); - } -} - -void MainFrame::OnSelectionClone() -{ - Select_Clone(); -} -// called when the escape key is used (either on the main window or on an inspector) -void MainFrame::OnSelectionDeselect() -{ - if (g_bClipMode) - OnViewClipper(); - else - if (g_bRotateMode) - OnSelectMouserotate(); - else - if (g_bScaleMode) - OnSelectMousescale(); - else - if (g_bPathMode) - { - if (ActiveXY()) - ActiveXY()->KillPathMode(); - } else - { - if (g_qeglobals.d_select_mode == sel_curvepoint && g_qeglobals.d_num_move_points > 0) - { - g_qeglobals.d_num_move_points = 0; - Sys_UpdateWindows(W_ALL); - } else - { - Select_Deselect (); - SetStatusText(2, " "); - } - } -} - -void MainFrame::OnBrushFlipx() -{ - Undo_Start("flip X"); - Undo_AddBrushList(&selected_brushes); - - Select_FlipAxis (0); - // spog - this does not work - it's a rotate not a flip - /* - for (brush_t *b=selected_brushes.next ; b != &selected_brushes ; b=b->next) - { - if(b->owner->eclass->fixedsize) - { - char buf[16]; - float a = FloatForKey(b->owner, "angle"); - a = div ((int)(180 - a), 180).rem; - sprintf (buf, "%d", (int)a); - SetKeyValue(b->owner, "angle", buf); - Brush_Build(b,true,true,false,false); // don't filter - } - } - */ - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} - -void MainFrame::OnBrushFlipy() -{ - Undo_Start("flip Y"); - Undo_AddBrushList(&selected_brushes); - - Select_FlipAxis (1); - // spog - this does not work - it's a rotate not a flip - /* - for (brush_t *b=selected_brushes.next ; b != &selected_brushes ; b=b->next) - { - if(b->owner->eclass->fixedsize) - { - float a = FloatForKey(b->owner, "angle"); - if (a == 0 || a == 180 || a == 360) - continue; - if ( a == 90 || a == 270) - { - a += 180; - } - else if (a > 270) - a += 90; - else if (a > 180) - a -= 90; - else if (a > 90) - a += 90; - else - a -= 90; - a = (int)a % 360; - char buf[16]; - sprintf (buf, "%d", (int)a); - SetKeyValue(b->owner, "angle", buf); - Brush_Build(b,true,true,false,false); // don't filter - } - - } - */ - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} - -void MainFrame::OnBrushFlipz() -{ - Undo_Start("flip Z"); - Undo_AddBrushList(&selected_brushes); - Select_FlipAxis (2); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +LatchedInt g_Layout_viewStyle( 0, "Window Layout" ); +LatchedBool g_Layout_enableDetachableMenus( true, "Detachable Menus" ); +LatchedBool g_Layout_enablePatchToolbar( true, "Patch Toolbar" ); +LatchedBool g_Layout_enablePluginToolbar( true, "Plugin Toolbar" ); -void MainFrame::OnBrushRotatex() -{ - Undo_Start("rotate X"); - Undo_AddBrushList(&selected_brushes); - Select_RotateAxis (0, 90); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} -void MainFrame::OnBrushRotatey() -{ - Undo_Start("rotate Y"); - Undo_AddBrushList(&selected_brushes); - Select_RotateAxis (1, 90); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} -void MainFrame::OnBrushRotatez() -{ - Undo_Start("rotate Z"); - Undo_AddBrushList(&selected_brushes); - Select_RotateAxis (2, 90); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +GtkMenuItem* create_file_menu(){ + // File menu + GtkMenuItem* file_menu_item = new_sub_menu_item_with_mnemonic( "_File" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( file_menu_item ) )); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu ); + } -void MainFrame::OnSelectionArbitraryrotation() -{ - Undo_Start("arbitrary rotation"); - Undo_AddBrushList(&selected_brushes); + create_menu_item_with_mnemonic( menu, "_New Map", "NewMap" ); + menu_separator( menu ); - DoRotateDlg (); +#if 0 + //++timo temporary experimental stuff for sleep mode.. + create_menu_item_with_mnemonic( menu, "_Sleep", "Sleep" ); + menu_separator( menu ); + // end experimental +#endif - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + create_menu_item_with_mnemonic( menu, "_Open...", "OpenMap" ); + + create_menu_item_with_mnemonic( menu, "_Import...", "ImportMap" ); + create_menu_item_with_mnemonic( menu, "_Save", "SaveMap" ); + create_menu_item_with_mnemonic( menu, "Save _as...", "SaveMapAs" ); + create_menu_item_with_mnemonic( menu, "_Export selected...", "ExportSelected" ); + menu_separator( menu ); + create_menu_item_with_mnemonic( menu, "Save re_gion...", "SaveRegion" ); + menu_separator( menu ); + create_menu_item_with_mnemonic( menu, "_Refresh models", "RefreshReferences" ); + menu_separator( menu ); + create_menu_item_with_mnemonic( menu, "Pro_ject settings...", "ProjectSettings" ); + menu_separator( menu ); + create_menu_item_with_mnemonic( menu, "_Pointfile...", "TogglePointfile" ); + menu_separator( menu ); + MRU_constructMenu( menu ); + menu_separator( menu ); + create_menu_item_with_mnemonic( menu, "E_xit", "Exit" ); + + return file_menu_item; +} + +GtkMenuItem* create_edit_menu(){ + // Edit menu + GtkMenuItem* edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( edit_menu_item ) )); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu ); + } + create_menu_item_with_mnemonic( menu, "_Undo", "Undo" ); + create_menu_item_with_mnemonic( menu, "_Redo", "Redo" ); + menu_separator( menu ); + create_menu_item_with_mnemonic( menu, "_Copy", "Copy" ); + create_menu_item_with_mnemonic( menu, "_Paste", "Paste" ); + create_menu_item_with_mnemonic( menu, "P_aste To Camera", "PasteToCamera" ); + menu_separator( menu ); + create_menu_item_with_mnemonic( menu, "_Duplicate", "CloneSelection" ); + create_menu_item_with_mnemonic( menu, "Duplicate, make uni_que", "CloneSelectionAndMakeUnique" ); + create_menu_item_with_mnemonic( menu, "D_elete", "DeleteSelection" ); + menu_separator( menu ); + create_menu_item_with_mnemonic( menu, "Pa_rent", "ParentSelection" ); + menu_separator( menu ); + create_menu_item_with_mnemonic( menu, "C_lear Selection", "UnSelectSelection" ); + create_menu_item_with_mnemonic( menu, "_Invert Selection", "InvertSelection" ); + create_menu_item_with_mnemonic( menu, "Select i_nside", "SelectInside" ); + create_menu_item_with_mnemonic( menu, "Select _touching", "SelectTouching" ); + + auto convert_menu = create_sub_menu_with_mnemonic( menu, "E_xpand Selection" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( convert_menu ); + } + create_menu_item_with_mnemonic( convert_menu, "To Whole _Entities", "ExpandSelectionToEntities" ); + + menu_separator( menu ); + create_menu_item_with_mnemonic( menu, "Pre_ferences...", "Preferences" ); + + return edit_menu_item; +} + +void fill_view_xy_top_menu( ui::Menu menu ){ + create_check_menu_item_with_mnemonic( menu, "XY (Top) View", "ToggleView" ); +} + + +void fill_view_yz_side_menu( ui::Menu menu ){ + create_check_menu_item_with_mnemonic( menu, "YZ (Side) View", "ToggleSideView" ); +} + + +void fill_view_xz_front_menu( ui::Menu menu ){ + create_check_menu_item_with_mnemonic( menu, "XZ (Front) View", "ToggleFrontView" ); +} + + +ui::Widget g_toggle_z_item; +ui::Widget g_toggle_console_item; +ui::Widget g_toggle_entity_item; +ui::Widget g_toggle_entitylist_item; + +GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ + // View menu + GtkMenuItem* view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( view_menu_item ) )); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu ); + } + + if ( style == MainFrame::eFloating ) { + fill_view_camera_menu( menu ); + fill_view_xy_top_menu( menu ); + fill_view_yz_side_menu( menu ); + fill_view_xz_front_menu( menu ); + } + if ( style == MainFrame::eFloating || style == MainFrame::eSplit ) { + create_menu_item_with_mnemonic( menu, "Console View", "ToggleConsole" ); + create_menu_item_with_mnemonic( menu, "Texture Browser", "ToggleTextures" ); + create_menu_item_with_mnemonic( menu, "Entity Inspector", "ToggleEntityInspector" ); + } + else + { + create_menu_item_with_mnemonic( menu, "Entity Inspector", "ViewEntityInfo" ); + } + create_menu_item_with_mnemonic( menu, "_Surface Inspector", "SurfaceInspector" ); + create_menu_item_with_mnemonic( menu, "Entity List", "EntityList" ); + + menu_separator( menu ); + { + auto camera_menu = create_sub_menu_with_mnemonic( menu, "Camera" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( camera_menu ); + } + create_menu_item_with_mnemonic( camera_menu, "_Center", "CenterView" ); + create_menu_item_with_mnemonic( camera_menu, "_Up Floor", "UpFloor" ); + create_menu_item_with_mnemonic( camera_menu, "_Down Floor", "DownFloor" ); + menu_separator( camera_menu ); + create_menu_item_with_mnemonic( camera_menu, "Far Clip Plane In", "CubicClipZoomIn" ); + create_menu_item_with_mnemonic( camera_menu, "Far Clip Plane Out", "CubicClipZoomOut" ); + menu_separator( camera_menu ); + create_menu_item_with_mnemonic( camera_menu, "Next leak spot", "NextLeakSpot" ); + create_menu_item_with_mnemonic( camera_menu, "Previous leak spot", "PrevLeakSpot" ); + menu_separator( camera_menu ); + create_menu_item_with_mnemonic( camera_menu, "Look Through Selected", "LookThroughSelected" ); + create_menu_item_with_mnemonic( camera_menu, "Look Through Camera", "LookThroughCamera" ); + } + menu_separator( menu ); + { + auto orthographic_menu = create_sub_menu_with_mnemonic( menu, "Orthographic" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( orthographic_menu ); + } + if ( style == MainFrame::eRegular || style == MainFrame::eRegularLeft || style == MainFrame::eFloating ) { + create_menu_item_with_mnemonic( orthographic_menu, "_Next (XY, YZ, XY)", "NextView" ); + create_menu_item_with_mnemonic( orthographic_menu, "XY (Top)", "ViewTop" ); + create_menu_item_with_mnemonic( orthographic_menu, "YZ", "ViewSide" ); + create_menu_item_with_mnemonic( orthographic_menu, "XZ", "ViewFront" ); + menu_separator( orthographic_menu ); + } + + create_menu_item_with_mnemonic( orthographic_menu, "_XY 100%", "Zoom100" ); + create_menu_item_with_mnemonic( orthographic_menu, "XY Zoom _In", "ZoomIn" ); + create_menu_item_with_mnemonic( orthographic_menu, "XY Zoom _Out", "ZoomOut" ); + } + + menu_separator( menu ); + + { + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Show" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu_in_menu ); + } + create_check_menu_item_with_mnemonic( menu_in_menu, "Show _Angles", "ShowAngles" ); + create_check_menu_item_with_mnemonic( menu_in_menu, "Show _Names", "ShowNames" ); + create_check_menu_item_with_mnemonic( menu_in_menu, "Show Blocks", "ShowBlocks" ); + create_check_menu_item_with_mnemonic( menu_in_menu, "Show C_oordinates", "ShowCoordinates" ); + create_check_menu_item_with_mnemonic( menu_in_menu, "Show Window Outline", "ShowWindowOutline" ); + create_check_menu_item_with_mnemonic( menu_in_menu, "Show Axes", "ShowAxes" ); + create_check_menu_item_with_mnemonic( menu_in_menu, "Show Workzone", "ShowWorkzone" ); + create_check_menu_item_with_mnemonic( menu_in_menu, "Show Stats", "ShowStats" ); + } + + { + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Filter" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu_in_menu ); + } + Filters_constructMenu( menu_in_menu ); + } + menu_separator( menu ); + { + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Hide/Show" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu_in_menu ); + } + create_menu_item_with_mnemonic( menu_in_menu, "Hide Selected", "HideSelected" ); + create_menu_item_with_mnemonic( menu_in_menu, "Show Hidden", "ShowHidden" ); + } + menu_separator( menu ); + { + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Region" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu_in_menu ); + } + create_menu_item_with_mnemonic( menu_in_menu, "_Off", "RegionOff" ); + create_menu_item_with_mnemonic( menu_in_menu, "_Set XY", "RegionSetXY" ); + create_menu_item_with_mnemonic( menu_in_menu, "Set _Brush", "RegionSetBrush" ); + create_menu_item_with_mnemonic( menu_in_menu, "Set Se_lected Brushes", "RegionSetSelection" ); + } + + command_connect_accelerator( "CenterXYView" ); + + return view_menu_item; +} + +GtkMenuItem* create_selection_menu(){ + // Selection menu + GtkMenuItem* selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( selection_menu_item ) )); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu ); + } + + { + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Components" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu_in_menu ); + } + create_check_menu_item_with_mnemonic( menu_in_menu, "_Edges", "DragEdges" ); + create_check_menu_item_with_mnemonic( menu_in_menu, "_Vertices", "DragVertices" ); + create_check_menu_item_with_mnemonic( menu_in_menu, "_Faces", "DragFaces" ); + } + + menu_separator( menu ); + + { + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Nudge" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu_in_menu ); + } + create_menu_item_with_mnemonic( menu_in_menu, "Nudge Left", "SelectNudgeLeft" ); + create_menu_item_with_mnemonic( menu_in_menu, "Nudge Right", "SelectNudgeRight" ); + create_menu_item_with_mnemonic( menu_in_menu, "Nudge Up", "SelectNudgeUp" ); + create_menu_item_with_mnemonic( menu_in_menu, "Nudge Down", "SelectNudgeDown" ); + } + { + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Rotate" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu_in_menu ); + } + create_menu_item_with_mnemonic( menu_in_menu, "Rotate X", "RotateSelectionX" ); + create_menu_item_with_mnemonic( menu_in_menu, "Rotate Y", "RotateSelectionY" ); + create_menu_item_with_mnemonic( menu_in_menu, "Rotate Z", "RotateSelectionZ" ); + } + { + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Flip" ); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu_in_menu ); + } + create_menu_item_with_mnemonic( menu_in_menu, "Flip _X", "MirrorSelectionX" ); + create_menu_item_with_mnemonic( menu_in_menu, "Flip _Y", "MirrorSelectionY" ); + create_menu_item_with_mnemonic( menu_in_menu, "Flip _Z", "MirrorSelectionZ" ); + } + menu_separator( menu ); + create_menu_item_with_mnemonic( menu, "Arbitrary rotation...", "ArbitraryRotation" ); + create_menu_item_with_mnemonic( menu, "Arbitrary scale...", "ArbitraryScale" ); + + return selection_menu_item; +} + +GtkMenuItem* create_bsp_menu(){ + // BSP menu + GtkMenuItem* bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( bsp_menu_item ) )); + + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu ); + } + + create_menu_item_with_mnemonic( menu, "Customize...", "BuildMenuCustomize" ); + + menu_separator( menu ); + + Build_constructMenu( menu ); + + g_bsp_menu = menu; + + return bsp_menu_item; +} + +GtkMenuItem* create_grid_menu(){ + // Grid menu + GtkMenuItem* grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( grid_menu_item ) )); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu ); + } + + Grid_constructMenu( menu ); + + return grid_menu_item; +} + +GtkMenuItem* create_misc_menu(){ + // Misc menu + GtkMenuItem* misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( misc_menu_item ) )); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu ); + } -void MainFrame::OnSelectScale() -{ - Undo_Start("scale"); - Undo_AddBrushList(&selected_brushes); - DoScaleDlg (); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +#if 0 + create_menu_item_with_mnemonic( menu, "_Benchmark", FreeCaller() ); +#endif + gtk_container_add( GTK_CONTAINER( menu ), GTK_WIDGET( create_colours_menu() ) ); -void MainFrame::OnSelectionMakehollow() -{ - //if (ActiveXY()) - // ActiveXY()->UndoCopy(); - Undo_Start("hollow"); - Undo_AddBrushList(&selected_brushes); - CSG_MakeHollow (); - Undo_EndBrushList(&selected_brushes); - Undo_End(); + create_menu_item_with_mnemonic( menu, "Find brush...", "FindBrush" ); + create_menu_item_with_mnemonic( menu, "Map Info...", "MapInfo" ); + // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394 +// create_menu_item_with_mnemonic(menu, "_Print XY View", FreeCaller()); + create_menu_item_with_mnemonic( menu, "_Background select", FreeCaller() ); + return misc_menu_item; } -void MainFrame::OnSelectionCsgsubtract() -{ - Undo_Start("CSG subtract"); - CSG_Subtract(); - Undo_End(); -} +GtkMenuItem* create_entity_menu(){ + // Brush menu + GtkMenuItem* entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( entity_menu_item ) )); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu ); + } -void MainFrame::OnSelectionCsgmerge() -{ - Undo_Start("CSG merge"); - Undo_AddBrushList(&selected_brushes); - CSG_Merge(); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + Entity_constructMenu( menu ); -void MainFrame::OnSelectionNoOutline() -{ - //g_qeglobals.d_savedinfo.bNoSelectedOutlines ^= 1; - g_qeglobals.d_savedinfo.iSelectedOutlinesStyle = (g_qeglobals.d_savedinfo.iSelectedOutlinesStyle & OUTLINE_ZBUF) ^ OUTLINE_ZBUF; - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_selection_nooutline")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), (g_qeglobals.d_savedinfo.iSelectedOutlinesStyle & OUTLINE_ZBUF)); - g_bIgnoreCommands--; - Sys_UpdateWindows (W_CAMERA); + return entity_menu_item; } -void MainFrame::OnSelectionOutlineStyle() -{ - if ((g_qeglobals.d_savedinfo.iSelectedOutlinesStyle & OUTLINE_ZBUF) && (g_qeglobals.d_savedinfo.iSelectedOutlinesStyle & OUTLINE_BSEL)) - g_qeglobals.d_savedinfo.iSelectedOutlinesStyle &= ~OUTLINE_ZBUF; - else if (g_qeglobals.d_savedinfo.iSelectedOutlinesStyle & OUTLINE_BSEL) - g_qeglobals.d_savedinfo.iSelectedOutlinesStyle &= ~OUTLINE_BSEL; - else if (g_qeglobals.d_savedinfo.iSelectedOutlinesStyle & OUTLINE_ZBUF) - g_qeglobals.d_savedinfo.iSelectedOutlinesStyle |= OUTLINE_BSEL; - else - g_qeglobals.d_savedinfo.iSelectedOutlinesStyle |= OUTLINE_ZBUF; - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_selection_nooutline")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), (g_qeglobals.d_savedinfo.iSelectedOutlinesStyle & OUTLINE_ZBUF)); - g_bIgnoreCommands--; - Sys_UpdateWindows (W_CAMERA); -} - -void MainFrame::OnSelectionSelectcompletetall() -{ - if (ActiveXY()) - ActiveXY()->UndoCopy(); - Select_CompleteTall (); -} +GtkMenuItem* create_brush_menu(){ + // Brush menu + GtkMenuItem* brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( brush_menu_item ) )); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu ); + } -void MainFrame::OnSelectionSelecttouching() -{ - Select_Touching(); -} + Brush_constructMenu( menu ); -void MainFrame::OnSelectionSelectpartialtall() -{ - Select_PartialTall(); + return brush_menu_item; } -void MainFrame::OnSelectionSelectinside() -{ - Select_Inside (); -} +GtkMenuItem* create_patch_menu(){ + // Curve menu + GtkMenuItem* patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( patch_menu_item ) )); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu ); + } -void MainFrame::OnViewClipper() -{ - GtkWidget *w = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_view_clipper")); - g_bIgnoreCommands++; - - if (ActiveXY()) - { - if (ActiveXY()->ClipMode()) - { - ActiveXY()->SetClipMode(false); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), FALSE); - } else - { - if (ActiveXY()->RotateMode()) - OnSelectMouserotate(); - ActiveXY()->SetClipMode(true); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE); - } - } - g_bIgnoreCommands--; -} - -void MainFrame::OnClipSelected() -{ - if (m_pActiveXY && m_pActiveXY->ClipMode()) - { - Undo_Start("clip selected"); - Undo_AddBrushList(&selected_brushes); - m_pActiveXY->Clip(); - Undo_EndBrushList(&selected_brushes); - Undo_End(); - } else - { - if (g_bPatchBendMode) - Patch_BendHandleENTER(); -// else if (g_bPatchBendMode) -// Patch_InsDelHandleENTER(); - } -} - -void MainFrame::OnSplitSelected() -{ - if (m_pActiveXY) - { - Undo_Start("split selected"); - Undo_AddBrushList(&selected_brushes); - m_pActiveXY->SplitClip(); - Undo_EndBrushList(&selected_brushes); - Undo_End(); - } -} + Patch_constructMenu( menu ); -void MainFrame::OnFlipClip() -{ - if (m_pActiveXY) - m_pActiveXY->FlipClip(); + return patch_menu_item; } -void MainFrame::OnSelectionConnect() -{ - Undo_Start("connect selected entities"); - Undo_AddBrushList(&selected_brushes); - ConnectEntities(); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +GtkMenuItem* create_help_menu(){ + // Help menu + GtkMenuItem* help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" ); + auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( help_menu_item ) )); + if ( g_Layout_enableDetachableMenus.m_value ) { + menu_tearoff( menu ); + } -void MainFrame::OnSelectionUngroupentity() -{ - Undo_Start("ungroup selected entities"); - Undo_AddBrushList(&selected_brushes); - Select_Ungroup(); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + create_menu_item_with_mnemonic( menu, "Manual", "OpenManual" ); -void MainFrame::OnSelectionMergeentity() -{ - Undo_Start("merge entity"); - Undo_AddBrushList(&selected_brushes); - Select_MergeEntity(); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + // this creates all the per-game drop downs for the game pack helps + // it will take care of hooking the Sys_OpenURL calls etc. + create_game_help_menu( menu ); -void MainFrame::OnSelectionGroupworld() -{ - Undo_Start("group world"); - Undo_AddBrushList(&selected_brushes); - Select_GroupEntity(world_entity); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + create_menu_item_with_mnemonic( menu, "Bug report", FreeCaller() ); + create_menu_item_with_mnemonic( menu, "Shortcuts list", FreeCaller() ); + create_menu_item_with_mnemonic( menu, "_About", FreeCaller() ); -void MainFrame::OnSelectionMakeDetail() -{ - Undo_Start("make detail"); - Undo_AddBrushList(&selected_brushes); - Select_MakeDetail (); - Undo_EndBrushList(&selected_brushes); - Undo_End(); + return help_menu_item; } -void MainFrame::OnSelectionMakeStructural() -{ - Undo_Start("make structural"); - Undo_AddBrushList(&selected_brushes); - Select_MakeStructural (); - Undo_EndBrushList(&selected_brushes); - Undo_End(); +GtkMenuBar* create_main_menu( MainFrame::EViewStyle style ){ + GtkMenuBar* menu_bar = GTK_MENU_BAR( gtk_menu_bar_new() ); + gtk_widget_show( GTK_WIDGET( menu_bar ) ); + + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_file_menu() ) ); + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_edit_menu() ) ); + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_view_menu( style ) ) ); + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_selection_menu() ) ); + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_bsp_menu() ) ); + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_grid_menu() ) ); + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_misc_menu() ) ); + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_entity_menu() ) ); + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_brush_menu() ) ); + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_patch_menu() ) ); + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_plugins_menu() ) ); + gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_help_menu() ) ); + + return menu_bar; } -void MainFrame::OnBspCommand (unsigned int nID) -{ - // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=503 - // make sure we don't attempt to region compile a map with the camera outside the region - if (region_active) - { - vec3_t vOrig; - VectorSet(vOrig, - (int)g_pParentWnd->GetCamWnd()->Camera()->origin[0], - (int)g_pParentWnd->GetCamWnd()->Camera()->origin[1], - (int)g_pParentWnd->GetCamWnd()->Camera()->origin[2]); - - int i; - for (i=0 ; i<3 ; i++) - { - if (vOrig[i] > region_maxs[i] || vOrig[i] < region_mins[i]) - { - Sys_FPrintf(SYS_ERR, "The camera must be in the region to start a region compile.\n"); - return; - } - } - } - - // if the map has not been saved yet we need to handle it now before we start processing the BSP commands - if (stricmp( currentmap, "unnamed.map") == 0) - { - OnFileSaveas(); - } - - if (g_PrefsDlg.m_bSnapShots && (stricmp (currentmap, "unnamed.map") != 0)) - Map_Snapshot(); - - if (g_qeglobals.bBSPFrontendPlugin) - { - char *cmd = (char*)g_slist_nth_data (g_BSPFrontendCommands, nID-CMD_BSPCOMMAND); - g_BSPFrontendTable.m_pfnDispatchBSPCommand (cmd); - } else - { - RunBsp (bsp_commands[nID-CMD_BSPCOMMAND]); - } -} - -void MainFrame::OnGrid (unsigned int nID) -{ - if (nID == ID_GRID_025) - { - g_qeglobals.d_gridsize = 0.25f; - g_qeglobals.d_bSmallGrid = true; - } else if (nID == ID_GRID_05) - { - g_qeglobals.d_gridsize = 0.5f; - g_qeglobals.d_bSmallGrid = true; - } else - { - switch (nID) - { - case ID_GRID_1: g_qeglobals.d_gridsize = 0; break; - case ID_GRID_2: g_qeglobals.d_gridsize = 1; break; - case ID_GRID_4: g_qeglobals.d_gridsize = 2; break; - case ID_GRID_8: g_qeglobals.d_gridsize = 3; break; - case ID_GRID_16: g_qeglobals.d_gridsize = 4; break; - case ID_GRID_32: g_qeglobals.d_gridsize = 5; break; - case ID_GRID_64: g_qeglobals.d_gridsize = 6; break; - case ID_GRID_128: g_qeglobals.d_gridsize = 7; break; - case ID_GRID_256: g_qeglobals.d_gridsize = 8; break; - } - g_qeglobals.d_gridsize = 1 << (int)g_qeglobals.d_gridsize; - g_qeglobals.d_bSmallGrid = false; - } - - SetGridStatus(); - - // SnapTToGrid option: need to check everywhere the grid size is changed - // this is a bit clumsy, have to do in OnGrid OnGridPrev and OnGridNext - if (g_PrefsDlg.m_bSnapTToGrid) - DoSnapTToGrid(); - - Sys_UpdateWindows (W_XY|W_Z); -} - -void MainFrame::OnSnaptogrid() -{ - g_PrefsDlg.m_bNoClamp ^= 1; - g_PrefsDlg.SavePrefs (); - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_snaptogrid")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_PrefsDlg.m_bNoClamp ? FALSE : TRUE); - g_bIgnoreCommands--; +void PatchInspector_registerShortcuts(){ + command_connect_accelerator( "PatchInspector" ); } -void MainFrame::OnTexturesShowinuse() -{ - Sys_BeginWait (); - Texture_ShowInuse (); -#ifdef _DEBUG - if (!g_bShowAllShaders) - Sys_Printf("Already showing only in-use textures.\n"); -#endif - Sys_UpdateWindows( W_TEXTURE ); - Sys_EndWait (); +void Patch_registerShortcuts(){ + command_connect_accelerator( "InvertCurveTextureX" ); + command_connect_accelerator( "InvertCurveTextureY" ); + command_connect_accelerator( "PatchInsertInsertColumn" ); + command_connect_accelerator( "PatchInsertInsertRow" ); + command_connect_accelerator( "PatchDeleteLastColumn" ); + command_connect_accelerator( "PatchDeleteLastRow" ); + command_connect_accelerator( "NaturalizePatch" ); + //command_connect_accelerator("CapCurrentCurve"); } -void MainFrame::OnTexturesShowall() -{ - Texture_ShowAll(); +void Manipulators_registerShortcuts(){ + toggle_add_accelerator( "MouseRotate" ); + toggle_add_accelerator( "MouseTranslate" ); + toggle_add_accelerator( "MouseScale" ); + toggle_add_accelerator( "MouseDrag" ); + toggle_add_accelerator( "ToggleClipper" ); } -// do some triggering on/off, if the inspector is already up then hide it -void MainFrame::OnTexturesInspector() -{ - ToggleSurface(); +void TexdefNudge_registerShortcuts(){ + command_connect_accelerator( "TexRotateClock" ); + command_connect_accelerator( "TexRotateCounter" ); + command_connect_accelerator( "TexScaleUp" ); + command_connect_accelerator( "TexScaleDown" ); + command_connect_accelerator( "TexScaleLeft" ); + command_connect_accelerator( "TexScaleRight" ); + command_connect_accelerator( "TexShiftUp" ); + command_connect_accelerator( "TexShiftDown" ); + command_connect_accelerator( "TexShiftLeft" ); + command_connect_accelerator( "TexShiftRight" ); } -void MainFrame::OnViewNearest(unsigned int nID) -{ - Texture_SetMode(nID); +void SelectNudge_registerShortcuts(){ + command_connect_accelerator( "MoveSelectionDOWN" ); + command_connect_accelerator( "MoveSelectionUP" ); + //command_connect_accelerator("SelectNudgeLeft"); + //command_connect_accelerator("SelectNudgeRight"); + //command_connect_accelerator("SelectNudgeUp"); + //command_connect_accelerator("SelectNudgeDown"); } -void MainFrame::OnTextureReplaceall() -{ - FindTextureDialog::show(); +void SnapToGrid_registerShortcuts(){ + command_connect_accelerator( "SnapToGrid" ); } -void MainFrame::OnToggleLock() -{ - g_PrefsDlg.m_bTextureLock = !g_PrefsDlg.m_bTextureLock; +void SelectByType_registerShortcuts(){ + command_connect_accelerator( "SelectAllOfType" ); +} - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_toggle_lock")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_PrefsDlg.m_bTextureLock ? TRUE : FALSE); - g_bIgnoreCommands--; - g_PrefsDlg.SavePrefs (); - SetGridStatus(); +void SurfaceInspector_registerShortcuts(){ + command_connect_accelerator( "FitTexture" ); } -void MainFrame::OnToggleRotatelock() -{ - g_PrefsDlg.m_bRotateLock ^= 1; - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_toggle_rotatelock")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_PrefsDlg.m_bRotateLock ? TRUE : FALSE); - g_bIgnoreCommands--; - g_PrefsDlg.SavePrefs (); - SetGridStatus(); +void register_shortcuts(){ + PatchInspector_registerShortcuts(); + Patch_registerShortcuts(); + Grid_registerShortcuts(); + XYWnd_registerShortcuts(); + CamWnd_registerShortcuts(); + Manipulators_registerShortcuts(); + SurfaceInspector_registerShortcuts(); + TexdefNudge_registerShortcuts(); + SelectNudge_registerShortcuts(); + SnapToGrid_registerShortcuts(); + SelectByType_registerShortcuts(); } -// use a dialog for direct selection of a texture menu -// the API is a bit crappy, we need to set texture_directory to the directory name in /textures/ -void MainFrame::OnTexturesLoad() -{ - char def_path[NAME_MAX]; - - // FIXME - // check if that works with fs_game (I suspect some more design is needed) - // see how this is done in 1.2? - // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=507 - strcpy (def_path, g_pGameDescription->mEnginePath.GetBuffer()); - strcat (def_path, g_pGameDescription->mBaseGame.GetBuffer()); - strcat (def_path, "/"); - - char *dir = dir_dialog (m_pWidget, _("Load textures from path"), def_path); - - if (dir != NULL) - { - // very uncertain task, let's hope the guy pointed to somewhere below the dir we gave him - Sys_Printf("user select: '%s'\n", dir); - // remove a potential trailing slash? - if (dir[strlen(dir)-1]=='/' || dir[strlen(dir)-1]=='\\') - dir[strlen(dir)-1] = '\0'; - char *pouic = MAX(strrchr(dir, '/'),strrchr(dir, '\\')); - if (pouic) - { - strcpy(texture_directory, pouic+1); - Sys_Printf("Loading '%s'\n", texture_directory); - Texture_ShowDirectory(); - } - else - Sys_FPrintf(SYS_WRN, "Failed to extract the directory\n"); - g_free(dir); - } - else - Sys_FPrintf(SYS_WRN, "texture load dialog cancelled\n"); -} - -void MainFrame::OnTexturesReloadshaders() -{ - Sys_BeginWait (); - QERApp_ReloadShaders(); - // current shader - // NOTE: we are kinda making it loop on itself, it will update the pShader and scroll the texture window - Texture_SetTexture (&g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, false, NULL, false); - Sys_UpdateWindows (W_ALL); - Sys_EndWait(); +void File_constructToolbar( ui::Toolbar toolbar ){ + toolbar_append_button( toolbar, "Open an existing map (CTRL + O)", "file_open.png", "OpenMap" ); + toolbar_append_button( toolbar, "Save the active map (CTRL + S)", "file_save.png", "SaveMap" ); } -void MainFrame::OnTexturesShadersShow() -{ - g_PrefsDlg.m_bShowShaders ^= 1; - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_textures_shaders_show")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_PrefsDlg.m_bShowShaders ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows(W_TEXTURE); +void UndoRedo_constructToolbar( ui::Toolbar toolbar ){ + toolbar_append_button( toolbar, "Undo (CTRL + Z)", "undo.png", "Undo" ); + toolbar_append_button( toolbar, "Redo (CTRL + Y)", "redo.png", "Redo" ); } -void MainFrame::SetTextureScale(int id) -{ - GtkWidget *item; - - switch (id) - { - case ID_TEXTURES_TEXTUREWINDOWSCALE_10: - g_PrefsDlg.m_nTextureScale = 10; - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_textures_texturewindowscale_10")); - break; - case ID_TEXTURES_TEXTUREWINDOWSCALE_25: - g_PrefsDlg.m_nTextureScale = 25; - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_textures_texturewindowscale_25")); - break; - case ID_TEXTURES_TEXTUREWINDOWSCALE_50: - g_PrefsDlg.m_nTextureScale = 50; - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_textures_texturewindowscale_50")); - break; - case ID_TEXTURES_TEXTUREWINDOWSCALE_200: - g_PrefsDlg.m_nTextureScale = 200; - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_textures_texturewindowscale_200")); - break; - default: - g_PrefsDlg.m_nTextureScale = 100; - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_textures_texturewindowscale_100")); - break; - } - - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - g_bIgnoreCommands--; - - Texture_ResetPosition(); -} - -void MainFrame::OnTexturewindowScaleup() -{ - switch(g_PrefsDlg.m_nTextureScale) { - // 200, all the way in, don't do anything - case 100: - SetTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_200); - break; - case 50: - SetTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_100); - break; - case 25: - SetTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_50); - break; - case 10: - SetTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_25); - break; - } -} - -void MainFrame::OnTexturewindowScaledown() -{ - switch(g_PrefsDlg.m_nTextureScale) { - case 200: - SetTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_100); - break; - case 100: - SetTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_50); - break; - case 50: - SetTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_25); - break; - case 25: - SetTextureScale(ID_TEXTURES_TEXTUREWINDOWSCALE_10); - break; - // 10, all the way out, don't do anything - } -} - -void MainFrame::OnTexturesLoadlist() -{ - DoTextureListDlg (); +void RotateFlip_constructToolbar( ui::Toolbar toolbar ){ + toolbar_append_button( toolbar, "x-axis Flip", "brush_flipx.png", "MirrorSelectionX" ); + toolbar_append_button( toolbar, "x-axis Rotate", "brush_rotatex.png", "RotateSelectionX" ); + toolbar_append_button( toolbar, "y-axis Flip", "brush_flipy.png", "MirrorSelectionY" ); + toolbar_append_button( toolbar, "y-axis Rotate", "brush_rotatey.png", "RotateSelectionY" ); + toolbar_append_button( toolbar, "z-axis Flip", "brush_flipz.png", "MirrorSelectionZ" ); + toolbar_append_button( toolbar, "z-axis Rotate", "brush_rotatez.png", "RotateSelectionZ" ); } -void MainFrame::OnTexturesShaderlistonly() -{ - g_PrefsDlg.m_bTexturesShaderlistOnly ^= 1; - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget),"menu_textures_shaderlistonly")); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), g_PrefsDlg.m_bTexturesShaderlistOnly ? TRUE : FALSE); - g_bIgnoreCommands--; - FillTextureMenu(); +void Select_constructToolbar( ui::Toolbar toolbar ){ + toolbar_append_button( toolbar, "Select touching", "selection_selecttouching.png", "SelectTouching" ); + toolbar_append_button( toolbar, "Select inside", "selection_selectinside.png", "SelectInside" ); } -void MainFrame::OnTextureWad(unsigned int nID) -{ - Sys_BeginWait (); - Texture_ShowDirectory (nID); - Sys_UpdateWindows (W_ALL); - Sys_EndWait (); +void CSG_constructToolbar( ui::Toolbar toolbar ){ + toolbar_append_button( toolbar, "CSG Subtract (SHIFT + U)", "selection_csgsubtract.png", "CSGSubtract" ); + toolbar_append_button( toolbar, "CSG Merge (CTRL + U)", "selection_csgmerge.png", "CSGMerge" ); + toolbar_append_button( toolbar, "Hollow", "selection_makehollow.png", "CSGHollow" ); } -void MainFrame::OnMiscBenchmark() -{ - m_pCamWnd->BenchMark(); +void ComponentModes_constructToolbar( ui::Toolbar toolbar ){ + toolbar_append_toggle_button( toolbar, "Select Vertices (V)", "modify_vertices.png", "DragVertices" ); + toolbar_append_toggle_button( toolbar, "Select Edges (E)", "modify_edges.png", "DragEdges" ); + toolbar_append_toggle_button( toolbar, "Select Faces (F)", "modify_faces.png", "DragFaces" ); } -void MainFrame::OnColorSetoriginal() -{ - for (int i=0 ; i<3 ; i++) - { - g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.75f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.5f; - g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25f; - } - - //djbob - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR_ALT][0] = 0.5f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR_ALT][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR_ALT][2] = 0.0f; - - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR_ALT][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR_ALT][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR_ALT][2] = 0.0f; - //-djbob - - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0f; +void Clipper_constructToolbar( ui::Toolbar toolbar ){ - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0f; - - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0f; - - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0f; - - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0f; + toolbar_append_toggle_button( toolbar, "Clipper (X)", "view_clipper.png", "ToggleClipper" ); +} - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5f; - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75f; +void XYWnd_constructToolbar( ui::Toolbar toolbar ){ + toolbar_append_button( toolbar, "Change views", "view_change.png", "NextView" ); +} - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][2] = 0.0f; +void Manipulators_constructToolbar( ui::Toolbar toolbar ){ + toolbar_append_toggle_button( toolbar, "Translate (W)", "select_mousetranslate.png", "MouseTranslate" ); + toolbar_append_toggle_button( toolbar, "Rotate (R)", "select_mouserotate.png", "MouseRotate" ); + toolbar_append_toggle_button( toolbar, "Scale", "select_mousescale.png", "MouseScale" ); + toolbar_append_toggle_button( toolbar, "Resize (Q)", "select_mouseresize.png", "MouseDrag" ); - Sys_UpdateWindows (W_ALL); + Clipper_constructToolbar( toolbar ); } -void MainFrame::OnColorSetqer() -{ - for (int i=0 ; i<3 ; i++) - { - g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.5f; - g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25f; - } +ui::Toolbar create_main_toolbar( MainFrame::EViewStyle style ){ + auto toolbar = ui::Toolbar(GTK_TOOLBAR( gtk_toolbar_new() )); + gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL ); + gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS ); - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0f; + gtk_widget_show( GTK_WIDGET( toolbar ) ); - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0f; + auto space = [&]() { + auto btn = gtk_separator_tool_item_new(); + gtk_widget_show(GTK_WIDGET(btn)); + gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(btn)); + }; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0f; + File_constructToolbar( toolbar ); - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0f; + space(); - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0f; + UndoRedo_constructToolbar( toolbar ); - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5f; - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75f; + space(); - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][2] = 0.0f; + RotateFlip_constructToolbar( toolbar ); - Sys_UpdateWindows (W_ALL); -} + space(); -void MainFrame::OnColorSetblack() -{ - for (int i=0 ; i<3 ; i++) - { - g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.2f; - g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25f; - } + Select_constructToolbar( toolbar ); - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][0] = 0.3f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][1] = 0.5f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][2] = 0.5f; + space(); - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0f; + CSG_constructToolbar( toolbar ); - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 1.0f; + space(); - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0f; + ComponentModes_constructToolbar( toolbar ); - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0f; + if ( style == MainFrame::eRegular || style == MainFrame::eRegularLeft || style == MainFrame::eFloating ) { + space(); - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 1.0f; + XYWnd_constructToolbar( toolbar ); + } - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.7f; - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.7f; - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.0f; + space(); - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][2] = 0.0f; + CamWnd_constructToolbar( toolbar ); - Sys_UpdateWindows (W_ALL); -} + space(); -/* ydnar: to emulate maya/max/lightwave color schemes */ -void MainFrame::OnColorSetydnar() -{ - for (int i=0 ; i<3 ; i++) - { - g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][i] = 0.25f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][i] = 0.77f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMINOR][i] = 0.83f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDMAJOR][i] = 0.89f; - g_qeglobals.d_savedinfo.colors[COLOR_CAMERABACK][i] = 0.25f; - } + Manipulators_constructToolbar( toolbar ); - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][1] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDBLOCK][2] = 1.0f; + if ( g_Layout_enablePatchToolbar.m_value ) { + space(); - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_GRIDTEXT][2] = 0.0f; + Patch_constructToolbar( toolbar ); + } - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES][2] = 0.0f; + space(); - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_CLIPPER][2] = 1.0f; + toolbar_append_toggle_button( toolbar, "Texture Lock (SHIFT +T)", "texture_lock.png", "TogTexLock" ); - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][0] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_BRUSHES][2] = 0.0f; + space(); - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][0] = 0.5f; - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME][2] = 0.75f; + /*auto g_view_entities_button =*/ toolbar_append_button( toolbar, "Entities (N)", "entities.png", "ToggleEntityInspector" ); + auto g_view_console_button = toolbar_append_button( toolbar, "Console (O)", "console.png", "ToggleConsole" ); + auto g_view_textures_button = toolbar_append_button( toolbar, "Texture Browser (T)", "texture_browser.png", "ToggleTextures" ); + // TODO: call light inspector + //GtkButton* g_view_lightinspector_button = toolbar_append_button(toolbar, "Light Inspector", "lightinspector.png", "ToggleLightInspector"); - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][0] = 1.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][1] = 0.0f; - g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES3D][2] = 0.0f; + space(); + /*auto g_refresh_models_button =*/ toolbar_append_button( toolbar, "Refresh Models", "refresh_models.png", "RefreshReferences" ); - Sys_UpdateWindows (W_ALL); -} -void MainFrame::OnTexturebk() -{ - DoColor(COLOR_TEXTUREBACK); - Sys_UpdateWindows (W_ALL); -} + // disable the console and texture button in the regular layouts + if ( style == MainFrame::eRegular || style == MainFrame::eRegularLeft ) { + gtk_widget_set_sensitive( GTK_WIDGET( g_view_console_button ), FALSE ); + gtk_widget_set_sensitive( GTK_WIDGET( g_view_textures_button ), FALSE ); + } -void MainFrame::OnColorsXybk() -{ - DoColor(COLOR_GRIDBACK); - Sys_UpdateWindows (W_ALL); + return toolbar; } -void MainFrame::OnColorsMajor() -{ - DoColor(COLOR_GRIDMAJOR); - Sys_UpdateWindows (W_ALL); -} - -void MainFrame::OnColorsMinor() -{ - DoColor(COLOR_GRIDMINOR); - Sys_UpdateWindows (W_ALL); -} +ui::Widget create_main_statusbar( ui::Widget pStatusLabel[c_count_status] ){ + GtkTable* table = ui::Table( 1, c_count_status, FALSE ); + gtk_widget_show( GTK_WIDGET( table ) ); -void MainFrame::OnColorsMajor_Alt() -{ - DoColor(COLOR_GRIDMAJOR_ALT); - Sys_UpdateWindows (W_ALL); -} + { + GtkLabel* label = GTK_LABEL( ui::Label( "Label" ) ); + gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); + gtk_misc_set_padding( GTK_MISC( label ), 4, 2 ); + gtk_widget_show( GTK_WIDGET( label ) ); + gtk_table_attach_defaults( table, GTK_WIDGET( label ), 0, 1, 0, 1 ); + pStatusLabel[c_command_status] = ui::Widget(GTK_WIDGET( label )); + } -void MainFrame::OnColorsMinor_Alt() -{ - DoColor(COLOR_GRIDMINOR_ALT); - Sys_UpdateWindows (W_ALL); -} + for ( int i = 1; i < c_count_status; ++i ) + { + GtkFrame* frame = ui::Frame(); + gtk_widget_show( GTK_WIDGET( frame ) ); + gtk_table_attach_defaults( table, GTK_WIDGET( frame ), i, i + 1, 0, 1 ); + gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN ); -void MainFrame::OnColorsGridtext() -{ - DoColor(COLOR_GRIDTEXT); - Sys_UpdateWindows (W_ALL); -} + GtkLabel* label = GTK_LABEL( ui::Label( "Label" ) ); + gtk_label_set_ellipsize( label, PANGO_ELLIPSIZE_END ); + gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); + gtk_misc_set_padding( GTK_MISC( label ), 4, 2 ); + gtk_widget_show( GTK_WIDGET( label ) ); + gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( label ) ); + pStatusLabel[i] = ui::Widget(GTK_WIDGET( label )); + } -void MainFrame::OnColorsGridblock() -{ - DoColor(COLOR_GRIDBLOCK); - Sys_UpdateWindows (W_ALL); + return ui::Widget(GTK_WIDGET( table )); } -void MainFrame::OnColorsCameraBack() -{ - DoColor(COLOR_CAMERABACK); - Sys_UpdateWindows (W_ALL); -} +#if 0 -void MainFrame::OnColorsBrush() -{ - DoColor(COLOR_BRUSHES); - Sys_UpdateWindows (W_ALL); -} -void MainFrame::OnColorsSelectedbrush() -{ - DoColor(COLOR_SELBRUSHES); - Sys_UpdateWindows (W_ALL); -} +WidgetFocusPrinter g_mainframeWidgetFocusPrinter( "mainframe" ); -void MainFrame::OnColorsSelectedbrush3D() +class WindowFocusPrinter { - DoColor(COLOR_SELBRUSHES3D); - Sys_UpdateWindows (W_ALL); -} +const char* m_name; -void MainFrame::OnColorsClipper() -{ - DoColor(COLOR_CLIPPER); - Sys_UpdateWindows (W_ALL); +static gboolean frame_event( ui::Widget widget, GdkEvent* event, WindowFocusPrinter* self ){ + globalOutputStream() << self->m_name << " frame_event\n"; + return FALSE; } - -void MainFrame::OnColorsViewname() -{ - DoColor(COLOR_VIEWNAME); - Sys_UpdateWindows (W_ALL); +static gboolean keys_changed( ui::Widget widget, WindowFocusPrinter* self ){ + globalOutputStream() << self->m_name << " keys_changed\n"; + return FALSE; } - -void MainFrame::OnMiscGamma() -{ - float fSave = g_qeglobals.d_savedinfo.fGamma; - DoGamma(); - if (fSave != g_qeglobals.d_savedinfo.fGamma) - { - gtk_MessageBox(m_pWidget, _("You must restart Radiant for Gamma settings to take effect.")); - } -} -void MainFrame::OnMiscFindbrush() -{ - DoFind(); +static gboolean notify( ui::Window window, gpointer dummy, WindowFocusPrinter* self ){ + if ( gtk_window_is_active( window ) ) { + globalOutputStream() << self->m_name << " takes toplevel focus\n"; + } + else + { + globalOutputStream() << self->m_name << " loses toplevel focus\n"; + } + return FALSE; } - -void MainFrame::OnMiscNextleakspot() -{ - Pointfile_Next(); +public: +WindowFocusPrinter( const char* name ) : m_name( name ){ } - -void MainFrame::OnMiscPreviousleakspot() -{ - Pointfile_Prev(); +void connect( ui::Window toplevel_window ){ + g_signal_connect( G_OBJECT( toplevel_window ), "notify::has_toplevel_focus", G_CALLBACK( notify ), this ); + g_signal_connect( G_OBJECT( toplevel_window ), "notify::is_active", G_CALLBACK( notify ), this ); + g_signal_connect( G_OBJECT( toplevel_window ), "keys_changed", G_CALLBACK( keys_changed ), this ); + g_signal_connect( G_OBJECT( toplevel_window ), "frame_event", G_CALLBACK( frame_event ), this ); } +}; -void MainFrame::OnMiscPrintxy() -{ -// WXY_Print(); -} +WindowFocusPrinter g_mainframeFocusPrinter( "mainframe" ); -void MainFrame::OnMiscSelectentitycolor() -{ - if (edit_entity) - { - CString strColor = ValueForKey(edit_entity, "_color"); - if (strColor.GetLength() > 0) - { - float fR, fG, fB; - int n = sscanf(strColor,"%f %f %f", &fR, &fG, &fB); - if (n == 3) - { - g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0] = fR; - g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1] = fG; - g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2] = fB; - } - } - - if (inspector_mode == W_ENTITY && (DoColor(COLOR_ENTITY))) - { - char buffer[100]; - sprintf(buffer, "%f %f %f", g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0], - g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1], - g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2]); - - gtk_entry_set_text (GTK_ENTRY (EntWidgets[EntValueField]), buffer); - gtk_entry_set_text (GTK_ENTRY (EntWidgets[EntKeyField]), "_color"); - AddProp(); - //DK - SOF change to get color to entity quickly - //--::SetWindowText( hwndEnt[EntValueField], buffer ); - //--::SetWindowText( hwndEnt[EntKeyField], "color" ); - //--AddProp(); - } - Sys_UpdateWindows( W_ALL ); - } -} - -void MainFrame::OnConvertcurves() -{ -#if 0 - Select_Deselect(); - for (brush_t* pb = active_brushes.next ; pb != &active_brushes ; pb = pb->next) - { - if (pb->curveBrush) - { - for (face_t* f = pb->brush_faces ; f ; f=f->next) - { - if (f->texdef.contents & CONTENTS_LADDER) - { - f->texdef.contents &= ~CONTENTS_LADDER; - f->texdef.contents |= CONTENTS_NEGATIVE_CURVE; - } - } - } - } - Map_BuildBrushData(); #endif -} - -void MainFrame::OnRegionOff() -{ - Map_RegionOff (); -} -void MainFrame::OnRegionSetxy() +class MainWindowActive { - Map_RegionXY (); -} +static gboolean notify( ui::Window window, gpointer dummy, MainWindowActive* self ){ + if ( g_wait.m_window && gtk_window_is_active( window ) && !gtk_widget_get_visible( g_wait.m_window ) ) { + gtk_widget_show( GTK_WIDGET( g_wait.m_window ) ); + } -void MainFrame::OnRegionSettallbrush() -{ - Map_RegionTallBrush (); + return FALSE; } - -void MainFrame::OnRegionSetbrush() -{ - Map_RegionBrush (); +public: +void connect( ui::Window toplevel_window ){ + g_signal_connect( G_OBJECT( toplevel_window ), "notify::is-active", G_CALLBACK( notify ), this ); } +}; -void MainFrame::OnRegionSetselection() -{ - Map_RegionSelectedBrushes (); -} +MainWindowActive g_MainWindowActive; -void MainFrame::OnBrush3sided() -{ - Undo_Start("3 sided"); - Undo_AddBrushList(&selected_brushes); - Brush_MakeSided(3); - Undo_EndBrushList(&selected_brushes); - Undo_End(); +SignalHandlerId XYWindowDestroyed_connect( const SignalHandler& handler ){ + return g_pParentWnd->GetXYWnd()->onDestroyed.connectFirst( handler ); } -void MainFrame::OnBrush4sided() -{ - Undo_Start("4 sided"); - Undo_AddBrushList(&selected_brushes); - Brush_MakeSided(4); - Undo_EndBrushList(&selected_brushes); - Undo_End(); +void XYWindowDestroyed_disconnect( SignalHandlerId id ){ + g_pParentWnd->GetXYWnd()->onDestroyed.disconnect( id ); } -void MainFrame::OnBrush5sided() -{ - Undo_Start("5 sided"); - Undo_AddBrushList(&selected_brushes); - Brush_MakeSided(5); - Undo_EndBrushList(&selected_brushes); - Undo_End(); +MouseEventHandlerId XYWindowMouseDown_connect( const MouseEventHandler& handler ){ + return g_pParentWnd->GetXYWnd()->onMouseDown.connectFirst( handler ); } -void MainFrame::OnBrush6sided() -{ - Undo_Start("6 sided"); - Undo_AddBrushList(&selected_brushes); - Brush_MakeSided(6); - Undo_EndBrushList(&selected_brushes); - Undo_End(); +void XYWindowMouseDown_disconnect( MouseEventHandlerId id ){ + g_pParentWnd->GetXYWnd()->onMouseDown.disconnect( id ); } -void MainFrame::OnBrush7sided() -{ - Undo_Start("7 sided"); - Undo_AddBrushList(&selected_brushes); - Brush_MakeSided(7); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +// ============================================================================= +// MainFrame class -void MainFrame::OnBrush8sided() -{ - Undo_Start("8 sided"); - Undo_AddBrushList(&selected_brushes); - Brush_MakeSided(8); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +MainFrame* g_pParentWnd = 0; -void MainFrame::OnBrush9sided() +ui::Window MainFrame_getWindow() { - Undo_Start("9 sided"); - Undo_AddBrushList(&selected_brushes); - Brush_MakeSided(9); - Undo_EndBrushList(&selected_brushes); - Undo_End(); + return g_pParentWnd ? g_pParentWnd->m_window : ui::Window(); } -void MainFrame::OnBrushArbitrarysided() -{ - Undo_Start("arbitrary sided"); - Undo_AddBrushList(&selected_brushes); - DoSides(); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +std::vector g_floating_windows; -void MainFrame::OnBrushMakecone() -{ - Undo_Start("make cone"); - Undo_AddBrushList(&selected_brushes); - DoSides(true); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusTextCaller( *this ) ){ + m_pXYWnd = 0; + m_pCamWnd = 0; + m_pZWnd = 0; + m_pYZWnd = 0; + m_pXZWnd = 0; + m_pActiveXY = 0; -void MainFrame::OnBrushPrimitivesSphere() -{ - Undo_Start("make sphere"); - Undo_AddBrushList(&selected_brushes); + for ( int n = 0; n < c_count_status; n++ ) + { + m_pStatusLabel[n] = ui::root; + } - DoSides(false, true); + m_bSleeping = false; - Undo_EndBrushList(&selected_brushes); - Undo_End(); + Create(); } -void MainFrame::OnCurvePatchtube() -{ - Undo_Start("make curve cylinder"); - Undo_AddBrushList(&selected_brushes); - Patch_BrushToMesh(false); - Sys_UpdateWindows (W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} - -void MainFrame::OnCurvePatchdensetube() -{ - Undo_Start("dense cylinder"); - Undo_AddBrushList(&selected_brushes); - - Patch_BrushToMesh(false); - OnCurveInsertAddrow(); - Sys_UpdateWindows (W_ALL); +MainFrame::~MainFrame(){ + SaveWindowInfo(); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + gtk_widget_hide( GTK_WIDGET( m_window ) ); -void MainFrame::OnCurvePatchverydensetube() -{ - Undo_Start("very dense cylinder"); - Undo_AddBrushList(&selected_brushes); + Shutdown(); - Patch_BrushToMesh(false); - OnCurveInsertAddrow(); - OnCurveInsertInsertrow(); - OnCurveInsertAddrow(); - Sys_UpdateWindows (W_ALL); + for ( std::vector::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i ) + { + gtk_widget_destroy( *i ); + } - Undo_EndBrushList(&selected_brushes); - Undo_End(); + gtk_widget_destroy( GTK_WIDGET( m_window ) ); } -void MainFrame::OnCurvePatchsquare() -{ - Undo_Start("square cylinder"); - Undo_AddBrushList(&selected_brushes); +void MainFrame::SetActiveXY( XYWnd* p ){ + if ( m_pActiveXY ) { + m_pActiveXY->SetActive( false ); + } - Patch_BrushToMesh(false, false, false, true); - Sys_UpdateWindows (W_ALL); + m_pActiveXY = p; - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + if ( m_pActiveXY ) { + m_pActiveXY->SetActive( true ); + } -void MainFrame::OnCurvePatchendcap() -{ - Undo_Start("make end cap"); - Undo_AddBrushList(&selected_brushes); - Patch_BrushToMesh(false, false, true); - Sys_UpdateWindows (W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); } -void MainFrame::OnCurvePatchbevel() -{ - Undo_Start("make bevel"); - Undo_AddBrushList(&selected_brushes); - Patch_BrushToMesh(false, true, false); - Sys_UpdateWindows (W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); +void MainFrame::ReleaseContexts(){ +#if 0 + if ( m_pXYWnd ) { + m_pXYWnd->DestroyContext(); + } + if ( m_pYZWnd ) { + m_pYZWnd->DestroyContext(); + } + if ( m_pXZWnd ) { + m_pXZWnd->DestroyContext(); + } + if ( m_pCamWnd ) { + m_pCamWnd->DestroyContext(); + } + if ( m_pTexWnd ) { + m_pTexWnd->DestroyContext(); + } + if ( m_pZWnd ) { + m_pZWnd->DestroyContext(); + } +#endif } -void MainFrame::OnCurveMoreendcapsbevelsSquarebevel() -{ - Undo_Start("square bevel"); - Undo_AddBrushList(&selected_brushes); - - Patch_BrushToMesh(false, true, false, true); - Sys_UpdateWindows (W_ALL); - - Undo_EndBrushList(&selected_brushes); - Undo_End(); +void MainFrame::CreateContexts(){ +#if 0 + if ( m_pCamWnd ) { + m_pCamWnd->CreateContext(); + } + if ( m_pXYWnd ) { + m_pXYWnd->CreateContext(); + } + if ( m_pYZWnd ) { + m_pYZWnd->CreateContext(); + } + if ( m_pXZWnd ) { + m_pXZWnd->CreateContext(); + } + if ( m_pTexWnd ) { + m_pTexWnd->CreateContext(); + } + if ( m_pZWnd ) { + m_pZWnd->CreateContext(); + } +#endif } -void MainFrame::OnCurveMoreendcapsbevelsSquareendcap() -{ - Undo_Start("square endcap"); - Undo_AddBrushList(&selected_brushes); - - Patch_BrushToMesh(false, false, true, true); - Sys_UpdateWindows (W_ALL); +#ifdef _DEBUG +//#define DBG_SLEEP +#endif - Undo_EndBrushList(&selected_brushes); - Undo_End(); +void MainFrame::OnSleep(){ +#if 0 + m_bSleeping ^= 1; + if ( m_bSleeping ) { + // useful when trying to debug crashes in the sleep code + globalOutputStream() << "Going into sleep mode..\n"; + + globalOutputStream() << "Dispatching sleep msg..."; + DispatchRadiantMsg( RADIANT_SLEEP ); + globalOutputStream() << "Done.\n"; + + gtk_window_iconify( m_window ); + GlobalSelectionSystem().setSelectedAll( false ); + + GlobalShaderCache().unrealise(); + Shaders_Free(); + GlobalOpenGL_debugAssertNoErrors(); + ScreenUpdates_Disable(); + + // release contexts + globalOutputStream() << "Releasing contexts..."; + ReleaseContexts(); + globalOutputStream() << "Done.\n"; + } + else + { + globalOutputStream() << "Waking up\n"; + + gtk_window_deiconify( m_window ); + + // create contexts + globalOutputStream() << "Creating contexts..."; + CreateContexts(); + globalOutputStream() << "Done.\n"; + + globalOutputStream() << "Making current on camera..."; + m_pCamWnd->MakeCurrent(); + globalOutputStream() << "Done.\n"; + + globalOutputStream() << "Reloading shaders..."; + Shaders_Load(); + GlobalShaderCache().realise(); + globalOutputStream() << "Done.\n"; + + ScreenUpdates_Enable(); + + globalOutputStream() << "Dispatching wake msg..."; + DispatchRadiantMsg( RADIANT_WAKEUP ); + globalOutputStream() << "Done\n"; + } +#endif } -void MainFrame::OnCurvePatchcone() -{ - Undo_Start("make curve cone"); - Undo_AddBrushList(&selected_brushes); - Patch_BrushToMesh(true); - Sys_UpdateWindows (W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} -void MainFrame::OnCurveSimplepatchmesh() -{ - Undo_Start("make simpe patch mesh"); - Undo_AddBrushList(&selected_brushes); - DoNewPatchDlg (); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +ui::Window create_splash(){ + ui::Window window = ui::Window( ui::window_type::TOP ); + gtk_window_set_decorated( window, FALSE ); + gtk_window_set_resizable( window, FALSE ); + gtk_window_set_modal( window, TRUE ); + gtk_window_set_default_size( window, -1, -1 ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); + gtk_container_set_border_width( GTK_CONTAINER( window ), 0 ); -void MainFrame::OnCurveInsertInsertcolumn() -{ - Undo_Start("insert (2) columns"); - Undo_AddBrushList(&selected_brushes); - Patch_AdjustSelected(true, true, false); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + GtkImage* image = new_local_image( "splash.png" ); + gtk_widget_show( GTK_WIDGET( image ) ); + gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( image ) ); -void MainFrame::OnCurveInsertAddcolumn() -{ - Undo_Start("add (2) columns"); - Undo_AddBrushList(&selected_brushes); - Patch_AdjustSelected(true, true, true); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + gtk_widget_set_size_request( GTK_WIDGET( window ), -1, -1 ); + gtk_widget_show( GTK_WIDGET( window ) ); -void MainFrame::OnCurveInsertInsertrow() -{ - Undo_Start("insert (2) rows"); - Undo_AddBrushList(&selected_brushes); - Patch_AdjustSelected(true, false, false); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); + return window; } -void MainFrame::OnCurveInsertAddrow() -{ - Undo_Start("add (2) rows"); - Undo_AddBrushList(&selected_brushes); - Patch_AdjustSelected(true, false, true); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +static ui::Window splash_screen; -void MainFrame::OnCurveDeleteFirstcolumn() -{ - Undo_Start("delete first (2) columns"); - Undo_AddBrushList(&selected_brushes); - Patch_AdjustSelected(false, true, true); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +void show_splash(){ + splash_screen = create_splash(); -void MainFrame::OnCurveDeleteLastcolumn() -{ - Undo_Start("delete last (2) columns"); - Undo_AddBrushList(&selected_brushes); - Patch_AdjustSelected(false, true, false); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); + process_gui(); } -void MainFrame::OnCurveDeleteFirstrow() -{ - Undo_Start("delete first (2) rows"); - Undo_AddBrushList(&selected_brushes); - Patch_AdjustSelected(false, false, true); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); +void hide_splash(){ + gtk_widget_destroy( GTK_WIDGET( splash_screen ) ); } -void MainFrame::OnCurveDeleteLastrow() -{ - Undo_Start("delete last (2) rows"); - Undo_AddBrushList(&selected_brushes); - Patch_AdjustSelected(false, false, false); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +WindowPositionTracker g_posCamWnd; +WindowPositionTracker g_posXYWnd; +WindowPositionTracker g_posXZWnd; +WindowPositionTracker g_posYZWnd; -void MainFrame::OnCurveNegative() -{ - Patch_ToggleInverted(); - //Sys_UpdateWindows(W_ALL); -} +static gint mainframe_delete( ui::Widget widget, GdkEvent *event, gpointer data ){ + if ( ConfirmModified( "Exit Radiant" ) ) { + gtk_main_quit(); + } -void MainFrame::OnCurveRedisperseRows() -{ - Undo_Start("redisperse rows"); - Undo_AddBrushList(&selected_brushes); - Patch_DisperseRows(); - Sys_UpdateWindows (W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); + return TRUE; } -void MainFrame::OnCurveRedisperseIntermediateCols() -{ - Undo_Start("redisperse im cols"); - Undo_AddBrushList(&selected_brushes); - Patch_DisperseIntermediateColumns(); - Sys_UpdateWindows (W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} +void MainFrame::Create(){ + ui::Window window = ui::Window( ui::window_type::TOP ); -void MainFrame::OnCurveRedisperseIntermediateRows() -{ - Undo_Start("redisperse im rows"); - Undo_AddBrushList(&selected_brushes); - Patch_DisperseIntermediateRows(); - Sys_UpdateWindows (W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + GlobalWindowObservers_connectTopLevel( window ); -void MainFrame::OnCurveMatrixTranspose() -{ - Patch_Transpose(); - Sys_UpdateWindows (W_ALL); -} + gtk_window_set_transient_for( splash_screen, window ); -void MainFrame::OnCurveCap() -{ - Patch_CapCurrent(); - Sys_UpdateWindows (W_ALL); -} +#if !defined( WIN32 ) + { + GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.png" ); + if ( pixbuf != 0 ) { + gtk_window_set_icon( window, pixbuf ); + g_object_unref( pixbuf ); + } + } +#endif -void MainFrame::OnCurveCyclecap() -{ - Patch_CycleCapSelected(); - Sys_UpdateWindows (W_ALL); -} + gtk_widget_add_events( GTK_WIDGET( window ), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK ); + g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( mainframe_delete ), this ); -void MainFrame::OnCurveOverlaySet() -{ - Patch_SetOverlays(); - Sys_UpdateWindows(W_ALL); -} + m_position_tracker.connect( window ); -void MainFrame::OnCurveOverlayClear() -{ - Patch_ClearOverlays(); - Sys_UpdateWindows(W_ALL); -} +#if 0 + g_mainframeWidgetFocusPrinter.connect( window ); + g_mainframeFocusPrinter.connect( window ); +#endif -void MainFrame::OnCurveThicken() -{ - Undo_Start("curve thicken"); - Undo_AddBrushList(&selected_brushes); - DoThickenDlg (); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + g_MainWindowActive.connect( window ); -/*! -this can no longer be trigger manually from the menu -happens only once at startup -*/ -void MainFrame::OnPluginsRefresh() -{ - CleanPlugInMenu(); - m_PlugInMgr.Init(); -} + GetPlugInMgr().Init( window ); -// open the Q3Rad manual -void MainFrame::OnHelp() -{ - // at least on win32, g_strGameToolsPath + "Q3Rad_Manual/index.htm" - Str help; - help = g_strAppPath; - help += "Q3Rad_Manual/index.htm"; - OpenURL(help.GetBuffer()); -} + ui::Widget vbox = ui::VBox( FALSE, 0 ); + gtk_container_add( GTK_CONTAINER( window ), vbox ); + gtk_widget_show( vbox ); -// FIXME: we'll go towards a unified help thing soon -void MainFrame::OnHelpLinks() -{ - Str link; - link = g_strAppPath; - link += "links.htm"; - OpenURL(link.GetBuffer()); -} + global_accel_connect_window( window ); -void MainFrame::OnHelpBugreport() -{ - OpenURL("http://www.qeradiant.com/faq/fom-serve/cache/138.html"); -} + m_nCurrentStyle = (EViewStyle)g_Layout_viewStyle.m_value; -void MainFrame::OnHelpCommandlist() -{ - DoCommandListDlg (); -} + register_shortcuts(); -void MainFrame::OnHelpAbout() -{ - DoAbout(); -} + GtkMenuBar* main_menu = create_main_menu( CurrentStyle() ); + gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_menu ), FALSE, FALSE, 0 ); -void MainFrame::OnPopupSelection() -{ - GtkWidget *menu, *item; - const gchar *labels[] = { _("Select Complete Tall"), _("Select Touching"), _("Select Partial Tall"), _("Select Inside")}; - int ids[] = { ID_SELECTION_SELECTCOMPLETETALL, ID_SELECTION_SELECTTOUCHING, - ID_SELECTION_SELECTPARTIALTALL, ID_SELECTION_SELECTINSIDE}; + GtkToolbar* main_toolbar = create_main_toolbar( CurrentStyle() ); + gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_toolbar ), FALSE, FALSE, 0 ); - menu = gtk_menu_new (); + GtkToolbar* plugin_toolbar = create_plugin_toolbar(); + if ( !g_Layout_enablePluginToolbar.m_value ) { + gtk_widget_hide( GTK_WIDGET( plugin_toolbar ) ); + } + gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( plugin_toolbar ), FALSE, FALSE, 0 ); - for (int i = 0; i < 4; i++) - { - item = gtk_menu_item_new_with_label (labels[i]); - gtk_signal_connect (GTK_OBJECT (item), "activate", GTK_SIGNAL_FUNC (HandleCommand), - GINT_TO_POINTER (ids[i])); - gtk_widget_show (item); - gtk_menu_append (GTK_MENU (menu), item); - } + ui::Widget main_statusbar = create_main_statusbar( m_pStatusLabel ); + gtk_box_pack_end( GTK_BOX( vbox ), main_statusbar, FALSE, TRUE, 2 ); - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME); -} + GroupDialog_constructWindow( window ); + g_page_entity = GroupDialog_addPage( "Entities", EntityInspector_constructWindow( GroupDialog_getWindow() ), RawStringExportCaller( "Entities" ) ); -void MainFrame::OnViewChange() -{ - OnViewNextview(); - //HandlePopup(this, IDR_POPUP_VIEW); -} + if ( FloatingGroupDialog() ) { + g_page_console = GroupDialog_addPage( "Console", Console_constructWindow( GroupDialog_getWindow() ), RawStringExportCaller( "Console" ) ); + } -void MainFrame::OnTexturesPopup() -{ - gpointer item = g_object_get_data (G_OBJECT (m_pWidget), "render_quality_menu"); - gtk_menu_popup (GTK_MENU (item), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME); -} +#ifdef WIN32 + if ( g_multimon_globals.m_bStartOnPrimMon ) { + PositionWindowOnPrimaryScreen( g_layout_globals.m_position ); + window_set_position( window, g_layout_globals.m_position ); + } + else +#endif + if ( g_layout_globals.nState & GDK_WINDOW_STATE_MAXIMIZED ) { + gtk_window_maximize( window ); + WindowPosition default_position( -1, -1, 640, 480 ); + window_set_position( window, default_position ); + } + else + { + window_set_position( window, g_layout_globals.m_position ); + } + + m_window = window; + + gtk_widget_show( GTK_WIDGET( window ) ); + + if ( CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft ) { + { + ui::Widget vsplit = ui::VPaned(); + m_vSplit = vsplit; + gtk_box_pack_start( GTK_BOX( vbox ), vsplit, TRUE, TRUE, 0 ); + gtk_widget_show( vsplit ); + + // console + ui::Widget console_window = Console_constructWindow( window ); + gtk_paned_pack2( GTK_PANED( vsplit ), console_window, FALSE, TRUE ); + + { + ui::Widget hsplit = ui::HPaned(); + gtk_widget_show( hsplit ); + m_hSplit = hsplit; + gtk_paned_add1( GTK_PANED( vsplit ), hsplit ); + + // xy + m_pXYWnd = new XYWnd(); + m_pXYWnd->SetViewType( XY ); + ui::Widget xy_window = ui::Widget(GTK_WIDGET( create_framed_widget( m_pXYWnd->GetWidget() ) )); + + { + ui::Widget vsplit2 = ui::VPaned(); + gtk_widget_show( vsplit2 ); + m_vSplit2 = vsplit2; + + if ( CurrentStyle() == eRegular ) { + gtk_paned_add1( GTK_PANED( hsplit ), xy_window ); + gtk_paned_add2( GTK_PANED( hsplit ), vsplit2 ); + } + else + { + gtk_paned_add1( GTK_PANED( hsplit ), vsplit2 ); + gtk_paned_add2( GTK_PANED( hsplit ), xy_window ); + } + + + // camera + m_pCamWnd = NewCamWnd(); + GlobalCamera_setCamWnd( *m_pCamWnd ); + CamWnd_setParent( *m_pCamWnd, window ); + GtkFrame* camera_window = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) ); + + gtk_paned_add1( GTK_PANED( vsplit2 ), GTK_WIDGET( camera_window ) ); + + // textures + GtkFrame* texture_window = create_framed_widget( TextureBrowser_constructWindow( window ) ); + + gtk_paned_add2( GTK_PANED( vsplit2 ), GTK_WIDGET( texture_window ) ); + } + } + } + + gtk_paned_set_position( GTK_PANED( m_vSplit ), g_layout_globals.nXYHeight ); + + if ( CurrentStyle() == eRegular ) { + gtk_paned_set_position( GTK_PANED( m_hSplit ), g_layout_globals.nXYWidth ); + } + else + { + gtk_paned_set_position( GTK_PANED( m_hSplit ), g_layout_globals.nCamWidth ); + } + + gtk_paned_set_position( GTK_PANED( m_vSplit2 ), g_layout_globals.nCamHeight ); + } + else if ( CurrentStyle() == eFloating ) { + { + ui::Window window = ui::Window(create_persistent_floating_window( "Camera", m_window )); + global_accel_connect_window( window ); + g_posCamWnd.connect( window ); + + gtk_widget_show( GTK_WIDGET( window ) ); + + m_pCamWnd = NewCamWnd(); + GlobalCamera_setCamWnd( *m_pCamWnd ); + + { + GtkFrame* frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) ); + gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + } + CamWnd_setParent( *m_pCamWnd, window ); + + g_floating_windows.push_back( window ); + } + + { + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XY ), m_window )); + global_accel_connect_window( window ); + g_posXYWnd.connect( window ); + + m_pXYWnd = new XYWnd(); + m_pXYWnd->m_parent = window; + m_pXYWnd->SetViewType( XY ); -void MainFrame::ToggleCamera() -{ - if (m_bCamPreview) - m_bCamPreview = false; - else - m_bCamPreview = true; -} -void MainFrame::OnViewCameraupdate() -{ - Sys_UpdateWindows(W_CAMERA); -} + { + GtkFrame* frame = create_framed_widget( m_pXYWnd->GetWidget() ); + gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + } + XY_Top_Shown_Construct( window ); -void MainFrame::OnSelectMouserotate() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_select_mouserotate")); - g_bIgnoreCommands++; - - if (ActiveXY()) - { - if (ActiveXY()->ClipMode()) - OnViewClipper(); - if (ActiveXY()->RotateMode()) - { - // SetRotateMode(false) always works - ActiveXY()->SetRotateMode(false); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), FALSE); - } else - { - // may not work if no brush selected, see return value - if (ActiveXY()->SetRotateMode(true)) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), TRUE); - else - // if MFC called, we need to set back to FALSE ourselves - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), FALSE); - } - } - g_bIgnoreCommands--; -} - -void MainFrame::OnSelectMousescale() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_select_mousescale")); - g_bIgnoreCommands++; - - if (ActiveXY()) - { - if (ActiveXY()->ClipMode()) - OnViewClipper(); - if (ActiveXY()->RotateMode()) - { - // SetRotateMode(false) always works - ActiveXY()->SetRotateMode(false); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), FALSE); - } - if (ActiveXY()->ScaleMode()) - { - ActiveXY()->SetScaleMode(false); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), FALSE); - } else - { - ActiveXY()->SetScaleMode(true); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), TRUE); - } - } - g_bIgnoreCommands--; -} - -void MainFrame::OnScalelockx() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_scalelockx")); - g_bIgnoreCommands++; - - if (g_nScaleHow & SCALE_X) - { - g_nScaleHow ^= SCALE_X; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), FALSE); - } else - { - g_nScaleHow |= SCALE_X; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), TRUE); - } - g_bIgnoreCommands--; -} - -void MainFrame::OnScalelocky() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_scalelocky")); - g_bIgnoreCommands++; - - if (g_nScaleHow & SCALE_Y) - { - g_nScaleHow ^= SCALE_Y; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), FALSE); - } else - { - g_nScaleHow |= SCALE_Y; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), TRUE); - } - g_bIgnoreCommands--; -} - -void MainFrame::OnScalelockz() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_scalelockz")); - g_bIgnoreCommands++; - - if (g_nScaleHow & SCALE_Z) - { - g_nScaleHow ^= SCALE_Z; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), FALSE); - } else - { - g_nScaleHow |= SCALE_Z; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), TRUE); - } - g_bIgnoreCommands--; -} - -void MainFrame::OnDontselectcurve() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_dontselectcurve")); - g_bIgnoreCommands++; - g_PrefsDlg.m_bSelectCurves ^= 1; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_PrefsDlg.m_bSelectCurves) ? FALSE : TRUE); - g_bIgnoreCommands--; -} + g_floating_windows.push_back( window ); + } -void MainFrame::OnPatchToggleBox() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_patch_showboundingbox")); - g_bIgnoreCommands++; - g_bPatchShowBounds ^= 1; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_bPatchShowBounds) ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows(W_ALL); -} + { + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XZ ), m_window )); + global_accel_connect_window( window ); + g_posXZWnd.connect( window ); -void MainFrame::OnPatchWireframe() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_patch_wireframe")); - g_bIgnoreCommands++; - g_bPatchWireFrame ^= 1; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_bPatchWireFrame) ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows(W_ALL); -} + m_pXZWnd = new XYWnd(); + m_pXZWnd->m_parent = window; + m_pXZWnd->SetViewType( XZ ); -void MainFrame::OnPatchBend() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_patch_bend")); - g_bIgnoreCommands++; - Patch_BendToggle(); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_bPatchBendMode) ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows(W_ALL); -} + { + GtkFrame* frame = create_framed_widget( m_pXZWnd->GetWidget() ); + gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + } -void MainFrame::OnPatchWeld() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_patch_weld")); - g_bIgnoreCommands++; - g_bPatchWeld ^= 1; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_bPatchWeld) ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows(W_ALL); -} + XZ_Front_Shown_Construct( window ); -void MainFrame::OnPatchDrilldown() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_patch_drilldown")); - g_bIgnoreCommands++; - g_bPatchDrillDown ^= 1; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_bPatchDrillDown) ? TRUE : FALSE); - g_bIgnoreCommands--; - Sys_UpdateWindows(W_ALL); -} + g_floating_windows.push_back( window ); + } -void MainFrame::OnShowEntities() -{ - gpointer item = g_object_get_data (G_OBJECT (m_pWidget), "view_entitiesas_menu"); // use pointer to existing menu object - gtk_menu_popup (GTK_MENU (item), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME); -} + { + ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( YZ ), m_window )); + global_accel_connect_window( window ); + g_posYZWnd.connect( window ); -void MainFrame::OnDropGroupName() -{ - /* - char* name = DoNameDlg ("Name Selection"); + m_pYZWnd = new XYWnd(); + m_pYZWnd->m_parent = window; + m_pYZWnd->SetViewType( YZ ); - if (name != NULL) - { - Select_Name (name); - Sys_UpdateWindows (W_ALL); - free (name); - } - */ -} + { + GtkFrame* frame = create_framed_widget( m_pYZWnd->GetWidget() ); + gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + } -void MainFrame::OnDropGroupNewgroup() -{ + YZ_Side_Shown_Construct( window ); -} + g_floating_windows.push_back( window ); + } -void MainFrame::OnDropGroupRemove() -{ - /* - Select_AddToGroup("World"); - Sys_UpdateWindows (W_ALL); - */ -} + { + GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) ); + g_page_textures = GroupDialog_addPage( "Textures", ui::Widget(GTK_WIDGET( frame )), TextureBrowserExportTitleCaller() ); + } -// NOTE: it's called OnFaceFit() but we want to process everything here, faces and patches -void MainFrame::OnFaceFit() -{ - SurfaceDlgFitAll(); -} + GroupDialog_show(); + } + else // 4 way + { + m_pCamWnd = NewCamWnd(); + GlobalCamera_setCamWnd( *m_pCamWnd ); + CamWnd_setParent( *m_pCamWnd, window ); -void MainFrame::OnDontselectmodel() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "tb_dontselectmodel")); - g_bIgnoreCommands++; - g_PrefsDlg.m_bSelectModels ^= 1; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), (g_PrefsDlg.m_bSelectModels) ? FALSE : TRUE); - g_bIgnoreCommands--; -} + ui::Widget camera = CamWnd_getWidget( *m_pCamWnd ); -void MainFrame::OnViewTexture() -{ - if (FloatingGroupDialog()) // QE4 style - { - if (inspector_mode == W_TEXTURE) - { - if (GTK_WIDGET_VISIBLE (g_qeglobals_gui.d_entity)) - widget_delete_hide (g_qeglobals_gui.d_entity); - else - gtk_widget_show (g_qeglobals_gui.d_entity); - } else - { - gtk_widget_show (g_qeglobals_gui.d_entity); - SetInspectorMode (W_TEXTURE); - } - } -} - -void MainFrame::OnPatchInspector() -{ - TogglePatchInspector(); -} + m_pYZWnd = new XYWnd(); + m_pYZWnd->SetViewType( YZ ); -void MainFrame::OnCurveNegativeTextureX() -{ - Patch_InvertTexture(false); - //Sys_UpdateWindows(W_ALL); -} + ui::Widget yz = m_pYZWnd->GetWidget(); -void MainFrame::OnCurveNegativeTextureY() -{ - Patch_InvertTexture(true); - //Sys_UpdateWindows(W_ALL); -} + m_pXYWnd = new XYWnd(); + m_pXYWnd->SetViewType( XY ); -void MainFrame::OnCurveInsertcolumn() -{ - if (&selected_brushes == selected_brushes.next) - return; - Undo_Start("insert colum"); - Undo_AddBrushList(&selected_brushes); - //Patch_AdjustSelectedRowCols(0, 2); - Patch_AdjustSelected(true, true, true); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} - -void MainFrame::OnCurveInsertrow() -{ - if (&selected_brushes == selected_brushes.next) - return; - Undo_Start("insert row"); - Undo_AddBrushList(&selected_brushes); - //Patch_AdjustSelectedRowCols(2, 0); - Patch_AdjustSelected(true, false, true); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} - -void MainFrame::OnCurveDeletecolumn() -{ - if (&selected_brushes == selected_brushes.next) - return; - Undo_Start("delete column"); - Undo_AddBrushList(&selected_brushes); - Patch_AdjustSelected(false, true, true); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + ui::Widget xy = m_pXYWnd->GetWidget(); -void MainFrame::OnCurveDeleterow() -{ - if (&selected_brushes == selected_brushes.next) - return; - Undo_Start("delete row"); - Undo_AddBrushList(&selected_brushes); - Patch_AdjustSelected(false, false, true); - Sys_UpdateWindows(W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + m_pXZWnd = new XYWnd(); + m_pXZWnd->SetViewType( XZ ); -void MainFrame::OnPatchTab() -{ - if (g_bPatchBendMode) - Patch_BendHandleTAB(); -// else if (g_bPatchInsertMode) -// Patch_InsDelHandleTAB(); - else - { - // check to see if the selected brush is part of a func group - // if it is, deselect everything and reselect the next brush - // in the group - brush_t *b2, *b = selected_brushes.next; - entity_t * e; - if (b != &selected_brushes) - { - if (strcmpi(b->owner->eclass->name, "worldspawn") != 0) - { - e = b->owner; - Select_Deselect(); - for (b2 = e->brushes.onext ; b2 != &e->brushes ; b2 = b2->onext) - { - if (b == b2) - { - b2 = b2->onext; - break; - } - } - if (b2 == &e->brushes) - b2 = b2->onext; - - Select_Brush(b2, false); - Sys_UpdateWindows(W_ALL); - } - } - } -} - -void MainFrame::OnCameraForward(bool keydown) -{ - if (g_PrefsDlg.m_bCamDiscrete && (m_pCamWnd && !m_pCamWnd->m_bFreeMove) ) - { - if(keydown) - { - VectorMA (m_pCamWnd->Camera()->origin, SPEED_MOVE, m_pCamWnd->Camera()->forward, m_pCamWnd->Camera()->origin); - int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA); - Sys_UpdateWindows (nUpdate); - } - } - else { - if (keydown) - m_pCamWnd->Camera()->movementflags |= MOVE_FORWARD; - else - m_pCamWnd->Camera()->movementflags &= ~MOVE_FORWARD; - } -} - -void MainFrame::OnCameraBack(bool keydown) -{ - if (g_PrefsDlg.m_bCamDiscrete && (m_pCamWnd && !m_pCamWnd->m_bFreeMove) ) - { - if(keydown) - { - VectorMA (m_pCamWnd->Camera()->origin, -SPEED_MOVE, m_pCamWnd->Camera()->forward, m_pCamWnd->Camera()->origin); - int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA); - Sys_UpdateWindows (nUpdate); - } - } - else { - if (keydown) - m_pCamWnd->Camera()->movementflags |= MOVE_BACK; - else - m_pCamWnd->Camera()->movementflags &= ~MOVE_BACK; - } -} - -void MainFrame::OnCameraLeft(bool keydown) -{ - if (m_pCamWnd) - { - if (m_pCamWnd->m_bFreeMove) - { - OnCameraStrafeleft(keydown); - return; - } - } - - if (g_PrefsDlg.m_bCamDiscrete) - { - if(keydown) - { - m_pCamWnd->Camera()->angles[1] += SPEED_TURN; - int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA); - Sys_UpdateWindows (nUpdate); - } - } - else { - if (keydown) - m_pCamWnd->Camera()->movementflags |= MOVE_ROTLEFT; - else - m_pCamWnd->Camera()->movementflags &= ~MOVE_ROTLEFT; - } -} - -void MainFrame::OnCameraRight(bool keydown) -{ - if (m_pCamWnd) - { - if (m_pCamWnd->m_bFreeMove) - { - OnCameraStraferight(keydown); - return; - } - } - - if (g_PrefsDlg.m_bCamDiscrete) - { - if(keydown) - { - m_pCamWnd->Camera()->angles[1] -= SPEED_TURN; - int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA); - Sys_UpdateWindows (nUpdate); - } - } - else { - if (keydown) - m_pCamWnd->Camera()->movementflags |= MOVE_ROTRIGHT; - else - m_pCamWnd->Camera()->movementflags &= ~MOVE_ROTRIGHT; - } -} - -void MainFrame::OnCameraUp() -{ - m_pCamWnd->Camera()->origin[2] += SPEED_MOVE; - int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY | W_Z) : (W_CAMERA); - Sys_UpdateWindows (nUpdate); -} + ui::Widget xz = m_pXZWnd->GetWidget(); -void MainFrame::OnCameraDown() -{ - m_pCamWnd->Camera()->origin[2] -= SPEED_MOVE; - int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY | W_Z) : (W_CAMERA); - Sys_UpdateWindows (nUpdate); -} + GtkHPaned* split = create_split_views( camera, yz, xy, xz ); + gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( split ), TRUE, TRUE, 0 ); -void MainFrame::OnCameraAngleup() -{ - m_pCamWnd->Camera()->angles[0] += SPEED_TURN; - if (m_pCamWnd->Camera()->angles[0] > 85) - m_pCamWnd->Camera()->angles[0] = 85; - Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY); -} + { + GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( window ) ); + g_page_textures = GroupDialog_addPage( "Textures", ui::Widget(GTK_WIDGET( frame )), TextureBrowserExportTitleCaller() ); + } + } -void MainFrame::OnCameraAngledown() -{ - m_pCamWnd->Camera()->angles[0] -= SPEED_TURN; - if (m_pCamWnd->Camera()->angles[0] < -85) - m_pCamWnd->Camera()->angles[0] = -85; - Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY); -} + EntityList_constructWindow( window ); + PreferencesDialog_constructWindow( window ); + FindTextureDialog_constructWindow( window ); + SurfaceInspector_constructWindow( window ); + PatchInspector_constructWindow( window ); -void MainFrame::OnCameraStrafeleft(bool keydown) -{ - // FIXME: as soon as gtk supports proper keyup/down support, remove this bit - if (m_pCamWnd) - { - if (!m_pCamWnd->m_bFreeMove) - { - if(keydown) - { - VectorMA (m_pCamWnd->Camera()->origin, -SPEED_MOVE, m_pCamWnd->Camera()->right, m_pCamWnd->Camera()->origin); - int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA); - Sys_UpdateWindows (nUpdate); - } - return; - } - } - - if (keydown) - m_pCamWnd->Camera()->movementflags |= MOVE_STRAFELEFT; - else - m_pCamWnd->Camera()->movementflags &= ~MOVE_STRAFELEFT; -} - -void MainFrame::OnCameraStraferight(bool keydown) -{ - // FIXME: as soon as gtk supports proper keyup/down support, remove this bit - if (m_pCamWnd) - { - if (!m_pCamWnd->m_bFreeMove) - { - if(keydown) - { - VectorMA (m_pCamWnd->Camera()->origin, SPEED_MOVE, m_pCamWnd->Camera()->right, m_pCamWnd->Camera()->origin); - int nUpdate = (g_PrefsDlg.m_bCamXYUpdate) ? (W_CAMERA | W_XY) : (W_CAMERA); - Sys_UpdateWindows (nUpdate); - } - return; - } - } - - if (keydown) - m_pCamWnd->Camera()->movementflags |= MOVE_STRAFERIGHT; - else - m_pCamWnd->Camera()->movementflags &= ~MOVE_STRAFERIGHT; -} - -void MainFrame::OnGridToggle() -{ - g_qeglobals.d_showgrid = !g_qeglobals.d_showgrid; - Sys_UpdateWindows (W_XY|W_Z); -} + SetActiveXY( m_pXYWnd ); -void MainFrame::OnViewCrosshair() -{ - g_bCrossHairs ^= 1; - Sys_UpdateWindows (W_XY); -} + AddGridChangeCallback( SetGridStatusCaller( *this ) ); + AddGridChangeCallback( ReferenceCaller( *this ) ); -void MainFrame::OnSelectionTextureRotateclock() -{ - Select_RotateTexture(abs(g_PrefsDlg.m_nRotation)); -} + g_defaultToolMode = DragMode; + g_defaultToolMode(); + SetStatusText( m_command_status, c_TranslateMode_status ); -void MainFrame::OnSelectionTextureRotatecounter() -{ - Select_RotateTexture(-abs(g_PrefsDlg.m_nRotation)); -} + EverySecondTimer_enable(); -void MainFrame::OnSelectionTextureScaleup() -{ - Select_ScaleTexture(0, g_qeglobals.d_savedinfo.m_SIIncrement.scale[1]); + //GlobalShortcuts_reportUnregistered(); } -void MainFrame::OnSelectionTextureScaledown() -{ - Select_ScaleTexture(0, -g_qeglobals.d_savedinfo.m_SIIncrement.scale[1]); -} +void MainFrame::SaveWindowInfo(){ + if ( !FloatingGroupDialog() ) { + g_layout_globals.nXYHeight = gtk_paned_get_position( GTK_PANED( m_vSplit ) ); -void MainFrame::OnSelectionTextureScaleLeft() -{ - Select_ScaleTexture(-g_qeglobals.d_savedinfo.m_SIIncrement.scale[0],0); -} + if ( CurrentStyle() != eRegular ) { + g_layout_globals.nCamWidth = gtk_paned_get_position( GTK_PANED( m_hSplit ) ); + } + else + { + g_layout_globals.nXYWidth = gtk_paned_get_position( GTK_PANED( m_hSplit ) ); + } -void MainFrame::OnSelectionTextureScaleRight() -{ - Select_ScaleTexture(g_qeglobals.d_savedinfo.m_SIIncrement.scale[0],0); -} + g_layout_globals.nCamHeight = gtk_paned_get_position( GTK_PANED( m_vSplit2 ) ); + } -void MainFrame::OnSelectionTextureShiftleft() -{ - Select_ShiftTexture((int)-g_qeglobals.d_savedinfo.m_SIIncrement.shift[0], 0); -} + g_layout_globals.m_position = m_position_tracker.getPosition(); -void MainFrame::OnSelectionTextureShiftright() -{ - Select_ShiftTexture((int)g_qeglobals.d_savedinfo.m_SIIncrement.shift[0], 0); + g_layout_globals.nState = gdk_window_get_state( gtk_widget_get_window(GTK_WIDGET( m_window )) ); } -void MainFrame::OnSelectionTextureShiftup() -{ - Select_ShiftTexture(0, (int)g_qeglobals.d_savedinfo.m_SIIncrement.shift[1]); -} +void MainFrame::Shutdown(){ + EverySecondTimer_disable(); -void MainFrame::OnSelectionTextureShiftdown() -{ - Select_ShiftTexture(0, (int)-g_qeglobals.d_savedinfo.m_SIIncrement.shift[1]); -} + EntityList_destroyWindow(); -void MainFrame::OnGridPrev() -{ - GtkWidget *item; - if (g_qeglobals.d_gridsize == 1) - { - g_qeglobals.d_gridsize = 0.5; - g_qeglobals.d_bSmallGrid = true; - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_05")); - } else if (g_qeglobals.d_gridsize == 0.5) - { - g_qeglobals.d_gridsize = 0.25; - g_qeglobals.d_bSmallGrid = true; - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_025")); - } else if (g_qeglobals.d_gridsize > 1) - { - g_qeglobals.d_gridsize = (int)g_qeglobals.d_gridsize >> 1; - g_qeglobals.d_bSmallGrid = false; - - switch ((int)g_qeglobals.d_gridsize) - { - case 1: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_1")); break; - case 2: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_2")); break; - case 4: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_4")); break; - case 8: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_8")); break; - case 16: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_16")); break; - case 32: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_32")); break; - case 64: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_64")); break; - case 128: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_128")); break; - case 256: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_256")); break; - } - - } else - return; - - // SnapTToGrid option: need to check everywhere the grid size is changed - // this is a bit clumsy, have to do in OnGrid OnGridPrev and OnGridNext - if (g_PrefsDlg.m_bSnapTToGrid) - DoSnapTToGrid(); - - SetGridStatus(); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - g_bIgnoreCommands--; - - Sys_UpdateWindows(W_XY | W_Z); -} - -void MainFrame::OnGridNext() -{ - GtkWidget *item; - if (g_qeglobals.d_gridsize == 0.25) - { - g_qeglobals.d_gridsize = 0.5; - g_qeglobals.d_bSmallGrid = true; - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_05")); - } else if (g_qeglobals.d_gridsize == 0.5) - { - g_qeglobals.d_gridsize = 1; - g_qeglobals.d_bSmallGrid = false; - item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_1")); - } else if (g_qeglobals.d_gridsize < 256) - { - g_qeglobals.d_gridsize = (int)g_qeglobals.d_gridsize << 1; - g_qeglobals.d_bSmallGrid = false; - - switch ((int)g_qeglobals.d_gridsize) - { - case 1: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_1")); break; - case 2: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_2")); break; - case 4: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_4")); break; - case 8: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_8")); break; - case 16: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_16")); break; - case 32: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_32")); break; - case 64: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_64")); break; - case 128: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_128")); break; - case 256: item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_grid_256")); break; - default: item = NULL; - } - - } else - return; - - // SnapTToGrid option: need to check everywhere the grid size is changed - // this is a bit clumsy, have to do in OnGrid OnGridPrev and OnGridNext - if (g_PrefsDlg.m_bSnapTToGrid) - DoSnapTToGrid(); - - SetGridStatus(); - g_bIgnoreCommands++; - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - g_bIgnoreCommands--; - - Sys_UpdateWindows(W_XY | W_Z); -} - -void MainFrame::OnSelectionMovedown() -{ - if (&selected_brushes == selected_brushes.next) - return; - Undo_Start("move down"); - Undo_AddBrushList(&selected_brushes); + delete m_pXYWnd; + m_pXYWnd = 0; + delete m_pYZWnd; + m_pYZWnd = 0; + delete m_pXZWnd; + m_pXZWnd = 0; - vec3_t vAmt; - vAmt[0] = vAmt[1] = 0.0; - vAmt[2] = -g_qeglobals.d_gridsize; - Select_Move (vAmt); - Sys_UpdateWindows(W_CAMERA | W_XY | W_Z); + TextureBrowser_destroyWindow(); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} + DeleteCamWnd( m_pCamWnd ); + m_pCamWnd = 0; -void MainFrame::OnSelectionMoveup() -{ - if (&selected_brushes == selected_brushes.next) - return; - Undo_Start("move up"); - Undo_AddBrushList(&selected_brushes); + PreferencesDialog_destroyWindow(); + SurfaceInspector_destroyWindow(); + FindTextureDialog_destroyWindow(); + PatchInspector_destroyWindow(); - vec3_t vAmt; - vAmt[0] = vAmt[1] = 0.0; - vAmt[2] = g_qeglobals.d_gridsize; - Select_Move (vAmt); - Sys_UpdateWindows(W_CAMERA | W_XY | W_Z); + g_DbgDlg.destroyWindow(); - Undo_EndBrushList(&selected_brushes); - Undo_End(); + // destroying group-dialog last because it may contain texture-browser + GroupDialog_destroyWindow(); } -void MainFrame::OnSelectionPrint() -{ - for (brush_t* b=selected_brushes.next ; b != &selected_brushes ; b=b->next) - Brush_Print(b); +void MainFrame::RedrawStatusText(){ + gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_command_status] ), m_command_status.c_str() ); + gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_position_status] ), m_position_status.c_str() ); + gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_brushcount_status] ), m_brushcount_status.c_str() ); + gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_texture_status] ), m_texture_status.c_str() ); + gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_grid_status] ), m_grid_status.c_str() ); } -void MainFrame::OnSelectionTogglesizepaint() -{ - g_PrefsDlg.m_bSizePaint = !g_PrefsDlg.m_bSizePaint; - Sys_UpdateWindows(W_XY); +void MainFrame::UpdateStatusText(){ + m_idleRedrawStatusText.queueDraw(); } -void MainFrame::OnPatchNaturalize() -{ - Patch_NaturalizeSelected(); - Sys_UpdateWindows (W_ALL); +void MainFrame::SetStatusText( CopiedString& status_text, const char* pText ){ + status_text = pText; + UpdateStatusText(); } -void MainFrame::OnSnapToGrid() -{ - if (&selected_brushes == selected_brushes.next) - return; - Undo_Start("snap selection to grid"); - Undo_AddBrushList(&selected_brushes); - //Select_SnapToGrid(); - for (brush_t *pb = selected_brushes.next ; pb != &selected_brushes ; pb = pb->next) - { - if (pb->patchBrush) - Patch_SnapToGrid(pb->pPatch); - else - Brush_SnapToGrid(pb); - } - Sys_UpdateWindows (W_ALL); - Undo_EndBrushList(&selected_brushes); - Undo_End(); -} - -void MainFrame::OnSelectAll() -{ - Select_AllOfType(); +void Sys_Status( const char* status ){ + if ( g_pParentWnd != 0 ) { + g_pParentWnd->SetStatusText( g_pParentWnd->m_command_status, status ); + } } -void MainFrame::OnSelectionInvert() -{ - Select_Invert(); - Sys_UpdateWindows(W_XY | W_Z | W_CAMERA); +int getRotateIncrement(){ + return static_cast( g_si_globals.rotate ); } +int getFarClipDistance(){ + return g_camwindow_globals.m_nCubicScale; +} -void PerformFiltering () -{ - brush_t *brush; - - // mattn - this should be removed - otherwise the filters from the - // plugins are wiped away with each update -#if 0 - // spog - deletes old filters list and creates new one when - // g_qeglobals.d_savedinfo.exclude is updated - g_qeglobals.d_savedinfo.filters = FilterListDelete(g_qeglobals.d_savedinfo.filters); - g_qeglobals.d_savedinfo.filters = FilterUpdate(g_qeglobals.d_savedinfo.filters); -#endif - - for ( brush = active_brushes.next; brush != &active_brushes; brush = brush->next ) - brush->bFiltered = FilterBrush( brush ); +float ( *GridStatus_getGridSize )() = GetGridSize; +int ( *GridStatus_getRotateIncrement )() = getRotateIncrement; +int ( *GridStatus_getFarClipDistance )() = getFarClipDistance; +bool ( *GridStatus_getTextureLockEnabled )(); - for ( brush = selected_brushes.next; brush != &selected_brushes; brush = brush->next ) - brush->bFiltered = FilterBrush( brush ); +void MainFrame::SetGridStatus(){ + StringOutputStream status( 64 ); + const char* lock = ( GridStatus_getTextureLockEnabled() ) ? "ON" : "OFF"; + status << ( GetSnapGridSize() > 0 ? "G:" : "g:" ) << GridStatus_getGridSize() + << " R:" << GridStatus_getRotateIncrement() + << " C:" << GridStatus_getFarClipDistance() + << " L:" << lock; + SetStatusText( m_grid_status, status.c_str() ); } -void MainFrame::OnFilterAreaportals() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_areaportals")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_AREAPORTALS) & EXCLUDE_AREAPORTALS) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterCaulk() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_caulk")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CAULK) & EXCLUDE_CAULK) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterClips() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_clips")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CLIP) & EXCLUDE_CLIP) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterBotClips() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_botclips")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_BOTCLIP) & EXCLUDE_BOTCLIP) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterStructural() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_structural")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_STRUCTURAL) & EXCLUDE_STRUCTURAL) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterDetails() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_details")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_DETAILS) & EXCLUDE_DETAILS) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterEntities() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_entities")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_ENT) & EXCLUDE_ENT) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterHintsskips() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_hintsskips")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_HINTSSKIPS) & EXCLUDE_HINTSSKIPS) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterLights() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_lights")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_LIGHTS) & EXCLUDE_LIGHTS) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterLiquids() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_liquids")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_LIQUIDS) & EXCLUDE_LIQUIDS) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterModels() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_models")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_MODELS) & EXCLUDE_MODELS) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterPatches() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_patches")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CURVES) & EXCLUDE_CURVES) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterPaths() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_paths")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_PATHS) & EXCLUDE_PATHS) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterClusterportals() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_clusterportals")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CLUSTERPORTALS) & EXCLUDE_CLUSTERPORTALS) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterLightgrid() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_lightgrid")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_LIGHTGRID) & EXCLUDE_LIGHTGRID) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterTranslucent() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_translucent")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_TRANSLUCENT) & EXCLUDE_TRANSLUCENT) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterTriggers() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_triggers")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_TRIGGERS) & EXCLUDE_TRIGGERS) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); -} - -void MainFrame::OnFilterWorld() -{ - GtkWidget *item = GTK_WIDGET (g_object_get_data (G_OBJECT (m_pWidget), "menu_filter_world")); - g_bIgnoreCommands++; - if ((g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_WORLD) & EXCLUDE_WORLD) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - else - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE); - g_bIgnoreCommands--; - PerformFiltering(); - Sys_UpdateWindows (W_XY|W_CAMERA); +void GridStatus_onTextureLockEnabledChanged(){ + if ( g_pParentWnd != 0 ) { + g_pParentWnd->SetGridStatus(); + } } +void GlobalGL_sharedContextCreated(){ + GLFont *g_font = NULL; + // report OpenGL information + globalOutputStream() << "GL_VENDOR: " << reinterpret_cast( glGetString( GL_VENDOR ) ) << "\n"; + globalOutputStream() << "GL_RENDERER: " << reinterpret_cast( glGetString( GL_RENDERER ) ) << "\n"; + globalOutputStream() << "GL_VERSION: " << reinterpret_cast( glGetString( GL_VERSION ) ) << "\n"; + globalOutputStream() << "GL_EXTENSIONS: " << reinterpret_cast( glGetString( GL_EXTENSIONS ) ) << "\n"; + QGL_sharedContextCreated( GlobalOpenGL() ); + ShaderCache_extensionsInitialised(); + + GlobalShaderCache().realise(); + Textures_Realise(); + +#ifdef WIN32 + /* win32 is dodgy here, just use courier new then */ + g_font = glfont_create( "arial 9" ); +#else + GtkSettings *settings = gtk_settings_get_default(); + gchar *fontname; + g_object_get( settings, "gtk-font-name", &fontname, NULL ); + g_font = glfont_create( fontname ); +#endif + GlobalOpenGL().m_font = g_font; +} + +void GlobalGL_sharedContextDestroyed(){ + Textures_Unrealise(); + GlobalShaderCache().unrealise(); + + QGL_sharedContextDestroyed( GlobalOpenGL() ); +} + + +void Layout_constructPreferences( PreferencesPage& page ){ + { + const char* layouts[] = { "window1.png", "window2.png", "window3.png", "window4.png" }; + page.appendRadioIcons( + "Window Layout", + STRING_ARRAY_RANGE( layouts ), + LatchedIntImportCaller( g_Layout_viewStyle ), + IntExportCaller( g_Layout_viewStyle.m_latched ) + ); + } + page.appendCheckBox( + "", "Detachable Menus", + LatchedBoolImportCaller( g_Layout_enableDetachableMenus ), + BoolExportCaller( g_Layout_enableDetachableMenus.m_latched ) + ); + if ( !string_empty( g_pGameDescription->getKeyValue( "no_patch" ) ) ) { + page.appendCheckBox( + "", "Patch Toolbar", + LatchedBoolImportCaller( g_Layout_enablePatchToolbar ), + BoolExportCaller( g_Layout_enablePatchToolbar.m_latched ) + ); + } + page.appendCheckBox( + "", "Plugin Toolbar", + LatchedBoolImportCaller( g_Layout_enablePluginToolbar ), + BoolExportCaller( g_Layout_enablePluginToolbar.m_latched ) + ); +} + +void Layout_constructPage( PreferenceGroup& group ){ + PreferencesPage page( group.createPage( "Layout", "Layout Preferences" ) ); + Layout_constructPreferences( page ); +} + +void Layout_registerPreferencesPage(){ + PreferencesDialog_addInterfacePage( FreeCaller1() ); +} + + +#include "preferencesystem.h" +#include "stringio.h" + +void MainFrame_Construct(){ + GlobalCommands_insert( "OpenManual", FreeCaller(), Accelerator( GDK_F1 ) ); + + GlobalCommands_insert( "Sleep", FreeCaller(), Accelerator( 'P', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "NewMap", FreeCaller() ); + GlobalCommands_insert( "OpenMap", FreeCaller(), Accelerator( 'O', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "ImportMap", FreeCaller() ); + GlobalCommands_insert( "SaveMap", FreeCaller(), Accelerator( 'S', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "SaveMapAs", FreeCaller() ); + GlobalCommands_insert( "ExportSelected", FreeCaller() ); + GlobalCommands_insert( "SaveRegion", FreeCaller() ); + GlobalCommands_insert( "RefreshReferences", FreeCaller() ); + GlobalCommands_insert( "ProjectSettings", FreeCaller() ); + GlobalCommands_insert( "Exit", FreeCaller() ); + + GlobalCommands_insert( "Undo", FreeCaller(), Accelerator( 'Z', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "Redo", FreeCaller(), Accelerator( 'Y', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "Copy", FreeCaller(), Accelerator( 'C', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "Paste", FreeCaller(), Accelerator( 'V', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PasteToCamera", FreeCaller(), Accelerator( 'V', (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "CloneSelection", FreeCaller(), Accelerator( GDK_space ) ); + GlobalCommands_insert( "CloneSelectionAndMakeUnique", FreeCaller(), Accelerator( GDK_space, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "DeleteSelection", FreeCaller(), Accelerator( GDK_BackSpace ) ); + GlobalCommands_insert( "ParentSelection", FreeCaller() ); + GlobalCommands_insert( "UnSelectSelection", FreeCaller(), Accelerator( GDK_Escape ) ); + GlobalCommands_insert( "InvertSelection", FreeCaller(), Accelerator( 'I' ) ); + GlobalCommands_insert( "SelectInside", FreeCaller() ); + GlobalCommands_insert( "SelectTouching", FreeCaller() ); + GlobalCommands_insert( "ExpandSelectionToEntities", FreeCaller(), Accelerator( 'E', (GdkModifierType)( GDK_MOD1_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "Preferences", FreeCaller(), Accelerator( 'P' ) ); + + GlobalCommands_insert( "ToggleConsole", FreeCaller(), Accelerator( 'O' ) ); + GlobalCommands_insert( "ToggleEntityInspector", FreeCaller(), Accelerator( 'N' ) ); + GlobalCommands_insert( "EntityList", FreeCaller(), Accelerator( 'L' ) ); + + GlobalCommands_insert( "ShowHidden", FreeCaller(), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "HideSelected", FreeCaller(), Accelerator( 'H' ) ); + + GlobalToggles_insert( "DragVertices", FreeCaller(), ToggleItem::AddCallbackCaller( g_vertexMode_button ), Accelerator( 'V' ) ); + GlobalToggles_insert( "DragEdges", FreeCaller(), ToggleItem::AddCallbackCaller( g_edgeMode_button ), Accelerator( 'E' ) ); + GlobalToggles_insert( "DragFaces", FreeCaller(), ToggleItem::AddCallbackCaller( g_faceMode_button ), Accelerator( 'F' ) ); + + GlobalCommands_insert( "MirrorSelectionX", FreeCaller() ); + GlobalCommands_insert( "RotateSelectionX", FreeCaller() ); + GlobalCommands_insert( "MirrorSelectionY", FreeCaller() ); + GlobalCommands_insert( "RotateSelectionY", FreeCaller() ); + GlobalCommands_insert( "MirrorSelectionZ", FreeCaller() ); + GlobalCommands_insert( "RotateSelectionZ", FreeCaller() ); + + GlobalCommands_insert( "ArbitraryRotation", FreeCaller() ); + GlobalCommands_insert( "ArbitraryScale", FreeCaller() ); + + GlobalCommands_insert( "BuildMenuCustomize", FreeCaller() ); + + GlobalCommands_insert( "FindBrush", FreeCaller() ); + + GlobalCommands_insert( "MapInfo", FreeCaller(), Accelerator( 'M' ) ); + + + GlobalToggles_insert( "ToggleClipper", FreeCaller(), ToggleItem::AddCallbackCaller( g_clipper_button ), Accelerator( 'X' ) ); + + GlobalToggles_insert( "MouseTranslate", FreeCaller(), ToggleItem::AddCallbackCaller( g_translatemode_button ), Accelerator( 'W' ) ); + GlobalToggles_insert( "MouseRotate", FreeCaller(), ToggleItem::AddCallbackCaller( g_rotatemode_button ), Accelerator( 'R' ) ); + GlobalToggles_insert( "MouseScale", FreeCaller(), ToggleItem::AddCallbackCaller( g_scalemode_button ) ); + GlobalToggles_insert( "MouseDrag", FreeCaller(), ToggleItem::AddCallbackCaller( g_dragmode_button ), Accelerator( 'Q' ) ); + + GlobalCommands_insert( "ColorSchemeOriginal", FreeCaller() ); + GlobalCommands_insert( "ColorSchemeQER", FreeCaller() ); + GlobalCommands_insert( "ColorSchemeBlackAndGreen", FreeCaller() ); + GlobalCommands_insert( "ColorSchemeYdnar", FreeCaller() ); + GlobalCommands_insert( "ChooseTextureBackgroundColor", makeCallback( g_ColoursMenu.m_textureback ) ); + GlobalCommands_insert( "ChooseGridBackgroundColor", makeCallback( g_ColoursMenu.m_xyback ) ); + GlobalCommands_insert( "ChooseGridMajorColor", makeCallback( g_ColoursMenu.m_gridmajor ) ); + GlobalCommands_insert( "ChooseGridMinorColor", makeCallback( g_ColoursMenu.m_gridminor ) ); + GlobalCommands_insert( "ChooseSmallGridMajorColor", makeCallback( g_ColoursMenu.m_gridmajor_alt ) ); + GlobalCommands_insert( "ChooseSmallGridMinorColor", makeCallback( g_ColoursMenu.m_gridminor_alt ) ); + GlobalCommands_insert( "ChooseGridTextColor", makeCallback( g_ColoursMenu.m_gridtext ) ); + GlobalCommands_insert( "ChooseGridBlockColor", makeCallback( g_ColoursMenu.m_gridblock ) ); + GlobalCommands_insert( "ChooseBrushColor", makeCallback( g_ColoursMenu.m_brush ) ); + GlobalCommands_insert( "ChooseCameraBackgroundColor", makeCallback( g_ColoursMenu.m_cameraback ) ); + GlobalCommands_insert( "ChooseSelectedBrushColor", makeCallback( g_ColoursMenu.m_selectedbrush ) ); + GlobalCommands_insert( "ChooseCameraSelectedBrushColor", makeCallback( g_ColoursMenu.m_selectedbrush3d ) ); + GlobalCommands_insert( "ChooseClipperColor", makeCallback( g_ColoursMenu.m_clipper ) ); + GlobalCommands_insert( "ChooseOrthoViewNameColor", makeCallback( g_ColoursMenu.m_viewname ) ); + + + GlobalCommands_insert( "CSGSubtract", FreeCaller(), Accelerator( 'U', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "CSGMerge", FreeCaller(), Accelerator( 'U', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "CSGHollow", FreeCaller() ); + + Grid_registerCommands(); + + GlobalCommands_insert( "SnapToGrid", FreeCaller(), Accelerator( 'G', (GdkModifierType)GDK_CONTROL_MASK ) ); + + GlobalCommands_insert( "SelectAllOfType", FreeCaller(), Accelerator( 'A', (GdkModifierType)GDK_SHIFT_MASK ) ); + + GlobalCommands_insert( "TexRotateClock", FreeCaller(), Accelerator( GDK_Next, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexRotateCounter", FreeCaller(), Accelerator( GDK_Prior, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexScaleUp", FreeCaller(), Accelerator( GDK_Up, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexScaleDown", FreeCaller(), Accelerator( GDK_Down, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexScaleLeft", FreeCaller(), Accelerator( GDK_Left, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexScaleRight", FreeCaller(), Accelerator( GDK_Right, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "TexShiftUp", FreeCaller(), Accelerator( GDK_Up, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexShiftDown", FreeCaller(), Accelerator( GDK_Down, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexShiftLeft", FreeCaller(), Accelerator( GDK_Left, (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "TexShiftRight", FreeCaller(), Accelerator( GDK_Right, (GdkModifierType)GDK_SHIFT_MASK ) ); + + GlobalCommands_insert( "MoveSelectionDOWN", FreeCaller(), Accelerator( GDK_KP_Subtract ) ); + GlobalCommands_insert( "MoveSelectionUP", FreeCaller(), Accelerator( GDK_KP_Add ) ); + + GlobalCommands_insert( "SelectNudgeLeft", FreeCaller(), Accelerator( GDK_Left, (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "SelectNudgeRight", FreeCaller(), Accelerator( GDK_Right, (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "SelectNudgeUp", FreeCaller(), Accelerator( GDK_Up, (GdkModifierType)GDK_MOD1_MASK ) ); + GlobalCommands_insert( "SelectNudgeDown", FreeCaller(), Accelerator( GDK_Down, (GdkModifierType)GDK_MOD1_MASK ) ); + + Patch_registerCommands(); + XYShow_registerCommands(); + + typedef FreeCaller1 ComponentModeSelectionChangedCaller; + GlobalSelectionSystem().addSelectionChangeCallback( ComponentModeSelectionChangedCaller() ); + + GlobalPreferenceSystem().registerPreference( "DetachableMenus", BoolImportStringCaller( g_Layout_enableDetachableMenus.m_latched ), BoolExportStringCaller( g_Layout_enableDetachableMenus.m_latched ) ); + GlobalPreferenceSystem().registerPreference( "PatchToolBar", BoolImportStringCaller( g_Layout_enablePatchToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePatchToolbar.m_latched ) ); + GlobalPreferenceSystem().registerPreference( "PluginToolBar", BoolImportStringCaller( g_Layout_enablePluginToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePluginToolbar.m_latched ) ); + GlobalPreferenceSystem().registerPreference( "QE4StyleWindows", IntImportStringCaller( g_Layout_viewStyle.m_latched ), IntExportStringCaller( g_Layout_viewStyle.m_latched ) ); + GlobalPreferenceSystem().registerPreference( "XYHeight", IntImportStringCaller( g_layout_globals.nXYHeight ), IntExportStringCaller( g_layout_globals.nXYHeight ) ); + GlobalPreferenceSystem().registerPreference( "XYWidth", IntImportStringCaller( g_layout_globals.nXYWidth ), IntExportStringCaller( g_layout_globals.nXYWidth ) ); + GlobalPreferenceSystem().registerPreference( "CamWidth", IntImportStringCaller( g_layout_globals.nCamWidth ), IntExportStringCaller( g_layout_globals.nCamWidth ) ); + GlobalPreferenceSystem().registerPreference( "CamHeight", IntImportStringCaller( g_layout_globals.nCamHeight ), IntExportStringCaller( g_layout_globals.nCamHeight ) ); + + GlobalPreferenceSystem().registerPreference( "State", IntImportStringCaller( g_layout_globals.nState ), IntExportStringCaller( g_layout_globals.nState ) ); + GlobalPreferenceSystem().registerPreference( "PositionX", IntImportStringCaller( g_layout_globals.m_position.x ), IntExportStringCaller( g_layout_globals.m_position.x ) ); + GlobalPreferenceSystem().registerPreference( "PositionY", IntImportStringCaller( g_layout_globals.m_position.y ), IntExportStringCaller( g_layout_globals.m_position.y ) ); + GlobalPreferenceSystem().registerPreference( "Width", IntImportStringCaller( g_layout_globals.m_position.w ), IntExportStringCaller( g_layout_globals.m_position.w ) ); + GlobalPreferenceSystem().registerPreference( "Height", IntImportStringCaller( g_layout_globals.m_position.h ), IntExportStringCaller( g_layout_globals.m_position.h ) ); + + GlobalPreferenceSystem().registerPreference( "CamWnd", WindowPositionTrackerImportStringCaller( g_posCamWnd ), WindowPositionTrackerExportStringCaller( g_posCamWnd ) ); + GlobalPreferenceSystem().registerPreference( "XYWnd", WindowPositionTrackerImportStringCaller( g_posXYWnd ), WindowPositionTrackerExportStringCaller( g_posXYWnd ) ); + GlobalPreferenceSystem().registerPreference( "YZWnd", WindowPositionTrackerImportStringCaller( g_posYZWnd ), WindowPositionTrackerExportStringCaller( g_posYZWnd ) ); + GlobalPreferenceSystem().registerPreference( "XZWnd", WindowPositionTrackerImportStringCaller( g_posXZWnd ), WindowPositionTrackerExportStringCaller( g_posXZWnd ) ); + + { + const char* ENGINEPATH_ATTRIBUTE = +#if defined( WIN32 ) + "enginepath_win32" +#elif defined( __APPLE__ ) + "enginepath_macos" +#elif defined( __linux__ ) || defined ( __FreeBSD__ ) + "enginepath_linux" +#else +#error "unknown platform" +#endif + ; + StringOutputStream path( 256 ); + path << DirectoryCleaned( g_pGameDescription->getRequiredKeyValue( ENGINEPATH_ATTRIBUTE ) ); + g_strEnginePath = path.c_str(); + } + GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) ); + g_Layout_viewStyle.useLatched(); + g_Layout_enableDetachableMenus.useLatched(); + g_Layout_enablePatchToolbar.useLatched(); + g_Layout_enablePluginToolbar.useLatched(); -// ============================================================================= -// leo: Unused functions, not called anywhere from the code (need to check) + Layout_registerPreferencesPage(); + Paths_registerPreferencesPage(); -void MainFrame::OnViewConsole() -{ - if (FloatingGroupDialog()) // QE4 style - { - if (inspector_mode == W_CONSOLE && CurrentStyle() != MainFrame::eFloating) // are we in console mode already? - { - if (GTK_WIDGET_VISIBLE (g_qeglobals_gui.d_entity)) - widget_delete_hide (g_qeglobals_gui.d_entity); - else - gtk_widget_show (g_qeglobals_gui.d_entity); - } else - { - gtk_widget_show (g_qeglobals_gui.d_entity); - SetInspectorMode(W_CONSOLE); - } - } -} - -void MainFrame::OnCurveFreeze() -{ - Patch_Freeze(); -} + g_brushCount.setCountChangedCallback( FreeCaller() ); + g_entityCount.setCountChangedCallback( FreeCaller() ); + GlobalEntityCreator().setCounter( &g_entityCount ); -void MainFrame::OnCurveUnFreeze() -{ - Patch_UnFreeze(false); -} + GLWidget_sharedContextCreated = GlobalGL_sharedContextCreated; + GLWidget_sharedContextDestroyed = GlobalGL_sharedContextDestroyed; -void MainFrame::OnCurveUnFreezeAll() -{ - Patch_UnFreeze(true); + GlobalEntityClassManager().attach( g_WorldspawnColourEntityClassObserver ); } -void MainFrame::OnSelectReselect() -{ - Select_Reselect(); -} +void MainFrame_Destroy(){ + GlobalEntityClassManager().detach( g_WorldspawnColourEntityClassObserver ); -void MainFrame::OnSelectionTextureFit() -{ - // TODO: Add your command handler code here + GlobalEntityCreator().setCounter( 0 ); + g_entityCount.setCountChangedCallback( Callback() ); + g_brushCount.setCountChangedCallback( Callback() ); } -void MainFrame::OnPatchEnter() -{ +void GLWindow_Construct(){ + GlobalPreferenceSystem().registerPreference( "MouseButtons", IntImportStringCaller( g_glwindow_globals.m_nMouseType ), IntExportStringCaller( g_glwindow_globals.m_nMouseType ) ); } -void MainFrame::OnDropGroupAddtoWorld() -{ - /* - Select_AddToGroup("World"); - Sys_UpdateWindows (W_ALL); - */ +void GLWindow_Destroy(){ }