- just for you james! Fixed about screen text alignment
- re-enabled unit titles in special debug mode (requires special keys to toggle)
This commit is contained in:
parent
89b1431882
commit
41ae17757b
|
@ -117,6 +117,7 @@ public:
|
|||
|
||||
static const char *playerTextureCacheLookupKey;
|
||||
static const char *factionPreviewTextureCacheLookupKey;
|
||||
static const char *characterMenuScreenPositionListCacheLookupKey;
|
||||
static const char *pathCacheLookupKey;
|
||||
static const char *path_data_CacheLookupKey;
|
||||
static const char *path_ini_CacheLookupKey;
|
||||
|
|
|
@ -52,8 +52,10 @@ const char *GameConstants::RANDOMFACTION_SLOTNAME = "*Random*";
|
|||
|
||||
const char *GameConstants::playerTextureCacheLookupKey = "playerTextureCache";
|
||||
const char *GameConstants::factionPreviewTextureCacheLookupKey = "factionPreviewTextureCache";
|
||||
const char *GameConstants::characterMenuScreenPositionListCacheLookupKey = "characterMenuScreenPositionListCache";
|
||||
const char *GameConstants::application_name = "MegaGlest";
|
||||
|
||||
|
||||
const char *GameConstants::pathCacheLookupKey = "pathCache_";
|
||||
const char *GameConstants::path_data_CacheLookupKey = "data";
|
||||
const char *GameConstants::path_ini_CacheLookupKey = "ini";
|
||||
|
|
|
@ -3970,18 +3970,14 @@ void Renderer::renderUnits(const int renderFps) {
|
|||
|
||||
glPopMatrix();
|
||||
unit->setVisible(true);
|
||||
|
||||
if( showDebugUI == true &&
|
||||
(showDebugUILevel & debugui_unit_titles) == debugui_unit_titles) {
|
||||
//unit->setScreenPos(computeScreenPosition(unit->getCurrVectorFlat()));
|
||||
unit->setScreenPos(computeScreenPosition(unit->getCurrVector()));
|
||||
|
||||
unit->setScreenPos(computeScreenPosition(currVec));
|
||||
visibleFrameUnitList.push_back(unit);
|
||||
visibleFrameUnitListCameraKey = game->getGameCamera()->getCameraMovementKey();
|
||||
}
|
||||
|
||||
//if(allowRenderUnitTitles == true) {
|
||||
// Add to the pending render unit title list
|
||||
//renderUnitTitleList.push_back(std::pair<Unit *,Vec3f>(unit,computeScreenPosition(unit->getCurrVectorFlat())) );
|
||||
//}
|
||||
}
|
||||
|
||||
if(modelRenderStarted == true) {
|
||||
|
@ -4851,7 +4847,6 @@ void Renderer::renderDisplay() {
|
|||
}
|
||||
|
||||
void Renderer::renderMenuBackground(const MenuBackground *menuBackground) {
|
||||
|
||||
assertGl();
|
||||
|
||||
const Vec3f &cameraPosition= menuBackground->getCamera()->getConstPosition();
|
||||
|
@ -4893,15 +4888,43 @@ void Renderer::renderMenuBackground(const MenuBackground *menuBackground) {
|
|||
glAlphaFunc(GL_GREATER, 0.0f);
|
||||
float alpha= clamp((minDist-dist) / minDist, 0.f, 1.f);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Vec4f(1.0f, 1.0f, 1.0f, alpha).ptr());
|
||||
|
||||
std::vector<Vec3f> &characterMenuScreenPositionListCache =
|
||||
CacheManager::getCachedItem< std::vector<Vec3f> >(GameConstants::characterMenuScreenPositionListCacheLookupKey);
|
||||
characterMenuScreenPositionListCache.clear();
|
||||
|
||||
modelRenderer->begin(true, true, false);
|
||||
|
||||
for(int i=0; i < MenuBackground::characterCount; ++i) {
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslatef(i*2.f-4.f, -1.4f, -7.5f);
|
||||
|
||||
Vec3f worldPos(i*2.f-4.f, -1.4f, -7.5f);
|
||||
glTranslatef(worldPos.x,worldPos.y,worldPos.z);
|
||||
|
||||
//
|
||||
// Get the screen coordinates for each character model - START
|
||||
std::vector<GLdouble> projection(16);
|
||||
std::vector<GLdouble> modelview(16);
|
||||
std::vector<GLdouble> screen_coords(3);
|
||||
|
||||
glGetDoublev(GL_PROJECTION_MATRIX, projection.data());
|
||||
glGetDoublev(GL_MODELVIEW_MATRIX, modelview.data());
|
||||
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
GLint viewport[]= {0, 0, metrics.getVirtualW(), metrics.getVirtualH()};
|
||||
|
||||
gluProject(worldPos.x, worldPos.y, worldPos.z,
|
||||
modelview.data(), projection.data(), viewport,
|
||||
screen_coords.data(), screen_coords.data() + 1, screen_coords.data() + 2);
|
||||
characterMenuScreenPositionListCache.push_back(Vec3f(screen_coords[0],screen_coords[1],screen_coords[2]));
|
||||
// Get the screen coordinates for each character model - END
|
||||
//
|
||||
|
||||
menuBackground->getCharacterModelPtr(i)->updateInterpolationData(menuBackground->getAnim(), true);
|
||||
modelRenderer->render(menuBackground->getCharacterModelPtr(i));
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
modelRenderer->end();
|
||||
|
@ -7149,6 +7172,8 @@ Texture2D * Renderer::findFactionLogoTexture(string logoFilename) {
|
|||
}
|
||||
|
||||
void Renderer::cycleShowDebugUILevel() {
|
||||
//printf("#1 showDebugUILevel = %d, debugui_fps = %d, debugui_unit_titles = %d\n",showDebugUILevel,debugui_fps,debugui_unit_titles);
|
||||
|
||||
if((showDebugUILevel & debugui_fps) != debugui_fps ||
|
||||
(showDebugUILevel & debugui_unit_titles) != debugui_unit_titles) {
|
||||
showDebugUILevel |= debugui_fps;
|
||||
|
@ -7157,6 +7182,8 @@ void Renderer::cycleShowDebugUILevel() {
|
|||
else {
|
||||
showDebugUILevel = debugui_fps;
|
||||
}
|
||||
|
||||
//printf("#2 showDebugUILevel = %d, debugui_fps = %d, debugui_unit_titles = %d\n",showDebugUILevel,debugui_fps,debugui_unit_titles);
|
||||
}
|
||||
|
||||
void Renderer::renderFPSWhenEnabled(int lastFps) {
|
||||
|
|
|
@ -997,6 +997,7 @@ void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
|
|||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
//if(key == configKeys.getCharKey("HotKeyShowDebug")) {
|
||||
if(isKeyPressed(configKeys.getSDLKey("HotKeyShowDebug"),key) == true) {
|
||||
//printf("debug key pressed keystate.mod = %d [%d]\n",keystate.mod,keystate.mod & (KMOD_LALT | KMOD_RALT));
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
//if(keystate.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
|
||||
|
@ -3235,6 +3236,7 @@ int glestMain(int argc, char** argv) {
|
|||
renderer.setAllowRenderUnitTitles(SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"In [%s::%s Line: %d] renderer.setAllowRenderUnitTitles = %d\n",__FILE__,__FUNCTION__,__LINE__,SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled);
|
||||
}
|
||||
renderer.setAllowRenderUnitTitles(true);
|
||||
|
||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == true) {
|
||||
//Renderer &renderer= Renderer::getInstance();
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include "config.h"
|
||||
#include "menu_state_options.h"
|
||||
#include <iostream>
|
||||
#include "metrics.h"
|
||||
#include "cache_manager.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
|
@ -31,11 +33,13 @@ namespace Game {
|
|||
// =====================================================
|
||||
|
||||
MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu) :
|
||||
MenuState(program, mainMenu, "about"){
|
||||
MenuState(program, mainMenu, "about") {
|
||||
|
||||
containerName= "About";
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
adjustModelText = true;
|
||||
|
||||
string additionalCredits= loadAdditionalCredits();
|
||||
|
||||
//init
|
||||
|
@ -48,50 +52,49 @@ MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu) :
|
|||
labelAdditionalCredits.setText(additionalCredits);
|
||||
|
||||
if(additionalCredits == "") {
|
||||
for(int i= 0; i < aboutStringCount1; ++i){
|
||||
for(int i= 0; i < aboutStringCount1; ++i) {
|
||||
labelAbout1[i].registerGraphicComponent(containerName, "labelAbout1" + intToStr(i));
|
||||
labelAbout1[i].init(100, 700 - i * 20);
|
||||
labelAbout1[i].setText(getAboutString1(i));
|
||||
}
|
||||
|
||||
for(int i= 0; i < aboutStringCount2; ++i){
|
||||
for(int i= 0; i < aboutStringCount2; ++i) {
|
||||
labelAbout2[i].registerGraphicComponent(containerName, "labelAbout2" + intToStr(i));
|
||||
labelAbout2[i].init(450, 620 - i * 20);
|
||||
labelAbout2[i].setText(getAboutString2(i));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(int i= 0; i < aboutStringCount1; ++i){
|
||||
for(int i= 0; i < aboutStringCount1; ++i) {
|
||||
labelAbout1[i].registerGraphicComponent(containerName, "labelAbout1" + intToStr(i));
|
||||
labelAbout1[i].init(100, 700 - i * 20);
|
||||
labelAbout1[i].setText(getAboutString1(i));
|
||||
}
|
||||
|
||||
for(int i= 0; i < aboutStringCount2; ++i){
|
||||
for(int i= 0; i < aboutStringCount2; ++i) {
|
||||
labelAbout2[i].registerGraphicComponent(containerName, "labelAbout2" + intToStr(i));
|
||||
labelAbout2[i].init(100, 620 - i * 20);
|
||||
labelAbout2[i].setText(getAboutString2(i));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i= 0; i < teammateCount; ++i){
|
||||
for(int i= 0; i < teammateCount; ++i) {
|
||||
int xPos = (182 + i * 138);
|
||||
labelTeammateName[i].registerGraphicComponent(containerName, "labelTeammateName" + intToStr(i));
|
||||
labelTeammateName[i].init(100 + i * 180, 500);
|
||||
labelTeammateName[i].init(xPos, 500);
|
||||
labelTeammateRole[i].registerGraphicComponent(containerName, "labelTeammateRole" + intToStr(i));
|
||||
labelTeammateRole[i].init(100 + i * 180, 520);
|
||||
labelTeammateRole[i].init(xPos, 520);
|
||||
|
||||
labelTeammateName[i].setText(getTeammateName(i));
|
||||
labelTeammateRole[i].setText(getTeammateRole(i));
|
||||
}
|
||||
|
||||
labelTeammateName[5].init(100, 160);
|
||||
labelTeammateRole[5].init(100, 180);
|
||||
labelTeammateName[6].init(333, 160);
|
||||
labelTeammateRole[6].init(333, 180);
|
||||
labelTeammateName[7].init(566, 160);
|
||||
labelTeammateRole[7].init(566, 180);
|
||||
labelTeammateName[8].init(800, 160);
|
||||
labelTeammateRole[8].init(800, 180);
|
||||
for(int i = teammateTopLineCount; i < teammateCount; ++i) {
|
||||
labelTeammateName[i].init(202 + (i-5) * 138, 160);
|
||||
labelTeammateRole[i].init(202 + (i-5) * 138, 180);
|
||||
}
|
||||
labelTeammateName[8].init(labelTeammateName[4].getX(), 160);
|
||||
labelTeammateRole[8].init(labelTeammateRole[4].getX(), 180);
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
}
|
||||
|
@ -99,6 +102,7 @@ MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu) :
|
|||
void MenuStateAbout::reloadUI() {
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
adjustModelText = true;
|
||||
string additionalCredits= loadAdditionalCredits();
|
||||
|
||||
buttonReturn.setText(lang.get("Return"));
|
||||
|
@ -123,7 +127,7 @@ void MenuStateAbout::reloadUI() {
|
|||
}
|
||||
}
|
||||
|
||||
for(int i= 0; i < teammateCount; ++i){
|
||||
for(int i= 0; i < teammateCount; ++i) {
|
||||
labelTeammateName[i].setText(getTeammateName(i));
|
||||
labelTeammateRole[i].setText(getTeammateRole(i));
|
||||
}
|
||||
|
@ -175,18 +179,57 @@ void MenuStateAbout::mouseMove(int x, int y, const MouseState *ms){
|
|||
buttonReturn.mouseMove(x, y);
|
||||
}
|
||||
|
||||
void MenuStateAbout::render(){
|
||||
void MenuStateAbout::render() {
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
renderer.renderLabel(&labelAdditionalCredits);
|
||||
renderer.renderButton(&buttonReturn);
|
||||
for(int i= 0; i < aboutStringCount1; ++i){
|
||||
|
||||
for(int i= 0; i < aboutStringCount1; ++i) {
|
||||
renderer.renderLabel(&labelAbout1[i]);
|
||||
}
|
||||
for(int i= 0; i < aboutStringCount2; ++i){
|
||||
for(int i= 0; i < aboutStringCount2; ++i) {
|
||||
renderer.renderLabel(&labelAbout2[i]);
|
||||
}
|
||||
for(int i= 0; i < teammateCount; ++i){
|
||||
|
||||
if(adjustModelText == true) {
|
||||
std::vector<Vec3f> &characterMenuScreenPositionListCache =
|
||||
CacheManager::getCachedItem< std::vector<Vec3f> >(GameConstants::characterMenuScreenPositionListCacheLookupKey);
|
||||
|
||||
for(int i= 0; i < teammateCount; ++i) {
|
||||
int characterPos = (i % teammateTopLineCount);
|
||||
if(characterPos < characterMenuScreenPositionListCache.size()) {
|
||||
adjustModelText = false;
|
||||
|
||||
int xPos = characterMenuScreenPositionListCache[characterPos].x;
|
||||
if(i == 7 && characterPos+1 < characterMenuScreenPositionListCache.size()) {
|
||||
xPos += ((characterMenuScreenPositionListCache[characterPos+1].x - characterMenuScreenPositionListCache[characterPos].x) / 2);
|
||||
}
|
||||
else if(i == 8 && characterPos+1 < characterMenuScreenPositionListCache.size()) {
|
||||
xPos = characterMenuScreenPositionListCache[characterPos+1].x;
|
||||
}
|
||||
|
||||
FontMetrics *fontMetrics= NULL;
|
||||
if(Renderer::renderText3DEnabled == false) {
|
||||
fontMetrics= labelTeammateName[i].getFont()->getMetrics();
|
||||
}
|
||||
else {
|
||||
fontMetrics= labelTeammateName[i].getFont3D()->getMetrics();
|
||||
}
|
||||
int newxPos = xPos - (fontMetrics->getTextWidth(labelTeammateName[i].getText()) / 2);
|
||||
if(newxPos != labelTeammateName[i].getX()) {
|
||||
labelTeammateName[i].init(newxPos, labelTeammateName[i].getY());
|
||||
}
|
||||
|
||||
newxPos = xPos - (fontMetrics->getTextWidth(labelTeammateRole[i].getText()) / 2);
|
||||
if(newxPos != labelTeammateRole[i].getX()) {
|
||||
labelTeammateRole[i].init(newxPos, labelTeammateRole[i].getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i= 0; i < teammateCount; ++i) {
|
||||
renderer.renderLabel(&labelTeammateName[i]);
|
||||
renderer.renderLabel(&labelTeammateRole[i]);
|
||||
}
|
||||
|
@ -198,11 +241,8 @@ void MenuStateAbout::render(){
|
|||
|
||||
void MenuStateAbout::keyDown(SDL_KeyboardEvent key){
|
||||
Config &configKeys= Config::getInstance(std::pair<ConfigType, ConfigType>(cfgMainKeys, cfgUserKeys));
|
||||
//if(key == configKeys.getCharKey("SaveGUILayout")){
|
||||
if(isKeyPressed(configKeys.getSDLKey("SaveGUILayout"),key) == true) {
|
||||
GraphicComponent::saveAllCustomProperties(containerName);
|
||||
//Lang &lang= Lang::getInstance();
|
||||
//console.addLine(lang.get("GUILayoutSaved") + " [" + (saved ? lang.get("Yes") : lang.get("No"))+ "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
static const int aboutStringCount1= 3;
|
||||
static const int aboutStringCount2= 3;
|
||||
static const int teammateCount= 9;
|
||||
static const int teammateTopLineCount= 5;
|
||||
|
||||
private:
|
||||
GraphicButton buttonReturn;
|
||||
|
@ -35,6 +36,7 @@ private:
|
|||
GraphicLabel labelTeammateName[teammateCount];
|
||||
GraphicLabel labelTeammateRole[teammateCount];
|
||||
|
||||
bool adjustModelText;
|
||||
string loadAdditionalCredits();
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue