mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Merge branch 'master' of github.com:MightyPirates/OpenComputers into master-MC1.7.10
This commit is contained in:
commit
c7e8beece6
@ -445,6 +445,17 @@ local keyBindHandlers = {
|
|||||||
save = function()
|
save = function()
|
||||||
if readonly then return end
|
if readonly then return end
|
||||||
local new = not fs.exists(filename)
|
local new = not fs.exists(filename)
|
||||||
|
local backup
|
||||||
|
if not new then
|
||||||
|
backup = filename .. "~"
|
||||||
|
for i = 1, math.huge do
|
||||||
|
if not fs.exists(backup) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
backup = filename .. "~" .. i
|
||||||
|
end
|
||||||
|
fs.copy(filename, backup)
|
||||||
|
end
|
||||||
local f, reason = io.open(filename, "w")
|
local f, reason = io.open(filename, "w")
|
||||||
if f then
|
if f then
|
||||||
local chars, firstLine = 0, true
|
local chars, firstLine = 0, true
|
||||||
@ -467,6 +478,9 @@ local keyBindHandlers = {
|
|||||||
else
|
else
|
||||||
setStatus(reason)
|
setStatus(reason)
|
||||||
end
|
end
|
||||||
|
if not new then
|
||||||
|
fs.remove(backup)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
close = function()
|
close = function()
|
||||||
-- TODO ask to save if changed
|
-- TODO ask to save if changed
|
||||||
|
@ -12,10 +12,10 @@ import scala.collection.convert.WrapAsScala._
|
|||||||
|
|
||||||
abstract class Player(val playerInventory: InventoryPlayer, val otherInventory: IInventory) extends Container {
|
abstract class Player(val playerInventory: InventoryPlayer, val otherInventory: IInventory) extends Container {
|
||||||
/** Number of player inventory slots to display horizontally. */
|
/** Number of player inventory slots to display horizontally. */
|
||||||
protected val playerInventorySizeX = InventoryPlayer.getHotbarSize
|
protected val playerInventorySizeX = math.min(9, InventoryPlayer.getHotbarSize)
|
||||||
|
|
||||||
/** Subtract four for armor slots. */
|
/** Subtract four for armor slots. */
|
||||||
protected val playerInventorySizeY = (playerInventory.getSizeInventory - 4) / playerInventorySizeX
|
protected val playerInventorySizeY = math.min(4, (playerInventory.getSizeInventory - 4) / playerInventorySizeX)
|
||||||
|
|
||||||
/** Render size of slots (width and height). */
|
/** Render size of slots (width and height). */
|
||||||
protected val slotSize = 18
|
protected val slotSize = 18
|
||||||
@ -116,7 +116,7 @@ abstract class Player(val playerInventory: InventoryPlayer, val otherInventory:
|
|||||||
|
|
||||||
// Show the quick slot bar below the internal inventory.
|
// Show the quick slot bar below the internal inventory.
|
||||||
val quickBarSpacing = 4
|
val quickBarSpacing = 4
|
||||||
for (index <- 0 until InventoryPlayer.getHotbarSize) {
|
for (index <- 0 until playerInventorySizeX) {
|
||||||
val x = left + index * slotSize
|
val x = left + index * slotSize
|
||||||
val y = top + slotSize * (playerInventorySizeY - 1) + quickBarSpacing
|
val y = top + slotSize * (playerInventorySizeY - 1) + quickBarSpacing
|
||||||
addSlotToContainer(new Slot(playerInventory, index, x, y))
|
addSlotToContainer(new Slot(playerInventory, index, x, y))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user