ReActif

ui_new.lua

Jan 29th, 2026 (edited)
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 58.50 KB | None | 0 0
  1. --[[ AUTOLOOT UI REWORK
  2. Remove the right-hand column from the Autoloot CET window.
  3. And redirect the tooltips to bubbles instead of a column!
  4.  
  5. Modified Lines:
  6. 1129-1133 ; 1183-1186 ; 1212-1221 ; 1226-1228 ; 1233-1237 ; 1254-1258 ; 1282-1286 ; 1310-1314 ; 1341-1345 ; 1360-1364
  7. 1375-1379 ; 1390-1394 ; 1406-1410 ; 1426-1430 ; 1466-1470 ; 1483-1487 ; 1508-1512 ; 1539-1543 ; 1569-1573 ; 1578-1599
  8. ]]--
  9. -------------------------------------------------------------------------------------------------------------------------------
  10. -- Mod expansion and additional coding by anygoodname by keanuWheeze consent.
  11. -- This mod shall not be redistributed or modified/renamed/rebranded and published as a separate mod without keanuWheeze and anygoodname permission.
  12. -- To use code snippets from this mod in other mods requires a consent and a proper credit note.
  13.  
  14. --[[ DISCLAIMER:
  15.  
  16. This mod is a non-commercial fan creation intended for personal use only.
  17.  
  18. By using the word "republish" I mean both republish and redistribute in this disclaimer:
  19. You're not allowed to republish the mod without my consent or against the Nexusmods rules.
  20. You're not allowed to republish parts of this mod code or files without consent. Either mine either other authors.
  21. You can modify the mod code or files for your personal use only.
  22. By modifying the mod code or files, you acknowledge I cannot support the modified mod code or files.
  23. You're not allowed to publish your modifications to the mod code or files without my consent.
  24. You're not allowed to publicly propose unauthorized changes to the mod code or files.
  25. You're not allowed to use any part of the mod code or files for commercial purposes, advertising or promotion of any kind.
  26. You can use the mod code and files to learn how to code this game mods and improve your skills.
  27. You can use parts the code or file modifications in your creations only by my consent and on a credit note.
  28. You're not allowed to use parts of the code or files marked as coming from other people without their consent.
  29. You can create and publish translations of the parts of the mod that are explicitly marked as allowed to translate either in the mod description either in the mod files.
  30. The translations must follow the Nexusmods translation publishing rules.
  31. ]]--
  32.  
  33. -- DO NOT TRANSLATE THIS FILE!
  34. -- Translation support is described in the file: "..\Cyberpunk 2077\bin\x64\plugins\cyber_engine_tweaks\mods\AutoLoot\language\Readme.txt"
  35.  
  36. -- Apr 10, 2025 based on the (c)keanuWheeze original script modified by (c)anygoodname by the keanuWheeze consent
  37.  
  38. function printError(...)
  39.     local args = {...}
  40.     if #args < 1 then return end
  41.     local output = tostring(args[1])
  42.     if #args > 1 then for i = 2, #args do output = output .. " " .. tostring(args[i]) end end
  43.     if type(output) == "string" and string.len(output) > 0 then
  44.         print(output)
  45.         spdlog.error(output)
  46.     end
  47. end
  48.  
  49. local n, t
  50. local nativeSettings, isUsingNativeSettings, nativeSettingsIgnoreAction = nil, false, false
  51. local nativeSettingsOptions          = {}
  52. local nativeSettingsSubcategoryPaths = {}
  53. local isInitialized                  = false
  54. local nativeSettingsIgnoreNextAction, nativeSettingsPlaySounds
  55. local lastMinimapContainerController = nil
  56. local lastShowWidget, lastIsLooting
  57. local shouldForceMinimapMonitorUpdate
  58. local tintColor                      = "tintColor"
  59. local fontStyle                      = "fontStyle"
  60. local MainColorsBlue                 = "MainColors.Blue"
  61. local MainColorsActiveBlue           = "MainColors.ActiveBlue"
  62. local MainColorsMediumBlue           = "MainColors.MediumBlue"
  63. local MainColorsRed                  = "MainColors.Red"
  64. local MainColorsActiveRed            = "MainColors.ActiveRed"
  65. local MainColorsBodyFontWeight       = "MainColors.BodyFontWeight"
  66. local isPreGameState                 = true
  67. local GameGetSystemRequestsHandler
  68. local isSameInstance
  69.  
  70. ui = {
  71.     modVer        = "v3.8.15",
  72.     moduleVer     = "v3.8.15",
  73.     modName       = "Autoloot",
  74.     modAuthorName = "keanuWheeze and anygoodname",
  75.     isInitialized = false,
  76.     uiStrings,
  77.     config        = require("modules/config")
  78. }
  79.  
  80. local uiDefaultStrings = {
  81.     exportOrder = {
  82.         "cetUiStrings",
  83.         "nuiUiStrings"
  84.     },
  85.     cetUiStrings = {
  86.         exportOrder = {
  87.             "cetKeyBindings",
  88.             "settings",
  89.             "monitor",
  90.             "warnings"
  91.         },
  92.         cetKeyBindings = {
  93.             autolootMonitorKey = "AutoLoot Monitor",
  94.             autolootTriggerKey = "AutoLoot"
  95.         },
  96.         settings = {
  97.             exportOrder = {
  98.                 "windowTitle",
  99.                 "general_settings",
  100.                 "tooltipsHeader",
  101.                 "range",
  102.                 "useDefaultActionKey",
  103.                 "enableTakedownLoot",
  104.                 "enableBurstTrigger",
  105.                 "burstTriggerCooldownTime",
  106.                 "monitor_settings",
  107.                 "showDebugMonitorWindow",
  108.                 "monitorType",
  109.                 "showMonitorWindowOnlyWhenTriggerActive",
  110.                 "autohideMonitorWindow"
  111.             },
  112.             windowTitle      = "AutoLoot",
  113.             general_settings = "General settings:",
  114.             tooltipsHeader   = "Hover your mouse over a menu item on the left to see its tooltip displayed here.",
  115.             range = {
  116.                 title    = "Range:",
  117.                 tooltips = "This sets the maximum range for the auto loot."
  118.             },
  119.             useDefaultActionKey = {
  120.                 title    = "Use the game default action key.",
  121.                 tooltips = "This enables the autoloot on the game default action key press.\nWarning: beware of the Midas golden touch syndrome!"
  122.             },
  123.             enableTakedownLoot = {
  124.                 title    = "Autoloot NPCs on Takedowns.",
  125.                 tooltips = "This option enables automatic looting of NPCs defeated by performing takedowns.\nPlease note that quest-related items and iconic weapons will not be looted."
  126.             },
  127.             enableBurstTrigger = {
  128.                 title    = "Enable Burst mode",
  129.                 tooltips = "The Burst mode allows you to toggle continuous autolooting on a loot trigger double-tap for a period of time.\n\nBursts last up to the defined maximum duration and can be stopped by double-tapping again, entering combat, entering vehicles, pausing the game, or other game state changes that require breaking autolooting for some reason.\n\nFor better control of the autolooting state, please consider turning on the Looting Monitor."
  130.             },
  131.             burstTriggerCooldownTime = {
  132.                 title    = "Max. Burst duration (mm:ss):",
  133.                 tooltips = "This option sets the maximum duration for a looting burst.\nNote: changes will be applied on the next burst."
  134.             },
  135.             monitor_settings = "Looting Monitor settings:",
  136.             showDebugMonitorWindow = {
  137.                 title    = "Show Monitor window.",
  138.                 tooltips = "This enables a small monitor window showing the current autolooting state.\nPlease note that the monitor window may be hidden when visiting the game Settings menu."
  139.             },
  140.             monitorType = {
  141.                 title    = "Select Monitor type:",
  142.                 tooltips = "Select the type of the Looting Monitor to display.",
  143.                 choices  = {
  144.                     "CET window",
  145.                     "Minimap indicator",
  146.                     "CET window and Minimap indicator"
  147.                 }
  148.             },
  149.             showMonitorWindowOnlyWhenTriggerActive = {
  150.                 title    = "Show Monitor only if looting trigger active.",
  151.                 tooltips = "Show the monitor only when the looting trigger is active (key/button pressed or Burst mode active)."
  152.             },
  153.             autohideMonitorWindow = {
  154.                 title    = "Autohide Monitor window.",
  155.                 tooltips = "When enabled, it will automatically hide and show the monitor window following the game cinematic state."
  156.             }
  157.         },
  158.         monitor = {
  159.             idleStr    = "Idle.",
  160.             lootingStr = "Looting "
  161.         },
  162.         warnings = {
  163.             modDisabled = "This mod is disabled due to corrupted mod files or incompatibility with the current game version."
  164.         }
  165.     },
  166.     nuiUiStrings = {
  167.         settings = {
  168.             exportOrder = {
  169.                 "windowTitle",
  170.                 "general_settings",
  171.                 "range",
  172.                 "useDefaultActionKey",
  173.                 "enableTakedownLoot",
  174.                 "enableBurstTrigger",
  175.                 "burstTriggerCooldownTime",
  176.                 "monitor_settings",
  177.                 "showDebugMonitorWindow",
  178.                 "monitorType",
  179.                 "showMonitorWindowOnlyWhenTriggerActive",
  180.                 "autohideMonitorWindow"
  181.             },
  182.             windowTitle      = "AutoLoot",
  183.             general_settings = "General settings:",
  184.             range = {
  185.                 title    = "Range",
  186.                 tooltips = "This sets the maximum range for the auto loot."
  187.             },
  188.             useDefaultActionKey = {
  189.                 title    = "Use the game default action key",
  190.                 tooltips = "This enables the auto loot on the game default action key press.\nWarning: beware of the Midas golden touch syndrome!"
  191.             },
  192.             enableTakedownLoot = {
  193.                 title    = "Autoloot NPCs on Takedowns.",
  194.                 tooltips = "This option enables automatic looting of NPCs defeated by performing takedowns.\nPlease note that quest-related items and iconic weapons will not be looted."
  195.             },
  196.             enableBurstTrigger = {
  197.                 title    = "Enable Burst mode",
  198.                 tooltips = "The Burst mode allows you to toggle continuous autolooting on a loot trigger double-tap for a period of time.\n\nBursts last up to the defined maximum duration and can be stopped by double-tapping again, entering combat, entering vehicles, pausing the game, or other game state changes that require breaking autolooting for some reason.\n\nFor better control of the autolooting state, please consider turning on the Looting Monitor."
  199.             },
  200.             burstTriggerCooldownTime = {
  201.                 title    = "Max. Burst duration (mm:ss)",
  202.                 tooltips = "This option sets the maximum duration for a looting burst.\nNote: changes will be applied on the next burst."
  203.             },
  204.             monitor_settings = "Looting Monitor settings:",
  205.             showDebugMonitorWindow = {
  206.                 title    = "Show Monitor window",
  207.                 tooltips = "This enables a small monitor window showing the current autolooting state.\nPlease note that the monitor window may be hidden when visiting the game Settings menu."
  208.             },
  209.             monitorType = {
  210.                 title    = "Select Monitor type",
  211.                 tooltips = "Select the type of the Looting Monitor to display.",
  212.                 choices  = {
  213.                     "CET window",
  214.                     "Minimap indicator",
  215.                     "CET window and Minimap indicator"
  216.                 }
  217.             },
  218.             showMonitorWindowOnlyWhenTriggerActive = {
  219.                 title    = "Show Monitor only if looting trigger active",
  220.                 tooltips = "Show the monitor only when the looting trigger is active (key/button pressed or Burst mode active)."
  221.             },
  222.             autohideMonitorWindow = {
  223.                 title    = "Autohide Monitor window",
  224.                 tooltips = "When enabled, it will automatically hide and show the monitor window following the game cinematic state."
  225.             }
  226.         },
  227.         monitor = {
  228.             idleStr    = "Autoloot is idle",
  229.             lootingStr = "Autolooting "
  230.         }
  231.     }
  232. }
  233.  
  234. function cloneTable(source)
  235.     local output = {}
  236.     if #source == 0 then
  237.         for key, entry in pairs(source) do
  238.             if type(entry) == "table" then
  239.                 entry = cloneTable(entry)
  240.             end
  241.             output[key] = entry
  242.         end
  243.     else
  244.         for key, entry in ipairs(source) do
  245.             if type(entry) == "table" then
  246.                 entry = cloneTable(entry)
  247.             end
  248.             table.insert(output, entry)
  249.         end
  250.     end
  251.     return output
  252. end
  253.  
  254. local uiStrings = cloneTable(uiDefaultStrings)
  255. ui.uiStrings = uiStrings
  256.  
  257. function dumpTableToJson(inputTable, isCustomOrder, sortIfNoCustomOrderFound)
  258.     local function getTableTypeWithKeysOrCount(array, sort)
  259.         local count = #array
  260.         local isOrderedArray = count > 0
  261.         if isOrderedArray then
  262.             return false, count
  263.         end
  264.         local keys = {}
  265.         for key, value in pairs(array) do
  266.             table.insert(keys, key)
  267.         end
  268.         if sort then table.sort(keys) end
  269.         return true, keys
  270.     end
  271.  
  272.     local function serializeTable(val, level)
  273.         local outputStr     = ""
  274.         local indentStr     = string.rep("\t", level)
  275.         local nextIndentStr = string.rep("\t", level + 1)
  276.  
  277.         if type(val) == "table" then
  278.             local isTableWithKeys, keysOrCount = getTableTypeWithKeysOrCount(val, not isCustomOrder)
  279.             if not isTableWithKeys then
  280.                 outputStr = outputStr .. "[\n"
  281.                 for i = 1, #val do
  282.                     value = val[i]
  283.                     local valueType = type(value)
  284.                     if valueType ~= "table" and valueType ~= "string" and valueType ~= "number" and valueType ~= "boolean" then value = tostring(value) end
  285.                     outputStr = outputStr .. nextIndentStr .. serializeTable(value, level + 1)
  286.                     if i < keysOrCount then outputStr = outputStr .. ",\n" end
  287.                 end
  288.                 outputStr = outputStr .. "\n" .. indentStr .. "]"
  289.             else
  290.                 outputStr = outputStr .. "{\n"
  291.                 local comma = false
  292.                 local keys  = keysOrCount
  293.                 if isCustomOrder then
  294.                     if type(val.exportOrder) == "table" and #val.exportOrder > 0 then
  295.                         keys = val.exportOrder
  296.                     else
  297.                         if sortIfNoCustomOrderFound then table.sort(keys) end
  298.                     end
  299.                 end
  300.                 for i, key in ipairs(keys) do
  301.                     local value     = val[key]
  302.                     local valueType = type(value)
  303.                     if valueType ~= "table" and valueType ~= "string" and valueType ~= "number" and valueType ~= "boolean" then value = tostring(value) end
  304.                     if comma then outputStr = outputStr .. ",\n" else comma = true end
  305.                     outputStr = outputStr .. nextIndentStr .. '"' .. tostring(key) .. '": ' .. serializeTable(value, level + 1)
  306.                 end
  307.                 outputStr = outputStr .. "\n" .. indentStr .. "}"
  308.             end
  309.         elseif type(val) == "string" then
  310.             outputStr = outputStr .. '"' .. val:gsub('"', '\\"'):gsub('\n', '\\n') .. '"'
  311.         else
  312.             outputStr = outputStr .. tostring(val)
  313.         end
  314.  
  315.         return outputStr
  316.     end
  317.  
  318.     return serializeTable(inputTable, 0)
  319. end
  320.  
  321. function loadJsonTable(fileName, verbose)
  322.     if type(fileName) ~= "string" then return end
  323.     local file = io.open(fileName, "r")
  324.     if file then
  325.         local jString = file:read("*a")
  326.         file:close()
  327.         if type(jString) ~= "string" then return end
  328.         local decodeResult, data = pcall(function() return json.decode(jString) end)
  329.         if not decodeResult then
  330.             if verbose then
  331.                 print(data)
  332.             end
  333.             return
  334.         end
  335.         if type(data) ~= "table" then
  336.             if verbose then
  337.                 print(fileName, "does not seem to contain valid table data")
  338.             end
  339.             return
  340.         end
  341.         if verbose then
  342.             print("Valid table data found in", fileName)
  343.         end
  344.         return data
  345.     else
  346.         if verbose then
  347.             print("Cannot find fileName:", fileName)
  348.         end
  349.     end
  350. end
  351.  
  352. function saveTextFile(text, fileName)
  353.     if type(text) ~= "string" then return end
  354.     if type(fileName) ~= "string" then return end
  355.     local file = io.open(fileName, "w")
  356.     if file then
  357.         file:write(text)
  358.         file:close()
  359.     else
  360.         print("Cannot save text to file", fileName)
  361.     end
  362. end
  363.  
  364. local exportedStringsFileHeader = {
  365.     exportOrder = {
  366.         "_1_",
  367.         "modName",
  368.         "modAuthorName",
  369.         "modVer",
  370.         "_2_",
  371.         "translationAuthorName",
  372.         "translationVer",
  373.         "_3_"
  374.     },
  375.     _1_ = "----------------------------------------",
  376.     modName       = ui.modName,
  377.     modAuthorName = ui.modAuthorName,
  378.     modVer        = ui.modVer,
  379.     _2_ = "----------------------------------------",
  380.     translationAuthorName = "Put your name here",
  381.     translationVer = "Put your file verison here",
  382.     _3_ = "----------------------------------------"
  383. }
  384.  
  385. local stringsFileSet = { uiStrings = "uiStrings.json" }
  386.  
  387. local exportTable = {}
  388. exportTable.exportOrder = { "fileHeader", "uiStrings" }
  389. exportTable.fileHeader  = exportedStringsFileHeader
  390. exportTable.uiStrings   = uiDefaultStrings
  391. pcall(function() jsonDump = dumpTableToJson(exportTable, true, true) end)
  392. if type(jsonDump) == "string" then saveTextFile(jsonDump, "language/en-us_template/uiStrings.json") end
  393.  
  394. function replaceTableEntries(sourceTable, replacementTable, finalDataType, verbose)
  395.     if type(sourceTable) ~= "table" then return sourceTable end
  396.     if type(replacementTable) ~= "table" then return sourceTable end
  397.     if finalDataType ~= "string" then finalDataType = nil end
  398.     local outputTable = cloneTable(sourceTable)
  399.     local count, replacementCount = 0, 0
  400.     local childResult = true
  401.  
  402.     for sourceKey, sourceEntry in pairs(sourceTable) do
  403.         count = count + 1
  404.         local replacementEntry = replacementTable[sourceKey]
  405.         if replacementEntry then
  406.             if type(sourceEntry) == "table" then
  407.                 replacementEntry, childResult = replaceTableEntries(sourceEntry, replacementEntry, finalDataType, verbose)
  408.             end
  409.             if replacementEntry then
  410.                 local replacementEntryType = type(replacementEntry)
  411.                 if replacementEntryType == "table" or ((not finalDataType) or (finalDataType and replacementEntryType == finalDataType)) then
  412.                     outputTable[sourceKey] = replacementEntry
  413.                     if childResult then replacementCount = replacementCount + 1 end
  414.                 else
  415.                     if verbose then
  416.                         printError("incorrect data type:", sourceKey, "in the replacement table. The missing value is substituted with a default.")
  417.                     end
  418.                 end
  419.             else
  420.                 if verbose then
  421.                     printError("missing:", sourceKey, "in the replacement table. The missing value is substituted with a default value.")
  422.                 end
  423.             end
  424.         else
  425.             if verbose then
  426.                 printError("missing:", sourceKey, "in the replacement table. The missing value is substituted with a default value.")
  427.             end
  428.         end
  429.     end
  430.     return outputTable, replacementCount > 0
  431. end
  432.  
  433. local currentUiLanguage = "en-us"
  434. local languages = {
  435.     ["ar-ar"] = false,
  436.     ["cz-cz"] = false,
  437.     ["de-de"] = false,
  438.     ["en-us"] = false,
  439.     ["es-es"] = false,
  440.     ["es-mx"] = false,
  441.     ["fr-fr"] = false,
  442.     ["hu-hu"] = false,
  443.     ["it-it"] = false,
  444.     ["jp-jp"] = false,
  445.     ["kr-kr"] = false,
  446.     ["pl-pl"] = false,
  447.     ["pt-br"] = false,
  448.     ["ru-ru"] = false,
  449.     ["th-th"] = false,
  450.     ["tr-tr"] = false,
  451.     ["ua-ua"] = false,
  452.     ["zh-cn"] = false,
  453.     ["zh-tw"] = false
  454. }
  455.  
  456. function loadAllLanguageFiles()
  457.     for id, data in pairs(languages) do
  458.         local loadedData = {}
  459.         local fileRoot   = "language/" .. id .. "/"
  460.         local isAnythingLoaded = false
  461.         for tableName, fileName in pairs(stringsFileSet) do
  462.             local filePath = fileRoot .. fileName
  463.             local fileData = loadJsonTable(filePath)
  464.             if type(fileData) == "table" then
  465.                 loadedData = {fileHeader = fileData.fileHeader, uiStrings = fileData.uiStrings}
  466.                 isAnythingLoaded = true
  467.             end
  468.         end
  469.         if isAnythingLoaded then
  470.             languages[id] = loadedData
  471.             print(ui.modName, ui.modVer .. ":", id, "language files loaded.")
  472.         end
  473.     end
  474. end
  475.  
  476. loadAllLanguageFiles()
  477.  
  478. function quickloadUserSettings()
  479.     local file = io.open("config/config.json", "r")
  480.     if not file then return end
  481.     local jString = file:read("*a")
  482.     file:close()
  483.  
  484.     if type(jString) ~= "string" then return end
  485.     local decodeResult, settings = pcall(function() return json.decode(jString) end)
  486.     if not decodeResult then return end
  487.     if type(settings) ~= "table" then return end
  488.     return settings
  489. end
  490.  
  491. function getGameUILanguage(updateUserSettings, forceSettingsUpdate)
  492.     if type(Game) == "userdata" and type(GetPlayer) == "function" then
  493.         local lang = "en-us"
  494.         local settingsSystem = Game.GetSettingsSystem()
  495.         if settingsSystem:HasGroup("/language") and settingsSystem:HasVar("/language", "OnScreen") then
  496.             lang = settingsSystem:GetVar("/language", "OnScreen"):GetValue()
  497.         end
  498.         lang = NameToString(lang)
  499.         if updateUserSettings and (isModInitialized or forceSettingsUpdate) then
  500.             ui.settings.lastLanguageSelected = lang
  501.         end
  502.         return lang, true
  503.     end
  504.  
  505.     local lastLanguageSelected = "en-us"
  506.     if isModInitialized then
  507.         if type(ui.settings.lastLanguageSelected) == "string" then
  508.             lastLanguageSelected = ui.settings.lastLanguageSelected
  509.         end
  510.     else
  511.         local userSettings = quickloadUserSettings()
  512.         if userSettings and type(userSettings.lastLanguageSelected) == "string" then
  513.             lastLanguageSelected = userSettings.lastLanguageSelected
  514.         end
  515.     end
  516.     if languages[lastLanguageSelected] then
  517.         return lastLanguageSelected
  518.     end
  519.     return "en-us"
  520. end
  521.  
  522. function loadLocalizedStrings(updateUserSettings, forceSettingsUpdate)
  523.     currentUiLanguage = getGameUILanguage(updateUserSettings, forceSettingsUpdate)
  524.  
  525.     if type(currentUiLanguage) ~= "string" then return end
  526.     uiStrings    = cloneTable(uiDefaultStrings)
  527.     ui.uiStrings = uiStrings
  528.  
  529.     local newStringsSet = languages[currentUiLanguage]
  530.     if type(newStringsSet) ~= "table" then return end
  531.  
  532.     local isAnythingChanged = false
  533.     for tableName, newTableData in pairs(newStringsSet) do
  534.         if type(newTableData) and tableName == "uiStrings" then
  535.             local replacedTableData, result = replaceTableEntries(uiStrings, newTableData, "string", false)
  536.             if result then
  537.                 uiStrings         = replacedTableData
  538.                 ui.uiStrings      = uiStrings
  539.                 isAnythingChanged = true
  540.             end
  541.         end
  542.     end
  543.     if isAnythingChanged and isInitialized then
  544.         setupNativeSettings(true)
  545.     end
  546. end
  547.  
  548. loadLocalizedStrings()
  549.  
  550. function ui.onInit()
  551.     if isInitialized then return true end
  552.  
  553.     n = CName
  554.     t = TweakDBID
  555.  
  556.     isSameInstance           = Game["OperatorEqual;IScriptableIScriptable;Bool"] -- (c)keanuWheeze
  557.     tintColor                = n"tintColor"
  558.     fontStyle                = n"fontStyle"
  559.     MainColorsBlue           = n"MainColors.Blue"
  560.     MainColorsActiveBlue     = n"MainColors.ActiveBlue"
  561.     MainColorsMediumBlue     = n"MainColors.MediumBlue"
  562.     MainColorsRed            = n"MainColors.Red"
  563.     MainColorsActiveRed      = n"MainColors.ActiveRed"
  564.     MainColorsBodyFontWeight = n"MainColors.BodyFontWeight"
  565.  
  566.     GameGetSystemRequestsHandler = Game.GetSystemRequestsHandler
  567.     isPreGameState               = GameGetSystemRequestsHandler():IsPreGame()
  568.  
  569.     local lastlanguageSelected = ui.settings.lastLanguageSelected
  570.     loadLocalizedStrings(true, true)
  571.     if ui.settings.lastLanguageSelected ~= lastlanguageSelected then
  572.         ui.config.saveConfig("config/config.json", ui.settings)
  573.     end
  574.  
  575.     setupNativeSettings()
  576.  
  577.     ObserveAfter("PlayerPuppet", "OnGameAttached", function(self)
  578.         isPreGameState = GameGetSystemRequestsHandler():IsPreGame()
  579.         if self:IsReplacer() then return end
  580.         local lastlanguageSelected = ui.settings.lastLanguageSelected
  581.         loadLocalizedStrings(true, true)
  582.         if ui.settings.lastLanguageSelected ~= lastlanguageSelected then
  583.             ui.config.saveConfig("config/config.json", ui.settings)
  584.         end
  585.         setupNativeSettings(true)
  586.         if isPreGameState then
  587.             removeMonitorWidget()
  588.         end
  589.     end)
  590.     ObserveAfter("PlayerPuppet", "OnWorkspotFinishedEvent", function(this, evt)
  591.         shouldForceMinimapMonitorUpdate = true
  592.     end)
  593.     if PlayerPuppet.OnSceneTierChange then
  594.         ObserveAfter("PlayerPuppet", "OnSceneTierChange", function(this, newState)
  595.             isPreGameState = GameGetSystemRequestsHandler():IsPreGame()
  596.             if isPreGameState then
  597.                 removeMonitorWidget()
  598.                 return
  599.             end
  600.             shouldForceMinimapMonitorUpdate = true
  601.         end)
  602.     else
  603.         ObserveAfter("PlayerVisionModeController", "OnRestrictedSceneChanged", function(self, value)
  604.             isPreGameState = GameGetSystemRequestsHandler():IsPreGame()
  605.             if isPreGameState then
  606.                 removeMonitorWidget()
  607.                 return
  608.             end
  609.             shouldForceMinimapMonitorUpdate = true
  610.         end)
  611.     end
  612.     ObserveBefore("inkISystemRequestsHandler", "RequestSaveUserSettings", function(this)
  613.         isPreGameState = GameGetSystemRequestsHandler():IsPreGame()
  614.         if not isPreGameState then return end
  615.         local lastlanguageSelected = ui.settings.lastLanguageSelected
  616.         loadLocalizedStrings(true, true)
  617.         if ui.settings.lastLanguageSelected ~= lastlanguageSelected then
  618.             ui.config.saveConfig("config/config.json", ui.settings)
  619.             setupNativeSettings(true)
  620.         end
  621.     end)
  622.  
  623.     ObserveAfter("MinimapContainerController", "OnInitialize", function(this)
  624.         lastMinimapContainerController = this
  625.         isPreGameState = GameGetSystemRequestsHandler():IsPreGame()
  626.         local parent = this.timeDisplayWidget.widget
  627.         if parent then
  628.             parent = parent.parentWidget
  629.         end
  630.         removeMonitorWidget(parent)
  631.         lastShowWidget = nil
  632.         lastIsLooting  = nil
  633.     end)
  634.     ObserveBefore("MinimapContainerController", "OnUnitialize", function(this)
  635.         isPreGameState = GameGetSystemRequestsHandler():IsPreGame()
  636.         local parent = this.timeDisplayWidget.widget
  637.         if parent then
  638.             parent = parent.parentWidget
  639.         end
  640.         removeMonitorWidget(parent)
  641.         lastShowWidget = nil
  642.         lastIsLooting  = nil
  643.     end)
  644.     Observe("MinimapContainerController", "OnPlayerAttach", function(this)
  645.         lastMinimapContainerController = this
  646.         isPreGameState = GameGetSystemRequestsHandler():IsPreGame()
  647.         local parent = this.timeDisplayWidget.widget
  648.         if parent then
  649.             parent = parent.parentWidget
  650.         end
  651.         removeMonitorWidget(parent)
  652.         lastShowWidget = nil
  653.         lastIsLooting  = nil
  654.         if isPreGameState then return end
  655.         if not ui.settings.showDebugMonitorWindow then return end
  656.         addMonitorWidgetToMinimap()
  657.     end)
  658.     Observe("MinimapContainerController", "OnPSMCombatChanged", function(this)
  659.         lastMinimapContainerController = this
  660.         isPreGameState = GameGetSystemRequestsHandler():IsPreGame()
  661.         if isPreGameState then
  662.             local parent = this.timeDisplayWidget.widget
  663.             if parent then
  664.                 parent = parent.parentWidget
  665.             end
  666.             removeMonitorWidget(parent)
  667.             return
  668.         end
  669.         if not ui.settings.showDebugMonitorWindow then return end
  670.         addMonitorWidgetToMinimap()
  671.     end)
  672.     Observe("MinimapContainerController", "OnLocationUpdated", function(this)
  673.         lastMinimapContainerController = this
  674.         isPreGameState = GameGetSystemRequestsHandler():IsPreGame()
  675.         if isPreGameState then
  676.             local parent = this.timeDisplayWidget.widget
  677.             if parent then
  678.                 parent = parent.parentWidget
  679.             end
  680.             removeMonitorWidget(parent)
  681.             return
  682.         end
  683.         if not ui.settings.showDebugMonitorWindow then return end
  684.         addMonitorWidgetToMinimap()
  685.     end)
  686.  
  687.     ObserveAfter("SettingsSelectorController", "OnInitialize", function(this)
  688.         if not nativeSettings.fromMods then return end
  689.         local ctl = nativeSettingsOptions.burstTriggerCooldownTime.controller
  690.         if not ctl then return end
  691.         if not IsDefined(ctl) then return end
  692.         if not ctl.ValueText.widget then return end
  693.         local newText = intToMinSecStr(ctl.newValue)
  694.         if not newText then return end
  695.         inkTextRef.SetText(ctl.ValueText, newText)
  696.     end)
  697.  
  698.     local n_SettingsSelectorControllerInt = n"SettingsSelectorControllerInt"
  699.     ObserveAfter("SettingsSelectorControllerInt", "Refresh", function(this)
  700.         if not nativeSettings.fromMods then return end
  701.         if not this:IsA(n_SettingsSelectorControllerInt) then return end
  702.         local ctl = nativeSettingsOptions.burstTriggerCooldownTime.controller
  703.         if not ctl then return end
  704.         if not IsDefined(ctl) then return end
  705.         if not isSameInstance(this, ctl) then return end
  706.         local newText = intToMinSecStr(ctl.newValue)
  707.         if not newText then return end
  708.         inkTextRef.SetText(ctl.ValueText, newText)
  709.     end)
  710.  
  711.     local shouldResetSettingsPanel, shouldReloadMenu, shouldRestoreDefaultSettings
  712.     ObserveBefore("SettingsMainGameController", "RequestRestoreDefaults", function(this)
  713.         shouldRestoreDefaultSettings = false
  714.         if not nativeSettings then return end
  715.         if not nativeSettings.fromMods then return end
  716.         if type(ui.defaultSettings) ~= "table" then return end
  717.  
  718.         local currentOption = nativeSettings.data[nativeSettings.currentTab]
  719.         if not currentOption then return end
  720.         if currentOption.isRedMod then return end
  721.         if currentOption.path ~= "AutoLoot" then return end
  722.  
  723.         shouldRestoreDefaultSettings = true
  724.         setupNativeSettings(true, true)
  725.     end)
  726.     ObserveAfter("SettingsMainGameController", "RequestRestoreDefaults", function(this)
  727.         if not shouldRestoreDefaultSettings then return end
  728.         shouldRestoreDefaultSettings = false
  729.         setupNativeSettings(true)
  730.     end)
  731.  
  732.     isInitialized = true
  733.     return true
  734. end
  735.  
  736. function ui.onShutdown()
  737.     if not Game then return end
  738.     if not GetPlayer() then return end
  739.     removeMonitorWidget()
  740. end
  741.  
  742. function setupNativeSettings(forceNew, showAll)
  743.     isUsingNativeSettings = false
  744.     nativeSettings        = GetMod("nativeSettings")
  745.     if not nativeSettings then return end
  746.  
  747.     ui.nativeSettings = nativeSettings
  748.     if type(uiStrings) ~= "table" then return end
  749.  
  750.     local modPath = "/AutoLoot"
  751.  
  752.     nativeSettingsSubcategoryPaths = {
  753.         general_settings = modPath .. "/general_settings",
  754.         monitor_settings = modPath .. "/monitor_settings"
  755.     }
  756.  
  757.     local nativeSettingsDisplayName = uiStrings.nuiUiStrings.settings.windowTitle
  758.     if forceNew and nativeSettings.pathExists(modPath) then
  759.         if type(nativeSettingsSubcategoryPaths) == "table" then
  760.             for _, path in pairs(nativeSettingsSubcategoryPaths) do
  761.                 nativeSettings.removeSubcategory(path)
  762.             end
  763.         end
  764.         local path = modPath:gsub("/", "")
  765.         nativeSettings.data[path]  = nil
  766.         nativeSettingsIgnoreAction = false
  767.     end
  768.  
  769.     if not nativeSettings.pathExists(modPath) then
  770.         nativeSettings.addTab(modPath, uiStrings.nuiUiStrings.settings.windowTitle or "AutoLoot")
  771.     end
  772.     if nativeSettings.pathExists(modPath) then
  773.         isUsingNativeSettings = true
  774.     else
  775.         return
  776.     end
  777.  
  778.     local buttonTitle, buttonTooltips = "", ""
  779.     local buttonsPath = nativeSettingsSubcategoryPaths.general_settings
  780.     nativeSettings.addSubcategory(buttonsPath, uiStrings.nuiUiStrings.settings.general_settings or "General settings:")
  781.  
  782.     buttonTitle    = uiStrings.nuiUiStrings.settings.range.title
  783.     buttonTooltips = uiStrings.nuiUiStrings.settings.range.tooltips
  784.     nativeSettingsOptions.range = nativeSettings.addRangeInt(buttonsPath, buttonTitle, buttonTooltips, 1, 100, 1, ui.settings.range, ui.defaultSettings.range, function(newValue)
  785.         nativeSettingsPlaySounds = false
  786.         if nativeSettingsIgnoreNextAction then
  787.             nativeSettingsIgnoreNextAction = false
  788.             return
  789.         end
  790.         ui.settings.range = newValue
  791.         ui.config.saveConfig("config/config.json", ui.settings)
  792.     end)
  793.  
  794.     buttonTitle    = uiStrings.nuiUiStrings.settings.useDefaultActionKey.title
  795.     buttonTooltips = uiStrings.nuiUiStrings.settings.useDefaultActionKey.tooltips
  796.     nativeSettingsOptions.useDefaultActionKey = nativeSettings.addSwitch(buttonsPath, buttonTitle, buttonTooltips, ui.settings.useDefaultActionKey, ui.defaultSettings.useDefaultActionKey, function(newState)
  797.         nativeSettingsPlaySounds = false
  798.         if nativeSettingsIgnoreNextAction then
  799.             nativeSettingsIgnoreNextAction = false
  800.             return
  801.         end
  802.         local isStateChanged = ui.settings.useDefaultActionKey ~= newState
  803.         ui.settings.useDefaultActionKey = newState
  804.         if isStateChanged then
  805.             ui.config.saveConfig("config/config.json", ui.settings)
  806.         end
  807.     end)
  808.  
  809.     buttonTitle    = uiStrings.nuiUiStrings.settings.enableTakedownLoot.title
  810.     buttonTooltips = uiStrings.nuiUiStrings.settings.enableTakedownLoot.tooltips
  811.     nativeSettingsOptions.enableTakedownLoot = nativeSettings.addSwitch(buttonsPath, buttonTitle, buttonTooltips, ui.settings.enableTakedownLoot, ui.defaultSettings.enableTakedownLoot, function(newState)
  812.         nativeSettingsPlaySounds = false
  813.         if nativeSettingsIgnoreNextAction then
  814.             nativeSettingsIgnoreNextAction = false
  815.             return
  816.         end
  817.         local isStateChanged = ui.settings.enableTakedownLoot ~= newState
  818.         ui.settings.enableTakedownLoot = newState
  819.         if isStateChanged then
  820.             ui.config.saveConfig("config/config.json", ui.settings)
  821.         end
  822.     end)
  823.  
  824.     buttonTitle    = uiStrings.nuiUiStrings.settings.enableBurstTrigger.title
  825.     buttonTooltips = uiStrings.nuiUiStrings.settings.enableBurstTrigger.tooltips
  826.     nativeSettingsOptions.enableBurstTrigger = nativeSettings.addSwitch(buttonsPath, buttonTitle, buttonTooltips, ui.settings.enableBurstTrigger, ui.defaultSettings.enableTakedownLoot, function(newState)
  827.         nativeSettingsPlaySounds = false
  828.         if nativeSettingsIgnoreNextAction then
  829.             nativeSettingsIgnoreNextAction = false
  830.             return
  831.         end
  832.         local isStateChanged = ui.settings.enableBurstTrigger ~= newState
  833.         ui.settings.enableBurstTrigger = newState
  834.         if isStateChanged then
  835.             ui.config.saveConfig("config/config.json", ui.settings)
  836.         end
  837.     end)
  838.  
  839.     buttonTitle    = uiStrings.nuiUiStrings.settings.burstTriggerCooldownTime.title
  840.     buttonTooltips = uiStrings.nuiUiStrings.settings.burstTriggerCooldownTime.tooltips
  841.  
  842.     local step, maxVal, defaultVal = 15, 300, ui.defaultSettings.burstTriggerCooldownTime
  843.     if type(ui.uiBurstParams) == "table" then
  844.         step       = ui.uiBurstParams[1] or step
  845.         defaultVal = ui.uiBurstParams[2] or defaultVal
  846.         maxVal     = ui.uiBurstParams[3] or maxVal
  847.     end
  848.  
  849.     local minVal = step
  850.     nativeSettingsOptions.burstTriggerCooldownTime = nativeSettings.addRangeInt(buttonsPath, buttonTitle, buttonTooltips, minVal, maxVal, step, ui.settings.burstTriggerCooldownTime, defaultVal, function(newValue)
  851.         nativeSettingsPlaySounds = false
  852.         if nativeSettingsIgnoreNextAction then
  853.             nativeSettingsIgnoreNextAction = false
  854.             return
  855.         end
  856.         ui.settings.burstTriggerCooldownTime = newValue
  857.         ui.config.saveConfig("config/config.json", ui.settings)
  858.     end)
  859.  
  860.     buttonsPath = nativeSettingsSubcategoryPaths.monitor_settings
  861.     nativeSettings.addSubcategory(buttonsPath, uiStrings.nuiUiStrings.settings.monitor_settings or "Looting Monitor settings:")
  862.  
  863.     buttonTitle    = uiStrings.nuiUiStrings.settings.showDebugMonitorWindow.title
  864.     buttonTooltips = uiStrings.nuiUiStrings.settings.showDebugMonitorWindow.tooltips
  865.     nativeSettingsOptions.showDebugMonitorWindow = nativeSettings.addSwitch(buttonsPath, buttonTitle, buttonTooltips, ui.settings.showDebugMonitorWindow, ui.defaultSettings.showDebugMonitorWindow, function(newState)
  866.         nativeSettingsPlaySounds = false
  867.         if nativeSettingsIgnoreNextAction then
  868.             nativeSettingsIgnoreNextAction = false
  869.             return
  870.         end
  871.         local isStateChanged = ui.settings.showDebugMonitorWindow ~= newState
  872.         ui.settings.showDebugMonitorWindow = newState
  873.         if isStateChanged then
  874.             lastShowWidget = nil
  875.             lastIsLooting  = nil
  876.             if ui.settings.showDebugMonitorWindow then
  877.                 addMonitorWidgetToMinimap()
  878.             else
  879.                 removeMonitorWidget()
  880.             end
  881.             ui.config.saveConfig("config/config.json", ui.settings)
  882.             ui.payload = function()
  883.                 setupNativeSettings(true)
  884.             end
  885.         end
  886.     end)
  887.  
  888.     if showAll or ui.settings.showDebugMonitorWindow then
  889.         buttonTitle    = uiStrings.nuiUiStrings.settings.monitorType.title
  890.         buttonTooltips = uiStrings.nuiUiStrings.settings.monitorType.tooltips
  891.         local choices  = uiStrings.nuiUiStrings.settings.monitorType.choices
  892.         nativeSettingsOptions.monitorType = nativeSettings.addSelectorString(buttonsPath, buttonTitle, buttonTooltips, choices, ui.settings.monitorType + 1, ui.defaultSettings.monitorType + 1, function(newValue)
  893.             nativeSettingsPlaySounds = false
  894.             if nativeSettingsIgnoreNextAction then
  895.                 nativeSettingsIgnoreNextAction = false
  896.                 return
  897.             end
  898.             newValue = newValue - 1
  899.             local isStateChanged = ui.settings.monitorType ~= newValue
  900.             ui.settings.monitorType = newValue
  901.             if isStateChanged then
  902.                 lastShowWidget = nil
  903.                 lastIsLooting  = nil
  904.                 ui.config.saveConfig("config/config.json", ui.settings)
  905.             end
  906.         end)
  907.  
  908.         buttonTitle    = uiStrings.nuiUiStrings.settings.showMonitorWindowOnlyWhenTriggerActive.title
  909.         buttonTooltips = uiStrings.nuiUiStrings.settings.showMonitorWindowOnlyWhenTriggerActive.tooltips
  910.         nativeSettingsOptions.showMonitorWindowOnlyWhenTriggerActive = nativeSettings.addSwitch(buttonsPath, buttonTitle, buttonTooltips, ui.settings.showMonitorWindowOnlyWhenTriggerActive, ui.defaultSettings.showMonitorWindowOnlyWhenTriggerActive, function(newState)
  911.             nativeSettingsPlaySounds = false
  912.             if nativeSettingsIgnoreNextAction then
  913.                 nativeSettingsIgnoreNextAction = false
  914.                 return
  915.             end
  916.             local isStateChanged = ui.settings.showMonitorWindowOnlyWhenTriggerActive ~= newState
  917.             ui.settings.showMonitorWindowOnlyWhenTriggerActive = newState
  918.             if isStateChanged then
  919.                 lastShowWidget = nil
  920.                 lastIsLooting  = nil
  921.                 ui.config.saveConfig("config/config.json", ui.settings)
  922.             end
  923.         end)
  924.  
  925.         buttonTitle    = uiStrings.nuiUiStrings.settings.autohideMonitorWindow.title
  926.         buttonTooltips = uiStrings.nuiUiStrings.settings.autohideMonitorWindow.tooltips
  927.         nativeSettingsOptions.autohideMonitorWindow = nativeSettings.addSwitch(buttonsPath, buttonTitle, buttonTooltips, ui.settings.autohideMonitorWindow, ui.defaultSettings.autohideMonitorWindow, function(newState)
  928.             nativeSettingsPlaySounds = false
  929.             if nativeSettingsIgnoreNextAction then
  930.                 nativeSettingsIgnoreNextAction = false
  931.                 return
  932.             end
  933.             local isStateChanged = ui.settings.autohideMonitorWindow ~= newState
  934.             ui.settings.autohideMonitorWindow = newState
  935.             if isStateChanged then
  936.                 lastShowWidget = nil
  937.                 lastIsLooting  = nil
  938.                 ui.config.saveConfig("config/config.json", ui.settings)
  939.             end
  940.         end)
  941.     end
  942. end
  943.  
  944. local minimapMonitorWidget = {}
  945. local indicator = {
  946.     last  = 0,
  947.     max   = 4,
  948.     chars = {
  949.         "   ",
  950.         ".  ",
  951.         ".. ",
  952.         "..."
  953.     }
  954. }
  955. local prevTickTime = 0
  956.  
  957. function createMinimapMonitor(skipPreCheck)
  958.     if not skipPreCheck then
  959.         if minimapMonitorWidget.widget and IsDefined(minimapMonitorWidget.widget) then return end
  960.         if not lastMinimapContainerController then return end
  961.         if not IsDefined(lastMinimapContainerController) then return end
  962.     end
  963.  
  964.     local fontSize  = 26
  965.     local topWidget = inkFlex.new()
  966.     topWidget:SetVisible(false)
  967.     topWidget:SetName("minimapAutolootMonitor")
  968.     CName.add("minimapAutolootMonitor")
  969.     local margin = inkMargin.new({ left = -330, top = -19, right = 0, bottom = 0 })
  970.     topWidget:SetMargin(margin)
  971.  
  972.     label = inkText.new()
  973.     label:SetName("minimapAutolootMonitorLabel")
  974.     CName.add("minimapAutolootMonitorLabel")
  975.     label:SetFontFamily("base\\gameplay\\gui\\fonts\\raj\\raj.inkfontfamily")
  976.     label:SetFontStyle("Regular")
  977.     label:SetFontSize(fontSize)
  978.     label:SetStyle(ResRef.FromName("base\\gameplay\\gui\\fullscreen\\fullscreen_main_colors.inkstyle"))
  979.     label:BindProperty(tintColor, MainColorsMediumBlue)
  980.     label:BindProperty(fontStyle, MainColorsBodyFontWeight)
  981.     label:SetAnchor(inkEAnchor.CenterLeft)
  982.     label:SetAnchorPoint(Vector2.new({ X = 0, Y = 0.5 }))
  983.     label:SetVerticalAlignment(textVerticalAlignment.Center)
  984.     label:SetText("Idle.")
  985.     label.fitToContent = false
  986.     label:SetMargin(math.ceil(fontSize * 0.5), 0, 0, 0)
  987.     label:Reparent(topWidget, -1)
  988.  
  989.     return {
  990.         widget = topWidget,
  991.         label  = label
  992.     }
  993. end
  994.  
  995. function addMonitorWidgetToMinimap()
  996.     if not lastMinimapContainerController then return end
  997.     if not IsDefined(lastMinimapContainerController) then return end
  998.     local parent = lastMinimapContainerController.timeDisplayWidget.widget
  999.     if not parent then return end
  1000.     parent = parent.parentWidget
  1001.     if not parent then return end
  1002.     if isPreGameState then
  1003.         removeMonitorWidget(parent)
  1004.         return
  1005.     end
  1006.  
  1007.     local lookedWidget = parent:GetWidget("minimapAutolootMonitor")
  1008.     if lookedWidget and lookedWidget.name.value == "minimapAutolootMonitor" then
  1009.         if isSameInstance(lookedWidget, minimapMonitorWidget.widget) then return end
  1010.         parent:RemoveChild(lookedWidget)
  1011.         minimapMonitorWidget = {}
  1012.     end
  1013.  
  1014.     if (not minimapMonitorWidget.widget) or (not IsDefined(minimapMonitorWidget.widget)) then
  1015.         minimapMonitorWidget = createMinimapMonitor(true)
  1016.     end
  1017.     if not minimapMonitorWidget.widget then return end
  1018.  
  1019.     indicator.last = 1
  1020.     minimapMonitorWidget.widget:Reparent(parent, -1)
  1021. end
  1022.  
  1023. function removeMonitorWidget(parent)
  1024.     if minimapMonitorWidget.widget and IsDefined(minimapMonitorWidget.widget) then
  1025.         parent = parent or minimapMonitorWidget.widget.parentWidget
  1026.         if parent then
  1027.             parent:RemoveChild(minimapMonitorWidget.widget)
  1028.         end
  1029.         minimapMonitorWidget = {}
  1030.         indicator.last = 1
  1031.         return
  1032.     end
  1033.  
  1034.     if not lastMinimapContainerController then
  1035.         minimapMonitorWidget = {}
  1036.         indicator.last = 1
  1037.         return
  1038.     end
  1039.     if not IsDefined(lastMinimapContainerController) then
  1040.         minimapMonitorWidget = {}
  1041.         indicator.last = 1
  1042.         return
  1043.     end
  1044.     parent = parent or lastMinimapContainerController.timeDisplayWidget.widget.parentWidget
  1045.     if not parent then
  1046.         minimapMonitorWidget = {}
  1047.         indicator.last = 1
  1048.         return
  1049.     end
  1050.     local lookedWidget = parent:GetWidget("minimapAutolootMonitor")
  1051.     if lookedWidget and lookedWidget.name.value == "minimapAutolootMonitor" then
  1052.         parent:RemoveChild(lookedWidget)
  1053.     end
  1054.     minimapMonitorWidget = {}
  1055.     indicator.last = 1
  1056. end
  1057.  
  1058. function ui.hideMinimapMonitorWidget()
  1059.     if isPreGameState then return end
  1060.     if not minimapMonitorWidget.widget then return end
  1061.     if not minimapMonitorWidget.widget.isVisible then return end
  1062.     minimapMonitorWidget.widget:SetVisible(false)
  1063. end
  1064.  
  1065. local chr = indicator.chars[1]
  1066. function ui.updateMinimapMonitorWidgetText(showWidget, isLooting, force)
  1067.     if isPreGameState then return end
  1068.     if not minimapMonitorWidget.widget then return end
  1069.     if not IsDefined(minimapMonitorWidget.widget) then return end
  1070.     if not showWidget then
  1071.         minimapMonitorWidget.widget:SetVisible(false)
  1072.         return
  1073.     end
  1074.  
  1075.     if shouldForceMinimapMonitorUpdate then
  1076.         force = true
  1077.         shouldForceMinimapMonitorUpdate = false
  1078.     end
  1079.     local isUpdate = force or lastShowWidget ~= showWidget or lastIsLooting ~= isLooting
  1080.     lastShowWidget = showWidget
  1081.     lastIsLooting  = isLooting
  1082.     if (not isUpdate) and (not isLooting) then return end
  1083.  
  1084.     local labelText = ""
  1085.     if isLooting then
  1086.         labelText = uiStrings.nuiUiStrings.monitor.lootingStr or "Looting "
  1087.         if isUpdate then
  1088.             if minimapMonitorWidget.setIsLooting then
  1089.                 minimapMonitorWidget.setIsLooting(isLooting)
  1090.             end
  1091.         end
  1092.         if prevTickTime ~= ui.logic.lastLootCompletedTime then
  1093.             prevTickTime = ui.logic.lastLootCompletedTime
  1094.             indicator.last = indicator.last + 1
  1095.             if indicator.last > indicator.max then
  1096.                 indicator.last = 1
  1097.             end
  1098.             chr = indicator.chars[indicator.last]
  1099.         end
  1100.         labelText = labelText .. chr
  1101.     else
  1102.         labelText = uiStrings.nuiUiStrings.monitor.idleStr or "Idle."
  1103.         if minimapMonitorWidget.setIsLooting then
  1104.             minimapMonitorWidget.setIsLooting(isLooting)
  1105.         end
  1106.         indicator.last = 1
  1107.     end
  1108.  
  1109.     minimapMonitorWidget.label:SetText(labelText)
  1110.     minimapMonitorWidget.widget:SetVisible(true)
  1111. end
  1112.  
  1113. function intToTimeStr(seconds)
  1114.     local hours   = math.floor(seconds / 3600)
  1115.     local minutes = math.floor((seconds % 3600) / 60)
  1116.     local secs    = seconds % 60
  1117.     return string.format("%02d:%02d:%02d", hours, minutes, secs)
  1118. end
  1119.  
  1120. function intToMinSecStr(seconds)
  1121.     if type(seconds) ~= "number" then return end
  1122.     local minutes = math.floor((seconds % 3600) / 60)
  1123.     local secs    = seconds % 60
  1124.     return string.format("%02d:%02d", minutes, secs)
  1125. end
  1126.  
  1127. ui.shouldInitWindow    = false
  1128. local shouldApplyStyle = false
  1129. -- START - REACTIF UI REWORK
  1130. --local leftSideWidth, rightSideWidth = 200, 100
  1131. local leftSideWidth, rightSideWidth = 200, 0  -- Removal of the right-hand column of tooltips
  1132. local CPS = require("CPStyling")              -- Need to transform tooltips into real tooltips
  1133. -- END - REACTIF UI REWORK
  1134. local minWindowWidth   = leftSideWidth + rightSideWidth
  1135. local rangeButtonWidth = math.floor(rightSideWidth * 0.8)
  1136. local leftMargin       = 8
  1137. local step             = 15
  1138. local maxVal           = 300
  1139. local minVal           = step
  1140. local halfStep         = step * 0.5
  1141.  
  1142. local rangeSliderName    = "##" .. ui.modName .. "range_slider"
  1143. local burstTimeLeftName  = "##" .. ui.modName .. "burstTimeLeft"
  1144. local burstTimeRightName = "##" .. ui.modName .. "burstTimeRight"
  1145. local burstTimeName      = "##" .. ui.modName .. "burstTime"
  1146. local mainViewTableName  = "##" .. ui.modName .. "mainViewTable"
  1147. local timeCounterWidth   = 41
  1148. local timeCounter = {
  1149.     width   = 41,
  1150.     lastVal = 0,
  1151.     lastStr = "00:00"
  1152. }
  1153. local footer     = ui.modName .. " " .. ui.modVer
  1154. local isFirstRun = true
  1155.  
  1156. function initWindow(autoLoot)
  1157.     ui.shouldInitWindow = false
  1158.     shouldApplyStyle = type(autoLoot.CPS) == "table"
  1159.     local x, y = ImGui.CalcTextSize("abcdefghijklmnoprstuwxyz /_.,ABCDEFGHIJKLMNOPRSTUWXYZ")
  1160.     local widthFactor = 17
  1161.     leftSideWidth     = math.floor(y * widthFactor)
  1162.     rightSideWidth    = math.floor(y * widthFactor / 1.3)
  1163.     minWindowWidth    = leftSideWidth + rightSideWidth
  1164.     rangeButtonWidth  = math.floor(leftSideWidth * 0.85)
  1165.     leftMargin        = ImGui.GetTextLineHeight() * 0.5
  1166.     timeCounter.width = ImGui.CalcTextSize("_00:00_")
  1167.     if type(autoLoot.uiBurstParams) == "table" then
  1168.         step     = autoLoot.uiBurstParams[1] or step
  1169.         maxVal   = autoLoot.uiBurstParams[3] or maxVal
  1170.         minVal   = step
  1171.         halfStep = step * 0.5
  1172.     end
  1173.     footer = ui.modName .. " " .. ui.modVer
  1174. end
  1175.  
  1176. function ui.draw(autoLoot)
  1177.     if ui.shouldInitWindow then
  1178.         initWindow(autoLoot)
  1179.     end
  1180.     if shouldApplyStyle then
  1181.         autoLoot.CPS.setThemeBegin()
  1182.     end
  1183.     -- START - REACTIF UI REWORK: Adjusting the size of the window bar (CET closed on first launch)
  1184.     --ImGui.SetNextWindowSize(minWindowWidth, -1)
  1185.     ImGui.SetNextWindowSize(minWindowWidth / 2, -1)
  1186.     -- END - REACTIF UI REWORK
  1187.     if ImGui.Begin(uiStrings.cetUiStrings.settings.windowTitle or "AutoLoot", ImGuiWindowFlags.AlwaysAutoResize) then
  1188.         if ImGui.IsWindowCollapsed() then
  1189.             if shouldApplyStyle then
  1190.                 autoLoot.CPS.setThemeEnd()
  1191.             end
  1192.             ImGui.End()
  1193.             return
  1194.         end
  1195.  
  1196.         if not ui.isInitialized then
  1197.             ImGui.Spacing()
  1198.             ImGui.TextWrapped(uiStrings.cetUiStrings.warnings.modDisabled)
  1199.             ImGui.Spacing()
  1200.             ImGui.Separator()
  1201.             ImGui.Text(ui.modName .. " " .. ui.modVer .. "            ")
  1202.             if shouldApplyStyle then
  1203.                 autoLoot.CPS.setThemeEnd()
  1204.             end
  1205.             ImGui.End()
  1206.             return
  1207.         end
  1208.  
  1209.         pcall(function()
  1210.             ImGui.Separator()
  1211.  
  1212.             --[[ START - REACTIF UI REWORK: Removal of the right-hand column of tooltips
  1213.             local isTable = ImGui.BeginTable(mainViewTableName, 2)
  1214.             if isTable then
  1215.                 if isFirstRun then
  1216.                     ImGui.TableSetupColumn(mainViewTableName) --ImGui.TableSetupColumn(mainViewTableName, 0, leftSideWidth)
  1217.                     isFirstRun = false
  1218.                 end
  1219.                 ImGui.TableNextColumn()
  1220.             end
  1221.             -- END - REACTIF UI REWORK ]]
  1222.  
  1223.             ImGui.TextWrapped(uiStrings.cetUiStrings.settings.general_settings)
  1224.             ImGui.Spacing()
  1225.  
  1226.             -- START - REACTIF UI REWORK: Removal of the default tooltips text (no longer needed)
  1227.             --local tooltips = uiStrings.cetUiStrings.settings.tooltipsHeader
  1228.             -- END - REACTIF UI REWORK
  1229.  
  1230.             ImGui.TextWrapped(uiStrings.cetUiStrings.settings.range.title)
  1231.             if ImGui.IsItemHovered() then
  1232.                 tooltips = uiStrings.cetUiStrings.settings.range.tooltips
  1233.                 -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1234.                 CPS.CPToolTip1Begin(300, 60)
  1235.                 ImGui.TextWrapped(tooltips)
  1236.                 CPS.CPToolTip1End()
  1237.                 -- END - REACTIF UI REWORK
  1238.             end
  1239.             if type(autoLoot.settings.range) ~= "number" then
  1240.                 autoLoot.settings.range = 20
  1241.             end
  1242.             ImGui.SetNextItemWidth(rangeButtonWidth)
  1243.             autoLoot.settings.range, changed = ImGui.SliderInt(rangeSliderName, autoLoot.settings.range, 1, 100)
  1244.             if changed then
  1245.                 if isUsingNativeSettings and nativeSettingsOptions.range then
  1246.                     nativeSettingsIgnoreNextAction = true
  1247.                     nativeSettingsPlaySounds       = true
  1248.                     nativeSettings.setOption(nativeSettingsOptions.range, autoLoot.settings.range)
  1249.                 end
  1250.                 autoLoot.config.saveConfig("config/config.json", autoLoot.settings)
  1251.             end
  1252.             if ImGui.IsItemHovered() then
  1253.                 tooltips = uiStrings.cetUiStrings.settings.range.tooltips
  1254.                 -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1255.                 CPS.CPToolTip1Begin(300, 60)
  1256.                 ImGui.TextWrapped(tooltips)
  1257.                 CPS.CPToolTip1End()
  1258.                 -- END - REACTIF UI REWORK
  1259.             end
  1260.             ImGui.Spacing()
  1261.  
  1262.             if type(autoLoot.settings.useDefaultActionKey) ~= "boolean" then
  1263.                 autoLoot.settings.useDefaultActionKey = false
  1264.             end
  1265.             autoLoot.settings.useDefaultActionKey, changed = ImGui.Checkbox(
  1266.                 uiStrings.cetUiStrings.settings.useDefaultActionKey.title,
  1267.                 autoLoot.settings.useDefaultActionKey
  1268.             )
  1269.             if changed then
  1270.                 if isUsingNativeSettings and nativeSettingsOptions.useDefaultActionKey then
  1271.                     nativeSettingsIgnoreNextAction = true
  1272.                     nativeSettingsPlaySounds       = true
  1273.                     nativeSettings.setOption(
  1274.                         nativeSettingsOptions.useDefaultActionKey,
  1275.                         autoLoot.settings.useDefaultActionKey
  1276.                     )
  1277.                 end
  1278.                 autoLoot.config.saveConfig("config/config.json", autoLoot.settings)
  1279.             end
  1280.             if ImGui.IsItemHovered() then
  1281.                 tooltips = uiStrings.cetUiStrings.settings.useDefaultActionKey.tooltips
  1282.                 -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1283.                 CPS.CPToolTip1Begin(300, 150)
  1284.                 ImGui.TextWrapped(tooltips)
  1285.                 CPS.CPToolTip1End()
  1286.                 -- END - REACTIF UI REWORK
  1287.             end
  1288.             ImGui.Spacing()
  1289.  
  1290.             if type(autoLoot.settings.enableTakedownLoot) ~= "boolean" then
  1291.                 autoLoot.settings.enableTakedownLoot = false
  1292.             end
  1293.             autoLoot.settings.enableTakedownLoot, changed = ImGui.Checkbox(
  1294.                 uiStrings.cetUiStrings.settings.enableTakedownLoot.title,
  1295.                 autoLoot.settings.enableTakedownLoot
  1296.             )
  1297.             if changed then
  1298.                 if isUsingNativeSettings and nativeSettingsOptions.enableTakedownLoot then
  1299.                     nativeSettingsIgnoreNextAction = true
  1300.                     nativeSettingsPlaySounds       = true
  1301.                     nativeSettings.setOption(
  1302.                         nativeSettingsOptions.enableTakedownLoot,
  1303.                         autoLoot.settings.enableTakedownLoot
  1304.                     )
  1305.                 end
  1306.                 autoLoot.config.saveConfig("config/config.json", autoLoot.settings)
  1307.             end
  1308.             if ImGui.IsItemHovered() then
  1309.                 tooltips = uiStrings.cetUiStrings.settings.enableTakedownLoot.tooltips
  1310.                 -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1311.                 CPS.CPToolTip1Begin(300, 110)
  1312.                 ImGui.TextWrapped(tooltips)
  1313.                 CPS.CPToolTip1End()
  1314.                 -- END - REACTIF UI REWORK
  1315.             end
  1316.             ImGui.Spacing()
  1317.  
  1318.             if type(autoLoot.settings.enableBurstTrigger) ~= "boolean" then
  1319.                 autoLoot.settings.enableBurstTrigger = false
  1320.             end
  1321.             autoLoot.settings.enableBurstTrigger, changed = ImGui.Checkbox(
  1322.                 uiStrings.cetUiStrings.settings.enableBurstTrigger.title,
  1323.                 autoLoot.settings.enableBurstTrigger
  1324.             )
  1325.             if changed then
  1326.                 if isUsingNativeSettings and nativeSettingsOptions.enableBurstTrigger then
  1327.                     nativeSettingsIgnoreNextAction = true
  1328.                     nativeSettingsPlaySounds       = true
  1329.                     nativeSettings.setOption(
  1330.                         nativeSettingsOptions.enableBurstTrigger,
  1331.                         autoLoot.settings.enableBurstTrigger
  1332.                     )
  1333.                 end
  1334.                 autoLoot.config.saveConfig("config/config.json", autoLoot.settings)
  1335.                 if (not autoLoot.settings.enableBurstTrigger) and autoLoot.isBurst then
  1336.                     GetPlayer():RemoveCooldown("autoloot_burst_trigger_cooldown")
  1337.                 end
  1338.             end
  1339.             if ImGui.IsItemHovered() then
  1340.                 tooltips = uiStrings.cetUiStrings.settings.enableBurstTrigger.tooltips
  1341.                 -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1342.                 CPS.CPToolTip1Begin(300, 220)
  1343.                 ImGui.TextWrapped(tooltips)
  1344.                 CPS.CPToolTip1End()
  1345.                 -- END - REACTIF UI REWORK
  1346.             end
  1347.             ImGui.Spacing()
  1348.  
  1349.             if type(autoLoot.settings.burstTriggerCooldownTime) == "number" then
  1350.                 local val       = autoLoot.settings.burstTriggerCooldownTime
  1351.                 local changed   = false
  1352.                 local isEnabled = autoLoot.settings.enableBurstTrigger
  1353.                 if not isEnabled then
  1354.                     ImGui.BeginDisabled()
  1355.                 end
  1356.  
  1357.                 ImGui.TextWrapped(uiStrings.cetUiStrings.settings.burstTriggerCooldownTime.title)
  1358.                 if ImGui.IsItemHovered() then
  1359.                     tooltips = uiStrings.cetUiStrings.settings.burstTriggerCooldownTime.tooltips
  1360.                     -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1361.                     CPS.CPToolTip1Begin(300, 80)
  1362.                     ImGui.TextWrapped(tooltips)
  1363.                     CPS.CPToolTip1End()
  1364.                     -- END - REACTIF UI REWORK
  1365.                 end
  1366.                 if ImGui.ArrowButton(burstTimeLeftName, ImGuiDir.Left) then
  1367.                     if val > minVal then
  1368.                         val     = math.max(val - step, minVal)
  1369.                         val     = math.floor((val + halfStep) / step) * step
  1370.                         changed = val ~= autoLoot.settings.burstTriggerCooldownTime
  1371.                     end
  1372.                 end
  1373.                 if ImGui.IsItemHovered() then
  1374.                     tooltips = uiStrings.cetUiStrings.settings.burstTriggerCooldownTime.tooltips
  1375.                     -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1376.                     CPS.CPToolTip1Begin(300, 80)
  1377.                     ImGui.TextWrapped(tooltips)
  1378.                     CPS.CPToolTip1End()
  1379.                     -- END - REACTIF UI REWORK
  1380.                 end
  1381.                 ImGui.SameLine()
  1382.                 if val ~= timeCounter.lastVal then
  1383.                     timeCounter.lastVal = val
  1384.                     timeCounter.lastStr = intToMinSecStr(val)
  1385.                 end
  1386.                 ImGui.SetNextItemWidth(timeCounter.width)
  1387.                 ImGui.InputText(burstTimeName, timeCounter.lastStr, 5, ImGuiInputTextFlags.ReadOnly)
  1388.                 if ImGui.IsItemHovered() then
  1389.                     tooltips = uiStrings.cetUiStrings.settings.burstTriggerCooldownTime.tooltips
  1390.                     -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1391.                     CPS.CPToolTip1Begin(300, 80)
  1392.                     ImGui.TextWrapped(tooltips)
  1393.                     CPS.CPToolTip1End()
  1394.                     -- END - REACTIF UI REWORK
  1395.                 end
  1396.                 ImGui.SameLine()
  1397.                 if ImGui.ArrowButton(burstTimeRightName, ImGuiDir.Right) then
  1398.                     if val < maxVal then
  1399.                         val     = math.min(val + step, maxVal)
  1400.                         val     = math.floor((val + halfStep) / step) * step
  1401.                         changed = val ~= autoLoot.settings.burstTriggerCooldownTime
  1402.                     end
  1403.                 end
  1404.                 if ImGui.IsItemHovered() then
  1405.                     tooltips = uiStrings.cetUiStrings.settings.burstTriggerCooldownTime.tooltips
  1406.                     -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1407.                     CPS.CPToolTip1Begin(300, 80)
  1408.                     ImGui.TextWrapped(tooltips)
  1409.                     CPS.CPToolTip1End()
  1410.                     -- END - REACTIF UI REWORK
  1411.                 end
  1412.                 if changed then
  1413.                     autoLoot.settings.burstTriggerCooldownTime = val
  1414.                     if isUsingNativeSettings and nativeSettingsOptions.burstTriggerCooldownTime then
  1415.                         nativeSettingsIgnoreNextAction = true
  1416.                         nativeSettingsPlaySounds       = true
  1417.                         nativeSettings.setOption(
  1418.                             nativeSettingsOptions.burstTriggerCooldownTime,
  1419.                             autoLoot.settings.burstTriggerCooldownTime
  1420.                         )
  1421.                     end
  1422.                     autoLoot.config.saveConfig("config/config.json", autoLoot.settings)
  1423.                 end
  1424.                 if ImGui.IsItemHovered() then
  1425.                     tooltips = uiStrings.cetUiStrings.settings.burstTriggerCooldownTime.tooltips
  1426.                     -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1427.                     CPS.CPToolTip1Begin(300, 80)
  1428.                     ImGui.TextWrapped(tooltips)
  1429.                     CPS.CPToolTip1End()
  1430.                     -- END - REACTIF UI REWORK
  1431.                 end
  1432.                 if not isEnabled then
  1433.                     ImGui.EndDisabled()
  1434.                 end
  1435.                 ImGui.Spacing()
  1436.             end
  1437.  
  1438.             ImGui.Separator()
  1439.             ImGui.TextWrapped(uiStrings.cetUiStrings.settings.monitor_settings)
  1440.             ImGui.Spacing()
  1441.  
  1442.             if type(autoLoot.settings.showDebugMonitorWindow) ~= "boolean" then
  1443.                 autoLoot.settings.showDebugMonitorWindow = false
  1444.             end
  1445.             autoLoot.settings.showDebugMonitorWindow, changed = ImGui.Checkbox(
  1446.                 uiStrings.cetUiStrings.settings.showDebugMonitorWindow.title,
  1447.                 autoLoot.settings.showDebugMonitorWindow
  1448.             )
  1449.             if changed then
  1450.                 lastShowWidget = nil
  1451.                 lastIsLooting  = nil
  1452.                 if isUsingNativeSettings and nativeSettingsOptions.showDebugMonitorWindow then
  1453.                     nativeSettingsIgnoreNextAction = true
  1454.                     nativeSettingsPlaySounds       = true
  1455.                     setupNativeSettings(true)
  1456.                 end
  1457.                 if autoLoot.settings.showDebugMonitorWindow then
  1458.                     addMonitorWidgetToMinimap()
  1459.                 else
  1460.                     removeMonitorWidget()
  1461.                 end
  1462.                 autoLoot.config.saveConfig("config/config.json", autoLoot.settings)
  1463.             end
  1464.             if ImGui.IsItemHovered() then
  1465.                 tooltips = uiStrings.cetUiStrings.settings.showDebugMonitorWindow.tooltips
  1466.                 -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1467.                 CPS.CPToolTip1Begin(300, 75)
  1468.                 ImGui.TextWrapped(tooltips)
  1469.                 CPS.CPToolTip1End()
  1470.                 -- END - REACTIF UI REWORK
  1471.             end
  1472.             ImGui.Spacing()
  1473.  
  1474.             if autoLoot.settings.showDebugMonitorWindow then
  1475.                 if type(autoLoot.settings.monitorType) ~= "number" then
  1476.                     autoLoot.settings.monitorType = 0
  1477.                 end
  1478.                 local choices = uiStrings.cetUiStrings.settings.monitorType.choices
  1479.                 if type(choices) == "table" and #choices > 0 then
  1480.                     ImGui.Text(uiStrings.cetUiStrings.settings.monitorType.title)
  1481.                     if ImGui.IsItemHovered() then
  1482.                         tooltips = uiStrings.cetUiStrings.settings.monitorType.tooltips
  1483.                         -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1484.                         CPS.CPToolTip1Begin(300, 55)
  1485.                         ImGui.TextWrapped(tooltips)
  1486.                         CPS.CPToolTip1End()
  1487.                         -- END - REACTIF UI REWORK
  1488.                     end
  1489.                     ImGui.SetNextItemWidth(rangeButtonWidth)
  1490.                     local oldValue = ui.settings.monitorType
  1491.                     local newValue, isClicked = ImGui.Combo("##monitorType", oldValue, choices, #choices)
  1492.                     if newValue ~= oldValue then
  1493.                         lastShowWidget = nil
  1494.                         lastIsLooting  = nil
  1495.                         autoLoot.settings.monitorType = newValue
  1496.                         if isUsingNativeSettings and nativeSettingsOptions.monitorType then
  1497.                             nativeSettingsIgnoreNextAction = true
  1498.                             nativeSettingsPlaySounds       = true
  1499.                             nativeSettings.setOption(
  1500.                                 nativeSettingsOptions.monitorType,
  1501.                                 autoLoot.settings.monitorType + 1
  1502.                             )
  1503.                         end
  1504.                         autoLoot.config.saveConfig("config/config.json", autoLoot.settings)
  1505.                     end
  1506.                     if ImGui.IsItemHovered() then
  1507.                         tooltips = uiStrings.cetUiStrings.settings.monitorType.tooltips
  1508.                         -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1509.                         CPS.CPToolTip1Begin(300, 55)
  1510.                         ImGui.TextWrapped(tooltips)
  1511.                         CPS.CPToolTip1End()
  1512.                         -- END - REACTIF UI REWORK
  1513.                     end
  1514.                     ImGui.Spacing()
  1515.                 end
  1516.  
  1517.                 if type(autoLoot.settings.showMonitorWindowOnlyWhenTriggerActive) ~= "boolean" then
  1518.                     autoLoot.settings.showMonitorWindowOnlyWhenTriggerActive = false
  1519.                 end
  1520.                 autoLoot.settings.showMonitorWindowOnlyWhenTriggerActive, changed = ImGui.Checkbox(
  1521.                     uiStrings.cetUiStrings.settings.showMonitorWindowOnlyWhenTriggerActive.title,
  1522.                     autoLoot.settings.showMonitorWindowOnlyWhenTriggerActive
  1523.                 )
  1524.                 if changed then
  1525.                     lastShowWidget = nil
  1526.                     lastIsLooting  = nil
  1527.                     if isUsingNativeSettings and nativeSettingsOptions.showMonitorWindowOnlyWhenTriggerActive then
  1528.                         nativeSettingsIgnoreNextAction = true
  1529.                         nativeSettingsPlaySounds       = true
  1530.                         nativeSettings.setOption(
  1531.                             nativeSettingsOptions.showMonitorWindowOnlyWhenTriggerActive,
  1532.                             autoLoot.settings.showMonitorWindowOnlyWhenTriggerActive
  1533.                         )
  1534.                     end
  1535.                     autoLoot.config.saveConfig("config/config.json", autoLoot.settings)
  1536.                 end
  1537.                 if ImGui.IsItemHovered() then
  1538.                     tooltips = uiStrings.cetUiStrings.settings.showMonitorWindowOnlyWhenTriggerActive.tooltips
  1539.                     -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1540.                     CPS.CPToolTip1Begin(300, 70)
  1541.                     ImGui.TextWrapped(tooltips)
  1542.                     CPS.CPToolTip1End()
  1543.                     -- END - REACTIF UI REWORK
  1544.                 end
  1545.                 ImGui.Spacing()
  1546.  
  1547.                 if type(autoLoot.settings.autohideMonitorWindow) ~= "boolean" then
  1548.                     autoLoot.settings.autohideMonitorWindow = false
  1549.                 end
  1550.                 autoLoot.settings.autohideMonitorWindow, changed = ImGui.Checkbox(
  1551.                     uiStrings.cetUiStrings.settings.autohideMonitorWindow.title,
  1552.                     autoLoot.settings.autohideMonitorWindow
  1553.                 )
  1554.                 if changed then
  1555.                     lastShowWidget = nil
  1556.                     lastIsLooting  = nil
  1557.                     if isUsingNativeSettings and nativeSettingsOptions.autohideMonitorWindow then
  1558.                         nativeSettingsIgnoreNextAction = true
  1559.                         nativeSettingsPlaySounds       = true
  1560.                         nativeSettings.setOption(
  1561.                             nativeSettingsOptions.autohideMonitorWindow,
  1562.                             autoLoot.settings.autohideMonitorWindow
  1563.                         )
  1564.                     end
  1565.                     autoLoot.config.saveConfig("config/config.json", autoLoot.settings)
  1566.                 end
  1567.                 if ImGui.IsItemHovered() then
  1568.                     tooltips = uiStrings.cetUiStrings.settings.autohideMonitorWindow.tooltips
  1569.                     -- START - REACTIF UI REWORK: Transform tooltips into real tooltips
  1570.                     CPS.CPToolTip1Begin(300, 60)
  1571.                     ImGui.TextWrapped(tooltips)
  1572.                     CPS.CPToolTip1End()
  1573.                     -- END - REACTIF UI REWORK
  1574.                 end
  1575.                 ImGui.Spacing()
  1576.             end
  1577.  
  1578.             --[[ START - REACTIF UI REWORK: Removal of the right-hand column of tooltips
  1579.             if isTable then
  1580.                 ImGui.TableNextColumn()
  1581.                 ImGui.Dummy(rightSideWidth, 0)
  1582.                 if tooltips then
  1583.                     if shouldApplyStyle then
  1584.                         autoLoot.CPS.setThemeEnd()
  1585.                     end
  1586.                     ImGui.Indent(leftMargin)
  1587.                     ImGui.PushStyleColor(ImGuiCol.Text, 0xffc0c8cf)
  1588.                     ImGui.TextWrapped(tooltips)
  1589.                     ImGui.PopStyleColor()
  1590.                     ImGui.Unindent(leftMargin)
  1591.                     if shouldApplyStyle then
  1592.                         autoLoot.CPS.setThemeBegin()
  1593.                     end
  1594.                 end
  1595.             end
  1596.             if isTable then
  1597.                 ImGui.EndTable()
  1598.             end
  1599.             -- END - REACTIF UI REWORK ]]
  1600.  
  1601.             ImGui.Separator()
  1602.             ImGui.TextWrapped(footer)
  1603.         end)
  1604.     end
  1605.     if shouldApplyStyle then
  1606.         autoLoot.CPS.setThemeEnd()
  1607.     end
  1608.     ImGui.End()
  1609. end
  1610.  
  1611. return ui
Advertisement
Add Comment
Please, Sign In to add comment