diff --git a/.luarc.json b/.luarc.json index c0e7ca4..5c0c1ed 100644 --- a/.luarc.json +++ b/.luarc.json @@ -1,20 +1,29 @@ { - "diagnostics.globals": [ - "Settings", - "ScrollUtil", - "CreateScrollBoxListLinearView", - "MinimalSliderWithSteppersMixin", - "CreateDataProvider", - "SlashCmdList", - "STANDARD_TEXT_FONT", - "GameMenuFrame", - "DevTool", - "InterfaceOptionsFramePanelContainer", - "TeleportMeButtonsFrame", - "ToggleGameMenu" - ], - "workspace.library": [ - "~/Documents/GitHub/AddonDev/LuaLS/Libraries/vscode-wow-api/Annotations", - "~/Documents/GitHub/AddonDev/LuaLS/Libraries/wow-api-type-definitions" - ] + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "diagnostics.globals": [ + "Settings", + "ScrollUtil", + "CreateScrollBoxListLinearView", + "MinimalSliderWithSteppersMixin", + "CreateDataProvider", + "SlashCmdList", + "STANDARD_TEXT_FONT", + "GameMenuFrame", + "DevTool", + "InterfaceOptionsFramePanelContainer", + "TeleportMeButtonsFrame", + "ToggleGameMenu", + "LE_EXPANSION_WAR_WITHIN", + "MYTHIC_DUNGEON_SEASON" + ], + "workspace.library": [ + "~/Documents/GitHub/AddonDev/LuaLS/Libraries/vscode-wow-api/Annotations", + "~/Documents/GitHub/AddonDev/LuaLS/Libraries/wow-api-type-definitions", + "~\\.vscode\\extensions\\ketho.wow-api-0.18.2\\Annotations" + ], + "workspace.ignoreDir": [".vscode", "Libs"], + "diagnostics.enable": true, + "diagnostics.ignoredFiles": "Disable", + "diagnostics.libraryFiles": "Disable", + "runtime.version": "Lua 5.1" } diff --git a/.vscode/extensions.json b/.vscode/extensions.json index eb09762..26ced48 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,5 @@ { - "recommendations": [ + "recommendations": [ "ketho.wow-api", "sumneko.lua", "JohnnyMorganz.stylua" diff --git a/README.md b/README.md index 3517d51..06faef1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,32 @@ # Teleport Menu + Adds simple buttons to the game menu (esc key) to use your hearthstone(s) and teleports quick and easy. + +## Development Environment + +To ensure a consistent development environment, please use the following tools and configurations: + +### 1. Lua Language Server by Sumneko + +- We highly recommend using the Lua Language Server by Sumneko for code completion, error checking, and other language features. +- Install the Lua Language Server extension in your preferred code editor (e.g., VS Code). +- Configure the server to use the WoW API definitions (see below). + +### 2. Stylua + +- We use Stylua for code formatting to maintain a consistent code style. +- Install Stylua and configure your editor to use it for Lua files. +- Our project uses tab indentation with a tab size of 4. Ensure your Stylua configuration matches this. +- Example Stylua configuration in .editorconfig: + +``` +indent_style = tab +indent_size = 4 +quote_style = double +``` + +### 3. VSCode WoW API by Ketho + +- For VS Code users, we strongly recommend installing the VSCode WoW API extension by Ketho. +- This extension provides API definitions and code completion for the World of Warcraft Lua API, which is essential for addon development. + - This extension is vital for using the Sumneko Lua language server with the WoW API. diff --git a/TeleportMenu.lua b/TeleportMenu.lua index aa04619..583a901 100644 --- a/TeleportMenu.lua +++ b/TeleportMenu.lua @@ -291,6 +291,11 @@ local flyOutFramesPool = {} local secureButtons = {} local secureButtonsPool = {} +--- @class Cooldown +--- @field cooldownFrame Cooldown +--- @field CheckCooldown fun(self: Cooldown, id: ItemInfo, type: string): nil +--- @param frame Cooldown|Button +--- @return Cooldown local function createCooldownFrame(frame) if frame.cooldownFrame then return frame.cooldownFrame @@ -428,8 +433,8 @@ local function createFlyOutFrame() return flyOutFrame end ----@param id ItemInfo ----@return boolean +--- @param id ItemInfo +--- @return boolean local function IsItemEquipped(id) return C_Item.IsEquippableItem(id) and C_Item.IsEquippedItem(id) end @@ -447,13 +452,15 @@ local function ClearAllInvalidHighlights() end end ----@param frame Frame ----@param type string ----@param text string|nil ----@param id integer ----@param hearthstone? boolean ----@return Frame +--- @param frame Frame +--- @param type string +--- @param text string|nil +--- @param id integer +--- @param hearthstone? boolean +--- @return Frame local function CreateSecureButton(frame, type, text, id, hearthstone) + ---@class Button + ---@field cooldownFrame Cooldown local button if next(secureButtonsPool) then button = table.remove(secureButtonsPool) @@ -473,6 +480,9 @@ local function CreateSecureButton(frame, type, text, id, hearthstone) if type == "item" and not C_Item.IsEquippedItem(id) then self:ClearHighlightTexture() end + if self.cooldownFrame then + self.cooldownFrame:CheckCooldown(id, type) + end table.insert(secureButtonsPool, self) end @@ -511,6 +521,7 @@ local function CreateSecureButton(frame, type, text, id, hearthstone) end end) end + self.cooldownFrame:CheckCooldown(id, type) end) button.cooldownFrame:CheckCooldown(id, type)