New lua function CHARMAN:GetCharacterCount.

How the Characters mod won't display by default if
there are no characters to play with at all.
This commit is contained in:
Jason Felds
2011-07-05 19:10:07 -04:00
parent d3c8abed4a
commit e281ca418b
5 changed files with 32 additions and 10 deletions
+3
View File
@@ -14,6 +14,9 @@ StepMania 5.0 ????????? | 20110???
Saving should still work, but this was never tested yet. [Wolfman2000]
* [ScreenOptions] Mini is now ITG Mini, and Tiny is now Pump Pro Mini.
This will prevent many prior courses from breaking. [sharksoda, Wolfman2000]
* [CharacterManager] Add a lua function to check how many characters you have.
For an example of how this is used, check the default theme's scripts
folder, specifically 03 ThemePrefs.lua. [Wolfman2000]
2011/07/04
----------
+1
View File
@@ -580,6 +580,7 @@
<Function name='GetAllCharacters'/>
<Function name='GetCharacter'/>
<Function name='GetRandomCharacter'/>
<Function name='GetCharacterCount'/>
</Class>
<Class base='ActorFrame' name='ComboGraph'>
<Function name='Load'/>
+3
View File
@@ -1540,6 +1540,9 @@
<Function name='GetRandomCharacter' return='Character' arguments=''>
Returns a random character.
</Function>
<Function name='GetCharacterCount' return='int' arguments=''>
Returns the number of characters available.
</Function>
</Class>
<Class name='ComboGraph'>
<Function name='Load' return='void' arguments='string sMetricsGroup'>
+17 -10
View File
@@ -231,9 +231,9 @@ function UserPrefShowLotsaOptions()
end
function GetDefaultOptionLines()
local LineSets = {
"1,8,14,2,3,4,5,6,R,7,9,10,11,12,13,16,17,18", -- All
"1,8,14,2,7,13,16,17,18", -- DDR Essentials ( no turns, fx )
local LineSets = { -- none of these include characters yet.
"1,8,14,2,3,4,5,6,R,7,9,10,11,12,13,16,17", -- All
"1,8,14,2,7,13,16,17", -- DDR Essentials ( no turns, fx )
};
local function IsExtra()
if GAMESTATE:IsExtraStage() or GAMESTATE:IsExtraStage2() then
@@ -242,15 +242,22 @@ function GetDefaultOptionLines()
return false
end
end
if not IsExtra() then
if GetUserPrefB("UserPrefShowLotsaOptions") then
return GetUserPrefB("UserPrefShowLotsaOptions") and LineSets[1] or LineSets[2];
else
return LineSets[2]; -- Just make sure!
local function CheckCharacters(mods)
if CHARMAN:GetCharacterCount() > 0 then
return mods .. ",18"; --TODO: Better line name.
end
else
return "1,8,14,2,7,13,16,17,18" -- "failsafe" list
return mods;
end
modLines = LineSets[2];
if not IsExtra() then
modLines = GetUserPrefB("UserPrefShowLotsaOptions")
and LineSets[1] or LineSets[2];
end
return CheckCharacters(modLines);
end;
function UserPrefAutoSetStyle()
+8
View File
@@ -152,6 +152,13 @@ public:
LuaHelpers::CreateTableFromArray(vChars, L);
return 1;
}
static int GetCharacterCount(T* p, lua_State *L)
{
vector<Character*> chars;
p->GetCharacters(chars);
lua_pushnumber(L, chars.size());
return 1;
}
LunaCharacterManager()
{
@@ -159,6 +166,7 @@ public:
// sm-ssc adds:
ADD_METHOD( GetRandomCharacter );
ADD_METHOD( GetAllCharacters );
ADD_METHOD( GetCharacterCount );
}
};