diff --git a/UI.lua b/UI.lua index 4f12406..45fba76 100644 --- a/UI.lua +++ b/UI.lua @@ -18,7 +18,7 @@ function WellEater:initSettingsMenu() if data.choices and not data.choicesValues then data.choicesValues = {} for i=1, #data.choices do - tinsert(data.choicesValues, i-1) + table.insert(data.choicesValues, i-1) end end @@ -41,8 +41,6 @@ function WellEater:initSettingsMenu() end if not data.setFunc then data.setFunc = function(value) - d("New value of" .. data.key .. " is") - d(value) self:setUserPreference(data.key, value) end end @@ -79,8 +77,6 @@ function WellEater:initSettingsMenu() name = L.timerSetupLabel, tooltip = L.timerSetupLabel_TT, setFunc = function(value) - d("New value of updayeYime is") - d(value) self:setUserPreference("updateTime", value) self.InterfaceHook_OnTimerSlider() @@ -95,41 +91,17 @@ function WellEater:initSettingsMenu() }) MakeControlEntry({ - type = "dropdown", - name = L.foodQualityMinHeader, - tooltip = L.foodQualityMinHeader, - choices = { - L.foodGreen, - L.foodBlue, - L.foodCyan, - L.foodGold - }, choicesValues = { - ITEM_QUALITY_MAGIC, - ITEM_QUALITY_ARCANE, - ITEM_QUALITY_ARTIFACT, - ITEM_QUALITY_LEGENDARY - }, - noAlert = true, - }, "general", "minQuality") - - MakeControlEntry({ - type = "dropdown", - name = L.foodQualityMaxHeader, - tooltip = L.foodQualityMaxHeader, - choices = { - L.foodGreen, - L.foodBlue, - L.foodCyan, - L.foodGold - }, choicesValues = { - ITEM_QUALITY_MAGIC, - ITEM_QUALITY_ARCANE, - ITEM_QUALITY_ARTIFACT, - ITEM_QUALITY_LEGENDARY - }, - noAlert = true, - }, "general", "maxQuality") + type = "header", + name = L.foodQualityHeader, + }) + for i = ITEM_QUALITY_MAGIC, ITEM_QUALITY_LEGENDARY do + MakeControlEntry({ + type = "checkbox", + name = L.foods[i], + tooltip = L.foods[i], + }, "general", i) + end self.optionsData = optionsTable -- local myLAMAddonPanel = diff --git a/WellEater.lua b/WellEater.lua index 7131c81..a8d8310 100644 --- a/WellEater.lua +++ b/WellEater.lua @@ -8,8 +8,10 @@ local NAMESPACE = {} NAMESPACE.settingsDefaults = { enabled = true, updateTime = 2000, - maxQuality = ITEM_QUALITY_ARCANE, - minQuality = ITEM_QUALITY_ARCANE + [ITEM_QUALITY_MAGIC] = false, + [ITEM_QUALITY_ARCANE] = true, + [ITEM_QUALITY_ARTIFACT] = false, + [ITEM_QUALITY_LEGENDARY] = false, } function WellEater:getAddonName() @@ -33,6 +35,10 @@ function WellEater:getUserPreference(setting) return self.settingsUser and self.settingsUser[setting] end +function WellEater:getAllUserPreferences() + return self.settingsUser +end + function WellEater:getUserDefault(setting) return NAMESPACE.settingsDefaults and NAMESPACE.settingsDefaults[setting] end @@ -129,6 +135,7 @@ local function processAutoEat() end for _, itemInfo in pairs(bagCache) do + local locSettings = WellEater:getAllUserPreferences() local slotId = itemInfo.slotIndex if not itemInfo.stolen then local itemType, specialType = GetItemType(bagId, slotId) @@ -136,22 +143,21 @@ local function processAutoEat() if (itemType == ITEMTYPE_FOOD or itemType == ITEMTYPE_DRINK) and not SkillUpItem(itemId) then local icon, stack, sellPrice, meetsUsageRequirement, locked, equipType, itemStyleId, quality = GetItemInfo(bagId, slotId) - local maxItemQ = WellEater:getUserPreference("maxQuality") - local minItemQ = WellEater:getUserPreference("minQuality") - if meetsUsageRequirement and maxItemQ and maxItemQ >= quality - and minItemQ and minItemQ <= quality then + if meetsUsageRequirement and locSettings and locSettings[quality] then local usable, onlyFromActionSlot = IsItemUsable(bagId, slotId) if usable and not onlyFromActionSlot then local itemLink = GetItemLink(bagId, slotId) local hasAbility,abilityHeader,abilityDescription = GetItemLinkOnUseAbilityInfo(itemLink) - - local formattedName = zo_strformat("<<1>>", GetItemLinkName(itemLink)) -- no control codes + local locale = WellEater:getLocale() + local formattedName = zo_strformat(locale.youEat, GetItemLinkName(itemLink)) -- no control codes if formattedName and abilityDescription then - d("Name = " .. formattedName) - d("Description = " .. abilityDescription) + --d("Name = " .. formattedName) + --d("Description = " .. abilityDescription) + WellEaterIndicator:SetHidden(false) + WellEaterIndicatorLabel:SetText(formattedName) end tryToUseItem(bagId, slotId) @@ -165,7 +171,6 @@ local function processAutoEat() end local function TimersUpdate() - if not WellEater:prepareToAnalize() then return end @@ -181,6 +186,7 @@ local function TimersUpdate() foodQuantity = timeEnding * 1000 - now haveFood = (bFood and (foodQuantity > 0)) if haveFood then + WellEaterIndicator:SetHidden(true) break end end @@ -205,8 +211,6 @@ local function StartUp() end local function ShutDown() - d(WellEater.AddonName .. " Shutdown minQ = " .. WellEater.settingsUser.minQuality) - d(WellEater.AddonName .. " Shutdown maxQ = " .. WellEater.settingsUser.maxQuality) d(WellEater.AddonName .. " Timer cancelled") EVENT_MANAGER:UnregisterForUpdate(WellEater.AddonName .. "_TimersUpdate") end diff --git a/WellEater.txt b/WellEater.txt index b376356..e6c1e4e 100644 --- a/WellEater.txt +++ b/WellEater.txt @@ -7,6 +7,7 @@ ## DependsOn: LibAddonMenu-2.0>=28 WellEater.lua +WellEater.xml UI.lua lang/en.lua lang/$(language).lua diff --git a/WellEater.xml b/WellEater.xml new file mode 100644 index 0000000..c16c05f --- /dev/null +++ b/WellEater.xml @@ -0,0 +1,15 @@ +<GuiXml> + <Controls> + <TopLevelControl name="WellEaterIndicator"> + <Dimensions x="200" y="25" /> + <Anchor point="CENTER" relativeTo="GuiRoot" relativePoint="CENTER" /> + + <Controls> + <Label name="$(parent)Label" width="300" height="40" font="ZoFontWinH4" inheritAlpha="true" color="FFFFFF" + wrapMode="TRUNCATE" verticalAlignment="TOP" horizontalAlignment="CENTER"> + <Anchor point="TOP" relativeTo="$(parent)" relativePoint="TOP" /> + </Label> + </Controls> + </TopLevelControl> + </Controls> +</GuiXml> \ No newline at end of file diff --git a/lang/en.lua b/lang/en.lua index c5883d1..7c40b70 100644 --- a/lang/en.lua +++ b/lang/en.lua @@ -2,17 +2,19 @@ WellEater = WellEater or {} local L = { generalSetupHeader = "Food search criteria to scan your inventory", generalSetupDescription = "Auto eat your preferred meals provided by your inventory after food or drink buff expiration", - foodQualityMinHeader = "Food Quality Min Range", - foodQualityMaxHeader = "Food Quality Max Range", - foodGreen = "Normal (green)", - foodBlue = "Excellent (blue)", - foodCyan = "Artifact (cyan)", - foodGold = "Legendary (gold)", - + foodQualityHeader = "Food Quality", + foods = { + [ITEM_QUALITY_MAGIC] = "Normal (green)", + [ITEM_QUALITY_ARCANE] = "Excellent (blue)", + [ITEM_QUALITY_ARTIFACT] = "Artifact (cyan)", + [ITEM_QUALITY_LEGENDARY] = "Legendary (gold)", + }, timerSetupHeader = "Inventory Scan Timer", timerSetupLabel = "Scan period, ms", timerSetupLabel_TT = "How often the inventory is scanned for food. The more the better but more probably " .. "you can run out of food for a long time in critical situation", + + youEat = "You have eaten <<1>>", } function WellEater:getLocale() diff --git a/lang/ru.lua b/lang/ru.lua index fa55c67..ad9965f 100644 --- a/lang/ru.lua +++ b/lang/ru.lua @@ -2,18 +2,20 @@ WellEater = WellEater or {} local L = { generalSetupHeader = "Критерии поиска еды в инвентаре", generalSetupDescription = "После истечения времени эффектов, которые дает еда, позволяет автоматически съесть найденное в инвентаре блюдо", - foodQualityMinHeader = "Минимум качества еды", - foodQualityMaxHeader = "Максимум качества еды", - foodGreen = "Хорошее (зеленое)", - foodBlue = "Превосходное (синее)", - foodCyan = "Эпическое (фиолетовое)", - foodGold = "Легендарное (золотое)", - + foodQualityHeader = "Качество еды", + foods = { + [ITEM_QUALITY_MAGIC] = "Хорошее (зеленое)", + [ITEM_QUALITY_ARCANE] = "Превосходное (синее)", + [ITEM_QUALITY_ARTIFACT] = "Эпическое (фиолетовое)", + [ITEM_QUALITY_LEGENDARY] = "Легендарное (золотое)", + }, timerSetupHeader = "Таймер опроса инвентаря", timerSetupLabel = "Период опроса, мс", timerSetupLabel_TT = "Как часто инвентарь сканируется на наличие еды." .. " Большее значение - меньше нагрузка но большая вероятность оказаться без еды на некоторое время".. " в критической ситуации", + + youEat = "Вы съели: <<1>>", } function WellEater:getLocale()