Thread Tools Display Modes
10-23-10, 12:04 PM   #1
barbol12
A Cyclonian
 
barbol12's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 42
WTF -->Lua

hello guys, need some help...

i am trying to make it so i can take my saved information, from WTF files for addons, and put them into a Lua file, so that when people DL my interface, they dont need to do the WTF folder stuff. and when they login, to simply press a button to load the addons...

but i seem to have a complication, taking the stuff from the WTF folders into the Lua folder, can someone help me, to know what exactly i need to transfer....
  Reply With Quote
10-23-10, 12:24 PM   #2
Nillerr
A Fallenroot Satyr
 
Nillerr's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2010
Posts: 22
I haven't tried this myself, but there should be a way to "tap into" the database of the different AddOns, allowing you to install your own data on the first load. The way I figured it would be something like:
Code:
local AddonToTapInto = LibStub("AceAddon-3.0"):GetAddon("AddonToTapInto")
AddonToTapInto.db.profile = MyWTFTable
I have no idea if this would work just like that, and I'd imagine it would require you to add every Addon of your UI as dependencies for your "UI Installer Addon".

This of course, assumes the Addon is an Ace3 Addon.
  Reply With Quote
10-23-10, 04:18 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
You can tell your UI addon to load after the other addons it uses by listing them as dependencies in your TOC file. meanwhile, you can take a copy of all the SavedVariable files and include them in your addon (they are just plain Lua files). Even so, there's no guarantee that this method would work since there's no telling what each addon does to their saved info in the form of caching the global pointer.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
10-23-10, 04:52 PM   #4
Nillerr
A Fallenroot Satyr
 
Nillerr's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2010
Posts: 22
Instead of adding the dependencies, I think you could start loading the data at the PLAYER_LOGIN event, I don't know though.

But as the above said, your Loader or whatever, would have to be manually adapted to include every Addons database and/or time of loading. Also, after the installation, a ReloadUI should be forced to force the user to save the new data to the various Addons databases.

This is only a one-time task though, so it shouldn't be that much of a problem.
You might also want to make sure that the Loader is disabled afterwards, as having it enabled will only force database updates that shouldn't be required at all.

At the moment, I am looking into ways of creating a Library for this sort of thing, if I come out successful, I'll make sure to provide a good piece of documentation.

Last edited by Nillerr : 10-23-10 at 04:56 PM.
  Reply With Quote
10-24-10, 09:58 AM   #5
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
this is an example of my UI taking over the default Macaroon setup. Of course i cut it a bit short since the whole thing wont fit here but the top part is whats important. You need to find out what the default settings table is called by the addon your taking over. for macaroon it was macaroonSavedState. The first two lines make sure that my UI only does this the first time Macaroon and GrimUI run together then it returns full control to Macaroon. Exactly how this all works is partly dependent on the addon your taking over and how it was coded. That whole Ace hook thing that was mentioned above would require both addons to be using the ace library and still do not think it would work like that.

The lua inside the WTF's are tables... the data inside of them has to be used as such. Everything after MacaroonSavedState is what you would find in the Macaroon WTF.

Code:
local MacTakeOver = CreateFrame("Frame", "MacTakeOver", UIParent)


MacTakeOver:RegisterEvent("ADDON_LOADED")

MacTakeOver:SetScript("OnEvent", function() 
    if addon.settings.chatInitialized == true then
        addon.settings.macaroonInitialized = true
    end
    if Macaroon and addon.settings.macaroonInitialized == false then
        addon.settings.macaroonInitialized = true
        MacaroonSavedState = {
    ["cooldownAlpha"] = 1,
    ["bagOffsetX"] = 0,
    ["useShared"] = false,
    ["bagOffsetY"] = 70,
    ["timerLimit"] = 4,
    ["firstRun"] = true,
    ["registerForClicks"] = "AnyUp",
    ["currSpec"] = 1,
    ["buttonRadius"] = 87.5,
    ["bars"] = {
        {
            {
                ["arcLength"] = 360,
                ["prowl"] = false,
                ["spellGlow"] = true,
                ["hotKeys"] = "",
                ["copyDrag"] = false,
                ["tooltips"] = true,
                ["customRange"] = false,
                ["hotKeyText"] = "",
                ["arcStart"] = 90,
                ["snapToPoint"] = false,
                ["buttonList"] = {
                    ["homestate"] = "1;2;3;4;5;6;7;8;9;10",
                },
                ["target"] = false,
                ["snapTo"] = false,
                ["snapToFrame"] = false,
                ["stealth"] = false,
                ["origID"] = 1,
                ["shape"] = 1,
                ["barLockShift"] = false,
                ["reaction"] = false,
                ["ctrl"] = false,
                ["snapToPad"] = 0,
                ["hidden"] = false,
                ["shift"] = false,
                ["y"] = 116.9545311955373,
                ["x"] = 248.1222926662736,
                ["name"] = "MainBar1",
                ["homestate"] = true,
                ["padH"] = 0,
                ["barStrata"] = "MEDIUM",
                ["laststate"] = "homestate",
                ["alpha"] = 1,
                ["alt"] = false,
                ["dualSpec"] = false,
                ["point"] = "BOTTOM",
                ["fishing"] = false,
                ["scale"] = 0.7999999999999998,
                ["companion"] = false,
                ["currentstate"] = "homestate",
                ["barLink"] = false,
                ["tooltipsCombat"] = false,
                ["showstates"] = false,
                ["columns"] = false,
                ["autoHide"] = false,
                ["barLockAlt"] = false,
                ["vehicle"] = false,
                ["hotKeysShown"] = true,
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 10-24-10 at 10:01 AM.
  Reply With Quote
10-24-10, 11:45 AM   #6
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
Actually when you open a .lua file in the savedvariables folder you notice that data is stored like SOMETHING = {} so you can basically make a installer addon to (once) set that variable to a custom value (i.e.) your own addon settings.

Not easy to explain really, hmm.
  Reply With Quote
03-06-11, 09:06 AM   #7
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Vladinator View Post
Actually when you open a .lua file in the savedvariables folder you notice that data is stored like SOMETHING = {} so you can basically make a installer addon to (once) set that variable to a custom value (i.e.) your own addon settings.

Not easy to explain really, hmm.
This is true. Also note more often then not to get the addon to register those settings it will require a reload on first install. Unless you find the function in the addon that loads its saved vars and run it in your addon after it sets the table settings. This is only possible if the addon you took over made the function that sets everything up, according to the saved var, a global.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 03-06-11 at 09:09 AM.
  Reply With Quote
03-06-11, 10:39 AM   #8
Aprikot
A Frostmaul Preserver
 
Aprikot's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 284
There is an easy to follow config file included in cleanUI (..\@cleanConfig\@cleanConfig.lua). Lines 42-134 create & load an MSBT profile (a saved variables-like table). The popup dialog code at the bottom was also helpful to me:

lua Code:
  1. local function SimplueUIConfig()
  2.     -- Setup Basic InGame settings
  3.     SetCVar("buffDurations", 1)
  4.     SetCVar("screenshotQuality", 10)
  5.     SetCVar("cameraDistanceMax", 50)
  6.     SetCVar("cameraDistanceMaxFactor", 3.4)
  7.     SetCVar("consolidateBuffs", 0)
  8.     SetCVar("ffxDeath", 0)
  9.     SetCVar("chatMouseScroll", 1)
  10.    
  11.     -- Position and size the frame
  12.     ChatFrame1:ClearAllPoints()
  13.     ChatFrame1:SetPoint("BOTTOMLEFT",UIParent, 20, 20)
  14.     ChatFrame1:SetWidth(450)
  15.     ChatFrame1:SetHeight(118)
  16.     FCF_SavePositionAndDimensions(ChatFrame1)
  17.     FCF_SetLocked(ChatFrame1, 1)
  18.    
  19.     local channels = {
  20.         "SAY",
  21.         "EMOTE",
  22.         "YELL",
  23.         "GUILD",
  24.         "GUILD_OFFICER",
  25.         "GUILD_ACHIEVEMENT",
  26.         "ACHIEVEMENT",
  27.         "WHISPER",
  28.         "PARTY",
  29.         "RAID",
  30.         "RAID_LEADER",
  31.         "RAID_WARNING",
  32.         "BATTLEGROUND",
  33.         "BATTLEGROUND_LEADER",
  34.         "CHANNEL1",
  35.         "CHANNEL2",
  36.     }
  37.    
  38.     for i, v in ipairs(channels) do
  39.         ToggleChatColorNamesByClassGroup(true, v)
  40.     end
  41.    
  42.     if IsAddOnLoaded("MikScrollingBattleText") then
  43.         -- Setup MSBT
  44.         MikSBT.Profiles.savedVariables.profiles["Clean"] = {
  45.             ["normalOutlineIndex"] = 2,
  46.             ["exclusiveSkillsDisabled"] = true,
  47.             ["glancing"] = {
  48.                 ["disabled"] = true,
  49.             },
  50.             ["crushing"] = {
  51.                 ["disabled"] = true,
  52.             },
  53.             ["hideFullOverheals"] = true,
  54.             ["hideSkills"] = true,
  55.             ["regenAbilitiesDisabled"] = true,
  56.             ["triggers"] = {
  57.                 ["Custom1"] = {
  58.                     ["message"] = "Bloodlust!",
  59.                     ["colorB"] = 0,
  60.                     ["colorR"] = 0,
  61.                     ["alwaysSticky"] = true,
  62.                     ["scrollArea"] = "Static",
  63.                     ["fontSize"] = 26,
  64.                     ["mainEvents"] = "SPELL_AURA_APPLIED{recipientAffiliation;;eq;;4026531840;;skillName;;eq;;Bloodlust}",
  65.                 },
  66.             },
  67.             ["critFontName"] = "Skurri",
  68.             ["critOutlineIndex"] = 2,
  69.             ["soundsDisabled"] = true,
  70.             ["textShadowingDisabled"] = true,
  71.             ["hideNames"] = true,
  72.             ["skillIconsDisabled"] = true,
  73.             ["events"] = {
  74.                 ["NOTIFICATION_COMBAT_ENTER"] = {
  75.                     ["scrollArea"] = "Static",
  76.                 },
  77.                 ["NOTIFICATION_COMBAT_LEAVE"] = {
  78.                     ["scrollArea"] = "Static",
  79.                 },
  80.                 ["NOTIFICATION_CP_FULL"] = {
  81.                     ["message"] = "5 CP - Let it Rip!",
  82.                     ["scrollArea"] = "Static",
  83.                 },
  84.                 ["NOTIFICATION_EXTRA_ATTACK"] = {
  85.                     ["disabled"] = true,
  86.                 },
  87.                 ["NOTIFICATION_CP_GAIN"] = {
  88.                     ["alwaysSticky"] = true,
  89.                     ["scrollArea"] = "Static",
  90.                 },
  91.             },
  92.             ["scrollAreas"] = {
  93.                 ["Notification"] = {
  94.                     ["disabled"] = true,
  95.                 },
  96.                 ["Static"] = {
  97.                     ["critFontSize"] = 28,
  98.                     ["scrollHeight"] = 200,
  99.                     ["offsetY"] = -165,
  100.                     ["direction"] = "Up",
  101.                     ["normalFontSize"] = 20,
  102.                 },
  103.                 ["Incoming"] = {
  104.                     ["direction"] = "Up",
  105.                     ["stickyBehavior"] = "Normal",
  106.                     ["stickyTextAlignIndex"] = 2,
  107.                     ["scrollWidth"] = 300,
  108.                     ["offsetX"] = -406,
  109.                     ["textAlignIndex"] = 1,
  110.                     ["behavior"] = "MSBT_NORMAL",
  111.                     ["offsetY"] = -165,
  112.                     ["animationStyle"] = "Straight",
  113.                     ["scrollHeight"] = 200,
  114.                 },
  115.                 ["Outgoing"] = {
  116.                     ["stickyTextAlignIndex"] = 2,
  117.                     ["behavior"] = "MSBT_NORMAL",
  118.                     ["skillIconsDisabled"] = true,
  119.                     ["stickyBehavior"] = "Normal",
  120.                     ["scrollHeight"] = 200,
  121.                     ["offsetX"] = 106,
  122.                     ["animationStyle"] = "Straight",
  123.                     ["direction"] = "Up",
  124.                     ["offsetY"] = -165,
  125.                     ["textAlignIndex"] = 3,
  126.                     ["scrollWidth"] = 300,
  127.                 },
  128.             },
  129.             ["alwaysShowQuestItems"] = false,
  130.             ["normalFontName"] = "Skurri",
  131.             ["creationVersion"] = MikSBT.VERSION .. "." .. MikSBT.SVN_REVISION,
  132.         }
  133.         MikSBT.Profiles.SelectProfile("Clean")
  134.     end
  135.    
  136.     -- Ask if they want to reload the UI
  137.     StaticPopup_Show("RELOAD_UI")
  138.     DisableAddOn("@cleanConfig")
  139. end
  140.  
  141. -- Create confirmation popup
  142. StaticPopupDialogs["CONFIGURE_UI"] = {
  143.     text = "Would you like to configure CleanUI now?",
  144.     button1 = YES,
  145.     button2 = NO,
  146.     OnAccept = SimplueUIConfig,
  147.     timeout = 0,
  148.     whileDead = 1,
  149.     hideOnEscape = 0,
  150.     exclusive = true
  151. }
  152.  
  153. -- Create reload confirmation popup
  154. StaticPopupDialogs["RELOAD_UI"] = {
  155.     text = "CleanUI has been sucessfully configured!\n Would you like to reload the Interface now?",
  156.     button1 = YES,
  157.     button2 = NO,
  158.     OnAccept = ReloadUI,
  159.     timeout = 0,
  160.     whileDead = 1,
  161.     hideOnEscape = 0,
  162.     exclusive = true
  163. }
  164.  
  165. StaticPopup_Show("CONFIGURE_UI")
  Reply With Quote
03-06-11, 12:40 PM   #9
lilsparky
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 117
this will be complicated by addons that store config data that is tied to specific characters/servers.
  Reply With Quote
03-14-11, 10:40 AM   #10
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by lilsparky View Post
this will be complicated by addons that store config data that is tied to specific characters/servers.
Indeed it will, even more complicated by whether the author chose to use two different saved variables in the toc or if they used one saved variable and then used table creations to separate the data for different chars and servers.

Side note, that code from CleanUI is actually a pretty good idea, as long as the addon you are changing has profiling setup and its as simple as setting the profile. Note that no mater what it requires a reload. there is a method of getting around the reload but it is dependent on how the addon was setup and uses an unreliable method of file naming to control load order. Granted ive always found it reliable but few addons setup in a fashion that allow you to use that method. It involves using ! at the start of the file name to insure that that file loads first or at least a head of 99% of the addons out there. This method would have you basically redo certain functions from the addon you are controlling before it ever loads. Having the end user do a reload on first install though is safer and easier
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 03-14-11 at 10:47 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » WTF -->Lua


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off