Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.Xna.Framework;
  4. using Microsoft.Xna.Framework.Graphics;
  5. using Microsoft.Xna.Framework.Input;
  6. using Microsoft.Xna.Framework.Audio;
  7. using Microsoft.Xna.Framework.Media;
  8.  
  9. namespace StarAttack
  10. {
  11. // TODO:
  12. // 1) SaveLoad - test it
  13. // 4) xbox standart keys: y - backspace etc.
  14. public class HighScoreScreen
  15. {
  16. public bool inputMode = false;
  17. public static int MAX_NAME_LENGTH = 20;
  18. public bool capsLock = true;
  19.  
  20. int score = 91110;
  21.  
  22. public StarGame.GameState goBackState = StarGame.GameState.MAIN_MENU;
  23.  
  24. public Menu areYouSureMenu;
  25. public bool areYouSureMode = false;
  26.  
  27. public List<MyParticleEffect> effects = new List<MyParticleEffect>();
  28. Animation top3;
  29.  
  30. private Animation x_button;
  31. private Animation y_button;
  32.  
  33. public HighScoreScreen()
  34. {
  35. List<string> mainMenuOptions1 = new List<string>();
  36. mainMenuOptions1.Add("No");
  37. mainMenuOptions1.Add("Yes");
  38.  
  39. Vector2 start = new Vector2(1280 / 2 - 77, 250);
  40. areYouSureMenu = new Menu(null, mainMenuOptions1.ToArray(), MainMenu.menuFont, start, true, StarGame.graphics);
  41. areYouSureMenu.color = MainMenu.TEXT_COLOR;
  42.  
  43. areYouSureMenu.title = "Are you sure?";
  44.  
  45. effects.Add(new MyParticleEffect(TextureManager.pipe_smoke_n_little_emmiter, TextureManager.pipe_smoke_n_renderer, new Vector2(382-32, 728), false, false));
  46. effects.Add(new MyParticleEffect(TextureManager.pipe_smoke_n_little_emmiter, TextureManager.pipe_smoke_n_renderer, new Vector2(900+32, 728), false, false));
  47. effects.Add(new MyParticleEffect(TextureManager.pipe_smoke_w_emmiter, TextureManager.pipe_smoke_w_renderer, new Vector2(1149, 100), true, false));
  48. effects.Add(new MyParticleEffect(TextureManager.pipe_smoke_e_emmiter, TextureManager.pipe_smoke_e_renderer, new Vector2(124, 100), true, false));
  49.  
  50. top3 = StarGame.textureManager.GetBonusAnimation(Bonus.BonusType.MISSLE);
  51.  
  52. x_button = TextureManager.buttonX.MakeAnim();
  53. y_button = TextureManager.buttonY.MakeAnim();
  54. //for (int i = 0; i < 4; i++ )
  55. // effects.Add(new MyParticleEffect(TextureManager.pipe_smoke_n_little_emmiter, TextureManager.pipe_smoke_n_renderer, new Vector2(210 + i * 64*4, 668), false, false));
  56. }
  57.  
  58. public void UpdateAreYouSure(GameTime gameTime)
  59. {
  60. KeyboardState ks = Keyboard.GetState();
  61. if (AnyGamePad.OnButtonDown(Buttons.DPadDown) || AnyGamePad.OnThumbstickDown(Buttons.DPadDown) || (ks.IsKeyDown(Keys.Down) && StarGame.oldKeyboardState.IsKeyUp(Keys.Down)))
  62. {
  63. areYouSureMenu.Down();
  64. }
  65. else if (AnyGamePad.OnButtonDown(Buttons.DPadUp) || AnyGamePad.OnThumbstickDown(Buttons.DPadUp) || (ks.IsKeyDown(Keys.Up) && StarGame.oldKeyboardState.IsKeyUp(Keys.Up)))
  66. {
  67. areYouSureMenu.Up();
  68. }
  69.  
  70. #if WINDOWS
  71. MainMenu.countdown -= gameTime.ElapsedGameTime.Milliseconds;
  72. if (MainMenu.countdown <= 0 && Mouse.GetState().Y > Misc.screenHeight / 2 + MainMenu.MINIMAL_MOUSE_MOVE && !areYouSureMenu.cursor.IsMax())
  73. {
  74. areYouSureMenu.Down();
  75. MainMenu.countdown = MainMenu.MOUSE_MENU_MOVE_DELAY_MS * 15;
  76. }
  77. else if (MainMenu.countdown <= 0 && Mouse.GetState().Y < Misc.screenHeight / 2 - MainMenu.MINIMAL_MOUSE_MOVE && !areYouSureMenu.cursor.IsMin())
  78. {
  79. areYouSureMenu.Up();
  80. MainMenu.countdown = MainMenu.MOUSE_MENU_MOVE_DELAY_MS * 15;
  81. }
  82. MainMenu.ResetMousePosition();
  83.  
  84. int wheel = Mouse.GetState().ScrollWheelValue - StarGame.oldMouseState.ScrollWheelValue;
  85. if (wheel < 0 && !areYouSureMenu.cursor.IsMax())
  86. {
  87. areYouSureMenu.Down();
  88. }
  89. else if (wheel > 0 && !areYouSureMenu.cursor.IsMin())
  90. {
  91. areYouSureMenu.Up();
  92. }
  93. #endif
  94.  
  95. if (AnyGamePad.OnButtonDown(Buttons.B) || AnyGamePad.OnButtonDown(Buttons.Start))
  96. {
  97. AudioManager.PlaySound(AudioManager.menuSelectSnd);
  98. areYouSureMode = false;
  99. }
  100.  
  101. bool mouseSelect = false;
  102.  
  103. #if WINDOWS
  104. mouseSelect = Mouse.GetState().LeftButton == ButtonState.Pressed && StarGame.oldMouseState.LeftButton == ButtonState.Released;
  105. #endif
  106.  
  107. if (StarGame.OnKeyDown(Keys.Y) || mouseSelect
  108. || AnyGamePad.OnButtonDown(Buttons.A)
  109. || (ks.IsKeyDown(Keys.Enter) && StarGame.oldKeyboardState.IsKeyUp(Keys.Enter))
  110. || (ks.IsKeyDown(Keys.Z) && StarGame.oldKeyboardState.IsKeyUp(Keys.Z))
  111. )
  112. {
  113. if (areYouSureMenu.getSelectedMenuOption().Equals("No"))
  114. {
  115. AudioManager.PlaySound(AudioManager.menuSelectSnd);
  116. areYouSureMode = false;
  117. }
  118. else if (areYouSureMenu.getSelectedMenuOption().Equals("Yes"))
  119. {
  120. StarGame.GetInstance().gameState = goBackState;
  121. if (goBackState == StarGame.GameState.CONTINUE)
  122. {
  123. StarGame.GetInstance().continueScreen.Activate();
  124. }
  125. goBackState = StarGame.GameState.MAIN_MENU;
  126. inputMode = false;
  127. areYouSureMode = false;
  128. }
  129. }
  130. }
  131.  
  132.  
  133.  
  134. public void Update(GameTime gameTime)
  135. {
  136. foreach (MyParticleEffect pe in effects)
  137. {
  138. pe.Update(gameTime, Vector2.Zero);
  139. }
  140. if (areYouSureMode)
  141. {
  142. UpdateAreYouSure(gameTime);
  143. return;
  144. }
  145.  
  146. bool mouseSelect = false;
  147. #if WINDOWS
  148. mouseSelect = Mouse.GetState().LeftButton == ButtonState.Pressed && StarGame.oldMouseState.LeftButton == ButtonState.Released;
  149. #endif
  150.  
  151.  
  152. if (!inputMode)
  153. {
  154. if (AnyGamePad.OnButtonDown(Buttons.A)
  155. || AnyGamePad.OnButtonDown(Buttons.B)
  156. || AnyGamePad.OnButtonDown(Buttons.X)
  157. || AnyGamePad.OnButtonDown(Buttons.Y)
  158. || AnyGamePad.OnButtonDown(Buttons.Start)
  159. || AnyGamePad.OnButtonDown(Buttons.Back)
  160. || AnyGamePad.OnRightTriggerDown()
  161. || StarGame.OnKeyDown(Keys.Escape)
  162. || StarGame.OnKeyDown(Keys.Enter)
  163. || StarGame.OnKeyDown(Keys.Space)
  164. || StarGame.OnKeyDown(Keys.LeftControl)
  165. || StarGame.OnKeyDown(Keys.X)
  166. || StarGame.OnKeyDown(Keys.Z)
  167. || StarGame.OnKeyDown(Keys.Y)
  168. || mouseSelect
  169. )
  170. {
  171.  
  172. AudioManager.PlaySound(AudioManager.menuSelectSnd);
  173. StarGame.GetInstance().gameState = goBackState;
  174. if (goBackState == StarGame.GameState.CONTINUE)
  175. {
  176. StarGame.GetInstance().continueScreen.Activate();
  177. }
  178. goBackState = StarGame.GameState.MAIN_MENU;
  179. }
  180. }
  181. else
  182. {
  183. // CURSOR
  184. KeyboardState ks = Keyboard.GetState();
  185. if (AnyGamePad.OnButtonDown(Buttons.DPadDown) || AnyGamePad.OnThumbstickDown(Buttons.DPadDown) || (ks.IsKeyDown(Keys.Down) && StarGame.oldKeyboardState.IsKeyUp(Keys.Down)))
  186. {
  187. yCursor.Increment();
  188. }
  189. else if (AnyGamePad.OnButtonDown(Buttons.DPadUp) || AnyGamePad.OnThumbstickDown(Buttons.DPadUp) || (ks.IsKeyDown(Keys.Up) && StarGame.oldKeyboardState.IsKeyUp(Keys.Up)))
  190. {
  191. yCursor.Decrement();
  192. }
  193. else if (AnyGamePad.OnButtonDown(Buttons.DPadLeft) || AnyGamePad.OnThumbstickDown(Buttons.DPadLeft) || (ks.IsKeyDown(Keys.Left) && StarGame.oldKeyboardState.IsKeyUp(Keys.Left)))
  194. {
  195. xCursor.Decrement();
  196. }
  197. else if (AnyGamePad.OnButtonDown(Buttons.DPadRight) || AnyGamePad.OnThumbstickDown(Buttons.DPadRight) || (ks.IsKeyDown(Keys.Right) && StarGame.oldKeyboardState.IsKeyUp(Keys.Right)))
  198. {
  199. xCursor.Increment();
  200. }
  201.  
  202. if (AnyGamePad.OnButtonDown(Buttons.LeftStick))
  203. {
  204. yCursor.SetValue(2);
  205. xCursor.SetValue(9);
  206. mouseSelect = true;
  207. }
  208.  
  209. if (AnyGamePad.OnButtonDown(Buttons.Start))
  210. {
  211. yCursor.SetValue(3);
  212. xCursor.SetValue(10);
  213. mouseSelect = true;
  214. }
  215.  
  216.  
  217. // INPUT FROM ONSCREEN KEYBOARD
  218. if (AnyGamePad.OnButtonDown(Buttons.A)
  219. || AnyGamePad.OnButtonDown(Buttons.X)
  220. || AnyGamePad.OnButtonDown(Buttons.Y)
  221. || AnyGamePad.OnButtonDown(Buttons.Start)
  222. || AnyGamePad.OnRightTriggerDown()
  223. || StarGame.OnKeyDown(Keys.Enter)
  224. || StarGame.OnKeyDown(Keys.LeftControl)
  225. || mouseSelect
  226. )
  227. {
  228.  
  229. // Y - SPACE
  230. if (AnyGamePad.OnButtonDown(Buttons.Y))
  231. {
  232. xCursor.SetValue(4);
  233. yCursor.SetValue(2);
  234. }
  235.  
  236. // X - BACKSPACE
  237. if (AnyGamePad.OnButtonDown(Buttons.X))
  238. {
  239. xCursor.SetValue(10);
  240. yCursor.SetValue(2);
  241. }
  242.  
  243. char c = 'A';
  244. c += (char)(KEYBOARD_X_SIZE * yCursor.GetValue() + xCursor.GetValue());
  245. if (yCursor.GetValue() == 2)
  246. {
  247. if (xCursor.GetValue() == 4)
  248. {
  249. c = ' ';
  250. }
  251. if (xCursor.GetValue() == 5)
  252. {
  253. c = '_';
  254. }
  255. if (xCursor.GetValue() == 6)
  256. {
  257. c = '-';
  258. }
  259. if (xCursor.GetValue() == 7)
  260. {
  261. c = ',';
  262. }
  263. if (xCursor.GetValue() == 8)
  264. {
  265. c = '.';
  266. }
  267. }
  268. if (yCursor.GetValue() == 3 && xCursor.GetValue() != 11)
  269. {
  270. c = (char)('0' + xCursor.GetValue());
  271. }
  272. if (yCursor.GetValue() == 3 && xCursor.GetValue() == 10)
  273. {
  274. // ENTER
  275. if (usernameBuffer.Length == 0)
  276. {
  277. AudioManager.PlaySound(AudioManager.no);
  278. }
  279. else
  280. {
  281. AudioManager.PlaySound(AudioManager.yes);
  282. inputMode = false;
  283. RecordTableEntry e = new RecordTableEntry();
  284. e.name = usernameBuffer;
  285. e.score = score;
  286. e.difficulty = Balance.DIFF_STRING.ToLower();
  287. if (e.difficulty == "easy")
  288. e.difficulty += " ";
  289. if (e.difficulty == "hard")
  290. e.difficulty += " ";
  291. RecordTable.AddRecord(e);
  292. RecordTable.Save();
  293. }
  294. }
  295. else if (yCursor.GetValue() == 2 && xCursor.GetValue() == 10)
  296. {
  297. // BACKSPACE
  298. if (usernameBuffer.Length > 0)
  299. {
  300. usernameBuffer = usernameBuffer.Remove(usernameBuffer.Length - 1);
  301. }
  302. else
  303. {
  304. AudioManager.PlaySound(AudioManager.no);
  305. }
  306. }
  307. else if (yCursor.GetValue() == 2 && xCursor.GetValue() == 9)
  308. {
  309. capsLock = !capsLock;
  310. }
  311. else if (usernameBuffer.Length < MAX_NAME_LENGTH)
  312. {
  313. string aa = capsLock ? c.ToString().ToUpper() : c.ToString().ToLower();
  314. usernameBuffer += aa;
  315. AudioManager.PlaySound(AudioManager.yes);
  316. }
  317. else
  318. {
  319. AudioManager.PlaySound(AudioManager.no);
  320. }
  321. }
  322.  
  323. if (AnyGamePad.OnButtonDown(Buttons.B)
  324. || StarGame.OnKeyDown(Keys.Escape)
  325. || StarGame.OnKeyDown(Keys.B)
  326. || StarGame.OnKeyDown(Keys.X)
  327. )
  328. {
  329. areYouSureMode = true;
  330. }
  331. #if WINDOWS
  332. if (StarGame.OnKeyDown(Keys.CapsLock))
  333. {
  334. capsLock = !capsLock;
  335. }
  336.  
  337. Nullable<Char> cc = null;
  338. if (StarGame.OnKeyDown(Keys.A))
  339. cc = 'a';
  340. if (StarGame.OnKeyDown(Keys.B))
  341. cc = 'b';
  342. if (StarGame.OnKeyDown(Keys.C))
  343. cc = 'c';
  344. if (StarGame.OnKeyDown(Keys.D))
  345. cc = 'd';
  346. if (StarGame.OnKeyDown(Keys.E))
  347. cc = 'e';
  348. if (StarGame.OnKeyDown(Keys.F))
  349. cc = 'f';
  350. if (StarGame.OnKeyDown(Keys.G))
  351. cc = 'g';
  352. if (StarGame.OnKeyDown(Keys.H))
  353. cc = 'h';
  354. if (StarGame.OnKeyDown(Keys.I))
  355. cc = 'i';
  356. if (StarGame.OnKeyDown(Keys.J))
  357. cc = 'j';
  358. if (StarGame.OnKeyDown(Keys.K))
  359. cc = 'k';
  360. if (StarGame.OnKeyDown(Keys.L))
  361. cc = 'l';
  362. if (StarGame.OnKeyDown(Keys.N))
  363. cc = 'n';
  364. if (StarGame.OnKeyDown(Keys.M))
  365. cc = 'm';
  366. if (StarGame.OnKeyDown(Keys.O))
  367. cc = 'o';
  368. if (StarGame.OnKeyDown(Keys.P))
  369. cc = 'p';
  370. if (StarGame.OnKeyDown(Keys.Q))
  371. cc = 'q';
  372. if (StarGame.OnKeyDown(Keys.R))
  373. cc = 'r';
  374. if (StarGame.OnKeyDown(Keys.S))
  375. cc = 's';
  376. if (StarGame.OnKeyDown(Keys.T))
  377. cc = 't';
  378. if (StarGame.OnKeyDown(Keys.U))
  379. cc = 'u';
  380. if (StarGame.OnKeyDown(Keys.V))
  381. cc = 'v';
  382. if (StarGame.OnKeyDown(Keys.W))
  383. cc = 'w';
  384. if (StarGame.OnKeyDown(Keys.X))
  385. cc = 'x';
  386. if (StarGame.OnKeyDown(Keys.Y))
  387. cc = 'y';
  388. if (StarGame.OnKeyDown(Keys.Z))
  389. cc = 'z';
  390.  
  391.  
  392. if (StarGame.OnKeyDown(Keys.NumPad0))
  393. cc = '0';
  394. if (StarGame.OnKeyDown(Keys.NumPad1))
  395. cc = '1';
  396. if (StarGame.OnKeyDown(Keys.NumPad2))
  397. cc = '2';
  398. if (StarGame.OnKeyDown(Keys.NumPad3))
  399. cc = '3';
  400. if (StarGame.OnKeyDown(Keys.NumPad4))
  401. cc = '4';
  402. if (StarGame.OnKeyDown(Keys.NumPad5))
  403. cc = '5';
  404. if (StarGame.OnKeyDown(Keys.NumPad6))
  405. cc = '6';
  406. if (StarGame.OnKeyDown(Keys.NumPad7))
  407. cc = '7';
  408. if (StarGame.OnKeyDown(Keys.NumPad8))
  409. cc = '8';
  410. if (StarGame.OnKeyDown(Keys.NumPad9))
  411. cc = '9';
  412.  
  413. if (StarGame.OnKeyDown(Keys.D0))
  414. cc = '0';
  415. if (StarGame.OnKeyDown(Keys.D1))
  416. cc = '1';
  417. if (StarGame.OnKeyDown(Keys.D2))
  418. cc = '2';
  419. if (StarGame.OnKeyDown(Keys.D3))
  420. cc = '3';
  421. if (StarGame.OnKeyDown(Keys.D4))
  422. cc = '4';
  423. if (StarGame.OnKeyDown(Keys.D5))
  424. cc = '5';
  425. if (StarGame.OnKeyDown(Keys.D6))
  426. cc = '6';
  427. if (StarGame.OnKeyDown(Keys.D7))
  428. cc = '7';
  429. if (StarGame.OnKeyDown(Keys.D8))
  430. cc = '8';
  431. if (StarGame.OnKeyDown(Keys.D9))
  432. cc = '9';
  433.  
  434. if (StarGame.OnKeyDown(Keys.Space))
  435. cc = ' ';
  436.  
  437.  
  438. if (cc != null)
  439. {
  440. if (usernameBuffer.Length < MAX_NAME_LENGTH)
  441. {
  442. string cl = cc.ToString();
  443. if (capsLock)
  444. {
  445. if (Keyboard.GetState().IsKeyDown(Keys.LeftShift))
  446. {
  447. cl = cl.ToLower();
  448. }
  449. else
  450. {
  451. cl = cl.ToUpper();
  452. }
  453. }
  454. else
  455. {
  456. if (Keyboard.GetState().IsKeyDown(Keys.LeftShift))
  457. {
  458. cl = cl.ToUpper();
  459. }
  460. else
  461. {
  462. cl = cl.ToLower();
  463. }
  464. }
  465. usernameBuffer += cl;
  466. AudioManager.PlaySound(AudioManager.yes);
  467. }
  468. else
  469. {
  470. AudioManager.PlaySound(AudioManager.no);
  471. }
  472. }
  473.  
  474. if (StarGame.OnKeyDown(Keys.Back) || StarGame.OnKeyDown(Keys.Delete))
  475. {
  476. if (usernameBuffer.Length > 0)
  477. {
  478. usernameBuffer = usernameBuffer.Remove(usernameBuffer.Length - 1);
  479. }
  480. else
  481. {
  482. AudioManager.PlaySound(AudioManager.no);
  483. }
  484. }
  485. #endif
  486. }
  487.  
  488.  
  489.  
  490.  
  491. }
  492.  
  493.  
  494. public static Rectangle doubled = new Rectangle(0, 0, 640 * 2, 360 * 2);
  495. static Color alphaBg = new Color(0.6f, 0.6f, 0.6f, .6f);
  496. int img = 1;
  497.  
  498. Color outgray = new Color(.0f, .0f, .0f, .5f);
  499.  
  500. readonly static Vector2 startPos = new Vector2(160, 170);
  501. Vector2 pos = new Vector2();
  502. int Y_STEP = 40;
  503. public void Draw(Camera camera)
  504. {
  505.  
  506. camera.Draw(TextureManager.whitePixel, Misc.titleSafeArea, MainMenu.BG_COLOR);
  507. camera.GetSpriteBatch().Draw(TextureManager.intro_comic, doubled, new Rectangle(0, 360 * img, 640, 360), alphaBg);
  508. //camera.Draw(StarGame.GetInstance().splashScreen, Vector2.Zero, alphaBg);
  509.  
  510.  
  511. pos = new Vector2(0, 50);
  512. SpriteFont font = TextureManager.scoreFontBig;
  513. string str = "HIGH SCORES";
  514. Vector2 size = font.MeasureString(str);
  515. pos.X = 1280 / 2 - size.X / 2;
  516. camera.DrawString(font, str, pos + Misc.v6, MainMenu.SHADOW_COLOR);
  517. camera.DrawString(font, str, pos, MainMenu.TEXT_HIGHLIGHT);
  518.  
  519.  
  520. pos = startPos;
  521. int i = 1;
  522. foreach (RecordTableEntry e in RecordTable.rt.records)
  523. {
  524. pos.X = startPos.X;
  525. string record = (i == 10 ? "" : " ") + i + ". " + e.name;
  526. camera.DrawString(TextureManager.scoreFont2, record, pos + DialogItem.shadowOffset, MainMenu.SHADOW_COLOR);
  527. camera.DrawString(TextureManager.scoreFont2, record, pos, i >= 4 ? MainMenu.TEXT_COLOR : Color.Gold);
  528.  
  529. pos.X = 590;
  530. record = e.GetScoreAsString(7) + " " + e.difficulty + " (" + e.GetTitle() + ")";
  531. camera.DrawString(TextureManager.scoreFont2, record, pos + DialogItem.shadowOffset, MainMenu.SHADOW_COLOR);
  532. camera.DrawString(TextureManager.scoreFont2, record, pos, i >= 4 ? MainMenu.TEXT_COLOR : Color.Gold);
  533. pos.Y += Y_STEP;
  534. i++;
  535. }
  536.  
  537. Vector2 a = startPos + new Vector2(-24, 4);
  538. camera.Draw(top3, a);
  539. a.Y += Y_STEP;
  540. camera.Draw(top3, a);
  541. a.Y += Y_STEP;
  542. camera.Draw(top3, a);
  543.  
  544. if (inputMode && !areYouSureMode)
  545. {
  546. camera.Draw(TextureManager.whitePixel, Misc.titleSafeArea, outgray);
  547.  
  548. int size_t = 64;
  549. Rectangle src = new Rectangle(size_t * 6, size_t * 7, size_t, size_t);
  550. Rectangle src_enter = new Rectangle(size_t * 7, size_t * 0, size_t, size_t);
  551. Rectangle src_backspace = new Rectangle(size_t * 3, size_t * 0, size_t, size_t);
  552. Rectangle src_capslock_on = new Rectangle(size_t * 2, size_t * 0, size_t, size_t);
  553. Rectangle src_capslock_off = new Rectangle(size_t * 5, size_t * 0, size_t, size_t);
  554.  
  555. #if XBOX
  556. camera.Draw(x_button, new Vector2(1024, 500-48));
  557. camera.Draw(y_button, new Vector2(1024 + 48, 500 - 48));
  558.  
  559. camera.GetSpriteBatch().DrawString(TextureManager.scoreFont2, "Backspace", new Vector2(4+1024+3+32, 500+3-10), MainMenu.SHADOW_COLOR, MathHelper.PiOver2, Vector2.Zero, 1, SpriteEffects.None, 1);
  560. camera.GetSpriteBatch().DrawString(TextureManager.scoreFont2, "Backspace", new Vector2(4 + 1024 + 32, 500 - 10), MainMenu.TEXT_HIGHLIGHT, MathHelper.PiOver2, Vector2.Zero, 1, SpriteEffects.None, 1);
  561.  
  562. camera.GetSpriteBatch().DrawString(TextureManager.scoreFont2, "Space", new Vector2(4 + 1024 + 3 + 32 + 48, 500 + 3 - 10), MainMenu.SHADOW_COLOR, MathHelper.PiOver2, Vector2.Zero, 1, SpriteEffects.None, 1);
  563. camera.GetSpriteBatch().DrawString(TextureManager.scoreFont2, "Space", new Vector2(4 + 1024 + 32 + 48, 500 - 10), MainMenu.TEXT_HIGHLIGHT, MathHelper.PiOver2, Vector2.Zero, 1, SpriteEffects.None, 1);
  564. #endif
  565.  
  566. Vector2 p = klavaStartPos;
  567. char c = 'A';
  568. for (int y = 0; y < KEYBOARD_Y_SIZE; y++)
  569. {
  570. for (int x = 0; x < KEYBOARD_X_SIZE; x++)
  571. {
  572. Rectangle img_src = src;
  573. p.X = klavaStartPos.X + (size_t + 4) * x;
  574. p.Y = klavaStartPos.Y + (size_t + 4) * y;
  575. Color bgColor = Color.White;
  576. if (10 == x && 3 == y)
  577. {
  578. bgColor = Color.LightGreen;
  579. img_src = src_enter;
  580. }
  581. if (10 == x && 2 == y)
  582. {
  583. bgColor = Color.LightSalmon;
  584. img_src = src_backspace;
  585. }
  586. if (9 == x && 2 == y)
  587. {
  588. bgColor = Color.LightYellow;
  589. img_src = capsLock ? src_capslock_on : src_capslock_off;
  590. }
  591. if (x == xCursor.GetValue() && y == yCursor.GetValue())
  592. {
  593. bgColor = Color.Gray;
  594. }
  595. camera.Draw(TextureManager.klava.images[0], p, img_src, bgColor);
  596. char cc = c;
  597. if (c >= 65 + 26)
  598. {
  599. switch (c)
  600. {
  601. case (char)(65 + 26):
  602. cc = ' ';
  603. break;
  604. case (char)(65 + 27):
  605. cc = '_';
  606. break;
  607. case (char)(65 + 28):
  608. cc = '-';
  609. break;
  610. case (char)(65 + 29):
  611. cc = ',';
  612. break;
  613. case (char)(65 + 30):
  614. cc = '.';
  615. break;
  616. case (char)(65 + 31):
  617. cc = ' ';
  618. break;
  619. case (char)(65 + 32):
  620. cc = ' ';
  621. break;
  622. case (char)(65 + 33):
  623. cc = '0';
  624. break;
  625. case (char)(65 + 34):
  626. cc = '1';
  627. break;
  628. case (char)(65 + 35):
  629. cc = '2';
  630. break;
  631. case (char)(65 + 36):
  632. cc = '3';
  633. break;
  634. case (char)(65 + 37):
  635. cc = '4';
  636. break;
  637. case (char)(65 + 38):
  638. cc = '5';
  639. break;
  640. case (char)(65 + 39):
  641. cc = '6';
  642. break;
  643. case (char)(65 + 40):
  644. cc = '7';
  645. break;
  646. case (char)(65 + 41):
  647. cc = '8';
  648. break;
  649. case (char)(65 + 42):
  650. cc = '9';
  651. break;
  652. case (char)(65 + 43):
  653. cc = ' ';
  654. break;
  655. }
  656. }
  657. string output = cc.ToString();
  658. if (capsLock)
  659. {
  660. output = output.ToUpper();
  661. }
  662. else
  663. {
  664. output = output.ToLower();
  665. }
  666.  
  667. camera.DrawString(TextureManager.scoreFont2, output, p + DialogItem.shadowOffset + charOffset, MainMenu.SHADOW_COLOR);
  668. Color clr = MainMenu.TEXT_HIGHLIGHT;
  669. if (x == xCursor.GetValue() && y == yCursor.GetValue())
  670. {
  671. clr = Color.Gold;
  672. }
  673.  
  674. camera.DrawString(TextureManager.scoreFont2, output, p + charOffset, clr);
  675. c++;
  676.  
  677. }
  678. }
  679.  
  680. string uname = usernameBuffer;
  681. if (uname.Length == 0)
  682. {
  683. uname = "<YOUR SCORE: " + score + ", ENTER NAME>";
  684. }
  685. Vector2 tpos = usernamePos;
  686. Vector2 tsize = TextureManager.scoreFont2.MeasureString(uname);
  687. tpos.X = 1280 / 2 - tsize.X / 2;
  688. camera.DrawString(TextureManager.scoreFont2, uname, tpos + DialogItem.shadowOffset, MainMenu.SHADOW_COLOR);
  689. camera.DrawString(TextureManager.scoreFont2, uname, tpos, MainMenu.TEXT_COLOR);
  690. }
  691.  
  692. if (areYouSureMode)
  693. {
  694. camera.Draw(TextureManager.whitePixel, Misc.titleSafeArea, new Color(.1f, .1f, .1f, .9f));
  695. Color old = areYouSureMenu.color;
  696. areYouSureMenu.color = MainMenu.SHADOW_COLOR;
  697. areYouSureMenu.start += new Vector2(4);
  698. areYouSureMenu.Draw(camera);
  699. areYouSureMenu.color = old;
  700. areYouSureMenu.start -= new Vector2(4);
  701. areYouSureMenu.Draw(camera);
  702. }
  703.  
  704. foreach (MyParticleEffect pe in effects)
  705. {
  706. pe.Draw(camera);
  707. }
  708.  
  709.  
  710. }
  711.  
  712. public void SetInputMode(bool inputMode, int score, StarGame.GameState goBackState)
  713. {
  714. this.inputMode = inputMode;
  715. this.score = score;
  716. xCursor.SetValue(0);
  717. yCursor.SetValue(0);
  718. this.goBackState = goBackState;
  719. usernameBuffer = "";
  720.  
  721. }
  722.  
  723.  
  724. Vector2 klavaStartPos = new Vector2(1280 / 2 - (64 + 4) * 11 / 2, 420 - 64);
  725. Vector2 charOffset = new Vector2(24, 5);
  726. static int KEYBOARD_X_SIZE = 11;
  727. static int KEYBOARD_Y_SIZE = 4;
  728. Ring xCursor = new Ring(KEYBOARD_X_SIZE);
  729. Ring yCursor = new Ring(KEYBOARD_Y_SIZE);
  730. string usernameBuffer = "";
  731. Vector2 usernamePos = new Vector2(200, 370 - 64);
  732. }
  733. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement