]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/camwindow.cpp
cleaned up duplicated doom3 light_radius default value
[xonotic/netradiant.git] / radiant / camwindow.cpp
index 057e6aa888ae9ede42d87426d410425fb273350b..62e209b8b58a77e7d2410c88c53424ae383a0da9 100644 (file)
@@ -37,7 +37,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "renderable.h"
 #include "preferencesystem.h"
 
-#include "generic/callback.h"
+#include "signal/signal.h"
 #include "container/array.h"
 #include "scenelib.h"
 #include "render.h"
@@ -60,16 +60,16 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "timer.h"
 
-std::vector<Callback> g_cameraMoved_callbacks;
+Signal0 g_cameraMoved_callbacks;
 
-void AddCameraMovedCallback(const Callback& callback)
+void AddCameraMovedCallback(const SignalHandler& handler)
 {
-  g_cameraMoved_callbacks.push_back(callback);
+  g_cameraMoved_callbacks.connectLast(handler);
 }
 
 void CameraMovedNotify()
 {
-  std::for_each(g_cameraMoved_callbacks.begin(), g_cameraMoved_callbacks.end(), CallbackInvoke());
+  g_cameraMoved_callbacks();
 }
 
 
@@ -1120,6 +1120,7 @@ void CamWnd_Move_Discrete_Import(bool value)
 }
 
 
+
 void CamWnd_Add_Handlers_Move(CamWnd& camwnd)
 {
   camwnd.m_selection_button_press_handler = g_signal_connect(G_OBJECT(camwnd.m_gl_widget), "button_press_event", G_CALLBACK(selection_button_press), camwnd.m_window_observer);
@@ -1532,7 +1533,7 @@ void CamWnd::Cam_Draw()
   }
 
 
-  unsigned int globalstate = RENDER_DEPTHTEST|RENDER_COLOURWRITE|RENDER_DEPTHWRITE|RENDER_ALPHATEST|RENDER_BLEND|RENDER_CULLFACE|RENDER_COLOUR|RENDER_OFFSETLINE;
+  unsigned int globalstate = RENDER_DEPTHTEST|RENDER_COLOURWRITE|RENDER_DEPTHWRITE|RENDER_ALPHATEST|RENDER_BLEND|RENDER_CULLFACE|RENDER_COLOURARRAY|RENDER_OFFSETLINE|RENDER_POLYGONSMOOTH|RENDER_LINESMOOTH|RENDER_FOG|RENDER_COLOURCHANGE;
   switch (m_Camera.draw_mode)
   {
   case cd_wire:
@@ -1752,6 +1753,11 @@ void CamWnd_constructToolbar(GtkToolbar* toolbar)
 void CamWnd_registerShortcuts()
 {
   toggle_add_accelerator("ToggleCubicClip");
+  
+  if(g_pGameDescription->mGameType == "doom3")
+  {
+    command_connect_accelerator("TogglePreview");
+  }
 }
 
 
@@ -1781,6 +1787,17 @@ void CamWnd_SetMode(camera_draw_mode mode)
   }
 }
 
+void CamWnd_TogglePreview(void)
+{
+  // gametype must be doom3 for this function to work
+  // if the gametype is not doom3 something is wrong with the
+  // global command list or somebody else calls this function.
+  ASSERT_MESSAGE(g_pGameDescription->mGameType == "doom3", "CamWnd_TogglePreview called although mGameType is not doom3 compatible");
+
+  // switch between textured and lighting mode
+  CamWnd_SetMode((CamWnd_GetMode() == cd_lighting) ? cd_texture : cd_lighting);
+}
+
 
 CameraModel* g_camera_model = 0;
 
@@ -1946,6 +1963,11 @@ void CamWnd_Construct()
   GlobalCommands_insert("LookThroughSelected", FreeCaller<GlobalCamera_LookThroughSelected>());
   GlobalCommands_insert("LookThroughCamera", FreeCaller<GlobalCamera_LookThroughCamera>());
 
+  if(g_pGameDescription->mGameType == "doom3")
+  {
+    GlobalCommands_insert("TogglePreview", FreeCaller<CamWnd_TogglePreview>(), Accelerator(GDK_F3));
+  }
+
   GlobalShortcuts_insert("CameraForward", Accelerator(GDK_Up));
   GlobalShortcuts_insert("CameraBack", Accelerator(GDK_Down));
   GlobalShortcuts_insert("CameraLeft", Accelerator(GDK_Left));