bug on F1 menu

This commit is contained in:
Shadow15510 2021-11-05 16:37:09 +01:00
parent bad46c8c8e
commit 3fed055c92
14 changed files with 770 additions and 155 deletions

View File

@ -24,6 +24,8 @@ set(ASSETS_fx
assets-fx/large_water.png
assets-fx/title.png
assets-fx/fn_keys.png
assets-fx/fn_1.png
assets-fx/fn_2.png
)
set(ASSETS_cg)

BIN
assets-fx/brownout.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
assets-fx/fn_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
assets-fx/fn_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 866 B

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,3 +1,421 @@
#include "calccity.h"
static const char tiles_names = {};
const struct building buildings[41] = {
// Menu 1
{
.name = "TERRE",
.id = (unsigned char []){48, 49, 110, 111, 112, 113, 114, 120, 121, 122, 123, 124, 130, 131, 132, 133, 134},
.cost = 10,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "EAU",
.id = (unsigned char []){139},
.cost = 15,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "FORET",
.id = (unsigned char []){76},
.cost = 15,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "HABITATIONS TYPE 1",
.id = (unsigned char []){66},
.cost = 100,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "HABITATIONS TYPE 2",
.id = (unsigned char []){67},
.cost = 150,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "HABITATIONS TYPE 3",
.id = (unsigned char []){68},
.cost = 200,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "BUREAUX TYPE 1",
.id = (unsigned char []){45},
.cost = 50,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "BUREAUX TYPE 2",
.id = (unsigned char []){46},
.cost = 100,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "BUREAUX TYPE 3",
.id = (unsigned char []){47},
.cost = 150,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "USINE TYPE 1",
.id = (unsigned char []){54},
.cost = 200,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "USINE TYPE 2",
.id = (unsigned char []){55},
.cost = 300,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "USINE TYPE 3",
.id = (unsigned char []){56},
.cost = 400,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "FERME TYPE 1",
.id = (unsigned char []){9},
.cost = 50,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "FERME TYPE 2",
.id = (unsigned char []){19},
.cost = 75,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "FERME TYPE 3",
.id = (unsigned char []){44},
.cost = 100,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
// Menu 2
{
.name = "ROUTE",
.id = (unsigned char []){80, 81, 82, 83, 90, 91, 92, 93, 100, 101, 102},
.cost = 10,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "PORT",
.id = (unsigned char []){62, 63, 64, 65},
.cost = 500,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "AEROPORT",
.id = (unsigned char []){0, 1, 2, 12},
.cost = 3500,
.size = {2, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "RAIL",
.id = (unsigned char []){84, 85, 86, 87, 94, 95, 96, 97, 104, 105, 106},
.cost = 50,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "CENTRALE ELECTRIQUE 1",
.id = (unsigned char []){71},
.cost = 500,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "CENTRALE ELECTRIQUE 2",
.id = (unsigned char []){72},
.cost = 1000,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "CENTALE NUCLEAIRE",
.id = (unsigned char []){50, 51, 60, 61},
.cost = 25000,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "INCINERATEUR",
.id = (unsigned char []){3, 4, 13, 14},
.cost = 2500,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0},
}
{
.name = "STATION D'EPURATION",
.id = (unsigned char []){77},
.cost = 50,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "TERRAIN DE SPORT",
.id = (unsigned char []){78},
.cost = 250,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "AIRE DE JEUX",
.id = (unsigned char []){69},
.cost = 150,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "STADE",
.id = (unsigned char []){42, 43, 52, 53},
.cost = 10000,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "CASERNE DE POLICE",
.id = (unsigned char []){70},
.cost = 250,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "CASERNE DE POMPIERS",
.id = (unsigned char []){58},
.cost = 250,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "HOPITAL",
.id = (unsigned char []){59},
.cost = 250,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "CENTRE ECOLOGIQUE",
.id = (unsigned char []){75},
.cost = 2500,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "ECOLE TYPE 1",
.id = (unsigned char []){73},
.cost = 250,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "ECOLE TYPE 2",
.id = (unsigned char []){74},
.cost = 500,
.size = {1, 1},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "UNIVERSITE",
.id = (unsigned char []){28, 29, 38, 39},
.cost = 2500,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "EGLISE ET CIMETIERE",
.id = (unsigned char []){10, 11, 20, 21},
.cost = 2500,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
},
// Others buildings
{
.name = "IMMEUBLE";
.id = (unsigned char []){5, 6, 15, 56},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0},
}
{
.name = "TOUR DE BUREAUX",
.id = (unsigned char []){7, 8, 17, 18},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "USINE",
.id = (unsigned char []){30, 31, 40, 41},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "CASERNE DE POLICE",
.id = (unsigned char []){26, 27, 36, 37},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "CASERNE DE POMPIERS",
.id = (unsigned char []){22, 23, 32, 33},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
},
{
.name = "HOPITAL",
.id = (unsigned char []){24, 25, 34, 35},
.cost = 0,
.size = {2, 2},
.stat = {0},
.taxes = {0},
.funds = {0}
},
};

View File

@ -1,28 +1,43 @@
#ifndef _CALCCITY_H
#define _CALCCITY_H
#include <gint/std/stdlib.h>
#include <stdlib.h>
struct calccity
{
// human's statistics = {happyness, health, education, housing, work, food}
unsigned long humans[6];
// population evolution = {population, birth_rate, death_rate, immigration, emigration}
unsigned long population[5];
// main statistics
/*
housing,
health,
education,
food,
work,
transport,
// trade statistics = {import, export, production, commercial, industrial, annual_cost}
unsigned long trade[6];
crime,
firehazard,
nuclearhazard,
pollution,
// production = {water, power}
unsigned long production[2];
commercial,
industrial,
production,
import,
export,
annual_cost,
water_consumption,
power_consumption,
power_supply,
grabage
graves,
*/
unsigned long stat[21];
// consumption = {water, power}
unsigned long consumption[2];
// some others statistics = {treasure, crime, safety, fire_hazard, nuclear_hazard, pollution, transport, grabage, graves}
// some others statistics = {treasure, population, safety, hapyness, birth_rate, death_rate, immigration, emigration, water_supply}
unsigned long misc[9];
// taxes in percents on {housing, trade, industry, export}
unsigned int taxes[4];
@ -49,6 +64,7 @@ struct camera
int zoom;
int cursor_x, cursor_y;
int cursor_size[2];
};
@ -58,6 +74,53 @@ struct map
};
struct building
{
char *name;
unsigned char *id;
int cost;
unsigned char size[2];
/*
housing,
health,
education,
food,
work,
transport,
crime,
firehazard,
nuclearhazard,
pollution,
commercial,
industrial,
production,
import,
export,
annual_cost,
water_consumption,
power_consumption,
power_supply,
grabage
graves,
*/
unsigned int stat[21];
// commercial, industrial, export
unsigned int taxes[3];
// police, firemen, education, heathcare
unsigned int funds[4];
};
#define ENGINE_TICK 100
static const struct building buildings[41];
#endif /* _CALCCITY_H */

View File

@ -1,8 +1,10 @@
#include <gint/keyboard.h>
#include <gint/std/stdlib.h>
#include <gint/display.h>
#include <gint/std/string.h>
#include <gint/timer.h>
#include <gint/clock.h>
#include <stdlib.h>
#include <math.h>
#include "core.h"
@ -44,6 +46,8 @@ void default_values(struct calccity *calccity, struct camera *camera, struct map
memset(camera, 0, sizeof *camera);
camera->cursor_x = 2;
camera->cursor_y = 2;
camera->cursor_size[0] = 8;
camera->cursor_size[1] = 8;
// Initialisation of struct map
@ -151,8 +155,6 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
int end = 0, key = 0;
//int build_mode = 0;
while (!end)
{
// Real-time clock system
@ -160,33 +162,14 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
tick = 0;
next_step(calccity);
// Display map
display_large_map(calccity, camera, map);
display_around(calccity, camera);
dclear(C_WHITE);
main_display(calccity, camera, map, 1);
dupdate();
// Get and manage input
key = rtc_key();
keyboard_managment(calccity, camera, key);
// Open the menu
switch (calccity->menu)
{
// Tax and funds
case 4:
menu_4(calccity);
break;
case 5:
menu_5(calccity);
break;
// Options
case 6:
end = menu_6(calccity);
break;
}
calccity->menu = 0;
end = keyboard_managment(calccity, camera, map, key);
}
// Free timer
@ -194,8 +177,10 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
}
void keyboard_managment(struct calccity *calccity, struct camera *camera, const int key)
int keyboard_managment(struct calccity *calccity, struct camera *camera, struct map *map, const int key)
{
int end = 0;
switch (key)
{
case KEY_UP:
@ -204,12 +189,12 @@ void keyboard_managment(struct calccity *calccity, struct camera *camera, const
break;
case KEY_RIGHT:
if (camera->cursor_x < 14) camera->cursor_x ++;
if (camera->cursor_x < floor(120 / camera->cursor_size[0]) - 1) camera->cursor_x ++;
else if (camera->x < 42) camera->x ++;
break;
case KEY_DOWN:
if (camera->cursor_y < 6) camera->cursor_y ++;
if (camera->cursor_y < floor(57 / camera->cursor_size[1]) - 1) camera->cursor_y ++;
else if (camera->y < 46) camera->y ++;
break;
@ -218,29 +203,95 @@ void keyboard_managment(struct calccity *calccity, struct camera *camera, const
else if (camera->x > 0) camera->x --;
break;
case KEY_F1:
calccity->menu = 1;
int build_mode = 0;
struct building selected_building = menu_1(calccity, camera, map, &build_mode);
if (build_mode)
build(calccity, camera, map, &selected_building);
break;
case KEY_F2:
calccity->menu = 2;
break;
case KEY_F3:
calccity->menu = 3;
break;
case KEY_F4:
calccity->menu = 4;
menu_4(calccity);
break;
case KEY_F5:
calccity->menu = 5;
menu_5(calccity);
break;
case KEY_F6:
calccity->menu = 6;
end = menu_6(calccity);
break;
}
return end;
}
void build(struct calccity *calccity, struct camera *camera, struct map *map, struct building *building)
{
// Timer initialisation
static volatile int tick = 1;
int t = timer_configure(TIMER_ANY, ENGINE_TICK*1000, GINT_CALL(callback_tick, &tick));
if (t >= 0) timer_start(t);
// Adjust cursor size
camera->cursor_size[0] = building->size[0] * 15;
camera->cursor_size[1] = building->size[1] * 15;
camera->cursor_x = 1;
camera->cursor_y = 1;
int key = 0, end = 0;
while (!end)
{
// Real-time clock system
while (!tick) sleep();
tick = 0;
next_step(calccity);
dclear(C_WHITE);
main_display(calccity, camera, map, 1);
dprint_opt(4, 8, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "$%d %d,%d", building->cost, building->size[0], building->size[1]);
dprint_opt(4, 15, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "%s", building->name);
dupdate();
key = rtc_key();
switch (key)
{
case KEY_UP:
if (camera->cursor_y > 0) camera->cursor_y --;
else if (camera->y > 0) camera->y --;
break;
case KEY_RIGHT:
if (camera->cursor_x < floor(120 / camera->cursor_size[0]) - 1) camera->cursor_x ++;
else if (camera->x < 42) camera->x ++;
break;
case KEY_DOWN:
if (camera->cursor_y < floor(57 / camera->cursor_size[1]) - 1) camera->cursor_y ++;
else if (camera->y < 46) camera->y ++;
break;
case KEY_LEFT:
if (camera->cursor_x > 0) camera->cursor_x --;
else if (camera->x > 0) camera->x --;
break;
case KEY_ALPHA:
end = 1;
break;
case KEY_SHIFT:
end = 1;
break;
}
}
if (t >= 0) timer_stop(t);
}

View File

@ -20,7 +20,10 @@ void next_step(struct calccity *calccity);
// main_loop : game main loop
void main_loop(struct calccity *calccity, struct camera *camera, struct map *map);
// keyboard_managment : get the key and manage input
void keyboard_managment(struct calccity *calccity, struct camera *camera, const int key);
// keyboard_managment : get the key, manage input and open menus
int keyboard_managment(struct calccity *calccity, struct camera *camera, struct map *map, const int key);
// build : manage the build
void build(struct calccity *calccity, struct camera *camera, struct map *map, struct building *building);
#endif /* _CORE_H */

View File

@ -1,5 +1,6 @@
#include <gint/display.h>
#include <gint/keyboard.h>
#include <math.h>
#include "display.h"
@ -15,13 +16,19 @@ void title_screen(void)
}
void main_display(struct calccity *calccity, struct camera *camera, struct map *map, const int disp_cursor)
{
// Display map
display_large_map(calccity, camera, map);
display_around(calccity, camera, disp_cursor);
}
void display_large_map(struct calccity *calccity, struct camera *camera, struct map *map)
{
extern const bopti_image_t img_large_tileset;
extern const bopti_image_t img_large_water;
dclear(C_WHITE);
for (int y = 0; y < 4; y++)
{
for (int x = 0; x < 8; x ++)
@ -44,7 +51,7 @@ void display_large_map(struct calccity *calccity, struct camera *camera, struct
}
void display_around(struct calccity *calccity, struct camera *camera)
void display_around(struct calccity *calccity, struct camera *camera, const int disp_cursor)
{
extern const bopti_image_t img_fn_keys;
@ -61,11 +68,13 @@ void display_around(struct calccity *calccity, struct camera *camera)
dprint_opt(4, 1, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "%d-%d", calccity->month, calccity->year);
// Cursor
drect_border(8 * camera->cursor_x + 3, 8 * camera->cursor_y, 8 * camera->cursor_x + 11, 8 * camera->cursor_y + 8, C_WHITE, 1, C_BLACK);
dline(8 * camera->cursor_x + 6, 8 * camera->cursor_y + 4, 8 * camera->cursor_x + 8, 8 * camera->cursor_y + 4, C_BLACK);
dline(8 * camera->cursor_x + 7, 8 * camera->cursor_y + 3, 8 * camera->cursor_x + 7, 8 * camera->cursor_y + 5, C_BLACK);
dupdate();
if (disp_cursor)
{
int middle_x = floor(camera->cursor_size[0] / 2) + 3;
int middle_y = floor(camera->cursor_size[1] / 2);
drect_border(camera->cursor_size[0] * camera->cursor_x + 3, camera->cursor_size[1] * camera->cursor_y, camera->cursor_size[0] * camera->cursor_x + 3 + camera->cursor_size[0], camera->cursor_size[1] * camera->cursor_y + camera->cursor_size[1], C_WHITE, 1, C_BLACK);
dline(camera->cursor_size[0] * camera->cursor_x + middle_x - 1, camera->cursor_size[1] * camera->cursor_y + middle_y , camera->cursor_size[0] * camera->cursor_x + middle_x + 1, camera->cursor_size[1] * camera->cursor_y + middle_y , C_BLACK);
dline(camera->cursor_size[0] * camera->cursor_x + middle_x , camera->cursor_size[1] * camera->cursor_y + middle_y - 1, camera->cursor_size[0] * camera->cursor_x + middle_x , camera->cursor_size[1] * camera->cursor_y + middle_y + 1, C_BLACK);
}
}

View File

@ -2,14 +2,18 @@
#define _DISPLAY_H
#include "calccity.h"
#include "core.h"
// title_screen : display title screen
void title_screen(void);
// main_display : the general display function
void main_display(struct calccity *calccity, struct camera *camera, struct map *map, const int disp_cursor);
// display_large_map : display the current state of the large map
void display_large_map(struct calccity *calccity, struct camera *camera, struct map *map);
// display_around : display the screen frame and cursor
void display_around(struct calccity *calccity, struct camera *camera);
void display_around(struct calccity *calccity, struct camera *camera, const int disp_cursor);
#endif /* _DISPLAY_H */

View File

@ -1,113 +1,57 @@
#include <gint/keyboard.h>
#include <gint/display.h>
#include <gint/std/stdlib.h>
#include <stdlib.h>
#include "menus.h"
void menu_5(struct calccity *calccity)
struct building menu_1(struct calccity *calccity, struct camera *camera, struct map *map, int *build_mode)
{
int scroll = 0, key = 0;
int opt = GETKEY_DEFAULT & GETKEY_REP_ARROWS;
int timeout = 0;
static const char *names[23] = {
"GENERAL",
"ARGENT",
"POPULATION",
"BONHEUR",
"SANTE",
"EDUCATION",
"LOGEMENT",
"TRAVAIL",
"NOURRITURE",
"EAU",
"ENERGIE",
"TRANSPORT",
"DECHETS",
"TOMBES",
"RISQUES",
"CRIME",
"RISQUE INCENDIE",
"RISQUE NUCLEAIRE",
"POLLUTION",
"COMMERCE",
"PRODUCTION",
"IMPORT",
"EXPORT"
};
long int values[23] = {
-1,
calccity->misc[0],
calccity->population[0],
calccity->humans[0],
calccity->humans[1],
calccity->humans[2],
calccity->humans[3],
calccity->humans[4],
calccity->humans[5],
calccity->production[0],
calccity->production[1],
calccity->misc[6],
calccity->misc[7],
calccity->misc[8],
-1,
calccity->misc[1],
calccity->misc[3],
calccity->misc[4],
calccity->misc[5],
-1,
calccity->trade[2],
calccity->trade[0],
calccity->trade[1]
};
extern const bopti_image_t img_fn_1;
int key = 0, x = 0, y = 0;
while (key != KEY_ALPHA)
{
dclear(C_WHITE);
// Title
drect(0, 0, 127, 6, C_BLACK);
dtext(27, 1, C_WHITE, "STATISTIQUES");
display_large_map(calccity, camera, map);
display_around(calccity, camera, 0);
drect(3, 57, 19, 64, C_INVERT);
// Frame
dhline(0, C_BLACK);
dhline(63, C_BLACK);
dvline(0, C_BLACK);
dvline(127, C_BLACK);
// Scroll bar
dline(5, 6, 5, 63, C_BLACK);
drect(2, scroll + 8, 3, 8 + scroll + 38, C_BLACK);
for (int i = 0; i < 8; i ++)
{
if (values[i + scroll] < 0)
{
drect(5, 7 + i * 7, 127, 13 + i * 7, C_BLACK);
dtext(12, 8 + i * 7, C_WHITE, names[i + scroll]);
}
else
dprint(7, 8 + i * 7, C_BLACK, "%s %lu", names[i + scroll], values[i + scroll]);
}
dimage(3, 11, &img_fn_1);
drect(9 * x + 4, 9 * y + 12, 9 * x + 4 + 7, 9 * y + 12 + 7, C_INVERT);
dupdate();
key = getkey_opt(opt, &timeout).key;
struct building default_building = buildings[x + 3 * y];
key = rtc_key();
switch (key)
{
case KEY_UP:
if (scroll > 0) scroll --;
if (y > 0) y --;
break;
case KEY_LEFT:
if (x > 0) x --;
break;
case KEY_DOWN:
if (scroll < 15) scroll ++;
if (y < 4) y ++;
break;
case KEY_RIGHT:
if (x < 2) x ++;
break;
case KEY_SHIFT:
*build_mode = 1;
return buildings[x + y * 3];
break;
}
}
*build_mode = 0;
return default_building;
}
@ -174,6 +118,124 @@ void menu_4(struct calccity *calccity)
}
void menu_5(struct calccity *calccity)
{
int scroll = 0, key = 0;
int opt = GETKEY_DEFAULT & GETKEY_REP_ARROWS;
int timeout = 0;
static const char *names[28] = {
"GENERAL",
"ARGENT",
"POPULATION",
"LOGEMENT",
"SANTE",
"EDUCATION",
"NOURRITURE",
"TRAVAIL",
"TRANSPORT",
"SECURITE",
"CRIME",
"RISQUE INCENDIE",
"RISQUE NUCLEAIRE",
"POLLUTION",
"ECONOMIE",
"COMMERCE",
"INDUSTRIE",
"PRODUCTION",
"IMPORT",
"EXPORT",
"COUT ANNUEL",
"DIVERS",
"CONSO. EAU",
"PRODU. EAU",
"CONSO. ENERGIE",
"PRODU. ENERGIE",
"DECHETS",
"TOMBES"
};
long values[28] = {0};
int offset = 0;
for (int i = 0; i < 28; i ++)
{
switch (i)
{
case 0: case 9: case 14: case 21:
values[i] = -1;
offset ++;
break;
case 1:
values[i] = calccity->misc[0];
offset ++;
break;
case 2:
values[i] = calccity->misc[1];
offset ++;
break;
case 23:
values[i] = calccity->misc[8];
offset ++;
break;
default:
values[i] = calccity->stat[i - offset];
break;
}
}
while (key != KEY_ALPHA)
{
dclear(C_WHITE);
// Title
drect(0, 0, 127, 6, C_BLACK);
dtext(27, 1, C_WHITE, "STATISTIQUES");
// Frame
dhline(0, C_BLACK);
dhline(63, C_BLACK);
dvline(0, C_BLACK);
dvline(127, C_BLACK);
// Scroll bar
dline(5, 6, 5, 63, C_BLACK);
drect(2, scroll + 8, 3, 8 + scroll + 33, C_BLACK);
for (int i = 0; i < 8; i ++)
{
if (values[i + scroll] < 0)
{
drect(5, 7 + i * 7, 127, 13 + i * 7, C_BLACK);
dtext(12, 8 + i * 7, C_WHITE, names[i + scroll]);
}
else
dprint(7, 8 + i * 7, C_BLACK, "%s %lu", names[i + scroll], values[i + scroll]);
}
dupdate();
key = getkey_opt(opt, &timeout).key;
switch (key)
{
case KEY_UP:
if (scroll > 0) scroll --;
break;
case KEY_DOWN:
if (scroll < 20) scroll ++;
break;
}
}
}
int menu_6(struct calccity *calccity)
{
int choice = 0, key = 0;
@ -182,12 +244,12 @@ int menu_6(struct calccity *calccity)
while (key != KEY_ALPHA)
{
int prcnt = 100 - (calccity->time_speed * 100 / 10000);
int prcnt = 100 - (calccity->time_speed * 100 / 7500);
dclear(C_WHITE);
drect(0, 0, 127, 6, C_BLACK);
dtext(39, 1, C_WHITE, "OPTIONS");
dtext(42, 1, C_WHITE, "OPTIONS");
dhline(0, C_BLACK);
dhline(63, C_BLACK);

View File

@ -2,7 +2,10 @@
#define _MENUS_H
#include "calccity.h"
#include "core.h"
// menu_1 : building 1
struct building menu_1(struct calccity *calccity, struct camera *camera, struct map *map, int *build_mode);
// menu_4 : tax and funds
void menu_4(struct calccity *calccity);