Mercurial > wow > libmoduledbshare-1-0
comparison LibModuleDBShare-1.0/LibModuleDBShare-1.0.lua @ 18:dacd01bf164f
Added profile callbacks.
Piggybacked on AceDBOptions' localization for "profiles"
| author | Andrew Knoll <andrewtknoll@gmail.com> |
|---|---|
| date | Thu, 14 Mar 2013 01:16:01 -0400 |
| parents | 4ed8d6827ef7 |
| children | ec910729e073 |
comparison
equal
deleted
inserted
replaced
| 17:4ed8d6827ef7 | 18:dacd01bf164f |
|---|---|
| 49 AceConfigDialog:AddToBlizOptions(groupName); | 49 AceConfigDialog:AddToBlizOptions(groupName); |
| 50 group.syncDBTable = {}; | 50 group.syncDBTable = {}; |
| 51 group.syncDB = AceDB:New(group.syncDBTable, nil, initialProfile); | 51 group.syncDB = AceDB:New(group.syncDBTable, nil, initialProfile); |
| 52 group.profileOptionsTable = AceDBOptions:GetOptionsTable(group.syncDB, false); | 52 group.profileOptionsTable = AceDBOptions:GetOptionsTable(group.syncDB, false); |
| 53 AceConfigRegistry:RegisterOptionsTable(groupName.."Profiles", group.profileOptionsTable); | 53 AceConfigRegistry:RegisterOptionsTable(groupName.."Profiles", group.profileOptionsTable); |
| 54 AceConfigDialog:AddToBlizOptions(groupName.."Profiles", "Profiles", groupName); -- need to figure out localization | 54 AceConfigDialog:AddToBlizOptions(groupName.."Profiles", group.profileOptionsTable.name, groupName); |
| 55 -- profile change callbacks | 55 group.members = {}; |
| 56 group.syncDB:RegisterCallback(group, "OnNewProfile", "OnNewProfile"); | |
| 57 group.syncDB:RegisterCallback(group, "OnProfileChanged", "OnProfileChanged"); | |
| 58 group.syncDB:RegisterCallback(group, "OnProfileDeleted", "OnProfileDeleted"); | |
| 59 group.syncDB:RegisterCallback(group, "OnProfileCopied", "OnProfileCopied"); | |
| 60 group.syncDB:RegisterCallback(group, "OnProfileReset", "OnProfileReset"); | |
| 56 for k, v in pairs(DBGroup) do | 61 for k, v in pairs(DBGroup) do |
| 57 group[k] = v; | 62 group[k] = v; |
| 58 end | 63 end |
| 59 return group; | 64 return group; |
| 60 end | 65 end |
| 74 -- @usage | 79 -- @usage |
| 75 -- myAddonDBGroup:AddDB(MyAddon.db) | 80 -- myAddonDBGroup:AddDB(MyAddon.db) |
| 76 function DBGroup:AddDB(db) | 81 function DBGroup:AddDB(db) |
| 77 | 82 |
| 78 end | 83 end |
| 84 | |
| 85 function DBGroup:OnNewProfile(db, profile) | |
| 86 print("New Profile"); | |
| 87 print(type(profile)); | |
| 88 print(tostring(profile)); | |
| 89 end | |
| 90 | |
| 91 function DBGroup:OnProfileChanged(db, profile) | |
| 92 print("Profile Changed"); | |
| 93 print(type(profile)); | |
| 94 print(tostring(profile)); | |
| 95 end | |
| 96 | |
| 97 function DBGroup:OnProfileDeleted(db, profile) | |
| 98 print("Profile Deleted"); | |
| 99 print(type(profile)); | |
| 100 print(tostring(profile)); | |
| 101 end | |
| 102 | |
| 103 function DBGroup:OnProfileCopied(db, profile) | |
| 104 print("Profile Copied"); | |
| 105 print(type(profile)); | |
| 106 print(tostring(profile)); | |
| 107 end | |
| 108 | |
| 109 function DBGroup:OnProfileReset(db) | |
| 110 print("Profile Reset"); | |
| 111 end |
