moved common platform code into shared are for win32 projects

This commit is contained in:
Mark Vejvoda
2010-04-30 19:01:47 +00:00
parent 3e7f3ed485
commit b10bb3c2bc
11 changed files with 47 additions and 902 deletions

View File

@@ -108,14 +108,14 @@ private:
int lastMouseX[3];
int lastMouseY[3];
static unsigned int lastMouseEvent; /** for use in mouse hover calculations */
static int64 lastMouseEvent; /** for use in mouse hover calculations */
static MouseState mouseState;
static Vec2i mousePos;
static bool isKeyPressedDown;
static bool isFullScreen;
static SDL_keysym keystate;
static void setLastMouseEvent(unsigned int lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;}
static void setLastMouseEvent(int64 lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;}
static unsigned int getLastMouseEvent() {return Window::lastMouseEvent;}
static const MouseState &getMouseState() {return Window::mouseState;}

View File

@@ -13,87 +13,16 @@
#define _SHARED_PLATFORM_PLATFORMUTIL_H_
#include <windows.h>
#include <string>
#include <vector>
#include <stdexcept>
#include <list>
#include "types.h"
#include "checksum.h"
#include <utility>
#include "platform_common.h"
using namespace Shared::PlatformCommon;
using std::string;
using std::vector;
using std::exception;
using std::list;
using Shared::Platform::int64;
using Shared::Util::Checksum;
namespace Shared{ namespace Platform{
// =====================================================
// class PerformanceTimer
// =====================================================
class PerformanceTimer{
private:
int64 thisTicks;
int64 lastTicks;
int64 updateTicks;
int times; // number of consecutive times
int maxTimes; // maximum number consecutive times
public:
void init(int fps, int maxTimes= -1);
bool isTime();
void reset();
};
// =====================================================
// class Chrono
// =====================================================
class Chrono{
private:
int64 startCount;
int64 accumCount;
static int64 freq;
bool stopped;
public:
Chrono();
void start();
void stop();
int64 getMicros() const;
int64 getMillis() const;
int64 getSeconds() const;
static int64 getCurTicks();
static int64 getCurMillis();
private:
int64 queryCounter(int multiplier) const;
};
// =====================================================
// class ModeInfo
// =====================================================
class ModeInfo {
public:
int width;
int height;
int depth;
ModeInfo(int width, int height, int depth);
string getString() const;
};
// =====================================================
// class PlatformExceptionHandler
// =====================================================
@@ -117,36 +46,9 @@ public:
// =====================================================
// Misc
// =====================================================
void Tokenize(const string& str,vector<string>& tokens,const string& delimiters = " ");
bool isdir(const char *path);
void findDirs(const vector<string> &paths, vector<string> &results, bool errorOnNotFound=false);
void findAll(const vector<string> &paths, const string &fileFilter, vector<string> &results, bool cutExtension=false, bool errorOnNotFound=true);
void findAll(const string &path, vector<string> &results, bool cutExtension=false, bool errorOnNotFound=true);
int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum);
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum);
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(vector<string> paths, string pathSearchString, const string filterFileExt, vector<std::pair<string,int32> > *recursiveMap);
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(const string &path, const string &filterFileExt, vector<std::pair<string,int32> > *recursiveMap);
void createDirectoryPaths(string Path);
string extractDirectoryPathFromFile(string filename);
string extractExtension(const string& filename);
void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight);
void getFullscreenVideoModes(list<ModeInfo> *modeinfos);
bool changeVideoMode(int resH, int resW, int colorBits, int refreshFrequency);
void restoreVideoMode(bool exitingApp=false);
bool EndsWith(const string &str, const string& key);
void message(string message);
bool ask(string message);
void exceptionMessage(const exception &excp);
int getScreenW();
int getScreenH();
void sleep(int millis);
void showCursor(bool b);
bool isKeyDown(int virtualKey);
string getCommandLine();
}}//end namespace