Some save/load fixes

This commit is contained in:
LeshaInc 2020-08-16 02:06:48 +03:00
parent ccee51bef0
commit 7c5f084710
No known key found for this signature in database
GPG Key ID: B4855290FC36DE72
4 changed files with 10 additions and 3 deletions

@ -1 +1 @@
Subproject commit 7064d123b1b6d17ee93f355acdb3978b850513e4
Subproject commit 8c979af4b6597b3f3ce8f40d8bcf3089cbbe2731

View File

@ -30,10 +30,12 @@ class ComputerNode(val computer: Case, setup: Boolean = true) extends Node {
computer.add(new GraphicsCard(computer.tier.min(1)))
computer.add(Loot.OpenOsFloppy.create())
computer.add(Loot.OpenOsEEPROM.create())
refitSlots()
// refitSlots()
OcelotDesktop.workspace.add(computer)
}
refitSlots()
def this(nbt: NBTTagCompound) {
this({
val address = nbt.getString("address")
@ -95,7 +97,7 @@ class ComputerNode(val computer: Case, setup: Boolean = true) extends Node {
else
computer.remove(item)
case mem: Memory => memorySlots
.find(slot => slot._item.isEmpty && slot.tier >= (mem.tier + 1) / 2)
.find(slot => slot._item.isEmpty && slot.tier >= (mem.tier + 1) / 2 - 1)
.get._item = Some(mem)
case hdd: HDDManaged => diskSlots
.find(slot => slot._item.isEmpty && slot.tier >= hdd.tier)

View File

@ -48,6 +48,7 @@ class RootWidget extends Widget {
val frontendNBT = new NBTTagCompound
OcelotDesktop.workspace.save(backendNBT)
UiHandler.root.workspaceView.save(frontendNBT)
UiHandler.root.workspaceView.windowPool.closeAll()
OcelotDesktop.workspace.load(backendNBT)
UiHandler.root.workspaceView.load(frontendNBT)
}

View File

@ -26,6 +26,10 @@ class WindowPool extends Widget with DragHandler {
windows.lastOption.foreach(_.focus())
}
def closeAll(): Unit = {
for (window <- windows) closeWindow(window)
}
def changeFocus(window: Window): Unit = {
windows.lastOption.foreach(_.unfocus())
window.focus()