private void bLastSlide_Click(object sender, EventArgs e) { foreach (TextSplitShow TSS in Globals.WindowList) { TSS.GoToLast(); } }
public string GetDataAsHtml( GameVersion version, TSS.TSSFile stringDic, Dictionary<uint, TSS.TSSEntry> inGameIdDict ) { StringBuilder sb = new StringBuilder(); sb.Append( "<tr>" ); /* sb.Append( "<td>" ); sb.Append( RefString ); sb.Append( "</td>" ); //*/ sb.Append( "<td>" ); sb.Append( "<span class=\"itemname\">" ); sb.Append( inGameIdDict[NameStringDicID].StringJpnHtml( version ) ); sb.Append( "</span>" ); sb.Append( "<br>" ); sb.Append( inGameIdDict[DescStringDicID].StringJpnHtml( version ) ); sb.Append( "</td>" ); sb.Append( "<td>" ); sb.Append( "<span class=\"itemname\">" ); sb.Append( inGameIdDict[NameStringDicID].StringEngHtml( version ) ); sb.Append( "</span>" ); sb.Append( "<br>" ); sb.Append( inGameIdDict[DescStringDicID].StringEngHtml( version ) ); sb.Append( "</td>" ); sb.Append( "<td>" ); sb.Append( GradeCost + " Grade" ); sb.Append( "</td>" ); return sb.ToString(); }
/// <summary>Initialize session and base classes.</summary> /// <param name="session">The session.</param> /// <param name="delays">The delays.</param> protected AbstractTssController(TSession session, uint[] delays) : base(session) { Tss = new TSS(delays); _simulation = new TssSimulationWrapper(this); TargetSpeed = AdjustedSpeed = 1.0f; }
private void bOK_Click(object sender, EventArgs e) { Properties.Settings.Default.Continuous = cContinuous.Checked; Properties.Settings.Default.NavigateAll = cNavigateAll.Checked; Properties.Settings.Default.NavigationWindowAlwaysOnTop = cNavigationWindowAlwaysOnTop.Checked; Globals.TSM.TopMost = cNavigationWindowAlwaysOnTop.Checked; Properties.Settings.Default.DisplayVerticalScrollBars = cDisplayVerticalScrollbars.SelectedIndex; foreach (TextSplitShow TSS in Globals.WindowList) { // I'd rather have this be Vertical than ForcedVertical, but there is the issue with Resizing. May change this in v2.1 if (cDisplayVerticalScrollbars.SelectedIndex == 0) { TSS.tTextBox.ScrollBars = RichTextBoxScrollBars.ForcedVertical; } if (cDisplayVerticalScrollbars.SelectedIndex == 1) { TSS.tTextBox.ScrollBars = RichTextBoxScrollBars.Vertical; } if (cDisplayVerticalScrollbars.SelectedIndex == 2) { TSS.tTextBox.ScrollBars = RichTextBoxScrollBars.ForcedVertical; } TSS.DisplaySlide(); } Close(); }
public void TestSaveScriptAsOriginal() { var BytesOriginal = File.ReadAllBytes(Utils.TestInputPath + "/BTL_EP_210_090"); var Tss = new TSS().Load(new MemoryStream(BytesOriginal)); var BytesTranslated = Tss.Save().ToArray(); CollectionAssert.AreEqual(BytesOriginal, BytesTranslated); }
public void TestTranslateScript() { string TssFileName = "BTL_EP_210_090"; int ExpectedTextCount = 4; var ExpectedStrings = new Queue <String>(); var Tss = new TSS().Load(File.OpenRead(Utils.TestInputPath + "/" + TssFileName)); int mm = 0; Tss.TranslateTexts((Text) => { for (int n = 0; n < Text.Translated.Length; n++) { Text.Original[n].Text = "Original" + mm++; Text.Translated[n].Text = "Translated" + mm++; } }, (String) => { try { //Console.WriteLine(String); if (String == "VB36_1402") { return(String = "**VB36_1403**"); } return(null); } finally { ExpectedStrings.Enqueue(String); } }); Assert.AreEqual(ExpectedTextCount * 2 * 2, mm); mm = 0; var Tss2 = new TSS().Load(Tss.Save()); var TranslatedTexts = Tss2.ExtractTexts(); Assert.AreEqual(ExpectedTextCount, TranslatedTexts.Count); foreach (var Text in TranslatedTexts) { for (int n = 0; n < Text.Translated.Length; n++) { Assert.AreEqual("Original" + mm++, Text.Original[n].Text); Assert.AreEqual("Translated" + mm++, Text.Translated[n].Text); } } var TranslatedStrings = Tss2.ExtractStrings(); foreach (var StringInfo in TranslatedStrings) { //Assert.AreEqual("Original" + mm++, Text.Original[n].Text); Assert.AreEqual(ExpectedStrings.Dequeue(), StringInfo.Text); } Assert.AreEqual(ExpectedTextCount * 2 * 2, mm); //File.WriteAllBytes(Utils.TestOutputPath + "/BTL_EP_210_090.translated", Tss.Save().ToArray()); }
public void TestReadInstructions() { var Tss = new TSS().Load(File.OpenRead(Utils.TestInputPath + "/BTL_EP_210_090")); using (var OutputStream = File.Open(Utils.TestOutputPath + "/BTL_EP_210_090.script", FileMode.Create)) using (var StreamWriter = new StreamWriter(OutputStream)) { foreach (var Instruction in Tss.ReadInstructions()) { StreamWriter.WriteLine("{0}", Instruction.ToString()); } } }
private void Calculate_Click(object sender, EventArgs e) { //Declare Swimmer's Label, so we can write the Swimmer's Name, and store it with his/her proper Data string swimmerName; swimmerName = Console.ReadLine(); swimmerName = lblSwimerName.ToString(); //Declarations double longDistance; double longTime; double shortDistance; double shortTime; double workoutDistance; double workingTime; double CSS; //Critical Swim Speed double NSS; //Normalized Swim Speed double IF; //Intensity Factor double TSS; //Training Stress Score //Inputs //This 4 lines (with code) are used to calculate the CSS longDistance = double.Parse(lblLongerDistance.Text); longTime = double.Parse(lblLongerTime.Text); shortDistance = double.Parse(lblShorterDistance.Text); shortTime = double.Parse(lblShorterTime.Text); //This 2 lines of code are used to calculate the NSS workoutDistance = double.Parse(lblWorkoutDistance.Text); workingTime = double.Parse(lblWorkingTime.Text); //Processing CSS = (longDistance - shortDistance) / (longTime - shortTime); //Calculates the CSS NSS = (workoutDistance / workingTime); //Calculates tge NSS IF = (NSS / CSS); //Calculates the IF TSS = ((Math.Pow(IF, 3)) * (workingTime / 3600) * 100); //Calculates the TSS //OutPut lblCSS.Text = CSS.ToString(); lblNSS.Text = NSS.ToString(); lblIF.Text = IF.ToString(); lblTSS.Text = TSS.ToString(); }
private void Handle2() { if (!Patcher.TempFS.Exists("string_dic_es.so")) { var TotalCount = Patcher.EntriesByRoom.Where(Room => Room.Key.StartsWith("misc/")).Sum(Item => Item.Value.Count); this.Patcher.ProgressHandler.AddProgressLevel("Traduciendo String.dic", TotalCount, () => { long OriginalLength = Patcher.TempFS.GetFileInfo("string_dic_uk.so").Size; long TranslatedLength = OriginalLength; Patcher.TempFS.OpenFileRWScope("string_dic_es.so.temp", (TssStream) => { var Tss = new TSS().Load(TssStream); Tss.TranslateTexts((TextEntry) => { this.Patcher.ProgressHandler.IncrementLevelProgress(); var RoomPath = String.Format("misc/{0}", (TextEntry.Id / 1000) * 1000); var TextId = String.Format("{0:D8}", TextEntry.Id); var TranslationRoom = Patcher.EntriesByRoom[RoomPath]; var TranslationEntry = TranslationRoom[TextId]; TextEntry.TranslateWithTranslationEntry(TranslationEntry); }, (String) => { return(null); }, HandleType1: true, AddAdditionalSpace: true); var TssTranslatedStream = Tss.Save(); OriginalLength = TssStream.Length; TranslatedLength = TssTranslatedStream.Length; TssStream.Position = 0; TssStream.WriteStream(TssTranslatedStream.Slice()).WriteByteRepeatedTo(0x00, TssStream.Length); }); Console.WriteLine("Old: {0}", OriginalLength); Console.WriteLine("New: {0}", TranslatedLength); if (TranslatedLength > OriginalLength) { throw (new Exception(String.Format("Translated string_dic is bigger than the original one. {0} > {1}", TranslatedLength, OriginalLength))); } Patcher.TempFS.MoveFile("string_dic_es.so.temp", "string_dic_es.so", true); }); } }
public string GetDataAsHtml( GameVersion version, TSS.TSSFile stringDic, Dictionary<uint, TSS.TSSEntry> inGameIdDict ) { StringBuilder sb = new StringBuilder(); sb.Append( "<tr id=\"skill" + InGameID + "\">" ); //sb.Append( RefString + "<br>" ); sb.Append( "<td>" ); sb.Append( "<img src=\"skill-icons/category-" + Category + ".png\" width=\"32\" height=\"32\">" ); sb.Append( "</td>" ); sb.Append( "<td class=\"skilljpn\">" ); sb.Append( "<span class=\"itemname\">" ); sb.Append( inGameIdDict[NameStringDicID].StringJpnHtml( version ) ); sb.Append( "</span>" ); sb.Append( "<br>" ); sb.Append( inGameIdDict[DescStringDicID].StringJpnHtml( version ) ); sb.Append( "</td>" ); sb.Append( "<td>" ); sb.Append( "<span class=\"itemname\">" ); sb.Append( inGameIdDict[NameStringDicID].StringEngHtml( version ) ); sb.Append( "</span>" ); sb.Append( "<br>" ); sb.Append( inGameIdDict[DescStringDicID].StringEngHtml( version ) ); sb.Append( "</td>" ); sb.Append( "<td class=\"skilldata\">" ); if ( LearnableByBitmask > 0 ) { sb.Append( "<span class=\"equip\">" ); Website.GenerateWebsite.AppendCharacterBitfieldAsImageString( sb, version, LearnableByBitmask ); sb.Append( "</span>" ); } sb.Append( EquipCost + " SP<br>" ); sb.Append( LearnCost + " LP<br>" ); sb.Append( "Symbol Weight: " + SymbolValue + "<br>" ); //sb.Append( "~7: " + Unknown7 + "<br>" ); //sb.Append( "~13: " + Unknown13 + "<br>" ); //sb.Append( "~14: " + Unknown14 + "<br>" ); //sb.Append( "~15: " + Unknown15 + "<br>" ); if ( Inactive == 0 ) { sb.Append( "Unusable<br>" ); } sb.Append( "</td>" ); sb.Append( "</tr>" ); return sb.ToString(); }
public void StringTests() { var TSS = new TSS(); TSS.Load(File.OpenRead(String.Format(@"{0}\BTL_EP_510_080.TSS", Utils.TestInputPath))); var SelectedInstructions = TSS.ReadInstructions() .Where( Instruction => ( (Instruction.Opcode == TSS.Opcode.PUSH) && (Instruction.ParameterType.Value == TSS.ValueType.String) ) ) .Cast <TSS.PushInstructionNode>() ; Assert.AreEqual <String>(SelectedInstructions.ElementAt(2).ValueToPush.Value, "MUS_F03_NOR_CAP3"); //Console.WriteLine(StringInstructions.Implode("\r\n")); }
public string GetDataAsHtml( GameVersion version, TSS.TSSFile stringDic, Dictionary<uint, TSS.TSSEntry> inGameIdDict ) { StringBuilder sb = new StringBuilder(); sb.Append( "<td>" ); sb.Append( "<span class=\"itemname\">" ); sb.Append( inGameIdDict[NameStringDicId].StringJpnHtml( version ) ); sb.Append( "</span><br>" ); sb.Append( inGameIdDict[TextStringDicId].StringJpnHtml( version ) ); sb.Append( "</td>" ); sb.Append( "<td>" ); sb.Append( "<span class=\"itemname\">" ); sb.Append( inGameIdDict[NameStringDicId].StringEngHtml( version ) ); sb.Append( "</span><br>" ); sb.Append( inGameIdDict[TextStringDicId].StringEngHtml( version ) ); sb.Append( "</td>" ); return sb.ToString(); }
public void TestReadTexts() { var Tss = new TSS().Load(File.OpenRead(Utils.TestInputPath + "/BTL_EP_210_090")); var Texts = Tss.ExtractTexts(); Assert.AreEqual(4, Texts.Count); /* * Assert.AreEqual( * "TextEntry(TextType=0,Id=0x3FA74,Id2=0x42AC,Original=[\"バルボス\", \"\\t(VB36_0703)くっ、やりやがって……許さん!!\"],Translated=[\"Barbos\", \"\\t(VB36_0703)Agh... Y-you\\'ll never beat me!\"])", * Texts[0].ToString() * ); */ Assert.AreEqual( "\t(VS21_176)You have lost! \nNow give up!".EscapeString(), Texts[3].Translated[1].Text.EscapeString() ); }
public string GetDataAsHtml( GameVersion version, TSS.TSSFile stringDic, Dictionary<uint, TSS.TSSEntry> inGameIdDict ) { StringBuilder sb = new StringBuilder(); var synopsisEntry = inGameIdDict[TextStringDicId]; string jp = synopsisEntry.StringJpn != null ? synopsisEntry.StringJpn : ""; jp = Website.GenerateWebsite.ReplaceIconsWithHtml( new StringBuilder( jp ), version, true ).ToString(); string en = synopsisEntry.StringEng != null ? synopsisEntry.StringEng : ""; en = Website.GenerateWebsite.ReplaceIconsWithHtml( new StringBuilder( en ), version, false ).ToString(); string[] textJpn = jp.Split( '\f' ); string[] textEng = en.Split( '\f' ); for ( int i = 0; i < textJpn.Length; ++i ) { textJpn[i] = VesperiaUtil.RemoveTags( textJpn[i], true, true ).Replace( "\n", "<br />" ); } for ( int i = 0; i < textEng.Length; ++i ) { textEng[i] = VesperiaUtil.RemoveTags( textEng[i], false, true ).Replace( "\n", "<br />" ); } //sb.Append( "Unlocks between " + StoryIdMin + " and " + StoryIdMax + "<br>" ); sb.Append( "<table class=\"synopsis\">" ); sb.Append( "<tr id=\"synopsis" + ID + "\"><td class=\"synopsistitle\" colspan=\"" + textJpn.Length + "\">" ); if ( version == GameVersion.PS3 ) { sb.Append( "<img src=\"synopsis/U_" + RefString1 + ".png\"><br><br>" ); } sb.Append( inGameIdDict[NameStringDicId].StringJpnHtml( version ) + "</td></tr><tr>" ); foreach ( string s in textJpn ) { sb.Append( "<td>" + s + "</td>" ); } sb.Append( "</tr>" ); sb.Append( "</table>" ); sb.Append( "<br>" ); sb.Append( "<table class=\"synopsis\">" ); sb.Append( "<tr id=\"synopsis" + ID + "\"><td class=\"synopsistitle\" colspan=\"" + textEng.Length + "\">" ); sb.Append( inGameIdDict[NameStringDicId].StringEngHtml( version ) + "</td></tr><tr>" ); foreach ( string s in textEng ) { sb.Append( "<td>" + s + "</td>" ); } sb.Append( "</tr>" ); sb.Append( "</table>" ); return sb.ToString(); }
public void LoadTest() { var TSS = new TSS(); TSS.Load(File.OpenRead(String.Format(@"{0}\BTL_EP_510_080.TSS", Utils.TestInputPath))); TSS.ReadInstructions(); var SelectedInstructions = TSS.PushArrayInstructionNodes .Where(Instruction => (Instruction.ArrayNumberOfElements == 6)) ; Assert.AreEqual( @"[" + @"''," + @"''," + @"'\u30a2\u30ec\u30af\u30bb\u30a4'," + @"'101(VB45_0703)\u304f\u3063\u2026\u2026\u3001\u3084\u3063\u3066\u304f\u308c\u305f\u306a\uff01'," + "'Alexei'," + "'101(VB45_0703)Aagh...not bad!'" + @"]" , SelectedInstructions.ElementAt(0).Elements.ToArray().ToJson(true) ); }
public string GetDataAsHtml( GameVersion version, TSS.TSSFile stringDic, Dictionary<uint, TSS.TSSEntry> inGameIdDict ) { var nameEn = inGameIdDict[NameStringDicID].StringEng; var nameJp = inGameIdDict[NameStringDicID].StringJpn; StringBuilder sb = new StringBuilder(); sb.Append( "<tr>" ); sb.Append( "<td>" ); Website.GenerateWebsite.AppendCharacterBitfieldAsImageString( sb, version, 1u << (int)( Character - 1 ) ); sb.Append( "</td>" ); sb.Append( "<td>" ); sb.Append( "<span class=\"itemname\">" ); sb.Append( inGameIdDict[NameStringDicID].StringJpnHtml( version ) ); sb.Append( "</span>" ); sb.Append( "<br>" ); sb.Append( inGameIdDict[DescStringDicID].StringJpnHtml( version ) ); sb.Append( "</td>" ); sb.Append( "<td>" ); sb.Append( "<span class=\"itemname\">" ); if ( nameEn.Contains( "\x06(COS)" ) && !nameJp.Contains( "\x06(COS)" ) ) { sb.Append( nameEn.Replace( "\x06(COS)", "" ).ToHtmlEng( version ) ); Console.WriteLine( "Removed EN costume icon for " + nameEn ); } else { sb.Append( inGameIdDict[NameStringDicID].StringEngHtml( version ) ); } sb.Append( "</span>" ); sb.Append( "<br>" ); sb.Append( inGameIdDict[DescStringDicID].StringEngHtml( version ) ); sb.Append( "</td>" ); sb.Append( "<td>" ); sb.Append( BunnyGuildPointsMaybe + " Fame point" + ( BunnyGuildPointsMaybe != 1 ? "s" : "" ) ); sb.Append( "</td>" ); return sb.ToString(); }
public string GetDataAsHtml( GameVersion version, Dictionary<uint, Arte> arteIdDict, T8BTEMST.T8BTEMST enemies, T8BTSK.T8BTSK skills, TSS.TSSFile stringDic, Dictionary<uint, TSS.TSSEntry> inGameIdDict, bool phpLinks = false ) { StringBuilder sb = new StringBuilder(); sb.Append( "<tr id=\"arte" + InGameID + "\">" ); sb.Append( "<td style=\"text-align: right;\">" ); //sb.Append( RefString + "<br>" ); if ( Character > 0 && Character <= 9 ) { Website.GenerateWebsite.AppendCharacterBitfieldAsImageString( sb, version, 1u << (int)( Character - 1 ) ); } if ( Character > 9 ) { var enemy = enemies.EnemyIdDict[Character]; sb.Append( "<a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Enemy, version, phpLinks, category: (int)enemy.Category, id: (int)enemy.InGameID ) + "\">" ); sb.Append( "<img src=\"monster-icons/48px/monster-" + enemy.IconID.ToString( "D3" ) + ".png\" width=\"32\" height=\"32\" title=\"" + inGameIdDict[enemy.NameStringDicID].StringEngOrJpnHtml( version ) + "\">" ); sb.Append( "</a>" ); } sb.Append( "<img src=\"menu-icons/artes-" ); switch ( Type ) { case ArteType.Base: sb.Append( "00" ); break; case ArteType.Arcane: sb.Append( "01" ); break; case ArteType.Altered: sb.Append( "12" ); break; case ArteType.AlteredSpell: sb.Append( "12" ); break; case ArteType.NoviceSpell: sb.Append( "04" ); break; case ArteType.IntermediateSpell: sb.Append( "05" ); break; case ArteType.AdvancedSpell: sb.Append( "06" ); break; case ArteType.Burst: sb.Append( "02" ); break; case ArteType.BurstSpell: sb.Append( "02" ); break; case ArteType.AlteredBurst: sb.Append( "02" ); break; case ArteType.AlteredBurstSpell: sb.Append( "02" ); break; case ArteType.Mystic: sb.Append( "02" ); break; } sb.Append( ".png\" width=\"32\" height=\"32\">" ); sb.Append( "</td>" ); sb.Append( "<td>" ); sb.Append( "<span class=\"itemname\">" ); sb.Append( inGameIdDict[NameStringDicId].StringJpnHtml( version ) + "</span><br>" ); sb.Append( inGameIdDict[DescStringDicId].StringJpnHtml( version ) ); sb.Append( "</td>" ); sb.Append( "<td>" ); sb.Append( "<span class=\"itemname\">" ); sb.Append( inGameIdDict[NameStringDicId].StringEngHtml( version ) + "</span><br>" ); sb.Append( inGameIdDict[DescStringDicId].StringEngHtml( version ) ); sb.Append( "</td>" ); sb.Append( "<td>" ); //sb.Append( Type + "<br>" ); bool iconsInserted = false; if ( Character <= 9 ) { switch ( FatalStrikeType ) { case 0: sb.Append( "<img src=\"menu-icons/artes-13.png\" width=\"16\" height=\"16\">" ); iconsInserted = true; break; case 1: sb.Append( "<img src=\"menu-icons/artes-15.png\" width=\"16\" height=\"16\">" ); iconsInserted = true; break; case 2: sb.Append( "<img src=\"menu-icons/artes-14.png\" width=\"16\" height=\"16\">" ); iconsInserted = true; break; } } if ( ElementFire > 0 ) { sb.Append( "<img src=\"text-icons/icon-element-02.png\" width=\"16\" height=\"16\">" ); iconsInserted = true; } if ( ElementEarth > 0 ) { sb.Append( "<img src=\"text-icons/icon-element-04.png\" width=\"16\" height=\"16\">" ); iconsInserted = true; } if ( ElementWind > 0 ) { sb.Append( "<img src=\"text-icons/icon-element-01.png\" width=\"16\" height=\"16\">" ); iconsInserted = true; } if ( ElementWater > 0 ) { sb.Append( "<img src=\"text-icons/icon-element-05.png\" width=\"16\" height=\"16\">" ); iconsInserted = true; } if ( ElementLight > 0 ) { sb.Append( "<img src=\"text-icons/icon-element-03.png\" width=\"16\" height=\"16\">" ); iconsInserted = true; } if ( ElementDarkness > 0 ) { sb.Append( "<img src=\"text-icons/icon-element-06.png\" width=\"16\" height=\"16\">" ); iconsInserted = true; } if ( iconsInserted ) { sb.Append( "<br>" ); } if ( TPUsage > 0 ) { sb.Append( "TP usage: " + TPUsage + "<br>" ); } for ( int i = 0; i < LearnRequirementsOtherArtesType.Length; ++i ) { if ( LearnRequirementsOtherArtesType[i] > 0 ) { switch ( LearnRequirementsOtherArtesType[i] ) { case 1: // Level if ( LearnRequirementsOtherArtesId[i] == 300 ) { sb.Append( "Learn via Event" ); } else { sb.Append( "Level " + LearnRequirementsOtherArtesId[i] ); } break; case 2: // Other Arte var otherArte = arteIdDict[LearnRequirementsOtherArtesId[i]]; if ( otherArte.ID != this.ID ) { sb.Append( "<img src=\"menu-icons/artes-" + otherArte.GetIconNumber() + ".png\" width=\"16\" height=\"16\">" ); sb.Append( "<a href=\"#arte" + otherArte.InGameID + "\">" + inGameIdDict[otherArte.NameStringDicId].StringEngOrJpnHtml( version ) ); sb.Append( "</a>, " ); } else { sb.Append( "Learn with " ); } sb.Append( LearnRequirementsOtherArtesUsageCount[i] + " uses" ); break; case 3: // appears on Rita and Repede's Burst Artes in 360 only, appears to be unused break; default: sb.Append( "##Unknown Learn Type: " + LearnRequirementsOtherArtesType[i] + "<br>" ); sb.Append( "##Value 1: " + LearnRequirementsOtherArtesId[i] + "<br>" ); sb.Append( "##Value 2: " + LearnRequirementsOtherArtesUsageCount[i] + "<br>" ); break; } sb.Append( "<br>" ); } } for ( int i = 0; i < AlteredArteRequirementType.Length; ++i ) { if ( AlteredArteRequirementType[i] > 0 ) { switch ( AlteredArteRequirementType[i] ) { case 1: // original arte var otherArte = arteIdDict[AlteredArteRequirementId[i]]; sb.Append( "Alters from " ); sb.Append( "<img src=\"menu-icons/artes-" + otherArte.GetIconNumber() + ".png\" width=\"16\" height=\"16\">" ); sb.Append( "<a href=\"#arte" + otherArte.InGameID + "\">" + inGameIdDict[otherArte.NameStringDicId].StringEngOrJpnHtml( version ) + "</a>" ); break; case 3: // skill var skill = skills.SkillIdDict[AlteredArteRequirementId[i]]; sb.Append( "<img src=\"skill-icons/category-" + skill.Category + ".png\" width=\"16\" height=\"16\">" ); sb.Append( "<a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Skill, version, phpLinks, id: (int)skill.InGameID ) + "\">" + inGameIdDict[skill.NameStringDicID].StringEngOrJpnHtml( version ) + "</a>" ); break; default: sb.Append( "##Unknown Altered Type: " + AlteredArteRequirementType[i] + "<br>" ); sb.Append( "##Value: " + AlteredArteRequirementId[i] + "<br>" ); break; } sb.Append( "<br>" ); } } if ( UsableInMenu > 0 ) { sb.Append( "Usable outside of battle" ); } sb.Append( "</td>" ); /* sb.Append( "<td>" ); sb.AppendLine(); sb.AppendLine( "~" + 9 + ": " + Data[9] + "<br>" ); for ( int i = 16; i < 22; ++i ) { sb.AppendLine( "~" + i + ": " + Data[i] + "<br>" ); } for ( int i = 40; i < 69; ++i ) { if ( i == 44 ) continue; if ( i == 42 || i == 66 ) { sb.AppendLine( "~" + i + ": " + Data[i].UIntToFloat() + "<br>" ); } else { sb.AppendLine( "~" + i + ": " + Data[i] + "<br>" ); } } for ( int i = 79; i < 95; ++i ) { if ( i == 83 ) continue; sb.AppendLine( "~" + i + ": " + Data[i] + "<br>" ); } sb.Append( "</td>" ); //*/ sb.Append( "</tr>" ); return sb.ToString(); }
public void HandleBattlePackDialogs(Stream OldStream, Stream NewStream) { FPS4 OldFps4; FPS4 NewFps4; OldFps4 = new FPS4(OldStream.Slice()); NewFps4 = new FPS4(OldStream.Slice()); // Intended OldStream var TranslatedFiles = new ConcurrentDictionary <string, MemoryStream>(); var Names = new[] { "BTL_EP_0070_010", "BTL_EP_030_040", "BTL_EP_030_080", "BTL_EP_0950_010", "BTL_EP_0960_020", "BTL_EP_1040_020", "BTL_EP_150_170", "BTL_EP_170_050", "BTL_EP_210_090", "BTL_EP_270_110", "BTL_EP_270_110_1", "BTL_EP_340_070", "BTL_EP_370_050", "BTL_EP_420_080", "BTL_EP_440_040", "BTL_EP_470_030", "BTL_EP_490_060_0", "BTL_EP_490_060_1", "BTL_EP_510_050", "BTL_EP_510_080", "BTL_EP_640_050", "BTL_EP_650_030", "BTL_EP_650_050", "BTL_LL_MONSTER", "MA_VAL_A_05", }; Patcher.Action("Translating Battle Scripts", () => { Patcher.ProgressHandler.AddProgressLevel("Traduciendo scripts de batalla...", Names.Length, () => { Patcher.ParallelForeach("Translating", Names, (Name) => Name, (Name) => { using (var CompressedTssStream = OldFps4[Name].Open()) { using (var TssStream = TalesCompression.DecompressStream(CompressedTssStream)) { var TssName = Name; var Tss = new TSS().Load(TssStream); Tss.TranslateTexts((Entry) => { //if (Entry == null) return; var TranslationEntry = Patcher.EntriesByRoom["battle/" + TssName][String.Format("{0:X8}", Entry.Id2)]; int TextCount = Entry.Original.Length; Entry.TranslateWithTranslationEntry(TranslationEntry); //Console.WriteLine("{0} : {1}", Entry.Translated[1], TranslationEntry.texts.es[1]); }, (String) => { return(null); }); var TranslatedCompressedStream = TalesCompression.CreateFromVersion(Patcher.CompressionVersion, Patcher.CompressionFallback).EncodeFile(Tss.Save()); TranslatedFiles[Name] = TranslatedCompressedStream; } } Patcher.ProgressHandler.IncrementLevelProgress(); }); }); }); Patcher.Action("Reconstructing Battle Scripts Package", () => { NewFps4.ClearAllEntries(); foreach (var Entry in OldFps4.Entries.Values) { var EntryName = Entry.Name; if (TranslatedFiles.ContainsKey(EntryName)) { NewFps4.CreateEntry(EntryName, TranslatedFiles[EntryName]); } else { NewFps4.CreateEntry(EntryName, Entry.Open()); } } NewFps4.SaveTo(NewStream, DoAlign: false); }); }
public string GetDataAsHtml( GameVersion version, ItemDat.ItemDat items, WRLDDAT.WRLDDAT locations, TSS.TSSFile stringDic, Dictionary<uint, TSS.TSSEntry> inGameIdDict, bool phpLinks = false ) { var sb = new StringBuilder(); sb.Append( "<tr id=\"enemy" + InGameID + "\">" ); sb.Append( "<td style=\"height: 46px;\">" ); var enemyNameEntry = inGameIdDict[NameStringDicID]; sb.Append( "<img src=\"monster-icons/44px/monster-" + IconID.ToString( "D3" ) + ".png\" title=\"" + RefString + "\">" ); sb.Append( "</td>" ); sb.Append( "<td style=\"height: 46px;\">" ); sb.Append( "<span class=\"itemname\">" + enemyNameEntry.StringJpnHtml( version ) + "</span><br>" ); sb.Append( "<span class=\"itemname\">" + enemyNameEntry.StringEngHtml( version ) + "</span><br>" ); //sb.Append( RefString2 + "<br>" ); //sb.Append( RefString3 + "<br>" ); //sb.Append( RefString4 + "<br>" ); //sb.Append( RefString5 + "<br>" ); sb.Append( "</td>" ); //sb.Append( " / Category: " + Category + "<br>" ); AppendStats( sb, "Easy", 0 ); AppendStats( sb, "Normal", 1 ); AppendStats( sb, "Hard", 2 ); AppendStats( sb, "Unknown", 3 ); sb.Append( "<td rowspan=\"2\">" ); sb.Append( "EXP: " + EXP + ", " ); Website.GenerateWebsite.AppendFatalStrikeIcon( sb, FatalTypeExp ); sb.Append( " +" + EXPModifier + "<br>" ); sb.Append( "LP: " + LP + ", " ); Website.GenerateWebsite.AppendFatalStrikeIcon( sb, FatalTypeLP ); sb.Append( " +" + LPModifier + "<br>" ); sb.Append( "Gald: " + Gald + "<br>" ); sb.Append( "Fatal Strike Resistances:<br>" ); Website.GenerateWebsite.AppendFatalStrikeIcon( sb, 0 ); sb.Append( FatalBlue ); sb.Append( " " ); Website.GenerateWebsite.AppendFatalStrikeIcon( sb, 1 ); sb.Append( FatalRed ); sb.Append( " " ); Website.GenerateWebsite.AppendFatalStrikeIcon( sb, 2 ); sb.Append( FatalGreen ); sb.Append( "<br>" ); int weakCount = 0; int strongCount = 0; int immuneCount = 0; int absorbCount = 0; for ( int i = 0; i < Attributes.Length; ++i ) { if ( Attributes[i] > 100 ) { weakCount++; } if ( Attributes[i] > 0 && Attributes[i] < 100 ) { strongCount++; } if ( Attributes[i] == 0 ) { immuneCount++; } if ( Attributes[i] < 0 ) { absorbCount++; } } if ( weakCount > 0 ) { sb.Append( "Weak: " ); for ( int i = 0; i < Attributes.Length; ++i ) { if ( Attributes[i] > 100 ) { Website.GenerateWebsite.AppendElementIcon( sb, (Element)i ); sb.Append( Attributes[i] - 100 ); sb.Append( "% " ); } } sb.Append( "<br>" ); } if ( strongCount > 0 ) { sb.Append( "Strong: " ); for ( int i = 0; i < Attributes.Length; ++i ) { if ( Attributes[i] > 0 && Attributes[i] < 100 ) { Website.GenerateWebsite.AppendElementIcon( sb, (Element)i ); sb.Append( Attributes[i] ); sb.Append( "% " ); } } sb.Append( "<br>" ); } if ( immuneCount > 0 ) { sb.Append( "Immune: " ); for ( int i = 0; i < Attributes.Length; ++i ) { if ( Attributes[i] == 0 ) { Website.GenerateWebsite.AppendElementIcon( sb, (Element)i ); } } sb.Append( "<br>" ); } if ( absorbCount > 0 ) { sb.Append( "Absorb: " ); for ( int i = 0; i < Attributes.Length; ++i ) { if ( Attributes[i] < 0 ) { Website.GenerateWebsite.AppendElementIcon( sb, (Element)i ); sb.Append( -Attributes[i] ); sb.Append( "% " ); } } sb.Append( "<br>" ); } if ( KillableWithFS == 0 ) { sb.AppendLine( "Immune to Fatal Strike.<br>" ); } sb.Append( "</td>" ); /* sb.Append( "<td rowspan=\"2\">" ); sb.AppendLine(); for ( int i = 0; i < 62; ++i ) { if ( !KnownValues.Contains( i ) ) { sb.Append( "~" + i + ": " + Data[i] ); sb.Append( " [" + Category + "/" + enemyNameEntry.StringEngOrJpn + "]" ); sb.AppendLine( "<br>" ); } } for ( int i = 62; i < Data.Length; ++i ) { if ( !KnownValues.Contains( i ) ) { sb.Append( "~" + i + ": " + DataFloat[i] ); sb.Append( " [" + Category + "/" + enemyNameEntry.StringEngOrJpn + "]" ); sb.AppendLine( "<br>" ); } } sb.Append( "</td>" ); //*/ sb.Append( "</tr>" ); sb.Append( "<tr>" ); sb.Append( "<td colspan=\"2\">" ); if ( InMonsterBook == 0 ) { sb.AppendLine( "Not in Monster Book.<br>" ); } if ( Location != 0 ) { var loc = locations.LocationIdDict[Location]; sb.Append( "<a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Location, version, phpLinks, id: (int)loc.LocationID ) + "\">" ); if ( LocationWeather > -1 ) { sb.AppendLine( "<img src=\"menu-icons/weather-" + LocationWeather + ".png\" width=\"16\" height=\"16\">" ); } sb.AppendLine( loc.GetLastValidName( inGameIdDict ).StringEngOrJpnHtml( version ) + "</a><br>" ); } for ( int i = 0; i < DropItems.Length; ++i ) { if ( DropItems[i] != 0 ) { sb.Append( "Drops:<br>" ); break; } } for ( int i = 0; i < DropItems.Length; ++i ) { if ( DropItems[i] != 0 ) { var item = items.itemIdDict[DropItems[i]]; sb.Append( "<img src=\"item-icons/ICON" + item.Data[(int)ItemData.Icon] + ".png\" height=\"16\" width=\"16\"> " ); sb.Append( "<a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Item, version, phpLinks, id: (int)item.Data[(int)ItemData.ID], icon: (int)item.Data[(int)ItemData.Icon] ) + "\">" ); sb.Append( inGameIdDict[item.NamePointer].StringEngOrJpnHtml( version ) + "</a>" ); sb.Append( ", " + DropChances[i] + "%" ); if ( DropChances[i] < 100 ) { sb.Append( ", " ); Website.GenerateWebsite.AppendFatalStrikeIcon( sb, FatalTypeDrop ); sb.Append( " +" + DropModifier[i] + "%" ); } sb.Append( "<br>" ); } } if ( SecretMissionDrop != 0 && SecretMissionDropChance > 0 ) { sb.Append( "Secret Mission Reward:<br>" ); var item = items.itemIdDict[SecretMissionDrop]; sb.Append( "<img src=\"item-icons/ICON" + item.Data[(int)ItemData.Icon] + ".png\" height=\"16\" width=\"16\"> " ); sb.Append( "<a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Item, version, phpLinks, id: (int)item.Data[(int)ItemData.ID], icon: (int)item.Data[(int)ItemData.Icon] ) + "\">" ); sb.Append( inGameIdDict[item.NamePointer].StringEngOrJpnHtml( version ) + "</a>, " + SecretMissionDropChance + "%<br>" ); } if ( StealItem != 0 ) { sb.Append( "Steal:<br>" ); var item = items.itemIdDict[StealItem]; sb.Append( "<img src=\"item-icons/ICON" + item.Data[(int)ItemData.Icon] + ".png\" height=\"16\" width=\"16\"> " ); sb.Append( "<a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Item, version, phpLinks, id: (int)item.Data[(int)ItemData.ID], icon: (int)item.Data[(int)ItemData.Icon] ) + "\">" ); sb.Append( inGameIdDict[item.NamePointer].StringEngOrJpnHtml( version ) + "</a>, " + StealChance + "%<br>" ); } sb.Append( "</td>" ); sb.AppendLine( "</tr>" ); return sb.ToString(); }
public void FullTest() { var TSS = new TSS(); TSS.Load(File.OpenRead(String.Format(@"{0}\string_dic_us.so", Utils.TestInputPath))); }
public static string GetItemDataAsText( GameVersion version, ItemDat items, ItemDatSingle item, T8BTSK.T8BTSK skills, T8BTEMST.T8BTEMST enemies, COOKDAT.COOKDAT Recipes, WRLDDAT.WRLDDAT Locations, TSS.TSSFile tss, Dictionary<uint, TSS.TSSEntry> dict = null ) { if ( dict == null ) { dict = tss.GenerateInGameIdDictionary(); } var sb = new StringBuilder(); sb.AppendLine( "[" + item.ItemString.TrimNull() + "]" ); sb.Append( "[Icon" + item.Data[(int)ItemData.Icon] + "] " ); var nameEntry = dict[item.NamePointer]; sb.AppendLine( nameEntry.StringEngOrJpn ); var descEntry = dict[item.DescriptionPointer]; sb.AppendLine( descEntry.StringEngOrJpn ); switch ( item.Data[(int)ItemData.Category] ) { case 2: sb.AppendLine( "<Tools>" ); break; case 3: sb.AppendLine( "<Main>" ); break; case 4: sb.AppendLine( "<Sub>" ); break; case 5: sb.AppendLine( "<Head>" ); break; case 6: sb.AppendLine( "<Body>" ); break; case 7: sb.AppendLine( "<Accessories>" ); break; case 8: sb.AppendLine( "<Ingredients>" ); break; case 9: sb.AppendLine( "<Synthesis Materials>" ); break; case 10: sb.AppendLine( "<Valuables>" ); break; case 11: sb.AppendLine( "<DLC>" ); break; default: sb.AppendLine( "<UNKNOWN>" ); break; } sb.AppendLine( "Price in shops: " + item.Data[(int)ItemData.ShopPrice] + " Gald" ); if ( item.Data[(int)ItemData.BuyableIn1] > 0 || item.Data[(int)ItemData.BuyableIn2] > 0 || item.Data[(int)ItemData.BuyableIn3] > 0 ) { sb.Append( "Available at shops in: " ); if ( item.Data[(int)ItemData.BuyableIn1] > 0 ) { sb.Append( Locations.LocationIdDict[item.Data[(int)ItemData.BuyableIn1]].GetLastValidName( dict ).StringEngOrJpn ); } if ( item.Data[(int)ItemData.BuyableIn2] > 0 ) { sb.Append( "; " + Locations.LocationIdDict[item.Data[(int)ItemData.BuyableIn2]].GetLastValidName( dict ).StringEngOrJpn ); } if ( item.Data[(int)ItemData.BuyableIn3] > 0 ) { sb.Append( "; " + Locations.LocationIdDict[item.Data[(int)ItemData.BuyableIn3]].GetLastValidName( dict ).StringEngOrJpn ); } sb.AppendLine(); } uint equip = item.Data[(int)ItemData.EquippableByBitfield]; if ( equip > 0 ) { sb.Append( "Equippable by: " ); if ( ( equip & 1 ) == 1 ) { sb.Append( "[YUR]" ); } if ( ( equip & 2 ) == 2 ) { sb.Append( "[EST]" ); } if ( ( equip & 4 ) == 4 ) { sb.Append( "[KAR]" ); } if ( ( equip & 8 ) == 8 ) { sb.Append( "[RIT]" ); } if ( ( equip & 16 ) == 16 ) { sb.Append( "[RAV]" ); } if ( ( equip & 32 ) == 32 ) { sb.Append( "[JUD]" ); } if ( ( equip & 64 ) == 64 ) { sb.Append( "[RAP]" ); } if ( ( equip & 128 ) == 128 ) { sb.Append( "[FRE]" ); } if ( version == GameVersion.PS3 && ( equip & 256 ) == 256 ) { sb.Append( "[PAT]" ); } sb.AppendLine(); } uint synthCount = item.Data[(int)ItemData.SynthRecipeCount]; switch ( synthCount ) { case 0: sb.AppendLine( "Can't be synthesized." ); break; case 1: sb.AppendLine( "Can be synthesized in 1 way." ); break; default: sb.AppendLine( "Can be synthesized in " + synthCount + " ways." ); break; } for ( int j = 0; j < synthCount; ++j ) { uint synthItemCount = item.Data[(int)ItemData.Synth1ItemSlotCount + j * 16]; sb.AppendLine( "Synthesis method #" + ( j + 1 ) ); sb.AppendLine( " Required Synthesis Level: " + item.Data[(int)ItemData._Synth1Level + j * 16] ); sb.AppendLine( " Price: " + item.Data[(int)ItemData.Synth1Price + j * 16] + " Gald" ); sb.AppendLine( " Requires " + synthItemCount + " items:" ); for ( int i = 0; i < synthItemCount; ++i ) { var otherItem = items.itemIdDict[item.Data[(int)ItemData.Synth1Item1Type + i * 2 + j * 16]]; var otherItemNameEntry = dict[otherItem.NamePointer]; string otherItemName = otherItemNameEntry.StringEngOrJpn; sb.AppendLine( " Item " + ( i + 1 ) + ": " + otherItemName + " x" + item.Data[(int)ItemData.Synth1Item1Count + i * 2 + j * 16] ); } } switch ( item.Data[(int)ItemData.Category] ) { case 2: default: // seems to be some kind of singletarget/multitarget flag maybe? //sb.AppendLine( "~19: " + item.Data[(int)ItemData.PATK] ); // seems to be a bitfield regarding what stuff it heals, 1 == death, 2 = magical ailment, 4 == physical ailment // this is already covered below so don't print it //sb.AppendLine( "~20: " + item.Data[(int)ItemData.MATK] ); if ( item.Data[(int)ItemData.MDEF_or_HPHealPercent] > 0 ) { sb.AppendLine( "HP Heal %: " + item.Data[(int)ItemData.MDEF_or_HPHealPercent] ); } if ( item.Data[(int)ItemData.AGL_TPHealPercent] > 0 ) { sb.AppendLine( "TP Heal %: " + item.Data[(int)ItemData.AGL_TPHealPercent] ); } // why is this here twice? uint physAilAlt = item.Data[(int)ItemData.PDEF]; uint physAil = item.Data[(int)ItemData._LUCK]; if ( physAil != physAilAlt ) { throw new Exception(); } if ( physAil > 0 ) { sb.Append( "Cures physical ailments: " ); if ( ( physAil & 1 ) == 1 ) { sb.Append( "Death " ); } if ( ( physAil & 2 ) == 2 ) { sb.Append( "Poison " ); } if ( ( physAil & 4 ) == 4 ) { sb.Append( "Paralysis " ); } if ( ( physAil & 8 ) == 8 ) { sb.Append( "Petrification " ); } if ( ( physAil & 16 ) == 16 ) { sb.Append( "Weak " ); } if ( ( physAil & 32 ) == 32 ) { sb.Append( "SealedArtes " ); } if ( ( physAil & 64 ) == 64 ) { sb.Append( "SealedSkills " ); } if ( ( physAil & 128 ) == 128 ) { sb.Append( "Contamination " ); } sb.AppendLine(); } if ( item.Data[(int)ItemData._AGL_Again] > 0 ) { sb.AppendLine( "Cures magical ailments" ); } if ( item.Data[26] > 0 ) { sb.AppendLine( "Permanent PATK increase: " + item.Data[26] ); } if ( item.Data[27] > 0 ) { sb.AppendLine( "Permanent PDEF increase: " + item.Data[27] ); } if ( item.Data[(int)ItemData.AttrFire] > 0 ) { sb.AppendLine( "Permanent MATK increase: " + item.Data[(int)ItemData.AttrFire] ); } if ( item.Data[(int)ItemData.AttrWater] > 0 ) { sb.AppendLine( "Permanent MDEF increase: " + item.Data[(int)ItemData.AttrWater] ); } if ( item.Data[(int)ItemData.AttrWind] > 0 ) { sb.AppendLine( "Permanent AGL increase: " + item.Data[(int)ItemData.AttrWind] ); } if ( item.Data[(int)ItemData.Skill1] > 0 ) { sb.AppendLine( "Max HP increase: " + item.Data[(int)ItemData.Skill1] ); } if ( item.Data[(int)ItemData.Skill1Metadata] > 0 ) { sb.AppendLine( "Max TP increase: " + item.Data[(int)ItemData.Skill1Metadata] ); } break; case 3: case 4: case 5: case 6: case 7: if ( (int)item.Data[(int)ItemData.PATK] > 0 ) { sb.AppendLine( "PATK: " + (int)item.Data[(int)ItemData.PATK] ); } if ( (int)item.Data[(int)ItemData.MATK] > 0 ) { sb.AppendLine( "MATK: " + (int)item.Data[(int)ItemData.MATK] ); } if ( (int)item.Data[(int)ItemData.PDEF] > 0 ) { sb.AppendLine( "PDEF: " + (int)item.Data[(int)ItemData.PDEF] ); } if ( (int)item.Data[(int)ItemData.MDEF_or_HPHealPercent] > 0 ) { sb.AppendLine( "MDEF: " + (int)item.Data[(int)ItemData.MDEF_or_HPHealPercent] ); } int agl1 = (int)item.Data[(int)ItemData.AGL_TPHealPercent]; int agl2 = (int)item.Data[(int)ItemData._AGL_Again]; if ( agl1 != agl2 ) { sb.AppendLine( "!!! AGL1: " + agl1 + " / AGL2: " + agl2 ); } else { if ( agl1 > 0 ) { sb.AppendLine( "AGL: " + agl1 ); } } if ( (int)item.Data[(int)ItemData._LUCK] > 0 ) { sb.AppendLine( "LUCK: " + (int)item.Data[(int)ItemData._LUCK] ); } if ( (int)item.Data[(int)ItemData.AttrFire] != 0 ) { sb.AppendLine( "Attribute Fire: " + (int)item.Data[(int)ItemData.AttrFire] ); } if ( (int)item.Data[(int)ItemData.AttrWater] != 0 ) { sb.AppendLine( "Attribute Water: " + (int)item.Data[(int)ItemData.AttrWater] ); } if ( (int)item.Data[(int)ItemData.AttrWind] != 0 ) { sb.AppendLine( "Attribute Wind: " + (int)item.Data[(int)ItemData.AttrWind] ); } if ( (int)item.Data[(int)ItemData.AttrEarth] != 0 ) { sb.AppendLine( "Attribute Earth: " + (int)item.Data[(int)ItemData.AttrEarth] ); } if ( (int)item.Data[(int)ItemData.AttrLight] != 0 ) { sb.AppendLine( "Attribute Light: " + (int)item.Data[(int)ItemData.AttrLight] ); } if ( (int)item.Data[(int)ItemData.AttrDark] != 0 ) { sb.AppendLine( "Attribute Darkness: " + (int)item.Data[(int)ItemData.AttrDark] ); } for ( int i = 0; i < 3; ++i ) { uint skillId = item.Data[(int)ItemData.Skill1 + i * 2]; if ( skillId != 0 ) { var skill = skills.SkillIdDict[skillId]; var skillNameEntry = dict[skill.NameStringDicID]; string skillName = skillNameEntry.StringEngOrJpn; sb.AppendLine( "Skill #" + ( i + 1 ) + " Name: " + skillName ); sb.AppendLine( "Skill #" + ( i + 1 ) + " Metadata: " + item.Data[(int)ItemData.Skill1Metadata + i * 2] ); } } break; } for ( int j = 0; j < 2; ++j ) { for ( int i = 0; i < 16; ++i ) { uint enemyId = item.Data[(int)ItemData.Drop1Enemy + i + j * 32]; if ( enemyId != 0 ) { var enemy = enemies.EnemyIdDict[enemyId]; var enemyNameEntry = dict[enemy.NameStringDicID]; string enemyName = enemyNameEntry.StringEngOrJpn; sb.AppendLine( "Enemy " + ( j == 0 ? "Drop" : "Steal" ) + " #" + ( i + 1 ) + ": " + enemyName + ", " + item.Data[(int)ItemData.Drop1Chance + i + j * 32] + "%" ); } } } for ( int i = 0; i < 8; ++i ) { if ( item.Data[(int)ItemData.UsedInRecipe1 + i] != 0 ) { sb.AppendLine( "Used in Recipe #" + ( i + 1 ) + ": " + item.Data[(int)ItemData.UsedInRecipe1 + i] ); } } //sb.AppendLine( "~3: " + item.Data[3] ); //sb.AppendLine( "~5: " + item.Data[5] ); //sb.AppendLine( "~18: " + item.Data[18] ); /* all of these values make no sense to me, probably useless for the reader sb.AppendLine( "~169: " + item.Data[169] ); sb.AppendLine( "~170: " + item.Data[170] ); sb.AppendLine( "~171: " + item.Data[171] ); sb.AppendLine( "~172: " + item.Data[172] ); sb.AppendLine( "~173: " + item.Data[173] ); sb.AppendLine( "~174: " + item.Data[174] ); */ // no idea, maybe related to what shows up on the character model? //sb.AppendLine( "~175: " + (int)item.Data[175] ); // seems to be some sort of ID, useless for the reader //sb.AppendLine( "~176: " + item.Data[176] ); if ( item.Data[(int)ItemData.UsableInBattle] > 0 ) { sb.AppendLine( "Usable in battle" ); }; if ( item.Data[(int)ItemData.InCollectorsBook] == 0 ) { sb.AppendLine( "Not in Collector's Book" ); } return sb.ToString(); }
protected void Expand(string FilePath) { if (FilePath.Contains('*') || FilePath.Contains('?')) { var BasePath = Path.GetDirectoryName(FilePath); var Recursive = false; if (BasePath == "") { BasePath = "."; } foreach (var FileName in Directory.EnumerateFiles(BasePath, Path.GetFileName(FilePath), Recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)) { Expand(FileName); } return; } var ListToExpand = new List <string>(); //Console.WriteLine("Expanding '{0}'...", FilePath); using (var _FileStream = File.OpenRead(FilePath)) { if (_FileStream.Length == 0) { //Console.WriteLine("EMPTY: {0}", FilePath); return; } var FileStream = DecompressIfCompressedStream(_FileStream); var MagicData = FileStream.Slice().ReadBytesUpTo(0x100); if (false) { } else if (TO8SCEL.IsValid(MagicData)) { try { var To8Scel = new TO8SCEL(FileStream); foreach (var Entry in To8Scel) { var EntryFilePath = FilePath + ".d/" + Entry.Index; if (Overwrite || !File.Exists(EntryFilePath)) { Console.WriteLine("{0}", EntryFilePath); try { var EntryStream = DecompressIfCompressedStream(Entry.CompressedStream); if (EntryStream.Length > 0) { EntryStream.CopyToFile(EntryFilePath); } } catch (Exception Exception) { ShowException(Exception); } } if (File.Exists(EntryFilePath)) { ListToExpand.Add(EntryFilePath); } } } catch (Exception Exception) { ShowException(Exception); } } else if (FPS4.IsValid(MagicData)) { //Console.WriteLine("FPS4"); try { var Fps4 = new FPS4(FileStream); foreach (var Entry in Fps4) { var EntryFilePath = FilePath + ".d/" + Entry.Name; if (Overwrite || !File.Exists(EntryFilePath)) { Console.WriteLine("{0}", EntryFilePath); try { var EntryStream = DecompressIfCompressedStream(Entry.Open()); if (EntryStream.Length > 0) { EntryStream.CopyToFile(EntryFilePath); } } catch (Exception Exception) { ShowException(Exception); } } if (File.Exists(EntryFilePath)) { ListToExpand.Add(EntryFilePath); } } } catch (Exception Exception) { ShowException(Exception); } } else if (TSS.IsValid(MagicData)) { int RoomId = 0; try { RoomId = int.Parse(Path.GetFileNameWithoutExtension(FilePath)); } catch { } var TxtFile = FilePath + ".txt"; Console.WriteLine("{0}", TxtFile); if (Overwrite || !File.Exists(TxtFile)) { var Tss = new TSS().Load(FileStream.Slice()); using (var TxtStream = File.Open(TxtFile, FileMode.Create, FileAccess.Write)) using (var TextWriter = new StreamWriter(TxtStream)) { try { Tss.DumpTexts(TextWriter); } catch (Exception Exception) { ShowException(Exception); } } } var ScrFile = FilePath + ".scr"; Console.WriteLine("{0}", ScrFile); if (Overwrite || !File.Exists(ScrFile)) { var Tss = new TSS().Load(FileStream.Slice()); using (var TxtStream = File.Open(ScrFile, FileMode.Create, FileAccess.Write)) using (var TextWriter = new StreamWriter(TxtStream)) { try { var ErrorString = ConsoleUtils.CaptureError(() => { Tss.DumpScript(TextWriter); }); } catch (Exception Exception) { ShowException(Exception); } } } } else if (TO8CHTX.IsValid(MagicData)) { var Chtx = new TO8CHTX(FileStream); var TxtFile = FilePath + ".txt"; Console.WriteLine("{0}", TxtFile); if (Overwrite || !File.Exists(TxtFile)) { using (var TxtStream = File.Open(TxtFile, FileMode.Create, FileAccess.Write)) using (var TextWriter = new StreamWriter(TxtStream)) { foreach (var Entry in Chtx.Entries) { TextWriter.WriteLine("{0}", Entry.Title); TextWriter.WriteLine("{0}", Entry.TextOriginal); TextWriter.WriteLine("{0}", Entry.TextTranslated); TextWriter.WriteLine(""); } } //Chtx.Entries[0].Title //Console.WriteLine("CHAT!"); } } else if (SE3.IsValid(MagicData)) { var Se3 = new SE3().Load(FileStream); foreach (var Entry in Se3.Entries) { var EntryFullNameXma = FilePath + "." + Entry.Name + ".xma"; var EntryFullNameWav = FilePath + "." + Entry.Name + ".wav"; Console.WriteLine("{0}", EntryFullNameXma); if (Overwrite || !File.Exists(EntryFullNameXma)) { Entry.ToXmaWav().CopyToFile(EntryFullNameXma); } if (Overwrite || !File.Exists(EntryFullNameWav)) { using (var WavOut = File.Open(EntryFullNameWav, FileMode.Create, FileAccess.Write)) { Entry.ToWav(WavOut); } } } } else if (TXM.IsValid(MagicData)) { string BasePath; string TxmPath; string TxvPath; if (Path.GetExtension(FilePath).ToLower() == ".txm") { BasePath = Path.GetDirectoryName(FilePath) + "/" + Path.GetFileNameWithoutExtension(FilePath); TxmPath = BasePath + ".txm"; TxvPath = BasePath + ".txv"; } else { var DirectoryPath = Path.GetDirectoryName(FilePath); TxmPath = DirectoryPath + "/" + Path.GetFileName(FilePath); TxvPath = DirectoryPath + "/" + (int.Parse(Path.GetFileName(TxmPath)) + 1); BasePath = TxmPath; } var Txm = TXM.FromTxmTxv(File.OpenRead(TxmPath), File.OpenRead(TxvPath)); /* * if (Txm.Surface2DEntries.Length > 0 && Txm.Surface3DEntries.Length > 0) * { * // 3D and 2D surfaces * //Console.WriteLine("ERROR 3D and 2D SURFACES! (2D: {0}, 3D: {1})", Txm.Surface2DEntries.Length, Txm.Surface3DEntries.Length); * } * else if (Txm.Surface2DEntries.Length > 0) * { * // 2D Surfaces * //Console.WriteLine("2D SURFACES! {0}", Txm.Surface2DEntries.Length); * } * else if (Txm.Surface3DEntries.Length > 0) * { * // 3D Surfaces * //Console.WriteLine("3D SURFACES! {0}", Txm.Surface3DEntries.Length); * } */ foreach (var Entry in Txm.Surface2DEntries) { var ImagePath = BasePath + "." + Entry.Name + ".png"; if (Overwrite || !File.Exists(ImagePath)) { try { Entry.Bitmap.Save(ImagePath); } catch (Exception Exception) { ShowException(Exception); } } } foreach (var Entry in Txm.Surface3DEntries) { var ImagePath0 = BasePath + "." + Entry.Name + "." + 0 + ".png"; if (Overwrite || !File.Exists(ImagePath0)) { try { var n = 0; foreach (var Bitmap in Entry.Bitmaps.Bitmaps) { var ImagePath = BasePath + "." + Entry.Name + "." + n + ".png"; Console.WriteLine("{0}", ImagePath); if (Overwrite || !File.Exists(ImagePath)) { Bitmap.Save(ImagePath); } n++; } } catch (Exception Exception) { ShowException(Exception); } } } } else { } } // Expand all the queued stuff foreach (var Item in ListToExpand) { try { Expand(Item); } catch (Exception Exception) { Console.WriteLine(" ERROR: {0}", Verbose ? Exception.ToString() : Exception.Message.ToString()); } } }
public static string GetItemDataAsHtml( GameVersion version, ItemDat items, ItemDatSingle item, T8BTSK.T8BTSK skills, T8BTEMST.T8BTEMST enemies, COOKDAT.COOKDAT Recipes, WRLDDAT.WRLDDAT Locations, TSS.TSSFile tss, Dictionary<uint, TSS.TSSEntry> dict = null, bool phpLinks = false ) { if ( dict == null ) { dict = tss.GenerateInGameIdDictionary(); } var sb = new StringBuilder(); sb.Append( "<tr id=\"item" + item.Data[(int)ItemData.ID] + "\">" ); sb.Append( "<td rowspan=\"3\">" ); sb.Append( "<img src=\"items/U_" + item.ItemString.TrimNull() + ".png\" height=\"128\" width=\"128\">" ); sb.Append( "</td><td colspan=\"2\">" ); uint equip = item.Data[(int)ItemData.EquippableByBitfield]; if ( equip > 0 ) { sb.Append( "<span class=\"equip\">" ); Website.GenerateWebsite.AppendCharacterBitfieldAsImageString( sb, version, equip ); sb.Append( "</span>" ); } var nameEntry = dict[item.NamePointer]; var descEntry = dict[item.DescriptionPointer]; sb.Append( "<img src=\"item-icons/ICON" + item.Data[(int)ItemData.Icon] + ".png\" height=\"16\" width=\"16\"> " ); sb.Append( "<span class=\"itemname\">" ); sb.Append( nameEntry.StringJpnHtml( version ) ); sb.Append( "</span>" ); sb.Append( "<br>" ); sb.Append( "<span class=\"itemdesc\">" ); sb.Append( descEntry.StringJpnHtml( version ) ); sb.Append( "</span>" ); sb.Append( "<br>" ); sb.Append( "<br>" ); sb.Append( "<img src=\"item-icons/ICON" + item.Data[(int)ItemData.Icon] + ".png\" height=\"16\" width=\"16\"> " ); sb.Append( "<span class=\"itemname\">" ); sb.Append( nameEntry.StringEngHtml( version ) ); sb.Append( "</span>" ); sb.Append( "<br>" ); sb.Append( "<span class=\"itemdesc\">" ); sb.Append( descEntry.StringEngHtml( version ) ); sb.Append( "</span>" ); sb.Append( "<span class=\"special\">" ); if ( item.Data[(int)ItemData.UsableInBattle] > 0 ) { sb.Append( "Usable in battle" ); }; if ( item.Data[(int)ItemData.InCollectorsBook] == 0 ) { sb.Append( "Not in Collector's Book" ); } sb.Append( "</span>" ); sb.Append( "</td>" ); uint synthCount = item.Data[(int)ItemData.SynthRecipeCount]; switch ( synthCount ) { case 0: break; case 1: sb.Append( "<td colspan=\"2\">" ); break; default: sb.Append( "<td>" ); break; } for ( int j = 0; j < synthCount; ++j ) { uint synthItemCount = item.Data[(int)ItemData.Synth1ItemSlotCount + j * 16]; sb.Append( "Synthesis Level: " + item.Data[(int)ItemData._Synth1Level + j * 16] ); sb.Append( "<br>" ); sb.Append( "Price: " + item.Data[(int)ItemData.Synth1Price + j * 16] + " Gald" ); for ( int i = 0; i < synthItemCount; ++i ) { sb.Append( "<br>" ); var otherItem = items.itemIdDict[item.Data[(int)ItemData.Synth1Item1Type + i * 2 + j * 16]]; var otherItemNameEntry = dict[otherItem.NamePointer]; string otherItemName = otherItemNameEntry.StringEngOrJpnHtml( version ); sb.Append( "<img src=\"item-icons/ICON" + otherItem.Data[(int)ItemData.Icon] + ".png\" height=\"16\" width=\"16\"> " ); sb.Append( "<a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Item, version, phpLinks, id: (int)otherItem.Data[(int)ItemData.ID], icon: (int)otherItem.Data[(int)ItemData.Icon] ) + "\">" ); sb.Append( otherItemName + "</a> x" + item.Data[(int)ItemData.Synth1Item1Count + i * 2 + j * 16] ); } if ( synthCount > 1 && j == 0 ) { sb.Append( "</td><td>" ); } } sb.Append( "</td></tr><tr>" ); uint category = item.Data[(int)ItemData.Category]; switch ( category ) { case 2: default: sb.Append( "<td colspan=\"2\">" ); if ( item.Data[(int)ItemData.MDEF_or_HPHealPercent] > 0 ) { sb.Append( "HP Heal %: " + item.Data[(int)ItemData.MDEF_or_HPHealPercent] + "<br>" ); } if ( item.Data[(int)ItemData.AGL_TPHealPercent] > 0 ) { sb.Append( "TP Heal %: " + item.Data[(int)ItemData.AGL_TPHealPercent] + "<br>" ); } // why is this here twice? uint physAilAlt = item.Data[(int)ItemData.PDEF]; uint physAil = item.Data[(int)ItemData._LUCK]; if ( physAil != physAilAlt ) { throw new Exception(); } if ( physAil > 0 ) { sb.Append( "Cures physical ailments: " ); if ( ( physAil & 1 ) == 1 ) { sb.Append( "<img src=\"text-icons/icon-status-13.png\" height=\"32\" width=\"32\">" ); } if ( ( physAil & 2 ) == 2 ) { sb.Append( "<img src=\"text-icons/icon-status-01.png\" height=\"32\" width=\"32\">" ); } if ( ( physAil & 4 ) == 4 ) { sb.Append( "<img src=\"text-icons/icon-status-02.png\" height=\"32\" width=\"32\">" ); } if ( ( physAil & 8 ) == 8 ) { sb.Append( "<img src=\"text-icons/icon-status-03.png\" height=\"32\" width=\"32\">" ); } if ( ( physAil & 16 ) == 16 ) { sb.Append( "<img src=\"text-icons/icon-status-04.png\" height=\"32\" width=\"32\">" ); } if ( ( physAil & 32 ) == 32 ) { sb.Append( "<img src=\"text-icons/icon-status-05.png\" height=\"32\" width=\"32\">" ); } if ( ( physAil & 64 ) == 64 ) { sb.Append( "<img src=\"text-icons/icon-status-06.png\" height=\"32\" width=\"32\">" ); } if ( ( physAil & 128 ) == 128 ) { sb.Append( "<img src=\"text-icons/icon-status-07.png\" height=\"32\" width=\"32\">" ); } sb.Append( "<br>" ); } if ( item.Data[(int)ItemData._AGL_Again] > 0 ) { sb.Append( "Cures magical ailments<br>" ); } if ( item.Data[(int)ItemData.PermanentPAtkIncrease] > 0 ) { sb.Append( "Permanent PATK increase: " + item.Data[(int)ItemData.PermanentPAtkIncrease] + "<br>" ); } if ( item.Data[(int)ItemData.PermanentPDefIncrease] > 0 ) { sb.Append( "Permanent PDEF increase: " + item.Data[(int)ItemData.PermanentPDefIncrease] + "<br>" ); } if ( item.Data[(int)ItemData.AttrFire] > 0 ) { sb.Append( "Permanent MATK increase: " + item.Data[(int)ItemData.AttrFire] + "<br>" ); } if ( item.Data[(int)ItemData.AttrWater] > 0 ) { sb.Append( "Permanent MDEF increase: " + item.Data[(int)ItemData.AttrWater] + "<br>" ); } if ( item.Data[(int)ItemData.AttrWind] > 0 ) { sb.Append( "Permanent AGL increase: " + item.Data[(int)ItemData.AttrWind] + "<br>" ); } if ( item.Data[(int)ItemData.Skill1] > 0 ) { sb.Append( "Max HP increase: " + item.Data[(int)ItemData.Skill1] + "<br>" ); } if ( item.Data[(int)ItemData.Skill1Metadata] > 0 ) { sb.Append( "Max TP increase: " + item.Data[(int)ItemData.Skill1Metadata] + "<br>" ); } for ( int i = 0; i < 8; ++i ) { int recipeId = (int)item.Data[(int)ItemData.UsedInRecipe1 + i]; if ( recipeId != 0 ) { var recipe = Recipes.RecipeList[recipeId]; var recipeNameEntry = dict[recipe.NameStringDicID]; sb.Append( "<a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Recipe, version, phpLinks, id: (int)recipe.ID ) + "\">" + recipeNameEntry.StringEngOrJpnHtml( version ) + "</a><br>" ); } } sb.Append( "</td>" ); break; case 3: case 4: case 5: case 6: case 7: sb.Append( "<td>" ); if ( (int)item.Data[(int)ItemData.PATK] > 0 ) { sb.Append( "PATK: " + (int)item.Data[(int)ItemData.PATK] + "<br>" ); } if ( (int)item.Data[(int)ItemData.MATK] > 0 ) { sb.Append( "MATK: " + (int)item.Data[(int)ItemData.MATK] + "<br>" ); } if ( (int)item.Data[(int)ItemData.PDEF] > 0 ) { sb.Append( "PDEF: " + (int)item.Data[(int)ItemData.PDEF] + "<br>" ); } if ( (int)item.Data[(int)ItemData.MDEF_or_HPHealPercent] > 0 ) { sb.Append( "MDEF: " + (int)item.Data[(int)ItemData.MDEF_or_HPHealPercent] + "<br>" ); } int agl1 = (int)item.Data[(int)ItemData.AGL_TPHealPercent]; int agl2 = (int)item.Data[(int)ItemData._AGL_Again]; if ( agl2 > 0 ) { sb.Append( "AGL: " + agl2 + "<br>" ); } if ( (int)item.Data[(int)ItemData._LUCK] > 0 ) { sb.Append( "LUCK: " + (int)item.Data[(int)ItemData._LUCK] + "<br>" ); } int attackElementCount = 0; int defenseElementCount = 0; for ( int i = 0; i < 6; ++i ) { if ( (int)item.Data[(int)ItemData.AttrFire + i] > 0 ) { attackElementCount++; } if ( (int)item.Data[(int)ItemData.AttrFire + i] < 0 ) { defenseElementCount++; } } if ( attackElementCount > 0 || defenseElementCount > 0 ) { int fire = (int)item.Data[(int)ItemData.AttrFire]; int watr = (int)item.Data[(int)ItemData.AttrWater]; int wind = (int)item.Data[(int)ItemData.AttrWind]; int eart = (int)item.Data[(int)ItemData.AttrEarth]; int lght = (int)item.Data[(int)ItemData.AttrLight]; int dark = (int)item.Data[(int)ItemData.AttrDark]; if ( defenseElementCount > 0 ) { sb.Append( "<table class=\"element\"><tr>" ); sb.Append( "<td colspan=\"" + defenseElementCount + "\">Resistance</td>" ); sb.Append( "</tr><tr>" ); if ( fire < 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-02.png\"></td>" ); } if ( eart < 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-04.png\"></td>" ); } if ( wind < 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-01.png\"></td>" ); } if ( watr < 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-05.png\"></td>" ); } if ( lght < 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-03.png\"></td>" ); } if ( dark < 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-06.png\"></td>" ); } sb.Append( "</tr><tr>" ); if ( fire < 0 ) { sb.Append( "<td>" + -fire + "%</td>" ); } if ( eart < 0 ) { sb.Append( "<td>" + -eart + "%</td>" ); } if ( wind < 0 ) { sb.Append( "<td>" + -wind + "%</td>" ); } if ( watr < 0 ) { sb.Append( "<td>" + -watr + "%</td>" ); } if ( lght < 0 ) { sb.Append( "<td>" + -lght + "%</td>" ); } if ( dark < 0 ) { sb.Append( "<td>" + -dark + "%</td>" ); } sb.Append( "</tr></table>" ); } if ( attackElementCount > 0 ) { sb.Append( "<table class=\"element\"><tr>" ); if ( category == 3 || category == 4 ) { // weapons and sub-weapons add elemental attributes to your attack sb.Append( "<td colspan=\"" + attackElementCount + "\">Attack Element</td>" ); } else { // defensive equipment instead uses this field as a weak/resist, with weak as positive and resist as negative values sb.Append( "<td colspan=\"" + attackElementCount + "\">Weakness</td>" ); } sb.Append( "</tr><tr>" ); if ( fire > 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-02.png\"></td>" ); } if ( eart > 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-04.png\"></td>" ); } if ( wind > 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-01.png\"></td>" ); } if ( watr > 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-05.png\"></td>" ); } if ( lght > 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-03.png\"></td>" ); } if ( dark > 0 ) { sb.Append( "<td><img src=\"text-icons/icon-element-06.png\"></td>" ); } if ( !( category == 3 || category == 4 ) ) { // weapons always have a "1" here, don't print that, it's not useful sb.Append( "</tr><tr>" ); if ( fire > 0 ) { sb.Append( "<td>" + fire + "%</td>" ); } if ( eart > 0 ) { sb.Append( "<td>" + eart + "%</td>" ); } if ( wind > 0 ) { sb.Append( "<td>" + wind + "%</td>" ); } if ( watr > 0 ) { sb.Append( "<td>" + watr + "%</td>" ); } if ( lght > 0 ) { sb.Append( "<td>" + lght + "%</td>" ); } if ( dark > 0 ) { sb.Append( "<td>" + dark + "%</td>" ); } } sb.Append( "</tr></table>" ); } } sb.Append( "</td><td>" ); for ( int i = 0; i < 3; ++i ) { uint skillId = item.Data[(int)ItemData.Skill1 + i * 2]; if ( skillId != 0 ) { var skill = skills.SkillIdDict[skillId]; var skillNameEntry = dict[skill.NameStringDicID]; string skillName = skillNameEntry.StringEngOrJpnHtml( version ); string skillCat = "<img src=\"skill-icons/category-" + skill.Category.ToString() + ".png\" height=\"16\" width=\"16\">"; sb.Append( skillCat ); sb.Append( "<a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Skill, version, phpLinks, id: (int)skill.InGameID ) + "\">" ); sb.Append( skillName ); sb.Append( "</a>, " + item.Data[(int)ItemData.Skill1Metadata + i * 2] + "<br>" ); } } sb.Append( "</td>" ); break; } sb.Append( "<td colspan=\"2\">" ); sb.Append( item.Data[(int)ItemData.ShopPrice] + " Gald" ); if ( item.Data[(int)ItemData.BuyableIn1] > 0 || item.Data[(int)ItemData.BuyableIn2] > 0 || item.Data[(int)ItemData.BuyableIn3] > 0 ) { //sb.Append( "<br>Available at shops in:" ); for ( int i = 0; i < 3; ++i ) { if ( item.Data[(int)ItemData.BuyableIn1 + i] > 0 ) { var loc = Locations.LocationIdDict[item.Data[(int)ItemData.BuyableIn1 + i]]; sb.Append( "<br><a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Location, version, phpLinks, id: (int)loc.LocationID ) + "\">" ); sb.Append( loc.GetLastValidName( dict ).StringEngOrJpnHtml( version ) + "</a>" ); } } sb.AppendLine(); } sb.Append( "</td></tr><tr>" ); // read how many drops and steals this item lists int[] dropStealCount = new int[2]; for ( int j = 0; j < 2; ++j ) { dropStealCount[j] = 0; for ( int i = 0; i < 16; ++i ) { uint enemyId = item.Data[(int)ItemData.Drop1Enemy + i + j * 32]; if ( enemyId != 0 ) { dropStealCount[j]++; } } } for ( int j = 0; j < 2; ++j ) { sb.Append( "<td colspan=\"2\">" ); if ( dropStealCount[j] > 0 ) { int colCount = Math.Min( 4, dropStealCount[j] ); int rowCount = ( dropStealCount[j] - 1 ) / 4 + 1; sb.Append( "<table class=\"element\">" ); sb.Append( "<tr><td colspan=\"" + colCount + "\">" ); sb.Append( j == 0 ? "Drop" : "Steal" ); sb.Append( "</td></tr>" ); int cellCount = 0; for ( int i = 0; i < 16; ++i ) { uint enemyId = item.Data[(int)ItemData.Drop1Enemy + i + j * 32]; if ( enemyId != 0 ) { if ( cellCount % 4 == 0 ) { sb.Append( "<tr>" ); } sb.Append( "<td>" ); var enemy = enemies.EnemyIdDict[enemyId]; var enemyNameEntry = dict[enemy.NameStringDicID]; string enemyName = enemyNameEntry.StringEngOrJpnHtml( version ); sb.Append( "<img src=\"monster-icons/44px/monster-" + enemy.IconID.ToString( "D3" ) + ".png\"><br>" ); sb.Append( "<a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Enemy, version, phpLinks, category: (int)enemy.Category, id: (int)enemy.InGameID ) + "\">" ); sb.Append( enemyName + "</a><br>" + item.Data[(int)ItemData.Drop1Chance + i + j * 32] + "%" ); sb.Append( "</td>" ); if ( cellCount % 4 == 3 ) { sb.Append( "</tr>" ); } cellCount++; } } if ( cellCount % 4 != 0 ) { if ( cellCount > 4 ) { for ( int i = cellCount % 4; i < 4; ++i ) { sb.Append( "<td></td>" ); } } sb.Append( "</tr>" ); } sb.Append( "</table>" ); } sb.Append( "</td>" ); } sb.Append( "</tr>" ); return sb.ToString(); }
private void Power_Click(object sender, EventArgs e) { int sum = 0; //converts the rows to integers for the cells for (int i = 0; i < dataGridView1.Rows.Count; i++) { sum += Convert.ToInt32(dataGridView1.Rows[i].Cells["heartrate"].Value); } int count_row = dataGridView1.Rows.Count; GetCalculations calc = new GetCalculations(); //use Get Calculations to determine average double avg = calc.CalculateAverage(sum, count_row); PowerTextBox.AppendText(Environment.NewLine); PowerTextBox.AppendText(Environment.NewLine + "Average heart rate: " + avg.ToString("N0")); var lines = File.ReadAllLines(openFileDialog1.FileName); foreach (var line in lines) { if (line.StartsWith("Lower3=")) { Lower3 = double.Parse(line.Replace("Lower3=", "")); PowerTextBox.AppendText(Environment.NewLine); PowerTextBox.AppendText(Environment.NewLine + "Threshhold Heartrate: " + Lower3); } if (line.StartsWith("Length=")) { Length = TimeSpan.Parse(line.Replace("Length=", "")); var time = Length.ToString(); //initiate variable for length of session double seconds = TimeSpan.Parse(time).TotalSeconds; double secondslength = seconds; //convert the time of session to seconds double dec_length = secondslength / 3600; // time of session as a decimal PowerTextBox.AppendText(Environment.NewLine); PowerTextBox.AppendText(Environment.NewLine + "Length of Workout: " + dec_length.ToString("N2")); } if (line.StartsWith("RestHR=")) { RestHR = double.Parse(line.Replace("RestHR=", "")); PowerTextBox.AppendText(Environment.NewLine); PowerTextBox.AppendText(Environment.NewLine + "Resting heart rate: " + RestHR); var time = Length.ToString(); //initiate variable for length of session double seconds = TimeSpan.Parse(time).TotalSeconds; double secondslength = seconds; //convert the time of session to seconds double dec_length = secondslength / 3600; // time of session as a decimal double TSS; PowerCalculation powercalc = new PowerCalculation(); TSS = powercalc.CalculateTSS(avg, RestHR, Lower3, dec_length); //TTS = powercalc.CalculateTSS(144, 46, 170, 1.1); these are actual figures from the file PowerTextBox.AppendText(Environment.NewLine); PowerTextBox.AppendText(Environment.NewLine + "Training Stress Score (TSS):" + "" + TSS.ToString("N2")); } } double NP; //normalised power double nnp = 168;; //in our case I used the average heart rate and not the rolling average heart rate PowerCalculation powercalc1 = new PowerCalculation(); NP = powercalc1.CalculateNP(nnp); double IFF; //Intensity Function double func = 320;; //function threshold as supplied by the client int sum4 = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) { sum4 += Convert.ToInt32(dataGridView1.Rows[i].Cells["power"].Value); } GetCalculations calc1 = new GetCalculations(); //use Get Calculations to determine average double avg4 = calc1.CalculateAverage(sum4, count_row); PowerCalculation powercalc2 = new PowerCalculation(); IFF = powercalc2.CalculateIF(avg4, func); PowerTextBox.AppendText(Environment.NewLine); PowerTextBox.AppendText(Environment.NewLine + "Normalised Power (NP):" + NP); PowerTextBox.AppendText(Environment.NewLine); PowerTextBox.AppendText(Environment.NewLine + "Intensity Factor (IF):" + IFF.ToString("N2")); MovingAverageCalculator calculator = new MovingAverageCalculator(30); // loop through the values 1 to 10 //for (int i = 1; i <= 10; i++) //{ // // write out the average // Console.WriteLine(calculator.NextValue(i)); //} //for (int i = 0; i < dataGridView1.Rows.Count; i++) //{ // float[] sumpower = new float[Convert.ToInt32(dataGridView1.Rows[i].Cells["power"].Value)]; // //PowerTextBox.AppendText(Environment.NewLine + calculator.NextValue(i)); // PowerTextBox.AppendText(Environment.NewLine + sumpower); //} }
private void TranslateRooms() { if (Patcher.TempFS.Exists("scenario_es.dat")) { return; } var PasswordString = Patcher.PatcherDataFS.ReadAllBytes("Text/password.txt").GetString(Encoding.UTF8).Trim(); //Console.WriteLine(PasswordString); //Console.ReadKey(); this.Patcher.ProgressHandler.AddProgressLevel("Traduciendo habitaciones", RoomCount, () => { FileSystem.CopyFile(Patcher.GameFileSystem, "language/scenario_uk.dat", Patcher.TempFS, "scenario_uk.dat"); var TO8SCEL = new TO8SCEL(Patcher.TempFS.OpenFileRW("scenario_uk.dat")); //TO8SCEL.Save(new MemoryStream()); //Patcher.GameAccessPath("language/scenario_uk.dat", () => Patcher.TempFS.CreateDirectory("SCENARIO_ES", 0777, false); Patcher.ParallelForeach //Patcher.Foreach ("Translating Room", Iterators.IntRange(0, RoomCount - 1), (RoomId) => RoomId.ToString(), (RoomId) => { var ScenarioTempFileName = ScenarioTempFileNamePrep + RoomId; if (!Patcher.TempFS.Exists(ScenarioTempFileName)) { if (TO8SCEL.Entries[RoomId].CompressedStream.Length > 0) { var Stream = TO8SCEL.Entries[RoomId].UncompressedStream; var RoomPath = String.Format("scenario/{0:D4}", RoomId); var Tss = new TSS().Load(Stream); Tss.TranslateTexts((Entry) => { var TextId = String.Format("{0:X8}", Entry.Id); if (Patcher.EntriesByRoom.ContainsKey(RoomPath)) { var TranslationRoom = Patcher.EntriesByRoom[RoomPath]; if (TranslationRoom.ContainsKey(TextId)) { var TranslationEntry = TranslationRoom[TextId]; Entry.TranslateWithTranslationEntry(TranslationEntry); } else { Console.Error.WriteLine("Missing Translation {0} : {1:X8} : {2:X8} : {3:X8}", RoomPath, Entry.Id, Entry.Id2, Entry.Id3); } } else { Console.Error.WriteLine("Missing Room"); } }, (Text) => { if (RoomId == 192) { //Console.WriteLine("{0}", Text); if (Text == "sun") { return(PasswordString); } } if (RoomId == 31 || RoomId == 35) { //Console.WriteLine("{0}", Text); if (Text == "1st") { return("1ª"); } if (Text == "2nd") { return("2ª"); } if (Text == "Last") { return("Última"); } if (Text == "%s Battle") { return("%s batalla"); } if (Text == "%s?\n") { return("¿%s?\n"); } } if (RoomId == 1256 || RoomId == 1257 || RoomId == 1258 || RoomId == 1259 || RoomId == 1260 || RoomId == 1271 || RoomId == 1272 || RoomId == 1273) { if (Text == "SELECT") { return("Selección"); } } //Los siguientes textos no se pueden arreglar con este método, ya que ni si quiera se cargan (Text nunca será "1st Battle", etc.) //Investigando cómo van los TSS, he visto que la mayoría (o todos) los textos se cargan con un Opcode.PUSH_ARRAY //Por lo visto el programa solamente procesa por ahora las entradas que tienen 6 elementos. (TSS.HandleTexts()) //En este caso, también se gestiona con un PUSH_ARRAY, pero distinto. Para empezar, los textos ya no son ValueType.String (0xC), //si no 0x2C. ¿Otro tipo de strings? Y contienen 3 elementos. He intentado apañar el asunto, y aunque he conseguido leer esos textos, //no me veo capaz de meterme en semejante inmensidad de código ajeno sin romper nada. Así que por ahora prefiero hacer un método //cutre que no implique modificar nada existente. Este método está en la función FixTexts() /*if (RoomId == 344 || RoomId == 1331) * { * if (Text == "1st Battle") return "Ronda 1"; * if (Text == "2st Battle") return "Ronda 2"; //Sí, en inglés hay una errata. * if (Text == "Last Battle") return "Última ronda"; * }*/ return(null); }); //if (RoomId == 192) Console.ReadKey(); Patcher.TempFS.WriteAllBytes(ScenarioTempFileName, Tss.Save().ToArray()); } else { //Console.WriteLine("CompressedStream.Length = 0"); } } this.Patcher.ProgressHandler.IncrementLevelProgress(); }); //FileSystem.CopyFile(Patcher.TempFS, "scenario_es.dat", Patcher.TempFS, "scenario_es.dat.finished"); }); }
public string GetDataAsHtml( GameVersion version, COOKDAT recipes, ItemDat.ItemDat items, TSS.TSSFile stringDic, Dictionary<uint, TSS.TSSEntry> inGameIdDict, bool phpLinks = false ) { StringBuilder sb = new StringBuilder(); sb.Append( "<tr id=\"recipe" + ID + "\"><td>" ); sb.Append( "<img src=\"recipes/U_" + RefString + ".png\">" ); sb.Append( "</td><td>" ); sb.Append( "<span class=\"itemname\">" + inGameIdDict[NameStringDicID].StringJpnHtml( version ) + "</span><br>" ); sb.Append( inGameIdDict[DescriptionStringDicID].StringJpnHtml( version ) + "<br>" ); sb.Append( inGameIdDict[EffectStringDicID].StringJpnHtml( version ) + "<br>" ); sb.Append( "<br>" ); sb.Append( "<span class=\"itemname\">" + inGameIdDict[NameStringDicID].StringEngHtml( version ) + "</span><br>" ); sb.Append( inGameIdDict[DescriptionStringDicID].StringEngHtml( version ) + "<br>" ); sb.Append( inGameIdDict[EffectStringDicID].StringEngHtml( version ) + "<br>" ); sb.Append( "</td><td>" ); for ( int i = 0; i < IngredientGroups.Length; ++i ) { if ( IngredientGroups[i] != 0 ) { uint stringDicId; stringDicId = IngredientGroupDict[IngredientGroups[i]]; var entry = inGameIdDict[stringDicId]; sb.Append( "<img src=\"item-icons/ICON" + IngredientGroups[i] + ".png\" height=\"16\" width=\"16\"> " ); sb.Append( entry.StringEngOrJpnHtml( version ) + " x" + IngredientGroupCount[i] + "<br>" ); } } for ( int i = 0; i < Ingredients.Length; ++i ) { if ( Ingredients[i] != 0 ) { var item = items.itemIdDict[Ingredients[i]]; sb.Append( "<img src=\"item-icons/ICON" + item.Data[(int)ItemData.Icon] + ".png\" height=\"16\" width=\"16\"> " ); sb.Append( "<a href=\"" + Website.GenerateWebsite.GetUrl( Website.WebsiteSection.Item, version, phpLinks, id: (int)item.Data[(int)ItemData.ID], icon: (int)item.Data[(int)ItemData.Icon] ) + "\">" ); sb.Append( inGameIdDict[item.NamePointer].StringEngOrJpnHtml( version ) + "</a> x" + IngredientCount[i] + "<br>" ); } } sb.Append( "</td><td>" ); if ( HP > 0 ) { sb.Append( "HP Heal: " + HP + "%<br>" ); } if ( TP > 0 ) { sb.Append( "TP Heal: " + TP + "%<br>" ); } if ( PhysicalAilmentHeal > 0 || DeathHeal > 0 ) { sb.Append( "Cures Ailments: " ); if ( DeathHeal > 0 ) { sb.Append( "<img src=\"text-icons/icon-status-13.png\" height=\"16\" width=\"16\" title=\"Death\">" ); } if ( ( PhysicalAilmentHeal & 1 ) == 1 ) { sb.Append( "<img src=\"text-icons/icon-status-01.png\" height=\"16\" width=\"16\" title=\"Poison\">" ); } if ( ( PhysicalAilmentHeal & 2 ) == 2 ) { sb.Append( "<img src=\"text-icons/icon-status-07.png\" height=\"16\" width=\"16\" title=\"Contamination\">" ); } if ( ( PhysicalAilmentHeal & 4 ) == 4 ) { sb.Append( "<img src=\"text-icons/icon-status-02.png\" height=\"16\" width=\"16\" title=\"Paralysis\">" ); } if ( ( PhysicalAilmentHeal & 8 ) == 8 ) { sb.Append( "<img src=\"text-icons/icon-status-03.png\" height=\"16\" width=\"16\" title=\"Petrification\">" ); } if ( ( PhysicalAilmentHeal & 16 ) == 16 ) { sb.Append( "<img src=\"text-icons/icon-status-04.png\" height=\"16\" width=\"16\" title=\"Weakness\">" ); } if ( ( PhysicalAilmentHeal & 32 ) == 32 ) { sb.Append( "<img src=\"text-icons/icon-status-05.png\" height=\"16\" width=\"16\" title=\"Sealed Artes\">" ); } if ( ( PhysicalAilmentHeal & 64 ) == 64 ) { sb.Append( "<img src=\"text-icons/icon-status-06.png\" height=\"16\" width=\"16\" title=\"Sealed Skills\">" ); } sb.Append( "<br>" ); } if ( StatValue > 0 ) { //sb.Append( "Stat Type: " + StatType + "<br>" ); switch ( StatType ) { case 1: sb.Append( "P. ATK" ); break; case 2: sb.Append( "P. DEF" ); break; case 3: sb.Append( "M. ATK" ); break; case 4: sb.Append( "M. DEF" ); break; case 5: sb.Append( "AGL" ); break; case 11: sb.Append( "Over Limit gauge increases<br>" ); break; } if ( StatType != 11 ) { sb.Append( " +" + StatValue + ( StatType < 5 ? "%" : "" ) + "<br>" ); sb.Append( "Duration: " + StatTime + " seconds<br>" ); } } if ( RecipeCreationCharacter.Count( x => x != 0 ) > 0 ) { sb.Append( "Recipe Evolutions:<br>" ); for ( int i = 0; i < RecipeCreationCharacter.Length; ++i ) { if ( RecipeCreationCharacter[i] != 0 ) { var otherRecipe = recipes.RecipeList[(int)RecipeCreationRecipe[i]]; Website.GenerateWebsite.AppendCharacterBitfieldAsImageString( sb, version, (uint)( 1 << (int)( RecipeCreationCharacter[i] - 1 ) ) ); sb.Append( " <a href=\"#recipe" + otherRecipe.ID + "\">" ); sb.Append( inGameIdDict[otherRecipe.NameStringDicID].StringEngOrJpnHtml( version ) ); sb.Append( "</a>" ); sb.Append( "<br>" ); } } } sb.Append( "<table class=\"element\">" ); sb.Append( "<tr>" ); sb.Append( "<td>Likes</td>" ); sb.Append( "<td>Dislikes</td>" ); sb.Append( "</tr>" ); sb.Append( "<tr>" ); sb.Append( "<td>" ); Website.GenerateWebsite.AppendCharacterBitfieldAsImageString( sb, version, CharactersLike ); sb.Append( "</td>" ); sb.Append( "<td>" ); Website.GenerateWebsite.AppendCharacterBitfieldAsImageString( sb, version, CharactersDislike ); sb.Append( "</td>" ); sb.Append( "</tr>" ); sb.Append( "<tr>" ); sb.Append( "<td>Good at</td>" ); sb.Append( "<td>Bad at</td>" ); sb.Append( "</tr>" ); sb.Append( "<tr>" ); sb.Append( "<td>" ); Website.GenerateWebsite.AppendCharacterBitfieldAsImageString( sb, version, CharactersGoodAtMaking ); sb.Append( "</td>" ); sb.Append( "<td>" ); Website.GenerateWebsite.AppendCharacterBitfieldAsImageString( sb, version, CharactersBadAtMaking ); sb.Append( "</td>" ); sb.Append( "</tr>" ); sb.Append( "</table>" ); sb.Append( "</td></tr>" ); return sb.ToString(); }
public string GetDataAsHtml( GameVersion version, T8BTTA strategy, TSS.TSSFile stringDic, Dictionary<uint, TSS.TSSEntry> inGameIdDict ) { StringBuilder sb = new StringBuilder(); //sb.Append( RefString ); sb.Append( "<tr>" ); sb.Append( "<td colspan=\"5\">" ); sb.Append( "<span class=\"itemname\">" ); sb.Append( inGameIdDict[NameStringDicID].StringJpnHtml( version ) ); sb.Append( "</span>" ); sb.Append( "<br>" ); sb.Append( inGameIdDict[DescStringDicID].StringJpnHtml( version ) ); sb.Append( "</td>" ); sb.Append( "<td colspan=\"5\">" ); sb.Append( "<span class=\"itemname\">" ); sb.Append( inGameIdDict[NameStringDicID].StringEngHtml( version ) ); sb.Append( "</span>" ); sb.Append( "<br>" ); sb.Append( inGameIdDict[DescStringDicID].StringEngHtml( version ) ); sb.Append( "</td>" ); sb.Append( "</tr>" ); sb.Append( "<tr>" ); sb.Append( "<td>" ); sb.Append( "</td>" ); for ( int i = 0; i < StrategyDefaults.GetLength( 1 ); ++i ) { sb.Append( "<td class=\"strategychar\">" ); Website.GenerateWebsite.AppendCharacterBitfieldAsImageString( sb, version, 1u << i ); sb.Append( "</td>" ); } sb.Append( "</tr>" ); for ( uint xRaw = 0; xRaw < StrategyDefaults.GetLength( 0 ); ++xRaw ) { uint x = xRaw; // swap around OVL and FS because they're stored the wrong way around compared to how they show up ingame if ( x == 6 ) { x = 7; } else if ( x == 7 ) { x = 6; } sb.Append( "<tr>" ); sb.Append( "<td>" ); sb.Append( "<span class=\"strategycat\">" ); sb.Append( GetCategoryName( x, version, inGameIdDict ) ); sb.Append( "</span>" ); sb.Append( "</td>" ); for ( uint y = 0; y < StrategyDefaults.GetLength( 1 ); ++y ) { if ( version == GameVersion.X360 && y == 8 ) { continue; } sb.Append( "<td>" ); var option = strategy.StrategyOptionDict[StrategyDefaults[x, y]]; sb.Append( inGameIdDict[option.NameStringDicID].StringEngOrJpnHtml( version ) ); sb.Append( "</td>" ); } sb.Append( "</tr>" ); } //sb.Append( "<td>" ); //for ( int i = 0; i < UnknownFloats1.Length; ++i ) { // sb.Append( UnknownFloats1[i] + " / " ); //} //sb.Append( "<br>" ); //for ( int i = 0; i < UnknownFloats2.Length; ++i ) { // sb.Append( UnknownFloats2[i] + " / " ); //} //sb.Append( "</td>" ); return sb.ToString(); }
// メイン ロジック #region 生成処理 /// <summary>D層、Daoクラスファイル、SQLファイルを生成する。</summary> private void btnDaoAndSqlGen_Click(object sender, EventArgs e) { // D層定義情報ファイル StreamReader srDaoDef = null; // ↓↓↓【追加】↓↓↓ // .NET型定義情報ファイル StreamReader srTypeDef = null; // DTO生成フラグの初期化 this.CreateDTO = (this.cbxEntity.Checked || this.cbxTypedDataSet.Checked); // メンテナンス画面生成フラグの初期化 this.CreateMaintenanceScreen = (this.cbxOnlyTableMaintenance.Checked || this.cbxTableMaintenance.Checked); // ↑↑↑【追加】↑↑↑ // ↓↓↓【追加】↓↓↓ // DB型定義情報ファイル StreamReader srDbTypeDef = null; // DB型定義情報ファイル読み込みフラグ設定 this.ReadDbTypeInfo = (this.ReadDbTypeInfo || rbnODP.Checked); // ↑↑↑【追加】↑↑↑ try { // カーソルを待機状態にする System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; #region 拡張子の設定 if (this.rbnDTL_CS.Checked) { // Visual C# this.ClassTemplateFileExtension = "cs"; this.CodebehindLanguage = "C#"; this.CommentOut = "//"; } else { // Visual Basic this.ClassTemplateFileExtension = "vb"; this.CodebehindLanguage = "VB"; this.CommentOut = "'"; } #endregion #region チェック処理 FileInfo fileInfo = null; DirectoryInfo dirInfo = null; #region D層定義情報ファイル // 標準生成 fileInfo = new FileInfo(this.txtSetDaoDefinition.Text); if (fileInfo.Exists) { } else { //MessageBox.Show(string.Format("チェックエラーです:D層定義情報ファイル[{0}]が存在しません。", fileInfo.Name)); MessageBox.Show(string.Format(this.RM_GetString("FilenotExistDlayerInfo"), fileInfo.Name)); return; } // ↓↓↓【追加】↓↓↓ // +エンティテイ生成+型付きデータセット生成 if (this.CreateDTO) { // *.CSVである前提の仕様だがOKか?(一応ファイル名を出力する) int temp = this.txtSetDaoDefinition.Text.Length - 4; this.DotNetTypeInfoFilePath = this.txtSetDaoDefinition.Text.Substring(0, temp) + "_DotNetTypeInfo" + this.txtSetDaoDefinition.Text.Substring(temp); fileInfo = new FileInfo(this.DotNetTypeInfoFilePath); if (fileInfo.Exists) { } else { //MessageBox.Show(string.Format("チェックエラーです:.NET型情報ファイル[{0}]が存在しません。", fileInfo.Name)); MessageBox.Show(string.Format(this.RM_GetString("FilenotExistNETtypeInfo"), fileInfo.Name)); return; } } // ↑↑↑【追加】↑↑↑ // ↓↓↓【追加】↓↓↓ // DB型情報ファイル読み込み if (this.ReadDbTypeInfo) { // *.CSVである前提の仕様だがOKか?(一応ファイル名を出力する) int temp = this.txtSetDaoDefinition.Text.Length - 4; this.DbTypeInfoFilePath = this.txtSetDaoDefinition.Text.Substring(0, temp) + "_DBTypeInfo" + this.txtSetDaoDefinition.Text.Substring(temp); fileInfo = new FileInfo(this.DbTypeInfoFilePath); if (fileInfo.Exists) { } else { //MessageBox.Show(string.Format("チェックエラーです:DB型情報ファイル[{0}]が存在しません。", fileInfo.Name)); MessageBox.Show(string.Format(this.RM_GetString("FilenotExistDBtypeInfo"), fileInfo.Name)); return; } } // ↑↑↑【追加】↑↑↑ #endregion #region 入力ファイル dirInfo = new DirectoryInfo(this.txtSetSourceTemplate.Text); if (dirInfo.Exists) { } else { //MessageBox.Show("入力ファイル(テンプレート ファイル)のルート フォルダが存在しません。"); MessageBox.Show(this.RM_GetString("InputFileRootFolderNotExist")); return; } #region Dao、Entity、DataSetテンプレート ファイル // Daoテンプレート ファイル if (!this.cbxOnlyDTO.Checked && !this.cbxOnlyTableMaintenance.Checked) { this.DaoTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.DaoTemplateFileName, this.ClassTemplateFileExtension); } // ↓↓↓【追加】↓↓↓ if (this.CreateDTO) { // Entityテンプレート ファイル this.EntityTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.EntityTemplateFileName, this.ClassTemplateFileExtension); // DataSetテンプレート ファイル this.DataSetTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.DataSetTemplateFileName, ""); } if (this.CreateMaintenanceScreen) { // TableAdapterテンプレート ファイル this.TableAdapterTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.TableAdapterTemplateFileName, this.ClassTemplateFileExtension); // ConditionalSearchテンプレート ファイル this.ConditionalSearchTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.ConditionalSearchTemplateFileName, ""); // SearchAndUpdateテンプレート ファイル this.SearchAndUpdateTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.SearchAndUpdateTemplateFileName, ""); // Detailテンプレート ファイル this.DetailTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.DetailTemplateFileName, ""); } // ↑↑↑【追加】↑↑↑ #endregion if (!this.cbxOnlyDTO.Checked && !this.cbxOnlyTableMaintenance.Checked) { #region SQLテンプレート ファイル(静的) this.InsertTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.InsertTemplateFileName, ""); this.SelectTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.SelectTemplateFileName, ""); this.UpdateTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.UpdateTemplateFileName, ""); this.DeleteTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.DeleteTemplateFileName, ""); #endregion #region SQLテンプレート ファイル(動的) this.DynInsTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.DynInsTemplateFileName, ""); this.DynSelTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.DynSelTemplateFileName, ""); this.DynUpdTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.DynUpdTemplateFileName, ""); this.DynDelTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.DynDelTemplateFileName, ""); // ↓↓↓【追加】↓↓↓ this.DynSelCntTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.DynSelCntTemplateFileName, ""); // ↑↑↑【追加】↑↑↑ #endregion } #endregion #region 出力ファイル dirInfo = new DirectoryInfo(this.txtSetOutput.Text); if (dirInfo.Exists) { } else { //MessageBox.Show("出力ファイル(Daoクラス ファイル、SQLファイル.etc)のルート フォルダが存在しません。"); MessageBox.Show(this.RM_GetString("OutputFileRootFolderNotExist")); return; } #endregion #region Like検索用エスケープ文字 // ↓↓↓【追加】↓↓↓ //エスケープ文字のチェック if (rbnODP.Checked == true && txtEscapeChar.Text.Length != 1) { //Oracle ODP.NET かつ エスケープ文字が入力されていない(1文字でない)場合 //MessageBox.Show("エスケープ文字が設定されていません。"); MessageBox.Show(this.RM_GetString("EscCharacterNotSet")); return; } // ↑↑↑【追加】↑↑↑ #endregion #region タイムスタンプ列 // タイムスタンプ列名を取得 this.TimeStampColName = this.txtTimeStampColName.Text.Trim(); // タイムスタンプ更新方法を取得 this.TimeStampUpdMethod = this.txtTimeStampUpdMethod.Text.Trim(); // タイムスタンプの設定ステータスのチェック&設定 if (this.TimeStampColName == "" & this.TimeStampUpdMethod == "") { // なにもない。 this.TimeStampStatus = TSS.Non; } else if (this.TimeStampColName != "" & this.TimeStampUpdMethod == "") { // 名前だけある。 this.TimeStampStatus = TSS.Name; } else if (this.TimeStampColName != "" & this.TimeStampUpdMethod != "") { // 名前と更新方法の両方がある。 this.TimeStampStatus = TSS.NandM; } else { // 更新方法だけある。 //MessageBox.Show("タイムスタンプ列名がありません。"); MessageBox.Show(this.RM_GetString("NoTimestampColName")); return; } #endregion #endregion #region 生成処理(将来的に関数化しても良い) #region 固定情報の設定 // 日付 this.TimeStamp = DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day; // ユーザ名 this.UserName = this.txtFamilyName.Text + " " + this.txtPersonalName.Text; //// エンコーディング(XML用) this.XMLEncoding = this.cmbSFEncoding.Text; // SQLの制御文字 if (rbnSQL.Checked || rbnOLE.Checked || rbnODB.Checked) { this.ParamSign = '@'; this.EnclosureCharS = '['; this.EnclosureCharE = ']'; } else if (rbnODP.Checked) { this.ParamSign = ':'; this.EnclosureCharS = '"'; this.EnclosureCharE = '"'; } else if (rbnDB2.Checked) { this.ParamSign = '@'; this.EnclosureCharS = '"'; this.EnclosureCharE = '"'; } else if (rbnMySQL.Checked) { this.ParamSign = '@'; this.EnclosureCharS = '`'; this.EnclosureCharE = '`'; } else if (rbnPstgrs.Checked) { // Npgsqlでは、「@」・「:」の双方をサポートするが、 // 本Fxでは、「:」を選択(動作がOracleに近いため)。 this.ParamSign = '@'; // PostgreSQLでは、表名を囲えないので注意。 this.EnclosureCharS = '"'; this.EnclosureCharE = '"'; } else { // 他(ありえない) } #endregion #region D層定義情報ファイル読取変数 // D層定義情報ファイル・.NET型定義情報ファイルを開く this.OpenSrDefInfo(out srDaoDef, out srTypeDef, out srDbTypeDef); // D層定義情報ファイルから読んだ1行 string rlDaoDef = ""; string[] rlDaoDef2 = null; // ↓↓↓【追加】↓↓↓ // .NET型定義情報ファイルから読んだ1行 string rlTypeDef = ""; string[] rlTypeDef2 = null; // ↑↑↑【追加】↑↑↑ // ↓↓↓【追加】↓↓↓ // DB型定義情報ファイルから読んだ1行 string rlDbTypeDef = ""; string[] rlDbTypeDef2 = null; // ↑↑↑【追加】↑↑↑ #endregion #region D層定義情報ファイル ヘッダー制御 if (this.cbxDaoDefinitionHeader.Checked) { // ヘッダーは、無視 if (!srDaoDef.EndOfStream) { rlDaoDef = srDaoDef.ReadLine(); } // ↓↓↓【追加】↓↓↓ if (this.CreateDTO) { if (!srTypeDef.EndOfStream) { rlTypeDef = srTypeDef.ReadLine(); } } // ↑↑↑【追加】↑↑↑ // ↓↓↓【追加】↓↓↓ if (this.ReadDbTypeInfo) { if (!srDbTypeDef.EndOfStream) { rlDbTypeDef = srDbTypeDef.ReadLine(); } } // ↑↑↑【追加】↑↑↑ } else { // ヘッダーは、無し } #endregion #region データがなくなるまでループ while (!srDaoDef.EndOfStream) { // 消しました(2行目でやってないので)。 //// null・空文字チェック ////(.NET型定義情報はD層定義情報に合わせる //if (string.IsNullOrEmpty(rlDaoDef)) //{ // // スキップ // continue; //} // 1行読込 rlDaoDef = srDaoDef.ReadLine(); rlDaoDef2 = rlDaoDef.Split(','); // ↓↓↓【追加】↓↓↓ if (this.CreateDTO) { rlTypeDef = srTypeDef.ReadLine(); rlTypeDef2 = rlTypeDef.Split(','); } // ↑↑↑【追加】↑↑↑ // ↓↓↓【追加】↓↓↓ if (this.ReadDbTypeInfo) { rlDbTypeDef = srDbTypeDef.ReadLine(); rlDbTypeDef2 = rlDbTypeDef.Split(','); } // ↑↑↑【追加】↑↑↑ if (rlDaoDef2[0] != "") { // テーブル名の退避 this.TableName = rlDaoDef2[0].Trim(); #region 生成準備 #region 主キー列の情報の収集 // 初期化 this.PK_Columns = new ArrayList(); this.PK_ColumnsType = new ArrayList(); this.PK_ColumnsDbType = new ArrayList(); // 長さが2以上の場合、主キー列を取りに行く。 if (rlDaoDef2.Length >= 2) { for (int i = 1; i < rlDaoDef2.Length; i++) { if (rlDaoDef2[i] == "") { break; } this.PK_Columns.Add(rlDaoDef2[i].Trim()); } } // ↓↓↓【追加】↓↓↓ if (this.CreateDTO) { if (rlTypeDef2.Length >= 2) { for (int i = 1; i < rlTypeDef2.Length; i++) { if (rlTypeDef2[i] == "") { break; } this.PK_ColumnsType.Add(rlTypeDef2[i].Trim()); } } } // ↑↑↑【追加】↑↑↑ // ↓↓↓【追加】↓↓↓ if (this.ReadDbTypeInfo) { if (rlDbTypeDef2.Length >= 2) { for (int i = 1; i < rlDbTypeDef2.Length; i++) { if (rlDbTypeDef2[i] == "") { break; } this.PK_ColumnsDbType.Add(rlDbTypeDef2[i].Trim()); } } } // ↑↑↑【追加】↑↑↑ // チェック処理(主キー列が無い) if (PK_Columns.Count == 0) { throw new CheckException( //this.TableName + "テーブルに主キーが定義されていません。"); this.TableName + this.RM_GetString("PrimaryKeyNotDefined")); } #endregion // 2行目(その他の列情報)を読む。 rlDaoDef = srDaoDef.ReadLine(); rlDaoDef2 = rlDaoDef.Split(','); // ↓↓↓【追加】↓↓↓ if (this.CreateDTO) { rlTypeDef = srTypeDef.ReadLine(); rlTypeDef2 = rlTypeDef.Split(','); } // ↑↑↑【追加】↑↑↑ // ↓↓↓【追加】↓↓↓ if (this.ReadDbTypeInfo) { rlDbTypeDef = srDbTypeDef.ReadLine(); rlDbTypeDef2 = rlDbTypeDef.Split(','); } // ↑↑↑【追加】↑↑↑ #region 主キー以外の列情報の収集 // 初期化 this.ELSE_Columns = new ArrayList(); this.ELSE_ColumnsType = new ArrayList(); this.ELSE_ColumnsDbType = new ArrayList(); // チェック処理(テーブル名に値が入っている) if (rlDaoDef2[0].Trim() != "") { throw new CheckException( //"不正なフォーマットです。" this.RM_GetString("InvalidFormat") + this.TableName + ":" + rlDaoDef); } // 長さが2以上の場合、主キー以外の列情報を取りに行く。 if (rlDaoDef2.Length >= 2) { for (int i = 1; i < rlDaoDef2.Length; i++) { if (rlDaoDef2[i] == "") { break; } this.ELSE_Columns.Add(rlDaoDef2[i].Trim()); } } // ↓↓↓【追加】↓↓↓ if (this.CreateDTO) { if (rlTypeDef2.Length >= 2) { for (int i = 1; i < rlTypeDef2.Length; i++) { if (rlTypeDef2[i] == "") { break; } this.ELSE_ColumnsType.Add(rlTypeDef2[i].Trim()); } } } // ↑↑↑【追加】↑↑↑ // ↓↓↓【追加】↓↓↓ if (this.ReadDbTypeInfo) { if (rlDbTypeDef2.Length >= 2) { for (int i = 1; i < rlDbTypeDef2.Length; i++) { if (rlDbTypeDef2[i] == "") { break; } this.ELSE_ColumnsDbType.Add(rlDbTypeDef2[i].Trim()); } } } // ↑↑↑【追加】↑↑↑ #endregion #endregion #region コメント #region 共通 #region(1)共通 静的カラム リスト // ● タイムスタンプ状態(Non、Name、NandM) // 例:[aaa], // [bbb], // [ccc], // [ddd], // [eee] ~ // ※ カンマ区切りにして後で、 // [,] → [,] + [\r\n] + [インデント]と置換する。 #endregion #region(2)共通 静的 検索条件 ★ // ● タイムスタンプ状態(Non) // 例:[aaa] = @aaa, [aaa] = @aaa // [bbb] = @bbb, AND [bbb] = @bbb // [ccc] = @ccc, → AND [ccc] = @ccc // [ddd] = @ddd, AND [ddd] = @ddd // [eee] = @eee ~ AND [eee] = @eee ~ // ※ 主キーの列のみ対象とするので、IS NULLは不要 // ※ カンマ区切りにして後で、 // [,] → [\r\n] + [インデント] + [AND ]と置換する。 // ↓ // // ● タイムスタンプ状態(Name、NandM) // 例:[aaa] = @aaa // AND [bbb] = @bbb // AND [ccc] = @ccc // AND [ddd] = @ddd // ★ <IF>AND [eee] = @eee</IF> ~ // ※ タイムスタンプ列が有る場合は、それも対象にする。 // ※ タイムスタンプ状態によっては、 // 「AND [eee] = @eee」 → 「<IF>AND [eee] = @eee</IF>」と置換する。 #endregion #region(3)共通 動的 検索条件 // 例:<IF>AND [aaa] = @aaa<ELSE>[aaa] IS NILL</ELSE></IF>, // <IF>AND [bbb] = @bbb<ELSE>[bbb] IS NILL</ELSE></IF>, // <IF>AND [ccc] = @ccc<ELSE>[ccc] IS NILL</ELSE></IF>, // <IF>AND [ddd] = @ddd<ELSE>[ddd] IS NILL</ELSE></IF>, // <IF>AND [eee] = @eee<ELSE>[eee] IS NILL</ELSE></IF> ~ // ※ カンマ区切りにして後で、 // [>,] → [>] + [\r\n] + [インデント]と置換する。 #endregion #region(4)共通 動的SET句リスト ★ // ● タイムスタンプ状態(Non、Name) // 例:<IF>[aaa] = @Set_aaa_Upd,</IF>, // <IF>[bbb] = @Set_bbb_Upd,</IF>, // <IF>[ccc] = @Set_ccc_Upd,</IF>, // <IF>[ddd] = @Set_ddd_Upd,</IF>, // <IF>[eee] = @Set_eee_Upd,</IF> ~ // ※ カンマ区切りにして後で、 // [>,] → [>] + [\r\n] + [インデント]と置換する。 // ↓ // ● タイムスタンプ状態(NandM) // 例:<IF>[aaa] = @Set_aaa_Upd,</IF>, // <IF>[bbb] = @Set_bbb_Upd,</IF>, // <IF>[ccc] = @Set_ccc_Upd,</IF>, // <IF>[ddd] = @Set_ddd_Upd,</IF>, // [eee] = SYSTIMESTAMP(), ~ // ※ タイムスタンプ状態によっては、 // 「<IF>[eee] = @Set_eee_Upd,</IF>」 → 「[eee] = SYSTIMESTAMP(),」と置換する。 #endregion #endregion #region 個別 #region(5)Insert用パラメタ リスト ★ // ● タイムスタンプ状態(Non、Name) // 例:@aaa, // @bbb, // @ccc, // @ddd, // @eee ~ // ※ カンマ区切りにして後で、 // [,] → [,] + [\r\n] + [インデント]と置換する。 // ↓ // ● タイムスタンプ状態(NandM) // 例:@aaa, // @bbb, // @ccc, // @ddd, // SYSTIMESTAMP() ~ // ※ タイムスタンプ状態によっては、 // 「@eee」 → 「SYSTIMESTAMP()」と置換する。 #endregion #region(6)DynIns用カラム リスト ★ // ● タイムスタンプ状態(Non、Name) // 例:<INSCOL name="aaa">[aaa],</INSCOL>, // <INSCOL name="bbb">[bbb],</INSCOL>, // <INSCOL name="ccc">[ccc],</INSCOL>, // <INSCOL name="ddd">[ddd],</INSCOL>, // <INSCOL name="eee">[eee],</INSCOL> ~ // ※ カンマ区切りにして後で、 // [>,] → [>] + [\r\n] + [インデント]と置換する。 // ↓ // ● タイムスタンプ状態(NandM) // 例:<INSCOL name="aaa">[aaa],</INSCOL>, // <INSCOL name="bbb">[bbb],</INSCOL>, // <INSCOL name="ccc">[ccc],</INSCOL>, // <INSCOL name="ddd">[ddd],</INSCOL>, // [eee], ~ // ※ タイムスタンプ状態によっては、 // 「<INSCOL name="eee">[eee],</INSCOL>」 → 「[eee],」と置換する。 #endregion #region(7)DynIns用パラメタ リスト ★ // ● タイムスタンプ状態(Non、Name) // 例:<IF>@aaa,</IF>, // <IF>@bbb,</IF>, // <IF>@ccc,</IF>, // <IF>@ddd,</IF>, // <IF>@eee,</IF> ~ // ※ カンマ区切りにして後で、 // [>,] → [>] + [\r\n] + [インデント]と置換する。 // ↓ // ● タイムスタンプ状態(NandM) // 例:<IF>@aaa,</IF>, // <IF>@bbb,</IF>, // <IF>@ccc,</IF>, // <IF>@ddd,</IF>, // SYSTIMESTAMP(), ~ // ※ タイムスタンプ状態によっては、 // 「<IF>@eee,</IF>」 → 「SYSTIMESTAMP(),」と置換する。 #endregion #endregion #endregion #region 初期化 //(1)共通 静的カラム リスト this.AllColumnListSQL = ""; this.PKColumnListSQL = ""; //(2)共通 静的 検索条件 ★ this.ColumnsCondition = ""; //(3)共通 動的 検索条件 this.DynColsCondition = ""; // ↓↓↓【追加】↓↓↓ //(3.5)共通 動的 曖昧検索条件 this.DynColsCondition_Like = ""; // ↑↑↑【追加】↑↑↑ //(4)共通 動的更新SET句リスト ★ this.DynUpdParameters = ""; //(5)Insert用パラメタ リスト ★ this.InsertParameters = ""; //(6)DynIns用カラム リスト ★ this.DynInsColumns = ""; //(7)DynIns用パラメタ リスト ★ this.DynInsParameters = ""; // その他、ColumnList this.AllColumnList = ""; this.PKColumnList = ""; this.PKFirstColumn = ""; this.AllColumnListTableAdapterSQL = ""; #endregion #region 生成処理 // 主キー列 for (int index = 0; index < this.PK_Columns.Count; index++) { string col = (string)PK_Columns[index]; string dbType = ""; if (this.ReadDbTypeInfo == true) { dbType = (string)PK_ColumnsDbType[index]; } // 連結 this.CreateString(col, dbType, true); } // 主キー以外の列 for (int index = 0; index < this.ELSE_Columns.Count; index++) { string col = (string)ELSE_Columns[index]; string dbType = ""; if (this.ReadDbTypeInfo == true) { dbType = (string)ELSE_ColumnsDbType[index]; } // 連結 this.CreateString(col, dbType, false); } // ↑↑↑【修正】↑↑↑ // 最後のカンマを削除する。 this.DeleteLastComma(); #endregion // Daoクラス名 this.DaoClassName = this.DaoClassNameHeader + this.TableName.Replace(' ', '_') + this.DaoClassNameFooter; // DTO、メンテナンス画面のみの場合はDao、SQLは生成しない。 if (!(this.cbxOnlyDTO.Checked || this.cbxOnlyTableMaintenance.Checked)) { #region SQLファイルを生成 // メソッド名、SQLファイル名はDaoファイル用であるが、 // SQLファイル用に流用するため、このブロックで生成。 #region Insertの処理 // メソッド名 this.InsertMethodName = this.MethodNameHeaderS + this.MethodLabel_Ins + this.MethodNameFooterS; // SQLファイル名(保持用ワーク) this.InsertFileName = this.DaoClassName + "_" + this.InsertMethodName; // ファイル名(テンポラリ・カレント) this.FileName = this.InsertFileName; // ファイル生成 this.GenerateSQLFile(this.InsertTemplateFilePath, this.SqlFileExtension); #endregion #region DynInsの処理 // メソッド名 this.DynInsMethodName = this.MethodNameHeaderD + this.MethodLabel_Ins + this.MethodNameFooterD; // SQLファイル名(保持用ワーク) this.DynInsFileName = this.DaoClassName + "_" + this.DynInsMethodName; // ファイル名(テンポラリ・カレント) this.FileName = this.DynInsFileName; // ファイル生成 this.GenerateSQLFile(this.DynInsTemplateFilePath, this.XmlFileExtension); #endregion #region Selectの処理 // メソッド名 this.SelectMethodName = this.MethodNameHeaderS + this.MethodLabel_Sel + this.MethodNameFooterS; // SQLファイル名(保持用ワーク) this.SelectFileName = this.DaoClassName + "_" + this.SelectMethodName; // ファイル名(テンポラリ・カレント) this.FileName = this.SelectFileName; // ファイル生成 this.GenerateSQLFile(this.SelectTemplateFilePath, this.XmlFileExtension); #endregion #region DynSelの処理 // メソッド名 this.DynSelMethodName = this.MethodNameHeaderD + this.MethodLabel_Sel + this.MethodNameFooterD; // SQLファイル名(保持用ワーク) this.DynSelFileName = this.DaoClassName + "_" + this.DynSelMethodName; // ファイル名(テンポラリ・カレント) this.FileName = this.DynSelFileName; // ファイル生成 this.GenerateSQLFile(this.DynSelTemplateFilePath, this.XmlFileExtension); #endregion #region Updateの処理 // メソッド名 this.UpdateMethodName = this.MethodNameHeaderS + this.MethodLabel_Upd + this.MethodNameFooterS; // SQLファイル名(保持用ワーク) this.UpdateFileName = this.DaoClassName + "_" + this.UpdateMethodName; // ファイル名(テンポラリ・カレント) this.FileName = this.UpdateFileName; // ファイル生成 this.GenerateSQLFile(this.UpdateTemplateFilePath, this.XmlFileExtension); #endregion #region DynUpdの処理 // メソッド名 this.DynUpdMethodName = this.MethodNameHeaderD + this.MethodLabel_Upd + this.MethodNameFooterD; // SQLファイル名(保持用ワーク) this.DynUpdFileName = this.DaoClassName + "_" + this.DynUpdMethodName; // ファイル名(テンポラリ・カレント) this.FileName = this.DynUpdFileName; // ファイル生成 this.GenerateSQLFile(this.DynUpdTemplateFilePath, this.XmlFileExtension); #endregion #region Deleteの処理 // メソッド名 this.DeleteMethodName = this.MethodNameHeaderS + this.MethodLabel_Del + this.MethodNameFooterS; // SQLファイル名(保持用ワーク) this.DeleteFileName = this.DaoClassName + "_" + this.DeleteMethodName; // ファイル名(テンポラリ・カレント) this.FileName = this.DeleteFileName; // ファイル生成 this.GenerateSQLFile(this.DeleteTemplateFilePath, this.XmlFileExtension); #endregion #region DynDelの処理 // メソッド名 this.DynDelMethodName = this.MethodNameHeaderD + this.MethodLabel_Del + this.MethodNameFooterD; // SQLファイル名(保持用ワーク) this.DynDelFileName = this.DaoClassName + "_" + this.DynDelMethodName; // ファイル名(テンポラリ・カレント) this.FileName = this.DynDelFileName; // ファイル生成 this.GenerateSQLFile(this.DynDelTemplateFilePath, this.XmlFileExtension); #endregion // ↓↓↓【追加】↓↓↓ #region DynSelCntの処理 // メソッド名 this.DynSelCntMethodName = this.MethodNameHeaderD + this.MethodLabel_SelCnt + this.MethodNameFooterD; // SQLファイル名(保持用ワーク) this.DynSelCntFileName = this.DaoClassName + "_" + this.DynSelCntMethodName; // ファイル名(テンポラリ・カレント) this.FileName = this.DynSelCntFileName; // ファイル生成 this.GenerateSQLFile(this.DynSelCntTemplateFilePath, this.XmlFileExtension); #endregion // ↑↑↑【追加】↑↑↑ #endregion #region Daoファイルを生成 // カレント・ファイル出力用とReplace用途 this.FileName = this.DaoClassName; // Daoファイルを生成 // DTE:DaoClassテンプレートのEncoding this.GenerateClassFile( this.DaoTemplateFilePath, (int)this.cmbDTEncoding.SelectedValue, this.FileName); #endregion } // ↓↓↓【追加】↓↓↓ if (this.CreateDTO && !this.cbxOnlyTableMaintenance.Checked) { #region Entityファイルを生成 if (this.cbxEntity.Checked) { // カレント・ファイル出力用とReplace用途 // Entityクラス名 this.EntityClassName = this.EntityClassNameHeader + this.TableName.Replace(' ', '_') + this.EntityClassNameFooter; // Entityファイル名 this.FileName = this.EntityClassName; // Entityファイルを生成 // DTE:DaoClassテンプレートのEncoding this.GenerateClassFile( this.EntityTemplateFilePath, (int)this.cmbDTEncoding.SelectedValue, this.FileName); } #endregion #region DataSetファイルを生成 if (this.cbxTypedDataSet.Checked) { // カレント・ファイル出力用とReplace用途 // DataSetクラス名 this.DataSetClassName = this.DataSetClassNameHeader + this.TableName.Replace(' ', '_') + this.DataSetClassNameFooter; // DataSetファイル名 this.FileName = this.DataSetClassName + ".xsd"; // DataTableクラス名 this.DataTableClassName = this.DataTableClassNameHeader + this.TableName.Replace(' ', '_') + this.DataTableClassNameFooter; // DataSetファイルを生成 // DTE:DaoClassテンプレートのEncoding this.GenerateClassFile( this.DataSetTemplateFilePath, (int)this.cmbDTEncoding.SelectedValue, this.FileName); } #endregion } if (this.CreateMaintenanceScreen && !this.cbxOnlyDTO.Checked) { // カレント・ファイル出力用とReplace用途 // TableAdapterを生成 this.FileName = this.TableName.Replace(' ', '_') + this.TableAdapterTemplateFileName; this.GenerateClassFile( this.TableAdapterTemplateFilePath, (int)this.cmbDTEncoding.SelectedValue, this.FileName); #region ASPXファイル、Codebehindファイル // ASPXファイル、Codebehindファイル(ConditionalSearch)を生成 this.FileName = this.TableName + this.ConditionalSearchTemplateFileName; this.GenerateClassFile( this.ConditionalSearchTemplateFilePath, (int)this.cmbDTEncoding.SelectedValue, this.FileName); this.GenerateClassFile( this.ConditionalSearchTemplateFilePath + "." + this.ClassTemplateFileExtension, (int)this.cmbDTEncoding.SelectedValue, this.FileName + "." + this.ClassTemplateFileExtension); // ASPXファイル、Codebehindファイル(SearchAndUpdate)を生成 this.FileName = this.TableName + this.SearchAndUpdateTemplateFileName; this.GenerateClassFile( this.SearchAndUpdateTemplateFilePath, (int)this.cmbDTEncoding.SelectedValue, this.FileName); this.GenerateClassFile( this.SearchAndUpdateTemplateFilePath + "." + this.ClassTemplateFileExtension, (int)this.cmbDTEncoding.SelectedValue, this.FileName + "." + this.ClassTemplateFileExtension); // ASPXファイル、Codebehindファイル(Detail)を生成 this.FileName = this.TableName + this.DetailTemplateFileName; this.GenerateClassFile( this.DetailTemplateFilePath, (int)this.cmbDTEncoding.SelectedValue, this.FileName); this.GenerateClassFile( this.DetailTemplateFilePath + "." + this.ClassTemplateFileExtension, (int)this.cmbDTEncoding.SelectedValue, this.FileName + "." + this.ClassTemplateFileExtension); #endregion } // ↑↑↑【追加】↑↑↑ // テーブル名の初期化 this.TableName = ""; } else { // 不正な状態 throw new CheckException( //"D層定義情報ファイル・フォーマットエラー。テーブル名がありません。:" + rlDaoDef); this.RM_GetString("FileFormatError") + rlDaoDef); } } #endregion #endregion // カーソルを元に戻す System.Windows.Forms.Cursor.Current = Cursors.Default; // メッセージ //MessageBox.Show("自動生成完了!"); MessageBox.Show(this.RM_GetString("FileGenComplete")); } catch (CheckException cex) { //MessageBox.Show("チェックエラーです:" + cex.Message); MessageBox.Show(this.RM_GetString("CheckExceptionError") + cex.Message); } catch (Exception ex) { //MessageBox.Show("ランタイムエラーです:" + ex.Message); MessageBox.Show(this.RM_GetString("RuntimeError") + ex.Message); } finally { // D層定義情報ファイル if (srDaoDef != null) { srDaoDef.Close(); } // ↓↓↓【追加】↓↓↓ // .NET型定義情報ファイル if (srTypeDef != null) { srTypeDef.Close(); } // ↑↑↑【追加】↑↑↑ // カーソルを元に戻す System.Windows.Forms.Cursor.Current = Cursors.Default; } }
// メイン ロジック #region 生成処理 /// <summary>D層、Daoクラスファイル、SQLファイルを生成する。</summary> private void btnDaoAndSqlGen_Click(object sender, EventArgs e) { this.TableName_join = ""; // D層定義情報ファイル StreamReader srDaoDef = null; // ↓↓↓【追加】↓↓↓ // .NET型定義情報ファイル StreamReader srTypeDef = null; // DB型定義情報ファイル StreamReader srDbTypeDef = null; // DB型定義情報ファイル読み込みフラグ設定 this.ReadDbTypeInfo = (this.ReadDbTypeInfo || rbnODP.Checked); // ↑↑↑【追加】↑↑↑ try { // カーソルを待機状態にする System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; #region 拡張子の設定 if (this.rbnDTL_CS.Checked) { // Visual C# this.ClassTemplateFileExtension = "cs"; this.CodebehindLanguage = "C#"; this.CommentOut = "//"; } else { // Visual Basic this.ClassTemplateFileExtension = "vb"; this.CodebehindLanguage = "VB"; this.CommentOut = "'"; } #endregion #region チェック処理 FileInfo fileInfo = null; DirectoryInfo dirInfo = null; #region D層定義情報ファイル // 標準生成 fileInfo = new FileInfo(this.txtSetDaoDefinition.Text); if (fileInfo.Exists) { } else { //MessageBox.Show(string.Format("チェックエラーです:D層定義情報ファイル[{0}]が存在しません。", fileInfo.Name)); MessageBox.Show(string.Format(this.RM_GetString("FilenotExistDlayerInfo"), fileInfo.Name)); return; } // ↓↓↓【追加】↓↓↓ // DB型情報ファイル読み込み if (this.ReadDbTypeInfo) { // *.CSVである前提の仕様だがOKか?(一応ファイル名を出力する) int temp = this.txtSetDaoDefinition.Text.Length - 4; this.DbTypeInfoFilePath = this.txtSetDaoDefinition.Text.Substring(0, temp) + "_DBTypeInfo" + this.txtSetDaoDefinition.Text.Substring(temp); fileInfo = new FileInfo(this.DbTypeInfoFilePath); if (fileInfo.Exists) { } else { //MessageBox.Show(string.Format("チェックエラーです:DB型情報ファイル[{0}]が存在しません。", fileInfo.Name)); MessageBox.Show(string.Format(this.RM_GetString("FilenotExistDBtypeInfo"), fileInfo.Name)); return; } } // ↑↑↑【追加】↑↑↑ #endregion #region 入力ファイル dirInfo = new DirectoryInfo(this.txtSetSourceTemplate.Text); if (dirInfo.Exists) { } else { //MessageBox.Show("入力ファイル(テンプレート ファイル)のルート フォルダが存在しません。"); MessageBox.Show(this.RM_GetString("InputFileRootFolderNotExist")); return; } #region Dao、Entity、DataSetテンプレート ファイル // ConditionalSearchテンプレート ファイル this.ConditionalSearchTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.JoinConditionalSearchTemplateFileName, ""); // SearchAndUpdateテンプレート ファイル this.SearchAndUpdateTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.JoinSearchAndUpdateTemplateFileName, ""); // Detailテンプレート ファイル this.DetailTemplateFilePath = this.CheckTemplateFile( this.txtSetSourceTemplate.Text, this.JoinDetailTemplateFileName, ""); // ↑↑↑【追加】↑↑↑ #endregion #endregion #region 出力ファイル dirInfo = new DirectoryInfo(this.txtSetOutput.Text); if (dirInfo.Exists) { } else { //MessageBox.Show("出力ファイル(Daoクラス ファイル、SQLファイル.etc)のルート フォルダが存在しません。"); MessageBox.Show(this.RM_GetString("OutputFileRootFolderNotExist")); return; } #endregion #region タイムスタンプ列 // タイムスタンプ列名を取得 this.TimeStampColName = this.txtTimeStampColName.Text.Trim(); // タイムスタンプ更新方法を取得 this.TimeStampUpdMethod = this.txtTimeStampUpdMethod.Text.Trim(); // タイムスタンプの設定ステータスのチェック&設定 if (this.TimeStampColName == "" & this.TimeStampUpdMethod == "") { // なにもない。 this.TimeStampStatus = TSS.Non; } else if (this.TimeStampColName != "" & this.TimeStampUpdMethod == "") { // 名前だけある。 this.TimeStampStatus = TSS.Name; } else if (this.TimeStampColName != "" & this.TimeStampUpdMethod != "") { // 名前と更新方法の両方がある。 this.TimeStampStatus = TSS.NandM; } else { // 更新方法だけある。 //MessageBox.Show("タイムスタンプ列名がありません。"); MessageBox.Show(this.RM_GetString("NoTimestampColName")); return; } #endregion #endregion #region 生成処理(将来的に関数化しても良い) #region 固定情報の設定 // 日付 this.TimeStamp = DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day; // ユーザ名 this.UserName = this.txtFamilyName.Text + " " + this.txtPersonalName.Text; this.strDAP = ""; this.strDBMS = ""; GetProviderInfo(); #endregion #region Read the DaoDefinitaion Files and get Primary key Information intTable = 0; PkList = new ArrayList(); ElseList = new ArrayList(); AllTableNames = new ArrayList(); string strTableName = ""; string strRlDaoDef = ""; string[] strRlDaoDef2 = null; this.OpenSrDefInfo(out srDaoDef, out srTypeDef, out srDbTypeDef); if (this.cbxDaoDefinitionHeader.Checked) { if (!srDaoDef.EndOfStream) { strRlDaoDef = srDaoDef.ReadLine(); } } while (!srDaoDef.EndOfStream) { // for primary keys strRlDaoDef = srDaoDef.ReadLine(); strRlDaoDef2 = strRlDaoDef.Split(','); #region Get Tables Names if (strRlDaoDef2[0] != "") { //Only Include the tables which are used in the Select Join statements of DpqueryTool if (DPQTableNames.Contains(strRlDaoDef2[0])) { strTableName = strRlDaoDef2[0].Trim(); AllTableNames.Add(strRlDaoDef2[0].Trim()); } else { //This is to Exclude the Tables which are not used in Select Join statements of DpqueryTool but available in DaoDefinition .csv file. strRlDaoDef = srDaoDef.ReadLine(); continue; } } #endregion #region Add only Primary key columns of only required tables ArrayList colpkList = new ArrayList(); if (strRlDaoDef2.Length > 2) { for (int i = 1; i < strRlDaoDef2.Length; i++) { if (strRlDaoDef2[i] == "") { break; } //Only Include the columns which are used in the Select Join statements of DpqueryTool if (DPQAllCoumns.Contains(strTableName + "." + strRlDaoDef2[i].Trim())) colpkList.Add(strTableName + "." + strRlDaoDef2[i].Trim()); else if (DPQAllCoumns.Contains(strRlDaoDef2[i].Trim())) { colpkList.Add(strRlDaoDef2[i].Trim()); } } PkList.Add(colpkList); } else { MessageBox.Show(this.RM_GetString("PKnotAvailable") + strTableName); return; } #endregion #region Add only Else key columns of only required tables // for Else keys strRlDaoDef = srDaoDef.ReadLine(); strRlDaoDef2 = strRlDaoDef.Split(','); ArrayList colelseList = new ArrayList(); if (strRlDaoDef2.Length >= 2) { for (int i = 1; i < strRlDaoDef2.Length; i++) { if (strRlDaoDef2[i] == "") { break; } if (DPQAllCoumns.Contains(strTableName + "." + strRlDaoDef2[i].Trim())) colelseList.Add(strTableName + "." + strRlDaoDef2[i].Trim()); else if (DPQAllCoumns.Contains(strRlDaoDef2[i].Trim())) { colelseList.Add(strRlDaoDef2[i].Trim()); } } } // To remove Timestamp column display in grid view and use TimeStampColName to set when if (colelseList.Contains(strTableName + "." + this.TimeStampColName)) colelseList.Remove(strTableName + "." + this.TimeStampColName); ElseList.Add(colelseList); #endregion } #endregion #region データがなくなるまでループ if (PkList.Count > 0) { foreach (string tablename in AllTableNames) { this.TableName_join += tablename + "_"; } this.TableName_join += "JOIN"; #region ASPXファイル、Codebehindファイル // ASPXファイル、Codebehindファイル(_Screen_ConditionalSearch)を生成 this.FileName = this.TableName_join + this.JoinConditionalSearchTemplateFileName; this.GenerateClassFile1( this.ConditionalSearchTemplateFilePath, (int)this.cmbDTEncoding.SelectedValue, this.FileName); this.GenerateClassFile1( this.ConditionalSearchTemplateFilePath + "." + this.ClassTemplateFileExtension, (int)this.cmbDTEncoding.SelectedValue, this.FileName + "." + this.ClassTemplateFileExtension); //// ASPXファイル、Codebehindファイル(_Screen_SearchAndUpdate)を生成 this.FileName = this.TableName_join + this.JoinSearchAndUpdateTemplateFileName; this.GenerateClassFile1( this.SearchAndUpdateTemplateFilePath, (int)this.cmbDTEncoding.SelectedValue, this.FileName); this.GenerateClassFile1( this.SearchAndUpdateTemplateFilePath + "." + this.ClassTemplateFileExtension, (int)this.cmbDTEncoding.SelectedValue, this.FileName + "." + this.ClassTemplateFileExtension); // ASPXファイル、Codebehindファイル(Detail)を生成 this.FileName = this.TableName_join + this.JoinDetailTemplateFileName; this.GenerateClassFile1( this.DetailTemplateFilePath, (int)this.cmbDTEncoding.SelectedValue, this.FileName); this.GenerateClassFile1( this.DetailTemplateFilePath + "." + this.ClassTemplateFileExtension, (int)this.cmbDTEncoding.SelectedValue, this.FileName + "." + this.ClassTemplateFileExtension); #endregion MessageBox.Show(this.RM_GetString("ScreenGenerationSuccess")); } else { MessageBox.Show(this.RM_GetString("PkSetMessgae")); } #endregion #endregion // カーソルを元に戻す System.Windows.Forms.Cursor.Current = Cursors.Default; } catch (CheckException cex) { //MessageBox.Show("チェックエラーです:" + cex.Message); MessageBox.Show(this.RM_GetString("CheckExceptionError") + cex.Message); } catch (Exception ex) { //MessageBox.Show("ランタイムエラーです:" + ex.Message); MessageBox.Show(this.RM_GetString("RuntimeError") + ex.Message); } finally { // D層定義情報ファイル if (srDaoDef != null) { srDaoDef.Close(); } // ↓↓↓【追加】↓↓↓ // .NET型定義情報ファイル if (srTypeDef != null) { srTypeDef.Close(); } // ↑↑↑【追加】↑↑↑ // カーソルを元に戻す System.Windows.Forms.Cursor.Current = Cursors.Default; } }