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.GraphicsCardAdvanced.name=Hochwertige Grafikkarte
|
||||||
oc:item.GraphicsCardBasic.name=Einfache Grafikkarte
|
oc:item.GraphicsCardBasic.name=Einfache Grafikkarte
|
||||||
oc:item.GraphicsCardProfessional.name=Professionelle Grafikkarte
|
oc:item.GraphicsCardProfessional.name=Professionelle Grafikkarte
|
||||||
oc:item.HardDiskDrive2m.name=Festplatte (2MB)
|
oc:item.HardDiskDrive.name=Festplatte
|
||||||
oc:item.HardDiskDrive4m.name=Festplatte (4MB)
|
oc:item.Memory.name=Speicher
|
||||||
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.NetworkCard.name=Netzwerkkarte
|
oc:item.NetworkCard.name=Netzwerkkarte
|
||||||
oc:item.PowerSupply.name=Netzteil
|
oc:item.PowerSupply.name=Netzteil
|
||||||
oc:item.RedstoneCard.name=Redstonekarte
|
oc:item.RedstoneCard.name=Redstonekarte
|
||||||
|
@ -19,12 +19,8 @@ oc:item.Disk.name=Floppy Disk
|
|||||||
oc:item.GraphicsCardAdvanced.name=Advanced Graphics Card
|
oc:item.GraphicsCardAdvanced.name=Advanced Graphics Card
|
||||||
oc:item.GraphicsCardBasic.name=Basic Graphics Card
|
oc:item.GraphicsCardBasic.name=Basic Graphics Card
|
||||||
oc:item.GraphicsCardProfessional.name=Professional Graphics Card
|
oc:item.GraphicsCardProfessional.name=Professional Graphics Card
|
||||||
oc:item.HardDiskDrive2m.name=Hard Disk Drive (2MB)
|
oc:item.HardDiskDrive.name=Hard Disk Drive
|
||||||
oc:item.HardDiskDrive4m.name=Hard Disk Drive (4MB)
|
oc:item.Memory.name=Memory
|
||||||
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.NetworkCard.name=Network Card
|
oc:item.NetworkCard.name=Network Card
|
||||||
oc:item.PowerSupply.name=Power Supply
|
oc:item.PowerSupply.name=Power Supply
|
||||||
oc:item.RedstoneCard.name=Redstone Card
|
oc:item.RedstoneCard.name=Redstone Card
|
||||||
|
@ -27,9 +27,6 @@ local scrollX, scrollY = 0, 0
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
local function setStatus(value)
|
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()
|
local w, h = component.gpu.getResolution()
|
||||||
component.gpu.set(1, h, text.padRight(unicode.sub(value, 1, w - 10), w - 10))
|
component.gpu.set(1, h, text.padRight(unicode.sub(value, 1, w - 10), w - 10))
|
||||||
end
|
end
|
||||||
@ -175,7 +172,7 @@ local function delete()
|
|||||||
component.gpu.copy(1, cy + 2, w, h - (cy + 1), 0, -1)
|
component.gpu.copy(1, cy + 2, w, h - (cy + 1), 0, -1)
|
||||||
component.gpu.set(1, h, text.padRight(buffer[cby + (h - cy)], w))
|
component.gpu.set(1, h, text.padRight(buffer[cby + (h - cy)], w))
|
||||||
end
|
end
|
||||||
setStatus()
|
setStatus("Save: [Ctrl+S] Close: [Ctrl+W]")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -193,6 +190,7 @@ local function insert(value)
|
|||||||
end
|
end
|
||||||
component.gpu.set(cx, cy, value)
|
component.gpu.set(cx, cy, value)
|
||||||
right(len)
|
right(len)
|
||||||
|
setStatus("Save: [Ctrl+S] Close: [Ctrl+W]")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function enter()
|
local function enter()
|
||||||
@ -209,7 +207,7 @@ local function enter()
|
|||||||
component.gpu.set(1, cy + 1, text.padRight(buffer[cby + 1], w))
|
component.gpu.set(1, cy + 1, text.padRight(buffer[cby + 1], w))
|
||||||
end
|
end
|
||||||
setCursor(1, cby + 1)
|
setCursor(1, cby + 1)
|
||||||
setStatus()
|
setStatus("Save: [Ctrl+S] Close: [Ctrl+W]")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onKeyDown(char, code)
|
local function onKeyDown(char, code)
|
||||||
@ -237,13 +235,27 @@ local function onKeyDown(char, code)
|
|||||||
elseif keyboard.isControlDown() then
|
elseif keyboard.isControlDown() then
|
||||||
local cbx, cby = getCursor()
|
local cbx, cby = getCursor()
|
||||||
if code == keyboard.keys.s and not readonly then
|
if code == keyboard.keys.s and not readonly then
|
||||||
local f = io.open(filename, "w")
|
local new = not fs.exists(filename)
|
||||||
for _, line in ipairs(buffer) do
|
local f, reason = io.open(filename, "w")
|
||||||
f:write(line)
|
if f then
|
||||||
f:write("\n")
|
local chars = 0
|
||||||
|
for _, line in ipairs(buffer) do
|
||||||
|
f:write(line)
|
||||||
|
f:write("\n")
|
||||||
|
chars = chars + unicode.len(line)
|
||||||
|
end
|
||||||
|
f:close()
|
||||||
|
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
|
end
|
||||||
f:close()
|
elseif code == keyboard.keys.w or code == keyboard.keys.c or code == keyboard.keys.x then
|
||||||
elseif code == keyboard.keys.w then
|
|
||||||
-- TODO ask to save if changed
|
-- TODO ask to save if changed
|
||||||
running = false
|
running = false
|
||||||
end
|
end
|
||||||
@ -278,18 +290,27 @@ do
|
|||||||
local f = io.open(filename)
|
local f = io.open(filename)
|
||||||
if f then
|
if f then
|
||||||
local w, h = getSize()
|
local w, h = getSize()
|
||||||
|
local chars = 0
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
table.insert(buffer, line)
|
table.insert(buffer, line)
|
||||||
|
chars = chars + unicode.len(line)
|
||||||
if #buffer <= h then
|
if #buffer <= h then
|
||||||
component.gpu.set(1, #buffer, line)
|
component.gpu.set(1, #buffer, line)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
f:close()
|
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
|
else
|
||||||
table.insert(buffer, "")
|
table.insert(buffer, "")
|
||||||
|
setStatus(string.format([["%s" [New File] ]], fs.name(filename)))
|
||||||
end
|
end
|
||||||
setCursor(1, 1)
|
setCursor(1, 1)
|
||||||
setStatus()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
while running do
|
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
|
// power.buffer
|
||||||
var bufferCapacitor = 500.0
|
var bufferCapacitor = 500.0
|
||||||
var bufferConverter = 100.0
|
var bufferConverter = 100.0
|
||||||
var bufferChargingStation = 50000.0 // TODO
|
var bufferChargingStation = 50000.0 // TODO implement
|
||||||
var bufferPowerSupply = 50.0
|
var bufferPowerSupply = 50.0
|
||||||
var bufferRobot = 10000.0
|
var bufferRobot = 10000.0
|
||||||
|
|
||||||
@ -71,6 +71,7 @@ object Config {
|
|||||||
var maxClipboard = 1024
|
var maxClipboard = 1024
|
||||||
var maxUsernameLength = 32
|
var maxUsernameLength = 32
|
||||||
var maxUsers = 16
|
var maxUsers = 16
|
||||||
|
var ramSizes = Array(64, 128, 256)
|
||||||
var startupDelay = 0.25
|
var startupDelay = 0.25
|
||||||
var threads = 4
|
var threads = 4
|
||||||
var timeout = 1.0
|
var timeout = 1.0
|
||||||
@ -78,6 +79,7 @@ object Config {
|
|||||||
// server.filesystem
|
// server.filesystem
|
||||||
var fileCost = 512
|
var fileCost = 512
|
||||||
var bufferChanges = true
|
var bufferChanges = true
|
||||||
|
var hddSizes = Array(2048, 4096, 8192)
|
||||||
var maxHandles = 16
|
var maxHandles = 16
|
||||||
var maxReadBuffer = 8 * 1024
|
var maxReadBuffer = 8 * 1024
|
||||||
|
|
||||||
@ -316,6 +318,14 @@ object Config {
|
|||||||
|amounts of memory by registering an unlimited number of users.
|
|amounts of memory by registering an unlimited number of users.
|
||||||
|See also: `canComputersBeOwned`.""".stripMargin) max 0
|
|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,
|
startupDelay = config.fetch("server.computer.startupDelay", startupDelay,
|
||||||
"""|The time in seconds to wait after a computer has been restored before
|
"""|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
|
|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
|
|since all loaded files have to be kept in memory (loaded as in when
|
||||||
|the hard drive is in a computer).""".stripMargin)
|
|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,
|
maxHandles = config.fetch("server.filesystem.maxHandles", maxHandles,
|
||||||
"""|The maximum number of file handles any single computer may have open
|
"""|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
|
|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)
|
gpu1 = new item.GraphicsCard(multi, 0)
|
||||||
gpu2 = new item.GraphicsCard(multi, 1)
|
gpu2 = new item.GraphicsCard(multi, 1)
|
||||||
gpu3 = new item.GraphicsCard(multi, 2)
|
gpu3 = new item.GraphicsCard(multi, 2)
|
||||||
hdd1 = new item.HardDiskDrive(multi, 2)
|
hdd1 = new item.HardDiskDrive(multi, 0)
|
||||||
hdd2 = new item.HardDiskDrive(multi, 4)
|
hdd2 = new item.HardDiskDrive(multi, 1)
|
||||||
hdd3 = new item.HardDiskDrive(multi, 8)
|
hdd3 = new item.HardDiskDrive(multi, 2)
|
||||||
lan = new item.NetworkCard(multi)
|
lan = new item.NetworkCard(multi)
|
||||||
psu = new item.PowerSupply(multi)
|
psu = new item.PowerSupply(multi)
|
||||||
ram1 = new item.Memory(multi, 32)
|
ram1 = new item.Memory(multi, 0)
|
||||||
ram2 = new item.Memory(multi, 64)
|
ram2 = new item.Memory(multi, 1)
|
||||||
ram3 = new item.Memory(multi, 128)
|
ram3 = new item.Memory(multi, 2)
|
||||||
rs = new item.RedstoneCard(multi)
|
rs = new item.RedstoneCard(multi)
|
||||||
wlan = new item.WirelessNetworkCard(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 addInformation(item: ItemStack, player: EntityPlayer, tooltip: java.util.List[String], advanced: Boolean) {}
|
||||||
|
|
||||||
|
def getItemDisplayName(stack: ItemStack): Option[String] = None
|
||||||
|
|
||||||
def icon: Option[Icon] = _icon
|
def icon: Option[Icon] = _icon
|
||||||
|
|
||||||
protected def icon_=(value: Icon) = _icon = Option(value)
|
protected def icon_=(value: Icon) = _icon = Option(value)
|
||||||
|
@ -77,6 +77,15 @@ class Delegator(id: Int) extends Item(id) {
|
|||||||
case _ => getUnlocalizedName
|
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 getUnlocalizedName: String = Config.namespace + "item"
|
||||||
|
|
||||||
override def isBookEnchantable(itemA: ItemStack, itemB: ItemStack): Boolean = false
|
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.entity.player.EntityPlayer
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
|
|
||||||
class HardDiskDrive(val parent: Delegator, val megaBytes: Int) extends Delegate {
|
class HardDiskDrive(val parent: Delegator, val tier: Int) extends Delegate {
|
||||||
val unlocalizedName = "HardDiskDrive" + megaBytes + "m"
|
val unlocalizedName = "HardDiskDrive"
|
||||||
|
|
||||||
|
val kiloBytes = Config.hddSizes(tier)
|
||||||
|
|
||||||
override def addInformation(item: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) = {
|
override def addInformation(item: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) = {
|
||||||
super.addInformation(item, player, tooltip, advanced)
|
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")
|
val fsNbt = data.getCompoundTag("fs")
|
||||||
if (fsNbt.hasKey("capacity.used")) {
|
if (fsNbt.hasKey("capacity.used")) {
|
||||||
val used = fsNbt.getLong("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) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(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 li.cil.oc.Config
|
||||||
import net.minecraft.client.renderer.texture.IconRegister
|
import net.minecraft.client.renderer.texture.IconRegister
|
||||||
|
import net.minecraft.item.ItemStack
|
||||||
|
|
||||||
class Memory(val parent: Delegator, val kiloBytes: Int) extends Delegate {
|
class Memory(val parent: Delegator, val tier: Int) extends Delegate {
|
||||||
val unlocalizedName = "Memory" + kiloBytes + "k"
|
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) {
|
override def registerIcons(iconRegister: IconRegister) {
|
||||||
super.registerIcons(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
|
case _ => null
|
||||||
}
|
}
|
||||||
} else Items.multi.subItem(item) match {
|
} 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 Some(disk: Disk) => createEnvironment(item, 512 * 1024)
|
||||||
case _ => null
|
case _ => null
|
||||||
}
|
}
|
||||||
|