[Gcblue-commits] gcb_wx/src/graphics tcMapMissionObject.cpp, NONE, 1.1 tcOOBView.cpp, 1.16, 1.17
Status: Alpha
Brought to you by:
ddcforge
From: Dewitt C. <ddc...@us...> - 2006-12-15 03:38:51
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv32056/src/graphics Modified Files: tcOOBView.cpp Added Files: tcMapMissionObject.cpp Log Message: --- NEW FILE: tcMapMissionObject.cpp --- /** ** @file tcMapMissionObject.cpp */ /* Copyright (C) 2006 Dewitt Colclough (de...@gc...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" // precompiled header file #ifndef WX_PRECOMP #include "wx/wx.h" #endif // WX_PRECOMP #include "tcMapMissionObject.h" #include "tcMapView.h" #include "math_constants.h" #include "simmath.h" #include "tcSimState.h" #include "common/tcStream.h" #include "common/tcObjStream.h" #include "ai/tcMission.h" #include "ai/tcCAPMission.h" #include "ai/tcMissionManager.h" #ifdef _DEBUG #define new DEBUG_NEW #endif /** * Loads state from stream */ tcUpdateStream& tcMapMissionObject::operator<<(tcUpdateStream& stream) { tcMapObject::operator<<(stream); stream >> caption; return stream; } /** * Saves state to stream */ tcUpdateStream& tcMapMissionObject::operator>>(tcUpdateStream& stream) { tcMapObject::operator>>(stream); stream << caption; return stream; } void tcMapMissionObject::Draw(tc3DWindow* host) { if (!isActive) return; if (updateCounter++ % 4 == 0) Update(); tcPoint pscreen = GetScreenPoint(); float x = pscreen.x; float y = pscreen.y; const osg::Vec4 color(1, 1, 1, 1); // override color; host->DrawTextR(caption.c_str(), x+5.0f, y, mapView->GetDefaultFont(), color, 12.0, LEFT_BASE_LINE); if (markerEnabled) // avoids parent draw overhead this way { const float a = 4.0f; host->DrawLineR(x, y-a, x, y+a, color); host->DrawLineR(x-a, y, x+a, y, color); } if (isHooked) { const osg::Vec4 hookColor(1, 1, 1, 1); const float a = 10.0f; host->DrawLineR(x-a, y-a, x+a, y-a, hookColor); host->DrawLineR(x-a, y+a, x+a, y+a, hookColor); host->DrawLineR(x-a, y-a, x-a, y+a, hookColor); host->DrawLineR(x+a, y-a, x+a, y+a, hookColor); } } tcMission* tcMapMissionObject::GetMission() { tcGameObject* obj = tcSimState::Get()->GetObject(platformId); tcFlightOpsObject* host = dynamic_cast<tcFlightOpsObject*>(obj); if (host == 0) { return 0; } tcMissionManager* missionManager = host->GetFlightPort()->GetMissionManager(); if (missionManager == 0) { return 0; } tcMission* mission = missionManager->GetMission(missionId); return mission; } void tcMapMissionObject::MoveToScreenPoint(const wxPoint& pos) { tcMapObject::MoveToScreenPoint(pos); if (dragActive) return; // don't update during drag tcMission* mission = GetMission(); if (tcCAPMission* cap = dynamic_cast<tcCAPMission*>(mission)) { cap->SetStation(_x, _y); cap->UpdateStation(); } } /** * @return false if keyCode is valid command for this object */ bool tcMapMissionObject::ProcessKey(int keyCode) { if (keyCode == WXK_DELETE) { tcMission* mission = GetMission(); if (mission) { mission->EndMission(); } return true; } else { return false; } } void tcMapMissionObject::SetDragActive(bool state) { if (state == dragActive) return; // no change, return if (state == false) { tcMission* mission = GetMission(); if (tcCAPMission* cap = dynamic_cast<tcCAPMission*>(mission)) { cap->SetStation(_x, _y); cap->UpdateStation(); } } dragActive = state; } void tcMapMissionObject::Update() { tcGameObject* obj = tcSimState::Get()->GetObject(platformId); if (obj == 0) { FlagForDelete(); return; } if (dragActive) return; // no updates during drag tcMission* mission = GetMission(); if (tcCAPMission* cap = dynamic_cast<tcCAPMission*>(mission)) { float range_km, az_deg; cap->GetPatrolOffset(range_km, az_deg); if (range_km > 0) { tcTrack track; track.mfLon_rad = obj->mcKin.mfLon_rad; track.mfLat_rad = obj->mcKin.mfLat_rad; track.OffsetDeg(range_km, az_deg); _x = track.mfLon_rad; _y = track.mfLat_rad; caption = "CAP"; } else { _x = 0; _y = 0; caption = ""; } } else { FlagForDelete(); return; } } tcMapMissionObject::tcMapMissionObject(long platformId_, unsigned int missionId_) : tcMapObject(), platformId(platformId_), missionId(missionId_), updateCounter(0) { } tcMapMissionObject::~tcMapMissionObject() { } Index: tcOOBView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcOOBView.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcOOBView.cpp 2 Dec 2006 02:23:48 -0000 1.16 --- tcOOBView.cpp 15 Dec 2006 03:38:49 -0000 1.17 *************** *** 661,664 **** --- 661,690 ---- } + void tcOOBView::OnLButtonDClick(wxMouseEvent& event) + { + wxPoint point = event.GetPosition(); + + if (tsOOBInfo* info = + ButtonContainingPoint(wxRealPoint((float)point.x,(float)point.y))) + { + long new_key = info->mnID; + if (new_key != -1) + { + long flags = 0; + if (event.ShiftDown()) flags += 1; + if (event.ControlDown()) flags += 2; + if (event.AltDown()) flags += 4; + + wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_DCLICKHOOK) ; + command.SetEventObject(this); + command.m_extraLong = flags; + AddPendingEvent(command); + } + mnSelectedKey = new_key; + + tcSound::Get()->PlayEffect("ShortBeep"); + } + } + void tcOOBView::OnLButtonDown(wxMouseEvent& event) |