From: Matthias Braun Date: Sun, 8 May 2005 23:23:03 +0000 (+0000) Subject: we can now fade in scripts X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e5345cbdfe499dff26e2c93107e871bb0af905cd;p=supertux.git we can now fade in scripts SVN-Revision: 2454 --- diff --git a/data/levels/test/yeti.stl b/data/levels/test/yeti.stl index 0673514ea..017c472cd 100644 --- a/data/levels/test/yeti.stl +++ b/data/levels/test/yeti.stl @@ -100,6 +100,9 @@ (speed 0.500000) ) (spawnpoint (name "main") (x 480) (y 448)) + (init-script " +DisplayEffect.fade_in(2.5); +") (yeti (x 2) (y 177) @@ -110,7 +113,7 @@ Text.set_font(\"big\"); Text.fade_in(1.5); set_wakeup_time(4); suspend(); -Text.fade_out(1); +DisplayEffect.fade_out(1.5); set_wakeup_time(1.5); suspend(); Level.finish(); diff --git a/src/object/display_effect.cpp b/src/object/display_effect.cpp new file mode 100644 index 000000000..0d85a8037 --- /dev/null +++ b/src/object/display_effect.cpp @@ -0,0 +1,102 @@ +#include +#include "display_effect.h" + +#include +#include "video/drawing_context.h" +#include "main.h" + +DisplayEffect::DisplayEffect() + : type(NO_FADE), fadetime(0), fading(0), black(false) +{ +} + +DisplayEffect::~DisplayEffect() +{ +} + +void +DisplayEffect::action(float elapsed_time) +{ + switch(type) { + case NO_FADE: + return; + case FADE_IN: + fading -= elapsed_time; + if(fading < 0) { + type = NO_FADE; + } + break; + case FADE_OUT: + fading -= elapsed_time; + if(fading < 0) { + type = NO_FADE; + black = true; + } + break; + default: + assert(false); + } +} + +void +DisplayEffect::draw(DrawingContext& context) +{ + if(!black && type == NO_FADE) + return; + + context.push_transform(); + context.set_translation(Vector(0, 0)); + + uint8_t alpha; + if(black) { + alpha = 255; + } else { + switch(type) { + case FADE_IN: + alpha = static_cast + (fading * 255.0 / fadetime); + break; + case FADE_OUT: + alpha = static_cast + ((fadetime-fading) * 255.0 / fadetime); + break; + default: + alpha = 0; + assert(false); + } + } + context.draw_filled_rect(Vector(0, 0), Vector(SCREEN_WIDTH, SCREEN_HEIGHT), + Color(0, 0, 0, alpha), LAYER_GUI-10); + context.pop_transform(); +} + +void +DisplayEffect::fade_out(float fadetime) +{ + black = false; + this->fadetime = fadetime; + fading = fadetime; + type = FADE_OUT; +} + +void +DisplayEffect::fade_in(float fadetime) +{ + black = false; + this->fadetime = fadetime; + fading = fadetime; + type = FADE_IN; +} + +void +DisplayEffect::set_black(bool enabled) +{ + black = enabled; +} + +bool +DisplayEffect::is_black() +{ + return black; +} + diff --git a/src/object/display_effect.h b/src/object/display_effect.h new file mode 100644 index 000000000..0d0da2741 --- /dev/null +++ b/src/object/display_effect.h @@ -0,0 +1,32 @@ +#ifndef __OBJECT_DISPLAY_EFFECT_H__ +#define __OBJECT_DISPLAY_EFFECT_H__ + +#include "scripting/display_effect.h" +#include "game_object.h" + +class DisplayEffect : public GameObject, public Scripting::DisplayEffect +{ +public: + DisplayEffect(); + virtual ~DisplayEffect(); + + void action(float elapsed_time); + void draw(DrawingContext& context); + + void fade_out(float fadetime); + void fade_in(float fadetime); + void set_black(bool enabled); + bool is_black(); + +private: + enum FadeType { + NO_FADE, FADE_IN, FADE_OUT + }; + FadeType type; + float fadetime; + float fading; + bool black; +}; + +#endif + diff --git a/src/object/text_object.cpp b/src/object/text_object.cpp index 298e787c1..a623a3498 100644 --- a/src/object/text_object.cpp +++ b/src/object/text_object.cpp @@ -79,8 +79,8 @@ TextObject::draw(DrawingContext& context) } context.draw_filled_rect(Vector(125, 50), Vector(550, 120), - Color(150, 180, 200, 125), LAYER_GUI-10); - context.draw_text(font, text, Vector(125+35, 50+35), LEFT_ALLIGN, LAYER_GUI); + Color(150, 180, 200, 125), LAYER_GUI-50); + context.draw_text(font, text, Vector(125+35, 50+35), LEFT_ALLIGN, LAYER_GUI-40); context.pop_transform(); } diff --git a/src/scripting/display.cpp b/src/scripting/display.cpp deleted file mode 100644 index 6da4e875d..000000000 --- a/src/scripting/display.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include - -#include -#include -#include "display.h" - -#define NOIMPL printf(__FUNCTION__ " not implemented\n"); - -namespace Scripting -{ - Display::Display() - {} - - Display::~Display() - {} - - void - Display::set_effect(const std::string& ) - {} -} - diff --git a/src/scripting/display.h b/src/scripting/display.h deleted file mode 100644 index 0cd272018..000000000 --- a/src/scripting/display.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __DISPLAY_H__ -#define __DISPLAY_H__ - -namespace Scripting -{ - -class Display -{ -public: -#ifndef SCRIPTING_API - Display(); - ~Display(); -#endif - - void set_effect(const std::string& effect); -}; - -} - -#endif - diff --git a/src/scripting/display_effect.h b/src/scripting/display_effect.h new file mode 100644 index 000000000..74fad9cf9 --- /dev/null +++ b/src/scripting/display_effect.h @@ -0,0 +1,32 @@ +#ifndef __SCRIPTING_DISPLAY_EFFECT_H__ +#define __SCRIPTING_DISPLAY_EFFECT_H__ + +namespace Scripting +{ + +class DisplayEffect +{ +public: +#ifndef SCRIPTING_API + virtual ~DisplayEffect() + {} +#endif + + /// fade display to black + virtual void fade_out(float fadetime) = 0; + /// fade display from black to normal + virtual void fade_in(float fadetime) = 0; + /// set display black (or back to normal) + virtual void set_black(bool enabled) = 0; + /// check if display is set to black + virtual bool is_black() = 0; + + // fade display until just a small visible circle is left + // (like what happens in some cartoons at the end) + // void shrink_fade(Vector goal, float radius, float fadetime); +}; + +} + +#endif + diff --git a/src/scripting/script_interpreter.cpp b/src/scripting/script_interpreter.cpp index d9662d5dd..cf3937e90 100644 --- a/src/scripting/script_interpreter.cpp +++ b/src/scripting/script_interpreter.cpp @@ -17,8 +17,10 @@ #include "sector.h" #include "object/text_object.h" #include "object/scripted_object.h" +#include "object/display_effect.h" #include "scripting/sound.h" #include "scripting/scripted_object.h" +#include "scripting/display_effect.h" static void printfunc(HSQUIRRELVM, const char* str, ...) { @@ -68,19 +70,26 @@ ScriptInterpreter::ScriptInterpreter(Sector* sector) if(!scripted_object) continue; - std::cout << "Exposing " << scripted_object->get_name() << "\n"; expose_object(scripted_object, scripted_object->get_name(), "ScriptedObject"); } // expose some "global" objects sound = new Scripting::Sound(); expose_object(sound, "Sound", "Sound"); + level = new Scripting::Level(); expose_object(level, "Level", "Level"); + TextObject* text_object = new TextObject(); sector->add_object(text_object); Scripting::Text* text = static_cast (text_object); expose_object(text, "Text", "Text"); + + DisplayEffect* display_effect = new DisplayEffect(); + sector->add_object(display_effect); + Scripting::DisplayEffect* display_effect_api + = static_cast (display_effect); + expose_object(display_effect_api, "DisplayEffect", "DisplayEffect"); } ScriptInterpreter::~ScriptInterpreter() diff --git a/src/scripting/semantic.cache b/src/scripting/semantic.cache index d69301614..252805e92 100644 --- a/src/scripting/semantic.cache +++ b/src/scripting/semantic.cache @@ -45,38 +45,18 @@ :tokens '(("__LEVEL_H__" variable nil nil ((const . t)) nil nil [21 51]) ("Scripting" type "namespace" (("Level" type "class" (("public" label ((reparse-symbol . classsubparts)) [79 86]) ("Level" function ("Level" type "class") nil ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [113 121]) ("Level" function "void" nil ((destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [126 135]) ("finish" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [203 217]) ("spawn" function ("void") (("sector" variable ("std::string" type "class") nil ((const . t)) nil nil [289 315]) ("spawnpoint" variable ("std::string" type "class") nil ((const . t)) nil nil [316 346])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [278 347])) nil nil nil ((reparse-symbol . namespacesubparts)) [65 350])) nil nil nil nil [42 353])) :unmatched-syntax 'nil ) - (semanticdb-table "scripted_object.cpp" - :file "scripted_object.cpp" - :pointmax 952 - :major-mode 'c++-mode - :tokens '(("config.h" include t nil nil [1 20]) ("string" include t nil nil [22 39]) ("stdio.h" include t nil nil [40 58]) ("scripted_object.h" include nil nil nil [59 87]) ("NOIMPL" variable nil nil ((const . t)) nil nil [89 161]) ("Scripting" type "namespace" (("ScriptedObject" function ("ScriptedObject" type "class") nil ((parent . "ScriptedObject") (constructor . t)) nil ((reparse-symbol . namespacesubparts)) [187 224]) ("ScriptedObject" function "void" nil ((parent . "ScriptedObject") (destructor . t)) nil ((reparse-symbol . namespacesubparts)) [228 266]) ("set_animation" function ("void") (("" variable ("std::string" type "class") nil ((const . t)) nil nil [307 327])) ((parent . "ScriptedObject")) nil ((reparse-symbol . namespacesubparts)) [270 347]) ("get_animation" function ("std::string" type "class") nil ((parent . "ScriptedObject")) nil ((reparse-symbol . namespacesubparts)) [351 431]) ("move" function ("void") (("" variable "float" nil nil nil nil [463 470]) ("" variable "float" nil nil nil nil [471 478])) ((parent . "ScriptedObject")) nil ((reparse-symbol . namespacesubparts)) [435 498]) ("set_pos" function ("void") (("" variable "float" nil nil nil nil [533 540]) ("" variable "float" nil nil nil nil [541 548])) ((parent . "ScriptedObject")) nil ((reparse-symbol . namespacesubparts)) [502 568]) ("get_pos_x" function ("float") nil ((parent . "ScriptedObject")) nil ((reparse-symbol . namespacesubparts)) [572 642]) ("get_pos_y" function ("float") nil ((parent . "ScriptedObject")) nil ((reparse-symbol . namespacesubparts)) [646 716]) ("set_velocity" function ("void") (("" variable "float" nil nil nil nil [756 763]) ("" variable "float" nil nil nil nil [764 771])) ((parent . "ScriptedObject")) nil ((reparse-symbol . namespacesubparts)) [720 791]) ("get_velocity_x" function ("float") nil ((parent . "ScriptedObject")) nil ((reparse-symbol . namespacesubparts)) [795 870]) ("get_velocity_y" function ("float") nil ((parent . "ScriptedObject")) nil ((reparse-symbol . namespacesubparts)) [874 949])) nil nil nil nil [163 951])) - :unmatched-syntax '((punctuation 635 . 636) (punctuation 634 . 635) (symbol 620 . 634) (FLOAT 612 . 617)) - ) - (semanticdb-table "scripted_object.h" + (semanticdb-table "scripted_object.h" :file "scripted_object.h" :pointmax 699 :major-mode 'c++-mode :tokens '(("__SCRIPTED_OBJECT_H__" variable nil nil ((const . t)) nil nil [41 91]) ("Scripting" type "namespace" (("ScriptedObject" type "class" (("public" label ((reparse-symbol . classsubparts)) [128 135]) ("ScriptedObject" function ("ScriptedObject" type "class") nil ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [160 177]) ("ScriptedObject" function "void" nil ((typemodifiers "virtual") (destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [180 206]) ("set_animation" function ("void") (("animation" variable ("std::string" type "class") nil ((const . t)) nil nil [244 273])) ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [217 278]) ("get_animation" function ("std::string" type "class") nil ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [281 321]) ("move" function ("void") (("x" variable "float" nil nil nil nil [343 351]) ("y" variable "float" nil nil nil nil [352 360])) ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [325 365]) ("set_pos" function ("void") (("x" variable "float" nil nil nil nil [389 397]) ("y" variable "float" nil nil nil nil [398 406])) ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [368 411]) ("get_pos_x" function ("float") nil ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [414 444]) ("get_pos_y" function ("float") nil ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [447 477]) ("set_velocity" function ("void") (("x" variable "float" nil nil nil nil [506 514]) ("y" variable "float" nil nil nil nil [515 523])) ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [480 528]) ("get_velocity_x" function ("float") nil ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [531 566]) ("get_velocity_y" function ("float") nil ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [569 604]) ("set_visible" function ("void") (("visible" variable ("bool" type "class") nil nil nil nil [632 645])) ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [607 650]) ("is_visible" function ("bool" type "class") nil ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [653 683])) nil nil nil ((reparse-symbol . namespacesubparts)) [105 686])) nil nil nil nil [82 689])) :unmatched-syntax 'nil ) - (semanticdb-table "display.cpp" - :file "display.cpp" - :pointmax 280 - :major-mode 'c++-mode - :tokens '(("config.h" include t nil nil [1 20]) ("string" include t nil nil [22 39]) ("stdio.h" include t nil nil [40 58]) ("display.h" include nil nil nil [59 79]) ("NOIMPL" variable nil nil ((const . t)) nil nil [81 142]) ("Scripting" type "namespace" (("Display" function ("Display" type "class") nil ((parent . "Display") (constructor . t)) nil ((reparse-symbol . namespacesubparts)) [169 192]) ("Display" function "void" nil ((parent . "Display") (destructor . t)) nil ((reparse-symbol . namespacesubparts)) [196 220]) ("set_effect" function ("void") (("effect" variable ("std::string" type "class") nil ((const . t)) nil ((dirty . t)) [251 271])) ((parent . "Display")) nil ((reparse-symbol . namespacesubparts)) [224 276])) nil nil nil nil [145 278])) - :unmatched-syntax '((punctuation 142 . 143)) - ) - (semanticdb-table "display.h" - :file "display.h" - :pointmax 217 - :major-mode 'c++-mode - :tokens '(("__DISPLAY_H__" variable nil nil ((const . t)) nil nil [23 55]) ("Scripting" type "namespace" (("Display" type "class" (("public" label ((reparse-symbol . classsubparts)) [85 92]) ("Display" function ("Display" type "class") nil ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [119 129]) ("Display" function "void" nil ((destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [134 145]) ("set_effect" function ("void") (("effect" variable ("std::string" type "class") nil ((const . t)) nil nil [174 200])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [158 201])) nil nil nil ((reparse-symbol . namespacesubparts)) [69 204])) nil nil nil nil [46 207])) - ) - (semanticdb-table "script_interpreter.cpp" + (semanticdb-table "script_interpreter.cpp" :file "script_interpreter.cpp" - :pointmax 3471 + :pointmax 5137 :major-mode 'c++-mode - :tokens '(("config.h" include t nil nil [1 20]) ("script_interpreter.h" include nil nil nil [22 53]) ("stdarg.h" include t nil nil [55 74]) ("stdexcept" include t nil nil [75 95]) ("sstream" include t nil nil [96 114]) ("sqstdio.h" include t nil nil [115 135]) ("sqstdaux.h" include t nil nil [136 157]) ("sqstdblob.h" include t nil nil [158 180]) ("sqstdsystem.h" include t nil nil [181 205]) ("sqstdmath.h" include t nil nil [206 228]) ("sqstdstring.h" include t nil nil [229 253]) ("wrapper.h" include nil nil nil [255 275]) ("wrapper_util.h" include nil nil nil [276 301]) ("printfunc" function ("void") (("" variable ("HSQUIRRELVM" type "class") nil nil nil nil [325 337]) ("str" variable "char" nil ((const . t) (pointer . 1)) nil nil [338 354]) ("..." ((reparse-symbol . arg-sub-list)) [355 359])) ((typemodifiers "static")) nil nil [303 452]) ("ScriptInterpreter::_current" variable ("ScriptInterpreter" type "class") "0" ((pointer . 1)) nil nil [454 505]) ("ScriptInterpreter" function ("ScriptInterpreter" type "class") nil ((parent . "ScriptInterpreter") (constructor . t)) nil nil [507 1428]) ("ScriptInterpreter" function "void" nil ((parent . "ScriptInterpreter") (destructor . t)) nil nil [1430 1473]) ("squirrel_read_char" function ("SQInteger" type "class") (("file" variable ("SQUserPointer" type "class") nil nil nil nil [1511 1530])) ((typemodifiers "static")) nil nil [1475 1663]) ("load_script" function ("void") (("in" variable ("std::istream" type "class") nil nil nil nil [1702 1719]) ("sourcename" variable ("std::string" type "class") nil ((const . t)) nil nil [1720 1750])) ((parent . "ScriptInterpreter")) nil nil [1666 1882]) ("run_script" function ("void") nil ((parent . "ScriptInterpreter")) nil nil [1884 2061]) ("expose_object" function ("void") (("object" variable "void" nil ((pointer . 1)) nil nil [2101 2114]) ("name" variable ("std::string" type "class") nil ((const . t)) nil nil [2115 2139]) ("type" variable ("std::string" type "class") nil ((const . t)) nil nil [2173 2197])) ((parent . "ScriptInterpreter")) nil nil [2063 3161]) ("suspend" function ("void") (("seconds" variable "float" nil nil nil nil [3195 3209])) ((parent . "ScriptInterpreter")) nil nil [3163 3263]) ("update" function ("void") nil ((parent . "ScriptInterpreter")) nil nil [3265 3470])) + :tokens '(("config.h" include t nil nil [1 20]) ("script_interpreter.h" include nil nil nil [22 53]) ("stdarg.h" include t nil nil [55 74]) ("stdexcept" include t nil nil [75 95]) ("sstream" include t nil nil [96 114]) ("sqstdio.h" include t nil nil [115 135]) ("sqstdaux.h" include t nil nil [136 157]) ("sqstdblob.h" include t nil nil [158 180]) ("sqstdsystem.h" include t nil nil [181 205]) ("sqstdmath.h" include t nil nil [206 228]) ("sqstdstring.h" include t nil nil [229 253]) ("wrapper.h" include nil nil nil [255 275]) ("wrapper_util.h" include nil nil nil [276 301]) ("sector.h" include nil nil nil [302 321]) ("object/text_object.h" include nil nil nil [322 353]) ("object/scripted_object.h" include nil nil nil [354 389]) ("object/display_effect.h" include nil nil nil [390 424]) ("scripting/sound.h" include nil nil nil [425 453]) ("scripting/scripted_object.h" include nil nil nil [454 492]) ("scripting/display_effect.h" include nil nil nil [493 530]) ("printfunc" function ("void") (("" variable ("HSQUIRRELVM" type "class") nil nil nil nil [554 566]) ("str" variable "char" nil ((const . t) (pointer . 1)) nil nil [567 583]) ("..." ((reparse-symbol . arg-sub-list)) [584 588])) ((typemodifiers "static")) nil nil [532 681]) ("ScriptInterpreter::_current" variable ("ScriptInterpreter" type "class") "0" ((pointer . 1)) nil nil [683 734]) ("ScriptInterpreter" function ("ScriptInterpreter" type "class") (("sector" variable ("Sector" type "class") nil ((pointer . 1)) nil nil [773 788])) ((parent . "ScriptInterpreter") (constructor . t)) nil nil [736 2788]) ("ScriptInterpreter" function "void" nil ((parent . "ScriptInterpreter") (destructor . t)) nil nil [2790 2880]) ("squirrel_read_char" function ("SQInteger" type "class") (("file" variable ("SQUserPointer" type "class") nil nil nil nil [2918 2937])) ((typemodifiers "static")) nil nil [2882 3070]) ("load_script" function ("void") (("in" variable ("std::istream" type "class") nil nil nil nil [3109 3126]) ("sourcename" variable ("std::string" type "class") nil ((const . t)) nil nil [3127 3157])) ((parent . "ScriptInterpreter")) nil nil [3073 3289]) ("start_script" function ("void") nil ((parent . "ScriptInterpreter")) nil nil [3291 3575]) ("expose_object" function ("void") (("object" variable "void" nil ((pointer . 1)) nil nil [3615 3628]) ("name" variable ("std::string" type "class") nil ((const . t)) nil nil [3629 3653]) ("type" variable ("std::string" type "class") nil ((const . t)) nil nil [3687 3711])) ((parent . "ScriptInterpreter")) nil nil [3577 4675]) ("set_wakeup_time" function ("void") (("seconds" variable "float" nil nil nil nil [4717 4731])) ((parent . "ScriptInterpreter")) nil nil [4677 4766]) ("action" function ("void") (("" variable "float" nil nil nil nil [4799 4806])) ((parent . "ScriptInterpreter")) nil nil [4768 5084]) ("draw" function ("void") (("" variable ("DrawingContext" type "class") nil nil nil nil [5115 5132])) ((parent . "ScriptInterpreter")) nil nil [5086 5136])) :unmatched-syntax 'nil ) (semanticdb-table "wrapper_util.h" @@ -100,5 +80,11 @@ :tokens '(("__SCRIPT_INTERPRETER_H__" variable nil nil ((const . t)) nil nil [34 69]) ("squirrel.h" include t nil nil [68 89]) ("iostream" include t nil nil [90 109]) ("timer.h" include nil nil nil [110 128]) ("ScriptInterpreter" type "class" (("public" label ((reparse-symbol . classsubparts)) [156 163]) ("ScriptInterpreter" function ("ScriptInterpreter" type "class") nil ((constructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [166 186]) ("ScriptInterpreter" function "void" nil ((destructor . t) (prototype . t)) nil ((reparse-symbol . classsubparts)) [189 210]) ("load_script" function ("void") (("in" variable ("std::istream" type "class") nil nil nil nil [231 248]) ("sourcename" variable ("std::string" type "class") "\"\"" ((const . t)) nil nil [249 283])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [214 285]) ("run_script" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [288 306]) ("expose_object" function ("void") (("object" variable "void" nil ((pointer . 1)) nil nil [331 344]) ("name" variable ("std::string" type "class") nil ((const . t)) nil nil [345 369]) ("type" variable ("std::string" type "class") nil ((const . t)) nil nil [391 415])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [312 416]) ("suspend" function ("void") (("seconds" variable "float" nil nil nil nil [433 447])) ((prototype . t)) nil ((reparse-symbol . classsubparts)) [420 448]) ("update" function ("void") nil ((prototype . t)) nil ((reparse-symbol . classsubparts)) [451 465]) ("current" function ("ScriptInterpreter" type "class") nil ((typemodifiers "static") (pointer . 1)) nil ((reparse-symbol . classsubparts)) [469 533]) ("private" label ((reparse-symbol . classsubparts)) [535 543]) ("v" variable ("HSQUIRRELVM" type "class") nil nil nil nil [546 560]) ("_current" variable ("ScriptInterpreter" type "class") nil ((typemodifiers "static") (pointer . 1)) nil nil [563 598]) ("resume_timer" variable ("Timer" type "class") nil nil nil nil [601 620])) nil nil nil nil [130 623])) :unmatched-syntax 'nil ) + (semanticdb-table "display_effect.h" + :file "display_effect.h" + :pointmax 731 + :major-mode 'c++-mode + :tokens '(("__SCRIPTING_DISPLAY_EFFECT_H__" variable nil nil ((const . t)) nil nil [40 89]) ("Scripting" type "namespace" (("DisplayEffect" type "class" (("public" label ((reparse-symbol . classsubparts)) [125 132]) ("DisplayEffect" function "void" nil ((typemodifiers "virtual") (destructor . t)) nil ((reparse-symbol . classsubparts)) [159 190]) ("fade_out" function ("void") (("fadetime" variable "float" nil nil nil nil [255 270])) ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [233 275]) ("fade_in" function ("void") (("fadetime" variable "float" nil nil nil nil [343 358])) ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [322 363]) ("set_black" function ("void") (("enabled" variable ("bool" type "class") nil nil nil nil [437 450])) ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [414 455]) ("is_black" function ("bool" type "class") nil ((typemodifiers "virtual") (prototype . t) (pure-virtual . t)) nil ((reparse-symbol . classsubparts)) [501 529])) nil nil nil ((reparse-symbol . namespacesubparts)) [103 718])) nil nil nil nil [80 721])) + ) ) ) diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index 8b8263760..60bf5cee6 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -12,18 +12,53 @@ using namespace Scripting; -static int Display_set_effect_wrapper(HSQUIRRELVM v) +static int DisplayEffect_fade_out_wrapper(HSQUIRRELVM v) { - Scripting::Display* _this; + Scripting::DisplayEffect* _this; sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); - const char* arg0; - sq_getstring(v, 2, &arg0); + float arg0; + sq_getfloat(v, 2, &arg0); + + _this->fade_out(arg0); + + return 0; +} + +static int DisplayEffect_fade_in_wrapper(HSQUIRRELVM v) +{ + Scripting::DisplayEffect* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + float arg0; + sq_getfloat(v, 2, &arg0); + + _this->fade_in(arg0); - _this->set_effect(arg0); + return 0; +} + +static int DisplayEffect_set_black_wrapper(HSQUIRRELVM v) +{ + Scripting::DisplayEffect* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + SQBool arg0; + sq_getbool(v, 2, &arg0); + + _this->set_black(arg0); return 0; } +static int DisplayEffect_is_black_wrapper(HSQUIRRELVM v) +{ + Scripting::DisplayEffect* _this; + sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0); + + bool return_value = _this->is_black(); + + sq_pushbool(v, return_value); + return 1; +} + static int Camera_shake_wrapper(HSQUIRRELVM v) { Scripting::Camera* _this; @@ -344,8 +379,11 @@ WrappedFunction supertux_global_functions[] = { { 0, 0 } }; -static WrappedFunction supertux_Display_methods[] = { - { "set_effect", &Display_set_effect_wrapper }, +static WrappedFunction supertux_DisplayEffect_methods[] = { + { "fade_out", &DisplayEffect_fade_out_wrapper }, + { "fade_in", &DisplayEffect_fade_in_wrapper }, + { "set_black", &DisplayEffect_set_black_wrapper }, + { "is_black", &DisplayEffect_is_black_wrapper }, }; static WrappedFunction supertux_Camera_methods[] = { @@ -388,7 +426,7 @@ static WrappedFunction supertux_Text_methods[] = { }; WrappedClass supertux_classes[] = { - { "Display", supertux_Display_methods }, + { "DisplayEffect", supertux_DisplayEffect_methods }, { "Camera", supertux_Camera_methods }, { "Level", supertux_Level_methods }, { "ScriptedObject", supertux_ScriptedObject_methods }, diff --git a/src/scripting/wrapper.interface.h b/src/scripting/wrapper.interface.h index 6c83c4f6e..761a16605 100644 --- a/src/scripting/wrapper.interface.h +++ b/src/scripting/wrapper.interface.h @@ -1,5 +1,5 @@ /** This file is processes by miniswig to produce the scripting API */ -#include "display.h" +#include "display_effect.h" #include "camera.h" #include "level.h" #include "scripted_object.h"