Allows override of flycast.lua file (#411)
This commit is contained in:
parent
1057f50f86
commit
417ffc09f8
|
@ -160,4 +160,8 @@ std::array<std::array<Option<MapleDeviceType>, 2>, 4> MapleExpansionDevices {
|
|||
Option<bool> UseRawInput("RawInput", false, "input");
|
||||
#endif
|
||||
|
||||
#ifdef USE_LUA
|
||||
OptionString LuaFileName("LuaFileName", "flycast.lua");
|
||||
#endif
|
||||
|
||||
} // namespace config
|
||||
|
|
|
@ -484,5 +484,9 @@ extern Option<bool> UseRawInput;
|
|||
constexpr bool UseRawInput = false;
|
||||
#endif
|
||||
|
||||
#ifdef USE_LUA
|
||||
extern OptionString LuaFileName;
|
||||
#endif
|
||||
|
||||
} // namespace config
|
||||
|
||||
|
|
|
@ -578,6 +578,19 @@ static void luaRegister(lua_State *L)
|
|||
.endNamespace();
|
||||
}
|
||||
|
||||
static std::string getLuaFile()
|
||||
{
|
||||
std::string initFile;
|
||||
if( !config::LuaFileName.get().empty()){
|
||||
initFile = get_readonly_config_path(config::LuaFileName.get());
|
||||
} else {
|
||||
initFile = get_readonly_config_path("flycast.lua");
|
||||
}
|
||||
|
||||
return initFile;
|
||||
|
||||
}
|
||||
|
||||
static void doExec(const std::string& path)
|
||||
{
|
||||
if (L == nullptr)
|
||||
|
@ -598,7 +611,7 @@ void exec(const std::string& path)
|
|||
|
||||
void init()
|
||||
{
|
||||
std::string initFile = get_readonly_config_path("flycast.lua");
|
||||
std::string initFile = getLuaFile();
|
||||
if (!file_exists(initFile))
|
||||
return;
|
||||
L = luaL_newstate();
|
||||
|
|
|
@ -1965,6 +1965,20 @@ static void gui_display_settings()
|
|||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::EndTabItem();
|
||||
|
||||
#ifdef USE_LUA
|
||||
header("Lua Scripting");
|
||||
{
|
||||
char LuaFileName[256];
|
||||
|
||||
strcpy(LuaFileName, config::LuaFileName.get().c_str());
|
||||
ImGui::InputText("Lua Filename", LuaFileName, sizeof(LuaFileName), ImGuiInputTextFlags_CharsNoBlank, nullptr, nullptr);
|
||||
ImGui::SameLine();
|
||||
ShowHelpMarker("Specify lua filename to use. Should be located in Flycasts root directory. Defaults to flycast.lua when empty.");
|
||||
config::LuaFileName = LuaFileName;
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (ImGui::BeginTabItem("About"))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue