diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/data.h | 100 | ||||
| -rw-r--r-- | src/include/game.h | 31 | ||||
| -rw-r--r-- | src/include/scenery.h | 29 | ||||
| -rw-r--r-- | src/include/scenes/error_scene.h | 15 | ||||
| -rw-r--r-- | src/include/scenes/loading_scene.h | 15 | ||||
| -rw-r--r-- | src/include/scenes/loading_world_scene.h | 16 | ||||
| -rw-r--r-- | src/include/scenes/menu_scene.h | 15 | ||||
| -rw-r--r-- | src/include/scenes/place_detail.h | 16 | ||||
| -rw-r--r-- | src/include/scenes/save_state_select.h | 15 | ||||
| -rw-r--r-- | src/include/scenes/settings_scene.h | 15 | ||||
| -rw-r--r-- | src/include/scenes/world_map.h | 16 | ||||
| -rw-r--r-- | src/include/settings.h | 28 | ||||
| -rw-r--r-- | src/include/tooltip.h | 18 | ||||
| -rw-r--r-- | src/include/ui/animation.h | 24 | ||||
| -rw-r--r-- | src/include/ui/button.h | 20 | ||||
| -rw-r--r-- | src/include/ui/colors.h | 62 | ||||
| -rw-r--r-- | src/include/ui/panel.h | 15 | ||||
| -rw-r--r-- | src/include/ui/portrait.h | 28 | ||||
| -rw-r--r-- | src/include/ui/selectors.h | 13 | ||||
| -rw-r--r-- | src/include/world.h | 383 |
20 files changed, 874 insertions, 0 deletions
diff --git a/src/include/data.h b/src/include/data.h new file mode 100644 index 0000000..1f13791 --- /dev/null +++ b/src/include/data.h @@ -0,0 +1,100 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_DATA
+#define INCLUDE_DATA
+
+#define FONT_SIZE_SPACING 4
+#define FONT_COUNT 20
+#define FONT_START 8
+
+image* img_logo_fruitosis;
+
+image* img_truck_unknown;
+image* img_iveco_stralis_activespace;
+image* img_iveco_stralis_hiway;
+
+image* img_logo_mercedes;
+image* img_logo_iveco;
+image* img_logo_volvo;
+
+image* img_white;
+image* img_location_pin;
+image* img_city;
+image* img_boat;
+image* img_star;
+image* img_road;
+image* img_timer;
+image* img_coins;
+image* img_arrow_left_rounded;
+image* img_globe;
+image* img_questionmark;
+image* img_checkmark;
+image* img_grid;
+image* img_lock;
+image* img_arrow_left;
+image* img_arrow_right;
+image* img_logo;
+image* img_pause;
+image* img_close;
+image* img_back;
+image* img_locationdot;
+image* img_dot;
+image* img_carwheel;
+image* img_graph;
+image* img_list;
+image* img_bank;
+image* img_tabitem;
+image* img_portrait;
+image* img_resume;
+image* img_signature;
+image* img_hired;
+image* img_denied;
+image* img_world_map;
+
+image* img_button_bottom;
+image* img_button_top;
+image* img_button_left;
+image* img_button_right;
+image* img_button_bottomleft;
+image* img_button_bottomright;
+image* img_button_topleft;
+image* img_button_topright;
+
+image* img_panel_bottom;
+image* img_panel_top;
+image* img_panel_left;
+image* img_panel_right;
+image* img_panel_bottomleft;
+image* img_panel_bottomright;
+image* img_panel_topleft;
+image* img_panel_topright;
+
+#define PORTRAIT_MAX_HAIR_COUNT 5
+image* img_portrait_body;
+image* img_portrait_head;
+image* img_portrait_hair[PORTRAIT_MAX_HAIR_COUNT];
+
+font* font_regular[FONT_COUNT];
+
+sound* snd_click;
+sound* snd_click2;
+sound* snd_click3;
+sound* snd_event;
+sound* snd_accelerate;
+
+#define SOUNGS_COUNT 30
+sound* snd_songs[SOUNGS_COUNT];
+
+void data_load();
+
+font empty_font_d = {0};
+
+#define SIZE_RDF(_w, _size) ((s32)(_size * (_w) + 3) & ~0x03)
+#define SIZE_RD(_w, _size) ((s32)((_size * (_w/1280.0f)) + 3) & ~0x03)
+#define FONT_REGULAR(_size) (_size < FONT_START || _size > (FONT_START+(FONT_SIZE_SPACING*FONT_COUNT))) ? (&empty_font_d) : font_regular[(_size-FONT_START)/FONT_SIZE_SPACING];
+
+#endif
\ No newline at end of file diff --git a/src/include/game.h b/src/include/game.h new file mode 100644 index 0000000..2c09ada --- /dev/null +++ b/src/include/game.h @@ -0,0 +1,31 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_GAME
+#define INCLUDE_GAME
+
+typedef enum t_game_state
+{
+ GAME_STATE_LOADING = 1,
+ GAME_STATE_MENU = 2,
+ GAME_STATE_SELECT_SAVE = 3,
+ GAME_STATE_WORLD_MAP = 4,
+ GAME_STATE_LOADING_WORLD = 5,
+ GAME_STATE_ERROR = 6,
+ GAME_STATE_PLACE_DETAIL = 7,
+ GAME_STATE_SETTINGS = 8,
+} game_state;
+
+typedef struct t_game
+{
+ game_state current_state;
+} game;
+
+void game_set_active_scene(game_state state);
+void game_update(platform_window* window);
+void game_render(platform_window* window);
+
+#endif
\ No newline at end of file diff --git a/src/include/scenery.h b/src/include/scenery.h new file mode 100644 index 0000000..08afec0 --- /dev/null +++ b/src/include/scenery.h @@ -0,0 +1,29 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_SCENERY
+#define INCLUDE_SCENERY
+
+#define BOAT_ROUTE_MAX_POINTS 300
+
+typedef struct t_boat_route_point
+{
+ float x;
+ float y;
+} boat_route_point;
+
+typedef struct t_boat_route
+{
+ boat_route_point points[BOAT_ROUTE_MAX_POINTS];
+ u8 count;
+ u8 current_point;
+ float current_point_duration;
+ bool reversed;
+} boat_route;
+
+void update_render_scenery(world* world);
+
+#endif
\ No newline at end of file diff --git a/src/include/scenes/error_scene.h b/src/include/scenes/error_scene.h new file mode 100644 index 0000000..b2b9a0d --- /dev/null +++ b/src/include/scenes/error_scene.h @@ -0,0 +1,15 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_ERROR_SCENE
+#define INCLUDE_ERROR_SCENE
+
+void error_scene_init();
+void error_scene_render(platform_window* window);
+void error_scene_update(platform_window* window);
+void error_scene_destroy();
+
+#endif
\ No newline at end of file diff --git a/src/include/scenes/loading_scene.h b/src/include/scenes/loading_scene.h new file mode 100644 index 0000000..3e49a9a --- /dev/null +++ b/src/include/scenes/loading_scene.h @@ -0,0 +1,15 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_LOADING_SCENE
+#define INCLUDE_LOADING_SCENE
+
+void loading_scene_init();
+void loading_scene_render(platform_window* window);
+void loading_scene_update(platform_window* window);
+void loading_scene_destroy();
+
+#endif
\ No newline at end of file diff --git a/src/include/scenes/loading_world_scene.h b/src/include/scenes/loading_world_scene.h new file mode 100644 index 0000000..864fe8d --- /dev/null +++ b/src/include/scenes/loading_world_scene.h @@ -0,0 +1,16 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_LOADING_WORLD_SCENE
+#define INCLUDE_LOADING_WORLD_SCENE
+
+void loading_world_scene_init();
+void start_loading_world(char* saved_file_path);
+void loading_world_scene_render(platform_window* window);
+void loading_world_scene_update(platform_window* window);
+void loading_world_scene_destroy();
+
+#endif
\ No newline at end of file diff --git a/src/include/scenes/menu_scene.h b/src/include/scenes/menu_scene.h new file mode 100644 index 0000000..e68b778 --- /dev/null +++ b/src/include/scenes/menu_scene.h @@ -0,0 +1,15 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_MENU_SCENE
+#define INCLUDE_MENU_SCENE
+
+void menu_scene_init();
+void menu_scene_render(platform_window* window);
+void menu_scene_update(platform_window* window);
+void menu_scene_destroy();
+
+#endif
\ No newline at end of file diff --git a/src/include/scenes/place_detail.h b/src/include/scenes/place_detail.h new file mode 100644 index 0000000..91c34ab --- /dev/null +++ b/src/include/scenes/place_detail.h @@ -0,0 +1,16 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_PLACE_DETAIL_SCENE
+#define INCLUDE_PLACE_DETAIL_SCENE
+
+void place_detail_scene_init();
+void place_detail_set_active_location(world_location* location);
+void place_detail_scene_render(platform_window* window);
+void place_detail_scene_update(platform_window* window);
+void place_detail_scene_destroy();
+
+#endif
\ No newline at end of file diff --git a/src/include/scenes/save_state_select.h b/src/include/scenes/save_state_select.h new file mode 100644 index 0000000..260bec2 --- /dev/null +++ b/src/include/scenes/save_state_select.h @@ -0,0 +1,15 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_SELECT_SAVE_SCENE
+#define INCLUDE_SELECT_SAVE_SCENE
+
+void save_state_select_scene_init();
+void save_state_select_scene_render(platform_window* window);
+void save_state_select_scene_update(platform_window* window);
+void save_state_select_scene_destroy();
+
+#endif
\ No newline at end of file diff --git a/src/include/scenes/settings_scene.h b/src/include/scenes/settings_scene.h new file mode 100644 index 0000000..701e6a9 --- /dev/null +++ b/src/include/scenes/settings_scene.h @@ -0,0 +1,15 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_SETTINGS_SCENE
+#define INCLUDE_SETTINGS_SCENE
+
+void settings_scene_init();
+void settings_scene_render(platform_window* window);
+void settings_scene_update(platform_window* window);
+void settings_scene_destroy();
+
+#endif
\ No newline at end of file diff --git a/src/include/scenes/world_map.h b/src/include/scenes/world_map.h new file mode 100644 index 0000000..d678868 --- /dev/null +++ b/src/include/scenes/world_map.h @@ -0,0 +1,16 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_WORLD_MAP_SCENE
+#define INCLUDE_WORLD_MAP_SCENE
+
+void world_map_set_active_world(world* world);
+void world_map_scene_init();
+void world_map_scene_render(platform_window* window);
+void world_map_scene_update(platform_window* window);
+void world_map_scene_destroy();
+
+#endif
\ No newline at end of file diff --git a/src/include/settings.h b/src/include/settings.h new file mode 100644 index 0000000..cba99ad --- /dev/null +++ b/src/include/settings.h @@ -0,0 +1,28 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_SETTINGS
+#define INCLUDE_SETTINGS
+
+#define AUDIO_CHANNEL_SFX_1 1
+#define AUDIO_CHANNEL_SFX_2 2
+#define AUDIO_CHANNEL_SFX_3 3
+
+u16 key_back = KEY_ESCAPE;
+u16 key_accept = KEY_ENTER;
+u16 key_insights_graph = KEY_F1;
+u16 key_insights_chart = KEY_F2;
+u16 key_events = KEY_F3;
+u16 key_bank = KEY_F4;
+
+float volume_global = 0.2f;
+float volume_music = 0.2f;
+float volume_sfx = 0.2f;
+
+bool option_vsync = true;
+bool option_fullscreen = false;
+
+#endif
\ No newline at end of file diff --git a/src/include/tooltip.h b/src/include/tooltip.h new file mode 100644 index 0000000..8748c81 --- /dev/null +++ b/src/include/tooltip.h @@ -0,0 +1,18 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_TOOPTIP
+#define INCLUDE_TOOPTIP
+
+char tooltip_buffer[100];
+s32 tooltip_x = 0;
+s32 tooltip_y = 0;
+bool tooltop_visible = false;
+
+void show_tooltip(s32 x, s32 y, char* buf);
+void update_render_tooltip();
+
+#endif
\ No newline at end of file diff --git a/src/include/ui/animation.h b/src/include/ui/animation.h new file mode 100644 index 0000000..1a10c0f --- /dev/null +++ b/src/include/ui/animation.h @@ -0,0 +1,24 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_ANIMATION
+#define INCLUDE_ANIMATION
+
+typedef struct t_animation
+{
+ float time;
+ bool started;
+ float duration;
+ float percentage;
+} animation;
+
+#define AN_LI(_cx,_dx,_an) (_cx + (_dx-_cx)*_an.percentage)
+#define AN_LI_TINT(_color, _an) rgba((_color).r,(_color).g,(_color).b,255*_an.percentage)
+
+animation animation_create(s32 duration);
+float animation_update(animation* an);
+
+#endif
\ No newline at end of file diff --git a/src/include/ui/button.h b/src/include/ui/button.h new file mode 100644 index 0000000..e381631 --- /dev/null +++ b/src/include/ui/button.h @@ -0,0 +1,20 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_BUTTON
+#define INCLUDE_BUTTON
+
+typedef enum t_button_type
+{
+ BUTTON_STATIC = 0,
+ BUTTON_ENABLED = 1,
+ BUTTON_DISABLED = 2,
+ BUTTON_HIGHLIGHTED = 3,
+} button_type;
+
+bool button_render(float scale, button_type enabled, char* text, s32 x, s32 y, s32 w, s32 h);
+
+#endif
\ No newline at end of file diff --git a/src/include/ui/colors.h b/src/include/ui/colors.h new file mode 100644 index 0000000..f8a7f91 --- /dev/null +++ b/src/include/ui/colors.h @@ -0,0 +1,62 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_COLORS
+#define INCLUDE_COLORS
+
+#define COLOR_WORLD_MAP_BACKGROUND rgb(32,52,63)
+#define COLOR_WHITE rgb(255,255,255)
+#define COLOR_BLACK rgb(0,0,0)
+#define COLOR_INSPECT_ACTIVE_JOB_LINE_CONNECTION rgb(40,40,40)
+#define COLOR_DOT_HOVERED rgb(100,220,100)
+
+#define COLOR_TEXT_NEGATIVE rgb(226,86,86)
+#define COLOR_TITLE rgb(8, 10, 12)
+#define COLOR_TEXT_SHADOW rgb(24,24,24)
+#define COLOR_TEXT rgb(207,207,207)
+
+#define COLOR_BUTTON_DISABLED_TINT rgb(70,70,70)
+
+#define COLOR_BUTTON_HIGHLIGHTED_TINT rgb(240,160,160)
+#define COLOR_BUTTON_ACTIVE_TINT rgb(210,210,210)
+#define COLOR_PANEL_BACKGROUND rgb(66,63,58)
+
+#define COLOR_BUTTON rgb(98, 95, 90)
+#define COLOR_BUTTON_ACTIVE rgb(81, 78, 74)
+#define COLOR_BUTTON_HIGHLIGHTED_ACTIVE rgb(92, 60, 56)
+#define COLOR_BUTTON_DISABLED rgb(27, 26, 25)
+
+#define COLOR_LOCATION_DOT_UNOWNED rgb(220,220,220)
+#define COLOR_LOCATION_DOT_OWNED rgb(220,100,100)
+
+#define COLOR_LIST_ENTRY_BACKGROUND rgb(46,43,40)
+#define COLOR_LIST_ENTRY_BACKGROUND_ACTIVE rgb(63,59,56)
+
+#define COLOR_SCHEDULE_ROW_ACTIVE rgb(118,115,100)
+#define COLOR_SCHEDULE_TILE_FIXED rgb(178,239,155)
+#define COLOR_SCHEDULE_TILE_HOVERED rgb(26,200,237)
+#define COLOR_SCHEDULE_TILE_INVALID rgb(244,70,73)
+#define COLOR_SCHEDULE_TILE_INVALID_SELECTED rgb(252,159,160)
+#define COLOR_SCHEDULE_TILE_SELECTED rgb(174,212,230)
+#define COLOR_SCHEDULE_TILE_HIGHLIGHTED rgb(237,177,26)
+
+#define COLOR_SELECTOR_UNDERLINE rgb(180,180,180)
+
+#define LEGENDA_HOVER_BACKGROUND_COLOR rgba(255,0,0,50)
+#define LEGENDA_COLOR_DISABLED rgb(120,120,120)
+#define LEGENDA_SUB_COLOR_DISABLED rgba(120,120,120,100)
+
+#define COLOR_SCHEDULE_BG rgb(142,138,132)
+#define COLOR_SCHEDULE_BORDER rgb(75,73,69)
+#define COLOR_SCHEDULE_BORDER_THIN rgb(88,85,80)
+
+#define COLOR_TEXTBOX_TINT rgb(100,100,100)
+#define COLOR_TEXTBOX_FILL rgb(38, 37, 35)
+
+#define COLOR_WRONG rgb(168,45,45)
+#define COLOR_CORRECT rgb(47,168,45)
+
+#endif
\ No newline at end of file diff --git a/src/include/ui/panel.h b/src/include/ui/panel.h new file mode 100644 index 0000000..83103d2 --- /dev/null +++ b/src/include/ui/panel.h @@ -0,0 +1,15 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_PANEL
+#define INCLUDE_PANEL
+
+// 1280 is our reference width.
+#define UI_SCALE(_w) (_w/1280.0f)
+
+void panel_render(float scale, s32 x, s32 y, s32 w, s32 h);
+
+#endif
\ No newline at end of file diff --git a/src/include/ui/portrait.h b/src/include/ui/portrait.h new file mode 100644 index 0000000..8bff8e1 --- /dev/null +++ b/src/include/ui/portrait.h @@ -0,0 +1,28 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_PORTRAIT
+#define INCLUDE_PORTRAIT
+
+color hair_palette[] = {
+ rgb(199, 186, 168), rgb(188, 181, 160), rgb(191, 173, 148), rgb(203, 181, 138), rgb(187, 162, 120),
+ rgb(174, 153, 122), rgb(172, 134, 109), rgb(205, 169, 129), rgb(168, 115, 88), rgb(137, 82, 71),
+ rgb(158, 131, 99), rgb(150, 116, 93), rgb(128, 93, 73), rgb(202, 162, 136), rgb(197, 146, 137),
+ rgb(194, 136, 129), rgb(165, 127, 117), rgb(152, 111, 113), rgb(123, 103, 93), rgb(98, 79, 73)
+};
+
+color skin_palette[] = {
+ rgb(233, 203, 167), rgb(238, 208, 183), rgb(247, 221, 196), rgb(247, 226, 171), rgb(239, 199, 148), rgb(239, 192, 136),
+ rgb(231, 188, 145), rgb(236, 192, 131), rgb(208, 158, 125), rgb(203, 150, 98), rgb(171, 139, 100), rgb(148, 98, 61),
+};
+
+color body_palette[] = {
+ rgb(33, 28, 32), rgb(76, 74, 77), rgb(109, 103, 107), rgb(171, 133, 86), rgb(213, 175, 126), rgb(240, 229, 225),
+};
+
+void draw_employee_portrait(employee* emp, float x, float y, float w, float h);
+
+#endif
\ No newline at end of file diff --git a/src/include/ui/selectors.h b/src/include/ui/selectors.h new file mode 100644 index 0000000..6832ff7 --- /dev/null +++ b/src/include/ui/selectors.h @@ -0,0 +1,13 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_EMPLOYEE_SELECTOR
+#define INCLUDE_EMPLOYEE_SELECTOR
+
+employee* employee_selector_render(platform_window* window, float scale, bool enabled, employee* current_val, s32 x, s32 y, s32 w, s32 h, animation an, scheduled_job* offer);
+world_location* location_selector_render(platform_window* window, float scale, bool enabled, world_location* current_val, s32 x, s32 y, s32 w, s32 h);
+
+#endif
\ No newline at end of file diff --git a/src/include/world.h b/src/include/world.h new file mode 100644 index 0000000..4f8af10 --- /dev/null +++ b/src/include/world.h @@ -0,0 +1,383 @@ +/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+#ifndef INCLUDE_WORLD
+#define INCLUDE_WORLD
+
+#define MAX_WORLD_LOCATION_NAME_LENGTH 20
+#define MAX_ENPOLYEE_FIRSTNAME_LENGTH 14
+#define MAX_ENPOLYEE_LASTNAME_LENGTH 14
+#define MAX_EMPLOYEE_NAME_LENGTH 30
+#define MAX_COMPANY_NAME_LENGTH 50
+#define MAX_DEALER_NAME_LENGTH 20
+#define MAX_TRUCK_NAME_LENGTH 30
+#define MAX_PRODUCT_NAME_LENGTH 50
+#define MAX_EMPLOYEE_NR_LENGTH 12
+#define MAX_INPUT_LENGTH_FOR_EMPLOYEE_SELECTOR 10
+
+// Static = loaded from file
+// Save State = loaded from save state
+// Dynamic = set at runtime
+
+#define MINUTES(_n) (_n*60)
+#define HOURS(_n) (_n*MINUTES(60))
+#define DAYS(_n) (_n*HOURS(24))
+
+typedef struct t_world_location world_location;
+typedef struct t_employee employee;
+
+#define WORK_HOUR_START 8
+#define WORK_HOUR_END 20
+#define TIME_SLOTS_PER_HOUR 4
+#define TIME_SLOTS_PER_DAY ((WORK_HOUR_END-WORK_HOUR_START)*TIME_SLOTS_PER_HOUR)
+#define TIME_SLOTS_PER_WEEK (TIME_SLOTS_PER_DAY*7)
+
+#define MAX_JOBOFFER_COUNT 25
+#define MAX_EMPLOYEE_COUNT (TIME_SLOTS_PER_WEEK)
+#define MAX_TRUCK_COUNT (TIME_SLOTS_PER_WEEK)
+
+#define MISSED_DELIVERY_TRUST_PENALTY (0.5f)
+#define MAX_EFFECTIVE_EXPERIENCE 25.0f // anything past 25 years of experience has no extra positives.
+#define SHIPTIME_DURATION_MULTIPLIER_MAX 1.0f
+#define SHIPTIME_DURATION_MULTIPLIER_MIN 1.15f
+#define DIESEL_PRICE_PER_LITER 1.4f
+
+#define INVALID_ID 0
+#define MAX_WORKED_HOURS_WEEKLY (45.0f)
+#define MINIMUM_EMPLOYEE_HAPPINESS (0.4f)
+#define EMPLOYEE_MAX_UNHAPPY_DAYS_BEFORE_QUITTING (60.0f)
+
+#define CDAYTORDAY(_day) (_day == 0 ? 7 : _day) // m = 1, s = 7
+#define RDAYTOCDAY(_day) (_day == 7 ? 0 : _day) // m = 1, s = 0
+
+#define BASE_PAY 1800
+#define RAISE_PER_YEAR 55
+#define MAX_PAY 3250
+
+typedef enum t_minor_event
+{
+ EXTERNAL_INSPECTION, // Check overworking, safety
+} minor_event;
+
+typedef enum t_weekday
+{
+ MONDAY = 1,
+ TUESDAY = 2,
+ WEDNESDAY = 3,
+ THURSDAY = 4,
+ FRIDAY = 5,
+ SATURDAY = 6,
+ SUNDAY = 0,
+
+ DAY_INVALID = 99
+} weekday;
+
+typedef struct t_product
+{
+ char name[MAX_PRODUCT_NAME_LENGTH];
+} product;
+
+typedef struct t_company
+{
+ // Static
+ char name[MAX_COMPANY_NAME_LENGTH];
+ array products;
+
+ // Dynamic
+ image* logo;
+} company;
+
+typedef struct t_truck
+{
+ // Static
+ char name[MAX_TRUCK_NAME_LENGTH];
+ u16 hp;
+ u32 price;
+ u16 fuelcapacity;
+ u16 torque;
+ float fuelusage;
+
+ // Dynamic
+ image* logo;
+
+ // Save State
+ s32 type;
+ s32 id;
+ employee* assigned_employee;
+} truck;
+
+typedef struct t_truck_dealer
+{
+ // Static
+ char name[MAX_DEALER_NAME_LENGTH];
+ array trucks;
+
+ // Dynamic
+ image* logo;
+} truck_dealer;
+
+#define JOB_OFFER_REWARD_PER_CONNECTION 160
+#define MAX_SHIPDAYS 4
+
+typedef struct t_job_offer
+{
+ u32 id;
+ s64 expire_date;
+ company* company;
+ product* product;
+ s32 shipday_count;
+ weekday shipdays[MAX_SHIPDAYS];
+ u32 reward;
+ array connections; // Should not be freed if offer has been accepted.
+ double total_distance; // in KM
+ time_t duration_sec_min; // experienced drivers
+ time_t duration_sec_max; // inexperienced drivers
+} job_offer;
+
+typedef struct t_employee
+{
+ u32 id;
+ char name[MAX_EMPLOYEE_NAME_LENGTH];
+ u8 age;
+ struct tm hire_date;
+ u8 experience;
+ float salary;
+ float happiness;
+ s16 days_below_happiness_treshold;
+ u32 current_location_id;
+ u32 original_location_id;
+ truck* assigned_truck;
+ u32 active_job_id;
+
+ // Portrait
+ u8 portrait_hair_type;
+ color hair_color;
+ color face_color;
+ color body_color;
+} employee;
+
+#define RESUME_FADEOUT_MS 300
+typedef struct t_resume
+{
+ employee* employee;
+ s64 expire_date;
+ bool hired;
+ animation animation;
+} resume;
+
+typedef struct t_scheduled_job_time
+{
+ s16 day; // sunday = 0
+ s16 timeslot;
+ bool stay_at_destination;
+ employee* assignee;
+} scheduled_job_time;
+
+typedef struct t_scheduled_job
+{
+ float trust;
+ job_offer offer;
+ world_location* location;
+ scheduled_job_time timeslots[MAX_SHIPDAYS];
+} scheduled_job;
+
+typedef struct t_active_job
+{
+ // save state
+ s16 day;
+ s16 timeslot;
+ bool stay_at_destination;
+ job_offer offer;
+ employee assignee;
+ truck assigned_truck;
+ time_t duration_sec;
+ time_t left_at;
+ time_t done_at;
+ bool reversed;
+
+ // dynamic
+ vec2f px_pos;
+ bool is_hovered;
+} active_job;
+
+typedef struct t_active_job_ref
+{
+ s16 day;
+ s16 timeslot;
+ u32 offerid;
+} active_job_ref;
+
+typedef struct t_world_update_result
+{
+ active_job* clicked_job;
+ world_location* clicked_location;
+} world_update_result;
+
+#define NUM_DAYS 7
+typedef struct t_schedule
+{
+ array jobs;
+} schedule;
+
+typedef struct t_world_location
+{
+ // Static
+ u8 size;
+ double latitude;
+ double longitude;
+ char name[MAX_WORLD_LOCATION_NAME_LENGTH];
+ s32 map_position_x;
+ s32 map_position_y;
+
+ // Save State
+ bool is_owned;
+ array employees; // Contains internal and external employees. Employee can be at 2 locations at any given time.
+ array job_offers;
+ array resumes;
+ array trucks;
+ float reliability;
+ schedule schedule;
+ u16 purchase_year;
+ array insights;
+
+ // Dynamic
+ array connections;
+ bool is_hovered;
+ u32 id;
+} world_location;
+
+typedef struct t_job_endpoints
+{
+ world_location* source;
+ world_location* dest;
+} job_endpoints;
+
+typedef enum t_event_type
+{
+ EVENT_TYPE_MISSED_SHIPMENT_NO_TRUCK, // go to employee detail
+ EVENT_TYPE_MISSED_SHIPMENT_NOT_AT_LOCATION, // go to schedule
+ EVENT_TYPE_MISSED_SHIPMENT_NO_ASSIGNEE, // go to schedule
+ EVENT_TYPE_EMPLOYEE_QUIT, // go to schedule
+} event_type;
+
+#define MAX_EVENT_MESSAGE_LENGTH 150
+
+typedef struct t_event
+{
+ void* data;
+ event_type type;
+ scheduled_job_time job_time;
+ char message[MAX_EVENT_MESSAGE_LENGTH];
+} event;
+
+#define MIN_SIMULATION_SPEED 0
+#define MAX_SIMULATION_SPEED 8
+
+#define LOG_HISTORY_LENGTH 25
+
+typedef struct t_event_log
+{
+ array events;
+ u16 write_cursor;
+ bool has_unread_messages;
+} event_log;
+
+#define ADD_EXPENSE(_world,_loc,_var,_amount)\
+ {\
+ _world->money -= _amount;\
+ money_data_collection* collection = get_current_insights_data(_world);\
+ collection->months[_world->current_time.tm_mon].total_expenses -= _amount;\
+ collection->months[_world->current_time.tm_mon].total_profit -= _amount;\
+ collection->months[_world->current_time.tm_mon]._var -= _amount;\
+ if (_loc) {\
+ collection = get_current_insights_data_for_location(_world,_loc);\
+ collection->months[_world->current_time.tm_mon].total_expenses -= _amount;\
+ collection->months[_world->current_time.tm_mon].total_profit -= _amount;\
+ collection->months[_world->current_time.tm_mon]._var -= _amount;}\
+ }
+
+#define ADD_INCOME(_world,_loc,_var,_amount)\
+ {\
+ _world->money += _amount;\
+ money_data_collection* collection = get_current_insights_data(_world);\
+ collection->months[_world->current_time.tm_mon].total_income += _amount;\
+ collection->months[_world->current_time.tm_mon].total_profit += _amount;\
+ collection->months[_world->current_time.tm_mon]._var += _amount;\
+ if (_loc) {\
+ collection = get_current_insights_data_for_location(_world,_loc);\
+ collection->months[_world->current_time.tm_mon].total_income += _amount;\
+ collection->months[_world->current_time.tm_mon].total_profit += _amount;\
+ collection->months[_world->current_time.tm_mon]._var += _amount;}\
+ }
+
+#define EXPENSES get_current_insights_data(world)->months[world->current_time.tm_mon]
+
+typedef struct t_money_data
+{
+ float total_income;
+ float total_expenses;
+ float total_profit;
+
+ float income_from_trips;
+
+ float expenses_from_trucks;
+ float expenses_from_utility;
+ float expenses_from_healthcare;
+ float expenses_from_repairs;
+ float expenses_from_fuel;
+ float expenses_from_employees;
+} money_data;
+
+#define MONTHS_IN_YEAR 12
+
+typedef struct t_money_data_collection
+{
+ money_data months[MONTHS_IN_YEAR];
+} money_data_collection;
+
+typedef struct t_company_investments
+{
+ u32 safety;
+ u32 marketing;
+ u32 human_resources;
+ u32 training;
+ u32 legal;
+} company_investments;
+
+typedef struct t_world
+{
+ // Save State
+ s64 simulation_time;
+ u16 start_year;
+ float money;
+ u32 next_id;
+ u8 simulation_speed;
+ array active_jobs;
+ event_log log;
+ array insights;
+ company_investments investments;
+ u16 days_since_last_random_event;
+
+ // Dynamic
+ array locations;
+ array companies;
+ array firstnames;
+ array lastnames;
+ array truck_dealers;
+ array boat_routes;
+ struct tm current_time;
+} world;
+
+world* world_create_new();
+void world_report_event(world* world, char* msg, event_type type, void* data);
+world_location* get_world_location_by_id(world* world, s32 id);
+world_location* get_world_location_by_name(world* world, char* str);
+float world_location_get_price(world_location* location);
+void add_truck_to_world_location(world* world, world_location* location, truck* tr);
+void world_update(platform_window* window, world* world);
+world_update_result world_render(platform_window* window, world* world);
+
+#endif
\ No newline at end of file |
