コード例 #1
0
ファイル: Display.cs プロジェクト: dmorigin/se_mod_vis
            public bool addRenderTarget(IMyTextSurface surface, RenderTargetID id, Vector2I coordinate)
            {
                if (getRenderTarget(coordinate) == null && surface != null)
                {
                    RenderTarget rt = new RenderTarget(id, coordinate);
                    rt.construct();
                    rt.setupSurface(surface);

                    // calculate surface offset
                    Vector2 offset = new Vector2(coordinate.X * rt.Size.X, coordinate.Y * rt.Size.Y);

                    // expand vd area
                    renderArea_.X      = Math.Min(renderArea_.X, offset.X);
                    renderArea_.Y      = Math.Min(renderArea_.Y, offset.Y);
                    renderArea_.Width  = Math.Max(renderArea_.Width, (coordinate.X + 1) * rt.Size.X);
                    renderArea_.Height = Math.Max(renderArea_.Height, (coordinate.Y + 1) * rt.Size.Y);

                    // add pd to list
                    renderTargets_.Add(rt);
                    reference_ = getReferenceRT();
                    return(true);
                }

                return(false);
            }
コード例 #2
0
ファイル: RenderTarget.cs プロジェクト: dmorigin/se_mod_vis
            public void setupSurface(IMyTextSurface surface)
            {
                surface_             = surface;
                surface_.Script      = "";
                surface_.ContentType = ContentType.SCRIPT;
                surface_.Font        = Default.Font;
                surface_.FontSize    = 1f;
                surface_.TextPadding = 0f;

                BackgroundColor = Color.Black;

                RectangleF rect;

                if (!RenderTargetID.tryGetFixed(ID, out rect))
                {
                    Size     = surface_.SurfaceSize;
                    Position = (surface_.TextureSize - Size) * 0.5f;
                }
                else
                {
                    Size     = rect.Size;
                    Position = rect.Position;
                }

                DisplayOffset = -(Size * Coordinate) + Position;

                if (RenderTarget.sprites_.Count == 0)
                {
                    surface_.GetSprites(RenderTarget.sprites_);
                }

                drawInitScreen();
            }
コード例 #3
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);
                }
コード例 #4
0
ファイル: Console.cs プロジェクト: dmorigin/se_mod_vis
            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);
            }
コード例 #5
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);
                }
コード例 #6
0
ファイル: RenderTarget.cs プロジェクト: dmorigin/se_mod_vis
            /*
             * public Color BackgroundColor
             * {
             *  get { return surface_.ScriptBackgroundColor; }
             *  set
             *  {
             *      surface_.ScriptBackgroundColor = value;
             *      surface_.BackgroundColor = value;
             *  }
             * }*/

            public RenderTarget(RenderTargetID id, Vector2I coordinate)
            {
                Coordinate = coordinate;
                ID         = id;
            }