44 Replies
It's to generate Javascript code for Minecraft. In-game, you can make an "Action Form" (what I call Pages) and you can add a title, body, and [buttons]. I want to make a GUI to generate this code easily. I want just 2 options for the buttons in this GUI; either text output, which is basically an empty action that is easily replaceable. The other action is redirecting to another page, with other buttons and everything else.
I've tried it before but hopefully I can get a little advice for this one.
I'd like to know the best methods for making the page a button lists, so they can be added, edited, and deleted without issues.
This one's old but is partial inspiration
So your goal is to generate the code shown on that image, with the GUI app shown on the left?
Correct
Sure, that doesnt't seem too hard.
everything except the buttons is trivial, so I assume thats where you want help
Currently I just have the reference image as I just want to know if there's specific tricks or advice for the different, more difficult tasks, before I start and make it harder on myself later.
no this seems pretty straight forward to me
having button index be editable might make it harder thou
I'd rather recommend having a draggable list if you want to be able to re-order them
I think that's a good idea, but the indices are important
well yes, but they can be generated from the buttons order
true.
my first instict was to just have the form state keep track of what the "next id" should be and run with that
but then you can't edit them or re-order
so a better choice might be to calculate the IDs when the "save" or "generate" button is clicked
I would like to eventually have it generate on certain actions like when the page and/or buttons are saved, but the refresh button can be renamed to "Generate" for the time being
or just have any GUI action invoke the refresh
thats fine too, if you want the code preview
So I am trying to plan out the different objects and stuff to use for the UI
I'm guessing a normal ListBox or something similar for the pages, as they're not important in any order
WPF? Avalonia? Winforms?
WPF
If there's a better alternative that you prefer, I'm fine to look into it
Avalonia is very similar but would let you also run this program on mac and linux
WPF is windows only
I plan to only use it myself
on windows
alright, then WPF is a solid choice
I am looking for the behavior to work, hopefully to 100%. I would like for the visuals to represent or match what I had made in photoshop, but I'm not sure if I would want to edit them myself or find a framework
or whatever it's called with custom shaped controls and stuff
WPF allows a lot of styling
I am expecting to just do it manually
yeah you'll need to apply styles to the controls, but I think there is a way to do it "once" for the entire app
per control, probably
but still
I can highly recommend SingletonSean on youtube for WPF stuff
Definitely have seen some of his videos in the past
I'll try and figure out what I need to do for each part of my UI and try to look for it in his, or other channels
What would be a good way to save the data in the pages, and even the buttons, in the lists?
wdym?
you'd just put that in your viewmodel
I'd make a custom class that represents an added button, and properties for the other fields (title, desc)
I'd previously used this class
Seems fine. Your button would need to store the data for its "action" too
other than that, I don't see any issues
So should I try and make the challenge of having the button indices be changeable, or just generate an index based on when it was created?
I'd generate index based on their position in the list
if you want to support re-ordering, its probably not a huge issue
In my old version, I wanted to make a button, or 3 or 4, and if one was deleted, it would find the LowestMissingNumber and use that index
see, thats done for you if you just use the list index
the lowestmissingnumber?
ye
Should I do 2 columns, then divide those columns with another grid?
for the page list and the main section as 2 columns, then the main section can be a grid
Either that, or you split it up further
I'm not an expert on WPF, but if this was javascript, I'd make a component for the "page view" and its state, and create one of those for each "page" in your list
it sounds reasoable to do the same here
I'm just gonna find one of those SimpletonSean vids on viewmodels and stuff
meaning you'd make a "control" for this part
and you'd databind the state to a viewmodel
one model for each "page"
in your pagelist
yep
coming back from not doing .net for a while really hurts
but I'll try
Ah, I see Klarth already recommend the exact same approach in #gui
Using a
DataTemplate
seems like a solid optionSingleton Sean
I missed that typo lol.
Figured it out but didn't bother changing it. Thanks
More for other people who might look up Sean tbh