Skip to content

Commit

Permalink
ignore enter in neteval, add get/select current player binds
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Dec 1, 2018
1 parent 5d1ac8b commit 3471e61
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
25 changes: 25 additions & 0 deletions src/ScreenNetEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "Style.h"
#include "ThemeManager.h"
#include "NetworkSyncManager.h"
#include "InputEventPlus.h"

static const int NUM_SCORE_DIGITS = 9;

Expand Down Expand Up @@ -132,6 +133,17 @@ ScreenNetEvaluation::MenuDown(const InputEventPlus& input)
return true;
}

bool
ScreenNetEvaluation::Input(const InputEventPlus& input)
{
// throw out "enter" inputs so players don't accidentally close the screen
// while talking about scores, force them to esc to the next screen -mina
if (input.DeviceI.button == KEY_ENTER)
return false;

return Screen::Input(input);
}

void
ScreenNetEvaluation::HandleScreenMessage(const ScreenMessage SM)
{
Expand Down Expand Up @@ -282,11 +294,24 @@ class LunaScreenNetEvaluation : public Luna<ScreenNetEvaluation>
lua_pushnil(L);
return 1;
}
static int GetCurrentPlayer(T* p, lua_State* L)
{
lua_pushnumber(L, p->m_iCurrentPlayer + 1);
return 1;
}
static int SelectPlayer(T* p, lua_State* L)
{
p->m_iCurrentPlayer = IArg(1) - 1;
p->UpdateStats();
return 0;
}
LunaScreenNetEvaluation()
{
ADD_METHOD(GetNumActivePlayers);
ADD_METHOD(GetHighScore);
ADD_METHOD(GetOptions);
ADD_METHOD(GetCurrentPlayer);
ADD_METHOD(SelectPlayer);
}
};

Expand Down
7 changes: 2 additions & 5 deletions src/ScreenNetEvaluation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ class ScreenNetEvaluation : public ScreenEvaluation

// sm-ssc:
int GetNumActivePlayers() { return m_iActivePlayers; }

bool Input(const InputEventPlus& input) override;
// Lua
void PushSelf(lua_State* L) override;

int m_iCurrentPlayer;

void UpdateStats();
protected:
bool MenuLeft(const InputEventPlus& input) override;
bool MenuUp(const InputEventPlus& input) override;
bool MenuRight(const InputEventPlus& input) override;
bool MenuDown(const InputEventPlus& input) override;
void HandleScreenMessage(ScreenMessage SM) override;
void TweenOffScreen() override;

void UpdateStats();

private:
// todo: Make this an AutoActor -aj
Quad m_rectUsersBG;
Expand Down

0 comments on commit 3471e61

Please sign in to comment.