Skip to content

Commit

Permalink
Fix online prev msg crashes. Fix mouse wheel movement when song was a…
Browse files Browse the repository at this point in the history
…lready started
  • Loading branch information
nico-abram committed Feb 5, 2017
1 parent d06ef27 commit 17eb440
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
8 changes: 5 additions & 3 deletions Themes/Til Death/BGAnimations/_mousewheelscroll.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
local moving = false
local whee
local pressingtab = false
local top

local function scrollInput(event)
if event.DeviceInput.button == "DeviceButton_tab" then
Expand All @@ -10,14 +11,14 @@ local function scrollInput(event)
elseif event.type == "InputEventType_Release" then
pressingtab = false
end
elseif event.DeviceInput.button == "DeviceButton_mousewheel up" and event.type == "InputEventType_FirstPress" then
elseif event.DeviceInput.button == "DeviceButton_mousewheel up" and event.type == "InputEventType_FirstPress" and top:GetSelectionState() ~= 2 then
moving = true
if pressingtab == true then
whee:Move(-2)
else
whee:Move(-1)
end
elseif event.DeviceInput.button == "DeviceButton_mousewheel down" and event.type == "InputEventType_FirstPress" then
elseif event.DeviceInput.button == "DeviceButton_mousewheel down" and event.type == "InputEventType_FirstPress" and top:GetSelectionState() ~= 2 then
moving = true
if pressingtab == true then
whee:Move(2)
Expand All @@ -33,7 +34,8 @@ end
local t = Def.ActorFrame{
BeginCommand=function(self)
whee = SCREENMAN:GetTopScreen():GetMusicWheel()
SCREENMAN:GetTopScreen():AddInputCallback(scrollInput)
top = SCREENMAN:GetTopScreen()
top:AddInputCallback(scrollInput)
self:visible(false)
end,
}
Expand Down
21 changes: 16 additions & 5 deletions src/ScreenNetSelectBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ RString ScreenNetSelectBase::GetPreviousMsg()
if (m_sTextLastestInputsIndex <= m_sTextLastestInputs.size() && m_sTextLastestInputsIndex > 0)
return m_sTextLastestInputs[m_sTextLastestInputs.size() - m_sTextLastestInputsIndex];
m_sTextLastestInputsIndex = m_sTextLastestInputs.size();
return m_sTextLastestInputs[m_sTextLastestInputs.size() - m_sTextLastestInputsIndex];
return m_sTextLastestInputsIndex == 0 ? "" : m_sTextLastestInputs[m_sTextLastestInputs.size() - m_sTextLastestInputsIndex];
}

RString ScreenNetSelectBase::GetNextMsg()
{
m_sTextLastestInputsIndex -= 1;
if (m_sTextLastestInputsIndex < m_sTextLastestInputs.size() && m_sTextLastestInputsIndex > 0)
if (m_sTextLastestInputsIndex <= m_sTextLastestInputs.size() && m_sTextLastestInputsIndex > 0)
return m_sTextLastestInputs[m_sTextLastestInputs.size() - m_sTextLastestInputsIndex];
m_sTextLastestInputsIndex = 0;
return "";
Expand Down Expand Up @@ -724,17 +724,20 @@ class LunaScreenNetSelectBase : public Luna<ScreenNetSelectBase>
{
static int ChatboxInput(T* p, lua_State *L)
{
p->enableChatboxInput = BArg(1);
if (!lua_isnil(L, 1))
p->enableChatboxInput = BArg(1);
return 1;
}
static int UsersVisible(T* p, lua_State *L)
{
p->SetUsersVisible(BArg(1));
if (!lua_isnil(L, 1))
p->SetUsersVisible(BArg(1));
return 1;
}
static int ChatboxVisible(T* p, lua_State *L)
{
p->SetChatboxVisible(BArg(1));
if (!lua_isnil(L, 1))
p->SetChatboxVisible(BArg(1));
return 1;
}
static int GetUserQty(T* p, lua_State *L)
Expand All @@ -744,6 +747,8 @@ class LunaScreenNetSelectBase : public Luna<ScreenNetSelectBase>
}
static int GetUser(T* p, lua_State *L)
{
if (lua_isnil(L, 1))
return 0;
if (IArg(1) <= p->ToUsers()->size() && IArg(1) >= 1)
lua_pushstring(L, (*(p->ToUsers()))[IArg(1) - 1].GetText());
else
Expand All @@ -752,6 +757,8 @@ class LunaScreenNetSelectBase : public Luna<ScreenNetSelectBase>
}
static int GetUserState(T* p, lua_State *L)
{
if (lua_isnil(L, 1))
return 0;
if (IArg(1) <= p->ToUsers()->size() && IArg(1) >= 1)
lua_pushnumber(L, NSMAN->m_PlayerStatus[NSMAN->m_ActivePlayer[IArg(1) - 1]]);
else
Expand All @@ -765,6 +772,8 @@ class LunaScreenNetSelectBase : public Luna<ScreenNetSelectBase>
}
static int GetFriendName(T* p, lua_State *L)
{
if (lua_isnil(L, 1))
return 0;
if (IArg(1) <= NSMAN->fl_PlayerNames.size() && IArg(1) >= 1)
lua_pushstring(L, (NSMAN->fl_PlayerNames[IArg(1) - 1]).c_str());
else
Expand All @@ -773,6 +782,8 @@ class LunaScreenNetSelectBase : public Luna<ScreenNetSelectBase>
}
static int GetFriendState(T* p, lua_State *L)
{
if (lua_isnil(L, 1))
return 0;
if (IArg(1) <= NSMAN->fl_PlayerStates.size() && IArg(1) >= 1)
lua_pushnumber(L, NSMAN->fl_PlayerStates[IArg(1) - 1]);
else
Expand Down
10 changes: 10 additions & 0 deletions src/ScreenSelectMusic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,11 @@ bool ScreenSelectMusic::can_open_options_list(PlayerNumber pn)
return true;
}

int ScreenSelectMusic::GetSelectionState()
{
return static_cast<int>(m_SelectionState);
}


// lua start
#include "LuaBinding.h"
Expand Down Expand Up @@ -2102,13 +2107,18 @@ class LunaScreenSelectMusic: public Luna<ScreenSelectMusic>
return 1;
}

static int GetSelectionState(T* p, lua_State *L) {
lua_pushnumber(L, p->GetSelectionState());
return 1;
}
LunaScreenSelectMusic()
{
ADD_METHOD( GetGoToOptions );
ADD_METHOD( GetMusicWheel );
ADD_METHOD( OpenOptionsList );
ADD_METHOD( CanOpenOptionsList );
ADD_METHOD( SelectCurrent );
ADD_METHOD( GetSelectionState );
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/ScreenSelectMusic.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class ScreenSelectMusic : public ScreenWithMenuElements

bool can_open_options_list(PlayerNumber pn);

int GetSelectionState();

// Lua
virtual void PushSelf( lua_State *L );

Expand Down

0 comments on commit 17eb440

Please sign in to comment.