Mercurial > wow > reaction
comparison ReAction.lua @ 127:29dacbecdb52
Fixed handling for making new bars with the same name
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Wed, 04 Mar 2009 21:19:32 +0000 |
| parents | a2d2f23137c8 |
| children | 8cc187143acd |
comparison
equal
deleted
inserted
replaced
| 126:6a4b4d3c5fad | 127:29dacbecdb52 |
|---|---|
| 304 -- (1) ReAction:CreateBar(name, [cfgTable]) | 304 -- (1) ReAction:CreateBar(name, [cfgTable]) |
| 305 -- (2) ReAction:CreateBar(name, "barType", [nRows], [nCols], [btnSize], [btnSpacing]) | 305 -- (2) ReAction:CreateBar(name, "barType", [nRows], [nCols], [btnSize], [btnSpacing]) |
| 306 function ReAction:CreateBar(name, config, ...) | 306 function ReAction:CreateBar(name, config, ...) |
| 307 local profile = self.db.profile | 307 local profile = self.db.profile |
| 308 | 308 |
| 309 if not name then | 309 if name then |
| 310 if bars[name] then | |
| 311 self:UserError(format(L["ReAction: name '%s' already in use"],name)) | |
| 312 return nil | |
| 313 end | |
| 314 else | |
| 310 local prefix = L["Bar "] | 315 local prefix = L["Bar "] |
| 311 local i = 1 | 316 local i = 1 |
| 312 repeat | 317 repeat |
| 313 name = prefix..i | 318 name = prefix..i |
| 314 i = i + 1 | 319 i = i + 1 |
| 369 local bar, name = SelectBar(x) | 374 local bar, name = SelectBar(x) |
| 370 if type(newname) ~= "string" then | 375 if type(newname) ~= "string" then |
| 371 error("ReAction:RenameBar() - second argument must be a string") | 376 error("ReAction:RenameBar() - second argument must be a string") |
| 372 end | 377 end |
| 373 if bar and name and #newname > 0 then | 378 if bar and name and #newname > 0 then |
| 379 if newname == name then | |
| 380 return | |
| 381 end | |
| 374 if bars[newname] then | 382 if bars[newname] then |
| 375 self:UserError(("%s ('%s')"):format(L["ReAction: name already in use"],newname)) | 383 self:UserError(format(L["ReAction: name '%s' already in use"],newname)) |
| 376 else | 384 else |
| 377 bars[newname], bars[name] = bars[name], nil | 385 bars[newname], bars[name] = bars[name], nil |
| 378 bar:SetName(newname or "") | 386 bar:SetName(newname or "") |
| 379 local cfg = self.db.profile.bars | 387 local cfg = self.db.profile.bars |
| 380 cfg[newname], cfg[name] = cfg[name], nil | 388 cfg[newname], cfg[name] = cfg[name], nil |
