private void DrawLine(string line, Rectangle dest, SpriteBatch sb, Color defaultColor) { Vector2 vector2 = Utils.ClipVec2ForTextRendering(new Vector2((float)dest.X, (float)(dest.Y + dest.Height) - (GuiData.ActiveFontConfig.tinyFontCharHeight + 1f))); if (line.StartsWith("!ATTACHMENT:")) { if (!AttachmentRenderer.RenderAttachment(line.Substring("!ATTACHMENT:".Length), (object)OS.currentInstance, vector2, this.DrawnButtonIndex, this.AttachmentPressedSound)) { return; } ++this.DrawnButtonIndex; } else if (line.StartsWith("!ANNOUNCEMENT!")) { Rectangle destinationRectangle = new Rectangle((int)vector2.X - 2, (int)vector2.Y, dest.Width + 2, (int)((double)GuiData.ActiveFontConfig.tinyFontCharHeight + 6.0)); sb.Draw(Utils.white, destinationRectangle, Color.Red * 0.22f); sb.DrawString(GuiData.tinyfont, line, vector2, defaultColor); } else { sb.DrawString(GuiData.tinyfont, line, vector2, defaultColor); } }
public static bool RenderAttachment(string data, object osObj, Vector2 dpos, int startingButtonIndex, SoundEffect buttonSound) { OS os = (OS)osObj; string[] strArray = data.Split(AttachmentRenderer.spaceDelim, StringSplitOptions.RemoveEmptyEntries); if (strArray.Length < 1) { return(false); } if (strArray[0].Equals("link")) { Vector2 labelSize = TextItem.doMeasuredTinyLabel(dpos, LocaleTerms.Loc("LINK") + " : " + strArray[1] + "@" + strArray[2], new Color?()); Computer computer = Programs.getComputer(os, strArray[2]); if (!os.netMap.visibleNodes.Contains(os.netMap.nodes.IndexOf(computer))) { AttachmentRenderer.DrawButtonGlow(dpos, labelSize, os); } if (Button.doButton(800009 + startingButtonIndex, (int)((double)dpos.X + (double)labelSize.X + 5.0), (int)dpos.Y, 20, 17, "+", new Color?())) { if (computer == null) { os.write("ERROR: Linked target not found"); } else { computer.highlightFlashTime = 1f; os.netMap.discoverNode(computer); SFX.addCircle(Programs.getComputer(os, strArray[2]).getScreenSpacePosition(), Color.White, 32f); if (buttonSound != null && !Settings.soundDisabled) { buttonSound.Play(); } } } } else if (strArray[0].Equals("account")) { Vector2 labelSize = TextItem.doMeasuredTinyLabel(dpos, LocaleTerms.Loc("ACCOUNT") + " : " + strArray[1] + " : User="******" Pass="******"+", new Color?())) { Computer computer = Programs.getComputer(os, strArray[2]); computer.highlightFlashTime = 1f; os.netMap.discoverNode(computer); computer.highlightFlashTime = 1f; SFX.addCircle(computer.getScreenSpacePosition(), Color.White, 32f); for (int index = 0; index < computer.users.Count; ++index) { UserDetail user = computer.users[index]; if (user.name.Equals(strArray[3])) { user.known = true; computer.users[index] = user; break; } } if (buttonSound != null && !Settings.soundDisabled) { buttonSound.Play(); } } } else { if (!strArray[0].Equals("note")) { return(false); } Vector2 labelSize = TextItem.doMeasuredTinyLabel(dpos, LocaleTerms.Loc("NOTE") + " : " + strArray[1], new Color?()); string note = LocalizedFileLoader.SafeFilterString(strArray[2]); if (!NotesExe.NoteExists(note, os)) { AttachmentRenderer.DrawButtonGlow(dpos, labelSize, os); } if (Button.doButton(800009 + startingButtonIndex, (int)((double)dpos.X + (double)labelSize.X + 5.0), (int)dpos.Y, 20, 17, "+", new Color?())) { NotesExe.AddNoteToOS(note, os, false); } } return(true); }