From 954c8c85c3873adb87714fbc118cbff64c091ba1 Mon Sep 17 00:00:00 2001 From: robin Date: Sun, 2 May 2021 12:48:54 +0200 Subject: [PATCH] Move keybind to lua, and setting to prefs --- core.lua | 9 ++++++--- locale_deDE.lua | 13 +++++++------ locale_enUS.lua | 1 + prefs.lua | 6 +++++- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/core.lua b/core.lua index 7dd1106..538d8d1 100644 --- a/core.lua +++ b/core.lua @@ -60,7 +60,7 @@ local function OnDataUpdate() end end -function zzCoords_MinimapToggle() +local function zzCoords_MinimapToggle() if(MinimapCluster:IsVisible()) then MinimapCluster:Hide() else @@ -122,8 +122,11 @@ child['specs'] = { } function events:PLAYER_ENTERING_WORLD(event) child:UnregisterEvent('PLAYER_ENTERING_WORLD') - BINDING_HEADER_COORDS = childName - BINDING_NAME_COORDS_TOGGLE = L["Toggle Minimap"] + local m = CreateFrame("BUTTON", "zzCoords_MinimapToggleFrame") + m:SetScript("OnClick", zzCoords_MinimapToggle) + if(db['toggleMap'] and db['toggleMap'] ~= '') then + SetBinding(db['toggleMap'], "CLICK zzCoords_MinimapToggleFrame:LeftButton") + end child:RegisterEvent({"ZONE_CHANGED_NEW_AREA","ZONE_CHANGED","ZONE_CHANGED_INDOORS","NEW_WMO_CHUNK"}, child.ZoneEvent) child:RegisterEvent({"PLAYER_STARTED_MOVING", "PLAYER_STOPPED_MOVING"}, child.MoveEvent) end diff --git a/locale_deDE.lua b/locale_deDE.lua index f7b57a2..99b5b6a 100755 --- a/locale_deDE.lua +++ b/locale_deDE.lua @@ -17,7 +17,7 @@ if L then L['HINT4'] = "|c0000ff00Shift-Rechtsklick|r |c00ffffffschaltet Minimap an/aus|r" L['Show Zone'] = "Zeige Zone" L['Show Subzone'] = "Zeige Subzone" - L["Toggle Minimap"] = "Minimap ein-/ausschalten" + L["Toggle Minimap"] = "Minimap ein-/ausblenden" L['Max Length'] = "Max. L\195\164nge" L['Limits the maximum length of the zone'] = "Limitiert die Anzeigel\195\164nge der Zone" L['Mapcoords Screen'] = "Kartenkoordinaten Vollbild" @@ -34,10 +34,11 @@ if L then L['This hides the coords-display in your broker display'] = "Zeigt die Koordinaten im Display-Broker nicht an" L['Colorized Zone'] = "Farbige Zone" L['Show PvP informations about current area'] = "Zeigt PvP Informationen zur Zone farblich an" + L['Set keybind'] = "Setze Tastaturbelegung" end --- ö \195\182 ß \195\159 --- ü \195\188 ä \195\164 --- Ä \195\132 --- ö \195\182 --- Ü \195\156 \ No newline at end of file +-- � \195\182 � \195\159 +-- � \195\188 � \195\164 +-- � \195\132 +-- � \195\182 +-- � \195\156 \ No newline at end of file diff --git a/locale_enUS.lua b/locale_enUS.lua index ee47146..37a8f40 100644 --- a/locale_enUS.lua +++ b/locale_enUS.lua @@ -34,4 +34,5 @@ if L then L['This hides the coords-display in your broker display'] = true L['Colorized Zone'] = true L['Show PvP informations about current area'] = true + L['Set keybind'] = true end \ No newline at end of file diff --git a/prefs.lua b/prefs.lua index 2fb8ed6..da71f4a 100644 --- a/prefs.lua +++ b/prefs.lua @@ -2,7 +2,10 @@ local addonName, addon = ... local childName = addon['childName'] local child = addon[childName] local L = LibStub("AceLocale-3.0"):GetLocale(childName, true) -function child:PrefChanged() +function child:PrefChanged(info, value, oldvalue) + if(info[#info] == 'toggleMap' and value ~= oldvalue) then + SetBinding(value, "CLICK zzCoords_MinimapToggleFrame:LeftButton") + end child:ZoneEvent() end local init = { @@ -20,6 +23,7 @@ local init = { config:AddConfigEntry(main,'windowXY',"header",L['Mapcoords Window'],nil,6) config:AddConfigEntry(main,"windowX","range",L['Window X'],L['Adjusts the X-Offset on windowed map'],7,-512,512,1) config:AddConfigEntry(main,"windowY","range",L['Window Y'],L['Adjusts the Y-Offset on windowed map'],8,-512,512,1) + config:AddConfigEntry(main,"toggleMap","keybinding",L['Toggle Minimap'],L['Set keybind'],5) end } addon.RegisterCallback(init, format("Init%s", childName), 'Setup') \ No newline at end of file