mirror of
https://github.com/glest/glest-source.git
synced 2025-09-02 20:42:34 +02:00
global:reformat source
indent -i2 -nut -bl -bli0 -ppi3 -nce -npsl
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -21,122 +21,161 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>
|
// along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||||
|
|
||||||
#ifndef _GLEST_GAME_CONFIG_H_
|
#ifndef _GLEST_GAME_CONFIG_H_
|
||||||
#define _GLEST_GAME_CONFIG_H_
|
# define _GLEST_GAME_CONFIG_H_
|
||||||
|
|
||||||
#ifdef WIN32
|
# ifdef WIN32
|
||||||
#include <winsock2.h>
|
# include <winsock2.h>
|
||||||
#include <winsock.h>
|
# include <winsock.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#include "properties.h"
|
# include "properties.h"
|
||||||
#include <vector>
|
# include <vector>
|
||||||
#include "game_constants.h"
|
# include "game_constants.h"
|
||||||
#include <SDL.h>
|
# include <SDL.h>
|
||||||
#include "leak_dumper.h"
|
# include "leak_dumper.h"
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest
|
||||||
|
{
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
|
||||||
using Shared::Util::Properties;
|
using Shared::Util::Properties;
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Config
|
// class Config
|
||||||
//
|
//
|
||||||
// Game configuration
|
// Game configuration
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
enum ConfigType {
|
enum ConfigType
|
||||||
cfgMainGame,
|
{
|
||||||
cfgUserGame,
|
cfgMainGame,
|
||||||
cfgTempGame,
|
cfgUserGame,
|
||||||
cfgMainKeys,
|
cfgTempGame,
|
||||||
cfgUserKeys,
|
cfgMainKeys,
|
||||||
cfgTempKeys
|
cfgUserKeys,
|
||||||
};
|
cfgTempKeys
|
||||||
|
};
|
||||||
|
|
||||||
class Config {
|
class Config
|
||||||
private:
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
std::pair<Properties,Properties> properties;
|
std::pair < Properties, Properties > properties;
|
||||||
Properties tempProperties;
|
Properties tempProperties;
|
||||||
std::pair<ConfigType,ConfigType> cfgType;
|
std::pair < ConfigType, ConfigType > cfgType;
|
||||||
std::pair<string,string> fileNameParameter;
|
std::pair < string, string > fileNameParameter;
|
||||||
std::pair<string,string> fileName;
|
std::pair < string, string > fileName;
|
||||||
std::pair<bool,bool> fileLoaded;
|
std::pair < bool, bool > fileLoaded;
|
||||||
string custom_path_parameter;
|
string custom_path_parameter;
|
||||||
|
|
||||||
static map<ConfigType,Config> configList;
|
static map < ConfigType, Config > configList;
|
||||||
|
|
||||||
static const char *glest_ini_filename;
|
static const char *glest_ini_filename;
|
||||||
static const char *glestuser_ini_filename;
|
static const char *glestuser_ini_filename;
|
||||||
|
|
||||||
static map<string,string> customRuntimeProperties;
|
static map < string, string > customRuntimeProperties;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const char *glestkeys_ini_filename;
|
static const char *glestkeys_ini_filename;
|
||||||
static const char *glestuserkeys_ini_filename;
|
static const char *glestuserkeys_ini_filename;
|
||||||
|
|
||||||
static const char *ACTIVE_MOD_PROPERTY_NAME;
|
static const char *ACTIVE_MOD_PROPERTY_NAME;
|
||||||
|
|
||||||
static const char *colorPicking;
|
static const char *colorPicking;
|
||||||
static const char *selectBufPicking;
|
static const char *selectBufPicking;
|
||||||
static const char *frustumPicking;
|
static const char *frustumPicking;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Config();
|
Config ();
|
||||||
Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist,string custom_path="");
|
Config (std::pair < ConfigType, ConfigType > type, std::pair < string,
|
||||||
bool tryCustomPath(std::pair<ConfigType,ConfigType> &type, std::pair<string,string> &file, string custom_path);
|
string > file, std::pair < bool, bool > fileMustExist,
|
||||||
static void CopyAll(Config *src,Config *dest);
|
string custom_path = "");
|
||||||
vector<pair<string,string> > getPropertiesFromContainer(const Properties &propertiesObj) const;
|
bool tryCustomPath (std::pair < ConfigType, ConfigType > &type,
|
||||||
static bool replaceFileWithLocalFile(const vector<string> &dirList, string fileNamePart, string &resultToReplace);
|
std::pair < string, string > &file,
|
||||||
|
string custom_path);
|
||||||
|
static void CopyAll (Config * src, Config * dest);
|
||||||
|
vector < pair < string,
|
||||||
|
string >
|
||||||
|
>getPropertiesFromContainer (const Properties & propertiesObj) const;
|
||||||
|
static bool replaceFileWithLocalFile (const vector < string > &dirList,
|
||||||
|
string fileNamePart,
|
||||||
|
string & resultToReplace);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static Config &getInstance(std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame) ,
|
static Config & getInstance (std::pair < ConfigType, ConfigType > type =
|
||||||
std::pair<string,string> file = std::make_pair(glest_ini_filename,glestuser_ini_filename) ,
|
std::make_pair (cfgMainGame, cfgUserGame),
|
||||||
std::pair<bool,bool> fileMustExist = std::make_pair(true,false),string custom_path="" );
|
std::pair < string, string > file =
|
||||||
void save(const string &path="");
|
std::make_pair (glest_ini_filename,
|
||||||
void reload();
|
glestuser_ini_filename),
|
||||||
|
std::pair < bool, bool > fileMustExist =
|
||||||
|
std::make_pair (true, false),
|
||||||
|
string custom_path = "");
|
||||||
|
void save (const string & path = "");
|
||||||
|
void reload ();
|
||||||
|
|
||||||
int getInt(const string &key,const char *defaultValueIfNotFound=NULL) const;
|
int getInt (const string & key, const char *defaultValueIfNotFound =
|
||||||
bool getBool(const string &key,const char *defaultValueIfNotFound=NULL) const;
|
NULL) const;
|
||||||
float getFloat(const string &key,const char *defaultValueIfNotFound=NULL) const;
|
bool getBool (const string & key, const char *defaultValueIfNotFound =
|
||||||
const string getString(const string &key,const char *defaultValueIfNotFound=NULL) const;
|
NULL) const;
|
||||||
|
float getFloat (const string & key, const char *defaultValueIfNotFound =
|
||||||
|
NULL) const;
|
||||||
|
const string getString (const string & key,
|
||||||
|
const char *defaultValueIfNotFound =
|
||||||
|
NULL) const;
|
||||||
|
|
||||||
int getInt(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
int getInt (const char *key, const char *defaultValueIfNotFound =
|
||||||
bool getBool(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
NULL) const;
|
||||||
float getFloat(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
bool getBool (const char *key, const char *defaultValueIfNotFound =
|
||||||
const string getString(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
NULL) const;
|
||||||
//char getCharKey(const char *key) const;
|
float getFloat (const char *key, const char *defaultValueIfNotFound =
|
||||||
SDL_Keycode getSDLKey(const char *key) const;
|
NULL) const;
|
||||||
|
const string getString (const char *key,
|
||||||
|
const char *defaultValueIfNotFound =
|
||||||
|
NULL) const;
|
||||||
|
//char getCharKey(const char *key) const;
|
||||||
|
SDL_Keycode getSDLKey (const char *key) const;
|
||||||
|
|
||||||
void setInt(const string &key, int value, bool tempBuffer=false);
|
void setInt (const string & key, int value, bool tempBuffer = false);
|
||||||
void setBool(const string &key, bool value, bool tempBuffer=false);
|
void setBool (const string & key, bool value, bool tempBuffer = false);
|
||||||
void setFloat(const string &key, float value, bool tempBuffer=false);
|
void setFloat (const string & key, float value, bool tempBuffer =
|
||||||
void setString(const string &key, const string &value, bool tempBuffer=false);
|
false);
|
||||||
|
void setString (const string & key, const string & value,
|
||||||
|
bool tempBuffer = false);
|
||||||
|
|
||||||
vector<string> getPathListForType(PathType type, string scenarioDir = "");
|
vector < string > getPathListForType (PathType type,
|
||||||
|
string scenarioDir = "");
|
||||||
|
|
||||||
vector<pair<string,string> > getMergedProperties() const;
|
vector < pair < string, string > >getMergedProperties () const;
|
||||||
vector<pair<string,string> > getMasterProperties() const;
|
vector < pair < string, string > >getMasterProperties () const;
|
||||||
vector<pair<string,string> > getUserProperties() const;
|
vector < pair < string, string > >getUserProperties () const;
|
||||||
void setUserProperties(const vector<pair<string,string> > &valueList);
|
void setUserProperties (const vector < pair < string,
|
||||||
|
string > >&valueList);
|
||||||
|
|
||||||
string getFileName(bool userFilename) const;
|
string getFileName (bool userFilename) const;
|
||||||
|
|
||||||
SDL_Keycode translateStringToSDLKey(const string &value) const;
|
SDL_Keycode translateStringToSDLKey (const string & value) const;
|
||||||
|
|
||||||
string toString();
|
string toString ();
|
||||||
|
|
||||||
static string getCustomRuntimeProperty(string key) { return customRuntimeProperties[key]; }
|
static string getCustomRuntimeProperty (string key)
|
||||||
static void setCustomRuntimeProperty(string key, string value) { customRuntimeProperties[key] = value; }
|
{
|
||||||
|
return customRuntimeProperties[key];
|
||||||
|
}
|
||||||
|
static void setCustomRuntimeProperty (string key, string value)
|
||||||
|
{
|
||||||
|
customRuntimeProperties[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
static string findValidLocalFileFromPath(string fileName);
|
static string findValidLocalFileFromPath (string fileName);
|
||||||
|
|
||||||
static string getMapPath(const string &mapName, string scenarioDir="", bool errorOnNotFound=true);
|
static string getMapPath (const string & mapName, string scenarioDir =
|
||||||
};
|
"", bool errorOnNotFound = true);
|
||||||
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}} //end namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -19,263 +19,342 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#ifndef _GLEST_GAME_COREDATA_H_
|
#ifndef _GLEST_GAME_COREDATA_H_
|
||||||
#define _GLEST_GAME_COREDATA_H_
|
# define _GLEST_GAME_COREDATA_H_
|
||||||
|
|
||||||
#ifdef WIN32
|
# ifdef WIN32
|
||||||
#include <winsock2.h>
|
# include <winsock2.h>
|
||||||
#include <winsock.h>
|
# include <winsock.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#include <string>
|
# include <string>
|
||||||
#include "sound.h"
|
# include "sound.h"
|
||||||
#include "font.h"
|
# include "font.h"
|
||||||
#include "texture.h"
|
# include "texture.h"
|
||||||
#include "sound_container.h"
|
# include "sound_container.h"
|
||||||
#include "leak_dumper.h"
|
# include "leak_dumper.h"
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest
|
||||||
|
{
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
|
||||||
using ::Shared::Graphics::Texture2D;
|
using::Shared::Graphics::Texture2D;
|
||||||
using ::Shared::Graphics::Texture3D;
|
using::Shared::Graphics::Texture3D;
|
||||||
using ::Shared::Graphics::Font;
|
using::Shared::Graphics::Font;
|
||||||
using ::Shared::Graphics::Font2D;
|
using::Shared::Graphics::Font2D;
|
||||||
using ::Shared::Graphics::Font3D;
|
using::Shared::Graphics::Font3D;
|
||||||
using ::Shared::Graphics::FontChangedCallbackInterface;
|
using::Shared::Graphics::FontChangedCallbackInterface;
|
||||||
using ::Shared::Sound::StrSound;
|
using::Shared::Sound::StrSound;
|
||||||
using ::Shared::Sound::StaticSound;
|
using::Shared::Sound::StaticSound;
|
||||||
|
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class CoreData
|
// class CoreData
|
||||||
//
|
//
|
||||||
/// Data shared among all the ProgramStates
|
/// Data shared among all the ProgramStates
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class GameSettings;
|
class GameSettings;
|
||||||
|
|
||||||
class CoreData {
|
class CoreData
|
||||||
private:
|
{
|
||||||
std::map<int,bool> itemLoadAttempted;
|
private:
|
||||||
|
std::map < int, bool > itemLoadAttempted;
|
||||||
|
|
||||||
StrSound introMusic;
|
StrSound introMusic;
|
||||||
StrSound menuMusic;
|
StrSound menuMusic;
|
||||||
StaticSound clickSoundA;
|
StaticSound clickSoundA;
|
||||||
StaticSound clickSoundB;
|
StaticSound clickSoundB;
|
||||||
StaticSound clickSoundC;
|
StaticSound clickSoundC;
|
||||||
StaticSound attentionSound;
|
StaticSound attentionSound;
|
||||||
StaticSound highlightSound;
|
StaticSound highlightSound;
|
||||||
StaticSound markerSound;
|
StaticSound markerSound;
|
||||||
SoundContainer waterSounds;
|
SoundContainer waterSounds;
|
||||||
|
|
||||||
Texture2D *logoTexture;
|
Texture2D *logoTexture;
|
||||||
std::vector<Texture2D *> logoTextureList;
|
std::vector < Texture2D * >logoTextureList;
|
||||||
Texture2D *backgroundTexture;
|
Texture2D *backgroundTexture;
|
||||||
Texture2D *fireTexture;
|
Texture2D *fireTexture;
|
||||||
Texture2D *teamColorTexture;
|
Texture2D *teamColorTexture;
|
||||||
Texture2D *snowTexture;
|
Texture2D *snowTexture;
|
||||||
Texture2D *waterSplashTexture;
|
Texture2D *waterSplashTexture;
|
||||||
Texture2D *customTexture;
|
Texture2D *customTexture;
|
||||||
Texture2D *buttonSmallTexture;
|
Texture2D *buttonSmallTexture;
|
||||||
Texture2D *buttonBigTexture;
|
Texture2D *buttonBigTexture;
|
||||||
Texture2D *horizontalLineTexture;
|
Texture2D *horizontalLineTexture;
|
||||||
Texture2D *verticalLineTexture;
|
Texture2D *verticalLineTexture;
|
||||||
Texture2D *checkBoxTexture;
|
Texture2D *checkBoxTexture;
|
||||||
Texture2D *checkedCheckBoxTexture;
|
Texture2D *checkedCheckBoxTexture;
|
||||||
Texture2D *gameWinnerTexture;
|
Texture2D *gameWinnerTexture;
|
||||||
Texture2D *notOnServerTexture;
|
Texture2D *notOnServerTexture;
|
||||||
Texture2D *onServerDifferentTexture;
|
Texture2D *onServerDifferentTexture;
|
||||||
Texture2D *onServerTexture;
|
Texture2D *onServerTexture;
|
||||||
Texture2D *onServerInstalledTexture;
|
Texture2D *onServerInstalledTexture;
|
||||||
Texture2D *statusReadyTexture;
|
Texture2D *statusReadyTexture;
|
||||||
Texture2D *statusNotReadyTexture;
|
Texture2D *statusNotReadyTexture;
|
||||||
Texture2D *statusBRBTexture;
|
Texture2D *statusBRBTexture;
|
||||||
|
|
||||||
Texture2D *healthbarTexture;
|
Texture2D *healthbarTexture;
|
||||||
Texture2D *healthbarBackgroundTexture;
|
Texture2D *healthbarBackgroundTexture;
|
||||||
|
|
||||||
std::vector<Texture2D *> miscTextureList;
|
std::vector < Texture2D * >miscTextureList;
|
||||||
|
|
||||||
Font2D *displayFont;
|
Font2D *displayFont;
|
||||||
Font2D *menuFontNormal;
|
Font2D *menuFontNormal;
|
||||||
Font2D *displayFontSmall;
|
Font2D *displayFontSmall;
|
||||||
Font2D *menuFontBig;
|
Font2D *menuFontBig;
|
||||||
Font2D *menuFontVeryBig;
|
Font2D *menuFontVeryBig;
|
||||||
Font2D *consoleFont;
|
Font2D *consoleFont;
|
||||||
|
|
||||||
Font3D *displayFont3D;
|
Font3D *displayFont3D;
|
||||||
Font3D *menuFontNormal3D;
|
Font3D *menuFontNormal3D;
|
||||||
Font3D *displayFontSmall3D;
|
Font3D *displayFontSmall3D;
|
||||||
Font3D *menuFontBig3D;
|
Font3D *menuFontBig3D;
|
||||||
Font3D *menuFontVeryBig3D;
|
Font3D *menuFontVeryBig3D;
|
||||||
Font3D *consoleFont3D;
|
Font3D *consoleFont3D;
|
||||||
|
|
||||||
string introVideoFilename;
|
string introVideoFilename;
|
||||||
string introVideoFilenameFallback;
|
string introVideoFilenameFallback;
|
||||||
|
|
||||||
string mainMenuVideoFilename;
|
string mainMenuVideoFilename;
|
||||||
string mainMenuVideoFilenameFallback;
|
string mainMenuVideoFilenameFallback;
|
||||||
|
|
||||||
string battleEndWinVideoFilename;
|
string battleEndWinVideoFilename;
|
||||||
string battleEndWinVideoFilenameFallback;
|
string battleEndWinVideoFilenameFallback;
|
||||||
string battleEndWinMusicFilename;
|
string battleEndWinMusicFilename;
|
||||||
|
|
||||||
string battleEndLoseVideoFilename;
|
string battleEndLoseVideoFilename;
|
||||||
string battleEndLoseVideoFilenameFallback;
|
string battleEndLoseVideoFilenameFallback;
|
||||||
string battleEndLoseMusicFilename;
|
string battleEndLoseMusicFilename;
|
||||||
|
|
||||||
std::map<std::string,std::vector<FontChangedCallbackInterface *> > registeredFontChangedCallbacks;
|
std::map < std::string,
|
||||||
public:
|
std::vector <
|
||||||
|
FontChangedCallbackInterface * >>registeredFontChangedCallbacks;
|
||||||
|
public:
|
||||||
|
|
||||||
enum TextureSystemType {
|
enum TextureSystemType
|
||||||
tsyst_NONE,
|
{
|
||||||
tsyst_logoTexture,
|
tsyst_NONE,
|
||||||
tsyst_backgroundTexture,
|
tsyst_logoTexture,
|
||||||
tsyst_fireTexture,
|
tsyst_backgroundTexture,
|
||||||
tsyst_teamColorTexture,
|
tsyst_fireTexture,
|
||||||
tsyst_snowTexture,
|
tsyst_teamColorTexture,
|
||||||
tsyst_waterSplashTexture,
|
tsyst_snowTexture,
|
||||||
tsyst_customTexture,
|
tsyst_waterSplashTexture,
|
||||||
tsyst_buttonSmallTexture,
|
tsyst_customTexture,
|
||||||
tsyst_buttonBigTexture,
|
tsyst_buttonSmallTexture,
|
||||||
tsyst_horizontalLineTexture,
|
tsyst_buttonBigTexture,
|
||||||
tsyst_verticalLineTexture,
|
tsyst_horizontalLineTexture,
|
||||||
tsyst_checkBoxTexture,
|
tsyst_verticalLineTexture,
|
||||||
tsyst_checkedCheckBoxTexture,
|
tsyst_checkBoxTexture,
|
||||||
tsyst_gameWinnerTexture,
|
tsyst_checkedCheckBoxTexture,
|
||||||
tsyst_notOnServerTexture,
|
tsyst_gameWinnerTexture,
|
||||||
tsyst_onServerDifferentTexture,
|
tsyst_notOnServerTexture,
|
||||||
tsyst_onServerTexture,
|
tsyst_onServerDifferentTexture,
|
||||||
tsyst_onServerInstalledTexture,
|
tsyst_onServerTexture,
|
||||||
tsyst_statusReadyTexture,
|
tsyst_onServerInstalledTexture,
|
||||||
tsyst_statusNotReadyTexture,
|
tsyst_statusReadyTexture,
|
||||||
tsyst_statusBRBTexture,
|
tsyst_statusNotReadyTexture,
|
||||||
tsyst_healthbarTexture,
|
tsyst_statusBRBTexture,
|
||||||
tsyst_healthbarBackgroundTexture,
|
tsyst_healthbarTexture,
|
||||||
|
tsyst_healthbarBackgroundTexture,
|
||||||
|
|
||||||
tsyst_COUNT
|
tsyst_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
~CoreData();
|
~CoreData ();
|
||||||
static CoreData &getInstance();
|
static CoreData & getInstance ();
|
||||||
|
|
||||||
void load();
|
void load ();
|
||||||
void cleanup();
|
void cleanup ();
|
||||||
void loadFonts();
|
void loadFonts ();
|
||||||
|
|
||||||
// Textures
|
// Textures
|
||||||
Texture2D *getTextureBySystemId(TextureSystemType type);
|
Texture2D *getTextureBySystemId (TextureSystemType type);
|
||||||
|
|
||||||
Texture2D *getBackgroundTexture();
|
Texture2D *getBackgroundTexture ();
|
||||||
Texture2D *getFireTexture();
|
Texture2D *getFireTexture ();
|
||||||
Texture2D *getTeamColorTexture();
|
Texture2D *getTeamColorTexture ();
|
||||||
Texture2D *getSnowTexture();
|
Texture2D *getSnowTexture ();
|
||||||
Texture2D *getLogoTexture();
|
Texture2D *getLogoTexture ();
|
||||||
Texture2D *getWaterSplashTexture();
|
Texture2D *getWaterSplashTexture ();
|
||||||
Texture2D *getCustomTexture();
|
Texture2D *getCustomTexture ();
|
||||||
Texture2D *getButtonSmallTexture();
|
Texture2D *getButtonSmallTexture ();
|
||||||
Texture2D *getButtonBigTexture();
|
Texture2D *getButtonBigTexture ();
|
||||||
Texture2D *getHorizontalLineTexture();
|
Texture2D *getHorizontalLineTexture ();
|
||||||
Texture2D *getVerticalLineTexture();
|
Texture2D *getVerticalLineTexture ();
|
||||||
Texture2D *getCheckBoxTexture();
|
Texture2D *getCheckBoxTexture ();
|
||||||
Texture2D *getCheckedCheckBoxTexture();
|
Texture2D *getCheckedCheckBoxTexture ();
|
||||||
Texture2D *getNotOnServerTexture();
|
Texture2D *getNotOnServerTexture ();
|
||||||
Texture2D *getOnServerDifferentTexture();
|
Texture2D *getOnServerDifferentTexture ();
|
||||||
Texture2D *getOnServerTexture();
|
Texture2D *getOnServerTexture ();
|
||||||
Texture2D *getOnServerInstalledTexture();
|
Texture2D *getOnServerInstalledTexture ();
|
||||||
Texture2D *getStatusReadyTexture();
|
Texture2D *getStatusReadyTexture ();
|
||||||
Texture2D *getStatusNotReadyTexture();
|
Texture2D *getStatusNotReadyTexture ();
|
||||||
Texture2D *getStatusBRBTexture();
|
Texture2D *getStatusBRBTexture ();
|
||||||
Texture2D *getGameWinnerTexture();
|
Texture2D *getGameWinnerTexture ();
|
||||||
|
|
||||||
Texture2D *getHealthbarTexture();
|
Texture2D *getHealthbarTexture ();
|
||||||
Texture2D *getHealthbarBackgroundTexture();
|
Texture2D *getHealthbarBackgroundTexture ();
|
||||||
|
|
||||||
size_t getLogoTextureExtraCount();
|
size_t getLogoTextureExtraCount ();
|
||||||
Texture2D *getLogoTextureExtra(int idx);
|
Texture2D *getLogoTextureExtra (int idx);
|
||||||
|
|
||||||
std::vector<Texture2D *> & getMiscTextureList();
|
std::vector < Texture2D * >&getMiscTextureList ();
|
||||||
|
|
||||||
// Sounds and Music
|
// Sounds and Music
|
||||||
StrSound *getIntroMusic();
|
StrSound *getIntroMusic ();
|
||||||
StrSound *getMenuMusic();
|
StrSound *getMenuMusic ();
|
||||||
|
|
||||||
StaticSound *getClickSoundA();
|
StaticSound *getClickSoundA ();
|
||||||
StaticSound *getClickSoundB();
|
StaticSound *getClickSoundB ();
|
||||||
StaticSound *getClickSoundC();
|
StaticSound *getClickSoundC ();
|
||||||
StaticSound *getAttentionSound();
|
StaticSound *getAttentionSound ();
|
||||||
StaticSound *getHighlightSound();
|
StaticSound *getHighlightSound ();
|
||||||
StaticSound *getMarkerSound();
|
StaticSound *getMarkerSound ();
|
||||||
StaticSound *getWaterSound();
|
StaticSound *getWaterSound ();
|
||||||
|
|
||||||
// Fonts
|
// Fonts
|
||||||
Font2D *getDisplayFont() const {return displayFont;}
|
Font2D *getDisplayFont () const
|
||||||
Font2D *getDisplayFontSmall() const {return displayFontSmall;}
|
{
|
||||||
Font2D *getMenuFontNormal() const {return menuFontNormal;}
|
return displayFont;
|
||||||
Font2D *getMenuFontBig() const {return menuFontBig;}
|
}
|
||||||
Font2D *getMenuFontVeryBig() const {return menuFontVeryBig;}
|
Font2D *getDisplayFontSmall () const
|
||||||
Font2D *getConsoleFont() const {return consoleFont;}
|
{
|
||||||
|
return displayFontSmall;
|
||||||
|
}
|
||||||
|
Font2D *getMenuFontNormal () const
|
||||||
|
{
|
||||||
|
return menuFontNormal;
|
||||||
|
}
|
||||||
|
Font2D *getMenuFontBig () const
|
||||||
|
{
|
||||||
|
return menuFontBig;
|
||||||
|
}
|
||||||
|
Font2D *getMenuFontVeryBig () const
|
||||||
|
{
|
||||||
|
return menuFontVeryBig;
|
||||||
|
}
|
||||||
|
Font2D *getConsoleFont () const
|
||||||
|
{
|
||||||
|
return consoleFont;
|
||||||
|
}
|
||||||
|
|
||||||
Font3D *getDisplayFont3D() const {return displayFont3D;}
|
Font3D *getDisplayFont3D () const
|
||||||
Font3D *getDisplayFontSmall3D() const {return displayFontSmall3D;}
|
{
|
||||||
Font3D *getMenuFontNormal3D() const {return menuFontNormal3D;}
|
return displayFont3D;
|
||||||
Font3D *getMenuFontBig3D() const {return menuFontBig3D;}
|
}
|
||||||
Font3D *getMenuFontVeryBig3D() const {return menuFontVeryBig3D;}
|
Font3D *getDisplayFontSmall3D () const
|
||||||
Font3D *getConsoleFont3D() const {return consoleFont3D;}
|
{
|
||||||
|
return displayFontSmall3D;
|
||||||
|
}
|
||||||
|
Font3D *getMenuFontNormal3D () const
|
||||||
|
{
|
||||||
|
return menuFontNormal3D;
|
||||||
|
}
|
||||||
|
Font3D *getMenuFontBig3D () const
|
||||||
|
{
|
||||||
|
return menuFontBig3D;
|
||||||
|
}
|
||||||
|
Font3D *getMenuFontVeryBig3D () const
|
||||||
|
{
|
||||||
|
return menuFontVeryBig3D;
|
||||||
|
}
|
||||||
|
Font3D *getConsoleFont3D () const
|
||||||
|
{
|
||||||
|
return consoleFont3D;
|
||||||
|
}
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
string getMainMenuVideoFilename() const { return mainMenuVideoFilename; }
|
string getMainMenuVideoFilename () const
|
||||||
bool hasMainMenuVideoFilename() const;
|
{
|
||||||
string getMainMenuVideoFilenameFallback() const { return mainMenuVideoFilenameFallback; }
|
return mainMenuVideoFilename;
|
||||||
bool hasMainMenuVideoFilenameFallback() const;
|
}
|
||||||
|
bool hasMainMenuVideoFilename () const;
|
||||||
|
string getMainMenuVideoFilenameFallback () const
|
||||||
|
{
|
||||||
|
return mainMenuVideoFilenameFallback;
|
||||||
|
}
|
||||||
|
bool hasMainMenuVideoFilenameFallback () const;
|
||||||
|
|
||||||
string getIntroVideoFilename() const { return introVideoFilename; }
|
string getIntroVideoFilename () const
|
||||||
bool hasIntroVideoFilename() const;
|
{
|
||||||
string getIntroVideoFilenameFallback() const { return introVideoFilenameFallback; }
|
return introVideoFilename;
|
||||||
bool hasIntroVideoFilenameFallback() const;
|
}
|
||||||
|
bool hasIntroVideoFilename () const;
|
||||||
|
string getIntroVideoFilenameFallback () const
|
||||||
|
{
|
||||||
|
return introVideoFilenameFallback;
|
||||||
|
}
|
||||||
|
bool hasIntroVideoFilenameFallback () const;
|
||||||
|
|
||||||
string getBattleEndVideoFilename(bool won) const { return won == true ? battleEndWinVideoFilename : battleEndLoseVideoFilename; }
|
string getBattleEndVideoFilename (bool won) const
|
||||||
//bool hasBattleEndVideoFilename(bool won) const;
|
{
|
||||||
string getBattleEndVideoFilenameFallback(bool won) const { return won == true ? battleEndWinVideoFilenameFallback : battleEndLoseVideoFilenameFallback; }
|
return won ==
|
||||||
bool hasBattleEndVideoFilenameFallback(bool won) const;
|
true ? battleEndWinVideoFilename : battleEndLoseVideoFilename;
|
||||||
|
}
|
||||||
|
//bool hasBattleEndVideoFilename(bool won) const;
|
||||||
|
string getBattleEndVideoFilenameFallback (bool won) const
|
||||||
|
{
|
||||||
|
return won ==
|
||||||
|
true ? battleEndWinVideoFilenameFallback :
|
||||||
|
battleEndLoseVideoFilenameFallback;
|
||||||
|
}
|
||||||
|
bool hasBattleEndVideoFilenameFallback (bool won) const;
|
||||||
|
|
||||||
string getBattleEndMusicFilename(bool won) const { return won == true ? battleEndWinMusicFilename : battleEndLoseMusicFilename; }
|
string getBattleEndMusicFilename (bool won) const
|
||||||
|
{
|
||||||
|
return won ==
|
||||||
|
true ? battleEndWinMusicFilename : battleEndLoseMusicFilename;
|
||||||
|
}
|
||||||
|
|
||||||
void saveGameSettingsToFile(std::string fileName, GameSettings *gameSettings,int advancedIndex=0);
|
void saveGameSettingsToFile (std::string fileName,
|
||||||
bool loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings);
|
GameSettings * gameSettings,
|
||||||
|
int advancedIndex = 0);
|
||||||
|
bool loadGameSettingsFromFile (std::string fileName,
|
||||||
|
GameSettings * gameSettings);
|
||||||
|
|
||||||
void registerFontChangedCallback(std::string entityName, FontChangedCallbackInterface *cb);
|
void registerFontChangedCallback (std::string entityName,
|
||||||
void unRegisterFontChangedCallback(std::string entityName);
|
FontChangedCallbackInterface * cb);
|
||||||
private:
|
void unRegisterFontChangedCallback (std::string entityName);
|
||||||
|
private:
|
||||||
|
|
||||||
CoreData();
|
CoreData ();
|
||||||
|
|
||||||
int computeFontSize(int size);
|
int computeFontSize (int size);
|
||||||
void cleanupTexture(Texture2D **texture);
|
void cleanupTexture (Texture2D ** texture);
|
||||||
void loadTextures(string data_path);
|
void loadTextures (string data_path);
|
||||||
void loadSounds(string data_path);
|
void loadSounds (string data_path);
|
||||||
void loadMusic(string data_path);
|
void loadMusic (string data_path);
|
||||||
void loadIntroMedia(string data_path);
|
void loadIntroMedia (string data_path);
|
||||||
void loadMainMenuMedia(string data_path);
|
void loadMainMenuMedia (string data_path);
|
||||||
void loadBattleEndMedia(string data_path);
|
void loadBattleEndMedia (string data_path);
|
||||||
|
|
||||||
string getDataPath();
|
string getDataPath ();
|
||||||
void loadTextureIfRequired(Texture2D **tex,string data_path,
|
void loadTextureIfRequired (Texture2D ** tex, string data_path,
|
||||||
string uniqueFilePath, int texSystemId, bool setMipMap,
|
string uniqueFilePath, int texSystemId,
|
||||||
bool setAlpha, bool loadUniqueFilePath,
|
bool setMipMap, bool setAlpha,
|
||||||
bool compressionDisabled = false);
|
bool loadUniqueFilePath,
|
||||||
|
bool compressionDisabled = false);
|
||||||
|
|
||||||
void loadLogoTextureExtraIfRequired();
|
void loadLogoTextureExtraIfRequired ();
|
||||||
void loadMiscTextureListIfRequired();
|
void loadMiscTextureListIfRequired ();
|
||||||
|
|
||||||
void loadWaterSoundsIfRequired();
|
void loadWaterSoundsIfRequired ();
|
||||||
void loadMusicIfRequired();
|
void loadMusicIfRequired ();
|
||||||
|
|
||||||
void triggerFontChangedCallbacks(std::string fontUniqueId, Font *font);
|
void triggerFontChangedCallbacks (std::string fontUniqueId,
|
||||||
template<typename T> T * loadFont(Font *menuFontNormal, string menuFontNameNormal, int menuFontNameNormalSize, string fontType, string fontTypeFamily, string fontUniqueKey);
|
Font * font);
|
||||||
};
|
template < typename T > T * loadFont (Font * menuFontNormal,
|
||||||
|
string menuFontNameNormal,
|
||||||
|
int menuFontNameNormalSize,
|
||||||
|
string fontType,
|
||||||
|
string fontTypeFamily,
|
||||||
|
string fontUniqueKey);
|
||||||
|
};
|
||||||
|
|
||||||
}} //end namespace
|
}} //end namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,91 +1,120 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
// by the Free Software Foundation; either version 2 of the
|
// by the Free Software Foundation; either version 2 of the
|
||||||
// License, or (at your option) any later version
|
// License, or (at your option) any later version
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
#ifndef _GLEST_GAME_LANG_H_
|
#ifndef _GLEST_GAME_LANG_H_
|
||||||
#define _GLEST_GAME_LANG_H_
|
# define _GLEST_GAME_LANG_H_
|
||||||
|
|
||||||
#ifdef WIN32
|
# ifdef WIN32
|
||||||
#include <winsock2.h>
|
# include <winsock2.h>
|
||||||
#include <winsock.h>
|
# include <winsock.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#include "properties.h"
|
# include "properties.h"
|
||||||
#include "leak_dumper.h"
|
# include "leak_dumper.h"
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest
|
||||||
|
{
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
|
||||||
using Shared::Util::Properties;
|
using Shared::Util::Properties;
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Lang
|
// class Lang
|
||||||
//
|
//
|
||||||
// String table
|
// String table
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class Lang {
|
class Lang
|
||||||
private:
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
bool is_utf8_language;
|
bool is_utf8_language;
|
||||||
string language;
|
string language;
|
||||||
std::map<string,Properties> gameStringsAllLanguages;
|
std::map < string, Properties > gameStringsAllLanguages;
|
||||||
|
|
||||||
Properties scenarioStrings;
|
Properties scenarioStrings;
|
||||||
|
|
||||||
Properties tilesetStrings;
|
Properties tilesetStrings;
|
||||||
Properties tilesetStringsDefault;
|
Properties tilesetStringsDefault;
|
||||||
|
|
||||||
std::map<string, std::map<string, Properties> > techTreeStringsAllLanguages;
|
std::map < string, std::map < string,
|
||||||
string techNameLoaded;
|
Properties > >techTreeStringsAllLanguages;
|
||||||
bool allowNativeLanguageTechtree;
|
string techNameLoaded;
|
||||||
|
bool allowNativeLanguageTechtree;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Lang();
|
Lang ();
|
||||||
void loadGameStringProperties(string language, Properties &properties, bool fileMustExist,bool fallbackToDefault=false);
|
void loadGameStringProperties (string language, Properties & properties,
|
||||||
bool fileMatchesISO630Code(string uselanguage, string testLanguageFile);
|
bool fileMustExist,
|
||||||
string getNativeLanguageName(string uselanguage, string testLanguageFile);
|
bool fallbackToDefault = false);
|
||||||
|
bool fileMatchesISO630Code (string uselanguage,
|
||||||
|
string testLanguageFile);
|
||||||
|
string getNativeLanguageName (string uselanguage,
|
||||||
|
string testLanguageFile);
|
||||||
|
|
||||||
string parseResult(const string &key, const string &value);
|
string parseResult (const string & key, const string & value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Lang &getInstance();
|
static Lang & getInstance ();
|
||||||
|
|
||||||
string getTechNameLoaded() const { return techNameLoaded; }
|
string getTechNameLoaded () const
|
||||||
bool getAllowNativeLanguageTechtree() const { return allowNativeLanguageTechtree; }
|
{
|
||||||
void setAllowNativeLanguageTechtree(bool value) { allowNativeLanguageTechtree = value; }
|
return techNameLoaded;
|
||||||
|
}
|
||||||
|
bool getAllowNativeLanguageTechtree () const
|
||||||
|
{
|
||||||
|
return allowNativeLanguageTechtree;
|
||||||
|
}
|
||||||
|
void setAllowNativeLanguageTechtree (bool value)
|
||||||
|
{
|
||||||
|
allowNativeLanguageTechtree = value;
|
||||||
|
}
|
||||||
|
|
||||||
void loadGameStrings(string uselanguage, bool loadFonts=true, bool fallbackToDefault=false);
|
void loadGameStrings (string uselanguage, bool loadFonts =
|
||||||
void loadScenarioStrings(string scenarioDir, string scenarioName, bool isTutorial);
|
true, bool fallbackToDefault = false);
|
||||||
bool loadTechTreeStrings(string techTree, bool forceLoad=false);
|
void loadScenarioStrings (string scenarioDir, string scenarioName,
|
||||||
void loadTilesetStrings(string tileset);
|
bool isTutorial);
|
||||||
|
bool loadTechTreeStrings (string techTree, bool forceLoad = false);
|
||||||
|
void loadTilesetStrings (string tileset);
|
||||||
|
|
||||||
string getString(const string &s,string uselanguage="", bool fallbackToDefault=false);
|
string getString (const string & s, string uselanguage =
|
||||||
bool hasString(const string &s, string uselanguage="", bool fallbackToDefault=false);
|
"", bool fallbackToDefault = false);
|
||||||
|
bool hasString (const string & s, string uselanguage =
|
||||||
|
"", bool fallbackToDefault = false);
|
||||||
|
|
||||||
string getScenarioString(const string &s);
|
string getScenarioString (const string & s);
|
||||||
bool hasScenarioString(const string &s);
|
bool hasScenarioString (const string & s);
|
||||||
|
|
||||||
string getTechTreeString(const string &s, const char *defaultValue=NULL);
|
string getTechTreeString (const string & s, const char *defaultValue =
|
||||||
string getTilesetString(const string &s, const char *defaultValue=NULL);
|
NULL);
|
||||||
|
string getTilesetString (const string & s, const char *defaultValue =
|
||||||
|
NULL);
|
||||||
|
|
||||||
string getLanguage() const { return language; }
|
string getLanguage () const
|
||||||
bool isLanguageLocal(string compareLanguage) const;
|
{
|
||||||
//bool isUTF8Language() const;
|
return language;
|
||||||
string getDefaultLanguage() const;
|
}
|
||||||
|
bool isLanguageLocal (string compareLanguage) const;
|
||||||
|
//bool isUTF8Language() const;
|
||||||
|
string getDefaultLanguage () const;
|
||||||
|
|
||||||
map<string,string> getDiscoveredLanguageList(bool searchKeyIsLangName=false);
|
map < string,
|
||||||
pair<string,string> getNavtiveNameFromLanguageName(string langName);
|
string > getDiscoveredLanguageList (bool searchKeyIsLangName = false);
|
||||||
|
pair < string,
|
||||||
|
string > getNavtiveNameFromLanguageName (string langName);
|
||||||
|
|
||||||
string getLanguageFile(string uselanguage);
|
string getLanguageFile (string uselanguage);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}} //end namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,115 +1,132 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
// by the Free Software Foundation; either version 2 of the
|
// by the Free Software Foundation; either version 2 of the
|
||||||
// License, or (at your option) any later version
|
// License, or (at your option) any later version
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
#include "metrics.h"
|
#include "metrics.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "platform_util.h"
|
#include "platform_util.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest
|
||||||
|
{
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Metrics
|
// class Metrics
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
Metrics::Metrics() {
|
Metrics::Metrics ()
|
||||||
reloadData();
|
{
|
||||||
}
|
reloadData ();
|
||||||
|
}
|
||||||
|
|
||||||
void Metrics::reload(int resWidth, int resHeight) {
|
void Metrics::reload (int resWidth, int resHeight)
|
||||||
Metrics *metrics = getInstancePtr();
|
{
|
||||||
metrics->reloadData(resWidth, resHeight);
|
Metrics *metrics = getInstancePtr ();
|
||||||
}
|
metrics->reloadData (resWidth, resHeight);
|
||||||
|
}
|
||||||
|
|
||||||
void Metrics::reloadData(int resWidth, int resHeight) {
|
void Metrics::reloadData (int resWidth, int resHeight)
|
||||||
Config &config = Config::getInstance();
|
{
|
||||||
|
Config & config = Config::getInstance ();
|
||||||
virtualW= 1000;
|
|
||||||
virtualH= 750;
|
|
||||||
|
|
||||||
if(resWidth > 0) {
|
virtualW = 1000;
|
||||||
screenW= resWidth;
|
virtualH = 750;
|
||||||
}
|
|
||||||
else {
|
|
||||||
screenW= config.getInt("ScreenWidth");
|
|
||||||
}
|
|
||||||
if(resHeight > 0) {
|
|
||||||
screenH= resHeight;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
screenH= config.getInt("ScreenHeight");
|
|
||||||
}
|
|
||||||
|
|
||||||
minimapX= 10;
|
|
||||||
minimapY= 750-128-30+16;
|
|
||||||
minimapW= 128;
|
|
||||||
minimapH= 128;
|
|
||||||
|
|
||||||
displayX= 800;
|
if (resWidth > 0)
|
||||||
displayY= 250;
|
{
|
||||||
displayW= 128;
|
screenW = resWidth;
|
||||||
displayH= 480;
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
screenW = config.getInt ("ScreenWidth");
|
||||||
|
}
|
||||||
|
if (resHeight > 0)
|
||||||
|
{
|
||||||
|
screenH = resHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
screenH = config.getInt ("ScreenHeight");
|
||||||
|
}
|
||||||
|
|
||||||
Metrics * Metrics::getInstancePtr() {
|
minimapX = 10;
|
||||||
static Metrics metrics;
|
minimapY = 750 - 128 - 30 + 16;
|
||||||
return &metrics;
|
minimapW = 128;
|
||||||
}
|
minimapH = 128;
|
||||||
|
|
||||||
const Metrics &Metrics::getInstance(){
|
displayX = 800;
|
||||||
Metrics *metrics = getInstancePtr();
|
displayY = 250;
|
||||||
return *metrics;
|
displayW = 128;
|
||||||
}
|
displayH = 480;
|
||||||
|
}
|
||||||
|
|
||||||
float Metrics::getAspectRatio() const{
|
Metrics *Metrics::getInstancePtr ()
|
||||||
if(screenH == 0) {
|
{
|
||||||
throw megaglest_runtime_error("div by 0 screenH == 0");
|
static Metrics metrics;
|
||||||
}
|
return &metrics;
|
||||||
return static_cast<float>(screenW)/screenH;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int Metrics::toVirtualX(int w) const{
|
const Metrics & Metrics::getInstance ()
|
||||||
if(screenW == 0) {
|
{
|
||||||
throw megaglest_runtime_error("div by 0 screenW == 0");
|
Metrics *metrics = getInstancePtr ();
|
||||||
}
|
return *metrics;
|
||||||
return w*virtualW/screenW;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int Metrics::toVirtualY(int h) const{
|
float Metrics::getAspectRatio () const
|
||||||
if(screenH == 0) {
|
{
|
||||||
throw megaglest_runtime_error("div by 0 screenH == 0");
|
if (screenH == 0)
|
||||||
}
|
{
|
||||||
|
throw megaglest_runtime_error ("div by 0 screenH == 0");
|
||||||
|
}
|
||||||
|
return static_cast < float >(screenW) / screenH;
|
||||||
|
}
|
||||||
|
|
||||||
//printf("h [%d] virtualH [%d] screenH [%d] result = %d\n",h,virtualH,screenH,(h*virtualH/screenH));
|
int Metrics::toVirtualX (int w) const
|
||||||
|
{
|
||||||
|
if (screenW == 0)
|
||||||
|
{
|
||||||
|
throw megaglest_runtime_error ("div by 0 screenW == 0");
|
||||||
|
}
|
||||||
|
return w * virtualW / screenW;
|
||||||
|
}
|
||||||
|
|
||||||
return h*virtualH/screenH;
|
int Metrics::toVirtualY (int h) const
|
||||||
}
|
{
|
||||||
|
if (screenH == 0)
|
||||||
|
{
|
||||||
|
throw megaglest_runtime_error ("div by 0 screenH == 0");
|
||||||
|
}
|
||||||
|
|
||||||
bool Metrics::isInDisplay(int x, int y) const{
|
//printf("h [%d] virtualH [%d] screenH [%d] result = %d\n",h,virtualH,screenH,(h*virtualH/screenH));
|
||||||
return
|
|
||||||
|
return h * virtualH / screenH;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Metrics::isInDisplay (int x, int y) const
|
||||||
|
{
|
||||||
|
return
|
||||||
x > displayX &&
|
x > displayX &&
|
||||||
y > displayY &&
|
y > displayY && x < displayX + displayW && y < displayY + displayH;
|
||||||
x < displayX+displayW &&
|
}
|
||||||
y < displayY+displayH;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Metrics::isInMinimap(int x, int y) const{
|
bool Metrics::isInMinimap (int x, int y) const
|
||||||
return
|
{
|
||||||
|
return
|
||||||
x > minimapX &&
|
x > minimapX &&
|
||||||
y > minimapY &&
|
y > minimapY && x < minimapX + minimapW && y < minimapY + minimapH;
|
||||||
x < minimapX+minimapW &&
|
}
|
||||||
y < minimapY+minimapH;
|
|
||||||
}
|
|
||||||
|
|
||||||
}}// end namespace
|
}
|
||||||
|
} // end namespace
|
||||||
|
@@ -1,77 +1,117 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
// by the Free Software Foundation; either version 2 of the
|
// by the Free Software Foundation; either version 2 of the
|
||||||
// License, or (at your option) any later version
|
// License, or (at your option) any later version
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
#ifndef _GLEST_GAME_METRICS_H_
|
#ifndef _GLEST_GAME_METRICS_H_
|
||||||
#define _GLEST_GAME_METRICS_H_
|
# define _GLEST_GAME_METRICS_H_
|
||||||
|
|
||||||
#ifdef WIN32
|
# ifdef WIN32
|
||||||
#include <winsock2.h>
|
# include <winsock2.h>
|
||||||
#include <winsock.h>
|
# include <winsock.h>
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#include "config.h"
|
# include "config.h"
|
||||||
#include "leak_dumper.h"
|
# include "leak_dumper.h"
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest
|
||||||
|
{
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Metrics
|
// class Metrics
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class Metrics{
|
class Metrics
|
||||||
private:
|
{
|
||||||
int virtualW;
|
private:
|
||||||
int virtualH;
|
int virtualW;
|
||||||
int screenW;
|
int virtualH;
|
||||||
int screenH;
|
int screenW;
|
||||||
int minimapX;
|
int screenH;
|
||||||
int minimapY;
|
int minimapX;
|
||||||
int minimapW;
|
int minimapY;
|
||||||
int minimapH;
|
int minimapW;
|
||||||
int displayX;
|
int minimapH;
|
||||||
int displayY;
|
int displayX;
|
||||||
int displayH;
|
int displayY;
|
||||||
int displayW;
|
int displayH;
|
||||||
|
int displayW;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Metrics();
|
Metrics ();
|
||||||
static Metrics *getInstancePtr();
|
static Metrics *getInstancePtr ();
|
||||||
void reloadData(int resWidth=-1, int resHeight=-1);
|
void reloadData (int resWidth = -1, int resHeight = -1);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const Metrics &getInstance();
|
static const Metrics & getInstance ();
|
||||||
|
|
||||||
int getVirtualW() const {return virtualW;}
|
|
||||||
int getVirtualH() const {return virtualH;}
|
|
||||||
int getScreenW() const {return screenW;}
|
|
||||||
int getScreenH() const {return screenH;}
|
|
||||||
int getMinimapX() const {return minimapX;}
|
|
||||||
int getMinimapY() const {return minimapY;}
|
|
||||||
int getMinimapW() const {return minimapW;}
|
|
||||||
int getMinimapH() const {return minimapH;}
|
|
||||||
int getDisplayX() const {return displayX;}
|
|
||||||
int getDisplayY() const {return displayY;}
|
|
||||||
int getDisplayH() const {return displayH;}
|
|
||||||
int getDisplayW() const {return displayW;}
|
|
||||||
float getAspectRatio() const;
|
|
||||||
|
|
||||||
int toVirtualX(int w) const;
|
|
||||||
int toVirtualY(int h) const;
|
|
||||||
|
|
||||||
bool isInDisplay(int x, int y) const;
|
int getVirtualW () const
|
||||||
bool isInMinimap(int x, int y) const;
|
{
|
||||||
|
return virtualW;
|
||||||
|
}
|
||||||
|
int getVirtualH () const
|
||||||
|
{
|
||||||
|
return virtualH;
|
||||||
|
}
|
||||||
|
int getScreenW () const
|
||||||
|
{
|
||||||
|
return screenW;
|
||||||
|
}
|
||||||
|
int getScreenH () const
|
||||||
|
{
|
||||||
|
return screenH;
|
||||||
|
}
|
||||||
|
int getMinimapX () const
|
||||||
|
{
|
||||||
|
return minimapX;
|
||||||
|
}
|
||||||
|
int getMinimapY () const
|
||||||
|
{
|
||||||
|
return minimapY;
|
||||||
|
}
|
||||||
|
int getMinimapW () const
|
||||||
|
{
|
||||||
|
return minimapW;
|
||||||
|
}
|
||||||
|
int getMinimapH () const
|
||||||
|
{
|
||||||
|
return minimapH;
|
||||||
|
}
|
||||||
|
int getDisplayX () const
|
||||||
|
{
|
||||||
|
return displayX;
|
||||||
|
}
|
||||||
|
int getDisplayY () const
|
||||||
|
{
|
||||||
|
return displayY;
|
||||||
|
}
|
||||||
|
int getDisplayH () const
|
||||||
|
{
|
||||||
|
return displayH;
|
||||||
|
}
|
||||||
|
int getDisplayW () const
|
||||||
|
{
|
||||||
|
return displayW;
|
||||||
|
}
|
||||||
|
float getAspectRatio () const;
|
||||||
|
|
||||||
static void reload(int resWidth=-1, int resHeight=-1);
|
int toVirtualX (int w) const;
|
||||||
};
|
int toVirtualY (int h) const;
|
||||||
|
|
||||||
}}//end namespace
|
bool isInDisplay (int x, int y) const;
|
||||||
|
bool isInMinimap (int x, int y) const;
|
||||||
|
|
||||||
|
static void reload (int resWidth = -1, int resHeight = -1);
|
||||||
|
};
|
||||||
|
|
||||||
|
}} //end namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user