示例#1
0
 @Override
 public void dispose() {
   textWidgets.forEach(TextWidget::dispose);
   background.dispose();
   reorganize.dispose();
   newMilitary.dispose();
   recruit.dispose();
   training.dispose();
   merge.dispose();
   disband.dispose();
   upgrade.dispose();
   militaryListTextTemplate.dispose();
   invalidateListPanes();
 }
示例#2
0
  @Override
  public void loadXml(NodeList nodes) {
    for (int i = 0; i < nodes.getLength(); ++i) {
      Node n = nodes.item(i);

      if (n.getNodeName().equals("Background")) {
        background =
            new Texture(
                Gdx.files.external(
                    ArchitectureCommandFrame.DATA_PATH + XmlHelper.loadAttribute(n, "FileName")));
        backgroundPos = Point.fromXml(n);
      } else if (n.getNodeName().equals("MilitaryTable")) {
        militaryTablePos = XmlHelper.loadRectangleFromXml(n);
        NodeList child = n.getChildNodes();
        for (int j = 0; j < child.getLength(); ++j) {
          Node n2 = child.item(j);
          if (n2.getNodeName().equals("Portrait")) {
            militaryTablePortraitSize = Point.fromXmlAsSize(n2);
            militaryTablePortraitColor =
                XmlHelper.loadColorFromXml(
                    Integer.parseUnsignedInt(XmlHelper.loadAttribute(n2, "BorderColor")));
          } else if (n2.getNodeName().equals("Caption")) {
            militaryTableCaptionSize = Point.fromXmlAsSize(n2);
            militaryTableCaptionTemplate = new TextWidget<>(TextWidget.Setting.fromXml(n2));
          } else if (n2.getNodeName().equals("Detail")) {
            militaryTableDetailSize = Point.fromXmlAsSize(n2);
            militaryTableDetailTemplate = new TextWidget<>(TextWidget.Setting.fromXml(n2));
          }
        }
      } else if (n.getNodeName().equals("Reorganize")) {
        reorganize = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n);
        reorganizePos = XmlHelper.loadRectangleFromXml(n);
      } else if (n.getNodeName().equals("New")) {
        newMilitary = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n);
        newMilitaryPos = XmlHelper.loadRectangleFromXml(n);
      } else if (n.getNodeName().equals("Recruit")) {
        recruit = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n);
        recruitPos = XmlHelper.loadRectangleFromXml(n);
      } else if (n.getNodeName().equals("Training")) {
        training = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n);
        trainingPos = XmlHelper.loadRectangleFromXml(n);
      } else if (n.getNodeName().equals("Merge")) {
        merge = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n);
        mergePos = XmlHelper.loadRectangleFromXml(n);
      } else if (n.getNodeName().equals("Disband")) {
        disband = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n);
        disbandPos = XmlHelper.loadRectangleFromXml(n);
      } else if (n.getNodeName().equals("Upgrade")) {
        upgrade = StateTexture.fromXml(ArchitectureCommandFrame.DATA_PATH, n);
        upgradePos = XmlHelper.loadRectangleFromXml(n);
      } else if (n.getNodeName().equals("MilitaryList")) {
        militaryListPos = XmlHelper.loadRectangleFromXml(n);
        listNameWidth = Integer.parseInt(XmlHelper.loadAttribute(n, "NameWidth"));
        listRecruitWidth = Integer.parseInt(XmlHelper.loadAttribute(n, "RecruitWidth"));
        listTrainWidth = Integer.parseInt(XmlHelper.loadAttribute(n, "TrainWidth"));
        listQuantityWidth = Integer.parseInt(XmlHelper.loadAttribute(n, "QuantityWidth"));
        listRowHeight = Integer.parseInt(XmlHelper.loadAttribute(n, "RowHeight"));
        militaryListTextTemplate = new TextWidget<>(TextWidget.Setting.fromXml(n));
      } else if (n.getNodeName().equals("SelectedBorderColor")) {
        selectedBorderColor =
            XmlHelper.loadColorFromXml(
                Integer.parseUnsignedInt(XmlHelper.loadAttribute(n, "BorderColor")));
      } else {
        ArchitectureCommandFrame.loadText(n, textWidgets);
      }
    }
  }
示例#3
0
 @Override
 public void onMouseMove(float x, float y) {
   if (reorganizePos.contains(x, y)) {
     reorganize.setState(StateTexture.State.SELECTED);
   } else {
     reorganize.setState(StateTexture.State.NORMAL);
   }
   if (newMilitaryPos.contains(x, y)) {
     newMilitary.setState(StateTexture.State.SELECTED);
   } else {
     newMilitary.setState(StateTexture.State.NORMAL);
   }
   if (recruitPos.contains(x, y)) {
     recruit.setState(StateTexture.State.SELECTED);
   } else {
     recruit.setState(StateTexture.State.NORMAL);
   }
   if (trainingPos.contains(x, y)) {
     training.setState(StateTexture.State.SELECTED);
   } else {
     training.setState(StateTexture.State.NORMAL);
   }
   if (mergePos.contains(x, y)) {
     merge.setState(StateTexture.State.SELECTED);
   } else {
     merge.setState(StateTexture.State.NORMAL);
   }
   if (disbandPos.contains(x, y)) {
     disband.setState(StateTexture.State.SELECTED);
   } else {
     disband.setState(StateTexture.State.NORMAL);
   }
   if (upgradePos.contains(x, y)) {
     upgrade.setState(StateTexture.State.SELECTED);
   } else {
     upgrade.setState(StateTexture.State.NORMAL);
   }
 }
示例#4
0
  @Override
  public void draw(Batch batch, float parentAlpha) {
    batch.draw(
        reorganize.get(),
        parent.getX() + reorganizePos.x,
        parent.getY() + reorganizePos.y,
        reorganizePos.width,
        reorganizePos.height);
    batch.draw(
        newMilitary.get(),
        parent.getX() + newMilitaryPos.x,
        parent.getY() + newMilitaryPos.y,
        newMilitaryPos.width,
        newMilitaryPos.height);
    batch.draw(
        recruit.get(),
        parent.getX() + recruitPos.x,
        parent.getY() + recruitPos.y,
        recruitPos.width,
        recruitPos.height);
    batch.draw(
        training.get(),
        parent.getX() + trainingPos.x,
        parent.getY() + trainingPos.y,
        trainingPos.width,
        trainingPos.height);
    batch.draw(
        merge.get(),
        parent.getX() + mergePos.x,
        parent.getY() + mergePos.y,
        mergePos.width,
        mergePos.height);
    batch.draw(
        disband.get(),
        parent.getX() + disbandPos.x,
        parent.getY() + disbandPos.y,
        disbandPos.width,
        disbandPos.height);
    batch.draw(
        upgrade.get(),
        parent.getX() + upgradePos.x,
        parent.getY() + upgradePos.y,
        upgradePos.width,
        upgradePos.height);

    for (TextWidget<ArchitectureCommandFrame.TextType> textWidget : textWidgets) {
      textWidget.setPosition(
          textWidget.getExtra().position.x + parent.getX(),
          textWidget.getExtra().position.y + parent.getY());
      if (textWidget.getExtra().staticText) {
        textWidget.setText(textWidget.getExtra().name);
      } else {
        textWidget.setText(
            parent.getCurrentArchitecture().getFieldString(textWidget.getExtra().name));
      }
      textWidget.draw(batch, parentAlpha);
    }

    if (militaryBottomPane == null) {
      initMilitaryBottomPane();
    }
    if (militaryTopPane == null) {
      initMilitaryTopPane();
    }

    if (currentMilitary != null) {
      batch.end();

      shapeRenderer.begin(ShapeRenderer.ShapeType.Line);

      shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
      shapeRenderer.setTransformMatrix(batch.getTransformMatrix());

      shapeRenderer.setColor(selectedBorderColor);
      shapeRenderer.rect(
          parent.getX() + currentMilitaryPos.getX(),
          parent.getY() + currentMilitaryPos.getY(),
          currentMilitaryPos.getWidth(),
          currentMilitaryPos.getHeight());

      shapeRenderer.end();

      batch.begin();
    }
  }