Index: binaries/data/mods/public/simulation/components/Trigger.js
===================================================================
--- binaries/data/mods/public/simulation/components/Trigger.js (revision 17171)
+++ binaries/data/mods/public/simulation/components/Trigger.js (working copy)
@@ -19,6 +19,7 @@
"Interval",
"Range",
"TreasureCollected",
+ "CinemaPathEnded"
];
Trigger.prototype.Init = function()
@@ -234,7 +235,7 @@
// See function "SpawnUnits" in ProductionQueue for more details
};
-// Handles "OnTrainingFinished" event.
+// Handles "OnResearchFinished" event.
Trigger.prototype.OnGlobalResearchFinished = function(msg)
{
this.CallEvent("ResearchFinished", msg);
@@ -242,6 +243,12 @@
// "tech": tech}
};
+// Handles "OnCinemaPathEnded" event.
+Trigger.prototype.OnGlobalCinemaPathEnded = function(msg)
+{
+ this.CallEvent("CinemaPathEnded", msg);
+}
+
Trigger.prototype.OnGlobalOwnershipChanged = function(msg)
{
this.CallEvent("OwnershipChanged", msg);
Index: source/graphics/CinemaManager.cpp
===================================================================
--- source/graphics/CinemaManager.cpp (revision 0)
+++ source/graphics/CinemaManager.cpp (working copy)
@@ -0,0 +1,263 @@
+/* Copyright (C) 2015 Wildfire Games.
+ * This file is part of 0 A.D.
+ *
+ * 0 A.D. 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.
+ *
+ * 0 A.D. 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 0 A.D. If not, see .
+ */
+
+
+#include "precompiled.h"
+
+#include "Camera.h"
+#include "CinemaManager.h"
+#include "GameView.h"
+#include "gui/CGUI.h"
+#include "gui/GUIManager.h"
+#include "gui/IGUIObject.h"
+#include "lib/ogl.h"
+#include "maths/MathUtil.h"
+#include "maths/Quaternion.h"
+#include "maths/Vector3D.h"
+#include "maths/Vector4D.h"
+#include "ps/CLogger.h"
+#include "ps/CStr.h"
+#include "ps/Game.h"
+#include "ps/Hotkey.h"
+#include "simulation2/components/ICmpOverlayRenderer.h"
+#include "simulation2/components/ICmpRangeManager.h"
+#include "simulation2/components/ICmpSelectable.h"
+#include "simulation2/components/ICmpTerritoryManager.h"
+#include "simulation2/MessageTypes.h"
+#include "simulation2/system/ComponentManager.h"
+#include "simulation2/Simulation2.h"
+#include
+#include
+#include "renderer/Renderer.h"
+
+
+CCinemaManager::CCinemaManager()
+ : m_Enabled(false), m_Paused(true), m_DrawPaths(true)
+{
+}
+
+void CCinemaManager::AddPath(const CStrW& name, CCinemaPath path)
+{
+ if (m_Paths.find(name) != m_Paths.end())
+ {
+ LOGWARNING("Path with name '%s' already exists", name.ToUTF8());
+ return;
+ }
+ m_Paths[name] = path;
+}
+
+void CCinemaManager::AddPathToQueue(const CStrW& name)
+{
+ if (!HasPath(name))
+ {
+ LOGWARNING("Path with name '%s' doesn't exist", name.ToUTF8());
+ return;
+ }
+ m_PathQueue.push_back(m_Paths[name]);
+}
+
+void CCinemaManager::ClearQueue()
+{
+ m_PathQueue.clear();
+}
+
+void CCinemaManager::SetAllPaths(const std::map& paths)
+{
+ m_Paths = paths;
+}
+
+void CCinemaManager::SetCurrentPath(const CStrW& name, bool current)
+{
+ // ...
+}
+
+bool CCinemaManager::HasPath(const CStrW& name) const
+{
+ return m_Paths.find(name) != m_Paths.end();
+}
+
+void CCinemaManager::SetEnabled(bool enabled)
+{
+ if (m_Enabled == enabled)
+ return;
+
+ // sn - session gui object
+ IGUIObject *sn = g_GUI->FindObjectByName("sn");
+ CmpPtr cmpRangeManager(g_Game->GetSimulation2()->GetSimContext().GetSystemEntity());
+ CmpPtr cmpTerritoryManager(g_Game->GetSimulation2()->GetSimContext().GetSystemEntity());
+
+ // GUI visibility
+ if (sn)
+ {
+ if (enabled)
+ sn->SetSetting("hidden", L"true");
+ else
+ sn->SetSetting("hidden", L"false");
+ }
+
+ // Overlay visibility
+ g_Renderer.SetOptionBool(CRenderer::Option::OPT_SILHOUETTES, !enabled);
+ if (cmpRangeManager)
+ {
+ if (enabled)
+ m_MapRevealed = cmpRangeManager->GetLosRevealAll(-1);
+ // TODO: improve m_MapRevealed state and without fade in
+ cmpRangeManager->SetLosRevealAll(-1, enabled);
+ }
+ if (cmpTerritoryManager)
+ cmpTerritoryManager->SetVisibility(!enabled);
+ ICmpSelectable::SetOverrideVisibility(!enabled);
+ ICmpOverlayRenderer::SetOverrideVisibility(!enabled);
+
+ m_Enabled = enabled;
+}
+
+void CCinemaManager::MoveToPointAt(float time)
+{
+ // TODO: Update after Atlas UI patch
+ /*ENSURE(m_CurrentPath != m_Paths.end());
+ ClearQueue();
+
+ m_CurrentPath->second.m_TimeElapsed = time;
+ if (!m_CurrentPath->second.Validate())
+ return;
+
+ m_CurrentPath->second.MoveToPointAt(m_CurrentPath->second.m_TimeElapsed /
+ m_CurrentPath->second.GetDuration(), m_CurrentPath->second.GetNodeFraction(),
+ m_CurrentPath->second.m_PreviousRotation );*/
+}
+
+void CCinemaManager::Play()
+{
+ SetEnabled(true);
+ m_Paused = false;
+}
+
+void CCinemaManager::Pause()
+{
+ m_Paused = true;
+}
+
+void CCinemaManager::Stop()
+{
+ m_Paused = true;
+ SetEnabled(false);
+ m_PathQueue.clear();
+}
+
+void CCinemaManager::Skip()
+{
+ Next(true);
+}
+
+void CCinemaManager::Next(bool skipped)
+{
+ CMessageCinemaPathEnded msg(m_PathQueue.back().GetName(), skipped);
+ g_Game->GetSimulation2()->PostMessage(SYSTEM_ENTITY, msg);
+
+ m_PathQueue.pop_front();
+ if (m_PathQueue.empty())
+ {
+ SetEnabled(false);
+ m_Paused = true;
+ }
+}
+
+void CCinemaManager::Update(const float deltaRealTime)
+{
+ if (!m_Enabled || m_Paused)
+ return;
+
+ if (HotkeyIsPressed("leave"))
+ {
+ Skip();
+ return;
+ }
+
+ if (m_PathQueue.front().Play(deltaRealTime))
+ return;
+
+ Next();
+ return;
+}
+
+void CCinemaManager::Render()
+{
+ if (GetEnabled())
+ {
+ DrawBars();
+ return;
+ }
+
+ if (!m_DrawPaths)
+ return;
+
+ // draw all paths
+ for (auto it : m_Paths)
+ it.second.Draw();
+}
+
+void CCinemaManager::DrawBars() const
+{
+ int height = (float)g_xres / 2.39f;
+ int shift = (g_yres - height) / 2;
+ if (shift <= 0)
+ return;
+
+#if CONFIG2_GLES
+ #warning TODO : implement bars for GLES
+#else
+ // Set up transform for GL bars
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ CMatrix3D transform;
+ transform.SetOrtho(0.f, (float)g_xres, 0.f, (float)g_yres, -1.f, 1000.f);
+ glLoadMatrixf(&transform._11);
+
+ glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
+
+ glEnable(GL_BLEND);
+ glDisable(GL_DEPTH_TEST);
+
+ glBegin(GL_QUADS);
+ glVertex2i(0, 0);
+ glVertex2i(g_xres, 0);
+ glVertex2i(g_xres, shift);
+ glVertex2i(0, shift);
+ glEnd();
+
+ glBegin(GL_QUADS);
+ glVertex2i(0, g_yres - shift);
+ glVertex2i(g_xres, g_yres - shift);
+ glVertex2i(g_xres, g_yres);
+ glVertex2i(0, g_yres);
+ glEnd();
+
+ glDisable(GL_BLEND);
+ glEnable(GL_DEPTH_TEST);
+
+ // Restore transform
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+#endif
+}
Index: source/graphics/CinemaManager.h
===================================================================
--- source/graphics/CinemaManager.h (revision 0)
+++ source/graphics/CinemaManager.h (working copy)
@@ -0,0 +1,124 @@
+/* Copyright (C) 2015 Wildfire Games.
+ * This file is part of 0 A.D.
+ *
+ * 0 A.D. 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.
+ *
+ * 0 A.D. 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 0 A.D. If not, see .
+ */
+
+
+#ifndef INCLUDED_CINEMAMANAGER
+#define INCLUDED_CINEMAMANAGER
+
+#include
+#include