made ram and disk sizes for the three tiers configurable and generalized their localization method (not one per tier but one for all that gets extended based on the tier); more informative status bare messages for text editor
@ -19,12 +19,8 @@ oc:item.Disk.name=Diskette
|
||||
oc:item.GraphicsCardAdvanced.name=Hochwertige Grafikkarte
|
||||
oc:item.GraphicsCardBasic.name=Einfache Grafikkarte
|
||||
oc:item.GraphicsCardProfessional.name=Professionelle Grafikkarte
|
||||
oc:item.HardDiskDrive2m.name=Festplatte (2MB)
|
||||
oc:item.HardDiskDrive4m.name=Festplatte (4MB)
|
||||
oc:item.HardDiskDrive8m.name=Festplatte (8MB)
|
||||
oc:item.Memory128k.name=RAM (128KB)
|
||||
oc:item.Memory32k.name=RAM (32KB)
|
||||
oc:item.Memory64k.name=RAM (64KB)
|
||||
oc:item.HardDiskDrive.name=Festplatte
|
||||
oc:item.Memory.name=Speicher
|
||||
oc:item.NetworkCard.name=Netzwerkkarte
|
||||
oc:item.PowerSupply.name=Netzteil
|
||||
oc:item.RedstoneCard.name=Redstonekarte
|
||||
|
@ -19,12 +19,8 @@ oc:item.Disk.name=Floppy Disk
|
||||
oc:item.GraphicsCardAdvanced.name=Advanced Graphics Card
|
||||
oc:item.GraphicsCardBasic.name=Basic Graphics Card
|
||||
oc:item.GraphicsCardProfessional.name=Professional Graphics Card
|
||||
oc:item.HardDiskDrive2m.name=Hard Disk Drive (2MB)
|
||||
oc:item.HardDiskDrive4m.name=Hard Disk Drive (4MB)
|
||||
oc:item.HardDiskDrive8m.name=Hard Disk Drive (8MB)
|
||||
oc:item.Memory128k.name=RAM (128KB)
|
||||
oc:item.Memory32k.name=RAM (32KB)
|
||||
oc:item.Memory64k.name=RAM (64KB)
|
||||
oc:item.HardDiskDrive.name=Hard Disk Drive
|
||||
oc:item.Memory.name=Memory
|
||||
oc:item.NetworkCard.name=Network Card
|
||||
oc:item.PowerSupply.name=Power Supply
|
||||
oc:item.RedstoneCard.name=Redstone Card
|
||||
|
@ -27,9 +27,6 @@ local scrollX, scrollY = 0, 0
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local function setStatus(value)
|
||||
if not value then
|
||||
value = string.format([["%s" %dL Menu: [Ctrl] ]], fs.name(filename), #buffer)
|
||||
end
|
||||
local w, h = component.gpu.getResolution()
|
||||
component.gpu.set(1, h, text.padRight(unicode.sub(value, 1, w - 10), w - 10))
|
||||
end
|
||||
@ -175,7 +172,7 @@ local function delete()
|
||||
component.gpu.copy(1, cy + 2, w, h - (cy + 1), 0, -1)
|
||||
component.gpu.set(1, h, text.padRight(buffer[cby + (h - cy)], w))
|
||||
end
|
||||
setStatus()
|
||||
setStatus("Save: [Ctrl+S] Close: [Ctrl+W]")
|
||||
end
|
||||
end
|
||||
|
||||
@ -193,6 +190,7 @@ local function insert(value)
|
||||
end
|
||||
component.gpu.set(cx, cy, value)
|
||||
right(len)
|
||||
setStatus("Save: [Ctrl+S] Close: [Ctrl+W]")
|
||||
end
|
||||
|
||||
local function enter()
|
||||
@ -209,7 +207,7 @@ local function enter()
|
||||
component.gpu.set(1, cy + 1, text.padRight(buffer[cby + 1], w))
|
||||
end
|
||||
setCursor(1, cby + 1)
|
||||
setStatus()
|
||||
setStatus("Save: [Ctrl+S] Close: [Ctrl+W]")
|
||||
end
|
||||
|
||||
local function onKeyDown(char, code)
|
||||
@ -237,13 +235,27 @@ local function onKeyDown(char, code)
|
||||
elseif keyboard.isControlDown() then
|
||||
local cbx, cby = getCursor()
|
||||
if code == keyboard.keys.s and not readonly then
|
||||
local f = io.open(filename, "w")
|
||||
local new = not fs.exists(filename)
|
||||
local f, reason = io.open(filename, "w")
|
||||
if f then
|
||||
local chars = 0
|
||||
for _, line in ipairs(buffer) do
|
||||
f:write(line)
|
||||
f:write("\n")
|
||||
chars = chars + unicode.len(line)
|
||||
end
|
||||
f:close()
|
||||
elseif code == keyboard.keys.w then
|
||||
local format
|
||||
if new then
|
||||
format = [["%s" [New] %dL,%dC written]]
|
||||
else
|
||||
format = [["%s" %dL,%dC written]]
|
||||
end
|
||||
setStatus(string.format(format, fs.name(filename), #buffer, chars))
|
||||
else
|
||||
setStatus(reason)
|
||||
end
|
||||
elseif code == keyboard.keys.w or code == keyboard.keys.c or code == keyboard.keys.x then
|
||||
-- TODO ask to save if changed
|
||||
running = false
|
||||
end
|
||||
@ -278,18 +290,27 @@ do
|
||||
local f = io.open(filename)
|
||||
if f then
|
||||
local w, h = getSize()
|
||||
local chars = 0
|
||||
for line in f:lines() do
|
||||
table.insert(buffer, line)
|
||||
chars = chars + unicode.len(line)
|
||||
if #buffer <= h then
|
||||
component.gpu.set(1, #buffer, line)
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
local format
|
||||
if readonly then
|
||||
format = [["%s" [readonly] %dL,%dC]]
|
||||
else
|
||||
format = [["%s" [New File] %dL,%dC]]
|
||||
end
|
||||
setStatus(string.format(format, fs.name(filename), #buffer, chars))
|
||||
else
|
||||
table.insert(buffer, "")
|
||||
setStatus(string.format([["%s" [New File] ]], fs.name(filename)))
|
||||
end
|
||||
setCursor(1, 1)
|
||||
setStatus()
|
||||
end
|
||||
|
||||
while running do
|
||||
|
BIN
assets/opencomputers/textures/items/hdd0.png
Normal file
After Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 265 B After Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 265 B |
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 211 B |
Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 212 B |
Before Width: | Height: | Size: 227 B After Width: | Height: | Size: 227 B |
@ -42,7 +42,7 @@ object Config {
|
||||
// power.buffer
|
||||
var bufferCapacitor = 500.0
|
||||
var bufferConverter = 100.0
|
||||
var bufferChargingStation = 50000.0 // TODO
|
||||
var bufferChargingStation = 50000.0 // TODO implement
|
||||
var bufferPowerSupply = 50.0
|
||||
var bufferRobot = 10000.0
|
||||
|
||||
@ -71,6 +71,7 @@ object Config {
|
||||
var maxClipboard = 1024
|
||||
var maxUsernameLength = 32
|
||||
var maxUsers = 16
|
||||
var ramSizes = Array(64, 128, 256)
|
||||
var startupDelay = 0.25
|
||||
var threads = 4
|
||||
var timeout = 1.0
|
||||
@ -78,6 +79,7 @@ object Config {
|
||||
// server.filesystem
|
||||
var fileCost = 512
|
||||
var bufferChanges = true
|
||||
var hddSizes = Array(2048, 4096, 8192)
|
||||
var maxHandles = 16
|
||||
var maxReadBuffer = 8 * 1024
|
||||
|
||||
@ -316,6 +318,14 @@ object Config {
|
||||
|amounts of memory by registering an unlimited number of users.
|
||||
|See also: `canComputersBeOwned`.""".stripMargin) max 0
|
||||
|
||||
ramSizes = (config.fetch("server.computer.ramSizes", ramSizes,
|
||||
"""|The sizes of the three tiers of RAM, in kilobytes. If this list is
|
||||
|longer than three entries, the remaining ones will be ignored. If the
|
||||
|list is shorter it will be filled up with the default values, assuming
|
||||
|the given values (if any) are the lower tiers.""".stripMargin).
|
||||
map(_ max 0).padTo(3, Int.MinValue), ramSizes).zipped.
|
||||
map((a, b) => if (a >= 0) a else b)
|
||||
|
||||
startupDelay = config.fetch("server.computer.startupDelay", startupDelay,
|
||||
"""|The time in seconds to wait after a computer has been restored before
|
||||
|it continues to run. This is meant to allow the world around the
|
||||
@ -358,6 +368,14 @@ object Config {
|
||||
|since all loaded files have to be kept in memory (loaded as in when
|
||||
|the hard drive is in a computer).""".stripMargin)
|
||||
|
||||
hddSizes = (config.fetch("server.computer.hddSizes", hddSizes,
|
||||
"""|The sizes of the three tiers of hard drives, in kilobytes. If this
|
||||
|list is longer than three entries, the remaining ones will be ignored.
|
||||
|If the list is shorter it will be filled up with the default values,
|
||||
|assuming the given values (if any) are the lower tiers.""".stripMargin).
|
||||
map(_ max 0).padTo(3, Int.MinValue), hddSizes).zipped.
|
||||
map((a, b) => if (a >= 0) a else b)
|
||||
|
||||
maxHandles = config.fetch("server.filesystem.maxHandles", maxHandles,
|
||||
"""|The maximum number of file handles any single computer may have open
|
||||
|at a time. Note that this is *per filesystem*. Also note that this is
|
||||
|
@ -25,14 +25,14 @@ object Items {
|
||||
gpu1 = new item.GraphicsCard(multi, 0)
|
||||
gpu2 = new item.GraphicsCard(multi, 1)
|
||||
gpu3 = new item.GraphicsCard(multi, 2)
|
||||
hdd1 = new item.HardDiskDrive(multi, 2)
|
||||
hdd2 = new item.HardDiskDrive(multi, 4)
|
||||
hdd3 = new item.HardDiskDrive(multi, 8)
|
||||
hdd1 = new item.HardDiskDrive(multi, 0)
|
||||
hdd2 = new item.HardDiskDrive(multi, 1)
|
||||
hdd3 = new item.HardDiskDrive(multi, 2)
|
||||
lan = new item.NetworkCard(multi)
|
||||
psu = new item.PowerSupply(multi)
|
||||
ram1 = new item.Memory(multi, 32)
|
||||
ram2 = new item.Memory(multi, 64)
|
||||
ram3 = new item.Memory(multi, 128)
|
||||
ram1 = new item.Memory(multi, 0)
|
||||
ram2 = new item.Memory(multi, 1)
|
||||
ram3 = new item.Memory(multi, 2)
|
||||
rs = new item.RedstoneCard(multi)
|
||||
wlan = new item.WirelessNetworkCard(multi)
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ trait Delegate {
|
||||
|
||||
def addInformation(item: ItemStack, player: EntityPlayer, tooltip: java.util.List[String], advanced: Boolean) {}
|
||||
|
||||
def getItemDisplayName(stack: ItemStack): Option[String] = None
|
||||
|
||||
def icon: Option[Icon] = _icon
|
||||
|
||||
protected def icon_=(value: Icon) = _icon = Option(value)
|
||||
|
@ -77,6 +77,15 @@ class Delegator(id: Int) extends Item(id) {
|
||||
case _ => getUnlocalizedName
|
||||
}
|
||||
|
||||
override def getItemDisplayName(stack: ItemStack) =
|
||||
subItem(stack) match {
|
||||
case Some(subItem) => subItem.getItemDisplayName(stack) match {
|
||||
case Some(name) => name
|
||||
case _ => super.getItemDisplayName(stack)
|
||||
}
|
||||
case _ => super.getItemDisplayName(stack)
|
||||
}
|
||||
|
||||
override def getUnlocalizedName: String = Config.namespace + "item"
|
||||
|
||||
override def isBookEnchantable(itemA: ItemStack, itemB: ItemStack): Boolean = false
|
||||
|
@ -6,8 +6,10 @@ import net.minecraft.client.renderer.texture.IconRegister
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
class HardDiskDrive(val parent: Delegator, val megaBytes: Int) extends Delegate {
|
||||
val unlocalizedName = "HardDiskDrive" + megaBytes + "m"
|
||||
class HardDiskDrive(val parent: Delegator, val tier: Int) extends Delegate {
|
||||
val unlocalizedName = "HardDiskDrive"
|
||||
|
||||
val kiloBytes = Config.hddSizes(tier)
|
||||
|
||||
override def addInformation(item: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) = {
|
||||
super.addInformation(item, player, tooltip, advanced)
|
||||
@ -26,16 +28,26 @@ class HardDiskDrive(val parent: Delegator, val megaBytes: Int) extends Delegate
|
||||
val fsNbt = data.getCompoundTag("fs")
|
||||
if (fsNbt.hasKey("capacity.used")) {
|
||||
val used = fsNbt.getLong("capacity.used")
|
||||
tooltip.add("Disk usage: %d/%d Byte".format(used, megaBytes * 1024 * 1024))
|
||||
tooltip.add("Disk usage: %d/%d Byte".format(used, kiloBytes * 1024))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def getItemDisplayName(stack: ItemStack) = {
|
||||
val localizedName = parent.getItemStackDisplayName(stack)
|
||||
Some(if (kiloBytes >= 1024) {
|
||||
localizedName + " (%dMB)".format(kiloBytes / 1024)
|
||||
}
|
||||
else {
|
||||
localizedName + " (%dKB)".format(kiloBytes)
|
||||
})
|
||||
}
|
||||
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Config.resourceDomain + ":hdd" + megaBytes)
|
||||
icon = iconRegister.registerIcon(Config.resourceDomain + ":hdd" + tier)
|
||||
}
|
||||
}
|
@ -2,13 +2,19 @@ package li.cil.oc.common.item
|
||||
|
||||
import li.cil.oc.Config
|
||||
import net.minecraft.client.renderer.texture.IconRegister
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
class Memory(val parent: Delegator, val kiloBytes: Int) extends Delegate {
|
||||
val unlocalizedName = "Memory" + kiloBytes + "k"
|
||||
class Memory(val parent: Delegator, val tier: Int) extends Delegate {
|
||||
val unlocalizedName = "Memory"
|
||||
|
||||
val kiloBytes = Config.ramSizes(tier)
|
||||
|
||||
override def getItemDisplayName(stack: ItemStack) =
|
||||
Some(parent.getItemStackDisplayName(stack) + " (%dKB)".format(kiloBytes))
|
||||
|
||||
override def registerIcons(iconRegister: IconRegister) {
|
||||
super.registerIcons(iconRegister)
|
||||
|
||||
icon = iconRegister.registerIcon(Config.resourceDomain + ":ram" + kiloBytes)
|
||||
icon = iconRegister.registerIcon(Config.resourceDomain + ":ram" + tier)
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ object FileSystem extends Item {
|
||||
case _ => null
|
||||
}
|
||||
} else Items.multi.subItem(item) match {
|
||||
case Some(hdd: HardDiskDrive) => createEnvironment(item, hdd.megaBytes * 1024 * 1024)
|
||||
case Some(hdd: HardDiskDrive) => createEnvironment(item, hdd.kiloBytes * 1024)
|
||||
case Some(disk: Disk) => createEnvironment(item, 512 * 1024)
|
||||
case _ => null
|
||||
}
|
||||
|