Fixed quotes and spelling in new actor examples. Fixed RollingNumbers to do nothing instead of crashing if it's rendered before it loads its metrics.
This commit is contained in:
@@ -1,17 +1,17 @@
|
|||||||
-- A simple BitmapText example. Puts “Hello World!” in the center of the screen.
|
-- A simple BitmapText example. Puts "Hello World!" in the center of the screen.
|
||||||
-- BitmapTexts put text on the screen (pretty self-explanatory)
|
-- BitmapTexts put text on the screen (pretty self-explanatory)
|
||||||
|
|
||||||
Def.BitmapText{
|
Def.BitmapText{
|
||||||
Font=”Common normal”,
|
Font="Common Normal",
|
||||||
-- Chooses the font for the text. The font needs to be in the themes Fonts folder or
|
-- Chooses the font for the text. The font needs to be in the theme's Fonts
|
||||||
-- the fallback theme’s Fonts folder. By default, Common normal is
|
-- folder or the fallback theme's Fonts folder. By default, Common Normal
|
||||||
-- “_open sans semibold”.
|
-- is "_open sans semibold".
|
||||||
-- File is used in XML files from ITG, instead of Font. It’s deprecated.
|
-- File is used in XML files from ITG, instead of Font. It's deprecated.
|
||||||
-- You shouldn’t use it.
|
-- You shouldn't use it.
|
||||||
|
|
||||||
Text=”Hello World!”,
|
Text="Hello World!",
|
||||||
-- Chooses what the BitmapText will show. Pretty straightforward.
|
-- Chooses what the BitmapText will show. Pretty straightforward.
|
||||||
|
|
||||||
OnCommand=cmd(Center)
|
OnCommand= function(self) self:Center() end,
|
||||||
-- Puts the text in the center in the center of the screen.
|
-- Puts the text in the center in the center of the screen.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,16 @@
|
|||||||
Def.Quad{
|
Def.Quad{
|
||||||
-- Quads have no special attributes, but they do have a few special functions.
|
-- Quads have no special attributes, but they do have a few special functions.
|
||||||
OnCommand=function(self)
|
OnCommand=function(self)
|
||||||
self:SetWidth(40) -- scales the quad’s width to 40
|
self:SetWidth(40) -- scales the quad's width to 40
|
||||||
self:SetHeight(40) -- scales the quad’s height to 40
|
self:SetHeight(40) -- scales the quad's height to 40
|
||||||
-- SetWidth and SetHeight must be capitalized to work.
|
-- SetWidth and SetHeight must be capitalized to work.
|
||||||
-- SetSize (or setsize) is a shorthand for SetWidth and SetHeight.
|
-- SetSize (or setsize) is a shorthand for SetWidth and SetHeight.
|
||||||
-- The syntax is setsize(x, y), where x is the width and y is the height.
|
-- The syntax is setsize(x, y), where x is the width and y is the height.
|
||||||
-- The default width and height is 1, which is less than 1 pixel on some displays
|
-- The default width and height is 1, which is less than 1 pixel on some displays
|
||||||
|
|
||||||
self:diffuse(color(Red))
|
self:diffuse(Color.Red)
|
||||||
-- Sets the color to red.
|
-- Sets the color to red.
|
||||||
-- A list of all possible names for the colors can be found in
|
-- A list of all possible names for the colors can be found in
|
||||||
-- Themes/_fallback/Scripts/02 Colors.lua
|
-- Themes/_fallback/Scripts/02 Colors.lua
|
||||||
|
|
||||||
self:Center()
|
self:Center()
|
||||||
|
|||||||
@@ -4,35 +4,40 @@
|
|||||||
-- To test this, put this in your metrics ini:
|
-- To test this, put this in your metrics ini:
|
||||||
|
|
||||||
[RollingNumbersExample]
|
[RollingNumbersExample]
|
||||||
Fallback=”RollingNumbers”
|
Fallback="RollingNumbers"
|
||||||
|
|
||||||
TextFormat=”%04.0f”
|
TextFormat="%04.0f"
|
||||||
ApproachSeconds=10
|
ApproachSeconds=10
|
||||||
Commify=true
|
Commify=true
|
||||||
LeadingZeroMultiplyColor=Color.Orange
|
LeadingZeroMultiplyColor=Color.Orange
|
||||||
|
|
||||||
-- Be sure to reload the metrics if StepMania is currently open.
|
-- Be sure to reload the metrics if StepMania is currently open.
|
||||||
|
|
||||||
-- Let’s go over the parts:
|
-- Let's go over the parts:
|
||||||
-- TextFormat: How many trailing zeroes you want, using the format “xx.0f”, where xx
|
-- TextFormat: How many trailing zeroes you want, using the format "xx.0f", where xx
|
||||||
-- is the number.
|
-- is the number.
|
||||||
-- ApproachSeconds: How many seconds it takes to reach the target number (explained later)
|
-- ApproachSeconds: How many seconds it takes to reach the target number (explained later)
|
||||||
-- Commify: Whether or not to use commas every 3 digits, i.e. 1,000 vs 1000.
|
-- Commify: Whether or not to use commas every 3 digits, i.e. 1,000 vs 1000.
|
||||||
-- Commify can only be true or false.
|
-- Commify can only be true or false.
|
||||||
-- LeadingZeroMultiplyColor: The color of the closest zero to the number.
|
-- LeadingZeroMultiplyColor: The color of the closest zero to the number.
|
||||||
-- For example, if you were to make LeadingZeroMultiplyColor red, and
|
-- For example, if you were to make LeadingZeroMultiplyColor red, and
|
||||||
-- your RollingNumber was at 100 with a TextFormat of “%04.0f”, then
|
-- your RollingNumber was at 100 with a TextFormat of "%04.0f", then
|
||||||
-- then the zero before the 1 (0100) would be red.
|
-- then the zero before the 1 (0100) would be red.
|
||||||
|
|
||||||
-- Now, for the actual thing:
|
-- Now, for the actual thing:
|
||||||
Def.RollingNumbers{
|
Def.RollingNumbers{
|
||||||
-- RollingNumbers derives from BitmapText, so you’re gonna need a font.
|
-- RollingNumbers derives from BitmapText, so you're gonna need a font.
|
||||||
Font=”Common Normal”,
|
Font="Common Normal",
|
||||||
|
|
||||||
-- Text is unnecessary however, and may break the game.
|
-- The Text field is ignored.
|
||||||
|
|
||||||
-- Let’s load the metrics and set our target number
|
-- Let's load the metrics and set our target number
|
||||||
OnCommand=cmd(Load,”RollingNumbersExample”;targetnumber,1000)
|
-- If you don't call Load, your RollingNumbers actor will not be rendered
|
||||||
|
-- and you won't be able to set the target number.
|
||||||
|
OnCommand= function(self)
|
||||||
|
self:Load("RollingNumbersExample"):targetnumber(1000)
|
||||||
|
:xy(_screen.cx, _screen.cy - 100)
|
||||||
|
end
|
||||||
|
|
||||||
}
|
}
|
||||||
-- Your RollingNumber should start at zero, then take 10 seconds to reach 1000.
|
-- Your RollingNumber should start at zero, then take 10 seconds to reach 1000.
|
||||||
|
|||||||
+18
-1
@@ -13,10 +13,12 @@ RollingNumbers::RollingNumbers()
|
|||||||
m_fCurrentNumber = 0;
|
m_fCurrentNumber = 0;
|
||||||
m_fTargetNumber = 0;
|
m_fTargetNumber = 0;
|
||||||
m_fScoreVelocity = 0;
|
m_fScoreVelocity = 0;
|
||||||
|
m_metrics_loaded= false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RollingNumbers::Load( const RString &sMetricsGroup )
|
void RollingNumbers::Load( const RString &sMetricsGroup )
|
||||||
{
|
{
|
||||||
|
m_metrics_loaded= true;
|
||||||
TEXT_FORMAT.Load(sMetricsGroup, "TextFormat");
|
TEXT_FORMAT.Load(sMetricsGroup, "TextFormat");
|
||||||
APPROACH_SECONDS.Load(sMetricsGroup, "ApproachSeconds");
|
APPROACH_SECONDS.Load(sMetricsGroup, "ApproachSeconds");
|
||||||
COMMIFY.Load(sMetricsGroup, "Commify");
|
COMMIFY.Load(sMetricsGroup, "Commify");
|
||||||
@@ -40,6 +42,10 @@ void RollingNumbers::DrawPart(RageColor const* diffuse, RageColor const& stroke,
|
|||||||
|
|
||||||
void RollingNumbers::DrawPrimitives()
|
void RollingNumbers::DrawPrimitives()
|
||||||
{
|
{
|
||||||
|
if(!m_metrics_loaded)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
RageColor diffuse_orig[NUM_DIFFUSE_COLORS];
|
RageColor diffuse_orig[NUM_DIFFUSE_COLORS];
|
||||||
RageColor diffuse_temp[NUM_DIFFUSE_COLORS];
|
RageColor diffuse_temp[NUM_DIFFUSE_COLORS];
|
||||||
RageColor stroke_orig= GetCurrStrokeColor();
|
RageColor stroke_orig= GetCurrStrokeColor();
|
||||||
@@ -93,6 +99,11 @@ void RollingNumbers::Update( float fDeltaTime )
|
|||||||
|
|
||||||
void RollingNumbers::SetTargetNumber( float fTargetNumber )
|
void RollingNumbers::SetTargetNumber( float fTargetNumber )
|
||||||
{
|
{
|
||||||
|
if(!m_metrics_loaded)
|
||||||
|
{
|
||||||
|
LuaHelpers::ReportScriptError("You must use Load to load the metrics for a RollingNumbers actor before doing anything else.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if( fTargetNumber == m_fTargetNumber ) // no change
|
if( fTargetNumber == m_fTargetNumber ) // no change
|
||||||
return;
|
return;
|
||||||
m_fTargetNumber = fTargetNumber;
|
m_fTargetNumber = fTargetNumber;
|
||||||
@@ -109,9 +120,15 @@ void RollingNumbers::SetTargetNumber( float fTargetNumber )
|
|||||||
|
|
||||||
void RollingNumbers::UpdateText()
|
void RollingNumbers::UpdateText()
|
||||||
{
|
{
|
||||||
|
if(!m_metrics_loaded)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
RString s = ssprintf( TEXT_FORMAT.GetValue(), m_fCurrentNumber );
|
RString s = ssprintf( TEXT_FORMAT.GetValue(), m_fCurrentNumber );
|
||||||
if( COMMIFY )
|
if(COMMIFY)
|
||||||
|
{
|
||||||
s = Commify( s );
|
s = Commify( s );
|
||||||
|
}
|
||||||
SetText( s );
|
SetText( s );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ private:
|
|||||||
float m_fTargetNumber;
|
float m_fTargetNumber;
|
||||||
/** @brief The speed we are trying to reach the target number. */
|
/** @brief The speed we are trying to reach the target number. */
|
||||||
float m_fScoreVelocity;
|
float m_fScoreVelocity;
|
||||||
|
bool m_metrics_loaded;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user