Skyscraper 2.0
objectinfo.cpp
Go to the documentation of this file.
1/*
2 Skyscraper 2.0 Alpha - Object Information Dialog
3 Copyright (C)2003-2024 Ryan Thoryk
4 https://www.skyscrapersim.net
5 https://sourceforge.net/projects/skyscraper/
6 Contact - ryan@skyscrapersim.net
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21*/
22
23//(*InternalHeaders(ObjectInfo)
24#include <wx/intl.h>
25#include <wx/string.h>
26//*)
27
28#include <wx/filedlg.h>
29#include "globals.h"
30#include "sbs.h"
31#include "camera.h"
32#include "debugpanel.h"
33#include "vm.h"
34#include "enginecontext.h"
35#include "scriptproc.h"
36#include "createobject.h"
37#include "parameterviewer.h"
38#include "moveobject.h"
39#include "objectinfo.h"
40#include "textwindow.h"
41
42using namespace SBS;
43
44namespace Skyscraper {
45
46//(*IdInit(ObjectInfo)
47const long ObjectInfo::ID_ObjectTree = wxNewId();
48const long ObjectInfo::ID_bDelete = wxNewId();
49const long ObjectInfo::ID_bMove = wxNewId();
50const long ObjectInfo::ID_bCreate = wxNewId();
51const long ObjectInfo::ID_bViewScript = wxNewId();
52const long ObjectInfo::ID_bReset = wxNewId();
53const long ObjectInfo::ID_bOK = wxNewId();
54const long ObjectInfo::ID_bSave = wxNewId();
55const long ObjectInfo::ID_STATICTEXT1 = wxNewId();
56const long ObjectInfo::ID_tNumber = wxNewId();
57const long ObjectInfo::ID_STATICTEXT5 = wxNewId();
58const long ObjectInfo::ID_tName = wxNewId();
59const long ObjectInfo::ID_STATICTEXT2 = wxNewId();
60const long ObjectInfo::ID_tType = wxNewId();
61const long ObjectInfo::ID_STATICTEXT11 = wxNewId();
62const long ObjectInfo::ID_tPermanent = wxNewId();
63const long ObjectInfo::ID_STATICTEXT3 = wxNewId();
64const long ObjectInfo::ID_tParent = wxNewId();
65const long ObjectInfo::ID_STATICTEXT6 = wxNewId();
66const long ObjectInfo::ID_tParentName = wxNewId();
67const long ObjectInfo::ID_STATICTEXT4 = wxNewId();
68const long ObjectInfo::ID_tParentType = wxNewId();
69const long ObjectInfo::ID_STATICLINE1 = wxNewId();
70const long ObjectInfo::ID_STATICTEXT7 = wxNewId();
71const long ObjectInfo::ID_tLineNum = wxNewId();
72const long ObjectInfo::ID_STATICTEXT12 = wxNewId();
73const long ObjectInfo::ID_tIncludeFile = wxNewId();
74const long ObjectInfo::ID_STATICTEXT10 = wxNewId();
75const long ObjectInfo::ID_tContext = wxNewId();
76const long ObjectInfo::ID_STATICTEXT8 = wxNewId();
77const long ObjectInfo::ID_tScriptCommand = wxNewId();
78const long ObjectInfo::ID_STATICTEXT9 = wxNewId();
79const long ObjectInfo::ID_tScriptCommand2 = wxNewId();
80//*)
81
82BEGIN_EVENT_TABLE(ObjectInfo,wxDialog)
83 //(*EventTable(ObjectInfo)
84 //*)
85END_EVENT_TABLE()
86
87ObjectInfo::ObjectInfo(DebugPanel* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
88{
89 //(*Initialize(ObjectInfo)
90 wxBoxSizer* BoxSizer1;
91 wxBoxSizer* BoxSizer2;
92 wxBoxSizer* BoxSizer3;
93 wxFlexGridSizer* FlexGridSizer1;
94 wxFlexGridSizer* FlexGridSizer2;
95 wxFlexGridSizer* FlexGridSizer3;
96 wxFlexGridSizer* FlexGridSizer4;
97 wxFlexGridSizer* FlexGridSizer5;
98 wxFlexGridSizer* FlexGridSizer6;
99
100 Create(parent, wxID_ANY, _("Object Manager"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
101 BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
102 FlexGridSizer4 = new wxFlexGridSizer(0, 1, 0, 0);
103 ObjectTree = new wxTreeCtrl(this, ID_ObjectTree, wxDefaultPosition, wxSize(300,350), wxTR_DEFAULT_STYLE|wxBORDER_SUNKEN|wxVSCROLL, wxDefaultValidator, _T("ID_ObjectTree"));
104 FlexGridSizer4->Add(ObjectTree, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
105 BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
106 bDelete = new wxButton(this, ID_bDelete, _("Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bDelete"));
107 bDelete->SetToolTip(_("Delete selected object"));
108 BoxSizer2->Add(bDelete, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
109 bMove = new wxButton(this, ID_bMove, _("Move"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bMove"));
110 bMove->SetToolTip(_("Move selected object"));
111 BoxSizer2->Add(bMove, 1, wxALL|wxALIGN_TOP, 5);
112 bCreate = new wxButton(this, ID_bCreate, _("Create"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bCreate"));
113 bCreate->SetToolTip(_("Create a new object"));
114 BoxSizer2->Add(bCreate, 1, wxALL|wxALIGN_TOP, 5);
115 FlexGridSizer4->Add(BoxSizer2, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
116 BoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
117 bViewScript = new wxButton(this, ID_bViewScript, _("View Script"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bViewScript"));
118 bViewScript->SetToolTip(_("View current running script"));
119 BoxSizer3->Add(bViewScript, 1, wxALL|wxALIGN_TOP, 5);
120 bReset = new wxButton(this, ID_bReset, _("Reset State"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bReset"));
121 bReset->SetToolTip(_("Reset the state of the current object"));
122 BoxSizer3->Add(bReset, 1, wxALL|wxALIGN_TOP, 5);
123 bOK = new wxButton(this, ID_bOK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bOK"));
124 BoxSizer3->Add(bOK, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
125 bSave = new wxButton(this, ID_bSave, _("Save Script"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bSave"));
126 bSave->Disable();
127 bSave->Hide();
128 BoxSizer3->Add(bSave, 1, wxALL|wxALIGN_TOP, 5);
129 FlexGridSizer4->Add(BoxSizer3, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
130 BoxSizer1->Add(FlexGridSizer4, 1, wxALL|wxEXPAND, 5);
131 FlexGridSizer2 = new wxFlexGridSizer(0, 1, 0, 0);
132 FlexGridSizer1 = new wxFlexGridSizer(0, 2, 0, 0);
133 StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Number:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
134 FlexGridSizer1->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
135 tNumber = new wxTextCtrl(this, ID_tNumber, wxEmptyString, wxDefaultPosition, wxSize(125,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tNumber"));
136 FlexGridSizer1->Add(tNumber, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
137 StaticText5 = new wxStaticText(this, ID_STATICTEXT5, _("Name:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT5"));
138 FlexGridSizer1->Add(StaticText5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
139 tName = new wxTextCtrl(this, ID_tName, wxEmptyString, wxDefaultPosition, wxSize(125,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tName"));
140 FlexGridSizer1->Add(tName, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
141 StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Type:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
142 FlexGridSizer1->Add(StaticText2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
143 tType = new wxTextCtrl(this, ID_tType, wxEmptyString, wxDefaultPosition, wxSize(125,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tType"));
144 FlexGridSizer1->Add(tType, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
145 StaticText11 = new wxStaticText(this, ID_STATICTEXT11, _("Permanent:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT11"));
146 FlexGridSizer1->Add(StaticText11, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
147 tPermanent = new wxTextCtrl(this, ID_tPermanent, wxEmptyString, wxDefaultPosition, wxSize(125,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tPermanent"));
148 FlexGridSizer1->Add(tPermanent, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
149 StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("Parent:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
150 FlexGridSizer1->Add(StaticText3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
151 tParent = new wxTextCtrl(this, ID_tParent, wxEmptyString, wxDefaultPosition, wxSize(125,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tParent"));
152 FlexGridSizer1->Add(tParent, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
153 StaticText6 = new wxStaticText(this, ID_STATICTEXT6, _("Parent Name:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
154 FlexGridSizer1->Add(StaticText6, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
155 tParentName = new wxTextCtrl(this, ID_tParentName, wxEmptyString, wxDefaultPosition, wxSize(125,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tParentName"));
156 FlexGridSizer1->Add(tParentName, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
157 StaticText4 = new wxStaticText(this, ID_STATICTEXT4, _("Parent Type:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
158 FlexGridSizer1->Add(StaticText4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
159 tParentType = new wxTextCtrl(this, ID_tParentType, wxEmptyString, wxDefaultPosition, wxSize(125,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tParentType"));
160 FlexGridSizer1->Add(tParentType, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
161 FlexGridSizer2->Add(FlexGridSizer1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
162 StaticLine1 = new wxStaticLine(this, ID_STATICLINE1, wxDefaultPosition, wxSize(10,-1), wxLI_HORIZONTAL, _T("ID_STATICLINE1"));
163 FlexGridSizer2->Add(StaticLine1, 1, wxALL|wxEXPAND, 5);
164 FlexGridSizer3 = new wxFlexGridSizer(0, 3, 0, 0);
165 StaticText7 = new wxStaticText(this, ID_STATICTEXT7, _("Object created on line:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT7"));
166 FlexGridSizer3->Add(StaticText7, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
167 tLineNum = new wxTextCtrl(this, ID_tLineNum, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tLineNum"));
168 tLineNum->SetMinSize(wxSize(100,-1));
169 FlexGridSizer3->Add(tLineNum, 1, wxLEFT|wxRIGHT, 5);
170 FlexGridSizer2->Add(FlexGridSizer3, 1, wxTOP|wxLEFT|wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
171 FlexGridSizer6 = new wxFlexGridSizer(0, 3, 0, 0);
172 StaticText12 = new wxStaticText(this, ID_STATICTEXT12, _("In included file:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT12"));
173 FlexGridSizer6->Add(StaticText12, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
174 tIncludeFile = new wxTextCtrl(this, ID_tIncludeFile, wxEmptyString, wxDefaultPosition, wxSize(150,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tIncludeFile"));
175 FlexGridSizer6->Add(tIncludeFile, 1, wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
176 FlexGridSizer2->Add(FlexGridSizer6, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
177 FlexGridSizer5 = new wxFlexGridSizer(0, 3, 0, 0);
178 StaticText10 = new wxStaticText(this, ID_STATICTEXT10, _("Script context:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT10"));
179 FlexGridSizer5->Add(StaticText10, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
180 tContext = new wxTextCtrl(this, ID_tContext, wxEmptyString, wxDefaultPosition, wxSize(125,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tContext"));
181 FlexGridSizer5->Add(tContext, 1, wxLEFT|wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
182 FlexGridSizer2->Add(FlexGridSizer5, 1, wxBOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
183 StaticText8 = new wxStaticText(this, ID_STATICTEXT8, _("Script Command:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT8"));
184 FlexGridSizer2->Add(StaticText8, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
185 tScriptCommand = new wxTextCtrl(this, ID_tScriptCommand, wxEmptyString, wxDefaultPosition, wxSize(300,40), wxTE_MULTILINE|wxTE_READONLY|wxTE_CENTRE|wxTE_WORDWRAP, wxDefaultValidator, _T("ID_tScriptCommand"));
186 FlexGridSizer2->Add(tScriptCommand, 1, wxALL|wxEXPAND, 5);
187 StaticText9 = new wxStaticText(this, ID_STATICTEXT9, _("Processed Script Command:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT9"));
188 FlexGridSizer2->Add(StaticText9, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
189 tScriptCommand2 = new wxTextCtrl(this, ID_tScriptCommand2, wxEmptyString, wxDefaultPosition, wxSize(-1,40), wxTE_MULTILINE|wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tScriptCommand2"));
190 FlexGridSizer2->Add(tScriptCommand2, 1, wxALL|wxEXPAND, 5);
191 BoxSizer1->Add(FlexGridSizer2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
192 SetSizer(BoxSizer1);
193 BoxSizer1->Fit(this);
194 BoxSizer1->SetSizeHints(this);
195 Center();
196
197 Connect(ID_ObjectTree,wxEVT_COMMAND_TREE_SEL_CHANGED,(wxObjectEventFunction)&ObjectInfo::On_ObjectTree_SelectionChanged);
198 Connect(ID_bDelete,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bDelete_Click);
199 Connect(ID_bMove,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bMove_Click);
200 Connect(ID_bCreate,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bCreate_Click);
201 Connect(ID_bViewScript,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bViewScript_Click);
202 Connect(ID_bReset,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bReset_Click);
203 Connect(ID_bOK,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bOK_Click);
204 Connect(ID_bSave,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bSave_Click);
205 //*)
206 panel = parent;
207 createobject = 0;
208 modifyobject = 0;
209 moveobject = 0;
210 OnInit();
211}
212
214{
215 //(*Destroy(ObjectInfo)
216 //*)
217
218 if (createobject)
219 createobject->Destroy();
220 createobject = 0;
221 if (modifyobject)
222 modifyobject->Destroy();
223 modifyobject = 0;
224 if (moveobject)
225 moveobject->Destroy();
226 moveobject = 0;
227}
228
230{
231 oldobject = -1;
232 oldcamobject = -1;
233 changed = false;
234 lastcount = 0;
235 deleted = false;
237}
238
239void ObjectInfo::On_bOK_Click(wxCommandEvent& event)
240{
241 this->Hide();
242}
243
245{
246 //if active engine has changed, refresh values
247 if (Simcore != panel->GetSystem())
248 OnInit();
249
250 if (!Simcore)
251 return;
252
254 {
256 if (deleted == false)
257 PopulateTree();
258 deleted = false;
259 }
260
261 if (moveobject)
262 moveobject->Loop();
263
264 int number = oldobject;
265 if (changed == false)
266 {
267 int newobject = Simcore->camera->GetClickedObjectNumber();
268 if (newobject != oldcamobject)
269 {
272 }
273 else
274 number = oldobject;
275 }
276 else
277 {
278 wxTreeItemId id = ObjectTree->GetSelection();
279 if (id.IsOk())
280 {
281 TreeItemData *data = (TreeItemData*) ObjectTree->GetItemData(id);
282 wxString num;
283 num = data->GetDesc();
284 number = atoi(num);
285 }
286 changed = false;
287 }
288 if (number == oldobject)
289 return;
290
291 oldobject = number;
292 Object *object = Simcore->GetObject(number);
293 tNumber->SetValue(ToString(number));
294 tLineNum->Clear();
295 tIncludeFile->Clear();
296 tScriptCommand->Clear();
297 tScriptCommand2->Clear();
298 tContext->Clear();
299 tName->Clear();
300 tType->Clear();
301 tPermanent->Clear();
302 tParent->Clear();
303 tParentName->Clear();
304 tParentType->Clear();
305
306 if (object)
307 {
308 tName->SetValue(object->GetName());
309 tType->SetValue(object->GetType());
310 tLineNum->SetValue(ToString(object->linenum));
311 tIncludeFile->SetValue(object->includefile);
312 tScriptCommand->SetValue(object->command);
313 tScriptCommand2->SetValue(object->command_processed);
314 tContext->SetValue(object->context);
315 tPermanent->SetValue(BoolToString(object->IsPermanent()));
316
317 Object *parent = object->GetParent();
318 if (parent)
319 {
320 tParent->SetValue(ToString(parent->GetNumber()));
321 tParentName->SetValue(parent->GetName());
322 tParentType->SetValue(parent->GetType());
323 }
324 }
325}
326
328{
329 //erase tree
330 ObjectTree->DeleteAllItems();
331
332 //populate object tree
333 wxTreeItemId id = ObjectTree->AddRoot(Simcore->GetName(), -1, -1, new TreeItemData(ToString(Simcore->GetNumber())));
334
335 //add child objects
336 AddChildren(Simcore, id);
337
338 ObjectTree->Expand(id);
339}
340
341void ObjectInfo::AddChildren(Object *parent, const wxTreeItemId& treeparent)
342{
343 if (!parent)
344 return;
345
346 //add child objects of given SBS object to tree
347 if (parent->GetChildrenCount() > 0)
348 {
349 for (int i = 0; i < parent->GetChildrenCount(); i++)
350 {
351 if (parent->GetChild(i))
352 {
353 //add child object
354 wxTreeItemId id = ObjectTree->AppendItem(treeparent, parent->GetChild(i)->GetName(), -1, -1, new TreeItemData(ToString(parent->GetChild(i)->GetNumber())));
355
356 //if child object has children, call recursively to add those
357 if (parent->GetChild(i)->GetChildrenCount() > 0)
358 AddChildren(parent->GetChild(i), id);
359 }
360 }
361 }
362}
363
365{
366 changed = true;
367}
368
369void ObjectInfo::On_bDelete_Click(wxCommandEvent& event)
370{
371 wxTreeItemId sel = ObjectTree->GetSelection();
372
373 if (!sel.IsOk())
374 return;
375
376 TreeItemData *data = (TreeItemData*) ObjectTree->GetItemData(sel);
377 wxString num;
378 num = data->GetDesc();
379 int number = atoi(num);
380
381 //call SBS to delete object
382 if (Simcore->DeleteObject(number))
383 {
384 //delete object from tree
385 ObjectTree->Delete(sel);
386 deleted = true;
387 }
388}
389
390void ObjectInfo::On_bCreate_Click(wxCommandEvent& event)
391{
392 if (!createobject)
393 createobject = new CreateObject(panel, this, -1);
394 if (createobject)
395 createobject->Show();
396}
397
398void ObjectInfo::On_bModify_Click(wxCommandEvent& event)
399{
400 if (!modifyobject)
401 modifyobject = new ParameterViewer(panel, this, tType->GetValue(), tParentType->GetValue(), false, -1);
402 if (modifyobject)
403 modifyobject->Show();
404}
405
406void ObjectInfo::On_bSave_Click(wxCommandEvent& event)
407{
408 wxFileDialog Selector (0, _("Save Building Script"), _("buildings/"), _(""), _("Building files (*.bld *.txt)|*.bld;*.txt"), wxFD_SAVE);
409 int result = Selector.ShowModal();
410 if (result == wxID_CANCEL)
411 return;
412 wxString filename = wxT("buildings/") + Selector.GetFilename();
413}
414
415void ObjectInfo::On_bViewScript_Click(wxCommandEvent& event)
416{
417 TextWindow *twindow = new TextWindow(NULL, -1);
418 twindow->SetMinSize(wxSize(640, 480));
419 twindow->tMain->SetMinSize(wxSize(640, 480));
420 twindow->Fit();
421 twindow->Center();
422 twindow->SetTitle(wxT("Current Script"));
423 twindow->Show(true);
424
425 std::vector<std::string> *data = panel->GetRoot()->GetActiveEngine()->GetScriptProcessor()->GetBuildingData();
426 for (size_t i = 0; i < data->size(); i++)
427 {
428 twindow->tMain->WriteText(data->at(i) + wxT("\n"));
429 }
430
431 twindow->tMain->SetInsertionPoint(0);
432}
433
434void ObjectInfo::On_bMove_Click(wxCommandEvent& event)
435{
436 wxTreeItemId sel = ObjectTree->GetSelection();
437
438 if (!sel.IsOk())
439 return;
440
441 TreeItemData *data = (TreeItemData*) ObjectTree->GetItemData(sel);
442
443 wxString num;
444 num = data->GetDesc();
445 int number = atoi(num);
446
447 if (moveobject)
448 delete moveobject;
449 moveobject = 0;
450
451 moveobject = new MoveObject(panel, this, -1, panel->GetRoot()->GetActiveEngine(), number);
452 moveobject->Show();
453}
454
455void ObjectInfo::On_bReset_Click(wxCommandEvent& event)
456{
457 wxTreeItemId sel = ObjectTree->GetSelection();
458
459 if (!sel.IsOk())
460 return;
461
462 TreeItemData *data = (TreeItemData*) ObjectTree->GetItemData(sel);
463 wxString num;
464 num = data->GetDesc();
465 int number = atoi(num);
466
467 //call SBS to reset object state
468 Object *obj = Simcore->GetObject(number);
469 if (obj)
470 obj->ResetState();
471}
472
473}
int GetClickedObjectNumber()
Definition camera.cpp:749
const std::string & GetName()
Definition object.cpp:53
Object * GetParent()
Definition object.cpp:42
std::string command
Definition object.h:59
bool IsPermanent()
Definition object.cpp:166
std::string context
Definition object.h:61
int linenum
Definition object.h:62
int GetNumber()
Definition object.cpp:183
virtual void ResetState()
Definition object.h:102
Object * GetChild(int index)
Definition object.cpp:225
int GetChildrenCount()
Definition object.cpp:234
std::string command_processed
Definition object.h:60
const std::string & GetType()
Definition object.cpp:177
std::string includefile
Definition object.h:63
Camera * camera
Definition sbs.h:160
int GetObjectCount()
Definition sbs.cpp:2446
Object * GetObject(int number)
Definition sbs.cpp:2452
bool DeleteObject(Object *object)
Definition sbs.cpp:2567
SBS::SBS * GetSystem()
Definition debugpanel.h:131
ScriptProcessor * GetScriptProcessor()
ParameterViewer * modifyobject
Definition objectinfo.h:145
wxTextCtrl * tIncludeFile
Definition objectinfo.h:67
wxTextCtrl * tNumber
Definition objectinfo.h:70
static const long ID_tType
Definition objectinfo.h:102
static const long ID_bSave
Definition objectinfo.h:96
static const long ID_STATICTEXT12
Definition objectinfo.h:114
wxTextCtrl * tScriptCommand2
Definition objectinfo.h:75
static const long ID_bViewScript
Definition objectinfo.h:93
static const long ID_bCreate
Definition objectinfo.h:92
static const long ID_STATICLINE1
Definition objectinfo.h:111
static const long ID_tIncludeFile
Definition objectinfo.h:115
static const long ID_bMove
Definition objectinfo.h:91
void On_bOK_Click(wxCommandEvent &event)
void On_ObjectTree_SelectionChanged(wxTreeEvent &event)
static const long ID_tParentType
Definition objectinfo.h:110
static const long ID_STATICTEXT9
Definition objectinfo.h:120
static const long ID_tLineNum
Definition objectinfo.h:113
void On_bDelete_Click(wxCommandEvent &event)
wxTextCtrl * tParentType
Definition objectinfo.h:73
static const long ID_tParentName
Definition objectinfo.h:108
CreateObject * createobject
Definition objectinfo.h:144
static const long ID_STATICTEXT6
Definition objectinfo.h:107
void On_bCreate_Click(wxCommandEvent &event)
wxTextCtrl * tParentName
Definition objectinfo.h:72
static const long ID_tNumber
Definition objectinfo.h:98
MoveObject * moveobject
Definition objectinfo.h:146
static const long ID_STATICTEXT11
Definition objectinfo.h:103
void AddChildren(SBS::Object *parent, const wxTreeItemId &treeparent)
static const long ID_bDelete
Definition objectinfo.h:90
static const long ID_STATICTEXT7
Definition objectinfo.h:112
static const long ID_STATICTEXT10
Definition objectinfo.h:116
void On_bMove_Click(wxCommandEvent &event)
static const long ID_tName
Definition objectinfo.h:100
static const long ID_STATICTEXT8
Definition objectinfo.h:118
wxTextCtrl * tLineNum
Definition objectinfo.h:68
wxTextCtrl * tContext
Definition objectinfo.h:66
static const long ID_STATICTEXT1
Definition objectinfo.h:97
static const long ID_STATICTEXT4
Definition objectinfo.h:109
static const long ID_ObjectTree
Definition objectinfo.h:89
static const long ID_STATICTEXT5
Definition objectinfo.h:99
static const long ID_bReset
Definition objectinfo.h:94
void On_bModify_Click(wxCommandEvent &event)
static const long ID_bOK
Definition objectinfo.h:95
static const long ID_tScriptCommand
Definition objectinfo.h:119
static const long ID_tParent
Definition objectinfo.h:106
static const long ID_tPermanent
Definition objectinfo.h:104
static const long ID_tScriptCommand2
Definition objectinfo.h:121
wxTextCtrl * tScriptCommand
Definition objectinfo.h:76
void On_bReset_Click(wxCommandEvent &event)
wxTextCtrl * tParent
Definition objectinfo.h:71
wxTextCtrl * tPermanent
Definition objectinfo.h:74
void On_bViewScript_Click(wxCommandEvent &event)
static const long ID_tContext
Definition objectinfo.h:117
static const long ID_STATICTEXT3
Definition objectinfo.h:105
wxTreeCtrl * ObjectTree
Definition objectinfo.h:78
void On_bSave_Click(wxCommandEvent &event)
static const long ID_STATICTEXT2
Definition objectinfo.h:101
std::vector< std::string > * GetBuildingData()
const wxChar * GetDesc() const
Definition objectinfo.h:155
EngineContext * GetActiveEngine()
Definition vm.h:81
std::string ToString(int number)
Definition globals.cpp:279
std::string BoolToString(bool item)
Definition globals.cpp:101
TextWindow * twindow
Definition uexception.h:23