Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend: Config to Kotlin #2 #3173

Open
wants to merge 9 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ChatConfig {
@Expose
@ConfigOption(name = "Dungeon Filters", desc = "Hide specific message types in Dungeons.")
@ConfigEditorDraggableList
var dungeonFilteredMessageTypes: List<DungeonMessageTypes> = ArrayList()
var dungeonFilteredMessageTypes: List<DungeonMessageTypes> = listOf()


enum class DungeonMessageTypes(private val displayName: String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,92 +1,79 @@
package at.hannibal2.skyhanni.config.features.chroma;

import at.hannibal2.skyhanni.config.FeatureToggle;
import at.hannibal2.skyhanni.config.HasLegacyId;
import at.hannibal2.skyhanni.features.chroma.ChromaManager;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
import io.github.notenoughupdates.moulconfig.observer.Property;

public class ChromaConfig {

package at.hannibal2.skyhanni.config.features.chroma

import at.hannibal2.skyhanni.config.FeatureToggle
import at.hannibal2.skyhanni.config.HasLegacyId
import at.hannibal2.skyhanni.features.chroma.ChromaManager
import com.google.gson.annotations.Expose
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption
import io.github.notenoughupdates.moulconfig.observer.Property

class ChromaConfig {
@Expose
@ConfigOption(name = "Chroma Preview", desc = "§fPlease star SkyHanni on GitHub!")
@ConfigEditorInfoText(infoTitle = "Only in SkyBlock")
public boolean chromaPreview = false;
var chromaPreview: Boolean = false

@Expose
@ConfigOption(name = "Enabled", desc = "Toggle SkyHanni's chroma.")
@ConfigEditorBoolean
@FeatureToggle
public Property<Boolean> enabled = Property.of(false);
var enabled: Property<Boolean> = Property.of(false)

@Expose
@ConfigOption(name = "Chroma Size", desc = "Change the size of each color in the chroma.")
@ConfigEditorSlider(minValue = 1f, maxValue = 100f, minStep = 1f)
public float chromaSize = 30f;
var chromaSize: Float = 30f

@Expose
@ConfigOption(name = "Chroma Speed", desc = "Change how fast the chroma animation moves.")
@ConfigEditorSlider(minValue = 0.5f, maxValue = 20f, minStep = 0.5f)
public float chromaSpeed = 6f;
var chromaSpeed: Float = 6f

@Expose
@ConfigOption(name = "Chroma Saturation", desc = "Change the saturation of the chroma.")
@ConfigEditorSlider(minValue = 0f, maxValue = 1f, minStep = 0.01f)
public float chromaSaturation = 0.75f;
var chromaSaturation: Float = 0.75f

@Expose
@ConfigOption(name = "Chroma Direction", desc = "Change the slant and direction of the chroma.")
@ConfigEditorDropdown
public Direction chromaDirection = Direction.FORWARD_RIGHT;
var chromaDirection: Direction = Direction.FORWARD_RIGHT

public enum Direction implements HasLegacyId {
enum class Direction(private val displayName: String, private val legacyId: Int) : HasLegacyId {
FORWARD_RIGHT("Forward + Right", 0),
FORWARD_LEFT("Forward + Left", 1),
BACKWARD_RIGHT("Backward + Right", 2),
BACKWARD_LEFT("Backward + Left", 3);

private final String str;
private final int legacyId;

Direction(String str, int legacyId) {
this.str = str;
this.legacyId = legacyId;
}

// Constructor if new enum elements are added post-migration
Direction(String str) {
this(str, -1);
}

@Override
public int getLegacyId() {
return legacyId;
}
constructor(displayName: String) : this(displayName, -1)

@Override
public String toString() {
return str;
}
override fun getLegacyId() = legacyId
override fun toString() = displayName
}

@ConfigOption(name = "Reset to Default", desc = "Reset all chroma settings to the default.")
@ConfigEditorButton(buttonText = "Reset")
public Runnable resetSettings = ChromaManager::resetChromaSettings;
var resetSettings: Runnable = Runnable { ChromaManager.resetChromaSettings() }

@Expose
@ConfigOption(name = "Everything Chroma", desc = "Render §4§l§oALL §r§7text in chroma. §e(Disables Patcher's Optimized Font Renderer while enabled)")
@ConfigOption(
name = "Everything Chroma",
desc = "Render §4§l§oALL §r§7text in chroma. §e(Disables Patcher's Optimized Font Renderer while enabled)"
)
@ConfigEditorBoolean
public boolean allChroma = false;
var allChroma: Boolean = false

@Expose
@ConfigOption(name = "Ignore Chat", desc = "Prevent Everything Chroma from applying to the chat (if you unironically use that feature...)")
@ConfigOption(
name = "Ignore Chat",
desc = "Prevent Everything Chroma from applying to the chat (if you unironically use that feature...)"
)
@ConfigEditorBoolean
public boolean ignoreChat = false;

var ignoreChat: Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ public enum NumberFormatEntry implements HasLegacyId {
SHORT("Short", 0),
LONG("Long", 1);

private final String str;
private final String displayName;
private final int legacyId;

NumberFormatEntry(String str, int legacyId) {
this.str = str;
NumberFormatEntry(String displayName, int legacyId) {
this.displayName = displayName;
this.legacyId = legacyId;
}

// Constructor if new enum elements are added post-migration
NumberFormatEntry(String str) {
this(str, -1);
NumberFormatEntry(String displayName) {
this(displayName, -1);
}

@Override
Expand All @@ -45,7 +45,7 @@ public int getLegacyId() {

@Override
public String toString() {
return str;
return displayName;
}
}

Expand All @@ -64,17 +64,17 @@ public enum DisplayTypeEntry implements HasLegacyId {
LOWEST_NEXT("Lowest kills needed to next tier", 6),
HIGHEST_NEXT("Highest kills needed to next tier", 7);

private final String str;
private final String displayName;
private final int legacyId;

DisplayTypeEntry(String str, int legacyId) {
this.str = str;
DisplayTypeEntry(String displayName, int legacyId) {
this.displayName = displayName;
this.legacyId = legacyId;
}

// Constructor if new enum elements are added post-migration
DisplayTypeEntry(String str) {
this(str, -1);
DisplayTypeEntry(String displayName) {
this(displayName, -1);
}

@Override
Expand All @@ -84,7 +84,7 @@ public int getLegacyId() {

@Override
public String toString() {
return str;
return displayName;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ public enum EnderNodeDisplayEntry implements HasLegacyId {
ENDERMAN_PET("§f10§7-§a8§7-§93§7-§52§7-§61 §fEnderman Pet", 23),
;

private final String str;
private final String displayName;
private final int legacyId;

EnderNodeDisplayEntry(String str, int legacyId) {
this.str = str;
EnderNodeDisplayEntry(String displayName, int legacyId) {
this.displayName = displayName;
this.legacyId = legacyId;
}

// Constructor if new enum elements are added post-migration
EnderNodeDisplayEntry(String str) {
this(str, -1);
EnderNodeDisplayEntry(String displayName) {
this(displayName, -1);
}

@Override
Expand All @@ -122,7 +122,7 @@ public int getLegacyId() {

@Override
public String toString() {
return str;
return displayName;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public enum AlertType {
CHAT_TITLE("Chat & Title"),
;

private final String str;
private final String displayName;

AlertType(String str) {
this.str = str;
AlertType(String displayName) {
this.displayName = displayName;
}

@Override
public String toString() {
return str;
return displayName;
}
}

Expand Down Expand Up @@ -73,15 +73,15 @@ public enum DisplayType {
BOTH("Both"),
;

private final String str;
private final String displayName;

DisplayType(String str) {
this.str = str;
DisplayType(String displayName) {
this.displayName = displayName;
}

@Override
public String toString() {
return str;
return displayName;
}
}

Expand All @@ -97,15 +97,15 @@ public enum OutlineType {
CIRCLE("Circle")
;

private final String str;
private final String displayName;

OutlineType(String str) {
this.str = str;
OutlineType(String displayName) {
this.displayName = displayName;
}

@Override
public String toString() {
return str;
return displayName;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public enum ShowWhen {
ONLY_BOW_HAND("Bow in hand"),

;
private final String str;
private final String displayName;

ShowWhen(String str) {
this.str = str;
ShowWhen(String displayName) {
this.displayName = displayName;
}

@Override
public String toString() {
return str;
return displayName;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ public enum NameVisibility implements HasLegacyId {
SHORT_NAME("Short Name", 2),
;

private final String str;
private final String displayName;
private final int legacyId;

NameVisibility(String str, int legacyId) {
this.str = str;
NameVisibility(String displayName, int legacyId) {
this.displayName = displayName;
this.legacyId = legacyId;
}

// Constructor if new enum elements are added post-migration
NameVisibility(String str) {
this(str, -1);
NameVisibility(String displayName) {
this(displayName, -1);
}

@Override
Expand All @@ -75,7 +75,7 @@ public int getLegacyId() {

@Override
public String toString() {
return str;
return displayName;
}
}

Expand Down Expand Up @@ -134,17 +134,17 @@ public enum BossCategory implements HasLegacyId {
BROODMOTHER("§bBroodmother")
;

private final String str;
private final String displayName;
private final int legacyId;

BossCategory(String str, int legacyId) {
this.str = str;
BossCategory(String displayName, int legacyId) {
this.displayName = displayName;
this.legacyId = legacyId;
}

// Constructor if new enum elements are added post-migration
BossCategory(String str) {
this(str, -1);
BossCategory(String displayName) {
this(displayName, -1);
}

@Override
Expand All @@ -154,7 +154,7 @@ public int getLegacyId() {

@Override
public String toString() {
return str;
return displayName;
}
}

Expand Down
Loading
Loading