Improve QuestFrame font handling
All checks were successful
forgejo/Czech Quests/addon/pipeline/head This commit looks good

This commit is contained in:
Roman Jaroš 2025-03-08 21:39:43 +01:00
parent d90715c2cc
commit 7a12abeda3
8 changed files with 96 additions and 181 deletions

View file

@ -15,6 +15,12 @@ local function CreateCzechFont(frame, name, size, flags)
end end
addon.API.CreateCzechFont = CreateCzechFont addon.API.CreateCzechFont = CreateCzechFont
local function UpdateCzechFont(FontString, name, size)
local _, _, flags = FontString:GetFont()
FontString:SetFont(FontPath .. name, size, flags)
end
addon.API.UpdateCzechFont = UpdateCzechFont
local function GetFontContainer() local function GetFontContainer()
local container = Settings.CreateControlTextContainer() local container = Settings.CreateControlTextContainer()
container:Add("morpheus_cz.ttf", "Morpheus (cz)") container:Add("morpheus_cz.ttf", "Morpheus (cz)")

View file

@ -110,6 +110,10 @@ local function InitSpeeches()
addon.SpeechFrame:UpdateSettings() addon.SpeechFrame:UpdateSettings()
end) end)
CreateButton('Zobrazit testovaci zpravu', "Zobrazit", function()
addon.API.AddSpeechMessage("Test", "Text message")
end)
end end
local function InitOthers() local function InitOthers()

View file

@ -49,6 +49,9 @@ local function ShowQuestTranslation(event)
if data then if data then
local title = GetQuestTitle(data.title, questId) local title = GetQuestTitle(data.title, questId)
local xOffset = hasModel and 210 or 10 local xOffset = hasModel and 210 or 10
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
xOffset = -20
end
if event == "QUEST_PROGRESS" then if event == "QUEST_PROGRESS" then
frame:SetData(title, data.progress, "", "", QuestFrame, -20, xOffset) frame:SetData(title, data.progress, "", "", QuestFrame, -20, xOffset)
elseif event == "QUEST_COMPLETE" then elseif event == "QUEST_COMPLETE" then
@ -109,13 +112,21 @@ local function InitQuests()
if event == "PLAYER_LOGIN" then if event == "PLAYER_LOGIN" then
-- classic -- classic
if QuestLogFrame then if QuestLogFrame then
QuestLogFrame:SetScript("OnEnter", function() ShowQuestTranslation() end) QuestLogFrame:SetScript("OnEnter", function()
QuestLogFrame:SetScript("OnLeave", function() frame:Hide() end) ShowQuestTranslation()
end)
QuestLogFrame:SetScript("OnLeave", function()
frame:Hide()
end)
end end
-- retail -- retail
if QuestMapDetailsScrollFrame then if QuestMapDetailsScrollFrame then
QuestMapDetailsScrollFrame:SetScript("OnEnter", function() ShowQuestTranslation() end) QuestMapDetailsScrollFrame:SetScript("OnEnter", function()
QuestMapDetailsScrollFrame:SetScript("OnLeave", function() frame:Hide() end) ShowQuestTranslation()
end)
QuestMapDetailsScrollFrame:SetScript("OnLeave", function()
frame:Hide()
end)
end end
frame:Init() frame:Init()

View file

@ -35,30 +35,43 @@ function QuestFrame:Init()
self.Texture:SetAllPoints(true) self.Texture:SetAllPoints(true)
self.Texture:SetHorizTile(true) self.Texture:SetHorizTile(true)
-- Load settings -- Create fonts
self:UpdateSettings()
end
function QuestFrame:UpdateSettings()
self.Title = self:CreateHeader() self.Title = self:CreateHeader()
self.Text1 = self:CreateText() self.Text1 = self:CreateText()
self.Header = self:CreateHeader() self.Header = self:CreateHeader()
self.Text2 = self:CreateText() self.Text2 = self:CreateText()
self:ApplyTheme() -- Load settings
self:UpdateSettings()
end
function QuestFrame:UpdateSettings()
addon.API.UpdateCzechFont(
self.Title,
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_NAME,
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_SIZE
)
addon.API.UpdateCzechFont(
self.Text1,
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_NAME,
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_SIZE
)
addon.API.UpdateCzechFont(
self.Header,
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_NAME,
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_SIZE
)
addon.API.UpdateCzechFont(
self.Text2,
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_NAME,
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_SIZE
)
if not CzechQuestsAddon_Store.config.QUEST_TEXTURE_ALPHA_ONLY_MOVING then if not CzechQuestsAddon_Store.config.QUEST_TEXTURE_ALPHA_ONLY_MOVING then
self.Texture:SetAlpha(CzechQuestsAddon_Store.config.QUEST_TEXTURE_ALPHA / 100) self.Texture:SetAlpha(CzechQuestsAddon_Store.config.QUEST_TEXTURE_ALPHA / 100)
end end
end end
function QuestFrame:ResetText()
self.Title:SetText("")
self.Header:SetText("")
self.Text1:SetText("")
self.Text2:SetText("")
end
function QuestFrame:SetTextColor(r, g, b, a) function QuestFrame:SetTextColor(r, g, b, a)
self.Title:SetTextColor(r, g, b, a) self.Title:SetTextColor(r, g, b, a)
self.Header:SetTextColor(r, g, b, a) self.Header:SetTextColor(r, g, b, a)
@ -69,56 +82,53 @@ end
function QuestFrame:ApplyTheme() function QuestFrame:ApplyTheme()
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
self.Texture:SetTexture("Interface/QUESTFRAME/QuestBG"); self.Texture:SetTexture("Interface/QUESTFRAME/QuestBG");
self.Texture:SetTexCoord(0, .58, 0.005, 0.66)
self:SetTextColor(0, 0, 0, 1)
if CzechQuestsAddon_Store.config.QUEST_DARK_MODE then if CzechQuestsAddon_Store.config.QUEST_DARK_MODE then
self:SetBackdropColor(0, 0, 0, 1) self:SetBackdropColor(0, 0, 0, 1)
self.Texture:SetColorTexture(0, 0, 0, 1) self.Texture:SetColorTexture(0, 0, 0, 1)
self:SetTextColor(255, 255, 255, 1) self:SetTextColor(255, 255, 255, 1)
else
self.Texture:SetTexCoord(0, .58, 0.005, 0.66)
self:SetTextColor(0, 0, 0, 1)
end end
else else
self.Texture:SetTexture("Interface/QUESTFRAME/QuestBackgroundParchment"); self.Texture:SetTexture("Interface/QUESTFRAME/QuestBackgroundParchment");
self.Texture:SetTexCoord(0, .01, 0, 0.4) self.Texture:SetTexCoord(0, .01, 0, 0.4)
self:SetTextColor(0, 0, 0, 1) self:SetTextColor(0, 0, 0, 1)
local questTextContrast = C_CVar.GetCVar("questTextContrast") local questTextContrast = C_CVar.GetCVar("questTextContrast")
if questTextContrast == "1" then -- Brown if questTextContrast == "1" then
-- Brown
self.Texture:SetTexCoord(0, .01, .4, .8) self.Texture:SetTexCoord(0, .01, .4, .8)
elseif questTextContrast == "2" or questTextContrast == "3" then -- Gray elseif questTextContrast == "2" or questTextContrast == "3" then
-- Gray
self.Texture:SetColorTexture(255, 255, 255, 1) self.Texture:SetColorTexture(255, 255, 255, 1)
elseif questTextContrast == "4" then -- Black elseif questTextContrast == "4" then
-- Black
self.Texture:SetColorTexture(0, 0, 0, 1) self.Texture:SetColorTexture(0, 0, 0, 1)
self:SetTextColor(0, 0, 0, 1) self:SetTextColor(255, 255, 255, 1)
end end
end end
end end
function QuestFrame:CalculateHeight() function QuestFrame:ResetFontText()
local height = 0; self.Title:SetText("")
local heights = { self.Text1:SetText("")
self.Title:GetHeight() , self.Header:SetText("")
self.Text1:GetHeight(), self.Text2:SetText("")
self.Header:GetHeight(),
self.Text2:GetHeight(),
10
}
for _, value in ipairs(heights) do
height = height + value + 10
end
self:SetHeight(height)
end end
function QuestFrame:SetData(name, text1, header, text2, parentFrame, yOffset, xOffset) function QuestFrame:SetData(name, text1, header, text2, parentFrame, yOffset, xOffset)
-- Reset previously values -- Reset previously values
self:ResetText() self:ResetFontText()
self:ApplyTheme()
-- Set parent -- Set parent
self:SetParent(parentFrame) self:SetParent(parentFrame)
-- set text to labels -- set text to labels
self.Title:SetText(name) self.Title:SetText(name or "")
self.Text1:SetText(text1) self.Text1:SetText(text1 or "")
self.Header:SetText(header) self.Header:SetText(header or "")
self.Text2:SetText(text2) self.Text2:SetText(text2 or "")
-- apply text positions -- apply text positions
self.Title:SetPoint("TOPLEFT", self, "TOPLEFT", 10, -10) self.Title:SetPoint("TOPLEFT", self, "TOPLEFT", 10, -10)
@ -127,11 +137,7 @@ function QuestFrame:SetData(name, text1, header, text2, parentFrame, yOffset, xO
self.Text2:SetPoint("TOPLEFT", self.Header, "BOTTOMLEFT", 0, -5) self.Text2:SetPoint("TOPLEFT", self.Header, "BOTTOMLEFT", 0, -5)
-- apply frame position -- apply frame position
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then self:SetPoint("TOPLEFT", parentFrame, "TOPRIGHT", xOffset, yOffset)
self:SetPoint("TOPLEFT", parentFrame, "TOPRIGHT", xOffset, yOffset)
else
self:SetPoint("TOPLEFT", parentFrame, "TOPRIGHT", xOffset, yOffset)
end
self:Show() self:Show()
@ -145,3 +151,18 @@ function QuestFrame:SetData(name, text1, header, text2, parentFrame, yOffset, xO
self:CalculateHeight() self:CalculateHeight()
end end
end end
function QuestFrame:CalculateHeight()
local height = 0;
local heights = {
self.Title:GetHeight(),
self.Text1:GetHeight(),
self.Header:GetHeight(),
self.Text2:GetHeight(),
10
}
for _, value in ipairs(heights) do
height = height + value + 10
end
self:SetHeight(height)
end

View file

@ -73,6 +73,7 @@ local function AddMessage(sender, message)
RemoveMessage(MessageFrame) RemoveMessage(MessageFrame)
end) end)
end end
addon.API.AddSpeechMessage = AddMessage
local function ShowSpeechTranslation(sender, message) local function ShowSpeechTranslation(sender, message)
local text = CzechQuestsAddon:GetData("speech", message) local text = CzechQuestsAddon:GetData("speech", message)

View file

@ -28,6 +28,7 @@ function SpeechFrame:UpdateSettings()
self:SetWidth(CzechQuestsAddon_Store.config.SPEECH_FRAME_WIDTH) self:SetWidth(CzechQuestsAddon_Store.config.SPEECH_FRAME_WIDTH)
-- Set position -- Set position
self:ClearAllPoints()
self:SetPoint( self:SetPoint(
"BOTTOMLEFT", UIParent, "BOTTOMLEFT", "BOTTOMLEFT", UIParent, "BOTTOMLEFT",
CzechQuestsAddon_Store.config.SPEECH_FRAME_POSITION_X, CzechQuestsAddon_Store.config.SPEECH_FRAME_POSITION_X,

View file

@ -1,129 +0,0 @@
#!/usr/bin/env zsh
output_directory="CzechQuests"
wow_versions=(
"Classic ERA" # 1 - classic_era
"Retail" # 2 - retail
)
toc_files=(
"CzechQuests_Vanilla.toc"
"CzechQuests_Mainline.toc"
)
read_toc_version() {
local wow_version=$1
local toc_file=${toc_files[$wow_version]}
local current_version=0
if [[ -f "$toc_file" ]]; then
current_version=$(grep "## Version:" "$toc_file" | cut -d ' ' -f 3)
fi
echo "$current_version"
}
write_toc_version() {
local wow_version=$1
local next_version=$2
local toc_file=${toc_files[$wow_version]}
if [[ -f "$toc_file" ]]; then
sed -i '' "s/## Version: $current_version/## Version: $next_version/" "$toc_file"
fi
}
make_zip() {
local wow_version=$1
local current_version=$2
local zip_filename=""
local files_to_zip=()
# prepare output directory
mkdir -p $output_directory
mkdir -p "${output_directory}/Addon/Data/"
# Includes classic era continents
if [ "$wow_version" = "1" ]; then
cp -r "./Addon/Data/classic_era/" "${output_directory}/Addon/Data/"
cp "./CzechQuests_Vanilla.toc" "${output_directory}"
zip_filename="czech-quests-classic_era-v$current_version.zip"
fi
# Includes retail continents
if [ "$wow_version" = "2" ]; then
cp -r "./Addon/Data/retail/" "${output_directory}/Addon/Data/"
cp "./CzechQuests_Mainline.toc" "${output_directory}"
zip_filename="czech-quests-retail-v$current_version.zip"
fi
# includes frames
while IFS= read -r line; do
files_to_zip+=("$line")
done < <(find . -name "*.lua" -path "./Addon/Frames/*")
# includes code
while IFS= read -r line; do
files_to_zip+=("$line")
done < <(find . -name "*.lua" -path "./Addon/Code/*")
# includes assets
while IFS= read -r line; do
files_to_zip+=("$line")
done < <(find . -name "*" -path "./Assets/*")
# includes other files
files_to_zip+=("./Addon/Data/other.lua" "./Addon/Addon.lua" "./CzechQuests.lua")
# prepare output directory
for file in "${files_to_zip[@]}"; do
rsync -R "$file" "$output_directory"
done
# Remove invalid files
find "$output_directory" -name ".DS_Store" -type f -delete
# create zip file
zip -r "$zip_filename" $output_directory
# remove output directory
rm -r $output_directory
}
release_wow() {
local wow_version=$1
# Read current version from file for wow version
current_version=$(read_toc_version "$wow_version")
# Increase version
new_version="$current_version"
vared -p "Choose version: " new_version
# Write to file
write_toc_version "$wow_version" "$new_version"
# Generate zip
make_zip $wow_version $new_version
}
init() {
echo "Choose Wow:"
select opt in "${wow_versions[@]}"
do
case $opt in
"Classic ERA")
echo "You chose Classic ERA"
release_wow 1
return 0
;;
"Retail")
echo "You chose Retail"
release_wow 2
return 0
;;
esac
done
}
init

10
sync.sh
View file

@ -1,19 +1,19 @@
#!/bin/bash #!/bin/bash
wow_source_folder="retail" #wow_source_folder="retail"
wow_destiny_folder="retail" #wow_destiny_folder="retail"
#wow_destiny_folder="retail" #wow_destiny_folder="retail"
#wow_destiny_folder="beta" #wow_destiny_folder="beta"
#wow_source_folder="classic_era" wow_source_folder="classic_era"
#wow_destiny_folder="classic_era" wow_destiny_folder="classic_era"
src_folder="." src_folder="."
dest_folder="/Applications/World of Warcraft/_${wow_destiny_folder}_/Interface/AddOns/CzechQuests" dest_folder="/Applications/World of Warcraft/_${wow_destiny_folder}_/Interface/AddOns/CzechQuests"
fswatch -o "$src_folder" | while read -r change; do fswatch -o "$src_folder" | while read -r change; do
rsync -avu --delete "$src_folder" "$dest_folder" --exclude={'.*','*.png','*.sh','*.md','Addon/Data/**','downloader/**'} rsync -avu --delete "$src_folder" "$dest_folder" --exclude={'.*','*.png','*.sh','*.md','Addon/Data/**','downloader/**',"lib/**","Jenkinsfile"}
rsync -au --delete "$src_folder/Addon/Data/$wow_source_folder/" "$dest_folder/Addon/Data/" rsync -au --delete "$src_folder/Addon/Data/$wow_source_folder/" "$dest_folder/Addon/Data/"
echo "Dest: $dest_folder" echo "Dest: $dest_folder"
cp "$src_folder/Addon/Data/other.lua" "$dest_folder/Addon/Data/" cp "$src_folder/Addon/Data/other.lua" "$dest_folder/Addon/Data/"