new icons for network player state

labels can have a texture now
no more player coloring accroding to network state
This commit is contained in:
Titus Tscharntke 2013-10-27 16:13:27 +00:00
parent 539df3a854
commit 0b2d58f03b
7 changed files with 124 additions and 61 deletions

View File

@ -282,6 +282,7 @@ GraphicLabel::GraphicLabel() {
maxEditWidth = -1;
maxEditRenderWidth = -1;
isPassword = false;
texture = NULL;
}
void GraphicLabel::init(int x, int y, int w, int h, bool centered, Vec3f textColor, bool wordWrap) {

View File

@ -149,6 +149,7 @@ private:
vector<int> textCharLength;
bool isPassword;
Texture2D *texture;
public:
GraphicLabel();
@ -189,6 +190,8 @@ public:
void setMaxEditRenderWidth(int value) { maxEditRenderWidth = value; }
int getMaxEditRenderWidth() const { return maxEditRenderWidth; }
void setTexture(Texture2D *value) { texture = value; }
Texture2D *getTexture() const { return texture; }
};
// ===========================================================

View File

@ -157,6 +157,15 @@ Texture2D *CoreData::getTextureBySystemId(TextureSystemType type) const {
case tsyst_onServerInstalledTexture:
result = onServerInstalledTexture;
break;
case tsyst_statusReadyTexture:
result = statusReadyTexture;
break;
case tsyst_statusNotReadyTexture:
result = statusNotReadyTexture;
break;
case tsyst_statusBRBTexture:
result = statusBRBTexture;
break;
//std::vector<Texture2D *> miscTextureList;
}
@ -207,6 +216,24 @@ void CoreData::load() {
snowTexture->setTextureSystemId(tsyst_snowTexture);
}
statusReadyTexture= renderer.newTexture2D(rsGlobal);
if(statusReadyTexture) {
statusReadyTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/status_ready.png"));
statusReadyTexture->setTextureSystemId(tsyst_statusReadyTexture);
}
statusNotReadyTexture= renderer.newTexture2D(rsGlobal);
if(statusNotReadyTexture) {
statusNotReadyTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/status_notready.png"));
statusNotReadyTexture->setTextureSystemId(tsyst_statusNotReadyTexture);
}
statusBRBTexture= renderer.newTexture2D(rsGlobal);
if(statusBRBTexture) {
statusBRBTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/status_brb.png"));
statusBRBTexture->setTextureSystemId(tsyst_statusBRBTexture);
}
customTexture= renderer.newTexture2D(rsGlobal);
if(customTexture) {
customTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/custom_texture.tga"));

View File

@ -72,6 +72,9 @@ private:
Texture2D *onServerDifferentTexture;
Texture2D *onServerTexture;
Texture2D *onServerInstalledTexture;
Texture2D *statusReadyTexture;
Texture2D *statusNotReadyTexture;
Texture2D *statusBRBTexture;
std::vector<Texture2D *> miscTextureList;
@ -125,7 +128,10 @@ public:
tsyst_notOnServerTexture,
tsyst_onServerDifferentTexture,
tsyst_onServerTexture,
tsyst_onServerInstalledTexture
tsyst_onServerInstalledTexture,
tsyst_statusReadyTexture,
tsyst_statusNotReadyTexture,
tsyst_statusBRBTexture
//std::vector<Texture2D *> miscTextureList;
};
@ -158,6 +164,9 @@ public:
Texture2D *getOnServerDifferentTexture() const {return onServerDifferentTexture;}
Texture2D *getOnServerTexture() const {return onServerTexture;}
Texture2D *getOnServerInstalledTexture() const {return onServerInstalledTexture;}
Texture2D *getStatusReadyTexture() const {return statusReadyTexture;}
Texture2D *getStatusNotReadyTexture() const {return statusNotReadyTexture;}
Texture2D *getStatusBRBTexture() const {return statusBRBTexture;}
Texture2D *getGameWinnerTexture() const {return gameWinnerTexture;}

View File

@ -2886,7 +2886,36 @@ void Renderer::renderLabel(GraphicLabel *label) {
}
}
if(label->getTexture()!=NULL )
{
int x= label->getX();
int y= label->getY();
int h= label->getH();
int w= label->getW();
if(h>0){
//background
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, static_cast<Texture2DGl*>( label->getTexture())->getHandle());
glColor4f(1.0f, 1.0f, 1.0f, 1.0f*label->getFade()) ;
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0.f, 0.f);
glVertex2f(x, y);
glTexCoord2f(0.f, 1.f);
glVertex2f(x, y+h);
glTexCoord2f(1.f, 0.f);
glVertex2f(x+w, y);
glTexCoord2f(1.f, 1.f);
glVertex2f(x+w, y+h);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopAttrib();
}
}
Vec3f labelColor=label->getTextColor();
Vec4f colorWithAlpha = Vec4f(labelColor.x,labelColor.y,labelColor.z,GraphicComponent::getFade());
renderLabel(label,&colorWithAlpha);

View File

@ -298,7 +298,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
xoffset=40;
xoffset=30;
int rowHeight=27;
for(int i=0; i<GameConstants::maxPlayers; ++i){
labelPlayers[i].registerGraphicComponent(containerName,"labelPlayers" + intToStr(i));
@ -308,50 +308,50 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
labelPlayers[i].setEditable(false);
labelPlayerStatus[i].registerGraphicComponent(containerName,"labelPlayerStatus" + intToStr(i));
labelPlayerStatus[i].init(xoffset+12, setupPos-30-i*rowHeight, 60);
labelPlayerStatus[i].init(xoffset+15, setupPos-30-i*rowHeight, 60);
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));
labelPlayerNames[i].init(xoffset+20,setupPos-30-i*rowHeight);
labelPlayerNames[i].init(xoffset+30,setupPos-30-i*rowHeight);
listBoxControls[i].registerGraphicComponent(containerName,"listBoxControls" + intToStr(i));
listBoxControls[i].init(xoffset+160, setupPos-30-i*rowHeight);
listBoxControls[i].init(xoffset+170, setupPos-30-i*rowHeight);
listBoxControls[i].setEditable(false);
listBoxRMultiplier[i].registerGraphicComponent(containerName,"listBoxRMultiplier" + intToStr(i));
listBoxRMultiplier[i].init(xoffset+300, setupPos-30-i*rowHeight,70);
listBoxRMultiplier[i].init(xoffset+310, setupPos-30-i*rowHeight,70);
listBoxRMultiplier[i].setEditable(false);
listBoxFactions[i].registerGraphicComponent(containerName,"listBoxFactions" + intToStr(i));
listBoxFactions[i].init(xoffset+380, setupPos-30-i*rowHeight, 250);
listBoxFactions[i].init(xoffset+390, setupPos-30-i*rowHeight, 250);
listBoxFactions[i].setLeftControlled(true);
listBoxFactions[i].setEditable(false);
listBoxTeams[i].registerGraphicComponent(containerName,"listBoxTeams" + intToStr(i));
listBoxTeams[i].init(xoffset+640, setupPos-30-i*rowHeight, 60);
listBoxTeams[i].init(xoffset+650, setupPos-30-i*rowHeight, 60);
listBoxTeams[i].setEditable(false);
labelNetStatus[i].registerGraphicComponent(containerName,"labelNetStatus" + intToStr(i));
labelNetStatus[i].init(xoffset+705, setupPos-30-i*rowHeight, 60);
labelNetStatus[i].init(xoffset+715, setupPos-30-i*rowHeight, 60);
labelNetStatus[i].setFont(CoreData::getInstance().getDisplayFontSmall());
labelNetStatus[i].setFont3D(CoreData::getInstance().getDisplayFontSmall3D());
grabSlotButton[i].registerGraphicComponent(containerName,"grabSlotButton" + intToStr(i));
grabSlotButton[i].init(xoffset+710, setupPos-30-i*rowHeight, 30);
grabSlotButton[i].init(xoffset+720, setupPos-30-i*rowHeight, 30);
grabSlotButton[i].setText(">");
}
labelControl.registerGraphicComponent(containerName,"labelControl");
labelControl.init(xoffset+160, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelControl.init(xoffset+170, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelControl.setText(lang.get("Control"));
labelRMultiplier.registerGraphicComponent(containerName,"labelRMultiplier");
labelRMultiplier.init(xoffset+300, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelRMultiplier.init(xoffset+310, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelFaction.registerGraphicComponent(containerName,"labelFaction");
labelFaction.init(xoffset+380, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelFaction.init(xoffset+390, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelFaction.setText(lang.get("Faction"));
labelTeam.registerGraphicComponent(containerName,"labelTeam");
labelTeam.init(xoffset+640, setupPos, 60, GraphicListBox::defH, true);
labelTeam.init(xoffset+650, setupPos, 60, GraphicListBox::defH, true);
labelTeam.setText(lang.get("Team"));
labelControl.setFont(CoreData::getInstance().getMenuFontBig());
@ -390,8 +390,11 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
for(int i=0; i<GameConstants::maxPlayers; ++i){
labelPlayerStatus[i].setText("");
labelPlayerStatus[i].setTexture(NULL);
labelPlayerStatus[i].setH(16);
labelPlayerStatus[i].setW(12);
labelPlayers[i].setText(intToStr(i));
labelPlayers[i].setText(intToStr(i+1));
labelPlayerNames[i].setText("");
labelPlayerNames[i].setMaxEditWidth(16);
labelPlayerNames[i].setMaxEditRenderWidth(135);
@ -684,7 +687,7 @@ void MenuStateConnectedGame::reloadUI() {
}
for(int i=0; i < GameConstants::maxPlayers; ++i) {
labelPlayers[i].setText(intToStr(i));
labelPlayers[i].setText(intToStr(i+1));
listBoxControls[i].setItems(controlItems);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
@ -4523,7 +4526,7 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
}
}
labelPlayerStatus[i].setText("");
labelPlayerStatus[i].setTexture(NULL);;
}
if(hasFactions == true && gameSettings != NULL) {
@ -4555,23 +4558,20 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
gameSettings->getFactionControl(i) == ctHuman) {
switch(gameSettings->getNetworkPlayerStatuses(i)) {
case npst_BeRightBack:
labelPlayerStatus[slot].setText("#");
labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.8f, 0.f));
labelPlayerStatus[slot].setTexture(CoreData::getInstance().getStatusBRBTexture());
break;
case npst_Ready:
labelPlayerStatus[slot].setText("#");
labelPlayerStatus[slot].setTextColor(Vec3f(0.f, 1.f, 0.f));
labelPlayerStatus[slot].setTexture(CoreData::getInstance().getStatusReadyTexture());
break;
case npst_PickSettings:
labelPlayerStatus[slot].setText("#");
labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.f, 0.f));
labelPlayerStatus[slot].setTexture(CoreData::getInstance().getStatusNotReadyTexture());
break;
case npst_Disconnected:
labelPlayerStatus[slot].setText(lang.get("-"));
labelPlayerStatus[slot].setTexture(NULL);
break;
default:
labelPlayerStatus[slot].setText("");
labelPlayerStatus[slot].setTexture(NULL);
break;
}
}

View File

@ -469,7 +469,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
checkBoxNetworkPauseGameForLaggedClients.setValue(true);
//list boxes
xoffset=40;
xoffset=30;
int rowHeight=27;
for(int i=0; i<GameConstants::maxPlayers; ++i){
@ -479,52 +479,52 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
labelPlayers[i].setFont3D(CoreData::getInstance().getMenuFontBig3D());
labelPlayerStatus[i].registerGraphicComponent(containerName,"labelPlayerStatus" + intToStr(i));
labelPlayerStatus[i].init(xoffset+12, setupPos-30-i*rowHeight, 60);
labelPlayerStatus[i].init(xoffset+15, setupPos-30-i*rowHeight, 60);
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));
labelPlayerNames[i].init(xoffset+20,setupPos-30-i*rowHeight);
labelPlayerNames[i].init(xoffset+30,setupPos-30-i*rowHeight);
listBoxControls[i].registerGraphicComponent(containerName,"listBoxControls" + intToStr(i));
listBoxControls[i].init(xoffset+160, setupPos-30-i*rowHeight);
listBoxControls[i].init(xoffset+170, setupPos-30-i*rowHeight);
buttonBlockPlayers[i].registerGraphicComponent(containerName,"buttonBlockPlayers" + intToStr(i));
//buttonBlockPlayers[i].init(xoffset+355, setupPos-30-i*rowHeight, 70);
buttonBlockPlayers[i].init(xoffset+200, setupPos-30-i*rowHeight, 70);
buttonBlockPlayers[i].init(xoffset+210, setupPos-30-i*rowHeight, 70);
buttonBlockPlayers[i].setText(lang.get("BlockPlayer"));
buttonBlockPlayers[i].setFont(CoreData::getInstance().getDisplayFontSmall());
buttonBlockPlayers[i].setFont3D(CoreData::getInstance().getDisplayFontSmall3D());
listBoxRMultiplier[i].registerGraphicComponent(containerName,"listBoxRMultiplier" + intToStr(i));
listBoxRMultiplier[i].init(xoffset+300, setupPos-30-i*rowHeight,70);
listBoxRMultiplier[i].init(xoffset+310, setupPos-30-i*rowHeight,70);
listBoxFactions[i].registerGraphicComponent(containerName,"listBoxFactions" + intToStr(i));
listBoxFactions[i].init(xoffset+380, setupPos-30-i*rowHeight, 250);
listBoxFactions[i].init(xoffset+390, setupPos-30-i*rowHeight, 250);
listBoxFactions[i].setLeftControlled(true);
listBoxTeams[i].registerGraphicComponent(containerName,"listBoxTeams" + intToStr(i));
listBoxTeams[i].init(xoffset+640, setupPos-30-i*rowHeight, 60);
listBoxTeams[i].init(xoffset+650, setupPos-30-i*rowHeight, 60);
labelNetStatus[i].registerGraphicComponent(containerName,"labelNetStatus" + intToStr(i));
labelNetStatus[i].init(xoffset+705, setupPos-30-i*rowHeight, 60);
labelNetStatus[i].init(xoffset+715, setupPos-30-i*rowHeight, 60);
labelNetStatus[i].setFont(CoreData::getInstance().getDisplayFontSmall());
labelNetStatus[i].setFont3D(CoreData::getInstance().getDisplayFontSmall3D());
}
buttonClearBlockedPlayers.registerGraphicComponent(containerName,"buttonClearBlockedPlayers");
buttonClearBlockedPlayers.init(xoffset+160, setupPos-30-8*rowHeight, 140);
buttonClearBlockedPlayers.init(xoffset+170, setupPos-30-8*rowHeight, 140);
labelControl.registerGraphicComponent(containerName,"labelControl");
labelControl.init(xoffset+160, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelControl.init(xoffset+170, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelControl.setText(lang.get("Control"));
labelRMultiplier.registerGraphicComponent(containerName,"labelRMultiplier");
labelRMultiplier.init(xoffset+300, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelRMultiplier.init(xoffset+310, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelFaction.registerGraphicComponent(containerName,"labelFaction");
labelFaction.init(xoffset+380, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelFaction.init(xoffset+390, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
labelFaction.setText(lang.get("Faction"));
labelTeam.registerGraphicComponent(containerName,"labelTeam");
labelTeam.init(xoffset+640, setupPos, 50, GraphicListBox::defH, true);
labelTeam.init(xoffset+650, setupPos, 50, GraphicListBox::defH, true);
labelTeam.setText(lang.get("Team"));
labelControl.setFont(CoreData::getInstance().getMenuFontBig());
@ -577,10 +577,13 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
}
for(int i=0; i < GameConstants::maxPlayers; ++i) {
labelPlayerStatus[i].setText("");
labelPlayerStatus[i].setText(" ");
labelPlayerStatus[i].setTexture(CoreData::getInstance().getStatusReadyTexture());
labelPlayerStatus[i].setH(16);
labelPlayerStatus[i].setW(12);
//labelPlayers[i].setText(lang.get("Player")+" "+intToStr(i));
labelPlayers[i].setText(intToStr(i));
labelPlayers[i].setText(intToStr(i+1));
labelPlayerNames[i].setText("*");
labelPlayerNames[i].setMaxEditWidth(16);
labelPlayerNames[i].setMaxEditRenderWidth(135);
@ -799,7 +802,7 @@ void MenuStateCustomGame::reloadUI() {
}
for(int i=0; i < GameConstants::maxPlayers; ++i) {
labelPlayers[i].setText(lang.get("Player")+" "+intToStr(i));
labelPlayers[i].setText(intToStr(i+1));
listBoxControls[i].setItems(controlItems);
}
@ -2335,34 +2338,31 @@ void MenuStateCustomGame::update() {
if(listBoxControls[i].getSelectedItemIndex() == ctHuman) {
switch(gameSettings.getNetworkPlayerStatuses(slotIndex)) {
case npst_BeRightBack:
labelPlayerStatus[i].setText("#");
labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.8f, 0.f));
labelPlayerStatus[i].setTexture(CoreData::getInstance().getStatusBRBTexture());
break;
case npst_Ready:
labelPlayerStatus[i].setText("#");
labelPlayerStatus[i].setTextColor(Vec3f(0.f, 1.f, 0.f));
labelPlayerStatus[i].setTexture(CoreData::getInstance().getStatusReadyTexture());
break;
case npst_PickSettings:
labelPlayerStatus[i].setText("#");
labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.f, 0.f));
labelPlayerStatus[i].setTexture(CoreData::getInstance().getStatusNotReadyTexture());
break;
case npst_Disconnected:
labelPlayerStatus[i].setText("-");
labelPlayerStatus[i].setTexture(NULL);
break;
default:
labelPlayerStatus[i].setText("");
labelPlayerStatus[i].setTexture(NULL);
break;
}
}
else {
labelPlayerStatus[i].setText("");
labelPlayerStatus[i].setTexture(NULL);
}
factionCount++;
}
else {
labelPlayerStatus[i].setText("");
labelPlayerStatus[i].setTexture(NULL);
}
}
@ -2376,20 +2376,14 @@ void MenuStateCustomGame::update() {
if(hasNetworkGameSettings() == true) {
switch(serverInterface->getSlot(i)->getNetworkPlayerStatus()) {
case npst_BeRightBack:
labelPlayerStatus[i].setText("#");
labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.8f, 0.f));
labelPlayerNames[i].setTextColor(Vec3f(1.f, 0.8f, 0.f));
labelPlayerStatus[i].setTexture(CoreData::getInstance().getStatusBRBTexture());
break;
case npst_Ready:
labelPlayerStatus[i].setText("#");
labelPlayerStatus[i].setTextColor(Vec3f(0.f, 1.f, 0.f));
labelPlayerNames[i].setTextColor(Vec3f(0.f, 1.f, 0.f));
labelPlayerStatus[i].setTexture(CoreData::getInstance().getStatusReadyTexture());
break;
case npst_PickSettings:
default:
labelPlayerStatus[i].setText("#");
labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.f, 0.f));
labelPlayerNames[i].setTextColor(Vec3f(1.f, 0.f, 0.f));
labelPlayerStatus[i].setTexture(CoreData::getInstance().getStatusNotReadyTexture());
break;
}
}