Skip to content

Commit

Permalink
Create the atlas files from wago.tools automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
InfusOnWoW committed Jan 23, 2024
1 parent 21eb8eb commit c18f3a7
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 22 deletions.
1 change: 0 additions & 1 deletion .github/scripts/atlas.lua

This file was deleted.

63 changes: 63 additions & 0 deletions .github/scripts/atlas_update.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
local version = ...

print("Creating atlas file for", version)

local versionMap = {
wow = "_Retail",
wow_classic = "_Wrath",
wow_classic_era = "_Vanilla"
}

if not versionMap[version] then
print("Unknown version", version)
return -1
end

local outputFileName = "Atlas" .. versionMap[version] .. ".lua"

local ftcsv = require('ftcsv')

local validAtlasIds = {}
local validAtlasElementIds = {}
local validNames = {}

for lineNr, atlas in ftcsv.parseLine("UiTextureAtlas.csv", ",") do
validAtlasIds[atlas.ID] = true
end

for lineNr, member in ftcsv.parseLine("UiTextureAtlasMember.csv", ",") do
local uiTextureAtlasID = member.UiTextureAtlasID
local uiTextureAtlasElementId = member.UiTextureAtlasElementID

if validAtlasIds[uiTextureAtlasID] and not validAtlasElementIds[uiTextureAtlasElementId] then
validAtlasElementIds[uiTextureAtlasElementId] = true
end
end

for lineNr, element in ftcsv.parseLine("UiTextureAtlasElement.csv", ",") do
local name = element.Name
local id = element.ID
if validAtlasElementIds[id] and name:lower():sub(1, 5) ~= "cguy_" then
validNames[name] = true
end
end

--for name in pairs(validNames) do
-- print("Found +", name)
--end

local output = io.open(outputFileName, "w+")
output:write("if not WeakAuras.IsLibsOK() then return end\n")
output:write("--- @type string, Private\n")
output:write("local AddonName, Private = ...\n")
output:write("Private.AtlasList = {")
for name in pairs(validNames) do
output:write('"')
output:write(name)
output:write('",')
end
output:write("}\n")
io.close(output)

print("Created output file", outputFileName)
return 0
16 changes: 0 additions & 16 deletions .github/scripts/atlascsv2lua.lua

This file was deleted.

15 changes: 15 additions & 0 deletions .github/scripts/wagotools-atlas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

for version in wow wow_classic wow_classic_era
do
wget -O "UiTextureAtlas.csv" "https://wago.tools/db2/UiTextureAtlas/csv?branch=${version}"
wget -O "UiTextureAtlasMember.csv" "https://wago.tools/db2/UiTextureAtlasMember/csv?branch=${version}"
wget -O "UiTextureAtlasElement.csv" "https://wago.tools/db2/UiTextureAtlasElement/csv?branch=${version}"

lua ./atlas_update.lua ${version}
done

mv Atlas_Retail.lua ../../WeakAuras/
mv Atlas_Wrath.lua ../../WeakAuras/
mv Atlas_Vanilla.lua ../../WeakAuras/

39 changes: 39 additions & 0 deletions .github/workflows/atlas-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Create Atlas file list update pull request

on:
schedule:
- cron: '0 10 * * 1'

workflow_dispatch:

jobs:
atlasUpdate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: leafo/gh-actions-lua@v10
- uses: leafo/gh-actions-luarocks@v4

- name: Lua rocks
run: |
luarocks install --server=https://luarocks.org/manifests/fouriertransformer ftcsv
shell: bash

- name: Update Atlas files from wago.tools
run: |
cd .github/scripts/
./wagotools-atlas.sh
shell: bash

- name: Cleanup luarocks
run: |
rm -rf .luarocks
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
branch: update-atlasfiles
commit-message: Update atlas file list from wago.tools
title: Update atlas file list from wago.tools
delete-branch: true
1 change: 0 additions & 1 deletion WeakAuras/Types_Retail.lua

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions WeakAuras/Types_Vanilla.lua

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions WeakAuras/Types_Wrath.lua

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions WeakAuras/WeakAuras.toc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ArchiveTypes\Repository.lua
DefaultOptions.lua

# Core files
Atlas_Retail.lua
Types_Retail.lua
Types.lua
Prototypes.lua
Expand Down
1 change: 1 addition & 0 deletions WeakAuras/WeakAuras_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ArchiveTypes\Repository.lua
DefaultOptions.lua

# Core files
Atlas_Vanilla.lua
Types_Vanilla.lua
Types.lua
Prototypes.lua
Expand Down
1 change: 1 addition & 0 deletions WeakAuras/WeakAuras_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ArchiveTypes\Repository.lua
DefaultOptions.lua

# Core files
Atlas_Wrath.lua
Types_Wrath.lua
Types.lua
Prototypes.lua
Expand Down

0 comments on commit c18f3a7

Please sign in to comment.