aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-08-11 00:40:07 +0200
committer hop311 <hop3114@gmail.com>2024-08-14 00:07:46 +0200
commit7e05aaccf0e13299702ddeed17661831c3ddc692 (patch)
treeb85022a240a4a24c0ee0fd44cd59ff6bc112c18f /src
parent9f9c5844bfedc5e366a35cdba386027fb9f3a14a (diff)
Assorted minor fixes (clang-format.sh shebang, parse national foci scripts, factor song chance, update openvic-dataloader)assorted-fixes
Diffstat (limited to 'src')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp5
-rw-r--r--src/openvic-simulation/interface/GUI.cpp6
-rw-r--r--src/openvic-simulation/interface/GUI.hpp3
-rw-r--r--src/openvic-simulation/military/UnitInstanceGroup.cpp1
-rw-r--r--src/openvic-simulation/military/UnitType.cpp2
-rw-r--r--src/openvic-simulation/misc/SongChance.cpp18
-rw-r--r--src/openvic-simulation/misc/SongChance.hpp12
-rw-r--r--src/openvic-simulation/misc/SoundEffect.cpp4
-rw-r--r--src/openvic-simulation/misc/SoundEffect.hpp18
9 files changed, 36 insertions, 33 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index 63571c7..1be040f 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -831,7 +831,7 @@ bool Dataloader::_load_song_chances(DefinitionManager& definition_manager) {
bool ret = true;
SongChanceManager& song_chance_manager = definition_manager.get_song_chance_manager();
- if(path.empty()) {
+ if (path.empty()) {
Logger::info("No Songs.txt file to load");
song_chance_manager.lock_song_chances();
return true;
@@ -1096,7 +1096,7 @@ bool Dataloader::load_defines(DefinitionManager& definition_manager) {
Logger::error("Failed to load diplomatic actions!");
ret = false;
}
- if(!definition_manager.get_script_manager().get_condition_manager().setup_conditions(definition_manager)) {
+ if (!definition_manager.get_script_manager().get_condition_manager().setup_conditions(definition_manager)) {
Logger::error("Failed to set up conditions!");
ret = false;
}
@@ -1131,6 +1131,7 @@ bool Dataloader::parse_scripts(DefinitionManager& definition_manager) const {
PARSE_SCRIPTS("decision", definition_manager.get_decision_manager());
PARSE_SCRIPTS("event", definition_manager.get_event_manager());
PARSE_SCRIPTS("song chance", definition_manager.get_song_chance_manager());
+ PARSE_SCRIPTS("national focus", definition_manager.get_politics_manager().get_national_focus_manager());
return ret;
}
diff --git a/src/openvic-simulation/interface/GUI.cpp b/src/openvic-simulation/interface/GUI.cpp
index 87e3624..4f42b86 100644
--- a/src/openvic-simulation/interface/GUI.cpp
+++ b/src/openvic-simulation/interface/GUI.cpp
@@ -184,12 +184,10 @@ bool Text::_fill_key_map(NodeTools::case_insensitive_key_map_t& key_map, UIManag
"maxWidth", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(max_size.x)),
"maxHeight", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(max_size.y)),
"borderSize", ZERO_OR_ONE, expect_fvec2(assign_variable_callback(border_size)),
+ "textureFile", ZERO_OR_ONE, expect_string(assign_variable_callback_string(texture_file), true),
"fixedsize", ZERO_OR_ONE, success_callback,
- "allwaystransparent", ZERO_OR_ONE, success_callback,
-
- // Add warning about redundant key?
- "textureFile", ZERO_OR_ONE, success_callback
+ "allwaystransparent", ZERO_OR_ONE, success_callback
);
return ret;
}
diff --git a/src/openvic-simulation/interface/GUI.hpp b/src/openvic-simulation/interface/GUI.hpp
index 4e1b062..a86d432 100644
--- a/src/openvic-simulation/interface/GUI.hpp
+++ b/src/openvic-simulation/interface/GUI.hpp
@@ -203,8 +203,9 @@ namespace OpenVic::GUI {
GFX::Font const* PROPERTY(font);
fvec2_t PROPERTY(max_size); /* Defines keys: maxWidth, maxHeight */
fvec2_t PROPERTY(border_size);
+ std::string PROPERTY(texture_file);
- // TODO - fixedsize, textureFile
+ // TODO - fixedsize
protected:
Text();
diff --git a/src/openvic-simulation/military/UnitInstanceGroup.cpp b/src/openvic-simulation/military/UnitInstanceGroup.cpp
index 07736f3..65ecf5b 100644
--- a/src/openvic-simulation/military/UnitInstanceGroup.cpp
+++ b/src/openvic-simulation/military/UnitInstanceGroup.cpp
@@ -155,7 +155,6 @@ UnitInstanceGroupBranched<UnitType::branch_t::NAVAL>::UnitInstanceGroupBranched(
std::vector<ShipInstance*>&& new_units
) : UnitInstanceGroup { new_name, std::move(new_units) } {}
-
fixed_point_t UnitInstanceGroupBranched<UnitType::branch_t::NAVAL>::get_total_consumed_supply() const {
fixed_point_t total_consumed_supply = 0;
diff --git a/src/openvic-simulation/military/UnitType.cpp b/src/openvic-simulation/military/UnitType.cpp
index fb65bf8..11f7221 100644
--- a/src/openvic-simulation/military/UnitType.cpp
+++ b/src/openvic-simulation/military/UnitType.cpp
@@ -151,7 +151,7 @@ bool UnitTypeManager::load_unit_type_file(
) {
using namespace std::string_view_literals;
auto type_symbol = parser.find_intern("type"sv);
- if(!type_symbol) {
+ if (!type_symbol) {
Logger::error("type could not be interned.");
}
diff --git a/src/openvic-simulation/misc/SongChance.cpp b/src/openvic-simulation/misc/SongChance.cpp
index 4a99362..94fb571 100644
--- a/src/openvic-simulation/misc/SongChance.cpp
+++ b/src/openvic-simulation/misc/SongChance.cpp
@@ -3,18 +3,16 @@
using namespace OpenVic;
using namespace OpenVic::NodeTools;
-SongChance::SongChance(size_t new_index, std::string_view new_filename, ConditionalWeight&& new_chance):
-HasIdentifier { std::to_string(new_index) },
-file_name { new_filename },
-chance { std::move(new_chance) }
-{}
+SongChance::SongChance(
+ size_t new_index, std::string_view new_filename, ConditionalWeight&& new_chance
+) : HasIdentifier { std::to_string(new_index) }, file_name { new_filename }, chance { std::move(new_chance) } {}
bool SongChance::parse_scripts(DefinitionManager const& definition_manager) {
return chance.parse_scripts(definition_manager);
}
bool SongChanceManager::load_songs_file(ast::NodeCPtr root) {
- bool ret = true;
+ bool ret = true;
ret &= expect_dictionary_reserve_length(
song_chances,
@@ -28,15 +26,15 @@ bool SongChanceManager::load_songs_file(ast::NodeCPtr root) {
bool ret = expect_dictionary_keys(
"name", ONE_EXACTLY, expect_string(assign_variable_callback(name)),
- "chance", ONE_EXACTLY, chance.expect_conditional_weight(ConditionalWeight::BASE)
+ "chance", ONE_EXACTLY, chance.expect_conditional_weight(ConditionalWeight::FACTOR)
)(value);
- ret &= song_chances.add_item({song_chances.size(), name, std::move(chance) });
+ ret &= song_chances.add_item({ song_chances.size(), name, std::move(chance) });
return ret;
}
)(root);
- if(song_chances.size() == 0) {
+ if (song_chances.size() == 0) {
Logger::error("No songs found in Songs.txt");
return false;
}
@@ -50,4 +48,4 @@ bool SongChanceManager::parse_scripts(DefinitionManager const& definition_manage
ret &= songChance.parse_scripts(definition_manager);
}
return ret;
-} \ No newline at end of file
+}
diff --git a/src/openvic-simulation/misc/SongChance.hpp b/src/openvic-simulation/misc/SongChance.hpp
index f92af7a..dc7d929 100644
--- a/src/openvic-simulation/misc/SongChance.hpp
+++ b/src/openvic-simulation/misc/SongChance.hpp
@@ -1,19 +1,23 @@
#pragma once
-#include <openvic-simulation/types/IdentifierRegistry.hpp>
-#include <openvic-simulation/scripts/ConditionalWeight.hpp>
+#include "openvic-simulation/types/IdentifierRegistry.hpp"
+#include "openvic-simulation/scripts/ConditionalWeight.hpp"
namespace OpenVic {
/*For music/Songs.txt if it exists*/
struct SongChanceManager;
+
struct SongChance : HasIdentifier {
- private:
friend struct SongChanceManager;
+
+ private:
std::string PROPERTY(file_name);
ConditionalWeight PROPERTY(chance);
+
SongChance(size_t new_index, std::string_view new_filename, ConditionalWeight&& new_chance);
+
bool parse_scripts(DefinitionManager const& definition_manager);
-
+
public:
SongChance(SongChance&&) = default;
};
diff --git a/src/openvic-simulation/misc/SoundEffect.cpp b/src/openvic-simulation/misc/SoundEffect.cpp
index df3196b..b32d353 100644
--- a/src/openvic-simulation/misc/SoundEffect.cpp
+++ b/src/openvic-simulation/misc/SoundEffect.cpp
@@ -20,7 +20,7 @@ bool SoundEffectManager::_load_sound_define(std::string_view sfx_identifier, ast
Logger::error("Invalid sound identifier - empty!");
return false;
}
- if(file.empty()) {
+ if (file.empty()) {
Logger::error("Invalid sound file name - empty!");
return false;
}
@@ -35,4 +35,4 @@ bool SoundEffectManager::load_sound_defines_file(ast::NodeCPtr root) {
return _load_sound_define(key,value);
}
)(root);
-} \ No newline at end of file
+}
diff --git a/src/openvic-simulation/misc/SoundEffect.hpp b/src/openvic-simulation/misc/SoundEffect.hpp
index 7f18dce..35d05dc 100644
--- a/src/openvic-simulation/misc/SoundEffect.hpp
+++ b/src/openvic-simulation/misc/SoundEffect.hpp
@@ -1,29 +1,31 @@
#pragma once
-#include <openvic-simulation/types/fixed_point/FixedPoint.hpp>
-#include <openvic-simulation/types/IdentifierRegistry.hpp>
+#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
+#include "openvic-simulation/types/IdentifierRegistry.hpp"
namespace OpenVic {
/*For interface/Sound.sfx */
struct SoundEffectManager;
+
struct SoundEffect : HasIdentifier {
- private:
friend struct SoundEffectManager;
+
+ private:
std::string PROPERTY(file);
fixed_point_t PROPERTY(volume);
+
SoundEffect(std::string_view new_identifier, std::string_view new_file, fixed_point_t new_volume);
-
+
public:
SoundEffect(SoundEffect&&) = default;
};
-
+
struct SoundEffectManager {
-
private:
- IdentifierRegistry<SoundEffect> IDENTIFIER_REGISTRY(sound_effect);
+ IdentifierRegistry<SoundEffect> IDENTIFIER_REGISTRY(sound_effect);
bool _load_sound_define(std::string_view sfx_identifier, ast::NodeCPtr root);
public:
bool load_sound_defines_file(ast::NodeCPtr root);
};
-} \ No newline at end of file
+}