Mercurial > wow > inventory
comparison Modules/Config.lua @ 242:03cd9d95e980
Added ZeroAuctions group import.
author | Zerotorescue |
---|---|
date | Sat, 19 Feb 2011 15:26:46 +0100 |
parents | 24e71ed0a422 |
children |
comparison
equal
deleted
inserted
replaced
241:65a9ef84d18f | 242:03cd9d95e980 |
---|---|
2070 order = 5, | 2070 order = 5, |
2071 type = "header", | 2071 type = "header", |
2072 name = "", | 2072 name = "", |
2073 hidden = function() return addon.db.profile.defaults.hideHelp; end, | 2073 hidden = function() return addon.db.profile.defaults.hideHelp; end, |
2074 }, | 2074 }, |
2075 localItemData = { | 2075 selectExportGroups = { |
2076 order = 9, | 2076 order = 9, |
2077 type = "multiselect", | 2077 type = "multiselect", |
2078 name = "Select groups", | 2078 name = "Select groups", |
2079 desc = "Select which groups should be included in the export.", | 2079 desc = "Select which groups should be included in the export.", |
2080 values = function() | 2080 values = function() |
2361 }, | 2361 }, |
2362 }; | 2362 }; |
2363 end | 2363 end |
2364 | 2364 |
2365 function mod:MakeGroupOptions() | 2365 function mod:MakeGroupOptions() |
2366 local selectedImportGroups; | |
2366 options.args.groups = { | 2367 options.args.groups = { |
2367 order = 1100, | 2368 order = 1100, |
2368 type = "group", | 2369 type = "group", |
2369 name = "Groups", | 2370 name = "Groups", |
2370 desc = "Change a group.", | 2371 desc = "Change a group.", |
2404 set = function(_, value) currentGroupType = value; end, | 2405 set = function(_, value) currentGroupType = value; end, |
2405 get = function() return currentGroupType; end, | 2406 get = function() return currentGroupType; end, |
2406 }, | 2407 }, |
2407 }, | 2408 }, |
2408 }, | 2409 }, |
2409 import = { | 2410 importExport = { |
2410 order = 20, | 2411 order = 20, |
2411 type = "group", | 2412 type = "group", |
2412 inline = true, | 2413 inline = true, |
2413 name = "Import a group", | 2414 name = "Import a group export", |
2414 args = { | 2415 args = { |
2416 help = { | |
2417 order = 5, | |
2418 type = "description", | |
2419 name = "If you have exported one or more groups (which can be done by clicking a group and opening the management tab or at the middle of the extra tab) you can instantly import them here. These groups will be added if no groups with the same name already exist.", | |
2420 hidden = function() return addon.db.profile.defaults.hideHelp; end, | |
2421 }, | |
2415 input = { | 2422 input = { |
2416 order = 10, | 2423 order = 10, |
2417 type = "input", | 2424 type = "input", |
2418 multiline = true, | 2425 multiline = true, |
2419 name = "Group data", | 2426 name = "Exported group data", |
2420 desc = "Paste the group data as provided by a group export. If you are trying to import multiple groups at the same time, make sure to use newlines to seperate them.", | 2427 desc = "Paste the group data as provided by a group export. If you are trying to import multiple groups at the same time, make sure to use newlines to seperate them.", |
2421 set = function(info, value) | 2428 set = function(info, value) |
2422 local data = { string.split("\n", value or "") }; | 2429 local data = { string.split("\n", value or "") }; |
2423 | 2430 |
2424 for _, current in pairs(data) do | 2431 for _, current in pairs(data) do |
2475 get = false, | 2482 get = false, |
2476 width = "full", | 2483 width = "full", |
2477 }, | 2484 }, |
2478 }, | 2485 }, |
2479 }, | 2486 }, |
2487 importFromOtherAddons = { | |
2488 order = 30, | |
2489 type = "group", | |
2490 inline = true, | |
2491 name = "Import groups from other addons", | |
2492 args = { | |
2493 selectImportGroups = { | |
2494 order = 10, | |
2495 type = "multiselect", | |
2496 name = "Select groups", | |
2497 desc = "Select which groups should be imported.", | |
2498 values = function() | |
2499 local temp = {}; | |
2500 temp["*InverseAll"] = "Inverse"; | |
2501 | |
2502 local Ace = LibStub("AceAddon-3.0", true); | |
2503 if Ace then | |
2504 local ZA = Ace:GetAddon("ZeroAuctions", true); | |
2505 | |
2506 if ZA then | |
2507 for groupName, contents in pairs(ZA.db.global.groups) do | |
2508 temp["ZeroAuctions$" .. groupName] = string.format("ZA: %s", groupName); | |
2509 end | |
2510 end | |
2511 | |
2512 local APM = Ace:GetAddon("AuctionProfitMaster", true); | |
2513 | |
2514 if APM then | |
2515 for groupName, contents in pairs(APM.db.global.groups) do | |
2516 temp["AuctionProfitMaster$" .. groupName] = string.format("APM: %s", groupName); | |
2517 end | |
2518 end | |
2519 end | |
2520 | |
2521 return temp; | |
2522 end, | |
2523 get = function(info, value) | |
2524 --local groupName = groupIdToName[info[2]]; | |
2525 --local optionName = info[#info]; | |
2526 | |
2527 return selectedImportGroups and selectedImportGroups[value]; | |
2528 end, | |
2529 set = function(info, name, value) | |
2530 --local groupName = groupIdToName[info[2]]; | |
2531 --local optionName = info[#info]; | |
2532 | |
2533 if not selectedImportGroups then | |
2534 selectedImportGroups = {}; | |
2535 end | |
2536 | |
2537 if name == "*InverseAll" then | |
2538 for groupName, _ in pairs(info.option.values()) do | |
2539 if selectedImportGroups and selectedImportGroups[groupName] then | |
2540 selectedImportGroups[groupName] = nil; | |
2541 else | |
2542 selectedImportGroups[groupName] = true; | |
2543 end | |
2544 end | |
2545 else | |
2546 if selectedImportGroups and selectedImportGroups[name] then | |
2547 selectedImportGroups[name] = nil; | |
2548 else | |
2549 selectedImportGroups[name] = true; | |
2550 end | |
2551 end | |
2552 end, | |
2553 }, | |
2554 import = { | |
2555 order = 20, | |
2556 type = "execute", | |
2557 name = "Import selected groups", | |
2558 desc = "Import the groups selected above.", | |
2559 func = function(info) | |
2560 -- Go through all selected groups | |
2561 for selection in pairs(selectedImportGroups) do | |
2562 local sourceAddon, groupName = string.match(selection, "^(%a+)\$(.+)$"); | |
2563 | |
2564 if sourceAddon == "ZeroAuctions" or sourceAddon == "AuctionProfitMaster" then | |
2565 -- ZeroAuctions/AuctionProfitMaster-group | |
2566 | |
2567 local ZA = LibStub("AceAddon-3.0"):GetAddon(sourceAddon); -- If it was in the list, we're sure the addon is enabled | |
2568 | |
2569 local temp = {}; | |
2570 | |
2571 do-- Set settings region | |
2572 local currentProfile = ZA.db.profile; | |
2573 if currentProfile then | |
2574 -- Set price threshold | |
2575 local threshold = currentProfile.threshold and currentProfile.threshold[groupName]; | |
2576 if threshold then | |
2577 -- Set price threshold | |
2578 temp.overridePriceThreshold = true; | |
2579 temp.priceThreshold = threshold; | |
2580 end | |
2581 | |
2582 -- Set minimum global stock, minimum local stock and restock target | |
2583 local postCap = currentProfile.postCap and currentProfile.postCap[groupName]; | |
2584 local perAuction = currentProfile.perAuction and currentProfile.perAuction[groupName]; | |
2585 if postCap and perAuction then | |
2586 -- Restock target | |
2587 temp.overrideRestockTarget = true; | |
2588 temp.restockTarget = (postCap * perAuction); | |
2589 | |
2590 -- Minimum global stock | |
2591 temp.overrideMinGlobalStock = true; | |
2592 temp.minGlobalStock = (postCap * perAuction); | |
2593 | |
2594 -- Minimum local stock | |
2595 temp.overrideMinLocalStock = true; | |
2596 temp.minLocalStock = perAuction; | |
2597 end | |
2598 end | |
2599 end | |
2600 | |
2601 local items = ZA.db.global.groups[groupName]; | |
2602 | |
2603 if not groupName or not items then | |
2604 addon:Print("The provided data is not supported.", addon.Colors.Red); | |
2605 elseif ValidateGroupName(nil, groupName) ~= true then | |
2606 addon:Print(("Aborting: A group named \"%s\" already exists."):format(groupName), addon.Colors.Red); | |
2607 else | |
2608 addon:Print(("Importing %s..."):format(groupName)); | |
2609 | |
2610 temp.items = {}; | |
2611 | |
2612 if items then | |
2613 -- Remove items that are already in another group | |
2614 for value, _ in pairs(items) do | |
2615 local textItemId = string.match(value, "^item:(%d+)$"); | |
2616 local itemId = tonumber(textItemId or ""); | |
2617 | |
2618 local itemData = addon.ItemData:New(itemId); | |
2619 | |
2620 if not itemId then | |
2621 addon:Print(("\"%s\" is not a number."):format(value), addon.Colors.Red); | |
2622 elseif itemData:InGroup() then | |
2623 addon:Print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red); | |
2624 else | |
2625 temp.items[itemId] = 0; | |
2626 end | |
2627 end | |
2628 end | |
2629 | |
2630 addon.db.profile.groups[groupName] = temp; | |
2631 end | |
2632 end | |
2633 end | |
2634 | |
2635 mod:FillGroupOptions(); | |
2636 end, | |
2637 }, | |
2638 }, | |
2639 }, | |
2480 }, | 2640 }, |
2481 }; | 2641 }; |
2482 end | 2642 end |
2483 | 2643 |
2484 function mod:FillGroupOptions() | 2644 function mod:FillGroupOptions() |