mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-09-22 23:18:01 +03:00
parts: implement more ConstructionProcess ops
Implement Create, CreatePixelOnly, DrawText and CopyText operations.
This commit is contained in:
@@ -91,8 +91,18 @@ int PE_GetFreeNumber(void);
|
||||
bool PE_IsExist(int parts_no);
|
||||
|
||||
// construction.c
|
||||
bool PE_AddCreateToPartsConstructionProcess(int parts_no, int w, int h, int state);
|
||||
bool PE_AddCreatePixelOnlyToPartsConstructionProcess(int parts_no, int w, int h, int state);
|
||||
bool PE_AddCreateCGToProcess(int parts_no, struct string *cg_name, int state);
|
||||
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_AddCopyTextToPartsConstructionProcess(int parts_no, int x, int y, struct string *text,
|
||||
int type, int size, int r, int g, int b, float bold_weight,
|
||||
int edge_r, int edge_g, int edge_b, float edge_weight,
|
||||
int char_space, int line_space, int state);
|
||||
bool PE_AddDrawTextToPartsConstructionProcess(int parts_no, int x, int y, struct string *text,
|
||||
int type, int size, int r, int g, int b, float bold_weight,
|
||||
int edge_r, int edge_g, int edge_b, float edge_weight,
|
||||
int char_space, int line_space, int state);
|
||||
bool PE_BuildPartsConstructionProcess(int parts_no, int state);
|
||||
bool PE_SetPartsConstructionSurfaceArea(int parts_no, int x, int y, int w, int h, int state);
|
||||
|
||||
@@ -109,6 +119,7 @@ bool PE_SetClickMissSoundNumber(int sound_no);
|
||||
void PE_BeginInput(void);
|
||||
void PE_EndInput(void);
|
||||
int PE_GetClickPartsNumber(void);
|
||||
bool PE_IsCursorIn(int parts_no, int mouse_x, int mouse_y, int state);
|
||||
|
||||
// motion.c
|
||||
void PE_AddMotionPos(int parts_no, int begin_x, int begin_y, int end_x, int end_y, int begin_t, int end_t);
|
||||
|
||||
@@ -39,6 +39,10 @@ static int anonymous_channels[NR_ANONYMOUS_CHANNELS];
|
||||
|
||||
void audio_init(void)
|
||||
{
|
||||
static bool audio_initialized = false;
|
||||
if (audio_initialized)
|
||||
return;
|
||||
|
||||
id_pool_init(&wav);
|
||||
id_pool_init(&bgm);
|
||||
|
||||
@@ -47,6 +51,7 @@ void audio_init(void)
|
||||
}
|
||||
|
||||
mixer_init();
|
||||
audio_initialized = true;
|
||||
}
|
||||
|
||||
void audio_update(void)
|
||||
|
||||
+5
-5
@@ -860,8 +860,8 @@ HLL_LIBRARY(GUIEngine,
|
||||
HLL_TODO_EXPORT(Parts_GetPartsFlatEndFrame, GUIEngine_Parts_GetPartsFlatEndFrame),
|
||||
HLL_TODO_EXPORT(Parts_ExistsFlatFile, GUIEngine_Parts_ExistsFlatFile),
|
||||
HLL_TODO_EXPORT(Parts_ClearPartsConstructionProcess, GUIEngine_Parts_ClearPartsConstructionProcess),
|
||||
HLL_TODO_EXPORT(Parts_AddCreateToPartsConstructionProcess, GUIEngine_Parts_AddCreateToPartsConstructionProcess),
|
||||
HLL_TODO_EXPORT(Parts_AddCreatePixelOnlyToPartsConstructionProcess, GUIEngine_Parts_AddCreatePixelOnlyToPartsConstructionProcess),
|
||||
HLL_EXPORT(Parts_AddCreateToPartsConstructionProcess, PE_AddCreateToPartsConstructionProcess),
|
||||
HLL_EXPORT(Parts_AddCreatePixelOnlyToPartsConstructionProcess, PE_AddCreatePixelOnlyToPartsConstructionProcess),
|
||||
HLL_EXPORT(Parts_AddCreateCGToProcess, PE_AddCreateCGToProcess),
|
||||
HLL_TODO_EXPORT(Parts_AddFillToPartsConstructionProcess, GUIEngine_Parts_AddFillToPartsConstructionProcess),
|
||||
HLL_EXPORT(Parts_AddFillAlphaColorToPartsConstructionProcess, PE_AddFillAlphaColorToPartsConstructionProcess),
|
||||
@@ -876,8 +876,8 @@ HLL_LIBRARY(GUIEngine,
|
||||
HLL_TODO_EXPORT(Parts_AddMulFilterToPartsConstructionProcess, GUIEngine_Parts_AddMulFilterToPartsConstructionProcess),
|
||||
HLL_TODO_EXPORT(Parts_AddDrawLineToPartsConstructionProcess, GUIEngine_Parts_AddDrawLineToPartsConstructionProcess),
|
||||
HLL_EXPORT(Parts_BuildPartsConstructionProcess, PE_BuildPartsConstructionProcess),
|
||||
HLL_TODO_EXPORT(Parts_AddDrawTextToPartsConstructionProcess, GUIEngine_Parts_AddDrawTextToPartsConstructionProcess),
|
||||
HLL_TODO_EXPORT(Parts_AddCopyTextToPartsConstructionProcess, GUIEngine_Parts_AddCopyTextToPartsConstructionProcess),
|
||||
HLL_EXPORT(Parts_AddDrawTextToPartsConstructionProcess, PE_AddDrawTextToPartsConstructionProcess),
|
||||
HLL_EXPORT(Parts_AddCopyTextToPartsConstructionProcess, PE_AddCopyTextToPartsConstructionProcess),
|
||||
HLL_EXPORT(Parts_SetPartsConstructionSurfaceArea, PE_SetPartsConstructionSurfaceArea),
|
||||
HLL_TODO_EXPORT(Parts_CreateParts3DLayerPluginID, GUIEngine_Parts_CreateParts3DLayerPluginID),
|
||||
HLL_TODO_EXPORT(Parts_GetParts3DLayerPluginID, GUIEngine_Parts_GetParts3DLayerPluginID),
|
||||
@@ -954,7 +954,7 @@ HLL_LIBRARY(GUIEngine,
|
||||
HLL_TODO_EXPORT(Parts_AddMotionVibrationSize, GUIEngine_Parts_AddMotionVibrationSize),
|
||||
HLL_TODO_EXPORT(Parts_AddWholeMotionVibrationSize, GUIEngine_Parts_AddWholeMotionVibrationSize),
|
||||
HLL_TODO_EXPORT(Parts_AddMotionSound, GUIEngine_Parts_AddMotionSound),
|
||||
HLL_TODO_EXPORT(Parts_IsCursorIn, GUIEngine_Parts_IsCursorIn),
|
||||
HLL_EXPORT(Parts_IsCursorIn, PE_IsCursorIn),
|
||||
HLL_TODO_EXPORT(Parts_SetThumbnailReductionSize, GUIEngine_Parts_SetThumbnailReductionSize),
|
||||
HLL_TODO_EXPORT(Parts_SetThumbnailMode, GUIEngine_Parts_SetThumbnailMode),
|
||||
HLL_TODO_EXPORT(GetClickNumber, GUIEngine_GetClickNumber),
|
||||
|
||||
+154
-15
@@ -32,10 +32,15 @@ static struct parts_construction_process *get_cproc(int parts_no, int state)
|
||||
void parts_cp_op_free(struct parts_cp_op *op)
|
||||
{
|
||||
switch (op->type) {
|
||||
case PARTS_CP_CREATE:
|
||||
case PARTS_CP_CREATE_PIXEL_ONLY:
|
||||
case PARTS_CP_CG:
|
||||
break;
|
||||
case PARTS_CP_FILL_ALPHA_COLOR:
|
||||
break;
|
||||
case PARTS_CP_DRAW_TEXT:
|
||||
case PARTS_CP_COPY_TEXT:
|
||||
free_string(op->text.text);
|
||||
break;
|
||||
}
|
||||
free(op);
|
||||
}
|
||||
@@ -46,8 +51,34 @@ static void parts_add_cp_op(struct parts_construction_process *cproc, struct par
|
||||
}
|
||||
|
||||
bool PE_ClearPartsConstructionProcess(int parts_no, int state);
|
||||
bool PE_AddCreateToPartsConstructionProcess(int parts_no, int w, int h, int state);
|
||||
bool PE_AddCreatePixelOnlyToPartsConstructionProcess(int parts_no, int w, int h, int state);
|
||||
|
||||
bool PE_AddCreateToPartsConstructionProcess(int parts_no, int w, int h, 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_CREATE;
|
||||
op->create.w = w;
|
||||
op->create.h = h;
|
||||
parts_add_cp_op(cproc, op);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PE_AddCreatePixelOnlyToPartsConstructionProcess(int parts_no, int w, int h, 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_CREATE_PIXEL_ONLY;
|
||||
op->create.w = w;
|
||||
op->create.h = h;
|
||||
parts_add_cp_op(cproc, op);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PE_AddCreateCGToProcess(int parts_no, struct string *cg_name, int state)
|
||||
{
|
||||
@@ -88,15 +119,102 @@ bool PE_AddFillAlphaColorToPartsConstructionProcess(int parts_no, int x, int y,
|
||||
}
|
||||
|
||||
bool PE_AddFillAMapToPartsConstructionProcess(int parts_no, int x, int y, int w, int h, int a, int state);
|
||||
bool PE_AddFillWithAlphaToPartsConstructionProcess(int parts_no, int x, int y, int w, int h, 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);
|
||||
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, int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh, int interp_type, int state);
|
||||
bool PE_AddGrayFilterToPartsConstructionProcess(int parts_no, int x, int y, int w, int h, bool full_size, int state);
|
||||
bool PE_AddAddFilterToPartsConstructionProcess(int parts_no, int x, int y, int w, int h, int r, int g, int b, bool full_size, int state);
|
||||
bool PE_AddMulFilterToPartsConstructionProcess(int parts_no, int x, int y, int w, int h, int r, int g, int b, bool full_size, int state);
|
||||
bool PE_AddDrawLineToPartsConstructionProcess(int parts_no, int x1, int y1, int x2, int y2, int r, int g, int b, int a, int state);
|
||||
bool PE_AddFillWithAlphaToPartsConstructionProcess(int parts_no, int x, int y, int w, int h,
|
||||
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);
|
||||
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,
|
||||
int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh, int interp_type, int state);
|
||||
bool PE_AddGrayFilterToPartsConstructionProcess(int parts_no, int x, int y, int w, int h,
|
||||
bool full_size, int state);
|
||||
bool PE_AddAddFilterToPartsConstructionProcess(int parts_no, int x, int y, int w, int h,
|
||||
int r, int g, int b, bool full_size, int state);
|
||||
bool PE_AddMulFilterToPartsConstructionProcess(int parts_no, int x, int y, int w, int h,
|
||||
int r, int g, int b, bool full_size, int state);
|
||||
bool PE_AddDrawLineToPartsConstructionProcess(int parts_no, int x1, int y1, int x2, int y2,
|
||||
int r, int g, int b, int a, int state);
|
||||
|
||||
static bool add_text_to_cproc(int parts_no, int x, int y, struct string *text,
|
||||
int type, int size, int r, int g, int b, float bold_weight,
|
||||
int edge_r, int edge_g, int edge_b, float edge_weight,
|
||||
int char_space, int line_space, int state, enum parts_cp_op_type op_type)
|
||||
{
|
||||
if (!parts_state_valid(--state))
|
||||
return false;
|
||||
|
||||
struct parts_cp_op *op = xcalloc(1, sizeof(struct parts_cp_op));
|
||||
op->type = op_type;
|
||||
op->text = (struct parts_cp_text) {
|
||||
.text = string_dup(text),
|
||||
.x = x,
|
||||
.y = y,
|
||||
.line_space = line_space,
|
||||
.style = {
|
||||
.face = type,
|
||||
.size = size,
|
||||
.bold_width = bold_weight,
|
||||
.weight = 0,
|
||||
.edge_left = edge_weight,
|
||||
.edge_up = edge_weight,
|
||||
.edge_right = edge_weight,
|
||||
.edge_down = edge_weight,
|
||||
.color = { r, g, b, 255 },
|
||||
.edge_color = { edge_r, edge_g, edge_b, 255 },
|
||||
.scale_x = 1.0f,
|
||||
.space_scale_x = 1.0f,
|
||||
.font_spacing = char_space
|
||||
}
|
||||
};
|
||||
|
||||
parts_add_cp_op(get_cproc(parts_no, state), op);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool PE_AddDrawTextToPartsConstructionProcess(int parts_no, int x, int y, struct string *text,
|
||||
int type, int size, int r, int g, int b, float bold_weight,
|
||||
int edge_r, int edge_g, int edge_b, float edge_weight,
|
||||
int char_space, int line_space, int state)
|
||||
{
|
||||
return add_text_to_cproc(parts_no, x, y, text, type, size, r, g, b, bold_weight,
|
||||
edge_r, edge_g, edge_b, edge_weight, char_space, line_space, state,
|
||||
PARTS_CP_DRAW_TEXT);
|
||||
}
|
||||
|
||||
bool PE_AddCopyTextToPartsConstructionProcess(int parts_no, int x, int y, struct string *text,
|
||||
int type, int size, int r, int g, int b, float bold_weight,
|
||||
int edge_r, int edge_g, int edge_b, float edge_weight,
|
||||
int char_space, int line_space, int state)
|
||||
{
|
||||
return add_text_to_cproc(parts_no, x, y, text, type, size, r, g, b, bold_weight,
|
||||
edge_r, edge_g, edge_b, edge_weight, char_space, line_space, state,
|
||||
PARTS_CP_COPY_TEXT);
|
||||
}
|
||||
|
||||
static void build_create(struct parts *parts, struct parts_construction_process *cproc,
|
||||
struct parts_cp_create *op)
|
||||
{
|
||||
gfx_delete_texture(&cproc->common.texture);
|
||||
gfx_init_texture_rgba(&cproc->common.texture, op->w, op->h, (SDL_Color){0,0,0,0});
|
||||
parts->rect.w = op->w;
|
||||
parts->rect.h = op->h;
|
||||
parts_recalculate_pos(parts);
|
||||
}
|
||||
|
||||
static void build_create_pixel_only(struct parts *parts, struct parts_construction_process *cproc,
|
||||
struct parts_cp_create *op)
|
||||
{
|
||||
gfx_delete_texture(&cproc->common.texture);
|
||||
gfx_init_texture_rgb(&cproc->common.texture, op->w, op->h, (SDL_Color){0,0,0,255});
|
||||
parts->rect.w = op->w;
|
||||
parts->rect.h = op->h;
|
||||
parts_recalculate_pos(parts);
|
||||
}
|
||||
|
||||
static void build_cg(struct parts *parts, struct parts_construction_process *cproc, struct parts_cp_cg *op)
|
||||
{
|
||||
@@ -115,6 +233,17 @@ static void build_fill_alpha_color(struct parts_construction_process *cproc,
|
||||
gfx_fill_alpha_color(&cproc->common.texture, op->x, op->y, op->w, op->h, op->r, op->g, op->b, op->a);
|
||||
}
|
||||
|
||||
static void build_draw_text(struct parts_construction_process *cproc, struct parts_cp_text *op)
|
||||
{
|
||||
// FIXME: this should set alpha to 0 in text area
|
||||
gfx_render_text(&cproc->common.texture, op->x, op->y, op->text->text, &op->style);
|
||||
}
|
||||
|
||||
static void build_copy_text(struct parts_construction_process *cproc, struct parts_cp_text *op)
|
||||
{
|
||||
gfx_render_text(&cproc->common.texture, op->x, op->y, op->text->text, &op->style);
|
||||
}
|
||||
|
||||
bool PE_BuildPartsConstructionProcess(int parts_no, int state)
|
||||
{
|
||||
if (!parts_state_valid(--state))
|
||||
@@ -125,21 +254,31 @@ bool PE_BuildPartsConstructionProcess(int parts_no, int state)
|
||||
struct parts_cp_op *op;
|
||||
TAILQ_FOREACH(op, &cproc->ops, entry) {
|
||||
switch (op->type) {
|
||||
case PARTS_CP_CREATE:
|
||||
build_create(parts, cproc, &op->create);
|
||||
break;
|
||||
case PARTS_CP_CREATE_PIXEL_ONLY:
|
||||
build_create_pixel_only(parts, cproc, &op->create);
|
||||
break;
|
||||
case PARTS_CP_CG:
|
||||
build_cg(parts, cproc, &op->cg);
|
||||
break;
|
||||
case PARTS_CP_FILL_ALPHA_COLOR:
|
||||
build_fill_alpha_color(cproc, &op->fill_alpha_color);
|
||||
break;
|
||||
case PARTS_CP_DRAW_TEXT:
|
||||
build_draw_text(cproc, &op->text);
|
||||
break;
|
||||
case PARTS_CP_COPY_TEXT:
|
||||
build_copy_text(cproc, &op->text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
parts_recalculate_pos(parts);
|
||||
parts_dirty(parts);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PE_AddDrawTextToPartsConstructionProcess(int parts_no, int x, int y, struct string *text, int type, int size, int r, int g, int b, float bold_weight, int edge_r, int edge_g, int edge_b, float edge_weight, int char_space, int line_space, int state);
|
||||
bool PE_AddCopyTextToPartsConstructionProcess(int parts_no, int x, int y, struct string *text, int type, int size, int r, int g, int b, float bold_weight, int edge_r, int edge_g, int edge_b, float edge_weight, int char_space, int line_space, int state);
|
||||
|
||||
bool PE_SetPartsConstructionSurfaceArea(int parts_no, int x, int y, int w, int h, int state)
|
||||
{
|
||||
if (!parts_state_valid(--state))
|
||||
|
||||
@@ -168,4 +168,11 @@ int PE_GetClickPartsNumber(void)
|
||||
return clicked_parts;
|
||||
}
|
||||
|
||||
bool PE_IsCursorIn(int parts_no, int mouse_x, int mouse_y, int state)
|
||||
{
|
||||
if (!parts_state_valid(--state))
|
||||
return false;
|
||||
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -545,7 +545,9 @@ bool PE_Init(void)
|
||||
{
|
||||
parts_table = ht_create(1024);
|
||||
parts_render_init();
|
||||
gfx_init();
|
||||
gfx_font_init();
|
||||
audio_init();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,8 +129,17 @@ struct parts_gauge {
|
||||
};
|
||||
|
||||
enum parts_cp_op_type {
|
||||
PARTS_CP_CREATE,
|
||||
PARTS_CP_CREATE_PIXEL_ONLY,
|
||||
PARTS_CP_CG,
|
||||
PARTS_CP_FILL_ALPHA_COLOR
|
||||
PARTS_CP_FILL_ALPHA_COLOR,
|
||||
PARTS_CP_DRAW_TEXT,
|
||||
PARTS_CP_COPY_TEXT,
|
||||
};
|
||||
|
||||
struct parts_cp_create {
|
||||
int w;
|
||||
int h;
|
||||
};
|
||||
|
||||
struct parts_cp_cg {
|
||||
@@ -142,12 +151,21 @@ struct parts_cp_fill_alpha_color {
|
||||
int r, g, b, a;
|
||||
};
|
||||
|
||||
struct parts_cp_text {
|
||||
struct string *text;
|
||||
int x, y;
|
||||
int line_space;
|
||||
struct text_style style;
|
||||
};
|
||||
|
||||
struct parts_cp_op {
|
||||
TAILQ_ENTRY(parts_cp_op) entry;
|
||||
enum parts_cp_op_type type;
|
||||
union {
|
||||
struct parts_cp_create create;
|
||||
struct parts_cp_cg cg;
|
||||
struct parts_cp_fill_alpha_color fill_alpha_color;
|
||||
struct parts_cp_text text;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user