Thread: [Gcblue-commits] gcb_wx/src/sim Game.cpp,1.154,1.155 tcGameObject.cpp,1.43,1.44 tcSimState.cpp,1.96,
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2006-04-21 23:29:14
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8677/src/sim Modified Files: Game.cpp tcGameObject.cpp tcSimState.cpp Log Message: Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** tcSimState.cpp 26 Mar 2006 00:32:15 -0000 1.96 --- tcSimState.cpp 21 Apr 2006 23:29:10 -0000 1.97 *************** *** 1913,1916 **** --- 1913,1955 ---- /** + * Call when adding child object, e.g. aircraft to flightdeck. + * This allows child object to be looked up by name (but not id) during scenario creation + */ + void tcSimState::RegisterChildObject(const std::string& name, tcGameObject* parent) + { + wxASSERT(parent != 0); + + std::map<std::string, long>::iterator iter = + captiveObjectMap.find(name); + if (iter != captiveObjectMap.end()) + { + wxASSERT(false); + fprintf(stderr, "RegisterChildObject - %s already exists in captiveObjectMap\n", + name.c_str()); + return; + } + + captiveObjectMap[name] = parent->mnID; + } + + /** + * Call when removing child object, e.g. launching aircraft from flightdeck + */ + void tcSimState::UnregisterChildObject(const std::string& name) + { + std::map<std::string, long>::iterator iter = + captiveObjectMap.find(name); + if (iter == captiveObjectMap.end()) + { + wxASSERT(false); + fprintf(stderr, "UnregisterChildObject - %s does not exist in captiveObjectMap\n", + name.c_str()); + return; + } + + captiveObjectMap.erase(iter); + } + + /** * */ *************** *** 2167,2171 **** /** ! * @return game object matching unitName or NULL if not found. */ tcGameObject* tcSimState::GetObjectByName(const std::string& unitName) --- 2206,2210 ---- /** ! * @return game object matching unitName or 0 if not found. */ tcGameObject* tcSimState::GetObjectByName(const std::string& unitName) *************** *** 2173,2204 **** // first try to lookup in map std::map<std::string, long>::iterator iter = objectNameMap.find(unitName); ! if (iter == objectNameMap.end()) return 0; ! ! if (tcGameObject *obj = GetObject(iter->second)) ! { ! return obj; ! } ! else // object doesnt exist, clear map entry { ! objectNameMap.erase(iter); ! return 0; } ! ! /* ! tnPoolIndex pos = maPlatformState.GetStartPosition(); ! tnPoolIndex nSize = maPlatformState.GetCount(); ! tnPoolIndex nKey; ! ! for (int i=0;i<nSize;i++) { ! maPlatformState.GetNextAssoc(pos,nKey,obj); ! wxASSERT(obj); ! if (unitName == obj->mzUnit.mz) { ! return obj; } } ! return NULL; ! */ } --- 2212,2251 ---- // first try to lookup in map std::map<std::string, long>::iterator iter = objectNameMap.find(unitName); ! if (iter != objectNameMap.end()) { ! if (tcGameObject *obj = GetObject(iter->second)) ! { ! return obj; ! } ! else // object doesnt exist any more, clear map entry ! { ! wxASSERT(false); ! objectNameMap.erase(iter); ! return 0; ! } } ! else // check captiveObjectMap to see if this is a flightdeck object { ! std::map<std::string, long>::iterator iter = captiveObjectMap.find(unitName); ! if (iter != captiveObjectMap.end()) { ! tcGameObject* parent = GetObject(iter->second); ! if (parent != 0) ! { ! return parent->GetChildByName(unitName); ! } ! else ! { ! wxASSERT(false); ! captiveObjectMap.erase(iter); ! return 0; ! } ! } ! else ! { ! return 0; } } ! } *************** *** 2823,2826 **** --- 2870,2874 ---- objectNameMap.clear(); + captiveObjectMap.clear(); } Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** tcGameObject.cpp 26 Mar 2006 00:32:15 -0000 1.43 --- tcGameObject.cpp 21 Apr 2006 23:29:10 -0000 1.44 *************** *** 118,122 **** * */ ! void tcGameObject::ClearChildren(void) { { --- 118,122 ---- * */ ! void tcGameObject::ClearChildren() { { *************** *** 124,131 **** for (size_t i=0;i<child_count;i++) { ! tcGameObject *pGameObj = children.at(i); ! if (pGameObj != NULL) { ! delete pGameObj; } } --- 124,132 ---- for (size_t i=0;i<child_count;i++) { ! tcGameObject* child = children.at(i); ! if (child != 0) { ! simState->UnregisterChildObject(child->GetName()); ! delete child; } } *************** *** 136,143 **** for (size_t i=0;i<launch_count;i++) { ! tcGameObject *pGameObj = toLaunch.at(i); ! if (pGameObj != NULL) { ! delete pGameObj; } } --- 137,144 ---- for (size_t i=0;i<launch_count;i++) { ! tcGameObject* gameObj = toLaunch.at(i); ! if (gameObj != 0) { ! delete gameObj; } } *************** *** 436,439 **** --- 437,442 ---- child->parent = this; children.push_back(child); + + simState->RegisterChildObject(child->GetName(), this); } *************** *** 456,459 **** --- 459,502 ---- /** + * Linear search for child with matching name + */ + tcGameObject* tcGameObject::GetChildByName(const std::string& name) const + { + size_t nChildren = children.size(); + for (size_t n=0; n<nChildren; n++) + { + if (name == children[n]->mzUnit.mz) + { + return children[n]; + } + } + + return 0; + } + + + tcGameObject* tcGameObject::GetChild(size_t idx) + { + if (idx < children.size()) + { + return children[idx]; + } + else + { + return 0; + } + } + + const char* tcGameObject::GetName() const + { + return mzUnit.mz; + } + + size_t tcGameObject::GetNumberOfChildren() const + { + return children.size(); + } + + /** * Linear search to verify child */ *************** *** 484,487 **** --- 527,532 ---- children[n] = children.back(); children.pop_back(); + + simState->UnregisterChildObject(child->GetName()); return; } Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.154 retrieving revision 1.155 diff -C2 -d -r1.154 -r1.155 *** Game.cpp 28 Mar 2006 23:58:12 -0000 1.154 --- Game.cpp 21 Apr 2006 23:29:09 -0000 1.155 *************** *** 49,52 **** --- 49,53 ---- #include "tcMessageCenter.h" #include "tcMessageInterface.h" + #include "tcMPGameView.h" #include "tcNetworkView.h" #include "tcDisplaySettingsView.h" *************** *** 96,99 **** --- 97,101 ---- EVT_COMMAND(ID_OPTIONSVIEW, wxEVT_COMMAND_BUTTON_CLICKED , tcGame::SwitchToOptions) EVT_COMMAND(ID_SCENARIOSELECTVIEW, wxEVT_COMMAND_BUTTON_CLICKED , tcGame::SwitchToScenarioSelect) + EVT_COMMAND(ID_MPGAMEVIEW, wxEVT_COMMAND_BUTTON_CLICKED , tcGame::SwitchToMPGameView) EVT_COMMAND(ID_MULTIPLAYERVIEW, wxEVT_COMMAND_BUTTON_CLICKED , tcGame::SwitchToNetwork) EVT_COMMAND(ID_BRIEFINGVIEW, wxEVT_COMMAND_BUTTON_CLICKED , tcGame::SwitchToBriefing) *************** *** 258,261 **** --- 260,264 ---- worldMap->SetActive(false); gameWindow->SetActive(false); + databaseViewer->SetActive(false); briefingView->SetButtonCaption(ID_STARTVIEW, "Return"); *************** *** 418,421 **** --- 421,429 ---- } + void tcGame::SwitchToMPGameView(wxCommandEvent& event) + { + meScreenMode = MPGAME; + } + void tcGame::SwitchToNetwork(wxCommandEvent& event) { *************** *** 548,551 **** --- 556,561 ---- InitializeNetworkView(); + InitializeMultiplayerGameSetup(); + InitializeMessageCenter(); *************** *** 789,792 **** --- 799,807 ---- } + void tcGame::InitializeMultiplayerGameSetup() + { + multiplayerGameSetup = new tcMPGameView(glCanvas, wxPoint(0,0), frameSize, "MPGameView"); + } + /** * Initialize network view interface *************** *** 1495,1498 **** --- 1510,1514 ---- messageCenter->SetActive(false); networkView->SetActive(false); + multiplayerGameSetup->SetActive(false); chatBox->SetActive(false); briefingView->SetActive(false); *************** *** 1506,1509 **** --- 1522,1526 ---- startView->SetActive(true); startView->Draw(); + viewer->SetActive(true); break; case CREDIT: *************** *** 1514,1521 **** --- 1531,1540 ---- creditView->SetActive(true); creditView->Draw(); + viewer->SetActive(false); break; case DATABASEVIEW: databaseViewer->SetActive(true); databaseViewer->Draw(); + viewer->SetActive(true); viewer->SetDatabaseView(true); if (lastMode != DATABASEVIEW) *************** *** 1523,1526 **** --- 1542,1547 ---- size3D = MODE3D_DATABASE; Update3DSize(); + /// reselect display class to update camera range + databaseViewer->SelectDisplayClass(databaseViewer->GetDisplayClass()); } break; *************** *** 1528,1547 **** --- 1549,1578 ---- optionsView->SetActive(true); optionsView->Draw(); + viewer->SetActive(false); break; case DISPLAYSETTINGS: displaySettingsView->SetActive(true); displaySettingsView->Draw(); + viewer->SetActive(false); break; case SCENARIOSELECT: scenarioSelectView->SetActive(true); scenarioSelectView->Draw(); + viewer->SetActive(true); break; case NETWORK: networkView->SetActive(true); networkView->Draw(); + viewer->SetActive(false); break; + case MPGAME: + multiplayerGameSetup->SetActive(true); + multiplayerGameSetup->Draw(); + viewer->SetActive(false); + break; case SIMPLEBRIEF: briefingView->SetActive(true); briefingView->Draw(); + viewer->SetActive(false); break; } *************** *** 1553,1557 **** } - viewer->SetActive(true); static float cameraTime = 0; --- 1584,1587 ---- *************** *** 1563,1568 **** } ! viewer->SetCameraAz(cameraTime); ! viewer->SetCameraEl(0.5f * sinf(0.1f*cameraTime)); if (meScreenMode != DATABASEVIEW) --- 1593,1601 ---- } ! //viewer->SetCameraAz(cameraTime); ! //viewer->SetCameraEl(0.5f * sinf(0.1f*cameraTime)); ! ! viewer->SetCameraSpinRate(0.01f); ! if (meScreenMode != DATABASEVIEW) *************** *** 1662,1665 **** --- 1695,1699 ---- viewer->SetActive(false); viewer->SetDatabaseView(false); + viewer->SetCameraSpinRate(0); worldMap->SetActive(false); tcMessageInterface::Get()->SetPopupChatText(false); *************** *** 1667,1671 **** gameWindow->SetActive(false); } - lastMode = meScreenMode; --- 1701,1704 ---- *************** *** 1782,1785 **** --- 1815,1826 ---- viewer->SetDatabaseView(true); viewer->SetActive(true); + if (lastMode != DATABASEVIEW) + { + size3D = MODE3D_DATABASE; + Update3DSize(); + viewer->SetCameraSpinRate(0.01f); + /// reselect display class to update camera range + databaseViewer->SelectDisplayClass(databaseViewer->GetDisplayClass()); + } } else if (meScreenMode == DISPLAYSETTINGS) *************** *** 1788,1791 **** --- 1829,1840 ---- displaySettingsView->Draw(); } + + if ((lastMode == DATABASEVIEW) && (meScreenMode != DATABASEVIEW)) + { + size3D = MODE3D_SMALL; + Update3DSize(); + } + + lastMode = meScreenMode; } *************** *** 2802,2825 **** * */ ! tcGame::tcGame(const wxPoint& pos, const wxSize& size) : ! wxFrame((wxFrame *)0, -1, "Global Conflict", pos, size, wxNO_FULL_REPAINT_ON_RESIZE), // | wxNO_FULL_REPAINT_ON_RESIZE | wxCLIP_CHILDREN ! framePos(pos.x, pos.y), frameSize(size.GetWidth(), size.GetHeight()), ! mnWidth(size.GetWidth()), mnHeight(size.GetHeight()), ! gameDateZulu(2000,4,10,5,0,0) { ! viewer = 0; ! infoConsole = 0; ! briefingConsoleLeft = 0; ! briefingConsoleBottom = 0; ! tacticalMap = 0; ! worldMap = 0; ! optionsView = 0; ! hookInfo = 0; ! objectControl = 0; ! oobView = 0; ! popupControl = 0; ! director = 0; ! networkView = 0; ! messageCenter = 0; SetBackgroundColour(*wxBLACK); --- 2851,2877 ---- * */ ! tcGame::tcGame(const wxPoint& pos, const wxSize& size) ! : ! wxFrame((wxFrame *)0, -1, "Global Conflict", pos, size, wxNO_FULL_REPAINT_ON_RESIZE), // | wxNO_FULL_REPAINT_ON_RESIZE | wxCLIP_CHILDREN ! framePos(pos.x, pos.y), frameSize(size.GetWidth(), size.GetHeight()), ! mnWidth(size.GetWidth()), mnHeight(size.GetHeight()), ! gameDateZulu(2000,4,10,5,0,0), ! viewer(0), ! infoConsole(0), ! briefingConsoleLeft(0), ! briefingConsoleBottom(0), ! tacticalMap(0), ! worldMap(0), ! optionsView(0), ! hookInfo(0), ! objectControl(0), ! oobView(0), ! popupControl(0), ! director(0), ! networkView(0), ! multiplayerGameSetup(0), ! messageCenter(0) { ! SetBackgroundColour(*wxBLACK); |