Exemplo n.º 1
0
        public SetupForm()
        {
            InitializeComponent();

            var ticket = new Ticket("/tvmaid/mutex/main");

            while (ticket.GetOwner(1000) == false)
            {
                var res = MessageBox.Show("Tvmaidが起動中です。終了してください。キャンセルすると終了します。", logo, MessageBoxButtons.RetryCancel);
                if (res == DialogResult.Cancel)
                {
                    throw new AppException("Tvmaidが終了されませんでした。");
                }
            }
            ticket.Dispose();

            Util.CopyUserFile();

            tvmaidDef = new DefineFile(Path.Combine(Util.GetUserPath(), "Tvmaid.def"));
            tvmaidDef.Load();
            tunerDef = new DefineFile(Path.Combine(Util.GetUserPath(), "tuner.def"));
            tunerDef.Load();

            tvtestBox.Text = tvmaidDef["tvtest"];
            recDirBox.Text = tvmaidDef["record.folder"];

            foreach (var key in tunerDef.Keys)
            {
                tunerListBox.Items.Add(key + "=" + tunerDef[key]);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load the flyff defines files.
        /// </summary>
        private void LoadDefines()
        {
            string[] defines =
            {
                "define.h",
                "defineAttribute.h",
                "defineEvent.h",
                "defineHonor.h",
                "defineItem.h",
                "defineItemkind.h",
                "defineJob.h",
                "defineNeuz.h",
                "defineObj.h",
                "defineSkill.h",
                "defineSound.h",
                "defineText.h",
                "defineWorld.h"
            };

            foreach (var defineFile in defines)
            {
                var defineFileContent = new DefineFile(Path.Combine(Global.DataPath, "res", "data", defineFile));
                defineFileContent.Parse();

                foreach (var define in defineFileContent.Defines)
                {
                    if (!this.defines.ContainsKey(define.Key) && define.Value is int)
                    {
                        this.defines.Add(define.Key, int.Parse(define.Value.ToString()));
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public void Load()
        {
            var defines     = new ConcurrentDictionary <string, int>();
            var headerFiles = from x in Directory.GetFiles(GameResourcesConstants.Paths.ResourcePath, "*.*", SearchOption.AllDirectories)
                              where DefineFile.Extensions.Contains(Path.GetExtension(x))
                              select x;

            foreach (var headerFile in headerFiles)
            {
                using (var defineFile = new DefineFile(headerFile))
                {
                    foreach (var define in defineFile.Defines)
                    {
                        var isIntValue = int.TryParse(define.Value.ToString(), out int intValue);

                        if (isIntValue && !defines.ContainsKey(define.Key))
                        {
                            defines.TryAdd(define.Key, intValue);
                        }
                        else
                        {
                            _logger.LogWarning(GameResourcesConstants.Errors.ObjectIgnoredMessage, "Define", define.Key,
                                               isIntValue ? "already declared" : $"'{define.Value}' is not a integer value");
                        }
                    }
                }
            }

            _cache.Set(GameResourcesConstants.Defines, defines);
            _logger.LogInformation("-> {0} defines found.", defines.Count);
        }
Exemplo n.º 4
0
        public void CountDefines()
        {
            var defines = new DefineFile(DefineFilePath);

            Assert.NotNull(defines);
            Assert.Equal(DefinesCount, defines.Count);

            defines.Dispose();
        }
Exemplo n.º 5
0
        public void OpenDefineFile()
        {
            var defines = new DefineFile(DefineFilePath);

            Assert.NotNull(defines);
            Assert.NotEqual(0, defines.Count);

            defines.Dispose();
        }
Exemplo n.º 6
0
        public void GetDefineValueAsNumberFromIndexer()
        {
            var defines = new DefineFile(DefineFilePath);

            Assert.NotNull(defines);

            int value = defines.GetValue <int>(TextTwoKey);

            Assert.Equal(TextTwoValue, value);

            defines.Dispose();
        }
Exemplo n.º 7
0
        public void GetDefineValueAsNumberFromMethod()
        {
            var defines = new DefineFile(DefineFilePath);

            Assert.NotNull(defines);

            int value = (int)defines[TextTwoKey];

            Assert.Equal(TextTwoValue, value);

            defines.Dispose();
        }
Exemplo n.º 8
0
        public void TryGetCommentedDefineValue()
        {
            var defines = new DefineFile(DefineFilePath);

            Assert.NotNull(defines);

            var exception = Assert.Throws <KeyNotFoundException>(() =>
            {
                object defineValueFromIndexer = defines[TextCommentKey];
            });

            Assert.NotNull(exception);
            Assert.Equal(typeof(KeyNotFoundException), exception.GetType());

            defines.Dispose();
        }
Exemplo n.º 9
0
        public static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: DefineToConst className defineFilePath");
                return;
            }

            var defineFile = new DefineFile(args[1]);

            Console.WriteLine("Parsing {0} ...", args[1]);
            defineFile.Parse();
            Console.WriteLine("Parsing done.");

            Console.WriteLine("Creating const class {0}...", args[0]);
            CreateConstClass(args[0], defineFile);
            Console.WriteLine("Const class done.");
        }
Exemplo n.º 10
0
        private static void CreateConstClass(string className, DefineFile defineFile)
        {
            var sBuilder = new StringBuilder();

            sBuilder.AppendLine("public class " + className);
            sBuilder.AppendLine("{");

            foreach (var define in defineFile.Defines)
            {
                string defineValueType = GetDefineValueType(define.Value);
                string defineValue     = GetDefineHexValue(define.Value);

                var format = string.Format("\tpublic const {0} {1} = 0x{2};", defineValueType, define.Key, defineValue);

                sBuilder.AppendLine(format);
            }

            sBuilder.AppendLine("}");

            File.WriteAllText(className + ".cs", sBuilder.ToString());
        }
Exemplo n.º 11
0
 void LoadDef()
 {
     Util.CopyUserFile();
     stateDef = new DefineFile(Path.Combine(Util.GetUserPath(), "Maidmon.state.def"));
     stateDef.Load();
 }