annotate OptionView.lua @ 34:6ce173840e68

Reworked the whole "wow object" system: - Only save what is strictly necessary. - Save appropriate persistent information for all objects (like spellIDs instead of spellBook+spellIndex). - Fixed Battle Pets objects (non-combat pets in pre-MoP). - Fixed item objects. - Cleaned and simplified most objects implementation. - Moved the settings and button profile to the root of the saved data, rather than in a per-character sub-table (that data is already tagged as saved per character). This should fix most issues with objects changing without user interaction on diverse occasions. Old profiles are not converted to the new system. This will come soon. Some issues persist due to the asynchronous loading of some informations: - Pet icons are never properly loaded from saved data. - Items are not properly loaded the first time the UI is started (a "/reload ui" or disconnect/connect cycle fixes this problem).
author madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09
date Thu, 25 Apr 2013 01:31:31 +0000
parents e8a004a4177b
children 72adde883f46
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@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@27 41 CyborgMMO_BindingFrameButtonName:SetText(buttonStr.." Mode "..mode)
madcatzinc@29 42 CyborgMMO_BindingFrameKey:SetText(CyborgMMO_StringTable["CyborgMMO_CurrentBinding"].." "..CyborgMMO_ProfileKeyBindings[CyborgMMO_GetButtonIndex(lastButton)])
madcatzinc@4 43 CyborgMMO_BindingFrame:Show()
madcatzinc@1 44 end
madcatzinc@1 45
madcatzinc@26 46 function CyborgMMO_SetBindingButtonText(name)
madcatzinc@29 47 local binding = CyborgMMO_ProfileKeyBindings[CyborgMMO_GetButtonIndex(name)]
madcatzinc@1 48 getglobal(name):SetText(binding)
madcatzinc@1 49 end
madcatzinc@1 50
madcatzinc@4 51 function CyborgMMO_GetButtonIndex(name)
madcatzinc@22 52 local row,mode = name:match('Row(.)Mode(.)')
madcatzinc@22 53 row = tonumber(row, 16)
madcatzinc@22 54 mode = tonumber(mode)
madcatzinc@1 55 local modeStr = string.sub(name, mode +1,mode+2)
madcatzinc@1 56 local rowStr = string.sub(name, row-1,row-1)
madcatzinc@22 57 return (mode-1) * 13 + row
madcatzinc@1 58 end
madcatzinc@1 59
madcatzinc@5 60 function CyborgMMO_ShowProfileTooltip(self)
madcatzinc@13 61 local red,green,blue = self:GetVertexColor()
madcatzinc@13 62 if red == 0 and green == 0 and blue == 0 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