2022-03-03 03:55:19 +01:00
|
|
|
local dimtable = {
|
2022-03-12 15:18:41 +01:00
|
|
|
design = {width = 1080, height = 1920},
|
|
|
|
screen = {width = nil, height = nil},
|
|
|
|
view = {width = nil, height = nil},
|
|
|
|
ratio = {landscapeUW = 21 / 9, landscapeWide = 16 / 9, landscapeStd = 4 / 3, portrait = 9 / 16},
|
2022-03-03 03:55:19 +01:00
|
|
|
}
|
|
|
|
|
2022-03-26 00:38:30 +01:00
|
|
|
dimtable.transformToScreenSpace = function()
|
2022-03-03 03:55:19 +01:00
|
|
|
gfx.Translate((dimtable.screen.width - dimtable.view.width) / 2, 0);
|
|
|
|
gfx.Scale(dimtable.view.width / dimtable.design.width, dimtable.view.height / dimtable.design.height);
|
|
|
|
gfx.Scissor(0, 0, dimtable.design.width, dimtable.design.height);
|
|
|
|
end
|
|
|
|
|
2022-03-26 00:38:30 +01:00
|
|
|
dimtable.updateResolution = function(ratio)
|
2022-03-12 15:18:41 +01:00
|
|
|
if not ratio then ratio = dimtable.ratio.portrait end
|
2022-03-03 03:55:19 +01:00
|
|
|
|
|
|
|
local screenWidth, screenHeight = game.GetResolution()
|
|
|
|
if screenWidth ~= dimtable.screen.width or screenHeight ~= dimtable.screen.height then
|
|
|
|
dimtable.screen.width, dimtable.screen.height = screenWidth, screenHeight
|
|
|
|
dimtable.view.width, dimtable.view.height = ratio * dimtable.screen.height, dimtable.screen.height
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-03-26 00:38:30 +01:00
|
|
|
return dimtable
|