Added code battle spectator mode switch

master
krzys-h 2015-09-13 15:59:42 +02:00
parent 389aaaf132
commit 7500ab4988
5 changed files with 39 additions and 8 deletions

2
data

@ -1 +1 @@
Subproject commit 9a3bba50a6e2a556e21728da15a3055c65910615
Subproject commit d6a5cd49165903fdadbe63cd87d0982e8118b8af

View File

@ -501,6 +501,9 @@ void InitializeEventTypeTexts()
EVENT_TYPE_TEXT[EVENT_STUDIO_STEP] = "EVENT_STUDIO_STEP";
EVENT_TYPE_TEXT[EVENT_WRITE_SCENE_FINISHED] = "EVENT_WRITE_SCENE_FINISHED";
EVENT_TYPE_TEXT[EVENT_CODE_BATTLE_START] = "EVENT_CODE_BATTLE_START";
EVENT_TYPE_TEXT[EVENT_CODE_BATTLE_SPECTATOR] = "EVENT_CODE_BATTLE_SPECTATOR";
}
std::string ParseEventType(EventType eventType)

View File

@ -533,6 +533,7 @@ 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
EVENT_CODE_BATTLE_SPECTATOR = 2201, //!< button that controls the code battle spectator camera
//! Maximum value of standard events
EVENT_STD_MAX,

View File

@ -692,6 +692,11 @@ bool CRobotMain::ProcessEvent(Event &event)
m_userPause = nullptr;
}
if (event.type == EVENT_CODE_BATTLE_SPECTATOR)
{
SetCodeBattleSpectatorMode(!m_codeBattleSpectator);
}
// Management of the console.
if (event.type == EVENT_KEY_DOWN &&
event.GetData<KeyEventData>()->key == KEY(BACKQUOTE)) // Pause ?
@ -1820,7 +1825,7 @@ bool CRobotMain::SelectObject(CObject* obj, bool displayError)
if (m_movie->IsExist()) return false;
if (obj != nullptr && !IsSelectable(obj)) return false;
if (m_missionType == MISSION_CODE_BATTLE && m_codeBattleStarted)
if (m_missionType == MISSION_CODE_BATTLE && m_codeBattleStarted && m_codeBattleSpectator)
{
DeselectAll();
@ -2644,12 +2649,9 @@ bool CRobotMain::EventFrame(const Event &event)
if (!m_codeBattleStarted && m_userPause == nullptr)
{
m_codeBattleStarted = true;
DestroyCodeBattleInterface();
CreateCodeBattleInterface();
// Deselect object, but keep camera attached to it
CObject* obj = DeselectAll();
SelectObject(obj, false); // this uses code battle selection mode already
m_camera->SetFixDirectionV(-0.25f*Math::PI);
SetCodeBattleSpectatorMode(true);
m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE));
}
@ -5997,10 +5999,32 @@ void CRobotMain::CreateCodeBattleInterface()
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);
if (!m_codeBattleStarted)
{
pw->CreateButton(pos, ddim, 21, EVENT_CODE_BATTLE_START);
}
else
{
pw->CreateButton(pos, ddim, 13, EVENT_CODE_BATTLE_SPECTATOR);
}
}
void CRobotMain::DestroyCodeBattleInterface()
{
m_interface->DeleteControl(EVENT_WINDOW6);
}
void CRobotMain::SetCodeBattleSpectatorMode(bool mode)
{
// Deselect object, but keep camera attached to it
CObject* obj = DeselectAll();
if (m_codeBattleSpectator)
obj = m_camera->GetControllingObject();
m_codeBattleSpectator = mode;
SelectObject(obj, false); // this uses code battle selection mode already
if (mode)
m_camera->SetFixDirectionV(-0.25f*Math::PI);
}

View File

@ -418,6 +418,7 @@ protected:
void CreateCodeBattleInterface();
void DestroyCodeBattleInterface();
void SetCodeBattleSpectatorMode(bool mode);
protected:
@ -537,6 +538,8 @@ protected:
bool m_codeBattleInit = false;
bool m_codeBattleStarted = false;
//! Code battle spectator mode, hides object UI, changes camera to CAM_TYPE_PLANE and allows for switching to free camera by clicking outside of any object
bool m_codeBattleSpectator = true;
std::map<int, std::string> m_teamNames;