Skip to content

Commit

Permalink
Replaced SDL_Scancode back to int
Browse files Browse the repository at this point in the history
xrGame/key_binding_registrator_script.cpp: reformat
xrGame/xr_level_controller.cpp: reformat
  • Loading branch information
Xottab-DUTY committed Jul 24, 2018
1 parent ede90c5 commit 569772d
Show file tree
Hide file tree
Showing 75 changed files with 536 additions and 294 deletions.
2 changes: 1 addition & 1 deletion src/xrEngine/IInputReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void IInputReceiver::IR_OnDeactivate(void)
int i;
for (i = 0; i < CInput::COUNT_KB_BUTTONS; i++)
if (IR_GetKeyState(i))
IR_OnKeyboardRelease((SDL_Scancode)i);
IR_OnKeyboardRelease(i);

for (i = 0; i < CInput::COUNT_MOUSE_BUTTONS; i++)
if (IR_GetBtnState(i))
Expand Down
4 changes: 2 additions & 2 deletions src/xrEngine/edit_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ void callback_base::on_key_press(line_edit_control* const control)

// -------------------------------------------------------------------------------------------------

type_pair::type_pair(SDL_Scancode dik, char c, char c_shift, bool b_translate) { init(dik, c, c_shift, b_translate); }
type_pair::type_pair(int dik, char c, char c_shift, bool b_translate) { init(dik, c, c_shift, b_translate); }
type_pair::~type_pair() {}
void type_pair::init(SDL_Scancode dik, char c, char c_shift, bool b_translate)
void type_pair::init(int dik, char c, char c_shift, bool b_translate)
{
m_translate = b_translate;
m_dik = dik;
Expand Down
6 changes: 3 additions & 3 deletions src/xrEngine/edit_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ class callback_base : public base
class type_pair : public base
{
public:
type_pair(SDL_Scancode dik, char c, char c_shift, bool b_translate);
type_pair(int dik, char c, char c_shift, bool b_translate);
virtual ~type_pair();
void init(SDL_Scancode dik, char c, char c_shift, bool b_translate);
void init(int dik, char c, char c_shift, bool b_translate);
virtual void on_key_press(line_edit_control* const control);

private:
SDL_Scancode m_dik;
int m_dik;
bool m_translate;
char m_char;
char m_char_shift;
Expand Down
12 changes: 6 additions & 6 deletions src/xrEngine/line_edit_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void line_edit_control::assign_char_pairs(init_mode mode)
create_char_pair(SDL_SCANCODE_Z, 'z', 'Z', true);
}

void line_edit_control::create_key_state(SDL_Scancode const dik, key_state state)
void line_edit_control::create_key_state(int const dik, key_state state)
{
Base* prev = m_actions[dik];
// if ( m_actions[dik] )
Expand All @@ -369,7 +369,7 @@ void line_edit_control::create_key_state(SDL_Scancode const dik, key_state state
m_actions[dik] = new text_editor::key_state_base(state, prev);
}

void line_edit_control::create_char_pair(SDL_Scancode const dik, char c, char c_shift, bool translate)
void line_edit_control::create_char_pair(int const dik, char c, char c_shift, bool translate)
{
if (m_actions[dik])
{
Expand All @@ -379,7 +379,7 @@ void line_edit_control::create_char_pair(SDL_Scancode const dik, char c, char c_
m_actions[dik] = new text_editor::type_pair(dik, c, c_shift, translate);
}

void line_edit_control::assign_callback(SDL_Scancode const dik, key_state state, Callback const& callback)
void line_edit_control::assign_callback(int const dik, key_state state, Callback const& callback)
{
VERIFY(dik < SDL_NUM_SCANCODES);
Base* prev_action = m_actions[dik];
Expand All @@ -405,7 +405,7 @@ void line_edit_control::set_edit(pcstr str)

// ========================================================

void line_edit_control::on_key_press(SDL_Scancode dik)
void line_edit_control::on_key_press(int dik)
{
if (SDL_NUM_SCANCODES <= dik)
{
Expand Down Expand Up @@ -451,7 +451,7 @@ void line_edit_control::on_key_press(SDL_Scancode dik)

// -------------------------------------------------------------------------------------------------

void line_edit_control::on_key_hold(SDL_Scancode dik)
void line_edit_control::on_key_hold(int dik)
{
update_key_states();
update_bufs();
Expand All @@ -478,7 +478,7 @@ void line_edit_control::on_key_hold(SDL_Scancode dik)
}
}

void line_edit_control::on_key_release(SDL_Scancode dik)
void line_edit_control::on_key_release(int dik)
{
m_accel = 1.0f;
m_rep_time = 0.0f;
Expand Down
12 changes: 6 additions & 6 deletions src/xrEngine/line_edit_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class ENGINE_API line_edit_control
~line_edit_control();

void clear_states();
void on_key_press(SDL_Scancode dik);
void on_key_hold(SDL_Scancode dik);
void on_key_release(SDL_Scancode dik);
void on_key_press(int dik);
void on_key_hold(int dik);
void on_key_release(int dik);
void on_frame();

void assign_callback(SDL_Scancode const dik, key_state state, Callback const& callback);
void assign_callback(int const dik, key_state state, Callback const& callback);

void insert_character(char c);

Expand Down Expand Up @@ -106,8 +106,8 @@ class ENGINE_API line_edit_control
void xr_stdcall SwitchKL();

void assign_char_pairs(init_mode mode);
void create_key_state(SDL_Scancode const dik, key_state state);
void create_char_pair(SDL_Scancode const dik, char c, char c_shift, bool translate = false);
void create_key_state(int const dik, key_state state);
void create_char_pair(int const dik, char c, char c_shift, bool translate = false);

void clear_inserted();
bool empty_inserted();
Expand Down
6 changes: 3 additions & 3 deletions src/xrEngine/line_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace text_editor
line_editor::line_editor(u32 str_buffer_size) : m_control(str_buffer_size) {}
line_editor::~line_editor() {}
void line_editor::on_frame() { m_control.on_frame(); }
void line_editor::IR_OnKeyboardPress(int dik) {m_control.on_key_press((SDL_Scancode)dik); }
void line_editor::IR_OnKeyboardHold(int dik) {m_control.on_key_hold((SDL_Scancode)dik); }
void line_editor::IR_OnKeyboardRelease(int dik) {m_control.on_key_release((SDL_Scancode)dik); }
void line_editor::IR_OnKeyboardPress(int dik) {m_control.on_key_press(dik); }
void line_editor::IR_OnKeyboardHold(int dik) {m_control.on_key_hold(dik); }
void line_editor::IR_OnKeyboardRelease(int dik) {m_control.on_key_release(dik); }
} // namespace text_editor
24 changes: 12 additions & 12 deletions src/xrGame/Level_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void CLevel::IR_OnKeyboardPress(int key)

bool b_ui_exist = !!CurrentGameUI();

EGameActions _curr = get_binded_action((SDL_Scancode) key);
EGameActions _curr = get_binded_action(key);

#ifdef INPUT_CALLBACKS
/* avo: script callback */
Expand Down Expand Up @@ -167,7 +167,7 @@ void CLevel::IR_OnKeyboardPress(int key)
{
if (b_ui_exist && CurrentGameUI()->TopInputReceiver())
{
if (CurrentGameUI()->IR_UIOnKeyboardPress((SDL_Scancode) key))
if (CurrentGameUI()->IR_UIOnKeyboardPress(key))
return; // special case for mp and main_menu
CurrentGameUI()->TopInputReceiver()->HideDialog();
}
Expand All @@ -183,7 +183,7 @@ void CLevel::IR_OnKeyboardPress(int key)
if (!bReady || !b_ui_exist)
return;

if (b_ui_exist && CurrentGameUI()->IR_UIOnKeyboardPress((SDL_Scancode) key))
if (b_ui_exist && CurrentGameUI()->IR_UIOnKeyboardPress(key))
return;

if (Device.Paused() && !IsDemoPlay()
Expand All @@ -193,7 +193,7 @@ void CLevel::IR_OnKeyboardPress(int key)
)
return;

if (game && game->OnKeyboardPress(get_binded_action((SDL_Scancode) key)))
if (game && game->OnKeyboardPress(get_binded_action(key)))
return;

if (_curr == kQUICK_SAVE && IsGameTypeSingle())
Expand Down Expand Up @@ -475,14 +475,14 @@ void CLevel::IR_OnKeyboardPress(int key)
}
#endif // MASTER_GOLD

if (bindConsoleCmds.execute((SDL_Scancode)key))
if (bindConsoleCmds.execute(key))
return;

if (CURRENT_ENTITY())
{
IInputReceiver* IR = smart_cast<IInputReceiver*>(smart_cast<CGameObject*>(CURRENT_ENTITY()));
if (IR)
IR->IR_OnKeyboardPress(get_binded_action((SDL_Scancode)key));
IR->IR_OnKeyboardPress(get_binded_action(key));
}

#ifdef _DEBUG
Expand All @@ -508,9 +508,9 @@ void CLevel::IR_OnKeyboardRelease(int key)
/* avo: end */
#endif

if (CurrentGameUI() && CurrentGameUI()->IR_UIOnKeyboardRelease((SDL_Scancode) key))
if (CurrentGameUI() && CurrentGameUI()->IR_UIOnKeyboardRelease(key))
return;
if (game && game->OnKeyboardRelease(get_binded_action((SDL_Scancode)key)))
if (game && game->OnKeyboardRelease(get_binded_action(key)))
return;
if (Device.Paused()
#ifdef DEBUG
Expand All @@ -523,7 +523,7 @@ void CLevel::IR_OnKeyboardRelease(int key)
{
IInputReceiver* IR = smart_cast<IInputReceiver*>(smart_cast<CGameObject*>(CURRENT_ENTITY()));
if (IR)
IR->IR_OnKeyboardRelease(get_binded_action((SDL_Scancode)key));
IR->IR_OnKeyboardRelease(get_binded_action(key));
}
}

Expand Down Expand Up @@ -568,7 +568,7 @@ void CLevel::IR_OnKeyboardHold(int key)

#endif // DEBUG

if (CurrentGameUI() && CurrentGameUI()->IR_UIOnKeyboardHold((SDL_Scancode)key))
if (CurrentGameUI() && CurrentGameUI()->IR_UIOnKeyboardHold(key))
return;
if (Device.Paused() && !Level().IsDemoPlay()
#ifdef DEBUG
Expand All @@ -580,7 +580,7 @@ void CLevel::IR_OnKeyboardHold(int key)
{
IInputReceiver* IR = smart_cast<IInputReceiver*>(smart_cast<CGameObject*>(CURRENT_ENTITY()));
if (IR)
IR->IR_OnKeyboardHold(get_binded_action((SDL_Scancode)key));
IR->IR_OnKeyboardHold(get_binded_action(key));
}
}

Expand All @@ -594,7 +594,7 @@ void CLevel::IR_OnActivate()
{
if (IR_GetKeyState(i))
{
EGameActions action = get_binded_action((SDL_Scancode) i);
EGameActions action = get_binded_action(i);
switch (action)
{
case kFWD:
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void CMainMenu::IR_OnKeyboardPress(int dik)
if (!IsActive())
return;

if (is_binded(kCONSOLE, (SDL_Scancode)dik))
if (is_binded(kCONSOLE, dik))
{
Console->Show();
return;
Expand All @@ -349,23 +349,23 @@ void CMainMenu::IR_OnKeyboardPress(int dik)
return;
}

CDialogHolder::IR_UIOnKeyboardPress((SDL_Scancode)dik);
CDialogHolder::IR_UIOnKeyboardPress(dik);
};

void CMainMenu::IR_OnKeyboardRelease(int dik)
{
if (!IsActive())
return;

CDialogHolder::IR_UIOnKeyboardRelease((SDL_Scancode)dik);
CDialogHolder::IR_UIOnKeyboardRelease(dik);
};

void CMainMenu::IR_OnKeyboardHold(int dik)
{
if (!IsActive())
return;

CDialogHolder::IR_UIOnKeyboardHold((SDL_Scancode)dik);
CDialogHolder::IR_UIOnKeyboardHold(dik);
};

void CMainMenu::IR_OnMouseWheel(int x, int y)
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/UIDialogHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void CDialogHolder::CleanInternals()
GetUICursor().Hide();
}

bool CDialogHolder::IR_UIOnKeyboardPress(SDL_Scancode dik)
bool CDialogHolder::IR_UIOnKeyboardPress(int dik)
{
CUIDialogWnd* TIR = TopInputReceiver();
if (!TIR)
Expand Down Expand Up @@ -279,7 +279,7 @@ bool CDialogHolder::IR_UIOnKeyboardPress(SDL_Scancode dik)
return true;
}

bool CDialogHolder::IR_UIOnKeyboardRelease(SDL_Scancode dik)
bool CDialogHolder::IR_UIOnKeyboardRelease(int dik)
{
CUIDialogWnd* TIR = TopInputReceiver();
if (!TIR)
Expand Down Expand Up @@ -314,7 +314,7 @@ bool CDialogHolder::IR_UIOnKeyboardRelease(SDL_Scancode dik)
return true;
}

bool CDialogHolder::IR_UIOnKeyboardHold(SDL_Scancode dik)
bool CDialogHolder::IR_UIOnKeyboardHold(int dik)
{
CUIDialogWnd* TIR = TopInputReceiver();
if (!TIR)
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/UIDialogHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class CDialogHolder : public pureFrame
virtual void StartDialog(CUIDialogWnd* pDialog, bool bDoHideIndicators);
virtual void StopDialog(CUIDialogWnd* pDialog);
virtual bool IgnorePause() { return false; }
virtual bool IR_UIOnKeyboardPress(SDL_Scancode dik);
virtual bool IR_UIOnKeyboardRelease(SDL_Scancode dik);
virtual bool IR_UIOnKeyboardPress(int dik);
virtual bool IR_UIOnKeyboardRelease(int dik);
virtual bool IR_UIOnMouseMove(int dx, int dy);
virtual bool IR_UIOnMouseWheel(int x, int y);
virtual bool IR_UIOnKeyboardHold(SDL_Scancode dik);
virtual bool IR_UIOnKeyboardHold(int dik);
};
4 changes: 2 additions & 2 deletions src/xrGame/UIGameCTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ void CUIGameCTA::SetVoteTimeResultMsg(LPCSTR str)
m_voteStatusWnd->SetVoteTimeResultMsg(str);
}

bool CUIGameCTA::IR_UIOnKeyboardPress(SDL_Scancode dik)
bool CUIGameCTA::IR_UIOnKeyboardPress(int dik)
{
if (inherited::IR_UIOnKeyboardPress(dik))
return true;
Expand Down Expand Up @@ -813,7 +813,7 @@ bool CUIGameCTA::IR_UIOnKeyboardPress(SDL_Scancode dik)
return false;
}

bool CUIGameCTA::IR_UIOnKeyboardRelease(SDL_Scancode dik)
bool CUIGameCTA::IR_UIOnKeyboardRelease(int dik)
{
if (inherited::IR_UIOnKeyboardRelease(dik))
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/UIGameCTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class CUIGameCTA : public UIGameMP
virtual void OnFrame();
virtual void Render();

virtual bool IR_UIOnKeyboardPress(SDL_Scancode dik);
virtual bool IR_UIOnKeyboardRelease(SDL_Scancode dik);
virtual bool IR_UIOnKeyboardPress(int dik);
virtual bool IR_UIOnKeyboardRelease(int dik);

bool IsTeamPanelsShown();
void ShowTeamPanels(bool bShow);
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/UIGameMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void UIGameMP::ShowDemoPlayControl()
GetUICursor().SetUICursorPosition(m_pDemoPlayControl->GetLastCursorPos());
}

bool UIGameMP::IR_UIOnKeyboardPress(SDL_Scancode dik)
bool UIGameMP::IR_UIOnKeyboardPress(int dik)
{
if (is_binded(kCROUCH, dik) && Level().IsDemoPlay())
{
Expand All @@ -41,7 +41,7 @@ bool UIGameMP::IR_UIOnKeyboardPress(SDL_Scancode dik)
return inherited::IR_UIOnKeyboardPress(dik);
}

bool UIGameMP::IR_UIOnKeyboardRelease(SDL_Scancode dik) { return inherited::IR_UIOnKeyboardRelease(dik); }
bool UIGameMP::IR_UIOnKeyboardRelease(int dik) { return inherited::IR_UIOnKeyboardRelease(dik); }
/*
bool UIGameMP::IsMapDescShown()
{
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/UIGameMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class UIGameMP : public CUIGameCustom
bool IsServerInfoShown();
bool ShowServerInfo(); // shows only if it has some info ...

virtual bool IR_UIOnKeyboardPress(SDL_Scancode dik);
virtual bool IR_UIOnKeyboardRelease(SDL_Scancode dik);
virtual bool IR_UIOnKeyboardPress(int dik);
virtual bool IR_UIOnKeyboardRelease(int dik);
virtual void SetClGame(game_cl_GameState* g);

protected:
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/UIGameSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void CUIGameSP::OnFrame()
}
}

bool CUIGameSP::IR_UIOnKeyboardPress(SDL_Scancode dik)
bool CUIGameSP::IR_UIOnKeyboardPress(int dik)
{
if (inherited::IR_UIOnKeyboardPress(dik))
return true;
Expand Down Expand Up @@ -275,7 +275,7 @@ void CChangeLevelWnd::OnCancel()
Actor()->MoveActor(m_position_cancel, m_angles_cancel);
}

bool CChangeLevelWnd::OnKeyboardAction(SDL_Scancode dik, EUIMessages keyboard_action)
bool CChangeLevelWnd::OnKeyboardAction(int dik, EUIMessages keyboard_action)
{
if (keyboard_action == WINDOW_KEY_PRESSED)
{
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/UIGameSP.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CUIGameSP : public CUIGameCustom
virtual ~CUIGameSP();

virtual void SetClGame(game_cl_GameState* g);
virtual bool IR_UIOnKeyboardPress(SDL_Scancode dik);
virtual bool IR_UIOnKeyboardPress(int dik);
virtual void OnFrame();

void StartTalk(bool disable_break);
Expand Down Expand Up @@ -69,5 +69,5 @@ class CChangeLevelWnd : public CUIDialogWnd
virtual bool WorkInPause() const { return true; }
virtual void Show(bool status);
virtual void Hide();
virtual bool OnKeyboardAction(SDL_Scancode dik, EUIMessages keyboard_action);
virtual bool OnKeyboardAction(int dik, EUIMessages keyboard_action);
};
Loading

0 comments on commit 569772d

Please sign in to comment.