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: Added Tooltip Move #1581

Merged
merged 6 commits into from
Apr 28, 2024
Merged
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
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityCollectionSt
import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggLocator
import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggsManager
import at.hannibal2.skyhanni.features.event.chocolatefactory.HoppityEggsShared
import at.hannibal2.skyhanni.features.event.chocolatefactory.clicks.CompactFactoryClick
import at.hannibal2.skyhanni.features.event.chocolatefactory.clicks.FactoryItemTooltipFeatures
import at.hannibal2.skyhanni.features.event.diana.AllBurrowsList
import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper
import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker
Expand Down Expand Up @@ -626,7 +626,7 @@ class SkyHanniMod {
loadModule(ChocolateFactoryBarnManager)
loadModule(ChocolateFactoryInventory)
loadModule(ChocolateFactoryStats)
loadModule(CompactFactoryClick)
loadModule(FactoryItemTooltipFeatures)
loadModule(HoppityEggsManager)
loadModule(HoppityEggLocator)
loadModule(HoppityEggsShared)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,14 @@ public class ChocolateFactoryConfig {
@ConfigOption(name = "Always Compact", desc = "Always Compact the item toolip on the chocolate. Requires the above option to be enabled.")
@ConfigEditorBoolean
public boolean compactOnClickAlways = false;

@Expose
@ConfigOption(name = "Tooltip Move", desc = "Move Tooltip away from the item you hover over while inside the Chocolate Factory.")
@ConfigEditorBoolean
@FeatureToggle
public boolean tooltipMove = false;

@Expose
@ConfigLink(owner = ChocolateFactoryConfig.class, field = "tooltipMove")
public Position tooltipMovePosition = new Position(-380, 150, false, true);
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
package at.hannibal2.skyhanni.features.event.chocolatefactory.clicks

import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI
import at.hannibal2.skyhanni.utils.CollectionUtils.getOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds

object CompactFactoryClick {
object FactoryItemTooltipFeatures {
private val config get() = ChocolateFactoryAPI.config

private var lastClick = SimpleTimeMark.farPast()
private var lastHover = SimpleTimeMark.farPast()
private var tooltipToHover = listOf<String>()

@SubscribeEvent
fun onTooltip(event: LorenzToolTipEvent) {
if (!ChocolateFactoryAPI.inChocolateFactory) return

if (config.tooltipMove) {
if (event.slot.slotNumber <= 44) {
lastHover = SimpleTimeMark.now()
tooltipToHover = event.toolTip.toList()
event.cancel()
} else {
lastHover = SimpleTimeMark.farPast()
}
return
}

onCompactClick(event)
}

@SubscribeEvent
fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) {
if (!ChocolateFactoryAPI.inChocolateFactory) return
if (config.tooltipMove) {
if (lastHover.passedSince() < 300.milliseconds) {
config.tooltipMovePosition.renderStrings(tooltipToHover, posLabel = "Tooltip Move")
}
}
}

private fun onCompactClick(event: LorenzToolTipEvent) {
if (!config.compactOnClick) return

val itemStack = event.itemStack
Expand Down
Loading