void disableChoices() {
   btnSubmit.setVisible(false);
   vaBid.setVisible(false);
   lblConfirmation.setVisible(true);
   btnYes.setVisible(true);
   btnNo.setVisible(true);
 }
 void enableChoices() {
   currentBid = 0;
   btnSubmit.setVisible(true);
   vaBid.setVisible(true);
   lblConfirmation.setVisible(false);
   btnYes.setVisible(false);
   btnNo.setVisible(false);
 }
 void disableGUI() {
   btnSubmit.setVisible(false);
   vaBid.setVisible(false);
   btnYes.setVisible(false);
   btnNo.setVisible(false);
   lblConfirmation.setPosition((gcw / 2) - lblConfirmation.getWidth() / 2, fixed_y + 350);
   lblConfirmation.setText("You bid " + currentBid + ".\nWaiting for " + otherPlayer.getName());
 }
 public void layout(Widget widget, boolean visible) {
   if (label != null) {
     if (label.getParent() != widget) {
       System.out.println("Adding widget Label");
       widget.add(label);
     }
     if (visible) {
       // adjust this to account for view location
       Vector2D labelLocation =
           Vector2D.subtract(
               getLocation(), -Main.viewLocation.x, (Main.viewLocation.y - Main.SCREEN_HEIGHT));
       //                Vector2D labelLocation = Vector2D.subtract( Main.viewLocation,
       // getLocation());
       label.setPosition((int) labelLocation.x, (int) labelLocation.y);
       label.setText(name);
       label.adjustSize();
     }
     label.setVisible(visible);
   }
 }
  @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)));
  }
  @Override
  public void enter(GameContainer gc, StateBasedGame sbg) throws SlickException {
    super.enter(gc, sbg);
    client = HRRUClient.conn.getClient();
    rootPane.removeAllChildren();
    itemPanel.removeAllChildren();

    end = false;
    finished = false;
    resume = false;
    ready = false;
    otherPlayerReady = 0;
    currentBid = 0;
    amountWon = 0;
    maximumBid = 0;
    clock2 = 0;
    clock3 = 0;
    timer = 60;
    timer2 = 999;
    overallTimer = 0;
    otherPlayerBid = 0;
    otherPlayerWon = 0;
    winCheck = false;

    start_message = "";
    full_start_message = "MAKE YOUR BID...";
    full_start_counter = 0;
    ticker = "";
    tickerBoolean = true;
    winString = "Think carefully.";

    // Testing
    /*
    Character characters[] = (new CharacterSheet()).getCharacters();
    player1 = new Player("player1");
    player2 = new Player("player2");
    player1.setPlayerCharacterID(2);
    player1.setPlayerCharacter(characters[2]);
    player2.setPlayerCharacter(characters[4]);
    player2.setPlayerCharacterID(4);
    player1.setScore(5000);
    HRRUClient.cs.setState(6);
    HRRUClient.cs.setP1(player1);
    HRRUClient.cs.setP2(player2);
    HRRUClient.cs.setPlayer(1);
    */

    // Retrieve player information
    player1 = HRRUClient.cs.getP1();
    player2 = HRRUClient.cs.getP2();
    playerID = HRRUClient.cs.getPlayer();
    if (playerID == 1) {
      player = player1;
      otherPlayer = player2;
      otherPlayerID = 2;
      maximumBid = player.getScore();
    } else {
      player = player2;
      otherPlayer = player1;
      otherPlayerID = 1;
      maximumBid = player.getScore();
    }

    // setup description
    descriptionModel.setHtml(
        "<html><body><div><p style='text-align: center;'>"
            + "You and "
            + otherPlayer.getName()
            + " are both "
            + "<a style='font-family: name;'>bidding</a> for the item using your <a style='font-family: name;'>points</a>.</p>"
            + "<p style='margin-top: 10px; text-align: center;'>The player with the <a style='font-family: name;'>highest bid</a> wins the item for the <a style='font-family: name;'>cost of their winning bid.</a></p>"
            + "<p style='margin-top: 10px; text-align: center;'>The highest bidder will then win the <a style='font-family: name;'>value</a> of the item in <a style='font-family: name;'>points!</a></p>"
            + "</div></body></html>");

    // Setup new item variables
    item_id = HRRUClient.cs.getSecondary_id();
    currentItem = items[item_id];
    itemValue = HRRUClient.cs.getSecondary_value();

    itemPanel.setPosition(50, fixed_y);
    lblItemName = new Label(currentItem.getName());
    lblItemValue = new Label("" + itemValue);
    itemDescriptionModel.setText(currentItem.getDescription());
    lblItemName.setTheme("itematari16");
    lblItemValue.setTheme("itematari16");
    itemDescription.setTheme("questiontextarea");

    DialogLayout.Group hItemLabel = itemPanel.createSequentialGroup(lItemName);
    DialogLayout.Group hItemResult = itemPanel.createSequentialGroup(lblItemName);
    DialogLayout.Group hDescriptionLabel = itemPanel.createSequentialGroup(lDescription);
    DialogLayout.Group hDescriptionResult = itemPanel.createSequentialGroup(itemDescription);
    DialogLayout.Group hItemValueLabel = itemPanel.createSequentialGroup(lItemValue);
    DialogLayout.Group hItemValueResult = itemPanel.createSequentialGroup(lblItemValue);

    itemPanel.setHorizontalGroup(
        itemPanel
            .createParallelGroup()
            .addGroup(hItemLabel)
            .addGroup(hItemResult)
            .addGroup(hDescriptionLabel)
            .addGroup(hDescriptionResult)
            .addGroup(hItemValueLabel)
            .addGroup(hItemValueResult));

    itemPanel.setVerticalGroup(
        itemPanel
            .createSequentialGroup()
            .addWidget(lItemName)
            .addWidget(lblItemName)
            .addGap(30)
            .addWidget(lDescription)
            .addWidget(itemDescription)
            .addGap(60)
            .addWidget(lItemValue)
            .addWidget(lblItemValue));

    lblConfirmation.setPosition((gcw / 2) - lblConfirmation.getWidth() / 2, fixed_y + 320);
    // Setup bidding GUI
    vaBid.setMinMaxValue(0, maximumBid);
    vaBid.setValue(0);
    vaBid.setVisible(true);
    btnSubmit.setVisible(true);
    btnYes.setVisible(false);
    btnNo.setVisible(false);
    lblConfirmation.setVisible(false);
    p1ResultPanel.setVisible(false);
    p2ResultPanel.setVisible(false);
    description.setVisible(true);
    rootPane.add(description);
    rootPane.add(p1ResultPanel);
    rootPane.add(p2ResultPanel);
    rootPane.add(btnYes);
    rootPane.add(btnNo);
    rootPane.add(lblConfirmation);
    rootPane.add(btnSubmit);
    rootPane.add(vaBid);
    rootPane.add(itemPanel);
  }