From 8c39a1b725fb6f44dfd343013db773e6645188bf Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Tue, 12 Apr 2011 22:20:41 +0000 Subject: [PATCH] now you are "forced" to say "ready" when you are connected :-D --- source/glest_game/facilities/components.cpp | 4 +- source/glest_game/facilities/components.h | 9 +++- source/glest_game/graphics/renderer.cpp | 48 ++++++++++++++++++- .../menu/menu_state_connected_game.cpp | 18 +++++++ 4 files changed, 76 insertions(+), 3 deletions(-) diff --git a/source/glest_game/facilities/components.cpp b/source/glest_game/facilities/components.cpp index a956f78da..111c0932a 100644 --- a/source/glest_game/facilities/components.cpp +++ b/source/glest_game/facilities/components.cpp @@ -290,14 +290,16 @@ bool GraphicButton::mouseMove(int x, int y){ const int GraphicListBox::defH= 22; const int GraphicListBox::defW= 140; -void GraphicListBox::init(int x, int y, int w, int h){ +void GraphicListBox::init(int x, int y, int w, int h, Vec3f textColor){ GraphicComponent::init(x, y, w, h); + this->textColor=textColor; graphButton1.init(x, y, 22, h); graphButton2.init(x+w-22, y, 22, h); graphButton1.setText("<"); graphButton2.setText(">"); selectedItemIndex=-1; + lighted=false; } //queryes diff --git a/source/glest_game/facilities/components.h b/source/glest_game/facilities/components.h index 33da92dd7..3a1f1b88a 100644 --- a/source/glest_game/facilities/components.h +++ b/source/glest_game/facilities/components.h @@ -170,9 +170,11 @@ private: GraphicButton graphButton1, graphButton2; vector items; int selectedItemIndex; + bool lighted; + Vec3f textColor; public: - void init(int x, int y, int w=defW, int h=defH); + void init(int x, int y, int w=defW, int h=defH, Vec3f textColor=Vec3f(1.f, 1.f, 1.f)); int getItemCount() const {return items.size();} string getItem(int index) const {return items[index];} @@ -180,12 +182,17 @@ public: string getSelectedItem() const {return items[selectedItemIndex];} const GraphicButton *getButton1() const {return &graphButton1;} const GraphicButton *getButton2() const {return &graphButton2;} + bool getLighted() const {return lighted;} + void setLighted(bool lighted) {this->lighted= lighted;} + Vec3f getTextColor() const {return textColor;} + void setTextColor(Vec3f color) {this->textColor= color;} void pushBackItem(string item); void setItems(const vector &items); void setSelectedItemIndex(int index, bool errorOnMissing=true); void setSelectedItem(string item, bool errorOnMissing=true); void setEditable(bool editable); + virtual void setY(int y); virtual bool mouseMove(int x, int y); diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index a06a03f1b..9ca84f24c 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -1717,11 +1717,57 @@ void Renderer::renderListBox(const GraphicListBox *listBox) { glEnable(GL_BLEND); GraphicLabel label; - label.init(listBox->getX(), listBox->getY(), listBox->getW(), listBox->getH(), true); + label.init(listBox->getX(), listBox->getY(), listBox->getW(), listBox->getH(), true,listBox->getTextColor()); label.setText(listBox->getText()); label.setFont(listBox->getFont()); renderLabel(&label); + + //lighting + + bool renderLighted= (listBox->getLighted()); + + + if(renderLighted) { + float anim= GraphicComponent::getAnim(); + if(anim>0.5f) anim= 1.f-anim; + + Vec3f color=listBox->getTextColor(); + int x= listBox->getX()+listBox->getButton1()->getW(); + int y= listBox->getY(); + int h= listBox->getH(); + int w= listBox->getW()-listBox->getButton1()->getW()-listBox->getButton2()->getW(); + + const int lightSize= 0; + const Vec4f color1= Vec4f(color.x, color.y, color.z, 0.1f+anim*0.5f); + const Vec4f color2= Vec4f(color.x, color.y, color.z, 0.3f+anim); + + glBegin(GL_TRIANGLE_FAN); + + glColor4fv(color2.ptr()); + glVertex2f(x+w/2, y+h/2); + + glColor4fv(color1.ptr()); + glVertex2f(x-lightSize, y-lightSize); + + glColor4fv(color1.ptr()); + glVertex2f(x+w+lightSize, y-lightSize); + + glColor4fv(color1.ptr()); + glVertex2f(x+w+lightSize, y+h+lightSize); + + glColor4fv(color1.ptr()); + glVertex2f(x+w+lightSize, y+h+lightSize); + + glColor4fv(color1.ptr()); + glVertex2f(x-lightSize, y+h+lightSize); + + glColor4fv(color1.ptr()); + glVertex2f(x-lightSize, y-lightSize); + + glEnd(); + } + glPopAttrib(); } diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 66f4ca365..f60d0e857 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -285,6 +285,8 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM listBoxPlayerStatus.registerGraphicComponent(containerName,"listBoxPlayerStatus"); //listBoxPlayerStatus.init(10, 600, 150); listBoxPlayerStatus.init(525, 180, 125); + listBoxPlayerStatus.setTextColor(Vec3f(1.0f,0.f,0.f)); + listBoxPlayerStatus.setLighted(true); playerStatuses.push_back(lang.get("PlayerStatusSetup")); playerStatuses.push_back(lang.get("PlayerStatusBeRightBack")); playerStatuses.push_back(lang.get("PlayerStatusReady")); @@ -690,6 +692,22 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){ soundRenderer.playFx(coreData.getClickSoundC()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); + if(getNetworkPlayerStatus()==npst_PickSettings) + { + listBoxPlayerStatus.setTextColor(Vec3f(1.0f,0.0f,0.0f)); + listBoxPlayerStatus.setLighted(true); + } + else if(getNetworkPlayerStatus()==npst_BeRightBack) + { + listBoxPlayerStatus.setTextColor(Vec3f(1.0f,1.0f,0.0f)); + listBoxPlayerStatus.setLighted(true); + } + else if(getNetworkPlayerStatus()==npst_Ready) + { + listBoxPlayerStatus.setTextColor(Vec3f(0.0f,1.0f,0.0f)); + listBoxPlayerStatus.setLighted(false); + } + ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface(); if(clientInterface->isConnected()) { clientInterface->setGameSettingsReceived(false);