From 42aadd5af9dd2edcf65f56049bbb1f6153920675 Mon Sep 17 00:00:00 2001 From: vicky Date: Mon, 20 Feb 2023 20:51:04 +0100 Subject: [PATCH 1/3] first steps --- python/dontlook.py | 24 ++++++++++++++++++ python/main.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 python/dontlook.py create mode 100644 python/main.py diff --git a/python/dontlook.py b/python/dontlook.py new file mode 100644 index 0000000..1b3fe4f --- /dev/null +++ b/python/dontlook.py @@ -0,0 +1,24 @@ +import dearpygui.dearpygui as dpg + +dpg.create_context() +dpg.configure_app(manual_callback_management=True) +dpg.create_viewport() +dpg.setup_dearpygui() + + +def callback(sender, app_data, user_data): + print("Called on the main thread!") + + +with dpg.window(label="Tutorial"): + dpg.add_button(label="Press me", tag="pog", callback=callback) + + +# main loop +dpg.show_viewport() +while dpg.is_dearpygui_running(): + jobs = dpg.get_callback_queue() # retrieves and clears queue + dpg.run_callbacks(jobs) + dpg.render_dearpygui_frame() + +dpg.destroy_context() diff --git a/python/main.py b/python/main.py new file mode 100644 index 0000000..3e3a7d2 --- /dev/null +++ b/python/main.py @@ -0,0 +1,61 @@ +import dearpygui.dearpygui as dpg +import xiv_craft_solver as xcs + +dpg.create_context() +dpg.configure_app(manual_callback_management=True) +dpg.create_viewport(title='XIV Solver', width=500, height=900) + + +class USER: + craftsmanship = 0 + control = 0 + + +class RECIPE: + durability = 70 + + +def button_callback(sender, app_data, user_data): + print(f"sender is: {sender}") + print(f"app_data is: {app_data}") + print(f"user_data is: {user_data}") + + +def specialist(_, app_data, c_s): + print(c_s) + print(app_data) + if dpg.get_value(specialist_checkbox): + dpg.set_value(stats, [c_s[0]+1, c_s[1]+2, c_s[2]+3, 0]) + else: + dpg.set_value(stats, [c_s[0], c_s[1], c_s[2], 0]) + + +with dpg.window(label="Settings", width=500, height=900): + dpg.add_text("Character") + dpg.add_combo(items=("NEW", "AAAAA", "BBBBB"), label="Your character") + # Make NEW prompt for a name when saving + stats = dpg.add_input_intx(size=3, label="Stats", tag="stats_tooltip") + with dpg.tooltip("stats_tooltip"): + dpg.add_text("Craftsmanship / Control / CP") + + current_stats = dpg.get_value(stats) + specialist_checkbox = dpg.add_checkbox(label="Specialist", callback=specialist, tag="specialist") + dpg.add_button(label="Save!") + dpg.add_text("Recipe") + dpg.add_combo(items=("AAAAA", "BBBBB"), label="Food") + dpg.add_combo(items=("AAAAA", "BBBBB"), label="Pots") + dpg.add_combo(items=("NEW", "AAAAA", "BBBBB"), label="Recipe") + test = dpg.add_input_intx(size=3, label="Stats", tag="recipe_tooltip") + with dpg.tooltip("recipe_tooltip"): + dpg.add_text("Quality / Progress / Durability") + dpg.add_button(label="Solve!") + dpg.add_collapsing_header(label="Result") + +dpg.setup_dearpygui() +dpg.show_viewport() +while dpg.is_dearpygui_running(): + jobs = dpg.get_callback_queue() # retrieves and clears queue + dpg.run_callbacks(jobs) + dpg.render_dearpygui_frame() +dpg.start_dearpygui() +dpg.destroy_context() -- 2.45.1 From 6ffe91174b4dd00404199697bc6b289c987d2a96 Mon Sep 17 00:00:00 2001 From: vicky Date: Tue, 21 Feb 2023 22:26:45 +0100 Subject: [PATCH 2/3] i'm not very focused on atomic commits --- configs/consumables.yaml | 25 +++++++ configs/recipes.yaml | 3 + configs/users.yaml | 8 +++ python/dontlook.py | 26 ++------ python/loader.py | 69 +++++++++++++++++++ python/main.py | 140 +++++++++++++++++++++++++++++++-------- 6 files changed, 225 insertions(+), 46 deletions(-) create mode 100644 configs/consumables.yaml create mode 100644 configs/recipes.yaml create mode 100644 configs/users.yaml create mode 100644 python/loader.py diff --git a/configs/consumables.yaml b/configs/consumables.yaml new file mode 100644 index 0000000..60704b7 --- /dev/null +++ b/configs/consumables.yaml @@ -0,0 +1,25 @@ +Foods: + # Name: [(Bonus craftsmanship%, max value), (bonus control%, max value), (bonus cp%, max value)] + # For example, Calamari Ripieni HQ gives 5% craftsmanship up to a maximum of 120, and 26% CP up to a + # maximum of 82, and is hence noted as: + # Calamari Ripieni HQ: [(5, 120), (0, 0), (26, 82)] + # + # Here is your template to copy/paste and fill in: + # Name: [(0, 0), (0, 0), (0, 0)] + + Calamari Ripieni HQ: [[5, 120], [0, 0], [26, 82]] + Calamari Ripieni: [[4, 96], [0, 0], [21, 66]] + Chili Crab HQ: [[0, 0], [6, 70], [26, 72]] + Chili Crab: [[0, 0], [5, 56], [21, 57]] + +Pots: + # Same as above: + # Name: [(Bonus craftsmanship%, max value), (bonus control%, max value), (bonus cp%, max value)] + # For example, Cunning Craftsman's Draught HQ gives 6% CP up to a maximum of 21, and is hence noted as: + # Cunning Craftsman's Draught HQ: [(0, 0), (0, 0), (6, 21)] + # + # Here is your template to copy/paste and fill in: + # Name: [(0, 0), (0, 0), (0, 0)] + + Cunning Craftsman's Draught HQ: [(0, 0), (0, 0), (6, 21)] + Cunning Craftsman's Draught: [(0, 0), (0, 0), (5, 17)] \ No newline at end of file diff --git a/configs/recipes.yaml b/configs/recipes.yaml new file mode 100644 index 0000000..4c8e277 --- /dev/null +++ b/configs/recipes.yaml @@ -0,0 +1,3 @@ +# Name: [Quality, difficulty, durability] +Grade 7 Tincture of Strength: [12628, 5060, 70] +Grade 5 Strength Alkahest: [6200, 1300, 40] \ No newline at end of file diff --git a/configs/users.yaml b/configs/users.yaml new file mode 100644 index 0000000..d19bad5 --- /dev/null +++ b/configs/users.yaml @@ -0,0 +1,8 @@ +# Name: [Craftsmanship, control, cp] +# You are encouraged to use this either for multiple characters if you have them, or different jobs having +# different gear or melds. +# The top line will always be selected by default + +Vicky Crosia: [4021, 3933, 587] +Dandaedre Zadiel: [0, 0, 0] +Sekundes Dullahan: [2566, 2443, 522] \ No newline at end of file diff --git a/python/dontlook.py b/python/dontlook.py index 1b3fe4f..cf6b64f 100644 --- a/python/dontlook.py +++ b/python/dontlook.py @@ -1,24 +1,12 @@ import dearpygui.dearpygui as dpg +import dearpygui.demo as demo dpg.create_context() -dpg.configure_app(manual_callback_management=True) -dpg.create_viewport() +dpg.create_viewport(title='Custom Title', width=600, height=600) + +demo.show_demo() + dpg.setup_dearpygui() - - -def callback(sender, app_data, user_data): - print("Called on the main thread!") - - -with dpg.window(label="Tutorial"): - dpg.add_button(label="Press me", tag="pog", callback=callback) - - -# main loop dpg.show_viewport() -while dpg.is_dearpygui_running(): - jobs = dpg.get_callback_queue() # retrieves and clears queue - dpg.run_callbacks(jobs) - dpg.render_dearpygui_frame() - -dpg.destroy_context() +dpg.start_dearpygui() +dpg.destroy_context() \ No newline at end of file diff --git a/python/loader.py b/python/loader.py new file mode 100644 index 0000000..3c9ea60 --- /dev/null +++ b/python/loader.py @@ -0,0 +1,69 @@ +import rich +import yaml + + +class Loader: + # TODO: create folder/file if missing when clicking "save" + # TODO: log any missing file(s) or the whole folder + def __init__(self): + self.user_list = {'NEW': [0, 0, 0]} + self.foods_list = {' ': [[0, 0], [0, 0], [0, 0]]} + self.pots_list = {' ': [[0, 0], [0, 0], [0, 0]]} + self.recipes_list = {'NEW': [0, 0, 0]} + try: + with open('../configs/users.yaml', 'r') as file: + self.user_list.update(yaml.safe_load(file)) + except FileNotFoundError as e: + print(e) + try: + with open('../configs/consumables.yaml', 'r') as file: + loaded_file = yaml.safe_load(file) + self.foods_list.update(loaded_file['Foods']) + self.pots_list.update(loaded_file['Pots']) + except FileNotFoundError as e: + print(e) + try: + with open('../configs/recipes.yaml', 'r') as file: + self.recipes_list.update(yaml.safe_load(file)) + except FileNotFoundError as e: + print(e) + + def get_users_dict(self) -> dict: + return self.user_list + + def get_users_names(self) -> list: + user_names = [] + for n in self.user_list: + user_names.append(n) + return user_names + + def get_foods_dict(self) -> dict: + return self.foods_list + + def get_foods_names(self) -> list: + foods_names = [] + for f in self.foods_list: + foods_names.append(f) + return foods_names + + def get_pots_dict(self) -> dict: + return self.pots_list + + def get_pots_names(self) -> list: + pots_names = [] + for p in self.pots_list: + pots_names.append(p) + return pots_names + + def get_recipes_dict(self) -> dict: + return self.recipes_list + + def get_recipes_names(self) -> list: + recipes_names = [] + for r in self.recipes_list: + recipes_names.append(r) + return recipes_names + + +if __name__ == "__main__": + loader = Loader() diff --git a/python/main.py b/python/main.py index 3e3a7d2..25ecfb4 100644 --- a/python/main.py +++ b/python/main.py @@ -1,56 +1,142 @@ import dearpygui.dearpygui as dpg +import loader +import rich import xiv_craft_solver as xcs dpg.create_context() dpg.configure_app(manual_callback_management=True) -dpg.create_viewport(title='XIV Solver', width=500, height=900) +dpg.create_viewport(title='XIV Solver', width=500, height=700) -class USER: +class User: + name = '' craftsmanship = 0 control = 0 + cp = 0 + food = '' + pot = '' + + def set_user_stats(self, _, app_data, __): + self.craftsmanship = app_data[0] + self.control = app_data[1] + self.cp = app_data[2] + dpg.set_value(user_stats, user.get_user_stats()) + return self.craftsmanship, self.control, self.cp + + def set_user_name(self, _, app_data, __): + self.name = app_data + self.set_user_stats(0, full_config.get_users_dict()[self.name], None) + dpg.set_value(user_stats, self.get_user_stats()) + return self.name + + def get_user_stats(self): + return self.craftsmanship, self.control, self.cp + + def set_specialist(self, _, app_data, __): + if app_data: + self.craftsmanship += 20 + self.control += 20 + self.cp += 15 + dpg.set_value(user_stats, [self.craftsmanship, self.control, self.cp, 0]) + else: + self.craftsmanship -= 20 + self.control -= 20 + self.cp -= 15 + dpg.set_value(user_stats, [self.craftsmanship, self.control, self.cp, 0]) + return self.craftsmanship, self.control, self.cp + + def set_food(self, un, app_data, nu): + # TODO: create pre- and post-enhancements stats to be able to handle multiple stacking buffs + self.food = app_data + temp_user_craftsmanship = user.craftsmanship + temp_user_control = user.control + temp_user_cp = user.cp + + craftsmanship, control, cp = full_config.get_foods_dict()[app_data] + + if user.craftsmanship * craftsmanship[0] / 100 > craftsmanship[1]: + temp_user_craftsmanship += craftsmanship[1] + else: + temp_user_craftsmanship += round(user.craftsmanship * craftsmanship[0] / 100) + + if user.control * control[0] / 100 > control[1]: + temp_user_control += control[1] + else: + temp_user_control += round(user.control * control[0] / 100) + + if user.cp * cp[0] / 100 > cp[1]: + temp_user_cp += cp[1] + else: + temp_user_cp += round(user.cp * cp[0] / 100) + + dpg.set_value(user_stats, [temp_user_craftsmanship, temp_user_control, temp_user_cp]) -class RECIPE: - durability = 70 +class Recipe: + name = '' + quality = 0 + difficulty = 0 + durability = 0 + + def set_recipe_stats(self, _, app_data, __): + self.quality = app_data[0] + self.difficulty = app_data[1] + self.durability = app_data[2] + return self.quality, self.difficulty, self.durability + + def get_recipe_stats(self): + return self.quality, self.difficulty, self.durability + + def set_recipe_name(self, _, app_data, __): + self.name = app_data + self.set_recipe_stats(0, full_config.get_recipes_dict()[self.name], 0) + dpg.set_value(recipe_stats, self.get_recipe_stats()) + return self.name -def button_callback(sender, app_data, user_data): - print(f"sender is: {sender}") - print(f"app_data is: {app_data}") - print(f"user_data is: {user_data}") +with dpg.window(label="Settings", width=500, height=700, no_resize=True, no_title_bar=True): + user = User() + recipe = Recipe() + full_config = loader.Loader() + characters_names = full_config.get_users_names() + foods_names = full_config.get_foods_names() + pots_names = full_config.get_pots_names() + recipe_names = full_config.get_recipes_names() -def specialist(_, app_data, c_s): - print(c_s) - print(app_data) - if dpg.get_value(specialist_checkbox): - dpg.set_value(stats, [c_s[0]+1, c_s[1]+2, c_s[2]+3, 0]) - else: - dpg.set_value(stats, [c_s[0], c_s[1], c_s[2], 0]) - - -with dpg.window(label="Settings", width=500, height=900): dpg.add_text("Character") - dpg.add_combo(items=("NEW", "AAAAA", "BBBBB"), label="Your character") + user_combo = dpg.add_combo(items=characters_names, label="Your character", callback=user.set_user_name) + dpg.set_value(user_combo, "NEW") + # TODO: Load 1rst user in users.yaml by default # Make NEW prompt for a name when saving - stats = dpg.add_input_intx(size=3, label="Stats", tag="stats_tooltip") + user_stats = dpg.add_input_intx(size=3, label="Stats", tag="stats_tooltip", callback=user.set_user_stats) with dpg.tooltip("stats_tooltip"): dpg.add_text("Craftsmanship / Control / CP") + specialist_checkbox = dpg.add_checkbox(label="Specialist", tag="specialist", callback=user.set_specialist) + dpg.add_button(label="Save!", indent=282) + + dpg.add_separator() + + dpg.add_text("Consumables") + food_combo = dpg.add_combo(items=foods_names, label="Food", callback=user.set_food) + pot_combo = dpg.add_combo(items=pots_names, label="Pot") + + dpg.add_separator() - current_stats = dpg.get_value(stats) - specialist_checkbox = dpg.add_checkbox(label="Specialist", callback=specialist, tag="specialist") - dpg.add_button(label="Save!") dpg.add_text("Recipe") - dpg.add_combo(items=("AAAAA", "BBBBB"), label="Food") - dpg.add_combo(items=("AAAAA", "BBBBB"), label="Pots") - dpg.add_combo(items=("NEW", "AAAAA", "BBBBB"), label="Recipe") - test = dpg.add_input_intx(size=3, label="Stats", tag="recipe_tooltip") + recipe_combo = dpg.add_combo(items=recipe_names, label="Recipe", callback=recipe.set_recipe_name) + dpg.set_value(recipe_combo, "NEW") + recipe_stats = dpg.add_input_intx(size=3, label="Stats", tag="recipe_tooltip", callback=recipe.set_recipe_stats) with dpg.tooltip("recipe_tooltip"): dpg.add_text("Quality / Progress / Durability") + # TODO: add a small grey text message if recipe matches a known recipe + dpg.add_button(label="Save!", indent=282) + dpg.add_button(label="Solve!") dpg.add_collapsing_header(label="Result") + # TODO: add a log space at the bottom + dpg.setup_dearpygui() dpg.show_viewport() while dpg.is_dearpygui_running(): -- 2.45.1 From 09e88a8f78ba213bd61db26f85cf68c825d67101 Mon Sep 17 00:00:00 2001 From: vicky Date: Wed, 22 Feb 2023 01:11:21 +0100 Subject: [PATCH 3/3] reworked the whole logic behind the gui, this is starting to look decent --- .gitignore | 3 +- configs/consumables.yaml | 16 +- configs/recipes.yaml | 2 +- python/{dontlook.py => example_dearpygui.py} | 2 +- python/main.py | 146 ++++++++++++------- 5 files changed, 103 insertions(+), 66 deletions(-) rename python/{dontlook.py => example_dearpygui.py} (91%) diff --git a/.gitignore b/.gitignore index 495887a..c7d61f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ /target /.idea *.iml - +/bin.py +python/dontlook.py # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/configs/consumables.yaml b/configs/consumables.yaml index 60704b7..f9d7e20 100644 --- a/configs/consumables.yaml +++ b/configs/consumables.yaml @@ -1,11 +1,11 @@ Foods: - # Name: [(Bonus craftsmanship%, max value), (bonus control%, max value), (bonus cp%, max value)] + # Name: [[Bonus craftsmanship%, max value], [bonus control%, max value], [bonus cp%, max value]] # For example, Calamari Ripieni HQ gives 5% craftsmanship up to a maximum of 120, and 26% CP up to a # maximum of 82, and is hence noted as: - # Calamari Ripieni HQ: [(5, 120), (0, 0), (26, 82)] + # Calamari Ripieni HQ: [[5, 120], [0, 0], [26, 82]] # # Here is your template to copy/paste and fill in: - # Name: [(0, 0), (0, 0), (0, 0)] + # Name: [[0, 0], [0, 0], [0, 0]] Calamari Ripieni HQ: [[5, 120], [0, 0], [26, 82]] Calamari Ripieni: [[4, 96], [0, 0], [21, 66]] @@ -14,12 +14,12 @@ Foods: Pots: # Same as above: - # Name: [(Bonus craftsmanship%, max value), (bonus control%, max value), (bonus cp%, max value)] + # Name: [[Bonus craftsmanship%, max value], [bonus control%, max value], [bonus cp%, max value]] # For example, Cunning Craftsman's Draught HQ gives 6% CP up to a maximum of 21, and is hence noted as: - # Cunning Craftsman's Draught HQ: [(0, 0), (0, 0), (6, 21)] + # Cunning Craftsman's Draught HQ: [[0, 0], [0, 0], [6, 21]] # # Here is your template to copy/paste and fill in: - # Name: [(0, 0), (0, 0), (0, 0)] + # Name: [[0, 0], [0, 0], [0, 0]] - Cunning Craftsman's Draught HQ: [(0, 0), (0, 0), (6, 21)] - Cunning Craftsman's Draught: [(0, 0), (0, 0), (5, 17)] \ No newline at end of file + Cunning Craftsman's Draught HQ: [[0, 0], [0, 0], [6, 21]] + Cunning Craftsman's Draught: [[0, 0], [0, 0], [5, 17]] \ No newline at end of file diff --git a/configs/recipes.yaml b/configs/recipes.yaml index 4c8e277..50aa10d 100644 --- a/configs/recipes.yaml +++ b/configs/recipes.yaml @@ -1,3 +1,3 @@ # Name: [Quality, difficulty, durability] Grade 7 Tincture of Strength: [12628, 5060, 70] -Grade 5 Strength Alkahest: [6200, 1300, 40] \ No newline at end of file +Grade 5 Strength Alkahest: [6200, 1300, 35] \ No newline at end of file diff --git a/python/dontlook.py b/python/example_dearpygui.py similarity index 91% rename from python/dontlook.py rename to python/example_dearpygui.py index cf6b64f..75011be 100644 --- a/python/dontlook.py +++ b/python/example_dearpygui.py @@ -9,4 +9,4 @@ demo.show_demo() dpg.setup_dearpygui() dpg.show_viewport() dpg.start_dearpygui() -dpg.destroy_context() \ No newline at end of file +dpg.destroy_context() diff --git a/python/main.py b/python/main.py index 25ecfb4..76c2691 100644 --- a/python/main.py +++ b/python/main.py @@ -9,67 +9,99 @@ dpg.create_viewport(title='XIV Solver', width=500, height=700) class User: - name = '' + name = 'NEW' + food = '' + pot = '' + specialist = False + initial_craftsmanship = 0 + initial_control = 0 + initial_cp = 0 craftsmanship = 0 control = 0 cp = 0 - food = '' - pot = '' - def set_user_stats(self, _, app_data, __): - self.craftsmanship = app_data[0] - self.control = app_data[1] - self.cp = app_data[2] - dpg.set_value(user_stats, user.get_user_stats()) - return self.craftsmanship, self.control, self.cp + def refresh_gui(self) -> True: + self.compute_stats() + dpg.set_value(user_combo, self.name) + dpg.set_value(food_combo, self.food) + dpg.set_value(pot_combo, self.pot) + dpg.set_value(user_effective_stats, [self.craftsmanship, self.control, self.cp]) + return True - def set_user_name(self, _, app_data, __): - self.name = app_data - self.set_user_stats(0, full_config.get_users_dict()[self.name], None) - dpg.set_value(user_stats, self.get_user_stats()) - return self.name + def compute_stats(self) -> list: + food = [] + try: + full_food = full_config.get_foods_dict()[self.food] + # [[5, 120], [0, 0], [26, 82]] + if user.initial_craftsmanship * full_food[0][0] / 100 > full_food[0][1]: + food.append(full_food[0][1]) + else: + food.append(round(user.initial_craftsmanship * full_food[0][0] / 100)) + if user.initial_control * full_food[1][0] / 100 > full_food[1][1]: + food.append(full_food[1][1]) + else: + food.append(round(user.initial_control * full_food[1][0] / 100)) + if user.initial_cp * full_food[2][0] / 100 > full_food[2][1]: + food.append(full_food[2][1]) + else: + food.append(round(user.initial_cp * full_food[2][0] / 100)) + except KeyError as _: + food = [0, 0, 0] + pass - def get_user_stats(self): - return self.craftsmanship, self.control, self.cp + pot = [] + try: + full_pot = full_config.get_pots_dict()[self.pot] + # [(0, 0), (0, 0), (6, 21)] + if user.initial_craftsmanship * full_pot[0][0] / 100 > full_pot[0][1]: + pot.append(full_pot[0][1]) + else: + pot.append(round(user.initial_craftsmanship * full_pot[0][0] / 100)) + if user.initial_control * full_pot[1][0] / 100 > full_pot[1][1]: + pot.append(full_pot[1][1]) + else: + pot.append(round(user.initial_control * full_pot[1][0] / 100)) + if user.initial_cp * full_pot[2][0] / 100 > full_pot[2][1]: + pot.append(full_pot[2][1]) + else: + pot.append(round(user.initial_cp * full_pot[2][0] / 100)) + except KeyError as _: + pot = [0, 0, 0] + pass - def set_specialist(self, _, app_data, __): + if user.specialist: + specialist = [20, 20, 15] + else: + specialist = [0, 0, 0] + + self.craftsmanship = self.initial_craftsmanship + food[0] + pot[0] + specialist[0] + self.control = self.initial_control + food[1] + pot[1] + specialist[1] + self.cp = self.initial_cp + food[2] + pot[2] + specialist[2] + + def set_initial_stats(self, _, app_data, __) -> list: + self.initial_craftsmanship = app_data[0] + self.initial_control = app_data[1] + self.initial_cp = app_data[2] + self.refresh_gui() + return [self.initial_craftsmanship, self.initial_control, self.initial_cp] + + def set_specialist(self, _, app_data, __) -> bool: if app_data: - self.craftsmanship += 20 - self.control += 20 - self.cp += 15 - dpg.set_value(user_stats, [self.craftsmanship, self.control, self.cp, 0]) + self.specialist = True else: - self.craftsmanship -= 20 - self.control -= 20 - self.cp -= 15 - dpg.set_value(user_stats, [self.craftsmanship, self.control, self.cp, 0]) - return self.craftsmanship, self.control, self.cp + self.specialist = False + self.refresh_gui() + return self.specialist - def set_food(self, un, app_data, nu): - # TODO: create pre- and post-enhancements stats to be able to handle multiple stacking buffs + def set_food(self, _, app_data, __) -> str: self.food = app_data - temp_user_craftsmanship = user.craftsmanship - temp_user_control = user.control - temp_user_cp = user.cp + self.refresh_gui() + return self.food - craftsmanship, control, cp = full_config.get_foods_dict()[app_data] - - if user.craftsmanship * craftsmanship[0] / 100 > craftsmanship[1]: - temp_user_craftsmanship += craftsmanship[1] - else: - temp_user_craftsmanship += round(user.craftsmanship * craftsmanship[0] / 100) - - if user.control * control[0] / 100 > control[1]: - temp_user_control += control[1] - else: - temp_user_control += round(user.control * control[0] / 100) - - if user.cp * cp[0] / 100 > cp[1]: - temp_user_cp += cp[1] - else: - temp_user_cp += round(user.cp * cp[0] / 100) - - dpg.set_value(user_stats, [temp_user_craftsmanship, temp_user_control, temp_user_cp]) + def set_pot(self, _, app_data, __) -> str: + self.pot = app_data + self.refresh_gui() + return self.food class Recipe: @@ -105,21 +137,25 @@ with dpg.window(label="Settings", width=500, height=700, no_resize=True, no_titl recipe_names = full_config.get_recipes_names() dpg.add_text("Character") - user_combo = dpg.add_combo(items=characters_names, label="Your character", callback=user.set_user_name) + user_combo = dpg.add_combo(items=characters_names, label="Your character") dpg.set_value(user_combo, "NEW") # TODO: Load 1rst user in users.yaml by default - # Make NEW prompt for a name when saving - user_stats = dpg.add_input_intx(size=3, label="Stats", tag="stats_tooltip", callback=user.set_user_stats) + # TODO: Make NEW prompt for a name when saving + user_stats = dpg.add_input_intx(size=3, label="Stats", tag="stats_tooltip", callback=user.set_initial_stats) with dpg.tooltip("stats_tooltip"): dpg.add_text("Craftsmanship / Control / CP") - specialist_checkbox = dpg.add_checkbox(label="Specialist", tag="specialist", callback=user.set_specialist) dpg.add_button(label="Save!", indent=282) + specialist_checkbox = dpg.add_checkbox(label="Specialist", tag="specialist", callback=user.set_specialist) + dpg.add_text(" ") + user_effective_stats = dpg.add_input_intx(size=3, label="Effective stats", tag="effective_stats_tooltip", readonly=True) + with dpg.tooltip("effective_stats_tooltip"): + dpg.add_text("Craftsmanship / Control / CP") dpg.add_separator() dpg.add_text("Consumables") food_combo = dpg.add_combo(items=foods_names, label="Food", callback=user.set_food) - pot_combo = dpg.add_combo(items=pots_names, label="Pot") + pot_combo = dpg.add_combo(items=pots_names, label="Pot", callback=user.set_pot) dpg.add_separator() @@ -128,7 +164,7 @@ with dpg.window(label="Settings", width=500, height=700, no_resize=True, no_titl dpg.set_value(recipe_combo, "NEW") recipe_stats = dpg.add_input_intx(size=3, label="Stats", tag="recipe_tooltip", callback=recipe.set_recipe_stats) with dpg.tooltip("recipe_tooltip"): - dpg.add_text("Quality / Progress / Durability") + dpg.add_text("Quality / Difficulty / Durability") # TODO: add a small grey text message if recipe matches a known recipe dpg.add_button(label="Save!", indent=282) -- 2.45.1