Mercurial > wow > cyborg-mmo7
comparison CyborgMMO7.lua @ 21:c8b19bc87787
Simplified settings handling, and fixed a few minor bugs related to them.
| author | madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09 |
|---|---|
| date | Thu, 25 Apr 2013 01:30:26 +0000 |
| parents | 937be4664323 |
| children | 3b1c0b676583 |
comparison
equal
deleted
inserted
replaced
| 20:937be4664323 | 21:c8b19bc87787 |
|---|---|
| 24 end | 24 end |
| 25 | 25 |
| 26 local VarsLoaded = false | 26 local VarsLoaded = false |
| 27 local EnteredWorld = false | 27 local EnteredWorld = false |
| 28 local BindingsLoaded = false | 28 local BindingsLoaded = false |
| 29 local SettingsLoaded = false | |
| 29 local SaveName = GetRealmName().."_"..UnitName("player") | 30 local SaveName = GetRealmName().."_"..UnitName("player") |
| 30 local CyborgMMO_Settings = nil | 31 local Settings = nil |
| 31 | 32 |
| 32 | 33 |
| 33 function CyborgMMO_MiniMapButtonReposition(pos) | 34 function CyborgMMO_MiniMapButtonReposition(pos) |
| 34 CyborgMMO_MiniMapFrame:SetPoint("TOPLEFT", | 35 CyborgMMO_MiniMapFrame:SetPoint("TOPLEFT", |
| 35 "Minimap", | 36 "Minimap", |
| 129 | 130 |
| 130 CyborgMMO_SetupModeCallbacks(1) | 131 CyborgMMO_SetupModeCallbacks(1) |
| 131 CyborgMMO_SetupModeCallbacks(2) | 132 CyborgMMO_SetupModeCallbacks(2) |
| 132 CyborgMMO_SetupModeCallbacks(3) | 133 CyborgMMO_SetupModeCallbacks(3) |
| 133 | 134 |
| 134 | 135 Settings = data.Settings |
| 135 --Reload Slider values: | 136 if not Settings then |
| 136 if not data["Settings"] then | 137 Settings = {} |
| 137 data["Settings"] = {} | 138 Settings.Cyborg = 0.75 |
| 138 data["Settings"]["Cyborg"] = 0.75 | 139 Settings.Plugin = 0.75 |
| 139 data["Settings"]["Plugin"] = 0.75 | 140 Settings.MiniMapButton = true |
| 140 data["Settings"]["MiniMapButton"] = true | 141 Settings.CyborgButton = true |
| 141 data["Settings"]["CyborgButton"] = true | 142 data.Settings = Settings |
| 142 end | 143 end |
| 143 | 144 SettingsLoaded = true |
| 144 CyborgMMO_Settings = data["Settings"] | 145 |
| 145 | 146 -- Reload Slider values: |
| 146 CyborgMMO_OptionPageCyborgSizeSlider:SetValue(CyborgMMO_Settings["Cyborg"]) | 147 CyborgMMO_SetOpenButtonSize(Settings.Cyborg) |
| 147 CyborgMMO_SetOpenButtonSize(CyborgMMO_Settings["Cyborg"]) | 148 CyborgMMO_SetMainPageSize(Settings.Plugin) |
| 148 CyborgMMO_OptionPagePluginSizeSlider:SetValue(CyborgMMO_Settings["Plugin"]) | 149 |
| 149 CyborgMMO_SetMainPageSize(CyborgMMO_Settings["Plugin"]) | 150 CyborgMMO_SetMiniMapButton(Settings.MiniMapButton) |
| 150 | 151 CyborgMMO_SetCyborgHeadButton(Settings.CyborgButton) |
| 151 CyborgMMO_SetMiniMapButton(CyborgMMO_Settings["MiniMapButton"]) | |
| 152 CyborgMMO_SetCyborgHeadButton(CyborgMMO_Settings["CyborgButton"]) | |
| 153 | 152 |
| 154 local xmin,ymin = Minimap:GetLeft(),Minimap:GetBottom() | 153 local xmin,ymin = Minimap:GetLeft(),Minimap:GetBottom() |
| 155 CyborgMMO_MiniMapButtonReposition(math.deg(math.atan2(ymin, xmin))) | 154 CyborgMMO_MiniMapButtonReposition(math.deg(math.atan2(ymin, xmin))) |
| 156 -- Close the main window for now | 155 -- Close the main window for now |
| 157 CyborgMMO_Close() | 156 CyborgMMO_Close() |
| 187 CyborgMMO_MainPage:RegisterEvent("PLAYER_REGEN_DISABLED") | 186 CyborgMMO_MainPage:RegisterEvent("PLAYER_REGEN_DISABLED") |
| 188 end | 187 end |
| 189 | 188 |
| 190 function CyborgMMO_Close() | 189 function CyborgMMO_Close() |
| 191 CyborgMMO_MainPage:Hide() | 190 CyborgMMO_MainPage:Hide() |
| 192 if CyborgMMO_Settings["CyborgButton"] then | |
| 193 CyborgMMO_OpenButtonPage:Show() | |
| 194 end | |
| 195 end | 191 end |
| 196 | 192 |
| 197 function CyborgMMO_Open() | 193 function CyborgMMO_Open() |
| 198 CyborgMMO_MainPage:Show() | 194 CyborgMMO_MainPage:Show() |
| 199 CyborgMMO_RatQuickPage:Hide() | 195 CyborgMMO_RatQuickPage:Hide() |
| 200 if CyborgMMO_Settings["CyborgButton"] then | |
| 201 CyborgMMO_OpenButtonPage:Show() | |
| 202 end | |
| 203 end | 196 end |
| 204 | 197 |
| 205 function CyborgMMO_IsOpen() | 198 function CyborgMMO_IsOpen() |
| 206 if CyborgMMO_MainPage:IsVisible() == 1 then | 199 if CyborgMMO_MainPage:IsVisible() == 1 then |
| 207 return true | 200 return true |
| 239 debugframe:AddMessage(table.concat(t, ' ')) | 232 debugframe:AddMessage(table.concat(t, ' ')) |
| 240 end | 233 end |
| 241 end | 234 end |
| 242 | 235 |
| 243 function CyborgMMO_SetMainPageSize(percent) | 236 function CyborgMMO_SetMainPageSize(percent) |
| 244 if VarsLoaded and EnteredWorld then | 237 CyborgMMO_MainPage:SetScale(percent) |
| 245 CyborgMMO_MainPage:SetScale(percent) | 238 CyborgMMO_OptionPagePluginSizeSlider:SetValue(percent) |
| 246 CyborgMMO_Settings["Plugin"] = percent | 239 if BindingsLoaded then |
| 247 local data = CyborgMMO_GetSaveData() | 240 Settings.Plugin = percent |
| 248 data["Settings"] = CyborgMMO_Settings | |
| 249 CyborgMMO_OptionPagePluginSizeSlider:SetValue(percent) | |
| 250 end | 241 end |
| 251 end | 242 end |
| 252 | 243 |
| 253 function CyborgMMO_SetOpenButtonSize(percent) | 244 function CyborgMMO_SetOpenButtonSize(percent) |
| 254 if VarsLoaded and EnteredWorld then | 245 CyborgMMO_OpenButtonPage:SetScale(percent) |
| 255 CyborgMMO_OpenButtonPage:SetScale(percent) | 246 CyborgMMO_OptionPageCyborgSizeSlider:SetValue(percent) |
| 256 CyborgMMO_Settings["Cyborg"] = percent | 247 if SettingsLoaded then |
| 257 local data = CyborgMMO_GetSaveData() | 248 Settings.Cyborg = percent |
| 258 data["Settings"] = CyborgMMO_Settings | 249 end |
| 259 CyborgMMO_OptionPageCyborgSizeSlider:SetValue(percent) | 250 end |
| 260 end | 251 |
| 261 end | 252 function CyborgMMO_SetCyborgHeadButton(visible) |
| 262 | 253 if visible then |
| 263 function CyborgMMO_SetCyborgHeadButton(boolVal) | 254 CyborgMMO_OpenButtonPage:Show() |
| 264 CyborgMMO_Settings["CyborgButton"] = boolVal | |
| 265 CyborgMMO_OptionPageCyborgButton:SetChecked(boolVal) | |
| 266 if CyborgMMO_Settings["CyborgButton"] then | |
| 267 CyborgMMO_Close() | |
| 268 else | 255 else |
| 269 CyborgMMO_OpenButtonPage:Hide() | 256 CyborgMMO_OpenButtonPage:Hide() |
| 270 end | 257 end |
| 271 local data = CyborgMMO_GetSaveData() | 258 CyborgMMO_OptionPageCyborgButton:SetChecked(visible) |
| 272 data["Settings"] = CyborgMMO_Settings | 259 if SettingsLoaded then |
| 273 end | 260 Settings.CyborgButton = visible |
| 274 | 261 end |
| 275 function CyborgMMO_SetMiniMapButton(boolVal) | 262 end |
| 276 CyborgMMO_Settings["MiniMapButton"] = boolVal | 263 |
| 277 CyborgMMO_OptionPageMiniMapButton:SetChecked(boolVal) | 264 function CyborgMMO_SetMiniMapButton(visible) |
| 278 if CyborgMMO_Settings["MiniMapButton"] then | 265 if visible then |
| 279 CyborgMMO_MiniMapFrameButton:Show() | 266 CyborgMMO_MiniMapFrameButton:Show() |
| 280 else | 267 else |
| 281 CyborgMMO_MiniMapFrameButton:Hide() | 268 CyborgMMO_MiniMapFrameButton:Hide() |
| 282 end | 269 end |
| 283 local data = CyborgMMO_GetSaveData() | 270 CyborgMMO_OptionPageMiniMapButton:SetChecked(visible) |
| 284 data["Settings"] = CyborgMMO_Settings | 271 if SettingsLoaded then |
| 285 end | 272 Settings.MiniMapButton = visible |
| 286 | 273 end |
| 274 end | |
| 275 |
