4 uint32_t province_size = state.world.province_size();
5 uint32_t texture_size = province_size + 256 - province_size % 256;
7 std::vector<uint32_t> prov_color(texture_size * 2);
9 auto selected = state.map_state.selected_province;
10 auto for_nation = state.world.province_get_nation_from_province_ownership(selected);
14 for(
auto p : state.world.nation_get_province_ownership(for_nation)) {
15 auto v = p.get_province().get_daily_net_migration();
20 for(
auto p : state.world.nation_get_province_ownership(for_nation)) {
21 auto v = p.get_province().get_daily_net_migration();
28 prov_color[i] = color;
29 prov_color[i + texture_size] = color;
33 static auto last_checked_date =
sys::date{};
34 static std::vector<float> nation_totals;
36 if(state.ui_date != last_checked_date) {
37 last_checked_date = state.ui_date;
39 auto sz = state.world.nation_size();
40 if(
uint32_t(nation_totals.size()) < sz) {
41 nation_totals.resize(sz);
45 nation_totals[i] = 0.0f;
47 float least_neg = -1.0f;
48 float greatest_pos = 1.0f;
49 for(
auto p : state.world.in_province) {
50 auto owner = p.get_nation_from_province_ownership();
51 if(owner &&
uint32_t(owner.id.index()) < sz) {
52 auto v = p.get_daily_net_immigration();
53 nation_totals[owner.id.index()] += v;
57 if(nation_totals[i] < 0.0f)
58 least_neg = std::min(nation_totals[i], least_neg);
60 greatest_pos = std::max(nation_totals[i], greatest_pos);
63 if(nation_totals[i] < 0.0f) {
64 nation_totals[i] = 0.5f - 0.5f * nation_totals[i] / least_neg;
65 }
else if(nation_totals[i] > 0.0f) {
66 nation_totals[i] = 0.5f + 0.5f * nation_totals[i] / greatest_pos;
68 nation_totals[i] = 0.5f;
72 for(
auto p : state.world.in_province) {
73 auto owner = p.get_nation_from_province_ownership();
74 if(owner &&
uint32_t(owner.id.index()) < nation_totals.size()) {
80 prov_color[i] = color;
81 prov_color[i + texture_size] = color;
std::vector< uint32_t > migration_map_from(sys::state &state)
uint32_t color_gradient(float percent, uint32_t top_color, uint32_t bot_color)
constexpr uint16_t to_map_id(dcon::province_id id)
uint32_t pack_color(float r, float g, float b)