Project Alice
Loading...
Searching...
No Matches
rgo_output.hpp
Go to the documentation of this file.
1#pragma once
2std::vector<uint32_t> rgo_output_map_from(sys::state& state) {
3 uint32_t province_size = state.world.province_size();
4 uint32_t texture_size = province_size + 256 - province_size % 256;
5
6 std::vector<uint32_t> prov_color(texture_size * 2);
7
8 auto selected_province = state.map_state.get_selected_province();
9 if(selected_province) {
10 auto searched_rgo = state.world.province_get_rgo(selected_province);
11 float max_rgo_size = 0.f;
12 state.world.for_each_province([&](dcon::province_id prov_id) {
13 auto n = state.world.province_get_nation_from_province_ownership(prov_id);
14
15 max_rgo_size = std::max(max_rgo_size, state.world.province_get_rgo_actual_production_per_good(prov_id, searched_rgo));
16 });
17 state.world.for_each_province([&](dcon::province_id prov_id) {
18 auto i = province::to_map_id(prov_id);
19 auto n = state.world.province_get_nation_from_province_ownership(prov_id);
20
21 uint32_t color = ogl::color_gradient(state.world.province_get_rgo_actual_production_per_good(prov_id, searched_rgo) / max_rgo_size,
22 sys::pack_color(46, 247, 15), // red
23 sys::pack_color(247, 15, 15) // green
24 );
25 prov_color[i] = color;
26 prov_color[i + texture_size] = color;
27 });
28 } else {
29 state.world.for_each_province([&](dcon::province_id prov_id) {
30 auto const color = state.world.commodity_get_color(state.world.province_get_rgo(prov_id));
31 auto i = province::to_map_id(prov_id);
32 prov_color[i] = color;
33 prov_color[i + texture_size] = color;
34 });
35 }
36 return prov_color;
37}
uint32_t color_gradient(float percent, uint32_t top_color, uint32_t bot_color)
Definition: color.hpp:42
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
std::vector< uint32_t > rgo_output_map_from(sys::state &state)
Definition: rgo_output.hpp:2