- added a new bit style gamesetting flag for future new game settings.
- added ability to see map resources but still keep fog of war (GAE's shroud of darkness), but not activated by UI yet, tested and works
This commit is contained in:
parent
1c51b6c21d
commit
f204d4445c
|
@ -116,7 +116,8 @@ public:
|
|||
~Game();
|
||||
|
||||
//get
|
||||
GameSettings *getGameSettings() {return &gameSettings;}
|
||||
GameSettings *getGameSettings() {return &gameSettings;}
|
||||
const GameSettings *getReadOnlyGameSettings() const {return &gameSettings;}
|
||||
|
||||
const GameCamera *getGameCamera() const {return &gameCamera;}
|
||||
GameCamera *getGameCamera() {return &gameCamera;}
|
||||
|
|
|
@ -24,6 +24,16 @@ namespace Glest{ namespace Game{
|
|||
// class GameSettings
|
||||
// =====================================================
|
||||
|
||||
enum FlagTypes1 {
|
||||
ft1_none = 0x00,
|
||||
ft1_show_map_resources = 0x01
|
||||
//ft1_xx = 0x02,
|
||||
//ft1_xx = 0x04,
|
||||
//ft1_xx = 0x08,
|
||||
//ft1_xx = 0x10,
|
||||
};
|
||||
|
||||
|
||||
class GameSettings{
|
||||
private:
|
||||
string description;
|
||||
|
@ -43,7 +53,7 @@ private:
|
|||
int teams[GameConstants::maxPlayers];
|
||||
int startLocationIndex[GameConstants::maxPlayers];
|
||||
int mapFilterIndex;
|
||||
|
||||
|
||||
|
||||
bool defaultUnits;
|
||||
bool defaultResources;
|
||||
|
@ -57,6 +67,8 @@ private:
|
|||
bool networkPauseGameForLaggedClients;
|
||||
PathFinderType pathFinderType;
|
||||
|
||||
uint32 flagTypes1;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
@ -78,6 +90,8 @@ public:
|
|||
teams[i] = 0;
|
||||
startLocationIndex[i] = i;
|
||||
}
|
||||
|
||||
flagTypes1 = ft1_none;
|
||||
}
|
||||
|
||||
// default copy constructor will do fine, and will maintain itself ;)
|
||||
|
@ -131,6 +145,7 @@ public:
|
|||
int getNetworkFramePeriod() const {return networkFramePeriod; }
|
||||
bool getNetworkPauseGameForLaggedClients() const {return networkPauseGameForLaggedClients; }
|
||||
PathFinderType getPathFinderType() const { return pathFinderType; }
|
||||
uint32 getFlagTypes1() const { return flagTypes1;}
|
||||
|
||||
//set
|
||||
void setDescription(const string& description) {this->description= description;}
|
||||
|
@ -144,7 +159,7 @@ public:
|
|||
void setNetworkPlayerName(int factionIndex,const string& playername) {this->networkPlayerNames[factionIndex]= playername;}
|
||||
void setFactionControl(int factionIndex, ControlType controller) {this->factionControls[factionIndex]= controller;}
|
||||
void setResourceMultiplierIndex(int factionIndex, int multiplierIndex) {this->resourceMultiplierIndex[factionIndex]= multiplierIndex;}
|
||||
|
||||
|
||||
void setThisFactionIndex(int thisFactionIndex) {this->thisFactionIndex= thisFactionIndex;}
|
||||
void setFactionCount(int factionCount) {this->factionCount= factionCount;}
|
||||
void setTeam(int factionIndex, int team) {this->teams[factionIndex]= team;}
|
||||
|
@ -162,6 +177,7 @@ public:
|
|||
void setNetworkFramePeriod(int value) {this->networkFramePeriod = value; }
|
||||
void setNetworkPauseGameForLaggedClients(bool value) {this->networkPauseGameForLaggedClients = value; }
|
||||
void setPathFinderType(PathFinderType value) {this->pathFinderType = value; }
|
||||
void setFlagTypes1(uint32 value) {this->flagTypes1 = value; }
|
||||
|
||||
string toString() const {
|
||||
string result = "";
|
||||
|
@ -197,6 +213,7 @@ public:
|
|||
result += "networkFramePeriod = " + intToStr(networkFramePeriod) + "\n";
|
||||
result += "networkPauseGameForLaggedClients = " + intToStr(networkPauseGameForLaggedClients) + "\n";
|
||||
result += "pathFinderType = " + intToStr(pathFinderType) + "\n";
|
||||
result += "flagTypes1 = " + intToStr(flagTypes1) + "\n";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1965,6 +1965,10 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
|||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
// Test flags values
|
||||
//gameSettings->setFlagTypes1(ft1_show_map_resources);
|
||||
//
|
||||
|
||||
gameSettings->setMapFilterIndex(listBoxMapFilter.getSelectedItemIndex());
|
||||
gameSettings->setDescription(formatString(getCurrentMapFile()));
|
||||
gameSettings->setMap(getCurrentMapFile());
|
||||
|
|
|
@ -232,6 +232,7 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
|
|||
data.networkFramePeriod = gameSettings->getNetworkFramePeriod();
|
||||
data.networkPauseGameForLaggedClients = gameSettings->getNetworkPauseGameForLaggedClients();
|
||||
data.pathFinderType = gameSettings->getPathFinderType();
|
||||
data.flagTypes1 = gameSettings->getFlagTypes1();
|
||||
|
||||
for(int i= 0; i<data.factionCount; ++i){
|
||||
data.factionTypeNames[i]= gameSettings->getFactionTypeName(i);
|
||||
|
@ -261,6 +262,7 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const{
|
|||
gameSettings->setNetworkFramePeriod(data.networkFramePeriod);
|
||||
gameSettings->setNetworkPauseGameForLaggedClients((data.networkPauseGameForLaggedClients != 0));
|
||||
gameSettings->setPathFinderType(static_cast<PathFinderType>(data.pathFinderType));
|
||||
gameSettings->setFlagTypes1(data.flagTypes1);
|
||||
|
||||
for(int i= 0; i<data.factionCount; ++i){
|
||||
gameSettings->setFactionTypeName(i, data.factionTypeNames[i].getString());
|
||||
|
|
|
@ -211,6 +211,7 @@ private:
|
|||
uint8 networkFramePeriod; // allowed values 0 - 255
|
||||
int8 networkPauseGameForLaggedClients;
|
||||
int8 pathFinderType;
|
||||
uint32 flagTypes1;
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
//
|
||||
// Copyright (C) 2001-2008 Martio 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
|
||||
// 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
|
||||
// ==============================================================
|
||||
|
||||
|
@ -15,9 +15,10 @@
|
|||
|
||||
#include "world.h"
|
||||
#include "vec.h"
|
||||
#include "renderer.h"
|
||||
#include "renderer.h"
|
||||
#include "config.h"
|
||||
#include "object.h"
|
||||
#include "game_settings.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Graphics;
|
||||
|
@ -34,21 +35,36 @@ Minimap::Minimap() {
|
|||
fowPixmap0= NULL;
|
||||
fowPixmap1= NULL;
|
||||
fogOfWar= true;//Config::getInstance().getBool("FogOfWar");
|
||||
gameSettings= NULL;
|
||||
}
|
||||
|
||||
void Minimap::init(int w, int h, const World *world, bool fogOfWar){
|
||||
void Minimap::init(int w, int h, const World *world, bool fogOfWar) {
|
||||
int scaledW= w/Map::cellScale;
|
||||
int scaledH= h/Map::cellScale;
|
||||
|
||||
this->fogOfWar = fogOfWar;
|
||||
this->gameSettings = world->getGameSettings();
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
|
||||
//fow pixmaps
|
||||
float f= 0.f;
|
||||
fowPixmap0= new Pixmap2D(next2Power(scaledW), next2Power(scaledH), 1);
|
||||
fowPixmap1= new Pixmap2D(next2Power(scaledW), next2Power(scaledH), 1);
|
||||
|
||||
fowPixmap0->setPixels(&f);
|
||||
fowPixmap1->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);
|
||||
}
|
||||
|
||||
//fow tex
|
||||
fowTex= renderer.newTexture2D(rsGame);
|
||||
|
@ -62,7 +78,7 @@ void Minimap::init(int w, int h, const World *world, bool fogOfWar){
|
|||
tex= renderer.newTexture2D(rsGame);
|
||||
tex->getPixmap()->init(scaledW, scaledH, 3);
|
||||
tex->setMipmap(false);
|
||||
|
||||
|
||||
computeTexture(world);
|
||||
}
|
||||
|
||||
|
@ -75,9 +91,9 @@ Minimap::~Minimap() {
|
|||
// ==================== set ====================
|
||||
|
||||
void Minimap::incFowTextureAlphaSurface(const Vec2i &sPos, float alpha) {
|
||||
|
||||
|
||||
assert(sPos.x<fowPixmap1->getW() && sPos.y<fowPixmap1->getH());
|
||||
|
||||
|
||||
if(fowPixmap1->getPixelf(sPos.x, sPos.y)<alpha){
|
||||
fowPixmap1->setPixel(sPos.x, sPos.y, alpha);
|
||||
}
|
||||
|
@ -93,7 +109,19 @@ void Minimap::resetFowTex() {
|
|||
|
||||
for(int i=0; i<fowTex->getPixmap()->getW(); ++i){
|
||||
for(int j=0; j<fowTex->getPixmap()->getH(); ++j){
|
||||
if(fogOfWar && overridefogOfWarValue){
|
||||
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);
|
||||
|
||||
|
@ -117,13 +145,13 @@ void Minimap::updateFowTex(float t) {
|
|||
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)));
|
||||
fowTex->getPixmap()->setPixel(i, j, p0+(t*(p1-p0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== PRIVATE ====================
|
||||
// ==================== PRIVATE ====================
|
||||
|
||||
void Minimap::computeTexture(const World *world) {
|
||||
|
||||
|
@ -134,8 +162,8 @@ void Minimap::computeTexture(const World *world) {
|
|||
|
||||
for(int j=0; j<tex->getPixmap()->getH(); ++j){
|
||||
for(int i=0; i<tex->getPixmap()->getW(); ++i){
|
||||
SurfaceCell *sc= map->getSurfaceCell(i, j);
|
||||
|
||||
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);
|
||||
|
@ -149,7 +177,7 @@ void Minimap::computeTexture(const World *world) {
|
|||
if(color.y>1.f) color.y=1.f;
|
||||
if(color.z>1.f) color.z=1.f;
|
||||
}
|
||||
else{
|
||||
else{
|
||||
color= sc->getObject()->getType()->getColor();
|
||||
}
|
||||
tex->getPixmap()->setPixel(i, j, color);
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
//
|
||||
// Copyright (C) 2001-2008 Martio 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
|
||||
// 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
|
||||
// ==============================================================
|
||||
|
||||
|
@ -24,7 +24,8 @@ using Shared::Graphics::Vec2i;
|
|||
using Shared::Graphics::Pixmap2D;
|
||||
using Shared::Graphics::Texture2D;
|
||||
|
||||
class World;
|
||||
class World;
|
||||
class GameSettings;
|
||||
|
||||
enum ExplorationState{
|
||||
esNotExplored,
|
||||
|
@ -33,7 +34,7 @@ enum ExplorationState{
|
|||
};
|
||||
|
||||
// =====================================================
|
||||
// class Minimap
|
||||
// class Minimap
|
||||
//
|
||||
/// State of the in-game minimap
|
||||
// =====================================================
|
||||
|
@ -44,7 +45,8 @@ private:
|
|||
Pixmap2D *fowPixmap1;
|
||||
Texture2D *tex;
|
||||
Texture2D *fowTex; //Fog Of War Texture2D
|
||||
bool fogOfWar;
|
||||
bool fogOfWar;
|
||||
const GameSettings *gameSettings;
|
||||
|
||||
private:
|
||||
static const float exploredAlpha;
|
||||
|
@ -66,6 +68,6 @@ private:
|
|||
void computeTexture(const World *world);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -876,7 +876,7 @@ void World::initCells(bool fogOfWar) {
|
|||
j/(next2Power(map.getSurfaceH())-1.f)));
|
||||
|
||||
for (int k = 0; k < GameConstants::maxPlayers; k++) {
|
||||
sc->setExplored(k, !fogOfWar);
|
||||
sc->setExplored(k, (game->getGameSettings()->getFlagTypes1() & ft1_show_map_resources) == ft1_show_map_resources);
|
||||
sc->setVisible(k, !fogOfWar);
|
||||
}
|
||||
for (int k = GameConstants::maxPlayers; k < GameConstants::maxPlayers + GameConstants::specialFactions; k++) {
|
||||
|
@ -1342,6 +1342,10 @@ void World::computeFow(int factionIdxToTick) {
|
|||
}
|
||||
}
|
||||
|
||||
const GameSettings * World::getGameSettings() const {
|
||||
return (game != NULL ? game->getReadOnlyGameSettings() : NULL);
|
||||
}
|
||||
|
||||
// WARNING! This id is critical! Make sure it fits inside the network packet
|
||||
// (currently cannot be larger than 2,147,483,647)
|
||||
// Make sure each faction has their own unique section of id #'s for proper
|
||||
|
|
|
@ -196,7 +196,8 @@ public:
|
|||
int getUnitCount(int factionIndex);
|
||||
int getUnitCountOfType(int factionIndex, const string &typeName);
|
||||
|
||||
Game * getGame() { return game; }
|
||||
Game * getGame() { return game; }
|
||||
const GameSettings * getGameSettings() const;
|
||||
|
||||
std::vector<std::string> validateFactionTypes();
|
||||
std::vector<std::string> validateResourceTypes();
|
||||
|
|
Loading…
Reference in New Issue