diff --git a/.github/workflows/gnu_linux.yml b/.github/workflows/gnu_linux.yml index f8dfd78a..c55ec6ba 100644 --- a/.github/workflows/gnu_linux.yml +++ b/.github/workflows/gnu_linux.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 1 - submodules: true + submodules: recursive - name: Install 32-bit dependencies if: ${{ matrix.arch == 32 }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c935fcd0..3f1d1005 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 1 - submodules: true + submodules: recursive - name: Use cached dependencies id: cache-dependencies diff --git a/.gitmodules b/.gitmodules index 60d60edb..0e29c642 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ -[submodule "rte/external/miniswig"] - path = rte/external/miniswig - url = https://github.com/WindstilleTeam/miniswig -[submodule "rte/external/squirrel"] - path = rte/external/squirrel - url = https://github.com/albertodemichelis/squirrel.git [submodule "rte/external/physfs"] path = rte/external/physfs url = https://github.com/icculus/physfs +[submodule "rte/external/simplesquirrel"] + path = rte/external/simplesquirrel + url = https://github.com/SuperTux/simplesquirrel diff --git a/rte/CMakeLists.txt b/rte/CMakeLists.txt index 6c061505..9d3bba7e 100644 --- a/rte/CMakeLists.txt +++ b/rte/CMakeLists.txt @@ -30,12 +30,6 @@ if (USE_SDL2_MIXER) option(USE_FASTFILL "Use an O(1) algorithm for replacing unloaded sounds with new sounds instead of the original O(n) algorithm" ON) endif() -if (USE_SDL2_MIXER) - set(AUDIO_SOURCE src/audio/audio_sdl2.cpp) -else() - set(AUDIO_SOURCE src/audio/audio_none.cpp) -endif() - # preprocess config.hpp, used for optional libraries configure_file(src/config.hpp.in config.hpp) @@ -73,8 +67,9 @@ find_package(SDL2 REQUIRED) find_package(SDL2_image REQUIRED) find_package(SDL2_gfx REQUIRED) +add_subdirectory("${CMAKE_SOURCE_DIR}/external/simplesquirrel/") + include(ProvidePhysFS) -include(ProvideSquirrel) # If static linking is enabled, link additional libraries # Also, look at all of the dependencies it uses. This is one of the reasons why the portability API exists. @@ -104,20 +99,14 @@ if(BUILD_STATIC_LIBS) endif() endif() -# Include additional scripts -include(BuildMiniswigWrapper) - # Set include directories include_directories(${SDL2_INCLUDE_DIRS}) include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src") # Search for source files and copy the test suite to the output directory -file(GLOB SRCFILES src/api/*.cpp +file(GLOB SRCFILES src/audio/*.cpp src/brux/*.cpp - ${AUDIO_SOURCE} - src/external/*.c - src/squirrel/*.cpp - src/squirrel/wrapper.cpp) + src/external/*.c) add_executable(brux ${SRCFILES}) file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/test/" DESTINATION "${RUNTIME_OUTPUT_DIR}") @@ -131,6 +120,8 @@ if(WIN32) # FIXME: Proper way of having the SDL2 libraries copied over to binary if (USE_SDL2_MIXER) target_link_libraries(brux PUBLIC ${SDL2_MIXER_LIBRARIES}) endif() + + target_link_libraries(brux PUBLIC simplesquirrel_static) else() target_link_libraries(brux PUBLIC SDL2) target_link_libraries(brux PUBLIC SDL2::Image) @@ -139,8 +130,8 @@ else() if (USE_SDL2_MIXER) target_link_libraries(brux PUBLIC SDL2::Mixer) endif() + + target_link_libraries(brux PUBLIC simplesquirrel) endif() target_link_libraries(brux PUBLIC LibPhysfs) -target_link_libraries(brux PUBLIC LibSquirrel) -target_link_libraries(brux PUBLIC LibSqstdlib) diff --git a/rte/cmake/BuildMiniswigWrapper.cmake b/rte/cmake/BuildMiniswigWrapper.cmake deleted file mode 100644 index 2dafd547..00000000 --- a/rte/cmake/BuildMiniswigWrapper.cmake +++ /dev/null @@ -1,25 +0,0 @@ -option(GENERATE_WRAPPER "Build Miniswig and generate the Squirrel wrapper" OFF) - -if(GENERATE_WRAPPER) - add_subdirectory(external/miniswig) - add_custom_command( - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/squirrel/wrapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/squirrel/wrapper.hpp - COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${CMAKE_CXX_COMPILER} - ARGS -x "c++" -E -CC - -DBRUX_API_GEN src/api/api.hpp - -o ${CMAKE_CURRENT_BINARY_DIR}/miniswig.tmp - -Isrc - COMMAND cd ${CMAKE_CURRENT_BINARY_DIR} && external/miniswig/miniswig - ARGS --input miniswig.tmp - --input-hpp api/api.hpp - --output-cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/squirrel/wrapper.cpp - --output-hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/squirrel/wrapper.hpp - --module brux - --select-namespace BruxAPI - DEPENDS external/miniswig/miniswig - IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/src/api/api.hpp - ) - add_custom_target(squirrel_wrapper ALL - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/squirrel/wrapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/squirrel/wrapper.hpp - ) -endif() diff --git a/rte/cmake/ProvideSquirrel.cmake b/rte/cmake/ProvideSquirrel.cmake deleted file mode 100644 index 6d82f4e6..00000000 --- a/rte/cmake/ProvideSquirrel.cmake +++ /dev/null @@ -1,83 +0,0 @@ -# ORIGIN: https://github.com/SuperTux/supertux/blob/master/mk/cmake/SuperTux/ProvideSquirrel.cmake - -option(USE_SYSTEM_SQUIRREL "Use preinstalled squirrel if available" ON) - -if(USE_SYSTEM_SQUIRREL) - find_package(squirrel 3.2 QUIET) -endif() - -if(TARGET squirrel::squirrel) - message(STATUS "Found preinstalled squirrel") - - add_library(LibSquirrel ALIAS squirrel::squirrel) - add_library(LibSqstdlib ALIAS squirrel::sqstdlib) -else() - if(USE_SYSTEM_SQUIRREL) - message(STATUS "Could NOT find squirrel, using external/squirrel fallback") - endif() - - if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel/CMakeLists.txt) - message(FATAL_ERROR "squirrel submodule is not checked out or ${CMAKE_CURRENT_SOURCE_DIR}/external/squirrel/CMakeLists.txt is missing") - endif() - - if(CMAKE_CROSSCOMPILING) - set(SQUIRREL_MULTIARCH_DIR "${CMAKE_LIBRARY_ARCHITECTURE}/") - else() - set(SQUIRREL_MULTIARCH_DIR "") - endif() - - set(SQUIRREL_PREFIX ${CMAKE_BINARY_DIR}/squirrel/ex) - ExternalProject_Add(squirrel_project - SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/squirrel/" - BUILD_BYPRODUCTS - "${SQUIRREL_PREFIX}/lib/${SQUIRREL_MULTIARCH_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}sqstdlib_static${CMAKE_STATIC_LIBRARY_SUFFIX}" - "${SQUIRREL_PREFIX}/lib/${SQUIRREL_MULTIARCH_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}squirrel_static${CMAKE_STATIC_LIBRARY_SUFFIX}" - CMAKE_ARGS - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} - -DCMAKE_INSTALL_PREFIX=${SQUIRREL_PREFIX} - -DCMAKE_INSTALL_LIBDIR=lib - -DINSTALL_INC_DIR=include - -DCMAKE_POSITION_INDEPENDENT_CODE=ON) - - if(WIN32) - add_library(LibSquirrel SHARED IMPORTED) - set_target_properties(LibSquirrel PROPERTIES - IMPORTED_LOCATION "${SQUIRREL_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}squirrel${CMAKE_SHARED_LIBRARY_SUFFIX}" - IMPORTED_IMPLIB "${SQUIRREL_PREFIX}/lib/squirrel${CMAKE_LINK_LIBRARY_SUFFIX}" - INTERFACE_INCLUDE_DIRECTORIES "${SQUIRREL_PREFIX}/include") - - add_library(LibSqstdlib SHARED IMPORTED) - set_target_properties(LibSqstdlib PROPERTIES - IMPORTED_LOCATION "${SQUIRREL_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}sqstdlib${CMAKE_SHARED_LIBRARY_SUFFIX}" - IMPORTED_IMPLIB "${SQUIRREL_PREFIX}/lib/sqstdlib${CMAKE_LINK_LIBRARY_SUFFIX}" - INTERFACE_INCLUDE_DIRECTORIES "${SQUIRREL_PREFIX}/include") - else() - add_library(LibSquirrel STATIC IMPORTED) - set_target_properties(LibSquirrel PROPERTIES - IMPORTED_LOCATION "${SQUIRREL_PREFIX}/lib/${SQUIRREL_MULTIARCH_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}squirrel_static${CMAKE_STATIC_LIBRARY_SUFFIX}" - INTERFACE_INCLUDE_DIRECTORIES "${SQUIRREL_PREFIX}/include") - - add_library(LibSqstdlib STATIC IMPORTED) - set_target_properties(LibSqstdlib PROPERTIES - IMPORTED_LOCATION "${SQUIRREL_PREFIX}/lib/${SQUIRREL_MULTIARCH_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}sqstdlib_static${CMAKE_STATIC_LIBRARY_SUFFIX}" - INTERFACE_INCLUDE_DIRECTORIES "${SQUIRREL_PREFIX}/include") - endif() - - # Pre-create directory so that cmake doesn't complain about its non-existance - file(MAKE_DIRECTORY ${SQUIRREL_PREFIX}/include) - - add_dependencies(LibSquirrel squirrel_project) - add_dependencies(LibSqstdlib squirrel_project) - - if(WIN32) - get_property(SQUIRREL_LIB_PATH TARGET LibSquirrel PROPERTY IMPORTED_LOCATION) - get_property(SQSTDLIB_LIB_PATH TARGET LibSqstdlib PROPERTY IMPORTED_LOCATION) - install(FILES ${SQUIRREL_LIB_PATH} ${SQSTDLIB_LIB_PATH} DESTINATION "${INSTALL_SUBDIR_BIN}") - endif() -endif() - -# EOF # diff --git a/rte/external/miniswig b/rte/external/miniswig deleted file mode 160000 index 029d2ce2..00000000 --- a/rte/external/miniswig +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 029d2ce210ba3b5ae8691b1b39b174b464c6e2f9 diff --git a/rte/external/simplesquirrel b/rte/external/simplesquirrel new file mode 160000 index 00000000..c6042720 --- /dev/null +++ b/rte/external/simplesquirrel @@ -0,0 +1 @@ +Subproject commit c60427201f2d59308c71a26bbd9c6b7529551e6a diff --git a/rte/external/squirrel b/rte/external/squirrel deleted file mode 160000 index 57b8f569..00000000 --- a/rte/external/squirrel +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 57b8f569026153f3444beab090a9ba1815e25d30 diff --git a/rte/src/api/api.hpp b/rte/src/api/api.hpp deleted file mode 100644 index 8b4c13f0..00000000 --- a/rte/src/api/api.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// This file is processed by Miniswig to produce the Brux Squirrel API. - -#include "api/audio.hpp" -#include "api/fileio.hpp" -#include "api/graphics.hpp" -#include "api/input.hpp" -#include "api/json.hpp" -#include "api/main.hpp" -#include "api/maths.hpp" -#include "api/sdl.hpp" -#include "api/shapes.hpp" -#include "api/sprites.hpp" -#include "api/text.hpp" diff --git a/rte/src/api/audio.cpp b/rte/src/api/audio.cpp deleted file mode 100644 index 109f79e8..00000000 --- a/rte/src/api/audio.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// Brux - Audio API -// Copyright (C) 2016 KelvinShadewing -// Copyright (C) 2023 Vankata453 -// Copyright (C) 2023 hexaheximal -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "api/audio.hpp" - -#include "brux/main.hpp" - -#include "audio/audio.hpp" -#include "brux/global.hpp" - -namespace BruxAPI { - -/////////// -// AUDIO // -/////////// - -int loadSound(const std::string& s) { - return xyLoadSound(s); -} - -int loadMusic(const std::string& m) { - return xyLoadMusic(m); -} - -int playSound(int s, int l) { - return xyPlaySound(s, l); -} - -int playSoundChannel(int s, int l, int c) { - return xyPlaySoundChannel(s, l, c); -} - -void playMusic(int m, int l) { - xyPlayMusic(m, l); -} - -void deleteSound(int s) { - xyDeleteSound(s); -} - -void deleteMusic(int m) { - xyDeleteMusic(m); -} - -void stopSound(int s) { - xyStopSound(s); -} - -void stopMusic() { - xyStopMusic(); -} - -void stopChannel(int c) { - xyStopChannel(c); -} - -bool checkSound(int c) { - return xyCheckSound(c); -} - -bool checkMusic() { - return xyCheckMusic(); -} - -void setMaxChannels(int c) { - xyAllocateChannels(c); -} - -void pauseMusic() { - xyPauseMusic(); -} - -void resumeMusic() { - xyResumeMusic(); -} - -bool musicPaused() { - return xyIsMusicPaused(); -} - -void fadeMusic(int f) { - xyFadeMusic(f); -} - -void setMusicVolume(int vol) { - gvVolumeMusic = vol; - xySetMusicVolume(vol); -} - -void setSoundVolume(int vol) { - gvVolumeSound = vol; -} - -int getMusicVolume() { - return gvVolumeMusic; -} - -int getSoundVolume() { - return gvVolumeSound; -} - -const std::string& getAudioDriver() { - return gvAudioDriver; -} - -bool isAudioAvailable() { - return xyIsAudioAvailable(); -} - -} // namespace BruxAPI diff --git a/rte/src/api/audio.hpp b/rte/src/api/audio.hpp deleted file mode 100644 index be34d378..00000000 --- a/rte/src/api/audio.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// Brux - Audio API -// Copyright (C) 2016 KelvinShadewing -// Copyright (C) 2023 Vankata453 -// Copyright (C) 2023 hexaheximal -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef BRUX_API_AUDIO_HEADER -#define BRUX_API_AUDIO_HEADER - -#ifndef BRUX_API_GEN - -#include - -#endif - -namespace BruxAPI { - -/////////// -// AUDIO // -/////////// - -int loadSound(const std::string& s); // Doc'd -int loadMusic(const std::string& m); // Doc'd -int playSound(int s, int l); // Doc'd -int playSoundChannel(int s, int l, int c); -void playMusic(int m, int l); // Doc'd -void deleteSound(int s); // Doc'd -void deleteMusic(int m); // Doc'd -void stopSound(int s); // Doc'd -void stopMusic(); // Doc'd -void stopChannel(int c); // Doc'd -bool checkSound(int c); // Doc'd -bool checkMusic(); // Doc'd -void setMaxChannels(int c); // Doc'd -void pauseMusic(); // Doc'd -void resumeMusic(); // Doc'd -bool musicPaused(); // Doc'd -void fadeMusic(int f); // Doc'd -void setMusicVolume(int vol); // Doc'd -void setSoundVolume(int vol); // Doc'd -int getMusicVolume(); // Doc'd -int getSoundVolume(); // Doc'd -const std::string& getAudioDriver(); // Doc'd -bool isAudioAvailable(); // Doc'd - -} // namespace BruxAPI - -#endif diff --git a/rte/src/api/fileio.cpp b/rte/src/api/fileio.cpp deleted file mode 100644 index bd5f6350..00000000 --- a/rte/src/api/fileio.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// Brux - File I/O API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "api/fileio.hpp" - -#include "brux/main.hpp" - -#include "brux/fileio.hpp" -#include "brux/global.hpp" - -namespace BruxAPI { - -///////////// -// FILE IO // -///////////// - -void import(const std::string& file) { - donut(file); -} - -void donut(const std::string& file) { - xyPrint("Running %s...", file.c_str()); - sqstd_dofile(gvSquirrel, file.c_str(), 0, 1); -} - -void require(const std::string& file) { - gvDidError = false; - - xyPrint("Running %s...", file.c_str()); - sqstd_dofile(gvSquirrel, file.c_str(), 0, 1); - - if(gvDidError) - xyEnd(); -} - -void dostr(const std::string& str) { - SQInteger oldtop = sq_gettop(gvSquirrel); - - sq_compilebuffer(gvSquirrel, str.c_str(), static_cast(str.size()) * sizeof(SQChar), "std::string", 1); - sq_pushroottable(gvSquirrel); - sq_call(gvSquirrel, 1, SQFalse, SQTrue); - sq_settop(gvSquirrel, oldtop); -} - -void mount(const std::string& dir, const std::string& mountpoint, bool prepend) { - xyFSMount(dir, mountpoint, prepend); -} - -void unmount(const std::string& dir) { - xyFSUnmount(dir); -} - -std::string getdir() { - return xyGetDir(); -} - -std::string getWriteDir() { - return xyGetWriteDir(); -} - -std::string getPrefDir(const std::string& org, const std::string& app) { - return xyGetPrefDir(org, app); -} - -void setWriteDir(const std::string& dir) { - xySetWriteDir(dir); -} - -void createDir(const std::string& name) { - xyCreateDir(name); -} - -std::string fileRead(const std::string& file) { - if (xyFileExists(file)) { - return xyFileRead(file); - } - - xyPrint("WARNING: %s does not exist!", file.c_str()); - - return "-1"; -} - -void fileWrite(const std::string& file, const std::string& data) { - xyFileWrite(file, data); -} - -void fileAppend(const std::string& file, const std::string& data) { - xyFileAppend(file, data); -} - -bool fileExists(const std::string& file) { - return xyFileExists(file); -} - -void fileDelete(const std::string& file) { - xyFileDelete(file); -} - -bool isdir(const std::string& dir) { - return xyIsDirectory(dir); -} - -SQInteger lsdir(HSQUIRRELVM v, const std::string& dir) { - // Create array for results. - - sq_newarray(v, 0); - - // Append all results to the array. - - const std::vector files = xyListDirectory(dir); - - for (const std::string& file: files) { - sq_pushstring(v, file.c_str(), file.size()); - sq_arrayappend(v, -2); - } - - return 1; -} - -} // namespace BruxAPI diff --git a/rte/src/api/fileio.hpp b/rte/src/api/fileio.hpp deleted file mode 100644 index 9185fcf9..00000000 --- a/rte/src/api/fileio.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// Brux - File I/O API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef BRUX_API_FILEIO_HEADER -#define BRUX_API_FILEIO_HEADER - -#ifndef BRUX_API_GEN - -#include - -#include - -#endif - -namespace BruxAPI { - -///////////// -// FILE IO // -///////////// - -void import(const std::string& file); // Clone of `donut()` -void donut(const std::string& file); // Doc'd -void require(const std::string& file); -void dostr(const std::string& str); // Doc'd -void mount(const std::string& dir, const std::string& mountpoint, bool prepend); // Doc'd -void unmount(const std::string& dir); // Doc'd -std::string getdir(); // Doc'd -std::string getWriteDir(); // Doc'd -std::string getPrefDir(const std::string& org, const std::string& app); // Doc'd -void setWriteDir(const std::string& dir); // Doc'd -void createDir(const std::string& name); // Doc'd -std::string fileRead(const std::string& file); // Doc'd -void fileWrite(const std::string& file, const std::string& data); // Doc'd -void fileAppend(const std::string& file, const std::string& data); // Doc'd -bool fileExists(const std::string& file); // Doc'd -void fileDelete(const std::string& file); // Doc'd -bool isdir(const std::string& dir); // Doc'd -SQInteger lsdir(HSQUIRRELVM v, const std::string& dir); // Doc'd - -} // namespace BruxAPI - -#endif diff --git a/rte/src/api/graphics.cpp b/rte/src/api/graphics.cpp deleted file mode 100644 index 1547ba2f..00000000 --- a/rte/src/api/graphics.cpp +++ /dev/null @@ -1,232 +0,0 @@ -// Brux - Graphics API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "api/graphics.hpp" - -#include "brux/global.hpp" -#include "brux/graphics.hpp" - -namespace BruxAPI { - -////////////// -// GRAPHICS // -////////////// - -void clearScreen() { - SDL_RenderClear(gvRender); -} - -void setDrawTarget(int tex) { - xySetDrawTarget(tex); - gvDrawTarget = tex; -} - -int getDrawTarget() { - return gvDrawTarget; -} - -void resetDrawTarget() { - xyResetDrawTarget(); -} - -void drawImage(int img, int x, int y) { - xyDrawImage(img, x, y); -} - -void drawImagePart(int img, int x, int y, int ox, int oy, int w, int h) { - xyDrawImagePart(img, x, y, ox, oy, w, h); -} - -void drawImageEx(int img, int x, int y, float a, int f, int w, int h, int c) { - xyDrawImageEx(img, x, y, a, static_cast(f), w, h, 0, c); -} - -void setDrawColor(int color) { - xySetDrawColor(color); -} - -int loadImage(const std::string& file) { - return xyLoadImage(file); -} - -// Originally this was named loadImageKey, although that seems to be a typo - the documentation says it's getImageKeyed. -// I discovered that by running the test suite and noticing the missing function. - -int loadImageKeyed(const std::string& file, int key) { - return xyLoadImageKeyed(file, key); -} - -void setBackgroundColor(int color) { - xySetBackgroundColor(color); -} - -void setScaling(float scale) { - if (scale <= 0) { - return; - } - - SDL_RenderSetScale(gvRender, scale, scale); -} - -void setScalingFilter(int hint) { - if (hint > 2) { - hint = 2; - } - - if (hint < 0) { - hint = 0; - } - - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(hint).c_str()); -} - -void setResolution(int w, int h) { - // Don't allow the width and/or height to be 0 - - if (w < 1 || h < 1) { - throw std::runtime_error("Window dimensions cannot be 0"); - } - - SDL_Rect screensize; - - screensize.x = 0; - screensize.y = 0; - screensize.w = w; - screensize.h = h; - - SDL_RenderSetViewport(gvRender, &screensize); - SDL_RenderSetLogicalSize(gvRender, w, h); - SDL_SetWindowSize(gvWindow, w, h); - SDL_SetWindowMinimumSize(gvWindow, w, h); -} - -int screenW() { - SDL_Rect vp; - - SDL_RenderGetViewport(gvRender, &vp); - - return vp.w; -} - -int screenH() { - SDL_Rect vp; - - SDL_RenderGetViewport(gvRender, &vp); - - return vp.h; -} - -int windowW() { - int w; - - SDL_GetWindowSize(gvWindow, &w, 0); - - return w; -} - -int windowH() { - int h; - - SDL_GetWindowSize(gvWindow, 0, &h); - - return h; -} - -int newTexture(int w, int h) { - return xyNewTexture(w, h); -} - -void textureSetBlendMode(int texture, int blend) { - if (texture < 0 || texture > static_cast(vcTextures.size()) - 1) { - throw std::runtime_error("Invalid texture ID. Cannot set blend mode"); - } - - SDL_BlendMode mode; - - switch (blend) { - case 0: - mode = SDL_BLENDMODE_NONE; - break; - case 1: - mode = SDL_BLENDMODE_BLEND; - break; - case 2: - mode = SDL_BLENDMODE_ADD; - break; - case 3: - mode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT); - break; - case 4: - mode = SDL_BLENDMODE_MOD; - break; - default: - mode = SDL_BLENDMODE_NONE; - break; - } - - SDL_SetTextureBlendMode(vcTextures[texture], mode); -} - -int findTexture(const std::string& name) { - for (int i = 0; i < vcTextureNames.size(); i++) { - if (vcTextureNames[i] == name) { - return i; - } - } - - return 0; -} - -void deleteTexture(int tex) { - xyDeleteImage(tex); -} - -std::string getTextureName(int texture) { - if (texture > 0 && texture < vcTextureNames.size()) { - return vcTextureNames[texture]; - } - - return ""; -} - -int getTextureFilter(int tex) { - SDL_ScaleMode sm = (SDL_ScaleMode)0; - - if(tex > 0 && tex < vcTextures.size() && vcTextures[tex] != 0) - SDL_GetTextureScaleMode(vcTextures[tex], &sm); - else - xyPrint("WARNING: Texture not found!"); - - return (int)sm; -} - -void setTextureFilter(int tex, int filter) { - SDL_ScaleMode sm = (SDL_ScaleMode)min(max(filter, 0), 2); - - if(tex > 0 && tex < vcTextures.size() && vcTextures[tex] != 0) - SDL_SetTextureScaleMode(vcTextures[tex], sm); - else - xyPrint("WARNING: Texture not found!"); -} - -void printTextureNames() { - for (int i = 0; i < vcTextureNames.size(); i++) { - xyPrint("%d - %s", i, vcTextureNames[i].c_str()); - } -} - -} // namespace BruxAPI diff --git a/rte/src/api/graphics.hpp b/rte/src/api/graphics.hpp deleted file mode 100644 index 0866b8ea..00000000 --- a/rte/src/api/graphics.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// Brux - Graphics API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef BRUX_API_GRAPHICS_HEADER -#define BRUX_API_GRAPHICS_HEADER - -#ifndef BRUX_API_GEN - -#include - -#endif - -namespace BruxAPI { - -////////////// -// GRAPHICS // -////////////// - -void clearScreen(); // Doc'd -void setDrawTarget(int tex); // Doc'd -int getDrawTarget(); // Doc'd -void resetDrawTarget(); -void drawImage(int img, int x, int y); // Doc'd -void drawImagePart(int img, int x, int y, int ox, int oy, int w, int h); -void drawImageEx(int img, int x, int y, float a, int f, int w, int h, int c); -void setDrawColor(int color); // Doc'd -int loadImage(const std::string& file); // Doc'd -int loadImageKeyed(const std::string& file, int key); // Doc'd -void setBackgroundColor(int color); // Doc'd -void setScaling(float scale); -void setScalingFilter(int hint); // Doc'd -void setResolution(int w, int h); // Doc'd -int screenW(); // Doc'd -int screenH(); // Doc'd -int windowW(); -int windowH(); -int newTexture(int w, int h); // Doc'd -void textureSetBlendMode(int texture, int blend); // Doc'd -int findTexture(const std::string& name); -void deleteTexture(int tex); -std::string getTextureName(int texture); -int getTextureFilter(int tex); -void setTextureFilter(int tex, int filter); -void printTextureNames(); - -} // namespace BruxAPI - -#endif diff --git a/rte/src/api/input.cpp b/rte/src/api/input.cpp deleted file mode 100644 index 1f02d6d3..00000000 --- a/rte/src/api/input.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// Brux - Input API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "api/input.hpp" - -#include "brux/input.hpp" - -bool quitRequested = false; - -namespace BruxAPI { - -/////////// -// INPUT // -/////////// - -int keyPress(int key) { - return xyKeyPress(key); -} - -int keyDown(int key) { - return xyKeyDown(key); -} - -int keyRelease(int key) { - return xyKeyRelease(key); -} - -int keyPressAny() { - int key = -1; - - for (int i = 0; i < 322; i++) { - if (xyKeyPress(i)) { - key = i; - break; - } - } - - return key; -} - -int mouseDown(int button) { - return xyMouseButton(button); -} - -int mousePress(int button) { - return xyMousePress(button); -} - -int mouseRelease(int button) { - return xyMouseRelease(button); -} - -int mouseX() { - return gvMouseX; -} - -int mouseY() { - return gvMouseY; -} - -bool getQuit() { - return gvQuit || quitRequested; -} - -void quitGame() { - quitRequested = true; -} - -int joyCount() { - return SDL_NumJoysticks(); -} - -std::string joyName(int i) { - return gvPadName[i]; -} - -int joyX(int i) { - return gvPadX[i]; -} - -int joyY(int i) { - return gvPadY[i]; -} - -int joyZ(int i) { - return gvPadZ[i]; -} - -int joyH(int i) { - return gvPadH[i]; -} - -int joyV(int i) { - return gvPadV[i]; -} - -int joyR(int i) { - return gvPadR[i]; -} - -int joyL(int i) { - return gvPadL[i]; -} - -int joyAxis(int i, int j) { - return gvPadAxis[i][j]; -} - -bool joyHatDown(int i, int d) { - return gvPadHat[i] & (1 << (d - 1)); -} - -bool joyHatPress(int i, int d) { - return (gvPadHat[i] & (1 << (d - 1))) && !(gvPadHatLast[i] & (1 << (d - 1))); -} - -bool joyHatRelease(int i, int d) { - return !(gvPadHat[i] & (1 << (d - 1))) && (gvPadHatLast[i] & (1 << (d - 1))); -} - -int joyButtonDown(int i, int b) { - return gvPadButton[i][b]; -} - -int joyButtonPress(int i, int b) { - return (gvPadButton[i][b] && !gvPadLastButton[i][b]); -} - -int joyButtonRelease(int i, int b) { - return (!gvPadButton[i][b] && gvPadLastButton[i][b]); -} - -int joyPressAny(int p) { - int button = -1; - - for (int i = 0; i < 32; i++) { - if (gvPadButton[p][i] && !gvPadLastButton[p][i]) { - button = i; - break; - } - } - - return button; -} - -int joyAxisPress(int p, int a, int d) { - return xyJoyAxisPress(p, a, d); -} - -int joyAxisRelease(int p, int a, int d) { - return xyJoyAxisRelease(p, a, d); -} - -std::string keyString() { - const std::string input = gvInputString; - gvInputString = ""; // Clean input. - return input; -} - -int mouseWheelX() { - return ::mouseWheelX; -} - -int mouseWheelY() { - return ::mouseWheelY; -} - -} // namespace BruxAPI diff --git a/rte/src/api/input.hpp b/rte/src/api/input.hpp deleted file mode 100644 index 8c81ee8f..00000000 --- a/rte/src/api/input.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Brux - Input API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef BRUX_API_INPUT_HEADER -#define BRUX_API_INPUT_HEADER - -#ifndef BRUX_API_GEN - -#include - -#endif - -namespace BruxAPI { - -/////////// -// INPUT // -/////////// - -int keyPress(int key); // Doc'd -int keyDown(int key); // Doc'd -int keyRelease(int key); // Doc'd -int keyPressAny(); // Doc'd -int mouseDown(int button); // Doc'd -int mousePress(int button); // Doc'd -int mouseRelease(int button); // Doc'd -int mouseX(); // Doc'd -int mouseY(); // Doc'd -bool getQuit(); // Doc'd -void quitGame(); // Doc'd -int joyCount(); // Doc'd -std::string joyName(int i); // Doc'd -int joyX(int i); // Doc'd -int joyY(int i); // Doc'd -int joyZ(int i); // Doc'd -int joyH(int i); // Doc'd -int joyV(int i); // Doc'd -int joyR(int i); // Doc'd -int joyL(int i); // Doc'd -int joyAxis(int i, int j); // Doc'd -bool joyHatDown(int i, int d); // Doc'd -bool joyHatPress(int i, int d); // Doc'd -bool joyHatRelease(int i, int d); // Doc'd -int joyButtonPress(int i, int b); // Doc'd -int joyButtonDown(int i, int b); // Doc'd -int joyButtonRelease(int i, int b); // Doc'd -int joyPressAny(int p); // Doc'd -int joyAxisPress(int p, int a, int d); // Doc'd -int joyAxisRelease(int p, int a, int d); // Doc'd -std::string keyString(); // Doc'd -int mouseWheelX(); // Doc'd -int mouseWheelY(); // Doc'd - -} // namespace BruxAPI - -#endif diff --git a/rte/src/api/json.cpp b/rte/src/api/json.cpp deleted file mode 100644 index c076bf0d..00000000 --- a/rte/src/api/json.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Brux - JSON API -// Copyright (C) 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "api/json.hpp" - -#include "brux/main.hpp" - -#include "brux/fileio.hpp" - -namespace BruxAPI { - -////////// -// JSON // -////////// - -SQInteger jsonRead(HSQUIRRELVM v, const std::string& str) { - sqDecodeJSON(v, str.c_str()); - return 1; -} - -} // namespace BruxAPI diff --git a/rte/src/api/json.hpp b/rte/src/api/json.hpp deleted file mode 100644 index b8203cca..00000000 --- a/rte/src/api/json.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Brux - JSON API -// Copyright (C) 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef BRUX_API_JSON_HEADER -#define BRUX_API_JSON_HEADER - -#ifndef BRUX_API_GEN - -#include - -#include - -#endif - -namespace BruxAPI { - -////////// -// JSON // -////////// - -SQInteger jsonRead(HSQUIRRELVM v, const std::string& str); // Doc'd - -} // namespace BruxAPI - -#endif diff --git a/rte/src/api/main.cpp b/rte/src/api/main.cpp deleted file mode 100644 index 9f65aff4..00000000 --- a/rte/src/api/main.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Brux - Main API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "api/main.hpp" - -#include "brux/main.hpp" - -#include "brux/fileio.hpp" -#include "brux/global.hpp" -#include "brux/graphics.hpp" - -namespace BruxAPI { - -////////// -// MAIN // -////////// - -void wait(int seconds) { - xyWait(seconds); -} - -void update() { - if (!gvUpdateDeprecationWarningShown) { - xyPrint("WARNING: update() is deprecated and will be removed in a future release."); - gvUpdateDeprecationWarningShown = true; - } - - xyUpdate(); -} - -std::string getOS() { - return SDL_GetPlatform(); -} - -int getTicks() { - return SDL_GetTicks(); -} - -int getFPS() { - return static_cast(std::round(gvFPS)); -} - -void setFPS(int max_fps) { - if (max_fps < 0) { - throw std::runtime_error("Maximum FPS cannot be negative"); - } - - gvMaxFPS = max_fps; -} - -void setWindowTitle(const std::string& title) { - SDL_SetWindowTitle(gvWindow, title.c_str()); -} - -void setWindowIcon(const std::string& file) { - if (!xyFileExists(file)) { - return; - } - - SDL_Surface* icon = IMG_Load(file.c_str()); - SDL_SetWindowIcon(gvWindow, icon); - SDL_FreeSurface(icon); -} - -int getFrames() { - return gvFrames; -} - -int displayW() { - SDL_DisplayMode DM; - SDL_GetCurrentDisplayMode(0, &DM); - - return DM.w; -} - -int displayH() { - SDL_DisplayMode DM; - SDL_GetCurrentDisplayMode(0, &DM); - - return DM.h; -} - -std::string bruxVersion() { - return gvVNo; -} - -void toggleFullscreen() { - SDL_SetWindowFullscreen(gvWindow, (SDL_GetWindowFlags(gvWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP) ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP); -} - -} // namespace BruxAPI diff --git a/rte/src/api/main.hpp b/rte/src/api/main.hpp deleted file mode 100644 index 623744d9..00000000 --- a/rte/src/api/main.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Brux - Main API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef BRUX_API_MAIN_HEADER -#define BRUX_API_MAIN_HEADER - -#ifndef BRUX_API_GEN - -#include - -#endif - -namespace BruxAPI { - -////////// -// MAIN // -////////// - -void wait(int seconds); // Doc'd -void update(); // Doc'd -std::string getOS(); // Doc'd -int getTicks(); // Doc'd -int getFPS(); // Doc'd -void setFPS(int max_fps); // Doc'd -void setWindowTitle(const std::string& title); // Doc'd -void setWindowIcon(const std::string& file); // Doc'd -int getFrames(); // Doc'd -int displayW(); // Doc'd -int displayH(); // Doc'd -std::string bruxVersion(); // Doc'd -void toggleFullscreen(); // Doc'd - -} // namespace BruxAPI - -#endif diff --git a/rte/src/api/maths.cpp b/rte/src/api/maths.cpp deleted file mode 100644 index 2cf2b015..00000000 --- a/rte/src/api/maths.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// Brux - Maths API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "api/maths.hpp" - -#include "brux/main.hpp" - -#include "brux/maths.hpp" - -namespace BruxAPI { - -/////////// -// MATHS // -/////////// - -float randFloat(float a) { - return xyRandomFloat(a); -} - -int randInt(int a) { - return xyRandomInt(a); -} - -float distance2(float x1, float y1, float x2, float y2) { - return xyDistance(x1, y1, x2, y2); -} - -bool inDistance2(float x1, float y1, float x2, float y2, float d) { - return xyInDistance2(x1, y1, x2, y2, d); -} - -float distance3(float x1, float y1, float z1, float x2, float y2, float z2) { - return xyDistance3(x1, y1, z1, x2, y2, z2); -} - -float wrap(float x, float mx, float mn) { - return xyWrap(x, mn, mx); -} - -int floor(float f) { - return static_cast(std::floor(f)); -} - -int ceil(float f) { - return static_cast(std::ceil(f)); -} - -int round(float f) { - return static_cast(std::round(f)); -} - -float pointAngle(float x1, float y1, float x2, float y2) { - return xyPointAngle(x1, y1, x2, y2); -} - -float abs(float f) { - return std::abs(f); -} - -float lendirX(float l, float d) { - return xyLenDirX(l, d); -} - -float lendirY(float l, float d) { - return xyLenDirY(l, d); -} - -// this code sucks so much -// kelvin, please stop doing this awfulness - -std::string binstr(int i) { - int l = static_cast(log2(i)) + 1; - std::string s; - - switch (l) { - case 0: - s = "0"; - break; - case 1: - s = std::bitset<1>(i).to_string(); - break; - case 2: - s = std::bitset<2>(i).to_string(); - break; - case 3: - s = std::bitset<3>(i).to_string(); - break; - case 4: - s = std::bitset<4>(i).to_string(); - break; - case 5: - s = std::bitset<5>(i).to_string(); - break; - case 6: - s = std::bitset<6>(i).to_string(); - break; - case 7: - s = std::bitset<7>(i).to_string(); - break; - case 8: - s = std::bitset<8>(i).to_string(); - break; - case 9: - s = std::bitset<9>(i).to_string(); - break; - case 10: - s = std::bitset<10>(i).to_string(); - break; - case 11: - s = std::bitset<11>(i).to_string(); - break; - case 12: - s = std::bitset<12>(i).to_string(); - break; - case 13: - s = std::bitset<13>(i).to_string(); - break; - case 14: - s = std::bitset<14>(i).to_string(); - break; - case 15: - s = std::bitset<15>(i).to_string(); - break; - case 16: - s = std::bitset<16>(i).to_string(); - break; - case 17: - s = std::bitset<17>(i).to_string(); - break; - case 18: - s = std::bitset<18>(i).to_string(); - break; - case 19: - s = std::bitset<19>(i).to_string(); - break; - case 20: - s = std::bitset<20>(i).to_string(); - break; - case 21: - s = std::bitset<21>(i).to_string(); - break; - case 22: - s = std::bitset<22>(i).to_string(); - break; - case 23: - s = std::bitset<23>(i).to_string(); - break; - case 24: - s = std::bitset<24>(i).to_string(); - break; - case 25: - s = std::bitset<25>(i).to_string(); - break; - case 26: - s = std::bitset<26>(i).to_string(); - break; - case 27: - s = std::bitset<27>(i).to_string(); - break; - case 28: - s = std::bitset<28>(i).to_string(); - break; - case 29: - s = std::bitset<29>(i).to_string(); - break; - case 30: - s = std::bitset<30>(i).to_string(); - break; - case 31: - s = std::bitset<31>(i).to_string(); - break; - case 32: - s = std::bitset<32>(i).to_string(); - break; - default: - s = std::bitset<64>(i).to_string(); - break; - } - - return s; -} - -} // namespace BruxAPI diff --git a/rte/src/api/maths.hpp b/rte/src/api/maths.hpp deleted file mode 100644 index ae1a6c4c..00000000 --- a/rte/src/api/maths.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Brux - Maths API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef BRUX_API_MATHS_HEADER -#define BRUX_API_MATHS_HEADER - -#ifndef BRUX_API_GEN - -#include - -#endif - -namespace BruxAPI { - -/////////// -// MATHS // -/////////// - -float randFloat(float a); // Doc'd -int randInt(int a); // Doc'd -float distance2(float x1, float y1, float x2, float y2); // Doc'd -bool inDistance2(float x1, float y1, float x2, float y2, float d); -float distance3(float x1, float y1, float z1, float x2, float y2, float z2); -float wrap(float x, float mx, float mn); // Doc'd -int floor(float f); // Doc'd -int ceil(float f); // Doc'd -int round(float f); // Doc'd -float pointAngle(float x1, float y1, float x2, float y2); // Doc'd -float abs(float f); // Doc'd -float lendirX(float l, float d); // Doc'd -float lendirY(float l, float d); // Doc'd -std::string binstr(int i); // Doc'd - -} // namespace BruxAPI - -#endif diff --git a/rte/src/api/sdl.cpp b/rte/src/api/sdl.cpp deleted file mode 100644 index 38b8fc8a..00000000 --- a/rte/src/api/sdl.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Brux - SDL API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "api/sdl.hpp" - -#include "brux/global.hpp" -#include "brux/graphics.hpp" - -namespace BruxAPI { - -///////////// -// SDL_GFX // -///////////// - -void drawCircle(int x, int y, int radius, bool filled) { - if (filled) { - filledCircleColor(gvRender, x, y, radius, gvDrawColor); - return; - } - - circleColor(gvRender, x, y, radius, gvDrawColor); -} - -void drawRec(int x, int y, int w, int h, bool filled) { - drawRect(x, y, w, h, filled); -} - -void drawRect(int x, int y, int w, int h, bool filled) { - if (filled) - boxColor(gvRender, x, y, x + w, y + h, gvDrawColor); - else - rectangleColor(gvRender, x, y, x + w, y + h, gvDrawColor); -} - -void drawPoint(int x, int y) { - pixelColor(gvRender, x, y, gvDrawColor); -} - -void drawLine(int x1, int y1, int x2, int y2) { - thickLineColor(gvRender, x1, y1, x2, y2, 1, gvDrawColor); -} - -void drawLineWide(int x1, int y1, int x2, int y2, int w) { - thickLineColor(gvRender, x1, y1, x2, y2, w, gvDrawColor); -} - -} // namespace BruxAPI diff --git a/rte/src/api/sdl.hpp b/rte/src/api/sdl.hpp deleted file mode 100644 index e157422b..00000000 --- a/rte/src/api/sdl.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Brux - SDL API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef BRUX_API_SDL_HEADER -#define BRUX_API_SDL_HEADER - -#ifndef BRUX_API_GEN - -#include - -#endif - -namespace BruxAPI { - -///////////// -// SDL_GFX // -///////////// - -void drawCircle(int x, int y, int radius, bool filled); // Doc'd -void drawRec(int x, int y, int w, int h, bool filled); // Clone of `drawRect()` -void drawRect(int x, int y, int w, int h, bool filled); // Doc'd -void drawPoint(int x, int y); // Doc'd -void drawLine(int x1, int y1, int x2, int y2); // Doc'd -void drawLineWide(int x1, int y1, int x2, int y2, int w); // Doc'd - -} // namespace BruxAPI - -#endif diff --git a/rte/src/api/shapes.cpp b/rte/src/api/shapes.cpp deleted file mode 100644 index a5c0bc0e..00000000 --- a/rte/src/api/shapes.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Brux - Shapes API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "api/shapes.hpp" - -#include "brux/main.hpp" - -#include "brux/shapes.hpp" - -namespace BruxAPI { - -//////////// -// SHAPES // -//////////// - -bool hitLineLine(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) { - xyPnt a(x0, y0); - xyPnt b(x1, y1); - xyPnt c(x2, y2); - xyPnt d(x3, y3); - - return xyLineLine(&a, &b, &c, &d); -} - -bool hitLineCircle(float x0, float y0, float x1, float y1, float x2, float y2, float r) { - xyPnt a(x0, y0); - xyPnt b(x1, y1); - xyPnt c(x2, y2); - - return xyLineCircle(&a, &b, &c, r); -} - -bool hitLinePoint(float x0, float y0, float x1, float y1, float x2, float y2) { - return xyLinePoint(x0, y0, x1, y1, x2, y2); -} - -} // namespace BruxAPI diff --git a/rte/src/api/shapes.hpp b/rte/src/api/shapes.hpp deleted file mode 100644 index 9383c1dc..00000000 --- a/rte/src/api/shapes.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Brux - Shapes API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef BRUX_API_SHAPES_HEADER -#define BRUX_API_SHAPES_HEADER - -#ifndef BRUX_API_GEN - -#include - -#endif - -namespace BruxAPI { - -//////////// -// SHAPES // -//////////// - -bool hitLineLine(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3); // Doc'd -bool hitLineCircle(float x0, float y0, float x1, float y1, float x2, float y2, float r); // Doc'd -bool hitLinePoint(float x0, float y0, float x1, float y1, float x2, float y2); // Doc'd - -} // namespace BruxAPI - -#endif diff --git a/rte/src/api/sprites.cpp b/rte/src/api/sprites.cpp deleted file mode 100644 index 9f1b1e75..00000000 --- a/rte/src/api/sprites.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// Brux - Sprites API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "api/sprites.hpp" - -#include "brux/main.hpp" - -#include "brux/global.hpp" -#include "brux/sprite.hpp" - -namespace BruxAPI { - -///////////// -// SPRITES // -///////////// - -std::string spriteName(int sprite) { - if (static_cast(vcSprites.size()) <= sprite || sprite < 0 || vcSprites[sprite] == 0) { - return "N/A"; - } - - return vcSprites[sprite]->name; -} - -int findSprite(const std::string& name) { - for (size_t i = 0; i < vcSprites.size(); i++) { - if (vcSprites[i] != 0) { - if (vcSprites[i]->getname() == name) { - return vcSprites[i]->getnum(); - } - } - } - - return 0; -} - -int newSprite(const std::string& i, int w, int h, int m, int p, float px, float py) { - xySprite* newsprite = new xySprite(i, w, h, m, p, px, py); - - return newsprite->getnum(); -} - -int newSpriteFT(int t, int w, int h, int m, int p, float px, float py) { - xySprite* newsprite = new xySprite(t, w, h, m, p, px, py); - - return newsprite->getnum(); -} - -// Macros to help easily check if a sprite is valid. - -#define SPRITE_CHECK_VALID if (static_cast(vcSprites.size()) <= i || vcSprites[i] == 0) -#define SPRITE_CHECK_VALID_VOID SPRITE_CHECK_VALID return -#define SPRITE_CHECK_VALID_INT SPRITE_CHECK_VALID return 0 - -void drawSprite(int i, int f, int x, int y) { - SPRITE_CHECK_VALID_VOID; - vcSprites[i]->draw(f, x, y); -} - -void drawSpriteEx(int i, int f, int x, int y, int a, int l, float sx, float sy, float p) { - SPRITE_CHECK_VALID_VOID; - vcSprites[i]->drawex(f, x, y, a, static_cast(l), sx, sy, p); -} - -void drawSpriteMod(int i, int f, int x, int y, int c) { - SPRITE_CHECK_VALID_VOID; - vcSprites[i]->drawmod(f, x, y, c); -} - -void drawSpriteExMod(int i, int f, int x, int y, int a, int l, float sx, float sy, float p, int c) { - SPRITE_CHECK_VALID_VOID; - vcSprites[i]->drawexmod(f, x, y, a, static_cast(l), sx, sy, p, c); -} - -void deleteSprite(int i) { - SPRITE_CHECK_VALID_VOID; - delete vcSprites[i]; -} - -int spriteW(int i) { - SPRITE_CHECK_VALID_INT; - return vcSprites[i]->getw(); -} - -int spriteH(int i) { - SPRITE_CHECK_VALID_INT; - return vcSprites[i]->geth(); -} - -void replaceSprite(int s, const std::string& f, int w, int h, int m, int p, float x, float y) { - if (s <= 0 || s >= static_cast(vcSprites.size())) { - return; - } - - if (vcSprites[s] != 0) { - vcSprites[s]->replaceSprite(f, w, h, m, p, x, y); - return; - } - - vcSprites[s] = new xySprite(f, w, h, m, p, x, y); -} - -void spriteSetBlendMode(int sprite, int blend) { - if (sprite < 0 || sprite > static_cast(vcSprites.size()) - 1) { - throw std::runtime_error("Invalid sprite ID. Cannot set blend mode"); - } - - SDL_BlendMode mode; - - switch (blend) { - case 0: - mode = SDL_BLENDMODE_NONE; - break; - case 1: - mode = SDL_BLENDMODE_BLEND; - break; - case 2: - mode = SDL_BLENDMODE_ADD; - break; - case 3: - mode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT); - break; - case 4: - mode = SDL_BLENDMODE_MOD; - break; - default: - mode = SDL_BLENDMODE_NONE; - break; - } - - SDL_SetTextureBlendMode(vcTextures[vcSprites[sprite]->gettex()], mode); -} - -} // namespace BruxAPI diff --git a/rte/src/api/sprites.hpp b/rte/src/api/sprites.hpp deleted file mode 100644 index e50b73ab..00000000 --- a/rte/src/api/sprites.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Brux - Sprites API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef BRUX_API_SPRITES_HEADER -#define BRUX_API_SPRITES_HEADER - -#ifndef BRUX_API_GEN - -#include - -#endif - -namespace BruxAPI { - -///////////// -// SPRITES // -///////////// - -std::string spriteName(int sprite); // Doc'd -int findSprite(const std::string& name); // Doc'd -int newSprite(const std::string& i, int w, int h, int m, int p, float px, float py); // Doc'd -int newSpriteFT(int t, int w, int h, int m, int p, float px, float py); -void drawSprite(int i, int f, int x, int y); // Doc'd -void drawSpriteEx(int i, int f, int x, int y, int a, int l, float sx, float sy, float p); // Doc'd -void drawSpriteMod(int i, int f, int x, int y, int c); // Doc'd -void drawSpriteExMod(int i, int f, int x, int y, int a, int l, float sx, float sy, float p, int c); // Doc'd -void deleteSprite(int i); // Doc'd -int spriteW(int i); // Doc'd -int spriteH(int i); // Doc'd -void replaceSprite(int s, const std::string& f, int w, int h, int m, int p, float x, float y); -void spriteSetBlendMode(int sprite, int blend); // Doc'd - -} // namespace BruxAPI - -#endif diff --git a/rte/src/api/text.cpp b/rte/src/api/text.cpp deleted file mode 100644 index ad47a794..00000000 --- a/rte/src/api/text.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Brux - Text API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "api/text.hpp" - -#include "brux/main.hpp" - -#include "brux/global.hpp" -#include "brux/text.hpp" - -namespace BruxAPI { - -////////// -// TEXT // -////////// - -int newFont(int i, int c, int t, bool m, int k) { - // Sanitize inputs - - if (i < 0) { - i = 0; - } - - if (t > 255) { - t = 255; - } - - if (c > 255) { - c = 255; - } - - xyFont* newfont = new xyFont(i, static_cast(c), static_cast(t), m, k); - - return newfont->getnum(); -} - -// Macro to help easily check if a font is valid. - -#define FONT_CHECK_VALID if (f >= static_cast(vcFonts.size()) || vcFonts[f] == 0) return - -void drawText(int f, float x, float y, const std::string& s) { - FONT_CHECK_VALID; - vcFonts[f]->draw(static_cast(x), static_cast(y), s); -} - -SQInteger chint(HSQUIRRELVM v, int i) { - const char s = static_cast(i); - sq_pushstring(v, &s, 1); - return 1; -} - -} // namespace BruxAPI diff --git a/rte/src/api/text.hpp b/rte/src/api/text.hpp deleted file mode 100644 index f326e2c9..00000000 --- a/rte/src/api/text.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Brux - Text API -// Copyright (C) 2016 KelvinShadewing -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef BRUX_API_TEXT_HEADER -#define BRUX_API_TEXT_HEADER - -#ifndef BRUX_API_GEN - -#include - -#include - -#endif - -namespace BruxAPI { - -////////// -// TEXT // -////////// - -int newFont(int i, int c, int t, bool m, int k); // Doc'd -void drawText(int f, float x, float y, const std::string& s); // Doc'd -SQInteger chint(HSQUIRRELVM v, int i); // Doc'd - -} // namespace BruxAPI - -#endif diff --git a/rte/src/audio/audio.cpp b/rte/src/audio/audio.cpp new file mode 100644 index 00000000..9b79eeb0 --- /dev/null +++ b/rte/src/audio/audio.cpp @@ -0,0 +1,70 @@ +// Brux - Audio Portability API - Generic functions +// Copyright (C) 2024 Vankata453 +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "audio/audio.hpp" + +#include + +// Get the current music volume + +int xyGetMusicVolume() { + return gvVolumeMusic; +} + +// Get the current sound volume + +int xyGetSoundVolume() { + return gvVolumeSound; +} + +// Set the sound volume + +void xySetSoundVolume(int volume) { + gvVolumeSound = volume; +} + +// Get the current audio driver + +std::string xyGetAudioDriver() { + return gvAudioDriver; +} + + +void xyRegisterAudioAPI(ssq::VM& vm) { + vm.addFunc("loadSound", xyLoadSound); // Doc'd + vm.addFunc("loadMusic", xyLoadMusic); // Doc'd + vm.addFunc("playSound", xyPlaySound); // Doc'd + vm.addFunc("playSoundChannel", xyPlaySoundChannel); + vm.addFunc("playMusic", xyPlayMusic); // Doc'd + vm.addFunc("deleteSound", xyDeleteSound); // Doc'd + vm.addFunc("deleteMusic", xyDeleteMusic); // Doc'd + vm.addFunc("stopSound", xyStopSound); // Doc'd + vm.addFunc("stopMusic", xyStopMusic); // Doc'd + vm.addFunc("stopChannel", xyStopChannel); // Doc'd + vm.addFunc("checkSound", xyCheckSound); // Doc'd + vm.addFunc("checkMusic", xyCheckMusic); // Doc'd + vm.addFunc("setMaxChannels", xyAllocateChannels); // Doc'd + vm.addFunc("pauseMusic", xyPauseMusic); // Doc'd + vm.addFunc("resumeMusic", xyResumeMusic); // Doc'd + vm.addFunc("musicPaused", xyIsMusicPaused); // Doc'd + vm.addFunc("fadeMusic", xyFadeMusic); // Doc'd + vm.addFunc("setMusicVolume", xySetMusicVolume); // Doc'd + vm.addFunc("setSoundVolume", xySetSoundVolume); // Doc'd + vm.addFunc("getMusicVolume", xyGetMusicVolume); // Doc'd + vm.addFunc("getSoundVolume", xyGetSoundVolume); // Doc'd + vm.addFunc("getAudioDriver", xyGetAudioDriver); // Doc'd + vm.addFunc("isAudioAvailable", xyIsAudioAvailable); // Doc'd +} diff --git a/rte/src/audio/audio.hpp b/rte/src/audio/audio.hpp index 03b29d65..d439d930 100644 --- a/rte/src/audio/audio.hpp +++ b/rte/src/audio/audio.hpp @@ -20,11 +20,7 @@ #include "brux/global.hpp" -#ifdef USE_SDL2_MIXER -#include -#endif - -extern const std::string& gvAudioDriver; +extern const std::string gvAudioDriver; // Checks if audio playback is currently available @@ -110,8 +106,27 @@ bool xyCheckMusic(); int xyGetAudioChannels(); +// Get the current music volume + +int xyGetMusicVolume(); + // Set the music volume void xySetMusicVolume(int volume); +// Get the current sound volume + +int xyGetSoundVolume(); + +// Set the sound volume + +void xySetSoundVolume(int volume); + +// Get the current audio driver + +std::string xyGetAudioDriver(); + + +void xyRegisterAudioAPI(ssq::VM& vm); + #endif diff --git a/rte/src/audio/audio_none.cpp b/rte/src/audio/audio_none.cpp index c5dd3001..7ce1efaf 100644 --- a/rte/src/audio/audio_none.cpp +++ b/rte/src/audio/audio_none.cpp @@ -19,7 +19,7 @@ #ifndef USE_SDL2_MIXER -const std::string& gvAudioDriver = "None"; +const std::string gvAudioDriver = "None"; // Checks if audio playback is currently available @@ -152,6 +152,7 @@ int xyGetAudioChannels() { // Set the music volume void xySetMusicVolume(int volume) { + gvVolumeMusic = volume; // We don't need to do anything here, as this doesn't actually play any audio } diff --git a/rte/src/audio/audio_sdl2.cpp b/rte/src/audio/audio_sdl2.cpp index db661e82..b1036371 100644 --- a/rte/src/audio/audio_sdl2.cpp +++ b/rte/src/audio/audio_sdl2.cpp @@ -19,6 +19,8 @@ #ifdef USE_SDL2_MIXER +#include + std::vector vcSounds; std::vector vcMusic; @@ -27,7 +29,7 @@ std::vector unloadedSounds; std::vector unloadedMusic; #endif -const std::string& gvAudioDriver = "SDL2"; +const std::string gvAudioDriver = "SDL2"; bool isAudioLoaded = false; bool didAudioLoadFail = false; @@ -423,6 +425,7 @@ int xyGetAudioChannels() { // Set the music volume void xySetMusicVolume(int volume) { + gvVolumeMusic = volume; Mix_VolumeMusic(volume); } diff --git a/rte/src/brux/actors.cpp b/rte/src/brux/actors.cpp index ef29a9ee..e2885410 100644 --- a/rte/src/brux/actors.cpp +++ b/rte/src/brux/actors.cpp @@ -31,7 +31,7 @@ \*/ void xyLoadActors() { - const SQChar *cmd = R"rew(::actor <- {} + const char* cmd = R"rew(::actor <- {} ::__actlast__ <- 0 ::__actor_delete_list__ <- [] @@ -136,9 +136,6 @@ void xyLoadActors() { print("Imported actors lib."))rew"; - SQInteger oldtop = sq_gettop(gvSquirrel); - sq_compilebuffer(gvSquirrel, cmd, (int)strlen(cmd) * sizeof(SQChar), "actors.nut", 1); - sq_pushroottable(gvSquirrel); - sq_call(gvSquirrel, 1, SQFalse, SQTrue); - sq_settop(gvSquirrel, oldtop); + ssq::Script script = gvSquirrel.compileSource(cmd, "actors.nut"); + gvSquirrel.run(script); } diff --git a/rte/src/brux/core.cpp b/rte/src/brux/core.cpp index 77c12547..4f94bf58 100644 --- a/rte/src/brux/core.cpp +++ b/rte/src/brux/core.cpp @@ -24,7 +24,7 @@ #include "brux/core.hpp" void xyLoadCore() { - const SQChar *cmd =R"rew( + const char* cmd =R"rew( const k__0 = 0; const k__1 = 1; const k__2 = 2; @@ -502,9 +502,37 @@ void xyLoadCore() { print("Imported core lib.");)rew"; - SQInteger oldtop = sq_gettop(gvSquirrel); - sq_compilebuffer(gvSquirrel, cmd, (int)strlen(cmd) * sizeof(SQChar), "core", 1); - sq_pushroottable(gvSquirrel); - sq_call(gvSquirrel, 1, SQFalse, SQTrue); - sq_settop(gvSquirrel, oldtop); + ssq::Script script = gvSquirrel.compileSource(cmd, "core.nut"); + gvSquirrel.run(script); +} + + +/** General API functions */ + +void xyDonut(const std::string& file) { + xyPrint("Running %s...", file.c_str()); + ssq::Script script = gvSquirrel.compileFile(file.c_str()); + gvSquirrel.run(script); +} + +void xyRequire(const std::string& file) { + gvDidError = false; + + xyDonut(file); + + if(gvDidError) + xyEnd(); +} + +void xyDostr(const std::string& str) { + ssq::Script script = gvSquirrel.compileSource(str.c_str(), "std::string"); + gvSquirrel.run(script); +} + + +void xyRegisterCoreAPI(ssq::VM& vm) { + vm.addFunc("import", xyDonut); // Clone of `donut()` + vm.addFunc("donut", xyDonut); // Doc'd + vm.addFunc("require", xyRequire); + vm.addFunc("dostr", xyDostr); // Doc'd } diff --git a/rte/src/brux/core.hpp b/rte/src/brux/core.hpp index 71c15b89..0f9f5ed8 100644 --- a/rte/src/brux/core.hpp +++ b/rte/src/brux/core.hpp @@ -21,7 +21,20 @@ #ifndef _CORE_H_ #define _CORE_H_ +#include + +namespace ssq { + class VM; +} + void xyLoadCore(); void xyLoadActors(); +/** General API functions */ +void xyDonut(const std::string& file); +void xyRequire(const std::string& file); +void xyDostr(const std::string& str); + +void xyRegisterCoreAPI(ssq::VM& vm); + #endif diff --git a/rte/src/brux/fileio.cpp b/rte/src/brux/fileio.cpp index 63a9fe1d..07088943 100644 --- a/rte/src/brux/fileio.cpp +++ b/rte/src/brux/fileio.cpp @@ -19,13 +19,14 @@ | FILE I/O SOURCE | \*===============*/ -#include +#include "brux/fileio.hpp" #include +#include + #include "brux/main.hpp" #include "brux/global.hpp" -#include "brux/fileio.hpp" // Initalize a PhysicsFS error. @@ -66,7 +67,6 @@ void xyFSUnmount(const std::string& dir) { std::string xyGetDir() { // Get the current working directory - return getcwd(0, 0); } @@ -121,8 +121,7 @@ void xyCreateDir(const std::string& name) { throw PhysFSError("Could not create directory '" + name + "'", "mkdir"); } -std::string xyFileRead(const std::string& file) -{ +std::string xyFileRead(const std::string& file) { // Check if the file exists. if (!xyFileExists(file)) throw std::runtime_error("File '" + file + "' doesn't exist."); @@ -143,8 +142,16 @@ std::string xyFileRead(const std::string& file) return result; } -void xyFileWrite(const std::string& file, const std::string& data) -{ +std::string xyFileReadAPI(const std::string& file) { + if (xyFileExists(file)) { + return xyFileRead(file); + } + + xyPrint("WARNING: '%s' does not exist!", file.c_str()); + return ""; +} + +void xyFileWrite(const std::string& file, const std::string& data) { // If the full path to the file's directory isn't available, create it. xyCreateDir(std::filesystem::path(file).parent_path().string()); @@ -158,8 +165,7 @@ void xyFileWrite(const std::string& file, const std::string& data) PHYSFS_close(handle); } -void xyFileAppend(const std::string& file, const std::string& data) -{ +void xyFileAppend(const std::string& file, const std::string& data) { // If the file currently exists, read its data. std::string file_data; if (xyFileExists(file)) @@ -181,8 +187,7 @@ bool xyLegacyFileExists(const std::string& file) { return stat(file.c_str(), &buff) != -1; } -void xyFileDelete(const std::string& name) -{ +void xyFileDelete(const std::string& name) { // If a directory is provided, delete all files inside of it. if (xyIsDirectory(name)) { std::filesystem::path dir_path = name; @@ -224,7 +229,6 @@ std::vector xyListDirectory(const std::string& dir) { throw PhysFSError(err.str(), "enumerateFiles"); } char **i; - for (i = rc; *i != NULL; i++) result.push_back(*i); @@ -236,7 +240,7 @@ std::vector xyListDirectory(const std::string& dir) { // JSON encoding / decoding. // Originally implemented by Nova Storm. -void sqDecodeJSONTable(HSQUIRRELVM v, cJSON* item) { +static void sqDecodeJSONTable(HSQUIRRELVM v, cJSON* item) { if (!item) { return; } @@ -285,36 +289,61 @@ void sqDecodeJSONTable(HSQUIRRELVM v, cJSON* item) { } } -void sqDecodeJSON(HSQUIRRELVM v, const char* str) { +SQInteger sqDecodeJSON(HSQUIRRELVM v, const std::string& str) { + if (str.empty()) { + sq_pushnull(v); + return 1; + } + if (str[0] != '{' && str[0] != '[') { - if (!strcmp(str, "true")) { + if (str == "true") { sq_pushbool(v, SQTrue); + return 1; } - - if (!strcmp(str, "false")) { + if (str == "false") { sq_pushbool(v, SQFalse); + return 1; } // FIXME: This code doesn't handle multi-digit integers and floating-point numbers properly. - if (std::isdigit(str[0]) || (str[0] == '-' && std::isdigit(str[1]))) { - sq_pushinteger(v, strtol(str, NULL, 0)); + sq_pushinteger(v, strtol(str.c_str(), NULL, 0)); + return 1; } - - sq_pushstring(v, str, -1); - return; + + sq_pushstring(v, str.c_str(), -1); + return 1; } - cJSON* root = cJSON_Parse(str); + cJSON* root = cJSON_Parse(str.c_str()); if (!root || !root->child) { sq_pushnull(v); - return; + return 1; } sq_newtable(v); sqDecodeJSONTable(v, root->child); cJSON_Delete(root); - return; + return 1; +} + + +void xyRegisterFileIOAPI(ssq::VM& vm) { + vm.addFunc("mount", xyFSMount); // Doc'd + vm.addFunc("unmount", xyFSUnmount); // Doc'd + vm.addFunc("getdir", xyGetDir); // Doc'd + vm.addFunc("getWriteDir", xyGetWriteDir); // Doc'd + vm.addFunc("getPrefDir", xyGetPrefDir); // Doc'd + vm.addFunc("setWriteDir", xySetWriteDir); // Doc'd + vm.addFunc("createDir", xyCreateDir); // Doc'd + vm.addFunc("fileRead", xyFileReadAPI); // Doc'd + vm.addFunc("fileWrite", xyFileWrite); // Doc'd + vm.addFunc("fileAppend", xyFileAppend); // Doc'd + vm.addFunc("fileExists", xyFileExists); // Doc'd + vm.addFunc("fileDelete", xyFileDelete); // Doc'd + vm.addFunc("isdir", xyIsDirectory); // Doc'd + vm.addFunc("lsdir", xyListDirectory); // Doc'd + vm.addFunc("jsonRead", sqDecodeJSON); // Doc'd } diff --git a/rte/src/brux/fileio.hpp b/rte/src/brux/fileio.hpp index 06add7c8..0247603e 100644 --- a/rte/src/brux/fileio.hpp +++ b/rte/src/brux/fileio.hpp @@ -25,6 +25,12 @@ #include #include +#include + +namespace ssq { + class VM; +} + // A class that takes the last PhysicsFS error and converts it to a readable message. class PhysFSError final: public std::exception { @@ -53,6 +59,7 @@ std::string xyGetPrefDir(const std::string& org, const std::string& app); void xySetWriteDir(const std::string& dir); void xyCreateDir(const std::string& name); std::string xyFileRead(const std::string& file); +std::string xyFileReadAPI(const std::string& file); void xyFileWrite(const std::string& file, const std::string& data); void xyFileAppend(const std::string& file, const std::string& data); bool xyFileExists(const std::string& file); @@ -65,7 +72,8 @@ std::vector xyListDirectory(const std::string& dir); // JSON encoding / decoding. // Originally implemented by Nova Storm. -void sqDecodeJSONTable(HSQUIRRELVM v, cJSON* Item); -void sqDecodeJSON(HSQUIRRELVM v, const char* str); +SQInteger sqDecodeJSON(HSQUIRRELVM v, const std::string& str); + +void xyRegisterFileIOAPI(ssq::VM& vm); #endif diff --git a/rte/src/brux/global.cpp b/rte/src/brux/global.cpp index 49bcf964..dc891d46 100644 --- a/rte/src/brux/global.cpp +++ b/rte/src/brux/global.cpp @@ -48,7 +48,7 @@ Uint32 gvWinH = 240; // Squirrel VM -HSQUIRRELVM gvSquirrel; +ssq::VM gvSquirrel; // Log buffer @@ -130,6 +130,7 @@ Uint32 gvVolumeSound = 128; Uint32 gvDrawTarget = 0; bool gvUpdateDeprecationWarningShown = false; bool gvDidError = false; +bool gvQuitRequested = false; // Gamepad // NOTE: I don't know why, I don't want to know why, but *somehow* this entirely breaks if we use the Uint32 type for this diff --git a/rte/src/brux/global.hpp b/rte/src/brux/global.hpp index 8aac0f5f..8b608bbb 100644 --- a/rte/src/brux/global.hpp +++ b/rte/src/brux/global.hpp @@ -22,10 +22,12 @@ #ifndef _GLOBALS_H_ #define _GLOBALS_H_ +#include + #include "brux/main.hpp" +#include "brux/shapes.hpp" #include "brux/sprite.hpp" #include "brux/text.hpp" -#include "brux/shapes.hpp" #define pi 3.14159265f #define OS_WINDOWS 0 @@ -40,7 +42,7 @@ extern int gvMouseX; extern int gvMouseY; extern Uint32 gvScrW, gvScrH; extern Uint32 gvWinW, gvWinH; -extern HSQUIRRELVM gvSquirrel; +extern ssq::VM gvSquirrel; extern std::ofstream gvLog; extern SDL_Window *gvWindow; extern SDL_Renderer *gvRender; @@ -83,6 +85,7 @@ extern Uint32 gvVolumeSound; extern Uint32 gvDrawTarget; extern bool gvUpdateDeprecationWarningShown; extern bool gvDidError; +extern bool gvQuitRequested; // Gamepad diff --git a/rte/src/brux/graphics.cpp b/rte/src/brux/graphics.cpp index df917f35..50176f9b 100644 --- a/rte/src/brux/graphics.cpp +++ b/rte/src/brux/graphics.cpp @@ -18,9 +18,12 @@ | GRAPHICS SOURCE | \*===============*/ +#include "brux/graphics.hpp" + +#include + #include "brux/main.hpp" #include "brux/global.hpp" -#include "brux/graphics.hpp" #include "brux/fileio.hpp" ////////// @@ -77,7 +80,7 @@ void xySetDrawColor(int r, int g, int b, int a) { // Set draw color from 24- or 32-bit integer -void xySetDrawColor(SQInteger color) { +void xySetDrawColor(int color) { // If the value of color is too big for a 24-bit integer, then treat it as 32-bit Uint8 r; @@ -144,11 +147,18 @@ void xyWait(int ticks) { // Set draw target to a texture void xySetDrawTarget(Uint32 tex) { + gvDrawTarget = tex; if (vcTextures.size() >= tex || vcTextures[tex] != 0) { SDL_SetRenderTarget(gvRender, vcTextures[tex]); } } +// Get the draw target texture + +int xyGetDrawTarget() { + return gvDrawTarget; +} + // Set draw target back to screen void xyResetDrawTarget() { @@ -361,7 +371,7 @@ void xyDrawImagePart(Uint32 tex, int x, int y, int ox, int oy, int w, int h) { SDL_RenderCopy(gvRender, vcTextures[tex], &slice, &rec); } -void xyDrawImageEx(Uint32 tex, int x, int y, float angle, SDL_RendererFlip flip, int xscale, int yscale, int alpha, Uint32 color) { +void xyDrawImageEx(Uint32 tex, int x, int y, float angle, int flip, int xscale, int yscale, Uint32 color) { SDL_Rect rec; rec.x = 0; @@ -403,9 +413,7 @@ void xyDrawImageEx(Uint32 tex, int x, int y, float angle, SDL_RendererFlip flip, des.h = rec.h * yscale; SDL_SetTextureColorMod(vcTextures[tex], r, g, b); - SDL_SetTextureAlphaMod(vcTextures[tex], alpha * 255); - SDL_RenderCopyEx(gvRender, vcTextures[tex], &rec, &des, (double)angle, piv, flip); - SDL_SetTextureAlphaMod(vcTextures[tex], 255); + SDL_RenderCopyEx(gvRender, vcTextures[tex], &rec, &des, (double)angle, piv, static_cast(flip)); SDL_SetTextureColorMod(vcTextures[tex], 255, 255, 255); } @@ -428,12 +436,6 @@ void xyDeleteImage(Uint32 tex) { vcTextureNames.pop_back(); } -// Get the current FPS - -Uint32 xyGetFPS() { - return static_cast(std::round(gvFPS)); -} - // Load a texture and assign it to a slot in the textures list Uint32 xyNewTexture(Uint32 w, Uint32 h) { @@ -472,7 +474,215 @@ Uint32 xyNewTexture(Uint32 w, Uint32 h) { return vcTextures.size() - 1; } +// Set the scale of drawing coordinates + +void xySetScaling(float scale) { + if (scale <= 0) { + return; + } + + SDL_RenderSetScale(gvRender, scale, scale); +} + +// Set the scaling filter + +void xySetScalingFilter(int hint) { + if (hint > 2) { + hint = 2; + } + else if (hint < 0) { + hint = 0; + } + + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(hint).c_str()); +} + +// Set the screen resolution + +void xySetResolution(int w, int h) { + // Don't allow the width and/or height to be 0 + if (w < 1 || h < 1) { + throw std::runtime_error("Window dimensions cannot be 0"); + } + + SDL_Rect screensize; + + screensize.x = 0; + screensize.y = 0; + screensize.w = w; + screensize.h = h; + + SDL_RenderSetViewport(gvRender, &screensize); + SDL_RenderSetLogicalSize(gvRender, w, h); + SDL_SetWindowSize(gvWindow, w, h); + SDL_SetWindowMinimumSize(gvWindow, w, h); +} + +// Get the screen width + +int xyScreenW() { + SDL_Rect vp; + + SDL_RenderGetViewport(gvRender, &vp); + + return vp.w; +} + +// Get the screen height + +int xyScreenH() { + SDL_Rect vp; + + SDL_RenderGetViewport(gvRender, &vp); + + return vp.h; +} + +// Get the window width + +int xyWindowW() { + int w; + + SDL_GetWindowSize(gvWindow, &w, 0); + + return w; +} + +// Get the window height + +int xyWindowH() { + int h; + + SDL_GetWindowSize(gvWindow, 0, &h); + + return h; +} + +// Set a texture's blend mode + +void xyTextureSetBlendMode(int texture, int blend) { + if (texture < 0 || texture > static_cast(vcTextures.size()) - 1) { + throw std::runtime_error("Invalid texture ID. Cannot set blend mode"); + } + + SDL_BlendMode mode; + + switch (blend) { + case 0: + mode = SDL_BLENDMODE_NONE; + break; + case 1: + mode = SDL_BLENDMODE_BLEND; + break; + case 2: + mode = SDL_BLENDMODE_ADD; + break; + case 3: + mode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT); + break; + case 4: + mode = SDL_BLENDMODE_MOD; + break; + default: + mode = SDL_BLENDMODE_NONE; + break; + } + + SDL_SetTextureBlendMode(vcTextures[texture], mode); +} + +// Find a texture's ID by its name + +int xyFindTexture(const std::string& name) { + for (int i = 0; i < vcTextureNames.size(); i++) { + if (vcTextureNames[i] == name) { + return i; + } + } + + return 0; +} + +// Get the name of a texture + +std::string xyGetTextureName(int texture) { + if (texture > 0 && texture < vcTextureNames.size()) { + return vcTextureNames[texture]; + } + + return ""; +} + +// Get a texture's filter + +int xyGetTextureFilter(int tex) { + SDL_ScaleMode sm = (SDL_ScaleMode)0; + + if(tex > 0 && tex < vcTextures.size() && vcTextures[tex] != 0) + SDL_GetTextureScaleMode(vcTextures[tex], &sm); + else + xyPrint("WARNING: Texture not found!"); + + return (int)sm; +} + +// Set a texture's filter + +void xySetTextureFilter(int tex, int filter) { + SDL_ScaleMode sm = (SDL_ScaleMode)std::min(std::max(filter, 0), 2); + + if(tex > 0 && tex < vcTextures.size() && vcTextures[tex] != 0) + SDL_SetTextureScaleMode(vcTextures[tex], sm); + else + xyPrint("WARNING: Texture not found!"); +} + +// Print the names of all loaded textures + +void xyPrintTextureNames() { + for (int i = 0; i < vcTextureNames.size(); i++) { + xyPrint("%d - %s", i, vcTextureNames[i].c_str()); + } +} + + +/** SHAPES */ + +// Draw a circle +void xyDrawCircle(int x, int y, int radius, bool filled) { + if (filled) + filledCircleColor(gvRender, x, y, radius, gvDrawColor); + else + circleColor(gvRender, x, y, radius, gvDrawColor); +} + +// Draw a rectangle + +void xyDrawRect(int x, int y, int w, int h, bool filled) { + if (filled) + boxColor(gvRender, x, y, x + w, y + h, gvDrawColor); + else + rectangleColor(gvRender, x, y, x + w, y + h, gvDrawColor); +} + +// Draw a pixel + +void xyDrawPoint(int x, int y) { + pixelColor(gvRender, x, y, gvDrawColor); +} + +// Draw a line + +void xyDrawLine(int x1, int y1, int x2, int y2) { + thickLineColor(gvRender, x1, y1, x2, y2, 1, gvDrawColor); +} + +// Draw a thick line + +void xyDrawLineWide(int x1, int y1, int x2, int y2, int w) { + thickLineColor(gvRender, x1, y1, x2, y2, w, gvDrawColor); +} ////////////// // GEOMETRY // @@ -481,3 +691,39 @@ Uint32 xyNewTexture(Uint32 w, Uint32 h) { +void xyRegisterGraphicsAPI(ssq::VM& vm) { + vm.addFunc("clearScreen", xyClearScreen); // Doc'd + vm.addFunc("setDrawTarget", xySetDrawTarget); // Doc'd + vm.addFunc("getDrawTarget", xyGetDrawTarget); // Doc'd + vm.addFunc("resetDrawTarget", xyResetDrawTarget); + vm.addFunc("drawImage", xyDrawImage); // Doc'd + vm.addFunc("drawImagePart", xyDrawImagePart); + vm.addFunc("drawImageEx", xyDrawImageEx); + vm.addFunc("setDrawColor", static_cast(xySetDrawColor)); // Doc'd + vm.addFunc("loadImage", xyLoadImage); // Doc'd + vm.addFunc("loadImageKeyed", xyLoadImageKeyed); // Doc'd + vm.addFunc("setBackgroundColor", xySetBackgroundColor); // Doc'd + vm.addFunc("setScaling", xySetScaling); + vm.addFunc("setScalingFilter", xySetScalingFilter); // Doc'd + vm.addFunc("setResolution", xySetResolution); // Doc'd + vm.addFunc("screenW", xyScreenW); // Doc'd + vm.addFunc("screenH", xyScreenH); // Doc'd + vm.addFunc("windowW", xyWindowW); + vm.addFunc("windowH", xyWindowH); + vm.addFunc("newTexture", xyNewTexture); // Doc'd + vm.addFunc("textureSetBlendMode", xyTextureSetBlendMode); // Doc'd + vm.addFunc("findTexture", xyFindTexture); + vm.addFunc("deleteTexture", xyDeleteImage); + vm.addFunc("getTextureName", xyGetTextureName); + vm.addFunc("getTextureFilter", xyGetTextureFilter); + vm.addFunc("setTextureFilter", xySetTextureFilter); + vm.addFunc("printTextureNames", xyPrintTextureNames); + + /** SHAPES */ + vm.addFunc("drawCircle", xyDrawCircle); // Doc'd + vm.addFunc("drawRec", xyDrawRect); // Clone of `drawRect()` + vm.addFunc("drawRect", xyDrawRect); // Doc'd + vm.addFunc("drawPoint", xyDrawPoint); // Doc'd + vm.addFunc("drawLine", xyDrawLine); // Doc'd + vm.addFunc("drawLineWide", xyDrawLineWide); // Doc'd +} diff --git a/rte/src/brux/graphics.hpp b/rte/src/brux/graphics.hpp index 6e7762eb..a9b294a9 100644 --- a/rte/src/brux/graphics.hpp +++ b/rte/src/brux/graphics.hpp @@ -27,15 +27,15 @@ SDL_Texture* xyLoadTexture(const std::string& path); void xyClearScreen(); void xyWait(int ticks); void xySetDrawTarget(Uint32 tex); +int xyGetDrawTarget(); void xyResetDrawTarget(); void xyDrawImage(Uint32 tex, int x, int y); void xyDrawImagePart(Uint32 tex, int x, int y, int ox, int oy, int w, int h); -void xyDrawImageEx(Uint32 tex, int x, int y, float angle, SDL_RendererFlip flip, int xscale, int yscale, int alpha, Uint32 color); -Uint32 xyLoadImage(const std::string& path, Uint32 key); -void xySetDrawColor(int r, int g, int b, int a); -void xySetDrawColor(SQInteger color); +void xyDrawImageEx(Uint32 tex, int x, int y, float angle, int flip, int xscale, int yscale, Uint32 color); Uint32 xyLoadImage(const std::string& path); Uint32 xyLoadImageKeyed(const std::string& path, Uint32 key); +void xySetDrawColor(int r, int g, int b, int a); +void xySetDrawColor(int color); void xySetBackgroundColor(Uint32 color); void xyDeleteImage(Uint32 img); Uint8 xyGetRed(Uint32 color); @@ -43,5 +43,27 @@ Uint8 xyGetGreen(Uint32 color); Uint8 xyGetBlue(Uint32 color); Uint8 xyGetAlpha(Uint32 color); Uint32 xyNewTexture(Uint32 w, Uint32 h); +void xySetScaling(float scale); +void xySetScalingFilter(int hint); +void xySetResolution(int w, int h); +int xyScreenW(); +int xyScreenH(); +int xyWindowW(); +int xyWindowH(); +void xyTextureSetBlendMode(int texture, int blend); +int xyFindTexture(const std::string& name); +std::string xyGetTextureName(int texture); +int xyGetTextureFilter(int tex); +void xySetTextureFilter(int tex, int filter); +void xyPrintTextureNames(); + +/** SHAPES */ +void xyDrawCircle(int x, int y, int radius, bool filled); +void xyDrawRect(int x, int y, int w, int h, bool filled); +void xyDrawPoint(int x, int y); +void xyDrawLine(int x1, int y1, int x2, int y2); +void xyDrawLineWide(int x1, int y1, int x2, int y2, int w); + +void xyRegisterGraphicsAPI(ssq::VM& vm); #endif diff --git a/rte/src/brux/input.cpp b/rte/src/brux/input.cpp index e2558c59..0aa6c075 100644 --- a/rte/src/brux/input.cpp +++ b/rte/src/brux/input.cpp @@ -20,6 +20,10 @@ #include "brux/input.hpp" +#include + +#include "brux/global.hpp" + bool xyKeyPress(Uint32 key) { // Ignore invalid keys @@ -30,6 +34,19 @@ bool xyKeyPress(Uint32 key) { return keystate[key] && !keylast[key]; } +int xyKeyPressAny() { + int key = -1; + + for (int i = 0; i < 322; i++) { + if (xyKeyPress(i)) { + key = i; + break; + } + } + + return key; +} + bool xyKeyRelease(Uint32 key) { // Ignore invalid keys @@ -50,6 +67,14 @@ bool xyKeyDown(Uint32 key) { return keystate[key]; } +int xyMouseX() { + return gvMouseX; +} + +int xyMouseY() { + return gvMouseY; +} + bool xyMouseArea(SDL_Rect* area) { return ((gvMouseX >= area->x) && (gvMouseX <= area->x + area->w) && (gvMouseY >= area->y) && (gvMouseY <= area->y + area->h)); } @@ -147,3 +172,135 @@ int xyJoyAxisRelease(int pad, int axis, int dz) { return 0; } + +std::string xyJoyName(int i) { + return gvPadName[i]; +} + +int xyJoyX(int i) { + return gvPadX[i]; +} + +int xyJoyY(int i) { + return gvPadY[i]; +} + +int xyJoyZ(int i) { + return gvPadZ[i]; +} + +int xyJoyH(int i) { + return gvPadH[i]; +} + +int xyJoyV(int i) { + return gvPadV[i]; +} + +int xyJoyR(int i) { + return gvPadR[i]; +} + +int xyJoyL(int i) { + return gvPadL[i]; +} + +int xyJoyAxis(int i, int j) { + return gvPadAxis[i][j]; +} + +bool xyJoyHatDown(int i, int d) { + return gvPadHat[i] & (1 << (d - 1)); +} + +bool xyJoyHatPress(int i, int d) { + return (gvPadHat[i] & (1 << (d - 1))) && !(gvPadHatLast[i] & (1 << (d - 1))); +} + +bool xyJoyHatRelease(int i, int d) { + return !(gvPadHat[i] & (1 << (d - 1))) && (gvPadHatLast[i] & (1 << (d - 1))); +} + +int xyJoyButtonDown(int i, int b) { + return gvPadButton[i][b]; +} + +int xyJoyButtonPress(int i, int b) { + return (gvPadButton[i][b] && !gvPadLastButton[i][b]); +} + +int xyJoyButtonRelease(int i, int b) { + return (!gvPadButton[i][b] && gvPadLastButton[i][b]); +} + +int xyJoyPressAny(int p) { + int button = -1; + + for (int i = 0; i < 32; i++) { + if (gvPadButton[p][i] && !gvPadLastButton[p][i]) { + button = i; + break; + } + } + + return button; +} + +bool xyGetQuit() { + return gvQuit || gvQuitRequested; +} + +void xyQuitGame() { + gvQuitRequested = true; +} + +std::string xyKeyString() { + const std::string input = gvInputString; + gvInputString = ""; // Clean input. + return input; +} + +int xyMouseWheelX() { + return mouseWheelX; +} + +int xyMouseWheelY() { + return mouseWheelY; +} + + +void xyRegisterInputAPI(ssq::VM& vm) { + vm.addFunc("keyPress", xyKeyPress); // Doc'd + vm.addFunc("keyDown", xyKeyDown); // Doc'd + vm.addFunc("keyRelease", xyKeyRelease); // Doc'd + vm.addFunc("keyPressAny", xyKeyPressAny); // Doc'd + vm.addFunc("mouseDown", xyMouseButton); // Doc'd + vm.addFunc("mousePress", xyMousePress); // Doc'd + vm.addFunc("mouseRelease", xyMouseRelease); // Doc'd + vm.addFunc("mouseX", xyMouseX); // Doc'd + vm.addFunc("mouseY", xyMouseY); // Doc'd + vm.addFunc("getQuit", xyGetQuit); // Doc'd + vm.addFunc("quitGame", xyQuitGame); // Doc'd + vm.addFunc("joyCount", SDL_NumJoysticks); // Doc'd + vm.addFunc("joyName", xyJoyName); // Doc'd + vm.addFunc("joyX", xyJoyX); // Doc'd + vm.addFunc("joyY", xyJoyY); // Doc'd + vm.addFunc("joyZ", xyJoyZ); // Doc'd + vm.addFunc("joyH", xyJoyH); // Doc'd + vm.addFunc("joyV", xyJoyV); // Doc'd + vm.addFunc("joyR", xyJoyR); // Doc'd + vm.addFunc("joyL", xyJoyL); // Doc'd + vm.addFunc("joyAxis", xyJoyAxis); // Doc'd + vm.addFunc("joyHatDown", xyJoyHatDown); // Doc'd + vm.addFunc("joyHatPress", xyJoyHatPress); // Doc'd + vm.addFunc("joyHatRelease", xyJoyHatRelease); // Doc'd + vm.addFunc("joyButtonPress", xyJoyButtonPress); // Doc'd + vm.addFunc("joyButtonDown", xyJoyButtonDown); // Doc'd + vm.addFunc("joyButtonRelease", xyJoyButtonRelease); // Doc'd + vm.addFunc("joyPressAny", xyJoyPressAny); // Doc'd + vm.addFunc("joyAxisPress", xyJoyAxisPress); // Doc'd + vm.addFunc("joyAxisRelease", xyJoyAxisRelease); // Doc'd + vm.addFunc("keyString", xyKeyString); // Doc'd + vm.addFunc("mouseWheelX", xyMouseWheelX); // Doc'd + vm.addFunc("mouseWheelY", xyMouseWheelY); // Doc'd +} diff --git a/rte/src/brux/input.hpp b/rte/src/brux/input.hpp index 3ba04298..de235f72 100644 --- a/rte/src/brux/input.hpp +++ b/rte/src/brux/input.hpp @@ -21,11 +21,14 @@ #ifndef _INPUT_H_ #define _INPUT_H_ -#include "brux/global.hpp" +#include "brux/main.hpp" bool xyKeyPress(Uint32 key); // Check if a key was pressed +int xyKeyPressAny(); // Get the next pressed key bool xyKeyRelease(Uint32 key); // Check if a key was released bool xyKeyDown(Uint32 key); // Check if a key is down +int xyMouseX(); // Get the mouse cursor X position +int xyMouseY(); // Get the mouse cursor Y position bool xyMouseArea(SDL_Rect* area); // Check if the mouse is in an area bool xyMouseButton(int button); // Check if a mouse button is down bool xyMousePress(int button); @@ -33,5 +36,28 @@ bool xyMouseRelease(int button); void xyInitInput(); // Set up input int xyJoyAxisPress (int pad, int axis, int dz); // Check if an axis was pressed int xyJoyAxisRelease (int pad, int axis, int dz); // Check if an axis was released +std::string xyJoyName(int i); +int xyJoyX(int i); +int xyJoyY(int i); +int xyJoyZ(int i); +int xyJoyH(int i); +int xyJoyV(int i); +int xyJoyR(int i); +int xyJoyL(int i); +int xyJoyAxis(int i, int j); +bool xyJoyHatDown(int i, int d); +bool xyJoyHatPress(int i, int d); +bool xyJoyHatRelease(int i, int d); +int xyJoyButtonDown(int i, int b); +int xyJoyButtonPress(int i, int b); +int xyJoyButtonRelease(int i, int b); +int xyJoyPressAny(int p); +bool xyGetQuit(); // Check if game quit has been requested +void xyQuitGame(); // Request game quit +std::string xyKeyString(); // Get and clear string of last pressed key +int xyMouseWheelX(); // Get mouse wheel X movement +int xyMouseWheelY(); // Get mouse wheel Y movement + +void xyRegisterInputAPI(ssq::VM& vm); #endif diff --git a/rte/src/brux/main.cpp b/rte/src/brux/main.cpp index f9332e0f..bb46ee74 100644 --- a/rte/src/brux/main.cpp +++ b/rte/src/brux/main.cpp @@ -31,14 +31,18 @@ #include "brux/main.hpp" +#include + #include "audio/audio.hpp" -#include "api/input.hpp" #include "brux/core.hpp" #include "brux/fileio.hpp" #include "brux/global.hpp" #include "brux/graphics.hpp" #include "brux/input.hpp" -#include "squirrel/wrapper.hpp" +#include "brux/maths.hpp" +#include "brux/shapes.hpp" +#include "brux/sprite.hpp" +#include "brux/text.hpp" ///////////////// //MAIN FUNCTION// @@ -55,16 +59,6 @@ int main(int argc, char* argv[]) { FS.chdir('/bin'); ); #endif - // Initialize the file system (PhysFS) - xyFSInit(); - - // Mount the current working directory. - xyFSMount(xyGetDir(), "/", true); - - // Set the current write directory to a default for Brux. - // Can be changed later by the game. - xySetWriteDir(xyGetPrefDir("brux", "brux")); - // Process arguments std::string xygapp = ""; @@ -119,6 +113,16 @@ int main(int argc, char* argv[]) { } } + // Initialize the file system (PhysFS) + xyFSInit(); + + // Mount the current working directory. + xyFSMount(xyGetDir(), "/", true); + + // Set the current write directory to a default for Brux. + // Can be changed later by the game. + xySetWriteDir(xyGetPrefDir("brux", "brux")); + bool shouldLoad = false; if (xygapp != "") { @@ -164,8 +168,12 @@ int main(int argc, char* argv[]) { SDL_ShowCursor(0); - xyPrint("Running %s...", xygapp.c_str()); - sqstd_dofile(gvSquirrel, xygapp.c_str(), 0, 1); + try { + xyDonut(xygapp); + } + catch (const std::exception& err) { + xyPrint("Error running '%s': %s", xygapp.c_str(), err.what()); + } // Unload everything once the squirrel code is finished running @@ -189,7 +197,7 @@ int xyInit() { // Initiate log file remove("log.txt"); - gvLog.open("log.txt", ios_base::out); + gvLog.open("log.txt", std::ios_base::out); // Print opening message @@ -267,27 +275,28 @@ int xyInit() { // Initiate Squirrel - gvSquirrel = sq_open(1024); - + gvSquirrel = ssq::VM(1024, ssq::Libs::IO | ssq::Libs::SYSTEM | ssq::Libs::MATH | ssq::Libs::STRING); - sq_setprintfunc(gvSquirrel, sqPrint, sqError); - sq_pushroottable(gvSquirrel); + gvSquirrel.setPrintFunc(sqPrint, sqError); - sqstd_register_iolib(gvSquirrel); - sqstd_register_systemlib(gvSquirrel); - sqstd_register_mathlib(gvSquirrel); - sqstd_register_stringlib(gvSquirrel); - - // Bind all Brux API functions to Squirrel, using the miniswig generated wrapper. + // Bind all Brux API functions to Squirrel xyPrint("Embedding API..."); - BruxAPI::register_brux_wrapper(gvSquirrel); + xyRegisterAudioAPI(gvSquirrel); + xyRegisterCoreAPI(gvSquirrel); + xyRegisterFileIOAPI(gvSquirrel); + xyRegisterGraphicsAPI(gvSquirrel); + xyRegisterInputAPI(gvSquirrel); + xyRegisterMainAPI(gvSquirrel); + xyRegisterMathsAPI(gvSquirrel); + xyRegisterShapesAPI(gvSquirrel); + xyRegisterSpriteAPI(gvSquirrel); + xyRegisterTextAPI(gvSquirrel); // The error handler does not seem to print compile-time errors. // I haven't been able to figure out why, as the same code works in my other apps, // and is taken from the sq.c example included with Squirrel. - - sqstd_seterrorhandlers(gvSquirrel); + gvSquirrel.setStdErrorFunc(); xyPrint("Squirrel initialized successfully!"); @@ -334,10 +343,9 @@ void xyEnd() { // Run Squirrel's garbage collector, and then close the Squirrel VM. xyPrint("Closing Squirrel..."); - SQInteger garbage = sq_collectgarbage(gvSquirrel); + SQInteger garbage = sq_collectgarbage(gvSquirrel.getHandle()); xyPrint("Collected %i junk obects.", garbage); - sq_pop(gvSquirrel, 1); - sq_close(gvSquirrel); + gvSquirrel.destroy(); // Unload all of the audio stuff @@ -372,8 +380,8 @@ void xyPrint(const SQChar *s, ...) { vsnprintf(buffer, sizeof(buffer), s, argv); va_end(argv); - cout << buffer << endl; - gvLog << buffer << endl; + std::cout << buffer << std::endl; + gvLog << buffer << std::endl; } void sqPrint(HSQUIRRELVM v, const SQChar *s, ...) { @@ -385,8 +393,8 @@ void sqPrint(HSQUIRRELVM v, const SQChar *s, ...) { vsnprintf(buffer, sizeof(buffer), s, argv); va_end(argv); - cout << buffer << endl; - gvLog << buffer << endl; + std::cout << buffer << std::endl; + gvLog << buffer << std::endl; } void sqError(HSQUIRRELVM v, const SQChar *s, ...) { @@ -400,11 +408,16 @@ void sqError(HSQUIRRELVM v, const SQChar *s, ...) { vsnprintf(buffer, sizeof(buffer), s, argv); va_end(argv); - cout << buffer << endl; - gvLog << buffer << endl; + std::cout << buffer << std::endl; + gvLog << buffer << std::endl; } void xyUpdate() { + if (!gvUpdateDeprecationWarningShown) { + xyPrint("WARNING: update() is deprecated and will be removed in a future release."); + gvUpdateDeprecationWarningShown = true; + } + // Update last button state int i; @@ -629,6 +642,58 @@ void xyUpdate() { gvFrames++; } +int xyGetFPS() { + return static_cast(std::round(gvFPS)); +} + +void xySetFPS(int max_fps) { + if (max_fps < 0) { + throw std::runtime_error("Maximum FPS cannot be negative"); + } + + gvMaxFPS = max_fps; +} + +void xySetWindowTitle(const std::string& title) { + SDL_SetWindowTitle(gvWindow, title.c_str()); +} + +void xySetWindowIcon(const std::string& file) { + if (!xyFileExists(file)) { + return; + } + + SDL_Surface* icon = IMG_Load(file.c_str()); + SDL_SetWindowIcon(gvWindow, icon); + SDL_FreeSurface(icon); +} + +int xyGetFrames() { + return gvFrames; +} + +int xyDisplayW() { + SDL_DisplayMode DM; + SDL_GetCurrentDisplayMode(0, &DM); + + return DM.w; +} + +int xyDisplayH() { + SDL_DisplayMode DM; + SDL_GetCurrentDisplayMode(0, &DM); + + return DM.h; +} + +std::string xyBruxVersion() { + return gvVNo; +} + +void xyToggleFullscreen() { + SDL_SetWindowFullscreen(gvWindow, (SDL_GetWindowFlags(gvWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP) ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP); +} + int xyGetOS() { #ifdef _WIN32 return OS_WINDOWS; @@ -650,3 +715,20 @@ int xyGetOS() { void __stack_chk_fail(void) { xyPrint("Stack smash detected."); } + + +void xyRegisterMainAPI(ssq::VM& vm) { + vm.addFunc("wait", xyWait); // Doc'd + vm.addFunc("update", xyUpdate); // Doc'd + vm.addFunc("getOS", xyGetOS); // Doc'd + vm.addFunc("getTicks", SDL_GetTicks); // Doc'd + vm.addFunc("getFPS", xyGetFPS); // Doc'd + vm.addFunc("setFPS", xySetFPS); // Doc'd + vm.addFunc("setWindowTitle", xySetWindowTitle); // Doc'd + vm.addFunc("setWindowIcon", xySetWindowIcon); // Doc'd + vm.addFunc("getFrames", xyGetFrames); // Doc'd + vm.addFunc("displayW", xyDisplayW); // Doc'd + vm.addFunc("displayH", xyDisplayH); // Doc'd + vm.addFunc("bruxVersion", xyBruxVersion); // Doc'd + vm.addFunc("toggleFullscreen", xyToggleFullscreen); // Doc'd +} diff --git a/rte/src/brux/main.hpp b/rte/src/brux/main.hpp index 2096cc49..6b185c66 100644 --- a/rte/src/brux/main.hpp +++ b/rte/src/brux/main.hpp @@ -77,17 +77,14 @@ void __stack_chk_fail(void); #include #include -#include -#include -#include -#include -#include #ifdef __EMSCRIPTEN__ #include #endif -using namespace std; +namespace ssq { + class VM; +} // Defines @@ -97,6 +94,11 @@ using namespace std; #define scvprintf vprintf #endif +#ifdef _MSC_VER + #undef min // Fixes a std::min "illegal token on right side of '::'" error + #undef max // Fixes a std::max "illegal token on right side of '::'" error +#endif + // Prototypes int xyInit(); @@ -105,7 +107,18 @@ void xyEnd(); void xyPrint(const SQChar *s, ...); void sqPrint(HSQUIRRELVM v, const SQChar *s, ...); void sqError(HSQUIRRELVM v, const SQChar *s, ...); -int xyGetOS(); void xyUpdate(); +int xyGetOS(); +int xyGetFPS(); +void xySetFPS(int max_fps); +void xySetWindowTitle(const std::string& title); +void xySetWindowIcon(const std::string& file); +int xyGetFrames(); +int xyDisplayW(); +int xyDisplayH(); +std::string xyBruxVersion(); +void xyToggleFullscreen(); + +void xyRegisterMainAPI(ssq::VM& vm); #endif diff --git a/rte/src/brux/maths.cpp b/rte/src/brux/maths.cpp index 6626cef6..13c8c43b 100644 --- a/rte/src/brux/maths.cpp +++ b/rte/src/brux/maths.cpp @@ -18,9 +18,12 @@ | MATHS SOURCE | \*============*/ +#include "brux/maths.hpp" + +#include + #include "brux/main.hpp" #include "brux/global.hpp" -#include "brux/maths.hpp" float xyDistance(float x1, float y1, float x2, float y2) { //2D distance formula @@ -28,7 +31,7 @@ float xyDistance(float x1, float y1, float x2, float y2) { float yd = (float)(y1 - y2); return sqrt((xd * xd) + (yd * yd)); -}; +} float xyDistance3(float x1, float y1, float z1, float x2, float y2, float z2) { float xd = (float)(x1 - x2); @@ -36,55 +39,197 @@ float xyDistance3(float x1, float y1, float z1, float x2, float y2, float z2) { float zd = (float)(z1 - z2); return sqrt((xd * xd) + (yd * yd) + (zd * zd)); -}; +} bool xyInDistance2(float x1, float y1, float x2, float y2, float distance) { //Faster than xyDistance for checking within range //xyDistance is better for when the actual distance needs to be shown return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) <= distance * distance; -}; +} int xyRandomInt(int mx) { int numb = rand(); numb %= mx; return numb; -}; +} float xyRandomFloat(float mx) { return (static_cast(rand()) / (float)RAND_MAX) * mx; -}; +} float xyWrap(float x, float a0, float a1) { - float mx = max(a0, a1); - float mn = min(a0, a1); + float mx = std::max(a0, a1); + float mn = std::min(a0, a1); float diff = mx - mn + 1; if(x >= 0) return mn + fmodf(x, diff); if(x < 0) return mx + fmod(x, diff); return 0; //Just so GCC is happy -}; +} + +int xyFloor(float f) { + return static_cast(std::floor(f)); +} + +int xyCeil(float f) { + return static_cast(std::ceil(f)); +} + +int xyRound(float f) { + return static_cast(std::round(f)); +} float xyPointAngle(float x1, float y1, float x2, float y2) { return atan2(y2 - y1, x2 - x1) * (180 / pi); -}; +} bool xyPointInBox(float x1, float y1, float x2, float y2, float px, float py) { //Get min/max of box in case box is flipped float t, b, l, r; - l = min(x1, x2); - r = max(x1, x2); - t = min(y1, y2); - b = max(y1, y2); + l = std::min(x1, x2); + r = std::max(x1, x2); + t = std::min(y1, y2); + b = std::max(y1, y2); return px < r && px > l && py < b && py > t; -}; +} float xyLenDirX(float l, float d) { return l * cos(d * pi / 180); -}; +} float xyLenDirY(float l, float d) { return l * sin(d * pi / 180); -}; +} + +std::string xyBinstr(int i) { + int l = static_cast(log2(i)) + 1; + std::string s; + + switch (l) { + case 0: + s = "0"; + break; + case 1: + s = std::bitset<1>(i).to_string(); + break; + case 2: + s = std::bitset<2>(i).to_string(); + break; + case 3: + s = std::bitset<3>(i).to_string(); + break; + case 4: + s = std::bitset<4>(i).to_string(); + break; + case 5: + s = std::bitset<5>(i).to_string(); + break; + case 6: + s = std::bitset<6>(i).to_string(); + break; + case 7: + s = std::bitset<7>(i).to_string(); + break; + case 8: + s = std::bitset<8>(i).to_string(); + break; + case 9: + s = std::bitset<9>(i).to_string(); + break; + case 10: + s = std::bitset<10>(i).to_string(); + break; + case 11: + s = std::bitset<11>(i).to_string(); + break; + case 12: + s = std::bitset<12>(i).to_string(); + break; + case 13: + s = std::bitset<13>(i).to_string(); + break; + case 14: + s = std::bitset<14>(i).to_string(); + break; + case 15: + s = std::bitset<15>(i).to_string(); + break; + case 16: + s = std::bitset<16>(i).to_string(); + break; + case 17: + s = std::bitset<17>(i).to_string(); + break; + case 18: + s = std::bitset<18>(i).to_string(); + break; + case 19: + s = std::bitset<19>(i).to_string(); + break; + case 20: + s = std::bitset<20>(i).to_string(); + break; + case 21: + s = std::bitset<21>(i).to_string(); + break; + case 22: + s = std::bitset<22>(i).to_string(); + break; + case 23: + s = std::bitset<23>(i).to_string(); + break; + case 24: + s = std::bitset<24>(i).to_string(); + break; + case 25: + s = std::bitset<25>(i).to_string(); + break; + case 26: + s = std::bitset<26>(i).to_string(); + break; + case 27: + s = std::bitset<27>(i).to_string(); + break; + case 28: + s = std::bitset<28>(i).to_string(); + break; + case 29: + s = std::bitset<29>(i).to_string(); + break; + case 30: + s = std::bitset<30>(i).to_string(); + break; + case 31: + s = std::bitset<31>(i).to_string(); + break; + case 32: + s = std::bitset<32>(i).to_string(); + break; + default: + s = std::bitset<64>(i).to_string(); + break; + } + + return s; +} + + +void xyRegisterMathsAPI(ssq::VM& vm) { + vm.addFunc("randFloat", xyRandomFloat); // Doc'd + vm.addFunc("randInt", xyRandomInt); // Doc'd + vm.addFunc("distance2", xyDistance); // Doc'd + vm.addFunc("inDistance2", xyInDistance2); + vm.addFunc("distance3", xyDistance3); + vm.addFunc("wrap", xyWrap); // Doc'd + vm.addFunc("floor", xyFloor); // Doc'd + vm.addFunc("ceil", xyCeil); // Doc'd + vm.addFunc("round", xyRound); // Doc'd + vm.addFunc("pointAngle", xyPointAngle); // Doc'd + vm.addFunc("abs", static_cast(std::abs)); // Doc'd + vm.addFunc("lendirX", xyLenDirX); // Doc'd + vm.addFunc("lendirY", xyLenDirY); // Doc'd + vm.addFunc("binstr", xyBinstr); // Doc'd +} diff --git a/rte/src/brux/maths.hpp b/rte/src/brux/maths.hpp index 46d4480a..65adc62b 100644 --- a/rte/src/brux/maths.hpp +++ b/rte/src/brux/maths.hpp @@ -21,15 +21,27 @@ #ifndef _XYMATHS_H_ #define _XYMATHS_H_ +#include + +namespace ssq { + class VM; +} + float xyDistance(float x1, float y1, float x2, float y2); //Distance between two points float xyDistance3(float x1, float y1, float z1, float x2, float y2, float z2); bool xyInDistance2(float x1, float y1, float x2, float y2, float distance); int xyRandomInt(int mx); //Generate a random integer float xyRandomFloat(float mx); //Generate a random float float xyWrap(float x,float a0,float a1); //Wrap an integer +int xyFloor(float f); +int xyCeil(float f); +int xyRound(float f); float xyPointAngle(float x1, float y1, float x2, float y2); //Get the angle between two points bool xyPointInBox(float x1, float y1, float x2, float y2, float px, float py); float xyLenDirX(float l, float d); float xyLenDirY(float l, float d); +std::string xyBinstr(int i); + +void xyRegisterMathsAPI(ssq::VM& vm); #endif diff --git a/rte/src/brux/shapes.cpp b/rte/src/brux/shapes.cpp index bb88eb2d..ae1d450c 100644 --- a/rte/src/brux/shapes.cpp +++ b/rte/src/brux/shapes.cpp @@ -18,10 +18,13 @@ | SHAPES SOURCE | \*=============*/ +#include "brux/shapes.hpp" + +#include + #include "brux/main.hpp" #include "brux/global.hpp" #include "brux/maths.hpp" -#include "brux/shapes.hpp" /*\ This part is being put on hold. @@ -209,6 +212,15 @@ bool xyLineLine(xyPnt* a, xyPnt* b, xyPnt* c, xyPnt* d) { return (r >= 0 && r <= 1) && (s >= 0 && s <= 1); } +bool xyLineLineAPI(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) { + xyPnt a(x0, y0); + xyPnt b(x1, y1); + xyPnt c(x2, y2); + xyPnt d(x3, y3); + + return xyLineLine(&a, &b, &c, &d); +} + bool xyPointLine(xyPnt* a, xyPnt* b, xyPnt* c) { return false; //TODO: Fill this in } @@ -234,6 +246,14 @@ bool xyLineCircle(xyPnt* a, xyPnt* b, xyPnt* c, float r) { return (len <= r); } +bool xyLineCircleAPI(float x0, float y0, float x1, float y1, float x2, float y2, float r) { + xyPnt a(x0, y0); + xyPnt b(x1, y1); + xyPnt c(x2, y2); + + return xyLineCircle(&a, &b, &c, r); +} + bool xyLinePoint(float lx0, float ly0, float lx1, float ly1, float px, float py) { float ll = xyDistance(lx0, ly0, lx1, ly1); float d1 = xyDistance(lx0, ly0, px, py); @@ -555,4 +575,11 @@ bool xyHitTest(xyShape* a, xyShape* b) { return 0; break; }; -}; +} + + +void xyRegisterShapesAPI(ssq::VM& vm) { + vm.addFunc("hitLineLine", xyLineLineAPI); // Doc'd + vm.addFunc("hitLineCircle", xyLineCircleAPI); // Doc'd + vm.addFunc("hitLinePoint", xyLinePoint); // Doc'd +} diff --git a/rte/src/brux/shapes.hpp b/rte/src/brux/shapes.hpp index e3935a61..e16f562b 100644 --- a/rte/src/brux/shapes.hpp +++ b/rte/src/brux/shapes.hpp @@ -21,6 +21,12 @@ #ifndef _SHAPES_H_ #define _SHAPES_H_ +#include + +namespace ssq { + class VM; +} + const int _SHP = 0; //Formless shape const int _LIN = 1; //Line const int _CIR = 2; //Circle @@ -108,9 +114,13 @@ class xyShape }; bool xyLineLine(xyPnt* a, xyPnt* b, xyPnt* c, xyPnt* d); +bool xyLineLineAPI(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3); bool xyPointLine(xyPnt* a, xyPnt* b, xyPnt* c); bool xyLineCircle(xyPnt* a, xyPnt* b, xyPnt* c, float r); +bool xyLineCircleAPI(float x0, float y0, float x1, float y1, float x2, float y2, float r); bool xyLinePoint(float lx0, float ly0, float lx1, float ly1, float px, float py); bool xyHitTest(xyShape* a, xyShape* b); +void xyRegisterShapesAPI(ssq::VM& vm); + #endif diff --git a/rte/src/brux/sprite.cpp b/rte/src/brux/sprite.cpp index 790705b1..79896a4d 100644 --- a/rte/src/brux/sprite.cpp +++ b/rte/src/brux/sprite.cpp @@ -18,10 +18,13 @@ | SPRITE SOURCE | \*=============*/ -#include "brux/main.hpp" +#include "brux/sprite.hpp" + +#include + #include "brux/global.hpp" #include "brux/graphics.hpp" -#include "brux/sprite.hpp" +#include "brux/main.hpp" #include "brux/maths.hpp" xySprite::xySprite(const std::string& filename, Uint32 width, Uint32 height, Uint32 margin, Uint32 padding, float pivotX, float pivotY): @@ -321,3 +324,142 @@ void xySprite::drawexmod(int f, int x, int y, int angle, SDL_RendererFlip flip, delete piv; }; + + +/** API */ + +std::string xySpriteName(int sprite) { + if (static_cast(vcSprites.size()) <= sprite || sprite < 0 || vcSprites[sprite] == 0) { + return "N/A"; + } + + return vcSprites[sprite]->name; +} + +int xyFindSprite(const std::string& name) { + for (size_t i = 0; i < vcSprites.size(); i++) { + if (vcSprites[i] != 0) { + if (vcSprites[i]->getname() == name) { + return vcSprites[i]->getnum(); + } + } + } + + return 0; +} + +int xyNewSprite(const std::string& i, int w, int h, int m, int p, float px, float py) { + xySprite* newsprite = new xySprite(i, w, h, m, p, px, py); + + return newsprite->getnum(); +} + +int xyNewSpriteFT(int t, int w, int h, int m, int p, float px, float py) { + xySprite* newsprite = new xySprite(t, w, h, m, p, px, py); + + return newsprite->getnum(); +} + +#define SPRITE_CHECK_VALID if (static_cast(vcSprites.size()) <= i || vcSprites[i] == 0) +#define SPRITE_CHECK_VALID_VOID SPRITE_CHECK_VALID return +#define SPRITE_CHECK_VALID_INT SPRITE_CHECK_VALID return 0 + +void xyDrawSprite(int i, int f, int x, int y) { + SPRITE_CHECK_VALID_VOID; + vcSprites[i]->draw(f, x, y); +} + +void xyDrawSpriteEx(int i, int f, int x, int y, int a, int l, float sx, float sy, float p) { + SPRITE_CHECK_VALID_VOID; + vcSprites[i]->drawex(f, x, y, a, static_cast(l), sx, sy, p); +} + +void xyDrawSpriteMod(int i, int f, int x, int y, int c) { + SPRITE_CHECK_VALID_VOID; + vcSprites[i]->drawmod(f, x, y, c); +} + +void xyDrawSpriteExMod(int i, int f, int x, int y, int a, int l, float sx, float sy, float p, int c) { + SPRITE_CHECK_VALID_VOID; + vcSprites[i]->drawexmod(f, x, y, a, static_cast(l), sx, sy, p, c); +} + +void xyDeleteSprite(int i) { + SPRITE_CHECK_VALID_VOID; + delete vcSprites[i]; +} + +int xySpriteW(int i) { + SPRITE_CHECK_VALID_INT; + return vcSprites[i]->getw(); +} + +int xySpriteH(int i) { + SPRITE_CHECK_VALID_INT; + return vcSprites[i]->geth(); +} + +#undef SPRITE_CHECK_VALID +#undef SPRITE_CHECK_VALID_VOID +#undef SPRITE_CHECK_VALID_INT + +void xyReplaceSprite(int s, const std::string& f, int w, int h, int m, int p, float x, float y) { + if (s <= 0 || s >= static_cast(vcSprites.size())) { + return; + } + + if (vcSprites[s] != 0) { + vcSprites[s]->replaceSprite(f, w, h, m, p, x, y); + return; + } + + vcSprites[s] = new xySprite(f, w, h, m, p, x, y); +} + +void xySpriteSetBlendMode(int sprite, int blend) { + if (sprite < 0 || sprite > static_cast(vcSprites.size()) - 1) { + throw std::runtime_error("Invalid sprite ID. Cannot set blend mode"); + } + + SDL_BlendMode mode; + + switch (blend) { + case 0: + mode = SDL_BLENDMODE_NONE; + break; + case 1: + mode = SDL_BLENDMODE_BLEND; + break; + case 2: + mode = SDL_BLENDMODE_ADD; + break; + case 3: + mode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT); + break; + case 4: + mode = SDL_BLENDMODE_MOD; + break; + default: + mode = SDL_BLENDMODE_NONE; + break; + } + + SDL_SetTextureBlendMode(vcTextures[vcSprites[sprite]->gettex()], mode); +} + + +void xyRegisterSpriteAPI(ssq::VM& vm) { + vm.addFunc("spriteName", xySpriteName); // Doc'd + vm.addFunc("findSprite", xyFindSprite); // Doc'd + vm.addFunc("newSprite", xyNewSprite); // Doc'd + vm.addFunc("newSpriteFT", xyNewSpriteFT); + vm.addFunc("drawSprite", xyDrawSprite); // Doc'd + vm.addFunc("drawSpriteEx", xyDrawSpriteEx); // Doc'd + vm.addFunc("drawSpriteMod", xyDrawSpriteMod); // Doc'd + vm.addFunc("drawSpriteExMod", xyDrawSpriteExMod); // Doc'd + vm.addFunc("deleteSprite", xyDeleteSprite); // Doc'd + vm.addFunc("spriteW", xySpriteW); // Doc'd + vm.addFunc("spriteH", xySpriteH); // Doc'd + vm.addFunc("replaceSprite", xyReplaceSprite); + vm.addFunc("spriteSetBlendMode", xySpriteSetBlendMode); // Doc'd +} diff --git a/rte/src/brux/sprite.hpp b/rte/src/brux/sprite.hpp index 29b8105c..1acf36b7 100644 --- a/rte/src/brux/sprite.hpp +++ b/rte/src/brux/sprite.hpp @@ -21,6 +21,8 @@ #ifndef _SPRITE_H_ #define _SPRITE_H_ +#include "brux/main.hpp" + class xySprite { private: Uint32 numero, mar, pad, w, h, tex, col, row, frames = 0; @@ -48,4 +50,21 @@ class xySprite { const char* getname() const { return name.c_str(); } }; +/** API */ +std::string xySpriteName(int sprite); +int xyFindSprite(const std::string& name); +int xyNewSprite(const std::string& i, int w, int h, int m, int p, float px, float py); +int xyNewSpriteFT(int t, int w, int h, int m, int p, float px, float py); +void xyDrawSprite(int i, int f, int x, int y); +void xyDrawSpriteEx(int i, int f, int x, int y, int a, int l, float sx, float sy, float p); +void xyDrawSpriteMod(int i, int f, int x, int y, int c); +void xyDrawSpriteExMod(int i, int f, int x, int y, int a, int l, float sx, float sy, float p, int c); +void xyDeleteSprite(int i); +int xySpriteW(int i); +int xySpriteH(int i); +void xyReplaceSprite(int s, const std::string& f, int w, int h, int m, int p, float x, float y); +void xySpriteSetBlendMode(int sprite, int blend); + +void xyRegisterSpriteAPI(ssq::VM& vm); + #endif diff --git a/rte/src/brux/text.cpp b/rte/src/brux/text.cpp index 0e6d921f..399b9ad2 100644 --- a/rte/src/brux/text.cpp +++ b/rte/src/brux/text.cpp @@ -18,11 +18,14 @@ | TEXT SOURCE | \*===========*/ -#include "brux/main.hpp" +#include "brux/text.hpp" + +#include + #include "brux/global.hpp" #include "brux/graphics.hpp" +#include "brux/main.hpp" #include "brux/sprite.hpp" -#include "brux/text.hpp" //New bitmap font format to replace SDL_ttf. // @@ -156,3 +159,42 @@ void xyFont::draw(int x, int y, std::string text) { Uint32 xyFont::getnum() { return numero; }; + + +/** API */ + +int xyNewFont(int i, int c, int t, bool m, int k) { + // Sanitize inputs + if (i < 0) { + i = 0; + } + else if (t > 255) { + t = 255; + } + else if (c > 255) { + c = 255; + } + + xyFont* newfont = new xyFont(i, static_cast(c), static_cast(t), m, k); + return newfont->getnum(); +} + +#define FONT_CHECK_VALID if (f >= static_cast(vcFonts.size()) || vcFonts[f] == 0) return + +void xyDrawText(int f, float x, float y, const std::string& s) { + FONT_CHECK_VALID; + vcFonts[f]->draw(static_cast(x), static_cast(y), s); +} + +#undef FONT_CHECK_VALID + +std::string xyChint(int i) { + return std::string(1, static_cast(i)); +} + + +void xyRegisterTextAPI(ssq::VM& vm) { + vm.addFunc("newFont", xyNewFont); // Doc'd + vm.addFunc("drawText", xyDrawText); // Doc'd + vm.addFunc("chint", xyChint); // Doc'd +} diff --git a/rte/src/brux/text.hpp b/rte/src/brux/text.hpp index e6cbe585..fe89ae5b 100644 --- a/rte/src/brux/text.hpp +++ b/rte/src/brux/text.hpp @@ -21,6 +21,8 @@ #ifndef _TEXT_H_ #define _TEXT_H_ +#include "brux/sprite.hpp" + class xyFont { private: @@ -38,4 +40,11 @@ class xyFont void draw(int x, int y, std::string text); }; +/** API */ +int xyNewFont(int i, int c, int t, bool m, int k); +void xyDrawText(int f, float x, float y, const std::string& s); +std::string xyChint(int i); + +void xyRegisterTextAPI(ssq::VM& vm); + #endif diff --git a/rte/src/squirrel/squirrel_error.cpp b/rte/src/squirrel/squirrel_error.cpp deleted file mode 100644 index 50ae1bc9..00000000 --- a/rte/src/squirrel/squirrel_error.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// SuperTux -// Copyright (C) 2006 Matthias Braun -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#include "squirrel/squirrel_error.hpp" - -#include - -SquirrelError::SquirrelError(HSQUIRRELVM v, const std::string& message) throw() : - m_message() -{ - std::ostringstream msg; - msg << "Squirrel error: " << message << " ("; - - // Attempt to get last error. - const char* lasterr; - sq_getlasterror(v); - if (sq_gettype(v, -1) != OT_STRING) - { - lasterr = "no error info"; - } - else - { - sq_getstring(v, -1, &lasterr); - } - - msg << lasterr << ")"; - sq_pop(v, 1); - m_message = msg.str(); -} - -/* EOF */ diff --git a/rte/src/squirrel/squirrel_error.hpp b/rte/src/squirrel/squirrel_error.hpp deleted file mode 100644 index 6621642e..00000000 --- a/rte/src/squirrel/squirrel_error.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// SuperTux -// Copyright (C) 2006 Matthias Braun -// 2023 Vankata453 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#ifndef HEADER_BRUX_SQUIRREL_SQUIRREL_ERROR_HPP -#define HEADER_BRUX_SQUIRREL_SQUIRREL_ERROR_HPP - -#include - -#include -#include - -/** Exception class for squirrel errors, it takes a HSQUIRRELVM and uses - * sq_geterror() to retrieve additional information about the last error that - * has occurred and creates a readable message from that. - */ -class SquirrelError final : public std::exception -{ -private: - std::string m_message; - -public: - SquirrelError(HSQUIRRELVM v, const std::string& message) throw(); - - const char* what() const throw() { return m_message.c_str(); } -}; - -#endif - -/* EOF */ diff --git a/rte/src/squirrel/wrapper.cpp b/rte/src/squirrel/wrapper.cpp deleted file mode 100644 index c49663de..00000000 --- a/rte/src/squirrel/wrapper.cpp +++ /dev/null @@ -1,5285 +0,0 @@ -/** - * WARNING: This file is automatically generated from: - * 'src/api/api.hpp' - * DO NOT CHANGE - */ - -#include "squirrel/wrapper.hpp" - -#include -#include -#include -#include - -#include "api/api.hpp" - -#include "squirrel/squirrel_error.hpp" - -namespace BruxAPI { -namespace Wrapper { - -static SQInteger loadSound_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::loadSound(arg0); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'loadSound'")); - return SQ_ERROR; - } - -} - -static SQInteger loadMusic_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::loadMusic(arg0); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'loadMusic'")); - return SQ_ERROR; - } - -} - -static SQInteger playSound_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::playSound(static_cast (arg0), static_cast (arg1)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'playSound'")); - return SQ_ERROR; - } - -} - -static SQInteger playSoundChannel_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::playSoundChannel(static_cast (arg0), static_cast (arg1), static_cast (arg2)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'playSoundChannel'")); - return SQ_ERROR; - } - -} - -static SQInteger playMusic_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::playMusic(static_cast (arg0), static_cast (arg1)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'playMusic'")); - return SQ_ERROR; - } - -} - -static SQInteger deleteSound_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::deleteSound(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'deleteSound'")); - return SQ_ERROR; - } - -} - -static SQInteger deleteMusic_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::deleteMusic(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'deleteMusic'")); - return SQ_ERROR; - } - -} - -static SQInteger stopSound_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::stopSound(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'stopSound'")); - return SQ_ERROR; - } - -} - -static SQInteger stopMusic_wrapper(HSQUIRRELVM vm) -{ - (void) vm; - - try { - BruxAPI::stopMusic(); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'stopMusic'")); - return SQ_ERROR; - } - -} - -static SQInteger stopChannel_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::stopChannel(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'stopChannel'")); - return SQ_ERROR; - } - -} - -static SQInteger checkSound_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - bool return_value = BruxAPI::checkSound(static_cast (arg0)); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'checkSound'")); - return SQ_ERROR; - } - -} - -static SQInteger checkMusic_wrapper(HSQUIRRELVM vm) -{ - - try { - bool return_value = BruxAPI::checkMusic(); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'checkMusic'")); - return SQ_ERROR; - } - -} - -static SQInteger setMaxChannels_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::setMaxChannels(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setMaxChannels'")); - return SQ_ERROR; - } - -} - -static SQInteger pauseMusic_wrapper(HSQUIRRELVM vm) -{ - (void) vm; - - try { - BruxAPI::pauseMusic(); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'pauseMusic'")); - return SQ_ERROR; - } - -} - -static SQInteger resumeMusic_wrapper(HSQUIRRELVM vm) -{ - (void) vm; - - try { - BruxAPI::resumeMusic(); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'resumeMusic'")); - return SQ_ERROR; - } - -} - -static SQInteger musicPaused_wrapper(HSQUIRRELVM vm) -{ - - try { - bool return_value = BruxAPI::musicPaused(); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'musicPaused'")); - return SQ_ERROR; - } - -} - -static SQInteger fadeMusic_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::fadeMusic(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'fadeMusic'")); - return SQ_ERROR; - } - -} - -static SQInteger setMusicVolume_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::setMusicVolume(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setMusicVolume'")); - return SQ_ERROR; - } - -} - -static SQInteger setSoundVolume_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::setSoundVolume(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setSoundVolume'")); - return SQ_ERROR; - } - -} - -static SQInteger getMusicVolume_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::getMusicVolume(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getMusicVolume'")); - return SQ_ERROR; - } - -} - -static SQInteger getSoundVolume_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::getSoundVolume(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getSoundVolume'")); - return SQ_ERROR; - } - -} - -static SQInteger getAudioDriver_wrapper(HSQUIRRELVM vm) -{ - - try { - const std::string& return_value = BruxAPI::getAudioDriver(); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getAudioDriver'")); - return SQ_ERROR; - } - -} - -static SQInteger isAudioAvailable_wrapper(HSQUIRRELVM vm) -{ - - try { - bool return_value = BruxAPI::isAudioAvailable(); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'isAudioAvailable'")); - return SQ_ERROR; - } - -} - -static SQInteger import_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::import(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'import'")); - return SQ_ERROR; - } - -} - -static SQInteger donut_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::donut(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'donut'")); - return SQ_ERROR; - } - -} - -static SQInteger require_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::require(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'require'")); - return SQ_ERROR; - } - -} - -static SQInteger dostr_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::dostr(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'dostr'")); - return SQ_ERROR; - } - -} - -static SQInteger mount_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - const SQChar* arg1; - if(SQ_FAILED(sq_getstring(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a string")); - return SQ_ERROR; - } - SQBool arg2; - if(SQ_FAILED(sq_getbool(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not a bool")); - return SQ_ERROR; - } - - try { - BruxAPI::mount(arg0, arg1, arg2 == SQTrue); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'mount'")); - return SQ_ERROR; - } - -} - -static SQInteger unmount_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::unmount(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'unmount'")); - return SQ_ERROR; - } - -} - -static SQInteger getdir_wrapper(HSQUIRRELVM vm) -{ - - try { - std::string return_value = BruxAPI::getdir(); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getdir'")); - return SQ_ERROR; - } - -} - -static SQInteger getWriteDir_wrapper(HSQUIRRELVM vm) -{ - - try { - std::string return_value = BruxAPI::getWriteDir(); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getWriteDir'")); - return SQ_ERROR; - } - -} - -static SQInteger getPrefDir_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - const SQChar* arg1; - if(SQ_FAILED(sq_getstring(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a string")); - return SQ_ERROR; - } - - try { - std::string return_value = BruxAPI::getPrefDir(arg0, arg1); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getPrefDir'")); - return SQ_ERROR; - } - -} - -static SQInteger setWriteDir_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::setWriteDir(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setWriteDir'")); - return SQ_ERROR; - } - -} - -static SQInteger createDir_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::createDir(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'createDir'")); - return SQ_ERROR; - } - -} - -static SQInteger fileRead_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - std::string return_value = BruxAPI::fileRead(arg0); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'fileRead'")); - return SQ_ERROR; - } - -} - -static SQInteger fileWrite_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - const SQChar* arg1; - if(SQ_FAILED(sq_getstring(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::fileWrite(arg0, arg1); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'fileWrite'")); - return SQ_ERROR; - } - -} - -static SQInteger fileAppend_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - const SQChar* arg1; - if(SQ_FAILED(sq_getstring(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::fileAppend(arg0, arg1); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'fileAppend'")); - return SQ_ERROR; - } - -} - -static SQInteger fileExists_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - bool return_value = BruxAPI::fileExists(arg0); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'fileExists'")); - return SQ_ERROR; - } - -} - -static SQInteger fileDelete_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::fileDelete(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'fileDelete'")); - return SQ_ERROR; - } - -} - -static SQInteger isdir_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - bool return_value = BruxAPI::isdir(arg0); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'isdir'")); - return SQ_ERROR; - } - -} - -static SQInteger lsdir_wrapper(HSQUIRRELVM vm) -{ - HSQUIRRELVM arg0 = vm; - const SQChar* arg1; - if(SQ_FAILED(sq_getstring(vm, 2, &arg1))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - SQInteger return_value = BruxAPI::lsdir(arg0, arg1); - - return return_value; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'lsdir'")); - return SQ_ERROR; - } - -} - -static SQInteger clearScreen_wrapper(HSQUIRRELVM vm) -{ - (void) vm; - - try { - BruxAPI::clearScreen(); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'clearScreen'")); - return SQ_ERROR; - } - -} - -static SQInteger setDrawTarget_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::setDrawTarget(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setDrawTarget'")); - return SQ_ERROR; - } - -} - -static SQInteger getDrawTarget_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::getDrawTarget(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getDrawTarget'")); - return SQ_ERROR; - } - -} - -static SQInteger resetDrawTarget_wrapper(HSQUIRRELVM vm) -{ - (void) vm; - - try { - BruxAPI::resetDrawTarget(); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'resetDrawTarget'")); - return SQ_ERROR; - } - -} - -static SQInteger drawImage_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::drawImage(static_cast (arg0), static_cast (arg1), static_cast (arg2)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawImage'")); - return SQ_ERROR; - } - -} - -static SQInteger drawImagePart_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - SQInteger arg4; - if(SQ_FAILED(sq_getinteger(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not an integer")); - return SQ_ERROR; - } - SQInteger arg5; - if(SQ_FAILED(sq_getinteger(vm, 7, &arg5))) { - sq_throwerror(vm, _SC("Argument 6 not an integer")); - return SQ_ERROR; - } - SQInteger arg6; - if(SQ_FAILED(sq_getinteger(vm, 8, &arg6))) { - sq_throwerror(vm, _SC("Argument 7 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::drawImagePart(static_cast (arg0), static_cast (arg1), static_cast (arg2), static_cast (arg3), static_cast (arg4), static_cast (arg5), static_cast (arg6)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawImagePart'")); - return SQ_ERROR; - } - -} - -static SQInteger drawImageEx_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQFloat arg3; - if(SQ_FAILED(sq_getfloat(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not a float")); - return SQ_ERROR; - } - SQInteger arg4; - if(SQ_FAILED(sq_getinteger(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not an integer")); - return SQ_ERROR; - } - SQInteger arg5; - if(SQ_FAILED(sq_getinteger(vm, 7, &arg5))) { - sq_throwerror(vm, _SC("Argument 6 not an integer")); - return SQ_ERROR; - } - SQInteger arg6; - if(SQ_FAILED(sq_getinteger(vm, 8, &arg6))) { - sq_throwerror(vm, _SC("Argument 7 not an integer")); - return SQ_ERROR; - } - SQInteger arg7; - if(SQ_FAILED(sq_getinteger(vm, 9, &arg7))) { - sq_throwerror(vm, _SC("Argument 8 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::drawImageEx(static_cast (arg0), static_cast (arg1), static_cast (arg2), arg3, static_cast (arg4), static_cast (arg5), static_cast (arg6), static_cast (arg7)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawImageEx'")); - return SQ_ERROR; - } - -} - -static SQInteger setDrawColor_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::setDrawColor(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setDrawColor'")); - return SQ_ERROR; - } - -} - -static SQInteger loadImage_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::loadImage(arg0); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'loadImage'")); - return SQ_ERROR; - } - -} - -static SQInteger loadImageKeyed_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::loadImageKeyed(arg0, static_cast (arg1)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'loadImageKeyed'")); - return SQ_ERROR; - } - -} - -static SQInteger setBackgroundColor_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::setBackgroundColor(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setBackgroundColor'")); - return SQ_ERROR; - } - -} - -static SQInteger setScaling_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - - try { - BruxAPI::setScaling(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setScaling'")); - return SQ_ERROR; - } - -} - -static SQInteger setScalingFilter_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::setScalingFilter(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setScalingFilter'")); - return SQ_ERROR; - } - -} - -static SQInteger setResolution_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::setResolution(static_cast (arg0), static_cast (arg1)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setResolution'")); - return SQ_ERROR; - } - -} - -static SQInteger screenW_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::screenW(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'screenW'")); - return SQ_ERROR; - } - -} - -static SQInteger screenH_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::screenH(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'screenH'")); - return SQ_ERROR; - } - -} - -static SQInteger windowW_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::windowW(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'windowW'")); - return SQ_ERROR; - } - -} - -static SQInteger windowH_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::windowH(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'windowH'")); - return SQ_ERROR; - } - -} - -static SQInteger newTexture_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::newTexture(static_cast (arg0), static_cast (arg1)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'newTexture'")); - return SQ_ERROR; - } - -} - -static SQInteger textureSetBlendMode_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::textureSetBlendMode(static_cast (arg0), static_cast (arg1)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'textureSetBlendMode'")); - return SQ_ERROR; - } - -} - -static SQInteger findTexture_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::findTexture(arg0); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'findTexture'")); - return SQ_ERROR; - } - -} - -static SQInteger deleteTexture_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::deleteTexture(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'deleteTexture'")); - return SQ_ERROR; - } - -} - -static SQInteger getTextureName_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - std::string return_value = BruxAPI::getTextureName(static_cast (arg0)); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getTextureName'")); - return SQ_ERROR; - } - -} - -static SQInteger getTextureFilter_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::getTextureFilter(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getTextureFilter'")); - return SQ_ERROR; - } - -} - -static SQInteger setTextureFilter_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::setTextureFilter(static_cast (arg0), static_cast (arg1)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setTextureFilter'")); - return SQ_ERROR; - } - -} - -static SQInteger printTextureNames_wrapper(HSQUIRRELVM vm) -{ - (void) vm; - - try { - BruxAPI::printTextureNames(); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'printTextureNames'")); - return SQ_ERROR; - } - -} - -static SQInteger keyPress_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::keyPress(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'keyPress'")); - return SQ_ERROR; - } - -} - -static SQInteger keyDown_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::keyDown(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'keyDown'")); - return SQ_ERROR; - } - -} - -static SQInteger keyRelease_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::keyRelease(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'keyRelease'")); - return SQ_ERROR; - } - -} - -static SQInteger keyPressAny_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::keyPressAny(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'keyPressAny'")); - return SQ_ERROR; - } - -} - -static SQInteger mouseDown_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::mouseDown(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'mouseDown'")); - return SQ_ERROR; - } - -} - -static SQInteger mousePress_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::mousePress(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'mousePress'")); - return SQ_ERROR; - } - -} - -static SQInteger mouseRelease_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::mouseRelease(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'mouseRelease'")); - return SQ_ERROR; - } - -} - -static SQInteger mouseX_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::mouseX(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'mouseX'")); - return SQ_ERROR; - } - -} - -static SQInteger mouseY_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::mouseY(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'mouseY'")); - return SQ_ERROR; - } - -} - -static SQInteger getQuit_wrapper(HSQUIRRELVM vm) -{ - - try { - bool return_value = BruxAPI::getQuit(); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getQuit'")); - return SQ_ERROR; - } - -} - -static SQInteger quitGame_wrapper(HSQUIRRELVM vm) -{ - (void) vm; - - try { - BruxAPI::quitGame(); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'quitGame'")); - return SQ_ERROR; - } - -} - -static SQInteger joyCount_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::joyCount(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyCount'")); - return SQ_ERROR; - } - -} - -static SQInteger joyName_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - std::string return_value = BruxAPI::joyName(static_cast (arg0)); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyName'")); - return SQ_ERROR; - } - -} - -static SQInteger joyX_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyX(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyX'")); - return SQ_ERROR; - } - -} - -static SQInteger joyY_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyY(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyY'")); - return SQ_ERROR; - } - -} - -static SQInteger joyZ_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyZ(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyZ'")); - return SQ_ERROR; - } - -} - -static SQInteger joyH_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyH(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyH'")); - return SQ_ERROR; - } - -} - -static SQInteger joyV_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyV(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyV'")); - return SQ_ERROR; - } - -} - -static SQInteger joyR_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyR(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyR'")); - return SQ_ERROR; - } - -} - -static SQInteger joyL_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyL(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyL'")); - return SQ_ERROR; - } - -} - -static SQInteger joyAxis_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyAxis(static_cast (arg0), static_cast (arg1)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyAxis'")); - return SQ_ERROR; - } - -} - -static SQInteger joyHatDown_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - bool return_value = BruxAPI::joyHatDown(static_cast (arg0), static_cast (arg1)); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyHatDown'")); - return SQ_ERROR; - } - -} - -static SQInteger joyHatPress_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - bool return_value = BruxAPI::joyHatPress(static_cast (arg0), static_cast (arg1)); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyHatPress'")); - return SQ_ERROR; - } - -} - -static SQInteger joyHatRelease_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - bool return_value = BruxAPI::joyHatRelease(static_cast (arg0), static_cast (arg1)); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyHatRelease'")); - return SQ_ERROR; - } - -} - -static SQInteger joyButtonPress_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyButtonPress(static_cast (arg0), static_cast (arg1)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyButtonPress'")); - return SQ_ERROR; - } - -} - -static SQInteger joyButtonDown_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyButtonDown(static_cast (arg0), static_cast (arg1)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyButtonDown'")); - return SQ_ERROR; - } - -} - -static SQInteger joyButtonRelease_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyButtonRelease(static_cast (arg0), static_cast (arg1)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyButtonRelease'")); - return SQ_ERROR; - } - -} - -static SQInteger joyPressAny_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyPressAny(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyPressAny'")); - return SQ_ERROR; - } - -} - -static SQInteger joyAxisPress_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyAxisPress(static_cast (arg0), static_cast (arg1), static_cast (arg2)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyAxisPress'")); - return SQ_ERROR; - } - -} - -static SQInteger joyAxisRelease_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::joyAxisRelease(static_cast (arg0), static_cast (arg1), static_cast (arg2)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'joyAxisRelease'")); - return SQ_ERROR; - } - -} - -static SQInteger keyString_wrapper(HSQUIRRELVM vm) -{ - - try { - std::string return_value = BruxAPI::keyString(); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'keyString'")); - return SQ_ERROR; - } - -} - -static SQInteger mouseWheelX_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::mouseWheelX(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'mouseWheelX'")); - return SQ_ERROR; - } - -} - -static SQInteger mouseWheelY_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::mouseWheelY(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'mouseWheelY'")); - return SQ_ERROR; - } - -} - -static SQInteger jsonRead_wrapper(HSQUIRRELVM vm) -{ - HSQUIRRELVM arg0 = vm; - const SQChar* arg1; - if(SQ_FAILED(sq_getstring(vm, 2, &arg1))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - SQInteger return_value = BruxAPI::jsonRead(arg0, arg1); - - return return_value; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'jsonRead'")); - return SQ_ERROR; - } - -} - -static SQInteger wait_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::wait(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'wait'")); - return SQ_ERROR; - } - -} - -static SQInteger update_wrapper(HSQUIRRELVM vm) -{ - (void) vm; - - try { - BruxAPI::update(); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'update'")); - return SQ_ERROR; - } - -} - -static SQInteger getOS_wrapper(HSQUIRRELVM vm) -{ - - try { - std::string return_value = BruxAPI::getOS(); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getOS'")); - return SQ_ERROR; - } - -} - -static SQInteger getTicks_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::getTicks(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getTicks'")); - return SQ_ERROR; - } - -} - -static SQInteger getFPS_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::getFPS(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getFPS'")); - return SQ_ERROR; - } - -} - -static SQInteger setFPS_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::setFPS(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setFPS'")); - return SQ_ERROR; - } - -} - -static SQInteger setWindowTitle_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::setWindowTitle(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setWindowTitle'")); - return SQ_ERROR; - } - -} - -static SQInteger setWindowIcon_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::setWindowIcon(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'setWindowIcon'")); - return SQ_ERROR; - } - -} - -static SQInteger getFrames_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::getFrames(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'getFrames'")); - return SQ_ERROR; - } - -} - -static SQInteger displayW_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::displayW(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'displayW'")); - return SQ_ERROR; - } - -} - -static SQInteger displayH_wrapper(HSQUIRRELVM vm) -{ - - try { - int return_value = BruxAPI::displayH(); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'displayH'")); - return SQ_ERROR; - } - -} - -static SQInteger bruxVersion_wrapper(HSQUIRRELVM vm) -{ - - try { - std::string return_value = BruxAPI::bruxVersion(); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'bruxVersion'")); - return SQ_ERROR; - } - -} - -static SQInteger toggleFullscreen_wrapper(HSQUIRRELVM vm) -{ - (void) vm; - - try { - BruxAPI::toggleFullscreen(); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'toggleFullscreen'")); - return SQ_ERROR; - } - -} - -static SQInteger randFloat_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - - try { - float return_value = BruxAPI::randFloat(arg0); - - sq_pushfloat(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'randFloat'")); - return SQ_ERROR; - } - -} - -static SQInteger randInt_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::randInt(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'randInt'")); - return SQ_ERROR; - } - -} - -static SQInteger distance2_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - SQFloat arg1; - if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a float")); - return SQ_ERROR; - } - SQFloat arg2; - if(SQ_FAILED(sq_getfloat(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not a float")); - return SQ_ERROR; - } - SQFloat arg3; - if(SQ_FAILED(sq_getfloat(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not a float")); - return SQ_ERROR; - } - - try { - float return_value = BruxAPI::distance2(arg0, arg1, arg2, arg3); - - sq_pushfloat(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'distance2'")); - return SQ_ERROR; - } - -} - -static SQInteger inDistance2_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - SQFloat arg1; - if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a float")); - return SQ_ERROR; - } - SQFloat arg2; - if(SQ_FAILED(sq_getfloat(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not a float")); - return SQ_ERROR; - } - SQFloat arg3; - if(SQ_FAILED(sq_getfloat(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not a float")); - return SQ_ERROR; - } - SQFloat arg4; - if(SQ_FAILED(sq_getfloat(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not a float")); - return SQ_ERROR; - } - - try { - bool return_value = BruxAPI::inDistance2(arg0, arg1, arg2, arg3, arg4); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'inDistance2'")); - return SQ_ERROR; - } - -} - -static SQInteger distance3_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - SQFloat arg1; - if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a float")); - return SQ_ERROR; - } - SQFloat arg2; - if(SQ_FAILED(sq_getfloat(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not a float")); - return SQ_ERROR; - } - SQFloat arg3; - if(SQ_FAILED(sq_getfloat(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not a float")); - return SQ_ERROR; - } - SQFloat arg4; - if(SQ_FAILED(sq_getfloat(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not a float")); - return SQ_ERROR; - } - SQFloat arg5; - if(SQ_FAILED(sq_getfloat(vm, 7, &arg5))) { - sq_throwerror(vm, _SC("Argument 6 not a float")); - return SQ_ERROR; - } - - try { - float return_value = BruxAPI::distance3(arg0, arg1, arg2, arg3, arg4, arg5); - - sq_pushfloat(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'distance3'")); - return SQ_ERROR; - } - -} - -static SQInteger wrap_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - SQFloat arg1; - if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a float")); - return SQ_ERROR; - } - SQFloat arg2; - if(SQ_FAILED(sq_getfloat(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not a float")); - return SQ_ERROR; - } - - try { - float return_value = BruxAPI::wrap(arg0, arg1, arg2); - - sq_pushfloat(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'wrap'")); - return SQ_ERROR; - } - -} - -static SQInteger floor_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::floor(arg0); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'floor'")); - return SQ_ERROR; - } - -} - -static SQInteger ceil_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::ceil(arg0); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'ceil'")); - return SQ_ERROR; - } - -} - -static SQInteger round_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::round(arg0); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'round'")); - return SQ_ERROR; - } - -} - -static SQInteger pointAngle_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - SQFloat arg1; - if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a float")); - return SQ_ERROR; - } - SQFloat arg2; - if(SQ_FAILED(sq_getfloat(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not a float")); - return SQ_ERROR; - } - SQFloat arg3; - if(SQ_FAILED(sq_getfloat(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not a float")); - return SQ_ERROR; - } - - try { - float return_value = BruxAPI::pointAngle(arg0, arg1, arg2, arg3); - - sq_pushfloat(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'pointAngle'")); - return SQ_ERROR; - } - -} - -static SQInteger abs_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - - try { - float return_value = BruxAPI::abs(arg0); - - sq_pushfloat(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'abs'")); - return SQ_ERROR; - } - -} - -static SQInteger lendirX_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - SQFloat arg1; - if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a float")); - return SQ_ERROR; - } - - try { - float return_value = BruxAPI::lendirX(arg0, arg1); - - sq_pushfloat(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'lendirX'")); - return SQ_ERROR; - } - -} - -static SQInteger lendirY_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - SQFloat arg1; - if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a float")); - return SQ_ERROR; - } - - try { - float return_value = BruxAPI::lendirY(arg0, arg1); - - sq_pushfloat(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'lendirY'")); - return SQ_ERROR; - } - -} - -static SQInteger binstr_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - std::string return_value = BruxAPI::binstr(static_cast (arg0)); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'binstr'")); - return SQ_ERROR; - } - -} - -static SQInteger drawCircle_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQBool arg3; - if(SQ_FAILED(sq_getbool(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not a bool")); - return SQ_ERROR; - } - - try { - BruxAPI::drawCircle(static_cast (arg0), static_cast (arg1), static_cast (arg2), arg3 == SQTrue); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawCircle'")); - return SQ_ERROR; - } - -} - -static SQInteger drawRec_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - SQBool arg4; - if(SQ_FAILED(sq_getbool(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not a bool")); - return SQ_ERROR; - } - - try { - BruxAPI::drawRec(static_cast (arg0), static_cast (arg1), static_cast (arg2), static_cast (arg3), arg4 == SQTrue); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawRec'")); - return SQ_ERROR; - } - -} - -static SQInteger drawRect_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - SQBool arg4; - if(SQ_FAILED(sq_getbool(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not a bool")); - return SQ_ERROR; - } - - try { - BruxAPI::drawRect(static_cast (arg0), static_cast (arg1), static_cast (arg2), static_cast (arg3), arg4 == SQTrue); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawRect'")); - return SQ_ERROR; - } - -} - -static SQInteger drawPoint_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::drawPoint(static_cast (arg0), static_cast (arg1)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawPoint'")); - return SQ_ERROR; - } - -} - -static SQInteger drawLine_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::drawLine(static_cast (arg0), static_cast (arg1), static_cast (arg2), static_cast (arg3)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawLine'")); - return SQ_ERROR; - } - -} - -static SQInteger drawLineWide_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - SQInteger arg4; - if(SQ_FAILED(sq_getinteger(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::drawLineWide(static_cast (arg0), static_cast (arg1), static_cast (arg2), static_cast (arg3), static_cast (arg4)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawLineWide'")); - return SQ_ERROR; - } - -} - -static SQInteger hitLineLine_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - SQFloat arg1; - if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a float")); - return SQ_ERROR; - } - SQFloat arg2; - if(SQ_FAILED(sq_getfloat(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not a float")); - return SQ_ERROR; - } - SQFloat arg3; - if(SQ_FAILED(sq_getfloat(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not a float")); - return SQ_ERROR; - } - SQFloat arg4; - if(SQ_FAILED(sq_getfloat(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not a float")); - return SQ_ERROR; - } - SQFloat arg5; - if(SQ_FAILED(sq_getfloat(vm, 7, &arg5))) { - sq_throwerror(vm, _SC("Argument 6 not a float")); - return SQ_ERROR; - } - SQFloat arg6; - if(SQ_FAILED(sq_getfloat(vm, 8, &arg6))) { - sq_throwerror(vm, _SC("Argument 7 not a float")); - return SQ_ERROR; - } - SQFloat arg7; - if(SQ_FAILED(sq_getfloat(vm, 9, &arg7))) { - sq_throwerror(vm, _SC("Argument 8 not a float")); - return SQ_ERROR; - } - - try { - bool return_value = BruxAPI::hitLineLine(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'hitLineLine'")); - return SQ_ERROR; - } - -} - -static SQInteger hitLineCircle_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - SQFloat arg1; - if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a float")); - return SQ_ERROR; - } - SQFloat arg2; - if(SQ_FAILED(sq_getfloat(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not a float")); - return SQ_ERROR; - } - SQFloat arg3; - if(SQ_FAILED(sq_getfloat(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not a float")); - return SQ_ERROR; - } - SQFloat arg4; - if(SQ_FAILED(sq_getfloat(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not a float")); - return SQ_ERROR; - } - SQFloat arg5; - if(SQ_FAILED(sq_getfloat(vm, 7, &arg5))) { - sq_throwerror(vm, _SC("Argument 6 not a float")); - return SQ_ERROR; - } - SQFloat arg6; - if(SQ_FAILED(sq_getfloat(vm, 8, &arg6))) { - sq_throwerror(vm, _SC("Argument 7 not a float")); - return SQ_ERROR; - } - - try { - bool return_value = BruxAPI::hitLineCircle(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'hitLineCircle'")); - return SQ_ERROR; - } - -} - -static SQInteger hitLinePoint_wrapper(HSQUIRRELVM vm) -{ - SQFloat arg0; - if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a float")); - return SQ_ERROR; - } - SQFloat arg1; - if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a float")); - return SQ_ERROR; - } - SQFloat arg2; - if(SQ_FAILED(sq_getfloat(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not a float")); - return SQ_ERROR; - } - SQFloat arg3; - if(SQ_FAILED(sq_getfloat(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not a float")); - return SQ_ERROR; - } - SQFloat arg4; - if(SQ_FAILED(sq_getfloat(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not a float")); - return SQ_ERROR; - } - SQFloat arg5; - if(SQ_FAILED(sq_getfloat(vm, 7, &arg5))) { - sq_throwerror(vm, _SC("Argument 6 not a float")); - return SQ_ERROR; - } - - try { - bool return_value = BruxAPI::hitLinePoint(arg0, arg1, arg2, arg3, arg4, arg5); - - sq_pushbool(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'hitLinePoint'")); - return SQ_ERROR; - } - -} - -static SQInteger spriteName_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - std::string return_value = BruxAPI::spriteName(static_cast (arg0)); - - assert(return_value.size() < static_cast(std::numeric_limits::max())); - sq_pushstring(vm, return_value.c_str(), static_cast(return_value.size())); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'spriteName'")); - return SQ_ERROR; - } - -} - -static SQInteger findSprite_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::findSprite(arg0); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'findSprite'")); - return SQ_ERROR; - } - -} - -static SQInteger newSprite_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - SQInteger arg4; - if(SQ_FAILED(sq_getinteger(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not an integer")); - return SQ_ERROR; - } - SQFloat arg5; - if(SQ_FAILED(sq_getfloat(vm, 7, &arg5))) { - sq_throwerror(vm, _SC("Argument 6 not a float")); - return SQ_ERROR; - } - SQFloat arg6; - if(SQ_FAILED(sq_getfloat(vm, 8, &arg6))) { - sq_throwerror(vm, _SC("Argument 7 not a float")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::newSprite(arg0, static_cast (arg1), static_cast (arg2), static_cast (arg3), static_cast (arg4), arg5, arg6); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'newSprite'")); - return SQ_ERROR; - } - -} - -static SQInteger newSpriteFT_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - SQInteger arg4; - if(SQ_FAILED(sq_getinteger(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not an integer")); - return SQ_ERROR; - } - SQFloat arg5; - if(SQ_FAILED(sq_getfloat(vm, 7, &arg5))) { - sq_throwerror(vm, _SC("Argument 6 not a float")); - return SQ_ERROR; - } - SQFloat arg6; - if(SQ_FAILED(sq_getfloat(vm, 8, &arg6))) { - sq_throwerror(vm, _SC("Argument 7 not a float")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::newSpriteFT(static_cast (arg0), static_cast (arg1), static_cast (arg2), static_cast (arg3), static_cast (arg4), arg5, arg6); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'newSpriteFT'")); - return SQ_ERROR; - } - -} - -static SQInteger drawSprite_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::drawSprite(static_cast (arg0), static_cast (arg1), static_cast (arg2), static_cast (arg3)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawSprite'")); - return SQ_ERROR; - } - -} - -static SQInteger drawSpriteEx_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - SQInteger arg4; - if(SQ_FAILED(sq_getinteger(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not an integer")); - return SQ_ERROR; - } - SQInteger arg5; - if(SQ_FAILED(sq_getinteger(vm, 7, &arg5))) { - sq_throwerror(vm, _SC("Argument 6 not an integer")); - return SQ_ERROR; - } - SQFloat arg6; - if(SQ_FAILED(sq_getfloat(vm, 8, &arg6))) { - sq_throwerror(vm, _SC("Argument 7 not a float")); - return SQ_ERROR; - } - SQFloat arg7; - if(SQ_FAILED(sq_getfloat(vm, 9, &arg7))) { - sq_throwerror(vm, _SC("Argument 8 not a float")); - return SQ_ERROR; - } - SQFloat arg8; - if(SQ_FAILED(sq_getfloat(vm, 10, &arg8))) { - sq_throwerror(vm, _SC("Argument 9 not a float")); - return SQ_ERROR; - } - - try { - BruxAPI::drawSpriteEx(static_cast (arg0), static_cast (arg1), static_cast (arg2), static_cast (arg3), static_cast (arg4), static_cast (arg5), arg6, arg7, arg8); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawSpriteEx'")); - return SQ_ERROR; - } - -} - -static SQInteger drawSpriteMod_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - SQInteger arg4; - if(SQ_FAILED(sq_getinteger(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::drawSpriteMod(static_cast (arg0), static_cast (arg1), static_cast (arg2), static_cast (arg3), static_cast (arg4)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawSpriteMod'")); - return SQ_ERROR; - } - -} - -static SQInteger drawSpriteExMod_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - SQInteger arg4; - if(SQ_FAILED(sq_getinteger(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not an integer")); - return SQ_ERROR; - } - SQInteger arg5; - if(SQ_FAILED(sq_getinteger(vm, 7, &arg5))) { - sq_throwerror(vm, _SC("Argument 6 not an integer")); - return SQ_ERROR; - } - SQFloat arg6; - if(SQ_FAILED(sq_getfloat(vm, 8, &arg6))) { - sq_throwerror(vm, _SC("Argument 7 not a float")); - return SQ_ERROR; - } - SQFloat arg7; - if(SQ_FAILED(sq_getfloat(vm, 9, &arg7))) { - sq_throwerror(vm, _SC("Argument 8 not a float")); - return SQ_ERROR; - } - SQFloat arg8; - if(SQ_FAILED(sq_getfloat(vm, 10, &arg8))) { - sq_throwerror(vm, _SC("Argument 9 not a float")); - return SQ_ERROR; - } - SQInteger arg9; - if(SQ_FAILED(sq_getinteger(vm, 11, &arg9))) { - sq_throwerror(vm, _SC("Argument 10 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::drawSpriteExMod(static_cast (arg0), static_cast (arg1), static_cast (arg2), static_cast (arg3), static_cast (arg4), static_cast (arg5), arg6, arg7, arg8, static_cast (arg9)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawSpriteExMod'")); - return SQ_ERROR; - } - -} - -static SQInteger deleteSprite_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::deleteSprite(static_cast (arg0)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'deleteSprite'")); - return SQ_ERROR; - } - -} - -static SQInteger spriteW_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::spriteW(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'spriteW'")); - return SQ_ERROR; - } - -} - -static SQInteger spriteH_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::spriteH(static_cast (arg0)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'spriteH'")); - return SQ_ERROR; - } - -} - -static SQInteger replaceSprite_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - const SQChar* arg1; - if(SQ_FAILED(sq_getstring(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a string")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQInteger arg3; - if(SQ_FAILED(sq_getinteger(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not an integer")); - return SQ_ERROR; - } - SQInteger arg4; - if(SQ_FAILED(sq_getinteger(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not an integer")); - return SQ_ERROR; - } - SQInteger arg5; - if(SQ_FAILED(sq_getinteger(vm, 7, &arg5))) { - sq_throwerror(vm, _SC("Argument 6 not an integer")); - return SQ_ERROR; - } - SQFloat arg6; - if(SQ_FAILED(sq_getfloat(vm, 8, &arg6))) { - sq_throwerror(vm, _SC("Argument 7 not a float")); - return SQ_ERROR; - } - SQFloat arg7; - if(SQ_FAILED(sq_getfloat(vm, 9, &arg7))) { - sq_throwerror(vm, _SC("Argument 8 not a float")); - return SQ_ERROR; - } - - try { - BruxAPI::replaceSprite(static_cast (arg0), arg1, static_cast (arg2), static_cast (arg3), static_cast (arg4), static_cast (arg5), arg6, arg7); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'replaceSprite'")); - return SQ_ERROR; - } - -} - -static SQInteger spriteSetBlendMode_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - - try { - BruxAPI::spriteSetBlendMode(static_cast (arg0), static_cast (arg1)); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'spriteSetBlendMode'")); - return SQ_ERROR; - } - -} - -static SQInteger newFont_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not an integer")); - return SQ_ERROR; - } - SQInteger arg2; - if(SQ_FAILED(sq_getinteger(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not an integer")); - return SQ_ERROR; - } - SQBool arg3; - if(SQ_FAILED(sq_getbool(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not a bool")); - return SQ_ERROR; - } - SQInteger arg4; - if(SQ_FAILED(sq_getinteger(vm, 6, &arg4))) { - sq_throwerror(vm, _SC("Argument 5 not an integer")); - return SQ_ERROR; - } - - try { - int return_value = BruxAPI::newFont(static_cast (arg0), static_cast (arg1), static_cast (arg2), arg3 == SQTrue, static_cast (arg4)); - - sq_pushinteger(vm, return_value); - return 1; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'newFont'")); - return SQ_ERROR; - } - -} - -static SQInteger drawText_wrapper(HSQUIRRELVM vm) -{ - SQInteger arg0; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - SQFloat arg1; - if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) { - sq_throwerror(vm, _SC("Argument 2 not a float")); - return SQ_ERROR; - } - SQFloat arg2; - if(SQ_FAILED(sq_getfloat(vm, 4, &arg2))) { - sq_throwerror(vm, _SC("Argument 3 not a float")); - return SQ_ERROR; - } - const SQChar* arg3; - if(SQ_FAILED(sq_getstring(vm, 5, &arg3))) { - sq_throwerror(vm, _SC("Argument 4 not a string")); - return SQ_ERROR; - } - - try { - BruxAPI::drawText(static_cast (arg0), arg1, arg2, arg3); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'drawText'")); - return SQ_ERROR; - } - -} - -static SQInteger chint_wrapper(HSQUIRRELVM vm) -{ - HSQUIRRELVM arg0 = vm; - SQInteger arg1; - if(SQ_FAILED(sq_getinteger(vm, 2, &arg1))) { - sq_throwerror(vm, _SC("Argument 1 not an integer")); - return SQ_ERROR; - } - - try { - SQInteger return_value = BruxAPI::chint(arg0, static_cast (arg1)); - - return return_value; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'chint'")); - return SQ_ERROR; - } - -} - -} // namespace wrapper -void register_brux_wrapper(HSQUIRRELVM v) -{ - using namespace Wrapper; - - sq_pushstring(v, "loadSound", -1); - sq_newclosure(v, &loadSound_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'loadSound'"); - } - - sq_pushstring(v, "loadMusic", -1); - sq_newclosure(v, &loadMusic_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'loadMusic'"); - } - - sq_pushstring(v, "playSound", -1); - sq_newclosure(v, &playSound_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'playSound'"); - } - - sq_pushstring(v, "playSoundChannel", -1); - sq_newclosure(v, &playSoundChannel_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'playSoundChannel'"); - } - - sq_pushstring(v, "playMusic", -1); - sq_newclosure(v, &playMusic_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'playMusic'"); - } - - sq_pushstring(v, "deleteSound", -1); - sq_newclosure(v, &deleteSound_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'deleteSound'"); - } - - sq_pushstring(v, "deleteMusic", -1); - sq_newclosure(v, &deleteMusic_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'deleteMusic'"); - } - - sq_pushstring(v, "stopSound", -1); - sq_newclosure(v, &stopSound_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'stopSound'"); - } - - sq_pushstring(v, "stopMusic", -1); - sq_newclosure(v, &stopMusic_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'stopMusic'"); - } - - sq_pushstring(v, "stopChannel", -1); - sq_newclosure(v, &stopChannel_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'stopChannel'"); - } - - sq_pushstring(v, "checkSound", -1); - sq_newclosure(v, &checkSound_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'checkSound'"); - } - - sq_pushstring(v, "checkMusic", -1); - sq_newclosure(v, &checkMusic_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'checkMusic'"); - } - - sq_pushstring(v, "setMaxChannels", -1); - sq_newclosure(v, &setMaxChannels_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setMaxChannels'"); - } - - sq_pushstring(v, "pauseMusic", -1); - sq_newclosure(v, &pauseMusic_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'pauseMusic'"); - } - - sq_pushstring(v, "resumeMusic", -1); - sq_newclosure(v, &resumeMusic_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'resumeMusic'"); - } - - sq_pushstring(v, "musicPaused", -1); - sq_newclosure(v, &musicPaused_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'musicPaused'"); - } - - sq_pushstring(v, "fadeMusic", -1); - sq_newclosure(v, &fadeMusic_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'fadeMusic'"); - } - - sq_pushstring(v, "setMusicVolume", -1); - sq_newclosure(v, &setMusicVolume_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setMusicVolume'"); - } - - sq_pushstring(v, "setSoundVolume", -1); - sq_newclosure(v, &setSoundVolume_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setSoundVolume'"); - } - - sq_pushstring(v, "getMusicVolume", -1); - sq_newclosure(v, &getMusicVolume_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getMusicVolume'"); - } - - sq_pushstring(v, "getSoundVolume", -1); - sq_newclosure(v, &getSoundVolume_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getSoundVolume'"); - } - - sq_pushstring(v, "getAudioDriver", -1); - sq_newclosure(v, &getAudioDriver_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getAudioDriver'"); - } - - sq_pushstring(v, "isAudioAvailable", -1); - sq_newclosure(v, &isAudioAvailable_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'isAudioAvailable'"); - } - - sq_pushstring(v, "import", -1); - sq_newclosure(v, &import_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'import'"); - } - - sq_pushstring(v, "donut", -1); - sq_newclosure(v, &donut_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'donut'"); - } - - sq_pushstring(v, "require", -1); - sq_newclosure(v, &require_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'require'"); - } - - sq_pushstring(v, "dostr", -1); - sq_newclosure(v, &dostr_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'dostr'"); - } - - sq_pushstring(v, "mount", -1); - sq_newclosure(v, &mount_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".ssb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'mount'"); - } - - sq_pushstring(v, "unmount", -1); - sq_newclosure(v, &unmount_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'unmount'"); - } - - sq_pushstring(v, "getdir", -1); - sq_newclosure(v, &getdir_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getdir'"); - } - - sq_pushstring(v, "getWriteDir", -1); - sq_newclosure(v, &getWriteDir_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getWriteDir'"); - } - - sq_pushstring(v, "getPrefDir", -1); - sq_newclosure(v, &getPrefDir_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".ss"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getPrefDir'"); - } - - sq_pushstring(v, "setWriteDir", -1); - sq_newclosure(v, &setWriteDir_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setWriteDir'"); - } - - sq_pushstring(v, "createDir", -1); - sq_newclosure(v, &createDir_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'createDir'"); - } - - sq_pushstring(v, "fileRead", -1); - sq_newclosure(v, &fileRead_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'fileRead'"); - } - - sq_pushstring(v, "fileWrite", -1); - sq_newclosure(v, &fileWrite_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".ss"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'fileWrite'"); - } - - sq_pushstring(v, "fileAppend", -1); - sq_newclosure(v, &fileAppend_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".ss"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'fileAppend'"); - } - - sq_pushstring(v, "fileExists", -1); - sq_newclosure(v, &fileExists_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'fileExists'"); - } - - sq_pushstring(v, "fileDelete", -1); - sq_newclosure(v, &fileDelete_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'fileDelete'"); - } - - sq_pushstring(v, "isdir", -1); - sq_newclosure(v, &isdir_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'isdir'"); - } - - sq_pushstring(v, "lsdir", -1); - sq_newclosure(v, &lsdir_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'lsdir'"); - } - - sq_pushstring(v, "clearScreen", -1); - sq_newclosure(v, &clearScreen_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'clearScreen'"); - } - - sq_pushstring(v, "setDrawTarget", -1); - sq_newclosure(v, &setDrawTarget_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setDrawTarget'"); - } - - sq_pushstring(v, "getDrawTarget", -1); - sq_newclosure(v, &getDrawTarget_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getDrawTarget'"); - } - - sq_pushstring(v, "resetDrawTarget", -1); - sq_newclosure(v, &resetDrawTarget_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'resetDrawTarget'"); - } - - sq_pushstring(v, "drawImage", -1); - sq_newclosure(v, &drawImage_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawImage'"); - } - - sq_pushstring(v, "drawImagePart", -1); - sq_newclosure(v, &drawImagePart_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawImagePart'"); - } - - sq_pushstring(v, "drawImageEx", -1); - sq_newclosure(v, &drawImageEx_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawImageEx'"); - } - - sq_pushstring(v, "setDrawColor", -1); - sq_newclosure(v, &setDrawColor_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setDrawColor'"); - } - - sq_pushstring(v, "loadImage", -1); - sq_newclosure(v, &loadImage_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'loadImage'"); - } - - sq_pushstring(v, "loadImageKeyed", -1); - sq_newclosure(v, &loadImageKeyed_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".sb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'loadImageKeyed'"); - } - - sq_pushstring(v, "setBackgroundColor", -1); - sq_newclosure(v, &setBackgroundColor_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setBackgroundColor'"); - } - - sq_pushstring(v, "setScaling", -1); - sq_newclosure(v, &setScaling_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setScaling'"); - } - - sq_pushstring(v, "setScalingFilter", -1); - sq_newclosure(v, &setScalingFilter_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setScalingFilter'"); - } - - sq_pushstring(v, "setResolution", -1); - sq_newclosure(v, &setResolution_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setResolution'"); - } - - sq_pushstring(v, "screenW", -1); - sq_newclosure(v, &screenW_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'screenW'"); - } - - sq_pushstring(v, "screenH", -1); - sq_newclosure(v, &screenH_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'screenH'"); - } - - sq_pushstring(v, "windowW", -1); - sq_newclosure(v, &windowW_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'windowW'"); - } - - sq_pushstring(v, "windowH", -1); - sq_newclosure(v, &windowH_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'windowH'"); - } - - sq_pushstring(v, "newTexture", -1); - sq_newclosure(v, &newTexture_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'newTexture'"); - } - - sq_pushstring(v, "textureSetBlendMode", -1); - sq_newclosure(v, &textureSetBlendMode_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'textureSetBlendMode'"); - } - - sq_pushstring(v, "findTexture", -1); - sq_newclosure(v, &findTexture_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'findTexture'"); - } - - sq_pushstring(v, "deleteTexture", -1); - sq_newclosure(v, &deleteTexture_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'deleteTexture'"); - } - - sq_pushstring(v, "getTextureName", -1); - sq_newclosure(v, &getTextureName_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getTextureName'"); - } - - sq_pushstring(v, "getTextureFilter", -1); - sq_newclosure(v, &getTextureFilter_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getTextureFilter'"); - } - - sq_pushstring(v, "setTextureFilter", -1); - sq_newclosure(v, &setTextureFilter_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setTextureFilter'"); - } - - sq_pushstring(v, "printTextureNames", -1); - sq_newclosure(v, &printTextureNames_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'printTextureNames'"); - } - - sq_pushstring(v, "keyPress", -1); - sq_newclosure(v, &keyPress_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'keyPress'"); - } - - sq_pushstring(v, "keyDown", -1); - sq_newclosure(v, &keyDown_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'keyDown'"); - } - - sq_pushstring(v, "keyRelease", -1); - sq_newclosure(v, &keyRelease_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'keyRelease'"); - } - - sq_pushstring(v, "keyPressAny", -1); - sq_newclosure(v, &keyPressAny_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'keyPressAny'"); - } - - sq_pushstring(v, "mouseDown", -1); - sq_newclosure(v, &mouseDown_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'mouseDown'"); - } - - sq_pushstring(v, "mousePress", -1); - sq_newclosure(v, &mousePress_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'mousePress'"); - } - - sq_pushstring(v, "mouseRelease", -1); - sq_newclosure(v, &mouseRelease_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'mouseRelease'"); - } - - sq_pushstring(v, "mouseX", -1); - sq_newclosure(v, &mouseX_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'mouseX'"); - } - - sq_pushstring(v, "mouseY", -1); - sq_newclosure(v, &mouseY_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'mouseY'"); - } - - sq_pushstring(v, "getQuit", -1); - sq_newclosure(v, &getQuit_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getQuit'"); - } - - sq_pushstring(v, "quitGame", -1); - sq_newclosure(v, &quitGame_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'quitGame'"); - } - - sq_pushstring(v, "joyCount", -1); - sq_newclosure(v, &joyCount_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyCount'"); - } - - sq_pushstring(v, "joyName", -1); - sq_newclosure(v, &joyName_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyName'"); - } - - sq_pushstring(v, "joyX", -1); - sq_newclosure(v, &joyX_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyX'"); - } - - sq_pushstring(v, "joyY", -1); - sq_newclosure(v, &joyY_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyY'"); - } - - sq_pushstring(v, "joyZ", -1); - sq_newclosure(v, &joyZ_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyZ'"); - } - - sq_pushstring(v, "joyH", -1); - sq_newclosure(v, &joyH_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyH'"); - } - - sq_pushstring(v, "joyV", -1); - sq_newclosure(v, &joyV_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyV'"); - } - - sq_pushstring(v, "joyR", -1); - sq_newclosure(v, &joyR_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyR'"); - } - - sq_pushstring(v, "joyL", -1); - sq_newclosure(v, &joyL_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyL'"); - } - - sq_pushstring(v, "joyAxis", -1); - sq_newclosure(v, &joyAxis_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyAxis'"); - } - - sq_pushstring(v, "joyHatDown", -1); - sq_newclosure(v, &joyHatDown_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyHatDown'"); - } - - sq_pushstring(v, "joyHatPress", -1); - sq_newclosure(v, &joyHatPress_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyHatPress'"); - } - - sq_pushstring(v, "joyHatRelease", -1); - sq_newclosure(v, &joyHatRelease_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyHatRelease'"); - } - - sq_pushstring(v, "joyButtonPress", -1); - sq_newclosure(v, &joyButtonPress_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyButtonPress'"); - } - - sq_pushstring(v, "joyButtonDown", -1); - sq_newclosure(v, &joyButtonDown_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyButtonDown'"); - } - - sq_pushstring(v, "joyButtonRelease", -1); - sq_newclosure(v, &joyButtonRelease_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyButtonRelease'"); - } - - sq_pushstring(v, "joyPressAny", -1); - sq_newclosure(v, &joyPressAny_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyPressAny'"); - } - - sq_pushstring(v, "joyAxisPress", -1); - sq_newclosure(v, &joyAxisPress_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyAxisPress'"); - } - - sq_pushstring(v, "joyAxisRelease", -1); - sq_newclosure(v, &joyAxisRelease_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'joyAxisRelease'"); - } - - sq_pushstring(v, "keyString", -1); - sq_newclosure(v, &keyString_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'keyString'"); - } - - sq_pushstring(v, "mouseWheelX", -1); - sq_newclosure(v, &mouseWheelX_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'mouseWheelX'"); - } - - sq_pushstring(v, "mouseWheelY", -1); - sq_newclosure(v, &mouseWheelY_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'mouseWheelY'"); - } - - sq_pushstring(v, "jsonRead", -1); - sq_newclosure(v, &jsonRead_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'jsonRead'"); - } - - sq_pushstring(v, "wait", -1); - sq_newclosure(v, &wait_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'wait'"); - } - - sq_pushstring(v, "update", -1); - sq_newclosure(v, &update_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'update'"); - } - - sq_pushstring(v, "getOS", -1); - sq_newclosure(v, &getOS_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getOS'"); - } - - sq_pushstring(v, "getTicks", -1); - sq_newclosure(v, &getTicks_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getTicks'"); - } - - sq_pushstring(v, "getFPS", -1); - sq_newclosure(v, &getFPS_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getFPS'"); - } - - sq_pushstring(v, "setFPS", -1); - sq_newclosure(v, &setFPS_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setFPS'"); - } - - sq_pushstring(v, "setWindowTitle", -1); - sq_newclosure(v, &setWindowTitle_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setWindowTitle'"); - } - - sq_pushstring(v, "setWindowIcon", -1); - sq_newclosure(v, &setWindowIcon_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'setWindowIcon'"); - } - - sq_pushstring(v, "getFrames", -1); - sq_newclosure(v, &getFrames_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'getFrames'"); - } - - sq_pushstring(v, "displayW", -1); - sq_newclosure(v, &displayW_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'displayW'"); - } - - sq_pushstring(v, "displayH", -1); - sq_newclosure(v, &displayH_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'displayH'"); - } - - sq_pushstring(v, "bruxVersion", -1); - sq_newclosure(v, &bruxVersion_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'bruxVersion'"); - } - - sq_pushstring(v, "toggleFullscreen", -1); - sq_newclosure(v, &toggleFullscreen_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "."); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'toggleFullscreen'"); - } - - sq_pushstring(v, "randFloat", -1); - sq_newclosure(v, &randFloat_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'randFloat'"); - } - - sq_pushstring(v, "randInt", -1); - sq_newclosure(v, &randInt_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'randInt'"); - } - - sq_pushstring(v, "distance2", -1); - sq_newclosure(v, &distance2_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'distance2'"); - } - - sq_pushstring(v, "inDistance2", -1); - sq_newclosure(v, &inDistance2_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'inDistance2'"); - } - - sq_pushstring(v, "distance3", -1); - sq_newclosure(v, &distance3_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'distance3'"); - } - - sq_pushstring(v, "wrap", -1); - sq_newclosure(v, &wrap_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'wrap'"); - } - - sq_pushstring(v, "floor", -1); - sq_newclosure(v, &floor_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'floor'"); - } - - sq_pushstring(v, "ceil", -1); - sq_newclosure(v, &ceil_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'ceil'"); - } - - sq_pushstring(v, "round", -1); - sq_newclosure(v, &round_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'round'"); - } - - sq_pushstring(v, "pointAngle", -1); - sq_newclosure(v, &pointAngle_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'pointAngle'"); - } - - sq_pushstring(v, "abs", -1); - sq_newclosure(v, &abs_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'abs'"); - } - - sq_pushstring(v, "lendirX", -1); - sq_newclosure(v, &lendirX_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'lendirX'"); - } - - sq_pushstring(v, "lendirY", -1); - sq_newclosure(v, &lendirY_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'lendirY'"); - } - - sq_pushstring(v, "binstr", -1); - sq_newclosure(v, &binstr_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'binstr'"); - } - - sq_pushstring(v, "drawCircle", -1); - sq_newclosure(v, &drawCircle_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawCircle'"); - } - - sq_pushstring(v, "drawRec", -1); - sq_newclosure(v, &drawRec_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawRec'"); - } - - sq_pushstring(v, "drawRect", -1); - sq_newclosure(v, &drawRect_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawRect'"); - } - - sq_pushstring(v, "drawPoint", -1); - sq_newclosure(v, &drawPoint_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawPoint'"); - } - - sq_pushstring(v, "drawLine", -1); - sq_newclosure(v, &drawLine_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawLine'"); - } - - sq_pushstring(v, "drawLineWide", -1); - sq_newclosure(v, &drawLineWide_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawLineWide'"); - } - - sq_pushstring(v, "hitLineLine", -1); - sq_newclosure(v, &hitLineLine_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'hitLineLine'"); - } - - sq_pushstring(v, "hitLineCircle", -1); - sq_newclosure(v, &hitLineCircle_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'hitLineCircle'"); - } - - sq_pushstring(v, "hitLinePoint", -1); - sq_newclosure(v, &hitLinePoint_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'hitLinePoint'"); - } - - sq_pushstring(v, "spriteName", -1); - sq_newclosure(v, &spriteName_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'spriteName'"); - } - - sq_pushstring(v, "findSprite", -1); - sq_newclosure(v, &findSprite_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".s"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'findSprite'"); - } - - sq_pushstring(v, "newSprite", -1); - sq_newclosure(v, &newSprite_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".sb|nb|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'newSprite'"); - } - - sq_pushstring(v, "newSpriteFT", -1); - sq_newclosure(v, &newSpriteFT_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'newSpriteFT'"); - } - - sq_pushstring(v, "drawSprite", -1); - sq_newclosure(v, &drawSprite_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawSprite'"); - } - - sq_pushstring(v, "drawSpriteEx", -1); - sq_newclosure(v, &drawSpriteEx_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawSpriteEx'"); - } - - sq_pushstring(v, "drawSpriteMod", -1); - sq_newclosure(v, &drawSpriteMod_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawSpriteMod'"); - } - - sq_pushstring(v, "drawSpriteExMod", -1); - sq_newclosure(v, &drawSpriteExMod_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|nb|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawSpriteExMod'"); - } - - sq_pushstring(v, "deleteSprite", -1); - sq_newclosure(v, &deleteSprite_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'deleteSprite'"); - } - - sq_pushstring(v, "spriteW", -1); - sq_newclosure(v, &spriteW_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'spriteW'"); - } - - sq_pushstring(v, "spriteH", -1); - sq_newclosure(v, &spriteH_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'spriteH'"); - } - - sq_pushstring(v, "replaceSprite", -1); - sq_newclosure(v, &replaceSprite_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nsb|nb|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'replaceSprite'"); - } - - sq_pushstring(v, "spriteSetBlendMode", -1); - sq_newclosure(v, &spriteSetBlendMode_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'spriteSetBlendMode'"); - } - - sq_pushstring(v, "newFont", -1); - sq_newclosure(v, &newFont_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|nb|nb|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'newFont'"); - } - - sq_pushstring(v, "drawText", -1); - sq_newclosure(v, &drawText_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|nb|nb|ns"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'drawText'"); - } - - sq_pushstring(v, "chint", -1); - sq_newclosure(v, &chint_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, ".b|n"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'chint'"); - } - -} - -} // namespace scripting - -/* EOF */ diff --git a/rte/src/squirrel/wrapper.hpp b/rte/src/squirrel/wrapper.hpp deleted file mode 100644 index a7cf9b7c..00000000 --- a/rte/src/squirrel/wrapper.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/** - * WARNING: This file is automatically generated from: - * 'src/api/api.hpp' - * DO NOT CHANGE - */ -#ifndef HEADER_BRUX_SQUIRREL_WRAPPER_HPP -#define HEADER_BRUX_SQUIRREL_WRAPPER_HPP - -#include - -namespace BruxAPI { - -void register_brux_wrapper(HSQUIRRELVM v); - - -} - -#endif - -/* EOF */