madcatzinc@13
|
1 --~ Warcraft Plugin for Cyborg MMO7
|
madcatzinc@0
|
2 --~ Filename: OptionView.lua
|
madcatzinc@0
|
3 --~ Description: The code for the Option page in the UI, not much here because we dont have many options. Probably could refactor.
|
madcatzinc@0
|
4 --~ Copyright (C) 2012 Mad Catz Inc.
|
madcatzinc@0
|
5 --~ Author: Christopher Hooks
|
madcatzinc@0
|
6
|
madcatzinc@0
|
7 --~ This program is free software; you can redistribute it and/or
|
madcatzinc@0
|
8 --~ modify it under the terms of the GNU General Public License
|
madcatzinc@0
|
9 --~ as published by the Free Software Foundation; either version 2
|
madcatzinc@0
|
10 --~ of the License, or (at your option) any later version.
|
madcatzinc@0
|
11
|
madcatzinc@0
|
12 --~ This program is distributed in the hope that it will be useful,
|
madcatzinc@0
|
13 --~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
madcatzinc@0
|
14 --~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
madcatzinc@0
|
15 --~ GNU General Public License for more details.
|
madcatzinc@0
|
16
|
madcatzinc@0
|
17 --~ You should have received a copy of the GNU General Public License
|
madcatzinc@0
|
18 --~ along with this program; if not, write to the Free Software
|
madcatzinc@0
|
19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
madcatzinc@0
|
20
|
madcatzinc@4
|
21 CyborgMMO_OptionView = {
|
madcatzinc@0
|
22 new = function(self)
|
madcatzinc@13
|
23 self.name = "Cyborg MMO7 Plugin"
|
madcatzinc@13
|
24 InterfaceOptions_AddCategory(self)
|
madcatzinc@0
|
25 return self
|
madcatzinc@13
|
26 end,
|
madcatzinc@0
|
27 }
|
madcatzinc@1
|
28
|
madcatzinc@1
|
29 local lastButton = nil
|
madcatzinc@1
|
30
|
madcatzinc@4
|
31 function CyborgMMO_BindButton(name)
|
madcatzinc@2
|
32 lastButton = name
|
madcatzinc@4
|
33 local index = CyborgMMO_GetButtonIndex(name)
|
madcatzinc@2
|
34 local mode = 1
|
madcatzinc@13
|
35 while index > 13 do
|
madcatzinc@2
|
36 mode = mode + 1
|
madcatzinc@2
|
37 index = index - 13
|
madcatzinc@2
|
38 end
|
madcatzinc@13
|
39 local buttonStr = CyborgMMO_StringTable[("CyborgMMO_OptionPageRebindMouseRow"..index.."Name")]
|
madcatzinc@13
|
40
|
madcatzinc@4
|
41 getglobal("CyborgMMO_BindingFrameButtonName"):SetText(buttonStr.." Mode "..mode)
|
madcatzinc@5
|
42 getglobal("CyborgMMO_BindingFrameKey"):SetText(CyborgMMO_StringTable["CyborgMMO_CurrentBinding"].." "..CyborgMMO_WowCommands[CyborgMMO_GetButtonIndex(lastButton)])
|
madcatzinc@4
|
43 CyborgMMO_BindingFrame:Show()
|
madcatzinc@1
|
44 end
|
madcatzinc@1
|
45
|
madcatzinc@4
|
46 function CyborgMMO_GetBindingButtonText(name)
|
madcatzinc@13
|
47 if not CyborgMMO_WowCommands then
|
madcatzinc@13
|
48 CyborgMMO_LoadWowCommands()
|
madcatzinc@1
|
49 end
|
madcatzinc@13
|
50
|
madcatzinc@5
|
51 local binding = CyborgMMO_WowCommands[CyborgMMO_GetButtonIndex(name)]
|
madcatzinc@1
|
52 getglobal(name):SetText(binding)
|
madcatzinc@1
|
53 end
|
madcatzinc@1
|
54
|
madcatzinc@4
|
55 function CyborgMMO_GetButtonIndex(name)
|
madcatzinc@1
|
56 local row,mode = string.find(name,"Mode")
|
madcatzinc@1
|
57 local modeStr = string.sub(name, mode +1,mode+2)
|
madcatzinc@1
|
58 local rowStr = string.sub(name, row-1,row-1)
|
madcatzinc@4
|
59 return (CyborgMMO_GetNumberFromHexLetter(rowStr) + ((CyborgMMO_GetNumberFromHexLetter(modeStr) - 1) * 13))
|
madcatzinc@1
|
60 end
|
madcatzinc@1
|
61
|
madcatzinc@5
|
62 function CyborgMMO_ShowProfileTooltip(self)
|
madcatzinc@13
|
63 local red,green,blue = self:GetVertexColor()
|
madcatzinc@13
|
64 if red == 0 and green == 0 and blue == 0 then
|
madcatzinc@13
|
65 GameTooltip:SetOwner(self:GetParent(), "ANCHOR_RIGHT")
|
madcatzinc@13
|
66 GameTooltip:SetText(CyborgMMO_StringTable["CyborgMMO_ToolTipLine1"], nil, nil, nil, nil, 1)
|
madcatzinc@13
|
67 GameTooltip:AddLine(nil, 0.8, 1.0, 0.8)
|
madcatzinc@13
|
68 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine2"], 0.8, 1.0, 0.8)
|
madcatzinc@13
|
69 GameTooltip:AddLine(nil, 0.8, 1.0, 0.8)
|
madcatzinc@13
|
70 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine3"], 0.8, 1.0, 0.8)
|
madcatzinc@13
|
71 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine4"], 0.8, 1.0, 0.8)
|
madcatzinc@13
|
72 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine5"], 0.8, 1.0, 0.8)
|
madcatzinc@13
|
73 GameTooltip:AddLine(nil, 0.8, 1.0, 0.8)
|
madcatzinc@13
|
74 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine6"], 0.8, 1.0, 0.8)
|
madcatzinc@13
|
75 GameTooltip:Show()
|
madcatzinc@5
|
76 end
|
madcatzinc@5
|
77 end
|
madcatzinc@5
|
78
|
madcatzinc@5
|
79 function CyborgMMO_HideProfileTooltip(self)
|
madcatzinc@13
|
80 GameTooltip:Hide()
|
madcatzinc@5
|
81 end
|
madcatzinc@5
|
82
|
madcatzinc@4
|
83 function CyborgMMO_GetNumberFromHexLetter(str)
|
madcatzinc@1
|
84 local number = 0
|
madcatzinc@13
|
85 if str == "A" then
|
madcatzinc@1
|
86 number = 10
|
madcatzinc@13
|
87 elseif str == "B" then
|
madcatzinc@1
|
88 number = 11
|
madcatzinc@13
|
89 elseif str == "C" then
|
madcatzinc@1
|
90 number = 12
|
madcatzinc@13
|
91 elseif str == "D" then
|
madcatzinc@1
|
92 number = 13
|
madcatzinc@13
|
93 elseif str == "E" then
|
madcatzinc@1
|
94 number = 14
|
madcatzinc@13
|
95 elseif str == "F" then
|
madcatzinc@1
|
96 number = 15
|
madcatzinc@13
|
97 else
|
madcatzinc@13
|
98 number = tonumber(str)
|
madcatzinc@1
|
99 end
|
madcatzinc@1
|
100 return number
|
madcatzinc@1
|
101 end
|
madcatzinc@1
|
102
|
madcatzinc@4
|
103 function CyborgMMO_SetNewKeybind(keyOrButton)
|
madcatzinc@5
|
104 local previous = CyborgMMO_WowCommands[CyborgMMO_GetButtonIndex(lastButton)]
|
madcatzinc@13
|
105 CyborgMMO_WowCommands[CyborgMMO_GetButtonIndex(lastButton)] = keyOrButton
|
madcatzinc@13
|
106 CyborgMMO_GetBindingButtonText(lastButton)
|
madcatzinc@4
|
107 CyborgMMO_BindingFrame:Hide()
|
madcatzinc@18
|
108 CyborgMMO_RatPageModel:LoadData()
|
madcatzinc@1
|
109 end
|
madcatzinc@1
|
110
|
madcatzinc@4
|
111 function CyborgMMO_BindingFrameOnKeyDown(self, keyOrButton)
|
madcatzinc@13
|
112 if keyOrButton == "ESCAPE" then
|
madcatzinc@13
|
113 CyborgMMO_BindingFrame:Hide()
|
madcatzinc@13
|
114 return
|
madcatzinc@13
|
115 end
|
madcatzinc@13
|
116
|
madcatzinc@13
|
117 if GetBindingFromClick(keyOrButton) == "SCREENSHOT" then
|
madcatzinc@13
|
118 RunBinding("SCREENSHOT")
|
madcatzinc@13
|
119 return
|
madcatzinc@13
|
120 end
|
madcatzinc@13
|
121
|
madcatzinc@13
|
122 local keyPressed = keyOrButton
|
madcatzinc@13
|
123
|
madcatzinc@13
|
124 if keyPressed == "UNKNOWN" then
|
madcatzinc@13
|
125 return
|
madcatzinc@13
|
126 end
|
madcatzinc@13
|
127
|
madcatzinc@13
|
128 -- Convert the mouse button names
|
madcatzinc@13
|
129 if keyPressed == "LeftButton" then
|
madcatzinc@13
|
130 keyPressed = "BUTTON1"
|
madcatzinc@13
|
131 elseif keyPressed == "RightButton" then
|
madcatzinc@13
|
132 keyPressed = "BUTTON2"
|
madcatzinc@13
|
133 elseif keyPressed == "MiddleButton" then
|
madcatzinc@13
|
134 keyPressed = "BUTTON3"
|
madcatzinc@13
|
135 elseif keyPressed == "Button4" then
|
madcatzinc@13
|
136 keyPressed = "BUTTON4"
|
madcatzinc@13
|
137 elseif keyOrButton == "Button5" then
|
madcatzinc@13
|
138 keyPressed = "BUTTON5"
|
madcatzinc@13
|
139 elseif keyPressed == "Button6" then
|
madcatzinc@13
|
140 keyPressed = "BUTTON6"
|
madcatzinc@13
|
141 elseif keyOrButton == "Button7" then
|
madcatzinc@13
|
142 keyPressed = "BUTTON7"
|
madcatzinc@13
|
143 elseif keyPressed == "Button8" then
|
madcatzinc@13
|
144 keyPressed = "BUTTON8"
|
madcatzinc@13
|
145 elseif keyOrButton == "Button9" then
|
madcatzinc@13
|
146 keyPressed = "BUTTON9"
|
madcatzinc@13
|
147 elseif keyPressed == "Button10" then
|
madcatzinc@13
|
148 keyPressed = "BUTTON10"
|
madcatzinc@13
|
149 elseif keyOrButton == "Button11" then
|
madcatzinc@13
|
150 keyPressed = "BUTTON11"
|
madcatzinc@13
|
151 elseif keyPressed == "Button12" then
|
madcatzinc@13
|
152 keyPressed = "BUTTON12"
|
madcatzinc@13
|
153 elseif keyOrButton == "Button13" then
|
madcatzinc@13
|
154 keyPressed = "BUTTON13"
|
madcatzinc@13
|
155 elseif keyPressed == "Button14" then
|
madcatzinc@13
|
156 keyPressed = "BUTTON14"
|
madcatzinc@13
|
157 elseif keyOrButton == "Button15" then
|
madcatzinc@13
|
158 keyPressed = "BUTTON15"
|
madcatzinc@13
|
159 elseif keyPressed == "Button16" then
|
madcatzinc@13
|
160 keyPressed = "BUTTON16"
|
madcatzinc@13
|
161 elseif keyOrButton == "Button17" then
|
madcatzinc@13
|
162 keyPressed = "BUTTON17"
|
madcatzinc@13
|
163 elseif keyPressed == "Button18" then
|
madcatzinc@13
|
164 keyPressed = "BUTTON18"
|
madcatzinc@13
|
165 elseif keyOrButton == "Button19" then
|
madcatzinc@13
|
166 keyPressed = "BUTTON19"
|
madcatzinc@13
|
167 elseif keyPressed == "Button20" then
|
madcatzinc@13
|
168 keyPressed = "BUTTON20"
|
madcatzinc@13
|
169 elseif keyOrButton == "Button21" then
|
madcatzinc@13
|
170 keyPressed = "BUTTON21"
|
madcatzinc@13
|
171 elseif keyPressed == "Button22" then
|
madcatzinc@13
|
172 keyPressed = "BUTTON22"
|
madcatzinc@13
|
173 elseif keyOrButton == "Button23" then
|
madcatzinc@13
|
174 keyPressed = "BUTTON23"
|
madcatzinc@13
|
175 elseif keyPressed == "Button24" then
|
madcatzinc@13
|
176 keyPressed = "BUTTON24"
|
madcatzinc@13
|
177 elseif keyOrButton == "Button25" then
|
madcatzinc@13
|
178 keyPressed = "BUTTON25"
|
madcatzinc@13
|
179 elseif keyPressed == "Button26" then
|
madcatzinc@13
|
180 keyPressed = "BUTTON26"
|
madcatzinc@13
|
181 elseif keyOrButton == "Button27" then
|
madcatzinc@13
|
182 keyPressed = "BUTTON27"
|
madcatzinc@13
|
183 elseif keyPressed == "Button28" then
|
madcatzinc@13
|
184 keyPressed = "BUTTON28"
|
madcatzinc@13
|
185 elseif keyOrButton == "Button29" then
|
madcatzinc@13
|
186 keyPressed = "BUTTON29"
|
madcatzinc@13
|
187 elseif keyPressed == "Button30" then
|
madcatzinc@13
|
188 keyPressed = "BUTTON30"
|
madcatzinc@13
|
189 elseif keyOrButton == "Button31" then
|
madcatzinc@13
|
190 keyPressed = "BUTTON31"
|
madcatzinc@13
|
191 end
|
madcatzinc@13
|
192
|
madcatzinc@13
|
193 if keyPressed == "LSHIFT" or
|
madcatzinc@13
|
194 keyPressed == "RSHIFT" or
|
madcatzinc@13
|
195 keyPressed == "LCTRL" or
|
madcatzinc@13
|
196 keyPressed == "RCTRL" or
|
madcatzinc@13
|
197 keyPressed == "LALT" or
|
madcatzinc@13
|
198 keyPressed == "RALT" then
|
madcatzinc@13
|
199 return
|
madcatzinc@13
|
200 end
|
madcatzinc@13
|
201 if IsShiftKeyDown() then
|
madcatzinc@13
|
202 keyPressed = "SHIFT-"..keyPressed
|
madcatzinc@13
|
203 end
|
madcatzinc@13
|
204 if IsControlKeyDown() then
|
madcatzinc@13
|
205 keyPressed = "CTRL-"..keyPressed
|
madcatzinc@13
|
206 end
|
madcatzinc@13
|
207 if IsAltKeyDown() then
|
madcatzinc@13
|
208 keyPressed = "ALT-"..keyPressed
|
madcatzinc@13
|
209 end
|
madcatzinc@13
|
210 if keyPressed == "BUTTON1" or keyPressed == "BUTTON2" then
|
madcatzinc@13
|
211 return
|
madcatzinc@13
|
212 end
|
madcatzinc@13
|
213
|
madcatzinc@13
|
214 CyborgMMO_SetNewKeybind(keyPressed)
|
madcatzinc@1
|
215 end
|