keyboard + linux stuff

This commit is contained in:
Vladislav Khorev 2013-06-12 16:09:17 +00:00
parent a89cfc0371
commit 490cdad867
9 changed files with 136 additions and 1 deletions

View File

@ -22,6 +22,7 @@
<ClInclude Include="..\include\GlobalConst.h" />
<ClInclude Include="..\include\GUIManager\ButtonWidget.h" />
<ClInclude Include="..\include\GUIManager\GUIManager.h" />
<ClInclude Include="..\include\GUIManager\KeyboardWidget.h" />
<ClInclude Include="..\include\GUIManager\WidgetTemplatesImpl.h" />
<ClInclude Include="..\include\GUIManager\WidgetXmlParsers.h" />
<ClInclude Include="..\include\HalibutAnimation\HalibutAnimation.h" />
@ -71,6 +72,7 @@
<ClCompile Include="..\src\GlobalConst.cpp" />
<ClCompile Include="..\src\GUIManager\ButtonWidget.cpp" />
<ClCompile Include="..\src\GUIManager\GUIManager.cpp" />
<ClCompile Include="..\src\GUIManager\KeyboardWidget.cpp" />
<ClCompile Include="..\src\GUIManager\WidgetXmlParsers.cpp" />
<ClCompile Include="..\src\HalibutAnimation\HalibutAnimation.cpp" />
<ClCompile Include="..\src\LightManager\LightManager.cpp" />

View File

@ -3,6 +3,7 @@
#include "include/Render/RenderMisc.h"
#include "include/GUIManager/ButtonWidget.h"
#include "include/GUIManager/KeyboardWidget.h"
#include "include/GUIManager/WidgetXmlParsers.h"
#include "include/Utils/Utils.h"
#include "include/ScriptManager/ScriptManager.h"
@ -142,6 +143,8 @@ public:
boost::signal<void(int)> KeyPressedSignal;
//boost::signal<void()> PostUpdateSignal;
TGUIManager();
~TGUIManager();
void AddWidget(std::shared_ptr<TInstancingWidgetAncestor> widgetAncestor, const std::string& name, const std::string& groupName, int order = 0);

View File

@ -15,6 +15,9 @@ Use global variable Console like that:
#ifdef TARGET_WIN32
#include <fstream>
#endif
#ifdef TARGET_LINUX
#include <fstream>
#endif
#ifdef TARGET_ANDROID
#include <asm/page.h>
#include <limits.h>
@ -88,6 +91,28 @@ public:
#endif
#ifdef TARGET_LINUX
class TFileConsole : public TSimpleConsole
{
protected:
std::string filename;
std::ofstream f;
public:
TFileConsole();
TFileConsole(const std::string& Afilename);
~TFileConsole();
TFileConsole& operator<<(const std::string& s);
void PrintImmediate(const std::string& s);
};
#endif
#ifdef TARGET_ANDROID
class TJavaConsole : public TSimpleConsole

View File

@ -15,6 +15,10 @@ namespace SE
extern TFileConsole* Console;
#endif
#ifdef TARGET_LINUX
extern TFileConsole* Console;
#endif
#ifdef TARGET_ANDROID
extern TJavaConsole* Console;
#endif

View File

@ -158,6 +158,51 @@ boost::shared_array<TYPENAME> CreateMemFromFile(const std::string& fileName, car
}
#endif
#ifdef TARGET_LINUX
template<typename TYPENAME>
boost::shared_array<TYPENAME> CreateMemFromFile(const std::string& fileName, cardinal& intCount)
{
cardinal SIZEOF_TYPENAME = sizeof(TYPENAME);
FILE * pFile;
long fSize;
size_t result;
TYPENAME* fileData;
if (fopen(&pFile, fileName.c_str(), "rb" ) != 0)
{
throw ErrorToLog("File not loaded: " + fileName);
}
// obtain file size:
fseek (pFile , 0 , SEEK_END);
fSize = ftell (pFile);
rewind (pFile);
fileData = new TYPENAME [fSize % SIZEOF_TYPENAME == 0 ? fSize/SIZEOF_TYPENAME : fSize/SIZEOF_TYPENAME + 1];
result = fread (&fileData[0], 1, fSize, pFile);
if (result != fSize)
{
throw ErrorToLog("File not loaded: " + fileName);
}
// terminate
fclose (pFile);
intCount = fSize;
return boost::shared_array<TYPENAME>(fileData);
}
#endif
#ifdef TARGET_ANDROID
template<typename TYPENAME>

View File

@ -9,6 +9,11 @@ const std::string CONST_CLICK_SIGNAL_NAME = "OnClick";
const std::string CONST_DRAG_SIGNAL_NAME = "OnDrag";
TGUIManager::TGUIManager()
{
}
TGUIManager::~TGUIManager()
{

View File

@ -17,7 +17,6 @@ TSalmonRenderer* Renderer;
TIosConsole* Console;
TSalmonRendererIos* Renderer;
#endif
TResourceManager* ResourceManager;

View File

@ -140,6 +140,55 @@ void TFileConsole::PrintImmediate(const std::string& s)
#endif
#ifdef TARGET_LINUX
TFileConsole::TFileConsole()
: filename("conlog.txt")
, f("conlog.txt")
{
}
TFileConsole::TFileConsole(const std::string& Afilename)
: filename(Afilename)
, f(Afilename)
{
}
TFileConsole::~TFileConsole()
{
f.close();
}
TFileConsole& TFileConsole::operator<<(const std::string& s)
{
boost::posix_time::ptime t = boost::posix_time::second_clock::local_time();
std::string string_with_time_mark;
string_with_time_mark = to_simple_string(t)+": "+s;
PrintImmediate(string_with_time_mark);
History += string_with_time_mark+endl;
CutHistory();
return *this;
}
void TFileConsole::PrintImmediate(const std::string& s)
{
f<<s+endl;
f.flush();
}
#endif

View File

@ -80,6 +80,9 @@ std::string GetFilePathUserData(const std::string& filename)
#ifdef TARGET_WIN32
std::string realFileName = filename;
#endif
#ifdef TARGET_LINUX
std::string realFileName = filename;
#endif
#ifdef TARGET_ANDROID
std::string realFileName = JniGetApplicationDir()+"/" + filename;
#endif