NetRoom/SelectBase/Music lua objects. Scrolling with lua funcs and binded to ctrl+pg up/down. Show prev msgs, binded to pg up/down. Music wheel move, selectmusic screen's select current song, chatbox visibility, input en/disabling and UserList visibility lua functions. (#1394)
This commit is contained in:
@@ -1709,6 +1709,15 @@ public:
|
||||
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()
|
||||
{
|
||||
@@ -1717,6 +1726,7 @@ public:
|
||||
ADD_METHOD( IsRouletting );
|
||||
ADD_METHOD( SelectSong );
|
||||
ADD_METHOD( SelectCourse );
|
||||
ADD_METHOD( Move );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -194,6 +194,32 @@ 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.
|
||||
|
||||
@@ -62,6 +62,9 @@ public:
|
||||
void AddItem( WheelItemBaseData *itemdata );
|
||||
void RemoveItem( int index );
|
||||
|
||||
// Lua
|
||||
void PushSelf(lua_State *L);
|
||||
|
||||
private:
|
||||
virtual WheelItemBase *MakeItem();
|
||||
int m_offset;
|
||||
|
||||
+49
-12
@@ -189,28 +189,40 @@ void ScreenNetRoom::TweenOffScreen()
|
||||
NSMAN->ReportNSSOnOff( 6 );
|
||||
}
|
||||
|
||||
bool ScreenNetRoom::MenuStart( const InputEventPlus &input )
|
||||
bool ScreenNetRoom::MenuStart(const InputEventPlus &input)
|
||||
{
|
||||
SelectCurrent();
|
||||
ScreenNetSelectBase::MenuStart(input);
|
||||
return true;
|
||||
}
|
||||
|
||||
RoomWheel* ScreenNetRoom::GetRoomWheel()
|
||||
{
|
||||
return &m_RoomWheel;
|
||||
}
|
||||
|
||||
void ScreenNetRoom::SelectCurrent()
|
||||
{
|
||||
|
||||
m_RoomWheel.Select();
|
||||
RoomWheelItemData* rwd = dynamic_cast<RoomWheelItemData*>( m_RoomWheel.LastSelected() );
|
||||
if( rwd )
|
||||
RoomWheelItemData* rwd = dynamic_cast<RoomWheelItemData*>(m_RoomWheel.LastSelected());
|
||||
if (rwd)
|
||||
{
|
||||
if ( rwd->m_iFlags % 2 )
|
||||
if (rwd->m_iFlags % 2)
|
||||
{
|
||||
m_sLastPickedRoom = rwd->m_sText;
|
||||
ScreenTextEntry::TextEntry( SM_BackFromReqPass, ENTER_ROOM_REQPASSWORD, "", 255 );
|
||||
}
|
||||
ScreenTextEntry::TextEntry(SM_BackFromReqPass, ENTER_ROOM_REQPASSWORD, "", 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMAN->m_SMOnlinePacket.ClearPacket();
|
||||
NSMAN->m_SMOnlinePacket.Write1( 1 );
|
||||
NSMAN->m_SMOnlinePacket.Write1( 1 ); //Type (enter a room)
|
||||
NSMAN->m_SMOnlinePacket.WriteNT( rwd->m_sText );
|
||||
NSMAN->SendSMOnline( );
|
||||
NSMAN->m_SMOnlinePacket.Write1(1);
|
||||
NSMAN->m_SMOnlinePacket.Write1(1); //Type (enter a room)
|
||||
NSMAN->m_SMOnlinePacket.WriteNT(rwd->m_sText);
|
||||
NSMAN->SendSMOnline();
|
||||
}
|
||||
}
|
||||
ScreenNetSelectBase::MenuStart( input );
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
bool ScreenNetRoom::MenuBack( const InputEventPlus &input )
|
||||
@@ -312,6 +324,31 @@ void ScreenNetRoom::CreateNewRoom( const RString& rName, const RString& rDesc,
|
||||
NSMAN->SendSMOnline( );
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
static int SelectCurrent(T* p, lua_State *L) {
|
||||
p->SelectCurrent();
|
||||
return 1;
|
||||
}
|
||||
LunaScreenNetRoom()
|
||||
{
|
||||
ADD_METHOD(GetMusicWheel);
|
||||
ADD_METHOD(SelectCurrent);
|
||||
}
|
||||
};
|
||||
|
||||
LUA_REGISTER_DERIVED_CLASS(ScreenNetRoom, ScreenNetSelectBase)
|
||||
// lua end
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -33,6 +33,12 @@ public:
|
||||
virtual bool Input( const InputEventPlus &input );
|
||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||
|
||||
RoomWheel* GetRoomWheel();
|
||||
void SelectCurrent();
|
||||
|
||||
// Lua
|
||||
void PushSelf(lua_State *L);
|
||||
|
||||
protected:
|
||||
virtual bool MenuStart( const InputEventPlus &input );
|
||||
virtual bool MenuBack( const InputEventPlus &input );
|
||||
|
||||
+405
-4
@@ -63,6 +63,8 @@ void ScreenNetSelectBase::Init()
|
||||
m_textChatOutput.SetText( NSMAN->m_sChatText );
|
||||
m_textChatOutput.SetMaxLines( SHOW_CHAT_LINES, 1 );
|
||||
|
||||
scroll = 0;
|
||||
|
||||
//Display users list
|
||||
UpdateUsers();
|
||||
|
||||
@@ -84,13 +86,38 @@ bool ScreenNetSelectBase::Input( const InputEventPlus &input )
|
||||
|
||||
switch( input.DeviceI.button )
|
||||
{
|
||||
case KEY_PGUP:
|
||||
if (!bHoldingCtrl) {
|
||||
ShowPreviousMsg();
|
||||
break;
|
||||
}
|
||||
else {
|
||||
Scroll(1);
|
||||
Scroll(1);
|
||||
break;
|
||||
}
|
||||
case KEY_PGDN:
|
||||
if (!bHoldingCtrl) {
|
||||
ShowNextMsg();
|
||||
break;
|
||||
}
|
||||
else {
|
||||
Scroll(-1);
|
||||
Scroll(-1);
|
||||
break;
|
||||
}
|
||||
case KEY_ENTER:
|
||||
case KEY_KP_ENTER:
|
||||
if (!bHoldingCtrl)
|
||||
{
|
||||
if ( m_sTextInput != "" )
|
||||
NSMAN->SendChat( m_sTextInput );
|
||||
m_sTextInput="";
|
||||
if (m_sTextInput != "") {
|
||||
NSMAN->SendChat(m_sTextInput);
|
||||
m_sTextLastestInputs.push_back(m_sTextInput);
|
||||
m_sTextLastestInputsIndex = 0;
|
||||
if (m_sTextLastestInputs.size() > 10)
|
||||
m_sTextLastestInputs.erase(m_sTextLastestInputs.begin());
|
||||
}
|
||||
m_sTextInput = "";
|
||||
UpdateTextInput();
|
||||
return true;
|
||||
}
|
||||
@@ -106,7 +133,9 @@ bool ScreenNetSelectBase::Input( const InputEventPlus &input )
|
||||
|
||||
if( (c >= L' ') && (!bHoldingCtrl) )
|
||||
{
|
||||
m_sTextInput += WStringToRString(wstring()+c);
|
||||
if (!enableChatboxInput)
|
||||
return true;
|
||||
m_sTextInput += WStringToRString(wstring() + c);
|
||||
UpdateTextInput();
|
||||
}
|
||||
|
||||
@@ -197,6 +226,53 @@ void ScreenNetSelectBase::UpdateUsers()
|
||||
|
||||
this->AddChild( &m_textUsers[i] );
|
||||
}
|
||||
if (!usersVisible)
|
||||
for (unsigned i = 0; i < NSMAN->m_ActivePlayer.size(); i++)
|
||||
m_textUsers[i].SetVisible(false);
|
||||
MESSAGEMAN->Broadcast("UsersUpdate");
|
||||
}
|
||||
|
||||
void ScreenNetSelectBase::Scroll(int movescroll)
|
||||
{
|
||||
if (scroll + movescroll >= 0 && scroll + movescroll <= m_textChatOutput.lines - SHOW_CHAT_LINES)
|
||||
scroll += movescroll;
|
||||
m_textChatOutput.ResetText();
|
||||
m_textChatOutput.SetMaxLines(SHOW_CHAT_LINES, 1, scroll);
|
||||
return;
|
||||
}
|
||||
|
||||
RString ScreenNetSelectBase::GetPreviousMsg()
|
||||
{
|
||||
m_sTextLastestInputsIndex += 1;
|
||||
if (m_sTextLastestInputsIndex <= m_sTextLastestInputs.size() && m_sTextLastestInputsIndex > 0)
|
||||
return m_sTextLastestInputs[m_sTextLastestInputs.size() - m_sTextLastestInputsIndex];
|
||||
m_sTextLastestInputsIndex = m_sTextLastestInputs.size();
|
||||
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)
|
||||
return m_sTextLastestInputs[m_sTextLastestInputs.size() - m_sTextLastestInputsIndex];
|
||||
m_sTextLastestInputsIndex = 0;
|
||||
return "";
|
||||
}
|
||||
void ScreenNetSelectBase::ShowPreviousMsg()
|
||||
{
|
||||
SetInputText(GetPreviousMsg());
|
||||
return;
|
||||
}
|
||||
void ScreenNetSelectBase::ShowNextMsg()
|
||||
{
|
||||
SetInputText(GetNextMsg());
|
||||
return;
|
||||
}
|
||||
void ScreenNetSelectBase::SetInputText(RString text)
|
||||
{
|
||||
m_sTextInput = text;
|
||||
UpdateTextInput();
|
||||
return;
|
||||
}
|
||||
|
||||
/** ColorBitmapText ***********************************************************/
|
||||
@@ -324,10 +400,192 @@ void ColorBitmapText::SetText( const RString& _sText, const RString& _sAlternate
|
||||
if( iLineWidth > 0 )
|
||||
SimpleAddLine( sCurrentLine, iLineWidth );
|
||||
|
||||
lines = m_wTextLines.size();
|
||||
|
||||
BuildChars();
|
||||
UpdateBaseZoom();
|
||||
}
|
||||
|
||||
void ColorBitmapText::ResetText()
|
||||
{
|
||||
ASSERT(m_pFont != NULL);
|
||||
|
||||
int iWrapWidthPixels = m_iWrapWidthPixels;
|
||||
|
||||
// Set up the first color.
|
||||
m_vColors.clear();
|
||||
ColorChange change;
|
||||
change.c = RageColor(1, 1, 1, 1);
|
||||
change.l = 0;
|
||||
m_vColors.push_back(change);
|
||||
|
||||
m_wTextLines.clear();
|
||||
|
||||
RString sCurrentLine = "";
|
||||
int iLineWidth = 0;
|
||||
|
||||
RString sCurrentWord = "";
|
||||
int iWordWidth = 0;
|
||||
int iGlyphsSoFar = 0;
|
||||
|
||||
for (unsigned i = 0; i < m_sText.length(); i++)
|
||||
{
|
||||
int iCharsLeft = m_sText.length() - i - 1;
|
||||
|
||||
// First: Check for the special (color) case.
|
||||
|
||||
if (m_sText.length() > 8 && i < m_sText.length() - 9)
|
||||
{
|
||||
RString FirstThree = m_sText.substr(i, 3);
|
||||
if (FirstThree.CompareNoCase("|c0") == 0 && iCharsLeft > 8)
|
||||
{
|
||||
ColorChange cChange;
|
||||
unsigned int r, g, b;
|
||||
sscanf(m_sText.substr(i, 9).c_str(), "|%*c0%2x%2x%2x", &r, &g, &b);
|
||||
cChange.c = RageColor(r / 255.f, g / 255.f, b / 255.f, 1.f);
|
||||
cChange.l = iGlyphsSoFar;
|
||||
if (iGlyphsSoFar == 0)
|
||||
m_vColors[0] = cChange;
|
||||
else
|
||||
m_vColors.push_back(cChange);
|
||||
i += 8;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
int iCharLength = min(utf8_get_char_len(m_sText[i]), iCharsLeft + 1);
|
||||
RString curCharStr = m_sText.substr(i, iCharLength);
|
||||
wchar_t curChar = utf8_get_char(curCharStr);
|
||||
i += iCharLength - 1;
|
||||
int iCharWidth = m_pFont->GetLineWidthInSourcePixels(wstring() + curChar);
|
||||
|
||||
switch (curChar)
|
||||
{
|
||||
case L' ':
|
||||
if ( /* iLineWidth == 0 &&*/ iWordWidth == 0)
|
||||
break;
|
||||
sCurrentLine += sCurrentWord + " ";
|
||||
iLineWidth += iWordWidth + iCharWidth;
|
||||
sCurrentWord = "";
|
||||
iWordWidth = 0;
|
||||
iGlyphsSoFar++;
|
||||
break;
|
||||
case L'\n':
|
||||
if (iLineWidth + iWordWidth > iWrapWidthPixels)
|
||||
{
|
||||
SimpleAddLine(sCurrentLine, iLineWidth);
|
||||
if (iWordWidth > 0)
|
||||
iLineWidth = iWordWidth + //Add the width of a space
|
||||
m_pFont->GetLineWidthInSourcePixels(L" ");
|
||||
sCurrentLine = sCurrentWord + " ";
|
||||
iWordWidth = 0;
|
||||
sCurrentWord = "";
|
||||
iGlyphsSoFar++;
|
||||
}
|
||||
else
|
||||
{
|
||||
SimpleAddLine(sCurrentLine + sCurrentWord, iLineWidth + iWordWidth);
|
||||
sCurrentLine = ""; iLineWidth = 0;
|
||||
sCurrentWord = ""; iWordWidth = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (iWordWidth + iCharWidth > iWrapWidthPixels && iLineWidth == 0)
|
||||
{
|
||||
SimpleAddLine(sCurrentWord, iWordWidth);
|
||||
sCurrentWord = curCharStr; iWordWidth = iCharWidth;
|
||||
}
|
||||
else if (iWordWidth + iLineWidth + iCharWidth > iWrapWidthPixels)
|
||||
{
|
||||
SimpleAddLine(sCurrentLine, iLineWidth);
|
||||
sCurrentLine = "";
|
||||
iLineWidth = 0;
|
||||
sCurrentWord += curCharStr;
|
||||
iWordWidth += iCharWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
sCurrentWord += curCharStr;
|
||||
iWordWidth += iCharWidth;
|
||||
}
|
||||
iGlyphsSoFar++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (iWordWidth > 0)
|
||||
{
|
||||
sCurrentLine += sCurrentWord;
|
||||
iLineWidth += iWordWidth;
|
||||
}
|
||||
|
||||
if (iLineWidth > 0)
|
||||
SimpleAddLine(sCurrentLine, iLineWidth);
|
||||
lines = m_wTextLines.size();
|
||||
BuildChars();
|
||||
UpdateBaseZoom();
|
||||
}
|
||||
|
||||
void ColorBitmapText::SetMaxLines(int iNumLines, int iDirection, unsigned int &scroll)
|
||||
{
|
||||
iNumLines = max(0, iNumLines);
|
||||
iNumLines = min((int)m_wTextLines.size(), iNumLines);
|
||||
if (iDirection == 0)
|
||||
{
|
||||
// Crop all bottom lines
|
||||
m_wTextLines.resize(iNumLines);
|
||||
m_iLineWidths.resize(iNumLines);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Because colors are relative to the beginning, we have to crop them back
|
||||
unsigned shift = 0;
|
||||
if (scroll > m_iLineWidths.size() - iNumLines)
|
||||
scroll = m_iLineWidths.size() - iNumLines;
|
||||
|
||||
for (unsigned i = 0; i < m_wTextLines.size() - iNumLines - scroll; i++)
|
||||
shift += m_wTextLines[i].length();
|
||||
|
||||
// When we're cutting out text, we need to maintain the last
|
||||
// color, so our text at the top doesn't become colorless.
|
||||
RageColor LastColor;
|
||||
|
||||
for (unsigned i = 0; i < m_vColors.size(); i++)
|
||||
{
|
||||
m_vColors[i].l -= shift;
|
||||
if (m_vColors[i].l < 0)
|
||||
{
|
||||
LastColor = m_vColors[i].c;
|
||||
m_vColors.erase(m_vColors.begin() + i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
// If we already have a color set for the first char
|
||||
// do not override it.
|
||||
if (m_vColors.size() > 0 && m_vColors[0].l > 0)
|
||||
{
|
||||
ColorChange tmp;
|
||||
tmp.c = LastColor;
|
||||
tmp.l = 0;
|
||||
m_vColors.insert(m_vColors.begin(), tmp);
|
||||
}
|
||||
|
||||
if (scroll == 0 || m_iLineWidths.size() <= iNumLines || scroll > m_iLineWidths.size() - iNumLines) {
|
||||
m_wTextLines.erase(m_wTextLines.begin(), m_wTextLines.end() - iNumLines);
|
||||
m_iLineWidths.erase(m_iLineWidths.begin(), m_iLineWidths.end() - iNumLines);
|
||||
}
|
||||
else {
|
||||
m_wTextLines.erase(m_wTextLines.begin(), m_wTextLines.end() - iNumLines - scroll);
|
||||
m_iLineWidths.erase(m_iLineWidths.begin(), m_iLineWidths.end() - iNumLines - scroll);
|
||||
|
||||
m_wTextLines.erase(m_wTextLines.end() - scroll, m_wTextLines.end());
|
||||
m_iLineWidths.erase(m_iLineWidths.begin(), m_iLineWidths.end());
|
||||
}
|
||||
}
|
||||
BuildChars();
|
||||
}
|
||||
|
||||
void ColorBitmapText::SimpleAddLine( const RString &sAddition, const int iWidthPixels)
|
||||
{
|
||||
m_wTextLines.push_back( RStringToWstring( sAddition ) );
|
||||
@@ -439,6 +697,149 @@ void ColorBitmapText::SetMaxLines( int iNumLines, int iDirection )
|
||||
}
|
||||
|
||||
|
||||
void ScreenNetSelectBase::SetChatboxVisible(bool visibility)
|
||||
{
|
||||
m_textChatInput.SetVisible(visibility);
|
||||
m_textChatOutput.SetVisible(visibility);
|
||||
return;
|
||||
}
|
||||
void ScreenNetSelectBase::SetUsersVisible(bool visibility)
|
||||
{
|
||||
usersVisible = visibility;
|
||||
for (unsigned int i = 0; i < m_textUsers.size(); i++)
|
||||
m_textUsers[i].SetVisible(visibility);
|
||||
return;
|
||||
}
|
||||
|
||||
vector<BitmapText>* ScreenNetSelectBase::ToUsers()
|
||||
{
|
||||
return &m_textUsers;
|
||||
}
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
/** @brief Allow Lua to have access to the PlayerState. */
|
||||
class LunaScreenNetSelectBase : public Luna<ScreenNetSelectBase>
|
||||
{
|
||||
static int ChatboxInput(T* p, lua_State *L)
|
||||
{
|
||||
if (!lua_isnil(L, 1))
|
||||
p->enableChatboxInput = BArg(1);
|
||||
return 1;
|
||||
}
|
||||
static int UsersVisible(T* p, lua_State *L)
|
||||
{
|
||||
if (!lua_isnil(L, 1))
|
||||
p->SetUsersVisible(BArg(1));
|
||||
return 1;
|
||||
}
|
||||
static int ChatboxVisible(T* p, lua_State *L)
|
||||
{
|
||||
if (!lua_isnil(L, 1))
|
||||
p->SetChatboxVisible(BArg(1));
|
||||
return 1;
|
||||
}
|
||||
static int GetUserQty(T* p, lua_State *L)
|
||||
{
|
||||
lua_pushnumber(L, p->ToUsers()->size());
|
||||
return 1;
|
||||
}
|
||||
static int GetUser(T* p, lua_State *L)
|
||||
{
|
||||
if (IArg(1) <= p->ToUsers()->size() && IArg(1) >= 1)
|
||||
lua_pushstring(L, (*(p->ToUsers()))[IArg(1) - 1].GetText());
|
||||
else
|
||||
lua_pushstring(L, "");
|
||||
return 1;
|
||||
}
|
||||
static int GetUserState(T* p, lua_State *L)
|
||||
{
|
||||
if (IArg(1) <= p->ToUsers()->size() && IArg(1) >= 1)
|
||||
lua_pushnumber(L, NSMAN->m_PlayerStatus[NSMAN->m_ActivePlayer[IArg(1) - 1]]);
|
||||
else
|
||||
lua_pushnumber(L, 0);
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
static int GetFriendQty(T* p, lua_State *L)
|
||||
{
|
||||
lua_pushnumber(L, NSMAN->fl_PlayerNames.size());
|
||||
return 1;
|
||||
}
|
||||
static int GetFriendName(T* p, lua_State *L)
|
||||
{
|
||||
if (IArg(1) <= NSMAN->fl_PlayerNames.size() && IArg(1) >= 1)
|
||||
lua_pushstring(L, (NSMAN->fl_PlayerNames[IArg(1) - 1]).c_str());
|
||||
else
|
||||
lua_pushstring(L, "");
|
||||
return 1;
|
||||
}
|
||||
static int GetFriendState(T* p, lua_State *L)
|
||||
{
|
||||
if (IArg(1) <= NSMAN->fl_PlayerStates.size() && IArg(1) >= 1)
|
||||
lua_pushnumber(L, NSMAN->fl_PlayerStates[IArg(1) - 1]);
|
||||
else
|
||||
lua_pushnumber(L, 0);
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
static int ScrollChatUp(T* p, lua_State *L)
|
||||
{
|
||||
p->Scroll(1);
|
||||
return 1;
|
||||
}
|
||||
static int ScrollChatDown(T* p, lua_State *L)
|
||||
{
|
||||
p->Scroll(-1);
|
||||
return 1;
|
||||
}
|
||||
static int ShowNextMsg(T* p, lua_State *L)
|
||||
{
|
||||
p->ShowNextMsg();
|
||||
return 1;
|
||||
}
|
||||
static int ShowPreviousMsg(T* p, lua_State *L)
|
||||
{
|
||||
p->ShowPreviousMsg();
|
||||
return 1;
|
||||
}
|
||||
static int GetChatScroll(T* p, lua_State *L)
|
||||
{
|
||||
lua_pushnumber(L, p->GetScroll());
|
||||
return 1;
|
||||
}
|
||||
static int GetChatLines(T* p, lua_State *L)
|
||||
{
|
||||
lua_pushnumber(L, p->GetLines());
|
||||
return 1;
|
||||
}
|
||||
public:
|
||||
LunaScreenNetSelectBase()
|
||||
{
|
||||
ADD_METHOD(GetUser);
|
||||
ADD_METHOD(UsersVisible);
|
||||
ADD_METHOD(ChatboxInput);
|
||||
ADD_METHOD(ChatboxVisible);
|
||||
ADD_METHOD(GetUserQty);
|
||||
ADD_METHOD(GetUserState);
|
||||
/*
|
||||
ADD_METHOD(GetFriendQty);
|
||||
ADD_METHOD(GetFriendState);
|
||||
ADD_METHOD(GetFriendName);
|
||||
*/
|
||||
ADD_METHOD(ScrollChatUp);
|
||||
ADD_METHOD(ScrollChatDown);
|
||||
ADD_METHOD(ShowNextMsg);
|
||||
ADD_METHOD(ShowPreviousMsg);
|
||||
ADD_METHOD(GetChatScroll);
|
||||
ADD_METHOD(GetChatLines);
|
||||
}
|
||||
};
|
||||
|
||||
LUA_REGISTER_DERIVED_CLASS(ScreenNetSelectBase, ScreenWithMenuElements)
|
||||
// lua end
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,6 +15,9 @@ class ColorBitmapText : public BitmapText
|
||||
public:
|
||||
void SetText( const RString &sText, const RString &sAlternateText = "", int iWrapWidthPixels = -1 );
|
||||
void DrawPrimitives();
|
||||
int lines = 0;
|
||||
void ResetText();
|
||||
void SetMaxLines(int iNumLines, int iDirection, unsigned int &scroll);
|
||||
void SetMaxLines( int iLines, bool bCutBottom = true ); //if bCutBottom = false then, it will crop the top
|
||||
void SimpleAddLine( const RString &sAddition, int iWidthPixels );
|
||||
void SetMaxLines( int iNumLines, int iDirection );
|
||||
@@ -39,6 +42,24 @@ public:
|
||||
|
||||
void UpdateUsers();
|
||||
void UpdateTextInput();
|
||||
|
||||
|
||||
bool usersVisible = true;
|
||||
bool enableChatboxInput = true;
|
||||
void SetChatboxVisible(bool visibility);
|
||||
void SetUsersVisible(bool visibility);
|
||||
vector<BitmapText>* ToUsers();
|
||||
void Scroll(int movescroll);
|
||||
RString GetPreviousMsg();
|
||||
RString GetNextMsg();
|
||||
void SetInputText(RString text);
|
||||
void ShowPreviousMsg();
|
||||
void ShowNextMsg();
|
||||
unsigned int GetScroll() { return scroll; }
|
||||
unsigned int GetLines() { return m_textChatOutput.lines; }
|
||||
// Lua
|
||||
virtual void PushSelf(lua_State *L);
|
||||
|
||||
private:
|
||||
//Chatting
|
||||
ColorBitmapText m_textChatInput;
|
||||
@@ -46,6 +67,9 @@ private:
|
||||
AutoActor m_sprChatInputBox;
|
||||
AutoActor m_sprChatOutputBox;
|
||||
RString m_sTextInput;
|
||||
unsigned int m_sTextLastestInputsIndex;
|
||||
vector<RString> m_sTextLastestInputs;
|
||||
unsigned int scroll;
|
||||
RString m_actualText;
|
||||
|
||||
vector <BitmapText> m_textUsers;
|
||||
|
||||
@@ -424,36 +424,40 @@ bool ScreenNetSelectMusic::MenuDown( const InputEventPlus &input )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScreenNetSelectMusic::MenuStart( const InputEventPlus &input )
|
||||
bool ScreenNetSelectMusic::MenuStart(const InputEventPlus &input)
|
||||
{
|
||||
return SelectCurrent();
|
||||
}
|
||||
bool ScreenNetSelectMusic::SelectCurrent()
|
||||
{
|
||||
|
||||
bool bResult = m_MusicWheel.Select();
|
||||
|
||||
if( !bResult )
|
||||
if (!bResult)
|
||||
return true;
|
||||
|
||||
if( m_MusicWheel.GetSelectedType() != WheelItemDataType_Song )
|
||||
if (m_MusicWheel.GetSelectedType() != WheelItemDataType_Song)
|
||||
return true;
|
||||
|
||||
Song * pSong = m_MusicWheel.GetSelectedSong();
|
||||
|
||||
if( pSong == NULL )
|
||||
if (pSong == NULL)
|
||||
return false;
|
||||
|
||||
GAMESTATE->m_pCurSong.Set( pSong );
|
||||
GAMESTATE->m_pCurSong.Set(pSong);
|
||||
|
||||
if( NSMAN->useSMserver )
|
||||
if (NSMAN->useSMserver)
|
||||
{
|
||||
NSMAN->m_sArtist = pSong->GetTranslitArtist();
|
||||
NSMAN->m_sMainTitle = pSong->GetTranslitMainTitle();
|
||||
NSMAN->m_sSubTitle = pSong->GetTranslitSubTitle();
|
||||
NSMAN->m_iSelectMode = 2; // Command for user selecting song
|
||||
NSMAN->SelectUserSong ();
|
||||
NSMAN->SelectUserSong();
|
||||
}
|
||||
else
|
||||
StartSelectedSong();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScreenNetSelectMusic::MenuBack( const InputEventPlus &input )
|
||||
{
|
||||
SOUND->StopMusic();
|
||||
@@ -603,6 +607,37 @@ void ScreenNetSelectMusic::Update( float fDeltaTime )
|
||||
ScreenNetSelectBase::Update( fDeltaTime );
|
||||
}
|
||||
|
||||
MusicWheel* ScreenNetSelectMusic::GetMusicWheel()
|
||||
{
|
||||
return &m_MusicWheel;
|
||||
}
|
||||
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
/** @brief Allow Lua to have access to the PlayerState. */
|
||||
class LunaScreenNetSelectMusic : public Luna<ScreenNetSelectMusic>
|
||||
{
|
||||
public:
|
||||
static int GetMusicWheel(T* p, lua_State *L) {
|
||||
p->GetMusicWheel()->PushSelf(L);
|
||||
return 1;
|
||||
}
|
||||
static int SelectCurrent(T* p, lua_State *L) {
|
||||
p->SelectCurrent();
|
||||
return 1;
|
||||
}
|
||||
LunaScreenNetSelectMusic()
|
||||
{
|
||||
ADD_METHOD(GetMusicWheel);
|
||||
ADD_METHOD(SelectCurrent);
|
||||
}
|
||||
};
|
||||
|
||||
LUA_REGISTER_DERIVED_CLASS(ScreenNetSelectMusic, ScreenNetSelectBase)
|
||||
// lua end
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,6 +22,11 @@ public:
|
||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||
|
||||
void StartSelectedSong();
|
||||
bool SelectCurrent();
|
||||
|
||||
MusicWheel* GetMusicWheel();
|
||||
// Lua
|
||||
virtual void PushSelf(lua_State *L);
|
||||
|
||||
protected:
|
||||
virtual bool MenuStart( const InputEventPlus &input );
|
||||
|
||||
Reference in New Issue
Block a user