5
5
local LibStub = LibStub
6
6
local reg = LibStub (" AceConfigRegistry-3.0" )
7
7
8
- local MAJOR , MINOR = " BlizzConfigDialog-1.0" , 1
8
+ local MAJOR , MINOR = " BlizzConfigDialog-1.0" , 2
9
9
local BlizzConfigDialog = LibStub :NewLibrary (MAJOR , MINOR )
10
10
11
11
if not BlizzConfigDialog then return end
@@ -76,6 +76,7 @@ local isInherited = {
76
76
local stringIsLiteral = {
77
77
name = true ,
78
78
desc = true ,
79
+ action = true ,
79
80
icon = true ,
80
81
usage = true ,
81
82
width = true ,
@@ -258,6 +259,15 @@ local function CheckOptionHidden(option, options, path, appName)
258
259
return GetOptionsMemberValue (" hidden" , option , options , path , appName )
259
260
end
260
261
262
+ --- @param minValue number
263
+ --- @param maxValue number
264
+ --- @return number | function
265
+ local function GetFormatter1to10 (minValue , maxValue )
266
+ return function (value )
267
+ return RoundToSignificantDigits (((value - minValue )/ (maxValue - minValue ) * 9 ) + 1 , 1 )
268
+ end
269
+ end
270
+
261
271
--- Feed the given options to the Blizzard settings panel
262
272
--
263
273
-- @param appName The application name as given to `:RegisterOptionsTable()`
@@ -316,12 +326,15 @@ local function FeedOptions(appName, options, path, group, category, layout, isRo
316
326
end
317
327
else
318
328
local function OnSettingChanged (_ , setting , val )
319
- local variable = setting :GetVariable ()
320
329
v .set (setting , val );
321
330
end
322
331
323
332
if v .type == " execute" then
324
- -- TODO
333
+ local buttonName = GetOptionsMemberValue (" buttonName" , v , options , path , appName )
334
+ local desc = GetOptionsMemberValue (" desc" , v , options , path , appName )
335
+ local addSearchTags = true ;
336
+ local initializer = CreateSettingsButtonInitializer (name , buttonName or name , v .func , desc , addSearchTags );
337
+ layout :AddInitializer (initializer );
325
338
326
339
elseif v .type == " input" then
327
340
-- TODO
@@ -337,7 +350,19 @@ local function FeedOptions(appName, options, path, group, category, layout, isRo
337
350
setting :SetValue (value )
338
351
339
352
elseif v .type == " range" then
340
- -- TODO
353
+ local defaultValue = tonumber (GetOptionsMemberValue (" defaultValue" , v , options , path , appName ))
354
+ local setting = Settings .RegisterProxySetting (category , " PROXY_" .. k , Settings .DefaultVarLocation ,
355
+ Settings .VarType .Number , name , defaultValue , v .get , v .set );
356
+
357
+ local minValue = GetOptionsMemberValue (" min" , v , options , path , appName )
358
+ local maxValue = GetOptionsMemberValue (" max" , v , options , path , appName )
359
+ local step = GetOptionsMemberValue (" step" , v , options , path , appName )
360
+ local desc = GetOptionsMemberValue (" desc" , v , options , path , appName )
361
+
362
+ local sliderOptions = Settings .CreateSliderOptions (minValue , maxValue , step );
363
+
364
+ sliderOptions :SetLabelFormatter (MinimalSliderWithSteppersMixin .Label .Right );
365
+ Settings .CreateSlider (category , setting , sliderOptions , desc );
341
366
342
367
elseif v .type == " select" then
343
368
local value = GetOptionsMemberValue (" get" , v , options , path , appName )
@@ -352,7 +377,7 @@ local function FeedOptions(appName, options, path, group, category, layout, isRo
352
377
end
353
378
return container :GetData ()
354
379
end
355
-
380
+
356
381
local setting = Settings .RegisterAddOnSetting (category , name , k , type (defaultValue ), defaultValue )
357
382
Settings .CreateDropDown (category , setting , GetOptions , desc )
358
383
Settings .SetOnValueChangedCallback (k , OnSettingChanged )
@@ -365,7 +390,15 @@ local function FeedOptions(appName, options, path, group, category, layout, isRo
365
390
-- TODO
366
391
367
392
elseif v .type == " keybinding" then
368
- -- TODO
393
+ local action = GetOptionsMemberValue (" action" , v , options , path , appName );
394
+ assert (action ~= " " and action ~= nil )
395
+
396
+ local bindingIndex = C_KeyBindings .GetBindingIndex (action );
397
+ assert (bindingIndex ~= nil )
398
+
399
+ local initializer = CreateKeybindingEntryInitializer (bindingIndex , true );
400
+ initializer :AddSearchTags (GetBindingName (action ));
401
+ layout :AddInitializer (initializer );
369
402
370
403
elseif v .type == " header" then
371
404
layout :AddInitializer (CreateSettingsListSectionHeaderInitializer (name ));
0 commit comments