Skip to content

Commit

Permalink
Improvement: Faction Quest Widget is disabled (#1977)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
hannibal002 and hannibal002 authored Jun 3, 2024
1 parent 1e67ef0 commit 960009e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ReputationHelperConfig {
@ConfigOption(name = "Enabled", desc = "Enable features around Reputation features in the Crimson Isle.")
@ConfigEditorBoolean
@FeatureToggle
public boolean enabled = false;
public Property<Boolean> enabled = Property.of(false);

@Expose
@ConfigOption(name = "Hide Completed", desc = "Hides tasks after they've been completed.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) {

private var display = emptyList<List<Any>>()
private var dirty = true
var tabListQuestsMissing = false

/**
* c - Barbarian Not Accepted
Expand Down Expand Up @@ -87,7 +88,7 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) {
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (!IslandType.CRIMSON_ISLE.isInIsland()) return
if (!config.enabled) return
if (!config.enabled.get()) return
if (!dirty && display.isEmpty()) {
dirty = true
}
Expand Down Expand Up @@ -124,17 +125,23 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) {
// TODO test
if (factionType == FactionType.NONE) return

newList.addAsSingletonList("Reputation Helper:")
questHelper.render(newList)
miniBossHelper.render(newList)
kuudraBossHelper.render(newList)
newList.addAsSingletonList("§e§lReputation Helper")
if (tabListQuestsMissing) {
newList.addAsSingletonList("§cFaction Quests Widget not found!")
newList.addAsSingletonList("§7Open §e/tab §7and enable it!")
} else {
questHelper.render(newList)
miniBossHelper.render(newList)
kuudraBossHelper.render(newList)
}


display = newList
}

@SubscribeEvent(priority = EventPriority.LOWEST)
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
if (!config.enabled) return
if (!config.enabled.get()) return
if (!IslandType.CRIMSON_ISLE.isInIsland()) return

if (config.useHotkey && !config.hotkey.isKeyHeld()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.SackAPI.getAmountInSacksOrNull
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
Expand All @@ -28,6 +29,7 @@ import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.CrimsonMi
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems
Expand Down Expand Up @@ -74,13 +76,41 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) {
questLoader.checkInventory(event)
}

@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
ConditionalUtils.onToggle(config.enabled) {
if (IslandType.CRIMSON_ISLE.isInIsland()) {
questLoader.loadFromTabList()
}
}
}

// TODO use WidgetUpdateEvent once its merged
@SubscribeEvent
fun onTabListUpdate(event: TabListUpdateEvent) {
if (!isEnabled()) return

questLoader.loadFromTabList()
}

// @SubscribeEvent
// fun onTabListWidgetUpdate(event: WidgetUpdateEvent.NewValues) {
// if (!isEnabled()) return
// if (event.isWidget(TabWidget.FACTION_QUESTS)) {
// println("WidgetUpdateEvent.NewValues")
// questLoader.loadFromTabList(event.lines)
// }
// }
//
// @SubscribeEvent
// fun onTabListWidgetUpdate(event: WidgetUpdateEvent.Clear) {
// if (!isEnabled()) return
// if (event.isWidget(TabWidget.FACTION_QUESTS)) {
// println("WidgetUpdateEvent.Clear")
// questLoader.loadFromTabList(emptyList())
// }
// }

@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (!isEnabled()) return
Expand Down Expand Up @@ -317,5 +347,5 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) {
}
}

private fun isEnabled() = IslandType.CRIMSON_ISLE.isInIsland() && config.enabled
private fun isEnabled() = IslandType.CRIMSON_ISLE.isInIsland() && config.enabled.get()
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,33 @@ class QuestLoader(private val dailyQuestHelper: DailyQuestHelper) {
}
}

// TODO use WidgetUpdateEvent once its merged
// fun loadFromTabList(lines: List<String>) {
fun loadFromTabList() {
var i = -1
dailyQuestHelper.greatSpook = false
var found = 0


for (line in TabListData.getTabList()) {
if (line.contains("Faction Quests:")) {
// for (line in lines) {
if (line == "§5§lFaction Quests:") {
i = 0
continue
}
if (i == -1) continue

i++
readQuest(line)
found++
if (dailyQuestHelper.greatSpook) return
if (i == 5) {
break
}
}

dailyQuestHelper.reputationHelper.tabListQuestsMissing = found == 0
dailyQuestHelper.update()
}

private fun readQuest(line: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DailyKuudraBossHelper(private val reputationHelper: CrimsonIsleReputationH
@SubscribeEvent
fun onRenderWorld(event: LorenzRenderWorldEvent) {
if (!IslandType.CRIMSON_ISLE.isInIsland()) return
if (!config.enabled) return
if (!config.enabled.get()) return
if (!reputationHelper.showLocations()) return
if (allKuudraDone) return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel
}

private fun getByDisplayName(name: String) = miniBosses.firstOrNull { it.displayName == name }
private fun isEnabled() = IslandType.CRIMSON_ISLE.isInIsland() && config.enabled
private fun isEnabled() = IslandType.CRIMSON_ISLE.isInIsland() && config.enabled.get()
}

0 comments on commit 960009e

Please sign in to comment.