MainMenuView.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /*
  2. =======================================================================================
  3. Copyright (C) 2009-2011 id Software LLC, a ZeniMax Media company. All Right Reserved.
  4. This file is part of the DOOM Classic iOS v2.1 GPL Source Code.
  5. =======================================================================================
  6. */
  7. #import "MainMenuView.h"
  8. #import "doomAppDelegate.h"
  9. #include "doomiphone.h"
  10. @implementation Banner_SubItem
  11. @end
  12. @implementation Banner_SubMenu
  13. - (void)awakeFromNib {
  14. isHidden = YES;
  15. }
  16. - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
  17. UIView *hitView = [super hitTest:point withEvent:event];
  18. if (hitView != self) {
  19. return hitView;
  20. }
  21. return nil;
  22. }
  23. - (void) Hide {
  24. if( !isHidden ) {
  25. isHidden = YES;
  26. [UIView beginAnimations:@"Show" context:nil];
  27. [UIView setAnimationDuration:0.5f];
  28. [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
  29. [UIView setAnimationBeginsFromCurrentState:NO];
  30. [UIView setAnimationDelegate:self];
  31. [UIView setAnimationDidStopSelector:@selector(Disable)];
  32. self.alpha = 1.0f;
  33. [ self viewWithTag: 0 ].alpha = 0.0f;
  34. [UIView commitAnimations];
  35. }
  36. }
  37. - (void) Show {
  38. if( isHidden ) {
  39. isHidden = NO;
  40. [UIView beginAnimations:@"Show" context:nil];
  41. [UIView setAnimationDuration:0.5f];
  42. [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
  43. [UIView setAnimationBeginsFromCurrentState:NO];
  44. [UIView setAnimationDelegate:self];
  45. [UIView setAnimationDidStopSelector:@selector(Enable)];
  46. self.alpha = 1.0f;
  47. [ self viewWithTag: 0 ].alpha = 1.0f;
  48. [UIView commitAnimations];
  49. }
  50. }
  51. @end
  52. @implementation MainMenuView
  53. - (void) initialize{
  54. // Hide Everything.
  55. [self ResetMenu];
  56. }
  57. - (void)awakeFromNib {
  58. [self initialize];
  59. }
  60. - (void) ResetMenu {
  61. }
  62. - (IBAction) ResumeGamePressed {
  63. [ gAppDelegate ResumeGame ];
  64. Sound_StartLocalSound( "iphone/baborted_01.wav" );
  65. }
  66. - (IBAction) NewGamePressed {
  67. // Go to the Map Menu.
  68. [gAppDelegate NewGame];
  69. Sound_StartLocalSound( "iphone/baborted_01.wav" );
  70. }
  71. - (IBAction) MultiplayerPressed {
  72. // Go to the MP Menu.
  73. // get the address for the local service, which may
  74. // start up a bluetooth personal area network
  75. boolean serverResolved = ResolveNetworkServer( &netServer.address );
  76. // open our socket now that the network interfaces have been configured
  77. // Explicitly open on interface 1, which is en0. If bluetooth ever starts
  78. // working better, we can handle multiple interfaces.
  79. if ( gameSocket <= 0 ) {
  80. gameSocket = UDPSocket( "en0", DOOM_PORT );
  81. }
  82. // get the address for the local service
  83. if ( !serverResolved ) {
  84. // nobody else is acting as a server, so start one here
  85. RegisterGameService();
  86. SetupEmptyNetGame();
  87. }
  88. menuState = IPM_MULTIPLAYER;
  89. [gAppDelegate HideIB];
  90. Sound_StartLocalSound( "iphone/baborted_01.wav" );
  91. }
  92. - (IBAction) CreditsPressed {
  93. [gAppDelegate CreditsMenu];
  94. Sound_StartLocalSound( "iphone/baborted_01.wav" );
  95. }
  96. - (IBAction) SupportPressed {
  97. [gAppDelegate GotoSupport];
  98. Sound_StartLocalSound( "iphone/baborted_01.wav" );
  99. }
  100. - (IBAction) LegalPressed {
  101. [gAppDelegate LegalMenu];
  102. Sound_StartLocalSound( "iphone/baborted_01.wav" );
  103. }
  104. - (IBAction) DemoPressed {
  105. [gAppDelegate DemoGame ];
  106. Sound_StartLocalSound( "iphone/baborted_01.wav" );
  107. }
  108. - (IBAction) OtherIdGamesPressed {
  109. [gAppDelegate idSoftwareApps];
  110. Sound_StartLocalSound( "iphone/baborted_01.wav" );
  111. }
  112. - (IBAction) ControlsOptionsPressed {
  113. [gAppDelegate ControlsMenu];
  114. Sound_StartLocalSound( "iphone/baborted_01.wav" );
  115. }
  116. - (IBAction) SettingsOptionsPressed {
  117. [gAppDelegate SettingsMenu ];
  118. Sound_StartLocalSound( "iphone/baborted_01.wav" );
  119. }
  120. - (void) ShowPlayBanner {
  121. [ mPlayButton setEnabled: NO ];
  122. [ mSettingsButton setEnabled: YES ];
  123. [ mAboutButton setEnabled: YES ];
  124. [ mExtrasButton setEnabled: YES ];
  125. [ mPlaySubMenu Show ];
  126. [ mSettingsSubMenu Hide ];
  127. [ mExtrasSubMenu Hide ];
  128. [ mAboutSubMenu Hide ];
  129. }
  130. - (void) ShowSettingsBanner {
  131. [ mPlayButton setEnabled: YES ];
  132. [ mSettingsButton setEnabled: NO ];
  133. [ mAboutButton setEnabled: YES ];
  134. [ mExtrasButton setEnabled: YES ];
  135. [ mSettingsSubMenu Show ];
  136. [ mPlaySubMenu Hide ];
  137. [ mExtrasSubMenu Hide ];
  138. [ mAboutSubMenu Hide ];
  139. }
  140. - (void) ShowAboutBanner {
  141. [ mPlayButton setEnabled: YES ];
  142. [ mSettingsButton setEnabled: YES ];
  143. [ mAboutButton setEnabled: NO ];
  144. [ mExtrasButton setEnabled: YES ];
  145. [ mAboutSubMenu Show ];
  146. [ mPlaySubMenu Hide ];
  147. [ mSettingsSubMenu Hide ];
  148. [ mExtrasSubMenu Hide ];
  149. }
  150. - (void) ShowExtrasBanner {
  151. [ mPlayButton setEnabled: YES ];
  152. [ mSettingsButton setEnabled: YES ];
  153. [ mAboutButton setEnabled: YES ];
  154. [ mExtrasButton setEnabled: NO ];
  155. [ mExtrasSubMenu Show ];
  156. [ mPlaySubMenu Hide ];
  157. [ mSettingsSubMenu Hide ];
  158. [ mAboutSubMenu Hide ];
  159. }
  160. @end