This commit is contained in:
2024-12-31 00:37:45 +01:00
parent 6cf19a6f9b
commit 3465acd673
5 changed files with 66 additions and 53 deletions

View File

@@ -119,6 +119,7 @@ Editor :: struct {
last_right_mouse_click_time: float;
menu_position: Vector2;
hide_ui: bool;
icons : struct {
play: Texture_Handle;

View File

@@ -121,21 +121,19 @@ editor_ui :: () {
entity := engine.editor.selected_entities[0];
//ui_slider(*slider_value, 0.0, 1.0);
ui_textfield("Name", *entity.name);
ui_label(tprint("Id: %", entity.id));
updated := ui_vector_field("Position", *entity.transform.position);
euler_rotation := quaternion_to_euler_v3(entity.transform.orientation);
euler_rotation *= RADIANS_TO_DEGREES;
updated |= ui_vector_field("Rotation", *euler_rotation);
euler_rotation *= DEGREES_TO_RADIANS;
entity.transform.orientation = euler_to_quaternion(euler_rotation);
updated |= ui_vector_field("Scale", *entity.transform.scale);
//updated := ui_vector_field("Position", *entity.transform.position);
//euler_rotation := quaternion_to_euler_v3(entity.transform.orientation);
//euler_rotation *= RADIANS_TO_DEGREES;
//updated |= ui_vector_field("Rotation", *euler_rotation);
//euler_rotation *= DEGREES_TO_RADIANS;
//entity.transform.orientation = euler_to_quaternion(euler_rotation);
//updated |= ui_vector_field("Scale", *entity.transform.scale);
if updated {
update_matrix(*entity.transform);
}
//if updated {
// update_matrix(*entity.transform);
//}
entity_ui(entity);
}
@@ -148,7 +146,9 @@ text_fun : string;
slider_value : float = 0.0;
base_editor_update :: () {
editor_ui();
if !engine.editor.hide_ui {
editor_ui();
}
camera := *engine.editor.camera;
@@ -173,37 +173,39 @@ base_editor_update :: () {
}
}
}
if key_pressed(.CTRL) && key_down(.Z) {
undo();
}
if key_pressed(.CTRL) && key_down(.S) {
save_scene(engine.current_scene, "../assets/scenes/");
//show_message("Saved scene");
}
if key_down(.DELETE) || key_down(.BACKSPACE) {
for engine.editor.selected_entities {
mark_entity_deleted(it);
if !engine.editor.focused_widget {
if key_pressed(.CTRL) && key_down(.Z) {
undo();
}
engine.editor.transform_gizmo.selected_axis = .NONE;
engine.editor.selected_entities.count = 0;
}
if key_pressed(.CTRL) && key_down(.D) {
duplicated_entities: [..] *Entity;
duplicated_entities.allocator = temp;
for e: engine.editor.selected_entities {
array_add(*duplicated_entities, duplicate_entity(e));
if key_pressed(.CTRL) && key_down(.S) {
save_scene(engine.current_scene, "../assets/scenes/");
//show_message("Saved scene");
}
engine.editor.selected_entities.count = 0;
if key_down(.DELETE) || key_down(.BACKSPACE) {
for engine.editor.selected_entities {
mark_entity_deleted(it);
}
for e: duplicated_entities {
array_add(*engine.editor.selected_entities, e);
engine.editor.transform_gizmo.selected_axis = .NONE;
engine.editor.selected_entities.count = 0;
}
if key_pressed(.CTRL) && key_down(.D) {
duplicated_entities: [..] *Entity;
duplicated_entities.allocator = temp;
for e: engine.editor.selected_entities {
array_add(*duplicated_entities, duplicate_entity(e));
}
engine.editor.selected_entities.count = 0;
for e: duplicated_entities {
array_add(*engine.editor.selected_entities, e);
}
}
}
}
@@ -260,7 +262,7 @@ base_editor_update :: () {
engine.editor.menu_position.y = cast(float)engine.renderer.render_target_height - mouse_position.y;
}
if !key_pressed(.CTRL) {
if !engine.editor.focused_widget && !key_pressed(.CTRL) {
if key_down(.W) {
engine.editor.transform_gizmo.transform_type = .TRANSLATION;
}
@@ -278,6 +280,10 @@ base_editor_update :: () {
update_view_matrix(camera);
}
if key_pressed(.CTRL) && key_down(.U) {
engine.editor.hide_ui = !engine.editor.hide_ui;
}
if key_pressed(.CTRL) && key_down(.E) {
new_mode := ifx engine.mode == .EDITING then Engine_Mode.PLAYING else .EDITING;
switch_engine_mode(new_mode);