Permalink
Browse files

Update mainmenu selection

  • Loading branch information...
TheCycoONE committed Sep 20, 2018
1 parent 302ed68 commit 1e20b1013810ce5af93975926284d3cca765c29b
Showing with 25 additions and 6 deletions.
  1. +25 −6 CorsixTH/Lua/ui.lua
@@ -393,15 +393,34 @@ function UI:removeKeyHandler(keys, window)
end
end

local menu_bg_sizes = { -- Available menu background sizes
{1920, 1080},
}

--! Set the menu background image
--!
--! The menu size closest to, but no larger than the height of the currently
--! set game window is selected. If no image fits that criteria the smallest
--! available image is used.
function UI:setMenuBackground()
local bg_size = menu_bg_sizes[1]
self.background = self.app.gfx:loadRaw("mainmenu" .. bg_size[2], bg_size[1], bg_size[2], "Bitmap")
local screen_h = self.app.config.height
local bg_size_idx = 1

-- Available mainmenu*.bmp sizes
local menu_bg_sizes = {
{640, 480},
{1280, 720},
{1920, 1080},
}

for i, bg_size in ipairs(menu_bg_sizes) do
if screen_h >= bg_size[2] then
bg_size_idx = i
else
break
end
end

local bg_size = menu_bg_sizes[bg_size_idx]
self.background_width = bg_size[1]
self.background_height = bg_size[2]
self.background = self.app.gfx:loadRaw("mainmenu" .. bg_size[2], bg_size[1], bg_size[2], "Bitmap")
end

function UI:onChangeResolution()

0 comments on commit 1e20b10

Please sign in to comment.