Mercurial > wow > cyborg-mmo7
comparison OptionView.lua @ 1:a4e2eaf9cad9
Initial Fixes for ticket 1: Added a menu to the interface options page to allow the syncing of the addon to the mouse profile. This should resolve i8n issues
| author | madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09 |
|---|---|
| date | Wed, 23 May 2012 08:26:07 +0000 |
| parents | bf9220814fb5 |
| children | 08c83fa555a5 |
comparison
equal
deleted
inserted
replaced
| 0:bf9220814fb5 | 1:a4e2eaf9cad9 |
|---|---|
| 24 InterfaceOptions_AddCategory(self); | 24 InterfaceOptions_AddCategory(self); |
| 25 return self | 25 return self |
| 26 | 26 |
| 27 end | 27 end |
| 28 } | 28 } |
| 29 | |
| 30 local lastButton = nil | |
| 31 | |
| 32 function BindButton(name) | |
| 33 lastButton = name; | |
| 34 BindingFrame:Show() | |
| 35 | |
| 36 end | |
| 37 | |
| 38 function GetBindingButtonText(name) | |
| 39 if(nil == WowCommands) then | |
| 40 LoadWowCommands(); | |
| 41 end | |
| 42 | |
| 43 local binding = WowCommands[GetButtonIndex(name)] | |
| 44 getglobal(name):SetText(binding) | |
| 45 end | |
| 46 | |
| 47 function GetButtonIndex(name) | |
| 48 local row,mode = string.find(name,"Mode") | |
| 49 local modeStr = string.sub(name, mode +1,mode+2) | |
| 50 local rowStr = string.sub(name, row-1,row-1) | |
| 51 return (GetNumberFromHexLetter(rowStr) + ((GetNumberFromHexLetter(modeStr) - 1) * 13)) | |
| 52 end | |
| 53 | |
| 54 function GetNumberFromHexLetter(str) | |
| 55 local number = 0 | |
| 56 if("A" == str) then | |
| 57 number = 10 | |
| 58 elseif("B" == str) then | |
| 59 number = 11 | |
| 60 elseif("C" == str) then | |
| 61 number = 12 | |
| 62 elseif("D" == str) then | |
| 63 number = 13 | |
| 64 elseif("E" == str) then | |
| 65 number = 14 | |
| 66 elseif("F" == str) then | |
| 67 number = 15 | |
| 68 else | |
| 69 number = tonumber(str) | |
| 70 end | |
| 71 return number | |
| 72 end | |
| 73 | |
| 74 function SetNewKeybind(keyOrButton) | |
| 75 local previous = WowCommands[GetButtonIndex(lastButton)] | |
| 76 WowCommands[GetButtonIndex(lastButton)] = keyOrButton; | |
| 77 GetBindingButtonText(lastButton); | |
| 78 BindingFrame:Hide() | |
| 79 RatPageModel.Instance().LoadData() | |
| 80 end | |
| 81 | |
| 82 function BindingFrame_OnKeyDown(self, keyOrButton) | |
| 83 if keyOrButton=="ESCAPE" then | |
| 84 BindingFrame:Hide() | |
| 85 return | |
| 86 end | |
| 87 | |
| 88 if ( GetBindingFromClick(keyOrButton) == "SCREENSHOT" ) then | |
| 89 RunBinding("SCREENSHOT"); | |
| 90 return; | |
| 91 end | |
| 92 | |
| 93 local keyPressed = keyOrButton; | |
| 94 | |
| 95 if ( keyPressed == "UNKNOWN" ) then | |
| 96 return; | |
| 97 end | |
| 98 | |
| 99 -- Convert the mouse button names | |
| 100 if ( keyPressed == "LeftButton" ) then | |
| 101 keyPressed = "BUTTON1"; | |
| 102 elseif ( keyPressed == "RightButton" ) then | |
| 103 keyPressed = "BUTTON2"; | |
| 104 elseif ( keyPressed == "MiddleButton" ) then | |
| 105 keyPressed = "BUTTON3"; | |
| 106 elseif ( keyPressed == "Button4" ) then | |
| 107 keyPressed = "BUTTON4" | |
| 108 elseif ( keyOrButton == "Button5" ) then | |
| 109 keyPressed = "BUTTON5" | |
| 110 elseif ( keyPressed == "Button6" ) then | |
| 111 keyPressed = "BUTTON6" | |
| 112 elseif ( keyOrButton == "Button7" ) then | |
| 113 keyPressed = "BUTTON7" | |
| 114 elseif ( keyPressed == "Button8" ) then | |
| 115 keyPressed = "BUTTON8" | |
| 116 elseif ( keyOrButton == "Button9" ) then | |
| 117 keyPressed = "BUTTON9" | |
| 118 elseif ( keyPressed == "Button10" ) then | |
| 119 keyPressed = "BUTTON10" | |
| 120 elseif ( keyOrButton == "Button11" ) then | |
| 121 keyPressed = "BUTTON11" | |
| 122 elseif ( keyPressed == "Button12" ) then | |
| 123 keyPressed = "BUTTON12" | |
| 124 elseif ( keyOrButton == "Button13" ) then | |
| 125 keyPressed = "BUTTON13" | |
| 126 elseif ( keyPressed == "Button14" ) then | |
| 127 keyPressed = "BUTTON14" | |
| 128 elseif ( keyOrButton == "Button15" ) then | |
| 129 keyPressed = "BUTTON15" | |
| 130 elseif ( keyPressed == "Button16" ) then | |
| 131 keyPressed = "BUTTON16" | |
| 132 elseif ( keyOrButton == "Button17" ) then | |
| 133 keyPressed = "BUTTON17" | |
| 134 elseif ( keyPressed == "Button18" ) then | |
| 135 keyPressed = "BUTTON18" | |
| 136 elseif ( keyOrButton == "Button19" ) then | |
| 137 keyPressed = "BUTTON19" | |
| 138 elseif ( keyPressed == "Button20" ) then | |
| 139 keyPressed = "BUTTON20" | |
| 140 elseif ( keyOrButton == "Button21" ) then | |
| 141 keyPressed = "BUTTON21" | |
| 142 elseif ( keyPressed == "Button22" ) then | |
| 143 keyPressed = "BUTTON22" | |
| 144 elseif ( keyOrButton == "Button23" ) then | |
| 145 keyPressed = "BUTTON23" | |
| 146 elseif ( keyPressed == "Button24" ) then | |
| 147 keyPressed = "BUTTON24" | |
| 148 elseif ( keyOrButton == "Button25" ) then | |
| 149 keyPressed = "BUTTON25" | |
| 150 elseif ( keyPressed == "Button26" ) then | |
| 151 keyPressed = "BUTTON26" | |
| 152 elseif ( keyOrButton == "Button27" ) then | |
| 153 keyPressed = "BUTTON27" | |
| 154 elseif ( keyPressed == "Button28" ) then | |
| 155 keyPressed = "BUTTON28" | |
| 156 elseif ( keyOrButton == "Button29" ) then | |
| 157 keyPressed = "BUTTON29" | |
| 158 elseif ( keyPressed == "Button30" ) then | |
| 159 keyPressed = "BUTTON30" | |
| 160 elseif ( keyOrButton == "Button31" ) then | |
| 161 keyPressed = "BUTTON31" | |
| 162 end | |
| 163 | |
| 164 if ( keyPressed == "LSHIFT" or | |
| 165 keyPressed == "RSHIFT" or | |
| 166 keyPressed == "LCTRL" or | |
| 167 keyPressed == "RCTRL" or | |
| 168 keyPressed == "LALT" or | |
| 169 keyPressed == "RALT" ) then | |
| 170 return; | |
| 171 end | |
| 172 if ( IsShiftKeyDown() ) then | |
| 173 keyPressed = "SHIFT-"..keyPressed | |
| 174 end | |
| 175 if ( IsControlKeyDown() ) then | |
| 176 keyPressed = "CTRL-"..keyPressed | |
| 177 end | |
| 178 if ( IsAltKeyDown() ) then | |
| 179 keyPressed = "ALT-"..keyPressed | |
| 180 end | |
| 181 if ( keyPressed == "BUTTON1" or keyPressed == "BUTTON2" ) then | |
| 182 return; | |
| 183 end | |
| 184 | |
| 185 SetNewKeybind(keyPressed) | |
| 186 | |
| 187 --~ if keyPressed then | |
| 188 --~ BindPadCore.keyPressed = keyPressed | |
| 189 --~ local oldAction = GetBindingAction(keyPressed) | |
| 190 --~ | |
| 191 --~ local keyText = BindPadCore.GetBindingText(keyPressed, "KEY_"); | |
| 192 --~ if oldAction~="" and oldAction ~= BindPadCore.selectedSlot.action then | |
| 193 --~ if StaticPopupDialogs["BINDPAD_CONFIRM_BINDING"] == nil then | |
| 194 --~ StaticPopupDialogs["BINDPAD_CONFIRM_BINDING"] = { | |
| 195 --~ button1 = YES, | |
| 196 --~ button2 = NO, | |
| 197 --~ timeout = 0, | |
| 198 --~ hideOnEscape = 1, | |
| 199 --~ OnAccept = BindPadBindFrame_SetBindKey, | |
| 200 --~ OnCancel = BindPadBindFrame_Update, | |
| 201 --~ whileDead = 1 | |
| 202 --~ } | |
| 203 --~ end | |
| 204 --~ StaticPopupDialogs["BINDPAD_CONFIRM_BINDING"].text = format(BINDPAD_TEXT_CONFIRM_BINDING, keyText, oldAction, keyText, BindPadCore.selectedSlot.action); | |
| 205 --~ StaticPopup_Show("BINDPAD_CONFIRM_BINDING") | |
| 206 --~ else | |
| 207 --~ BindPadBindFrame_SetBindKey(); | |
| 208 --~ end | |
| 209 --~ end | |
| 210 end |
