Skip to content

Commit

Permalink
Adds support for second set of sort buttons for the player inventory.
Browse files Browse the repository at this point in the history
Adds support for hotkey to toggle the overlay visibility.

closes #301
  • Loading branch information
blackd committed Aug 6, 2024
1 parent e5e1657 commit 06260ba
Show file tree
Hide file tree
Showing 15 changed files with 261 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,34 @@ import org.anti_ad.mc.common.vanilla.Vanilla
import org.anti_ad.mc.ipnext.inventory.ContainerType
import org.anti_ad.mc.ipnext.inventory.nonStorage
import org.anti_ad.mc.ipnext.inventory.playerOnly
import org.anti_ad.mc.ipnext.inventory.simple

val versionSpecificContainerTypes = setOf(PlayerContainer::class.java /**/ to playerOnly,
CreativeContainer::class.java /**/ to setOf(ContainerType.PURE_BACKPACK,
ContainerType.CREATIVE),

EnchantingTableContainer::class.java /**/ to nonStorage,
EnchantingTableContainer::class.java /**/ to setOf(ContainerType.PURE_BACKPACK),
AnvilContainer::class.java /**/ to setOf(ContainerType.PURE_BACKPACK,
ContainerType.ANVIL),
BeaconContainer::class.java /**/ to nonStorage,
BlastFurnaceContainer::class.java /**/ to nonStorage,
CartographyTableContainer::class.java /**/ to nonStorage,
AbstractFurnaceContainer::class.java /**/ to nonStorage,
GrindstoneContainer::class.java /**/ to nonStorage,
BlastFurnaceContainer::class.java /**/ to simple,
CartographyTableContainer::class.java /**/ to simple,
AbstractFurnaceContainer::class.java /**/ to simple,
GrindstoneContainer::class.java /**/ to simple,
LecternContainer::class.java /**/ to nonStorage,
LoomContainer::class.java /**/ to nonStorage,
StonecutterContainer::class.java /**/ to setOf(ContainerType.PURE_BACKPACK,
ContainerType.STONECUTTER),
SmithingTableContainer::class.java /**/ to nonStorage,
SmokerContainer::class.java /**/ to nonStorage,
SmithingTableContainer::class.java /**/ to simple,
SmokerContainer::class.java /**/ to simple,

MerchantContainer::class.java /**/ to setOf(ContainerType.TRADER),
CraftingTableContainer::class.java /**/ to setOf(ContainerType.CRAFTING),
CrafterContainer::class.java /**/ to nonStorage,
CrafterContainer::class.java /**/ to simple,

HopperContainer::class.java /**/ to setOf(ContainerType.NO_SORTING_STORAGE,
ContainerType.PURE_BACKPACK), //setOf(ContainerType.NO_SORTING_STORAGE),
BrewingStandContainer::class.java /**/ to nonStorage, //setOf(ContainerType.NO_SORTING_STORAGE),
AbstractFurnaceContainer::class.java /**/ to nonStorage, //setOf(ContainerType.NO_SORTING_STORAGE),

GenericContainer::class.java /**/ to setOf(ContainerType.SORTABLE_STORAGE,
ContainerType.RECTANGULAR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.anti_ad.mc.ipnext.ingame.`(syncId)`
import org.anti_ad.mc.ipnext.inventory.ContainerType
import org.anti_ad.mc.ipnext.inventory.nonStorage
import org.anti_ad.mc.ipnext.inventory.playerOnly
import org.anti_ad.mc.ipnext.inventory.simple

val versionSpecificContainerTypes = setOf(PlayerContainer::class.java /**/ to playerOnly,
CreativeContainer::class.java /**/ to setOf(ContainerType.PURE_BACKPACK,
Expand All @@ -35,25 +36,26 @@ val versionSpecificContainerTypes = setOf(PlayerContainer::class.java
AnvilContainer::class.java /**/ to setOf(ContainerType.PURE_BACKPACK,
ContainerType.ANVIL),
BeaconContainer::class.java /**/ to nonStorage,
BlastFurnaceContainer::class.java /**/ to nonStorage,
CartographyTableContainer::class.java /**/ to nonStorage,
ForgingContainer::class.java /**/ to nonStorage,
FurnaceContainer::class.java /**/ to nonStorage,
GrindstoneContainer::class.java /**/ to nonStorage,
BlastFurnaceContainer::class.java /**/ to simple,
CartographyTableContainer::class.java /**/ to simple,
ForgingContainer::class.java /**/ to simple,
FurnaceContainer::class.java /**/ to simple,
GrindstoneContainer::class.java /**/ to simple,
LecternContainer::class.java /**/ to nonStorage,
LoomContainer::class.java /**/ to nonStorage,
StonecutterContainer::class.java /**/ to setOf(ContainerType.PURE_BACKPACK,
ContainerType.STONECUTTER),
SmithingTableContainer::class.java /**/ to nonStorage,
SmokerContainer::class.java /**/ to nonStorage,
SmithingTableContainer::class.java /**/ to simple,
SmokerContainer::class.java /**/ to simple,

MerchantContainer::class.java /**/ to setOf(ContainerType.TRADER),
CraftingTableContainer::class.java /**/ to setOf(ContainerType.CRAFTING),
CrafterContainer::class.java /**/ to simple,

HopperContainer::class.java /**/ to setOf(ContainerType.NO_SORTING_STORAGE,
ContainerType.PURE_BACKPACK), //setOf(ContainerType.NO_SORTING_STORAGE),
BrewingStandContainer::class.java /**/ to nonStorage, //setOf(ContainerType.NO_SORTING_STORAGE),
AbstractFurnaceContainer::class.java /**/ to nonStorage, //setOf(ContainerType.NO_SORTING_STORAGE),
AbstractFurnaceContainer::class.java /**/ to simple, //setOf(ContainerType.NO_SORTING_STORAGE),

GenericContainer::class.java /**/ to setOf(ContainerType.SORTABLE_STORAGE,
ContainerType.RECTANGULAR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.anti_ad.mc.ipnext.ingame.`(syncId)`
import org.anti_ad.mc.ipnext.inventory.ContainerType
import org.anti_ad.mc.ipnext.inventory.nonStorage
import org.anti_ad.mc.ipnext.inventory.playerOnly
import org.anti_ad.mc.ipnext.inventory.simple

val versionSpecificContainerTypes = setOf(PlayerContainer::class.java /**/ to playerOnly,
CreativeContainer::class.java /**/ to setOf(ContainerType.PURE_BACKPACK,
Expand All @@ -35,25 +36,26 @@ val versionSpecificContainerTypes = setOf(PlayerContainer::class.java
AnvilContainer::class.java /**/ to setOf(ContainerType.PURE_BACKPACK,
ContainerType.ANVIL),
BeaconContainer::class.java /**/ to nonStorage,
BlastFurnaceContainer::class.java /**/ to nonStorage,
CartographyTableContainer::class.java /**/ to nonStorage,
ForgingContainer::class.java /**/ to nonStorage,
FurnaceContainer::class.java /**/ to nonStorage,
GrindstoneContainer::class.java /**/ to nonStorage,
BlastFurnaceContainer::class.java /**/ to simple,
CartographyTableContainer::class.java /**/ to simple,
ForgingContainer::class.java /**/ to simple,
FurnaceContainer::class.java /**/ to simple,
GrindstoneContainer::class.java /**/ to simple,
LecternContainer::class.java /**/ to nonStorage,
LoomContainer::class.java /**/ to nonStorage,
StonecutterContainer::class.java /**/ to setOf(ContainerType.PURE_BACKPACK,
ContainerType.STONECUTTER),
SmithingTableContainer::class.java /**/ to nonStorage,
SmokerContainer::class.java /**/ to nonStorage,
SmithingTableContainer::class.java /**/ to simple,
SmokerContainer::class.java /**/ to simple,

MerchantContainer::class.java /**/ to setOf(ContainerType.TRADER),
CraftingTableContainer::class.java /**/ to setOf(ContainerType.CRAFTING),
CrafterContainer::class.java /**/ to simple,

HopperContainer::class.java /**/ to setOf(ContainerType.NO_SORTING_STORAGE,
ContainerType.PURE_BACKPACK), //setOf(ContainerType.NO_SORTING_STORAGE),
BrewingStandContainer::class.java /**/ to nonStorage, //setOf(ContainerType.NO_SORTING_STORAGE),
AbstractFurnaceContainer::class.java /**/ to nonStorage, //setOf(ContainerType.NO_SORTING_STORAGE),
AbstractFurnaceContainer::class.java /**/ to simple, //setOf(ContainerType.NO_SORTING_STORAGE),

GenericContainer::class.java /**/ to setOf(ContainerType.SORTABLE_STORAGE,
ContainerType.RECTANGULAR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,17 @@ public enum IPNButton {
VILLAGER_DO_LOCAL_TRADES2,
VILLAGER_GLOBAL_BOOKMARK,
VILLAGER_LOCAL_BOOKMARK,
/**
* The sort button
*/
SORT_PLAYER,

/**
* The sort in columns button
*/
SORT_COLUMNS_PLAYER,
/**
* The sort in rows button
*/
SORT_ROWS_PLAYER,
}
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,20 @@ object LockedSlotsSettings : ConfigDeclaration {
}

object GuiSettings : ConfigDeclaration {

override val builder = createBuilder()

.CATEGORY("$category.gui.general")
val INVENTORY_OVERLAY_BUTTONS_VISIBLE /**/ by keyToggleBool(true, KeybindSettings.GUI_DEFAULT)
val ENABLE_INVENTORY_EDITOR_BUTTON /**/ by keyToggleBool(true, KeybindSettings.GUI_DEFAULT)
val ENABLE_INVENTORY_SETTINGS_BUTTON /**/ by keyToggleBool(true, KeybindSettings.GUI_DEFAULT)
.CATEGORY("$category.profiles")
val ENABLE_PROFILES_UI /**/ by keyToggleBool(true, KeybindSettings.GUI_DEFAULT)
val ENABLE_PROFILES_ANNOUNCEMENT /**/ by bool(true)
.CATEGORY("$category.inventory")
val ENABLE_INVENTORY_BUTTONS /**/ by keyToggleBool(true, KeybindSettings.GUI_DEFAULT)
//val TREAT_UNKNOWN_SCREENS_AS_CONTAINERS /**/ by bool(true)
val SHOW_BUTTONS_BOTH_SIDES /**/ by bool(false)

val SHOW_FAST_RENAME_CHECKBOX /**/ by keyToggleBool(true, KeybindSettings.GUI_DEFAULT)
val FAST_RENAME_CHECKBOX_VALUE /**/ by enum(ContinuousCraftingCheckboxValue.UNCHECKED)
val FAST_RENAME_SAVED_VALUE /**/ by bool(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class EditorWidget(override val screen: ContainerScreen<*>,
inner class InitWidgets { // todo cleanup code


private val showHideButton = ProfileButtonWidget { -> showEditorScreen() }.apply {
private val showHideButton = ProfileButtonWidget{ -> showEditorScreen() }.apply {
tx = 160
ty = 40
hints = this@EditorWidget.hints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ import org.anti_ad.mc.ipnext.integration.HintClassData
import org.anti_ad.mc.ipnext.integration.HintsManagerNG
import org.anti_ad.mc.common.vanilla.Vanilla
import org.anti_ad.mc.common.vanilla.alias.glue.I18n
import org.anti_ad.mc.common.vanilla.render.rClearDepth
import org.anti_ad.mc.common.vanilla.render.glue.rDrawOutline
import org.anti_ad.mc.common.vanilla.render.rStandardGlState
import org.anti_ad.mc.common.vanilla.render.opaque
import org.anti_ad.mc.ipn.api.IPNButton
import org.anti_ad.mc.ipnext.config.Debugs
Expand All @@ -50,18 +48,27 @@ import org.anti_ad.mc.ipnext.inventory.ContainerType
import org.anti_ad.mc.ipnext.inventory.ContainerTypes

class ProfilesUICollectionWidget(override val screen: ContainerScreen<*>,
private val hintsData: HintClassData = HintsManagerNG.getHints(screen.javaClass)): InsertableWidget(), Hintable {
hintsData: HintClassData = HintsManagerNG.getHints(screen.javaClass)): InsertableWidget(), Hintable {

override var hints: ButtonPositionHint = hintsData.hintFor(IPNButton.PROFILE_SELECTOR)
override var hintManagementRenderer = Hintable.HintManagementRenderer(this)
override var underManagement: Boolean = false
override val container = Vanilla.container()
private val types = ContainerTypes.getTypes(container)

var visibleSource: () -> Boolean

override var visible: Boolean
get() = visibleSource() && super.visible
set(value) {
super.visible = value
}

private var initialized = false

init {
visible = types.contains(ContainerType.PLAYER)
visibleSource = { GuiSettings.ENABLE_PROFILES_UI.value }
}

override fun postBackgroundRender(context: NativeContext,
Expand Down Expand Up @@ -120,9 +127,10 @@ class ProfilesUICollectionWidget(override val screen: ContainerScreen<*>,

inner class InitWidgets { // todo cleanup code

private val nextProfileButton = ProfileButtonWidget { -> ProfileSwitchHandler.nextProfile(true) }.apply {
private val nextProfileButton = ProfileButtonWidget{ -> ProfileSwitchHandler.nextProfile(true) }.apply {
tx = 50
ty = 20
parent = this@ProfilesUICollectionWidget
this@ProfilesUICollectionWidget.addChild(this)
visible = types.contains(ContainerType.PLAYER)
tooltipText = I18n.translate("inventoryprofiles.tooltip.next_profile_button")
Expand All @@ -131,12 +139,13 @@ class ProfilesUICollectionWidget(override val screen: ContainerScreen<*>,
private val prevProfileButton = ProfileButtonWidget { -> ProfileSwitchHandler.prevProfile(true) }.apply {
tx = 60
ty = 20
parent = this@ProfilesUICollectionWidget
this@ProfilesUICollectionWidget.addChild(this)
visible = types.contains(ContainerType.PLAYER)
tooltipText = I18n.translate("inventoryprofiles.tooltip.prev_profile_button")
}

private val profileButton = ActiveProfileButtonWidget { ProfileSwitchHandler.applyCurrent(true) }.apply {
private val profileButton = ActiveProfileButtonWidget{ ProfileSwitchHandler.applyCurrent(true) }.apply {

parent = this@ProfilesUICollectionWidget
val profile = getCurrentProfileName()
Expand Down Expand Up @@ -170,6 +179,13 @@ class ProfilesUICollectionWidget(override val screen: ContainerScreen<*>,
}

inner class ActiveProfileButtonWidget(onClick: () -> Unit): CustomButtonWidget(onClick) {

override var visible: Boolean
get() = GuiSettings.INVENTORY_OVERLAY_BUTTONS_VISIBLE.value && super.visible
set(value) {
super.visible = value
}

override var text: String
get() {
return getCurrentProfileName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ class SettingsWidget(override val screen: ContainerScreen<*>,
inner class InitWidgets { // todo cleanup code


private val showHideButton = ProfileButtonWidget { -> onClick() }.apply {
private val showHideButton = ProfileButtonWidget{ -> onClick() }.apply {
tx = 140
ty = 0
hints = this@SettingsWidget.hints
this@SettingsWidget.addChild(this)
visible = GuiSettings.ENABLE_INVENTORY_SETTINGS_BUTTON.booleanValue
visible = GuiSettings.ENABLE_INVENTORY_SETTINGS_BUTTON.value
tooltipText = I18n.translate("inventoryprofiles.tooltip.settings_open")
zIndex = 0
hintableList.add(this)
Expand Down
Loading

0 comments on commit 06260ba

Please sign in to comment.