Skip to content

Commit

Permalink
Fixed a small Bug with Clickable Buttons and Added RasuLib (Base Addo…
Browse files Browse the repository at this point in the history
…n Library)
  • Loading branch information
Larsj02 committed May 22, 2024
1 parent fd4afb7 commit 367cf3f
Show file tree
Hide file tree
Showing 13 changed files with 462 additions and 100 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
"CLOSE",
"ButtonFrameTemplate_ShowButtonBar",
"ButtonFrameTemplate_HideAttic",
"DONE"
"DONE",
"SlashCmdList",
"hash_SlashCmdList",
"PVEFrame_ShowFrame",
"PVEFrame"
]
}
3 changes: 2 additions & 1 deletion CloakTooltip.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---@class RemixGemHelperPrivate
local Private = select(2, ...)
local addon = Private.Addon
local const = Private.constants
local function getCloakLevel()
local level = 0
Expand All @@ -9,7 +10,7 @@ local function getCloakLevel()
level = level + 1
end
end
return string.format(" [Rank %d/12]", level)
return string.format(" [%s %d/12]", addon.Loc["Rank"], level)
end

local function getCloakStats()
Expand Down
53 changes: 21 additions & 32 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ local Private = select(2, ...)
local const = Private.constants
local gemUtil = Private.GemUtil
local cache = Private.Cache
local settings = Private.Settings
local uiElements = Private.UIElements
local misc = Private.Misc
local scrapUtil = Private.ScrapUtil
local timeFormatter = CreateFromMixins(SecondsFormatterMixin);
timeFormatter:Init(1, 3, true, true);
local addon = Private.Addon
local timeFormatter = CreateFromMixins(SecondsFormatterMixin)
timeFormatter:Init(1, 3, true, true)

Private.TimeFormatter = timeFormatter
Private.Frames = {}
Expand Down Expand Up @@ -159,7 +159,7 @@ local function createScrapFrame()
})
local scrapItemsText = scrapBagItems:CreateFontString()
scrapItemsText:SetFontObject(const.FONT_OBJECTS.HEADING)
scrapItemsText:SetText("NOTHING TO USE")
scrapItemsText:SetText("NOTHING TO SCRAP")
scrapItemsText:SetPoint("CENTER", 0, -10)
scrapItemsText:Hide()
local allPointsScrap = {
Expand All @@ -183,7 +183,7 @@ local function createScrapFrame()
local scrappableItems = scrapUtil:GetScrappableItems()
for _, itemInfo in ipairs(scrappableItems) do
scrapItemScrollView:UpdateContentData(
{ { itemID = itemInfo.itemID, hideCount = true, itemLink = itemInfo.itemLink } }, true)
{ { itemID = itemInfo.itemID, hideCount = true, itemLink = itemInfo.itemLink } }, true)
end
scrapBagItems:SetHeight(#scrappableItems > 0 and 250 or 75)
scrapItemsText:SetShown(#scrappableItems < 1)
Expand All @@ -196,7 +196,7 @@ end
local function createFrame()
local gems = uiElements:CreateBaseFrame(CharacterFrame, {
title = const.ADDON_NAME,
width = 300
width = 375
})
gems:RegisterEvent("BAG_UPDATE_DELAYED")

Expand Down Expand Up @@ -274,7 +274,7 @@ local function createFrame()
GameTooltip:Hide()
end)
frameToggle:SetScript("OnMouseDown", function()
settings:UpdateSetting("show_frame", not settings:GetSetting("show_frame"))
addon:ToggleDatabaseValue("show_frame")
end)

---@class SearchFrame : EditBox
Expand All @@ -294,7 +294,7 @@ local function createFrame()
initializer = function(self, info)
for i = 0, #const.SOCKET_TYPES_INDEX do
local socketType = gemUtil:GetSocketTypeName(i)
if socketType ~= "Primordial" or settings:GetSetting("show_primordial") then
if socketType ~= "Primordial" or addon:GetDatabaseValue("show_primordial") then
info.func = self.SetValue
info.arg1 = i
info.checked = self.selection == i
Expand All @@ -318,7 +318,7 @@ local function createFrame()
text = "Unowned",
tooltip = "Show Unowned Gems in the List.",
onClick = function(self)
settings:UpdateSetting("show_unowned", self:GetChecked())
addon:SetDatabaseValue("show_unowned", self:GetChecked())
end
})

Expand All @@ -327,7 +327,7 @@ local function createFrame()
text = "Primordial",
tooltip = "Show Primordial Gems in the List.",
onClick = function(self)
settings:UpdateSetting("show_primordial", self:GetChecked())
addon:SetDatabaseValue("show_primordial", self:GetChecked())
end
})

Expand Down Expand Up @@ -378,27 +378,16 @@ local function createFrame()
bagItemScrollBox:SetScript("OnEvent", updateBagItems)
bagItemScrollBox:SetScript("OnShow", updateBagItems)

local helpText =
"|A:newplayertutorial-icon-mouse-leftbutton:16:16|a Click a Gem in this list to Socket or Unsocket.\n" ..
"'In Bag Item' or 'Socketed' indicates that you unsocket it.\n" ..
"'In Bag' indicates that the Gem is in your bag and ready to be socketed.\n\n" ..
"When hovering over a Gem that is 'Socketed' you will see the item highlighted in your character panel.\n" ..
"You can use the dropdown or the search bar at the top to filter your list.\n" ..
"This Addon also adds the current Rank and stats of your cloak inside the cloak tooltip.\n" ..
"You should see an icon in the top right of your character frame which can be used to hide or show this frame.\n" ..
"Below the Gem list you should have some clickable buttons to quickly open Chests or combine Gems\n\n" ..
"And to get rid of this frame simply shift click it.\nHave fun!"

local helpButton = CreateFrame("Button", nil, gems, "MainHelpPlateButton")
helpButton:SetScript("OnEnter", function(self)
HelpTip:Show(self, { text = helpText })
HelpTip:Show(self, { text = addon.Loc["HelpText"] })
end)
helpButton:SetScript("OnLeave", function(self)
HelpTip:Hide(self)
end)
helpButton:SetScript("OnClick", function(self)
helpButton:SetScript("OnClick", function()
if IsLeftShiftKeyDown() then
settings:UpdateSetting("show_helpframe", false)
addon:SetDatabaseValue("show_helpframe", false)
end
end)
helpButton:SetPoint("TOPRIGHT", 25, 25)
Expand Down Expand Up @@ -469,19 +458,19 @@ local function createFrame()
end)

selectionTreeUpdate()
settings:CreateSettingCallback("show_frame", function(_, newState)
gems:SetShown(newState)
addon:CreateDatabaseCallback("show_frame", function (_, value)
gems:SetShown(value)
end)
settings:CreateSettingCallback("show_unowned", function(_, newState)
addon:CreateDatabaseCallback("show_unowned", function (_, value)
selectionTreeUpdate()
showUnowned:SetChecked(newState)
showUnowned:SetChecked(value)
end)
settings:CreateSettingCallback("show_primordial", function(_, newState)
addon:CreateDatabaseCallback("show_primordial", function (_, value)
selectionTreeUpdate()
showPrimordial:SetChecked(newState)
showPrimordial:SetChecked(value)
end)
settings:CreateSettingCallback("show_helpframe", function(_, newState)
helpButton:SetShown(newState)
addon:CreateDatabaseCallback("show_helpframe", function (_, value)
helpButton:SetShown(value)
end)


Expand Down
7 changes: 4 additions & 3 deletions GemUtil.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---@class RemixGemHelperPrivate
local Private = select(2, ...)
local const = Private.constants
local addon = Private.Addon

---@class SocketTypeInfo
---@field name string
Expand Down Expand Up @@ -201,15 +202,15 @@ function gemUtil:GetFilteredGems(socketTypeFilter, nameFilter)
for _, gemInfo in pairs(self.owned_gems) do
local gemType = self:GetGemSocketType(gemInfo.itemID)
if socketTypeFilter == "ALL" or gemType == socketTypeFilter then
if gemType ~= "PRIMORDIAL" or Private.Settings:GetSetting("show_primordial") then
if gemType ~= "PRIMORDIAL" or addon:GetDatabaseValue("show_primordial") then
if isMatchingFilter(gemInfo.itemID, nameFilter) then
tinsert(validGems[gemType], gemInfo)
end
end
end
end

if Private.Settings:GetSetting("show_unowned") then
if addon:GetDatabaseValue("show_unowned") then
for gemItemID, gemType in pairs(const.GEM_SOCKET_TYPE) do
if socketTypeFilter == "ALL" or gemType == socketTypeFilter then
if isMatchingFilter(gemItemID, nameFilter) then
Expand All @@ -220,7 +221,7 @@ function gemUtil:GetFilteredGems(socketTypeFilter, nameFilter)
break
end
end
if (not dupeID) and (gemType ~= "PRIMORDIAL" or Private.Settings:GetSetting("show_primordial")) then
if (not dupeID) and (gemType ~= "PRIMORDIAL" or addon:GetDatabaseValue("show_primordial")) then
local cacheInfo = Private.Cache:GetItemInfo(gemItemID)
if cacheInfo and cacheInfo.link then
local hyperlink = cacheInfo.link
Expand Down
23 changes: 23 additions & 0 deletions Init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---@class RemixGemHelperPrivate
local Private = select(2, ...)
local const = Private.constants

local defaultDatabase = {
show_unowned = false,
show_primordial = false,
show_frame = true,
show_helpframe = true
}

local addon = LibStub("RasuAddon"):CreateAddon(
const.ADDON_NAME,
"RemixGemHelperDB",
defaultDatabase,
Private.Locales
)
for lang, langInfo in pairs(Private.Locales) do
if langInfo.isEditing then
function GetLocale() return lang end
end
end
Private.Addon = addon
Loading

0 comments on commit 367cf3f

Please sign in to comment.