From 8b53a5247c6b096c14ba6b2f776832c8b475df2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Jaro=C5=A1?= Date: Tue, 4 Mar 2025 07:49:19 +0100 Subject: [PATCH] Enhance speech frame behavior and settings --- Addon/Code/DataApi.lua | 1 + Addon/Code/QuestParser.lua | 2 +- Addon/Code/Speeches.lua | 33 +++++++++++++------- Addon/Data/retail/0.lua | 5 +-- Addon/Data/retail/1.lua | 12 ------- Addon/Frames/Settings/OptionsSpeechFrame.lua | 19 ++++++++--- Addon/Frames/TranslationSpeechFrame.lua | 9 ++++-- CzechQuests.lua | 3 ++ CzechQuests_Mainline.toc | 2 +- CzechQuests_Vanilla.toc | 2 +- release.sh | 11 +++++-- sync.sh | 9 +++--- 12 files changed, 65 insertions(+), 43 deletions(-) diff --git a/Addon/Code/DataApi.lua b/Addon/Code/DataApi.lua index ac16784..e355b7d 100755 --- a/Addon/Code/DataApi.lua +++ b/Addon/Code/DataApi.lua @@ -125,6 +125,7 @@ local function ApplySpeechPlaceholders(text) local formatted = text; formatted = string.gsub(formatted, '', playerName); formatted = string.gsub(formatted, 'Champions', playerName); + formatted = string.gsub(formatted, 'champions', playerName); return formatted end diff --git a/Addon/Code/QuestParser.lua b/Addon/Code/QuestParser.lua index 76b4470..6bfae69 100755 --- a/Addon/Code/QuestParser.lua +++ b/Addon/Code/QuestParser.lua @@ -8,7 +8,7 @@ end local function SplitSentences(paragraph) local sentences = {} - for sentence in string.gmatch(paragraph, "([^%.%?!]+[%.%?!]?)[%s]*") do + for sentence in string.gmatch(paragraph, "([^,%.%?!]+[,%.%?!]?)[%s]*") do local trimmed = sentence:gsub("^%s+", ""):gsub("%s+$", "") if #trimmed > 0 then table.insert(sentences, trimmed) diff --git a/Addon/Code/Speeches.lua b/Addon/Code/Speeches.lua index cdf8fd3..c369fc8 100755 --- a/Addon/Code/Speeches.lua +++ b/Addon/Code/Speeches.lua @@ -1,28 +1,35 @@ local messages = {} + local function ReflowMessages() local offsetY = 5 for i = #messages, 1, -1 do - local msg = messages[i] - msg:ClearAllPoints() - msg:SetPoint( + local fs = messages[i] + fs:ClearAllPoints() + fs:SetPoint( "BOTTOMLEFT", CzechQuestsAddon.translationSpeechFrame.content, "BOTTOMLEFT", - 10, + 5, offsetY ) - offsetY = offsetY + msg:GetHeight() + fs:Show() + offsetY = offsetY + fs:GetHeight() end if #messages == 0 then CzechQuestsAddon.translationSpeechFrame:Hide() end - CzechQuestsAddon.translationSpeechFrame.content:SetHeight(offsetY + 5) + offsetY = offsetY + 5 + if offsetY < 150 then + offsetY = 150 + end - CzechQuestsAddon.translationSpeechFrame:UpdateScrollChildRect() -- Ujistí se, že velikost obsahu je aktuální + CzechQuestsAddon.translationSpeechFrame.content:SetHeight(offsetY) + + CzechQuestsAddon.translationSpeechFrame:UpdateScrollChildRect() local maxScroll = CzechQuestsAddon.translationSpeechFrame:GetVerticalScrollRange() - CzechQuestsAddon.translationSpeechFrame:SetVerticalScroll(maxScroll) -- Nastaví rolování na dolní okraj + CzechQuestsAddon.translationSpeechFrame:SetVerticalScroll(maxScroll) end @@ -33,7 +40,7 @@ local function RemoveMessage(frame) local fadeOut = fadeAnimationGroup:CreateAnimation("Alpha") fadeOut:SetFromAlpha(1) fadeOut:SetToAlpha(0) - fadeOut:SetDuration(0.2) + fadeOut:SetDuration(1) fadeOut:SetStartDelay(0) fadeAnimationGroup:SetScript("OnFinished", function() @@ -42,7 +49,6 @@ local function RemoveMessage(frame) ReflowMessages() end) - fs:Show() fadeAnimationGroup:Play() break @@ -54,8 +60,6 @@ local function AddMessage(sender, message) local formattedText = string.format("|cffffd200%s|r\n%s", sender, message) local frame = CzechQuestsAddon:CreateTranslationSpeechFrameMessage(formattedText) - CzechQuestsAddon.translationSpeechFrame:Show() - table.insert(messages, frame) ReflowMessages() @@ -66,7 +70,12 @@ end function CzechQuestsAddon:ShowSpeechTranslation(sender, message) local text = CzechQuestsAddon:GetData("speech", message) + if text == nil and CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING then + text = message + end + if text ~= nil then + CzechQuestsAddon.translationSpeechFrame:Show() AddMessage(sender, text) end end \ No newline at end of file diff --git a/Addon/Data/retail/0.lua b/Addon/Data/retail/0.lua index 26a3628..bb895c5 100644 --- a/Addon/Data/retail/0.lua +++ b/Addon/Data/retail/0.lua @@ -22,8 +22,9 @@ CzechQuestsAddon.data.quest[78529] = { } CzechQuestsAddon.data.quest[81514] = { titleMale = "Bountiful Delves", - objectiveMale = "Dokonči venkovní události, světové úkoly nebo získej renown a získej obnovený klíč od truhly nebo úlomky klíče od truhly, které ti umožní odemknout truhlu v Bountiful Delve.", - descriptionMale = "K boji proti Xal'atathovi budeme potřebovat spoustu zdrojů. Naštěstí pro vás jsme objevili zdroj! Některá naleziště, která jsme našli, jsou 'štědrá' na to, že tam padouši hromadí další poklady. Tento poklad lze odemknout pouze pomocí speciálních klíčů, které najdete po celém Khaz Algaru. Klíče a fragmenty klíčů lze nalézt po celém světě. Ulovte je a ponořte se do štědrého hloubení!", + objectiveMale = "Dokonči venkovní události, světové úkoly nebo týdenní úkoly, abys získal Restored Coffer Key nebo Coffer Key Shards, které ti umožní odemknout truhlu v Bountiful Delve.", + objectiveFemale = "Dokonči venkovní události, světové úkoly nebo týdenní úkoly, abys získala Restored Coffer Key nebo Coffer Key Shards, které ti umožní odemknout truhlu v Bountiful Delve.", + descriptionMale = "K boji proti Xal'atath budeme potřebovat spoustu zdrojů. Naštěstí pro tebe jsme objevili zdroj! Některá naleziště, která jsme našli, jsou 'štědrá' v tom, že tam padouši hromadí další poklady. Tento poklad lze odemknout pouze pomocí speciálních klíčů, které najdeš po celém Khaz Algar. Klíče a fragmenty klíčů lze nalézt po celém světě. Ulov je a ponoř se do štědrého hloubení!", progressMale = "Už jsi našel klíč?", progressFemale = "Už jsi našla klíč?", completionMale = "To byl ale úlovek! Máš chuť na trochu víc zábavy?", diff --git a/Addon/Data/retail/1.lua b/Addon/Data/retail/1.lua index c20ff5f..b69ca0b 100644 --- a/Addon/Data/retail/1.lua +++ b/Addon/Data/retail/1.lua @@ -5489,24 +5489,12 @@ CzechQuestsAddon.data.quest[88878] = { CzechQuestsAddon.data.speech["It's just business pal."] = { text = "Je to jen obchod, kamaráde.", } -CzechQuestsAddon.data.speech["Where is Noggenfogger's Shipment? Don't you make me look bad in front of him."] = { - text = "Kde se nachází zásilka Noggenfogger? Nechtěj, abych před ním vypadal špatně.", -} CzechQuestsAddon.data.speech["I had to be a... big shot..."] = { text = "Musel jsem být... velký...", } -CzechQuestsAddon.data.speech["You get the delivery to the secret project site yesterday! And whatever's left goes to Venture for munition's testing."] = { - text = "Dodávku na tajné místo projektu jste obdrželi včera! A co zbylo, jde do Venture na testování munice.", -} CzechQuestsAddon.data.speech["This tollbooth has to be brand new."] = { text = "Tato mýtná budka musí být úplně nová.", } -CzechQuestsAddon.data.speech["Where is Noggenfogger's shipment? Don't you make me look bad in front of him."] = { - text = "Kde je zásilka Noggenfogger? Nechtěj, abych před ním vypadal špatně.", -} -CzechQuestsAddon.data.speech["You get the delivery to the secret project site yesterday! And whatever's left goes to Venture for munitions testing."] = { - text = "Dodávku na tajné místo projektu jste obdrželi včera! A co zbylo, jde do Venture na testování munice.", -} CzechQuestsAddon.data.speech["Yer back! What happened?"] = { text = "Jsi zpátky! Co se stalo?", } diff --git a/Addon/Frames/Settings/OptionsSpeechFrame.lua b/Addon/Frames/Settings/OptionsSpeechFrame.lua index 88cc162..9a79441 100755 --- a/Addon/Frames/Settings/OptionsSpeechFrame.lua +++ b/Addon/Frames/Settings/OptionsSpeechFrame.lua @@ -51,7 +51,7 @@ function CzechQuestsAddon:AddSpeechOptions(category, layout) category, "CzechQuestsAddon__TRANSLATION_SPEECH_FRAME_WIDTH", type(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH), - "Šírka zprávy", + "Šírka okna", CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH, function() return CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH @@ -66,18 +66,29 @@ function CzechQuestsAddon:AddSpeechOptions(category, layout) ) end ) - local windowWidthSizeSliderOption = Settings.CreateSliderOptions(200, 800, 10) + local windowWidthSizeSliderOption = Settings.CreateSliderOptions(200, 1000, 10) windowWidthSizeSliderOption:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right); Settings.CreateSlider(category, windowWidthSizeSlider, windowWidthSizeSliderOption) + -- Show original + local originalWhenMissingCheckbox = Settings.RegisterAddOnSetting( + category, + "CzechQuestsAddon__TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING", + "TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING", + CzechQuestsAddon_Store.config, + type(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING), + "Original pokud není preklad", + CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING + ) + Settings.CreateCheckbox(category, originalWhenMissingCheckbox) + local initializer= CreateSettingsButtonInitializer( 'Resetovat pozici okna', 'RESET', function() CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION = { x = 0, y = 0} - CzechQuestsAddon.translationSpeechFrame:ClearAllPoints() CzechQuestsAddon.translationSpeechFrame:SetPoint( - "CENTER", UIParent, "CENTER", + "TOPLEFT", UIParent, "TOPLEFT", CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.x, CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.y ) diff --git a/Addon/Frames/TranslationSpeechFrame.lua b/Addon/Frames/TranslationSpeechFrame.lua index 9a53d0b..33d00d8 100755 --- a/Addon/Frames/TranslationSpeechFrame.lua +++ b/Addon/Frames/TranslationSpeechFrame.lua @@ -2,8 +2,9 @@ function CzechQuestsAddon:CreateTranslationSpeechFrame() local scroll = {}; -- Speech Translation Frame - scroll = CreateFrame("ScrollFrame", "CzechQuestsTranslationSpeechFrame", UIParent, "MinimalScrollFrameTemplate") + scroll = CreateFrame("ScrollFrame", "CzechQuestsTranslationSpeechFrame", UIParent, "UIPanelScrollFrameTemplate") scroll:SetSize(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH, 150) + scroll:Hide() -- Make movable scroll:SetMovable(true) @@ -57,13 +58,12 @@ function CzechQuestsAddon:CreateTranslationSpeechFrame() CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.y ) - scroll:Hide() - scroll.content:SetPoint("BOTTOMLEFT", scroll, "BOTTOMLEFT", 0, 0) return scroll; end + function CzechQuestsAddon:CreateTranslationSpeechFrameMessage(message) local frame = {}; @@ -71,6 +71,9 @@ function CzechQuestsAddon:CreateTranslationSpeechFrameMessage(message) frame = CreateFrame("Frame", nil, CzechQuestsAddon.translationSpeechFrame.content) frame:SetSize(CzechQuestsAddon.translationSpeechFrame.content:GetWidth() - 20, 1) + -- Hide + frame:Hide() + -- Message frame.string = frame:CreateFontString(nil, "OVERLAY") frame.string:SetWidth(frame:GetWidth()) diff --git a/CzechQuests.lua b/CzechQuests.lua index e495a35..3981b58 100644 --- a/CzechQuests.lua +++ b/CzechQuests.lua @@ -67,6 +67,9 @@ local function OnEvent(self, event, addonName, ...) if not CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH then CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH = 320; end + if not CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING then + CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING = false; + end if not CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION then CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION = { x = 0, y = 0} end diff --git a/CzechQuests_Mainline.toc b/CzechQuests_Mainline.toc index 6ead8d2..913c5f1 100755 --- a/CzechQuests_Mainline.toc +++ b/CzechQuests_Mainline.toc @@ -2,7 +2,7 @@ ## Title: CzechQuests ## Notes: Addon displays texts of quests in Czech language as tooltip ## Author: Roman Jaroš -## Version: 0.2.11 +## Version: 0.2.12 ## SavedVariables: CzechQuestsAddon_Store ## Category: Quests ## IconTexture: Interface\AddOns\CzechQuests\Assets\Icons\Logo diff --git a/CzechQuests_Vanilla.toc b/CzechQuests_Vanilla.toc index 968e41b..865821d 100755 --- a/CzechQuests_Vanilla.toc +++ b/CzechQuests_Vanilla.toc @@ -2,7 +2,7 @@ ## Title: CzechQuests ## Notes: Addon displays texts of quests in Czech language as tooltip ## Author: Roman Jaroš -## Version: 0.1.10 +## Version: 0.1.11 ## SavedVariables: CzechQuestsAddon_Store CzechQuests.lua diff --git a/release.sh b/release.sh index d48cae3..ca71e85 100755 --- a/release.sh +++ b/release.sh @@ -62,13 +62,18 @@ make_zip() { files_to_zip+=("$line") done < <(find . -name "*.lua" -path "./Addon/Frames/*") - # includes frames + # includes code while IFS= read -r line; do files_to_zip+=("$line") - done < <(find . -name "*.ttf" -path "./Assets/*") + 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" "./Addon/Translation.lua" "./Addon/Utils.lua" "./CzechQuests.lua") + files_to_zip+=("./Addon/Data/other.lua" "./Addon/Addon.lua" "./CzechQuests.lua") # prepare output directory for file in "${files_to_zip[@]}"; do diff --git a/sync.sh b/sync.sh index 24b87c7..740bbfc 100644 --- a/sync.sh +++ b/sync.sh @@ -2,12 +2,12 @@ src_folder="." -wow_source_folder="retail" -wow_destiny_folder="retail" +#wow_source_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" # CLASSIC ERA dest_folder="/Applications/World of Warcraft/_${wow_destiny_folder}_/Interface/AddOns/CzechQuests" @@ -17,3 +17,4 @@ fswatch -o "$src_folder" | while read -r change; do rsync -au --delete "$src_folder/Addon/Data/$wow_source_folder/" "$dest_folder/Addon/Data/" cp "$src_folder/Addon/Data/other.lua" "$dest_folder/Addon/Data/" done +