Skip to content

Commit

Permalink
Add Employment overlay
Browse files Browse the repository at this point in the history
Better sorting for overlays in Commerce overlay submenu.
Sort overlay hotkeys in config window in the same order as in-game overlay menu.
  • Loading branch information
Ouaz committed Feb 21, 2024
1 parent 323e1fb commit c7f0502
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 46 deletions.
13 changes: 7 additions & 6 deletions src/core/hotkey_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ static const char *ini_keys[] = {
"undo",
"mothball_toggle",
"storage_order",
"show_overlay_efficiency",
"show_overlay_food_stocks",
"show_overlay_logistics",
"show_overlay_entertainment",
"show_overlay_education",
"show_overlay_school",
Expand All @@ -113,13 +110,17 @@ static const char *ini_keys[] = {
"show_overlay_clinic",
"show_overlay_hospital",
"show_overlay_sickness",
"show_overlay_logistics",
"show_overlay_food_stocks",
"show_overlay_efficiency",
"show_overlay_mothball",
"show_overlay_tax_income",
"show_overlay_levy",
"show_overlay_employment",
"show_overlay_religion",
"show_overlay_desirability",
"show_overlay_sentiment",
"show_overlay_mothball",
"show_overlay_religion",
"show_overlay_roads",
"show_overlay_levy",
"rotate_map_north",
"build_wheat_farm",
"show_empire_map",
Expand Down
13 changes: 7 additions & 6 deletions src/core/hotkey_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ typedef enum {
HOTKEY_UNDO,
HOTKEY_MOTHBALL_TOGGLE,
HOTKEY_STORAGE_ORDER,
HOTKEY_SHOW_OVERLAY_EFFICIENCY,
HOTKEY_SHOW_OVERLAY_FOOD_STOCKS,
HOTKEY_SHOW_OVERLAY_LOGISTICS,
HOTKEY_SHOW_OVERLAY_ENTERTAINMENT,
HOTKEY_SHOW_OVERLAY_EDUCATION,
HOTKEY_SHOW_OVERLAY_SCHOOL,
Expand All @@ -99,13 +96,17 @@ typedef enum {
HOTKEY_SHOW_OVERLAY_CLINIC,
HOTKEY_SHOW_OVERLAY_HOSPITAL,
HOTKEY_SHOW_OVERLAY_SICKNESS,
HOTKEY_SHOW_OVERLAY_LOGISTICS,
HOTKEY_SHOW_OVERLAY_FOOD_STOCKS,
HOTKEY_SHOW_OVERLAY_EFFICIENCY,
HOTKEY_SHOW_OVERLAY_MOTHBALL,
HOTKEY_SHOW_OVERLAY_TAX_INCOME,
HOTKEY_SHOW_OVERLAY_LEVY,
HOTKEY_SHOW_OVERLAY_EMPLOYMENT,
HOTKEY_SHOW_OVERLAY_RELIGION,
HOTKEY_SHOW_OVERLAY_DESIRABILITY,
HOTKEY_SHOW_OVERLAY_SENTIMENT,
HOTKEY_SHOW_OVERLAY_MOTHBALL,
HOTKEY_SHOW_OVERLAY_RELIGION,
HOTKEY_SHOW_OVERLAY_ROADS,
HOTKEY_SHOW_OVERLAY_LEVY,
HOTKEY_ROTATE_MAP_NORTH,
HOTKEY_BUILD_WHEAT_FARM,
HOTKEY_SHOW_EMPIRE_MAP,
Expand Down
1 change: 1 addition & 0 deletions src/game/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum {
OVERLAY_EFFICIENCY = 39,
OVERLAY_STORAGES = 40,
OVERLAY_HEALTH = 41,
OVERLAY_EMPLOYMENT = 42,
};

void game_state_init(void);
Expand Down
48 changes: 26 additions & 22 deletions src/input/hotkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,6 @@ static void set_definition_for_action(hotkey_action action, hotkey_definition *d
case HOTKEY_PASTE_BUILDING_SETTINGS:
def->action = &data.hotkey_state.paste_building_settings;
break;
case HOTKEY_SHOW_OVERLAY_EFFICIENCY:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_EFFICIENCY;
break;
case HOTKEY_SHOW_OVERLAY_FOOD_STOCKS:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_FOOD_STOCKS;
break;
case HOTKEY_SHOW_OVERLAY_LOGISTICS:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_LOGISTICS;
break;
case HOTKEY_SHOW_OVERLAY_ENTERTAINMENT:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_ENTERTAINMENT;
Expand Down Expand Up @@ -383,33 +371,49 @@ static void set_definition_for_action(hotkey_action action, hotkey_definition *d
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_SICKNESS;
break;
case HOTKEY_SHOW_OVERLAY_TAX_INCOME:
case HOTKEY_SHOW_OVERLAY_LOGISTICS:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_TAX_INCOME;
def->value = OVERLAY_LOGISTICS;
break;
case HOTKEY_SHOW_OVERLAY_DESIRABILITY:
case HOTKEY_SHOW_OVERLAY_FOOD_STOCKS:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_DESIRABILITY;
def->value = OVERLAY_FOOD_STOCKS;
break;
case HOTKEY_SHOW_OVERLAY_SENTIMENT:
case HOTKEY_SHOW_OVERLAY_EFFICIENCY:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_SENTIMENT;
def->value = OVERLAY_EFFICIENCY;
break;
case HOTKEY_SHOW_OVERLAY_MOTHBALL:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_MOTHBALL;
break;
case HOTKEY_SHOW_OVERLAY_TAX_INCOME:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_TAX_INCOME;
break;
case HOTKEY_SHOW_OVERLAY_LEVY:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_LEVY;
break;
case HOTKEY_SHOW_OVERLAY_EMPLOYMENT:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_EMPLOYMENT;
break;
case HOTKEY_SHOW_OVERLAY_RELIGION:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_RELIGION;
break;
case HOTKEY_SHOW_OVERLAY_ROADS:
case HOTKEY_SHOW_OVERLAY_DESIRABILITY:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_ROADS;
def->value = OVERLAY_DESIRABILITY;
break;
case HOTKEY_SHOW_OVERLAY_LEVY:
case HOTKEY_SHOW_OVERLAY_SENTIMENT:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_LEVY;
def->value = OVERLAY_SENTIMENT;
break;
case HOTKEY_SHOW_OVERLAY_ROADS:
def->action = &data.hotkey_state.show_overlay;
def->value = OVERLAY_ROADS;
break;
case HOTKEY_ROTATE_MAP_NORTH:
def->action = &data.hotkey_state.rotate_map_north;
Expand Down
8 changes: 7 additions & 1 deletion src/translation/english.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,12 @@ static translation_string all_strings[] = {
{TR_BUTTON_BACK_TO_MAIN_MENU, "Exit to main menu" },
{TR_LABEL_PAUSE_MENU, "Pause" },
{TR_OVERLAY_LEVY, "Levies" },
{TR_TOOLTIP_OVERLAY_LEVY, " denarii paid monthly in levies." },
{TR_TOOLTIP_OVERLAY_LEVY, " denarii paid monthly in levies" },
{TR_OVERLAY_EMPLOYMENT, "Employment" },
{TR_TOOLTIP_OVERLAY_EMPLOYMENT_FULL, "This building is fully staffed" },
{TR_TOOLTIP_OVERLAY_EMPLOYMENT_MISSING_1, " employee needed in this building" },
{TR_TOOLTIP_OVERLAY_EMPLOYMENT_MISSING_2, " employees needed in this building" },
{TR_TOOLTIP_OVERLAY_EMPLOYMENT_MOTHBALL, " employees needed in this building (mothballed)" },
{TR_MAP_EDITOR_OPTIONS, "Scenario settings" },
{TR_BUILDING_TAVERN, "Tavern" },
{TR_BUILDING_GRAND_GARDEN, "Grand garden" },
Expand Down Expand Up @@ -851,6 +856,7 @@ static translation_string all_strings[] = {
{TR_HOTKEY_SHOW_OVERLAY_RELIGION, "Religion overlay" },
{TR_HOTKEY_SHOW_OVERLAY_ROADS, "Roads overlay" },
{TR_HOTKEY_SHOW_OVERLAY_LEVY, "Levies overlay" },
{TR_HOTKEY_SHOW_OVERLAY_EMPLOYMENT, "Employment overlay" },
{TR_HOTKEY_ROTATE_MAP_NORTH, "Rotate map to North" },
{TR_HOTKEY_BUILD_WHEAT_FARM, "Wheat farm" },
{TR_HOTKEY_SHOW_MESSAGES, "Show messages"},
Expand Down
6 changes: 6 additions & 0 deletions src/translation/translation.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,11 @@ typedef enum {
TR_LABEL_PAUSE_MENU,
TR_OVERLAY_LEVY,
TR_TOOLTIP_OVERLAY_LEVY,
TR_OVERLAY_EMPLOYMENT,
TR_TOOLTIP_OVERLAY_EMPLOYMENT_FULL,
TR_TOOLTIP_OVERLAY_EMPLOYMENT_MISSING_1,
TR_TOOLTIP_OVERLAY_EMPLOYMENT_MISSING_2,
TR_TOOLTIP_OVERLAY_EMPLOYMENT_MOTHBALL,
TR_MAP_EDITOR_OPTIONS,
TR_BUILDING_TAVERN,
TR_BUILDING_GRAND_GARDEN,
Expand Down Expand Up @@ -846,6 +851,7 @@ typedef enum {
TR_HOTKEY_SHOW_OVERLAY_RELIGION,
TR_HOTKEY_SHOW_OVERLAY_ROADS,
TR_HOTKEY_SHOW_OVERLAY_LEVY,
TR_HOTKEY_SHOW_OVERLAY_EMPLOYMENT,
TR_HOTKEY_ROTATE_MAP_NORTH,
TR_HOTKEY_BUILD_WHEAT_FARM,
TR_HOTKEY_SHOW_MESSAGES,
Expand Down
62 changes: 62 additions & 0 deletions src/widget/city_overlay_other.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "city_overlay_other.h"

#include "building/animation.h"
#include "building/building.h"
#include "building/industry.h"
#include "building/model.h"
#include "building/monument.h"
Expand Down Expand Up @@ -160,6 +161,11 @@ static int show_figure_logistics(const figure *f)
return f->type == FIGURE_WAREHOUSEMAN || f->type == FIGURE_DEPOT_CART_PUSHER;
}

static int show_figure_employment(const figure *f)
{
return f->type == FIGURE_LABOR_SEEKER;
}

static int show_figure_none(const figure *f)
{
return 0;
Expand Down Expand Up @@ -220,6 +226,18 @@ static int get_column_height_tax_income(const building *b)
return NO_COLUMN;
}

static int get_column_height_employment(const building *b)
{
int full_staff = building_get_laborers(b->type);
int pct_staff = calc_percentage(b->num_workers, full_staff);

int height = 100 - pct_staff;
if (height == 0) {
return NO_COLUMN;
}
return full_staff ? height / 10 : NO_COLUMN;
}

static int get_column_height_none(const building *b)
{
return NO_COLUMN;
Expand Down Expand Up @@ -342,6 +360,34 @@ static int get_tooltip_tax_income(tooltip_context *c, const building *b)
}
}

static int get_tooltip_employment(tooltip_context *c, const building *b)
{
int full = building_get_laborers(b->type);
int missing = full - b->num_workers;

if (full >= 1) {
if (missing == 0) {
c->translation_key = TR_TOOLTIP_OVERLAY_EMPLOYMENT_FULL;
} else if (missing <= 1) {
c->has_numeric_prefix = 1;
c->numeric_prefix = missing;
c->translation_key = TR_TOOLTIP_OVERLAY_EMPLOYMENT_MISSING_1;
return 1;
} else if (missing >= 2 && b->state == BUILDING_STATE_MOTHBALLED) {
c->has_numeric_prefix = 1;
c->numeric_prefix = missing;
c->translation_key = TR_TOOLTIP_OVERLAY_EMPLOYMENT_MOTHBALL;
return 1;
} else {
c->has_numeric_prefix = 1;
c->numeric_prefix = missing;
c->translation_key = TR_TOOLTIP_OVERLAY_EMPLOYMENT_MISSING_2;
return 1;
}
}
return 0;
}

static int get_tooltip_water(tooltip_context *c, int grid_offset)
{
if (map_terrain_is(grid_offset, TERRAIN_RESERVOIR_RANGE)) {
Expand Down Expand Up @@ -476,6 +522,22 @@ const city_overlay *city_overlay_for_tax_income(void)
return &overlay;
}

const city_overlay *city_overlay_for_employment(void)
{
static city_overlay overlay = {
OVERLAY_EMPLOYMENT,
COLUMN_COLOR_RED_TO_GREEN,
show_building_none,
show_figure_employment,
get_column_height_employment,
0,
get_tooltip_employment,
0,
0
};
return &overlay;
}

static int has_deleted_building(int grid_offset)
{
building *b = building_get(map_building_at(grid_offset));
Expand Down
2 changes: 2 additions & 0 deletions src/widget/city_overlay_other.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const city_overlay *city_overlay_for_roads(void);

const city_overlay *city_overlay_for_levy(void);

const city_overlay *city_overlay_for_employment(void);

const city_overlay *city_overlay_for_mothball(void);

const city_overlay *city_overlay_for_logistics(void);
Expand Down
5 changes: 3 additions & 2 deletions src/widget/city_with_overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ static const city_overlay *get_city_overlay(void)
return city_overlay_for_roads();
case OVERLAY_LEVY:
return city_overlay_for_levy();
case OVERLAY_EMPLOYMENT:
return city_overlay_for_employment();
case OVERLAY_MOTHBALL:
return city_overlay_for_mothball();
case OVERLAY_ENEMY:
Expand Down Expand Up @@ -707,8 +709,7 @@ int city_with_overlay_get_tooltip_text(tooltip_context *c, int grid_offset)
overlay_type != OVERLAY_DAMAGE && overlay_type != OVERLAY_NATIVE && overlay_type != OVERLAY_DESIRABILITY &&
overlay_type != OVERLAY_PROBLEMS && overlay_type != OVERLAY_MOTHBALL && overlay_type != OVERLAY_ENEMY &&
overlay_type != OVERLAY_LOGISTICS && overlay_type != OVERLAY_SICKNESS && overlay_type != OVERLAY_EFFICIENCY &&
overlay_type != OVERLAY_HEALTH
;
overlay_type != OVERLAY_HEALTH && overlay_type != OVERLAY_EMPLOYMENT;
building *b = building_get(building_id);
if (overlay_requires_house && !b->house_size) {
return 0;
Expand Down
13 changes: 7 additions & 6 deletions src/window/hotkey_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ static hotkey_widget hotkey_widgets[] = {
{HOTKEY_SHOW_OVERLAY_FIRE, TR_HOTKEY_SHOW_OVERLAY_FIRE},
{HOTKEY_SHOW_OVERLAY_DAMAGE, TR_HOTKEY_SHOW_OVERLAY_DAMAGE},
{HOTKEY_SHOW_OVERLAY_CRIME, TR_HOTKEY_SHOW_OVERLAY_CRIME},
{HOTKEY_SHOW_OVERLAY_RISKS_NATIVE, TR_HOTKEY_SHOW_OVERLAY_RISKS_NATIVE},
{HOTKEY_SHOW_OVERLAY_PROBLEMS, TR_HOTKEY_SHOW_OVERLAY_PROBLEMS},
{HOTKEY_SHOW_OVERLAY_FOOD_STOCKS, TR_HOTKEY_SHOW_OVERLAY_FOOD_STOCKS},
{HOTKEY_SHOW_OVERLAY_LOGISTICS, TR_HOTKEY_SHOW_OVERLAY_LOGISTICS},
{HOTKEY_SHOW_OVERLAY_ENTERTAINMENT, TR_HOTKEY_SHOW_OVERLAY_ENTERTAINMENT},
{HOTKEY_SHOW_OVERLAY_EDUCATION, TR_HOTKEY_SHOW_OVERLAY_EDUCATION},
{HOTKEY_SHOW_OVERLAY_SCHOOL, TR_HOTKEY_SHOW_OVERLAY_SCHOOL},
Expand All @@ -135,14 +134,16 @@ static hotkey_widget hotkey_widgets[] = {
{HOTKEY_SHOW_OVERLAY_CLINIC, TR_HOTKEY_SHOW_OVERLAY_CLINIC},
{HOTKEY_SHOW_OVERLAY_HOSPITAL, TR_HOTKEY_SHOW_OVERLAY_HOSPITAL},
{HOTKEY_SHOW_OVERLAY_SICKNESS, TR_HOTKEY_SHOW_OVERLAY_SICKNESS},
{HOTKEY_SHOW_OVERLAY_LOGISTICS, TR_HOTKEY_SHOW_OVERLAY_LOGISTICS},
{HOTKEY_SHOW_OVERLAY_FOOD_STOCKS, TR_HOTKEY_SHOW_OVERLAY_FOOD_STOCKS},
{HOTKEY_SHOW_OVERLAY_MOTHBALL, TR_HOTKEY_SHOW_OVERLAY_MOTHBALL},
{HOTKEY_SHOW_OVERLAY_TAX_INCOME, TR_HOTKEY_SHOW_OVERLAY_TAX_INCOME},
{HOTKEY_SHOW_OVERLAY_LEVY, TR_HOTKEY_SHOW_OVERLAY_LEVY},
{HOTKEY_SHOW_OVERLAY_EMPLOYMENT, TR_HOTKEY_SHOW_OVERLAY_EMPLOYMENT},
{HOTKEY_SHOW_OVERLAY_RELIGION, TR_HOTKEY_SHOW_OVERLAY_RELIGION},
{HOTKEY_SHOW_OVERLAY_DESIRABILITY, TR_HOTKEY_SHOW_OVERLAY_DESIRABILITY},
{HOTKEY_SHOW_OVERLAY_SENTIMENT, TR_HOTKEY_SHOW_OVERLAY_SENTIMENT},
{HOTKEY_SHOW_OVERLAY_MOTHBALL, TR_HOTKEY_SHOW_OVERLAY_MOTHBALL},
{HOTKEY_SHOW_OVERLAY_RELIGION, TR_HOTKEY_SHOW_OVERLAY_RELIGION},
{HOTKEY_SHOW_OVERLAY_ROADS, TR_HOTKEY_SHOW_OVERLAY_ROADS},
{HOTKEY_SHOW_OVERLAY_LEVY, TR_HOTKEY_SHOW_OVERLAY_LEVY},
{HOTKEY_SHOW_OVERLAY_RISKS_NATIVE, TR_HOTKEY_SHOW_OVERLAY_RISKS_NATIVE},
{HOTKEY_HEADER, TR_HOTKEY_HEADER_BOOKMARKS},
{HOTKEY_GO_TO_BOOKMARK_1, TR_HOTKEY_GO_TO_BOOKMARK_1},
{HOTKEY_GO_TO_BOOKMARK_2, TR_HOTKEY_GO_TO_BOOKMARK_2},
Expand Down
6 changes: 3 additions & 3 deletions src/window/overlay_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ static generic_button submenu_buttons[] = {
{0, 216, 160, 24, button_submenu_item, button_none, 9, 0},
};

static const int MENU_ID_TO_OVERLAY[OVERLAY_BUTTONS] = { OVERLAY_NONE, OVERLAY_WATER, 1, 3, 5, 6, 7, OVERLAY_RELIGION, OVERLAY_ROADS, OVERLAY_DESIRABILITY, OVERLAY_SENTIMENT };
static const int MENU_ID_TO_OVERLAY[OVERLAY_BUTTONS] = { OVERLAY_NONE, OVERLAY_WATER, 1, 3, 5, 6, 7, OVERLAY_RELIGION, OVERLAY_DESIRABILITY, OVERLAY_SENTIMENT, OVERLAY_ROADS };
static const int MENU_ID_TO_SUBMENU_ID[OVERLAY_BUTTONS] = { 0, 0, 1, 2, 3, 4, 5, 0, 0 };
static const int ADDITIONAL_OVERLAY_TR[] = { TR_OVERLAY_ROADS, TR_OVERLAY_LEVY, TR_OVERLAY_TAVERN, TR_OVERLAY_ARENA_COL, TR_OVERLAY_SENTIMENT, TR_OVERLAY_MOTHBALL, TR_OVERLAY_ENEMY, TR_OVERLAY_LOGISTICS, TR_OVERLAY_SICKNESS, TR_OVERLAY_EFFICIENCY, TR_OVERLAY_STORAGES, TR_OVERLAY_HEALTH };
static const int ADDITIONAL_OVERLAY_TR[] = { TR_OVERLAY_ROADS, TR_OVERLAY_LEVY, TR_OVERLAY_TAVERN, TR_OVERLAY_ARENA_COL, TR_OVERLAY_SENTIMENT, TR_OVERLAY_MOTHBALL, TR_OVERLAY_ENEMY, TR_OVERLAY_LOGISTICS, TR_OVERLAY_SICKNESS, TR_OVERLAY_EFFICIENCY, TR_OVERLAY_STORAGES, TR_OVERLAY_HEALTH, TR_OVERLAY_EMPLOYMENT };

static const int SUBMENU_ID_TO_OVERLAY[6][OVERLAY_BUTTONS] = {
{0},
{OVERLAY_FIRE, OVERLAY_DAMAGE, OVERLAY_CRIME, OVERLAY_NATIVE, OVERLAY_PROBLEMS, OVERLAY_ENEMY, 0},
{OVERLAY_ENTERTAINMENT, OVERLAY_TAVERN, OVERLAY_THEATER, OVERLAY_AMPHITHEATER, OVERLAY_ARENA, OVERLAY_COLOSSEUM, OVERLAY_HIPPODROME, 0},
{OVERLAY_EDUCATION, OVERLAY_SCHOOL, OVERLAY_LIBRARY, OVERLAY_ACADEMY, 0},
{OVERLAY_HEALTH, OVERLAY_BARBER, OVERLAY_BATHHOUSE, OVERLAY_CLINIC, OVERLAY_HOSPITAL, OVERLAY_SICKNESS, 0},
{OVERLAY_TAX_INCOME, OVERLAY_LEVY, OVERLAY_EFFICIENCY, OVERLAY_FOOD_STOCKS, OVERLAY_MOTHBALL, OVERLAY_LOGISTICS, 0},
{OVERLAY_LOGISTICS, OVERLAY_FOOD_STOCKS, OVERLAY_EFFICIENCY, OVERLAY_MOTHBALL, OVERLAY_TAX_INCOME, OVERLAY_LEVY, OVERLAY_EMPLOYMENT, 0},
};

static struct {
Expand Down

0 comments on commit c7f0502

Please sign in to comment.