1 | // SuperTux |
2 | // Copyright (C) 2006 Matthias Braun <matze@braunis.de> |
3 | // |
4 | // This program is free software: you can redistribute it and/or modify |
5 | // it under the terms of the GNU General Public License as published by |
6 | // the Free Software Foundation, either version 3 of the License, or |
7 | // (at your option) any later version. |
8 | // |
9 | // This program is distributed in the hope that it will be useful, |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | // GNU General Public License for more details. |
13 | // |
14 | // You should have received a copy of the GNU General Public License |
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | |
17 | #ifndef HEADER_SUPERTUX_SCRIPTING_FUNCTIONS_HPP |
18 | #define |
19 | |
20 | #ifndef SCRIPTING_API |
21 | #include <squirrel.h> |
22 | #include <string> |
23 | |
24 | #define __suspend |
25 | #define __custom(x) |
26 | #endif |
27 | |
28 | namespace scripting { |
29 | |
30 | /** Display the value of the argument. This is useful for inspecting tables. */ |
31 | SQInteger display(HSQUIRRELVM vm) __custom("t." ); |
32 | |
33 | /** Displays contents of the current stack */ |
34 | void print_stacktrace(HSQUIRRELVM vm); |
35 | |
36 | /** returns the currently running thread */ |
37 | SQInteger get_current_thread(HSQUIRRELVM vm) __custom("t" ); |
38 | |
39 | /** Should use christmas mode */ |
40 | bool is_christmas(); |
41 | |
42 | /** Display a text file and scrolls it over the screen (on next screenswitch) */ |
43 | void display_text_file(const std::string& filename); |
44 | |
45 | /** Load and display a worldmap (on next screenswitch) */ |
46 | void load_worldmap(const std::string& filename); |
47 | |
48 | /** Switch to a different worldmap after unloading current one, after exit_screen() is called */ |
49 | void set_next_worldmap(const std::string& dirname, const std::string& spawnpoint); |
50 | |
51 | /** Load and display a level (on next screenswitch) */ |
52 | void load_level(const std::string& filename); |
53 | |
54 | /** Suspend the script execution for the specified number of seconds */ |
55 | void wait(HSQUIRRELVM vm, float seconds) __suspend; |
56 | |
57 | /** Suspend the script execution until the current screen has been changed */ |
58 | void wait_for_screenswitch(HSQUIRRELVM vm) __suspend; |
59 | |
60 | /** Exits the currently running screen (force exit from worldmap or scrolling text for example) */ |
61 | void exit_screen(); |
62 | |
63 | /** Translate a text into the users language (by looking it up in the .po files) */ |
64 | std::string translate(const std::string& text); |
65 | std::string _(const std::string& text); |
66 | |
67 | std::string translate_plural(const std::string& text, const std::string& |
68 | text_plural, int num); |
69 | std::string __(const std::string& text, const std::string& text_plural, int num); |
70 | |
71 | /** Load a script file and executes it. This is typically used to import functions from external files. */ |
72 | void import(HSQUIRRELVM v, const std::string& filename); |
73 | |
74 | /** Save world state to scripting table */ |
75 | void save_state(); |
76 | |
77 | /** Load world state from scripting table */ |
78 | void load_state(); |
79 | |
80 | /** enable/disable drawing of collision rectangles */ |
81 | void debug_collrects(bool enable); |
82 | |
83 | /** enable/disable drawing of fps */ |
84 | void debug_show_fps(bool enable); |
85 | |
86 | /** enable/disable drawing of non-solid layers */ |
87 | void debug_draw_solids_only(bool enable); |
88 | |
89 | /** enable/disable drawing of editor images */ |
90 | void debug_draw_editor_images(bool enable); |
91 | |
92 | /** enable/disable worldmap ghost mode */ |
93 | void debug_worldmap_ghost(bool enable); |
94 | |
95 | /** Changes music to musicfile */ |
96 | void play_music(const std::string& musicfile); |
97 | |
98 | /** Stops the music */ |
99 | void stop_music(float fadetime); |
100 | |
101 | /** Plays a soundfile */ |
102 | void play_sound(const std::string& soundfile); |
103 | |
104 | /** Set the game_speed */ |
105 | void set_game_speed(float speed); |
106 | |
107 | /** speeds Tux up */ |
108 | void grease(); |
109 | |
110 | /** makes Tux invincible for 10000 units of time */ |
111 | void invincible(); |
112 | |
113 | /** makes Tux a ghost, i.e. lets him float around and through solid objects */ |
114 | void ghost(); |
115 | |
116 | /** recall Tux's invincibility and ghost status */ |
117 | void mortal(); |
118 | |
119 | /** reinitialise and respawn Tux at the beginning of the current level */ |
120 | void restart(); |
121 | |
122 | /** print Tux's current coordinates in a level */ |
123 | void whereami(); |
124 | |
125 | /** move Tux near the end of the level */ |
126 | void gotoend(); |
127 | |
128 | /** move Tux to the X and Y blocks relative to his position */ |
129 | void warp(float offset_x, float offset_y); |
130 | |
131 | /** show the camera's coordinates */ |
132 | void camera(); |
133 | |
134 | /** adjust gamma */ |
135 | void set_gamma(float gamma); |
136 | |
137 | /** exit the game */ |
138 | void quit(); |
139 | |
140 | /** Returns a random integer */ |
141 | int rand(); |
142 | |
143 | /** Record a demo to the given file. */ |
144 | void record_demo(const std::string& filename); |
145 | |
146 | /** Play back a demo from the given file. */ |
147 | void play_demo(const std::string& filename); |
148 | |
149 | } // namespace scripting |
150 | |
151 | #endif |
152 | |
153 | /* EOF */ |
154 | |