Skip to content

Commit

Permalink
update speedrunigt
Browse files Browse the repository at this point in the history
  • Loading branch information
RedLime committed Jun 21, 2022
1 parent 2913dc7 commit b92e57a
Show file tree
Hide file tree
Showing 25 changed files with 167 additions and 100 deletions.
11 changes: 3 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//file:noinspection GroovyAssignabilityCheck
//file:noinspection GroovyAccessibility
plugins {
id 'fabric-loom' version '0.7-SNAPSHOT'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -18,12 +18,7 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven { url 'https://jitpack.io' }
}

configurations {
Expand Down Expand Up @@ -51,7 +46,7 @@ dependencies {
modIncludeImplementation(fabricApi.module("fabric-tool-attribute-api-v1", project.fabric_version))
//modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation "curse.maven:speedrunigt-538881:3538360"
modImplementation "com.github.RedLime:SpeedRunIGT:${project.minecraft_version}-SNAPSHOT"
}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ org.gradle.jvmargs=-Xmx1G


# Mod Properties
mod_version = 2.2.1+1.16.1
mod_version = 4.0+1.16.1
maven_group = com.redlimerl
archives_base_name = GhostRunner

Expand Down
37 changes: 4 additions & 33 deletions src/main/java/com/redlimerl/ghostrunner/GhostRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.redlimerl.ghostrunner.gui.screen.APIKeyScreen;
import com.redlimerl.ghostrunner.gui.screen.GhostRunnerInfoScreen;
import com.redlimerl.ghostrunner.gui.widget.OpacitySliderWidget;
import com.redlimerl.speedrunigt.option.SpeedRunOption;
import com.redlimerl.speedrunigt.option.SpeedRunOptions;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
Expand Down Expand Up @@ -94,46 +95,16 @@ public void onInitializeClient() {
KeyBinding ghostToggleKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("ghostrunner.title.toggle_ghost", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_P, "ghostrunner.title"));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (ghostToggleKey.wasPressed()) {
boolean option = !SpeedRunOptions.getOption(RunnerOptions.TOGGLE_GHOST);
SpeedRunOptions.setOption(RunnerOptions.TOGGLE_GHOST, option);
boolean option = !SpeedRunOption.getOption(RunnerOptions.TOGGLE_GHOST);
SpeedRunOption.setOption(RunnerOptions.TOGGLE_GHOST, option);
if (client.player != null) {
client.player.sendMessage(new LiteralText("[Ghost Runner] ").formatted(Formatting.BOLD).formatted(Formatting.AQUA)
.append(new TranslatableText("ghostrunner.message.toggle_ghost", new TranslatableText("addServer.resourcePack." + (option ? "enabled" : "disabled"))).formatted(Formatting.WHITE)), true);
}
}
});

SpeedRunOptions.addOptionButton(screen -> new OpacitySliderWidget());
SpeedRunOptions.addOptionButton(screen ->
new ButtonWidget(0, 0, 150, 20, new TranslatableText("ghostrunner.option.toggle_point_notification").append(": ").append(SpeedRunOptions.getOption(RunnerOptions.TOGGLE_CHECKPOINT_MESSAGE) ? ScreenTexts.ON : ScreenTexts.OFF), button -> {
SpeedRunOptions.setOption(RunnerOptions.TOGGLE_CHECKPOINT_MESSAGE, !SpeedRunOptions.getOption(RunnerOptions.TOGGLE_CHECKPOINT_MESSAGE));
button.setMessage(new TranslatableText("ghostrunner.option.toggle_point_notification").append(": ").append(SpeedRunOptions.getOption(RunnerOptions.TOGGLE_CHECKPOINT_MESSAGE) ? ScreenTexts.ON : ScreenTexts.OFF));
})
, new TranslatableText("ghostrunner.option.toggle_point_notification.context"));
SpeedRunOptions.addOptionButton(screen ->
new ButtonWidget(0, 0, 150, 20, new TranslatableText("ghostrunner.option.toggle_fsg_macro_mode").append(": ").append(SpeedRunOptions.getOption(RunnerOptions.TOGGLE_MACRO_FOR_FSG) ? ScreenTexts.ON : ScreenTexts.OFF), button -> {
SpeedRunOptions.setOption(RunnerOptions.TOGGLE_MACRO_FOR_FSG, !SpeedRunOptions.getOption(RunnerOptions.TOGGLE_MACRO_FOR_FSG));
button.setMessage(new TranslatableText("ghostrunner.option.toggle_fsg_macro_mode").append(": ").append(SpeedRunOptions.getOption(RunnerOptions.TOGGLE_MACRO_FOR_FSG) ? ScreenTexts.ON : ScreenTexts.OFF));
})
, new TranslatableText("ghostrunner.option.toggle_fsg_macro_mode.context"));
SpeedRunOptions.addOptionButton(screen ->
new ButtonWidget(0, 0, 150, 20, new TranslatableText("ghostrunner.menu.register_api_key"), button -> {
MinecraftClient client = MinecraftClient.getInstance();
if (client != null) client.openScreen(new APIKeyScreen(bool -> client.openScreen(screen)));
})
);
SpeedRunOptions.addOptionButton(screen ->
new ButtonWidget(0, 0, 150, 20, new TranslatableText("ghostrunner.menu.info"), button -> {
MinecraftClient client = MinecraftClient.getInstance();
if (client != null) client.openScreen(new GhostRunnerInfoScreen(screen));
})
);
SpeedRunOptions.addOptionButton(screen ->
new ButtonWidget(0, 0, 150, 20, new TranslatableText("options.controls"), button -> {
MinecraftClient client = MinecraftClient.getInstance();
if (client != null) client.openScreen(new ControlsOptionsScreen(screen, client.options));
})
);
UPDATE_STATUS.check();
}

public static void debug(Object obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.redlimerl.ghostrunner.GhostRunner;
import com.redlimerl.ghostrunner.gui.GenericToast;
import com.redlimerl.ghostrunner.util.Utils;
import com.redlimerl.speedrunigt.option.SpeedRunOption;
import com.redlimerl.speedrunigt.option.SpeedRunOptions;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.resource.language.I18n;
Expand Down Expand Up @@ -84,7 +85,7 @@ public String getLastVersion() {
public void popNotice() {
if (!isPopped && status == Status.OUTDATED) {
isPopped = true;
if (!SpeedRunOptions.getOption(RunnerOptions.UPDATE_NOTIFICATION)) return;
if (!SpeedRunOption.getOption(RunnerOptions.UPDATE_NOTIFICATION)) return;
MinecraftClient client = MinecraftClient.getInstance();
client.getToastManager().add(new GenericToast(I18n.translate("ghostrunner.message.update.found_new_update"), null, new ItemStack(Items.ANVIL)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.redlimerl.ghostrunner.gui.screen;

import com.redlimerl.ghostrunner.data.RunnerOptions;
import com.redlimerl.speedrunigt.option.SpeedRunOption;
import com.redlimerl.speedrunigt.option.SpeedRunOptions;
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
import net.minecraft.client.gui.screen.Screen;
Expand Down Expand Up @@ -32,7 +33,7 @@ protected void init() {

this.saveButton = addButton(new ButtonWidget(width / 2 - 100, height / 4 + 32, 98, 20, new TranslatableText("selectWorld.edit.save"),
(button) -> {
SpeedRunOptions.setOption(RunnerOptions.SPEEDRUN_COM_API_KEY, finalKey);
SpeedRunOption.setOption(RunnerOptions.SPEEDRUN_COM_API_KEY, finalKey);
booleanConsumer.accept(true);
}));

Expand All @@ -42,7 +43,7 @@ protected void init() {

this.apiKeyTextField = new TextFieldWidget(textRenderer, width / 2 - 100, height / 4 + 9, 200, 20, new LiteralText("API Key..."));
this.apiKeyTextField.setMaxLength(30);
this.apiKeyTextField.setText(SpeedRunOptions.getOption(RunnerOptions.SPEEDRUN_COM_API_KEY));
this.apiKeyTextField.setText(SpeedRunOption.getOption(RunnerOptions.SPEEDRUN_COM_API_KEY));
children.add(this.apiKeyTextField);
setInitialFocus(this.apiKeyTextField);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.redlimerl.ghostrunner.record.data.GhostData;
import com.redlimerl.ghostrunner.util.Utils;
import com.redlimerl.ghostrunner.util.submit.SubmitData;
import com.redlimerl.speedrunigt.option.SpeedRunOption;
import com.redlimerl.speedrunigt.option.SpeedRunOptions;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.BackgroundHelper;
Expand Down Expand Up @@ -72,7 +73,7 @@ protected void init() {
this.submitButton = addButton(new ButtonWidget(width / 2 - 100, yPos + 99, 200, 20,
ghost.getRecordURL().isEmpty() ? new TranslatableText("ghostrunner.menu.submit_record") : new TranslatableText("ghostrunner.menu.open_speedrun_com"),
ghost.getRecordURL().isEmpty() ? (button) -> {
if (SpeedRunOptions.getOption(RunnerOptions.SPEEDRUN_COM_API_KEY).length() < 24) {
if (SpeedRunOption.getOption(RunnerOptions.SPEEDRUN_COM_API_KEY).length() < 24) {
client.openScreen(new ConfirmScreen(bool ->
client.openScreen(bool ? new APIKeyScreen(bool2 ->
client.openScreen(bool2 ? new GhostSubmitScreen(this, ghost) : this)) : this),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.redlimerl.ghostrunner.record.data.GhostData;
import com.redlimerl.speedrunigt.timer.InGameTimer;
import com.redlimerl.speedrunigt.timer.InGameTimerUtils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
Expand Down Expand Up @@ -53,8 +54,8 @@ public GeneralInfoListWidget(MinecraftClient minecraftClient, GhostInfoScreen in

GhostData ghostData = infoScreen.ghostData;
addEntry(new Entry(this, "seed", String.valueOf(ghostData.getSeed())));
addEntry(new Entry(this, "realtime", InGameTimer.timeToStringFormat(ghostData.getRealTimeAttack())));
addEntry(new Entry(this, "ingametime", InGameTimer.timeToStringFormat(ghostData.getInGameTime())));
addEntry(new Entry(this, "realtime", InGameTimerUtils.timeToStringFormat(ghostData.getRealTimeAttack())));
addEntry(new Entry(this, "ingametime", InGameTimerUtils.timeToStringFormat(ghostData.getInGameTime())));
addEntry(new Entry(this, "category", ghostData.getGhostCategory().getText().getString()));
addEntry(new Entry(this, "gametype", ghostData.getType().getContext()));
addEntry(new Entry(this, "clientversion", ghostData.getClientVersion()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.redlimerl.ghostrunner.record.data.GhostData;
import com.redlimerl.ghostrunner.util.TarGzUtil;
import com.redlimerl.ghostrunner.util.Utils;
import com.redlimerl.speedrunigt.option.SpeedRunOptionScreen;
import com.redlimerl.speedrunigt.gui.screen.SpeedRunOptionScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ScreenTexts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.redlimerl.ghostrunner.data.RunnerOptions;
import com.redlimerl.ghostrunner.data.UpdateStatus;
import com.redlimerl.ghostrunner.data.UpdateStatus.Status;
import com.redlimerl.speedrunigt.option.SpeedRunOption;
import com.redlimerl.speedrunigt.option.SpeedRunOptions;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ScreenTexts;
Expand Down Expand Up @@ -38,11 +39,11 @@ protected void init() {
addButton(new ButtonWidget(width / 2 - 75, height - 80, 150, 20, new TranslatableText("ghostrunner.menu.open_github_repo"), (ButtonWidget button) -> Util.getOperatingSystem().open("https://github.com/RedLime/GhostRunner/")));
addButton(new ButtonWidget(width / 2 - 100, height - 40, 200, 20, ScreenTexts.BACK, (ButtonWidget button) -> client.openScreen(parent)));

addButton(new CheckboxWidget(20, 20, 20, 20, new TranslatableText("ghostrunner.option.toggle_update_notification"), SpeedRunOptions.getOption(RunnerOptions.UPDATE_NOTIFICATION)) {
addButton(new CheckboxWidget(20, 20, 20, 20, new TranslatableText("ghostrunner.option.toggle_update_notification"), SpeedRunOption.getOption(RunnerOptions.UPDATE_NOTIFICATION)) {
@Override
public void onPress() {
super.onPress();
SpeedRunOptions.setOption(RunnerOptions.UPDATE_NOTIFICATION, isChecked());
SpeedRunOption.setOption(RunnerOptions.UPDATE_NOTIFICATION, isChecked());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.redlimerl.ghostrunner.util.Utils;
import com.redlimerl.ghostrunner.util.submit.SubmitData;
import com.redlimerl.speedrunigt.timer.InGameTimer;
import com.redlimerl.speedrunigt.timer.InGameTimerUtils;
import net.minecraft.client.gui.screen.ConfirmScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ScreenTexts;
Expand Down Expand Up @@ -98,7 +99,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
drawCenteredText(matrices, textRenderer, title, width / 2, 20, 16777215);
drawCenteredText(matrices, textRenderer, new TranslatableText("ghostrunner.message.not_need_seed_description"), width / 2, this.submitButton.y - 12, 16777215);
drawCenteredText(matrices, textRenderer, new TranslatableText("ghostrunner.ghostdata.title").append(": ")
.append(ghostData.getGhostCategory().getText().getString() + " | " + ghostData.getType().getContext() + " | " + InGameTimer.timeToStringFormat(ghostData.getInGameTime())),
.append(ghostData.getGhostCategory().getText().getString() + " | " + ghostData.getType().getContext() + " | " + InGameTimerUtils.timeToStringFormat(ghostData.getInGameTime())),
width / 2, this.submitButton.y - 24, 16777215);
drawTextWithShadow(matrices, textRenderer, new TranslatableText("ghostrunner.title.description"), width / 2 - 100, this.descriptionField.y - 10, 16777215);
drawTextWithShadow(matrices, textRenderer, new TranslatableText("ghostrunner.title.video_url"), width / 2 - 100, this.videoUrlField.y - 10, 16777215);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.redlimerl.ghostrunner.record.data.GhostType;
import com.redlimerl.ghostrunner.util.TarGzUtil;
import com.redlimerl.speedrunigt.timer.InGameTimer;
import com.redlimerl.speedrunigt.timer.InGameTimerUtils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.ConfirmScreen;
Expand Down Expand Up @@ -156,9 +157,9 @@ public void render(MatrixStack matrices, int index, int y, int x, int entryWidth
float xOffset = (float) x;

MutableText timeContext = new LiteralText(" IGT: ").formatted(Formatting.GRAY)
.append(new LiteralText(InGameTimer.timeToStringFormat(ghost.getInGameTime())).formatted(Formatting.UNDERLINE).formatted(Formatting.YELLOW))
.append(new LiteralText(InGameTimerUtils.timeToStringFormat(ghost.getInGameTime())).formatted(Formatting.UNDERLINE).formatted(Formatting.YELLOW))
.append(new LiteralText(" / RTA: ").formatted(Formatting.GRAY))
.append(new LiteralText(InGameTimer.timeToStringFormat(ghost.getRealTimeAttack())).formatted(Formatting.UNDERLINE).formatted(Formatting.LIGHT_PURPLE))
.append(new LiteralText(InGameTimerUtils.timeToStringFormat(ghost.getRealTimeAttack())).formatted(Formatting.UNDERLINE).formatted(Formatting.LIGHT_PURPLE))
.append(new LiteralText(" / ").formatted(Formatting.GRAY))
.append(ghost.getGhostCategory().getText().formatted(Formatting.UNDERLINE).formatted(Formatting.AQUA));
MutableText runnerContext = new TranslatableText("ghostrunner.context.by").append(": ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.redlimerl.ghostrunner.record.ReplayGhost;
import com.redlimerl.ghostrunner.record.data.GhostData;
import com.redlimerl.speedrunigt.timer.InGameTimer;
import com.redlimerl.speedrunigt.timer.InGameTimerUtils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.ScreenTexts;
Expand Down Expand Up @@ -103,7 +104,7 @@ public void render(MatrixStack matrices, int index, int y, int x, int entryWidth
ghostName = ghostName.substring(indexCount, 20+indexCount);
}

selectWidget.client.textRenderer.draw(matrices, new LiteralText("").append(new LiteralText("[" + InGameTimer.timeToStringFormat(ghostData.getInGameTime()) + "] ")
selectWidget.client.textRenderer.draw(matrices, new LiteralText("").append(new LiteralText("[" + InGameTimerUtils.timeToStringFormat(ghostData.getInGameTime()) + "] ")
.formatted(Formatting.GRAY)).append(new LiteralText(ghostName)), (float) (x + 4), (float) (y + 6), GhostSelectScreen.WHITE_COLOR);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.redlimerl.ghostrunner.gui.widget;

import com.redlimerl.ghostrunner.data.RunnerOptions;
import com.redlimerl.speedrunigt.option.SpeedRunOption;
import com.redlimerl.speedrunigt.option.SpeedRunOptions;
import net.minecraft.client.gui.widget.SliderWidget;
import net.minecraft.text.LiteralText;
Expand All @@ -9,7 +10,7 @@
public class OpacitySliderWidget extends SliderWidget {

public OpacitySliderWidget() {
super(0, 0, 150, 20, LiteralText.EMPTY, SpeedRunOptions.getOption(RunnerOptions.GHOST_OPACITY));
super(0, 0, 150, 20, LiteralText.EMPTY, SpeedRunOption.getOption(RunnerOptions.GHOST_OPACITY));
updateMessage();
}

Expand All @@ -21,6 +22,6 @@ protected void updateMessage() {

@Override
protected void applyValue() {
SpeedRunOptions.setOption(RunnerOptions.GHOST_OPACITY, (float) this.value);
SpeedRunOption.setOption(RunnerOptions.GHOST_OPACITY, (float) this.value);
}
}
Loading

0 comments on commit b92e57a

Please sign in to comment.