2010-04-01 02:13:28 +02:00
|
|
|
|
// ==============================================================
|
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
|
|
|
|
//
|
2010-12-09 21:41:11 +01:00
|
|
|
|
// 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
|
2010-04-01 02:13:28 +02:00
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
|
|
#include "core_data.h"
|
|
|
|
|
|
|
|
|
|
#include "logger.h"
|
|
|
|
|
#include "renderer.h"
|
|
|
|
|
#include "graphics_interface.h"
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "util.h"
|
2010-08-06 00:27:26 +02:00
|
|
|
|
#include "platform_util.h"
|
2010-12-09 21:41:11 +01:00
|
|
|
|
#include "game_constants.h"
|
|
|
|
|
#include "game_util.h"
|
2010-04-01 02:13:28 +02:00
|
|
|
|
#include "leak_dumper.h"
|
|
|
|
|
|
|
|
|
|
using namespace Shared::Sound;
|
|
|
|
|
using namespace Shared::Graphics;
|
|
|
|
|
using namespace Shared::Util;
|
|
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
|
// class CoreData
|
|
|
|
|
// =====================================================
|
|
|
|
|
|
|
|
|
|
// ===================== PUBLIC ========================
|
|
|
|
|
|
2010-12-09 21:41:11 +01:00
|
|
|
|
CoreData &CoreData::getInstance() {
|
2010-04-01 02:13:28 +02:00
|
|
|
|
static CoreData coreData;
|
|
|
|
|
return coreData;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-09 21:41:11 +01:00
|
|
|
|
CoreData::~CoreData() {
|
2010-04-01 02:13:28 +02:00
|
|
|
|
deleteValues(waterSounds.getSounds().begin(), waterSounds.getSounds().end());
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-09 21:41:11 +01:00
|
|
|
|
void CoreData::load() {
|
|
|
|
|
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
2011-03-23 06:49:38 +01:00
|
|
|
|
if(data_path != "") {
|
|
|
|
|
endPathWithSlash(data_path);
|
|
|
|
|
}
|
2010-12-09 21:41:11 +01:00
|
|
|
|
|
|
|
|
|
const string dir = data_path + "data/core";
|
2010-04-01 02:13:28 +02:00
|
|
|
|
Logger::getInstance().add("Core data");
|
|
|
|
|
|
|
|
|
|
Renderer &renderer= Renderer::getInstance();
|
|
|
|
|
|
|
|
|
|
//textures
|
|
|
|
|
backgroundTexture= renderer.newTexture2D(rsGlobal);
|
|
|
|
|
backgroundTexture->setMipmap(false);
|
2010-12-09 21:41:11 +01:00
|
|
|
|
backgroundTexture->getPixmap()->load(dir+"/menu/textures/back.tga");
|
2010-04-01 02:13:28 +02:00
|
|
|
|
|
|
|
|
|
fireTexture= renderer.newTexture2D(rsGlobal);
|
|
|
|
|
fireTexture->setFormat(Texture::fAlpha);
|
|
|
|
|
fireTexture->getPixmap()->init(1);
|
|
|
|
|
fireTexture->getPixmap()->load(dir+"/misc_textures/fire_particle.tga");
|
|
|
|
|
|
|
|
|
|
snowTexture= renderer.newTexture2D(rsGlobal);
|
|
|
|
|
snowTexture->setMipmap(false);
|
|
|
|
|
snowTexture->setFormat(Texture::fAlpha);
|
|
|
|
|
snowTexture->getPixmap()->init(1);
|
|
|
|
|
snowTexture->getPixmap()->load(dir+"/misc_textures/snow_particle.tga");
|
2010-12-09 21:41:11 +01:00
|
|
|
|
|
2010-04-01 02:13:28 +02:00
|
|
|
|
customTexture= renderer.newTexture2D(rsGlobal);
|
2010-12-09 21:41:11 +01:00
|
|
|
|
customTexture->getPixmap()->load(dir+"/menu/textures/custom_texture.tga");
|
2010-04-01 02:13:28 +02:00
|
|
|
|
|
|
|
|
|
logoTexture= renderer.newTexture2D(rsGlobal);
|
|
|
|
|
logoTexture->setMipmap(false);
|
|
|
|
|
logoTexture->getPixmap()->load(dir+"/menu/textures/logo.tga");
|
|
|
|
|
|
2010-08-06 00:27:26 +02:00
|
|
|
|
logoTextureList.clear();
|
|
|
|
|
string logosPath= dir+"/menu/textures/logo*.*";
|
|
|
|
|
vector<string> logoFilenames;
|
|
|
|
|
findAll(logosPath, logoFilenames);
|
|
|
|
|
for(int i = 0; i < logoFilenames.size(); ++i) {
|
|
|
|
|
string logo = logoFilenames[i];
|
2010-08-07 00:19:48 +02:00
|
|
|
|
if(strcmp("logo.tga",logo.c_str()) != 0) {
|
2010-08-06 00:27:26 +02:00
|
|
|
|
Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal);
|
2010-08-07 01:07:08 +02:00
|
|
|
|
logoTextureExtra->setMipmap(true);
|
2010-08-06 00:27:26 +02:00
|
|
|
|
logoTextureExtra->getPixmap()->load(dir+"/menu/textures/" + logo);
|
|
|
|
|
logoTextureList.push_back(logoTextureExtra);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-01 02:13:28 +02:00
|
|
|
|
waterSplashTexture= renderer.newTexture2D(rsGlobal);
|
|
|
|
|
waterSplashTexture->setFormat(Texture::fAlpha);
|
|
|
|
|
waterSplashTexture->getPixmap()->init(1);
|
|
|
|
|
waterSplashTexture->getPixmap()->load(dir+"/misc_textures/water_splash.tga");
|
|
|
|
|
|
|
|
|
|
buttonSmallTexture= renderer.newTexture2D(rsGlobal);
|
2010-10-28 08:59:43 +02:00
|
|
|
|
buttonSmallTexture->setForceCompressionDisabled(true);
|
2010-04-01 02:13:28 +02:00
|
|
|
|
buttonSmallTexture->getPixmap()->load(dir+"/menu/textures/button_small.tga");
|
|
|
|
|
|
|
|
|
|
buttonBigTexture= renderer.newTexture2D(rsGlobal);
|
2010-10-28 08:59:43 +02:00
|
|
|
|
buttonBigTexture->setForceCompressionDisabled(true);
|
2010-04-01 02:13:28 +02:00
|
|
|
|
buttonBigTexture->getPixmap()->load(dir+"/menu/textures/button_big.tga");
|
2010-12-09 21:41:11 +01:00
|
|
|
|
|
2010-12-27 01:59:57 +01:00
|
|
|
|
horizontalLineTexture= renderer.newTexture2D(rsGlobal);
|
|
|
|
|
horizontalLineTexture->setForceCompressionDisabled(true);
|
|
|
|
|
horizontalLineTexture->getPixmap()->load(dir+"/menu/textures/line_horizontal.tga");
|
|
|
|
|
|
|
|
|
|
verticalLineTexture= renderer.newTexture2D(rsGlobal);
|
|
|
|
|
verticalLineTexture->setForceCompressionDisabled(true);
|
|
|
|
|
verticalLineTexture->getPixmap()->load(dir+"/menu/textures/line_vertical.tga");
|
|
|
|
|
|
|
|
|
|
checkBoxTexture= renderer.newTexture2D(rsGlobal);
|
|
|
|
|
checkBoxTexture->setForceCompressionDisabled(true);
|
|
|
|
|
checkBoxTexture->getPixmap()->load(dir+"/menu/textures/checkbox.tga");
|
|
|
|
|
|
|
|
|
|
checkedCheckBoxTexture= renderer.newTexture2D(rsGlobal);
|
|
|
|
|
checkedCheckBoxTexture->setForceCompressionDisabled(true);
|
|
|
|
|
checkedCheckBoxTexture->getPixmap()->load(dir+"/menu/textures/checkbox_checked.tga");
|
|
|
|
|
|
2010-04-01 02:13:28 +02:00
|
|
|
|
//display font
|
|
|
|
|
Config &config= Config::getInstance();
|
2010-04-01 20:59:05 +02:00
|
|
|
|
string displayFontNamePrefix=config.getString("FontDisplayPrefix");
|
|
|
|
|
string displayFontNamePostfix=config.getString("FontDisplayPostfix");
|
2010-04-08 00:20:28 +02:00
|
|
|
|
int displayFontSize=computeFontSize(config.getInt("FontDisplayBaseSize"));
|
2010-04-01 20:59:05 +02:00
|
|
|
|
string displayFontName=displayFontNamePrefix+intToStr(displayFontSize)+displayFontNamePostfix;
|
2010-04-01 02:13:28 +02:00
|
|
|
|
displayFont= renderer.newFont(rsGlobal);
|
|
|
|
|
displayFont->setType(displayFontName);
|
2010-04-01 20:59:05 +02:00
|
|
|
|
displayFont->setSize(displayFontSize);
|
2010-04-01 02:13:28 +02:00
|
|
|
|
|
2011-03-28 05:54:23 +02:00
|
|
|
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontName = [%s] displayFontSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontName.c_str(),displayFontSize);
|
2010-04-11 03:25:06 +02:00
|
|
|
|
|
2010-04-01 20:59:05 +02:00
|
|
|
|
//menu fonts
|
2010-04-08 00:20:28 +02:00
|
|
|
|
string displayFontNameSmallPrefix= config.getString("FontDisplayPrefix");
|
|
|
|
|
string displayFontNameSmallPostfix= config.getString("FontDisplayPostfix");
|
|
|
|
|
int displayFontNameSmallSize=computeFontSize(config.getInt("FontDisplaySmallBaseSize"));
|
|
|
|
|
string displayFontNameSmall=displayFontNameSmallPrefix+intToStr(displayFontNameSmallSize)+displayFontNameSmallPostfix;
|
|
|
|
|
displayFontSmall= renderer.newFont(rsGlobal);
|
|
|
|
|
displayFontSmall->setType(displayFontNameSmall);
|
|
|
|
|
displayFontSmall->setSize(displayFontNameSmallSize);
|
2010-12-09 21:41:11 +01:00
|
|
|
|
|
2011-03-28 05:54:23 +02:00
|
|
|
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontSmallName = [%s] displayFontSmallNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontNameSmall.c_str(),displayFontNameSmallSize);
|
2010-12-09 21:41:11 +01:00
|
|
|
|
|
2010-04-01 20:59:05 +02:00
|
|
|
|
string menuFontNameNormalPrefix= config.getString("FontMenuNormalPrefix");
|
|
|
|
|
string menuFontNameNormalPostfix= config.getString("FontMenuNormalPostfix");
|
2010-04-08 00:20:28 +02:00
|
|
|
|
int menuFontNameNormalSize=computeFontSize(config.getInt("FontMenuNormalBaseSize"));
|
2010-04-01 20:59:05 +02:00
|
|
|
|
string menuFontNameNormal= menuFontNameNormalPrefix+intToStr(menuFontNameNormalSize)+menuFontNameNormalPostfix;
|
2010-04-01 02:13:28 +02:00
|
|
|
|
menuFontNormal= renderer.newFont(rsGlobal);
|
|
|
|
|
menuFontNormal->setType(menuFontNameNormal);
|
2010-04-01 20:59:05 +02:00
|
|
|
|
menuFontNormal->setSize(menuFontNameNormalSize);
|
2010-04-01 02:13:28 +02:00
|
|
|
|
menuFontNormal->setWidth(Font::wBold);
|
|
|
|
|
|
2011-03-28 05:54:23 +02:00
|
|
|
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNormalName = [%s] menuFontNormalNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameNormal.c_str(),menuFontNameNormalSize);
|
2010-04-01 20:59:05 +02:00
|
|
|
|
|
|
|
|
|
string menuFontNameBigPrefix= config.getString("FontMenuBigPrefix");
|
|
|
|
|
string menuFontNameBigPostfix= config.getString("FontMenuBigPostfix");
|
2010-04-08 00:20:28 +02:00
|
|
|
|
int menuFontNameBigSize=computeFontSize(config.getInt("FontMenuBigBaseSize"));
|
2010-04-01 20:59:05 +02:00
|
|
|
|
string menuFontNameBig= menuFontNameBigPrefix+intToStr(menuFontNameBigSize)+menuFontNameBigPostfix;
|
2010-04-01 02:13:28 +02:00
|
|
|
|
menuFontBig= renderer.newFont(rsGlobal);
|
|
|
|
|
menuFontBig->setType(menuFontNameBig);
|
2010-04-01 20:59:05 +02:00
|
|
|
|
menuFontBig->setSize(menuFontNameBigSize);
|
2010-04-01 02:13:28 +02:00
|
|
|
|
|
2011-03-28 05:54:23 +02:00
|
|
|
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNameBig = [%s] menuFontNameBigSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameBig.c_str(),menuFontNameBigSize);
|
2010-04-11 03:25:06 +02:00
|
|
|
|
|
2010-04-01 20:59:05 +02:00
|
|
|
|
string menuFontNameVeryBigPrefix= config.getString("FontMenuBigPrefix");
|
|
|
|
|
string menuFontNameVeryBigPostfix= config.getString("FontMenuBigPostfix");
|
2010-04-08 00:20:28 +02:00
|
|
|
|
int menuFontNameVeryBigSize=computeFontSize(config.getInt("FontMenuVeryBigBaseSize"));
|
2010-04-01 20:59:05 +02:00
|
|
|
|
string menuFontNameVeryBig= menuFontNameVeryBigPrefix+intToStr(menuFontNameVeryBigSize)+menuFontNameVeryBigPostfix;
|
2010-04-01 02:13:28 +02:00
|
|
|
|
menuFontVeryBig= renderer.newFont(rsGlobal);
|
|
|
|
|
menuFontVeryBig->setType(menuFontNameVeryBig);
|
2010-04-01 20:59:05 +02:00
|
|
|
|
menuFontVeryBig->setSize(menuFontNameVeryBigSize);
|
2010-04-01 02:13:28 +02:00
|
|
|
|
|
2011-03-28 05:54:23 +02:00
|
|
|
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNameVeryBig = [%s] menuFontNameVeryBigSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameVeryBig.c_str(),menuFontNameVeryBigSize);
|
2010-04-11 03:25:06 +02:00
|
|
|
|
|
2010-04-01 02:13:28 +02:00
|
|
|
|
//console font
|
2010-04-01 20:59:05 +02:00
|
|
|
|
string consoleFontNamePrefix= config.getString("FontConsolePrefix");
|
|
|
|
|
string consoleFontNamePostfix= config.getString("FontConsolePostfix");
|
2010-04-08 00:20:28 +02:00
|
|
|
|
int consoleFontNameSize=computeFontSize(config.getInt("FontConsoleBaseSize"));
|
2010-04-01 20:59:05 +02:00
|
|
|
|
string consoleFontName= consoleFontNamePrefix+intToStr(consoleFontNameSize)+consoleFontNamePostfix;
|
2010-04-01 02:13:28 +02:00
|
|
|
|
consoleFont= renderer.newFont(rsGlobal);
|
|
|
|
|
consoleFont->setType(consoleFontName);
|
2010-04-01 20:59:05 +02:00
|
|
|
|
consoleFont->setSize(consoleFontNameSize);
|
2010-04-01 02:13:28 +02:00
|
|
|
|
|
2011-03-28 05:54:23 +02:00
|
|
|
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] consoleFontName = [%s] consoleFontNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,consoleFontName.c_str(),consoleFontNameSize);
|
2010-04-11 03:25:06 +02:00
|
|
|
|
|
2010-04-01 02:13:28 +02:00
|
|
|
|
//sounds
|
|
|
|
|
clickSoundA.load(dir+"/menu/sound/click_a.wav");
|
|
|
|
|
clickSoundB.load(dir+"/menu/sound/click_b.wav");
|
|
|
|
|
clickSoundC.load(dir+"/menu/sound/click_c.wav");
|
2010-05-16 18:40:21 +02:00
|
|
|
|
attentionSound.load(dir+"/menu/sound/attention.wav");
|
2011-01-01 21:31:25 +01:00
|
|
|
|
highlightSound.load(dir+"/menu/sound/highlight.wav");
|
2010-04-01 02:13:28 +02:00
|
|
|
|
introMusic.open(dir+"/menu/music/intro_music.ogg");
|
|
|
|
|
introMusic.setNext(&menuMusic);
|
|
|
|
|
menuMusic.open(dir+"/menu/music/menu_music.ogg");
|
|
|
|
|
menuMusic.setNext(&menuMusic);
|
|
|
|
|
waterSounds.resize(6);
|
|
|
|
|
for(int i=0; i<6; ++i){
|
|
|
|
|
waterSounds[i]= new StaticSound();
|
|
|
|
|
waterSounds[i]->load(dir+"/water_sounds/water"+intToStr(i)+".wav");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int CoreData::computeFontSize(int size){
|
2010-04-08 00:20:28 +02:00
|
|
|
|
Config &config= Config::getInstance();
|
|
|
|
|
int screenH= config.getInt("ScreenHeight");
|
2010-04-01 20:59:05 +02:00
|
|
|
|
int rs= size*screenH/1024;
|
2010-04-08 00:20:28 +02:00
|
|
|
|
//FontSizeAdjustment
|
|
|
|
|
rs=rs+config.getInt("FontSizeAdjustment");
|
|
|
|
|
if(rs<10){
|
|
|
|
|
rs= 10;
|
2010-04-01 02:13:28 +02:00
|
|
|
|
}
|
2011-03-28 05:54:23 +02:00
|
|
|
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fontsize orginal %d calculated:%d \n",__FILE__,__FUNCTION__,__LINE__,size,rs);
|
2010-04-01 02:13:28 +02:00
|
|
|
|
return rs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ================== PRIVATE ========================
|
|
|
|
|
|
|
|
|
|
}}//end namespace
|