Exemplo n.º 1
0
        public HydraEngine(ActorTree actors, IRenderer renderer)
        {
            Actors   = actors;
            Renderer = renderer;

            Scheduler.RegisterUpdateListener(this);
        }
Exemplo n.º 2
0
        private EditorWindow(Builder builder) : base(builder.GetObject(Common.ID_MainWindow).Handle)
        {
            builder.Autoconnect(this);
            _rightVBox              = builder.GetObject(Common.ID_RightVBox) as Box;
            _packageChooser         = builder.GetObject(Common.ID_PackageChooser) as FileChooserButton;
            _packageSaveButton      = builder.GetObject(Common.ID_PackageSaveButton) as Button;
            _packageCookButton      = builder.GetObject(Common.ID_PackageCookButton) as Button;
            _packageSaver           = builder.GetObject(Common.ID_PackageSaver) as FileChooserDialog;
            _packageSavePopover     = builder.GetObject(Common.ID_PackageSavePopover) as Popover;
            _drawingArea            = builder.GetObject(Common.ID_DrawingArea) as DrawingArea;
            _hierarchyTree          = builder.GetObject(Common.ID_HierarchyTree) as TreeView;
            _aboutDialog            = builder.GetObject(Common.ID_AboutDialog) as AboutDialog;
            _aboutTrigger           = builder.GetObject(Common.ID_AboutDialogTrigger) as MenuItem;
            _templatePopover        = builder.GetObject(Common.ID_TemplatePopover) as Popover;
            _templatePopoverTrigger = builder.GetObject(Common.ID_TemplatePopoverTrigger) as Button;
            _renderStats            = builder.GetObject(Common.ID_FrameRenderStats) as Label;
            _hierarchyModel         = _hierarchyTree.Model as ListStore;

            DeleteEvent                     += Window_DeleteEvent;
            _packageChooser.FileSet         += PackageChooser_LoadFile;
            _packageSaveButton.Clicked      += PackageSaveButton_Clicked;
            _packageCookButton.Clicked      += PackageCookButton_Clicked;
            _packageSaver.FileActivated     += PackageSaver_SaveFile;
            _aboutTrigger.Activated         += AboutTrigger_Activated;
            _templatePopoverTrigger.Clicked += TemplatePopoverTrigger_Clicked;

            _actorTree   = DefaultActorListFactory.New();
            _gtkRenderer = new GtkRenderer(_drawingArea);
            _hydra       = new HotSwappableHydraEngine(_actorTree, _gtkRenderer);
            _gtkRenderer.LinkTo(_hydra);
            _rendererLayer = new EditorLayer(_drawingArea, _renderStats);
            _gtkRenderer.RegisterRenderLayer(_rendererLayer);
            UpdateHierarchy();
        }
Exemplo n.º 3
0
        public static ActorTree New()
        {
            var tree       = new ActorTree();
            var background = new ASquare(Vector2D.Zero, new Vector2D(256, 256), new Color3(0x000004));
            var text       = new AText(Vector2D.Zero, "12:00", Color3.White);

            tree.AddActor(background);
            tree.AddActor(text);
            return(tree);
        }
Exemplo n.º 4
0
 private void PackageChooser_LoadFile(object sender, EventArgs e)
 {
     using var file = File.OpenRead(_packageChooser.Filename);
     _loadedPackage = new Package(file);
     if (_loadedPackage.Header.Version < PackageVersion.RevisedActorTrees)
     {
         _actorTree = new ActorTree(_loadedPackage);
     }
     _hydra.SwapActorTree(_actorTree);
     _gtkRenderer.LinkTo(_hydra);
     UpdateHierarchy();
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            var assembly    = typeof(Program).Assembly;
            var fileVersion = assembly.GetCustomAttribute <AssemblyFileVersionAttribute>();

#if DEBUG
            var buildType = "Debug";
#else
            var buildType = "Release";
#endif
            Console.WriteLine($"OpenPackage (HydraEd {fileVersion.Version}/{buildType})");

            if (args.Length == 0)
            {
                Console.WriteLine("Error: Run this tool again with the file path specified.");
                return;
            }
            var filename = string.Join(' ', args);
            using var file = File.OpenRead(filename);
            var package = new Package(file);

            Application.Init();

            var app = new Application("com.alex.hydra.devtool", GLib.ApplicationFlags.None);
            app.Register(GLib.Cancellable.Current);

            var win         = new Window(WindowType.Toplevel);
            var drawingArea = new DrawingArea();
            win.SetSizeRequest(256, 256);
            drawingArea.SetSizeRequest(256, 256);

            var actorTree   = new ActorTree(package);
            var gtkRenderer = new GtkRenderer(drawingArea);
            var hydra       = new HydraEngine(actorTree, gtkRenderer);
            gtkRenderer.LinkTo(hydra);
            win.DeleteEvent += (object sender, DeleteEventArgs args) => { Application.Quit(); };

            win.Child = drawingArea;
            app.AddWindow(win);
            win.ShowAll();
            drawingArea.QueueDraw();

            Application.Run();
        }
Exemplo n.º 6
0
        public override void RenderActors(ActorTree actors)
        {
            foreach (var layer in RenderLayers)
            {
                layer.BeforeActorsRender(_context);
            }

            for (var index = 0; index < actors.ActorCount(); index++)
            {
                actors.GetActor(index).OnRender(_context);
            }

            foreach (var layer in RenderLayers)
            {
                layer.AfterActorsRender(_context);
            }

            _context.DisposeOfGtkContext();
        }
Exemplo n.º 7
0
 public HierarchyOutline(ActorTree actorTree) : base()
 {
     _actorTree     = actorTree;
     HeadersVisible = true;
 }
Exemplo n.º 8
0
 public HotSwappableHydraEngine(ActorTree actors, IRenderer renderer) : base(actors, renderer)
 {
 }
Exemplo n.º 9
0
 public void SwapActorTree(ActorTree actors)
 {
     Actors = actors;
     Scheduler.RemoveAllListeners();
     Scheduler.RegisterUpdateListener(this);
 }
Exemplo n.º 10
0
 public virtual void RenderActors(ActorTree actors)
 {
 }