Skip to content

Commit

Permalink
Merge pull request #33 from Skrelpoid/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Skrelpoid authored Jan 27, 2019
2 parents b94a466 + 708be9c commit dfd09e1
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 15 deletions.
13 changes: 0 additions & 13 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

14 changes: 14 additions & 0 deletions src/main/java/skrelpoid/superfastmode/SuperFastMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import java.io.IOException;
import java.lang.reflect.Field;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.backends.lwjgl.LwjglGraphics;
Expand All @@ -12,6 +14,7 @@
import com.evacipated.cardcrawl.modthespire.lib.SpireInitializer;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.vfx.AbstractGameEffect;

import basemod.BaseMod;
import basemod.ReflectionHacks;

Expand All @@ -27,8 +30,11 @@ public class SuperFastMode {
public static float deltaMultiplier = 2;
public static Field deltaField;
public static boolean isDeltaMultiplied = true;
public static boolean isInstantLerp = true;
public static SpireConfig config;

// TODO UI rendering should not be affected by multiplied delta. WIP

public static void initialize() {
logger.info("Initializing SuperFastMode");
BaseMod.subscribe(new UIManager());
Expand Down Expand Up @@ -59,11 +65,13 @@ private static void initConfig() {

private static void loadConfig() {
isDeltaMultiplied = config.getBool("isDeltaMultiplied");
isInstantLerp = config.getBool("isInstantLerp");
deltaMultiplier = config.getFloat("deltaMultiplier");
}

public static void writeConfig() {
config.setBool("isDeltaMultiplied", isDeltaMultiplied);
config.setBool("isInstantLerp", isInstantLerp);
config.setFloat("deltaMultiplier", deltaMultiplier);
}

Expand Down Expand Up @@ -109,6 +117,12 @@ public static void tickDuration(AbstractGameAction a) {
}
}

public static void instantLerp(float[] start, float target) {
if (isInstantLerp) {
start[0] = target;
}
}

public static void updateVFX(AbstractGameEffect effect) {
// Copied from AbstractGameEffect.update()
effect.duration -= getDelta();
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/skrelpoid/superfastmode/UIManager.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package skrelpoid.superfastmode;

import java.io.IOException;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.megacrit.cardcrawl.helpers.FontHelper;

import basemod.BaseMod;
import basemod.ModLabel;
import basemod.ModLabeledToggleButton;
Expand Down Expand Up @@ -38,7 +40,9 @@ public void receivePostInitialize() {
public static void buildUI() {
panel = new ModPanel();
panel.addUIElement(deltaToggle());
panel.addUIElement(skipToggle());
panel.addUIElement(deltaSlider());
panel.addUIElement(skipInfo());
panel.addUIElement(deltaInfo());
panel.addUIElement(speedInfo());
panel.addUIElement(progress());
Expand All @@ -60,6 +64,19 @@ private static void updateDeltaToggle(ModToggleButton b) {
speedUpdated = true;
}

private static ModLabeledToggleButton skipToggle() {
final float x = 350;
final float y = 590;
return new ModLabeledToggleButton("Make some Actions instant", x, y, Color.WHITE, FontHelper.tipBodyFont,
SuperFastMode.isInstantLerp, panel, l -> {}, UIManager::updateSkipToggle);
}

private static void updateSkipToggle(ModToggleButton b) {
SuperFastMode.isInstantLerp = b.enabled;
SuperFastMode.logger.info("Toggling skip actions (lerp) to " + b.enabled);
speedUpdated = true;
}

private static ModSlider deltaSlider() {
final float x = 1250;
final float y = 480;
Expand All @@ -75,6 +92,13 @@ private static void updateDeltaSlider(ModSlider s) {
speedUpdated = true;
}

private static ModLabel skipInfo() {
final float x = 350;
final float y = 650;
return new ModLabel("Makes many things faster, but they appear choppy.", x, y,
FontHelper.tipBodyFont, panel, l -> {});
}

private static ModLabel deltaInfo() {
final float x = 350;
final float y = 510;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.megacrit.cardcrawl.vfx.combat.PowerDebuffEffect;
import com.megacrit.cardcrawl.vfx.combat.PowerIconShowEffect;
import com.megacrit.cardcrawl.vfx.scene.BottomFogEffect;
import basemod.animations.SpriterAnimation;
import javassist.CannotCompileException;
import javassist.expr.ExprEditor;
import javassist.expr.MethodCall;
Expand Down Expand Up @@ -258,6 +259,7 @@ public class DefaultDeltaPatches {
@SpirePatch(clz = MapRoomNode.class, method = "update")
@SpirePatch(clz = MapRoomNode.class, method = "updateEmerald")
@SpirePatch(clz = MapRoomNode.class, method = "oscillateColor")
@SpirePatch(clz = SpriterAnimation.class, method = "renderSprite")
public static class DeltaPatch {
public static ExprEditor Instrument() {
return new ExprEditor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package skrelpoid.superfastmode.patches;

import com.evacipated.cardcrawl.modthespire.lib.ByRef;
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;

import skrelpoid.superfastmode.SuperFastMode;

// The methods patched here normally return a value between start and target.
// If start == target, these methods all return target. This makes many things instant
// E.G. Cards that animate from your deck to your hand will be instantly in
// your hand because currentX will be set to targetX instantly
public class MathHelperPatches {

@SpirePatch(clz = com.megacrit.cardcrawl.helpers.MathHelper.class, method = "mouseLerpSnap")
@SpirePatch(clz = com.megacrit.cardcrawl.helpers.MathHelper.class, method = "cardLerpSnap")
@SpirePatch(clz = com.megacrit.cardcrawl.helpers.MathHelper.class, method = "cardScaleLerpSnap")
@SpirePatch(clz = com.megacrit.cardcrawl.helpers.MathHelper.class, method = "uiLerpSnap")
@SpirePatch(clz = com.megacrit.cardcrawl.helpers.MathHelper.class, method = "orbLerpSnap")
@SpirePatch(clz = com.megacrit.cardcrawl.helpers.MathHelper.class, method = "scaleLerpSnap")
@SpirePatch(clz = com.megacrit.cardcrawl.helpers.MathHelper.class, method = "fadeLerpSnap")
@SpirePatch(clz = com.megacrit.cardcrawl.helpers.MathHelper.class, method = "popLerpSnap")
@SpirePatch(clz = com.megacrit.cardcrawl.helpers.MathHelper.class, method = "angleLerpSnap")
@SpirePatch(clz = com.megacrit.cardcrawl.helpers.MathHelper.class, method = "slowColorLerpSnap")
@SpirePatch(clz = com.megacrit.cardcrawl.helpers.MathHelper.class, method = "scrollSnapLerpSpeed")
public static class InstantLerp {
public static void Prefix(@ByRef float[] start, float target) {
SuperFastMode.instantLerp(start, target);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package skrelpoid.superfastmode.patches;

import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;

import skrelpoid.superfastmode.SuperFastMode;

public class MathUtilsPatches {

// I do not know why this is not the way this method works by default
// Fixes pretty much everything that uses this method
@SpirePatch(clz = com.badlogic.gdx.math.MathUtils.class, method = "lerp")
public static class LerpPatch {
public static float Replace(float fromValue, float toValue, float progress) {
float result = lerp(fromValue, toValue, progress);
// result should never be higher than toValue
if (SuperFastMode.isInstantLerp) {
result = toValue;
}
return result;
}
}

public static float lerp(float from, float to, float progress) {
return from + (to - from) * progress;
}
}
4 changes: 2 additions & 2 deletions src/main/resources/ModTheSpire.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"name": "SuperFastMode",
"author_list": ["Skrelpoid"],
"description": "Artificially speeds up the Game. Ingame, go to Mods>SuperFastMode>Config to change Settings.",
"version": "1.0.4",
"sts_version": "12-20-2018",
"version": "1.0.5",
"sts_version": "01-23-2019",
"mts_version": "3.6.3",
"dependencies": ["basemod"],
"update_json": "https://api.github.com/repos/Skrelpoid/SuperFastMode/releases/latest"
Expand Down

0 comments on commit dfd09e1

Please sign in to comment.