]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/camwindow.cpp
fixed camera freemove shortcuts bug
[xonotic/netradiant.git] / radiant / camwindow.cpp
index 5d5bea9f4dfb8e116102d2365fa9edafe7d93f68..73c416c6fd8623f694e544190ff33b4a175b2f46 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);
@@ -1350,9 +1351,8 @@ static gboolean camwindow_freemove_focusout(GtkWidget* widget, GdkEventFocus* ev
 
 void CamWnd::EnableFreeMove()
 {
-#if 0
-  globalOutputStream() << "EnableFreeMove\n";
-#endif
+  //globalOutputStream() << "EnableFreeMove\n";
+
   ASSERT_MESSAGE(!m_bFreeMove, "EnableFreeMove: free-move was already enabled");
   m_bFreeMove = true;
   Camera_clearMovementFlags(getCamera(), MOVE_ALL);
@@ -1369,9 +1369,8 @@ void CamWnd::EnableFreeMove()
 
 void CamWnd::DisableFreeMove()
 {
-#if 0
-  globalOutputStream() << "DisableFreeMove\n";
-#endif
+  //globalOutputStream() << "DisableFreeMove\n";
+
   ASSERT_MESSAGE(m_bFreeMove, "DisableFreeMove: free-move was not enabled");
   m_bFreeMove = false;
   Camera_clearMovementFlags(getCamera(), MOVE_ALL);
@@ -1532,7 +1531,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 +1751,11 @@ void CamWnd_constructToolbar(GtkToolbar* toolbar)
 void CamWnd_registerShortcuts()
 {
   toggle_add_accelerator("ToggleCubicClip");
+  
+  if(g_pGameDescription->mGameType == "doom3")
+  {
+    command_connect_accelerator("TogglePreview");
+  }
 }
 
 
@@ -1781,6 +1785,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;
 
@@ -1930,6 +1945,7 @@ void Camera_registerPreferencesPage()
 
 typedef FreeCaller1<bool, CamWnd_Move_Discrete_Import> CamWndMoveDiscreteImportCaller;
 
+/// \brief Initialisation for things that have the same lifespan as this module.
 void CamWnd_Construct()
 {
   GlobalCommands_insert("CenterView", FreeCaller<GlobalCamera_ResetAngles>(), Accelerator(GDK_End));
@@ -1945,6 +1961,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));