From 8fa081b6b4ad26851f3ab8f485ba76f3e4338762 Mon Sep 17 00:00:00 2001 From: Ibrahim Zidan Date: Wed, 17 Apr 2019 07:29:18 +0200 Subject: Implement Refinery UI Signed-off-by: Ibrahim Zidan --- src/map/refine.p.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 4 deletions(-) (limited to 'src/map/refine.p.h') diff --git a/src/map/refine.p.h b/src/map/refine.p.h index d47944315..e1a24f6b7 100644 --- a/src/map/refine.p.h +++ b/src/map/refine.p.h @@ -28,11 +28,11 @@ #include "refine.h" #include "common/conf.h" -/* Structures */ struct s_refine_info { - int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE]; // success chance - int bonus[MAX_REFINE]; // cumulative fixed bonus damage - int randombonus_max[MAX_REFINE]; // cumulative maximum random bonus damage + int chance[REFINE_CHANCE_TYPE_MAX][MAX_REFINE]; //< success chance + int bonus[MAX_REFINE]; //< cumulative fixed bonus damage + int randombonus_max[MAX_REFINE]; //< cumulative maximum random bonus damage + struct s_refine_requirement refine_requirements[MAX_REFINE]; //< The requirements used for refinery UI }; struct refine_interface_dbs { @@ -66,6 +66,64 @@ struct refine_interface_private { * @return The number of found entries. **/ int (*readdb_refine_libconfig) (const char *filename); + + /** + * Converts refine database failure behvaior string to enum refine_ui_failure_behavior + * @param str the string to convert + * @param result pointer to where the converted value will be held + * @return true on success, false otherwise. + **/ + bool (*failure_behavior_string2enum) (const char *str, enum refine_ui_failure_behavior *result); + + /** + * Processes a refine_db.conf RefineryUISettings items entry. + * + * @param elem Libconfig setting entry. It is expected to be valid and it + * won't be freed (it is care of the caller to do so if + * necessary) + * @param req a pointer to requirements struct to fill with the item data + * @param name the current element name + * @param source Source of the entry (file name), to be displayed in case of + * validation errors. + * @return true on success, false otherwise. + **/ + bool (*readdb_refinery_ui_settings_items) (const struct config_setting_t *elem, struct s_refine_requirement *req, const char *name, const char *source); + + /** + * Processes a refine_db.conf RefineryUISettings entry. + * + * @param elem Libconfig setting entry. It is expected to be valid and it + * won't be freed (it is care of the caller to do so if + * necessary) + * @param type the type index in refine database to fill the data + * @param name the current element name + * @param source Source of the entry (file name), to be displayed in case of + * validation errors. + * @return true on success, false otherwise. + **/ + bool (*readdb_refinery_ui_settings_sub) (const struct config_setting_t *elem, int type, const char *name, const char *source); + + /** + * Reads a refine_db.conf RefineryUISettings entry and sends it to be processed. + * + * @param r Libconfig setting entry. It is expected to be valid and it + * won't be freed (it is care of the caller to do so if + * necessary) + * @param type the type index in refine database to fill the data + * @param name the current element name + * @param source Source of the entry (file name), to be displayed in case of + * validation errors. + * @return true on success, false otherwise. + **/ + int (*readdb_refinery_ui_settings) (const struct config_setting_t *r, int type, const char *name, const char *source); + + /** + * Checks if a given item in player's inventory is refineable. + * @param sd player session data. + * @param item_index the item index in player's inventory. + * @return true if item is refineable, false otherwise. + **/ + bool (*is_refinable) (struct map_session_data *sd, int item_index); }; #endif -- cgit v1.2.3-70-g09d2