improve: editor UI - blue panel borders, brighter colors, click selection

This commit is contained in:
shuiyu1123 committed 2026-07-11 01:49:53 +08:00
1 parent 258f63fcee
commit c4815c3c69
1 file changed
+45 -32
+45 -32
View File
@@ -230,60 +230,73 @@ static void on_render(Engine* engine) {
ID3D11DeviceContext* ctx = g_dev->context;
float sw = (float)g_dev->width, sh = (float)g_dev->height;
graphics_device_clear(g_dev, 0.10f, 0.10f, 0.12f, 1.0f);
graphics_device_clear(g_dev, 0.18f, 0.18f, 0.22f, 1.0f);
setup_2d(ctx, sw, sh);
float mh = 28, th = 28, ch = 180, pw = 220, sh2 = 22;
draw_quad(ctx, 0, 0, sw, mh, 0.20f, 0.22f, 0.35f, 1.0f);
draw_quad(ctx, 0, mh, sw, th, 0.17f, 0.18f, 0.28f, 1.0f);
draw_quad(ctx, 0, mh+th, pw, sh-mh-th-ch-sh2, 0.15f, 0.15f, 0.22f, 1.0f);
draw_quad(ctx, pw, mh+th, sw-2*pw, sh-mh-th-ch-sh2, 0.10f, 0.10f, 0.14f, 1.0f);
draw_quad(ctx, sw-pw, mh+th, pw, sh-mh-th-ch-sh2, 0.15f, 0.15f, 0.22f, 1.0f);
draw_quad(ctx, 0, sh-ch-sh2, sw, ch, 0.12f, 0.12f, 0.18f, 1.0f);
draw_quad(ctx, 0, sh-sh2, sw, sh2, 0.18f, 0.18f, 0.28f, 1.0f);
float mh = 30, th = 30, ch = 180, pw = 240, sbh = 24;
draw_quad(ctx, 0, 0, sw, 2, 0.30f, 0.40f, 0.80f, 1.0f);
draw_quad(ctx, 0, 0, sw, mh, 0.15f, 0.15f, 0.22f, 1.0f);
draw_quad(ctx, 0, mh, sw, 1, 0.35f, 0.45f, 0.75f, 1.0f);
draw_text(ctx, L"lity3d Editor", 10, 6, 0.7f, 0.85f, 1.0f, 1.0f);
draw_quad(ctx, 0, mh+1, sw, th, 0.22f, 0.22f, 0.30f, 1.0f);
draw_quad(ctx, 0, mh+th+1, sw, 1, 0.30f, 0.30f, 0.40f, 1.0f);
float body_h = sh - mh - th - ch - sbh - 2;
draw_quad(ctx, 0, mh+th+2, pw, body_h, 0.22f, 0.22f, 0.28f, 1.0f);
draw_quad(ctx, pw, mh+th+2, 1, body_h, 0.35f, 0.45f, 0.75f, 1.0f);
draw_quad(ctx, pw+1, mh+th+2, sw-pw*2-2, body_h, 0.16f, 0.16f, 0.20f, 1.0f);
draw_quad(ctx, sw-pw-1, mh+th+2, 1, body_h, 0.35f, 0.45f, 0.75f, 1.0f);
draw_quad(ctx, sw-pw, mh+th+2, pw, body_h, 0.22f, 0.22f, 0.28f, 1.0f);
draw_quad(ctx, 0, sh-ch-sbh, sw, 1, 0.35f, 0.45f, 0.75f, 1.0f);
draw_quad(ctx, 0, sh-ch-sbh+1, sw, ch, 0.19f, 0.19f, 0.25f, 1.0f);
draw_quad(ctx, 0, sh-sbh, sw, 1, 0.35f, 0.45f, 0.75f, 1.0f);
draw_quad(ctx, 0, sh-sbh+1, sw, sbh, 0.20f, 0.22f, 0.32f, 1.0f);
draw_text(ctx, L"lity3d Editor", 12, 7, 0.6f, 0.8f, 1.0f, 1.0f);
const wchar_t* menus[] = {L"\u6587\u4ef6", L"\u7f16\u8f91", L"\u89c6\u56fe", L"\u6784\u5efa", L"\u5e2e\u52a9"};
int mx = 120;
for (int i = 0; i < 5; i++) { draw_text(ctx, menus[i], mx, 8, 0.9f, 0.9f, 0.92f, 1.0f); mx += 70; }
draw_text(ctx, L"\u573a\u666f", 10, 36, 0.9f, 0.9f, 0.92f, 1.0f);
draw_text(ctx, L"\u89c6\u53e3", (int)(pw+10), 36, 0.9f, 0.9f, 0.92f, 1.0f);
draw_text(ctx, L"\u5c5e\u6027", (int)(sw-pw+10), 36, 0.9f, 0.9f, 0.92f, 1.0f);
draw_text(ctx, L"\u63a7\u5236\u53f0", 10, (int)(sh-ch-sh2+6), 0.9f, 0.9f, 0.92f, 1.0f);
int mx = 130;
for (int i = 0; i < 5; i++) { draw_text(ctx, menus[i], mx, 8, 0.9f, 0.9f, 0.92f, 1.0f); mx += 80; }
draw_text(ctx, L"\u573a\u666f", 12, (int)(mh+th+8), 0.5f, 0.7f, 1.0f, 1.0f);
draw_text(ctx, L"\u89c6\u53e3", (int)(pw+16), (int)(mh+th+8), 0.5f, 0.7f, 1.0f, 1.0f);
draw_text(ctx, L"\u5c5e\u6027", (int)(sw-pw+12), (int)(mh+th+8), 0.5f, 0.7f, 1.0f, 1.0f);
draw_text(ctx, L"\u63a7\u5236\u53f0", 12, (int)(sh-ch-sbh+8), 0.5f, 0.7f, 1.0f, 1.0f);
for (int i = 0; i < g_entity_count; i++) {
float ey = 60 + i * 22;
if (i == g_selected) draw_quad(ctx, 4, ey-2, pw-8, 20, 0.25f, 0.30f, 0.50f, 1.0f);
float ey = mh + th + 30 + i * 24;
if (i == g_selected)
draw_quad(ctx, 4, ey - 2, pw - 8, 22, 0.25f, 0.35f, 0.60f, 1.0f);
wchar_t wn[64]; int len = (int)strlen(g_entities[i].name);
for (int j = 0; j < len && j < 63; j++) wn[j] = (wchar_t)g_entities[i].name[j];
wn[len] = 0;
draw_text(ctx, wn, 28, (int)ey, 0.85f, 0.85f, 0.88f, 1.0f);
for (int j = 0; j < len && j < 63; j++) wn[j] = (wchar_t)g_entities[i].name[j]; wn[len] = 0;
draw_text(ctx, wn, 16, (int)ey, (i == g_selected) ? 1.0f : 0.85f, (i == g_selected) ? 1.0f : 0.85f, (i == g_selected) ? 1.0f : 0.88f, 1.0f);
}
if (g_selected >= 0 && g_selected < g_entity_count) {
SceneEntity* e = &g_entities[g_selected]; int ix = (int)(sw-pw+10), iy = 60;
draw_text(ctx, L"\u540d\u79f0:", ix, iy, 0.6f, 0.7f, 0.9f, 1.0f);
SceneEntity* e = &g_entities[g_selected]; int ix = (int)(sw-pw+12), iy = (int)(mh+th+32);
draw_text(ctx, L"\u540d\u79f0:", ix, iy, 0.5f, 0.7f, 1.0f, 1.0f);
wchar_t wn[64]; int len = (int)strlen(e->name);
for (int j = 0; j < len && j < 63; j++) wn[j] = (wchar_t)e->name[j]; wn[len] = 0;
draw_text(ctx, wn, ix+40, iy, 0.9f, 0.9f, 0.92f, 1.0f);
iy += 22;
draw_text(ctx, L"\u53ef\u89c1: \u2611", ix, iy, 0.9f, 0.9f, 0.92f, 1.0f);
draw_text(ctx, wn, ix + 48, iy, 1.0f, 1.0f, 1.0f, 1.0f);
iy += 26;
draw_text(ctx, L"\u53ef\u89c1: \u2611", ix, iy, 0.85f, 0.85f, 0.88f, 1.0f);
}
int cy = (int)(sh-ch-sh2+24);
for (int i = g_console_count-1; i >= 0 && i >= g_console_count-6; i--) {
int cy = (int)(sh - ch - sbh + 28);
for (int i = g_console_count - 1; i >= 0 && i >= g_console_count - 6; i--) {
wchar_t wl[256]; int len = (int)strlen(g_console_lines[i]);
for (int j = 0; j < len && j < 255; j++) wl[j] = (wchar_t)g_console_lines[i][j];
wl[len] = 0; draw_text(ctx, wl, 10, cy, 0.65f, 0.65f, 0.7f, 1.0f); cy += 18;
wl[len] = 0; draw_text(ctx, wl, 12, cy, 0.7f, 0.7f, 0.75f, 1.0f); cy += 20;
}
char status[256];
snprintf(status, sizeof(status), "%s | %d entities | Ctrl+S save .ly | Esc quit", g_file_path, g_entity_count);
snprintf(status, sizeof(status), "%s | %d entities | Ctrl+S save | Ctrl+O load | Esc quit", g_file_path, g_entity_count);
wchar_t ws[256]; int sl = (int)strlen(status);
for (int j = 0; j < sl && j < 255; j++) ws[j] = (wchar_t)status[j]; ws[sl] = 0;
draw_text(ctx, ws, 10, (int)(sh-18), 0.5f, 0.5f, 0.55f, 1.0f);
draw_text(ctx, ws, 12, (int)(sh - 20), 0.6f, 0.6f, 0.65f, 1.0f);
graphics_device_present(g_dev);
}