示例#1
0
                bool configScreen(string key, string value, Configuration.Options options)
                {
                    // set surface index
                    int      screenId   = Configuration.asInteger(value, Default.DisplayID);
                    string   groupId    = Default.EmptyDisplayGroupID;
                    Vector2I coordinate = Default.DisplayCoordinate;

                    // extract group id
                    if (options.Count == 2)
                    {
                        // extract group id
                        groupId = options[0];

                        // extract coordinates
                        coordinate = options.asVector(1, Default.DisplayCoordinate);
                    }

                    if (screenId < 0 || screenId >= provider_.surfaceProvider_.SurfaceCount)
                    {
                        provider_.log(Console.LogType.Error, $"Invalid display id: {screenId}");
                        return(false);
                    }

                    Display display = Display.createDisplay(groupId, screenId, provider_.customName_);

                    if (display == null)
                    {
                        return(false);
                    }

                    // create render target to display
                    RenderTargetID RTID = RenderTargetID.fromSurfaceProvider(provider_.surfaceProvider_, screenId);

                    if (!display.addRenderTarget(provider_.surfaceProvider_.GetSurface(screenId), RTID, coordinate))
                    {
                        provider_.log(Console.LogType.Error, $"Render target exists: {groupId}:{coordinate}");
                        return(false);
                    }

                    // configure display
                    if (coordinate == new Vector2I(0, 0))
                    {
                        // setup display text
                        IMyTextPanel lcdPanel = provider_.surfaceProvider_ as IMyTextPanel;
                        if (lcdPanel != null)
                        {
                            display.PanelConnector = new Display.PanelConnectorObj(lcdPanel);
                        }

                        // create content container
                        ContentContainer container = new ContentContainer(display.GroupId);
                        setSubHandler(container.getConfigHandler());
                        display.ContentContainer = container;
                    }

                    return(true);
                }
示例#2
0
            public bool redirectConsole(IMyTextSurfaceProvider provider, int displayId)
            {
                if (provider != null && displayId < provider.SurfaceCount && displayId >= 0)
                {
                    if (renderTarget_ != null)
                    {
                        renderTarget_.releaseSurface();
                    }

                    renderTarget_ = new RenderTarget(RenderTargetID.fromSurfaceProvider(provider, displayId), new Vector2I(0, 0));
                    renderTarget_.setupSurface(provider.GetSurface(displayId));
                    renderTarget_.BackgroundColor = Color.Black;

                    float lineCount = (renderTarget_.Size.Y / (Default.CharHeight * fontSize_));
                    lineHeight_     = renderTarget_.Size.Y / (int)lineCount;
                    lineCorrection_ = (lineCount - (int)lineCount) * (int)(lineCount + 1);
                    return(true);
                }

                return(false);
            }