Skip to content

Commit

Permalink
wip: round three
Browse files Browse the repository at this point in the history
  • Loading branch information
ffainy committed Jun 25, 2022
1 parent 1fdb836 commit a82503a
Show file tree
Hide file tree
Showing 17 changed files with 232 additions and 73 deletions.
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ root = true
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

Expand All @@ -12,6 +13,4 @@ indent_style = space
indent_size = 2

[*.md]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/__pycache__/
/.vscode/
/tools/
*.code-workspace
*.psd
*.exe

4 changes: 2 additions & 2 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
column_width = 120
column_width = 180
indent_type = "Spaces"
quote_style = "AutoPreferSingle"
line_endings = "Windows"
line_endings = "Unix"
Binary file added assets/textures/site/curse.blp
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file added assets/textures/site/qq.blp
Binary file not shown.
Binary file added assets/textures/site/wago.blp
Binary file not shown.
Binary file added assets/textures/site/wowi.blp
Binary file not shown.
17 changes: 16 additions & 1 deletion core/dev.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@ local F, C = unpack(select(2, ...))

C.DevsList = {
['Farfaraway-白银之手'] = true,
['貳拾年老術士-白银之手'] = true,
['Fionorolah-白银之手'] = true,
['Orchestra-白银之手'] = true,
['Rhonesaia-白银之手'] = true,
['歸雁入胡天-白银之手'] = true,
['單方只一味-白银之手'] = true,
['池魚故淵-白银之手'] = true,
['盡在不言中-白银之手'] = true,
['終是意難平-白银之手'] = true,
['神而明之-白银之手'] = true,
['雨色入青山-白银之手'] = true,
['Dontbeshy-死亡之翼'] = true,
['熒惑-死亡之翼'] = true,
['Kangrinboqe-霜之哀伤'] = true,
['哞夫人-霜之哀伤'] = true,
['烽火夜長歌-霜之哀伤'] = true,
['瑪格漢之光-霜之哀伤'] = true,
}

do
Expand Down
6 changes: 3 additions & 3 deletions core/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ do
end)
end

function F:RegisterSlash(...)
function F:RegisterSlashCommand(...)
local name = C.ADDON_TITLE .. 'Slash' .. math.random()

local numArgs = select('#', ...)
local callback = select(numArgs, ...)
if type(callback) ~= 'function' or numArgs < 2 then
error('Syntax: RegisterSlash("/slash1"[, "/slash2"], slashFunction)')
error('Syntax: RegisterSlashCommand("/slash1"[, "/slash2"], slashFunction)')
end

for index = 1, numArgs - 1 do
local str = select(index, ...)
if type(str) ~= 'string' then
error('Syntax: RegisterSlash("/slash1"[, "/slash2"], slashFunction)')
error('Syntax: RegisterSlashCommand("/slash1"[, "/slash2"], slashFunction)')
end

_G['SLASH_' .. name .. index] = str
Expand Down
50 changes: 25 additions & 25 deletions core/slash.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local F, C = unpack(select(2, ...))
local GUI = F:GetModule('GUI')

F:RegisterSlash('/free', function(msg)
F:RegisterSlashCommand('/free', function(msg)
local str, _ = string.split(' ', string.lower(msg), 2)
if string.match(str, 'reset') or string.match(str, 'init') then
StaticPopup_Show('ANDROMEDA_RESET_ALL')
Expand All @@ -24,17 +24,17 @@ F:RegisterSlash('/free', function(msg)
end)

-- Leave group
F:RegisterSlash('/lg', function()
F:RegisterSlashCommand('/lg', function()
C_PartyInfo.LeaveParty()
end)

-- Disband party or raid
F:RegisterSlash('/disband', function()
F:RegisterSlashCommand('/disband', function()
StaticPopup_Show('ANDROMEDA_DISBAND_GROUP')
end)

-- Convert party raid
F:RegisterSlash('/convert', function()
F:RegisterSlashCommand('/convert', function()
if GetNumGroupMembers() > 0 then
if UnitInRaid('player') and (UnitIsGroupLeader('player')) then
C_PartyInfo.ConvertToParty()
Expand All @@ -47,22 +47,22 @@ F:RegisterSlash('/convert', function()
end)

-- Ready check
F:RegisterSlash('/rdc', function()
F:RegisterSlashCommand('/rdc', function()
DoReadyCheck()
end)

-- Role poll
F:RegisterSlash('/role', function()
F:RegisterSlashCommand('/role', function()
InitiateRolePoll()
end)

-- Reset instance
F:RegisterSlash('/ri', function()
F:RegisterSlashCommand('/ri', function()
ResetInstances()
end)

-- Teleport LFG instance
F:RegisterSlash('/tp', function()
F:RegisterSlashCommand('/tp', function()
if IsInInstance() then
LFGTeleport(true)
else
Expand All @@ -71,12 +71,12 @@ F:RegisterSlash('/tp', function()
end)

-- Take screenshot
F:RegisterSlash('/ss', function()
F:RegisterSlashCommand('/ss', function()
Screenshot()
end)

-- Mount special pose
F:RegisterSlash('/ms', function()
F:RegisterSlashCommand('/ms', function()
if IsMounted() then
DoEmote('MOUNTSPECIAL')
else
Expand All @@ -85,12 +85,12 @@ F:RegisterSlash('/ms', function()
end)

-- Set BattleNet broadcast
F:RegisterSlash('/bb', function(msg)
F:RegisterSlashCommand('/bb', function(msg)
BNSetCustomMessage(msg)
end)

-- Switch specialization
F:RegisterSlash('/spec', function(msg)
F:RegisterSlashCommand('/spec', function(msg)
local specID = tonumber(msg)
if specID then
local canUse, failureReason = C_SpecializationInfo.CanPlayerUseTalentSpecUI()
Expand All @@ -117,7 +117,7 @@ hooksecurefunc('ChatEdit_OnSpacePressed', function(editBox)
end
end)

F:RegisterSlash('/tt', function(msg)
F:RegisterSlashCommand('/tt', function(msg)
if UnitCanCooperate('player', 'target') or UnitIsUnit('player', 'target') then
SendChatMessage(msg, 'WHISPER', nil, GetUnitName('target', true))
end
Expand All @@ -141,7 +141,7 @@ do
end
end

F:RegisterSlash('/way', function(msg)
F:RegisterSlashCommand('/way', function(msg)
if IsAddOnLoaded('TomTom') then
return
end
Expand All @@ -166,24 +166,24 @@ do
end

-- Clear chat
F:RegisterSlash('/clear', function()
F:RegisterSlashCommand('/clear', function()
for i = 1, _G.NUM_CHAT_WINDOWS do
_G[string.format('ChatFrame%d', i)]:Clear()
end
end)

-- Dev tool
F:RegisterSlash('/rl', function()
F:RegisterSlashCommand('/rl', function()
ReloadUI()
end)

F:RegisterSlash('/fs', function()
F:RegisterSlashCommand('/fs', function()
_G.UIParentLoadAddOn('Blizzard_DebugTools')
_G.FrameStackTooltip_Toggle(false, true, true)
end)

-- Disable all addons except andromeda and debug tool
F:RegisterSlash('/debugmode', function()
F:RegisterSlashCommand('/debugmode', function()
for i = 1, GetNumAddOns() do
local name = GetAddOnInfo(i)
if name ~= C.ADDON_NAME and name ~= '!BaudErrorFrame' and name ~= 'REHack' and GetAddOnEnableState(C.MY_NAME, name) == 2 then
Expand All @@ -202,7 +202,7 @@ local function GetNPCID(unit)
end
end

F:RegisterSlash('/npcid', function()
F:RegisterSlashCommand('/npcid', function()
local npcID = GetNPCID('target')
if npcID then
local str = 'NPC ID: ' .. npcID
Expand All @@ -211,7 +211,7 @@ F:RegisterSlash('/npcid', function()
end)

-- Print quest info
F:RegisterSlash('/questid', function(msg)
F:RegisterSlashCommand('/questid', function(msg)
local questID = tonumber(msg)
if questID then
local isCompleted = C_QuestLog.IsQuestFlaggedCompleted(questID)
Expand All @@ -223,7 +223,7 @@ F:RegisterSlash('/questid', function(msg)
end)

-- Print map info
F:RegisterSlash('/mapid', function()
F:RegisterSlashCommand('/mapid', function()
local mapID
if _G.WorldMapFrame:IsShown() then
mapID = _G.WorldMapFrame:GetMapID()
Expand All @@ -235,7 +235,7 @@ F:RegisterSlash('/mapid', function()
end)

-- Print instance info
F:RegisterSlash('/instinfo', function()
F:RegisterSlashCommand('/instinfo', function()
local name, instanceType, difficultyID, difficultyName, _, _, _, instanceMapID = GetInstanceInfo()
F:Print(C.LINE_STRING)
F:Print('Name ' .. C.INFO_COLOR .. name)
Expand All @@ -247,7 +247,7 @@ F:RegisterSlash('/instinfo', function()
end)

-- Print item info
F:RegisterSlash('/iteminfo', function(msg)
F:RegisterSlashCommand('/iteminfo', function(msg)
local itemID = tonumber(msg)
if itemID then
local name, link, rarity, level, minLevel, type, subType, _, _, _, _, classID, subClassID, bindType =
Expand All @@ -274,7 +274,7 @@ F:RegisterSlash('/iteminfo', function(msg)
end)

-- Print item info
F:RegisterSlash('/scaleinfo', function()
F:RegisterSlashCommand('/scaleinfo', function()
F:Print(C.LINE_STRING)
F:Print('C.SCREEN_WIDTH ' .. C.SCREEN_WIDTH)
F:Print('C.SCREEN_HEIGHT ' .. C.SCREEN_HEIGHT)
Expand All @@ -285,7 +285,7 @@ F:RegisterSlash('/scaleinfo', function()
end)

-- DBM test
F:RegisterSlash('/dbmtest', function()
F:RegisterSlashCommand('/dbmtest', function()
if IsAddOnLoaded('DBM-Core') then
_G.DBM:DemoMode()
else
Expand Down
76 changes: 76 additions & 0 deletions generate_changelog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import os
import re
from slpp import slpp as lua

# 找到最新的更新文档
latest_version = 0
for _, _, files in os.walk("core/changelog", topdown=False):
for file in files:
version = re.sub(r"(\.lua)|(^.*\.xml)", "", file)
if version and not version == "_template":
version = float(version)
if version > latest_version:
latest_version = version

# 提取更新记录的 lua 字符串
changelog_path = "core/changelog/{:.2f}.lua".format(latest_version)
with open(changelog_path, "r", encoding="utf8") as f:
changelog_lua_string = f.read().replace("\n", "")

start_index = changelog_lua_string.find("{")
changelog_lua_string = changelog_lua_string[start_index:]

# 解析 lua table 到 Python dict
changelog = lua.decode(changelog_lua_string)

locales = [
{
"language": "enUS",
"VERSION": "Version",
"IMPORTANT": "Important",
"NEW": "New",
"IMPROVEMENT": "Improvement",
"RELEASED_STRING": "{} Released"
},
{
"language": "zhCN",
"VERSION": "版本",
"IMPORTANT": "重要",
"NEW": "新增",
"IMPROVEMENT": "改善",
"RELEASED_STRING": "{} 发布"
}
]

parts = [
{
"emoji": "🌟",
"name": "IMPORTANT",
},
{
"emoji": "🔆",
"name": "NEW",
},
{
"emoji": "⚡",
"name": "IMPROVEMENT",
}
]

with open("CHANGELOG.md", "w", encoding="utf8") as f:
for locale in locales:
f.write("# {}: {:.2f}\n".format(locale["VERSION"], latest_version))
f.write(locale["RELEASED_STRING"].format(
changelog["RELEASE_DATE"])+"\n")

for part in parts:
try:
if len(changelog[part["name"]]["zhTW"]) > 0:
f.write("## {} {}\n".format(
part["emoji"], locale[part["name"]]))
for line in changelog[part["name"]][locale["language"]]:
f.write("- {}\n".format(line))
except:
pass

f.write("\n------\n")
Loading

0 comments on commit a82503a

Please sign in to comment.