use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.
the class GuidePageEditorWidget method mouseClicked.
@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
if (super.mouseClicked(mouseX, mouseY, button)) {
return true;
}
boolean flag = false;
for (int i = fixed.size() - 1; i >= 0; i--) {
Widget widget = fixed.get(i);
if (widget.isMouseOverElement(mouseX, mouseY)) {
if (widget instanceof IGuideWidget && widget != selected) {
configEditor.loadConfigurator((IGuideWidget) widget);
selected = widget;
setToolButton(selected);
}
playButtonClickSound();
flag = true;
break;
}
}
if (!flag) {
for (Widget widget : stream) {
if (widget.isMouseOverElement(mouseX, mouseY)) {
if (widget instanceof IGuideWidget && widget != selected) {
configEditor.loadConfigurator((IGuideWidget) widget);
selected = widget;
setToolButton(selected);
}
playButtonClickSound();
flag = true;
break;
}
}
}
return flag;
}
use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.
the class GuidePageEditorWidget method onPosSizeChanged.
private void onPosSizeChanged(Position pos, Size size) {
Widget widget = customPositionSizeWidget.getControlled();
if (widget instanceof IGuideWidget && ((IGuideWidget) widget).isFixed()) {
JsonObject config = ((IGuideWidget) widget).getConfig();
if (config.has("x")) {
config.addProperty("x", pos.x + scrollXOffset);
((IGuideWidget) widget).updateValue("x");
}
if (config.has("y")) {
config.addProperty("y", pos.y + scrollYOffset);
((IGuideWidget) widget).updateValue("y");
}
if (config.has("width")) {
config.addProperty("width", size.width);
((IGuideWidget) widget).updateValue("width");
}
if (config.has("height")) {
config.addProperty("height", size.height);
((IGuideWidget) widget).updateValue("height");
}
((IGuideWidget) widget).onFixedPositionSizeChanged(pos, size);
}
toolButtons.setSelfPosition(new Position(pos.x + size.width / 2, pos.y));
}
use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.
the class GuidePageEditorWidget method getJsonConfig.
public JsonObject getJsonConfig() {
JsonObject json = new JsonObject();
json.addProperty("section", section);
json.addProperty("title", title.content.get(0));
JsonArray array = new JsonArray();
json.add("stream", array);
stream.forEach(widget -> {
if (widget instanceof IGuideWidget) {
array.add(((IGuideWidget) widget).getConfig());
}
});
JsonArray array2 = new JsonArray();
json.add("fixed", array2);
fixed.forEach(widget -> {
if (widget instanceof IGuideWidget) {
array2.add(((IGuideWidget) widget).getConfig());
}
});
return json;
}
use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.
the class GuideConfigEditor method mouseClicked.
@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
boolean flag = super.mouseClicked(mouseX, mouseY, button);
if (selectedTabIndex == 1 && widgetSelector != null) {
for (Widget widget : widgetSelector.widgets) {
if (widget.isMouseOverElement(mouseX, mouseY)) {
if (widget instanceof IGuideWidget) {
if (selected != null) {
selected.setStroke(0);
}
((IGuideWidget) widget).setStroke(0xFF7CA1FF);
selected = (IGuideWidget) widget;
}
playButtonClickSound();
return true;
}
}
}
return flag;
}
use of gregtech.common.terminal.app.guide.widget.IGuideWidget in project GregTech by GregTechCEu.
the class GuideConfigEditor method createWidgetSelector.
private DraggableScrollableWidgetGroup createWidgetSelector() {
DraggableScrollableWidgetGroup group = new DraggableScrollableWidgetGroup(0, 0, getSize().width, getSize().height - 10).setBackground(TerminalTheme.COLOR_B_3).setYScrollBarWidth(4).setYBarStyle(null, TerminalTheme.COLOR_F_1);
// 133
int y = 10;
for (Map.Entry<String, IGuideWidget> entry : GuidePageWidget.REGISTER_WIDGETS.entrySet()) {
IGuideWidget widgetTemplate = entry.getValue();
JsonObject template = widgetTemplate.getTemplate(false);
Widget guideWidget = widgetTemplate.updateOrCreateStreamWidget(5, y + 10, getSize().width - 14, template);
group.addWidget(new LabelWidget(getSize().width / 2 - 1, y - 3, entry.getKey(), -1).setXCentered(true).setShadow(true));
y += guideWidget.getSize().height + 25;
group.addWidget(guideWidget);
}
group.addWidget(new WidgetGroup(new Position(5, group.getWidgetBottomHeight() + 5), Size.ZERO));
return group;
}
Aggregations