Esempio n. 1
0
            static SdlScreens()
            {
                int displays = GetNumVideoDisplays();
                devices = new IScreen[displays];
                for (int d = 0; d < displays; d++)
                {
                    IRectangle bounds;
                    SdlFactory.GetDisplayBounds(d, out Rect rc);
                    bounds = Factory.newRectangle(rc.X, rc.Y, rc.Width, rc.Height);

                    SdlFactory.GetCurrentDisplayMode(d, out DisplayMode dm);

                    int total = GetNumDisplayModes(d);
                    var list = new IResolution[total];

                    for (int m = 0; m < total; m++)
                    {
                        GetDisplayMode(d, m, out DisplayMode sdm);
                        list[m] = new SdlResolution(bounds.X, bounds.Y, sdm.Width, sdm.Height, sdm.Format, sdm.RefreshRate);
                    }

                    var current_resolution = new SdlResolution(bounds.X, bounds.Y, dm.Width, dm.Height, dm.Format, dm.RefreshRate);
                    var device = new SdlScreen(current_resolution, d == 0, list, bounds, d);

                    devices[d] = (device);
                    if (d == 0)
                        primary = device;
                }
            }
Esempio n. 2
0
                public void ChangeResolution(int resolutionIndex)
                {
                    if (resolutionIndex >= resolutions.Length)
                        return;
                    var resolution = resolutions[resolutionIndex];

                    if (!resolution.Valid)
                        RestoreResolution();

                    if (resolution == this.Resolution)
                        return;

                    //effect.FadeOut();

                    if (changeResolution(this, resolution))
                    {
                        this.Resolution = resolution;
                    }
                    else
                    {
                        throw new System.Exception(string.Format("Device {0}: Failed to change resolution to {1}.",
                            this, resolution));
                    }

                    //effect.FadeIn();
                }
        private void ChangeDisplayWindow(IResolution resolution)
        {
            currentResolution = resolution;

            wind?.Dispose();

            wind = DisplayWindow.CreateFullScreen(Name, resolution);
            Display.RenderTarget = wind.FrameBuffer;
        }
Esempio n. 4
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.SupportedOrientations = DisplayOrientation.Portrait | DisplayOrientation.PortraitDown;

            _resolution = new ResolutionComponent(this, graphics, new Point(720, 1280), new Point(720, 1280), false, false);

            Content.RootDirectory = "Content";
        }
        private void ChangeDisplayWindow(IResolution resolution)
        {
            currentResolution = resolution;

            var screen = window.Screen;

            var createWindowParams = CreateWindowParams.FullScreen(
                Name, resolution, null);
        }
        private void ChangeResolution(IResolution resolution)
        {
            currentResolution = resolution;

            foreach (var window in windows)
            {
                window.Resolution = resolution;
            }
        }
Esempio n. 7
0
        public static ReadOnlyCollection <Element> GetElementsEx(this IResolution r, string path = "")
        {
            var container = r.GetElementEx(path) as Container;

            if (container == null)
            {
                throw new Exception("Element does not have child elements.");
            }
            return(container.elements);
        }
 /// <summary>
 /// Constructs a new ScreenManager instance.
 /// </summary>
 /// <param name="Input">An InputHelper instance, used for updating screens.</param>
 public ScreenManager(Game Gme, GraphicsDevice Graphics, SpriteFont[] Fonts, InputHelper Input, IResolution Res)
 {
     m_Game       = Gme;
     m_Graphics   = Graphics;
     m_SBatch     = new SpriteBatch(Graphics);
     m_Camera     = new Camera(Graphics);
     m_Input      = Input;
     m_Fonts      = Fonts;
     m_Resolution = Res;
 }
Esempio n. 9
0
        protected PluginsProvider(
            IMixinProvider mixinProvider,
            IResolution container)
        {
            Contract.Requires(mixinProvider != null);
            Contract.Requires(container != null);

            this.MixinProvider = mixinProvider;
            this.Container     = container;
        }
Esempio n. 10
0
        public static string GetDataEx(this IResolution r, string path = "")
        {
            var valueElement = r.GetElementEx(path) as ValueElement;

            if (valueElement == null)
            {
                throw new Exception("Element does not have a value.");
            }
            return(valueElement.data);
        }
Esempio n. 11
0
        public static void SetData(this IResolution r, string path, dynamic data)
        {
            var valueElement = r.GetElement(path) as ValueElement;

            if (valueElement == null)
            {
                return;
            }
            valueElement.data = data;
        }
Esempio n. 12
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            graphics.IsFullScreen          = true;
            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;

            resolution = new ResolutionComponent(this, graphics, new Point(1024, 576),
                                                 new Point(1024, 576), false, true);
        }
Esempio n. 13
0
        public static bool GetFlag(this IResolution r, string flagsPath, string flag)
        {
            var valueElement = r.GetElement(flagsPath) as ValueElement;
            var flagsDef     = valueElement?.flagsDef;

            if (flagsDef == null)
            {
                return(false);
            }
            return(flagsDef.FlagIsSet(valueElement.data, flag));
        }
Esempio n. 14
0
                internal SdlScreen(IResolution currentResolution, bool primary, IResolution[] resolutions, IRectangle bounds, object id)
                {
                    // Todo: Consolidate current resolution with bounds? Can they fall out of sync right now?
                    this.Resolution = currentResolution;
                    this.original = currentResolution;
                    IsPrimary = primary;
                    this.resolutions = (resolutions);
#pragma warning disable 612, 618
                    this.Bounds = bounds.Width ==0|| bounds.Height==0 ? currentResolution.Bounds : bounds;
#pragma warning restore 612, 618
                    this.monitorID = id;
                }
Esempio n. 15
0
        public static void SetValue(
            this IResolution r, string path, string value
            )
        {
            var valueElement = r.GetElement(path) as ValueElement;

            if (valueElement == null)
            {
                return;
            }
            valueElement.value = value;
        }
Esempio n. 16
0
                public void RestoreResolution()
                {
                    if (original.Valid)
                    {
                        //effect.FadeOut();

                        if (restoreResolution(this))
                            Resolution = original;
                        else
                            throw new System.Exception(string.Format("Device {0}: Failed to restore resolution.", this));
                        //effect.FadeIn();
                    }
                }
Esempio n. 17
0
        public static Element GetElement(this IResolution r, string path = "")
        {
            var element = r as Element;

            while (path.Length > 0)
            {
                if (element == null)
                {
                    return(null);
                }
                StringHelpers.SplitPath(path, out string pathPart, out path);
                element = element.ResolveElement(pathPart);
            }
            return(element);
        }
Esempio n. 18
0
        public static Element AddElement(this IResolution r, string path)
        {
            Element element = (Element)r;

            while (path.Length > 0)
            {
                if (element == null)
                {
                    return(null);
                }
                StringHelpers.SplitPath(path, out string pathPart, out path);
                element = element.CreateElement(pathPart);
            }
            return(element);
        }
        private void ChangeDisplayWindow(IResolution resolution)
        {
            currentResolution = resolution;

            foreach (var window in windows)
            {
                var screen = window.Screen;

                var createWindowParams = CreateWindowParams.FullScreen(
                    Name, resolution, null);

                createWindowParams.TargetScreen = screen;

                windows.Add(new DisplayWindow(createWindowParams));
            }
        }
Esempio n. 20
0
        public static Element GetParentElement(
            this IResolution r, Func <Element, bool> test
            )
        {
            var parent = r.container;

            while (parent != null)
            {
                if (test(parent))
                {
                    return(parent);
                }
                parent = parent.container;
            }
            return(null);
        }
Esempio n. 21
0
        public static bool GetFlagEx(this IResolution r, string flagsPath, string flag)
        {
            var valueElement = r.GetElementEx(flagsPath) as ValueElement;

            if (valueElement == null)
            {
                throw new Exception("Element does not have a value.");
            }
            FlagsDef flagsDef = valueElement.flagsDef;

            if (flagsDef == null)
            {
                throw new Exception("Element does not have flags.");
            }
            return(flagsDef.FlagIsSet(valueElement.data, flag));
        }
Esempio n. 22
0
 public static Element CreateElement(this IResolution r, string pathPart)
 {
     foreach (var strategy in strategies)
     {
         MatchData match = strategy.Match((Element)r, pathPart);
         if (match == null)
         {
             continue;
         }
         if (!strategy.canResolve)
         {
             return(strategy.Create(match));
         }
         return(strategy.Resolve(match) ?? strategy.Create(match));
     }
     return(null);
 }
Esempio n. 23
0
        public static Element GetElementEx(this IResolution r, string path = "")
        {
            var element = r as Element;

            if (element == null)
            {
                throw new Exception("Cannot resolve element from null.");
            }
            while (path.Length > 0)
            {
                StringHelpers.SplitPath(path, out string pathPart, out path);
                element = element.ResolveElement(pathPart);
                if (element == null)
                {
                    throw new Exception($"Failed to resolve element {pathPart}");
                }
            }
            return(element);
        }
Esempio n. 24
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = GlobalSettings.Default.ScreenWidth;
            graphics.PreferredBackBufferHeight = GlobalSettings.Default.ScreenHeight;
            graphics.IsFullScreen = GlobalSettings.Default.Fullscreen;

            m_Resolution = new ResolutionComponent(this, graphics, new Point(800, 600),
                                                   new Point(GlobalSettings.Default.ScreenWidth, GlobalSettings.Default.ScreenHeight),
                                                   GlobalSettings.Default.Fullscreen, false, false);

            Window.Title      = "The Sims Online";
            Window.TextInput += Window_TextInput;
            IsFixedTimeStep   = true;

            Application.ApplicationExit += Application_ApplicationExit;

            Content.RootDirectory = "Content";
        }
Esempio n. 25
0
        public LedSendServer(IRedisManager redis, IResolution resolution, IDTCache cache)
        {
            _serverUrl = ConfigurationManager.ConnectionStrings["Signalr"].ConnectionString;

            _log = LogManager.GetLogger(typeof(LedSendServer));

            _timer = new Timer(10000)
            {
                Enabled = true
            };

            _redis = redis;

            _resolution = resolution;

            fontList = _redis.Get <List <FontLibrary> >("Default:Kylin:LED:FontLibrary");

            _cache = cache;
        }
Esempio n. 26
0
        public static ReadOnlyCollection <Element> GetElements(this IResolution r, string path = "")
        {
            Container container = (Container)r.GetElement(path);

            return(container?.elements);
        }
Esempio n. 27
0
        public static bool RemoveElement(this IResolution r, string path)
        {
            var element = r.GetElement(path);

            return(element.Remove());
        }
Esempio n. 28
0
 public ResolutionContext(IResolution resolution)
 {
     this.resolution = resolution;
 }
Esempio n. 29
0
        public static dynamic GetData(this IResolution r, string path = "")
        {
            ValueElement valueElement = (ValueElement)r.GetElement(path);

            return(valueElement?.data);
        }
Esempio n. 30
0
        public static string GetValue(this IResolution r, string path = "")
        {
            var valueElement = r.GetElement(path) as ValueElement;

            return(valueElement?.value);
        }