Scales all in-game UI including text and damage numbers
My monitor is 1080p so I couldn't test this very well. Feel free to make changes if you want
Preview:
SpoilerShow
1 - First you have to be on the new beta branch. On steam, right click the game > Properties > Betas. Add the code "ggllooeegggg" to unlock the secret "nutcracker" beta
2 - Go to "\Documents\Almost Human\legend of grimrock 2". Once the beta is downloaded, you'll see a file named "mods.cfg" and a "Mods" folder
3 - In the Mods folder, create a text file and paste the code from the end of this post, name it "hires.lua" (or any name you want). Confirm when windows ask if you want to change the extension
4 - Add the mod to mods.cfg so it looks like this:
Code: Select all
mods = {
"hires.lua",
}
Mod code:
Code: Select all
-- This file contains sections of Legend of Grimrock 2 source code; anything you
-- do with this file must comply with the Grimrock modding terms:
-- http://www.grimrock.net/modding_log1/modding-and-asset-usage-terms/
--
-- You are free to alter this mod or reuse its code in other Grimrock mods.
--[=[
=== UModManager Info Section ===
id = "HighResScaling"
name = "Hi-Res UI Scaling"
description = [[Forces the in-game UI to scale past 1x.
Made by 7Soul (henriquelazarini@gmail.com)]]
version = "2.0.0"
priority = 10
overwrittenFields = {"Gui.draw", "Gui.presetScaleFactors", "Gui.drawTextParagraph, "ToolTip.drawGeneric"}
=== End of Mod Info ===
]=]
-- Add your resolution to the table here (has to match the resolution that shows in the options menu)
Gui.presetScaleFactors = {
["1600 x 1200"] = 1,
["1920 x 1080"] = 1,
["1920 x 1200"] = 1.1,
["2715 x 1527"] = 1.3,
}
function GameMode:startGame()
self.requestNewGame = true
local uiScaleFactor = Gui.presetScaleFactors[config.resolution]
if not uiScaleFactor then
uiScaleFactor = config.height / 1080
end
-- dispose all scaled fonts
for k,v in pairs(FontType) do
if string.match(k, ".*Scaled$") then
v:dispose()
end
end
FontType.PalatinoScaled = Font.loadTrueType("assets/fonts/palab.ttf", 24 * uiScaleFactor, "stroke")
FontType.PalatinoPlainScaled = Font.loadTrueType("assets/fonts/pala.ttf", 24 * uiScaleFactor, "stroke")
FontType.PalatinoLargeScaled = Font.loadTrueType("assets/fonts/palab.ttf", 30 * uiScaleFactor, "stroke")
FontType.ScrollScaled = Font.loadTrueType("assets/fonts/palai.ttf", 18 * uiScaleFactor)
FontType.ScrollTitleScaled = Font.loadTrueType("assets/fonts/palai.ttf", 28 * uiScaleFactor)
-- create small font
-- HACK: size 12 looks terrible in 1280x720
local size = math.floor(18 * uiScaleFactor + 0.5)
if size == 12 then size = 13 end
self.emulateSmallFontStroke = (size < 14)
if self.emulateSmallFontStroke then
--print("emulating small stroked font")
FontType.PalatinoSmallScaled = Font.loadTrueType("assets/fonts/palab.ttf", size)
else
FontType.PalatinoSmallScaled = Font.loadTrueType("assets/fonts/palab.ttf", size, "stroke")
end
FontType.PalatinoSmallPlainScaled = Font.loadTrueType("assets/fonts/pala.ttf", size, "stroke")
-- create tiny font
local size = 16 * uiScaleFactor
self.emulateTinyFontStroke = (size < 14)
if self.emulateTinyFontStroke then
--print("emulating tiny stroked font")
FontType.PalatinoTinyScaled = Font.loadTrueType("assets/fonts/palab.ttf", size)
else
FontType.PalatinoTinyScaled = Font.loadTrueType("assets/fonts/palab.ttf", size, "stroke")
end
self.fontStrokeColor = {0,0,0,170}
end
--
function Gui:draw()
self:updateLayout()
self:updateColors()
ImmediateMode.beginDraw()
ImmediateMode.setTextureFilterMode("Linear_MipLinear")
local uiScaleFactor = Gui.presetScaleFactors[config.resolution]
if not uiScaleFactor then
uiScaleFactor = config.height / 1080
end
-- setup ui scaling transform for resolutions other than 1920x1080
self:setGuiScaling(uiScaleFactor, 0, 0)
-- draw mouse item info
if self.mouseItem then
local x,y = 70,100
self:drawItemIcon(self.mouseItem, x, y, uiScaleFactor, false)
gui:drawText(self.mouseItem:getFormattedName(), x + 75, y + 45, FontType.PalatinoScaled)
end
-- arrows & action icons
-- scale wrt bottom-right screen corner
self:setGuiScaling(uiScaleFactor, config.width, config.height)
if config.arrowIcons and not charSheet:isVisible() then
self:updateMovementButtons()
end
self.attackPanel:update()
-- scale wrt upper-right screen corner
self:setGuiScaling(uiScaleFactor, config.width, 0)
charSheet:update()
self:resetGuiTransform()
self:updateDragging()
self:updateFloatingTexts()
self:updateHudPrints()
self:updateScrambleText()
if party:isHookRegistered("onDrawGui") then
party:callHook("onDrawGui", gui:createCustomGuiContext())
end
-- draw tool tip
ToolTip.setStyle("rounded_rect")
ToolTip.setRect(0,0, 600,500)
ToolTip.update()
ToolTip.setHint("skill_list", false)
-- draw mouse item
if self.mouseItem then
local mx,my = sys.mousePos()
mx = mx - gameMode.viewport[1]
my = my - gameMode.viewport[2]
local iconSize = 75 * uiScaleFactor -- Item icons don't usually scale, so we need to take it into account when positioning it on the mouse
self:drawItemIcon(self.mouseItem, mx - iconSize/2, my - iconSize/2, uiScaleFactor)
end
self:updateCelestialBodies()
if party:isResting() then
self:drawTextCentered(party.restingText or "Zzzz...", config.width/2, config.height/2, FontType.PalatinoSmall)
end
ImmediateMode.endDraw()
end
-- Scales text paragraphs in order to scale text boxes
local oldGuiDrawTextParagraph = Gui.drawTextParagraph
function Gui:drawTextParagraph(text, x, y, width, font, color)
local uiScaleFactor = self.presetScaleFactors[config.resolution]
if not uiScaleFactor then
uiScaleFactor = config.height / 1080
end
local w,h = oldGuiDrawTextParagraph(self, text, x, y, width*uiScaleFactor, font, color)
return w,h
end