https://linen.dev logo
Join Discord
Powered by
# haxe-ui
  • b

    bright-gpu-74537

    01/25/2023, 9:04 PM
    maybe you guys can all help each other... exciting more people writing backends... i was sure it would only ever be a "me thing"... now everyones at it 😄
  • m

    melodic-advantage-23638

    01/25/2023, 9:07 PM
    Maybe 🙂
  • m

    melodic-advantage-23638

    01/25/2023, 9:08 PM
    @elegant-twilight-61392 the most important thing to do is get one of the existing backends running that you're going to look at and put breakpoints in to help you understand what is calling what
  • m

    melodic-advantage-23638

    01/25/2023, 9:11 PM
    I had an "aha" moment the other day when I was trying to figure out how it all fit together... was in ComponentImpl onAdd function in the heaps backend, where it checks if the parentComponent is null and if so adds it Screen.instance.addComponent
  • m

    melodic-advantage-23638

    01/25/2023, 9:12 PM
    In the openfl version (I just checked) it's onAddedToStage
  • m

    melodic-advantage-23638

    01/25/2023, 9:15 PM
    That might not sound like it makes any sense yet, but openfl needs to have these things added to its list of things to render, and so the root components (which in openfl inherit from Sprite) need to be added to the stage
  • m

    melodic-advantage-23638

    01/25/2023, 9:16 PM
    In heaps it gets added to the h2d scene, and in my backend I'm creating a new UIManager so it'll end up adding it to that
  • m

    melodic-advantage-23638

    01/25/2023, 9:21 PM
    The other thing to take a look at is whether Godot will let you set up a clipping rectangle for its sprite like openfl does (scrollRect)
  • m

    melodic-advantage-23638

    01/25/2023, 9:22 PM
    As I believe this is how each component is masked to only render inside its parent's borders
  • a

    ambitious-knife-25690

    01/25/2023, 9:32 PM
    ask questions here if you get a stuck
  • a

    ambitious-knife-25690

    01/25/2023, 9:34 PM
    also I git cloned pretty much all of the main backends into a local haxelib folder next to my backend so I could easily command pallete to all the different implementations
  • a

    ambitious-knife-25690

    01/25/2023, 9:35 PM
    they all have unique ways of doing things so one of them may have the 'right way' for your backend as opposed to just one of them having all of the solutions
  • e

    elegant-twilight-61392

    01/25/2023, 9:36 PM
    damn, i cant make the
    ComponentSurface
    just a typedef for godots
    Control
    node â˜šī¸
  • e

    elegant-twilight-61392

    01/25/2023, 9:36 PM
    the ComponentCommon that extends ComponentSurface adds a _ready var, but _ready is godots on ready function basically
  • b

    bright-gpu-74537

    01/25/2023, 9:38 PM
    billy had the same problems... you'll have to use composition for now... renaming an internal var like
    _ready
    =>
    _componentReady
    isnt such a big deal
  • e

    elegant-twilight-61392

    01/25/2023, 9:40 PM
    Copy code
    hx
    class ComponentSurface {
       public var node:Node;
    
       public function new() {
          this.node = new Control();
       }
    }
    should work too, right?
  • b

    bright-gpu-74537

    01/25/2023, 9:40 PM
    yeah, should be fine...
  • a

    ambitious-knife-25690

    01/25/2023, 9:41 PM
    tbh the inheritance ain't that awkward
  • a

    ambitious-knife-25690

    01/25/2023, 9:41 PM
    gives a good excuse for some conveniences
  • e

    elegant-twilight-61392

    01/25/2023, 9:42 PM
    it would probably help if i made
    Node
    be
    CanvasItem
    instead because while all `Node2D`s and `Control`s are `CanvasItem`s, `Node3D`s are not canvas items lol
  • e

    elegant-twilight-61392

    01/25/2023, 9:43 PM
    but i have to use either
    Control
    or
    Node2D
    because you cant directly instance a
    CanvasItem
    , at least in the editor
  • a

    ambitious-knife-25690

    01/25/2023, 9:43 PM
    you want to have a unifying base type
  • e

    elegant-twilight-61392

    01/25/2023, 9:44 PM
    CanvasItem
    has all the relevant drawing methods
  • e

    elegant-twilight-61392

    01/25/2023, 9:44 PM
    so it doesnt matter if its actually an instance of
    Node2D
    or
    Control
    or really anything else that extends either of those
  • e

    elegant-twilight-61392

    01/25/2023, 9:45 PM
    pretty sure like 70% of the nodes you can create in the editor are based on
    CanvasItem
  • e

    elegant-twilight-61392

    01/25/2023, 10:25 PM
    so i need the user to pass an instance of the
    ToolkitOptions
    object (containing the root godot node to add things to), but is there a way to throw an error if they dont?
  • m

    melodic-advantage-23638

    01/25/2023, 10:28 PM
    I've only seen trace messages but I guess you could just throw an error.
  • m

    melodic-advantage-23638

    01/25/2023, 10:28 PM
    trace("WARNING: trying to add a component to a null root. Either set Screen.instance.root or specify one in Toolkit.init");
  • e

    elegant-twilight-61392

    01/25/2023, 10:29 PM
    yeah, but like where would i check this? HaxeUIApp extends AppImpl so i cant do it in the constructor
  • m

    melodic-advantage-23638

    01/25/2023, 10:30 PM
    That one is in ScreenImpl
1...140914101411...1687Latest