[Gcblue-commits] gcb_wx/src/graphics tcContainerGui.cpp,1.1,1.2 tcPlatformGui.cpp,1.1,1.2 tcStoresGu
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-06-12 20:47:09
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv840/src/graphics Modified Files: tcContainerGui.cpp tcPlatformGui.cpp tcStoresGui.cpp Log Message: Drag and drop icon gui updates Index: tcStoresGui.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcStoresGui.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcStoresGui.cpp 11 Jun 2005 21:01:44 -0000 1.1 --- tcStoresGui.cpp 12 Jun 2005 20:46:58 -0000 1.2 *************** *** 94,98 **** const osg::Vec4 captionColor(1.0f, 1.0f, 1.0f, 1.0f); const char* unitName = parent->mzUnit.mz; ! wxString captionText = wxString::Format("%s Stores", unitName); DrawTextR(captionText.c_str(), 10.0f, 20.0f, defaultFont.get(), captionColor, 18.0f, LEFT_BASE_LINE); --- 94,100 ---- const osg::Vec4 captionColor(1.0f, 1.0f, 1.0f, 1.0f); const char* unitName = parent->mzUnit.mz; ! const std::string& storesDisplayName = stores->GetDisplayName(); ! ! wxString captionText = wxString::Format("%s: %s", unitName, storesDisplayName.c_str()); DrawTextR(captionText.c_str(), 10.0f, 20.0f, defaultFont.get(), captionColor, 18.0f, LEFT_BASE_LINE); Index: tcPlatformGui.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcPlatformGui.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcPlatformGui.cpp 11 Jun 2005 21:01:44 -0000 1.1 --- tcPlatformGui.cpp 12 Jun 2005 20:46:58 -0000 1.2 *************** *** 32,35 **** --- 32,36 ---- #include "tcFlightOpsObject.h" #include "tcDatabaseObject.h" + #include "tcGenericDBObject.h" #include "common/tinyxml.h" #include "tcTime.h" *************** *** 119,124 **** tcContainerSlot& slot = slots[n]; tcContainerItem* item = slot.GetItem(); ! tcStoresContainerItem* storesItem = dynamic_cast<tcStoresContainerItem*>(item); ! bool isMouseOver = slot.IsMouseOver(); --- 120,124 ---- tcContainerSlot& slot = slots[n]; tcContainerItem* item = slot.GetItem(); ! tcLauncherContainerItem* launcherItem = dynamic_cast<tcLauncherContainerItem*>(item); bool isMouseOver = slot.IsMouseOver(); *************** *** 144,157 **** } - // draw caption if mouse is over slot - if (isMouseOver) - { - const osg::Vec4 color(1.0f, 1.0f, 1.0f, 1.0f); - DrawTextR(item->GetItemName().c_str(), slot.loc.GetLeft(), slot.loc.GetTop() + 15.0f, defaultFont.get(), - color, 14.0f, LEFT_BASE_LINE); - - } } // draw expanded rectangle for slot border --- 144,176 ---- } } + + /* draw caption if mouse is over slot + ** If slot has item use item name, otherwise if launcher draw launcher + ** compatibility info + */ + if (isMouseOver) + { + const osg::Vec4 color(1.0f, 1.0f, 1.0f, 1.0f); + wxString caption; + if (item) + { + caption = item->GetItemName().c_str(); + } + else if (n < nLaunchers) + { + GetLauncherCompatibilityCaption(n, caption); + } + else + { + caption = ""; + } + + DrawTextR(caption.c_str(), slot.loc.GetLeft(), slot.loc.GetTop() + 15.0f, defaultFont.get(), + color, 14.0f, LEFT_BASE_LINE); + + + } // draw expanded rectangle for slot border *************** *** 169,172 **** --- 188,215 ---- } + // draw fuel state info under fuel icon if mouse is not over icon + tcContainerSlot& fuelSlot = slots[fuelIdx]; + if (!fuelSlot.IsMouseOver()) + { + float x = fuelSlot.loc.GetLeft(); + float y = fuelSlot.loc.GetTop() + 15.0f; + float fuelCapacity_kg = platform->mpDBObject->mfFuelCapacity_kg; + + wxString caption; + if (fuelCapacity_kg > 0) + { + caption = wxString::Format("Fuel: %.0f / %.0f kg", platform->fuel_kg, + fuelCapacity_kg); + } + else + { + caption = "Fuel: N/A"; + } + const osg::Vec4 color(1.0f, 1.0f, 1.0f, 1.0f); + + DrawTextR(caption.c_str(), x, y, defaultFont.get(), + color, 14.0f, LEFT_BASE_LINE); + } + DrawBorder(); *************** *** 175,178 **** --- 218,240 ---- } + /** + * Creates caption that describes compatible items for launcher + */ + void tcPlatformGui::GetLauncherCompatibilityCaption(unsigned int launcherIdx, wxString& caption) + { + caption = ""; + + tcLauncher* launcher = platform->GetLauncher(launcherIdx); + wxASSERT(launcher); + + unsigned int nTypes = launcher->GetCompatibleCount(); + for (unsigned int n=0; n<nTypes; n++) + { + wxString s = wxString::Format("%s(%d) ", launcher->GetCompatibleName(n).c_str(), + launcher->GetCompatibleQuantity(n)); + caption += s; + } + } + void tcPlatformGui::HandleDrop(size_t slotIdx, tcContainerItem* item) { *************** *** 180,183 **** --- 242,251 ---- if (storesItem == 0) return; // only handle entity items + if (slotIdx == fuelIdx) + { + HandleFuelDrop(storesItem); + return; + } + if (slotIdx >= nLaunchers) return; // only accept drops to launchers *************** *** 191,194 **** --- 259,277 ---- } + void tcPlatformGui::HandleFuelDrop(tcStoresContainerItem* item) + { + wxASSERT(item); + const std::string& itemName = item->GetItemName(); + if (itemName != "Fuel") return; + + tcStores* stores = item->GetStores(); + wxASSERT(stores); + if (stores == 0) return; + + stores->LoadOther(itemName, platform); + + tcSound::Get()->PlayEffect("Thuck"); + } + void tcPlatformGui::InitializeGui() { *************** *** 233,240 **** } // load icons magazineIcon = tc3DWindow::CreateTexturedSymbol("icons\\magazine.jpg", 32.0f); flightPortIcon = tc3DWindow::CreateTexturedSymbol("icons\\flightport.jpg", 32.0f); ! } --- 316,329 ---- } + // add fuel slot for refueling + fuelIdx = nLaunchers + nMagazines + nFlightPorts; + slotLoc.Set(fuelLoc.x, fuelLoc.x + slotSize, + fuelLoc.y, fuelLoc.y + slotSize); + AddSlot(slotLoc); + // load icons magazineIcon = tc3DWindow::CreateTexturedSymbol("icons\\magazine.jpg", 32.0f); flightPortIcon = tc3DWindow::CreateTexturedSymbol("icons\\flightport.jpg", 32.0f); ! fuelIcon = tc3DWindow::CreateTexturedSymbol("icons\\refuel.jpg", 32.0f); } *************** *** 367,370 **** --- 456,462 ---- double flightPortLocX = 0; double flightPortLocY = 0; + + double fuelLocX = 0; + double fuelLocY = 0; elt->Attribute("SlotSize", &slotSizeXml); *************** *** 383,386 **** --- 475,481 ---- elt->Attribute("FlightPortLocY", &flightPortLocY); + elt->Attribute("FuelLocX", &fuelLocX); + elt->Attribute("FuelLocY", &fuelLocY); + slotSize = slotSizeXml; *************** *** 397,400 **** --- 492,498 ---- flightPortLoc.x = flightPortLocX; flightPortLoc.y = flightPortLocY; + + fuelLoc.x = fuelLocX; + fuelLoc.y = fuelLocY; } *************** *** 427,431 **** } ! // update magazine slots (just add item if not added yet) for (size_t n=magazineIdx; n<magazineIdx+nMagazines; n++) { --- 525,529 ---- } ! // update magazine slots (add item if not added yet) for (size_t n=magazineIdx; n<magazineIdx+nMagazines; n++) { *************** *** 435,446 **** if (item == 0) { item = new tcContainerItem(); slot.SetItem(item); item->SetIcon(magazineIcon.get()); } slot.SetUpdated(true); } ! // update flightport slots (just add item if not added yet) for (size_t n=flightPortIdx; n<flightPortIdx+nFlightPorts; n++) { --- 533,547 ---- if (item == 0) { + tcStores* magazine = platform->GetMagazine(n - magazineIdx); + const std::string& magazineName = magazine->GetDisplayName(); item = new tcContainerItem(); slot.SetItem(item); item->SetIcon(magazineIcon.get()); + item->SetItemName(magazineName); } slot.SetUpdated(true); } ! // update flightport slots (add item if not added yet) for (size_t n=flightPortIdx; n<flightPortIdx+nFlightPorts; n++) { *************** *** 453,460 **** slot.SetItem(item); item->SetIcon(flightPortIcon.get()); } slot.SetUpdated(true); } ! --- 554,585 ---- slot.SetItem(item); item->SetIcon(flightPortIcon.get()); + item->SetItemName("Right click to open"); } slot.SetUpdated(true); } ! ! // update refuel slot (add item if not added yet) ! { ! tcContainerSlot& slot = slots[fuelIdx]; ! ! tcContainerItem* item = slot.GetItem(); ! if (item == 0) ! { ! item = new tcContainerItem(); ! slot.SetItem(item); ! item->SetIcon(fuelIcon.get()); ! item->SetItemName("Drag fuel here to refuel"); ! } ! if (platform->IsRefueling()) ! { ! item->SetDrawState(tcContainerItem::BLINK); ! } ! else ! { ! item->SetDrawState(tcContainerItem::NORMAL); ! } ! ! slot.SetUpdated(true); ! } Index: tcContainerGui.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcContainerGui.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcContainerGui.cpp 11 Jun 2005 21:01:44 -0000 1.1 --- tcContainerGui.cpp 12 Jun 2005 20:46:58 -0000 1.2 *************** *** 220,223 **** --- 220,227 ---- } + /** + * @param slotIdx index of slot that is receiving drop + * @param item pointer to dropped item + */ void tcContainerGui::HandleDrop(size_t slotIdx, tcContainerItem* item) { |