// TODO: display n to m lines. public void UpdatePublic(bool show = true) { try { if (FontSize != _panel.GetValueFloat("FontSize")) { _panel.SetValueFloat("FontSize", FontSize); } } catch (Exception ex) { // The game may generate an exception from the GetValueFloat(GetValue) call. // We can safely ignore this if it doesn't work, but it may indicate a game issue. EconomyScript.Instance.ServerLogger.WriteException(ex, UpdateCrashMessage); EconomyScript.Instance.ClientLogger.WriteException(ex, UpdateCrashMessage); } LastUpdate = DateTime.Now; // no need to update if the text has not changed. if (_panel.GetPublicText() != _publicString.ToString()) { _panel.WritePublicText(_publicString.ToString()); if (show) { if (ForceRedraw) { _panel.ShowTextureOnScreen(); } _panel.ShowPublicTextOnScreen(); } } }
public void Password(string argument) { if (LCD != null) { LCD.SetValueFloat("FontSize", PasswordFontSize); LCD.SetValueColor("FontColor", PasswordFontColor); LCD.SetValueColor("BackgroundColor", PasswordBackColor); LCD.WriteText(new String(PasswordCharacter, argument.Length), false); } }
public void progressPanels() { while (Runtime.CurrentInstructionCount < LOAD_LIMIT && PanelQueue.Count > 0) { panelProgressCount++; long panelId = PanelQueue.Dequeue().EntityId; IMyTextPanel Panel = GridTerminalSystem.GetBlockWithId(panelId) as IMyTextPanel; IMyTerminalBlock Cargo = getCargo(Panel); if (Panel != null && Panel is IMyTextPanel && Cargo != null && Panel.IsFunctional && Panel.IsWorking) { int fillLevel0 = 0; int fillLevel1 = 0; string fillBar = getFillLevelBarForBlock(Cargo, out fillLevel0, out fillLevel1); switch (Cargo.InventoryCount) { case 1: Panel.CustomData = getText("lcdStatSingleInventory", Cargo.CustomName, DateTime.Now, fillLevel0); Panel.WritePublicTitle(getText("lcdTitleStatSingle", fillLevel0, Cargo.CustomName)); break; case 2: Panel.CustomData = getText("lcdStatDoubleInventory", Cargo.CustomName, DateTime.Now, fillLevel0, fillLevel1); Panel.WritePublicTitle(getText("lcdTitleStatDouble", fillLevel0, fillLevel1, Cargo.CustomName)); break; } Panel.WritePublicText(fillBar); Panel.SetValueFloat("FontSize", fontSizeFuelBar); Panel.SetValue <long>("Font", fontIdMonospaced); Panel.ShowPublicTextOnScreen(); } else { Panel.WritePublicTitle(""); Panel.WritePublicText(getText("warnNoInventory")); Panel.SetValueFloat("FontSize", fontSizeText); Panel.SetValue <long>("Font", fontIdRed); Panel.ShowPublicTextOnScreen(); } } }
public static void ShowMessageOnLcd(IMyTextPanel lcd, LcdMessage message) { if (lcd == null) { return; } lcd.WriteText(message.Text); lcd.SetValue <Color>("FontColor", message.FontColor); lcd.SetValue <Color>("BackgroundColor", message.BackgroundColor); lcd.SetValueFloat("FontSize", message.FontSize); }
// TODO: display n to m lines. public void UpdatePublic(bool show = true) { if (FontSize != _panel.GetValueFloat("FontSize")) { _panel.SetValueFloat("FontSize", FontSize); } LastUpdate = DateTime.Now; // no need to update if the text has not changed. if (_panel.GetPublicText() != _publicString.ToString()) { _panel.WritePublicText(_publicString.ToString()); if (show) { if (ForceRedraw) { _panel.ShowTextureOnScreen(); } _panel.ShowPublicTextOnScreen(); } } }
// Doesn't work public static void ShowMessagesOnLcd(IMyTextPanel lcd, List <LcdMessage> messages) { if (lcd == null) { return; } foreach (var message in messages) { lcd.SetValue <Color>("FontColor", message.FontColor); lcd.SetValue <Color>("BackgroundColor", message.BackgroundColor); lcd.SetValueFloat("FontSize", message.FontSize); lcd.WriteText(message.Text, true); } }
public void progressPanel(IMyTextPanel Panel) { IMyButtonPanel ButtonPanel = getButtonPanel(Panel); if (ButtonPanel != null) { StringBuilder slug = new StringBuilder(); for (int i = 0; i < 4; i++) { if (ButtonPanel.IsButtonAssigned(i) && ButtonPanel.HasCustomButtonName(i)) { slug.AppendLine(string.Format(@"[{0}]: {1}", i + 1, ButtonPanel.GetButtonName(i))); } else { slug.AppendLine(string.Format(@"[{0}]: ...", i + 1)); } } Panel.WritePublicText(slug.ToString()); Panel.WritePublicTitle(ButtonPanel.CustomName); Panel.SetValueFloat("FontSize", 0.65f); Panel.ShowPublicTextOnScreen(); } }
public static void Add(IMyTextPanel block) { block.WritePublicTitle("API Key QR Code"); block.WritePrivateTitle("API Key String"); string black = ""; string white = ""; string key = ""; while (keyDict.ContainsKey(key = Generator.GenerateWeakKey(16))) { } block.WritePrivateText(key); keyDict.Add(key, block.EntityId); //Generate and write QR code. //TODO: Offload this functionality to client mod. QrEncoder q = new QrEncoder(ErrorCorrectionLevel.H); var code = q.Encode(key); if (code != null) { StringBuilder sb = new StringBuilder(); var bits = code.Matrix; for (int i = 0; i < bits.Width + 2; i++) { sb.Append(white); } sb.AppendLine(); for (int i = 0; i < bits.Height; i++) { sb.Append(white); for (int j = 0; j < bits.Width; j++) { if (bits.InternalArray[i, j]) { sb.Append(black); } else { sb.Append(white); } } sb.Append(white); sb.AppendLine(); } for (int i = 0; i < bits.Width + 2; i++) { sb.Append(white); } sb.AppendLine(); block.WritePublicText(sb.ToString()); block.ShowPublicTextOnScreen(); block.SetValueFloat("FontSize", 0.5f); block.SetValueColor("FontColor", new VRageMath.Color(120, 0, 0)); } }
private void init() { #region initialization oldPBName = Me.CustomName; unique_id = (new Random()).Next(); all_blocks_found = true; autopilot_en = true; location_name = "UNKNOWN"; // For spinner counter = 0; string parse = Me.CustomName.Replace(BLOCK_PREFIX, ""); int id1 = Me.CustomName.IndexOf('['); int id2 = Me.CustomName.IndexOf(']'); if (id1 >= 0 && id2 >= 0) { parse = parse.Substring(id1 + 1, id2 - id1 - 1); } else { parse = ""; } BaconArgs Args = BaconArgs.parse(parse); IS_BASE = (Args.getFlag('b') > 0); DOCK_LEFT = (Args.getFlag('l') > 0); IS_PLANET = (Args.getFlag('p') > 0); if (IS_PLANET) { IS_BASE = true; } List <string> nameArg = Args.getOption("name"); if (nameArg.Count > 0 && nameArg[0] != null) { location_name = nameArg[0]; } // Set all known blocks to null or clear lists lcdPanel = null; messageReceiver = null; WANProgram = null; connector = null; remoteControl = null; door = null; timer = null; landLight = null; mainGear = 0; gyros.Clear(); destinations.Clear(); gears.Clear(); // Get all blocks List <IMyTerminalBlock> blks = new List <IMyTerminalBlock>(); GridTerminalSystem.SearchBlocksOfName(BLOCK_PREFIX, blks, hasPrefix); num_blocks_found = blks.Count; // Assign blocks to variables as appropriate foreach (var blk in blks) { // LCD panel for printing if (blk is IMyTextPanel) { lcdPanel = blk as IMyTextPanel; lcdPanel.ShowPublicTextOnScreen(); lcdPanel.SetValueFloat("FontSize", 1.2f); } // Wico Area Network programmable block else if (blk is IMyProgrammableBlock && !blk.Equals(Me)) { WANProgram = blk as IMyProgrammableBlock; } // Autopilot else if (!IS_BASE && blk is IMyRemoteControl) { remoteControl = blk as IMyRemoteControl; } /* Ship or station connector for docking * Used to connect to station and for orientation info */ else if (!IS_PLANET && blk is IMyShipConnector) { connector = blk as IMyShipConnector; } /* Door used for docking; used for orientation information * since it's more obvious which way a door faces than a connector */ else if (!IS_PLANET && blk is IMyDoor) { door = blk as IMyDoor; } // Gyros for ship orientation else if (!IS_BASE && blk is IMyGyro) { IMyGyro g = blk as IMyGyro; gyros.Add(g); } // Timer block so that we can orient ship properly - requires multiple calls/sec else if (!IS_BASE && blk is IMyTimerBlock) { timer = blk as IMyTimerBlock; timer.SetValueFloat("TriggerDelay", 1.0f); } // Light (interior or spotlight) determines where we will land else if (IS_BASE && IS_PLANET && blk is IMyInteriorLight) { landLight = blk as IMyInteriorLight; } // Landing gear.... else if (!IS_BASE && blk is IMyLandingGear) { IMyLandingGear gear = blk as IMyLandingGear; gears.Add(gear); if (gear.CustomName.ToLower().Contains("main")) { mainGear = gears.Count - 1; } } } // Make sure all gyros reset resetGyros(); // Clear block list blks.Clear(); // Get text panel blocks used by Wico Area Network for communication GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(blks, hasWANRPrefix); if (blks.Count == 0) { Echo("Error: Can't find message received text panel for Wico Area Network"); all_blocks_found = false; } else { messageReceiver = blks[0] as IMyTextPanel; messageReceiver.WritePublicTitle(""); messageReceiver.WritePrivateTitle("NAV"); } if (WANProgram == null) { Echo("Error: Can't find programming block for Wico Area Network"); all_blocks_found = false; } if (lcdPanel == null) { Echo("Error: Expect 1 LCD"); all_blocks_found = false; } if (!IS_PLANET && connector == null) { Echo("Error: Can't find any connectors to use for docking"); all_blocks_found = false; } if (!IS_BASE && remoteControl == null) { Echo("Error: Can't find any remote control blocks"); all_blocks_found = false; } if (!IS_PLANET && door == null) { Echo("Error: Can't find door"); all_blocks_found = false; } if (!IS_BASE && gyros.Count == 0) { Echo("Error: No gyros detected"); all_blocks_found = false; } if (!IS_BASE && timer == null) { Echo("Error: No timer found"); all_blocks_found = false; } if (IS_PLANET && landLight == null) { Echo("Error: No light for landing ship destination found"); all_blocks_found = false; } if (!IS_BASE && gears.Count == 0) { Echo("Warning: no landing gear found. You will not be able to land on planets"); } // Init communicator state machine comm = communicate().GetEnumerator(); // Clear autopilot state machine fly = null; #endregion }
private void init() { #region initialization oldPBName = Me.CustomName; unique_id = (new Random()).Next(); all_blocks_found = true; autopilot_en = true; location_name = "UNKNOWN"; // For spinner counter = 0; string parse = Me.CustomName.Replace(BLOCK_PREFIX, ""); int id1 = Me.CustomName.IndexOf('['); int id2 = Me.CustomName.IndexOf(']'); if (id1 >= 0 && id2 >= 0) { parse = parse.Substring(id1 + 1, id2 - id1 - 1); } else { parse = ""; } BaconArgs Args = BaconArgs.parse(parse); IS_BASE = (Args.getFlag('b') > 0); DOCK_LEFT = (Args.getFlag('l') > 0); IS_PLANET = (Args.getFlag('p') > 0); if (IS_PLANET) IS_BASE = true; List<string> nameArg = Args.getOption("name"); if (nameArg.Count > 0 && nameArg[0] != null) { location_name = nameArg[0]; } // Set all known blocks to null or clear lists lcdPanel = null; messageReceiver = null; WANProgram = null; connector = null; remoteControl = null; door = null; timer = null; landLight = null; mainGear = 0; gyros.Clear(); destinations.Clear(); gears.Clear(); // Get all blocks List<IMyTerminalBlock> blks = new List<IMyTerminalBlock>(); GridTerminalSystem.SearchBlocksOfName(BLOCK_PREFIX, blks, hasPrefix); num_blocks_found = blks.Count; // Assign blocks to variables as appropriate foreach (var blk in blks) { // LCD panel for printing if (blk is IMyTextPanel) { lcdPanel = blk as IMyTextPanel; lcdPanel.ShowPublicTextOnScreen(); lcdPanel.SetValueFloat("FontSize", 1.2f); } // Wico Area Network programmable block else if (blk is IMyProgrammableBlock && !blk.Equals(Me)) { WANProgram = blk as IMyProgrammableBlock; } // Autopilot else if (!IS_BASE && blk is IMyRemoteControl) { remoteControl = blk as IMyRemoteControl; } /* Ship or station connector for docking * Used to connect to station and for orientation info */ else if (!IS_PLANET && blk is IMyShipConnector) { connector = blk as IMyShipConnector; } /* Door used for docking; used for orientation information * since it's more obvious which way a door faces than a connector */ else if (!IS_PLANET && blk is IMyDoor) { door = blk as IMyDoor; } // Gyros for ship orientation else if (!IS_BASE && blk is IMyGyro) { IMyGyro g = blk as IMyGyro; gyros.Add(g); } // Timer block so that we can orient ship properly - requires multiple calls/sec else if (!IS_BASE && blk is IMyTimerBlock) { timer = blk as IMyTimerBlock; timer.SetValueFloat("TriggerDelay", 1.0f); } // Light (interior or spotlight) determines where we will land else if (IS_BASE && IS_PLANET && blk is IMyInteriorLight) { landLight = blk as IMyInteriorLight; } // Landing gear.... else if (!IS_BASE && blk is IMyLandingGear) { IMyLandingGear gear = blk as IMyLandingGear; gears.Add(gear); if (gear.CustomName.ToLower().Contains("main")) { mainGear = gears.Count - 1; } } } // Make sure all gyros reset resetGyros(); // Clear block list blks.Clear(); // Get text panel blocks used by Wico Area Network for communication GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(blks, hasWANRPrefix); if (blks.Count == 0) { Echo("Error: Can't find message received text panel for Wico Area Network"); all_blocks_found = false; } else { messageReceiver = blks[0] as IMyTextPanel; messageReceiver.WritePublicTitle(""); messageReceiver.WritePrivateTitle("NAV"); } if (WANProgram == null) { Echo("Error: Can't find programming block for Wico Area Network"); all_blocks_found = false; } if (lcdPanel == null) { Echo("Error: Expect 1 LCD"); all_blocks_found = false; } if (!IS_PLANET && connector == null) { Echo("Error: Can't find any connectors to use for docking"); all_blocks_found = false; } if (!IS_BASE && remoteControl == null) { Echo("Error: Can't find any remote control blocks"); all_blocks_found = false; } if (!IS_PLANET && door == null) { Echo("Error: Can't find door"); all_blocks_found = false; } if (!IS_BASE && gyros.Count == 0) { Echo("Error: No gyros detected"); all_blocks_found = false; } if (!IS_BASE && timer == null) { Echo("Error: No timer found"); all_blocks_found = false; } if (IS_PLANET && landLight == null) { Echo("Error: No light for landing ship destination found"); all_blocks_found = false; } if (!IS_BASE && gears.Count == 0) { Echo("Warning: no landing gear found. You will not be able to land on planets"); } // Init communicator state machine comm = communicate().GetEnumerator(); // Clear autopilot state machine fly = null; #endregion }