Mercurial > wow > ouroloot
comparison core.lua @ 4:05caaf17b3ca
Get history window in a working state again in prep for redoing orders.
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Sun, 24 Apr 2011 07:29:01 +0000 |
| parents | fe437e761ef8 |
| children | 7adbc59de8fe |
comparison
equal
deleted
inserted
replaced
| 3:2753b9763882 | 4:05caaf17b3ca |
|---|---|
| 343 if opts.register_slashloot then | 343 if opts.register_slashloot then |
| 344 SLASH_ACECONSOLE_OUROLOOT2 = "/loot" | 344 SLASH_ACECONSOLE_OUROLOOT2 = "/loot" |
| 345 end | 345 end |
| 346 | 346 |
| 347 self.history_all = self.history_all or OuroLootSV_hist or {} | 347 self.history_all = self.history_all or OuroLootSV_hist or {} |
| 348 local r = GetRealmName() | 348 local r = assert(GetRealmName()) |
| 349 self.history_all[r] = self:_prep_new_history_category (self.history_all[r], r) | 349 self.history_all[r] = self:_prep_new_history_category (self.history_all[r], r) |
| 350 self.history = self.history_all[r] | 350 self.history = self.history_all[r] |
| 351 OuroLootSV_hist = nil | |
| 351 | 352 |
| 352 _init(self) | 353 _init(self) |
| 353 self.OnInitialize = nil | 354 self.OnInitialize = nil |
| 354 end | 355 end |
| 355 | 356 |
| 1165 -- }, ...... | 1166 -- }, ...... |
| 1166 -- }, | 1167 -- }, |
| 1167 -- ["OtherRealm"] = ...... | 1168 -- ["OtherRealm"] = ...... |
| 1168 -- } | 1169 -- } |
| 1169 do | 1170 do |
| 1170 -- Builds the map of names to array indices. | 1171 -- Builds the map of names to array indices, using passed table or |
| 1172 -- self.history, and stores the result into its 'byname' field. Also | |
| 1173 -- called from the GUI code at least once. | |
| 1171 function addon:_build_history_names (opt_hist) | 1174 function addon:_build_history_names (opt_hist) |
| 1172 local hist = opt_hist or self.history | 1175 local hist = opt_hist or self.history |
| 1173 local m = {} | 1176 local m = {} |
| 1174 for i = 1, #hist do | 1177 for i = 1, #hist do |
| 1175 m[hist[i].name] = i | 1178 m[hist[i].name] = i |
| 1176 end | 1179 end |
| 1177 hist.byname = m | 1180 hist.byname = m |
| 1181 end | |
| 1182 | |
| 1183 -- Prepares and returns table to be used as self.history. | |
| 1184 function addon:_prep_new_history_category (prev_table, realmname) | |
| 1185 local t = prev_table or { | |
| 1186 --kind = 'realm', | |
| 1187 realm = realmname, | |
| 1188 } | |
| 1189 | |
| 1190 --[[ | |
| 1191 t.cols = setmetatable({ | |
| 1192 { value = realmname }, | |
| 1193 }, self.time_column1_used_mt) | |
| 1194 ]] | |
| 1195 | |
| 1196 if not t.byname then | |
| 1197 self:_build_history_names (t) | |
| 1198 end | |
| 1199 | |
| 1200 return t | |
| 1178 end | 1201 end |
| 1179 | 1202 |
| 1180 -- Maps a name to an array index, creating new tables if needed. Returns | 1203 -- Maps a name to an array index, creating new tables if needed. Returns |
| 1181 function addon:get_loot_history (name) | 1204 function addon:get_loot_history (name) |
| 1182 local i | 1205 local i |
| 1185 i = #self.history + 1 | 1208 i = #self.history + 1 |
| 1186 self.history[i] = { name=name } | 1209 self.history[i] = { name=name } |
| 1187 self.history.byname[name] = i | 1210 self.history.byname[name] = i |
| 1188 end | 1211 end |
| 1189 return self.history[i] | 1212 return self.history[i] |
| 1190 end | |
| 1191 | |
| 1192 -- Prepares and returns table to be used as self.history. | |
| 1193 function addon:_prep_new_history_category (prev_table, realmname) | |
| 1194 local t = prev_table or { | |
| 1195 --kind = 'realm', | |
| 1196 realm = realmname, | |
| 1197 } | |
| 1198 | |
| 1199 --[[ | |
| 1200 t.cols = setmetatable({ | |
| 1201 { value = realmname }, | |
| 1202 }, self.time_column1_used_mt) | |
| 1203 ]] | |
| 1204 | |
| 1205 if not t.byname then | |
| 1206 self:_build_history_names (t) | |
| 1207 end | |
| 1208 | |
| 1209 return t | |
| 1210 end | 1213 end |
| 1211 | 1214 |
| 1212 function addon:_addHistoryEntry (lootindex) | 1215 function addon:_addHistoryEntry (lootindex) |
| 1213 local e = g_loot[lootindex] | 1216 local e = g_loot[lootindex] |
| 1214 local h = self:get_loot_history(e.person) | 1217 local h = self:get_loot_history(e.person) |
