/** Empty constructor for externalization. */ public PlayerOptions() { waveCounter = new GenericTexture(); waveCounter.setVisible(false); waveCounter.setDrawAlphaChannel(true); waveCounter.setUrl("http://i.imgur.com/fWiJl.png"); waveCounter.setWidth(125); waveCounter.setHeight(125); waveCounter.setAnchor(WidgetAnchor.TOP_RIGHT); waveCounter.shiftXPos(-85); waveCounter.shiftYPos(-35); waveCounter.setPriority(RenderPriority.High); waveCounterWave = new GenericLabel("Wave: 0"); waveCounterWave.setVisible(false); waveCounterWave.setAnchor(WidgetAnchor.TOP_RIGHT); waveCounterWave.setAlign(WidgetAnchor.CENTER_CENTER); waveCounterWave.shiftXPos(-35); waveCounterWave.shiftYPos(37); waveCounterWave.setTextColor(new Color(150, 0, 10)); waveCounterWave.setHeight(10); waveCounterWave.setWidth(10); waveCounterZombies = new GenericLabel("0"); waveCounterZombies.setVisible(false); waveCounterZombies.setAnchor(WidgetAnchor.TOP_RIGHT); waveCounterZombies.setAlign(WidgetAnchor.CENTER_CENTER); waveCounterZombies.shiftXPos(-40); waveCounterZombies.shiftYPos(18); waveCounterZombies.setTextColor(new Color(150, 0, 10)); waveCounterZombies.setScale(2); waveCounterZombies.setHeight(20); waveCounterZombies.setWidth(20); }
private void doOwnerList( FPlayer player, SpoutPlayer sPlayer, FLocation here, Faction factionHere) { // ---------- // Owner list // ---------- if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0 && Conf.spoutTerritoryOwnersShow && Conf.ownedAreasEnabled) { GenericLabel label; if (ownerLabels.containsKey(player.getName())) label = ownerLabels.get(player.getName()); else { label = new GenericLabel(); label .setWidth(1) .setHeight(1); // prevent Spout's questionable new "no default size" warning label.setScale(Conf.spoutTerritoryDisplaySize); label.setY((int) (10 * Conf.spoutTerritoryDisplaySize)); sPlayer.getMainScreen().attachWidget(P.p, label); ownerLabels.put(player.getName(), label); } String msg = ""; if (player.getFaction() == factionHere) { msg = factionHere.getOwnerListString(here); if (!msg.isEmpty()) msg = Conf.ownedLandMessage + msg; } label.setText(msg); alignLabel(label, msg); label.setDirty(true); } }
private void addCredit() { GenericLabel label = new GenericLabel( "AmbientSpout Free v" + AmbientSpout.callback.getDescription().getVersion() + " - By Rahazan."); label.setTextColor(new Color(0.4F, 0.4F, 0.4F)); label.setAnchor(WidgetAnchor.TOP_LEFT); label.setWidth(180).setHeight(6); label.shiftXPos(1).shiftYPos(1); this.attachWidget(AmbientSpout.callback, label); }
public static void open( Plugin plugin, SpoutPlayer splayer) { // method used to open the GUI for a player GenericTexture face = new GenericTexture(); int width = splayer.getCurrentScreen().getWidth(); int height = splayer.getCurrentScreen().getHeight(); face.setUrl( "http://landoflegend.net/forums/images/CoderGreen/site_logo.png"); // this must be a png // image face.setWidth(splayer.getCurrentScreen().getWidth() / 8) .setHeight( splayer.getCurrentScreen().getHeight() / 8); // you can manipulate the size of most widgets // face.setAnchor(WidgetAnchor.CENTER_CENTER); // the enum type WidgetAnchor provides a // convenience method for placing widgets face.setX(width / 2 - face.getWidth() / 2); face.setY(height - face.getHeight() - 5); // GenericButton button = new GenericButton("The Drogans?!"); // button.setWidth(80); // button.setHeight(20); // button.setX(width/4); // button.setY(height/2); // button.setAnchor(WidgetAnchor.CENTER_LEFT); GenericListWidget scrollTry = new GenericListWidget(); ListWidgetItem item = new ListWidgetItem("Drogans", "Drogans"); scrollTry.addItem(item); scrollTry.setX(width / 4); scrollTry.setY(height / 2); GenericLabel label = new GenericLabel("Clans - First try"); // label.setAnchor(WidgetAnchor.CENTER_RIGHT); label.setWidth(80); label.setHeight(40); label.setScale(1); label.setX(width / 2 - label.getWidth() / 2); label.setY(20); GenericPopup popup = new GenericPopup(); // create the popup (A popup will "free the mouse") popup.attachWidget(plugin, face); // attach any widgets we want to the popup popup.attachWidget(plugin, scrollTry); popup.attachWidget(plugin, label); // button.set splayer.closeActiveWindow(); splayer.getMainScreen().attachPopupScreen(popup); // attach the popup to the players screen }
public MainGUI(Player p) { this.p = p; nextSongButton = new GenericButton("Music On"); // The first button. nextSongButton.setAnchor( WidgetAnchor .CENTER_CENTER); // We are "sticking" it from the center_center, from there we will be // shifting. nextSongButton.setWidth(90).setHeight(20); // Setting the width and height of the button. nextSongButton.shiftXPos(-90 / 2).shiftYPos(-nextSongButton.getHeight() / 2 + 5); stopMusicButton = new GenericButton("Music Off"); // The second button. stopMusicButton.setAnchor(WidgetAnchor.CENTER_CENTER); stopMusicButton.setWidth(90).setHeight(20); // stopMusicButton.shiftXPos(0).shiftYPos(stopMusicButton.getHeight()/2); stopMusicButton.shiftXPos(-90 / 2).shiftYPos((int) (stopMusicButton.getHeight() * 1.1)); if (Settings.useBackgroundImage) addBackground(); currentSongLabel = new GenericLabel(""); currentSongLabel.setAnchor(WidgetAnchor.CENTER_CENTER); currentSongLabel.setWidth(200).setHeight(10); currentSongLabel.shiftXPos(-50).shiftYPos(50); currentSongLabel.setTextColor(new Color(200, 200, 200)); if (Settings.showCurrentSong) this.attachWidget(AmbientSpout.callback, currentSongLabel); if (!AmbientSpout.callback.getConfig().getBoolean("Settings.Donation", false)) addCredit(); if (Model.playerMusicEnabled.containsKey(p.getName())) { if (Model.playerMusicEnabled.get(p.getName())) { nextSongButton.setText("Next Song"); updateCurrentSong(); } else { stopMusicButton.setVisible(false); } } if (p.hasPermission("ambientspout.admin") || p.isOp()) { // System.out.println("Adding EffectLoopButton"); //TODO DebugOnly addEffectLoopButton(); } this.attachWidget(AmbientSpout.callback, nextSongButton); this.attachWidget(AmbientSpout.callback, stopMusicButton); }
private void doLabels(FPlayer player, SpoutPlayer sPlayer, boolean notify) { FLocation here = player.getLastStoodAt(); Faction factionHere = Board.getFactionAt(here); String tag = factionHere.getColorTo(player).toString() + factionHere.getTag(); // ---------------------- // Main territory display // ---------------------- if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0) { GenericLabel label; if (territoryLabels.containsKey(player.getName())) label = territoryLabels.get(player.getName()); else { label = new GenericLabel(); label .setWidth(1) .setHeight(1); // prevent Spout's questionable new "no default size" warning label.setScale(Conf.spoutTerritoryDisplaySize); sPlayer.getMainScreen().attachWidget(P.p, label); territoryLabels.put(player.getName(), label); } String msg = tag; if (Conf.spoutTerritoryDisplayShowDescription && !factionHere.getDescription().isEmpty()) msg += " - " + factionHere.getDescription(); label.setText(msg); alignLabel(label, msg); label.setDirty(true); } // ----------------------- // Fading territory notice // ----------------------- if (notify && Conf.spoutTerritoryNoticeShow && Conf.spoutTerritoryNoticeSize > 0) { NoticeLabel label; if (territoryChangeLabels.containsKey(player.getName())) label = territoryChangeLabels.get(player.getName()); else { label = new NoticeLabel(Conf.spoutTerritoryNoticeLeaveAfterSeconds); label .setWidth(1) .setHeight(1); // prevent Spout's questionable new "no default size" warning label.setScale(Conf.spoutTerritoryNoticeSize); label.setY(Conf.spoutTerritoryNoticeTop); sPlayer.getMainScreen().attachWidget(P.p, label); territoryChangeLabels.put(player.getName(), label); } String msg = tag; if (Conf.spoutTerritoryNoticeShowDescription && !factionHere.getDescription().isEmpty()) msg += " - " + factionHere.getDescription(); label.setText(msg); alignLabel(label, msg, 2); label.resetNotice(); label.setDirty(true); } // and owner list, of course doOwnerList(player, sPlayer, here, factionHere); }
public Tree(MMOSkillTree plugin, GenericPopup popup, SpoutPlayer sPlayer, SkillSet skillSet) { this.plugin = plugin; skillTreePopup = popup; Player p = (Player) sPlayer; // System.out.println("tree skillSet:"+skillSet); SkillsPlayer mmoPlayer = MMOSkillTree.mmoPlayerManager.get(p); Set set = mmoPlayer.getSet(skillSet); label = new GenericLabel("You probably wish this did something, but it doesn't yet."); label.setAnchor(WidgetAnchor.TOP_CENTER); label.setWidth(168).setHeight(10).setX(-90).setY(10); label.setScale(0.7F); skillTreePopup.attachWidget(plugin, label); infoBox = new GenericContainer(); infoBox.setLayout(ContainerType.VERTICAL); infoBox.setWidth(50).setHeight(230); infoBox.setAnchor(WidgetAnchor.TOP_CENTER); infoBox.setAlign(WidgetAnchor.TOP_CENTER); infoBox.setX(-150).setY(11); skillTreePopup.attachWidget(plugin, infoBox); GenericLabel infoLabel = new GenericLabel( set.string + " Skills\n\n" + "Exp:" + set.getCurLvlXp() + "/" + set.getNextLvlXp() + "\n\n" + "Skill Points:" + set.skillPoints); infoLabel.setScale(0.5F); infoLabel.setMargin(5); infoBox.addChild(infoLabel); box = new GenericContainer(); box.setLayout(ContainerType.VERTICAL); box.setAnchor(WidgetAnchor.TOP_CENTER); box.setWidth(168) .setHeight( 210); // This is taller than it should be so the top skills align right to the top, and // bottom ones to the bottom, instead of having a big gap box.setX(-84).setY(30); box.setPriority(RenderPriority.High); box.setAuto(true); swordSkills = new Sword(); for (Entry<String, TreeSkill> entry : swordSkills.map.entrySet()) { // String key = entry.getKey(); TreeSkill skill = entry.getValue(); int row = skill.getRow(); int col = skill.getCol(); skills[row][col] = skill; } for (int row = 0; row < numRows; row++) { Container rowBox = new GenericContainer(); rowBox.setLayout(ContainerType.HORIZONTAL); rowBox.setWidth(300).setHeight(38); for (int col = 0; col < numCols; col++) { if (skills[row][col] == null) { skills[row][col] = new TreeSkill(); } TreeSkill skill = skills[row][col]; skillSlots[row][col] = new SkillSlot(rowBox).setName(skill.getName()).setType(skill.getType()); } box.addChild(rowBox); } for (int row = 0; row < numRows; row++) { for (int col = 0; col < numCols; col++) { SkillSlot skillSlot = skillSlots[row][col]; TreeSkill skill = skills[row][col]; String[] children = skill.getChildren(); for (int i = 0; i < children.length; i++) { TreeSkill childSkill = swordSkills.getSkill(children[i]); // System.out.println(skill.getName() + " has child " + childSkill.getName()); int childRow = childSkill.getRow(); int childCol = childSkill.getCol(); // System.out.println( "childRow:"+childRow + " row:"+row ); // System.out.println( "childCol:"+childCol + " col:"+col ); if (childCol == col && childRow == row + 1) { skillSlot.arrowToB(); } if (childCol == col + 1 && childRow == row) { skillSlot.arrowToR(); } if (childCol == col - 1 && childRow == row) { // System.out.println(skill.getName() +" to left to "+ childSkill.getName()); skillSlot.arrowToL(); } if (childCol == col + 1 && childRow == row + 1) { skillSlot.arrowToBR(); } if (childCol == col - 1 && childRow == row + 1) { skillSlot.arrowToBL(); } int botIterations = childRow - row; int rightIterations = childCol - col; if (botIterations > 1) { for (int ii = 0; ii <= botIterations; ii++) { // System.out.println("longL botIterations:"+botIterations + " ii:"+ii); SkillSlot lowerSkillSlot = skillSlots[ii][col]; if (ii < botIterations) { lowerSkillSlot.arrowToLongB(); } else { lowerSkillSlot.arrowToB(); } } } if (rightIterations > 1) { for (int ii = 0; ii <= botIterations; ii++) { SkillSlot lowerSkillSlot = skillSlots[ii][col]; if (ii < rightIterations) { lowerSkillSlot.arrowToLongR(); } else { lowerSkillSlot.arrowToR(); } } } if (rightIterations > -1) { for (int ii = 0; ii >= botIterations; ii--) { SkillSlot lowerSkillSlot = skillSlots[ii][col]; if (ii > rightIterations) { lowerSkillSlot.arrowToLongL(); } else { lowerSkillSlot.arrowToL(); } } } } } } skillTreePopup.attachWidget(plugin, box); }
public void openTabScreen() { tabHeader = new GenericTexture("http://i.imgur.com/t8CPF.png"); tabHeader.setDrawAlphaChannel(true); tabHeader.setAnchor(WidgetAnchor.CENTER_CENTER); tabHeader.setWidth(212); tabHeader.setHeight(8); tabHeader.shiftYPos(-100); tabHeader.shiftXPos(tabHeader.getWidth() / -2 + 20); @SuppressWarnings({"unchecked", "rawtypes"}) List<PlayerStats> sortedStats = new ArrayList(ZArena.getInstance().getGameHandler().getPlayerStats().values()); Collections.sort(sortedStats); int index = 0; for (PlayerStats stats : sortedStats) { GenericTexture part = new GenericTexture("http://i.imgur.com/qvrX8.png"); part.setDrawAlphaChannel(true); part.setAnchor(WidgetAnchor.CENTER_CENTER); part.setWidth(255); part.setHeight(15); part.shiftYPos(-90 + index * 15); part.shiftXPos(part.getWidth() / -2); part.setPriority(RenderPriority.Low); tabMain.add(part); Player player = stats.getPlayer(); GenericLabel name = new GenericLabel(player.getName()); name.setAnchor(WidgetAnchor.CENTER_CENTER); name.setAlign(WidgetAnchor.TOP_CENTER); name.setHeight(11); name.setWidth(10); name.shiftYPos(-86 + index * 15); name.shiftXPos(-75); GenericLabel kills = new GenericLabel(stats.getKills() + ""); kills.setAnchor(WidgetAnchor.CENTER_CENTER); kills.setAlign(WidgetAnchor.TOP_CENTER); kills.setHeight(11); kills.setWidth(10); kills.shiftYPos(-86 + index * 15); GenericLabel money = new GenericLabel("$" + stats.getMoney()); money.setAnchor(WidgetAnchor.CENTER_CENTER); money.setAlign(WidgetAnchor.TOP_CENTER); money.setHeight(11); money.setWidth(10); money.shiftYPos(-86 + index * 15); money.shiftXPos(50); GenericLabel health = new GenericLabel((stats.isAlive()) ? player.getHealth() + "" : "DEAD"); health.setTextColor( (!stats.isAlive()) ? new Color(150, 0, 0) : (player.getHealth() > 15) ? new Color(0, 200, 0) : (player.getHealth() > 10) ? new Color(255, 255, 0) : (player.getHealth() > 5) ? new Color(255, 140, 0) : new Color(200, 0, 0)); health.setAnchor(WidgetAnchor.CENTER_CENTER); health.setAlign(WidgetAnchor.TOP_CENTER); health.setHeight(11); health.setWidth(10); health.shiftYPos(-86 + index * 15); health.shiftXPos(100); tabText.add(name); tabText.add(money); tabText.add(kills); tabText.add(health); index++; } ((SpoutPlayer) Bukkit.getPlayer(player)) .getMainScreen() .attachWidget(ZArena.getInstance(), tabHeader); for (GenericTexture part : tabMain) { ((SpoutPlayer) Bukkit.getPlayer(player)) .getMainScreen() .attachWidget(ZArena.getInstance(), part); } for (GenericLabel text : tabText) { ((SpoutPlayer) Bukkit.getPlayer(player)) .getMainScreen() .attachWidget(ZArena.getInstance(), text); } }