コード例 #1
0
  private void inizializiraneWarningMessage() {
    tableMessage = new Table();
    tableMessage.setFillParent(true);
    tableMessage.top();

    labelMessage = new Label("", skin);
    labelMessage.setColor(Color.WHITE);
    labelMessage.setAlignment(Align.center);
    tableMessage.add(labelMessage).expandX().padTop(Constant.CONSTANT_TABLE_MESSAGE_PAD_TOP);
    stage.addActor(tableMessage);
  }
コード例 #2
0
 /** Set benchmark table position */
 public void setUpPosition(BenchmarkPosition benchmarkPosition) {
   switch (benchmarkPosition) {
     case CENTER:
       table.center();
       break;
     case TOP_LEFT:
       table.top().left();
       break;
     case TOP_RIGHT:
       table.top().right();
       break;
     case BOTTOM_LEFT:
       table.bottom().left();
       break;
     case BOTTOM_RIGHT:
       table.bottom().right();
       break;
     default:
       table.top().left();
       break;
   }
 }
  public PropertyTable(Skin skin) {
    //		super(skin);
    table = new Table(skin);
    this.skin = skin;
    top().left();
    table.top().left();

    table.add(new Label("Name", skin));
    table.add(new Label("Value", skin));
    table.setFillParent(true);

    fill();
    prefHeight(1000);

    setActor(table);
  }
コード例 #4
0
ファイル: Hud.java プロジェクト: dfsilva/MarioBros
  public Hud(SpriteBatch sb) {
    // define our tracking variables
    worldTimer = 300;
    timeCount = 0;
    score = 0;

    // setup the HUD viewport using a new camera seperate from our gamecam
    // define our stage using that viewport and our games spritebatch
    viewport = new FitViewport(MarioBros.V_WIDTH, MarioBros.V_HEIGHT, new OrthographicCamera());
    stage = new Stage(viewport, sb);

    // define a table used to organize our hud's labels
    Table table = new Table();
    // Top-Align table
    table.top();
    // make the table fill the entire stage
    table.setFillParent(true);

    // define our labels using the String, and a Label style consisting of a font and color
    countdownLabel =
        new Label(
            String.format("%03d", worldTimer), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    scoreLabel =
        new Label(
            String.format("%06d", score), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    timeLabel = new Label("TIME", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    levelLabel = new Label("1-1", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    worldLabel = new Label("WORLD", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    marioLabel = new Label("MARIO", new Label.LabelStyle(new BitmapFont(), Color.WHITE));

    // add our labels to our table, padding the top, and giving them all equal width with expandX
    table.add(marioLabel).expandX().padTop(10);
    table.add(worldLabel).expandX().padTop(10);
    table.add(timeLabel).expandX().padTop(10);
    // add a second row to our table
    table.row();
    table.add(scoreLabel).expandX();
    table.add(levelLabel).expandX();
    table.add(countdownLabel).expandX();

    // add our table to the stage
    stage.addActor(table);
  }
コード例 #5
0
ファイル: GameOverlay.java プロジェクト: happypandaface/28in
  public GameOverlay() {
    batch = new SpriteBatch();
    stage = new Stage();
    inMux = new InputMultiplexer();
    inMux.addProcessor(stage);
    overlayStage = new Stage();

    topMenu = new Table();
    topMenu.setFillParent(true);
    topMenu.top();
    topMenu.left();
    stage.addActor(topMenu);

    bottomMenu = new Table();
    bottomMenu.setFillParent(true);
    bottomMenu.bottom();
    stage.addActor(bottomMenu);

    overlayMenu = new Table();
    overlayMenu.setFillParent(true);
    overlayMenu.center();
    overlayStage.addActor(overlayMenu);
  }
コード例 #6
0
  private void initMilitaryTopPane() {
    Table contentTable = new Table();

    int itemPerRow =
        (int) (militaryTablePos.width / (militaryTablePortraitSize.x + militaryTableCaptionSize.x));
    int index = 0;
    for (Military m : parent.getCurrentArchitecture().getMilitariesWithLeader()) {
      Table item = new Table();

      Person leader = m.getLeader();
      ImageWidget<Military> portrait;
      if (leader != null) {
        portrait =
            new ImageWidget<>(
                parent.getScreen().getSmallPortrait(leader.getPortraitId()),
                militaryTablePortraitColor);
      } else {
        portrait = new ImageWidget<>(null, militaryTablePortraitColor);
      }
      portrait.setExtra(m);
      item.add(portrait).width(militaryTablePortraitSize.x).height(militaryTablePortraitSize.y);

      Table detail = new Table();

      TextWidget<Military> caption = new TextWidget<>(militaryTableCaptionTemplate);
      caption.setExtra(m);
      caption.setText(m.getName());
      detail
          .add(caption)
          .width(militaryTableCaptionSize.x)
          .height(militaryTableCaptionSize.y)
          .row();

      TextWidget<Military> quantity = new TextWidget<>(militaryTableDetailTemplate);
      quantity.setExtra(m);
      quantity.setText(
          GlobalStrings.getString(GlobalStrings.Keys.MILITARY_QUANTITY_SHORT) + m.getQuantity());
      detail.add(quantity).width(militaryTableDetailSize.x).height(militaryTableDetailSize.y).row();

      TextWidget<Military> morale = new TextWidget<>(militaryTableDetailTemplate);
      morale.setExtra(m);
      morale.setText(
          GlobalStrings.getString(GlobalStrings.Keys.MILITARY_MORALE_SHORT) + m.getMorale());
      detail.add(morale).width(militaryTableDetailSize.x).height(militaryTableDetailSize.y).row();

      TextWidget<Military> combativity = new TextWidget<>(militaryTableDetailTemplate);
      combativity.setExtra(m);
      combativity.setText(
          GlobalStrings.getString(GlobalStrings.Keys.MILITARY_COMBATIVITY_SHORT)
              + m.getCombativity());
      detail
          .add(combativity)
          .width(militaryTableDetailSize.x)
          .height(militaryTableDetailSize.y)
          .row();

      detail.top();
      item.add(detail);

      item.addListener(
          new InputListener() {
            @Override
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
              currentMilitary = m;
              currentMilitaryPos =
                  new Rectangle(
                      item.getX() + militaryTablePos.getX(),
                      item.getY() + militaryTablePos.getY(),
                      item.getWidth(),
                      item.getHeight());
              if (m.isCampaignable()) {
                parent
                    .getScreen()
                    .getMapLayer()
                    .startSelectingLocation(
                        parent.getCurrentArchitecture().getCampaignablePositions(),
                        p -> {
                          m.startCampaign(p);
                          invalidateListPanes();
                        });
              }
              return true;
            }
          });

      contentTable.add(item);

      index++;
      if (index % itemPerRow == 0) {
        contentTable.row();
      }
    }

    contentTable.top().left();

    ScrollPane data = new ScrollPane(contentTable);
    militaryTopPane =
        WidgetUtility.setupScrollpane(
            militaryTablePos.getX(),
            militaryTablePos.getY(),
            militaryTablePos.getWidth(),
            militaryTablePos.getHeight(),
            data,
            parent.getScrollbar());

    parent.addActor(militaryTopPane);
  }
コード例 #7
0
  private void initMilitaryBottomPane() {
    Table contentTable = new Table();

    for (Military m : parent.getCurrentArchitecture().getMilitariesWithoutLeader()) {
      List<TextWidget<Military>> rowWidgets = new ArrayList<>();

      TextWidget<Military> name = new TextWidget<>(militaryListTextTemplate);
      name.setExtra(m);
      name.setText(m.getName());
      contentTable.add(name).width(listNameWidth).height(listRowHeight);
      rowWidgets.add(name);

      TextWidget<Military> quantity = new TextWidget<>(militaryListTextTemplate);
      quantity.setExtra(m);
      quantity.setText(String.valueOf(m.getQuantity()));
      contentTable.add(quantity).width(listQuantityWidth).height(listRowHeight);
      rowWidgets.add(quantity);

      TextWidget<Military> recruit = new TextWidget<>(militaryListTextTemplate);
      recruit.setExtra(m);
      if (m.isFullyRecruited()) {
        recruit.setText(GlobalStrings.getString(GlobalStrings.Keys.TICK));
      } else if (m.isBeingRecruited()) {
        recruit.setText(GlobalStrings.getString(GlobalStrings.Keys.UP_ARROW));
      } else {
        recruit.setText("");
      }
      contentTable.add(recruit).width(listRecruitWidth).height(listRowHeight).center();
      rowWidgets.add(recruit);

      TextWidget<Military> train = new TextWidget<>(militaryListTextTemplate);
      train.setExtra(m);
      if (m.isFullyTrained()) {
        train.setText(GlobalStrings.getString(GlobalStrings.Keys.TICK));
      } else if (m.isBeingTrained()) {
        train.setText(GlobalStrings.getString(GlobalStrings.Keys.UP_ARROW));
      } else {
        train.setText("");
      }
      contentTable.add(train).width(listTrainWidth).height(listRowHeight).center();
      rowWidgets.add(train);

      rowWidgets.forEach(
          x ->
              x.addListener(
                  new InputListener() {
                    @Override
                    public boolean touchDown(
                        InputEvent event, float x, float y, int pointer, int button) {
                      currentMilitary = m;
                      currentMilitaryPos =
                          new Rectangle(
                              name.getX() + militaryListPos.getX(),
                              name.getY() + militaryListPos.getY(),
                              militaryListPos.getWidth(),
                              name.getHeight());
                      return true;
                    }
                  }));

      showingTextWidgets.addAll(rowWidgets);

      contentTable.row().height(listRowHeight);
    }

    contentTable.top().left();

    ScrollPane data = new ScrollPane(contentTable);
    militaryBottomPane =
        WidgetUtility.setupScrollpane(
            militaryListPos.getX(),
            militaryListPos.getY(),
            militaryListPos.getWidth(),
            militaryListPos.getHeight(),
            data,
            parent.getScrollbar());

    parent.addActor(militaryBottomPane);
  }
コード例 #8
0
  public HotbarInventoryView(
      Stage stage,
      Skin skin,
      Inventory hotbarInventory,
      Inventory inventory,
      DragAndDrop dragAndDrop,
      OreClient client) {
    m_skin = skin;
    m_inventory = inventory;
    m_client = client;
    m_stage = stage;

    m_hotbarInventory = hotbarInventory;
    // attach to the inventory model
    m_hotbarInventory.addListener(this);

    container = new Table(m_skin);
    container.setFillParent(true);
    container.top().left().setSize(800, 100);
    container.padLeft(10).padTop(10);

    container.defaults().space(4);

    stage.addActor(container);

    Image dragImage = new Image();
    dragImage.setSize(32, 32);

    for (byte i = 0; i < Inventory.maxHotbarSlots; ++i) {

      Image slotImage = new Image();

      SlotElement element = new SlotElement();
      m_slots[i] = element;

      element.itemImage = slotImage;

      Table slotTable = new Table(m_skin);
      element.table = slotTable;
      slotTable.setTouchable(Touchable.enabled);
      slotTable.addListener(new SlotClickListener(this, i));
      slotTable.addListener(new SlotInputListener(this, i));

      slotTable.add(slotImage);
      slotTable.background("default-pane");

      slotTable.row();

      Label itemCount = new Label(null, m_skin);
      slotTable.add(itemCount).bottom().fill();
      element.itemCountLabel = itemCount;

      //            container.add(slotTable).size(50, 50);
      container.add(slotTable).fill().size(50, 50);
      setHotbarSlotVisible(i, false);

      dragAndDrop.addSource(new HotbarDragSource(slotTable, i, dragImage, this));

      dragAndDrop.addTarget(new HotbarDragTarget(slotTable, i, this));
    }

    m_tooltip = new Label(null, m_skin);
    stage.addActor(m_tooltip);
  }
コード例 #9
0
  public void createWindow() {
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextButton closeButton = new TextButton("", skin, "close-toggle");

    Random random = new Random();

    dialog = new Window("Terminal", skin);
    dialog.setBounds(10 + random.nextInt(50), 100 + random.nextInt(50), 400, 200);
    dialog.setResizable(true);
    dialog.setKeepWithinStage(true);
    dialog
        .getTitleTable()
        .add(closeButton)
        .size(dialog.getPadTop() * 4 / 5, dialog.getPadTop() * 4 / 5)
        .padRight(dialog.getPadRight());
    dialog.left().top();
    dialog.setResizeBorder(5);
    dialog.padRight(0);
    dialog.padBottom(1);

    SimpleDateFormat simpleDateformat = new SimpleDateFormat("E");
    String day = simpleDateformat.format(new Date());
    String month = new SimpleDateFormat("MMM").format(Calendar.getInstance().getTime());
    int date = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
    int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
    int min = Calendar.getInstance().get(Calendar.MINUTE);
    int sec = Calendar.getInstance().get(Calendar.SECOND);
    String textTest =
        "Last login: "******" "
            + month
            + " "
            + String.format("%02d", date)
            + " "
            + String.format("%02d", hour)
            + ":"
            + String.format("%02d", min)
            + ":"
            + String.format("%02d", sec);

    cld.textHistory = textTest;
    consoleDialog = new Label(cld.textHistory, skin);
    consoleDialog.setWrap(true);
    consoleDialog.setAlignment(Align.topLeft, Align.topLeft);

    consoleArrow =
        new Label(cld.parser.getInputPrefix(), new LabelStyle(skin.get(LabelStyle.class)));
    consoleField = new TextField("", skin);
    consoleField.setFocusTraversal(false);
    Color colour = Color.ORANGE;
    colour.a = 0.8f;
    consoleField.getStyle().cursor = skin.newDrawable("white", colour);
    consoleField.getStyle().cursor.setMinWidth(10);
    consoleField.setBlinkTime(0.6f);

    Table scrollTable = new Table();
    scrollTable.top();
    scrollTable.add(consoleDialog).colspan(2).growX().fill().left().top();
    scrollTable.row();
    scrollTable.add(consoleArrow).left().top();
    scrollTable.add(consoleField).expand(true, false).fill().left().top();
    scrollTable.padBottom(1);

    consoleScroll = new ScrollPane(scrollTable, skin);
    consoleScroll.setFadeScrollBars(false);
    consoleScroll.setVariableSizeKnobs(true);
    consoleScroll.setFlickScroll(false);
    dialog.add(consoleScroll).fill().expand();
    this.stage.addActor(dialog);

    closeButton.addListener(new CLICloseButtonListener(this, dialog));

    setKeyboardFocus();
  }
コード例 #10
0
  @Override
  public void create() {
    skin = new Skin(Gdx.files.internal(SKIN));

    EditorLogger.setDebug();
    EditorLogger.debug("CREATE");
    Ctx.project = new Project();
    Ctx.msg = new Message(skin);
    Ctx.assetManager = new EditorAssetManager();

    scnEditor = new ScnEditor(skin);
    skin.getFont("default-font").getData().markupEnabled = true;

    /** * STAGE SETUP ** */
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);

    // RIGHT PANEL
    ScenePanel scenePanel = new ScenePanel(skin);
    ActorPanel actorPanel = new ActorPanel(skin);

    Table rightPanel = new Table();
    rightPanel.top().left();
    //		rightPanel.add(scenePanel).expand().fill();
    //		rightPanel.row();
    rightPanel.add(actorPanel).expand().fill();

    SplitPane splitPaneRight = new SplitPane(scnEditor, rightPanel, false, skin);

    // LEFT PANEL
    ProjectPanel projectPanel = new ProjectPanel(skin);
    //		AssetPanel assetPanel = new AssetPanel(skin);
    Image img = new Image(Ctx.assetManager.getIcon("title"));
    img.setScaling(Scaling.none);
    img.setAlign(Align.left);

    Table leftPanel = new Table();
    leftPanel.top().left().padLeft(10);
    leftPanel.add(img).expand().fill().padBottom(20).padTop(20).padLeft(20);
    leftPanel.row();
    leftPanel.add(new ProjectToolbar(skin)).expandX().fill();
    leftPanel.row();
    leftPanel.add(projectPanel).expand().fill();
    leftPanel.row();
    leftPanel.add(scenePanel).expand().fill();

    SplitPane splitPaneLeft = new SplitPane(leftPanel, splitPaneRight, false, skin);
    splitPaneLeft.setFillParent(true);
    splitPaneLeft.setSplitAmount(0.3f);
    stage.addActor(splitPaneLeft);

    // LOAD LAST OPEN PROJECT
    String lastProject = Ctx.project.getEditorConfig().getProperty(Project.LAST_PROJECT_PROP, "");

    if (!lastProject.isEmpty() && new File(lastProject).exists()) {
      try {
        EditorLogger.debug("Loading last project: " + lastProject);
        Ctx.project.loadProject(new File(lastProject));
      } catch (Exception e) {
        EditorLogger.debug("Error loading last project: " + e.getMessage());
        Ctx.project.closeProject();
        e.printStackTrace();
      }
    }

    stage.setScrollFocus(scnEditor.getScnWidget());
    stage.setKeyboardFocus(scnEditor.getScnWidget());
  }