annotate OptionView.lua @ 55:72adde883f46

Removed the "Defaults" button from the option page. It was no longer visible following addition of the prefix anyway. Plugged the built-in "Defaults" button of the interface options dialog to what the custom button was previously doing.
author madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09
date Fri, 03 May 2013 23:24:26 +0000
parents e8a004a4177b
children b7ee4a10eaf0
rev   line source
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@55 24 self.default = CyborgMMO_SetDefaultSettings
madcatzinc@13 25 InterfaceOptions_AddCategory(self)
madcatzinc@0 26 return self
madcatzinc@13 27 end,
madcatzinc@0 28 }
madcatzinc@1 29
madcatzinc@1 30 local lastButton = nil
madcatzinc@1 31
madcatzinc@4 32 function CyborgMMO_BindButton(name)
madcatzinc@2 33 lastButton = name
madcatzinc@4 34 local index = CyborgMMO_GetButtonIndex(name)
madcatzinc@2 35 local mode = 1
madcatzinc@13 36 while index > 13 do
madcatzinc@2 37 mode = mode + 1
madcatzinc@2 38 index = index - 13
madcatzinc@2 39 end
madcatzinc@13 40 local buttonStr = CyborgMMO_StringTable[("CyborgMMO_OptionPageRebindMouseRow"..index.."Name")]
madcatzinc@13 41
madcatzinc@27 42 CyborgMMO_BindingFrameButtonName:SetText(buttonStr.." Mode "..mode)
madcatzinc@29 43 CyborgMMO_BindingFrameKey:SetText(CyborgMMO_StringTable["CyborgMMO_CurrentBinding"].." "..CyborgMMO_ProfileKeyBindings[CyborgMMO_GetButtonIndex(lastButton)])
madcatzinc@4 44 CyborgMMO_BindingFrame:Show()
madcatzinc@1 45 end
madcatzinc@1 46
madcatzinc@26 47 function CyborgMMO_SetBindingButtonText(name)
madcatzinc@29 48 local binding = CyborgMMO_ProfileKeyBindings[CyborgMMO_GetButtonIndex(name)]
madcatzinc@1 49 getglobal(name):SetText(binding)
madcatzinc@1 50 end
madcatzinc@1 51
madcatzinc@4 52 function CyborgMMO_GetButtonIndex(name)
madcatzinc@22 53 local row,mode = name:match('Row(.)Mode(.)')
madcatzinc@22 54 row = tonumber(row, 16)
madcatzinc@22 55 mode = tonumber(mode)
madcatzinc@1 56 local modeStr = string.sub(name, mode +1,mode+2)
madcatzinc@1 57 local rowStr = string.sub(name, row-1,row-1)
madcatzinc@22 58 return (mode-1) * 13 + row
madcatzinc@1 59 end
madcatzinc@1 60
madcatzinc@5 61 function CyborgMMO_ShowProfileTooltip(self)
madcatzinc@13 62 local red,green,blue = self:GetVertexColor()
madcatzinc@13 63 if red == 0 and green == 0 and blue == 0 then
madcatzinc@13 64 GameTooltip:SetOwner(self:GetParent(), "ANCHOR_RIGHT")
madcatzinc@13 65 GameTooltip:SetText(CyborgMMO_StringTable["CyborgMMO_ToolTipLine1"], nil, nil, nil, nil, 1)
madcatzinc@13 66 GameTooltip:AddLine(nil, 0.8, 1.0, 0.8)
madcatzinc@13 67 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine2"], 0.8, 1.0, 0.8)
madcatzinc@13 68 GameTooltip:AddLine(nil, 0.8, 1.0, 0.8)
madcatzinc@13 69 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine3"], 0.8, 1.0, 0.8)
madcatzinc@13 70 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine4"], 0.8, 1.0, 0.8)
madcatzinc@13 71 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine5"], 0.8, 1.0, 0.8)
madcatzinc@13 72 GameTooltip:AddLine(nil, 0.8, 1.0, 0.8)
madcatzinc@13 73 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine6"], 0.8, 1.0, 0.8)
madcatzinc@13 74 GameTooltip:Show()
madcatzinc@5 75 end
madcatzinc@5 76 end
madcatzinc@5 77
madcatzinc@5 78 function CyborgMMO_HideProfileTooltip(self)
madcatzinc@13 79 GameTooltip:Hide()
madcatzinc@5 80 end
madcatzinc@5 81
madcatzinc@4 82 function CyborgMMO_SetNewKeybind(keyOrButton)
madcatzinc@29 83 CyborgMMO_ProfileKeyBindings[CyborgMMO_GetButtonIndex(lastButton)] = keyOrButton
madcatzinc@26 84 CyborgMMO_SetBindingButtonText(lastButton)
madcatzinc@4 85 CyborgMMO_BindingFrame:Hide()
madcatzinc@18 86 CyborgMMO_RatPageModel:LoadData()
madcatzinc@1 87 end
madcatzinc@1 88
madcatzinc@4 89 function CyborgMMO_BindingFrameOnKeyDown(self, keyOrButton)
madcatzinc@13 90 if keyOrButton == "ESCAPE" then
madcatzinc@13 91 CyborgMMO_BindingFrame:Hide()
madcatzinc@13 92 return
madcatzinc@13 93 end
madcatzinc@13 94
madcatzinc@13 95 if GetBindingFromClick(keyOrButton) == "SCREENSHOT" then
madcatzinc@13 96 RunBinding("SCREENSHOT")
madcatzinc@13 97 return
madcatzinc@13 98 end
madcatzinc@13 99
madcatzinc@13 100 local keyPressed = keyOrButton
madcatzinc@13 101
madcatzinc@13 102 if keyPressed == "UNKNOWN" then
madcatzinc@13 103 return
madcatzinc@13 104 end
madcatzinc@13 105
madcatzinc@13 106 -- Convert the mouse button names
madcatzinc@13 107 if keyPressed == "LeftButton" then
madcatzinc@13 108 keyPressed = "BUTTON1"
madcatzinc@13 109 elseif keyPressed == "RightButton" then
madcatzinc@13 110 keyPressed = "BUTTON2"
madcatzinc@13 111 elseif keyPressed == "MiddleButton" then
madcatzinc@13 112 keyPressed = "BUTTON3"
madcatzinc@13 113 elseif keyPressed == "Button4" then
madcatzinc@13 114 keyPressed = "BUTTON4"
madcatzinc@13 115 elseif keyOrButton == "Button5" then
madcatzinc@13 116 keyPressed = "BUTTON5"
madcatzinc@13 117 elseif keyPressed == "Button6" then
madcatzinc@13 118 keyPressed = "BUTTON6"
madcatzinc@13 119 elseif keyOrButton == "Button7" then
madcatzinc@13 120 keyPressed = "BUTTON7"
madcatzinc@13 121 elseif keyPressed == "Button8" then
madcatzinc@13 122 keyPressed = "BUTTON8"
madcatzinc@13 123 elseif keyOrButton == "Button9" then
madcatzinc@13 124 keyPressed = "BUTTON9"
madcatzinc@13 125 elseif keyPressed == "Button10" then
madcatzinc@13 126 keyPressed = "BUTTON10"
madcatzinc@13 127 elseif keyOrButton == "Button11" then
madcatzinc@13 128 keyPressed = "BUTTON11"
madcatzinc@13 129 elseif keyPressed == "Button12" then
madcatzinc@13 130 keyPressed = "BUTTON12"
madcatzinc@13 131 elseif keyOrButton == "Button13" then
madcatzinc@13 132 keyPressed = "BUTTON13"
madcatzinc@13 133 elseif keyPressed == "Button14" then
madcatzinc@13 134 keyPressed = "BUTTON14"
madcatzinc@13 135 elseif keyOrButton == "Button15" then
madcatzinc@13 136 keyPressed = "BUTTON15"
madcatzinc@13 137 elseif keyPressed == "Button16" then
madcatzinc@13 138 keyPressed = "BUTTON16"
madcatzinc@13 139 elseif keyOrButton == "Button17" then
madcatzinc@13 140 keyPressed = "BUTTON17"
madcatzinc@13 141 elseif keyPressed == "Button18" then
madcatzinc@13 142 keyPressed = "BUTTON18"
madcatzinc@13 143 elseif keyOrButton == "Button19" then
madcatzinc@13 144 keyPressed = "BUTTON19"
madcatzinc@13 145 elseif keyPressed == "Button20" then
madcatzinc@13 146 keyPressed = "BUTTON20"
madcatzinc@13 147 elseif keyOrButton == "Button21" then
madcatzinc@13 148 keyPressed = "BUTTON21"
madcatzinc@13 149 elseif keyPressed == "Button22" then
madcatzinc@13 150 keyPressed = "BUTTON22"
madcatzinc@13 151 elseif keyOrButton == "Button23" then
madcatzinc@13 152 keyPressed = "BUTTON23"
madcatzinc@13 153 elseif keyPressed == "Button24" then
madcatzinc@13 154 keyPressed = "BUTTON24"
madcatzinc@13 155 elseif keyOrButton == "Button25" then
madcatzinc@13 156 keyPressed = "BUTTON25"
madcatzinc@13 157 elseif keyPressed == "Button26" then
madcatzinc@13 158 keyPressed = "BUTTON26"
madcatzinc@13 159 elseif keyOrButton == "Button27" then
madcatzinc@13 160 keyPressed = "BUTTON27"
madcatzinc@13 161 elseif keyPressed == "Button28" then
madcatzinc@13 162 keyPressed = "BUTTON28"
madcatzinc@13 163 elseif keyOrButton == "Button29" then
madcatzinc@13 164 keyPressed = "BUTTON29"
madcatzinc@13 165 elseif keyPressed == "Button30" then
madcatzinc@13 166 keyPressed = "BUTTON30"
madcatzinc@13 167 elseif keyOrButton == "Button31" then
madcatzinc@13 168 keyPressed = "BUTTON31"
madcatzinc@13 169 end
madcatzinc@13 170
madcatzinc@13 171 if keyPressed == "LSHIFT" or
madcatzinc@13 172 keyPressed == "RSHIFT" or
madcatzinc@13 173 keyPressed == "LCTRL" or
madcatzinc@13 174 keyPressed == "RCTRL" or
madcatzinc@13 175 keyPressed == "LALT" or
madcatzinc@13 176 keyPressed == "RALT" then
madcatzinc@13 177 return
madcatzinc@13 178 end
madcatzinc@13 179 if IsShiftKeyDown() then
madcatzinc@13 180 keyPressed = "SHIFT-"..keyPressed
madcatzinc@13 181 end
madcatzinc@13 182 if IsControlKeyDown() then
madcatzinc@13 183 keyPressed = "CTRL-"..keyPressed
madcatzinc@13 184 end
madcatzinc@13 185 if IsAltKeyDown() then
madcatzinc@13 186 keyPressed = "ALT-"..keyPressed
madcatzinc@13 187 end
madcatzinc@13 188 if keyPressed == "BUTTON1" or keyPressed == "BUTTON2" then
madcatzinc@13 189 return
madcatzinc@13 190 end
madcatzinc@13 191
madcatzinc@13 192 CyborgMMO_SetNewKeybind(keyPressed)
madcatzinc@1 193 end