Menu.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package bs;
  7. import bswfx.BomberStudent;
  8. import bswfx.ScreenManager;
  9. /**
  10. *
  11. * @author loquicom
  12. */
  13. public class Menu {
  14. public static final int CREATE = 0;
  15. public static final int JOIN = 1;
  16. public static final int QUIT = 2;
  17. protected int selected = 0;
  18. public Menu(){
  19. ScreenManager.setScreen(ScreenManager.MENU_SCREEN);
  20. }
  21. public int getAction(){
  22. return this.selected;
  23. }
  24. public void up(){
  25. if(this.selected == 0){
  26. this.selected = 3;
  27. }
  28. this.selected--;
  29. }
  30. public void down(){
  31. if(this.selected == 2){
  32. this.selected = -1;
  33. }
  34. this.selected++;
  35. }
  36. public String toHtml(){
  37. String html = "<!DOCTYPE html><html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"file:" + System.getProperty("user.dir") + "/file/css/menu.css\"></head><body>";
  38. html += "<button id=\"id0\" disabled>Créer</button>";
  39. html += "<button id=\"id1\" disabled>Rejoindre</button>";
  40. html += "<button id=\"id2\" disabled>Quitter</button>";
  41. html += "</body></html>";
  42. html = html.replaceAll("id" + this.selected, "select");
  43. return html;
  44. }
  45. public void show(){
  46. BomberStudent.wfx.loadHtml(this.toHtml());
  47. }
  48. }