Exemple #1
0
  private void buildHierarchy() {
    if (hList != null) hList.dispose();

    handlers.clear();
    hList = new Widget();
    hList.transform.x = 2;
    hList.transform.y = 32;
    hList.transform.width = 80;
    hList.transform.height = 86;

    final ElementList el = new ElementList();
    for (Widget w : guiEdit.toEdit.getDrawList()) {
      if (!w.disposed) hierarchyAdd(el, w);
    }
    hList.addComponent(el);
    hList.regEventHandler(
        new ProgressChangeHandler() {

          @Override
          public void handleEvent(Widget w, ProgressChangedEvent event) {
            double p = (double) el.getProgress() / el.getMaxProgress();
            VerticalDragBar.get(dragbar).setProgress(dragbar, p);
          }
        });

    addWidget(hList);
  }
Exemple #2
0
    public SingleWidget(Widget w) {
      transform.width = 80;
      transform.height = 12;

      hierLevel = w.getHierarchyLevel();
      target = w;
      regEventHandler(
          new FrameEventHandler() {
            @Override
            public void handleEvent(Widget w, FrameEvent event) {
              double r = 1, g = 1, b = 1;
              double brightness = event.hovering ? .5 : .3;
              if (target.isFocused()) {
                brightness *= 1.6;
                r = b = .6;
              }
              if (modified) {
                r = g = 1;
                b = 0;
              }
              GL11.glColor4d(r, g, b, brightness);
              HudUtils.colorRect(0, 0, w.transform.width, w.transform.height);
            }
          });

      regEventHandler(
          new MouseDownHandler() {
            @Override
            public void handleEvent(Widget w, MouseDownEvent event) {
              guiEdit.toEdit.gainFocus(target);
            }
          });

      {
        Widget eye = new Widget();
        eye.transform.setSize(10, 10).setPos(1, 1);
        eye.addComponent(new Tint());
        eye.addComponent(new DrawTexture().setTex(vis_on));
        eye.regEventHandler(
            new MouseDownHandler() {
              @Override
              public void handleEvent(Widget w, MouseDownEvent event) {
                on = !on;
                target.visible = on;
                DrawTexture.get(w).setTex(on ? vis_on : vis_off);
              }
            });
        addWidget(eye);
      }

      addWidget(new Name());
    }
    public void updateInfo() {

      Preset p = data.getPreset(id);
      byte[] pdata = (id == active && editor != null) ? editor.display : p.getData();

      for (int i = 0; i < 4; ++i) {
        Category cat = AbilityData.get(player).getCategory();
        Controllable c = cat.getControllable(pdata[i]);
        Widget main = widget.getWidget("" + i);
        DrawTexture.get(main.getWidget("icon")).texture =
            c == null ? Resources.TEX_EMPTY : c.getHintIcon();
        TextBox.get(main.getWidget("text")).content = c == null ? "" : c.getHintText();
      }
    }
  @GuiCallback("scroll_bar")
  public void onProgressChange(Widget w, DraggedEvent event) {
    VerticalDragBar vdb = VerticalDragBar.get(w);

    ElementList list = ElementList.get(pageMain.getWidget("area"));
    list.setProgress((int) (vdb.getProgress() * list.getMaxProgress()));
  }
Exemple #5
0
 private void hierarchyAdd(ElementList list, Widget w) {
   SingleWidget sw;
   list.addWidget(sw = new SingleWidget(w));
   handlers.put(w, sw);
   for (Widget ww : w.getDrawList()) {
     if (!ww.disposed) hierarchyAdd(list, ww);
   }
 }
 private Widget createCopy() {
   Widget ret = template.copy();
   for (Widget w : ret.getDrawList()) {
     for (Widget w2 : w.getDrawList()) w2.regEventHandlerAtBegin(new AlphaAssign());
   }
   return ret;
 }
  private void init() {
    foreground.addWidget(loaded.getWidget("background").copy());
    transitor.addWidget(loaded.getWidget("background").copy());

    // Build the pages
    for (int i = 0; i < 4; ++i) {
      Widget normal = createCopy();
      TextBox.get(normal.getWidget("title")).setContent(local("tag") + (i + 1));

      for (int j = 0; j < 4; ++j) {
        normal.getWidget("" + j).addComponent(new HintHandler(j));
      }
      normal.addComponent(new ForegroundPage(i));
      add(i, foreground, normal);
    }

    for (int i = 0; i < 4; ++i) {
      Widget back = createCopy();
      TextBox.get(back.getWidget("title")).setContent(local("tag") + (i + 1));

      back.addComponent(new TransitPage(i));
      add(i, transitor, back);
    }

    resetAll();
  }
  private Widget createMedia(Media media) {
    Widget ret = loaded.getWidget("t_one").copy();
    DrawTexture.get(ret.getWidget("icon")).texture = media.cover;
    TextBox.get(ret.getWidget("title")).content = media.getDisplayName();
    TextBox.get(ret.getWidget("desc")).content = media.getDesc();
    TextBox.get(ret.getWidget("time")).content = media.getLengthStr();

    ret.regEventHandler(
        MouseDownEvent.class,
        (Widget w, MouseDownEvent event) -> {
          if (w.isFocused()) {
            player.startPlay(media);
            gui.postEvent(new UpdateMediaEvent());
          }
        });

    return ret;
  }
 @Override
 public void handleEvent(Widget w, FrameEvent event) {
   double masterAlpha = getPage(w.getWidgetParent().getWidgetParent()).alpha;
   DrawTexture dt = DrawTexture.get(w);
   if (dt != null) {
     dt.color.a = masterAlpha;
   } else {
     TextBox.get(w).color.a = masterAlpha;
   }
 }
Exemple #10
0
  private Widget setupButton(int count, final String name, final String desc) {
    final double size = 10;
    Widget w = new Widget();
    final Tint tint = new Tint();
    w.addComponent(tint);
    w.addComponent(new DrawTexture().setTex(GuiEdit.tex(name)));
    w.transform.setSize(size, size).setPos(2 + count * 12, 11);
    w.regEventHandler(
        new FrameEventHandler() {
          @Override
          public void handleEvent(Widget w, FrameEvent event) {
            Widget target = getAccessTarget();
            tint.enabled = target != null && target.visible;

            if (event.hovering) {
              Font.font.draw(desc, size / 2, size, 10, 0xffffff, Align.CENTER);
            }
          }
        });

    addWidget(w);
    return w;
  }
  private void init() {
    pageMain = loaded.getWidget("back").copy();

    List<Media> installedMedias = data.getInstalledMediaList();

    player.updatePlayerMedias(installedMedias);

    {
      Widget area = pageMain.getWidget("area");
      ElementList list = new ElementList();

      for (Media m : installedMedias) {
        list.addWidget(createMedia(m));
      }

      area.addComponent(list);
    }

    EventLoader.load(pageMain, this);
    gui.addWidget(pageMain);

    gui.postEvent(new UpdateMediaEvent());
  }
Exemple #12
0
  private void addButtons() {
    Widget tmp;

    tmp = setupButton(0, "arrow_left", CGUILang.butDechild());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().moveLeft();
              buildHierarchy();
            }
          }
        });

    tmp = setupButton(1, "arrow_right", CGUILang.butChild());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().moveRight();
              buildHierarchy();
            }
          }
        });

    tmp = setupButton(2, "arrow_up", CGUILang.butMoveUp());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().moveUp();
              buildHierarchy();
            }
          }
        });

    tmp = setupButton(3, "arrow_down", CGUILang.butMoveDown());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().moveDown();
              buildHierarchy();
            }
          }
        });

    //		tmp = setupButton(4, "rename", CGUILang.butRename());
    //		tmp.regEventHandler(new MouseDownHandler() {
    //			@Override
    //			public void handleEvent(Widget w, MouseDownEvent event) {
    //				if(getAccessTarget() != null) {
    //					TextBox box = handlers.get(getAccessTarget()).box;
    //					box.allowEdit = true;
    //					handlers.get(getAccessTarget()).transform.doesListenKey = true;
    //					System.out.println("Rename callback");
    //				}
    //			}
    //		});

    tmp = setupButton(4, "remove", CGUILang.butRemove());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().dispose();
              buildHierarchy();
            }
          }
        });

    tmp = setupButton(5, "duplicate", CGUILang.butDuplicate());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().getAbstractParent().addWidget(getAccessTarget().copy());
              buildHierarchy();
            }
          }
        });

    tmp = setupButton(6, "up", "Move Up");
    tmp.transform.setPos(90, 30);
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (hList != null) {
              ElementList list = ElementList.get(hList);
              list.progressLast();
            }
          }
        });

    tmp = setupButton(7, "down", "Move Down");
    tmp.transform.setPos(90, 110);
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (hList != null) {
              ElementList list = ElementList.get(hList);
              list.progressNext();
            }
          }
        });

    {
      tmp = new Widget();
      tmp.transform.setSize(10, 10);
      tmp.transform.setPos(90, 40);

      final VerticalDragBar bar = new VerticalDragBar();
      bar.setArea(40, 100);
      tmp.addComponent(bar);

      DrawTexture dt = new DrawTexture().setTex(null).setColor4i(200, 200, 255, 200);
      tmp.addComponent(dt);

      tmp.regEventHandler(
          new DraggedHandler() {
            @Override
            public void handleEvent(Widget w, DraggedEvent event) {
              double p = bar.getProgress();
              if (hList != null) {
                ElementList list = ElementList.get(hList);
                list.setProgress((int) Math.round(p * list.getMaxProgress()));
              }
            }
          });

      addWidget(tmp);
      dragbar = tmp;
    }
  }
    public Selector(int _keyid) {
      keyid = _keyid;

      AbilityData aData = AbilityData.get(player);
      Category c = aData.getCategory();

      for (Skill s : aData.getControllableSkillList()) {
        int cid = s.getControlID();
        if (!editor.hasMapping(cid)) {
          available.add(s);
        }
      }

      List<SelectionProvider> providers = new ArrayList();
      providers.add(
          new SelectionProvider(
              -1, Resources.getTexture("guis/preset_settings/cancel"), local("skill_remove")));
      for (Skill s : available)
        providers.add(new SelectionProvider(s.getControlID(), s.getHintIcon(), s.getDisplayName()));

      height = MARGIN * 2 + SIZE + STEP * (ldiv(providers.size(), MAX_PER_ROW) - 1);
      width =
          available.size() < MAX_PER_ROW
              ? MARGIN * 2 + SIZE + STEP * (providers.size() - 1)
              : MARGIN * 2 + SIZE + STEP * (MAX_PER_ROW - 1);

      transform.setSize(width, height);

      // Build the window and the widget
      regEventHandler(
          new FrameEventHandler() {

            @Override
            public void handleEvent(Widget w, FrameEvent event) {
              CRL_WHITE.bind();
              ACRenderingHelper.drawGlow(0, 0, width, height, 1, CRL_WHITE);

              CRL_BACK.bind();
              HudUtils.colorRect(0, 0, width, height);

              String str;
              Widget hovering = foreground.getHoveringWidget();
              if (hovering != null && hovering.getName().contains("_sel")) {
                SelHandler sh = hovering.getComponent("_sel");
                str = sh.selection.hint;
              } else {
                str = local("skill_select");
              }

              double len = Font.font.strLen(str, 9);
              CRL_BACK.bind();
              HudUtils.colorRect(0, -13.5, len + 6, 11.5);
              ACRenderingHelper.drawGlow(0, -13.5, len + 6, 11.5, 1, CRL_GLOW);

              Font.font.draw(str, 3, -12, 9, 0xbbbbbb);

              GL11.glColor4d(1, 1, 1, 1);
            }
          });

      // Build all the skills that can be set
      for (int i = 0; i < providers.size(); ++i) {
        int row = i / MAX_PER_ROW, col = i % MAX_PER_ROW;
        SelectionProvider selection = providers.get(i);
        Widget single = new Widget();
        single.transform.setPos(MARGIN + col * STEP, MARGIN + row * STEP);
        single.transform.setSize(SIZE, SIZE);

        DrawTexture tex = new DrawTexture().setTex(selection.texture);
        single.addComponent(tex);
        single.addComponent(new Tint());
        single.addComponent(new SelHandler(selection));
        addWidget("_sel" + i, single);
      }
    }
 static Page getPage(Widget w) {
   return w.getComponent("Page");
 }
 private void updatePopState() {
   System.out.println(player.isPlaying());
   DrawTexture.get(pageMain.getWidget("pop")).texture =
       (player.isPlaying() && !player.isPaused()) ? T_PAUSE : T_PLAY;
 }