From d033400614e7e2c0ff49e5100c81e937e5818e74 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 28 Jul 2018 13:47:51 +0800 Subject: *update --- src/libjin/3rdparty/smount/smount.c | 2 +- src/libjin/Audio/Audio.cpp | 2 +- src/libjin/Audio/Audio.h | 6 ++-- src/libjin/Audio/SDL/SDLAudio.h | 2 -- src/libjin/Audio/SDL/SDLSource.h | 2 +- src/libjin/Audio/Source.h | 4 +-- src/libjin/Common/Singleton.h | 38 ----------------------- src/libjin/Common/Singleton.hpp | 37 ++++++++++++++++++++++ src/libjin/Common/Subsystem.h | 43 -------------------------- src/libjin/Common/Subsystem.hpp | 43 ++++++++++++++++++++++++++ src/libjin/Core/Game.cpp | 37 +++++++++++++++++++--- src/libjin/Core/Game.h | 58 ++++++++++++++++------------------- src/libjin/Core/Thread.cpp | 0 src/libjin/Core/Thread.h | 1 - src/libjin/Core/Timer.cpp | 0 src/libjin/Core/Timer.h | 1 - src/libjin/Graphics/Window.cpp | 11 ++++--- src/libjin/Graphics/Window.h | 6 ++-- src/libjin/Input/Keyboard.h | 4 ++- src/libjin/Input/Mouse.h | 2 +- src/libjin/Tilemap/Tilemap.cpp | 0 src/libjin/Tilemap/Tilemap.h | 5 ++- src/libjin/Time/Timer.cpp | 0 src/libjin/Time/Timer.h | 17 ++++++++++ src/libjin/Utils/unittest.cpp | 2 +- src/libjin/audio/audio.cpp | 2 +- src/libjin/audio/audio.h | 6 ++-- src/libjin/audio/source.h | 4 +-- src/libjin/common/singleton.h | 38 ----------------------- src/libjin/common/subsystem.h | 43 -------------------------- src/libjin/core/game.cpp | 37 +++++++++++++++++++--- src/libjin/core/game.h | 58 ++++++++++++++++------------------- src/libjin/core/thread.cpp | 0 src/libjin/core/thread.h | 1 - src/libjin/core/timer.cpp | 0 src/libjin/core/timer.h | 1 - src/libjin/input/keyboard.h | 4 ++- src/libjin/input/mouse.h | 2 +- src/libjin/modules.h | 2 ++ src/libjin/tilemap/tilemap.h | 5 ++- src/libjin/utils/unittest.cpp | 2 +- src/lua/audio/luaopen_audio.cpp | 2 +- src/lua/core/luaopen_core.cpp | 14 ++++----- src/lua/embed/boot.lua.h | 4 +-- src/lua/graphics/luaopen_graphics.cpp | 2 +- 45 files changed, 268 insertions(+), 282 deletions(-) delete mode 100644 src/libjin/Common/Singleton.h create mode 100644 src/libjin/Common/Singleton.hpp delete mode 100644 src/libjin/Common/Subsystem.h create mode 100644 src/libjin/Common/Subsystem.hpp delete mode 100644 src/libjin/Core/Thread.cpp delete mode 100644 src/libjin/Core/Thread.h delete mode 100644 src/libjin/Core/Timer.cpp delete mode 100644 src/libjin/Core/Timer.h create mode 100644 src/libjin/Tilemap/Tilemap.cpp create mode 100644 src/libjin/Time/Timer.cpp create mode 100644 src/libjin/Time/Timer.h delete mode 100644 src/libjin/common/singleton.h delete mode 100644 src/libjin/common/subsystem.h delete mode 100644 src/libjin/core/thread.cpp delete mode 100644 src/libjin/core/thread.h delete mode 100644 src/libjin/core/timer.cpp delete mode 100644 src/libjin/core/timer.h (limited to 'src') diff --git a/src/libjin/3rdparty/smount/smount.c b/src/libjin/3rdparty/smount/smount.c index c4e2ef0..3006fa3 100644 --- a/src/libjin/3rdparty/smount/smount.c +++ b/src/libjin/3rdparty/smount/smount.c @@ -109,7 +109,7 @@ int smtexists(smtShared* S, const char *path) static struct stat smtgetstat(smtShared* S, const char*path) { char* r = concat(S->mount->path, "/", path, 0); - struct stat s = {}; + struct stat s = {0}; if (!r) return s; int res = stat(r, &s); free(r); diff --git a/src/libjin/Audio/Audio.cpp b/src/libjin/Audio/Audio.cpp index 363bf4d..5fb10da 100644 --- a/src/libjin/Audio/Audio.cpp +++ b/src/libjin/Audio/Audio.cpp @@ -1,7 +1,7 @@ #include "../modules.h" #if JIN_MODULES_AUDIO -#include +#include "SDL2/SDL.h" #include "audio.h" namespace jin diff --git a/src/libjin/Audio/Audio.h b/src/libjin/Audio/Audio.h index faec4db..60de66d 100644 --- a/src/libjin/Audio/Audio.h +++ b/src/libjin/Audio/Audio.h @@ -3,10 +3,10 @@ #include "../modules.h" #if JIN_MODULES_AUDIO -#include +#include "SDL2/SDL.h" #include "../utils/macros.h" -#include "../common/subsystem.h" +#include "../common/Subsystem.hpp" namespace jin { @@ -43,4 +43,4 @@ namespace audio } #endif // JIN_MODULES_AUDIO -#endif \ No newline at end of file +#endif // __JIN_AUDIO_H \ No newline at end of file diff --git a/src/libjin/Audio/SDL/SDLAudio.h b/src/libjin/Audio/SDL/SDLAudio.h index 4c9ab34..bac4544 100644 --- a/src/libjin/Audio/SDL/SDLAudio.h +++ b/src/libjin/Audio/SDL/SDLAudio.h @@ -59,8 +59,6 @@ namespace audio }; - typedef SDLAudio::Setting SDLAudioSetting; - } } diff --git a/src/libjin/Audio/SDL/SDLSource.h b/src/libjin/Audio/SDL/SDLSource.h index 38f7ec4..5c6aefc 100644 --- a/src/libjin/Audio/SDL/SDLSource.h +++ b/src/libjin/Audio/SDL/SDLSource.h @@ -113,4 +113,4 @@ namespace audio } #endif // JIN_MODULES_AUDIO && JIN_AUDIO_SDLAUDIO -#endif \ No newline at end of file +#endif // __JIN_SOURCE_SDL_H \ No newline at end of file diff --git a/src/libjin/Audio/Source.h b/src/libjin/Audio/Source.h index 5b9c12b..3abe7de 100644 --- a/src/libjin/Audio/Source.h +++ b/src/libjin/Audio/Source.h @@ -3,7 +3,7 @@ #include "../modules.h" #if JIN_MODULES_AUDIO -#include +#include "SDL2/SDL.h" namespace jin { @@ -48,4 +48,4 @@ namespace audio } #endif // JIN_MODULES_AUDIO -#endif \ No newline at end of file +#endif // __JIN_AUDIO_SOURCE_H \ No newline at end of file diff --git a/src/libjin/Common/Singleton.h b/src/libjin/Common/Singleton.h deleted file mode 100644 index ff8a9ce..0000000 --- a/src/libjin/Common/Singleton.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __JIN_SINGLETON_H -#define __JIN_SINGLETON_H - -namespace jin -{ - template - class Singleton - { - public: - static T* get() - { - if (_instance == nullptr) - _instance = new T; - return _instance; - } - static void destroy() - { - delete _instance; - _instance = nullptr; - } - protected: - Singleton() {}; - virtual ~Singleton() {}; - private: - Singleton(const Singleton&); - Singleton& operator = (const Singleton&); - - static T* _instance; - }; - - template T* Singleton::_instance = nullptr; - -#define SINGLETON(T) \ - friend Singleton - -} // jin - -#endif \ No newline at end of file diff --git a/src/libjin/Common/Singleton.hpp b/src/libjin/Common/Singleton.hpp new file mode 100644 index 0000000..c3ce467 --- /dev/null +++ b/src/libjin/Common/Singleton.hpp @@ -0,0 +1,37 @@ +#ifndef __JIN_SINGLETON_H +#define __JIN_SINGLETON_H + +namespace jin +{ + template + class Singleton + { + public: + static T* get() + { + if (_instance == nullptr) + _instance = new T; + return _instance; + } + static void destroy() + { + delete _instance; + _instance = nullptr; + } + protected: + Singleton() {}; + virtual ~Singleton() {}; + static T* _instance; + private: + Singleton(const Singleton&); + Singleton& operator = (const Singleton&); + }; + + template T* Singleton::_instance = nullptr; + +#define SINGLETON(T) \ + friend Singleton + +} // jin + +#endif // __JIN_SINGLETON_H \ No newline at end of file diff --git a/src/libjin/Common/Subsystem.h b/src/libjin/Common/Subsystem.h deleted file mode 100644 index 8a4ecf6..0000000 --- a/src/libjin/Common/Subsystem.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef __JIN_COMMON_SUBSYSTEM_H -#define __JIN_COMMON_SUBSYSTEM_H - -#include "singleton.h" -#include "../utils/macros.h" - -namespace jin -{ - - template - class Subsystem : public Singleton - { - public: - struct Setting {}; - typedef Setting SettingBase; - - bool init(const SettingBase* setting) - { - static bool success = initSystem(setting); - return success; - } - - void quit() - { - CALLONCE(quitSystem()); - destroy(); - } - - protected: - - Subsystem() {}; - virtual ~Subsystem() {}; - - SINGLETON(System); - - virtual onlyonce bool initSystem(const Setting* setting) = 0; - virtual onlyonce void quitSystem() = 0; - - }; - -} // jin - -#endif \ No newline at end of file diff --git a/src/libjin/Common/Subsystem.hpp b/src/libjin/Common/Subsystem.hpp new file mode 100644 index 0000000..f4e270b --- /dev/null +++ b/src/libjin/Common/Subsystem.hpp @@ -0,0 +1,43 @@ +#ifndef __JIN_COMMON_SUBSYSTEM_H +#define __JIN_COMMON_SUBSYSTEM_H + +#include "singleton.hpp" +#include "../utils/macros.h" + +namespace jin +{ + + template + class Subsystem : public Singleton + { + public: + struct Setting {}; + typedef Setting SettingBase; + + bool init(const SettingBase* setting) + { + static bool success = initSystem(setting); + return success; + } + + void quit() + { + CALLONCE(quitSystem()); + destroy(); + } + + protected: + + Subsystem() {}; + virtual ~Subsystem() {}; + + SINGLETON(System); + + virtual onlyonce bool initSystem(const Setting* setting) = 0; + virtual onlyonce void quitSystem() = 0; + + }; + +} // jin + +#endif \ No newline at end of file diff --git a/src/libjin/Core/Game.cpp b/src/libjin/Core/Game.cpp index 2090d64..f2223b2 100644 --- a/src/libjin/Core/Game.cpp +++ b/src/libjin/Core/Game.cpp @@ -1,17 +1,46 @@ #include "game.h" +#include "../Time/Timer.h" +#include "../input/Event.h" namespace jin { namespace core { - Game::Game() :_run(true) {}; + using namespace jin::input; + + Game::Game() :_running(true) {}; void Game::run() { + _running = true; + Event e; + while (_running) + { + while (jin::input::pollEvent(&e)) + { + if (_instance != nullptr && _onEvent) + _onEvent(&e); + } + if (!_running) + break; + } + } + + bool Game::initSystem(const SettingBase* setting) + { + if (setting == nullptr) + return false; + Game::Setting* s = (Game::Setting*) setting; + _onEvent = s->eventHandler; + _onUpdate = s->updater; + _onDraw = s->drawer; + return true; + } + void Game::quitSystem() + { } - -} -} +} // core +} // jin \ No newline at end of file diff --git a/src/libjin/Core/Game.h b/src/libjin/Core/Game.h index becb780..e9d0340 100644 --- a/src/libjin/Core/Game.h +++ b/src/libjin/Core/Game.h @@ -1,40 +1,35 @@ #ifndef __JIN_CORE_GAME_H #define __JIN_CORE_GAME_H -#include +#include "SDL2/SDL.h" -#include "../common/singleton.h" +#include "../Common/Subsystem.hpp" #include "../utils/macros.h" +#include "../Input/Event.h" namespace jin { namespace core { - class Game : public Singleton + + class Game : public Subsystem { public: - struct Setting - { + typedef void(*onEvent)(jin::input::Event* e); + typedef void(*onUpdate)(float dt); + typedef void(*onDraw)(); - }; - - inline void quit() + struct Setting : SettingBase { - CALLONCE(_quit()); - } - - inline bool running() - { - return run; - } - - inline void exit() - { - CALLONCE(_exit()); - } + onEvent eventHandler; + onUpdate updater; + onDraw drawer; + }; void run(); + inline void stop() { _running = false; }; + bool running() { return _running; }; private: @@ -43,19 +38,18 @@ namespace core SINGLETON(Game); - bool _run; + onEvent _onEvent; + onUpdate _onUpdate; + onDraw _onDraw; - inline void _exit() - { - SDL_Quit(); - } + bool _running; + + onlyonce bool initSystem(const SettingBase* setting); + onlyonce void quitSystem(); - inline void _quit() - { - _run = false; - } }; -} -} -#endif \ No newline at end of file +} // core +} // jin + +#endif // __JIN_CORE_GAME_H \ No newline at end of file diff --git a/src/libjin/Core/Thread.cpp b/src/libjin/Core/Thread.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/libjin/Core/Thread.h b/src/libjin/Core/Thread.h deleted file mode 100644 index 6f70f09..0000000 --- a/src/libjin/Core/Thread.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/src/libjin/Core/Timer.cpp b/src/libjin/Core/Timer.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/libjin/Core/Timer.h b/src/libjin/Core/Timer.h deleted file mode 100644 index 6f70f09..0000000 --- a/src/libjin/Core/Timer.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/src/libjin/Graphics/Window.cpp b/src/libjin/Graphics/Window.cpp index 2d0fa82..28e5b84 100644 --- a/src/libjin/Graphics/Window.cpp +++ b/src/libjin/Graphics/Window.cpp @@ -14,14 +14,14 @@ namespace jin namespace graphics { - onlyonce bool WindowSystem::initSystem(const SettingBase* s) + bool WindowSystem::initSystem(const SettingBase* s) { Loghelper::log(Loglevel::LV_INFO, "Init window system"); if (SDL_Init(SDL_INIT_VIDEO) < 0) return false; - const WindowSetting* setting = (WindowSetting*)s; + const Setting* setting = (Setting*)s; width = setting->width; height = setting->height; @@ -73,9 +73,10 @@ namespace graphics return true; } - onlyonce void WindowSystem::quitSystem() + void WindowSystem::quitSystem() { SDL_DestroyWindow(wnd); + SDL_Quit(); } inline void WindowSystem::swapBuffers() @@ -84,7 +85,7 @@ namespace graphics SDL_GL_SwapWindow(wnd); } -} -} +} // graphics +} // jin #endif // JIN_MODULES_RENDER \ No newline at end of file diff --git a/src/libjin/Graphics/Window.h b/src/libjin/Graphics/Window.h index 893fdb8..6213cee 100644 --- a/src/libjin/Graphics/Window.h +++ b/src/libjin/Graphics/Window.h @@ -3,9 +3,9 @@ #include "../modules.h" #if JIN_MODULES_RENDER -#include +#include "SDL2/SDL.h" #include "../utils/utils.h" -#include "../common/subsystem.h" +#include "../common/Subsystem.hpp" namespace jin { @@ -51,8 +51,6 @@ namespace graphics onlyonce void quitSystem() override; }; - typedef WindowSystem::Setting WindowSetting; - } // render } // jin diff --git a/src/libjin/Input/Keyboard.h b/src/libjin/Input/Keyboard.h index bbb6456..3e78ab1 100644 --- a/src/libjin/Input/Keyboard.h +++ b/src/libjin/Input/Keyboard.h @@ -1,5 +1,6 @@ #ifndef __JIN_KEYBOARD_H #define __JIN_KEYBOARD_H + namespace jin { namespace input @@ -10,4 +11,5 @@ namespace input }; } } -#endif \ No newline at end of file + +#endif // __JIN_KEYBOARD_H \ No newline at end of file diff --git a/src/libjin/Input/Mouse.h b/src/libjin/Input/Mouse.h index cb70407..5fc6b47 100644 --- a/src/libjin/Input/Mouse.h +++ b/src/libjin/Input/Mouse.h @@ -3,7 +3,7 @@ #include "../modules.h" #ifdef JIN_MODULES_INPUT -#include "../Common/Singleton.h" +#include "../Common/Singleton.hpp" namespace jin { diff --git a/src/libjin/Tilemap/Tilemap.cpp b/src/libjin/Tilemap/Tilemap.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/libjin/Tilemap/Tilemap.h b/src/libjin/Tilemap/Tilemap.h index 27cbe51..a2bce62 100644 --- a/src/libjin/Tilemap/Tilemap.h +++ b/src/libjin/Tilemap/Tilemap.h @@ -1,5 +1,7 @@ #ifndef __JIN_TILEMAP_H #define __JIN_TILEMAP_H +#include "../modules.h" +#if JIN_MODULES_TILEMAP namespace jin { @@ -11,4 +13,5 @@ namespace tilemap }// tilemap }// jin -#endif \ No newline at end of file +#endif // JIN_MODULES_TILEMAP +#endif // __JIN_TILEMAP_H \ No newline at end of file diff --git a/src/libjin/Time/Timer.cpp b/src/libjin/Time/Timer.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/libjin/Time/Timer.h b/src/libjin/Time/Timer.h new file mode 100644 index 0000000..1742306 --- /dev/null +++ b/src/libjin/Time/Timer.h @@ -0,0 +1,17 @@ +#ifndef __JIN_TIMER_H +#define __JIN_TIMER_H +#include "../modules.h" +#if JIN_MODULES_TIME + +namespace jin +{ +namespace time +{ + + + +} +} + +#endif // JIN_MODULES_TIME +#endif // __JIN_TIMER_H \ No newline at end of file diff --git a/src/libjin/Utils/unittest.cpp b/src/libjin/Utils/unittest.cpp index 2952b0b..44f1ae5 100644 --- a/src/libjin/Utils/unittest.cpp +++ b/src/libjin/Utils/unittest.cpp @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) #include #include #include -#include +#include "SDL2/SDL.h" #include <3rdparty/cmixer/cmixer.h> diff --git a/src/libjin/audio/audio.cpp b/src/libjin/audio/audio.cpp index 363bf4d..5fb10da 100644 --- a/src/libjin/audio/audio.cpp +++ b/src/libjin/audio/audio.cpp @@ -1,7 +1,7 @@ #include "../modules.h" #if JIN_MODULES_AUDIO -#include +#include "SDL2/SDL.h" #include "audio.h" namespace jin diff --git a/src/libjin/audio/audio.h b/src/libjin/audio/audio.h index faec4db..60de66d 100644 --- a/src/libjin/audio/audio.h +++ b/src/libjin/audio/audio.h @@ -3,10 +3,10 @@ #include "../modules.h" #if JIN_MODULES_AUDIO -#include +#include "SDL2/SDL.h" #include "../utils/macros.h" -#include "../common/subsystem.h" +#include "../common/Subsystem.hpp" namespace jin { @@ -43,4 +43,4 @@ namespace audio } #endif // JIN_MODULES_AUDIO -#endif \ No newline at end of file +#endif // __JIN_AUDIO_H \ No newline at end of file diff --git a/src/libjin/audio/source.h b/src/libjin/audio/source.h index 5b9c12b..3abe7de 100644 --- a/src/libjin/audio/source.h +++ b/src/libjin/audio/source.h @@ -3,7 +3,7 @@ #include "../modules.h" #if JIN_MODULES_AUDIO -#include +#include "SDL2/SDL.h" namespace jin { @@ -48,4 +48,4 @@ namespace audio } #endif // JIN_MODULES_AUDIO -#endif \ No newline at end of file +#endif // __JIN_AUDIO_SOURCE_H \ No newline at end of file diff --git a/src/libjin/common/singleton.h b/src/libjin/common/singleton.h deleted file mode 100644 index ff8a9ce..0000000 --- a/src/libjin/common/singleton.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __JIN_SINGLETON_H -#define __JIN_SINGLETON_H - -namespace jin -{ - template - class Singleton - { - public: - static T* get() - { - if (_instance == nullptr) - _instance = new T; - return _instance; - } - static void destroy() - { - delete _instance; - _instance = nullptr; - } - protected: - Singleton() {}; - virtual ~Singleton() {}; - private: - Singleton(const Singleton&); - Singleton& operator = (const Singleton&); - - static T* _instance; - }; - - template T* Singleton::_instance = nullptr; - -#define SINGLETON(T) \ - friend Singleton - -} // jin - -#endif \ No newline at end of file diff --git a/src/libjin/common/subsystem.h b/src/libjin/common/subsystem.h deleted file mode 100644 index 8a4ecf6..0000000 --- a/src/libjin/common/subsystem.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef __JIN_COMMON_SUBSYSTEM_H -#define __JIN_COMMON_SUBSYSTEM_H - -#include "singleton.h" -#include "../utils/macros.h" - -namespace jin -{ - - template - class Subsystem : public Singleton - { - public: - struct Setting {}; - typedef Setting SettingBase; - - bool init(const SettingBase* setting) - { - static bool success = initSystem(setting); - return success; - } - - void quit() - { - CALLONCE(quitSystem()); - destroy(); - } - - protected: - - Subsystem() {}; - virtual ~Subsystem() {}; - - SINGLETON(System); - - virtual onlyonce bool initSystem(const Setting* setting) = 0; - virtual onlyonce void quitSystem() = 0; - - }; - -} // jin - -#endif \ No newline at end of file diff --git a/src/libjin/core/game.cpp b/src/libjin/core/game.cpp index 2090d64..f2223b2 100644 --- a/src/libjin/core/game.cpp +++ b/src/libjin/core/game.cpp @@ -1,17 +1,46 @@ #include "game.h" +#include "../Time/Timer.h" +#include "../input/Event.h" namespace jin { namespace core { - Game::Game() :_run(true) {}; + using namespace jin::input; + + Game::Game() :_running(true) {}; void Game::run() { + _running = true; + Event e; + while (_running) + { + while (jin::input::pollEvent(&e)) + { + if (_instance != nullptr && _onEvent) + _onEvent(&e); + } + if (!_running) + break; + } + } + + bool Game::initSystem(const SettingBase* setting) + { + if (setting == nullptr) + return false; + Game::Setting* s = (Game::Setting*) setting; + _onEvent = s->eventHandler; + _onUpdate = s->updater; + _onDraw = s->drawer; + return true; + } + void Game::quitSystem() + { } - -} -} +} // core +} // jin \ No newline at end of file diff --git a/src/libjin/core/game.h b/src/libjin/core/game.h index becb780..e9d0340 100644 --- a/src/libjin/core/game.h +++ b/src/libjin/core/game.h @@ -1,40 +1,35 @@ #ifndef __JIN_CORE_GAME_H #define __JIN_CORE_GAME_H -#include +#include "SDL2/SDL.h" -#include "../common/singleton.h" +#include "../Common/Subsystem.hpp" #include "../utils/macros.h" +#include "../Input/Event.h" namespace jin { namespace core { - class Game : public Singleton + + class Game : public Subsystem { public: - struct Setting - { + typedef void(*onEvent)(jin::input::Event* e); + typedef void(*onUpdate)(float dt); + typedef void(*onDraw)(); - }; - - inline void quit() + struct Setting : SettingBase { - CALLONCE(_quit()); - } - - inline bool running() - { - return run; - } - - inline void exit() - { - CALLONCE(_exit()); - } + onEvent eventHandler; + onUpdate updater; + onDraw drawer; + }; void run(); + inline void stop() { _running = false; }; + bool running() { return _running; }; private: @@ -43,19 +38,18 @@ namespace core SINGLETON(Game); - bool _run; + onEvent _onEvent; + onUpdate _onUpdate; + onDraw _onDraw; - inline void _exit() - { - SDL_Quit(); - } + bool _running; + + onlyonce bool initSystem(const SettingBase* setting); + onlyonce void quitSystem(); - inline void _quit() - { - _run = false; - } }; -} -} -#endif \ No newline at end of file +} // core +} // jin + +#endif // __JIN_CORE_GAME_H \ No newline at end of file diff --git a/src/libjin/core/thread.cpp b/src/libjin/core/thread.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/libjin/core/thread.h b/src/libjin/core/thread.h deleted file mode 100644 index 6f70f09..0000000 --- a/src/libjin/core/thread.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/src/libjin/core/timer.cpp b/src/libjin/core/timer.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/libjin/core/timer.h b/src/libjin/core/timer.h deleted file mode 100644 index 6f70f09..0000000 --- a/src/libjin/core/timer.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/src/libjin/input/keyboard.h b/src/libjin/input/keyboard.h index bbb6456..3e78ab1 100644 --- a/src/libjin/input/keyboard.h +++ b/src/libjin/input/keyboard.h @@ -1,5 +1,6 @@ #ifndef __JIN_KEYBOARD_H #define __JIN_KEYBOARD_H + namespace jin { namespace input @@ -10,4 +11,5 @@ namespace input }; } } -#endif \ No newline at end of file + +#endif // __JIN_KEYBOARD_H \ No newline at end of file diff --git a/src/libjin/input/mouse.h b/src/libjin/input/mouse.h index cb70407..5fc6b47 100644 --- a/src/libjin/input/mouse.h +++ b/src/libjin/input/mouse.h @@ -3,7 +3,7 @@ #include "../modules.h" #ifdef JIN_MODULES_INPUT -#include "../Common/Singleton.h" +#include "../Common/Singleton.hpp" namespace jin { diff --git a/src/libjin/modules.h b/src/libjin/modules.h index 34c1d11..48b71c9 100644 --- a/src/libjin/modules.h +++ b/src/libjin/modules.h @@ -33,4 +33,6 @@ #define JIN_MODULES_THREAD 1 +#define JIN_MODULES_TIME 1 + #endif \ No newline at end of file diff --git a/src/libjin/tilemap/tilemap.h b/src/libjin/tilemap/tilemap.h index 27cbe51..a2bce62 100644 --- a/src/libjin/tilemap/tilemap.h +++ b/src/libjin/tilemap/tilemap.h @@ -1,5 +1,7 @@ #ifndef __JIN_TILEMAP_H #define __JIN_TILEMAP_H +#include "../modules.h" +#if JIN_MODULES_TILEMAP namespace jin { @@ -11,4 +13,5 @@ namespace tilemap }// tilemap }// jin -#endif \ No newline at end of file +#endif // JIN_MODULES_TILEMAP +#endif // __JIN_TILEMAP_H \ No newline at end of file diff --git a/src/libjin/utils/unittest.cpp b/src/libjin/utils/unittest.cpp index 2952b0b..44f1ae5 100644 --- a/src/libjin/utils/unittest.cpp +++ b/src/libjin/utils/unittest.cpp @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) #include #include #include -#include +#include "SDL2/SDL.h" #include <3rdparty/cmixer/cmixer.h> diff --git a/src/lua/audio/luaopen_audio.cpp b/src/lua/audio/luaopen_audio.cpp index 73c5bea..9a6bade 100644 --- a/src/lua/audio/luaopen_audio.cpp +++ b/src/lua/audio/luaopen_audio.cpp @@ -9,7 +9,7 @@ namespace lua static int l_init(lua_State* L) { - SDLAudioSetting setting; + SDLAudio::Setting setting; if (! SDLAudio::get()->init(&setting)) { luax_error(L, "could not init audio"); diff --git a/src/lua/core/luaopen_core.cpp b/src/lua/core/luaopen_core.cpp index 0e79ff5..d20a3bc 100644 --- a/src/lua/core/luaopen_core.cpp +++ b/src/lua/core/luaopen_core.cpp @@ -15,22 +15,22 @@ namespace lua return 1; } - static int l_quit(lua_State* L) + static int l_stop(lua_State* L) { - Game::get()->quit(); + Game::get()->stop(); return 0; } - static int l_exit(lua_State* L) + static int l_quit(lua_State* L) { - Game::get()->exit(); + Game::get()->quit(); return 0; } - + static const luaL_Reg f[] = { {"running", l_running}, - {"quit", l_quit}, // for end game loop - {"exit", l_exit}, // for exit whole game + {"stop", l_stop}, // for end game loop + {"quit", l_quit}, // for exit whole game {0, 0} }; diff --git a/src/lua/embed/boot.lua.h b/src/lua/embed/boot.lua.h index 2a9cfc5..c1d22a3 100644 --- a/src/lua/embed/boot.lua.h +++ b/src/lua/embed/boot.lua.h @@ -117,7 +117,7 @@ local function onError(msg) print("Error:\n" .. msg) function jin.core.onEvent(e) if e.type == 'quit' then - jin.core.quit() + jin.core.stop() end end local ww, wh = jin.graphics.size() @@ -150,7 +150,7 @@ local function main() -- quit subsystems jin.graphics.destroy() -- exit whole game - jin.core.exit() + jin.core.quit() end main() diff --git a/src/lua/graphics/luaopen_graphics.cpp b/src/lua/graphics/luaopen_graphics.cpp index 42586a5..2d1ff57 100644 --- a/src/lua/graphics/luaopen_graphics.cpp +++ b/src/lua/graphics/luaopen_graphics.cpp @@ -28,7 +28,7 @@ namespace lua static int l_init(lua_State* L) { WindowSystem* wnd = WindowSystem::get(); - WindowSetting setting; + WindowSystem::Setting setting; setting.width = luax_getfield_integer(L, 1, "width"); setting.height = luax_getfield_integer(L, 1, "height"); setting.title = luax_getfield_string(L, 1, "title"); -- cgit v1.1-26-g67d0