@@ -3,7 +3,9 @@ local defaultOptions = {
33 ITEM_TRANSLATIONS = true ,
44 SPELL_TRANSLATIONS = true ,
55 NPC_TRANSLATIONS = true ,
6- SELECTED_LANGUAGE = ' en'
6+ SELECTED_LANGUAGE = ' en' ,
7+ SELECTED_INTERACTION = ' hover' ,
8+ SELECTED_HOTKEY = nil
79}
810
911local addonName = ...
@@ -41,7 +43,7 @@ local function InitializeOptions()
4143 languageDropdownDescription :SetText (" Select language:" )
4244
4345 local languageDropdown = CreateFrame (" Frame" , " MultiLanguageLanguageDropdown" , optionsPanel , " UIDropDownMenuTemplate" )
44- languageDropdown :SetPoint (" TOPLEFT" , title , " BOTTOMLEFT" , - 16 , - 26 )
46+ languageDropdown :SetPoint (" TOPLEFT" , languageDropdownDescription , " BOTTOMLEFT" , - 16 , - 4 )
4547
4648 local function OnLanguageDropdownValueChanged (self , arg1 , arg2 , checked )
4749 MultiLanguageOptions .SELECTED_LANGUAGE = arg1
@@ -91,6 +93,99 @@ local function InitializeOptions()
9193
9294 UIDropDownMenu_SetWidth (languageDropdown , 150 )
9395 UIDropDownMenu_Initialize (languageDropdown , InitializeLanguageDropdown )
96+
97+ local interactionDropdownDescription = optionsPanel :CreateFontString (nil , " ARTWORK" , " GameFontnormalSmall" )
98+ interactionDropdownDescription :SetPoint (" TOPLEFT" , enableNpcTranslationCheckbox , " BOTTOMLEFT" , 0 , - 8 )
99+ interactionDropdownDescription :SetText (" Select interaction:" )
100+
101+ local interactionDropdown = CreateFrame (" Frame" , " MultiLanguageInteractionDropdown" , optionsPanel , " UIDropDownMenuTemplate" )
102+ interactionDropdown :SetPoint (" TOPLEFT" , interactionDropdownDescription , " BOTTOMLEFT" , - 16 , - 4 )
103+
104+ local function SetSelectedInteractionText (interactionText , selectedInteractionText , checked )
105+ if checked then
106+ return selectedInteractionText
107+ end
108+
109+ return interactionText
110+ end
111+
112+ local function OnInteractionDropdownValueChanged (self , arg1 , arg2 , checked )
113+ MultiLanguageOptions .SELECTED_INTERACTION = arg1
114+ UIDropDownMenu_SetText (interactionDropdown , arg2 )
115+ end
116+
117+ local function InitializeInteractionDropdown ()
118+ local info = UIDropDownMenu_CreateInfo ()
119+ local interactionText = " Hover"
120+
121+ info .text = " Hover"
122+ info .value = " hover"
123+ info .arg1 = info .value
124+ info .arg2 = info .text
125+ info .checked = MultiLanguageOptions .SELECTED_INTERACTION == " hover"
126+ info .func = OnInteractionDropdownValueChanged
127+ info .minWidth = 145
128+ interactionText = SetSelectedInteractionText (interactionText , info .text , info .checked )
129+ UIDropDownMenu_AddButton (info )
130+
131+ info .text = " Hover + hotkey"
132+ info .value = " hover-hotkey"
133+ info .arg1 = info .value
134+ info .arg2 = info .text
135+ info .checked = MultiLanguageOptions .SELECTED_INTERACTION == " hover-hotkey"
136+ info .func = OnInteractionDropdownValueChanged
137+ info .minWidth = 145
138+ interactionText = SetSelectedInteractionText (interactionText , info .text , info .checked )
139+ UIDropDownMenu_AddButton (info )
140+
141+ UIDropDownMenu_SetText (interactionDropdown , interactionText )
142+ UIDropDownMenu_SetAnchor (interactionDropdown , 16 , 4 , " TOPLEFT" , interactionDropdown , " BOTTOMLEFT" )
143+ end
144+
145+ UIDropDownMenu_SetWidth (interactionDropdown , 150 )
146+ UIDropDownMenu_Initialize (interactionDropdown , InitializeInteractionDropdown )
147+
148+ local hotkeyDescription = optionsPanel :CreateFontString (nil , " ARTWORK" , " GameFontnormalSmall" )
149+ hotkeyDescription :SetPoint (" TOPLEFT" , interactionDropdown , " BOTTOMLEFT" , 16 , - 8 )
150+ hotkeyDescription :SetText (" Register Hotkey (right-click to unbind):" )
151+
152+ local registerHotkeyButton = CreateFrame (" Button" , " MultiLanguageRegisterHotkeyButton" , optionsPanel , " UIPanelButtonTemplate" )
153+ registerHotkeyButton :SetWidth (120 )
154+ registerHotkeyButton :SetHeight (25 )
155+ registerHotkeyButton :SetPoint (" TOPLEFT" , hotkeyDescription , " TOPLEFT" , 0 , - 12 )
156+
157+ if MultiLanguageOptions .SELECTED_HOTKEY then
158+ registerHotkeyButton :SetText (MultiLanguageOptions .SELECTED_HOTKEY )
159+ else
160+ registerHotkeyButton :SetText (" Not Bound" )
161+ end
162+
163+ local waitingForKey = false
164+
165+ registerHotkeyButton :SetScript (" OnMouseDown" , function (self , button )
166+ if button == " LeftButton" then
167+ if not waitingForKey then
168+ waitingForKey = true
169+ registerHotkeyButton :SetText (" Press button.." )
170+ end
171+ elseif button == " RightButton" then
172+ waitingForKey = false
173+ registerHotkeyButton :SetText (" Not Bound" )
174+ MultiLanguageOptions .SELECTED_HOTKEY = nil
175+ end
176+ end )
177+
178+ local function SetHotkeyButton (self , key )
179+ if waitingForKey then
180+ MultiLanguageOptions .SELECTED_HOTKEY = key
181+ registerHotkeyButton :SetText (MultiLanguageOptions .SELECTED_HOTKEY )
182+ waitingForKey = false
183+ end
184+ end
185+
186+ registerHotkeyButton :SetScript (" OnKeyDown" , SetHotkeyButton )
187+ registerHotkeyButton :SetPropagateKeyboardInput (true )
188+
94189 InterfaceOptions_AddCategory (optionsPanel )
95190end
96191
0 commit comments