Skip to content

Expand tiles UI #1998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
16ef9b4
Adjust points cost
SneakBug8 Jun 13, 2025
d2ad815
Merge remote-tracking branch 'origin/main' into feature/province-tile…
SneakBug8 Jun 13, 2025
2375e2e
Expand RGO tooltip
SneakBug8 Jun 8, 2025
da646ee
Admin and market tiles
SneakBug8 Jun 13, 2025
679b044
Local admin employment
SneakBug8 Jun 13, 2025
ecdd9ca
Local admin wages
SneakBug8 Jun 13, 2025
b73b7a9
capital administration tile
SneakBug8 Jun 13, 2025
eeada8d
regional admin building
SneakBug8 Jun 13, 2025
5e33d78
Fixes
SneakBug8 Jun 13, 2025
031fa76
Fix govt empl calculations
SneakBug8 Jun 13, 2025
02df4ba
fix
SneakBug8 Jun 13, 2025
665024f
a comment
SneakBug8 Jun 13, 2025
b9a67ce
Local tax offices (no admin tile)
SneakBug8 Jun 13, 2025
86a1261
fix
SneakBug8 Jun 13, 2025
4609063
case for unowned provinces
SneakBug8 Jun 13, 2025
e565e95
minor tooltip changes
SneakBug8 Jun 13, 2025
d68c1a4
undo change
SneakBug8 Jun 13, 2025
497d5ee
Bring back potentials in uncolonized
SneakBug8 Jun 13, 2025
650cdc4
Expanded tooltips
SneakBug8 Jun 14, 2025
de96ec2
Merge remote-tracking branch 'origin/main' into feature/province-tile…
SneakBug8 Jun 22, 2025
b852af8
Market tile first version
SneakBug8 Jun 23, 2025
fb8c431
expanded market tile
SneakBug8 Jun 23, 2025
ac6c725
Trade attractiveness modifier
SneakBug8 Jun 23, 2025
c1e1ab9
Province building tooltips
SneakBug8 Jun 24, 2025
7377c8c
Tooltips on province buildings
SneakBug8 Jun 24, 2025
6ffff97
Fix trade tooltip calculations
SneakBug8 Jun 24, 2025
9df35b8
Fix trade centre tooltip
SneakBug8 Jun 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/alice.gfx
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,6 @@ spriteTypes = {
spriteType = {
name = "provincetiles"
texturefile = "assets\\provincetiles.png"
noOfFrames = 15
noOfFrames = 22
}
}
48 changes: 44 additions & 4 deletions assets/localisation/en-US/alice.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PROVINCEVIEW_GOODSINCOME;Sold ?Y$x$?W ?Y$GOODS$?W for ?Y$VALUE$?W yesterday
support_for_blank;support for $text$
uh_support_for_blank;upper house support for $text$
up_to;up to
Expand Down Expand Up @@ -377,6 +378,30 @@ has_not_recently_lost_war;has not recently lost a war
mobilized;mobilized
mobilization_size;mobilization size
admin_spending;administration spending
employment_type_no_education;Employment type: ?YNo education?W
employment_type_basic_education;Employment type: ?YBasic education?W
employment_type_high_education_and_accepted;Employment type: ?YHigh Education and Accepted?W
employment_type_high_education;Employment type: ?YHigh Education?W
alice_trade_attractiveness;Trade Route Attraction
trade_center;Trade Centre
trade_center_desc;Trade Centres manage trade inside the market and between state-level markets, buying goods up to desired stockpile and selling extras to neighbours.
trade_center_employment;Trade Center Employees: ?Y$value$?W
trade_centre_max_throughput;Max throughput: ?Y$value$?W
local_admin;Local Administration
capital_admin;Capital Administration
local_admin_spending;Estimated cost: ?Y$value$?W
local_admin_employment;Administration Employees: ?Y$value$?W
target_employment;Target employment: ?Y$value$?W
employment_satisfaction;Employment satisfaction: ?Y$value$?W
wage;Wage: ?Y$value$?W
local_admin_efficiency;Local administrations are ?Y$value$?W less efficient than the capital one.
tax_collection_rate;Tax collection rate: ?Y$value$?W
poor_potential;Potential poor taxes: ?Y$value$?W
mid_potential;Potential middle taxes: ?Y$value$?W
rich_potential;Potential rich taxes: ?Y$value$?W
poor_taxes;Actual poor taxes: ?Y$value$?W
mid_taxes;Actual middle taxes: ?Y$value$?W
rich_taxes;Actual rich taxes: ?Y$value$?W
greater_than_edu_spending;greater than education spending
support_for_rp;support for ruling party
colonial;colonial
Expand Down Expand Up @@ -517,9 +542,10 @@ factory_upgrade_condition_11;State has available resource potentials
factory_delete_header;Delete factory
factory_delete_not_allowed;The ruling party does not allow us to delete factories
factory_level;Factory level ?Y$val$
factory_stats_1;This factory is currently operating at $val$ capacity
factory_stats_2;This factory is targeting $val$ capacity
factory_stats_3;It produced $val$ units of $x$ in the previous day
factory_employment;Factory employees: ?Y$val$
factory_stats_1;Current production scale: ?Y$val$?W
factory_stats_2;Target production scale: ?Y$val$?W
factory_stats_3;Yesterday it produced ?Y$val$ $good$?W sold for ?Y$x$?W
factory_stats_4;It made a profit of $val$ in the previous day
factory_stats_5;Inputs availability:
factory_stats_6;Efficiency inputs availability:
Expand Down Expand Up @@ -1185,7 +1211,11 @@ alice_spending_commodity_2;?R$cost$?W - Buying $need$ of $name$ (at $val$ x unit
alice_recommended_build;?GThis factory is recommended to be built?W
alice_factory_bonus;We will receive a ?Y$x$?W bonus if:
alice_factory_inputs;Inputs required:
alice_factory_construction_cost;Construction cost:
alice_construction_cost;Construction cost:
alice_building_modifier;Building gives the following effect:
alice_new_building_modifier;Building will give the following effect:
alice_building_level;Building Level: ?Y$val$?W
alice_building_conditions;To build, the following must be true:
alice_factory_construction_explain_3;Purchased goods worth: ?Y$x$?W
alice_factory_construction_explain_4;Total estimated price: ?Y$x$?W
alice_factory_construction_explain_5;Progress: ?Y$x$?W
Expand Down Expand Up @@ -1419,6 +1449,14 @@ trade_route_volume_base_change;Base expected change: ?Y$val$?W (Current volume ?
trade_route_volume_expansion_multiplier;Expansion multiplier: ?Y$val$?W (Depends on actual access to commodity in exporting market)
trade_route_volume_decay;Decay: ?Y$val$?W (Prevents trade volume from running too far away)
trade_route_volume_final_change;Expected change: ?Y$val$
trade_centre_trade_volume;Trade volume: ?Y$val$
trade_centre_trade_value;Trade value: ?Y$val$
trade_centre_imports_volume;Imports volume: ?Y$val$
trade_centre_imports_value;Imports value: ?Y$val$
trade_centre_exports_volume;Exports volume: ?Y$val$
trade_centre_exports_value;Exports value: ?Y$val$
trade_centre_trade_routes_profit;Profit from trade routes: ?Y$val$
trade_centre_money;Money stockpile: ?Y$val$
investment_pool;Investment pool: ?Y$x$?W
investment_pool_income_1;Population reinvestment: ?G$x$?W
investment_pool_income_2;Transfer from subject $country$: ?G$x$?W
Expand Down Expand Up @@ -1551,6 +1589,8 @@ pop_migration_attraction_3;The migration target factor: $x$
pop_migration_attraction_wage_ratio;And the wage difference multipler: $x$
pop_migration_attraction_bureaucracy;Bureaucracy base attraction: $x$
alice_toggle_administration;Establish or abolish local administration. Administrations outside your control will not work. Consult administrative map mode to check existing administrations.
administration_tile;Local administration
market_tile;Local market
alice_unit_target;===> $x$
alice_lobby_resync;Resync lobby
alice_lobby_resync_players_loading;Cannot resync when players are loading
Expand Down
2 changes: 1 addition & 1 deletion assets/localisation/zh-CN/alice.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ CANBUILD_FORCEDISARM;国家尚未解除武装。
alice_naval_coordination_penalty;$x$ 因超过敌舰规模而受到 ?R$y$?W 的海军协调惩罚,使其目标选择减少了 ?R$val$?W 。
alice_naval_coordination_bonus;$x$ 因低于敌舰规模而受到 ?R$y$?W 的海军协调加成,使其目标选择增加了 ?R$val$?W 。
alice_naval_stacking_penalty;$x$ 因堆叠惩罚而受到 ?R$val$?W 的伤害倍增。
alice_factory_construction_cost;施工成本:
alice_construction_cost;施工成本:
alice_factory_construction_explain_3;购买的商品价值:?Y$x$?W
alice_factory_construction_explain_4;估计总价:?Y$x$?W
alice_factory_construction_explain_5;进展:?Y$x$?W
Expand Down
Binary file modified assets/provincetiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/economy/economy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ bool is_bankrupt_debtor_to(sys::state& state, dcon::nation_id debt_holder, dcon:

// abstract modifiers
float factory_total_desired_employment_score(sys::state const& state, dcon::factory_id f);
float factory_total_desired_employment(sys::state const& state, dcon::factory_id f);
float factory_total_employment(sys::state const& state, dcon::factory_id f);
float factory_unqualified_employment(sys::state const& state, dcon::factory_id f);
float factory_primary_employment(sys::state const& state, dcon::factory_id f);
Expand Down
28 changes: 27 additions & 1 deletion src/economy/economy_government.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void update_consumption_administration(sys::state& state, dcon::nation_id n) {
auto wage = state.world.province_get_labor_price(capital_of_capital_state, economy::labor::high_education_and_accepted);
auto demand = budget_per_administration / wage;
auto sat = state.world.province_get_labor_demand_satisfaction(capital_of_capital_state, economy::labor::high_education_and_accepted);
state.world.province_get_control_scale(capital) += std::max(0.f, (demand * sat - base_admin_employment) * population_per_admin(state, n) * 0.5f);
state.world.province_get_control_scale(capital) += std::max(0.f, (demand * sat - base_admin_employment) * population_per_admin(state, n) * local_administration_efficiency);
state.world.province_set_administration_employment_target(capital_of_capital_state, demand);
state.world.province_get_labor_demand(capital_of_capital_state, economy::labor::high_education_and_accepted) += demand;
});
Expand Down Expand Up @@ -268,4 +268,30 @@ tax_information explain_tax_income(sys::state& state, dcon::nation_id n) {
return result;
}

// Calculate employment of local administrations in the province.
// When using, check for capital administration separately
float explain_administration_employment(sys::state& state, dcon::province_id p) {
auto n = state.world.province_get_nation_from_province_ownership(p);

for(auto admin : state.world.nation_get_nation_administration(n)) {
if(admin.get_administration().get_capital() == p) {
return state.world.province_get_administration_employment_target(p) * state.world.province_get_labor_demand_satisfaction(p, economy::labor::high_education_and_accepted);
}
}

return 0.f;
}

// Calculate employment of the capital administration
float explain_capital_administration_employment(sys::state& state, dcon::nation_id n) {
auto capital = state.world.nation_get_capital(n);
auto capital_state = state.world.province_get_state_membership(capital);
auto capital_of_capital_state = state.world.state_instance_get_capital(capital_state);

auto target_employment = state.world.nation_get_administration_employment_target_in_capital(n);
auto satisfaction = state.world.province_get_labor_demand_satisfaction(capital, economy::labor::high_education_and_accepted);

return target_employment * satisfaction;
}

}
5 changes: 5 additions & 0 deletions src/economy/economy_government.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ struct state;
}

namespace economy {

inline constexpr float local_administration_efficiency = 0.5f;

// see details about internal workings of the system in cpp file

// ratio of taxes you can collect in a given province
Expand Down Expand Up @@ -39,4 +42,6 @@ struct tax_information {
// sums up all tax income all over the nation
tax_information explain_tax_income(sys::state& state, dcon::nation_id n);
tax_information explain_tax_income_local(sys::state& state, dcon::nation_id n, dcon::province_id sid);
float explain_administration_employment(sys::state& state, dcon::province_id p);
float explain_capital_administration_employment(sys::state& state, dcon::nation_id n);
}
170 changes: 127 additions & 43 deletions src/economy/economy_trade_routes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,82 @@

namespace economy {

// Labour demand for a single trade route
float trade_route_labour_demand(sys::state& state, dcon::trade_route_id trade_route, dcon::province_fat_id A_capital, dcon::province_fat_id B_capital) {
auto total_demanded_labor = 0.f;
auto available_labor = std::min(
state.world.province_get_labor_demand_satisfaction(A_capital, labor::no_education),
state.world.province_get_labor_demand_satisfaction(B_capital, labor::no_education)
);

state.world.for_each_commodity([&](auto cid) {
auto current_volume = state.world.trade_route_get_volume(trade_route, cid);
if(current_volume == 0.f) {
return;
}
current_volume = current_volume * std::max(0.999999f, available_labor);
state.world.trade_route_set_volume(trade_route, cid, current_volume);
auto effect_of_scale = std::max(
trade_effect_of_scale_lower_bound,
1.f - std::abs(current_volume) * effect_of_transportation_scale
);
total_demanded_labor += std::abs(current_volume)
* state.world.trade_route_get_distance(trade_route)
/ trade_distance_covered_by_pair_of_workers_per_unit_of_good
* effect_of_scale;
assert(std::isfinite(total_demanded_labor));
});

return total_demanded_labor;
}

// Calculate labour demand for trade routes between markets
float transportation_between_markets_labor_demand(sys::state& state, dcon::market_id market) {

auto total_demanded_labour = 0.f;

for(auto route : state.world.market_get_trade_route(market)) {
auto A = state.world.trade_route_get_connected_markets(route, 0);
auto B = state.world.trade_route_get_connected_markets(route, 1);

auto A_capital = state.world.state_instance_get_capital(state.world.market_get_zone_from_local_market(A));
auto B_capital = state.world.state_instance_get_capital(state.world.market_get_zone_from_local_market(B));

total_demanded_labour += trade_route_labour_demand(state, route, A_capital, B_capital);
}

return total_demanded_labour;
}


// Calculate labour demand for trade inside the market
float transportation_inside_market_labor_demand(sys::state& state, dcon::market_id market, dcon::province_id capital) {
auto base_cargo_transport_demand = 0.f;

state.world.for_each_commodity([&](auto commodity) {
state.world.market_for_each_trade_route(market, [&](auto trade_route) {
auto current_volume = state.world.trade_route_get_volume(trade_route, commodity);
auto origin =
current_volume > 0.f
? state.world.trade_route_get_connected_markets(trade_route, 0)
: state.world.trade_route_get_connected_markets(trade_route, 1);
auto target =
current_volume <= 0.f
? state.world.trade_route_get_connected_markets(trade_route, 0)
: state.world.trade_route_get_connected_markets(trade_route, 1);

//auto sat = state.world.market_get_direct_demand_satisfaction(origin, commodity);
base_cargo_transport_demand += std::abs(current_volume);
});
});

// auto soft_transport_demand_limit = state.world.market_get_max_throughput(market);
//if(base_cargo_transport_demand > soft_transport_demand_limit) {
// base_cargo_transport_demand = base_cargo_transport_demand * base_cargo_transport_demand / soft_transport_demand_limit;
//}

return base_cargo_transport_demand;
}

tariff_data explain_trade_route(sys::state& state, dcon::trade_route_id trade_route) {
auto m0 = state.world.trade_route_get_connected_markets(trade_route, 0);
Expand Down Expand Up @@ -76,6 +152,52 @@ tariff_data explain_trade_route(sys::state& state, dcon::trade_route_id trade_ro
};
}

void make_trade_center_tooltip(sys::state& state, text::columnar_layout& contents, dcon::market_id market) {
auto trade_volume = 0.f;
auto trade_value = 0.f;
auto imports_volume = 0.f;
auto imports_value = 0.f;
auto exports_volume = 0.f;
auto exports_value = 0.f;
auto profit = 0.f;

auto labour_demand = 0.f;

for(auto commodity : state.world.in_commodity) {
for(auto route : state.world.market_get_trade_route(market)) {
auto explain = explain_trade_route_commodity(state, route, commodity);

if(market == explain.origin && explain.amount_origin > 0) {
exports_volume += explain.amount_origin;
exports_value += explain.amount_origin * explain.price_origin;
trade_value += explain.amount_origin * explain.price_origin;
trade_volume += explain.amount_origin;
profit += explain.amount_origin * explain.payment_received_per_unit;
}
else if(market == explain.target && explain.amount_target > 0) {
exports_volume += explain.amount_target;
exports_value += explain.amount_target * explain.price_target;
trade_value += explain.amount_target * explain.price_target;
trade_volume += explain.amount_target;
profit -= explain.amount_target * explain.payment_per_unit;
}
}
}

text::add_line(state, contents, "trade_centre_trade_volume", text::variable_type::val, text::fp_two_places{ trade_volume });
text::add_line(state, contents, "trade_centre_imports_volume", text::variable_type::val, text::fp_two_places{ imports_volume }, 15);
text::add_line(state, contents, "trade_centre_exports_volume", text::variable_type::val, text::fp_two_places{ exports_volume }, 15);

text::add_line(state, contents, "trade_centre_max_throughput", text::variable_type::val, text::fp_two_places{ state.world.market_get_max_throughput(market) });

text::add_line(state, contents, "trade_centre_trade_value", text::variable_type::val, text::fp_currency{ trade_value });
text::add_line(state, contents, "trade_centre_imports_value", text::variable_type::val, text::fp_currency{ imports_value }, 15);
text::add_line(state, contents, "trade_centre_exports_value", text::variable_type::val, text::fp_currency{ exports_value }, 15);

text::add_line(state, contents, "trade_centre_trade_routes_profit", text::variable_type::val, text::fp_currency{ profit });
text::add_line(state, contents, "trade_centre_money", text::variable_type::val, text::fp_currency{ state.world.market_get_stockpile(market, money) });
}

void make_trade_volume_tooltip(
sys::state& state,
text::columnar_layout& contents,
Expand Down Expand Up @@ -793,35 +915,14 @@ void update_trade_routes_consumption(sys::state& state) {
// register trade demand on transportation labor:
// money are paid during calculation of trade route profits and actual movement of goods
state.world.for_each_trade_route([&](auto trade_route) {

auto A = state.world.trade_route_get_connected_markets(trade_route, 0);
auto B = state.world.trade_route_get_connected_markets(trade_route, 1);

auto A_capital = state.world.state_instance_get_capital(state.world.market_get_zone_from_local_market(A));
auto B_capital = state.world.state_instance_get_capital(state.world.market_get_zone_from_local_market(B));

auto total_demanded_labor = 0.f;
auto available_labor = std::min(
state.world.province_get_labor_demand_satisfaction(A_capital, labor::no_education),
state.world.province_get_labor_demand_satisfaction(B_capital, labor::no_education)
);

state.world.for_each_commodity([&](auto cid) {
auto current_volume = state.world.trade_route_get_volume(trade_route, cid);
if(current_volume == 0.f) {
return;
}
current_volume = current_volume * std::max(0.999999f, available_labor);
state.world.trade_route_set_volume(trade_route, cid, current_volume);
auto effect_of_scale = std::max(
trade_effect_of_scale_lower_bound,
1.f - std::abs(current_volume) * effect_of_transportation_scale
);
total_demanded_labor += std::abs(current_volume)
* state.world.trade_route_get_distance(trade_route)
/ trade_distance_covered_by_pair_of_workers_per_unit_of_good
* effect_of_scale;
assert(std::isfinite(total_demanded_labor));
});

auto total_demanded_labor = trade_route_labour_demand(state, trade_route, A_capital, B_capital);

state.world.province_get_labor_demand(A_capital, labor::no_education) += total_demanded_labor;
state.world.province_get_labor_demand(B_capital, labor::no_education) += total_demanded_labor;
Expand All @@ -837,26 +938,9 @@ void update_trade_routes_consumption(sys::state& state) {

state.world.for_each_market([&](auto market) {
auto capital = state.world.state_instance_get_capital(state.world.market_get_zone_from_local_market(market));
auto base_cargo_transport_demand = 0.f;
auto soft_transport_demand_limit = state.world.market_get_max_throughput(market);

state.world.for_each_commodity([&](auto commodity) {
state.world.market_for_each_trade_route(market, [&](auto trade_route) {
auto current_volume = state.world.trade_route_get_volume(trade_route, commodity);
auto origin =
current_volume > 0.f
? state.world.trade_route_get_connected_markets(trade_route, 0)
: state.world.trade_route_get_connected_markets(trade_route, 1);
auto target =
current_volume <= 0.f
? state.world.trade_route_get_connected_markets(trade_route, 0)
: state.world.trade_route_get_connected_markets(trade_route, 1);

//auto sat = state.world.market_get_direct_demand_satisfaction(origin, commodity);
base_cargo_transport_demand += std::abs(current_volume);
});
});
auto base_cargo_transport_demand = transportation_inside_market_labor_demand(state, market, capital);

// auto soft_transport_demand_limit = state.world.market_get_max_throughput(market);
//if(base_cargo_transport_demand > soft_transport_demand_limit) {
// base_cargo_transport_demand = base_cargo_transport_demand * base_cargo_transport_demand / soft_transport_demand_limit;
//}
Expand Down
10 changes: 10 additions & 0 deletions src/economy/economy_trade_routes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ struct trade_route_volume_change_reasons {
bool commodity_is_not_discovered;
};

float trade_route_labour_demand(sys::state& state, dcon::trade_route_id trade_route, dcon::province_fat_id A_capital, dcon::province_fat_id B_capital);
float transportation_between_markets_labor_demand(sys::state& state, dcon::market_id market);
float transportation_inside_market_labor_demand(sys::state& state, dcon::market_id market, dcon::province_id capital);

void make_trade_center_tooltip(
sys::state& state,
text::columnar_layout& contents,
dcon::market_id market
);

void make_trade_volume_tooltip(
sys::state& state,
text::columnar_layout& contents,
Expand Down
Loading