SHARE
TWEET

windowTestGui.java

MaineQat Nov 29th, 2014 25 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.minecolonies.client.gui;
  2.  
  3. import com.blockout.Pane;
  4. import com.blockout.controls.Button;
  5. import com.blockout.controls.Label;
  6. import com.blockout.views.ScrollingList;
  7. import com.blockout.views.Window;
  8. import com.minecolonies.MineColonies;
  9. import com.minecolonies.colony.CitizenData;
  10. import com.minecolonies.lib.Constants;
  11. import com.minecolonies.network.messages.OpenInventoryMessage;
  12. import com.minecolonies.util.LanguageHandler;
  13.  
  14. public class GuiTestWindow extends Window implements Button.Handler
  15. {
  16.     private static String INVENTORY_BUTTON_ID = "inventory";
  17.  
  18.     private CitizenData.View citizen;
  19.  
  20.     public GuiTestWindow(CitizenData.View citizen)
  21.     {
  22.         super(Constants.MODID + ":" + "gui/windowTestGUI.xml");
  23.         this.citizen = citizen;
  24.     }
  25.  
  26.     public void onOpened()
  27.     {
  28.         try
  29.         {
  30.             findPaneOfTypeByID("strength", Label.class).setLabel(LanguageHandler.format("com.minecolonies.gui.citizen.skills.strength", citizen.strength));
  31.             findPaneOfTypeByID("stamina", Label.class).setLabel(LanguageHandler.format("com.minecolonies.gui.citizen.skills.stamina", citizen.stamina));
  32.             findPaneOfTypeByID("wisdom", Label.class).setLabel(LanguageHandler.format("com.minecolonies.gui.citizen.skills.wisdom", citizen.wisdom));
  33.             //findPaneOfTypeByID("intelligence", Label.class).setLabel(LanguageHandler.format("com.minecolonies.gui.citizen.skills.intelligence", citizen.intelligence));
  34.             //findPaneOfTypeByID("charisma", Label.class).setLabel(LanguageHandler.format("com.minecolonies.gui.citizen.skills.charisma", citizen.charisma));
  35.  
  36.             findPaneOfTypeByID("scrollgroup", ScrollingList.class).setDataProvider(
  37.                 new ScrollingList.DataProvider() {
  38.                     @Override
  39.                     public int getElementCount() { return 20; }
  40.  
  41.                     @Override
  42.                     public void updateElement(int index, Pane pane)
  43.                     {
  44.                         pane.findPaneOfTypeByID("listlabel", Label.class).setLabel(String.format("#%d", index));
  45.                         ScrollingList scrollList = pane.findPaneOfTypeByID("scrollgroup2", ScrollingList.class);
  46.                         if (scrollList != null)
  47.                         {
  48.                             scrollList.setDataProvider(
  49.                                 new ScrollingList.DataProvider() {
  50.                                     @Override
  51.                                     public int getElementCount() { return 5; }
  52.  
  53.                                     @Override
  54.                                     public void updateElement(int index2, Pane pane)
  55.                                     {
  56.                                         pane.findPaneOfTypeByID("listlabel2", Label.class).setLabel(String.format("%c", 'A' + index2));
  57.                                     }
  58.                                 });
  59.                         }
  60.                     }
  61.                 });
  62.         }
  63.         catch (NullPointerException exc) {}
  64.     }
  65.  
  66.     @Override
  67.     public void onButtonClicked(Button button)
  68.     {
  69.         if (button.getID().equals(INVENTORY_BUTTON_ID))
  70.         {
  71.             MineColonies.network.sendToServer(new OpenInventoryMessage(citizen));
  72.         }
  73.     }
  74. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top