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(); }
public void drawScreen(int mx, int my, float partialTicks) { LIGui.drawBlackout(); if (transiting) { updateTransit(); transitor.resize(width, height); transitor.draw(-1, -1); } else { updatePosForeground(); foreground.resize(width, height); foreground.draw(mx, my); } }
protected void mouseClicked(int mx, int my, int button) { if (button == 0) { if (!transiting) { foreground.mouseClicked(mx, my, button); } } }
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; }
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()); }
static { loaded = CGUIDocLoader.load(new ResourceLocation("academy:guis/preset_edit.xml")); template = loaded.getWidget("template"); }
private Widget get(LIGui gui, int i) { return gui.getWidget("" + i); }
private void add(int i, LIGui gui, Widget w) { gui.addWidget("" + i, w); }