Added code battle start button; fixed bug with starting code battle

master
krzys-h 2015-09-06 19:12:00 +02:00
parent cf72693b25
commit 51330dde5e
7 changed files with 75 additions and 16 deletions

2
data

@ -1 +1 @@
Subproject commit 305cad6f4361e612aed130ea59294240ddb9dcff
Subproject commit 256cbfc75da33250b331177b9d4e8d220e4fe17b

View File

@ -129,16 +129,16 @@ enum EventType
EVENT_EDIT8 = 78,
EVENT_EDIT9 = 79,
EVENT_WINDOW0 = 80, // the bottom panel
EVENT_WINDOW1 = 81, // map
EVENT_WINDOW2 = 82, // CDisplayText
EVENT_WINDOW3 = 83, // CStudio
EVENT_WINDOW4 = 84, // DisplayInfo
EVENT_WINDOW5 = 85, // setup
EVENT_WINDOW6 = 86,
EVENT_WINDOW7 = 87,
EVENT_WINDOW8 = 88,
EVENT_WINDOW9 = 89, // dialogue
EVENT_WINDOW0 = 80, //!< object interface (CObjectInterface + CAuto classes)
EVENT_WINDOW1 = 81, //!< CMainMap
EVENT_WINDOW2 = 82, //!< CDisplayText
EVENT_WINDOW3 = 83, //!< CStudio
EVENT_WINDOW4 = 84, //!< CDisplayInfo
EVENT_WINDOW5 = 85, //!< all menu windows
EVENT_WINDOW6 = 86, //!< code battle interface
EVENT_WINDOW7 = 87, //!< (unused)
EVENT_WINDOW8 = 88, //!< (unused)
EVENT_WINDOW9 = 89, //!< CMainDialog and CStudio file selector
EVENT_LABEL0 = 90,
EVENT_LABEL1 = 91,
@ -531,6 +531,8 @@ enum EventType
EVENT_WRITE_SCENE_FINISHED = 2100, //!< indicates end of writing scene (writing screenshot image)
EVENT_CODE_BATTLE_START = 2200, //!< button that starts the code battle
//! Maximum value of standard events
EVENT_STD_MAX,

View File

@ -678,6 +678,20 @@ bool CRobotMain::ProcessEvent(Event &event)
return false;
}
if (event.type == EVENT_UPDINTERFACE)
{
if (m_missionType == MISSION_CODE_BATTLE && !m_codeBattleStarted)
{
CreateCodeBattleInterface();
}
}
if (event.type == EVENT_CODE_BATTLE_START)
{
m_pause->DeactivatePause(m_userPause);
m_userPause = nullptr;
}
// Management of the console.
if (event.type == EVENT_KEY_DOWN &&
event.GetData<KeyEventData>()->key == KEY(BACKQUOTE)) // Pause ?
@ -2609,9 +2623,10 @@ bool CRobotMain::EventFrame(const Event &event)
m_codeBattleInit = true; // Will start on resume
}
if (!m_codeBattleStarted && m_userPause != nullptr)
if (!m_codeBattleStarted && m_userPause == nullptr)
{
m_codeBattleStarted = true;
DestroyCodeBattleInterface();
m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE));
}
}
@ -3730,6 +3745,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_eventQueue->AddEvent(Event(EVENT_QUIT));
m_ui->ShowLoadingScreen(false);
if (m_missionType == MISSION_CODE_BATTLE)
{
CreateCodeBattleInterface();
}
CreateShortcuts();
}
@ -5932,3 +5951,32 @@ void CRobotMain::StartDetectEffect(COldObject* object, CObject* target)
m_sound->Play(target != nullptr ? SOUND_BUILD : SOUND_RECOVER);
}
void CRobotMain::CreateCodeBattleInterface()
{
Math::Point pos, ddim;
ddim.x = 100.0f/640.0f;
ddim.y = 100.0f/480.0f;
pos.x = 540.0f/640.0f;
pos.y = 100.0f/480.0f;
Ui::CWindow* pw = m_interface->CreateWindows(pos, ddim, 3, EVENT_WINDOW6);
ddim.x = 100.0f/640.0f;
ddim.y = 16.0f/480.0f;
pos.x = 540.0f/640.0f;
pos.y = 178.0f/480.0f;
pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, "Code battle");
float titleBarSize = (11.0f/64.0f); // this is from the texture
ddim.x = 80.0f/640.0f;
ddim.y = ((1-titleBarSize)*100.0f-20.0f)/480.0f;
pos.x = 550.0f/640.0f;
pos.y = 110.0f/480.0f;
pw->CreateButton(pos, ddim, 21, EVENT_CODE_BATTLE_START);
}
void CRobotMain::DestroyCodeBattleInterface()
{
m_interface->DeleteControl(EVENT_WINDOW6);
}

View File

@ -416,6 +416,9 @@ protected:
void PushToSelectionHistory(CObject* obj);
CObject* PopFromSelectionHistory();
void CreateCodeBattleInterface();
void DestroyCodeBattleInterface();
protected:
CController* m_ctrl = nullptr;

View File

@ -367,6 +367,9 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
m_infoCamera = m_camera->GetType();
m_camera->SetType(Gfx::CAM_TYPE_INFO);
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6));
if (pw != nullptr) pw->ClearState(STATE_VISIBLE);
pos = m_infoActualPos = m_infoFinalPos;
dim = m_infoActualDim = m_infoFinalDim;
pw = m_interface->CreateWindows(pos, dim, 4, EVENT_WINDOW4);
@ -829,6 +832,9 @@ void CDisplayInfo::StopDisplayInfo()
else
{
m_main->SetEditLock(false, false);
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6));
if (pw != nullptr) pw->SetState(STATE_VISIBLE);
}
m_pause->DeactivatePause(m_satcomPause);
m_satcomPause = nullptr;

View File

@ -369,7 +369,7 @@ void CMainDialog::StartDialog(Math::Point dim, bool fireParticles)
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6));
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
if ( pw != nullptr ) pw->ClearState(STATE_VISIBLE);
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW7));
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
@ -524,7 +524,7 @@ void CMainDialog::StopDialog()
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6));
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
if ( pw != nullptr ) pw->SetState(STATE_VISIBLE);
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW7));
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);

View File

@ -1104,7 +1104,7 @@ void CStudio::StartDialog(StudioDialog type)
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW6));
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
if ( pw != nullptr ) pw->ClearState(STATE_VISIBLE);
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW7));
if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
@ -1219,7 +1219,7 @@ void CStudio::StopDialog()
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW6));
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
if ( pw != nullptr ) pw->SetState(STATE_VISIBLE);
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW7));
if ( pw != nullptr ) pw->SetState(STATE_ENABLE);