Mercurial > wow > reaction
annotate modules/VehicleExit.lua @ 234:0e20f65375d5
Reworked button creation to not use goofy event driven semantics.
author | Flick |
---|---|
date | Tue, 22 Mar 2011 17:05:51 -0700 |
parents | c4b134512c50 |
children |
rev | line source |
---|---|
flickerstreak@159 | 1 --[[ |
Flick@234 | 2 ReAction Vehicle Exit button options module |
flickerstreak@159 | 3 --]] |
flickerstreak@159 | 4 |
flickerstreak@159 | 5 -- local imports |
flickerstreak@175 | 6 local addonName, addonTable = ... |
flickerstreak@175 | 7 local ReAction = addonTable.ReAction |
flickerstreak@159 | 8 local L = ReAction.L |
flickerstreak@159 | 9 |
flickerstreak@159 | 10 -- module declaration |
flickerstreak@159 | 11 local moduleID = "VehicleExit" |
flickerstreak@159 | 12 local module = ReAction:NewModule( moduleID ) |
flickerstreak@159 | 13 |
flickerstreak@159 | 14 -- Button class |
flickerstreak@159 | 15 local Button = ReAction.Button.VehicleExit |
flickerstreak@159 | 16 |
flickerstreak@159 | 17 -- module methods |
flickerstreak@159 | 18 function module:OnInitialize() |
flickerstreak@159 | 19 self.registered = { } |
flickerstreak@159 | 20 self.buttons = { } |
flickerstreak@159 | 21 |
flickerstreak@159 | 22 ReAction:RegisterBarOptionGenerator(self, "GetBarOptions") |
flickerstreak@159 | 23 end |
flickerstreak@159 | 24 |
flickerstreak@159 | 25 ---- Options ---- |
flickerstreak@159 | 26 local Handler = { } |
flickerstreak@159 | 27 local meta = { __index = Handler } |
flickerstreak@159 | 28 |
flickerstreak@159 | 29 function Handler:New(bar) |
flickerstreak@159 | 30 return setmetatable( |
flickerstreak@159 | 31 { |
flickerstreak@159 | 32 bar = bar |
flickerstreak@159 | 33 }, meta) |
flickerstreak@159 | 34 end |
flickerstreak@159 | 35 |
flickerstreak@159 | 36 function Handler:GetConfig() |
flickerstreak@222 | 37 return self.bar:GetConfig() |
flickerstreak@159 | 38 end |
flickerstreak@159 | 39 |
flickerstreak@159 | 40 function Handler:GetPassengerOnly() |
flickerstreak@159 | 41 return not self:GetConfig().withControls |
flickerstreak@159 | 42 end |
flickerstreak@159 | 43 |
flickerstreak@159 | 44 function Handler:SetPassengerOnly(info, value) |
flickerstreak@159 | 45 self:GetConfig().withControls = not value |
Flick@234 | 46 Button:UpdateRegistration(self.bar) |
flickerstreak@159 | 47 end |
flickerstreak@159 | 48 |
flickerstreak@159 | 49 |
flickerstreak@159 | 50 function module:GetBarOptions(bar) |
flickerstreak@159 | 51 if bar.config.type == moduleID then |
flickerstreak@159 | 52 return { |
flickerstreak@159 | 53 type = "group", |
flickerstreak@159 | 54 name = L["Exit Vehicle"], |
flickerstreak@159 | 55 handler = Handler:New(bar), |
flickerstreak@159 | 56 args = { |
flickerstreak@159 | 57 passengerOnly = { |
flickerstreak@159 | 58 name = L["Show only when passenger"], |
flickerstreak@159 | 59 desc = L["Only show the button when riding as a passenger in a vehicle (no vehicle controls)"], |
flickerstreak@159 | 60 order = 2, |
flickerstreak@159 | 61 width = "double", |
flickerstreak@159 | 62 type = "toggle", |
flickerstreak@159 | 63 get = "GetPassengerOnly", |
flickerstreak@159 | 64 set = "SetPassengerOnly", |
flickerstreak@159 | 65 }, |
flickerstreak@159 | 66 } |
flickerstreak@159 | 67 } |
flickerstreak@159 | 68 end |
flickerstreak@159 | 69 end |
flickerstreak@159 | 70 |
flickerstreak@159 | 71 |