extra team color markers ( by default use * to toggle/switch on )
This commit is contained in:
parent
eb67fb8121
commit
9ef8c82441
|
@ -14,6 +14,7 @@ ChangeFontColor=C
|
|||
GameSpeedIncrease='+'
|
||||
GameSpeedDecrease='-'
|
||||
ExitKey=escape
|
||||
ExtraTeamColorMarker='*'
|
||||
GroupUnitsKey1='0'
|
||||
GroupUnitsKey2='1'
|
||||
GroupUnitsKey3='2'
|
||||
|
|
|
@ -66,6 +66,7 @@ Game::Game(Program *program, const GameSettings *gameSettings):
|
|||
lastRenderLog2d = 0;
|
||||
totalRenderFps = 0;
|
||||
lastMaxUnitCalcTime = 0;
|
||||
renderExtraTeamColor = 0;
|
||||
|
||||
mouseMoved= false;
|
||||
quitTriggeredIndicator = false;
|
||||
|
@ -1598,6 +1599,10 @@ void Game::keyDown(SDL_KeyboardEvent key) {
|
|||
//printf("Toggle pause paused = %d\n",paused);
|
||||
setPaused(!paused);
|
||||
}
|
||||
else if(isKeyPressed(configKeys.getSDLKey("ExtraTeamColorMarker"),key, false) == true) {
|
||||
//printf("Toggle ExtraTeamColorMarker\n");
|
||||
toggleTeamColorMarker();
|
||||
}
|
||||
//switch display color
|
||||
//else if(key == configKeys.getCharKey("ChangeFontColor")) {
|
||||
else if(isKeyPressed(configKeys.getSDLKey("ChangeFontColor"),key, false) == true) {
|
||||
|
@ -1895,11 +1900,23 @@ void Game::render3d(){
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderSelectionEffects]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
|
||||
// renderTeamColorCircle
|
||||
if((renderExtraTeamColor&renderTeamColorCircleBit)>0){
|
||||
renderer.renderTeamColorCircle();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
}
|
||||
//units
|
||||
renderer.renderUnits(avgRenderFps);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderUnits]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
|
||||
// renderTeamColorPlane
|
||||
if((renderExtraTeamColor&renderTeamColorPlaneBit)>0){
|
||||
renderer.renderTeamColorPlane();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||
}
|
||||
//objects
|
||||
renderer.renderObjects(avgRenderFps);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] renderFps = %d took msecs: %lld [renderObjects]\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||
|
@ -2475,5 +2492,9 @@ Vec2i Game::getPerformanceTimerResults() {
|
|||
void Game::consoleAddLine(string line) {
|
||||
console.addLine(line);
|
||||
}
|
||||
void Game::toggleTeamColorMarker() {
|
||||
renderExtraTeamColor++;
|
||||
renderExtraTeamColor=renderExtraTeamColor%4;
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -114,6 +114,10 @@ private:
|
|||
int updateFpsAvgTest;
|
||||
int renderFpsAvgTest;
|
||||
|
||||
int renderExtraTeamColor;
|
||||
static const int renderTeamColorCircleBit=1;
|
||||
static const int renderTeamColorPlaneBit=2;
|
||||
|
||||
bool photoModeEnabled;
|
||||
bool visibleHUD;
|
||||
bool withRainEffect;
|
||||
|
@ -146,6 +150,8 @@ public:
|
|||
bool getPaused() const { return paused;}
|
||||
void setPaused(bool value);
|
||||
const int getTotalRenderFps() const {return totalRenderFps;}
|
||||
|
||||
void toggleTeamColorMarker();
|
||||
//init
|
||||
virtual void load(LoadGameItem loadTypes);
|
||||
virtual void load();
|
||||
|
|
|
@ -64,6 +64,11 @@ void CoreData::load() {
|
|||
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");
|
||||
|
||||
snowTexture= renderer.newTexture2D(rsGlobal);
|
||||
snowTexture->setMipmap(false);
|
||||
snowTexture->setFormat(Texture::fAlpha);
|
||||
|
|
|
@ -50,6 +50,7 @@ private:
|
|||
std::vector<Texture2D *> logoTextureList;
|
||||
Texture2D *backgroundTexture;
|
||||
Texture2D *fireTexture;
|
||||
Texture2D *teamColorTexture;
|
||||
Texture2D *snowTexture;
|
||||
Texture2D *waterSplashTexture;
|
||||
Texture2D *customTexture;
|
||||
|
@ -83,6 +84,7 @@ public:
|
|||
|
||||
Texture2D *getBackgroundTexture() const {return backgroundTexture;}
|
||||
Texture2D *getFireTexture() const {return fireTexture;}
|
||||
Texture2D *getTeamColorTexture() const {return teamColorTexture;}
|
||||
Texture2D *getSnowTexture() const {return snowTexture;}
|
||||
Texture2D *getLogoTexture() const {return logoTexture;}
|
||||
Texture2D *getWaterSplashTexture() const {return waterSplashTexture;}
|
||||
|
|
|
@ -2946,6 +2946,54 @@ void Renderer::renderWater() {
|
|||
assertGl();
|
||||
}
|
||||
|
||||
void Renderer::renderTeamColorCircle(){
|
||||
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||
if(qCache.visibleQuadUnitList.size() > 0) {
|
||||
|
||||
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_BLEND);
|
||||
glLineWidth(2.f);
|
||||
|
||||
for(int visibleUnitIndex = 0;
|
||||
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex) {
|
||||
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
|
||||
Vec3f currVec= unit->getCurrVectorFlat();
|
||||
Vec3f color=unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0);
|
||||
glColor4f(color.x, color.y, color.z, 0.7f);
|
||||
renderSelectionCircle(currVec, unit->getType()->getSize(), 0.8f, 0.05f);
|
||||
}
|
||||
glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::renderTeamColorPlane(){
|
||||
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||
if(qCache.visibleQuadUnitList.size() > 0){
|
||||
glPushAttrib(GL_ENABLE_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
const Texture2D *texture=CoreData::getInstance().getTeamColorTexture();
|
||||
for(int visibleUnitIndex = 0;
|
||||
visibleUnitIndex < qCache.visibleQuadUnitList.size(); ++visibleUnitIndex){
|
||||
Unit *unit = qCache.visibleQuadUnitList[visibleUnitIndex];
|
||||
Vec3f currVec= unit->getCurrVectorFlat();
|
||||
renderTeamColorEffect(currVec,visibleUnitIndex,unit->getType()->getSize(),
|
||||
unit->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0),texture);
|
||||
}
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Renderer::renderUnits(const int renderFps) {
|
||||
Unit *unit=NULL;
|
||||
const World *world= game->getWorld();
|
||||
|
@ -3055,8 +3103,34 @@ void Renderer::renderUnits(const int renderFps) {
|
|||
glAlphaFunc(GL_GREATER, 0.0f);
|
||||
//assert
|
||||
assertGl();
|
||||
|
||||
}
|
||||
|
||||
void Renderer::renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture) {
|
||||
GLUquadricObj *disc;
|
||||
float halfSize=size;
|
||||
halfSize=halfSize;
|
||||
float heigthoffset=0.5+heigth%25*0.004;
|
||||
glPushMatrix();
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<const Texture2DGl*>(texture)->getHandle());
|
||||
glColor4f(color.x, color.y, color.z, 1.0f);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2i(0, 1);
|
||||
glVertex3f(v.x-halfSize,v.y+heigthoffset,v.z+halfSize);
|
||||
glTexCoord2i(0, 0);
|
||||
glVertex3f(v.x-halfSize,v.y+heigthoffset, v.z-halfSize);
|
||||
glTexCoord2i(1, 1);
|
||||
|
||||
glVertex3f(v.x+halfSize,v.y+heigthoffset, v.z+halfSize);
|
||||
glTexCoord2i(1, 0);
|
||||
glVertex3f(v.x+halfSize,v.y+heigthoffset, v.z-halfSize);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Renderer::renderSelectionEffects() {
|
||||
|
||||
const World *world= game->getWorld();
|
||||
|
@ -3336,10 +3410,9 @@ void Renderer::renderWaterEffects(){
|
|||
}
|
||||
|
||||
void Renderer::renderHud(){
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
const World *world= game->getWorld();
|
||||
Texture2D *hudTexture=game->getGui()->getHudTexture();
|
||||
if(hudTexture!=NULL){
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
renderTextureQuad(0, 0, metrics.getVirtualW(), metrics.getVirtualH(),hudTexture,1.0f);
|
||||
}
|
||||
}
|
||||
|
@ -5056,7 +5129,7 @@ void Renderer::enableProjectiveTexturing() {
|
|||
|
||||
// ==================== private aux drawing ====================
|
||||
|
||||
void Renderer::renderSelectionCircle(Vec3f v, int size, float radius) {
|
||||
void Renderer::renderSelectionCircle(Vec3f v, int size, float radius, float thickness) {
|
||||
GLUquadricObj *disc;
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
@ -5066,7 +5139,7 @@ void Renderer::renderSelectionCircle(Vec3f v, int size, float radius) {
|
|||
glRotatef(90.f, 1.f, 0.f, 0.f);
|
||||
disc= gluNewQuadric();
|
||||
gluQuadricDrawStyle(disc, GLU_FILL);
|
||||
gluCylinder(disc, radius*(size-0.2f), radius*size, 0.2f, 30, 1);
|
||||
gluCylinder(disc, radius*(size-thickness), radius*size, thickness, 30, 1);
|
||||
gluDeleteQuadric(disc);
|
||||
|
||||
glPopMatrix();
|
||||
|
|
|
@ -424,6 +424,8 @@ public:
|
|||
void loadConfig();
|
||||
void saveScreen(const string &path);
|
||||
Quad2i getVisibleQuad() const {return visibleQuad;}
|
||||
void renderTeamColorPlane();
|
||||
void renderTeamColorCircle();
|
||||
|
||||
//static
|
||||
static Shadows strToShadows(const string &s);
|
||||
|
@ -495,7 +497,8 @@ private:
|
|||
void enableProjectiveTexturing();
|
||||
|
||||
//private aux drawing
|
||||
void renderSelectionCircle(Vec3f v, int size, float radius);
|
||||
void renderSelectionCircle(Vec3f v, int size, float radius, float thickness=0.2f);
|
||||
void renderTeamColorEffect(Vec3f &v, int heigth, int size, Vec3f color, const Texture2D *texture);
|
||||
void renderArrow(const Vec3f &pos1, const Vec3f &pos2, const Vec3f &color, float width);
|
||||
void renderTile(const Vec2i &pos);
|
||||
void renderQuad(int x, int y, int w, int h, const Texture2D *texture);
|
||||
|
|
Loading…
Reference in New Issue