Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hop311 committed Feb 13, 2025
1 parent 1fc952c commit 7b82879
Show file tree
Hide file tree
Showing 31 changed files with 899 additions and 405 deletions.
2 changes: 1 addition & 1 deletion extension/deps/openvic-simulation
Submodule openvic-simulation updated 44 files
+19 −1 src/headless/main.cpp
+2 −6 src/openvic-simulation/GameManager.cpp
+1 −3 src/openvic-simulation/GameManager.hpp
+64 −20 src/openvic-simulation/InstanceManager.cpp
+11 −4 src/openvic-simulation/InstanceManager.hpp
+139 −53 src/openvic-simulation/country/CountryInstance.cpp
+32 −20 src/openvic-simulation/country/CountryInstance.hpp
+4 −2 src/openvic-simulation/dataloader/NodeTools.hpp
+2 −1 src/openvic-simulation/economy/GoodDefinition.cpp
+3 −3 src/openvic-simulation/economy/GoodInstance.cpp
+9 −1 src/openvic-simulation/economy/GoodInstance.hpp
+123 −101 src/openvic-simulation/economy/production/ArtisanalProducer.cpp
+10 −4 src/openvic-simulation/economy/production/ArtisanalProducer.hpp
+6 −7 src/openvic-simulation/economy/production/ArtisanalProducerFactoryPattern.cpp
+2 −7 src/openvic-simulation/economy/production/ArtisanalProducerFactoryPattern.hpp
+11 −8 src/openvic-simulation/economy/production/ResourceGatheringOperation.cpp
+0 −3 src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp
+8 −20 src/openvic-simulation/map/MapInstance.cpp
+2 −4 src/openvic-simulation/map/MapInstance.hpp
+2 −4 src/openvic-simulation/map/Mapmode.cpp
+54 −20 src/openvic-simulation/map/ProvinceInstance.cpp
+15 −10 src/openvic-simulation/map/ProvinceInstance.hpp
+4 −0 src/openvic-simulation/map/Region.cpp
+1 −0 src/openvic-simulation/map/Region.hpp
+3 −0 src/openvic-simulation/military/Leader.cpp
+18 −19 src/openvic-simulation/military/Leader.hpp
+37 −4 src/openvic-simulation/military/LeaderTrait.cpp
+2 −0 src/openvic-simulation/military/LeaderTrait.hpp
+18 −13 src/openvic-simulation/military/UnitInstance.cpp
+36 −12 src/openvic-simulation/military/UnitInstance.hpp
+245 −129 src/openvic-simulation/military/UnitInstanceGroup.cpp
+79 −28 src/openvic-simulation/military/UnitInstanceGroup.hpp
+639 −0 src/openvic-simulation/misc/GameAction.cpp
+130 −0 src/openvic-simulation/misc/GameAction.hpp
+2 −7 src/openvic-simulation/misc/SimulationClock.cpp
+3 −7 src/openvic-simulation/misc/SimulationClock.hpp
+1 −1 src/openvic-simulation/modifier/ModifierManager.cpp
+211 −47 src/openvic-simulation/pop/Pop.cpp
+48 −14 src/openvic-simulation/pop/Pop.hpp
+53 −0 src/openvic-simulation/pop/PopValuesFromProvince.cpp
+35 −0 src/openvic-simulation/pop/PopValuesFromProvince.hpp
+13 −0 src/openvic-simulation/types/IdentifierRegistry.hpp
+67 −0 src/openvic-simulation/types/fixed_point/FixedPoint.hpp
+0 −2 src/openvic-simulation/utility/BMP.hpp
6 changes: 6 additions & 0 deletions extension/doc_classes/GUIListBox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
<description>
</description>
</method>
<method name="sort_children">
<return type="int" enum="Error" />
<param index="0" name="callable" type="Callable" />
<description>
</description>
</method>
<method name="unset_fixed">
<return type="int" enum="Error" />
<param index="0" name="signal" type="bool" default="true" />
Expand Down
43 changes: 0 additions & 43 deletions extension/doc_classes/GameSingleton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,12 @@
Return a [Texture2DArray] containing all the textures that the province shape image was split into.
</description>
</method>
<method name="get_selected_province_index" qualifiers="const">
<return type="int" />
<description>
Returns the [int] index of the currently selected province, or [code]0[/code] if there is no selected province.
</description>
</method>
<method name="get_terrain_texture" qualifiers="const">
<return type="Texture2DArray" />
<description>
Return a [Texture2DArray] containing all terrain textures, both the solid blue generated water texture and the loaded land terrain textures.
</description>
</method>
<method name="get_viewed_country_capital_position" qualifiers="const">
<return type="Vector2" />
<description>
Returns the viewed country's capital position as a normalized [Vector2], or [code](0.0, 0.0)[/code] if no country is being viewed.
</description>
</method>
<method name="is_parchment_mapmode_allowed" qualifiers="const">
<return type="bool" />
<description>
Expand Down Expand Up @@ -177,20 +165,6 @@
Sets the active mapmode to that identified by [param index]. Returns [code]FAILED[/code] if the mapmode index is invalid, otherwise returns [code]OK[/code].
</description>
</method>
<method name="set_selected_province">
<return type="void" />
<param index="0" name="index" type="int" />
<description>
Sets the currently selected province to that identified by [param index], or unselects the currently selected province if [param index] is [code]0[/code].
</description>
</method>
<method name="set_viewed_country_by_province_index">
<return type="void" />
<param index="0" name="province_index" type="int" />
<description>
Sets the viewed country to that which owns the province identified by [param province_index], or unsets the viewed country if the province has no owner/is uncolonised. Returns [code]FAILED[/code] if the [param province_index] is invalid, otherwise returns [code]OK[/code].
</description>
</method>
<method name="setup_game">
<return type="int" enum="Error" />
<param index="0" name="bookmark_index" type="int" />
Expand All @@ -210,12 +184,6 @@
Sets up the simulation's clock and timestamps so that it can be unpaused, marking the move from the initialized but static game state used for the lobby to the dynamic game session that is ready to tick, update and simulate.
</description>
</method>
<method name="unset_selected_province">
<return type="void" />
<description>
Unselects the currently selected province, should there be one.
</description>
</method>
<method name="update_clock">
<return type="int" enum="Error" />
<description>
Expand All @@ -224,11 +192,6 @@
</method>
</methods>
<signals>
<signal name="clock_state_changed">
<description>
Signal emitted when the simulation's clock changes state (paused vs unpaused, clock speed, etc.).
</description>
</signal>
<signal name="gamestate_updated">
<description>
Signal emitted when the simulation's gamestate is updated (this happens after any event that changes the gamestate, e.g. a day tick, a player taking a decision, etc).
Expand All @@ -240,11 +203,5 @@
Signal emitted when the active mapmode changes, with the new mapmode's [param index] provided as a parameter.
</description>
</signal>
<signal name="province_selected">
<param index="0" name="index" type="int" />
<description>
Signal emitted when the currently selected province changes, with the new province's [param index] provided as a parameter (or [code]0[/code] if there is no longer a selected province/the change was de-selecting a province).
</description>
</signal>
</signals>
</class>
33 changes: 6 additions & 27 deletions extension/doc_classes/MenuSingleton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,19 @@
<tutorials>
</tutorials>
<methods>
<method name="can_decrease_speed" qualifiers="const">
<return type="bool" />
<method name="calculate_trade_menu_stockpile_cutoff_amount" qualifiers="static">
<return type="float" />
<param index="0" name="slider" type="GUIScrollbar" />
<description>
</description>
</method>
<method name="can_increase_speed" qualifiers="const">
<method name="can_decrease_speed" qualifiers="const">
<return type="bool" />
<description>
</description>
</method>
<method name="decrease_speed">
<return type="void" />
<description>
</description>
</method>
<method name="expand_selected_province_building">
<return type="int" enum="Error" />
<param index="0" name="building_index" type="int" />
<method name="can_increase_speed" qualifiers="const">
<return type="bool" />
<description>
</description>
</method>
Expand Down Expand Up @@ -191,11 +186,6 @@
<description>
</description>
</method>
<method name="increase_speed">
<return type="void" />
<description>
</description>
</method>
<method name="is_paused" qualifiers="const">
<return type="bool" />
<description>
Expand Down Expand Up @@ -248,12 +238,6 @@
<description>
</description>
</method>
<method name="set_paused">
<return type="void" />
<param index="0" name="paused" type="bool" />
<description>
</description>
</method>
<method name="show_control_tooltip">
<return type="void" />
<param index="0" name="text" type="String" />
Expand All @@ -270,11 +254,6 @@
<description>
</description>
</method>
<method name="toggle_paused">
<return type="void" />
<description>
</description>
</method>
<method name="update_search_results">
<return type="void" />
<param index="0" name="text" type="String" />
Expand Down
104 changes: 104 additions & 0 deletions extension/doc_classes/PlayerSingleton.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PlayerSingleton" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="create_leader" qualifiers="const">
<return type="void" />
<param index="0" name="is_general" type="bool" />
<description>
</description>
</method>
<method name="decrease_speed" qualifiers="const">
<return type="void" />
<description>
</description>
</method>
<method name="expand_selected_province_building" qualifiers="const">
<return type="void" />
<param index="0" name="building_index" type="int" />
<description>
</description>
</method>
<method name="get_player_country_capital_position" qualifiers="const">
<return type="Vector2" />
<description>
</description>
</method>
<method name="get_selected_province_index" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="increase_speed" qualifiers="const">
<return type="void" />
<description>
</description>
</method>
<method name="set_auto_assign_leaders" qualifiers="const">
<return type="void" />
<param index="0" name="value" type="bool" />
<description>
</description>
</method>
<method name="set_auto_create_leaders" qualifiers="const">
<return type="void" />
<param index="0" name="value" type="bool" />
<description>
</description>
</method>
<method name="set_can_use_leader" qualifiers="const">
<return type="void" />
<param index="0" name="leader_id" type="int" />
<param index="1" name="can_use" type="bool" />
<description>
</description>
</method>
<method name="set_good_automated" qualifiers="const">
<return type="void" />
<param index="0" name="good_index" type="int" />
<param index="1" name="is_automated" type="bool" />
<description>
</description>
</method>
<method name="set_mobilise" qualifiers="const">
<return type="void" />
<param index="0" name="value" type="bool" />
<description>
</description>
</method>
<method name="set_player_country_by_province_index">
<return type="void" />
<param index="0" name="province_index" type="int" />
<description>
</description>
</method>
<method name="set_selected_province_by_index">
<return type="void" />
<param index="0" name="province_index" type="int" />
<description>
</description>
</method>
<method name="toggle_paused" qualifiers="const">
<return type="void" />
<description>
</description>
</method>
<method name="unset_selected_province">
<return type="void" />
<description>
</description>
</method>
</methods>
<signals>
<signal name="province_selected">
<param index="0" name="index" type="int" />
<description>
</description>
</signal>
</signals>
</class>
31 changes: 28 additions & 3 deletions extension/src/openvic-extension/classes/GUIListBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ void GUIListBox::_bind_methods() {

OV_BIND_METHOD(GUIListBox::get_gui_listbox_name);
OV_BIND_METHOD(GUIListBox::get_scrollbar);
OV_BIND_METHOD(GUIListBox::sort_children, { "callable" });

ADD_SIGNAL(MethodInfo(_signal_scroll_index_changed(), PropertyInfo(Variant::INT, "value")));
}
Expand Down Expand Up @@ -196,9 +197,12 @@ void GUIListBox::clear_children(int32_t remaining_child_count) {
child->queue_free();
}

if (scrollbar != nullptr) {
scrollbar->set_value(0);
}
// TODO - reduce scroll level if it is now past the remaining children, but don't force it to 0 if the children it's
// viewing haven't been removed!

// if (scrollbar != nullptr) {
// scrollbar->set_value(0);
// }
}

void GUIListBox::set_scroll_index(int32_t new_scroll_index, bool signal) {
Expand Down Expand Up @@ -302,3 +306,24 @@ String GUIListBox::get_gui_listbox_name() const {
GUIScrollbar* GUIListBox::get_scrollbar() const {
return scrollbar;
}

Error GUIListBox::sort_children(Callable const& callable) {
TypedArray<Node> children;
ERR_FAIL_COND_V(children.resize(get_child_count()) != OK, FAILED);

for (int64_t index = children.size() - 1; index >= 0; --index) {
Node* child = get_child(index);

children[index] = child;

remove_child(child);
}

children.sort_custom(callable);

for (int64_t index = 0; index < children.size(); ++index) {
add_child(Object::cast_to<Node>(children[index]));
}

return OK;
}
2 changes: 2 additions & 0 deletions extension/src/openvic-extension/classes/GUIListBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,7 @@ namespace OpenVic {
godot::String get_gui_listbox_name() const;

GUIScrollbar* get_scrollbar() const;

godot::Error sort_children(godot::Callable const& callable);
};
}
4 changes: 2 additions & 2 deletions extension/src/openvic-extension/classes/GUIScrollbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,13 @@ Error GUIScrollbar::set_gui_scrollbar(GUI::Scrollbar const* new_gui_scrollbar) {

_calculate_rects();

fixed_point_t step_size = gui_scrollbar->get_step_size();
step_size = gui_scrollbar->get_step_size();
if (step_size <= 0) {
UtilityFunctions::push_error(
"Invalid step size ", Utilities::fixed_point_to_string_dp(step_size, -1), " for GUIScrollbar ",
gui_scrollbar_name, " - not positive! Defaulting to 1."
);
step_size = 1;
step_size = fixed_point_t::_1();
ret = false;
}
min_value = gui_scrollbar->get_min_value() / step_size;
Expand Down
1 change: 1 addition & 0 deletions extension/src/openvic-extension/classes/GUIScrollbar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace OpenVic {
godot::Orientation PROPERTY(orientation, godot::HORIZONTAL);
real_t PROPERTY(length_override, 0.0);

fixed_point_t PROPERTY(step_size);
int32_t PROPERTY(value, 0);
int32_t PROPERTY(min_value, 0);
int32_t PROPERTY(max_value, 0);
Expand Down
9 changes: 9 additions & 0 deletions extension/src/openvic-extension/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "openvic-extension/singletons/MapItemSingleton.hpp"
#include "openvic-extension/singletons/MenuSingleton.hpp"
#include "openvic-extension/singletons/ModelSingleton.hpp"
#include "openvic-extension/singletons/PlayerSingleton.hpp"
#include "openvic-extension/singletons/SoundSingleton.hpp"

using namespace godot;
Expand All @@ -44,6 +45,7 @@ static MenuSingleton* _menu_singleton = nullptr;
static ModelSingleton* _model_singleton = nullptr;
static AssetManager* _asset_manager_singleton = nullptr;
static SoundSingleton* _sound_singleton = nullptr;
static PlayerSingleton* _player_singleton = nullptr;

void initialize_openvic_types(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
Expand Down Expand Up @@ -86,6 +88,10 @@ void initialize_openvic_types(ModuleInitializationLevel p_level) {
_sound_singleton = memnew(SoundSingleton);
Engine::get_singleton()->register_singleton("SoundSingleton", SoundSingleton::get_singleton());

ClassDB::register_class<PlayerSingleton>();
_player_singleton = memnew(PlayerSingleton);
Engine::get_singleton()->register_singleton("PlayerSingleton", PlayerSingleton::get_singleton());

ClassDB::register_class<MapMesh>();
ClassDB::register_abstract_class<GFXCorneredTileSupportingTexture>();

Expand Down Expand Up @@ -151,6 +157,9 @@ void uninitialize_openvic_types(ModuleInitializationLevel p_level) {

Engine::get_singleton()->unregister_singleton("SoundSingleton");
memdelete(_sound_singleton);

Engine::get_singleton()->unregister_singleton("PlayerSingleton");
memdelete(_player_singleton);
}

extern "C" {
Expand Down
Loading

0 comments on commit 7b82879

Please sign in to comment.