Ejemplo n.º 1
0
 private void updateBreathBar(
     DrownsComponent drownsComponent, DrowningComponent drowningComponent) {
   if (drownsComponent != null && drowningComponent != null) {
     float breath = drowningComponent.getPercentageBreath(time.getGameTimeInMs());
     if (breath <= 0) {
       for (UIImage breathBubble : breathBubbles) {
         breathBubble.setVisible(true);
         breathBubble.setTextureOrigin(new Vector2f(25f, 18f));
       }
     } else {
       breath *= NUM_BUBBLE_ICONS;
       for (int i = 0; i < breathBubbles.length; ++i) {
         breathBubbles[i].setVisible(true);
         if (NUM_BUBBLE_ICONS - i - 1 < breath) {
           breathBubbles[i].setTextureOrigin(new Vector2f(16f, 18f));
         } else {
           breathBubbles[i].setTextureOrigin(new Vector2f(25f, 18f));
         }
       }
     }
   } else {
     for (UIImage breathBubble : breathBubbles) {
       breathBubble.setVisible(false);
     }
   }
 }
Ejemplo n.º 2
0
  public UIScreenBookOreo() {
    setId("oreobook");
    setHorizontalAlign(EHorizontalAlign.LEFT);
    setVerticalAlign(EVerticalAlign.CENTER);
    setModal(true);
    // setCloseBinds(new String[]{"engine:useHeldItem"});
    setCloseKeys(new int[] {Keyboard.KEY_ESCAPE});
    setSize(new Vector2f(800, 400));

    background = new UIImage();
    background.setTexture(Assets.getTexture("miniion:openbook"));
    background.setPosition(new Vector2f(0, 0));
    background.setSize(new Vector2f(600, 400));
    background.setVisible(true);
    addDisplayElement(background);

    pagetitle = new UILabel("Summoned minions");
    pagetitle.setPosition(new Vector2f(50, 20));
    pagetitle.setColor(org.newdawn.slick.Color.black);
    pagetitle.setVisible(true);
    addDisplayElement(pagetitle);

    pagetitle2 = new UILabel("Active minion");
    pagetitle2.setPosition(new Vector2f(340, 20));
    pagetitle2.setColor(org.newdawn.slick.Color.black);
    pagetitle2.setVisible(true);
    addDisplayElement(pagetitle2);

    uiminionlist = new UIList();
    uiminionlist.setSize(new Vector2f(250, 350));
    uiminionlist.setPosition(new Vector2f(45, 40));
    uiminionlist.setVisible(true);
    addDisplayElement(uiminionlist);

    selected = new UISelectedMinion(this);
    selected.setPosition(new Vector2f(310, 40));
    selected.setSize(new Vector2f(250, 170));
    selected.setVisible(true);
    addDisplayElement(selected);

    btnshowminion = new UIModButton(new Vector2f(100, 20), ButtonType.NORMAL);
    btnshowminion.setLabel("Show minion window");
    btnshowminion.setColorOffset(120);
    btnshowminion.setVisible(true);
    btnshowminion.setPosition(new Vector2f(375, 260));
    btnshowminion.addClickListener(
        new ClickListener() {
          @Override
          public void click(UIDisplayElement element, int button) {
            if (btnshowminion.getLabel().getText() == "Show minion window") {
              btnshowminion.setLabel("Hide minion minion");
            } else {
              btnshowminion.setLabel("Show minion window");
            }
          }
        });
    this.addDisplayElement(btnshowminion);
  }
Ejemplo n.º 3
0
  /** Init. the HUD. */
  public UIScreenHUD() {
    setId("hud");
    maximize();
    time = CoreRegistry.get(Time.class);

    // Create hearts
    hearts = new UIImage[NUM_HEART_ICONS];
    for (int i = 0; i < NUM_HEART_ICONS; i++) {
      hearts[i] = new UIImage(Assets.getTexture("engine:icons"));
      hearts[i].setVisible(true);
      hearts[i].setTextureSize(new Vector2f(9f, 9f));
      hearts[i].setTextureOrigin(new Vector2f(52f, 0.0f)); // 106f for poison
      hearts[i].setSize(new Vector2f(18f, 18f));
      hearts[i].setVerticalAlign(EVerticalAlign.BOTTOM);
      hearts[i].setHorizontalAlign(EHorizontalAlign.CENTER);
      hearts[i].setPosition(new Vector2f(18f * i - 212f, -52f));

      addDisplayElement(hearts[i]);
    }

    breathBubbles = new UIImage[NUM_BUBBLE_ICONS];
    for (int i = 0; i < NUM_BUBBLE_ICONS; ++i) {
      breathBubbles[i] = new UIImage(Assets.getTexture("engine:icons"));
      breathBubbles[i].setVisible(true);
      breathBubbles[i].setTextureSize(new Vector2f(9f, 9f));
      breathBubbles[i].setTextureOrigin(new Vector2f(16f, 18f));
      breathBubbles[i].setSize(new Vector2f(18f, 18f));
      breathBubbles[i].setVerticalAlign(EVerticalAlign.BOTTOM);
      breathBubbles[i].setHorizontalAlign(EHorizontalAlign.CENTER);
      breathBubbles[i].setPosition(new Vector2f(-18f * i + 210f, -52f));

      addDisplayElement(breathBubbles[i]);
    }

    crosshair = new UIImage(Assets.getTexture("engine:gui"));
    crosshair.setId("crosshair");
    crosshair.setTextureSize(new Vector2f(20f, 20f));
    crosshair.setTextureOrigin(new Vector2f(24f, 24f));
    crosshair.setSize(new Vector2f(40f, 40f));
    crosshair.setHorizontalAlign(EHorizontalAlign.CENTER);
    crosshair.setVerticalAlign(EVerticalAlign.CENTER);
    crosshair.setVisible(true);

    addDisplayElement(crosshair);

    localPlayer = CoreRegistry.get(LocalPlayer.class);

    update();
    layout();
  }
Ejemplo n.º 4
0
  public UIZoneBook() {

    setId("zonebook");
    setModal(true);
    maximize();
    setCloseKeys(new int[] {Keyboard.KEY_ESCAPE});

    background = new UIImage();
    background.setTexture(Assets.getTexture("miniion:openbook"));
    background.setHorizontalAlign(EHorizontalAlign.CENTER);
    background.setVerticalAlign(EVerticalAlign.CENTER);
    background.setSize(new Vector2f(500, 300));
    background.setVisible(true);
    addDisplayElement(background);

    uizonelist = new UIList();
    uizonelist.setSize(new Vector2f(200, 220));
    uizonelist.setPosition(new Vector2f(40, 20));
    uizonelist.setVisible(true);
    background.addDisplayElement(uizonelist);

    uizonelistgroup = new UIList();
    uizonelistgroup.setSize(new Vector2f(200, 250));
    uizonelistgroup.setPosition(new Vector2f(40, 20));
    uizonelistgroup.setVisible(true);
    background.addDisplayElement(uizonelistgroup);

    lblzonename = new UILabel("Zone name :");
    lblzonename.setPosition(new Vector2f(260, 20));
    lblzonename.setColor(Color.black);
    lblzonename.setVisible(true);
    background.addDisplayElement(lblzonename);

    txtzonename = new UIText();
    txtzonename.setPosition(new Vector2f(350, 20));
    txtzonename.setColor(Color.black);
    txtzonename.setSize(new Vector2f(80, 20));
    txtzonename.setVisible(true);
    background.addDisplayElement(txtzonename);

    lblheight = new UILabel("Height :");
    lblheight.setPosition(new Vector2f(260, 40));
    lblheight.setColor(Color.black);
    lblheight.setVisible(true);
    background.addDisplayElement(lblheight);

    txtheight = new UIText();
    txtheight.setPosition(new Vector2f(350, 40));
    txtheight.setColor(Color.black);
    txtheight.setSize(new Vector2f(80, 20));
    txtheight.setVisible(true);
    background.addDisplayElement(txtheight);

    lblwidth = new UILabel("Width :");
    lblwidth.setPosition(new Vector2f(260, 60));
    lblwidth.setColor(Color.black);
    lblwidth.setVisible(true);
    background.addDisplayElement(lblwidth);

    txtwidth = new UIText();
    txtwidth.setPosition(new Vector2f(350, 60));
    txtwidth.setColor(Color.black);
    txtwidth.setSize(new Vector2f(80, 20));
    txtwidth.setVisible(true);
    background.addDisplayElement(txtwidth);

    lbldepth = new UILabel("Depth :");
    lbldepth.setPosition(new Vector2f(260, 80));
    lbldepth.setColor(Color.black);
    lbldepth.setVisible(true);
    background.addDisplayElement(lbldepth);

    txtdepth = new UIText();
    txtdepth.setPosition(new Vector2f(350, 80));
    txtdepth.setColor(Color.black);
    txtdepth.setSize(new Vector2f(80, 20));
    txtdepth.setVisible(true);
    background.addDisplayElement(txtdepth);

    lblzonetype = new UILabel("");
    lblzonetype.setPosition(new Vector2f(260, 100));
    lblzonetype.setColor(Color.black);
    lblzonetype.setVisible(true);
    background.addDisplayElement(lblzonetype);

    cmbType = new UIComboBox(new Vector2f(80, 20), new Vector2f(80, 200));
    cmbType.setPosition(new Vector2f(350, 100));
    cmbType.setVisible(false);
    background.addDisplayElement(cmbType);
    initTypes();

    lblError = new UILabel("");
    lblError.setWrap(true);
    lblError.setSize(new Vector2f(200, 80));
    lblError.setPosition(new Vector2f(260, 130));
    lblError.setColor(Color.red);
    lblError.setVisible(true);
    background.addDisplayElement(lblError);

    btnSave = new UIModButton(new Vector2f(50, 20), ButtonType.NORMAL);
    btnSave.setPosition(new Vector2f(260, 230));
    btnSave.setLabel("Save");
    btnSave.setId("btnSave");
    btnSave.setVisible(true);
    btnSave.addClickListener(
        new ClickListener() {
          @Override
          public void click(UIDisplayElement element, int button) {
            executeClick(element, button);
          }
        });
    background.addDisplayElement(btnSave);

    btnDelete = new UIModButton(new Vector2f(50, 20), ButtonType.NORMAL);
    btnDelete.setPosition(new Vector2f(260, 230));
    btnDelete.setLabel("Delete");
    btnDelete.setId("btnDelZone");
    btnDelete.setVisible(false);
    btnDelete.addClickListener(
        new ClickListener() {
          @Override
          public void click(UIDisplayElement element, int button) {
            executeDelClick(element, button, (Zone) uizonelist.getSelection().getValue());
          }
        });
    background.addDisplayElement(btnDelete);

    btnBack = new UIModButton(new Vector2f(50, 20), ButtonType.NORMAL);
    btnBack.setPosition(new Vector2f(40, 240));
    btnBack.setLabel("Back");
    btnBack.setId("btnBack");
    btnBack.setVisible(false);
    btnBack.addClickListener(
        new ClickListener() {
          @Override
          public void click(UIDisplayElement element, int button) {
            initList();
            btnBack.setVisible(false);
          }
        });
    background.addDisplayElement(btnBack);
  }
Ejemplo n.º 5
0
  /** Init. the HUD. */
  public UIScreenHUD() {
    maximize();

    _hearts = new UIImage[10];

    // Create hearts
    for (int i = 0; i < 10; i++) {
      _hearts[i] = new UIImage(AssetManager.loadTexture("engine:icons"));
      _hearts[i].setVisible(true);
      _hearts[i].setTextureSize(new Vector2f(9f, 9f));
      _hearts[i].setTextureOrigin(new Vector2f(52f, 0.0f)); // 106f for poison
      _hearts[i].setSize(new Vector2f(18f, 18f));
      _hearts[i].setVerticalAlign(EVerticalAlign.BOTTOM);
      _hearts[i].setHorizontalAlign(EHorizontalAlign.CENTER);
      _hearts[i].setPosition(new Vector2f(18f * i - 212f, -52f));

      addDisplayElement(_hearts[i]);
    }

    crosshair = new UIImage(AssetManager.loadTexture("engine:gui"));
    crosshair.setTextureSize(new Vector2f(20f, 20f));
    crosshair.setTextureOrigin(new Vector2f(24f, 24f));
    crosshair.setSize(new Vector2f(40f, 40f));
    crosshair.setHorizontalAlign(EHorizontalAlign.CENTER);
    crosshair.setVerticalAlign(EVerticalAlign.CENTER);
    crosshair.setVisible(true);

    debugLine1 = new UIText();
    debugLine1.setPosition(new Vector2f(4, 4));
    debugLine2 = new UIText();
    debugLine2.setPosition(new Vector2f(4, 22));
    debugLine3 = new UIText();
    debugLine3.setPosition(new Vector2f(4, 38));
    debugLine4 = new UIText();
    debugLine4.setPosition(new Vector2f(4, 54));

    toolbar = new UIItemContainer(9);
    toolbar.setVisible(true);
    toolbar.setHorizontalAlign(EHorizontalAlign.CENTER);
    toolbar.setVerticalAlign(EVerticalAlign.BOTTOM);

    minionbar = new UIMinionbar();
    minionbar.setVisible(true);

    messagequeue = new UIMessageQueue();
    messagequeue.setVisible(true);

    buffBar = new UIBuff();
    buffBar.setVisible(true);

    addDisplayElement(crosshair, "crosshair");
    addDisplayElement(debugLine1);
    addDisplayElement(debugLine2);
    addDisplayElement(debugLine3);
    addDisplayElement(debugLine4);

    addDisplayElement(toolbar);
    addDisplayElement(minionbar);
    addDisplayElement(messagequeue);
    addDisplayElement(buffBar);

    CoreRegistry.get(EventSystem.class).registerEventHandler(this);

    update();
    layout();
  }
Ejemplo n.º 6
0
  public UIMenuConfigVideo() {
    setId("config:video");
    setBackgroundImage("engine:loadingbackground");
    setModal(true);
    maximize();

    title = new UIImage(Assets.getTexture("engine:terasology"));
    title.setHorizontalAlign(EHorizontalAlign.CENTER);
    title.setPosition(new Vector2f(0f, 128f));
    title.setVisible(true);
    title.setSize(new Vector2f(512f, 128f));

    version = new UILabel("Video Settings");
    version.setHorizontalAlign(EHorizontalAlign.CENTER);
    version.setPosition(new Vector2f(0f, 230f));
    version.setVisible(true);

    graphicsQualityButton = new UIStateButton(new Vector2f(256f, 32f));
    StateButtonAction graphicsQualityStateAction =
        new StateButtonAction() {
          @Override
          public void action(UIDisplayElement element) {
            UIStateButton button = (UIStateButton) element;
            switch (button.getState()) {
              case 0:
                Config.getInstance().setEnablePostProcessingEffects(false);
                Config.getInstance().setFlickeringLight(false);
                break;
              case 1:
                Config.getInstance().setEnablePostProcessingEffects(false);
                Config.getInstance().setFlickeringLight(true);
                break;
              case 2:
                Config.getInstance().setEnablePostProcessingEffects(true);
                Config.getInstance().setFlickeringLight(true);
                break;
            }

            ShaderManager.getInstance().recompileAllShaders();
          }
        };
    graphicsQualityButton.addState("Graphics Quality: Ugly", graphicsQualityStateAction);
    graphicsQualityButton.addState("Graphics Quality: Nice", graphicsQualityStateAction);
    graphicsQualityButton.addState("Graphics Quality: Epic", graphicsQualityStateAction);
    graphicsQualityButton.addClickListener(clickAction);
    graphicsQualityButton.setHorizontalAlign(EHorizontalAlign.CENTER);
    graphicsQualityButton.setPosition(
        new Vector2f(-graphicsQualityButton.getSize().x / 2f - 10f, 300f));
    graphicsQualityButton.setVisible(true);

    viewingDistanceButton = new UIStateButton(new Vector2f(256f, 32f));
    StateButtonAction viewingDistanceStateAction =
        new StateButtonAction() {
          @Override
          public void action(UIDisplayElement element) {
            UIStateButton button = (UIStateButton) element;
            Config.getInstance().setViewingDistanceById(button.getState());
          }
        };
    viewingDistanceButton.addState("Viewing Distance: Near", viewingDistanceStateAction);
    viewingDistanceButton.addState("Viewing Distance: Moderate", viewingDistanceStateAction);
    viewingDistanceButton.addState("Viewing Distance: Far", viewingDistanceStateAction);
    viewingDistanceButton.addState("Viewing Distance: Ultra", viewingDistanceStateAction);
    viewingDistanceButton.addClickListener(clickAction);
    viewingDistanceButton.setHorizontalAlign(EHorizontalAlign.CENTER);
    viewingDistanceButton.setPosition(
        new Vector2f(-viewingDistanceButton.getSize().x / 2f - 10f, 300f + 40f));
    viewingDistanceButton.setVisible(true);

    fovButton = new UISlider(new Vector2f(256f, 32f), 75, 130);
    fovButton.addChangedListener(
        new ChangedListener() {
          @Override
          public void changed(UIDisplayElement element) {
            UISlider slider = (UISlider) element;
            slider.setText("FOV: " + String.valueOf(slider.getValue()));
            Config.getInstance().setFov(slider.getValue());
          }
        });
    fovButton.setHorizontalAlign(EHorizontalAlign.CENTER);
    fovButton.setPosition(new Vector2f(-fovButton.getSize().x / 2f - 10f, 300f + 2 * 40f));
    fovButton.setVisible(true);

    bobbingButton = new UIStateButton(new Vector2f(256f, 32f));
    StateButtonAction bobbingStateAction =
        new StateButtonAction() {
          @Override
          public void action(UIDisplayElement element) {
            UIStateButton button = (UIStateButton) element;
            if (button.getState() == 0) Config.getInstance().setCameraBobbing(false);
            else Config.getInstance().setCameraBobbing(true);
          }
        };
    bobbingButton.addState("Bobbing: Off", bobbingStateAction);
    bobbingButton.addState("Bobbing: On", bobbingStateAction);
    bobbingButton.addClickListener(clickAction);
    bobbingButton.setHorizontalAlign(EHorizontalAlign.CENTER);
    bobbingButton.setPosition(new Vector2f(-bobbingButton.getSize().x / 2f - 10f, 300f + 3 * 40f));
    bobbingButton.setVisible(true);

    animateGrassButton = new UIStateButton(new Vector2f(256f, 32f));
    StateButtonAction animateGrassStateAction =
        new StateButtonAction() {
          @Override
          public void action(UIDisplayElement element) {
            UIStateButton button = (UIStateButton) element;
            if (button.getState() == 0) Config.getInstance().setAnimatedGrass(false);
            else Config.getInstance().setAnimatedGrass(true);

            ShaderManager.getInstance().recompileAllShaders();
          }
        };
    animateGrassButton.addState("Animate Grass: Off", animateGrassStateAction);
    animateGrassButton.addState("Animate Grass: On", animateGrassStateAction);
    animateGrassButton.addClickListener(clickAction);
    animateGrassButton.setHorizontalAlign(EHorizontalAlign.CENTER);
    animateGrassButton.setPosition(new Vector2f(animateGrassButton.getSize().x / 2f, 300f));
    animateGrassButton.setVisible(true);

    reflectiveWaterButton = new UIStateButton(new Vector2f(256f, 32f));
    StateButtonAction reflectiveWaterStateAction =
        new StateButtonAction() {
          @Override
          public void action(UIDisplayElement element) {
            UIStateButton button = (UIStateButton) element;
            if (button.getState() == 0) Config.getInstance().setComplexWater(false);
            else Config.getInstance().setComplexWater(true);

            ShaderManager.getInstance().recompileAllShaders();
          }
        };
    reflectiveWaterButton.addState("Water World Reflection: Off", reflectiveWaterStateAction);
    reflectiveWaterButton.addState("Water World Reflection: On", reflectiveWaterStateAction);
    reflectiveWaterButton.addClickListener(clickAction);
    reflectiveWaterButton.setHorizontalAlign(EHorizontalAlign.CENTER);
    reflectiveWaterButton.setPosition(
        new Vector2f(reflectiveWaterButton.getSize().x / 2f, 300f + 40f));
    reflectiveWaterButton.setVisible(true);

    blurIntensityButton = new UIStateButton(new Vector2f(256f, 32f));
    StateButtonAction blurIntensityStateAction =
        new StateButtonAction() {
          @Override
          public void action(UIDisplayElement element) {
            UIStateButton button = (UIStateButton) element;
            Config.getInstance().setBlurIntensity(button.getState());
            ShaderManager.getInstance().recompileAllShaders();
          }
        };
    blurIntensityButton.addState("Blur Intensity: Off", blurIntensityStateAction);
    blurIntensityButton.addState("Blur Intensity: Some", blurIntensityStateAction);
    blurIntensityButton.addState("Blur Intensity: Normal", blurIntensityStateAction);
    blurIntensityButton.addState("Blur Intensity: Max", blurIntensityStateAction);
    blurIntensityButton.addClickListener(clickAction);
    blurIntensityButton.setHorizontalAlign(EHorizontalAlign.CENTER);
    blurIntensityButton.setPosition(
        new Vector2f(blurIntensityButton.getSize().x / 2f, 300f + 2 * 40f));
    blurIntensityButton.setVisible(true);

    backToConfigMenuButton = new UIButton(new Vector2f(256f, 32f), UIButton.ButtonType.NORMAL);
    backToConfigMenuButton.getLabel().setText("Back");
    backToConfigMenuButton.setHorizontalAlign(EHorizontalAlign.CENTER);
    backToConfigMenuButton.setPosition(new Vector2f(0f, 300f + 7 * 40f));
    backToConfigMenuButton.setVisible(true);
    backToConfigMenuButton.addClickListener(
        new ClickListener() {
          @Override
          public void click(UIDisplayElement element, int button) {
            getGUIManager().openWindow("config");
          }
        });

    addDisplayElement(title);
    addDisplayElement(version);

    addDisplayElement(graphicsQualityButton);
    addDisplayElement(fovButton);
    addDisplayElement(viewingDistanceButton);
    addDisplayElement(animateGrassButton);
    addDisplayElement(reflectiveWaterButton);
    addDisplayElement(blurIntensityButton);
    addDisplayElement(bobbingButton);
    addDisplayElement(backToConfigMenuButton);

    setup();
  }