[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.101,1.102 tcLauncherState.cpp,1.18,1.19 tcMenu.cpp,1.7,1.
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-11-01 03:17:30
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20973/src/sim Modified Files: Game.cpp tcLauncherState.cpp tcMenu.cpp tcRadar.cpp tcSensorMap.cpp Log Message: A few more changes related to GDI+ replacement Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcLauncherState.cpp 14 Sep 2004 02:01:47 -0000 1.18 --- tcLauncherState.cpp 1 Nov 2004 03:17:18 -0000 1.19 *************** *** 31,39 **** #include <iostream> #include "common/tcObjStream.h" ! tcDatabase* tcLauncherState::mpDatabase = NULL; tcSimState* tcLauncherState::simState = NULL; class tcGame { --- 31,40 ---- #include <iostream> #include "common/tcObjStream.h" ! #include "Game.h" tcDatabase* tcLauncherState::mpDatabase = NULL; tcSimState* tcLauncherState::simState = NULL; + /* class tcGame { *************** *** 41,44 **** --- 42,46 ---- static void DisplayMessage(const char* msg); }; + */ /** Index: tcMenu.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMenu.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcMenu.cpp 29 Oct 2004 02:50:54 -0000 1.7 --- tcMenu.cpp 1 Nov 2004 03:17:18 -0000 1.8 *************** *** 27,30 **** --- 27,32 ---- #include "tcMenu.h" + #include <osg/ref_ptr> + #include <osg/Geometry> *************** *** 34,37 **** --- 36,84 ---- tc3DWindow* tcMenu::parentWindow = 0; + osg::ref_ptr<osg::Geometry> tcMenu::submenuIcon; + + void tcMenu::InitSubmenuIcon() + { + float w = 2.0f; + + submenuIcon = new osg::Geometry; + + osg::Vec4Array* colors = new osg::Vec4Array; + colors->push_back(osg::Vec4(0.0f, 0.0f, 0.0f, 1.0f)); + submenuIcon->setColorArray(colors); + submenuIcon->setColorBinding(osg::Geometry::BIND_OVERALL); + + // create vertex array + osg::Vec3Array* vertices = new osg::Vec3Array; + submenuIcon->setVertexArray(vertices); + + + vertices->push_back(osg::Vec3(w, 0, 0)); + vertices->push_back(osg::Vec3(-w, w, 0)); + vertices->push_back(osg::Vec3(-w, -w, 0)); + submenuIcon->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLES, 0, 3)); + + + + submenuIcon->setUseDisplayList(true); + + // set state + osg::StateSet* stateSet = submenuIcon->getOrCreateStateSet(); + stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); + stateSet->setMode(GL_DEPTH_WRITEMASK, osg::StateAttribute::OFF); + stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF); + stateSet->setMode(GL_BLEND, osg::StateAttribute::ON); + stateSet->setRenderBinDetails(31, "RenderBin"); + } + + void tcMenu::SetSubmenuIconRenderBin(int bin) + { + wxASSERT(submenuIcon.valid()); + + osg::StateSet* stateSet = submenuIcon->getOrCreateStateSet(); + stateSet->setRenderBinDetails(bin, "RenderBin"); + } + + void tcMenu::AddItem(string caption, int command) { *************** *** 222,229 **** if (apMD->mpSubMenu != NULL) { #if 0 // draw submenu triangle icon PointF aSubIcon[3]; // points for tri submenu icon, rel to upper left of item ! aSubIcon[0].X = item_rect.X + mfItemWidth - 2.0f; aSubIcon[0].Y = item_rect.Y + 0.5f*item_rect.Height; aSubIcon[1].X = aSubIcon[0].X - 5.0f; --- 269,282 ---- if (apMD->mpSubMenu != NULL) { + float subx = item_rect.left + mfItemWidth - 4.0f; + float suby = item_rect.YCenter(); + + + parentWindow->DrawGeometryR(submenuIcon.get(), subx, suby); #if 0 + // draw submenu triangle icon PointF aSubIcon[3]; // points for tri submenu icon, rel to upper left of item ! aSubIcon[0].X = item_rect.X + mfItemWidth - 5.0f; aSubIcon[0].Y = item_rect.Y + 0.5f*item_rect.Height; aSubIcon[1].X = aSubIcon[0].X - 5.0f; *************** *** 335,341 **** parentWindow->MeasureText(parentWindow->GetDefaultFont(), fontSize, pmd->mzCaption.c_str(), boundingBox); ! maxWidth = (boundingBox.GetWidth() > maxWidth) ? boundingBox.GetWidth() : maxWidth; maxHeight = (boundingBox.GetHeight() > maxHeight) ? boundingBox.GetHeight() : maxHeight; } --- 388,399 ---- parentWindow->MeasureText(parentWindow->GetDefaultFont(), fontSize, pmd->mzCaption.c_str(), boundingBox); + + int w = boundingBox.GetWidth(); + if (pmd->mpSubMenu) w += 3; ! maxWidth = (w > maxWidth) ? w : maxWidth; maxHeight = (boundingBox.GetHeight() > maxHeight) ? boundingBox.GetHeight() : maxHeight; + + } *************** *** 369,372 **** --- 427,435 ---- mpCurrent = this; mpParent = NULL; + + if (!submenuIcon.valid()) + { + InitSubmenuIcon(); + } } *************** *** 378,381 **** --- 441,449 ---- mpCurrent = this; mpParent = apParent; + + if (!submenuIcon.valid()) + { + InitSubmenuIcon(); + } } Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -d -r1.101 -r1.102 *** Game.cpp 29 Oct 2004 02:50:53 -0000 1.101 --- Game.cpp 1 Nov 2004 03:17:18 -0000 1.102 *************** *** 729,733 **** wxSize(mnBriefingWidth, leftConsoleHeight), "xml/briefing_left.xml") ; ! briefingConsoleLeft->SetBaseRenderBin(10); if (!briefingConsoleLeft) --- 729,733 ---- wxSize(mnBriefingWidth, leftConsoleHeight), "xml/briefing_left.xml") ; ! briefingConsoleLeft->SetBaseRenderBin(20); if (!briefingConsoleLeft) *************** *** 763,767 **** briefingConsoleBottom->SetActive(false); briefingConsoleBottom->LoadBackgroundImage("briefing_bottom.jpg"); ! briefingConsoleBottom->SetBaseRenderBin(10); briefingConsoleBottom->Print(" "); // need this to get it to display --- 763,767 ---- briefingConsoleBottom->SetActive(false); briefingConsoleBottom->LoadBackgroundImage("briefing_bottom.jpg"); ! briefingConsoleBottom->SetBaseRenderBin(20); briefingConsoleBottom->Print(" "); // need this to get it to display *************** *** 844,848 **** tacticalMap = new tcTacticalMapView(glCanvas, wxPoint(mrectMap.left,mrectMap.top), wxSize(mrectMap.right-mrectMap.left, mrectMap.bottom-mrectMap.top)); ! tacticalMap->SetBaseRenderBin(20); tacticalMapSize = TM_LARGE; --- 844,848 ---- tacticalMap = new tcTacticalMapView(glCanvas, wxPoint(mrectMap.left,mrectMap.top), wxSize(mrectMap.right-mrectMap.left, mrectMap.bottom-mrectMap.top)); ! tacticalMap->SetBaseRenderBin(10); tacticalMapSize = TM_LARGE; *************** *** 974,978 **** // popupControl init popupControl = new tcPopupControl(glCanvas, wxPoint(1400, 400), ! wxSize(300, 300)); popupControl->SetBaseRenderBin(30); if (!popupControl) --- 974,978 ---- // popupControl init popupControl = new tcPopupControl(glCanvas, wxPoint(1400, 400), ! wxSize(400, 400)); popupControl->SetBaseRenderBin(30); if (!popupControl) *************** *** 1021,1024 **** --- 1021,1026 ---- wxASSERT(infoConsole); pythonInterface->AttachConsole(infoConsole); + // sensor maps get cleared in tcSimState::RandInit() + pythonInterface->AttachSensorMap(simState->mcSensorMap.GetMap(mcUserInfo.GetOwnAlliance())); mcGameView.AttachObjectControl(objectControl); Index: tcSensorMap.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorMap.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcSensorMap.cpp 14 Sep 2004 02:01:47 -0000 1.10 --- tcSensorMap.cpp 1 Nov 2004 03:17:18 -0000 1.11 *************** *** 113,116 **** --- 113,137 ---- + void tcSensorMapTrack::Clear() + { + for (int k=0; k<mnContributors; k++) + { + tcSensorReport* sensorReport = &maSensorReport[k]; + sensorReport->Clear(); + } + + mfLastUpdateTime = 0; + mnContributors = 0; + mnEmitters = 0; + mnDatabaseID = -1; + matchupRating = 0; + expectedDamage = 0; + assessedDamage = 0; + intercepts.clear(); + engaged.clear(); + + tcTrack::Clear(); + } + unsigned tcSensorMapTrack::GetEngagedCount() const { *************** *** 290,295 **** ! // check if reporting sensor has reported, if so update report ! // if not add new report if slots are free bool tcSensorMapTrack::AddReport(const Sensor::tcSensorReport& report) { --- 311,318 ---- ! /** ! * check if reporting sensor has reported, if so update report ! * if not add new report if slots are free ! */ bool tcSensorMapTrack::AddReport(const Sensor::tcSensorReport& report) { *************** *** 548,555 **** maTrack.AddElement(psmtrack, nKey); maTrackToSensorTrack[anTrackID] = nKey; if (psmtrack->UpdateActiveReport(rpReport, anSensorID)) { //psmtrack->UpdateTrack(); ! rpSMTrack = psmtrack; return true; } --- 571,584 ---- maTrack.AddElement(psmtrack, nKey); maTrackToSensorTrack[anTrackID] = nKey; + if (psmtrack->UpdateActiveReport(rpReport, anSensorID)) { //psmtrack->UpdateTrack(); ! rpSMTrack = psmtrack; ! #ifdef _DEBUG ! fprintf(stdout, "New active detection, alliance: %d, track id: %d, sm key: %d\n", ! alliance, anTrackID, nKey); ! #endif ! return true; } *************** *** 629,637 **** void tcAllianceSensorMap::DropTrack(tnPoolIndex anID) { ! if (anID == NULL_INDEX) {return;} tnPoolIndex nKey = maTrackToSensorTrack[anID]; ! if (nKey == NULL_INDEX) {return;} // doesn't exist ! maTrackToSensorTrack[anID] = NULL_INDEX; // used to be = maTrack.GetPoolSize(); maTrack.RemoveKey(nKey); } --- 658,678 ---- void tcAllianceSensorMap::DropTrack(tnPoolIndex anID) { ! tcSensorMapTrack* track = GetSensorMapTrack(anID); ! if (track == 0) ! { ! fprintf(stderr, "Error - tcAllianceSensorMap::DropTrack - track does not exist\n"); ! return; ! } ! ! track->Clear(); ! tnPoolIndex nKey = maTrackToSensorTrack[anID]; ! if (nKey == NULL_INDEX) ! { ! fprintf(stderr, "Error - tcAllianceSensorMap::DropTrack - track does not exist (B)\n"); ! return; ! } ! maTrackToSensorTrack[anID] = -1; maTrack.RemoveKey(nKey); } *************** *** 706,714 **** } /*******************************************************************************/ ! tcSensorMapTrack* tcAllianceSensorMap::GetSensorMapTrack(unsigned long anTrackID) { ! unsigned long nMapID; tcSensorMapTrack *pSMTrack; --- 747,759 ---- } + unsigned int tcAllianceSensorMap::GetAlliance() const + { + return alliance; + } /*******************************************************************************/ ! tcSensorMapTrack* tcAllianceSensorMap::GetSensorMapTrack(long anTrackID) { ! long nMapID; tcSensorMapTrack *pSMTrack; *************** *** 720,728 **** } /*******************************************************************************/ ! bool tcAllianceSensorMap::GetTrack(unsigned long anTrackID, tcTrack& track) { tcSensorMapTrack *pSensorTrack; ! if (!(pSensorTrack = GetSensorMapTrack(anTrackID))) { return false; } --- 765,774 ---- } /*******************************************************************************/ ! bool tcAllianceSensorMap::GetTrack(long anTrackID, tcTrack& track) { tcSensorMapTrack *pSensorTrack; ! if (!(pSensorTrack = GetSensorMapTrack(anTrackID))) ! { return false; } *************** *** 781,785 **** } ! tcAllianceSensorMap::tcAllianceSensorMap() { Clear(); } --- 827,833 ---- } ! tcAllianceSensorMap::tcAllianceSensorMap(unsigned int mapAlliance) ! : alliance(mapAlliance) ! { Clear(); } *************** *** 832,840 **** } ! void tcSensorMap::CreateMapForAlliance(UINT8 anAlliance) { if (mnMaps >= MAX_MAPS) { throw "Exceeded number of maps"; } ! mapMap[mnMaps] = new tcAllianceSensorMap(); maMapIdxForAlliance[anAlliance] = mnMaps; mnMaps++; --- 880,889 ---- } ! void tcSensorMap::CreateMapForAlliance(UINT8 anAlliance) ! { if (mnMaps >= MAX_MAPS) { throw "Exceeded number of maps"; } ! mapMap[mnMaps] = new tcAllianceSensorMap(anAlliance); maMapIdxForAlliance[anAlliance] = mnMaps; mnMaps++; *************** *** 885,905 **** } ! bool tcSensorMap::GetTrack(unsigned long anTrackID, tcTrack& track, UINT8 anAlliance) { tcAllianceSensorMap *pMap = GetMap(anAlliance); return pMap->GetTrack(anTrackID, track); } ! tcSensorMapTrack* tcSensorMap::GetSensorMapTrack(unsigned long anTrackID, UINT8 anAlliance){ tcAllianceSensorMap *pMap = GetMap(anAlliance); return pMap->GetSensorMapTrack(anTrackID); } ! int tcSensorMap::Serialize(tcFile& file, bool mbLoad) { ! if (mbLoad) { Clear(); file.Read(maMapIdxForAlliance,MAX_ALLIANCES*sizeof(int)); file.Read(&mnMaps,sizeof(mnMaps)); ! for(int n=0;n<mnMaps;n++) { ! mapMap[n] = new tcAllianceSensorMap(); mapMap[n]->Serialize(file,mbLoad); } --- 934,959 ---- } ! bool tcSensorMap::GetTrack(unsigned long anTrackID, tcTrack& track, UINT8 anAlliance) ! { tcAllianceSensorMap *pMap = GetMap(anAlliance); return pMap->GetTrack(anTrackID, track); } ! tcSensorMapTrack* tcSensorMap::GetSensorMapTrack(long anTrackID, UINT8 anAlliance) ! { tcAllianceSensorMap *pMap = GetMap(anAlliance); return pMap->GetSensorMapTrack(anTrackID); } ! int tcSensorMap::Serialize(tcFile& file, bool mbLoad) ! { ! if (mbLoad) ! { Clear(); file.Read(maMapIdxForAlliance,MAX_ALLIANCES*sizeof(int)); file.Read(&mnMaps,sizeof(mnMaps)); ! for(int n=0;n<mnMaps;n++) ! { ! mapMap[n] = new tcAllianceSensorMap(0); mapMap[n]->Serialize(file,mbLoad); } Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcRadar.cpp 14 Sep 2004 02:01:47 -0000 1.12 --- tcRadar.cpp 1 Nov 2004 03:17:18 -0000 1.13 *************** *** 401,404 **** --- 401,406 ---- if (!bAccept) return; + bool bNewReport = pReport->IsNew(); + if (bNewReport) {pReport->mfStartTime = t;} // new detection pReport->mfLat_rad = (float)target->mcKin.mfLat_rad; *************** *** 409,415 **** pReport->mnSensorPlatformID = parent->mnID; pReport->mnTrackID = target->mnID; ! bool bNewReport = pReport->IsNew(); ! bool bNewDetection = pSMTrack->IsNew(); ! if (bNewReport) {pReport->mfStartTime = t;} // new detection double fTrackLife = pReport->mfTimestamp - pReport->mfStartTime; if (fTrackLife >= 16.0) --- 411,415 ---- pReport->mnSensorPlatformID = parent->mnID; pReport->mnTrackID = target->mnID; ! double fTrackLife = pReport->mfTimestamp - pReport->mfStartTime; if (fTrackLife >= 16.0) *************** *** 430,434 **** } ! if (bNewDetection) { --- 430,434 ---- } ! bool bNewDetection = pSMTrack->IsNew(); if (bNewDetection) { *************** *** 438,445 **** tcSound::Get()->PlayEffect(SEFFECT_PING); } ! char zBuff[128]; ! sprintf(zBuff,"target %d detected at %3.1f km at time %.1f [a:%d]", target->mnID,range_km,t,parent->mnAlliance); - WTLC(zBuff); } --- 438,443 ---- tcSound::Get()->PlayEffect(SEFFECT_PING); } ! fprintf(stdout, "target %d detected at %3.1f km at time %.1f [a:%d]\n", target->mnID,range_km,t,parent->mnAlliance); } |