From cb45fd02e9f064a2368b6ebb393e91ad0e254f52 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ond=C5=99ej=20Ho=C5=A1ek?= Date: Wed, 31 Jan 2007 17:07:21 +0000 Subject: [PATCH] * B140: Hack alarm: "fixed" the black-fading screen as requested by jonaskoelker. * Fixed "emtpy" spelling mistake SVN-Revision: 4759 --- data/levels/world1/worldmap.stwm | 7 +++++++ data/levels/world2/worldmap.stwm | 8 ++++++++ src/physfs/physfs_sdl.cpp | 2 +- src/physfs/physfs_stream.cpp | 2 +- src/scripting/functions.cpp | 5 +++++ src/scripting/functions.hpp | 6 ++++++ src/scripting/wrapper.cpp | 25 +++++++++++++++++++++++++ 7 files changed, 53 insertions(+), 2 deletions(-) diff --git a/data/levels/world1/worldmap.stwm b/data/levels/world1/worldmap.stwm index 55cc59ce9..f8b1f1086 100644 --- a/data/levels/world1/worldmap.stwm +++ b/data/levels/world1/worldmap.stwm @@ -23,6 +23,13 @@ state.world <- \"levels/world2/worldmap.stwm\";") (x 37) (y 20) ) + (special-tile + (invisible-tile #t) + (script "abort_screenfade();") + (apply-to-direction "south") + (x 37) + (y 19) + ) (sprite-change (change-on-touch #t) (initial-stay-action #f) diff --git a/data/levels/world2/worldmap.stwm b/data/levels/world2/worldmap.stwm index 5775ef6b2..f9a032a4a 100644 --- a/data/levels/world2/worldmap.stwm +++ b/data/levels/world2/worldmap.stwm @@ -13,6 +13,14 @@ state.world <- \"levels/world1/worldmap.stwm\";") (x 8) (y 45) + (apply-to-direction "east") + ) + (special-tile + (invisible-tile #t) + (script "abort_screenfade();") + (x 9) + (y 45) + (apply-to-direction "west") ) (sprite-change (change-on-touch #f) diff --git a/src/physfs/physfs_sdl.cpp b/src/physfs/physfs_sdl.cpp index 0d6730b4d..4ad2b6e34 100644 --- a/src/physfs/physfs_sdl.cpp +++ b/src/physfs/physfs_sdl.cpp @@ -80,7 +80,7 @@ SDL_RWops* get_physfs_SDLRWops(const std::string& filename) // check this as PHYSFS seems to be buggy and still returns a // valid pointer in this case if(filename == "") { - throw std::runtime_error("Couldn't open file: emtpy filename"); + throw std::runtime_error("Couldn't open file: empty filename"); } PHYSFS_file* file = (PHYSFS_file*) PHYSFS_openRead(filename.c_str()); diff --git a/src/physfs/physfs_stream.cpp b/src/physfs/physfs_stream.cpp index 1bc8d50e6..e1d155772 100644 --- a/src/physfs/physfs_stream.cpp +++ b/src/physfs/physfs_stream.cpp @@ -31,7 +31,7 @@ IFileStreambuf::IFileStreambuf(const std::string& filename) // check this as PHYSFS seems to be buggy and still returns a // valid pointer in this case if(filename == "") { - throw std::runtime_error("Couldn't open file: emtpy filename"); + throw std::runtime_error("Couldn't open file: empty filename"); } file = PHYSFS_openRead(filename.c_str()); if(file == 0) { diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index c2f8c98fb..36e470509 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -96,6 +96,11 @@ void shrink_screen(float dest_x, float dest_y, float seconds) main_loop->set_screen_fade(new ShrinkFade(Vector(dest_x, dest_y), seconds)); } +void abort_screenfade() +{ + main_loop->set_screen_fade(NULL); +} + std::string translate(const std::string& text) { return dictionary_manager.get_dictionary().translate(text); diff --git a/src/scripting/functions.hpp b/src/scripting/functions.hpp index b42aff5bb..d56f6c2f7 100644 --- a/src/scripting/functions.hpp +++ b/src/scripting/functions.hpp @@ -88,6 +88,12 @@ void fadeout_screen(float seconds); void shrink_screen(float dest_x, float dest_y, float seconds); /** + * Aborts any kind of previous screen fade; the screenchange will happen + * anyway. + */ +void abort_screenfade(); + +/** * Translate a text into the users language (by looking it up in the .po * files) */ diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index 1f8060b1a..e0ab1c23a 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -2861,6 +2861,25 @@ static SQInteger shrink_screen_wrapper(HSQUIRRELVM vm) } +static SQInteger abort_screenfade_wrapper(HSQUIRRELVM vm) +{ + (void) vm; + + try { + Scripting::abort_screenfade(); + + return 0; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'abort_screenfade'")); + return SQ_ERROR; + } + +} + static SQInteger translate_wrapper(HSQUIRRELVM vm) { const SQChar* arg0; @@ -3767,6 +3786,12 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'shrink_screen'"); } + sq_pushstring(v, "abort_screenfade", -1); + sq_newclosure(v, &abort_screenfade_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'abort_screenfade'"); + } + sq_pushstring(v, "translate", -1); sq_newclosure(v, &translate_wrapper, 0); if(SQ_FAILED(sq_createslot(v, -3))) { -- 2.11.0