endlesstravel / Love2dCS

C# Wrapper for LÖVE, a 2d game engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setting window size should apply both width and height immediately

Shadowblitz16 opened this issue · comments

setting window size should apply both width and height immediately disregarding fps.
right now it slowly applys width and height one at a time and it takes about 2 seconds to do so.

using Love;
using System;

namespace PureCore
{
    public static class Sys
    {

        static SysRunner Scene { get; set; }
        public static void Init()
        {
            Scene = new SysRunner();
        }

        public static bool IsRunning()
        {
            return Scene.IsRunning();
        }

        public static void SetName(string name)
        {
            Scene.Name = name;
        }
        public static void SetFps (uint    fps)
        {
            Scene.Fps = fps;
        }
        public static void SetW   (uint      w)
        {
            Scene.W = w;
        }
        public static void SetH   (uint      h)
        {
            Scene.H = h;
        }
    }

    internal class SysRunner : Scene
    {
        bool running = true;
        uint fps;
        public string  Name
        {
            get
            {
                return Window.GetTitle();
            }
            set
            {
                Window.SetTitle(value);
            }
        }
        public uint    Fps
        {
            get
            {
                return (uint)(Timer.GetFPS() * fps);
            }
            set
            {
                fps = value;
                Timer.EnableLimitMaxFPS(1f / fps);
            }
        }
        public uint    W
        {
            get
            {
                Window.GetMode(out int w, out int _);
                return (uint)w;
            }
            set
            {
                Window.SetMode((int)value, (int)H);
            }
        }
        public uint    H
        {
            get
            {
                Window.GetMode(out _, out int h);
                return (uint)h;
            }
            set
            {
                Window.SetMode((int)W, (int)value);
            }
        }


        public SysRunner()
        {
            Boot.Init(new BootConfig());
            Name = "Untitled game";
            Fps  = 60;
            W    = 256;
            H    = 240;
        }

        public bool IsRunning()
        {
            Boot.SystemStep(this);
            Timer.Sleep(1/Timer.GetDelta());
            return running;
        }

        public override bool Quit()
        {
            running = false; // mark it as true to break loop
            return false; // return true will lead Application.Exit(); 
        }
    }
}
commented

I agree with you that the function of changing the window size brought by LÖVE's slow, which you can respond to the official forum.

do you have a link to a topic where I can complain?