📄 platform_util.h
字号:
// ==============================================================
// This file is part of Glest Shared Library (www.glest.org)
//
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
#ifndef _SHARED_PLATFORM_PLATFORMUTIL_H_
#define _SHARED_PLATFORM_PLATFORMUTIL_H_
#include <string>
#include <vector>
#include <stdexcept>
#include <SDL.h>
#include "types.h"
using std::string;
using std::vector;
using std::exception;
using Shared::Platform::int64;
namespace Shared{ namespace Platform{
// =====================================================
// class PerformanceTimer
// =====================================================
class PerformanceTimer{
private:
Uint32 lastTicks;
Uint32 updateTicks;
int times; // number of consecutive times
int maxTimes; // maximum number consecutive times
public:
void init(float fps, int maxTimes= -1);
bool isTime();
void reset();
};
// =====================================================
// class Chrono
// =====================================================
class Chrono {
private:
Uint32 startCount;
Uint32 accumCount;
Uint32 freq;
bool stopped;
public:
Chrono();
void start();
void stop();
int64 getMicros() const;
int64 getMillis() const;
int64 getSeconds() const;
private:
int64 queryCounter(int multiplier) const;
};
// =====================================================
// class PlatformExceptionHandler
// =====================================================
class PlatformExceptionHandler {
public:
virtual ~PlatformExceptionHandler() {}
void install(string dumpFileName) {}
virtual void handle()=0;
};
// =====================================================
// Misc
// =====================================================
void findAll(const string &path, vector<string> &results, bool cutExtension=false);
bool changeVideoMode(int resH, int resW, int colorBits, int refreshFrequency);
void restoreVideoMode();
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
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -