mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 21:51:17 +02:00
- reworked fonts to now use 3d matrix positioning and render performance is much better.
*NOTE: Still need to deal with some letters getting partially chopped off in some cases.
This commit is contained in:
@@ -52,6 +52,7 @@ GraphicComponent::GraphicComponent(std::string containerName, std::string objNam
|
|||||||
h = 0;
|
h = 0;
|
||||||
text = "";
|
text = "";
|
||||||
font = NULL;
|
font = NULL;
|
||||||
|
font3D = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicComponent::clearRegisteredComponents(std::string containerName) {
|
void GraphicComponent::clearRegisteredComponents(std::string containerName) {
|
||||||
@@ -209,6 +210,7 @@ void GraphicComponent::init(int x, int y, int w, int h) {
|
|||||||
this->w= w;
|
this->w= w;
|
||||||
this->h= h;
|
this->h= h;
|
||||||
font= CoreData::getInstance().getMenuFontNormal();
|
font= CoreData::getInstance().getMenuFontNormal();
|
||||||
|
font3D= CoreData::getInstance().getMenuFontNormal3D();
|
||||||
enabled= true;
|
enabled= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,6 +424,7 @@ void GraphicMessageBox::setY(int y) {
|
|||||||
|
|
||||||
void GraphicMessageBox::init(const string &button1Str) {
|
void GraphicMessageBox::init(const string &button1Str) {
|
||||||
font= CoreData::getInstance().getMenuFontNormal();
|
font= CoreData::getInstance().getMenuFontNormal();
|
||||||
|
font3D= CoreData::getInstance().getMenuFontNormal3D();
|
||||||
|
|
||||||
h= defH;
|
h= defH;
|
||||||
w= defW;
|
w= defW;
|
||||||
|
@@ -25,6 +25,7 @@ using std::string;
|
|||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
using Shared::Graphics::Font2D;
|
using Shared::Graphics::Font2D;
|
||||||
|
using Shared::Graphics::Font3D;
|
||||||
using namespace Shared::Graphics;
|
using namespace Shared::Graphics;
|
||||||
using Shared::Graphics::Vec3f;
|
using Shared::Graphics::Vec3f;
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ protected:
|
|||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
string text;
|
string text;
|
||||||
Font2D *font;
|
Font2D *font;
|
||||||
|
Font3D *font3D;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
bool editable;
|
bool editable;
|
||||||
bool visible;
|
bool visible;
|
||||||
@@ -84,6 +86,7 @@ public:
|
|||||||
virtual int getH() const {return h;}
|
virtual int getH() const {return h;}
|
||||||
virtual const string &getText() const {return text;}
|
virtual const string &getText() const {return text;}
|
||||||
virtual Font2D *getFont() {return font;}
|
virtual Font2D *getFont() {return font;}
|
||||||
|
virtual Font3D *getFont3D() {return font3D;}
|
||||||
virtual bool getEnabled() const {return enabled;}
|
virtual bool getEnabled() const {return enabled;}
|
||||||
virtual bool getEditable() const {return editable;}
|
virtual bool getEditable() const {return editable;}
|
||||||
virtual bool getVisible() const {return visible;}
|
virtual bool getVisible() const {return visible;}
|
||||||
@@ -94,6 +97,7 @@ public:
|
|||||||
virtual void setH(int h) {this->h= h;}
|
virtual void setH(int h) {this->h= h;}
|
||||||
virtual void setText(const string &text) {this->text= text;}
|
virtual void setText(const string &text) {this->text= text;}
|
||||||
virtual void setFont(Font2D *font) {this->font= font;}
|
virtual void setFont(Font2D *font) {this->font= font;}
|
||||||
|
virtual void setFont3D(Font3D *font) {this->font3D= font3D;}
|
||||||
virtual void setEnabled(bool enabled) {this->enabled= enabled;}
|
virtual void setEnabled(bool enabled) {this->enabled= enabled;}
|
||||||
virtual void setEditable(bool editable) {this->editable= editable;}
|
virtual void setEditable(bool editable) {this->editable= editable;}
|
||||||
virtual void setVisible(bool value) {this->visible = value;}
|
virtual void setVisible(bool value) {this->visible = value;}
|
||||||
|
@@ -136,6 +136,44 @@ void Logger::renderLoadingScreen() {
|
|||||||
else {
|
else {
|
||||||
renderer.renderBackground(loadingTexture);
|
renderer.renderBackground(loadingTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(showProgressBar == true) {
|
||||||
|
if(Renderer::renderText3DEnabled) {
|
||||||
|
renderer.renderProgressBar3D(
|
||||||
|
progress,
|
||||||
|
metrics.getVirtualW() / 4,
|
||||||
|
59 * metrics.getVirtualH() / 100,
|
||||||
|
coreData.getDisplayFontSmall3D(),
|
||||||
|
350,""); // no string here, because it has to be language specific and does not give much information
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
renderer.renderProgressBar(
|
||||||
|
progress,
|
||||||
|
metrics.getVirtualW() / 4,
|
||||||
|
59 * metrics.getVirtualH() / 100,
|
||||||
|
coreData.getDisplayFontSmall(),
|
||||||
|
350,""); // no string here, because it has to be language specific and does not give much information
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Renderer::renderText3DEnabled) {
|
||||||
|
renderer.renderText3D(
|
||||||
|
state, coreData.getMenuFontBig3D(), Vec3f(1.f),
|
||||||
|
metrics.getVirtualW()/4, 65*metrics.getVirtualH()/100, false);
|
||||||
|
|
||||||
|
renderer.renderText3D(
|
||||||
|
current, coreData.getMenuFontNormal3D(), 1.0f,
|
||||||
|
metrics.getVirtualW() / 4,
|
||||||
|
62 * metrics.getVirtualH() / 100, false);
|
||||||
|
|
||||||
|
if(this->statusText != "") {
|
||||||
|
renderer.renderText3D(
|
||||||
|
this->statusText, coreData.getMenuFontNormal3D(), 1.0f,
|
||||||
|
metrics.getVirtualW() / 4,
|
||||||
|
56 * metrics.getVirtualH() / 100, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderer.renderText(
|
renderer.renderText(
|
||||||
state, coreData.getMenuFontBig(), Vec3f(1.f),
|
state, coreData.getMenuFontBig(), Vec3f(1.f),
|
||||||
metrics.getVirtualW()/4, 65*metrics.getVirtualH()/100, false);
|
metrics.getVirtualW()/4, 65*metrics.getVirtualH()/100, false);
|
||||||
@@ -145,21 +183,13 @@ void Logger::renderLoadingScreen() {
|
|||||||
metrics.getVirtualW() / 4,
|
metrics.getVirtualW() / 4,
|
||||||
62 * metrics.getVirtualH() / 100, false);
|
62 * metrics.getVirtualH() / 100, false);
|
||||||
|
|
||||||
if(showProgressBar == true) {
|
|
||||||
renderer.renderProgressBar(
|
|
||||||
progress,
|
|
||||||
metrics.getVirtualW() / 4,
|
|
||||||
59 * metrics.getVirtualH() / 100,
|
|
||||||
coreData.getDisplayFontSmall(),
|
|
||||||
350,""); // no string here, because it has to be language specific and does not give much information
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this->statusText != "") {
|
if(this->statusText != "") {
|
||||||
renderer.renderText(
|
renderer.renderText(
|
||||||
this->statusText, coreData.getMenuFontNormal(), 1.0f,
|
this->statusText, coreData.getMenuFontNormal(), 1.0f,
|
||||||
metrics.getVirtualW() / 4,
|
metrics.getVirtualW() / 4,
|
||||||
56 * metrics.getVirtualH() / 100, false);
|
56 * metrics.getVirtualH() / 100, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(buttonCancel.getEnabled() == true) {
|
if(buttonCancel.getEnabled() == true) {
|
||||||
renderer.renderButton(&buttonCancel);
|
renderer.renderButton(&buttonCancel);
|
||||||
|
@@ -41,6 +41,7 @@ ChatManager::ChatManager() {
|
|||||||
yPos=150;
|
yPos=150;
|
||||||
maxTextLenght=64;
|
maxTextLenght=64;
|
||||||
font=CoreData::getInstance().getConsoleFont();
|
font=CoreData::getInstance().getConsoleFont();
|
||||||
|
font3D=CoreData::getInstance().getConsoleFont3D();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatManager::init(Console* console, int thisTeamIndex, const bool inMenu, string manualPlayerNameOverride) {
|
void ChatManager::init(Console* console, int thisTeamIndex, const bool inMenu, string manualPlayerNameOverride) {
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using Shared::Graphics::Font2D;
|
using Shared::Graphics::Font2D;
|
||||||
|
using Shared::Graphics::Font3D;
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ private:
|
|||||||
int yPos;
|
int yPos;
|
||||||
int maxTextLenght;
|
int maxTextLenght;
|
||||||
Font2D *font;
|
Font2D *font;
|
||||||
|
Font3D *font3D;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -64,7 +66,9 @@ public:
|
|||||||
int getMaxTextLenght() const {return maxTextLenght;}
|
int getMaxTextLenght() const {return maxTextLenght;}
|
||||||
void setMaxTextLenght(int maxTextLenght) {this->maxTextLenght= maxTextLenght;}
|
void setMaxTextLenght(int maxTextLenght) {this->maxTextLenght= maxTextLenght;}
|
||||||
Font2D *getFont() const {return font;}
|
Font2D *getFont() const {return font;}
|
||||||
|
Font3D *getFont3D() const {return font3D;}
|
||||||
void setFont(Font2D *font) {this->font= font;}
|
void setFont(Font2D *font) {this->font= font;}
|
||||||
|
void setFont3D(Font3D *font) {this->font3D= font;}
|
||||||
void addText(string text);
|
void addText(string text);
|
||||||
void switchOnEdit();
|
void switchOnEdit();
|
||||||
|
|
||||||
|
@@ -39,6 +39,7 @@ Console::Console() {
|
|||||||
yPos=20;
|
yPos=20;
|
||||||
lineHeight=20;
|
lineHeight=20;
|
||||||
font=CoreData::getInstance().getConsoleFont();
|
font=CoreData::getInstance().getConsoleFont();
|
||||||
|
font3D=CoreData::getInstance().getConsoleFont3D();
|
||||||
stringToHighlight="";
|
stringToHighlight="";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@ using namespace std;
|
|||||||
namespace Glest { namespace Game {
|
namespace Glest { namespace Game {
|
||||||
|
|
||||||
using Shared::Graphics::Font2D;
|
using Shared::Graphics::Font2D;
|
||||||
|
using Shared::Graphics::Font3D;
|
||||||
using Shared::Graphics::Vec3f;
|
using Shared::Graphics::Vec3f;
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Console
|
// class Console
|
||||||
@@ -67,6 +68,7 @@ private:
|
|||||||
int yPos;
|
int yPos;
|
||||||
int lineHeight;
|
int lineHeight;
|
||||||
Font2D *font;
|
Font2D *font;
|
||||||
|
Font3D *font3D;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Console();
|
Console();
|
||||||
@@ -80,7 +82,9 @@ public:
|
|||||||
int getLineHeight() const {return lineHeight;}
|
int getLineHeight() const {return lineHeight;}
|
||||||
void setLineHeight(int lineHeight) {this->lineHeight= lineHeight;}
|
void setLineHeight(int lineHeight) {this->lineHeight= lineHeight;}
|
||||||
Font2D *getFont() const {return font;}
|
Font2D *getFont() const {return font;}
|
||||||
|
Font3D *getFont3D() const {return font3D;}
|
||||||
void setFont(Font2D *font) {this->font= font;}
|
void setFont(Font2D *font) {this->font= font;}
|
||||||
|
void setFont3D(Font3D *font) {this->font3D= font;}
|
||||||
string getStringToHighlight() const { return stringToHighlight;}
|
string getStringToHighlight() const { return stringToHighlight;}
|
||||||
void setStringToHighlight(string stringToHighlight) { this->stringToHighlight = stringToHighlight;}
|
void setStringToHighlight(string stringToHighlight) { this->stringToHighlight = stringToHighlight;}
|
||||||
|
|
||||||
|
@@ -1919,10 +1919,17 @@ void Game::render2d(){
|
|||||||
if(!scriptManager.getDisplayText().empty() && !scriptManager.getMessageBoxEnabled()){
|
if(!scriptManager.getDisplayText().empty() && !scriptManager.getMessageBoxEnabled()){
|
||||||
Vec4f fontColor = getGui()->getDisplay()->getColor();
|
Vec4f fontColor = getGui()->getDisplay()->getColor();
|
||||||
|
|
||||||
|
if(Renderer::renderText3DEnabled == true) {
|
||||||
|
renderer.renderText3D(
|
||||||
|
scriptManager.getDisplayText(), coreData.getMenuFontNormal3D(),
|
||||||
|
Vec3f(fontColor.x,fontColor.y,fontColor.z), 200, 680, false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderer.renderText(
|
renderer.renderText(
|
||||||
scriptManager.getDisplayText(), coreData.getMenuFontNormal(),
|
scriptManager.getDisplayText(), coreData.getMenuFontNormal(),
|
||||||
Vec3f(fontColor.x,fontColor.y,fontColor.z), 200, 680, false);
|
Vec3f(fontColor.x,fontColor.y,fontColor.z), 200, 680, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(program != NULL) program->renderProgramMsgBox();
|
if(program != NULL) program->renderProgramMsgBox();
|
||||||
|
|
||||||
@@ -2040,17 +2047,30 @@ void Game::render2d(){
|
|||||||
int mh= metrics.getMinimapH();
|
int mh= metrics.getMinimapH();
|
||||||
const Vec4f fontColor=getGui()->getDisplay()->getColor();
|
const Vec4f fontColor=getGui()->getDisplay()->getColor();
|
||||||
|
|
||||||
|
if(Renderer::renderText3DEnabled == true) {
|
||||||
|
renderer.renderTextShadow3D(str, coreData.getMenuFontNormal3D(),
|
||||||
|
fontColor, 10, metrics.getVirtualH() - mh - 60, false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderer.renderTextShadow(str, coreData.getMenuFontNormal(),
|
renderer.renderTextShadow(str, coreData.getMenuFontNormal(),
|
||||||
fontColor, 10, metrics.getVirtualH() - mh - 60, false);
|
fontColor, 10, metrics.getVirtualH() - mh - 60, false);
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < world.getFactionCount(); ++i) {
|
for(int i = 0; i < world.getFactionCount(); ++i) {
|
||||||
string factionInfo = factionDebugInfo[i];
|
string factionInfo = factionDebugInfo[i];
|
||||||
Vec3f playerColor = world.getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0);
|
Vec3f playerColor = world.getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0);
|
||||||
|
|
||||||
|
if(Renderer::renderText3DEnabled == true) {
|
||||||
|
renderer.renderText3D(factionInfo, coreData.getMenuFontBig3D(),
|
||||||
|
Vec4f(playerColor.x,playerColor.y,playerColor.z,1.0),
|
||||||
|
10, metrics.getVirtualH() - mh - 90 - 280 - (i * 16), false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderer.renderText(factionInfo, coreData.getMenuFontBig(),
|
renderer.renderText(factionInfo, coreData.getMenuFontBig(),
|
||||||
Vec4f(playerColor.x,playerColor.y,playerColor.z,1.0),
|
Vec4f(playerColor.x,playerColor.y,playerColor.z,1.0),
|
||||||
10, metrics.getVirtualH() - mh - 90 - 280 - (i * 16), false);
|
10, metrics.getVirtualH() - mh - 90 - 280 - (i * 16), false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if((renderer.getShowDebugUILevel() & debugui_unit_titles) == debugui_unit_titles) {
|
if((renderer.getShowDebugUILevel() & debugui_unit_titles) == debugui_unit_titles) {
|
||||||
if(renderer.getAllowRenderUnitTitles() == false) {
|
if(renderer.getAllowRenderUnitTitles() == false) {
|
||||||
@@ -2070,12 +2090,20 @@ void Game::render2d(){
|
|||||||
int mh= metrics.getMinimapH();
|
int mh= metrics.getMinimapH();
|
||||||
const Vec4f fontColor=getGui()->getDisplay()->getColor();
|
const Vec4f fontColor=getGui()->getDisplay()->getColor();
|
||||||
|
|
||||||
|
if(Renderer::renderText3DEnabled == true) {
|
||||||
|
renderer.renderTextShadow3D(
|
||||||
|
NetworkManager::getInstance().getGameNetworkInterface()->getNetworkStatus(),
|
||||||
|
coreData.getMenuFontNormal3D(),
|
||||||
|
fontColor, mx + mw + 5 , metrics.getVirtualH()-30-20, false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderer.renderTextShadow(
|
renderer.renderTextShadow(
|
||||||
NetworkManager::getInstance().getGameNetworkInterface()->getNetworkStatus(),
|
NetworkManager::getInstance().getGameNetworkInterface()->getNetworkStatus(),
|
||||||
coreData.getMenuFontNormal(),
|
coreData.getMenuFontNormal(),
|
||||||
fontColor, mx + mw + 5 , metrics.getVirtualH()-30-20, false);
|
fontColor, mx + mw + 5 , metrics.getVirtualH()-30-20, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//resource info
|
//resource info
|
||||||
if(photoModeEnabled == false) {
|
if(photoModeEnabled == false) {
|
||||||
|
@@ -38,6 +38,8 @@ namespace Glest { namespace Game{
|
|||||||
|
|
||||||
uint32 Renderer::SurfaceData::nextUniqueId = 1;
|
uint32 Renderer::SurfaceData::nextUniqueId = 1;
|
||||||
|
|
||||||
|
bool Renderer::renderText3DEnabled = true;
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class MeshCallbackTeamColor
|
// class MeshCallbackTeamColor
|
||||||
// =====================================================
|
// =====================================================
|
||||||
@@ -955,6 +957,91 @@ void Renderer::renderTextureQuad(int x, int y, int w, int h, const Texture2D *te
|
|||||||
assertGl();
|
assertGl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::renderConsoleLine3D(int lineIndex, int xPosition, int yPosition, int lineHeight,
|
||||||
|
Font3D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo) {
|
||||||
|
Vec4f fontColor;
|
||||||
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
|
FontMetrics *fontMetrics= font->getMetrics();
|
||||||
|
|
||||||
|
if(game != NULL) {
|
||||||
|
fontColor = game->getGui()->getDisplay()->getColor();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// white shadowed is default ( in the menu for example )
|
||||||
|
//fontColor=Vec4f(1.f, 1.f, 1.f, 0.0f);
|
||||||
|
fontColor=Vec4f(lineInfo->color.x,lineInfo->color.y,lineInfo->color.z, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec4f defaultFontColor = fontColor;
|
||||||
|
|
||||||
|
if(lineInfo->PlayerIndex >= 0) {
|
||||||
|
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
|
||||||
|
Vec3f playerColor = crcPlayerTextureCache[lineInfo->PlayerIndex]->getPixmap()->getPixel3f(0, 0);
|
||||||
|
fontColor.x = playerColor.x;
|
||||||
|
fontColor.y = playerColor.y;
|
||||||
|
fontColor.z = playerColor.z;
|
||||||
|
|
||||||
|
GameNetworkInterface *gameNetInterface = NetworkManager::getInstance().getGameNetworkInterface();
|
||||||
|
if(gameNetInterface != NULL && gameNetInterface->getGameSettings() != NULL) {
|
||||||
|
const GameSettings *gameSettings = gameNetInterface->getGameSettings();
|
||||||
|
string playerName = gameSettings->getNetworkPlayerNameByPlayerIndex(lineInfo->PlayerIndex);
|
||||||
|
if(playerName != lineInfo->originalPlayerName && lineInfo->originalPlayerName != "") {
|
||||||
|
playerName = lineInfo->originalPlayerName;
|
||||||
|
}
|
||||||
|
//printf("playerName [%s], line [%s]\n",playerName.c_str(),line.c_str());
|
||||||
|
|
||||||
|
//string headerLine = "*" + playerName + ":";
|
||||||
|
string headerLine = playerName + ": ";
|
||||||
|
|
||||||
|
if(fontMetrics == NULL) {
|
||||||
|
throw runtime_error("fontMetrics == NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
renderTextShadow3D(
|
||||||
|
headerLine,
|
||||||
|
font,
|
||||||
|
fontColor,
|
||||||
|
xPosition, lineIndex * lineHeight + yPosition);
|
||||||
|
|
||||||
|
fontColor = defaultFontColor;
|
||||||
|
//xPosition += (8 * (playerName.length() + 2));
|
||||||
|
// Proper font spacing after username portion of chat text rendering
|
||||||
|
xPosition += (metrics.toVirtualX(fontMetrics->getTextWidth(headerLine)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(lineInfo->originalPlayerName != "") {
|
||||||
|
string playerName = lineInfo->originalPlayerName;
|
||||||
|
string headerLine = playerName + ": ";
|
||||||
|
|
||||||
|
if(fontMetrics == NULL) {
|
||||||
|
throw runtime_error("fontMetrics == NULL");
|
||||||
|
}
|
||||||
|
|
||||||
|
renderTextShadow3D(
|
||||||
|
headerLine,
|
||||||
|
font,
|
||||||
|
fontColor,
|
||||||
|
xPosition, lineIndex * lineHeight + yPosition);
|
||||||
|
|
||||||
|
fontColor = defaultFontColor;
|
||||||
|
//xPosition += (8 * (playerName.length() + 2));
|
||||||
|
// Proper font spacing after username portion of chat text rendering
|
||||||
|
xPosition += (metrics.toVirtualX(fontMetrics->getTextWidth(headerLine)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fontColor = defaultFontColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stringToHightlight!="" && lineInfo->text.find(stringToHightlight)!=string::npos){
|
||||||
|
fontColor=Vec4f(1.f, 0.5f, 0.5f, 0.0f);
|
||||||
|
}
|
||||||
|
renderTextShadow3D(
|
||||||
|
lineInfo->text,
|
||||||
|
font,
|
||||||
|
fontColor,
|
||||||
|
xPosition, (lineIndex * lineHeight) + yPosition);
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::renderConsoleLine(int lineIndex, int xPosition, int yPosition, int lineHeight,
|
void Renderer::renderConsoleLine(int lineIndex, int xPosition, int yPosition, int lineHeight,
|
||||||
Font2D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo) {
|
Font2D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo) {
|
||||||
Vec4f fontColor;
|
Vec4f fontColor;
|
||||||
@@ -1052,25 +1139,45 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,
|
|||||||
if(showFullConsole) {
|
if(showFullConsole) {
|
||||||
for(int i = 0; i < console->getStoredLineCount(); ++i) {
|
for(int i = 0; i < console->getStoredLineCount(); ++i) {
|
||||||
const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i);
|
const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i);
|
||||||
|
if(renderText3DEnabled == true) {
|
||||||
|
renderConsoleLine3D(i, console->getXPos(), console->getYPos(),
|
||||||
|
console->getLineHeight(), console->getFont3D(),
|
||||||
|
console->getStringToHighlight(), &lineInfo);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderConsoleLine(i, console->getXPos(), console->getYPos(),
|
renderConsoleLine(i, console->getXPos(), console->getYPos(),
|
||||||
console->getLineHeight(), console->getFont(), console->getStringToHighlight(), &lineInfo);
|
console->getLineHeight(), console->getFont(),
|
||||||
|
console->getStringToHighlight(), &lineInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(showMenuConsole) {
|
else if(showMenuConsole) {
|
||||||
int allowedMaxLines = (overrideMaxConsoleLines >= 0 ? overrideMaxConsoleLines : maxConsoleLines);
|
int allowedMaxLines = (overrideMaxConsoleLines >= 0 ? overrideMaxConsoleLines : maxConsoleLines);
|
||||||
for(int i = 0; i < console->getStoredLineCount() && i < allowedMaxLines; ++i) {
|
for(int i = 0; i < console->getStoredLineCount() && i < allowedMaxLines; ++i) {
|
||||||
const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i);
|
const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i);
|
||||||
|
if(renderText3DEnabled == true) {
|
||||||
|
renderConsoleLine3D(i, console->getXPos(), console->getYPos(),
|
||||||
|
console->getLineHeight(), console->getFont3D(), console->getStringToHighlight(), &lineInfo);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderConsoleLine(i, console->getXPos(), console->getYPos(),
|
renderConsoleLine(i, console->getXPos(), console->getYPos(),
|
||||||
console->getLineHeight(), console->getFont(), console->getStringToHighlight(), &lineInfo);
|
console->getLineHeight(), console->getFont(), console->getStringToHighlight(), &lineInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
for(int i = 0; i < console->getLineCount(); ++i) {
|
for(int i = 0; i < console->getLineCount(); ++i) {
|
||||||
const ConsoleLineInfo &lineInfo = console->getLineItem(i);
|
const ConsoleLineInfo &lineInfo = console->getLineItem(i);
|
||||||
|
if(renderText3DEnabled == true) {
|
||||||
|
renderConsoleLine3D(i, console->getXPos(), console->getYPos(),
|
||||||
|
console->getLineHeight(), console->getFont3D(), console->getStringToHighlight(), &lineInfo);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderConsoleLine(i, console->getXPos(), console->getYPos(),
|
renderConsoleLine(i, console->getXPos(), console->getYPos(),
|
||||||
console->getLineHeight(), console->getFont(), console->getStringToHighlight(), &lineInfo);
|
console->getLineHeight(), console->getFont(), console->getStringToHighlight(), &lineInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1081,7 +1188,7 @@ void Renderer::renderChatManager(const ChatManager *chatManager) {
|
|||||||
if(chatManager->getEditEnabled()) {
|
if(chatManager->getEditEnabled()) {
|
||||||
string text="";
|
string text="";
|
||||||
|
|
||||||
if(chatManager->getInMenu()){
|
if(chatManager->getInMenu()) {
|
||||||
text += lang.get("Chat");
|
text += lang.get("Chat");
|
||||||
}
|
}
|
||||||
else if(chatManager->getTeamMode()) {
|
else if(chatManager->getTeamMode()) {
|
||||||
@@ -1100,25 +1207,37 @@ void Renderer::renderChatManager(const ChatManager *chatManager) {
|
|||||||
fontColor=Vec4f(1.f, 1.f, 1.f, 0.0f);
|
fontColor=Vec4f(1.f, 1.f, 1.f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(renderText3DEnabled == true) {
|
||||||
|
renderTextShadow3D(
|
||||||
|
text,
|
||||||
|
chatManager->getFont3D(),
|
||||||
|
fontColor,
|
||||||
|
chatManager->getXPos(), chatManager->getYPos());
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderTextShadow(
|
renderTextShadow(
|
||||||
text,
|
text,
|
||||||
chatManager->getFont(),
|
chatManager->getFont(),
|
||||||
fontColor,
|
fontColor,
|
||||||
chatManager->getXPos(), chatManager->getYPos());
|
chatManager->getXPos(), chatManager->getYPos());
|
||||||
|
}
|
||||||
//textRenderer->begin(CoreData::getInstance().getConsoleFont());
|
|
||||||
//textRenderer->render(text, 300, 150);
|
|
||||||
//textRenderer->end();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (chatManager->getInMenu()) {
|
if (chatManager->getInMenu()) {
|
||||||
string text = ">> "+lang.get("PressEnterToChat")+" <<";
|
string text = ">> "+lang.get("PressEnterToChat")+" <<";
|
||||||
fontColor = Vec4f(0.5f, 0.5f, 0.5f, 0.5f);
|
fontColor = Vec4f(0.5f, 0.5f, 0.5f, 0.5f);
|
||||||
|
|
||||||
|
if(renderText3DEnabled == true) {
|
||||||
|
renderTextShadow3D(text, chatManager->getFont3D(), fontColor,
|
||||||
|
chatManager->getXPos(), chatManager->getYPos());
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderTextShadow(text, chatManager->getFont(), fontColor,
|
renderTextShadow(text, chatManager->getFont(), fontColor,
|
||||||
chatManager->getXPos(), chatManager->getYPos());
|
chatManager->getXPos(), chatManager->getYPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderResourceStatus() {
|
void Renderer::renderResourceStatus() {
|
||||||
@@ -1169,10 +1288,18 @@ void Renderer::renderResourceStatus() {
|
|||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
if(renderText3DEnabled == true) {
|
||||||
|
renderTextShadow3D(
|
||||||
|
str, CoreData::getInstance().getDisplayFontSmall3D(),
|
||||||
|
fontColor,
|
||||||
|
j*100+220, metrics.getVirtualH()-30, false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderTextShadow(
|
renderTextShadow(
|
||||||
str, CoreData::getInstance().getDisplayFontSmall(),
|
str, CoreData::getInstance().getDisplayFontSmall(),
|
||||||
fontColor,
|
fontColor,
|
||||||
j*100+220, metrics.getVirtualH()-30, false);
|
j*100+220, metrics.getVirtualH()-30, false);
|
||||||
|
}
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1440,12 +1567,22 @@ void Renderer::renderLabel(GraphicLabel *label,const Vec4f *color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(color != NULL) {
|
if(color != NULL) {
|
||||||
|
if(renderText3DEnabled == true) {
|
||||||
|
renderText3D(lines[i], label->getFont3D(), (*color), textPos.x, textPos.y, label->getCentered());
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderText(lines[i], label->getFont(), (*color), textPos.x, textPos.y, label->getCentered());
|
renderText(lines[i], label->getFont(), (*color), textPos.x, textPos.y, label->getCentered());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(renderText3DEnabled == true) {
|
||||||
|
renderText3D(lines[i], label->getFont3D(), GraphicComponent::getFade(), textPos.x, textPos.y, label->getCentered());
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
renderText(lines[i], label->getFont(), GraphicComponent::getFade(), textPos.x, textPos.y, label->getCentered());
|
renderText(lines[i], label->getFont(), GraphicComponent::getFade(), textPos.x, textPos.y, label->getCentered());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1555,24 +1692,25 @@ void Renderer::renderButton(GraphicButton *button, const Vec4f *fontColorOverrid
|
|||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2i textPos= Vec2i(x+w/2, y+h/2);
|
Vec2i textPos= Vec2i(x + w / 2, y + h / 2);
|
||||||
|
|
||||||
if(button->getEditable()) {
|
if(button->getEditable()) {
|
||||||
Font2D *font = button->getFont();
|
if(renderText3DEnabled == true) {
|
||||||
//Font3D *font3d = ConvertFont2DTo3D(button->getFont());
|
renderText3D(button->getText(), button->getFont3D(), color,x + w / 2, y + h / 2, true);
|
||||||
renderText(
|
|
||||||
button->getText(), font, color,
|
|
||||||
x+w/2, y+h/2, true);
|
|
||||||
//delete font3d;
|
|
||||||
|
|
||||||
// renderText(
|
|
||||||
// button->getText(), button->getFont(), color,
|
|
||||||
// x+w/2, y+h/2, true);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
renderText(
|
renderText(button->getText(), button->getFont(), color,x + w / 2, y + h / 2, true);
|
||||||
button->getText(), button->getFont(),disabledTextColor,
|
}
|
||||||
x+w/2, y+h/2, true);
|
}
|
||||||
|
else {
|
||||||
|
if(renderText3DEnabled == true) {
|
||||||
|
renderText3D(button->getText(), button->getFont3D(),disabledTextColor,
|
||||||
|
x + w / 2, y + h / 2, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
renderText(button->getText(), button->getFont(),disabledTextColor,
|
||||||
|
x + w / 2, y + h / 2, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
@@ -1976,6 +2114,20 @@ void Renderer::renderMessageBox(GraphicMessageBox *messageBox) {
|
|||||||
fontColor=Vec4f(1.f, 1.f, 1.f, 1.0f);
|
fontColor=Vec4f(1.f, 1.f, 1.f, 1.0f);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
if(renderText3DEnabled == true) {
|
||||||
|
//text
|
||||||
|
renderTextShadow3D(
|
||||||
|
messageBox->getText(), messageBox->getFont3D(), fontColor,
|
||||||
|
messageBox->getX()+15, messageBox->getY()+7*messageBox->getH()/10,
|
||||||
|
false );
|
||||||
|
|
||||||
|
renderTextShadow3D(
|
||||||
|
messageBox->getHeader(), messageBox->getFont3D(),fontColor,
|
||||||
|
messageBox->getX()+15, messageBox->getY()+93*messageBox->getH()/100,
|
||||||
|
false );
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
//text
|
//text
|
||||||
renderTextShadow(
|
renderTextShadow(
|
||||||
messageBox->getText(), messageBox->getFont(), fontColor,
|
messageBox->getText(), messageBox->getFont(), fontColor,
|
||||||
@@ -1986,6 +2138,7 @@ void Renderer::renderMessageBox(GraphicMessageBox *messageBox) {
|
|||||||
messageBox->getHeader(), messageBox->getFont(),fontColor,
|
messageBox->getHeader(), messageBox->getFont(),fontColor,
|
||||||
messageBox->getX()+15, messageBox->getY()+93*messageBox->getH()/100,
|
messageBox->getX()+15, messageBox->getY()+93*messageBox->getH()/100,
|
||||||
false );
|
false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== complex rendering ====================
|
// ==================== complex rendering ====================
|
||||||
@@ -3459,7 +3612,7 @@ void Renderer::renderMinimap(){
|
|||||||
assertGl();
|
assertGl();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderDisplay(){
|
void Renderer::renderDisplay() {
|
||||||
|
|
||||||
CoreData &coreData= CoreData::getInstance();
|
CoreData &coreData= CoreData::getInstance();
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
@@ -3467,6 +3620,43 @@ void Renderer::renderDisplay(){
|
|||||||
|
|
||||||
glPushAttrib(GL_ENABLE_BIT);
|
glPushAttrib(GL_ENABLE_BIT);
|
||||||
|
|
||||||
|
if(renderText3DEnabled == true) {
|
||||||
|
//infoString
|
||||||
|
renderTextShadow3D(
|
||||||
|
display->getInfoText().c_str(),
|
||||||
|
coreData.getDisplayFont3D(),
|
||||||
|
display->getColor(),
|
||||||
|
metrics.getDisplayX(),
|
||||||
|
metrics.getDisplayY()+Display::infoStringY);
|
||||||
|
|
||||||
|
//title
|
||||||
|
renderTextShadow3D(
|
||||||
|
display->getTitle().c_str(),
|
||||||
|
coreData.getDisplayFont3D(),
|
||||||
|
display->getColor(),
|
||||||
|
metrics.getDisplayX()+40,
|
||||||
|
metrics.getDisplayY() + metrics.getDisplayH() - 20);
|
||||||
|
|
||||||
|
glColor3f(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
//text
|
||||||
|
renderTextShadow3D(
|
||||||
|
display->getText().c_str(),
|
||||||
|
coreData.getDisplayFont3D(),
|
||||||
|
display->getColor(),
|
||||||
|
metrics.getDisplayX() -1,
|
||||||
|
metrics.getDisplayY() + metrics.getDisplayH() - 56);
|
||||||
|
|
||||||
|
//progress Bar
|
||||||
|
if(display->getProgressBar() != -1) {
|
||||||
|
renderProgressBar3D(
|
||||||
|
display->getProgressBar(),
|
||||||
|
metrics.getDisplayX(),
|
||||||
|
metrics.getDisplayY() + metrics.getDisplayH()-50,
|
||||||
|
coreData.getDisplayFontSmall3D());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
//infoString
|
//infoString
|
||||||
renderTextShadow(
|
renderTextShadow(
|
||||||
display->getInfoText().c_str(),
|
display->getInfoText().c_str(),
|
||||||
@@ -3501,6 +3691,7 @@ void Renderer::renderDisplay(){
|
|||||||
metrics.getDisplayY() + metrics.getDisplayH()-50,
|
metrics.getDisplayY() + metrics.getDisplayH()-50,
|
||||||
coreData.getDisplayFontSmall());
|
coreData.getDisplayFontSmall());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//up images
|
//up images
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
@@ -186,6 +186,8 @@ public:
|
|||||||
//light
|
//light
|
||||||
static const float maxLightDist;
|
static const float maxLightDist;
|
||||||
|
|
||||||
|
static bool renderText3DEnabled;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Shadows {
|
enum Shadows {
|
||||||
sDisabled,
|
sDisabled,
|
||||||
@@ -196,6 +198,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//config
|
//config
|
||||||
int maxLights;
|
int maxLights;
|
||||||
bool photoMode;
|
bool photoMode;
|
||||||
@@ -326,6 +329,8 @@ public:
|
|||||||
Font3D *newFont3D(ResourceScope rs);
|
Font3D *newFont3D(ResourceScope rs);
|
||||||
|
|
||||||
TextRenderer2D *getTextRenderer() const {return textRenderer;}
|
TextRenderer2D *getTextRenderer() const {return textRenderer;}
|
||||||
|
TextRenderer3D *getTextRenderer3D() const {return textRenderer3D;}
|
||||||
|
|
||||||
void manageParticleSystem(ParticleSystem *particleSystem, ResourceScope rs);
|
void manageParticleSystem(ParticleSystem *particleSystem, ResourceScope rs);
|
||||||
void cleanupParticleSystems(vector<ParticleSystem *> &particleSystems,ResourceScope rs);
|
void cleanupParticleSystems(vector<ParticleSystem *> &particleSystems,ResourceScope rs);
|
||||||
void cleanupUnitParticleSystems(vector<UnitParticleSystem *> &particleSystems,ResourceScope rs);
|
void cleanupUnitParticleSystems(vector<UnitParticleSystem *> &particleSystems,ResourceScope rs);
|
||||||
@@ -346,7 +351,9 @@ public:
|
|||||||
void renderBackground(const Texture2D *texture);
|
void renderBackground(const Texture2D *texture);
|
||||||
void renderTextureQuad(int x, int y, int w, int h, const Texture2D *texture, float alpha=1.f,const Vec3f *color=NULL);
|
void renderTextureQuad(int x, int y, int w, int h, const Texture2D *texture, float alpha=1.f,const Vec3f *color=NULL);
|
||||||
void renderConsole(const Console *console, const bool showAll=false, const bool showMenuConsole=false, int overrideMaxConsoleLines=-1);
|
void renderConsole(const Console *console, const bool showAll=false, const bool showMenuConsole=false, int overrideMaxConsoleLines=-1);
|
||||||
|
void renderConsoleLine3D(int lineIndex, int xPosition, int yPosition, int lineHeight, Font3D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo);
|
||||||
void renderConsoleLine(int lineIndex, int xPosition, int yPosition, int lineHeight, Font2D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo);
|
void renderConsoleLine(int lineIndex, int xPosition, int yPosition, int lineHeight, Font2D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo);
|
||||||
|
|
||||||
void renderChatManager(const ChatManager *chatManager);
|
void renderChatManager(const ChatManager *chatManager);
|
||||||
void renderResourceStatus();
|
void renderResourceStatus();
|
||||||
void renderSelectionQuad();
|
void renderSelectionQuad();
|
||||||
@@ -358,9 +365,8 @@ public:
|
|||||||
void renderText3D(const string &text, Font3D *font, float alpha, int x, int y, bool centered);
|
void renderText3D(const string &text, Font3D *font, float alpha, int x, int y, bool centered);
|
||||||
void renderText3D(const string &text, Font3D *font, const Vec3f &color, int x, int y, bool centered);
|
void renderText3D(const string &text, Font3D *font, const Vec3f &color, int x, int y, bool centered);
|
||||||
void renderText3D(const string &text, Font3D *font, const Vec4f &color, int x, int y, bool centered);
|
void renderText3D(const string &text, Font3D *font, const Vec4f &color, int x, int y, bool centered);
|
||||||
void renderTextShadow3D(const string &text, Font3D *font,const Vec4f &color, int x, int y, bool centered);
|
void renderTextShadow3D(const string &text, Font3D *font,const Vec4f &color, int x, int y, bool centered=false);
|
||||||
void renderProgressBar3D(int size, int x, int y, Font3D *font, int customWidth,
|
void renderProgressBar3D(int size, int x, int y, Font3D *font, int customWidth=-1, string prefixLabel="", bool centeredText=true);
|
||||||
string prefixLabel,bool centeredText);
|
|
||||||
|
|
||||||
//components
|
//components
|
||||||
void renderLabel(GraphicLabel *label);
|
void renderLabel(GraphicLabel *label);
|
||||||
|
@@ -72,7 +72,16 @@ void BattleEnd::update() {
|
|||||||
|
|
||||||
void BattleEnd::render(){
|
void BattleEnd::render(){
|
||||||
Renderer &renderer= Renderer::getInstance();
|
Renderer &renderer= Renderer::getInstance();
|
||||||
TextRenderer2D *textRenderer= renderer.getTextRenderer();
|
TextRenderer2D *textRenderer2D= renderer.getTextRenderer();
|
||||||
|
TextRenderer3D *textRenderer3D= renderer.getTextRenderer3D();
|
||||||
|
TextRenderer *textRenderer= NULL;
|
||||||
|
if(Renderer::renderText3DEnabled == true) {
|
||||||
|
textRenderer= textRenderer3D;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
textRenderer= textRenderer2D;
|
||||||
|
}
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
renderer.clearBuffers();
|
renderer.clearBuffers();
|
||||||
@@ -137,7 +146,13 @@ void BattleEnd::render(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool disableStatsColorCoding = Config::getInstance().getBool("DisableBattleEndColorCoding","false");
|
bool disableStatsColorCoding = Config::getInstance().getBool("DisableBattleEndColorCoding","false");
|
||||||
textRenderer->begin(CoreData::getInstance().getMenuFontNormal());
|
|
||||||
|
if(Renderer::renderText3DEnabled == true) {
|
||||||
|
textRenderer3D->begin(CoreData::getInstance().getMenuFontNormal3D());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
textRenderer2D->begin(CoreData::getInstance().getMenuFontNormal());
|
||||||
|
}
|
||||||
|
|
||||||
int lm= 20;
|
int lm= 20;
|
||||||
int bm= 100;
|
int bm= 100;
|
||||||
@@ -292,7 +307,12 @@ void BattleEnd::render(){
|
|||||||
|
|
||||||
textRenderer->end();
|
textRenderer->end();
|
||||||
|
|
||||||
textRenderer->begin(CoreData::getInstance().getMenuFontVeryBig());
|
if(Renderer::renderText3DEnabled == true) {
|
||||||
|
textRenderer3D->begin(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
textRenderer2D->begin(CoreData::getInstance().getMenuFontVeryBig());
|
||||||
|
}
|
||||||
|
|
||||||
string header = stats.getDescription() + " - ";
|
string header = stats.getDescription() + " - ";
|
||||||
|
|
||||||
|
@@ -32,12 +32,13 @@ namespace Glest{ namespace Game{
|
|||||||
// class Text
|
// class Text
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
Text::Text(const string &text, const Vec2i &pos, int time, Font2D *font) {
|
Text::Text(const string &text, const Vec2i &pos, int time, Font2D *font, Font3D *font3D) {
|
||||||
this->text= text;
|
this->text= text;
|
||||||
this->pos= pos;
|
this->pos= pos;
|
||||||
this->time= time;
|
this->time= time;
|
||||||
this->texture= NULL;
|
this->texture= NULL;
|
||||||
this->font= font;
|
this->font= font;
|
||||||
|
this->font3D = font3D;
|
||||||
}
|
}
|
||||||
|
|
||||||
Text::Text(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int time) {
|
Text::Text(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int time) {
|
||||||
@@ -72,8 +73,8 @@ Intro::Intro(Program *program):
|
|||||||
mouse2d = 0;
|
mouse2d = 0;
|
||||||
|
|
||||||
texts.push_back(Text(coreData.getLogoTexture(), Vec2i(w/2-128, h/2-64), Vec2i(256, 128), 4000));
|
texts.push_back(Text(coreData.getLogoTexture(), Vec2i(w/2-128, h/2-64), Vec2i(256, 128), 4000));
|
||||||
texts.push_back(Text(glestVersionString, Vec2i(w/2+45, h/2-45), 4000, coreData.getMenuFontNormal()));
|
texts.push_back(Text(glestVersionString, Vec2i(w/2+45, h/2-45), 4000, coreData.getMenuFontNormal(),coreData.getMenuFontNormal3D()));
|
||||||
texts.push_back(Text("www.megaglest.org", Vec2i(w/2, h/2), 12000, coreData.getMenuFontVeryBig()));
|
texts.push_back(Text("www.megaglest.org", Vec2i(w/2, h/2), 12000, coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D()));
|
||||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
|
|
||||||
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__);
|
||||||
@@ -124,11 +125,20 @@ void Intro::render() {
|
|||||||
//disappearing
|
//disappearing
|
||||||
alpha= 1.f- static_cast<float>(difTime-appearTime-showTime)/disapearTime;
|
alpha= 1.f- static_cast<float>(difTime-appearTime-showTime)/disapearTime;
|
||||||
}
|
}
|
||||||
if(!text->getText().empty()){
|
|
||||||
|
if(text->getText().empty() == false) {
|
||||||
|
if(Renderer::renderText3DEnabled) {
|
||||||
|
renderer.renderText3D(
|
||||||
|
text->getText(), text->getFont3D(), alpha,
|
||||||
|
text->getPos().x, text->getPos().y, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderer.renderText(
|
renderer.renderText(
|
||||||
text->getText(), text->getFont(), alpha,
|
text->getText(), text->getFont(), alpha,
|
||||||
text->getPos().x, text->getPos().y, true);
|
text->getPos().x, text->getPos().y, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(text->getTexture()!=NULL){
|
if(text->getTexture()!=NULL){
|
||||||
renderer.renderTextureQuad(
|
renderer.renderTextureQuad(
|
||||||
text->getPos().x, text->getPos().y,
|
text->getPos().x, text->getPos().y,
|
||||||
|
@@ -26,6 +26,7 @@ using Shared::Graphics::Vec2i;
|
|||||||
using Shared::Graphics::Vec2f;
|
using Shared::Graphics::Vec2f;
|
||||||
using Shared::Graphics::Vec3f;
|
using Shared::Graphics::Vec3f;
|
||||||
using Shared::Graphics::Font2D;
|
using Shared::Graphics::Font2D;
|
||||||
|
using Shared::Graphics::Font3D;
|
||||||
using Shared::Graphics::Texture2D;
|
using Shared::Graphics::Texture2D;
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
@@ -34,21 +35,23 @@ namespace Glest{ namespace Game{
|
|||||||
// class Text
|
// class Text
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class Text{
|
class Text {
|
||||||
private:
|
private:
|
||||||
string text;
|
string text;
|
||||||
Vec2i pos;
|
Vec2i pos;
|
||||||
Vec2i size;
|
Vec2i size;
|
||||||
int time;
|
int time;
|
||||||
Font2D *font;
|
Font2D *font;
|
||||||
|
Font3D *font3D;
|
||||||
const Texture2D *texture;
|
const Texture2D *texture;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Text(const string &text, const Vec2i &pos, int time, Font2D *font);
|
Text(const string &text, const Vec2i &pos, int time, Font2D *font, Font3D *font3D);
|
||||||
Text(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int time);
|
Text(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int time);
|
||||||
|
|
||||||
const string &getText() const {return text;}
|
const string &getText() const {return text;}
|
||||||
Font2D *getFont() {return font;}
|
Font2D *getFont() {return font;}
|
||||||
|
Font3D *getFont3D() {return font3D;}
|
||||||
const Vec2i &getPos() const {return pos;}
|
const Vec2i &getPos() const {return pos;}
|
||||||
const Vec2i &getSize() const {return size;}
|
const Vec2i &getSize() const {return size;}
|
||||||
int getTime() const {return time;}
|
int getTime() const {return time;}
|
||||||
|
@@ -2455,6 +2455,8 @@ int glestMain(int argc, char** argv) {
|
|||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**WARNING** Forcing Legacy Fonts Enabled\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**WARNING** Forcing Legacy Fonts Enabled\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Renderer::renderText3DEnabled = config.getBool("Enable3DFontRendering",intToStr(Renderer::renderText3DEnabled).c_str());
|
||||||
|
|
||||||
// Set some statics based on ini entries
|
// Set some statics based on ini entries
|
||||||
SystemFlags::ENABLE_THREADED_LOGGING = config.getBool("ThreadedLogging","true");
|
SystemFlags::ENABLE_THREADED_LOGGING = config.getBool("ThreadedLogging","true");
|
||||||
FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str()));
|
FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str()));
|
||||||
|
@@ -111,10 +111,17 @@ void MainMenu::render() {
|
|||||||
renderer.renderMouse2d(mouseX, mouseY, mouse2dAnim);
|
renderer.renderMouse2d(mouseX, mouseY, mouse2dAnim);
|
||||||
|
|
||||||
if(renderer.getShowDebugUI() == true) {
|
if(renderer.getShowDebugUI() == true) {
|
||||||
|
if(Renderer::renderText3DEnabled) {
|
||||||
|
renderer.renderText3D(
|
||||||
|
"FPS: " + intToStr(lastFps),
|
||||||
|
coreData.getMenuFontNormal3D(), Vec3f(1.f), 10, 10, false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
renderer.renderText(
|
renderer.renderText(
|
||||||
"FPS: " + intToStr(lastFps),
|
"FPS: " + intToStr(lastFps),
|
||||||
coreData.getMenuFontNormal(), Vec3f(1.f), 10, 10, false);
|
coreData.getMenuFontNormal(), Vec3f(1.f), 10, 10, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderer.swapBuffers();
|
renderer.swapBuffers();
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ public:
|
|||||||
virtual ~TextRenderer2DGl();
|
virtual ~TextRenderer2DGl();
|
||||||
|
|
||||||
virtual void begin(Font2D *font);
|
virtual void begin(Font2D *font);
|
||||||
virtual void render(const string &text, int x, int y, bool centered, Vec3f *color=NULL);
|
virtual void render(const string &text, float x, float y, bool centered=false, Vec3f *color=NULL);
|
||||||
virtual void end();
|
virtual void end();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -51,12 +51,14 @@ private:
|
|||||||
Font3DGl *font;
|
Font3DGl *font;
|
||||||
bool rendering;
|
bool rendering;
|
||||||
|
|
||||||
|
void internalRender(const string &text, float x, float y, bool centered, Vec3f *color);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextRenderer3DGl();
|
TextRenderer3DGl();
|
||||||
virtual ~TextRenderer3DGl();
|
virtual ~TextRenderer3DGl();
|
||||||
|
|
||||||
virtual void begin(Font3D *font);
|
virtual void begin(Font3D *font);
|
||||||
virtual void render(const string &text, float x, float y, bool centered);
|
virtual void render(const string &text, float x, float y, bool centered=false, Vec3f *color=NULL);
|
||||||
virtual void end();
|
virtual void end();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -25,26 +25,32 @@ namespace Shared { namespace Graphics {
|
|||||||
// class TextRenderer2D
|
// class TextRenderer2D
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class TextRenderer2D {
|
class TextRenderer {
|
||||||
|
public:
|
||||||
|
virtual void render(const string &text, float x, float y, bool centered=false, Vec3f *color=NULL) = 0;
|
||||||
|
virtual void end()= 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TextRenderer2D : public TextRenderer {
|
||||||
public:
|
public:
|
||||||
virtual ~TextRenderer2D(){};
|
virtual ~TextRenderer2D(){};
|
||||||
|
|
||||||
virtual void begin(Font2D *font)= 0;
|
virtual void begin(Font2D *font)= 0;
|
||||||
virtual void render(const string &text, int x, int y, bool centered= false,Vec3f *color=NULL)= 0;
|
//virtual void render(const string &text, int x, int y, bool centered= false,Vec3f *color=NULL)= 0;
|
||||||
virtual void end()= 0;
|
//virtual void end()= 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class TextRenderer3D
|
// class TextRenderer3D
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class TextRenderer3D {
|
class TextRenderer3D : public TextRenderer {
|
||||||
public:
|
public:
|
||||||
virtual ~TextRenderer3D(){};
|
virtual ~TextRenderer3D(){};
|
||||||
|
|
||||||
virtual void begin(Font3D *font)= 0;
|
virtual void begin(Font3D *font)= 0;
|
||||||
virtual void render(const string &text, float x, float y, bool centered= false)= 0;
|
//virtual void render(const string &text, float x, float y, bool centered= false,Vec3f *color=NULL)= 0;
|
||||||
virtual void end()= 0;
|
//virtual void end()= 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -61,7 +61,10 @@ void TextRenderer2DGl::begin(Font2D *font) {
|
|||||||
rendering = true;
|
rendering = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextRenderer2DGl::render(const string &text, int x, int y, bool centered, Vec3f *color) {
|
void TextRenderer2DGl::render(const string &text, float x, float y, bool centered, Vec3f *color) {
|
||||||
|
|
||||||
|
printf("**** RENDERING 2D text [%s]\n",text.c_str());
|
||||||
|
|
||||||
//tester->render(text, x, y, this->font->getWidth(),centered);
|
//tester->render(text, x, y, this->font->getWidth(),centered);
|
||||||
//return;
|
//return;
|
||||||
|
|
||||||
@@ -387,21 +390,34 @@ void TextRenderer3DGl::begin(Font3D *font) {
|
|||||||
assertGl();
|
assertGl();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextRenderer3DGl::render(const string &text, float x, float y, bool centered) {
|
void TextRenderer3DGl::render(const string &text, float x, float y, bool centered, Vec3f *color) {
|
||||||
assert(rendering);
|
assert(rendering);
|
||||||
|
|
||||||
|
internalRender(text, x, y, centered, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextRenderer3DGl::internalRender(const string &text, float x, float y, bool centered, Vec3f *color) {
|
||||||
|
//assert(rendering);
|
||||||
|
|
||||||
|
if(color != NULL) {
|
||||||
|
glPushAttrib(GL_CURRENT_BIT);
|
||||||
|
glColor3fv(color->ptr());
|
||||||
|
}
|
||||||
|
|
||||||
const unsigned char *utext= NULL;
|
const unsigned char *utext= NULL;
|
||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glPushAttrib(GL_POLYGON_BIT);
|
glLoadIdentity();
|
||||||
|
//glPushAttrib(GL_POLYGON_BIT);
|
||||||
|
|
||||||
int size = font->getSize();
|
int size = font->getSize();
|
||||||
//float scale= size / 15.f;
|
//float scale= size / 15.f;
|
||||||
float scale= 1.0f;
|
float scale= 1.0f;
|
||||||
//float scale= size;
|
//float scale= size;
|
||||||
Vec3f translatePos;
|
Vec3f translatePos;
|
||||||
|
FontMetrics *metrics= font->getMetrics();
|
||||||
|
|
||||||
if(font->getTextHandler() != NULL) {
|
if(font->getTextHandler() != NULL) {
|
||||||
if(centered) {
|
if(centered) {
|
||||||
@@ -418,7 +434,6 @@ void TextRenderer3DGl::render(const string &text, float x, float y, bool center
|
|||||||
else {
|
else {
|
||||||
utext= reinterpret_cast<const unsigned char*>(text.c_str());
|
utext= reinterpret_cast<const unsigned char*>(text.c_str());
|
||||||
if(centered) {
|
if(centered) {
|
||||||
FontMetrics *metrics= font->getMetrics();
|
|
||||||
//glTranslatef(x-scale*metrics->getTextWidth(text)/2.f, y-scale*metrics->getHeight()/2.f, 0);
|
//glTranslatef(x-scale*metrics->getTextWidth(text)/2.f, y-scale*metrics->getHeight()/2.f, 0);
|
||||||
translatePos.x = x-scale*metrics->getTextWidth(text)/2.f;
|
translatePos.x = x-scale*metrics->getTextWidth(text)/2.f;
|
||||||
translatePos.y = y-scale*metrics->getHeight()/2.f;
|
translatePos.y = y-scale*metrics->getHeight()/2.f;
|
||||||
@@ -433,11 +448,20 @@ void TextRenderer3DGl::render(const string &text, float x, float y, bool center
|
|||||||
}
|
}
|
||||||
|
|
||||||
//glScalef(scale, scale, scale);
|
//glScalef(scale, scale, scale);
|
||||||
|
float scaleX = 0.65;
|
||||||
|
float scaleY = 0.75;
|
||||||
|
float scaleZ = 1.0;
|
||||||
|
|
||||||
|
//x = translatePos.x;
|
||||||
|
float yScaleFactor = (metrics->getHeight() * (1.0 - scaleY));
|
||||||
|
translatePos.y += yScaleFactor;
|
||||||
|
//y = translatePos.y;
|
||||||
|
|
||||||
glTranslatef(translatePos.x, translatePos.y, translatePos.z);
|
glTranslatef(translatePos.x, translatePos.y, translatePos.z);
|
||||||
|
glScalef(scaleX, scaleY, scaleZ);
|
||||||
|
|
||||||
font->getTextHandler()->Render(text.c_str());
|
//font->getTextHandler()->Render(text.c_str());
|
||||||
|
|
||||||
/*
|
|
||||||
if(Font::fontIsMultibyte == true) {
|
if(Font::fontIsMultibyte == true) {
|
||||||
if(font->getTextHandler() != NULL) {
|
if(font->getTextHandler() != NULL) {
|
||||||
if(text.find("\n") == text.npos && text.find("\t") == text.npos) {
|
if(text.find("\n") == text.npos && text.find("\t") == text.npos) {
|
||||||
@@ -479,23 +503,34 @@ void TextRenderer3DGl::render(const string &text, float x, float y, bool center
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool needsRecursiveRender = false;
|
||||||
for (unsigned int i=0; i < parts.size(); ++i) {
|
for (unsigned int i=0; i < parts.size(); ++i) {
|
||||||
switch(parts[i][0]) {
|
switch(parts[i][0]) {
|
||||||
case '\t':
|
case '\t':
|
||||||
translatePos= Vec3f((translatePos.x / size + 3.f) * size, y-(size + 1.f) * line, translatePos.z);
|
//translatePos= Vec3f((translatePos.x / size + 3.f) * size, y-(size + 1.f) * line, translatePos.z);
|
||||||
glTranslatef(translatePos.x, translatePos.y, translatePos.z);
|
translatePos= Vec3f((translatePos.x / size + 3.f) * size, translatePos.y, translatePos.z);
|
||||||
|
needsRecursiveRender = true;
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
|
{
|
||||||
line++;
|
line++;
|
||||||
translatePos= Vec3f(static_cast<float>(x), y - (font->getTextHandler()->LineHeight(parts[i].c_str())) * line, translatePos.z);
|
float yLineValue = font->getTextHandler()->LineHeight(parts[i].c_str());
|
||||||
glTranslatef(translatePos.x, translatePos.y, translatePos.z);
|
translatePos= Vec3f(translatePos.x, translatePos.y - yLineValue, translatePos.z);
|
||||||
|
needsRecursiveRender = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if(needsRecursiveRender == true) {
|
||||||
|
internalRender(parts[i], translatePos.x, translatePos.y, false, color);
|
||||||
|
needsRecursiveRender = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
font->getTextHandler()->Render(parts[i].c_str());
|
font->getTextHandler()->Render(parts[i].c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
//setlocale(LC_CTYPE, "en_ca.UTF-8");
|
//setlocale(LC_CTYPE, "en_ca.UTF-8");
|
||||||
|
|
||||||
@@ -562,33 +597,48 @@ void TextRenderer3DGl::render(const string &text, float x, float y, bool center
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool needsRecursiveRender = false;
|
||||||
for (unsigned int i=0; i < parts.size(); ++i) {
|
for (unsigned int i=0; i < parts.size(); ++i) {
|
||||||
switch(parts[i][0]) {
|
switch(parts[i][0]) {
|
||||||
case '\t':
|
case '\t':
|
||||||
translatePos= Vec3f((translatePos.x / size + 3.f) * size, y-(size + 1.f) * line, translatePos.z);
|
//translatePos= Vec3f((translatePos.x / size + 3.f) * size, y-(size + 1.f) * line, translatePos.z);
|
||||||
glTranslatef(translatePos.x, translatePos.y, translatePos.z);
|
translatePos= Vec3f((translatePos.x / size + 3.f) * size, translatePos.y, translatePos.z);
|
||||||
|
needsRecursiveRender = true;
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
|
{
|
||||||
line++;
|
line++;
|
||||||
translatePos= Vec3f(static_cast<float>(x), y - (font->getTextHandler()->LineHeight(parts[i].c_str())) * line, translatePos.z);
|
float yLineValue = font->getTextHandler()->LineHeight(parts[i].c_str());
|
||||||
glTranslatef(translatePos.x, translatePos.y, translatePos.z);
|
translatePos= Vec3f(translatePos.x, translatePos.y - yLineValue, translatePos.z);
|
||||||
|
needsRecursiveRender = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if(needsRecursiveRender == true) {
|
||||||
|
internalRender(parts[i], translatePos.x, translatePos.y, false, color);
|
||||||
|
needsRecursiveRender = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
font->getTextHandler()->Render(parts[i].c_str());
|
font->getTextHandler()->Render(parts[i].c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
for (int i=0; utext[i]!='\0'; ++i) {
|
for (int i=0; utext[i]!='\0'; ++i) {
|
||||||
glCallList(font->getHandle()+utext[i]);
|
glCallList(font->getHandle()+utext[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
//glPopMatrix();
|
||||||
|
//glPopAttrib();
|
||||||
|
|
||||||
|
if(color != NULL) {
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
}
|
||||||
|
|
||||||
assertGl();
|
assertGl();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user