diff options
-rw-r--r-- | src/ui/studio.cpp | 274 | ||||
-rw-r--r-- | src/ui/studio.h | 50 |
2 files changed, 169 insertions, 155 deletions
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 2b90b8f..7473a18 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -20,7 +20,35 @@ #include "studio.h" -#include <script/cbottoken.h> +#include "CBot/CBotDll.h" + +#include "app/app.h" +#include "common/event.h" +#include "common/iman.h" +#include "common/misc.h" +#include "graphics/engine/camera.h" +#include "graphics/engine/engine.h" +#include "object/object.h" +#include "script/cbottoken.h" +#include "script/script.h" +#include "sound/sound.h" +#include "ui/check.h" +#include "ui/control.h" +#include "ui/color.h" +#include "ui/compass.h" +#include "ui/edit.h" +#include "ui/group.h" +#include "ui/image.h" +#include "ui/interface.h" +#include "ui/key.h" +#include "ui/label.h" +#include "ui/list.h" +#include "ui/map.h" +#include "ui/shortcut.h" +#include "ui/target.h" +#include "ui/window.h" + +#include <stdio.h> const int MAX_FNAME = 255; @@ -82,7 +110,7 @@ bool CStudio::EventProcess(const Event &event) EventFrame(event); } - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw == nullptr ) return false; edit = static_cast<CEdit*>(pw->SearchControl(EVENT_STUDIO_EDIT)); @@ -138,8 +166,8 @@ bool CStudio::EventProcess(const Event &event) if ( event.type == EVENT_STUDIO_SIZE ) // size? { - slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); - if ( slider == 0 ) return false; + slider = static_cast< CSlider* >(pw->SearchControl(EVENT_STUDIO_SIZE)); + if ( slider == nullptr ) return false; m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f); ViewEditScript(); } @@ -213,8 +241,8 @@ bool CStudio::EventProcess(const Event &event) if ( event.type == EVENT_KEY_DOWN ) { - if ( event.param == m_app->GetKey(KEYRANK_CBOT, 0) || - event.param == m_app->GetKey(KEYRANK_CBOT, 1) ) + if ( event.key.key == m_app->GetInputBinding(INPUT_SLOT_CBOT).key // || + /*TODO event.param == m_app->GetKey(KEYRANK_CBOT, 1)*/ ) { if ( m_helpFilename.length() > 0 ) { @@ -250,7 +278,7 @@ bool CStudio::EventProcess(const Event &event) m_bEditMaximized = false; } m_main->SetEditFull(m_bEditMaximized); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != nullptr ) { pw->SetMaximized(m_bEditMaximized); @@ -276,7 +304,7 @@ bool CStudio::EventProcess(const Event &event) m_bEditMaximized = true; } m_main->SetEditFull(m_bEditMaximized); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != nullptr ) { pw->SetMaximized(m_bEditMaximized); @@ -322,13 +350,13 @@ bool CStudio::EventFrame(const Event &event) m_time += event.rTime; m_fixInfoTextTime -= event.rTime; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw == nullptr ) return false; - edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit == 0 ) return false; - list = (CList*)pw->SearchControl(EVENT_STUDIO_LIST); + list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST)); if ( list == 0 ) return false; if ( !m_script->IsRunning() && m_bRunning ) // stop? @@ -337,7 +365,7 @@ bool CStudio::EventFrame(const Event &event) UpdateFlux(); // stop AdjustEditScript(); GetResource(RES_TEXT, RT_STUDIO_PROGSTOP, res); - SetInfoText(std::string(res), false); + SetInfoText(res, false); Event newEvent = event; newEvent.type = EVENT_OBJECT_PROGSTOP; @@ -416,13 +444,13 @@ void CStudio::SearchToken(CEdit* edit) i = cursor1; if ( i > 0 ) { - character = (unsigned char)text[i-1]; + character = static_cast< unsigned char > (text[i-1]); if ( !IsToken(character) ) { level = 1; while ( i > 0 ) { - character = (unsigned char)text[i-1]; + character = static_cast< unsigned char > (text[i-1]); if ( character == ')' ) { level ++; @@ -442,7 +470,7 @@ void CStudio::SearchToken(CEdit* edit) } while ( i > 0 ) { - character = (unsigned char)text[i-1]; + character = static_cast< unsigned char > (text[i-1]); if ( IsToken(character) ) break; i --; } @@ -451,7 +479,7 @@ void CStudio::SearchToken(CEdit* edit) while ( i > 0 ) { - character = (unsigned char)text[i-1]; + character = static_cast< unsigned char > (text[i-1]); if ( !IsToken(character) ) break; i --; } @@ -459,7 +487,7 @@ void CStudio::SearchToken(CEdit* edit) while ( i < len ) { - character = (unsigned char)text[i]; + character = static_cast< unsigned char > (text[i]); if ( !IsToken(character) ) break; i ++; } @@ -478,7 +506,7 @@ void CStudio::SearchToken(CEdit* edit) { for ( i=0 ; i<OBJECT_MAX ; i++ ) { - type = (ObjectType)i; + type = static_cast< ObjectType >(i); text = GetObjectName(type); if ( text[0] != 0 ) { @@ -547,7 +575,7 @@ void CStudio::StartEditScript(CScript *script, std::string name, int rank) m_bRealTime = m_bRunning; m_script->SetStepMode(!m_bRealTime); - button = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT); + button = static_cast< CButton* >(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if ( button != 0 ) { button->ClearState(STATE_VISIBLE); @@ -578,7 +606,11 @@ void CStudio::StartEditScript(CScript *script, std::string name, int rank) edit->SetFontStretch(0.7f); edit->SetDisplaySpec(true); edit->SetAutoIndent(m_engine->GetEditIndentMode()); - m_script->PutScript(edit, name); + // TODO replace to PutScript after change to std::string + char* tmp; + strcpy(tmp, name.c_str()); +// m_script->PutScript(edit, name); + m_script->PutScript(edit, tmp); ColorizeScript(edit); ViewEditScript(); @@ -587,7 +619,7 @@ void CStudio::StartEditScript(CScript *script, std::string name, int rank) list->SetState(STATE_SHADOW); list->SetFontType(Gfx::FONT_COURIER); list->SetSelectCap(false); - list->SetFontSize(SMALLFONT*0.85f); + list->SetFontSize(Gfx::FONT_SIZE_SMALL*0.85f); //? list->SetFontStretch(1.0f); button = pw->CreateButton(pos, dim, 56, EVENT_STUDIO_NEW); @@ -647,7 +679,7 @@ void CStudio::AdjustEditScript() wpos = m_editActualPos; wdim = m_editActualDim; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != nullptr ) { pw->SetPos(wpos); @@ -662,7 +694,7 @@ void CStudio::AdjustEditScript() pos.y = wpos.y+0.09f+hList; dim.x = wdim.x-0.02f; dim.y = wdim.y-0.22f-hList; - edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit != 0 ) { edit->SetPos(pos); @@ -673,7 +705,7 @@ void CStudio::AdjustEditScript() pos.y = wpos.y+0.09f; dim.x = wdim.x-0.02f; dim.y = hList; - list = (CList*)pw->SearchControl(EVENT_STUDIO_LIST); + list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST)); if ( list != 0 ) { list->SetPos(pos); @@ -686,56 +718,56 @@ void CStudio::AdjustEditScript() pos.y = wpos.y+wdim.y-dim.y-0.06f; pos.x = wpos.x+0.01f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_NEW); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_NEW)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.05f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_OPEN); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_OPEN)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.09f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_SAVE); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_SAVE)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.14f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_UNDO); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_UNDO)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.19f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_CUT); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_CUT)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.23f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_COPY); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COPY)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.27f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_PASTE); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_PASTE)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.32f; - slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE); + slider = static_cast< CSlider* >(pw->SearchControl(EVENT_STUDIO_SIZE)); if ( slider != 0 ) { ppos = pos; @@ -747,21 +779,21 @@ void CStudio::AdjustEditScript() slider->SetDim(ddim); } pos.x = wpos.x+0.36f; - group = (CGroup*)pw->SearchControl(EVENT_LABEL1); + group = static_cast< CGroup* >(pw->SearchControl(EVENT_LABEL1)); if ( group != 0 ) { group->SetPos(pos); group->SetDim(dim); } pos.x = wpos.x+0.40f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_TOOL); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_TOOL)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.44f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_HELP); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_HELP)); if ( button != 0 ) { button->SetPos(pos); @@ -772,14 +804,14 @@ void CStudio::AdjustEditScript() pos.x = wpos.x+0.01f; dim.x = 80.0f/640.0f; dim.y = 25.0f/480.0f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_OK); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_OK)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.14f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_CANCEL); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_CANCEL)); if ( button != 0 ) { button->SetPos(pos); @@ -787,28 +819,28 @@ void CStudio::AdjustEditScript() } pos.x = wpos.x+0.28f; dim.x = dim.y*0.75f; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_COMPILE); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COMPILE)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.28f+dim.x*1; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_RUN); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_RUN)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.28f+dim.x*2; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_REALTIME); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_REALTIME)); if ( button != 0 ) { button->SetPos(pos); button->SetDim(dim); } pos.x = wpos.x+0.28f+dim.x*3; - button = (CButton*)pw->SearchControl(EVENT_STUDIO_STEP); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_STEP)); if ( button != 0 ) { button->SetPos(pos); @@ -825,12 +857,12 @@ bool CStudio::StopEditScript(bool bCancel) CButton* button; char buffer[100]; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw == nullptr ) return false; if ( !bCancel && !m_script->IsRunning() ) { - edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit != 0 ) { if ( !m_script->GetScript(edit) ) // compile @@ -845,7 +877,7 @@ bool CStudio::StopEditScript(bool bCancel) m_interface->DeleteControl(EVENT_WINDOW3); - button = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT); + button = static_cast< CButton* >(m_interface->SearchControl(EVENT_BUTTON_QUIT)); if ( button != 0 ) { button->SetState(STATE_VISIBLE); @@ -862,23 +894,23 @@ bool CStudio::StopEditScript(bool bCancel) // The messages are not clickable 8 seconds, // even if a message was clickable poster before. -void CStudio::SetInfoText(char *text, bool bClickable) +void CStudio::SetInfoText(std::string text, bool bClickable) { - CWindow* pw; - CList* list; char res[100]; if ( bClickable && m_fixInfoTextTime > 0.0f ) return; if ( !bClickable ) m_fixInfoTextTime = 8.0f; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + CWindow* pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw == nullptr ) return; - list = (CList*)pw->SearchControl(EVENT_STUDIO_LIST); + CList* list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST)); if ( list == 0 ) return; list->Flush(); // just text - list->SetName(0, text); + char* tmp; + strcpy(tmp,text.c_str()); + list->SetName(0, tmp); // TODO if ( text[0] == 0 ) bClickable = false; list->SetSelectCap(bClickable); @@ -904,15 +936,15 @@ void CStudio::ViewEditScript() { CWindow* pw; CEdit* edit; - POINT dim; + Math::IntPoint dim; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw == nullptr ) return; - edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit == 0 ) return; - dim = m_engine->GetDim(); + dim = m_engine->GetWindowSize(); edit->SetFontSize(m_main->GetFontSize()/(dim.x/640.0f)); } @@ -954,10 +986,10 @@ void CStudio::UpdateButtons() CEdit* edit; CButton* button; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw == nullptr ) return; - edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit == 0 ) return; if ( m_bRunning ) @@ -973,20 +1005,20 @@ void CStudio::UpdateButtons() edit->SetHiliteCap(true); } - button = (CButton*)pw->SearchControl(EVENT_STUDIO_COMPILE); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COMPILE)); if ( button == 0 ) return; button->SetState(STATE_ENABLE, !m_bRunning); - button = (CButton*)pw->SearchControl(EVENT_STUDIO_RUN); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_RUN)); if ( button == 0 ) return; button->SetIcon(m_bRunning?8:21); // stop/run - button = (CButton*)pw->SearchControl(EVENT_STUDIO_REALTIME); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_REALTIME)); if ( button == 0 ) return; button->SetIcon(m_bRealTime?64+22:64+21); button->SetState(STATE_ENABLE, (!m_bRunning || !m_script->IsContinue())); - button = (CButton*)pw->SearchControl(EVENT_STUDIO_STEP); + button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_STEP)); if ( button == 0 ) return; button->SetState(STATE_ENABLE, (m_bRunning && !m_bRealTime && !m_script->IsContinue())); } @@ -1007,31 +1039,31 @@ void CStudio::StartDialog(StudioDialog type) m_dialog = type; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW1)); if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW6)); if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW7)); if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW8)); if ( pw != nullptr ) pw->ClearState(STATE_ENABLE); if ( m_dialog == SD_OPEN || @@ -1058,14 +1090,14 @@ void CStudio::StartDialog(StudioDialog type) { GetResource(RES_TEXT, RT_IO_LIST, name); pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL1, name); - pla->SetTextAlign(1); + pla->SetTextAlign(Gfx::TEXT_ALIGN_RIGHT); pli = pw->CreateList(pos, dim, 0, EVENT_DIALOG_LIST); pli->SetState(STATE_SHADOW); GetResource(RES_TEXT, RT_IO_NAME, name); pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL2, name); - pla->SetTextAlign(1); + pla->SetTextAlign(Gfx::TEXT_ALIGN_RIGHT); pe = pw->CreateEdit(pos, dim, 0, EVENT_DIALOG_EDIT); pe->SetState(STATE_SHADOW); @@ -1076,7 +1108,7 @@ void CStudio::StartDialog(StudioDialog type) GetResource(RES_TEXT, RT_IO_DIR, name); pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL3, name); - pla->SetTextAlign(1); + pla->SetTextAlign(Gfx::TEXT_ALIGN_RIGHT); pc = pw->CreateCheck(pos, dim, 0, EVENT_DIALOG_CHECK1); GetResource(RES_TEXT, RT_IO_PRIVATE, name); @@ -1126,31 +1158,31 @@ void CStudio::StopDialog() if ( m_dialog == SD_NULL ) return; m_dialog = SD_NULL; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW1)); if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW2)); if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW6)); if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW7)); if ( pw != nullptr ) pw->SetState(STATE_ENABLE); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW8)); if ( pw != nullptr ) pw->SetState(STATE_ENABLE); m_interface->DeleteControl(EVENT_WINDOW9); @@ -1171,7 +1203,7 @@ void CStudio::AdjustDialog() int nli, nch; char name[100]; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; wpos = pw->GetPos(); @@ -1185,7 +1217,7 @@ void CStudio::AdjustDialog() ppos.y = wpos.y+wdim.y-55.0f/480.0f; ddim.x = wdim.x-20.0f/640.0f; ddim.y = 20.0f/480.0f; - pla = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL1); + pla = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL1)); if ( pla != 0 ) { pla->SetPos(ppos); @@ -1195,13 +1227,13 @@ void CStudio::AdjustDialog() nli = (int)((wdim.y-120.0f/480.0f)/(18.0f/480.0f)); ddim.y = nli*18.0f/480.0f+9.0f/480.0f; ppos.y = wpos.y+wdim.y-48.0f/480.0f-ddim.y; - pli = (CList*)pw->SearchControl(EVENT_DIALOG_LIST); + pli = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST)); if ( pli != 0 ) { pli->SetPos(ppos); pli->SetDim(ddim); pli->SetTabs(0, ddim.x-(50.0f+130.0f+16.0f)/640.0f); - pli->SetTabs(1, 50.0f/640.0f, -1); + pli->SetTabs(1, 50.0f/640.0f, Gfx::TEXT_ALIGN_LEFT); pli->SetTabs(2, 130.0f/640.0f); //? pli->ShowSelect(); } @@ -1209,7 +1241,7 @@ void CStudio::AdjustDialog() ppos.y = wpos.y+30.0f/480.0f; ddim.x = 50.0f/640.0f; ddim.y = 20.0f/480.0f; - pla = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL2); + pla = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL2)); if ( pla != 0 ) { pla->SetPos(ppos); @@ -1219,13 +1251,13 @@ void CStudio::AdjustDialog() ppos.x += 50.0f/640.0f; ppos.y = wpos.y+36.0f/480.0f; ddim.x = wdim.x-170.0f/640.0f; - pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT); + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); if ( pe != 0 ) { pe->SetPos(ppos); pe->SetDim(ddim); - nch = (int)((ddim.x*640.0f-22.0f)/8.0f); + nch = static_cast< int >((ddim.x*640.0f-22.0f)/8.0f); pe->GetText(name, 100); pe->SetMaxChar(nch); name[nch] = 0; // truncates the text according to max @@ -1236,7 +1268,7 @@ void CStudio::AdjustDialog() ppos.y = wpos.y+5.0f/480.0f; ddim.x = 50.0f/640.0f; ddim.y = 16.0f/480.0f; - pla = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL3); + pla = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL3)); if ( pla != 0 ) { pla->SetPos(ppos); @@ -1246,7 +1278,7 @@ void CStudio::AdjustDialog() ppos.x += 50.0f/640.0f; ppos.y = wpos.y+12.0f/480.0f; ddim.x = 70.0f/640.0f; - pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK1); + pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK1)); if ( pc != 0 ) { pc->SetPos(ppos); @@ -1254,7 +1286,7 @@ void CStudio::AdjustDialog() } ppos.x += 80.0f/640.0f; - pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK2); + pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK2)); if ( pc != 0 ) { pc->SetPos(ppos); @@ -1265,7 +1297,7 @@ void CStudio::AdjustDialog() ppos.y = wpos.y+34.0f/480.0f; ddim.x = 90.0f/640.0f; ddim.y = 23.0f/480.0f; - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_DIALOG_OK)); if ( pb != 0 ) { pb->SetPos(ppos); @@ -1273,7 +1305,7 @@ void CStudio::AdjustDialog() } ppos.y -= 26.0f/480.0f; - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_DIALOG_CANCEL)); if ( pb != 0 ) { pb->SetPos(ppos); @@ -1289,7 +1321,7 @@ bool CStudio::EventDialog(const Event &event) CWindow* pw; Math::Point wpos, wdim; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return false; if ( event.type == EVENT_WINDOW9 ) // window is moved? @@ -1328,7 +1360,7 @@ bool CStudio::EventDialog(const Event &event) } if ( event.type == EVENT_DIALOG_OK || - (event.type == EVENT_KEYDOWN && event.param == VK_RETURN) ) + (event.type == EVENT_KEY_DOWN && event.param == KEY(RETURN)) ) { if ( m_dialog == SD_OPEN ) { @@ -1344,7 +1376,7 @@ bool CStudio::EventDialog(const Event &event) } if ( event.type == EVENT_DIALOG_CANCEL || - (event.type == EVENT_KEYDOWN && event.param == VK_ESCAPE) || + (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) || event.type == pw->GetEventTypeClose() ) { StopDialog(); @@ -1364,11 +1396,11 @@ void CStudio::UpdateChangeList() char name[100]; char* p; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; - pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST); + pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST)); if ( pl == 0 ) return; - pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT); + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); if ( pe == nullptr ) return; strcpy(name, pl->GetName(pl->GetSelect())); @@ -1389,9 +1421,9 @@ void CStudio::UpdateChangeEdit() CWindow* pw; CList* pl; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; - pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST); + pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST)); if ( pl == 0 ) return; pl->SetSelect(-1); @@ -1410,12 +1442,12 @@ void CStudio::UpdateDialogAction() int len, i; bool bError; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; - pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT); + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); if ( pe == nullptr ) return; - pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK); - if ( pb == 0 ) return; + pb = static_cast< CButton* >(pw->SearchControl(EVENT_DIALOG_OK)); + if ( pb == nullptr ) return; pe->GetText(name, 100); len = strlen(name); @@ -1454,22 +1486,22 @@ void CStudio::UpdateDialogPublic() char dir[MAX_FNAME]; char text[MAX_FNAME+100]; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return; - pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK1); + pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK1)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, !m_main->GetIOPublic()); } - pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK2); + pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK2)); if ( pc != 0 ) { pc->SetState(STATE_CHECK, m_main->GetIOPublic()); } - pl = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL1); + pl = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL1)); if ( pl != 0 ) { GetResource(RES_TEXT, RT_IO_LIST, name); @@ -1494,9 +1526,9 @@ void CStudio::UpdateDialogList() char temp[MAX_FNAME]; int nbFilenames, i; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9); if ( pw == nullptr ) return; - pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST); + pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST); if ( pl == 0 ) return; pl->Flush(); @@ -1558,8 +1590,8 @@ void CStudio::SearchDirectory(char *dir, bool bCreate) } if ( bCreate ) - { - _mkdir(dir); // if does not exist yet! + {// TODO +// mkdir(dir,0777); // if does not exist yet! } } @@ -1573,10 +1605,10 @@ bool CStudio::ReadProgram() char dir[100]; char* p; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return false; - pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT); + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); if ( pe == nullptr ) return false; pe->GetText(filename, 100); if ( filename[0] == 0 ) return false; @@ -1589,9 +1621,9 @@ bool CStudio::ReadProgram() SearchDirectory(dir, true); strcat(dir, filename); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw == nullptr ) return false; - pe = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( pe == nullptr ) return false; if ( !pe->ReadText(dir) ) return false; @@ -1611,10 +1643,10 @@ bool CStudio::WriteProgram() char dir[100]; char* p; - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9)); if ( pw == nullptr ) return false; - pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT); + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT)); if ( pe == nullptr ) return false; pe->GetText(filename, 100); if ( filename[0] == 0 ) return false; @@ -1627,9 +1659,9 @@ bool CStudio::WriteProgram() SearchDirectory(dir, true); strcat(dir, filename); - pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3); + pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw == nullptr ) return false; - pe = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT); + pe = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( pe == nullptr ) return false; if ( !pe->WriteText(dir) ) return false; diff --git a/src/ui/studio.h b/src/ui/studio.h index 8b7355c..905baa6 100644 --- a/src/ui/studio.h +++ b/src/ui/studio.h @@ -18,47 +18,29 @@ // studio.h #pragma once +#include "common/event.h" -#include <string> - -#include <object/object.h> - -#include <script/script.h> - -#include <graphics/engine/engine.h> -#include <graphics/engine/camera.h> +#include "graphics/engine/camera.h" -#include <common/event.h> -#include <common/misc.h> -#include <common/iman.h> -#include <sound/sound.h> - -#include <ui/control.h> -#include <ui/button.h> -#include <ui/color.h> -#include <ui/check.h> -#include <ui/key.h> -#include <ui/group.h> -#include <ui/image.h> -#include <ui/label.h> -#include <ui/edit.h> -#include <ui/editvalue.h> -#include <ui/scroll.h> -#include <ui/slider.h> -#include <ui/list.h> -#include <ui/shortcut.h> -#include <ui/compass.h> -#include <ui/target.h> -#include <ui/map.h> -#include <ui/window.h> -#include <ui/interface.h> +#include <string> -#include <app/app.h> +class CEventQueue; +class CInstanceManager; +class CRobotMain; +class CScript; +class CSoundInterface; +namespace Gfx { +class CEngine; +class CCamera; +}; namespace Ui { +class CEdit; +class CInterface; + enum StudioDialog { SD_NULL, @@ -100,7 +82,7 @@ class CStudio void UpdateDialogAction(); void UpdateDialogPublic(); void UpdateDialogList(); - void SearchDirectory(std::string dir, bool bCreate); + void SearchDirectory(char* dir, bool bCreate); bool ReadProgram(); bool WriteProgram(); |