From dcd2d333b8f18a5b4c7a76c05f6c4a138f5b1e4f Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Fri, 24 Mar 2017 10:35:20 +0800 Subject: [PATCH 1/4] Fix File Operating functions in Windows Specific Version --- MiniEngine_Windows.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/MiniEngine_Windows.cpp b/MiniEngine_Windows.cpp index 17862ae..8278dad 100644 --- a/MiniEngine_Windows.cpp +++ b/MiniEngine_Windows.cpp @@ -1,7 +1,7 @@ #include "MiniEngine.h" using namespace std; -#include "windows.h" +#include //GBK编码转换到UTF8编码 int _GBKToUTF8(unsigned char * lpGBKStr,unsigned char * lpUTF8Str,int nUTF8StrLen) @@ -118,3 +118,25 @@ string GBKToUTF8(string GBKString) delete[] utf8str; return s; } + +#ifdef _MSC_VER +bool isexist(std::string Path) +{ + return false; +} + +bool canread(std::string Path) +{ + return false; +} + +bool canwrite(std::string Path) +{ + return false; +} + +bool canexecute(std::string Path) +{ + return false; +} +#endif /// End of _MSC_VER From c7c59975caa54b9f376af5c8dd4f8bda39ac659f Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Fri, 24 Mar 2017 10:46:33 +0800 Subject: [PATCH 2/4] Add Font::ready() Now we can check if a Font Object is Ready. ( Font Library Loaded ) --- MiniEngine.cpp | 5 +++++ MiniEngine.h | 1 + 2 files changed, 6 insertions(+) diff --git a/MiniEngine.cpp b/MiniEngine.cpp index 7069156..886307a 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -566,6 +566,11 @@ namespace MiniEngine font.reset(temp, TTF_CloseFont); return 0; } + + bool Font::isReady() + { + return (font.get() != nullptr); + } Texture Font::renderText(Renderer rnd, std::string Text, RGBA fg) { diff --git a/MiniEngine.h b/MiniEngine.h index cac60d0..c809e86 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -219,6 +219,7 @@ namespace MiniEngine Font() = default; Font(std::string FontFileName, int size) throw(ErrorViewer); int use(std::string FontFileName, int size); + bool isReady(); Texture renderText(Renderer rnd, std::string Text, RGBA fg); Texture renderTextWrapped(Renderer rnd, std::string Text, RGBA fg, int WrapLength); Texture renderTextShaded(Renderer rnd, std::string Text, RGBA fg, RGBA bg); From 73e5be676384e4743c645ed6d12b8c54df658a4b Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Fri, 24 Mar 2017 10:59:35 +0800 Subject: [PATCH 3/4] Fix bugs in UTF8ToGBK and GBKToUTF8 GBK->UTF8 x/2*3 UTF8->GBK x/3*2 --- MiniEngine_Windows.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MiniEngine_Windows.cpp b/MiniEngine_Windows.cpp index 8278dad..b07522e 100644 --- a/MiniEngine_Windows.cpp +++ b/MiniEngine_Windows.cpp @@ -83,7 +83,7 @@ int _UTF8ToGBK(unsigned char * lpUTF8Str,unsigned char * lpGBKStr,int nGBKStrLen string UTF8ToGBK(string UTF8String) { - int sz=UTF8String.size()+32; + int sz=UTF8String.size()*2/3+256; auto utf8str=new unsigned char[sz]; memset(utf8str,0,sz); memcpy(utf8str,UTF8String.c_str(),UTF8String.size()); @@ -102,7 +102,7 @@ string UTF8ToGBK(string UTF8String) string GBKToUTF8(string GBKString) { - int sz=GBKString.size()+32; + int sz=GBKString.size()*3/2+32; auto gbkstr=new unsigned char[sz]; memset(gbkstr,0,sz); memcpy(gbkstr,GBKString.c_str(),GBKString.size()); From 9a632324b7ecb4b9641426d8c1b17816135e7143 Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Fri, 24 Mar 2017 11:07:27 +0800 Subject: [PATCH 4/4] Add TextInput in SDLSystem --- MiniEngine.cpp | 10 ++++++++++ MiniEngine.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/MiniEngine.cpp b/MiniEngine.cpp index 886307a..d0df5b2 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -738,6 +738,16 @@ namespace MiniEngine } } + void SDLSystem::StartTextInput() + { + SDL_StartTextInput(); + } + + void SDLSystem::StopTextInput() + { + SDL_StopTextInput(); + } + AudioPlayer::AudioPlayer() { if (!_sysAudioCounter) diff --git a/MiniEngine.h b/MiniEngine.h index c809e86..c296c30 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -257,6 +257,9 @@ namespace MiniEngine static Platform GetPlatform(); + static void StartTextInput(); + static void StopTextInput(); + class Android { public: