protected override void InitTextures(ArchiveWorker aw = null) { Textures = new List <TextureHandler>(); for (int t = 0; t < Props.Count; t++) { TEX tex; tex = new TEX(ArchiveWorker.GetBinaryFile(ArchiveString, aw.GetListOfFiles().First(x => x.IndexOf(Props[t].Filename, StringComparison.OrdinalIgnoreCase) >= 0))); if (Props[t].Colors == null || Props[t].Colors.Length == 0) { for (ushort i = 0; i < tex.GetClutCount; i++) { if (FORCE_ORIGINAL == false && Props[t].Big != null && Props[t].Big.Count > 0) { Textures.Add(TextureHandler.Create(Props[t].Big[0].Filename, tex, 2, Props[t].Big[0].Split / 2, i)); } else { Textures.Add(TextureHandler.Create(Props[t].Filename, tex, 1, 1, i)); } } } else { if (FORCE_ORIGINAL == false && Props[t].Big != null && Props[t].Big.Count > 0) { Textures.Add(TextureHandler.Create(Props[t].Big[0].Filename, tex, 2, Props[t].Big[0].Split / 2, (ushort)Textures.Count, colors: Props[t].Big[0].Colors ?? Props[t].Colors)); } else { Textures.Add(TextureHandler.Create(Props[t].Filename, tex, 1, 1, (ushort)Textures.Count, colors: Props[t].Colors)); } } } }
//Splash is 640x400 16BPP typical TIM with palette of ggg bbbbb a rrrrr gg private void ReadSplash() { if (string.IsNullOrWhiteSpace(filename)) { return; } string fn = Path.GetFileNameWithoutExtension(filename); //Debug.Assert(!fn.Equals("ff8", StringComparison.OrdinalIgnoreCase)); ArchiveBase aw = ArchiveWorker.Load(Memory.Archives.A_MAIN); byte[] buffer = aw.GetBinaryFile(filename); TIM_OVERTURE tim = new TIM_OVERTURE(buffer); if ((fn.Equals("ff8", StringComparison.OrdinalIgnoreCase)) || (fn.IndexOf("loop", StringComparison.OrdinalIgnoreCase) >= 0)) { tim.IgnoreAlpha = true; } tex = TextureHandler.Create(fn, tim, 0);//TIM2.Overture(buffer); //using (FileStream fs = File.Create(Path.Combine("D:\\main", Path.GetFileNameWithoutExtension(filename) + ".png"))) // splashTex.SaveAsPng(fs, splashTex.Width, splashTex.Height); GC.Collect(); GC.WaitForPendingFinalizers(); }
/// <summary> /// Draw Item /// </summary> /// <param name="id"></param> /// <param name="dst"></param> /// <param name="fade"></param> public virtual void Draw(Enum id, Rectangle dst, float fade = 1) { Rectangle src = GetEntry(id).GetRectangle; TextureHandler tex = GetTexture(id); tex.Draw(dst, src, Color.White * fade); }
protected virtual VertexPositionTexture_Texture2D Quad(Entry entry, TextureHandler texture, float scale = .25f, Box_Options options = Box_Options.Middle | Box_Options.Center, float z = 0f) { var rectangle = entry.GetRectangle; var scaleFactor = texture.ScaleFactor; var offset = options.HasFlag(Box_Options.UseOffset) ? entry.Offset : Vector2.Zero; var vpt = new VertexPositionTexture[6]; float left, right, bottom, top; if (options.HasFlag(Box_Options.Left)) { left = 0; right = rectangle.Width; } else if (options.HasFlag(Box_Options.Right)) { left = -rectangle.Width; right = 0; } else// (options.HasFlag(Box_Options.Center)) { left = -rectangle.Width / 2f; right = rectangle.Width / 2f; } if (options.HasFlag(Box_Options.Top)) { bottom = 0; top = rectangle.Height; } else if (options.HasFlag(Box_Options.Buttom)) { bottom = -rectangle.Height; top = 0; } else //(options.HasFlag(Box_Options.Middle)) { bottom = -rectangle.Height / 2f; top = rectangle.Height / 2f; } var v = new VertexPositionTexture[] { new VertexPositionTexture(new Vector3(left + offset.X, top + offset.Y, z) * scale, new Vector2(rectangle.Right * scaleFactor.X / texture.Width, rectangle.Top * scaleFactor.Y / texture.Height)), new VertexPositionTexture(new Vector3(right + offset.X, top + offset.Y, z) * scale, new Vector2(rectangle.Left * scaleFactor.X / texture.Width, rectangle.Top * scaleFactor.Y / texture.Height)), new VertexPositionTexture(new Vector3(right + offset.X, bottom + offset.Y, z) * scale, new Vector2(rectangle.Left * scaleFactor.X / texture.Width, rectangle.Bottom * scaleFactor.Y / texture.Height)), new VertexPositionTexture(new Vector3(left + offset.X, bottom + offset.Y, z) * scale, new Vector2(rectangle.Right * scaleFactor.X / texture.Width, rectangle.Bottom * scaleFactor.Y / texture.Height)), }; vpt[0] = v[0]; vpt[1] = v[1]; vpt[2] = v[3]; vpt[3] = v[1]; vpt[4] = v[2]; vpt[5] = v[3]; return(new VertexPositionTexture_Texture2D(vpt, texture)); }
private void ReadTIM(int id, BinaryReader br, out TextureHandler[] tex) { var temp = new TIM2(br, EXE_Offsets.TIM[id]); tex = new TextureHandler[temp.GetClutCount]; for (ushort i = 0; i < temp.GetClutCount; i++) { tex[i] = TextureHandler.Create($"ff8exe{id.ToString("D2")}", temp, i); } }
public VertexPositionTexture_Texture2D(VertexPositionTexture[] vPT, TextureHandler texture) { VPT = vPT; TransformedVPT = (VertexPositionTexture[])VPT.Clone(); Texture = texture; ate = new AlphaTestEffect(Memory.graphics.GraphicsDevice) { Texture = (Texture2D)Texture }; }
public void LoadFonts() { ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU); string sysfntTdwFilepath = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tdw")); string sysfntFilepath = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tex")); TEX tex = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntFilepath)); sysfnt = tex.GetTexture((int)ColorID.White); sysfntbig = new TextureHandler("sysfld{0:00}.tex", tex, 2, 1, (int)ColorID.White); ReadTdw(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntTdwFilepath)); }
protected override void Init() { Size = new Vector2 { X = 840, Y = 630 }; //Data0 is scaled from 1280x720 Data0 = new Dictionary <Enum, Menu_Base> { { SectionName.BG, new IGMDataItem.Texture_Handler(TextureHandler.Create("start{0:00}", 2), new Rectangle(0, -25, 1280, 0)) } //new Rectangle(-45,-25, 1280+100, 0) }; //Data is scaled from Size Data.TryAdd(SectionName.Selections, IGMData_Selections.Create()); base.Init(); }
public void LoadFonts() { ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU); string sysfntTdwFilepath = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tdw")); string sysfntFilepath = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tex")); TEX tex = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntFilepath)); sysfnt = tex.GetTexture((int)ColorID.White); sysfntbig = TextureHandler.Create("sysfld{0:00}.tex", tex, 2, 1, (int)ColorID.White); TDW tim = new TDW(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntTdwFilepath), 0); charWidths = tim.CharWidths; menuFont = tim.GetTexture((ushort)ColorID.White); }
public texl(byte[] texlBuffer) { textures = new TextureHandler[20][]; using (var br = new BinaryReader(new MemoryStream(texlBuffer))) for (var i = 0; i < TEX_COUNT; i++) { var timOffset = i * TEX_SIZE; var tim = new TIM2(texlBuffer, (uint)timOffset); textures[i] = new TextureHandler[tim.GetClutCount]; for (ushort k = 0; k < textures[i].Length; k++) { textures[i][k] = TextureHandler.Create($"texl_tim{(i + 1).ToString("D2")}.tim", tim, k, null); } //todo detect if mods aren't using palettes. } }
public void LoadFonts() { Memory.Log.WriteLine($"{nameof(Font)} :: {nameof(LoadFonts)} "); var aw = ArchiveWorker.Load(Memory.Archives.A_MENU); var bufferTex = aw.GetBinaryFile("sysfnt.tex"); var tex = new TEX(bufferTex); sysfnt = tex.GetTexture((int)ColorID.White); sysfntbig = TextureHandler.Create("sysfld{0:00}.tex", tex, 2, 1, (int)ColorID.White); var bufferTDW = aw.GetBinaryFile("sysfnt.tdw"); var tim = new TDW(bufferTDW); charWidths = tim.CharWidths; menuFont = tim.GetTexture((ushort)ColorID.White); }
protected virtual void InitTextures <T>(ArchiveBase aw = null) where T : Texture_Base, new() { var count = (int)Props.Sum(x => x.Count); if (Textures == null) { Textures = new List <TextureHandler>(count); } if (Textures.Count <= 0) { if (aw == null) { aw = ArchiveWorker.Load(ArchiveString); } T tex; Scale = new Dictionary <uint, Vector2>(count); var b = 0; for (var j = 0; j < Props.Count; j++) { for (uint i = 0; i < Props[j].Count; i++) { tex = new T(); var buffer = aw.GetBinaryFile(string.Format(Props[j].Filename, i + TextureStartOffset)); if (buffer != null) { tex.Load(buffer); if (Props[j].Big != null && ForceOriginal == false && b < Props[j].Big.Count) { var th = TextureHandler.Create(Props[j].Big[b].Filename, tex, 2, Props[j].Big[b++].Split / 2); Textures.Add(th); Scale[i] = Vector2.One; } else { var th = TextureHandler.Create(Props[j].Filename, tex); Textures.Add(th); Scale[i] = th.GetScale(); //scale might not be used outside of texturehandler. } } } } } }
public virtual void Draw(Enum id, Rectangle dst, Vector2 fill, float fade = 1) { Rectangle src = GetEntry(id).GetRectangle; if (fill == Vector2.UnitX) { float r = (float)dst.Height / dst.Width; src.Height = (int)Math.Round(src.Height * r); } else if (fill == Vector2.UnitY) { float r = (float)dst.Width / dst.Height; src.Width = (int)Math.Round(src.Width * r); } TextureHandler tex = GetTexture(id); tex.Draw(dst, src, Color.White * fade); }
public void LoadFonts() { Memory.Log.WriteLine($"{nameof(Font)} :: {nameof(LoadFonts)} "); ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU); string[] filelist = aw.GetListOfFiles(); if (filelist != null) { string sysfntTdwFilepath = filelist.First(x => x.ToLower().Contains("sysfnt.tdw")); string sysfntFilepath = filelist.First(x => x.ToLower().Contains("sysfnt.tex")); TEX tex = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntFilepath)); sysfnt = tex.GetTexture((int)ColorID.White); sysfntbig = TextureHandler.Create("sysfld{0:00}.tex", tex, 2, 1, (int)ColorID.White); TDW tim = new TDW(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntTdwFilepath), 0); charWidths = tim.CharWidths; menuFont = tim.GetTexture((ushort)ColorID.White); } }
protected virtual void InitTextures(ArchiveWorker aw = null) { int count = (int)Props.Sum(x => x.Count); if (Textures == null) { Textures = new List <TextureHandler>(count); } if (Textures.Count <= 0) { if (aw == null) { aw = new ArchiveWorker(ArchiveString); } TEX tex; Scale = new Dictionary <uint, Vector2>(count); int b = 0; for (int j = 0; j < Props.Count; j++) { for (uint i = 0; i < Props[j].Count; i++) { string path = aw.GetListOfFiles().First(x => x.ToLower().Contains(string.Format(Props[j].Filename, i + TextureStartOffset))); tex = new TEX(aw.GetBinaryFile(path)); if (Props[j].Big != null && FORCE_ORIGINAL == false && b < Props[j].Big.Count) { TextureHandler th = new TextureHandler(Props[j].Big[b].Filename, tex, 2, Props[j].Big[b++].Split / 2); Textures.Add(th); Scale[i] = Vector2.One; } else { TextureHandler th = new TextureHandler(path, tex); Textures.Add(th); Scale[i] = th.GetScale(); //scale might not be used outside of texturehandler. } } } } }
//Splash is 640x400 16BPP typical TIM with palette of ggg bbbbb a rrrrr gg private void ReadSplash() { byte[] buffer = ArchiveWorker.GetBinaryFile(Memory.Archives.A_MAIN, filename); string fn = Path.GetFileNameWithoutExtension(filename); uint uncompSize = BitConverter.ToUInt32(buffer, 0); buffer = buffer.Skip(4).ToArray(); //hotfix for new LZSS buffer = LZSS.DecompressAllNew(buffer); TIM_OVERTURE tim = new TIM_OVERTURE(buffer); if ((fn.Equals("ff8", StringComparison.OrdinalIgnoreCase)) || (fn.IndexOf("loop", StringComparison.OrdinalIgnoreCase) >= 0)) { tim.IgnoreAlpha = true; } tex = (Texture2D)TextureHandler.Create(fn, tim, 0);//TIM2.Overture(buffer); //using (FileStream fs = File.Create(Path.Combine("D:\\main", Path.GetFileNameWithoutExtension(filename) + ".png"))) // splashTex.SaveAsPng(fs, splashTex.Width, splashTex.Height); GC.Collect(); GC.WaitForPendingFinalizers(); }