Advertisement
Guest User

Untitled

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