mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-22 23:06:18 +00:00
Allow for easy OS detection within Ruby scripts
This commit is contained in:
parent
e77c7bce4a
commit
77b419d30a
3 changed files with 15 additions and 0 deletions
|
|
@ -107,6 +107,7 @@ void oneshotBindingInit()
|
||||||
VALUE msg = rb_define_module_under(module, "Msg");
|
VALUE msg = rb_define_module_under(module, "Msg");
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
rb_const_set(module, rb_intern("OS"), rb_str_new2(shState->oneshot().os().c_str()));
|
||||||
rb_const_set(module, rb_intern("USER_NAME"), rb_str_new2(shState->oneshot().userName().c_str()));
|
rb_const_set(module, rb_intern("USER_NAME"), rb_str_new2(shState->oneshot().userName().c_str()));
|
||||||
rb_const_set(module, rb_intern("SAVE_PATH"), rb_str_new2(shState->oneshot().savePath().c_str()));
|
rb_const_set(module, rb_intern("SAVE_PATH"), rb_str_new2(shState->oneshot().savePath().c_str()));
|
||||||
rb_const_set(module, rb_intern("DOCS_PATH"), rb_str_new2(shState->oneshot().docsPath().c_str()));
|
rb_const_set(module, rb_intern("DOCS_PATH"), rb_str_new2(shState->oneshot().docsPath().c_str()));
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ struct OneshotPrivate
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
|
|
||||||
// String data
|
// String data
|
||||||
|
std::string os;
|
||||||
std::string lang;
|
std::string lang;
|
||||||
std::string userName;
|
std::string userName;
|
||||||
std::string savePath;
|
std::string savePath;
|
||||||
|
|
@ -183,6 +184,13 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
||||||
p->winPosChanged = false;
|
p->winPosChanged = false;
|
||||||
p->allowExit = true;
|
p->allowExit = true;
|
||||||
p->exiting = false;
|
p->exiting = false;
|
||||||
|
#ifdef OS_W32
|
||||||
|
p->os = "windows";
|
||||||
|
#elif defined OS_OSX
|
||||||
|
p->os = "macos";
|
||||||
|
#else
|
||||||
|
p->os = "linux";
|
||||||
|
#endif
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* USERNAME/DOCS PATH
|
* USERNAME/DOCS PATH
|
||||||
|
|
@ -373,6 +381,11 @@ void Oneshot::update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string &Oneshot::os() const
|
||||||
|
{
|
||||||
|
return p->os;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string &Oneshot::lang() const
|
const std::string &Oneshot::lang() const
|
||||||
{
|
{
|
||||||
return p->lang;
|
return p->lang;
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ public:
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
//Accessors
|
//Accessors
|
||||||
|
const std::string &os() const;
|
||||||
const std::string &lang() const;
|
const std::string &lang() const;
|
||||||
const std::string &userName() const;
|
const std::string &userName() const;
|
||||||
const std::string &savePath() const;
|
const std::string &savePath() const;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue