From 7a12abeda32f3b6aa0bc61f9eda5e28b34355e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Jaro=C5=A1?= Date: Sat, 8 Mar 2025 21:39:43 +0100 Subject: [PATCH] Improve QuestFrame font handling --- Addon/Code/FontUtils.lua | 6 ++ Addon/Code/Options.lua | 4 ++ Addon/Code/Quest.lua | 19 ++++-- Addon/Code/QuestFrame.lua | 105 ++++++++++++++++++------------ Addon/Code/Speech.lua | 1 + Addon/Code/SpeechFrame.lua | 1 + release.sh | 129 ------------------------------------- sync.sh | 12 ++-- 8 files changed, 96 insertions(+), 181 deletions(-) delete mode 100755 release.sh diff --git a/Addon/Code/FontUtils.lua b/Addon/Code/FontUtils.lua index 023c69e..adc1b77 100644 --- a/Addon/Code/FontUtils.lua +++ b/Addon/Code/FontUtils.lua @@ -15,6 +15,12 @@ local function CreateCzechFont(frame, name, size, flags) end 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 container = Settings.CreateControlTextContainer() container:Add("morpheus_cz.ttf", "Morpheus (cz)") diff --git a/Addon/Code/Options.lua b/Addon/Code/Options.lua index 380e313..2319706 100644 --- a/Addon/Code/Options.lua +++ b/Addon/Code/Options.lua @@ -110,6 +110,10 @@ local function InitSpeeches() addon.SpeechFrame:UpdateSettings() end) + CreateButton('Zobrazit testovaci zpravu', "Zobrazit", function() + addon.API.AddSpeechMessage("Test", "Text message") + end) + end local function InitOthers() diff --git a/Addon/Code/Quest.lua b/Addon/Code/Quest.lua index 167b3f0..342df22 100644 --- a/Addon/Code/Quest.lua +++ b/Addon/Code/Quest.lua @@ -49,6 +49,9 @@ local function ShowQuestTranslation(event) if data then local title = GetQuestTitle(data.title, questId) local xOffset = hasModel and 210 or 10 + if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then + xOffset = -20 + end if event == "QUEST_PROGRESS" then frame:SetData(title, data.progress, "", "", QuestFrame, -20, xOffset) elseif event == "QUEST_COMPLETE" then @@ -109,13 +112,21 @@ local function InitQuests() if event == "PLAYER_LOGIN" then -- classic if QuestLogFrame then - QuestLogFrame:SetScript("OnEnter", function() ShowQuestTranslation() end) - QuestLogFrame:SetScript("OnLeave", function() frame:Hide() end) + QuestLogFrame:SetScript("OnEnter", function() + ShowQuestTranslation() + end) + QuestLogFrame:SetScript("OnLeave", function() + frame:Hide() + end) end -- retail if QuestMapDetailsScrollFrame then - QuestMapDetailsScrollFrame:SetScript("OnEnter", function() ShowQuestTranslation() end) - QuestMapDetailsScrollFrame:SetScript("OnLeave", function() frame:Hide() end) + QuestMapDetailsScrollFrame:SetScript("OnEnter", function() + ShowQuestTranslation() + end) + QuestMapDetailsScrollFrame:SetScript("OnLeave", function() + frame:Hide() + end) end frame:Init() diff --git a/Addon/Code/QuestFrame.lua b/Addon/Code/QuestFrame.lua index 114a86c..d020426 100755 --- a/Addon/Code/QuestFrame.lua +++ b/Addon/Code/QuestFrame.lua @@ -35,30 +35,43 @@ function QuestFrame:Init() self.Texture:SetAllPoints(true) self.Texture:SetHorizTile(true) - -- Load settings - self:UpdateSettings() -end - -function QuestFrame:UpdateSettings() + -- Create fonts self.Title = self:CreateHeader() self.Text1 = self:CreateText() self.Header = self:CreateHeader() 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 self.Texture:SetAlpha(CzechQuestsAddon_Store.config.QUEST_TEXTURE_ALPHA / 100) 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) self.Title:SetTextColor(r, g, b, a) self.Header:SetTextColor(r, g, b, a) @@ -69,56 +82,53 @@ end function QuestFrame:ApplyTheme() if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then 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 self:SetBackdropColor(0, 0, 0, 1) self.Texture:SetColorTexture(0, 0, 0, 1) self:SetTextColor(255, 255, 255, 1) + else + self.Texture:SetTexCoord(0, .58, 0.005, 0.66) + self:SetTextColor(0, 0, 0, 1) end else self.Texture:SetTexture("Interface/QUESTFRAME/QuestBackgroundParchment"); self.Texture:SetTexCoord(0, .01, 0, 0.4) self:SetTextColor(0, 0, 0, 1) local questTextContrast = C_CVar.GetCVar("questTextContrast") - if questTextContrast == "1" then -- Brown + if questTextContrast == "1" then + -- Brown 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) - elseif questTextContrast == "4" then -- Black + elseif questTextContrast == "4" then + -- Black self.Texture:SetColorTexture(0, 0, 0, 1) - self:SetTextColor(0, 0, 0, 1) + self:SetTextColor(255, 255, 255, 1) 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) +function QuestFrame:ResetFontText() + self.Title:SetText("") + self.Text1:SetText("") + self.Header:SetText("") + self.Text2:SetText("") end function QuestFrame:SetData(name, text1, header, text2, parentFrame, yOffset, xOffset) -- Reset previously values - self:ResetText() + self:ResetFontText() + self:ApplyTheme() -- Set parent self:SetParent(parentFrame) -- set text to labels - self.Title:SetText(name) - self.Text1:SetText(text1) - self.Header:SetText(header) - self.Text2:SetText(text2) + self.Title:SetText(name or "") + self.Text1:SetText(text1 or "") + self.Header:SetText(header or "") + self.Text2:SetText(text2 or "") -- apply text positions 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) -- apply frame position - if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then - self:SetPoint("TOPLEFT", parentFrame, "TOPRIGHT", xOffset, yOffset) - else - self:SetPoint("TOPLEFT", parentFrame, "TOPRIGHT", xOffset, yOffset) - end + self:SetPoint("TOPLEFT", parentFrame, "TOPRIGHT", xOffset, yOffset) self:Show() @@ -144,4 +150,19 @@ function QuestFrame:SetData(name, text1, header, text2, parentFrame, yOffset, xO else self:CalculateHeight() 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 \ No newline at end of file diff --git a/Addon/Code/Speech.lua b/Addon/Code/Speech.lua index befbaa6..dd432e0 100755 --- a/Addon/Code/Speech.lua +++ b/Addon/Code/Speech.lua @@ -73,6 +73,7 @@ local function AddMessage(sender, message) RemoveMessage(MessageFrame) end) end +addon.API.AddSpeechMessage = AddMessage local function ShowSpeechTranslation(sender, message) local text = CzechQuestsAddon:GetData("speech", message) diff --git a/Addon/Code/SpeechFrame.lua b/Addon/Code/SpeechFrame.lua index 432bcd0..7bd4888 100755 --- a/Addon/Code/SpeechFrame.lua +++ b/Addon/Code/SpeechFrame.lua @@ -28,6 +28,7 @@ function SpeechFrame:UpdateSettings() self:SetWidth(CzechQuestsAddon_Store.config.SPEECH_FRAME_WIDTH) -- Set position + self:ClearAllPoints() self:SetPoint( "BOTTOMLEFT", UIParent, "BOTTOMLEFT", CzechQuestsAddon_Store.config.SPEECH_FRAME_POSITION_X, diff --git a/release.sh b/release.sh deleted file mode 100755 index ca71e85..0000000 --- a/release.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/sync.sh b/sync.sh index 7387e2d..e592f04 100644 --- a/sync.sh +++ b/sync.sh @@ -1,20 +1,20 @@ #!/bin/bash -wow_source_folder="retail" -wow_destiny_folder="retail" +#wow_source_folder="retail" +#wow_destiny_folder="retail" #wow_destiny_folder="retail" #wow_destiny_folder="beta" -#wow_source_folder="classic_era" -#wow_destiny_folder="classic_era" +wow_source_folder="classic_era" +wow_destiny_folder="classic_era" src_folder="." dest_folder="/Applications/World of Warcraft/_${wow_destiny_folder}_/Interface/AddOns/CzechQuests" 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/" echo "Dest: $dest_folder" cp "$src_folder/Addon/Data/other.lua" "$dest_folder/Addon/Data/" -done \ No newline at end of file +done