Skip to content

Commit

Permalink
Fix inability to change current Edit Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Mctalian committed Aug 15, 2024
1 parent 8e703a7 commit 6ba12b8
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
1 change: 1 addition & 0 deletions .pkgmeta
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ externals:
Libs/AceConsole-3.0: https://repos.wowace.com/wow/ace3/trunk/AceConsole-3.0
Libs/AceGUI-3.0: https://repos.wowace.com/wow/ace3/trunk/AceGUI-3.0
Libs/AceConfig-3.0: https://repos.wowace.com/wow/ace3/trunk/AceConfig-3.0
Libs/AceTimer-3.0: https://repos.wowace.com/wow/ace3/trunk/AceTimer-3.0

ignore:
- README.md
29 changes: 26 additions & 3 deletions Core.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local addonName = "DeviceLayoutPreset"
DLP = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0")
DLP = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0")

local options = {
name = addonName,
Expand Down Expand Up @@ -52,13 +52,35 @@ function DLP:OnInitialize()
end
LibStub("AceConfig-3.0"):RegisterOptionsTable(addonName, options)
self.initialized = false
self:RegisterEvent("EDIT_MODE_LAYOUTS_UPDATED")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterChatCommand("dlp", "SlashCommand")
self:RegisterChatCommand("devicelayoutpreset", "SlashCommand")
self:RegisterChatCommand("deviceLayoutPreset", "SlashCommand")
end

function DLP:EDIT_MODE_LAYOUTS_UPDATED(eventName, layoutInfo, reconcileLayouts)
function DLP:PLAYER_ENTERING_WORLD(event, isLogin, isReload)
if not self.initialized then
self:CheckForEditMode()
end
end

local attempts = 0
function DLP:CheckForEditMode()
if EditModeManagerFrame and EditModeManagerFrame.GetLayouts then
self:PopulateOptions()
else
if attempts <= 30 then
attempts = attempts + 1
-- Keep checking until it's available
self:ScheduleTimer("CheckForEditMode", 1)
else
self:Print("EditModeManagerFrame:GetLayouts was unavailable for > 30 seconds, could not retrieve list of layours")
self:Print("Please report this issue @ github: McTalian/DeviceLayoutPreset")
end
end
end

function DLP:PopulateOptions()
layouts = EditModeManagerFrame:GetLayouts()
self:InitializeOptions()
if self.db.global.presetIndexOnLogin == 0 or self.db.global.presetIndexOnLogin > table.getn(layouts) then
Expand All @@ -70,6 +92,7 @@ function DLP:EDIT_MODE_LAYOUTS_UPDATED(eventName, layoutInfo, reconcileLayouts)
if self.db.global.presetIndexOnLogin > 0 then
EditModeManagerFrame:SelectLayout(self.db.global.presetIndexOnLogin)
end
self.initialized = true
end

function DLP:InitializeOptions()
Expand Down
1 change: 1 addition & 0 deletions embeds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<Include file="Libs\AceConsole-3.0\AceConsole-3.0.xml"/>
<Include file="Libs\AceGUI-3.0\AceGUI-3.0.xml"/>
<Include file="Libs\AceConfig-3.0\AceConfig-3.0.xml"/>
<Include file="Libs\AceTimer-3.0\AceTimer-3.0.xml"/>
</Ui>
28 changes: 28 additions & 0 deletions local_dev.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# (!) Must run in an elevated Powershell 7.1 (or newer) prompt from the Windows side

# Running this will allow your changes in WSL to be reflected and testable in the game
# without manually moving files around.
# You will still need to package up your changes into the .release directory
# (using .release/local.sh in this repo)
# NOTE: Any brand new files will need to be staged in git for .release/local.sh to see it.

# This script only needs to be run one time and any subsequent local builds will be visible in
# WoW after a /reload

# To undo this, simply delete this addon's link/folder in your WoW addons directory and
# redownload / manually copy the addon.

$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path

# Find the .toc file and extract the addon name
$addonName = Get-ChildItem -Path $scriptDirectory -Filter *.toc | Select-Object -First 1 | ForEach-Object { $_.BaseName }

$sourcePath = "$scriptDirectory\.release\$addonName"
$destPath = "C:\Program Files (x86)\World of Warcraft\_retail_\Interface\AddOns\$addonName"

if (Test-Path $destPath) {
Remove-Item $destPath -Recurse -Force
Write-Host "Directory deleted: $destPath"
}

New-Item -ItemType SymbolicLink -Target "$sourcePath" -Path "$destPath"

0 comments on commit 6ba12b8

Please sign in to comment.