ingame fontcolor change with key 'C' is back
This commit is contained in:
parent
a71f0d0e7c
commit
f5e21ae896
|
@ -656,7 +656,11 @@ void Game::keyDown(char key){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//switch display color
|
||||||
|
else if(key=='C'){
|
||||||
|
gui.switchToNextDisplayColor();
|
||||||
|
}
|
||||||
|
|
||||||
//increment speed
|
//increment speed
|
||||||
else if(key==vkAdd){
|
else if(key==vkAdd){
|
||||||
if(speedChangesAllowed){
|
if(speedChangesAllowed){
|
||||||
|
|
|
@ -689,6 +689,7 @@ void Renderer::renderTextureQuad(int x, int y, int w, int h, const Texture2D *te
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderConsole(const Console *console){
|
void Renderer::renderConsole(const Console *console){
|
||||||
|
const Gui *gui= game->getGui();
|
||||||
glPushAttrib(GL_ENABLE_BIT);
|
glPushAttrib(GL_ENABLE_BIT);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
|
@ -696,6 +697,7 @@ void Renderer::renderConsole(const Console *console){
|
||||||
renderTextShadow(
|
renderTextShadow(
|
||||||
console->getLine(i),
|
console->getLine(i),
|
||||||
CoreData::getInstance().getConsoleFont(),
|
CoreData::getInstance().getConsoleFont(),
|
||||||
|
gui->getDisplay()->getColor(),
|
||||||
20, i*20+20);
|
20, i*20+20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -726,6 +728,7 @@ void Renderer::renderChatManager(const ChatManager *chatManager){
|
||||||
void Renderer::renderResourceStatus(){
|
void Renderer::renderResourceStatus(){
|
||||||
|
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
|
const Gui *gui= game->getGui();
|
||||||
const World *world= game->getWorld();
|
const World *world= game->getWorld();
|
||||||
const Faction *thisFaction= world->getFaction(world->getThisFactionIndex());
|
const Faction *thisFaction= world->getFaction(world->getThisFactionIndex());
|
||||||
|
|
||||||
|
@ -774,6 +777,7 @@ void Renderer::renderResourceStatus(){
|
||||||
|
|
||||||
renderTextShadow(
|
renderTextShadow(
|
||||||
str, CoreData::getInstance().getDisplayFontSmall(),
|
str, CoreData::getInstance().getDisplayFontSmall(),
|
||||||
|
gui->getDisplay()->getColor(),
|
||||||
j*100+220, metrics.getVirtualH()-30, false);
|
j*100+220, metrics.getVirtualH()-30, false);
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
|
@ -846,15 +850,18 @@ void Renderer::renderText(const string &text, const Font2D *font, const Vec3f &c
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderTextShadow(const string &text, const Font2D *font, int x, int y, bool centered){
|
void Renderer::renderTextShadow(const string &text, const Font2D *font,const Vec4f &color, int x, int y, bool centered){
|
||||||
glPushAttrib(GL_CURRENT_BIT);
|
glPushAttrib(GL_CURRENT_BIT);
|
||||||
|
|
||||||
Vec2i pos= centered? computeCenteredPos(text, font, x, y): Vec2i(x, y);
|
Vec2i pos= centered? computeCenteredPos(text, font, x, y): Vec2i(x, y);
|
||||||
|
|
||||||
textRenderer->begin(font);
|
if(color.w<0.5)
|
||||||
glColor3f(0.0f, 0.0f, 0.0f);
|
{
|
||||||
textRenderer->render(text, pos.x-1.0f, pos.y-1.0f);
|
textRenderer->begin(font);
|
||||||
glColor3f(1.0f, 1.0f, 1.0f);
|
glColor3f(0.0f, 0.0f, 0.0f);
|
||||||
|
textRenderer->render(text, pos.x-1.0f, pos.y-1.0f);
|
||||||
|
}
|
||||||
|
glColor3f(color.x,color.y,color.z);
|
||||||
textRenderer->render(text, pos.x, pos.y);
|
textRenderer->render(text, pos.x, pos.y);
|
||||||
textRenderer->end();
|
textRenderer->end();
|
||||||
|
|
||||||
|
@ -1717,11 +1724,12 @@ void Renderer::renderDisplay(){
|
||||||
const Display *display= game->getGui()->getDisplay();
|
const Display *display= game->getGui()->getDisplay();
|
||||||
|
|
||||||
glPushAttrib(GL_ENABLE_BIT);
|
glPushAttrib(GL_ENABLE_BIT);
|
||||||
|
|
||||||
//infoString
|
//infoString
|
||||||
renderTextShadow(
|
renderTextShadow(
|
||||||
display->getInfoText().c_str(),
|
display->getInfoText().c_str(),
|
||||||
coreData.getDisplayFont(),
|
coreData.getDisplayFont(),
|
||||||
|
display->getColor(),
|
||||||
metrics.getDisplayX(),
|
metrics.getDisplayX(),
|
||||||
metrics.getDisplayY()+Display::infoStringY);
|
metrics.getDisplayY()+Display::infoStringY);
|
||||||
|
|
||||||
|
@ -1729,6 +1737,7 @@ void Renderer::renderDisplay(){
|
||||||
renderTextShadow(
|
renderTextShadow(
|
||||||
display->getTitle().c_str(),
|
display->getTitle().c_str(),
|
||||||
coreData.getDisplayFont(),
|
coreData.getDisplayFont(),
|
||||||
|
display->getColor(),
|
||||||
metrics.getDisplayX()+40,
|
metrics.getDisplayX()+40,
|
||||||
metrics.getDisplayY() + metrics.getDisplayH() - 20);
|
metrics.getDisplayY() + metrics.getDisplayH() - 20);
|
||||||
|
|
||||||
|
@ -1738,6 +1747,7 @@ void Renderer::renderDisplay(){
|
||||||
renderTextShadow(
|
renderTextShadow(
|
||||||
display->getText().c_str(),
|
display->getText().c_str(),
|
||||||
coreData.getDisplayFont(),
|
coreData.getDisplayFont(),
|
||||||
|
display->getColor(),
|
||||||
metrics.getDisplayX() -1,
|
metrics.getDisplayX() -1,
|
||||||
metrics.getDisplayY() + metrics.getDisplayH() - 56);
|
metrics.getDisplayY() + metrics.getDisplayH() - 56);
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ public:
|
||||||
void renderSelectionQuad();
|
void renderSelectionQuad();
|
||||||
void renderText(const string &text, const Font2D *font, float alpha, int x, int y, bool centered= false);
|
void renderText(const string &text, const Font2D *font, float alpha, int x, int y, bool centered= false);
|
||||||
void renderText(const string &text, const Font2D *font, const Vec3f &color, int x, int y, bool centered= false);
|
void renderText(const string &text, const Font2D *font, const Vec3f &color, int x, int y, bool centered= false);
|
||||||
void renderTextShadow(const string &text, const Font2D *font, int x, int y, bool centered= false);
|
void renderTextShadow(const string &text, const Font2D *font,const Vec4f &color, int x, int y, bool centered= false);
|
||||||
|
|
||||||
//components
|
//components
|
||||||
void renderLabel(const GraphicLabel *label);
|
void renderLabel(const GraphicLabel *label);
|
||||||
|
|
98
source/glest_game/gui/display.cpp
Normal file
98
source/glest_game/gui/display.cpp
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
// ==============================================================
|
||||||
|
// This file is part of Glest (www.glest.org)
|
||||||
|
//
|
||||||
|
// Copyright (C) 2001-2008 Marti<74>o 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
|
||||||
|
// License, or (at your option) any later version
|
||||||
|
// ==============================================================
|
||||||
|
|
||||||
|
#include "display.h"
|
||||||
|
|
||||||
|
#include "metrics.h"
|
||||||
|
#include "command_type.h"
|
||||||
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
using namespace Shared::Graphics;
|
||||||
|
|
||||||
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// class Display
|
||||||
|
// =====================================================
|
||||||
|
|
||||||
|
Display::Display(){
|
||||||
|
colors[0]= Vec4f(1.f, 1.f, 1.f, 0.0f);
|
||||||
|
colors[1]= Vec4f(1.f, 0.5f, 0.5f, 0.0f);
|
||||||
|
colors[2]= Vec4f(0.5f, 0.5f, 1.0f, 0.0f);
|
||||||
|
colors[3]= Vec4f(0.5f, 1.0f, 0.5f, 0.0f);
|
||||||
|
colors[4]= Vec4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
colors[5]= Vec4f(0.0f, 0.0f, 1.0f, 1.0f);
|
||||||
|
colors[6]= Vec4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
colors[7]= Vec4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
|
colors[8]= Vec4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
currentColor= 0;
|
||||||
|
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//misc
|
||||||
|
void Display::clear(){
|
||||||
|
for(int i=0; i<upCellCount; ++i){
|
||||||
|
upImages[i]= NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i<downCellCount; ++i){
|
||||||
|
downImages[i]= NULL;
|
||||||
|
downLighted[i]= true;
|
||||||
|
commandTypes[i]= NULL;
|
||||||
|
commandClasses[i]= ccNull;
|
||||||
|
}
|
||||||
|
|
||||||
|
downSelectedPos= invalidPos;
|
||||||
|
title.clear();
|
||||||
|
text.clear();
|
||||||
|
progressBar= -1;
|
||||||
|
}
|
||||||
|
void Display::switchColor(){
|
||||||
|
currentColor= (currentColor+1) % colorCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Display::computeDownIndex(int x, int y){
|
||||||
|
y= y-(downY-cellSideCount*imageSize);
|
||||||
|
|
||||||
|
if(y>imageSize*cellSideCount){
|
||||||
|
return invalidPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cellX= x/imageSize;
|
||||||
|
int cellY= (y/imageSize) % cellSideCount;
|
||||||
|
int index= (cellSideCount-cellY-1)*cellSideCount+cellX;;
|
||||||
|
|
||||||
|
if(index<0 || index>=downCellCount || downImages[index]==NULL){
|
||||||
|
index= invalidPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Display::computeDownX(int index) const{
|
||||||
|
return (index % cellSideCount) * imageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Display::computeDownY(int index) const{
|
||||||
|
return Display::downY - (index/cellSideCount)*imageSize - imageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Display::computeUpX(int index) const{
|
||||||
|
return (index % cellSideCount) * imageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Display::computeUpY(int index) const{
|
||||||
|
return Metrics::getInstance().getDisplayH() - (index/cellSideCount)*imageSize - imageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
}}//end namespace
|
102
source/glest_game/gui/display.h
Normal file
102
source/glest_game/gui/display.h
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
// ==============================================================
|
||||||
|
// This file is part of Glest (www.glest.org)
|
||||||
|
//
|
||||||
|
// Copyright (C) 2001-2008 Marti<74>o 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
|
||||||
|
// License, or (at your option) any later version
|
||||||
|
// ==============================================================
|
||||||
|
|
||||||
|
#ifndef _GLEST_GAME_DISPLAY_H_
|
||||||
|
#define _GLEST_GAME_DISPLAY_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "texture.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "command_type.h"
|
||||||
|
#include "game_util.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
using Shared::Graphics::Texture2D;
|
||||||
|
using Shared::Graphics::Vec4f;
|
||||||
|
using Shared::Util::replaceBy;
|
||||||
|
|
||||||
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// class Display
|
||||||
|
//
|
||||||
|
/// Display for unit commands, and unit selection
|
||||||
|
// =====================================================
|
||||||
|
|
||||||
|
class Display{
|
||||||
|
public:
|
||||||
|
static const int cellSideCount= 4;
|
||||||
|
static const int upCellCount= cellSideCount*cellSideCount;
|
||||||
|
static const int downCellCount= cellSideCount*cellSideCount;
|
||||||
|
static const int colorCount= 9;
|
||||||
|
static const int imageSize= 32;
|
||||||
|
static const int invalidPos= -1;
|
||||||
|
static const int downY = imageSize*9;
|
||||||
|
static const int infoStringY= imageSize*4;
|
||||||
|
|
||||||
|
private:
|
||||||
|
string title;
|
||||||
|
string text;
|
||||||
|
string infoText;
|
||||||
|
const Texture2D *upImages[upCellCount];
|
||||||
|
const Texture2D *downImages[downCellCount];
|
||||||
|
bool downLighted[downCellCount];
|
||||||
|
const CommandType *commandTypes[downCellCount];
|
||||||
|
CommandClass commandClasses[downCellCount];
|
||||||
|
int progressBar;
|
||||||
|
int downSelectedPos;
|
||||||
|
Vec4f colors[colorCount];
|
||||||
|
int currentColor;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
Display();
|
||||||
|
|
||||||
|
//get
|
||||||
|
string getTitle() const {return title;}
|
||||||
|
string getText() const {return text;}
|
||||||
|
string getInfoText() const {return infoText;}
|
||||||
|
const Texture2D *getUpImage(int index) const {return upImages[index];}
|
||||||
|
const Texture2D *getDownImage(int index) const {return downImages[index];}
|
||||||
|
bool getDownLighted(int index) const {return downLighted[index];}
|
||||||
|
const CommandType *getCommandType(int i) {return commandTypes[i];}
|
||||||
|
CommandClass getCommandClass(int i) {return commandClasses[i];}
|
||||||
|
Vec4f getColor() const {return colors[currentColor];}
|
||||||
|
int getProgressBar() const {return progressBar;}
|
||||||
|
int getDownSelectedPos() const {return downSelectedPos;}
|
||||||
|
|
||||||
|
//set
|
||||||
|
void setTitle(const string title) {this->title= formatString(title);}
|
||||||
|
void setText(const string &text) {this->text= formatString(text);}
|
||||||
|
void setInfoText(const string infoText) {this->infoText= formatString(infoText);}
|
||||||
|
void setUpImage(int i, const Texture2D *image) {upImages[i]= image;}
|
||||||
|
void setDownImage(int i, const Texture2D *image) {downImages[i]= image;}
|
||||||
|
void setCommandType(int i, const CommandType *ct) {commandTypes[i]= ct;}
|
||||||
|
void setCommandClass(int i, const CommandClass cc) {commandClasses[i]= cc;}
|
||||||
|
void setDownLighted(int i, bool lighted) {downLighted[i]= lighted;}
|
||||||
|
void setProgressBar(int i) {progressBar= i;}
|
||||||
|
void setDownSelectedPos(int i) {downSelectedPos= i;}
|
||||||
|
|
||||||
|
//misc
|
||||||
|
void clear();
|
||||||
|
void switchColor();
|
||||||
|
int computeDownIndex(int x, int y);
|
||||||
|
int computeDownX(int index) const;
|
||||||
|
int computeDownY(int index) const;
|
||||||
|
int computeUpX(int index) const;
|
||||||
|
int computeUpY(int index) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
}}//end namespace
|
||||||
|
|
||||||
|
#endif
|
|
@ -361,6 +361,10 @@ void Gui::hotKey(char key){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Gui::switchToNextDisplayColor(){
|
||||||
|
display.switchColor();
|
||||||
|
}
|
||||||
|
|
||||||
void Gui::onSelectionChanged(){
|
void Gui::onSelectionChanged(){
|
||||||
resetState();
|
resetState();
|
||||||
computeDisplay();
|
computeDisplay();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
|
@ -174,6 +174,7 @@ public:
|
||||||
void hotKey(char key);
|
void hotKey(char key);
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
|
void switchToNextDisplayColor();
|
||||||
void onSelectionChanged();
|
void onSelectionChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user