diff options
Diffstat (limited to 'src/scenes/world_map.c')
| -rw-r--r-- | src/scenes/world_map.c | 95 |
1 files changed, 88 insertions, 7 deletions
diff --git a/src/scenes/world_map.c b/src/scenes/world_map.c index 1053420..5dc5373 100644 --- a/src/scenes/world_map.c +++ b/src/scenes/world_map.c @@ -207,10 +207,11 @@ static void _insights_draw_grid(float scale, bool invalid_location, money_data_c PUSH_VAL(5, data.expenses_from_fuel, true);
PUSH_VAL(6, data.expenses_from_employees, true);
PUSH_VAL(7, data.expenses_from_trucks, true);
+ PUSH_VAL(8, data.expenses_from_loans, true);
// ADD NEW ENTRY HERE
- PUSH_VAL(9, data.total_income, false);
- PUSH_VAL(10, data.total_expenses, true);
- PUSH_VAL(11, data.total_profit, data.total_profit < 0.0f);
+ PUSH_VAL(10, data.total_income, false);
+ PUSH_VAL(11, data.total_expenses, true);
+ PUSH_VAL(12, data.total_profit, data.total_profit < 0.0f);
}
renderer->render_rectangle(x, y, width_per_item*3, h, COLOR_SCHEDULE_BG);
@@ -258,10 +259,11 @@ static void _insights_draw_grid(float scale, bool invalid_location, money_data_c case 5: strcpy(buf, "Fuel"); break;
case 6: strcpy(buf, "Salaries"); break;
case 7: strcpy(buf, "Trucks"); break;
+ case 8: strcpy(buf, "Loans"); break;
// ADD NEW ENTRY HERE
- case 9: strcpy(buf, "Total Income"); break;
- case 10: strcpy(buf, "Total Expenses"); break;
- case 11: strcpy(buf, "Total Profit"); break;
+ case 10: strcpy(buf, "Total Income"); break;
+ case 11: strcpy(buf, "Total Expenses"); break;
+ case 12: strcpy(buf, "Total Profit"); break;
default: break;
}
@@ -304,6 +306,7 @@ static void _insights_draw_chart(platform_window*window, bool invalid_location, CHECK_MIN_MAX(data.expenses_from_fuel);
CHECK_MIN_MAX(data.expenses_from_employees);
CHECK_MIN_MAX(data.expenses_from_trucks);
+ CHECK_MIN_MAX(data.expenses_from_loans);
// ADD NEW ENTRY HERE
CHECK_MIN_MAX(data.total_income);
CHECK_MIN_MAX(data.total_expenses);
@@ -363,6 +366,7 @@ static void _insights_draw_chart(platform_window*window, bool invalid_location, "Fuel",
"Salaries",
"Trucks",
+ "Loans",
// ADD NEW ENTRY HERE
"Total Income",
"Total Expenses",
@@ -482,6 +486,7 @@ static void _insights_draw_chart(platform_window*window, bool invalid_location, DRAW_LINES_FOR_DATA(data.expenses_from_fuel);
DRAW_LINES_FOR_DATA(data.expenses_from_employees);
DRAW_LINES_FOR_DATA(data.expenses_from_trucks);
+ DRAW_LINES_FOR_DATA(data.expenses_from_loans);
// ADD NEW ENTRY HERE
DRAW_LINES_FOR_DATA(data.total_income);
DRAW_LINES_FOR_DATA(data.total_expenses);
@@ -1108,16 +1113,92 @@ static void world_map_draw_night(platform_window* window) renderer->render_image_tint(img_shadow, shadow2_offset, area.y + camera_y, area.w*zoom, area.h*zoom, rgba(255,255,255,100));
}
+#define PUSH_LOAN_BTN(_txt,_index, _loan)\
+{\
+button_row_h = 44*scale;\
+if (button_render(scale, _loan.is_active ? BUTTON_DISABLED : BUTTON_ENABLED, _txt, btn_row_x, btn_row_y, button_row_w, button_row_h)) {\
+ _loan.is_active = true;\
+ _loan.days_left = 12*28;\
+ _active_world->money += _loan.amount;\
+}\
+btn_row_x += (button_row_w+halfpad);\
+}
+
static void world_map_draw_bank(platform_window* window)
{
s32 screen_center_x = area.x + (area.w/2);
s32 screen_center_y = area.y + (area.h/2);
- s32 panel_w = 400 * scale;
+ s32 panel_w = 600 * scale;
s32 panel_h = 350 * scale;
s32 panel_x = screen_center_x - (panel_w/2);
s32 panel_y = screen_center_y - (panel_h/2);
+
panel_render(scale, panel_x, panel_y, panel_w, panel_h);
+
+ s32 pad = 20*scale;
+ s32 halfpad = pad/2;
+ s32 textpad = 20*scale;
+
+ s32 btn_row_x = panel_x + pad;
+ s32 btn_row_y = panel_y + pad;
+ s32 button_row_w = panel_w - (pad*2);
+ s32 button_row_h = 44*scale;
+ button_render(scale, BUTTON_STATIC, 0, btn_row_x, btn_row_y,button_row_w, button_row_h);
+
+ font* fnt_big = fnt_rd32;
+ s32 textx = btn_row_x+(10*scale);
+ s32 texty = btn_row_y+(button_row_h/2)-(fnt_big->px_h/2);
+ renderer->render_text(fnt_big, textx, texty, "Babobank Inc.", COLOR_TEXT);
+
+ btn_row_y += button_row_h + halfpad;
+ button_row_h += panel_h - pad*5.0f-button_row_h*2;
+
+ fnt_big = fnt_rd24;
+ button_render(scale, BUTTON_STATIC, 0, btn_row_x, btn_row_y,button_row_w, button_row_h);
+ {
+ s32 txt_offset = 0;
+ if (_active_world->bank_info.loan1.is_active) {
+ char txt[100];
+ sprintf(txt, "LOAN: 10K at $%.0f/month. %d days left.",
+ _active_world->bank_info.loan1.monthly_payment, _active_world->bank_info.loan1.days_left);
+ renderer->render_text(fnt_big, btn_row_x + textpad, btn_row_y + textpad + txt_offset, txt, COLOR_TEXT);
+ txt_offset += fnt_big->px_h + textpad;
+ }
+
+ if (_active_world->bank_info.loan2.is_active) {
+ char txt[100];
+ sprintf(txt, "LOAN: 50K at $%.0f/month. %d days left.",
+ _active_world->bank_info.loan2.monthly_payment, _active_world->bank_info.loan2.days_left);
+ renderer->render_text(fnt_big, btn_row_x + textpad, btn_row_y + textpad + txt_offset, txt, COLOR_TEXT);
+ txt_offset += fnt_big->px_h + textpad;
+ }
+
+ if (_active_world->bank_info.loan3.is_active) {
+ char txt[100];
+ sprintf(txt, "LOAN: 150K at $%.0f/month. %d days left.",
+ _active_world->bank_info.loan3.monthly_payment, _active_world->bank_info.loan3.days_left);
+ renderer->render_text(fnt_big, btn_row_x + textpad, btn_row_y + textpad + txt_offset, txt, COLOR_TEXT);
+ }
+
+ if (txt_offset == 0) {
+ renderer->render_text(fnt_big, btn_row_x + textpad, btn_row_y + textpad + txt_offset, "Take out a loan with Babobank Inc to grow your business.", COLOR_TEXT);
+ }
+ }
+
+ btn_row_y += button_row_h+halfpad;
+ button_row_w = ((button_row_w-halfpad*2)/3);
+
+ PUSH_LOAN_BTN("+ $10K @ 3\%", 0, _active_world->bank_info.loan1);
+ PUSH_LOAN_BTN("+ $50K @ 5\%", 1, _active_world->bank_info.loan2);
+ PUSH_LOAN_BTN("+ $150K @ 8\%", 2, _active_world->bank_info.loan3);
+
+
+ if (mouse_interacts(panel_x, panel_y, panel_w, panel_h)) {
+ reset_left_click();
+ } else if (is_left_clicked()) {
+ scene_state = WORLD_SCENE_STATE_IDLE;
+ }
}
static void world_map_draw_menu(platform_window* window)
|
