1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
-- file: minimap_relative.lua
-- brief: keeps the minimap at a relative size (maxspect)
-- author: Dave Rodgers
--
-- Copyright (C) 2007.
-- Licensed under the terms of the GNU GPL, v2 or later.
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function widget:GetInfo()
return {
name = "RelativeMinimap",
desc = "Keeps the minimap at a relative size (maxspect)",
author = "trepan",
date = "Feb 5, 2007",
license = "GNU GPL, v2 or later",
layer = 0,
enabled = true -- loaded by default?
}
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
-- Adjust these setting to your liking
--
-- offsets, in pixels
local xoff = 2
local yoff = 2
-- maximum fraction of screen size,
-- set one value to 1 to calibrate the other
local xmax = 0.262
local ymax = 0.310
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
-- Make sure these are floored
--
xoff = math.floor(xoff)
yoff = math.floor(yoff)
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function widget:Initialize()
widget:ViewResize(widgetHandler:GetViewSizes())
end
function widget:ViewResize(viewSizeX, viewSizeY)
-- the extra 2 pixels are for the minimap border
local xp = math.floor(viewSizeX * xmax) - xoff - 2
local yp = math.floor(viewSizeY * ymax) - yoff - 2
local limitAspect = (xp / yp)
local mapAspect = (Game.mapSizeX / Game.mapSizeZ)
local sx, sy
if (mapAspect > limitAspect) then
sx = xp
sy = xp / mapAspect
else
sx = yp * mapAspect
sy = yp
end
sx = math.floor(sx)
sy = math.floor(sy)
gl.ConfigMiniMap(xoff, viewSizeY - sy - yoff, sx, sy)
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
|