Skip to content

Commit

Permalink
fix: fix vigilance customizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Feb 24, 2022
1 parent 34681e6 commit 0e8ea01
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 3 deletions.
191 changes: 190 additions & 1 deletion src/main/java/net/wyvest/redaction/mixin/VigilancePaletteMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,195 @@
@Mixin(targets = "gg.essential.vigilance.gui.VigilancePalette", remap = false)
public class VigilancePaletteMixin {

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getBrightDivider() {
return VigilanceConfig.INSTANCE.getBrightDivider();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getDivider() {
return VigilanceConfig.INSTANCE.getDivider();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getDarkDivider() {
return VigilanceConfig.INSTANCE.getDarkDivider();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getOutline() {
return VigilanceConfig.INSTANCE.getOutline();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getScrollBar() {
return VigilanceConfig.INSTANCE.getScrollBar();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getBrightHighlight() {
return VigilanceConfig.INSTANCE.getBrightHighlight();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getHighlight() {
return VigilanceConfig.INSTANCE.getHighlight();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getDarkHighlight() {
return VigilanceConfig.INSTANCE.getDarkHighlight();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getLightBackground() {
return VigilanceConfig.INSTANCE.getLightBackground();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getBackground() {
return VigilanceConfig.INSTANCE.getBackground();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getDarkBackground() {
return VigilanceConfig.INSTANCE.getDarkBackground();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getSearchBarBackground() {
return VigilanceConfig.INSTANCE.getSearchBarBackground();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getBrightText() {
return VigilanceConfig.INSTANCE.getBrightText();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getMidText() {
return VigilanceConfig.INSTANCE.getMidText();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getDarkText() {
return VigilanceConfig.INSTANCE.getDarkText();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getModalBackground() {
return VigilanceConfig.INSTANCE.getModalBackground();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getWarning() {
return VigilanceConfig.INSTANCE.getWarning();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getAccent() {
return VigilanceConfig.INSTANCE.getAccent();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getSuccess() {
return VigilanceConfig.INSTANCE.getSuccess();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getTransparent() {
return VigilanceConfig.INSTANCE.getTransparent();
}

/**
* @author Wyvest
*/
@Overwrite
@NotNull
public final Color getDisabled() {
return VigilanceConfig.INSTANCE.getDisabled();
}

/**
* @author Wyvest
*/
Expand Down Expand Up @@ -208,6 +397,6 @@ public class VigilancePaletteMixin {
@Overwrite
@NotNull
public final BasicState<Color> getBgNoAlpha$Vigilance1_8_9() {
return new BasicState<>(new Color(VigilanceConfig.INSTANCE.getBrightDivider().getRed(), VigilanceConfig.INSTANCE.getBrightDivider().getGreen(), VigilanceConfig.INSTANCE.getBrightDivider().getBlue(), 0));
return new BasicState<>(new Color(VigilanceConfig.INSTANCE.getBackground().getRed(), VigilanceConfig.INSTANCE.getBackground().getGreen(), VigilanceConfig.INSTANCE.getBackground().getBlue(), 0));
}
}
5 changes: 3 additions & 2 deletions src/main/kotlin/net/wyvest/redaction/Redaction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package net.wyvest.redaction
import cc.woverflow.onecore.utils.Updater
import cc.woverflow.onecore.utils.command
import cc.woverflow.onecore.utils.openScreen
import gg.essential.api.utils.Multithreading
import gg.essential.api.utils.WebUtil
import net.minecraft.client.Minecraft
import net.minecraftforge.common.MinecraftForge.EVENT_BUS
Expand Down Expand Up @@ -34,13 +35,13 @@ object Redaction {
val mc: Minecraft
get() = Minecraft.getMinecraft()
val modDir = File(File(mc.mcDataDir, "W-OVERFLOW"), NAME)
var shouldApplyVigilanceMixin = false
val shouldApplyVigilanceMixin by lazy(LazyThreadSafetyMode.PUBLICATION) { WebUtil.fetchString("https://woverflow.cc/static/data/redaction_vigilance_mixin").toBoolean() }

@Mod.EventHandler
private fun onFMLPreInitialization(event: FMLPreInitializationEvent) {
if (!modDir.exists())
modDir.mkdirs()
shouldApplyVigilanceMixin = WebUtil.fetchString("https://woverflow.cc/static/data/redaction_vigilance_mixin").toBoolean()
Multithreading.runAsync { shouldApplyVigilanceMixin }
Updater.addToUpdater(event.sourceFile, NAME, ID, VERSION, "W-OVERFLOW/REDACTION")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.wyvest.redaction.config

import cc.woverflow.onecore.utils.browseURL
import gg.essential.universal.UDesktop
import gg.essential.vigilance.Vigilant
import gg.essential.vigilance.data.Property
import gg.essential.vigilance.data.PropertyType
Expand All @@ -8,6 +10,11 @@ import java.awt.Color
import java.io.File

object VigilanceConfig : Vigilant(File(Redaction.modDir, "vigilance.toml"), "Vigilance Config (from REDACTION)") {
@Property(PropertyType.BUTTON, "Warning", category = "Color Scheme", subcategory = "Info", description = "This feature will NOT work without an internet connection!\nALL ISSUES RELATING TO THIS MUST GO TO https://woverflow.cc/discord\n Click on the button to learn more.")
fun internetConnectionWarning() {
UDesktop.browseURL("https://github.com/W-OVERFLOW/REDACTION/blob/main/vigilance.md")
}

@Property(PropertyType.COLOR, "Bright Divider", category = "Color Scheme", subcategory = "Palette")
var brightDivider = Color(151, 151, 151)

Expand Down
9 changes: 9 additions & 0 deletions vigilance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# About Vigilance Palette Customization

## Why doesn't this feature work without an internet connection?

This feature is not supported by Sk1er LLC, which made the Vigilance library, thus breaking changes may be made at any time by Sk1er LLC. To make sure users of REDACTION do not crash if this happens, REDACTION only applies the mixin to modify Vigilance if the text in https://woverflow.cc/static/data/redaction_vigilance_mixin equals to "true". If the connection fails, it will default to false and thus not apply the mixin.

## Why do I need to get support for this feature in W-OVERFLOW, not Vigilance?

This feature is added by REDACTION, and thus all support should go to https://woverflow.cc/discord.

0 comments on commit 0e8ea01

Please sign in to comment.