basic support for portrait faces; make charselect menu more fun
|
@ -1,3 +1,5 @@
|
|||
|
||||
w = 326.5
|
||||
h = 478
|
||||
w = 326
|
||||
h = 477.5
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
w = 388
|
||||
w = 386
|
||||
h = 500
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
w = 338.5
|
||||
h = 493.5
|
||||
w = 337.5
|
||||
h = 492.5
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
w = 340
|
||||
h = 513
|
||||
w = 339
|
||||
h = 512.5
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
w = 402.5
|
||||
h = 478
|
||||
w = 400.5
|
||||
h = 477
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
w = 257
|
||||
h = 498.5
|
||||
w = 256
|
||||
h = 497.5
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
5
atlas/overrides/dialog/marisa_face_normal.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 57
|
||||
h = 50.5
|
||||
offset_x = -22
|
||||
offset_y = -134
|
5
atlas/overrides/dialog/marisa_face_smug.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 57
|
||||
h = 50
|
||||
offset_x = -24
|
||||
offset_y = -134.25
|
5
atlas/overrides/dialog/marisa_face_surprised.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 138
|
||||
h = 103.5
|
||||
offset_x = 16.5
|
||||
offset_y = -160
|
5
atlas/overrides/dialog/marisa_face_unamused.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 130
|
||||
h = 94
|
||||
offset_x = 11
|
||||
offset_y = -156.25
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
w = 311
|
||||
h = 491.5
|
||||
w = 310
|
||||
h = 491
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
5
atlas/overrides/dialog/reimu_face_normal.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 62.5
|
||||
h = 57.5
|
||||
offset_x = 23.25
|
||||
offset_y = -155.75
|
5
atlas/overrides/dialog/reimu_face_smug.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 63
|
||||
h = 64
|
||||
offset_x = 22
|
||||
offset_y = -157
|
5
atlas/overrides/dialog/reimu_face_surprised.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 132.5
|
||||
h = 107
|
||||
offset_x = -11.75
|
||||
offset_y = -179
|
5
atlas/overrides/dialog/reimu_face_unamused.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 100.5
|
||||
h = 61.5
|
||||
offset_x = 41.75
|
||||
offset_y = -157.25
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
w = 263.5
|
||||
h = 474
|
||||
w = 262.5
|
||||
h = 473.5
|
||||
offset_x = -16
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
w = 322
|
||||
h = 545.5
|
||||
w = 321
|
||||
h = 544.5
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
w = 288.5
|
||||
h = 491
|
||||
w = 286
|
||||
h = 490
|
||||
offset_x = 32
|
||||
offset_y = 0
|
||||
|
|
5
atlas/overrides/dialog/youmu_face_normal.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 65.5
|
||||
h = 60.5
|
||||
offset_x = -0.75
|
||||
offset_y = -173.75
|
5
atlas/overrides/dialog/youmu_face_smug.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 58
|
||||
h = 56
|
||||
offset_x = -2.5
|
||||
offset_y = -171.5
|
5
atlas/overrides/dialog/youmu_face_surprised.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 119
|
||||
h = 95.5
|
||||
offset_x = -27.5
|
||||
offset_y = -190.25
|
5
atlas/overrides/dialog/youmu_face_unamused.spr
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
w = 116.5
|
||||
h = 106
|
||||
offset_x = -27.75
|
||||
offset_y = -196.5
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 241 KiB After Width: | Height: | Size: 241 KiB |
Before Width: | Height: | Size: 205 KiB After Width: | Height: | Size: 205 KiB |
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 190 KiB |
Before Width: | Height: | Size: 215 KiB After Width: | Height: | Size: 215 KiB |
Before Width: | Height: | Size: 189 KiB After Width: | Height: | Size: 189 KiB |
Before Width: | Height: | Size: 194 KiB After Width: | Height: | Size: 190 KiB |
BIN
atlas/portraits/dialog/marisa_face_normal.webp
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
atlas/portraits/dialog/marisa_face_smug.webp
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
atlas/portraits/dialog/marisa_face_surprised.webp
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
atlas/portraits/dialog/marisa_face_unamused.webp
Normal file
After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 188 KiB |
BIN
atlas/portraits/dialog/reimu_face_normal.webp
Normal file
After Width: | Height: | Size: 5 KiB |
BIN
atlas/portraits/dialog/reimu_face_smug.webp
Normal file
After Width: | Height: | Size: 5 KiB |
BIN
atlas/portraits/dialog/reimu_face_surprised.webp
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
atlas/portraits/dialog/reimu_face_unamused.webp
Normal file
After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 111 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 247 KiB After Width: | Height: | Size: 247 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 167 KiB |
BIN
atlas/portraits/dialog/youmu_face_normal.webp
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
atlas/portraits/dialog/youmu_face_smug.webp
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
atlas/portraits/dialog/youmu_face_surprised.webp
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
atlas/portraits/dialog/youmu_face_unamused.webp
Normal file
After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 2 MiB |
|
@ -1,12 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 2
|
||||
region_y = 962
|
||||
region_w = 653
|
||||
region_h = 956
|
||||
region_x = 2944
|
||||
region_y = 2
|
||||
region_w = 652
|
||||
region_h = 955
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 326.5
|
||||
h = 478
|
||||
w = 326
|
||||
h = 477.5
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 811
|
||||
region_x = 807
|
||||
region_y = 2
|
||||
region_w = 776
|
||||
region_w = 772
|
||||
region_h = 1000
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 388
|
||||
w = 386
|
||||
h = 500
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 2275
|
||||
region_x = 2265
|
||||
region_y = 2
|
||||
region_w = 677
|
||||
region_h = 987
|
||||
region_w = 675
|
||||
region_h = 985
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 338.5
|
||||
h = 493.5
|
||||
w = 337.5
|
||||
h = 492.5
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1591
|
||||
region_x = 1583
|
||||
region_y = 2
|
||||
region_w = 680
|
||||
region_h = 1026
|
||||
region_w = 678
|
||||
region_h = 1025
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 340
|
||||
h = 513
|
||||
w = 339
|
||||
h = 512.5
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
texture = atlas_portraits_0
|
||||
region_x = 2
|
||||
region_y = 2
|
||||
region_w = 805
|
||||
region_h = 956
|
||||
region_w = 801
|
||||
region_h = 954
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 402.5
|
||||
h = 478
|
||||
w = 400.5
|
||||
h = 477
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1190
|
||||
region_y = 1032
|
||||
region_w = 514
|
||||
region_h = 997
|
||||
region_x = 1177
|
||||
region_y = 1031
|
||||
region_w = 512
|
||||
region_h = 995
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 257
|
||||
h = 498.5
|
||||
w = 256
|
||||
h = 497.5
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
14
resources/00-taisei.pkgdir/gfx/dialog/marisa_face_normal.spr
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1942
|
||||
region_y = 1717
|
||||
region_w = 114
|
||||
region_h = 101
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 57
|
||||
h = 50.5
|
||||
offset_x = -22
|
||||
offset_y = -134
|
14
resources/00-taisei.pkgdir/gfx/dialog/marisa_face_smug.spr
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 2060
|
||||
region_y = 1717
|
||||
region_w = 114
|
||||
region_h = 100
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 57
|
||||
h = 50
|
||||
offset_x = -24
|
||||
offset_y = -134.25
|
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1962
|
||||
region_y = 1247
|
||||
region_w = 276
|
||||
region_h = 207
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 138
|
||||
h = 103.5
|
||||
offset_x = 16.5
|
||||
offset_y = -160
|
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1693
|
||||
region_y = 1444
|
||||
region_w = 260
|
||||
region_h = 188
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 130
|
||||
h = 94
|
||||
offset_x = 11
|
||||
offset_y = -156.25
|
|
@ -1,12 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 2956
|
||||
region_y = 2
|
||||
region_w = 622
|
||||
region_h = 983
|
||||
region_x = 2944
|
||||
region_y = 961
|
||||
region_w = 620
|
||||
region_h = 982
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 311
|
||||
h = 491.5
|
||||
w = 310
|
||||
h = 491
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
14
resources/00-taisei.pkgdir/gfx/dialog/reimu_face_normal.spr
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1693
|
||||
region_y = 1636
|
||||
region_w = 125
|
||||
region_h = 115
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 62.5
|
||||
h = 57.5
|
||||
offset_x = 23.25
|
||||
offset_y = -155.75
|
14
resources/00-taisei.pkgdir/gfx/dialog/reimu_face_smug.spr
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1957
|
||||
region_y = 1458
|
||||
region_w = 126
|
||||
region_h = 128
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 63
|
||||
h = 64
|
||||
offset_x = 22
|
||||
offset_y = -157
|
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1693
|
||||
region_y = 1031
|
||||
region_w = 265
|
||||
region_h = 214
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 132.5
|
||||
h = 107
|
||||
offset_x = -11.75
|
||||
offset_y = -179
|
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1957
|
||||
region_y = 1590
|
||||
region_w = 201
|
||||
region_h = 123
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 100.5
|
||||
h = 61.5
|
||||
offset_x = 41.75
|
||||
offset_y = -157.25
|
|
@ -1,13 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 659
|
||||
region_x = 648
|
||||
region_y = 1006
|
||||
region_w = 527
|
||||
region_h = 948
|
||||
region_w = 525
|
||||
region_h = 947
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 263.5
|
||||
h = 474
|
||||
w = 262.5
|
||||
h = 473.5
|
||||
offset_x = -16
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 2275
|
||||
region_y = 993
|
||||
region_w = 644
|
||||
region_h = 1091
|
||||
region_x = 2
|
||||
region_y = 960
|
||||
region_w = 642
|
||||
region_h = 1089
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 322
|
||||
h = 545.5
|
||||
w = 321
|
||||
h = 544.5
|
||||
offset_x = 0
|
||||
offset_y = 0
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 2956
|
||||
region_y = 989
|
||||
region_w = 577
|
||||
region_h = 982
|
||||
region_x = 2265
|
||||
region_y = 991
|
||||
region_w = 572
|
||||
region_h = 980
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 288.5
|
||||
h = 491
|
||||
w = 286
|
||||
h = 490
|
||||
offset_x = 32
|
||||
offset_y = 0
|
||||
|
|
14
resources/00-taisei.pkgdir/gfx/dialog/youmu_face_normal.spr
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 2087
|
||||
region_y = 1458
|
||||
region_w = 131
|
||||
region_h = 121
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 65.5
|
||||
h = 60.5
|
||||
offset_x = -0.75
|
||||
offset_y = -173.75
|
14
resources/00-taisei.pkgdir/gfx/dialog/youmu_face_smug.spr
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1822
|
||||
region_y = 1636
|
||||
region_w = 116
|
||||
region_h = 112
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 58
|
||||
h = 56
|
||||
offset_x = -2.5
|
||||
offset_y = -171.5
|
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1693
|
||||
region_y = 1249
|
||||
region_w = 238
|
||||
region_h = 191
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 119
|
||||
h = 95.5
|
||||
offset_x = -27.5
|
||||
offset_y = -190.25
|
|
@ -0,0 +1,14 @@
|
|||
# Autogenerated by the atlas packer, do not modify
|
||||
|
||||
texture = atlas_portraits_0
|
||||
region_x = 1962
|
||||
region_y = 1031
|
||||
region_w = 233
|
||||
region_h = 212
|
||||
|
||||
# -- Pasted from the override file --
|
||||
|
||||
w = 116.5
|
||||
h = 106
|
||||
offset_x = -27.75
|
||||
offset_y = -196.5
|
125
src/dialog.c
|
@ -11,22 +11,31 @@
|
|||
#include "dialog.h"
|
||||
#include "global.h"
|
||||
|
||||
Dialog *create_dialog(const char *left, const char *right) {
|
||||
Dialog *dialog_create(void) {
|
||||
Dialog *d = calloc(1, sizeof(Dialog));
|
||||
|
||||
if(left) {
|
||||
d->images[Left] = get_sprite(left);
|
||||
}
|
||||
|
||||
if(right) {
|
||||
d->images[Right] = get_sprite(right);
|
||||
}
|
||||
|
||||
d->page_time = global.frames;
|
||||
d->birthtime = global.frames;
|
||||
return d;
|
||||
}
|
||||
|
||||
void dialog_set_actor(Dialog *d, DialogSide side, DialogActor *actor) {
|
||||
if(actor) {
|
||||
d->actors[side] = *actor;
|
||||
} else {
|
||||
memset(d->actors + side, 0, sizeof(*d->actors));
|
||||
}
|
||||
}
|
||||
|
||||
void dialog_set_playerchar_actor(Dialog *d, DialogSide side, PlayerCharacter *pc, DialogFace face) {
|
||||
plrchar_make_dialog_actor(pc, d->actors + side);
|
||||
|
||||
if(face == DIALOG_FACE_NONE) {
|
||||
d->actors[side].face = NULL;
|
||||
} else {
|
||||
d->actors[side].face = d->actors[side].faces[face];
|
||||
}
|
||||
}
|
||||
|
||||
static int message_index(Dialog *d, int offset) {
|
||||
int idx = d->pos + offset;
|
||||
|
||||
|
@ -34,36 +43,36 @@ static int message_index(Dialog *d, int offset) {
|
|||
idx = d->count - 1;
|
||||
}
|
||||
|
||||
while(idx >= 0 && d->messages[idx].side == BGM) {
|
||||
while(
|
||||
idx >= 0 &&
|
||||
d->actions[idx].type != DIALOG_MSG_LEFT &&
|
||||
d->actions[idx].type != DIALOG_MSG_RIGHT
|
||||
) {
|
||||
--idx;
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
void dset_image(Dialog *d, Side side, const char *name) {
|
||||
d->images[side] = get_sprite(name);
|
||||
DialogAction * dialog_add_action(Dialog *d, DialogActionType side, const char *msg) {
|
||||
d->actions = realloc(d->actions, (++d->count)*sizeof(DialogAction));
|
||||
d->actions[d->count-1].type = side;
|
||||
d->actions[d->count-1].msg = malloc(strlen(msg) + 1);
|
||||
d->actions[d->count-1].timeout = 0;
|
||||
strlcpy(d->actions[d->count-1].msg, msg, strlen(msg) + 1);
|
||||
return &d->actions[d->count-1];
|
||||
}
|
||||
|
||||
DialogMessage* dadd_msg(Dialog *d, Side side, const char *msg) {
|
||||
d->messages = realloc(d->messages, (++d->count)*sizeof(DialogMessage));
|
||||
d->messages[d->count-1].side = side;
|
||||
d->messages[d->count-1].msg = malloc(strlen(msg) + 1);
|
||||
d->messages[d->count-1].timeout = 0;
|
||||
strlcpy(d->messages[d->count-1].msg, msg, strlen(msg) + 1);
|
||||
return &d->messages[d->count-1];
|
||||
}
|
||||
|
||||
void delete_dialog(Dialog *d) {
|
||||
void dialog_destroy(Dialog *d) {
|
||||
for(int i = 0; i < d->count; i++) {
|
||||
free(d->messages[i].msg);
|
||||
free(d->actions[i].msg);
|
||||
}
|
||||
|
||||
free(d->messages);
|
||||
free(d->actions);
|
||||
free(d);
|
||||
}
|
||||
|
||||
void draw_dialog(Dialog *dialog) {
|
||||
void dialog_draw(Dialog *dialog) {
|
||||
if(dialog == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -91,8 +100,8 @@ void draw_dialog(Dialog *dialog) {
|
|||
|
||||
assume(cur_idx >= 0);
|
||||
|
||||
int cur_side = dialog->messages[cur_idx].side;
|
||||
int pre_side = pre_idx >= 0 ? dialog->messages[pre_idx].side : 2;
|
||||
int cur_side = dialog->actions[cur_idx].type;
|
||||
int pre_side = pre_idx >= 0 ? dialog->actions[pre_idx].type : 2;
|
||||
|
||||
Color clr = { 0 };
|
||||
|
||||
|
@ -114,9 +123,16 @@ void draw_dialog(Dialog *dialog) {
|
|||
}
|
||||
|
||||
for(int i = loop_start; i < 2 && i >= 0; i += loop_incr) {
|
||||
Sprite *base = dialog->actors[i].base;
|
||||
Sprite *face = dialog->actors[i].face;
|
||||
|
||||
if(!base) {
|
||||
continue;
|
||||
}
|
||||
|
||||
r_mat_push();
|
||||
|
||||
if(i == Left) {
|
||||
if(i == DIALOG_MSG_LEFT) {
|
||||
r_cull(CULL_FRONT);
|
||||
r_mat_scale(-1, 1, 1);
|
||||
} else {
|
||||
|
@ -141,21 +157,18 @@ void draw_dialog(Dialog *dialog) {
|
|||
}
|
||||
|
||||
color_mul_scalar(&clr, o);
|
||||
r_color(&clr);
|
||||
|
||||
if(dialog->images[i]) {
|
||||
Sprite *s = dialog->images[i];
|
||||
r_mat_translate((dialog_width - s->w)/2 + 32, VIEWPORT_H - s->h/2, 0);
|
||||
draw_sprite_batched_p(0, 0, s);
|
||||
r_state_push();
|
||||
r_shader_standard_notex();
|
||||
r_mat_push();
|
||||
r_mat_scale(s->w, s->h, 1);
|
||||
// r_mat_translate(0.5, 0.5, 0);
|
||||
r_color4(0.2, 0.2, 0.2, 0.2);
|
||||
// r_draw_quad();
|
||||
r_mat_pop();
|
||||
r_state_pop();
|
||||
SpriteParams sp = { 0 };
|
||||
sp.blend = BLEND_PREMUL_ALPHA;
|
||||
sp.color = &clr;
|
||||
sp.pos.x = (dialog_width - base->w) / 2 + 32;
|
||||
sp.pos.y = VIEWPORT_H - base->h / 2;
|
||||
sp.sprite_ptr = base;
|
||||
r_draw_sprite(&sp);
|
||||
|
||||
if(face) {
|
||||
sp.sprite_ptr = face;
|
||||
r_draw_sprite(&sp);
|
||||
}
|
||||
|
||||
r_mat_pop();
|
||||
|
@ -197,7 +210,7 @@ void draw_dialog(Dialog *dialog) {
|
|||
// dialog_bg_rect.h = dialog_bg_rect.w;
|
||||
|
||||
if(pre_idx >= 0 && page_text_alpha < 1) {
|
||||
if(pre_side == Right) {
|
||||
if(pre_side == DIALOG_MSG_RIGHT) {
|
||||
clr = *RGB(0.6, 0.6, 1.0);
|
||||
} else {
|
||||
clr = *RGB(1.0, 1.0, 1.0);
|
||||
|
@ -205,7 +218,7 @@ void draw_dialog(Dialog *dialog) {
|
|||
|
||||
color_mul_scalar(&clr, o);
|
||||
|
||||
text_draw_wrapped(dialog->messages[pre_idx].msg, VIEWPORT_W * 0.86, &(TextParams) {
|
||||
text_draw_wrapped(dialog->actions[pre_idx].msg, VIEWPORT_W * 0.86, &(TextParams) {
|
||||
.shader = "text_dialog",
|
||||
.aux_textures = { get_tex("cell_noise") },
|
||||
.shader_params = &(ShaderCustomParams) {{ o * (1.0 - (0.2 + 0.8 * page_text_alpha)), 1 }},
|
||||
|
@ -217,7 +230,7 @@ void draw_dialog(Dialog *dialog) {
|
|||
});
|
||||
}
|
||||
|
||||
if(cur_side == Right) {
|
||||
if(cur_side == DIALOG_MSG_RIGHT) {
|
||||
clr = *RGB(0.6, 0.6, 1.0);
|
||||
} else {
|
||||
clr = *RGB(1.0, 1.0, 1.0);
|
||||
|
@ -225,7 +238,7 @@ void draw_dialog(Dialog *dialog) {
|
|||
|
||||
color_mul_scalar(&clr, o);
|
||||
|
||||
text_draw_wrapped(dialog->messages[cur_idx].msg, VIEWPORT_W * 0.86, &(TextParams) {
|
||||
text_draw_wrapped(dialog->actions[cur_idx].msg, VIEWPORT_W * 0.86, &(TextParams) {
|
||||
.shader = "text_dialog",
|
||||
.aux_textures = { get_tex("cell_noise") },
|
||||
.shader_params = &(ShaderCustomParams) {{ o * page_text_alpha, 0 }},
|
||||
|
@ -245,12 +258,12 @@ void draw_dialog(Dialog *dialog) {
|
|||
r_state_pop();
|
||||
}
|
||||
|
||||
bool page_dialog(Dialog **d) {
|
||||
bool dialog_page(Dialog **d) {
|
||||
if(!*d || (*d)->pos >= (*d)->count) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int to = (*d)->messages[(*d)->pos].timeout;
|
||||
int to = (*d)->actions[(*d)->pos].timeout;
|
||||
|
||||
if(to && to > global.frames) {
|
||||
return false;
|
||||
|
@ -263,27 +276,27 @@ bool page_dialog(Dialog **d) {
|
|||
// XXX: maybe this can be handled elsewhere?
|
||||
if(!global.boss)
|
||||
global.timer++;
|
||||
} else if((*d)->messages[(*d)->pos].side == BGM) {
|
||||
stage_start_bgm((*d)->messages[(*d)->pos].msg);
|
||||
return page_dialog(d);
|
||||
} else if((*d)->actions[(*d)->pos].type == DIALOG_SET_BGM) {
|
||||
stage_start_bgm((*d)->actions[(*d)->pos].msg);
|
||||
return dialog_page(d);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void process_dialog(Dialog **d) {
|
||||
void dialog_update(Dialog **d) {
|
||||
if(!*d) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(dialog_is_active(*d)) {
|
||||
int to = (*d)->messages[(*d)->pos].timeout;
|
||||
int to = (*d)->actions[(*d)->pos].timeout;
|
||||
|
||||
if(
|
||||
(to && to >= global.frames) ||
|
||||
((global.plr.inputflags & INFLAG_SKIP) && global.frames - (*d)->page_time > 3)
|
||||
) {
|
||||
page_dialog(d);
|
||||
dialog_page(d);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,7 +307,7 @@ void process_dialog(Dialog **d) {
|
|||
} else {
|
||||
fapproach_asymptotic_p(&(*d)->opacity, 0, 0.1, 1e-3);
|
||||
if((*d)->opacity == 0) {
|
||||
delete_dialog(*d);
|
||||
dialog_destroy(*d);
|
||||
*d = NULL;
|
||||
}
|
||||
}
|
||||
|
|
72
src/dialog.h
|
@ -13,23 +13,44 @@
|
|||
|
||||
#include "resource/sprite.h"
|
||||
|
||||
struct DialogMessage;
|
||||
struct DialogAction;
|
||||
|
||||
typedef enum {
|
||||
Right,
|
||||
Left,
|
||||
BGM
|
||||
} Side;
|
||||
DIALOG_RIGHT,
|
||||
DIALOG_LEFT,
|
||||
} DialogSide;
|
||||
|
||||
typedef struct DialogMessage {
|
||||
Side side;
|
||||
typedef enum {
|
||||
DIALOG_MSG_RIGHT = DIALOG_RIGHT,
|
||||
DIALOG_MSG_LEFT = DIALOG_LEFT,
|
||||
DIALOG_SET_BGM
|
||||
} DialogActionType;
|
||||
|
||||
typedef enum {
|
||||
DIALOG_FACE_NORMAL,
|
||||
DIALOG_FACE_SURPRISED,
|
||||
DIALOG_FACE_ANNOYED,
|
||||
DIALOG_FACE_SMUG,
|
||||
|
||||
DIALOG_NUM_FACES,
|
||||
DIALOG_FACE_NONE,
|
||||
} DialogFace;
|
||||
|
||||
typedef struct DialogAction {
|
||||
DialogActionType type;
|
||||
char *msg;
|
||||
int timeout;
|
||||
} DialogMessage;
|
||||
} DialogAction;
|
||||
|
||||
typedef struct DialogActor {
|
||||
Sprite *base;
|
||||
Sprite *face;
|
||||
Sprite *faces[DIALOG_NUM_FACES];
|
||||
} DialogActor;
|
||||
|
||||
typedef struct Dialog {
|
||||
DialogMessage *messages;
|
||||
Sprite *images[2];
|
||||
DialogAction *actions;
|
||||
DialogActor actors[2];
|
||||
|
||||
int count;
|
||||
int pos;
|
||||
|
@ -39,22 +60,31 @@ typedef struct Dialog {
|
|||
float opacity;
|
||||
} Dialog;
|
||||
|
||||
Dialog *create_dialog(const char *left, const char *right)
|
||||
Dialog *dialog_create(void)
|
||||
attr_returns_nonnull attr_nodiscard;
|
||||
|
||||
void dset_image(Dialog *d, Side side, const char *name)
|
||||
attr_nonnull(1, 3);
|
||||
|
||||
DialogMessage* dadd_msg(Dialog *d, Side side, const char *msg)
|
||||
attr_nonnull(1, 3);
|
||||
|
||||
void delete_dialog(Dialog *d)
|
||||
void dialog_set_actor(Dialog *d, DialogSide side, DialogActor *actor)
|
||||
attr_nonnull(1);
|
||||
|
||||
void draw_dialog(Dialog *dialog);
|
||||
// HACK circular dependency...
|
||||
typedef struct PlayerCharacter PlayerCharacter;
|
||||
|
||||
bool page_dialog(Dialog **d) attr_nonnull(1);
|
||||
void process_dialog(Dialog **d) attr_nonnull(1);
|
||||
void dialog_set_playerchar_actor(Dialog *d, DialogSide side, PlayerCharacter *pc, DialogFace face)
|
||||
attr_nonnull(1, 3);
|
||||
|
||||
void dialog_set_image(Dialog *d, DialogSide side, const char *name)
|
||||
attr_nonnull(1, 3);
|
||||
|
||||
DialogAction *dialog_add_action(Dialog *d, DialogActionType side, const char *msg)
|
||||
attr_nonnull(1, 3);
|
||||
|
||||
void dialog_destroy(Dialog *d)
|
||||
attr_nonnull(1);
|
||||
|
||||
void dialog_draw(Dialog *dialog);
|
||||
|
||||
bool dialog_page(Dialog **d) attr_nonnull(1);
|
||||
void dialog_update(Dialog **d) attr_nonnull(1);
|
||||
|
||||
bool dialog_is_active(Dialog *d);
|
||||
|
||||
|
|
37
src/dialog/dialog_macros.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT-License
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
|
||||
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
|
||||
*/
|
||||
|
||||
#ifndef IGUARD_dialog_dialog_macros_h
|
||||
#define IGUARD_dialog_dialog_macros_h
|
||||
|
||||
#include "taisei.h"
|
||||
|
||||
#include "dialog.h"
|
||||
|
||||
#define DIALOG_SCRIPT(name) static void dialog_##name(Dialog *d)
|
||||
#define LEFT(message) dialog_add_action(d, DIALOG_MSG_LEFT, message)
|
||||
#define RIGHT(message) dialog_add_action(d, DIALOG_MSG_RIGHT, message)
|
||||
|
||||
#define EXPORT_DIALOG_SCRIPT(name) \
|
||||
PlayerDialogProcs dialog_##name = { \
|
||||
.stage1_pre_boss = dialog_##name##_stage1_pre_boss, \
|
||||
.stage1_post_boss = dialog_##name##_stage1_post_boss, \
|
||||
.stage2_pre_boss = dialog_##name##_stage2_pre_boss, \
|
||||
.stage2_post_boss = dialog_##name##_stage2_post_boss, \
|
||||
.stage3_pre_boss = dialog_##name##_stage3_pre_boss, \
|
||||
.stage3_post_boss = dialog_##name##_stage3_post_boss, \
|
||||
.stage4_pre_boss = dialog_##name##_stage4_pre_boss, \
|
||||
.stage4_post_boss = dialog_##name##_stage4_post_boss, \
|
||||
.stage5_post_midboss = dialog_##name##_stage5_post_midboss, \
|
||||
.stage5_pre_boss = dialog_##name##_stage5_pre_boss, \
|
||||
.stage5_post_boss = dialog_##name##_stage5_post_boss, \
|
||||
.stage6_pre_boss = dialog_##name##_stage6_pre_boss, \
|
||||
.stage6_pre_final = dialog_##name##_stage6_pre_final, \
|
||||
};
|
||||
|
||||
#endif // IGUARD_dialog_dialog_macros_h
|
|
@ -8,129 +8,113 @@
|
|||
|
||||
#include "taisei.h"
|
||||
|
||||
#include "marisa.h"
|
||||
#include "dialog_macros.h"
|
||||
|
||||
#define M(side,message) dadd_msg(d,side,message)
|
||||
|
||||
static void dialog_marisa_stage1_pre_boss(Dialog *d) {
|
||||
M(Left, "It’s gotten pretty cold ’round here. I wish I brought a sweater.");
|
||||
M(Right, "Every time there’s an incident, we fairies show up to stop weak humans like you from spoiling the fun!");
|
||||
M(Left, "So, you’re callin’ me weak?");
|
||||
M(Right, "Weak to cold for sure! I’ll turn you into a human-sized popsicle!");
|
||||
M(Left, "I’d like to see ya try.");
|
||||
DIALOG_SCRIPT(marisa_stage1_pre_boss) {
|
||||
LEFT("It’s gotten pretty cold ’round here. I wish I brought a sweater.");
|
||||
RIGHT("Every time there’s an incident, we fairies show up to stop weak humans like you from spoiling the fun!");
|
||||
LEFT("So, you’re callin’ me weak?");
|
||||
RIGHT("Weak to cold for sure! I’ll turn you into a human-sized popsicle!");
|
||||
LEFT("I’d like to see ya try.");
|
||||
}
|
||||
|
||||
static void dialog_marisa_stage1_post_boss(Dialog *d) {
|
||||
M(Right, "Waah, it’s hot! I’m gonna melt!");
|
||||
M(Left, "I’ve made the lake a lot warmer now, so ya can’t freeze anyone.");
|
||||
DIALOG_SCRIPT(marisa_stage1_post_boss) {
|
||||
RIGHT("Waah, it’s hot! I’m gonna melt!");
|
||||
LEFT("I’ve made the lake a lot warmer now, so ya can’t freeze anyone.");
|
||||
}
|
||||
|
||||
static void dialog_marisa_stage2_pre_boss(Dialog *d) {
|
||||
M(Right, "I can’t let you pass any further than this. Please go back down the mountain.");
|
||||
M(Left, "So, is that your misfortune talkin’?");
|
||||
M(Right, "Exploring that tunnel is only going to lead you to ruin. I’ll protect you by driving you away!");
|
||||
M(Left, "I can make dumb decisions on my own, thanks.");
|
||||
M(Right, "A bad attitude like that is destined to be cursed from the beginning. I’ll send you packing home as a favor to you, so you don’t get hurt further by your terrible ideas!");
|
||||
DIALOG_SCRIPT(marisa_stage2_pre_boss) {
|
||||
RIGHT("I can’t let you pass any further than this. Please go back down the mountain.");
|
||||
LEFT("So, is that your misfortune talkin’?");
|
||||
RIGHT("Exploring that tunnel is only going to lead you to ruin. I’ll protect you by driving you away!");
|
||||
LEFT("I can make dumb decisions on my own, thanks.");
|
||||
RIGHT("A bad attitude like that is destined to be cursed from the beginning. I’ll send you packing home as a favor to you, so you don’t get hurt further by your terrible ideas!");
|
||||
}
|
||||
|
||||
static void dialog_marisa_stage2_post_boss(Dialog *d) {
|
||||
M(Left, "Somehow I already feel luckier after beating ya. Fixin’ the border should be no sweat!");
|
||||
M(Right, "It’s as much as I can do since I cannot stop you. But maybe you could reconsider…?");
|
||||
M(Left, "Nope! I’m way too excited!");
|
||||
DIALOG_SCRIPT(marisa_stage2_post_boss) {
|
||||
LEFT("Somehow I already feel luckier after beating ya. Fixin’ the border should be no sweat!");
|
||||
RIGHT("It’s as much as I can do since I cannot stop you. But maybe you could reconsider…?");
|
||||
LEFT("Nope! I’m way too excited!");
|
||||
}
|
||||
|
||||
static void dialog_marisa_stage3_pre_boss(Dialog *d) {
|
||||
M(Left, "Huh, didn’t expect a bug to make it this far down the tunnel.");
|
||||
M(Right, "All of this beautiful light, and you didn’t expect me to be drawn to it?");
|
||||
M(Left, "I expected ya to lose, that’s all.");
|
||||
M(Right, "I’m nowhere near as weak as you think, human! In fact, being here has made me stronger than ever! That’s because I’m the one that made this tunnel and broke the barrier,");
|
||||
M(Right, "in order to finally show you all the true merit of insect power!");
|
||||
M(Left, "I can’t really say I believe ya on that point, bein’ that you’re just a bug ’n all.");
|
||||
M(Right, "Ha! Watch me put on a grand light show that will put your dud fireworks to shame!");
|
||||
DIALOG_SCRIPT(marisa_stage3_pre_boss) {
|
||||
LEFT("Huh, didn’t expect a bug to make it this far down the tunnel.");
|
||||
RIGHT("All of this beautiful light, and you didn’t expect me to be drawn to it?");
|
||||
LEFT("I expected ya to lose, that’s all.");
|
||||
RIGHT("I’m nowhere near as weak as you think, human! In fact, being here has made me stronger than ever! That’s because I’m the one that made this tunnel and broke the barrier,");
|
||||
RIGHT("in order to finally show you all the true merit of insect power!");
|
||||
LEFT("I can’t really say I believe ya on that point, bein’ that you’re just a bug ’n all.");
|
||||
RIGHT("Ha! Watch me put on a grand light show that will put your dud fireworks to shame!");
|
||||
}
|
||||
|
||||
static void dialog_marisa_stage3_post_boss(Dialog *d) {
|
||||
M(Left, "So where’s the finale? Nothing’s changed.");
|
||||
M(Right, "I was lying! I just wanted to take you down a peg with my new magic!");
|
||||
M(Left |