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/>
|
||||
|
||||
#ifndef _GLEST_GAME_CONFIG_H_
|
||||
#define _GLEST_GAME_CONFIG_H_
|
||||
# define _GLEST_GAME_CONFIG_H_
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
# ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
# include <winsock.h>
|
||||
# endif
|
||||
|
||||
#include "properties.h"
|
||||
#include <vector>
|
||||
#include "game_constants.h"
|
||||
#include <SDL.h>
|
||||
#include "leak_dumper.h"
|
||||
# include "properties.h"
|
||||
# include <vector>
|
||||
# include "game_constants.h"
|
||||
# include <SDL.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 {
|
||||
cfgMainGame,
|
||||
cfgUserGame,
|
||||
cfgTempGame,
|
||||
cfgMainKeys,
|
||||
cfgUserKeys,
|
||||
cfgTempKeys
|
||||
};
|
||||
enum ConfigType
|
||||
{
|
||||
cfgMainGame,
|
||||
cfgUserGame,
|
||||
cfgTempGame,
|
||||
cfgMainKeys,
|
||||
cfgUserKeys,
|
||||
cfgTempKeys
|
||||
};
|
||||
|
||||
class Config {
|
||||
private:
|
||||
class Config
|
||||
{
|
||||
private:
|
||||
|
||||
std::pair<Properties,Properties> properties;
|
||||
Properties tempProperties;
|
||||
std::pair<ConfigType,ConfigType> cfgType;
|
||||
std::pair<string,string> fileNameParameter;
|
||||
std::pair<string,string> fileName;
|
||||
std::pair<bool,bool> fileLoaded;
|
||||
string custom_path_parameter;
|
||||
std::pair < Properties, Properties > properties;
|
||||
Properties tempProperties;
|
||||
std::pair < ConfigType, ConfigType > cfgType;
|
||||
std::pair < string, string > fileNameParameter;
|
||||
std::pair < string, string > fileName;
|
||||
std::pair < bool, bool > fileLoaded;
|
||||
string custom_path_parameter;
|
||||
|
||||
static map<ConfigType,Config> configList;
|
||||
static map < ConfigType, Config > configList;
|
||||
|
||||
static const char *glest_ini_filename;
|
||||
static const char *glestuser_ini_filename;
|
||||
static const char *glest_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 *glestuserkeys_ini_filename;
|
||||
static const char *glestkeys_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 *selectBufPicking;
|
||||
static const char *frustumPicking;
|
||||
static const char *colorPicking;
|
||||
static const char *selectBufPicking;
|
||||
static const char *frustumPicking;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
Config();
|
||||
Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist,string custom_path="");
|
||||
bool tryCustomPath(std::pair<ConfigType,ConfigType> &type, 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);
|
||||
Config ();
|
||||
Config (std::pair < ConfigType, ConfigType > type, std::pair < string,
|
||||
string > file, std::pair < bool, bool > fileMustExist,
|
||||
string custom_path = "");
|
||||
bool tryCustomPath (std::pair < ConfigType, ConfigType > &type,
|
||||
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) ,
|
||||
std::pair<string,string> file = std::make_pair(glest_ini_filename,glestuser_ini_filename) ,
|
||||
std::pair<bool,bool> fileMustExist = std::make_pair(true,false),string custom_path="" );
|
||||
void save(const string &path="");
|
||||
void reload();
|
||||
static Config & getInstance (std::pair < ConfigType, ConfigType > type =
|
||||
std::make_pair (cfgMainGame, cfgUserGame),
|
||||
std::pair < string, string > file =
|
||||
std::make_pair (glest_ini_filename,
|
||||
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;
|
||||
bool getBool(const string &key,const char *defaultValueIfNotFound=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 string & key, const char *defaultValueIfNotFound =
|
||||
NULL) const;
|
||||
bool getBool (const string & key, const char *defaultValueIfNotFound =
|
||||
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;
|
||||
bool getBool(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
||||
float getFloat(const char *key,const char *defaultValueIfNotFound=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;
|
||||
int getInt (const char *key, const char *defaultValueIfNotFound =
|
||||
NULL) const;
|
||||
bool getBool (const char *key, const char *defaultValueIfNotFound =
|
||||
NULL) const;
|
||||
float getFloat (const char *key, const char *defaultValueIfNotFound =
|
||||
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 setBool(const string &key, bool value, bool tempBuffer=false);
|
||||
void setFloat(const string &key, float value, bool tempBuffer=false);
|
||||
void setString(const string &key, const string &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 setFloat (const string & key, float value, bool tempBuffer =
|
||||
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> > getMasterProperties() const;
|
||||
vector<pair<string,string> > getUserProperties() const;
|
||||
void setUserProperties(const vector<pair<string,string> > &valueList);
|
||||
vector < pair < string, string > >getMergedProperties () const;
|
||||
vector < pair < string, string > >getMasterProperties () const;
|
||||
vector < pair < string, string > >getUserProperties () const;
|
||||
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 void setCustomRuntimeProperty(string key, string value) { customRuntimeProperties[key] = value; }
|
||||
static string getCustomRuntimeProperty (string key)
|
||||
{
|
||||
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
|
||||
|
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/>.
|
||||
|
||||
#ifndef _GLEST_GAME_COREDATA_H_
|
||||
#define _GLEST_GAME_COREDATA_H_
|
||||
# define _GLEST_GAME_COREDATA_H_
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
# ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
# include <winsock.h>
|
||||
# endif
|
||||
|
||||
#include <string>
|
||||
#include "sound.h"
|
||||
#include "font.h"
|
||||
#include "texture.h"
|
||||
#include "sound_container.h"
|
||||
#include "leak_dumper.h"
|
||||
# include <string>
|
||||
# include "sound.h"
|
||||
# include "font.h"
|
||||
# include "texture.h"
|
||||
# include "sound_container.h"
|
||||
# include "leak_dumper.h"
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
namespace Glest
|
||||
{
|
||||
namespace Game
|
||||
{
|
||||
|
||||
using ::Shared::Graphics::Texture2D;
|
||||
using ::Shared::Graphics::Texture3D;
|
||||
using ::Shared::Graphics::Font;
|
||||
using ::Shared::Graphics::Font2D;
|
||||
using ::Shared::Graphics::Font3D;
|
||||
using ::Shared::Graphics::FontChangedCallbackInterface;
|
||||
using ::Shared::Sound::StrSound;
|
||||
using ::Shared::Sound::StaticSound;
|
||||
using::Shared::Graphics::Texture2D;
|
||||
using::Shared::Graphics::Texture3D;
|
||||
using::Shared::Graphics::Font;
|
||||
using::Shared::Graphics::Font2D;
|
||||
using::Shared::Graphics::Font3D;
|
||||
using::Shared::Graphics::FontChangedCallbackInterface;
|
||||
using::Shared::Sound::StrSound;
|
||||
using::Shared::Sound::StaticSound;
|
||||
|
||||
|
||||
// =====================================================
|
||||
// class CoreData
|
||||
// class CoreData
|
||||
//
|
||||
/// Data shared among all the ProgramStates
|
||||
// =====================================================
|
||||
|
||||
class GameSettings;
|
||||
class GameSettings;
|
||||
|
||||
class CoreData {
|
||||
private:
|
||||
std::map<int,bool> itemLoadAttempted;
|
||||
class CoreData
|
||||
{
|
||||
private:
|
||||
std::map < int, bool > itemLoadAttempted;
|
||||
|
||||
StrSound introMusic;
|
||||
StrSound menuMusic;
|
||||
StaticSound clickSoundA;
|
||||
StaticSound clickSoundB;
|
||||
StaticSound clickSoundC;
|
||||
StaticSound attentionSound;
|
||||
StaticSound highlightSound;
|
||||
StaticSound markerSound;
|
||||
SoundContainer waterSounds;
|
||||
StrSound introMusic;
|
||||
StrSound menuMusic;
|
||||
StaticSound clickSoundA;
|
||||
StaticSound clickSoundB;
|
||||
StaticSound clickSoundC;
|
||||
StaticSound attentionSound;
|
||||
StaticSound highlightSound;
|
||||
StaticSound markerSound;
|
||||
SoundContainer waterSounds;
|
||||
|
||||
Texture2D *logoTexture;
|
||||
std::vector<Texture2D *> logoTextureList;
|
||||
Texture2D *backgroundTexture;
|
||||
Texture2D *fireTexture;
|
||||
Texture2D *teamColorTexture;
|
||||
Texture2D *snowTexture;
|
||||
Texture2D *waterSplashTexture;
|
||||
Texture2D *customTexture;
|
||||
Texture2D *buttonSmallTexture;
|
||||
Texture2D *buttonBigTexture;
|
||||
Texture2D *horizontalLineTexture;
|
||||
Texture2D *verticalLineTexture;
|
||||
Texture2D *checkBoxTexture;
|
||||
Texture2D *checkedCheckBoxTexture;
|
||||
Texture2D *gameWinnerTexture;
|
||||
Texture2D *notOnServerTexture;
|
||||
Texture2D *onServerDifferentTexture;
|
||||
Texture2D *onServerTexture;
|
||||
Texture2D *onServerInstalledTexture;
|
||||
Texture2D *statusReadyTexture;
|
||||
Texture2D *statusNotReadyTexture;
|
||||
Texture2D *statusBRBTexture;
|
||||
Texture2D *logoTexture;
|
||||
std::vector < Texture2D * >logoTextureList;
|
||||
Texture2D *backgroundTexture;
|
||||
Texture2D *fireTexture;
|
||||
Texture2D *teamColorTexture;
|
||||
Texture2D *snowTexture;
|
||||
Texture2D *waterSplashTexture;
|
||||
Texture2D *customTexture;
|
||||
Texture2D *buttonSmallTexture;
|
||||
Texture2D *buttonBigTexture;
|
||||
Texture2D *horizontalLineTexture;
|
||||
Texture2D *verticalLineTexture;
|
||||
Texture2D *checkBoxTexture;
|
||||
Texture2D *checkedCheckBoxTexture;
|
||||
Texture2D *gameWinnerTexture;
|
||||
Texture2D *notOnServerTexture;
|
||||
Texture2D *onServerDifferentTexture;
|
||||
Texture2D *onServerTexture;
|
||||
Texture2D *onServerInstalledTexture;
|
||||
Texture2D *statusReadyTexture;
|
||||
Texture2D *statusNotReadyTexture;
|
||||
Texture2D *statusBRBTexture;
|
||||
|
||||
Texture2D *healthbarTexture;
|
||||
Texture2D *healthbarBackgroundTexture;
|
||||
Texture2D *healthbarTexture;
|
||||
Texture2D *healthbarBackgroundTexture;
|
||||
|
||||
std::vector<Texture2D *> miscTextureList;
|
||||
std::vector < Texture2D * >miscTextureList;
|
||||
|
||||
Font2D *displayFont;
|
||||
Font2D *menuFontNormal;
|
||||
Font2D *displayFontSmall;
|
||||
Font2D *menuFontBig;
|
||||
Font2D *menuFontVeryBig;
|
||||
Font2D *consoleFont;
|
||||
Font2D *displayFont;
|
||||
Font2D *menuFontNormal;
|
||||
Font2D *displayFontSmall;
|
||||
Font2D *menuFontBig;
|
||||
Font2D *menuFontVeryBig;
|
||||
Font2D *consoleFont;
|
||||
|
||||
Font3D *displayFont3D;
|
||||
Font3D *menuFontNormal3D;
|
||||
Font3D *displayFontSmall3D;
|
||||
Font3D *menuFontBig3D;
|
||||
Font3D *menuFontVeryBig3D;
|
||||
Font3D *consoleFont3D;
|
||||
Font3D *displayFont3D;
|
||||
Font3D *menuFontNormal3D;
|
||||
Font3D *displayFontSmall3D;
|
||||
Font3D *menuFontBig3D;
|
||||
Font3D *menuFontVeryBig3D;
|
||||
Font3D *consoleFont3D;
|
||||
|
||||
string introVideoFilename;
|
||||
string introVideoFilenameFallback;
|
||||
string introVideoFilename;
|
||||
string introVideoFilenameFallback;
|
||||
|
||||
string mainMenuVideoFilename;
|
||||
string mainMenuVideoFilenameFallback;
|
||||
string mainMenuVideoFilename;
|
||||
string mainMenuVideoFilenameFallback;
|
||||
|
||||
string battleEndWinVideoFilename;
|
||||
string battleEndWinVideoFilenameFallback;
|
||||
string battleEndWinMusicFilename;
|
||||
string battleEndWinVideoFilename;
|
||||
string battleEndWinVideoFilenameFallback;
|
||||
string battleEndWinMusicFilename;
|
||||
|
||||
string battleEndLoseVideoFilename;
|
||||
string battleEndLoseVideoFilenameFallback;
|
||||
string battleEndLoseMusicFilename;
|
||||
string battleEndLoseVideoFilename;
|
||||
string battleEndLoseVideoFilenameFallback;
|
||||
string battleEndLoseMusicFilename;
|
||||
|
||||
std::map<std::string,std::vector<FontChangedCallbackInterface *> > registeredFontChangedCallbacks;
|
||||
public:
|
||||
std::map < std::string,
|
||||
std::vector <
|
||||
FontChangedCallbackInterface * >>registeredFontChangedCallbacks;
|
||||
public:
|
||||
|
||||
enum TextureSystemType {
|
||||
tsyst_NONE,
|
||||
tsyst_logoTexture,
|
||||
tsyst_backgroundTexture,
|
||||
tsyst_fireTexture,
|
||||
tsyst_teamColorTexture,
|
||||
tsyst_snowTexture,
|
||||
tsyst_waterSplashTexture,
|
||||
tsyst_customTexture,
|
||||
tsyst_buttonSmallTexture,
|
||||
tsyst_buttonBigTexture,
|
||||
tsyst_horizontalLineTexture,
|
||||
tsyst_verticalLineTexture,
|
||||
tsyst_checkBoxTexture,
|
||||
tsyst_checkedCheckBoxTexture,
|
||||
tsyst_gameWinnerTexture,
|
||||
tsyst_notOnServerTexture,
|
||||
tsyst_onServerDifferentTexture,
|
||||
tsyst_onServerTexture,
|
||||
tsyst_onServerInstalledTexture,
|
||||
tsyst_statusReadyTexture,
|
||||
tsyst_statusNotReadyTexture,
|
||||
tsyst_statusBRBTexture,
|
||||
tsyst_healthbarTexture,
|
||||
tsyst_healthbarBackgroundTexture,
|
||||
enum TextureSystemType
|
||||
{
|
||||
tsyst_NONE,
|
||||
tsyst_logoTexture,
|
||||
tsyst_backgroundTexture,
|
||||
tsyst_fireTexture,
|
||||
tsyst_teamColorTexture,
|
||||
tsyst_snowTexture,
|
||||
tsyst_waterSplashTexture,
|
||||
tsyst_customTexture,
|
||||
tsyst_buttonSmallTexture,
|
||||
tsyst_buttonBigTexture,
|
||||
tsyst_horizontalLineTexture,
|
||||
tsyst_verticalLineTexture,
|
||||
tsyst_checkBoxTexture,
|
||||
tsyst_checkedCheckBoxTexture,
|
||||
tsyst_gameWinnerTexture,
|
||||
tsyst_notOnServerTexture,
|
||||
tsyst_onServerDifferentTexture,
|
||||
tsyst_onServerTexture,
|
||||
tsyst_onServerInstalledTexture,
|
||||
tsyst_statusReadyTexture,
|
||||
tsyst_statusNotReadyTexture,
|
||||
tsyst_statusBRBTexture,
|
||||
tsyst_healthbarTexture,
|
||||
tsyst_healthbarBackgroundTexture,
|
||||
|
||||
tsyst_COUNT
|
||||
};
|
||||
tsyst_COUNT
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
~CoreData();
|
||||
static CoreData &getInstance();
|
||||
~CoreData ();
|
||||
static CoreData & getInstance ();
|
||||
|
||||
void load();
|
||||
void cleanup();
|
||||
void loadFonts();
|
||||
void load ();
|
||||
void cleanup ();
|
||||
void loadFonts ();
|
||||
|
||||
// Textures
|
||||
Texture2D *getTextureBySystemId(TextureSystemType type);
|
||||
// Textures
|
||||
Texture2D *getTextureBySystemId (TextureSystemType type);
|
||||
|
||||
Texture2D *getBackgroundTexture();
|
||||
Texture2D *getFireTexture();
|
||||
Texture2D *getTeamColorTexture();
|
||||
Texture2D *getSnowTexture();
|
||||
Texture2D *getLogoTexture();
|
||||
Texture2D *getWaterSplashTexture();
|
||||
Texture2D *getCustomTexture();
|
||||
Texture2D *getButtonSmallTexture();
|
||||
Texture2D *getButtonBigTexture();
|
||||
Texture2D *getHorizontalLineTexture();
|
||||
Texture2D *getVerticalLineTexture();
|
||||
Texture2D *getCheckBoxTexture();
|
||||
Texture2D *getCheckedCheckBoxTexture();
|
||||
Texture2D *getNotOnServerTexture();
|
||||
Texture2D *getOnServerDifferentTexture();
|
||||
Texture2D *getOnServerTexture();
|
||||
Texture2D *getOnServerInstalledTexture();
|
||||
Texture2D *getStatusReadyTexture();
|
||||
Texture2D *getStatusNotReadyTexture();
|
||||
Texture2D *getStatusBRBTexture();
|
||||
Texture2D *getGameWinnerTexture();
|
||||
Texture2D *getBackgroundTexture ();
|
||||
Texture2D *getFireTexture ();
|
||||
Texture2D *getTeamColorTexture ();
|
||||
Texture2D *getSnowTexture ();
|
||||
Texture2D *getLogoTexture ();
|
||||
Texture2D *getWaterSplashTexture ();
|
||||
Texture2D *getCustomTexture ();
|
||||
Texture2D *getButtonSmallTexture ();
|
||||
Texture2D *getButtonBigTexture ();
|
||||
Texture2D *getHorizontalLineTexture ();
|
||||
Texture2D *getVerticalLineTexture ();
|
||||
Texture2D *getCheckBoxTexture ();
|
||||
Texture2D *getCheckedCheckBoxTexture ();
|
||||
Texture2D *getNotOnServerTexture ();
|
||||
Texture2D *getOnServerDifferentTexture ();
|
||||
Texture2D *getOnServerTexture ();
|
||||
Texture2D *getOnServerInstalledTexture ();
|
||||
Texture2D *getStatusReadyTexture ();
|
||||
Texture2D *getStatusNotReadyTexture ();
|
||||
Texture2D *getStatusBRBTexture ();
|
||||
Texture2D *getGameWinnerTexture ();
|
||||
|
||||
Texture2D *getHealthbarTexture();
|
||||
Texture2D *getHealthbarBackgroundTexture();
|
||||
Texture2D *getHealthbarTexture ();
|
||||
Texture2D *getHealthbarBackgroundTexture ();
|
||||
|
||||
size_t getLogoTextureExtraCount();
|
||||
Texture2D *getLogoTextureExtra(int idx);
|
||||
size_t getLogoTextureExtraCount ();
|
||||
Texture2D *getLogoTextureExtra (int idx);
|
||||
|
||||
std::vector<Texture2D *> & getMiscTextureList();
|
||||
std::vector < Texture2D * >&getMiscTextureList ();
|
||||
|
||||
// Sounds and Music
|
||||
StrSound *getIntroMusic();
|
||||
StrSound *getMenuMusic();
|
||||
// Sounds and Music
|
||||
StrSound *getIntroMusic ();
|
||||
StrSound *getMenuMusic ();
|
||||
|
||||
StaticSound *getClickSoundA();
|
||||
StaticSound *getClickSoundB();
|
||||
StaticSound *getClickSoundC();
|
||||
StaticSound *getAttentionSound();
|
||||
StaticSound *getHighlightSound();
|
||||
StaticSound *getMarkerSound();
|
||||
StaticSound *getWaterSound();
|
||||
StaticSound *getClickSoundA ();
|
||||
StaticSound *getClickSoundB ();
|
||||
StaticSound *getClickSoundC ();
|
||||
StaticSound *getAttentionSound ();
|
||||
StaticSound *getHighlightSound ();
|
||||
StaticSound *getMarkerSound ();
|
||||
StaticSound *getWaterSound ();
|
||||
|
||||
// Fonts
|
||||
Font2D *getDisplayFont() const {return displayFont;}
|
||||
Font2D *getDisplayFontSmall() const {return displayFontSmall;}
|
||||
Font2D *getMenuFontNormal() const {return menuFontNormal;}
|
||||
Font2D *getMenuFontBig() const {return menuFontBig;}
|
||||
Font2D *getMenuFontVeryBig() const {return menuFontVeryBig;}
|
||||
Font2D *getConsoleFont() const {return consoleFont;}
|
||||
// Fonts
|
||||
Font2D *getDisplayFont () const
|
||||
{
|
||||
return displayFont;
|
||||
}
|
||||
Font2D *getDisplayFontSmall () const
|
||||
{
|
||||
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 *getDisplayFontSmall3D() const {return displayFontSmall3D;}
|
||||
Font3D *getMenuFontNormal3D() const {return menuFontNormal3D;}
|
||||
Font3D *getMenuFontBig3D() const {return menuFontBig3D;}
|
||||
Font3D *getMenuFontVeryBig3D() const {return menuFontVeryBig3D;}
|
||||
Font3D *getConsoleFont3D() const {return consoleFont3D;}
|
||||
Font3D *getDisplayFont3D () const
|
||||
{
|
||||
return displayFont3D;
|
||||
}
|
||||
Font3D *getDisplayFontSmall3D () const
|
||||
{
|
||||
return displayFontSmall3D;
|
||||
}
|
||||
Font3D *getMenuFontNormal3D () const
|
||||
{
|
||||
return menuFontNormal3D;
|
||||
}
|
||||
Font3D *getMenuFontBig3D () const
|
||||
{
|
||||
return menuFontBig3D;
|
||||
}
|
||||
Font3D *getMenuFontVeryBig3D () const
|
||||
{
|
||||
return menuFontVeryBig3D;
|
||||
}
|
||||
Font3D *getConsoleFont3D () const
|
||||
{
|
||||
return consoleFont3D;
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
string getMainMenuVideoFilename() const { return mainMenuVideoFilename; }
|
||||
bool hasMainMenuVideoFilename() const;
|
||||
string getMainMenuVideoFilenameFallback() const { return mainMenuVideoFilenameFallback; }
|
||||
bool hasMainMenuVideoFilenameFallback() const;
|
||||
// Helper functions
|
||||
string getMainMenuVideoFilename () const
|
||||
{
|
||||
return mainMenuVideoFilename;
|
||||
}
|
||||
bool hasMainMenuVideoFilename () const;
|
||||
string getMainMenuVideoFilenameFallback () const
|
||||
{
|
||||
return mainMenuVideoFilenameFallback;
|
||||
}
|
||||
bool hasMainMenuVideoFilenameFallback () const;
|
||||
|
||||
string getIntroVideoFilename() const { return introVideoFilename; }
|
||||
bool hasIntroVideoFilename() const;
|
||||
string getIntroVideoFilenameFallback() const { return introVideoFilenameFallback; }
|
||||
bool hasIntroVideoFilenameFallback() const;
|
||||
string getIntroVideoFilename () const
|
||||
{
|
||||
return introVideoFilename;
|
||||
}
|
||||
bool hasIntroVideoFilename () const;
|
||||
string getIntroVideoFilenameFallback () const
|
||||
{
|
||||
return introVideoFilenameFallback;
|
||||
}
|
||||
bool hasIntroVideoFilenameFallback () const;
|
||||
|
||||
string getBattleEndVideoFilename(bool won) const { return won == true ? battleEndWinVideoFilename : battleEndLoseVideoFilename; }
|
||||
//bool hasBattleEndVideoFilename(bool won) const;
|
||||
string getBattleEndVideoFilenameFallback(bool won) const { return won == true ? battleEndWinVideoFilenameFallback : battleEndLoseVideoFilenameFallback; }
|
||||
bool hasBattleEndVideoFilenameFallback(bool won) const;
|
||||
string getBattleEndVideoFilename (bool won) const
|
||||
{
|
||||
return won ==
|
||||
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);
|
||||
bool loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings);
|
||||
void saveGameSettingsToFile (std::string fileName,
|
||||
GameSettings * gameSettings,
|
||||
int advancedIndex = 0);
|
||||
bool loadGameSettingsFromFile (std::string fileName,
|
||||
GameSettings * gameSettings);
|
||||
|
||||
void registerFontChangedCallback(std::string entityName, FontChangedCallbackInterface *cb);
|
||||
void unRegisterFontChangedCallback(std::string entityName);
|
||||
private:
|
||||
void registerFontChangedCallback (std::string entityName,
|
||||
FontChangedCallbackInterface * cb);
|
||||
void unRegisterFontChangedCallback (std::string entityName);
|
||||
private:
|
||||
|
||||
CoreData();
|
||||
CoreData ();
|
||||
|
||||
int computeFontSize(int size);
|
||||
void cleanupTexture(Texture2D **texture);
|
||||
void loadTextures(string data_path);
|
||||
void loadSounds(string data_path);
|
||||
void loadMusic(string data_path);
|
||||
void loadIntroMedia(string data_path);
|
||||
void loadMainMenuMedia(string data_path);
|
||||
void loadBattleEndMedia(string data_path);
|
||||
int computeFontSize (int size);
|
||||
void cleanupTexture (Texture2D ** texture);
|
||||
void loadTextures (string data_path);
|
||||
void loadSounds (string data_path);
|
||||
void loadMusic (string data_path);
|
||||
void loadIntroMedia (string data_path);
|
||||
void loadMainMenuMedia (string data_path);
|
||||
void loadBattleEndMedia (string data_path);
|
||||
|
||||
string getDataPath();
|
||||
void loadTextureIfRequired(Texture2D **tex,string data_path,
|
||||
string uniqueFilePath, int texSystemId, bool setMipMap,
|
||||
bool setAlpha, bool loadUniqueFilePath,
|
||||
bool compressionDisabled = false);
|
||||
string getDataPath ();
|
||||
void loadTextureIfRequired (Texture2D ** tex, string data_path,
|
||||
string uniqueFilePath, int texSystemId,
|
||||
bool setMipMap, bool setAlpha,
|
||||
bool loadUniqueFilePath,
|
||||
bool compressionDisabled = false);
|
||||
|
||||
void loadLogoTextureExtraIfRequired();
|
||||
void loadMiscTextureListIfRequired();
|
||||
void loadLogoTextureExtraIfRequired ();
|
||||
void loadMiscTextureListIfRequired ();
|
||||
|
||||
void loadWaterSoundsIfRequired();
|
||||
void loadMusicIfRequired();
|
||||
void loadWaterSoundsIfRequired ();
|
||||
void loadMusicIfRequired ();
|
||||
|
||||
void triggerFontChangedCallbacks(std::string fontUniqueId, Font *font);
|
||||
template<typename T> T * loadFont(Font *menuFontNormal, string menuFontNameNormal, int menuFontNameNormalSize, string fontType, string fontTypeFamily, string fontUniqueKey);
|
||||
};
|
||||
void triggerFontChangedCallbacks (std::string fontUniqueId,
|
||||
Font * font);
|
||||
template < typename T > T * loadFont (Font * menuFontNormal,
|
||||
string menuFontNameNormal,
|
||||
int menuFontNameNormalSize,
|
||||
string fontType,
|
||||
string fontTypeFamily,
|
||||
string fontUniqueKey);
|
||||
};
|
||||
|
||||
}} //end namespace
|
||||
}} //end namespace
|
||||
|
||||
#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
|
||||
// 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
|
||||
// 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 _GLEST_GAME_LANG_H_
|
||||
#define _GLEST_GAME_LANG_H_
|
||||
# define _GLEST_GAME_LANG_H_
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
# ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
# include <winsock.h>
|
||||
# endif
|
||||
|
||||
#include "properties.h"
|
||||
#include "leak_dumper.h"
|
||||
# include "properties.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 {
|
||||
private:
|
||||
class Lang
|
||||
{
|
||||
private:
|
||||
|
||||
bool is_utf8_language;
|
||||
string language;
|
||||
std::map<string,Properties> gameStringsAllLanguages;
|
||||
bool is_utf8_language;
|
||||
string language;
|
||||
std::map < string, Properties > gameStringsAllLanguages;
|
||||
|
||||
Properties scenarioStrings;
|
||||
Properties scenarioStrings;
|
||||
|
||||
Properties tilesetStrings;
|
||||
Properties tilesetStringsDefault;
|
||||
Properties tilesetStrings;
|
||||
Properties tilesetStringsDefault;
|
||||
|
||||
std::map<string, std::map<string, Properties> > techTreeStringsAllLanguages;
|
||||
string techNameLoaded;
|
||||
bool allowNativeLanguageTechtree;
|
||||
std::map < string, std::map < string,
|
||||
Properties > >techTreeStringsAllLanguages;
|
||||
string techNameLoaded;
|
||||
bool allowNativeLanguageTechtree;
|
||||
|
||||
private:
|
||||
Lang();
|
||||
void loadGameStringProperties(string language, Properties &properties, bool fileMustExist,bool fallbackToDefault=false);
|
||||
bool fileMatchesISO630Code(string uselanguage, string testLanguageFile);
|
||||
string getNativeLanguageName(string uselanguage, string testLanguageFile);
|
||||
private:
|
||||
Lang ();
|
||||
void loadGameStringProperties (string language, Properties & properties,
|
||||
bool fileMustExist,
|
||||
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:
|
||||
static Lang &getInstance();
|
||||
public:
|
||||
static Lang & getInstance ();
|
||||
|
||||
string getTechNameLoaded() const { return techNameLoaded; }
|
||||
bool getAllowNativeLanguageTechtree() const { return allowNativeLanguageTechtree; }
|
||||
void setAllowNativeLanguageTechtree(bool value) { allowNativeLanguageTechtree = value; }
|
||||
string getTechNameLoaded () const
|
||||
{
|
||||
return techNameLoaded;
|
||||
}
|
||||
bool getAllowNativeLanguageTechtree () const
|
||||
{
|
||||
return allowNativeLanguageTechtree;
|
||||
}
|
||||
void setAllowNativeLanguageTechtree (bool value)
|
||||
{
|
||||
allowNativeLanguageTechtree = value;
|
||||
}
|
||||
|
||||
void loadGameStrings(string uselanguage, bool loadFonts=true, bool fallbackToDefault=false);
|
||||
void loadScenarioStrings(string scenarioDir, string scenarioName, bool isTutorial);
|
||||
bool loadTechTreeStrings(string techTree, bool forceLoad=false);
|
||||
void loadTilesetStrings(string tileset);
|
||||
void loadGameStrings (string uselanguage, bool loadFonts =
|
||||
true, bool fallbackToDefault = false);
|
||||
void loadScenarioStrings (string scenarioDir, string scenarioName,
|
||||
bool isTutorial);
|
||||
bool loadTechTreeStrings (string techTree, bool forceLoad = false);
|
||||
void loadTilesetStrings (string tileset);
|
||||
|
||||
string getString(const string &s,string uselanguage="", bool fallbackToDefault=false);
|
||||
bool hasString(const string &s, string uselanguage="", bool fallbackToDefault=false);
|
||||
string getString (const string & s, string uselanguage =
|
||||
"", bool fallbackToDefault = false);
|
||||
bool hasString (const string & s, string uselanguage =
|
||||
"", bool fallbackToDefault = false);
|
||||
|
||||
string getScenarioString(const string &s);
|
||||
bool hasScenarioString(const string &s);
|
||||
string getScenarioString (const string & s);
|
||||
bool hasScenarioString (const string & s);
|
||||
|
||||
string getTechTreeString(const string &s, const char *defaultValue=NULL);
|
||||
string getTilesetString(const string &s, const char *defaultValue=NULL);
|
||||
string getTechTreeString (const string & s, const char *defaultValue =
|
||||
NULL);
|
||||
string getTilesetString (const string & s, const char *defaultValue =
|
||||
NULL);
|
||||
|
||||
string getLanguage() const { return language; }
|
||||
bool isLanguageLocal(string compareLanguage) const;
|
||||
//bool isUTF8Language() const;
|
||||
string getDefaultLanguage() const;
|
||||
string getLanguage () const
|
||||
{
|
||||
return language;
|
||||
}
|
||||
bool isLanguageLocal (string compareLanguage) const;
|
||||
//bool isUTF8Language() const;
|
||||
string getDefaultLanguage () const;
|
||||
|
||||
map<string,string> getDiscoveredLanguageList(bool searchKeyIsLangName=false);
|
||||
pair<string,string> getNavtiveNameFromLanguageName(string langName);
|
||||
map < string,
|
||||
string > getDiscoveredLanguageList (bool searchKeyIsLangName = false);
|
||||
pair < string,
|
||||
string > getNavtiveNameFromLanguageName (string langName);
|
||||
|
||||
string getLanguageFile(string uselanguage);
|
||||
};
|
||||
string getLanguageFile (string uselanguage);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
}} //end namespace
|
||||
|
||||
#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
|
||||
// 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
|
||||
// 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
|
||||
// ==============================================================
|
||||
|
||||
#include "metrics.h"
|
||||
#include "metrics.h"
|
||||
#include <stdexcept>
|
||||
#include "platform_util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
namespace Glest
|
||||
{
|
||||
namespace Game
|
||||
{
|
||||
|
||||
|
||||
// =====================================================
|
||||
// class Metrics
|
||||
// class Metrics
|
||||
// =====================================================
|
||||
|
||||
Metrics::Metrics() {
|
||||
reloadData();
|
||||
}
|
||||
Metrics::Metrics ()
|
||||
{
|
||||
reloadData ();
|
||||
}
|
||||
|
||||
void Metrics::reload(int resWidth, int resHeight) {
|
||||
Metrics *metrics = getInstancePtr();
|
||||
metrics->reloadData(resWidth, resHeight);
|
||||
}
|
||||
void Metrics::reload (int resWidth, int resHeight)
|
||||
{
|
||||
Metrics *metrics = getInstancePtr ();
|
||||
metrics->reloadData (resWidth, resHeight);
|
||||
}
|
||||
|
||||
void Metrics::reloadData(int resWidth, int resHeight) {
|
||||
Config &config = Config::getInstance();
|
||||
|
||||
virtualW= 1000;
|
||||
virtualH= 750;
|
||||
void Metrics::reloadData (int resWidth, int resHeight)
|
||||
{
|
||||
Config & config = Config::getInstance ();
|
||||
|
||||
if(resWidth > 0) {
|
||||
screenW= resWidth;
|
||||
}
|
||||
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;
|
||||
virtualW = 1000;
|
||||
virtualH = 750;
|
||||
|
||||
displayX= 800;
|
||||
displayY= 250;
|
||||
displayW= 128;
|
||||
displayH= 480;
|
||||
}
|
||||
if (resWidth > 0)
|
||||
{
|
||||
screenW = resWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
screenW = config.getInt ("ScreenWidth");
|
||||
}
|
||||
if (resHeight > 0)
|
||||
{
|
||||
screenH = resHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
screenH = config.getInt ("ScreenHeight");
|
||||
}
|
||||
|
||||
Metrics * Metrics::getInstancePtr() {
|
||||
static Metrics metrics;
|
||||
return &metrics;
|
||||
}
|
||||
minimapX = 10;
|
||||
minimapY = 750 - 128 - 30 + 16;
|
||||
minimapW = 128;
|
||||
minimapH = 128;
|
||||
|
||||
const Metrics &Metrics::getInstance(){
|
||||
Metrics *metrics = getInstancePtr();
|
||||
return *metrics;
|
||||
}
|
||||
displayX = 800;
|
||||
displayY = 250;
|
||||
displayW = 128;
|
||||
displayH = 480;
|
||||
}
|
||||
|
||||
float Metrics::getAspectRatio() const{
|
||||
if(screenH == 0) {
|
||||
throw megaglest_runtime_error("div by 0 screenH == 0");
|
||||
}
|
||||
return static_cast<float>(screenW)/screenH;
|
||||
}
|
||||
Metrics *Metrics::getInstancePtr ()
|
||||
{
|
||||
static Metrics metrics;
|
||||
return &metrics;
|
||||
}
|
||||
|
||||
int Metrics::toVirtualX(int w) const{
|
||||
if(screenW == 0) {
|
||||
throw megaglest_runtime_error("div by 0 screenW == 0");
|
||||
}
|
||||
return w*virtualW/screenW;
|
||||
}
|
||||
const Metrics & Metrics::getInstance ()
|
||||
{
|
||||
Metrics *metrics = getInstancePtr ();
|
||||
return *metrics;
|
||||
}
|
||||
|
||||
int Metrics::toVirtualY(int h) const{
|
||||
if(screenH == 0) {
|
||||
throw megaglest_runtime_error("div by 0 screenH == 0");
|
||||
}
|
||||
float Metrics::getAspectRatio () const
|
||||
{
|
||||
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{
|
||||
return
|
||||
//printf("h [%d] virtualH [%d] screenH [%d] result = %d\n",h,virtualH,screenH,(h*virtualH/screenH));
|
||||
|
||||
return h * virtualH / screenH;
|
||||
}
|
||||
|
||||
bool Metrics::isInDisplay (int x, int y) const
|
||||
{
|
||||
return
|
||||
x > displayX &&
|
||||
y > displayY &&
|
||||
x < displayX+displayW &&
|
||||
y < displayY+displayH;
|
||||
}
|
||||
y > displayY && x < displayX + displayW && y < displayY + displayH;
|
||||
}
|
||||
|
||||
bool Metrics::isInMinimap(int x, int y) const{
|
||||
return
|
||||
bool Metrics::isInMinimap (int x, int y) const
|
||||
{
|
||||
return
|
||||
x > minimapX &&
|
||||
y > minimapY &&
|
||||
x < minimapX+minimapW &&
|
||||
y < minimapY+minimapH;
|
||||
}
|
||||
y > minimapY && 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
|
||||
// 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
|
||||
// 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 _GLEST_GAME_METRICS_H_
|
||||
#define _GLEST_GAME_METRICS_H_
|
||||
# define _GLEST_GAME_METRICS_H_
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
# ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
# include <winsock.h>
|
||||
# endif
|
||||
|
||||
#include "config.h"
|
||||
#include "leak_dumper.h"
|
||||
# include "config.h"
|
||||
# include "leak_dumper.h"
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
namespace Glest
|
||||
{
|
||||
namespace Game
|
||||
{
|
||||
|
||||
// =====================================================
|
||||
// class Metrics
|
||||
// class Metrics
|
||||
// =====================================================
|
||||
|
||||
class Metrics{
|
||||
private:
|
||||
int virtualW;
|
||||
int virtualH;
|
||||
int screenW;
|
||||
int screenH;
|
||||
int minimapX;
|
||||
int minimapY;
|
||||
int minimapW;
|
||||
int minimapH;
|
||||
int displayX;
|
||||
int displayY;
|
||||
int displayH;
|
||||
int displayW;
|
||||
class Metrics
|
||||
{
|
||||
private:
|
||||
int virtualW;
|
||||
int virtualH;
|
||||
int screenW;
|
||||
int screenH;
|
||||
int minimapX;
|
||||
int minimapY;
|
||||
int minimapW;
|
||||
int minimapH;
|
||||
int displayX;
|
||||
int displayY;
|
||||
int displayH;
|
||||
int displayW;
|
||||
|
||||
private:
|
||||
Metrics();
|
||||
static Metrics *getInstancePtr();
|
||||
void reloadData(int resWidth=-1, int resHeight=-1);
|
||||
private:
|
||||
Metrics ();
|
||||
static Metrics *getInstancePtr ();
|
||||
void reloadData (int resWidth = -1, int resHeight = -1);
|
||||
|
||||
public:
|
||||
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;
|
||||
public:
|
||||
static const Metrics & getInstance ();
|
||||
|
||||
bool isInDisplay(int x, int y) const;
|
||||
bool isInMinimap(int x, int y) const;
|
||||
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;
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user