From 4c395f4bf28d0ae8abbb6b6fbe4deb8bd8755245 Mon Sep 17 00:00:00 2001 From: leper Date: Thu, 14 Nov 2013 00:10:04 +0000 Subject: [PATCH] Remove Trigger and Cinematic sections from Atlas. This was SVN commit r14166. --- .../AtlasUI/ScenarioEditor/SectionLayout.cpp | 7 +- .../Sections/Cinematic/Cinematic.cpp | 1144 ----------- .../Sections/Cinematic/Cinematic.h | 106 - .../Sections/Trigger/Trigger.cpp | 1750 ----------------- .../ScenarioEditor/Sections/Trigger/Trigger.h | 104 - 5 files changed, 1 insertion(+), 3110 deletions(-) delete mode 100644 source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp delete mode 100644 source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.h delete mode 100644 source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp delete mode 100644 source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.h diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp index 1f776ed297..54ead68284 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2013 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -28,12 +28,10 @@ #include "AtlasScript/ScriptInterface.h" #include "Sections/Environment/Environment.h" -#include "Sections/Cinematic/Cinematic.h" #include "Sections/Map/Map.h" #include "Sections/Object/Object.h" #include "Sections/Player/Player.h" #include "Sections/Terrain/Terrain.h" -#include "Sections/Trigger/Trigger.h" #include "General/Datafile.h" @@ -293,9 +291,6 @@ void SectionLayout::Build(ScenarioEditor& scenarioEditor) 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")); #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 deleted file mode 100644 index cacf540fe3..0000000000 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp +++ /dev/null @@ -1,1144 +0,0 @@ -/* Copyright (C) 2012 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 "Cinematic.h" - -#include "GameInterface/Messages.h" -#include "CustomControls/Buttons/ActionButton.h" -//#include "CustomControls/Buttons/FloatingSpinCtrl.h" -#include "General/Datafile.h" -#include "ScenarioEditor/ScenarioEditor.h" -#include "HighResTimer/HighResTimer.h" - -#include "General/VideoRecorder/VideoRecorder.h" - -#include "wx/spinctrl.h" -#include "wx/filename.h" -#include "wx/wfstream.h" -#include "wx/listctrl.h" -#include "wx/imaglist.h" - -#include - -using namespace AtlasMessage; - -#define CINEMA_EPSILON .0032f - -struct eCinemaButton -{ - enum { - previous/*, rewind, reverse*/, stop, - play, pause, /*forward,*/ next, record }; -}; - -float CinemaTextFloat(wxTextCtrl&, size_t, float, float, float); - -class CinematicBottomBar : public wxPanel -{ - friend void TimescaleSpin(void*); -public: - CinematicBottomBar(wxWindow* parent, CinematicSidebar* side); - void AddLists(CinematicSidebar* side, PathListCtrl* paths, NodeListCtrl* nodes); - void OnText(wxCommandEvent& WXUNUSED(event)) - { - m_OldScale = CinemaTextFloat(*m_TimeText, 2, -5.f, 5.f, m_OldScale); - m_Sidebar->UpdatePath((std::wstring)m_Name->GetLineText(0).wc_str(), m_OldScale); - } - void UpdatePath(std::wstring name, float scale) - { - m_Name->SetValue( wxString(name.c_str()) ); - m_TimeText->SetValue( wxString::Format(L"%f", scale) ); - if ( m_OldPathIndex != m_Sidebar->GetSelectedPath() ) - { - m_OldPathIndex = m_Sidebar->GetSelectedPath(); - m_OldScale = 0.f; - } - CinemaTextFloat(*m_TimeText, 2, -5.f, 5.f, 0.f); - } -private: - wxStaticBoxSizer* m_Sizer; - CinematicSidebar* m_Sidebar; - wxTextCtrl* m_Name, *m_TimeText; - float m_OldScale; - ssize_t m_OldPathIndex; - DECLARE_EVENT_TABLE(); -}; -BEGIN_EVENT_TABLE(CinematicBottomBar, wxPanel) -EVT_TEXT_ENTER(wxID_ANY, CinematicBottomBar::OnText) -END_EVENT_TABLE() - -///////////////////////////////////////////////////////////////////// - -class PathListCtrl : public wxListCtrl -{ -public: - PathListCtrl(wxWindow* parent, CinematicSidebar* side) - : wxListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL), - m_Sidebar(side) - { - InsertColumn(0, _("Paths"), wxLIST_FORMAT_LEFT, 180); - } - - void OnSelect(wxListEvent& event) - { - m_Sidebar->SelectPath(event.GetIndex()); - m_Sidebar->UpdateTexts(); - } - void AddPath() - { - std::wstringstream message; - message << "Path " << GetItemCount(); - std::wstring msgString = message.str(); - wxString fmt( msgString.c_str(), msgString.length() ); - InsertItem(GetItemCount(), fmt); - m_Sidebar->AddPath(msgString, GetItemCount()-1); - } - void DeletePath() - { - DeleteItem(m_Sidebar->GetSelectedPath()); - m_Sidebar->DeletePath(); - } - -private: - CinematicSidebar* m_Sidebar; - - DECLARE_EVENT_TABLE(); -}; -BEGIN_EVENT_TABLE(PathListCtrl, wxListCtrl) - EVT_LIST_ITEM_SELECTED(wxID_ANY, PathListCtrl::OnSelect) -END_EVENT_TABLE() - -class NodeListCtrl : public wxListCtrl -{ -public: - NodeListCtrl(wxWindow* parent, CinematicSidebar* side) - : wxListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL), - m_Sidebar(side) - { - InsertColumn(0, _("Nodes"), wxLIST_FORMAT_LEFT, 180); - } - void OnSelect(wxListEvent& event) - { - m_Sidebar->SelectSplineNode(event.GetIndex(), GetItemCount()); - m_Sidebar->UpdateTexts(); - } - void AddNode() - { - std::wstringstream message; - message << "Node " << GetItemCount(); - std::wstring msgString = message.str(); - wxString fmt( msgString.c_str(), msgString.length() ); - InsertItem(GetItemCount(), fmt); - - qGetCameraInfo qry; - qry.Post(); - sCameraInfo info = qry.info; - m_Sidebar->AddNode(info.pX, info.pY, info.pZ, info.rX, info.rY, info.rZ, GetItemCount()-1); - } - void DeleteNode() - { - DeleteItem(m_Sidebar->GetSelectedNode()); - m_Sidebar->DeleteNode(); - } - void UpdateNode() - { - qGetCameraInfo qry; - qry.Post(); - sCameraInfo info = qry.info; - m_Sidebar->UpdateNode(info.pX, info.pY, info.pZ, info.rX, info.rY, info.rZ, true, -1.f); - } - void GotoNode() - { - m_Sidebar->GotoNode(); - } -private: - CinematicSidebar* m_Sidebar; - - DECLARE_EVENT_TABLE(); -}; -BEGIN_EVENT_TABLE(NodeListCtrl, wxListCtrl) - EVT_LIST_ITEM_SELECTED(wxID_ANY, NodeListCtrl::OnSelect) -END_EVENT_TABLE() - -///////////////////////////////////////////////////////////////// - - -void CinemaPathAdd(void* data) -{ - PathListCtrl* list = reinterpret_cast(data); - list->AddPath(); -} -void CinemaNodeAdd(void* data) -{ - NodeListCtrl* list = reinterpret_cast(data); - list->AddNode(); -} - -void CinemaPathDel(void* data) -{ - PathListCtrl* list = reinterpret_cast(data); - list->DeletePath(); -} -void CinemaNodeDel(void* data) -{ - NodeListCtrl* list = reinterpret_cast(data); - list->DeleteNode(); -} - -void CinemaNodeUpdate(void* data) -{ - NodeListCtrl* list = reinterpret_cast(data); - list->UpdateNode(); -} -void CinemaNodeGoto(void* data) -{ - NodeListCtrl* list = reinterpret_cast(data); - list->GotoNode(); -} - -/////////////////////////////////////////////////////////// - -void CinemaStringToFloat(wxString& text, size_t decimals) -{ - size_t i, j; - if ( (i = text.find(L".")) == wxString::npos) - { - text.Append('.'); - text.Append('0', decimals); - } - else - { - j = text.find_last_not_of(L"0"); - text.Remove(j+1); - //Too many numbers - if ( j - i > decimals ) - text.Remove(i+decimals+1); - else - text.Append('0', decimals - (j-i)); - } -} -float CinemaTextFloat(wxTextCtrl& ctrl, size_t decimals, float min, - float max, float oldval) -{ - wxString text = ctrl.GetLineText(0); - double val; - if ( !text.ToDouble(&val) ) - { - wxBell(); - val = oldval; - text = wxString::Format(L"%f", val); - CinemaStringToFloat(text, decimals); - } - - if ( val > max ) - val = oldval; - else if ( val < min ) - val = oldval; - text = wxString::Format(L"%f", val); - CinemaStringToFloat(text, decimals); - ctrl.SetValue(text); - return val; - -} - -///////////////////////////////////////////////////////////// - -class CinemaSpinnerBox : public wxPanel -{ -public: - enum { RotationX_ID, RotationY_ID, RotationZ_ID, PositionX_ID, PositionY_ID, PositionZ_ID }; - CinemaSpinnerBox(wxWindow* parent, CinematicSidebar* side) - : wxPanel(parent), m_OldT(0), m_OldIndex(0) - { - m_MainSizer = new wxBoxSizer(wxHORIZONTAL); - SetSizer(m_MainSizer); - m_Sidebar = side; - - wxStaticBoxSizer* rotation = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("Rotation")); - wxStaticBoxSizer* position = new wxStaticBoxSizer(wxHORIZONTAL,this, _T("Position")); - wxStaticBoxSizer* time = new wxStaticBoxSizer(wxHORIZONTAL, this, _T("Time")); - - m_NodeRotationX = new wxSpinCtrl(this, RotationX_ID, _T("x"), - wxDefaultPosition, wxSize(50, 15), wxSP_ARROW_KEYS|wxSP_WRAP ); - m_NodeRotationY = new wxSpinCtrl(this, RotationY_ID, _T("y"), - wxDefaultPosition, wxSize(50, 15), wxSP_ARROW_KEYS|wxSP_WRAP ); - m_NodeRotationZ = new wxSpinCtrl(this, RotationZ_ID, _T("z"), - wxDefaultPosition, wxSize(50, 15), wxSP_ARROW_KEYS|wxSP_WRAP ); - - m_NodePositionX = new wxSpinCtrl(this, PositionX_ID, _T("x"), - wxDefaultPosition, wxSize(55, 15), wxSP_ARROW_KEYS|wxSP_WRAP ); - m_NodePositionY = new wxSpinCtrl(this, PositionY_ID, _T("y"), - wxDefaultPosition, wxSize(55, 15), wxSP_ARROW_KEYS|wxSP_WRAP ); - m_NodePositionZ = new wxSpinCtrl(this, PositionZ_ID, _T("z"), - wxDefaultPosition, wxSize(55, 15), wxSP_ARROW_KEYS | wxSP_WRAP ); - m_NodeT = new wxTextCtrl(this, wxID_ANY, _T("0.00"), - wxDefaultPosition, wxSize(55, 15), wxTE_PROCESS_ENTER ); - - time->Add(m_NodeT); - - m_NodeRotationX->SetRange(-360, 360); - m_NodeRotationY->SetRange(-360, 360); - m_NodeRotationZ->SetRange(-360, 360); - m_NodePositionX->SetRange(-1000, 1000); //TODO make these more exact - m_NodePositionY->SetRange(-200, 600); - m_NodePositionZ->SetRange(-1000, 1000); - - rotation->Add(m_NodeRotationX); - rotation->Add(m_NodeRotationY); - rotation->Add(m_NodeRotationZ); - position->Add(m_NodePositionX); - position->Add(m_NodePositionY); - position->Add(m_NodePositionZ); - - m_MainSizer->Add(rotation); - m_MainSizer->Add(position); - m_MainSizer->Add(time); - } - - void OnNodePush(wxSpinEvent& WXUNUSED(event)) - { - m_Sidebar->UpdateNode( m_NodePositionX->GetValue(), m_NodePositionY->GetValue(), - m_NodePositionZ->GetValue(), m_NodeRotationX->GetValue(), - m_NodeRotationY->GetValue(), m_NodeRotationZ->GetValue(), false, m_OldT); - } - - void OnText(wxCommandEvent& WXUNUSED(event)) - { - 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(), false, m_OldT ); - } - - void UpdateRotationSpinners(int x, int y, int z) - { - m_NodeRotationX->SetValue(x); - m_NodeRotationY->SetValue(y); - m_NodeRotationZ->SetValue(z); - } - - void UpdatePositionSpinners(int x, int y, int z, float t, ssize_t index) - { - m_NodePositionX->SetValue(x); - m_NodePositionY->SetValue(y); - m_NodePositionZ->SetValue(z); - m_NodeT->SetValue(wxString::Format(L"%f", t)); - - if ( m_OldIndex != index ) - { - m_OldT = 0.f; - m_OldIndex = index; - } - m_OldT = CinemaTextFloat(*m_NodeT, 2, 0.f, 100.f, m_OldT); - } -private: - wxSpinCtrl* m_NodeRotationX, *m_NodeRotationY, *m_NodeRotationZ, *m_NodePositionX, *m_NodePositionY, *m_NodePositionZ; - wxTextCtrl* m_NodeT; - float m_OldT; - int m_OldIndex; - wxBoxSizer* m_MainSizer; - CinematicSidebar* m_Sidebar; - DECLARE_EVENT_TABLE(); -}; - -BEGIN_EVENT_TABLE(CinemaSpinnerBox, wxPanel) -EVT_SPINCTRL(CinemaSpinnerBox::RotationX_ID, CinemaSpinnerBox::OnNodePush) -EVT_SPINCTRL(CinemaSpinnerBox::RotationY_ID, CinemaSpinnerBox::OnNodePush) -EVT_SPINCTRL(CinemaSpinnerBox::RotationZ_ID, CinemaSpinnerBox::OnNodePush) -EVT_SPINCTRL(CinemaSpinnerBox::PositionX_ID, CinemaSpinnerBox::OnNodePush) -EVT_SPINCTRL(CinemaSpinnerBox::PositionY_ID, CinemaSpinnerBox::OnNodePush) -EVT_SPINCTRL(CinemaSpinnerBox::PositionZ_ID, CinemaSpinnerBox::OnNodePush) -EVT_TEXT_ENTER(wxID_ANY, CinemaSpinnerBox::OnText) -END_EVENT_TABLE() - -///////////////////////////////////////////////////////////// -CinematicBottomBar::CinematicBottomBar(wxWindow* parent, CinematicSidebar* side) -: wxPanel(parent), m_Sidebar(side), m_OldScale(0), m_OldPathIndex(-1) -{ - m_Sizer = new wxStaticBoxSizer(wxVERTICAL, this); - SetSizer(m_Sizer); -} -void CinematicBottomBar::AddLists(CinematicSidebar* side, PathListCtrl* paths, NodeListCtrl* nodes) -{ - wxBoxSizer* top = new wxBoxSizer(wxHORIZONTAL); - CinemaSpinnerBox* spinners = new CinemaSpinnerBox(this, side); - side->SetSpinners(spinners); - - wxBoxSizer* pathButtons = new wxBoxSizer(wxVERTICAL); - wxBoxSizer* nodeButtons = new wxBoxSizer(wxVERTICAL); - - ActionButton* PathAdd = new ActionButton(this, _T("Add"), - &CinemaPathAdd, paths, wxSize(40, 18)); - ActionButton* NodeAdd = new ActionButton(this, _T("Add"), - &CinemaNodeAdd, nodes, wxSize(40, 18)); - ActionButton* PathDel = new ActionButton(this, _T("Del"), - &CinemaPathDel, paths, wxSize(40, 18)); - ActionButton* NodeDel = new ActionButton(this, _T("Del"), - &CinemaNodeDel, nodes, wxSize(40, 18)); - ActionButton* NodeUpdate = new ActionButton(this, _T("Mod"), - &CinemaNodeUpdate, nodes, wxSize(40, 18)); - ActionButton* NodeGoto = new ActionButton(this, _T("Goto"), - &CinemaNodeGoto, nodes, wxSize(44, 18)); - - wxBoxSizer* textBoxes = new wxBoxSizer(wxVERTICAL); - wxBoxSizer* timescale = new wxBoxSizer(wxHORIZONTAL); - - timescale->Add( new wxStaticText(this, wxID_ANY, _T("Timescale:")) ); - m_TimeText = new wxTextCtrl(this, wxID_ANY, _T("1.00"), - wxDefaultPosition, wxSize(55, 20)); - timescale->Add( m_TimeText ); - - wxBoxSizer* nameBox = new wxBoxSizer(wxHORIZONTAL); - nameBox->Add( new wxStaticText(this, wxID_ANY, _T("Name:")), 0, - wxALIGN_CENTER | wxLEFT | wxRIGHT, 5); - m_Name = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, - wxSize(55, 20)); - nameBox->Add( m_Name ); - - textBoxes->Add(timescale); - textBoxes->Add(nameBox, 0, wxEXPAND); - - pathButtons->Add(PathAdd, 0); - pathButtons->Add(PathDel, 0); - nodeButtons->Add(NodeAdd, 0); - nodeButtons->Add(NodeDel, 0); - nodeButtons->Add(NodeUpdate, 0); - nodeButtons->Add(NodeGoto, 0); - - top->Add(textBoxes, 0); - top->Add(paths, 0); - top->Add(pathButtons, 0); - top->Add(nodes, 0); - top->Add(nodeButtons, 0); - - m_Sizer->Add(top, 0); - m_Sizer->Add(spinners, 0); -} - -class CinemaInfoBox : public wxPanel -{ -public: - enum { Mode_ID, Style_ID, Rotation_ID, Spline_ID, Reset_ID }; - - CinemaInfoBox(CinematicSidebar* side) : wxPanel(side), - m_Sidebar(side), m_OldGrowth(0), m_OldSwitch(0), m_OldPathIndex(-1) - { - m_Sizer = new wxBoxSizer(wxVERTICAL); - SetSizer(m_Sizer); - //Use individual static boxes for nicer looks - wxBoxSizer* radios = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer* spinners = new wxBoxSizer(wxHORIZONTAL); - - wxString style[5] = {_T("Default"), _T("Growth"), _T("Expo"), - _T("Circle"), _T("Sine") }; - m_StyleBox = new wxRadioBox(this, Style_ID, _T("Style"), wxDefaultPosition, - wxDefaultSize, 5, style, 5, wxRA_SPECIFY_ROWS ); - radios->Add(m_StyleBox, 0, wxALIGN_CENTER); - - //Mode radio box - wxString mode[4]= { _T("Ease in"), _T("Ease Out"), - _T("In-out"), _T("Out-in") }; - m_ModeBox = new wxRadioBox(this, Mode_ID, _T("Mode"), wxDefaultPosition, - wxDefaultSize, 4, mode, 4, wxRA_SPECIFY_ROWS ); - radios->Add(m_ModeBox, 0, wxEXPAND | wxALIGN_CENTER); - - wxStaticText* growth = new wxStaticText(this, wxID_ANY, _T("Growth")); - wxStaticText* change = new wxStaticText(this, wxID_ANY, _T("Switch")); - m_Growth = new wxTextCtrl(this, wxID_ANY, _T("0.00"), wxDefaultPosition, - wxSize(50, 15), wxTE_PROCESS_ENTER); - m_Switch = new wxTextCtrl(this, wxID_ANY, _T("0.00"), wxDefaultPosition, - wxSize(50, 15), wxTE_PROCESS_ENTER); - - wxStaticBoxSizer* growthBox = new wxStaticBoxSizer(wxHORIZONTAL, this); - growthBox->Add(growth, 0, wxALIGN_CENTER); - growthBox->Add(m_Growth, 0, wxALIGN_CENTER); - wxStaticBoxSizer* switchBox = new wxStaticBoxSizer(wxHORIZONTAL, this); - switchBox->Add(change, 0, wxALIGN_CENTER); - switchBox->Add(m_Switch, 0, wxALIGN_CENTER); - - spinners->Add(growthBox); - spinners->Add(switchBox); - m_Sizer->Add(radios, 0, wxALIGN_CENTER); - m_Sizer->Add(spinners, 0, wxALIGN_CENTER); - - //Put this here since there isn't any other place yet - wxBoxSizer* displayH = new wxBoxSizer(wxHORIZONTAL); - m_DrawCurrent = new wxCheckBox(this, wxID_ANY, _T("Draw current")); - - wxString splineStrings[2] = { _T("Points"), _T("Lines") }; - m_SplineDisplay = new wxRadioBox(this, Spline_ID, _T("Spline Display"), - wxDefaultPosition, wxDefaultSize, 2, splineStrings, 2, wxRA_SPECIFY_ROWS); - wxString angle[2] = { _T("Relative"), _T("Absolute") }; - m_RotationDisplay = new wxRadioBox(this, Rotation_ID, _T("Rotation Display"), - wxDefaultPosition, wxDefaultSize, 2, angle, 2, wxRA_SPECIFY_ROWS ); - - displayH->Add(m_SplineDisplay, 0); - displayH->Add(m_RotationDisplay, 0); - m_Sizer->Add(displayH, 0, wxTop | wxALIGN_CENTER, 10); - m_Sizer->Add(m_DrawCurrent, 0); - m_Sizer->Add( new wxButton(this, Reset_ID, L"Reset Camera"), 0, wxALIGN_CENTER ); - } - void UpdatePath(const sCinemaPath* path) - { - m_ModeBox->SetSelection(path->mode); - m_StyleBox->SetSelection(path->style); - float growth = path->growth; //wxFormat doesn't like to share(able) - float change = path->change; - - m_Growth->SetValue( wxString::Format(L"%f", growth) ); - m_Switch->SetValue( wxString::Format(L"%f", change) ); - UpdateOldIndex(); - CinemaTextFloat(*m_Growth, 2, 0.f, 10.f, m_OldGrowth); - CinemaTextFloat(*m_Switch, 2, 0.f, 10.f, m_OldSwitch); - } - void OnChange(wxCommandEvent& WXUNUSED(event)) - { - m_OldGrowth = CinemaTextFloat(*m_Growth, 2, 0.f, 10.f, m_OldGrowth); - m_OldSwitch = CinemaTextFloat(*m_Switch, 2, 0.f, 10.f, m_OldSwitch); - UpdateOldIndex(); - m_Sidebar->UpdatePathInfo( m_ModeBox->GetSelection(), m_StyleBox->GetSelection(), - m_OldGrowth, m_OldSwitch, m_DrawCurrent->IsChecked(), - m_SplineDisplay->GetSelection() != 0 ); - } - void OnRotation(wxCommandEvent& WXUNUSED(event)) - { - m_Sidebar->m_RotationAbsolute = m_RotationDisplay->GetSelection()!=0; - m_Sidebar->UpdateSpinners(); - } - void ResetCamera(wxCommandEvent& WXUNUSED(event)) - { - POST_MESSAGE(CinemaEvent, ( m_Sidebar->GetSelectedPathName(), eCinemaEventMode::RESET, - 0.0f, GetDrawCurrent(), GetDrawLines() ) ); - } - void UpdateOldIndex() - { - if ( m_Sidebar->GetSelectedPath() != m_OldPathIndex ) - { - m_OldPathIndex = m_Sidebar->GetSelectedPath(); - m_OldGrowth = m_OldSwitch = 0.f; - } - } - - bool GetDrawCurrent() { return m_DrawCurrent->IsChecked(); } - bool GetDrawLines() { return m_SplineDisplay->GetSelection()!=0; } - -private: - wxBoxSizer* m_Sizer; - CinematicSidebar* m_Sidebar; - wxRadioBox* m_ModeBox, *m_StyleBox, *m_RotationDisplay, *m_SplineDisplay; - wxTextCtrl* m_Growth, *m_Switch; - wxCheckBox* m_DrawCurrent; - - float m_OldGrowth, m_OldSwitch; - ssize_t m_OldPathIndex; - DECLARE_EVENT_TABLE(); -}; -BEGIN_EVENT_TABLE(CinemaInfoBox, wxPanel) -EVT_RADIOBOX(CinemaInfoBox::Mode_ID, CinemaInfoBox::OnChange) -EVT_RADIOBOX(CinemaInfoBox::Style_ID, CinemaInfoBox::OnChange) -EVT_RADIOBOX(CinemaInfoBox::Spline_ID, CinemaInfoBox::OnChange) -EVT_CHECKBOX(wxID_ANY, CinemaInfoBox::OnChange) -EVT_RADIOBOX(CinemaInfoBox::Rotation_ID, CinemaInfoBox::OnRotation) -EVT_TEXT_ENTER(wxID_ANY, CinemaInfoBox::OnChange) -EVT_BUTTON(CinemaInfoBox::Reset_ID, CinemaInfoBox::ResetCamera) -END_EVENT_TABLE() - -class PathSlider : public wxSlider -{ - static const int range=1024; -public: - PathSlider(CinematicSidebar* side) - : wxSlider(side, wxID_ANY, 0, 0, range, wxDefaultPosition, - wxDefaultSize, wxSL_HORIZONTAL, wxDefaultValidator, _("Path")), - m_Sidebar(side), m_OldTime(0), m_NewTime(0) - { - m_Timer.SetOwner(this); - } - - void Update() - { - if ( m_Sidebar->m_SelectedPath < 0 ) - return; - int sliderValue = (m_Sidebar->m_TimeElapsed / m_Sidebar->GetCurrentPath()->duration) * range; - SetValue(sliderValue); - } - - void OnTick(wxTimerEvent& WXUNUSED(event)) - { - m_NewTime = m_HighResTimer.GetTime(); - 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)); - - void PrepareTimers() - { - m_OldTime = m_NewTime = m_HighResTimer.GetTime(); - m_Timer.Start(10); - } - void Reset() - { - SetValue(0); - } - - float m_OldTime; - float m_NewTime; - wxTimer m_Timer; - -private: - HighResTimer m_HighResTimer; - CinematicSidebar* m_Sidebar; - - DECLARE_EVENT_TABLE(); -}; -BEGIN_EVENT_TABLE(PathSlider, wxSlider) - EVT_SCROLL(PathSlider::OnScroll) - EVT_TIMER(wxID_ANY, PathSlider::OnTick) -END_EVENT_TABLE() - - -void PathSlider::OnScroll(wxScrollEvent& WXUNUSED(event)) -{ - m_Timer.Stop(); - if ( m_Sidebar->m_SelectedPath < 0 ) - { - SetValue(0); - return; - } - - //Move path and send movement message. If blank path, ignore - if ( m_Sidebar->GetCurrentPath()->duration < .0001f ) - return; - - float ratio = (float)GetValue() / (float)range; - float time = ratio * m_Sidebar->GetCurrentPath()->duration; - - POST_MESSAGE(CinemaEvent, - ( m_Sidebar->GetSelectedPathName(), eCinemaEventMode::IMMEDIATE_PATH, time, - m_Sidebar->m_InfoBox->GetDrawCurrent(), m_Sidebar->m_InfoBox->GetDrawLines()) ); - - m_Sidebar->m_TimeElapsed = time; -} - -////////////////////////////////////////////////////////////////////////// - -class CinemaButtonBox : public wxPanel -{ -public: - CinemaButtonBox(CinematicSidebar* parent) : wxPanel(parent), m_Parent(parent) - { - m_Sizer = new wxStaticBoxSizer(wxHORIZONTAL, this); - SetSizer(m_Sizer); - } - void Add(wxBitmapButton* button) - { - m_Sizer->Add(button); - } - void OnPrevious(wxCommandEvent& WXUNUSED(event)) - { - if ( m_Parent->m_SelectedPath < 0 ) - return; - - m_Parent->m_PathSlider->m_Timer.Stop(); - m_Parent->m_Playing = false; - float timeSet = 0.0f; - std::vector nodes = *m_Parent->GetCurrentPath()->nodes; - - for ( size_t i = 0; i < nodes.size(); ++i ) - { - timeSet += nodes[i].t; - if ( fabs((timeSet - m_Parent->m_TimeElapsed)) < .0001f ) - { - timeSet -= nodes[i].t; - break; - } - } - - 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 OnStop(wxCommandEvent& WXUNUSED(event)) - { - if ( m_Parent->m_SelectedPath < 0) - return; - - m_Parent->m_PathSlider->m_Timer.Stop(); - m_Parent->m_Playing = false; - m_Parent->m_TimeElapsed = 0.0f; - m_Parent->m_PathSlider->Update(); - - POST_MESSAGE(CinemaEvent, - (m_Parent->GetSelectedPathName(), eCinemaEventMode::IMMEDIATE_PATH, 0.0f, - m_Parent->m_InfoBox->GetDrawCurrent(), m_Parent->m_InfoBox->GetDrawLines()) ); - } - void OnPlay(wxCommandEvent& WXUNUSED(event)) - { - if ( m_Parent->m_SelectedPath < 0 ) - return; - - m_Parent->m_PathSlider->m_Timer.Stop(); - m_Parent->m_PathSlider->PrepareTimers(); - - POST_MESSAGE(CinemaEvent, - (m_Parent->GetSelectedPathName(), - eCinemaEventMode::SMOOTH, 0.0f, m_Parent->m_InfoBox->GetDrawCurrent(), - m_Parent->m_InfoBox->GetDrawLines()) ); - - m_Parent->m_Playing = true; - } - void OnRecord(wxCommandEvent& WXUNUSED(event)) - { - if ( m_Parent->m_SelectedPath < 0 ) - return; - m_Parent->m_PathSlider->m_Timer.Stop(); - m_Parent->m_PathSlider->PrepareTimers(); - - VideoRecorder::RecordCinematic(this, - wxString( m_Parent->GetSelectedPathName().c_str() ), m_Parent->GetCurrentPath()->duration); - } - void OnPause(wxCommandEvent& WXUNUSED(event)) - { - if ( m_Parent->m_SelectedPath < 0 ) - return; - m_Parent->m_PathSlider->m_Timer.Stop(); - m_Parent->m_Playing = false; - - POST_MESSAGE(CinemaEvent, - (m_Parent->GetSelectedPathName(), - eCinemaEventMode::IMMEDIATE_PATH, m_Parent->m_TimeElapsed, - m_Parent->m_InfoBox->GetDrawCurrent(), m_Parent->m_InfoBox->GetDrawLines()) ); - } - - 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(); - 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; - - POST_MESSAGE(CinemaEvent, - ( name, eCinemaEventMode::IMMEDIATE_PATH, timeSet, - m_Parent->m_InfoBox->GetDrawCurrent(), m_Parent->m_InfoBox->GetDrawLines()) ); - - m_Parent->m_PathSlider->Update(); - } - CinematicSidebar* m_Parent; - wxStaticBoxSizer* m_Sizer; - DECLARE_EVENT_TABLE(); -}; - -BEGIN_EVENT_TABLE(CinemaButtonBox, wxPanel) - EVT_BUTTON(eCinemaButton::previous, CinemaButtonBox::OnPrevious) - EVT_BUTTON(eCinemaButton::stop, CinemaButtonBox::OnStop) - EVT_BUTTON(eCinemaButton::play, CinemaButtonBox::OnPlay) - EVT_BUTTON(eCinemaButton::pause, CinemaButtonBox::OnPause) - EVT_BUTTON(eCinemaButton::next, CinemaButtonBox::OnNext) - EVT_BUTTON(eCinemaButton::record, CinemaButtonBox::OnRecord) -END_EVENT_TABLE() -////////////////////////////////////////////////////////////////////////// - -CinematicSidebar::CinematicSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer) -: Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer), m_SelectedPath(-1), m_SelectedSplineNode(-1), -m_TimeElapsed(0.f), m_RotationAbsolute(false), m_Playing(false) -{ - m_PathSlider = new PathSlider(this); - wxStaticBoxSizer* sliderBox = new wxStaticBoxSizer(wxVERTICAL, this, _T("Timeline")); - sliderBox->Add(m_PathSlider); - m_MainSizer->Add(sliderBox, 0, wxALIGN_CENTER); - m_IconSizer = new CinemaButtonBox(this); - LoadIcons(); //do this here; buttons must be added before box is - - m_MainSizer->Add(m_IconSizer, 0, wxALIGN_CENTER); - m_InfoBox = new CinemaInfoBox(this); - m_MainSizer->Add(m_InfoBox, 0, wxALIGN_CENTER); - - CinematicBottomBar* bottom = new CinematicBottomBar(bottomBarContainer, this); - m_BottomBar = bottom; - m_CinemaBottomBar = bottom; //avoid casting later - - m_PathList = new PathListCtrl(bottom, this); - m_NodeList = new NodeListCtrl(bottom, this); - bottom->AddLists(this, m_PathList, m_NodeList); -} - -void CinematicSidebar::OnFirstDisplay() -{ - qGetCinemaPaths qry; - qry.Post(); - m_Paths = *qry.paths; - - m_PathList->Freeze(); - for (size_t path = 0; path < m_Paths.size(); ++path) - { - m_PathList->InsertItem((long)path, wxString(m_Paths[path].name.c_str())); - } - m_PathList->Thaw(); - -} - -void CinematicSidebar::SelectPath(ssize_t n) -{ - if (n == -1) - { - m_PathList->DeleteAllItems(); - //Do this here to avoid thinking that there's still a path - m_SelectedPath = n; - SelectSplineNode(-1); - return; - } - else - { - wxCHECK_RET (n >= 0 && n < (ssize_t)m_Paths.size(), _T("SelectPath out of bounds")); - - m_SelectedPath = n; - SelectSplineNode(-1); - m_NodeList->Freeze(); - m_NodeList->DeleteAllItems(); - - if (n != -1) - { - size_t size = GetCurrentPath()->nodes.GetSize(); - for ( size_t i=0; iInsertItem((long)i, wxString::Format(_("Node %d"), i)); - } - } - - m_NodeList->Thaw(); - } - POST_MESSAGE(CinemaEvent, ( GetSelectedPathName(), eCinemaEventMode::SELECT, - (int)m_SelectedPath, m_InfoBox->GetDrawCurrent(), m_InfoBox->GetDrawLines() )); - - UpdateSpinners(); -} - -void CinematicSidebar::SelectSplineNode(ssize_t n, ssize_t size) -{ - if (n == -1 || m_SelectedPath == -1) - { - m_NodeList->DeleteAllItems(); - } - else - wxCHECK_RET (n < size, _T("SelectNode out of bounds")); - m_SelectedSplineNode = n; - UpdateSpinners(); -} -const sCinemaPath* CinematicSidebar::GetCurrentPath() const -{ - return &m_Paths[m_SelectedPath]; -} - -sCinemaSplineNode CinematicSidebar::GetCurrentNode() const -{ - if ( m_SelectedSplineNode < 0 ) - { - wxLogError(_("Invalid request for current spline node (no node selected)")); - return sCinemaSplineNode(); - } - return (*GetCurrentPath()->nodes)[m_SelectedSplineNode]; -} -//copied from sectionlayout's addpage() -wxImage CinematicSidebar::LoadIcon(const wxString& filename) -{ - wxImage img (1, 1, true); - - // Load the icon - wxFileName iconPath (_T("tools/atlas/buttons/")); - iconPath.MakeAbsolute(Datafile::GetDataDirectory()); - iconPath.SetFullName(filename); - wxFFileInputStream fstr (iconPath.GetFullPath()); - if (! fstr.Ok()) - { - wxLogError(_("Failed to open cinematic icon file '%s'"), iconPath.GetFullPath().c_str()); - } - else - { - img = wxImage(fstr, wxBITMAP_TYPE_BMP); - if (! img.Ok()) - { - wxLogError(_("Failed to load cinematic icon image '%s'"), iconPath.GetFullPath().c_str()); - img = wxImage (1, 1, true); - } - } - return img; -} -void CinematicSidebar::LoadIcons() -{ - wxBitmapButton* previous = new wxBitmapButton(m_IconSizer, - eCinemaButton::previous, LoadIcon( _T("previous_s.bmp") )); - m_IconSizer->Add(previous); - wxBitmapButton* stop = new wxBitmapButton(m_IconSizer, - eCinemaButton::stop, LoadIcon( _T("stop_s.bmp") )); - m_IconSizer->Add(stop); - wxBitmapButton* play = new wxBitmapButton(m_IconSizer, - eCinemaButton::play, LoadIcon( _T("play_s.bmp") )); - m_IconSizer->Add(play); - wxBitmapButton* pause = new wxBitmapButton(m_IconSizer, - eCinemaButton::pause, LoadIcon( _T("pause_s.bmp") )); - m_IconSizer->Add(pause); - wxBitmapButton* next = new wxBitmapButton(m_IconSizer, - eCinemaButton::next, LoadIcon( _T("next_s.bmp") )); - m_IconSizer->Add(next); - wxBitmapButton* record = new wxBitmapButton(m_IconSizer, - eCinemaButton::record, LoadIcon( _T("record_s.bmp") )); - m_IconSizer->Add(record); -} - -void CinematicSidebar::AddPath(std::wstring& name, int count) //rotation -{ - m_Paths.push_back( sCinemaPath(name) ); - SelectSplineNode(-1); - m_SelectedSplineNode = -1; - m_SelectedPath = count; //Ensure that selection is valid for UpdateEngineData - UpdateEngineData(); //Make sure the path exists in the engine before we send a select message to it - SelectPath(count); - -} -void CinematicSidebar::AddNode(float px, float py, float pz, float rx, float ry, float rz, int count) -{ - if ( m_SelectedPath < 0 ) - return; - - std::vector nodes = *GetCurrentPath()->nodes; - sCinemaSplineNode newNode(px, py, pz, rx, ry, rz); - if ( !nodes.empty() ) - { - newNode.SetTime(1.0f); - m_Paths[m_SelectedPath].duration = m_Paths[m_SelectedPath].duration + 1.0f; - } - - nodes.push_back(newNode); - m_Paths[m_SelectedPath].nodes = nodes; - UpdateEngineData(); - SelectSplineNode(count, count+1); -} - -void CinematicSidebar::DeletePath() -{ - if ( m_SelectedPath < 0 ) - return; - - m_Paths.erase( m_Paths.begin() + m_SelectedPath ); - ssize_t size = (ssize_t)m_Paths.size(); - - m_SelectedSplineNode = -1; - if ( size == 0 ) - SelectPath(-1); - else if ( m_SelectedPath > size-1 ) - SelectPath(size-1); - else - SelectPath(m_SelectedPath); - - UpdateEngineData(); -} - -void CinematicSidebar::DeleteNode() -{ - if ( m_SelectedPath < 0 || m_SelectedSplineNode < 0 ) - return; - - std::vector nodes = *m_Paths[m_SelectedPath].nodes; - m_Paths[m_SelectedPath].duration = m_Paths[m_SelectedPath].duration - nodes[m_SelectedSplineNode].t; - - if ( m_TimeElapsed > m_Paths[m_SelectedPath].duration ) - m_TimeElapsed = m_Paths[m_SelectedPath].duration; - - nodes.erase( nodes.begin() + m_SelectedSplineNode ); - 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); - else if ( m_SelectedSplineNode > size-1 ) - SelectSplineNode(size-1, size); - else - SelectSplineNode(m_SelectedSplineNode, size); - - SelectPath(m_SelectedPath); //Correct numbering - UpdateEngineData(); -} - -void CinematicSidebar::UpdatePath(std::wstring name, float timescale) -{ - if ( m_SelectedPath < 0 ) - return; - - 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, bool absoluteOveride, float t) -{ - if ( m_SelectedPath < 0 || m_SelectedSplineNode < 0 ) - return; - else if ( m_SelectedSplineNode == 0 && t > 0.0f ) - { - wxBell(); //Let them know: the first node has no meaning - return; - } - - std::vector nodes = *GetCurrentPath()->nodes; - if ( t < 0 ) - t = nodes[m_SelectedSplineNode].t; - - if ( m_RotationAbsolute || m_SelectedSplineNode == 0 || absoluteOveride ) - { - nodes[m_SelectedSplineNode].rx = rx; - nodes[m_SelectedSplineNode].ry = ry; - nodes[m_SelectedSplineNode].rz = rz; - } - else - { - nodes[m_SelectedSplineNode].rx = rx + nodes[m_SelectedSplineNode-1].rx; - nodes[m_SelectedSplineNode].ry = ry + nodes[m_SelectedSplineNode-1].ry; - nodes[m_SelectedSplineNode].rz = rz + nodes[m_SelectedSplineNode-1].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; - - nodes[m_SelectedSplineNode] = newNode; - m_Paths[m_SelectedPath].nodes = nodes; - - UpdateEngineData(); -} - -void CinematicSidebar::UpdateSpinners() -{ - if ( m_SelectedPath < 0 || m_SelectedSplineNode < 0 ) - return; - - std::vector nodes = *GetCurrentPath()->nodes; - sCinemaSplineNode node = nodes[m_SelectedSplineNode]; - - if ( !m_RotationAbsolute && m_SelectedSplineNode != 0 ) - { - m_SpinnerBox->UpdateRotationSpinners(node.rx - nodes[m_SelectedSplineNode-1].rx, - node.ry - nodes[m_SelectedSplineNode-1].ry, - node.rz - nodes[m_SelectedSplineNode-1].rz); - } - else - m_SpinnerBox->UpdateRotationSpinners(node.rx, node.ry, node.rz); - - m_SpinnerBox->UpdatePositionSpinners(node.px, node.py, node.pz, node.t, m_SelectedSplineNode); -} - -void CinematicSidebar::UpdateTexts() -{ - if ( m_SelectedPath < 0 ) - return; - - m_CinemaBottomBar->UpdatePath(GetSelectedPathName(), m_Paths[m_SelectedPath].timescale ); - if ( m_SelectedPath >= 0 ) - { - const sCinemaPath* path = GetCurrentPath(); - m_InfoBox->UpdatePath(path); - } -} -void CinematicSidebar::UpdatePathInfo(int mode, int style, float growth, float change, - bool drawCurrent, bool drawLine) -{ - if ( m_SelectedPath < 0 ) - return; - - m_Paths[m_SelectedPath].mode = mode; - m_Paths[m_SelectedPath].style = style; - m_Paths[m_SelectedPath].growth = growth; - m_Paths[m_SelectedPath].change = change; - - UpdateEngineData(); - POST_MESSAGE( CinemaEvent, (GetSelectedPathName(), - eCinemaEventMode::SELECT, (int)m_SelectedPath, drawCurrent, drawLine) ); -} - -void CinematicSidebar::UpdateEngineData() -{ - POST_COMMAND(SetCinemaPaths, (m_Paths) ); - SendEngineSelection(); - UpdateSpinners(); -} -void CinematicSidebar::SendEngineSelection() -{ - POST_MESSAGE(CinemaEvent, ( GetSelectedPathName(), eCinemaEventMode::SELECT, - (int)m_SelectedPath, m_InfoBox->GetDrawCurrent(), m_InfoBox->GetDrawLines() )); -} -void CinematicSidebar::GotoNode(ssize_t index) -{ - if ( m_SelectedPath < 0 || m_SelectedSplineNode < 0 ) - return; - if ( index < 0 ) - index = m_SelectedSplineNode; - - std::vector nodes = *GetCurrentPath()->nodes; - float time = 0; - - for ( ssize_t i=0; i<=index; ++i ) - time += nodes[i].t; - - m_TimeElapsed = time; - POST_MESSAGE( CinemaEvent, (GetSelectedPathName(), eCinemaEventMode::IMMEDIATE_PATH, time, - m_InfoBox->GetDrawCurrent(), m_InfoBox->GetDrawLines()) ); - - //this is just an echo if false - if ( m_TimeElapsed / GetCurrentPath()->duration < 1.f ) - m_PathSlider->Update(); -} - -std::wstring CinematicSidebar::GetSelectedPathName() const -{ - if ( m_SelectedPath < 0 ) - return std::wstring(L"Invalid path"); - return *m_Paths[m_SelectedPath].name; -} diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.h b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.h deleted file mode 100644 index 7db852d30d..0000000000 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.h +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (C) 2009 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 . - */ - -/* - Desc: receives user input and communicates with the engine - to perform various cinematic functions. -*/ - -#include "../Common/Sidebar.h" - -#include "GameInterface/Messages.h" - -class PathListCtrl; -class NodeListCtrl; -class PathSlider; -class CinemaSpinnerBox; -class CinemaInfoBox; -class CinematicBottomBar; -class CinemaButtonBox; -class wxImage; - -class CinematicSidebar : public Sidebar -{ - //For ease (from lazyness) - friend class CinemaButtonBox; - friend class PathSlider; - -public: - - CinematicSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer); - - //The actual data is stored in bottom bar, but is controled from here - void SelectPath(ssize_t n); - //avoid excessive shareable->vector conversion with size paramater - void SelectSplineNode(ssize_t n, ssize_t size = -1); - - 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, bool absoluteOveride, float t=-1); - - void DeleteTrack(); - void DeletePath(); - void DeleteNode(); - - void SetSpinners(CinemaSpinnerBox* box) { m_SpinnerBox = box; } - - const AtlasMessage::sCinemaPath* GetCurrentPath() const; - AtlasMessage::sCinemaSplineNode GetCurrentNode() const; - - std::wstring GetSelectedPathName() const; - int GetSelectedPath() const { return m_SelectedPath; } - int GetSelectedNode() const { return m_SelectedSplineNode; } - - void GotoNode(ssize_t index=-1); - - void UpdatePathInfo(int mode, int style, float growth, float change, bool drawCurrent, bool drawLine); - void UpdateSpinners(); - void UpdateTexts(); - - void UpdateEngineData(); - void SendEngineSelection(); - - float m_TimeElapsed; //path time - float m_AbsoluteTime; //track time - - bool m_RotationAbsolute; //rotation display flag in spinner box - bool m_Playing; - -protected: - virtual void OnFirstDisplay(); - -private: - // Stores all cinematics data for this map. Initialised by OnFirstDisplay. - // Sent back to the game by [TODO]. (TODO: handle 'undo' correctly) - std::vector m_Paths; - CinemaButtonBox* m_IconSizer; - - ssize_t m_SelectedPath; // -1 for none - ssize_t m_SelectedSplineNode; // -1 for none - - PathListCtrl* m_PathList; - NodeListCtrl* m_NodeList; - - PathSlider* m_PathSlider; - CinemaSpinnerBox* m_SpinnerBox; //We must update the display - CinemaInfoBox* m_InfoBox; // ^same^ - CinematicBottomBar* m_CinemaBottomBar; - - wxImage LoadIcon(const wxString& filename); - void LoadIcons(); -}; diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp deleted file mode 100644 index 9518f148ff..0000000000 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp +++ /dev/null @@ -1,1750 +0,0 @@ -/* Copyright (C) 2009 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 "Trigger.h" -#include "GameInterface/Messages.h" -#include "CustomControls/Buttons/ActionButton.h" -#include "ScenarioEditor/ScenarioEditor.h" -#include "ScenarioEditor/Tools/Common/MiscState.h" - -#include "wx/treectrl.h" -#include "wx/listctrl.h" -#include "wx/notebook.h" -#include -#include - -using namespace AtlasMessage; - -BEGIN_EVENT_TABLE(TriggerSidebar, Sidebar) -EVT_TREE_BEGIN_DRAG(wxID_ANY, TriggerSidebar::onTreeDrag) -EVT_TREE_END_LABEL_EDIT(wxID_ANY, TriggerSidebar::onTreeNameChange) -EVT_TREE_SEL_CHANGED(wxID_ANY, TriggerSidebar::onTreeSelChange) -EVT_LIST_ITEM_SELECTED(TriggerSidebar::ID_CondList, TriggerSidebar::onCondSelect) -EVT_LIST_ITEM_SELECTED(TriggerSidebar::ID_EffectList, TriggerSidebar::onEffectSelect) -EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, TriggerSidebar::onPageChange) -END_EVENT_TABLE() - - -class TriggerTreeCtrl : public wxTreeCtrl -{ -public: - TriggerTreeCtrl(TriggerSidebar* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS ) - : wxTreeCtrl(parent, id, pos, size, style), m_Sidebar(parent) { } - - void onClick(wxMouseEvent& evt); - -private: - TriggerSidebar* m_Sidebar; - DECLARE_EVENT_TABLE(); -}; - -BEGIN_EVENT_TABLE(TriggerTreeCtrl, wxTreeCtrl) -EVT_LEFT_DOWN(TriggerTreeCtrl::onClick) -END_EVENT_TABLE() - - -struct LogicBlockHelper -{ - LogicBlockHelper() { index = -1; end = false; } - LogicBlockHelper(int _index, bool _end) : index(_index), end(_end) {} - int index; - bool end; - - bool operator< ( const LogicBlockHelper& rhs ) const - { - return index < rhs.index; - } - bool operator== ( const LogicBlockHelper& rhs ) const - { - return index == rhs.index; - } -}; -class TriggerSpecText : public wxTextCtrl -{ - typedef void (*callback)(void* data, std::wstring input, int parameter); - -public: - TriggerSpecText(wxWindow* parent, std::wstring label, const wxPoint& pos, const wxSize& size, - int parameter, std::wstring dataType, callback func, void* data) - : wxTextCtrl(parent, wxID_ANY, wxString( label.c_str() ), pos, size, wxTE_PROCESS_ENTER), - m_DataType(dataType), m_Parameter(parameter), m_Data(data), m_Callback(func) - { - } - void onTextEnter(wxCommandEvent& WXUNUSED(evt)); - - //Disallow invalid input - bool VerifyInput(std::wstring& input) - { - std::wstringstream stream(input); - if ( m_DataType == L"int" ) - { - int test; - stream >> test; - return !stream.fail(); - } - else if ( m_DataType == L"real" ) - { - float test; - stream >> test; - return !stream.fail(); - } - else if ( m_DataType == L"bool" ) - { - bool test; - stream >> test; - return !stream.fail(); - } - else if ( m_DataType == L"string" ) - { - //Make strings appear as strings to javascript - std::wstring quote(L"\""); - input.insert(0, quote); - input.append(quote); - return true; - } - else - { - wxFAIL_MSG(L"Invalid input type for trigger specification"); - return false; - } - } -private: - void* m_Data; - int m_Parameter; - std::wstring m_DataType; - callback m_Callback; - - DECLARE_EVENT_TABLE(); - -}; -BEGIN_EVENT_TABLE(TriggerSpecText, wxTextCtrl) -EVT_TEXT_ENTER(wxID_ANY, TriggerSpecText::onTextEnter) -END_EVENT_TABLE() - -class TriggerSpecChoice : public wxChoice -{ - typedef void (*callback)(void* data, std::wstring input, int parameter); - -public: - TriggerSpecChoice(TriggerBottomBar* parent, std::wstring label, const wxPoint& pos, - const wxSize& size, const wxArrayString& strings, int parameter, callback func, void* data); - - void onChoice(wxCommandEvent& evt); - -private: - TriggerBottomBar* m_Parent; - callback m_Callback; - int m_Parameter; - void* m_Data; - - DECLARE_EVENT_TABLE(); -}; - -BEGIN_EVENT_TABLE(TriggerSpecChoice, wxChoice) -EVT_CHOICE(wxID_ANY, TriggerSpecChoice::onChoice) -END_EVENT_TABLE() - -class TriggerBottomBar; - -class TriggerEntitySelector : public wxPanel -{ - typedef void (*callback)(void* data, std::wstring input, int parameter); - enum { ID_SELECTION, ID_VIEW }; -public: - - TriggerEntitySelector(TriggerBottomBar* parent, std::wstring label, const wxPoint& pos, - const wxSize& size, int parameter, callback func, void* data); - - void onSelectionClick(wxCommandEvent& WXUNUSED(evt)) - { - std::wstring code(L"["); - std::wstringstream stream; - for ( size_t i = 0; i < g_SelectedObjects.size(); ++i ) - { - stream << g_SelectedObjects[i]; - if ( i != g_SelectedObjects.size()-1 ) - stream << L", "; - } - - code.append(stream.str()); - code.append(L"]"); - (*m_Callback)(m_Data, code, m_Parameter); - POST_MESSAGE(SetSelectionPreview, (g_SelectedObjects)); - } - void onViewClick(wxCommandEvent& WXUNUSED(evt)); - -private: - int m_Parameter; - callback m_Callback; - TriggerBottomBar* m_Parent; - void* m_Data; - - DECLARE_EVENT_TABLE(); -}; -BEGIN_EVENT_TABLE(TriggerEntitySelector, wxPanel) -EVT_BUTTON(TriggerEntitySelector::ID_SELECTION, TriggerEntitySelector::onSelectionClick) -EVT_BUTTON(TriggerEntitySelector::ID_VIEW, TriggerEntitySelector::onViewClick) -END_EVENT_TABLE() - -class TriggerPointPlacer : public wxPanel -{ - enum { ID_Set, ID_View }; - typedef void (*callback)(void* data, std::wstring input, int parameter); -public: - - TriggerPointPlacer(wxWindow* parent, const wxPoint& pos, - const wxSize& size, int parameter, callback func, void* data) : m_Callback(func), - wxPanel(parent, wxID_ANY, pos), m_Parameter(parameter), m_Data(data) - { - wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(mainSizer); - mainSizer->Add( new wxButton(this, ID_Set, L"Set point", pos, size) ); - mainSizer->Add( new wxButton(this, ID_View, L"View", pos, size) ); - } - - - void onSet(wxCommandEvent& WXUNUSED(evt)) - { - qGetWorldPosition query( wxGetMousePosition().x, wxGetMousePosition().y ); - query.Post(); - Position pos = query.position; - wxString wxForm = wxString::Format(L"Vector(%f, %f, %f)", pos.type0.x, pos.type0.y, pos.type0.z); - - std::wstring convert = (std::wstring)wxForm; - (*m_Callback)(m_Data, convert, m_Parameter); - POST_MESSAGE(TriggerToggleSelector, (true, pos)); - } - - void onView(wxCommandEvent& WXUNUSED(evt)) - { - //POST_MESSAGE( TriggerToggleSelector, (pos) ); - } - -private: - int m_Parameter; - void* m_Data; - callback m_Callback; - bool m_MouseCapture; - - DECLARE_EVENT_TABLE(); -}; - -BEGIN_EVENT_TABLE(TriggerPointPlacer, wxPanel) -EVT_BUTTON(TriggerPointPlacer::ID_Set, TriggerPointPlacer::onSet) -EVT_BUTTON(TriggerPointPlacer::ID_View, TriggerPointPlacer::onView) -END_EVENT_TABLE() - - -class TriggerListCtrl : public wxListCtrl -{ -public: - TriggerListCtrl(wxWindow* parent, TriggerSidebar* sidebar, bool condition, wxWindowID id, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxLC_ICON) - : wxListCtrl(parent, id, pos, size, style), m_Sidebar(sidebar), m_Condition(condition) - { - } - void onClick(wxMouseEvent& evt); - - TriggerSidebar* m_Sidebar; - bool m_Condition; -private: - DECLARE_EVENT_TABLE(); -}; -BEGIN_EVENT_TABLE(TriggerListCtrl, wxListCtrl) -EVT_LEFT_DOWN(TriggerListCtrl::onClick) -END_EVENT_TABLE() - - -class TriggerPage : public wxPanel -{ -public: - TriggerPage(wxWindow* parent, TriggerSidebar* sidebar, long ID, wxString title, bool condition) - : wxPanel(parent), m_Sidebar(sidebar), m_Condition(condition) - - { - wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); - - m_List = new TriggerListCtrl(this, sidebar, condition, ID, wxDefaultPosition, - wxSize(132, 210), wxLC_REPORT | wxLC_SINGLE_SEL); - m_List->InsertColumn(0, title, wxLIST_FORMAT_LEFT, 100); - - sizer->Add(m_List); - SetSizer(sizer); - } - - wxListCtrl* m_List; - TriggerSidebar* m_Sidebar; - bool m_Condition; -}; - - -class TriggerItemData : public wxTreeItemData, public sTrigger -{ -public: - TriggerItemData(TriggerSidebar* sidebar, const std::wstring& name, bool group) - : m_Sidebar(sidebar), sTrigger(name), m_Group(group), m_CondCount(0), m_EffectCount(0) {} - TriggerItemData(TriggerSidebar* sidebar, const sTrigger& trigger, bool group) - : m_Sidebar(sidebar), sTrigger(trigger), m_Group(group), m_CondCount(0), m_EffectCount(0) {} - - TriggerSidebar* m_Sidebar; - size_t m_CondCount, m_EffectCount; - bool m_Group; - std::list m_BlockIndices, m_BlockEndIndices; //index in sidebar list - - void AddBlock(const int block, const int index) - { - std::vector copy = *logicBlocks; - std::vector notCopy = *logicNots; - copy.push_back(block); - notCopy.push_back(false); - - logicBlocks = copy; - logicNots = notCopy; - m_BlockIndices.push_back(index); - } - void AddBlockEnd(const int block, const int index) - { - std::vector copy = *logicBlockEnds; - copy.push_back(block); - logicBlockEnds = copy; - m_BlockEndIndices.push_back(index); - } - - void ResetBlockIndices() - { - std::vector newLogicBlocks, newLogicBlockEnds; - m_BlockIndices.clear(); - m_BlockEndIndices.clear(); - int conditionCount = 0; - - for (int i=0; im_ConditionPage->m_List->GetItemCount(); ++i) - { - if ( m_Sidebar->m_ConditionPage->m_List->GetItemText(i) == m_Sidebar->m_LogicBlockString ) - { - newLogicBlocks.push_back(conditionCount); - m_BlockIndices.push_back(i); - } - - //Block ends belong to current condition, hence conditionCount-1 - else if ( m_Sidebar->m_ConditionPage->m_List->GetItemText(i) == m_Sidebar->m_LogicBlockEndString ) - { - if ( conditionCount == 0 ) - newLogicBlockEnds.push_back(0); - else - newLogicBlockEnds.push_back(conditionCount-1); - m_BlockEndIndices.push_back(i); - } - else - ++conditionCount; - } - logicBlocks = newLogicBlocks; - logicBlockEnds = newLogicBlockEnds; - } -}; - - -void onTriggerParameter(void* data, std::wstring paramString, int parameter); - - -class TriggerBottomBar : public wxPanel -{ - enum { ID_TimeEdit, ID_CondNameEdit, ID_EffectNameEdit, ID_TriggerNameEdit, ID_RunsEdit, - ID_EffectChoice, ID_CondChoice, - ID_TimeRadio, ID_LogicRadio, - ID_NotCheck, ID_ActiveCheck, ID_LogicNotCheck }; - -public: - enum { NO_VIEW, TRIGGER_VIEW, CONDITION_VIEW, EFFECT_VIEW, LOGIC_END_VIEW, LOGIC_VIEW }; - - TriggerBottomBar(TriggerSidebar* sidebar, wxWindow* parent) - : wxPanel(parent), m_Sidebar(sidebar) - { - m_Sizer = new wxBoxSizer(wxHORIZONTAL); - SetSizer(m_Sizer); - m_DependentStatus = NO_VIEW; - } - - int GetDependentStatus() - { - return m_DependentStatus; - } - void SetSpecs(std::vector conditions, std::vector effects) - { - m_ConditionSpecs = conditions; - m_EffectSpecs = effects; - } - - wxArrayString GetConditionNames() - { - wxArrayString ret; - for ( size_t i = 0; i < m_ConditionSpecs.size(); ++i ) - ret.Add( wxString(m_ConditionSpecs[i].displayName.c_str()) ); - return ret; - } - wxArrayString GetEffectNames() - { - wxArrayString ret; - for ( size_t i = 0; i < m_EffectSpecs.size(); ++i ) - ret.Add( wxString(m_EffectSpecs[i].displayName.c_str()) ); - return ret; - } - - void onEffectChoice(wxCommandEvent& evt) - { - //Retrieve specification corresponding to selection - if ( m_Sidebar->m_SelectedEffect != -1 ) - { - std::vector::iterator it = std::find( m_EffectSpecs.begin(), - m_EffectSpecs.end(), std::wstring(evt.GetString()) ); - DisplayTriggerSpec(*it); - } - } - - void onCondChoice(wxCommandEvent& evt) - { - if ( m_Sidebar->m_SelectedCond != -1 ) - { - std::vector::iterator it = std::find( m_ConditionSpecs.begin(), - m_ConditionSpecs.end(), std::wstring(evt.GetString()) ); - DisplayTriggerSpec(*it); - } - } - - void onTimeEnter(wxCommandEvent& WXUNUSED(evt)) - { - float fValue; - std::wstringstream stream( std::wstring(m_TimeEdit->GetValue()) ); - stream >> fValue; - - if ( stream.fail() ) - { - wxBell(); - return; - } - - m_Sidebar->GetSelectedItemData()->timeValue = fValue; - wxString value = wxString::Format(L"%.2f", fValue); - m_TimeEdit->SetValue(value); - m_Sidebar->UpdateEngineData(); - } - - void onConditionEnter(wxCommandEvent& WXUNUSED(evt)) - { - if ( m_Sidebar->m_SelectedCond == -1 ) - return; - - std::vector conditions = *m_Sidebar->GetSelectedItemData()->conditions; - int condition = m_Sidebar->GetConditionCount(m_Sidebar->m_SelectedCond); - - if ( condition == 0 ) - conditions[0].name = std::wstring( m_ConditionEdit->GetValue() ); - else - conditions[condition-1] = std::wstring( m_ConditionEdit->GetValue() ); - - m_Sidebar->GetSelectedItemData()->conditions = conditions; - m_Sidebar->UpdateLists(); - m_Sidebar->UpdateEngineData(); - } - void onEffectEnter(wxCommandEvent& WXUNUSED(evt)) - { - if ( m_Sidebar->m_SelectedEffect== -1 ) - return; - - std::vector effects = *m_Sidebar->GetSelectedItemData()->effects; - effects[m_Sidebar->m_SelectedEffect].name = std::wstring( m_EffectEdit->GetValue() ); - m_Sidebar->GetSelectedItemData()->effects = effects; - m_Sidebar->UpdateLists(); - m_Sidebar->UpdateEngineData(); - } - void onTriggerEnter(wxCommandEvent& WXUNUSED(evt)) - { - TriggerItemData* data = m_Sidebar->GetSelectedItemData(); - if ( data == NULL || m_Sidebar->m_TriggerTree->GetSelection() == m_Sidebar->m_TriggerTree->GetRootItem() ) - return; - - wxString name = m_TriggerEdit->GetValue(); - data->name = std::wstring(name); - m_Sidebar->m_TriggerTree->SetItemText(m_Sidebar->m_TriggerTree->GetSelection(), name); - m_Sidebar->UpdateEngineData(); - } - - void onRunsEnter(wxCommandEvent& WXUNUSED(evt)) - { - int iValue; - std::wstringstream stream( std::wstring(m_RunsEdit->GetValue()) ); - stream >> iValue; - - if ( stream.fail() ) - { - wxBell(); - return; - } - - m_Sidebar->GetSelectedItemData()->maxRuns = iValue; - m_Sidebar->UpdateEngineData(); - } - - void onLogicRadio(wxCommandEvent& evt) - { - if ( m_Sidebar->m_SelectedCond == -1 ) - return; - std::vector conditions = *m_Sidebar->GetSelectedItemData()->conditions; - int condition = m_Sidebar->GetConditionCount(m_Sidebar->m_SelectedCond); - conditions[condition-1].linkLogic = evt.GetInt() + 1; - - m_Sidebar->GetSelectedItemData()->conditions = conditions; - m_Sidebar->UpdateLists(); - m_Sidebar->UpdateEngineData(); - } - void onActiveCheck(wxCommandEvent& evt) - { - m_Sidebar->GetSelectedItemData()->active = (evt.GetInt() == 1); - m_Sidebar->UpdateEngineData(); - } - void onNotCheck(wxCommandEvent& evt) - { - if ( m_Sidebar->m_SelectedCond == -1 ) - return; - std::vector conditions = *m_Sidebar->GetSelectedItemData()->conditions; - int condition = m_Sidebar->GetConditionCount(m_Sidebar->m_SelectedCond); - bool value = (evt.GetInt() == 1); - conditions[condition-1].negated = value; - - m_Sidebar->GetSelectedItemData()->conditions = conditions; - m_Sidebar->UpdateLists(); - m_Sidebar->UpdateEngineData(); - } - - void onLogicNotCheck(wxCommandEvent& evt) - { - TriggerItemData* data = m_Sidebar->GetSelectedItemData(); - - int logicIndex = m_Sidebar->GetLogicBlockCount(m_Sidebar->m_SelectedCond) - 1; - std::vector nots = *data->logicNots; - nots[logicIndex] = evt.IsChecked(); - data->logicNots = nots; - } - - void DisplayTriggerSpec(const sTriggerSpec& spec) - { - if ( m_Sizer->Detach(m_ParameterSizer) ) - { - m_ParameterSizer->DeleteWindows(); - delete m_ParameterSizer; - //m_Sizer->Layout(); - // Layout(); - } - - //m_ParameterSizer = new wxStaticBoxSizer(wxVERTICAL, this, L"Parameters"); - m_ParameterSizer = new wxBoxSizer(wxVERTICAL); - wxBoxSizer* hRow = NULL; - std::vector parameters = *spec.parameters; - std::vector stringParameters; - int row = -1; - - //Set parameter data to new data if change is needed - if ( m_Sidebar->m_Notebook->GetCurrentPage() == m_Sidebar->m_ConditionPage ) - { - std::vector conditions = *m_Sidebar->GetSelectedItemData()->conditions; - int condition = m_Sidebar->GetConditionCount(m_Sidebar->m_SelectedCond) - 1 ; - if ( *conditions[condition].displayName != *spec.displayName ) - { - std::vector newParameters(parameters.size()); - conditions[condition].parameters = newParameters; - conditions[condition].displayName = *spec.displayName; - conditions[condition].functionName = *spec.functionName; - m_Sidebar->GetSelectedItemData()->conditions = conditions; - m_Sidebar->UpdateEngineData(); - } - stringParameters = *(*m_Sidebar->GetSelectedItemData()->conditions) - [m_Sidebar->m_SelectedCond].parameters; - } - else - { - std::vector effects = *m_Sidebar->GetSelectedItemData()->effects; - if ( *effects[m_Sidebar->m_SelectedEffect].displayName != *spec.displayName ) - { - std::vector newParameters(parameters.size()); - effects[m_Sidebar->m_SelectedEffect].parameters = newParameters; - effects[m_Sidebar->m_SelectedEffect].displayName = *spec.displayName; - effects[m_Sidebar->m_SelectedEffect].functionName = *spec.functionName; - m_Sidebar->GetSelectedItemData()->effects = effects; - m_Sidebar->UpdateEngineData(); - } - stringParameters = *(*m_Sidebar->GetSelectedItemData()->effects) - [m_Sidebar->m_SelectedEffect].parameters; - } - - //Add all parameters to sizer - for ( std::vector::iterator it=parameters.begin(); it!=parameters.end(); ++it ) - { - if ( it->row != row ) - { - row = it->row; - hRow = new wxBoxSizer(wxHORIZONTAL); - m_ParameterSizer->Add(hRow); - } - - - if ( *it->windowType == std::wstring(L"text") ) - { - hRow->Add( new wxStaticText(this, wxID_ANY, wxString( (*it->name).c_str() ), - wxPoint(it->xPos, it->yPos)) ); - wxTextCtrl* text = new TriggerSpecText(this, L"", wxDefaultPosition, wxSize(it->xSize, it->ySize), - it->parameterOrder, *it->inputType, &onTriggerParameter, this); - - hRow->Add( text, 0, wxLEFT, 5 ); - wxString fill( stringParameters[it->parameterOrder].c_str() ); - - //Trim quotes - if ( *it->inputType == L"string" && fill.size() > 0 ) - { - fill.erase(0, 1); - fill.erase(fill.size()-1, 1); - } - text->SetValue(fill); - } - - else if ( *it->windowType == std::wstring(L"choice") ) - { - qGetTriggerChoices qChoices(*spec.functionName + *it->name); - qChoices.Post(); - std::vector choices = *qChoices.choices; - wxArrayString strings; - - for ( size_t i = 0; i < choices.size(); ++i ) - strings.Add( wxString(choices[i].c_str()) ); - - hRow->Add( new wxStaticText(this, wxID_ANY, wxString( (*it->name).c_str() ), - wxPoint(it->xPos, it->yPos)) ); - wxChoice* choice = new TriggerSpecChoice( this, L"", wxDefaultPosition, wxSize(it->xSize, it->ySize), - strings, it->parameterOrder, &onTriggerParameter, this ); - - hRow->Add(choice); - choice->SetStringSelection( wxString(stringParameters[it->parameterOrder].c_str()) ); - } - - else if ( *it->windowType == std::wstring(L"entity_selector") ) - { - hRow->Add( new wxStaticText(this, wxID_ANY, wxString((*it->name).c_str())) ); - hRow->Add( new TriggerEntitySelector(this, L"Select", wxDefaultPosition, - wxSize(it->xSize, it->ySize), it->parameterOrder, &onTriggerParameter, this) ); - } - - else if ( *it->windowType == std::wstring(L"point_placer") ) - { - hRow->Add( new wxStaticText(this, wxID_ANY, wxString((*it->name).c_str())) ); - hRow->Add( new TriggerPointPlacer(this, wxDefaultPosition, wxSize(it->xSize, it->ySize), - it->parameterOrder, &onTriggerParameter, this) ); - } - else - { - wxFAIL_MSG(L"Invalid window type for trigger specification"); - row = -1; - //do something else... - } - } - - //(If nothing was added, it won't be automatically delted) - if ( row < 0 ) - { - delete hRow; - delete m_ParameterSizer; - } - else - m_Sizer->Add(m_ParameterSizer, 0, wxLEFT, 5); - - m_Sizer->Layout(); - Layout(); - } - - void FillConditionData() - { - if ( m_Sidebar->m_SelectedCond == -1 ) - return; - - TriggerItemData* itemData = m_Sidebar->GetSelectedItemData(); - int iCondition = m_Sidebar->GetConditionCount(m_Sidebar->m_SelectedCond); - if ( iCondition <= 0 ) - return; - sTriggerCondition condition = (*itemData->conditions)[iCondition-1]; - wxString display( (*condition.displayName).c_str() ); - m_ConditionEdit->SetValue( wxString(condition.name.c_str()) ); - - if ( display != L"" ) - { - std::vector::iterator it = std::find( m_ConditionSpecs.begin(), - m_ConditionSpecs.end(), std::wstring(display) ); - if ( it != m_ConditionSpecs.end() ) - { - m_ConditionChoice->SetStringSelection(display); - DisplayTriggerSpec(*it); - } - } - else - m_ConditionChoice->SetStringSelection(display); - - if ( condition.linkLogic == 0 || condition.linkLogic == 1 ) - m_LogicRadio->SetSelection(0); - else - m_LogicRadio->SetSelection(1); - - m_NotCheck->SetValue(condition.negated); - } - - void FillEffectData() - { - TriggerItemData* itemData = m_Sidebar->GetSelectedItemData(); - sTriggerEffect effect = (*itemData->effects)[m_Sidebar->m_SelectedEffect]; - wxString display( (*effect.displayName).c_str() ); - - m_EffectEdit->SetValue( wxString(effect.name.c_str()) ); - if ( display != L"" ) - { - std::vector::iterator it = std::find( m_EffectSpecs.begin(), - m_EffectSpecs.end(), std::wstring(display) ); - if ( it != m_EffectSpecs.end() ) - { - m_EffectChoice->SetStringSelection(display); - DisplayTriggerSpec(*it); - } - } - //m_TimeRadio->SetSelection(effect.loop); - - float timeVal = itemData->timeValue; - wxString value = wxString::Format(L"%.2f", timeVal); - m_TimeEdit->SetValue(value); - } - - void FillTriggerData() - { - if ( m_DependentStatus != TRIGGER_VIEW ) - return; - TriggerItemData* itemData = m_Sidebar->GetSelectedItemData(); - m_TriggerEdit->SetValue( wxString( (*itemData->name).c_str()) ); - m_ActiveCheck->SetValue(itemData->active); - int runs = itemData->maxRuns; - m_RunsEdit->SetValue( wxString( wxString::Format(L"%d", runs)) ); - - } - - void FillLogicData() - { - std::vector nots = *m_Sidebar->GetSelectedItemData()->logicNots; - m_LogicNotCheck->SetValue( nots[m_Sidebar->GetLogicBlockCount(m_Sidebar->m_SelectedCond)-1] ); - } - - - void ToEffectView() - { - DestroyChildren(); - m_Sizer = new wxBoxSizer(wxHORIZONTAL); - m_DependentSizer = new wxStaticBoxSizer(wxVERTICAL, this, wxString(L"Trigger Editor")); - SetSizer(m_Sizer, true); - - m_DependentSizer = new wxStaticBoxSizer(wxVERTICAL, this, wxString(L"Trigger Editor")); - wxStaticText* name = new wxStaticText(this, wxID_ANY, wxString(L"Name:")); - wxStaticText* effect = new wxStaticText(this, wxID_ANY, wxString(L"Effect:")); - m_EffectEdit = new wxTextCtrl(this, ID_EffectNameEdit, _T(""), wxDefaultPosition, - wxSize(100, 18), wxTE_PROCESS_ENTER); - - wxArrayString effectNames = GetEffectNames(); - wxString radioChoice[] = { wxString(L"Delay"), wxString(L"Loop") }; - m_EffectChoice = new wxChoice(this, ID_EffectChoice, wxDefaultPosition, wxSize(100, 13), effectNames); - - m_TimeRadio = new wxRadioBox(this, ID_TimeRadio, _T("Execution type"), - wxDefaultPosition, wxDefaultSize, 2, radioChoice, 2, wxRA_SPECIFY_COLS); - - wxStaticText* time = new wxStaticText(this, wxID_ANY, wxString(L"Time:")); - m_TimeEdit = new wxTextCtrl(this, ID_TimeEdit, _T(""), wxDefaultPosition, - wxSize(100, 18), wxTE_PROCESS_ENTER); - - wxBoxSizer* hNameHolder = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer* hEffectHolder = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer* hTimeHolder = new wxBoxSizer(wxHORIZONTAL); - - hNameHolder->Add(name); - hNameHolder->Add(m_EffectEdit, 0, wxLEFT, 5); - hEffectHolder->Add(effect); - hEffectHolder->Add(m_EffectChoice, 0, wxLEFT, 5); - hTimeHolder->Add(time); - hTimeHolder->Add(m_TimeEdit, 0, wxLEFT, 5); - - m_DependentSizer->Add(hNameHolder, 0, wxTOP, 5); - m_DependentSizer->Add(hEffectHolder, 0, wxTOP, 5); - m_DependentSizer->Add(m_TimeRadio, 0, wxTOP | wxALIGN_CENTER, 10); - m_DependentSizer->Add(hTimeHolder, 0, wxTOP | wxALIGN_CENTER, 5); - - m_Sizer->Add(m_DependentSizer); - m_Sizer->Layout(); - Layout(); - m_DependentStatus = EFFECT_VIEW; - } - - void ToConditionView() - { - DestroyChildren(); - m_Sizer = new wxBoxSizer(wxHORIZONTAL); - m_DependentSizer = new wxStaticBoxSizer(wxVERTICAL, this, wxString(L"Trigger Editor")); - SetSizer(m_Sizer, true); - - wxStaticText* name = new wxStaticText(this, wxID_ANY, wxString(L"Name:")); - wxStaticText* condition = new wxStaticText(this, wxID_ANY, wxString(L"Condition:")); - m_ConditionEdit = new wxTextCtrl(this, ID_CondNameEdit, _T(""), wxDefaultPosition, - wxSize(100, 18), wxTE_PROCESS_ENTER); - - wxArrayString conditionNames = GetConditionNames(); - wxString radioChoice[] = { wxString(L"And"), wxString(L"Or") }; - m_ConditionChoice = new wxChoice(this, ID_CondChoice, wxDefaultPosition, - wxSize(100, 13), conditionNames); - - m_LogicRadio = new wxRadioBox(this, ID_LogicRadio, _T("Link logic:"), - wxDefaultPosition, wxDefaultSize, 2, radioChoice, 2, wxRA_SPECIFY_COLS); - - m_NotCheck = new wxCheckBox(this, ID_NotCheck, wxString(L"Not ")); - - wxBoxSizer* hNameHolder = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer* hConditionHolder = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer* hLogicHolder = new wxBoxSizer(wxHORIZONTAL); - - hNameHolder->Add(name); - hNameHolder->Add(m_ConditionEdit, 0, wxLEFT | wxALIGN_CENTER, 5); - hConditionHolder->Add(condition); - hConditionHolder->Add(m_ConditionChoice, 0, wxLEFT | wxALIGN_CENTER, 5); - hLogicHolder->Add(m_LogicRadio, 0, 0, 5); - hLogicHolder->Add(m_NotCheck, 0, wxLEFT | wxALIGN_CENTER, 5); - - m_DependentSizer->Add(hNameHolder, 0, wxTOP, 5); - m_DependentSizer->Add(hConditionHolder, 0, wxTOP, 5); - m_DependentSizer->Add(hLogicHolder, 0, wxALIGN_CENTER | wxTOP, 10); - - m_Sizer->Add(m_DependentSizer); - m_Sizer->Layout(); - Layout(); - m_DependentStatus = CONDITION_VIEW; - } - - void ToTriggerView() - { - DestroyChildren(); - m_Sizer = new wxBoxSizer(wxHORIZONTAL); - m_DependentSizer = new wxStaticBoxSizer(wxVERTICAL, this, wxString(L"Trigger Editor")); - SetSizer(m_Sizer, true); - - wxStaticText* name = new wxStaticText(this, wxID_ANY, wxString(L"Name:")); - m_TriggerEdit = new wxTextCtrl(this, ID_TriggerNameEdit, _T(""), wxDefaultPosition, - wxSize(100, 18), wxTE_PROCESS_ENTER); - - wxStaticText* runs = new wxStaticText(this, wxID_ANY, wxString(L"Maximum runs:")); - m_RunsEdit = new wxTextCtrl(this, ID_RunsEdit, wxString(L"-1"), wxDefaultPosition, wxSize(100, 18)); - m_ActiveCheck = new wxCheckBox(this, ID_ActiveCheck, wxString(L"Active: ")); - - wxBoxSizer* nameHolder = new wxBoxSizer(wxHORIZONTAL), *runsHolder = new wxBoxSizer(wxHORIZONTAL); - - nameHolder->Add(name); - nameHolder->Add(m_TriggerEdit, 0, wxLEFT, 5); - runsHolder->Add(runs); - runsHolder->Add(m_RunsEdit, 0, wxLEFT, 5); - - m_DependentSizer->Add(nameHolder); - m_DependentSizer->Add(runsHolder, 0, wxTOP, 5); - m_DependentSizer->Add(m_ActiveCheck, 0, wxTOP, 5); - - m_Sizer->Add(m_DependentSizer); - m_Sizer->Layout(); - Layout(); - m_DependentStatus = TRIGGER_VIEW; - } - //void ToLogicEndView(); - - void ToLogicView() - { - DestroyChildren(); - m_Sizer = new wxBoxSizer(wxHORIZONTAL); - m_DependentSizer = new wxStaticBoxSizer(wxVERTICAL, this, wxString(L"Trigger Editor")); - SetSizer(m_Sizer, true); - - m_LogicNotCheck = new wxCheckBox(this, ID_LogicNotCheck, L"Not"); - m_DependentSizer->Add(m_LogicNotCheck); - m_Sizer->Add(m_DependentSizer, 0, wxTOP | wxLEFT | wxALIGN_LEFT, 10); - m_Sizer->Layout(); - Layout(); - m_DependentStatus = LOGIC_VIEW; - } - void ToNoView() - { - if ( m_DependentStatus == NO_VIEW ) - return; - DestroyChildren(); - m_DependentStatus = NO_VIEW; - m_Sidebar->m_ConditionPage->m_List->DeleteAllItems(); - m_Sidebar->m_EffectPage->m_List->DeleteAllItems(); - } - - TriggerSidebar* m_Sidebar; - -private: - - wxBoxSizer* m_Sizer, *m_ParameterSizer; - wxStaticBoxSizer* m_DependentSizer; //dependent = effect/condition - - wxTextCtrl* m_TimeEdit, *m_ConditionEdit, *m_EffectEdit, *m_TriggerEdit, *m_RunsEdit; - wxCheckBox* m_ActiveCheck, *m_NotCheck, *m_LogicNotCheck; - wxChoice* m_ConditionChoice, *m_EffectChoice; - wxRadioBox* m_LogicRadio, *m_TimeRadio, m_LogicEndRadio; - - std::vector m_ConditionSpecs, m_EffectSpecs; - - int m_DependentStatus; - - DECLARE_EVENT_TABLE(); -}; - - -BEGIN_EVENT_TABLE(TriggerBottomBar, wxPanel) -EVT_TEXT_ENTER(TriggerBottomBar::ID_TimeEdit, TriggerBottomBar::onTimeEnter) -EVT_TEXT_ENTER(TriggerBottomBar::ID_CondNameEdit, TriggerBottomBar::onConditionEnter) -EVT_TEXT_ENTER(TriggerBottomBar::ID_EffectNameEdit, TriggerBottomBar::onEffectEnter) -EVT_TEXT_ENTER(TriggerBottomBar::ID_TriggerNameEdit, TriggerBottomBar::onTriggerEnter) -EVT_TEXT_ENTER(TriggerBottomBar::ID_RunsEdit, TriggerBottomBar::onRunsEnter) -EVT_CHOICE(TriggerBottomBar::ID_EffectChoice, TriggerBottomBar::onEffectChoice) -EVT_CHOICE(TriggerBottomBar::ID_CondChoice, TriggerBottomBar::onCondChoice) - -EVT_RADIOBOX(TriggerBottomBar::ID_LogicRadio, TriggerBottomBar::onLogicRadio) -EVT_CHECKBOX(TriggerBottomBar::ID_ActiveCheck, TriggerBottomBar::onActiveCheck) -EVT_CHECKBOX(TriggerBottomBar::ID_NotCheck, TriggerBottomBar::onNotCheck) -EVT_CHECKBOX(TriggerBottomBar::ID_LogicNotCheck, TriggerBottomBar::onLogicNotCheck) -//EVT_RADIOBOX(TriggerBotomBar::ID_TimeRadio, TriggerBottomBar::onTimeRadio) -END_EVENT_TABLE() - - -void TriggerTreeCtrl::onClick(wxMouseEvent& evt) -{ - if ( m_Sidebar->m_TriggerTree->GetSelection() == m_Sidebar->m_TriggerTree->GetRootItem() || - !m_Sidebar->m_TriggerTree->GetSelection() ) - { - m_Sidebar->m_TriggerBottom->ToNoView(); - } - else - { - m_Sidebar->m_TriggerBottom->ToTriggerView(); - m_Sidebar->m_TriggerBottom->FillTriggerData(); - } - evt.Skip(); -} - -void TriggerListCtrl::onClick(wxMouseEvent& evt) -{ - evt.Skip(); - if ( m_Condition ) - { - 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->ToNoView(); - } - else if ( m_Sidebar->m_ConditionPage->m_List->GetItemText(m_Sidebar->m_SelectedCond) - == m_Sidebar->m_LogicBlockString ) - { - m_Sidebar->m_TriggerBottom->ToLogicView(); - m_Sidebar->m_TriggerBottom->FillLogicData(); - } - else - { - m_Sidebar->m_TriggerBottom->ToConditionView(); - m_Sidebar->m_TriggerBottom->FillConditionData(); - } - } - else - { - m_Sidebar->m_TriggerBottom->ToEffectView(); - if ( m_Sidebar->m_SelectedEffect != -1 ) - m_Sidebar->m_TriggerBottom->FillEffectData(); - } - -} - - -TriggerEntitySelector::TriggerEntitySelector(TriggerBottomBar* parent, std::wstring label, - const wxPoint& pos, const wxSize& size, int parameter, callback func, void* data) - : wxPanel(parent), m_Parent(parent), m_Parameter(parameter), m_Callback(func), m_Data(data) -{ - wxBoxSizer* MainSizer = new wxBoxSizer(wxVERTICAL); - SetSizer(MainSizer); - MainSizer->Add( new wxButton(this, ID_SELECTION, wxString(label.c_str()), pos, size) ); - MainSizer->Add( new wxButton(this, ID_VIEW, L"View", pos, size) ); -} -void TriggerEntitySelector::onViewClick(wxCommandEvent& WXUNUSED(evt)) -{ - std::wstring handles; - if ( m_Parent->m_Sidebar->m_Notebook->GetCurrentPage() == m_Parent->m_Sidebar->m_ConditionPage ) - { - std::vector conditions = *m_Parent->m_Sidebar->GetSelectedItemData()->conditions; - int condition = m_Parent->m_Sidebar->GetConditionCount(m_Parent->m_Sidebar->m_SelectedCond) - 1 ; - std::vector parameters = *conditions[condition].parameters; - handles = parameters[m_Parameter]; - } - else - { - std::vector effects = *m_Parent->m_Sidebar->GetSelectedItemData()->effects; - int effect = m_Parent->m_Sidebar->m_SelectedEffect; - std::vector parameters = *effects[effect].parameters; - handles = parameters[m_Parameter]; - } - - std::vector IDList; - size_t previous = handles.find(L"[")+1, current; - - //remove "]" - if ( handles.size() ) - handles.erase(handles.size()-1); - - while ( (current = handles.find(L", ", previous)) != std::wstring::npos ) - { - std::wstringstream toInt(handles.substr(previous, current - previous)); - int newID; - toInt >> newID; - IDList.push_back(newID); - previous = current+1; - } - - std::wstringstream toInt( handles.substr(previous) ); - int newID; - toInt >> newID; - IDList.push_back(newID); - g_SelectedObjects = IDList; - POST_MESSAGE(SetSelectionPreview, (g_SelectedObjects)); -} - -void TriggerSpecText::onTextEnter(wxCommandEvent& WXUNUSED(evt)) -{ - std::wstring text( GetValue().wc_str() ); - - if ( VerifyInput(text) ) - (*m_Callback)(m_Data, text, m_Parameter ); - else - wxBell(); -} - -TriggerSpecChoice::TriggerSpecChoice(TriggerBottomBar* parent, std::wstring WXUNUSED(label), const wxPoint& pos, - const wxSize& size, const wxArrayString& strings, int parameter, callback func, void* data) - : wxChoice(parent, wxID_ANY, pos, size, strings), m_Callback(func), m_Data(data), - m_Parent(parent), m_Parameter(parameter) - { - } -void TriggerSpecChoice::onChoice(wxCommandEvent& evt) -{ - (*m_Callback)(m_Data, std::wstring( evt.GetString().wc_str() ), m_Parameter); -} -void onTriggerParameter(void* data, std::wstring paramString, int parameter) -{ - TriggerBottomBar* bottomBar = static_cast(data); - - if ( bottomBar->m_Sidebar->m_Notebook->GetSelection() == 0 ) - { - if ( bottomBar->m_Sidebar->m_SelectedCond == -1 ) - return; - std::vector conditions = *bottomBar->m_Sidebar->GetSelectedItemData()->conditions; - std::vector parameters = *conditions[bottomBar->m_Sidebar->m_SelectedCond].parameters; - - parameters[parameter] = paramString; - conditions[bottomBar->m_Sidebar->m_SelectedCond].parameters = parameters; - bottomBar->m_Sidebar->GetSelectedItemData()->conditions = conditions; - } - else - { - if ( bottomBar->m_Sidebar->m_SelectedEffect == -1 ) - return; - std::vector effects = *bottomBar->m_Sidebar->GetSelectedItemData()->effects; - std::vector parameters = *effects[bottomBar->m_Sidebar->m_SelectedEffect].parameters; - - parameters[parameter] = paramString; - effects[bottomBar->m_Sidebar->m_SelectedEffect].parameters = parameters; - bottomBar->m_Sidebar->GetSelectedItemData()->effects = effects; - } - bottomBar->m_Sidebar->UpdateEngineData(); -} - -void onGroupPush(void* data) -{ - TriggerSidebar* sidebar = static_cast(data); - if ( !sidebar->m_TriggerTree->GetSelection()) - return; - if ( !sidebar->IsGroupSelected() ) - return; - - wxString name = wxString::Format(L"Group %d", sidebar->m_GroupCount); - wxTreeItemId ID = sidebar->m_TriggerTree->AppendItem( sidebar->m_TriggerTree->GetSelection(), - name, -1, -1, new TriggerItemData(sidebar, std::wstring(name), true) ); - sidebar->m_TriggerTree->EnsureVisible(ID); - ++sidebar->m_GroupCount; - - sidebar->UpdateEngineData(); -} - -void onTriggerPush(void* data) -{ - TriggerSidebar* sidebar = static_cast(data); - wxTreeItemId ID = sidebar->m_TriggerTree->GetSelection(); - - if ( !sidebar->IsGroupSelected() ) - ID = sidebar->m_TriggerTree->GetItemParent(ID); - - wxString name = wxString::Format(L"Trigger %d", sidebar->m_TriggerCount); - TriggerItemData* itemData = new TriggerItemData(sidebar, std::wstring(name), false); - itemData->group = std::wstring( sidebar->m_TriggerTree->GetItemText(ID) ); - - ID = sidebar->m_TriggerTree->AppendItem(ID, name, -1, -1, itemData); - sidebar->m_TriggerTree->Expand( sidebar->m_TriggerTree->GetRootItem() ); - - ++sidebar->m_TriggerCount; - sidebar->m_TriggerTree->SelectItem(ID); - sidebar->UpdateEngineData(); -} - -void onDeleteTreePush(void* data) -{ - TriggerSidebar* sidebar = static_cast(data); - if ( sidebar->m_TriggerTree->GetSelection() == sidebar->m_TriggerTree->GetRootItem() ) - return; - - if ( wxMessageBox( wxString(L"Are you sure you want to delete this item?"), - wxString(L"Caution"), wxYES_NO ) == wxYES ) - { - sidebar->m_TriggerTree->Delete(sidebar->m_TriggerTree->GetSelection()); - sidebar->m_TriggerTree->EnsureVisible( sidebar->m_TriggerTree->GetRootItem() ); - sidebar->m_TriggerBottom->FillTriggerData(); - } - - sidebar->UpdateEngineData(); -} - -void onConditionPush(void* data) -{ - TriggerSidebar* sidebar = static_cast(data); - if ( sidebar->IsGroupSelected() ) - return; - - sidebar->m_Notebook->SetSelection(0); - TriggerItemData* itemData = sidebar->GetSelectedItemData(); - std::wstring name = std::wstring( wxString::Format(L"Condition %d", itemData->m_CondCount).wc_str() ); - - if ( itemData->m_CondCount == 0 ) - sidebar->m_SelectedCond = 0; - - ++itemData->m_CondCount; - - std::vector conditions = *itemData->conditions; - conditions.push_back( sTriggerCondition(name) ); - itemData->conditions = conditions; - - long count = sidebar->m_ConditionPage->m_List->GetItemCount(); - - sidebar->m_ConditionPage->m_List->InsertItem(count, wxString(name.c_str()) ); - sidebar->m_ConditionPage->m_List->EnsureVisible(count); - sidebar->m_ConditionPage->m_List->SetItemState(count, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); - - sidebar->m_TriggerBottom->ToConditionView(); //Some data is not valid, so reset - sidebar->m_TriggerBottom->FillConditionData(); - - sidebar->UpdateEngineData(); -} - -void onEffectPush(void* data) -{ - TriggerSidebar* sidebar = static_cast(data); - if ( sidebar->IsGroupSelected() ) - return; - - sidebar->m_Notebook->SetSelection(1); - TriggerItemData* itemData = sidebar->GetSelectedItemData(); - std::wstring name = std::wstring( wxString::Format(L"Effect %d", itemData->m_EffectCount).wc_str() ); - - if ( itemData->m_EffectCount == 0 ) - sidebar->m_SelectedEffect = 0; - ++itemData->m_EffectCount; - - std::vector effects = *itemData->effects; - effects.push_back( sTriggerEffect(name) ); - itemData->effects = effects; - - long count = sidebar->m_EffectPage->m_List->GetItemCount(); - sidebar->m_EffectPage->m_List->InsertItem(count, wxString(name.c_str()) ); - sidebar->m_EffectPage->m_List->EnsureVisible(count); - sidebar->m_EffectPage->m_List->SetItemState(count, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); - - sidebar->m_TriggerBottom->ToEffectView(); - sidebar->m_TriggerBottom->FillEffectData(); - - sidebar->UpdateEngineData(); -} - -void onDeleteBookPush(void* data) -{ - TriggerSidebar* sidebar = static_cast(data); - wxListCtrl* list = static_cast(sidebar->m_Notebook->GetCurrentPage())->m_List; - if ( !list ) - return; - - TriggerItemData* itemData = sidebar->GetSelectedItemData(); - //Is condition? -- valid selection? - if ( list == sidebar->m_ConditionPage->m_List && sidebar->m_SelectedCond != -1 ) - { - std::wstring text(sidebar->m_ConditionPage->m_List->GetItemText(sidebar->m_SelectedCond) ); - int conditionCount = sidebar->GetConditionCount(sidebar->m_SelectedCond); - - if ( text == std::wstring(sidebar->m_LogicBlockString.wc_str()) ) - { - std::vector blocks = *itemData->logicBlocks; - if ( conditionCount == 0 ) - { - blocks.erase( std::find(blocks.begin(), blocks.end(), 0) ); - itemData->m_BlockIndices.erase( std::find( itemData->m_BlockIndices.begin(), - itemData->m_BlockIndices.end(), sidebar->m_SelectedCond ) ); - } - else - { - blocks.erase( std::find(blocks.begin(), blocks.end(), conditionCount) ); - itemData->m_BlockIndices.erase( std::find( itemData->m_BlockIndices.begin(), - itemData->m_BlockIndices.end(), sidebar->m_SelectedCond ) ); - } - itemData->logicBlocks = blocks; - } - - else if ( text == std::wstring(sidebar->m_LogicBlockEndString.wc_str()) ) - { - std::vector blockEnds = *itemData->logicBlockEnds; - if ( conditionCount == 0 ) - { - blockEnds.erase( std::find(blockEnds.begin(), blockEnds.end(), 0) ); - itemData->m_BlockEndIndices.erase( std::find( itemData->m_BlockEndIndices.begin(), - itemData->m_BlockEndIndices.end(), sidebar->m_SelectedCond ) ); - } - else - { - blockEnds.erase( std::find(blockEnds.begin(), blockEnds.end(), conditionCount-1) ); - itemData->m_BlockEndIndices.erase( std::find( itemData->m_BlockEndIndices.begin(), - itemData->m_BlockEndIndices.end(), sidebar->m_SelectedCond ) ); - } - itemData->logicBlockEnds = blockEnds; - } - - else - { - std::vector conditions = *itemData->conditions; - conditions.erase( std::find(conditions.begin(), conditions.end(), text) ); - itemData->conditions = conditions; - } - - list->DeleteItem( sidebar->m_SelectedCond ); - itemData->ResetBlockIndices(); - - if ( sidebar->m_SelectedCond == list->GetItemCount() ) - { - sidebar->m_SelectedCond = -1; - sidebar->m_TriggerBottom->ToNoView(); - } - else - sidebar->m_TriggerBottom->FillConditionData(); - } - - else if ( list == sidebar->m_EffectPage->m_List && sidebar->m_SelectedEffect != -1) - { - std::vector effects = *itemData->effects; - effects.erase( std::find( effects.begin(), effects.end(), std::wstring( - list->GetItemText(sidebar->m_SelectedEffect)) ) ); - itemData->effects = effects; - - list->DeleteItem( sidebar->m_SelectedEffect ); - - if ( itemData->effects.GetSize() == 0 || sidebar->m_SelectedEffect == list->GetItemCount() ) - { - sidebar->m_SelectedEffect = -1; - sidebar->m_TriggerBottom->ToNoView(); - } - else - sidebar->m_TriggerBottom->FillEffectData(); - } - sidebar->UpdateLists(); - sidebar->UpdateEngineData(); -} - -void onLogicBlockPush(void* data) -{ - TriggerSidebar* sidebar = static_cast(data); - sidebar->m_Notebook->SetSelection(0); - - if ( sidebar->IsGroupSelected() ) - return; - - int limit = sidebar->m_SelectedCond; - if ( sidebar->m_SelectedCond == -1 ) - limit = sidebar->m_ConditionPage->m_List->GetItemCount()-1; - - int conditionCount = sidebar->GetConditionCount(limit); - if ( conditionCount == 0 ) - { - sidebar->GetSelectedItemData()->AddBlock(0, 0); - sidebar->UpdateLists(); - return; - } - - sidebar->GetSelectedItemData()->AddBlock(conditionCount, limit); - sidebar->UpdateLists(); - sidebar->m_TriggerBottom->ToLogicView(); //Some data is not valid, so reset - sidebar->m_TriggerBottom->FillLogicData(); - sidebar->UpdateEngineData(); -} - -void onBlockEndPush(void* data) -{ - TriggerSidebar* sidebar = static_cast(data); - sidebar->m_Notebook->SetSelection(0); - - if ( sidebar->IsGroupSelected() ) - return; - - int limit = sidebar->m_SelectedCond; - if ( sidebar->m_SelectedCond == -1 ) - limit = sidebar->m_ConditionPage->m_List->GetItemCount()-1; - - int conditionCount = sidebar->GetConditionCount(limit); - if ( conditionCount == 0 ) - { - sidebar->GetSelectedItemData()->AddBlockEnd(0, 0); - sidebar->UpdateLists(); - return; - } - - sidebar->GetSelectedItemData()->AddBlockEnd(conditionCount-1, limit); - sidebar->UpdateLists(); -} - - -TriggerSidebar::TriggerSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer) -: Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer), m_GroupCount(0), m_TriggerCount(0), - m_SelectedCond(-1), m_SelectedEffect(-1) -{ - m_TriggerBottom = new TriggerBottomBar(this, bottomBarContainer); - m_BottomBar = m_TriggerBottom; - - m_TriggerTree = new TriggerTreeCtrl(this, wxID_ANY, wxDefaultPosition, - wxSize(140, 220), wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS); - m_TriggerTree->AddRoot(L"Triggers", -1, -1, new TriggerItemData(this, L"Triggers", true)); - m_TriggerTree->SelectItem( m_TriggerTree->GetRootItem() ); - m_TriggerTree->Expand( m_TriggerTree->GetRootItem() ); - - - wxBoxSizer* hHolder = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer* vHolder = new wxBoxSizer(wxVERTICAL); - wxBoxSizer* vButtons = new wxBoxSizer(wxVERTICAL); - - ActionButton* trigButton = new ActionButton( this, L"Trigger", &onTriggerPush, - this, wxSize(50, 20) ); - ActionButton* groupButton = new ActionButton( this, L"Group", &onGroupPush, - this, wxSize(50, 20) ); - ActionButton* deleteButton = new ActionButton( this, L"Delete", &onDeleteTreePush, - this, wxSize(50, 20) ); - - ActionButton* conditionButton = new ActionButton( this, L"Condition", - &onConditionPush, this, wxSize(54, 20) ); - ActionButton* effectButton = new ActionButton( this, L"Effect", - &onEffectPush, this, wxSize(50, 20) ); - ActionButton* bookDelete = new ActionButton( this, L"Delete", - &onDeleteBookPush, this, wxSize(50, 20) ); - ActionButton* logicBlock = new ActionButton( this, L"Block", - &onLogicBlockPush, this, wxSize(50, 20) ); - ActionButton* logicBlockEnd = new ActionButton( this, L"Block End", - &onBlockEndPush, this, wxSize(50, 20) ); - - - m_LogicBlockString = wxString(L"--------------------"); - m_LogicBlockEndString = wxString(L"==========="); - wxStaticText* bottomTitle = new wxStaticText( this, wxID_ANY, _T("Conditions and Effects") ); - m_Notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, - wxSize(132, 210), wxNB_TOP); - - m_ConditionPage = new TriggerPage(m_Notebook, this, ID_CondList, wxString(L"Conditions"), true); - m_EffectPage = new TriggerPage(m_Notebook, this, ID_EffectList, wxString(L"Effects"), false); - - m_Notebook->AddPage( m_ConditionPage, _T("Conditions") ); - m_Notebook->AddPage( m_EffectPage, _T("Effects") ); - m_Notebook->SetPageSize(wxSize(130, 240)); - - vButtons->Add(trigButton); - vButtons->Add(groupButton); - vButtons->Add(deleteButton); - vButtons->Add(conditionButton, 0, wxTOP, 190); - vButtons->Add(effectButton); - vButtons->Add(bookDelete); - vButtons->Add(logicBlock); - vButtons->Add(logicBlockEnd); - - vHolder->Add(m_TriggerTree, 0, wxTOP, 15); - vHolder->Add(bottomTitle, 0, wxALIGN_CENTER | wxTOP, 5); - vHolder->Add(m_Notebook, 0, wxTOP, 5 ); - - hHolder->Add(vHolder); - hHolder->Add(vButtons, 0, wxALIGN_CENTER); - m_MainSizer->Add(hHolder); -} - -int TriggerSidebar::GetConditionCount(int limit) -{ - int conditionCount = 0; - wxListCtrl* list = m_ConditionPage->m_List; - for ( int i = 0; i <= limit; ++i ) - { - if ( list->GetItemText(i) != m_LogicBlockString && list->GetItemText(i) != m_LogicBlockEndString) - ++conditionCount; - } - return conditionCount; -} - -int TriggerSidebar::GetLogicBlockCount(int limit) -{ - int logicCount = 0; - wxListCtrl* list = m_ConditionPage->m_List; - for ( int i = 0; i <= limit; ++i ) - { - if ( list->GetItemText(i) == m_LogicBlockString ) - ++logicCount; - } - return logicCount; -} -void TriggerSidebar::OnFirstDisplay() -{ - qGetTriggerData dataQuery; - dataQuery.Post(); - m_TriggerBottom->SetSpecs(*dataQuery.conditions, *dataQuery.effects); - - //Add all loaded triggers to the tree - const std::vector triggerGroups = *dataQuery.groups; - std::vector::const_iterator it = std::find( triggerGroups.begin(), - triggerGroups.end(), std::wstring(L"Triggers") ); - - if ( it != triggerGroups.end() ) - { - wxTreeItemId invalid; - AddGroupTree(*it, invalid); - m_TriggerTree->Expand( m_TriggerTree->GetRootItem() ); - } -} - -void TriggerSidebar::AddGroupTree(const sTriggerGroup& group, wxTreeItemId parent) -{ - wxTreeItemId newID; - wxString text( (*group.name).c_str() ); - - //Make sure root item doesn't already exist - if ( !parent && !m_TriggerTree->GetRootItem() ) - newID = m_TriggerTree->AddRoot(text, -1, -1, new TriggerItemData(this, *group.name, true)); - else if ( parent ) - newID = m_TriggerTree->AppendItem(parent, text); - else - newID = m_TriggerTree->GetRootItem(); - - const std::vector triggerBuf = *group.triggers; - const std::vector groupBuf = *group.children; - - for ( size_t i = 0; i < group.children.GetSize(); ++i ) - AddGroupTree( *std::find(m_TriggerGroups.begin(), m_TriggerGroups.end(), groupBuf[i]), newID ); - - for ( size_t i = 0; i < group.triggers.GetSize(); ++i ) - { - std::wstring trigName = *triggerBuf[i].name; - size_t condMax = 0, effectMax = 0; - - //Make triggers start where user last left off - if ( trigName.find(L"Trigger ") == 0 ) - { - trigName.erase(0, 8); //remove "Trigger " - std::wstringstream toInt(trigName); - size_t convert; - toInt >> convert; - ++convert; - - if ( !toInt.fail() ) - { - if ( convert > m_TriggerCount ) - m_TriggerCount = convert; - } - } - std::vector conditions = *triggerBuf[i].conditions; - std::vector effects = *triggerBuf[i].effects; - - for ( size_t j = 0; j < conditions.size(); ++j ) - { - std::wstring condName = *conditions[j].name; - - if ( condName.find(L"Condition ") == 0 ) - { - condName.erase(0, 10); - std::wstringstream toInt(condName); - size_t convert; - toInt >> convert; - ++convert; - - if ( !toInt.fail() ) - { - if ( convert > condMax ) - condMax = convert; - } - } - } - - for ( size_t j = 0; j < effects.size(); ++j ) - { - std::wstring effectName = *effects[j].name; - - if ( effectName .find(L"Effect ") == 0 ) - { - effectName.erase(0, 7); - std::wstringstream toInt(effectName); - size_t convert; - toInt >> convert; - ++convert; - - if ( !toInt.fail() ) - { - if ( convert > effectMax ) - effectMax = convert; - } - } - } - TriggerItemData* newTriggerData = new TriggerItemData(this, triggerBuf[i], false); - newTriggerData->m_CondCount = condMax; - newTriggerData->m_EffectCount = effectMax; - m_TriggerTree->AppendItem( newID, wxString( triggerBuf[i].name.c_str() ), -1, -1, newTriggerData); - } -} - - -void TriggerSidebar::onPageChange(wxNotebookEvent& evt) -{ - if ( evt.GetSelection() == 0 ) - { - m_TriggerBottom->ToConditionView(); - if ( m_SelectedCond != -1 ) - m_TriggerBottom->FillConditionData(); - return; - } - m_TriggerBottom->ToEffectView(); - if ( m_SelectedEffect != -1 ) - m_TriggerBottom->FillEffectData(); -} - -void TriggerSidebar::onTreeDrag(wxTreeEvent& WXUNUSED(evt)) -{ - //evt.Allow(); -} - -void TriggerSidebar::onTreeNameChange(wxTreeEvent& evt) -{ - ToDerived( m_TriggerTree->GetItemData(evt.GetItem()) )->name = std::wstring( - evt.GetLabel().wc_str()); - UpdateEngineData(); -} - -void TriggerSidebar::onTreeSelChange(wxTreeEvent& evt) -{ - //Prevent other triggers from trying to use previous data - m_SelectedCond = -1; - m_SelectedEffect = -1; - - if ( evt.GetItem() == m_TriggerTree->GetRootItem() ) - { - m_TriggerBottom->ToNoView(); - return; - } - - if ( m_TriggerBottom->GetDependentStatus() != TriggerBottomBar::TRIGGER_VIEW ) - m_TriggerBottom->ToTriggerView(); - m_TriggerBottom->FillTriggerData(); - - UpdateLists(); -} -void TriggerSidebar::UpdateLists() -{ - TriggerItemData* data = GetSelectedItemData(); - m_ConditionPage->m_List->Freeze(); - m_ConditionPage->m_List->DeleteAllItems(); - m_EffectPage->m_List->Freeze(); - m_EffectPage->m_List->DeleteAllItems(); - - const Shareable* conditions = data->conditions.GetBuffer(); - for ( size_t i = 0; i < data->conditions.GetSize(); ++i ) - { - m_ConditionPage->m_List->InsertItem( m_ConditionPage->m_List-> - GetItemCount(), wxString(conditions[i]->name.c_str()) ); - } - - const Shareable* effects = data->effects.GetBuffer(); - for ( size_t i = 0; i < data->effects.GetSize(); ++i ) - { - m_EffectPage->m_List->InsertItem(m_EffectPage->m_List->GetItemCount(), - wxString(effects[i]->name.c_str()) ); - } - - //These must be merged and sorted because adding them out-of-order screws up the list - std::list sortedBlocks; - std::list blocks = data->m_BlockIndices, blockEnds = data->m_BlockEndIndices; - - for ( std::list::iterator it = blocks.begin(); it != blocks.end(); ++it ) - sortedBlocks.push_back( LogicBlockHelper(*it, false) ); - for ( std::list::iterator it = blockEnds.begin(); it != blockEnds.end(); ++it ) - sortedBlocks.push_back( LogicBlockHelper(*it, true) ); - - sortedBlocks.sort(); - for ( std::list::iterator it = sortedBlocks.begin(); it != sortedBlocks.end(); ++it ) - { - if ( it->end ) - m_ConditionPage->m_List->InsertItem(it->index, m_LogicBlockEndString); - else - m_ConditionPage->m_List->InsertItem(it->index, m_LogicBlockString); - } - - m_ConditionPage->m_List->Thaw(); - m_EffectPage->m_List->Thaw(); -} - -void TriggerSidebar::onCondSelect(wxListEvent& evt) -{ - m_SelectedCond = evt.GetIndex(); - //if ( m_TriggerBottom->GetDependentStatus() != TriggerBottomBar::CONDITION_VIEW ) - if ( m_ConditionPage->m_List->GetItemText(m_SelectedCond) - == m_LogicBlockEndString ) - { - m_TriggerBottom->ToNoView(); - } - else if ( m_ConditionPage->m_List->GetItemText(m_SelectedCond) - == m_LogicBlockString ) - { - m_TriggerBottom->ToLogicView(); - - if ( m_SelectedCond != -1 ) - m_TriggerBottom->FillLogicData(); - } - else - { - m_TriggerBottom->ToConditionView(); - if ( m_SelectedCond != -1 ) - m_TriggerBottom->FillConditionData(); - } -} -void TriggerSidebar::onEffectSelect(wxListEvent& evt) -{ - m_SelectedEffect = evt.GetIndex(); - //if ( m_TriggerBottom->GetDependentStatus() != TriggerBottomBar::EFFECT_VIEW ) - m_TriggerBottom->ToEffectView(); - m_TriggerBottom->FillEffectData(); -} - -bool TriggerSidebar::IsGroupSelected() -{ - if ( ToDerived( m_TriggerTree->GetItemData(m_TriggerTree->GetSelection()) )->m_Group ) - return true; - return false; -} - -sTrigger TriggerSidebar::CreateTrigger(TriggerItemData* data) -{ - sTrigger trigger; - - trigger.active = data->active; - trigger.group = data->group; - trigger.maxRuns = data->maxRuns; - trigger.name = data->name; - trigger.timeValue = data->timeValue; - - trigger.logicBlockEnds = data->logicBlockEnds; - trigger.logicBlocks = data->logicBlocks; - trigger.conditions = data->conditions; - trigger.effects = data->effects; - trigger.logicNots = data->logicNots; - - return trigger; -} - -void TriggerSidebar::CreateGroup(std::vector& groupList, sTriggerGroup& parent, wxTreeItemId index) -{ - wxTreeItemIdValue cookie; - std::vector triggers; - sTriggerGroup group( std::wstring(m_TriggerTree->GetItemText(index)) ); - group.parentName = parent.name; - - //Add this group to parent's child group - std::vector parentChildren = *parent.children; - parentChildren.push_back(*group.parentName); - parent.children = parentChildren; - - for ( wxTreeItemId ID = m_TriggerTree->GetFirstChild(index, cookie); ID.IsOk(); - ID = m_TriggerTree->GetNextChild(index, cookie) ) - { - TriggerItemData* itemData = ToDerived( m_TriggerTree->GetItemData(ID) ); - if ( itemData->m_Group ) - CreateGroup(groupList, group, ID); - else - triggers.push_back( CreateTrigger(itemData) ); - } - - group.triggers = triggers; - groupList.push_back(group); -} - -void TriggerSidebar::UpdateEngineData() -{ - wxTreeItemIdValue cookie; - wxTreeItemId root = m_TriggerTree->GetRootItem(); - - //Find all root groups - std::vector groups; - std::vector triggers; - sTriggerGroup rootGroup(L"Triggers"); - - for ( wxTreeItemId ID = m_TriggerTree->GetFirstChild(root, cookie); ID.IsOk(); - ID = m_TriggerTree->GetNextChild(root, cookie) ) - { - TriggerItemData* itemData = ToDerived( m_TriggerTree->GetItemData(ID) ); - if ( itemData->m_Group ) - CreateGroup(groups, rootGroup, ID); - else - triggers.push_back( CreateTrigger(itemData) ); - } - - rootGroup.triggers = triggers; - groups.push_back(rootGroup); - POST_COMMAND( SetAllTriggers, (groups) ); -} -TriggerItemData* TriggerSidebar::ToDerived(wxTreeItemData* data) -{ - return ( static_cast(data) ); -} -TriggerItemData* TriggerSidebar::GetSelectedItemData() -{ - if ( !m_TriggerTree->GetSelection() ) - m_TriggerTree->SelectItem(m_TriggerTree->GetRootItem()); - return ToDerived( m_TriggerTree->GetItemData(m_TriggerTree->GetSelection()) ); - -} - diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.h b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.h deleted file mode 100644 index 082f6aa069..0000000000 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.h +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright (C) 2009 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 . - */ - -/* Desc: interface for creation and editing of triggers. Interprets - XML specifications then uses this to construct layout. -*/ - -#include "../Common/Sidebar.h" -#include "GameInterface/Messages.h" - -class TriggerItemData; -class TriggerTreeCtrl; -class TriggerBottomBar; -class TriggerPage; -class wxTreeItemId; -class wxTreeItemData; -class wxTreeEvent; -class wxListEvent; -class wxNotebook; -class wxNotebookEvent; -class wxTreeEvent; -class wxListEvent; - -class TriggerSidebar : public Sidebar -{ -public: - enum { ID_CondList, ID_EffectList }; - - TriggerSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer); - - void onTreeDrag(wxTreeEvent& evt); - void onTreeNameChange(wxTreeEvent& evt); - //void onTreeDelete(wxTreeEvent& evt); - void onTreeSelChange(wxTreeEvent& evt); - void onTreeCollapse(wxTreeEvent& evt); - void onListSelect(wxListEvent& evt); - void onEffectSelect(wxListEvent& evt); - void onCondSelect(wxListEvent& evt); - void onPageChange(wxNotebookEvent& evt); - - bool IsGroupSelected(); - TriggerItemData* ToDerived(wxTreeItemData* data); - TriggerItemData* GetSelectedItemData(); - - //Finds condition number (index+1) of m_SelectedCond [needed because of logic blocks] - int GetConditionCount(int limit); - int GetLogicBlockCount(int limit); - void UpdateLists(); - void UpdateEngineData(); - - //AtlasMessage::sTriggerList m_TriggerList; - - TriggerBottomBar* m_TriggerBottom; - TriggerTreeCtrl* m_TriggerTree; - TriggerPage* m_ConditionPage, *m_EffectPage; - wxNotebook* m_Notebook; - - size_t m_TriggerCount, m_GroupCount; - long m_SelectedCond, m_SelectedEffect, m_SelectedCondIndex, m_SelectedEffectIndex; - wxString m_LogicBlockString, m_LogicBlockEndString; - -protected: - virtual void OnFirstDisplay(); - -private: - struct copyIfRootChild - { - copyIfRootChild(std::vector& groupList) : m_groupList(groupList) {} - void operator() ( const AtlasMessage::sTriggerGroup& group ) - { - if ( *group.parentName == std::wstring(L"Triggers") ) - m_groupList.push_back(group); - } - private: - std::vector& m_groupList; - }; - - void AddGroupTree(const AtlasMessage::sTriggerGroup& group, wxTreeItemId parent); - - void CreateGroup(std::vector& groupList, - AtlasMessage::sTriggerGroup& parent, wxTreeItemId index); - - AtlasMessage::sTrigger CreateTrigger(TriggerItemData* data); - - std::vector m_TriggerGroups; - - DECLARE_EVENT_TABLE(); -}; - -