add get_mse_path script function

This commit is contained in:
GenevensiS
2025-05-22 12:39:09 +02:00
parent 94369f5969
commit c577417191
4 changed files with 19 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
Function: get_mse_path
--Usage--
> get_mse_path()
Returns the current MSE app folder absolute path.
+1
View File
@@ -113,6 +113,7 @@ These functions are built into the program, other [[type:function]]s can be defi
! Other functions <<<
| [[fun:get_mse_version]] Get the MSE app version.
| [[fun:get_mse_path]] Get the MSE app folder absolute path.
| [[fun:trace]] Output a message for debugging purposes.
| [[fun:assert]] Check a condition for debugging purposes.
| [[fun:warning]] Output a warning message.
+11
View File
@@ -19,6 +19,9 @@
#include <data/card.hpp>
#include <data/game.hpp>
#include <random>
#include <wx/filename.h>
#include <wx/stdpaths.h>
// ----------------------------------------------------------------------------- : Debugging
@@ -26,6 +29,13 @@ SCRIPT_FUNCTION(get_mse_version) {
SCRIPT_RETURN(app_version.toString());
}
SCRIPT_FUNCTION(get_mse_path) {
wxFileName app_path(wxStandardPaths::Get().GetExecutablePath());
String app_folder = app_path.GetPath();
app_folder.Replace("\\", "/");
SCRIPT_RETURN(app_folder);
}
SCRIPT_FUNCTION(trace) {
SCRIPT_PARAM_C(String, input);
#if defined(_DEBUG) && 0
@@ -770,6 +780,7 @@ SCRIPT_FUNCTION(rule) {
void init_script_basic_functions(Context& ctx) {
// debugging
ctx.setVariable(_("get_mse_version"), script_get_mse_version);
ctx.setVariable(_("get_mse_path"), script_get_mse_path);
ctx.setVariable(_("trace"), script_trace);
ctx.setVariable(_("warning"), script_warning);
ctx.setVariable(_("error"), script_error);
@@ -104,6 +104,7 @@ $built_in_functions = array(
'write_set_file' =>'',
// other
'get_mse_version' =>'',
'get_mse_path' =>'',
'trace' =>'',
'assert' =>'',
'exists_in_package' =>'',