// Start is called before the first frame update void Start() { hoodFrame = Environment.LoadAnimatedTexture(Hash.TGIRHash(0xCCC30000, 0x00000000, 0x856DDBAC, 0x499DB772), 4); var MenuStrings1 = new STRFile(Environment.GetAsset(Hash.TGIRHash(0x00000087, 0x00000000, 0x53545223, Hash.GroupHash("Neighborhood")))); var MenuStrings2 = new STRFile(Environment.GetAsset(Hash.TGIRHash(0x00000086, 0x00000000, 0x53545223, Hash.GroupHash("Neighborhood")))); Panel.mainPanel = new Panel(); var menuBackground = Environment.LoadUITexture(Hash.TGIRHash(0xCCC9AF70, 0x00000000, 0x856DDBAC, 0x499DB772)); //var menuBackground = Environment.LoadUITexture(new SU2.Utils.GroupEntryRef(0xCCC9AF70, 0x00000000, 0x856DDBAC, 0x499DB772)); Panel.mainPanel.MakePlainBackground(new Color(0.007843138f, 0.1647059f, 0.2784314f)); Panel.mainPanel.AddImage(menuBackground, Vector2.zero); var hoodChooser = Environment.LoadUITexture(Hash.TGIRHash(0xCCC30135, 0x00000000, 0x856DDBAC, 0x499DB772)); Panel.mainPanel.AddImage(hoodChooser, Vector2.zero); Panel.mainPanel.AddImage(Environment.LoadUITexture(Hash.TGIRHash(0xCCC30138, 0x00000000, 0x856DDBAC, 0x499DB772)), new Vector2(-3.5f, -253.5f)); var tleft = TopLeftSprite[Random.Range(0, TopLeftSprite.Count)]; var bright = BotRightSprite[Random.Range(0, BotRightSprite.Count)]; Panel.mainPanel.AddImage(Environment.LoadUITexture(tleft), new Vector2(-208.1f, 194.3f)); Panel.mainPanel.AddImage(Environment.LoadUITexture(bright), new Vector2(213.6f, -125.5f)); var exitButton = Environment.LoadAnimatedTexture(Hash.TGIRHash(0xCCC30095, 0x00000000, 0x856DDBAC, 0x499DB772), 4); Panel.mainPanel.AddImage(Environment.LoadUITexture(Hash.TGIRHash(0xCCC29090, 0x00000000, 0x856DDBAC, 0x499DB772)), new Vector2(-5f, -250.5f)); var exitButt = Panel.mainPanel.AddButton(exitButton, new Vector2(-5f, -250.5f), true, MenuStrings2.GetString(2)); exitButt.onPress += Environment.QuitGame; Panel.mainPanel.AddImage(Environment.LoadUITexture(Hash.TGIRHash(0xCCC30080, 0x00000000, 0x856DDBAC, 0x499DB772)), new Vector2(0f, 226.4f)); var spinBob = Environment.LoadAnimatedTexture(Hash.TGIRHash(0xCCC30200, 0x00000000, 0x856DDBAC, 0x499DB772)); Panel.mainPanel.AddImage(spinBob[0], new Vector2(-4.6f, 285f)); //File.WriteAllBytes(Environment.config.output, stre); var nhoodText = Panel.mainPanel.AddText(MenuStrings1.GetString(0), new Vector2(0f, 112f), 16); nhoodText.alignment = TextAnchor.MiddleCenter; nhoodText.fontSize = 20; nhoodText.color = new Color(0.6313726f, 0.6666667f, 0.9529412f); var nextButton = Environment.LoadAnimatedTexture(Hash.TGIRHash(0xCCC30115, 0x00000000, 0x856DDBAC, 0x499DB772), 4); nextHButton = Panel.mainPanel.AddButton(nextButton, new Vector2(288f, 51f), true, ""); var prevButton = Environment.LoadAnimatedTexture(Hash.TGIRHash(0xCCC30110, 0x00000000, 0x856DDBAC, 0x499DB772), 4); previousHButton = Panel.mainPanel.AddButton(prevButton, new Vector2(-288f, 51f), true, ""); nextHButton.onPress += NextPage; previousHButton.onPress += PrevPage; CalculateButtons(); var xOff = 175f; for (var i = 0; i < 3; i++) { var hh = Panel.mainPanel.CreateHoodFramePanel(new Vector2(-xOff + (xOff * i), 29.3f), Environment.hoods[i]); hoodFrames.Add(hh); } }
public Neighborhood(string folder) { nhoodFolder = Path.GetFullPath(folder).TrimEnd(Path.DirectorySeparatorChar); var packagePath = Path.Combine(folder, Path.GetFileName(nhoodFolder) + "_Neighborhood.package"); package = new DBPFFile(packagePath); var stringsFile = package.GetItemByFullID(Hash.TGIRHash(0x00000001, 0x00000000, 0x43545353, package.groupID)); if (stringsFile != null) { var ds = new STRFile(stringsFile); name = ds.GetString(0); desc = ds.GetString(1); } var pictureFile = Path.Combine(folder, Path.GetFileName(nhoodFolder) + "_Neighborhood.png"); var hoodTexture = Environment.LoadUITexture(Hash.TGIRHash(0xCCC30155, 0x00000000, 0x856DDBAC, 0x499DB772)); if (File.Exists(pictureFile)) { hoodTexture = Environment.LoadUITexture(File.ReadAllBytes(pictureFile)); } thumbnail = hoodTexture; largePic = hoodTexture; }
public static void Export(this STRFile strFile, string path, bool isUnicode) { using var fs = new FileStream(path, FileMode.Create); using var writer = new BinaryWriter(fs); writer.Write(strFile.Length); if (isUnicode) { writer.Write((byte)0x08); } else { writer.Write((byte)0x00); } writer.Write((byte)0x02); foreach (uint filePos in strFile.LineOffsets) { writer.Write(filePos);//offset } for (int i = 0; i < strFile.LineOffsets.Count; ++i) { writer.Write(i); //line index byte[] code; if (isUnicode) { code = Encoding.Unicode.GetBytes('\ufeff' + strFile.Lines[i].Text + '\0'); } else { code = Encoding.ASCII.GetBytes(strFile.Lines[i].Text + '\0'); } writer.Write(code); } }
public static STRFile Read(Stream fs) { using var reader = new BinaryReader(fs); var lineOffsets = new List <uint>(); //How much text line in this file var length = reader.ReadUInt16(); var unicodeFlag = reader.ReadByte(); //Unicode mode this flag will be 0x08, non unicode is 0x00 var unkFlag = reader.ReadByte(); //Unkmark, 0x02 fixed //The line binary offset in this file for (int i = 0; i < length; ++i) { var filePos = reader.ReadUInt32(); lineOffsets.Add(filePos); } var lines = new List <STRLine>(); for (int i = 0; i < length; ++i) { var index = reader.ReadUInt32(); int size; if (i + 1 == length) { size = (int)(fs.Length - lineOffsets[i]); } else { size = (int)(lineOffsets[i + 1] - lineOffsets[i]); } size -= 4; var code = reader.ReadBytes(size); string text; if (unicodeFlag == 0x08) { text = Encoding.Unicode.GetString(code).Trim('\uFEFF', '\0'); // remove unicode mark and end mark } else { text = Encoding.ASCII.GetString(code).Trim('\uFEFF', '\0'); // remove unicode mark and end mark } lines.Add(new STRLine { Index = index, Text = text }); } var file = new STRFile { Length = length, UnicodeFlag = unicodeFlag, UnkFlag = unkFlag, LineOffsets = lineOffsets, Lines = lines }; return(file); }