/** * Create a new CreatureDetailsWindow displaying details for the specified Creature. * * @param creature the Creature to show details for */ public CreatureDetailsWindow(Creature creature) { this.creature = creature; creature.addViewer(this); this.setSize(280, 300); this.setTitle("Details for " + creature.getTemplate().getName()); DialogLayout layout = new DialogLayout(); layout.setTheme("content"); this.add(layout); // set up the widgets for the top row Widget viewer = new Viewer(); viewer.setTheme("iconviewer"); Label title = new Label(creature.getTemplate().getName()); title.setTheme("titlelabel"); DialogLayout.Group topRowV = layout.createParallelGroup(viewer, title); DialogLayout.Group topRowH = layout.createSequentialGroup(viewer); topRowH.addGap(10); topRowH.addWidget(title); topRowH.addGap(10); // create widgets for details text area textAreaModel = new HTMLTextAreaModel(); TextArea textArea = new TextArea(textAreaModel); ScrollPane textPane = new ScrollPane(textArea); textPane.setFixed(ScrollPane.Fixed.HORIZONTAL); textPane.setTheme("detailspane"); // set the main top level layout Group mainGroupV = layout.createSequentialGroup(); mainGroupV.addGroup(topRowV); mainGroupV.addGap(5); mainGroupV.addWidget(textPane); Group mainGroupH = layout.createParallelGroup(); mainGroupH.addGroup(topRowH); mainGroupH.addWidget(textPane); layout.setHorizontalGroup(mainGroupH); layout.setVerticalGroup(mainGroupV); entityUpdated(creature); }
public EntityListMenu(Engine engine) { super(); setTitle("EntityMenu"); tree = new Tree(); tsm = new TreeDragNodeEntity(tree.getTable()); tsm.addActionListener(this); tree.setTreeSelectionManager(tsm); entity_tree = new DialogLayout(); entity_tree.setTheme("entitymenu"); property_editor = new ScrollPane(); property_editor.setTheme("propertymenu"); split_pane = new SplitPane(); split_pane.setDirection(SplitPane.Direction.VERTICAL); split_pane.setTheme("splitpane"); split_pane.add(entity_tree); split_pane.add(property_editor); this.add(split_pane); setEngine(engine); resourceMenuInit(); engine.getEntityList().addActionListener(this); }
public Alert(String text) { setTheme("/resizableframe"); final HTMLTextAreaModel textAreaModel = new HTMLTextAreaModel(text); textArea = new TextArea(textAreaModel); scrollPane = new ScrollPane(textArea); scrollPane.setFixed(ScrollPane.Fixed.HORIZONTAL); DialogLayout layout = new DialogLayout(); buttonGroupH = layout.createSequentialGroup(); buttonGroupH.addGap(); buttonGroupV = layout.createParallelGroup(); layout.setTheme("/alertbox"); layout.setHorizontalGroup( layout.createParallelGroup().addWidget(scrollPane).addGroup(buttonGroupH)); layout.setVerticalGroup( layout.createSequentialGroup().addWidget(scrollPane).addGroup(buttonGroupV)); add(layout); }
@Override public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException { clock2 += delta; clock3 += delta; timer2 -= delta; overallTimer += delta; gameState = HRRUClient.cs.getState(); // Connection to server lost if (gameState == serverlost) sbg.enterState(0); // Connection to other player lost if (gameState == cancelled) { if (playerID == 1) sbg.enterState(1); else sbg.enterState(2); } // Check if other player is finished if (otherPlayerID == 1) otherPlayerReady = HRRUClient.cs.getP1().getReady(); else otherPlayerReady = HRRUClient.cs.getP2().getReady(); if (clock3 > 100) { if (full_start_counter < full_start_message.length()) { start_message += full_start_message.substring(full_start_counter, full_start_counter + 1); full_start_counter++; clock3 -= 100; } } if (end == false) { if (clock2 > 999) { timer--; timer2 = 999; if (timer <= 0) { disableGUI(); end = true; playerBid = new Packet16SendBid(); playerBid.player = playerID; playerBid.bid = currentBid; playerBid.itemValue = itemValue; playerBid.sessionID = HRRUClient.cs.getSessionID(); client.sendTCP(playerBid); } clock2 -= 1000; if (tickerBoolean) { ticker = "|"; tickerBoolean = false; } else { ticker = ""; tickerBoolean = true; } } } if (end && !finished) { if (clock2 > 999) { timer--; timer2 = 999; clock2 -= 1000; if (tickerBoolean) { ticker = "|"; tickerBoolean = false; } else { ticker = ""; tickerBoolean = true; } } if (otherPlayerReady == 2) { // Setup new UI timer = 10; // should be 10 timer2 = 999; clock2 = 0; clock3 = 0; lblConfirmation.setVisible(false); description.setVisible(false); full_start_message = "The results are in..."; full_start_counter = 0; ticker = ""; start_message = ""; tickerBoolean = true; itemPanel.setPosition(50, 100); p1ResultPanel.setVisible(true); p2ResultPanel.setVisible(true); lblBid.setText("0"); lblBid2.setText("0"); lblAmountWon.setText("0"); lblAmountWon2.setText("0"); p1ResultPanel.setTheme("incorrectbid-panel"); p2ResultPanel.setTheme("incorrectbid-panel"); p1ResultPanel.reapplyTheme(); p2ResultPanel.reapplyTheme(); // Setup players results if (playerID == 1) { // results view when player 1 BiddingScore biddingScore = HRRUClient.cs.getP1().getCurrentBiddingScore(); otherPlayerBid = biddingScore.getOtherPlayerBid(); winCheck = biddingScore.isWin(); playerWon = biddingScore.getPlayerWon(); amountWon = biddingScore.getAmountWon(); winString = "No one won the item!"; if (winCheck) { winString = "You won " + amountWon + " points!"; p1ResultPanel.setTheme("correctbid-panel"); p2ResultPanel.setTheme("incorrectbid-panel"); lblBid.setText("" + currentBid); lblBid2.setText("" + otherPlayerBid); lblAmountWon.setText("" + amountWon); lblAmountWon2.setText("0"); p1ResultPanel.reapplyTheme(); p2ResultPanel.reapplyTheme(); } else if (!winCheck && otherPlayerBid != 0) { winString = otherPlayer.getName() + " wins " + amountWon + "!"; p1ResultPanel.setTheme("incorrectbid-panel"); p2ResultPanel.setTheme("correctbid-panel"); lblBid.setText("" + currentBid); lblBid2.setText("" + otherPlayerBid); lblAmountWon.setText("0"); lblAmountWon2.setText("" + amountWon); p1ResultPanel.reapplyTheme(); p2ResultPanel.reapplyTheme(); } finished = true; } else { // results view when player 2 BiddingScore biddingScore = HRRUClient.cs.getP2().getCurrentBiddingScore(); otherPlayerBid = biddingScore.getOtherPlayerBid(); winCheck = biddingScore.isWin(); playerWon = biddingScore.getPlayerWon(); amountWon = biddingScore.getAmountWon(); winString = "No one won the item!"; if (winCheck) { winString = "You won " + amountWon + "!"; p1ResultPanel.setTheme("incorrectbid-panel"); p2ResultPanel.setTheme("correctbid-panel"); lblBid2.setText("" + currentBid); lblBid.setText("" + otherPlayerBid); lblAmountWon2.setText("" + amountWon); lblAmountWon.setText("0"); p1ResultPanel.reapplyTheme(); p2ResultPanel.reapplyTheme(); } else if (!winCheck && otherPlayerBid != 0) { winString = otherPlayer.getName() + " wins " + amountWon + "!"; p1ResultPanel.setTheme("correctbid-panel"); p2ResultPanel.setTheme("incorrectbid-panel"); lblBid2.setText("" + currentBid); lblBid.setText("" + otherPlayerBid); lblAmountWon2.setText("0"); lblAmountWon.setText("" + amountWon); p1ResultPanel.reapplyTheme(); p2ResultPanel.reapplyTheme(); } finished = true; } } else if (otherPlayerReady == 0) { lblConfirmation.setText( "You bid " + currentBid + ".\nWaiting for " + otherPlayer.getName()); } } else if (finished) { if (clock2 > 999) { timer--; timer2 = 999; clock2 -= 1000; if (timer <= 0) { if (winCheck) { if (playerID == 1) HRRUClient.cs.getP1().addScore(amountWon); else HRRUClient.cs.getP2().addScore(amountWon); biddingResult = new BiddingScore( item_id, itemValue, currentBid, otherPlayerBid, playerWon, amountWon, winCheck); } else { if (playerID == 1) HRRUClient.cs.getP2().addScore(amountWon); else HRRUClient.cs.getP1().addScore(amountWon); biddingResult = new BiddingScore( item_id, itemValue, currentBid, otherPlayerBid, playerWon, 0, winCheck); } if (playerID == 1) HRRUClient.cs.getP1().addBiddingScore(biddingResult); else HRRUClient.cs.getP2().addBiddingScore(biddingResult); syncMessage = new Packet00SyncMessage(); syncMessage.player = playerID; syncMessage.sessionID = HRRUClient.cs.getSessionID(); client.sendTCP(syncMessage); finished = false; resume = true; } } } if (resume) { if (HRRUClient.cs.isSync()) { HRRUClient.cs.updateTimer(overallTimer); System.out.println("Time Subtract" + (overallTimer)); HRRUClient.cs.setSync(false); HRRUClient.cs.setState(p1_turn); sbg.enterState(play, new FadeOutTransition(), new FadeInTransition()); } } }
@Override public void init(GameContainer gc, StateBasedGame sbg) throws SlickException { gcw = gc.getWidth(); gch = gc.getHeight(); rotateTransition = new RotateTransition(); selectTransition = new SelectTransition(); emptyTransition = new EmptyTransition(); // Set up images scorebackground = new Image("simple/playerscorebackground.png"); background = new Image("simple/questionbg.png"); // Set up item lists itemList = new ItemList(); items = itemList.getItems(); // Set up item panel itemPanel = new DialogLayout(); itemPanel.setTheme("item-panel"); itemPanel.setSize(400, 220); itemPanel.setPosition(50, fixed_y); itemDescriptionModel = new SimpleTextAreaModel(); itemDescription = new TextArea(itemDescriptionModel); descriptionModel = new HTMLTextAreaModel(); description = new TextArea(descriptionModel); description.setTheme("trusttextarea"); description.setPosition(10, 110); description.setSize(780, 100); lItemName = new Label("Name: "); lDescription = new Label("Description: "); lItemValue = new Label("Value: "); lItemName.setTheme("questionatari16lbl"); lDescription.setTheme("questionatari16lbl"); lItemValue.setTheme("questionatari16lbl"); // Set up fonts // Create custom font for question try { loadFont = java.awt.Font.createFont( java.awt.Font.TRUETYPE_FONT, org.newdawn.slick.util.ResourceLoader.getResourceAsStream("font/visitor2.ttf")); } catch (FontFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } loadTitleFont = loadFont.deriveFont(Font.BOLD, titleFontSize); titleFont = new BasicFont(loadTitleFont); loadMainFont = loadFont.deriveFont(Font.BOLD, mainFontSize); mainFont = new BasicFont(loadMainFont); readyFont = new BasicFont(loadTitleFont, Color.red); loadTimerFont = loadFont.deriveFont(Font.BOLD, timerFontSize); loadTimerMFont = loadFont.deriveFont(Font.BOLD, timerMFontSize); timerFont = new BasicFont(loadTimerFont); timerMFont = new BasicFont(loadTimerMFont); // Confirmation GUI lblConfirmation = new Label(""); btnYes = new Button("Yes"); btnNo = new Button("No"); lblConfirmation.setTheme("labelscoretotal"); btnYes.setTheme("choicebutton"); btnNo.setTheme("choicebutton"); lblConfirmation.setPosition((gcw / 2) - lblConfirmation.getWidth() / 2, fixed_y + 320); btnYes.setPosition((gcw / 2) - 152, fixed_y + 340); btnNo.setPosition((gcw / 2) - 152, fixed_y + 370); btnYes.setSize(300, 25); btnNo.setSize(300, 25); btnYes.addCallback( new Runnable() { public void run() { emulateYes(); } }); btnNo.addCallback( new Runnable() { public void run() { enableChoices(); } }); // Bid GUI vaBid = new ValueAdjusterInt(); vaBid.setSize(200, 30); vaBid.setPosition((gcw / 2) - vaBid.getWidth() / 2, fixed_y + 320); btnSubmit = new Button("Submit Bid"); btnSubmit.setSize(200, 30); btnSubmit.setPosition((gcw / 2) - btnSubmit.getWidth() / 2 - 2, fixed_y + 360); btnSubmit.setTheme("choicebutton"); btnSubmit.addCallback( new Runnable() { public void run() { emulateChoice(); } }); // Results GUI p1ResultPanel = new DialogLayout(); p1ResultPanel.setTheme("incorrectbid-panel"); p1ResultPanel.setSize(300, 80); p1ResultPanel.setPosition((gcw / 2 - p1ResultPanel.getWidth() / 2 - 200), 420); p2ResultPanel = new DialogLayout(); p2ResultPanel.setTheme("incorrectbid-panel"); p2ResultPanel.setSize(300, 80); p2ResultPanel.setPosition((gcw / 2 - p2ResultPanel.getWidth() / 2 + 160), 420); lBid = new Label("Bid:"); lBid2 = new Label("Bid: "); lAmountWon = new Label("Amount Won: "); lblAmountWon = new Label(""); lblBid = new Label(""); lblBid2 = new Label(""); lAmountWon2 = new Label("Amount Won: "); lblAmountWon2 = new Label(""); lblBid.setTheme("labelscoretotalright"); lblBid2.setTheme("labelscoretotalright"); lblAmountWon.setTheme("labelscoretotalright"); lblAmountWon2.setTheme("labelscoretotalright"); DialogLayout.Group hLeftLabel1 = p1ResultPanel.createParallelGroup(lBid, lAmountWon); DialogLayout.Group hRightResult1 = p1ResultPanel.createParallelGroup(lblBid, lblAmountWon); p1ResultPanel.setHorizontalGroup( p1ResultPanel .createParallelGroup() .addGap(120) .addGroup(p1ResultPanel.createSequentialGroup(hLeftLabel1, hRightResult1))); p1ResultPanel.setVerticalGroup( p1ResultPanel .createSequentialGroup() .addGap(30) .addGroup(p1ResultPanel.createParallelGroup(lBid, lblBid)) .addGroup(p1ResultPanel.createParallelGroup(lAmountWon, lblAmountWon))); DialogLayout.Group hLeftLabel2 = p2ResultPanel.createParallelGroup(lBid2, lAmountWon2); DialogLayout.Group hRightResult2 = p2ResultPanel.createParallelGroup(lblBid2, lblAmountWon2); p2ResultPanel.setHorizontalGroup( p2ResultPanel .createParallelGroup() .addGroup(p2ResultPanel.createSequentialGroup(hLeftLabel2, hRightResult2))); p2ResultPanel.setVerticalGroup( p2ResultPanel .createSequentialGroup() .addGap(30) .addGroup(p2ResultPanel.createParallelGroup(lBid2, lblBid2)) .addGroup(p2ResultPanel.createParallelGroup(lAmountWon2, lblAmountWon2))); }
@SuppressWarnings("unchecked") public void createPropertyMenu() { if (ent != null) { DialogLayout dialog_layout = new DialogLayout(); dialog_layout.setTheme("dialoglayout"); dialog_layout.setHorizontalGroup(dialog_layout.createParallelGroup()); dialog_layout.setVerticalGroup(dialog_layout.createSequentialGroup()); Widget field; CollapsiblePanel cp; for (String prop : Entity.reqKeys) { if (ent.getProperty(prop).getClass() == float.class || ent.getProperty(prop).getClass() == Float.class) { field = new ValueAdjusterFloat(); ((ValueAdjusterFloat) field).setModel(new FloatModelWithEntCallbacks(0, 100, ent, prop)); ((ValueAdjusterInt) field).setTheme("valueadjuster"); } else if (ent.getProperty(prop).getClass() == int.class || ent.getProperty(prop).getClass() == Integer.class) { field = new ValueAdjusterInt(); ((ValueAdjusterInt) field).setModel(new IntegerModelWithEntCallbacks(0, 100, ent, prop)); ((ValueAdjusterInt) field).setTheme("valueadjuster"); } else if (ent.getProperty(prop).getClass() == String.class) { field = new EditField(); ((EditField) field).setModel(new StringModelWithEntCallbacks(ent, prop)); ((EditField) field).setTheme("editfield"); ((EditField) field).setForwardUnhandledKeysToCallback(true); ((EditField) field) .addCallback( new Callback() { @Override public void callback(int key) { createEntityList(); } }); } else if (ent.getProperty(prop).getClass() == boolean.class || ent.getProperty(prop).getClass() == Boolean.class) { field = new ToggleButton(); ((ToggleButton) field).setModel(new BooleanModelWithEntCallbacks(ent, prop)); ((ToggleButton) field).setTheme("togglebutton"); } else if (ent.getProperty(prop).getClass() == Vector3f.class) { field = new XYZAdjuster(prop); ((XYZAdjuster) field).setValue((Vector3f) ent.getProperty(prop)); ((XYZAdjuster) field).setTheme("xyzadjuster"); } else if (ent.getProperty(prop).getClass() == Vector4f.class) { field = new RGBAAdjuster(prop); ((RGBAAdjuster) field).setValue((Vector4f) ent.getProperty(prop)); ((RGBAAdjuster) field).setTheme("rgbaadjuster"); } else if (ent.getProperty(prop).getClass() == engine.render.Model.class) { field = new ComboBox<String>(); for (ResourceItem item : engine.resource_manager.getResourcesInCategory("models")) { ((ComboBox<String>) field).addItem(item.name); } ((ComboBox<String>) field).setTheme("combobox"); } else if (ent.getProperty(prop).getClass() == HashMap.class) { field = new ComboBox<String>(); for (String item : ((HashMap<String, Object>) ent.getProperty(prop)).keySet()) { ((ComboBox<String>) field).addItem(item); } ((ComboBox<String>) field).setTheme("combobox"); } else { field = new Label(); ((Label) field).setText((String) ent.getProperty(prop)); ((Label) field).setTheme("label"); } cp = new CollapsiblePanel(Direction.VERTICAL, prop, field, new SimpleBooleanModel()); cp.setTheme("collapsiblepanel"); dialog_layout.getHorizontalGroup().addWidget(cp); dialog_layout.getVerticalGroup().addWidget(cp); } property_editor.setContent(dialog_layout); } }