Skip to content

Commit

Permalink
Add UI support for variable number of invaders and invasion repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
crudelios committed Oct 7, 2024
1 parent 31fb5ac commit 640fbd3
Show file tree
Hide file tree
Showing 5 changed files with 376 additions and 48 deletions.
12 changes: 6 additions & 6 deletions src/graphics/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,37 +510,37 @@ void text_draw_with_money(const uint8_t *text, int value, const char *prefix, co
int text_draw_percentage(int value, int x_offset, int y_offset, font_t font)
{
uint8_t str[NUMBER_BUFFER_LENGTH];
number_to_string(str, value, '@', "%");
number_to_string(str, value, 0, "%");
return text_draw(str, x_offset, y_offset, font, 0);
}

int text_draw_label_and_number(const uint8_t *label, int value, const char *postfix, int x_offset, int y_offset, font_t font, color_t color)
{
uint8_t str[2 * NUMBER_BUFFER_LENGTH];
uint8_t *pos = label ? string_copy(label, str, NUMBER_BUFFER_LENGTH) : str;
number_to_string(pos, value, '@', postfix);
number_to_string(pos, value, 0, postfix);
return text_draw(str, x_offset, y_offset, font, color);
}

void text_draw_label_and_number_centered(const uint8_t *label, int value, const char *postfix, int x_offset, int y_offset, int box_width, font_t font, color_t color)
{
uint8_t str[2 * NUMBER_BUFFER_LENGTH];
uint8_t *pos = label ? string_copy(label, str, NUMBER_BUFFER_LENGTH) : str;
number_to_string(pos, value, '@', postfix);
number_to_string(pos, value, 0, postfix);
text_draw_centered(str, x_offset, y_offset, box_width, font, color);
}

void text_draw_number_centered(int value, int x_offset, int y_offset, int box_width, font_t font)
{
uint8_t str[NUMBER_BUFFER_LENGTH];
number_to_string(str, value, '@', " ");
number_to_string(str, value, 0, "");
text_draw_centered(str, x_offset, y_offset, box_width, font, 0);
}

void text_draw_number_centered_prefix(int value, char prefix, int x_offset, int y_offset, int box_width, font_t font)
{
uint8_t str[NUMBER_BUFFER_LENGTH];
number_to_string(str, value, prefix, " ");
number_to_string(str, value, prefix, "");
text_draw_centered(str, x_offset, y_offset, box_width, font, 0);
}

Expand All @@ -555,7 +555,7 @@ void text_draw_number_centered_colored(
int value, int x_offset, int y_offset, int box_width, font_t font, color_t color)
{
uint8_t str[NUMBER_BUFFER_LENGTH];
number_to_string(str, value, '@', " ");
number_to_string(str, value, 0, "");
text_draw_centered(str, x_offset, y_offset, box_width, font, color);
}

Expand Down
2 changes: 1 addition & 1 deletion src/scenario/invasion.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void scenario_invasion_update(int id, const invasion_t *invasion)
void scenario_invasion_delete(int id)
{
invasion_t *invasion = array_item(data.invasions, id);
invasion->type = INVASION_TYPE_NONE;
memset(invasion, 0, sizeof(invasion_t));
array_trim(data.invasions);
scenario.is_saved = 0;
}
Expand Down
17 changes: 17 additions & 0 deletions src/translation/english.c
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,23 @@ static translation_string all_strings[] = {
{TR_EDITOR_INVASION, "invasion"},
{TR_EDITOR_INVASIONS, "invasions"},
{TR_EDITOR_NEW_INVASION, "New invasion"},
{TR_EDITOR_INVASION_DATE, "Invasion date:"},
{TR_EDITOR_INVASION_SIZE, "Invasion size:"},
{TR_EDITOR_INVASION_BETWEEN, "Between"},
{TR_EDITOR_INVASION_AND, "and"},
{TR_EDITOR_INVASION_SIZE_UNITS, "units"},
{TR_EDITOR_INVASION_ENEMY_TYPE, "Enemy type:"},
{TR_EDITOR_INVASION_FROM, "From:"},
{TR_EDITOR_INVASION_ATTACK_PRIORITY, "Attack priority:"},
{TR_EDITOR_INVASION_REPEAT, "Repeat invasion:"},
{TR_EDITOR_INVASION_DO_NOT_REPEAT, "Do not repeat"},
{TR_EDITOR_INVASION_REPEAT_FOREVER, "Repeat forever"},
{TR_EDITOR_INVASION_REPEAT_ONCE, "Repeat once"},
{TR_EDITOR_INVASION_REPEAT_TWICE, "Repeat twice"},
{TR_EDITOR_INVASION_REPEAT_TEXT, "Repeat "},
{TR_EDITOR_INVASION_REPEAT_TIMES, " times"},
{TR_EDITOR_INVASION_REPEAT_FREQUENCY, "Repeat frequency:"},
{TR_EDITOR_INVASION_REPEAT_FREQUENCY_YEARS, "years"},
{TR_TOOLTIP_BUTTON_DELETE_COMMON_MESSAGES, "Delete common messages"}
};

Expand Down
17 changes: 17 additions & 0 deletions src/translation/translation.h
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,23 @@ typedef enum {
TR_EDITOR_INVASION,
TR_EDITOR_INVASIONS,
TR_EDITOR_NEW_INVASION,
TR_EDITOR_INVASION_DATE,
TR_EDITOR_INVASION_SIZE,
TR_EDITOR_INVASION_BETWEEN,
TR_EDITOR_INVASION_AND,
TR_EDITOR_INVASION_SIZE_UNITS,
TR_EDITOR_INVASION_ENEMY_TYPE,
TR_EDITOR_INVASION_FROM,
TR_EDITOR_INVASION_ATTACK_PRIORITY,
TR_EDITOR_INVASION_REPEAT,
TR_EDITOR_INVASION_DO_NOT_REPEAT,
TR_EDITOR_INVASION_REPEAT_FOREVER,
TR_EDITOR_INVASION_REPEAT_ONCE,
TR_EDITOR_INVASION_REPEAT_TWICE,
TR_EDITOR_INVASION_REPEAT_TEXT,
TR_EDITOR_INVASION_REPEAT_TIMES,
TR_EDITOR_INVASION_REPEAT_FREQUENCY,
TR_EDITOR_INVASION_REPEAT_FREQUENCY_YEARS,
TR_TOOLTIP_BUTTON_DELETE_COMMON_MESSAGES,
TRANSLATION_MAX_KEY
} translation_key;
Expand Down
Loading

0 comments on commit 640fbd3

Please sign in to comment.