Company List Window (#508)

* Initial Setup and window open

* Further work on events

* Implement Draw Events

* Implement draw scroll for Company List

* Fix for CI

* Remove duplicate function

* Fix clang formatting

* Fix window resetting too many variables when reopening window
This commit is contained in:
Svelbeard 2020-07-07 19:58:23 +01:00 committed by GitHub
parent 4335bd1bd9
commit 433c35344b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 1817 additions and 20 deletions

View File

@ -19,6 +19,7 @@ namespace openloco
enum company_flags
{
sorted = (1 << 3), // 0x08
increased_performance = (1 << 4), // 0x10
decreased_performance = (1 << 5), // 0x20
challenge_completed = (1 << 6), // 0x40
@ -76,21 +77,24 @@ namespace openloco
uint8_t headquarters_z; // 0x2579
coord_t headquarters_x; // 0x257A -1 on no headquarter placed
coord_t headquarters_y; // 0x257C
uint8_t pad_257E[0x88CE - 0x257E];
currency48_t companyValue; // 0x88CE
uint8_t pad_88D4[0x8B9E - 0x88D4];
currency48_t vehicleProfit; // 0x8B9E
uint16_t transportTypeCount[6]; // 0x8BA4
uint8_t pad_257E[0x85FC - 0x257E];
uint32_t cargo_units_delivered_history[120]; // 0x85FC
int16_t performance_index_history[120]; // 0x87DC
uint16_t history_size; // 0x88CC
currency48_t companyValueHistory[120]; // 0x88CE
currency48_t vehicleProfit; // 0x8B9E
uint16_t transportTypeCount[6]; // 0x8BA4
uint8_t var_8BB0[9];
uint8_t pad_8BB9[0x8BBC - 0x8BB9];
thing_id_t observation_thing; // 0x_8BBC;
thing_id_t observation_thing; // 0x8BBC;
int16_t observation_x; // 0x8BBE;
int16_t observation_y; // 0x8BC0;
uint8_t pad_8BC2[0x8BCE - 0x8BC2];
uint32_t cargoDelivered[32]; // 0x8BCE;
uint8_t var_8C4E;
uint8_t pad_8C4F[0x8E34 - 0x8C4F];
uint16_t jail_status; // 0x8E34
uint8_t pad_8C4F[0x8C54 - 0x8C4F];
uint32_t cargo_units_distance_history[120]; // 0x008C54
uint16_t jail_status; // 0x8E34
uint8_t pad_8E36[0x8FA8 - 0x8E36];
company_id_t id() const;
@ -102,7 +106,7 @@ namespace openloco
static_assert(sizeof(company) == 0x8FA8);
static_assert(sizeof(company::expenditures) == 0x440);
static_assert(offsetof(company, companyValue) == 0x88CE);
static_assert(offsetof(company, companyValueHistory[0]) == 0x88CE);
static_assert(offsetof(company, vehicleProfit) == 0x8B9E);
static_assert(offsetof(company, var_8C4E) == 0x8C4E);
static_assert(offsetof(company, var_8BB0) == 0x8BB0);

View File

@ -140,6 +140,21 @@ namespace openloco::companymgr
return regs.bx;
}
owner_status getOwnerStatus(company_id_t id)
{
registers regs;
regs.esi = (int32_t)get(id);
call(0x00438047, regs);
owner_status ownerStatus;
ownerStatus.string = regs.bx;
ownerStatus.argument1 = regs.ecx;
ownerStatus.argument2 = regs.edx;
return ownerStatus;
}
// 0x004383ED
void updateOwnerStatus()
{

View File

@ -19,7 +19,15 @@ namespace openloco::companymgr
uint8_t get_player_company_colour();
void update();
struct owner_status
{
string_id string;
uint32_t argument1;
uint32_t argument2;
};
company* getOpponent();
string_id getOwnerStatus(company_id_t id, FormatArguments& args);
owner_status getOwnerStatus(company_id_t id);
void updateOwnerStatus();
}

View File

@ -1056,7 +1056,33 @@ namespace openloco::string_ids
constexpr string_id menu_map = 1742;
constexpr string_id dropdown_companies_list = 1743;
constexpr string_id dropdown_company_performance = 1744;
constexpr string_id title_company_list = 1745;
constexpr string_id title_company_performance = 1746;
constexpr string_id title_company_cargo_units = 1747;
constexpr string_id title_company_values = 1748;
constexpr string_id title_cargo_payment_rates = 1749;
constexpr string_id tab_compare_companies = 1750;
constexpr string_id tab_company_performance = 1751;
constexpr string_id tab_cargo_graphs = 1752;
constexpr string_id tab_company_values = 1753;
constexpr string_id tab_cargo_payment_rates = 1754;
constexpr string_id tooltip_sort_company_name = 1755;
constexpr string_id tooltip_sort_company_status = 1756;
constexpr string_id tooltip_sort_company_performance = 1757;
constexpr string_id tooltip_sort_company_value = 1758;
constexpr string_id table_header_company_name = 1759;
constexpr string_id table_header_company_name_desc = 1760;
constexpr string_id table_header_company_status = 1761;
constexpr string_id table_header_company_status_desc = 1762;
constexpr string_id table_header_company_performance = 1763;
constexpr string_id table_header_company_performance_desc = 1764;
constexpr string_id table_header_company_value = 1765;
constexpr string_id table_header_company_value_desc = 1766;
constexpr string_id table_item_company = 1767;
constexpr string_id performance_index = 1768;
constexpr string_id performance_index_decrease = 1769;
constexpr string_id performance_index_increase = 1770;
constexpr string_id company_value_currency = 1771;
constexpr string_id corporate_rating_platelayer = 1772;
constexpr string_id corporate_rating_engineer = 1773;
constexpr string_id corporate_rating_traffic_manager = 1774;
@ -1067,10 +1093,24 @@ namespace openloco::string_ids
constexpr string_id corporate_rating_chairman = 1779;
constexpr string_id corporate_rating_president = 1780;
constexpr string_id corporate_rating_tycoon = 1781;
constexpr string_id company_singular = 1782;
constexpr string_id companies_plural = 1783;
constexpr string_id rawdate_short = 1784;
constexpr string_id percentage_one_decimal_place = 1785;
constexpr string_id cargo_units_delivered = 1787;
constexpr string_id player_info_performance = 1788;
constexpr string_id player_info_performance_decrease = 1789;
constexpr string_id player_info_performance_increase = 1790;
constexpr string_id small_company_value_currency = 1791;
constexpr string_id small_black_string = 1792;
constexpr string_id small_white_string = 1793;
constexpr string_id currency_symbol = 1795;
constexpr string_id cargo_delivered_days = 1796;
constexpr string_id cargo_delivered_currency = 1797;
constexpr string_id cargo_deliver_graph_title = 1798;
constexpr string_id cargo_transit_time = 1799;
constexpr string_id toolbar_status_paused = 1800;
@ -1132,6 +1172,16 @@ namespace openloco::string_ids
constexpr string_id the_other_player = 1934;
// String ids 1943--1982 (some blank) were used in the Atari credits screen, but are now unused.
constexpr string_id title_cargo_distance_graphs = 1983;
constexpr string_id tab_cargo_distance_graphs = 1984;
constexpr string_id tab_speed_records = 1995;
constexpr string_id speed_records = 1995;
constexpr string_id title_speed_records = 1996;
constexpr string_id land_speed_record = 1997;
constexpr string_id air_speed_record = 1998;
constexpr string_id water_speed_record = 1999;
constexpr string_id record_date_achieved = 2000;
constexpr string_id window_browse_input_caret = 2003;
constexpr string_id window_browse_filename = 2004;

View File

@ -74,7 +74,7 @@ namespace openloco
constexpr uint32_t toolbar_build_vehicle_boat_hover = 42;
constexpr uint32_t toolbar_stations = 43;
constexpr uint32_t toolbar_stations_hover = 44;
constexpr uint32_t tab_awards = 45;
constexpr uint32_t toolbar_menu_airport = 46;
constexpr uint32_t toolbar_menu_ship_port = 47;
constexpr uint32_t tab_cargo_ratings = 48;
@ -95,7 +95,30 @@ namespace openloco
constexpr uint32_t tab_population_frame5 = 62;
constexpr uint32_t tab_population_frame6 = 63;
constexpr uint32_t tab_population_frame7 = 64;
constexpr uint32_t tab_performance_index_frame0 = 65;
constexpr uint32_t tab_performance_index_frame1 = 66;
constexpr uint32_t tab_performance_index_frame2 = 67;
constexpr uint32_t tab_performance_index_frame3 = 68;
constexpr uint32_t tab_performance_index_frame4 = 69;
constexpr uint32_t tab_performance_index_frame5 = 70;
constexpr uint32_t tab_performance_index_frame6 = 71;
constexpr uint32_t tab_performance_index_frame7 = 72;
constexpr uint32_t tab_cargo_units_frame0 = 73;
constexpr uint32_t tab_cargo_units_frame1 = 74;
constexpr uint32_t tab_cargo_units_frame2 = 75;
constexpr uint32_t tab_cargo_units_frame3 = 76;
constexpr uint32_t tab_cargo_units_frame4 = 77;
constexpr uint32_t tab_cargo_units_frame5 = 78;
constexpr uint32_t tab_cargo_units_frame6 = 79;
constexpr uint32_t tab_cargo_units_frame7 = 80;
constexpr uint32_t tab_cargo_distance_frame0 = 81;
constexpr uint32_t tab_cargo_distance_frame1 = 82;
constexpr uint32_t tab_cargo_distance_frame2 = 83;
constexpr uint32_t tab_cargo_distance_frame3 = 84;
constexpr uint32_t tab_cargo_distance_frame4 = 85;
constexpr uint32_t tab_cargo_distance_frame5 = 86;
constexpr uint32_t tab_cargo_distance_frame6 = 87;
constexpr uint32_t tab_cargo_distance_frame7 = 88;
constexpr uint32_t tab_production_frame0 = 89;
constexpr uint32_t tab_production_frame1 = 90;
constexpr uint32_t tab_production_frame2 = 91;
@ -191,6 +214,7 @@ namespace openloco
constexpr uint32_t tab_cargo_delivered_frame1 = 199;
constexpr uint32_t tab_cargo_delivered_frame2 = 200;
constexpr uint32_t tab_cargo_delivered_frame3 = 201;
constexpr uint32_t tab_cargo_payment_rates = 202;
constexpr uint32_t build_vehicle_train_frame_0 = 251;
constexpr uint32_t build_vehicle_train_frame_1 = 252;

View File

@ -149,6 +149,11 @@ namespace openloco
return (_screen_flags & screen_flags::unknown_4) != 0;
}
bool is_unknown_5_mode()
{
return (_screen_flags & screen_flags::unknown_5) != 0;
}
bool is_paused()
{
return paused_state;

View File

@ -32,6 +32,7 @@ namespace openloco
bool isNetworked();
bool isTrackUpgradeMode();
bool is_unknown_4_mode();
bool is_unknown_5_mode();
bool is_paused();
uint8_t get_pause_flags();
uint32_t scenario_ticks();

View File

@ -276,7 +276,7 @@ namespace openloco::ui::windows::CompanyFaceSelection
namespace openloco::ui::windows::CompanyList
{
void openPerformanceIndexes();
void openUnk();
window* open();
}
namespace openloco::ui::windows::CompanyWindow

File diff suppressed because it is too large Load Diff

View File

@ -1713,7 +1713,7 @@ namespace openloco::ui::windows::CompanyWindow
{
// Set company value in format args.
FormatArguments args{};
args.push(company->companyValue);
args.push(company->companyValueHistory[0]);
gfx::draw_string_494B3F(
*dpi,

View File

@ -151,7 +151,7 @@ namespace openloco::ui::windows::PlayerInfoPanel
// If its index is bigger than the list then its the company list extra item
if (static_cast<uint16_t>(itemIndex) >= _sortedCompanies.size())
{
windows::CompanyList::openUnk();
windows::CompanyList::open();
}
else
{
@ -353,7 +353,7 @@ namespace openloco::ui::windows::PlayerInfoPanel
static void companyValueTooltip(FormatArguments& args)
{
auto playerCompany = companymgr::get(companymgr::get_controlling_id());
args.push(playerCompany->companyValue);
args.push(playerCompany->companyValueHistory[0]);
args.push(playerCompany->vehicleProfit);
}