lotrointerface.com
Search Downloads

LoTROInterface SVN KragenBars

[/] [branches/] [3.01/] [KragenBars/] [Main.lua] - Rev 133

Go to most recent revision | Compare with Previous | Blame | View Log

import "Turbine.UI";
import "Turbine.UI.Lotro";
import "KragenPlugs.Utils";
import "KragenPlugs.KragenBars";

-- load settings file
function LoadSettings()
        settings = Turbine.PluginData.Load( Turbine.DataScope.Character, "KragenBarsSettings" );

        -- Set main version number
        vars = { };
        vars.vers = 3.01;
        vars.player = Turbine.Gameplay.LocalPlayer.GetInstance();
        vars.playerlevel = vars.player:GetLevel();
        vars.effects = vars.player:GetEffects();
        vars.classid = vars.player:GetClass();
        vars.classattr = vars.player:GetClassAttributes();
        
        -- declare settings as a table and set default opacity
        if ( type( settings ) ~= "table" ) then
                settings = { };
                settings.opacity = 1;
                settings.lockslots = false;
                settings.snaptogrid = true;
        end
        
        -- if version is not declared then wipe settings file and set version number
                -- if version <3.00 (prior versions had string version number) then add required settings
        if (settings.vers == nil or type(settings.vers)=="string") then
                        settings = nil;
            settings = { };
            settings.vers = vars.vers;
            settings.opacity = 1;
            settings.lockslots = false;
            settings.snaptogrid = true;
            SaveSettings();
                end

        
        if (vars.classid == 40) then
            vars.playerclass = "Burglar";
            KragenBars = BurglarBars();
        elseif (vars.classid == 24) then
            vars.playerclass = "Captain";
            KragenBars = CaptainBars();
        elseif (vars.classid == 172) then
            vars.playerclass = "Champion";
            KragenBars = ChampionBars();
        elseif (vars.classid == 23) then
            vars.playerclass = "Guardian";
            KragenBars = GuardianBars();
        elseif (vars.classid == 162) then
            vars.playerclass = "Hunter";
            KragenBars = HunterBars();
        elseif (vars.classid == 185) then
            vars.playerclass = "Loremaster";
            KragenBars = LoreBars();
        elseif (vars.classid == 31) then
            vars.playerclass = "Minstrel";
            KragenBars = MiniBars();
        elseif (vars.classid == 193) then
            vars.playerclass = "Runekeeper";
            KragenBars = RuneBars();
        elseif (vars.classid == 194) then
            vars.playerclass = "Warden";
                        Turbine.Shell.WriteLine("KragenBars: Warden is not currently implemented in KragenBars.  Look for this feature in a future version.");
            -- KragenBars = WardenBars();
        end             
        
end

-- save to settings file
function SaveSettings()
        
        Turbine.PluginData.Save( Turbine.DataScope.Character, "KragenBarsSettings", settings );

end

-- on unload call each instances unload function to save settings
function UnloadPlugin()
        KragenBars:SaveSettings();
        
end


function ValidatePosition(x, y, width, height)
    x = math.min(math.max(x, 0), Turbine.UI.Display:GetWidth() - width);
    y = math.min(math.max(y, 0), Turbine.UI.Display:GetHeight() - height);
    return x, y;
        
end


-- setup user chat commands
KragenBarsCommand = Turbine.ShellCommand();

function KragenBarsCommand:Execute( command, arguments )
        if (arguments == "setup") then
                KragenBars:ShowSetup();
        elseif (arguments == "refresh") then
                KragenBars:Refresh();
        elseif (arguments == "save") then
                KragenBars:SaveSettings();
                elseif (arguments == "reset") then
                        KragenBars:DefaultPosition();
                        KragenBars:DefaultSettings();
                        KragenBars:Refresh();
        elseif (arguments == "defaultpos") then
                        KragenBars:DefaultPosition();
        else
        Turbine.Shell.WriteLine("KragenBars Help:\n - /Kragenbars setup - Opens Kragens setup window\n - /Kragenbars refresh - Refreshes Kragens bar settings (ie. after level up)\n - /Kragenbars reset - Resets settings to default\n - /Kragenbars defaultpos - Sets window positions to default");
        end

end


function AddCallback(object, event, callback)
        if (object[event] == nil) then
                object[event] = callback;
        else
                if (type(object[event]) == "table") then
                        table.insert(object[event], callback);
                else
                        object[event] = {object[event], callback};
                end
        end
end


-- inialize plugin
function init()
    settings = { };

        -- setup plugin unload function to save setting on unload.
                pluginName="KragenBars";
                window = Turbine.UI.Window();
                window:SetWantsUpdates(true);
                window.Update = function(sender,args)
                        if (Plugins[pluginName] ~= nil) then
                                Plugins[pluginName].Unload = function(self,sender,args)
                                        UnloadPlugin();
                                end
                                window:SetWantsUpdates(false);
                        end
                end

        Turbine.Shell.AddCommand( "Kragenbars", KragenBarsCommand );

        LoadSettings();
end


-- codeblock
init();

Go to most recent revision | Compare with Previous | Blame


All times are GMT -5. The time now is 08:36 PM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui