// 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(); } } }
void StatusLog(string text, IMyTextPanel block, bool bReverse = false) { if (block == null) { return; } if (text.Equals("clear")) { block.WritePublicText(""); } else { if (bReverse) { string oldtext = block.GetPublicText(); block.WritePublicText(text + "\n" + oldtext); } else { block.WritePublicText(text + "\n", true); } // block.WritePublicTitle(DateTime.Now.ToString()); } block.ShowTextureOnScreen(); block.ShowPublicTextOnScreen(); }
//Display text as a percentage bar and numeric text private void displayPercentOnScreen(IMyTextPanel scr, int per) { int x = 100; int y = 0; scr.WritePublicText(""); //clear scr.FontSize = scr.BlockDefinition.SubtypeName.Contains("Wide") ? 2.713F : 1.3565F; //size of 2.713 for wide, half that for normal scr.FontColor = getDisplayColor(per); scr.BackgroundColor = getBCGColor(per); //scr.WritePublicTitle("Battery Fraction:"); scr.WritePublicText("Battery Fraction:"); scr.WritePublicText("\n", true); scr.WritePublicText("[", true); for (int i = per; i > 0; i -= 2) { scr.WritePublicText("|", true); y += 2; } for (int i = x - y; i > 0; i -= 2) { scr.WritePublicText("'", true); } scr.WritePublicText("] (" + per + "%)\n", true); scr.ShowTextureOnScreen(); scr.ShowPublicTextOnScreen(); }
void SetPanelText(IMyTextPanel panel, string text) { if (panel != null) { panel.WritePublicText(text); panel.ShowTextureOnScreen(); panel.ShowPublicTextOnScreen(); } }
public void paint() { for (int i = 0; i < height; i++) { screenLines[i] = string.Join(null, screen, i * width, width) + "\n"; } console.WritePublicText(string.Concat(screenLines)); console.ShowTextureOnScreen(); console.ShowPublicTextOnScreen(); }
// Method for writting to LCD Panels void SetText(List <IMyTerminalBlock> blocks, string LCDText, Color color) { for (int i = 0; i < blocks.Count; i++) { IMyTextPanel panel = blocks[i] as IMyTextPanel; panel.WritePublicText(LCDText); panel.SetValue("FontColor", color); panel.ShowTextureOnScreen(); panel.ShowPublicTextOnScreen(); } }
// 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(); } } }
protected override void Disable() { if (textPanelBlock != null) { if (!normalShowText) { textPanelBlock.ShowTextureOnScreen(); } textPanelBlock.WritePublicText(normalText); textPanelBlock.FontSize = normalFontSize; textPanelBlock.FontColor = normalFontColor; textPanelBlock.BackgroundColor = normalBgColor; } }
void Log(string text, IMyTextPanel lcd) { if (lcd != null) { if (text.Equals("clear")) { lcd.WritePublicText(""); lcd.WritePublicTitle(lcd.CustomName + " Status"); } else { string oldtext = lcd.GetPublicText(); lcd.ShowTextureOnScreen(); lcd.WritePublicText(oldtext + "\n" + text, false); } lcd.ShowPublicTextOnScreen(); } }
void Main() { InitDebug(); if (minimums.Count == 0) { minimums.Add("Bulletproof Glass", 100000); minimums.Add("Computer", 30000); minimums.Add("Construction Component", 360000); minimums.Add("Detector Component", 1000); minimums.Add("Display", 30000); minimums.Add("Girder", 6000); minimums.Add("GravGen Component", 1000); minimums.Add("Interior Plate", 1500000); minimums.Add("Large Steel Tube", 180000); minimums.Add("Metal Grid", 300000); minimums.Add("Motor", 50000); minimums.Add("Radio Component", 1000); minimums.Add("Reactor Component", 8000); minimums.Add("Small Steel Tube", 300000); minimums.Add("Steel Plate", 3000000); minimums.Add("Thruster Component", 10000); minimums.Add("Solar Cell", 1000); minimums.Add("Power Cell", 1000); } List <IMyTerminalBlock> work = new List <IMyTerminalBlock>(); Dictionary <String, float> consolidated = new Dictionary <String, float>(); GridTerminalSystem.SearchBlocksOfName(PANEL_NAME, work); IMyTextPanel panel = null; for (int i = 0; i < work.Count; i++) { if (work[i] is IMyTextPanel) { panel = (IMyTextPanel)work[i]; break; } } List <IMyTerminalBlock> containerList = new List <IMyTerminalBlock>(); GridTerminalSystem.SearchBlocksOfName(CONTAINER_NAME, containerList); float maxVolume = 0.0f; float currentVolume = 0.0f; for (int i = 0; i < containerList.Count; i++) { if (containerList[i] is IMyCargoContainer) { var containerInvOwner = containerList[i] as VRage.ModAPI.Ingame.IMyInventoryOwner; var containerInventory = containerInvOwner.GetInventory(0); maxVolume += (float)containerInventory.MaxVolume; currentVolume += (float)containerInventory.CurrentVolume; var containerItems = containerInventory.GetItems(); for (int j = containerItems.Count - 1; j >= 0; j--) { String itemName = decodeItemName(containerItems[j].Content.SubtypeName, containerItems[j].Content.TypeId.ToString()) + "|" + containerItems[j].Content.TypeId.ToString(); float amount = (float)containerItems[j].Amount; if (!consolidated.ContainsKey(itemName)) { consolidated.Add(itemName, amount); } else { consolidated[itemName] += amount; } } } } Dictionary <String, float> working = new Dictionary <String, float>(); working.Clear(); var enumerator3 = minimums.GetEnumerator(); while (enumerator3.MoveNext()) { var pair = enumerator3.Current; String itemKey = pair.Key; working.Add(itemKey, 0); } List <String> list = new List <String>(); var enumerator = consolidated.GetEnumerator(); while (enumerator.MoveNext()) { var pair = enumerator.Current; String itemKey = pair.Key; float itemValue = pair.Value; checkStock(itemKey.Split('|')[0], itemValue); String txt = itemKey.Split('|')[0] + " - "; String amt = amountFormatter(itemValue, itemKey.Split('|')[1]); working[txt] += itemValue; txt += amt; list.Add(txt); } var enumerator2 = minimums.GetEnumerator(); while (enumerator2.MoveNext()) { var pair = enumerator2.Current; String itemKey = pair.Key; float itemValue = pair.Value; checkStock(itemKey, working[itemKey]); } list.Sort(); list.Insert(0, "------------------------------------------------------"); float percentageFull = (float)Math.Round(currentVolume / maxVolume * 100, 2); list.Insert(0, CONTAINER_NAME + " Inventory " + percentageFull.ToString("##0.00") + "%k full"); for (int o = 0; o < lineOffset; o++) { String shiftedItem = list[0]; list.RemoveAt(0); list.Add(shiftedItem); } panel.WritePublicText(String.Join("\n", list.ToArray()), false); panel.ShowTextureOnScreen(); panel.ShowPublicTextOnScreen(); if (list.Count > PANEL_LINES) { lineOffset++; if (list.Count - lineOffset < PANEL_LINES) { lineOffset = 0; } } }