Permalink
Browse files

Merge pull request #1472 from TheCycoONE/reduced_mainmenu

[RDY] mainmenu background sizes
  • Loading branch information...
Alberth289346 committed Sep 20, 2018
2 parents ce473fd + 1e20b10 commit 15ad40e5d3eb799b1c902db39bbd6f7dd95fca8e
@@ -45,7 +45,7 @@ function open(filename)
end
local bits_offset, header_size = LE(file:read(4)), LE(file:read(4))
if header_size ~= 40 then
return nil, "Expected BITMAPINFOHEADER"
return nil, "Expected BITMAPINFOHEADER. Header size was " .. header_size
end
local width, height = LE(file:read(4)), LE(file:read(4))
local planes, bpp = LE(file:read(2)), LE(file:read(2))
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.
@@ -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 15ad40e

Please sign in to comment.