Hi Judah. Love your videos covering Jai. I have a question. Does variable tagging support holding values and can that tag be read during runtime? E.g. for displaying a property UI panel based on the selected context. How would you tag a specific float with a Clamp tag that would have a min and max, so the panel knows how to render the UI for that specific property
Thanks! I appreciate the support! And it depends on what you mean by holding a value. For instance, the value can't be something known at runtime because it's just a constant string put on the declaration. However, you can read them at runtime if you have runtime type information enabled (which it is by default). Your example could definitely work like this: UI_Panel :: struct { parent: *UI_Panel; min: float32; @Clamp(0, parent.min) max: float32; @Clamp(parent.max) } ui_panel_update :: (panel: *UI_Panel) { info := cast(*Type_Info_Struct)type_info(UI_Panel); // if you don't like this style, you could also auto-generate this code with #insert #run for info.members if it.notes.count > 0 { for note: it.notes if starts_with(note, "@Clamp") { // now we know we're looking at the Clamp note of a struct member, // so we can parse the string and do whatever with it. // for example, seeing 'parent.min' in the string, then using its value at runtime
it's not exactly an LSP, but there's a sublime plugin called JaiTools which has syntax highlighting and goto definition; then I just have a sublime project that points to the install directory!
Apologies for the audio cut-outs. My microphone's gain was much lower than it usually is and I forgot to adjust it.
excellent video, shame it has audio problem. maybe it is time for a new microphone 🎤
Thanks! And it was mostly related to incompetence haha. I forgot to turn up my mic/adjust my noise gate in OBS…
man, I love your videos, I learned a lot from them.
Please make more Jai videos. ❤
damn man, I really want that jai
same, since 2016 TT_TT
mic keeps cutting out 😢
Hi Judah. Love your videos covering Jai.
I have a question. Does variable tagging support holding values and can that tag be read during runtime?
E.g. for displaying a property UI panel based on the selected context. How would you tag a specific float with a Clamp tag that would have a min and max, so the panel knows how to render the UI for that specific property
Thanks! I appreciate the support!
And it depends on what you mean by holding a value. For instance, the value can't be something known at runtime because it's just a constant string put on the declaration. However, you can read them at runtime if you have runtime type information enabled (which it is by default).
Your example could definitely work like this:
UI_Panel :: struct {
parent: *UI_Panel;
min: float32; @Clamp(0, parent.min)
max: float32; @Clamp(parent.max)
}
ui_panel_update :: (panel: *UI_Panel) {
info := cast(*Type_Info_Struct)type_info(UI_Panel);
// if you don't like this style, you could also auto-generate this code with #insert #run
for info.members if it.notes.count > 0 {
for note: it.notes if starts_with(note, "@Clamp") {
// now we know we're looking at the Clamp note of a struct member,
// so we can parse the string and do whatever with it.
// for example, seeing 'parent.min' in the string, then using its value at runtime
// ...
if use_parent_min {
panel.min = clamp(0, parent.min);
}
}
}
}
@@JudahCaruso Thank you for the detailed reply. It answered my questions :)
great stuff! do you have a jai LSP for Sublime or something like that here?
it's not exactly an LSP, but there's a sublime plugin called JaiTools which has syntax highlighting and goto definition; then I just have a sublime project that points to the install directory!