Fix focusing issues with controls and cheat console
parent
61ea372e51
commit
31bc740f4b
|
@ -711,7 +711,7 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
|
Ui::CEdit* pe = static_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
|
||||||
if (pe == nullptr) return false;
|
if (pe == nullptr) return false;
|
||||||
pe->SetState(Ui::STATE_VISIBLE);
|
pe->SetState(Ui::STATE_VISIBLE);
|
||||||
pe->SetFocus(true);
|
m_interface->SetFocus(pe);
|
||||||
if (m_phase == PHASE_SIMUL) ChangePause(PAUSE_CHEAT);
|
if (m_phase == PHASE_SIMUL) ChangePause(PAUSE_CHEAT);
|
||||||
m_cmdEdit = true;
|
m_cmdEdit = true;
|
||||||
}
|
}
|
||||||
|
@ -732,6 +732,9 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.type == EVENT_KEY_DOWN && m_cmdEdit)
|
||||||
|
return false; // cheat console active, so ignore keys
|
||||||
|
|
||||||
// Management of the speed change.
|
// Management of the speed change.
|
||||||
if (event.type == EVENT_SPEED)
|
if (event.type == EVENT_SPEED)
|
||||||
SetSpeed(1.0f);
|
SetSpeed(1.0f);
|
||||||
|
|
|
@ -109,7 +109,7 @@ void CScript::PutScript(Ui::CEdit* edit, const char* name)
|
||||||
edit->SetCursor(m_cursor2, m_cursor1);
|
edit->SetCursor(m_cursor2, m_cursor1);
|
||||||
edit->ShowSelect();
|
edit->ShowSelect();
|
||||||
}
|
}
|
||||||
edit->SetFocus(true);
|
m_interface->SetFocus(edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The script takes a paved text.
|
// The script takes a paved text.
|
||||||
|
@ -132,7 +132,7 @@ bool CScript::GetScript(Ui::CEdit* edit)
|
||||||
{
|
{
|
||||||
edit->SetCursor(m_cursor2, m_cursor1);
|
edit->SetCursor(m_cursor2, m_cursor1);
|
||||||
edit->ShowSelect();
|
edit->ShowSelect();
|
||||||
edit->SetFocus(true);
|
m_interface->SetFocus(edit);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ bool CScript::GetScript(Ui::CEdit* edit)
|
||||||
{
|
{
|
||||||
edit->SetCursor(m_cursor2, m_cursor1);
|
edit->SetCursor(m_cursor2, m_cursor1);
|
||||||
edit->ShowSelect();
|
edit->ShowSelect();
|
||||||
edit->SetFocus(true);
|
m_interface->SetFocus(edit);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,7 +912,7 @@ void CScript::New(Ui::CEdit* edit, const char* name)
|
||||||
|
|
||||||
edit->SetCursor(cursor2, cursor1);
|
edit->SetCursor(cursor2, cursor1);
|
||||||
edit->ShowSelect();
|
edit->ShowSelect();
|
||||||
edit->SetFocus(true);
|
m_interface->SetFocus(edit);
|
||||||
|
|
||||||
sf = m_main->GetScriptFile();
|
sf = m_main->GetScriptFile();
|
||||||
if ( sf[0] != 0 ) // Load an empty program specific?
|
if ( sf[0] != 0 ) // Load an empty program specific?
|
||||||
|
@ -973,7 +973,7 @@ void CScript::New(Ui::CEdit* edit, const char* name)
|
||||||
cursor2 = cursor1;
|
cursor2 = cursor1;
|
||||||
edit->SetCursor(cursor2, cursor1);
|
edit->SetCursor(cursor2, cursor1);
|
||||||
edit->ShowSelect();
|
edit->ShowSelect();
|
||||||
edit->SetFocus(true);
|
m_interface->SetFocus(edit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -384,7 +384,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
|
||||||
edit->HyperHome(filename.c_str());
|
edit->HyperHome(filename.c_str());
|
||||||
edit->SetEditCap(false); // just to see!
|
edit->SetEditCap(false); // just to see!
|
||||||
edit->SetHighlightCap(false);
|
edit->SetHighlightCap(false);
|
||||||
edit->SetFocus(true);
|
m_interface->SetFocus(edit);
|
||||||
|
|
||||||
ViewDisplayInfo();
|
ViewDisplayInfo();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "ui/edit.h"
|
#include "ui/edit.h"
|
||||||
#include "ui/button.h"
|
#include "ui/button.h"
|
||||||
|
#include "ui/interface.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ CEditValue::CEditValue() : CControl ()
|
||||||
m_stepValue = 0.1f; // 10%
|
m_stepValue = 0.1f; // 10%
|
||||||
m_minValue = 0.0f; // 0%
|
m_minValue = 0.0f; // 0%
|
||||||
m_maxValue = 1.0f; // 100%
|
m_maxValue = 1.0f; // 100%
|
||||||
|
|
||||||
|
m_interface = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object's destructor.
|
// Object's destructor.
|
||||||
|
@ -228,7 +230,7 @@ void CEditValue::HiliteValue(const Event &event)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_edit->SetCursor(pos, 0);
|
m_edit->SetCursor(pos, 0);
|
||||||
m_edit->SetFocus(true);
|
m_interface->SetFocus(m_edit);
|
||||||
|
|
||||||
Event newEvent = event;
|
Event newEvent = event;
|
||||||
newEvent.type = EVENT_FOCUS;
|
newEvent.type = EVENT_FOCUS;
|
||||||
|
@ -370,5 +372,10 @@ float CEditValue::GetMaxValue()
|
||||||
return m_maxValue;
|
return m_maxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CEditValue::SetInterface(CInterface* interface)
|
||||||
|
{
|
||||||
|
m_interface = interface;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,10 +72,13 @@ public:
|
||||||
void SetMaxValue(float value);
|
void SetMaxValue(float value);
|
||||||
float GetMaxValue();
|
float GetMaxValue();
|
||||||
|
|
||||||
|
void SetInterface(Ui::CInterface* interface);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void MoveAdjust();
|
void MoveAdjust();
|
||||||
void HiliteValue(const Event &event);
|
void HiliteValue(const Event &event);
|
||||||
|
|
||||||
|
Ui::CInterface* m_interface;
|
||||||
Ui::CEdit* m_edit;
|
Ui::CEdit* m_edit;
|
||||||
Ui::CButton* m_buttonUp;
|
Ui::CButton* m_buttonUp;
|
||||||
Ui::CButton* m_buttonDown;
|
Ui::CButton* m_buttonDown;
|
||||||
|
|
|
@ -181,7 +181,9 @@ CEdit* CInterface::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventT
|
||||||
|
|
||||||
CEditValue* CInterface::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
|
CEditValue* CInterface::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
|
||||||
{
|
{
|
||||||
return CreateControl<CEditValue>(pos, dim, icon, eventMsg);
|
CEditValue* ev = CreateControl<CEditValue>(pos, dim, icon, eventMsg);
|
||||||
|
ev->SetInterface(this);
|
||||||
|
return ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new lift.
|
// Creates a new lift.
|
||||||
|
@ -332,5 +334,18 @@ void CInterface::Draw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInterface::SetFocus(CControl* control)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < MAXCONTROL; i++)
|
||||||
|
{
|
||||||
|
if (m_table[i] != nullptr)
|
||||||
|
{
|
||||||
|
bool focus = m_table[i] == control;
|
||||||
|
m_table[i]->SetFocus(focus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,8 @@ public:
|
||||||
|
|
||||||
void Draw();
|
void Draw();
|
||||||
|
|
||||||
|
void SetFocus(CControl* control);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int GetNextFreeControl();
|
int GetNextFreeControl();
|
||||||
template <typename T> inline T* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
|
template <typename T> inline T* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
|
||||||
|
|
|
@ -430,7 +430,7 @@ void CMainDialog::ChangePhase(Phase phase)
|
||||||
}
|
}
|
||||||
pe->SetText(name.c_str());
|
pe->SetText(name.c_str());
|
||||||
pe->SetCursor(name.length(), 0);
|
pe->SetCursor(name.length(), 0);
|
||||||
pe->SetFocus(true);
|
m_interface->SetFocus(pe);
|
||||||
|
|
||||||
pos.x = 380.0f/640.0f;
|
pos.x = 380.0f/640.0f;
|
||||||
pos.y = 320.0f/480.0f;
|
pos.y = 320.0f/480.0f;
|
||||||
|
@ -3624,7 +3624,7 @@ void CMainDialog::NameCreate()
|
||||||
m_sound->Play(SOUND_TZOING);
|
m_sound->Play(SOUND_TZOING);
|
||||||
pe->SetText(name);
|
pe->SetText(name);
|
||||||
pe->SetCursor(strlen(name), 0);
|
pe->SetCursor(strlen(name), 0);
|
||||||
pe->SetFocus(true);
|
m_interface->SetFocus(pe);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4011,7 +4011,7 @@ void CMainDialog::IOReadName()
|
||||||
|
|
||||||
pe->SetText(name);
|
pe->SetText(name);
|
||||||
pe->SetCursor(strlen(name), 0);
|
pe->SetCursor(strlen(name), 0);
|
||||||
pe->SetFocus(true);
|
m_interface->SetFocus(pe);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates the list of games recorded on disk.
|
// Updates the list of games recorded on disk.
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ void CStudio::StartDialog(StudioDialog type)
|
||||||
}
|
}
|
||||||
|
|
||||||
pe->SetCursor(999, 0); // selects all
|
pe->SetCursor(999, 0); // selects all
|
||||||
pe->SetFocus(true);
|
m_interface->SetFocus(pe);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_main->SetSatComLock(true); // impossible to use the SatCom
|
m_main->SetSatComLock(true); // impossible to use the SatCom
|
||||||
|
@ -1430,7 +1430,7 @@ void CStudio::UpdateChangeList()
|
||||||
name = name.substr(0, name.find_first_of("\t"));
|
name = name.substr(0, name.find_first_of("\t"));
|
||||||
SetFilenameField(pe, name);
|
SetFilenameField(pe, name);
|
||||||
pe->SetCursor(999, 0); // selects all
|
pe->SetCursor(999, 0); // selects all
|
||||||
pe->SetFocus(true);
|
m_interface->SetFocus(pe);
|
||||||
|
|
||||||
UpdateDialogAction();
|
UpdateDialogAction();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue