/** * Decompiles a binary script from a stream. */ public YukaScript FromBinary(Stream s) { BinaryReader br = new BinaryReader(s); // read header s.Seek(0x10, SeekOrigin.Begin); codeoffset = br.ReadInt32(); codecount = br.ReadInt32(); indexoffset = br.ReadInt32(); indexcount = br.ReadInt32(); dataoffset = br.ReadInt32(); datalength = br.ReadInt32(); // seek to the start of the code block s.Seek(codeoffset, SeekOrigin.Begin); // as long as we have not reached the end of the code block while (s.Position < codeoffset + codecount * 4) { // try to read the next script element. ScriptElement elem = NextScriptElement(s); // if you found one, then... if (elem != null) { // ...add it to the list of commands. commands.Add(elem); // some logging logic. if (FlagCollection.current.Has('v')) { string output = elem.ToString(); if (output.StartsWith("yuka.Script")) { Console.ForegroundColor = ConsoleColor.Cyan; } Console.WriteLine(output); Console.ResetColor(); } } else { } } // create new script instance from list of commands and attached string data and return it return(new YukaScript(commands, stringTable)); }
public static Button OnClick(this Button button, ScriptElement onclick) => button.Attr("onclick", onclick.ToString());