Skip to content

Commit

Permalink
Add multiplayer to titleMenu scroller in til death
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Mar 27, 2018
1 parent 14c5e2d commit cdfb7d1
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 39 deletions.
46 changes: 25 additions & 21 deletions Themes/Til Death/Scripts/02 Branches.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ If the line is a function, you'll have to use Branch.keyname() instead.

-- used for various SMOnline-enabled screens:
function SMOnlineScreen()
if not IsNetSMOnline() then
return "ScreenSelectMusic"
end
for pn in ivalues(GAMESTATE:GetHumanPlayers()) do
if not IsSMOnlineLoggedIn(pn) then
return "ScreenSMOnlineLogin"
Expand All @@ -31,7 +34,6 @@ function GameOverOrContinue()
return "ScreenGameOver"
end
end

Branch = {
Init = function() return Branch.TitleMenu() end,
AfterInit = function()
Expand Down Expand Up @@ -68,6 +70,7 @@ Branch = {
end
end,
StartGame = function()
multiplayer = false
-- Check to see if there are 0 songs installed. Also make sure to check
-- that the additional song count is also 0, because there is
-- a possibility someone will use their existing StepMania simfile
Expand All @@ -81,11 +84,7 @@ Branch = {
if IsNetConnected() then
return "ScreenSelectStyle"
else
if THEME:GetMetric("Common","AutoSetStyle") == false then
return "ScreenSelectStyle"
else
return "ScreenProfileLoad"
end
return "ScreenProfileLoad"
end
end
end,
Expand All @@ -101,24 +100,15 @@ Branch = {
ReportStyle()
GAMESTATE:ApplyGameCommand("playmode,regular")
end
if IsNetSMOnline() then
return SMOnlineScreen()
end
if IsNetConnected() then
return "ScreenNetRoom"
end
return "ScreenProfileLoad"

--return CHARMAN:GetAllCharacters() ~= nil and "ScreenSelectCharacter" or "ScreenGameInformation"
end,
AfterSelectProfile = function()
if ( THEME:GetMetric("Common","AutoSetStyle") == true ) then
-- use SelectStyle in online...
-- OR DONT LOL!!! - mina
return IsNetConnected() and "ScreenSMOnlineLogin" or "ScreenSelectMusic"--"ScreenSelectPlayMode"
else
return "ScreenSelectMusic"--"ScreenSelectStyle"
end
return "ScreenSelectMusic"
end,
AfterNetSelectProfile = function()
return SMOnlineScreen()
end,
AfterProfileLoad = function()
return "ScreenSelectMusic"--"ScreenSelectPlayMode"
Expand All @@ -137,7 +127,18 @@ Branch = {
bTrue = PREFSMAN:GetPreference("ShowInstructions")
return (bTrue and GoToMusic() or "ScreenGameInformation")
end,
AfterSMOLogin = SMOnlineScreen(),
AfterSMOLogin = SMOnlineScreen,
MultiScreen = function()
if IsNetSMOnline() then
if not IsSMOnlineLoggedIn(PLAYER_1) then
return "ScreenNetSelectProfile"
else
return "ScreenNetRoom"
end
else
return "ScreenNetworkOptions"
end
end,
BackOutOfPlayerOptions = function()
return SelectMusicOrCourse()
end,
Expand Down Expand Up @@ -229,7 +230,10 @@ Branch = {
return "ScreenProfileSaveSummary"
end,
Network = function()
return IsNetConnected() and "ScreenTitleMenu" or "ScreenTitleMenu"
return IsNetConnected() and Branch.MultiScreen() or "ScreenTitleMenu"
end,
BackOutOfNetwork = function()
return "ScreenTitleMenu"
end,
AfterSaveSummary = function()
return GameOverOrContinue()
Expand Down
4 changes: 3 additions & 1 deletion Themes/Til Death/metrics.ini
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ ScrollerTransform=function(self,offset,itemIndex,numItems) \
self:y(20*(itemIndex-(numItems-1)/2)); \
end; \

ChoiceNames="GameStart,Options,AV,Color,GitHub,Exit"
ChoiceNames="GameStart,Multi,Options,AV,Color,GitHub,Exit"
ChoiceColor="screen,ScreenColorChange;text,ColorChange"
ChoiceColor="screen,ScreenColorChange;text,ColorChange"
ChoiceMulti="text,Multi;applydefaultoptions;screen,"..Branch.MultiScreen()
ChoiceAV="urlnoexit,https://www.ddrnl.com/viewtopic.php?f=13&t=156;text,Editor"
ChoiceGitHub="urlnoexit,https://github.com/etternagame/etterna;text,GitHub"

Expand Down
1 change: 1 addition & 0 deletions Themes/_fallback/Languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1958,6 +1958,7 @@ AnswerBlank=
%d songs in %d groups=%d songs in %d groups
%d courses in %d groups=%d courses in %d groups
%d unlocks=%d unlocks
Multi=Multiplayer
# New Default Strings
Gametype:=Gametype:
Difficulty:=Difficulty:
Expand Down
33 changes: 23 additions & 10 deletions Themes/_fallback/Scripts/02 Branches.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ If the line is a function, you'll have to use Branch.keyname() instead.

-- used for various SMOnline-enabled screens:
function SMOnlineScreen()
if not IsNetSMOnline() then
return "ScreenSelectMusic"
end
for pn in ivalues(GAMESTATE:GetHumanPlayers()) do
if not IsSMOnlineLoggedIn(pn) then
return "ScreenSMOnlineLogin"
Expand Down Expand Up @@ -89,6 +92,17 @@ Branch = {
end
end
end,
MultiScreen = function()
if IsNetSMOnline() then
if not IsSMOnlineLoggedIn(PLAYER_1) then
return "ScreenNetSelectProfile"
else
return "ScreenNetRoom"
end
else
return "ScreenNetworkOptions"
end
end,
OptionsEdit = function()
-- Similar to above, don't let anyone in here with 0 songs.
if SONGMAN:GetNumSongs() == 0 and SONGMAN:GetNumAdditionalSongs() == 0 then
Expand All @@ -101,24 +115,20 @@ Branch = {
ReportStyle()
GAMESTATE:ApplyGameCommand("playmode,regular")
end
if IsNetSMOnline() then
return SMOnlineScreen()
end
if IsNetConnected() then
return "ScreenNetRoom"
end
return "ScreenProfileLoad"

--return CHARMAN:GetAllCharacters() ~= nil and "ScreenSelectCharacter" or "ScreenGameInformation"
end,
AfterSelectProfile = function()
if ( THEME:GetMetric("Common","AutoSetStyle") == true ) then
-- use SelectStyle in online...
return IsNetConnected() and "ScreenSelectStyle" or "ScreenSelectPlayMode"
return "ScreenSelectMusic"
else
return "ScreenSelectStyle"
end
end,
AfterNetSelectProfile = function()
return SMOnlineScreen()
end,
AfterProfileLoad = function()
return "ScreenSelectPlayMode"
end,
Expand All @@ -136,7 +146,7 @@ Branch = {
bTrue = PREFSMAN:GetPreference("ShowInstructions")
return (bTrue and GoToMusic() or "ScreenGameInformation")
end,
AfterSMOLogin = SMOnlineScreen(),
AfterSMOLogin = SMOnlineScreen,
BackOutOfPlayerOptions = function()
return SelectMusicOrCourse()
end,
Expand Down Expand Up @@ -211,7 +221,10 @@ Branch = {
return "ScreenProfileSaveSummary"
end,
Network = function()
return IsNetConnected() and "ScreenTitleMenu" or "ScreenTitleMenu"
return IsNetConnected() and Branch.MultiScreen() or "ScreenTitleMenu"
end,
BackOutOfNetwork = function()
return "ScreenTitleMenu"
end,
AfterSaveSummary = function()
return GameOverOrContinue()
Expand Down
11 changes: 9 additions & 2 deletions Themes/_fallback/metrics.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1859,6 +1859,13 @@ TimerSeconds=-1
#
LoadEdits=true

[ScreenNetSelectProfile]
Fallback="ScreenSelectProfile"
Class="ScreenSelectProfile"
NextScreen=Branch.AfterNetSelectProfile()
StartScreen=Branch.AfterNetSelectProfile()
PrevScreen="ScreenTitleMenu"

[ScreenSelectProfile]
Fallback="ScreenWithMenuElements"
Class="ScreenSelectProfile"
Expand Down Expand Up @@ -3054,7 +3061,7 @@ Line1="conf,Game"
Class="ScreenNetworkOptions"
Fallback="ScreenOptionsServiceChild"
NextScreen=Branch.Network()
PrevScreen=Branch.Network()
PrevScreen=Branch.BackOutOfNetwork()

[ScreenOptionsManageProfiles]
Class="ScreenOptionsManageProfiles"
Expand Down Expand Up @@ -4195,7 +4202,7 @@ ShowHelp=false
[ScreenSMOnlineLogin]
Class="ScreenSMOnlineLogin"
Fallback="ScreenOptionsServiceChild"
NextScreen=Branch.AfterSMOLogin
NextScreen=Branch.AfterSMOLogin()
PrevScreen=Branch.TitleMenu()
ShowStyleIcon=false
TimerSeconds=-1
Expand Down
1 change: 1 addition & 0 deletions src/NetworkSyncManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ RoomData jsonToRoom(json& room)
tmp.SetDescription(s);
unsigned int state = room.value("state", 0);
tmp.SetState(state);
tmp.SetHasPassword(room.value("pass", false));
for (auto&& player : room.at("players"))
tmp.players.emplace_back(player.get<string>());
return tmp;
Expand Down
4 changes: 2 additions & 2 deletions src/RoomWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void RoomWheel::BuildFromRoomDatas()
itemData->m_sText = roomsInWheel[i].Name();
itemData->m_sDesc = roomsInWheel[i].Description();
itemData->m_iFlags = roomsInWheel[i].GetFlags();

itemData->hasPassword = roomsInWheel[i].HasPassword();
std::string color;
switch (roomsInWheel[i].State())
{
Expand All @@ -309,7 +309,7 @@ void RoomWheel::BuildFromRoomDatas()
}
itemData->m_color = THEME->GetMetricC(m_sName, color);

if (roomsInWheel[i].GetFlags() % 2)
if (roomsInWheel[i].GetFlags() % 2 || roomsInWheel[i].HasPassword())
itemData->m_color = THEME->GetMetricC(m_sName, "PasswdRoomColor");
}

Expand Down
8 changes: 6 additions & 2 deletions src/RoomWheel.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ class RoomData {
void SetDescription(const std::string& desc) { m_description = desc; }
void SetState(unsigned int state) { m_state = state; }
void SetFlags(unsigned int iFlags) { m_iFlags = iFlags; }
void SetHasPassword(bool pass) { hasPassword = pass; }
inline std::string Name() const { return m_name; }
inline std::string Description() const { return m_description; }
inline unsigned int State() const { return m_state; }
inline bool HasPassword() const { return hasPassword; }
inline unsigned int GetFlags() const { return m_iFlags; }
RoomData() { m_name=""; m_description=""; m_state=0; m_iFlags=0; }
vector<string> players;
Expand All @@ -24,16 +26,18 @@ class RoomData {
std::string m_description;
unsigned int m_state;
unsigned int m_iFlags;
bool hasPassword{false};
};

struct RoomWheelItemData : public WheelItemBaseData
{
RoomWheelItemData() = default;
RoomWheelItemData( WheelItemDataType type, const std::string& sTitle, const std::string& sDesc, const RageColor &color ):
WheelItemBaseData( type, sTitle, color ), m_sDesc(sDesc), m_iFlags(0) { };
RoomWheelItemData( WheelItemDataType type, const std::string& sTitle, const std::string& sDesc, const RageColor &color, const bool hasPass=false):
WheelItemBaseData( type, sTitle, color ), m_sDesc(sDesc), m_iFlags(0), hasPassword(hasPass) { };

std::string m_sDesc;
unsigned int m_iFlags{0};
bool hasPassword{ false };
};

class RoomWheelItem : public WheelItemBase
Expand Down
2 changes: 1 addition & 1 deletion src/ScreenNetRoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void ScreenNetRoom::SelectCurrent()
RoomWheelItemData* rwd = dynamic_cast<RoomWheelItemData*>(m_RoomWheel.LastSelected());
if (rwd)
{
if (rwd->m_iFlags % 2)
if (rwd->m_iFlags % 2 || rwd->hasPassword)
{
m_sLastPickedRoom = rwd->m_sText;
ScreenTextEntry::TextEntry(SM_BackFromReqPass, ENTER_ROOM_REQPASSWORD, "", 255);
Expand Down

0 comments on commit cdfb7d1

Please sign in to comment.