From 20b17d9f66549c22892a2b72975e326be4a9eb93 Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Thu, 2 Mar 2017 12:25:11 +0800 Subject: [PATCH] Move old files to SDLEngine. --- MiniEngine_SimpleWidgets.hpp | 187 ------------------ README.md | 8 +- .../MiniEngine}/Event.cpp | 0 {MiniEngine => SDLEngine/MiniEngine}/Event.h | 0 .../MiniEngine}/Widget.cpp | 0 {MiniEngine => SDLEngine/MiniEngine}/Widget.h | 0 .../MiniEngine}/widget_brush.hpp | 0 {include => SDLEngine/include}/App.h | 0 {include => SDLEngine/include}/InitManager.h | 0 {include => SDLEngine/include}/MusicManager.h | 0 {include => SDLEngine/include}/basic_config.h | 0 {include => SDLEngine/include}/config.h | 0 {include => SDLEngine/include}/mini_engine.h | 0 {include => SDLEngine/include}/sdl_engine.h | 0 makefile => SDLEngine/makefile | 0 {src => SDLEngine/src}/App.cpp | 0 {src => SDLEngine/src}/InitManager.cpp | 0 {src => SDLEngine/src}/MusicManager.cpp | 0 {src => SDLEngine/src}/basic_config.cpp | 0 {src => SDLEngine/src}/config.cpp | 0 {src => SDLEngine/src}/main.cpp | 0 {src => SDLEngine/src}/mini_engine.cpp | 0 {src => SDLEngine/src}/sdl_engine.cpp | 0 {src => SDLEngine/src}/sdl_engine_font.hpp | 0 {src => SDLEngine/src}/sdl_engine_rect.hpp | 0 .../src}/sdl_engine_renderer.hpp | 0 {src => SDLEngine/src}/sdl_engine_rgba.hpp | 0 {src => SDLEngine/src}/sdl_engine_surface.hpp | 0 {src => SDLEngine/src}/sdl_engine_texture.hpp | 0 {src => SDLEngine/src}/sdl_engine_window.hpp | 0 Test.cpp | 75 ------- 31 files changed, 4 insertions(+), 266 deletions(-) delete mode 100644 MiniEngine_SimpleWidgets.hpp rename {MiniEngine => SDLEngine/MiniEngine}/Event.cpp (100%) rename {MiniEngine => SDLEngine/MiniEngine}/Event.h (100%) rename {MiniEngine => SDLEngine/MiniEngine}/Widget.cpp (100%) rename {MiniEngine => SDLEngine/MiniEngine}/Widget.h (100%) rename {MiniEngine => SDLEngine/MiniEngine}/widget_brush.hpp (100%) rename {include => SDLEngine/include}/App.h (100%) rename {include => SDLEngine/include}/InitManager.h (100%) rename {include => SDLEngine/include}/MusicManager.h (100%) rename {include => SDLEngine/include}/basic_config.h (100%) rename {include => SDLEngine/include}/config.h (100%) rename {include => SDLEngine/include}/mini_engine.h (100%) rename {include => SDLEngine/include}/sdl_engine.h (100%) rename makefile => SDLEngine/makefile (100%) rename {src => SDLEngine/src}/App.cpp (100%) rename {src => SDLEngine/src}/InitManager.cpp (100%) rename {src => SDLEngine/src}/MusicManager.cpp (100%) rename {src => SDLEngine/src}/basic_config.cpp (100%) rename {src => SDLEngine/src}/config.cpp (100%) rename {src => SDLEngine/src}/main.cpp (100%) rename {src => SDLEngine/src}/mini_engine.cpp (100%) rename {src => SDLEngine/src}/sdl_engine.cpp (100%) rename {src => SDLEngine/src}/sdl_engine_font.hpp (100%) rename {src => SDLEngine/src}/sdl_engine_rect.hpp (100%) rename {src => SDLEngine/src}/sdl_engine_renderer.hpp (100%) rename {src => SDLEngine/src}/sdl_engine_rgba.hpp (100%) rename {src => SDLEngine/src}/sdl_engine_surface.hpp (100%) rename {src => SDLEngine/src}/sdl_engine_texture.hpp (100%) rename {src => SDLEngine/src}/sdl_engine_window.hpp (100%) delete mode 100644 Test.cpp diff --git a/MiniEngine_SimpleWidgets.hpp b/MiniEngine_SimpleWidgets.hpp deleted file mode 100644 index 165148a..0000000 --- a/MiniEngine_SimpleWidgets.hpp +++ /dev/null @@ -1,187 +0,0 @@ -#include "MiniEngine_Simple.h" -#include -#include -#include -#include -using namespace MiniEngine; - -class Drawable -{ -public: - virtual void update(Renderer& rnd)=0; - virtual ~Drawable() - { - - } -}; - -class Interactive : public Drawable -{ -public: - virtual void handle(SDL_Event e,int& running,int& update)=0; -}; - -class SimpleButton : public Interactive -{ -public: - enum class ButtonStatus {normal,mouseover,clicked}; - - /// StatusChanged API - function onStatusChanged; - - - virtual ~SimpleButton() - { - /// Disable the button while destructing - disable(); - } - - SimpleButton(Rect rect) - { - r=rect; - bstatus=ButtonStatus::normal; - } - void setNormalColor(RGBA NormalColor) - { - normal=NormalColor; - } - void setMouseoverColor(RGBA MouseoverColor) - { - mouseover=MouseoverColor; - } - void setClickedColor(RGBA ClickedColor) - { - clicked=ClickedColor; - } - - void enable() - { - disid=RegistDispatcher([this](SDL_Event e,int& r,int& u){handle(e,r,u);}); - upid=RegistUpdater([this](Renderer& rnd){update(rnd);}); - } - void disable() - { - UnregistUpdater(upid); - UnregistDispatcher(disid); - } - - virtual void update(Renderer& rnd) override - { - RGBA old=rnd.getColor(); - switch(bstatus) - { - case ButtonStatus::normal:rnd.setColor(normal);break; - case ButtonStatus::mouseover:rnd.setColor(mouseover);break; - case ButtonStatus::clicked:rnd.setColor(clicked);break; - } - rnd.fillRect(r); - rnd.setColor(old); - } - virtual void handle(SDL_Event e,int& running,int& update) override - { - switch(e.type) - { - case SDL_MOUSEMOTION: - { - if(Point(e.motion.x,e.motion.y).inRect(r)) - { - if(bstatus!=ButtonStatus::mouseover) - { - if(onStatusChanged) - onStatusChanged(running,update,bstatus,ButtonStatus::mouseover); - else - { - bstatus=ButtonStatus::mouseover; - update=1; - } - } - } - else - { - if(bstatus!=ButtonStatus::normal) - { - if(onStatusChanged) - onStatusChanged(running,update,bstatus,ButtonStatus::normal); - else - { - bstatus=ButtonStatus::normal; - update=1; - } - } - } - } - break; - case SDL_MOUSEBUTTONDOWN: - { - if(Point(e.button.x,e.button.y).inRect(r)) - { - if(bstatus!=ButtonStatus::clicked) - { - if(onStatusChanged) - onStatusChanged(running,update,bstatus,ButtonStatus::clicked); - else - { - bstatus=ButtonStatus::clicked; - update=1; - } - } - } - } - break; - case SDL_MOUSEBUTTONUP: - { - if(Point(e.button.x,e.button.y).inRect(r)) - { - if(bstatus!=ButtonStatus::mouseover) - { - if(onStatusChanged) - onStatusChanged(running,update,bstatus,ButtonStatus::mouseover); - else - { - bstatus=ButtonStatus::mouseover; - update=1; - } - } - } - } - break; - } - } -private: - int disid,upid; - Rect r; - /// normal - /// mouseover(MouseOver) -> clicked(Clicked) -> mouseover(ButtonUp) - RGBA normal,mouseover,clicked; - - - /// Status 0:Deactivate 1:MouseOver 2:Clicked - ButtonStatus bstatus; -}; - -/** -//Example Code -int main() -{ - SDLSystem::Init(); - Window wnd("Title Is Here",1024,768); - Renderer rnd=wnd.getRenderer(); - - SimpleButton button(Rect(0,0,150,150)); - button.onStatusChanged=[](int& r,int& u,SimpleButton::ButtonStatus& s,SimpleButton::ButtonStatus ns) - { - printf("Status From %d to %d\n",static_cast(s),static_cast(ns)); - if(s!=ns) u=1; - s=ns; - }; - button.setNormalColor(RGBA(255,0,0,255)); - button.setMouseoverColor(RGBA(0,255,0,255)); - button.setClickedColor(RGBA(0,0,255,255)); - button.enable(); - EventLoop(rnd); - - - SDLSystem::Quit(); - return 0; -} -*/ diff --git a/README.md b/README.md index 8e100fc..2d56cef 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,11 @@ -# MiniEngine +# MiniEngine (In maintenance) A C++ Mini Engine. Based on SDL2. -C++编写的SDL2引擎. +C++编写的SDL2引擎.(维护中) ### 编译说明 -Simple版本: 直接在cpp文件中include这个hpp文件.(目前可用) - **>>目前无法编译项目<<**   Windows: 请使用Codeblocks 16.01(推荐)载入所有.cpp文件.接下来Codeblocks会完成其余的工作. @@ -26,4 +24,6 @@ C4droid: 长按编译键选择编译模式为Makefile. 选择编译目标为SDL2 [前往SDL2官网下载最新版本](http://www.libsdl.org/download-2.0.php) [C4droid on GooglePlay](https://play.google.com/store/apps/details?id=com.n0n3m4.droidc&hl=en) +### 项目状态 +解决Brush和Board的问题中 diff --git a/MiniEngine/Event.cpp b/SDLEngine/MiniEngine/Event.cpp similarity index 100% rename from MiniEngine/Event.cpp rename to SDLEngine/MiniEngine/Event.cpp diff --git a/MiniEngine/Event.h b/SDLEngine/MiniEngine/Event.h similarity index 100% rename from MiniEngine/Event.h rename to SDLEngine/MiniEngine/Event.h diff --git a/MiniEngine/Widget.cpp b/SDLEngine/MiniEngine/Widget.cpp similarity index 100% rename from MiniEngine/Widget.cpp rename to SDLEngine/MiniEngine/Widget.cpp diff --git a/MiniEngine/Widget.h b/SDLEngine/MiniEngine/Widget.h similarity index 100% rename from MiniEngine/Widget.h rename to SDLEngine/MiniEngine/Widget.h diff --git a/MiniEngine/widget_brush.hpp b/SDLEngine/MiniEngine/widget_brush.hpp similarity index 100% rename from MiniEngine/widget_brush.hpp rename to SDLEngine/MiniEngine/widget_brush.hpp diff --git a/include/App.h b/SDLEngine/include/App.h similarity index 100% rename from include/App.h rename to SDLEngine/include/App.h diff --git a/include/InitManager.h b/SDLEngine/include/InitManager.h similarity index 100% rename from include/InitManager.h rename to SDLEngine/include/InitManager.h diff --git a/include/MusicManager.h b/SDLEngine/include/MusicManager.h similarity index 100% rename from include/MusicManager.h rename to SDLEngine/include/MusicManager.h diff --git a/include/basic_config.h b/SDLEngine/include/basic_config.h similarity index 100% rename from include/basic_config.h rename to SDLEngine/include/basic_config.h diff --git a/include/config.h b/SDLEngine/include/config.h similarity index 100% rename from include/config.h rename to SDLEngine/include/config.h diff --git a/include/mini_engine.h b/SDLEngine/include/mini_engine.h similarity index 100% rename from include/mini_engine.h rename to SDLEngine/include/mini_engine.h diff --git a/include/sdl_engine.h b/SDLEngine/include/sdl_engine.h similarity index 100% rename from include/sdl_engine.h rename to SDLEngine/include/sdl_engine.h diff --git a/makefile b/SDLEngine/makefile similarity index 100% rename from makefile rename to SDLEngine/makefile diff --git a/src/App.cpp b/SDLEngine/src/App.cpp similarity index 100% rename from src/App.cpp rename to SDLEngine/src/App.cpp diff --git a/src/InitManager.cpp b/SDLEngine/src/InitManager.cpp similarity index 100% rename from src/InitManager.cpp rename to SDLEngine/src/InitManager.cpp diff --git a/src/MusicManager.cpp b/SDLEngine/src/MusicManager.cpp similarity index 100% rename from src/MusicManager.cpp rename to SDLEngine/src/MusicManager.cpp diff --git a/src/basic_config.cpp b/SDLEngine/src/basic_config.cpp similarity index 100% rename from src/basic_config.cpp rename to SDLEngine/src/basic_config.cpp diff --git a/src/config.cpp b/SDLEngine/src/config.cpp similarity index 100% rename from src/config.cpp rename to SDLEngine/src/config.cpp diff --git a/src/main.cpp b/SDLEngine/src/main.cpp similarity index 100% rename from src/main.cpp rename to SDLEngine/src/main.cpp diff --git a/src/mini_engine.cpp b/SDLEngine/src/mini_engine.cpp similarity index 100% rename from src/mini_engine.cpp rename to SDLEngine/src/mini_engine.cpp diff --git a/src/sdl_engine.cpp b/SDLEngine/src/sdl_engine.cpp similarity index 100% rename from src/sdl_engine.cpp rename to SDLEngine/src/sdl_engine.cpp diff --git a/src/sdl_engine_font.hpp b/SDLEngine/src/sdl_engine_font.hpp similarity index 100% rename from src/sdl_engine_font.hpp rename to SDLEngine/src/sdl_engine_font.hpp diff --git a/src/sdl_engine_rect.hpp b/SDLEngine/src/sdl_engine_rect.hpp similarity index 100% rename from src/sdl_engine_rect.hpp rename to SDLEngine/src/sdl_engine_rect.hpp diff --git a/src/sdl_engine_renderer.hpp b/SDLEngine/src/sdl_engine_renderer.hpp similarity index 100% rename from src/sdl_engine_renderer.hpp rename to SDLEngine/src/sdl_engine_renderer.hpp diff --git a/src/sdl_engine_rgba.hpp b/SDLEngine/src/sdl_engine_rgba.hpp similarity index 100% rename from src/sdl_engine_rgba.hpp rename to SDLEngine/src/sdl_engine_rgba.hpp diff --git a/src/sdl_engine_surface.hpp b/SDLEngine/src/sdl_engine_surface.hpp similarity index 100% rename from src/sdl_engine_surface.hpp rename to SDLEngine/src/sdl_engine_surface.hpp diff --git a/src/sdl_engine_texture.hpp b/SDLEngine/src/sdl_engine_texture.hpp similarity index 100% rename from src/sdl_engine_texture.hpp rename to SDLEngine/src/sdl_engine_texture.hpp diff --git a/src/sdl_engine_window.hpp b/SDLEngine/src/sdl_engine_window.hpp similarity index 100% rename from src/sdl_engine_window.hpp rename to SDLEngine/src/sdl_engine_window.hpp diff --git a/Test.cpp b/Test.cpp deleted file mode 100644 index 7b9d996..0000000 --- a/Test.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "MiniEngine.h" -using namespace MiniEngine; - -#include -using namespace std; - -int AppMain() -{ - Window wnd("Sample Program",1280,720); - Renderer rnd=wnd.getRenderer(); - rnd.setBlendMode(BlendMode::Blend); - Font font("D:\\msyh.ttf",18); - - MusicPlayer mp; - Music mlogin=mp.loadMusic("res/1.mp3"); - Texture tlogin=rnd.loadTexture("res/page.jpg"); - tlogin.setBlendMode(BlendMode::Blend); - Texture tlogin2=rnd.loadTexture("res/page2.jpg"); - tlogin2.setBlendMode(BlendMode::Blend); - - mp.play(mlogin,0); - - int fade=0; - int fadex=0; - int aa=255; - int ba=0; - - EventHandle::RegistDispatcher(SDL_QUIT,[](SDL_Event e,int& r,int& u){r=0;u=1;}); - EventHandle::RegistDispatcher(SDL_KEYDOWN,[&](SDL_Event e,int& r,int& u){ - if(e.key.keysym.sym==SDLK_RETURN) - { - fade=1; - u=1; - } - else if(e.key.keysym.sym==SDLK_KP_ENTER) - { - fadex=1; - u=1; - } - }); - EventHandle::RegistUpdater([&](Renderer& rnd){ - if(fade) - { - cout<<"Fading..."<