[Gcblue-commits] gcb_wx/src/graphics tcMapView.cpp,1.47,1.48
Status: Alpha
Brought to you by:
ddcforge
From: Dewitt C. <ddc...@us...> - 2006-09-16 14:01:26
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv23922/src/graphics Modified Files: tcMapView.cpp Log Message: Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** tcMapView.cpp 5 Sep 2006 01:04:25 -0000 1.47 --- tcMapView.cpp 16 Sep 2006 14:01:24 -0000 1.48 *************** *** 39,42 **** --- 39,43 ---- #include "tcMapOverlay.h" #include "tcDragStatus.h" + #include "tcSimState.h" #include "tcTime.h" *************** *** 2681,2725 **** mpointMouse = point; - scrollActive = false; - scrollDirection = 0.0f; - - // changed to scroll at window edge - /* - - const int nScrollBorder = 10; - - // +200 is a hack to workaround the semi-transparent overlay window - if (mpointMouse.x <= nScrollBorder + 200) - { - scrollActive = true; - scrollDirection = 270.0f; - } - else if (mpointMouse.x >= mnWidth - nScrollBorder) - { - scrollActive = true; - scrollDirection = 90.0f; - } - else if (mpointMouse.y <= nScrollBorder) - { - scrollActive = true; - scrollDirection = 0.0f; - } - else if (mpointMouse.y >= mnHeight - nScrollBorder - 200) // -200 another similar hack - { - scrollActive = true; - scrollDirection = 180.0f; - } - else - { - scrollActive = false; - scrollDirection = 0.0f; - } - if (scrollActive) { ! lastScrollTime = tcTime::Get()->Get30HzCount(); } ! */ ! } --- 2682,2690 ---- mpointMouse = point; if (scrollActive) { ! UpdateEdgeScroll(point); } ! } *************** *** 2773,2776 **** --- 2738,2743 ---- { hookedId = hookedUnits; + + UpdateViewForHooked(); } *************** *** 2785,2788 **** --- 2752,2756 ---- { hookedId.push_back(id); + UpdateViewForHooked(); } } *************** *** 2833,2842 **** scrollActive = false; scrollDirection = 0.0f; } if (scrollActive) { ! lastScrollTime = tcTime::Get()->Get30HzCount(); } } --- 2801,2826 ---- scrollActive = false; scrollDirection = 0.0f; + + if (HasCapture()) + { + ReleaseMouse(); + } } if (scrollActive) { ! float dx = float(mpointMouse.x - mnWidth/2); ! float dy = -float(mpointMouse.y - mnHeight/2); ! ! scrollDirection = C_180OVERPI * atan2f(dx, dy); ! ! if (!HasCapture()) ! { ! lastScrollTime = tcTime::Get()->Get30HzCount(); ! CaptureMouse(); ! } ! } + } *************** *** 2864,2867 **** --- 2848,2870 ---- } + /** + * Check if first hooked object is within the view. If not then + * center view on object. + */ + void tcTacticalMapView::UpdateViewForHooked() + { + if (hookedId.size() == 0) return; + + tcGameObject* obj = tcSimState::Get()->GetObject(hookedId[0]); + if (obj == 0) return; + + tcPoint pos(obj->mcKin.mfLon_rad, obj->mcKin.mfLat_rad); + if (!PointInView(pos)) + { + tcPoint screen = GeoToScreen(pos); + SetViewCenterZoom(wxPoint(screen.x, screen.y), 1.0); + } + } + tcTacticalMapView::tcTacticalMapView(wxWindow *parent, |