[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.132,1.133 tcAirfieldObject.cpp,1.4,1.5 tcFlightPort.cpp,1
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-06-11 21:02:10
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5785/src/sim Modified Files: Game.cpp tcAirfieldObject.cpp tcFlightPort.cpp tcLauncher.cpp tcStores.cpp tcSurfaceObject.cpp Log Message: Initial commit for drag and drop icon gui Index: tcFlightPort.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcFlightPort.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** tcFlightPort.cpp 1 Jun 2005 00:13:32 -0000 1.19 --- tcFlightPort.cpp 11 Jun 2005 21:01:45 -0000 1.20 *************** *** 256,262 **** --- 256,264 ---- short int id; unsigned char op; + unsigned char pos; stream >> id; stream >> op; + stream >> pos; if (op == 0) // launch command *************** *** 268,272 **** bool found = false; size_t obj_count = units.size(); ! for(size_t n=0; (n<obj_count)&&(!found); n++) { tcAirState *airstate = units[n]; --- 270,274 ---- bool found = false; size_t obj_count = units.size(); ! for (size_t n=0; (n<obj_count)&&(!found); n++) { tcAirState *airstate = units[n]; *************** *** 274,278 **** { found = true; ! SetObjectDestination(n, (teLocation)op); } } --- 276,280 ---- { found = true; ! SetObjectDestination(n, (teLocation)op, pos); } } *************** *** 295,298 **** --- 297,301 ---- stream << commandList[n].id; stream << commandList[n].op; + stream << commandList[n].pos; } *************** *** 364,368 **** airstate->current_spot = emptySpotIdx; airstate->goal_location = loc; ! airstate->goal_spot = -1; units.push_back(airstate); // add to fport units vector --- 367,371 ---- airstate->current_spot = emptySpotIdx; airstate->goal_location = loc; ! airstate->goal_spot = airstate->current_spot; units.push_back(airstate); // add to fport units vector *************** *** 470,474 **** last_update_time = 0; } ! //---------------------------------------------------------------------------- /** * Search units vector and return matching index. Return -1 if not found. --- 473,477 ---- last_update_time = 0; } ! /** * Search units vector and return matching index. Return -1 if not found. *************** *** 484,488 **** return -1; // not found } ! //---------------------------------------------------------------------------- /** * Searches loc for empty spot returns spot index if found, --- 487,491 ---- return -1; // not found } ! /** * Searches loc for empty spot returns spot index if found, *************** *** 499,503 **** return -1; } ! //---------------------------------------------------------------------------- /** * Searches for empty spot at loc and returns spot index if found, --- 502,506 ---- return -1; } ! /** * Searches for empty spot at loc and returns spot index if found, *************** *** 512,521 **** return FindEmptySpot(loc_vector); } ! //---------------------------------------------------------------------------- tcAirState* tcFlightPort::GetAirState(unsigned n) { return units[n]; } ! //---------------------------------------------------------------------------- int tcFlightPort::GetAirStateIdx(long id) { --- 515,541 ---- return FindEmptySpot(loc_vector); } ! ! /** ! * Search (linear) units vector for obj ! * @return index with matching obj or -1 if not found. ! */ ! int tcFlightPort::FindAirState(tcGameObject* obj) ! { ! wxASSERT(obj); ! ! size_t nUnits = units.size(); ! for(size_t n=0; n<nUnits; n++) ! { ! tcAirState* airstate_n = units[n]; ! if (airstate_n->obj == obj) return (int)n; ! } ! return -1; // not found ! } ! tcAirState* tcFlightPort::GetAirState(unsigned n) { return units[n]; } ! int tcFlightPort::GetAirStateIdx(long id) { *************** *** 529,532 **** --- 549,557 ---- } + tcFlightportDBObject* tcFlightPort::GetDatabaseObject() const + { + return mpDBObject; + } + /** * @returns game object for unit with index n *************** *** 538,542 **** return units[n]->obj; } ! //---------------------------------------------------------------------------- int tcFlightPort::Launch(int runway) { --- 563,567 ---- return units[n]->obj; } ! int tcFlightPort::Launch(int runway) { *************** *** 564,568 **** return 1; } ! //---------------------------------------------------------------------------- /// Find runway that object with id is on int tcFlightPort::LaunchID(long id) --- 589,593 ---- return 1; } ! /// Find runway that object with id is on int tcFlightPort::LaunchID(long id) *************** *** 590,594 **** return 0; // not found on runway } ! //---------------------------------------------------------------------------- /** * Move object to new location if valid. Remove object from old location. --- 615,619 ---- return 0; // not found on runway } ! /** * Move object to new location if valid. Remove object from old location. *************** *** 638,642 **** return true; } ! //---------------------------------------------------------------------------- /** * @return pointer to tsSpotInfo for current location and spot. --- 663,667 ---- return true; } ! /** * @return pointer to tsSpotInfo for current location and spot. *************** *** 688,692 **** } - //---------------------------------------------------------------------------- /** * @return location vector corresponding to loc, or NULL if loc = HANGAR, TRANSIT, or NOWHERE. --- 713,716 ---- *************** *** 761,764 **** --- 785,809 ---- /** + * Use to check status of specific spot, e.g. runway 1 + * @return true if spot is empty, hangar spot is empty if hangar is not full + */ + bool tcFlightPort::IsSpotEmpty(teLocation loc, unsigned int spot) + { + if (loc == HANGAR) return (inHangarCount < hangarCapacity); + + std::vector<tsSpotInfo>* loc_vector = GetLocVector(loc); + + if ((loc == TRANSIT)||(loc == NOWHERE)) + { + wxASSERT(false); + return false; // error + } + + if (spot >= loc_vector->size()) return false; + + return ((*loc_vector)[spot].obj_info == 0); + } + + /** * Workaround for multiplayer client. * This clears spot info and reassigns units to spots based on the info in airstate *************** *** 797,806 **** } ! //---------------------------------------------------------------------------- ! void tcFlightPort::SetObjectDestination(unsigned n, teLocation loc) { if (n >= (unsigned)units.size()) return; // error, out of range tcAirState* airstate = units.at(n); airstate->goal_location = loc; if (parent->IsClientMode()) --- 842,854 ---- } ! /** ! * ! */ ! void tcFlightPort::SetObjectDestination(unsigned n, teLocation loc, unsigned int position) { if (n >= (unsigned)units.size()) return; // error, out of range tcAirState* airstate = units.at(n); airstate->goal_location = loc; + airstate->goal_spot = position; if (parent->IsClientMode()) *************** *** 809,812 **** --- 857,861 ---- cmd.id = (short int)airstate->obj->mnID; cmd.op = loc; + cmd.pos = position; commandList.push_back(cmd); return; *************** *** 921,928 **** if ((!inTransit)&&(airstate->current_location != airstate->goal_location)) { ! std::vector<tsSpotInfo> *loc_vector = NULL; ! int spot_idx = FindEmptySpot(airstate->goal_location, loc_vector); ! airstate->goal_spot = spot_idx; ! airstate->ready_time = afStatusTime + 30.0f; // short times for test MoveObjectToGoal(airstate); } --- 970,980 ---- if ((!inTransit)&&(airstate->current_location != airstate->goal_location)) { ! if (!IsSpotEmpty(airstate->goal_location, airstate->goal_spot)) ! { ! std::vector<tsSpotInfo> *loc_vector = 0; ! int spot_idx = FindEmptySpot(airstate->goal_location, loc_vector); ! airstate->goal_spot = spot_idx; ! } ! airstate->ready_time = afStatusTime + 30.0f; // short times for test MoveObjectToGoal(airstate); } Index: tcSurfaceObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSurfaceObject.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcSurfaceObject.cpp 29 Apr 2005 18:52:56 -0000 1.18 --- tcSurfaceObject.cpp 11 Jun 2005 21:01:45 -0000 1.19 *************** *** 111,114 **** --- 111,116 ---- UpdateAI(afStatusTime); + UpdateMagazines(afStatusTime); + mfStatusTime = afStatusTime; } Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** tcLauncher.cpp 1 Jun 2005 00:13:32 -0000 1.21 --- tcLauncher.cpp 11 Jun 2005 21:01:45 -0000 1.22 *************** *** 201,207 **** * @return class name of child, or "Empty" if none */ ! std::string tcLauncher::GetChildClassName() const { ! std::string s; if ((mpChildDBObj) && (isLoading || mnCurrent)) { --- 201,207 ---- * @return class name of child, or "Empty" if none */ ! const std::string& tcLauncher::GetChildClassName() const { ! static std::string s; if ((mpChildDBObj) && (isLoading || mnCurrent)) { *************** *** 215,218 **** --- 215,223 ---- } + tcDatabaseObject* tcLauncher::GetChildDatabaseObject() const + { + return mpChildDBObj; + } + /** * This can be a substitute for IsItemCompatible by testing != 0 *************** *** 289,293 **** } ! /** --- 294,301 ---- } ! tcGameObject* tcLauncher::GetParent() const ! { ! return parent; ! } /** *************** *** 372,375 **** --- 380,388 ---- } + bool tcLauncher::IsLoading() const + { + return isLoading; + } + /** * Use to change child class (e.g. while changing loadout via tcStores) Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.132 retrieving revision 1.133 diff -C2 -d -r1.132 -r1.133 *** Game.cpp 1 Jun 2005 00:13:32 -0000 1.132 --- Game.cpp 11 Jun 2005 21:01:45 -0000 1.133 *************** *** 25,31 **** #ifndef WX_PRECOMP #include "wx/wx.h" - #ifdef WIN32 - #include "wx/msw/private.h" // for MS Windows specific definitions - #endif #endif --- 25,28 ---- *************** *** 60,63 **** --- 57,64 ---- #include "tcUserSelectedGroups.h" #include "tcContainerGui.h" + #include "tcFlightPortGui.h" + #include "tcDraggedIconDisplay.h" + #include "tcStoresGui.h" + #include "tcPlatformGui.h" #if defined(_MSC_VER) *************** *** 987,990 **** --- 988,996 ---- popupControl->Raise(); // bring popup to top of windows hierarchy to receive mouse events + + // tcDraggedIconDisplay init + draggedIconDisplay = new tcDraggedIconDisplay(glCanvas); + draggedIconDisplay->SetBaseRenderBin(50); + wxASSERT(tacticalMap); *************** *** 1518,1521 **** --- 1524,1528 ---- worldMap->SetActive(false); tcMessageInterface::Get()->SetPopupChatText(false); + draggedIconDisplay->SetActive(false); } lastMode = meScreenMode; *************** *** 1558,1561 **** --- 1565,1571 ---- tcMessageInterface::Get()->SetPopupChatText(true); } + + draggedIconDisplay->SetActive(true); + draggedIconDisplay->Draw(); } else if (meScreenMode == TACTICALBRIEF) *************** *** 1591,1594 **** --- 1601,1606 ---- tcMessageInterface::Get()->SetPopupChatText(true); } + draggedIconDisplay->SetActive(true); + draggedIconDisplay->Draw(); } else if (meScreenMode == OPTIONS) *************** *** 2450,2458 **** if (s == "ShowFlightPanel") { ! // Freeze() to prevent flicker, not sure why this works ! popupControl->Freeze(); ! popupControl->SetMenu(MENUMODE_FLIGHTPANEL); ! popupControl->Track(wxPoint(mrectMap.left+220,mrectMap.top+70)); } } --- 2462,2494 ---- if (s == "ShowFlightPanel") + { + tcFlightPort* flightPort = tcSimPythonInterface::Get()->GetHookedObjFlightPort(); + if (flightPort) + { + // Freeze() to prevent flicker, not sure why this works + /* + popupControl->Freeze(); + popupControl->SetMenu(MENUMODE_FLIGHTPANEL); + popupControl->Track(wxPoint(mrectMap.left+220,mrectMap.top+70)); + */ + + tcFlightPortGui* gui = new tcFlightPortGui(flightPort, wxPoint(250, 200), "xml/flightport_gui_default.xml"); + } + } + else if (s == "ShowStoresPanel") { ! tcPlatformObject* obj = tcSimPythonInterface::Get()->GetHookedObj(); ! if (tcStores* stores = obj->GetMagazine(0)) ! { ! tcStoresGui* gui = new tcStoresGui(stores, wxPoint(500, 200), "xml/stores_gui_default.xml"); ! } ! } ! else if (s == "ShowPlatformPanel") ! { ! tcPlatformObject* obj = tcSimPythonInterface::Get()->GetHookedObj(); ! if (obj) ! { ! tcPlatformGui* gui = new tcPlatformGui(obj, wxPoint(220, 70), "xml/platform_gui_default.xml"); ! } } } Index: tcStores.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcStores.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcStores.cpp 21 May 2005 02:01:05 -0000 1.3 --- tcStores.cpp 11 Jun 2005 21:01:45 -0000 1.4 *************** *** 26,33 **** --- 26,35 ---- #include "tcLauncher.h" #include "tcMessageInterface.h" + #include "tcGameObject.h" #include "tcPlatformObject.h" #include "tcStoresDBObject.h" #include <iostream> #include "common/tcObjStream.h" + #include "tcDatabase.h" #ifdef _DEBUG *************** *** 35,54 **** #endif tcStores::StoreItem::StoreItem() { } tcStores::StoreItem::StoreItem(const StoreItem& src) ! : className(src.className), ! quantity(src.quantity) { } tcStores::StoreItem::StoreItem(const std::string& name, unsigned int qty) ! : className(name), ! quantity(qty) { } --- 37,78 ---- #endif + tcDatabaseObject* tcStores::StoreItem::GetDatabaseObject() const + { + return databaseObj; + } + /** + * Set pointer to database object associated with + * this item. + */ + void tcStores::StoreItem::LoadDatabaseObject() + { + databaseObj = tcDatabase::Get()->GetObject(className); + + if (databaseObj == 0) + { + fprintf(stderr, "tcStores::StoreItem::LoadDatabaseObject - " + "Can't find %s in database\n", className.c_str()); + wxASSERT(false); + } + } tcStores::StoreItem::StoreItem() + : databaseObj(0) { } tcStores::StoreItem::StoreItem(const StoreItem& src) ! : className(src.className), ! quantity(src.quantity), ! databaseObj(src.databaseObj) { } tcStores::StoreItem::StoreItem(const std::string& name, unsigned int qty) ! : className(name), ! quantity(qty) { + LoadDatabaseObject(); } *************** *** 220,224 **** /** ! * @return current quantity of stores, including future unloads */ unsigned int tcStores::CurrentQuantity() const --- 244,249 ---- /** ! * @return current quantity of stores, not including incoming unloads ! * @see tcStores::IncomingQuantity */ unsigned int tcStores::CurrentQuantity() const *************** *** 230,243 **** } - for (size_t k=0; k<ops.size(); k++) - { - if (ops[k].transferType == StoreOperation::UNLOAD) - { - currentCount += ops[k].quantity; - } - } return currentCount; } /** * Helper method to support operations between tcStores and --- 255,262 ---- } return currentCount; } + /** * Helper method to support operations between tcStores and *************** *** 249,253 **** wxASSERT(parent); ! if (child == 0) { return parent; --- 268,272 ---- wxASSERT(parent); ! if ((child == 0) || (child == parent)) { return parent; *************** *** 264,267 **** --- 283,354 ---- } + tcStoresDBObject* tcStores::GetDatabaseObject() const + { + return storesDBObj; + } + + /** + * Uses linear search + * @return database object for item or 0 if not found + */ + tcDatabaseObject* tcStores::GetDatabaseObjectForItem(const std::string& item) const + { + for (size_t n=0; n<stores.size(); n++) + { + if (stores[n].className == item) + { + return stores[n].GetDatabaseObject(); + } + } + + return 0; + } + + const std::string& tcStores::GetItemName(unsigned int idx) const + { + static std::string errorString = "Error"; + + if (idx >= stores.size()) + { + return errorString; + } + else + { + return stores[idx].className; + } + } + + + + unsigned int tcStores::GetNumberItemTypes() const + { + return stores.size(); + } + + + tcGameObject* tcStores::GetParent() const + { + return parent; + } + + /** + * @return quantity of stores being unloaded into stores + * @see tcStores::CurrentQuantity + */ + unsigned int tcStores::IncomingQuantity() const + { + unsigned currentCount = 0; + + for (size_t k=0; k<ops.size(); k++) + { + if (ops[k].transferType == StoreOperation::UNLOAD) + { + currentCount += ops[k].quantity; + } + } + + return currentCount; + } + /** * *************** *** 290,295 **** { unsigned currentQuantity = CurrentQuantity(); ! return (currentQuantity >= storesDBObj->capacity); } --- 377,383 ---- { unsigned currentQuantity = CurrentQuantity(); + unsigned incomingQuantity = IncomingQuantity(); ! return ((currentQuantity + incomingQuantity) >= storesDBObj->capacity); } *************** *** 532,536 **** if (obj->IsOwnAlliance()) { ! wxString s = wxString::Format("%s (%s) - Unloading %s from %s\n", obj->mzUnit.mz, obj->mzClass.mz, item.c_str(), storesDBObj->displayName.c_str()); --- 620,624 ---- if (obj->IsOwnAlliance()) { ! wxString s = wxString::Format("%s (%s) - Unloading %s to %s\n", obj->mzUnit.mz, obj->mzClass.mz, item.c_str(), storesDBObj->displayName.c_str()); Index: tcAirfieldObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirfieldObject.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcAirfieldObject.cpp 29 Apr 2005 18:52:55 -0000 1.4 --- tcAirfieldObject.cpp 11 Jun 2005 21:01:45 -0000 1.5 *************** *** 220,223 **** --- 220,225 ---- UpdateSensors(afStatusTime); + UpdateMagazines(afStatusTime); + mfStatusTime = afStatusTime; } |