Rework options and hover + fix quests for teldrassil zone

This commit is contained in:
Roman Jaroš 2024-07-08 01:16:53 +02:00
parent f2641af379
commit 05eb54cbbb
15 changed files with 681 additions and 295 deletions

98
Frames/OptionsFrame.lua Normal file → Executable file
View file

@ -11,7 +11,6 @@ local function CreateCheckBox(parent, optionsPanel, text, onClick)
local checkbox = CreateFrame("CheckButton", nil, optionsPanel, "InterfaceOptionsCheckButtonTemplate")
checkbox.Text:SetText(text)
checkbox:SetScript("OnClick", onClick)
return checkbox
end
@ -20,7 +19,6 @@ local function createOptionCheckbox(parent, optionsPanel, text, optionKey)
local checked = self:GetChecked()
CzechQuestsOptions[optionKey] = checked
end)
checkbox:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", 0, -8)
checkbox:SetChecked(CzechQuestsOptions[optionKey])
return checkbox
@ -37,114 +35,20 @@ local function InitializeOptions()
local enableDebugModeCheckbox = createOptionCheckbox(title, optionsPanel,"Enable DEBUG mode", "DEBUG_MODE")
enableDebugModeCheckbox:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 16, -8)
local interactionDropdownDescription = optionsPanel:CreateFontString(nil, "ARTWORK", "GameFontnormalSmall")
interactionDropdownDescription:SetPoint("TOPLEFT", enableDebugModeCheckbox, "BOTTOMLEFT", 0, -8)
interactionDropdownDescription:SetText("Select interaction:")
local interactionDropdown = CreateFrame("Frame", "CzechQuestsInteractionDropdown", optionsPanel, "UIDropDownMenuTemplate")
interactionDropdown:SetPoint("TOPLEFT", interactionDropdownDescription, "BOTTOMLEFT", -16, -4)
local function SetSelectedInteractionText(interactionText, selectedInteractionText, checked)
if checked then
return selectedInteractionText
end
return interactionText
end
local function OnInteractionDropdownValueChanged(self, arg1, arg2, checked)
CzechQuestsOptions.SELECTED_INTERACTION = arg1
UIDropDownMenu_SetText(interactionDropdown, arg2)
end
local function InitializeInteractionDropdown()
local info = UIDropDownMenu_CreateInfo()
local interactionText = "Hover"
info.text = "Hover"
info.value = "hover"
info.arg1 = info.value
info.arg2 = info.text
info.checked = CzechQuestsOptions.SELECTED_INTERACTION == "hover"
info.func = OnInteractionDropdownValueChanged
info.minWidth = 145
interactionText = SetSelectedInteractionText(interactionText, info.text, info.checked)
UIDropDownMenu_AddButton(info)
info.text = "Hover + hotkey"
info.value = "hover-hotkey"
info.arg1 = info.value
info.arg2 = info.text
info.checked = CzechQuestsOptions.SELECTED_INTERACTION == "hover-hotkey"
info.func = OnInteractionDropdownValueChanged
info.minWidth = 145
interactionText = SetSelectedInteractionText(interactionText, info.text, info.checked)
UIDropDownMenu_AddButton(info)
UIDropDownMenu_SetText(interactionDropdown, interactionText)
UIDropDownMenu_SetAnchor(interactionDropdown, 16, 4, "TOPLEFT", interactionDropdown, "BOTTOMLEFT")
end
UIDropDownMenu_SetWidth(interactionDropdown, 150)
UIDropDownMenu_Initialize(interactionDropdown, InitializeInteractionDropdown)
local hotkeyDescription = optionsPanel:CreateFontString(nil, "ARTWORK", "GameFontnormalSmall")
hotkeyDescription:SetPoint("TOPLEFT", interactionDropdown, "BOTTOMLEFT", 16, -8)
hotkeyDescription:SetText("Register Hotkey (right-click to unbind):")
local registerHotkeyButton = CreateFrame("Button", "CzechQuestsRegisterHotkeyButton", optionsPanel, "UIPanelButtonTemplate")
registerHotkeyButton:SetWidth(120)
registerHotkeyButton:SetHeight(25)
registerHotkeyButton:SetPoint("TOPLEFT", hotkeyDescription, "TOPLEFT", 0, -12)
if CzechQuestsOptions.SELECTED_HOTKEY then
registerHotkeyButton:SetText(CzechQuestsOptions.SELECTED_HOTKEY)
else
registerHotkeyButton:SetText("Not Bound")
end
local waitingForKey = false
registerHotkeyButton:SetScript("OnMouseDown", function(self, button)
if button == "LeftButton" then
if not waitingForKey then
waitingForKey = true
registerHotkeyButton:SetText("Press button..")
end
elseif button == "RightButton" then
waitingForKey = false
registerHotkeyButton:SetText("Not Bound")
CzechQuestsOptions.SELECTED_HOTKEY = nil
end
end)
local function SetHotkeyButton(self, key)
if waitingForKey then
CzechQuestsOptions.SELECTED_HOTKEY = key
registerHotkeyButton:SetText(CzechQuestsOptions.SELECTED_HOTKEY)
waitingForKey = false
end
end
registerHotkeyButton:SetScript("OnKeyDown", SetHotkeyButton)
registerHotkeyButton:SetPropagateKeyboardInput(true)
InterfaceOptions_AddCategory(optionsPanel)
end
local function addonLoaded(self, event, addonLoadedName)
if addonLoadedName == addonName then
CzechQuestsOptions = CzechQuestsOptions or defaultOptions
for key, value in pairs(defaultOptions) do
if CzechQuestsOptions[key] == nil then
CzechQuestsOptions[key] = value
end
end
InitializeOptions()
end
end
optionsFrame:RegisterEvent("ADDON_LOADED")
optionsFrame:SetScript("OnEvent", addonLoaded)
optionsFrame:SetScript("OnEvent", addonLoaded)

22
Frames/QuestFrame.lua Normal file → Executable file
View file

@ -5,36 +5,36 @@ local questTranslationFrame = CreateFrame("Frame", "QuestTranslationFrame", nil,
questTranslationFrame:SetWidth(QuestLogFrame:GetWidth())
questTranslationFrame:SetBackdrop({
bgFile = "Interface/Buttons/WHITE8X8",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
tile = true, tileSize = 16, edgeSize = 16,
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 },
})
questTranslationFrame:SetBackdropColor(0, 0, 0, 0.9)
questTranslationFrame:SetBackdropColor(236, 227, 161, 1)
questTranslationFrame:Hide()
local questTranslationFramePrimaryHeader = questTranslationFrame:CreateFontString("QuestTranslationFramePrimaryHeader", "OVERLAY", "QuestTitleFont")
questTranslationFramePrimaryHeader:SetWidth(questTranslationFrame:GetWidth() - 20)
questTranslationFramePrimaryHeader:SetJustifyH("LEFT")
questTranslationFramePrimaryHeader:SetTextColor(1, 1, 1, 1)
questTranslationFramePrimaryHeader:SetFont(headerFontPath, 18, "OUTLINE")
questTranslationFramePrimaryHeader:SetTextColor(0, 0, 0, 1)
questTranslationFramePrimaryHeader:SetFont(headerFontPath, 20, nil)
local questTranslationFrameSecondaryHeader = questTranslationFrame:CreateFontString("QuestTranslationFrameSecondaryHeader", "OVERLAY", "QuestTitleFont")
questTranslationFrameSecondaryHeader:SetWidth(questTranslationFrame:GetWidth() - 20)
questTranslationFrameSecondaryHeader:SetJustifyH("LEFT")
questTranslationFrameSecondaryHeader:SetTextColor(1, 1, 1, 1)
questTranslationFrameSecondaryHeader:SetFont(headerFontPath, 18, "OUTLINE")
questTranslationFrameSecondaryHeader:SetTextColor(0, 0, 0, 1)
questTranslationFrameSecondaryHeader:SetFont(headerFontPath, 20, nil)
local questTranslationFramePrimaryText = questTranslationFrame:CreateFontString("QuestTranslationFramePrimaryText", "OVERLAY", "QuestFont")
questTranslationFramePrimaryText:SetWidth(questTranslationFrame:GetWidth() - 20)
questTranslationFramePrimaryText:SetJustifyH("LEFT")
questTranslationFramePrimaryText:SetTextColor(1, 1, 1, 1)
questTranslationFramePrimaryText:SetFont(textFontPath, 13, "OUTLINE")
questTranslationFramePrimaryText:SetTextColor(0, 0, 0, 1)
questTranslationFramePrimaryText:SetFont(textFontPath, 15, nil)
local questTranslationFrameSecondaryText = questTranslationFrame:CreateFontString("QuestTranslationFrameSecondaryText", "OVERLAY", "QuestFont")
questTranslationFrameSecondaryText:SetWidth(questTranslationFrame:GetWidth() - 20)
questTranslationFrameSecondaryText:SetJustifyH("LEFT")
questTranslationFrameSecondaryText:SetTextColor(1, 1, 1, 1)
questTranslationFrameSecondaryText:SetFont(textFontPath, 13, "OUTLINE")
questTranslationFrameSecondaryText:SetTextColor(0, 0, 0, 1)
questTranslationFrameSecondaryText:SetFont(textFontPath, 15, nil)
QuestTranslationFrame:RegisterEvent("QUEST_PROGRESS")
QuestTranslationFrame:RegisterEvent("QUEST_COMPLETE")