mirror of
https://github.com/kepler155c/opus
synced 2025-10-17 08:47:39 +00:00
resizing + injector fixes
This commit is contained in:
@@ -103,17 +103,21 @@ return function(env)
|
||||
local sPath = string.gsub(pattern, "%?", fname)
|
||||
-- TODO: if there's no shell, we should not be checking relative paths below
|
||||
-- as they will resolve to root directory
|
||||
if env.shell and type(env.shell.getRunningProgram) == 'function' and sPath:sub(1, 1) ~= "/" then
|
||||
sPath = fs.combine(fs.getDir(env.shell.getRunningProgram() or ''), sPath)
|
||||
end
|
||||
if fs.exists(sPath) and not fs.isDir(sPath) then
|
||||
return loadfile(sPath, env)
|
||||
elseif sPath:match("^(https?:)") then
|
||||
print('loading ' .. sPath)
|
||||
if sPath:match("^(https?:)") then
|
||||
local c = loadUrl(sPath)
|
||||
if c then
|
||||
return load(c, modname, nil, env)
|
||||
end
|
||||
else
|
||||
if env.shell and
|
||||
type(env.shell.getRunningProgram) == 'function' and
|
||||
sPath:sub(1, 1) ~= "/" then
|
||||
|
||||
sPath = fs.combine(fs.getDir(env.shell.getRunningProgram() or ''), sPath)
|
||||
end
|
||||
if fs.exists(sPath) and not fs.isDir(sPath) then
|
||||
return loadfile(sPath, env)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -101,12 +101,17 @@ function Terminal.window(parent, sx, sy, w, h, isVisible)
|
||||
win.setTextColour = win.setTextColor
|
||||
|
||||
function win.getPaletteColor(n)
|
||||
return parent.getPaletteColor(n)
|
||||
if parent.getPaletteColor then
|
||||
return parent.getPaletteColor(n)
|
||||
end
|
||||
return 0, 0, 0
|
||||
end
|
||||
win.getPaletteColour = win.getPaletteColor
|
||||
|
||||
function win.setPaletteColor(n, r, g, b)
|
||||
return parent.setPaletteColor(n, r, g, b)
|
||||
if parent.setPaletteColor then
|
||||
return parent.setPaletteColor(n, r, g, b)
|
||||
end
|
||||
end
|
||||
win.setPaletteColour = win.setPaletteColor
|
||||
|
||||
|
@@ -504,9 +504,7 @@ function UI.Window:layout()
|
||||
end
|
||||
end
|
||||
|
||||
-- bad name... should be called something like postInit
|
||||
-- normally used to determine sizes since the parent is
|
||||
-- only known at this point
|
||||
-- Called when the window's parent has be assigned
|
||||
function UI.Window:setParent()
|
||||
self.oh, self.ow = self.height, self.width
|
||||
self.ox, self.oy = self.x, self.y
|
||||
|
@@ -66,6 +66,7 @@ function Canvas:resize(w, h)
|
||||
for i = 1, self.height do
|
||||
self.lines[i] = { dirty = true }
|
||||
end
|
||||
self:clear()
|
||||
end
|
||||
|
||||
self.ex = self.x + w - 1
|
||||
@@ -261,10 +262,20 @@ function Canvas:applyPalette(palette)
|
||||
end
|
||||
|
||||
function Canvas:render(device)
|
||||
local offset = { x = 0, y = 0 }
|
||||
local parent = self.parent
|
||||
while parent do
|
||||
offset.x = offset.x + parent.x - 1
|
||||
offset.y = offset.y + parent.y - 1
|
||||
parent = parent.parent
|
||||
end
|
||||
if #self.layers > 0 then
|
||||
self:__renderLayers(device, { x = 0, y = 0 })
|
||||
self:__renderLayers(device, offset)
|
||||
else
|
||||
self:__blitRect(device)
|
||||
self:__blitRect(device, nil, {
|
||||
x = self.x + offset.x,
|
||||
y = self.y + offset.y
|
||||
})
|
||||
self:clean()
|
||||
end
|
||||
end
|
||||
@@ -316,14 +327,10 @@ function Canvas:__renderLayers(device, offset)
|
||||
self.regions = nil
|
||||
|
||||
else
|
||||
offset = { x = self.x, y = self.y }
|
||||
local parent = self.parent
|
||||
while parent do
|
||||
offset.x = offset.x + parent.x - 1
|
||||
offset.y = offset.y + parent.y - 1
|
||||
parent = parent.parent
|
||||
end
|
||||
self:__blitRect(device, nil, offset)
|
||||
self:__blitRect(device, nil, {
|
||||
x = self.x + offset.x,
|
||||
y = self.y + offset.y
|
||||
})
|
||||
self.regions = nil
|
||||
end
|
||||
self:clean()
|
||||
|
@@ -7,12 +7,13 @@ UI.SlideOut.defaults = {
|
||||
UIElement = 'SlideOut',
|
||||
pageType = 'modal',
|
||||
}
|
||||
function UI.SlideOut:setParent()
|
||||
-- TODO: size should be set at this point
|
||||
self:layout()
|
||||
self.canvas = self:addLayer()
|
||||
|
||||
UI.Window.setParent(self)
|
||||
function UI.SlideOut:layout()
|
||||
UI.Window.layout(self)
|
||||
if not self.canvas then
|
||||
self.canvas = self:addLayer()
|
||||
else
|
||||
self.canvas:resize(self.width, self.height)
|
||||
end
|
||||
end
|
||||
|
||||
function UI.SlideOut:enable()
|
||||
|
@@ -19,9 +19,13 @@ UI.Viewport.defaults = {
|
||||
[ 'control-f' ] = 'scroll_pageDown',
|
||||
},
|
||||
}
|
||||
function UI.Viewport:setParent()
|
||||
UI.Window.setParent(self)
|
||||
self.canvas = self:addLayer()
|
||||
function UI.Viewport:layout()
|
||||
UI.Window.layout(self)
|
||||
if not self.canvas then
|
||||
self.canvas = self:addLayer()
|
||||
else
|
||||
self.canvas:resize(self.width, self.height)
|
||||
end
|
||||
end
|
||||
|
||||
function UI.Viewport:enable()
|
||||
|
Reference in New Issue
Block a user