Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package cz.ascaria.zoneofuprising.gui;
- import cz.ascaria.zoneofuprising.Main;
- import cz.ascaria.zoneofuprising.ZoneOfUprisingClient;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.logging.Level;
- import tonegod.gui.controls.windows.Window;
- import tonegod.gui.core.Screen;
- /**
- *
- * @author Ascaria Quynn
- */
- public class GuiManager {
- public HashMap<Class<?extends Layout>, Window[]> layouts;
- private ZoneOfUprisingClient game;
- private Screen screen;
- public GuiManager(ZoneOfUprisingClient game) {
- this.game = game;
- this.layouts = new HashMap<Class<?extends Layout>, Window[]>();
- }
- /**
- * Returns screen for guiNode.
- * @return
- */
- public Screen getScreen() {
- if(null == screen) {
- screen = new Screen(game);
- screen.setUseUIAudio(true);
- screen.setUseCursorEffects(true);
- }
- return screen;
- }
- /**
- * Which layout to show.
- * @param layout
- * @return true if layout was shown, false on fail
- */
- public boolean show(Class<?extends Layout> layout) {
- // Create layout if not exist
- if(!layouts.containsKey(layout)) {
- try {
- Layout instance = layout.newInstance();
- instance.setGuiManager(this);
- instance.setScreen(screen);
- layouts.put(layout, instance.getLayout());
- } catch (Exception ex) {
- Main.LOG.log(Level.SEVERE, null, ex);
- return false;
- }
- }
- // Hide all layouts and show specified one
- for(Map.Entry<Class<?extends Layout>, Window[]> entry : layouts.entrySet()) {
- if(layout.equals(entry.getKey())) {
- for(Window window : entry.getValue()) {
- window.show();
- //window.setZOrder(1);
- }
- } else {
- for(Window window : entry.getValue()) {
- window.hide();
- }
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement