diff --git a/binding-mri/oneshot-binding.cpp b/binding-mri/oneshot-binding.cpp index 447730d..46bad96 100644 --- a/binding-mri/oneshot-binding.cpp +++ b/binding-mri/oneshot-binding.cpp @@ -23,10 +23,12 @@ RB_METHOD(oneshotMsgBox) RB_UNUSED_PARAM; int type; - const char *body; - const char *title = 0; - rb_get_args(argc, argv, "iz|z", &type, &body, &title RB_ARG_END); - return rb_bool_new(shState->oneshot().msgbox(type, body, title)); + VALUE body; + VALUE title = Qnil; + rb_get_args(argc, argv, "iS|S", &type, &body, &title RB_ARG_END); + std::string bodyStr = std::string(RSTRING_PTR(body), RSTRING_LEN(body)); + std::string titleStr = (title == Qnil) ? "" : std::string(RSTRING_PTR(title), RSTRING_LEN(title)); + return rb_bool_new(shState->oneshot().msgbox(type, bodyStr.c_str(), titleStr.c_str())); } RB_METHOD(oneshotResetObscured) diff --git a/mkxp.pro b/mkxp.pro index cf06c11..9589698 100644 --- a/mkxp.pro +++ b/mkxp.pro @@ -66,7 +66,7 @@ win32 { PKGCONFIG += sigc++-2.0 pixman-1 zlib \ sdl2 SDL2_image SDL2_ttf openal SDL_sound vorbisfile freetype2 - LIBS += -lphysfs -lsecur32 + LIBS += -lphysfs -lsecur32 -lwinmm release { RC_FILE = assets/resources.rc diff --git a/scripts/EdText.rb b/scripts/EdText.rb index e6ebc81..310bdad 100644 --- a/scripts/EdText.rb +++ b/scripts/EdText.rb @@ -1,40 +1,40 @@ module EdText def self.blue_understand - Oneshot.msgbox Oneshot::Msg::YESNO, tr("Do you understand what this means?") + self.msgbox(Oneshot::Msg::YESNO, tr("Do you understand what this means?")) end + def self.info(text) - if(Graphics.fullscreen == true) - Graphics.fullscreen = false - $console = false - end - sleep 0.2 - Graphics.update - text.gsub!("\\p", $game_oneshot.player_name) - Oneshot.msgbox Oneshot::Msg::INFO, tr(text) - Graphics.frame_reset + # TODO tr text + self.msgbox(Oneshot::Msg::INFO, text) end + def self.yesno(text) - if(Graphics.fullscreen == true) - Graphics.fullscreen = false - $console = false - end - sleep 0.2 - Graphics.update - text.gsub!("\\p", $game_oneshot.player_name) - result = Oneshot.msgbox Oneshot::Msg::YESNO, tr(text) - Graphics.frame_reset - return result + # TODO tr text + self.msgbox(Oneshot::Msg::YESNO, text) end + def self.err(text) - if(Graphics.fullscreen == true) - Graphics.fullscreen = false - $console = false - end - sleep 0.2 - Graphics.update - text.gsub!("\\p", $game_oneshot.player_name) - result = Oneshot.msgbox Oneshot::Msg::ERR, tr(text) - Graphics.frame_reset - return result + # TODO tr text + self.msgbox(Oneshot::Msg::ERR, text) + end + + def self.msgbox(type, text) + if Graphics.fullscreen + Graphics.fullscreen = false + $console = false + sleep 0.2 + end + result = nil + thread = Thread.new do + result = Oneshot.msgbox(type, text + .gsub(/\s+\n\s+/, " ") + .gsub("\\p", $game_oneshot.player_name) + + " " * 10) + # HACK: Fuck + end + while thread.alive? + Graphics.update + end + result end end diff --git a/src/oneshot.cpp b/src/oneshot.cpp index 2c3afe6..6eece0f 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -15,6 +15,7 @@ #define WIN32_LEAN_AND_MEAN #define SECURITY_WIN32 #include + #include #include #include #include @@ -637,7 +638,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) { if (!title) title = ""; -#if defined OS_W32 +#if 0 //Get native window handle SDL_SysWMinfo wminfo; SDL_version version; @@ -667,7 +668,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) //Create message box WCHAR *wbody = w32_toWide(body); WCHAR *wtitle = w32_toWide(title); - int result = MessageBoxW(hwnd, wbody, wtitle, flags); + int result = MessageBoxW(N, wbody, wtitle, flags); delete [] title; delete [] body; @@ -698,19 +699,32 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) data.colorScheme = 0; data.title = title; data.message = body; +#ifdef OS_W32 + DWORD sound; +#endif //Set type switch (type) { case MSG_INFO: case MSG_YESNO: + default: data.flags = SDL_MESSAGEBOX_INFORMATION; +#ifdef OS_W32 + sound = SND_ALIAS_SYSTEMQUESTION; +#endif break; case MSG_WARN: data.flags = SDL_MESSAGEBOX_WARNING; +#ifdef OS_W32 + sound = SND_ALIAS_SYSTEMEXCLAMATION; + #endif break; case MSG_ERR: data.flags = SDL_MESSAGEBOX_WARNING; +#ifdef OS_W32 + sound = SND_ALIAS_SYSTEMASTERISK; +#endif break; } @@ -720,6 +734,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) case MSG_INFO: case MSG_WARN: case MSG_ERR: + default: data.numbuttons = 1; data.buttons = buttonsOk; break; @@ -730,6 +745,9 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) } //Show messagebox +#ifdef OS_W32 + PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC); +#endif int button; SDL_ShowMessageBox(&data, &button); return button ? true : false;