Пример #1
0
        public void Export()
        {
            try
            {
                Log.Message($"[{nameof(LocationNameExporter)}] Exporting...");
                Int32 skipped = 0;

                String text = EmbadedSentenseLoader.LoadText(EmbadedTextResources.LocationNames);

                Dictionary <Int32, String> locationNames = new Dictionary <Int32, String>();
                String[] array = text.Split('\r');
                for (Int32 i = 0; i < array.Length; i++)
                {
                    String str = array[i];
                    str = str.Replace("\n", String.Empty);
                    if (!String.IsNullOrEmpty(str))
                    {
                        String key   = str.Split(':')[0];
                        String value = str.Split(':')[1];
                        locationNames[Int32.Parse(key)] = FF9TextTool.RemoveOpCode(value);
                    }
                }

                Dictionary <String, LinkedList <TxtEntry> > entries = LocationNameFormatter.Build(locationNames);

                String directory = ModTextResources.Export.LocationNamesDirectory;
                Directory.CreateDirectory(directory);

                Char[] invalidChars = Path.GetInvalidFileNameChars();
                foreach (KeyValuePair <String, LinkedList <TxtEntry> > pair in entries)
                {
                    String outputPath = Path.Combine(directory, "Names of " + pair.Key.ReplaceChars("_", invalidChars) + ".strings");
                    if (File.Exists(outputPath))
                    {
                        skipped++;
                        continue;
                    }

                    TxtWriter.WriteStrings(outputPath, pair.Value.ToArray());
                }

                if (skipped > 0)
                {
                    Log.Warning($"[{nameof(LocationNameExporter)}] Exporting completed but [{skipped}/{entries.Count}] files has been skipped because already exists.");
                }
                else
                {
                    Log.Message($"[{nameof(LocationNameExporter)}] Exporting completed successfully.");
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"[{nameof(LocationNameExporter)}] Failed to export resource.");
            }
        }
Пример #2
0
        protected override Boolean LoadInternal()
        {
            String text = EmbadedSentenseLoader.LoadText(EmbadedTextResources.LocationNames);

            Dictionary <Int32, String> locationNames = FF9TextTool.LocationNames;

            String[] array = text.Split('\r');
            for (Int32 i = 0; i < array.Length; i++)
            {
                String str = array[i];
                str = str.Replace("\n", String.Empty);
                if (!String.IsNullOrEmpty(str))
                {
                    String key   = str.Split(':')[0];
                    String value = str.Split(':')[1];
                    locationNames[Int32.Parse(key)] = FF9TextTool.RemoveOpCode(value);
                }
            }
            return(true);
        }
Пример #3
0
        private void OnIcon(Int32 oneParameterFromTag)
        {
            String  text4;
            Boolean flag = true;
            Int32   num3 = oneParameterFromTag;

            switch (num3)
            {
            case 34:
                text4 = "[sub]0[/sub]";
                break;

            case 35:
                text4 = "[sub]1[/sub]";
                break;

            case 36:
            case 37:
            case 38:
IL_D2:
                switch (num3)
                {
                case 159:
                    text4 = "[sup]" + Localization.Get("Miss") + "[/sup]";
                    break;

                case 160:
                    text4 = "[sup]" + Localization.Get("Death") + "[/sup]";
                    break;

                case 161:
                    text4 = "[sup]" + Localization.Get("Guard") + "[/sup]";
                    break;

                case 162:
                    text4 = "[B880E0][sup]" + Localization.Get("Critical") + "[/sup][C8C8C8]";
                    break;

                case 163:
                    text4 = "[sup]MP[/sup]";
                    break;

                default:
                    if (num3 == 173)
                    {
                        text4 = "9";
                    }
                    else
                    {
                        if (num3 == 174)
                        {
                            text4 = "/";
                        }
                        else
                        {
                            if (num3 == 45)
                            {
                                text4 = "[sub]/[/sub]";
                            }
                            else
                            {
                                text4 = String.Concat("[ICON", "=", oneParameterFromTag, "] ");
                                flag  = false;
                            }
                        }
                    }
                    break;
                }
                break;

            case 39:
                text4 = "[sub]5[/sub]";
                break;

            default:
                goto IL_D2;
            }
            _sb.Append(text4);
            if (flag)
            {
                _currentWidth += NGUIText.GetTextWidthFromFF9Font(_label, FF9TextTool.RemoveOpCode(text4));
            }
            else
            {
                _currentWidth += FF9UIDataTool.GetIconSize(oneParameterFromTag).x;
            }
        }
Пример #4
0
        private static void SerializeAllActions(String outputDirectory)
        {
            UInt16 id = 0;

            using (CsvWriter csv = new CsvWriter(outputDirectory + "Actions.csv"))
            {
                csv.WriteLine("# This file contains NPC actions.");
                csv.WriteLine("# ----------------------------------------------------------------------------------------------------------------------------------");
                csv.WriteLine("# Id;cursor;def_cur;vfx_no;Vfx2;def_cam;prog_no;power;attr;rate;Category;AddNo;MP;Type");
                csv.WriteLine("# UInt16;UInt8;UInt8;Int16;UInt16;UInt8;UInt8;UInt8;UInt8;UInt8;UInt8;UInt8;UInt8;UInt8");
                csv.WriteLine("# ----------------------------------------------------------------------------------------------------------------------------------");

                foreach (var group in Actions.GroupBy(p => p.Key))
                {
                    KeyValuePair <String, AA_DATA>[] items    = group.OrderBy(v => ActionComparer.CalcDiff(v, group)).ToArray();
                    KeyValuePair <String, AA_DATA>   baseItem = items.First();
                    csv.WriteEntry(new ActionEntry(id, baseItem.Value), baseItem.Key);

                    String name       = group.Key;
                    String outputPath = outputDirectory + FF9TextTool.RemoveOpCode(name) + ".json";

                    using (JsonWriter writer = new JsonWriter(outputPath))
                    {
                        writer.BeginComplexArray();
                        foreach (KeyValuePair <String, AA_DATA> pair in items)
                        {
                            AA_DATA action = pair.Value;
                            writer.BeginObject();
                            writer.WriteUInt16("id", id);
                            writer.WriteString("name", name);
                            if (baseItem.Value.Info.cursor != action.Info.cursor)
                            {
                                writer.WriteEnum("targets", (TargetType)action.Info.cursor);
                            }
                            if (baseItem.Value.Info.def_cur != action.Info.def_cur)
                            {
                                writer.WriteBoolean("defaultAlly", action.Info.def_cur == 1);
                            }
                            if (baseItem.Value.Info.vfx_no != action.Info.vfx_no)
                            {
                                writer.WriteInt16("animationId1", action.Info.vfx_no);
                            }
                            if (baseItem.Value.Vfx2 != action.Vfx2)
                            {
                                writer.WriteUInt16("animationId2", action.Vfx2);
                            }

                            if (baseItem.Value.Ref.prog_no != action.Ref.prog_no)
                            {
                                writer.WriteByte("scriptId", action.Ref.prog_no);
                            }
                            if (baseItem.Value.Ref.power != action.Ref.power)
                            {
                                writer.WriteByte("power", action.Ref.power);
                            }
                            if (baseItem.Value.Ref.attr != action.Ref.attr)
                            {
                                writer.WriteFlags("elements", (EffectElement)action.Ref.attr);
                            }
                            if (baseItem.Value.Ref.rate != action.Ref.rate)
                            {
                                writer.WriteByte("rate", action.Ref.rate);
                            }

                            if (baseItem.Value.Category != action.Category)
                            {
                                writer.WriteByte("category", action.Category);
                            }
                            if (baseItem.Value.AddNo != action.AddNo)
                            {
                                writer.WriteByte("addNo", action.AddNo);
                            }
                            if (baseItem.Value.MP != action.MP)
                            {
                                writer.WriteByte("mp", action.MP);
                            }
                            if (baseItem.Value.Type != action.Type)
                            {
                                writer.WriteByte("type", action.Type);
                            }
                            writer.EndObject();
                        }
                        writer.EndComplexArray();
                    }
                    id++;
                }
            }
        }