Mercurial > wow > wowdb-profiler
comparison Comments.lua @ 268:b6036060c096
Cleanup.
| author | James D. Callahan III <jcallahan@curse.com> |
|---|---|
| date | Wed, 20 Mar 2013 13:02:29 -0500 |
| parents | f6f1d49b2a43 |
| children | 463b0f117b1b |
comparison
equal
deleted
inserted
replaced
| 267:f6f1d49b2a43 | 268:b6036060c096 |
|---|---|
| 290 _G.HideUIPanel(panel) | 290 _G.HideUIPanel(panel) |
| 291 end) | 291 end) |
| 292 panel.submitButton = submit | 292 panel.submitButton = submit |
| 293 end | 293 end |
| 294 | 294 |
| 295 local function NewComment(type_name, label, id) | |
| 296 comment_subject.id = id | |
| 297 comment_subject.label = label | |
| 298 comment_subject.type_name = type_name | |
| 299 | |
| 300 comment_frame.subject_name:SetText(label) | |
| 301 comment_frame.subject_data:SetFormattedText("(%s #%d)", type_name, id) | |
| 302 comment_frame.scroll_frame.edit_box:SetText("") | |
| 303 _G.ShowUIPanel(comment_frame) | |
| 304 end | |
| 305 | |
| 295 local function CreateUnitComment(unit_id) | 306 local function CreateUnitComment(unit_id) |
| 296 if not _G.UnitExists(unit_id) then | 307 if not _G.UnitExists(unit_id) then |
| 297 WDP:Printf("Unit '%s' does not exist.", unit_id) | 308 WDP:Printf("Unit '%s' does not exist.", unit_id) |
| 298 return | 309 return |
| 299 end | 310 end |
| 303 WDP:Printf("Unable to determine unit from '%s'", unit_id) | 314 WDP:Printf("Unable to determine unit from '%s'", unit_id) |
| 304 return | 315 return |
| 305 end | 316 end |
| 306 local type_name = private.UNIT_TYPE_NAMES[unit_type + 1] | 317 local type_name = private.UNIT_TYPE_NAMES[unit_type + 1] |
| 307 local unit_name = _G.UnitName(unit_id) | 318 local unit_name = _G.UnitName(unit_id) |
| 308 comment_subject.type_name = type_name | 319 NewComment(type_name, unit_name, unit_idnum) |
| 309 comment_subject.id = unit_idnum | |
| 310 comment_subject.label = unit_name | |
| 311 | |
| 312 comment_frame.subject_name:SetText(unit_name) | |
| 313 comment_frame.subject_data:SetFormattedText("(%s #%d)", type_name, unit_idnum) | |
| 314 comment_frame.scroll_frame.edit_box:SetText("") | |
| 315 _G.ShowUIPanel(comment_frame) | |
| 316 end | 320 end |
| 317 | 321 |
| 318 local DATA_TYPE_MAPPING = { | 322 local DATA_TYPE_MAPPING = { |
| 319 merchant = "ITEM", | 323 merchant = "ITEM", |
| 320 } | 324 } |
| 321 | 325 |
| 322 local CURSOR_DATA_FUNCS = { | 326 local CreateCursorComment |
| 323 item = function(data_type, data, data_subtype) | 327 do |
| 324 local item_name = _G.GetItemInfo(data) | 328 local CURSOR_DATA_FUNCS = { |
| 325 comment_subject.type_name = data_type | 329 item = function(type_name, id_num, data_subtype) |
| 326 comment_subject.id = data | 330 local item_name = _G.GetItemInfo(id_num) |
| 327 comment_subject.label = item_name | 331 NewComment(type_name, item_name, id_num) |
| 328 | 332 end, |
| 329 comment_frame.subject_name:SetText(item_name) | 333 merchant = function(type_name, item_index) |
| 330 comment_frame.subject_data:SetFormattedText("(%s #%d)", data_type, data) | 334 local item_link = _G.GetMerchantItemLink(item_index) |
| 331 end, | 335 local item_name = _G.GetItemInfo(item_link) |
| 332 merchant = function(data_type, data) | 336 NewComment(type_name, item_name, ItemLinkToID(item_link)) |
| 333 local item_link = _G.GetMerchantItemLink(data) | 337 end, |
| 334 local item_name = _G.GetItemInfo(item_link) | 338 spell = function(type_name, data, data_subtype, spell_id) |
| 335 local item_id = ItemLinkToID(item_link) | 339 local spell_name = _G.GetSpellInfo(spell_id) |
| 336 comment_subject.type_name = data_type | 340 NewComment(type_name, spell_name, spell_id) |
| 337 comment_subject.id = item_id | 341 end, |
| 338 comment_subject.label = item_name | 342 } |
| 339 | 343 |
| 340 comment_frame.subject_name:SetText(item_name) | 344 function CreateCursorComment() |
| 341 comment_frame.subject_data:SetFormattedText("(%s #%d)", data_type, item_id) | 345 local data_type, data, data_subtype, subdata = _G.GetCursorInfo() |
| 342 end, | 346 |
| 343 spell = function(data_type, data, data_subtype, subdata) | 347 if not CURSOR_DATA_FUNCS[data_type] then |
| 344 local spell_name = _G.GetSpellInfo(subdata) | 348 WDP:Print("Unable to determine comment subject from cursor.") |
| 345 comment_subject.type_name = data_type | 349 return |
| 346 comment_subject.id = subdata | 350 end |
| 347 comment_subject.label = spell_name | 351 CURSOR_DATA_FUNCS[data_type](DATA_TYPE_MAPPING[data_type] or data_type:upper(), data, data_subtype, subdata) |
| 348 | 352 end |
| 349 comment_frame.subject_name:SetText(spell_name) | |
| 350 comment_frame.subject_data:SetFormattedText("(%s #%d)", data_type, subdata) | |
| 351 end, | |
| 352 } | |
| 353 | |
| 354 local function CreateCursorComment() | |
| 355 local data_type, data, data_subtype, subdata = _G.GetCursorInfo() | |
| 356 | |
| 357 if not CURSOR_DATA_FUNCS[data_type] then | |
| 358 WDP:Print("Unable to determine comment subject from cursor.") | |
| 359 return | |
| 360 end | |
| 361 CURSOR_DATA_FUNCS[data_type](DATA_TYPE_MAPPING[data_type] or data_type:upper(), data, data_subtype, subdata) | |
| 362 comment_frame.scroll_frame.edit_box:SetText("") | |
| 363 _G.ShowUIPanel(comment_frame) | |
| 364 end | 353 end |
| 365 | 354 |
| 366 local function CreateQuestComment() | 355 local function CreateQuestComment() |
| 367 local index = _G.GetQuestLogSelection() | 356 local index = _G.GetQuestLogSelection() |
| 368 | 357 |
| 374 | 363 |
| 375 if is_header then | 364 if is_header then |
| 376 WDP:Print("You must select a quest from the Quest frame.") | 365 WDP:Print("You must select a quest from the Quest frame.") |
| 377 return | 366 return |
| 378 end | 367 end |
| 379 comment_subject.type_name = "QUEST" | 368 NewComment("QUEST", title, idnum) |
| 380 comment_subject.id = idnum | |
| 381 comment_subject.label = title | |
| 382 | |
| 383 comment_frame.subject_name:SetText(title) | |
| 384 comment_frame.subject_data:SetFormattedText("(%s #%d)", "QUEST", idnum) | |
| 385 comment_frame.scroll_frame.edit_box:SetText("") | |
| 386 _G.ShowUIPanel(comment_frame) | |
| 387 end | 369 end |
| 388 | 370 |
| 389 local function CreateAchievementComment() | 371 local function CreateAchievementComment() |
| 390 if not _G.AchievementFrame or not _G.AchievementFrameAchievements.selection then | 372 if not _G.AchievementFrame or not _G.AchievementFrameAchievements.selection then |
| 391 WDP:Print("You must select an achievement from the Achievement frame.") | 373 WDP:Print("You must select an achievement from the Achievement frame.") |
| 392 return | 374 return |
| 393 end | 375 end |
| 394 | 376 |
| 395 for _, button in next, _G.AchievementFrameAchievementsContainer.buttons do | 377 for _, button in next, _G.AchievementFrameAchievementsContainer.buttons do |
| 396 if button.selected then | 378 if button.selected then |
| 397 local title = button.label:GetText() | 379 NewComment("ACHIEVEMENT", button.label:GetText(), button.id) |
| 398 | |
| 399 comment_subject.type_name = "ACHIEVEMENT" | |
| 400 comment_subject.id = button.id | |
| 401 comment_subject.label = title | |
| 402 | |
| 403 comment_frame.subject_name:SetText(title) | |
| 404 comment_frame.subject_data:SetFormattedText("(%s #%d)", "ACHIEVEMENT", button.id) | |
| 405 comment_frame.scroll_frame.edit_box:SetText("") | |
| 406 _G.ShowUIPanel(comment_frame) | |
| 407 break | 380 break |
| 408 end | 381 end |
| 409 end | 382 end |
| 410 end | 383 end |
| 411 | 384 |
