From c70e5e028eae2414d866cc5ce08b5f0abcc7d9a4 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 14 Jun 2025 15:21:28 +0900 Subject: [PATCH] Implement GoatGUIEngine.AddDrawRectToPartsConstructionProcess Used in Rance Quest. --- include/parts.h | 2 ++ src/hll/GUIEngine.c | 2 +- src/hll/GoatGUIEngine.c | 2 +- src/hll/PartsEngine.c | 2 +- src/parts/construction.c | 33 +++++++++++++++++++++++++++++++-- src/parts/debug.c | 5 +++++ src/parts/parts_internal.h | 1 + src/parts/save.c | 2 ++ 8 files changed, 44 insertions(+), 5 deletions(-) diff --git a/include/parts.h b/include/parts.h index 7916b2c..32ae1a9 100644 --- a/include/parts.h +++ b/include/parts.h @@ -125,6 +125,8 @@ bool PE_AddFillToPartsConstructionProcess(int parts_no, int x, int y, int w, int bool PE_AddFillAlphaColorToPartsConstructionProcess(int parts_no, int x, int y, int w, int h, int r, int g, int b, int a, int state); bool PE_AddFillAMapToPartsConstructionProcess(int parts_no, int x, int y, int w, int h, int a, int state); +bool PE_AddDrawRectToPartsConstructionProcess(int parts_no, int x, int y, int w, int h, + int r, int g, int b, int state); bool PE_AddDrawCutCGToPartsConstructionProcess(int parts_no, struct string *cg_name, int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh, int interp_type, int state); bool PE_AddCopyCutCGToPartsConstructionProcess(int parts_no, struct string *cg_name, diff --git a/src/hll/GUIEngine.c b/src/hll/GUIEngine.c index b16c6ff..7f01689 100644 --- a/src/hll/GUIEngine.c +++ b/src/hll/GUIEngine.c @@ -899,7 +899,7 @@ HLL_LIBRARY(GUIEngine, HLL_EXPORT(Parts_AddFillAMapToPartsConstructionProcess, PE_AddFillAMapToPartsConstructionProcess), HLL_TODO_EXPORT(Parts_AddFillWithAlphaToPartsConstructionProcess, GUIEngine_Parts_AddFillWithAlphaToPartsConstructionProcess), HLL_TODO_EXPORT(Parts_AddFillGradationHorizonToPartsConstructionProcess, GUIEngine_Parts_AddFillGradationHorizonToPartsConstructionProcess), - HLL_TODO_EXPORT(Parts_AddDrawRectToPartsConstructionProcess, GUIEngine_Parts_AddDrawRectToPartsConstructionProcess), + HLL_EXPORT(Parts_AddDrawRectToPartsConstructionProcess, PE_AddDrawRectToPartsConstructionProcess), HLL_EXPORT(Parts_AddDrawCutCGToPartsConstructionProcess, PE_AddDrawCutCGToPartsConstructionProcess), HLL_EXPORT(Parts_AddCopyCutCGToPartsConstructionProcess, PE_AddCopyCutCGToPartsConstructionProcess), HLL_TODO_EXPORT(Parts_AddGrayFilterToPartsConstructionProcess, GUIEngine_Parts_AddGrayFilterToPartsConstructionProcess), diff --git a/src/hll/GoatGUIEngine.c b/src/hll/GoatGUIEngine.c index c09f3b2..4846035 100644 --- a/src/hll/GoatGUIEngine.c +++ b/src/hll/GoatGUIEngine.c @@ -191,7 +191,7 @@ HLL_LIBRARY(GoatGUIEngine, HLL_EXPORT(AddFillAMapToPartsConstructionProcess, PE_AddFillAMapToPartsConstructionProcess), HLL_TODO_EXPORT(AddFillWithAlphaToPartsConstructionProcess, PE_AddFillWithAlphaToPartsConstructionProcess), HLL_TODO_EXPORT(AddFillGradationHorizonToPartsConstructionProcess, PE_AddFillGradationHorizonToPartsConstructionProcess), - HLL_TODO_EXPORT(AddDrawRectToPartsConstructionProcess, PE_AddDrawRectToPartsConstructionProcess), + HLL_EXPORT(AddDrawRectToPartsConstructionProcess, PE_AddDrawRectToPartsConstructionProcess), HLL_EXPORT(BuildPartsConstructionProcess, PE_BuildPartsConstructionProcess), HLL_EXPORT(AddDrawTextToPartsConstructionProcess, PE_AddDrawTextToPartsConstructionProcess)); diff --git a/src/hll/PartsEngine.c b/src/hll/PartsEngine.c index 2750721..b82fb88 100644 --- a/src/hll/PartsEngine.c +++ b/src/hll/PartsEngine.c @@ -131,7 +131,7 @@ HLL_LIBRARY(PartsEngine, HLL_EXPORT(AddFillAMapToPartsConstructionProcess, PE_AddFillAMapToPartsConstructionProcess), HLL_TODO_EXPORT(AddFillWithAlphaToPartsConstructionProcess, PartsEngine_AddFillWithAlphaToPartsConstructionProcess), HLL_TODO_EXPORT(AddFillGradationHorizonToPartsConstructionProcess, PartsEngine_AddFillGradationHorizonToPartsConstructionProcess), - HLL_TODO_EXPORT(AddDrawRectToPartsConstructionProcess, PartsEngine_AddDrawRectToPartsConstructionProcess), + HLL_EXPORT(AddDrawRectToPartsConstructionProcess, PE_AddDrawRectToPartsConstructionProcess), HLL_EXPORT(AddDrawCutCGToPartsConstructionProcess, PartsEngine_AddDrawCutCGToPartsConstructionProcess_old), HLL_EXPORT(AddCopyCutCGToPartsConstructionProcess, PartsEngine_AddCopyCutCGToPartsConstructionProcess_old), HLL_TODO_EXPORT(AddGrayFilterToPartsConstructionProcess, PartsEngine_AddGrayFilterToPartsConstructionProcess), diff --git a/src/parts/construction.c b/src/parts/construction.c index a05523c..de15d00 100644 --- a/src/parts/construction.c +++ b/src/parts/construction.c @@ -38,6 +38,7 @@ void parts_cp_op_free(struct parts_cp_op *op) case PARTS_CP_FILL: case PARTS_CP_FILL_ALPHA_COLOR: case PARTS_CP_FILL_AMAP: + case PARTS_CP_DRAW_RECT: case PARTS_CP_DRAW_CUT_CG: case PARTS_CP_COPY_CUT_CG: break; @@ -118,7 +119,6 @@ bool PE_AddFillToPartsConstructionProcess(int parts_no, int x, int y, int w, int parts_add_cp_op(cproc, op); return true; - } bool PE_AddFillAlphaColorToPartsConstructionProcess(int parts_no, int x, int y, int w, int h, int r, int g, int b, int a, int state) @@ -159,8 +159,24 @@ bool PE_AddFillWithAlphaToPartsConstructionProcess(int parts_no, int x, int y, i int r, int g, int b, int a, int state); bool PE_AddFillGradationHorizonToPartsConstructionProcess(int parts_no, int x, int y, int w, int h, int top_r, int top_g, int top_b, int bot_r, int bot_g, int bot_b, int state); + bool PE_AddDrawRectToPartsConstructionProcess(int parts_no, int x, int y, int w, int h, - int r, int g, int b, int state); + int r, int g, int b, int state) +{ + if (!parts_state_valid(--state)) + return false; + + struct parts_construction_process *cproc = get_cproc(parts_no, state); + struct parts_cp_op *op = xcalloc(1, sizeof(struct parts_cp_op)); + op->type = PARTS_CP_DRAW_RECT; + op->fill = (struct parts_cp_fill) { + .x = x, .y = y, .w = w, .h = h, + .r = r, .g = g, .b = b, .a = 255 + }; + + parts_add_cp_op(cproc, op); + return true; +} bool PE_AddDrawCutCGToPartsConstructionProcess(int parts_no, struct string *cg_name, int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh, int interp_type, int state) @@ -322,6 +338,16 @@ static void build_fill_amap(struct parts_construction_process *cproc, struct par gfx_fill_amap(&cproc->common.texture, op->x, op->y, op->w, op->h, op->a); } +static void build_draw_rect(struct parts_construction_process *cproc, struct parts_cp_fill *op) +{ + int x2 = op->x + op->w - 1; + int y2 = op->y + op->h - 1; + gfx_draw_line(&cproc->common.texture, op->x, op->y, x2, op->y, op->r, op->g, op->b); + gfx_draw_line(&cproc->common.texture, op->x, op->y, op->x, y2, op->r, op->g, op->b); + gfx_draw_line(&cproc->common.texture, x2, op->y, x2, y2, op->r, op->g, op->b); + gfx_draw_line(&cproc->common.texture, op->x, y2, x2, y2, op->r, op->g, op->b); +} + static void build_draw_cut_cg(struct parts_construction_process *cproc, struct parts_cp_cut_cg *op) { struct cg *cg = asset_cg_load(op->cg_no); @@ -388,6 +414,9 @@ bool parts_build_construction_process(struct parts *parts, case PARTS_CP_FILL_AMAP: build_fill_amap(cproc, &op->fill); break; + case PARTS_CP_DRAW_RECT: + build_draw_rect(cproc, &op->fill); + break; case PARTS_CP_DRAW_CUT_CG: build_draw_cut_cg(cproc, &op->cut_cg); break; diff --git a/src/parts/debug.c b/src/parts/debug.c index b51432a..849e941 100644 --- a/src/parts/debug.c +++ b/src/parts/debug.c @@ -110,6 +110,7 @@ static void parts_construction_process_to_json(struct parts_construction_process [PARTS_CP_FILL] = "fill", [PARTS_CP_FILL_ALPHA_COLOR] = "fill_alpha_color", [PARTS_CP_FILL_AMAP] = "fill_amap", + [PARTS_CP_DRAW_RECT] = "draw_rect", [PARTS_CP_DRAW_CUT_CG] = "draw_cut_cg", [PARTS_CP_COPY_CUT_CG] = "copy_cut_cg", [PARTS_CP_DRAW_TEXT] = "draw_text", @@ -142,6 +143,7 @@ static void parts_construction_process_to_json(struct parts_construction_process case PARTS_CP_FILL: case PARTS_CP_FILL_ALPHA_COLOR: case PARTS_CP_FILL_AMAP: + case PARTS_CP_DRAW_RECT: cJSON_AddItemToObjectCS(obj, "rect", tmp = cJSON_CreateObject()); cJSON_AddNumberToObject(tmp, "x", op->fill.x); cJSON_AddNumberToObject(tmp, "y", op->fill.y); @@ -487,6 +489,9 @@ static void parts_list_print(struct parts *parts, int indent) case PARTS_CP_FILL_AMAP: sys_message(" fill-amap"); break; + case PARTS_CP_DRAW_RECT: + sys_message(" draw-rect"); + break; case PARTS_CP_DRAW_CUT_CG: sys_message(" draw-cut-cg"); break; diff --git a/src/parts/parts_internal.h b/src/parts/parts_internal.h index db3b6ee..15a2c43 100644 --- a/src/parts/parts_internal.h +++ b/src/parts/parts_internal.h @@ -178,6 +178,7 @@ enum parts_cp_op_type { PARTS_CP_FILL, PARTS_CP_FILL_ALPHA_COLOR, PARTS_CP_FILL_AMAP, + PARTS_CP_DRAW_RECT, PARTS_CP_DRAW_CUT_CG, PARTS_CP_COPY_CUT_CG, PARTS_CP_DRAW_TEXT, diff --git a/src/parts/save.c b/src/parts/save.c index 150de05..855f663 100644 --- a/src/parts/save.c +++ b/src/parts/save.c @@ -191,6 +191,7 @@ static void save_parts_cp_op(struct iarray_writer *w, struct parts_cp_op *op) case PARTS_CP_FILL: case PARTS_CP_FILL_ALPHA_COLOR: case PARTS_CP_FILL_AMAP: + case PARTS_CP_DRAW_RECT: iarray_write(w, op->fill.x); iarray_write(w, op->fill.y); iarray_write(w, op->fill.w); @@ -240,6 +241,7 @@ static struct parts_cp_op *load_parts_cp_op(struct iarray_reader *r) case PARTS_CP_FILL: case PARTS_CP_FILL_ALPHA_COLOR: case PARTS_CP_FILL_AMAP: + case PARTS_CP_DRAW_RECT: op->fill.x = iarray_read(r); op->fill.y = iarray_read(r); op->fill.w = iarray_read(r);