mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-24 03:54:34 -04:00
e550d24ee5
Fixed associated layout set in the combobox without taking effect in the editor when opening an external events editor. Fixed ExternalEventsEditor not setting its EventsEditor as being used on external events ( Not triggering code compilation on C++ Platform ). Fixed badly formulated sentence in ChoixAction/ChoixCondition. git-svn-id: svn://localhost@1205 8062f311-0dae-4547-b526-b8ab9ac864a5
137 lines
5.2 KiB
C++
137 lines
5.2 KiB
C++
/** \file
|
|
* Game Develop
|
|
* 2008-2013 Florian Rival (Florian.Rival@gmail.com)
|
|
*/
|
|
#include "ExternalEventsEditor.h"
|
|
|
|
//(*InternalHeaders(ExternalEventsEditor)
|
|
#include <wx/intl.h>
|
|
#include <wx/string.h>
|
|
//*)
|
|
#include <wx/textctrl.h>
|
|
#include <wx/log.h>
|
|
#include <wx/ribbon/bar.h>
|
|
#include "GDCore/PlatformDefinition/ExternalEvents.h"
|
|
#include "GDCore/CommonTools.h"
|
|
#include "GDCore/PlatformDefinition/Project.h"
|
|
#include "GDCore/IDE/Dialogs/MainFrameWrapper.h"
|
|
#include "EventsEditor.h"
|
|
|
|
//(*IdInit(ExternalEventsEditor)
|
|
const long ExternalEventsEditor::ID_STATICTEXT1 = wxNewId();
|
|
const long ExternalEventsEditor::ID_COMBOBOX1 = wxNewId();
|
|
const long ExternalEventsEditor::ID_CUSTOM2 = wxNewId();
|
|
//*)
|
|
|
|
BEGIN_EVENT_TABLE(ExternalEventsEditor,wxPanel)
|
|
//(*EventTable(ExternalEventsEditor)
|
|
//*)
|
|
END_EVENT_TABLE()
|
|
|
|
ExternalEventsEditor::ExternalEventsEditor(wxWindow* parent, gd::Project & game_, gd::ExternalEvents & events_, const gd::MainFrameWrapper & mainFrameWrapper_) :
|
|
events(events_),
|
|
game(game_),
|
|
mainFrameWrapper(mainFrameWrapper_)
|
|
{
|
|
//(*Initialize(ExternalEventsEditor)
|
|
wxFlexGridSizer* FlexGridSizer3;
|
|
wxFlexGridSizer* FlexGridSizer2;
|
|
|
|
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("wxID_ANY"));
|
|
SetBackgroundColour(wxColour(255,255,255));
|
|
FlexGridSizer1 = new wxFlexGridSizer(2, 1, 0, 0);
|
|
FlexGridSizer1->AddGrowableCol(0);
|
|
FlexGridSizer1->AddGrowableRow(1);
|
|
FlexGridSizer2 = new wxFlexGridSizer(0, 3, 0, 0);
|
|
FlexGridSizer2->AddGrowableCol(1);
|
|
FlexGridSizer2->AddGrowableRow(0);
|
|
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Edit as if the events were included to scene :"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
|
|
FlexGridSizer2->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
|
|
parentSceneComboBox = new wxComboBox(this, ID_COMBOBOX1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX1"));
|
|
parentSceneComboBox->SetSelection( parentSceneComboBox->Append(_("No scene")) );
|
|
FlexGridSizer2->Add(parentSceneComboBox, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 3);
|
|
FlexGridSizer1->Add(FlexGridSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
|
|
FlexGridSizer3 = new wxFlexGridSizer(0, 3, 0, 0);
|
|
FlexGridSizer3->AddGrowableCol(0);
|
|
FlexGridSizer3->AddGrowableRow(0);
|
|
FlexGridSizer4 = new wxFlexGridSizer(0, 1, 0, 0);
|
|
FlexGridSizer4->AddGrowableCol(0);
|
|
FlexGridSizer4->AddGrowableRow(0);
|
|
eventsEditor = new EventsEditor(this, game, emptyScene, events, mainFrameWrapper);
|
|
FlexGridSizer4->Add(eventsEditor, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
|
|
FlexGridSizer3->Add(FlexGridSizer4, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
|
|
FlexGridSizer1->Add(FlexGridSizer3, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
|
|
SetSizer(FlexGridSizer1);
|
|
FlexGridSizer1->Fit(this);
|
|
FlexGridSizer1->SetSizeHints(this);
|
|
|
|
Connect(ID_COMBOBOX1,wxEVT_COMMAND_COMBOBOX_SELECTED,(wxObjectEventFunction)&ExternalEventsEditor::OnparentSceneComboBoxSelect);
|
|
Connect(ID_COMBOBOX1,wxEVT_COMMAND_TEXT_ENTER,(wxObjectEventFunction)&ExternalEventsEditor::OnparentSceneComboBoxSelect);
|
|
//*)
|
|
Connect(ID_COMBOBOX1,wxEVT_COMMAND_COMBOBOX_DROPDOWN,(wxObjectEventFunction)&ExternalEventsEditor::OnparentSceneComboBoxDropDown);
|
|
|
|
eventsEditor->SetExternalEvents(&events);
|
|
if ( !events.GetAssociatedLayout().empty() ) {
|
|
parentSceneComboBox->SetValue(events.GetAssociatedLayout());
|
|
wxCommandEvent useless;
|
|
OnparentSceneComboBoxSelect(useless);
|
|
}
|
|
|
|
}
|
|
|
|
ExternalEventsEditor::~ExternalEventsEditor()
|
|
{
|
|
//(*Destroy(ExternalEventsEditor)
|
|
//*)
|
|
}
|
|
|
|
void ExternalEventsEditor::ForceRefreshRibbonAndConnect()
|
|
{
|
|
mainFrameWrapper.GetRibbon()->SetActivePage(3);
|
|
eventsEditor->ConnectEvents();
|
|
}
|
|
|
|
/**
|
|
* Change the scene used as parent for editing.
|
|
*/
|
|
void ExternalEventsEditor::OnparentSceneComboBoxSelect(wxCommandEvent& event)
|
|
{
|
|
std::string name = gd::ToString(parentSceneComboBox->GetValue()) ;
|
|
|
|
gd::Layout * scene = game.HasLayoutNamed(name) ? &game.GetLayout(name) : NULL;
|
|
|
|
if ( parentSceneComboBox->GetSelection() == 0 ) //0 i.e. "No scene"
|
|
scene = &emptyScene;
|
|
else if ( scene == NULL)
|
|
{
|
|
wxLogWarning(_("Scene not found."));
|
|
return;
|
|
}
|
|
|
|
//Save the scene chosen
|
|
events.SetAssociatedLayout(scene->GetName());
|
|
|
|
//Need to recreate an events editor.
|
|
delete eventsEditor;
|
|
eventsEditor = new EventsEditor(this, game, *scene, events, mainFrameWrapper);
|
|
eventsEditor->ConnectEvents();
|
|
|
|
//Make sure the new events editor is properly displayed.
|
|
FlexGridSizer4->Detach(eventsEditor);
|
|
FlexGridSizer4->Add(eventsEditor, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
|
|
FlexGridSizer4->Layout();
|
|
}
|
|
|
|
/**
|
|
* Update scene list.
|
|
*/
|
|
void ExternalEventsEditor::OnparentSceneComboBoxDropDown(wxCommandEvent& event)
|
|
{
|
|
parentSceneComboBox->Clear();
|
|
parentSceneComboBox->Append(_("No scene"));
|
|
|
|
for (unsigned int i = 0;i<game.GetLayoutCount();++i)
|
|
parentSceneComboBox->Append(game.GetLayout(i).GetName());
|
|
}
|
|
|