Verbose logging, bugs fixes, minor changes, one SEGFAULT fix(sunshine bindings) and other i dont rememberrrrrrrrrr

This commit is contained in:
ZakatTeamI2P 2026-04-28 21:43:24 +04:00
parent 8970eeb62e
commit 4eba89fd0c
27 changed files with 304 additions and 421 deletions

View file

@ -12,8 +12,8 @@ option(DEBUG "Debug mode" ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
#i want die #i want die
# set(DEBUG_C_FLAGS "-g -O0 -fno-omit-frame-pointer -ggdb") set(DEBUG_C_FLAGS "-g -O0 -fno-omit-frame-pointer -ggdb")
# set(DEBUG_CXX_FLAGS "-g -O0 -fno-omit-frame-pointer -ggdb") set(DEBUG_CXX_FLAGS "-g -O0 -fno-omit-frame-pointer -ggdb")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_C_FLAGS}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_C_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_CXX_FLAGS}")

View file

@ -117,7 +117,7 @@ DEF_AUD_PROP_I(SFX_Volume)
RB_METHOD(audioReset){ RB_METHOD(audioReset){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
printf("[audioReset] Reseting audio\n");
shState->audio().reset(); shState->audio().reset();
return Qnil; return Qnil;
@ -144,8 +144,8 @@ RB_METHOD(audioReset){
_rb_define_module_function(module, prop_name_s "=", audio##Set##PropName); \ _rb_define_module_function(module, prop_name_s "=", audio##Set##PropName); \
} }
void void audioBindingInit(){
audioBindingInit(){ printf("[audioBindingInit] Initialing Audio binding\n");
VALUE module = rb_define_module("Audio"); VALUE module = rb_define_module("Audio");
BIND_PLAY_STOP_FADE( bgm ); BIND_PLAY_STOP_FADE( bgm );
@ -163,4 +163,5 @@ audioBindingInit(){
INIT_AUD_PROP_BIND( BGM_Volume, "bgm_volume" ); INIT_AUD_PROP_BIND( BGM_Volume, "bgm_volume" );
INIT_AUD_PROP_BIND( SFX_Volume, "sfx_volume" ); INIT_AUD_PROP_BIND( SFX_Volume, "sfx_volume" );
printf("[audioBindingInit] Done\n");
} }

View file

@ -95,6 +95,7 @@ RB_METHOD(mriRgssStop);
RB_METHOD(_kernelCaller); RB_METHOD(_kernelCaller);
static void mriBindingInit(){ static void mriBindingInit(){
printf("[mriBindingInit] Loading bindings...\n");
tableBindingInit(); tableBindingInit();
etcBindingInit(); etcBindingInit();
fontBindingInit(); fontBindingInit();
@ -118,7 +119,8 @@ static void mriBindingInit(){
SunshineBindingInit(); SunshineBindingInit();
steamBindingInit(); steamBindingInit();
chromaBindingInit(); chromaBindingInit();
printf("[mriBindingInit] Done\n");
printf("[mriBindingInit] RGSS version: %i\n", rgssVer);
if (rgssVer >= 3){ if (rgssVer >= 3){
_rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain); _rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain);
_rb_define_module_function(rb_mKernel, "rgss_stop", mriRgssStop); _rb_define_module_function(rb_mKernel, "rgss_stop", mriRgssStop);
@ -243,6 +245,7 @@ static VALUE rgssMainRescue(VALUE arg, VALUE exc){
} }
static void processReset(){ static void processReset(){
printf("[processReset]\n");
shState->graphics().reset(); shState->graphics().reset();
shState->audio().reset(); shState->audio().reset();
@ -257,7 +260,6 @@ static VALUE rgssMainRescue_wrapper(VALUE data, VALUE ex){ return rgssMainRescue
RB_METHOD(mriRgssMain){ RB_METHOD(mriRgssMain){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
while (true){ while (true){
VALUE exc = Qnil; VALUE exc = Qnil;
@ -362,11 +364,13 @@ static void runRMXPScripts(BacktraceData &btData){
const std::string &scriptPack = conf.game.scripts; const std::string &scriptPack = conf.game.scripts;
if (scriptPack.empty()){ if (scriptPack.empty()){
printf("[runRMXPScripts] No game scripts specified (missing Game.ini?)\n");
showMsg("No game scripts specified (missing Game.ini?)"); showMsg("No game scripts specified (missing Game.ini?)");
return; return;
} }
if (!shState->fileSystem().exists(scriptPack.c_str())){ if (!shState->fileSystem().exists(scriptPack.c_str())){
printf("[runRMXPScripts] Unable to open %s\n", scriptPack);
showMsg("Unable to open '" + scriptPack + "'"); showMsg("Unable to open '" + scriptPack + "'");
return; return;
} }
@ -377,12 +381,15 @@ static void runRMXPScripts(BacktraceData &btData){
* still go wrong */ * still go wrong */
try{ try{
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false); scriptArray = kernelLoadDataInt(scriptPack.c_str(), false);
printf("[runRMXPScripts] %s", scriptPack.c_str());
}catch (const Exception &e){ }catch (const Exception &e){
printf("[runRMXPScripts] Failed to read script data: %s", e.msg);
showMsg(std::string("Failed to read script data: ") + e.msg); showMsg(std::string("Failed to read script data: ") + e.msg);
return; return;
} }
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)){ if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY)){
printf("[runRMXPScripts] Failed to read script data");
showMsg("Failed to read script data"); showMsg("Failed to read script data");
return; return;
} }
@ -393,7 +400,7 @@ static void runRMXPScripts(BacktraceData &btData){
rb_gv_set("$RGSS_SCRIPTS", scriptArray); rb_gv_set("$RGSS_SCRIPTS", scriptArray);
long scriptCount = RARRAY_LEN(scriptArray); long scriptCount = RARRAY_LEN(scriptArray);
printf("[runRMXPScripts] Scripts count: %ld\n", scriptCount);
std::string decodeBuffer; std::string decodeBuffer;
decodeBuffer.resize(0x1000); decodeBuffer.resize(0x1000);
@ -403,22 +410,21 @@ static void runRMXPScripts(BacktraceData &btData){
if (!RB_TYPE_P(script, RUBY_T_ARRAY)) if (!RB_TYPE_P(script, RUBY_T_ARRAY))
continue; continue;
VALUE scriptName = rb_ary_entry(script, 1); VALUE scriptName = rb_ary_entry(script, 1);
VALUE scriptString = rb_ary_entry(script, 2); VALUE scriptString = rb_ary_entry(script, 2);
printf("[runRMXPScripts] Script Name: %s", rb_str_to_str(scriptName));
//printf("[runRMXPScripts] ");
int result = Z_OK; int result = Z_OK;
unsigned long bufferLen; unsigned long bufferLen;
while (true){ while (true){
unsigned char *bufferPtr = unsigned char *bufferPtr = reinterpret_cast<unsigned char*>(const_cast<char*>(decodeBuffer.c_str()));
reinterpret_cast<unsigned char*>(const_cast<char*>(decodeBuffer.c_str())); const unsigned char *sourcePtr = reinterpret_cast<const unsigned char*>(RSTRING_PTR(scriptString));
const unsigned char *sourcePtr =
reinterpret_cast<const unsigned char*>(RSTRING_PTR(scriptString));
bufferLen = decodeBuffer.length(); bufferLen = decodeBuffer.length();
result = uncompress(bufferPtr, &bufferLen, result = uncompress(bufferPtr, &bufferLen, sourcePtr, RSTRING_LEN(scriptString));
sourcePtr, RSTRING_LEN(scriptString));
bufferPtr[bufferLen] = '\0'; bufferPtr[bufferLen] = '\0';
@ -430,14 +436,13 @@ static void runRMXPScripts(BacktraceData &btData){
if (result != Z_OK){ if (result != Z_OK){
static char buffer[256]; static char buffer[256];
snprintf(buffer, sizeof(buffer), "Error decoding script %ld: '%s'", snprintf(buffer, sizeof(buffer), "Error decoding script %ld: '%s'", i, RSTRING_PTR(scriptName));
i, RSTRING_PTR(scriptName)); printf("[runRMXPScripts] Script Name: %s", buffer);
showMsg(buffer); showMsg(buffer);
break; break;
} }
rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str())); rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str()));
} }
@ -454,8 +459,7 @@ static void runRMXPScripts(BacktraceData &btData){
for (long i = 0; i < scriptCount; ++i){ for (long i = 0; i < scriptCount; ++i){
VALUE script = rb_ary_entry(scriptArray, i); VALUE script = rb_ary_entry(scriptArray, i);
VALUE scriptDecoded = rb_ary_entry(script, 3); VALUE scriptDecoded = rb_ary_entry(script, 3);
VALUE string = newStringUTF8(RSTRING_PTR(scriptDecoded), VALUE string = newStringUTF8(RSTRING_PTR(scriptDecoded), RSTRING_LEN(scriptDecoded));
RSTRING_LEN(scriptDecoded));
VALUE fname; VALUE fname;
const char *scriptName = RSTRING_PTR(rb_ary_entry(script, 1)); const char *scriptName = RSTRING_PTR(rb_ary_entry(script, 1));
@ -533,13 +537,14 @@ static void showExc(VALUE exc, const BacktraceData &btData){
file = btData.scriptNames.value(file, file); file = btData.scriptNames.value(file, file);
std::string ms(640, '\0'); std::string ms(640, '\0');
snprintf(&ms[0], ms.size(), "Script '%s' line %s: %s occured.\n\n%s", snprintf(&ms[0], ms.size(), "[runRMXPScripts]Script '%s' line %s: %s occured.\n\n%s",
file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg)); file.c_str(), line, RSTRING_PTR(name), RSTRING_PTR(msg));
showMsg(ms); showMsg(ms);
} }
static void mriBindingExecute(){ static void mriBindingExecute(){
printf("[mirBindingExecute] Setting up ruby\n");
/* Normally only a ruby executable would do a sysinit, /* Normally only a ruby executable would do a sysinit,
* but not doing it will lead to crashes due to closed * but not doing it will lead to crashes due to closed
* stdio streams on some platforms (eg. Windows) */ * stdio streams on some platforms (eg. Windows) */
@ -548,9 +553,9 @@ static void mriBindingExecute(){
char **argv = 0; char **argv = 0;
char options_argv1[] = "oneshot", options_argv2[] = "-evd", options_argv3[] = "--jit"; char options_argv1[] = "oneshot", options_argv2[] = "-evd", options_argv3[] = "--jit";
char* options_argv[] = {options_argv1, options_argv2, options_argv3, NULL}; char* options_argv[] = {options_argv1, options_argv2, options_argv3, NULL};
printf("[mriBindingExecute] %s %s %s\n", options_argv1, options_argv2, options_argv3);
ruby_setup(); ruby_setup();
ruby_sysinit(&argc, &argv); ruby_sysinit(&argc, &argv);
//ruby_init();
rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding())); rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));
Config &conf = shState->rtData().config; Config &conf = shState->rtData().config;
@ -566,25 +571,27 @@ static void mriBindingExecute(){
rb_ary_push(lpaths, pathv); rb_ary_push(lpaths, pathv);
} }
} }
RbData rbData; RbData rbData;
shState->setBindingData(&rbData); shState->setBindingData(&rbData);
BacktraceData btData; BacktraceData btData;
mriBindingInit(); mriBindingInit();
runRMXPScripts(btData); runRMXPScripts(btData);
VALUE exc = rb_errinfo(); VALUE exc = rb_errinfo();
if (!NIL_P(exc) && !rb_obj_is_kind_of(exc, rb_eSystemExit)) if (!NIL_P(exc) && !rb_obj_is_kind_of(exc, rb_eSystemExit))
showExc(exc, btData); showExc(exc, btData);
printf("[mirBindingExecure] Ruby cleanup\n");
ruby_cleanup(0); ruby_cleanup(0);
shState->rtData().rqTermAck.set(); shState->rtData().rqTermAck.set();
} }
static void mriBindingTerminate(){ static void mriBindingTerminate(){
printf("[mriBindingTerminate] Terminating binding...\n");
rb_raise(rb_eSystemExit, " "); rb_raise(rb_eSystemExit, " ");
#ifdef __linux__ #ifdef __linux__
wallpaperBindingTerminate(); wallpaperBindingTerminate();
@ -592,6 +599,7 @@ static void mriBindingTerminate(){
} }
static void mriBindingReset(){ static void mriBindingReset(){
printf("[mriBindingReset] Binding reset...\n");
rb_raise(getRbData()->exc[Reset], " "); rb_raise(getRbData()->exc[Reset], " ");
} }

View file

@ -29,14 +29,12 @@
DEF_TYPE(Bitmap); DEF_TYPE(Bitmap);
static const char *objAsStringPtr(VALUE obj) static const char *objAsStringPtr(VALUE obj){
{
VALUE str = rb_obj_as_string(obj); VALUE str = rb_obj_as_string(obj);
return RSTRING_PTR(str); return RSTRING_PTR(str);
} }
void bitmapInitProps(Bitmap *b, VALUE self) void bitmapInitProps(Bitmap *b, VALUE self){
{
/* Wrap properties */ /* Wrap properties */
VALUE fontKlass = rb_const_get(rb_cObject, rb_intern("Font")); VALUE fontKlass = rb_const_get(rb_cObject, rb_intern("Font"));
VALUE fontObj = rb_obj_alloc(fontKlass); VALUE fontObj = rb_obj_alloc(fontKlass);
@ -48,19 +46,16 @@ void bitmapInitProps(Bitmap *b, VALUE self)
rb_iv_set(self, "font", fontObj); rb_iv_set(self, "font", fontObj);
} }
RB_METHOD(bitmapInitialize) RB_METHOD(bitmapInitialize){
{
Bitmap *b = 0; Bitmap *b = 0;
if (argc == 1) if (argc == 1){
{
char *filename; char *filename;
rb_get_args(argc, argv, "z", &filename RB_ARG_END); rb_get_args(argc, argv, "z", &filename RB_ARG_END);
GUARD_EXC( b = new Bitmap(filename); ) GUARD_EXC( b = new Bitmap(filename); )
} }
else else{
{
int width, height; int width, height;
rb_get_args(argc, argv, "ii", &width, &height RB_ARG_END); rb_get_args(argc, argv, "ii", &width, &height RB_ARG_END);
@ -73,8 +68,7 @@ RB_METHOD(bitmapInitialize)
return self; return self;
} }
RB_METHOD(bitmapWidth) RB_METHOD(bitmapWidth){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
@ -85,8 +79,7 @@ RB_METHOD(bitmapWidth)
return INT2FIX(value); return INT2FIX(value);
} }
RB_METHOD(bitmapHeight) RB_METHOD(bitmapHeight){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
@ -97,8 +90,7 @@ RB_METHOD(bitmapHeight)
return INT2FIX(value); return INT2FIX(value);
} }
RB_METHOD(bitmapRect) RB_METHOD(bitmapRect){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
@ -111,8 +103,7 @@ RB_METHOD(bitmapRect)
return wrapObject(r, RectType); return wrapObject(r, RectType);
} }
RB_METHOD(bitmapBlt) RB_METHOD(bitmapBlt){
{
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
int x, y; int x, y;
@ -133,8 +124,7 @@ RB_METHOD(bitmapBlt)
return self; return self;
} }
RB_METHOD(bitmapStretchBlt) RB_METHOD(bitmapStretchBlt){
{
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
VALUE destRectObj; VALUE destRectObj;
@ -156,15 +146,13 @@ RB_METHOD(bitmapStretchBlt)
return self; return self;
} }
RB_METHOD(bitmapFillRect) RB_METHOD(bitmapFillRect){
{
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
VALUE colorObj; VALUE colorObj;
Color *color; Color *color;
if (argc == 2) if (argc == 2){
{
VALUE rectObj; VALUE rectObj;
Rect *rect; Rect *rect;
@ -175,8 +163,7 @@ RB_METHOD(bitmapFillRect)
GUARD_EXC( b->fillRect(rect->toIntRect(), color->norm); ); GUARD_EXC( b->fillRect(rect->toIntRect(), color->norm); );
} }
else else{
{
int x, y, width, height; int x, y, width, height;
rb_get_args(argc, argv, "iiiio", &x, &y, &width, &height, &colorObj RB_ARG_END); rb_get_args(argc, argv, "iiiio", &x, &y, &width, &height, &colorObj RB_ARG_END);
@ -189,8 +176,7 @@ RB_METHOD(bitmapFillRect)
return self; return self;
} }
RB_METHOD(bitmapClear) RB_METHOD(bitmapClear){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
@ -200,8 +186,7 @@ RB_METHOD(bitmapClear)
return self; return self;
} }
RB_METHOD(bitmapGetPixel) RB_METHOD(bitmapGetPixel){
{
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
int x, y; int x, y;
@ -216,8 +201,7 @@ RB_METHOD(bitmapGetPixel)
return wrapObject(color, ColorType); return wrapObject(color, ColorType);
} }
RB_METHOD(bitmapSetPixel) RB_METHOD(bitmapSetPixel){
{
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
int x, y; int x, y;
@ -234,8 +218,7 @@ RB_METHOD(bitmapSetPixel)
return self; return self;
} }
RB_METHOD(bitmapHueChange) RB_METHOD(bitmapHueChange){
{
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
int hue; int hue;
@ -247,27 +230,23 @@ RB_METHOD(bitmapHueChange)
return self; return self;
} }
RB_METHOD(bitmapDrawText) RB_METHOD(bitmapDrawText){
{
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
const char *str; const char *str;
int align = Bitmap::Left; int align = Bitmap::Left;
if (argc == 2 || argc == 3) if (argc == 2 || argc == 3){
{
VALUE rectObj; VALUE rectObj;
Rect *rect; Rect *rect;
if (rgssVer >= 2) if (rgssVer >= 2){
{
VALUE strObj; VALUE strObj;
rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END); rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END);
str = objAsStringPtr(strObj); str = objAsStringPtr(strObj);
} }
else else{
{
rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END); rb_get_args(argc, argv, "oz|i", &rectObj, &str, &align RB_ARG_END);
} }
@ -275,19 +254,16 @@ RB_METHOD(bitmapDrawText)
GUARD_EXC( b->drawText(rect->toIntRect(), str, align); ); GUARD_EXC( b->drawText(rect->toIntRect(), str, align); );
} }
else else{
{
int x, y, width, height; int x, y, width, height;
if (rgssVer >= 2) if (rgssVer >= 2){
{
VALUE strObj; VALUE strObj;
rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END); rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END);
str = objAsStringPtr(strObj); str = objAsStringPtr(strObj);
} }
else else{
{
rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END); rb_get_args(argc, argv, "iiiiz|i", &x, &y, &width, &height, &str, &align RB_ARG_END);
} }
@ -297,21 +273,18 @@ RB_METHOD(bitmapDrawText)
return self; return self;
} }
RB_METHOD(bitmapTextSize) RB_METHOD(bitmapTextSize){
{
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
const char *str; const char *str;
if (rgssVer >= 2) if (rgssVer >= 2){
{
VALUE strObj; VALUE strObj;
rb_get_args(argc, argv, "o", &strObj RB_ARG_END); rb_get_args(argc, argv, "o", &strObj RB_ARG_END);
str = objAsStringPtr(strObj); str = objAsStringPtr(strObj);
} }
else else{
{
rb_get_args(argc, argv, "z", &str RB_ARG_END); rb_get_args(argc, argv, "z", &str RB_ARG_END);
} }
@ -325,16 +298,14 @@ RB_METHOD(bitmapTextSize)
DEF_PROP_OBJ_VAL(Bitmap, Font, Font, "font") DEF_PROP_OBJ_VAL(Bitmap, Font, Font, "font")
RB_METHOD(bitmapGradientFillRect) RB_METHOD(bitmapGradientFillRect){
{
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
VALUE color1Obj, color2Obj; VALUE color1Obj, color2Obj;
Color *color1, *color2; Color *color1, *color2;
bool vertical = false; bool vertical = false;
if (argc == 3 || argc == 4) if (argc == 3 || argc == 4){
{
VALUE rectObj; VALUE rectObj;
Rect *rect; Rect *rect;
@ -347,8 +318,7 @@ RB_METHOD(bitmapGradientFillRect)
GUARD_EXC( b->gradientFillRect(rect->toIntRect(), color1->norm, color2->norm, vertical); ); GUARD_EXC( b->gradientFillRect(rect->toIntRect(), color1->norm, color2->norm, vertical); );
} }
else else{
{
int x, y, width, height; int x, y, width, height;
rb_get_args(argc, argv, "iiiioo|b", &x, &y, &width, &height, rb_get_args(argc, argv, "iiiioo|b", &x, &y, &width, &height,
@ -363,12 +333,10 @@ RB_METHOD(bitmapGradientFillRect)
return self; return self;
} }
RB_METHOD(bitmapClearRect) RB_METHOD(bitmapClearRect){
{
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
if (argc == 1) if (argc == 1){
{
VALUE rectObj; VALUE rectObj;
Rect *rect; Rect *rect;
@ -378,8 +346,7 @@ RB_METHOD(bitmapClearRect)
GUARD_EXC( b->clearRect(rect->toIntRect()); ); GUARD_EXC( b->clearRect(rect->toIntRect()); );
} }
else else{
{
int x, y, width, height; int x, y, width, height;
rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END); rb_get_args(argc, argv, "iiii", &x, &y, &width, &height RB_ARG_END);
@ -390,8 +357,7 @@ RB_METHOD(bitmapClearRect)
return self; return self;
} }
RB_METHOD(bitmapBlur) RB_METHOD(bitmapBlur){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
@ -401,8 +367,7 @@ RB_METHOD(bitmapBlur)
return Qnil; return Qnil;
} }
RB_METHOD(bitmapRadialBlur) RB_METHOD(bitmapRadialBlur){
{
Bitmap *b = getPrivateData<Bitmap>(self); Bitmap *b = getPrivateData<Bitmap>(self);
int angle, divisions; int angle, divisions;
@ -413,8 +378,7 @@ RB_METHOD(bitmapRadialBlur)
return Qnil; return Qnil;
} }
RB_METHOD(bitmapInitializeCopy) RB_METHOD(bitmapInitializeCopy){
{
rb_check_argc(argc, 1); rb_check_argc(argc, 1);
VALUE origObj = argv[0]; VALUE origObj = argv[0];
@ -434,9 +398,8 @@ RB_METHOD(bitmapInitializeCopy)
} }
void void bitmapBindingInit(){
bitmapBindingInit() printf("[bitmapBindingInit] Initializing Bitmap binding\n");
{
VALUE klass = rb_define_class("Bitmap", rb_cObject); VALUE klass = rb_define_class("Bitmap", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&BitmapType>); rb_define_alloc_func(klass, classAllocate<&BitmapType>);
@ -458,8 +421,7 @@ bitmapBindingInit()
_rb_define_method(klass, "draw_text", bitmapDrawText); _rb_define_method(klass, "draw_text", bitmapDrawText);
_rb_define_method(klass, "text_size", bitmapTextSize); _rb_define_method(klass, "text_size", bitmapTextSize);
if (rgssVer >= 2) if (rgssVer >= 2){
{
_rb_define_method(klass, "gradient_fill_rect", bitmapGradientFillRect); _rb_define_method(klass, "gradient_fill_rect", bitmapGradientFillRect);
_rb_define_method(klass, "clear_rect", bitmapClearRect); _rb_define_method(klass, "clear_rect", bitmapClearRect);
_rb_define_method(klass, "blur", bitmapBlur); _rb_define_method(klass, "blur", bitmapBlur);
@ -467,4 +429,5 @@ bitmapBindingInit()
} }
INIT_PROP_BIND(Bitmap, Font, "font"); INIT_PROP_BIND(Bitmap, Font, "font");
printf("[bitmapBindingInit] Done\n");
} }

View file

@ -23,16 +23,16 @@ int lastAnimId = -1;
void _attemptLinkSdk() { void _attemptLinkSdk() {
Debug() << "Attempting to bind Chroma SDK"; Debug() << "[_attempLinkSdk]Attempting to bind Chroma SDK";
#ifdef _WIN32 #ifdef _WIN32
hLib = LoadLibrary(L"ChromaApi.dll"); hLib = LoadLibrary(L"ChromaApi.dll");
if (hLib != NULL) { if (hLib != NULL) {
Debug() << "Chroma Impl @" << hLib; Debug() << "[_attempLinkSdk]Chroma Impl @" << hLib;
INIT_SUCCESS = true; INIT_SUCCESS = true;
_playAnimation = (PluginPlayAnimation) GetProcAddress(hLib, "PluginPlayAnimation"); _playAnimation = (PluginPlayAnimation) GetProcAddress(hLib, "PluginPlayAnimation");
INIT_SUCCESS &= _playAnimation != NULL; INIT_SUCCESS &= _playAnimation != NULL;
Debug() << "Plugin method @" << (long)_playAnimation; Debug() << "[_attempLinkSdk]Plugin method @" << (long)_playAnimation;
_openAnimation = (PluginOpenAnimation) GetProcAddress(hLib, "PluginOpenAnimation"); _openAnimation = (PluginOpenAnimation) GetProcAddress(hLib, "PluginOpenAnimation");
INIT_SUCCESS &= _openAnimation != NULL; INIT_SUCCESS &= _openAnimation != NULL;
@ -43,18 +43,18 @@ void _attemptLinkSdk() {
_pluginIsInitialized = (PluginIsInitialized) GetProcAddress(hLib, "PluginIsInitialized"); _pluginIsInitialized = (PluginIsInitialized) GetProcAddress(hLib, "PluginIsInitialized");
INIT_SUCCESS &= _pluginInit != NULL; INIT_SUCCESS &= _pluginInit != NULL;
if (INIT_SUCCESS && !_pluginIsInitialized()) { if (INIT_SUCCESS && !_pluginIsInitialized()) {
Debug() << "Initializing chroma plugin"; Debug() << "[_attempLinkSdk]Initializing chroma plugin";
_pluginInit(); _pluginInit();
} }
_pluginUninit = (PluginUninit) GetProcAddress(hLib, "PluginUninit"); _pluginUninit = (PluginUninit) GetProcAddress(hLib, "PluginUninit");
INIT_SUCCESS &= _pluginUninit != NULL; INIT_SUCCESS &= _pluginUninit != NULL;
Debug() << "Plugin init success:" << INIT_SUCCESS; Debug() << "[_attempLinkSdk]Plugin init success:" << INIT_SUCCESS;
} }
#else #else
// Currently the Razor Chroma API is Windows-only. // Currently the Razor Chroma API is Windows-only.
// So, if we are not building for Windows platform, // So, if we are not building for Windows platform,
// then don't bother with Chroma stuff. // then don't bother with Chroma stuff.
Debug() << "Chroma: Unsupported Platform"; Debug() << "[_attempLinkSdk]Chroma: Unsupported Platform";
#endif #endif
} }
@ -62,16 +62,16 @@ void _attemptLinkSdk() {
RB_METHOD(chromaPlayAnimation) { RB_METHOD(chromaPlayAnimation) {
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Debug() << "Chroma: Attempting to play animation."; Debug() << "[chromaPlayAnimation]Chroma: Attempting to play animation.";
const char* animfile; const char* animfile;
bool loop; bool loop;
rb_get_args(argc, argv, "zb", &animfile, &loop RB_ARG_END); rb_get_args(argc, argv, "zb", &animfile, &loop RB_ARG_END);
if (INIT_SUCCESS) { if (INIT_SUCCESS) {
Debug() << "Opening animation:" << animfile; Debug() << "[chromaPlayAnimation]Opening animation:" << animfile;
lastAnimId = _openAnimation(animfile); lastAnimId = _openAnimation(animfile);
Debug() << "ID:" << lastAnimId; Debug() << "[chromaPlayAnimation]ID:" << lastAnimId;
_playAnimation(lastAnimId); _playAnimation(lastAnimId);
} }

View file

@ -193,6 +193,7 @@ INITCOPY_FUN(Rect)
{ RB_ATTR_R(Klass, Attr, attr); RB_ATTR_W(Klass, Attr, attr); } { RB_ATTR_R(Klass, Attr, attr); RB_ATTR_W(Klass, Attr, attr); }
void etcBindingInit(){ void etcBindingInit(){
printf("[etcBindingInit] Initializing etc binding\n");
VALUE klass; VALUE klass;
INIT_BIND(Color); INIT_BIND(Color);
@ -216,4 +217,5 @@ void etcBindingInit(){
RB_ATTR_RW(Rect, Width, width); RB_ATTR_RW(Rect, Width, width);
RB_ATTR_RW(Rect, Height, height); RB_ATTR_RW(Rect, Height, height);
_rb_define_method(klass, "empty", rectEmpty); _rb_define_method(klass, "empty", rectEmpty);
printf("[bitmapBindingInit] Done\n");
} }

View file

@ -30,24 +30,28 @@
#include <ruby.h> #include <ruby.h>
static void fileIntFreeInstance(void *inst){ static void fileIntFreeInstance(void *inst){
printf("[fileIntFreeInstance] fileIntFreeInstance\n");
SDL_IOStream *ops = static_cast<SDL_IOStream*>(inst); SDL_IOStream *ops = static_cast<SDL_IOStream*>(inst);
if (ops) { if (ops) {
printf("[fileIntFreeInstance] Closing ops\n");
SDL_CloseIO(ops); SDL_CloseIO(ops);
} }
} }
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance); DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
static VALUE fileIntForPath(const char *path, bool rubyExc){ static VALUE fileIntForPath(const char *path, bool rubyExc){
printf("[fileIntForPath] %s!\n", *path);
SDL_IOStream* ops = nullptr; SDL_IOStream* ops = nullptr;
try{ try{
shState->fileSystem().openReadRaw(ops, path); shState->fileSystem().openReadRaw(ops, path);
if (!ops){ if (!ops){
printf("NULL guard! fileIntForPath broken!"); printf("[fileIntForPath] Null guard!\n");
return Qnil; return Qnil;
} }
} }
catch (const Exception &e){ catch (const Exception &e){
if (ops) if (ops)
printf("[fileIntForPath] Closing ops\n");
SDL_CloseIO(ops); SDL_CloseIO(ops);
if (rubyExc) if (rubyExc)
@ -66,12 +70,13 @@ static VALUE fileIntForPath(const char *path, bool rubyExc){
} }
RB_METHOD(fileIntRead){ RB_METHOD(fileIntRead){
printf("[fileIntRead] fileIntRead\n");
int length = -1; int length = -1;
rb_get_args(argc, argv, "i", &length); rb_get_args(argc, argv, "i", &length);
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self); SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
if (!ops){ if (!ops){
printf("NULL guard! fileIntRead broken!"); printf("[fileIntRead] Null guard!\n");
return Qnil; return Qnil;
} }
if (length == -1){ if (length == -1){
@ -82,9 +87,12 @@ RB_METHOD(fileIntRead){
} }
if (length == 0) if (length == 0)
printf("[fileIntRead] zero length\n");
return Qnil; return Qnil;
VALUE data = rb_str_new(0, length); VALUE data = rb_str_new(0, length);
printf("[fileIntRead] data: %s\n", rb_str_to_str(data));
printf("[fileIntRead] length: %ld\n", NUM2LONG(length));
SDL_ReadIO(ops, RSTRING_PTR(data), length); SDL_ReadIO(ops, RSTRING_PTR(data), length);
@ -92,29 +100,34 @@ RB_METHOD(fileIntRead){
} }
RB_NA_METHOD(fileIntClose){ RB_NA_METHOD(fileIntClose){
printf("[fileIntClose] fileIntClose\n");
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self); SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
if (!ops){ if (!ops){
printf("NULL guard! fileIntClose broken!"); printf("[fileIntClose] Null guard\n");
return Qnil; return Qnil;
} }
printf("[fileIntClose] Closing ops\n");
SDL_CloseIO(ops); SDL_CloseIO(ops);
setPrivateData(self, nullptr); setPrivateData(self, nullptr);
return Qnil; return Qnil;
} }
RB_NA_METHOD(fileIntGetByte){ RB_NA_METHOD(fileIntGetByte){
printf("[fileIntGetByte] fileIntGetByte\n");
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self); SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
unsigned char byte = 0; unsigned char byte = 0;
size_t result = SDL_ReadIO(ops, &byte, 1); size_t result = SDL_ReadIO(ops, &byte, 1);
printf("[fileIntGetByte] %s\n", byte);
return (result == 1) ? INT2NUM(byte) : Qnil; return (result == 1) ? INT2NUM(byte) : Qnil;
} }
RB_NA_METHOD(fileIntBinmode){ RB_NA_METHOD(fileIntBinmode){
printf("[fileIntBinMode] Plug\n");
return Qnil; return Qnil;
} }
static VALUE load_protect(VALUE marsh_and_port) { static VALUE load_protect(VALUE marsh_and_port) {
printf("[Load_protect] Protecting!\n");
VALUE *arr = (VALUE *)marsh_and_port; VALUE *arr = (VALUE *)marsh_and_port;
VALUE marsh = arr[0]; VALUE marsh = arr[0];
VALUE port = arr[1]; VALUE port = arr[1];
@ -122,15 +135,15 @@ static VALUE load_protect(VALUE marsh_and_port) {
} }
VALUE kernelLoadDataInt(const char *filename, bool rubyExc){ VALUE kernelLoadDataInt(const char *filename, bool rubyExc){
printf("[kernelLoadDataInt] Filename: %s\n", filename);
VALUE port = fileIntForPath(filename, rubyExc); VALUE port = fileIntForPath(filename, rubyExc);
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal")); VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
VALUE args[2] = { marsh, port }; VALUE args[2] = { marsh, port };
int state = 0; int state = 0;
VALUE result = rb_protect(load_protect, (VALUE)args, &state); VALUE result = rb_protect(load_protect, (VALUE)args, &state);
printf("[kernelLoadDataInt] State %ld\n", NUM2LONG(state));
if(RTEST(result) == false){ if(RTEST(result) == false){
printf("DEBUG ERROR\n"); printf("[kernelLoadDataInt] Result == false, bRuH\n");
return 1;
} }
rb_funcallv(port, rb_intern("close"), 0, nullptr); rb_funcallv(port, rb_intern("close"), 0, nullptr);
@ -153,10 +166,9 @@ VALUE kernelLoadDataInt(const char *filename, bool rubyExc){
RB_METHOD(kernelLoadData){ RB_METHOD(kernelLoadData){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const char *filename; const char *filename;
rb_get_args(argc, argv, "z", &filename); rb_get_args(argc, argv, "z", &filename);
printf("[kernelLoadData] filename: %s\n", filename);
return kernelLoadDataInt(filename, true); return kernelLoadDataInt(filename, true);
} }
@ -167,20 +179,21 @@ RB_METHOD(kernelSaveData){
VALUE filename; VALUE filename;
rb_get_args(argc, argv, "oS", &obj, &filename); rb_get_args(argc, argv, "oS", &obj, &filename);
printf("[kernelSaveData] Filename: %s\n", rb_str_to_str(filename));
VALUE file = rb_file_open_str(filename, "wb"); VALUE file = rb_file_open_str(filename, "wb");
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal")); VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
VALUE v[] = { obj, file }; VALUE v[] = { obj, file };
rb_funcall2(marsh, rb_intern("dump"), ARRAY_SIZE(v), v); rb_funcall2(marsh, rb_intern("dump"), ARRAY_SIZE(v), v);
printf("[kernelSaveData] Closing file %s\n", rb_str_to_str(filename));
rb_io_close(file); rb_io_close(file);
return Qnil; return Qnil;
} }
static VALUE stringForceUTF8(VALUE arg){ static VALUE stringForceUTF8(VALUE arg){
printf("[stringForceUTF8] %s\n", rb_str_to_str(arg));
if (RB_TYPE_P(arg, RUBY_T_STRING)) { if (RB_TYPE_P(arg, RUBY_T_STRING)) {
/* If current encoding is ASCII-8BIT (binary), associate UTF-8 so /* If current encoding is ASCII-8BIT (binary), associate UTF-8 so
subsequent Ruby-level handling treats it as UTF-8. This preserves subsequent Ruby-level handling treats it as UTF-8. This preserves
@ -194,6 +207,7 @@ static VALUE stringForceUTF8(VALUE arg){
} }
static VALUE customProc(VALUE arg, VALUE proc){ static VALUE customProc(VALUE arg, VALUE proc){
printf("[customProc] \n");
VALUE obj = stringForceUTF8(arg); VALUE obj = stringForceUTF8(arg);
obj = rb_funcall2(proc, rb_intern("call"), 1, &obj); obj = rb_funcall2(proc, rb_intern("call"), 1, &obj);
return obj; return obj;
@ -205,7 +219,7 @@ RB_METHOD(_marshalLoad){
rb_scan_args(argc, argv, "01", &port, &proc); rb_scan_args(argc, argv, "01", &port, &proc);
VALUE utf8Proc; VALUE utf8Proc;
printf("[_marshalLoad]\n");
if (NIL_P(proc)) if (NIL_P(proc))
utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(stringForceUTF8), Qnil); utf8Proc = rb_proc_new(RUBY_METHOD_FUNC(stringForceUTF8), Qnil);
else else
@ -218,12 +232,13 @@ RB_METHOD(_marshalLoad){
} }
void fileIntBindingInit(){ void fileIntBindingInit(){
printf("[fileIntBindingInit] Initializing filesystem binding...\n");
VALUE klass = rb_define_class("FileInt", rb_cIO); VALUE klass = rb_define_class("FileInt", rb_cIO);
rb_define_alloc_func(klass, classAllocate<&FileIntType>); rb_define_alloc_func(klass, classAllocate<&FileIntType>);
rb_define_method(klass, "read", RUBY_METHOD_FUNC(fileIntRead), -1); rb_define_method(klass, "read", RUBY_METHOD_FUNC(fileIntRead), -1);
rb_define_method(klass, "getbyte", RUBY_METHOD_FUNC(fileIntGetByte), 0); rb_define_method(klass, "getbyte", RUBY_METHOD_FUNC(fileIntGetByte), 0);
rb_define_method(klass, "binmode1", RUBY_METHOD_FUNC(fileIntBinmode), 0); rb_define_method(klass, "binmode", RUBY_METHOD_FUNC(fileIntBinmode), 0);
rb_define_method(klass, "close", RUBY_METHOD_FUNC(fileIntClose), 0); rb_define_method(klass, "close", RUBY_METHOD_FUNC(fileIntClose), 0);
rb_define_module_function(rb_mKernel, "load_data", RUBY_METHOD_FUNC(kernelLoadData), -1); rb_define_module_function(rb_mKernel, "load_data", RUBY_METHOD_FUNC(kernelLoadData), -1);
@ -235,5 +250,7 @@ void fileIntBindingInit(){
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal")); VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
rb_define_alias(rb_singleton_class(marsh), "_mkxp_load_alias", "load"); rb_define_alias(rb_singleton_class(marsh), "_mkxp_load_alias", "load");
rb_define_module_function(marsh, "load", RUBY_METHOD_FUNC(_marshalLoad), -1); rb_define_module_function(marsh, "load", RUBY_METHOD_FUNC(_marshalLoad), -1);
printf("[fileIntBindingInit] Done\n");
} }

View file

@ -28,17 +28,12 @@
#include <string.h> #include <string.h>
static void static void collectStrings(VALUE obj, std::vector<std::string> &out){
collectStrings(VALUE obj, std::vector<std::string> &out) if (RB_TYPE_P(obj, RUBY_T_STRING)){
{
if (RB_TYPE_P(obj, RUBY_T_STRING))
{
out.push_back(RSTRING_PTR(obj)); out.push_back(RSTRING_PTR(obj));
} }
else if (RB_TYPE_P(obj, RUBY_T_ARRAY)) else if (RB_TYPE_P(obj, RUBY_T_ARRAY)){
{ for (long i = 0; i < RARRAY_LEN(obj); ++i){
for (long i = 0; i < RARRAY_LEN(obj); ++i)
{
VALUE str = rb_ary_entry(obj, i); VALUE str = rb_ary_entry(obj, i);
/* Non-string objects are tolerated (ignored) */ /* Non-string objects are tolerated (ignored) */
@ -52,8 +47,7 @@ collectStrings(VALUE obj, std::vector<std::string> &out)
DEF_TYPE(Font); DEF_TYPE(Font);
RB_METHOD(fontDoesExist) RB_METHOD(fontDoesExist){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const char *name = 0; const char *name = 0;
@ -69,8 +63,7 @@ RB_METHOD(fontDoesExist)
RB_METHOD(FontSetName); RB_METHOD(FontSetName);
RB_METHOD(fontInitialize) RB_METHOD(fontInitialize){
{
VALUE namesObj = Qnil; VALUE namesObj = Qnil;
int size = 0; int size = 0;
@ -109,8 +102,7 @@ RB_METHOD(fontInitialize)
return self; return self;
} }
RB_METHOD(fontInitializeCopy) RB_METHOD(fontInitializeCopy){
{
VALUE origObj; VALUE origObj;
rb_get_args(argc, argv, "o", &origObj RB_ARG_END); rb_get_args(argc, argv, "o", &origObj RB_ARG_END);
@ -132,15 +124,13 @@ RB_METHOD(fontInitializeCopy)
return self; return self;
} }
RB_METHOD(FontGetName) RB_METHOD(FontGetName){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_iv_get(self, "name"); return rb_iv_get(self, "name");
} }
RB_METHOD(FontSetName) RB_METHOD(FontSetName){
{
Font *f = getPrivateData<Font>(self); Font *f = getPrivateData<Font>(self);
rb_check_argc(argc, 1); rb_check_argc(argc, 1);
@ -188,14 +178,12 @@ DEF_KLASS_PROP(Font, bool, DefaultItalic, "b", rb_bool_new)
DEF_KLASS_PROP(Font, bool, DefaultShadow, "b", rb_bool_new) DEF_KLASS_PROP(Font, bool, DefaultShadow, "b", rb_bool_new)
DEF_KLASS_PROP(Font, bool, DefaultOutline, "b", rb_bool_new) DEF_KLASS_PROP(Font, bool, DefaultOutline, "b", rb_bool_new)
RB_METHOD(FontGetDefaultOutColor) RB_METHOD(FontGetDefaultOutColor){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_iv_get(self, "default_out_color"); return rb_iv_get(self, "default_out_color");
} }
RB_METHOD(FontSetDefaultOutColor) RB_METHOD(FontSetDefaultOutColor){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
VALUE colorObj; VALUE colorObj;
@ -208,15 +196,13 @@ RB_METHOD(FontSetDefaultOutColor)
return colorObj; return colorObj;
} }
RB_METHOD(FontGetDefaultName) RB_METHOD(FontGetDefaultName){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_iv_get(self, "default_name"); return rb_iv_get(self, "default_name");
} }
RB_METHOD(FontSetDefaultName) RB_METHOD(FontSetDefaultName){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
rb_check_argc(argc, 1); rb_check_argc(argc, 1);
@ -230,15 +216,13 @@ RB_METHOD(FontSetDefaultName)
return argv[0]; return argv[0];
} }
RB_METHOD(FontGetDefaultColor) RB_METHOD(FontGetDefaultColor){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_iv_get(self, "default_color"); return rb_iv_get(self, "default_color");
} }
RB_METHOD(FontSetDefaultColor) RB_METHOD(FontSetDefaultColor){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
VALUE colorObj; VALUE colorObj;
@ -257,9 +241,8 @@ RB_METHOD(FontSetDefaultColor)
rb_define_class_method(klass, prop_name_s "=", Klass##Set##PropName); \ rb_define_class_method(klass, prop_name_s "=", Klass##Set##PropName); \
} }
void void fontBindingInit(){
fontBindingInit() printf("[fontBindingInit] Initializing Font binding\n");
{
VALUE klass = rb_define_class("Font", rb_cObject); VALUE klass = rb_define_class("Font", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&FontType>); rb_define_alloc_func(klass, classAllocate<&FontType>);
@ -270,12 +253,10 @@ fontBindingInit()
const std::vector<std::string> &defNames = Font::getInitialDefaultNames(); const std::vector<std::string> &defNames = Font::getInitialDefaultNames();
VALUE defNamesObj; VALUE defNamesObj;
if (defNames.size() == 1) if (defNames.size() == 1){
{
defNamesObj = rb_str_new_cstr(defNames[0].c_str()); defNamesObj = rb_str_new_cstr(defNames[0].c_str());
} }
else else{
{
defNamesObj = rb_ary_new2(defNames.size()); defNamesObj = rb_ary_new2(defNames.size());
for (size_t i = 0; i < defNames.size(); ++i) for (size_t i = 0; i < defNames.size(); ++i)
@ -293,13 +274,11 @@ fontBindingInit()
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic"); INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color"); INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
if (rgssVer >= 2) if (rgssVer >= 2){
{
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow"); INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
} }
if (rgssVer >= 3) if (rgssVer >= 3){
{
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline"); INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color"); INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
} }
@ -315,14 +294,13 @@ fontBindingInit()
INIT_PROP_BIND(Font, Italic, "italic"); INIT_PROP_BIND(Font, Italic, "italic");
INIT_PROP_BIND(Font, Color, "color"); INIT_PROP_BIND(Font, Color, "color");
if (rgssVer >= 2) if (rgssVer >= 2){
{
INIT_PROP_BIND(Font, Shadow, "shadow"); INIT_PROP_BIND(Font, Shadow, "shadow");
} }
if (rgssVer >= 3) if (rgssVer >= 3){
{
INIT_PROP_BIND(Font, Outline, "outline"); INIT_PROP_BIND(Font, Outline, "outline");
INIT_PROP_BIND(Font, OutColor, "out_color"); INIT_PROP_BIND(Font, OutColor, "out_color");
} }
printf("[fontBindingInit] Done\n");
} }

View file

@ -25,8 +25,7 @@
#include "binding-types.h" #include "binding-types.h"
#include "exception.h" #include "exception.h"
RB_METHOD(graphicsUpdate) RB_METHOD(graphicsUpdate){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
shState->graphics().update(); shState->graphics().update();
@ -34,8 +33,7 @@ RB_METHOD(graphicsUpdate)
return Qnil; return Qnil;
} }
RB_METHOD(graphicsFreeze) RB_METHOD(graphicsFreeze){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
shState->graphics().freeze(); shState->graphics().freeze();
@ -43,8 +41,7 @@ RB_METHOD(graphicsFreeze)
return Qnil; return Qnil;
} }
RB_METHOD(graphicsTransition) RB_METHOD(graphicsTransition){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
int duration = 8; int duration = 8;
@ -58,8 +55,7 @@ RB_METHOD(graphicsTransition)
return Qnil; return Qnil;
} }
RB_METHOD(graphicsFrameReset) RB_METHOD(graphicsFrameReset){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
shState->graphics().frameReset(); shState->graphics().frameReset();
@ -79,7 +75,7 @@ RB_METHOD(graphicsFrameReset)
int value; \ int value; \
rb_get_args(argc, argv, "i", &value RB_ARG_END); \ rb_get_args(argc, argv, "i", &value RB_ARG_END); \
shState->graphics().set##PropName(value); \ shState->graphics().set##PropName(value); \
return rb_fix_new(value); \ return INT2FIX(value); \
} }
#define DEF_GRA_PROP_B(PropName) \ #define DEF_GRA_PROP_B(PropName) \
@ -97,22 +93,17 @@ RB_METHOD(graphicsFrameReset)
return rb_bool_new(value); \ return rb_bool_new(value); \
} }
RB_METHOD(graphicsWidth) RB_METHOD(graphicsWidth){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return INT2FIX(shState->graphics().width());
return rb_fix_new(shState->graphics().width());
} }
RB_METHOD(graphicsHeight) RB_METHOD(graphicsHeight){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return INT2FIX(shState->graphics().height());
return rb_fix_new(shState->graphics().height());
} }
RB_METHOD(graphicsWait) RB_METHOD(graphicsWait){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
int duration; int duration;
@ -123,8 +114,7 @@ RB_METHOD(graphicsWait)
return Qnil; return Qnil;
} }
RB_METHOD(graphicsFadeout) RB_METHOD(graphicsFadeout){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
int duration; int duration;
@ -135,8 +125,7 @@ RB_METHOD(graphicsFadeout)
return Qnil; return Qnil;
} }
RB_METHOD(graphicsFadein) RB_METHOD(graphicsFadein){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
int duration; int duration;
@ -149,8 +138,7 @@ RB_METHOD(graphicsFadein)
void bitmapInitProps(Bitmap *b, VALUE self); void bitmapInitProps(Bitmap *b, VALUE self);
RB_METHOD(graphicsSnapToBitmap) RB_METHOD(graphicsSnapToBitmap){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Bitmap *result = 0; Bitmap *result = 0;
@ -162,8 +150,7 @@ RB_METHOD(graphicsSnapToBitmap)
return obj; return obj;
} }
RB_METHOD(graphicsResizeScreen) RB_METHOD(graphicsResizeScreen){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
int width, height; int width, height;
@ -174,8 +161,7 @@ RB_METHOD(graphicsResizeScreen)
return Qnil; return Qnil;
} }
RB_METHOD(graphicsReset) RB_METHOD(graphicsReset){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
shState->graphics().reset(); shState->graphics().reset();
@ -183,8 +169,7 @@ RB_METHOD(graphicsReset)
return Qnil; return Qnil;
} }
RB_METHOD(graphicsPlayMovie) RB_METHOD(graphicsPlayMovie){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const char *filename; const char *filename;
@ -210,8 +195,8 @@ DEF_GRA_PROP_B(Frameskip)
_rb_define_module_function(module, prop_name_s "=", graphics##Set##PropName); \ _rb_define_module_function(module, prop_name_s "=", graphics##Set##PropName); \
} }
void graphicsBindingInit() void graphicsBindingInit(){
{ printf("[graphicsBindingInit] Initializing Graphics binding\n");
VALUE module = rb_define_module("Graphics"); VALUE module = rb_define_module("Graphics");
_rb_define_module_function(module, "update", graphicsUpdate); _rb_define_module_function(module, "update", graphicsUpdate);
@ -224,8 +209,7 @@ void graphicsBindingInit()
INIT_GRA_PROP_BIND( FrameRate, "frame_rate" ); INIT_GRA_PROP_BIND( FrameRate, "frame_rate" );
INIT_GRA_PROP_BIND( FrameCount, "frame_count" ); INIT_GRA_PROP_BIND( FrameCount, "frame_count" );
if (rgssVer >= 2) if (rgssVer >= 2){
{
_rb_define_module_function(module, "width", graphicsWidth); _rb_define_module_function(module, "width", graphicsWidth);
_rb_define_module_function(module, "height", graphicsHeight); _rb_define_module_function(module, "height", graphicsHeight);
_rb_define_module_function(module, "wait", graphicsWait); _rb_define_module_function(module, "wait", graphicsWait);
@ -237,8 +221,7 @@ void graphicsBindingInit()
INIT_GRA_PROP_BIND( Brightness, "brightness" ); INIT_GRA_PROP_BIND( Brightness, "brightness" );
} }
if (rgssVer >= 3) if (rgssVer >= 3){
{
_rb_define_module_function(module, "play_movie", graphicsPlayMovie); _rb_define_module_function(module, "play_movie", graphicsPlayMovie);
} }
@ -246,4 +229,5 @@ void graphicsBindingInit()
INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" ); INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" );
INIT_GRA_PROP_BIND( Smooth, "smooth" ); INIT_GRA_PROP_BIND( Smooth, "smooth" );
INIT_GRA_PROP_BIND( Frameskip, "frameskip" ); INIT_GRA_PROP_BIND( Frameskip, "frameskip" );
printf("[graphicsBindingInit] Done\n");
} }

View file

@ -25,8 +25,7 @@
#include "binding-util.h" #include "binding-util.h"
#include "util.h" #include "util.h"
RB_METHOD(inputUpdate) RB_METHOD(inputUpdate){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
shState->input().update(); shState->input().update();
@ -34,23 +33,19 @@ RB_METHOD(inputUpdate)
return Qnil; return Qnil;
} }
static int getButtonArg(int argc, VALUE *argv) static int getButtonArg(int argc, VALUE *argv){
{
int num; int num;
rb_check_argc(argc, 1); rb_check_argc(argc, 1);
if (FIXNUM_P(argv[0])) if (FIXNUM_P(argv[0])){
{
num = FIX2INT(argv[0]); num = FIX2INT(argv[0]);
} }
else if (SYMBOL_P(argv[0]) && rgssVer >= 3) else if (SYMBOL_P(argv[0]) && rgssVer >= 3){
{
VALUE symHash = getRbData()->buttoncodeHash; VALUE symHash = getRbData()->buttoncodeHash;
num = FIX2INT(rb_hash_lookup2(symHash, argv[0], INT2FIX(Input::None))); num = FIX2INT(rb_hash_lookup2(symHash, argv[0], INT2FIX(Input::None)));
} }
else else{
{
// FIXME: RMXP allows only few more types that // FIXME: RMXP allows only few more types that
// don't make sense (symbols in pre 3, floats) // don't make sense (symbols in pre 3, floats)
num = 0; num = 0;
@ -59,8 +54,7 @@ static int getButtonArg(int argc, VALUE *argv)
return num; return num;
} }
RB_METHOD(inputPress) RB_METHOD(inputPress){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
int num = getButtonArg(argc, argv); int num = getButtonArg(argc, argv);
@ -68,8 +62,7 @@ RB_METHOD(inputPress)
return rb_bool_new(shState->input().isPressed(num)); return rb_bool_new(shState->input().isPressed(num));
} }
RB_METHOD(inputTrigger) RB_METHOD(inputTrigger){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
int num = getButtonArg(argc, argv); int num = getButtonArg(argc, argv);
@ -77,8 +70,7 @@ RB_METHOD(inputTrigger)
return rb_bool_new(shState->input().isTriggered(num)); return rb_bool_new(shState->input().isTriggered(num));
} }
RB_METHOD(inputRepeat) RB_METHOD(inputRepeat){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
int num = getButtonArg(argc, argv); int num = getButtonArg(argc, argv);
@ -86,50 +78,43 @@ RB_METHOD(inputRepeat)
return rb_bool_new(shState->input().isRepeated(num)); return rb_bool_new(shState->input().isRepeated(num));
} }
RB_METHOD(inputDir4) RB_METHOD(inputDir4){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_fix_new(shState->input().dir4Value()); return rb_fix_new(shState->input().dir4Value());
} }
RB_METHOD(inputDir8) RB_METHOD(inputDir8){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_fix_new(shState->input().dir8Value()); return rb_fix_new(shState->input().dir8Value());
} }
/* Non-standard extensions */ /* Non-standard extensions */
RB_METHOD(inputMouseX) RB_METHOD(inputMouseX){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_fix_new(shState->input().mouseX()); return rb_fix_new(shState->input().mouseX());
} }
RB_METHOD(inputMouseY) RB_METHOD(inputMouseY){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_fix_new(shState->input().mouseY()); return rb_fix_new(shState->input().mouseY());
} }
RB_METHOD(inputQuit) RB_METHOD(inputQuit){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_bool_new(shState->input().hasQuit()); return rb_bool_new(shState->input().hasQuit());
} }
struct struct{
{
const char *str; const char *str;
Input::ButtonCode val; Input::ButtonCode val;
} }
static buttonCodes[] = static buttonCodes[] = {
{
{ "DOWN", Input::Down }, { "DOWN", Input::Down },
{ "LEFT", Input::Left }, { "LEFT", Input::Left },
{ "RIGHT", Input::Right }, { "RIGHT", Input::Right },
@ -158,9 +143,8 @@ static buttonCodes[] =
static elementsN(buttonCodes); static elementsN(buttonCodes);
void void inputBindingInit(){
inputBindingInit() printf("[inputBindingInit] Initializing Input binding\n");
{
VALUE module = rb_define_module("Input"); VALUE module = rb_define_module("Input");
_rb_define_module_function(module, "update", inputUpdate); _rb_define_module_function(module, "update", inputUpdate);
@ -203,4 +187,5 @@ inputBindingInit()
rb_const_set(module, sym, val); rb_const_set(module, sym, val);
} }
} }
printf("[inputBindingInit] Done\n");
} }

View file

@ -41,15 +41,13 @@ static volatile int message_len = 0;
#ifdef LINUX #ifdef LINUX
static std::string PIPE_PATH = std::string(getpwuid(getuid())->pw_dir) + "/.oneshot-pipe"; static std::string PIPE_PATH = std::string(getpwuid(getuid())->pw_dir) + "/.oneshot-pipe";
static volatile int out_pipe = -1; static volatile int out_pipe = -1;
void cleanup_pipe() void cleanup_pipe(){
{
unlink(PIPE_PATH.c_str()); unlink(PIPE_PATH.c_str());
remove(PIPE_PATH.c_str()); remove(PIPE_PATH.c_str());
} }
#endif #endif
int server_thread(void *data) int server_thread(void *data){
{
(void)data; (void)data;
#if defined OS_W32 #if defined OS_W32
HANDLE pipe = CreateNamedPipeW(L"\\\\.\\pipe\\oneshot-journal-to-game", HANDLE pipe = CreateNamedPipeW(L"\\\\.\\pipe\\oneshot-journal-to-game",
@ -72,16 +70,13 @@ int server_thread(void *data)
} }
CloseHandle(pipe); CloseHandle(pipe);
#else #else
if (access(PIPE_PATH.c_str(), F_OK) != -1) if (access(PIPE_PATH.c_str(), F_OK) != -1){
{
out_pipe = open(PIPE_PATH.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); out_pipe = open(PIPE_PATH.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
SDL_LockMutex(mutex); SDL_LockMutex(mutex);
active = true; active = true;
if (message_len > 0) if (message_len > 0){
{ if (write(out_pipe, (char*)message_buffer, message_len) == -1){
if (write(out_pipe, (char*)message_buffer, message_len) == -1) Debug() << "[journal-binding>server_thread()]Failure writing to journal's pipe!";
{
Debug() << "Failure writing to journal's pipe!";
} }
} }
SDL_UnlockMutex(mutex); SDL_UnlockMutex(mutex);
@ -165,8 +160,8 @@ RB_METHOD(journalActive)
return active ? Qtrue : Qfalse; return active ? Qtrue : Qfalse;
} }
void journalBindingInit() void journalBindingInit(){
{ printf("[journalBindingInit] Initializing Journal binding\n");
mutex = SDL_CreateMutex(); mutex = SDL_CreateMutex();
memset((char*)lang_buffer, 0, BUFFER_SIZE); memset((char*)lang_buffer, 0, BUFFER_SIZE);
lang_buffer[0] = '_'; lang_buffer[0] = '_';
@ -179,4 +174,5 @@ void journalBindingInit()
_rb_define_module_function(module, "set", journalSet); _rb_define_module_function(module, "set", journalSet);
_rb_define_module_function(module, "active?", journalActive); _rb_define_module_function(module, "active?", journalActive);
_rb_define_module_function(module, "setLang", journalSetLang); _rb_define_module_function(module, "setLang", journalSetLang);
printf("[inputBindingInit] Done\n");
} }

View file

@ -46,15 +46,13 @@ static volatile int message_len = 0;
#ifdef LINUX #ifdef LINUX
static std::string NIKO_PIPE_PATH = std::string(getpwuid(getuid())->pw_dir) + "/.oneshot-niko-pipe"; static std::string NIKO_PIPE_PATH = std::string(getpwuid(getuid())->pw_dir) + "/.oneshot-niko-pipe";
static volatile int out_pipe = -1; static volatile int out_pipe = -1;
void niko_cleanup_pipe() void niko_cleanup_pipe(){
{
unlink(NIKO_PIPE_PATH.c_str()); unlink(NIKO_PIPE_PATH.c_str());
remove(NIKO_PIPE_PATH.c_str()); remove(NIKO_PIPE_PATH.c_str());
} }
#endif #endif
int niko_server_thread(void *data) int niko_server_thread(void *data){
{
(void)data; (void)data;
#if defined OS_W32 #if defined OS_W32
HANDLE pipe = CreateNamedPipeW(L"\\\\.\\pipe\\oneshot-journal-to-game", HANDLE pipe = CreateNamedPipeW(L"\\\\.\\pipe\\oneshot-journal-to-game",
@ -85,7 +83,7 @@ int niko_server_thread(void *data)
{ {
if (write(out_pipe, (char*)message_buffer, message_len) == -1) if (write(out_pipe, (char*)message_buffer, message_len) == -1)
{ {
Debug() << "Failed to write to pipe!"; Debug() << "[niko_server_thread]Failed to write to pipe!";
} }
} }
SDL_UnlockMutex(mutex); SDL_UnlockMutex(mutex);
@ -94,8 +92,7 @@ int niko_server_thread(void *data)
#endif #endif
} }
RB_METHOD(nikoPrepare) RB_METHOD(nikoPrepare){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
// Prime native window info // Prime native window info
@ -128,8 +125,7 @@ RB_METHOD(nikoPrepare)
return Qnil; return Qnil;
} }
RB_METHOD(nikoStart) RB_METHOD(nikoStart){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
// Prime native window info // Prime native window info
@ -191,8 +187,8 @@ RB_METHOD(nikoStart)
return Qnil; return Qnil;
} }
void nikoBindingInit() void nikoBindingInit(){
{ printf("[nikoBindingInit] Initializing Niko binding:3\n");
mutex = SDL_CreateMutex(); mutex = SDL_CreateMutex();
#if defined __linux #if defined __linux
mkfifo(NIKO_PIPE_PATH.c_str(), 0666); mkfifo(NIKO_PIPE_PATH.c_str(), 0666);
@ -204,4 +200,5 @@ void nikoBindingInit()
//Functions //Functions
_rb_define_module_function(module, "get_ready", nikoPrepare); _rb_define_module_function(module, "get_ready", nikoPrepare);
_rb_define_module_function(module, "do_your_thing", nikoStart); _rb_define_module_function(module, "do_your_thing", nikoStart);
printf("[nikoBindingInit] Done\n");
} }

View file

@ -93,6 +93,7 @@ RB_METHOD(oneshotCRC32){
} }
void oneshotBindingInit(){ void oneshotBindingInit(){
printf("[oneshotBindingInit] Initializing Oneshot binding\n");
VALUE module = rb_define_module("Oneshot"); VALUE module = rb_define_module("Oneshot");
VALUE msg = rb_define_module_under(module, "Msg"); VALUE msg = rb_define_module_under(module, "Msg");
@ -122,4 +123,5 @@ void oneshotBindingInit(){
_rb_define_module_function(module, "exiting", oneshotExiting); _rb_define_module_function(module, "exiting", oneshotExiting);
_rb_define_module_function(module, "shake", oneshotShake); _rb_define_module_function(module, "shake", oneshotShake);
_rb_define_module_function(module, "crc32", oneshotCRC32); _rb_define_module_function(module, "crc32", oneshotCRC32);
printf("[oneshotBindingInit] Done\n");
} }

View file

@ -27,8 +27,7 @@
DEF_TYPE(Plane); DEF_TYPE(Plane);
RB_METHOD(planeInitialize) RB_METHOD(planeInitialize){
{
Plane *p = viewportElementInitialize<Plane>(argc, argv, self); Plane *p = viewportElementInitialize<Plane>(argc, argv, self);
setPrivateData(self, p); setPrivateData(self, p);
@ -56,9 +55,8 @@ DEF_PROP_F(Plane, ZoomX)
DEF_PROP_F(Plane, ZoomY) DEF_PROP_F(Plane, ZoomY)
void void planeBindingInit(){
planeBindingInit() printf("[planeBindingInit] Initializing Plane binding\n");
{
VALUE klass = rb_define_class("Plane", rb_cObject); VALUE klass = rb_define_class("Plane", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&PlaneType>); rb_define_alloc_func(klass, classAllocate<&PlaneType>);
@ -77,4 +75,5 @@ planeBindingInit()
INIT_PROP_BIND( Plane, BlendType, "blend_type" ); INIT_PROP_BIND( Plane, BlendType, "blend_type" );
INIT_PROP_BIND( Plane, Color, "color" ); INIT_PROP_BIND( Plane, Color, "color" );
INIT_PROP_BIND( Plane, Tone, "tone" ); INIT_PROP_BIND( Plane, Tone, "tone" );
printf("[planeBindingInit] Done\n");
} }

View file

@ -8,8 +8,7 @@
static Pipe ipc; static Pipe ipc;
static void start() static void start(){
{
ipc.open("oneshot-pipe", Pipe::Write); ipc.open("oneshot-pipe", Pipe::Write);
// Create process // Create process
@ -40,8 +39,7 @@ static void start()
pid_t pid = fork(); pid_t pid = fork();
if (pid == 0) { if (pid == 0) {
execl(exename.c_str(), "oneshot", execl(exename.c_str(), "oneshot",
(std::string("--gameFolder=") + shState->config().gameFolder).c_str(), (std::string("--gameFolder=") + shState->config().gameFolder).c_str(), "--screenMode=true", NULL);
"--screenMode=true", NULL);
exit(1); exit(1);
} }
#endif #endif
@ -49,23 +47,20 @@ static void start()
ipc.connect(); ipc.connect();
} }
RB_METHOD(screenStart) RB_METHOD(screenStart){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
start(); start();
return Qnil; return Qnil;
} }
RB_METHOD(screenFinish) RB_METHOD(screenFinish){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
ipc.write("END", sizeof("END")); ipc.write("END", sizeof("END"));
ipc.close(); ipc.close();
return Qnil; return Qnil;
} }
RB_METHOD(screenSet) RB_METHOD(screenSet){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const char *imageName; const char *imageName;
rb_get_args(argc, argv, "z", &imageName RB_ARG_END); rb_get_args(argc, argv, "z", &imageName RB_ARG_END);
@ -75,10 +70,11 @@ RB_METHOD(screenSet)
return Qnil; return Qnil;
} }
void screenBindingInit() void screenBindingInit(){
{ printf("[screenBindingInit] Initializing Screen binding\n");
VALUE module = rb_define_module("Screen"); VALUE module = rb_define_module("Screen");
_rb_define_module_function(module, "start", screenStart); _rb_define_module_function(module, "start", screenStart);
_rb_define_module_function(module, "finish", screenFinish); _rb_define_module_function(module, "finish", screenFinish);
_rb_define_module_function(module, "set", screenSet); _rb_define_module_function(module, "set", screenSet);
printf("[screenBindingInit] Done\n");
} }

View file

@ -30,8 +30,7 @@
DEF_TYPE(Sprite); DEF_TYPE(Sprite);
RB_METHOD(spriteInitialize) RB_METHOD(spriteInitialize){
{
Sprite *s = viewportElementInitialize<Sprite>(argc, argv, self); Sprite *s = viewportElementInitialize<Sprite>(argc, argv, self);
setPrivateData(self, s); setPrivateData(self, s);
@ -71,8 +70,7 @@ DEF_PROP_F(Sprite, WavePhase)
DEF_PROP_B(Sprite, Mirror) DEF_PROP_B(Sprite, Mirror)
DEF_PROP_B(Sprite, Obscured) DEF_PROP_B(Sprite, Obscured)
RB_METHOD(spriteWidth) RB_METHOD(spriteWidth){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Sprite *s = getPrivateData<Sprite>(self); Sprite *s = getPrivateData<Sprite>(self);
@ -80,11 +78,10 @@ RB_METHOD(spriteWidth)
int value = 0; int value = 0;
GUARD_EXC( value = s->getWidth(); ) GUARD_EXC( value = s->getWidth(); )
return rb_fix_new(value); return INT2NUM(value);
} }
RB_METHOD(spriteHeight) RB_METHOD(spriteHeight){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
Sprite *s = getPrivateData<Sprite>(self); Sprite *s = getPrivateData<Sprite>(self);
@ -92,12 +89,11 @@ RB_METHOD(spriteHeight)
int value = 0; int value = 0;
GUARD_EXC( value = s->getHeight(); ) GUARD_EXC( value = s->getHeight(); )
return rb_fix_new(value); return INT2NUM(value);
} }
void void spriteBindingInit(){
spriteBindingInit() printf("[spriteBindingInit] Initializing sprite binding\n");
{
VALUE klass = rb_define_class("Sprite", rb_cObject); VALUE klass = rb_define_class("Sprite", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&SpriteType>); rb_define_alloc_func(klass, classAllocate<&SpriteType>);
@ -124,8 +120,7 @@ spriteBindingInit()
INIT_PROP_BIND( Sprite, Tone, "tone" ); INIT_PROP_BIND( Sprite, Tone, "tone" );
INIT_PROP_BIND( Sprite, Obscured, "obscured" ); INIT_PROP_BIND( Sprite, Obscured, "obscured" );
if (rgssVer >= 2) if (rgssVer >= 2){
{
_rb_define_method(klass, "width", spriteWidth); _rb_define_method(klass, "width", spriteWidth);
_rb_define_method(klass, "height", spriteHeight); _rb_define_method(klass, "height", spriteHeight);
@ -136,4 +131,5 @@ spriteBindingInit()
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" ); INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" ); INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" );
} }
printf("[spriteBindingInit] Done\n");
} }

View file

@ -7,8 +7,7 @@
#include "binding-types.h" #include "binding-types.h"
#include "debugwriter.h" #include "debugwriter.h"
RB_METHOD(steamEnabled) RB_METHOD(steamEnabled){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
#ifdef STEAM #ifdef STEAM
@ -18,8 +17,7 @@ RB_METHOD(steamEnabled)
#endif #endif
} }
RB_METHOD(steamUnlock) RB_METHOD(steamUnlock){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const char *name; const char *name;
@ -31,8 +29,7 @@ RB_METHOD(steamUnlock)
return Qnil; return Qnil;
} }
RB_METHOD(steamLock) RB_METHOD(steamLock){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const char *name; const char *name;
@ -44,8 +41,7 @@ RB_METHOD(steamLock)
return Qnil; return Qnil;
} }
RB_METHOD(steamUnlocked) RB_METHOD(steamUnlocked){
{
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
const char *name; const char *name;
@ -58,8 +54,8 @@ RB_METHOD(steamUnlocked)
#endif #endif
} }
void steamBindingInit() void steamBindingInit(){
{ printf("[steamBindingInit] Initializing Steam binding\n");
VALUE module = rb_define_module("Steam"); VALUE module = rb_define_module("Steam");
/* Constants */ /* Constants */
@ -79,4 +75,5 @@ void steamBindingInit()
_rb_define_module_function(module, "unlock", steamUnlock); _rb_define_module_function(module, "unlock", steamUnlock);
_rb_define_module_function(module, "lock", steamLock); _rb_define_module_function(module, "lock", steamLock);
_rb_define_module_function(module, "unlocked?", steamUnlocked); _rb_define_module_function(module, "unlocked?", steamUnlocked);
printf("[steamBindingInit] Done\n");
} }

View file

@ -1,15 +1,12 @@
#include "oneshot.h" #include <ruby.h>
#include "etc.h"
#include "sharedstate.h"
#include "binding-util.h"
#include "binding-types.h"
#include "eventthread.h"
#include <SDL3/SDL.h>
#include <SDL3/SDL_version.h> #include <SDL3/SDL_version.h>
//for future use
void SunshineBindingInit(){ void SunshineBindingInit(){
VALUE module = rb_define_module("Sunshine"); printf("[SunshineBindingInit] Initializing Sunshine binding\n");
rb_const_set(module, rb_intern("SDLVersion"), static_cast<char>(SDL_VERSION)); VALUE module = rb_define_module("Sunshine");
rb_define_const(module, "SDLVersion", INT2NUM(SDL_VERSION));
printf("[SunshineBindingInit] SDL version: %u\n", SDL_VERSION);
printf("[SunshineBindingInit] Done\n");
} }

View file

@ -24,14 +24,12 @@
#include "binding-util.h" #include "binding-util.h"
#include "serializable-binding.h" #include "serializable-binding.h"
static int num2TableSize(VALUE v) static int num2TableSize(VALUE v){
{
int i = NUM2INT(v); int i = NUM2INT(v);
return std::max(0, i); return std::max(0, i);
} }
static void parseArgsTableSizes(int argc, VALUE *argv, int *x, int *y, int *z) static void parseArgsTableSizes(int argc, VALUE *argv, int *x, int *y, int *z){
{
*y = *z = 1; *y = *z = 1;
switch (argc) switch (argc)
@ -52,8 +50,7 @@ static void parseArgsTableSizes(int argc, VALUE *argv, int *x, int *y, int *z)
DEF_TYPE(Table); DEF_TYPE(Table);
RB_METHOD(tableInitialize) RB_METHOD(tableInitialize){
{
int x, y, z; int x, y, z;
parseArgsTableSizes(argc, argv, &x, &y, &z); parseArgsTableSizes(argc, argv, &x, &y, &z);
@ -65,8 +62,7 @@ RB_METHOD(tableInitialize)
return self; return self;
} }
RB_METHOD(tableResize) RB_METHOD(tableResize){
{
Table *t = getPrivateData<Table>(self); Table *t = getPrivateData<Table>(self);
int x, y, z; int x, y, z;
@ -89,8 +85,7 @@ TABLE_SIZE(x, X)
TABLE_SIZE(y, Y) TABLE_SIZE(y, Y)
TABLE_SIZE(z, Z) TABLE_SIZE(z, Z)
RB_METHOD(tableGetAt) RB_METHOD(tableGetAt){
{
Table *t = getPrivateData<Table>(self); Table *t = getPrivateData<Table>(self);
int x, y, z; int x, y, z;
@ -117,8 +112,7 @@ RB_METHOD(tableGetAt)
return INT2FIX(result); /* short always fits in a Fixnum */ return INT2FIX(result); /* short always fits in a Fixnum */
} }
RB_METHOD(tableSetAt) RB_METHOD(tableSetAt){
{
Table *t = getPrivateData<Table>(self); Table *t = getPrivateData<Table>(self);
int x, y, z, value; int x, y, z, value;
@ -158,9 +152,8 @@ RB_METHOD(tableSetAt)
MARSH_LOAD_FUN(Table) MARSH_LOAD_FUN(Table)
INITCOPY_FUN(Table) INITCOPY_FUN(Table)
void void tableBindingInit(){
tableBindingInit() printf("[tableBindingInit] Initializing Table binding\n");
{
VALUE klass = rb_define_class("Table", rb_cObject); VALUE klass = rb_define_class("Table", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&TableType>); rb_define_alloc_func(klass, classAllocate<&TableType>);
@ -176,5 +169,5 @@ tableBindingInit()
_rb_define_method(klass, "zsize", tableZSize); _rb_define_method(klass, "zsize", tableZSize);
_rb_define_method(klass, "[]", tableGetAt); _rb_define_method(klass, "[]", tableGetAt);
_rb_define_method(klass, "[]=", tableSetAt); _rb_define_method(klass, "[]=", tableSetAt);
printf("[tableBindingInit] Done\n");
} }

View file

@ -136,6 +136,7 @@ DEF_PROP_I(Tilemap, OX)
DEF_PROP_I(Tilemap, OY) DEF_PROP_I(Tilemap, OY)
void tilemapBindingInit(){ void tilemapBindingInit(){
printf("[tilemapBindingInit] Initializing tilemap binding\n");
VALUE klass = rb_define_class("TilemapAutotiles", rb_cObject); VALUE klass = rb_define_class("TilemapAutotiles", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&TilemapAutotilesType>); rb_define_alloc_func(klass, classAllocate<&TilemapAutotilesType>);
@ -161,4 +162,5 @@ void tilemapBindingInit(){
INIT_PROP_BIND( Tilemap, Wrapping, "wrapping" ); INIT_PROP_BIND( Tilemap, Wrapping, "wrapping" );
INIT_PROP_BIND( Tilemap, OX, "ox" ); INIT_PROP_BIND( Tilemap, OX, "ox" );
INIT_PROP_BIND( Tilemap, OY, "oy" ); INIT_PROP_BIND( Tilemap, OY, "oy" );
printf("[tilemapBindingInit] Done\n");
} }

View file

@ -80,6 +80,7 @@ DEF_PROP_I(Viewport, OY)
void viewportBindingInit(){ void viewportBindingInit(){
printf("[viewportBindingInit] Initializing viewport binding\n");
VALUE klass = rb_define_class("Viewport", rb_cObject); VALUE klass = rb_define_class("Viewport", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&ViewportType>); rb_define_alloc_func(klass, classAllocate<&ViewportType>);
@ -94,5 +95,6 @@ void viewportBindingInit(){
INIT_PROP_BIND( Viewport, OY, "oy" ); INIT_PROP_BIND( Viewport, OY, "oy" );
INIT_PROP_BIND( Viewport, Color, "color" ); INIT_PROP_BIND( Viewport, Color, "color" );
INIT_PROP_BIND( Viewport, Tone, "tone" ); INIT_PROP_BIND( Viewport, Tone, "tone" );
printf("[viewportBindingInit] Done\n");
} }

View file

@ -58,6 +58,7 @@
#ifdef __linux__ #ifdef __linux__
void desktopEnvironmentInit(){ void desktopEnvironmentInit(){
printf("[desktopEnvironmentInit] desktopEnvironmentInit()\n");
if (desktop != "uninitialized") { if (desktop != "uninitialized") {
return; return;
} }
@ -173,7 +174,7 @@ RB_METHOD(wallpaperSet){
std::string path; std::string path;
#ifdef _WIN32 #ifdef _WIN32
path = shState->config().gameFolder + "\\Wallpaper\\" + name + ".bmp"; path = shState->config().gameFolder + "\\Wallpaper\\" + name + ".bmp";
Debug() << "Setting wallpaper to" << path; Debug() << "[wallpaperSet]Setting wallpaper to" << path;
// Crapify the slashes // Crapify the slashes
size_t index = 0; size_t index = 0;
for (;;) { for (;;) {
@ -248,7 +249,7 @@ end:
} }
path = "/Wallpaper/" + nameFix + ".png"; path = "/Wallpaper/" + nameFix + ".png";
Debug() << "Setting wallpaper to " << path; Debug() << "[wallpaperSet]Setting wallpaper to " << path;
#ifdef __APPLE__ #ifdef __APPLE__
if (!isCached) { if (!isCached) {
@ -299,7 +300,7 @@ end:
colorArrType = g_type_from_name("GPtrArray_GValue_"); colorArrType = g_type_from_name("GPtrArray_GValue_");
if (!colorArrType) { if (!colorArrType) {
// Let's do some debug output here and skip changing the color // Let's do some debug output here and skip changing the color
Debug() << "WALLPAPER ERROR: xfconf-query call returned" << colorCommandRes; Debug() << "[wallpaperSet]WALLPAPER ERROR: xfconf-query call returned" << colorCommandRes;
return Qnil; return Qnil;
} }
} }
@ -468,12 +469,12 @@ RB_METHOD(wallpaperReset){
"}" << "}" <<
"}" << "}" <<
"'"; "'";
Debug() << "Reset wallpaper command:" << command.str(); Debug() << "[wallpaperReset]Reset wallpaper command:" << command.str();
int result = system(command.str().c_str()); int result = system(command.str().c_str());
Debug() << "Reset result:" << result; Debug() << "[wallpaperReset]Reset result:" << result;
} else { } else {
if (remove(fallbackPath.c_str()) != 0) { if (remove(fallbackPath.c_str()) != 0) {
Debug() << "Failed to delete:" << fallbackPath; Debug() << "[wallpaperReset]Failed to delete:" << fallbackPath;
} }
} }
#endif #endif

View file

@ -68,6 +68,7 @@ DEF_PROP_I(Window, ContentsOpacity)
void windowBindingInit(){ void windowBindingInit(){
printf("[windowBindingInit] Initialing Window binding\n");
VALUE klass = rb_define_class("Window", rb_cObject); VALUE klass = rb_define_class("Window", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&WindowType>); rb_define_alloc_func(klass, classAllocate<&WindowType>);
@ -92,4 +93,5 @@ void windowBindingInit(){
INIT_PROP_BIND( Window, Opacity, "opacity" ); INIT_PROP_BIND( Window, Opacity, "opacity" );
INIT_PROP_BIND( Window, BackOpacity, "back_opacity" ); INIT_PROP_BIND( Window, BackOpacity, "back_opacity" );
INIT_PROP_BIND( Window, ContentsOpacity, "contents_opacity" ); INIT_PROP_BIND( Window, ContentsOpacity, "contents_opacity" );
printf("[windowBindingInit] Done\n");
} }

View file

@ -32,8 +32,7 @@
#include <SDL3/SDL_thread.h> #include <SDL3/SDL_thread.h>
#include <SDL3/SDL_timer.h> #include <SDL3/SDL_timer.h>
struct AudioPrivate struct AudioPrivate{
{
int bgm_volume; int bgm_volume;
int sfx_volume; int sfx_volume;
@ -54,16 +53,14 @@ struct AudioPrivate
* keeping it paused/stopped while the ME plays, * keeping it paused/stopped while the ME plays,
* and unpausing/fading the BGM back in again * and unpausing/fading the BGM back in again
* afterwards */ * afterwards */
enum MeWatchState enum MeWatchState{
{
MeNotPlaying, MeNotPlaying,
BgmFadingOut, BgmFadingOut,
MePlaying, MePlaying,
BgmFadingIn BgmFadingIn
}; };
struct struct{
{
SDL_Thread *thread; SDL_Thread *thread;
AtomicFlag termReq; AtomicFlag termReq;
MeWatchState state; MeWatchState state;
@ -86,32 +83,26 @@ struct AudioPrivate
<AudioPrivate, &AudioPrivate::meWatchFun>(this, "audio_mewatch"); <AudioPrivate, &AudioPrivate::meWatchFun>(this, "audio_mewatch");
} }
~AudioPrivate() ~AudioPrivate(){
{
meWatch.termReq.set(); meWatch.termReq.set();
SDL_WaitThread(meWatch.thread, 0); SDL_WaitThread(meWatch.thread, 0);
} }
void meWatchFun() void meWatchFun(){
{
const float fadeOutStep = 1.f / (200 / AUDIO_SLEEP); const float fadeOutStep = 1.f / (200 / AUDIO_SLEEP);
const float fadeInStep = 1.f / (1000 / AUDIO_SLEEP); const float fadeInStep = 1.f / (1000 / AUDIO_SLEEP);
while (true) while (true){
{
syncPoint.passSecondarySync(); syncPoint.passSecondarySync();
if (meWatch.termReq) if (meWatch.termReq)
return; return;
switch (meWatch.state) switch (meWatch.state){
{ case MeNotPlaying:{
case MeNotPlaying:
{
me.lockStream(); me.lockStream();
if (me.stream.queryState() == ALStream::Playing) if (me.stream.queryState() == ALStream::Playing){
{
/* ME playing detected. -> FadeOutBGM */ /* ME playing detected. -> FadeOutBGM */
bgm.extPaused = true; bgm.extPaused = true;
meWatch.state = BgmFadingOut; meWatch.state = BgmFadingOut;
@ -122,12 +113,10 @@ struct AudioPrivate
break; break;
} }
case BgmFadingOut : case BgmFadingOut :{
{
me.lockStream(); me.lockStream();
if (me.stream.queryState() != ALStream::Playing) if (me.stream.queryState() != ALStream::Playing){
{
/* ME has ended while fading OUT BGM. -> FadeInBGM */ /* ME has ended while fading OUT BGM. -> FadeInBGM */
me.unlockStream(); me.unlockStream();
meWatch.state = BgmFadingIn; meWatch.state = BgmFadingIn;
@ -140,8 +129,7 @@ struct AudioPrivate
float vol = bgm.getVolume(AudioStream::External); float vol = bgm.getVolume(AudioStream::External);
vol -= fadeOutStep; vol -= fadeOutStep;
if (vol < 0 || bgm.stream.queryState() != ALStream::Playing) if (vol < 0 || bgm.stream.queryState() != ALStream::Playing){
{
/* Either BGM has fully faded out, or stopped midway. -> MePlaying */ /* Either BGM has fully faded out, or stopped midway. -> MePlaying */
bgm.setVolume(AudioStream::External, 0); bgm.setVolume(AudioStream::External, 0);
bgm.stream.pause(); bgm.stream.pause();
@ -159,12 +147,10 @@ struct AudioPrivate
break; break;
} }
case MePlaying : case MePlaying :{
{
me.lockStream(); me.lockStream();
if (me.stream.queryState() != ALStream::Playing) if (me.stream.queryState() != ALStream::Playing){
{
/* ME has ended */ /* ME has ended */
bgm.lockStream(); bgm.lockStream();
@ -172,14 +158,12 @@ struct AudioPrivate
ALStream::State sState = bgm.stream.queryState(); ALStream::State sState = bgm.stream.queryState();
if (sState == ALStream::Paused) if (sState == ALStream::Paused){
{
/* BGM is paused. -> FadeInBGM */ /* BGM is paused. -> FadeInBGM */
bgm.stream.play(); bgm.stream.play();
meWatch.state = BgmFadingIn; meWatch.state = BgmFadingIn;
} }
else else{
{
/* BGM is stopped. -> MeNotPlaying */ /* BGM is stopped. -> MeNotPlaying */
bgm.setVolume(AudioStream::External, 1.0f); bgm.setVolume(AudioStream::External, 1.0f);
@ -197,12 +181,10 @@ struct AudioPrivate
break; break;
} }
case BgmFadingIn : case BgmFadingIn :{
{
bgm.lockStream(); bgm.lockStream();
if (bgm.stream.queryState() == ALStream::Stopped) if (bgm.stream.queryState() == ALStream::Stopped){
{
/* BGM stopped midway fade in. -> MeNotPlaying */ /* BGM stopped midway fade in. -> MeNotPlaying */
bgm.setVolume(AudioStream::External, 1.0f); bgm.setVolume(AudioStream::External, 1.0f);
meWatch.state = MeNotPlaying; meWatch.state = MeNotPlaying;
@ -213,8 +195,7 @@ struct AudioPrivate
me.lockStream(); me.lockStream();
if (me.stream.queryState() == ALStream::Playing) if (me.stream.queryState() == ALStream::Playing){
{
/* ME started playing midway BGM fade in. -> FadeOutBGM */ /* ME started playing midway BGM fade in. -> FadeOutBGM */
bgm.extPaused = true; bgm.extPaused = true;
meWatch.state = BgmFadingOut; meWatch.state = BgmFadingOut;
@ -227,8 +208,7 @@ struct AudioPrivate
float vol = bgm.getVolume(AudioStream::External); float vol = bgm.getVolume(AudioStream::External);
vol += fadeInStep; vol += fadeInStep;
if (vol >= 1) if (vol >= 1){
{
/* BGM fully faded in. -> MeNotPlaying */ /* BGM fully faded in. -> MeNotPlaying */
vol = 1.0f; vol = 1.0f;
meWatch.state = MeNotPlaying; meWatch.state = MeNotPlaying;
@ -262,13 +242,11 @@ void Audio::bgmPlay(const char *filename,
p->bgm.play(filename, (volume*p->bgm_volume)/100, pitch, pos); p->bgm.play(filename, (volume*p->bgm_volume)/100, pitch, pos);
} }
void Audio::bgmStop() void Audio::bgmStop(){
{
p->bgm.stop(); p->bgm.stop();
} }
void Audio::bgmFade(int time) void Audio::bgmFade(int time){
{
p->bgm.fadeOut(time); p->bgm.fadeOut(time);
} }
@ -282,13 +260,11 @@ void Audio::bgsPlay(const char *filename,
p->bgs.play(filename, (volume*p->sfx_volume)/100, pitch, pos); p->bgs.play(filename, (volume*p->sfx_volume)/100, pitch, pos);
} }
void Audio::bgsStop() void Audio::bgsStop(){
{
p->bgs.stop(); p->bgs.stop();
} }
void Audio::bgsFade(int time) void Audio::bgsFade(int time){
{
p->bgs.fadeOut(time); p->bgs.fadeOut(time);
} }
@ -301,13 +277,11 @@ void Audio::mePlay(const char *filename,
p->me.play(filename, (volume*p->bgm_volume)/100, pitch); p->me.play(filename, (volume*p->bgm_volume)/100, pitch);
} }
void Audio::meStop() void Audio::meStop(){
{
p->me.stop(); p->me.stop();
} }
void Audio::meFade(int time) void Audio::meFade(int time){
{
p->me.fadeOut(time); p->me.fadeOut(time);
} }
@ -319,36 +293,30 @@ void Audio::sePlay(const char *filename,
p->se.play(filename, (volume*p->sfx_volume)/100, pitch); p->se.play(filename, (volume*p->sfx_volume)/100, pitch);
} }
void Audio::seStop() void Audio::seStop(){
{
p->se.stop(); p->se.stop();
} }
float Audio::bgmPos() float Audio::bgmPos(){
{
return p->bgm.playingOffset(); return p->bgm.playingOffset();
} }
float Audio::bgsPos() float Audio::bgsPos(){
{
return p->bgs.playingOffset(); return p->bgs.playingOffset();
} }
void Audio::reset() void Audio::reset(){
{
p->bgm.stop(); p->bgm.stop();
p->bgs.stop(); p->bgs.stop();
p->me.stop(); p->me.stop();
p->se.stop(); p->se.stop();
} }
int Audio::getBGM_Volume() const int Audio::getBGM_Volume() const{
{
return p->bgm_volume; return p->bgm_volume;
} }
void Audio::setBGM_Volume(int value) void Audio::setBGM_Volume(int value){
{
if(value > 100){ if(value > 100){
value = 100; value = 100;
}else if(value < 0){ }else if(value < 0){
@ -363,13 +331,11 @@ void Audio::setBGM_Volume(int value)
p->me.unlockStream(); p->me.unlockStream();
} }
int Audio::getSFX_Volume() const int Audio::getSFX_Volume() const{
{
return p->sfx_volume; return p->sfx_volume;
} }
void Audio::setSFX_Volume(int value) void Audio::setSFX_Volume(int value){
{
if(value > 100){ if(value > 100){
value = 100; value = 100;
}else if(value < 0){ }else if(value < 0){

View file

@ -65,12 +65,11 @@ static inline const char* glGetStringInt(GLenum name){
return (const char*) gl.GetString(name); return (const char*) gl.GetString(name);
} }
static void static void printGLInfo(){
printGLInfo(){ Debug() << "[main.cpp]GL Vendor :" << glGetStringInt(GL_VENDOR);
Debug() << "GL Vendor :" << glGetStringInt(GL_VENDOR); Debug() << "[main.cpp]GL Renderer :" << glGetStringInt(GL_RENDERER);
Debug() << "GL Renderer :" << glGetStringInt(GL_RENDERER); Debug() << "[main.cpp]GL Version :" << glGetStringInt(GL_VERSION);
Debug() << "GL Version :" << glGetStringInt(GL_VERSION); Debug() << "[main.cpp]GLSL Version :" << glGetStringInt(GL_SHADING_LANGUAGE_VERSION);
Debug() << "GLSL Version :" << glGetStringInt(GL_SHADING_LANGUAGE_VERSION);
} }
int rgssThreadFun(void *userdata){ int rgssThreadFun(void *userdata){
@ -89,7 +88,7 @@ int rgssThreadFun(void *userdata){
glCtx = SDL_GL_CreateContext(win); glCtx = SDL_GL_CreateContext(win);
if (!glCtx){ if (!glCtx){
rgssThreadError(threadData, std::string("Error creating context: ") + SDL_GetError()); rgssThreadError(threadData, std::string("[rgssThreadFun]Error creating context: ") + SDL_GetError());
return 0; return 0;
} }
@ -123,7 +122,7 @@ int rgssThreadFun(void *userdata){
ALCcontext *alcCtx = alcCreateContext(threadData->alcDev, 0); ALCcontext *alcCtx = alcCreateContext(threadData->alcDev, 0);
if (!alcCtx){ if (!alcCtx){
rgssThreadError(threadData, "Error creating OpenAL context"); rgssThreadError(threadData, "[rgssThreadFun]Error creating OpenAL context");
SDL_GL_DestroyContext(glCtx); SDL_GL_DestroyContext(glCtx);
return 0; return 0;
@ -376,7 +375,7 @@ int main(int argc, char *argv[]){
for (int i = 0; i < 1000; ++i){ for (int i = 0; i < 1000; ++i){
/* We can stop waiting when the request was ack'd */ /* We can stop waiting when the request was ack'd */
if (rtData.rqTermAck){ if (rtData.rqTermAck){
Debug() << "RGSS thread ack'd request after" << i*10 << "ms"; Debug() << "[main]RGSS thread ack'd request after" << i*10 << "ms";
break; break;
} }
@ -389,7 +388,7 @@ int main(int argc, char *argv[]){
if (rtData.rqTermAck) if (rtData.rqTermAck)
SDL_WaitThread(rgssThread, 0); SDL_WaitThread(rgssThread, 0);
else else
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(), "The RGSS script seems to be stuck and OneShot: sunshine will now force quit", win); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(), "The RGSS script seems to be stuck and OneShot will now force quit", win);
if (!rtData.rgssErrorMsg.empty()){ if (!rtData.rgssErrorMsg.empty()){
Debug() << rtData.rgssErrorMsg; Debug() << rtData.rgssErrorMsg;
@ -400,7 +399,7 @@ int main(int argc, char *argv[]){
/* Clean up any remainin events */ /* Clean up any remainin events */
eventThread.cleanup(); eventThread.cleanup();
Debug() << "Shutting down."; Debug() << "[main]Shutting down.";
unloadLocale(); unloadLocale();
unloadLanguageMetadata(); unloadLanguageMetadata();

View file

@ -37,6 +37,8 @@
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include "xdg-user-dir-lookup.h" #include "xdg-user-dir-lookup.h"
#endif #endif
#elif defined __FreeBSD__ || __NetBSD__ || __OpenBSD__
#error "Work in progress:3"
#else #else
#error "Operating system not detected." #error "Operating system not detected."
#endif #endif
@ -481,8 +483,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title){
#endif #endif
//Set type //Set type
switch (type) switch (type){
{
case MSG_INFO: case MSG_INFO:
case MSG_YESNO: case MSG_YESNO:
default: default:

View file

@ -192,8 +192,7 @@ struct WindowPrivate {
Quad baseTexQuad; Quad baseTexQuad;
struct WindowControls : public ViewportElement struct WindowControls : public ViewportElement{
{
WindowPrivate *p; WindowPrivate *p;
WindowControls(WindowPrivate *p, WindowControls(WindowPrivate *p,