summaryrefslogtreecommitdiffstats
path: root/src/ui/studio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/studio.cpp')
-rw-r--r--src/ui/studio.cpp196
1 files changed, 82 insertions, 114 deletions
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index cba19d6..928e129 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
@@ -17,58 +18,24 @@
// studio.cpp
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <windows.h>
-#include <direct.h>
-#include <io.h>
-#include <time.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "common/language.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/iman.h"
-#include "common/restext.h"
-#include "old/math3d.h"
-#include "object/robotmain.h"
-#include "object/object.h"
-#include "old/camera.h"
-#include "old/sound.h"
-#include "script/script.h"
-#include "ui/interface.h"
-#include "ui/button.h"
-#include "ui/check.h"
-#include "ui/slider.h"
-#include "ui/edit.h"
-#include "ui/list.h"
-#include "ui/label.h"
-#include "ui/group.h"
-#include "ui/window.h"
-#include "old/text.h"
-#include "script/cbottoken.h"
-#include "ui/studio.h"
-
+#include <ui/studio.h>
+namespace Ui {
// Object's constructor.
-CStudio::CStudio(CInstanceManager* iMan)
+CStudio::CStudio()
{
- m_iMan = iMan;
+ m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_STUDIO, this);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
+ m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_camera = static_cast<CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
m_bEditMaximized = false;
m_bEditMinimized = false;
@@ -103,7 +70,7 @@ bool CStudio::EventProcess(const Event &event)
return EventDialog(event);
}
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
EventFrame(event);
}
@@ -114,74 +81,74 @@ bool CStudio::EventProcess(const Event &event)
edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
if ( edit == 0 ) return false;
- if ( event.event == pw->RetEventMsgClose() )
+ if ( event.type == pw->GetEventTypeClose() )
{
Event newEvent = event;
newEvent.event = EVENT_STUDIO_OK;
m_event->AddEvent(newEvent);
}
- if ( event.event == EVENT_STUDIO_EDIT ) // text modifief?
+ if ( event.type == EVENT_STUDIO_EDIT ) // text modifief?
{
ColorizeScript(edit);
}
- if ( event.event == EVENT_STUDIO_LIST ) // list clicked?
+ if ( event.type == EVENT_STUDIO_LIST ) // list clicked?
{
m_main->StartDisplayInfo(m_helpFilename, -1);
}
- if ( event.event == EVENT_STUDIO_NEW ) // new?
+ if ( event.type == EVENT_STUDIO_NEW ) // new?
{
m_script->New(edit, "");
}
- if ( event.event == EVENT_STUDIO_OPEN ) // open?
+ if ( event.type == EVENT_STUDIO_OPEN ) // open?
{
StartDialog(SD_OPEN);
}
- if ( event.event == EVENT_STUDIO_SAVE ) // save?
+ if ( event.type == EVENT_STUDIO_SAVE ) // save?
{
StartDialog(SD_SAVE);
}
- if ( event.event == EVENT_STUDIO_UNDO ) // undo?
+ if ( event.type == EVENT_STUDIO_UNDO ) // undo?
{
edit->Undo();
}
- if ( event.event == EVENT_STUDIO_CUT ) // cut?
+ if ( event.type == EVENT_STUDIO_CUT ) // cut?
{
edit->Cut();
}
- if ( event.event == EVENT_STUDIO_COPY ) // copy?
+ if ( event.type == EVENT_STUDIO_COPY ) // copy?
{
edit->Copy();
}
- if ( event.event == EVENT_STUDIO_PASTE ) // paste?
+ if ( event.type == EVENT_STUDIO_PASTE ) // paste?
{
edit->Paste();
}
- if ( event.event == EVENT_STUDIO_SIZE ) // size?
+ if ( event.type == EVENT_STUDIO_SIZE ) // size?
{
slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE);
if ( slider == 0 ) return false;
- m_main->SetFontSize(9.0f+slider->RetVisibleValue()*6.0f);
+ m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f);
ViewEditScript();
}
- if ( event.event == EVENT_STUDIO_TOOL && // instructions?
+ if ( event.type == EVENT_STUDIO_TOOL && // instructions?
m_dialog == SD_NULL )
{
m_main->StartDisplayInfo(SATCOM_HUSTON, false);
}
- if ( event.event == EVENT_STUDIO_HELP && // help?
+ if ( event.type == EVENT_STUDIO_HELP && // help?
m_dialog == SD_NULL )
{
m_main->StartDisplayInfo(SATCOM_PROG, false);
}
- if ( event.event == EVENT_STUDIO_COMPILE ) // compile?
+ if ( event.type == EVENT_STUDIO_COMPILE ) // compile?
{
char buffer[100];
@@ -197,7 +164,7 @@ bool CStudio::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_STUDIO_RUN ) // run/stop?
+ if ( event.type == EVENT_STUDIO_RUN ) // run/stop?
{
if ( m_script->IsRunning() )
{
@@ -224,7 +191,7 @@ bool CStudio::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_STUDIO_REALTIME ) // real time?
+ if ( event.type == EVENT_STUDIO_REALTIME ) // real time?
{
m_bRealTime = !m_bRealTime;
m_script->SetStepMode(!m_bRealTime);
@@ -232,15 +199,15 @@ bool CStudio::EventProcess(const Event &event)
UpdateButtons();
}
- if ( event.event == EVENT_STUDIO_STEP ) // step?
+ if ( event.type == EVENT_STUDIO_STEP ) // step?
{
m_script->Step(event);
}
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEYDOWN )
{
- if ( event.param == m_engine->RetKey(KEYRANK_CBOT, 0) ||
- event.param == m_engine->RetKey(KEYRANK_CBOT, 1) )
+ if ( event.param == m_engine->GetKey(KEYRANK_CBOT, 0) ||
+ event.param == m_engine->GetKey(KEYRANK_CBOT, 1) )
{
if ( m_helpFilename[0] != 0 )
{
@@ -249,20 +216,20 @@ bool CStudio::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_WINDOW3 ) // window is moved?
+ if ( event.type == EVENT_WINDOW3 ) // window is moved?
{
- m_editActualPos = m_editFinalPos = pw->RetPos();
- m_editActualDim = m_editFinalDim = pw->RetDim();
+ m_editActualPos = m_editFinalPos = pw->GetPos();
+ m_editActualDim = m_editFinalDim = pw->GetDim();
m_main->SetWindowPos(m_editActualPos);
m_main->SetWindowDim(m_editActualDim);
AdjustEditScript();
}
- if ( event.event == pw->RetEventMsgReduce() )
+ if ( event.type == pw->GetEventTypeReduce() )
{
if ( m_bEditMinimized )
{
- m_editFinalPos = m_main->RetWindowPos();
- m_editFinalDim = m_main->RetWindowDim();
+ m_editFinalPos = m_main->GetWindowPos();
+ m_editFinalDim = m_main->GetWindowDim();
m_bEditMinimized = false;
m_bEditMaximized = false;
}
@@ -283,12 +250,12 @@ bool CStudio::EventProcess(const Event &event)
pw->SetMinimized(m_bEditMinimized);
}
}
- if ( event.event == pw->RetEventMsgFull() )
+ if ( event.type == pw->GetEventTypeFull() )
{
if ( m_bEditMaximized )
{
- m_editFinalPos = m_main->RetWindowPos();
- m_editFinalDim = m_main->RetWindowDim();
+ m_editFinalPos = m_main->GetWindowPos();
+ m_editFinalDim = m_main->GetWindowDim();
m_bEditMinimized = false;
m_bEditMaximized = false;
}
@@ -435,8 +402,8 @@ void CStudio::SearchToken(CEdit* edit)
char* text;
char token[100];
- text = edit->RetText();
- len = edit->RetTextLength();
+ text = edit->GetText();
+ len = edit->GetTextLength();
edit->GetCursor(cursor1, cursor2);
i = cursor1;
@@ -499,18 +466,18 @@ void CStudio::SearchToken(CEdit* edit)
}
token[i] = 0;
- strcpy(m_helpFilename, RetHelpFilename(token));
+ strcpy(m_helpFilename, GetHelpFilename(token));
if ( m_helpFilename[0] == 0 )
{
for ( i=0 ; i<OBJECT_MAX ; i++ )
{
type = (ObjectType)i;
- text = RetObjectName(type);
+ text = GetObjectName(type);
if ( text[0] != 0 )
{
if ( strcmp(token, text) == 0 )
{
- strcpy(m_helpFilename, RetHelpFilename(type));
+ strcpy(m_helpFilename, GetHelpFilename(type));
SetInfoText(token, true);
return;
}
@@ -520,7 +487,7 @@ void CStudio::SearchToken(CEdit* edit)
{
if ( strcmp(token, text) == 0 )
{
- strcpy(m_helpFilename, RetHelpFilename(type));
+ strcpy(m_helpFilename, GetHelpFilename(type));
SetInfoText(token, true);
return;
}
@@ -564,9 +531,9 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
m_main->SetEditLock(true, true);
m_main->SetEditFull(false);
- m_bInitPause = m_engine->RetPause();
+ m_bInitPause = m_engine->GetPause();
m_main->SetSpeed(1.0f);
- m_editCamera = m_camera->RetType();
+ m_editCamera = m_camera->GetType();
m_camera->SetType(CAMERA_EDIT);
m_bRunning = m_script->IsRunning();
@@ -579,8 +546,8 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
button->ClearState(STATE_VISIBLE);
}
- pos = m_editFinalPos = m_editActualPos = m_main->RetWindowPos();
- dim = m_editFinalDim = m_editActualDim = m_main->RetWindowDim();
+ pos = m_editFinalPos = m_editActualPos = m_main->GetWindowPos();
+ dim = m_editFinalDim = m_editActualDim = m_main->GetWindowDim();
pw = m_interface->CreateWindows(pos, dim, 8, EVENT_WINDOW3);
if ( pw == 0 ) return;
pw->SetState(STATE_SHADOW);
@@ -603,7 +570,7 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
edit->SetFontType(FONT_COURIER);
edit->SetFontStretch(0.7f);
edit->SetDisplaySpec(true);
- edit->SetAutoIndent(m_engine->RetEditIndentMode());
+ edit->SetAutoIndent(m_engine->GetEditIndentMode());
m_script->PutScript(edit, name);
ColorizeScript(edit);
@@ -632,7 +599,7 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
button->SetState(STATE_SHADOW);
slider = pw->CreateSlider(pos, dim, 0, EVENT_STUDIO_SIZE);
slider->SetState(STATE_SHADOW);
- slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f);
+ slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
pw->CreateGroup(pos, dim, 19, EVENT_LABEL1); // SatCom logo
button = pw->CreateButton(pos, dim, 128+57, EVENT_STUDIO_TOOL);
button->SetState(STATE_SHADOW);
@@ -678,7 +645,7 @@ void CStudio::AdjustEditScript()
{
pw->SetPos(wpos);
pw->SetDim(wdim);
- wdim = pw->RetDim();
+ wdim = pw->GetDim();
}
if ( m_bRunning ) hList = 80.0f/480.0f;
@@ -938,8 +905,8 @@ void CStudio::ViewEditScript()
edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
if ( edit == 0 ) return;
- dim = m_engine->RetDim();
- edit->SetFontSize(m_main->RetFontSize()/(dim.x/640.0f));
+ dim = m_engine->GetDim();
+ edit->SetFontSize(m_main->GetFontSize()/(dim.x/640.0f));
}
@@ -1063,8 +1030,8 @@ void CStudio::StartDialog(StudioDialog type)
if ( m_dialog == SD_OPEN ||
m_dialog == SD_SAVE )
{
- pos = m_main->RetIOPos();
- dim = m_main->RetIODim();
+ pos = m_main->GetIOPos();
+ dim = m_main->GetIODim();
}
//? pw = m_interface->CreateWindows(pos, dim, 8, EVENT_WINDOW9);
pw = m_interface->CreateWindows(pos, dim, m_dialog==SD_OPEN?14:13, EVENT_WINDOW9);
@@ -1097,7 +1064,7 @@ void CStudio::StartDialog(StudioDialog type)
pe->SetState(STATE_SHADOW);
if ( m_dialog == SD_SAVE )
{
- pe->SetText(m_script->RetFilename());
+ pe->SetText(m_script->GetFilename());
}
GetResource(RES_TEXT, RT_IO_DIR, name);
@@ -1200,8 +1167,8 @@ void CStudio::AdjustDialog()
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return;
- wpos = pw->RetPos();
- wdim = pw->RetDim();
+ wpos = pw->GetPos();
+ wdim = pw->GetDim();
pw->SetPos(wpos); // to move the buttons on the titlebar
if ( m_dialog == SD_OPEN ||
@@ -1318,10 +1285,10 @@ bool CStudio::EventDialog(const Event &event)
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return false;
- if ( event.event == EVENT_WINDOW9 ) // window is moved?
+ if ( event.type == EVENT_WINDOW9 ) // window is moved?
{
- wpos = pw->RetPos();
- wdim = pw->RetDim();
+ wpos = pw->GetPos();
+ wdim = pw->GetDim();
m_main->SetIOPos(wpos);
m_main->SetIODim(wdim);
AdjustDialog();
@@ -1330,22 +1297,22 @@ bool CStudio::EventDialog(const Event &event)
if ( m_dialog == SD_OPEN ||
m_dialog == SD_SAVE )
{
- if ( event.event == EVENT_DIALOG_LIST )
+ if ( event.type == EVENT_DIALOG_LIST )
{
UpdateChangeList();
}
- if ( event.event == EVENT_DIALOG_EDIT )
+ if ( event.type == EVENT_DIALOG_EDIT )
{
UpdateChangeEdit();
}
- if ( event.event == EVENT_DIALOG_CHECK1 ) // private?
+ if ( event.type == EVENT_DIALOG_CHECK1 ) // private?
{
m_main->SetIOPublic(false);
UpdateDialogPublic();
UpdateDialogList();
}
- if ( event.event == EVENT_DIALOG_CHECK2 ) // public?
+ if ( event.type == EVENT_DIALOG_CHECK2 ) // public?
{
m_main->SetIOPublic(true);
UpdateDialogPublic();
@@ -1353,8 +1320,8 @@ bool CStudio::EventDialog(const Event &event)
}
}
- if ( event.event == EVENT_DIALOG_OK ||
- (event.event == EVENT_KEYDOWN && event.param == VK_RETURN) )
+ if ( event.type == EVENT_DIALOG_OK ||
+ (event.type == EVENT_KEYDOWN && event.param == VK_RETURN) )
{
if ( m_dialog == SD_OPEN )
{
@@ -1369,9 +1336,9 @@ bool CStudio::EventDialog(const Event &event)
return true;
}
- if ( event.event == EVENT_DIALOG_CANCEL ||
- (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) ||
- event.event == pw->RetEventMsgClose() )
+ if ( event.type == EVENT_DIALOG_CANCEL ||
+ (event.type == EVENT_KEYDOWN && event.param == VK_ESCAPE) ||
+ event.type == pw->GetEventTypeClose() )
{
StopDialog();
return true;
@@ -1397,8 +1364,8 @@ void CStudio::UpdateChangeList()
pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT);
if ( pe == 0 ) return;
- strcpy(name, pl->RetName(pl->RetSelect()));
- name[pe->RetMaxChar()] = 0; // truncates according lg max editable
+ strcpy(name, pl->GetName(pl->GetSelect()));
+ name[pe->GetMaxChar()] = 0; // truncates according lg max editable
p = strchr(name, '\t'); // seeks first tab
if ( p != 0 ) *p = 0;
pe->SetText(name);
@@ -1486,13 +1453,13 @@ void CStudio::UpdateDialogPublic()
pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK1);
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, !m_main->RetIOPublic());
+ pc->SetState(STATE_CHECK, !m_main->GetIOPublic());
}
pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK2);
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_main->RetIOPublic());
+ pc->SetState(STATE_CHECK, m_main->GetIOPublic());
}
pl = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL1);
@@ -1573,13 +1540,13 @@ void CStudio::UpdateDialogList()
void CStudio::SearchDirectory(char *dir, bool bCreate)
{
- if ( m_main->RetIOPublic() )
+ if ( m_main->GetIOPublic() )
{
- sprintf(dir, "%s\\", m_main->RetPublicDir());
+ sprintf(dir, "%s\\", m_main->GetPublicDir());
}
else
{
- sprintf(dir, "%s\\%s\\Program\\", m_main->RetSavegameDir(), m_main->RetGamerName());
+ sprintf(dir, "%s\\%s\\Program\\", m_main->GetSavegameDir(), m_main->GetGamerName());
}
if ( bCreate )
@@ -1663,3 +1630,4 @@ bool CStudio::WriteProgram()
return true;
}
+}