Advertisement
Guest User

Untitled

a guest
Mar 9th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.23 KB | None | 0 0
  1. public final class LoginScreen {
  2.  
  3. private final mudclient mc;
  4.  
  5. private Menu welcomeMenu, newUserMenu, loginMenu;
  6.  
  7. private int loginStage = 0;
  8.  
  9. //buttons
  10. private int newUserButton, existingUserButton, newUserOkButton, loginOk, loginCancel;
  11.  
  12. //labels
  13. private int loginStatusLabel;
  14.  
  15. //inputs
  16. private int usernameInput, passwordInput;
  17.  
  18. public LoginScreen(mudclient mc) {
  19. this.mc = mc;
  20. }
  21.  
  22. public void initialize() {
  23. welcomeMenu = new Menu(mc.gameGraphics, 50);
  24. int y = 40;
  25.  
  26. if (!Config.MEMBERS_FEATURES) {
  27. welcomeMenu.createLabel(256, 200 + y, "Click on an option", 5, true);
  28. welcomeMenu.addButton(156, 240 + y, 120, 35);
  29. welcomeMenu.addButton(356, 240 + y, 120, 35);
  30. welcomeMenu.createLabel(156, 240 + y, "New User", 5, false);
  31. welcomeMenu.createLabel(356, 240 + y, "Existing User", 5, false);
  32. newUserButton = welcomeMenu.createButton(156, 240 + y, 120, 35);
  33. existingUserButton = welcomeMenu.createButton(356, 240 + y, 120, 35);
  34. } else {
  35. welcomeMenu.createLabel(256, 200 + y, "Welcome to RuneScape", 4, true);
  36. welcomeMenu.createLabel(256, 215 + y, "You need a member account to use this server", 4, true);
  37. welcomeMenu.addButton(256, 250 + y, 200, 35);
  38. welcomeMenu.createLabel(256, 250 + y, "Click here to login", 5, false);
  39. existingUserButton = welcomeMenu.createButton(256, 250 + y, 200, 35);
  40. }
  41.  
  42. newUserMenu = new Menu(mc.gameGraphics, 50);
  43. y = 230;
  44. newUserMenu.createLabel(256, y + 8, "To create an account please go back to the", 4, true);
  45. y += 20;
  46. newUserMenu.createLabel(256, y + 8, "www.projectrsc.com front page, and choose 'register'", 4, true);
  47. y += 30;
  48. newUserMenu.addButton(256, y + 17, 150, 34);
  49. newUserMenu.createLabel(256, y + 17, "Ok", 5, false);
  50. newUserOkButton = newUserMenu.createButton(256, y + 17, 150, 34);
  51.  
  52. loginMenu = new Menu(mc.gameGraphics, 50);
  53. y = 230;
  54. loginStatusLabel = loginMenu.createLabel(256, y - 10, "Please enter your username and password", 4, true);
  55. y += 28;
  56. loginMenu.addButton(140, y, 200, 40);
  57. loginMenu.createLabel(140, y - 10, "Username:", 4, false);
  58. usernameInput = loginMenu.createInput(140, y + 10, 200, 40, 4, 12, false, false);
  59. y += 47;
  60. loginMenu.addButton(190, y, 200, 40);
  61. loginMenu.createLabel(190, y - 10, "Password:", 4, false);
  62. passwordInput = loginMenu.createInput(190, y + 10, 200, 40, 4, 20, true, false);
  63. y -= 55;
  64. loginMenu.addButton(410, y, 120, 25);
  65. loginMenu.createLabel(410, y, "Ok", 4, false);
  66. loginOk = loginMenu.createButton(410, y, 120, 25);
  67. y += 30;
  68. loginMenu.addButton(410, y, 120, 25);
  69. loginMenu.createLabel(410, y, "Cancel", 4, false);
  70. loginCancel = loginMenu.createButton(410, y, 120, 25);
  71. y += 30;
  72. loginMenu.setFocus(usernameInput);
  73. }
  74.  
  75. public void createSprites() {
  76. int z = 0;
  77. byte x = 50;
  78. byte y = 50;
  79.  
  80. mc.engineHandle.loadSector(x * 48 + 23, y * 48 + 23, z);
  81. mc.engineHandle.loadSectorObjects(mc.gameDataModels);
  82.  
  83. char cameraX = '\u2600';
  84. char cameraY = '\u1900';
  85. char c3 = '\u044C';
  86. char c4 = '\u0378';
  87.  
  88. mc.gameCamera.zoom1 = 4100;
  89. mc.gameCamera.zoom2 = 4100;
  90. mc.gameCamera.zoom3 = 1;
  91. mc.gameCamera.zoom4 = 4000;
  92. mc.gameCamera.setCamera(cameraX, -mc.engineHandle.getAveragedElevation(cameraX, cameraY), cameraY, 912, c4, 0, c3 * 2);
  93. mc.gameCamera.finishCamera();
  94. mc.gameGraphics.fadePixels();
  95. mc.gameGraphics.fadePixels();
  96. mc.gameGraphics.drawBox(0, 0, 512, 6, 0);
  97.  
  98. for(int i1 = 6; i1 >= 1; i1--)
  99. mc.gameGraphics.method221(0, i1, 0, i1, 512, 8);
  100.  
  101. mc.gameGraphics.drawBox(0, 194, 512, 20, 0);
  102. for(int j1 = 6; j1 >= 1; j1--)
  103. mc.gameGraphics.method221(0, j1, 0, 194 - j1, 512, 8);
  104.  
  105. mc.gameGraphics.drawPicture(15, 15, mudclient.SPRITE_MEDIA_START + 10);
  106. mc.gameGraphics.storeSpriteVert(mudclient.SPRITE_TEXTURE_START, 0, 0, 512, 200);
  107. mc.gameGraphics.cbl(mudclient.SPRITE_TEXTURE_START);
  108.  
  109. //2nd scene
  110. cameraX = '\u2400';
  111. cameraY = '\u2400';
  112. c3 = '\u044C';
  113. c4 = '\u0378';
  114. mc.gameCamera.zoom1 = 4100;
  115. mc.gameCamera.zoom2 = 4100;
  116. mc.gameCamera.zoom3 = 1;
  117. mc.gameCamera.zoom4 = 4000;
  118. mc.gameCamera.setCamera(cameraX, -mc.engineHandle.getAveragedElevation(cameraX, cameraY), cameraY, 912, c4, 0, c3 * 2);
  119. mc.gameCamera.finishCamera();
  120. mc.gameGraphics.fadePixels();
  121. mc.gameGraphics.fadePixels();
  122. mc.gameGraphics.drawBox(0, 0, 512, 6, 0);
  123.  
  124. for(int i1 = 6; i1 >= 1; i1--)
  125. mc.gameGraphics.method221(0, i1, 0, i1, 512, 8);
  126.  
  127. mc.gameGraphics.drawBox(0, 194, 512, 20, 0);
  128. for(int j1 = 6; j1 >= 1; j1--)
  129. mc.gameGraphics.method221(0, j1, 0, 194 - j1, 512, 8);
  130.  
  131. mc.gameGraphics.drawPicture(15, 15, mudclient.SPRITE_MEDIA_START + 10);
  132. mc.gameGraphics.storeSpriteVert(mudclient.SPRITE_TEXTURE_START + 1, 0, 0, 512, 200);
  133. mc.gameGraphics.cbl(mudclient.SPRITE_TEXTURE_START + 1);
  134.  
  135. //3rd scene
  136. for(int i2 = 0; i2 < 64; i2++) {
  137. mc.gameCamera.removeModel(mc.engineHandle.aModelArrayArray598[0][i2]);
  138. mc.gameCamera.removeModel(mc.engineHandle.aModelArrayArray580[1][i2]);
  139. mc.gameCamera.removeModel(mc.engineHandle.aModelArrayArray598[1][i2]);
  140. mc.gameCamera.removeModel(mc.engineHandle.aModelArrayArray580[2][i2]);
  141. mc.gameCamera.removeModel(mc.engineHandle.aModelArrayArray598[2][i2]);
  142. }
  143.  
  144. cameraX = '\u2B80';
  145. cameraY = '\u2880';
  146. c3 = '\u01F4';
  147. c4 = '\u0178';
  148. mc.gameCamera.zoom1 = 4100;
  149. mc.gameCamera.zoom2 = 4100;
  150. mc.gameCamera.zoom3 = 1;
  151. mc.gameCamera.zoom4 = 4000;
  152. mc.gameCamera.setCamera(cameraX, -mc.engineHandle.getAveragedElevation(cameraX, cameraY), cameraY, 912, c4, 0, c3 * 2);
  153. mc.gameCamera.finishCamera();
  154. mc.gameGraphics.fadePixels();
  155. mc.gameGraphics.fadePixels();
  156. mc.gameGraphics.drawBox(0, 0, 512, 6, 0);
  157.  
  158. for(int i1 = 6; i1 >= 1; i1--)
  159. mc.gameGraphics.method221(0, i1, 0, i1, 512, 8);
  160.  
  161. mc.gameGraphics.drawBox(0, 194, 512, 20, 0);
  162. for(int j1 = 6; j1 >= 1; j1--)
  163. mc.gameGraphics.method221(0, j1, 0, 194 - j1, 512, 8);
  164.  
  165. mc.gameGraphics.drawPicture(15, 15, mudclient.SPRITE_MEDIA_START + 10);
  166. mc.gameGraphics.storeSpriteVert(mudclient.SPRITE_MEDIA_START + 10, 0, 0, 512, 200);
  167. mc.gameGraphics.cbl(mudclient.SPRITE_MEDIA_START + 10);
  168. }
  169.  
  170. public void render(JagGraphics graphics) {
  171. mc.loginScreenShown = false;
  172. graphics.interlace = false;
  173. graphics.clearScreen();
  174.  
  175. if (loginStage <= 2 && loginStage >= 0) {
  176. int timer = (mc.tick * 2) % 3072;
  177.  
  178. if(timer < 1024) {
  179. graphics.drawPicture(0, 10, mudclient.SPRITE_TEXTURE_START);
  180.  
  181. if(timer > 768) {
  182. graphics.drawTransparentPicture(0, 10, mudclient.SPRITE_TEXTURE_START + 1, timer - 768);
  183. }
  184. } else {
  185. if(timer < 2048) {
  186. graphics.drawPicture(0, 10, mudclient.SPRITE_TEXTURE_START + 1);
  187.  
  188. if(timer > 1792) {
  189. graphics.drawTransparentPicture(0, 10, mudclient.SPRITE_MEDIA_START + 10, timer - 1792);
  190. }
  191. } else {
  192. graphics.drawPicture(0, 10, mudclient.SPRITE_MEDIA_START + 10);
  193.  
  194. if(timer > 2816) {
  195. graphics.drawTransparentPicture(0, 10, mudclient.SPRITE_TEXTURE_START, timer - 2816);
  196. }
  197. }
  198. }
  199. }
  200.  
  201. if(loginStage == 0) {
  202. welcomeMenu.drawMenu();
  203. } else if(loginStage == 1) {
  204. newUserMenu.drawMenu();
  205. } else if(loginStage == 2) {
  206. loginMenu.drawMenu();
  207. }
  208.  
  209. graphics.drawPicture(0, mc.windowHeight, mudclient.SPRITE_MEDIA_START + 22);
  210. graphics.drawImage(mc.aGraphics936, 0, 0);
  211. }
  212.  
  213. public void tick() {
  214. if (mc.socketTimeout > 0) {
  215. mc.socketTimeout--;
  216. }
  217.  
  218. switch (loginStage) {
  219. case 0:
  220. welcomeMenu.mouseClick(mc.mouseX, mc.mouseY, mc.lastMouseButton, mc.mouseButton);
  221.  
  222. if (welcomeMenu.hasClicked(newUserButton)) {
  223. loginStage = 1;
  224. } else if (welcomeMenu.hasClicked(existingUserButton)) {
  225. loginStage = 2;
  226. loginMenu.setText(loginStatusLabel, "Please enter your username and password");
  227. loginMenu.setText(usernameInput, "");
  228. loginMenu.setText(passwordInput, "");
  229. loginMenu.setFocus(usernameInput);
  230. }
  231. break;
  232. case 1:
  233. newUserMenu.mouseClick(mc.mouseX, mc.mouseY, mc.lastMouseButton, mc.mouseButton);
  234.  
  235. if (newUserMenu.hasClicked(newUserOkButton)) {
  236. loginStage = 0;
  237. }
  238. break;
  239. case 2:
  240. loginMenu.mouseClick(mc.mouseX, mc.mouseY, mc.lastMouseButton, mc.mouseButton);
  241.  
  242. if (loginMenu.hasClicked(loginCancel)) {
  243. loginStage = 0;
  244. }
  245.  
  246. if (loginMenu.hasClicked(usernameInput)) {
  247. loginMenu.setFocus(passwordInput);
  248. }
  249.  
  250. if (loginMenu.hasClicked(passwordInput) || loginMenu.hasClicked(loginOk)) {
  251. mc.currentUser = loginMenu.getText(usernameInput);
  252. mc.currentPass = loginMenu.getText(passwordInput);
  253. mc.login(mc.currentUser, mc.currentPass, false);
  254. }
  255. break;
  256. }
  257. }
  258.  
  259. public void updateLoginStatus(String top, String bottom) {
  260. if (loginStage == 2 && loginMenu != null) {
  261. loginMenu.setText(loginStatusLabel, top + " " + bottom);
  262. }
  263. }
  264.  
  265. public void keyDown(int key) {
  266. if (loginStage == 0) {
  267. if (welcomeMenu != null)
  268. welcomeMenu.keyDown(key);
  269. } else if (loginStage == 1) {
  270. if (newUserMenu != null)
  271. newUserMenu.keyDown(key);
  272. } else if (loginStage == 2) {
  273. if (loginMenu != null)
  274. loginMenu.keyDown(key);
  275. }
  276. }
  277.  
  278. public void setLoginStage(int stage) {
  279. loginStage = stage;
  280. }
  281.  
  282. public int getLoginStage() {
  283. return loginStage;
  284. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement