コード例 #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
ファイル: VISManager.cs プロジェクト: dmorigin/se_mod_vis
                bool configRTFixSize(string key, string value, Configuration.Options options)
                {
                    int            index = options.asInteger(0, 0);
                    RenderTargetID id    = $"{value}:{index}";

                    if (id == RenderTargetID.Invalid)
                    {
                        manager_.log(Console.LogType.Error, $"Invalid block id \"{value}\"");
                        return(false);
                    }

                    RectangleF rect = new RectangleF(options.asVector(2, new Vector2()), options.asVector(1, new Vector2()));

                    if (Default.RenderTargetFixSize.ToList().Exists((pair) => pair.Key.Equals(id)))
                    {
                        Default.RenderTargetFixSize[id] = rect;
                    }
                    else
                    {
                        Default.RenderTargetFixSize.Add(id, rect);
                    }

                    return(true);
                }