[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.100,1.101 tcMenu.cpp,1.6,1.7
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-10-29 02:51:04
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17989/src/sim Modified Files: Game.cpp tcMenu.cpp Log Message: A few more changes related to GDI+ replacement Index: tcMenu.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMenu.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcMenu.cpp 8 Aug 2004 00:31:35 -0000 1.6 --- tcMenu.cpp 29 Oct 2004 02:50:54 -0000 1.7 *************** *** 1,6 **** ! /* ! ** tcMenu.cpp ! ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- ! /** ! ** @file tcMenu.cpp ! */ ! /* Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 23,75 **** #ifndef WX_PRECOMP #endif #include "tcMenu.h" ! using namespace Gdiplus; using namespace std; ! // static GDI+ object init ! Pen* tcMenu::mpPen = NULL; ! SolidBrush* tcMenu::mpBrush = NULL; ! Font* tcMenu::mpFont = NULL; ! unsigned tcMenu::mnReferenceCount = 0; ! WCHAR tcMenu::mzwchar[255]; void tcMenu::AddItem(string caption, int command) { ! if (mpCurrent == this) ! { ! tsMenuData md; ! md.Clear(); ! md.mzCaption = caption; ! md.mzCommand = ""; ! md.mzUserInput = ""; ! md.mnCommand = command; ! maMenuData.push_back(md); ! } ! else ! { ! mpCurrent->AddItem(caption, command); ! } } void tcMenu::AddItem(string caption, std::string command, int param) { ! if (mpCurrent == this) ! { ! tsMenuData md; ! md.Clear(); ! md.mzCaption = caption; ! md.mzCommand = command; ! md.mzUserInput = ""; ! md.mnCommand = param; ! maMenuData.push_back(md); ! } ! else { ! mpCurrent->AddItem(caption, command, param); ! } } --- 23,72 ---- #ifndef WX_PRECOMP + #include "wx/wx.h" #endif #include "tcMenu.h" ! using namespace std; ! ! tc3DWindow* tcMenu::parentWindow = 0; void tcMenu::AddItem(string caption, int command) { ! if (mpCurrent == this) ! { ! tsMenuData md; ! md.Clear(); ! md.mzCaption = caption; ! md.mzCommand = ""; ! md.mzUserInput = ""; ! md.mnCommand = command; ! maMenuData.push_back(md); ! } ! else ! { ! mpCurrent->AddItem(caption, command); ! } } void tcMenu::AddItem(string caption, std::string command, int param) { ! if (mpCurrent == this) ! { ! tsMenuData md; ! md.Clear(); ! md.mzCaption = caption; ! md.mzCommand = command; ! md.mzUserInput = ""; ! md.mnCommand = param; ! maMenuData.push_back(md); ! } ! else { ! mpCurrent->AddItem(caption, command, param); ! } } *************** *** 80,382 **** void tcMenu::AddItemUI(std::string caption, std::string callback, std::string input, int param) { ! if (mpCurrent == this) ! { ! tsMenuData md; ! md.Clear(); ! md.mzCaption = caption; ! md.mzCommand = callback; ! md.mzUserInput = input; ! md.mnCommand = param; ! maMenuData.push_back(md); ! } ! else ! { ! mpCurrent->AddItemUI(caption, callback, input, param); ! } } void tcMenu::BeginSubMenu() { ! if (mpCurrent == this) ! { ! int nSize = (int)maMenuData.size(); ! if (nSize == 0) {return;} // can't add submenu to empty menu ! tsMenuData& md = maMenuData[nSize-1]; ! if (md.mpSubMenu == NULL) ! { ! // create new menu with this as parent ! tcMenu *pNewMenu = new tcMenu(this); ! md.mpSubMenu = pNewMenu; ! } ! // set mpCurrent to submenu of last item ! mpCurrent = md.mpSubMenu; ! md.mnCommand = 0; // item with subitems can't have command ! md.mzCommand = ""; ! } ! else ! { ! mpCurrent->BeginSubMenu(); ! } } ! void tcMenu::EndSubMenu() { ! if (mpCurrent == this) { ! if (mpParent == NULL) {return;} // error endsub on top level ! mpParent->mpCurrent = mpParent; ! } ! else { ! mpCurrent->EndSubMenu(); ! } } ! void tcMenu::ClearSelected() { ! int nMenuSize = (int)maMenuData.size(); ! for(int i=0;i<nMenuSize;i++) { ! tsMenuData *pmd = &maMenuData[i]; ! pmd->mbSelected = false; ! if (pmd->mpSubMenu != NULL) {pmd->mpSubMenu->ClearSelected();} ! } } ! void tcMenu::Clear() { ! int nMenuSize = (int)maMenuData.size(); ! // clear submenus first ! for(int i=0;i<nMenuSize;i++) { ! tsMenuData *pmd = &maMenuData[i]; ! if (pmd->mpSubMenu != NULL) { ! pmd->mpSubMenu->Clear(); ! delete pmd->mpSubMenu; ! pmd->mpSubMenu = NULL; ! } ! } ! maMenuData.clear(); ! mbUpdateRegions = true; ! mpCurrent = this; ! mpParent = NULL; } ! int tcMenu::Draw(Graphics *apGraphics) { ! if (mbUpdateRegions) { ! UpdateRegions(apGraphics); ! mbUpdateRegions = false; ! } ! int nMenuSize = (int)maMenuData.size(); // number of items in menu ! ! for (int i=0;i<nMenuSize;i++) { ! tsMenuData *pmd = &maMenuData[i]; ! DrawItem(pmd, apGraphics); ! } ! return 1; } ! void tcMenu::DrawItem(tsMenuData *apMD, Graphics *apGraphics) { ! int nAlpha = 200; ! if (apGraphics==NULL) {return;} ! //if the menu item is selected ! if (apMD->mbSelected) { ! mpBrush->SetColor(Color(nAlpha,0,150,255)); } ! else { ! mpBrush->SetColor(Color(nAlpha,200,200,210)); ! } ! RectF item_rect = apMD->mrect; ! item_rect.Offset(anchor); ! apGraphics->FillRectangle(mpBrush,item_rect); ! ! if (apMD->mbSelected) { ! mpBrush->SetColor(Color(nAlpha,255,255,255)); } - else { - mpBrush->SetColor(Color(nAlpha,0,0,0)); - } ! PointF pointf(apMD->mrect.GetLeft() + 5.0f, apMD->mrect.GetTop()); ! pointf = pointf + anchor; - MultiByteToWideChar(CP_ACP, 0, apMD->mzCaption.c_str(), -1, mzwchar, 255); - apGraphics->DrawString(mzwchar, -1, mpFont, pointf, mpBrush); ! if (apMD->mpSubMenu != NULL) { ! // draw submenu triangle icon ! PointF aSubIcon[3]; // points for tri submenu icon, rel to upper left of item ! aSubIcon[0].X = item_rect.X + mfItemWidth - 2.0f; ! aSubIcon[0].Y = item_rect.Y + 0.5f*item_rect.Height; ! aSubIcon[1].X = aSubIcon[0].X - 5.0f; ! aSubIcon[1].Y = aSubIcon[0].Y - 5.0f; ! aSubIcon[2].X = aSubIcon[1].X; ! aSubIcon[2].Y = aSubIcon[0].Y + 5.0f; ! apGraphics->FillPolygon(mpBrush,aSubIcon,3); ! // if item is selected, draw the submenu ! if (apMD->mbSelected) { ! PointF submenu_offset; ! submenu_offset.X = item_rect.GetRight()-1.0f; ! submenu_offset.Y = item_rect.GetTop(); ! apMD->mpSubMenu->SetAnchor(submenu_offset); ! apMD->mpSubMenu->Draw(apGraphics); ! } ! } } - void tcMenu::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,12,FontStyleBold,UnitPixel); ! if (mpFont == NULL) {throw "DDPopupControl - mpFont creation failed\n";} ! mpBrush = new SolidBrush(Color(0xFEFFFFFF)); // color is ARGB ! if (mpBrush == NULL) {throw "DDPopupControl - mpBrush creation failed\n";} - mnReferenceCount = 0; // reset reference count - } ! void tcMenu::ReleaseGdi() { ! if (mpPen != NULL) {delete mpPen;mpPen=NULL;} ! if (mpFont != NULL) {delete mpFont;mpFont=NULL;} ! if (mpBrush != NULL) {delete mpBrush;mpBrush=NULL;} } ! /*****************************************************************************/ ! /* return pointer to item (NULL for none) containing point */ ! tsMenuData* tcMenu::ItemContainingPoint(PointF point) { ! int nMenuSize = (int)maMenuData.size(); ! ! PointF local_point = point - anchor; // adjust for anchor ! ! for(int i=0;i<nMenuSize;i++) { ! tsMenuData *pmd = &maMenuData[i]; ! if (pmd->mrect.Contains(local_point)) { ! return pmd; ! } ! // if item is selected and has submenu, check submenu ! if ((pmd->mpSubMenu != NULL)&&(pmd->mbSelected)) { ! tsMenuData *psub = pmd->mpSubMenu->ItemContainingPoint(point); ! if (psub != NULL) {return psub;} ! } ! } ! return NULL; // not found } ! /*****************************************************************************/ ! /* select menu item and all parent items containing point */ ! bool tcMenu::UpdateSelection(PointF point) { ! int nMenuSize = (int)maMenuData.size(); ! PointF local_point = point - anchor; // adjust for anchor ! // if (!menubox.Contains(point)) { return NULL;} ! bool bResult = false; ! for(int i=0;i<nMenuSize;i++) { ! tsMenuData *pmd = &maMenuData[i]; ! tcMenu *pSubMenu = pmd->mpSubMenu; ! bool bSelected = pmd->mbSelected; ! if (pmd->mrect.Contains(local_point)) { ! pmd->mbSelected = true; ! if (pSubMenu != NULL) {pSubMenu->ClearSelected();} ! bResult = true; ! } ! else if ((pSubMenu != NULL)&&(bSelected)) { ! if (pSubMenu->UpdateSelection(point) == false) { ! pmd->mbSelected = false; ! } ! else { ! bResult = true; ! } ! } ! else { ! pmd->mbSelected = false; ! } ! } ! return bResult; // not found ! } ! void tcMenu::UpdateRegions(Graphics *apGraphics) { ! float fMaxWidth = 0; ! float fMaxHeight = 0; ! tsMenuData *pmd; ! int nMenuSize = (int)maMenuData.size(); ! ! // find max item width and height ! for(int i=0;i<nMenuSize;i++) { ! RectF boundingBox; ! pmd = &maMenuData[i]; ! MultiByteToWideChar(CP_ACP, 0, pmd->mzCaption.c_str(), -1, mzwchar, 255); ! apGraphics->MeasureString(mzwchar, -1, mpFont, PointF(0,0), &boundingBox); ! fMaxWidth = (boundingBox.Width > fMaxWidth) ? boundingBox.Width : fMaxWidth; ! fMaxHeight = (boundingBox.Height > fMaxHeight) ? boundingBox.Height : fMaxHeight; ! } ! mfItemWidth = fMaxWidth + 12.0f; ! mfItemHeight = fMaxHeight; ! menubox.X = 0; ! menubox.Y = 0; // upper-left corner ! menubox.Width = fMaxWidth + 12.0f; ! menubox.Height = (fMaxHeight + 4.0f)*((float)nMenuSize); ! // set item rectangles ! RectF itemrect; ! itemrect.X = 0; ! itemrect.Y = 0; ! itemrect.Width = mfItemWidth; ! itemrect.Height = mfItemHeight; ! for(int i=0;i<nMenuSize;i++) { ! pmd = &maMenuData[i]; ! pmd->mrect = itemrect; ! itemrect.Y += mfItemHeight - 1.0f; ! } } ! tcMenu::tcMenu(void) { ! maMenuData.clear(); ! mbUpdateRegions = true; ! mpCurrent = this; ! mpParent = NULL; ! ! if (mpPen == NULL) {InitGdi();} ! mnReferenceCount++; } ! tcMenu::tcMenu(tcMenu* apParent) { ! maMenuData.clear(); ! mbUpdateRegions = true; ! mpCurrent = this; ! mpParent = apParent; ! ! if (mpPen == NULL) {InitGdi();} ! mnReferenceCount++; } ! tcMenu::~tcMenu(void) { ! Clear(); ! if (mnReferenceCount == 0) { ! throw "bad reference count"; ! } ! mnReferenceCount--; ! if (mnReferenceCount==0) {ReleaseGdi();} } --- 77,387 ---- void tcMenu::AddItemUI(std::string caption, std::string callback, std::string input, int param) { ! if (mpCurrent == this) ! { ! tsMenuData md; ! md.Clear(); ! md.mzCaption = caption; ! md.mzCommand = callback; ! md.mzUserInput = input; ! md.mnCommand = param; ! maMenuData.push_back(md); ! } ! else ! { ! mpCurrent->AddItemUI(caption, callback, input, param); ! } } void tcMenu::BeginSubMenu() { ! if (mpCurrent == this) ! { ! int nSize = (int)maMenuData.size(); ! if (nSize == 0) {return;} // can't add submenu to empty menu ! tsMenuData& md = maMenuData[nSize-1]; ! if (md.mpSubMenu == NULL) ! { ! // create new menu with this as parent ! tcMenu *pNewMenu = new tcMenu(this); ! md.mpSubMenu = pNewMenu; ! } ! // set mpCurrent to submenu of last item ! mpCurrent = md.mpSubMenu; ! md.mnCommand = 0; // item with subitems can't have command ! md.mzCommand = ""; ! } ! else ! { ! mpCurrent->BeginSubMenu(); ! } } ! void tcMenu::EndSubMenu() ! { ! if (mpCurrent == this) ! { ! if (mpParent == NULL) {return;} // error endsub on top level ! mpParent->mpCurrent = mpParent; ! } ! else { ! mpCurrent->EndSubMenu(); ! } } ! void tcMenu::ClearSelected() ! { ! int nMenuSize = (int)maMenuData.size(); ! for(int i=0;i<nMenuSize;i++) ! { ! tsMenuData *pmd = &maMenuData[i]; ! pmd->mbSelected = false; ! if (pmd->mpSubMenu != NULL) {pmd->mpSubMenu->ClearSelected();} ! } } ! void tcMenu::Clear() ! { ! int nMenuSize = (int)maMenuData.size(); ! // clear submenus first ! for(int i=0;i<nMenuSize;i++) ! { ! tsMenuData *pmd = &maMenuData[i]; ! if (pmd->mpSubMenu != NULL) ! { ! pmd->mpSubMenu->Clear(); ! delete pmd->mpSubMenu; ! pmd->mpSubMenu = NULL; ! } ! } ! maMenuData.clear(); ! mbUpdateRegions = true; ! mpCurrent = this; ! mpParent = NULL; } ! void tcMenu::Draw() ! { ! if (mbUpdateRegions) ! { ! UpdateRegions(); ! mbUpdateRegions = false; ! } ! int nMenuSize = (int)maMenuData.size(); // number of items in menu ! for (int i=0; i<nMenuSize; i++) ! { ! tsMenuData *pmd = &maMenuData[i]; ! DrawItem(pmd); ! } } ! void tcMenu::DrawItem(tsMenuData *apMD) ! { ! float alpha = 0.8f; ! ! osg::Vec4 color(0, 0, 0, 1); ! ! wxASSERT(parentWindow); ! //if the menu item is selected ! if (apMD->mbSelected) ! { ! color.set(0, 0.6f, 1.0f, alpha); } ! else ! { ! color.set(0.8f, 0.8f, 0.84f, alpha); ! } ! tcRect item_rect = apMD->mrect; ! item_rect.Offset(anchor.x, anchor.y); ! parentWindow->DrawRectangleR(item_rect, color, tc3DWindow::FILL_ON); ! if (apMD->mbSelected) ! { ! color.set(1, 1, 1, alpha); ! } ! else ! { ! color.set(0, 0, 0, alpha); ! } ! wxRealPoint pointf(apMD->mrect.GetLeft() + 5.0f, apMD->mrect.GetTop() - 2.0f); ! pointf = pointf + anchor; + parentWindow->DrawTextR(apMD->mzCaption.c_str(), pointf.x, pointf.y, + parentWindow->GetDefaultFont(), color, fontSize, LEFT_BASE_LINE); + if (apMD->mpSubMenu != NULL) + { + #if 0 + // draw submenu triangle icon + PointF aSubIcon[3]; // points for tri submenu icon, rel to upper left of item + aSubIcon[0].X = item_rect.X + mfItemWidth - 2.0f; + aSubIcon[0].Y = item_rect.Y + 0.5f*item_rect.Height; + aSubIcon[1].X = aSubIcon[0].X - 5.0f; + aSubIcon[1].Y = aSubIcon[0].Y - 5.0f; + aSubIcon[2].X = aSubIcon[1].X; + aSubIcon[2].Y = aSubIcon[0].Y + 5.0f; + apGraphics->FillPolygon(mpBrush,aSubIcon,3); + #endif + // if item is selected, draw the submenu + if (apMD->mbSelected) + { + wxRealPoint submenu_offset; + submenu_offset.x = item_rect.GetRight()-1.0f; + submenu_offset.y = item_rect.GetBottom(); + apMD->mpSubMenu->SetAnchor(submenu_offset); + apMD->mpSubMenu->Draw(); + } + } } ! /** ! * @return pointer to item (NULL for none) containing point ! */ ! tsMenuData* tcMenu::ItemContainingPoint(const wxRealPoint& point) ! { ! int nMenuSize = (int)maMenuData.size(); ! wxRealPoint local_point = point - anchor; // adjust for anchor + for(int i=0; i<nMenuSize; i++) + { + tsMenuData *pmd = &maMenuData[i]; + if (pmd->mrect.ContainsPoint(local_point.x, local_point.y)) + { + return pmd; + } ! // if item is selected and has submenu, check submenu ! if ((pmd->mpSubMenu != NULL) && (pmd->mbSelected)) ! { ! tsMenuData *psub = pmd->mpSubMenu->ItemContainingPoint(point); ! if (psub != NULL) {return psub;} ! } ! } ! return NULL; // not found } ! /** ! * select menu item and all parent items containing point ! */ ! bool tcMenu::UpdateSelection(const wxRealPoint& point) ! { ! int nMenuSize = (int)maMenuData.size(); ! wxRealPoint local_point = point - anchor; // adjust for anchor ! // if (!menubox.Contains(point)) { return NULL;} ! bool bResult = false; ! for(int i=0; i<nMenuSize; i++) ! { ! tsMenuData *pmd = &maMenuData[i]; ! tcMenu *pSubMenu = pmd->mpSubMenu; ! bool bSelected = pmd->mbSelected; ! if (pmd->mrect.ContainsPoint(local_point.x, local_point.y)) ! { ! pmd->mbSelected = true; ! if (pSubMenu != NULL) {pSubMenu->ClearSelected();} ! bResult = true; ! } ! else if ((pSubMenu != NULL)&&(bSelected)) ! { ! if (pSubMenu->UpdateSelection(point) == false) ! { ! pmd->mbSelected = false; ! } ! else ! { ! bResult = true; ! } ! } ! else ! { ! pmd->mbSelected = false; ! } ! } ! return bResult; // not found } ! void tcMenu::UpdateRegions() ! { ! int maxWidth = 0; ! int maxHeight = 0; ! tsMenuData *pmd; ! int nMenuSize = (int)maMenuData.size(); ! // find max item width and height ! for(int i=0; i<nMenuSize; i++) ! { ! wxSize boundingBox; ! pmd = &maMenuData[i]; ! parentWindow->MeasureText(parentWindow->GetDefaultFont(), fontSize, pmd->mzCaption.c_str(), ! boundingBox); ! maxWidth = (boundingBox.GetWidth() > maxWidth) ? boundingBox.GetWidth() : maxWidth; ! maxHeight = (boundingBox.GetHeight() > maxHeight) ? boundingBox.GetHeight() : maxHeight; ! } ! mfItemWidth = float(maxWidth) + 12.0f; ! mfItemHeight = float(maxHeight) + 2.0f; ! menubox.left = 0; ! menubox.bottom = 0; // upper-left corner ! menubox.right = menubox.left + float(maxWidth) + 12.0f; ! menubox.top = menubox.bottom + (float(maxHeight) + 4.0f)*((float)nMenuSize); ! // set item rectangles ! tcRect itemrect; ! itemrect.Set(0, mfItemWidth, 0, mfItemHeight); ! for(int i=0; i<nMenuSize; i++) ! { ! pmd = &maMenuData[i]; ! pmd->mrect = itemrect; ! itemrect.bottom += mfItemHeight - 1.0f; ! itemrect.top += mfItemHeight - 1.0f; ! } } ! tcMenu::tcMenu() ! : fontSize(14.0) ! { ! maMenuData.clear(); ! mbUpdateRegions = true; ! mpCurrent = this; ! mpParent = NULL; } ! tcMenu::tcMenu(tcMenu* apParent) ! : fontSize(14.0) ! { ! maMenuData.clear(); ! mbUpdateRegions = true; ! mpCurrent = this; ! mpParent = apParent; } ! tcMenu::~tcMenu() ! { ! Clear(); } Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** Game.cpp 21 Oct 2004 04:11:00 -0000 1.100 --- Game.cpp 29 Oct 2004 02:50:53 -0000 1.101 *************** *** 159,162 **** --- 159,163 ---- enableGraphicsEngine = true; enableTacticalMap = true; + togglePopup = false; std::cout << "Game constructor success" << std::endl; *************** *** 383,386 **** --- 384,389 ---- void tcGame::SwitchToCredit(wxCommandEvent& event) { + if (meGameMode != GM_START) return; + meScreenMode = CREDIT; tcSound::Get()->PlayMusic("tension1"); *************** *** 405,408 **** --- 408,413 ---- void tcGame::SwitchToScenarioSelect(wxCommandEvent& event) { + if (meGameMode != GM_START) return; + meScreenMode = SCENARIOSELECT; } *************** *** 504,511 **** /* start view has to be initialized first so that we can share its 2D surface with the other windows */ ! InitializeDisplaySettingsView(); InitializeOptionsView(); ! InitializeCreditView(); InitializeStartView(); --- 509,516 ---- /* start view has to be initialized first so that we can share its 2D surface with the other windows */ ! InitializeCreditView(); InitializeDisplaySettingsView(); InitializeOptionsView(); ! InitializeStartView(); *************** *** 723,728 **** briefingConsoleLeft = new tcSoundConsole(glCanvas, wxPoint(0,0), wxSize(mnBriefingWidth, leftConsoleHeight), "xml/briefing_left.xml") ; - briefingConsoleLeft->SetBaseRenderBin(10); if (!briefingConsoleLeft) --- 728,733 ---- briefingConsoleLeft = new tcSoundConsole(glCanvas, wxPoint(0,0), wxSize(mnBriefingWidth, leftConsoleHeight), "xml/briefing_left.xml") ; + briefingConsoleLeft->SetBaseRenderBin(10); if (!briefingConsoleLeft) *************** *** 739,750 **** briefingConsoleLeft->SetDelayedTextEffect(true); briefingConsoleLeft->LoadBackgroundImage("briefing_left.jpg"); briefingConsoleLeft->Print(" "); // need this to get it to display ! // add buttons ! //briefingConsoleLeft->AddButton(wxRect(10,leftConsoleHeight-20,50,14), ID_SKIPBRIEFING, "EXIT"); briefingConsoleBottom = new tcSoundConsole(glCanvas, wxPoint(0, mnHeight-mnBottomMargin), wxSize(mnWidth, mnBottomMargin), "xml/briefing_bottom.xml"); ! briefingConsoleBottom->SetBaseRenderBin(10); ! if (!briefingConsoleBottom) { --- 744,754 ---- briefingConsoleLeft->SetDelayedTextEffect(true); briefingConsoleLeft->LoadBackgroundImage("briefing_left.jpg"); + briefingConsoleLeft->Print(" "); // need this to get it to display ! briefingConsoleBottom = new tcSoundConsole(glCanvas, wxPoint(0, mnHeight-mnBottomMargin), wxSize(mnWidth, mnBottomMargin), "xml/briefing_bottom.xml"); ! if (!briefingConsoleBottom) { *************** *** 759,763 **** --- 763,769 ---- briefingConsoleBottom->SetActive(false); briefingConsoleBottom->LoadBackgroundImage("briefing_bottom.jpg"); + briefingConsoleBottom->SetBaseRenderBin(10); briefingConsoleBottom->Print(" "); // need this to get it to display + } *************** *** 838,842 **** tacticalMap = new tcTacticalMapView(glCanvas, wxPoint(mrectMap.left,mrectMap.top), wxSize(mrectMap.right-mrectMap.left, mrectMap.bottom-mrectMap.top)); ! tacticalMap->SetBaseRenderBin(10); tacticalMapSize = TM_LARGE; --- 844,848 ---- tacticalMap = new tcTacticalMapView(glCanvas, wxPoint(mrectMap.left,mrectMap.top), wxSize(mrectMap.right-mrectMap.left, mrectMap.bottom-mrectMap.top)); ! tacticalMap->SetBaseRenderBin(20); tacticalMapSize = TM_LARGE; *************** *** 897,900 **** --- 903,907 ---- wxPoint(mrectLowerLeft.left, mrectLowerLeft.top), wxSize(200,200), "xml/info_console.xml", "InfoConsole"); + infoConsole->SetBaseRenderBin(20); infoConsole->LoadBackgroundImage("start_background.jpg"); messageConsole = infoConsole; *************** *** 909,913 **** // infoConsole->InitGdi(10.0f,0xFF64FF64); infoConsole->SetLineSpacing(10); ! infoConsole->SetWrap(28); infoConsole->SetActive(false); --- 916,920 ---- // infoConsole->InitGdi(10.0f,0xFF64FF64); infoConsole->SetLineSpacing(10); ! //infoConsole->SetWrap(28); infoConsole->SetActive(false); *************** *** 916,920 **** hookInfo = new tcHookInfo(glCanvas, wxPoint(mrectLowerLeft.right,mrectLowerLeft.top), wxSize(200,200)); ! if (!hookInfo) { --- 923,927 ---- hookInfo = new tcHookInfo(glCanvas, wxPoint(mrectLowerLeft.right,mrectLowerLeft.top), wxSize(200,200)); ! hookInfo->SetBaseRenderBin(20); if (!hookInfo) { *************** *** 931,935 **** // objectControl init objectControl = new tcObjectControl(glCanvas, wxPoint(mrectLowerLeft.right+200,mrectLowerLeft.top), wxSize(mnWidth-400,200)); ! if (!objectControl) { --- 938,942 ---- // objectControl init objectControl = new tcObjectControl(glCanvas, wxPoint(mrectLowerLeft.right+200,mrectLowerLeft.top), wxSize(mnWidth-400,200)); ! //objectControl->SetBaseRenderBin(20); if (!objectControl) { *************** *** 952,956 **** mrectOOB.bottom = mnHeight-200; oobView = new tcOOBView(glCanvas, wxPoint(mrectOOB.left,mrectOOB.top), wxSize(mrectOOB.right-mrectOOB.left, mrectOOB.bottom-mrectOOB.top)); ! if (!oobView) { --- 959,963 ---- mrectOOB.bottom = mnHeight-200; oobView = new tcOOBView(glCanvas, wxPoint(mrectOOB.left,mrectOOB.top), wxSize(mrectOOB.right-mrectOOB.left, mrectOOB.bottom-mrectOOB.top)); ! oobView->SetBaseRenderBin(20); if (!oobView) { *************** *** 966,977 **** // popupControl init ! RECT rpopup; ! rpopup.left = 300; ! rpopup.top = 100; ! rpopup.right = 700; ! rpopup.bottom = 700; ! ! popupControl = new tcPopupControl(glCanvas, wxPoint(rpopup.left, rpopup.top), wxSize(rpopup.right - rpopup.left, rpopup.bottom - rpopup.top)); ! if (!popupControl) { --- 973,979 ---- // popupControl init ! popupControl = new tcPopupControl(glCanvas, wxPoint(1400, 400), ! wxSize(300, 300)); ! popupControl->SetBaseRenderBin(30); if (!popupControl) { *************** *** 984,991 **** popupControl->SetActive(false); popupControl->SetBlend(true); ! popupControl->Show(true); // to prevent artifact when displaying for first time ! popupControl->SetSkipCount(0); popupControl->Raise(); // bring popup to top of windows hierarchy to receive mouse events #if 0 --- 986,996 ---- popupControl->SetActive(false); popupControl->SetBlend(true); ! //popupControl->Show(true); // to prevent artifact when displaying for first time ! //popupControl->SetSkipCount(0); popupControl->Raise(); // bring popup to top of windows hierarchy to receive mouse events + wxASSERT(tacticalMap); + + #if 0 *************** *** 1563,1569 **** briefingConsoleLeft->SetActive(false); briefingConsoleBottom->SetActive(false); ! //optionsView->SetActive(false); networkView->SetActive(true); ! // displaySettingsView->SetActive(false); tacticalMap->SetActive(false); worldMap->SetActive(false); --- 1568,1574 ---- briefingConsoleLeft->SetActive(false); briefingConsoleBottom->SetActive(false); ! optionsView->SetActive(false); networkView->SetActive(true); ! displaySettingsView->SetActive(false); tacticalMap->SetActive(false); worldMap->SetActive(false); *************** *** 1580,1585 **** briefingConsoleLeft->SetActive(false); briefingConsoleBottom->SetActive(false); ! //optionsView->SetActive(false); ! //networkView->SetActive(false); displaySettingsView->SetActive(true); tacticalMap->SetActive(false); --- 1585,1590 ---- briefingConsoleLeft->SetActive(false); briefingConsoleBottom->SetActive(false); ! optionsView->SetActive(false); ! networkView->SetActive(false); displaySettingsView->SetActive(true); tacticalMap->SetActive(false); *************** *** 1747,1750 **** --- 1752,1757 ---- ProcessCommandList(); + if (togglePopup) TogglePopup(); // added to avoid asynchronously toggling popup state + mcGameView.Update(gameTime); *************** *** 1929,1932 **** --- 1936,1950 ---- void tcGame::OnRButtonDown(wxMouseEvent& event) { + rightButtonPoint = event.GetPosition(); + togglePopup = true; + } + + /** + * + */ + void tcGame::TogglePopup() + { + togglePopup = false; // clear + if (!popupControl) { *************** *** 1944,1948 **** popupControl->SetMenu(mm); tacticalMap->mbBypassPythonCallback = (mm == MENUMODE_PLATFORMEDIT); ! wxPoint point = event.GetPosition(); // workaround to keep popup submenus on screen if (point.x > mnWidth - 250) point.x = mnWidth - 250; --- 1962,1966 ---- popupControl->SetMenu(mm); tacticalMap->mbBypassPythonCallback = (mm == MENUMODE_PLATFORMEDIT); ! wxPoint point = rightButtonPoint; // workaround to keep popup submenus on screen if (point.x > mnWidth - 250) point.x = mnWidth - 250; *************** *** 1952,1956 **** } - /** * OnKeyDown is called for any key press that isn't captured by another --- 1970,1973 ---- |