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

Feature: Display Tab Widgets #1276

Merged
merged 85 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
ed3209e
init
Thunderblade73 Mar 8, 2024
72bc1b1
Merge branch 'beta' into widget
Thunderblade73 Mar 12, 2024
6a43b1e
added all widgets
Thunderblade73 Mar 12, 2024
4aec172
fixed pattern
Thunderblade73 Mar 12, 2024
d266204
formatting
Thunderblade73 Mar 12, 2024
3b5edd8
added updating the enum via repo
Thunderblade73 Mar 12, 2024
6468ebf
cleanup
Thunderblade73 Mar 12, 2024
c3e86d8
added garden patterns
Thunderblade73 Mar 12, 2024
ebc620c
added lines to enum
Thunderblade73 Mar 12, 2024
cef4edb
removed debug
Thunderblade73 Mar 12, 2024
eacc076
added to copyTabList
Thunderblade73 Mar 12, 2024
b2279f6
fixed patterns
Thunderblade73 Mar 12, 2024
89e6c4b
optimisation and cleanup
Thunderblade73 Mar 13, 2024
e7b08db
added verifyKeyShape and doc for RepoPatternManager.getUnusedPatterns
Thunderblade73 Mar 13, 2024
6d79c49
fix
Thunderblade73 Mar 13, 2024
55effdb
Update prefix and added a notice
Thunderblade73 Mar 14, 2024
ba5af7c
Merge branch 'beta' into widget
Thunderblade73 Mar 22, 2024
bff58f8
major fixes
Thunderblade73 Mar 22, 2024
30c83ff
Merge branch 'beta' into widget
Thunderblade73 Mar 24, 2024
b4a2013
added missing dungeon "widgets"
Thunderblade73 Mar 24, 2024
a5c8ece
init
Thunderblade73 Mar 25, 2024
2db26bb
info
Thunderblade73 Mar 25, 2024
13c6a04
Merge branch 'beta' into widget-guis
Thunderblade73 Mar 25, 2024
b0db6ed
fixed typo
Thunderblade73 Mar 25, 2024
b577ffc
Merge branch 'beta' into widget
Thunderblade73 Mar 25, 2024
668d1dd
Merge branch 'widget' into widget-guis
Thunderblade73 Mar 25, 2024
593ffd0
added remaining displays
Thunderblade73 Mar 25, 2024
5758c2c
Merge branch 'beta' into widget
Thunderblade73 Mar 28, 2024
0dea5c0
Merge branch 'widget' into widget-guis
Thunderblade73 Mar 28, 2024
72925f2
Merge branch 'beta' into widget
Thunderblade73 Mar 31, 2024
65ac5e8
Merge branch 'beta' into widget
Thunderblade73 Apr 3, 2024
f08634c
Merge branch 'widget' into widget-guis
Thunderblade73 Apr 3, 2024
f971784
Merge branch 'beta' into widget
Thunderblade73 Apr 3, 2024
cc72501
Merge branch 'widget' into widget-guis
Thunderblade73 Apr 3, 2024
d25375a
Merge branch 'beta' into widget
Thunderblade73 Apr 7, 2024
c793018
Merge branch 'widget' into widget-guis
Thunderblade73 Apr 7, 2024
7b42911
Kdocs + add missing widget
Thunderblade73 Apr 7, 2024
7d22916
Merge branch 'beta' into widget
Thunderblade73 Apr 13, 2024
84c5d13
Merge branch 'widget' into widget-guis
Thunderblade73 Apr 13, 2024
5262b67
fix
Thunderblade73 Apr 13, 2024
4eda0e1
Merge branch 'beta' into widget
Thunderblade73 Apr 16, 2024
b967d10
Merge branch 'beta' into widget-guis
Thunderblade73 Apr 16, 2024
6fda739
added config links
Thunderblade73 Apr 16, 2024
76f5a5b
Merge branch 'beta' into widget
Thunderblade73 Apr 17, 2024
5eb9fcf
Merge branch 'widget' into widget-guis
Thunderblade73 Apr 17, 2024
ecb78db
Merge branch 'beta' into widget
Thunderblade73 Apr 18, 2024
18c6068
Merge branch 'beta' into widget
Thunderblade73 Apr 21, 2024
6791720
Merge branch 'beta' into widget
Thunderblade73 Apr 23, 2024
2b5d530
Merge branch 'widget' into widget-guis
Thunderblade73 Apr 23, 2024
fc322ed
Merge branch 'beta' into widget
Thunderblade73 Apr 24, 2024
aa9dea1
Merge branch 'widget' into widget-guis
Thunderblade73 Apr 24, 2024
7b1e493
Merge branch 'beta' into widget
Thunderblade73 Apr 25, 2024
3542737
added new frozen corpses widget
Thunderblade73 May 5, 2024
4413b86
Merge branch 'refs/heads/beta' into widget
Thunderblade73 Jun 1, 2024
33340cc
updated
Thunderblade73 Jun 1, 2024
b9224fe
Merge branch 'refs/heads/widget' into widget-guis
Thunderblade73 Jun 1, 2024
2e94478
fixes
Thunderblade73 Jun 1, 2024
00d4acf
Merge branch 'refs/heads/beta' into fork/Thunderblade73/widget
CalMWolfs Jun 2, 2024
b49f661
slight code cleanup, and fix bug
CalMWolfs Jun 2, 2024
44b758c
re send added
Thunderblade73 Jun 2, 2024
5c34481
killed sub events
Thunderblade73 Jun 2, 2024
3657cbc
Merge branch 'refs/heads/widget' into widget-guis
Thunderblade73 Jun 2, 2024
f3efe00
being not so to fast :)
Thunderblade73 Jun 3, 2024
8ada530
Merge branch 'refs/heads/beta' into widget
Thunderblade73 Jun 3, 2024
0104cb9
Merge branch 'refs/heads/widget' into widget-guis
Thunderblade73 Jun 3, 2024
de78d13
Merge branch 'refs/heads/beta' into widget
Thunderblade73 Jun 3, 2024
2730fde
Merge branch 'refs/heads/widget' into widget-guis
Thunderblade73 Jun 3, 2024
10202e1
Merge branch 'refs/heads/beta' into widget-guis
Thunderblade73 Jun 3, 2024
6a0efe0
add rain and fix small issue
CalMWolfs Jun 4, 2024
d078400
use annotation
CalMWolfs Jun 4, 2024
ba23687
Merge branch 'refs/heads/beta' into widget-guis
Thunderblade73 Jun 9, 2024
c8617f3
formatting
Thunderblade73 Jun 9, 2024
df010ca
Merge branch 'refs/heads/beta' into widget-guis
Thunderblade73 Jun 9, 2024
05b1fba
formatting
Thunderblade73 Jun 9, 2024
fc3a78b
code cleanup
hannibal002 Jun 9, 2024
a1d340f
Merge branch 'refs/heads/beta' into widget-guis
Thunderblade73 Jun 14, 2024
b0f98f2
Merge branch 'refs/heads/beta' into fork/Thunderblade73/widget-guis
hannibal002 Jun 18, 2024
9bcc27c
formatting
hannibal002 Jun 18, 2024
149fa79
Merge branch 'refs/heads/beta' into widget-guis
Thunderblade73 Jun 20, 2024
454cd65
Merge branch 'refs/heads/beta' into fork/Thunderblade73/widget-guis
hannibal002 Jul 6, 2024
857b1d2
fixed merge conflict
hannibal002 Jul 6, 2024
40fac90
Merge branch 'refs/heads/beta' into fork/Thunderblade73/widget-guis
hannibal002 Sep 7, 2024
e9252a3
auto formatting
hannibal002 Sep 7, 2024
ae16797
removed unused code
hannibal002 Sep 7, 2024
2ed2418
fixed event tracker not existing
Thunderblade73 Sep 7, 2024
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
21 changes: 12 additions & 9 deletions src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.config

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.core.config.Position
import at.hannibal2.skyhanni.config.core.config.PositionList
import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson
import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson
import at.hannibal2.skyhanni.data.jsonobjects.local.KnownFeaturesJson
Expand Down Expand Up @@ -39,7 +40,6 @@ import java.nio.file.StandardCopyOption
import java.util.EnumMap
import kotlin.concurrent.fixedRateTimer
import kotlin.reflect.KMutableProperty0
import kotlin.reflect.KMutableProperty1

private fun GsonBuilder.registerIfBeta(create: TypeAdapterFactory): GsonBuilder {
return if (LorenzUtils.isBetaVersion()) {
Expand All @@ -66,8 +66,7 @@ class ConfigManager {

private fun setConfigHolder(type: ConfigFileType, value: Any) {
require(value.javaClass == type.clazz)
@Suppress("UNCHECKED_CAST")
(type.property as KMutableProperty0<Any>).set(value)
@Suppress("UNCHECKED_CAST") (type.property as KMutableProperty0<Any>).set(value)
(jsonHolder as MutableMap<ConfigFileType, Any>)[type] = value
}

Expand Down Expand Up @@ -96,8 +95,7 @@ class ConfigManager {
try {
findPositionLinks(features, mutableSetOf())
} catch (e: Exception) {
if (LorenzEvent.isInGuardedEventHandler)
throw e
if (LorenzEvent.isInGuardedEventHandler) throw e
}
}

Expand Down Expand Up @@ -125,7 +123,7 @@ class ConfigManager {
var missingConfigLink = false
for (field in obj.javaClass.fields) {
field.isAccessible = true
if (field.type != Position::class.java) {
if (field.type != Position::class.java && field.type != PositionList::class.java) {
findPositionLinks(field.get(obj), slog)
continue
}
Expand All @@ -141,8 +139,13 @@ class ConfigManager {
}
continue
}
val position = field.get(obj) as Position
position.setLink(configLink)
if (field.type == Position::class.java) {
val position = field.get(obj) as Position
position.setLink(configLink)
} else if (field.type == PositionList::class.java) {
val list = field.get(obj) as PositionList
list.setLink(configLink)
}
}
if (missingConfigLink) {
println("")
Expand Down Expand Up @@ -245,7 +248,7 @@ class ConfigManager {
unit.toPath(),
file.toPath(),
StandardCopyOption.REPLACE_EXISTING,
StandardCopyOption.ATOMIC_MOVE
StandardCopyOption.ATOMIC_MOVE,
)
} catch (e: AccessDeniedException) {
if (loop == 5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public class Position {
private boolean clicked = false;
public String internalName = null;

public Position() {
this(0, 0);
}

public Position(int x, int y) {
this(x, y, false, false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package at.hannibal2.skyhanni.config.core.config

import io.github.notenoughupdates.moulconfig.annotations.ConfigLink

class PositionList() : ArrayList<Position>(), MutableList<Position> {

constructor(init: Collection<Position>) : this() {
this.addAll(init)
}

constructor(size: Int) : this() {
this.addAll((0..<size).map { Position() })
}

@Throws(NoSuchFieldException::class)
fun setLink(configLink: ConfigLink) {
this.configLink = configLink
forEach {
it.setLink(configLink)
}
}

private var configLink: ConfigLink? = null

override fun add(element: Position): Boolean {
if (configLink != null) {
element.setLink(configLink!!)
}
return super.add(element)
}

override fun addAll(elements: Collection<Position>): Boolean {
if (configLink != null) {
elements.forEach {
it.setLink(configLink!!)
}
}
return super.addAll(elements)
}

override fun set(index: Int, element: Position): Position {
if (configLink != null) {
element.setLink(configLink!!)
}
return super.set(index, element)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public class GUIConfig {
@Accordion
public TextBoxConfig customTextBox = new TextBoxConfig();

@Expose
@ConfigOption(name = "Tab Widget", desc = "")
@Accordion
public TabWidgetConfig tabWidget = new TabWidgetConfig();

@Expose
@ConfigOption(name = "In-Game Date", desc = "")
@Accordion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package at.hannibal2.skyhanni.config.features.gui;

import at.hannibal2.skyhanni.config.FeatureToggle;
import at.hannibal2.skyhanni.config.core.config.PositionList;
import at.hannibal2.skyhanni.features.gui.TabWidgetDisplay;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;

import java.util.ArrayList;
import java.util.List;

public class TabWidgetConfig {

@Expose
@ConfigOption(name = "Enabled", desc = "Enables the gui elements for the selected widgets.")
@ConfigEditorBoolean
@FeatureToggle
public boolean enabled = false;

@ConfigOption(name = "Not working Info", desc = "If the information isn't shown in the tablist it won't show anything. Use /widget to turn on the information you need.")
@ConfigEditorInfoText
public String text1;

@ConfigOption(name = "Enable Info", desc = "Drag only one new value at time into the list, since the default locations are all the same.")
@ConfigEditorInfoText
public String text2;

@Expose
@ConfigOption(name = "Widgets", desc = "")
@ConfigEditorDraggableList
public List<TabWidgetDisplay> display = new ArrayList<>();

@Expose
@ConfigLink(owner = TabWidgetConfig.class, field = "enabled")
public PositionList displayPositions = new PositionList(TabWidgetDisplay.getEntries().size());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package at.hannibal2.skyhanni.features.gui

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.core.config.Position
import at.hannibal2.skyhanni.data.model.TabWidget
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.allLettersFirstUppercase
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

enum class TabWidgetDisplay(private val configName: String?, vararg val widgets: TabWidget) {
SOULFLOW(null, TabWidget.SOULFLOW),
COINS("Bank and Interest", TabWidget.BANK, TabWidget.INTEREST),
SB_LEVEL("Skyblock Level", TabWidget.SB_LEVEL),
PROFILE(null, TabWidget.PROFILE),
PLAYER_LIST("Players", TabWidget.PLAYER_LIST),
PET(null, TabWidget.PET),
PET_TRAINING("Pet Upgrade Info", TabWidget.PET_SITTER, TabWidget.PET_TRAINING),
STATS(null, TabWidget.STATS, TabWidget.DUNGEON_SKILLS_AND_STATS),
DUNGEON_TEAM("Dungeon Info about every person", TabWidget.DUNGEON_PARTY),
DUNGEON_PUZZLE("Dungeon Info about puzzles", TabWidget.DUNGEON_PUZZLE),
DUNGEON_OVERALL("Dungeon General Info (very long)", TabWidget.DUNGEON_STATS),
BESTIARY(null, TabWidget.BESTIARY),
DRAGON("Dragon Fight Info", TabWidget.DRAGON),
PROTECTOR("Protector State", TabWidget.PROTECTOR),
SHEN_RIFT("Shen's Auction inside the Rift", TabWidget.RIFT_SHEN),
MINION("Minion Info", TabWidget.MINION),
COLLECTION(null, TabWidget.COLLECTION),
TIMERS(null, TabWidget.TIMERS),
FIRE_SALE(null, TabWidget.FIRE_SALE),
RAIN("Park Rain", TabWidget.RAIN),
;

val position get() = config.displayPositions[ordinal]

override fun toString(): String {
return configName ?: name.lowercase().allLettersFirstUppercase()
}

@SkyHanniModule
companion object {

private val config get() = SkyHanniMod.feature.gui.tabWidget

private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled

@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
if (!isEnabled()) return
if (config?.displayPositions == null) return
config.display.forEach { widget ->
widget.position.renderStrings(
widget.widgets.flatMap { it.lines },
posLabel = "Display Widget: ${widget.name}",
)
}
}

@SubscribeEvent
fun onJoin(event: ProfileJoinEvent) {
// Validation that the displayPositions in the config is correct
val sizeDiff = TabWidgetDisplay.entries.size - config.displayPositions.size
if (sizeDiff == 0) return
if (sizeDiff < 0) {
ErrorManager.skyHanniError(
"Invalid State of config.displayPositions",
"Display" to TabWidgetDisplay.entries,
"Positions" to config.displayPositions,
)
} else {
config.displayPositions.addAll(generateSequence { Position() }.take(sizeDiff))
}
}
}
}
59 changes: 29 additions & 30 deletions src/test/java/at/hannibal2/skyhanni/test/RepoPatternTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ object RepoPatternTest {
RepoPatternManager.loadPatternsFromDump(
RepoPatternDump(
regexes = mapOf(
simpleRepoPattern.key to remoteValue
)
)
simpleRepoPattern.key to remoteValue,
),
),
)

val isRemoteWorking = simplePattern.pattern() == remoteValue
Expand Down Expand Up @@ -67,9 +67,9 @@ object RepoPatternTest {
RepoPatternDump(
regexes = mapOf(
listPatterns.key + ".1" to remoteValue1,
listPatterns.key + ".2" to remoteValue2
)
)
listPatterns.key + ".2" to remoteValue2,
),
),
)

val isRemoteWorking = list[0].pattern() == remoteValue1 && list[1].pattern() == remoteValue2
Expand All @@ -80,8 +80,8 @@ object RepoPatternTest {
RepoPatternDump(
regexes = mapOf(
listPatterns.key + ".1" to remoteValue3,
)
)
),
),
)

val isRemoteSingleWorking = list[0].pattern() == remoteValue3 && list.size == 1
Expand All @@ -92,8 +92,8 @@ object RepoPatternTest {
RepoPatternDump(
regexes = mapOf(
listPatterns.key to remoteValue4,
)
)
),
),
)

val isRemoteListToSingleWorking = list.isEmpty()
Expand All @@ -116,22 +116,22 @@ object RepoPatternTest {
val remoteValue3 = "I'm remote 3."
val remoteValue4 = "I'm remote 4."

val isLocalWorking = group.getUnusedPatterns()
.isEmpty() && pattern1.pattern() == simpleLocalePattern1 && pattern2.pattern() == simpleLocalePattern2
val isLocalWorking =
group.getUnusedPatterns().isEmpty() && pattern1.pattern() == simpleLocalePattern1 && pattern2.pattern() == simpleLocalePattern2

assert(isLocalWorking)

RepoPatternManager.loadPatternsFromDump(
RepoPatternDump(
regexes = mapOf(
groupInfo.prefix + ".a" to remoteValue1,
groupInfo.prefix + ".b" to remoteValue2
)
)
groupInfo.prefix + ".b" to remoteValue2,
),
),
)

val isRemoteWorking = group.getUnusedPatterns()
.isEmpty() && pattern1.pattern() == remoteValue1 && pattern2.pattern() == remoteValue2
val isRemoteWorking =
group.getUnusedPatterns().isEmpty() && pattern1.pattern() == remoteValue1 && pattern2.pattern() == remoteValue2

assert(isRemoteWorking)

Expand All @@ -140,9 +140,9 @@ object RepoPatternTest {
regexes = mapOf(
groupInfo.prefix + ".a" to remoteValue3,
groupInfo.prefix + ".b" to remoteValue2,
groupInfo.prefix + ".c" to remoteValue4
)
)
groupInfo.prefix + ".c" to remoteValue4,
),
),
)

val unused = group.getUnusedPatterns()
Expand All @@ -166,23 +166,22 @@ object RepoPatternTest {
val remoteValue3 = "I'm remote 3."
val remoteValue4 = "I'm remote 4."

val isLocalWorking = group.getUnusedPatterns()
.isEmpty() && list[0].pattern() == simpleLocalePattern1 && list[1].pattern() == simpleLocalePattern2
val isLocalWorking =
group.getUnusedPatterns().isEmpty() && list[0].pattern() == simpleLocalePattern1 && list[1].pattern() == simpleLocalePattern2

assert(isLocalWorking)

RepoPatternManager.loadPatternsFromDump(
RepoPatternDump(
regexes = mapOf(
groupInfo.prefix + ".a.1" to remoteValue1,
groupInfo.prefix + ".a.2" to remoteValue2
)
)
groupInfo.prefix + ".a.2" to remoteValue2,
),
),
)

val unused0 = group.getUnusedPatterns()
val isRemoteWorking = group.getUnusedPatterns()
.isEmpty() && list[0].pattern() == remoteValue1 && list[1].pattern() == remoteValue2
val isRemoteWorking = group.getUnusedPatterns().isEmpty() && list[0].pattern() == remoteValue1 && list[1].pattern() == remoteValue2

assert(isRemoteWorking)

Expand All @@ -191,9 +190,9 @@ object RepoPatternTest {
regexes = mapOf(
groupInfo.prefix + ".a.1" to remoteValue3,
groupInfo.prefix + ".a.2" to remoteValue2,
groupInfo.prefix + ".b" to remoteValue4
)
)
groupInfo.prefix + ".b" to remoteValue4,
),
),
)

val unused = group.getUnusedPatterns()
Expand Down
Loading