Skip to content

Commit 97f99c5

Browse files
authored
Task widget improvements (#18243)
1 parent fa42321 commit 97f99c5

5 files changed

Lines changed: 77 additions & 69 deletions

File tree

gfx/gfx_widgets.c

Lines changed: 69 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,6 @@ static void gfx_widgets_layout(
882882
if (!p_dispwidget->gfx_widgets_icons_textures[MENU_WIDGETS_ICON_HOURGLASS])
883883
p_dispwidget->msg_queue_task_text_start_x -= p_dispwidget->gfx_widget_fonts.msg_queue.glyph_width * 2.0f;
884884

885-
p_dispwidget->msg_queue_task_hourglass_x = p_dispwidget->msg_queue_rect_start_x + (p_dispwidget->simple_widget_padding / 2.5f);
886-
887885
p_dispwidget->msg_queue_default_rect_width_menu_alive
888886
= p_dispwidget->gfx_widget_fonts.msg_queue.glyph_width * 40.0f;
889887
p_dispwidget->msg_queue_default_rect_width = p_dispwidget->last_video_width
@@ -1145,20 +1143,14 @@ static void gfx_widgets_draw_task_msg(
11451143
unsigned video_width,
11461144
unsigned video_height)
11471145
{
1148-
/* Color of first progress bar in a task message */
1149-
static float msg_queue_task_progress_1[16] = COLOR_HEX_TO_FLOAT(BG_COLOR_DEFAULT, 1.0f);
1150-
/* Color of second progress bar in a task message
1151-
* (for multiple tasks with same message) */
1152-
static float msg_queue_task_progress_2[16] = COLOR_HEX_TO_FLOAT(BG_COLOR_PROGRESS, 1.0f);
1153-
/* Margin bar */
1154-
static float msg_queue_bar[16] = COLOR_HEX_TO_FLOAT(BG_COLOR_MARGIN, 1.0f);
1155-
/* Red icon */
1156-
static float msg_queue_task_negative[16] = COLOR_HEX_TO_FLOAT(ICON_COLOR_RED, 1.0f);
1157-
/* Green icon */
1158-
static float msg_queue_task_positive[16] = COLOR_HEX_TO_FLOAT(ICON_COLOR_GREEN, 1.0f);
1159-
/* Blue icon */
1160-
static float msg_queue_task_neutral[16] = COLOR_HEX_TO_FLOAT(ICON_COLOR_BLUE, 1.0f);
1161-
1146+
static float msg_queue_background[16] = COLOR_HEX_TO_FLOAT(BG_COLOR_DEFAULT, 1.0f);
1147+
static float msg_queue_bar[16] = COLOR_HEX_TO_FLOAT(BG_COLOR_MARGIN, 1.0f);
1148+
static float msg_queue_task_progress[16] = COLOR_HEX_TO_FLOAT(BG_COLOR_PROGRESS, 1.0f);
1149+
static float msg_queue_task_negative[16] = COLOR_HEX_TO_FLOAT(ICON_COLOR_RED, 1.0f);
1150+
static float msg_queue_task_positive[16] = COLOR_HEX_TO_FLOAT(ICON_COLOR_GREEN, 1.0f);
1151+
static float msg_queue_task_neutral[16] = COLOR_HEX_TO_FLOAT(ICON_COLOR_BLUE, 1.0f);
1152+
1153+
unsigned msg_queue_height = p_dispwidget->msg_queue_height;
11621154
unsigned text_color;
11631155
unsigned bar_width;
11641156

@@ -1170,12 +1162,13 @@ static void gfx_widgets_draw_task_msg(
11701162
float text_y_base;
11711163

11721164
float *msg_queue_current_background;
1173-
float *msg_queue_current_bar;
1165+
float *msg_queue_current_progress;
11741166

11751167
size_t _len = 0;
1168+
size_t task_percentage_offset = 0;
11761169
char task_percentage[256] = "";
11771170
bool draw_msg_new = false;
1178-
size_t task_percentage_offset = 0;
1171+
bool msg_alternative = (task_get_flags(msg->task_ptr) & RETRO_TASK_FLG_ALTERNATIVE_LOOK);
11791172

11801173
if (msg->msg_new)
11811174
draw_msg_new = !string_is_equal(msg->msg_new, msg->msg);
@@ -1184,43 +1177,58 @@ static void gfx_widgets_draw_task_msg(
11841177
{
11851178
if (msg->flags & DISPWIDG_FLAG_TASK_ERROR)
11861179
_len = strlcpy(task_percentage, msg_hash_to_str(MSG_ERROR), sizeof(task_percentage));
1180+
1181+
/* Not finished yet really */
1182+
if (msg->task_progress > 0 && msg->task_progress < 100)
1183+
msg->flags &= ~DISPWIDG_FLAG_TASK_FINISHED;
11871184
}
11881185
else if (msg->task_progress >= 0 && msg->task_progress <= 100)
11891186
_len = snprintf(task_percentage, sizeof(task_percentage),
11901187
"%i%%", msg->task_progress);
11911188

11921189
task_percentage_offset = p_dispwidget->gfx_widget_fonts.msg_queue.glyph_width * (_len + 1);
1193-
rect_width = p_dispwidget->msg_queue_padding * 5.0f + msg->width + task_percentage_offset;
1190+
rect_width = (msg_alternative)
1191+
? video_width
1192+
: (p_dispwidget->msg_queue_padding * 5.0f) + msg->width + task_percentage_offset;
11941193
bar_width = rect_width * msg->task_progress/100.0f;
11951194
text_color = COLOR_TEXT_ALPHA(TEXT_COLOR_INFO, (unsigned)(msg->alpha*255.0f));
11961195

11971196
/* Rect */
1198-
msg_queue_current_background = msg_queue_task_progress_1;
1197+
if ( msg->flags & DISPWIDG_FLAG_TASK_FINISHED
1198+
&& msg_alternative)
1199+
msg_queue_current_background = msg_queue_task_progress;
1200+
else
1201+
msg_queue_current_background = msg_queue_background;
11991202

1200-
if (msg->flags & DISPWIDG_FLAG_TASK_FINISHED)
1201-
{
1202-
if (msg->task_count == 1)
1203-
msg_queue_current_background = msg_queue_task_progress_1;
1204-
else
1205-
msg_queue_current_background = msg_queue_task_progress_2;
1206-
}
1203+
if (msg_alternative)
1204+
msg_queue_height *= 1.25f;
12071205

12081206
rect_x = p_dispwidget->msg_queue_rect_start_x;
12091207
rect_y = video_height - msg->offset_y;
1210-
rect_height = p_dispwidget->msg_queue_height / 2;
1208+
rect_height = msg_queue_height / 2;
12111209
rect_margin = p_dispwidget->simple_widget_padding * 0.15f;
12121210

1213-
gfx_display_set_alpha(msg_queue_bar, msg->alpha);
1214-
gfx_display_draw_quad(
1215-
p_disp,
1216-
userdata,
1217-
video_width, video_height,
1218-
rect_x, rect_y,
1219-
rect_margin, rect_height,
1220-
video_width, video_height,
1221-
msg_queue_bar,
1222-
NULL
1223-
);
1211+
if (msg_alternative)
1212+
{
1213+
rect_x = 0;
1214+
rect_y = video_height - rect_height;
1215+
rect_margin = 0;
1216+
}
1217+
1218+
if (rect_margin)
1219+
{
1220+
gfx_display_set_alpha(msg_queue_bar, msg->alpha);
1221+
gfx_display_draw_quad(
1222+
p_disp,
1223+
userdata,
1224+
video_width, video_height,
1225+
rect_x, rect_y,
1226+
rect_margin, rect_height,
1227+
video_width, video_height,
1228+
msg_queue_bar,
1229+
NULL
1230+
);
1231+
}
12241232

12251233
gfx_display_set_alpha(msg_queue_current_background, msg->alpha);
12261234
gfx_display_draw_quad(
@@ -1239,21 +1247,17 @@ static void gfx_widgets_draw_task_msg(
12391247
&& (msg->task_progress >= 0)
12401248
&& (msg->task_progress <= 100))
12411249
{
1242-
if (msg->task_count == 1)
1243-
msg_queue_current_bar = msg_queue_task_progress_1;
1244-
else
1245-
msg_queue_current_bar = msg_queue_task_progress_2;
1250+
msg_queue_current_progress = msg_queue_task_progress;
12461251

1247-
gfx_display_set_alpha(msg_queue_current_bar, 1.0f);
1252+
gfx_display_set_alpha(msg_queue_current_progress, msg->alpha);
12481253
gfx_display_draw_quad(
12491254
p_disp,
12501255
userdata,
12511256
video_width, video_height,
1252-
p_dispwidget->msg_queue_rect_start_x + rect_margin,
1253-
video_height - msg->offset_y,
1257+
rect_x + rect_margin, rect_y,
12541258
bar_width, rect_height,
12551259
video_width, video_height,
1256-
msg_queue_current_bar,
1260+
msg_queue_current_progress,
12571261
NULL
12581262
);
12591263
}
@@ -1268,11 +1272,19 @@ static void gfx_widgets_draw_task_msg(
12681272
int texture = MENU_WIDGETS_ICON_CHECK;
12691273
float *color = msg_queue_task_positive;
12701274

1275+
gfx_display_set_alpha(color, msg->alpha);
1276+
12711277
if (!(msg->flags & DISPWIDG_FLAG_TASK_FINISHED))
12721278
{
12731279
texture = MENU_WIDGETS_ICON_HOURGLASS;
12741280
color = msg_queue_task_neutral;
12751281
radians = msg->hourglass_rotation;
1282+
1283+
if (msg_alternative)
1284+
{
1285+
color = msg_queue_bar;
1286+
gfx_display_set_alpha(color, msg->alpha * 0.5f);
1287+
}
12761288
}
12771289
else if (msg->flags & DISPWIDG_FLAG_POSITIVE)
12781290
{
@@ -1285,17 +1297,16 @@ static void gfx_widgets_draw_task_msg(
12851297
color = msg_queue_task_negative;
12861298
}
12871299

1288-
gfx_display_set_alpha(color, msg->alpha);
12891300
gfx_widgets_draw_icon(
12901301
userdata,
12911302
p_disp,
12921303
video_width,
12931304
video_height,
1294-
p_dispwidget->msg_queue_height / 2.5f,
1295-
p_dispwidget->msg_queue_height / 2.5f,
1305+
msg_queue_height / 2.5f,
1306+
msg_queue_height / 2.5f,
12961307
p_dispwidget->gfx_widgets_icons_textures[texture],
1297-
p_dispwidget->msg_queue_task_hourglass_x + (p_dispwidget->msg_queue_height / MSG_QUEUE_FONT_SIZE),
1298-
video_height - msg->offset_y + (p_dispwidget->msg_queue_height / MSG_QUEUE_FONT_SIZE),
1308+
rect_x + (msg_queue_height / 9.0f) + (msg_queue_height / MSG_QUEUE_FONT_SIZE),
1309+
rect_y + (msg_queue_height / MSG_QUEUE_FONT_SIZE),
12991310
radians,
13001311
cosine,
13011312
sine,
@@ -1305,9 +1316,8 @@ static void gfx_widgets_draw_task_msg(
13051316
dispctx->blend_end(userdata);
13061317

13071318
/* Text */
1308-
text_y_base = video_height
1309-
- msg->offset_y
1310-
+ p_dispwidget->msg_queue_height / 4.0f
1319+
text_y_base = rect_y
1320+
+ (msg_queue_height / 4.0f)
13111321
+ p_dispwidget->gfx_widget_fonts.msg_queue.line_centre_offset;
13121322

13131323
if (draw_msg_new)
@@ -1323,7 +1333,7 @@ static void gfx_widgets_draw_task_msg(
13231333
gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.msg_queue,
13241334
msg->msg_new,
13251335
p_dispwidget->msg_queue_task_text_start_x,
1326-
text_y_base - p_dispwidget->msg_queue_height / 2.0f + msg->msg_transition_animation,
1336+
text_y_base - msg_queue_height / 2.0f + msg->msg_transition_animation,
13271337
video_width, video_height,
13281338
text_color,
13291339
TEXT_ALIGN_LEFT,
@@ -1352,8 +1362,7 @@ static void gfx_widgets_draw_task_msg(
13521362
text_color = COLOR_TEXT_ALPHA(TEXT_COLOR_INFO, (unsigned)(msg->alpha/2*255.0f));
13531363
gfx_widgets_draw_text(&p_dispwidget->gfx_widget_fonts.msg_queue,
13541364
task_percentage,
1355-
p_dispwidget->msg_queue_rect_start_x
1356-
+ rect_width - p_dispwidget->gfx_widget_fonts.msg_queue.glyph_width,
1365+
rect_x + rect_width - p_dispwidget->gfx_widget_fonts.msg_queue.glyph_width * 2,
13571366
text_y_base,
13581367
video_width, video_height,
13591368
text_color,
@@ -1396,7 +1405,6 @@ static void gfx_widgets_draw_regular_msg(
13961405
else
13971406
msg_queue_info = msg_queue_info_blue;
13981407

1399-
/* Icon */
14001408
gfx_display_set_alpha(msg_queue_info, msg->alpha);
14011409
gfx_display_set_alpha(p_dispwidget->pure_white, msg->alpha);
14021410
gfx_display_set_alpha(p_dispwidget->msg_queue_bg, msg->alpha);
@@ -1498,6 +1506,7 @@ static void gfx_widgets_draw_regular_msg(
14981506
dispctx->scissor_end(userdata, video_width, video_height);
14991507
}
15001508

1509+
/* Icon */
15011510
if (p_dispwidget->flags & DISPGFX_WIDGET_FLAG_MSG_QUEUE_HAS_ICONS)
15021511
{
15031512
float icon_size = p_dispwidget->msg_queue_icon_size_x / ((msg->flags & DISPWIDG_FLAG_SMALL) ? 2 : 1);
@@ -1517,7 +1526,7 @@ static void gfx_widgets_draw_regular_msg(
15171526
icon_size,
15181527
p_dispwidget->gfx_widgets_icons_textures[MENU_WIDGETS_ICON_INFO],
15191528
p_dispwidget->msg_queue_rect_start_x
1520-
+ (p_dispwidget->simple_widget_padding / 4.0f),
1529+
+ (p_dispwidget->msg_queue_height / 9.0f),
15211530
video_height - msg->offset_y - p_dispwidget->msg_queue_icon_offset_y,
15221531
0.0f, /* rad */
15231532
(invert_y ? -1.0f : 1.0f), /* cosine */

gfx/gfx_widgets.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@
5050
#define BG_COLOR_WHITE 0xFFFFFF
5151
#define BG_COLOR_DEFAULT 0x161616
5252
#define BG_COLOR_PROGRESS 0x323232
53-
#define BG_COLOR_MARGIN 0xCCCCCC
53+
#define BG_COLOR_MARGIN 0xBBBBBB
5454

5555
#define ICON_COLOR_RED 0xD82020
5656
#define ICON_COLOR_GREEN 0x20D820
57-
#define ICON_COLOR_BLUE 0x209BD8
57+
#define ICON_COLOR_BLUE 0x208BD8
5858
#define ICON_COLOR_YELLOW 0xD8BA20
5959

6060
RETRO_BEGIN_DECLS
@@ -239,7 +239,6 @@ typedef struct dispgfx_widget
239239
unsigned msg_queue_regular_padding_x;
240240
unsigned msg_queue_regular_text_start;
241241
unsigned msg_queue_task_text_start_x;
242-
unsigned msg_queue_task_hourglass_x;
243242
unsigned divider_width_1px;
244243

245244
float last_scale_factor;

tasks/task_core_updater.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,6 @@ static void task_core_updater_download_handler(retro_task_t *task)
979979
return;
980980

981981
task_finished:
982-
983982
if (task)
984983
task_set_flags(task, RETRO_TASK_FLG_FINISHED, true);
985984

@@ -1787,7 +1786,6 @@ static void task_play_feature_delivery_core_install_handler(
17871786
return;
17881787

17891788
task_finished:
1790-
17911789
if (task)
17921790
task_set_flags(task, RETRO_TASK_FLG_FINISHED, true);
17931791

tasks/task_decompress.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,16 @@ void *task_push_decompress(
334334

335335
_len = strlcpy(tmp,
336336
msg_hash_to_str(MSG_EXTRACTING), sizeof(tmp));
337-
tmp[ _len] = ' ';
338-
tmp[++_len] = '\'';
337+
tmp[ _len] = ':';
338+
tmp[++_len] = ' ';
339339
tmp[++_len] = '\0';
340340
_len += strlcpy(tmp + _len,
341341
path_basename(source_file),
342342
sizeof(tmp) - _len);
343-
tmp[_len ] = '\'';
344343
tmp[++_len] = '\0';
345344

346345
t->title = strdup(tmp);
346+
t->flags |= RETRO_TASK_FLG_ALTERNATIVE_LOOK;
347347
if (mute)
348348
t->flags |= RETRO_TASK_FLG_MUTE;
349349
else

tasks/task_http.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ static void *task_push_http_transfer_generic(
291291
t->cleanup = task_http_transfer_cleanup;
292292
t->user_data = user_data;
293293
t->progress = -1;
294+
t->flags |= RETRO_TASK_FLG_ALTERNATIVE_LOOK;
294295
if (mute)
295296
t->flags |= RETRO_TASK_FLG_MUTE;
296297
else
@@ -450,7 +451,8 @@ void* task_push_http_transfer_file(const char* url, bool mute,
450451
s = url;
451452

452453
_len = strlcpy(tmp, msg_hash_to_str(MSG_DOWNLOADING), sizeof(tmp));
453-
tmp[ _len] = ' ';
454+
tmp[ _len] = ':';
455+
tmp[++_len] = ' ';
454456
tmp[++_len] = '\0';
455457

456458
if (string_ends_with_size(s, ".index",

0 commit comments

Comments
 (0)