public static Color MessageColorToRGB(MessageColor p_color) { if (p_color == MessageColor.WHITE) { return(Color.white); } else if (p_color == MessageColor.LIGHT_BLUE) { return(new Color(100f / 255f, 220f / 255f, 1f)); } else if (p_color == MessageColor.BLUE) { return(new Color(0.25f, 0.25f, 1f)); } else if (p_color == MessageColor.RED) { return(new Color(1f, 0.15f, 0.15f)); } else if (p_color == MessageColor.YELLOW) { return(new Color(1f, 1f, 0.2f)); } else if (p_color == MessageColor.GREEN) { return(new Color(0f, 255f / 255f, 45f / 255f)); } return(Color.white); }
public void LogMessage(string message, MessageColor color = MessageColor.Blue) { LogSent?.Invoke(this, new LoggerEventArgs() { Message = message, Color = color }); }
public void ShowMessage(MessageColor color = MessageColor.None, string message = null, float duration = -1.0f) { messageBackgroundColor.color = Colors[(int)color]; Message.text = message == null ? "" : message; this.duration = duration == -1.0f ? 1f : duration; timer = 0.0f; isActivated = true; }
/// <summary>Creates a marker text</summary> /// <param name="text">The text to be displayed</param> /// <param name="Color">The color of the text</param> internal MarkerText(string text, MessageColor Color) { this.MessageToDisplay = text; this.Timeout = double.PositiveInfinity; this.TriggerOnce = false; this.Direction = MessageDirection.Both; this.TextColor = Color; this.RendererAlpha = 1.0; }
/// <summary>Creates a marker text</summary> /// <param name="text">The text to be displayed</param> /// <param name="Color">The color of the text</param> public MarkerText(string text, MessageColor Color) { MessageToDisplay = text; Timeout = double.PositiveInfinity; TriggerOnce = false; Direction = MessageDirection.Both; this.Color = Color; RendererAlpha = 1.0; }
/// <summary> /// Internal constructor to create a new participant. /// </summary> /// <param name="displayName">Diplay name. Cannot be null or empty.</param> /// <param name="phoneNumber">Phone number. Can be null or empty.</param> /// <param name="displayNameColor">Display name color.</param> internal ParticipantViewModel(string displayName, string phoneNumber, MessageColor displayNameColor) { this.DisplayName = displayName; if (!String.IsNullOrEmpty(this.DisplayName)) { this.DisplayName += ": "; } this.DisplayNameColor = displayNameColor; this.PhoneNumber = phoneNumber; }
/// <summary>Creates a general textual message</summary> public GeneralMessage() { Timeout = double.PositiveInfinity; TriggerOnce = true; Direction = MessageDirection.Forwards; MessageColor = MessageColor.White; MessageEarlyColor = MessageColor.White; MessageLateColor = MessageColor.White; Font = new OpenGlFont(FontFamily.GenericSansSerif, 12.0f); }
/// <summary>Creates a general textual message</summary> internal GeneralMessage() { this.Timeout = double.PositiveInfinity; this.TriggerOnce = true; this.Direction = MessageDirection.Forwards; this.MessageColor = MessageColor.White; this.MessageEarlyColor = MessageColor.White; this.MessageLateColor = MessageColor.White; this.Font = Fonts.SmallFont; }
/// <summary>Creates the foreground color for anti-aliasing text</summary> /// <param name="SystemColor">The color of the message text</param> /// <param name="Alpha">The alpha to apply</param> public Color128 CreateTextColor(MessageColor SystemColor, float Alpha) { Color128 c = new Color128(); if (this.R == 0 & this.G == 0 & this.B == 0) { switch (SystemColor) { case MessageColor.Black: c.R = 0.0f; c.G = 0.0f; c.B = 0.0f; break; case MessageColor.Gray: c.R = 0.4f; c.G = 0.4f; c.B = 0.4f; break; case MessageColor.White: c.R = 1.0f; c.G = 1.0f; c.B = 1.0f; break; case MessageColor.Red: c.R = 1.0f; c.G = 0.0f; c.B = 0.0f; break; case MessageColor.Orange: c.R = 0.9f; c.G = 0.7f; c.B = 0.0f; break; case MessageColor.Green: c.R = 0.3f; c.G = 1.0f; c.B = 0.0f; break; case MessageColor.Blue: c.R = 0.0f; c.G = 0.0f; c.B = 1.0f; break; case MessageColor.Magenta: c.R = 1.0f; c.G = 0.0f; c.B = 0.7f; break; default: c.R = 1.0f; c.G = 1.0f; c.B = 1.0f; break; } } else { c.R = inv255 * (float)this.R; c.G = inv255 * (float)this.G; c.B = inv255 * (float)this.B; } c.A = inv255 * (float)this.A * Alpha; return(c); }
private static void CreateTextColor(Color32 Original, MessageColor SystemColor, out float R, out float G, out float B, out float A) { if (Original.R == 0 & Original.G == 0 & Original.B == 0) { switch (SystemColor) { case MessageColor.Black: R = 0.0f; G = 0.0f; B = 0.0f; break; case MessageColor.Gray: R = 0.4f; G = 0.4f; B = 0.4f; break; case MessageColor.White: R = 1.0f; G = 1.0f; B = 1.0f; break; case MessageColor.Red: R = 1.0f; G = 0.0f; B = 0.0f; break; case MessageColor.Orange: R = 0.9f; G = 0.7f; B = 0.0f; break; case MessageColor.Green: R = 0.3f; G = 1.0f; B = 0.0f; break; case MessageColor.Blue: R = 1.0f; G = 1.0f; B = 1.0f; break; case MessageColor.Magenta: R = 1.0f; G = 0.0f; B = 0.7f; break; default: R = 1.0f; G = 1.0f; B = 1.0f; break; } } else { R = inv255 * (float)Original.R; G = inv255 * (float)Original.G; B = inv255 * (float)Original.B; } A = inv255 * (float)Original.A; }
private void CreateUIMessage(string p_message, MessageColor p_color) { GameObject __go = Instantiate(uiMessagePrefab); __go.transform.SetParent(messagesContainer.transform); __go.transform.localScale = Vector3.one; Text __text = __go.GetComponent <Text>(); __text.text = p_message; __text.color = Util.MessageColorToRGB(p_color); texts.Add(__text); //inputField.ActivateInputField(); StartCoroutine(VerticalScrollBarDelay(__text, true)); }
public override void AddScore(int Score, string Message, MessageColor Color, double Timeout) { Game.CurrentScore.CurrentValue += Score; int n = Game.ScoreMessages.Length; Array.Resize(ref Game.ScoreMessages, n + 1); Game.ScoreMessages[n] = new Game.ScoreMessage { Value = Score, Color = Color, RendererPosition = new Vector2(0, 0), RendererAlpha = 0.0, Text = Message, Timeout = Timeout }; }
/// <summary>Creates the background color for anti-aliasing text</summary> /// <param name="Original">The original background color</param> /// <param name="SystemColor">The color of the message text</param> private static void CreateBackColor(Color32 Original, MessageColor SystemColor, out float R, out float G, out float B, out float A) { if (Original.R == 0 & Original.G == 0 & Original.B == 0) { switch (SystemColor) { case MessageColor.Black: R = 0.0f; G = 0.0f; B = 0.0f; break; case MessageColor.Gray: R = 0.4f; G = 0.4f; B = 0.4f; break; case MessageColor.White: R = 1.0f; G = 1.0f; B = 1.0f; break; case MessageColor.Red: R = 1.0f; G = 0.0f; B = 0.0f; break; case MessageColor.Orange: R = 0.9f; G = 0.7f; B = 0.0f; break; case MessageColor.Green: R = 0.2f; G = 0.8f; B = 0.0f; break; case MessageColor.Blue: R = 0.0f; G = 0.7f; B = 1.0f; break; case MessageColor.Magenta: R = 1.0f; G = 0.0f; B = 0.7f; break; default: R = 1.0f; G = 1.0f; B = 1.0f; break; } } else { R = inv255 * (float)Original.R; G = inv255 * (float)Original.G; B = inv255 * (float)Original.B; } A = inv255 * (float)Original.A; }
private void DisplayStatusMessage(string msg, MessageColor col) { rtb_status.AppendText(DateTime.Now.ToShortTimeString() + " >> "); switch (col) { case MessageColor.Normal: rtb_status.SelectionColor = Color.Black; rtb_status.AppendText(msg + "\r\n"); break; case MessageColor.Warning: rtb_status.SelectionColor = Color.Orange; rtb_status.AppendText(msg + "\r\n"); break; case MessageColor.Error: rtb_status.SelectionColor = Color.Red; rtb_status.AppendText(msg + "\r\n"); break; } }
/// <summary> /// Saves the door definition /// </summary> /// <param name="writer">XML writer handle</param> /// <returns></returns> public override bool Save(XmlWriter writer) { if (writer == null) { return(false); } writer.WriteStartElement(Tag); writer.WriteAttributeString("color", MessageColor.ToArgb().ToString()); writer.WriteAttributeString("mustface", MustFace.ToString()); writer.WriteAttributeString("direction", Direction.ToString()); writer.WriteAttributeString("remaining", Remaining.ToString()); writer.WriteAttributeString("soundname", SoundName); writer.WriteAttributeString("loopsound", LoopSound.ToString()); writer.WriteAttributeString("displayborder", DisplayBorder.ToString()); writer.WriteAttributeString("intelligence", Intelligence.ToString()); writer.WriteAttributeString("message", Message); writer.WriteAttributeString("picturename", PictureName); // writer.WriteStartElement("text"); writer.WriteString(Text); writer.WriteEndElement(); foreach (ScriptChoice choice in Choices) { choice.Save(writer); } base.Save(writer); writer.WriteEndElement(); return(true); }
/// <summary>Adds a message to the in-game interface render queue</summary> /// <param name="Text">The text of the message</param> /// <param name="Depencency"></param> /// <param name="Mode"></param> /// <param name="Color">The color of the message text</param> /// <param name="Timeout">The time this message will display for</param> internal static void AddMessage(string Text, MessageDependency Depencency, Interface.GameMode Mode, MessageColor Color, double Timeout) { if (Interface.CurrentOptions.GameMode <= Mode) { if (Depencency == MessageDependency.RouteLimit | Depencency == MessageDependency.SectionLimit) { for (int i = 0; i < Messages.Length; i++) { if (Messages[i].Depencency == Depencency) return; } } int n = Messages.Length; Array.Resize<Message>(ref Messages, n + 1); Messages[n].InternalText = Text; Messages[n].DisplayText = ""; Messages[n].Depencency = Depencency; Messages[n].Timeout = Timeout; Messages[n].Color = Color; Messages[n].RendererPosition = new Vector2(0.0, 0.0); Messages[n].RendererAlpha = 0.0; } }
/// <summary>May be called from a .Net plugin, in order to add a message to the in-game display</summary> /// <param name="Message">The message to display</param> /// <param name="Color">The color in which to display the message</param> /// <param name="Time">The time in seconds for which to display the message</param> internal void AddInterfaceMessage(string Message, MessageColor Color, double Time) { Game.AddMessage(Message, MessageManager.MessageDependency.Plugin, Interface.GameMode.Expert, Color, Game.SecondsSinceMidnight + Time, null); }
//##Perform Message##// public static void Print(string message, MessageColor color = MessageColor.Default) { GameActions.Print(message, (ushort)color, MessageType.System, 1); }
public override void AddMessage(string Message, object MessageDependancy, GameMode Mode, MessageColor MessageColor, double MessageTimeOut, string Key) { MessageManager.AddMessage(Message, (MessageDependency)MessageDependancy, Mode, MessageColor, MessageTimeOut, Key); }
/// <summary>Renders the ATS lamp overlay</summary> /// <param name="Element">The HUD element these are to be rendererd onto</param> /// <param name="TimeElapsed">The time elapsed</param> private void RenderATSLamps(HUD.Element Element, double TimeElapsed) { if (TrainManager.PlayerTrain == null) { return; } // ats lamps if (CurrentLampCollection == null) { CurrentLampCollection = new LampCollection(TrainManager.PlayerTrain); } double lcrh, lw, rw; CalculateViewingPlaneSize(Element, out lw, out rw, out lcrh); // start // ReSharper disable once PossibleNullReferenceException int n = CurrentLampCollection.Lamps.Length; double w = CurrentLampCollection.Width + lw + rw; double h = Element.Value2 * n; double x = Element.Alignment.X < 0 ? 0.0 : Element.Alignment.X > 0 ? renderer.Screen.Width - w : 0.5 * (renderer.Screen.Width - w); double y = Element.Alignment.Y < 0 ? 0.0 : Element.Alignment.Y > 0 ? renderer.Screen.Height - h : 0.5 * (renderer.Screen.Height - h); x += Element.Position.X; y += Element.Position.Y; for (int j = 0; j < n; j++) { if (CurrentLampCollection.Lamps[j].Type != LampType.None) { int o; if (j == 0) { o = -1; } else if (CurrentLampCollection.Lamps[j - 1].Type == LampType.None) { o = -1; } else if (j < n - 1 && CurrentLampCollection.Lamps[j + 1].Type == LampType.None) { o = 1; } else if (j == n - 1) { o = 1; } else { o = 0; } HUD.Image Left = o < 0 ? Element.TopLeft : o == 0 ? Element.CenterLeft : Element.BottomLeft; HUD.Image Middle = o < 0 ? Element.TopMiddle : o == 0 ? Element.CenterMiddle : Element.BottomMiddle; HUD.Image Right = o < 0 ? Element.TopRight : o == 0 ? Element.CenterRight : Element.BottomRight; MessageColor sc = MessageColor.Gray; if (TrainManager.PlayerTrain.Plugin.Panel.Length >= 272) { switch (CurrentLampCollection.Lamps[j].Type) { case LampType.Ats: if (TrainManager.PlayerTrain.Plugin.Panel[256] != 0) { sc = MessageColor.Orange; } break; case LampType.AtsOperation: if (TrainManager.PlayerTrain.Plugin.Panel[258] != 0) { sc = MessageColor.Red; } break; case LampType.AtsPPower: if (TrainManager.PlayerTrain.Plugin.Panel[259] != 0) { sc = MessageColor.Green; } break; case LampType.AtsPPattern: if (TrainManager.PlayerTrain.Plugin.Panel[260] != 0) { sc = MessageColor.Orange; } break; case LampType.AtsPBrakeOverride: if (TrainManager.PlayerTrain.Plugin.Panel[261] != 0) { sc = MessageColor.Orange; } break; case LampType.AtsPBrakeOperation: if (TrainManager.PlayerTrain.Plugin.Panel[262] != 0) { sc = MessageColor.Orange; } break; case LampType.AtsP: if (TrainManager.PlayerTrain.Plugin.Panel[263] != 0) { sc = MessageColor.Green; } break; case LampType.AtsPFailure: if (TrainManager.PlayerTrain.Plugin.Panel[264] != 0) { sc = MessageColor.Red; } break; case LampType.Atc: if (TrainManager.PlayerTrain.Plugin.Panel[265] != 0) { sc = MessageColor.Orange; } break; case LampType.AtcPower: if (TrainManager.PlayerTrain.Plugin.Panel[266] != 0) { sc = MessageColor.Orange; } break; case LampType.AtcUse: if (TrainManager.PlayerTrain.Plugin.Panel[267] != 0) { sc = MessageColor.Orange; } break; case LampType.AtcEmergency: if (TrainManager.PlayerTrain.Plugin.Panel[268] != 0) { sc = MessageColor.Red; } break; case LampType.Eb: if (TrainManager.PlayerTrain.Plugin.Panel[270] != 0) { sc = MessageColor.Green; } break; case LampType.ConstSpeed: if (TrainManager.PlayerTrain.Plugin.Panel[269] != 0) { sc = MessageColor.Orange; } break; } } // colors Color128 bc = Element.BackgroundColor.CreateBackColor(sc, 1.0f); Color128 tc = Element.TextColor.CreateTextColor(sc, 1.0f); Color128 oc = Element.OverlayColor.CreateBackColor(sc, 1.0f); // left background if (Left.BackgroundTexture != null) { if (Program.CurrentHost.LoadTexture(ref Left.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp)) { double u = Left.BackgroundTexture.Width; double v = Left.BackgroundTexture.Height; renderer.Rectangle.Draw(Left.BackgroundTexture, new Vector2(x, y), new Vector2(u, v), bc); } } // right background if (Right.BackgroundTexture != null) { if (Program.CurrentHost.LoadTexture(ref Right.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp)) { double u = Right.BackgroundTexture.Width; double v = Right.BackgroundTexture.Height; renderer.Rectangle.Draw(Right.BackgroundTexture, new Vector2(x + w - u, y), new Vector2(u, v), bc); } } // middle background if (Middle.BackgroundTexture != null) { if (Program.CurrentHost.LoadTexture(ref Middle.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp)) { double v = Middle.BackgroundTexture.Height; renderer.Rectangle.Draw(Middle.BackgroundTexture, new Vector2(x + lw, y), new Vector2(w - lw - rw, v), bc); } } { // text string t = CurrentLampCollection.Lamps[j].Text; double u = CurrentLampCollection.Lamps[j].Width; double v = CurrentLampCollection.Lamps[j].Height; double p = Math.Round(Element.TextAlignment.X < 0 ? x : Element.TextAlignment.X > 0 ? x + w - u : x + 0.5 * (w - u)); double q = Math.Round(Element.TextAlignment.Y < 0 ? y : Element.TextAlignment.Y > 0 ? y + lcrh - v : y + 0.5 * (lcrh - v)); p += Element.TextPosition.X; q += Element.TextPosition.Y; renderer.OpenGlString.Draw(Element.Font, t, new Vector2(p, q), TextAlignment.TopLeft, tc, Element.TextShadow); } // left overlay if (Left.OverlayTexture != null) { if (Program.CurrentHost.LoadTexture(ref Left.OverlayTexture, OpenGlTextureWrapMode.ClampClamp)) { double u = Left.OverlayTexture.Width; double v = Left.OverlayTexture.Height; renderer.Rectangle.Draw(Left.OverlayTexture, new Vector2(x, y), new Vector2(u, v), oc); } } // right overlay if (Right.OverlayTexture != null) { if (Program.CurrentHost.LoadTexture(ref Right.OverlayTexture, OpenGlTextureWrapMode.ClampClamp)) { double u = Right.OverlayTexture.Width; double v = Right.OverlayTexture.Height; renderer.Rectangle.Draw(Right.OverlayTexture, new Vector2(x + w - u, y), new Vector2(u, v), oc); } } // middle overlay if (Middle.OverlayTexture != null) { if (Program.CurrentHost.LoadTexture(ref Middle.OverlayTexture, OpenGlTextureWrapMode.ClampClamp)) { double v = Middle.OverlayTexture.Height; renderer.Rectangle.Draw(Middle.OverlayTexture, new Vector2(x + lw, y), new Vector2(w - lw - rw, v), oc); } } } y += Element.Value2; } }
private void OnColor(MessageColor data) { m_color = CSSParse.Style.ParseCSSColor(data.color); gameObject.renderer.material.color = m_color; }
public ChatMessageReceivedEvent(IClient client, int messageId, MessageColor color) { Client = client; MessageId = messageId; Color = color; }
void CalculateConditions() { //reset some stuff outAuthCode = 0; for (int i = 0; i < 4; i++) { ConfirmDigits[i].text = "0"; } for (int i = 0; i < 10; i++) { Digits[i].text = "0"; } //voice actor today = DateTime.Today; if (voiceIndex == -1) { voiceIndex = Rand.Range(0, baseActors.Count()); if (today.Month == 4 && today.Day == 1) { voiceIndex = 3; Voice = VoiceActor.GoldFish; } else { Voice = baseActors[voiceIndex]; } } DebugLog("Your voice actor is " + Voice.ToString() + "."); //siloID siloID = ""; string siloBuild = ToChar((Bomb.GetBatteryHolderCount() % 36).ToString(), 0) + ToChar((Bomb.GetBatteryCount() % 36).ToString(), 0) + ToChar((Bomb.GetPortPlateCount() % 36).ToString(), 0); for (int i = 0; i < 3; i++) { int result = -1; if (int.TryParse(siloBuild[i].ToString(), out result)) { if (result == 0) { siloID += Bomb.GetSerialNumberLetters().First(); } else if (result > 0) { siloID += siloBuild[i]; } } else { siloID += siloBuild[i]; } } //message calculation int wrongIndex = Rand.Range(0, 10); outMessages[1] = ToChar(Rand.Range(10, 36).ToString(), 0) + (Bomb.GetIndicators().ToArray().Count() < 1 ? "MRP" : Bomb.GetIndicators().ToArray()[Rand.Range(0, Bomb.GetIndicators().ToArray().Count())]); if (wrongIndex == 4 || wrongIndex == 5 || wrongIndex == 8 || wrongIndex == 9) { for (int i = 0; i < Rand.Range(1, 3); i++) { int index2 = Rand.Range(1, 4); int index3 = Rand.Range(0, 26); if (index2 == 1) { outMessages[1] = "" + outMessages[1][0] + Alphabet[index3] + outMessages[1][2] + outMessages[1][3]; } else if (index2 == 2) { outMessages[1] = "" + outMessages[1][0] + outMessages[1][1] + Alphabet[index3] + outMessages[1][3]; } else { outMessages[1] = "" + outMessages[1][0] + outMessages[1][1] + outMessages[1][2] + Alphabet[index3]; } } } outMessages[0] = outMessages[1][0].ToString() + Encryptor(outMessages[1][1].ToString() + outMessages[1][2].ToString() + outMessages[1][3].ToString(), outMessages[1][0].ToString(), true); outMessages[3] = ToChar(Rand.Range(10, 36).ToString(), 0) + Bomb.GetSerialNumber()[0] + Bomb.GetSerialNumber()[2] + Bomb.GetSerialNumber()[5]; if (wrongIndex > 5) { for (int i = 0; i < Rand.Range(1, 3); i++) { int index2 = Rand.Range(1, 4); int index3 = Rand.Range(0, 26); if (index2 == 1) { outMessages[3] = "" + outMessages[3][0] + Alphabet[index3] + outMessages[3][2] + outMessages[3][3]; } else if (index2 == 2) { outMessages[3] = "" + outMessages[3][0] + outMessages[3][1] + Alphabet[index3] + outMessages[3][3]; } else { outMessages[3] = "" + outMessages[3][0] + outMessages[3][1] + outMessages[3][2] + Alphabet[index3]; } } } outMessages[2] = outMessages[3][0].ToString() + Encryptor(outMessages[3][1].ToString() + outMessages[3][2].ToString() + outMessages[3][3].ToString(), outMessages[3][0].ToString(), true); outMessages[2] = outMessages[3][0].ToString() + Encryptor(outMessages[3][1].ToString() + outMessages[3][2].ToString() + outMessages[3][3].ToString(), outMessages[3][0].ToString(), true); Log("The first part of the message is " + outMessages[1] + ", which is encrypted as " + outMessages[0] + "."); Log("The second part of the message is " + outMessages[3] + ", which is encrypted as " + outMessages[2] + "."); //authentication outAuthCode = 0; int[] logAuth = new int[6] { 0, 0, 0, 0, 0, 0 }; for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { logAuth[j + (3 * i)] += (ToNum(outMessages[1 + (2 * i)][j + 1].ToString(), 0) * ToNum(Bomb.GetSerialNumber()[j + (3 * i)].ToString(), 0)); outAuthCode += logAuth[j + (3 * i)]; } } string build = "The Authentication numbers are "; for (int i = 0; i < 6; i++) { build += logAuth[i].ToString() + (i == 4 ? " and " : ", "); } Log(build + "which totals up to " + (outAuthCode % 10000).ToString("0000") + "."); if (Rand.Range(0, 3) == 2) { outAuthCode = (outAuthCode + Rand.Range(1, 10000)) % 10000; correctParts[2] = false; } else { correctParts[2] = true; } Log("You are given " + outAuthCode.ToString("0000") + ", which is " + (correctParts[2] ? "valid." : "invalid.")); //color / type int colorIndex = Rand.Range(0, 5); correctColor = colorIndex == 0 ? MessageColor.Red : colorIndex < 3 ? MessageColor.Yellow : MessageColor.Green; Log("Your message type is " + ((correctColor == MessageColor.Red) ? "Red-Alpha" : correctColor == MessageColor.Yellow ? "Yellow-Alpha" : "Green-Alpha") + "."); //message checking string[] checkParts = new string[2] { Encryptor(outMessages[0][1].ToString() + outMessages[0][2].ToString() + outMessages[0][3].ToString(), outMessages[0][0].ToString(), false), Encryptor(outMessages[2][1].ToString() + outMessages[2][2].ToString() + outMessages[2][3].ToString(), outMessages[2][0].ToString(), false) }; correctParts[0] = Bomb.GetIndicators().Count() == 0 ? checkParts[0] == "MRP" : Bomb.GetIndicators().Any(str => str == checkParts[0]); correctParts[1] = Bomb.GetSerialNumber().Contains(checkParts[1][0]) && Bomb.GetSerialNumber().Contains(checkParts[1][1]) && Bomb.GetSerialNumber().Contains(checkParts[1][2]); Log("The first part of the message is " + (correctParts[0] ? "valid" : "invalid") + ", and the second part of the message is " + (correctParts[1] ? "valid." : "invalid.")); Log("The Silo ID is " + siloID + "."); if (!correctParts[2]) { correctResponse = ResponseType.Jamming; Log("The Authentication code is invalid, you must respond with a Jamming message."); } else if (!correctParts[0] && !correctParts[1]) { correctResponse = ResponseType.Error; Log("Both parts of the message are invalid, you must respond with an Error message."); } else if (correctParts[0] && correctParts[1]) { correctResponse = ResponseType.Either; Log("Both parts of the message are valid, you may respond with either."); } else if (correctParts[0]) { correctResponse = ResponseType.First; Log("Only the first part of the message is valid, you must respond with it."); } else if (correctParts[1]) { correctResponse = ResponseType.Second; Log("Only the second part of the message is valid, you must respond with it."); } else { Log("Something went wrong, no solution was identified."); } DebugLog(CalculateSolution()); }
/// <summary>Renders all default HUD elements</summary> /// <param name="Element">The HUD element these are to be rendererd onto</param> /// <param name="TimeElapsed">The time elapsed</param> private static void RenderHUDElement(Interface.HudElement Element, double TimeElapsed) { TrainManager.TrainDoorState LeftDoors = TrainManager.GetDoorsState(TrainManager.PlayerTrain, true, false); TrainManager.TrainDoorState RightDoors = TrainManager.GetDoorsState(TrainManager.PlayerTrain, false, true); System.Globalization.CultureInfo Culture = System.Globalization.CultureInfo.InvariantCulture; string Command = Element.Subject.ToLowerInvariant(); // default double w, h; if (Element.CenterMiddle.BackgroundTexture != null) { if (Textures.LoadTexture(Element.CenterMiddle.BackgroundTexture, Textures.OpenGlTextureWrapMode.ClampClamp)) { w = (double)Element.CenterMiddle.BackgroundTexture.Width; h = (double)Element.CenterMiddle.BackgroundTexture.Height; } else { w = 0.0; h = 0.0; } } else { w = 0.0; h = 0.0; } double x = Element.Alignment.X < 0 ? 0.0 : Element.Alignment.X == 0 ? 0.5 * (Screen.Width - w) : Screen.Width - w; double y = Element.Alignment.Y < 0 ? 0.0 : Element.Alignment.Y == 0 ? 0.5 * (Screen.Height - h) : Screen.Height - h; x += Element.Position.X; y += Element.Position.Y; // command const double speed = 1.0; MessageColor sc = MessageColor.None; string t; switch (Command) { case "reverser": if (TrainManager.PlayerTrain.Handles.Reverser.Driver < 0) { sc = MessageColor.Orange; if (TrainManager.PlayerTrain.ReverserDescriptions != null && TrainManager.PlayerTrain.ReverserDescriptions.Length > 2) { t = TrainManager.PlayerTrain.ReverserDescriptions[2]; } else { t = Interface.QuickReferences.HandleBackward; } } else if (TrainManager.PlayerTrain.Handles.Reverser.Driver > 0) { sc = MessageColor.Blue; if (TrainManager.PlayerTrain.ReverserDescriptions != null && TrainManager.PlayerTrain.ReverserDescriptions.Length > 0) { t = TrainManager.PlayerTrain.ReverserDescriptions[0]; } else { t = Interface.QuickReferences.HandleForward; } } else { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.ReverserDescriptions != null && TrainManager.PlayerTrain.ReverserDescriptions.Length > 1) { t = TrainManager.PlayerTrain.ReverserDescriptions[1]; } else { t = Interface.QuickReferences.HandleNeutral; } } Element.TransitionState = 0.0; break; case "power": if (TrainManager.PlayerTrain.Handles.SingleHandle) { return; } if (TrainManager.PlayerTrain.Handles.Power.Driver == 0) { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.PowerNotchDescriptions.Length > 0) { t = TrainManager.PlayerTrain.PowerNotchDescriptions[0]; } else { t = Interface.QuickReferences.HandlePowerNull; } } else { sc = MessageColor.Blue; if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.Handles.Power.Driver < TrainManager.PlayerTrain.PowerNotchDescriptions.Length) { t = TrainManager.PlayerTrain.PowerNotchDescriptions[TrainManager.PlayerTrain.Handles.Power.Driver]; } else { t = Interface.QuickReferences.HandlePower + TrainManager.PlayerTrain.Handles.Power.Driver.ToString(Culture); } } Element.TransitionState = 0.0; break; case "brake": if (TrainManager.PlayerTrain.Handles.SingleHandle) { return; } if (TrainManager.PlayerTrain.Cars[TrainManager.PlayerTrain.DriverCar].Specs.BrakeType == TrainManager.CarBrakeType.AutomaticAirBrake) { if (TrainManager.PlayerTrain.Handles.EmergencyBrake.Driver) { sc = MessageColor.Red; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 0) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[0]; } else { t = Interface.QuickReferences.HandleEmergency; } } else if (TrainManager.PlayerTrain.Handles.AirBrake.Handle.Driver == TrainManager.AirBrakeHandleState.Release) { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 1) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[1]; } else { t = Interface.QuickReferences.HandleRelease; } } else if (TrainManager.PlayerTrain.Handles.AirBrake.Handle.Driver == TrainManager.AirBrakeHandleState.Lap) { sc = MessageColor.Blue; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 2) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[2]; } else { t = Interface.QuickReferences.HandleLap; } } else { sc = MessageColor.Orange; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 3) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[3]; } else { t = Interface.QuickReferences.HandleService; } } } else { if (TrainManager.PlayerTrain.Handles.EmergencyBrake.Driver) { sc = MessageColor.Red; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 0) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[0]; } else { t = Interface.QuickReferences.HandleEmergency; } } else if (TrainManager.PlayerTrain.Handles.HoldBrake.Driver) { sc = MessageColor.Green; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 2) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[2]; } else { t = Interface.QuickReferences.HandleHoldBrake; } } else if (TrainManager.PlayerTrain.Handles.Brake.Driver == 0) { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 1) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[1]; } else { t = Interface.QuickReferences.HandleBrakeNull; } } else { sc = MessageColor.Orange; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && ((TrainManager.PlayerTrain.Handles.HasHoldBrake && TrainManager.PlayerTrain.Handles.Brake.Driver + 2 < TrainManager.PlayerTrain.BrakeNotchDescriptions.Length) || (!TrainManager.PlayerTrain.Handles.HasHoldBrake && TrainManager.PlayerTrain.Handles.Brake.Driver + 1 < TrainManager.PlayerTrain.BrakeNotchDescriptions.Length))) { t = TrainManager.PlayerTrain.Handles.HasHoldBrake ? TrainManager.PlayerTrain.BrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.Brake.Driver + 2] : TrainManager.PlayerTrain.BrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.Brake.Driver + 1]; } else { t = Interface.QuickReferences.HandleBrake + TrainManager.PlayerTrain.Handles.Brake.Driver.ToString(Culture); } } } Element.TransitionState = 0.0; break; case "locobrake": if (!TrainManager.PlayerTrain.Handles.HasLocoBrake) { return; } if (TrainManager.PlayerTrain.Handles.LocoBrake.Driver == 0) { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.LocoBrakeNotchDescriptions != null && TrainManager.PlayerTrain.LocoBrakeNotchDescriptions.Length > 1) { t = TrainManager.PlayerTrain.LocoBrakeNotchDescriptions[1]; } else { t = Interface.QuickReferences.HandleBrakeNull; } } else { sc = MessageColor.Orange; if (TrainManager.PlayerTrain.LocoBrakeNotchDescriptions != null && TrainManager.PlayerTrain.Handles.LocoBrake.Driver < TrainManager.PlayerTrain.LocoBrakeNotchDescriptions.Length) { t = TrainManager.PlayerTrain.LocoBrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.LocoBrake.Driver]; } else { t = Interface.QuickReferences.HandleLocoBrake + TrainManager.PlayerTrain.Handles.LocoBrake.Driver.ToString(Culture); } } Element.TransitionState = 0.0; break; case "single": if (!TrainManager.PlayerTrain.Handles.SingleHandle) { return; } if (TrainManager.PlayerTrain.Handles.EmergencyBrake.Driver) { sc = MessageColor.Red; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 0) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[0]; } else { t = Interface.QuickReferences.HandleEmergency; } } else if (TrainManager.PlayerTrain.Handles.HoldBrake.Driver) { sc = MessageColor.Green; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 1) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[1]; } else { t = Interface.QuickReferences.HandleHoldBrake; } } else if (TrainManager.PlayerTrain.Handles.Brake.Driver > 0) { sc = MessageColor.Orange; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.Handles.Brake.Driver + 3 < TrainManager.PlayerTrain.BrakeNotchDescriptions.Length) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.Brake.Driver + 3]; } else { t = Interface.QuickReferences.HandleBrake + TrainManager.PlayerTrain.Handles.Brake.Driver.ToString(Culture); } } else if (TrainManager.PlayerTrain.Handles.Power.Driver > 0) { sc = MessageColor.Blue; if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.Handles.Power.Driver < TrainManager.PlayerTrain.PowerNotchDescriptions.Length) { t = TrainManager.PlayerTrain.PowerNotchDescriptions[TrainManager.PlayerTrain.Handles.Power.Driver]; } else { t = Interface.QuickReferences.HandlePower + TrainManager.PlayerTrain.Handles.Power.Driver.ToString(Culture); } } else { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.PowerNotchDescriptions.Length > 0) { t = TrainManager.PlayerTrain.PowerNotchDescriptions[0]; } else { t = Interface.QuickReferences.HandlePowerNull; } } Element.TransitionState = 0.0; break; case "doorsleft": case "doorsright": { if ((LeftDoors & TrainManager.TrainDoorState.AllClosed) == 0 | (RightDoors & TrainManager.TrainDoorState.AllClosed) == 0) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } TrainManager.TrainDoorState Doors = Command == "doorsleft" ? LeftDoors : RightDoors; if ((Doors & TrainManager.TrainDoorState.Mixed) != 0) { sc = MessageColor.Orange; } else if ((Doors & TrainManager.TrainDoorState.AllClosed) != 0) { sc = MessageColor.Gray; } else if (TrainManager.PlayerTrain.Specs.DoorCloseMode == TrainManager.DoorMode.Manual) { sc = MessageColor.Green; } else { sc = MessageColor.Blue; } t = Command == "doorsleft" ? Interface.QuickReferences.DoorsLeft : Interface.QuickReferences.DoorsRight; } break; case "stopleft": case "stopright": case "stopnone": { int s = TrainManager.PlayerTrain.Station; if (s >= 0 && Game.PlayerStopsAtStation(s) && Interface.CurrentOptions.GameMode != Interface.GameMode.Expert) { bool cond; if (Command == "stopleft") { cond = Game.Stations[s].OpenLeftDoors; } else if (Command == "stopright") { cond = Game.Stations[s].OpenRightDoors; } else { cond = !Game.Stations[s].OpenLeftDoors & !Game.Stations[s].OpenRightDoors; } if (TrainManager.PlayerTrain.StationState == TrainManager.TrainStopState.Pending & cond) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } t = Element.Text; } break; case "stoplefttick": case "stoprighttick": case "stopnonetick": { int s = TrainManager.PlayerTrain.Station; if (s >= 0 && Game.PlayerStopsAtStation(s) && Interface.CurrentOptions.GameMode != Interface.GameMode.Expert) { int c = Game.GetStopIndex(s, TrainManager.PlayerTrain.Cars.Length); if (c >= 0) { bool cond; if (Command == "stoplefttick") { cond = Game.Stations[s].OpenLeftDoors; } else if (Command == "stoprighttick") { cond = Game.Stations[s].OpenRightDoors; } else { cond = !Game.Stations[s].OpenLeftDoors & !Game.Stations[s].OpenRightDoors; } if (TrainManager.PlayerTrain.StationState == TrainManager.TrainStopState.Pending & cond) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } double d = TrainManager.PlayerTrain.StationDistanceToStopPoint; double r; if (d > 0.0) { r = d / Game.Stations[s].Stops[c].BackwardTolerance; } else { r = d / Game.Stations[s].Stops[c].ForwardTolerance; } if (r < -1.0) { r = -1.0; } if (r > 1.0) { r = 1.0; } y -= r * (double)Element.Value1; } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } t = Element.Text; } break; case "clock": { int hours = (int)Math.Floor(Game.SecondsSinceMidnight); int seconds = hours % 60; hours /= 60; int minutes = hours % 60; hours /= 60; hours %= 24; t = hours.ToString(Culture).PadLeft(2, '0') + ":" + minutes.ToString(Culture).PadLeft(2, '0') + ":" + seconds.ToString(Culture).PadLeft(2, '0'); if (OptionClock) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } } break; case "gradient": if (OptionGradient == GradientDisplayMode.Percentage) { if (World.CameraTrackFollower.Pitch != 0) { double pc = World.CameraTrackFollower.Pitch; t = Math.Abs(pc).ToString("0.00", Culture) + "%" + (Math.Abs(pc) == pc ? " ↗" : " ↘"); } else { t = "Level"; } Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else if (OptionGradient == GradientDisplayMode.UnitOfChange) { if (World.CameraTrackFollower.Pitch != 0) { double gr = 1000 / World.CameraTrackFollower.Pitch; t = "1 in " + Math.Abs(gr).ToString("0", Culture) + (Math.Abs(gr) == gr ? " ↗" : " ↘"); } else { t = "Level"; } Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { if (World.CameraTrackFollower.Pitch != 0) { double gr = 1000 / World.CameraTrackFollower.Pitch; t = "1 in " + Math.Abs(gr).ToString("0", Culture) + (Math.Abs(gr) == gr ? " ↗" : " ↘"); } else { t = "Level"; } Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } break; case "speed": if (OptionSpeed == SpeedDisplayMode.Kmph) { double kmph = Math.Abs(TrainManager.PlayerTrain.Specs.CurrentAverageSpeed) * 3.6; t = kmph.ToString("0.00", Culture) + " km/h"; Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else if (OptionSpeed == SpeedDisplayMode.Mph) { double mph = Math.Abs(TrainManager.PlayerTrain.Specs.CurrentAverageSpeed) * 2.2369362920544; t = mph.ToString("0.00", Culture) + " mph"; Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { double mph = Math.Abs(TrainManager.PlayerTrain.Specs.CurrentAverageSpeed) * 2.2369362920544; t = mph.ToString("0.00", Culture) + " mph"; Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } break; case "fps": int fps = (int)Math.Round(Game.InfoFrameRate); t = fps.ToString(Culture) + " fps"; if (OptionFrameRates) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } break; case "ai": t = "A.I."; if (TrainManager.PlayerTrain.AI != null) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } break; case "score": if (Interface.CurrentOptions.GameMode == Interface.GameMode.Arcade) { t = Game.CurrentScore.CurrentValue.ToString(Culture) + " / " + Game.CurrentScore.Maximum.ToString(Culture); if (Game.CurrentScore.CurrentValue < 0) { sc = MessageColor.Red; } else if (Game.CurrentScore.CurrentValue > 0) { sc = MessageColor.Green; } else { sc = MessageColor.Gray; } Element.TransitionState = 0.0; } else { Element.TransitionState = 1.0; t = ""; } break; default: t = Element.Text; break; } // transitions float alpha = 1.0f; if ((Element.Transition & Interface.HudTransition.Move) != 0) { double s = Element.TransitionState; x += Element.TransitionVector.X * s * s; y += Element.TransitionVector.Y * s * s; } if ((Element.Transition & Interface.HudTransition.Fade) != 0) { alpha = (float)(1.0 - Element.TransitionState); } else if (Element.Transition == Interface.HudTransition.None) { alpha = (float)(1.0 - Element.TransitionState); } // render if (alpha != 0.0f) { // background if (Element.Subject == "reverser") { w = Math.Max(w, TrainManager.PlayerTrain.MaxReverserWidth); //X-Pos doesn't need to be changed } if (Element.Subject == "power") { w = Math.Max(w, TrainManager.PlayerTrain.MaxPowerNotchWidth); if (TrainManager.PlayerTrain.MaxReverserWidth > 48) { x += (TrainManager.PlayerTrain.MaxReverserWidth - 48); } } if (Element.Subject == "brake") { w = Math.Max(w, TrainManager.PlayerTrain.MaxBrakeNotchWidth); if (TrainManager.PlayerTrain.MaxReverserWidth > 48) { x += (TrainManager.PlayerTrain.MaxReverserWidth - 48); } if (TrainManager.PlayerTrain.MaxPowerNotchWidth > 48) { x += (TrainManager.PlayerTrain.MaxPowerNotchWidth - 48); } } if (Element.Subject == "single") { w = Math.Max(Math.Max(w, TrainManager.PlayerTrain.MaxPowerNotchWidth), TrainManager.PlayerTrain.MaxBrakeNotchWidth); if (TrainManager.PlayerTrain.MaxReverserWidth > 48) { x += (TrainManager.PlayerTrain.MaxReverserWidth - 48); } } if (Element.CenterMiddle.BackgroundTexture != null) { if (Textures.LoadTexture(Element.CenterMiddle.BackgroundTexture, Textures.OpenGlTextureWrapMode.ClampClamp)) { float r, g, b, a; CreateBackColor(Element.BackgroundColor, sc, out r, out g, out b, out a); GL.Color4(r, g, b, a * alpha); RenderOverlayTexture(Element.CenterMiddle.BackgroundTexture, x, y, x + w, y + h); } } { // text System.Drawing.Size size = MeasureString(Element.Font, t); float u = size.Width; float v = size.Height; double p = Math.Round(Element.TextAlignment.X < 0 ? x : Element.TextAlignment.X == 0 ? x + 0.5 * (w - u) : x + w - u); double q = Math.Round(Element.TextAlignment.Y < 0 ? y : Element.TextAlignment.Y == 0 ? y + 0.5 * (h - v) : y + h - v); p += Element.TextPosition.X; q += Element.TextPosition.Y; float r, g, b, a; CreateTextColor(Element.TextColor, sc, out r, out g, out b, out a); DrawString(Element.Font, t, new System.Drawing.Point((int)p, (int)q), TextAlignment.TopLeft, new Color128(r, g, b, a * alpha), Element.TextShadow); } // overlay if (Element.CenterMiddle.OverlayTexture != null) { if (Textures.LoadTexture(Element.CenterMiddle.OverlayTexture, Textures.OpenGlTextureWrapMode.ClampClamp)) { float r, g, b, a; CreateBackColor(Element.OverlayColor, sc, out r, out g, out b, out a); GL.Color4(r, g, b, a * alpha); RenderOverlayTexture(Element.CenterMiddle.OverlayTexture, x, y, x + w, y + h); } } } }
/// <summary>May be called from a .Net plugin, in order to add a message to the in-game display</summary> /// <param name="Message">The message to display</param> /// <param name="Color">The color in which to display the message</param> /// <param name="Time">The time in seconds for which to display the message</param> internal void AddInterfaceMessage(string Message, MessageColor Color, double Time) { MessageManager.AddMessage(Message, MessageDependency.Plugin, GameMode.Expert, Color, Program.CurrentRoute.SecondsSinceMidnight + Time, null); }
private void OnColor(MessageColor data) { m_color = CSSParse.Style.ParseCSSColor(data.color); gameObject.GetComponent<Renderer>().material.color = m_color; }
/// <summary>May be called from a .Net plugin, in order to add a message to the in-game display</summary> /// <param name="Message">The message to display</param> /// <param name="Color">The color in which to display the message</param> /// <param name="Time">The time in seconds for which to display the message</param> internal void AddInterfaceMessage(string Message, MessageColor Color, double Time) { TrainManagerBase.currentHost.AddMessage(Message, MessageDependency.Plugin, GameMode.Expert, Color, TrainManagerBase.currentHost.InGameTime + Time, null); }
private void OnColor(MessageColor data) { SetColor(CSSParse.Style.ParseCSSColor(data.color)); }
/// <summary>Adds a message to the in-game display</summary> /// <param name="Message">The text of the message</param> /// <param name="MessageDependancy">The dependancy of the message</param> /// <param name="Mode">The required game mode for the message to display</param> /// <param name="MessageColor">The color of the message font</param> /// <param name="MessageTimeOut">The timeout of the message</param> /// <param name="Key">The mesage key</param> public virtual void AddMessage(string Message, object MessageDependancy, GameMode Mode, MessageColor MessageColor, double MessageTimeOut, string Key) { }
public static bool ReadMarkerXML(string fileName, double StartingPosition, ref Marker Marker) { double EndingPosition = Double.PositiveInfinity; AbstractMessage Message = null; //The current XML file to load XmlDocument currentXML = new XmlDocument(); //Load the marker's XML file currentXML.Load(fileName); string Path = System.IO.Path.GetDirectoryName(fileName); if (currentXML.DocumentElement != null) { bool iM = false; XmlNodeList DocumentNodes = currentXML.DocumentElement.SelectNodes("/openBVE/TextMarker"); if (DocumentNodes == null || DocumentNodes.Count == 0) { DocumentNodes = currentXML.DocumentElement.SelectNodes("/openBVE/ImageMarker"); iM = true; } if (DocumentNodes == null || DocumentNodes.Count == 0) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "No marker nodes defined in XML file " + fileName); return(false); } foreach (XmlNode n in DocumentNodes) { if (n.ChildNodes.OfType <XmlElement>().Any()) { bool EarlyDefined = false, LateDefined = false; string EarlyText = null, Text = null, LateText = null; string[] Trains = null; Texture EarlyTexture = null, Texture = null, LateTexture = null; double EarlyTime = 0.0, LateTime = 0.0, TimeOut = Double.PositiveInfinity; MessageColor EarlyColor = MessageColor.White, OnTimeColor = MessageColor.White, LateColor = MessageColor.White; foreach (XmlNode c in n.ChildNodes) { switch (c.Name.ToLowerInvariant()) { case "early": if (!c.ChildNodes.OfType <XmlElement>().Any()) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "No paramaters defined for the early message in " + fileName); } foreach (XmlNode cc in c.ChildNodes) { switch (cc.Name.ToLowerInvariant()) { case "text": EarlyText = cc.InnerText; break; case "texture": case "image": string f; try { f = OpenBveApi.Path.CombineFile(Path, cc.InnerText); } catch { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "MessageEarlyTexture path was malformed in file " + fileName); break; } if (System.IO.File.Exists(f)) { if (!Plugin.CurrentHost.RegisterTexture(f, new TextureParameters(null, null), out EarlyTexture)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Loading MessageEarlyTexture " + f + " failed."); } } else { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "MessageEarlyTexture " + f + " does not exist."); } break; case "time": if (!Parser.TryParseTime(cc.InnerText, out EarlyTime)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Early message time invalid in " + fileName); } EarlyDefined = true; break; case "color": EarlyColor = ParseColor(cc.InnerText, fileName); break; } } break; case "ontime": if (!c.ChildNodes.OfType <XmlElement>().Any()) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "No paramaters defined for the on-time message in " + fileName); } foreach (XmlNode cc in c.ChildNodes) { switch (cc.Name.ToLowerInvariant()) { case "text": Text = cc.InnerText; break; case "texture": case "image": string f; try { f = OpenBveApi.Path.CombineFile(Path, cc.InnerText); } catch { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "MessageTexture path was malformed in file " + fileName); break; } if (System.IO.File.Exists(f)) { if (!Plugin.CurrentHost.RegisterTexture(f, new TextureParameters(null, null), out Texture)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Loading MessageTexture " + f + " failed."); } } else { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "MessageTexture " + f + " does not exist."); } break; case "color": OnTimeColor = ParseColor(cc.InnerText, fileName); break; case "time": Plugin.CurrentHost.AddMessage(MessageType.Error, false, "OnTime should not contain a TIME declaration in " + fileName); break; } } break; case "late": if (!c.ChildNodes.OfType <XmlElement>().Any()) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "No paramaters defined for the late message in " + fileName); } foreach (XmlNode cc in c.ChildNodes) { switch (cc.Name.ToLowerInvariant()) { case "text": LateText = cc.InnerText; break; case "texture": case "image": string f; try { f = OpenBveApi.Path.CombineFile(Path, cc.InnerText); } catch { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "MessageLateTexture path was malformed in file " + fileName); break; } if (System.IO.File.Exists(f)) { if (!Plugin.CurrentHost.RegisterTexture(f, new TextureParameters(null, null), out LateTexture)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Loading MessageLateTexture " + f + " failed."); } } else { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "MessageLateTexture " + f + " does not exist."); } break; case "time": if (!Parser.TryParseTime(cc.InnerText, out LateTime)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Early message time invalid in " + fileName); } LateDefined = true; break; case "color": LateColor = ParseColor(cc.InnerText, fileName); break; } } break; case "timeout": if (!NumberFormats.TryParseDouble(c.InnerText, new[] { 1.0 }, out TimeOut)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Marker timeout invalid in " + fileName); } break; case "distance": if (!NumberFormats.TryParseDouble(c.InnerText, new[] { 1.0 }, out EndingPosition)) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "Marker distance invalid in " + fileName); } break; case "trains": Trains = c.InnerText.Split(';'); break; } } //Check this marker is valid if (TimeOut == Double.PositiveInfinity && EndingPosition == Double.PositiveInfinity) { Plugin.CurrentHost.AddMessage(MessageType.Error, false, "No marker timeout or distance defined in marker XML " + fileName); return(false); } if (EndingPosition != Double.PositiveInfinity) { if (Math.Abs(EndingPosition) == EndingPosition) { //Positive EndingPosition = StartingPosition + EndingPosition; } else { //Negative EndingPosition = StartingPosition; StartingPosition -= EndingPosition; } } TextureMessage t = new TextureMessage(Plugin.CurrentHost); GeneralMessage m = new GeneralMessage(); //Add variants if (EarlyDefined) { if (iM) { if (EarlyTexture != null) { t.MessageEarlyTime = EarlyTime; t.MessageEarlyTexture = EarlyTexture; } else { Plugin.CurrentHost.AddMessage(MessageType.Warning, false, "An early time was defined, but no message was specified in MarkerXML " + fileName); } } else { if (EarlyText != null) { m.MessageEarlyTime = EarlyTime; m.MessageEarlyText = EarlyText; m.MessageEarlyColor = EarlyColor; } else { Plugin.CurrentHost.AddMessage(MessageType.Warning, false, "An early time was defined, but no message was specified in MarkerXML " + fileName); } } } if (LateDefined) { if (iM) { if (LateTexture != null) { t.MessageLateTime = LateTime; t.MessageLateTexture = LateTexture; } else { Plugin.CurrentHost.AddMessage(MessageType.Warning, false, "A late time was defined, but no message was specified in MarkerXML " + fileName); } } else { if (LateText != null) { m.MessageLateTime = LateTime; m.MessageLateText = LateText; m.MessageLateColor = LateColor; } else { Plugin.CurrentHost.AddMessage(MessageType.Warning, false, "An early time was defined, but no message was specified in MarkerXML " + fileName); } } } //Final on-time message if (iM) { t.Trains = Trains; if (Texture != null) { t.MessageOnTimeTexture = Texture; } } else { m.Trains = Trains; if (Text != null) { m.MessageOnTimeText = Text; m.Color = OnTimeColor; } } if (iM) { Message = t; } else { Message = m; } } } } Marker = new Marker(StartingPosition, EndingPosition, Message); return(true); }
/// <summary>May be called from a .Net plugin, in order to add a score to the post-game log</summary> /// <param name="Score">The score to add</param> /// <param name="Message">The message to display in the post-game log</param> /// <param name="Color">The color of the in-game message</param> /// <param name="Timeout">The time in seconds for which to display the in-game message</param> public virtual void AddScore(int Score, string Message, MessageColor Color, double Timeout) { }
/// <summary>Renders all default HUD elements</summary> /// <param name="Element">The HUD element these are to be rendererd onto</param> /// <param name="TimeElapsed">The time elapsed</param> private void RenderHUDElement(HUD.Element Element, double TimeElapsed) { if (TrainManager.PlayerTrain == null) { return; } TrainManager.TrainDoorState LeftDoors = TrainManager.GetDoorsState(TrainManager.PlayerTrain, true, false); TrainManager.TrainDoorState RightDoors = TrainManager.GetDoorsState(TrainManager.PlayerTrain, false, true); System.Globalization.CultureInfo Culture = System.Globalization.CultureInfo.InvariantCulture; string Command = Element.Subject.ToLowerInvariant(); // default double w, h; if (Element.CenterMiddle.BackgroundTexture != null) { if (Program.CurrentHost.LoadTexture(Element.CenterMiddle.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp)) { w = (double)Element.CenterMiddle.BackgroundTexture.Width; h = (double)Element.CenterMiddle.BackgroundTexture.Height; } else { w = 0.0; h = 0.0; } } else { w = 0.0; h = 0.0; } int stationIndex; if (TrainManager.PlayerTrain.Station >= 0 && TrainManager.PlayerTrain.StationState != TrainStopState.Completed) { stationIndex = TrainManager.PlayerTrain.LastStation; } else { stationIndex = TrainManager.PlayerTrain.LastStation + 1; } if (stationIndex > Program.CurrentRoute.Stations.Length - 1) { stationIndex = TrainManager.PlayerTrain.LastStation; } double x = Element.Alignment.X < 0 ? 0.0 : Element.Alignment.X == 0 ? 0.5 * (Program.Renderer.Screen.Width - w) : Program.Renderer.Screen.Width - w; double y = Element.Alignment.Y < 0 ? 0.0 : Element.Alignment.Y == 0 ? 0.5 * (Program.Renderer.Screen.Height - h) : Program.Renderer.Screen.Height - h; x += Element.Position.X; y += Element.Position.Y; // command const double speed = 1.0; MessageColor sc = MessageColor.None; string t; switch (Command) { case "reverser": if (TrainManager.PlayerTrain.Handles.Reverser.Driver < 0) { sc = MessageColor.Orange; if (TrainManager.PlayerTrain.ReverserDescriptions != null && TrainManager.PlayerTrain.ReverserDescriptions.Length > 2) { t = TrainManager.PlayerTrain.ReverserDescriptions[2]; } else { t = Translations.QuickReferences.HandleBackward; } } else if (TrainManager.PlayerTrain.Handles.Reverser.Driver > 0) { sc = MessageColor.Blue; if (TrainManager.PlayerTrain.ReverserDescriptions != null && TrainManager.PlayerTrain.ReverserDescriptions.Length > 0) { t = TrainManager.PlayerTrain.ReverserDescriptions[0]; } else { t = Translations.QuickReferences.HandleForward; } } else { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.ReverserDescriptions != null && TrainManager.PlayerTrain.ReverserDescriptions.Length > 1) { t = TrainManager.PlayerTrain.ReverserDescriptions[1]; } else { t = Translations.QuickReferences.HandleNeutral; } } Element.TransitionState = 0.0; break; case "power": if (TrainManager.PlayerTrain.Handles.SingleHandle) { return; } if (TrainManager.PlayerTrain.Handles.Power.Driver == 0) { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.PowerNotchDescriptions.Length > 0) { t = TrainManager.PlayerTrain.PowerNotchDescriptions[0]; } else { t = Translations.QuickReferences.HandlePowerNull; } } else { sc = MessageColor.Blue; if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.Handles.Power.Driver < TrainManager.PlayerTrain.PowerNotchDescriptions.Length) { t = TrainManager.PlayerTrain.PowerNotchDescriptions[TrainManager.PlayerTrain.Handles.Power.Driver]; } else { t = Translations.QuickReferences.HandlePower + TrainManager.PlayerTrain.Handles.Power.Driver.ToString(Culture); } } Element.TransitionState = 0.0; break; case "brake": if (TrainManager.PlayerTrain.Handles.SingleHandle) { return; } if (TrainManager.PlayerTrain.Handles.Brake is TrainManager.AirBrakeHandle) { if (TrainManager.PlayerTrain.Handles.EmergencyBrake.Driver) { sc = MessageColor.Red; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 0) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[0]; } else { t = Translations.QuickReferences.HandleEmergency; } } else if (TrainManager.PlayerTrain.Handles.Brake.Driver == (int)TrainManager.AirBrakeHandleState.Release) { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 1) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[1]; } else { t = Translations.QuickReferences.HandleRelease; } } else if (TrainManager.PlayerTrain.Handles.Brake.Driver == (int)TrainManager.AirBrakeHandleState.Lap) { sc = MessageColor.Blue; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 2) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[2]; } else { t = Translations.QuickReferences.HandleLap; } } else { sc = MessageColor.Orange; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 3) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[3]; } else { t = Translations.QuickReferences.HandleService; } } } else { if (TrainManager.PlayerTrain.Handles.EmergencyBrake.Driver) { sc = MessageColor.Red; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 0) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[0]; } else { t = Translations.QuickReferences.HandleEmergency; } } else if (TrainManager.PlayerTrain.Handles.HoldBrake.Driver) { sc = MessageColor.Green; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 2) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[2]; } else { t = Translations.QuickReferences.HandleHoldBrake; } } else if (TrainManager.PlayerTrain.Handles.Brake.Driver == 0) { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 1) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[1]; } else { t = Translations.QuickReferences.HandleBrakeNull; } } else { sc = MessageColor.Orange; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && ((TrainManager.PlayerTrain.Handles.HasHoldBrake && TrainManager.PlayerTrain.Handles.Brake.Driver + 2 < TrainManager.PlayerTrain.BrakeNotchDescriptions.Length) || (!TrainManager.PlayerTrain.Handles.HasHoldBrake && TrainManager.PlayerTrain.Handles.Brake.Driver + 1 < TrainManager.PlayerTrain.BrakeNotchDescriptions.Length))) { t = TrainManager.PlayerTrain.Handles.HasHoldBrake ? TrainManager.PlayerTrain.BrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.Brake.Driver + 2] : TrainManager.PlayerTrain.BrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.Brake.Driver + 1]; } else { t = Translations.QuickReferences.HandleBrake + TrainManager.PlayerTrain.Handles.Brake.Driver.ToString(Culture); } } } Element.TransitionState = 0.0; break; case "locobrake": if (!TrainManager.PlayerTrain.Handles.HasLocoBrake) { return; } if (TrainManager.PlayerTrain.Handles.LocoBrake is TrainManager.LocoAirBrakeHandle) { if (TrainManager.PlayerTrain.Handles.LocoBrake.Driver == (int)TrainManager.AirBrakeHandleState.Release) { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 1) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[1]; } else { t = Translations.QuickReferences.HandleRelease; } } else if (TrainManager.PlayerTrain.Handles.LocoBrake.Driver == (int)TrainManager.AirBrakeHandleState.Lap) { sc = MessageColor.Blue; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 2) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[2]; } else { t = Translations.QuickReferences.HandleLap; } } else { sc = MessageColor.Orange; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 3) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[3]; } else { t = Translations.QuickReferences.HandleService; } } } else { if (TrainManager.PlayerTrain.Handles.LocoBrake.Driver == 0) { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.LocoBrakeNotchDescriptions != null && TrainManager.PlayerTrain.LocoBrakeNotchDescriptions.Length > 1) { t = TrainManager.PlayerTrain.LocoBrakeNotchDescriptions[1]; } else { t = Translations.QuickReferences.HandleBrakeNull; } } else { sc = MessageColor.Orange; if (TrainManager.PlayerTrain.LocoBrakeNotchDescriptions != null && TrainManager.PlayerTrain.Handles.LocoBrake.Driver < TrainManager.PlayerTrain.LocoBrakeNotchDescriptions.Length) { t = TrainManager.PlayerTrain.LocoBrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.LocoBrake.Driver]; } else { t = Translations.QuickReferences.HandleLocoBrake + TrainManager.PlayerTrain.Handles.LocoBrake.Driver.ToString(Culture); } } } Element.TransitionState = 0.0; break; case "single": if (!TrainManager.PlayerTrain.Handles.SingleHandle) { return; } if (TrainManager.PlayerTrain.Handles.EmergencyBrake.Driver) { sc = MessageColor.Red; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 0) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[0]; } else { t = Translations.QuickReferences.HandleEmergency; } } else if (TrainManager.PlayerTrain.Handles.HoldBrake.Driver) { sc = MessageColor.Green; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.BrakeNotchDescriptions.Length > 1) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[1]; } else { t = Translations.QuickReferences.HandleHoldBrake; } } else if (TrainManager.PlayerTrain.Handles.Brake.Driver > 0) { sc = MessageColor.Orange; if (TrainManager.PlayerTrain.BrakeNotchDescriptions != null && TrainManager.PlayerTrain.Handles.Brake.Driver + 3 < TrainManager.PlayerTrain.BrakeNotchDescriptions.Length) { t = TrainManager.PlayerTrain.BrakeNotchDescriptions[TrainManager.PlayerTrain.Handles.Brake.Driver + 3]; } else { t = Translations.QuickReferences.HandleBrake + TrainManager.PlayerTrain.Handles.Brake.Driver.ToString(Culture); } } else if (TrainManager.PlayerTrain.Handles.Power.Driver > 0) { sc = MessageColor.Blue; if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.Handles.Power.Driver < TrainManager.PlayerTrain.PowerNotchDescriptions.Length) { t = TrainManager.PlayerTrain.PowerNotchDescriptions[TrainManager.PlayerTrain.Handles.Power.Driver]; } else { t = Translations.QuickReferences.HandlePower + TrainManager.PlayerTrain.Handles.Power.Driver.ToString(Culture); } } else { sc = MessageColor.Gray; if (TrainManager.PlayerTrain.PowerNotchDescriptions != null && TrainManager.PlayerTrain.PowerNotchDescriptions.Length > 0) { t = TrainManager.PlayerTrain.PowerNotchDescriptions[0]; } else { t = Translations.QuickReferences.HandlePowerNull; } } Element.TransitionState = 0.0; break; case "doorsleft": case "doorsright": { if ((LeftDoors & TrainManager.TrainDoorState.AllClosed) == 0 | (RightDoors & TrainManager.TrainDoorState.AllClosed) == 0) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } TrainManager.TrainDoorState Doors = Command == "doorsleft" ? LeftDoors : RightDoors; if ((Doors & TrainManager.TrainDoorState.Mixed) != 0) { sc = MessageColor.Orange; } else if ((Doors & TrainManager.TrainDoorState.AllClosed) != 0) { sc = MessageColor.Gray; } else if (TrainManager.PlayerTrain.Specs.DoorCloseMode == TrainManager.DoorMode.Manual) { sc = MessageColor.Green; } else { sc = MessageColor.Blue; } t = Command == "doorsleft" ? Translations.QuickReferences.DoorsLeft : Translations.QuickReferences.DoorsRight; } break; case "stopleft": case "stopright": case "stopnone": { int s = TrainManager.PlayerTrain.Station; if (s >= 0 && Program.CurrentRoute.Stations[s].PlayerStops() && Interface.CurrentOptions.GameMode != GameMode.Expert) { bool cond; if (Command == "stopleft") { cond = Program.CurrentRoute.Stations[s].OpenLeftDoors; } else if (Command == "stopright") { cond = Program.CurrentRoute.Stations[s].OpenRightDoors; } else { cond = !Program.CurrentRoute.Stations[s].OpenLeftDoors & !Program.CurrentRoute.Stations[s].OpenRightDoors; } if (TrainManager.PlayerTrain.StationState == TrainStopState.Pending & cond) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } t = Element.Text; } break; case "stoplefttick": case "stoprighttick": case "stopnonetick": { int s = TrainManager.PlayerTrain.Station; if (s >= 0 && Program.CurrentRoute.Stations[s].PlayerStops() && Interface.CurrentOptions.GameMode != GameMode.Expert) { int c = Program.CurrentRoute.Stations[s].GetStopIndex(TrainManager.PlayerTrain.Cars.Length); if (c >= 0) { bool cond; if (Command == "stoplefttick") { cond = Program.CurrentRoute.Stations[s].OpenLeftDoors; } else if (Command == "stoprighttick") { cond = Program.CurrentRoute.Stations[s].OpenRightDoors; } else { cond = !Program.CurrentRoute.Stations[s].OpenLeftDoors & !Program.CurrentRoute.Stations[s].OpenRightDoors; } if (TrainManager.PlayerTrain.StationState == TrainStopState.Pending & cond) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } double d = TrainManager.PlayerTrain.StationDistanceToStopPoint; double r; if (d > 0.0) { r = d / Program.CurrentRoute.Stations[s].Stops[c].BackwardTolerance; } else { r = d / Program.CurrentRoute.Stations[s].Stops[c].ForwardTolerance; } if (r < -1.0) { r = -1.0; } if (r > 1.0) { r = 1.0; } y -= r * (double)Element.Value1; } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } t = Element.Text; } break; case "clock": { int hours = (int)Math.Floor(Program.CurrentRoute.SecondsSinceMidnight); int seconds = hours % 60; hours /= 60; int minutes = hours % 60; hours /= 60; hours %= 24; t = hours.ToString(Culture).PadLeft(2, '0') + ":" + minutes.ToString(Culture).PadLeft(2, '0') + ":" + seconds.ToString(Culture).PadLeft(2, '0'); if (renderer.OptionClock) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } } break; case "gradient": if (renderer.OptionGradient == NewRenderer.GradientDisplayMode.Percentage) { if (World.CameraTrackFollower.Pitch != 0) { double pc = World.CameraTrackFollower.Pitch; t = Math.Abs(pc).ToString("0.00", Culture) + "%" + (Math.Abs(pc) == pc ? " ↗" : " ↘"); } else { t = "Level"; } Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else if (renderer.OptionGradient == NewRenderer.GradientDisplayMode.UnitOfChange) { if (World.CameraTrackFollower.Pitch != 0) { double gr = 1000 / World.CameraTrackFollower.Pitch; t = "1 in " + Math.Abs(gr).ToString("0", Culture) + (Math.Abs(gr) == gr ? " ↗" : " ↘"); } else { t = "Level"; } Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else if (renderer.OptionGradient == NewRenderer.GradientDisplayMode.Permil) { if (World.CameraTrackFollower.Pitch != 0) { double pm = World.CameraTrackFollower.Pitch; t = Math.Abs(pm).ToString("0.00", Culture) + "‰" + (Math.Abs(pm) == pm ? " ↗" : " ↘"); } else { t = "Level"; } Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { if (World.CameraTrackFollower.Pitch != 0) { double gr = 1000 / World.CameraTrackFollower.Pitch; t = "1 in " + Math.Abs(gr).ToString("0", Culture) + (Math.Abs(gr) == gr ? " ↗" : " ↘"); } else { t = "Level"; } Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } break; case "speed": if (renderer.OptionSpeed == NewRenderer.SpeedDisplayMode.Kmph) { double kmph = Math.Abs(TrainManager.PlayerTrain.CurrentSpeed) * 3.6; t = kmph.ToString("0.00", Culture) + " km/h"; Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else if (renderer.OptionSpeed == NewRenderer.SpeedDisplayMode.Mph) { double mph = Math.Abs(TrainManager.PlayerTrain.CurrentSpeed) * 2.2369362920544; t = mph.ToString("0.00", Culture) + " mph"; Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { double mph = Math.Abs(TrainManager.PlayerTrain.CurrentSpeed) * 2.2369362920544; t = mph.ToString("0.00", Culture) + " mph"; Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } break; case "dist_next_station": if (!Program.CurrentRoute.Stations[stationIndex].PlayerStops()) { int n = Program.CurrentRoute.Stations[stationIndex].GetStopIndex(TrainManager.PlayerTrain.NumberOfCars); double p0 = TrainManager.PlayerTrain.FrontCarTrackPosition(); double p1 = Program.CurrentRoute.Stations[stationIndex].Stops.Length > 0 ? Program.CurrentRoute.Stations[stationIndex].Stops[n].TrackPosition : Program.CurrentRoute.Stations[stationIndex].DefaultTrackPosition; double m = p1 - p0; if (m < 0) { m = 0.0; //Don't display negative numbers when passing (stop zone goes beyond the absolute station limit) } if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Km) { m /= 1000.0; t = "Pass: "******"0.000", Culture) + " km"; Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Mile) { m /= 1609.34; t = "Pass: "******"0.0000", Culture) + " miles"; Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { m /= 1609.34; t = "Pass: "******"0.0000", Culture) + " miles"; Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } } else { t = String.Empty; } break; case "dist_next_station2": if (!Program.CurrentRoute.Stations[stationIndex].PlayerStops()) { int n = Program.CurrentRoute.Stations[stationIndex].GetStopIndex(TrainManager.PlayerTrain.NumberOfCars); double p0 = TrainManager.PlayerTrain.FrontCarTrackPosition(); double p1 = 0.0; for (int i = stationIndex; i < Program.CurrentRoute.Stations.Length; i++) { if (Program.CurrentRoute.Stations[i].PlayerStops()) { p1 = Program.CurrentRoute.Stations[i].Stops.Length > 0 ? Program.CurrentRoute.Stations[i].Stops[n].TrackPosition : Program.CurrentRoute.Stations[i].DefaultTrackPosition; } } double m = p1 - p0; if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Km) { m /= 1000.0; t = "Next Stop: " + m.ToString("0.000", Culture) + " km"; Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Mile) { m /= 1609.34; t = "Next Stop: " + m.ToString("0.0000", Culture) + " miles"; Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { m /= 1609.34; t = "Next Stop: " + m.ToString("0.0000", Culture) + " miles"; Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } } else { int n = Program.CurrentRoute.Stations[stationIndex].GetStopIndex(TrainManager.PlayerTrain.NumberOfCars); double p0 = TrainManager.PlayerTrain.FrontCarTrackPosition(); double p1 = Program.CurrentRoute.Stations[stationIndex].Stops.Length > 0 ? Program.CurrentRoute.Stations[stationIndex].Stops[n].TrackPosition : Program.CurrentRoute.Stations[stationIndex].DefaultTrackPosition;; double m = p1 - p0; if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Km) { if (Math.Abs(m) <= 10.0) { t = "Stop: " + m.ToString("0.00", Culture) + " m"; } else { m /= 1000.0; t = "Stop: " + m.ToString("0.000", Culture) + " km"; } Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else if (renderer.OptionDistanceToNextStation == NewRenderer.DistanceToNextStationDisplayMode.Mile) { m /= 1609.34; t = "Stop: " + m.ToString("0.0000", Culture) + " miles"; Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { m /= 1609.34; t = "Stop: " + m.ToString("0.0000", Culture) + " miles"; Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } } break; case "fps": int fps = (int)Math.Round(Program.Renderer.FrameRate); t = fps.ToString(Culture) + " fps"; if (renderer.OptionFrameRates) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } break; case "ai": t = "A.I."; if (TrainManager.PlayerTrain.AI != null) { Element.TransitionState -= speed * TimeElapsed; if (Element.TransitionState < 0.0) { Element.TransitionState = 0.0; } } else { Element.TransitionState += speed * TimeElapsed; if (Element.TransitionState > 1.0) { Element.TransitionState = 1.0; } } break; case "score": if (Interface.CurrentOptions.GameMode == GameMode.Arcade) { t = Game.CurrentScore.CurrentValue.ToString(Culture) + " / " + Game.CurrentScore.Maximum.ToString(Culture); if (Game.CurrentScore.CurrentValue < 0) { sc = MessageColor.Red; } else if (Game.CurrentScore.CurrentValue > 0) { sc = MessageColor.Green; } else { sc = MessageColor.Gray; } Element.TransitionState = 0.0; } else { Element.TransitionState = 1.0; t = ""; } break; default: t = Element.Text; break; } // transitions float alpha = 1.0f; if ((Element.Transition & HUD.Transition.Move) != 0) { double s = Element.TransitionState; x += Element.TransitionVector.X * s * s; y += Element.TransitionVector.Y * s * s; } if ((Element.Transition & HUD.Transition.Fade) != 0) { alpha = (float)(1.0 - Element.TransitionState); } else if (Element.Transition == HUD.Transition.None) { alpha = (float)(1.0 - Element.TransitionState); } // render if (alpha != 0.0f) { // background if (Element.Subject == "reverser") { w = Math.Max(w, TrainManager.PlayerTrain.MaxReverserWidth); //X-Pos doesn't need to be changed } if (Element.Subject == "power") { w = Math.Max(w, TrainManager.PlayerTrain.MaxPowerNotchWidth); if (TrainManager.PlayerTrain.MaxReverserWidth > 48) { x += (TrainManager.PlayerTrain.MaxReverserWidth - 48); } } if (Element.Subject == "brake") { w = Math.Max(w, TrainManager.PlayerTrain.MaxBrakeNotchWidth); if (TrainManager.PlayerTrain.MaxReverserWidth > 48) { x += (TrainManager.PlayerTrain.MaxReverserWidth - 48); } if (TrainManager.PlayerTrain.MaxPowerNotchWidth > 48) { x += (TrainManager.PlayerTrain.MaxPowerNotchWidth - 48); } } if (Element.Subject == "single") { w = Math.Max(Math.Max(w, TrainManager.PlayerTrain.MaxPowerNotchWidth), TrainManager.PlayerTrain.MaxBrakeNotchWidth); if (TrainManager.PlayerTrain.MaxReverserWidth > 48) { x += (TrainManager.PlayerTrain.MaxReverserWidth - 48); } } if (Element.CenterMiddle.BackgroundTexture != null) { if (Program.CurrentHost.LoadTexture(Element.CenterMiddle.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp)) { Color128 c = Element.BackgroundColor.CreateBackColor(sc, alpha); renderer.Rectangle.Draw(Element.CenterMiddle.BackgroundTexture, new PointF((float)x, (float)y), new SizeF((float)w, (float)h), new Color128(c.R, c.G, c.B, c.A)); } } { // text System.Drawing.Size size = Element.Font.MeasureString(t); float u = size.Width; float v = size.Height; double p = Math.Round(Element.TextAlignment.X < 0 ? x : Element.TextAlignment.X == 0 ? x + 0.5 * (w - u) : x + w - u); double q = Math.Round(Element.TextAlignment.Y < 0 ? y : Element.TextAlignment.Y == 0 ? y + 0.5 * (h - v) : y + h - v); p += Element.TextPosition.X; q += Element.TextPosition.Y; Color128 c = Element.TextColor.CreateTextColor(sc, alpha); Program.Renderer.OpenGlString.Draw(Element.Font, t, new System.Drawing.Point((int)p, (int)q), TextAlignment.TopLeft, c, Element.TextShadow); } // overlay if (Element.CenterMiddle.OverlayTexture != null) { if (Program.CurrentHost.LoadTexture(Element.CenterMiddle.OverlayTexture, OpenGlTextureWrapMode.ClampClamp)) { Color128 c = Element.OverlayColor.CreateBackColor(sc, alpha); renderer.Rectangle.Draw(Element.CenterMiddle.BackgroundTexture, new PointF((float)x, (float)y), new SizeF((float)w, (float)h), new Color128(c.R, c.G, c.B, c.A)); } } } }
/// <summary>May be called from a .Net plugin, in order to add a score to the post-game log</summary> /// <param name="Score">The score to add</param> /// <param name="Message">The message to display in the post-game log</param> /// <param name="Color">The color of the in-game message</param> /// <param name="Timeout">The time in seconds for which to display the in-game message</param> internal void AddScore(int Score, string Message, MessageColor Color, double Timeout) { TrainManagerBase.currentHost.AddScore(Score, Message, Color, Timeout); }
/// <summary> /// Send room notification /// </summary> /// <param name="room">The room.</param> /// <param name="message">The message.</param> /// <param name="notifyRoom">if set to <c>true</c> [notify room].</param> /// <param name="format">The format.</param> /// <param name="color">The color.</param> /// <returns>Task<IResponse<System.Boolean>>.</returns> public async Task<IResponse<bool>> SendNotificationAsync(string room, string message, bool notifyRoom = true, MessageFormat format = MessageFormat.Html, MessageColor color = MessageColor.Gray) { var notification = new SendNotification { Color = color, Message = message, Notify = notifyRoom, Format = format }; return await SendNotificationAsync(room, notification); }
/// <summary>Adds a message to the in-game interface render queue</summary> /// <param name="Text">The text of the message</param> /// <param name="Depencency"></param> /// <param name="Mode"></param> /// <param name="Color">The color of the message text</param> /// <param name="Timeout">The time this message will display for</param> /// <param name="key">The textual key identifiying this message</param> internal static void AddMessage(string Text, MessageManager.MessageDependency Depencency, Interface.GameMode Mode, MessageColor Color, double Timeout, string key) { if (Interface.CurrentOptions.GameMode <= Mode) { MessageManager.GameMessage message = new MessageManager.GameMessage { InternalText = Text, MessageToDisplay = String.Empty, Depencency = Depencency, Color = Color, Timeout = Timeout, Key = key }; MessageManager.AddMessage(message); } }
/// <summary>May be called from a .Net plugin, in order to add a message to the in-game display</summary> /// <param name="Message">The message to display</param> /// <param name="Color">The color in which to display the message</param> /// <param name="Time">The time in seconds for which to display the message</param> internal void AddInterfaceMessage(string Message, MessageColor Color, double Time) { Game.AddMessage(Message, Game.MessageDependency.None, Interface.GameMode.Expert, Color, Game.SecondsSinceMidnight + Time); }