@Override public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { int nb = 0; if (server != null) { nb = server.getPartie().size(); g.drawString("Server : ON", 5, 5); } else g.drawString("Server : OFF", 5, 5); g.drawString( "Listes des parties ouvertes : " + nb, shapeListeServers.getX() + shapeListeServers.getWidth() / 2 - container.getDefaultFont().getWidth("Listes des parties ouvertes :" + nb) / 2, shapeListeServers.getY() - container.getDefaultFont().getHeight("Listes des parties ouvertes :" + nb) - 2); g.setDrawMode(Graphics.MODE_COLOR_MULTIPLY); g.setColor(Color.gray); g.fill(shapeListeServers); g.setDrawMode(Graphics.MODE_NORMAL); g.setColor(Color.white); g.draw(shapeListeServers); listeServers.renderString(container, g); butRetour.render(container, g); butCreerServer.render(container, g); super.render(container, game, g); }
@Override public void mouseReleased(int but, int x, int y) { if (butRetour.isMouseOver()) gotoPreviousView(); else if (butCreerServer.isMouseOver()) { if (server == null) { // On le creer server = new Server("Serveur jeu Drol"); Thread tmp = new Thread(server); tmp.start(); System.out.println("Serveur demarrer"); } else { // On le supprime server.stopServer(); server = null; System.out.println("Serveur arreter"); } } }
private void mettreAJourListePartie() { listeServers.clearList(); for (Partie v : server.getPartie()) if (v != null) { String type = "Salon"; if (v instanceof Jeu) type = "jeu"; listeServers.addElement( new ElementString( container, ResourceManager.getImage("transparent") .getScaledCopy(10, container.getDefaultFont().getHeight("1") + 2), 0, 0, "Id: " + v.getId() + " Nb joueurs: " + v.getListeDesJoueursDansLaPartie().size() + " instance: " + type)); } }