- more updates for headless mode (try to avoid using opengl completely), server now runs at around 20 MB RAM at game start.
This commit is contained in:
parent
fdd04d10c1
commit
c68aa74fcf
|
@ -680,11 +680,15 @@ void PopupMenu::init(string menuHeader,std::vector<string> menuItems) {
|
|||
int currentButtonWidth = -1;
|
||||
if(font3D != NULL) {
|
||||
FontMetrics *fontMetrics= font3D->getMetrics();
|
||||
currentButtonWidth = fontMetrics->getTextWidth(menuItems[i]);
|
||||
if(fontMetrics) {
|
||||
currentButtonWidth = fontMetrics->getTextWidth(menuItems[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if(font) {
|
||||
FontMetrics *fontMetrics= font->getMetrics();
|
||||
currentButtonWidth = fontMetrics->getTextWidth(menuItems[i]);
|
||||
if(fontMetrics) {
|
||||
currentButtonWidth = fontMetrics->getTextWidth(menuItems[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(maxButtonWidth < 0 || currentButtonWidth > maxButtonWidth) {
|
||||
|
|
|
@ -56,40 +56,57 @@ void CoreData::load() {
|
|||
|
||||
//textures
|
||||
backgroundTexture= renderer.newTexture2D(rsGlobal);
|
||||
backgroundTexture->setMipmap(false);
|
||||
backgroundTexture->getPixmap()->load(dir+"/menu/textures/back.tga");
|
||||
if(backgroundTexture) {
|
||||
backgroundTexture->setMipmap(false);
|
||||
backgroundTexture->getPixmap()->load(dir+"/menu/textures/back.tga");
|
||||
}
|
||||
|
||||
fireTexture= renderer.newTexture2D(rsGlobal);
|
||||
fireTexture->setFormat(Texture::fAlpha);
|
||||
fireTexture->getPixmap()->init(1);
|
||||
fireTexture->getPixmap()->load(dir+"/misc_textures/fire_particle.tga");
|
||||
if(fireTexture) {
|
||||
fireTexture->setFormat(Texture::fAlpha);
|
||||
fireTexture->getPixmap()->init(1);
|
||||
fireTexture->getPixmap()->load(dir+"/misc_textures/fire_particle.tga");
|
||||
}
|
||||
|
||||
teamColorTexture= renderer.newTexture2D(rsGlobal);
|
||||
teamColorTexture->setFormat(Texture::fAlpha);
|
||||
teamColorTexture->getPixmap()->init(1);
|
||||
teamColorTexture->getPixmap()->load(dir+"/misc_textures/team_color_texture.tga");
|
||||
if(teamColorTexture) {
|
||||
teamColorTexture->setFormat(Texture::fAlpha);
|
||||
teamColorTexture->getPixmap()->init(1);
|
||||
teamColorTexture->getPixmap()->load(dir+"/misc_textures/team_color_texture.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");
|
||||
if(snowTexture) {
|
||||
snowTexture->setMipmap(false);
|
||||
snowTexture->setFormat(Texture::fAlpha);
|
||||
snowTexture->getPixmap()->init(1);
|
||||
snowTexture->getPixmap()->load(dir+"/misc_textures/snow_particle.tga");
|
||||
}
|
||||
|
||||
customTexture= renderer.newTexture2D(rsGlobal);
|
||||
customTexture->getPixmap()->load(dir+"/menu/textures/custom_texture.tga");
|
||||
if(customTexture) {
|
||||
customTexture->getPixmap()->load(dir+"/menu/textures/custom_texture.tga");
|
||||
}
|
||||
|
||||
notOnServerTexture= renderer.newTexture2D(rsGlobal);
|
||||
notOnServerTexture->getPixmap()->load(dir+"/menu/textures/not_on_server.tga");
|
||||
if(notOnServerTexture) {
|
||||
notOnServerTexture->getPixmap()->load(dir+"/menu/textures/not_on_server.tga");
|
||||
}
|
||||
|
||||
onServerDifferentTexture= renderer.newTexture2D(rsGlobal);
|
||||
onServerDifferentTexture->getPixmap()->load(dir+"/menu/textures/on_server_different.tga");
|
||||
onServerTexture= renderer.newTexture2D(rsGlobal);
|
||||
onServerTexture->getPixmap()->load(dir+"/menu/textures/on_server.tga");
|
||||
onServerInstalledTexture= renderer.newTexture2D(rsGlobal);
|
||||
onServerInstalledTexture->getPixmap()->load(dir+"/menu/textures/on_server_installed.tga");
|
||||
if(onServerDifferentTexture) {
|
||||
onServerDifferentTexture->getPixmap()->load(dir+"/menu/textures/on_server_different.tga");
|
||||
onServerTexture= renderer.newTexture2D(rsGlobal);
|
||||
onServerTexture->getPixmap()->load(dir+"/menu/textures/on_server.tga");
|
||||
onServerInstalledTexture= renderer.newTexture2D(rsGlobal);
|
||||
onServerInstalledTexture->getPixmap()->load(dir+"/menu/textures/on_server_installed.tga");
|
||||
}
|
||||
|
||||
logoTexture= renderer.newTexture2D(rsGlobal);
|
||||
logoTexture->setMipmap(false);
|
||||
logoTexture->getPixmap()->load(dir+"/menu/textures/logo.tga");
|
||||
if(logoTexture) {
|
||||
logoTexture->setMipmap(false);
|
||||
logoTexture->getPixmap()->load(dir+"/menu/textures/logo.tga");
|
||||
}
|
||||
|
||||
logoTextureList.clear();
|
||||
string logosPath= dir+"/menu/textures/logo*.*";
|
||||
|
@ -99,44 +116,62 @@ void CoreData::load() {
|
|||
string logo = logoFilenames[i];
|
||||
if(strcmp("logo.tga",logo.c_str()) != 0) {
|
||||
Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal);
|
||||
logoTextureExtra->setMipmap(true);
|
||||
logoTextureExtra->getPixmap()->load(dir+"/menu/textures/" + logo);
|
||||
logoTextureList.push_back(logoTextureExtra);
|
||||
if(logoTextureExtra) {
|
||||
logoTextureExtra->setMipmap(true);
|
||||
logoTextureExtra->getPixmap()->load(dir+"/menu/textures/" + logo);
|
||||
logoTextureList.push_back(logoTextureExtra);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
waterSplashTexture= renderer.newTexture2D(rsGlobal);
|
||||
waterSplashTexture->setFormat(Texture::fAlpha);
|
||||
waterSplashTexture->getPixmap()->init(1);
|
||||
waterSplashTexture->getPixmap()->load(dir+"/misc_textures/water_splash.tga");
|
||||
if(waterSplashTexture) {
|
||||
waterSplashTexture->setFormat(Texture::fAlpha);
|
||||
waterSplashTexture->getPixmap()->init(1);
|
||||
waterSplashTexture->getPixmap()->load(dir+"/misc_textures/water_splash.tga");
|
||||
}
|
||||
|
||||
buttonSmallTexture= renderer.newTexture2D(rsGlobal);
|
||||
buttonSmallTexture->setForceCompressionDisabled(true);
|
||||
buttonSmallTexture->getPixmap()->load(dir+"/menu/textures/button_small.tga");
|
||||
if(buttonSmallTexture) {
|
||||
buttonSmallTexture->setForceCompressionDisabled(true);
|
||||
buttonSmallTexture->getPixmap()->load(dir+"/menu/textures/button_small.tga");
|
||||
}
|
||||
|
||||
buttonBigTexture= renderer.newTexture2D(rsGlobal);
|
||||
buttonBigTexture->setForceCompressionDisabled(true);
|
||||
buttonBigTexture->getPixmap()->load(dir+"/menu/textures/button_big.tga");
|
||||
if(buttonBigTexture) {
|
||||
buttonBigTexture->setForceCompressionDisabled(true);
|
||||
buttonBigTexture->getPixmap()->load(dir+"/menu/textures/button_big.tga");
|
||||
}
|
||||
|
||||
horizontalLineTexture= renderer.newTexture2D(rsGlobal);
|
||||
horizontalLineTexture->setForceCompressionDisabled(true);
|
||||
horizontalLineTexture->getPixmap()->load(dir+"/menu/textures/line_horizontal.tga");
|
||||
if(horizontalLineTexture) {
|
||||
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");
|
||||
if(verticalLineTexture) {
|
||||
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");
|
||||
if(checkBoxTexture) {
|
||||
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");
|
||||
if(checkedCheckBoxTexture) {
|
||||
checkedCheckBoxTexture->setForceCompressionDisabled(true);
|
||||
checkedCheckBoxTexture->getPixmap()->load(dir+"/menu/textures/checkbox_checked.tga");
|
||||
}
|
||||
|
||||
gameWinnerTexture= renderer.newTexture2D(rsGlobal);
|
||||
gameWinnerTexture->setForceCompressionDisabled(true);
|
||||
gameWinnerTexture->getPixmap()->load(dir+"/misc_textures/game_winner.png");
|
||||
if(gameWinnerTexture) {
|
||||
gameWinnerTexture->setForceCompressionDisabled(true);
|
||||
gameWinnerTexture->getPixmap()->load(dir+"/misc_textures/game_winner.png");
|
||||
}
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
|
@ -164,14 +199,18 @@ void CoreData::load() {
|
|||
string displayFontName = displayFontNamePrefix + intToStr(displayFontSize) + displayFontNamePostfix;
|
||||
|
||||
displayFont= renderer.newFont(rsGlobal);
|
||||
displayFont->setType(displayFontName,config.getString("FontDisplay",""));
|
||||
displayFont->setSize(displayFontSize);
|
||||
//displayFont->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(displayFont) {
|
||||
displayFont->setType(displayFontName,config.getString("FontDisplay",""));
|
||||
displayFont->setSize(displayFontSize);
|
||||
//displayFont->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
displayFont3D= renderer.newFont3D(rsGlobal);
|
||||
displayFont3D->setType(displayFontName,config.getString("FontDisplay",""));
|
||||
displayFont3D->setSize(displayFontSize);
|
||||
//displayFont3D->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(displayFont3D) {
|
||||
displayFont3D->setType(displayFontName,config.getString("FontDisplay",""));
|
||||
displayFont3D->setSize(displayFontSize);
|
||||
//displayFont3D->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -193,14 +232,18 @@ void CoreData::load() {
|
|||
string displayFontNameSmall = displayFontNameSmallPrefix + intToStr(displayFontNameSmallSize) + displayFontNameSmallPostfix;
|
||||
|
||||
displayFontSmall= renderer.newFont(rsGlobal);
|
||||
displayFontSmall->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""));
|
||||
displayFontSmall->setSize(displayFontNameSmallSize);
|
||||
//displayFontSmall->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(displayFontSmall) {
|
||||
displayFontSmall->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""));
|
||||
displayFontSmall->setSize(displayFontNameSmallSize);
|
||||
//displayFontSmall->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
displayFontSmall3D= renderer.newFont3D(rsGlobal);
|
||||
displayFontSmall3D->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""));
|
||||
displayFontSmall3D->setSize(displayFontNameSmallSize);
|
||||
//displayFontSmall3D->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(displayFontSmall3D) {
|
||||
displayFontSmall3D->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""));
|
||||
displayFontSmall3D->setSize(displayFontNameSmallSize);
|
||||
//displayFontSmall3D->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -221,16 +264,20 @@ void CoreData::load() {
|
|||
string menuFontNameNormal= menuFontNameNormalPrefix + intToStr(menuFontNameNormalSize) + menuFontNameNormalPostfix;
|
||||
|
||||
menuFontNormal= renderer.newFont(rsGlobal);
|
||||
menuFontNormal->setType(menuFontNameNormal,config.getString("FontMenuNormal",""));
|
||||
menuFontNormal->setSize(menuFontNameNormalSize);
|
||||
menuFontNormal->setWidth(Font::wBold);
|
||||
//menuFontNormal->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(menuFontNormal) {
|
||||
menuFontNormal->setType(menuFontNameNormal,config.getString("FontMenuNormal",""));
|
||||
menuFontNormal->setSize(menuFontNameNormalSize);
|
||||
menuFontNormal->setWidth(Font::wBold);
|
||||
//menuFontNormal->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
menuFontNormal3D= renderer.newFont3D(rsGlobal);
|
||||
menuFontNormal3D->setType(menuFontNameNormal,config.getString("FontMenuNormal",""));
|
||||
menuFontNormal3D->setSize(menuFontNameNormalSize);
|
||||
menuFontNormal3D->setWidth(Font::wBold);
|
||||
//menuFontNormal3D->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(menuFontNormal3D) {
|
||||
menuFontNormal3D->setType(menuFontNameNormal,config.getString("FontMenuNormal",""));
|
||||
menuFontNormal3D->setSize(menuFontNameNormalSize);
|
||||
menuFontNormal3D->setWidth(Font::wBold);
|
||||
//menuFontNormal3D->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -251,14 +298,18 @@ void CoreData::load() {
|
|||
string menuFontNameBig= menuFontNameBigPrefix+intToStr(menuFontNameBigSize)+menuFontNameBigPostfix;
|
||||
|
||||
menuFontBig= renderer.newFont(rsGlobal);
|
||||
menuFontBig->setType(menuFontNameBig,config.getString("FontMenuBig",""));
|
||||
menuFontBig->setSize(menuFontNameBigSize);
|
||||
//menuFontBig->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(menuFontBig) {
|
||||
menuFontBig->setType(menuFontNameBig,config.getString("FontMenuBig",""));
|
||||
menuFontBig->setSize(menuFontNameBigSize);
|
||||
//menuFontBig->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
menuFontBig3D= renderer.newFont3D(rsGlobal);
|
||||
menuFontBig3D->setType(menuFontNameBig,config.getString("FontMenuBig",""));
|
||||
menuFontBig3D->setSize(menuFontNameBigSize);
|
||||
//menuFontBig3D->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(menuFontBig3D) {
|
||||
menuFontBig3D->setType(menuFontNameBig,config.getString("FontMenuBig",""));
|
||||
menuFontBig3D->setSize(menuFontNameBigSize);
|
||||
//menuFontBig3D->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -279,14 +330,18 @@ void CoreData::load() {
|
|||
string menuFontNameVeryBig= menuFontNameVeryBigPrefix + intToStr(menuFontNameVeryBigSize) + menuFontNameVeryBigPostfix;
|
||||
|
||||
menuFontVeryBig= renderer.newFont(rsGlobal);
|
||||
menuFontVeryBig->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""));
|
||||
menuFontVeryBig->setSize(menuFontNameVeryBigSize);
|
||||
//menuFontVeryBig->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(menuFontVeryBig) {
|
||||
menuFontVeryBig->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""));
|
||||
menuFontVeryBig->setSize(menuFontNameVeryBigSize);
|
||||
//menuFontVeryBig->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
menuFontVeryBig3D= renderer.newFont3D(rsGlobal);
|
||||
menuFontVeryBig3D->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""));
|
||||
menuFontVeryBig3D->setSize(menuFontNameVeryBigSize);
|
||||
//menuFontVeryBig3D->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(menuFontVeryBig3D) {
|
||||
menuFontVeryBig3D->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""));
|
||||
menuFontVeryBig3D->setSize(menuFontNameVeryBigSize);
|
||||
//menuFontVeryBig3D->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
//printf("CoreData menuFontVeryBig3D [%d] menuFontVeryBig3D [%p]\n",menuFontVeryBig3D->getSize(),menuFontVeryBig3D);
|
||||
|
||||
|
@ -310,14 +365,18 @@ void CoreData::load() {
|
|||
string consoleFontName= consoleFontNamePrefix + intToStr(consoleFontNameSize) + consoleFontNamePostfix;
|
||||
|
||||
consoleFont= renderer.newFont(rsGlobal);
|
||||
consoleFont->setType(consoleFontName,config.getString("FontConsole",""));
|
||||
consoleFont->setSize(consoleFontNameSize);
|
||||
//consoleFont->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(consoleFont) {
|
||||
consoleFont->setType(consoleFontName,config.getString("FontConsole",""));
|
||||
consoleFont->setSize(consoleFontNameSize);
|
||||
//consoleFont->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
consoleFont3D= renderer.newFont3D(rsGlobal);
|
||||
consoleFont3D->setType(consoleFontName,config.getString("FontConsole",""));
|
||||
consoleFont3D->setSize(consoleFontNameSize);
|
||||
//consoleFont3D->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
if(consoleFont3D) {
|
||||
consoleFont3D->setType(consoleFontName,config.getString("FontConsole",""));
|
||||
consoleFont3D->setSize(consoleFontNameSize);
|
||||
//consoleFont3D->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -335,7 +394,9 @@ void CoreData::load() {
|
|||
|
||||
for(int i=0; i<6; ++i){
|
||||
waterSounds[i]= new StaticSound();
|
||||
waterSounds[i]->load(dir+"/water_sounds/water"+intToStr(i)+".wav");
|
||||
if(waterSounds[i]) {
|
||||
waterSounds[i]->load(dir+"/water_sounds/water"+intToStr(i)+".wav");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -126,16 +126,20 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
|
|||
|
||||
if(textureEnabled){
|
||||
texture= renderer->newTexture2D(rsGame);
|
||||
if(textureNode->getAttribute("luminance")->getBoolValue()){
|
||||
texture->setFormat(Texture::fAlpha);
|
||||
texture->getPixmap()->init(1);
|
||||
}
|
||||
else{
|
||||
texture->getPixmap()->init(4);
|
||||
if(texture) {
|
||||
if(textureNode->getAttribute("luminance")->getBoolValue()){
|
||||
texture->setFormat(Texture::fAlpha);
|
||||
texture->getPixmap()->init(1);
|
||||
}
|
||||
else{
|
||||
texture->getPixmap()->init(4);
|
||||
}
|
||||
}
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
texture->load(textureNode->getAttribute("path")->getRestrictedValue(currentPath));
|
||||
if(texture) {
|
||||
texture->load(textureNode->getAttribute("path")->getRestrictedValue(currentPath));
|
||||
}
|
||||
loadedFileList[textureNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(parentLoader,textureNode->getAttribute("path")->getRestrictedValue()));
|
||||
}
|
||||
else {
|
||||
|
@ -152,8 +156,9 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
|
|||
|
||||
string path= modelNode->getAttribute("path")->getRestrictedValue(currentPath);
|
||||
model= renderer->newModel(rsGame);
|
||||
|
||||
model->load(path, false, &loadedFileList, &parentLoader);
|
||||
if(model) {
|
||||
model->load(path, false, &loadedFileList, &parentLoader);
|
||||
}
|
||||
loadedFileList[path].push_back(make_pair(parentLoader,modelNode->getAttribute("path")->getRestrictedValue()));
|
||||
|
||||
if(modelNode->hasChild("cycles")) {
|
||||
|
|
|
@ -151,7 +151,10 @@ const int OBJECT_SELECT_OFFSET=100000000;
|
|||
|
||||
// ==================== constructor and destructor ====================
|
||||
|
||||
Renderer::Renderer() {
|
||||
Renderer::Renderer(bool masterserverMode) : BaseRenderer() {
|
||||
this->masterserverMode = masterserverMode;
|
||||
//printf("this->masterserverMode = %d\n",this->masterserverMode);
|
||||
|
||||
Renderer::rendererEnded = false;
|
||||
this->allowRenderUnitTitles = false;
|
||||
this->menu = NULL;
|
||||
|
@ -179,8 +182,6 @@ Renderer::Renderer() {
|
|||
fontManager[i] = NULL;
|
||||
}
|
||||
|
||||
GraphicsInterface &gi= GraphicsInterface::getInstance();
|
||||
FactoryRepository &fr= FactoryRepository::getInstance();
|
||||
Config &config= Config::getInstance();
|
||||
|
||||
Renderer::perspFarPlane = config.getFloat("PerspectiveFarPlane",floatToStr(Renderer::perspFarPlane).c_str());
|
||||
|
@ -189,21 +190,27 @@ Renderer::Renderer() {
|
|||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] Renderer::perspFarPlane [%f] this->no2DMouseRendering [%d] this->maxConsoleLines [%d]\n",__FILE__,__FUNCTION__,__LINE__,Renderer::perspFarPlane,this->no2DMouseRendering,this->maxConsoleLines);
|
||||
|
||||
GraphicsInterface &gi= GraphicsInterface::getInstance();
|
||||
FactoryRepository &fr= FactoryRepository::getInstance();
|
||||
gi.setFactory(fr.getGraphicsFactory(config.getString("FactoryGraphics")));
|
||||
GraphicsFactory *graphicsFactory= GraphicsInterface::getInstance().getFactory();
|
||||
|
||||
modelRenderer= graphicsFactory->newModelRenderer();
|
||||
textRenderer= graphicsFactory->newTextRenderer2D();
|
||||
textRenderer3D = graphicsFactory->newTextRenderer3D();
|
||||
particleRenderer= graphicsFactory->newParticleRenderer();
|
||||
if(this->masterserverMode == false) {
|
||||
modelRenderer= graphicsFactory->newModelRenderer();
|
||||
textRenderer= graphicsFactory->newTextRenderer2D();
|
||||
textRenderer3D = graphicsFactory->newTextRenderer3D();
|
||||
particleRenderer= graphicsFactory->newParticleRenderer();
|
||||
}
|
||||
|
||||
//resources
|
||||
for(int i=0; i< rsCount; ++i) {
|
||||
modelManager[i]= graphicsFactory->newModelManager();
|
||||
textureManager[i]= graphicsFactory->newTextureManager();
|
||||
modelManager[i]->setTextureManager(textureManager[i]);
|
||||
if(this->masterserverMode == false) {
|
||||
modelManager[i]= graphicsFactory->newModelManager();
|
||||
textureManager[i]= graphicsFactory->newTextureManager();
|
||||
modelManager[i]->setTextureManager(textureManager[i]);
|
||||
fontManager[i]= graphicsFactory->newFontManager();
|
||||
}
|
||||
particleManager[i]= graphicsFactory->newParticleManager();
|
||||
fontManager[i]= graphicsFactory->newFontManager();
|
||||
}
|
||||
|
||||
saveScreenShotThread = new SimpleTaskThread(this,0,25);
|
||||
|
@ -295,13 +302,16 @@ bool Renderer::isEnded() {
|
|||
return Renderer::rendererEnded;
|
||||
}
|
||||
|
||||
Renderer &Renderer::getInstance() {
|
||||
static Renderer renderer;
|
||||
Renderer &Renderer::getInstance(bool masterserverMode) {
|
||||
static Renderer renderer(masterserverMode);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
void Renderer::reinitAll() {
|
||||
//resources
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
for(int i=0; i<rsCount; ++i){
|
||||
//modelManager[i]->init();
|
||||
textureManager[i]->init(true);
|
||||
|
@ -325,6 +335,10 @@ void Renderer::init() {
|
|||
config.save();
|
||||
}
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
modelManager[rsGlobal]->init();
|
||||
textureManager[rsGlobal]->init();
|
||||
fontManager[rsGlobal]->init();
|
||||
|
@ -359,6 +373,10 @@ void Renderer::initGame(const Game *game){
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
//shadows
|
||||
if(shadows == sProjected || shadows == sShadowMapping) {
|
||||
static_cast<ModelRendererGl*>(modelRenderer)->setSecondaryTexCoordUnit(2);
|
||||
|
@ -418,6 +436,10 @@ void Renderer::initMenu(const MainMenu *mm) {
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
modelManager[rsMenu]->init();
|
||||
textureManager[rsMenu]->init();
|
||||
fontManager[rsMenu]->init();
|
||||
|
@ -493,6 +515,10 @@ void Renderer::end() {
|
|||
void Renderer::endGame() {
|
||||
game= NULL;
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
//delete resources
|
||||
modelManager[rsGame]->end();
|
||||
textureManager[rsGame]->end();
|
||||
|
@ -512,6 +538,11 @@ void Renderer::endGame() {
|
|||
|
||||
void Renderer::endMenu() {
|
||||
this->menu = NULL;
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
//delete resources
|
||||
modelManager[rsMenu]->end();
|
||||
textureManager[rsMenu]->end();
|
||||
|
@ -522,6 +553,10 @@ void Renderer::endMenu() {
|
|||
}
|
||||
|
||||
void Renderer::reloadResources() {
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i=0; i<rsCount; ++i) {
|
||||
modelManager[i]->end();
|
||||
textureManager[i]->end();
|
||||
|
@ -538,6 +573,10 @@ void Renderer::reloadResources() {
|
|||
// ==================== engine interface ====================
|
||||
|
||||
void Renderer::initTexture(ResourceScope rs, Texture *texture) {
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
textureManager[rs]->initTexture(texture);
|
||||
}
|
||||
|
||||
|
@ -546,6 +585,10 @@ void Renderer::endTexture(ResourceScope rs, Texture *texture, bool mustExistInLi
|
|||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] free texture from manager [%s]\n",__FILE__,__FUNCTION__,__LINE__,textureFilename.c_str());
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
textureManager[rs]->endTexture(texture,mustExistInList);
|
||||
|
||||
if(rs == rsGlobal) {
|
||||
|
@ -559,33 +602,65 @@ void Renderer::endTexture(ResourceScope rs, Texture *texture, bool mustExistInLi
|
|||
}
|
||||
}
|
||||
void Renderer::endLastTexture(ResourceScope rs, bool mustExistInList) {
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
textureManager[rs]->endLastTexture(mustExistInList);
|
||||
}
|
||||
|
||||
Model *Renderer::newModel(ResourceScope rs){
|
||||
if(this->masterserverMode == true) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modelManager[rs]->newModel();
|
||||
}
|
||||
|
||||
void Renderer::endModel(ResourceScope rs, Model *model,bool mustExistInList) {
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
modelManager[rs]->endModel(model,mustExistInList);
|
||||
}
|
||||
void Renderer::endLastModel(ResourceScope rs, bool mustExistInList) {
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
modelManager[rs]->endLastModel(mustExistInList);
|
||||
}
|
||||
|
||||
Texture2D *Renderer::newTexture2D(ResourceScope rs){
|
||||
if(this->masterserverMode == true) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return textureManager[rs]->newTexture2D();
|
||||
}
|
||||
|
||||
Texture3D *Renderer::newTexture3D(ResourceScope rs){
|
||||
if(this->masterserverMode == true) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return textureManager[rs]->newTexture3D();
|
||||
}
|
||||
|
||||
Font2D *Renderer::newFont(ResourceScope rs){
|
||||
if(this->masterserverMode == true) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fontManager[rs]->newFont2D();
|
||||
}
|
||||
|
||||
Font3D *Renderer::newFont3D(ResourceScope rs){
|
||||
if(this->masterserverMode == true) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fontManager[rs]->newFont3D();
|
||||
}
|
||||
|
||||
|
@ -627,6 +702,10 @@ void Renderer::swapBuffers() {
|
|||
|
||||
//places all the opengl lights
|
||||
void Renderer::setupLighting() {
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
int lightCount= 0;
|
||||
const World *world= game->getWorld();
|
||||
const GameCamera *gameCamera= game->getGameCamera();
|
||||
|
@ -5150,9 +5229,12 @@ void Renderer::loadConfig() {
|
|||
//load filter settings
|
||||
Texture2D::Filter textureFilter= strToTextureFilter(config.getString("Filter"));
|
||||
int maxAnisotropy= config.getInt("FilterMaxAnisotropy");
|
||||
for(int i=0; i<rsCount; ++i){
|
||||
textureManager[i]->setFilter(textureFilter);
|
||||
textureManager[i]->setMaxAnisotropy(maxAnisotropy);
|
||||
|
||||
if(this->masterserverMode == false) {
|
||||
for(int i=0; i<rsCount; ++i){
|
||||
textureManager[i]->setFilter(textureFilter);
|
||||
textureManager[i]->setMaxAnisotropy(maxAnisotropy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6741,9 +6823,11 @@ Texture2D * Renderer::preloadTexture(string logoFilename) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
result = renderer.newTexture2D(rsGlobal);
|
||||
result->setMipmap(true);
|
||||
result->load(logoFilename);
|
||||
//renderer.initTexture(rsGlobal,result);
|
||||
if(result) {
|
||||
result->setMipmap(true);
|
||||
result->load(logoFilename);
|
||||
//renderer.initTexture(rsGlobal,result);
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] add texture to manager and cache [%s]\n",__FILE__,__FUNCTION__,__LINE__,logoFilename.c_str());
|
||||
|
||||
|
|
|
@ -266,6 +266,8 @@ private:
|
|||
|
||||
//std::map<Vec3f,Vec3f> worldToScreenPosCache;
|
||||
|
||||
bool masterserverMode;
|
||||
|
||||
std::map<uint32,VisibleQuadContainerVBOCache > mapSurfaceVBOCache;
|
||||
|
||||
class SurfaceData {
|
||||
|
@ -332,12 +334,13 @@ private:
|
|||
Quad2i lastVisibleQuad;
|
||||
} mapRenderer;
|
||||
private:
|
||||
Renderer();
|
||||
Renderer(bool masterserverMode=false);
|
||||
~Renderer();
|
||||
|
||||
public:
|
||||
static Renderer &getInstance();
|
||||
static Renderer &getInstance(bool masterserverMode=false);
|
||||
static bool isEnded();
|
||||
bool isMasterserverMode() const { return masterserverMode; }
|
||||
|
||||
void reinitAll();
|
||||
|
||||
|
|
|
@ -107,6 +107,9 @@ void Intro::update(){
|
|||
|
||||
void Intro::render() {
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
if(renderer.isMasterserverMode() == true) {
|
||||
return;
|
||||
}
|
||||
int difTime=0;
|
||||
|
||||
canRender();
|
||||
|
|
|
@ -95,6 +95,7 @@ static string application_binary="";
|
|||
static string mg_app_name = "";
|
||||
static string mailStringSupport = "";
|
||||
static bool sdl_quitCalled = false;
|
||||
static bool isMasterServerModeEnabled = false;
|
||||
|
||||
FileCRCPreCacheThread *preCacheThread=NULL;
|
||||
|
||||
|
@ -209,8 +210,11 @@ void cleanupCRCThread() {
|
|||
|
||||
static void cleanupProcessObjects() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
showCursor(true);
|
||||
restoreVideoMode(true);
|
||||
|
||||
if(isMasterServerModeEnabled == false) {
|
||||
showCursor(true);
|
||||
restoreVideoMode(true);
|
||||
}
|
||||
|
||||
cleanupCRCThread();
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -487,7 +491,7 @@ public:
|
|||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
program->showMessage(errMsg.c_str());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
for(;program->isMessageShowing();) {
|
||||
for(;isMasterServerModeEnabled == false && program->isMessageShowing();) {
|
||||
//program->getState()->render();
|
||||
Window::handleEvent();
|
||||
program->loop();
|
||||
|
@ -497,7 +501,7 @@ public:
|
|||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
program->showMessage(errMsg.c_str());
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
for(;program->isMessageShowing();) {
|
||||
for(;isMasterServerModeEnabled == false && program->isMessageShowing();) {
|
||||
//program->renderProgramMsgBox();
|
||||
Window::handleEvent();
|
||||
program->loop();
|
||||
|
@ -535,8 +539,10 @@ public:
|
|||
|
||||
#ifdef WIN32
|
||||
|
||||
showCursor(true);
|
||||
restoreVideoMode(true);
|
||||
if(isMasterServerModeEnabled == false) {
|
||||
showCursor(true);
|
||||
restoreVideoMode(true);
|
||||
}
|
||||
|
||||
runtimeErrorMsg = errMsg;
|
||||
throw runtimeErrorMsg;
|
||||
|
@ -2423,6 +2429,9 @@ int glestMain(int argc, char** argv) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if( hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_MASTERSERVER_MODE])) == true) {
|
||||
isMasterServerModeEnabled = true;
|
||||
}
|
||||
|
||||
//off_t fileSize = getFileSize(argv[0]);
|
||||
//double fSize = ((double)fileSize / 1048576.0);
|
||||
|
@ -3136,6 +3145,7 @@ int glestMain(int argc, char** argv) {
|
|||
program->initServer(mainWindow,false,true);
|
||||
}
|
||||
else if(hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_MASTERSERVER_MODE])) == true) {
|
||||
Renderer &renderer= Renderer::getInstance(true);
|
||||
program->initServer(mainWindow,false,true,true);
|
||||
}
|
||||
else if(hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_AUTOSTART_LASTGAME])) == true) {
|
||||
|
@ -3394,7 +3404,9 @@ int glestMain(int argc, char** argv) {
|
|||
string playerTexture = data_path + "data/core/faction_textures/faction" + intToStr(index) + ".tga";
|
||||
if(fileExists(playerTexture) == true) {
|
||||
Texture2D *texture = Renderer::getInstance().newTexture2D(rsGlobal);
|
||||
texture->load(playerTexture);
|
||||
if(texture) {
|
||||
texture->load(playerTexture);
|
||||
}
|
||||
crcPlayerTextureCache[index] = texture;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -158,6 +158,7 @@ void Program::ShowMessageProgramState::update() {
|
|||
// ===================== PUBLIC ========================
|
||||
|
||||
Program::Program() {
|
||||
this->masterserverMode = false;
|
||||
skipRenderFrameCount = 0;
|
||||
programState= NULL;
|
||||
singleton = this;
|
||||
|
@ -169,6 +170,10 @@ Program::Program() {
|
|||
msgBox.setEnabled(false);
|
||||
}
|
||||
|
||||
bool Program::isMasterserverMode() const {
|
||||
return this->masterserverMode;
|
||||
}
|
||||
|
||||
void Program::initNormal(WindowGl *window){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -185,6 +190,7 @@ void Program::initServer(WindowGl *window, bool autostart,bool openNetworkSlots,
|
|||
bool masterserverMode) {
|
||||
MainMenu* mainMenu= NULL;
|
||||
|
||||
this->masterserverMode = masterserverMode;
|
||||
init(window);
|
||||
mainMenu= new MainMenu(this);
|
||||
setState(mainMenu);
|
||||
|
|
|
@ -144,12 +144,16 @@ private:
|
|||
GraphicMessageBox msgBox;
|
||||
int skipRenderFrameCount;
|
||||
|
||||
bool masterserverMode;
|
||||
|
||||
public:
|
||||
Program();
|
||||
~Program();
|
||||
|
||||
static Program *getInstance() {return singleton;}
|
||||
|
||||
bool isMasterserverMode() const;
|
||||
|
||||
GraphicMessageBox * getMsgBox() { return &msgBox; }
|
||||
void initNormal(WindowGl *window);
|
||||
void initServer(WindowGl *window,bool autostart=false,bool openNetworkSlots=false,bool masterserverMode=false);
|
||||
|
|
|
@ -95,24 +95,27 @@ void MainMenu::render() {
|
|||
incrementFps();
|
||||
|
||||
if(state->isMasterserverMode() == false) {
|
||||
renderer.clearBuffers();
|
||||
if(renderer.isMasterserverMode() == false) {
|
||||
renderer.clearBuffers();
|
||||
|
||||
//3d
|
||||
renderer.reset3dMenu();
|
||||
//3d
|
||||
renderer.reset3dMenu();
|
||||
|
||||
renderer.clearZBuffer();
|
||||
renderer.loadCameraMatrix(menuBackground.getCamera());
|
||||
renderer.renderMenuBackground(&menuBackground);
|
||||
renderer.renderParticleManager(rsMenu);
|
||||
renderer.clearZBuffer();
|
||||
renderer.loadCameraMatrix(menuBackground.getCamera());
|
||||
renderer.renderMenuBackground(&menuBackground);
|
||||
renderer.renderParticleManager(rsMenu);
|
||||
|
||||
//2d
|
||||
renderer.reset2d();
|
||||
//2d
|
||||
renderer.reset2d();
|
||||
}
|
||||
state->render();
|
||||
renderer.renderMouse2d(mouseX, mouseY, mouse2dAnim);
|
||||
|
||||
renderer.renderFPSWhenEnabled(lastFps);
|
||||
|
||||
renderer.swapBuffers();
|
||||
if(renderer.isMasterserverMode() == false) {
|
||||
renderer.renderMouse2d(mouseX, mouseY, mouse2dAnim);
|
||||
renderer.renderFPSWhenEnabled(lastFps);
|
||||
renderer.swapBuffers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,10 @@ MenuBackground::MenuBackground(){
|
|||
|
||||
//water texture
|
||||
waterTexture= renderer.newTexture2D(rsMenu);
|
||||
waterTexture->getPixmap()->init(4);
|
||||
waterTexture->getPixmap()->load(data_path + "data/core/menu/textures/water.tga");
|
||||
if(waterTexture) {
|
||||
waterTexture->getPixmap()->init(4);
|
||||
waterTexture->getPixmap()->load(data_path + "data/core/menu/textures/water.tga");
|
||||
}
|
||||
}
|
||||
|
||||
//fog
|
||||
|
@ -104,12 +106,16 @@ MenuBackground::MenuBackground(){
|
|||
|
||||
//load main model
|
||||
mainModel= renderer.newModel(rsMenu);
|
||||
mainModel->load(data_path + "data/core/menu/main_model/menu_main.g3d");
|
||||
if(mainModel) {
|
||||
mainModel->load(data_path + "data/core/menu/main_model/menu_main.g3d");
|
||||
}
|
||||
|
||||
//models
|
||||
for(int i=0; i<5; ++i){
|
||||
characterModels[i]= renderer.newModel(rsMenu);
|
||||
characterModels[i]->load(data_path + "data/core/menu/about_models/character"+intToStr(i)+".g3d");
|
||||
if(characterModels[i]) {
|
||||
characterModels[i]->load(data_path + "data/core/menu/about_models/character"+intToStr(i)+".g3d");
|
||||
}
|
||||
}
|
||||
|
||||
//about position
|
||||
|
|
|
@ -153,7 +153,15 @@ void MenuStateRoot::mouseMove(int x, int y, const MouseState *ms){
|
|||
|
||||
}
|
||||
|
||||
bool MenuStateRoot::isMasterserverMode() const {
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
return renderer.isMasterserverMode();
|
||||
}
|
||||
|
||||
void MenuStateRoot::render() {
|
||||
if(isMasterserverMode() == true) {
|
||||
return;
|
||||
}
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
|
|
|
@ -46,6 +46,8 @@ public:
|
|||
void update();
|
||||
virtual void keyDown(SDL_KeyboardEvent key);
|
||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||
|
||||
virtual bool isMasterserverMode() const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -453,7 +453,9 @@ void Faction::init(
|
|||
|
||||
texture= Renderer::getInstance().newTexture2D(rsGame);
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
texture->load(data_path + "data/core/faction_textures/faction"+intToStr(startLocationIndex)+".tga");
|
||||
if(texture) {
|
||||
texture->load(data_path + "data/core/faction_textures/faction"+intToStr(startLocationIndex)+".tga");
|
||||
}
|
||||
|
||||
if( game->getGameSettings()->getPathFinderType() == pfBasic &&
|
||||
Config::getInstance().getBool("EnableFactionWorkerThreads","true") == true) {
|
||||
|
|
|
@ -57,7 +57,9 @@ void CommandType::load(int id, const XmlNode *n, const string &dir,
|
|||
|
||||
string currentPath = dir;
|
||||
endPathWithSlash(currentPath);
|
||||
image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath));
|
||||
if(image) {
|
||||
image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath));
|
||||
}
|
||||
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(parentLoader,imageNode->getAttribute("path")->getRestrictedValue()));
|
||||
|
||||
//unit requirements
|
||||
|
|
|
@ -38,9 +38,11 @@ ObjectType::~ObjectType(){
|
|||
TilesetModelType* ObjectType::loadModel(const string &path, std::map<string,vector<pair<string, string> > > *loadedFileList,
|
||||
string parentLoader) {
|
||||
Model *model= Renderer::getInstance().newModel(rsGame);
|
||||
model->load(path, false, loadedFileList, &parentLoader);
|
||||
if(model) {
|
||||
model->load(path, false, loadedFileList, &parentLoader);
|
||||
}
|
||||
color= Vec3f(0.f);
|
||||
if(model->getMeshCount()>0 && model->getMesh(0)->getTexture(0) != NULL) {
|
||||
if(model && model->getMeshCount()>0 && model->getMesh(0)->getTexture(0) != NULL) {
|
||||
const Pixmap2D *p= model->getMesh(0)->getTexture(0)->getPixmapConst();
|
||||
color= p->getPixel3f(p->getW()/2, p->getH()/2);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,9 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
|||
//image
|
||||
const XmlNode *imageNode= resourceNode->getChild("image");
|
||||
image= renderer.newTexture2D(rsGame);
|
||||
image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath));
|
||||
if(image) {
|
||||
image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath));
|
||||
}
|
||||
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,imageNode->getAttribute("path")->getRestrictedValue()));
|
||||
|
||||
//type
|
||||
|
@ -94,7 +96,9 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
|||
string modelPath= modelNode->getAttribute("path")->getRestrictedValue(currentPath);
|
||||
|
||||
model= renderer.newModel(rsGame);
|
||||
model->load(modelPath, false, &loadedFileList, &sourceXMLFile);
|
||||
if(model) {
|
||||
model->load(modelPath, false, &loadedFileList, &sourceXMLFile);
|
||||
}
|
||||
loadedFileList[modelPath].push_back(make_pair(sourceXMLFile,modelNode->getAttribute("path")->getRestrictedValue()));
|
||||
|
||||
if(modelNode->hasChild("particles")){
|
||||
|
|
|
@ -192,7 +192,9 @@ void SkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
|||
string path= animationList[i]->getAttribute("path")->getRestrictedValue(currentPath);
|
||||
if(fileExists(path) == true) {
|
||||
Model *animation= Renderer::getInstance().newModel(rsGame);
|
||||
animation->load(path, false, &loadedFileList, &parentLoader);
|
||||
if(animation) {
|
||||
animation->load(path, false, &loadedFileList, &parentLoader);
|
||||
}
|
||||
loadedFileList[path].push_back(make_pair(parentLoader,animationList[i]->getAttribute("path")->getRestrictedValue()));
|
||||
|
||||
animations.push_back(animation);
|
||||
|
|
|
@ -418,13 +418,17 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree,
|
|||
//image
|
||||
const XmlNode *imageNode= parametersNode->getChild("image");
|
||||
image= Renderer::getInstance().newTexture2D(rsGame);
|
||||
image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath));
|
||||
if(image) {
|
||||
image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath));
|
||||
}
|
||||
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,imageNode->getAttribute("path")->getRestrictedValue()));
|
||||
|
||||
//image cancel
|
||||
const XmlNode *imageCancelNode= parametersNode->getChild("image-cancel");
|
||||
cancelImage= Renderer::getInstance().newTexture2D(rsGame);
|
||||
cancelImage->load(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath));
|
||||
if(cancelImage) {
|
||||
cancelImage->load(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath));
|
||||
}
|
||||
loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,imageCancelNode->getAttribute("path")->getRestrictedValue()));
|
||||
|
||||
//meeting point
|
||||
|
@ -432,7 +436,9 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree,
|
|||
meetingPoint= meetingPointNode->getAttribute("value")->getBoolValue();
|
||||
if(meetingPoint) {
|
||||
meetingPointImage= Renderer::getInstance().newTexture2D(rsGame);
|
||||
meetingPointImage->load(meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath));
|
||||
if(meetingPointImage) {
|
||||
meetingPointImage->load(meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath));
|
||||
}
|
||||
loadedFileList[meetingPointNode->getAttribute("image-path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,meetingPointNode->getAttribute("image-path")->getRestrictedValue()));
|
||||
}
|
||||
|
||||
|
|
|
@ -228,7 +228,9 @@ void UpgradeType::load(const string &dir, const TechTree *techTree,
|
|||
//image
|
||||
const XmlNode *imageNode= upgradeNode->getChild("image");
|
||||
image= Renderer::getInstance().newTexture2D(rsGame);
|
||||
image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath,true));
|
||||
if(image) {
|
||||
image->load(imageNode->getAttribute("path")->getRestrictedValue(currentPath,true));
|
||||
}
|
||||
loadedFileList[imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(make_pair(sourceXMLFile,imageNode->getAttribute("path")->getRestrictedValue()));
|
||||
|
||||
//if(fileExists(imageNode->getAttribute("path")->getRestrictedValue(currentPath,true)) == false) {
|
||||
|
@ -238,7 +240,9 @@ void UpgradeType::load(const string &dir, const TechTree *techTree,
|
|||
//image cancel
|
||||
const XmlNode *imageCancelNode= upgradeNode->getChild("image-cancel");
|
||||
cancelImage= Renderer::getInstance().newTexture2D(rsGame);
|
||||
cancelImage->load(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true));
|
||||
if(cancelImage) {
|
||||
cancelImage->load(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true));
|
||||
}
|
||||
loadedFileList[imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)].push_back(make_pair(sourceXMLFile,imageCancelNode->getAttribute("path")->getRestrictedValue()));
|
||||
|
||||
//if(fileExists(imageCancelNode->getAttribute("path")->getRestrictedValue(currentPath,true)) == false) {
|
||||
|
|
|
@ -56,45 +56,52 @@ void Minimap::init(int w, int h, const World *world, bool fogOfWar) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//fow pixmaps
|
||||
float f= 0.f;
|
||||
fowPixmap0= new Pixmap2D(potW, potH, 1);
|
||||
fowPixmap1= new Pixmap2D(potW, potH, 1);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(Renderer::getInstance().isMasterserverMode() == false) {
|
||||
fowPixmap0= new Pixmap2D(potW, potH, 1);
|
||||
fowPixmap1= new Pixmap2D(potW, potH, 1);
|
||||
|
||||
fowPixmap0->setPixels(&f);
|
||||
if((this->gameSettings->getFlagTypes1() & ft1_show_map_resources) == ft1_show_map_resources) {
|
||||
f = 0.f;
|
||||
fowPixmap1->setPixels(&f);
|
||||
f = 0.5f;
|
||||
for (int y=1; y < scaledH - 1; ++y) {
|
||||
for (int x=1; x < scaledW - 1; ++x) {
|
||||
fowPixmap1->setPixel(x, y, &f);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
fowPixmap0->setPixels(&f);
|
||||
if((this->gameSettings->getFlagTypes1() & ft1_show_map_resources) == ft1_show_map_resources) {
|
||||
f = 0.f;
|
||||
fowPixmap1->setPixels(&f);
|
||||
f = 0.5f;
|
||||
for (int y=1; y < scaledH - 1; ++y) {
|
||||
for (int x=1; x < scaledW - 1; ++x) {
|
||||
fowPixmap1->setPixel(x, y, &f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
fowPixmap1->setPixels(&f);
|
||||
else {
|
||||
fowPixmap1->setPixels(&f);
|
||||
}
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//fow tex
|
||||
fowTex= renderer.newTexture2D(rsGame);
|
||||
fowTex->setMipmap(false);
|
||||
fowTex->setPixmapInit(false);
|
||||
fowTex->setFormat(Texture::fAlpha);
|
||||
if(fowTex) {
|
||||
fowTex->setMipmap(false);
|
||||
fowTex->setPixmapInit(false);
|
||||
fowTex->setFormat(Texture::fAlpha);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scaledW = %d, scaledH = %d, potW = %d, potH = %d\n",__FILE__,__FUNCTION__,__LINE__,scaledW,scaledH,potW,potH);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scaledW = %d, scaledH = %d, potW = %d, potH = %d\n",__FILE__,__FUNCTION__,__LINE__,scaledW,scaledH,potW,potH);
|
||||
|
||||
fowTex->getPixmap()->init(potW, potH, 1);
|
||||
fowTex->getPixmap()->setPixels(&f);
|
||||
fowTex->getPixmap()->init(potW, potH, 1);
|
||||
fowTex->getPixmap()->setPixels(&f);
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//tex
|
||||
tex= renderer.newTexture2D(rsGame);
|
||||
tex->getPixmap()->init(scaledW, scaledH, 3);
|
||||
tex->setMipmap(false);
|
||||
if(tex) {
|
||||
tex->getPixmap()->init(scaledW, scaledH, 3);
|
||||
tex->setMipmap(false);
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -112,61 +119,66 @@ Minimap::~Minimap() {
|
|||
// ==================== set ====================
|
||||
|
||||
void Minimap::incFowTextureAlphaSurface(const Vec2i &sPos, float alpha) {
|
||||
if(fowPixmap1) {
|
||||
assert(sPos.x<fowPixmap1->getW() && sPos.y<fowPixmap1->getH());
|
||||
|
||||
assert(sPos.x<fowPixmap1->getW() && sPos.y<fowPixmap1->getH());
|
||||
|
||||
if(fowPixmap1->getPixelf(sPos.x, sPos.y)<alpha){
|
||||
fowPixmap1->setPixel(sPos.x, sPos.y, alpha);
|
||||
if(fowPixmap1->getPixelf(sPos.x, sPos.y)<alpha){
|
||||
fowPixmap1->setPixel(sPos.x, sPos.y, alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Minimap::resetFowTex() {
|
||||
Pixmap2D *tmpPixmap= fowPixmap0;
|
||||
fowPixmap0= fowPixmap1;
|
||||
fowPixmap1= tmpPixmap;
|
||||
if(fowTex) {
|
||||
Pixmap2D *tmpPixmap= fowPixmap0;
|
||||
fowPixmap0= fowPixmap1;
|
||||
fowPixmap1= tmpPixmap;
|
||||
|
||||
// Could turn off ONLY fog of war by setting below to false
|
||||
bool overridefogOfWarValue = fogOfWar;
|
||||
// Could turn off ONLY fog of war by setting below to false
|
||||
bool overridefogOfWarValue = fogOfWar;
|
||||
|
||||
for(int i=0; i<fowTex->getPixmap()->getW(); ++i){
|
||||
for(int j=0; j<fowTex->getPixmap()->getH(); ++j){
|
||||
if ((fogOfWar == false && overridefogOfWarValue == false) &&
|
||||
(gameSettings->getFlagTypes1() & ft1_show_map_resources) != ft1_show_map_resources) {
|
||||
float p0 = fowPixmap0->getPixelf(i, j);
|
||||
float p1 = fowPixmap1->getPixelf(i, j);
|
||||
if (p0 > p1) {
|
||||
fowPixmap1->setPixel(i, j, p0);
|
||||
}
|
||||
else {
|
||||
fowPixmap1->setPixel(i, j, p1);
|
||||
}
|
||||
}
|
||||
else if((fogOfWar && overridefogOfWarValue) ||
|
||||
(gameSettings->getFlagTypes1() & ft1_show_map_resources) != ft1_show_map_resources) {
|
||||
float p0= fowPixmap0->getPixelf(i, j);
|
||||
float p1= fowPixmap1->getPixelf(i, j);
|
||||
|
||||
if(p1>exploredAlpha){
|
||||
fowPixmap1->setPixel(i, j, exploredAlpha);
|
||||
for(int i=0; i<fowTex->getPixmap()->getW(); ++i){
|
||||
for(int j=0; j<fowTex->getPixmap()->getH(); ++j){
|
||||
if ((fogOfWar == false && overridefogOfWarValue == false) &&
|
||||
(gameSettings->getFlagTypes1() & ft1_show_map_resources) != ft1_show_map_resources) {
|
||||
float p0 = fowPixmap0->getPixelf(i, j);
|
||||
float p1 = fowPixmap1->getPixelf(i, j);
|
||||
if (p0 > p1) {
|
||||
fowPixmap1->setPixel(i, j, p0);
|
||||
}
|
||||
else {
|
||||
fowPixmap1->setPixel(i, j, p1);
|
||||
}
|
||||
}
|
||||
if(p0>p1){
|
||||
fowPixmap1->setPixel(i, j, p0);
|
||||
else if((fogOfWar && overridefogOfWarValue) ||
|
||||
(gameSettings->getFlagTypes1() & ft1_show_map_resources) != ft1_show_map_resources) {
|
||||
float p0= fowPixmap0->getPixelf(i, j);
|
||||
float p1= fowPixmap1->getPixelf(i, j);
|
||||
|
||||
if(p1>exploredAlpha){
|
||||
fowPixmap1->setPixel(i, j, exploredAlpha);
|
||||
}
|
||||
if(p0>p1){
|
||||
fowPixmap1->setPixel(i, j, p0);
|
||||
}
|
||||
}
|
||||
else{
|
||||
fowPixmap1->setPixel(i, j, 1.f);
|
||||
}
|
||||
}
|
||||
else{
|
||||
fowPixmap1->setPixel(i, j, 1.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Minimap::updateFowTex(float t) {
|
||||
for(int i=0; i<fowPixmap0->getW(); ++i){
|
||||
for(int j=0; j<fowPixmap0->getH(); ++j){
|
||||
float p1= fowPixmap1->getPixelf(i, j);
|
||||
if(p1!=fowTex->getPixmap()->getPixelf(i, j)){
|
||||
float p0= fowPixmap0->getPixelf(i, j);
|
||||
fowTex->getPixmap()->setPixel(i, j, p0+(t*(p1-p0)));
|
||||
if(fowPixmap0 && fowTex) {
|
||||
for(int i=0; i<fowPixmap0->getW(); ++i){
|
||||
for(int j=0; j<fowPixmap0->getH(); ++j){
|
||||
float p1= fowPixmap1->getPixelf(i, j);
|
||||
if(p1!=fowTex->getPixmap()->getPixelf(i, j)){
|
||||
float p0= fowPixmap0->getPixelf(i, j);
|
||||
fowTex->getPixmap()->setPixel(i, j, p0+(t*(p1-p0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,29 +191,31 @@ void Minimap::computeTexture(const World *world) {
|
|||
Vec3f color;
|
||||
const Map *map= world->getMap();
|
||||
|
||||
tex->getPixmap()->setPixels(Vec4f(1.f, 1.f, 1.f, 0.1f).ptr());
|
||||
if(tex) {
|
||||
tex->getPixmap()->setPixels(Vec4f(1.f, 1.f, 1.f, 0.1f).ptr());
|
||||
|
||||
for(int j=0; j<tex->getPixmap()->getH(); ++j){
|
||||
for(int i=0; i<tex->getPixmap()->getW(); ++i){
|
||||
SurfaceCell *sc= map->getSurfaceCell(i, j);
|
||||
for(int j=0; j<tex->getPixmap()->getH(); ++j){
|
||||
for(int i=0; i<tex->getPixmap()->getW(); ++i){
|
||||
SurfaceCell *sc= map->getSurfaceCell(i, j);
|
||||
|
||||
if(sc->getObject()==NULL || sc->getObject()->getType()==NULL){
|
||||
const Pixmap2D *p= world->getTileset()->getSurfPixmap(sc->getSurfaceType(), 0);
|
||||
color= p->getPixel3f(p->getW()/2, p->getH()/2);
|
||||
color= color * static_cast<float>(sc->getVertex().y/6.f);
|
||||
if(sc->getObject()==NULL || sc->getObject()->getType()==NULL){
|
||||
const Pixmap2D *p= world->getTileset()->getSurfPixmap(sc->getSurfaceType(), 0);
|
||||
color= p->getPixel3f(p->getW()/2, p->getH()/2);
|
||||
color= color * static_cast<float>(sc->getVertex().y/6.f);
|
||||
|
||||
if(sc->getVertex().y<= world->getMap()->getWaterLevel()){
|
||||
color+= Vec3f(0.5f, 0.5f, 1.0f);
|
||||
if(sc->getVertex().y<= world->getMap()->getWaterLevel()){
|
||||
color+= Vec3f(0.5f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
if(color.x>1.f) color.x=1.f;
|
||||
if(color.y>1.f) color.y=1.f;
|
||||
if(color.z>1.f) color.z=1.f;
|
||||
}
|
||||
|
||||
if(color.x>1.f) color.x=1.f;
|
||||
if(color.y>1.f) color.y=1.f;
|
||||
if(color.z>1.f) color.z=1.f;
|
||||
else{
|
||||
color= sc->getObject()->getType()->getColor();
|
||||
}
|
||||
tex->getPixmap()->setPixel(i, j, color);
|
||||
}
|
||||
else{
|
||||
color= sc->getObject()->getType()->getColor();
|
||||
}
|
||||
tex->getPixmap()->setPixel(i, j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,22 +87,28 @@ void SurfaceAtlas::addSurface(SurfaceInfo *si) {
|
|||
if(it == surfaceInfos.end()) {
|
||||
//add new texture
|
||||
Texture2D *t= Renderer::getInstance().newTexture2D(rsGame);
|
||||
if(t == NULL) {
|
||||
throw runtime_error("Could not create new texture (NULL)");
|
||||
if(t) {
|
||||
//if(t == NULL) {
|
||||
// throw runtime_error("Could not create new texture (NULL)");
|
||||
//}
|
||||
t->setWrapMode(Texture::wmClampToEdge);
|
||||
t->getPixmap()->init(surfaceSize, surfaceSize, 3);
|
||||
}
|
||||
t->setWrapMode(Texture::wmClampToEdge);
|
||||
t->getPixmap()->init(surfaceSize, surfaceSize, 3);
|
||||
|
||||
si->setCoord(Vec2f(0.f, 0.f));
|
||||
si->setTexture(t);
|
||||
surfaceInfos.push_back(*si);
|
||||
|
||||
//copy texture to pixmap
|
||||
if(si->getCenter()!=NULL){
|
||||
t->getPixmap()->copy(si->getCenter());
|
||||
if(si->getCenter() != NULL) {
|
||||
if(t) {
|
||||
t->getPixmap()->copy(si->getCenter());
|
||||
}
|
||||
}
|
||||
else{
|
||||
t->getPixmap()->splat(si->getLeftUp(), si->getRightUp(), si->getLeftDown(), si->getRightDown());
|
||||
else {
|
||||
if(t) {
|
||||
t->getPixmap()->splat(si->getLeftUp(), si->getRightUp(), si->getLeftDown(), si->getRightDown());
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
@ -116,6 +122,10 @@ float SurfaceAtlas::getCoordStep() const {
|
|||
}
|
||||
|
||||
void SurfaceAtlas::checkDimensions(const Pixmap2D *p) {
|
||||
if(Renderer::getInstance().isMasterserverMode() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(p == NULL) {
|
||||
throw runtime_error("Bad surface texture pixmap (NULL)");
|
||||
}
|
||||
|
|
|
@ -262,17 +262,23 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
|
|||
//water
|
||||
const XmlNode *waterNode= parametersNode->getChild("water");
|
||||
waterTex= renderer.newTexture3D(rsGame);
|
||||
waterTex->setMipmap(false);
|
||||
waterTex->setWrapMode(Texture::wmRepeat);
|
||||
if(waterTex) {
|
||||
waterTex->setMipmap(false);
|
||||
waterTex->setWrapMode(Texture::wmRepeat);
|
||||
}
|
||||
waterEffects= waterNode->getAttribute("effects")->getBoolValue();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
int waterFrameCount= waterNode->getChildCount();
|
||||
waterTex->getPixmap()->init(waterFrameCount, 4);
|
||||
if(waterTex) {
|
||||
waterTex->getPixmap()->init(waterFrameCount, 4);
|
||||
}
|
||||
for(int i=0; i<waterFrameCount; ++i){
|
||||
const XmlNode *waterFrameNode= waterNode->getChild("texture", i);
|
||||
waterTex->getPixmap()->loadSlice(waterFrameNode->getAttribute("path")->getRestrictedValue(currentPath), i);
|
||||
if(waterTex) {
|
||||
waterTex->getPixmap()->loadSlice(waterFrameNode->getAttribute("path")->getRestrictedValue(currentPath), i);
|
||||
}
|
||||
loadedFileList[waterFrameNode->getAttribute("path")->getRestrictedValue(currentPath)].push_back(make_pair(sourceXMLFile,waterFrameNode->getAttribute("path")->getRestrictedValue()));
|
||||
}
|
||||
|
||||
|
|
|
@ -1236,7 +1236,9 @@ void World::initFactionTypes(GameSettings *gs) {
|
|||
stats.setControl(i, gs->getFactionControl(i));
|
||||
stats.setResourceMultiplier(i,(gs->getResourceMultiplierIndex(i)+5)*0.1f);
|
||||
stats.setPlayerName(i,gs->getNetworkPlayerName(i));
|
||||
stats.setPlayerColor(i,getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0));
|
||||
if(getFaction(i)->getTexture()) {
|
||||
stats.setPlayerColor(i,getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
|
Loading…
Reference in New Issue