[Gcblue-commits] gcb_wx/src/graphics tcButton.cpp, 1.25, 1.26 tcPlatformGui.cpp, 1.11, 1.12 tcXmlWi
Status: Alpha
Brought to you by:
ddcforge
From: Dewitt C. <ddc...@us...> - 2006-09-06 01:28:23
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv14752/src/graphics Modified Files: tcButton.cpp tcPlatformGui.cpp tcXmlWindow.cpp Log Message: Index: tcXmlWindow.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcXmlWindow.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcXmlWindow.cpp 27 Mar 2006 01:08:17 -0000 1.9 --- tcXmlWindow.cpp 6 Sep 2006 01:28:20 -0000 1.10 *************** *** 152,155 **** --- 152,171 ---- } + tcButton* tcXmlWindow::GetButtonWithCommand(long command) + { + for (unsigned int n=0; n<children.size(); n++) + { + if (tcButton* button = dynamic_cast<tcButton*>(children[n])) + { + if (button->GetCommand() == command) + { + return button; + } + } + } + + return 0; + } + /** * This allows a window to change the caption of a button based on game state Index: tcButton.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcButton.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** tcButton.cpp 5 Sep 2006 01:04:25 -0000 1.25 --- tcButton.cpp 6 Sep 2006 01:28:20 -0000 1.26 *************** *** 57,61 **** // image based button drawing osg::Texture2D* image = isButtonOn ? onImage.get() : offImage.get(); ! if (isMouseOver) { DrawMouseOverCaption(); --- 57,61 ---- // image based button drawing osg::Texture2D* image = isButtonOn ? onImage.get() : offImage.get(); ! if (isMouseOver && isInteractive) { DrawMouseOverCaption(); *************** *** 89,93 **** textColor.set(0, 0, 0, backgroundAlpha); } ! else if (isMouseOver) { backgroundColor = overColor; --- 89,93 ---- textColor.set(0, 0, 0, backgroundAlpha); } ! else if (isMouseOver && isInteractive) { backgroundColor = overColor; *************** *** 154,157 **** --- 154,159 ---- void tcButton::OnEnterWindow(wxMouseEvent& event) { + if (!isInteractive) return; + isMouseOver = true; *************** *** 168,171 **** --- 170,175 ---- void tcButton::OnLButtonDown(wxMouseEvent& event) { + if (!isInteractive) return; + // send command event wxCommandEvent cmd(wxEVT_COMMAND_BUTTON_CLICKED, command) ; *************** *** 181,184 **** --- 185,190 ---- void tcButton::OnLeaveWindow(wxMouseEvent& event) { + if (!isInteractive) return; + isMouseOver = false; *************** *** 236,239 **** --- 242,251 ---- } + void tcButton::SetInteractive(bool state) + { + isInteractive = state; + } + + void tcButton::SetMouseOverCaption(const std::string& s) *************** *** 259,262 **** --- 271,275 ---- command(-1), isButtonOn(false), + isInteractive(true), isMouseOver(false), soundEffect(""), *************** *** 392,395 **** --- 405,409 ---- command(-1), isButtonOn(false), + isInteractive(true), isMouseOver(false), soundEffect(""), Index: tcPlatformGui.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcPlatformGui.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcPlatformGui.cpp 5 Sep 2006 01:04:25 -0000 1.11 --- tcPlatformGui.cpp 6 Sep 2006 01:28:20 -0000 1.12 *************** *** 43,46 **** --- 43,48 ---- #include "tcStores.h" #include "tcFlightPortGui.h" + #include "tcButton.h" + #include <osg/Geometry> *************** *** 59,77 **** ! ! ! void tcPlatformGui::OnLoadoutCommand(wxCommandEvent& event) { - std::string loadoutType; - switch (event.GetId()) - { - case 10: loadoutType = "Empty"; break; - case 11: loadoutType = "AAW"; break; - case 12: loadoutType = "ASuW"; break; - case 13: loadoutType = "ASW"; break; - case 14: loadoutType = "Strike"; break; - default: loadoutType = "Error"; break; - } - tcPlatformObject* platform = GetPlatform(); tcPlatformObject* host = 0; --- 61,69 ---- ! /** ! * @return first stores that has at least one compatible item with platform launcher (or 0 if none found) ! */ ! tcStores* tcPlatformGui::GetLoadoutStores() { tcPlatformObject* platform = GetPlatform(); tcPlatformObject* host = 0; *************** *** 88,92 **** wxASSERT(platform != 0); wxASSERT(host != 0); ! size_t nStores = host->GetMagazineCount(); for (size_t n=0; n<nStores; n++) --- 80,84 ---- wxASSERT(platform != 0); wxASSERT(host != 0); ! size_t nStores = host->GetMagazineCount(); for (size_t n=0; n<nStores; n++) *************** *** 97,106 **** if (mag->HasStoresForThisObject(platform)) { ! mag->AddAutomationOp(loadoutType, platform); ! return; } } ! fprintf(stderr, "tcPlatformGui::OnLoadoutCommand -- No compatible magazine found\n"); } --- 89,122 ---- if (mag->HasStoresForThisObject(platform)) { ! return mag; } } ! return 0; ! } ! ! void tcPlatformGui::OnLoadoutCommand(wxCommandEvent& event) ! { ! std::string loadoutType; ! switch (event.GetId()) ! { ! case 10: loadoutType = "Empty"; break; ! case 11: loadoutType = "AAW"; break; ! case 12: loadoutType = "ASuW"; break; ! case 13: loadoutType = "ASW"; break; ! case 14: loadoutType = "Strike"; break; ! default: loadoutType = "Error"; break; ! } ! ! tcPlatformObject* platform = GetPlatform(); ! tcStores* mag = GetLoadoutStores(); ! if (mag != 0) ! { ! mag->AddAutomationOp(loadoutType, platform); ! } ! else ! { ! fprintf(stderr, "tcPlatformGui::OnLoadoutCommand -- No compatible magazine found\n"); ! } } *************** *** 165,168 **** --- 181,186 ---- UpdateGui(); + UpdateLoadoutButtons(); + bool blinkOn = tcTime::Get()->Get30HzCount() % 30 < 15; *************** *** 711,714 **** --- 729,782 ---- /** + * For gui mode with auto loadout (air object), update + * the button state to disallow clicking of loadout types that + * are not available for this platform + */ + void tcPlatformGui::UpdateLoadoutButtons() + { + tcPlatformObject* platform = GetPlatform(); + tcAirObject* air = dynamic_cast<tcAirObject*>(platform); + if (air == 0) return; + + tcStores* mag = GetLoadoutStores(); + if (mag == 0) return; + + const osg::Vec4 off_fade(0.5, 0.5, 0.5, 0.5); + const osg::Vec4 over_fade(0.5, 0.5, 0.5, 0.5); + const osg::Vec4 on_fade(0.5, 0.5, 0.5, 0.5); + + const osg::Vec4 off_avail(0, 0, 0, 0.8); + const osg::Vec4 over_avail(0.4, 1.0, 0.4, 0.8); + const osg::Vec4 on_avail(1.0, 1.0, 1.0, 0.8); + + + + const long cmd_list[4] = {11, 12, 13, 14}; + const int tgt_flags[4] = {AIR_TARGET, SURFACE_TARGET, SUBSURFACE_TARGET, LAND_TARGET}; + int availableTargetFlags = mag->GetAvailableTargetFlags(platform); + + for (size_t n=0; n<4; n++) + { + if (tcButton* button = GetButtonWithCommand(cmd_list[n])) + { + bool available = (availableTargetFlags & tgt_flags[n]) != 0; + button->SetInteractive(available); + + if (available) + { + button->SetFillColors(off_avail, over_avail, on_avail); + } + else + { + button->SetFillColors(off_fade, over_fade, on_fade); + } + } + } + + + + } + + /** * */ |