mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-03 21:45:32 +02:00
misc additions
This commit is contained in:
parent
5b8d9e0100
commit
d63f9958a3
4 changed files with 51 additions and 10 deletions
|
@ -112,6 +112,10 @@ mkxp-z provides limited support for some WinAPI functions that would normally br
|
|||
|
||||
## Nonstandard RGSS extensions
|
||||
|
||||
### Kernel
|
||||
|
||||
* `load_data` now has a second optional `Boolean` argument which, if set to true, returns the contents of the file as a string (rather than trying to load it with Marshal first).
|
||||
|
||||
### Input
|
||||
|
||||
* The `Input.press?` family of functions accepts three additional button constants: `::MOUSELEFT`, `::MOUSEMIDDLE` and `::MOUSERIGHT` for the respective mouse buttons. It will now also accept [SDL scancodes](https://wiki.libsdl.org/SDL_Scancode?highlight=%28%5CbCategoryEnum%5Cb%29%7C%28CategoryKeyboard%29) in the form of symbols corresponding to each scancode (e.g. `SDL_SCANCODE_RETURN` would be requested through `Input.press?/trigger?/repeat? :RETURN`)
|
||||
|
@ -149,6 +153,8 @@ mkxp-z provides limited support for some WinAPI functions that would normally br
|
|||
* `game_title` returns the game's title as set in its ini.
|
||||
* `power_state` returns a hash with the system power state information. Its members are `:discharging` (Boolean), `:percent` (int/nil), and `:seconds` (int/nil)
|
||||
* `show_settings` displays the keybinding menu.
|
||||
* `nproc` returns the amount of logical cores available to the system.
|
||||
* `memory` returns the total amount of RAM detected by the system in megabytes.
|
||||
|
||||
### Discord
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
#include <SDL_filesystem.h>
|
||||
#include <SDL_power.h>
|
||||
#include <SDL_cpuinfo.h>
|
||||
|
||||
#ifdef __WIN32__
|
||||
#define NULL_IO "NUL"
|
||||
|
@ -107,6 +108,8 @@ RB_METHOD(mkxpUserLanguage);
|
|||
RB_METHOD(mkxpGameTitle);
|
||||
RB_METHOD(mkxpPowerState);
|
||||
RB_METHOD(mkxpSettingsMenu);
|
||||
RB_METHOD(mkxpCpuCount);
|
||||
RB_METHOD(mkxpSystemMemory);
|
||||
|
||||
RB_METHOD(mriRgssMain);
|
||||
RB_METHOD(mriRgssStop);
|
||||
|
@ -186,6 +189,8 @@ static void mriBindingInit()
|
|||
_rb_define_module_function(mod, "user_language", mkxpUserLanguage);
|
||||
_rb_define_module_function(mod, "game_title", mkxpGameTitle);
|
||||
_rb_define_module_function(mod, "power_state", mkxpPowerState);
|
||||
_rb_define_module_function(mod, "nproc", mkxpCpuCount);
|
||||
_rb_define_module_function(mod, "memory", mkxpSystemMemory);
|
||||
|
||||
/* Load global constants */
|
||||
rb_gv_set("MKXP", Qtrue);
|
||||
|
@ -344,6 +349,20 @@ RB_METHOD(mkxpSettingsMenu)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(mkxpCpuCount)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return INT2NUM(SDL_GetCPUCount());
|
||||
}
|
||||
|
||||
RB_METHOD(mkxpSystemMemory)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return INT2NUM(SDL_GetSystemRAM());
|
||||
}
|
||||
|
||||
static VALUE rgssMainCb(VALUE block)
|
||||
{
|
||||
rb_funcall2(block, rb_intern("call"), 0, 0);
|
||||
|
@ -476,7 +495,7 @@ static void runCustomScript(const std::string &filename)
|
|||
newStringUTF8(filename.c_str(), filename.size()), NULL);
|
||||
}
|
||||
|
||||
VALUE kernelLoadDataInt(const char *filename, bool rubyExc);
|
||||
VALUE kernelLoadDataInt(const char *filename, bool rubyExc, bool raw);
|
||||
|
||||
struct BacktraceData
|
||||
{
|
||||
|
@ -511,7 +530,7 @@ static void runRMXPScripts(BacktraceData &btData)
|
|||
* still go wrong */
|
||||
try
|
||||
{
|
||||
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false);
|
||||
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false, false);
|
||||
}
|
||||
catch (const Exception &e)
|
||||
{
|
||||
|
|
|
@ -145,17 +145,24 @@ RB_METHOD(fileIntPos)
|
|||
}
|
||||
|
||||
VALUE
|
||||
kernelLoadDataInt(const char *filename, bool rubyExc)
|
||||
kernelLoadDataInt(const char *filename, bool rubyExc, bool raw)
|
||||
{
|
||||
rb_gc_start();
|
||||
|
||||
VALUE port = fileIntForPath(filename, rubyExc);
|
||||
|
||||
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
||||
VALUE result;
|
||||
if (!raw)
|
||||
{
|
||||
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
||||
|
||||
// FIXME need to catch exceptions here with begin rescue
|
||||
VALUE data = fileIntRead(0, 0, port);
|
||||
VALUE result = rb_funcall2(marsh, rb_intern("load"), 1, &data);
|
||||
// FIXME need to catch exceptions here with begin rescue
|
||||
VALUE data = fileIntRead(0, 0, port);
|
||||
result = rb_funcall2(marsh, rb_intern("load"), 1, &data);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = fileIntRead(0, 0, port);
|
||||
}
|
||||
|
||||
rb_funcall2(port, rb_intern("close"), 0, NULL);
|
||||
|
||||
|
@ -167,7 +174,8 @@ RB_METHOD(kernelLoadData)
|
|||
RB_UNUSED_PARAM;
|
||||
|
||||
VALUE filename;
|
||||
rb_get_args(argc, argv, "S", &filename RB_ARG_END);
|
||||
bool raw = false;
|
||||
rb_get_args(argc, argv, "S|b", &filename, &raw RB_ARG_END);
|
||||
|
||||
// Until a faster method for getting RGSSAD data is
|
||||
// written (could just copy RMXP, keeping stuff in
|
||||
|
@ -186,7 +194,7 @@ RB_METHOD(kernelLoadData)
|
|||
rb_funcall(f, rb_intern("close"), 0);
|
||||
return ret;
|
||||
}
|
||||
return kernelLoadDataInt(RSTRING_PTR(filename), true);
|
||||
return kernelLoadDataInt(RSTRING_PTR(filename), true, raw);
|
||||
}
|
||||
|
||||
RB_METHOD(kernelSaveData)
|
||||
|
|
|
@ -389,8 +389,16 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
joystickConnected = true;
|
||||
|
||||
hap = SDL_HapticOpenFromJoystick(js);
|
||||
Debug() << (hap ? "true" : "false");
|
||||
if (hap && (SDL_HapticQuery(hap) & SDL_HAPTIC_SINE))
|
||||
{
|
||||
hapt = hap;
|
||||
Debug() << "Haptic device initialized";
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug() << "No haptic support found";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue