diff --git a/src/main/resources/data/opencomputers/opencomputers/loot_disks/openos/bin/resolution.lua b/src/main/resources/data/opencomputers/opencomputers/loot_disks/openos/bin/resolution.lua index 6c1bfce717..d171e05cfe 100644 --- a/src/main/resources/data/opencomputers/opencomputers/loot_disks/openos/bin/resolution.lua +++ b/src/main/resources/data/opencomputers/opencomputers/loot_disks/openos/bin/resolution.lua @@ -1,9 +1,19 @@ local shell = require("shell") local tty = require("tty") -local args = shell.parse(...) +local args, ops = shell.parse(...) local gpu = tty.gpu() +if ops["max"] then + local w, h = gpu.maxResolution() + io.write(w," ",h,"\n") + local limiter = gpu.capabilityLimiter() + if limiter then + io.write("(Limited by ",limiter,")\n") + end + return +end + if #args == 0 then local w, h = gpu.getViewport() io.write(w," ",h,"\n") @@ -11,7 +21,7 @@ if #args == 0 then end if #args ~= 2 then - print("Usage: resolution [ ]") + print("Usage: resolution [ ] or resolution --max") return end diff --git a/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala b/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala index 6284d29991..bae99d2563 100644 --- a/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala +++ b/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala @@ -436,6 +436,25 @@ class GraphicsCard(val tier: Int, val vramScreens: Option[Double] = None, val vi result(math.min(gmw, smw), math.min(gmh, smh)) }) + @Callback(direct = true, doc = """function():string or nil -- Return which of GPU or screen is limiting display capabilities, if either""") + def capabilityLimiter(context: Context, args: Arguments): Array[AnyRef] = + // FIXME: Assumes that GPU/screen tiers do not differ only by color depth, + // which is *currently* valid but may not be in the future. It would be + // better to just use the tier values directly, but I couldn't figure out + // how to access the physical screen from the TextBuffer... + screen(s => { + val gmw = maxResolution._1 + val smw = s.getMaximumWidth + result( + if (gmw > smw) + "screen" + else if (gmw < smw) + "gpu" + else // Equal, so neither is limiting + null + ) + }) + @Callback(direct = true, doc = """function():number, number -- Get the current viewport resolution.""") def getViewport(context: Context, args: Arguments): Array[AnyRef] = screen(s => result(s.getViewportWidth, s.getViewportHeight))