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_chkEnabled = wxNewId();
52const long ObjectInfo::ID_bViewScript = wxNewId();
53const long ObjectInfo::ID_bReset = wxNewId();
54const long ObjectInfo::ID_bOK = wxNewId();
55const long ObjectInfo::ID_bSave = wxNewId();
56const long ObjectInfo::ID_STATICTEXT1 = wxNewId();
57const long ObjectInfo::ID_tNumber = wxNewId();
58const long ObjectInfo::ID_STATICTEXT5 = wxNewId();
59const long ObjectInfo::ID_tName = wxNewId();
60const long ObjectInfo::ID_STATICTEXT2 = wxNewId();
61const long ObjectInfo::ID_tType = wxNewId();
62const long ObjectInfo::ID_STATICTEXT11 = wxNewId();
63const long ObjectInfo::ID_tPermanent = wxNewId();
64const long ObjectInfo::ID_STATICTEXT3 = wxNewId();
65const long ObjectInfo::ID_tParent = wxNewId();
66const long ObjectInfo::ID_STATICTEXT6 = wxNewId();
67const long ObjectInfo::ID_tParentName = wxNewId();
68const long ObjectInfo::ID_STATICTEXT4 = wxNewId();
69const long ObjectInfo::ID_tParentType = wxNewId();
70const long ObjectInfo::ID_STATICTEXT13 = wxNewId();
71const long ObjectInfo::ID_txtMovable = wxNewId();
72const long ObjectInfo::ID_STATICLINE1 = wxNewId();
73const long ObjectInfo::ID_STATICTEXT7 = wxNewId();
74const long ObjectInfo::ID_tLineNum = wxNewId();
75const long ObjectInfo::ID_STATICTEXT12 = wxNewId();
76const long ObjectInfo::ID_tIncludeFile = wxNewId();
77const long ObjectInfo::ID_STATICTEXT10 = wxNewId();
78const long ObjectInfo::ID_tContext = wxNewId();
79const long ObjectInfo::ID_STATICTEXT8 = wxNewId();
80const long ObjectInfo::ID_tScriptCommand = wxNewId();
81const long ObjectInfo::ID_STATICTEXT9 = wxNewId();
82const long ObjectInfo::ID_tScriptCommand2 = wxNewId();
83//*)
84
85BEGIN_EVENT_TABLE(ObjectInfo,wxDialog)
86 //(*EventTable(ObjectInfo)
87 //*)
88END_EVENT_TABLE()
89
90ObjectInfo::ObjectInfo(DebugPanel* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
91{
92 //(*Initialize(ObjectInfo)
93 wxBoxSizer* BoxSizer1;
94 wxBoxSizer* BoxSizer2;
95 wxBoxSizer* BoxSizer3;
96 wxFlexGridSizer* FlexGridSizer1;
97 wxFlexGridSizer* FlexGridSizer2;
98 wxFlexGridSizer* FlexGridSizer3;
99 wxFlexGridSizer* FlexGridSizer4;
100 wxFlexGridSizer* FlexGridSizer5;
101 wxFlexGridSizer* FlexGridSizer6;
102
103 Create(parent, wxID_ANY, _("Object Manager"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
104 BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
105 FlexGridSizer4 = new wxFlexGridSizer(0, 1, 0, 0);
106 ObjectTree = new wxTreeCtrl(this, ID_ObjectTree, wxDefaultPosition, wxSize(300,400), wxTR_DEFAULT_STYLE|wxBORDER_SUNKEN|wxVSCROLL, wxDefaultValidator, _T("ID_ObjectTree"));
107 FlexGridSizer4->Add(ObjectTree, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
108 FlexGridSizer4->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
109 BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
110 bDelete = new wxButton(this, ID_bDelete, _("Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bDelete"));
111 bDelete->SetToolTip(_("Delete selected object"));
112 BoxSizer2->Add(bDelete, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
113 bMove = new wxButton(this, ID_bMove, _("Move"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bMove"));
114 bMove->SetToolTip(_("Move selected object"));
115 BoxSizer2->Add(bMove, 1, wxALL|wxALIGN_TOP, 5);
116 bCreate = new wxButton(this, ID_bCreate, _("Create"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bCreate"));
117 bCreate->SetToolTip(_("Create a new object"));
118 BoxSizer2->Add(bCreate, 1, wxALL|wxALIGN_TOP, 5);
119 chkEnabled = new wxCheckBox(this, ID_chkEnabled, _("Enabled"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_chkEnabled"));
120 chkEnabled->SetValue(false);
121 BoxSizer2->Add(chkEnabled, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
122 FlexGridSizer4->Add(BoxSizer2, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
123 BoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
124 bViewScript = new wxButton(this, ID_bViewScript, _("View Script"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bViewScript"));
125 bViewScript->SetToolTip(_("View current running script"));
126 BoxSizer3->Add(bViewScript, 1, wxALL|wxALIGN_TOP, 5);
127 bReset = new wxButton(this, ID_bReset, _("Reset State"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bReset"));
128 bReset->SetToolTip(_("Reset the state of the current object"));
129 BoxSizer3->Add(bReset, 1, wxALL|wxALIGN_TOP, 5);
130 bOK = new wxButton(this, ID_bOK, _("OK"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bOK"));
131 BoxSizer3->Add(bOK, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
132 bSave = new wxButton(this, ID_bSave, _("Save Script"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_bSave"));
133 bSave->Disable();
134 bSave->Hide();
135 BoxSizer3->Add(bSave, 1, wxALL|wxALIGN_TOP, 5);
136 FlexGridSizer4->Add(BoxSizer3, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
137 BoxSizer1->Add(FlexGridSizer4, 1, wxALL|wxEXPAND, 5);
138 FlexGridSizer2 = new wxFlexGridSizer(0, 1, 0, 0);
139 FlexGridSizer1 = new wxFlexGridSizer(0, 2, 0, 0);
140 StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Number:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
141 FlexGridSizer1->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
142 tNumber = new wxTextCtrl(this, ID_tNumber, wxEmptyString, wxDefaultPosition, wxSize(200,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tNumber"));
143 FlexGridSizer1->Add(tNumber, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
144 StaticText5 = new wxStaticText(this, ID_STATICTEXT5, _("Name:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT5"));
145 FlexGridSizer1->Add(StaticText5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
146 tName = new wxTextCtrl(this, ID_tName, wxEmptyString, wxDefaultPosition, wxSize(200,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tName"));
147 FlexGridSizer1->Add(tName, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
148 StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Type:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
149 FlexGridSizer1->Add(StaticText2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
150 tType = new wxTextCtrl(this, ID_tType, wxEmptyString, wxDefaultPosition, wxSize(200,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tType"));
151 FlexGridSizer1->Add(tType, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
152 StaticText11 = new wxStaticText(this, ID_STATICTEXT11, _("Permanent:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT11"));
153 FlexGridSizer1->Add(StaticText11, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
154 tPermanent = new wxTextCtrl(this, ID_tPermanent, wxEmptyString, wxDefaultPosition, wxSize(200,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tPermanent"));
155 FlexGridSizer1->Add(tPermanent, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
156 StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("Parent:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
157 FlexGridSizer1->Add(StaticText3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
158 tParent = new wxTextCtrl(this, ID_tParent, wxEmptyString, wxDefaultPosition, wxSize(200,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tParent"));
159 FlexGridSizer1->Add(tParent, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
160 StaticText6 = new wxStaticText(this, ID_STATICTEXT6, _("Parent Name:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
161 FlexGridSizer1->Add(StaticText6, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
162 tParentName = new wxTextCtrl(this, ID_tParentName, wxEmptyString, wxDefaultPosition, wxSize(200,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tParentName"));
163 FlexGridSizer1->Add(tParentName, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
164 StaticText4 = new wxStaticText(this, ID_STATICTEXT4, _("Parent Type:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
165 FlexGridSizer1->Add(StaticText4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
166 tParentType = new wxTextCtrl(this, ID_tParentType, wxEmptyString, wxDefaultPosition, wxSize(200,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tParentType"));
167 FlexGridSizer1->Add(tParentType, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
168 StaticText13 = new wxStaticText(this, ID_STATICTEXT13, _("Is Movable:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT13"));
169 FlexGridSizer1->Add(StaticText13, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
170 txtMovable = new wxTextCtrl(this, ID_txtMovable, wxEmptyString, wxDefaultPosition, wxSize(200,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_txtMovable"));
171 FlexGridSizer1->Add(txtMovable, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
172 FlexGridSizer2->Add(FlexGridSizer1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
173 StaticLine1 = new wxStaticLine(this, ID_STATICLINE1, wxDefaultPosition, wxSize(10,-1), wxLI_HORIZONTAL, _T("ID_STATICLINE1"));
174 FlexGridSizer2->Add(StaticLine1, 1, wxALL|wxEXPAND, 5);
175 FlexGridSizer3 = new wxFlexGridSizer(0, 3, 0, 0);
176 StaticText7 = new wxStaticText(this, ID_STATICTEXT7, _("Object created on line:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT7"));
177 FlexGridSizer3->Add(StaticText7, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
178 tLineNum = new wxTextCtrl(this, ID_tLineNum, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tLineNum"));
179 tLineNum->SetMinSize(wxSize(100,-1));
180 FlexGridSizer3->Add(tLineNum, 1, wxLEFT|wxRIGHT, 5);
181 FlexGridSizer2->Add(FlexGridSizer3, 1, wxTOP|wxLEFT|wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
182 FlexGridSizer6 = new wxFlexGridSizer(0, 3, 0, 0);
183 StaticText12 = new wxStaticText(this, ID_STATICTEXT12, _("In included file:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT12"));
184 FlexGridSizer6->Add(StaticText12, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
185 tIncludeFile = new wxTextCtrl(this, ID_tIncludeFile, wxEmptyString, wxDefaultPosition, wxSize(150,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tIncludeFile"));
186 FlexGridSizer6->Add(tIncludeFile, 1, wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
187 FlexGridSizer2->Add(FlexGridSizer6, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
188 FlexGridSizer5 = new wxFlexGridSizer(0, 3, 0, 0);
189 StaticText10 = new wxStaticText(this, ID_STATICTEXT10, _("Script context:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT10"));
190 FlexGridSizer5->Add(StaticText10, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
191 tContext = new wxTextCtrl(this, ID_tContext, wxEmptyString, wxDefaultPosition, wxSize(125,-1), wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tContext"));
192 FlexGridSizer5->Add(tContext, 1, wxLEFT|wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
193 FlexGridSizer2->Add(FlexGridSizer5, 1, wxBOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
194 StaticText8 = new wxStaticText(this, ID_STATICTEXT8, _("Script Command:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT8"));
195 FlexGridSizer2->Add(StaticText8, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
196 tScriptCommand = new wxTextCtrl(this, ID_tScriptCommand, wxEmptyString, wxDefaultPosition, wxSize(300,40), wxTE_MULTILINE|wxTE_READONLY|wxTE_CENTRE|wxTE_WORDWRAP, wxDefaultValidator, _T("ID_tScriptCommand"));
197 FlexGridSizer2->Add(tScriptCommand, 1, wxALL|wxEXPAND, 5);
198 StaticText9 = new wxStaticText(this, ID_STATICTEXT9, _("Processed Script Command:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT9"));
199 FlexGridSizer2->Add(StaticText9, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
200 tScriptCommand2 = new wxTextCtrl(this, ID_tScriptCommand2, wxEmptyString, wxDefaultPosition, wxSize(-1,40), wxTE_MULTILINE|wxTE_READONLY|wxTE_CENTRE, wxDefaultValidator, _T("ID_tScriptCommand2"));
201 FlexGridSizer2->Add(tScriptCommand2, 1, wxALL|wxEXPAND, 5);
202 BoxSizer1->Add(FlexGridSizer2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
203 SetSizer(BoxSizer1);
204 BoxSizer1->SetSizeHints(this);
205 Center();
206
207 Connect(ID_ObjectTree,wxEVT_COMMAND_TREE_SEL_CHANGED,(wxObjectEventFunction)&ObjectInfo::On_ObjectTree_SelectionChanged);
208 Connect(ID_bDelete,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bDelete_Click);
209 Connect(ID_bMove,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bMove_Click);
210 Connect(ID_bCreate,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bCreate_Click);
211 Connect(ID_chkEnabled,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_chkEnabled_Click);
212 Connect(ID_bViewScript,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bViewScript_Click);
213 Connect(ID_bReset,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bReset_Click);
214 Connect(ID_bOK,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bOK_Click);
215 Connect(ID_bSave,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ObjectInfo::On_bSave_Click);
216 //*)
217 panel = parent;
218 createobject = 0;
219 modifyobject = 0;
220 moveobject = 0;
221 OnInit();
222}
223
225{
226 //(*Destroy(ObjectInfo)
227 //*)
228
229 if (createobject)
230 createobject->Destroy();
231 createobject = 0;
232 if (modifyobject)
233 modifyobject->Destroy();
234 modifyobject = 0;
235 if (moveobject)
236 moveobject->Destroy();
237 moveobject = 0;
238}
239
241{
242 oldobject = -1;
243 oldcamobject = -1;
244 changed = false;
245 lastcount = 0;
246 deleted = false;
248}
249
250void ObjectInfo::On_bOK_Click(wxCommandEvent& event)
251{
252 this->Hide();
253}
254
256{
257 //if active engine has changed, refresh values
258 if (Simcore != panel->GetSystem())
259 OnInit();
260
261 if (!Simcore)
262 return;
263
265 {
267 if (deleted == false)
268 PopulateTree();
269 deleted = false;
270 }
271
272 if (moveobject)
273 moveobject->Loop();
274
275 int number = oldobject;
276 if (changed == false)
277 {
278 int newobject = Simcore->camera->GetClickedObjectNumber();
279 if (newobject != oldcamobject)
280 {
283 }
284 else
285 number = oldobject;
286 }
287 else
288 {
289 wxTreeItemId id = ObjectTree->GetSelection();
290 if (id.IsOk())
291 {
292 TreeItemData *data = (TreeItemData*) ObjectTree->GetItemData(id);
293 wxString num;
294 num = data->GetDesc();
295 number = atoi(num);
296 }
297 changed = false;
298 }
299 if (number == oldobject)
300 return;
301
302 oldobject = number;
303 Object *object = Simcore->GetObject(number);
304 tNumber->SetValue(ToString(number));
305 tLineNum->Clear();
306 tIncludeFile->Clear();
307 tScriptCommand->Clear();
308 tScriptCommand2->Clear();
309 tContext->Clear();
310 tName->Clear();
311 tType->Clear();
312 tPermanent->Clear();
313 tParent->Clear();
314 tParentName->Clear();
315 tParentType->Clear();
316
317 if (object)
318 {
319 tName->SetValue(object->GetName());
320 tType->SetValue(object->GetType());
321 tLineNum->SetValue(ToString(object->linenum));
322 tIncludeFile->SetValue(object->includefile);
323 tScriptCommand->SetValue(object->command);
324 tScriptCommand2->SetValue(object->command_processed);
325 tContext->SetValue(object->context);
326 tPermanent->SetValue(BoolToString(object->IsPermanent()));
327 chkEnabled->SetValue(object->IsEnabled());
328 txtMovable->SetValue(BoolToString(object->IsMovable()));
329
330 Object *parent = object->GetParent();
331 if (parent)
332 {
333 tParent->SetValue(ToString(parent->GetNumber()));
334 tParentName->SetValue(parent->GetName());
335 tParentType->SetValue(parent->GetType());
336 }
337 }
338}
339
341{
342 //erase tree
343 ObjectTree->DeleteAllItems();
344
345 //populate object tree
346 wxTreeItemId id = ObjectTree->AddRoot(Simcore->GetName(), -1, -1, new TreeItemData(ToString(Simcore->GetNumber())));
347
348 //add child objects
349 AddChildren(Simcore, id);
350
351 ObjectTree->Expand(id);
352}
353
354void ObjectInfo::AddChildren(Object *parent, const wxTreeItemId& treeparent)
355{
356 if (!parent)
357 return;
358
359 //add child objects of given SBS object to tree
360 if (parent->GetChildrenCount() > 0)
361 {
362 for (int i = 0; i < parent->GetChildrenCount(); i++)
363 {
364 if (parent->GetChild(i))
365 {
366 //add child object
367 wxTreeItemId id = ObjectTree->AppendItem(treeparent, parent->GetChild(i)->GetName(), -1, -1, new TreeItemData(ToString(parent->GetChild(i)->GetNumber())));
368
369 //if child object has children, call recursively to add those
370 if (parent->GetChild(i)->GetChildrenCount() > 0)
371 AddChildren(parent->GetChild(i), id);
372 }
373 }
374 }
375}
376
378{
379 changed = true;
380}
381
382void ObjectInfo::On_bDelete_Click(wxCommandEvent& event)
383{
384 wxTreeItemId sel = ObjectTree->GetSelection();
385
386 if (!sel.IsOk())
387 return;
388
389 TreeItemData *data = (TreeItemData*) ObjectTree->GetItemData(sel);
390 wxString num;
391 num = data->GetDesc();
392 int number = atoi(num);
393
394 //call SBS to delete object
395 if (Simcore->DeleteObject(number))
396 {
397 //delete object from tree
398 ObjectTree->Delete(sel);
399 deleted = true;
400 }
401}
402
403void ObjectInfo::On_bCreate_Click(wxCommandEvent& event)
404{
405 if (!createobject)
406 createobject = new CreateObject(panel, this, -1);
407 if (createobject)
408 createobject->Show();
409}
410
411void ObjectInfo::On_bModify_Click(wxCommandEvent& event)
412{
413 if (!modifyobject)
414 modifyobject = new ParameterViewer(panel, this, tType->GetValue(), tParentType->GetValue(), false, -1);
415 if (modifyobject)
416 modifyobject->Show();
417}
418
419void ObjectInfo::On_bSave_Click(wxCommandEvent& event)
420{
421 wxFileDialog Selector (0, _("Save Building Script"), _("buildings/"), _(""), _("Building files (*.bld *.txt)|*.bld;*.txt"), wxFD_SAVE);
422 int result = Selector.ShowModal();
423 if (result == wxID_CANCEL)
424 return;
425 wxString filename = wxT("buildings/") + Selector.GetFilename();
426}
427
428void ObjectInfo::On_bViewScript_Click(wxCommandEvent& event)
429{
430 TextWindow *twindow = new TextWindow(NULL, -1);
431 twindow->SetMinSize(wxSize(640, 480));
432 twindow->tMain->SetMinSize(wxSize(640, 480));
433 twindow->Fit();
434 twindow->Center();
435 twindow->SetTitle(wxT("Current Script"));
436 twindow->Show(true);
437
438 std::vector<std::string> *data = panel->GetRoot()->GetActiveEngine()->GetScriptProcessor()->GetBuildingData();
439 for (size_t i = 0; i < data->size(); i++)
440 {
441 twindow->tMain->WriteText(data->at(i) + wxT("\n"));
442 }
443
444 twindow->tMain->SetInsertionPoint(0);
445}
446
447void ObjectInfo::On_bMove_Click(wxCommandEvent& event)
448{
449 wxTreeItemId sel = ObjectTree->GetSelection();
450
451 if (!sel.IsOk())
452 return;
453
454 TreeItemData *data = (TreeItemData*) ObjectTree->GetItemData(sel);
455
456 wxString num;
457 num = data->GetDesc();
458 int number = atoi(num);
459
460 if (moveobject)
461 delete moveobject;
462 moveobject = 0;
463
464 moveobject = new MoveObject(panel, this, -1, panel->GetRoot()->GetActiveEngine(), number);
465 moveobject->Show();
466}
467
468void ObjectInfo::On_bReset_Click(wxCommandEvent& event)
469{
470 wxTreeItemId sel = ObjectTree->GetSelection();
471
472 if (!sel.IsOk())
473 return;
474
475 TreeItemData *data = (TreeItemData*) ObjectTree->GetItemData(sel);
476 wxString num;
477 num = data->GetDesc();
478 int number = atoi(num);
479
480 //call SBS to reset object state
481 Object *obj = Simcore->GetObject(number);
482 if (obj)
483 obj->ResetState();
484}
485
486void ObjectInfo::On_chkEnabled_Click(wxCommandEvent& event)
487{
488 wxTreeItemId sel = ObjectTree->GetSelection();
489
490 if (!sel.IsOk())
491 return;
492
493 TreeItemData *data = (TreeItemData*) ObjectTree->GetItemData(sel);
494 wxString num;
495 num = data->GetDesc();
496 int number = atoi(num);
497
498 //call SBS to reset object state
499 Object *obj = Simcore->GetObject(number);
500 if (obj)
501 obj->Enabled(chkEnabled->GetValue());
502}
503
504}
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
bool IsMovable()
Definition object.cpp:172
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:100
virtual void Enabled(bool value)
Definition object.h:108
Object * GetChild(int index)
Definition object.cpp:231
int GetChildrenCount()
Definition object.cpp:240
std::string command_processed
Definition object.h:60
const std::string & GetType()
Definition object.cpp:177
virtual bool IsEnabled()
Definition object.h:109
std::string includefile
Definition object.h:63
Camera * camera
Definition sbs.h:160
int GetObjectCount()
Definition sbs.cpp:2476
Object * GetObject(int number)
Definition sbs.cpp:2482
bool DeleteObject(Object *object)
Definition sbs.cpp:2597
SBS::SBS * GetSystem()
Definition debugpanel.h:131
ScriptProcessor * GetScriptProcessor()
ParameterViewer * modifyobject
Definition objectinfo.h:153
wxTextCtrl * tIncludeFile
Definition objectinfo.h:70
wxTextCtrl * tNumber
Definition objectinfo.h:73
static const long ID_tType
Definition objectinfo.h:107
static const long ID_bSave
Definition objectinfo.h:101
void On_chkEnabled_Click(wxCommandEvent &event)
static const long ID_STATICTEXT12
Definition objectinfo.h:121
wxTextCtrl * tScriptCommand2
Definition objectinfo.h:78
static const long ID_bViewScript
Definition objectinfo.h:98
static const long ID_bCreate
Definition objectinfo.h:96
static const long ID_STATICLINE1
Definition objectinfo.h:118
static const long ID_tIncludeFile
Definition objectinfo.h:122
static const long ID_bMove
Definition objectinfo.h:95
void On_bOK_Click(wxCommandEvent &event)
void On_ObjectTree_SelectionChanged(wxTreeEvent &event)
static const long ID_txtMovable
Definition objectinfo.h:117
wxCheckBox * chkEnabled
Definition objectinfo.h:54
static const long ID_tParentType
Definition objectinfo.h:115
static const long ID_STATICTEXT9
Definition objectinfo.h:127
static const long ID_tLineNum
Definition objectinfo.h:120
void On_bDelete_Click(wxCommandEvent &event)
wxTextCtrl * tParentType
Definition objectinfo.h:76
static const long ID_tParentName
Definition objectinfo.h:113
static const long ID_STATICTEXT13
Definition objectinfo.h:116
CreateObject * createobject
Definition objectinfo.h:152
wxTextCtrl * txtMovable
Definition objectinfo.h:81
static const long ID_STATICTEXT6
Definition objectinfo.h:112
void On_bCreate_Click(wxCommandEvent &event)
wxTextCtrl * tParentName
Definition objectinfo.h:75
static const long ID_tNumber
Definition objectinfo.h:103
MoveObject * moveobject
Definition objectinfo.h:154
static const long ID_STATICTEXT11
Definition objectinfo.h:108
void AddChildren(SBS::Object *parent, const wxTreeItemId &treeparent)
static const long ID_bDelete
Definition objectinfo.h:94
static const long ID_STATICTEXT7
Definition objectinfo.h:119
static const long ID_STATICTEXT10
Definition objectinfo.h:123
void On_bMove_Click(wxCommandEvent &event)
static const long ID_tName
Definition objectinfo.h:105
static const long ID_STATICTEXT8
Definition objectinfo.h:125
wxTextCtrl * tLineNum
Definition objectinfo.h:71
wxTextCtrl * tContext
Definition objectinfo.h:69
static const long ID_STATICTEXT1
Definition objectinfo.h:102
static const long ID_STATICTEXT4
Definition objectinfo.h:114
static const long ID_ObjectTree
Definition objectinfo.h:93
static const long ID_STATICTEXT5
Definition objectinfo.h:104
static const long ID_bReset
Definition objectinfo.h:99
void On_bModify_Click(wxCommandEvent &event)
static const long ID_bOK
Definition objectinfo.h:100
static const long ID_tScriptCommand
Definition objectinfo.h:126
static const long ID_tParent
Definition objectinfo.h:111
static const long ID_tPermanent
Definition objectinfo.h:109
static const long ID_tScriptCommand2
Definition objectinfo.h:128
wxTextCtrl * tScriptCommand
Definition objectinfo.h:79
void On_bReset_Click(wxCommandEvent &event)
static const long ID_chkEnabled
Definition objectinfo.h:97
wxTextCtrl * tParent
Definition objectinfo.h:74
wxTextCtrl * tPermanent
Definition objectinfo.h:77
void On_bViewScript_Click(wxCommandEvent &event)
static const long ID_tContext
Definition objectinfo.h:124
static const long ID_STATICTEXT3
Definition objectinfo.h:110
wxTreeCtrl * ObjectTree
Definition objectinfo.h:82
void On_bSave_Click(wxCommandEvent &event)
static const long ID_STATICTEXT2
Definition objectinfo.h:106
std::vector< std::string > * GetBuildingData()
const wxChar * GetDesc() const
Definition objectinfo.h:163
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