Esempio n. 1
0
        public void Main(string argument)
        {
            List <IMyTextPanel> TTYs = new List <IMyTextPanel>();

            GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(TTYs, (IMyTextPanel x) => x.CustomName.Contains("TTY") && x.CubeGrid.Equals(Me.CubeGrid));
            BaconShell.Environment env = new BaconShell.Environment(this, GridTerminalSystem, new BaconDebug("debug", GridTerminalSystem, this, 99));
            BaconShell             bs  = new BaconShell(env);

            for (int i_TTY = 0; i_TTY < TTYs.Count; i_TTY++)
            {
                IMyTextPanel TTY   = TTYs[i_TTY];
                string       stdin = TTY.GetPrivateText();
                if (!stdin.Equals(""))
                {
                    StringBuilder stdout  = new StringBuilder();
                    string[]      command = stdin.Split(new Char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < command.Length; i++)
                    {
                        BaconArgs Args = BaconArgs.parse(command[i]);
                        stdout.Append(bs.runCommand(Args, env).ToString());
                    }
                    TTY.WritePrivateText("");
                    TTY.WritePublicText(stdout.ToString());
                }
            }
        }
Esempio n. 2
0
    public EasyBlock AppendPrivateText(string text)
    {
        IMyTextPanel textPanel = Block as IMyTextPanel;

        if (textPanel != null)
        {
            textPanel.WritePrivateText(text, true);
        }

        return(this);
    }
Esempio n. 3
0
        private bool displayOnPrivateText(IMyTextPanel TextPanel, StringBuilder Text)
        {
            string toPrivateTag = TAG.ToLower() + ">private";

            if (TextPanel.CustomName.ToLower().Contains(toPrivateTag))
            {
                return(TextPanel.WritePrivateText(Text.ToString()));
            }

            return(false);
        }
Esempio n. 4
0
        public void Main(string argument)
        {
            Echo(string.Format("Arguments:\n  {0}: switch panel state for {1} to open\n  {2}: switch panel state for {1} to close\n  {3}: switch panel state for {4} to open\n  {5}: switch panel state for {4} to close", open1, label1, close1, open2, label2, close2));
            IMyTextPanel GatePanel = null;

            switch (argument)
            {
            case open1:
                GatePanel = getPanelGate1();
                GatePanel?.WritePrivateText(getImageOpen(label1)?.ToString());
                Echo(string.Format("Try Open {0}", label1));
                break;

            case close1:
                GatePanel = getPanelGate1();
                GatePanel?.WritePrivateText(getImageClose(label1)?.ToString());
                Echo(string.Format("Try Close {0}", label1));
                break;

            case open2:
                GatePanel = getPanelGate2();
                GatePanel?.WritePrivateText(getImageOpen(label2)?.ToString());
                Echo(string.Format("Try Open {0}", label2));
                break;

            case close2:
                GatePanel = getPanelGate2();
                GatePanel?.WritePrivateText(getImageClose(label2)?.ToString());
                Echo(string.Format("Try Close {0}", label2));
                break;

            default:
                Echo(string.Format("ERROR: Unsupported argument: \"{0}\".", argument));
                break;
            }
            if (GatePanel == null)
            {
                Echo(string.Format("ERROR: Can't find Panel make sure it containse \"{0}\" in it's Name", (argument.Contains("1")?panelGate1:(argument.Contains("2")? panelGate2 :panelGate1 + "\" or \"" + panelGate2))));
            }
        }
Esempio n. 5
0
        public void UpdatePrivate(bool show = false)
        {
            if (FontSize != _panel.GetValueFloat("FontSize"))
            {
                _panel.SetValueFloat("FontSize", FontSize);
            }

            // no need to update if the text has not changed.
            if (_panel.GetPrivateText() != _privateString.ToString())
            {
                _panel.WritePrivateText(_privateString.ToString());

                if (show)
                {
                    if (ForceRedraw)
                    {
                        _panel.ShowTextureOnScreen();
                    }
                    _panel.ShowPrivateTextOnScreen();
                }
            }
        }
Esempio n. 6
0
        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));
            }
        }
Esempio n. 7
0
 //Internal storage interface
 private void Append(string value)
 {
     bus.WritePrivateText(value, true);
 }