Skip to content

Instantly share code, notes, and snippets.

@donnaken15
Last active April 25, 2022 04:00
Show Gist options
  • Save donnaken15/cf2b43bda3e8a8264f481323a494ef8d to your computer and use it in GitHub Desktop.
Save donnaken15/cf2b43bda3e8a8264f481323a494ef8d to your computer and use it in GitHub Desktop.
rough program to build guitar hero texs, made only for global_gfx, im not sure about anything else, main program/template here: https://cdn.discordapp.com/attachments/407427813117788161/871908227510595655/zzz_buildbase.zip
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
namespace buildtex
{
// lost muh code somehow
// whyyyyyyy
class Program
{
private static string[] config;
private static string[] curline;
private static uint line = 0;
private static uint file = 0;
private static uint listptr = 28;
private static uint listptr2 = 0;
private static uint fileoff = 0;
private static List<byte[]> dds;
private static BinaryWriter tex;
public static byte[] STH(string hex)
{
List<byte> list = new List<byte>();
for (int i = 0; i < hex.Length - 1; i += 2)
{
list.Add(byte.Parse(hex.Substring(i, 2), NumberStyles.HexNumber));
}
return list.ToArray();
}
static void Main(string[] args)
{
if (File.Exists("config.txt"))
{
config = File.ReadAllLines("config.txt");
File.Delete("output.tex");
tex = new BinaryWriter(File.OpenWrite("output.tex"));
line = 0;
while (line < 7)
{
tex.Write(STH(config[line]));
line++;
}
listptr2 = uint.Parse(config[2], NumberStyles.HexNumber);
while (listptr < listptr2)
{
tex.Write((byte)239);
listptr += 1;
}
fileoff = listptr2 + (uint)((config.Length - 7) * 40);
dds = new List<byte[]>();
while (line < config.Length)
{
tex.Write(STH("0A280200"));
curline = config[line].Split(new char[]
{
','
});
tex.Write(STH(curline[0]));
tex.Write(STH(curline[1]));
tex.Write(STH("0001"));
tex.Write(STH(curline[2]));
tex.Write(STH("0000000000"));
string imgid = (line - 6).ToString("00000000");
string[] fileexts = { ".png", ".dds", ".jpg" };
Console.WriteLine("Loading texture #" + imgid);
bool foundimg = false;
for (int i = 0; i < fileexts.Length; i++)
if (File.Exists(imgid + fileexts[i]))
{
dds.Add(File.ReadAllBytes(imgid + fileexts[i]));
foundimg = true;
break;
}
if (!foundimg)
{
dds.Add(new byte[0]);
}
tex.Write(STH(fileoff.ToString("x8")));
tex.Write(STH(dds[dds.Count - 1].Length.ToString("X8")));
tex.Write(STH("00000000"));
fileoff += (uint)dds[dds.Count - 1].Length;
file++;
line++;
}
foreach (byte[] buffer in dds)
{
tex.Write(buffer);
}
tex.Close();
Console.WriteLine("Done");
Console.ReadKey();
}
}
}
}
@donnaken15
Copy link
Author

donnaken15 commented Apr 25, 2022

THIS FORMATTING IS DOG POO
YOU FREAKING GIT!!

edit999: fixed in notepad++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment