[Gcblue-commits] gcb_wx/src/graphics tcFlightPortGui.cpp, 1.14, 1.15 tcMapObject.cpp, 1.12, 1.13 tc
Status: Alpha
Brought to you by:
ddcforge
From: Dewitt C. <ddc...@us...> - 2006-12-13 02:11:04
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv32556/src/graphics Modified Files: tcFlightPortGui.cpp tcMapObject.cpp tcMapOverlay.cpp tcMapView.cpp Log Message: Interactive GUI icon for CAP station Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** tcMapView.cpp 11 Dec 2006 01:20:42 -0000 1.53 --- tcMapView.cpp 13 Dec 2006 02:10:58 -0000 1.54 *************** *** 2609,2612 **** --- 2609,2618 ---- int nChar = event.GetKeyCode(); + if (overlay->IsInteracting()) + { + overlay->OnChar(event); + return; + } + if (nChar == WXK_ESCAPE) { *************** *** 2656,2663 **** CheckForNavPointEdit(buttonDownPoint); ! if (hookedId.size() == 0) { overlay->OnLButtonDown(event); ! if (overlay->IsInteracting()) return; } --- 2662,2673 ---- CheckForNavPointEdit(buttonDownPoint); ! if (editPointIdx < 0) { overlay->OnLButtonDown(event); ! if (overlay->IsInteracting()) ! { ! ClearHook(); ! return; ! } } Index: tcMapOverlay.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapOverlay.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcMapOverlay.cpp 11 Dec 2006 01:20:42 -0000 1.5 --- tcMapOverlay.cpp 13 Dec 2006 02:10:58 -0000 1.6 *************** *** 110,113 **** --- 110,114 ---- { overlayObjects[hookedIdx]->SetIsHooked(false); + overlayObjects[hookedIdx]->SetDragActive(false); } *************** *** 127,135 **** --- 128,191 ---- redraw = true; + isInteracting = false; + } + + /** + * Safely delete objects that are IsFlaggedForDelete() + */ + void tcMapOverlay::DeleteFlaggedObjects() + { + tcMapObject* hookedObj = 0; + + if (isInteracting && (hookedIdx < overlayObjects.size())) + { + hookedObj = overlayObjects[hookedIdx]; + } + + std::vector<tcMapObject*> temp; + + for (size_t n=0; n<overlayObjects.size(); n++) + { + if (!overlayObjects[n]->IsFlaggedForDelete()) + { + temp.push_back(overlayObjects[n]); + } + else + { + redraw = true; + } + } + + overlayObjects = temp; + + if (hookedObj != 0) + { + for (size_t n=0; n<overlayObjects.size(); n++) + { + if (overlayObjects[n] == hookedObj) + { + hookedIdx = n; + return; + } + } + } + + ClearInteraction(); // hooked object was deleted + + } void tcMapOverlay::Draw() { + static int updateCounter = 0; + + if (updateCounter++ % 10 == 0) + { + redraw = true; + } + if (!redraw) return; + + DeleteFlaggedObjects(); for (size_t n=0; n < overlayObjects.size(); n++) *************** *** 145,153 **** void tcMapOverlay::HookObject(size_t idx) { ! if (isInteracting && (hookedIdx == idx)) return; // already hooked if (hookedIdx < overlayObjects.size()) { overlayObjects[hookedIdx]->SetIsHooked(false); // clear previous hook } --- 201,213 ---- void tcMapOverlay::HookObject(size_t idx) { ! if (isInteracting && (hookedIdx == idx)) ! { ! return; // already hooked ! } if (hookedIdx < overlayObjects.size()) { overlayObjects[hookedIdx]->SetIsHooked(false); // clear previous hook + overlayObjects[hookedIdx]->SetDragActive(false); } *************** *** 172,175 **** --- 232,250 ---- } + + void tcMapOverlay::OnChar(wxKeyEvent& event) + { + if (isInteracting && (hookedIdx < overlayObjects.size())) + { + int nChar = event.GetKeyCode(); + overlayObjects[hookedIdx]->ProcessKey(nChar); + } + else + { + event.Skip(); + } + } + + void tcMapOverlay::OnLButtonDown(wxMouseEvent& event) { *************** *** 186,189 **** --- 261,265 ---- { HookObject(n); + overlayObjects[n]->SetDragActive(true); Redraw(); return; *************** *** 198,202 **** void tcMapOverlay::OnLButtonUp(wxMouseEvent& event) { ! ClearInteraction(); } --- 274,283 ---- void tcMapOverlay::OnLButtonUp(wxMouseEvent& event) { ! if (!isInteracting) return; ! ! if (hookedIdx < overlayObjects.size()) ! { ! overlayObjects[hookedIdx]->SetDragActive(false); ! } } *************** *** 211,216 **** } ! overlayObjects[hookedIdx]->MoveToScreenPoint(event.GetPosition()); ! Redraw(); } --- 292,300 ---- } ! if (overlayObjects[hookedIdx]->IsDragActive()) ! { ! overlayObjects[hookedIdx]->MoveToScreenPoint(event.GetPosition()); ! Redraw(); ! } } Index: tcFlightPortGui.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcFlightPortGui.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcFlightPortGui.cpp 6 Dec 2006 01:20:42 -0000 1.14 --- tcFlightPortGui.cpp 13 Dec 2006 02:10:58 -0000 1.15 *************** *** 233,237 **** } ! if (flightPort->GetMissionManager()->IsAircraftReserved(air->mnID)) { itemColor = itemColor * 0.7; --- 233,237 ---- } ! if (flightPort->GetOrCreateMissionManager()->IsAircraftReserved(air->mnID)) { itemColor = itemColor * 0.7; Index: tcMapObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapObject.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcMapObject.cpp 11 Dec 2006 01:20:42 -0000 1.12 --- tcMapObject.cpp 13 Dec 2006 02:10:58 -0000 1.13 *************** *** 162,165 **** --- 162,172 ---- } + void tcMapObject::FlagForDelete() + { + flaggedForDelete = true; + isActive = false; + } + + /** * @return screen distance from screen point pos *************** *** 173,176 **** --- 180,195 ---- } + bool tcMapObject::IsDragActive() const + { + return dragActive; + } + + + bool tcMapObject::IsFlaggedForDelete() const + { + return flaggedForDelete; + } + + bool tcMapObject::IsInteractive() const { *************** *** 211,214 **** --- 230,246 ---- } + /** + * @return false if keyCode is valid command for this object + */ + bool tcMapObject::ProcessKey(int keyCode) + { + return false; + } + + void tcMapObject::SetDragActive(bool state) + { + dragActive = state; + } + void tcMapObject::SetIsHooked(bool state) *************** *** 231,237 **** } ! tcMapObject::tcMapObject() { - tcMapObject(0,0); } --- 263,274 ---- } ! tcMapObject::tcMapObject() : ! _x(0), _y(0), ! useRelativeCoords(false), ! isInteractive(false), ! isHooked(false), ! flaggedForDelete(false), ! dragActive(false) { } *************** *** 239,243 **** : useRelativeCoords(useRel), isInteractive(false), ! isHooked(false) { if (useRel) --- 276,282 ---- : useRelativeCoords(useRel), isInteractive(false), ! isHooked(false), ! flaggedForDelete(false), ! dragActive(false) { if (useRel) |