Skip to content

Commit

Permalink
added column "Repeat frequency"
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenikus8 committed Feb 12, 2025
1 parent edf7a99 commit ec8dc04
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 29 deletions.
41 changes: 26 additions & 15 deletions src/window/editor/invasions.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ static void draw_background(void)
lang_text_draw(44, 15, 20, 12, FONT_LARGE_BLACK);

lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_INVASION_DATE, 30, 50, FONT_SMALL_PLAIN); // Invasion date:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_INVASION_SIZE, 170, 50, FONT_SMALL_PLAIN); // Invasion size:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_INVASION_ENEMY_TYPE, 305, 50, FONT_SMALL_PLAIN); // Enemy type:
lang_text_draw(CUSTOM_TRANSLATION, TR_PARAMETER_TYPE_INVASION_POINT, 420, 50, FONT_SMALL_PLAIN); // Invasion point
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REPEAT, 535, 50, FONT_SMALL_PLAIN); // "Repeat:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_INVASION_SIZE, 160, 50, FONT_SMALL_PLAIN); // Invasion size:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_INVASION_ENEMY_TYPE, 280, 50, FONT_SMALL_PLAIN); // Enemy type:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_INVASION_FROM, 398, 50, FONT_SMALL_PLAIN); // From:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REPEAT_FREQUENCY, 450, 30, FONT_SMALL_PLAIN); // Repeat frequency:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REPEAT_TEXT, 460, 50, FONT_SMALL_PLAIN); // Repeat
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REPEAT_FREQUENCY_YEARS, 532, 50, FONT_SMALL_PLAIN); // years

lang_text_draw_centered(13, 3, 0, 456, 640, FONT_NORMAL_BLACK);
lang_text_draw_multiline(152, 2, 20, 380, 600, FONT_NORMAL_BLACK);
Expand All @@ -131,33 +133,42 @@ static void draw_invasion_button(const grid_box_item *item)
const invasion_t *invasion = data.invasions[item->index];
text_draw_number(invasion->year, '+', " ", item->x + 10, item->y + 7, FONT_NORMAL_BLACK, 0);
lang_text_draw_year(scenario_property_start_year() + invasion->year, item->x + 50, item->y + 7, FONT_NORMAL_BLACK);
int width = text_draw_number(invasion->amount.min, '@', " ", item->x + 160, item->y + 7, FONT_NORMAL_BLACK, 0);
int width = text_draw_number(invasion->amount.min, '@', " ", item->x + 155, item->y + 7, FONT_NORMAL_BLACK, 0);
if (invasion->amount.max > invasion->amount.min) {
width += text_draw(string_from_ascii("-"), item->x + 155 + width, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw_number(invasion->amount.max, '@', " ", item->x + 150 + width, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw(string_from_ascii("-"), item->x + 150 + width, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw_number(invasion->amount.max, '@', " ", item->x + 145 + width, item->y + 7, FONT_NORMAL_BLACK, 0);
}

if (invasion->type == INVASION_TYPE_DISTANT_BATTLE) {
lang_text_draw(34, invasion->type, item->x + 280, item->y + 7, FONT_NORMAL_BLACK);
lang_text_draw(34, invasion->type, item->x + 255, item->y + 7, FONT_NORMAL_BLACK);
} else {
lang_text_draw(34, invasion->type, item->x + 280, item->y + 7, FONT_NORMAL_BLACK);
//lang_text_draw(44, 27, item->x + 460, item->y + 7, FONT_NORMAL_BLACK); // from
lang_text_draw(34, invasion->type, item->x + 255, item->y + 7, FONT_NORMAL_BLACK);
}

if (invasion->type != INVASION_TYPE_DISTANT_BATTLE) {
if (invasion->from + 1 == 9) {
width += text_draw(string_from_ascii("RND"), item->x + 434, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw(string_from_ascii("RND"), item->x + 385, item->y + 7, FONT_NORMAL_BLACK, 0);
} else {
text_draw_number(invasion->from + 1, '@', " ", item->x + 440, item->y + 7, FONT_NORMAL_BLACK, 0);
text_draw_number(invasion->from + 1, '@', " ", item->x + 391, item->y + 7, FONT_NORMAL_BLACK, 0);
}
}

if (invasion->repeat.times == INVASIONS_REPEAT_INFINITE) {
width += text_draw(string_from_ascii("INF"), 545, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw(string_from_ascii("INF"), 470, item->y + 7, FONT_NORMAL_BLACK, 0);
} else if (invasion->repeat.times == 0) {
width += text_draw(string_from_ascii("-"), 555, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw(string_from_ascii("-"), 480, item->y + 7, FONT_NORMAL_BLACK, 0);
} else {
text_draw_number(invasion->repeat.times, '@', " ", 538, item->y + 7, FONT_NORMAL_BLACK, 0);
text_draw_number(invasion->repeat.times, '@', " ", 465, item->y + 7, FONT_NORMAL_BLACK, 0);
}

if (invasion->repeat.times == 0) {
width += text_draw(string_from_ascii(" "), item->x + 500, item->y + 7, FONT_NORMAL_BLACK, 0);
} else if (invasion->repeat.times > 0 || invasion->repeat.times == INVASIONS_REPEAT_INFINITE) {
int width = text_draw_number(invasion->repeat.interval.min, '@', " ", item->x + 510, item->y + 7, FONT_NORMAL_BLACK, 0);
if (invasion->repeat.interval.max > invasion->repeat.interval.min) {
width += text_draw(string_from_ascii("-"), item->x + 500 + width, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw_number(invasion->repeat.interval.max, '@', " ", item->x + 490 + width, item->y + 7, FONT_NORMAL_BLACK, 0);
}
}
}

Expand Down
40 changes: 26 additions & 14 deletions src/window/editor/requests.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ static void draw_background(void)
lang_text_draw(44, 14, 20, 12, FONT_LARGE_BLACK);

lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REQUEST_DATE, 30, 50, FONT_SMALL_PLAIN); // Request date:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REQUEST_AMOUNT, 180, 50, FONT_SMALL_PLAIN); // Amount:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REQUEST_RESOURCE, 310, 50, FONT_SMALL_PLAIN); // Resource:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REQUEST_DEADLINE, 440, 50, FONT_SMALL_PLAIN); // Deadline:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REPEAT, 530, 50, FONT_SMALL_PLAIN); // Repeat:

lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REQUEST_AMOUNT, 150, 50, FONT_SMALL_PLAIN); // Amount:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REQUEST_RESOURCE, 270, 50, FONT_SMALL_PLAIN); // Resource:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REQUEST_DEADLINE, 380, 50, FONT_SMALL_PLAIN); // Deadline:
//lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REPEAT, 530, 50, FONT_SMALL_PLAIN); // Repeat:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REPEAT_FREQUENCY, 450, 30, FONT_SMALL_PLAIN); // Repeat frequency:
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REPEAT_TEXT, 460, 50, FONT_SMALL_PLAIN); // Repeat
lang_text_draw(CUSTOM_TRANSLATION, TR_EDITOR_REPEAT_FREQUENCY_YEARS, 532, 50, FONT_SMALL_PLAIN); // years

if (!data.requests_in_use) {
lang_text_draw_centered(44, 19, 0, 165, 640, FONT_LARGE_BLACK);
Expand All @@ -136,27 +138,37 @@ static void draw_request_button(const grid_box_item *item)
const scenario_request *request = data.requests[item->index];
text_draw_number(request->year, '+', " ", item->x + 10, item->y + 7, FONT_NORMAL_BLACK, 0);
lang_text_draw_year(scenario_property_start_year() + request->year, item->x + 50, item->y + 7, FONT_NORMAL_BLACK);
int width = text_draw_number(request->amount.min, '@', " ", item->x + 160, item->y + 7, FONT_NORMAL_BLACK, 0);
int width = text_draw_number(request->amount.min, '@', " ", item->x + 135, item->y + 7, FONT_NORMAL_BLACK, 0);
if (request->amount.max > request->amount.min) {
width += text_draw(string_from_ascii("-"), item->x + 155 + width, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw_number(request->amount.max, '@', " ", item->x + 150 + width, item->y + 7,
width += text_draw(string_from_ascii("-"), item->x + 130 + width, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw_number(request->amount.max, '@', " ", item->x + 125 + width, item->y + 7,
FONT_NORMAL_BLACK, 0);
}
int image_id = resource_get_data(request->resource)->image.editor.icon;
const image *img = image_get(image_id);
int base_height = (item->height - img->original.height) / 2;
image_draw(image_id, item->x + 290, item->y + base_height, COLOR_MASK_NONE, SCALE_NONE);
text_draw(resource_get_data(request->resource)->text, item->x + 320, item->y + 7,
image_draw(image_id, item->x + 260, item->y + base_height, COLOR_MASK_NONE, SCALE_NONE);
text_draw(resource_get_data(request->resource)->text, item->x + 290, item->y + 7,
FONT_NORMAL_BLACK, 0);

text_draw_number(request->deadline_years, '@', " ", 460, item->y + 7, FONT_NORMAL_BLACK, 0);
text_draw_number(request->deadline_years, '@', " ", 400, item->y + 7, FONT_NORMAL_BLACK, 0);

if (request->repeat.times == REQUESTS_REPEAT_INFINITE) {
width += text_draw(string_from_ascii("INF"), 545, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw(string_from_ascii("INF"), 470, item->y + 7, FONT_NORMAL_BLACK, 0);
} else if (request->repeat.times == 0) {
width += text_draw(string_from_ascii("-"), 555, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw(string_from_ascii("-"), 480, item->y + 7, FONT_NORMAL_BLACK, 0);
} else {
text_draw_number(request->repeat.times, '@', " ", 538, item->y + 7, FONT_NORMAL_BLACK, 0);
text_draw_number(request->repeat.times, '@', " ", 465, item->y + 7, FONT_NORMAL_BLACK, 0);
}

if (request->repeat.times == 0) {
width += text_draw(string_from_ascii(" "), item->x + 500, item->y + 7, FONT_NORMAL_BLACK, 0);
} else if (request->repeat.times > 0 || request->repeat.times == REQUESTS_REPEAT_INFINITE) {
int width = text_draw_number(request->repeat.interval.min, '@', " ", item->x + 510, item->y + 7, FONT_NORMAL_BLACK, 0);
if (request->repeat.interval.max > request->repeat.interval.min) {
width += text_draw(string_from_ascii("-"), item->x + 500 + width, item->y + 7, FONT_NORMAL_BLACK, 0);
width += text_draw_number(request->repeat.interval.max, '@', " ", item->x + 490 + width, item->y + 7, FONT_NORMAL_BLACK, 0);
}
}

}
Expand Down

0 comments on commit ec8dc04

Please sign in to comment.