mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
Code cleanup
This commit is contained in:
parent
5fd7991db2
commit
e1ced21b34
10 changed files with 22 additions and 86 deletions
|
|
@ -154,10 +154,8 @@ void audioBindingInit(){
|
|||
BIND_PLAY_STOP_FADE( bgs );
|
||||
BIND_PLAY_STOP_FADE( me );
|
||||
|
||||
if (rgssVer >= 3){
|
||||
BIND_POS( bgm );
|
||||
BIND_POS( bgs );
|
||||
}
|
||||
|
||||
BIND_PLAY_STOP( se )
|
||||
|
||||
|
|
|
|||
|
|
@ -75,9 +75,6 @@ void fileIntBindingInit();
|
|||
|
||||
void journalBindingInit();
|
||||
void wallpaperBindingInit();
|
||||
#ifdef __linux__
|
||||
void wallpaperBindingTerminate();
|
||||
#endif
|
||||
void nikoBindingInit();
|
||||
void oneshotBindingInit();
|
||||
void SunshineBindingInit();
|
||||
|
|
@ -104,16 +101,12 @@ static void mriBindingInit(){
|
|||
spriteBindingInit();
|
||||
viewportBindingInit();
|
||||
planeBindingInit();
|
||||
|
||||
windowBindingInit();
|
||||
tilemapBindingInit();
|
||||
|
||||
TimeBindingInit();
|
||||
|
||||
inputBindingInit();
|
||||
audioBindingInit();
|
||||
graphicsBindingInit();
|
||||
|
||||
fileIntBindingInit();
|
||||
journalBindingInit();
|
||||
wallpaperBindingInit();
|
||||
|
|
@ -126,21 +119,16 @@ static void mriBindingInit(){
|
|||
printf("[mriBindingInit] Done\n");
|
||||
printf("[mriBindingInit] RGSS version: %i\n", rgssVer);
|
||||
#endif
|
||||
if (rgssVer >= 3){
|
||||
|
||||
_rb_define_module_function(rb_mKernel, "rgss_main", mriRgssMain);
|
||||
_rb_define_module_function(rb_mKernel, "rgss_stop", mriRgssStop);
|
||||
|
||||
_rb_define_module_function(rb_mKernel, "msgbox", mriPrint);
|
||||
_rb_define_module_function(rb_mKernel, "msgbox_p", mriP);
|
||||
|
||||
rb_define_global_const("RGSS_VERSION", rb_str_new_cstr("3.0.1"));
|
||||
}else{
|
||||
_rb_define_module_function(rb_mKernel, "print", mriPrint);
|
||||
_rb_define_module_function(rb_mKernel, "p", mriP);
|
||||
|
||||
rb_define_alias(rb_singleton_class(rb_mKernel), "_mkxp_kernel_caller_alias", "caller");
|
||||
_rb_define_module_function(rb_mKernel, "caller", _kernelCaller);
|
||||
}
|
||||
|
||||
rb_eval_string(module_rpg1);
|
||||
|
||||
|
|
@ -153,7 +141,6 @@ static void mriBindingInit(){
|
|||
/* Load global constants */
|
||||
rb_gv_set("MKXP", Qtrue);
|
||||
|
||||
#ifdef DEBUG
|
||||
VALUE debug = rb_bool_new(shState->config().editor.debug);
|
||||
if (rgssVer == 1)
|
||||
rb_gv_set("DEBUG", debug);
|
||||
|
|
@ -161,15 +148,10 @@ static void mriBindingInit(){
|
|||
rb_gv_set("TEST", debug);
|
||||
|
||||
rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void showMsg(const std::string &msg){
|
||||
#ifdef NDEBUG
|
||||
shState->eThread().showMessageBox(msg.c_str());
|
||||
#else
|
||||
Debug() << "[DEBUG] " + msg.c_str();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void printP(int argc, VALUE *argv, const char *convMethod, const char *sep){
|
||||
|
|
@ -205,7 +187,6 @@ RB_METHOD(mriP){
|
|||
|
||||
RB_METHOD(mkxpDataDirectory){
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
const std::string &path = shState->config().customDataPath;
|
||||
const char *s = path.empty() ? "." : path.c_str();
|
||||
|
||||
|
|
@ -214,7 +195,6 @@ RB_METHOD(mkxpDataDirectory){
|
|||
|
||||
RB_METHOD(mkxpPuts){
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
const char *str;
|
||||
rb_get_args(argc, argv, "z", &str RB_ARG_END);
|
||||
|
||||
|
|
@ -234,7 +214,6 @@ RB_METHOD(mkxpRawKeyStates){
|
|||
|
||||
RB_METHOD(mkxpMouseInWindow){
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_bool_new(EventThread::mouseState.inWindow);
|
||||
}
|
||||
|
||||
|
|
@ -245,7 +224,6 @@ static VALUE rgssMainCb(VALUE block){
|
|||
|
||||
static VALUE rgssMainRescue(VALUE arg, VALUE exc){
|
||||
VALUE *excRet = (VALUE*) arg;
|
||||
|
||||
*excRet = exc;
|
||||
|
||||
return Qnil;
|
||||
|
|
@ -406,11 +384,7 @@ static void runRMXPScripts(BacktraceData &btData){
|
|||
}
|
||||
|
||||
/* Set the debug flag */
|
||||
#ifdef DEBUG
|
||||
rb_gv_set("$debug", conf.debugMode ? Qtrue : Qfalse);
|
||||
#else
|
||||
rb_gv_set("$debug", Qfalse);
|
||||
#endif
|
||||
|
||||
rb_gv_set("$RGSS_SCRIPTS", scriptArray);
|
||||
|
||||
|
|
@ -460,7 +434,6 @@ static void runRMXPScripts(BacktraceData &btData){
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
rb_ary_store(script, 3, rb_str_new_cstr(decodeBuffer.c_str()));
|
||||
}
|
||||
|
||||
|
|
@ -510,7 +483,6 @@ static void showExc(VALUE exc, const BacktraceData &btData){
|
|||
VALUE msg = rb_funcall2(exc, rb_intern("message"), 0, NULL);
|
||||
VALUE bt0 = rb_ary_entry(bt, 0);
|
||||
VALUE name = rb_class_path(rb_obj_class(exc));
|
||||
|
||||
VALUE ds = rb_sprintf("%" PRIsVALUE ": %" PRIsVALUE " (%" PRIsVALUE ")",
|
||||
bt0, exc, name);
|
||||
/* omit "useless" last entry (from ruby:1:in `eval') */
|
||||
|
|
@ -589,7 +561,6 @@ static void mriBindingExecute(){
|
|||
rb_ary_push(lpaths, pathv);
|
||||
}
|
||||
}
|
||||
|
||||
RbData rbData;
|
||||
shState->setBindingData(&rbData);
|
||||
BacktraceData btData;
|
||||
|
|
@ -625,4 +596,3 @@ static void mriBindingReset(){
|
|||
#endif
|
||||
rb_raise(getRbData()->exc[Reset], " ");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -412,13 +412,10 @@ void bitmapBindingInit(){
|
|||
_rb_define_method(klass, "hue_change", bitmapHueChange);
|
||||
_rb_define_method(klass, "draw_text", bitmapDrawText);
|
||||
_rb_define_method(klass, "text_size", bitmapTextSize);
|
||||
|
||||
if (rgssVer >= 2){
|
||||
_rb_define_method(klass, "gradient_fill_rect", bitmapGradientFillRect);
|
||||
_rb_define_method(klass, "clear_rect", bitmapClearRect);
|
||||
_rb_define_method(klass, "blur", bitmapBlur);
|
||||
_rb_define_method(klass, "radial_blur", bitmapRadialBlur);
|
||||
}
|
||||
|
||||
INIT_PROP_BIND(Bitmap, Font, "font");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ static void disposableBindingInit(VALUE klass){
|
|||
|
||||
/* Make sure we always have access to the original method, even
|
||||
* if it is overridden by user scripts */
|
||||
if (rgssVer == 1)
|
||||
rb_define_alias(klass, "_mkxp_dispose_alias", "dispose");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@ RB_NA_METHOD(fileIntClose){
|
|||
#endif
|
||||
SDL_CloseIO(ops);
|
||||
setPrivateData(self, nullptr);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
RB_NA_METHOD(fileIntGetByte){
|
||||
|
|
|
|||
|
|
@ -263,7 +263,6 @@ void fontBindingInit(){
|
|||
|
||||
rb_iv_set(klass, "default_name", defNamesObj);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color", ColorType);
|
||||
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
|
||||
|
|
@ -271,15 +270,9 @@ void fontBindingInit(){
|
|||
INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
|
||||
|
||||
if (rgssVer >= 2){
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
|
||||
}
|
||||
|
||||
if (rgssVer >= 3){
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
|
||||
}
|
||||
|
||||
rb_define_class_method(klass, "exist?", fontDoesExist);
|
||||
|
||||
|
|
@ -292,12 +285,8 @@ void fontBindingInit(){
|
|||
INIT_PROP_BIND(Font, Italic, "italic");
|
||||
INIT_PROP_BIND(Font, Color, "color");
|
||||
|
||||
if (rgssVer >= 2){
|
||||
INIT_PROP_BIND(Font, Shadow, "shadow");
|
||||
}
|
||||
|
||||
if (rgssVer >= 3){
|
||||
INIT_PROP_BIND(Font, Outline, "outline");
|
||||
INIT_PROP_BIND(Font, OutColor, "out_color");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,9 +219,7 @@ void graphicsBindingInit(){
|
|||
|
||||
INIT_GRA_PROP_BIND( Brightness, "brightness" );
|
||||
|
||||
if (rgssVer >= 3){
|
||||
_rb_define_module_function(module, "play_movie", graphicsPlayMovie);
|
||||
}
|
||||
|
||||
INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" );
|
||||
INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" );
|
||||
|
|
|
|||
|
|
@ -56,56 +56,45 @@ static int getButtonArg(int argc, VALUE *argv){
|
|||
|
||||
RB_METHOD(inputPress){
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
int num = getButtonArg(argc, argv);
|
||||
|
||||
return rb_bool_new(shState->input().isPressed(num));
|
||||
}
|
||||
|
||||
RB_METHOD(inputTrigger){
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
int num = getButtonArg(argc, argv);
|
||||
|
||||
return rb_bool_new(shState->input().isTriggered(num));
|
||||
}
|
||||
|
||||
RB_METHOD(inputRepeat){
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
int num = getButtonArg(argc, argv);
|
||||
|
||||
return rb_bool_new(shState->input().isRepeated(num));
|
||||
}
|
||||
|
||||
RB_METHOD(inputDir4){
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_fix_new(shState->input().dir4Value());
|
||||
}
|
||||
|
||||
RB_METHOD(inputDir8){
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_fix_new(shState->input().dir8Value());
|
||||
}
|
||||
|
||||
/* Non-standard extensions */
|
||||
RB_METHOD(inputMouseX){
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_fix_new(shState->input().mouseX());
|
||||
}
|
||||
|
||||
RB_METHOD(inputMouseY){
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_fix_new(shState->input().mouseY());
|
||||
}
|
||||
|
||||
RB_METHOD(inputQuit){
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_bool_new(shState->input().hasQuit());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@
|
|||
#include "exception.h"
|
||||
|
||||
template<class C>
|
||||
static VALUE
|
||||
serializableDump(int, VALUE *, VALUE self){
|
||||
static VALUE serializableDump(int, VALUE *, VALUE self){
|
||||
Serializable *s = getPrivateData<C>(self);
|
||||
|
||||
int dataSize = s->serialSize();
|
||||
|
|
|
|||
|
|
@ -120,7 +120,6 @@ void spriteBindingInit(){
|
|||
INIT_PROP_BIND( Sprite, Tone, "tone" );
|
||||
INIT_PROP_BIND( Sprite, Obscured, "obscured" );
|
||||
|
||||
if (rgssVer >= 2){
|
||||
_rb_define_method(klass, "width", spriteWidth);
|
||||
_rb_define_method(klass, "height", spriteHeight);
|
||||
|
||||
|
|
@ -130,5 +129,4 @@ void spriteBindingInit(){
|
|||
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
|
||||
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
|
||||
INIT_PROP_BIND( Sprite, WavePhase, "wave_phase" );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue