aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'mod/src/main/java')
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/CategoryItem.java11
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/GUIOpenItem.java10
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainConfigWidget.java12
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainPageWidget.java8
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MenuItem.java10
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/DomElement.java17
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/layouter/SingleChildPassingLayouter.java3
7 files changed, 64 insertions, 7 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/CategoryItem.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/CategoryItem.java
index 5a2c6f6c..fe0b2578 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/CategoryItem.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/CategoryItem.java
@@ -29,6 +29,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation;
+import java.io.IOException;
import java.util.function.Supplier;
public class CategoryItem extends AnnotatedImportOnlyWidget {
@@ -37,6 +38,8 @@ public class CategoryItem extends AnnotatedImportOnlyWidget {
public final BindableAttribute<String> name = new BindableAttribute<>(String.class);
@Bind(variableName = "description")
public final BindableAttribute<String> description = new BindableAttribute<>(String.class);
+ @Bind(variableName = "icon")
+ public final BindableAttribute<String> icon = new BindableAttribute<>(String.class, "dungeonsguide:textures/dglogox128.png");
private Supplier<Widget> pageCreator;
public CategoryItem(Supplier<Widget> pageCreator, String category, String description) {
@@ -45,6 +48,14 @@ public class CategoryItem extends AnnotatedImportOnlyWidget {
this.name.setValue(category);
this.description.setValue(description);
+ try {
+ String target = "dungeonsguide:textures/config/categoryIcon/"+category.toLowerCase()
+ .replace("&","").replace(" ","_")+".png";
+ if (Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(target)) != null)
+ icon.setValue(target);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
@On(functionName = "click")
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/GUIOpenItem.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/GUIOpenItem.java
index da65f8c6..a99b1cc4 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/GUIOpenItem.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/GUIOpenItem.java
@@ -31,6 +31,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation;
+import java.io.IOException;
import java.util.function.Supplier;
public class GUIOpenItem extends AnnotatedImportOnlyWidget {
@@ -46,7 +47,14 @@ public class GUIOpenItem extends AnnotatedImportOnlyWidget {
this.pageCreator = creator;
bindableAttribute.setValue(category);
- image.setValue("dungeonsguide:textures/config/"+category+".png");
+
+ image.setValue("dungeonsguide:textures/dglogox128.png");
+ try {
+ String target = "dungeonsguide:textures/config/categoryIcon/"+category.toLowerCase()
+ .replace("&","").replace(" ","_")+".png";
+ if (Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(target)) != null)
+ image.setValue(target);
+ } catch (IOException e) {}
}
@On(functionName = "click")
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainConfigWidget.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainConfigWidget.java
index aa25e2be..1dc6b5b9 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainConfigWidget.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainConfigWidget.java
@@ -47,6 +47,9 @@ public class MainConfigWidget extends AnnotatedImportOnlyWidget {
@Bind(variableName = "version")
public final BindableAttribute<String> version = new BindableAttribute<>(String.class, VersionInfo.VERSION);
+ @Bind(variableName = "sidebar")
+ public final BindableAttribute<String> sidebar = new BindableAttribute<>(String.class, "hide");
+
@Bind(variableName = "mainpage")
public final BindableAttribute<Widget> mainPage = new BindableAttribute<>(Widget.class, new MainPageWidget());
public MainConfigWidget() {
@@ -68,4 +71,13 @@ public class MainConfigWidget extends AnnotatedImportOnlyWidget {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
Navigator.getNavigator(getDomElement()).goBack();
}
+
+ @On(functionName = "toggleSidebar")
+ public void toggle() {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ if ("show".equals(this.sidebar.getValue()))
+ this.sidebar.setValue("hide");
+ else
+ this.sidebar.setValue("show");
+ }
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainPageWidget.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainPageWidget.java
index 884ff5d6..cfbce59b 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainPageWidget.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainPageWidget.java
@@ -18,9 +18,12 @@
package kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3;
+import kr.syeyoung.dungeonsguide.mod.config.guiconfig.location2.HUDLocationConfig;
import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute;
+import kr.syeyoung.dungeonsguide.mod.guiv2.GuiScreenAdapter;
import kr.syeyoung.dungeonsguide.mod.guiv2.Widget;
+import kr.syeyoung.dungeonsguide.mod.guiv2.elements.GlobalHUDScale;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedImportOnlyWidget;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind;
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On;
@@ -54,6 +57,11 @@ public class MainPageWidget extends AnnotatedImportOnlyWidget {
.collect(Collectors.toList());
}
+ @On(functionName = "guiconfig")
+ public void guiConfig() {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ Minecraft.getMinecraft().displayGuiScreen(new GuiScreenAdapter(new GlobalHUDScale(new HUDLocationConfig(null)), Minecraft.getMinecraft().currentScreen));
+ }
@On(functionName = "discord")
public void discord() {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MenuItem.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MenuItem.java
index e88c9e43..af87d15e 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MenuItem.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MenuItem.java
@@ -28,12 +28,13 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.util.ResourceLocation;
+import java.io.IOException;
import java.util.function.Supplier;
public class MenuItem extends AnnotatedImportOnlyWidget {
@Bind(variableName = "image")
- public final BindableAttribute<String> image = new BindableAttribute<>(String.class);
+ public final BindableAttribute<String> image = new BindableAttribute<>(String.class,"dungeonsguide:textures/dglogox128.png");
@Bind(variableName = "category")
public final BindableAttribute<String> bindableAttribute = new BindableAttribute<>(String.class);
@@ -43,7 +44,12 @@ public class MenuItem extends AnnotatedImportOnlyWidget {
this.pageCreator = creator;
bindableAttribute.setValue(category);
- image.setValue("dungeonsguide:textures/config/"+category+".png");
+ try {
+ String target = "dungeonsguide:textures/config/categoryIcon/"+category.toLowerCase()
+ .replace("&","").replace(" ","_")+".png";
+ if (Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(target)) != null)
+ image.setValue(target);
+ } catch (IOException e) {}
}
@On(functionName = "click")
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/DomElement.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/DomElement.java
index f35536be..3cf21e77 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/DomElement.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/DomElement.java
@@ -42,6 +42,17 @@ public class DomElement {
@Getter
@Setter(AccessLevel.PACKAGE)
private Renderer renderer = DrawNothingRenderer.INSTANCE; // renders element itself.
+
+ public Renderer getRenderer() {
+ if (layoutReq) {
+ layoutReq = false;
+ layouter.layout(this, new ConstraintBox(
+ size.getWidth(), size.getWidth(), size.getHeight(), size.getHeight()
+ ));
+ }
+ return renderer;
+ }
+
@Getter
@Setter(AccessLevel.PACKAGE)
private Layouter layouter = NullLayouter.INSTANCE; // layouts subelements
@@ -104,11 +115,11 @@ public class DomElement {
if (parent != null)
parent.requestRelayout();
}
+
+ private boolean layoutReq = false;
public void requestRelayout() {
if (layouter.canCutRequest() && size != null) {
- layouter.layout(this, new ConstraintBox(
- size.getWidth(), size.getWidth(), size.getHeight(), size.getHeight()
- ));
+ layoutReq = true;
return;
}
if (parent != null)
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/layouter/SingleChildPassingLayouter.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/layouter/SingleChildPassingLayouter.java
index 80075d19..a58173cf 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/layouter/SingleChildPassingLayouter.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/layouter/SingleChildPassingLayouter.java
@@ -30,7 +30,8 @@ public class SingleChildPassingLayouter implements Layouter {
@Override
public Size layout(DomElement buildContext, ConstraintBox constraintBox) {
if (buildContext.getChildren().isEmpty()) {
- return new Size(constraintBox.getMaxWidth(), constraintBox.getMaxHeight());
+ return new Size(constraintBox.getMaxWidth() == Double.POSITIVE_INFINITY ? 0 : constraintBox.getMaxWidth(),
+ constraintBox.getMaxHeight() == Double.POSITIVE_INFINITY ? 0 : constraintBox.getMaxHeight());
}
DomElement childCtx = buildContext.getChildren().get(0);