PartyNames: Added button for selecting random.

This commit is contained in:
Florian Küpper committed 2013-12-26 11:37:19 +01:00
1 parent 2427f40bc6
commit 4b4c8aa8f2
4 files changed
+111 -1

No files matched your search

@@ -24,6 +24,7 @@
<string name="TR_SCREENNAMES_TITLE">Tic-Tac-Toe: Choose Player</string>
<string name="TR_SCREENNAMES_TEAM1">Team 1</string>
<string name="TR_SCREENNAMES_TEAM2">Team 2</string>
<string name="TR_SCREENNAMES_BUTTON_RANDOM">Select random</string>
<string name="TR_SCREENMAIN_TITLE">Tic-Tac-Toe</string>
<string name="TR_SCREENMAIN_TEAM_CHOOSE">Choose a field.</string>
<string name="TR_SCREENMAIN_NEXT_PLAYER">Next player</string>
@@ -172,6 +172,63 @@
<Height>26</Height>
</SReflection>
</ButtonBack>
<ButtonRandom>
<!--<Skin>: Texture name-->
<Skin>Button</Skin>
<!--<SkinSelected>: Texture name for selected button-->
<SkinSelected>Button</SkinSelected>
<!--<X>, <Y>, <Z>, <W>, <H>: Button position, width and height-->
<X>565</X>
<Y>625</Y>
<Z>0,00</Z>
<W>150</W>
<H>50</H>
<!--<Color>: Button color from ColorScheme (high priority)-->
<!--or <R>, <G>, <B>, <A> (lower priority)-->
<Color>ButtonColor</Color>
<!--<SColor>: Selected button color from ColorScheme (high priority)-->
<!--or <SR>, <SG>, <SB>, <SA> (lower priority)-->
<SColor>ButtonSColor</SColor>
<Text>
<!--<X>, <Y>: Text position-->
<X>75</X>
<Y>10</Y>
<!--<H>: Text height-->
<H>27</H>
<!--<MaxW>: Maximum text width (if exists)-->
<MaxW>142</MaxW>
<!--<Color>: Text color from ColorScheme (high priority)-->
<!--or <R>, <G>, <B>, <A> (lower priority)-->
<Color>ButtonTextColor</Color>
<!--<SColor>: Selected Text color from ColorScheme (high priority)-->
<!--or <SR>, <SG>, <SB>, <SA> (lower priority)-->
<SColor>ButtonTextSColor</SColor>
<!--<Align>: Text align horizontal: Left, Center, Right-->
<Align>Center</Align>
<!--<HAlign>: Text align vertical (on downsizing): Top, Center, Bottom-->
<HAlign>Center</HAlign>
<!--<Style>: Text style: Normal, Italic, Bold, BoldItalic-->
<Style>Bold</Style>
<!--<Font>: Text font name-->
<Font>Outline</Font>
<!--<Text>: Nothing or translation tag-->
<Text>TR_SCREENNAMES_BUTTON_RANDOM</Text>
</Text>
<!--<Reflection> If exists:-->
<!-- <Space>: Reflection Space-->
<!-- <Height>: Reflection Height-->
<Reflection>
<Space>10</Space>
<Height>26</Height>
</Reflection>
<!--<SReflection> If exists:-->
<!-- <Space>: Reflection Space of selected button-->
<!-- <Height>: Reflection Height of selected button-->
<SReflection>
<Space>10</Space>
<Height>26</Height>
</SReflection>
</ButtonRandom>
<ButtonIncreasePlayer>
<!--<Skin>: Texture name-->
<Skin>Plus</Skin>
+32 -1
View File
@@ -56,6 +56,7 @@ namespace VocaluxeLib.Menu
private const string _ButtonNext = "ButtonNext";
private const string _ButtonBack = "ButtonBack";
private const string _ButtonRandom = "ButtonRandom";
private const string _ButtonIncreaseTeams = "ButtonIncreaseTeams";
private const string _ButtonDecreaseTeams = "ButtonDecreaseTeams";
private const string _ButtonIncreasePlayer = "ButtonIncreasePlayer";
@@ -69,7 +70,7 @@ namespace VocaluxeLib.Menu
public override void Init()
{
base.Init();
_ThemeButtons = new string[] { _ButtonBack, _ButtonNext, _ButtonIncreaseTeams, _ButtonDecreaseTeams, _ButtonIncreasePlayer, _ButtonDecreasePlayer };
_ThemeButtons = new string[] { _ButtonBack, _ButtonNext, _ButtonRandom, _ButtonIncreaseTeams, _ButtonDecreaseTeams, _ButtonIncreasePlayer, _ButtonDecreasePlayer };
_ThemeSelectSlides = new string[] { _SelectSlideTeams, _SelectSlidePlayer };
_ThemeNameSelections = new string[] { _NameSelection };
@@ -184,6 +185,9 @@ namespace VocaluxeLib.Menu
if (_Buttons[_ButtonNext].Selected)
Next();
if (_Buttons[_ButtonRandom].Selected)
_SelectRandom();
if (_Buttons[_ButtonIncreaseTeams].Selected)
IncreaseTeamNum();
@@ -320,6 +324,9 @@ namespace VocaluxeLib.Menu
if (_Buttons[_ButtonNext].Selected)
Next();
if (_Buttons[_ButtonRandom].Selected)
_SelectRandom();
if (_Buttons[_ButtonIncreaseTeams].Selected)
IncreaseTeamNum();
@@ -621,6 +628,17 @@ namespace VocaluxeLib.Menu
_UpdatePlayerSlide();
}
private void _RemoveAllPlayer()
{
for (int t = 0; t < _TeamList.Length; t++)
{
for (int p = 0; p < _TeamList[t].Count; p++)
{
_RemovePlayerByIndex(t, p);
}
}
}
private void _RemovePlayerByIndex(int team, int index)
{
if (_TeamList[team].Count > index)
@@ -637,6 +655,19 @@ namespace VocaluxeLib.Menu
_NameSelections[_NameSelection].RemoveUsedProfile(profileID);
}
private void _SelectRandom()
{
_RemoveAllPlayer();
for (int t = 0; t < _NumPlayerTeams.Length; t++)
{
for (int p = 0; p < _NumPlayerTeams[t]; p++)
{
int profileID = _NameSelections[_NameSelection].GetRandomUnusedProfile();
_AddPlayer(t, profileID);
}
}
}
#endregion
}
}
+21
View File
@@ -503,6 +503,27 @@ namespace VocaluxeLib.Menu
}
}
public int GetRandomUnusedProfile()
{
int id = -1;
if (_VisibleProfiles.Count == 0)
return id;
if (_VisibleProfiles.Count == _UsedProfiles.Count)
return id;
while(id == -1)
{
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count);
if (_UsedProfiles.Contains(_VisibleProfiles[rand]))
continue;
id = _VisibleProfiles[rand];
}
return id;
}
private void _PrepareTiles()
{
_Tiles.Clear();