Exemple #1
0
        //public static Vector GenerateScreenSize (Vector pixelSize) => new Vector (pixelSize.x / Dae.UnitPixelSize.x, pixelSize.y / Dae.UnitPixelSize.y);

        public static void Blit(CBuffer from, CBuffer to, IVector fromStart, IVector fromEnd, IVector toStart)
        {
            for (int fy = fromStart.y; fy < fromEnd.y && fy + toStart.y < to.Size.y; fy++)
            {
                for (int fx = fromStart.x; fx < fromEnd.x && fx + toStart.x < to.Size.x; fx++)
                {
                    IVector fLoc  = new IVector(fx, fy);
                    IVector toLoc = toStart + fLoc;

                    // Assignment
                    to[toLoc] = from[fLoc];
                }
            }
        }
Exemple #2
0
        internal static void AlertWindowResized(DWindow window)
        {
            GL.Viewport(0, 0, window.Width, window.Height);

            IVector res = new IVector(window.Width, window.Height);

            gridSize = res / (new IVector(1920, 1080) / hdScale);

            cachedUnitSize             = GetUnitSize(gridSize);
            cachedUnitScreenPositions  = new Vector[gridSize.y * gridSize.x];
            cachedUnitFontPositions    = new Vector[gridSize.y * gridSize.x];
            cachedUnitForegroundColors = new Color[gridSize.y * gridSize.x];
            cachedUnitBackgroundColors = new Color[gridSize.y * gridSize.x];

            IVector oldSize = rootCanvas.Size;

            bool rootCanvasSizeChanged = gridSize != oldSize;

            CBuffer oldBuffer = rootBuffer;

            rootCanvas.ChangeSize(gridSize);
            rootBuffer = rootCanvas.buffer;

            rootCanvas.SignalRender();

            if (rootCanvasSizeChanged)
            {
                window.Title = $"Dae | Size: {gridSize.x}x{gridSize.y}";
            }

            unitMaterial?.Set("size", GetUnitSize(gridSize) * unitScale);

            CBuffer.Blit(oldBuffer, rootBuffer, IVector.zero, oldBuffer.Size, IVector.zero);

            for (int y = 0; y < gridSize.y; y++)
            {
                for (int x = 0; x < gridSize.x; x++)
                {
                    CUnit unit = rootBuffer[x, y];
                    int   aPos = (y * gridSize.x) + x;
                    cachedUnitScreenPositions[aPos] = DMath.P01ToN1P1(GetCorrectedPosition(new Vector(x, y))).ReversedYFull;
                }
            }
        }
Exemple #3
0
        internal void RenderSubComponents()
        {
            // Remove all null components
            subComponents.RemoveAll(component => component == null);

            // Render all sub components
            foreach (Component component in subComponents)
            {
                if (component.Size.x > 0 && component.Size.y > 0)
                {
                    if (component.signalRender || !checkSignalRender)
                    {
                        component.signalRender = false;
                        component.Render();
                    }
                    CBuffer.Blit(component.buffer, buffer, Vector.zero, component.Size, component.position);
                }
            }
        }
Exemple #4
0
 public Component(IVector size)
 {
     buffer = new CBuffer(size);
 }
Exemple #5
0
 public Canvas(CBuffer buffer)
 {
     this.buffer = buffer;
 }
Exemple #6
0
        // Initialize/Start DAE
        internal static void Start()
        {
            rootBuffer = new CBuffer(new IVector(0, 0));
            rootCanvas = new RootCanvas(rootBuffer, RenderTarget.defaultRenderTarget);

            DWindow window = new DWindow();

            window.ProcessEvents();
            window.RenderFrameToScreen();

            // Initialize the static Graphics class
            Graphics.Initialize();

            // Clear out the screen (make sure it's not white when we start up the window) (Burns my eyes)
            GL.ClearColor(0, 0, 0, 1);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            window.Title = "LOADING ...";

            window.RenderFrameToScreen();

            window.Title = "LOADING PLUGINS ...";

            // Initialize PluginSystem
            PluginSystem.LoadPluginsFromAssembly(Assembly.GetExecutingAssembly());

            PluginSystem.LoadDllsFromPath(Util.CurrentPath + "Plugins/");

            window.Title = "LOADING START-UP SCRIPT...";

            Loader.PrepareScript();
            Loader.Run();

            Foo foo = new Foo(new IVector(30, 20));

            rootCanvas.AddComponent(foo);

            Button b1 = new Button(new IVector(15, 5));

            b1.position += 1;
            foo.AddComponent(b1);

            Button b2 = new Button(new IVector(15, 5));

            b2.position = b1.Size + 1;
            foo.AddComponent(b2);

            Time.OnSecond += OnSecond;

            window.Title = "Dae";

            IsRunning = true;

            logicTickThread = new Thread(TickLoop);
            logicTickThread.Start();

            // Enter the main loop
            Run();

            // Actually shutdown/free DAE from the system (GPU, Hooks & Memory)
            Shutdown();
        }