Skip to content

Commit

Permalink
Merge pull request #47 from Nickito12/master
Browse files Browse the repository at this point in the history
Mouse wheel music wheel and online chat scrolling
  • Loading branch information
MinaciousGrace authored Jan 29, 2017
2 parents 19fdf65 + a8eb1f7 commit 8333509
Show file tree
Hide file tree
Showing 11 changed files with 568 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ t[#t+1] = LoadFont("Common Large")..{
InitCommand=cmd(xy,5,32;halign,0;valign,1;zoom,0.55;diffuse,getMainColor('positive');settext,"Select Music:");
}
t[#t+1] = LoadActor("../_cursor")
t[#t+1] = LoadActor("../_mousewheelscroll")
t[#t+1] = LoadActor("../_halppls")
t[#t+1] = LoadActor("currenttime")

return t
return t
58 changes: 56 additions & 2 deletions Themes/Til Death/BGAnimations/_chatbox.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
local t = Def.ActorFrame{}

local top
local whee

local border = 5

Expand Down Expand Up @@ -30,6 +32,58 @@ local outputHeight = THEME:GetMetric("ScreenNetSelectBase","ChatOutputLines")*9.

end

local function isOverChatbox()
if INPUTFILTER:GetMouseX() > outputX-border and INPUTFILTER:GetMouseX() < outputX + outputWidth+border*2 and INPUTFILTER:GetMouseY() > outputY-border and INPUTFILTER:GetMouseY() < outputY + outputHeight+border*2 then
return true
end
return false
end


local function scrollInput(event)
if event.DeviceInput.button == "DeviceButton_tab" then
if event.type == "InputEventType_FirstPress" then
local pressingtab = true
elseif event.type == "InputEventType_Release" then
local pressingtab = false
end
elseif event.DeviceInput.button == "DeviceButton_mousewheel up" and event.type == "InputEventType_FirstPress" then
if isOverChatbox() then
top:ScrollChatUp()
else
moving = true
if pressingtab == true then
whee:Move(-2)
else
whee:Move(-1)
end
end
elseif event.DeviceInput.button == "DeviceButton_mousewheel down" and event.type == "InputEventType_FirstPress" then
if isOverChatbox() then
top:ScrollChatDown()
else
moving = true
if pressingtab == true then
whee:Move(2)
else
whee:Move(1)
end
end
elseif moving == true then
whee:Move(0)
moving = false
end
end


local t = Def.ActorFrame{
BeginCommand=function(self)
top = SCREENMAN:GetTopScreen()
whee = top:GetMusicWheel()
top:AddInputCallback(scrollInput)
end,
}

t[#t+1] = Def.Quad{
InitCommand=cmd(xy,inputX-border,inputY-border;zoomto,outputWidth+border*2,inputHeight+border*2;halign,0;valign,0;diffuse,color("#00000099");),
TabChangedMessageCommand=function(self)
Expand All @@ -53,4 +107,4 @@ t[#t+1] = Def.Quad{
end,
}

return t
return t
40 changes: 40 additions & 0 deletions Themes/Til Death/BGAnimations/_mousewheelscroll.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

local moving = false
local whee
local pressingtab = false

local function scrollInput(event)
if event.DeviceInput.button == "DeviceButton_tab" then
if event.type == "InputEventType_FirstPress" then
pressingtab = true
elseif event.type == "InputEventType_Release" then
pressingtab = false
end
elseif event.DeviceInput.button == "DeviceButton_mousewheel up" and event.type == "InputEventType_FirstPress" 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
moving = true
if pressingtab == true then
whee:Move(2)
else
whee:Move(1)
end
elseif moving == true then
whee:Move(0)
moving = false
end
end

local t = Def.ActorFrame{
BeginCommand=function(self)
whee = SCREENMAN:GetTopScreen():GetMusicWheel()
SCREENMAN:GetTopScreen():AddInputCallback(scrollInput)
self:visible(false)
end,
}
return t
112 changes: 112 additions & 0 deletions Themes/Til Death/_chatbox.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@

local top
local whee

local border = 5

local inputX = THEME:GetMetric("ScreenNetSelectBase","ChatInputX")
local inputY = THEME:GetMetric("ScreenNetSelectBase","ChatInputY")
local inputWidth = THEME:GetMetric("ScreenNetSelectBase","ChatTextInputWidth")*0.4
local inputHeight = 25


local outputX = THEME:GetMetric("ScreenNetSelectBase","ChatOutputX")
local outputY = THEME:GetMetric("ScreenNetSelectBase","ChatOutputY")
local outputWidth = THEME:GetMetric("ScreenNetSelectBase","ChatTextOutputWidth")*0.3153
local outputHeight = THEME:GetMetric("ScreenNetSelectBase","ChatOutputLines")*9.25

if IsUsingWideScreen() == true then

local border = 5

local inputX = THEME:GetMetric("ScreenNetSelectBase","ChatInputX")
local inputY = THEME:GetMetric("ScreenNetSelectBase","ChatInputY")
local inputWidth = THEME:GetMetric("ScreenNetSelectBase","ChatTextInputWidth")*0.4
local inputHeight = 25


local outputX = THEME:GetMetric("ScreenNetSelectBase","ChatOutputX")
local outputY = THEME:GetMetric("ScreenNetSelectBase","ChatOutputY")
local outputWidth = THEME:GetMetric("ScreenNetSelectBase","ChatTextOutputWidth")*0.3153
local outputHeight = THEME:GetMetric("ScreenNetSelectBase","ChatOutputLines")*9.25

end

local function isOverChatbox()
if INPUTFILTER:GetMouseX() > outputX-border and INPUTFILTER:GetMouseX() < outputX + outputWidth+border*2 and INPUTFILTER:GetMouseY() > outputY-border and INPUTFILTER:GetMouseY() < outputY + outputHeight+border*2 then
return true
end
return false
end


local function scrollInput(event)
if event.DeviceInput.button == "DeviceButton_tab" then
if event.type == "InputEventType_FirstPress" then
local pressingtab = true
elseif event.type == "InputEventType_Repeat" then
pressingtab = true
elseif event.type == "InputEventType_Release" then
local pressingtab = false
end
elseif event.DeviceInput.button == "DeviceButton_mousewheel up" and event.type == "InputEventType_FirstPress" then
if isOverChatbox() then
top:ScrollChatUp()
else
moving = true
if pressingtab == true then
whee:Move(-2)
else
whee:Move(-1)
end
end
elseif event.DeviceInput.button == "DeviceButton_mousewheel down" and event.type == "InputEventType_FirstPress" then
if isOverChatbox() then
top:ScrollChatDown()
else
moving = true
if pressingtab == true then
whee:Move(2)
else
whee:Move(1)
end
end
elseif moving == true then
whee:Move(0)
moving = false
end
end


local t = Def.ActorFrame{
BeginCommand=function(self)
top = SCREENMAN:GetTopScreen()
whee = top:GetMusicWheel()
top:AddInputCallback(scrollInput)
end,
}

t[#t+1] = Def.Quad{
InitCommand=cmd(xy,inputX-border,inputY-border;zoomto,outputWidth+border*2,inputHeight+border*2;halign,0;valign,0;diffuse,color("#00000099");),
TabChangedMessageCommand=function(self)
local top= SCREENMAN:GetTopScreen()
if getTabIndex() == 0 then
self:visible(true)
else
self:visible(false)
end
end,
}
t[#t+1] = Def.Quad{
InitCommand=cmd(xy,outputX-border,outputY-border;zoomto,outputWidth+border*2,outputHeight+border*2;halign,0;valign,0;diffuse,color("#00000099");),
TabChangedMessageCommand=function(self)
local top= SCREENMAN:GetTopScreen()
if getTabIndex() == 0 then
self:visible(true)
else
self:visible(false)
end
end,
}

return t
10 changes: 10 additions & 0 deletions src/MusicWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,15 @@ class LunaMusicWheel : public Luna<MusicWheel>
p->ReloadSongList(true, SArg(1));
return 1;
}
static int Move(T* p, lua_State *L)
{
if (lua_isnil(L, 1)) { p->Move(0); }
else
{
p->Move(IArg(1));
}
return 1;
}

LunaMusicWheel()
{
Expand All @@ -1886,6 +1895,7 @@ class LunaMusicWheel : public Luna<MusicWheel>
ADD_METHOD( SelectSong );
ADD_METHOD( SelectCourse );
ADD_METHOD( SongSearch );
ADD_METHOD( Move );
}
};

Expand Down
27 changes: 27 additions & 0 deletions src/RoomWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,33 @@ unsigned int RoomWheel::GetNumItems() const
return m_CurWheelItemData.size() - m_offset;
}


// lua start
#include "LuaBinding.h"

class LunaRoomWheel : public Luna<RoomWheel>
{
public:
static int Move(T* p, lua_State *L)
{
if (lua_isnil(L, 1)) { p->Move(0); }
else
{
p->Move(IArg(1));
}
return 1;
}

LunaRoomWheel()
{
ADD_METHOD(Move);
}
};

LUA_REGISTER_DERIVED_CLASS(RoomWheel, WheelBase)
// lua end


/*
* (c) 2004 Josh Allen
* All rights reserved.
Expand Down
3 changes: 3 additions & 0 deletions src/RoomWheel.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class RoomWheel : public WheelBase
int GetPerminateOffset() const { return m_offset; }
void AddItem( WheelItemBaseData *itemdata );
void RemoveItem( int index );

// Lua
void PushSelf(lua_State *L);

private:
virtual WheelItemBase *MakeItem();
Expand Down
25 changes: 25 additions & 0 deletions src/ScreenNetRoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ bool ScreenNetRoom::Input( const InputEventPlus &input )
return ScreenNetSelectBase::Input( input );
}

RoomWheel* ScreenNetRoom::GetRoomWheel()
{
return &m_RoomWheel;
}

void ScreenNetRoom::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_GoToPrevScreen )
Expand Down Expand Up @@ -314,6 +319,26 @@ void ScreenNetRoom::CreateNewRoom( const RString& rName, const RString& rDesc,

#endif

// lua start
#include "LuaBinding.h"

/** @brief Allow Lua to have access to the PlayerState. */
class LunaScreenNetRoom : public Luna<ScreenNetRoom>
{
public:
static int GetMusicWheel(T* p, lua_State *L) {
p->GetRoomWheel()->PushSelf(L);
return 1;
}
LunaScreenNetRoom()
{
ADD_METHOD(GetMusicWheel);
}
};

LUA_REGISTER_DERIVED_CLASS(ScreenNetRoom, ScreenNetSelectBase)
// lua end

/*
* (c) 2004 Charles Lohr, Josh Allen
* (c) 2001-2004 Chris Danford
Expand Down
4 changes: 4 additions & 0 deletions src/ScreenNetRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class ScreenNetRoom : public ScreenNetSelectBase
virtual void Init();
virtual bool Input( const InputEventPlus &input );
virtual void HandleScreenMessage( const ScreenMessage SM );
RoomWheel* GetRoomWheel();

// Lua
void PushSelf(lua_State *L);

protected:
virtual bool MenuStart( const InputEventPlus &input );
Expand Down
Loading

0 comments on commit 8333509

Please sign in to comment.