gcblue-commits Mailing List for Global Conflict Blue (Page 45)
Status: Alpha
Brought to you by:
ddcforge
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(112) |
Feb
(106) |
Mar
(88) |
Apr
(111) |
May
(53) |
Jun
(60) |
Jul
(58) |
Aug
(61) |
Sep
(45) |
Oct
(31) |
Nov
(71) |
Dec
(70) |
| 2005 |
Jan
(33) |
Feb
(57) |
Mar
(98) |
Apr
(47) |
May
(53) |
Jun
(79) |
Jul
(79) |
Aug
|
Sep
(33) |
Oct
(1) |
Nov
(20) |
Dec
(64) |
| 2006 |
Jan
(20) |
Feb
(1) |
Mar
(43) |
Apr
(11) |
May
(8) |
Jun
(23) |
Jul
|
Aug
(28) |
Sep
(58) |
Oct
(25) |
Nov
(47) |
Dec
(70) |
|
From: Dewitt C. <ddc...@us...> - 2004-09-05 01:02:18
|
Update of /cvsroot/gcblue/gcb_wx/src/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28730/src/common Modified Files: tcOptionsView.cpp Log Message: Index: tcOptionsView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcOptionsView.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcOptionsView.cpp 8 Aug 2004 00:31:33 -0000 1.8 --- tcOptionsView.cpp 5 Sep 2004 01:02:01 -0000 1.9 *************** *** 214,218 **** else { ! /* Now this uses tcStandardWindow button bar to switch back to start // switch back to start view if no buttons clicked (for now) wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_STARTVIEW) ; --- 214,218 ---- else { ! /* Now this uses tcXmlWindow button bar to switch back to start // switch back to start view if no buttons clicked (for now) wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_STARTVIEW) ; *************** *** 251,255 **** const wxPoint& pos, const wxSize& size, const wxString& name) : ! tcStandardWindow(parent, pos, size, "xml/options_view.xml", name, surfaceHost) { wxASSERT(surfaceHost); --- 251,255 ---- const wxPoint& pos, const wxSize& size, const wxString& name) : ! tcXmlWindow(parent, pos, size, "xml/options_view.xml", name, surfaceHost) { wxASSERT(surfaceHost); |
|
From: Dewitt C. <ddc...@us...> - 2004-09-05 01:02:12
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28730/src/scriptinterface Modified Files: tcSimPythonInterface.cpp Log Message: Index: tcSimPythonInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcSimPythonInterface.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcSimPythonInterface.cpp 16 Aug 2004 01:43:31 -0000 1.17 --- tcSimPythonInterface.cpp 5 Sep 2004 01:02:02 -0000 1.18 *************** *** 310,314 **** --- 310,316 ---- * Loads scenario from Python script file. File should have * method "CreateScenario(scenario_manager)". + * * @param filePath complete file path, e.g. "scenario\\fastattack.txt" + * filePath is only used for information when logging error * @param fileName just the file name, e.g. "fastattack.txt" */ *************** *** 322,330 **** wxString errText; ! // remove .py extension from fileName ! wxString fileNameRoot = wxString(fileName).BeforeFirst('.'); // import scenario file ! cmdText = wxString::Format("from %s import *\n", fileNameRoot.c_str()); errText = wxString::Format("Error importing scenario file: %s\n", filePath); CallPython(cmdText.c_str(), errText.c_str()); --- 324,338 ---- wxString errText; ! wxString fileNameWx(fileName); ! if (fileNameWx.Contains(".py")) ! { ! // remove .py extension from fileName ! int findIdx = fileNameWx.Find(".py"); ! fileNameWx = fileNameWx.SubString(0, findIdx - 1); ! fprintf(stdout, "tcSimPythonInterface -- Loading scenario %s\n", fileNameWx.c_str()); ! } // import scenario file ! cmdText = wxString::Format("from %s import *\n", fileNameWx.c_str()); errText = wxString::Format("Error importing scenario file: %s\n", filePath); CallPython(cmdText.c_str(), errText.c_str()); |
|
From: Dewitt C. <ddc...@us...> - 2004-09-05 01:02:11
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28730/src/graphics Modified Files: tcDisplaySettingsView.cpp Added Files: tcCreditView.cpp tcNetworkView.cpp tcPanel.cpp tcPopupControl.cpp tcScenarioSelectView.cpp tcStartView.cpp tcXmlWindow.cpp Removed Files: tcStandardWindow.cpp Log Message: --- NEW FILE: tcXmlWindow.cpp --- /** @file tcXmlWindow.cpp */ /* ** Copyright (C) 2003 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" #ifdef WIN32 #include "wx/msw/private.h" // for MS Windows specific definitions #endif // WIN32 #endif // WX_PRECOMP #include "tcXmlWindow.h" #include "wxcommands.h" #include "common/tinyxml.h" #include "tcButton.h" #include "tcRadioButton.h" #include <iostream> unsigned tcXmlWindow::ref_count = 0; Gdiplus::SolidBrush* tcXmlWindow::mpBrush = NULL; Gdiplus::Font* tcXmlWindow::font20 = NULL; Gdiplus::Font* tcXmlWindow::font16 = NULL; Gdiplus::Font* tcXmlWindow::font12 = NULL; Gdiplus::Font* tcXmlWindow::font10 = NULL; Gdiplus::Font* tcXmlWindow::font8 = NULL; Gdiplus::Pen* tcXmlWindow::mpPen = NULL; BEGIN_EVENT_TABLE(tcXmlWindow, tcWindow) EVT_COMMAND(-1, wxEVT_COMMAND_BUTTON_CLICKED , tcXmlWindow::OnButtonCommand) END_EVENT_TABLE() using namespace Gdiplus; void tcXmlWindow::AddXMLControls() { if ((config == NULL)||(config->Error())) { std::cerr << "Error - tcXmlWindow::AddXMLControls - Null or invalid xml file" << std::endl; return; } // config is also the root node TiXmlNode* root = config->FirstChild("Window"); if (!root) { std::cerr << "Error - tcXmlWindow::AddXMLControls - <Window> xml tag not found at doc top\n"; return; } // add buttons TiXmlNode* current = root->FirstChild("Button"); while (current) { tcButton *button = new tcButton(this, current); current = current->NextSibling("Button"); } // add radio buttons current = root->FirstChild("RadioButton"); while (current) { tcRadioButton *radioButton = new tcRadioButton(this, current); current = current->NextSibling("RadioButton"); } } /** * Intended to be overrided to intercept command events from GUI * objects within the window. * This routine intercepts the ID_BUTTONREDRAW event which is * a workaround for the older style of owner controlled buttons. */ void tcXmlWindow::OnButtonCommand(wxCommandEvent& event) { if (event.m_id == ID_BUTTONREDRAW) { } else { event.Skip(); } } tcXmlWindow::tcXmlWindow(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& configFile, const wxString& name, tcWindow *surfaceHost) : tcWindow(parent, pos, size, name, surfaceHost) { if (configFile.length() > 2) { config = new TiXmlDocument(configFile.c_str()); if (!config->LoadFile()) { delete config; config = NULL; std::cerr << "Error loading XML file " << configFile.c_str() << std::endl; } } else { config = NULL; } if (ref_count++ > 0) return; wxASSERT(font20 == NULL); FontFamily ff(L"Arial"); font20 = new Font(&ff,20,FontStyleRegular,UnitPixel); if (font20 == NULL) { std::cerr << "tcXmlWindow - font20 creation failed" << std::endl; } font16 = new Font(&ff,16,FontStyleBold,UnitPixel); if (font16 == NULL) { std::cerr << "tcXmlWindow - font16 creation failed" << std::endl; } font12 = new Font(&ff,12,FontStyleRegular,UnitPixel); if (font12 == NULL) { std::cerr << "tcXmlWindow - font12 creation failed" << std::endl; } font10 = new Font(&ff,10,FontStyleRegular,UnitPixel); if (font12 == NULL) { std::cerr << "tcXmlWindow - font10 creation failed" << std::endl; } font8 = new Font(&ff,8,FontStyleRegular,UnitPixel); if (font8 == NULL) { std::cerr << "tcXmlWindow - font8 creation failed" << std::endl; } mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB if (mpBrush == NULL) { std::cerr << "tcXmlWindow - mpBrush creation failed" << std::endl; } mpPen = new Pen(Color(255,200,200,200),2); if (mpPen == NULL) { std::cerr << "tcXmlWindow - mpPen creation failed" << std::endl; } } /** * If this is the last object destroyed, * clean up Gdiplus objects. */ tcXmlWindow::~tcXmlWindow() { if (config) delete config; wxASSERT(ref_count); if (--ref_count > 0) return; if (font20 != NULL) {delete font20;} if (font16 != NULL) {delete font16;} if (font12 != NULL) {delete font12;} if (font10 != NULL) {delete font10;} if (font8 != NULL) {delete font8;} if (mpBrush != NULL) {delete mpBrush;} if (mpPen != NULL) {delete mpPen;} font20 = NULL; font16 = NULL; font12 = NULL; font10 = NULL; font8 = NULL; mpBrush = NULL; } --- NEW FILE: tcPanel.cpp --- /* ** tcPanel.cpp ** ** Copyright (C) 2003 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 #endif #include "tcPanel.h" using namespace Gdiplus; // static GDI+ object init Pen* tcPanel::mpPen = NULL; SolidBrush* tcPanel::mpBrush = NULL; Font* tcPanel::mpFont = NULL; Font* tcPanel::mpBoldFont = NULL; StringFormat tcPanel::stringformatleftalign; unsigned tcPanel::mnReferenceCount = 0; WCHAR tcPanel::mzwchar[255]; void tcPanel::AddItem(std::string caption, int cmd, float x, float y, float width, float height) { tsItemData item; item.Clear(); item.caption = caption; item.command = ""; item.userInput = ""; item.cmd = cmd; item.rect.X = x; item.rect.Y = y; item.rect.Width = width; item.rect.Height = height; panelItems.push_back(item); } void tcPanel::AddItem(std::string caption, std::string command, float x, float y, float width, float height, int param) { tsItemData item; item.Clear(); item.caption = caption; item.command = command; item.userInput = ""; item.cmd = param; item.rect.X = x; item.rect.Y = y; item.rect.Width = width; item.rect.Height = height; panelItems.push_back(item); } // version for user input with callback void tcPanel::AddItemUI(std::string caption, std::string callback, std::string input, float x, float y, float width, float height, int param) { tsItemData item; item.Clear(); item.caption = caption; item.command = callback; item.userInput = input; item.cmd = param; // used as parameter to pass to python callback function item.rect.X = x; item.rect.Y = y; item.rect.Width = width; item.rect.Height = height; panelItems.push_back(item); } // sets isBold to true for last item added to panel void tcPanel::BoldLastItem() { tsItemData& item = panelItems.back(); item.isBold = true; } void tcPanel::ClearSelected() { int nItems = (int)panelItems.size(); for(int i=0;i<nItems;i++) { tsItemData *item = &panelItems[i]; item->isSelected = false; } } void tcPanel::Clear() { int nItems = (int)panelItems.size(); panelItems.clear(); mbUpdateRegions = true; } int tcPanel::Draw(Graphics *apGraphics) { if (mbUpdateRegions) { UpdateBox(); mbUpdateRegions = false; } mpBrush->SetColor(Color(200,200,200,150)); apGraphics->FillRectangle(mpBrush,boundingBox); // draw title caption StringFormat format; format.SetAlignment(StringAlignmentCenter); mpBrush->SetColor(Color(250,10,10,50)); MultiByteToWideChar(CP_ACP, 0, title.c_str(), -1, mzwchar, 255); apGraphics->DrawString(mzwchar, -1, mpBoldFont, titleBox, &format, mpBrush); int nItems = (int)panelItems.size(); // number of panelItems in menu for (int i=0;i<nItems;i++) { tsItemData *item = &panelItems[i]; DrawItem(item, apGraphics); } return 1; } void tcPanel::DrawItem(tsItemData *item, Graphics *apGraphics) { int nAlpha = 200; if (apGraphics==NULL) {return;} //if the menu item is selected if (item->isSelected) { mpBrush->SetColor(Color(nAlpha,0,10,55)); } else { mpBrush->SetColor(Color(nAlpha,200,200,210)); } RectF item_rect = item->rect; item_rect.Offset(anchor); apGraphics->FillRectangle(mpBrush,item_rect); if (item->isSelected) { mpBrush->SetColor(Color(nAlpha,255,255,255)); } else { mpBrush->SetColor(Color(nAlpha,0,0,0)); } PointF pointf(item->rect.GetLeft() + border_width, item->rect.GetTop()); pointf = pointf + anchor; Font *font = (item->isBold) ? mpBoldFont : mpFont; MultiByteToWideChar(CP_ACP, 0, item->caption.c_str(), -1, mzwchar, 255); apGraphics->DrawString(mzwchar, -1, font, item_rect, &stringformatleftalign, mpBrush); } void tcPanel::InitGdi() { if (mpPen != NULL) {return;} mpPen = new Pen(Color(0xFEFFFFFF),2); if (mpPen == NULL) {throw "mpPen creation failed";} FontFamily ff(L"Arial"); mpFont = new Font(&ff,10,FontStyleRegular,UnitPixel); if (mpFont == NULL) {throw "tcPanel - mpFont creation failed\n";} mpBoldFont = new Font(&ff,10,FontStyleBold,UnitPixel); if (mpBoldFont == NULL) {throw "tcPanel - mpBoldFont creation failed\n";} mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB if (mpBrush == NULL) {throw "tcPanel - mpBrush creation failed\n";} // Seems to have trouble when specifying centered alignment stringformatleftalign.SetFormatFlags(StringFormatFlagsNoWrap); stringformatleftalign.SetAlignment(StringAlignmentNear); stringformatleftalign.SetTrimming(StringTrimmingEllipsisCharacter); mnReferenceCount = 0; // reset reference count } void tcPanel::InitWithDefaults() { for (int i=0;i<6;i++) { char buff[64]; float x = 10.0f + (float)i * 50.0f; float y = 30.0f; sprintf(buff,"",i); AddItem(buff,-1,x,y,40.0f,15.0f); } title = "No data available."; } void tcPanel::ReleaseGdi() { if (mpPen != NULL) {delete mpPen;mpPen=NULL;} if (mpFont != NULL) {delete mpFont;mpFont=NULL;} if (mpBoldFont != NULL) {delete mpBoldFont;mpBoldFont=NULL;} if (mpBrush != NULL) {delete mpBrush;mpBrush=NULL;} } /*****************************************************************************/ /* return pointer to item (NULL for none) containing point */ tsItemData* tcPanel::ItemContainingPoint(PointF point) { int nItems = (int)panelItems.size(); PointF local_point = point - anchor; // adjust for anchor for(int i=0;i<nItems;i++) { tsItemData *item = &panelItems[i]; if (item->rect.Contains(local_point)) { return item; } } return NULL; // not found } /*****************************************************************************/ /* select menu item and all parent panelItems containing point */ bool tcPanel::UpdateSelection(PointF point) { int nItems = (int)panelItems.size(); PointF local_point = point - anchor; // adjust for anchor bool bResult = false; for(int i=0;i<nItems;i++) { tsItemData *item = &panelItems[i]; if (item->rect.Contains(local_point)) { bool hasCommand = (item->cmd != -1) || (item->command.length() > 0); item->isSelected = hasCommand; } else { item->isSelected = false; } } return bResult; // not found } void tcPanel::UpdateBox() { int nItems = (int)panelItems.size(); boundingBox.X = 0; boundingBox.Y = 0; boundingBox.Width = 0; boundingBox.Height = 0; for(int i=0;i<nItems;i++) { tsItemData *item = &panelItems[i]; float right = item->rect.GetRight(); float bottom = item->rect.GetBottom(); boundingBox.Width = (right > boundingBox.Width) ? right : boundingBox.Width; boundingBox.Height = (bottom > boundingBox.Height) ? bottom : boundingBox.Height; } boundingBox.Width += border_width; boundingBox.Height += border_width; titleBox = boundingBox; titleBox.Height = border_width; } tcPanel::tcPanel(void) { title = ""; panelItems.clear(); mbUpdateRegions = true; border_width = 12.0f; if (mpPen == NULL) {InitGdi();} mnReferenceCount++; } tcPanel::tcPanel(tcPanel* apParent) { panelItems.clear(); mbUpdateRegions = true; if (mpPen == NULL) {InitGdi();} mnReferenceCount++; } tcPanel::~tcPanel(void) { Clear(); if (mnReferenceCount == 0) { throw "bad reference count"; } mnReferenceCount--; if (mnReferenceCount==0) {ReleaseGdi();} } --- NEW FILE: tcCreditView.cpp --- /* ** @file tcCreditView.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" #ifdef WIN32 #include "wx/msw/private.h" #endif #endif #include "tcCreditView.h" #include "aerror.h" #include "tcString.h" #include "wxcommands.h" #include "tcTime.h" using namespace Gdiplus; void tcCreditView::AddCredit(tcString& s, float afTrailSpace, int effect) { if (mnCredits >= MAX_CREDITS) {return;} maCredit[mnCredits].mfTrailSpace = afTrailSpace; maCredit[mnCredits].mnEffect = effect; maCredit[mnCredits++].mzCaption = s; } /*******************************************************************************/ bool tcCreditView::Init() { tcString s; s = "------- C R E D I T S -------"; AddCredit(s, 40.0f, 1); s = "CREDITS NOT UPDATED YET FOR 0.6"; AddCredit(s, 75.0f, 1); s = "Dewitt Colclough"; AddCredit(s, 25.0f, 1); s = "Project manager and lead developer\n"; AddCredit(s, 80.0f, 0); s = "Marcelo C\341ceres (op4_delta)"; AddCredit(s, 25.0f, 1); s = "3D art"; AddCredit(s, 60.0f, 0); s = "Marco Belli"; AddCredit(s, 25.0f, 1); s = "Developer - Sound, Linux port"; AddCredit(s, 60.0f, 0); s = "Jason Morris"; AddCredit(s, 25.0f, 1); s = "Developer"; AddCredit(s, 60.0f, 0); s = "Test\n"; AddCredit(s, 23.0f, 1); AddCredit(tcString("Marco Belli"), 12.0f, 2); AddCredit(tcString("Marcelo C\341ceres"), 12.0f, 2); AddCredit(tcString("Rob Carpenter"), 12.0f, 2); AddCredit(tcString("Paul Daly"), 12.0f, 2); AddCredit(tcString("Dust"), 12.0f, 2); AddCredit(tcString("Jason Morris"), 12.0f, 2); AddCredit(tcString("Andrew Platfoot"), 12.0f, 2); AddCredit(tcString("Justin Priestman"), 12.0f, 2); AddCredit(tcString("Gregg Smith"), 38.0f+12.0f, 2); s = "Some 2D art courtesy of U.S. Navy, www.news.navy.mil/view_galleries.asp \n"; AddCredit(s, 60.0f, 0); s = "3D sky code\n"; AddCredit(s, 25.0f, 0); s = "Combat Simulator Project, csp.sourceforge.net \n"; AddCredit(s, 60.0f, 1); s = "Map data based on GTOPO30 archive distributed by the \nLand Processes Distributed Active Archive Center (LP DAAC)\nlpdaac.usgs.gov \n"; AddCredit(s, 100.0f, 0); s = "Thanks to the developers of these software libraries:\n"; AddCredit(s, 30.0f, 0); s = "wxWindows\n"; AddCredit(s, 20.0f, 0); s = "www.wxwindows.org\n"; AddCredit(s, 30.0f, 0); s = "Python 2.3\n"; AddCredit(s, 20.0f, 0); s = "www.python.org\n"; AddCredit(s, 30.0f, 0); s = "Boost Python\n"; AddCredit(s, 20.0f, 0); s = "www.boost.org\n"; AddCredit(s, 30.0f, 0); s = "OpenSceneGraph\n"; AddCredit(s, 20.0f, 0); s = "openscenegraph.sourceforge.net\n"; AddCredit(s, 60.0f, 0); s = "Special thanks to:"; AddCredit(s, 30.0f, 0); s = "Harpoon HQ, www.harpoonhq.com\n"; AddCredit(s, 30.0f, 0); s = "Mille-Sabords, www.mille-sabords.com\n"; AddCredit(s, 30.0f, 0); s = "Seawolves Surface Division, www.seawolves.org/fc\n"; AddCredit(s, 30.0f, 0); s = "and\n"; AddCredit(s, 30.0f, 0); s = "To those who offered advice through e-mail and \nthe global_conflict discussion group"; AddCredit(s, 120.0f, 0); s = "GLOBAL CONFLICT BLUE"; AddCredit(s, 20.0f, 0); s = "An open source project"; AddCredit(s, 20.0f, 0); s = "www.gcblue.com"; AddCredit(s, 20.0f, 0); s = "Copyright (C) 2002-2004, All rights reserved.\n"; AddCredit(s, 60.0f, 0); FontFamily ff(L"Arial"); mpFont = new Font(&ff,16,FontStyleRegular,UnitPixel); if (mpFont == NULL) { WTL("tcCreditView - mpFont creation failed\n"); return false; } mpFontLarge = new Font(&ff,20,FontStyleBold,UnitPixel); if (mpFontLarge == NULL) { WTL("tcCreditView - mpFontLarge creation failed\n"); return false; } mpFontSmall = new Font(&ff,12,FontStyleRegular,UnitPixel); if (mpFontSmall == NULL) { WTL("tcCreditView - mpFontSmall creation failed\n"); return false; } mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB if (mpBrush == NULL) { WTL("tcCreditView - mpBrush creation failed\n"); return false; } mpPen = new Pen(Color(255,200,200,200),2); if (mpPen == NULL) { WTL("tcCreditView - mpPen creation failed\n"); return false; } Rewind(); return true; } /*******************************************************************************/ int tcCreditView::Draw() { static WCHAR szwchar[256]; UINT32 nDeltaTime = tcTime::Get()->Get30HzCount() - mnStartTime; Graphics *pGraphics; Erase(); if (!GetGraphics(pGraphics)) { return false; } DrawBackground(pGraphics); // Get the text rendering hint. TextRenderingHint oldhint = pGraphics->GetTextRenderingHint(); // Set the text rendering hint to TextRenderingHintAntiAlias. pGraphics->SetTextRenderingHint(TextRenderingHintAntiAlias); float fY = (float)mnHeight - 0.5f*(float)nDeltaTime; float fX = 0.5f*(float)mnWidth; const UINT32 nColorFade = 0x8E328032; const UINT32 nColorBright = 0xFE64FF64; mpBrush->SetColor(Color(nColorBright)); // font color //DrawTextCentered(pGraphics, mpFont, mpBrush, crawlstring.GetBuffer(), fX,fY); static int nFlashId = -1; static bool bFlash = false; static UINT32 snFocusTime; static tcString szFocus; // reset static variables if rewind occured if (mbDrawRewind) { nFlashId = -1; bFlash = false; mbDrawRewind = false; } if (bFlash) { if (nFlashId >= 0) {szFocus = maCredit[nFlashId].mzCaption;} snFocusTime = tcTime::Get()->Get30HzCount(); mpBrush->SetColor(Color(255,255,255,255)); pGraphics->FillRectangle(mpBrush,0,0,mnWidth,mnHeight); tcSound::Get()->PlayEffect(SEFFECT_EXPLOSION2); } if (nFlashId >= 0) { UINT32 nDeltaFocusTime = (tcTime::Get()->Get30HzCount() - snFocusTime); } for (int n=0;n<(int)mnCredits;n++) { tcString s = maCredit[n].mzCaption; const float fEffectZone = 60.0f; float dyeffect = fY - ((float)mnHeight - fEffectZone); if ((dyeffect >= 0)&&(dyeffect <= fEffectZone)) { mpBrush->SetColor(Color(nColorFade)); // font color DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), fX - 40.0f*dyeffect,fY); DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), fX + 40.0f*dyeffect,fY); DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), fX - 30.0f*dyeffect,fY); DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), fX + 30.0f*dyeffect,fY); DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), fX - 20.0f*dyeffect,fY); DrawTextCentered(pGraphics, mpFont, mpBrush, s.GetBuffer(), fX + 20.0f*dyeffect,fY); mpBrush->SetColor(Color(nColorBright)); // font color } else if (fY <= (float)mnHeight) { if ((n > nFlashId)&&(maCredit[n].mnEffect == 1)) { nFlashId = n; bFlash = true; } else { bFlash = false; } Font *pFont = mpFont; if (maCredit[n].mnEffect == 1) { pFont = mpFontLarge; } else if (maCredit[n].mnEffect == 2) { pFont = mpFontSmall; } mpBrush->SetColor(Color(nColorFade)); // font color DrawTextCentered(pGraphics, pFont, mpBrush, s.GetBuffer(), fX + 1.0f,fY + 1.0f); mpBrush->SetColor(Color(nColorBright)); // font color DrawTextCentered(pGraphics, pFont, mpBrush, s.GetBuffer(), fX,fY); } fY += maCredit[n].mfTrailSpace; } pGraphics->SetTextRenderingHint(oldhint); ReleaseGraphics(pGraphics); DrawBorder(); // rewind after credits are done crawling if (fY < -100.0f) { Rewind(); } return true; } /** * return to start view on left mouse click. */ void tcCreditView::OnLButtonDown(wxMouseEvent& event) { wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_STARTVIEW) ; command.SetEventObject(this); AddPendingEvent(command); } void tcCreditView::Rewind() { mnStartTime = tcTime::Get()->Get30HzCount(); mbDrawRewind = true; } ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// tcCreditView::tcCreditView(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name, tcWindow *sharedSurface) : tcWindow(parent, pos, size, name, sharedSurface) { mpFont = NULL; mpFontLarge = NULL; mpFontSmall = NULL; mpBrush = NULL; mnCredits = 0; mbDrawRewind = false; } tcCreditView::~tcCreditView() { if (mpFont != NULL) {delete mpFont;} if (mpFontLarge != NULL) {delete mpFontLarge;} if (mpFontSmall != NULL) {delete mpFontSmall;} if (mpBrush != NULL) {delete mpBrush;} if (mpPen != NULL) {delete mpPen;} } --- NEW FILE: tcPopupControl.cpp --- /* ** tcPopupControl.cpp ** ** Copyright (C) 2003 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" #ifdef WIN32 #include "wx/msw/private.h" // for MS Windows specific definitions #endif #endif #include "tcPopupControl.h" #include "aerror.h" #include "tcSimPythonInterface.h" using namespace Gdiplus; using namespace ScriptInterface; int tcPopupControl::Draw(void) { static int drawCount = 0; drawCount++; Graphics *pGraphics; if (!mbActive) { // SetActive(false); // to make sure tc2DSurface is inactive? return 1; } Thaw(); /* else { SetActive(true); } */ //if (!GetLowQualityGraphics(pGraphics)) { if (!GetGraphics(pGraphics)) { WTL("Failed to get Graphics in tcPopupControl::Draw()\n"); return 0; } mpBrush->SetColor(Color(0,0,0,0)); pGraphics->SetCompositingMode(CompositingModeSourceCopy); pGraphics->FillRectangle(mpBrush,0,0,mnWidth,mnHeight); pGraphics->SetCompositingMode(CompositingModeSourceOver); if (mpPanel != NULL) mbRebuildMenu = (drawCount % 16) == 0; // periodically update panel display if (mbRebuildMenu) { mbRebuildMenu = false; SetMenu(); } if (mpMenu != NULL) mpMenu->Draw(pGraphics); if (mpPanel != NULL) mpPanel->Draw(pGraphics); ReleaseGraphics(pGraphics); return 1; } void tcPopupControl::UpdateRegions(void) { } void tcPopupControl::InitMenu() { mcGameMenu.Clear(); //mcGameMenu.AddItem("Switch to scenedit mode", GC_TOGGLEEDIT); //mcGameMenu.AddItem("File", 0); // mcGameMenu.BeginSubMenu(); //mcGameMenu.AddItem("Save scenario", GC_SAVESCEN); //mcGameMenu.AddItem("Load scenario", GC_LOADSCEN); mcGameMenu.AddItem("Quit", GC_QUIT); //mcGameMenu.EndSubMenu(); mcPlatformMenu.Clear(); mcTrackMenu.Clear(); mcGameEditMenu.Clear(); mcGameEditMenu.AddItem("Switch to play mode", GC_TOGGLEEDIT); mcGameEditMenu.AddItem("Create random scen", GC_RESETMAP); mcGameEditMenu.AddItem("Add random platform", GC_ADDRANDPLAT); // platform edit menu mcPlatformEditMenu.Clear(); mcPlatformEditMenu.AddItem("Move platform", PC_GETNEWLOCATION); mcPlatformEditMenu.AddItem("Change heading", PC_GETNEWHEADING); mcPlatformEditMenu.AddItem("Delete platform", PC_DELETE); // panel mcPanel.Clear(); } void tcPopupControl::SetMenu(teMenuMode mode) { meMode = mode; SetMenu(); } void tcPopupControl::SetMenu() { switch (meMode) { case MENUMODE_GAME: mpMenu = &mcGameMenu; mpPanel = NULL; break; case MENUMODE_PLATFORM: mpMenu = &mcPlatformMenu; mpPanel = NULL; mpPythonInterface->AttachMenu(mpMenu); mpPythonInterface->SelectUnitMenu(); mpPythonInterface->BuildPlatformMenu(); break; case MENUMODE_GROUP: mpMenu = &mcPlatformMenu; mpPanel = NULL; mpPythonInterface->AttachMenu(mpMenu); mpPythonInterface->SelectGroupMenu(); mpPythonInterface->BuildGroupMenu(); break; case MENUMODE_TRACK: mpMenu = &mcTrackMenu; mpPanel = NULL; mpPythonInterface->AttachMenu(mpMenu); mpPythonInterface->SelectTrackMenu(); mpPythonInterface->BuildTrackMenu(); break; case MENUMODE_GAMEEDIT: mpMenu = &mcGameEditMenu; mpPanel = NULL; break; case MENUMODE_PLATFORMEDIT: mpMenu = &mcPlatformEditMenu; mpPanel = NULL; break; case MENUMODE_FLIGHTPANEL: mpMenu = NULL; mpPanel = &mcPanel; mpPythonInterface->AttachPanel(mpPanel); mpPythonInterface->SelectFlightInterface(); mpPythonInterface->BuildFlightPortPanel(); // to avoid flicker during panel update mpPanel->UpdateSelection(PointF((float)mpointMouse.x,(float)mpointMouse.y)); break; default: mpMenu = NULL; mpPanel = NULL; break; } } bool tcPopupControl::Track(wxPoint point) { if (mbActive == true) { SetActive(false); return true; } SetActive(true); wxWindow::Raise(); mpointUpperLeft = point; // MoveWindow(point.x,point.y - (mpMenu->GetSize()-1)*mnItemHeight); // adjust mrectWindow to new popup menu location MoveWindow(point.x,point.y); mbActive = true; SetMenu(); UpdateRegions(); return true; } /*****************************************************************************/ // modified to handle panel, TODO needs rework void tcPopupControl::OnLButtonDown(wxMouseEvent& event) { int builtInCommand; std::string pythonCommand; std::string uiCommand; bool callCommand = false; if (!mbActive) {return;} if (mpCommandInterface == NULL) return; /* if buttondown is inside the menu, call Game::ProcessCommand */ wxPoint p = event.GetPosition(); PointF pointf((float)p.x,(float)p.y); if (mpMenu != NULL) { tsMenuData *pmd = mpMenu->ItemContainingPoint(pointf); if (pmd != NULL) { builtInCommand = pmd->mnCommand; // also used as parameter for python cmd pythonCommand = pmd->mzCommand; uiCommand = pmd->mzUserInput; callCommand = true; } else { SetActive(false); // close the popup return; } } if ((!callCommand)&&(mpPanel != NULL)) { tsItemData *item = mpPanel->ItemContainingPoint(pointf); if (item != NULL) { builtInCommand = item->cmd; pythonCommand = item->command; uiCommand = item->userInput; callCommand = true; } else { SetActive(false); return; } } if (pythonCommand.length() > 0) { if (uiCommand.length() > 0) { mpCommandInterface->GetUserInput(pythonCommand.c_str(), uiCommand.c_str(),builtInCommand); // builtInCommand used as a param here } else { mpCommandInterface->AddPythonCommand(pythonCommand.c_str(), builtInCommand); // builtInCommand used as a param here } } else if (builtInCommand != 0) { mpCommandInterface->AddCommand((teGameCommand)builtInCommand,0,0); } else { return; // exit without closing menu } // if panel then rebuild but do not close, otherwise close the menu if (mpPanel != NULL) mbRebuildMenu = true; else SetActive(false); return; } /*****************************************************************************/ void tcPopupControl::OnMouseMove(wxMouseEvent& event) { if (!mbActive) {return;} wxPoint point = event.GetPosition(); //point.x -= mrectWindow.left; //point.y = mrectWindow.bottom - point.y; mpointMouse = point; if (mpMenu != NULL) mpMenu->UpdateSelection(PointF((float)point.x,(float)point.y)); if (mpPanel != NULL) mpPanel->UpdateSelection(PointF((float)point.x,(float)point.y)); } ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// tcPopupControl::tcPopupControl(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name) : tcWindow(parent, pos, size, name) { mpointUpperLeft.x = 100; mpointUpperLeft.y = 100; mbActive = false; mbRebuildMenu = false; mpCommandInterface = NULL; mpPythonInterface = NULL; meMode = MENUMODE_GAME; SetMenu(); InitMenu(); mpPen = new Pen(Color(0xFEFFFFFF),2); if (mpPen == NULL) {WTL("tcPopupControl - mpPen creation failed\n");} FontFamily ff(L"Arial"); mpFont = new Font(&ff,12,FontStyleBold,UnitPixel); if (mpFont == NULL) {WTL("tcPopupControl - mpFont creation failed\n");} mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB if (mpBrush == NULL) {WTL("tcPopupControl - mpBrush creation failed\n");} mbShowDebug = false; } tcPopupControl::~tcPopupControl() { if (mpPen != NULL) {delete mpPen;} if (mpFont != NULL) {delete mpFont;} if (mpBrush != NULL) {delete mpBrush;} } --- NEW FILE: tcStartView.cpp --- /* ** tcStartView.cpp ** ** Copyright (C) 2003 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" #ifdef WIN32 #include "wx/msw/private.h" // for MS Windows specific definitions #endif #endif #include "tcStartView.h" #include "tcSound.h" #include "tcOptions.h" #include "aerror.h" #include "wxcommands.h" using namespace Gdiplus; bool tcStartView::Init() { char zBuff[96]; for(int i=0; i < N_START_BUTTONS; i++) { tsButtonInfo *pButton = &maButton[i]; sprintf(zBuff,"%sstart%d%s",IMAGE_PATH,i,"_off.jpg"); MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); pButton->mpiButtonOff = new Image(mzwchar,false); pButton->mnButtonWidth = pButton->mpiButtonOff->GetWidth(); pButton->mnButtonHeight = pButton->mpiButtonOff->GetHeight(); sprintf(zBuff,"%sstart%d%s",IMAGE_PATH,i,"_on.jpg"); MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); pButton->mpiButtonOver = new Image(mzwchar,false); sprintf(zBuff,"%sstart%d%s",IMAGE_PATH,i,"_on.jpg"); MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); pButton->mpiButtonOn = new Image(mzwchar,false); if ((pButton->mpiButtonOff == NULL)||(pButton->mpiButtonOver == NULL)|| (pButton->mpiButtonOn == NULL)) { WTL("tcStartView - button image load error, possible missing file"); } } maButton[0].mzCaption = "Select scenario."; maButton[1].mzCaption = "Configure game options."; maButton[2].mzCaption = "Browse database (not functional)."; maButton[3].mzCaption = "Show credits."; maButton[4].mzCaption = "Start game."; maButton[5].mzCaption = "Multiplayer configuration."; PlaceButtons(); FontFamily ff(L"Arial"); mpFont = new Font(&ff,10,FontStyleRegular,UnitPixel); if (mpFont == NULL) { WTL("tcStartView - mpFont creation failed\n"); return false; } mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB if (mpBrush == NULL) { WTL("tcStartView - mpBrush creation failed\n"); return false; } mpPen = new Pen(Color(255,200,200,200),2); if (mpPen == NULL) { WTL("tcStartView - mpPen creation failed\n"); return false; } return true; } int tcStartView::Draw() { static WCHAR szwchar[256]; static nTestCount = 0; Graphics *pGraphics; Erase(); if (!GetGraphics(pGraphics)) { return false; } DrawBackground(pGraphics); /*** Draw buttons ***/ mpBrush->SetColor(Color(0xFEFFFFFF)); // font color for(int i=0;i<N_START_BUTTONS;i++) { DrawButtonLine(pGraphics, i); } for(int i=0;i<N_START_BUTTONS;i++) { DrawButton(pGraphics, i); } ReleaseGraphics(pGraphics); DrawBorder(); return true; } void tcStartView::DrawButton(Graphics *apGraphics, int anButton) { Image *pButtonImage; static WCHAR szwchar[256]; // wide char array buffer for string conversion int x,y,nState; if (apGraphics == NULL) {return;} if ((anButton < 0)||(anButton >= N_START_BUTTONS)) {return;} tsButtonInfo *pButton = &maButton[anButton]; nState = pButton->mnState; if (nState == 0) {pButtonImage = pButton->mpiButtonOff;} else {pButtonImage = (nState == 1) ? pButton->mpiButtonOver : pButton->mpiButtonOn;} if (pButtonImage != NULL) { x = pButton->mnButtonX; y = pButton->mnButtonY; // not using size fields causes errors (stretching) with non power of 2 bitmap size apGraphics->DrawImage(pButtonImage,x,y,pButton->mnButtonWidth,pButton->mnButtonHeight); } if (nState != 0) { RectF textbox; textbox.X = (float)pButton->mnTextX; textbox.Y = (float)pButton->mnTextY; textbox.Width = pButton->mnButtonWidth * 2.5f; textbox.Height = 30; DrawTextInRectWrap(apGraphics, mpFont, mpBrush, pButton->mzCaption.GetBuffer(),textbox); mpPen->SetColor(0xFFFBFADE); } else { mpPen->SetColor(0xFF858476); } apGraphics->DrawRectangle(mpPen,pButton->mnButtonX,pButton->mnButtonY, pButton->mnButtonWidth,pButton->mnButtonHeight); } void tcStartView::DrawButtonLine(Graphics *apGraphics, int anButton) { int nState; if (apGraphics == NULL) {return;} if ((anButton < 0)||(anButton >= N_START_BUTTONS)) {return;} tsButtonInfo *pButton = &maButton[anButton]; nState = pButton->mnState; if (nState != 0) { mpPen->SetColor(0xFFFBFADE); } else { mpPen->SetColor(0xFF858476); } int nLineY = pButton->mnButtonY + pButton->mnButtonHeight/2; int nLineX1 = pButton->mnButtonX; int nLineX2 = pButton->mnButtonX + pButton->mnButtonWidth; const int nMargin = 50; apGraphics->DrawLine(mpPen,nMargin,nLineY,nLineX1,nLineY); apGraphics->DrawLine(mpPen,nLineX2,nLineY,mnWidth-nMargin,nLineY); } void tcStartView::OnMouseMove(wxMouseEvent& event) { bool bButtonOver; int nButton; //TranslatePoint(point); // adjust for flipped up/down bButtonOver = ButtonContainingPoint(event.GetPosition(), nButton); if (bButtonOver) { if (nButton >= N_START_BUTTONS) { WTL("tcStartView::OnMouseMove error"); return; } //tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } for(int i=0;i<N_START_BUTTONS;i++) { if ((i == nButton)&&(bButtonOver)) { bool bButtonEnabled = (i==4) ? mbPlayEnabled : (i!=2); if ((maButton[i].mnState == 0)&&(bButtonEnabled)) { tcSound::Get()->PlayEffect(SEFFECT_THUCK); } if (bButtonEnabled) {maButton[i].mnState = 1;} } else { maButton[i].mnState = 0; } } } void tcStartView::OnLButtonDown(wxMouseEvent& event) { bool bButtonClicked; int nButton; if (!mbActive) { event.Skip(); return; } //TranslatePoint(point); // adjust for flipped up/down bButtonClicked = ButtonContainingPoint(event.GetPosition(), nButton); bool bButtonEnabled = (nButton==4) ? mbPlayEnabled : (nButton!=2); if (!bButtonEnabled) {bButtonClicked = false;} if (bButtonClicked) { if (nButton >= N_START_BUTTONS) { WTL("tcStartView::OnLButtonDown error"); return; } if (nButton != 2) { tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } int command_id; if (nButton == 0) command_id = ID_SCENARIOSELECTVIEW; else if (nButton == 1) command_id = ID_OPTIONSVIEW; else if (nButton == 2) command_id = ID_DATABASEVIEW; else if (nButton == 3) command_id = ID_CREDITVIEW; else if (nButton == 4) command_id = ID_STARTGAME; else if (nButton == 5) command_id = ID_MULTIPLAYERVIEW; else command_id = 0; // add command to event handler, use button type if (command_id) { wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, command_id) ; command.SetEventObject(this); AddPendingEvent(command); } } else { nButton = -1; } for(int i=0;i<N_START_BUTTONS;i++) { if ((i == nButton)&&(bButtonClicked)) { maButton[i].mnState = 2; } else { maButton[i].mnState = 0; } } mnActiveButton = nButton; } /*** Update button placement fields ***/ void tcStartView::PlaceButtons() { int xpos,ypos; ypos = mnYStart; xpos = mnXStart; for(int i=0; i < N_START_BUTTONS - 1; i++) { tsButtonInfo *pButton = &maButton[i]; pButton->mnTextX = xpos; pButton->mnTextY = ypos+pButton->mnButtonHeight+2; pButton->mnButtonX = xpos; pButton->mnButtonY = ypos; xpos += 0*pButton->mnButtonWidth; ypos += pButton->mnButtonHeight; ypos += 32; } // place Play button to right of Scenario button const int nPlayIdx = 4; const int nScenarioIdx = 0; tsButtonInfo *pPlayButton = &maButton[nPlayIdx]; tsButtonInfo *pScenarioButton = &maButton[nScenarioIdx]; pPlayButton->mnButtonX = pScenarioButton->mnButtonX + 2*pScenarioButton->mnButtonWidth; pPlayButton->mnButtonY = pScenarioButton->mnButtonY; pPlayButton->mnTextX = pPlayButton->mnButtonX; pPlayButton->mnTextY = pPlayButton->mnButtonY+pPlayButton->mnButtonHeight+2; // place Multiplay button to right of Options button const int nMultiIdx = 5; const int nOptionsIdx = 1; tsButtonInfo *pMultiButton = &maButton[nMultiIdx]; tsButtonInfo *pOptionButton = &maButton[nOptionsIdx]; pMultiButton->mnButtonX = pOptionButton->mnButtonX + 2*pOptionButton->mnButtonWidth; pMultiButton->mnButtonY = pOptionButton->mnButtonY; pMultiButton->mnTextX = pMultiButton->mnButtonX; pMultiButton->mnTextY = pMultiButton->mnButtonY+pMultiButton->mnButtonHeight+2; } bool tcStartView::ButtonContainingPoint(wxPoint point, int& rnButton) { int i; int nx, ny, nButtonWidth, nButtonHeight; for(i=0; i < N_START_BUTTONS; i++) { nx = maButton[i].mnButtonX; ny = maButton[i].mnButtonY; nButtonWidth = maButton[i].mnButtonWidth; nButtonHeight = maButton[i].mnButtonHeight; wxRect cr(nx,ny,nButtonWidth,nButtonHeight); if (cr.Inside(point)) { rnButton = i; return true; } } return false; } /** * tcStartView constructor. */ tcStartView::tcStartView(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name) : tcWindow(parent, pos, size, name) { wxSize parentSize = parent->GetSize(); if (parentSize.GetHeight() > 800) { mnXStart = 200; mnYStart = 300; } else if (parentSize.GetHeight() > 700) { mnXStart = 200; mnYStart = 200; } else { mnXStart = 200; mnYStart = 50; } mpOptions = NULL; mpFont = NULL; mpBrush = NULL; for (int i=0; i < N_START_BUTTONS; i++) { maButton[i].mnButtonX = -100; maButton[i].mnButtonY = -100; maButton[i].mnTextX = -100; maButton[i].mnTextY = -100; maButton[i].mzCaption = "X"; maButton[i].mnState = 0; } mnActiveButton = -1; mbPlayEnabled = false; } /** * tcStartView destructor. */ tcStartView::~tcStartView() { if (mpFont != NULL) { delete mpFont; } if (mpBrush != NULL) { delete mpBrush; } if (mpPen != NULL) { delete mpPen; } for(int i=0; i < N_START_BUTTONS; i++) { if (maButton[i].mpiButtonOff != NULL) { delete maButton[i].mpiButtonOff; } if (maButton[i].mpiButtonOver != NULL) { delete maButton[i].mpiButtonOver; } if (maButton[i].mpiButtonOn != NULL) { delete maButton[i].mpiButtonOn; } } } --- tcStandardWindow.cpp DELETED --- --- NEW FILE: tcScenarioSelectView.cpp --- /** * @file tcScenarioSelectView.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" #ifdef WIN32 #include "wx/msw/private.h" // for MS Windows specific definitions #endif #endif #include "wx/dir.h" #include "wx/gdicmn.h" #include "tcScenarioSelectView.h" #include "aerror.h" #include "tcString.h" #include "wxcommands.h" #include "tcSimPythonInterface.h" #include "common/tinyxml.h" using namespace Gdiplus; tcScenarioSelectView::wxScenarioTraverser::wxScenarioTraverser( std::vector<scenarioInfo>& sInfo) : info(sInfo) { } /** * Handles files encountered during directory traversal. * * If the file contains a double underscore or does not end in .py * then return with wxDIR_CONTINUE. * Otherwise save the path up to the last \ in path * and the remainder (without the .py extension) in * caption. */ wxDirTraverseResult tcScenarioSelectView::wxScenarioTraverser ::OnFile(const wxString& filename) { if ((filename.Contains(".pyc")) || (!filename.Contains(".py")) || (filename.Contains("__")) ) { return wxDIR_CONTINUE; } wxString scenarioDir(SCENARIO_PATH); size_t scenarioDirLength = scenarioDir.size(); int findIdx = filename.find(scenarioDir); if (findIdx == -1) { fprintf(stderr, "Corrupt scen structure\n"); return wxDIR_CONTINUE; } findIdx += scenarioDir.size() + 1; // omit SCENARIO_PATH from pathString wxString pathString = filename.Mid(findIdx); wxString captionString; if (pathString.Contains("\\")) { findIdx = pathString.find_last_of("\\"); captionString = pathString.Mid(findIdx+1); } else { captionString = pathString; } pathString.Replace("\\", "."); // for python compatibility captionString = captionString.BeforeLast('.'); // remove extension scenarioInfo scen; scen.path = pathString.GetData(); scen.caption = captionString.GetData(); scen.drawState = scenarioInfo::OFF; info.push_back(scen); return wxDIR_CONTINUE; } wxDirTraverseResult tcScenarioSelectView::wxScenarioTraverser ::OnDir(const wxString& dirname) { if (dirname == "CVS") return wxDIR_IGNORE; // create a candidate parent, and then run traverser to find children scenarioInfo parent; wxDir scenarioDir(dirname); wxScenarioTraverser traverser(parent.children); scenarioDir.Traverse(traverser); // if any children are found, add this parent to the scenarioInfo member if (parent.children.size()) { parent.caption = dirname.AfterLast('\\'); parent.showChildren = false; parent.drawState = scenarioInfo::OFF; info.push_back(parent); } return wxDIR_IGNORE; } /** * Scan scenario directories and populate scenInfo */ void tcScenarioSelectView::BuildScenarioInfo() { wxString cwd = wxGetCwd(); cwd += wxString::Format("\\%s", SCENARIO_PATH); wxDir scenarioDir(cwd); if (scenarioDir.IsOpened()) { wxScenarioTraverser traverser(scenInfo); scenarioDir.Traverse(traverser); } else { scenInfo.clear(); wxMessageBox("scenario directory does not exist!"); return; } } void tcScenarioSelectView::DrawScenarioDirectory(std::vector<scenarioInfo>& info, Gdiplus::Graphics* graphics) { mpBrush->SetColor(0xFEFFFAAE); for (size_t n=0; n<info.size(); ++n) { scenarioInfo& item = info[n]; bool isDirectory = item.children.size(); if (item.drawState == scenarioInfo::ON) mpBrush->SetColor(0xFEFBFADE); else if (item.drawState == scenarioInfo::OVER) mpBrush->SetColor(0xFE8584E6); else mpBrush->SetColor(0xFE959486); if (isDirectory) { graphics->DrawImage(directoryIcon, item.drawBox.x, item.drawBox.y-2, xIndent, yHeight); DrawTextInRect(graphics, font12, mpBrush, item.caption.c_str(), RectF(item.drawBox.x + xIndent, item.drawBox.y, item.drawBox.width - xIndent, item.drawBox.height)); if (item.showChildren) { DrawScenarioDirectory(item.children, graphics); } } else { DrawTextInRect(graphics, font10, mpBrush, item.caption.c_str(), RectF(item.drawBox.x, item.drawBox.y, item.drawBox.width, item.drawBox.height)); } } } /** * Loads scenario with path+filename of SCENARIO_PATH\<filePath>.py */ void tcScenarioSelectView::LoadScenario(std::string filePath, std::string caption) { std::string totalPath = SCENARIO_PATH; totalPath += "\\"; // generalize this for Linux? totalPath += filePath; mpSimState->mpPythonInterface->LoadScenario(totalPath.c_str(), filePath.c_str()); if (mpSimState->msScenarioInfo.mbLoaded) { loadedScenarioCaption = caption; } else { wxString s = wxString::Format("Error in scenario %s. " "Check log/pyerr.txt for details.", totalPath.c_str()); wxMessageBox(s.c_str(),"Error",wxICON_ERROR); } } /** * recursive method to write scenarioInfo vector to stdout */ void tcScenarioSelectView::LogScenarioInfo(std::vector<scenarioInfo>& info, int level) { for (size_t ind=0; ind<info.size(); ++ind) { for (int i=0; i<level; ++i) { fprintf(stdout, " "); } fprintf(stdout, "%s (%s)\n", info[ind].caption.c_str(), info[ind].path.c_str()); if (info[ind].children.size()) { LogScenarioInfo(info[ind].children, level + 1); } } } /** * */ bool tcScenarioSelectView::ProcessMouseClick(std::vector<scenarioInfo>& info, wxPoint pos) { for (size_t n=0; n < info.size(); ++n) { wxRect r(info[n].drawBox.x, info[n].drawBox.y, info[n].drawBox.width, info[n].drawBox.height); bool isDirectory = info[n].children.size(); if (r.Inside(pos)) { if (isDirectory) { info[n].showChildren = !info[n].showChildren; } else { LoadScenario(info[n].path, info[n].caption); } return true; } if (isDirectory && (info[n].showChildren)) { if (ProcessMouseClick(info[n].children, pos)) { return true; } } } return false; } /** * Recursive method to update drawing info of scenarioInfo vector */ void tcScenarioSelectView::UpdateDrawInfo(std::vector<scenarioInfo>& info, wxRealPoint& currentPos) { currentPos.x += xIndent; for (size_t n=0; n < info.size(); ++n) { scenarioInfo& item = info[n]; item.drawBox.x = currentPos.x; item.drawBox.y = currentPos.y; item.drawBox.height = yHeight - 2; item.drawBox.width = xWidth; currentPos.y += yHeight; bool hasChildren = item.children.size(); if (hasChildren) { // extend left side of draw box for icon item.drawBox.x -= xIndent; item.drawBox.width += xIndent; if (item.showChildren) { UpdateDrawInfo(item.children, currentPos); } } wxRect r(item.drawBox.x, item.drawBox.y, item.drawBox.width, item.drawBox.height); int oldState = item.drawState; if (item.caption == loadedScenarioCaption) { item.drawState = scenarioInfo::ON; if (item.drawState != oldState) tcSound::Get()->PlayEffect(SEFFECT_BEEP2); } else if (r.Inside(mousePosition)) { item.drawState = scenarioInfo::OVER; if (item.drawState != oldState) tcSound::Get()->PlayEffect(SEFFECT_THUCK); } else { item.drawState = scenarioInfo::OFF; } } currentPos.x -= xIndent; } /** * Initialize the tcScenarioSelectView object. */ bool tcScenarioSelectView::Init() { char zBuff[96]; sprintf(zBuff,"%sfolder.png",IMAGE_PATH); MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); directoryIcon = new Image(mzwchar, false); scenarioIcon = new Image(mzwchar, false); BuildScenarioInfo(); UpdateDrawInfo(scenInfo, wxRealPoint(basePosition)); LogScenarioInfo(scenInfo, 0); return true; } /** * */ int tcScenarioSelectView::Draw() { static WCHAR szwchar[256]; static nTestCount = 0; Graphics* graphics; Erase(); if (!GetGraphics(graphics)) { return false; } DrawBackground(graphics); DrawChildren(graphics); /*** Draw line ***/ if (mpSimState->msScenarioInfo.mbLoaded) { mpPen->SetColor(0xFFFFFAAE); } else { mpPen->SetColor(0xFF858466); } const float nMargin = 50; graphics->DrawLine(mpPen, nMargin, yStart-nMargin, mnWidth-nMargin, yStart-nMargin); /*** Draw caption ***/ tcString caption; if (mpSimState->msScenarioInfo.mbLoaded) { caption.Format("Scenario loaded (%s)",mpSimState->msScenarioInfo.mzName); mpBrush->SetColor(0xFEFFFAAE); } else { caption = "Please select a scenario."; mpBrush->SetColor(0xFE858466); } DrawText(graphics, font16, mpBrush, caption.GetBuffer(), nMargin, (float)(yStart-nMargin-20)); /*** Draw description ***/ tcString infostring; if (mpSimState->msScenarioInfo.mbLoaded) { mpBrush->SetColor(0xFEFFFAAE); } else { mpBrush->SetColor(0xFE858466); } RectF textbox; textbox.X = xStart + 300; textbox.Y = yStart; textbox.Width = (float)(mnWidth - xStart - 25); textbox.Height = (float)(mnHeight - yStart - 25); infostring.Format("SCENARIO: %s\n\n", mpSimState->msScenarioInfo.mzName); infostring += mpSimState->msScenarioInfo.mzDescription; DrawTextInRectWrap(graphics, font16, mpBrush, infostring.GetBuffer(), textbox); DrawScenarioDirectory(scenInfo, graphics); ReleaseGraphics(graphics); DrawBorder(); return true; } /** * */ void tcScenarioSelectView::OnMouseMove(wxMouseEvent& event) { mousePosition = event.GetPosition(); UpdateDrawInfo(scenInfo, wxRealPoint(basePosition)); } /** * */ void tcScenarioSelectView::OnLButtonDown(wxMouseEvent& event) { if (!mbActive) { event.Skip(); return; } mousePosition = event.GetPosition(); if (ProcessMouseClick(scenInfo, mousePosition)) { UpdateDrawInfo(scenInfo, wxRealPoint(basePosition)); return; } } ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// /** * @param surfaceHost tcWindow to share surface of */ tcScenarioSelectView::tcScenarioSelectView(wxWindow *parent, tcWindow *surfaceHost, const wxPoint& pos, const wxSize& size, const wxString& name) : tcXmlWindow(parent, pos, size, "xml/scenarioselect_view.xml", name, surfaceHost), xIndent(15), xStart(55), xWidth(120), yHeight(15), yHeightDir(18), yStart(220), basePosition(xStart, yStart), loadedScenarioCaption("") { wxASSERT(surfaceHost); LoadBackgroundImage("start_background.jpg"); if (config) { AddXMLControls(); } else { std::cerr << "tcScenarioSelectView::tcScenarioSelectView - " "NULL xml config node\n"; return; } TiXmlNode* root = config->FirstChild("Window"); if (!root) { std::cerr << "tcScenarioSelectView::tcScenarioSelectView - " "Missing top level <Window> tag\n"; return; } mpOptions = tcOptions::Get(); mpSimState = tcSimState::Get(); } tcScenarioSelectView::~tcScenarioSelectView() { if (!directoryIcon) delete directoryIcon; if (!scenarioIcon) delete scenarioIcon; } --- NEW FILE: tcNetworkView.cpp --- /** tcNetworkView.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" #ifdef WIN32 #include "wx/msw/private.h" #endif #endif #include "tcNetworkView.h" #include "tcButton.h" #include "tcEditBox.h" #include "tcConsoleBox.h" #include "common/tinyxml.h" #include "network/tcMultiplayerInterface.h" #include "wxcommands.h" #include "tcSimState.h" #include "common/tcOptions.h" using namespace Gdiplus; BEGIN_EVENT_TABLE(tcNetworkView, tcXmlWindow) EVT_COMMAND(ID_MULTIPLAYERMODE, wxEVT_COMMAND_BUTTON_CLICKED , tcNetworkView::SetNetworkMode) EVT_COMMAND(ID_CONNECT, wxEVT_COMMAND_BUTTON_CLICKED , tcNetworkView::OnConnect) EVT_COMMAND(ID_SENDTEST, wxEVT_COMMAND_BUTTON_CLICKED , tcNetworkView::SendTest) EVT_COMMAND(ID_CHATPROTOCOL, wxEVT_COMMAND_BUTTON_CLICKED , tcNetworkView::SetChatProtocol) EVT_COMMAND(1, wxEVT_COMMAND_TEXT_UPDATED, tcNetworkView::SetIPText) EVT_COMMAND(2, wxEVT_COMMAND_TEXT_UPDATED, tcNetworkView::SendChatText) END_EVENT_TABLE() #ifdef _DEBUG #define new DEBUG_NEW #endif using network::tcMultiplayerInterface; int tcNetworkView::Draw() { Graphics *pGraphics; Erase(); if (!GetGraphics(pGraphics)) { return false; } DrawBackground(pGraphics); DrawChildren(pGraphics); DrawStatusBox(pGraphics); ReleaseGraphics(pGraphics); return true; } void tcNetworkView::DrawStatusBox(Gdiplus::Graphics *graphics) { graphics->DrawRectangle(mpPen, statusBoxBounds.x, statusBoxBounds.y, statusBoxBounds.width, statusBoxBounds.height); float x = (float)statusBoxBounds.x + 0.5*(float)statusBoxBounds.width; float y = (float)statusBoxBounds.y + 10.0f; mpBrush->SetCol... [truncated message content] |
|
From: Dewitt C. <ddc...@us...> - 2004-09-04 02:49:53
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21052/src/sim Modified Files: tcScenarioSelectView.cpp Log Message: Index: tcScenarioSelectView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcScenarioSelectView.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcScenarioSelectView.cpp 3 Sep 2004 02:37:32 -0000 1.18 --- tcScenarioSelectView.cpp 4 Sep 2004 02:49:42 -0000 1.19 *************** *** 146,156 **** for (size_t n=0; n<info.size(); ++n) { ! DrawTextInRect(graphics, mpFont, mpBrush, info[n].caption.c_str(), ! RectF(info[n].drawBox.x, info[n].drawBox.y, ! info[n].drawBox.width, info[n].drawBox.height)); ! if ((info[n].children.size()) && (info[n].showChildren)) { ! DrawScenarioDirectory(info[n].children, graphics); } } } --- 146,173 ---- for (size_t n=0; n<info.size(); ++n) { ! bool isDirectory = info[n].children.size(); ! ! if (isDirectory) { ! graphics->DrawImage(directoryIcon, info[n].drawBox.x, ! info[n].drawBox.y-2, xIndent, yHeight); ! ! DrawTextInRect(graphics, mpFont, mpBrush, info[n].caption.c_str(), ! RectF(info[n].drawBox.x + xIndent, info[n].drawBox.y, ! info[n].drawBox.width - xIndent, info[n].drawBox.height)); ! ! if (info[n].showChildren) ! { ! DrawScenarioDirectory(info[n].children, graphics); ! } ! } ! else ! { ! DrawTextInRect(graphics, mpFont, mpBrush, info[n].caption.c_str(), ! RectF(info[n].drawBox.x, info[n].drawBox.y, ! info[n].drawBox.width, info[n].drawBox.height)); } + + } } *************** *** 227,233 **** currentPos.y += yHeight; ! if ((info[n].children.size()) && info[n].showChildren) { ! UpdateDrawInfo(info[n].children, currentPos); } } --- 244,257 ---- currentPos.y += yHeight; ! bool hasChildren = info[n].children.size(); ! if (hasChildren) { ! // extend left side of draw box for icon ! info[n].drawBox.x -= xIndent; ! info[n].drawBox.width += xIndent; ! if (info[n].showChildren) ! { ! UpdateDrawInfo(info[n].children, currentPos); ! } } } *************** *** 262,265 **** --- 286,294 ---- WTL("tcScenarioSelectView - button image load error, possible missing file"); } + sprintf(zBuff,"%sfolder.png",IMAGE_PATH); + MultiByteToWideChar(CP_ACP, 0, zBuff, -1, mzwchar, 255); + directoryIcon = new Image(mzwchar, false); + scenarioIcon = new Image(mzwchar, false); + mnReturnButtonState = 0; PlaceButtons(); *************** *** 710,714 **** const wxString& name, tcWindow *sharedSurface) : tcWindow(parent, pos, size, name, sharedSurface), ! xIndent(10), xStart(55), xWidth(120), --- 739,743 ---- const wxString& name, tcWindow *sharedSurface) : tcWindow(parent, pos, size, name, sharedSurface), ! xIndent(15), xStart(55), xWidth(120), *************** *** 748,751 **** --- 777,783 ---- if (mpiButtonOn != NULL) {delete mpiButtonOn;} + if (!directoryIcon) delete directoryIcon; + if (!scenarioIcon) delete scenarioIcon; + } |
|
From: Dewitt C. <ddc...@us...> - 2004-09-04 02:49:51
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21052/include/sim Modified Files: tcScenarioSelectView.h Log Message: Index: tcScenarioSelectView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcScenarioSelectView.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcScenarioSelectView.h 3 Sep 2004 02:37:32 -0000 1.10 --- tcScenarioSelectView.h 4 Sep 2004 02:49:42 -0000 1.11 *************** *** 130,133 **** --- 130,136 ---- Gdiplus::Image *mpiButtonOver; Gdiplus::Image *mpiButtonOff; + Gdiplus::Image* directoryIcon; + Gdiplus::Image* scenarioIcon; + int mnButtonWidth; int mnButtonHeight; |
|
From: Dewitt C. <ddc...@us...> - 2004-09-03 02:37:42
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22976/src/sim Modified Files: tcScenarioSelectView.cpp Log Message: Index: tcScenarioSelectView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcScenarioSelectView.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcScenarioSelectView.cpp 1 Sep 2004 02:55:37 -0000 1.17 --- tcScenarioSelectView.cpp 3 Sep 2004 02:37:32 -0000 1.18 *************** *** 1,4 **** ! /* ! * Copyright (C) 2003 Dewitt Colclough (de...@tw...) * All rights reserved. * --- 1,6 ---- ! /** ! * @file tcScenarioSelectView.cpp ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) * All rights reserved. * *************** *** 28,31 **** --- 30,34 ---- #include "wx/dir.h" + #include "wx/gdicmn.h" #include "tcScenarioSelectView.h" #include "aerror.h" *************** *** 101,108 **** { parent.caption = dirname.AfterLast('\\'); info.push_back(parent); } ! return wxDIR_CONTINUE; } --- 104,112 ---- { parent.caption = dirname.AfterLast('\\'); + parent.showChildren = false; info.push_back(parent); } ! return wxDIR_IGNORE; } *************** *** 132,137 **** --- 136,160 ---- } + + } + + void tcScenarioSelectView::DrawScenarioDirectory(std::vector<scenarioInfo>& info, + Graphics* graphics) + { + mpBrush->SetColor(0xFEFFFAAE); + + for (size_t n=0; n<info.size(); ++n) + { + DrawTextInRect(graphics, mpFont, mpBrush, info[n].caption.c_str(), + RectF(info[n].drawBox.x, info[n].drawBox.y, + info[n].drawBox.width, info[n].drawBox.height)); + if ((info[n].children.size()) && (info[n].showChildren)) + { + DrawScenarioDirectory(info[n].children, graphics); + } + } } + /** * recursive method to write scenarioInfo vector to stdout *************** *** 158,161 **** --- 181,239 ---- /** + * + */ + bool tcScenarioSelectView::ProcessMouseClick(std::vector<scenarioInfo>& info, wxPoint pos) + { + for (size_t n=0; n < info.size(); ++n) + { + wxRect r(info[n].drawBox.x, info[n].drawBox.y, + info[n].drawBox.width, info[n].drawBox.height); + + bool hasChildren = info[n].children.size(); + + if (r.Inside(pos)) + { + if (hasChildren) + { + info[n].showChildren = !info[n].showChildren; + } + return true; + } + if (hasChildren && (info[n].showChildren)) + { + if (ProcessMouseClick(info[n].children, pos)) + { + return true; + } + } + } + + return false; + } + + /** + * Recursive method to update drawing info of scenarioInfo vector + */ + void tcScenarioSelectView::UpdateDrawInfo(std::vector<scenarioInfo>& info, + wxRealPoint& currentPos) + { + currentPos.x += xIndent; + for (size_t n=0; n < info.size(); ++n) + { + info[n].drawBox.x = currentPos.x; + info[n].drawBox.y = currentPos.y; + info[n].drawBox.height = yHeight - 2; + info[n].drawBox.width = xWidth; + currentPos.y += yHeight; + + if ((info[n].children.size()) && info[n].showChildren) + { + UpdateDrawInfo(info[n].children, currentPos); + } + } + currentPos.x -= xIndent; + } + + /** * Initialize the tcScenarioSelectView object. */ *************** *** 205,208 **** --- 283,287 ---- BuildScenarioInfo(); + UpdateDrawInfo(scenInfo, wxRealPoint(xStart, yStart)); LogScenarioInfo(scenInfo, 0); return true; *************** *** 294,297 **** --- 373,379 ---- "RETURN",rx,ry); + DrawScenarioDirectory(scenInfo, pGraphics); + + ReleaseGraphics(pGraphics); DrawBorder(); *************** *** 354,357 **** --- 436,441 ---- } + + /** * *************** *** 419,424 **** } - //TranslatePoint(point); // adjust for flipped up/down wxPoint point = event.GetPosition(); if (mrectReturnButton.Contains((REAL)point.x,(REAL)point.y)) { --- 503,513 ---- } wxPoint point = event.GetPosition(); + + if (ProcessMouseClick(scenInfo, point)) + { + UpdateDrawInfo(scenInfo, wxRealPoint(xStart, yStart)); + } + if (mrectReturnButton.Contains((REAL)point.x,(REAL)point.y)) { *************** *** 620,624 **** const wxPoint& pos, const wxSize& size, const wxString& name, tcWindow *sharedSurface) ! : tcWindow(parent, pos, size, name, sharedSurface) { mpOptions = NULL; --- 709,718 ---- const wxPoint& pos, const wxSize& size, const wxString& name, tcWindow *sharedSurface) ! : tcWindow(parent, pos, size, name, sharedSurface), ! xIndent(10), ! xStart(55), ! xWidth(120), ! yHeight(15), ! yStart(20) { mpOptions = NULL; |
|
From: Dewitt C. <ddc...@us...> - 2004-09-03 02:37:42
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22976/include/sim Modified Files: tcScenarioSelectView.h Log Message: Index: tcScenarioSelectView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcScenarioSelectView.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcScenarioSelectView.h 1 Sep 2004 02:55:36 -0000 1.9 --- tcScenarioSelectView.h 3 Sep 2004 02:37:32 -0000 1.10 *************** *** 51,57 **** --- 51,66 ---- struct scenarioInfo { + std::string path; ///< path after SCENARIO_PATH including filename std::string caption; ///< dir name or filename without the .py extension std::vector<scenarioInfo> children; + bool showChildren; ///< for directories + struct + { + float x; + float y; + float width; + float height; + } drawBox; ///< location to draw to screen }; *************** *** 107,110 **** --- 116,125 ---- private: enum {MAX_START_BUTTONS = 16}; + const float xIndent; + const float xStart; + const float xWidth; + const float yHeight; + const float yStart; + unsigned mnButtons; tcOptions *mpOptions; *************** *** 124,129 **** --- 139,148 ---- void BuildScenarioInfo(); + void DrawScenarioDirectory(std::vector<scenarioInfo>& info, + Gdiplus::Graphics* graphics); wxArrayString GetListOfScenarioFiles(); void LogScenarioInfo(std::vector<scenarioInfo>& info, int level); + bool ProcessMouseClick(std::vector<scenarioInfo>& info, wxPoint pos); + void UpdateDrawInfo(std::vector<scenarioInfo>& info, wxRealPoint& currentPos); }; |
|
From: Dewitt C. <ddc...@us...> - 2004-09-01 02:56:27
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9034/include/graphics Modified Files: tcMapObject.h tcParticleEffect.h tcParticlePlacer.h Added Files: SmokeTrailEmitter.h Log Message: --- NEW FILE: SmokeTrailEmitter.h --- /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library 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 * OpenSceneGraph Public License for more details. */ //osgParticle - Copyright (C) 2002 Marco Jez #ifndef OSGPARTICLE_SmokeTrailEmitter_ #define OSGPARTICLE_SmokeTrailEmitter_ 1 #include <osgParticle/Export> #include <osgParticle/Emitter> #include <osgParticle/Particle> #include <osgParticle/RandomRateCounter> #include <graphics/tcParticlePlacer.h> #include <osgParticle/PointPlacer> #include <osgParticle/Shooter> #include <osgParticle/RadialShooter> #include <osgParticle/ParticleSystem> #include <osg/ref_ptr> #include <osg/CopyOp> #include <osg/Object> #include <osg/Node> #include <osg/NodeVisitor> namespace osgParticle { /** An emitter class that holds three objects to control the creation of particles. These objects are a <I>counter</I>, a <I>placer</I> and a <I>shooter</I>. The counter controls the number of particles to be emitted at each frame; the placer must initialize the particle's position vector, while the shooter initializes its velocity vector. You can use the predefined counter/placer/shooter classes, or you can create your own. */ class SmokeTrailEmitter: public Emitter { public: SmokeTrailEmitter(); SmokeTrailEmitter(const SmokeTrailEmitter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); META_Node(osgParticle,SmokeTrailEmitter); /// Get the tcParticlePlacer object. inline tcParticlePlacer *getPlacer(); /// Get the const tcParticlePlacer object. inline const tcParticlePlacer *getPlacer() const; /// Set the tcParticlePlacer object. inline void setPlacer(tcParticlePlacer *p); protected: virtual ~SmokeTrailEmitter() {} SmokeTrailEmitter &operator=(const SmokeTrailEmitter &) { return *this; } void emit(double dt); private: osg::ref_ptr<tcParticlePlacer> placer_; /// template for close up particles used to make smoke trail look continuous near missile Particle closeUpTemplate; void InitializeCloseupTemplate(); }; // INLINE FUNCTIONS inline tcParticlePlacer* SmokeTrailEmitter::getPlacer() { return placer_.get(); } inline const tcParticlePlacer* SmokeTrailEmitter::getPlacer() const { return placer_.get(); } inline void SmokeTrailEmitter::setPlacer(tcParticlePlacer *p) { placer_ = p; } } #endif Index: tcParticlePlacer.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcParticlePlacer.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcParticlePlacer.h 4 Jun 2004 21:39:22 -0000 1.1 --- tcParticlePlacer.h 1 Sep 2004 02:55:35 -0000 1.2 *************** *** 25,31 **** { ! /** A point-shaped particle placer. ! This placer class uses the center point defined in its base class <CODE>CenteredPlacer</CODE> ! to place there all incoming particles. */ class tcParticlePlacer: public CenteredPlacer --- 25,32 ---- { ! /** ! * A point-shaped particle placer. ! * This placer class uses the center point defined in its base class <CODE>CenteredPlacer</CODE> ! * to place there all incoming particles. */ class tcParticlePlacer: public CenteredPlacer *************** *** 42,47 **** --- 43,54 ---- */ inline void place(Particle *P) const; + inline void placeAlongPath(Particle *P, float a) const; + inline void setApplyJitter(bool applyJitter); + inline void setCenter(float x, float y, float z); protected: + osg::Vec3 previousCenter; + bool applyJitter_; ///< true to randomize placement of particle + virtual ~tcParticlePlacer() {} tcParticlePlacer &operator=(const tcParticlePlacer &) { return *this; } *************** *** 51,55 **** inline tcParticlePlacer::tcParticlePlacer() ! : CenteredPlacer() { } --- 58,62 ---- inline tcParticlePlacer::tcParticlePlacer() ! : CenteredPlacer(), previousCenter(0, 0, 0), applyJitter_(false) { } *************** *** 62,69 **** inline void tcParticlePlacer::place(Particle *P) const { ! P->setPosition(getCenter()); } } --- 69,137 ---- inline void tcParticlePlacer::place(Particle *P) const { ! float a; ! ! if (applyJitter_) ! { ! a = 1.1f * (float)rand() / (float)RAND_MAX; ! } ! else ! { ! a = 1.0; ! } ! float b = 1.0 - a; ! ! osg::Vec3 cen = getCenter(); ! osg::Vec3 p(a*cen._v[0] + b*previousCenter._v[0], ! a*cen._v[1] + b*previousCenter._v[1], ! a*cen._v[2] + b*previousCenter._v[2]); ! ! P->setPosition(p); } + /** + * Places particle along path between current time and last update position. + * @param a fraction of distance traveled over last time step to place particle + */ + inline void tcParticlePlacer::placeAlongPath(Particle *P, float a) const + { + if (applyJitter_) + { + a = a + 0.05f * (float)rand() * 3.052e-5; + } + float b = 1.0 - a; + + osg::Vec3 cen = getCenter(); + osg::Vec3 p(b*cen._v[0] + a*previousCenter._v[0], + b*cen._v[1] + a*previousCenter._v[1], + b*cen._v[2] + a*previousCenter._v[2]); + + P->setPosition(p); + } + + inline void tcParticlePlacer::setApplyJitter(bool applyJitter) + { + applyJitter_ = applyJitter; + } + + inline void tcParticlePlacer::setCenter(float x, float y, float z) + { + const osg::Vec3& cen = getCenter(); + + /* ignore and return if center hasn't changed + ** This avoids an invalid previousCenter when setCenter + ** is called more than once at the same time step + */ + float absDiff = abs(cen._v[0] - x) + + abs(cen._v[1] - y) + + abs(cen._v[2] - z); + if (absDiff < 0.01) return; + + previousCenter = cen; + CenteredPlacer::setCenter(x, y, z); + + + + } } Index: tcMapObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcMapObject.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcMapObject.h 8 Aug 2004 00:31:32 -0000 1.4 --- tcMapObject.h 1 Sep 2004 02:55:35 -0000 1.5 *************** *** 37,40 **** --- 37,44 ---- #include "simmath.h" + /** + * Windows GDI+ library TO BE REPLACED with a cross-platform library + * or cross-platform wrapper. + */ namespace Gdiplus { Index: tcParticleEffect.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcParticleEffect.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcParticleEffect.h 4 Jun 2004 21:39:22 -0000 1.1 --- tcParticleEffect.h 1 Sep 2004 02:55:35 -0000 1.2 *************** *** 37,40 **** --- 37,42 ---- class ModularProgram; class AccelOperator; + class SmokeTrailEmitter; + class Emitter; } *************** *** 54,59 **** }; - static void SetParticleSystemUpdater(osgParticle::ParticleSystemUpdater* psu); - osgParticle::tcParticlePlacer* GetParticlePlacer() const {return particlePlacer;} --- 56,59 ---- *************** *** 66,70 **** private: int smokeMode; ! osg::ref_ptr<osgParticle::ModularEmitter> emitter; osg::ref_ptr<osgParticle::RadialShooter> shooter; osg::ref_ptr<osgParticle::RandomRateCounter> counter; --- 66,70 ---- private: int smokeMode; ! osg::ref_ptr<osgParticle::Emitter> emitter; osg::ref_ptr<osgParticle::RadialShooter> shooter; osg::ref_ptr<osgParticle::RandomRateCounter> counter; *************** *** 77,82 **** osg::Group* root; - static osgParticle::ParticleSystemUpdater* particleSystemUpdater; - void ConfigureForMode(); }; --- 77,80 ---- |
|
From: Dewitt C. <ddc...@us...> - 2004-09-01 02:56:27
|
Update of /cvsroot/gcblue/gcb_wx/include/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9034/include/database Modified Files: tcDatabase.h Log Message: Index: tcDatabase.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDatabase.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcDatabase.h 8 Aug 2004 00:31:32 -0000 1.7 --- tcDatabase.h 1 Sep 2004 02:55:35 -0000 1.8 *************** *** 40,43 **** --- 40,49 ---- #include "gctypes.h" + /** + * Contains database code for hierarchical database structure. + * Historically this database started with a binary format, then went to a + * csv flat text format, and then finally SQL. An XML write-only format was + * also added to support a web effort that lost steam. + */ namespace Database { |
|
From: Dewitt C. <ddc...@us...> - 2004-09-01 02:56:26
|
Update of /cvsroot/gcblue/gcb_wx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9034 Modified Files: GCblue.vcproj Log Message: Index: GCblue.vcproj =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/GCblue.vcproj,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** GCblue.vcproj 16 Aug 2004 01:43:28 -0000 1.64 --- GCblue.vcproj 1 Sep 2004 02:55:33 -0000 1.65 *************** *** 240,243 **** --- 240,246 ---- </File> <File + RelativePath=".\src\graphics\SmokeTrailEmitter.cpp"> + </File> + <File RelativePath="src\graphics\tc2DGraphicsSurface.cpp"> </File> *************** *** 1077,1080 **** --- 1080,1086 ---- </File> <File + RelativePath=".\include\graphics\SmokeTrailEmitter.h"> + </File> + <File RelativePath="include\graphics\tc2DGraphicsSurface.h"> </File> |
|
From: Dewitt C. <ddc...@us...> - 2004-09-01 02:55:48
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9034/src/sim Modified Files: tcScenarioSelectView.cpp Log Message: Index: tcScenarioSelectView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcScenarioSelectView.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcScenarioSelectView.cpp 9 Aug 2004 02:35:16 -0000 1.16 --- tcScenarioSelectView.cpp 1 Sep 2004 02:55:37 -0000 1.17 *************** *** 36,41 **** using namespace Gdiplus; /** ! * Intialize the tcScenarioSelectView object. */ bool tcScenarioSelectView::Init() --- 36,162 ---- using namespace Gdiplus; + + tcScenarioSelectView::wxScenarioTraverser::wxScenarioTraverser( + std::vector<scenarioInfo>& sInfo) + : info(sInfo) + { + } + + + wxDirTraverseResult tcScenarioSelectView::wxScenarioTraverser + ::OnFile(const wxString& filename) + { + /* if the file does not end in .py then return + ** otherwise save the path up to the last \ in path + ** and the remainder (without the .py extension) in + ** caption + */ + + int findIdx = filename.find(".py"); + if ((findIdx == -1) || (findIdx != filename.size() - 3)) return wxDIR_CONTINUE; + + + + wxString scenarioDir(SCENARIO_PATH); + size_t scenarioDirLength = scenarioDir.size(); + + findIdx = filename.find(scenarioDir); + if (findIdx == -1) + { + fprintf(stderr, "Corrupt scen structure\n"); + return wxDIR_CONTINUE; + } + + wxString pathString = filename.Mid(findIdx); + + findIdx = pathString.find_last_of("\\"); + + wxString captionString = pathString.Mid(findIdx+1); + captionString = captionString.BeforeLast('.'); // remove extension + + scenarioInfo scen; + scen.path = pathString.GetData(); + scen.caption = captionString.GetData(); + + info.push_back(scen); + + return wxDIR_CONTINUE; + } + + wxDirTraverseResult tcScenarioSelectView::wxScenarioTraverser + ::OnDir(const wxString& dirname) + { + if (dirname == "CVS") return wxDIR_IGNORE; + + // create a candidate parent, and then run traverser to find children + scenarioInfo parent; + + + wxDir scenarioDir(dirname); + wxScenarioTraverser traverser(parent.children); + scenarioDir.Traverse(traverser); + + // if any children are found, add this parent to the scenarioInfo member + if (parent.children.size()) + { + parent.caption = dirname.AfterLast('\\'); + info.push_back(parent); + } + + return wxDIR_CONTINUE; + } + + + + /** ! * Scan scenario directories and populate scenInfo ! */ ! void tcScenarioSelectView::BuildScenarioInfo() ! { ! wxString cwd = wxGetCwd(); ! cwd += wxString::Format("\\%s", SCENARIO_PATH); ! ! wxDir scenarioDir(cwd); ! ! if (scenarioDir.IsOpened()) ! { ! wxScenarioTraverser traverser(scenInfo); ! scenarioDir.Traverse(traverser); ! } ! else ! { ! scenInfo.clear(); ! wxMessageBox("scenario directory does not exist!"); ! return; ! } ! ! } ! ! /** ! * recursive method to write scenarioInfo vector to stdout ! */ ! void tcScenarioSelectView::LogScenarioInfo(std::vector<scenarioInfo>& info, int level) ! { ! ! ! for (size_t ind=0; ind<info.size(); ++ind) ! { ! for (int i=0; i<level; ++i) ! { ! fprintf(stdout, " "); ! } ! fprintf(stdout, "%s (%s)\n", info[ind].caption.c_str(), info[ind].path.c_str()); ! if (info[ind].children.size()) ! { ! LogScenarioInfo(info[ind].children, level + 1); ! } ! } ! ! ! } ! ! /** ! * Initialize the tcScenarioSelectView object. */ bool tcScenarioSelectView::Init() *************** *** 83,86 **** --- 204,209 ---- } + BuildScenarioInfo(); + LogScenarioInfo(scenInfo, 0); return true; } *************** *** 434,437 **** --- 557,562 ---- } + + /** * Gets a list of all scenario files that are available. |
|
From: Dewitt C. <ddc...@us...> - 2004-09-01 02:55:45
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9034/src/graphics Modified Files: tcParticleEffect.cpp Added Files: SmokeTrailEmitter.cpp Log Message: Index: tcParticleEffect.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcParticleEffect.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcParticleEffect.cpp 4 Jun 2004 21:39:22 -0000 1.1 --- tcParticleEffect.cpp 1 Sep 2004 02:55:36 -0000 1.2 *************** *** 27,30 **** --- 27,31 ---- #include <osgParticle/ParticleSystem> #include <osgParticle/ParticleSystemUpdater> + #include <osgParticle/Emitter> #include <osgParticle/ModularEmitter> #include <osgParticle/ModularProgram> *************** *** 35,38 **** --- 36,41 ---- #include <osgParticle/FluidFrictionOperator> + #include <graphics/SmokeTrailEmitter.h> + #include "stdwx.h" // precompiled header file *************** *** 123,134 **** - osgParticle::ParticleSystemUpdater* tcParticleEffect::particleSystemUpdater = NULL; - - void tcParticleEffect::SetParticleSystemUpdater(osgParticle::ParticleSystemUpdater* psu) - { - particleSystemUpdater = psu; - } - - void tcParticleEffect::AddToSceneGraph(osg::Group* rootGroup) { --- 126,129 ---- *************** *** 168,172 **** ! counter->setRateRange(30, 50); switch (smokeMode) --- 163,167 ---- ! switch (smokeMode) *************** *** 174,192 **** case MISSILE: { ! ptemplate.setLifeTime(3); // 3 seconds of life ! ptemplate.setSizeRange(osgParticle::rangef(0.75f, 3.0f)); ! ptemplate.setAlphaRange(osgParticle::rangef(0.0f, 1.5f)); ptemplate.setColorRange(osgParticle::rangev4( ! osg::Vec4(0.8f, 0.8f, 0.8f, 1.5f), ! osg::Vec4(0, 0.7f, 1.0f, 0.0f))); ! ptemplate.setRadius(1.5f); // 5 cm wide particles ! ptemplate.setMass(0.05f); // 50 g heavy ! shooter->setInitialSpeedRange(0, 0); ! accelOp->setAcceleration(osg::Vec3(0, 0, 0)); } break; case AFTERBURNER: { ptemplate.setLifeTime(3); // 3 seconds of life ptemplate.setSizeRange(osgParticle::rangef(0.75f, 3.0f)); --- 169,192 ---- case MISSILE: { ! //counter->setRateRange(300, 350); ! ptemplate.setLifeTime(2); ! ptemplate.setSizeRange(osgParticle::rangef(0.5f, 10.0f)); ! ptemplate.setAlphaRange(osgParticle::rangef(0.0f, 0.5f)); ptemplate.setColorRange(osgParticle::rangev4( ! osg::Vec4(0.8f, 0.8f, 0.8f, 0.2f), ! osg::Vec4(0, 0.7f, 1.0f, 0.5f))); ! ptemplate.setRadius(1.0f); ! ptemplate.setMass(0.05f); ! //shooter->setInitialSpeedRange(0, 0); ! accelOp->setAcceleration(osg::Vec3(0, 0, -0.0f)); ! ! particlePlacer->setApplyJitter(true); ! } break; case AFTERBURNER: { + counter->setRateRange(300, 350); ptemplate.setLifeTime(3); // 3 seconds of life ptemplate.setSizeRange(osgParticle::rangef(0.75f, 3.0f)); *************** *** 204,207 **** --- 204,208 ---- case DAMAGE: { + counter->setRateRange(20, 40); ptemplate.setLifeTime(8); // 3 seconds of life ptemplate.setSizeRange(osgParticle::rangef(2.5f, 5.0f)); *************** *** 267,304 **** : root(0), smokeMode(smokeModeCode) { ! emitter = new osgParticle::ModularEmitter; ! emitter->setParticleSystem(this); ! counter = new osgParticle::RandomRateCounter; ! emitter->setCounter(counter.get()); ! particlePlacer = new osgParticle::tcParticlePlacer; ! particlePlacer->setCenter(0, 0, 0); ! emitter->setPlacer(particlePlacer); ! emitter->setReferenceFrame(osgParticle::Emitter::RELATIVE_TO_ABSOLUTE); ! shooter = new osgParticle::RadialShooter; ! emitter->setShooter(shooter.get()); ! program = new osgParticle::ModularProgram; ! program->setParticleSystem(this); ! // create an operator that simulates the gravity acceleration. ! accelOp = new osgParticle::AccelOperator; ! program->addOperator(accelOp.get()); ! /* ! VortexOperator *op2 = new VortexOperator; ! op2->setCenter(osg::Vec3(8, 0, 0)); ! program->addOperator(op2); ! // fluid operator to simulate air friction. ! osgParticle::FluidFrictionOperator *op3 = new osgParticle::FluidFrictionOperator; ! op3->setFluidToAir(); ! program->addOperator(op3); ! */ ConfigureForMode(); --- 268,321 ---- : root(0), smokeMode(smokeModeCode) { ! if (smokeModeCode == MISSILE) ! { ! osgParticle::SmokeTrailEmitter* smokeTrailEmitter = ! new osgParticle::SmokeTrailEmitter; ! emitter = smokeTrailEmitter; ! smokeTrailEmitter->setParticleSystem(this); ! particlePlacer = new osgParticle::tcParticlePlacer; ! particlePlacer->setCenter(0, 0, 0); ! smokeTrailEmitter->setPlacer(particlePlacer); ! smokeTrailEmitter->setReferenceFrame(osgParticle::Emitter::RELATIVE_TO_ABSOLUTE); ! program = new osgParticle::ModularProgram; ! program->setParticleSystem(this); ! // create an operator that simulates the gravity acceleration. ! accelOp = new osgParticle::AccelOperator; ! program->addOperator(accelOp.get()); ! } ! else ! { ! osgParticle::ModularEmitter* modularEmitter = new osgParticle::ModularEmitter; ! emitter = modularEmitter; ! modularEmitter->setParticleSystem(this); + counter = new osgParticle::RandomRateCounter; ! modularEmitter->setCounter(counter.get()); ! particlePlacer = new osgParticle::tcParticlePlacer; ! particlePlacer->setCenter(0, 0, 0); ! modularEmitter->setPlacer(particlePlacer); ! modularEmitter->setReferenceFrame(osgParticle::Emitter::RELATIVE_TO_ABSOLUTE); ! shooter = new osgParticle::RadialShooter; ! ! modularEmitter->setShooter(shooter.get()); ! ! ! program = new osgParticle::ModularProgram; ! program->setParticleSystem(this); ! ! // create an operator that simulates the gravity acceleration. ! accelOp = new osgParticle::AccelOperator; ! program->addOperator(accelOp.get()); ! ! } ConfigureForMode(); --- NEW FILE: SmokeTrailEmitter.cpp --- #include <graphics/SmokeTrailEmitter.h> #include <osgParticle/Emitter> //#pragma warning (disable: 4273) // inconsistent dll linkage void osgParticle::SmokeTrailEmitter::InitializeCloseupTemplate() { Particle standardTemplate; standardTemplate.setLifeTime(2); standardTemplate.setSizeRange(osgParticle::rangef(0.5f, 1.0f)); standardTemplate.setAlphaRange(osgParticle::rangef(0.2f, 0.5f)); standardTemplate.setColorRange(osgParticle::rangev4( osg::Vec4(0.5f, 0.5f, 0.5f, 0.5f), osg::Vec4(0.7, 0.7f, 0.7f, 1.0f))); //standardTemplate.setRadius(0.1f); standardTemplate.setMass(0.05f); setParticleTemplate(standardTemplate); closeUpTemplate.setLifeTime(0.2); closeUpTemplate.setSizeRange(osgParticle::rangef(0.4f, 0.5f)); closeUpTemplate.setAlphaRange(osgParticle::rangef(0.3f, 0.1f)); closeUpTemplate.setColorRange(osgParticle::rangev4( osg::Vec4(0.5f, 0.5f, 0.5f, 1.0f), osg::Vec4(0.7, 0.7f, 0.7f, 0.5f))); //closeUpTemplate.setRadius(0.1f); closeUpTemplate.setMass(0.05f); } osgParticle::SmokeTrailEmitter::SmokeTrailEmitter() : Emitter(), placer_(new tcParticlePlacer) { InitializeCloseupTemplate(); } osgParticle::SmokeTrailEmitter::SmokeTrailEmitter(const SmokeTrailEmitter ©, const osg::CopyOp ©op) : Emitter(copy, copyop), placer_(static_cast<tcParticlePlacer*>(copyop(copy.placer_.get()))) { InitializeCloseupTemplate(); } void osgParticle::SmokeTrailEmitter::emit(double dt) { int n = 30; for (int i=0; i<n; ++i) { if (i==0) { if (Particle* P = getParticleSystem()->createParticle(&getParticleTemplate())) { placer_->placeAlongPath(P, 1.2f); } } else if (Particle* P = getParticleSystem()->createParticle(&closeUpTemplate)) { float fractionalDistance = 0.2f + float(i) / float(n); placer_->placeAlongPath(P, fractionalDistance); } } } |
|
From: Dewitt C. <ddc...@us...> - 2004-09-01 02:55:45
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9034/include/sim Modified Files: tcScenarioSelectView.h tcSensorMap.h Log Message: Index: tcSensorMap.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSensorMap.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcSensorMap.h 8 Aug 2004 00:31:33 -0000 1.7 --- tcSensorMap.h 1 Sep 2004 02:55:36 -0000 1.8 *************** *** 34,37 **** --- 34,41 ---- class tcUpdateStream; + /** + * Sensor track management code. This is older code + * that needs refactoring. + */ namespace Sensor { Index: tcScenarioSelectView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcScenarioSelectView.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcScenarioSelectView.h 17 Aug 2004 02:22:56 -0000 1.8 --- tcScenarioSelectView.h 1 Sep 2004 02:55:36 -0000 1.9 *************** *** 1,6 **** /* ! ** tcScenarioSelectView.h ! ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- /* ! ** @file tcScenarioSelectView.h ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 28,34 **** --- 28,36 ---- #include "wx/wx.h" + #include "wx/dir.h" #ifdef WIN32 #include "wx/msw/private.h" // for MS Windows specific definitions #endif + #include "tcwindow.h" #include "tcSound.h" *************** *** 41,48 **** #endif ! // TODO: this class along with StartView class should be derived from a more ! // general button interface or user interface class class tcScenarioSelectView : public tcWindow { public: // placement info for GUI buttons, text, etc. --- 43,75 ---- #endif ! /** ! * TODO: this class along with StartView class should be derived from a more ! * general button interface or user interface class ! */ class tcScenarioSelectView : public tcWindow { + struct scenarioInfo + { + std::string path; ///< path after SCENARIO_PATH including filename + std::string caption; ///< dir name or filename without the .py extension + std::vector<scenarioInfo> children; + }; + + /** + * Directory traverser to build scenario tree + */ + class wxScenarioTraverser : public wxDirTraverser + { + public: + wxScenarioTraverser(std::vector<scenarioInfo>& sInfo); + + wxDirTraverseResult OnFile(const wxString& filename); + + wxDirTraverseResult OnDir(const wxString& WXUNUSED(dirname)); + + private: + std::vector<scenarioInfo>& info; + }; + public: // placement info for GUI buttons, text, etc. *************** *** 65,75 **** void AttachOptions(tcOptions *apOptions) {mpOptions=apOptions;} void AttachSimState(tcSimState *apSimState) {mpSimState=apSimState;} ! bool Init(void); ! int Draw(void); void DrawButton(Gdiplus::Graphics *apGraphics, unsigned anButton); ! int GetActiveButton(void) {return mnActiveButton;} void OnLButtonDown(wxMouseEvent& event); void OnMouseMove(wxMouseEvent& event); ! void PlaceButtons(void); bool ButtonContainingPoint(wxPoint point, unsigned& rnButton); tcScenarioSelectView(wxWindow *parent, --- 92,102 ---- void AttachOptions(tcOptions *apOptions) {mpOptions=apOptions;} void AttachSimState(tcSimState *apSimState) {mpSimState=apSimState;} ! bool Init(); ! int Draw(); void DrawButton(Gdiplus::Graphics *apGraphics, unsigned anButton); ! int GetActiveButton() {return mnActiveButton;} void OnLButtonDown(wxMouseEvent& event); void OnMouseMove(wxMouseEvent& event); ! void PlaceButtons(); bool ButtonContainingPoint(wxPoint point, unsigned& rnButton); tcScenarioSelectView(wxWindow *parent, *************** *** 77,81 **** const wxString& name = "ScenarioSelectView", tcWindow *sharedSurface = NULL); ! virtual ~tcScenarioSelectView(void); private: enum {MAX_START_BUTTONS = 16}; --- 104,108 ---- const wxString& name = "ScenarioSelectView", tcWindow *sharedSurface = NULL); ! virtual ~tcScenarioSelectView(); private: enum {MAX_START_BUTTONS = 16}; *************** *** 91,100 **** --- 118,134 ---- int mnButtonHeight; + std::vector<scenarioInfo> scenInfo; tsButtonInfo maButton[MAX_START_BUTTONS]; int mnXStart,mnYStart; tcSimState *mpSimState; + void BuildScenarioInfo(); wxArrayString GetListOfScenarioFiles(); + void LogScenarioInfo(std::vector<scenarioInfo>& info, int level); + }; + + + #endif \ No newline at end of file |
|
From: Dewitt C. <ddc...@us...> - 2004-09-01 02:55:45
|
Update of /cvsroot/gcblue/gcb_wx/include/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9034/include/network Modified Files: tcMultiplayerInterface.h Log Message: Index: tcMultiplayerInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/network/tcMultiplayerInterface.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcMultiplayerInterface.h 8 Aug 2004 00:31:32 -0000 1.16 --- tcMultiplayerInterface.h 1 Sep 2004 02:55:36 -0000 1.17 *************** *** 40,43 **** --- 40,50 ---- class tcConsoleBox; + /** + * Multiplayer network code. + */ + namespace network + { + } + BEGIN_NAMESPACE(network) |
|
From: Dewitt C. <ddc...@us...> - 2004-09-01 02:55:45
|
Update of /cvsroot/gcblue/gcb_wx/include/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9034/include/scriptinterface Modified Files: tcSimPythonInterface.h Log Message: Index: tcSimPythonInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/scriptinterface/tcSimPythonInterface.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcSimPythonInterface.h 16 Aug 2004 01:43:30 -0000 1.14 --- tcSimPythonInterface.h 1 Sep 2004 02:55:36 -0000 1.15 *************** *** 50,54 **** using namespace Sensor; ! namespace ScriptInterface { /** * Interface class for creating popup mouse menus. --- 50,59 ---- using namespace Sensor; ! /** ! * Embedded python scripting interface code. ! * Contains all python interface classes. ! */ ! namespace ScriptInterface ! { /** * Interface class for creating popup mouse menus. |
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19191/include/sim Modified Files: tcAIData.h tcAero.h tcAeroAirObject.h tcAirfieldObject.h tcBallisticWeapon.h tcCarrierObject.h tcChatBox.h tcCreditView.h tcCustomControl.h tcDirector.h tcDirectorEvent.h tcESMSensor.h tcEditControl.h tcEngagementData.h tcFlightOpsObject.h tcGameObjIterator.h tcGameView.h tcGoal.h tcGuidanceState.h tcHookInfo.h tcLaunchRequest.h tcMapView.h tcMenu.h tcMissileObject.h tcNetworkView.h tcOOBView.h tcObjectControl.h tcPanel.h tcPopupControl.h tcRadar.h tcScenarioSelectView.h tcSensorState.h tcStartView.h tcSurfaceObject.h tcTerrainView.h tcTime.h tcWeaponObject.h Log Message: Index: tcDirector.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcDirector.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcDirector.h 8 Aug 2004 00:31:33 -0000 1.7 --- tcDirector.h 17 Aug 2004 02:22:56 -0000 1.8 *************** *** 24,28 **** --- 24,30 ---- #define _TCDIRECTOR_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcObjectControl.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcObjectControl.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcObjectControl.h 8 Aug 2004 00:31:33 -0000 1.6 --- tcObjectControl.h 17 Aug 2004 02:22:56 -0000 1.7 *************** *** 23,27 **** --- 23,29 ---- #define _OBJECTCONTROL_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcOOBView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcOOBView.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcOOBView.h 8 Aug 2004 00:31:33 -0000 1.5 --- tcOOBView.h 17 Aug 2004 02:22:56 -0000 1.6 *************** *** 24,28 **** --- 24,30 ---- #define _OOBVIEW_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" *************** *** 52,57 **** tcDBString mzName; tnPoolIndex mnLeaderID; ! unsigned maFollowers[MAX_FOLLOWERS]; ! unsigned char mnFollowers; bool mbRadiating; float mfDamage_fract; ///< damage over toughness --- 54,58 ---- tcDBString mzName; tnPoolIndex mnLeaderID; ! std::vector<unsigned> maFollowers; bool mbRadiating; float mfDamage_fract; ///< damage over toughness *************** *** 61,64 **** --- 62,67 ---- Gdiplus::RectF rdamage; ///< location for damage indicator Gdiplus::RectF raction; ///< loc for action string + + tsOOBInfo& operator= (const tsOOBInfo& rhs); }; *************** *** 69,81 **** * - Formation indication (tree view possibly) * weapons are not displayed */ class tcOOBView : public tcWindow { public: ! tcSimState *mpSimState; // sim state to retrieve platforms from tcTacticalMapView *mpMapView; ! int mnAlliance; // alliance to display ! unsigned mnCount; // current size of maOOB ! tsOOBInfo maOOB[MAX_OOB_OBJECTS]; tnPoolIndex mnSelectedKey; struct --- 72,89 ---- * - Formation indication (tree view possibly) * weapons are not displayed + * + * All of the code in this section is out of date and needs refactoring */ class tcOOBView : public tcWindow { public: ! tcSimState* mpSimState; ///< for retrieving platform info tcTacticalMapView *mpMapView; ! int mnAlliance; ///< alliance to display ! ! std::vector<tsOOBInfo> surfaceObj; ! std::vector<tsOOBInfo> airObj; ! std::vector<tsOOBInfo> flightopsObj; ///< carriers and airfields ! tnPoolIndex mnSelectedKey; struct *************** *** 87,93 **** void AttachMapView(tcTacticalMapView *apMapView) {mpMapView = apMapView;} ! void AttachSimState(tcSimState *apSimState) {mpSimState = apSimState;} ! void Update(void); ! int Draw(void); void OnLButtonDown(wxMouseEvent& event); void OnLButtonUp(wxMouseEvent& event); --- 95,100 ---- void AttachMapView(tcTacticalMapView *apMapView) {mpMapView = apMapView;} ! void Update(); ! int Draw(); void OnLButtonDown(wxMouseEvent& event); void OnLButtonUp(wxMouseEvent& event); *************** *** 104,116 **** float mfXOffset; float mfXIndent; ///< indent for formations Gdiplus::SolidBrush* mpBrush; Gdiplus::Pen* mpPen; Gdiplus::Font* mpFont; ! bool ButtonContainingPoint(Gdiplus::PointF pointf, unsigned& nRow); void PlaceIcons(Gdiplus::Graphics *apGraphics); ! void UpdateData(void); ! void UpdateFormation(void); ! void UpdateRect(void); }; --- 111,132 ---- float mfXOffset; float mfXIndent; ///< indent for formations + tnPoolIndex objKeys[MAX_OOB_OBJECTS]; Gdiplus::SolidBrush* mpBrush; Gdiplus::Pen* mpPen; Gdiplus::Font* mpFont; ! tsOOBInfo* ButtonContainingPoint(Gdiplus::PointF pointf); ! tsOOBInfo* ButtonContainingPointCategory(Gdiplus::PointF pointf, ! std::vector<tsOOBInfo>& objInfo); ! ! void DrawCategory(Gdiplus::Graphics* graphics, ! std::vector<tsOOBInfo>& objInfo, float stopy); ! float GetCategoryY(std::vector<tsOOBInfo>& objInfo); void PlaceIcons(Gdiplus::Graphics *apGraphics); ! void PlaceIconsCategory(Gdiplus::Graphics* graphics, std::vector<tsOOBInfo>& objInfo); ! void UpdateData(); ! void UpdateFormation(); ! void UpdateRect(); ! void UpdateRectCategory(std::vector<tsOOBInfo>& objInfo, float& y, float stopy); }; Index: tcCreditView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcCreditView.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcCreditView.h 8 Aug 2004 00:31:33 -0000 1.9 --- tcCreditView.h 17 Aug 2004 02:22:56 -0000 1.10 *************** *** 21,25 **** --- 21,27 ---- #define _CREDITVIEW_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcCustomControl.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcCustomControl.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcCustomControl.h 8 Aug 2004 00:31:33 -0000 1.4 --- tcCustomControl.h 17 Aug 2004 02:22:56 -0000 1.5 *************** *** 21,25 **** --- 21,27 ---- #define _CUSTOMCONTROL_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "tcwindow.h" Index: tcScenarioSelectView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcScenarioSelectView.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcScenarioSelectView.h 8 Aug 2004 00:31:33 -0000 1.7 --- tcScenarioSelectView.h 17 Aug 2004 02:22:56 -0000 1.8 *************** *** 23,27 **** --- 23,29 ---- #define _SCENARIOSELECTVIEW_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcGameObjIterator.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcGameObjIterator.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcGameObjIterator.h 8 Aug 2004 00:31:33 -0000 1.2 --- tcGameObjIterator.h 17 Aug 2004 02:22:56 -0000 1.3 *************** *** 22,26 **** --- 22,28 ---- #define _GAMEOBJITERATOR_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "simmath.h" Index: tcAeroAirObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcAeroAirObject.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcAeroAirObject.h 8 Aug 2004 00:31:33 -0000 1.5 --- tcAeroAirObject.h 17 Aug 2004 02:22:56 -0000 1.6 *************** *** 21,25 **** --- 21,27 ---- #define _AEROAIROBJECT_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "tcAirObject.h" Index: tcLaunchRequest.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcLaunchRequest.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcLaunchRequest.h 8 Aug 2004 00:31:33 -0000 1.2 --- tcLaunchRequest.h 17 Aug 2004 02:22:56 -0000 1.3 *************** *** 18,22 **** --- 18,24 ---- */ + #if _MSC_VER > 1000 #pragma once + #endif #ifndef _TCLAUNCHREQUEST_H_ Index: tcWeaponObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcWeaponObject.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcWeaponObject.h 8 Aug 2004 00:31:33 -0000 1.6 --- tcWeaponObject.h 17 Aug 2004 02:22:56 -0000 1.7 *************** *** 19,23 **** --- 19,25 ---- */ + #if _MSC_VER > 1000 #pragma once + #endif #ifndef _TCWEAPONOBJECT_H_ Index: tcGuidanceState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcGuidanceState.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcGuidanceState.h 8 Aug 2004 00:31:33 -0000 1.3 --- tcGuidanceState.h 17 Aug 2004 02:22:56 -0000 1.4 *************** *** 18,22 **** --- 18,24 ---- */ + #if _MSC_VER > 1000 #pragma once + #endif #ifndef _TCGUIDANCESTATE_H_ Index: tcRadar.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcRadar.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcRadar.h 8 Aug 2004 00:31:33 -0000 1.7 --- tcRadar.h 17 Aug 2004 02:22:56 -0000 1.8 *************** *** 18,22 **** --- 18,24 ---- */ + #if _MSC_VER > 1000 #pragma once + #endif #ifndef _tcRadar_H_ Index: tcFlightOpsObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcFlightOpsObject.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcFlightOpsObject.h 18 Jul 2004 03:18:00 -0000 1.2 --- tcFlightOpsObject.h 17 Aug 2004 02:22:56 -0000 1.3 *************** *** 21,25 **** --- 21,31 ---- */ + #ifndef _TCFLIGHTOPSOBJECT_H_ + #define _TCFLIGHTOPSOBJECT_H_ + + #if _MSC_VER > 1000 #pragma once + #endif + #include "tcFile.h" *************** *** 69,71 **** tcFlightOpsObject(); ! }; \ No newline at end of file --- 75,79 ---- tcFlightOpsObject(); ! }; ! ! #endif \ No newline at end of file Index: tcPanel.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcPanel.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcPanel.h 8 Aug 2004 00:31:33 -0000 1.5 --- tcPanel.h 17 Aug 2004 02:22:56 -0000 1.6 *************** *** 20,25 **** --- 20,29 ---- */ + #ifndef _TCPANEL_H_ + #define _TCPANEL_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" *************** *** 89,91 **** --- 93,96 ---- }; + #endif Index: tcChatBox.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcChatBox.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcChatBox.h 24 May 2004 00:14:46 -0000 1.1 --- tcChatBox.h 17 Aug 2004 02:22:56 -0000 1.2 *************** *** 22,26 **** --- 22,28 ---- #define _CHATBOX_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcAero.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcAero.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcAero.h 8 Aug 2004 00:31:33 -0000 1.5 --- tcAero.h 17 Aug 2004 02:22:56 -0000 1.6 *************** *** 25,29 **** --- 25,31 ---- #define _TCAERO_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "tcMissileDBObject.h" Index: tcCarrierObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcCarrierObject.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcCarrierObject.h 8 Aug 2004 00:31:33 -0000 1.9 --- tcCarrierObject.h 17 Aug 2004 02:22:56 -0000 1.10 *************** *** 18,22 **** --- 18,27 ---- */ + #ifndef _TCCARRIEROBJECT_H_ + #define _TCCARRIEROBJECT_H_ + + #if _MSC_VER > 1000 #pragma once + #endif #include "tcFile.h" *************** *** 48,50 **** tcCarrierObject(tcGenericDBObject *obj); virtual ~tcCarrierObject(); ! }; \ No newline at end of file --- 53,57 ---- tcCarrierObject(tcGenericDBObject *obj); virtual ~tcCarrierObject(); ! }; ! ! #endif \ No newline at end of file Index: tcEngagementData.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcEngagementData.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcEngagementData.h 8 Aug 2004 00:31:33 -0000 1.2 --- tcEngagementData.h 17 Aug 2004 02:22:56 -0000 1.3 *************** *** 18,22 **** --- 18,27 ---- */ + #ifndef _TCENGAGEMENTDATA_H_ + #define _TCENGAGEMENTDATA_H_ + + #if _MSC_VER > 1000 #pragma once + #endif #include "tcPool.h" *************** *** 42,44 **** tcEngagementData(); ! }; \ No newline at end of file --- 47,51 ---- tcEngagementData(); ! }; ! ! #endif \ No newline at end of file Index: tcHookInfo.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcHookInfo.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcHookInfo.h 8 Aug 2004 00:31:33 -0000 1.6 --- tcHookInfo.h 17 Aug 2004 02:22:56 -0000 1.7 *************** *** 24,28 **** --- 24,30 ---- #define _HOOKINFO_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcAIData.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcAIData.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcAIData.h 8 Aug 2004 00:31:33 -0000 1.7 --- tcAIData.h 17 Aug 2004 02:22:56 -0000 1.8 *************** *** 21,25 **** --- 21,27 ---- #define _AIDATA_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "simmath.h" Index: tcPopupControl.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcPopupControl.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcPopupControl.h 16 Aug 2004 01:43:30 -0000 1.5 --- tcPopupControl.h 17 Aug 2004 02:22:56 -0000 1.6 *************** *** 24,28 **** --- 24,30 ---- #define _POPUPCONTROL_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcESMSensor.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcESMSensor.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcESMSensor.h 24 May 2004 00:14:46 -0000 1.4 --- tcESMSensor.h 17 Aug 2004 02:22:56 -0000 1.5 *************** *** 18,26 **** */ - #pragma once - #ifndef _tcESMSensor_H_ #define _tcESMSensor_H_ #include "tcSensorState.h" #include "tcDatabase.h" --- 18,28 ---- */ #ifndef _tcESMSensor_H_ #define _tcESMSensor_H_ + #if _MSC_VER > 1000 + #pragma once + #endif + #include "tcSensorState.h" #include "tcDatabase.h" Index: tcAirfieldObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcAirfieldObject.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcAirfieldObject.h 18 Jul 2004 03:18:00 -0000 1.1 --- tcAirfieldObject.h 17 Aug 2004 02:22:56 -0000 1.2 *************** *** 20,24 **** --- 20,29 ---- */ + #ifndef _TCAIRFIELDOBJECT_H_ + #define _TCAIRFIELDOBJECT_H_ + + #if _MSC_VER > 1000 #pragma once + #endif #include "tcFile.h" *************** *** 47,49 **** tcAirfieldObject(tcGenericDBObject* obj); virtual ~tcAirfieldObject(); ! }; \ No newline at end of file --- 52,56 ---- tcAirfieldObject(tcGenericDBObject* obj); virtual ~tcAirfieldObject(); ! }; ! ! #endif \ No newline at end of file Index: tcEditControl.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcEditControl.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcEditControl.h 8 Aug 2004 00:31:33 -0000 1.6 --- tcEditControl.h 17 Aug 2004 02:22:56 -0000 1.7 *************** *** 21,25 **** --- 21,27 ---- #define _EDITCONTROL_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "tcCustomControl.h" Index: tcMapView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcMapView.h,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** tcMapView.h 16 Aug 2004 01:43:30 -0000 1.24 --- tcMapView.h 17 Aug 2004 02:22:56 -0000 1.25 *************** *** 24,28 **** --- 24,30 ---- #define _MAPVIEW_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcBallisticWeapon.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcBallisticWeapon.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcBallisticWeapon.h 5 Aug 2004 02:22:35 -0000 1.3 --- tcBallisticWeapon.h 17 Aug 2004 02:22:56 -0000 1.4 *************** *** 19,27 **** */ - #pragma once - #ifndef _TCBALLISTICWEAPON_H_ #define _TCBALLISTICWEAPON_H_ #include "tcWeaponObject.h" --- 19,29 ---- */ #ifndef _TCBALLISTICWEAPON_H_ #define _TCBALLISTICWEAPON_H_ + #if _MSC_VER > 1000 + #pragma once + #endif + #include "tcWeaponObject.h" Index: tcGoal.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcGoal.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcGoal.h 29 Dec 2003 01:10:25 -0000 1.2 --- tcGoal.h 17 Aug 2004 02:22:56 -0000 1.3 *************** *** 1,10 **** - #ifdef WIN32 - #pragma once - #endif #ifndef _TCGOAL_H_ #define _TCGOAL_H_ #include <vector> --- 1,31 ---- + /** + ** @file tcGoal.h + */ + /* Copyright (C) 2003 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 + */ #ifndef _TCGOAL_H_ #define _TCGOAL_H_ + #ifdef WIN32 + #pragma once + #endif + #include <vector> Index: tcStartView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcStartView.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcStartView.h 8 Aug 2004 00:31:33 -0000 1.7 --- tcStartView.h 17 Aug 2004 02:22:56 -0000 1.8 *************** *** 21,25 **** --- 21,27 ---- #define _STARTVIEW_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcMissileObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcMissileObject.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcMissileObject.h 8 Aug 2004 00:31:33 -0000 1.11 --- tcMissileObject.h 17 Aug 2004 02:22:56 -0000 1.12 *************** *** 18,22 **** --- 18,24 ---- */ + #if _MSC_VER > 1000 #pragma once + #endif #ifndef _TCMISSLEOBJECT_H_ Index: tcMenu.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcMenu.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcMenu.h 8 Aug 2004 00:31:33 -0000 1.5 --- tcMenu.h 17 Aug 2004 02:22:56 -0000 1.6 *************** *** 19,23 **** --- 19,28 ---- + #if _MSC_VER > 1000 #pragma once + #endif + + #ifndef _TCMENU_H_ + #define _TCMENU_H_ #include "wx/wx.h" *************** *** 90,91 **** --- 95,97 ---- + #endif \ No newline at end of file Index: tcDirectorEvent.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcDirectorEvent.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcDirectorEvent.h 8 Aug 2004 00:31:33 -0000 1.8 --- tcDirectorEvent.h 17 Aug 2004 02:22:56 -0000 1.9 *************** *** 24,28 **** --- 24,30 ---- #define _TCDIRECTOREVENT_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcTime.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcTime.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcTime.h 8 Aug 2004 00:31:33 -0000 1.6 --- tcTime.h 17 Aug 2004 02:22:56 -0000 1.7 *************** *** 17,21 **** --- 17,27 ---- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + #if _MSC_VER > 1000 #pragma once + #endif + + #ifndef _TCTIME_H_ + #define _TCTIME_H_ #include <wx/wx.h> *************** *** 41,43 **** tcTime(); ~tcTime(); ! }; \ No newline at end of file --- 47,51 ---- tcTime(); ~tcTime(); ! }; ! ! #endif \ No newline at end of file Index: tcGameView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcGameView.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcGameView.h 8 Aug 2004 00:31:33 -0000 1.8 --- tcGameView.h 17 Aug 2004 02:22:56 -0000 1.9 *************** *** 24,28 **** --- 24,30 ---- #define _GAMEVIEW_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcSensorState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSensorState.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcSensorState.h 24 May 2004 00:14:46 -0000 1.10 --- tcSensorState.h 17 Aug 2004 02:22:56 -0000 1.11 *************** *** 19,23 **** --- 19,25 ---- */ + #if _MSC_VER > 1000 #pragma once + #endif #ifndef _TCSENSORSTATE_H_ Index: tcTerrainView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcTerrainView.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcTerrainView.h 8 Aug 2004 00:31:33 -0000 1.7 --- tcTerrainView.h 17 Aug 2004 02:22:56 -0000 1.8 *************** *** 24,28 **** --- 24,30 ---- #define _TERRAINVIEW_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcNetworkView.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcNetworkView.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcNetworkView.h 8 Aug 2004 00:31:33 -0000 1.6 --- tcNetworkView.h 17 Aug 2004 02:22:56 -0000 1.7 *************** *** 22,26 **** --- 22,28 ---- #define _NETWORKVIEW_H_ + #if _MSC_VER > 1000 #pragma once + #endif #include "wx/wx.h" Index: tcSurfaceObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSurfaceObject.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcSurfaceObject.h 8 Aug 2004 00:31:33 -0000 1.8 --- tcSurfaceObject.h 17 Aug 2004 02:22:56 -0000 1.9 *************** *** 18,22 **** --- 18,27 ---- */ + #if _MSC_VER > 1000 #pragma once + #endif + + #ifndef _TCSURFACEOBJECT_H_ + #define _TCSURFACEOBJECT_H_ #include "tcFile.h" *************** *** 59,61 **** virtual void ApplyRestrictions(void); virtual void UpdateClimb(float dt_s) {} // do nothing for surface objs ! }; \ No newline at end of file --- 64,68 ---- virtual void ApplyRestrictions(void); virtual void UpdateClimb(float dt_s) {} // do nothing for surface objs ! }; ! ! #endif \ No newline at end of file |
|
From: Dewitt C. <ddc...@us...> - 2004-08-17 02:26:26
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19191/include/graphics Modified Files: tc2DGraphicsSurface.h Log Message: Index: tc2DGraphicsSurface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tc2DGraphicsSurface.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tc2DGraphicsSurface.h 8 Aug 2004 00:31:32 -0000 1.10 --- tc2DGraphicsSurface.h 17 Aug 2004 02:22:56 -0000 1.11 *************** *** 21,25 **** #define _TC2DGRAPHICSSURFACE_H_ ! #ifdef WIN32 #pragma once #endif --- 21,25 ---- #define _TC2DGRAPHICSSURFACE_H_ ! #if _MSC_VER > 1000 #pragma once #endif |
|
From: Dewitt C. <ddc...@us...> - 2004-08-17 02:25:55
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19191/src/sim Modified Files: Game.cpp tcOOBView.cpp Log Message: Index: tcOOBView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcOOBView.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcOOBView.cpp 8 Aug 2004 00:31:35 -0000 1.7 --- tcOOBView.cpp 17 Aug 2004 02:22:56 -0000 1.8 *************** *** 1,5 **** ! /* ! ** tcOOBView.cpp ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- ! /** ! ** @file tcOOBView.cpp ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 37,85 **** using namespace MapView; - void tcOOBView::Update() { - Graphics *pGraphics; - UpdateData(); - UpdateFormation(); - UpdateRect(); ! if (!GetGraphics(pGraphics)) { ! WTL("Failed to get Graphics in tcOOBView::Update()\n"); ! return; ! } ! PlaceIcons(pGraphics); ! ReleaseGraphics(pGraphics); } - // update maOOB data - void tcOOBView::UpdateData() { - tnPoolIndex aObjKeys[MAX_OOB_OBJECTS]; - unsigned nCount; - if (mpSimState==NULL) {return;} - nCount = mpSimState->GetAlliancePlatforms(aObjKeys, MAX_OOB_OBJECTS, mnAlliance); - mnCount = 0; ! for (unsigned n=0;(n<nCount)&&(mnCount<MAX_OOB_OBJECTS);n++) { ! tcGameObject *pGameObj; ! pGameObj = mpSimState->GetObject(aObjKeys[n]); ! if (pGameObj != NULL) { ! tcPlatformObject *pPlatformObj = dynamic_cast<tcPlatformObject*>(pGameObj); ! if (pPlatformObj != NULL) { ! tsOOBInfo *pInfo = &maOOB[mnCount++]; ! pInfo->mnID = pGameObj->mnID; ! pInfo->mzName = pGameObj->mzUnit; ! pInfo->mnFollowers = 0; ! pInfo->mbRadiating = pPlatformObj->IsRadiating(); ! pInfo->mfDamage_fract = 0; ! if (pPlatformObj->msFormationParameters.mbFormation) { ! pInfo->mnLeaderID = pPlatformObj->msFormationParameters.mnFormationLeader; ! } ! else { ! pInfo->mnLeaderID = NULL_INDEX; ! } ! pPlatformObj->mcAI.GetActionText(pInfo->mzAction); ! } ! } ! } } --- 38,135 ---- using namespace MapView; ! tsOOBInfo& tsOOBInfo::operator= (const tsOOBInfo& rhs) ! { ! mnID = rhs.mnID; ! mzName = rhs.mzName.mz; ! mnLeaderID = rhs.mnLeaderID; ! maFollowers.clear(); ! for (size_t n = 0; n < rhs.maFollowers.size(); n++) ! { ! maFollowers.push_back(rhs.maFollowers[n]); ! } ! mbRadiating = rhs.mbRadiating; ! mfDamage_fract = rhs.mfDamage_fract; ! mzAction = rhs.mzAction; ! rectf = rhs.rectf; ! remcon = rhs.remcon; ! rdamage = rhs.rdamage; ! raction = rhs.raction; ! ! return *this; } ! void tcOOBView::Update() ! { ! Graphics *pGraphics; ! ! UpdateData(); ! UpdateFormation(); ! UpdateRect(); ! ! if (!GetGraphics(pGraphics)) ! { ! WTL("Failed to get Graphics in tcOOBView::Update()\n"); ! return; ! } ! PlaceIcons(pGraphics); ! ReleaseGraphics(pGraphics); ! } ! ! /** ! * update maOOB data ! */ ! void tcOOBView::UpdateData() ! { ! ! surfaceObj.clear(); ! airObj.clear(); ! flightopsObj.clear(); ! ! wxASSERT(mpSimState); ! ! unsigned nCount = mpSimState->GetAlliancePlatforms(objKeys, MAX_OOB_OBJECTS, mnAlliance); ! ! for (unsigned n = 0; n < nCount; n++) ! { ! if (tcPlatformObject* platformObj = ! dynamic_cast<tcPlatformObject*>(mpSimState->GetObject(objKeys[n]))) ! { ! tsOOBInfo info; ! info.mnID = platformObj->mnID; ! info.mzName = platformObj->mzUnit; ! info.maFollowers.clear(); ! info.mbRadiating = platformObj->IsRadiating(); ! info.mfDamage_fract = platformObj->mfDamageLevel; ! if (platformObj->msFormationParameters.mbFormation) ! { ! info.mnLeaderID = platformObj->msFormationParameters.mnFormationLeader; ! } ! else ! { ! info.mnLeaderID = NULL_INDEX; ! } ! platformObj->mcAI.GetActionText(info.mzAction); ! ! if (dynamic_cast<tcAirObject*>(platformObj)) ! { ! airObj.push_back(info); ! } ! else if (dynamic_cast<tcFlightOpsObject*>(platformObj)) ! { ! flightopsObj.push_back(info); ! } ! else if (dynamic_cast<tcSurfaceObject*>(platformObj)) ! { ! surfaceObj.push_back(info); ! } ! else // unrecognized, do nothing ! { ! } ! } ! ! } } *************** *** 88,132 **** * update maOOB maFollowers array * this can be expensive with many objects, 0(N^2) */ ! void tcOOBView::UpdateFormation() { ! if (mpSimState==NULL) {return;} - for (unsigned n=0;n<mnCount;n++) { - tsOOBInfo *pInfo = &maOOB[n]; ! // apply formation change if needed ! if (msFormationChangeInfo.mbApply) { ! if (msFormationChangeInfo.mnFollowerKey == pInfo->mnID) { ! tcSurfaceObject *pSurfaceObj; ! pSurfaceObj = dynamic_cast<tcSurfaceObject*>(mpSimState->GetObject(pInfo->mnID)); ! // only allow formation change for surface objs ! if (pSurfaceObj != NULL) { ! pInfo->mnLeaderID = msFormationChangeInfo.mnNewLeaderKey; ! pSurfaceObj->msFormationParameters.mnFormationLeader = pInfo->mnLeaderID; ! pSurfaceObj->msFormationParameters.mbFormation = true; ! } ! msFormationChangeInfo.mbApply = false; ! } ! } ! // if the object is a follower in a formation update the leader's list ! if (pInfo->mnLeaderID != NULL_INDEX) { ! pInfo->rectf.Y = -100; // to guard against no update ! // find leader ! bool bSearching = true; ! for (unsigned k=0;(k<mnCount)&&(bSearching);k++) { ! tsOOBInfo *pLeader = &maOOB[k]; ! if (pLeader->mnID == pInfo->mnLeaderID) { ! if (pLeader->mnFollowers < MAX_FOLLOWERS) { ! pLeader->maFollowers[pLeader->mnFollowers++] = n; ! } ! else { ! pInfo->mnLeaderID = NULL_INDEX; // max followers exceeded ! } ! bSearching = false; ! } ! } ! } ! } ! msFormationChangeInfo.mbApply = false; // always clear formation change } --- 138,187 ---- * update maOOB maFollowers array * this can be expensive with many objects, 0(N^2) + * + * After recent mod, this only works for surface objects */ ! void tcOOBView::UpdateFormation() ! { ! wxASSERT(mpSimState); ! for (size_t n = 0; n < surfaceObj.size(); n++) ! { ! tsOOBInfo& info = surfaceObj[n]; ! ! // apply formation change if needed ! if (msFormationChangeInfo.mbApply) ! { ! if (msFormationChangeInfo.mnFollowerKey == info.mnID) ! { ! // only allow formation change for surface objs ! if (tcSurfaceObject* surfaceObj = ! dynamic_cast<tcSurfaceObject*>(mpSimState->GetObject(info.mnID))) ! { ! info.mnLeaderID = msFormationChangeInfo.mnNewLeaderKey; ! surfaceObj->msFormationParameters.mnFormationLeader = info.mnLeaderID; ! surfaceObj->msFormationParameters.mbFormation = true; ! } ! msFormationChangeInfo.mbApply = false; ! } ! } ! // if the object is a follower in a formation update the leader's list ! if (info.mnLeaderID != NULL_INDEX) ! { ! info.rectf.Y = -100; // to guard against no update ! // find leader ! bool bSearching = true; ! for (size_t k=0; (k<surfaceObj.size())&&(bSearching); k++) ! { ! tsOOBInfo& leader = surfaceObj[k]; ! if (leader.mnID == info.mnLeaderID) ! { ! leader.maFollowers.push_back(n); ! bSearching = false; ! } ! } ! } ! } ! msFormationChangeInfo.mbApply = false; // always clear formation change } *************** *** 134,360 **** * update maOOB rectf */ ! void tcOOBView::UpdateRect() { ! float y = mfYOffset; ! float x = mfXOffset; ! float fStopY = (float)mnHeight - mfRowSpacing; ! for (unsigned n=0;(n<mnCount)&&(y < fStopY);n++) { ! tsOOBInfo *pInfo = &maOOB[n]; ! if (pInfo->mnLeaderID == NULL_INDEX) { ! y += 2; // extra spacing to separate groups ! pInfo->rectf.X = x; ! pInfo->rectf.Y = y; ! pInfo->rectf.Width = (float)mnWidth - x; ! pInfo->rectf.Height = mfRowSpacing; ! y += mfRowSpacing; ! // draw followers ! for (int k=0;(k<pInfo->mnFollowers)&&(k<MAX_FOLLOWERS);k++) { ! unsigned nFollowerIdx = pInfo->maFollowers[k]; ! if (nFollowerIdx >= mnCount) { ! WTL("tcOOBView - error - corrupt follower index"); ! return; ! } ! tsOOBInfo *pFollower = &maOOB[nFollowerIdx]; ! pFollower->rectf.X = x + mfXIndent; ! pFollower->rectf.Y = y; ! pFollower->rectf.Width = (float)mnWidth - x; ! pFollower->rectf.Height = mfRowSpacing; ! y += mfRowSpacing; - // draw followers of follower (> 2 levels not supported) - for (int k2=0;(k2<pFollower->mnFollowers)&&(k2<MAX_FOLLOWERS);k2++) { - unsigned nFollowerIdx2 = pFollower->maFollowers[k2]; - if (nFollowerIdx2 >= mnCount) { - WTL("tcOOBView - error - corrupt follower2 index"); - return; - } - tsOOBInfo *pFollower2 = &maOOB[nFollowerIdx2]; - pFollower2->rectf.X = x + 2*mfXIndent; - pFollower2->rectf.Y = y; - pFollower2->rectf.Width = (float)mnWidth - x; - pFollower2->rectf.Height = mfRowSpacing; - y += mfRowSpacing; - } - } - } - } } ! int tcOOBView::Draw() { ! Graphics *pGraphics; ! float ftextx,ftexty; ! float fStopY = (float)mnHeight - mfRowSpacing; - static int nFrameCount = 0; - //if ((nFrameCount++ % 4)!=0) {return 1;} // draw every fourth call ! if (!GetGraphics(pGraphics)) { ! WTL("Failed to get Graphics in tcOOBView::Draw()\n"); ! return false; ! } ! if (IsBackgroundLoaded()) { ! DrawBackground(pGraphics); ! } ! else { ! // erase ! mpBrush->SetColor(Color(255,0,0,0)); ! pGraphics->FillRectangle(mpBrush,0,0,mnWidth,mnHeight); ! } ! /*** draw text ***/ ! mpBrush->SetColor(Color(254,100,255,100)); ! ftexty = 0; ! UINT32 nColor; ! for (unsigned n=0;n<mnCount;n++) { ! tsOOBInfo *pInfo = &maOOB[n]; ! ftextx = pInfo->rectf.X; ! ftexty = pInfo->rectf.Y; ! if ((ftexty > 0)&&(ftexty<fStopY)) { ! nColor = (pInfo->mnID == mnSelectedKey) ? 0xFEFFFFFF : 0xFE64FF64; ! mpBrush->SetColor(nColor); ! DrawText(pGraphics,mpFont,mpBrush,pInfo->mzName.mz,ftextx,ftexty); ! if (pInfo->mbRadiating) { ! nColor = 0xFE64FF64; ! mpBrush->SetColor(nColor); ! pGraphics->FillEllipse(mpBrush, pInfo->remcon); ! } ! ftextx = pInfo->raction.X; ! ftexty = pInfo->raction.Y; ! DrawText(pGraphics,mpFont,mpBrush,pInfo->mzAction.c_str(),ftextx,ftexty); ! } ! } ! ReleaseGraphics(pGraphics); ! DrawBorder(); ! return 1; } ! /******************************************************************************/ /** * updates location of icon rectangles within each OOBInfo item */ ! void tcOOBView::PlaceIcons(Graphics *apGraphics) { ! SizeF stringsize; ! ! for (unsigned n=0;n<mnCount;n++) { ! tsOOBInfo *pInfo = &maOOB[n]; ! MeasureText(apGraphics,mpFont,pInfo->mzName.mz,stringsize); ! pInfo->remcon.Y = pInfo->rectf.Y; ! pInfo->remcon.X = pInfo->rectf.X + stringsize.Width + 5.0f; ! pInfo->remcon.Height = stringsize.Height; ! pInfo->remcon.Width = stringsize.Height; ! pInfo->remcon.Inflate(-2.0f,-2.0f); ! MeasureText(apGraphics,mpFont,pInfo->mzAction.c_str(),stringsize); ! pInfo->raction.Y = pInfo->rectf.Y - 1.0f; ! pInfo->raction.X = pInfo->remcon.GetRight() + 5.0f; ! if (pInfo->raction.X < 120.0f) {pInfo->raction.X = 120.0f;} ! pInfo->raction.Height = stringsize.Height; ! pInfo->raction.Width = stringsize.Height; ! pInfo->raction.Inflate(-2.0f,-2.0f); ! } } ! /******************************************************************************/ void tcOOBView::OnLButtonDown(wxMouseEvent& event) { ! unsigned nObject; ! if (mpSimState == NULL) {return;} ! if (mpMapView == NULL) {return;} ! ! wxPoint point = event.GetPosition(); ! ! if (ButtonContainingPoint(PointF((float)point.x,(float)point.y),nObject)) ! { ! tsOOBInfo *pInfo = &maOOB[nObject]; ! long new_key = pInfo->mnID; ! if (new_key != mnSelectedKey) ! { ! wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_NEWHOOK) ; ! command.SetEventObject(this); ! command.m_extraLong = new_key; ! AddPendingEvent(command); ! } ! mnSelectedKey = new_key; ! tcSound::Get()->PlayEffect(SEFFECT_SHORTBEEP); ! ! mbMouseDrag = true; ! msFormationChangeInfo.mnFollowerKey = pInfo->mnID; ! } } ! /******************************************************************************/ void tcOOBView::OnLButtonUp(wxMouseEvent& event) { ! unsigned nObject; ! if (mpSimState == NULL) {return;} ! if (mpMapView == NULL) {return;} ! if (!mbMouseDrag) {return;} ! wxPoint point = event.GetPosition(); ! ! if (ButtonContainingPoint(PointF((float)point.x,(float)point.y),nObject)) { ! tsOOBInfo *pInfo = &maOOB[nObject]; ! if (pInfo->mnID != mnSelectedKey) { ! msFormationChangeInfo.mnNewLeaderKey = pInfo->mnID; ! msFormationChangeInfo.mbApply = true; ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); ! } ! } ! mbMouseDrag = false; } ! bool tcOOBView::ButtonContainingPoint(PointF pointf, unsigned& nRow) { ! for (unsigned n=0;n<mnCount;n++) { ! tsOOBInfo *pInfo = &maOOB[n]; ! if (pInfo->rectf.Contains(pointf)) { ! nRow = n; ! return true; ! } ! } ! return false; } tcOOBView::tcOOBView(wxWindow *parent, ! const wxPoint& pos, const wxSize& size, ! const wxString& name) : ! tcWindow(parent, pos, size, name) { ! mpSimState = NULL; ! mpMapView = NULL; ! mnCount = 0; ! mnAlliance = 0; ! mnSelectedKey = NULL_INDEX; ! mbMouseDrag = false; ! for(int i=0;i<MAX_OOB_OBJECTS;i++) { ! maOOB[i].mnID = NULL_INDEX; ! maOOB[i].mnLeaderID = NULL_INDEX; ! maOOB[i].mnFollowers = 0; ! maOOB[i].mbRadiating = false; ! maOOB[i].mfDamage_fract = 0; ! } ! mfRowSpacing = 12.0f; ! mfYOffset = 10.0f; ! mfXOffset = 5.0f; ! mfXIndent = 15.0f; ! mpPen = new Pen(Color(0xFEFFFFFF),2); ! if (mpPen == NULL) {WTL("tcOOBView - mpPen creation failed\n");} ! FontFamily ff(L"Arial"); ! mpFont = new Font(&ff,10,FontStyleBold,UnitPixel); ! if (mpFont == NULL) {WTL("tcOOBView - mpFont creation failed\n");} ! mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB ! if (mpBrush == NULL) {WTL("tcOOBView - mpBrush creation failed\n");} } ! tcOOBView::~tcOOBView() { ! if (mpPen != NULL) {delete mpPen;} ! if (mpFont != NULL) {delete mpFont;} ! if (mpBrush != NULL) {delete mpBrush;} } \ No newline at end of file --- 189,524 ---- * update maOOB rectf */ ! void tcOOBView::UpdateRect() ! { ! float y = mfYOffset; ! float stopy = (float)mnHeight - mfRowSpacing; ! UpdateRectCategory(surfaceObj, y, stopy); ! y += 2*mfRowSpacing; ! ! UpdateRectCategory(airObj, y, stopy); ! y += 2*mfRowSpacing; ! ! UpdateRectCategory(flightopsObj, y, stopy); } ! void tcOOBView::UpdateRectCategory(std::vector<tsOOBInfo>& objInfo, ! float& y, float stopy) ! { ! float x = mfXOffset; ! for (size_t n=0; (n < objInfo.size())&&(y < stopy); n++) ! { ! tsOOBInfo& info = objInfo[n]; ! if (info.mnLeaderID == NULL_INDEX) ! { ! y += 2; // extra spacing to separate groups ! info.rectf.X = x; ! info.rectf.Y = y; ! info.rectf.Width = (float)mnWidth - x; ! info.rectf.Height = mfRowSpacing; ! y += mfRowSpacing; ! // draw followers ! for (size_t k = 0; k < info.maFollowers.size(); k++) ! { ! size_t nFollowerIdx = info.maFollowers[k]; ! if (nFollowerIdx >= objInfo.size()) ! { ! WTL("tcOOBView - error - corrupt follower index"); ! return; ! } ! tsOOBInfo& follower = objInfo[nFollowerIdx]; ! follower.rectf.X = x + mfXIndent; ! follower.rectf.Y = y; ! follower.rectf.Width = (float)mnWidth - x; ! follower.rectf.Height = mfRowSpacing; ! y += mfRowSpacing; ! // draw followers of follower (> 2 levels not supported) ! for (size_t k2=0; k2 < follower.maFollowers.size(); k2++) ! { ! unsigned nFollowerIdx2 = follower.maFollowers[k2]; ! if (nFollowerIdx2 >= objInfo.size()) ! { ! WTL("tcOOBView - error - corrupt follower2 index"); ! return; ! } ! tsOOBInfo& follower2 = objInfo[nFollowerIdx2]; ! follower2.rectf.X = x + 2*mfXIndent; ! follower2.rectf.Y = y; ! follower2.rectf.Width = (float)mnWidth - x; ! follower2.rectf.Height = mfRowSpacing; ! y += mfRowSpacing; ! } ! } ! } ! } } ! ! int tcOOBView::Draw() ! { ! Graphics* graphics; ! ! float stopy = (float)mnHeight - mfRowSpacing; ! ! static int nFrameCount = 0; ! //if ((nFrameCount++ % 4)!=0) {return 1;} // draw every fourth call ! ! if (!GetGraphics(graphics)) ! { ! WTL("Failed to get Graphics in tcOOBView::Draw()\n"); ! return false; ! } ! if (IsBackgroundLoaded()) ! { ! DrawBackground(graphics); ! } ! else ! { ! // erase ! mpBrush->SetColor(Color(255,0,0,0)); ! graphics->FillRectangle(mpBrush,0,0,mnWidth,mnHeight); ! } ! ! float yheader; ! ! yheader = GetCategoryY(surfaceObj); ! if (yheader > 0) ! { ! mpBrush->SetColor(Color(254,200,200,250)); ! DrawText(graphics, mpFont, mpBrush, "* Surface", ! mfXOffset, yheader - 15.0f); ! } ! DrawCategory(graphics, surfaceObj, stopy); ! ! ! yheader = GetCategoryY(airObj); ! if (yheader > 0) ! { ! mpBrush->SetColor(Color(254,200,200,250)); ! DrawText(graphics, mpFont, mpBrush, "* Air", mfXOffset, yheader - 15.0f); ! } ! DrawCategory(graphics, airObj, stopy); ! ! yheader = GetCategoryY(flightopsObj); ! if (yheader > 0) ! { ! mpBrush->SetColor(Color(254,200,200,250)); ! DrawText(graphics, mpFont, mpBrush, "* CVs and Airfields", ! mfXOffset, yheader - 15.0f); ! } ! DrawCategory(graphics, flightopsObj, stopy); ! ! ! ReleaseGraphics(graphics); ! DrawBorder(); ! return 1; ! } ! ! void tcOOBView::DrawCategory(Gdiplus::Graphics* graphics, ! std::vector<tsOOBInfo>& objInfo, float stopy) ! { ! ! mpBrush->SetColor(Color(254,100,255,100)); ! ! for (size_t n = 0; n < objInfo.size(); n++) ! { ! tsOOBInfo& info = objInfo[n]; ! float ftextx = info.rectf.X; ! float ftexty = info.rectf.Y; ! if ((ftexty > 0) && (ftexty < stopy)) ! { ! UINT32 nColor; ! if (info.mnID == mnSelectedKey) ! nColor = 0xFEFFFFFF; ! else if (info.mfDamage_fract >= 0.5f) ! nColor = 0xFEFF6464; ! else if (info.mfDamage_fract > 0) ! nColor = 0xFEFFFF64; ! else ! nColor = 0xFE64FF64; ! ! mpBrush->SetColor(nColor); ! DrawText(graphics, mpFont, mpBrush, info.mzName.mz, ftextx, ftexty); ! if (info.mbRadiating) ! { ! nColor = 0xFE64FF64; ! mpBrush->SetColor(nColor); ! graphics->FillEllipse(mpBrush, info.remcon); ! } ! ftextx = info.raction.X; ! ftexty = info.raction.Y; ! DrawText(graphics, mpFont, mpBrush, info.mzAction.c_str(), ftextx, ftexty); ! } ! } ! } ! ! ! /** ! * @return y value of top of first item in category, or zero if none exists ! */ ! float tcOOBView::GetCategoryY(std::vector<tsOOBInfo>& objInfo) ! { ! if (objInfo.size()) ! { ! return objInfo[0].rectf.Y; ! } ! else ! { ! return 0; ! } ! } ! /** * updates location of icon rectangles within each OOBInfo item */ ! void tcOOBView::PlaceIcons(Graphics *apGraphics) ! { ! PlaceIconsCategory(apGraphics, surfaceObj); ! PlaceIconsCategory(apGraphics, airObj); ! PlaceIconsCategory(apGraphics, flightopsObj); ! } ! void tcOOBView::PlaceIconsCategory(Gdiplus::Graphics* graphics, ! std::vector<tsOOBInfo>& objInfo) ! { ! SizeF stringsize; ! for (size_t n=0; n < objInfo.size(); n++) ! { ! tsOOBInfo& info = objInfo[n]; ! ! MeasureText(graphics, mpFont, info.mzName.mz, stringsize); ! info.remcon.Y = info.rectf.Y; ! info.remcon.X = info.rectf.X + stringsize.Width + 5.0f; ! info.remcon.Height = stringsize.Height; ! info.remcon.Width = stringsize.Height; ! info.remcon.Inflate(-2.0f,-2.0f); ! ! MeasureText(graphics,mpFont,info.mzAction.c_str(),stringsize); ! info.raction.Y = info.rectf.Y - 1.0f; ! info.raction.X = info.remcon.GetRight() + 5.0f; ! if (info.raction.X < 120.0f) {info.raction.X = 120.0f;} ! info.raction.Height = stringsize.Height; ! info.raction.Width = stringsize.Height; ! info.raction.Inflate(-2.0f,-2.0f); ! } } ! void tcOOBView::OnLButtonDown(wxMouseEvent& event) { ! wxPoint point = event.GetPosition(); ! if (tsOOBInfo* info = ! ButtonContainingPoint(PointF((float)point.x,(float)point.y))) ! { ! long new_key = info->mnID; ! if (new_key != mnSelectedKey) ! { ! wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_NEWHOOK) ; ! command.SetEventObject(this); ! command.m_extraLong = new_key; ! AddPendingEvent(command); ! } ! mnSelectedKey = new_key; ! tcSound::Get()->PlayEffect(SEFFECT_SHORTBEEP); ! ! mbMouseDrag = true; ! msFormationChangeInfo.mnFollowerKey = info->mnID; ! } } ! void tcOOBView::OnLButtonUp(wxMouseEvent& event) { ! if (!mbMouseDrag) {return;} ! wxPoint point = event.GetPosition(); ! if (tsOOBInfo* info = ! ButtonContainingPoint(PointF((float)point.x,(float)point.y))) ! { ! if (info->mnID != mnSelectedKey) ! { ! msFormationChangeInfo.mnNewLeaderKey = info->mnID; ! msFormationChangeInfo.mbApply = true; ! tcSound::Get()->PlayEffect(SEFFECT_BEEP2); ! } ! } ! mbMouseDrag = false; } ! tsOOBInfo* tcOOBView::ButtonContainingPoint(PointF pointf) ! { ! tsOOBInfo* info = 0; ! ! if (info = ButtonContainingPointCategory(pointf, surfaceObj)) ! { ! return info; ! } ! else if (info = ButtonContainingPointCategory(pointf, airObj)) ! { ! return info; ! } ! else if (info = ButtonContainingPointCategory(pointf, flightopsObj)) ! { ! return info; ! } ! ! return 0; ! } ! ! tsOOBInfo* tcOOBView::ButtonContainingPointCategory(Gdiplus::PointF pointf, ! std::vector<tsOOBInfo>& objInfo) ! { ! for (size_t n = 0; n < objInfo.size(); n++) ! { ! tsOOBInfo* pInfo = &objInfo[n]; ! if (pInfo->rectf.Contains(pointf)) ! { ! return pInfo; ! } ! } ! ! return 0; } tcOOBView::tcOOBView(wxWindow *parent, ! const wxPoint& pos, const wxSize& size, ! const wxString& name) : ! tcWindow(parent, pos, size, name) , ! mpMapView(0), ! mnAlliance(0), ! mnSelectedKey(NULL_INDEX), ! mbMouseDrag(false), ! mfRowSpacing(12.0f), ! mfYOffset(20.0f), ! mfXOffset(5.0f), ! mfXIndent(15.0f) { ! mpSimState = tcSimState::Get(); ! mpPen = new Pen(Color(0xFEFFFFFF),2); ! if (mpPen == NULL) {WTL("tcOOBView - mpPen creation failed\n");} ! FontFamily ff(L"Arial"); ! mpFont = new Font(&ff,10,FontStyleBold,UnitPixel); ! if (mpFont == NULL) {WTL("tcOOBView - mpFont creation failed\n");} ! ! mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB ! if (mpBrush == NULL) {WTL("tcOOBView - mpBrush creation failed\n");} } ! tcOOBView::~tcOOBView() ! { ! if (mpPen != NULL) {delete mpPen;} ! if (mpFont != NULL) {delete mpFont;} ! if (mpBrush != NULL) {delete mpBrush;} } \ No newline at end of file Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** Game.cpp 16 Aug 2004 01:43:31 -0000 1.90 --- Game.cpp 17 Aug 2004 02:22:56 -0000 1.91 *************** *** 846,850 **** oobView->AttachMapView(tacticalMap); - oobView->AttachSimState(simState); oobView->mnAlliance = mcUserInfo.GetOwnAlliance(); // TODO: make this configurable --- 846,849 ---- |
|
From: Dewitt C. <ddc...@us...> - 2004-08-17 02:25:36
|
Update of /cvsroot/gcblue/gcb_wx/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19191/docs Modified Files: CHANGES.txt Log Message: Index: CHANGES.txt =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/docs/CHANGES.txt,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** CHANGES.txt 16 Aug 2004 01:43:29 -0000 1.34 --- CHANGES.txt 17 Aug 2004 02:22:55 -0000 1.35 *************** *** 4,7 **** --- 4,8 ---- --------------------------------------------------------------------- *** 2004-08-15 Dewitt Colclough *** + - Added grouping to OOB panel on the left - Added group selection menu for multiple unit commands. - Alt + leftclick now adds or deletes units from selection grouop |
|
From: Dewitt C. <ddc...@us...> - 2004-08-16 01:44:08
|
Update of /cvsroot/gcblue/gcb_wx/include/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3228/include/common Modified Files: simmath.h wxcommands.h Log Message: Index: simmath.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/common/simmath.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** simmath.h 9 Aug 2004 02:35:13 -0000 1.19 --- simmath.h 16 Aug 2004 01:43:29 -0000 1.20 *************** *** 130,133 **** --- 130,134 ---- void SetAllValid() {mnFlags |= 0x0F;} void GetPrediction(tcTrack& td, double mfTime); + tcTrack PredictAhead(float timeDelta_s); void Offset(float range_km, float heading_rad); void OffsetDeg(float range_km, float heading_deg); Index: wxcommands.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/common/wxcommands.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** wxcommands.h 8 Aug 2004 00:31:32 -0000 1.17 --- wxcommands.h 16 Aug 2004 01:43:29 -0000 1.18 *************** *** 1,7 **** ! /* ! ** wxcommands.h ** IDs for commands processed via wxWindows event handler. ! ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,7 ---- ! /** ! ** @file wxcommands.h ** IDs for commands processed via wxWindows event handler. ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 39,42 **** --- 39,43 ---- ID_STARTGAME = 70, ///< start game ID_NEWHOOK = 80, ///< new platform has been hooked by user + ID_GROUPHOOK = 82, ///< new group of platforms has been hooked by user ID_SETBRIEFING = 90, ///< enable/disable briefing mode ID_SETPAUSE = 100, ///< enable/disable game pause |
|
From: Dewitt C. <ddc...@us...> - 2004-08-16 01:44:08
|
Update of /cvsroot/gcblue/gcb_wx/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3228/docs Modified Files: CHANGES.txt Log Message: Index: CHANGES.txt =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/docs/CHANGES.txt,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** CHANGES.txt 9 Aug 2004 02:35:13 -0000 1.33 --- CHANGES.txt 16 Aug 2004 01:43:29 -0000 1.34 *************** *** 3,6 **** --- 3,12 ---- 0.6 --------------------------------------------------------------------- + *** 2004-08-15 Dewitt Colclough *** + - Added group selection menu for multiple unit commands. + - Alt + leftclick now adds or deletes units from selection grouop + - Added coarse adjustment to gunnery elevation calculation to correct + for altitude difference between gun and target. + *** 2004-08-08 Dewitt Colclough *** - Added read portion of SQL database upgrade using sqlite library. |
|
From: Dewitt C. <ddc...@us...> - 2004-08-16 01:44:08
|
Update of /cvsroot/gcblue/gcb_wx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3228 Modified Files: GCblue.vcproj Log Message: Index: GCblue.vcproj =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/GCblue.vcproj,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** GCblue.vcproj 9 Aug 2004 02:35:08 -0000 1.63 --- GCblue.vcproj 16 Aug 2004 01:43:28 -0000 1.64 *************** *** 298,301 **** --- 298,304 ---- </File> <File + RelativePath=".\src\scriptinterface\tcGroupInterface.cpp"> + </File> + <File RelativePath="src\scriptinterface\tcPanelInterface.cpp"> </File> *************** *** 1135,1138 **** --- 1138,1144 ---- </File> <File + RelativePath=".\include\scriptinterface\tcGroupInterface.h"> + </File> + <File RelativePath="include\scriptinterface\tcPanelInterface.h"> </File> |
|
From: Dewitt C. <ddc...@us...> - 2004-08-16 01:43:40
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3228/src/sim Modified Files: Game.cpp tcLauncherState.cpp tcMapView.cpp tcPopupControl.cpp Log Message: Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMapView.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** tcMapView.cpp 9 Aug 2004 02:35:16 -0000 1.30 --- tcMapView.cpp 16 Aug 2004 01:43:31 -0000 1.31 *************** *** 709,712 **** --- 709,723 ---- } + + /** + * @return true if id matches first element in hookedId vector + */ + bool tcTacticalMapView::IsFirstHook(long id) + { + if (hookedId.size() == 0) return false; + + return (hookedId[0] == id); + } + /** * Performs simple search for match by iterating through *************** *** 1269,1275 **** type = pMO->meSymbol; pMO->mbFocus = (IsHooked(pMO->mnID))&&(type != SYMBOL_SENSOR); ! if (pMO->mbFocus) { ! mfHookLat = pMO->mfLat; // move somewhere else and make this tighter mfHookLon = pMO->mfLon; } --- 1280,1287 ---- type = pMO->meSymbol; pMO->mbFocus = (IsHooked(pMO->mnID))&&(type != SYMBOL_SENSOR); ! ! if (mbMapCmdActive && (pMO->mbFocus)&&(IsFirstHook(pMO->mnID))) { ! mfHookLat = pMO->mfLat; // refactor mfHookLon = pMO->mfLon; } *************** *** 1455,1458 **** --- 1467,1472 ---- long currentHook; + hookedId.clear(); + if (GetHookCount() == 1) { *************** *** 1473,1477 **** } - hookedId.clear(); if (nMinID != -1) { --- 1487,1490 ---- *************** *** 1480,1483 **** --- 1493,1552 ---- return nMinID; } + + /** + * Adds another unit to the hook group or deselects unit in hook group + * The deselect requires at least two members are in the group. + */ + void tcTacticalMapView::HookAnother(wxPoint pscreen) + { + size_t hookCount = GetHookCount(); + + if (hookCount == 0) return; + + // return if closest id is already hooked + long closestId = GetClosest(pscreen); + bool unitWasRemoved = false; + + for (int n = int(hookCount)-1; (n >= 0)&&(!unitWasRemoved); n--) + { + if (hookedId[n] == closestId) + { + if (hookCount == 1) + { + return; + } + else // remove unit from group + { + hookedId.erase(hookedId.begin() + n); + unitWasRemoved = true; + } + } + } + + if (unitWasRemoved) + { + hookCount--; + } + else // otherwise add to hook group + { + hookedId.push_back(closestId); + hookCount++; + } + + wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_GROUPHOOK); + command.SetEventObject(this); + command.m_extraLong = hookCount; + long* groupList = new long[hookCount]; + for (size_t n = 0; n < hookCount; n++) + { + groupList[n] = hookedId[n]; + } + command.SetClientData(groupList); + + AddPendingEvent(command); + + } + + /** * Group hook. *************** *** 1511,1522 **** } ! // if single unit is hooked, post a single hook event ! if (GetHookCount()==1) ! { ! wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_NEWHOOK) ; ! command.SetEventObject(this); ! command.m_extraLong = GetHookID(); ! AddPendingEvent(command); ! } } --- 1580,1596 ---- } ! long hookCount = GetHookCount(); ! wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_GROUPHOOK); ! command.SetEventObject(this); ! command.m_extraLong = hookCount; ! long* groupList = new long[hookCount]; ! for (int n=0; n<hookCount; n++) ! { ! groupList[n] = hookedId[n]; ! } ! command.SetClientData(groupList); ! ! AddPendingEvent(command); ! } *************** *** 1547,1556 **** /***********************************************************************************/ ! int tcTacticalMapView::GetClosest(wxPoint pscreen) { tcMapObj *pMO; tcPoint geopoint = ScreenToGeo(pscreen), geopointi; float fHookDistance,fMinDistance,fDistance; ! int nMinID; // search for hook --- 1621,1630 ---- /***********************************************************************************/ ! long tcTacticalMapView::GetClosest(wxPoint pscreen) { tcMapObj *pMO; tcPoint geopoint = ScreenToGeo(pscreen), geopointi; float fHookDistance,fMinDistance,fDistance; ! long nMinID; // search for hook *************** *** 1747,1755 **** return; } ! Hook(buttonDownPoint); ! if (GetHookCount()==0) ! { ! isLButtonDown = true; ! } tcWindow::SkipMouseEvent(event); } --- 1821,1828 ---- return; } ! ! ! isLButtonDown = true; ! tcWindow::SkipMouseEvent(event); } *************** *** 1760,1773 **** void tcTacticalMapView::OnLButtonUp(wxMouseEvent& event) { ! if (isLButtonDown) ! { ! int xLeft = min(buttonDownPoint.x, mpointMouse.x); ! int yTop = min(buttonDownPoint.y, mpointMouse.y); ! int width = abs(mpointMouse.x - buttonDownPoint.x); ! int height = abs(mpointMouse.y - buttonDownPoint.y); ! HookGroup(wxRect(xLeft, yTop, width, height)); - isLButtonDown = false; - } } --- 1833,1865 ---- void tcTacticalMapView::OnLButtonUp(wxMouseEvent& event) { ! if (!isLButtonDown) return; ! ! wxPoint buttonUpPoint = event.GetPosition(); ! bool isAltDown = event.AltDown(); ! ! bool noDrag = (buttonDownPoint == buttonUpPoint); ! ! if (noDrag) ! { ! if (isAltDown) ! { ! HookAnother(buttonUpPoint); ! } ! else ! { ! Hook(buttonUpPoint); ! } ! } ! else ! { ! int xLeft = min(buttonDownPoint.x, buttonUpPoint.x); ! int yTop = min(buttonDownPoint.y, buttonUpPoint.y); ! int width = abs(buttonUpPoint.x - buttonDownPoint.x); ! int height = abs(buttonUpPoint.y - buttonDownPoint.y); ! HookGroup(wxRect(xLeft, yTop, width, height)); ! } ! ! isLButtonDown = false; } *************** *** 1871,1874 **** --- 1963,1967 ---- } + void tcTacticalMapView::UpdateNavPoints(vector<tcPoint> *mpPoints) { maNavPointGeo.clear(); Index: tcPopupControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPopupControl.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcPopupControl.cpp 8 Aug 2004 00:31:35 -0000 1.7 --- tcPopupControl.cpp 16 Aug 2004 01:43:31 -0000 1.8 *************** *** 147,150 **** --- 147,157 ---- mpPythonInterface->BuildPlatformMenu(); break; + case MENUMODE_GROUP: + mpMenu = &mcPlatformMenu; + mpPanel = NULL; + mpPythonInterface->AttachMenu(mpMenu); + mpPythonInterface->SelectGroupMenu(); + mpPythonInterface->BuildGroupMenu(); + break; case MENUMODE_TRACK: mpMenu = &mcTrackMenu; Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcLauncherState.cpp 9 Aug 2004 02:35:16 -0000 1.16 --- tcLauncherState.cpp 16 Aug 2004 01:43:31 -0000 1.17 *************** *** 119,122 **** --- 119,160 ---- } + /** + * @return approximate intercept time for target track + * For missiles this is assumes 600 kts velocity for now. + * For guns the range and speed are estimated using ballistics. + */ + float tcLauncherState::EstimateInterceptTimeForLauncher(unsigned nLauncher, tcTrack& track) + { + tcLauncher* launcher = GetLauncher(nLauncher); + if (!launcher) + { + fprintf(stderr, "EstimateInterceptTimeForLauncher - bad launcher\n"); + return 0; + } + tcDatabaseObject* child = launcher->mpChildDBObj; + tcKinematics kin = parent->mcKin; + float heading_rad = 0; + float tti_s = 0; + + if (tcMissileDBObject* missileInfo = dynamic_cast<tcMissileDBObject*>(child)) + { + kin.mfSpeed_kts = 600; + + kin.GetInterceptData2D(track, heading_rad, tti_s); + + } + else if (tcBallisticDBObject* ballInfo = dynamic_cast<tcBallisticDBObject*>(child)) + { + float range_km = kin.RangeToKm(track); + ballInfo->GetGunneryElevation(1000 * range_km, 0, tti_s); + } + else + { + fprintf(stderr, "EstimateInterceptTimeForLauncher - unknown child obj\n"); + } + + return tti_s; + } + const char* tcLauncherState::GetFireControlSensorClass(unsigned nLauncher) const { Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** Game.cpp 9 Aug 2004 02:35:16 -0000 1.89 --- Game.cpp 16 Aug 2004 01:43:31 -0000 1.90 *************** *** 82,85 **** --- 82,86 ---- EVT_COMMAND(ID_STARTGAME, wxEVT_COMMAND_BUTTON_CLICKED , tcGame::StartGame) EVT_COMMAND(ID_NEWHOOK, wxEVT_COMMAND_BUTTON_CLICKED, tcGame::NewHook) + EVT_COMMAND(ID_GROUPHOOK, wxEVT_COMMAND_BUTTON_CLICKED, tcGame::NewGroupHook) EVT_COMMAND(ID_SECONDARYHOOK, wxEVT_COMMAND_BUTTON_CLICKED, tcGame::SecondaryHook) EVT_COMMAND(ID_SETBRIEFING, wxEVT_COMMAND_BUTTON_CLICKED, tcGame::SetBriefingMode) *************** *** 443,447 **** pythonInterface->AttachMapData(&mcMapData); - pythonInterface->AttachSimState(simState); tcLauncherState::mpDatabase = database; --- 444,447 ---- *************** *** 1688,1694 **** --- 1688,1700 ---- void tcGame::OnLButtonUp(wxMouseEvent& event) {} + + /** + * @return current menu mode + * this menu mode sytem needs refactoring! + */ teMenuMode tcGame::GetMenuMode() { long hookID = tacticalMap->GetHookID(); + bool isGroupHooked = tacticalMap->GetHookCount() > 1; if (hookID==NULL_INDEX) *************** *** 1706,1713 **** simState->GetPlatformAlliance(hookID, nAlliance); ! if ((mcUserInfo.IsOwnAlliance(nAlliance))||(tcOptions::Get()->mnCommandMode == 0)) ! return MENUMODE_PLATFORM; else return MENUMODE_TRACK; } --- 1712,1731 ---- simState->GetPlatformAlliance(hookID, nAlliance); ! if ((mcUserInfo.IsOwnAlliance(nAlliance))|| ! (tcOptions::Get()->mnCommandMode == 0)) ! { ! if (isGroupHooked) ! { ! return MENUMODE_GROUP; ! } ! else ! { ! return MENUMODE_PLATFORM; ! } ! } else + { return MENUMODE_TRACK; + } } *************** *** 1751,1754 **** --- 1769,1814 ---- * hook ID is stored in event.m_extraLong */ + void tcGame::NewGroupHook(wxCommandEvent& event) + { + long hookCount = event.m_extraLong; + + if (hookCount <= 0) + { + NewHook(-1); + return; + } + + long* groupList = reinterpret_cast<long*>(event.m_clientData); + + // first object id is used for single unit displays + long primaryHook = groupList[0]; + if (hookCount == 1) + { + NewHook(primaryHook); + delete event.m_clientData; + return; + } + + //tacticalMap->SetHookID(primaryHook); + hookInfo->SetHookID(primaryHook); + oobView->SetHookID(primaryHook); + objectControl->SetHookID(primaryHook); + viewer->SetHookID(primaryHook); + + std::vector<long> groupUnits; + for (int n = 0; n< hookCount; n++) + { + groupUnits.push_back(groupList[n]); + } + pythonInterface->SetMenuGroup(groupUnits); + delete event.m_clientData; // is this necessary? + + tcSound::Get()->PlayEffect(SEFFECT_SHORTBEEP); + } + + /** + * Update member objects with new hook ID. + * hook ID is stored in event.m_extraLong + */ void tcGame::NewHook(wxCommandEvent& event) { *************** *** 1759,1763 **** /** ! * Update member objects with new hook ID. */ void tcGame::NewHook(long hookID) --- 1819,1824 ---- /** ! * Updates member objects with new hook ID. ! * hookID = -1 is used to clear the hooked obj */ void tcGame::NewHook(long hookID) |
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3228/src/scriptinterface Modified Files: tcPlatformInterface.cpp tcPlatformInterfaceExtension.cpp tcPlatformInterfaceExtensionB.cpp tcSimPythonInterface.cpp Added Files: tcGroupInterface.cpp Log Message: Index: tcPlatformInterfaceExtensionB.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterfaceExtensionB.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcPlatformInterfaceExtensionB.cpp 9 Aug 2004 02:35:16 -0000 1.14 --- tcPlatformInterfaceExtensionB.cpp 16 Aug 2004 01:43:31 -0000 1.15 *************** *** 94,97 **** --- 94,98 ---- .def("GetLauncherQuantity", &tcPlatformInterface::GetLauncherQuantity) .def("IsDatumLaunch", &tcPlatformInterface::IsDatumLaunch) + .def("GetLauncherInterceptTime", &tcPlatformInterface::GetLauncherInterceptTime) // orders Index: tcSimPythonInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcSimPythonInterface.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcSimPythonInterface.cpp 8 Aug 2004 00:31:34 -0000 1.16 --- tcSimPythonInterface.cpp 16 Aug 2004 01:43:31 -0000 1.17 *************** *** 1,6 **** ! /* ! ** tcSimPythonInterface.cpp ! ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- ! /** ! ** @file tcSimPythonInterface.cpp ! */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 189,200 **** ! // creates platform menu customized to object ! void tcSimPythonInterface::BuildPlatformMenu() { ! try { handle<>( PyRun_String("Menu.BuildUnitMenu(UserMenu, HookedUnitInfo)" , Py_file_input, mpDictionary->ptr(), mpDictionary->ptr()) ); } ! catch(error_already_set) { ! // handle the exception in some way fprintf(stderr,"Exception occured in BuildPlatformMenu\n"); PyErr_Print(); --- 189,221 ---- ! /** ! * Creates menu customized to selected group of units ! */ ! void tcSimPythonInterface::BuildGroupMenu() ! { ! try ! { ! handle<>( PyRun_String("Menu.BuildGroupMenu(UserMenu, GroupInfo)" ! , Py_file_input, mpDictionary->ptr(), mpDictionary->ptr()) ); ! } ! catch(error_already_set) ! { ! fprintf(stderr,"Exception occured in BuildGroupMenu\n"); ! PyErr_Print(); ! } ! } ! ! /** ! * creates platform menu customized to selected unit ! */ ! void tcSimPythonInterface::BuildPlatformMenu() ! { ! try ! { handle<>( PyRun_String("Menu.BuildUnitMenu(UserMenu, HookedUnitInfo)" , Py_file_input, mpDictionary->ptr(), mpDictionary->ptr()) ); } ! catch(error_already_set) ! { fprintf(stderr,"Exception occured in BuildPlatformMenu\n"); PyErr_Print(); *************** *** 259,275 **** void tcSimPythonInterface::GetObjectStringByMode(char *str) { ! if (meMenuMode == UNIT_MENU) ! { ! strcpy(str,"HookedUnitInfo"); ! } ! else if (meMenuMode == TRACK_MENU) ! { ! strcpy(str,"HookedTrackInfo"); ! } ! else if (meMenuMode == FLIGHT_MENU) ! { ! strcpy(str,"FlightPortInfo"); ! } ! else if ((mpHookedObj != NULL) && (mpSimState->mpUserInfo->IsOwnAlliance(mpHookedObj->mnAlliance))) { strcpy(str,"HookedUnitInfo"); --- 280,301 ---- void tcSimPythonInterface::GetObjectStringByMode(char *str) { ! switch (meMenuMode) ! { ! case UNIT_MENU: ! strcpy(str, "HookedUnitInfo"); ! return; ! case GROUP_MENU: ! strcpy(str, "GroupInfo"); ! return; ! case TRACK_MENU: ! strcpy(str, "HookedTrackInfo"); ! return; ! case FLIGHT_MENU: ! strcpy(str, "FlightPortInfo"); ! return; ! } ! ! if ((mpHookedObj != NULL) && ! (mpSimState->mpUserInfo->IsOwnAlliance(mpHookedObj->mnAlliance))) { strcpy(str,"HookedUnitInfo"); *************** *** 412,432 **** void tcSimPythonInterface::ProcessSecondaryHook(long id) { ! char zBuff[128]; ! if (mpHookedObj == NULL) return; ! if (!mpSimState->mpUserInfo->IsOwnAlliance(mpHookedObj->mnAlliance)) return; ! sprintf(zBuff,"Menu.ProcessSecondaryHook(HookedUnitInfo,%d)\n",id); ! CallPython(zBuff,"Exception occured in ProcessSecondaryHook\n"); } ! /* writes error message in text out to console, if console is attached */ void tcSimPythonInterface::ReportError(const char* text) { ! fprintf(stderr,text); ! if (mpConsole == NULL) return; ! mpConsole->Print(text); } ! // updates object reference for platform menu void tcSimPythonInterface::SetMenuPlatform(long anID) { --- 438,504 ---- void tcSimPythonInterface::ProcessSecondaryHook(long id) { ! char zBuff[128]; ! if (mpHookedObj == NULL) return; ! if (!mpSimState->mpUserInfo->IsOwnAlliance(mpHookedObj->mnAlliance)) return; ! sprintf(zBuff,"Menu.ProcessSecondaryHook(HookedUnitInfo,%d)\n",id); ! CallPython(zBuff,"Exception occured in ProcessSecondaryHook\n"); } ! /** ! * writes error message in text out to console, if console is attached ! */ void tcSimPythonInterface::ReportError(const char* text) { ! fprintf(stderr,text); ! if (mpConsole == NULL) return; ! mpConsole->Print(text); } ! void tcSimPythonInterface::SelectFlightInterface() ! { ! meMenuMode = FLIGHT_MENU; ! } ! ! void tcSimPythonInterface::SelectTrackMenu() ! { ! meMenuMode = TRACK_MENU; ! } ! ! void tcSimPythonInterface::SelectUnitMenu() ! { ! meMenuMode = UNIT_MENU; ! } ! ! void tcSimPythonInterface::SelectGroupMenu() ! { ! meMenuMode = GROUP_MENU; ! } ! ! ! void tcSimPythonInterface::SetMenuGroup(std::vector<long>& unitIds) ! { ! // if any of the ids are invalid or not own-alliance, then return ! for (unsigned idx=0; idx<unitIds.size(); idx++) ! { ! tcGameObject* gameObj = mpSimState->GetObject(unitIds[idx]); ! if ((!gameObj) || ! (!mpSimState->mpUserInfo->IsOwnAlliance(gameObj->mnAlliance))) ! { ! fprintf(stderr, "tcSimPythonInterface::SetMenuGroup - null or " ! " not own-alliance id\n"); ! return; ! } ! } ! ! meMenuMode = GROUP_MENU; ! ! groupInterface->SetUnits(unitIds); ! ! } ! ! /** ! * updates object reference for platform menu ! */ void tcSimPythonInterface::SetMenuPlatform(long anID) { *************** *** 434,438 **** tcTrackInterface::SetTrack(anID); ! if (mpSimState == NULL) {return;} tcGameObject *pGameObj = mpSimState->GetObject(anID); --- 506,511 ---- tcTrackInterface::SetTrack(anID); ! wxASSERT(mpSimState); ! tcGameObject *pGameObj = mpSimState->GetObject(anID); *************** *** 472,482 **** ! tcSimPythonInterface::tcSimPythonInterface(void) { mpConsole = NULL; director = NULL; ! mpSimState = NULL; mpHookedObj = NULL; object platformInterfaceType = tcPlatformInterface::GetPlatformInterface(); --- 545,558 ---- ! tcSimPythonInterface::tcSimPythonInterface() { mpConsole = NULL; director = NULL; ! mpSimState = tcSimState::Get(); mpHookedObj = NULL; + tcPlatformInterface::AttachSimState(mpSimState); + tcScenarioInterface::AttachSimState(mpSimState); + object platformInterfaceType = tcPlatformInterface::GetPlatformInterface(); *************** *** 487,490 **** --- 563,576 ---- hookedInterface = extract<tcPlatformInterface*>(HookedPlatformInterface); + + object GroupInterfaceType = class_<tcGroupInterface>("GroupInterfaceClass") + .def("GetPlatformInterface", &tcGroupInterface::GetPlatformInterface) + .def("GetUnitCount", &tcGroupInterface::GetUnitCount) + .def("GetUnitId", &tcGroupInterface::GetUnitId) + ; + GroupInterface = GroupInterfaceType(); + groupInterface = extract<tcGroupInterface*>(GroupInterface); + + MenuInterfaceType = class_<tcMenuInterface>("MenuInterfaceClass") .def("AddItem", &tcMenuInterface::AddItem) *************** *** 535,538 **** --- 621,625 ---- PyDict_SetItemString(mpDictionary->ptr(), "HookedTrackInfo", TrackInterface.ptr()); PyDict_SetItemString(mpDictionary->ptr(), "ScenarioManager", ScenarioInterface.ptr()); + PyDict_SetItemString(mpDictionary->ptr(), "GroupInfo", GroupInterface.ptr()); PyDict_SetItemString(mpDictionary->ptr(), "Y", PyInt_FromLong(2)); /* dict['Y']=2 */ *************** *** 556,560 **** ! tcSimPythonInterface::~tcSimPythonInterface(void) { --- 643,647 ---- ! tcSimPythonInterface::~tcSimPythonInterface() { Index: tcPlatformInterfaceExtension.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterfaceExtension.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcPlatformInterfaceExtension.cpp 8 Aug 2004 00:31:34 -0000 1.10 --- tcPlatformInterfaceExtension.cpp 16 Aug 2004 01:43:31 -0000 1.11 *************** *** 52,55 **** --- 52,56 ---- .def_readonly("Affiliation",&tcTrack::mnAffiliation) .def_readonly("ID",&tcTrack::mnID) + .def_readonly("Time", &tcTrack::mfTimestamp) .def("IsAir", &tcTrack::IsAir) .def("IsMissile", &tcTrack::IsMissile) *************** *** 57,60 **** --- 58,62 ---- .def("IsValid", &tcTrack::IsValid) .def("Offset", &tcTrack::Offset) + .def("PredictAhead", &tcTrack::PredictAhead) ; *************** *** 68,71 **** --- 70,74 ---- .def_readonly("Affiliation",&tcSensorMapTrack::mnAffiliation) .def_readonly("ID",&tcSensorMapTrack::mnID) + .def_readonly("Time", &tcSensorMapTrack::mfTimestamp) .def("IsAir", &tcSensorMapTrack::IsAir) .def("IsMissile", &tcSensorMapTrack::IsMissile) *************** *** 73,76 **** --- 76,80 ---- .def("IsValid", &tcSensorMapTrack::IsValid) .def("Offset", &tcSensorMapTrack::Offset) + .def("PredictAhead", &tcSensorMapTrack::PredictAhead) .def("GetEngagedCount", &tcSensorMapTrack::GetEngagedCount) ; --- NEW FILE: tcGroupInterface.cpp --- /** ** @file tcGroupInterface.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" #ifdef WIN32 #include "wx/msw/private.h" // for MS Windows specific definitions #endif // WIN32 #endif #include "tcGroupInterface.h" #include "tcPlatformInterface.h" #include "tcSimState.h" #ifdef _DEBUG #define new DEBUG_NEW #endif namespace ScriptInterface { tcSimState* tcGroupInterface::simState = NULL; /** * @return tcPlatformInterface object for group member <idx> */ tcPlatformInterface tcGroupInterface::GetPlatformInterface(int idx) { long id = GetUnitId(idx); tcGameObject* gameObj = simState->GetObject(id); if (tcPlatformObject* platformObj = dynamic_cast<tcPlatformObject*>(gameObj)) { return tcPlatformInterface(platformObj); } else { fprintf(stderr, "tcGroupInterface::GetPlatformInterface - " "returned NULL or non-platform obj\n"); return tcPlatformInterface(); } } /** * */ int tcGroupInterface::GetUnitCount() { return (int)groupUnits.size(); } /** * */ long tcGroupInterface::GetUnitId(int idx) { if ((size_t)idx >= groupUnits.size()) { return -1; } else { return groupUnits[idx]; } } /** * */ void tcGroupInterface::SetUnits(std::vector<long>& units) { groupUnits = units; } /** * */ tcGroupInterface::tcGroupInterface() { if (!simState) { simState = tcSimState::Get(); } groupUnits.clear(); } tcGroupInterface::~tcGroupInterface() { } } Index: tcPlatformInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterface.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** tcPlatformInterface.cpp 29 Jul 2004 00:14:18 -0000 1.26 --- tcPlatformInterface.cpp 16 Aug 2004 01:43:31 -0000 1.27 *************** *** 240,243 **** --- 240,244 ---- { tcKinematics *pTargetKin = &pGameObj->mcKin; + track.mfTimestamp = pGameObj->mfStatusTime; track.mfAlt_m = pTargetKin->mfAlt_m; track.mfHeading_rad = pTargetKin->mfHeading_rad; *************** *** 245,248 **** --- 246,252 ---- track.mfLon_rad = (float)pTargetKin->mfLon_rad; track.mfSpeed_kts = pTargetKin->mfSpeed_kts; + track.mnFlags = TRACK_SPEED_VALID | TRACK_HEADING_VALID | + TRACK_ALT_VALID; + track.mnClassification = pGameObj->mpDBObject->mnType; track.mnAffiliation = FRIENDLY; *************** *** 250,253 **** --- 254,259 ---- track.intercepts.clear(); track.assessedDamage = pGameObj->mfDamageLevel; + + return true; } *************** *** 303,307 **** } ! tcSensorMapTrack tcPlatformInterface::GetTargetTrackInfo(void) { tcSensorMapTrack track; --- 309,313 ---- } ! tcSensorMapTrack tcPlatformInterface::GetTargetTrackInfo() { tcSensorMapTrack track; *************** *** 311,314 **** --- 317,340 ---- } + float tcPlatformInterface::GetLauncherInterceptTime(int anLauncher, + tcSensorMapTrack& track) + { + wxASSERT(mpPlatformObj); + + tcLauncherState* launcherState; + mpPlatformObj->GetLauncherState(launcherState); + + if (launcherState) + { + return launcherState->EstimateInterceptTimeForLauncher(anLauncher, track); + } + else + { + fprintf(stderr, "tcPlatformInterface::EstimateLauncherInterceptTime" + " - NULL launcherState\n"); + return 0; + } + } + /** * If target is valid, sets heading to intercept target. *************** *** 952,955 **** --- 978,1004 ---- tcMapData* tcPlatformInterface::mapData = NULL; + tcPlatformInterface::tcPlatformInterface() + : mpPlatformObj(0) + { + wxASSERT(mpSimState); + } + + tcPlatformInterface::tcPlatformInterface(tcPlatformObject* obj) + : mpPlatformObj(obj) + { + wxASSERT(mpSimState); + + isPlatformOwnAlliance = (mpPlatformObj) ? + (mpSimState->mpUserInfo->IsOwnAlliance(mpPlatformObj->mnAlliance) != 0) : false; + + mpSensorMap = mpSimState->mcSensorMap.GetMap(mpPlatformObj->mnAlliance); + wxASSERT(mpSensorMap); + } + + tcPlatformInterface::~tcPlatformInterface() + { + } + + } |
|
From: Dewitt C. <ddc...@us...> - 2004-08-16 01:43:40
|
Update of /cvsroot/gcblue/gcb_wx/include/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3228/include/scriptinterface Modified Files: tcPlatformInterface.h tcSimPythonInterface.h Added Files: tcGroupInterface.h Log Message: Index: tcPlatformInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/scriptinterface/tcPlatformInterface.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tcPlatformInterface.h 9 Aug 2004 02:35:14 -0000 1.23 --- tcPlatformInterface.h 16 Aug 2004 01:43:29 -0000 1.24 *************** *** 35,39 **** namespace Sensor { ! class tcAllianceSensorMap; } class tcSimState; --- 35,39 ---- namespace Sensor { ! class tcAllianceSensorMap; } class tcSimState; *************** *** 43,303 **** namespace ScriptInterface { ! class tcFlightPortInterface; ! class tcLauncherInfo ! { ! public: ! int mnLauncher; // index of launcher, or -1 for none ! int mnQuantity; ! int mnTargetFlags; // 0x01 - surface, 0x02 - air, 0x04 - land ! float mfRange_km; ! int mnLaunchMode; // 0 - datum, 1 - handoff ! }; ! class tcSensorInfo ! { ! public: ! int isActive; // 0 if OFF, 1 if ON ! int type; // 0 radar, 1 ESM, 255 Error, more in the future ! }; ! // wrapper around tcSensorMapTrack with additional info for iterating ! class tcTrackIterator : public tcSensorMapTrack ! { ! public: ! long mnKey; ! }; ! class tcTrackList ! { ! public: ! std::vector<tcSensorMapTrack> track; ! tcSensorMapTrack GetTrack(int n) {return track[n];} ! int Size() {return (int)track.size();} ! tcTrackList() {track.clear();} ! }; ! /** ! * Interface class for Python-unit interface. ! * Holds static reference to platform of interest, ! * this static reference is set before passing object to Python. ! * Note, there is probably a better way to do this. ! */ ! class tcPlatformInterface ! { ! public: ! double mfCurrentTime; ! static void InitPythonClassesA(void); ! static object InitPythonPlatformInterface(); ! static object GetPlatformInterface(); ! // basic nav commands: heading, speed, altitude ! /// gets platform altitude in meters ! float GetAltitude() {return mpPlatformObj->mcKin.mfAlt_m;} ! /// gets fraction of fuel remaining from 0 - 1 ! float GetFuel() const; ! /// gets max altitude in meters indicated in database entry. ! float GetMaxAltitude(); ! /// gets current platform speed in kts ! float GetSpeed(); ! /// gets max platform speed indicated in database (only a nominal max for aerodynamic air platforms) ! float GetMaxSpeed(); ! /// gets current heading in degrees ! float GetHeading(); ! /// gets current heading in radians ! float GetHeadingRad(); ! /// gets height of terrain in meters at (lon, lat) ! float GetMapTerrainElevation(float lon_rad, float lat_rad); ! /// gets height of terrain under platform in meters ! float GetTerrainElevation(); ! /// true if platform has a throttle control (aero air models) ! bool HasThrottle(); ! /// set goal altitude for platform in meters ! /** ! * For air objects ! * @param alt_m goal altitude of platform in meters ! */ ! void SetAltitude(float alt_m) {mpPlatformObj->mcGS.mfGoalAltitude_m = alt_m;} ! /// sets maximum +/- pitch for air objects in degrees, workaround to slow descent for cv landing ! void SetPitchLimitDeg(float lim_deg); ! /// sets speed of platform ! void SetSpeed(float speed_kts) {mpPlatformObj->SetSpeed(speed_kts);} ! /// set speed of platform to maximum speed (use SetThrottle for aero air objects) ! void SetSpeedToMax(void); ! /// set throttle for air objects ! /** ! * for air objects, sets throttle ! * @param throttleFraction 0 - 1.1, use 0 - 1 for non afterburning throttle, 1.1 for afterburners ! */ ! void SetThrottle(float throttleFraction); ! /// sets heading in degrees ! void SetHeading(float heading_deg) {mpPlatformObj->SetHeading(C_PIOVER180*heading_deg);} ! /// sets heading in radians ! void SetHeadingRad(float heading_rad) {mpPlatformObj->SetHeading(heading_rad);} ! /// get heading to (lon,lat) datum in degrees ! float GetHeadingToDatum(float afLon_rad, float afLat_rad); ! /// get range to (lon,lat) datum in km ! float GetRangeToDatum(float afLon_rad, float afLat_rad); ! // platform info ! /// get unit name of platform ! std::string GetPlatformName(void); ! /// get database class name of platform ! std::string GetPlatformClass(void); ! /// returns true if platform is a surface platform ! bool IsSurface() {return (mpPlatformObj->mnModelType == MTYPE_SURFACE);} ! /// returns true if platform is an air platform ! bool IsAir() ! { ! UINT32 nModelType = mpPlatformObj->mnModelType; ! return (nModelType == MTYPE_FIXEDWING)||(nModelType == MTYPE_FIXEDWINGX) ! ||(nModelType == MTYPE_AIR)||(nModelType == MTYPE_HELO); ! } ! bool IsHelo() ! { ! return (mpPlatformObj->mnModelType == MTYPE_HELO); ! } ! // script variables ! /// returns user variable n ! UINT32 GetVar(int n) {return mpPlatformObj->mcAI.GetVar(n);} ! /// sets user variable n ! void SetVar(int n, UINT32 val) {mpPlatformObj->mcAI.SetVar(n,val);} ! ! // target commands ! /// set target for platform ! void SetTarget(long anID) {mpPlatformObj->DesignateTarget(anID);} ! /// get platform target, -1 for no target ! long GetTarget(void) {return mpPlatformObj->mcAI.GetTarget();} ! /// get range to target in km ! float GetRangeToTarget(void); ! /// get track info object for target ! tcSensorMapTrack GetTargetTrackInfo(void); ! tcGameObject* GetTargetObj(void); ! bool GetTargetTrack(tcSensorMapTrack& track); ! /// returns true if launcher is effective vs. current target ! bool IsLauncherEffective(int anLauncher); ! /// if target is valid, sets heading to intercept target. ! float SetHeadingToInterceptTarget(void); - // weapon related commands - /// gets launcher info object for best launcher for target - tcLauncherInfo GetBestLauncher(void); - /// gets number of launchers available on platform - int GetLauncherCount(void); - /// sets datum for launcher - void SendDatumToLauncher(float afLon_rad, float afLat_rad, float alt_m, int anLauncher); - /// hands off platform target to launcher - bool HandoffTargetToLauncher(int anLauncher); - /// orders launch - void Launch(int anLauncher, int quantity); - /// get class name of launcher weapon - std::string GetLauncherWeaponName(int anLauncher); - /// get quantity available for launch in launcher - int GetLauncherQuantity(int anLauncher); - /// true if launcher can launch using datum only (i.e. no track just a set of coordinates) - bool IsDatumLaunch(int anLauncher) {return mpPlatformObj->mcLauncherState.IsDatumLaunch(anLauncher);} - bool GetLauncherInfo(tcLauncherInfo& info, int anLauncher); ! // order related commands ! /// true if platform has any orders ! bool HasOrders(void); ! /// gets order info object for current platform order ! tcOrder GetCurrentOrder(void); ! /// called to indicate current order is complete and to move to next order ! void CompletedOrder(void); ! /// adds generic order ! void AddOrder(std::string order_text, long data = -1); ! /// adds navigation order ! void AddNavOrder(float afLon_rad, float afLat_rad); ! /// clear all orders ! void ClearOrders(void); ! /// delete order ! void DeleteOrder(int n); ! /// get total number of orders ! int GetOrderCount(); ! /// get order info object for order n ! tcOrder GetOrder(int n); ! // sensor map and sensor commands ! /// get first track in alliance sensor map, track iterator object is returned ! tcTrackIterator GetFirstTrack(void); ! /// gets total number of tracks in alliance sensor map ! int GetTrackCount(void); ! /// gets next track in sensor map, nPos is obtained from track iterator from last call ! tcTrackIterator GetNextTrack(long nPos); ! /// gets number of sensors on platform ! int GetSensorCount(); ! /// gets sensor info object for sensor n ! tcSensorInfo GetSensorInfo(int n); ! /// sets state of sensor n, 0 - off, 1 - on ! void SetSensorState(int n, int state); ! /// sets state of all sensors on platform, 0 - off, 1 - on ! void SetAllSensorState(int anState); ! /// gets track info object for closest track within range that matches classification and affiliation parameters ! tcSensorMapTrack GetClosestTrack(float afMaxRange_km, UINT16 anClassMask, ! UINT8 anAffiliation, int maxEngagements); ! /// gets track info object for closest air track within range matching affiliation ! tcSensorMapTrack GetClosestAirTrack(float afMaxRange_km, ! UINT8 anAffiliation, int maxEngagements); ! /// gets track info object for closest surface track within range matching affiliation ! tcSensorMapTrack GetClosestSurfaceTrack(float afMaxRange_km, ! UINT8 anAffiliation, int maxEngagements); ! /// gets track info object for closest missile track within range matching affiliation ! tcSensorMapTrack GetClosestMissileTrack(float afMaxRange_km, ! UINT8 anAffiliation, int maxEngagements); ! /// gets track list object that has all tracks within range matching affiliation ! tcTrackList GetTrackList(int anClassMask, float afMaxRange_km, UINT8 anAffiliation); ! /// get intercept heading to track in radians ! float GetInterceptHeadingToTrack(const tcSensorMapTrack& track); ! // get range to track in km ! float GetRangeToTrack(const tcSensorMapTrack& track); ! /// set heading to intercept track ! float SetHeadingToInterceptTrack(tcSensorMapTrack track); ! /// get track info object corresponding to track id ! tcSensorMapTrack GetTrackById(long id); ! // flightport (airstrip, cv flight deck, helo pad) ! /// true if platform has a flight port (e.g. carrier) ! bool HasFlightPort(void); ! tcFlightPortInterface GetFlightPortInfo(void); ! tcTrack GetLandingData(long id); ! int GetLandingState(); ! void SetLandingState(int state); ! // miscellaneous ! void GetUserInput(std::string callback, std::string uitype); ! void SendCommand(std::string command); ! /// display text message in user console ! void DisplayMessage(std::string text); ! /// play sound effect ! void PlaySound(int n); ! /// sets text displayed in platform info panel ! void SetActionText(std::string text) {mpPlatformObj->mcAI.mzActionText = text;} ! /// sets update interval for AI script revisits ! void SetUpdateInterval(float afInterval) {mpPlatformObj->mcAI.mfUpdateInterval = (afInterval >= 0.25) ? afInterval : 0.25f;} ! /// returns a random number between 0 and 1 ! float GetRand() {return randf();} ! static void SetObj(tcPlatformObject *apObj) {mpStaticPlatformObj = apObj;} ! void GetLocalObj(void); ! void SetPlatform(tcPlatformObject *obj); ! static void AttachCommandQueue(tcCommandQueue *cq) {mpCommandQueue = cq;} ! static void AttachSimState(tcSimState *apSS) {mpSimState = apSS;} ! static void AttachConsole(tcSoundConsole *apConsole) {mpConsole = apConsole;} ! static void AttachMapData(tcMapData* md) {mapData = md;} ! void GetSensorMap(void); ! private: ! tcPlatformObject *mpPlatformObj; ! bool isPlatformOwnAlliance; ///< true if platform is part of user's alliance ! static tcPlatformObject *mpStaticPlatformObj; ! static tcSimState *mpSimState; ! static tcAllianceSensorMap *mpSensorMap; ! static tcSoundConsole *mpConsole; ! static tcCommandQueue *mpCommandQueue; // for requesting GUI commands ! static tcMapData* mapData; ///< for getting terrain elevation ! }; } #endif \ No newline at end of file --- 43,310 ---- namespace ScriptInterface { ! class tcFlightPortInterface; ! class tcLauncherInfo ! { ! public: ! int mnLauncher; // index of launcher, or -1 for none ! int mnQuantity; ! int mnTargetFlags; // 0x01 - surface, 0x02 - air, 0x04 - land ! float mfRange_km; ! int mnLaunchMode; // 0 - datum, 1 - handoff ! }; ! class tcSensorInfo ! { ! public: ! int isActive; // 0 if OFF, 1 if ON ! int type; // 0 radar, 1 ESM, 255 Error, more in the future ! }; ! // wrapper around tcSensorMapTrack with additional info for iterating ! class tcTrackIterator : public tcSensorMapTrack ! { ! public: ! long mnKey; ! }; ! class tcTrackList ! { ! public: ! std::vector<tcSensorMapTrack> track; ! tcSensorMapTrack GetTrack(int n) {return track[n];} ! int Size() {return (int)track.size();} ! tcTrackList() {track.clear();} ! }; ! /** ! * Interface class for Python-unit interface. ! * Holds static reference to platform of interest, ! * this static reference is set before passing object to Python. ! * Note, there is probably a better way to do this. ! */ ! class tcPlatformInterface ! { ! public: ! double mfCurrentTime; ! static void InitPythonClassesA(void); ! static object InitPythonPlatformInterface(); ! static object GetPlatformInterface(); ! // basic nav commands: heading, speed, altitude ! /// gets platform altitude in meters ! float GetAltitude() {return mpPlatformObj->mcKin.mfAlt_m;} ! /// gets fraction of fuel remaining from 0 - 1 ! float GetFuel() const; ! /// gets max altitude in meters indicated in database entry. ! float GetMaxAltitude(); ! /// gets current platform speed in kts ! float GetSpeed(); ! /// gets max platform speed indicated in database (only a nominal max for aerodynamic air platforms) ! float GetMaxSpeed(); ! /// gets current heading in degrees ! float GetHeading(); ! /// gets current heading in radians ! float GetHeadingRad(); ! /// gets height of terrain in meters at (lon, lat) ! float GetMapTerrainElevation(float lon_rad, float lat_rad); ! /// gets height of terrain under platform in meters ! float GetTerrainElevation(); ! /// true if platform has a throttle control (aero air models) ! bool HasThrottle(); ! /// set goal altitude for platform in meters ! /** ! * For air objects ! * @param alt_m goal altitude of platform in meters ! */ ! void SetAltitude(float alt_m) {mpPlatformObj->mcGS.mfGoalAltitude_m = alt_m;} ! /// sets maximum +/- pitch for air objects in degrees, workaround to slow descent for cv landing ! void SetPitchLimitDeg(float lim_deg); ! /// sets speed of platform ! void SetSpeed(float speed_kts) {mpPlatformObj->SetSpeed(speed_kts);} ! /// set speed of platform to maximum speed (use SetThrottle for aero air objects) ! void SetSpeedToMax(void); ! /// set throttle for air objects ! /** ! * for air objects, sets throttle ! * @param throttleFraction 0 - 1.1, use 0 - 1 for non afterburning throttle, 1.1 for afterburners ! */ ! void SetThrottle(float throttleFraction); ! /// sets heading in degrees ! void SetHeading(float heading_deg) {mpPlatformObj->SetHeading(C_PIOVER180*heading_deg);} ! /// sets heading in radians ! void SetHeadingRad(float heading_rad) {mpPlatformObj->SetHeading(heading_rad);} ! /// get heading to (lon,lat) datum in degrees ! float GetHeadingToDatum(float afLon_rad, float afLat_rad); ! /// get range to (lon,lat) datum in km ! float GetRangeToDatum(float afLon_rad, float afLat_rad); ! // platform info ! /// get unit name of platform ! std::string GetPlatformName(void); ! /// get database class name of platform ! std::string GetPlatformClass(void); ! /// returns true if platform is a surface platform ! bool IsSurface() {return (mpPlatformObj->mnModelType == MTYPE_SURFACE);} ! /// returns true if platform is an air platform ! bool IsAir() ! { ! UINT32 nModelType = mpPlatformObj->mnModelType; ! return (nModelType == MTYPE_FIXEDWING)||(nModelType == MTYPE_FIXEDWINGX) ! ||(nModelType == MTYPE_AIR)||(nModelType == MTYPE_HELO); ! } ! bool IsHelo() ! { ! return (mpPlatformObj->mnModelType == MTYPE_HELO); ! } ! // script variables ! /// returns user variable n ! UINT32 GetVar(int n) {return mpPlatformObj->mcAI.GetVar(n);} ! /// sets user variable n ! void SetVar(int n, UINT32 val) {mpPlatformObj->mcAI.SetVar(n,val);} + // target commands + /// set target for platform + void SetTarget(long anID) {mpPlatformObj->DesignateTarget(anID);} + /// get platform target, -1 for no target + long GetTarget() {return mpPlatformObj->mcAI.GetTarget();} + /// get range to target in km + float GetRangeToTarget(void); + /// get track info object for target + tcSensorMapTrack GetTargetTrackInfo(); + tcGameObject* GetTargetObj(); + bool GetTargetTrack(tcSensorMapTrack& track); + /// estimates time for launched missile / gun to intercept track + float GetLauncherInterceptTime(int anLauncher, tcSensorMapTrack& track); + /// returns true if launcher is effective vs. current target + bool IsLauncherEffective(int anLauncher); + /// if target is valid, sets heading to intercept target. + float SetHeadingToInterceptTarget(); ! // weapon related commands ! /// gets launcher info object for best launcher for target ! tcLauncherInfo GetBestLauncher(void); ! /// gets number of launchers available on platform ! int GetLauncherCount(void); ! /// sets datum for launcher ! void SendDatumToLauncher(float afLon_rad, float afLat_rad, float alt_m, int anLauncher); ! /// hands off platform target to launcher ! bool HandoffTargetToLauncher(int anLauncher); ! /// orders launch ! void Launch(int anLauncher, int quantity); ! /// get class name of launcher weapon ! std::string GetLauncherWeaponName(int anLauncher); ! /// get quantity available for launch in launcher ! int GetLauncherQuantity(int anLauncher); ! /// true if launcher can launch using datum only (i.e. no track just a set of coordinates) ! bool IsDatumLaunch(int anLauncher) {return mpPlatformObj->mcLauncherState.IsDatumLaunch(anLauncher);} ! bool GetLauncherInfo(tcLauncherInfo& info, int anLauncher); ! // order related commands ! /// true if platform has any orders ! bool HasOrders(void); ! /// gets order info object for current platform order ! tcOrder GetCurrentOrder(void); ! /// called to indicate current order is complete and to move to next order ! void CompletedOrder(void); ! /// adds generic order ! void AddOrder(std::string order_text, long data = -1); ! /// adds navigation order ! void AddNavOrder(float afLon_rad, float afLat_rad); ! /// clear all orders ! void ClearOrders(void); ! /// delete order ! void DeleteOrder(int n); ! /// get total number of orders ! int GetOrderCount(); ! /// get order info object for order n ! tcOrder GetOrder(int n); ! // sensor map and sensor commands ! /// get first track in alliance sensor map, track iterator object is returned ! tcTrackIterator GetFirstTrack(void); ! /// gets total number of tracks in alliance sensor map ! int GetTrackCount(void); ! /// gets next track in sensor map, nPos is obtained from track iterator from last call ! tcTrackIterator GetNextTrack(long nPos); ! /// gets number of sensors on platform ! int GetSensorCount(); ! /// gets sensor info object for sensor n ! tcSensorInfo GetSensorInfo(int n); ! /// sets state of sensor n, 0 - off, 1 - on ! void SetSensorState(int n, int state); ! /// sets state of all sensors on platform, 0 - off, 1 - on ! void SetAllSensorState(int anState); ! /// gets track info object for closest track within range that matches classification and affiliation parameters ! tcSensorMapTrack GetClosestTrack(float afMaxRange_km, UINT16 anClassMask, ! UINT8 anAffiliation, int maxEngagements); ! /// gets track info object for closest air track within range matching affiliation ! tcSensorMapTrack GetClosestAirTrack(float afMaxRange_km, ! UINT8 anAffiliation, int maxEngagements); ! /// gets track info object for closest surface track within range matching affiliation ! tcSensorMapTrack GetClosestSurfaceTrack(float afMaxRange_km, ! UINT8 anAffiliation, int maxEngagements); ! /// gets track info object for closest missile track within range matching affiliation ! tcSensorMapTrack GetClosestMissileTrack(float afMaxRange_km, ! UINT8 anAffiliation, int maxEngagements); ! /// gets track list object that has all tracks within range matching affiliation ! tcTrackList GetTrackList(int anClassMask, float afMaxRange_km, UINT8 anAffiliation); ! /// get intercept heading to track in radians ! float GetInterceptHeadingToTrack(const tcSensorMapTrack& track); ! // get range to track in km ! float GetRangeToTrack(const tcSensorMapTrack& track); ! /// set heading to intercept track ! float SetHeadingToInterceptTrack(tcSensorMapTrack track); ! /// get track info object corresponding to track id ! tcSensorMapTrack GetTrackById(long id); ! // flightport (airstrip, cv flight deck, helo pad) ! /// true if platform has a flight port (e.g. carrier) ! bool HasFlightPort(void); ! tcFlightPortInterface GetFlightPortInfo(void); ! tcTrack GetLandingData(long id); ! int GetLandingState(); ! void SetLandingState(int state); ! ! // miscellaneous ! void GetUserInput(std::string callback, std::string uitype); ! void SendCommand(std::string command); ! /// display text message in user console ! void DisplayMessage(std::string text); ! /// play sound effect ! void PlaySound(int n); ! /// sets text displayed in platform info panel ! void SetActionText(std::string text) {mpPlatformObj->mcAI.mzActionText = text;} ! /// sets update interval for AI script revisits ! void SetUpdateInterval(float afInterval) {mpPlatformObj->mcAI.mfUpdateInterval = (afInterval >= 0.25) ? afInterval : 0.25f;} ! /// returns a random number between 0 and 1 ! float GetRand() {return randf();} ! static void SetObj(tcPlatformObject *apObj) {mpStaticPlatformObj = apObj;} ! void GetLocalObj(void); ! void SetPlatform(tcPlatformObject *obj); ! static void AttachCommandQueue(tcCommandQueue *cq) {mpCommandQueue = cq;} ! static void AttachSimState(tcSimState *apSS) {mpSimState = apSS;} ! static void AttachConsole(tcSoundConsole *apConsole) {mpConsole = apConsole;} ! static void AttachMapData(tcMapData* md) {mapData = md;} ! void GetSensorMap(); ! ! tcPlatformInterface(); ! tcPlatformInterface(tcPlatformObject* obj); ! ~tcPlatformInterface(); ! ! private: ! tcPlatformObject *mpPlatformObj; ! bool isPlatformOwnAlliance; ///< true if platform is part of user's alliance ! static tcPlatformObject *mpStaticPlatformObj; ! static tcSimState *mpSimState; ! static tcAllianceSensorMap *mpSensorMap; ! static tcSoundConsole *mpConsole; ! static tcCommandQueue *mpCommandQueue; // for requesting GUI commands ! static tcMapData* mapData; ///< for getting terrain elevation ! }; } #endif \ No newline at end of file --- NEW FILE: tcGroupInterface.h --- /** ** @file tcGroupInterface.h */ /* 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 ** ** Python interface to tcPanel for scripting */ #ifndef __tcGroupInterface_h__ #define __tcGroupInterface_h__ #if _MSC_VER > 1000 #pragma once #endif #include <vector> class tcSimState; namespace ScriptInterface { class tcPlatformInterface; /** * Class to control and build menus in python for groups of units */ class tcGroupInterface { public: /// returns tcPlatformInterface object for unit <idx> in group tcPlatformInterface GetPlatformInterface(int idx); /// number of units in group, zero for none int GetUnitCount(); /// unit id of unit <idx> in group, -1 for error long GetUnitId(int idx); /// sets id vector for units in group void SetUnits(std::vector<long>& units); static void AttachSimState(tcSimState* ss) {simState = ss;} tcGroupInterface(); ~tcGroupInterface(); private: static tcSimState* simState; std::vector<long> groupUnits; }; } #endif // __tcGroupInterface_h__ Index: tcSimPythonInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/scriptinterface/tcSimPythonInterface.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcSimPythonInterface.h 8 Aug 2004 00:31:32 -0000 1.13 --- tcSimPythonInterface.h 16 Aug 2004 01:43:30 -0000 1.14 *************** *** 36,39 **** --- 36,40 ---- #include "tcFlightPortInterface.h" #include "tcPanelInterface.h" + #include "tcGroupInterface.h" *************** *** 86,91 **** void AttachSensorMap(tcAllianceSensorMap *apSM) {tcTrackInterface::AttachSensorMap(apSM);} void AttachSimState(tcSimState *apSimState); ! void BuildPlatformMenu(); // creates platform menu customized to object ! void BuildTrackMenu(); // creates menu for track commands void BuildFlightPortPanel(); void CallPython(const char *commandtext, const char *errortext); --- 87,93 ---- void AttachSensorMap(tcAllianceSensorMap *apSM) {tcTrackInterface::AttachSensorMap(apSM);} void AttachSimState(tcSimState *apSimState); ! void BuildGroupMenu(); ///< creates menu customized to group of units ! void BuildPlatformMenu(); ///< creates menu customized to unit ! void BuildTrackMenu(); ///< creates menu for track commands void BuildFlightPortPanel(); void CallPython(const char *commandtext, const char *errortext); *************** *** 93,96 **** --- 95,99 ---- void LoadScenario(const char *filePath, const char *fileName); ///< loads scenario from Python script file void SetMenuPlatform(long anID); + void SetMenuGroup(std::vector<long>& unitIds); void ProcessCommand(std::string command, int param = -1); void ProcessCallback(std::string command, float afData, int param); *************** *** 100,112 **** void ProcessSecondaryHook(long id); void ReportError(const char* text); ! void SelectFlightInterface(void) {meMenuMode = FLIGHT_MENU;} ! void SelectTrackMenu(void) {meMenuMode = TRACK_MENU;} ! void SelectUnitMenu(void) {meMenuMode = UNIT_MENU;} ! tcSimPythonInterface(void); ! virtual ~tcSimPythonInterface(void); private: object PlatformInterface; ///< python tcPlatformInterface tcPlatformInterface *platformInterface; ///< C++ handle to PlatformInterface object HookedPlatformInterface; ///< interface for hooked platform for menu tcPlatformInterface *hookedInterface; ///< C++ handle to hooked plat interface --- 103,121 ---- void ProcessSecondaryHook(long id); void ReportError(const char* text); ! void SelectFlightInterface(); ///< change to flightport menu ! void SelectTrackMenu(); ///< change to track menu ! void SelectUnitMenu(); ///< change to unit menu ! void SelectGroupMenu(); ///< change to group menu ! tcSimPythonInterface(); ! virtual ~tcSimPythonInterface(); private: object PlatformInterface; ///< python tcPlatformInterface tcPlatformInterface *platformInterface; ///< C++ handle to PlatformInterface + + object GroupInterfaceType; + object GroupInterface; ///< python tcGroupInterface + tcGroupInterface* groupInterface; ///< C++ handle to GroupInterface + object HookedPlatformInterface; ///< interface for hooked platform for menu tcPlatformInterface *hookedInterface; ///< C++ handle to hooked plat interface *************** *** 124,129 **** tcPlatformObject *mpHookedObj; tcSoundConsole *mpConsole; ! enum teInterfaceMode { UNIT_MENU, TRACK_MENU, FLIGHT_MENU --- 133,140 ---- tcPlatformObject *mpHookedObj; tcSoundConsole *mpConsole; ! enum teInterfaceMode ! { UNIT_MENU, + GROUP_MENU, TRACK_MENU, FLIGHT_MENU |