| Line 73: |
Line 73: |
| | end | | end |
| | | | |
| − | local function scaleLayer(hd, layer) | + | local function scaleLayer(scaleWidth, scaleHeight, layer) |
| − | local scale = hd and 1.5 or 1
| |
| | local top, left, right, width, height = layer.top, layer.left, layer.right, (layer.width or layer.height), (layer.height or layer.width) | | local top, left, right, width, height = layer.top, layer.left, layer.right, (layer.width or layer.height), (layer.height or layer.width) |
| | layer.style = layer.style or {} | | layer.style = layer.style or {} |
| | if top then | | if top then |
| − | layer.style.top = _.round(scale * top) .. 'px' | + | layer.style.top = _.round(scaleHeight * top) .. 'px' |
| | end | | end |
| | if left then | | if left then |
| − | layer.style.left = _.round(scale * left) .. 'px' | + | layer.style.left = _.round(scaleWidth * left) .. 'px' |
| | end | | end |
| | if right then | | if right then |
| − | layer.style.right = _.round(scale * right) .. 'px' | + | layer.style.right = _.round(scaleWidth * right) .. 'px' |
| | end | | end |
| | if width and height then | | if width and height then |
| − | layer.size = _.round(scale * width) .. 'x' .. _.round(scale * height) .. 'px' | + | layer.size = _.round(scaleWidth * width) .. 'x' .. _.round(scaleHeight * height) .. 'px' |
| | end | | end |
| | if layer.opacity then | | if layer.opacity then |
| Line 95: |
Line 94: |
| | end | | end |
| | | | |
| − | function ShipBattleCardKai:get_layer(hd, name) | + | function ShipBattleCardKai:get_layer(scaleWidth, scaleHeight, name) |
| − | return scaleLayer(hd, self._battle_card_layers[name]) | + | return scaleLayer(scaleWidth, scaleHeight, self._battle_card_layers[name]) |
| | + | end |
| | + | |
| | + | local function parseSize(s) |
| | + | local width, height = string.match(s, "(%d+)x(%d+)") |
| | + | if width and height then |
| | + | return tonumber(width), tonumber(height) |
| | + | end |
| | end | | end |
| | | | |
| Line 108: |
Line 114: |
| | if not args.size then | | if not args.size then |
| | args.size = args.hd and self._battle_card_size_hd or self._battle_card_size | | args.size = args.hd and self._battle_card_size_hd or self._battle_card_size |
| | + | end |
| | + | local width, height = parseSize(args.size) |
| | + | local scaleWidth = 1 |
| | + | local scaleHeight = 1 |
| | + | if width and height then |
| | + | scaleWidth = width / 160 |
| | + | scaleHeight = height / 40 |
| | end | | end |
| | args.link = link | | args.link = link |
| Line 116: |
Line 129: |
| | if ship_layers then | | if ship_layers then |
| | for i, name in ipairs(ship_layers) do | | for i, name in ipairs(ship_layers) do |
| − | self:_add_layer(stack, self:get_layer(args.hd, name), ship, args, link) | + | self:_add_layer(stack, self:get_layer(scaleWidth, scaleHeight, name), ship, args, link) |
| | end | | end |
| | end | | end |
| | if args.flagship then | | if args.flagship then |
| − | self:_add_layer(stack, self:get_layer(args.hd, 'flagship'), ship, args, link) | + | self:_add_layer(stack, self:get_layer(scaleWidth, scaleHeight, 'flagship'), ship, args, link) |
| | end | | end |
| | if args.layers then | | if args.layers then |
| | for i, name in ipairs(_.split(args.layers)) do | | for i, name in ipairs(_.split(args.layers)) do |
| − | local layer = self:get_layer(args.hd, name) | + | local layer = self:get_layer(scaleWidth, scaleHeight, name) |
| | if layer then | | if layer then |
| | self:_add_layer(stack, layer, ship, args, link) | | self:_add_layer(stack, layer, ship, args, link) |