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

    famous-alarm-22563

    11/29/2022, 9:22 PM
    Like the player dying
  • b

    bright-gpu-74537

    11/29/2022, 9:22 PM
    im just heading off, but you'll have to knock up a sample of what you mean... im guessing you can do it in xml, but you can certainly do it in "normal" haxe
  • f

    famous-alarm-22563

    11/29/2022, 9:24 PM
    Alright... Say I have this template:
    Copy code
    <label ttext="alive"></label>
    how do I change the text from the Player class when the player dies.
  • b

    bright-gpu-74537

    11/29/2022, 9:25 PM
    im not 100% sure im following, but if i am, i would give it an id and use something like
    myPlayerUI.aliveLabel.text = ...
  • b

    bright-gpu-74537

    11/29/2022, 9:26 PM
    how are you building this "" UI?
  • f

    famous-alarm-22563

    11/29/2022, 9:26 PM
    That works... I was hoping that a better way existed thanks for taking the time to clear things up 🙂
  • b

    bright-gpu-74537

    11/29/2022, 9:27 PM
    if you are using the @:build macro you can use binding
  • b

    bright-gpu-74537

    11/29/2022, 9:27 PM
    but i dont know if you are or not
  • b

    bright-gpu-74537

    11/29/2022, 9:27 PM
    ... ill knock up an example real quick anyway... two secs
  • f

    famous-alarm-22563

    11/29/2022, 9:28 PM
    Thanks for pointing that out.. I'll explore the code for that macro and see if its what I want
  • f

    famous-alarm-22563

    11/29/2022, 9:28 PM
    :>
  • b

    bright-gpu-74537

    11/29/2022, 9:34 PM
    http://haxeui.org/builder/?72fb7f48
  • b

    bright-gpu-74537

    11/29/2022, 9:34 PM
    the "interesting" part here being:
    Copy code
    @:xml('
        <vbox>
            <switch id="playerAliveSwitch" />
        </vbox>
    ')
    class MyPlayerUI extends VBox {
        @:bind(playerAliveSwitch.value) public var isAlive:Bool;
    }
  • b

    bright-gpu-74537

    11/29/2022, 9:35 PM
    ie, "isAlive" is bound to "playerAliveSwitch.value", so you can just access it externally as if you were doing "player1.playerAliveSwitch.value"
  • b

    bright-gpu-74537

    11/29/2022, 9:36 PM
    (again, not totally sure if thats what you are asking for 🙂 )
  • e

    elegant-twilight-61392

    11/29/2022, 11:56 PM
    i think they might want something like
    <label value="Whatever.alive" ifTrue="alive" ifFalse="dead">
    and then it automatically changes the text based on the value of
    Whatever.alive
  • e

    elegant-twilight-61392

    11/29/2022, 11:57 PM
    which doesnt seem like something haxeui would do itself, but that effect is certainly possible
  • a

    ambitious-knife-25690

    11/30/2022, 12:02 AM
    yeah, you would need some kind of way that links the two parts
  • a

    ambitious-knife-25690

    11/30/2022, 12:02 AM
    i'm working on this myself, my immediate thought is event system (I'm using an ecs base)
  • a

    ambitious-knife-25690

    11/30/2022, 12:03 AM
    haven't gotten to mixing the ui and composite, just yet, but i've been idly thinking about it as i build up my framework base
  • a

    ambitious-knife-25690

    11/30/2022, 12:03 AM
    at least, i think an event system would have the "easiest" use, but I may think otherwise when i actually start working on that stuff
  • h

    hallowed-ocean-84954

    11/30/2022, 12:05 AM
    you can write functions in blocks in XML and call them from onchange attrs if you want and that can make component states rely on one another - but you can also do it from Haxe - but they suit different use cases
  • h

    hallowed-ocean-84954

    11/30/2022, 3:18 AM
    I got a compilation error due to incorrect assignment in a function in a script which is in itself fine. But the error was hard to track down because of where it was flagged. It was in completely the wrong place. In ui.xml I have this in a function:
    Copy code
    // Scene
                                rubiks = true;
    Now rubiks is an optionbox and I meant to assign rubiks.selected = true. In my UI.hx file the error was reported several lines away from the field which was binding to this field:
    Copy code
    @:bind(diffuse.value)         <-------------------error flagged here
        public var diffuseColor(default, null):Color;
    
        @:bind(specular.value)
        public var specularColor(default, null):Color;
    
        @:bind(shininess.pos)
        public var specularShininess(default, null):Float = 5;
    
        // Scene properties
        @:bind(rubiks.selected)
        public var sceneRubiks(default, null):Bool;   <----- Bool bound here
    error: Source/UI.hx:56: characters 3-16 : Bool should be haxe.ui.components.OptionBox
  • h

    hallowed-ocean-84954

    11/30/2022, 3:18 AM
    so the error was correct but it was on the wrong line.
  • b

    bright-gpu-74537

    11/30/2022, 6:52 AM
    ill check it out...
  • r

    refined-cat-44047

    11/30/2022, 7:12 AM
    I updated HaxeUI (and Flixel) for the first time in a while, and it looks like this has regressed, and the example does not work for me anymore https://discord.com/channels/162395145352904705/565569107701923852/1022798863909785640
  • b

    bright-gpu-74537

    11/30/2022, 7:44 AM
    hmmmm, weird... can you knock up a sample? Or post your app? Ill check it out at some point later
  • r

    refined-cat-44047

    11/30/2022, 8:09 AM
    oh cool. It is actually the same zip from the post above the one I linked https://discord.com/channels/162395145352904705/565569107701923852/1022795956565061632 That should work correctly, but then if you start the
    contentArea
    as hidden, by setting hidden to true in the
    main-view.xml
    , then it doesn't toggle with the button anymore
  • f

    future-iron-61487

    11/30/2022, 10:04 AM
    That would absolutely kill haxeui for games though
  • f

    future-iron-61487

    11/30/2022, 10:08 AM
    at least, full electron can't be embedded because of Javascript not being allowed (JIT forbidden) on some targets.
1...130913101311...1687Latest