From 684dbbe9ba4271978d3e0b4184babb755552b823 Mon Sep 17 00:00:00 2001 From: pyrolink Date: Fri, 27 Apr 2007 03:05:26 +0000 Subject: [PATCH] #Preliminary end game conditions; cinematic and trigger fixes Cinematic editor is less clumsy. Forward and backward buttons now move the camera to the next and previous nodes. This was SVN commit r5000. --- .../mods/official/gui/test/2_mainmenu.xml | 1 + .../gui/test/functions_page_pregame_load.js | 3 +- .../mods/official/scripts/TriggerSpecs.xml | 26 +++++- .../mods/official/scripts/game_startup.js | 45 +++++++++ .../official/scripts/trigger_functions.js | 18 ++++ source/graphics/CinemaTrack.cpp | 19 ++-- source/graphics/CinemaTrack.h | 2 +- source/graphics/MapWriter.cpp | 38 +++----- source/ps/Game.cpp | 7 +- source/ps/GameAttributes.cpp | 2 + source/ps/GameAttributes.h | 4 + source/scripting/ScriptGlue.cpp | 12 ++- source/simulation/Entity.cpp | 2 + source/simulation/EntityManager.cpp | 17 ++-- source/simulation/EntityManager.h | 3 + source/simulation/TriggerManager.cpp | 6 +- .../AtlasUI/ScenarioEditor/SectionLayout.cpp | 7 +- .../Sections/Cinematic/Cinematic.cpp | 93 +++++++++++++------ .../Sections/Cinematic/Cinematic.h | 2 +- .../Sections/Trigger/Trigger.cpp | 26 ++---- .../GameInterface/Handlers/CinemaHandler.cpp | 1 - 21 files changed, 234 insertions(+), 100 deletions(-) diff --git a/binaries/data/mods/official/gui/test/2_mainmenu.xml b/binaries/data/mods/official/gui/test/2_mainmenu.xml index a10366242b..d29244c000 100644 --- a/binaries/data/mods/official/gui/test/2_mainmenu.xml +++ b/binaries/data/mods/official/gui/test/2_mainmenu.xml @@ -922,6 +922,7 @@ A large landmass with rivers, forests and coastal fishing grounds. getCurrItemValue("pgSessionSetupMapName"), losSetting, fowEnabled, + getCurrItemValue("pgSessionSetupGameMode"), getGUIObjectByName("pgSessionSetupScreenshotMode").checked, "pgSessionSetup"); ]]> diff --git a/binaries/data/mods/official/gui/test/functions_page_pregame_load.js b/binaries/data/mods/official/gui/test/functions_page_pregame_load.js index 54f3ab26de..2f48987f8c 100644 --- a/binaries/data/mods/official/gui/test/functions_page_pregame_load.js +++ b/binaries/data/mods/official/gui/test/functions_page_pregame_load.js @@ -5,7 +5,7 @@ // ==================================================================== -function startMap (mapName, losSetting, fogOfWar, screenshotMode, openWindow) +function startMap (mapName, losSetting, fogOfWar, gameMode, screenshotMode, openWindow) { // Starts the map, closing the current window. // mapName: .pmp to load. @@ -23,6 +23,7 @@ function startMap (mapName, losSetting, fogOfWar, screenshotMode, openWindow) g_GameAttributes.mapFile = mapName; g_GameAttributes.losSetting = losSetting; g_GameAttributes.fogOfWar = fogOfWar; + g_GameAttributes.gameMode = gameMode g_GameAttributes.screenshotMode = screenshotMode; // Close setup window diff --git a/binaries/data/mods/official/scripts/TriggerSpecs.xml b/binaries/data/mods/official/scripts/TriggerSpecs.xml index 614921122d..302d041bf5 100644 --- a/binaries/data/mods/official/scripts/TriggerSpecs.xml +++ b/binaries/data/mods/official/scripts/TriggerSpecs.xml @@ -14,7 +14,7 @@ - holy,crap,comma,seperated,choices + holy,crap,comma,separated,choices 0 @@ -76,6 +76,30 @@ + + + + + + + 1,2,3,4,5,6 + 0 + + + + + <,<=,==,!=,>=,> + 1 + + + + + int + 2 + + + + diff --git a/binaries/data/mods/official/scripts/game_startup.js b/binaries/data/mods/official/scripts/game_startup.js index 781d366e1a..c7672c7bc5 100644 --- a/binaries/data/mods/official/scripts/game_startup.js +++ b/binaries/data/mods/official/scripts/game_startup.js @@ -39,6 +39,51 @@ for(var i=0; i 0.0f ) + if ( m_TimeElapsed <= GetDuration() && m_TimeElapsed >= 0.0f ) { //Find current node and past "node time" float previousTime = 0.0f, cumulation = 0.0f; @@ -209,7 +209,7 @@ bool CCinemaPath::Validate() for ( size_t i = 0; i < Node.size() - 1; ++i ) { cumulation += Node[i].Distance; - if ( m_TimeElapsed < cumulation ) + if ( m_TimeElapsed <= cumulation ) { m_PreviousNodeTime = previousTime; m_PreviousRotation = Node[i].Rotation; @@ -228,16 +228,19 @@ bool CCinemaPath::Play(float DeltaTime) m_TimeElapsed += m_Timescale*DeltaTime; if (!Validate()) + { + m_TimeElapsed = 0.0f; return false; + } MoveToPointAt( m_TimeElapsed / GetDuration(), GetNodeFraction(), m_PreviousRotation ); return true; } -CCinemaManager::CCinemaManager() : m_DrawCurrentSpline(false), m_Active(true) +CCinemaManager::CCinemaManager() : m_DrawCurrentSpline(false), m_Active(true), m_ValidCurrent(false) { - m_CurrentPath = m_Paths.end(); + m_CurrentPath = m_Paths.end(); } void CCinemaManager::AddPath(CCinemaPath path, const CStrW& name) @@ -273,7 +276,11 @@ void CCinemaManager::SetAllPaths( const std::map& paths) } void CCinemaManager::SetCurrentPath(const CStrW& name, bool current, bool drawLines) { - debug_assert(HasTrack(name)); + if ( !HasTrack(name) ) + m_ValidCurrent = false; + else + m_ValidCurrent = true; + m_CurrentPath = m_Paths.find(name); m_DrawCurrentSpline = current; m_DrawLines = drawLines; @@ -287,7 +294,7 @@ bool CCinemaManager::HasTrack(const CStrW& name) const void CCinemaManager::DrawSpline() const { - if ( !(m_DrawCurrentSpline || m_CurrentPath != m_Paths.end()) ) + if ( !(m_DrawCurrentSpline && m_ValidCurrent) ) return; static const int smoothness = 200; diff --git a/source/graphics/CinemaTrack.h b/source/graphics/CinemaTrack.h index a25b018abb..b541d98a48 100644 --- a/source/graphics/CinemaTrack.h +++ b/source/graphics/CinemaTrack.h @@ -133,7 +133,7 @@ public: private: - bool m_Active, m_DrawCurrentSpline, m_DrawLines; + bool m_Active, m_DrawCurrentSpline, m_DrawLines, m_ValidCurrent; std::map::iterator m_CurrentPath; std::map m_Paths; std::list m_PathQueue; diff --git a/source/graphics/MapWriter.cpp b/source/graphics/MapWriter.cpp index 0bcf122063..04908ce1ce 100644 --- a/source/graphics/MapWriter.cpp +++ b/source/graphics/MapWriter.cpp @@ -484,35 +484,19 @@ void CMapWriter::WriteTrigger(XMLWriter_File& xml_file_, const MapTrigger& trigg for ( std::list::const_iterator paramIter = it2->parameters.begin(); paramIter != it2->parameters.end(); ++paramIter ) { - if ( it2->negated ) - XML_Attribute("not", "true"); - else - XML_Attribute("not", "false"); - - XML_Setting("function", it2->functionName); - XML_Setting("display", it2->displayName); - for ( std::list::const_iterator paramIter = it2->parameters.begin(); - paramIter != it2->parameters.end(); ++paramIter ) - { - CStrW paramString(*paramIter); - paramString.Replace(CStrW(L"<"), CStrW(L"<")); - paramString.Replace(CStrW(L">"), CStrW(L">")); - XML_Setting("Parameter", paramString); - } - - if ( it2->linkLogic == 1 ) - { - XML_Setting("LinkLogic", "AND"); - } - else if ( it2->linkLogic == 2 ) - { - XML_Setting("LinkLogic", "OR"); - } + CStrW paramString(*paramIter); + //paramString.Replace(CStrW(L"<"), CStrW(L"<")); + //paramString.Replace(CStrW(L">"), CStrW(L">")); + XML_Setting("Parameter", paramString); + } + if ( it2->linkLogic == 1 ) + XML_Setting("LinkLogic", "AND"); + else if ( it2->linkLogic == 2 ) + XML_Setting("LinkLogic", "OR"); - if ( trigger.logicBlockEnds.find(distance) != trigger.logicBlockEnds.end() ) - { + if ( trigger.logicBlockEnds.find(distance) != trigger.logicBlockEnds.end() ) + { XML_Element("LogicBlockEnd"); - } } } } //Read all conditions diff --git a/source/ps/Game.cpp b/source/ps/Game.cpp index 3ed7056a8b..2d7c7c0895 100644 --- a/source/ps/Game.cpp +++ b/source/ps/Game.cpp @@ -223,14 +223,14 @@ bool CGame::Update(double deltaTime, bool doInterpolate) // TODO Detect game over and bring up the summary screen or something // ^ Quick game over hack is implemented, no summary screen however - if (m_World->GetEntityManager().GetDeath()) + /*if (m_World->GetEntityManager().GetDeath()) { UpdateGameStatus(); if (GameStatus != 0) EndGame(); } //reset death event flag - m_World->GetEntityManager().SetDeath(false); + m_World->GetEntityManager().SetDeath(false);*/ return ok; } @@ -239,6 +239,7 @@ bool CGame::Update(double deltaTime, bool doInterpolate) * Test player statistics and update game status as required. * **/ +/* void CGame::UpdateGameStatus() { bool EOG_lose = true; @@ -275,7 +276,7 @@ void CGame::UpdateGameStatus() GameStatus = EOG_LOSE; else GameStatus = EOG_NEUTRAL; -} +}*/ /** * End of game console message creation. diff --git a/source/ps/GameAttributes.cpp b/source/ps/GameAttributes.cpp index ce6a187b7d..388e8fb3f5 100644 --- a/source/ps/GameAttributes.cpp +++ b/source/ps/GameAttributes.cpp @@ -187,6 +187,7 @@ CGameAttributes::CGameAttributes(): m_StartingPhase("default"), m_LOSSetting(0), m_FogOfWar(true), + m_GameMode("default"), m_ScreenshotMode(false), m_NumSlots(8), m_UpdateCB(NULL), @@ -207,6 +208,7 @@ CGameAttributes::CGameAttributes(): AddSynchedProperty(L"numSlots", &m_NumSlots, &CGameAttributes::OnNumSlotsUpdate); AddSynchedProperty(L"losSetting", &m_LOSSetting); AddSynchedProperty(L"fogOfWar", &m_FogOfWar); + AddSynchedProperty(L"gameMode", &m_GameMode); AddSynchedProperty(L"screenshotMode", &m_ScreenshotMode); CXeromyces XeroFile; diff --git a/source/ps/GameAttributes.h b/source/ps/GameAttributes.h index 485fc81d81..009f4a4845 100644 --- a/source/ps/GameAttributes.h +++ b/source/ps/GameAttributes.h @@ -118,6 +118,7 @@ public: CStrW m_MapFile; CStrW m_ResourceLevel; CStrW m_StartingPhase; + CStrW m_GameMode; uint m_LOSSetting; bool m_FogOfWar; bool m_ScreenshotMode; @@ -167,6 +168,9 @@ public: inline uint GetSlotCount() { return m_NumSlots; } + inline CStrW GetGameMode() + { return m_GameMode; } + // Remove all slots that are either opened or closed, so that all slots have // an assignment and a player. Player IDs will be assigned in the same order // as the slot indexes, but without holes in the numbering. diff --git a/source/scripting/ScriptGlue.cpp b/source/scripting/ScriptGlue.cpp index f964e1d73d..b890b6735e 100644 --- a/source/scripting/ScriptGlue.cpp +++ b/source/scripting/ScriptGlue.cpp @@ -183,7 +183,7 @@ JSBool getPlayerUnitCount( JSContext* cx, JSObject*, uint argc, jsval* argv, jsv CStrW unitName = ToPrimitive( argv[1] ); unitCount = g_EntityManager.getPlayerUnitCount((size_t)playerNum, unitName); - *rval = ToJSVal( unitCount ); + *rval = ToJSVal( unitCount ); return JS_TRUE; } @@ -758,6 +758,13 @@ JSBool endGame(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval) return JS_TRUE; } +JSBool getGameMode(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval) +{ + JSU_REQUIRE_NO_PARAMS(); + + *rval = ToJSVal( g_GameAttributes.GetGameMode() ); + return JS_TRUE; +} //----------------------------------------------------------------------------- // Internationalization @@ -1392,6 +1399,8 @@ JSFunctionSpec ScriptFunctionTable[] = JS_FUNC(removeFromFormation, removeFromFormation, 1) JS_FUNC(lockEntityFormation, lockEntityFormation, 1) JS_FUNC(isFormationLocked, isFormationLocked, 1) + + JS_FUNC(registerTrigger, registerTrigger, 1) //Tech JS_FUNC(getTechnology, getTechnology, 2) @@ -1444,6 +1453,7 @@ JSFunctionSpec ScriptFunctionTable[] = // Game Setup JS_FUNC(startGame, startGame, 0) JS_FUNC(endGame, endGame, 0) + JS_FUNC(getGameMode, getGameMode, 0) JS_FUNC(createClient, createClient, 0) JS_FUNC(createServer, createServer, 0) diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index aab2002d2a..5588eb5457 100644 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -260,6 +260,8 @@ void CEntity::kill(bool keepActor) g_EntityManager.m_refd[me.m_handle] = false; // refd must be made false when DESTROYED is set g_EntityManager.SetDeath(true); // remember that a unit died this frame + g_EntityManager.removeUnitCount(this); //Decrease population + // If we have a death animation and want to keep the actor, play that animation if( keepActor && m_actor && m_actor->HasAnimation( "death" ) ) diff --git a/source/simulation/EntityManager.cpp b/source/simulation/EntityManager.cpp index 4321ea7d35..f08c3f743e 100644 --- a/source/simulation/EntityManager.cpp +++ b/source/simulation/EntityManager.cpp @@ -123,6 +123,10 @@ void CEntityManager::AddEntityClassData(const HEntity& handle) ++m_entityClassData[playerID][className]; classList = classList.AfterFirst(L" "); } + + //For last element + if ( m_entityClassData[playerID].find(className) == m_entityClassData[playerID].end() ) + m_entityClassData[playerID][className] = 0; ++m_entityClassData[playerID][className]; } @@ -349,12 +353,9 @@ void CEntityManager::invalidateAll() m_entities[i].m_entity->invalidateActor(); } -void CEntityManager::destroy( u16 handle ) + +void CEntityManager::removeUnitCount(CEntity* ent) { - m_reaper.push_back( m_entities[handle].m_entity ); - - //Remove trigger-helper data - CEntity* ent = m_entities[handle].m_entity; size_t playerID = (size_t)ent->GetPlayer()->GetPlayerID(); CStrW className, classList = ent->m_classes.getMemberList(); @@ -364,8 +365,10 @@ void CEntityManager::destroy( u16 handle ) classList = classList.AfterFirst(L" "); } --m_entityClassData[playerID][className]; - - ent->me.m_handle = INVALID_HANDLE; +} +void CEntityManager::destroy( u16 handle ) +{ + m_reaper.push_back( m_entities[handle].m_entity ); } bool CEntityManager::m_extant = false; diff --git a/source/simulation/EntityManager.h b/source/simulation/EntityManager.h index 1b208564eb..484c9c6011 100644 --- a/source/simulation/EntityManager.h +++ b/source/simulation/EntityManager.h @@ -82,8 +82,11 @@ public: inline int getPlayerUnitCount( size_t player, const CStrW& name ) { + if ( m_entityClassData[player].find(name) == m_entityClassData[player].end() ) + m_entityClassData[player][name] = 0; return m_entityClassData[player][name]; } + void removeUnitCount(CEntity* ent); //Removes unit from population count void AddEntityClassData(const HEntity& handle); void updateAll( size_t timestep ); diff --git a/source/simulation/TriggerManager.cpp b/source/simulation/TriggerManager.cpp index e0518cf25d..aeb6a14899 100644 --- a/source/simulation/TriggerManager.cpp +++ b/source/simulation/TriggerManager.cpp @@ -54,8 +54,8 @@ JSBool CTrigger::Construct( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsv CScriptObject effectFunc( JS_ValueToFunction(cx, argv[5]) ); CTrigger* newTrigger = new CTrigger( ToPrimitive( argv[0] ), ToPrimitive( argv[1] ), - ToPrimitive( argv[2] ), - ToPrimitive( argv[3] ), + ToPrimitive( argv[2] ), + ToPrimitive( argv[3]), condFunc, effectFunc ); g_TriggerManager.AddTrigger(newTrigger); @@ -191,7 +191,7 @@ void CTriggerManager::Update(float delta_ms) //Remove all expired triggers for ( std::list::iterator it = expired.begin(); it != expired.end(); ++it ) { - delete (*it)->second;; + delete (*it)->second; m_TriggerMap.erase(*it); } } diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp index e1c7835052..87e32cc220 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp @@ -271,8 +271,11 @@ void SectionLayout::Build() ADD_SIDEBAR(TerrainSidebar, _T("terrain.png"), _("Terrain")); ADD_SIDEBAR(ObjectSidebar, _T("object.png"), _("Object")); ADD_SIDEBAR(EnvironmentSidebar, _T("environment.png"), _("Environment")); - ADD_SIDEBAR(CinematicSidebar, _T("cinematic.png"), _("Cinema")); - ADD_SIDEBAR(TriggerSidebar, _T("trigger.png"), _("Trigger")); + + #ifndef ATLAS_PUBLIC_RELEASE + ADD_SIDEBAR(CinematicSidebar, _T("cinematic.png"), _("Cinema")); + ADD_SIDEBAR(TriggerSidebar, _T("trigger.png"), _("Trigger")); + #endif #undef ADD_SIDEBAR diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp index c3c449bf26..26ae384659 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp @@ -142,7 +142,7 @@ public: qGetCameraInfo qry; qry.Post(); sCameraInfo info = qry.info; - m_Sidebar->UpdateNode(info.pX, info.pY, info.pZ, info.rX, info.rY, info.rZ, -1.f); + m_Sidebar->UpdateNode(info.pX, info.pY, info.pZ, info.rX, info.rY, info.rZ, true, -1.f); } void GotoNode() { @@ -296,7 +296,7 @@ public: { m_Sidebar->UpdateNode( m_NodePositionX->GetValue(), m_NodePositionY->GetValue(), m_NodePositionZ->GetValue(), m_NodeRotationX->GetValue(), - m_NodeRotationY->GetValue(), m_NodeRotationZ->GetValue(), m_OldT); + m_NodeRotationY->GetValue(), m_NodeRotationZ->GetValue(), false, m_OldT); } void OnText(wxCommandEvent& WXUNUSED(event)) @@ -304,7 +304,7 @@ public: m_OldT = CinemaTextFloat(*m_NodeT, 2, 0.f, 100.f, m_OldT); m_Sidebar->UpdateNode( m_NodePositionX->GetValue(), m_NodePositionY->GetValue(), m_NodePositionZ->GetValue(), m_NodeRotationX->GetValue(), - m_NodeRotationY->GetValue(), m_NodeRotationZ->GetValue(), m_OldT ); + m_NodeRotationY->GetValue(), m_NodeRotationZ->GetValue(), false, m_OldT ); } void UpdateRotationSpinners(int x, int y, int z) @@ -552,7 +552,7 @@ public: m_Timer.SetOwner(this); } - void Update(float interval) + void Update() { if ( m_Sidebar->m_SelectedPath < 0 ) return; @@ -563,7 +563,18 @@ public: void OnTick(wxTimerEvent& WXUNUSED(event)) { m_NewTime = m_HighResTimer.GetTime(); - Update(m_NewTime - m_OldTime); + m_Sidebar->m_TimeElapsed += m_NewTime - m_OldTime; + + if ( m_Sidebar->m_TimeElapsed >= m_Sidebar->GetCurrentPath()->duration ) + { + m_Timer.Stop(); + m_Sidebar->m_TimeElapsed = 0.0f; + POST_MESSAGE(CinemaEvent, + ( *m_Sidebar->GetCurrentPath()->name, eCinemaEventMode::IMMEDIATE_PATH, 0.0f, + m_Sidebar->m_InfoBox->GetDrawCurrent(), m_Sidebar->m_InfoBox->GetDrawLines()) ); + } + + Update(); m_OldTime = m_NewTime; } void OnScroll(wxScrollEvent& WXUNUSED(event)); @@ -633,21 +644,31 @@ public: } void OnPrevious(wxCommandEvent& WXUNUSED(event)) { + if ( m_Parent->m_SelectedPath < 0 ) + return; + m_Parent->m_PathSlider->m_Timer.Stop(); m_Parent->m_Playing = false; - - if ( m_Parent->m_SelectedPath > 0) + float timeSet = 0.0f; + std::vector nodes = *m_Parent->GetCurrentPath()->nodes; + + for ( size_t i = 0; i < nodes.size(); ++i ) { - m_Parent->m_TimeElapsed = 0.0f; - POST_MESSAGE(CinemaEvent, - ( m_Parent->GetSelectedPathName(), eCinemaEventMode::IMMEDIATE_PATH, 0.0f, - m_Parent->m_InfoBox->GetDrawCurrent(), m_Parent->m_InfoBox->GetDrawLines()) ); + timeSet += nodes[i].t; + if ( fabs((timeSet - m_Parent->m_TimeElapsed)) < .0001f ) + { + timeSet -= nodes[i].t; + break; + } } - m_Parent->m_PathSlider->Update(0); + + m_Parent->m_TimeElapsed = timeSet; + POST_MESSAGE(CinemaEvent, + ( m_Parent->GetSelectedPathName(), eCinemaEventMode::IMMEDIATE_PATH, timeSet, + m_Parent->m_InfoBox->GetDrawCurrent(), m_Parent->m_InfoBox->GetDrawLines()) ); + + m_Parent->m_PathSlider->Update(); } - //void OnRewind(wxCommandEvent& event) - - //void OnReverse(wxCommandEvent& event) void OnStop(wxCommandEvent& WXUNUSED(event)) { if ( m_Parent->m_SelectedPath < 0) @@ -656,7 +677,7 @@ public: m_Parent->m_PathSlider->m_Timer.Stop(); m_Parent->m_Playing = false; m_Parent->m_TimeElapsed = 0.0f; - m_Parent->m_PathSlider->Update(0.0f); + m_Parent->m_PathSlider->Update(); POST_MESSAGE(CinemaEvent, (m_Parent->GetSelectedPathName(), eCinemaEventMode::IMMEDIATE_PATH, 0.0f, @@ -666,7 +687,7 @@ public: { if ( m_Parent->m_SelectedPath < 0 ) return; - + m_Parent->m_PathSlider->m_Timer.Stop(); m_Parent->m_PathSlider->PrepareTimers(); @@ -692,8 +713,6 @@ public: if ( m_Parent->m_SelectedPath < 0 ) return; m_Parent->m_PathSlider->m_Timer.Stop(); - //m_Parent->m_SliderBox->Reset(); - //m_Parent->m_NodeList->Thaw(); m_Parent->m_Playing = false; POST_MESSAGE(CinemaEvent, @@ -704,18 +723,28 @@ public: void OnNext(wxCommandEvent& WXUNUSED(event)) { + if ( m_Parent->m_SelectedPath < 0 ) + return; + m_Parent->m_PathSlider->m_Timer.Stop(); m_Parent->m_Playing = false; std::wstring name = m_Parent->GetSelectedPathName(); - const sCinemaPath* path = m_Parent->GetCurrentPath(); + std::vector nodes = *m_Parent->GetCurrentPath()->nodes; + float timeSet = 0.0f; + + for ( size_t i = 0; i < nodes.size(); ++i ) + { + timeSet += nodes[i].t; + if ( timeSet > m_Parent->m_TimeElapsed ) + break; + } + m_Parent->m_TimeElapsed = timeSet; - m_Parent->m_TimeElapsed = path->duration; - POST_MESSAGE(CinemaEvent, - ( name, eCinemaEventMode::IMMEDIATE_PATH, path->duration, + ( name, eCinemaEventMode::IMMEDIATE_PATH, timeSet, m_Parent->m_InfoBox->GetDrawCurrent(), m_Parent->m_InfoBox->GetDrawLines()) ); - m_Parent->m_PathSlider->Update(0); + m_Parent->m_PathSlider->Update(); } CinematicSidebar* m_Parent; wxStaticBoxSizer* m_Sizer; @@ -939,8 +968,12 @@ void CinematicSidebar::DeleteNode() m_TimeElapsed = m_Paths[m_SelectedPath].duration; nodes.erase( nodes.begin() + m_SelectedSplineNode ); - m_Paths[m_SelectedPath].nodes = nodes; ssize_t size = (ssize_t)nodes.size(); + + if ( m_SelectedSplineNode == 0 && size != 0 ) + nodes[m_SelectedSplineNode].t = 0; //Reset the first node's time to 0 + m_Paths[m_SelectedPath].nodes = nodes; + if ( size == 0 ) SelectSplineNode(-1); @@ -960,10 +993,11 @@ void CinematicSidebar::UpdatePath(std::wstring name, float timescale) m_Paths[m_SelectedPath].name = name; m_Paths[m_SelectedPath].timescale = timescale; + m_PathList->SetItemText(m_SelectedPath, name.c_str()); UpdateEngineData(); } -void CinematicSidebar::UpdateNode(float px, float py, float pz, float rx, float ry, float rz, float t) +void CinematicSidebar::UpdateNode(float px, float py, float pz, float rx, float ry, float rz, bool absoluteOveride, float t) { if ( m_SelectedPath < 0 || m_SelectedSplineNode < 0 ) return; @@ -977,7 +1011,7 @@ void CinematicSidebar::UpdateNode(float px, float py, float pz, float rx, float if ( t < 0 ) t = nodes[m_SelectedSplineNode].t; - if ( m_RotationAbsolute ) + if ( m_RotationAbsolute || m_SelectedSplineNode == 0 || absoluteOveride ) { nodes[m_SelectedSplineNode].rx = rx; nodes[m_SelectedSplineNode].ry = ry; @@ -990,7 +1024,8 @@ void CinematicSidebar::UpdateNode(float px, float py, float pz, float rx, float nodes[m_SelectedSplineNode].rz = rz + nodes[m_SelectedSplineNode-1].rz; } - sCinemaSplineNode newNode(px, py, pz, rx, ry, rz); + sCinemaSplineNode newNode(px, py, pz, nodes[m_SelectedSplineNode].rx, + nodes[m_SelectedSplineNode].ry, nodes[m_SelectedSplineNode].rz); newNode.SetTime(t); float delta = newNode.t - nodes[m_SelectedSplineNode].t; m_Paths[m_SelectedPath].duration = m_Paths[m_SelectedPath].duration + delta; @@ -1079,7 +1114,7 @@ void CinematicSidebar::GotoNode(ssize_t index) //this is just an echo if false if ( m_TimeElapsed / GetCurrentPath()->duration < 1.f ) - m_PathSlider->Update(0.0f); + m_PathSlider->Update(); } std::wstring CinematicSidebar::GetSelectedPathName() const diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.h b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.h index 925e815a2c..a96a068f88 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.h +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.h @@ -35,7 +35,7 @@ public: void AddPath(std::wstring& name, int count); void AddNode(float px, float py, float pz, float rx, float ry, float rz, int count); void UpdatePath(std::wstring name, float timescale); - void UpdateNode(float px, float py, float pz, float rx, float ry, float rz, float t=-1); + void UpdateNode(float px, float py, float pz, float rx, float ry, float rz, bool absoluteOveride, float t=-1); void DeleteTrack(); void DeletePath(); diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp index 4dcafe5ee7..dadf5e40fa 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp @@ -875,6 +875,8 @@ public: return; DestroyChildren(); m_DependentStatus = NO_VIEW; + m_Sidebar->m_ConditionPage->m_List->DeleteAllItems(); + m_Sidebar->m_EffectPage->m_List->DeleteAllItems(); } TriggerSidebar* m_Sidebar; @@ -931,18 +933,12 @@ void TriggerTreeCtrl::onClick(wxMouseEvent& evt) void TriggerListCtrl::onClick(wxMouseEvent& evt) { + evt.Skip(); if ( m_Condition ) { - //if ( m_Sidebar->m_TriggerBottom->GetDependentStatus() != TriggerBottomBar::CONDITION_VIEW ) + if ( m_Sidebar->m_SelectedCond < 0 ) + return; - /*if ( m_Sidebar->m_ConditionPage->m_List->GetItemText(m_Sidebar->m_SelectedCond) - == m_Sidebar->m_LogicBlockEndString ) - { - m_Sidebar->m_TriggerBottom->ToLogicEndView(); - - if ( m_Sidebar->m_SelectedCond != -1 ) - m_Sidebar->m_TriggerBottom->FillLogicEndData(); - }*/ if ( m_Sidebar->m_ConditionPage->m_List->GetItemText(m_Sidebar->m_SelectedCond) == m_Sidebar->m_LogicBlockEndString ) { @@ -952,25 +948,21 @@ void TriggerListCtrl::onClick(wxMouseEvent& evt) == m_Sidebar->m_LogicBlockString ) { m_Sidebar->m_TriggerBottom->ToLogicView(); - - if ( m_Sidebar->m_SelectedCond != -1 ) - m_Sidebar->m_TriggerBottom->FillLogicData(); + m_Sidebar->m_TriggerBottom->FillLogicData(); } else { m_Sidebar->m_TriggerBottom->ToConditionView(); - if ( m_Sidebar->m_SelectedCond != -1 ) - m_Sidebar->m_TriggerBottom->FillConditionData(); + m_Sidebar->m_TriggerBottom->FillConditionData(); } } else { - //if ( m_Sidebar->m_TriggerBottom->GetDependentStatus() != TriggerBottomBar::EFFECT_VIEW ) - m_Sidebar->m_TriggerBottom->ToEffectView(); + m_Sidebar->m_TriggerBottom->ToEffectView(); if ( m_Sidebar->m_SelectedEffect != -1 ) m_Sidebar->m_TriggerBottom->FillEffectData(); } - evt.Skip(); + } diff --git a/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp b/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp index 3769069aad..4de83699d9 100644 --- a/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp +++ b/source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp @@ -139,7 +139,6 @@ MESSAGEHANDLER(CinemaEvent) { CCinemaManager* manager = g_Game->GetView()->GetCinema(); - if ( msg->mode == eCinemaEventMode::SMOOTH ) manager->OverridePath(*msg->path); else if ( msg->mode == eCinemaEventMode::IMMEDIATE_PATH )