コード例 #1
0
ファイル: GUI.java プロジェクト: theoutsider24/JORTS
  public String getMouseHover(Vector2f v) {
    for (RectangleShape r : rects) {
      if (r.getGlobalBounds().contains(v)) {
        String result = r.toString();

        if (result.contains("buttonGrid")) {
          result = "";
          try {
            result = ((ButtonGrid) r).getButton(v).toString();
          } catch (Exception e) {
          }
        }
        if (result.equals("")) return null;
        return result;
      }
    }
    return null;
  }
コード例 #2
0
ファイル: GUI.java プロジェクト: theoutsider24/JORTS
  public void init() {
    errorMessage = new TextField();
    errorMessage.text.setColor(Color.RED);
    errorMessage.text.setCharacterSize(10);
    errorMessage.setFillColor(Color.TRANSPARENT);
    errorMessage.setOutlineColor(Color.TRANSPARENT);
    errorMessage.setPosition((RESOLUTION_X / 2) - 50, RESOLUTION_Y - LOWER_GUI_HEIGHT - 80);
    errorMessage.setSize(new Vector2f(200, 15));

    drawables = new ArrayList<Drawable>();
    this.view = window.uiView;
    minimap = new Minimap(window);
    minimap.setPosition(
        RESOLUTION_X - minimap.getSize().x - 20, RESOLUTION_Y - minimap.getSize().y - 20);
    // buttons = new ArrayList<uiButton>();

    lowerBackground = new GuiRectangle();
    lowerBackground.setPosition(0, RESOLUTION_Y - LOWER_GUI_HEIGHT);
    lowerBackground.setSize(new Vector2f(RESOLUTION_X, LOWER_GUI_HEIGHT));
    lowerBackground.setFillColor(new Color(50, 50, 50));

    topBackground = new GuiRectangle();
    topBackground.setPosition(0, 0);
    topBackground.setSize(new Vector2f(RESOLUTION_X, UPPER_GUI_HEIGHT));
    topBackground.setFillColor(new Color(50, 50, 50));

    buildingStatusLayout = new BuildingStatusLayout(this);
    unitStatusLayout = new UnitStatusLayout(this);

    playerList = new PlayerList(window);
    exit = new ExitButton("", window);
    console = new Console();

    clock = new GameClock();
    fpsTimer = new FPSTimer();

    unitCapCounter = new UnitCapCounter(window);
    resourceList = new ResourceList(window);

    selectionRect = new SelectionRect(window);
    cursor = new Cursor(window);
    cursor.setColor(Color.RED);

    mapEditorGui = new MapEditorGui(this);
    mapEditorGui.disable();

    cursorState =
        new UpdatableTextField() {
          @Override
          public void update() {
            setText(cursor.state);
          }
        };
    cursorState.setPosition(new Vector2f(10, RESOLUTION_Y - LOWER_GUI_HEIGHT - 70));

    // grid1 = new StandardButtonGrid(1, 7, new Vector2f(10,100),this);
    controlGroupButtonGrid =
        new ControlGroupButtonGrid(
            1, 9, new Vector2f(RESOLUTION_X / 2, RESOLUTION_Y - LOWER_GUI_HEIGHT - 40), this);
    actionButtonGrid =
        new ActionButtonGrid(0, 0, new Vector2f(20, RESOLUTION_Y - LOWER_GUI_HEIGHT + 20), this);

    // controlGroupButtonGrid.setOutlineThickness(0);
    // initButtons();

    pauseOverlay = new PauseOverlay();

    rects.add(minimap);
    // rects.add(grid1);
    rects.add(controlGroupButtonGrid);
    rects.add(actionButtonGrid);

    rects.add(buildingStatusLayout.currentSlot);
    rects.add(buildingStatusLayout.slots);

    rects.add(clock);
    rects.add(fpsTimer);
    rects.add(unitCapCounter);
    rects.add(exit);
    rects.add(lowerBackground);
    rects.add(topBackground);
  }