Skip to content

Commit

Permalink
Merge branch 'fix-thick-border-templates' into 'master'
Browse files Browse the repository at this point in the history
Use thick border textures for thick border UI templates

See merge request OpenMW/openmw!3466
  • Loading branch information
Capostrophic committed Oct 2, 2023
2 parents 08ff69f + 01aa67c commit 97c4c98
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions files/data/scripts/omw/mwui/borders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,52 @@ local cornerParts = {
bottom_right = v2(1, 1),
}

local borderSidePattern = 'textures/menu_thin_border_%s.dds'
local borderCornerPattern = 'textures/menu_thin_border_%s_corner.dds'
local borderSidePattern = 'textures/menu_%s_border_%s.dds'
local borderCornerPattern = 'textures/menu_%s_border_%s_corner.dds'

local borderResources = {}
do
local borderPieces = {}
for _, thickness in ipairs{'thin', 'thick'} do
borderResources[thickness] = {}
for k in pairs(sideParts) do
borderResources[k] = ui.texture{ path = borderSidePattern:format(k) }
borderResources[thickness][k] = ui.texture{ path = borderSidePattern:format(thickness, k) }
end
for k in pairs(cornerParts) do
borderResources[k] = ui.texture{ path = borderCornerPattern:format(k) }
borderResources[thickness][k] = ui.texture{ path = borderCornerPattern:format(thickness, k) }
end
end

local borderPieces = {}
for k in pairs(sideParts) do
local horizontal = k == 'top' or k == 'bottom'
borderPieces[k] = {
type = ui.TYPE.Image,
props = {
resource = borderResources[k],
tileH = horizontal,
tileV = not horizontal,
},
}
end
for k in pairs(cornerParts) do
borderPieces[k] = {
type = ui.TYPE.Image,
props = {
resource = borderResources[k],
},
}
borderPieces[thickness] = {}
for k in pairs(sideParts) do
local horizontal = k == 'top' or k == 'bottom'
borderPieces[thickness][k] = {
type = ui.TYPE.Image,
props = {
resource = borderResources[thickness][k],
tileH = horizontal,
tileV = not horizontal,
},
}
end
for k in pairs(cornerParts) do
borderPieces[thickness][k] = {
type = ui.TYPE.Image,
props = {
resource = borderResources[thickness][k],
},
}
end
end



local function borderTemplates(borderSize)
local function borderTemplates(thickness)
local borderSize = (thickness == 'thin') and constants.border or constants.thickBorder
local borderV = v2(1, 1) * borderSize
local result = {}
result.horizontalLine = {
type = ui.TYPE.Image,
props = {
resource = borderResources.top,
resource = borderResources[thickness].top,
tileH = true,
tileV = false,
size = v2(0, borderSize),
Expand All @@ -75,7 +78,7 @@ local function borderTemplates(borderSize)
result.verticalLine = {
type = ui.TYPE.Image,
props = {
resource = borderResources.left,
resource = borderResources[thickness].left,
tileH = false,
tileV = true,
size = v2(borderSize, 0),
Expand All @@ -90,7 +93,7 @@ local function borderTemplates(borderSize)
local horizontal = k == 'top' or k == 'bottom'
local direction = horizontal and v2(1, 0) or v2(0, 1)
result.borders.content:add {
template = borderPieces[k],
template = borderPieces[thickness][k],
props = {
position = (direction - v) * borderSize,
relativePosition = v,
Expand All @@ -101,7 +104,7 @@ local function borderTemplates(borderSize)
end
for k, v in pairs(cornerParts) do
result.borders.content:add {
template = borderPieces[k],
template = borderPieces[thickness][k],
props = {
position = -v * borderSize,
relativePosition = v,
Expand All @@ -126,7 +129,7 @@ local function borderTemplates(borderSize)
local horizontal = k == 'top' or k == 'bottom'
local direction = horizontal and v2(1, 0) or v2(0, 1)
result.box.content:add {
template = borderPieces[k],
template = borderPieces[thickness][k],
props = {
position = (direction + v) * borderSize,
relativePosition = v,
Expand All @@ -137,7 +140,7 @@ local function borderTemplates(borderSize)
end
for k, v in pairs(cornerParts) do
result.box.content:add {
template = borderPieces[k],
template = borderPieces[thickness][k],
props = {
position = v * borderSize,
relativePosition = v,
Expand Down Expand Up @@ -190,8 +193,8 @@ local function borderTemplates(borderSize)
return result
end

local thinBorders = borderTemplates(constants.border)
local thickBorders = borderTemplates(constants.thickBorder)
local thinBorders = borderTemplates('thin')
local thickBorders = borderTemplates('thick')

return function(templates)
for k, t in pairs(thinBorders) do
Expand All @@ -200,4 +203,4 @@ return function(templates)
for k, t in pairs(thickBorders) do
templates[k .. 'Thick'] = t
end
end
end

0 comments on commit 97c4c98

Please sign in to comment.