up to 36 units selectable; maps can set camera heigth now ( be careful with this for performance reasons! )
This commit is contained in:
parent
4cb2485cdf
commit
922df8e025
|
@ -552,7 +552,11 @@ void Game::init(bool initForPreviewOnly)
|
||||||
|
|
||||||
gameCamera.init(map->getW(), map->getH());
|
gameCamera.init(map->getW(), map->getH());
|
||||||
|
|
||||||
if(gameCamera.getCalculatedDefault()<map->getMaxMapHeight()+13.0f){
|
// camera default height calculation
|
||||||
|
if(map->getCameraHeight()>0 && gameCamera.getCalculatedDefault()<map->getCameraHeight()){
|
||||||
|
gameCamera.setCalculatedDefault(map->getCameraHeight());
|
||||||
|
}
|
||||||
|
else if(gameCamera.getCalculatedDefault()<map->getMaxMapHeight()+13.0f){
|
||||||
gameCamera.setCalculatedDefault(map->getMaxMapHeight()+13.0f);
|
gameCamera.setCalculatedDefault(map->getMaxMapHeight()+13.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3195,7 +3195,7 @@ void Renderer::renderDisplay(){
|
||||||
renderQuad(
|
renderQuad(
|
||||||
metrics.getDisplayX()+display->computeUpX(i),
|
metrics.getDisplayX()+display->computeUpX(i),
|
||||||
metrics.getDisplayY()+display->computeUpY(i),
|
metrics.getDisplayY()+display->computeUpY(i),
|
||||||
Display::imageSize, Display::imageSize, display->getUpImage(i));
|
display->getUpImageSize(), display->getUpImageSize(), display->getUpImage(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,21 @@ Display::Display(){
|
||||||
colors[8]= Vec4f(1.0f, 1.0f, 1.0f, 1.0f);
|
colors[8]= Vec4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
currentColor= 0;
|
currentColor= 0;
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Display::calculateUpDimensions(int index) {
|
||||||
|
if(index>maxUpIndex){
|
||||||
|
maxUpIndex=index;
|
||||||
|
if(maxUpIndex+1>upCellSideCount*upCellSideCount){
|
||||||
|
upCellSideCount=upCellSideCount+1;
|
||||||
|
upImageSize=imageSize*cellSideCount/upCellSideCount+0.9f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vec4f Display::getColor() const {
|
Vec4f Display::getColor() const {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] currentColor = %d\n",__FILE__,__FUNCTION__,__LINE__,currentColor);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] currentColor = %d\n",__FILE__,__FUNCTION__,__LINE__,currentColor);
|
||||||
if(currentColor < 0 || currentColor >= colorCount) {
|
if(currentColor < 0 || currentColor >= colorCount) {
|
||||||
|
@ -54,6 +63,13 @@ Vec4f Display::getColor() const {
|
||||||
return colors[currentColor];
|
return colors[currentColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Display::setUpImage(int i, const Texture2D *image)
|
||||||
|
{
|
||||||
|
if(i>=upCellCount) throw runtime_error("i>=upCellCount in Display::setUpImage");
|
||||||
|
upImages[i]= image;
|
||||||
|
calculateUpDimensions(i);
|
||||||
|
}
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
void Display::clear(){
|
void Display::clear(){
|
||||||
for(int i=0; i<upCellCount; ++i){
|
for(int i=0; i<upCellCount; ++i){
|
||||||
|
@ -71,6 +87,10 @@ void Display::clear(){
|
||||||
title.clear();
|
title.clear();
|
||||||
text.clear();
|
text.clear();
|
||||||
progressBar= -1;
|
progressBar= -1;
|
||||||
|
|
||||||
|
upCellSideCount=cellSideCount;
|
||||||
|
upImageSize=imageSize;
|
||||||
|
maxUpIndex= 0;
|
||||||
}
|
}
|
||||||
void Display::switchColor(){
|
void Display::switchColor(){
|
||||||
currentColor= (currentColor+1) % colorCount;
|
currentColor= (currentColor+1) % colorCount;
|
||||||
|
@ -103,11 +123,11 @@ int Display::computeDownY(int index) const{
|
||||||
}
|
}
|
||||||
|
|
||||||
int Display::computeUpX(int index) const{
|
int Display::computeUpX(int index) const{
|
||||||
return (index % cellSideCount) * imageSize;
|
return (index % upCellSideCount) * upImageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Display::computeUpY(int index) const{
|
int Display::computeUpY(int index) const{
|
||||||
return Metrics::getInstance().getDisplayH() - (index/cellSideCount)*imageSize - imageSize;
|
return Metrics::getInstance().getDisplayH() - (index/upCellSideCount)*upImageSize - upImageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Glest{ namespace Game{
|
||||||
class Display{
|
class Display{
|
||||||
public:
|
public:
|
||||||
static const int cellSideCount= 4;
|
static const int cellSideCount= 4;
|
||||||
static const int upCellCount= cellSideCount*cellSideCount;
|
static const int upCellCount= 36;
|
||||||
static const int downCellCount= cellSideCount*cellSideCount;
|
static const int downCellCount= cellSideCount*cellSideCount;
|
||||||
static const int colorCount= 9;
|
static const int colorCount= 9;
|
||||||
static const int imageSize= 32;
|
static const int imageSize= 32;
|
||||||
|
@ -59,6 +59,10 @@ private:
|
||||||
Vec4f colors[colorCount];
|
Vec4f colors[colorCount];
|
||||||
int currentColor;
|
int currentColor;
|
||||||
|
|
||||||
|
int upCellSideCount;
|
||||||
|
int upImageSize;
|
||||||
|
int maxUpIndex;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Display();
|
Display();
|
||||||
|
@ -75,12 +79,14 @@ public:
|
||||||
Vec4f getColor() const;
|
Vec4f getColor() const;
|
||||||
int getProgressBar() const {return progressBar;}
|
int getProgressBar() const {return progressBar;}
|
||||||
int getDownSelectedPos() const {return downSelectedPos;}
|
int getDownSelectedPos() const {return downSelectedPos;}
|
||||||
|
int getUpCellSideCount() const {return upCellSideCount;}
|
||||||
|
int getUpImageSize() const {return upImageSize;}
|
||||||
|
|
||||||
//set
|
//set
|
||||||
void setTitle(const string title) {this->title= formatString(title);}
|
void setTitle(const string title) {this->title= formatString(title);}
|
||||||
void setText(const string &text) {this->text= formatString(text);}
|
void setText(const string &text) {this->text= formatString(text);}
|
||||||
void setInfoText(const string infoText) {this->infoText= formatString(infoText);}
|
void setInfoText(const string infoText) {this->infoText= formatString(infoText);}
|
||||||
void setUpImage(int i, const Texture2D *image) {upImages[i]= image;}
|
void setUpImage(int i, const Texture2D *image);
|
||||||
void setDownImage(int i, const Texture2D *image) {downImages[i]= image;}
|
void setDownImage(int i, const Texture2D *image) {downImages[i]= image;}
|
||||||
void setCommandType(int i, const CommandType *ct) {commandTypes[i]= ct;}
|
void setCommandType(int i, const CommandType *ct) {commandTypes[i]= ct;}
|
||||||
void setCommandClass(int i, const CommandClass cc) {commandClasses[i]= cc;}
|
void setCommandClass(int i, const CommandClass cc) {commandClasses[i]= cc;}
|
||||||
|
@ -96,6 +102,9 @@ public:
|
||||||
int computeDownY(int index) const;
|
int computeDownY(int index) const;
|
||||||
int computeUpX(int index) const;
|
int computeUpX(int index) const;
|
||||||
int computeUpY(int index) const;
|
int computeUpY(int index) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void calculateUpDimensions(int index);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int maxGroups= 10;
|
static const int maxGroups= 10;
|
||||||
static const int maxUnits= 16;
|
static const int maxUnits= 36;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int factionIndex;
|
int factionIndex;
|
||||||
|
|
|
@ -106,6 +106,7 @@ Map::Map() {
|
||||||
waterLevel=0;
|
waterLevel=0;
|
||||||
heightFactor=0;
|
heightFactor=0;
|
||||||
cliffLevel=0;
|
cliffLevel=0;
|
||||||
|
cameraHeight=0;
|
||||||
w=0;
|
w=0;
|
||||||
h=0;
|
h=0;
|
||||||
surfaceW=0;
|
surfaceW=0;
|
||||||
|
@ -204,6 +205,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
|
||||||
w= surfaceW*cellScale;
|
w= surfaceW*cellScale;
|
||||||
h= surfaceH*cellScale;
|
h= surfaceH*cellScale;
|
||||||
cliffLevel = 0;
|
cliffLevel = 0;
|
||||||
|
cameraHeight = 0;
|
||||||
if(header.version==1){
|
if(header.version==1){
|
||||||
//desc = header.description;
|
//desc = header.description;
|
||||||
}
|
}
|
||||||
|
@ -212,8 +214,9 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
|
||||||
if(header.version2.cliffLevel>0){
|
if(header.version2.cliffLevel>0){
|
||||||
cliffLevel=static_cast<float>((header.version2.cliffLevel-0.01f)/(heightFactor));
|
cliffLevel=static_cast<float>((header.version2.cliffLevel-0.01f)/(heightFactor));
|
||||||
}
|
}
|
||||||
else {
|
if(header.version2.cameraHeight>0)
|
||||||
cliffLevel=0;
|
{
|
||||||
|
cameraHeight = header.version2.cameraHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,7 @@ private:
|
||||||
float waterLevel;
|
float waterLevel;
|
||||||
float heightFactor;
|
float heightFactor;
|
||||||
float cliffLevel;
|
float cliffLevel;
|
||||||
|
int cameraHeight;
|
||||||
int w;
|
int w;
|
||||||
int h;
|
int h;
|
||||||
int surfaceW;
|
int surfaceW;
|
||||||
|
@ -195,6 +196,7 @@ public:
|
||||||
float getHeightFactor() const {return heightFactor;}
|
float getHeightFactor() const {return heightFactor;}
|
||||||
float getWaterLevel() const {return waterLevel;}
|
float getWaterLevel() const {return waterLevel;}
|
||||||
float getCliffLevel() const {return cliffLevel;}
|
float getCliffLevel() const {return cliffLevel;}
|
||||||
|
int getCameraHeight() const {return cameraHeight;}
|
||||||
float getMaxMapHeight() const {return maxMapHeight;}
|
float getMaxMapHeight() const {return maxMapHeight;}
|
||||||
Vec2i getStartLocation(int locationIndex) const;
|
Vec2i getStartLocation(int locationIndex) const;
|
||||||
bool getSubmerged(const SurfaceCell *sc) const {return sc->getHeight()<waterLevel;}
|
bool getSubmerged(const SurfaceCell *sc) const {return sc->getHeight()<waterLevel;}
|
||||||
|
|
|
@ -726,13 +726,15 @@ void MainWindow::onMenuEditAdvanced(wxCommandEvent &event) {
|
||||||
simpleDialog.addValue("Height Factor", intToStr(program->getMap()->getHeightFactor()),"(lower means map is more more zoomed in)");
|
simpleDialog.addValue("Height Factor", intToStr(program->getMap()->getHeightFactor()),"(lower means map is more more zoomed in)");
|
||||||
simpleDialog.addValue("Water Level", intToStr(program->getMap()->getWaterLevel()),"(water is visible below this, and walkable until 1.5 less)");
|
simpleDialog.addValue("Water Level", intToStr(program->getMap()->getWaterLevel()),"(water is visible below this, and walkable until 1.5 less)");
|
||||||
simpleDialog.addValue("Cliff Level", intToStr(program->getMap()->getCliffLevel()),"(neighboring fields with at least this heights difference are cliffs)");
|
simpleDialog.addValue("Cliff Level", intToStr(program->getMap()->getCliffLevel()),"(neighboring fields with at least this heights difference are cliffs)");
|
||||||
|
simpleDialog.addValue("Camera Height", intToStr(program->getMap()->getCameraHeight()),"(you can give a camera heigth here default is 0 ;ignored if <20)");
|
||||||
if (!simpleDialog.show("Advanced")) return;
|
if (!simpleDialog.show("Advanced")) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
program->setMapAdvanced(
|
program->setMapAdvanced(
|
||||||
strToInt(simpleDialog.getValue("Height Factor")),
|
strToInt(simpleDialog.getValue("Height Factor")),
|
||||||
strToInt(simpleDialog.getValue("Water Level")),
|
strToInt(simpleDialog.getValue("Water Level")),
|
||||||
strToInt(simpleDialog.getValue("Cliff Level")));
|
strToInt(simpleDialog.getValue("Cliff Level")),
|
||||||
|
strToInt(simpleDialog.getValue("Camera Height")));
|
||||||
}
|
}
|
||||||
catch (const exception &e) {
|
catch (const exception &e) {
|
||||||
MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
|
|
@ -605,8 +605,8 @@ bool Program::setGridOnOff() {
|
||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Program::setMapAdvanced(int altFactor, int waterLevel, int cliffLevel) {
|
void Program::setMapAdvanced(int altFactor, int waterLevel, int cliffLevel , int cameraHeight) {
|
||||||
if(map) map->setAdvanced(altFactor, waterLevel, cliffLevel);
|
if(map) map->setAdvanced(altFactor, waterLevel, cliffLevel, cameraHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Program::loadMap(const string &path) {
|
void Program::loadMap(const string &path) {
|
||||||
|
|
|
@ -148,7 +148,7 @@ public:
|
||||||
bool setMapTitle(const string &title);
|
bool setMapTitle(const string &title);
|
||||||
bool setMapDesc(const string &desc);
|
bool setMapDesc(const string &desc);
|
||||||
bool setMapAuthor(const string &author);
|
bool setMapAuthor(const string &author);
|
||||||
void setMapAdvanced(int altFactor, int waterLevel, int minimumCliffHeight);
|
void setMapAdvanced(int altFactor, int waterLevel, int minimumCliffHeight, int cameraHeight);
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
void renderMap(int w, int h);
|
void renderMap(int w, int h);
|
||||||
|
|
|
@ -75,7 +75,8 @@ struct MapFileHeader {
|
||||||
int8 short_desc[MAX_DESCRIPTION_LENGTH_VERSION2];
|
int8 short_desc[MAX_DESCRIPTION_LENGTH_VERSION2];
|
||||||
int32 magic; // 0x01020304 for meta
|
int32 magic; // 0x01020304 for meta
|
||||||
int32 cliffLevel;
|
int32 cliffLevel;
|
||||||
int8 meta[120];
|
int32 cameraHeight;
|
||||||
|
int8 meta[116];
|
||||||
} version2;
|
} version2;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -113,6 +114,7 @@ private:
|
||||||
int heightFactor;
|
int heightFactor;
|
||||||
int waterLevel;
|
int waterLevel;
|
||||||
int cliffLevel;
|
int cliffLevel;
|
||||||
|
int cameraHeight;
|
||||||
//Cell **cells;
|
//Cell **cells;
|
||||||
std::vector<std::vector<Cell> > cells;
|
std::vector<std::vector<Cell> > cells;
|
||||||
|
|
||||||
|
@ -136,10 +138,12 @@ public:
|
||||||
int getHeightFactor() const{return heightFactor;}
|
int getHeightFactor() const{return heightFactor;}
|
||||||
int getWaterLevel() const{return waterLevel;}
|
int getWaterLevel() const{return waterLevel;}
|
||||||
int getCliffLevel() const{return cliffLevel;}
|
int getCliffLevel() const{return cliffLevel;}
|
||||||
|
int getCameraHeight() const{return cameraHeight;}
|
||||||
|
|
||||||
bool inside(int x, int y);
|
bool inside(int x, int y);
|
||||||
|
|
||||||
void setRefAlt(int x, int y);
|
void setRefAlt(int x, int y);
|
||||||
void setAdvanced(int heightFactor, int waterLevel, int cliffLevel);
|
void setAdvanced(int heightFactor, int waterLevel, int cliffLevel, int cameraHeight);
|
||||||
void setTitle(const string &title);
|
void setTitle(const string &title);
|
||||||
void setDesc(const string &desc);
|
void setDesc(const string &desc);
|
||||||
void setAuthor(const string &author);
|
void setAuthor(const string &author);
|
||||||
|
|
|
@ -32,6 +32,7 @@ MapPreview::MapPreview() {
|
||||||
heightFactor = DEFAULT_MAP_CELL_HEIGHT_FACTOR;
|
heightFactor = DEFAULT_MAP_CELL_HEIGHT_FACTOR;
|
||||||
waterLevel = DEFAULT_MAP_WATER_DEPTH;
|
waterLevel = DEFAULT_MAP_WATER_DEPTH;
|
||||||
cliffLevel = DEFAULT_CLIFF_HEIGHT;
|
cliffLevel = DEFAULT_CLIFF_HEIGHT;
|
||||||
|
cameraHeight = 0;
|
||||||
//cells = NULL;
|
//cells = NULL;
|
||||||
cells.clear();
|
cells.clear();
|
||||||
//startLocations = NULL;
|
//startLocations = NULL;
|
||||||
|
@ -630,10 +631,11 @@ void MapPreview::setAuthor(const string &author) {
|
||||||
this->author = author;
|
this->author = author;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapPreview::setAdvanced(int heightFactor, int waterLevel, int cliffLevel) {
|
void MapPreview::setAdvanced(int heightFactor, int waterLevel, int cliffLevel, int cameraHeight) {
|
||||||
this->heightFactor = heightFactor;
|
this->heightFactor = heightFactor;
|
||||||
this->waterLevel = waterLevel;
|
this->waterLevel = waterLevel;
|
||||||
this->cliffLevel = cliffLevel;
|
this->cliffLevel = cliffLevel;
|
||||||
|
this->cameraHeight = cameraHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapPreview::randomizeHeights() {
|
void MapPreview::randomizeHeights() {
|
||||||
|
@ -697,6 +699,7 @@ void MapPreview::loadFromFile(const string &path) {
|
||||||
else if(header.version==2){
|
else if(header.version==2){
|
||||||
desc = header.version2.short_desc;
|
desc = header.version2.short_desc;
|
||||||
cliffLevel=header.version2.cliffLevel;
|
cliffLevel=header.version2.cliffLevel;
|
||||||
|
cameraHeight=header.version2.cameraHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
//read start locations
|
//read start locations
|
||||||
|
@ -764,6 +767,7 @@ void MapPreview::saveToFile(const string &path) {
|
||||||
strncpy(header.version2.short_desc, desc.c_str(), MAX_DESCRIPTION_LENGTH_VERSION2);
|
strncpy(header.version2.short_desc, desc.c_str(), MAX_DESCRIPTION_LENGTH_VERSION2);
|
||||||
header.version2.magic= 0x01020304;
|
header.version2.magic= 0x01020304;
|
||||||
header.version2.cliffLevel= cliffLevel;
|
header.version2.cliffLevel= cliffLevel;
|
||||||
|
header.version2.cameraHeight= cameraHeight;
|
||||||
|
|
||||||
|
|
||||||
fwrite(&header, sizeof(MapFileHeader), 1, f1);
|
fwrite(&header, sizeof(MapFileHeader), 1, f1);
|
||||||
|
|
Loading…
Reference in New Issue