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(); }
public void btnClicked() { if (ans == Integer.parseInt(answer.getText())) { feedback.setText("Correct"); } else { feedback.setText("Incorrect"); } }
/** Update benchmarking. Must be used in render (or act or draw etc...) */ public void update() { if (isBenchmarkManagerActive) { if (System.nanoTime() - startTime >= 1000000000) { secondsTime++; startTime = System.nanoTime(); } if (!isFirstDataTaken) { if (secondsTime > 4f) { fpsBest = Gdx.graphics.getFramesPerSecond(); fpsWorst = Gdx.graphics.getFramesPerSecond(); isFirstDataTaken = true; } } else { if (Gdx.graphics.getFramesPerSecond() > fpsBest) fpsBest = Gdx.graphics.getFramesPerSecond(); if (Gdx.graphics.getFramesPerSecond() < fpsWorst) fpsWorst = Gdx.graphics.getFramesPerSecond(); } // labelRunTime.setText(getRunTime()); labelFps.setText(getFPS()); } }
public void tryAllUpRoot(UUID cliID) { CommandLineData newData = cld.findCommandLineData(cliID); if (newData != null) { cld = newData; consoleArrow.setText(cld.parser.getInputPrefix()); consoleDialog.setText(cld.textHistory); updateScroll += 5; } }
public void update() { if (backpackStock != null && backpackStock == -1) { stockLabel.setText(stock.getStock().toString()); price.setText("$" + ((Float) (1.1f * stock.getPrice())).toString()); } else if (pack.getContents().get(item) != null) { stockLabel.setText(pack.getContents().get(item).toString()); price.setText("$" + ((Float) (0.9f * stock.getPrice())).toString()); } }
public void resetEquipSlots() { _DPVal = 0; _APVal = 0; _DPValLabel.setText(String.valueOf(_DPVal)); notify(String.valueOf(_DPVal), InventoryObserver.InventoryEvent.UPDATED_DP); _APValLabel.setText(String.valueOf(_APVal)); notify(String.valueOf(_APVal), InventoryObserver.InventoryEvent.UPDATED_AP); }
@Override public void preUIrender(float delta) { if (game.getGameMode() == GameMode.NORMAL_TIME_LIMIT) { gameTimeLabel.setText(Tools.formatNumber(game.getGameTimeRemaining(), 2, 2)); } else if (game.getGameMode() == GameMode.NORMAL_CONTINUOUS) { gameTimeLabel.setText(Tools.formatNumber(game.getGameTimeElapsed(), 2, 2)); } game.render(batch); drawUI(); }
public void setBtnColorSampleColor() { imageActor.setColor(colorR, colorG, colorB, colorA); color.set(colorR, colorG, colorB, colorA); if (labelR != null) { labelR.setText(Float.toString(colorR * 100)); labelG.setText(Float.toString(colorG * 100)); labelB.setText(Float.toString(colorB * 100)); labelA.setText(Float.toString(colorA * 100)); } if (listener != null) { listener.changed(new ChangeListener.ChangeEvent(), this); } }
public void handleConsoleLog(ConsoleLogEvent event) { if (event.getOwnerUI() == cld.ownerUI) { cld.textHistory = cld.textHistory + "\n" + event.getText(); consoleDialog.setText(cld.textHistory); updateScroll += 20; } }
public void handleClearTerminal(ClearTerminalEvent event) { if (event.getOwnerUI() == cld.ownerUI) { cld.textHistory = ""; consoleDialog.setText(cld.textHistory); updateScroll += 20; } }
public void healVillage() { if (GameData.villageHp() >= GameData.maxVillageHp()) { showNotif("Your Village Health is full."); } else if (healMana <= GameData.mana()) { Sfx.playHeal(); healed = true; if (hp10 + GameData.villageHp() > GameData.maxVillageHp()) { GameData.setVillageHp(GameData.maxVillageHp()); // villageHpBar.addAction(scaleTo(1f, 1f, 1f)); } else { GameData.setVillageHp(GameData.villageHp() + hp10); // villageHpBar.addAction(scaleBy(0.1f, 0f, 1f)); } if (GameData.mana() - healMana < 0) { GameData.setMana(0); manaBar.addAction(scaleTo(0f, 1f, 1f)); } else { GameData.setMana(GameData.mana() - healMana); lobby.updateLabels(); } mana.setText(GameData.mana() + "/" + GameData.maxMana()); // villageHp.setText(GameData.villageHp() + "/" + GameData.maxVillageHp()); closeUi(); } else { showMagicAd(); int neededMana = healMana - GameData.mana(); showNotif("Need " + neededMana + " more mana."); } }
private boolean checkUserField(String logField) { if (logField.matches(Constant.USER_PATTERN)) { return true; } labelMessage.setText("Username must contain at least one letter and be 3-10 characters."); return false; }
@Override public void update() { if (readyToConnect && !connectStarted) { Client.reset(new LanClient()); Input.setup(Client.get()); connectStarted = true; } if (Input.isActive(Commands.get(Aigilas.Commands.Start), 0)) { if (ipIn.getText() != null && !ipIn.getText().isEmpty()) { String[] contents = ipIn.getText().split(":"); String address = contents[0]; if (contents.length > 1) { int port = Parse.inte(contents[1]); Config.get().setPort(port); } label.setText(waitMessage); Config.get().setServerIp(address); readyToConnect = true; ipIn.setVisible(false); } } if (Client.get().isGameStarting()) { for (int ii = 0; ii < Client.get().getPlayerCount(); ii++) { Input.setContext(Contexts.get(Sps.Contexts.Free), ii); } StateManager.loadState(new LoadingState()); } }
public void shieldVillage() { if (GameData.villageShield()) { showNotif("Shield is already activated."); } else if (shieldMana <= GameData.mana()) { Sfx.playShield(); GameData.setVillageShield(true); GameData.setShieldDuration(3600); showShieldBuff(); if (GameData.mana() - shieldMana < 0) { GameData.setMana(0); manaBar.addAction(scaleTo(0f, 1f, 1f)); } else { GameData.setMana(GameData.mana() - shieldMana); lobby.updateLabels(); } mana.setText(GameData.mana() + "/" + GameData.maxMana()); closeUi(); } else { showMagicAd(); int neededMana = shieldMana - GameData.mana(); showNotif("Need " + neededMana + " more mana."); } }
public void handleAutocompleteResponse(AutocompleteResponseEvent event) { if (event.getOwnerUI() == cld.ownerUI) { consoleArrow.setText(cld.parser.getInputPrefix()); consoleField.setText(event.getText()); consoleField.setCursorPosition(consoleField.getText().length()); } }
@Override public void onNotify(InventorySlot slot, SlotEvent event) { switch (event) { case ADDED_ITEM: InventoryItem addItem = slot.getTopInventoryItem(); if (addItem == null) return; if (addItem.isInventoryItemOffensive()) { _APVal += addItem.getItemUseTypeValue(); _APValLabel.setText(String.valueOf(_APVal)); notify(String.valueOf(_APVal), InventoryObserver.InventoryEvent.UPDATED_AP); if (addItem.isInventoryItemOffensiveWand()) { notify( String.valueOf(addItem.getItemUseTypeValue()), InventoryObserver.InventoryEvent.ADD_WAND_AP); } } else if (addItem.isInventoryItemDefensive()) { _DPVal += addItem.getItemUseTypeValue(); _DPValLabel.setText(String.valueOf(_DPVal)); notify(String.valueOf(_DPVal), InventoryObserver.InventoryEvent.UPDATED_DP); } break; case REMOVED_ITEM: InventoryItem removeItem = slot.getTopInventoryItem(); if (removeItem == null) return; if (removeItem.isInventoryItemOffensive()) { _APVal -= removeItem.getItemUseTypeValue(); _APValLabel.setText(String.valueOf(_APVal)); notify(String.valueOf(_APVal), InventoryObserver.InventoryEvent.UPDATED_AP); if (removeItem.isInventoryItemOffensiveWand()) { notify( String.valueOf(removeItem.getItemUseTypeValue()), InventoryObserver.InventoryEvent.REMOVE_WAND_AP); } } else if (removeItem.isInventoryItemDefensive()) { _DPVal -= removeItem.getItemUseTypeValue(); _DPValLabel.setText(String.valueOf(_DPVal)); notify(String.valueOf(_DPVal), InventoryObserver.InventoryEvent.UPDATED_DP); } break; default: break; } }
private boolean checkPasswordAndRePassword(String password, String rePassword) { if (password.equals(rePassword)) { return true; } else { labelMessage.setText("Password and Re-Password must be the same"); return false; } }
public final void renderPlayers() { // Display participated players for (int i = 0; i < playerPositions.size(); i++) { switch (playerPositions.get(i)) { case 1: p1Position.setText(Integer.toString(playerPositions.size() - i)); p1Field.setVisible(true); if (1 == Constants.PLAYERID) { p1FieldHighlight.setVisible(true); } break; case 2: p2Position.setText(Integer.toString(playerPositions.size() - i)); p2Field.setVisible(true); if (2 == Constants.PLAYERID) { p2FieldHighlight.setVisible(true); } break; case 3: p3Position.setText(Integer.toString(playerPositions.size() - i)); p3Field.setVisible(true); if (3 == Constants.PLAYERID) { p3FieldHighlight.setVisible(true); } break; case 4: p4Position.setText(Integer.toString(playerPositions.size() - i)); p4Field.setVisible(true); if (4 == Constants.PLAYERID) { p4FieldHighlight.setVisible(true); } break; } } }
private boolean checkEmailField(String emailField) { if (emailField.matches(Constant.EMAIL_PATTERN)) { return true; } else { labelMessage.setText("Invalid email"); return false; } }
public void render() { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); drawn = 0; stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); drawnLabel.setText("Drawn: " + drawn + "/" + count); drawnLabel.invalidateHierarchy(); }
public void enterClicked() { EventManager.get_instance() .broadcast(new CommandLineEvent(cld.ownerUI, consoleField.getText())); cld.previousCommands.add(consoleField.getText()); consoleArrow.setText(cld.parser.getInputPrefix()); consoleField.setText(""); setKeyboardFocus(); }
private boolean checkPasswordField(String passwordText) { if (passwordText.matches(Constant.PASSWORD_PATTERN)) { return true; } else { labelMessage.setText( "Password must contain a capital letter, \n one lowercase letter, one number and be 5-10 characters"); return false; } }
/** Sets the loading to finished and displays the finished loading message. */ public void loadingFinished() { if (!progressLabel.getText().equals(ON_FINISHED_LABEL_TEXT)) { progressLabel.setText(ON_FINISHED_LABEL_TEXT); centerProgressLabel(); loadBar.setScaleX(1); loadBar.invalidate(); } }
public void showNotif(String text) { notifTxt.remove(); notifTxt.setText(text); notifTxt.setPosition(512 - notifTxt.getWidth() / 2, 300 - notifTxt.getHeight() / 2); notifTxt.setAlignment(Align.center); GdxGame.ui_stage1.addActor(notifTxt); notifTxt.clearActions(); notifTxt.addAction(sequence(alpha(1f), delay(1f), fadeOut(1f), removeActor())); }
public int advanceDialogue(int currCount) { dialogueLabel.setText(Resources.getInstance().finalDialogue[currCount]); dialogueLabel.setColor(Resources.getInstance().finalDialogueColor[currCount]); dialogueLabel.setAlignment(Resources.getInstance().finalDialogueAlign[currCount]); if (currCount == 2) { leftPerson.setVisible(true); } return count + 1; }
@Override public void create() { w = Gdx.graphics.getWidth(); h = Gdx.graphics.getHeight(); margin = 10; stage = new Stage(); Gdx.input.setInputProcessor(stage); Skin skin = new Skin(Gdx.files.internal("data/uiskin.json")); FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf")); BitmapFont font15 = generator.generateFont(15); generator.dispose(); LabelStyle lblStyle = new LabelStyle(skin.get(LabelStyle.class)); lblStyle.font = font15; lblStyle.fontColor = Color.BLACK; lblStyle.background = null; LabelStyle lblOutStyle = new LabelStyle(skin.get(LabelStyle.class)); lblOutStyle.font = font15; lblOutStyle.fontColor = Color.BLACK; lblOutStyle.background = new ColorDrawable(new HSV_Color(Color.WHITE)); TextButtonStyle btnStyle = skin.get(TextButtonStyle.class); btnStyle.font = font15; btnStyle.fontColor = Color.BLACK; lblMsg = new Label(Msg, lblStyle); stage.addActor(lblMsg); lblOut = new Label("", lblOutStyle); // lblOut = new Label("", lblStyle); lblOut.setText(" "); stage.addActor(lblOut); btnRunLibGdx = new TextButton("", btnStyle); stage.addActor(btnRunLibGdx); btnRunTranslations = new TextButton("download and copy latest translations", btnStyle); btnRunTranslations.addListener(runListenerTranslations); stage.addActor(btnRunTranslations); btnRunTexturePacker = new TextButton("Pack and copy Texture Images", btnStyle); btnRunTexturePacker.addListener(runListenerTexture); stage.addActor(btnRunTexturePacker); TeePrintStream tee = new TeePrintStream(System.out); System.setOut(tee); chkSource(); layout(); }
@Override public void render() { Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); fpsLabel.setText("fps: " + Gdx.graphics.getFramesPerSecond()); stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); }
public void update(float dt) { timeCount += dt; if (timeCount >= 1) { if (worldTimer > 0) { worldTimer--; } else { timeUp = true; } countdownLabel.setText(String.format("%03d", worldTimer)); timeCount = 0; } }
private void updateGameTime(float delta) { time += delta; int seconds = (int) (time) % 60; int minutes = (int) ((time / 60) % 60); String t = null; if (seconds < 10) t = "0" + String.valueOf(seconds); else t = String.valueOf(seconds); gameTime.setText(String.valueOf(minutes) + ":" + t); if (time > 200 && stars == 1) dropStar(star1); if (time > 8 && stars == 2) dropStar(star2); if (time > 6 && stars == 3) dropStar(star3); }
private void updateFreeze() { freezers = LevelData.freezers; freezes.setText(String.valueOf(freezers)); imgFreeze.addAction( Actions.sequence( Actions.scaleTo(0f, 0f), Actions.alpha(1f), Actions.parallel( Actions.rotateBy(360f, 0.7f), Actions.scaleTo(1f, 1f, 0.5f), Actions.alpha(0f, 1.0f, Interpolation.circleIn)))); }