Ejemplo n.º 1
0
 /**
  * Called when game window resizes.
  *
  * @param minecraft Minecraft instance.
  * @param width New window width.
  * @param height New window height.
  */
 @Override
 public void onResize(Minecraft minecraft, int width, int height) {
   this.setWorldAndResolution(minecraft, width, height);
   for (ScreenLayer layer : this.guiLayers) {
     layer.notifyGUIUpdate();
   }
 }
Ejemplo n.º 2
0
 public void render(HashMap<String, Object> passedInformation) {
   // TODO: Do not re-render components if nothing changed (like Swing doesn't) to reduce lag.
   for (ScreenLayer layer : guiLayers) {
     MinecraftForge.EVENT_BUS.post(new LayerEvent.Render(GUIAPIEvent.Phase.START, layer));
     layer.render(passedInformation);
     MinecraftForge.EVENT_BUS.post(new LayerEvent.Render(GUIAPIEvent.Phase.END, layer));
   }
 }
Ejemplo n.º 3
0
  // TODO: Deal with duplicates. Can't use Traits sadly.
  public void keyboardInput() {
    HashMap<String, Object> passedInformation = new HashMap<String, Object>(0);
    passedInformation.put("character", Keyboard.getEventCharacter());
    passedInformation.put("key", Keyboard.getEventKey());
    passedInformation.put("down", Keyboard.getEventKeyState());
    passedInformation.put("time", Keyboard.getEventNanoseconds());
    passedInformation.put("count", Keyboard.getKeyCount());

    for (ScreenLayer layer : guiLayers) {
      MinecraftForge.EVENT_BUS.post(new LayerEvent.KeyboardInput(GUIAPIEvent.Phase.START, layer));
      layer.keyInputEvent(passedInformation);
      MinecraftForge.EVENT_BUS.post(new LayerEvent.KeyboardInput(GUIAPIEvent.Phase.END, layer));
    }
  }
Ejemplo n.º 4
0
  public void mergeLayers(ScreenLayer from, ScreenLayer into) {
    if (!exists(from) || !exists(into)) {
      return;
    }

    into.addComponentsFrom(from);
    guiLayers.remove(from);
  }
Ejemplo n.º 5
0
  public void mouseInput() {
    HashMap<String, Object> passedInformation = new HashMap<String, Object>(0);
    passedInformation.put("button", Mouse.getEventButton());
    passedInformation.put("down", Mouse.getEventButtonState());
    passedInformation.put("time", Mouse.getEventNanoseconds());
    passedInformation.put("deltaWheel", Mouse.getEventDWheel());
    passedInformation.put("x", Mouse.getEventX());
    passedInformation.put("y", Minecraft.getMinecraft().displayHeight - Mouse.getEventY());
    if (captureDeltas) {
      passedInformation.put("dWheel", Mouse.getDWheel());
      passedInformation.put("dX", Mouse.getDX());
      passedInformation.put("dY", Mouse.getDY());
    }
    passedInformation.put("count", Mouse.getButtonCount());

    for (ScreenLayer layer : guiLayers) {
      MinecraftForge.EVENT_BUS.post(new LayerEvent.MouseInput(GUIAPIEvent.Phase.START, layer));
      layer.mouseInputEvent(passedInformation);
      MinecraftForge.EVENT_BUS.post(new LayerEvent.MouseInput(GUIAPIEvent.Phase.END, layer));
    }
  }
Ejemplo n.º 6
0
 /** Called to update the GUI screen. This will also notify all components. */
 @Override
 public void updateScreen() {
   for (ScreenLayer layer : this.guiLayers) {
     layer.notifyGUIUpdate();
   }
 }
Ejemplo n.º 7
0
 public void gameGUIChanged(GuiScreen newScreen) {
   for (ScreenLayer layer : guiLayers) {
     layer.notifyGUIUpdate();
   }
 }