mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-23 14:55:39 +00:00
Increased the amount of custom event arguments from two to four.
This commit is contained in:
parent
0b79c19883
commit
6e24c8d77b
es-core/src
|
@ -3,12 +3,12 @@
|
||||||
// EmulationStation Desktop Edition
|
// EmulationStation Desktop Edition
|
||||||
// Scripting.cpp
|
// Scripting.cpp
|
||||||
//
|
//
|
||||||
// Executes custom scripts for various events in EmulationStation.
|
// Executes custom scripts for various events.
|
||||||
// By calling fireEvent() the scripts inside the directory corresponding to the
|
// By calling fireEvent() the scripts inside the directory corresponding to the
|
||||||
// argument 'eventName' will be executed with arg1 and arg2 as the script arguments.
|
// argument "eventName" will be executed with arg1, arg2, arg3 and arg4 as arguments.
|
||||||
//
|
//
|
||||||
// The scripts are searched for in ~/.emulationstation/scripts/<eventName>
|
// The scripts are searched for in ~/.emulationstation/scripts/<eventName>
|
||||||
// For example, if the event is called 'game-start', all scripts inside the directory
|
// For example, if the event is called "game-start", all scripts inside the directory
|
||||||
// ~/.emulationstation/scripts/game-start/ will be executed.
|
// ~/.emulationstation/scripts/game-start/ will be executed.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -21,13 +21,17 @@
|
||||||
|
|
||||||
namespace Scripting
|
namespace Scripting
|
||||||
{
|
{
|
||||||
void fireEvent(const std::string& eventName, const std::string& arg1, const std::string& arg2)
|
void fireEvent(const std::string& eventName,
|
||||||
|
const std::string& arg1,
|
||||||
|
const std::string& arg2,
|
||||||
|
const std::string& arg3,
|
||||||
|
const std::string& arg4)
|
||||||
{
|
{
|
||||||
if (!Settings::getInstance()->getBool("CustomEventScripts"))
|
if (!Settings::getInstance()->getBool("CustomEventScripts"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LOG(LogDebug) << "Scripting::fireEvent(): " << eventName << " \"" << arg1 << "\" \"" << arg2
|
LOG(LogDebug) << "Scripting::fireEvent(): " << eventName << " \"" << arg1 << "\" \"" << arg2
|
||||||
<< "\"";
|
<< "\" \"" << arg3 << "\" \"" << arg4 << "\"";
|
||||||
|
|
||||||
std::list<std::string> scriptDirList;
|
std::list<std::string> scriptDirList;
|
||||||
std::string scriptDir;
|
std::string scriptDir;
|
||||||
|
@ -42,12 +46,18 @@ namespace Scripting
|
||||||
for (auto it = scripts.cbegin(); it != scripts.cend(); ++it) {
|
for (auto it = scripts.cbegin(); it != scripts.cend(); ++it) {
|
||||||
std::string arg1Quotation;
|
std::string arg1Quotation;
|
||||||
std::string arg2Quotation;
|
std::string arg2Quotation;
|
||||||
|
std::string arg3Quotation;
|
||||||
|
std::string arg4Quotation;
|
||||||
// Add quotation marks around the arguments as long as these are not already
|
// Add quotation marks around the arguments as long as these are not already
|
||||||
// present (i.e. for arguments with spaces in them).
|
// present (i.e. for arguments with spaces in them).
|
||||||
if (arg1.front() != '\"')
|
if (!arg1.empty() && arg1.front() != '\"')
|
||||||
arg1Quotation = "\"";
|
arg1Quotation = "\"";
|
||||||
if (arg2.front() != '\"')
|
if (!arg2.empty() && arg2.front() != '\"')
|
||||||
arg2Quotation = "\"";
|
arg2Quotation = "\"";
|
||||||
|
if (!arg3.empty() && arg3.front() != '\"')
|
||||||
|
arg3Quotation = "\"";
|
||||||
|
if (!arg4.empty() && arg4.front() != '\"')
|
||||||
|
arg4Quotation = "\"";
|
||||||
std::string script;
|
std::string script;
|
||||||
script.append(*it)
|
script.append(*it)
|
||||||
.append(" ")
|
.append(" ")
|
||||||
|
@ -57,7 +67,15 @@ namespace Scripting
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append(arg2Quotation)
|
.append(arg2Quotation)
|
||||||
.append(arg2)
|
.append(arg2)
|
||||||
.append(arg2Quotation);
|
.append(arg2Quotation)
|
||||||
|
.append(" ")
|
||||||
|
.append(arg3Quotation)
|
||||||
|
.append(arg3)
|
||||||
|
.append(arg3Quotation)
|
||||||
|
.append(" ")
|
||||||
|
.append(arg4Quotation)
|
||||||
|
.append(arg4)
|
||||||
|
.append(arg4Quotation);
|
||||||
LOG(LogDebug) << "Executing: " << script;
|
LOG(LogDebug) << "Executing: " << script;
|
||||||
runSystemCommand(script);
|
runSystemCommand(script);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
// EmulationStation Desktop Edition
|
// EmulationStation Desktop Edition
|
||||||
// Scripting.h
|
// Scripting.h
|
||||||
//
|
//
|
||||||
// Executes custom scripts for various events in EmulationStation.
|
// Executes custom scripts for various events.
|
||||||
// By calling fireEvent() the scripts inside the directory corresponding to the
|
// By calling fireEvent() the scripts inside the directory corresponding to the
|
||||||
// argument 'eventName' will be executed with arg1 and arg2 as the script arguments.
|
// argument "eventName" will be executed with arg1, arg2, arg3 and arg4 as arguments.
|
||||||
//
|
//
|
||||||
// The scripts are searched for in ~/.emulationstation/scripts/<eventName>
|
// The scripts are searched for in ~/.emulationstation/scripts/<eventName>
|
||||||
// For example, if the event is called 'game-start', all scripts inside the directory
|
// For example, if the event is called "game-start", all scripts inside the directory
|
||||||
// ~/.emulationstation/scripts/game-start/ will be executed.
|
// ~/.emulationstation/scripts/game-start/ will be executed.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -21,7 +21,9 @@ namespace Scripting
|
||||||
{
|
{
|
||||||
void fireEvent(const std::string& eventName,
|
void fireEvent(const std::string& eventName,
|
||||||
const std::string& arg1 = "",
|
const std::string& arg1 = "",
|
||||||
const std::string& arg2 = "");
|
const std::string& arg2 = "",
|
||||||
}
|
const std::string& arg3 = "",
|
||||||
|
const std::string& arg4 = "");
|
||||||
|
} // namespace Scripting
|
||||||
|
|
||||||
#endif // ES_CORE_SCRIPTING_H
|
#endif // ES_CORE_SCRIPTING_H
|
||||||
|
|
Loading…
Reference in a new issue