Ejemplo n.º 1
39
 public static void Log(string logMessage, Action<string> echo = null, IMyProgrammableBlock me = null, string label = null, IMyTextPanel mirrorLcd = null, bool truncateForLcd = true)
 {
     String output = "";
     if(echo == null) {
         output = "\n";
         output += logMessage;
         throw new Exception(output);
     }
     if(LogBuffer == null) {
         LogBuffer = new StringBuilder();
     }
     if(label != null) {
         logMessage = label+": "+logMessage;
     }
     if(mirrorLcd != null) {
         string currentlyMirrored = mirrorLcd.GetPublicText();
         if(truncateForLcd && LogBuffer.Length + logMessage.Length > LOG_MAX_LCD_LENGTH_CHARS) {
             StringBuilder lcdBuffer = new StringBuilder(LogBuffer.ToString());
             int charAmountToOffset = fullLineCharsExceeding(lcdBuffer, logMessage.Length, LogBuffer.Length - (LOG_MAX_LCD_LENGTH_CHARS - logMessage.Length));
             lcdBuffer.Remove(0, LogBuffer.Length - LOG_MAX_LCD_LENGTH_CHARS + charAmountToOffset - 2);
             lcdBuffer.AppendLine();
             lcdBuffer.Append(logMessage);
             mirrorLcd.WritePublicText(lcdBuffer.ToString(), false);
         } else {
             string potentialNewLine = (currentlyMirrored.Length > 0)? "\n" : "";
             mirrorLcd.WritePublicText(potentialNewLine+logMessage, true);
         }
     }
     if(LogBuffer.Length + logMessage.Length * 2 > LOG_MAX_ECHO_LENGTH_CHARS) {
         int charAmountToRemove = fullLineCharsExceeding(LogBuffer, logMessage.Length);
         LogBuffer.Remove(0, charAmountToRemove);
         LogBuffer.Append(output);
     }
     if(LogBuffer.Length > 0) {
         LogBuffer.AppendLine();
     }
     LogBuffer.Append(logMessage);
     echo(LogBuffer.ToString());
 }
Ejemplo n.º 2
0
 private void AddEntriesToPanel(IMyTextPanel Panel)
 {
     if (Autoscroll)
     {
         List <string> buffer = new List <string>(Panel.GetPublicText().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries));
         buffer.AddRange(Queue);
         int maxLines = Math.Min(getMaxLinesFromPanel(Panel), buffer.Count);
         if (Prepend)
         {
             buffer.Reverse();
         }
         Panel.WritePublicText(string.Join("\n", buffer.GetRange(buffer.Count - maxLines, maxLines).ToArray()), false);
     }
     else
     {
         if (Prepend)
         {
             var buffer = new List <string>(Panel.GetPublicText().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries));
             buffer.AddRange(Queue);
             buffer.Reverse();
             Panel.WritePublicText(string.Join("\n", buffer.ToArray()), false);
         }
         else
         {
             Panel.WritePublicText(string.Join("\n", Queue.ToArray()), true);
         }
     }
 }
Ejemplo n.º 3
0
        private void CheckCommandsChanged()
        {
            string currentText = m_private ?
#pragma warning disable CS0618
                                 TextPanel.GetPrivateText() :
#pragma warning restore CS0618
                                 TextPanel.GetPublicText();

            if (currentText == m_panelText)
            {
                return;
            }

            m_panelText = currentText;
            GetAutopilotActions();
        }
Ejemplo n.º 4
0
            } // AddLog method

            public void Update()
            {
                const string title = "Log File\n"; // Screen Title

                int    i    = 0;                   // loop counter
                string temp = "";                  // temp string

                if (log == "")
                {
                    return; // nothing to do
                }

                lcd = LCDList[0] as IMyTextPanel; // grab the first lcd

                temp = lcd.GetPublicText();       // grab the text
                if (temp.Contains(title))
                {
                    temp.Remove(temp.IndexOf(title, 0), title.Length); // remove the title
                } // if title
                temp = title + log + temp;                             // update the log string

                lcd.WritePublicText(temp);                             // write to first panel

                for (i = 1; i < LCDList.Count; i++)
                {
                    lcd = LCDList[i] as IMyTextPanel; // grab the panel
                    lcd.WritePublicText(temp);        // write subsequent panel(s)
                } // lcd for

                log = ""; // reset log buffer
            } // Update method
        private void Log(string text)
        {
            return;

            string line = text; //Logger.Log(text);

            MyAPIGateway.Utilities.ShowMessage("TR-Log", line);

            if (LcdPanel == null)
            {
                return;
            }

            List <string> output = new List <string>();

            output.AddArray(LcdPanel.GetPublicText().Split('\n'));
            if (output.Count > 17)
            {
                while (output.Count > 16)
                {
                    output.RemoveAt(0);
                }

                LcdPanel.WritePublicText(string.Join("\n", output.ToArray()));
            }

            LcdPanel.WritePublicText(line + "\n", true);
        }
Ejemplo n.º 6
0
        private void debug(string line, int logLevel = LOG_LVL_DEBUG)
        {
            if (usedLogLevel != LOG_LVL_SILENT)
            {
                if (usedLogLevel >= logLevel)
                {
                    string prefix = "";
                    if (usedLogLevel >= LOG_LVL_DEBUG)
                    {
                        prefix = "[Tick#" + this.ElapsedTime.Ticks.ToString() + "]";
                    }

                    line = prefix + line;

                    Echo(line.Trim());

                    List <IMyTerminalBlock> LCDs = new List <IMyTerminalBlock>();
                    GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(LCDs, (x => x.CustomName.Contains(TAG_LOG_DEBUG_LCD) && x.CubeGrid.Equals(Me.CubeGrid)));

                    for (int i = 0; i < LCDs.Count; i++)
                    {
                        IMyTextPanel  LCD = LCDs[i] as IMyTextPanel;
                        StringBuilder sb  = new StringBuilder();
                        sb.AppendLine(line);
                        sb.Append(LCD.GetPublicText());
                        LCD.WritePublicText(sb.ToString());
                    }
                }
            }
        }
Ejemplo n.º 7
0
 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();
 }
Ejemplo n.º 8
0
        // 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();
                }
            }
        }
Ejemplo n.º 9
0
        private void LoadFullAmounts()
        {
            string input = setupScreen.GetPublicText();

            string[] lines = input.Split('\n');

            int i = 0;

            for (; i < lines.Length; i++)
            {
                if (lines[i] == "")
                {
                    break;
                }
                string[] args = lines[i].Split(';');
                if (args.Length >= 2)
                {
                    float y;
                    float.TryParse(args[1], out y);
                    mineralDic[args[0]].FullAmount = y;
                }
            }
            i++;
            for (; i < lines.Length; i++)
            {
                string[] args = lines[i].Split(';');
                if (args.Length >= 2)
                {
                    float y;
                    float.TryParse(args[1], out y);
                    componentDic[args[0]].FullAmount = y;
                }
            }
        }
Ejemplo n.º 10
0
        public void UpdateLCD()
        {
            if (Panel != null)
            {
                var sb = new StringBuilder();

                sb.Append(currentItem.UpdateDesc() ?? currentItem.Description);
                for (int i = 0; i < currentItem.Items.Count; i++)
                {
                    if (i == selectedItemIndex)
                    {
                        sb.Append("[ " + currentItem.Items[i].Name + " ]" + '\n');
                    }
                    else
                    {
                        sb.Append("  " + currentItem.Items[i].Name + '\n');
                    }
                }
                string result = sb.ToString();
                //saves bandwidth and render time
                if (Panel.GetPublicText() == result)
                {
                    return;
                }
                Panel.WritePublicText(result);
                //Panel.ShowPrivateTextOnScreen();
                Panel.ShowPublicTextOnScreen();
            }
        }
        public void LcdPrint(string msg, string lcdName = "VarPanel")
        {
            IMyTextPanel lcd =
                GridTerminalSystem.GetBlockWithName(lcdName) as IMyTextPanel;

            lcd.WritePublicText(lcd.GetPublicText() + msg);
        }
Ejemplo n.º 12
0
        void Main(string args)
        {
            Echo("Hellow World");

            IMyTextPanel LCD = GridTerminalSystem.GetBlockWithName("LCDW") as IMyTextPanel;

            if (IfFirstRun)
            {
                LCDTotalString = LCD.GetPublicText();

                LCDGIFStringArray = LCDTotalString.Split('*');
                IndexMax          = LCDGIFStringArray.Length;
                IfFirstRun        = false;
            }


            LCD.WritePublicText(LCDGIFStringArray[Index]);
            Index++;
            if (Index >= IndexMax)
            {
                Index = 0;
            }
            Echo(Index.ToString());
            Echo(IfFirstRun.ToString());
            return;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Builds detectedGrids from a text panel.
        /// </summary>
        /// <param name="textPanelName">text panel name to lookup</param>
        void createListDetected(string textPanelName)
        {
            // get panel
            IMyTextPanel            panel      = null;
            List <IMyTerminalBlock> textPanels = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(textPanels);
            for (int index = 0; index < textPanels.Count; index++)
            {
                if (textPanels[index].DisplayNameText == textPanelName)
                {
                    panel = textPanels[index] as IMyTextPanel;
                    break;
                }
            }

            // assume panel has been filled, otherwise something went horribly wrong

            // get data
            string[] splitByLine = panel.GetPublicText().Split(newLine, StringSplitOptions.RemoveEmptyEntries);

            // erase panel
            panel.WritePublicText("");

            // build from data and invoke handler
            for (int lineIndex = 0; lineIndex < splitByLine.Length; lineIndex++)
            {
                if (!string.IsNullOrWhiteSpace(splitByLine[lineIndex]))
                {
                    //string distanceString = splitByLine[lineIndex].Split(separator)[4];
                    //debug("distance = "+distanceString+" => "+);
                    handle_detectedGrid(new Detected(splitByLine[lineIndex]));
                }
            }
        }
        /// <summary>
        /// Extracts txt info
        /// </summary>
        /// <param name="txt"></param>
        /// txt panel
        /// <returns></returns>
        public string GetRaw(IMyTextPanel txt)
        {
            string output;

            output = txt.GetPublicText();
            return(output);
        }
        /// <summary>
        /// Clears selected LCD's public text and returns it.
        /// </summary>
        /// <param name="lcdName">Block Name of LCD (not the Title!)</param>
        /// <returns></returns>
        public string LcdClear(string lcdName)
        {
            IMyTextPanel lcd =
                GridTerminalSystem.GetBlockWithName(lcdName) as IMyTextPanel;
            string text = lcd.GetPublicText();

            lcd.WritePublicText("");
            return(text);
        }
Ejemplo n.º 16
0
 private void UpdateLCD()
 {
     thisHUDMessage = new HUDTextAPI.HUDMessage(thisLcd.EntityId,
                                                ttl,
                                                thistextPosition,
                                                thistextScale,
                                                true, false, Color.Black,
                                                thisconfigcolour + thisLcd.GetPublicText()
                                                );
     textAPI.Send(thisHUDMessage);
 }
Ejemplo n.º 17
0
    public string GetPublicText()
    {
        string ret = "";

        IMyTextPanel textPanel = Block as IMyTextPanel;

        if (textPanel != null)
        {
            ret = textPanel.GetPublicText();
        }

        return(ret);
    }
Ejemplo n.º 18
0
            //USERINPUT (FS)
            public void AddText(string mes)
            {
                string output = "[" + currentTarget + "]: " + mes;

                output = FormatMessage(output);
                string[]      entry     = output.Split('\n');
                string[]      lines     = window.GetPublicText().Split('\n');
                List <string> linesList = lines.ToList();
                short         counter   = (short)(lines.Length - 1);

                while (!lines[counter].StartsWith("[You]"))
                {
                    counter--;
                }
                foreach (string line in entry)
                {
                    linesList.Insert(counter, line);
                    counter++;
                }
                lines             = linesList.ToArray();
                window.CustomData = "";
                foreach (string line in lines)
                {
                    if (line != lines[lines.Length - 1])
                    {
                        window.CustomData = window.CustomData + line + "\n";
                    }
                    else
                    {
                        window.CustomData = window.CustomData + line;
                    }
                }
                if (currentState == Window.CHAT)
                {
                    UpdateChatWindow();
                }
            }
Ejemplo n.º 19
0
    public static void Log(string logMessage, Action <string> echo = null, IMyProgrammableBlock me = null, string label = null, IMyTextPanel mirrorLcd = null, bool truncateForLcd = true)
    {
        String output = "";

        if (echo == null)
        {
            output  = "\n";
            output += logMessage;
            throw new Exception(output);
        }
        if (LogBuffer == null)
        {
            LogBuffer = new StringBuilder();
        }
        if (label != null)
        {
            logMessage = label + ": " + logMessage;
        }
        if (mirrorLcd != null)
        {
            string currentlyMirrored = mirrorLcd.GetPublicText();
            if (truncateForLcd && LogBuffer.Length + logMessage.Length > LOG_MAX_LCD_LENGTH_CHARS)
            {
                StringBuilder lcdBuffer          = new StringBuilder(LogBuffer.ToString());
                int           charAmountToOffset = fullLineCharsExceeding(lcdBuffer, logMessage.Length, LogBuffer.Length - (LOG_MAX_LCD_LENGTH_CHARS - logMessage.Length));
                lcdBuffer.Remove(0, LogBuffer.Length - LOG_MAX_LCD_LENGTH_CHARS + charAmountToOffset - 2);
                lcdBuffer.AppendLine();
                lcdBuffer.Append(logMessage);
                mirrorLcd.WritePublicText(lcdBuffer.ToString(), false);
            }
            else
            {
                string potentialNewLine = (currentlyMirrored.Length > 0)? "\n" : "";
                mirrorLcd.WritePublicText(potentialNewLine + logMessage, true);
            }
        }
        if (LogBuffer.Length + logMessage.Length * 2 > LOG_MAX_ECHO_LENGTH_CHARS)
        {
            int charAmountToRemove = fullLineCharsExceeding(LogBuffer, logMessage.Length);
            LogBuffer.Remove(0, charAmountToRemove);
            LogBuffer.Append(output);
        }
        if (LogBuffer.Length > 0)
        {
            LogBuffer.AppendLine();
        }
        LogBuffer.Append(logMessage);
        echo(LogBuffer.ToString());
    }
Ejemplo n.º 20
0
            protected override void Enable()
            {
                if (textPanelBlock != null)
                {
                    normalShowText  = textPanelBlock.ShowText;
                    normalText      = textPanelBlock.GetPublicText();
                    normalFontSize  = textPanelBlock.FontSize;
                    normalFontColor = textPanelBlock.FontColor;
                    normalBgColor   = textPanelBlock.BackgroundColor;

                    textPanelBlock.WritePublicText(alertText);
                    textPanelBlock.FontSize        = fontSize;
                    textPanelBlock.FontColor       = fontColor;
                    textPanelBlock.BackgroundColor = bgColor;

                    textPanelBlock.Enabled = true;
                    textPanelBlock.ShowPublicTextOnScreen();
                }
            }
Ejemplo n.º 21
0
        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();
            }
        }
Ejemplo n.º 22
0
        string BottomLeftText(string input)
        {
            int    LCDW = 52;
            int    LCDH = 17;
            string text = LCD.GetPublicText();

            string[] textArr  = text.Split(new string[] { ('\n').ToString() }, StringSplitOptions.RemoveEmptyEntries);
            int      AddLines = (LCDH - textArr.Length);

            Echo("Lines " + AddLines.ToString());
            string input1 = "";

            for (int u = 0; u < AddLines; u++)
            {
                input1 += "\n";
            }
            input = input1 + input;
            string[] LinesArr = input1.Split(new string[] { ("\n").ToString() }, StringSplitOptions.RemoveEmptyEntries);
            Echo(LinesArr.Length.ToString());
            return(input);
        }
        /*
         *  example implementation for BaconArgs:
         *  run the PB with
         *      --source="TextPanel 1" --destination="TextPanel 2"
         *  to copy PublicText from TextPanel 1 to TextPanel 2
         */
        public void Main(string argument)
        {
            // parse PB arguments with Baconargs
            BaconArgs Args = BaconArgs.parse(argument);

            // validate if there is one --source and one --destination option given
            // as you can see the options are accessed without the leading --
            if (Args.getOption("source").Count == 1 && Args.getOption("destination").Count == 1)
            {
                // get the TextPanels using --source and --destination options
                // as options saved as a List<string> they are accessed like getOption("the option name")[zero-based-index]
                IMyTextPanel SourcePanel      = GridTerminalSystem.GetBlockWithName(Args.getOption("source")[0]) as IMyTextPanel;
                IMyTextPanel DestinationPanel = GridTerminalSystem.GetBlockWithName(Args.getOption("destination")[0]) as IMyTextPanel;

                //copy private text from source to destination if both block could be found
                if (SourcePanel != null && DestinationPanel != null)
                {
                    DestinationPanel.WritePublicText(SourcePanel.GetPublicText());
                }
            }
        }
Ejemplo n.º 24
0
        // 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();
                }
            }
        }
Ejemplo n.º 25
0
        private List <BfGps> getGpsWaypoints(IMyTextPanel TextPanel)
        {
            Dictionary <string, BfGps> Waypoints = new Dictionary <string, BfGps>();
            List <IMyTextPanel>        Panels    = getPipeFromTextPanel(TextPanel);

            Panels.Add(TextPanel);
            for (int i = 0; i < Panels.Count; i++)
            {
                IMyTextPanel TempPanel = Panels[i];
                Waypoints = addWaypointsToDict(TempPanel.CustomName, Waypoints);
                Waypoints = addWaypointsToDict(TempPanel.GetPublicText(), Waypoints);
                Waypoints = addWaypointsToDict(TempPanel.GetPrivateTitle(), Waypoints);
                Waypoints = addWaypointsToDict(TempPanel.GetPrivateText(), Waypoints);
            }
            List <BfGps> GpsPoints = new List <BfGps>();

            foreach (KeyValuePair <string, BfGps> item in Waypoints)
            {
                GpsPoints.Add(item.Value);
            }

            return(GpsPoints);
        }
Ejemplo n.º 26
0
        public Config readConfig()
        {
            Config       config    = new Config();
            IMyTextPanel configLCD = Utils.searchLcdWithName(gridTerminal, this.configLCDName);

            if (configLCD != null)
            {
                String script = configLCD.GetPublicText();
                if (!String.IsNullOrEmpty(script))
                {
                    String[] lines = script != null?script.Split(new string[] { "\n" }, StringSplitOptions.None) : null;

                    if (lines != null && lines.Length >= 1)
                    {
                        foreach (String line in lines)
                        {
                            String[] keyValue = line.Split(new string[] { "=" }, StringSplitOptions.None);
                            if (keyValue.Length == 2)
                            {
                                String   key          = keyValue[0].Replace("const string", "").Replace("string", "").Replace("const String", "").Replace("String", "").Trim();
                                String   valuesString = keyValue[1].Replace("\"", "").Replace(";", "");
                                String[] values       = valuesString.Split(new string[] { "," }, StringSplitOptions.None);
                                switch (key)
                                {
                                case "doors1":
                                    config.doors1.AddList(searchDoors(values));
                                    break;

                                case "doors2":
                                    config.doors2.AddList(searchDoors(values));
                                    break;

                                case "vents1":
                                    config.vents1.AddList(searchVents(values));
                                    break;

                                case "sluiceVents":
                                    config.sluiceVents.AddList(searchVents(values));
                                    break;

                                case "vents2":
                                    config.vents2.AddList(searchVents(values));
                                    break;

                                case "pressurized1":
                                    bool pressurized1 = false;
                                    if (values.Length > 0 && Boolean.TryParse(values[0], out pressurized1))
                                    {
                                        config.pressurized1 = pressurized1;
                                    }
                                    break;

                                case "pressurized2":
                                    bool pressurized2 = false;
                                    if (values.Length > 0 && Boolean.TryParse(values[0], out pressurized2))
                                    {
                                        config.pressurized2 = pressurized2;
                                    }
                                    break;

                                case "sensors1":
                                    config.sensors1.AddList(searchSensors(values));
                                    break;

                                case "sluiceSensors":
                                    config.sluiceSensors.AddList(searchSensors(values));
                                    break;

                                case "sensors2":
                                    config.sensors2.AddList(searchSensors(values));
                                    break;

                                case "lights":
                                    config.lights.AddList(searchLights(values));
                                    break;

                                case "abortSeconds":
                                    long abortMilliseconds = 0;
                                    if (values.Length > 0 && long.TryParse(values[0].Trim(), out abortMilliseconds))
                                    {
                                        config.abortMilliseconds = abortMilliseconds * 1000;
                                    }
                                    break;

                                case "statusPanel":
                                    if (values.Length > 0)
                                    {
                                        config.statusPanel = Utils.searchLcdWithName(this.gridTerminal, values[0].Trim());
                                    }
                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    configLCD.WritePublicText("const String doors1 = \"Tür1\";\n" +
                                              "const String pressurized1 = \"true\";\n" +
                                              "const String vents1 = \"\";\n" +
                                              "const String sensors1 = \"sensor1\";\n" +
                                              "const String sluiceVents = \"Vent1\";\n" +
                                              "const String sluiceSensors = \"sluiceSensor\";\n" +
                                              "const String doors2 = \"Tür2\";\n" +
                                              "const String pressurized2 = \"false\";\n" +
                                              "const String vents2 = \"\";\n" +
                                              "const String sensors2 = \"sensor2\";\n" +
                                              "const String lights = \"\";\n" +
                                              "const String abortSeconds = \"10\";\n" +
                                              "const String statusPanel = \"textPanel\";\n", false);
                    configLCD.SetShowOnScreen(Sandbox.Common.ObjectBuilders.ShowTextOnScreenFlag.PUBLIC);
                }
            }
            return(config);
        }
Ejemplo n.º 27
0
            public bool Initial(IMyTextPanel I_lcd, MyGridProgram I_currentScript, bool syncInitial = false)
            {
                if (!syncInitial)
                {
                    LCD             = I_lcd;
                    CurrentScript   = I_currentScript;
                    GIFRawString    = new StringBuilder(I_lcd.CustomData);
                    ScreenRawString = new StringBuilder(I_lcd.GetPublicText());

                    syncLastInitialStep             = 0;
                    syncLastInitialGIFRawStringStep = 0;

                    currentGIF = 0;
                    totalGIF   = 1;

                    L_Changes.Clear();


                    totalGIF = new PixelChange2(
                        GIFRawString[GIFRawString.Length - 2],
                        GIFRawString[GIFRawString.Length - 1]).index + 1;


                    for (int ig = 0; ig < totalGIF; ig++)
                    {
                        L_Changes.Add(new List <PixelChange2>());
                    }


                    if (GIFRawString.Length / 2 >= singleStepMaxInstructionCount)
                    {
                        ifCheckInstructionCount = true;
                    }
                }

                int spareInstructionCount = singleStepMaxInstructionCount - CurrentScript.Runtime.CurrentInstructionCount;

                if (spareInstructionCount <= 0)
                {
                    return(true);
                }
                int iInstructionLimit = syncLastInitialGIFRawStringStep + spareInstructionCount;



                int i = syncLastInitialGIFRawStringStep;
                int iInstructionLimitMax = syncLastInitialGIFRawStringStep + spareInstructionCount;
                int iTotalPixelChanges   = GIFRawString.Length / 2;
                int iMax = iTotalPixelChanges > iInstructionLimitMax ? iInstructionLimitMax : iTotalPixelChanges;



                PixelChange2 temp_storage = new PixelChange2();



                if (i + 1 == iTotalPixelChanges)
                {
                    return(false);
                }


                //只在大量费时工作启用sync检查
                for (/* :D */; i < iMax; i += 2)
                {
                    temp_storage = new PixelChange2(GIFRawString[i], GIFRawString[i + 1]);
                    L_Changes[temp_storage.index].Add(temp_storage);
                }
                syncLastInitialGIFRawStringStep = i;

                CurrentScript.Echo("Finished");
                return(true);
            }
Ejemplo n.º 28
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////
        /*                                                           EXTERNAL DATA PROCESSING                                                            */
        //////////////////////////////////////////////////////////////////////////////////////////////////////////

        void LoadExternalConfigData()
        {
            string _file = config.GetPublicText();

            if (_file.Contains(configDivider.ToString()))
            {
                string[] _data = _file.Split(configDivider);
                //////////////////////// GETTING PLATFORM ID ////////////////////////////
                if (_data.Length > 1)
                {
                    platformID = _data[1].Replace("platformID: ", "").Replace(blank, "");
                }
                if (platformID == "")
                {
                    Debug("<SEC>: No valid platformID found!");
                }
                Debug("PlatformID: " + platformID);
                ///////////////////// GETTING PLATFORM ROLE ID /////////////////////////
                if (_data.Length > 2)
                {
                    platformRoleID = int.Parse(_data[2].Replace("platformRoleID: ", "").Replace(blank, ""));
                }
                Debug("Platform Role ID: " + platformRoleID.ToString());
                //////////////////// GETTING CURRENT CONDITION /////////////////////////
                if (_data.Length > 3)
                {
                    condition = _data[3].Replace("condition: ", "").Replace(blank, "");
                }
                Debug("Condition: " + condition);
                if (_data.Length > 4)
                {
                    ////////////////////// GETTING INSTALL ENABLED /////////////////////////
                    if (_data[4].ToLower().Contains("true") || _data[4].ToLower().Contains("yes"))
                    {
                        installEnabled = true;
                    }
                    else
                    {
                        installEnabled = false;
                    }
                    Debug("Install Enabled: " + installEnabled.ToString());
                }
                else    ///////////////////////// CORRECTING FORMAT
                {
                    StoreExternalConfigData();
                }
                if (_data.Length > 5)
                {
                    ///////////////////// GETTING HIDE VERSION INFO ////////////////////////
                    if (_data[5].ToLower().Contains("true") || _data[5].ToLower().Contains("yes"))
                    {
                        hideVersionInfoOnScreen = true;
                    }
                    else
                    {
                        hideVersionInfoOnScreen = false;
                    }
                    Debug("Hide Version Info: " + hideVersionInfoOnScreen.ToString());
                }
                else    ///////////////////////// CORRECTING FORMAT
                {
                    StoreExternalConfigData();
                }
                if (_data.Length > 6)
                {
                    /////////////////// GETTING ALLOW BEACON RENAME //////////////////////
                    if (_data[6].ToLower().Contains("true") || _data[6].ToLower().Contains("yes"))
                    {
                        allowBeaconRename = true;
                    }
                    else
                    {
                        allowBeaconRename = false;
                    }
                    Debug("Allow beacon rename: " + allowBeaconRename.ToString());
                }
                else    ///////////////////////// CORRECTING FORMAT
                {
                    StoreExternalConfigData();
                }
                if (_data.Length > 7)
                {
                    /////////////////// GETTING SECURITY ACTIVE //////////////////////
                    if (_data[7].ToLower().Contains("true") || _data[7].ToLower().Contains("yes"))
                    {
                        securityActive = true;
                    }
                    else
                    {
                        securityActive = false;
                    }
                    Debug("activate security: " + securityActive.ToString());
                }
                else    ///////////////////////// CORRECTING FORMAT
                {
                    StoreExternalConfigData();
                }
                if (_data.Length > 9)
                {
                    ///////////////////////// GET DEFAULT PANEL BG COLOR
                    string[] _temp = _data[8].Split('}');
                    _temp[0] = _temp[0].Replace("LCD BG Color: {", "");
                    string[] _colors = _temp[0].Split(' ');
                    _colors[0]     = _colors[0].Replace("R:", "");
                    _colors[1]     = _colors[1].Replace("G:", "");
                    _colors[2]     = _colors[2].Replace("B:", "");
                    panelDefaultBG = new Color(int.Parse(_colors[0]), int.Parse(_colors[1]), int.Parse(_colors[2]));
                    ///////////////////////// GET DEFAULT PANEL FONT COLOR
                    _temp          = _data[9].Split('}');
                    _temp[0]       = _temp[0].Replace("LCD Font Color: {", "");
                    _colors        = _temp[0].Split(' ');
                    _colors[0]     = _colors[0].Replace("R:", "");
                    _colors[1]     = _colors[1].Replace("G:", "");
                    _colors[2]     = _colors[2].Replace("B:", "");
                    panelDefaultFC = new Color(int.Parse(_colors[0]), int.Parse(_colors[1]), int.Parse(_colors[2]));
                }
                else    ///////////////////////// CORRECTING FORMAT
                {
                    StoreExternalConfigData();
                }
                // StoreExternalConfigData ();
            }
            else
            {
                ///////////////////////// CORRECTING FORMAT
                StoreExternalConfigData();
            }
            SetCondition(condition);
        }
 void m(IMyTextPanel a)
 {
     if (Autoscroll)
     {
         var b = new List <string>(a.GetPublicText().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)); b.AddRange(k); int c = Math.Min(n(a), b.Count); if (Prepend)
         {
             b.Reverse();
         }
         a.WritePublicText(string.Join("\n", b.GetRange(b.Count - c, c).ToArray()), false);
     }
     else if (Prepend)
     {
         var b = new List <string>(a.GetPublicText().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)); b.AddRange(k); b.Reverse(); a.WritePublicText(string.Join("\n", b.ToArray()), false);
     }
     else
     {
         a.WritePublicText(string.Join("\n", k.ToArray()), true);
     }
 }
Ejemplo n.º 30
0
 public void WriteText(string str)
 {
     text.WritePublicText(text.GetPublicText() + str);
 }