diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml
index 27c291591a..c2297a38d2 100644
--- a/Docs/Luadoc/Lua.xml
+++ b/Docs/Luadoc/Lua.xml
@@ -925,6 +925,7 @@
+
diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml
index 77370ffcf2..bee1948b6f 100644
--- a/Docs/Luadoc/LuaDocumentation.xml
+++ b/Docs/Luadoc/LuaDocumentation.xml
@@ -2769,6 +2769,9 @@ save yourself some time, copy this for undocumented things:
second argument is an optional table of parameters. It may be omitted or explicitly
set to nil.
+
+ Sets whether logging of messages is enabled. If log is true, all messages that pass through Broadcast (from the engine for from the theme or from anywhere else), will be logged with Trace.
+
diff --git a/Docs/Themerdocs/Examples/Example_Screens/ScreenOptionsExample.ini b/Docs/Themerdocs/Examples/Example_Screens/ScreenOptionsExample.ini
new file mode 100644
index 0000000000..b373987f2c
--- /dev/null
+++ b/Docs/Themerdocs/Examples/Example_Screens/ScreenOptionsExample.ini
@@ -0,0 +1,128 @@
+# Try out this examply by copying these metrics into your metrics.ini.
+
+# Some elements will require entries to be added to the language file. Read Examples/LanguageFile.ini for instructions on adding entries to a language file.
+
+# Setting InitialScreen in the Common section just makes the theme start up in this screen.
+# This is only done for ease of seeing this example in action, and is not part of making an options screen.
+[Common]
+InitialScreen="ScreenOptionsExample"
+
+# The screen must have a metrics section with its name.
+[ScreenOptionsExample]
+# The Fallback metric for the screen should be "ScreenOptionsMaster", to pull in necessary fallback metrics from that section.
+Fallback="ScreenOptionsMaster"
+
+# The ForceAllPlayers metric will force join all players if set.
+# This example sets it because the example runs when players would not otherwise be joined.
+# An options screen that is meant to set song options between song select and gameplay should not set ForceAllPlayers to true.
+ForceAllPlayers=true
+
+# NavigationMode controls how the cursor is used to navigate the screen.
+# If it's not set by the theme, it defaults to the setting in Preferences.ini.
+# "toggle" sets navigation to the preferred toggle style mode. In toggle mode, all options on all rows are treated as on/off toggled options.
+# "menu" sets navigation to the menu style mode. In menu mode, each should have only a single option which sets a new screen when chosen.
+# This example does not set NavigationMode because the default is what it wants.
+# NavigationMode=
+
+# InputMode sets the input mode. This controls whether the players have separate cursors.
+# "individual" means the players' cursors can be separated and move to different options.
+# "together" means both players control the same cursor.
+InputMode="individual"
+
+# LineNames sets the names of the rows on the screen.
+# Names are separated by commas and can be anything that doesn't contain a comma.
+# Each name will be appended to "Line" to find the metric that defines that line. So a line name of "a" will be defined by the metric "Linea".
+LineNames="a,b,c,d,e,f,g,h,i,j,k,l,m,n"
+
+# Each line is defined by a metric that sets its type and arguments for that type.
+# This example is going to include a simple example of each type.
+# The types of option rows are: "list", "lua", "conf", "stepstype", "steps", "gamecommand".
+
+# The "list" row type takes a single argument: The subtype, or the metric that defines the elements of the list.
+# The subtypes of list are: "NoteSkins", "Steps", "StepsLocked", "Characters", "Styles", "Groups", "Difficulties", "SongsInCurrentSongGroup".
+# If the subtype is not one of the above, it is the name of the metric that defines the list.
+
+# This list example will create a list defined by a metric.
+# A list that is defined by a metric requires entries in the language file for the option title and the option explanation.
+# "list,Examples" requires an "Examples" entry in the "OptionTitles" and "OptionExplanations" sections of the language file.
+# When looking for the metric that defines the list, the ScreenOptionsMaster section is searched. See the ScreenOptionsMaster section of this file for an explanation of the body of the list.
+Linea="list,Examples"
+
+# The other list subtypes construct lists of GameCommands that execute specific actions.
+
+# The "NoteSkins" subtype constructs a list out of all noteskins available.
+Lineb="list,NoteSkins"
+
+# The "Steps" subtype constructs a list out of the playable steps for the current song or course. Because this is an example screen and there is no current song set, no steps are in the list when this screen is used.
+Linec="list,Steps"
+# The "StepsLocked" subtype is identical to the "Steps" subtype, but forces all players to make the same choice.
+Lined="list,StepsLocked"
+
+# The "Characters" subtype constructs a list out of the selectable dancers.
+Linee="list,Characters"
+
+# The "Styles" subtype constructs a list ouf of all styles for the current game type.
+Linef="list,Styles"
+
+# The "Groups" subtype constructs a list out of all the song groups.
+Lineg="list,Groups"
+
+# The "Difficulties" subtype constructs a list of the difficulties in the "DifficultiesToShow" metric from the "Common" section.
+Lineh="list,Difficulties"
+
+# The "SongsInCurrentSongGroup" subtype
+Linei="list,SongsInCurrentSongGroup"
+
+# This is the end of the list subtype examples.
+
+# The "lua" row type takes a single argument, a chunk of lua to run which must return a table defining the row. Full explanation of the lua option row type can be found in Examples/OptionRowHandlerLua.lua.
+# This example uses the "ArbitrarySpeedMods()" function just because I like it.
+Linej="lua,ArbitrarySpeedMods()"
+
+# The "steps" row type creates choices for the different charts for the current song. It takes a single argument, "EditSteps" or "EditSourceSteps". Its purpose is currently unknown.
+Linek="steps,EditSteps"
+
+# The "stepstype" row type is related to the "steps" row type and takes the same argument. Its purpose is also unknown.
+Linel="stepstype,EditSteps"
+
+# The "conf" row type constructs a row for changing a conf option. conf options are the options in Preferences.ini and the argument is the name of the option to edit.
+Linem="conf,AllowW1"
+
+# The "gamecommand" row type constructs a row with a single choice from a GameCommand and applies that GameCommand when the choice is chosen.
+# Everything after the "gamecommand;" part of the row command is used to construct the GameCommand.
+# Full documention on GameCommands can be found in gamecommands.txt.
+# This example just makes a GameCommand that does nothing, but has a name.
+Linen="gamecommand;name,ExampleCommand"
+
+
+[ScreenOptionsMaster]
+# The main metric defining the list is a command that sets the number of elements and some flags. All flags are optional, and most commonly will not be used.
+# The number of elements must come first.
+# Flags are separated by semicolons.
+# Arguments to flags are separated by commas.
+# Flags are:
+# "together": Any choice chosen is applied to both players.
+# "selectmultiple": Multiple choices on the row can be chosen.
+# "selectone": One choice on the row can be chosen.
+# "selectnone": No choice on the row can be chosen.
+# selectmultiple, selectone, and selectnone are mutually exclusive. If more than one is set, only the last one applies.
+# "showoneinrow": Only show one choice in the row.
+# "default": Sets the default choice. Takes one argument, the number of the choice. "default,2" makes the second choice the default.
+# "reloadrowmessages": Sets the messages that will cause the row to be reloaded. Arguments are the messages.
+# "enabledforplayers": Sets which players are allowed to use the row. Arguments are numbers.
+# "exportonchange": Sets whether the option is exported every time it changes.
+# "broadcastonexport": Sets the messages that are broadcast when the row is exported. Arguments are the messages.
+# Example line using all flags:
+#Examples="4;together;selectmultiple;showoneinrow;default,3;reloadrowmessages,ExampleReload;enabledforplayers,1,2;exportonchange;broadcastonexport,ExampleExport"
+Examples="4"
+
+# Each choice in the list is defined by a metric. The name of the metric is the name of the list with a comma and the id of the choice.
+# So the first choice in our "Examples" list is defined by the metric "Examples,1".
+# The metric defining a choice is a GameCommand. Full explanation of GameCommands is beyond the scope of this example. This example will only use the "name" part of a GameCommand. See gamecommands.txt for full documentation on GameCommands.
+# The "name" part of a GameCommand sets the name for that GameCommand. There must be an entry for this name in the "OptionNames" section of the language file.
+# A list also needs a Default entry, a command to apply if the none of the choices are selected. It can be empty, and it does not need a name.
+ExamplesDefault=""
+Examples,1="name,Ex1"
+Examples,2="name,Ex2"
+Examples,3="name,Ex3"
+Examples,4="name,Ex4"
diff --git a/Docs/Themerdocs/gamecommands.txt b/Docs/Themerdocs/gamecommands.txt
index 8b2f11a277..bed2c60725 100644
--- a/Docs/Themerdocs/gamecommands.txt
+++ b/Docs/Themerdocs/gamecommands.txt
@@ -1,62 +1,123 @@
-all the known gamecommands (pre-sm-ssc)
+GameCommands are constructed from subcommands separated by semicolons.
+Subcommands are constructed from a command name and its arguments, separated by commas.
+Each command takes its arguments and interprets them to set a property of the GameCommand.
+
+Most of the things that can be done through GameCommands can be done better through other means. GameCommand is kept around for compatibility with older versions and because ScreenOptionsMaster based screens often don't have the ability to use the better ways of doing things for their choices.
+
+Example command:
+"name,Example;screen,ScreenInit"
+This example creates a GameCommand with the name "Example" and its screen property set to "ScreenInit".
+
+When a GameCommand is applied, its properties are used to change things about the game.
+
+The various properties that can be set for a GameCommand are listed below, with their effects when applied.
+
+"announcer"
+Sets the name of the announcer. The argument must be the name of the directoory of the announcer.
+
+"applydefaultoptions"
+Applies the default options to the player. No argument.
+
+"clearcredits"
+Clears any credits that have been inserted. No argument.
+
+"course"
+Sets the current course to the argument.
-"style"
-"playmode"
"difficulty"
+Sets the difficulty property of this GameCommand.
+Acceptable args are:
+Beginner, Easy, Medium, Hard, Challenge, Edit
-"announcer" {m_sAnnouncer = sValue;}
+"fademusic"
+Must have 2 args: The volume to fade out to and the seconds to spread the fade over.
-"name" {m_sName = sValue;}
+"goalcalories"
+Sets the calorie goal of the player.
-"text" {m_sText = sValue;}
+"goaltype"
+Sets the goal type of the player. Types are: Calories, Time, None.
-"mod" {m_sPreferredModifiers += sValue;}
-
-"stagemod" {m_sStageModifiers += sValue;}
+"insertcredit"
+Inserts a credit. No arguments.
"lua"
+Sets a lua function to be run when this GameCommand is applied.
-"screen" {m_sScreen = sValue;}
+"mod"
+Sets a modifier to be applied to the player(s).
+
+"name"
+Sets the name of this GameCommand. For GameCommands used in option rows as choices, this is used to set the text that is shown on screen for the choice.
+
+"playmode"
+The "playmode" game command controls what mode of play the game is in. This is a choice between the normal play mode and the various course or battle modes. The noral effects of the different playmodes are described in playmods.txt, though a theme can check the current playmode and do anything it pleases with that information.
+Acceptable args are:
+Regular, Nonstop, Oni, Endless, Battle, Rave
+
+"preparescreen"
+Prepares the screen named by the argument when the command is applied. PrepareScreen takes time and blocks graphics, so this should not be used for screens that load a lot of data.
+
+"profileid"
+Sets the default local profile ID of the player.
+
+"screen"
+Sets the screen that will be transitioned to when this GameCommand is applied.
+
+"setenv"
+Arguments are "key,value" pairs of environment variables to be set. Only capable of setting string values.
+
+"setpref"
+Must have 2 args: The preference and the value to set it to. Preferences are listed in Preferences.ini.
"song"
-"steps"
-"course"
-"trail"
+Sets the current song. The argument should be of the form "Group/SongName".
-"setenv" {
- if( cmd.m_vsArgs.size() == 3 )
- m_SetEnv[ cmd.m_vsArgs[1] ] = cmd.m_vsArgs[2]; }
-
-"songgroup" {m_sSongGroup = sValue;}
+"songgroup"
+Sets the preferred song group. Does not immediately change the group on the music wheel, but the preferred group is the group that will be open when ScreenSelectMusic starts.
"sort"
-{
- m_SortOrder = StringToSortOrder( sValue );
- if( m_SortOrder == SortOrder_Invalid )
- {
- m_sInvalidReason = ssprintf( "SortOrder \"%s\" is not valid.", sValue.c_str() );
- m_bInvalid |= true;
- }
-}
+Sets the sort order. Does not immediately change the sort on the music wheel, but the sort is the sort that will be used when ScreenSelectMusic starts.
+Sort names are:
+Preferred, Group, Title, BPM, Popularity, TopGrades, Artist, Genre, BeginnerMeter, EasyMeter, MediumMeter, HardMeter, ChallengeMeter, DoubleBeginnerMeter, DoubleEasyMeter, DoubleMediumMeter, DoubleHardMeter, DoubleChallengeMeter, ModeMenu, AllCourses, Nonstop, Oni, Endless, Length, Roulette, Recent.
-"weight" {m_iWeightPounds = atoi( sValue );}
+"sound"
+Plays the sound at the path once.
-"goalcalories" {m_iGoalCalories = atoi( sValue );}
+"stagemod"
+Sets a modifier to be applied to the stagemods.
-"goaltype" {m_GoalType = StringToGoalType( sValue );}
+"steps"
+Sets the current steps to the steps at the specified difficulty for the current song. Emits an error if the song or the style is not already set when the GameCommand is parsed.
-"profileid" {m_sProfileID = sValue;}
+"stopmusic"
+Stops the music that is currently playing. No argument.
-"url" {m_sUrl = sValue;}
+"style"
+The "style" command is used to set the style of the game. The style of the game controls how many pads/players are used. Acceptable args depend on the game type.
+For dance: single, versus, double, couple, solo, couple-edit, threepanel, routine
+For pump: single, versus, halfdouble, double, couple, couple-edit, routine
+For kb7: single, versus
+For ez2: single, real, versus, versusReal, double
+For para: single, versus
+For ds3ddx: single
+For beat: single5, versus5, double5, single7, versus7, double7
+For maniax: single, versus, double
+For techno: single4, single5, single8, versus4, versus5, versus8, double4, double5, double8
+For popn: popn-five, popn-nine
+For lights: cabinet
-"sound" {m_sSoundPath = sValue;}
+"text"
+Sets the text property of the GameCommand. This is an alternative to the name field used by some screens.
-"preparescreen" {m_vsScreensToPrepare.push_back( sValue );}
+"trail"
+Sets the current trail to the trail at the specified difficulty for the current course. Emits an error if the course or the style is not already set when the GameCommand is parsed.
-"insertcredit" {m_bInsertCredit = true;}
+"url"
+Exits the game and launches a browser to visit the url.
-"clearcredits" {m_bClearCredits = true;}
+"urlnoexit"
+Launches a browser to visit the url.
-"stopmusic" {m_bStopMusic = true;}
-
-"applydefaultoptions" {m_bApplyDefaultOptions = true;}
\ No newline at end of file
+"weight"
+Sets the weight of the player.
diff --git a/Themes/_fallback/BGAnimations/ScreenSystemLayer error.lua b/Themes/_fallback/BGAnimations/ScreenSystemLayer error.lua
index 4a675d2875..fed9f3808b 100644
--- a/Themes/_fallback/BGAnimations/ScreenSystemLayer error.lua
+++ b/Themes/_fallback/BGAnimations/ScreenSystemLayer error.lua
@@ -77,7 +77,6 @@ function SetErrorMessageTime(which, t)
" time to below minimum of " .. min_message_time[which] .. "."})
return
end
- Trace("Setting error message " .. which .. " time to " .. t)
message_time[which]= t
end
@@ -113,7 +112,11 @@ local frame_args= {
if i > 1 and text_actors[i-1] then
text_actors[i]:settext(text_actors[i-1]:GetText())
else
- text_actors[i]:settext(params.Message)
+ -- Someone long ago decided that it was a good idea for "::" to be
+ -- a synonym for "\n", so that strings in metrics could have line
+ -- breaks.
+ -- So replace "::" with ":" so we don't have unwanted line breaks.
+ text_actors[i]:settext(params.Message:gsub("::", ":"))
end
width_clip_limit_text(text_actors[i], line_width)
end
diff --git a/src/Command.cpp b/src/Command.cpp
index a0332f037b..cb004a53f2 100644
--- a/src/Command.cpp
+++ b/src/Command.cpp
@@ -83,7 +83,13 @@ RString Commands::GetOriginalCommandString() const
{
RString s;
FOREACH_CONST( Command, v, c )
+ {
+ if(s != "")
+ {
+ s += ";";
+ }
s += c->GetOriginalCommandString();
+ }
return s;
}
diff --git a/src/CommonMetrics.cpp b/src/CommonMetrics.cpp
index 3635dd72a1..c8752192d8 100644
--- a/src/CommonMetrics.cpp
+++ b/src/CommonMetrics.cpp
@@ -44,8 +44,13 @@ void ThemeMetricDifficultiesToShow::Read()
{
Difficulty d = StringToDifficulty( *i );
if( d == Difficulty_Invalid )
- RageException::Throw( "Unknown difficulty \"%s\" in CourseDifficultiesToShow.", i->c_str() );
- m_v.push_back( d );
+ {
+ LuaHelpers::ReportScriptErrorFmt("Unknown difficulty \"%s\" in CourseDifficultiesToShow.", i->c_str());
+ }
+ else
+ {
+ m_v.push_back( d );
+ }
}
}
const vector& ThemeMetricDifficultiesToShow::GetValue() const { return m_v; }
@@ -74,8 +79,13 @@ void ThemeMetricCourseDifficultiesToShow::Read()
{
CourseDifficulty d = StringToDifficulty( *i );
if( d == Difficulty_Invalid )
- RageException::Throw( "Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow.", i->c_str() );
- m_v.push_back( d );
+ {
+ LuaHelpers::ReportScriptErrorFmt("Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow.", i->c_str());
+ }
+ else
+ {
+ m_v.push_back( d );
+ }
}
}
const vector& ThemeMetricCourseDifficultiesToShow::GetValue() const { return m_v; }
diff --git a/src/CourseContentsList.cpp b/src/CourseContentsList.cpp
index 2566465c15..8475b05547 100644
--- a/src/CourseContentsList.cpp
+++ b/src/CourseContentsList.cpp
@@ -26,7 +26,9 @@ void CourseContentsList::LoadFromNode( const XNode* pNode )
const XNode *pDisplayNode = pNode->GetChild( "Display" );
if( pDisplayNode == NULL )
- RageException::Throw( "%s: CourseContentsList: missing the Display child", ActorUtil::GetWhere(pNode).c_str() );
+ {
+ LuaHelpers::ReportScriptErrorFmt("%s: CourseContentsList: missing the Display child", ActorUtil::GetWhere(pNode).c_str());
+ }
for( int i=0; iGetChild( ssprintf("CursorP%i",pn+1) );
if( pChild == NULL )
- RageException::Throw( "%s: StepsDisplayList: missing the node \"CursorP%d\"", ActorUtil::GetWhere(pNode).c_str(), pn+1 );
- m_Cursors[pn].LoadActorFromNode( pChild, this );
+ {
+ LuaHelpers::ReportScriptErrorFmt("%s: StepsDisplayList: missing the node \"CursorP%d\"", ActorUtil::GetWhere(pNode).c_str(), pn+1);
+ }
+ else
+ {
+ m_Cursors[pn].LoadActorFromNode( pChild, this );
+ }
/* Hack: we need to tween cursors both up to down (cursor motion) and visible to
* invisible (fading). Cursor motion needs to stoptweening, so multiple motions
@@ -62,10 +67,15 @@ void StepsDisplayList::LoadFromNode( const XNode* pNode )
* colors; I think we do need a diffuse color stack ... */
pChild = pNode->GetChild( ssprintf("CursorP%iFrame",pn+1) );
if( pChild == NULL )
- RageException::Throw( "%s: StepsDisplayList: missing the node \"CursorP%dFrame\"", ActorUtil::GetWhere(pNode).c_str(), pn+1 );
- m_CursorFrames[pn].LoadFromNode( pChild );
- m_CursorFrames[pn].AddChild( m_Cursors[pn] );
- this->AddChild( &m_CursorFrames[pn] );
+ {
+ LuaHelpers::ReportScriptErrorFmt("%s: StepsDisplayList: missing the node \"CursorP%dFrame\"", ActorUtil::GetWhere(pNode).c_str(), pn+1);
+ }
+ else
+ {
+ m_CursorFrames[pn].LoadFromNode( pChild );
+ m_CursorFrames[pn].AddChild( m_Cursors[pn] );
+ this->AddChild( &m_CursorFrames[pn] );
+ }
}
for( unsigned m = 0; m < m_Lines.size(); ++m )
diff --git a/src/GameCommand.cpp b/src/GameCommand.cpp
index dbda6baa2b..02be6d13d0 100644
--- a/src/GameCommand.cpp
+++ b/src/GameCommand.cpp
@@ -251,7 +251,7 @@ void GameCommand::LoadOne( const Command& cmd )
if( m_pSong == NULL )
{
m_sInvalidReason = ssprintf( "Song \"%s\" not found", sValue.c_str() );
- m_bInvalid |= true;
+ m_bInvalid = true;
}
}
@@ -265,17 +265,23 @@ void GameCommand::LoadOne( const Command& cmd )
Song *pSong = (m_pSong != NULL)? m_pSong:GAMESTATE->m_pCurSong;
const Style *pStyle = m_pStyle ? m_pStyle : GAMESTATE->GetCurrentStyle();
if( pSong == NULL || pStyle == NULL )
- RageException::Throw( "Must set Song and Style to set Steps." );
-
- Difficulty dc = StringToDifficulty( sSteps );
- if( dc != Difficulty_Edit )
- m_pSteps = SongUtil::GetStepsByDifficulty( pSong, pStyle->m_StepsType, dc );
- else
- m_pSteps = SongUtil::GetStepsByDescription( pSong, pStyle->m_StepsType, sSteps );
- if( m_pSteps == NULL )
{
- m_sInvalidReason = "steps not found";
- m_bInvalid |= true;
+ LuaHelpers::ReportScriptError("Must set Song and Style to set Steps.");
+ m_sInvalidReason = "Song or Style not set";
+ m_bInvalid = true;
+ }
+ else
+ {
+ Difficulty dc = StringToDifficulty( sSteps );
+ if( dc != Difficulty_Edit )
+ m_pSteps = SongUtil::GetStepsByDifficulty( pSong, pStyle->m_StepsType, dc );
+ else
+ m_pSteps = SongUtil::GetStepsByDescription( pSong, pStyle->m_StepsType, sSteps );
+ if( m_pSteps == NULL )
+ {
+ m_sInvalidReason = "steps not found";
+ m_bInvalid = true;
+ }
}
}
}
@@ -286,7 +292,7 @@ void GameCommand::LoadOne( const Command& cmd )
if( m_pCourse == NULL )
{
m_sInvalidReason = ssprintf( "Course \"%s\" not found", sValue.c_str() );
- m_bInvalid |= true;
+ m_bInvalid = true;
}
}
@@ -300,16 +306,22 @@ void GameCommand::LoadOne( const Command& cmd )
Course *pCourse = (m_pCourse != NULL)? m_pCourse:GAMESTATE->m_pCurCourse;
const Style *pStyle = m_pStyle ? m_pStyle : GAMESTATE->GetCurrentStyle();
if( pCourse == NULL || pStyle == NULL )
- RageException::Throw( "Must set Course and Style to set Steps." );
-
- const CourseDifficulty cd = StringToDifficulty( sTrail );
- ASSERT_M( cd != Difficulty_Invalid, ssprintf("Invalid difficulty '%s'", sTrail.c_str()) );
-
- m_pTrail = pCourse->GetTrail( pStyle->m_StepsType, cd );
- if( m_pTrail == NULL )
{
- m_sInvalidReason = "trail not found";
- m_bInvalid |= true;
+ LuaHelpers::ReportScriptError("Must set Course and Style to set Trail.");
+ m_sInvalidReason = "Course or Style not set";
+ m_bInvalid = true;
+ }
+ else
+ {
+ const CourseDifficulty cd = StringToDifficulty( sTrail );
+ ASSERT_M( cd != Difficulty_Invalid, ssprintf("Invalid difficulty '%s'", sTrail.c_str()) );
+
+ m_pTrail = pCourse->GetTrail( pStyle->m_StepsType, cd );
+ if( m_pTrail == NULL )
+ {
+ m_sInvalidReason = "trail not found";
+ m_bInvalid = true;
+ }
}
}
}
@@ -331,7 +343,7 @@ void GameCommand::LoadOne( const Command& cmd )
if( m_SortOrder == SortOrder_Invalid )
{
m_sInvalidReason = ssprintf( "SortOrder \"%s\" is not valid.", sValue.c_str() );
- m_bInvalid |= true;
+ m_bInvalid = true;
}
}
@@ -406,7 +418,7 @@ void GameCommand::LoadOne( const Command& cmd )
if( pPref == NULL )
{
m_sInvalidReason = ssprintf("unknown preference \"%s\"", cmd.m_vsArgs[1].c_str() );
- m_bInvalid |= true;
+ m_bInvalid = true;
}
pPref->FromString(cmd.m_vsArgs[2]);
}
diff --git a/src/GameState.cpp b/src/GameState.cpp
index ba4da3ce06..0436e65a43 100644
--- a/src/GameState.cpp
+++ b/src/GameState.cpp
@@ -222,7 +222,10 @@ void GameState::ApplyGameCommand( const RString &sCommand, PlayerNumber pn )
RString sWhy;
if( !m.IsPlayable(&sWhy) )
- RageException::Throw( "Can't apply mode \"%s\": %s", sCommand.c_str(), sWhy.c_str() );
+ {
+ LuaHelpers::ReportScriptErrorFmt("Can't apply mode \"%s\": %s", sCommand.c_str(), sWhy.c_str());
+ return;
+ }
if( pn == PLAYER_INVALID )
m.ApplyToAllPlayers();
diff --git a/src/HoldJudgment.cpp b/src/HoldJudgment.cpp
index bfd0f04a1f..eefa50632f 100644
--- a/src/HoldJudgment.cpp
+++ b/src/HoldJudgment.cpp
@@ -28,7 +28,9 @@ void HoldJudgment::LoadFromNode( const XNode* pNode )
{
RString sFile;
if( ActorUtil::GetAttrPath(pNode, "File", sFile) )
- RageException::Throw( "%s: HoldJudgment: missing the attribute \"File\"", ActorUtil::GetWhere(pNode).c_str() );
+ {
+ LuaHelpers::ReportScriptErrorFmt("%s: HoldJudgment: missing the attribute \"File\"", ActorUtil::GetWhere(pNode).c_str());
+ }
CollapsePath( sFile );
diff --git a/src/LuaManager.cpp b/src/LuaManager.cpp
index 19827f0223..e76a7d8321 100644
--- a/src/LuaManager.cpp
+++ b/src/LuaManager.cpp
@@ -47,6 +47,8 @@ namespace LuaHelpers
template<> bool FromStack( Lua *L, float &Object, int iOffset );
template<> bool FromStack( Lua *L, int &Object, int iOffset );
template<> bool FromStack( Lua *L, RString &Object, int iOffset );
+
+ bool InReportScriptError= false;
}
void LuaManager::SetGlobal( const RString &sName, int val )
@@ -789,7 +791,14 @@ bool LuaHelpers::LoadScript( Lua *L, const RString &sScript, const RString &sNam
return true;
}
-void LuaHelpers::ReportScriptError(RString const& Error, RString ErrorType)
+void LuaHelpers::ScriptErrorMessage(RString const& Error)
+{
+ Message msg("ScriptError");
+ msg.SetParam("Message", Error);
+ MESSAGEMAN->Broadcast(msg);
+}
+
+Dialog::Result LuaHelpers::ReportScriptError(RString const& Error, RString ErrorType, bool UseAbort)
{
size_t line_break_pos= Error.find('\n');
RString short_error;
@@ -801,11 +810,21 @@ void LuaHelpers::ReportScriptError(RString const& Error, RString ErrorType)
{
short_error= Error.substr(0, line_break_pos);
}
- Message msg("ScriptError");
- msg.SetParam("Message", short_error);
- MESSAGEMAN->Broadcast(msg);
+ // Protect from a recursion loop resulting from a mistake in the error reporting lua.
+ if(!InReportScriptError)
+ {
+ InReportScriptError= true;
+ ScriptErrorMessage(short_error);
+ InReportScriptError= false;
+ }
LOG->Warn(Error.c_str());
+ if(UseAbort)
+ {
+ RString with_correct= Error + " Correct this and click Retry, or Cancel to break.";
+ return Dialog::AbortRetryIgnore(with_correct, ErrorType);
+ }
Dialog::OK(Error, ErrorType);
+ return Dialog::ok;
}
// For convenience when replacing uses of LOG->Warn.
diff --git a/src/LuaManager.h b/src/LuaManager.h
index 8fc8d820aa..644780eb67 100644
--- a/src/LuaManager.h
+++ b/src/LuaManager.h
@@ -15,6 +15,9 @@ extern "C"
#include "../extern/lua-5.1/src/lauxlib.h"
}
+// For Dialog::Result
+#include "arch/Dialog/Dialog.h"
+
class LuaManager
{
public:
@@ -58,8 +61,14 @@ namespace LuaHelpers
* and the stack is unchanged. */
bool LoadScript( Lua *L, const RString &sScript, const RString &sName, RString &sError );
- /* Report the error through the log and on the screen. */
- void ReportScriptError(RString const& Error, RString ErrorType= "LUA_ERROR");
+ /* Report the error three ways: Broadcast message, Warn, and Dialog. */
+ /* If UseAbort is true, reports the error through Dialog::AbortRetryIgnore
+ and returns the result. */
+ /* If UseAbort is false, reports the error through Dialog::OK and returns
+ Dialog::ok. */
+ Dialog::Result ReportScriptError(RString const& Error, RString ErrorType= "LUA_ERROR", bool UseAbort= false);
+ // Just the broadcast message part, for things that need to do the rest differently.
+ void ScriptErrorMessage(RString const& Error);
// For convenience when replacing uses of LOG->Warn.
void ReportScriptErrorFmt(const char *fmt, ...);
diff --git a/src/MessageManager.cpp b/src/MessageManager.cpp
index 6f4ffcda29..021b3100cb 100644
--- a/src/MessageManager.cpp
+++ b/src/MessageManager.cpp
@@ -5,6 +5,7 @@
#include "RageThreads.h"
#include "EnumHelper.h"
#include "LuaManager.h"
+#include "RageLog.h"
#include
#include