- Added ability to render text titles for each unit (currently used to debug)
This commit is contained in:
parent
50fe71a651
commit
7753435b3a
|
@ -1016,6 +1016,8 @@ void Game::render2d(){
|
||||||
if(config.getBool("DebugMode") && gui.getShowDebugUI() == true) {
|
if(config.getBool("DebugMode") && gui.getShowDebugUI() == true) {
|
||||||
renderer.renderText(str, coreData.getMenuFontNormal(),
|
renderer.renderText(str, coreData.getMenuFontNormal(),
|
||||||
Vec3f(1.0f), 10, 500, false);
|
Vec3f(1.0f), 10, 500, false);
|
||||||
|
|
||||||
|
renderer.renderUnitTitles(coreData.getMenuFontNormal(),Vec3f(1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
//network status
|
//network status
|
||||||
|
|
|
@ -1632,6 +1632,8 @@ void Renderer::renderUnit(RenderEntity &entity,MeshCallbackTeamColor *meshCallba
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
unit->setVisible(true);
|
unit->setVisible(true);
|
||||||
|
// Add to the pending render unit title list
|
||||||
|
renderUnitTitleList.push_back(std::pair<Unit *,Vec3f>(unit,computeScreenPosition(unit->getCurrVectorFlat())) );
|
||||||
|
|
||||||
entity.setState(resRendered);
|
entity.setState(resRendered);
|
||||||
}
|
}
|
||||||
|
@ -2196,6 +2198,38 @@ bool Renderer::computePosition(const Vec2i &screenPos, Vec2i &worldPos){
|
||||||
return map->isInside(worldPos);
|
return map->isInside(worldPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method takes world co-ordinates and translates them to screen co-ords
|
||||||
|
Vec3f Renderer::computeScreenPosition(const Vec3f &worldPos) {
|
||||||
|
assertGl();
|
||||||
|
|
||||||
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
|
GLint viewport[]= {0, 0, metrics.getVirtualW(), metrics.getVirtualH()};
|
||||||
|
GLdouble worldX = worldPos.x;
|
||||||
|
GLdouble worldY = worldPos.y;
|
||||||
|
GLdouble worldZ = worldPos.z;
|
||||||
|
|
||||||
|
//load matrices
|
||||||
|
loadProjectionMatrix();
|
||||||
|
loadGameCameraMatrix();
|
||||||
|
|
||||||
|
//get matrices
|
||||||
|
GLdouble modelviewMatrix[16];
|
||||||
|
glGetDoublev(GL_MODELVIEW_MATRIX, modelviewMatrix);
|
||||||
|
GLdouble projectionMatrix[16];
|
||||||
|
glGetDoublev(GL_PROJECTION_MATRIX, projectionMatrix);
|
||||||
|
|
||||||
|
//get the screen coordinates
|
||||||
|
GLdouble screenX;
|
||||||
|
GLdouble screenY;
|
||||||
|
GLdouble screenZ;
|
||||||
|
gluProject(worldX, worldY, worldZ,
|
||||||
|
modelviewMatrix, projectionMatrix, viewport,
|
||||||
|
&screenX, &screenY, &screenZ);
|
||||||
|
|
||||||
|
Vec3f screenPos(screenX,screenY,screenZ);
|
||||||
|
return screenPos;
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::computeSelected(Selection::UnitContainer &units, const Vec2i &posDown, const Vec2i &posUp){
|
void Renderer::computeSelected(Selection::UnitContainer &units, const Vec2i &posDown, const Vec2i &posUp){
|
||||||
|
|
||||||
//declarations
|
//declarations
|
||||||
|
@ -3312,4 +3346,22 @@ Texture2D::Filter Renderer::strToTextureFilter(const string &s){
|
||||||
throw runtime_error("Error converting from string to FilterType, found: "+s);
|
throw runtime_error("Error converting from string to FilterType, found: "+s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method renders titles for units
|
||||||
|
void Renderer::renderUnitTitles(Font2D *font, Vec3f color) {
|
||||||
|
if(renderUnitTitleList.size() > 0) {
|
||||||
|
for(int idx = 0; idx < renderUnitTitleList.size(); idx++) {
|
||||||
|
std::pair<Unit *,Vec3f> &unitInfo = renderUnitTitleList[idx];
|
||||||
|
Unit *unit = unitInfo.first;
|
||||||
|
if(unit != NULL) {
|
||||||
|
string str = unit->getFullName() + " - " + intToStr(unit->getId());
|
||||||
|
//get the screen coordinates
|
||||||
|
Vec3f &screenPos = unitInfo.second;
|
||||||
|
renderText(str, font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] screenPos.x = %f, screenPos.y = %f, screenPos.z = %f\n",__FILE__,__FUNCTION__,__LINE__,screenPos.x,screenPos.y,screenPos.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
renderUnitTitleList.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -257,6 +257,9 @@ private:
|
||||||
|
|
||||||
bool allowRotateUnits;
|
bool allowRotateUnits;
|
||||||
|
|
||||||
|
//std::vector<Unit *> renderUnitTitleList;
|
||||||
|
std::vector<std::pair<Unit *,Vec3f> > renderUnitTitleList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Renderer();
|
Renderer();
|
||||||
~Renderer();
|
~Renderer();
|
||||||
|
@ -371,6 +374,8 @@ public:
|
||||||
static string shadowsToStr(Shadows shadows);
|
static string shadowsToStr(Shadows shadows);
|
||||||
|
|
||||||
const Game * getGame() { return game; }
|
const Game * getGame() { return game; }
|
||||||
|
void renderUnitTitles(Font2D *font, Vec3f color);
|
||||||
|
Vec3f computeScreenPosition(const Vec3f &worldPos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//private misc
|
//private misc
|
||||||
|
|
|
@ -179,7 +179,7 @@ public:
|
||||||
void switchToNextDisplayColor();
|
void switchToNextDisplayColor();
|
||||||
void onSelectionChanged();
|
void onSelectionChanged();
|
||||||
|
|
||||||
bool getShowDebugUI() { return showDebugUI; }
|
bool getShowDebugUI() const { return showDebugUI; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -1267,15 +1267,15 @@ void Unit::logSynchData(string source) {
|
||||||
std::string Unit::toString() const {
|
std::string Unit::toString() const {
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
|
|
||||||
/*
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
result += "id = " + intToStr(this->id);
|
|
||||||
result += " name [" + this->getFullName() + "]";
|
|
||||||
result += " desc: " + this->getDesc();
|
|
||||||
*/
|
|
||||||
result += "id = " + intToStr(this->id);
|
result += "id = " + intToStr(this->id);
|
||||||
if(this->type != NULL) {
|
if(this->type != NULL) {
|
||||||
result += " name [" + this->type->getName() + "]";
|
result += " name [" + this->type->getName() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
result += " hp = " + intToStr(this->hp);
|
result += " hp = " + intToStr(this->hp);
|
||||||
result += " ep = " + intToStr(this->ep);
|
result += " ep = " + intToStr(this->ep);
|
||||||
result += " loadCount = " + intToStr(this->loadCount);
|
result += " loadCount = " + intToStr(this->loadCount);
|
||||||
|
@ -1287,9 +1287,14 @@ std::string Unit::toString() const {
|
||||||
result += " progress2 = " + intToStr(this->progress2);
|
result += " progress2 = " + intToStr(this->progress2);
|
||||||
result += " kills = " + intToStr(this->kills);
|
result += " kills = " + intToStr(this->kills);
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(this->targetRef.getUnit() != NULL) {
|
if(this->targetRef.getUnit() != NULL) {
|
||||||
result += " targetRef = " + this->targetRef.getUnit()->toString();
|
result += " targetRef = " + this->targetRef.getUnit()->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
result += " currField = " + intToStr(this->currField);
|
result += " currField = " + intToStr(this->currField);
|
||||||
result += " targetField = " + intToStr(this->targetField);
|
result += " targetField = " + intToStr(this->targetField);
|
||||||
if(level != NULL) {
|
if(level != NULL) {
|
||||||
|
@ -1306,6 +1311,8 @@ std::string Unit::toString() const {
|
||||||
result += " targetRotation = " + floatToStr(this->targetRotation);
|
result += " targetRotation = " + floatToStr(this->targetRotation);
|
||||||
result += " rotation = " + floatToStr(this->rotation);
|
result += " rotation = " + floatToStr(this->rotation);
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(loadType != NULL) {
|
if(loadType != NULL) {
|
||||||
result += " loadType = " + loadType->getName();
|
result += " loadType = " + loadType->getName();
|
||||||
}
|
}
|
||||||
|
@ -1318,12 +1325,18 @@ std::string Unit::toString() const {
|
||||||
result += " alive = " + intToStr(this->alive);
|
result += " alive = " + intToStr(this->alive);
|
||||||
result += " showUnitParticles = " + intToStr(this->showUnitParticles);
|
result += " showUnitParticles = " + intToStr(this->showUnitParticles);
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
result += " totalUpgrade = " + totalUpgrade.toString();
|
result += " totalUpgrade = " + totalUpgrade.toString();
|
||||||
|
|
||||||
result += " " + unitPath.toString() + "\n";
|
result += " " + unitPath.toString() + "\n";
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
result += "Command count = " + intToStr(commands.size()) + "\n";
|
result += "Command count = " + intToStr(commands.size()) + "\n";
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
int cmdIdx = 0;
|
int cmdIdx = 0;
|
||||||
for(Commands::const_iterator iterList = commands.begin(); iterList != commands.end(); ++iterList) {
|
for(Commands::const_iterator iterList = commands.begin(); iterList != commands.end(); ++iterList) {
|
||||||
result += " index = " + intToStr(cmdIdx) + " ";
|
result += " index = " + intToStr(cmdIdx) + " ";
|
||||||
|
@ -1334,9 +1347,16 @@ std::string Unit::toString() const {
|
||||||
cmdIdx++;
|
cmdIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
result += "allowRotateUnits = " + intToStr(allowRotateUnits) + "\n";
|
result += "allowRotateUnits = " + intToStr(allowRotateUnits) + "\n";
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
result += "modelFacing = " + intToStr(modelFacing.asInt()) + "\n";
|
result += "modelFacing = " + intToStr(modelFacing.asInt()) + "\n";
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
||||||
va_list argList;
|
va_list argList;
|
||||||
va_start(argList, fmt);
|
va_start(argList, fmt);
|
||||||
|
|
||||||
char szBuf[1024]="";
|
char szBuf[4096]="";
|
||||||
vsprintf(szBuf,fmt, argList);
|
vsprintf(szBuf,fmt, argList);
|
||||||
|
|
||||||
// Either output to a logfile or
|
// Either output to a logfile or
|
||||||
|
|
Loading…
Reference in New Issue