]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/mainframe.cpp
- Added option to toggle the camera window stats on/off
[xonotic/netradiant.git] / radiant / mainframe.cpp
index ee4f8cbbafce75af07fe9a8fb2ec0ee81dfcca8f..6d3f754fdb536631ff01b8722a0154ba147d3668 100644 (file)
@@ -186,7 +186,7 @@ void VFS_Destroy()
 
 void HomePaths_Realise()
 {
-#if defined (__linux__) || defined (__APPLE__)
+#if defined(POSIX)
   const char* prefix = g_pGameDescription->getKeyValue("prefix");
   if(!string_empty(prefix)) 
   {
@@ -339,6 +339,19 @@ const char* AppPath_get()
   return g_strAppPath.c_str();
 }
 
+/// 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();
+}
+
 /// directory for temp files
 /// NOTE: on *nix this is were we check for .pid
 CopiedString g_strSettingsPath;
@@ -510,10 +523,10 @@ public:
 const char* const c_library_extension =
 #if defined(WIN32)
 "dll"
-#elif defined(__linux__)
-"so"
 #elif defined (__APPLE__)
 "dylib"
+#elif defined(__linux__) || defined (__FreeBSD__)
+"so"
 #endif
 ;
 
@@ -1047,15 +1060,18 @@ public:
   }
 };
 
-FreeCaller1<const BoolImportCallback&, BoolFunctionExport<EdgeMode>::apply> g_edgeMode_button_caller;
+typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<EdgeMode>::apply> EdgeModeApplyCaller;
+EdgeModeApplyCaller g_edgeMode_button_caller;
 BoolExportCallback g_edgeMode_button_callback(g_edgeMode_button_caller);
 ToggleItem g_edgeMode_button(g_edgeMode_button_callback);
 
-FreeCaller1<const BoolImportCallback&, BoolFunctionExport<VertexMode>::apply> g_vertexMode_button_caller;
+typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<VertexMode>::apply> VertexModeApplyCaller;
+VertexModeApplyCaller g_vertexMode_button_caller;
 BoolExportCallback g_vertexMode_button_callback(g_vertexMode_button_caller);
 ToggleItem g_vertexMode_button(g_vertexMode_button_callback);
 
-FreeCaller1<const BoolImportCallback&, BoolFunctionExport<FaceMode>::apply> g_faceMode_button_caller;
+typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<FaceMode>::apply> FaceModeApplyCaller;
+FaceModeApplyCaller g_faceMode_button_caller;
 BoolExportCallback g_faceMode_button_callback(g_faceMode_button_caller);
 ToggleItem g_faceMode_button(g_faceMode_button_callback);
 
@@ -1964,6 +1980,8 @@ GtkMenuItem* create_edit_menu()
   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");
 
   GtkMenu* convert_menu = create_sub_menu_with_mnemonic(menu, "E_xpand Selection");
   create_menu_item_with_mnemonic(convert_menu, "To Whole _Entities", "ExpandSelectionToEntities");
@@ -2015,7 +2033,7 @@ GtkMenuItem* create_view_menu(MainFrame::EViewStyle style)
   if(style == MainFrame::eFloating || style == MainFrame::eSplit)
   {
     create_menu_item_with_mnemonic(menu, "Console View", "ToggleConsole");
-    create_menu_item_with_mnemonic(menu, "Texture Browser", "ViewTextures");
+    create_menu_item_with_mnemonic(menu, "Texture Browser", "ToggleTextures");
     create_menu_item_with_mnemonic(menu, "Entity Inspector", "ToggleEntityInspector");
   }
   else
@@ -2069,6 +2087,7 @@ GtkMenuItem* create_view_menu(MainFrame::EViewStyle style)
     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");
   }
 
   {
@@ -2180,44 +2199,6 @@ GtkMenuItem* create_grid_menu()
   return grid_menu_item;
 }
 
-void RefreshShaders()
-{
-  ScopeDisableScreenUpdates disableScreenUpdates("Processing...", "Loading Shaders");
-  GlobalShaderSystem().refresh();
-  UpdateAllWindows();
-}
-
-
-GtkMenuItem* create_textures_menu()
-{
-  // Textures menu
-  GtkMenuItem* textures_menu_item = new_sub_menu_item_with_mnemonic("_Textures");
-  GtkMenu* menu = GTK_MENU(gtk_menu_item_get_submenu(textures_menu_item));
-  g_textures_menu = menu;
-  if (g_Layout_enableDetachableMenus.m_value)
-    menu_tearoff (menu);
-
-  create_check_menu_item_with_mnemonic(menu, "Hide _Unused", "ShowInUse");
-  create_menu_item_with_mnemonic(menu, "Show All", "ShowAllTextures");
-
-  menu_separator(menu);
-  create_check_menu_item_with_mnemonic(menu, "Show shaders", "ToggleShowShaders");
-  create_menu_item_with_mnemonic(menu, "Flush & Reload Shaders", "RefreshShaders");
-  create_menu_item_with_mnemonic(menu, "Directory list...", "TextureDirectoryList");
-  menu_separator(menu);
-
-  create_menu_item_with_mnemonic(menu, "Find / Replace...", "FindReplaceTextures");
-
-
-  menu_separator(menu);
-  create_check_menu_item_with_mnemonic (menu, "Shaders Only", "ToggleShowShaderlistOnly");
-  g_textures_menu_separator = menu_separator(menu);
-
-  TextureGroupsMenu_Construct();
-
-  return textures_menu_item;
-}
-
 GtkMenuItem* create_misc_menu()
 {
   // Misc menu
@@ -2312,7 +2293,6 @@ GtkMenuBar* create_main_menu(MainFrame::EViewStyle 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_textures_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()));
@@ -2421,6 +2401,12 @@ void RotateFlip_constructToolbar(GtkToolbar* toolbar)
   toolbar_append_button(toolbar, "z-axis Rotate", "brush_rotatez.bmp", "RotateSelectionZ");
 }
 
+void Select_constructToolbar(GtkToolbar* toolbar)
+{
+  toolbar_append_button(toolbar, "Select touching", "selection_selecttouching.bmp", "SelectTouching");
+  toolbar_append_button(toolbar, "Select inside", "selection_selectinside.bmp", "SelectInside");
+}
+
 void CSG_constructToolbar(GtkToolbar* toolbar)
 {
   toolbar_append_button(toolbar, "CSG Subtract", "selection_csgsubtract.bmp", "CSGSubtract");
@@ -2472,6 +2458,10 @@ GtkToolbar* create_main_toolbar(MainFrame::EViewStyle style)
 
   gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
 
+  Select_constructToolbar(toolbar);
+
+  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
+
   CSG_constructToolbar(toolbar);
 
   gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
@@ -2504,6 +2494,21 @@ GtkToolbar* create_main_toolbar(MainFrame::EViewStyle style)
 
   toolbar_append_toggle_button(toolbar, "Texture Lock", "texture_lock.bmp", "TogTexLock");
 
+  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
+
+  GtkButton* g_view_entities_button = toolbar_append_button(toolbar, "Entities", "entities.bmp", "ToggleEntityInspector");
+  GtkButton* g_view_console_button = toolbar_append_button(toolbar, "Console", "console.bmp", "ToggleConsole");
+  GtkButton* g_view_textures_button = toolbar_append_button(toolbar, "Texture Browser", "texture_browser.bmp", "ToggleTextures");
+  // TODO: call light inspector
+  //GtkButton* g_view_lightinspector_button = toolbar_append_button(toolbar, "Light Inspector", "lightinspector.bmp", "ToggleLightInspector");
+
+  // 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);
+  }
+
   return toolbar;
 }
 
@@ -2541,30 +2546,6 @@ GtkWidget* create_main_statusbar(GtkWidget *pStatusLabel[c_count_status])
 
 #if 0
 
-class WidgetFocusPrinter
-{
-  const char* m_name;
-
-  static gboolean focus_in(GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self)
-  {
-    globalOutputStream() << self->m_name << " takes focus\n";
-    return FALSE;
-  }
-  static gboolean focus_out(GtkWidget *widget, GdkEventFocus *event, WidgetFocusPrinter* self)
-  {
-    globalOutputStream() << self->m_name << " loses focus\n";
-    return FALSE;
-  }
-public:
-  WidgetFocusPrinter(const char* name) : m_name(name)
-  {
-  }
-  void connect(GtkWindow* window)
-  {
-    g_signal_connect(G_OBJECT(window), "focus_in_event", G_CALLBACK(focus_in), this);
-    g_signal_connect(G_OBJECT(window), "focus_out_event", G_CALLBACK(focus_out), this);
-  }
-};
 
 WidgetFocusPrinter g_mainframeWidgetFocusPrinter("mainframe");
 
@@ -2631,6 +2612,16 @@ public:
 
 MainWindowActive g_MainWindowActive;
 
+SignalHandlerId XYWindowDestroyed_connect(const SignalHandler& handler)
+{
+  return g_pParentWnd->GetXYWnd()->onDestroyed.connectFirst(handler);
+}
+
+void XYWindowDestroyed_disconnect(SignalHandlerId id)
+{
+  g_pParentWnd->GetXYWnd()->onDestroyed.disconnect(id);
+}
+
 MouseEventHandlerId XYWindowMouseDown_connect(const MouseEventHandler& handler)
 {
   return g_pParentWnd->GetXYWnd()->onMouseDown.connectFirst(handler);
@@ -2991,7 +2982,6 @@ void MainFrame::Create()
           GtkFrame* texture_window = create_framed_widget(TextureBrowser_constructWindow(window));
 
           gtk_paned_add2(GTK_PANED(vsplit2), GTK_WIDGET(texture_window));
-         
         }
       }
     }
@@ -3175,8 +3165,6 @@ void MainFrame::Shutdown()
 
   EntityList_destroyWindow();
 
-  g_textures_menu = 0;
-
   delete m_pXYWnd;
   m_pXYWnd = 0;
   delete m_pYZWnd;
@@ -3369,6 +3357,8 @@ void MainFrame_Construct()
   GlobalCommands_insert("ParentSelection", FreeCaller<Scene_parentSelected>());
   GlobalCommands_insert("UnSelectSelection", FreeCaller<Selection_Deselect>(), Accelerator(GDK_Escape));
   GlobalCommands_insert("InvertSelection", FreeCaller<Select_Invert>(), Accelerator('I'));
+  GlobalCommands_insert("SelectInside", FreeCaller<Select_Inside>());
+  GlobalCommands_insert("SelectTouching", FreeCaller<Select_Touching>());
   GlobalCommands_insert("ExpandSelectionToEntities", FreeCaller<Scene_ExpandSelectionToEntities>(), Accelerator('E', (GdkModifierType)(GDK_MOD1_MASK|GDK_CONTROL_MASK)));
   GlobalCommands_insert("Preferences", FreeCaller<PreferencesDialog_showDialog>(), Accelerator('P'));
 
@@ -3431,10 +3421,6 @@ void MainFrame_Construct()
   GlobalCommands_insert("CSGMerge", FreeCaller<CSG_Merge>(), Accelerator('U', (GdkModifierType)GDK_CONTROL_MASK));
   GlobalCommands_insert("CSGHollow", FreeCaller<CSG_MakeHollow>());
 
-  GlobalCommands_insert("TextureDirectoryList", FreeCaller<DoTextureListDlg>());
-
-  GlobalCommands_insert("RefreshShaders", FreeCaller<RefreshShaders>());
-
   Grid_registerCommands();
 
   GlobalCommands_insert("SnapToGrid", FreeCaller<Selection_SnapToGrid>(), Accelerator('G', (GdkModifierType)GDK_CONTROL_MASK));
@@ -3463,7 +3449,8 @@ void MainFrame_Construct()
   Patch_registerCommands();
   XYShow_registerCommands();
 
-  GlobalSelectionSystem().addSelectionChangeCallback(FreeCaller1<const Selectable&, ComponentMode_SelectionChanged>());
+  typedef FreeCaller1<const Selectable&, ComponentMode_SelectionChanged> 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));
@@ -3489,7 +3476,7 @@ void MainFrame_Construct()
     const char* ENGINEPATH_ATTRIBUTE =
 #if defined(WIN32)
       "enginepath_win32"
-#elif defined(__linux__)
+#elif defined(__linux__) || defined (__FreeBSD__)
       "enginepath_linux"
 #elif defined(__APPLE__)
       "enginepath_macos"