use of io.xol.chunkstories.gui.layer.ingame.ChatManager.ChatPanelOverlay in project chunkstories by Hugobros3.
the class Ingame method handleInput.
@Override
public boolean handleInput(Input input) {
// Block inputs if chatting
if (input.equals("chat")) {
gameWindow.setLayer(chatManager.new ChatPanelOverlay(gameWindow, this));
focus(false);
guiHidden = false;
return true;
} else if (input.equals("hideGui")) {
guiHidden = !guiHidden;
return true;
} else if (input.equals("screenshot")) {
chatManager.insert(world.getWorldRenderer().screenShot());
} else if (input.equals("toggleDebugInfo")) {
OptionBoolean debugInfo = (OptionBoolean) client.getConfiguration().getOption("client.debug.showDebugInfo");
debugInfo.toggle();
guiHidden = false;
return true;
} else if (input.equals("takeCubemap")) {
// shouldTakeACubemap = true;
return true;
// CTRL-F12 reloads
} else if (input.equals("reloadContent")) {
// Rebuild the mod FS
gameWindow.getClient().reloadAssets();
// Reload plugins
world.getPluginManager().reloadPlugins();
// Mark some caches dirty
world.getWorldRenderer().reloadContentSpecificStuff();
return true;
// CTRL-R redraws chunks
} else if (input.equals("redrawChunks")) {
((ClientParticlesRenderer) world.getParticlesManager()).cleanAllParticles();
world.redrawEverything();
world.getWorldRenderer().flagChunksModified();
return true;
// Item slots selection
} else if (input.getName().startsWith("inventorySlot")) {
int requestedInventorySlot = Integer.parseInt(input.getName().replace("inventorySlot", ""));
// Match zero onto last slot
if (requestedInventorySlot == 0)
requestedInventorySlot = 10;
// Map to zero-indexed inventory
requestedInventorySlot--;
if (playerEntity != null && playerEntity instanceof EntityWithSelectedItem) {
// Do not accept request to select non-existent inventories slots
if (requestedInventorySlot > ((EntityWithInventory) playerEntity).getInventory().getWidth())
return false;
ItemPile p = ((EntityWithInventory) playerEntity).getInventory().getItemPileAt(requestedInventorySlot, 0);
if (p != null)
requestedInventorySlot = p.getX();
((EntityWithSelectedItem) playerEntity).setSelectedItemIndex(requestedInventorySlot);
}
return true;
} else if (input.equals("exit")) /* Exit brings up the pause menu */
{
focus(false);
guiHidden = false;
gameWindow.setLayer(new PauseMenu(gameWindow, this));
return true;
} else if (input instanceof MouseScroll) {
MouseScroll ms = (MouseScroll) input;
if (playerEntity != null && playerEntity instanceof EntityWithSelectedItem) {
ItemPile selected = null;
int selectedInventorySlot = ((EntityWithSelectedItem) playerEntity).getSelectedItemIndex();
int originalSlot = selectedInventorySlot;
if (ms.amount() < 0) {
selectedInventorySlot %= ((EntityWithInventory) playerEntity).getInventory().getWidth();
selected = ((EntityWithInventory) playerEntity).getInventory().getItemPileAt(selectedInventorySlot, 0);
if (selected != null)
selectedInventorySlot += selected.getItem().getDefinition().getSlotsWidth();
else
selectedInventorySlot++;
} else {
selectedInventorySlot--;
if (selectedInventorySlot < 0)
selectedInventorySlot += ((EntityWithInventory) playerEntity).getInventory().getWidth();
selected = ((EntityWithInventory) playerEntity).getInventory().getItemPileAt(selectedInventorySlot, 0);
if (selected != null)
selectedInventorySlot = selected.getX();
}
// Switch slot
if (originalSlot != selectedInventorySlot)
((EntityWithSelectedItem) playerEntity).setSelectedItemIndex(selectedInventorySlot);
return true;
}
}
return false;
}
use of io.xol.chunkstories.gui.layer.ingame.ChatManager.ChatPanelOverlay in project chunkstories by Hugobros3.
the class Ingame method render.
@Override
public void render(RenderingInterface renderer) {
// Update client entity
if ((playerEntity == null || playerEntity != getPlayer().getControlledEntity()) && getPlayer().getControlledEntity() != null) {
playerEntity = getPlayer().getControlledEntity();
if (playerEntity instanceof EntityWithSelectedItem)
inventoryBarDrawer = ((EntityWithSelectedItem) playerEntity).getInventory() == null ? null : new InventoryGridRenderer((EntityWithSelectedItem) playerEntity);
else
inventoryBarDrawer = null;
}
if (playerEntity != null && ((EntityLiving) playerEntity).isDead() && !(gameWindow.getLayer() instanceof DeathScreen))
gameWindow.setLayer(new DeathScreen(gameWindow, this));
// Update the player
if (playerEntity instanceof EntityControllable)
((EntityControllable) playerEntity).onEachFrame(getPlayer());
Location selectedBlock = null;
if (playerEntity instanceof EntityControllable)
selectedBlock = ((EntityControllable) playerEntity).getBlockLookingAt(true);
world.getPluginManager().fireEvent(new CameraSetupEvent(renderer.getCamera()));
// Main render call
world.getWorldRenderer().renderWorld(renderer);
// Debug draws
if (client.getConfiguration().getBooleanOption("client.debug.physicsVisualization") && playerEntity != null) {
wireframeDebugger.render(renderer);
}
if (!guiHidden && selectedBlock != null && playerEntity instanceof EntityCreative && ((EntityCreative) playerEntity).getCreativeModeComponent().get())
selectionRenderer.drawSelectionBox(renderer, selectedBlock);
// Fades in & out the overlay
if (!isCovered()) {
if (pauseOverlayFade > 0.0)
pauseOverlayFade -= 0.1;
} else {
float maxFade = 1.0f;
if (gameWindow.getLayer() instanceof ChatPanelOverlay)
maxFade = 0.25f;
if (pauseOverlayFade < maxFade)
pauseOverlayFade += 0.1;
}
// Blit the final 3d image
world.getWorldRenderer().blitFinalImage(renderer, guiHidden);
// Draw the GUI
if (!guiHidden) {
chatManager.render(renderer);
// Draw inventory
if (playerEntity != null && inventoryBarDrawer != null)
inventoryBarDrawer.drawPlayerInventorySummary(renderer, renderer.getWindow().getWidth() / 2 - 7, 64 + 64);
// Draw debug info
if (client.getConfiguration().getBooleanOption("client.debug.showDebugInfo"))
debugInfoRenderer.drawF3debugMenu(renderer);
renderer.getGuiRenderer().drawBoxWindowsSpaceWithSize(getGameWindow().getWidth() / 2 - 8, getGameWindow().getHeight() / 2 - 8, 16, 16, 0, 1, 1, 0, renderer.textures().getTexture("./textures/gui/cursor.png"), false, true, null);
}
// Lack of overlay should infer autofocus
if (!isCovered())
focus(true);
// Check connection didn't died and change scene if it has
if (world instanceof WorldClientRemote) {
if (!((WorldClientRemote) world).getConnection().isOpen())
gameWindow.getClient().exitToMainMenu("Connection terminated : " + "(TODO: not this way)");
}
// Auto-switch to pause if it detects the game isn't in focus anymore
if (!gameWindow.hasFocus() && !isCovered()) {
focus(false);
gameWindow.setLayer(new PauseMenu(gameWindow, gameWindow.getLayer()));
}
}
Aggregations