📄 auccommand.lua
字号:
--[[ Auctioneer Addon for World of Warcraft(tm). Version: 3.5.0.0917 (Platypus) Revision: $Id: AucCommand.lua 917 2006-07-04 19:54:25Z mentalpower $ Auctioneer command functions. Functions to allow setting of values, switching commands etc. License: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program(see GPL.txt); if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.]]--Local function prototypeslocal register, convertKhaos, getKhaosDefault, setKhaosSetKeyParameter, setKhaosSetKeyValue, getKhaosLocaleList, getKhaosDurationsList, getKhaosProtectionList, getKhaosFinishList, registerKhaos, buildCommandMap, commandMap, commandMapRev, command, chatPrintHelp, onOff, clear, alsoInclude, isValidLocale, setLocale, default, getFrameNames, getFrameIndex, setFrame, protectWindow, auctionDuration, finish, genVarSet, percentVarSet, numVarSet, setFilter, getFilterVal, getFilter, findFilterClass, setFilter, getLocalefunction register() if (Khaos) then if (not Auctioneer_Khaos_Registered) then registerKhaos(); end endend-- Convert a single key in a table of configuration settingsfunction convertConfig(t, key, values, ...) --Local local modified = false; local v = nil; for i,localizedKey in ipairs(arg) do if (t[localizedKey] ~= nil) then v = t[localizedKey]; t[localizedKey] = nil; modified = true; end end if (t[key] ~= nil) then v = t[key]; end if (v ~= nil) then if (values[v] ~= nil) then t[key] = values[v]; modified = true; else t[key] = v; end end return modified;end-- Convert Khaos options to standardized keys and valuesfunction convertKhaos() if (not Khaos_Configurations) then return; end -- Array that maps localized versions of strings to standardized local convertOnOff = { ['apagado'] = 'off', -- esES ['prendido'] = 'on', -- esES } local localeConvMap = { ['apagado'] = 'default', ['prendido'] = 'default', ['off'] = 'default', ['on'] = 'default', } -- Format: standardizedKey, valueMap, esES, localizedKey local conversions = { -- Localized stuff to get rid of { 'show-warning', convertOnOff, 'ver-advertencia' }, { 'show-verbose', convertOnOff, 'ver-literal' }, { 'show-stats', convertOnOff, 'ver-estadisticas'}, { 'show-average', convertOnOff, 'ver-promedio' }, { 'show-median', convertOnOff, 'ver-mediano' }, { 'show-suggest', convertOnOff, 'ver-sugerencia' }, { 'embed', convertOnOff, 'integrado' }, { 'show-embed-blankline', convertOnOff, 'ver-integrado-lineavacia' }, { 'pct-bidmarkdown', convertOnOff, 'pct-menosoferta' }, { 'pct-markup', convertOnOff, 'pct-mas' }, { 'pct-maxless', convertOnOff, 'pct-sinmaximo' }, { 'pct-nocomp', convertOnOff, 'pct-sincomp' }, { 'pct-underlow', convertOnOff, 'pct-bajomenor' }, { 'pct-undermkt', convertOnOff, 'pct-bajomercado' }, { 'autofill', convertOnOff, 'autoinsertar' }, { 'show-link', convertOnOff, 'ver-enlace' }, -- Changed key names { 'locale', convertOnOff, 'AuctioneerLocale' }, { 'printframe', convertOnOff, 'AuctioneerPrintFrame' }, { 'also', convertOnOff, 'AuctioneerInclude' }, { 'enabled', convertOnOff, 'AuctioneerEnable' }, } -- Prepend placeholder for the table parameter for i,c in ipairs(conversions) do table.insert(c, 1, nil) end for i,config in ipairs(Khaos_Configurations) do if (config.configuration and config.configuration.Auctioneer) then local converted = false; -- Run the defined conversions for i,c in ipairs(conversions) do -- Replace first parameter with actual table to process -- Inserting here will cause problems for the second iteration c[1] = config.configuration.Auctioneer converted = convertConfig(unpack(c)) or converted end if (converted) then Auctioneer.Util.ChatPrint("Converted old Khaos configuration \"" .. config.name .. "\"") end end endendfunction getKhaosDefault(filter) if (filter == "also") then return Auctioneer.Core.Constants.FilterDefaults[filter]; elseif (Auctioneer.Core.Constants.FilterDefaults[filter] == 'on') then return true; elseif (Auctioneer.Core.Constants.FilterDefaults[filter] == 'off') then return false; else return Auctioneer.Core.Constants.FilterDefaults[filter]; endendfunction setKhaosSetKeyParameter(key, parameter, value) --Local if (Auctioneer_Khaos_Registered) then if (Khaos.getSetKey("Auctioneer", key)) then Khaos.setSetKeyParameter("Auctioneer", key, parameter, value) else EnhTooltip.DebugPrint("setKhaosSetKeyParameter(): key " .. key .. " does not exist") end endendfunction setKhaosSetKeyValue(key, value) --Local if (Auctioneer_Khaos_Registered) then local kKey = Khaos.getSetKey("Auctioneer", key) if (not kKey) then EnhTooltip.DebugPrint("setKhaosSetKeyParameter(): key " .. key .. " does not exist") elseif (kKey.checked ~= nil) then if (type(value) == "string") then value = (value == "on"); end Khaos.setSetKeyParameter("Auctioneer", key, "checked", value) elseif (kKey.value ~= nil) then Khaos.setSetKeyParameter("Auctioneer", key, "value", value) else EnhTooltip.DebugPrint("setKhaosSetKeyValue(): don't know how to update key ", key) end endendfunction getKhaosLocaleList() --Local local options = { [_AUCT('CmdDefault')] = 'default' }; for locale, data in AuctioneerLocalizations do options[locale] = locale; end return optionsendfunction getKhaosLoadList() --Local return { [_AUCT('GuiLoad_Always')] = 'always', [_AUCT('GuiLoad_Never')] = 'never', [_AUCT('GuiLoad_AuctionHouse')] = 'auctionhouse' }endfunction getKhaosDurationsList() --Local local list = {} for i = 0, 3 do list[_AUCT('CmdAuctionDuration'..i)] = i end return listendfunction getKhaosProtectionList() --Local local list = {} for i = 0, 2 do list[_AUCT('CmdProtectWindow'..i)] = i end return listendfunction getKhaosFinishList() --Local local list = {} for i = 0, 3 do list[_AUCT('CmdFinish'..i)] = i end return listendfunction registerKhaos() -- Convert old Khaos settings to current optionSet convertKhaos(); local optionSet = { id="Auctioneer"; text="Auctioneer"; helptext=function() return _AUCT('GuiMainHelp') end; difficulty=1; default={checked=true}; options={ { id="Header"; text="Auctioneer"; helptext=function() return _AUCT('GuiMainHelp') end; type=K_HEADER; difficulty=1; }; { id="enabled"; type=K_TEXT; text=function() return _AUCT('GuiMainEnable') end; helptext=function() return _AUCT('HelpOnoff') end; callback=function(state) Auctioneer.Command.OnOff(state.checked); end; feedback=function(state) if (state.checked) then return _AUCT('StatOn'); else return _AUCT('StatOff'); end end; check=true; default={checked=true}; disabled={checked=false}; difficulty=1; }; { id="LoadSettings"; type=K_PULLDOWN; setup = { options = getKhaosLoadList; multiSelect = false; }; text=function() return _AUCT('GuiLoad') end; helptext=function() return _AUCT('HelpLoad') end; callback=function(state) end; feedback=function(state) mainHandler("load " .. state.value, "GUI") end; default={value = 'auctionhouse'}; disabled={value = 'never'}; difficulty=1; }; { id="locale"; type=K_PULLDOWN; setup = { options = getKhaosLocaleList; multiSelect = false; }; text=function() return _AUCT('GuiLocale') end; helptext=function() return _AUCT('HelpLocale') end; callback = function(state) end; feedback = function (state) Auctioneer.Command.SetLocale(state.value); return string.format(_AUCT('FrmtActSet'), _AUCT('CmdLocale'), state.value); end; default = { value = Auctioneer.Command.GetLocale(); }; disabled = { value = Auctioneer.Command.GetLocale(); }; dependencies={enabled={checked=true;}}; difficulty=2; }; { id="AuctioneerStatsHeader"; type=K_HEADER; text=function() return _AUCT('GuiStatsHeader') end; helptext=function() return _AUCT('GuiStatsHelp') end; difficulty=2; }; { id="show-stats"; type=K_TEXT; text=function() return _AUCT('GuiStatsEnable') end; helptext=function() return _AUCT('HelpStats') end; callback=function(state) Auctioneer.Command.GenVarSet("show-stats", state.checked); end; feedback=function(state) if (state.checked) then return (string.format(_AUCT('FrmtActEnable'), _AUCT('ShowStats'))); else return (string.format(_AUCT('FrmtActDisable'), _AUCT('ShowStats'))); end end; check=true; default={checked=getKhaosDefault('show-stats')}; disabled={checked=false}; dependencies={enabled={checked=true;}}; difficulty=1; }; { id="show-average"; type=K_TEXT; text=function() return _AUCT('GuiAverages') end; helptext=function() return _AUCT('HelpAverage') end; callback=function(state) Auctioneer.Command.GenVarSet("show-average", state.checked); end; feedback=function(state) if (state.checked) then return (string.format(_AUCT('FrmtActEnable'), _AUCT('ShowAverage'))); else return (string.format(_AUCT('FrmtActDisable'), _AUCT('ShowAverage'))); end end; check=true; default={checked=getKhaosDefault('show-average')}; disabled={checked=false}; dependencies={enabled={checked=true;}}; difficulty=2; }; { id="show-median"; type=K_TEXT; text=function() return _AUCT('GuiMedian') end; helptext=function() return _AUCT('HelpMedian') end; callback=function(state) Auctioneer.Command.GenVarSet("show-median", state.checked); end; feedback=function(state) if (state.checked) then return (string.format(_AUCT('FrmtActEnable'), _AUCT('ShowMedian'))); else return (string.format(_AUCT('FrmtActDisable'), _AUCT('ShowMedian'))); end end; check=true; default={checked=getKhaosDefault('show-median')}; disabled={checked=false}; dependencies={enabled={checked=true;}}; difficulty=2; }; { id="show-suggest"; type=K_TEXT; text=function() return _AUCT('GuiSuggest') end; helptext=function() return _AUCT('HelpSuggest') end; callback=function(state) Auctioneer.Command.GenVarSet("show-suggest", state.checked); end; feedback=function(state) if (state.checked) then return (string.format(_AUCT('FrmtActEnable'), _AUCT('ShowSuggest'))); else return (string.format(_AUCT('FrmtActDisable'), _AUCT('ShowSuggest'))); end end; check=true; default={checked=getKhaosDefault('show-suggest')}; disabled={checked=false};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -