Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ list(APPEND ALICE_CORE_SOURCES_LIST
"${PROJECT_SOURCE_DIR}/src/map/map_data_loading.cpp"
"${PROJECT_SOURCE_DIR}/src/map/map_borders.cpp"
"${PROJECT_SOURCE_DIR}/src/map/map.cpp"
"${PROJECT_SOURCE_DIR}/src/map/flow_map.cpp"
"${PROJECT_SOURCE_DIR}/src/graphics/xac.cpp"
"${PROJECT_SOURCE_DIR}/src/graphics/stateless_render.cpp"
"${PROJECT_SOURCE_DIR}/src/lunasvg/graphics.cpp"
Expand Down
29 changes: 18 additions & 11 deletions assets/alice.gui
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,25 @@ guiTypes = {


iconType = {
name = "gfx_storage_unit_types"
spriteType = "GFX_unit_strip"
position = { -150 -150 }
Orientation = "UPPER_LEFT"
}
name = "gfx_storage_unit_types"
spriteType = "GFX_unit_strip"
position = { -150 -150 }
Orientation = "UPPER_LEFT"
}

iconType = {
name = "gfx_storage_commodity"
spriteType = "GFX_resources_big"
position = { -150 -150 }
Orientation = "UPPER_LEFT"
}
iconType = {
name = "gfx_storage_commodity"
spriteType = "GFX_resources_big"
position = { -150 -150 }
Orientation = "UPPER_LEFT"
}

iconType = {
name = "gfx_storage_pop_types"
spriteType = "GFX_pops_small"
position = { -150 -150 }
Orientation = "UPPER_LEFT"
}

instantTextBoxType = {
name = "alice_investment_text"
Expand Down
3 changes: 3 additions & 0 deletions assets/localisation/en-US/settings.csv
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ graphics_details_1;Classic
graphics_details_2;Modern
graphics_details_3;Gores
disband_confirmation_label;Unit disband confirmation
trade_particles_section_label;Trade particles settings
reset_trade_particles;Reset trade particles
trade_particles_count;Particles count
Binary file modified assets/main_menu.aui
Binary file not shown.
47 changes: 36 additions & 11 deletions src/gamestate/system_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,7 @@ void state::save_user_settings() const {
US_SAVE(locale);
US_SAVE(graphics_mode);
US_SAVE(unit_disband_confirmation);
US_SAVE(trade_particles_count);
#undef US_SAVE

simple_fs::write_file(settings_location, NATIVE("user_settings.dat"), &buffer[0], uint32_t(ptr - buffer));
Expand Down Expand Up @@ -1686,6 +1687,7 @@ void state::load_user_settings() {
US_LOAD(locale);
US_LOAD(graphics_mode);
US_LOAD(unit_disband_confirmation);
US_LOAD(trade_particles_count);
#undef US_LOAD
} while(false);

Expand Down Expand Up @@ -3811,10 +3813,15 @@ void state::load_scenario_data(parsers::error_handler& err, sys::year_month_day
// return;
//}
bool sea_route = false;
if(p2.index() >= province_definitions.first_sea_province.index() || p1.index() >= province_definitions.first_sea_province.index()) {
if(
p2.index() >= province_definitions.first_sea_province.index()
|| p1.index() >= province_definitions.first_sea_province.index()
) {
sea_route = true;
}

auto ignore_sea_land_province = world.province_adjacency_get_canal_or_blockade_province(adj);

auto mid_point_1 = world.province_get_mid_point(p1);
auto mid_point_2 = world.province_get_mid_point(p2);

Expand Down Expand Up @@ -3856,6 +3863,7 @@ void state::load_scenario_data(parsers::error_handler& err, sys::year_month_day

auto handle_next = [&](int x, int y, int next_x, int next_y, float base_distance, int8_t direction, int8_t dx, int8_t dy, uint8_t speed, float prev_dist) {
auto next_idx = next_x + next_y * map_state.map_data.size_x;
auto local_idx = x + y * map_state.map_data.size_x;
if(!visited[next_idx]) {
for(int i = 1; i <= (int)speed; i++) {
auto nx = x + dx * i;
Expand All @@ -3869,9 +3877,18 @@ void state::load_scenario_data(parsers::error_handler& err, sys::year_month_day
auto modifier = context.modifier_by_terrain_index[local_terrain];
auto& modifier_data = world.modifier_get_province_values(modifier);
auto move_cost_mod = terrain_cost[local_terrain];
dcon::province_id local_province = province::from_map_id(map_state.map_data.province_id_map[local_idx]);
dcon::province_id next_province = province::from_map_id(map_state.map_data.province_id_map[next_idx]);
bool apply_malus = true;
if(ignore_sea_land_province) {
apply_malus = (ignore_sea_land_province != local_province) && (ignore_sea_land_province != next_province);
}
if(sea_route) {
move_cost_mod = 100.f;
if (local_terrain == 255) move_cost_mod = 1.f;
if(local_terrain != 255 && apply_malus) {
move_cost_mod = 100.f;
} else {
move_cost_mod = 1.f;
}
}
auto next_distance = prev_dist + base_distance * std::max(0.05f, (move_cost_mod * 20.f));
auto scaled_x = (float)next_x / (float)map_state.map_data.size_x;
Expand Down Expand Up @@ -3975,6 +3992,7 @@ void state::load_scenario_data(parsers::error_handler& err, sys::year_month_day
int step = 0;

glm::vec2 current_pos{ end_x, end_y };
glm::vec2 temp_prev = current_pos;


while(end_idx != start_idx && (int)(end_idx) >= 0) {
Expand Down Expand Up @@ -4019,21 +4037,28 @@ void state::load_scenario_data(parsers::error_handler& err, sys::year_month_day
map_state.map_data.railroad_vertices.emplace_back(map::textured_line_vertex{ norm_next, +start_normal, 0.0f, distance });
map_state.map_data.railroad_vertices.emplace_back(map::textured_line_vertex{ norm_next, -start_normal, 1.0f, distance });

assert(norm_pos != norm_next);

end_idx = next_idx;
temp_prev = current_pos;
current_pos = next_pos;
}

glm::vec2 next_pos = put_in_local(mid_point_1, current_pos, float(map_state.map_data.size_x));
distance += glm::length(next_pos - current_pos) / float(map_state.map_data.size_y);
glm::vec2 prev_perpendicular = glm::normalize(mid_point_1 - current_pos);
auto start_normal = glm::vec2(-prev_perpendicular.y, prev_perpendicular.x);
auto norm_pos = current_pos / glm::vec2(map_state.map_data.size_x, map_state.map_data.size_y);
auto norm_next = next_pos / glm::vec2(map_state.map_data.size_x, map_state.map_data.size_y);
map_state.map_data.railroad_vertices.emplace_back(map::textured_line_vertex{ norm_pos, +start_normal, 0.0f, 0.f });//C
map_state.map_data.railroad_vertices.emplace_back(map::textured_line_vertex{ norm_pos, -start_normal, 1.0f, 0.f });//D
map_state.map_data.railroad_vertices.emplace_back(map::textured_line_vertex{ norm_next, +start_normal, 0.0f, distance });
map_state.map_data.railroad_vertices.emplace_back(map::textured_line_vertex{ norm_next, -start_normal, 1.0f, distance });

if(mid_point_1 != current_pos) {
glm::vec2 prev_perpendicular = glm::normalize(mid_point_1 - current_pos);
auto start_normal = glm::vec2(-prev_perpendicular.y, prev_perpendicular.x);
auto norm_pos = current_pos / glm::vec2(map_state.map_data.size_x, map_state.map_data.size_y);
auto norm_next = next_pos / glm::vec2(map_state.map_data.size_x, map_state.map_data.size_y);

map_state.map_data.railroad_vertices.emplace_back(map::textured_line_vertex{ norm_pos, +start_normal, 0.0f, 0.f });//C
map_state.map_data.railroad_vertices.emplace_back(map::textured_line_vertex{ norm_pos, -start_normal, 1.0f, 0.f });//D
map_state.map_data.railroad_vertices.emplace_back(map::textured_line_vertex{ norm_next, +start_normal, 0.0f, distance });
map_state.map_data.railroad_vertices.emplace_back(map::textured_line_vertex{ norm_next, -start_normal, 1.0f, distance });
}

map_state.map_data.railroad_counts.push_back(GLsizei(map_state.map_data.railroad_vertices.size() - map_state.map_data.railroad_starts.back()));

clear_visited();
Expand Down
5 changes: 4 additions & 1 deletion src/gamestate/system_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "immediate_mode_state.hpp"
#include "network_containers.hpp"
#include "container_types_ui.hpp"
#include "flow_map.hpp"

namespace game_scene {
scene_properties nation_picker();
Expand Down Expand Up @@ -401,6 +402,7 @@ struct user_settings_s {
sys::graphics_mode graphics_mode = sys::graphics_mode::classic;
uint32_t UNUSED_UINT32_T = 0;
char locale[16] = "en-US";
uint8_t trade_particles_count = 2;
};


Expand Down Expand Up @@ -930,7 +932,8 @@ struct alignas(64) state {
std::atomic<bool> ui_pause = false; // force pause by an important message being open
std::atomic<bool> railroad_built = true; // game state -> map
std::atomic<bool> sprawl_update_requested = true;
std::atomic<bool> update_trade_flow = true;

flow_map::flow_map_data flow_map { };

std::atomic<int64_t> tick_start_counter;
std::atomic<int64_t> tick_end_counter;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/economy_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ void render(sys::state& state) {
state.selected_trade_good = cid;
}
update(state);
state.update_trade_flow.store(true, std::memory_order::release);
state.flow_map.request_update(flow_map::data_source::commodity);
}
state.iui_state.localized_string_r(
state, (int32_t)static_elements::commodities + cid.index(),
Expand Down
Loading
Loading