From 117f3dfe4a02c2d8bef0b4bf1f5c9f828f498b0a Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Fri, 2 Feb 2007 02:17:15 +0000 Subject: [PATCH] Rough cinematic/triggers in map. Fixed some issues with triggers. JS command execution in Atlas. This was SVN commit r4829. --- .../data/mods/official/maps/scenarios/cinematic.xml | 4 ++-- .../data/mods/official/scripts/entity_functions.js | 2 +- source/graphics/GameView.cpp | 2 +- source/simulation/TriggerManager.cpp | 9 +++++---- .../atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp | 11 +++++++++++ .../atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h | 1 + .../atlas/GameInterface/Handlers/MiscHandlers.cpp | 6 ++++++ source/tools/atlas/GameInterface/Messages.h | 4 ++++ 8 files changed, 31 insertions(+), 8 deletions(-) diff --git a/binaries/data/mods/official/maps/scenarios/cinematic.xml b/binaries/data/mods/official/maps/scenarios/cinematic.xml index 1c1540c4a2..aec2e3f150 100644 --- a/binaries/data/mods/official/maps/scenarios/cinematic.xml +++ b/binaries/data/mods/official/maps/scenarios/cinematic.xml @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:660eeb7b462dfc6b68f44d29a2d6b6c126b399565b39fbe25c2edfec543e3ded -size 246417 +oid sha256:1de615a0a67906ab8101af5eb41f6e8d20cf575f2a20f0536b1d71baa5bd6046 +size 249905 diff --git a/binaries/data/mods/official/scripts/entity_functions.js b/binaries/data/mods/official/scripts/entity_functions.js index 816308bd4c..e66f32a08b 100644 --- a/binaries/data/mods/official/scripts/entity_functions.js +++ b/binaries/data/mods/official/scripts/entity_functions.js @@ -973,7 +973,7 @@ function damage( dmg, inflictor ) if (this.traits.audio && this.traits.audio.path) { if(getGUIGlobal().newRandomSound) { - curr_pain = getGUIGlobal().newRandomSound( + var curr_pain = getGUIGlobal().newRandomSound( "voice", "pain", this.traits.audio.path); if (curr_pain) curr_pain.play(); } diff --git a/source/graphics/GameView.cpp b/source/graphics/GameView.cpp index 7059d287ee..93fb47827e 100644 --- a/source/graphics/GameView.cpp +++ b/source/graphics/GameView.cpp @@ -53,7 +53,7 @@ const float CGameView::defaultFOV = DEGTORAD(20.f); const float CGameView::defaultNear = 1.f; const float CGameView::defaultFar = 5000.f; -class CGameViewImpl : public CJSObject +class CGameViewImpl : public CJSObject, boost::noncopyable { public: CGameViewImpl(CGame* game) diff --git a/source/simulation/TriggerManager.cpp b/source/simulation/TriggerManager.cpp index 363f7b1689..e0518cf25d 100644 --- a/source/simulation/TriggerManager.cpp +++ b/source/simulation/TriggerManager.cpp @@ -138,7 +138,7 @@ bool TriggerParameter::operator< ( const TriggerParameter& rhs ) const } //===========Trigger Manager=========== -CTriggerManager::CTriggerManager() : m_UpdateRate(.80f), m_UpdateTime(.80f) +CTriggerManager::CTriggerManager() : m_UpdateRate(.20f), m_UpdateTime(.20f) { } @@ -165,11 +165,12 @@ std::vector CTriggerManager::GetTriggerTranslations(const std::wst return m_TriggerTranslations[name]; } -void CTriggerManager::Update(float delta) +void CTriggerManager::Update(float delta_ms) { + float delta = delta_ms / 1000.f; m_UpdateTime -= delta; if ( m_UpdateTime < 0 ) - m_UpdateTime = m_UpdateRate; + m_UpdateTime += m_UpdateRate; else return; @@ -178,7 +179,7 @@ void CTriggerManager::Update(float delta) { if ( it->second->ShouldFire() ) { - it->second->m_timeLeft -= delta; + it->second->m_timeLeft -= m_UpdateRate; if ( it->second->m_timeLeft < 0 ) { if ( !it->second->Fire() ) diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp index 1b84a7eb06..41fa980152 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp @@ -263,6 +263,7 @@ enum ID_MessageTrace, ID_Screenshot, ID_MediaPlayer, + ID_JavaScript, ID_Toolbar // must be last in the list }; @@ -284,6 +285,7 @@ BEGIN_EVENT_TABLE(ScenarioEditor, wxFrame) EVT_MENU(ID_MessageTrace, ScenarioEditor::OnMessageTrace) EVT_MENU(ID_Screenshot, ScenarioEditor::OnScreenshot) EVT_MENU(ID_MediaPlayer, ScenarioEditor::OnMediaPlayer) + EVT_MENU(ID_JavaScript, ScenarioEditor::OnJavaScript) EVT_IDLE(ScenarioEditor::OnIdle) END_EVENT_TABLE() @@ -347,6 +349,7 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent) menuMisc->AppendCheckItem(ID_MessageTrace, _("Message debug trace")); menuMisc->Append(ID_Screenshot, _("&Screenshot")); menuMisc->Append(ID_MediaPlayer, _("&Media player")); + menuMisc->Append(ID_JavaScript, _("&JS console")); } @@ -603,6 +606,14 @@ void ScenarioEditor::OnMediaPlayer(wxCommandEvent& WXUNUSED(event)) #endif } +void ScenarioEditor::OnJavaScript(wxCommandEvent& WXUNUSED(event)) +{ + wxString cmd = ::wxGetTextFromUser(_T(""), _("JS command"), _T(""), this); + if (cmd.IsEmpty()) + return; + POST_MESSAGE(JavaScript, (cmd.c_str())); +} + ////////////////////////////////////////////////////////////////////////// Position::Position(const wxPoint& pt) diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h index 5da2c9686b..380d67dda6 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h @@ -25,6 +25,7 @@ public: void OnMessageTrace(wxCommandEvent& event); void OnScreenshot(wxCommandEvent& event); void OnMediaPlayer(wxCommandEvent& event); + void OnJavaScript(wxCommandEvent& event); static AtlasWindowCommandProc& GetCommandProc(); diff --git a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp index 0dab5fefc9..b2cd2156e1 100644 --- a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp @@ -35,6 +35,7 @@ QUERYHANDLER(CinemaRecord) manager->SetCurrentTrack(*msg->track, false, false, false); const int w = 640, h = 480; + { g_Renderer.Resize(w, h); SViewPort vp = { 0, 0, w, h }; @@ -114,5 +115,10 @@ MESSAGEHANDLER(SimPlay) View::GetView_Game()->SetSpeedMultiplier(msg->speed); } +MESSAGEHANDLER(JavaScript) +{ + g_ScriptingHost.ExecuteScript(*msg->command, L"Atlas"); +} + } diff --git a/source/tools/atlas/GameInterface/Messages.h b/source/tools/atlas/GameInterface/Messages.h index 321afc6235..3d8ef60cdd 100644 --- a/source/tools/atlas/GameInterface/Messages.h +++ b/source/tools/atlas/GameInterface/Messages.h @@ -37,6 +37,10 @@ MESSAGE(SetViewParamC, ((Colour, value)) ); +MESSAGE(JavaScript, + ((std::wstring, command)) + ); + ////////////////////////////////////////////////////////////////////////// MESSAGE(SimStateSave,