상속: FOCommon.Config
예제 #1
0
        public frmMain()
        {
            Directory.SetCurrentDirectory(Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString());

            Config = new Config("ObjectEditor");
            if (Config.IsFirstTime())
            {
                OptionsForm = new frmOptions(Config);
                OptionsForm.ShowDialog();
            }
            Config.Load();

            Utils.InitLog("." + Path.DirectorySeparatorChar + "ObjectEditor.log");
            FOCommon.Utils.InitLog("." + Path.DirectorySeparatorChar + "ObjectEditor.log", false);
            Utils.Log("Initializing Object Editor " + Utils.GetVersion() + " compatible with " + Utils.GetFormatCompatibilityVersion() + " format.");
            Utils.Log(FOCommon.Utils.GetCLRInfo());

            if (Config.ScriptingEnabled)
            {
                Utils.Log("Starting scripthost...");
                Scripting.Host.ScriptHost = new Scripting.OEScriptHost();
                Scripting.Host.ScriptGlobal = new Scripting.ScriptGlobal();
                Scripting.Host.ScriptGlobal.Init(Scripting.Host.ScriptHost);
                Scripting.Host.ScriptHost.Init(this, Config.PathEditorScript);
                Scripting.Host.ScriptHost.RegisterFormEvents(this);
            }

            InitializeComponent();
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
        }
예제 #2
0
 public frmOptions(Config Cfg)
 {
     this.Cfg = Cfg;
     InitializeComponent();
 }
예제 #3
0
파일: Data.cs 프로젝트: SnakeSolidNL/tools
        public static bool LoadDefines(Config Cfg)
        {
            ClearLists();
            DefineParser defines = new DefineParser();
            string CurrentLine="";
            string CurrentFile="";

            if (!defines.ReadDefines(@Cfg.PathDefines))
            {
                Message.Show("Can't find " + Cfg.PathDefines, MessageBoxButtons.OK, MessageBoxIcon.Error, true);
                return false;
            }

            try
            {
                Defines = defines.Defines;

                ItemPid.Add("", 0); // none
                WeaponPerks.Add("", 0);

                CurrentFile = "_defines.fos";
                // Read stuff from parsed defines from _defines.fos
                foreach (KeyValuePair<string, int> kvp in Defines)
                {
                    CurrentLine = kvp.Key;
                    if (kvp.Key.StartsWith("ITEM_TYPE_")) ItemTypes.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 10) : kvp.Key), kvp.Value);
                    if (kvp.Key.StartsWith("CALIBER_")) Calibers.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 8) : kvp.Key), kvp.Value);
                    if (kvp.Key.StartsWith("WEAPON_PERK_")) WeaponPerks.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 12) : kvp.Key), kvp.Value);
                    if (kvp.Key.StartsWith("DAMAGE_")) DamageTypes.Add((Cfg.StripPrefix ? kvp.Key.Remove(0, 7) : kvp.Key), kvp.Value);
                }

                if (!File.Exists(Cfg.PathDataFolder + Path.DirectorySeparatorChar + "DefineNames.lst"))
                {
                    Message.Show("Can't find DefinesNames.lst", MessageBoxButtons.OK, MessageBoxIcon.Error, true);
                    return false;
                }

                List<String> Lines = new List<String>(File.ReadAllLines(Cfg.PathDataFolder + Path.DirectorySeparatorChar + "DefineNames.lst", Encoding.UTF8));
                bool PAnim1 = false;
                bool PAnim2 = false;
                bool PSkills = false;
                int BaseNum = 0;
                char[] Sep = { ' ', '\t' };
                CurrentFile = "DefineNames.lst";
                foreach (String Line in Lines)
                {
                    CurrentLine = Line;
                    if (Line.Length == 0 || Line[0] == '#')
                        continue;

                    if (Line[0] == '*')
                    {
                        PAnim1 = false;
                        PAnim2 = false;
                        PSkills = false;
                        BaseNum = Int32.Parse(Line.Remove(0, 1));
                    }

                    if (Line.Length < 6)
                        continue;

                    string[] Parts = Line.Split(Sep, StringSplitOptions.RemoveEmptyEntries);
                    if (PAnim1) Anim1.Add(Parts[1], BaseNum + Int32.Parse(Parts[0]));
                    if (PAnim2) Anim2.Add(Parts[1], BaseNum + Int32.Parse(Parts[0]));
                    if (PSkills) Skills.Add(Parts[1], BaseNum + Int32.Parse(Parts[0]));

                    if (Line.Contains("---ANIM1---")) PAnim1 = true;
                    else if (Line.Contains("---ANIM2---")) PAnim2 = true;
                    else if (Line.Contains("---SKILLS---")) PSkills = true;
                }

                if (!File.Exists(Cfg.PathDataFolder + Path.DirectorySeparatorChar +"ItemNames.lst"))
                {
                    Message.Show("Can't find ItemNames.lst", MessageBoxButtons.OK, MessageBoxIcon.Error, true);
                    return false;
                }

                CurrentFile = "ItemNames.lst";
                Lines = new List<String>(File.ReadAllLines(Cfg.PathDataFolder + Path.DirectorySeparatorChar + "ItemNames.lst", Encoding.UTF8));
                foreach (String Line in Lines)
                {
                    CurrentLine = Line;
                    if (Line.Length < 4) continue;
                    string[] Parts = Line.Split(Sep, StringSplitOptions.RemoveEmptyEntries);
                    if (ItemPid.ContainsKey(Parts[1]))
                        ItemPid[Parts[1]] = Int32.Parse(Parts[0]);
                    else
                        ItemPid.Add(Parts[1], Int32.Parse(Parts[0]));
                }
            }
            catch (IndexOutOfRangeException)
            {
                Message.Show("Error while parsing line '" + CurrentLine + "' in " + CurrentFile, MessageBoxButtons.OK, MessageBoxIcon.Error, true);
            }
            return true;
        }