Divergent/mods/DynaHUD/gamedata/scripts/z_mini_map_toggle_mp.script

76 lines
2.5 KiB
Plaintext

--[[
Monkey patch to mini_map_toggle script
hides the ammo counter and ammo icon if map is toggled on if both share the same position on the hud, and viceversa
20/11/2020
Anomaly game scripts used as reference: ui_sidhud.script by RavenAscendant
Author: strangerism
--]]
local KEY = DIK_keys.DIK_SLASH --change this if you don't use MCM or havn't updated to the curent version
-- local function notify(minimap_player_choice_visible)
-- printf("notify minimap_player_choice_visible %s",minimap_player_choice_visible)
-- if minimap_player_choice_visible then
-- zzzz_dynahud.print_tip("ui_mcm_dynahud_dynamic_minimap_global_visible")
-- else
-- zzzz_dynahud.print_tip("ui_mcm_dynahud_dynamic_minimap_global_hidden")
-- end
-- end
function monkey() end
if mini_map_toggle_mcm then
monkey = mini_map_toggle_mcm.on_key_press
-- monkey_kh = mini_map_toggle_mcm.on_key_hold
end
function monkey_on_key_press(key)
if KEY == nil then
KEY = ui_mcm.get("rax_mmt/keybind")
end
--printf("monkey_on_key_press - you pressed %s - minimap key is %s",key, KEY)
if (key == KEY) then
local minimap_enabled = ui_options.get("video/hud/show_minimap")
--printf("minimap toggle activated with minimap visible %s", minimap_enabled)
monkey(key)
--printf(">>> minimap style == %s", zzzz_dynahud.MINIMAP.style)
--printf(">>> hud style == %s", zzzz_dynahud.HUD.style)
minimap_enabled = ui_options.get("video/hud/show_minimap")
--printf(">>> minimap_enabled %s",minimap_enabled)
local itm = db.actor:active_item()
local is_weapon = itm and IsWeapon(itm) or false
if is_weapon then
if zzzz_dynahud.HUD.style == -2 then
zzzz_dynahud.ui_show_cur_ammo(false)
zzzz_dynahud.ui_show_weapon_icon(false)
if ui_bartgac_mcm then ui_bartgac_mcm.BGAC_OFF() end
elseif not minimap_enabled and (zzzz_dynahud.MINIMAP.style == 0 and zzzz_dynahud.HUD.style == 0) then
zzzz_dynahud.ui_show_cur_ammo(false)
zzzz_dynahud.ui_show_weapon_icon(false)
if ui_bartgac_mcm then ui_bartgac_mcm.BGAC_OFF() end
else
zzzz_dynahud.ui_show_cur_ammo(true)
zzzz_dynahud.ui_show_weapon_icon(true)
if ui_bartgac_mcm then ui_bartgac_mcm.BGAC_ON() end
end
end
end
end
-- function monkey_on_key_hold(key)
-- monkey_kh(key)
-- printf("monkey_on_key_hold %s",key)
-- end
if mini_map_toggle_mcm then
mini_map_toggle_mcm.on_key_press = monkey_on_key_press
-- mini_map_toggle_mcm.on_key_hold = monkey_on_key_hold
end
function on_game_start()
printf("[z_mini_map_toggle_mcm] I am monkey patching mini_map_toggle_mcm.script")
KEY = ui_mcm.get("rax_mmt/keybind")
end