MapMenuView.m 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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 "MapMenuView.h"
  8. #import "doomAppDelegate.h"
  9. @implementation MapMenuView
  10. - (void) initialize{
  11. [self resetDifficulty ];
  12. [mapScroller1 setContentSize:CGSizeMake(
  13. mapScroller1.bounds.size.width,
  14. CGRectGetMaxY(lastElement1.frame)
  15. )];
  16. [mapScroller2 setContentSize:CGSizeMake(
  17. mapScroller2.bounds.size.width,
  18. CGRectGetMaxY(lastElement2.frame)
  19. )];
  20. [mapScroller3 setContentSize:CGSizeMake(
  21. mapScroller3.bounds.size.width,
  22. CGRectGetMaxY(lastElement3.frame)
  23. )];
  24. [mapScroller4 setContentSize:CGSizeMake(
  25. mapScroller4.bounds.size.width,
  26. CGRectGetMaxY(lastElement4.frame)
  27. )];
  28. [ playButton setEnabled: NO ];
  29. [ playLabel setEnabled: NO ];
  30. selectedMap = nil;
  31. episodeSelected = -1;
  32. mapSelected = -1;
  33. }
  34. - (void)awakeFromNib {
  35. [self initialize];
  36. }
  37. - (id) initWithCoder:(NSCoder *)aCoder{
  38. if(self = [super initWithCoder:aCoder] ) {
  39. [self initialize];
  40. }
  41. return self;
  42. }
  43. - (id) initWithFrame:(CGRect)rect{
  44. if(self = [super initWithFrame:rect] ) {
  45. [self initialize];
  46. }
  47. return self;
  48. }
  49. - (void) resetDifficulty {
  50. easySelection.hidden = NO;
  51. easySelectionLabel.hidden = NO;
  52. mediumSelection.hidden = YES;
  53. mediumSelectionLabel.hidden = YES;
  54. hardSelection.hidden = YES;
  55. hardSelectionLabel.hidden = YES;
  56. NightmareSelection.hidden = YES;
  57. nightmareSelectionLabel.hidden = YES;
  58. }
  59. - (void) setEpisode: (int) episode {
  60. mapScroller1.alpha = 0.0f;
  61. mapScroller2.alpha = 0.0f;
  62. mapScroller3.alpha = 0.0f;
  63. mapScroller4.alpha = 0.0f;
  64. switch( episode ) {
  65. case 0:
  66. selectedScroller = mapScroller1;
  67. break;
  68. case 1:
  69. selectedScroller = mapScroller2;
  70. break;
  71. case 2:
  72. selectedScroller = mapScroller3;
  73. break;
  74. case 3:
  75. selectedScroller = mapScroller4;
  76. break;
  77. };
  78. selectedScroller.alpha = 1.0f;
  79. }
  80. -(IBAction) BackPressed {
  81. // Go Back to MainMenu.
  82. [gAppDelegate NewGame ];
  83. Sound_StartLocalSound( "iphone/controller_down_01_SILENCE.wav" );
  84. }
  85. - (int) getSkill {
  86. if( easySelection.hidden == NO ) {
  87. return 0;
  88. } else if( mediumSelection.hidden == NO ) {
  89. return 1;
  90. } else if( hardSelection.hidden == NO ) {
  91. return 2;
  92. } else if( NightmareSelection.hidden == NO ) {
  93. return 3;
  94. }
  95. return 0;
  96. }
  97. -(IBAction) UpMission {
  98. CGFloat xOffset = selectedScroller.contentOffset.x;
  99. CGFloat yOffset = selectedScroller.contentOffset.y;
  100. if (selectedScroller.contentOffset.y > 10 )
  101. {
  102. [selectedScroller setContentOffset:CGPointMake(xOffset, yOffset - 50 ) animated:YES];
  103. }
  104. }
  105. -(IBAction) DownMission {
  106. CGFloat xOffset = selectedScroller.contentOffset.x;
  107. CGFloat yOffset = selectedScroller.contentOffset.y;
  108. if (selectedScroller.contentOffset.y < 300 )
  109. {
  110. [selectedScroller setContentOffset:CGPointMake(xOffset, yOffset + 50 ) animated:YES];
  111. }
  112. }
  113. -(IBAction) Play {
  114. int skillLevel = [self getSkill];
  115. [gAppDelegate playMap: 0: episodeSelected: mapSelected: skillLevel ];
  116. }
  117. - (void) playMap: (int) dataset: (int) episode: (int) map {
  118. [ playButton setEnabled: YES ];
  119. [ playLabel setEnabled: YES ];
  120. if( selectedMap != nil ) {
  121. [ selectedMap setEnabled: YES ];
  122. }
  123. episodeSelected = episode;
  124. mapSelected = map;
  125. int mapTag = episode * 10 + ( map - 1 );
  126. selectedMap = (UIFontButton *)[ self viewWithTag: mapTag ];
  127. [selectedMap setEnabled: NO];
  128. Sound_StartLocalSound( "iphone/controller_down_01_SILENCE.wav" );
  129. }
  130. // Difficulty Setting
  131. -(IBAction) EasyPressed {
  132. [self resetDifficulty];
  133. Sound_StartLocalSound( "iphone/controller_down_01_SILENCE.wav" );
  134. }
  135. -(IBAction) MediumPressed {
  136. easySelection.hidden = YES;
  137. mediumSelection.hidden = NO;
  138. hardSelection.hidden = YES;
  139. NightmareSelection.hidden = YES;
  140. easySelectionLabel.hidden = YES;
  141. mediumSelectionLabel.hidden = NO;
  142. hardSelectionLabel.hidden = YES;
  143. nightmareSelectionLabel.hidden = YES;
  144. Sound_StartLocalSound( "iphone/controller_down_01_SILENCE.wav" );
  145. }
  146. -(IBAction) HardPressed {
  147. easySelection.hidden = YES;
  148. mediumSelection.hidden = YES;
  149. hardSelection.hidden = NO;
  150. NightmareSelection.hidden = YES;
  151. easySelectionLabel.hidden = YES;
  152. mediumSelectionLabel.hidden = YES;
  153. hardSelectionLabel.hidden = NO;
  154. nightmareSelectionLabel.hidden = YES;
  155. Sound_StartLocalSound( "iphone/controller_down_01_SILENCE.wav" );
  156. }
  157. -(IBAction) NightmarePressed{
  158. easySelection.hidden = YES;
  159. mediumSelection.hidden = YES;
  160. hardSelection.hidden = YES;
  161. NightmareSelection.hidden = NO;
  162. easySelectionLabel.hidden = YES;
  163. mediumSelectionLabel.hidden = YES;
  164. hardSelectionLabel.hidden = YES;
  165. nightmareSelectionLabel.hidden = NO;
  166. Sound_StartLocalSound( "iphone/controller_down_01_SILENCE.wav" );
  167. }
  168. // DOOM EPISODES
  169. -(IBAction) E1M1 {
  170. [ self playMap: 0: 1: 1 ];
  171. }
  172. -(IBAction) E1M2{
  173. [ self playMap: 0: 1: 2 ];
  174. }
  175. -(IBAction) E1M3{
  176. [ self playMap: 0: 1: 3 ];
  177. }
  178. -(IBAction) E1M4{
  179. [ self playMap: 0: 1: 4 ];
  180. }
  181. -(IBAction) E1M5{
  182. [ self playMap: 0: 1: 5 ];
  183. }
  184. -(IBAction) E1M6{
  185. [ self playMap: 0: 1: 6 ];
  186. }
  187. -(IBAction) E1M7{
  188. [ self playMap: 0: 1: 7 ];
  189. }
  190. -(IBAction) E1M8{
  191. [ self playMap: 0: 1: 8 ];
  192. }
  193. -(IBAction) E1M9{
  194. [ self playMap: 0: 1: 9 ];
  195. }
  196. -(IBAction) E2M1{
  197. [ self playMap: 0: 2: 1 ];
  198. }
  199. -(IBAction) E2M2{
  200. [ self playMap: 0: 2: 2 ];
  201. }
  202. -(IBAction) E2M3{
  203. [ self playMap: 0: 2: 3 ];
  204. }
  205. -(IBAction) E2M4{
  206. [ self playMap: 0: 2: 4 ];
  207. }
  208. -(IBAction) E2M5{
  209. [ self playMap: 0: 2: 5 ];
  210. }
  211. -(IBAction) E2M6{
  212. [ self playMap: 0: 2: 6 ];
  213. }
  214. -(IBAction) E2M7{
  215. [ self playMap: 0: 2: 7 ];
  216. }
  217. -(IBAction) E2M8{
  218. [ self playMap: 0: 2: 8 ];
  219. }
  220. -(IBAction) E2M9{
  221. [ self playMap: 0: 2: 9 ];
  222. }
  223. -(IBAction) E3M1{
  224. [ self playMap: 0: 3: 1 ];
  225. }
  226. -(IBAction) E3M2{
  227. [ self playMap: 0: 3: 2 ];
  228. }
  229. -(IBAction) E3M3{
  230. [ self playMap: 0: 3: 3 ];
  231. }
  232. -(IBAction) E3M4{
  233. [ self playMap: 0: 3: 4 ];
  234. }
  235. -(IBAction) E3M5{
  236. [ self playMap: 0: 3: 5 ];
  237. }
  238. -(IBAction) E3M6{
  239. [ self playMap: 0: 3: 6 ];
  240. }
  241. -(IBAction) E3M7 {
  242. [ self playMap: 0: 3: 7 ];
  243. }
  244. -(IBAction) E3M8{
  245. [ self playMap: 0: 3: 8 ];
  246. }
  247. -(IBAction) E3M9{
  248. [ self playMap: 0: 3: 9 ];
  249. }
  250. -(IBAction) E4M1{
  251. [ self playMap: 0: 4: 1 ];
  252. }
  253. -(IBAction) E4M2{
  254. [ self playMap: 0: 4: 2 ];
  255. }
  256. -(IBAction) E4M3{
  257. [ self playMap: 0: 4: 3 ];
  258. }
  259. -(IBAction) E4M4{
  260. [ self playMap: 0: 4: 4 ];
  261. }
  262. -(IBAction) E4M5{
  263. [ self playMap: 0: 4: 5 ];
  264. }
  265. -(IBAction) E4M6{
  266. [ self playMap: 0: 4: 6 ];
  267. }
  268. -(IBAction) E4M7{
  269. [ self playMap: 0: 4: 7 ];
  270. }
  271. -(IBAction) E4M8{
  272. [ self playMap: 0: 4: 8 ];
  273. }
  274. -(IBAction) E4M9{
  275. [ self playMap: 0: 4: 9 ];
  276. }
  277. @end