more microui

This commit is contained in:
2026-03-25 17:48:46 +05:45
parent 5bc235f1ab
commit 00ae6cbc4e
5 changed files with 239 additions and 42 deletions
+83 -13
View File
@@ -27,6 +27,7 @@ import "core:fmt"
By doing comparasion on def
*/
/*
interface_body_def_editor :: proc(def: ^engine_entity_def)
{
if im.BeginCombo("Body Type", fmt.ctprint(def.body_def.type))
@@ -59,14 +60,58 @@ interface_body_def_editor :: proc(def: ^engine_entity_def)
def.body_def.name = cstring(&def.name_buf[0])
}
}
*/
mu_interface_body_def_editor :: proc(interface: ^interface_state, def : ^engine_entity_def)
{
ctx := &interface.state.mu_ctx
if .ACTIVE in mu.begin_treenode(ctx, "Body Type")
{
for type in b2.BodyType
{
state := def.body_def.type == type
if .CHANGE in mu.checkbox(ctx, fmt.tprint(type), &state)
{
def.body_def.type = type
}
}
mu.end_treenode(ctx)
}
mu.label(ctx, "Position")
mu.slider(ctx, &def.body_def.position[0], -50, 50)
mu.slider(ctx, &def.body_def.position[1], -50, 50)
angle := draw.RAD2DEG * b2.Rot_GetAngle(def.body_def.rotation)
mu.label(ctx, "Rotation")
if .CHANGE in mu.slider(ctx, &angle, 0, 359)
{
def.body_def.rotation = b2.MakeRot(draw.DEG2RAD * angle)
}
mu.label(ctx, "Linear Velocity")
mu.slider(ctx, &def.body_def.linearVelocity[0], 0, 500)
mu.slider(ctx, &def.body_def.linearVelocity[1], 0, 500)
mu.label(ctx, "Angular Velocity")
mu.slider(ctx, &def.body_def.angularVelocity, 0, 500)
mu.label(ctx, "Linear Damping")
mu.slider(ctx, &def.body_def.linearDamping, 0, 500)
mu.label(ctx, "Angular Damping")
mu.slider(ctx, &def.body_def.angularDamping, 0, 500)
mu.label(ctx, "Gravity Scale")
mu.slider(ctx, &def.body_def.gravityScale, 0, 100)
mu.checkbox(ctx, "Fixed rotation", &def.body_def.fixedRotation)
}
interface_edit_static_index :: proc(interface:^interface_state, def: ^engine_entity_def) -> bool
{
curr_index := &interface.curr_static_index
entity := interface.entities[interface.selected_entity]
level := interface.world
entity := interface.entities[interface.selected_entity]
level := interface.world
if level.relations[entity.index] == nil
@@ -123,6 +168,26 @@ interface_edit_static_index :: proc(interface:^interface_state, def: ^engine_ent
return false
}
mu_interface_edit_static_index :: proc(interface: ^interface_state, def : ^engine_entity_def) -> bool
{
curr_index := &interface.curr_static_index
entity := interface.entities[interface.selected_entity]
level := interface.world
ctx := &interface.state.mu_ctx
if level.relations[entity.index] == nil
{
level.relations[entity.index] = {}
}
indexes := &level.relations[entity.index]
//if mu.slider()
}
mu_interface_shape_def_editor :: proc(
state : ^engine_state,
def : ^engine_entity_def) -> bool
@@ -210,6 +275,7 @@ mu_interface_shape_def_editor :: proc(
}
/*
interface_shape_def_editor :: proc(def: ^engine_entity_def) -> bool
{
shape_def := &def.shape_def
@@ -300,6 +366,7 @@ interface_shape_def_editor :: proc(def: ^engine_entity_def) -> bool
}
return false
}
*/
interface_entity :: proc(interface: ^interface_state) -> bool
{
@@ -322,20 +389,23 @@ interface_entity :: proc(interface: ^interface_state) -> bool
im.Separator()
if im.CollapsingHeader("Shape Edit")
if .ACTIVE in mu.begin_treenode(&interface.state.mu_ctx, "Body Def")
{
//interface_shape_def_editor(def)
mu_interface_body_def_editor(interface, def)
mu.end_treenode(&interface.state.mu_ctx)
}
if .ACTIVE in mu.begin_treenode(&interface.state.mu_ctx, "Shape Def")
{
mu_interface_shape_def_editor(interface.state, def)
mu.end_treenode(&interface.state.mu_ctx)
}
mu_interface_shape_def_editor(interface.state, def)
im.Separator()
if im.CollapsingHeader("Body Edit")
{
interface_body_def_editor(def)
}
if im.CollapsingHeader("Static Index")
if .ACTIVE in mu.begin_treenode(&interface.state.mu_ctx, "Static Index")
{
ret |= interface_edit_static_index(interface, def)
}