Advertisement
Guest User

Untitled

a guest
Jun 11th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.11 KB | None | 0 0
  1. Index: binaries/data/mods/public/gui/session/hotkeys/misc.xml
  2. ===================================================================
  3. --- binaries/data/mods/public/gui/session/hotkeys/misc.xml  (revision 17965)
  4. +++ binaries/data/mods/public/gui/session/hotkeys/misc.xml  (working copy)
  5. @@ -2,10 +2,21 @@
  6.  <object>
  7.     <object hotkey="cancel">
  8.         <action on="Press">closeOpenDialogs();</action>
  9.     </object>
  10.  
  11. +   <object hotkey="cancel">
  12. +       <action on="Press">
  13. +           let list = g_Selection.toList();
  14. +           if (list.length != 1)
  15. +               return;
  16. +
  17. +           let lookAt = GetEntityState(list[0]).position;
  18. +           Engine.CameraPrintCoordinates(lookAt.x, lookAt.y, lookAt.z);
  19. +       </action>
  20. +   </object>
  21. +
  22.     <!-- Chat: Depending on the current state, it either opens message window or closes message window / posts message -->
  23.     <object hotkey="chat">
  24.         <action on="Press">toggleChatWindow();</action>
  25.     </object>
  26.  
  27. Index: source/graphics/GameView.cpp
  28. ===================================================================
  29. --- source/graphics/GameView.cpp    (revision 17965)
  30. +++ source/graphics/GameView.cpp    (working copy)
  31. @@ -905,10 +905,18 @@ float CGameView::GetCameraZ()
  32.     CCamera targetCam = m->ViewCamera;
  33.     CVector3D pivot = GetSmoothPivot(targetCam);
  34.     return pivot.Z;
  35.  }
  36.  
  37. +void CGameView::PrintCoordinates(float lookAtX, float lookAtY, float lookAtZ)
  38. +{
  39. +   debug_printf("\t\t\t<Node deltatime=\"1\">\n");
  40. +   debug_printf("\t\t\t\t<Position x=\"%f\" y=\"%f\" z=\"%f\"/>\n", GetCameraPosX(), GetCameraPosY(), GetCameraPosZ());
  41. +   debug_printf("\t\t\t\t<Target x=\"%f\" y=\"%f\" z=\"%f\"/>\n", lookAtX, lookAtY, lookAtZ);
  42. +   debug_printf("\t\t\t</Node>\n");
  43. +}
  44. +
  45.  float CGameView::GetCameraPosX()
  46.  {
  47.     return m->PosX.GetValue();
  48.  }
  49.  
  50. Index: source/graphics/GameView.h
  51. ===================================================================
  52. --- source/graphics/GameView.h  (revision 17965)
  53. +++ source/graphics/GameView.h  (working copy)
  54. @@ -80,10 +80,11 @@ public:
  55.     void BeginFrame();
  56.     void Render();
  57.  
  58.     InReaction HandleEvent(const SDL_Event_* ev);
  59.  
  60. +   void PrintCoordinates(float lookAtX, float lookAtY, float lookAtZ);
  61.     float GetCameraX();
  62.     float GetCameraZ();
  63.     float GetCameraPosX();
  64.     float GetCameraPosY();
  65.     float GetCameraPosZ();
  66. Index: source/gui/scripting/ScriptFunctions.cpp
  67. ===================================================================
  68. --- source/gui/scripting/ScriptFunctions.cpp    (revision 17965)
  69. +++ source/gui/scripting/ScriptFunctions.cpp    (working copy)
  70. @@ -531,10 +531,19 @@ float CameraGetX(ScriptInterface::CxPriv
  71.         return g_Game->GetView()->GetCameraX();
  72.     return -1;
  73.  }
  74.  
  75.  /**
  76. + * Print current camera coordinates as XML.
  77. + */
  78. +void CameraPrintCoordinates(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float lookAtX, float lookAtY, float lookAtZ)
  79. +{
  80. +   if (g_Game && g_Game->GetView())
  81. +       g_Game->GetView()->PrintCoordinates(lookAtX, lookAtY, lookAtZ);
  82. +}
  83. +
  84. +/**
  85.   * Get the current Z coordinate of the camera.
  86.   */
  87.  float CameraGetZ(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
  88.  {
  89.     if (g_Game && g_Game->GetView())
  90. @@ -1059,10 +1068,11 @@ void GuiScriptingInit(ScriptInterface& s
  91.     scriptInterface.RegisterFunction<bool, &IsAtlasRunning>("IsAtlasRunning");
  92.     scriptInterface.RegisterFunction<JS::Value, VfsPath, &LoadMapSettings>("LoadMapSettings");
  93.     scriptInterface.RegisterFunction<JS::Value, &GetMapSettings>("GetMapSettings");
  94.     scriptInterface.RegisterFunction<float, &CameraGetX>("CameraGetX");
  95.     scriptInterface.RegisterFunction<float, &CameraGetZ>("CameraGetZ");
  96. +   scriptInterface.RegisterFunction<void, float, float, float, &CameraPrintCoordinates>("CameraPrintCoordinates");
  97.     scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollow>("CameraFollow");
  98.     scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollowFPS>("CameraFollowFPS");
  99.     scriptInterface.RegisterFunction<void, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, &SetCameraData>("SetCameraData");
  100.     scriptInterface.RegisterFunction<void, entity_pos_t, entity_pos_t, &CameraMoveTo>("CameraMoveTo");
  101.     scriptInterface.RegisterFunction<entity_id_t, &GetFollowedEntity>("GetFollowedEntity");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement