<commit_before>local A, L = unpack(select(2, ...))
local M = A:NewModule("options", "AceTimer-3.0")
A.options = M
M.private = {
  optionsGUI = false,
  optionsTable = false,
  defaults = {
    profile = {
      options = {
        tankAssist = true,
        fixOfflineML = true,
        sortMode = "TMURH", -- other valid values: "THMUR", "meter", "nosort"
        splitOddEven = true,
        resumeAfterCombat = true,
        tankMainTankAlways = false,
        tankMainTankPRN = true, -- ignored (implied false) if tankMainTankAlways == true
        openRaidTabPRN = true, -- ignored (implied false) if tankMainTankAlways == true and tankMainTankPRN = false
        tankMark = true,
        tankMarkIcons = {4, 6, 1, 2, 3, 7, 9, 9},
        partyMark = true,
        partyMarkIcons = {4, 6, 9, 9, 9},
        minimapIcon = {}, -- handled by LibDBIcon
        showMinimapIconAlways = true,
        showMinimapIconPRN = false, -- ignored (implied false) if showMinimapIconAlways == true
        addButtonToRaidTab = true,
        watchChat = true,
        announceChatAlways = false,
        announceChatPRN = true, -- ignored (implied false) if announceChatAlways == true
      },
    },
  },
}
local R = M.private

-- In parentheses is how many times DBM uses that mark for all Draenor content.
--
-- Skull, cross, and moon are used the least frequently. However those marks
-- usually mean "kill first", "kill second", and "keep cc'd", respectively.
--
-- Of the remaining marks, triangle and square are next. That's why they're the
-- default tank marks.
local MARKS = {
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_1:14:14:0:0|t", -- 1=star (16)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_2:14:14:0:0|t", -- 2=circle (16)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_3:14:14:0:0|t", -- 3=diamond (14)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_4:14:14:0:0|t", -- 4=triangle (11)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_5:14:14:0:0|t", -- 5=moon (9)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_6:14:14:0:0|t", -- 6=square (10)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_7:14:14:0:0|t", -- 7=cross (7)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_8:14:14:0:0|t", -- 8=skull (9)
  L["options.value.noMark"],
}
local DELAY_FIX_BUTTONS = 0.1

local ipairs = ipairs

local function getOptionMark(arr, index)
  if arr[index] and arr[index] <= 8 then
    return arr[index]
  end
  return 9
end

local function setOptionMark(arr, index, value)
  if arr ~= A.options.partyMarkIcons then
    A.sorter:Stop()
  end
  if value <= 0 or value > 8 then
    value = 9
  end
  arr[index] = value
  -- Assume the user knows what they're doing.
  -- Don't bother fixing duplicates.
end

local BUTTONS, RAIDLEAD, RAIDASSIST, PARTY, UI, CHAT, RESET = 100, 200, 300, 400, 500, 600, 700, 900

R.optionsTable = {
  type = "group",
  name = "|cff33ff99"..A.name.."|r "..format(L["versionAuthor"], A.version, "|cff33ff99"..A.author.."|r"),
  args = {
    desc = {
      order = 0,
      type = "description",
      name = L["options.widget.top.desc"].."|n",
      fontSize = "medium",
      hidden = function(i)
        -- For consistency's sake, we want the Fix Groups button in the options
        -- pane to be right-click-able, just like its twin on the raid tab.
        --
        -- Getting a reference to the button frame is a little kludgey.
        -- It's auto-created by Ace libraries, which doesn't give us an easy
        -- reference to the frame. So we walk the AceGUI tree each time the
        -- options pane is displayed.
        --
        -- We use a short timer to delay the tree walk: at the time the hidden
        -- function is called, the tree hasn't been built yet.
        M:ScheduleTimer(function()
          for _, g in ipairs(R.optionsGUI.obj.children[1].frame.obj.children) do
            if g.type == "Button" then
              -- Enable right-click on all buttons in the options pane.
              g.frame:RegisterForClicks("AnyUp")
            end
          end
        end, DELAY_FIX_BUTTONS)
      end,
    },
    buttonCommandDefault = {
      order = BUTTONS+10,
      type = "execute",
      name = L["button.fixGroups.text"],<commit_msg>fix Lua error that was occurring when player closes the config menu immediately<commit_after>local A, L = unpack(select(2, ...))
local M = A:NewModule("options", "AceTimer-3.0")
A.options = M
M.private = {
  optionsGUI = false,
  optionsTable = false,
  defaults = {
    profile = {
      options = {
        tankAssist = true,
        fixOfflineML = true,
        sortMode = "TMURH", -- other valid values: "THMUR", "meter", "nosort"
        splitOddEven = true,
        resumeAfterCombat = true,
        tankMainTankAlways = false,
        tankMainTankPRN = true, -- ignored (implied false) if tankMainTankAlways == true
        openRaidTabPRN = true, -- ignored (implied false) if tankMainTankAlways == true and tankMainTankPRN = false
        tankMark = true,
        tankMarkIcons = {4, 6, 1, 2, 3, 7, 9, 9},
        partyMark = true,
        partyMarkIcons = {4, 6, 9, 9, 9},
        minimapIcon = {}, -- handled by LibDBIcon
        showMinimapIconAlways = true,
        showMinimapIconPRN = false, -- ignored (implied false) if showMinimapIconAlways == true
        addButtonToRaidTab = true,
        watchChat = true,
        announceChatAlways = false,
        announceChatPRN = true, -- ignored (implied false) if announceChatAlways == true
      },
    },
  },
}
local R = M.private

-- In parentheses is how many times DBM uses that mark for all Draenor content.
--
-- Skull, cross, and moon are used the least frequently. However those marks
-- usually mean "kill first", "kill second", and "keep cc'd", respectively.
--
-- Of the remaining marks, triangle and square are next. That's why they're the
-- default tank marks.
local MARKS = {
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_1:14:14:0:0|t", -- 1=star (16)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_2:14:14:0:0|t", -- 2=circle (16)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_3:14:14:0:0|t", -- 3=diamond (14)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_4:14:14:0:0|t", -- 4=triangle (11)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_5:14:14:0:0|t", -- 5=moon (9)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_6:14:14:0:0|t", -- 6=square (10)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_7:14:14:0:0|t", -- 7=cross (7)
  "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_8:14:14:0:0|t", -- 8=skull (9)
  L["options.value.noMark"],
}
local DELAY_FIX_BUTTONS = 0.1

local ipairs = ipairs

local function getOptionMark(arr, index)
  if arr[index] and arr[index] <= 8 then
    return arr[index]
  end
  return 9
end

local function setOptionMark(arr, index, value)
  if arr ~= A.options.partyMarkIcons then
    A.sorter:Stop()
  end
  if value <= 0 or value > 8 then
    value = 9
  end
  arr[index] = value
  -- Assume the user knows what they're doing.
  -- Don't bother fixing duplicates.
end

local BUTTONS, RAIDLEAD, RAIDASSIST, PARTY, UI, CHAT, RESET = 100, 200, 300, 400, 500, 600, 700, 900

R.optionsTable = {
  type = "group",
  name = "|cff33ff99"..A.name.."|r "..format(L["versionAuthor"], A.version, "|cff33ff99"..A.author.."|r"),
  args = {
    desc = {
      order = 0,
      type = "description",
      name = L["options.widget.top.desc"].."|n",
      fontSize = "medium",
      hidden = function(i)
        -- For consistency's sake, we want the Fix Groups button in the options
        -- pane to be right-click-able, just like its twin on the raid tab.
        --
        -- Getting a reference to the button frame is a little kludgey.
        -- It's auto-created by Ace libraries, which doesn't give us an easy
        -- reference to the frame. So we walk the AceGUI tree each time the
        -- options pane is displayed.
        --
        -- We use a short timer to delay the tree walk: at the time the hidden
        -- function is called, the tree hasn't been built yet.
        M:ScheduleTimer(function()
          if not R.optionsGUI.obj.children[1] then
            -- The GUI tree does not exist any more.
            -- The player must have closed the options window immediately.
            return
          end
          for _, g in ipairs(R.optionsGUI.obj.children[1].frame.obj.children) do
            if g.type == "Button" then
              -- Enable right-click on all buttons in the options pane.
              g.frame:RegisterForClicks("AnyUp")
            end
          end
        end, DELAY_FIX_BUTTONS)
      end,
    },
    buttonCommandDefault = {
      order = BUTTONS+10,
      type = "execute",
      name = L["button.fixGroups.text"],
{'fraction_non_alphanumeric': 0.12831352833638027, 'fraction_numerical': 0.031192870201096894, 'mean_word_length': 2.6425301706200583, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5777220', 'n_tokens_mistral': 3091, 'n_tokens_neox': 2868, 'n_words': 826}