annotate OptionView.lua @ 71:60e5f3262337 tip

Added tag v6.1.0-1 for changeset 553715eacab6
author Jerome Vuarand <jerome.vuarand@gmail.com>
date Thu, 26 Feb 2015 14:18:54 +0000
parents c22f1accec43
children
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@62 23 self.name = CyborgMMO_StringTable.CyborgMMO_OptionPageTitle
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@59 62 if not CyborgMMO_ModeDetected then
madcatzinc@13 63 GameTooltip:SetOwner(self:GetParent(), "ANCHOR_RIGHT")
madcatzinc@13 64 GameTooltip:SetText(CyborgMMO_StringTable["CyborgMMO_ToolTipLine1"], nil, nil, nil, nil, 1)
madcatzinc@13 65 GameTooltip:AddLine(nil, 0.8, 1.0, 0.8)
madcatzinc@13 66 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine2"], 0.8, 1.0, 0.8)
madcatzinc@13 67 GameTooltip:AddLine(nil, 0.8, 1.0, 0.8)
madcatzinc@13 68 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine3"], 0.8, 1.0, 0.8)
madcatzinc@13 69 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine4"], 0.8, 1.0, 0.8)
madcatzinc@13 70 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine5"], 0.8, 1.0, 0.8)
madcatzinc@13 71 GameTooltip:AddLine(nil, 0.8, 1.0, 0.8)
madcatzinc@13 72 GameTooltip:AddLine(CyborgMMO_StringTable["CyborgMMO_ToolTipLine6"], 0.8, 1.0, 0.8)
madcatzinc@13 73 GameTooltip:Show()
madcatzinc@5 74 end
madcatzinc@5 75 end
madcatzinc@5 76
madcatzinc@5 77 function CyborgMMO_HideProfileTooltip(self)
madcatzinc@13 78 GameTooltip:Hide()
madcatzinc@5 79 end
madcatzinc@5 80
madcatzinc@4 81 function CyborgMMO_SetNewKeybind(keyOrButton)
madcatzinc@29 82 CyborgMMO_ProfileKeyBindings[CyborgMMO_GetButtonIndex(lastButton)] = keyOrButton
madcatzinc@26 83 CyborgMMO_SetBindingButtonText(lastButton)
madcatzinc@4 84 CyborgMMO_BindingFrame:Hide()
madcatzinc@18 85 CyborgMMO_RatPageModel:LoadData()
madcatzinc@1 86 end
madcatzinc@1 87
madcatzinc@4 88 function CyborgMMO_BindingFrameOnKeyDown(self, keyOrButton)
madcatzinc@13 89 if keyOrButton == "ESCAPE" then
madcatzinc@13 90 CyborgMMO_BindingFrame:Hide()
madcatzinc@13 91 return
madcatzinc@13 92 end
madcatzinc@13 93
madcatzinc@13 94 if GetBindingFromClick(keyOrButton) == "SCREENSHOT" then
madcatzinc@13 95 RunBinding("SCREENSHOT")
madcatzinc@13 96 return
madcatzinc@13 97 end
madcatzinc@13 98
madcatzinc@13 99 local keyPressed = keyOrButton
madcatzinc@13 100
madcatzinc@13 101 if keyPressed == "UNKNOWN" then
madcatzinc@13 102 return
madcatzinc@13 103 end
madcatzinc@13 104
madcatzinc@13 105 -- Convert the mouse button names
madcatzinc@13 106 if keyPressed == "LeftButton" then
madcatzinc@13 107 keyPressed = "BUTTON1"
madcatzinc@13 108 elseif keyPressed == "RightButton" then
madcatzinc@13 109 keyPressed = "BUTTON2"
madcatzinc@13 110 elseif keyPressed == "MiddleButton" then
madcatzinc@13 111 keyPressed = "BUTTON3"
madcatzinc@13 112 elseif keyPressed == "Button4" then
madcatzinc@13 113 keyPressed = "BUTTON4"
madcatzinc@13 114 elseif keyOrButton == "Button5" then
madcatzinc@13 115 keyPressed = "BUTTON5"
madcatzinc@13 116 elseif keyPressed == "Button6" then
madcatzinc@13 117 keyPressed = "BUTTON6"
madcatzinc@13 118 elseif keyOrButton == "Button7" then
madcatzinc@13 119 keyPressed = "BUTTON7"
madcatzinc@13 120 elseif keyPressed == "Button8" then
madcatzinc@13 121 keyPressed = "BUTTON8"
madcatzinc@13 122 elseif keyOrButton == "Button9" then
madcatzinc@13 123 keyPressed = "BUTTON9"
madcatzinc@13 124 elseif keyPressed == "Button10" then
madcatzinc@13 125 keyPressed = "BUTTON10"
madcatzinc@13 126 elseif keyOrButton == "Button11" then
madcatzinc@13 127 keyPressed = "BUTTON11"
madcatzinc@13 128 elseif keyPressed == "Button12" then
madcatzinc@13 129 keyPressed = "BUTTON12"
madcatzinc@13 130 elseif keyOrButton == "Button13" then
madcatzinc@13 131 keyPressed = "BUTTON13"
madcatzinc@13 132 elseif keyPressed == "Button14" then
madcatzinc@13 133 keyPressed = "BUTTON14"
madcatzinc@13 134 elseif keyOrButton == "Button15" then
madcatzinc@13 135 keyPressed = "BUTTON15"
madcatzinc@13 136 elseif keyPressed == "Button16" then
madcatzinc@13 137 keyPressed = "BUTTON16"
madcatzinc@13 138 elseif keyOrButton == "Button17" then
madcatzinc@13 139 keyPressed = "BUTTON17"
madcatzinc@13 140 elseif keyPressed == "Button18" then
madcatzinc@13 141 keyPressed = "BUTTON18"
madcatzinc@13 142 elseif keyOrButton == "Button19" then
madcatzinc@13 143 keyPressed = "BUTTON19"
madcatzinc@13 144 elseif keyPressed == "Button20" then
madcatzinc@13 145 keyPressed = "BUTTON20"
madcatzinc@13 146 elseif keyOrButton == "Button21" then
madcatzinc@13 147 keyPressed = "BUTTON21"
madcatzinc@13 148 elseif keyPressed == "Button22" then
madcatzinc@13 149 keyPressed = "BUTTON22"
madcatzinc@13 150 elseif keyOrButton == "Button23" then
madcatzinc@13 151 keyPressed = "BUTTON23"
madcatzinc@13 152 elseif keyPressed == "Button24" then
madcatzinc@13 153 keyPressed = "BUTTON24"
madcatzinc@13 154 elseif keyOrButton == "Button25" then
madcatzinc@13 155 keyPressed = "BUTTON25"
madcatzinc@13 156 elseif keyPressed == "Button26" then
madcatzinc@13 157 keyPressed = "BUTTON26"
madcatzinc@13 158 elseif keyOrButton == "Button27" then
madcatzinc@13 159 keyPressed = "BUTTON27"
madcatzinc@13 160 elseif keyPressed == "Button28" then
madcatzinc@13 161 keyPressed = "BUTTON28"
madcatzinc@13 162 elseif keyOrButton == "Button29" then
madcatzinc@13 163 keyPressed = "BUTTON29"
madcatzinc@13 164 elseif keyPressed == "Button30" then
madcatzinc@13 165 keyPressed = "BUTTON30"
madcatzinc@13 166 elseif keyOrButton == "Button31" then
madcatzinc@13 167 keyPressed = "BUTTON31"
madcatzinc@13 168 end
madcatzinc@13 169
madcatzinc@13 170 if keyPressed == "LSHIFT" or
madcatzinc@13 171 keyPressed == "RSHIFT" or
madcatzinc@13 172 keyPressed == "LCTRL" or
madcatzinc@13 173 keyPressed == "RCTRL" or
madcatzinc@13 174 keyPressed == "LALT" or
madcatzinc@13 175 keyPressed == "RALT" then
madcatzinc@13 176 return
madcatzinc@13 177 end
madcatzinc@13 178 if IsShiftKeyDown() then
madcatzinc@13 179 keyPressed = "SHIFT-"..keyPressed
madcatzinc@13 180 end
madcatzinc@13 181 if IsControlKeyDown() then
madcatzinc@13 182 keyPressed = "CTRL-"..keyPressed
madcatzinc@13 183 end
madcatzinc@13 184 if IsAltKeyDown() then
madcatzinc@13 185 keyPressed = "ALT-"..keyPressed
madcatzinc@13 186 end
madcatzinc@13 187 if keyPressed == "BUTTON1" or keyPressed == "BUTTON2" then
madcatzinc@13 188 return
madcatzinc@13 189 end
madcatzinc@13 190
madcatzinc@13 191 CyborgMMO_SetNewKeybind(keyPressed)
madcatzinc@1 192 end