Skip to content

Commit

Permalink
v3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bellyillish committed Dec 4, 2024
1 parent 75f6ef8 commit 7abe63a
Show file tree
Hide file tree
Showing 136 changed files with 301 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ function correctX(x, targetRatio, settings)
if x and align and align[1] and align[1] ~= anchor1 then
if align[1] == "CENTER" then
l = Dart.baseWidth / 2 - (r - l) / 2
r = Dart.baseWidth / 2 + (r - l) / 2
r = Dart.baseWidth / 2 + (r - bounds.l) / 2
x = x + (l - bounds.l)
else
l = Dart.baseWidth - r
r = Dart.baseWidth - l
r = Dart.baseWidth - bounds.l
x = x + (l - bounds.l)
end

Expand Down Expand Up @@ -270,11 +270,11 @@ function correctY(y, targetRatio, settings)
if y and align and align[2] and align[2] ~= anchor2 then
if align[2] == "CENTER" then
t = Dart.baseHeight / 2 - (b - t) / 2
b = Dart.baseHeight / 2 + (b - t) / 2
b = Dart.baseHeight / 2 + (b - bounds.t) / 2
y = y + (t - bounds.t)
else
t = Dart.baseHeight - t
b = Dart.baseHeight - b
t = Dart.baseHeight - b
b = Dart.baseHeight - bounds.t
y = y + (t - bounds.t)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ function mcmOnLoad(options)
MCM.getOffsetXField({def = config.offset[1]}),
MCM.getOffsetYField({def = config.offset[2]}),
MCM.getLine(),
MCM.getSpacingField({hint = "dart_statusIcons_spacing", def = config.spacing}),
MCM.getSpacingField({
hint = "dart_statusIcons_spacing",
def = config.spacing,
min = -128,
max = 128
}),
}
}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ end


function mcmOnLoad(options)
options[11] = {
options[7] = {
id = "dart_pda",
sh = true,
gr = {
Expand Down Expand Up @@ -65,12 +65,21 @@ function onPreRefresh()

ui_pda_contacts_tab.SINGLETON = null
ui_pda_encyclopedia_tab.SINGLETON = null
ui_pda_glitched_tab.SINGLETON = null
ui_pda_npc_tab.SINGLETON = null
ui_pda_radio_tab.SINGLETON = null
ui_pda_relations_tab.SINGLETON = null
ui_pda_taskboard_tab.SINGLETON = null
ui_pda_warfare_tab.SINGLETON = null
ui_pda_radio_tab.SINGLETON = null
ui_pda_npc_tab.SINGLETON = null

if ui_pda_glitched_tab then
ui_pda_glitched_tab.SINGLETON = null
end

if ui_pda_taskboard_tab then
ui_pda_taskboard_tab.SINGLETON = null
end

if ui_pda_warfare_tab then
ui_pda_warfare_tab.SINGLETON = null
end
end


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@
<string id="ui_mcm_dart_minimap_clockOffsetY_desc">
<text>Adjust the vertical position of the clock. Positive values move it down. Negative values move it up.</text>
</string>

<string id="ui_mcm_dart_minimap_clockOffset_note">
<text>NOTE: this only affects the circular minimap because the clock position is fixed in the square minimap.</text>
</string>
</string_table>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ end


function mcmOnLoad(options)
options[7] = {
options[6] = {
id = "dart_minimap",
sh = true,
gr = {
Expand Down Expand Up @@ -81,6 +81,7 @@ function mcmOnLoad(options)
hint = "dart_minimap_clockOffsetY",
def = config.clockOffset[2]
}),
MCM.getNote({text = "ui_mcm_dart_minimap_clockOffset_note"}),
}
}
end
Expand Down
130 changes: 130 additions & 0 deletions 00 i - Minimap & Compass/gamedata/scripts/modxml_z_dart_minimap.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
local Dart = dart_core
local Utils = dart_utils
local Module = dart_module


local mod = "minimap"


function parseCircularMap(XML, config)
local compass = XML:query("minimap > compass")[1]
local frame = XML:query("minimap > level_frame")[1]
local bg = XML:query("minimap > background")[1]
local clock = XML:query("minimap > clock_wnd")[1]

local compassAttrs = XML:safeGetAttrs(compass)
local frameAttrs = XML:safeGetAttrs(frame)
local bgAttrs = XML:safeGetAttrs(bg)

local scaleSettings = Utils.merge(config, {
bounds = {
l = (frameAttrs.x * Dart.baseHeight - compassAttrs.width / 2),
t = (frameAttrs.y * Dart.baseHeight - compassAttrs.height / 2),
r = (frameAttrs.x * Dart.baseHeight + compassAttrs.width / 2),
b = (frameAttrs.y * Dart.baseHeight + compassAttrs.height / 2),
}
})

XML:safeSetAttrs(frame, function(attrs)
local dumbUnits = Dart.baseHeight
return {
x = Utils.correctX(attrs.x * dumbUnits, XML.aspectRatio, scaleSettings) / dumbUnits,
y = Utils.correctY(attrs.y * dumbUnits, XML.aspectRatio, scaleSettings) / dumbUnits,
width = attrs.width * config.scale,
height = attrs.height * config.scale,
a = config.alpha,
}
end)

XML:safeSetAttrs(compass, function(attrs)
return {
width = attrs.width * config.scale,
height = attrs.height * config.scale,
}
end)

XML:safeSetAttrs(bg, function(attrs)
return {
width = attrs.width * config.scale,
height = attrs.height * config.scale,
}
end)

XML:safeSetAttrs(clock, function(attrs)
local dumbUnits = bgAttrs.height * Dart.baseHeight
return {
x = (attrs.x * dumbUnits + config.clockOffset[1] / Utils.getAspectRatioVs(Dart.ratio4x3)) / dumbUnits,
y = (attrs.y * dumbUnits + config.clockOffset[2] / Utils.getAspectRatioVs(Dart.ratio4x3)) / dumbUnits,
}
end)
end


function parseSquareMap(XML, config)
local compass = XML:query("minimap > compass")[1]
local frame = XML:query("minimap > level_frame")[1]
local bg = XML:query("minimap > background")[1]
local counter = XML:query("minimap > static_counter")[1]

local frameAttrs = XML:safeGetAttrs(frame)
local width = math.max(frameAttrs.width, frameAttrs.height)
local height = math.min(frameAttrs.width, frameAttrs.height)

local scaleSettings = Utils.merge(config, {
anchor = {"LEFT", "TOP"},
bounds = {
l = (frameAttrs.x - width / 2) * Dart.baseHeight,
r = (frameAttrs.x + width / 2) * Dart.baseHeight,
t = (frameAttrs.y - height / 2) * Dart.baseHeight,
b = (frameAttrs.y + height / 2) * Dart.baseHeight,
}
})

XML:safeSetAttrs(frame, function(attrs)
local dumbUnits = Dart.baseHeight
return {
x = Utils.correctX(attrs.x * dumbUnits, XML.aspectRatio, scaleSettings) / dumbUnits,
y = Utils.correctY(attrs.y * dumbUnits, XML.aspectRatio, scaleSettings) / dumbUnits,
width = width * config.scale * Dart.ratio4x3,
height = height * config.scale,
a = config.alpha,
ratio_mode = 1,
}
end)

XML:safeSetAttrs(compass, function(attrs)
return {
width = attrs.width * config.scale,
height = attrs.height * config.scale,
}
end)

XML:safeSetAttrs(bg, function(attrs)
return {
width = attrs.width * config.scale,
height = attrs.height * config.scale,
}
end)

-- hide the engine-rendered counter
XML:safeSetAttrs(counter, {x = -9999, y = -9999})
end


function parseZoneMap(XML, config)
local frame = XML:query("minimap > level_frame")[1]
local frameAttrs = XML:safeGetAttrs(frame)

local isSquareMap = tostring(frameAttrs.rounded) == "0"

if isSquareMap then
parseSquareMap(XML, config)
else
parseCircularMap(XML, config)
end
end


function on_xml_read()
Module.registerModule(mod, "zone_map", parseZoneMap)
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Disable the script-rendered map counter
local stub = true
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
<text>Adjust the size of icons. Values greater than 1 make them larger. Values less than 1 make them smaller.</text>
</string>

<string id="ui_mcm_dart_inventory_scaleEquipment">
<text>Also Scale Icons for Equipped Items</text>
</string>

<string id="ui_mcm_dart_inventory_scaleEquipment_desc">
<text>In addition to inventories, also scale the icons in the player's equipment slots (weapons, armor, belt, quick slots, etc.).</text>
</string>

<string id="ui_mcm_dart_inventory_padScale">
<text>Icon Spacing Scale</text>
</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local Utils = dart_utils


local config = {
scale = 0.75,
scale = 1,
padScale = 0,
}

Expand All @@ -14,27 +14,33 @@ Dart.state.inventory = {}


function mcmOnConfig(mcmConfig)
local scale = ui_mcm.get("dart/dart_inventory/scale")
local padScale = ui_mcm.get("dart/dart_inventory/padScale")
local scale = ui_mcm.get("dart/dart_inventory/scale")
local scaleEquipment = ui_mcm.get("dart/dart_inventory/scaleEquipment")
local padScale = ui_mcm.get("dart/dart_inventory/padScale")

if scale then
mcmConfig.inventory.scale = scale
end

if scaleEquipment then
mcmConfig.inventory.scaleEquipment = scaleEquipment
end

if padScale then
mcmConfig.inventory.padScale = padScale
end
end


function mcmOnLoad(options)
options[10] = {
options[9] = {
id = "dart_inventory",
sh = true,
gr = {
MCM.getTitle(),
MCM.getSubtitle({text = "ui_mcm_dart_inventory_title"}),
MCM.getScaleField({hint = "dart_inventory_scale", def = config.scale}),
MCM.getCheckboxField({id = "scaleEquipment", hint = "dart_inventory_scaleEquipment"}),
MCM.getLine(),
MCM.getScaleField({
id = "padScale",
Expand All @@ -49,27 +55,5 @@ function mcmOnLoad(options)
end


function onPreRefresh()
if ui_inventory.GUI then
ui_inventory.GUI:actor_on_net_destroy()
end
end


function onPostRefresh()
if zzz_rax_sortingplus_mcm then
zzz_rax_sortingplus_mcm.actor_on_first_update()
end
if zz_ui_inventory_better_stats_bars then
zz_ui_inventory_better_stats_bars.on_option_change()
end
if custom_functor_autoinject then
custom_functor_autoinject.process_queue()
end
end


RegisterScriptCallback("on_dart_mcm_load", mcmOnLoad)
RegisterScriptCallback("on_dart_mcm_config", mcmOnConfig)
RegisterScriptCallback("on_dart_pre_refresh", onPreRefresh)
RegisterScriptCallback("on_dart_post_refresh", onPostRefresh)
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ local mod = "inventory"
Module.createLogger(mod)("Monkey patching UICellContainer:InitControls()")


-- only auto-resize these container IDs (just a best guess)
-- only auto-resize these container IDs (best guess)
function shouldAutoResize(container)
return
container.ID == "actor_bag"
return nil
or container.ID == "actor_bag"
or container.ID == "actor_trade"
or container.ID == "actor_trade_bag"
or container.ID == "npc_bag"
Expand All @@ -19,6 +19,16 @@ function shouldAutoResize(container)
end


function shouldScale(container)
local config = Module.config(mod)

return config.scaleEquipment
or container.ID ~= "actor_equ"
and container.ID ~= "actor_belt"
and container.ID ~= "actor_quick"
end


local InitControls = utils_ui.UICellContainer.InitControls

function utils_ui.UICellContainer:InitControls(owner, prof, ele_base)
Expand Down Expand Up @@ -48,8 +58,10 @@ function utils_ui.UICellContainer:InitControls(owner, prof, ele_base)
end

-- grid_size doesn't stretch to aspect ratio but grid_line does
self.grid_size = gridSize
self.grid_line = Utils.correctW(gridLine, xmlAspectRatio)
if shouldScale(self) then
self.grid_size = gridSize
self.grid_line = Utils.correctW(gridLine, xmlAspectRatio)
end

return InitControls(self, owner, prof, ele_base)
end
Loading

0 comments on commit 7abe63a

Please sign in to comment.