mainmenu.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //===========================================================================//
  2. // File: mainmenu.cpp //
  3. // Contents: Main Menu for Links //
  4. //---------------------------------------------------------------------------//
  5. // Copyright (C) Microsoft Corporation. All rights reserved. //
  6. //===========================================================================//
  7. #include "pch.h"
  8. #include "wlib.h"
  9. #include "mainmenu.h"
  10. //#include "resource.h"
  11. #include <assert.h>
  12. #include "EditorInterface.h"
  13. MainMenu *pMainMenu = NULL;
  14. MainMenu::MainMenu(EditorInterface *pEditorInterface):Window(L"MainMenu",0,0,Environment.screenWidth,Environment.screenHeight,pEditorInterface/*pgWinMan->Root()*/,0,0)
  15. {
  16. pMenu = NULL;
  17. bEndModal = false;
  18. pMenu = new Menu(this,0,0,0,0,IDR_EDITOR_MENU,pgRes);
  19. WindowRect(pMenu->WindowRect());
  20. Show();
  21. pMainMenu = this;
  22. m_pEditorInterface = pEditorInterface;
  23. assert(m_pEditorInterface);
  24. /*
  25. DWORD dwCheck = gos_NewTextureFromFile(gos_Texture_Alpha,"data/wlib/check.tga",gosHint_VideoMemory|gosHint_DisableMipmap);
  26. CHECKMARK_APPEARANCE ca;
  27. ca.dwTexture = dwCheck;
  28. ca.fSize = 1.0;
  29. ca.iPixelSize = 16;
  30. ca.ptCheck.x = .0;
  31. ca.ptCheck.y = .0;
  32. pgWinMan->SetCheckMarkAppearance( ca );
  33. */
  34. }
  35. extern bool gos_RunMainLoop( void(*DoGameLogic)() );
  36. extern DWORD TerminateGame; // BUGBUG exported function handles this with return value
  37. void MainMenu::DoModal()
  38. {
  39. while (!TerminateGame && !bEndModal)
  40. {
  41. gos_RunMainLoop( NULL );
  42. pgWinMan->Dispatch();
  43. }
  44. }
  45. void MainMenu::OnCommand(Window *wnd, int nCommand)
  46. {
  47. if (MC_CLICKED == nCommand) {
  48. /* Set focus to parent window (EditorInterface). This is not technically correct.
  49. Technically, focus should be set to the window that previously had it. But at the
  50. moment we know that EditorInterface previously had it. Also, I think perhaps
  51. the Menu class should automatically restore focus appropriately. I could be
  52. wrong. */
  53. if ((pMenu == pgWinMan->InFocus()) || (this == pgWinMan->InFocus()))
  54. {
  55. if (Parent() == 0)
  56. pgWinMan->SetFocus(0);
  57. else
  58. {
  59. if (!Parent()->SetFocus())
  60. pgWinMan->SetFocus(0);
  61. }
  62. }
  63. m_pEditorInterface->handleNewMenuMessage(wnd->GetID());
  64. bEndModal = true;
  65. }
  66. }