示例#1
0
  public void setRoot(RootCLI root) {
    CommandLineData newData = new CommandLineData(root, cld);
    cld = newData;

    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 =
        "Connected to "
            + root.getDeviceName()
            + ": "
            + day
            + " "
            + month
            + " "
            + String.format("%02d", date)
            + " "
            + String.format("%02d", hour)
            + ":"
            + String.format("%02d", min)
            + ":"
            + String.format("%02d", sec);

    cld.textHistory = textTest;
    consoleArrow.setText(cld.parser.getInputPrefix());
    consoleDialog.setText(cld.textHistory);
    this.setKeyboardFocus();
  }
示例#2
0
 public void handleConsoleLog(ConsoleLogEvent event) {
   if (event.getOwnerUI() == cld.ownerUI) {
     cld.textHistory = cld.textHistory + "\n" + event.getText();
     consoleDialog.setText(cld.textHistory);
     updateScroll += 20;
   }
 }
示例#3
0
 public void handleClearTerminal(ClearTerminalEvent event) {
   if (event.getOwnerUI() == cld.ownerUI) {
     cld.textHistory = "";
     consoleDialog.setText(cld.textHistory);
     updateScroll += 20;
   }
 }
示例#4
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();
  }