示例#1
0
        public CraftWindow(CraftBuddy cbInstance)
        {
            InitializeComponent();

            _cb = cbInstance;
            _cbLogger = cbInstance.Logger;

            lb_recipes.DisplayMember = "Name";
            lb_recipes.ValueMember = "Id";
            PopulateRecipeList();

            cmbox_profile_template.DisplayMember = "Name";
            PopulateTemplates();
        }
示例#2
0
        public void OnInitialize()
        {
            // Create a new logger
            if(Logger == null)
                Logger = new cbLogger();

            // Get plugin path and check if recipe files, and templates exist
            GlobalSettings _settings = GlobalSettings.Instance;
            string PluginPath = Path.Combine(_settings.PluginsPath, "CraftBuddy");
            RecipesPath = Path.Combine(PluginPath, @"Data\Recipes");
            if(!Directory.Exists(RecipesPath))
            {
                Logger.Write(LoggerType.Error, string.Format("Failed to load the recipes from '{0}'", RecipesPath));
                return;
            }
            TemplatesPath = Path.Combine(PluginPath, @"Data\Templates");
            if(!Directory.Exists(TemplatesPath))
            {
                Logger.Write(LoggerType.Error, string.Format("Template directory not found at '{0}'", TemplatesPath));
                return;
            }

            // Load settings
            string SettingsPath = Path.Combine(PluginPath, @"Data\Settings\settings.json");
            if(!File.Exists(SettingsPath))
            {
                Logger.Write(LoggerType.Error, string.Format("Settings file not found at '{0}'", SettingsPath));
                return;
            }
            else
            {
                using(StreamReader sr = new StreamReader(SettingsPath))
                {
                    string jsonData = sr.ReadToEnd();
                    Settings = JsonConvert.DeserializeObject<cbSettings>(jsonData);
                }
            }

            ReloadTemplates();
        }