This repository was archived by the owner on Jun 1, 2021. It is now read-only.
forked from MightyPirates/OpenComputers
-
Notifications
You must be signed in to change notification settings - Fork 4
GUI Boilerplate and Computer Case GUI Beginnings #17
Draft
rschulman
wants to merge
9
commits into
lucsoft:master-MC1.16
Choose a base branch
from
rschulman:master-MC1.16
base: master-MC1.16
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dc009c3
Create some fundamentals for gui management and partial completion of…
rschulman aac2220
Merge conflicts from upstream
rschulman 3f24d20
Revert changes to `Case` constructor in `Case.kt` and `Case` creation…
rschulman 346d7c1
Propagate case tier into Case BlockEntity and ScreenHandler
rschulman 49f479b
Add new texture for slots
rschulman e0d7eb8
Rebase, plus move CaseEntity functions into the new Case.kt file
rschulman 10c0929
Change Case into an ExtendedScreenHandler, trying to get correct case…
rschulman 19c4252
Add toTag and fromTag for Case entity to store and recover entity tier
rschulman 5f7e000
Add and align slots for tier 1 and 2, and slot textures for tier 1
rschulman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,4 @@ object OpenComputers: ModInitializer { | |
| ConfigLoader.initializeConfig() | ||
| Components.registerComponents() | ||
| } | ||
|
|
||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package li.cli.oc.client.gui.blocks | ||
|
|
||
| import com.mojang.blaze3d.systems.RenderSystem | ||
| import li.cli.oc.OpenComputers | ||
| import net.minecraft.client.gui.screen.ingame.HandledScreen | ||
| import net.minecraft.client.gui.widget.TexturedButtonWidget | ||
| import net.minecraft.client.util.math.MatrixStack | ||
| import net.minecraft.entity.player.PlayerInventory | ||
| import net.minecraft.screen.ScreenHandler | ||
| import net.minecraft.text.Text | ||
| import net.minecraft.util.Identifier | ||
|
|
||
| class CaseScreen(handler: ScreenHandler?, inventory: PlayerInventory?, title: Text?) : HandledScreen<ScreenHandler?>(handler, inventory, title) { | ||
|
|
||
| override fun drawBackground(matrices: MatrixStack?, delta: Float, mouseX: Int, mouseY: Int) { | ||
| RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f) | ||
| assert(client != null) | ||
| client!!.textureManager.bindTexture(TEXTURE) | ||
| val x = (width - backgroundWidth) / 2 | ||
| val y = (height - backgroundHeight) / 2 | ||
| drawTexture(matrices, x, y, 0, 0, backgroundWidth, backgroundHeight) | ||
|
|
||
| client!!.textureManager.bindTexture(COMP_TEXTURE) | ||
| drawTexture(matrices, x, y + 1, 0, 0, 256, 256) | ||
| } | ||
|
|
||
|
|
||
| override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { | ||
| renderBackground(matrices) | ||
| super.render(matrices, mouseX, mouseY, delta) | ||
| drawMouseoverTooltip(matrices, mouseX, mouseY) | ||
| } | ||
|
|
||
| override fun init() { | ||
| super.init() | ||
| val x = (width - backgroundWidth) / 2 | ||
| val y = (height - backgroundHeight) / 2 | ||
| // Center the title | ||
| titleX = 7 | ||
| val powerButton = TexturedButtonWidget(x + (backgroundWidth / 2) - 18 , y + 34, 18, 18, 0, 0, 0, BUTTON_TEXTURE, 36, 36) { button -> | ||
| TODO( | ||
| "Computer start/stop here" | ||
| ) | ||
| } | ||
| addButton(powerButton) | ||
|
|
||
|
|
||
| } | ||
|
|
||
| companion object { | ||
| private val TEXTURE = Identifier(OpenComputers.modId, "textures/gui/background.png") | ||
| private val COMP_TEXTURE = Identifier(OpenComputers.modId, "textures/gui/computer.png") | ||
| private val BUTTON_TEXTURE = Identifier(OpenComputers.modId, "textures/gui/button_power.png") | ||
| private val SLOT_TEXTURE = Identifier(OpenComputers.modId, "textures/gui/slot.png") | ||
| } | ||
|
|
||
| } |
36 changes: 36 additions & 0 deletions
36
src/main/kotlin/li/cli/oc/client/gui/blocks/CaseScreenHandler.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package li.cli.oc.client.gui.blocks | ||
|
|
||
| import li.cli.oc.Components | ||
| import li.cli.oc.client.gui.blocks.slots.* | ||
| import net.minecraft.entity.player.PlayerEntity | ||
| import net.minecraft.entity.player.PlayerInventory | ||
| import net.minecraft.inventory.SimpleInventory | ||
| import net.minecraft.screen.ScreenHandler | ||
| import net.minecraft.screen.slot.Slot | ||
|
|
||
| class CaseScreenHandler(syncId: Int, playerInventory: PlayerInventory) : ScreenHandler(Components.CASE_SCREEN_HANDLER, syncId) { | ||
| private val inventory = SimpleInventory(10) | ||
|
|
||
| override fun canUse(player: PlayerEntity?): Boolean { | ||
| return inventory.canPlayerUse(player) | ||
| } | ||
|
|
||
| init { | ||
| // BIOS Slot to the left of the power button | ||
| addSlot(Slot(inventory, 0, 20, 20)) | ||
|
|
||
| // Two Expansion Slot Cards to the left of the component grid | ||
| addSlot(Slot(inventory, 1, 80, 10)) | ||
| addSlot(Slot(inventory, 2, 80, 30)) | ||
|
|
||
| // One CPU Slot in the center top of the component grid | ||
| addSlot(Slot(inventory, 3, 100, 10)) | ||
|
|
||
| // Two RAM Slots in the direct middle and bottom middle of the component grid | ||
| addSlot(Slot(inventory, 4, 100, 30)) | ||
| addSlot(Slot(inventory, 5, 100, 50)) | ||
|
|
||
| // One HDD Slot in the top right of the component grid | ||
| addSlot(Slot(inventory, 6, 120, 10)) | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
src/main/kotlin/li/cli/oc/client/gui/blocks/slots/CPUSlot.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package li.cli.oc.client.gui.blocks.slots | ||
|
|
||
| import li.cli.oc.items.CPU | ||
| import net.minecraft.inventory.Inventory | ||
| import net.minecraft.item.ItemStack | ||
| import net.minecraft.screen.slot.Slot | ||
|
|
||
| class CPUSlot(inventory: Inventory, index: Int, x: Int, y: Int, level: Int) : Slot(inventory, index, x, y) { | ||
| private val tier: Int = 0 | ||
|
|
||
| /* override fun canInsert(stack: ItemStack?): Boolean { | ||
| if (stack != null) { | ||
| return stack.item is CPU && CPU.tier <= tier | ||
| } | ||
|
|
||
| return false | ||
| }*/ | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/main/kotlin/li/cli/oc/client/gui/blocks/slots/EEPROMSlot.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package li.cli.oc.client.gui.blocks.slots | ||
|
|
||
| import net.minecraft.inventory.Inventory | ||
| import net.minecraft.item.ItemStack | ||
| import net.minecraft.screen.slot.Slot | ||
|
|
||
| class EEPROMSlot(inventory: Inventory, index: Int, x: Int, y: Int) : Slot(inventory, index, x, y) { | ||
|
|
||
| /* override fun canInsert(stack: ItemStack?): Boolean { | ||
| if (stack != null) { | ||
| return stack.item is EEPROM // TODO: Rename once BIOS Card item class is created | ||
| } | ||
|
|
||
| return false | ||
| }*/ | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/li/cli/oc/client/gui/blocks/slots/ExpSlot.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package li.cli.oc.client.gui.blocks.slots | ||
|
|
||
| import net.minecraft.inventory.Inventory | ||
| import net.minecraft.item.ItemStack | ||
| import net.minecraft.screen.slot.Slot | ||
|
|
||
| class ExpSlot(inventory: Inventory, index: Int, x: Int, y: Int, level: Int) : Slot(inventory, index, x, y) { | ||
| private val level: Int = 0 | ||
|
|
||
| /* override fun canInsert(stack: ItemStack?): Boolean { | ||
| if (stack != null) { | ||
| return stack.item is ExpansionCard && ExpansionCard.level <= level// TODO: Rename once Expansion Card item class is created | ||
| } | ||
|
|
||
| return false | ||
| }*/ | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/li/cli/oc/client/gui/blocks/slots/HDSlot.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package li.cli.oc.client.gui.blocks.slots | ||
|
|
||
| import net.minecraft.inventory.Inventory | ||
| import net.minecraft.item.ItemStack | ||
| import net.minecraft.screen.slot.Slot | ||
|
|
||
| class HDSlot(inventory: Inventory, index: Int, x: Int, y: Int, level: Int) : Slot(inventory, index, x, y) { | ||
| private val level: Int = 0 | ||
|
|
||
| /* override fun canInsert(stack: ItemStack?): Boolean { | ||
| if (stack != null) { | ||
| return stack.item is HardDrive && HardDrive.level <= level// TODO: Rename once Expansion Card item class is created | ||
| } | ||
|
|
||
| return false | ||
| }*/ | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/li/cli/oc/client/gui/blocks/slots/RAMSlot.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package li.cli.oc.client.gui.blocks.slots | ||
|
|
||
| import net.minecraft.inventory.Inventory | ||
| import net.minecraft.item.ItemStack | ||
| import net.minecraft.screen.slot.Slot | ||
|
|
||
| class RAMSlot(inventory: Inventory, index: Int, x: Int, y: Int, level: Int) : Slot(inventory, index, x, y) { | ||
| private val level: Int = 0 | ||
|
|
||
| /* override fun canInsert(stack: ItemStack?): Boolean { | ||
| if (stack != null) { | ||
| return stack.item is RAMCard && RAMCard.level <= level// TODO: Rename once RAM Card item class is created | ||
| } | ||
|
|
||
| return false | ||
| }*/ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package li.cli.oc.items | ||
|
|
||
| import li.cli.oc.OpenComputers | ||
| import net.minecraft.item.Item | ||
|
|
||
| class CPU(tier: Int) : Item(Settings().group(OpenComputers.ITEM_GROUP)) { | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.