[Gcblue-commits] gcb_wx/src/sim tcCommandQueue.cpp,NONE,1.1 tcSensorTrackIterator.cpp,NONE,1.1 Game.
Status: Alpha
Brought to you by:
ddcforge
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30338/src/sim Modified Files: Game.cpp tcObjectControl.cpp tcOpticalSensor.cpp tcRadar.cpp tcSimState.cpp Added Files: tcCommandQueue.cpp tcSensorTrackIterator.cpp Log Message: Sonar work, passive sonar, torpedoes --- NEW FILE: tcSensorTrackIterator.cpp --- /** ** @file tcSensorTrackIterator.cpp */ /* ** Copyright (C) 2004 Dewitt Colclough (de...@tw...) ** 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 #include "tcSensorTrackIterator.h" #include "tcGameObject.h" #include "tcSensorMap.h" #include "tcSimState.h" #ifdef _DEBUG #define new DEBUG_NEW #endif namespace Sensor { tcSimState* tcSensorTrackIterator::simState = NULL; /** * */ void tcSensorTrackIterator::First() { if (!map) { currentPos = -1; currentObj = 0; nIterated = 1; return; } wxASSERT(map->GetTrackCount() >= 0); nSize = (unsigned int)map->GetTrackCount(); nIterated = 0; if (nSize == 0) { currentPos = -1; currentObj = 0; nIterated = 1; return; } currentPos = map->GetStartTrackPosition(); Next(); } /** * */ tcSensorMapTrack* tcSensorTrackIterator::Get() { return currentObj; } /** * Advance to next object that meets filter criteria. If * no objects are found, set currentObj to NULL */ void tcSensorTrackIterator::Next() { if (!map) { nIterated++; return; } bool searching = true; while ((nIterated <= nSize) && searching) { if (nIterated < nSize) // kind of a hack, nIterated > nSize is used for end condition { map->GetNextTrack(currentPos, currentObj); } nIterated++; if (PassesFilter(currentObj)) { searching = false; // found eligible object } else { currentObj = 0; } } } /** * */ bool tcSensorTrackIterator::NotDone() { return (nIterated <= nSize); } /** * Checks currentObj against filtering criteria. This is used * to iterate through a filtered set of objects. * @return true if current obj meets filtering criteria, false otherwise */ bool tcSensorTrackIterator::PassesFilter(const tcSensorMapTrack* track) { if (!track) return false; bool passesClassMask = (classMask & track->mnClassification) != 0; if (!passesClassMask) return false; if (!useRegion) return true; return region.ContainsPoint(track->mfLon_rad, track->mfLat_rad); } tcSensorTrackIterator::tcSensorTrackIterator(unsigned int alliance_, unsigned int classificationMask, const tcGeoRect& filterRegion) : useRegion(true), alliance(alliance_), classMask(classificationMask) { if (!simState) { simState = tcSimState::Get(); } region = filterRegion; map = simState->mcSensorMap.GetMap(alliance); First(); } tcSensorTrackIterator::tcSensorTrackIterator() : useRegion(false), alliance(0), classMask(0) { if (!simState) { simState = tcSimState::Get(); } map = simState->mcSensorMap.GetMap(alliance); First(); } tcSensorTrackIterator::~tcSensorTrackIterator() { } } Index: tcOpticalSensor.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcOpticalSensor.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcOpticalSensor.cpp 2 Dec 2004 04:17:27 -0000 1.3 --- tcOpticalSensor.cpp 11 Dec 2004 01:09:08 -0000 1.4 *************** *** 22,25 **** --- 22,26 ---- #include "stdwx.h" #include "aerror.h" + #include "tcCommandQueue.h" #include "nsNav.h" #include "tcOpticalSensor.h" Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** tcSimState.cpp 7 Dec 2004 04:00:43 -0000 1.61 --- tcSimState.cpp 11 Dec 2004 01:09:08 -0000 1.62 *************** *** 33,36 **** --- 33,37 ---- #include "tcSimPythonInterface.h" #include "osg/Group" + #include "tcCommandQueue.h" #include "tcGoalTracker.h" #include "tcGoal.h" --- NEW FILE: tcCommandQueue.cpp --- /** ** @file tcCommandQueue.cpp */ /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** 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" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "tcCommandQueue.h" #ifdef _DEBUG #define new DEBUG_NEW #endif /** * */ tcCommandQueue* tcCommandQueue::Get() { static tcCommandQueue instance; return &instance; } /** * */ void tcCommandQueue::AddCommand(const tsCommandInfo& newcmd) { if (mnCount < MAX_QUEUED_COMMANDS) { maCommand[mnCount++] = newcmd; } } /** * */ void tcCommandQueue::AddCommand(teGameCommand aeCmd, float afData, long anData, int anData2) { tsCommandInfo newcmd; newcmd.meCmd = aeCmd; newcmd.mfData = afData; newcmd.mnData = anData; newcmd.mnData2 = anData2; newcmd.mbUsePython = false; newcmd.mbCallback = false; newcmd.mbGetUserInput = false; newcmd.platformID = -1; if (mnCount < MAX_QUEUED_COMMANDS) { maCommand[mnCount++] = newcmd; } } /** * For string commands */ void tcCommandQueue::AddCommand(const char *azCommand, int param) { tsCommandInfo newcmd; newcmd.meCmd = GC_TEXTCOMMAND; newcmd.mbUsePython = false; newcmd.mbCallback = false; newcmd.mbGetUserInput = false; newcmd.mnData = param; strcpy(newcmd.mzString , azCommand); strcpy(newcmd.mzUserInput, ""); newcmd.platformID = -1; if (mnCount < MAX_QUEUED_COMMANDS) { maCommand[mnCount++] = newcmd; } } /** * version without user input and callback */ void tcCommandQueue::AddPythonCommand(const char *azCommand, int param) { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; newcmd.mbUsePython = true; newcmd.mbCallback = false; newcmd.mbGetUserInput = false; newcmd.mnData = param; // int param newcmd.textParam = ""; // text param strcpy(newcmd.mzString , azCommand); strcpy(newcmd.mzUserInput, ""); newcmd.platformID = -1; if (mnCount < MAX_QUEUED_COMMANDS) { maCommand[mnCount++] = newcmd; } } /** * version without user input and callback */ void tcCommandQueue::AddPythonCommand(const char *azCommand, std::string textParam) { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; newcmd.mbUsePython = true; newcmd.mbCallback = false; newcmd.mbGetUserInput = false; newcmd.mnData = -1; // int param newcmd.textParam = textParam; strcpy(newcmd.mzString , azCommand); strcpy(newcmd.mzUserInput, ""); newcmd.platformID = -1; if (mnCount < MAX_QUEUED_COMMANDS) { maCommand[mnCount++] = newcmd; } } /* GetUserInput is called to add a command to get user input data. ** Once the user input is complete, the callback function is called though ** AddPythonCallback. Data that describes the user input is passed to the ** callback function along with an optional parameter. */ void tcCommandQueue::GetUserInput(const char *azCallback, const char *azUserInput, int param) { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; newcmd.mbUsePython = true; newcmd.mbCallback = false; newcmd.mbGetUserInput = true; newcmd.mnData = param; newcmd.textParam = ""; strcpy(newcmd.mzString , azCallback); strcpy(newcmd.mzUserInput, azUserInput); newcmd.platformID = -1; if (mnCount < MAX_QUEUED_COMMANDS) { maCommand[mnCount++] = newcmd; } } /** * This version accepts a platformID parameter vs. defaulting to hooked platform * * GetUserInput is called to add a command to get user input data. * Once the user input is complete, the callback function is called though * AddPythonCallback. Data that describes the user input is passed to the * callback function along with an optional parameter. */ void tcCommandQueue::GetUserInputForID(const char *azCallback, const char *azUserInput, long platformID, int param) { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; newcmd.mbUsePython = true; newcmd.mbCallback = false; newcmd.mbGetUserInput = true; newcmd.mnData = param; newcmd.textParam = ""; strcpy(newcmd.mzString , azCallback); strcpy(newcmd.mzUserInput, azUserInput); newcmd.platformID = platformID; if (mnCount < MAX_QUEUED_COMMANDS) { maCommand[mnCount++] = newcmd; } } /** * version for callback * Always applies to current hooked platform */ void tcCommandQueue::AddPythonCallback(const char *azCallback, const char *azUserInput, int param) { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; newcmd.mbUsePython = true; newcmd.mbCallback = true; newcmd.mbGetUserInput = false; newcmd.mnData = param; newcmd.textParam = ""; strcpy(newcmd.mzString , azCallback); strcpy(newcmd.mzUserInput, azUserInput); newcmd.platformID = -1; if (mnCount < MAX_QUEUED_COMMANDS) { maCommand[mnCount++] = newcmd; } } /** * Version for specific platform ID vs. defaulting to hooked platform */ void tcCommandQueue::AddPythonCallbackForID(const char *azCallback, const char *azUserInput, long platformID, int param) { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; newcmd.mbUsePython = true; newcmd.mbCallback = true; newcmd.mbGetUserInput = false; newcmd.mnData = param; newcmd.textParam = ""; strcpy(newcmd.mzString , azCallback); strcpy(newcmd.mzUserInput, azUserInput); newcmd.platformID = platformID; if (mnCount < MAX_QUEUED_COMMANDS) { maCommand[mnCount++] = newcmd; } } /** * for sending messages */ void tcCommandQueue::DisplayInfoMessage(const char *azString) { tsCommandInfo newcmd; newcmd.meCmd = GC_DISPLAYMESSAGE; newcmd.mbUsePython = false; strcpy(newcmd.mzString, azString); newcmd.platformID = -1; if (mnCount < MAX_QUEUED_COMMANDS) { maCommand[mnCount++] = newcmd; } } /** * */ bool tcCommandQueue::GetCommand(tsCommandInfo& newcmd) { if (mnCount == 0) { newcmd.meCmd = GC_NULL; return false; } else { newcmd = maCommand[--mnCount]; return true; } } /** * */ tcCommandQueue::tcCommandQueue() { mnCount = 0; } /** * */ tcCommandQueue::~tcCommandQueue() { } Index: tcObjectControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcObjectControl.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** tcObjectControl.cpp 7 Dec 2004 04:00:43 -0000 1.26 --- tcObjectControl.cpp 11 Dec 2004 01:09:07 -0000 1.27 *************** *** 44,47 **** --- 44,48 ---- #include "tcAltitudeBarControl.h" #include "tcLauncherPopup.h" + #include "tcCommandQueue.h" #include <osg/Geometry> *************** *** 1736,1744 **** mnHookID = NULL_INDEX; mnPreviousHookID = NULL_INDEX; ! mpSS = NULL; mnLaunchers = 0; mpHookedGameObj = NULL; - mpCommandInterface = NULL; mpUserInfo = NULL; msOCSymbolList.mnSymbols = 0; --- 1737,1746 ---- mnHookID = NULL_INDEX; mnPreviousHookID = NULL_INDEX; ! ! mpSS = tcSimState::Get(); ! mpCommandInterface = tcCommandQueue::Get(); mnLaunchers = 0; mpHookedGameObj = NULL; mpUserInfo = NULL; msOCSymbolList.mnSymbols = 0; Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.110 retrieving revision 1.111 diff -C2 -d -r1.110 -r1.111 *** Game.cpp 7 Dec 2004 04:00:42 -0000 1.110 --- Game.cpp 11 Dec 2004 01:09:07 -0000 1.111 *************** *** 1,21 **** /** ! ** @file Game.cpp main application class */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ! ** 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 */ --- 1,22 ---- /** ! ** @file Game.cpp main application class */ ! /* ! ** Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ! ** 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 */ *************** *** 38,41 **** --- 39,43 ---- #include "tcCustomControl.h" #include "commandlist.h" // for custom command queue handler + #include "tcCommandQueue.h" #include "tcHookInfo.h" #include "tcOOBView.h" *************** *** 105,188 **** - /** - * The tcGame object constructor. - * - */ - tcGame::tcGame(const wxPoint& pos, const wxSize& size) : - wxFrame((wxFrame *)NULL, -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 = NULL; - infoConsole = NULL; - briefingConsoleLeft = NULL; - briefingConsoleBottom = NULL; - tacticalMap = NULL; - worldMap = NULL; - editControl = NULL; - optionsView = NULL; - hookInfo = NULL; - objectControl = NULL; - oobView = NULL; - popupControl = NULL; - director = NULL; - networkView = NULL; - messageCenter = NULL; - - SetBackgroundColour(*wxBLACK); - Show(FALSE); - - simState = tcSimState::Get(); - database = tcDatabase::Get(); - - glCanvas = new wxGLCanvas(this, -1, wxPoint(0,0), size, 0, "GLCanvas", 0, wxNullPalette); - glCanvas->SetBackgroundColour(*wxBLACK); - - pythonInterface = new tcSimPythonInterface(); - goalTracker = simState->GetGoalTracker(); - - mbQuit = false; - mbPaused = false; - mbScenarioEdit = false; - accelerateTime = 0; - meScreenMode = TACTICAL; - mbSaveScenario = false; - strcpy(mzFileName,""); - mpGraphicsEngine = NULL; - mb3DActive = true; - size3D = MODE3D_SMALL; - meEditControlState = ECS_NONE; - mbSwitchToPlay = false; - gameTime = 0; - directorTime = 0; - nLastCount = 0; - multiplayerMode = 0; // single-player default - - mnBriefingWidth = 300; - mnLeftMargin = 000; - mnBottomMargin = 200; - - enableGraphicsEngine = true; - enableTacticalMap = true; - togglePopup = false; - - std::cout << "Game constructor success" << std::endl; - } - - /** - * The tcGame object destructor. - * - */ - tcGame::~tcGame() - { - if (pythonInterface) - { - delete pythonInterface; - } - messageConsole = NULL; - - Finish(); - } void tcGame::CheckGoals() --- 107,110 ---- *************** *** 543,547 **** chatBox = new tcChatBox(glCanvas, wxPoint(200, 200), wxSize(300, 180), "ChatBox"); chatBox->SetActive(false); ! chatBox->MoveToTop(); //database->LoadDBCSV(); --- 465,469 ---- chatBox = new tcChatBox(glCanvas, wxPoint(200, 200), wxSize(300, 180), "ChatBox"); chatBox->SetActive(false); ! //database->LoadDBCSV(); *************** *** 595,598 **** --- 517,522 ---- pythonInterface->AttachDirector(director); + viewer->Raise(); + InitSim(); } *************** *** 686,689 **** --- 610,614 ---- viewer->Show(FALSE); viewer->Freeze(); + mb3DActive = false; size3D = MODE3D_START; *************** *** 907,911 **** tacticalMap->AttachMapData(&mcMapData); tacticalMap->AttachOptions(tcOptions::Get()); ! tacticalMap->AttachCommandInterface(&mcCommandQueue); tacticalMap->Init(); --- 832,836 ---- tacticalMap->AttachMapData(&mcMapData); tacticalMap->AttachOptions(tcOptions::Get()); ! tacticalMap->AttachCommandInterface(commandQueue); tacticalMap->Init(); *************** *** 936,940 **** worldMap->AttachMapData(&mcMapData); worldMap->AttachOptions(tcOptions::Get()); ! worldMap->AttachCommandInterface(&mcCommandQueue); worldMap->Init(); worldMap->SetActive(false); --- 861,865 ---- worldMap->AttachMapData(&mcMapData); worldMap->AttachOptions(tcOptions::Get()); ! worldMap->AttachCommandInterface(commandQueue); worldMap->Init(); worldMap->SetActive(false); *************** *** 999,1004 **** objectControl->LoadBackgroundImage("console_b.jpg"); - objectControl->AttachCommandInterface(&mcCommandQueue); - objectControl->AttachSimState(simState); objectControl->AttachUserInfo(&mcUserInfo); --- 924,927 ---- *************** *** 1033,1037 **** } ! popupControl->AttachCommandInterface(&mcCommandQueue); popupControl->AttachPythonInterface(pythonInterface); popupControl->SetActive(false); --- 956,960 ---- } ! popupControl->AttachCommandInterface(commandQueue); popupControl->AttachPythonInterface(pythonInterface); popupControl->SetActive(false); *************** *** 1068,1072 **** #endif ! tcCustomControl::AttachCommandInterface(&mcCommandQueue); tcCustomControl::InitGdi(); --- 991,995 ---- #endif ! tcCustomControl::AttachCommandInterface(commandQueue); tcCustomControl::InitGdi(); *************** *** 1118,1122 **** simState->AttachPythonInterface(pythonInterface); simState->AttachUserInfo(&mcUserInfo); ! simState->AttachCommandInterface(&mcCommandQueue); --- 1041,1045 ---- simState->AttachPythonInterface(pythonInterface); simState->AttachUserInfo(&mcUserInfo); ! simState->AttachCommandInterface(commandQueue); *************** *** 1124,1128 **** wxASSERT(director); pythonInterface->AttachSensorMap(simState->mcSensorMap.GetMap(mcUserInfo.GetOwnAlliance())); ! pythonInterface->AttachCommandQueue(&mcCommandQueue); mcGameView.AttachSimState(simState); --- 1047,1051 ---- wxASSERT(director); pythonInterface->AttachSensorMap(simState->mcSensorMap.GetMap(mcUserInfo.GetOwnAlliance())); ! pythonInterface->AttachCommandQueue(commandQueue); mcGameView.AttachSimState(simState); *************** *** 2267,2275 **** void tcGame::ProcessCommandList() { ! for (unsigned nCmd=0; nCmd < mcCommandQueue.mnCount; nCmd++) { tsCommandInfo cmd_info; ! if(mcCommandQueue.GetCommand(cmd_info)) { if (cmd_info.mbUsePython) --- 2190,2198 ---- void tcGame::ProcessCommandList() { ! for (unsigned nCmd=0; nCmd < commandQueue->mnCount; nCmd++) { tsCommandInfo cmd_info; ! if(commandQueue->GetCommand(cmd_info)) { if (cmd_info.mbUsePython) *************** *** 2277,2285 **** if (cmd_info.mbCallback) { ! ProcessCallback(cmd_info.mzString, cmd_info.mzUserInput, cmd_info.mnData); } else if (cmd_info.mbGetUserInput) { ! GetUserInput(cmd_info.mzString, cmd_info.mzUserInput, cmd_info.mnData); } else --- 2200,2211 ---- if (cmd_info.mbCallback) { ! ProcessCallback(cmd_info.mzString, cmd_info.mzUserInput, ! cmd_info.platformID, cmd_info.mnData); } else if (cmd_info.mbGetUserInput) { ! if (cmd_info.platformID == -1) cmd_info.platformID = tacticalMap->GetHookID(); ! GetUserInput(cmd_info.mzString, cmd_info.mzUserInput, ! cmd_info.platformID, cmd_info.mnData); } else *************** *** 2287,2291 **** std::string s = cmd_info.mzString; int param = cmd_info.mnData; ! pythonInterface->ProcessCommand(s, param, cmd_info.textParam); } } --- 2213,2218 ---- std::string s = cmd_info.mzString; int param = cmd_info.mnData; ! pythonInterface->ProcessCommand(s, cmd_info.platformID, ! param, cmd_info.textParam); } } *************** *** 2339,2353 **** * Calls Python callback */ ! void tcGame::ProcessCallback(char *azCallback, char *azUserInput, int param) { if (strcmp(azUserInput,"Heading") == 0) { float fHeading = tacticalMap->GetMapCmdHeading(); ! pythonInterface->ProcessCallback(azCallback, fHeading, param); } else if (strcmp(azUserInput,"Target") == 0) { long nTarget = tacticalMap->GetMapCmdTarget(); ! pythonInterface->ProcessCallback(azCallback, nTarget, param); } else if (strcmp(azUserInput,"Datum") == 0) --- 2266,2280 ---- * Calls Python callback */ ! void tcGame::ProcessCallback(char *azCallback, char *azUserInput, long id, int param) { if (strcmp(azUserInput,"Heading") == 0) { float fHeading = tacticalMap->GetMapCmdHeading(); ! pythonInterface->ProcessCallback(azCallback, id, fHeading, param); } else if (strcmp(azUserInput,"Target") == 0) { long nTarget = tacticalMap->GetMapCmdTarget(); ! pythonInterface->ProcessCallback(azCallback, id, nTarget, param); } else if (strcmp(azUserInput,"Datum") == 0) *************** *** 2355,2359 **** tcPoint p; tacticalMap->GetMapCmdDatum(p); ! pythonInterface->ProcessCallback(azCallback, p.x, p.y, param); } else {} --- 2282,2286 ---- tcPoint p; tacticalMap->GetMapCmdDatum(p); ! pythonInterface->ProcessCallback(azCallback, id, p.x, p.y, param); } else {} *************** *** 2363,2369 **** * Gets user input for Python call back and then calls Python callback */ ! void tcGame::GetUserInput(char *azCallback, char *azUserInput, int param) { ! tacticalMap->SetMapCmdCallback(azCallback, param); if (strcmp(azUserInput,"Heading") == 0) --- 2290,2296 ---- * Gets user input for Python call back and then calls Python callback */ ! void tcGame::GetUserInput(char *azCallback, char *azUserInput, long id, int param) { ! tacticalMap->SetMapCmdCallback(azCallback, id, param); if (strcmp(azUserInput,"Heading") == 0) *************** *** 2381,2385 **** else { ! tacticalMap->SetMapCmdCallback("", -1); } } --- 2308,2312 ---- else { ! tacticalMap->SetMapCmdCallback("", id, -1); } } *************** *** 2424,2787 **** } - /* ** deferred methods * **/ - #if 0 - - bool tcGame::Init3DScene() { - tsSceneObjectInfo sSceneObjInfo; - tsSceneCameraInfo sCamInfo; - - sCamInfo.mfLat_deg = 50.1f; - sCamInfo.mfLon_deg = -5.0f; - sCamInfo.mfAlt_m = 1000.0f; - sCamInfo.mfLookAz_rad = 270.0f*C_PIOVER180; - sCamInfo.mfLookEl_rad = -10.0f*C_PIOVER180; - sCamInfo.mfNearPlane = 10.0f; - sCamInfo.mfFarPlane = 70000.0f; - sCamInfo.mfFOV_deg = 45.0f; - sCamInfo.mfAspect = (float)(mrect3D.right-mrect3D.left)/(float)(mrect3D.bottom-mrect3D.top); - sCamInfo.mfAspect = fabsf(sCamInfo.mfAspect); - mc3DScene.AttachMapData(&mcMapData); - mc3DScene.SetCameraInfo(sCamInfo); - mp3DSurface->Attach3dScene(&mc3DScene); - - // mfAz = 0; - // mfEl = 0; - // mfAzStart = sCamInfo.mfLookAz; - // mfElStart = sCamInfo.mfLookEl; - - memset(&sSceneObjInfo,0x00,sizeof(tsSceneObjectInfo)); - - - - ConsoleMessage("Initializing 3D terrain"); - mc3DScene.InitTerrain(); - - - return true; - } - bool tcGame::InitButtonBars(void) { - int nY = 30; - // button bar for lower left window selection - SetRect(&marectButtonBar[0],mrectConsole.right - 100,nY-25,mrectConsole.right,nY); - maButtonBar[0].SetWindow(marectButtonBar[0]); - maButtonBar[0].ClearButtons(); - maButtonBar[0].AddButton("buttonbar_on.bmp","buttonbar_off.bmp","Norm"); - maButtonBar[0].AddButton("buttonbar_on.bmp","buttonbar_off.bmp","Test"); - maButtonBar[0].SetTitle("Console"); - maButtonBar[0].UpdateWindow(); - maButtonBar[0].GetWindow(marectButtonBar[0]); - if(!maButtonBar[0].CreateSurfaces(mpGraphicsEngine)) {return false;} - if (maButtonBar[0].Init() == false) {return false;} ! // symbology selection ! SetRect(&marectButtonBar[1],mrectConsole.right - 200,nY-25,mrectConsole.right,nY); ! maButtonBar[1].SetWindow(marectButtonBar[1]); ! maButtonBar[1].ClearButtons(); ! maButtonBar[1].AddButton("buttonbar_on.bmp","buttonbar_off.bmp","NTDS"); ! maButtonBar[1].AddButton("buttonbar_on.bmp","buttonbar_off.bmp","Icon"); ! maButtonBar[1].SetTitle("Symbology"); ! maButtonBar[1].UpdateWindow(); ! maButtonBar[1].GetWindow(marectButtonBar[1]); ! if(!maButtonBar[1].CreateSurfaces(mpGraphicsEngine)) {return false;} ! if (maButtonBar[1].Init() == false) {return false;} ! ! // 3D window size ! SetRect(&marectButtonBar[2],mrectConsole.right - 350,nY-25,mrectConsole.right,nY); ! maButtonBar[2].SetWindow(marectButtonBar[2]); ! maButtonBar[2].ClearButtons(); ! maButtonBar[2].AddButton("buttonbar_on.bmp","buttonbar_off.bmp","Small"); ! maButtonBar[2].AddButton("buttonbar_on.bmp","buttonbar_off.bmp","Large"); ! maButtonBar[2].AddButton("buttonbar_on.bmp","buttonbar_off.bmp","OFF"); ! maButtonBar[2].SetTitle("3D Mode"); ! maButtonBar[2].UpdateWindow(); ! maButtonBar[2].GetWindow(marectButtonBar[2]); ! if(!maButtonBar[2].CreateSurfaces(mpGraphicsEngine)) {return false;} ! if (maButtonBar[2].Init() == false) {return false;} ! ! // upper left view selection ! SetRect(&marectButtonBar[3],20, mrectOOB.top + 20, 0, 0); ! maButtonBar[3].SetWindow(marectButtonBar[3]); ! maButtonBar[3].ClearButtons(); ! maButtonBar[3].AddButton("buttonbar_on.bmp","buttonbar_off.bmp","OOB"); ! maButtonBar[3].AddButton("buttonbar_on.bmp","buttonbar_off.bmp","Help"); ! maButtonBar[3].SetTitle("View selection"); ! maButtonBar[3].UpdateWindow(); ! maButtonBar[3].GetWindow(marectButtonBar[3]); ! if(!maButtonBar[3].CreateSurfaces(mpGraphicsEngine)) {return false;} ! if (maButtonBar[3].Init() == false) {return false;} ! ! return true; ! } ! ! bool tcGame::PointInButtonBar(CPoint point) { ! for (int n=0;n<N_BUTTON_BARS;n++) { ! CRect r(marectButtonBar[n]); ! if (r.PtInRect(point)) { ! return true; ! } ! } ! return false; ! } ! void tcGame::UpdateButtonBarMode(teScreenMode aeMode) { ! static teScreenMode aeLastMode = NONE; ! if (aeMode == aeLastMode) {return;} ! SyncButtonBars(); // to synch when change is applied through options screen ! if (aeMode == TACTICAL) { ! for (int n=0;n<N_BUTTON_BARS;n++) { ! maButtonBar[n].SetActive(true); ! } ! } ! else { ! for (int n=0;n<N_BUTTON_BARS;n++) { ! maButtonBar[n].SetActive(false); ! } ! } ! aeLastMode = aeMode; ! } ! // should move to within buttonbar class, derive buttonbar from wxWindow ! bool tcGame::OnLButtonDownButtonBar(UINT nFlags, CPoint point) { ! bool bWithin = false; ! for (int n=0;(n<N_BUTTON_BARS)&&(!bWithin);n++) { ! CRect r(marectButtonBar[n]); ! if (r.PtInRect(point)) { ! maButtonBar[n].OnLButtonDown(nFlags,point); ! bWithin = true; ! } ! } ! mcOptions.mbUseNTDS = maButtonBar[1].mnCurrentButton == 0; ! if (maButtonBar[2].mnCurrentButton == 2) { ! mb3DActive = false; ! } ! else if (maButtonBar[2].mnCurrentButton == 0) { ! mb3DActive = true; ! mb3DSmall = true; ! } ! else { ! mb3DActive = true; ! mb3DSmall = false; ! } ! Update3DMode(); ! mcOptions.Synchronize(); ! return bWithin; ! } ! // synch button bar state to options, call when options are changed ! void tcGame::SyncButtonBars() ! { ! maButtonBar[1].mnCurrentButton = (mcOptions.mbUseNTDS) ? 0 : 1; ! } ! void tcGame::Update3DMode() ! { ! if (!mb3DActive) ! { ! tacticalMap->SetActive(true); ! mp3DSurface->mbActive = false; ! maButtonBar[2].mnCurrentButton = 2; ! } ! else ! { ! mp3DSurface->mbActive = true; ! if (mb3DSmall) ! { ! mrect3D = mrect3DSmall; ! mp3DSurface->mrectWindow = mrect3D; ! tacticalMap->SetActive(true); ! maButtonBar[2].mnCurrentButton = 0; ! } ! else ! { ! mrect3D = mrectMap; ! mp3DSurface->mrectWindow = mrect3D; ! tacticalMap->SetActive(false); ! maButtonBar[2].mnCurrentButton = 1; ! } ! } } - /** ! * change virtual base class function in CommandInterface if this is changed */ ! void tcGame::ProcessCommand(teGameCommand aeCmd, float afData, long anData, int anData2) { ! static float sfData; ! static long snData; ! static int snData2; ! static enum { ! PLATFORM_LOCATION, ! PLATFORM_DATUM, ! LAUNCHER_DATUM, ! PLATFORM_TARGET, ! LAUNCHER_TARGET ! } seMode; ! ! switch (aeCmd) { ! /* ! case GC_TOGGLEEDIT: ! mbScenarioEdit = !mbScenarioEdit; ! if (mbScenarioEdit) { ! mcOptions.mnViewMode = 1; ! mcOptions.mnCommandMode = 0; ! } ! else { ! mcOptions.mnViewMode = 2; ! mcOptions.mnCommandMode = 1; ! } ! mbPaused = true; ! break; ! */ ! case GC_QUIT: ! WTL("tcGame::ProcessCommand GC_QUIT"); ! mbQuit = true; ! break; ! /* ! case GC_RESETMAP: ! WTL("tcGame::ProcessCommand GC_RESETMAP"); ! simState->DeleteAllPlatforms(); ! simState->ClearSensorMaps(); ! simState->RandInit(); ! break; ! case GC_ADDRANDPLAT: ! WTL("tcGame::ProcessCommand GC_ADDRANDPLAT"); ! simState->AddRandomPlatform(); ! break; ! case GC_SAVESCEN: ! WTL("tcGame::ProcessCommand GC_SAVESCEN"); ! mcEditControl.SetActive(true); ! mcEditControl.SetCaption("Enter scenario name for save:"); ! mcEditControl.SetBuffer(""); ! meEditControlState = ECS_GETSAVESCENARIO; ! //mbSaveScenario = true; ! break; ! case GC_LOADSCEN: ! WTL("tcGame::ProcessCommand GC_LOADSCEN"); ! mcEditControl.SetActive(true); ! mcEditControl.SetCaption("Enter scenario name to load:"); ! mcEditControl.SetBuffer(""); ! meEditControlState = ECS_GETLOADSCENARIO; ! break; ! case PC_GETNEWHEADING: ! WTL("tcGame::ProcessCommand PC_GETNEWHEADING"); ! tacticalMap->ActivateCmd(MC_HEADING); ! break; ! case PC_GETNEWLOCATION: ! WTL("tcGame::ProcessCommand PC_GETNEWLOCATION"); ! tacticalMap->ActivateCmd(MC_DATUM); ! seMode = PLATFORM_LOCATION; // get new location for platform (scen edit mode) ! break; ! case PC_CHANGEHEADING: ! WTL("tcGame::ProcessCommand PC_CHANGEHEADING"); ! if (mbScenarioEdit) { ! simState->ChangeHeadingForced(tacticalMap->mnHookID,afData); ! } ! else { ! simState->ChangeHeading(tacticalMap->mnHookID,afData); ! } ! break; ! case PC_HALFSPEED: ! WTL("tcGame::ProcessCommand PC_HALFSPEED"); ! simState->ChangeNormSpeed(tacticalMap->mnHookID,0.5f); ! break; ! case PC_FULLSPEED: ! WTL("tcGame::ProcessCommand PC_FULLSPEED"); ! simState->ChangeNormSpeed(tacticalMap->mnHookID,1.0f); ! break; ! case PC_GETNEWTARGET: ! WTL("tcGame::ProcessCommand PC_GETNEWTARGET"); ! tacticalMap->ActivateCmd(MC_TARGET); ! seMode = PLATFORM_TARGET; ! break; ! case PC_GETLAUNCHERTARGET: ! WTL("tcGame::ProcessCommand PC_GETLAUNCHERTARGET"); ! tacticalMap->ActivateCmd(MC_TARGET); ! seMode = LAUNCHER_TARGET; ! break; ! case PC_DESIGNATETARGET: ! { ! WTL("tcGame::ProcessCommand PC_DESIGNATETARGET"); // change to TARGETSET ? ! tcPoint p; ! tacticalMap->GetMapCmdDatum(p); ! if (seMode == PLATFORM_TARGET) { ! simState->DesignateTarget(tacticalMap->mnHookID,anData); ! } ! else { ! if (simState->DesignateLauncherTarget(tacticalMap->mnHookID,anData,snData2)==false) { ! tcSound::Get()->PlayEffect(SEFFECT_REJECTBEEP); ! // failed, repeat command ! ProcessCommand(PC_GETLAUNCHERTARGET,0,0,anData); ! } ! } ! } ! break; ! case PC_GETDATUM: ! WTL("tcGame::ProcessCommand PC_GETDATUM"); ! tacticalMap->ActivateCmd(MC_DATUM); ! //tcSound::Get()->PlayEffect(SEFFECT_TWOBEEPS); ! seMode = PLATFORM_DATUM; ! break; ! case PC_GETLAUNCHERDATUM: ! WTL("tcGame::ProcessCommand PC_GETLAUNCHERDATUM"); ! tacticalMap->ActivateCmd(MC_DATUM); ! //tcSound::Get()->PlayEffect(SEFFECT_TWOBEEPS); ! seMode = LAUNCHER_DATUM; ! break; ! case PC_DATUMSET: ! { ! WTL("tcGame::ProcessCommand PC_DATUMSET"); ! tcPoint p; ! tacticalMap->GetMapCmdDatum(p); ! if (seMode == PLATFORM_LOCATION) { ! simState->ChangeLocation(tacticalMap->mnHookID,p.x,p.y); ! } ! else if (seMode == PLATFORM_DATUM) { ! simState->DesignateDatum(tacticalMap->mnHookID,p); ! } ! else { ! simState->DesignateLauncherDatum(tacticalMap->mnHookID,p,snData2); ! } ! } ! break; ! case PC_LAUNCH: ! WTL("tcGame::ProcessCommand PC_LAUNCH"); ! if (simState->IsLauncherReady(tacticalMap->mnHookID,0)) { ! simState->RequestLaunch(tacticalMap->mnHookID,0); ! } ! else if (simState->IsLauncherReady(tacticalMap->mnHookID,1)) { ! simState->RequestLaunch(tacticalMap->mnHookID,1); ! } ! else if (simState->IsLauncherReady(tacticalMap->mnHookID,2)) { ! simState->RequestLaunch(tacticalMap->mnHookID,2); ! } ! else if (simState->IsLauncherReady(tacticalMap->mnHookID,3)) { ! simState->RequestLaunch(tacticalMap->mnHookID,3); ! } ! else { ! tcSound::Get()->PlayEffect(SEFFECT_REJECTBEEP); ! infoConsole->Print("No launchers ready to fire"); ! } ! break; ! case PC_DELETE: ! WTL("tcGame::ProcessCommand PC_DELETE"); ! simState->DeletePlatform(tacticalMap->mnHookID); ! tacticalMap->mnHookID = NULL_INDEX; ! mcHook.SetHookID(NULL_INDEX); ! mcObjectControl.SetHookID(NULL_INDEX); ! break; ! */ ! default: ! WTL("tcGame::ProcessCommand unrecognized game command"); ! break; } ! sfData = afData; ! snData = anData; ! snData2 = anData2; } - #endif \ No newline at end of file --- 2351,2435 ---- } ! /** ! * The tcGame object constructor. ! * ! */ ! tcGame::tcGame(const wxPoint& pos, const wxSize& size) : ! wxFrame((wxFrame *)NULL, -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 = NULL; ! infoConsole = NULL; ! briefingConsoleLeft = NULL; ! briefingConsoleBottom = NULL; ! tacticalMap = NULL; ! worldMap = NULL; ! editControl = NULL; ! optionsView = NULL; ! hookInfo = NULL; ! objectControl = NULL; ! oobView = NULL; ! popupControl = NULL; ! director = NULL; ! networkView = NULL; ! messageCenter = NULL; ! SetBackgroundColour(*wxBLACK); ! Show(FALSE); ! simState = tcSimState::Get(); ! database = tcDatabase::Get(); ! commandQueue = tcCommandQueue::Get(); ! glCanvas = new wxGLCanvas(this, -1, wxPoint(0,0), size, 0, "GLCanvas", 0, wxNullPalette); ! glCanvas->SetBackgroundColour(*wxBLACK); ! pythonInterface = new tcSimPythonInterface(); ! goalTracker = simState->GetGoalTracker(); + mbQuit = false; + mbPaused = false; + mbScenarioEdit = false; + accelerateTime = 0; + meScreenMode = TACTICAL; + mbSaveScenario = false; + strcpy(mzFileName,""); + mpGraphicsEngine = NULL; + mb3DActive = true; + size3D = MODE3D_SMALL; + meEditControlState = ECS_NONE; + mbSwitchToPlay = false; + gameTime = 0; + directorTime = 0; + nLastCount = 0; + multiplayerMode = 0; // single-player default ! mnBriefingWidth = 300; ! mnLeftMargin = 000; ! mnBottomMargin = 200; ! enableGraphicsEngine = true; ! enableTacticalMap = true; ! togglePopup = false; + std::cout << "Game constructor success" << std::endl; } /** ! * The tcGame object destructor. ! * */ ! tcGame::~tcGame() { ! if (pythonInterface) ! { ! delete pythonInterface; } ! messageConsole = NULL; ! ! Finish(); } Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcRadar.cpp 7 Dec 2004 04:00:43 -0000 1.20 --- tcRadar.cpp 11 Dec 2004 01:09:08 -0000 1.21 *************** *** 22,25 **** --- 22,26 ---- #include "stdwx.h" #include "aerror.h" + #include "tcCommandQueue.h" #include "nsNav.h" #include "tcRadar.h" |