Add ExtendedSimplePositionWidget and MultiTabWrapperWidget #35
@@ -20,7 +20,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java: [ '17' ]
|
java: [ '21' ]
|
||||||
os: [ ubuntu-latest ]
|
os: [ ubuntu-latest ]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
@@ -32,7 +32,7 @@ jobs:
|
|||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
distribution: 'oracle'
|
distribution: 'temurin'
|
||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
@@ -51,7 +51,7 @@ jobs:
|
|||||||
deploy:
|
deploy:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java: [ '17' ]
|
java: [ '21' ]
|
||||||
os: [ ubuntu-latest ]
|
os: [ ubuntu-latest ]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
if: ${{ gitea.ref == 'refs/heads/master' && gitea.event_name == 'push' }}
|
if: ${{ gitea.ref == 'refs/heads/master' && gitea.event_name == 'push' }}
|
||||||
@@ -65,7 +65,7 @@ jobs:
|
|||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
distribution: 'oracle'
|
distribution: 'temurin'
|
||||||
- name: make gradle wrapper executable
|
- name: make gradle wrapper executable
|
||||||
if: ${{ runner.os != 'Windows' }}
|
if: ${{ runner.os != 'Windows' }}
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
4
Core/build.gradle
Normal file
4
Core/build.gradle
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
loom {
|
||||||
|
accessWidenerPath = file("src/main/resources/core.accesswidener")
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package fr.altarik.toolbox.core.client.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.widget.Positioner;
|
||||||
|
import net.minecraft.client.gui.widget.SimplePositioningWidget;
|
||||||
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public abstract class ExtendedSimplePositionWidget extends SimplePositioningWidget {
|
||||||
|
|
||||||
|
private final List<Element> elements = new ArrayList<>();
|
||||||
|
|
||||||
|
public ExtendedSimplePositionWidget(int x, int y, int width, int height) {
|
||||||
|
super(x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends Widget> T add(T widget, Positioner positioner) {
|
||||||
|
this.elements.add(new Element(widget, positioner));
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends Widget> void remove(T widget) {
|
||||||
|
this.elements.remove(new Element(widget, this.copyPositioner()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachElement(Consumer<Widget> consumer) {
|
||||||
|
this.elements.forEach((element) -> consumer.accept(element.widget));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package fr.altarik.toolbox.core.client.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
|
import net.minecraft.client.gui.widget.WrapperWidget;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public abstract class MultiTabWrapperWidget<A extends Enum<A>, B extends Widget> extends WrapperWidget {
|
||||||
|
|
||||||
|
protected final Screen parent;
|
||||||
|
protected A currentTab;
|
||||||
|
|
||||||
|
public MultiTabWrapperWidget(Screen parent) {
|
||||||
|
this(parent, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MultiTabWrapperWidget(Screen parent, int x, int y, int width, int height) {
|
||||||
|
super(x, y, width, height);
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setCurrentTab(A currentTab) {
|
||||||
|
this.currentTab = currentTab;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract B getCurrentTab();
|
||||||
|
|
||||||
|
public abstract void update();
|
||||||
|
|
||||||
|
public abstract void remove();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachElement(Consumer<Widget> consumer) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
4
Core/src/main/resources/core.accesswidener
Normal file
4
Core/src/main/resources/core.accesswidener
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
accessWidener v2 named
|
||||||
|
|
||||||
|
accessible class net/minecraft/client/gui/widget/SimplePositioningWidget$Element
|
||||||
|
accessible method net/minecraft/client/gui/widget/SimplePositioningWidget$Element <init> (Lnet/minecraft/client/gui/widget/Widget;Lnet/minecraft/client/gui/widget/Positioner;)V
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.postgresql:postgresql:42.6.0'
|
implementation 'org.postgresql:postgresql:42.7.5'
|
||||||
testImplementation 'com.google.code.gson:gson:2.10'
|
testImplementation 'com.google.code.gson:gson:2.10'
|
||||||
implementation project(':Core')
|
implementation project(':Core')
|
||||||
// implementation "org.hibernate.orm:hibernate-core:${project.hibernate_version}"
|
// implementation "org.hibernate.orm:hibernate-core:${project.hibernate_version}"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import fr.altarik.CreateTag
|
|||||||
import fr.altarik.ReportDiscord
|
import fr.altarik.ReportDiscord
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.9-SNAPSHOT' apply false
|
id 'fabric-loom' version "${loom_version}" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
Properties local = new Properties()
|
Properties local = new Properties()
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ fabric.loom.multiProjectOptimisation=true
|
|||||||
junit_version=5.9.0
|
junit_version=5.9.0
|
||||||
minecraft_version=1.20.4
|
minecraft_version=1.20.4
|
||||||
yarn_mappings=1.20.4+build.3
|
yarn_mappings=1.20.4+build.3
|
||||||
loader_version=0.16.9
|
loader_version=0.17.2
|
||||||
fabric_version=0.97.2+1.20.4
|
fabric_version=0.97.3+1.20.4
|
||||||
hibernate_version=6.6.3.Final
|
hibernate_version=6.6.3.Final
|
||||||
|
loom_version=1.11-SNAPSHOT
|
||||||
|
|
||||||
maven_group=fr.altarik.toolbox
|
maven_group=fr.altarik.toolbox
|
||||||
maven_version=5.1.1
|
maven_version=5.2.0-SNAPSHOT
|
||||||
|
|
||||||
git_owner=quentinlegot
|
git_owner=quentinlegot
|
||||||
git_repo=Toolbox
|
git_repo=Toolbox
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
Reference in New Issue
Block a user