/** Update the current FPS display in the title of the client window. */ @SuppressWarnings("nls") public void updateFPS() { if (!IllaClient.getExitRequested()) { displayFrame.setTitle( IllaClient.getVersionText() + " FPS: " + Graphics.getInstance().getRenderManager().getRealFPS() + " Particles: " + Game.getParticleSystem().getParticleCount() + " Objects: " + display.getObjects()); } }
/** Prepare the window that shall show the openGL content. */ private void initWindow() { IllarionLookAndFeel.setupLookAndFeel(); // create canvas that shall show the openGL content display = Graphics.getInstance().getRenderDisplay(); display.getRenderArea().setBackground(Color.red); configChanged(IllaClient.getCfg(), CFG_RESOLUTION); final Component displayParent = display.getRenderArea(); displayParent.setBackground(Color.green); displayParent.setVisible(true); // set up the window settings displayFrame = new Frame(); displayFrame.setLayout(new BorderLayout(0, 0)); displayFrame.setTitle(IllaClient.getVersionText()); displayFrame.setBackground(Color.black); setIcon(displayFrame); displayFrame.addWindowListener(new ClientWindowListener()); displayFrame.setResizable(false); displayFrame.setFocusable(false); displayFrame.setFocusableWindowState(true); displayFrame.setFocusTraversalKeysEnabled(false); displayParent.setFocusable(true); displayParent.setFocusTraversalKeysEnabled(false); // add the canvas to the window and make the canvas the openGL render // target. displayFrame.add(displayParent, BorderLayout.CENTER); displayFrame.pack(); displayFrame.setLocationRelativeTo(null); displayFrame.setVisible(true); displayParent.requestFocusInWindow(); final RenderDisplay usedDisplay = display; Graphics.getInstance() .getRenderManager() .addTask( new RenderTask() { @Override public boolean render(final int delta) { usedDisplay.startRendering(); return false; } }); }
/** * Load a icon file from a path and prepare it for usage as window icon file. Only JPEG, GIF and * PNG is supported. * * @param path the path to the file that shall be loaded * @return the ImageIcon that was loaded from the file. */ @SuppressWarnings("nls") public static Image loadIcon(final String path) { try { final InputStream in = IllaClient.getResource(path); return ImageIO.read(in); } catch (final Exception e) { LOGGER.error("can't load image " + path, e); return null; } }
/** * Initialize OpenGL and create main window, also prepare the sprite of the splash screen in case * the client is not set to low memory settings. */ private void initGraphics() { configChanged(IllaClient.getCfg(), CFG_FULLSCREEN); }
/** Switch between full screen and windowed mode. */ @SuppressWarnings("nls") public void toggleFullscreen() { IllaClient.getCfg().set("fullScreen", !display.isFullscreen()); }
/** * Private constructor so nothing can create a instance of this object but the singleton instance. */ private ClientWindow() { super(); IllaClient.getCfg().addListener(CFG_FULLSCREEN, this); IllaClient.getCfg().addListener(CFG_RESOLUTION, this); }