コード例 #1
0
ファイル: GuiNewAbout.java プロジェクト: nallar/Spoutcraft
 @SuppressWarnings("unchecked")
 public void load(InputStream input) {
   Addon spoutcraft = Spoutcraft.getAddonManager().getAddon("Spoutcraft");
   scroll.removeWidgets(spoutcraft);
   try {
     Yaml yaml = new Yaml();
     HashMap<String, Object> root = (HashMap<String, Object>) yaml.load(input);
     if (root.containsKey("options")) {
       HashMap<String, Object> options = (HashMap<String, Object>) root.get("options");
       if (options.containsKey("section-margin")) {
         sectionMargin = (Integer) options.get("section-margin");
       }
       if (options.containsKey("column-margin")) {
         columnMargin = (Integer) options.get("column-margin");
       }
     }
     if (root.containsKey("columns")) {
       LinkedHashMap<String, Object> columns = (LinkedHashMap<String, Object>) root.get("columns");
       for (Object col : columns.values()) {
         System.out.println("Column");
         List<Section> sections = new LinkedList<Section>();
         LinkedHashMap<String, Object> secs = (LinkedHashMap<String, Object>) col;
         for (Object sec : secs.values()) {
           System.out.println("Section");
           LinkedHashMap<String, Object> section = (LinkedHashMap<String, Object>) sec;
           String title = "Untitled";
           if (section.containsKey("title")) {
             title = (String) section.get("title");
           }
           Set<String> keys = section.keySet();
           if (keys.size() > 2) {
             System.out.println("Too many keys");
             continue;
           }
           String sectionType = "";
           for (String key : keys) {
             if (!key.equals("title")) {
               sectionType = key;
             }
           }
           Section sectionObject = Section.getSection(sectionType);
           if (sectionObject == null) {
             System.out.println("type " + sectionType + " not found");
             continue;
           }
           sectionObject.init(this, title, section.get(sectionType));
           System.out.println(
               "Section " + title + " of type " + sectionObject.getClass().getSimpleName());
           scroll.attachWidgets(spoutcraft, sectionObject.getWidgets().toArray(new Widget[0]));
           sections.add(sectionObject);
         }
         this.columns.add(sections);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     layoutWidgets();
   }
 }
コード例 #2
0
  public void initGui() {
    Addon spoutcraft = Spoutcraft.getAddonManager().getAddon("Spoutcraft");
    recordLabel = new GenericLabel("Key:");
    recordLabel.setAlign(WidgetAnchor.TOP_LEFT);
    recordLabel.setWidth(50).setHeight(20);
    recordLabel.setX(10).setY(40);
    getScreen().attachWidget(spoutcraft, recordLabel);

    recordButton = new GenericButton();
    recordButton.setAlign(WidgetAnchor.CENTER_CENTER);
    recordButton.setHeight(20).setWidth(100);
    recordButton.setX(44).setY(33);
    getScreen().attachWidget(spoutcraft, recordButton);
    updateRecordButton();

    titleLabel = new GenericLabel("Name:");
    titleLabel.setAlign(WidgetAnchor.TOP_LEFT);
    titleLabel.setWidth(50).setHeight(20);
    titleLabel.setX(10).setY(10);
    getScreen().attachWidget(spoutcraft, titleLabel);

    commandText = new GenericTextField();
    commandText.setHeight(16).setWidth(355);
    commandText.setX(45).setY(8);
    commandText.setText(item.getTitle());
    commandText.setFocus(true);
    commandText.setMaximumCharacters(99);
    getScreen().attachWidget(spoutcraft, commandText);

    slot = new GuiCommandsSlot(this);
    getScreen().attachWidget(spoutcraft, slot);

    doneButton = new GenericButton("Done");
    doneButton.setHeight(20).setWidth(50);
    doneButton.setX(10).setY(height - 30);
    getScreen().attachWidget(spoutcraft, doneButton);

    addButton = new GenericButton("Add Command");
    addButton.setHeight(20).setWidth(100);
    addButton.setX(70).setY(height - 30);
    getScreen().attachWidget(spoutcraft, addButton);

    editButton = new GenericButton("Edit Command");
    editButton.setHeight(20).setWidth(100);
    editButton.setX(180).setY(height - 30);
    getScreen().attachWidget(spoutcraft, editButton);

    removeButton = new GenericButton("Remove Command");
    removeButton.setHeight(20).setWidth(100);
    removeButton.setX(290).setY(height - 30);
    getScreen().attachWidget(spoutcraft, removeButton);

    updateButtons();
  }
コード例 #3
0
ファイル: GuiNewAbout.java プロジェクト: nallar/Spoutcraft
  @Override
  protected void createInstances() {
    title = new GenericLabel("About");
    buttonDone = new GenericButton("Main Menu");
    scroll = new GenericScrollArea();

    Addon spoutcraft = Spoutcraft.getAddonManager().getAddon("Spoutcraft");
    getScreen().attachWidgets(spoutcraft, title, buttonDone, scroll);

    Thread load =
        new Thread() {
          @Override
          public void run() {
            try {
              load((new URL("http://get.spout.org/about.yml")).openStream());
            } catch (MalformedURLException e) {
              e.printStackTrace();
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        };
    load.start();
  }
コード例 #4
0
 public GenericScreen() {
   screenWidth = Spoutcraft.getClient().getRenderDelegate().getScreenWidth();
   screenHeight = Spoutcraft.getClient().getRenderDelegate().getScreenHeight();
   spoutcraft = Spoutcraft.getAddonManager().getAddon("Spoutcraft");
 }