finalized save feature!

This commit is contained in:
vicky 2023-03-04 14:32:27 +01:00
parent a2b618f566
commit cf9fe275ee
4 changed files with 59 additions and 29 deletions

View File

@ -136,7 +136,7 @@ class Recipe:
progress_extra_difficulty = 0 progress_extra_difficulty = 0
def refresh_gui(self): def refresh_gui(self):
dpg.set_value(recipe_stats, self.get_recipe_stats()[0:3]) dpg.set_value(basic_recipe_stats, self.get_recipe_stats()[0:3])
dpg.set_value(advanced_recipe_stats, self.get_recipe_stats()[3:7]) dpg.set_value(advanced_recipe_stats, self.get_recipe_stats()[3:7])
if self.name != ' ': if self.name != ' ':
dpg.set_value(save_recipe_as, self.name) dpg.set_value(save_recipe_as, self.name)
@ -147,11 +147,11 @@ class Recipe:
stats = [0, 0, 0] stats = [0, 0, 0]
advanced_stats = [0, 0, 0, 0] advanced_stats = [0, 0, 0, 0]
if tag == 'recipe_tooltip': if tag == 'basic_recipe_stats':
stats = app_data stats = app_data
advanced_stats = dpg.get_value(advanced_recipe_stats) advanced_stats = dpg.get_value(advanced_recipe_stats)
elif tag == 'advanced_recipe_tooltip': elif tag == 'advanced_recipe_stats':
stats = dpg.get_value(recipe_stats) stats = dpg.get_value(basic_recipe_stats)
advanced_stats = app_data advanced_stats = app_data
elif tag == 0: elif tag == 0:
stats = [app_data[0], app_data[1], app_data[2]] stats = [app_data[0], app_data[1], app_data[2]]
@ -183,6 +183,22 @@ class Recipe:
def get_recipe_name(self) -> str: def get_recipe_name(self) -> str:
return self.name return self.name
@staticmethod
def save_recipe() -> True:
if dpg.get_value(save_recipe_as) == '':
loggers.add_log('Cannot save recipe without a name.')
elif re.search(r'^\s+$', dpg.get_value(save_recipe_as)):
loggers.add_log('Name cannot be only whitespaces.')
elif re.search(r'^\s.+', dpg.get_value(save_recipe_as)):
loggers.add_log('Name cannot start with a whitespace.')
elif re.search(r'\s$', dpg.get_value(save_recipe_as)):
loggers.add_log('Name cannot end with a whitespace.')
else:
saver.save_recipe(dpg.get_value(save_recipe_as), dpg.get_value(basic_recipe_stats), dpg.get_value(advanced_recipe_stats))
loggers.add_log('Recipe saved!')
dpg.configure_item('recipe_combo', items=full_config.get_recipes_names())
return True
class Solution: class Solution:
def __init__(self, title, logger): def __init__(self, title, logger):
@ -267,7 +283,6 @@ if __name__ == '__main__':
save_user_as = dpg.add_input_text(hint='Save as...') save_user_as = dpg.add_input_text(hint='Save as...')
# TODO: make it so field is not cleared at every input in stats # TODO: make it so field is not cleared at every input in stats
dpg.add_button(label="Save!", callback=user.save_users) dpg.add_button(label="Save!", callback=user.save_users)
# TODO: Can't save if value == ' '
# EFFECTIVE STATS # EFFECTIVE STATS
dpg.add_separator() dpg.add_separator()
@ -286,20 +301,20 @@ if __name__ == '__main__':
# RECIPE # RECIPE
dpg.add_separator() dpg.add_separator()
dpg.add_text("Recipe") dpg.add_text("Recipe")
recipe_combo = dpg.add_combo(items=recipe_names, label="Recipe", callback=recipe.set_recipe_name) recipe_combo = dpg.add_combo(items=recipe_names, tag='recipe_combo', label="Recipe", callback=recipe.set_recipe_name)
dpg.set_value(recipe_combo, " ") dpg.set_value(recipe_combo, " ")
recipe_stats = dpg.add_input_intx(size=3, label="Stats", tag="recipe_tooltip", callback=recipe.set_recipe_stats) basic_recipe_stats = dpg.add_input_intx(size=3, label="Stats", tag="basic_recipe_stats", callback=recipe.set_recipe_stats)
with dpg.tooltip("recipe_tooltip"): with dpg.tooltip("basic_recipe_stats"):
dpg.add_text("Progress / Quality / Durability") dpg.add_text("Progress / Quality / Durability")
advanced_recipe_stats = dpg.add_input_intx( advanced_recipe_stats = dpg.add_input_intx(
size=4, label="Advanced stats", tag="advanced_recipe_tooltip", callback=recipe.set_recipe_stats size=4, label="Advanced stats", tag="advanced_recipe_stats", callback=recipe.set_recipe_stats
) )
with dpg.tooltip("advanced_recipe_tooltip"): with dpg.tooltip("advanced_recipe_stats"):
dpg.add_text("Progress / Quality difficulty // Progress / Quality extra difficulty") dpg.add_text("Progress / Quality difficulty // Progress / Quality extra difficulty")
# TODO: add a log if recipe matches a known recipe # TODO: add a log if recipe matches a known recipe
with dpg.group(horizontal=True): with dpg.group(horizontal=True):
save_recipe_as = dpg.add_input_text(hint='Save as...') save_recipe_as = dpg.add_input_text(hint='Save as...')
dpg.add_button(label="Save!", callback=request_solve) dpg.add_button(label="Save!", callback=recipe.save_recipe)
# TODO: Can't save if value == ' ' # TODO: Can't save if value == ' '
# SOLVE # SOLVE

View File

@ -2,7 +2,7 @@
# as can be found on other solver websites, such as https://yyyy.games/crafter/index.html#/simulator and checking custom recipe. # as can be found on other solver websites, such as https://yyyy.games/crafter/index.html#/simulator and checking custom recipe.
# The language option is the second menu to the left from the top-right hand corner. # The language option is the second menu to the left from the top-right hand corner.
# If this seems super convoluted, and you'd rather it was just the three in-game values, know that me too. # If this seems super convoluted, and you'd rather it was just the three in-game values, know that me too.
# Unfortunately that is how Square Enix chose to make crafting work in FFXIV. # Unfortunately that is how the craft system works in FFXIV.
Grade 7 Tincture of Strength: [5060, 12628, 70, 130, 115, 80, 70] Grade 7 Tincture of Strength: [5060, 12628, 70, 130, 115, 80, 70]
Grade 5 Strength Alkahest: [1300, 6200, 40, 123, 107, 100, 100] Grade 5 Strength Alkahest: [1300, 6200, 40, 123, 107, 100, 100]

View File

@ -1,11 +1,9 @@
# Name: [Craftsmanship, control, cp] # Name: [Progress, quality, durability, progress difficulty, quality difficulty, extra progress difficulty, extra quality difficulty]
# You are encouraged to use this either for multiple characters if you have them, or different jobs having # as can be found on other solver websites, such as https://yyyy.games/crafter/index.html#/simulator and checking custom recipe.
# different gear or melds. # The language option is the second menu to the left from the top-right hand corner.
# The top line will always be selected by default # If this seems super convoluted, and you'd rather it was just the three in-game values, know that me too.
# Unfortunately that is how the craft system works in FFXIV.
Grade 7 Tincture of Strength: [5060, 12628, 70, 130, 115, 80, 70]
Vicky Crosia: [4021, 3933, 587] Grade 5 Strength Alkahest: [1300, 6200, 40, 123, 107, 100, 100]
Dandaedre Zadiel: [0, 0, 2] ewq: [0, 1, 2, 3, 4, 5, 6]
Sekundes Dullahan: [2566, 2443, 522]
ewww: [213, 3124, 0]
bernard: [0, 0, 0]

View File

@ -32,7 +32,7 @@ class Printer:
# Unfortunately that is how the craft system works in FFXIV.''' # Unfortunately that is how the craft system works in FFXIV.'''
} }
def save_users(self, user_name: str = None, user_stats: list = None): def save_users(self, user_name: str = None, user_stats: list = None) -> dict:
output = self.help_text_dict['users'] + '\n\n' output = self.help_text_dict['users'] + '\n\n'
if user_name.title() == '': if user_name.title() == '':
@ -49,12 +49,29 @@ class Printer:
self.print_users(output) self.print_users(output)
return self.full_config.get_users_dict() return self.full_config.get_users_dict()
def print_users(self, output: str): def print_users(self, output: str) -> True:
with open(self.full_config.relative_import(self.full_config.config.yaml_user), 'w') as file: with open(self.full_config.relative_import(self.full_config.config.yaml_user), 'w') as file:
file.write(output) file.write(output)
return True
def save_recipe(self): def save_recipe(self, recipe_name: str = None, recipe_basic_stats: list = None, recipe_advanced_stats: list = None) -> dict:
pass output = self.help_text_dict['recipe'] + '\n\n'
def save_consumables(self): if recipe_name.title() == '':
pass for recipe, stats in self.full_config.get_recipes_dict().items():
if recipe != ' ':
output += f'{recipe}: [{stats[0]}, {stats[1]}, {stats[2]}, {stats[3]}, {stats[4]}, {stats[5]}, {stats[6]}]\n'
else:
self.full_config.get_recipes_dict()[recipe_name] = recipe_basic_stats[:-1] + recipe_advanced_stats
for recipe, stats in self.full_config.get_recipes_dict().items():
if recipe != ' ':
output += f'{recipe}: [{stats[0]}, {stats[1]}, {stats[2]}, {stats[3]}, {stats[4]}, {stats[5]}, {stats[6]}]\n'
self.print_recipe(output)
return self.full_config.get_recipes_dict()
def print_recipe(self, output) -> True:
with open(self.full_config.relative_import(self.full_config.config.yaml_recipes), 'w') as file:
file.write(output)
return True