public void LoadLibrary(ILibraryService service, IConfigSource source, IRegistryCore registry)
        {
            m_service = service;
            m_registry = registry;
            m_Database = Framework.Utilities.DataManager.RequestPlugin<IInventoryData>();

            IConfig libConfig = source.Configs["InventoryIARLoader"];
            const string pLibrariesLocation = "DefaultInventory/";
            AddDefaultAssetTypes();
            if (libConfig != null)
            {
                if (libConfig.GetBoolean("WipeLibrariesOnNextLoad", false))
                {
                    service.ClearDefaultInventory(); //Nuke it
                    libConfig.Set("WipeLibrariesOnNextLoad", false);
                    source.Save();
                }
                if (libConfig.GetBoolean("PreviouslyLoaded", false))
                    return; //If it is loaded, don't reload
                foreach (string iarFileName in Directory.GetFiles(pLibrariesLocation, "*.iar"))
                {
                    LoadLibraries(iarFileName);
                }
            }
        }
Example #2
0
        public frmMain()
        {
            #if (DEBUG_1||DEBUG_2||DEBUG_3)
            debugLogger = new DebugLogger("frmMain.log");
            #endif
            debugLogger.WriteDebug_3("Begin Method: frmMain.frmMain()");

            InitializeComponent();

            Directory.SetCurrentDirectory(Directory.GetParent(Application.ExecutablePath).FullName);
            debugLogger.WriteDebug_2("Set Current Directory to " + Directory.GetParent(Application.ExecutablePath).FullName);

            // TODO: Determine why this is a double nested try/catch to load some INI settings
            try
            {
                inifile = new IniConfigSource(Directory.GetCurrentDirectory() + "\\settings.ini");
                DBString = inifile.Configs["Files"].GetString("dbfile","");
                LogFile = inifile.Configs["Files"].GetString("logfile","");
                OutputDirectory = inifile.Configs["Files"].GetString("outdir","");
                DKPTax = inifile.Configs["Other"].GetDouble("tax",0.0);
                MinDKP = inifile.Configs["Other"].GetDouble("mindkp", 0);
                TierAPct = inifile.Configs["Other"].GetDouble("tierapct", 0.6);
                TierBPct = inifile.Configs["Other"].GetDouble("tierbpct", 0.3);
                TierCPct = inifile.Configs["Other"].GetDouble("tiercpct", 0.0);
                GuildNames = inifile.Configs["Other"].GetString("GuildNames", "Eternal Sovereign");
                debugLogger.WriteDebug_1("Read settings from INI: DBFile=" + DBString + ", LogFile=" + LogFile + ", OutputDirectory="
                    + OutputDirectory + ", DKPTax=" + DKPTax + ", GuildNames=" + GuildNames);

                StatusMessage ="Read settings from INI...";
                try
                {
                    parser = new LogParser(this,LogFile);
                    debugLogger.WriteDebug_3("Created log parser");
                }
                catch (Exception ex) {
                    debugLogger.WriteDebug_1("Failed to create log parser: " + ex.Message);
                }
            }
            catch (FileNotFoundException ex)
            {
                debugLogger.WriteDebug_3("settings.ini not found, creating");

                FileStream a = File.Create(Directory.GetCurrentDirectory() + "\\settings.ini");
                a.Close();
                sbpMessage.Text = "settings.ini not found... Loading defaults";
                try
                {
                    inifile = new IniConfigSource(Directory.GetCurrentDirectory() + "\\settings.ini");
                    inifile.AddConfig("Files");
                    inifile.AddConfig("Other");
                    LogFile = inifile.Configs["Files"].GetString("logfile","");
                    DBString = inifile.Configs["Files"].GetString("dbfile","");
                    OutputDirectory = inifile.Configs["Files"].GetString("outdir","");
                    DKPTax = inifile.Configs["Other"].GetDouble("tax",0.0);
                    MinDKP = inifile.Configs["Other"].GetDouble("mindkp", 0);
                    TierAPct = inifile.Configs["Other"].GetDouble("tierapct", 0.6);
                    TierBPct = inifile.Configs["Other"].GetDouble("tierbpct", 0.3);
                    TierCPct = inifile.Configs["Other"].GetDouble("tiercpct", 0.0);
                    GuildNames = inifile.Configs["Other"].GetString("GuildNames", "Eternal Sovereign");
                    inifile.Save();
                    debugLogger.WriteDebug_1("Read settings from INI: dbFile=" + DBString + ", logFile=" + LogFile
                        + ", outDir=" + OutputDirectory + ", tax=" + DKPTax + ", mindkp=" + MinDKP + ", GuildNames=" + GuildNames);
                }
                catch (Exception exc)
                {
                    debugLogger.WriteDebug_1("Failed to create new settings.ini: " + exc.Message);
                    MessageBox.Show("Error opening settings.ini","Error");
                    Environment.Exit(1);
                }
            }
            catch (Exception ex)
            {
                debugLogger.WriteDebug_1("Failed to load settings.ini: " + ex.Message);
                MessageBox.Show("Error opening settings.ini","Error");
                Environment.Exit(1);
            }
            UITimer = new Timer();
            UITimer.Interval = 100;
            UITimer.Tick += new EventHandler(UITimer_Tick);
            UITimer.Start();

            debugLogger.WriteDebug_3("End Method: frmMain.frmMain()");
        }