Skip to content

Commit

Permalink
Gradle Changes and stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed Oct 9, 2024
1 parent 25af2e0 commit 70df427
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
path: build/libs/

- name: pre-release action
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@v2.0.8
with:
tag_name: "latest"
name: "DynamicHUD Pre-release"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public void initAfter() {

@Override
public AbstractMoveableScreen getMovableScreen() {
return new AbstractMoveableScreen(Text.literal("Editor Screen"), renderer) {
};
return new AbstractMoveableScreen(Text.literal("Editor Screen"), renderer) {};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.tanishisherewith.dynamichud.utils.contextmenu.Option;
import net.minecraft.client.gui.DrawContext;

public interface SkinRenderer<T extends Option<?>> {
public interface SkinRenderer<T extends Option<?>> {
void render(DrawContext drawContext, T option, int x, int y, int mouseX, int mouseY);

default boolean mouseClicked(T option, double mouseX, double mouseY, int button) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,27 +180,29 @@ public static void saveWidgets(File file, List<Widget> widgets) throws IOExcepti
public static void loadWidgets(File file) throws IOException {
widgets.clear();

if (file.exists() || (file = new File(file.getAbsolutePath() + ".backup")).exists()) {
if (!file.exists()) {
printWarn("Main file " + file.getAbsolutePath() + " was not found... Loading from a found backup file");
}
if (!file.exists()) {
DynamicHUD.logger.warn("Main file {} was not found... Loading from a found backup file", file.getAbsolutePath());
file = new File(file.getAbsolutePath() + ".backup");
}

NbtCompound rootTag = NbtIo.read(file.toPath());
NbtList widgetList = rootTag.getList("widgets", NbtType.COMPOUND);
if (widgetList == null) {
printWarn("RootTag or WidgetList is null. File is either empty or corrupted: " + file);
return;
}
for (int i = 0; i < widgetList.size(); i++) {
NbtCompound widgetTag = widgetList.getCompound(i);
WidgetData<?> widgetData = widgetDataMap.get(widgetTag.getString("name"));
Widget widget = widgetData.createWidget();
widget.readFromTag(widgetTag);
printInfo("Loaded Widget: " + widget);
widgets.add(widget);
}
} else {
printWarn("Widget File does not exist. Try saving one first");
NbtCompound rootTag = NbtIo.read(file.toPath());

if (rootTag == null) {
printWarn("RootTag is null. File is either empty or corrupted: " + file);
return;
}
NbtList widgetList = rootTag.getList("widgets", NbtType.COMPOUND);
if (widgetList == null) {
printWarn("WidgetList is null. File is empty: " + file);
return;
}
for (int i = 0; i < widgetList.size(); i++) {
NbtCompound widgetTag = widgetList.getCompound(i);
WidgetData<?> widgetData = widgetDataMap.get(widgetTag.getString("name"));
Widget widget = widgetData.createWidget();
widget.readFromTag(widgetTag);
printInfo("Loaded Widget: " + widget);
widgets.add(widget);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public WidgetRenderer(List<Widget> widgets) {
addScreen(ContextMenuScreen.class);
}

public WidgetRenderer(String modID) {
this(WidgetManager.getWidgetsForMod(modID));
}

public void addWidget(Widget widget) {
widgets.add(widget);
}
Expand Down

0 comments on commit 70df427

Please sign in to comment.