@Override public void initialise() { nuiManager.getHUD().addHUDElement("toolbar"); TransferItemCursor cursor = new TransferItemCursor(); UIElement cursorElement = Assets.generateAsset( new ResourceUrn("engine:transferItemCursor"), new UIData(cursor), UIElement.class); nuiManager.addOverlay(cursorElement, ControlWidget.class); }
@ReceiveEvent(components = ClientComponent.class) public void onShowOnlinePlayers(OnlinePlayersButton event, EntityRef entity) { boolean show = event.isDown(); String onlinePlayersOverlay = "engine:onlinePlayersOverlay"; if (show) { nuiManager.addOverlay(onlinePlayersOverlay, OnlinePlayersOverlay.class); } else { nuiManager.removeOverlay(onlinePlayersOverlay); } event.consume(); }
@ReceiveEvent(components = ClientComponent.class, priority = EventPriority.PRIORITY_CRITICAL) public void onToggleConsole(ConsoleButton event, EntityRef entity) { if (event.getState() == ButtonState.DOWN) { nuiManager.toggleScreen("engine:console"); event.consume(); } }
@ReceiveEvent(components = ClientComponent.class) public void onTogglePause(PauseButton event, EntityRef entity) { if (event.getState() == ButtonState.DOWN) { nuiManager.toggleScreen("engine:pauseMenu"); event.consume(); } }
@ReceiveEvent(components = ClientComponent.class) public void onToggleInventory(InventoryButton event, EntityRef entity) { if (event.getState() == ButtonState.DOWN) { nuiManager.toggleScreen("engine:inventoryScreen"); event.consume(); } }
@Override public void init(GameEngine engine) { EngineTime time = (EngineTime) CoreRegistry.get(Time.class); time.setPaused(true); time.setGameTime(0); CoreRegistry.get(Game.class).load(gameManifest); switch (netMode) { case CLIENT: initClient(); break; default: initHost(); break; } progress = 0; maxProgress = 0; for (LoadProcess process : loadProcesses) { maxProgress += process.getExpectedCost(); } popStep(); loadingScreen = nuiManager.setScreen("engine:loadingScreen", LoadingScreen.class); loadingScreen.updateStatus(current.getMessage(), current.getProgress()); }
@Override public void update(float delta) { long startTime = 1000 * Sys.getTime() / Sys.getTimerResolution(); while (current != null && 1000 * Sys.getTime() / Sys.getTimerResolution() - startTime < 20) { if (current.step()) { popStep(); } } if (current == null) { nuiManager.popScreen(); CoreRegistry.get(GameEngine.class).changeState(new StateIngame()); } else { float progressValue = (progress + current.getExpectedCost() * current.getProgress()) / maxProgress; loadingScreen.updateStatus(current.getMessage(), progressValue); nuiManager.update(delta); } }
@ReceiveEvent(components = {ClientComponent.class}) public void onDeath(DeathEvent event, EntityRef entity) { if (entity.getComponent(ClientComponent.class).local) { nuiManager.pushScreen("engine:deathScreen"); } }
@Override public void render() { nuiManager.render(); }