Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"recommendations": [
"recommendations": [
"ketho.wow-api",
"sumneko.lua",
"JohnnyMorganz.stylua"
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
27 changes: 19 additions & 8 deletions TeleportMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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)

Expand Down