From bb1dc7aaa26a9a8415f9f8576ca4360d5dafd87f Mon Sep 17 00:00:00 2001 From: Pithlit Date: Sat, 13 Jul 2024 17:01:14 +0200 Subject: [PATCH] resource category and description --- src/spaceObjects/shipTemplateBasedObject.cpp | 6 ++++++ src/spaceObjects/shipTemplateBasedObject.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/spaceObjects/shipTemplateBasedObject.cpp b/src/spaceObjects/shipTemplateBasedObject.cpp index 6206673df..cb174224b 100644 --- a/src/spaceObjects/shipTemplateBasedObject.cpp +++ b/src/spaceObjects/shipTemplateBasedObject.cpp @@ -183,6 +183,12 @@ REGISTER_SCRIPT_SUBCLASS_NO_CREATE(ShipTemplateBasedObject, SpaceObject) /// Returns true, if the operation was sucessfull; false otherwise. /// Example: stbo:tryTransferResource("trade item", 1, otherShip) REGISTER_SCRIPT_CLASS_FUNCTION(ShipTemplateBasedObject, tryTransferResource); + /// Sets a category for a resource for this ship + /// Example: stbo:setResourceCategory("empty cargo space", "Cargo") + REGISTER_SCRIPT_CLASS_FUNCTION(ShipTemplateBasedObject, setResourceCategory); + /// Sets a description for a resource for this ship + /// Example: stbo:setResourceCategory("empty cargo space", "Can be filled with cargo") + REGISTER_SCRIPT_CLASS_FUNCTION(ShipTemplateBasedObject, setResourceDescription); /// [DEPRECATED] /// Use ShipTemplateBasedObject:getShieldLevel() with an index value. REGISTER_SCRIPT_CLASS_FUNCTION(ShipTemplateBasedObject, getFrontShield); diff --git a/src/spaceObjects/shipTemplateBasedObject.h b/src/spaceObjects/shipTemplateBasedObject.h index 7a24995a0..3258378fc 100644 --- a/src/spaceObjects/shipTemplateBasedObject.h +++ b/src/spaceObjects/shipTemplateBasedObject.h @@ -40,6 +40,8 @@ class ShipTemplateBasedObject : public SpaceObject, public Updatable EPlayerShipType player_ship_type; ERestockMissileBehaviour restocks_missiles_docked; std::map resources; + std::map resource_categories; + std::map resource_descriptions; ScriptSimpleCallback on_destruction; ScriptSimpleCallback on_taking_damage; @@ -134,6 +136,8 @@ class ShipTemplateBasedObject : public SpaceObject, public Updatable bool tryTransformResource(string resource_name_from, int amount_from, string resource_name_to, int amount_to); void transferResource(string resource_name, int amount, P other); bool tryTransferResource(string resource_name, int amount, P other); + void setResourceCategory(string resource_name, string resource_category) { resource_categories[resource_name] = resource_category; } + void setResourceDescription(string resource_name, string resource_description) { resource_descriptions[resource_name] = resource_description; } }; #endif//SHIP_TEMPLATE_BASED_OBJECT_H