Skip to content
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
2 changes: 1 addition & 1 deletion gradle/scripts/mod_dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//file:noinspection DependencyNotationArgument

dependencies {
api("com.cleanroommc:modularui:3.1.4") { transitive = false }
api("com.cleanroommc:modularui:3.1.5") { transitive = false }
api("codechicken:codechickenlib:3.2.3.358")
api("com.cleanroommc:groovyscript:1.3.4") { transitive = false }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.github.trcdevelopers.clayium.api.capability

import com.cleanroommc.modularui.api.drawable.IKey
import com.cleanroommc.modularui.api.widget.IGuiAction
import com.cleanroommc.modularui.value.sync.DoubleSyncValue
import com.cleanroommc.modularui.value.sync.PanelSyncManager
import com.cleanroommc.modularui.value.sync.SyncHandlers
import com.cleanroommc.modularui.widgets.ProgressWidget
Expand Down Expand Up @@ -220,10 +221,11 @@ abstract class AbstractWorkable(
fun getProgressBar(syncManager: PanelSyncManager, showRecipes: Boolean = true): ProgressWidget {
syncManager.syncValue("requiredProgress", SyncHandlers.longNumber(::requiredProgress, ::requiredProgress::set))
syncManager.syncValue("craftingProgress", SyncHandlers.longNumber(::currentProgress, ::currentProgress::set))
syncManager.syncValue("progress", DoubleSyncValue(::getNormalizedProgress))

val widget = ProgressWidget()
.size(22, 17)
.progress(this::getNormalizedProgress)
.syncHandler("progress")
.texture(ClayGuiTextures.PROGRESS_BAR, 22)
if (showRecipes && Mods.JustEnoughItems.isModLoaded) {
widget.addTooltipLine(IKey.lang("jei.tooltip.show.recipes"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class LaserEnergyHolder(
))

return IKey.dynamic { "Laser : ${this.storedPower.format()}" }.asWidget()
.alignment(Alignment.Center)
.textAlign(Alignment.Center)
.width(60)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ abstract class AbstractBuilderMetaTileEntity(
.child(SlotGroupWidget.builder()
.matrix(*matrixStr.toTypedArray())
.key('I') { MuiSlots.itemSlotBuilder(itemInventory, it).slotGroup("builder_inventory").build() }
.build().alignX(Alignment.TopCenter.x).top(12)
.build().horizontalCenter().top(12)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ abstract class AbstractItemGeneratorMetaTileEntity(
MuiSlots.itemSlotBuilder(itemInventory, index)
.slotGroup("machine_inventory")
.build()
}.build().align(Alignment.Center))
}.build().center())
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ abstract class AbstractMinerMetaTileEntity(

return super.buildMainParentWidget(syncManager)
.child(IKey.dynamic { "Laser : ${laser?.let { LaserEnergy(it.energy).format() } ?: 0}" }.asWidget()
.width(80).alignment(Alignment.Center)
.alignX(Alignment.Center.x).bottom(12)
.width(80).textAlign(Alignment.Center)
.horizontalCenter().bottom(12)
)
.child(MuiSlots.phantomSlotBuilder(filterSlot, 0).filter { it.hasCapability(ClayiumCapabilities.ITEM_FILTER) }.build()
.background(ClayGuiTextures.FILTER_SLOT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.cleanroommc.modularui.utils.Alignment
import com.cleanroommc.modularui.value.sync.PanelSyncManager
import com.cleanroommc.modularui.widgets.SlotGroupWidget
import com.cleanroommc.modularui.widgets.TextWidget
import com.cleanroommc.modularui.widgets.layout.Column
import com.cleanroommc.modularui.widgets.layout.Flow
import io.github.trcdevelopers.clayium.api.GUI_DEFAULT_WIDTH
import io.github.trcdevelopers.clayium.api.capability.IPipeConnectionLogic
import io.github.trcdevelopers.clayium.api.capability.impl.ClayiumItemStackHandler
Expand Down Expand Up @@ -79,8 +79,8 @@ class ClayBufferMetaTileEntity(
.child(
TextWidget(IKey.lang(this.translationKey, IKey.lang(tier.prefixTranslationKey)))
.margin(6)
.align(Alignment.TopLeft))
.child(Column()
.left(0).top(0))
.child(Flow.column()
.marginTop(18)
.child(SlotGroupWidget.builder()
.matrix(*matrixStr.toTypedArray())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ClayLaserMetaTileEntity(
.columnWithPlayerInv {
child(buildMainParentWidget(syncManager).child(
clayEnergyHolder.createCeTextWidget(syncManager).bottom(12).left(0))
.child(clayEnergyHolder.createSlotWidget().align(Alignment.BottomRight)))
.child(clayEnergyHolder.createSlotWidget().right(0).bottom(0)))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.cleanroommc.modularui.screen.ModularPanel
import com.cleanroommc.modularui.utils.Alignment
import com.cleanroommc.modularui.value.sync.PanelSyncManager
import com.cleanroommc.modularui.widget.ParentWidget
import com.cleanroommc.modularui.widgets.layout.Column
import com.cleanroommc.modularui.widgets.layout.Flow
import io.github.trcdevelopers.clayium.api.ClayiumApi
import io.github.trcdevelopers.clayium.api.block.BlockMachine.Companion.IS_PIPE
Expand Down Expand Up @@ -690,7 +689,7 @@ abstract class MetaTileEntity(

protected inline fun ModularPanel.columnWithPlayerInv(builder: (Flow.() -> Flow)): ModularPanel {
return this.child(
Column().margin(7).sizeRel(1f)
Flow.column().margin(7).sizeRel(1f)
.builder()
.child(MuiSlots.playerInventory(0))
)
Expand All @@ -702,12 +701,12 @@ abstract class MetaTileEntity(
protected open fun buildMainParentWidget(syncManager: PanelSyncManager): ParentWidget<*> {
return ParentWidget().widthRel(1f).expanded().marginBottom(2)
.child(IKey.str(asStackForm().displayName).asWidget()
.align(Alignment.TopLeft))
.child(IKey.lang("container.inventory").asWidget().align(Alignment.BottomLeft))
.left(0).top(0))
.child(IKey.lang("container.inventory").asWidget().left(0).bottom(0))
.child(IKey.dynamic {
// if empty string, a bug occurs.
if (overclock != 1.0) SidelessI18n.format("gui.clayium.overclock", overclock) else " "
}.asWidget().width(100).alignment(Alignment.CenterRight).align(Alignment.BottomRight))
}.asWidget().width(100).textAlign(Alignment.CenterRight).right(0).bottom(0))
}

@Deprecated("Use onRightClickServerSide instead.", ReplaceWith("onRightClickServerSide(player, hand, clickedSide, hitX, hitY, hitZ)"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import com.cleanroommc.modularui.screen.ModularPanel
import com.cleanroommc.modularui.utils.Alignment
import com.cleanroommc.modularui.value.sync.PanelSyncManager
import com.cleanroommc.modularui.widgets.SlotGroupWidget
import com.cleanroommc.modularui.widgets.layout.Column
import com.cleanroommc.modularui.widgets.layout.Row
import com.cleanroommc.modularui.widgets.layout.Flow
import io.github.trcdevelopers.clayium.api.GUI_DEFAULT_WIDTH
import io.github.trcdevelopers.clayium.api.capability.ClayiumCapabilities
import io.github.trcdevelopers.clayium.api.capability.IPipeConnectionLogic
Expand Down Expand Up @@ -118,14 +117,14 @@ class MultiTrackBufferMetaTileEntity(
val slotsRowString = "I".repeat(trackInvSize)
return ModularPanel("multi_track_buffer")
.size(max(GUI_DEFAULT_WIDTH, trackInvSize * 18 + 4 + 18 + /* margin*/ 12), 18 + trackRow * 18 + 94 + 2)
.align(Alignment.Center)
.center()
.columnWithPlayerInv {
child(buildMainParentWidget(syncManager)
.child(Column().width(trackInvSize * 18 + 4 + 18).height(trackRow * 18)
.align(Alignment.Center)
.child(Flow.column().width(trackInvSize * 18 + 4 + 18).height(trackRow * 18)
.center()
.also { column ->
for ((i, handler) in tracks.withIndex()) {
column.child(Row().width(trackInvSize * 18 + 4 + 18).height(18)
column.child(Flow.row().width(trackInvSize * 18 + 4 + 18).height(18)
.child(SlotGroupWidget.builder()
.matrix(slotsRowString)
.key('I') { slotIndex ->
Expand All @@ -137,7 +136,7 @@ class MultiTrackBufferMetaTileEntity(
.build())
.child(MuiSlots.phantomSlot(filtersHandler, i)
.background(ClayGuiTextures.M_TRACK_FILTER_SLOTS[i])
.align(Alignment.CenterRight)))
.right(0).verticalCenter()))
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.cleanroommc.modularui.value.sync.PanelSyncManager
import com.cleanroommc.modularui.widget.ParentWidget
import com.cleanroommc.modularui.widgets.ButtonWidget
import com.cleanroommc.modularui.widgets.SlotGroupWidget
import com.cleanroommc.modularui.widgets.layout.Row
import com.cleanroommc.modularui.widgets.layout.Flow
import io.github.trcdevelopers.clayium.api.ClayEnergy
import io.github.trcdevelopers.clayium.api.capability.impl.AbstractRecipeLogic
import io.github.trcdevelopers.clayium.api.capability.impl.ClayEnergyHolder
Expand Down Expand Up @@ -57,14 +57,14 @@ abstract class WorkableMetaTileEntity(
}

override fun buildMainParentWidget(syncManager: PanelSyncManager): ParentWidget<*> {
val slotsAndProgressBar = Row()
val slotsAndProgressBar = Flow.row()
.widthRel(0.7f).height(26)
.align(Alignment.Center)
.child(workable.getProgressBar(syncManager).align(Alignment.Center))
.center()
.child(workable.getProgressBar(syncManager).center())

if (importItems.slots == 1) {
slotsAndProgressBar.child(
MuiSlots.itemSlotBuilder(importItems, 0).singletonSlotGroup().build().align(Alignment.CenterLeft)
MuiSlots.itemSlotBuilder(importItems, 0).singletonSlotGroup().build().left(0).verticalCenter()
)
} else if (importItems.slots == 2) {
syncManager.registerSlotGroup("input_inv", 1)
Expand All @@ -76,12 +76,12 @@ abstract class WorkableMetaTileEntity(
if (index == 0) background(ClayGuiTextures.IMPORT_1_SLOT) else background(ClayGuiTextures.IMPORT_2_SLOT)
}}
.build()
.align(Alignment.CenterLeft))
.left(0).verticalCenter())
}
if (exportItems.slots == 1) {
slotsAndProgressBar.child(
MuiSlots.itemSlotBuilder(exportItems, 0).singletonSlotGroup().takeOnly().buildLarge()
.align(Alignment.CenterRight))
.right(0).verticalCenter())
} else if (exportItems.slots == 2) {
syncManager.registerSlotGroup("output_inv", 1)
slotsAndProgressBar.child(
Expand All @@ -96,24 +96,24 @@ abstract class WorkableMetaTileEntity(
}
}
.build()
.align(Alignment.CenterRight)
.right(0).verticalCenter()
)
}

return super.buildMainParentWidget(syncManager)
.child(slotsAndProgressBar.align(Alignment.Center))
.child(slotsAndProgressBar.center())
.child(clayEnergyHolder.createCeTextWidget(syncManager)
.name("CE Text")
.bottom(12).left(0))
.child(clayEnergyHolder.createSlotWidget()
.name("CE Slot")
.align(Alignment.BottomRight))
.childIf(tier.numeric < 3, ButtonWidget()
.size(16, 16).align(Alignment.BottomCenter)
.right(0).bottom(0))
.childIf(tier.numeric < 3) { ButtonWidget()
.size(16, 16).horizontalCenter().bottom(0)
.overlay(ClayGuiTextures.CE_BUTTON)
.hoverOverlay(ClayGuiTextures.CE_BUTTON_HOVERED)
.syncHandler(InteractionSyncHandler().setOnMousePressed {
clayEnergyHolder.addEnergy(ClayEnergy(1))
}))
})}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ClayBlastFurnaceMetaTileEntity(
override fun buildMainParentWidget(syncManager: PanelSyncManager): ParentWidget<*> {
return super.buildMainParentWidget(syncManager)
.child(multiblockLogic.tierTextWidget(syncManager)
.align(Alignment.BottomCenter))
.horizontalCenter().bottom(0))
}

override fun createMetaTileEntity(): MetaTileEntity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ class ClayReactorMetaTileEntity(
syncManager.syncValue("clay_laser", clayLaserSyncValue)
return super.buildMainParentWidget(syncManager)
.child(IKey.dynamic { SidelessI18n.format("gui.clayium.laser_energy", UtilLocale.laserNumeral(this.laser?.energy?.toLong() ?: 0L)) }
.asWidget().width(70).alignment(Alignment.Center)
.asWidget().width(70).textAlign(Alignment.Center)
.pos(102, 53))
.child(multiblockLogic.tierTextWidget(syncManager)
.alignX(Alignment.Center.x).bottom(12))
.horizontalCenter().bottom(12))
}

override fun acceptLaser(irradiatedSide: EnumFacing, laser: ClayLaser?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class MultiblockLogic(
fun tierTextWidget(syncManager: PanelSyncManager): TextWidget<*> {
syncManager.syncValue("multiblock_tier", SyncHandlers.intNumber({ recipeLogicTier }, { recipeLogicTier = it }))
return IKey.dynamic { SidelessI18n.format("tooltip.clayium.tier", recipeLogicTier) }
.asWidget().width(40).alignment(Alignment.Center)
.asWidget().width(40).textAlign(Alignment.Center)
}

override fun <T> getCapability(capability: Capability<T>, facing: EnumFacing?): T? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.cleanroommc.modularui.screen.ModularPanel
import com.cleanroommc.modularui.utils.Alignment
import com.cleanroommc.modularui.value.sync.PanelSyncManager
import com.cleanroommc.modularui.widget.ParentWidget
import com.cleanroommc.modularui.widgets.layout.Column
import com.cleanroommc.modularui.widgets.layout.Flow
import io.github.trcdevelopers.clayium.api.capability.impl.InfiniteItemStackHandler
import io.github.trcdevelopers.clayium.api.unification.material.CPropertyKey
import io.github.trcdevelopers.clayium.api.util.toItemStack
Expand Down Expand Up @@ -39,13 +39,13 @@ class TileEntityCreativeEnergySource : TileEntity(), IGuiHolderClayium<PosGuiDat

override fun buildUI(data: PosGuiData, syncManager: PanelSyncManager): ModularPanel {
return ModularPanel.defaultPanel("clayium:creative_energy_source")
.child(Column().margin(7).sizeRel(1f)
.child(Flow.column().margin(7).sizeRel(1f)
.child(ParentWidget().widthRel(1f).expanded().marginBottom(2)
.child(IKey.lang("tile.clayium.creative_energy_source.name").asWidget()
.align(Alignment.TopLeft))
.child(IKey.lang("container.inventory").asWidget().align(Alignment.BottomLeft))
.left(0).top(0))
.child(IKey.lang("container.inventory").asWidget().left(0).bottom(0))
.child(MuiSlots.itemSlotBuilder(handler, 0).takeOnly().build()
.align(Alignment.Center))
.center())
)
.child(MuiSlots.playerInventory(0))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.cleanroommc.modularui.api.widget.IGuiAction
import com.cleanroommc.modularui.factory.PosGuiData
import com.cleanroommc.modularui.screen.ModularPanel
import com.cleanroommc.modularui.utils.Alignment
import com.cleanroommc.modularui.value.sync.DoubleSyncValue
import com.cleanroommc.modularui.value.sync.InteractionSyncHandler
import com.cleanroommc.modularui.value.sync.PanelSyncManager
import com.cleanroommc.modularui.value.sync.SyncHandlers
Expand Down Expand Up @@ -126,10 +127,11 @@ class TileClayWorkTable : TileEntity(), IGuiHolderClayium<PosGuiData> {
override fun buildUI(data: PosGuiData, syncManager: PanelSyncManager): ModularPanel {
syncManager.syncValue("craftingProgress", SyncHandlers.intNumber({ craftingProgress }, { craftingProgress = it }))
syncManager.syncValue("requiredProgress", SyncHandlers.intNumber({ requiredProgress }, { requiredProgress = it }))
syncManager.syncValue("progress", DoubleSyncValue(::getNormalizedProgress))

val progressWidget: ProgressWidget = ProgressWidget().size(80, 16)
.texture(ClayGuiTextures.WorkTable.PROGRESS_BAR_EMPTY, 80)
.progress(this::getNormalizedProgress)
.syncHandler("progress")
if (Mods.JustEnoughItems.isModLoaded) {
progressWidget.addTooltipLine(IKey.lang("jei.tooltip.show.recipes"))
.listenGuiAction(IGuiAction.MousePressed { _ ->
Expand All @@ -142,8 +144,8 @@ class TileClayWorkTable : TileEntity(), IGuiHolderClayium<PosGuiData> {
return ModularPanel.defaultPanel("clay_work_table")
.child(Flow.column().margin(7).sizeRel(1f)
.child(ParentWidget().widthRel(1f).expanded().marginBottom(2)
.child(IKey.lang("tile.clayium.clay_work_table.name").asWidget().align(Alignment.TopLeft))
.child(IKey.lang("container.inventory").asWidget().align(Alignment.BottomLeft))
.child(IKey.lang("tile.clayium.clay_work_table.name").asWidget().left(0).top(0))
.child(IKey.lang("container.inventory").asWidget().left(0).bottom(0))
.child(MuiSlots.itemSlotBuilder(this.itemHandler, INPUT_SLOT)
.singletonSlotGroup()
.buildLarge()
Expand Down
Loading
Loading