Project Alice
Loading...
Searching...
No Matches
admin.hpp
Go to the documentation of this file.
1#pragma once
2
3std::vector<uint32_t> admin_map_from(sys::state& state) {
4 uint32_t province_size = state.world.province_size();
5 uint32_t texture_size = province_size + 256 - province_size % 256;
6
7 std::vector<uint32_t> prov_color(texture_size * 2);
8 dcon::province_id selected_province = state.map_state.get_selected_province();
9 dcon::nation_id selected_nation = selected_province
10 ? state.world.province_get_nation_from_province_ownership(selected_province)
11 : state.local_player_nation;
12 state.world.for_each_province([&](dcon::province_id prov_id) {
13 auto i = province::to_map_id(prov_id);
14 auto fat_id = dcon::fatten(state.world, prov_id);
15 if(!selected_nation || fat_id.get_nation_from_province_ownership() == selected_nation) {
16 auto admin_efficiency = province::state_admin_efficiency(state, fat_id.get_state_membership());
17 uint32_t color = ogl::color_gradient(admin_efficiency,
18 sys::pack_color(46, 247, 15), // red
19 sys::pack_color(247, 15, 15) // green
20 );
21 prov_color[i] = color;
22 prov_color[i + texture_size] = color;
23 } else {
24 prov_color[i] = 0;
25 prov_color[i + texture_size] = 0;
26 }
27 });
28 return prov_color;
29}
std::vector< uint32_t > admin_map_from(sys::state &state)
Definition: admin.hpp:3
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
uint32_t color_gradient(float percent, uint32_t top_color, uint32_t bot_color)
Definition: color.hpp:42
float state_admin_efficiency(sys::state &state, dcon::state_instance_id id)
Definition: province.cpp:503
constexpr uint16_t to_map_id(dcon::province_id id)
Definition: province.hpp:10
uint32_t pack_color(float r, float g, float b)
uint uint32_t