Skip to content

Commit

Permalink
Version 1.13.0 (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVG207 authored Mar 26, 2024
2 parents 711bb47 + fc9fcfd commit 554cae8
Show file tree
Hide file tree
Showing 20 changed files with 704 additions and 519 deletions.
1 change: 1 addition & 0 deletions umalauncher/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ chr_profile/*
edg_profile/*
node_modules/*
training_logs/*
appdata/
screenshot.png
umasettings*.json
log.log
Expand Down
21 changes: 11 additions & 10 deletions umalauncher/carrotjuicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import umapatcher

class CarrotJuicer():
start_time = None
browser: horsium.BrowserWindow = None
previous_element = None
threader = None
Expand All @@ -43,6 +42,8 @@ class CarrotJuicer():
def __init__(self, threader):
self.threader = threader

self.start_time = 0

self.skill_id_dict = mdb.get_skill_id_dict()

self.screen_state_handler = threader.screenstate
Expand Down Expand Up @@ -110,7 +111,7 @@ def to_json(self, packet, out_name="packet.json"):
def open_helper(self):
self.close_browser()

start_pos = self.threader.settings["s_browser_position"]
start_pos = self.threader.settings["browser_position"]
if not start_pos:
start_pos = self.get_browser_reset_position()

Expand Down Expand Up @@ -153,12 +154,12 @@ def save_rect(self, rect_var, setting):
rect_var = None

def save_last_browser_rect(self):
self.save_rect(self.last_browser_rect, "s_browser_position")
self.save_rect(self.last_browser_rect, "browser_position")

def save_skill_window_rect(self):
if self.skill_browser:
self.skill_browser.last_window_rect = self.last_skills_rect
self.save_rect(self.last_skills_rect, "s_skills_position")
self.save_rect(self.last_skills_rect, "skills_position")

def end_training(self):
if self.training_tracker:
Expand All @@ -169,7 +170,7 @@ def end_training(self):
return

def add_response_to_tracker(self, data):
should_track = self.threader.settings["s_track_trainings"]
should_track = self.threader.settings["track_trainings"]
if self.previous_request:
if should_track:
self.training_tracker.add_request(self.previous_request)
Expand Down Expand Up @@ -213,7 +214,7 @@ def handle_response(self, message, is_json=False):
if not data:
return

if self.threader.settings["s_save_packets"]:
if self.threader.settings["save_packets"]:
logger.debug("Response:")
logger.debug(json.dumps(data))
self.to_json(data, "packet_in.json")
Expand Down Expand Up @@ -452,7 +453,7 @@ def handle_request(self, message):
if not data:
return

if self.threader.settings["s_save_packets"]:
if self.threader.settings["save_packets"]:
logger.debug("Request:")
logger.debug(json.dumps(data))
self.to_json(data, "packet_out.json")
Expand Down Expand Up @@ -561,7 +562,7 @@ def update_helper_table(self, data):

def update_skill_window(self):
if not self.skill_browser:
self.skill_browser = horsium.BrowserWindow("https://gametora.com/umamusume/skills", self.threader, rect=self.threader.settings['s_skills_position'], run_at_launch=setup_skill_window)
self.skill_browser = horsium.BrowserWindow("https://gametora.com/umamusume/skills", self.threader, rect=self.threader.settings['skills_position'], run_at_launch=setup_skill_window)
else:
self.skill_browser.ensure_tab_open()
if self.browser and self.browser.alive():
Expand Down Expand Up @@ -660,7 +661,7 @@ def run(self):

msg_path = os.path.join(base_path, "CarrotJuicer")

if not self.threader.settings["s_enable_carrotjuicer"] or not self.threader.settings['s_enable_browser']:
if not self.threader.settings["enable_carrotjuicer"] or not self.threader.settings['enable_browser']:
if self.browser and self.browser.alive():
self.browser.quit()
if self.skill_browser and self.skill_browser.alive():
Expand Down Expand Up @@ -928,7 +929,7 @@ def gametora_dark_mode(browser: horsium.BrowserWindow):
time.sleep(0.25)

dark_enabled = browser.execute_script("""return document.querySelector("[class^='tooltips_tooltip_']").querySelector("[class^='filters_toggle_button_']").childNodes[0].querySelector("input").checked;""")
if dark_enabled != browser.threader.settings["s_gametora_dark_mode"]:
if dark_enabled != browser.threader.settings["gametora_dark_mode"]:
browser.execute_script("""document.querySelector("[class^='tooltips_tooltip_']").querySelector("[class^='filters_toggle_button_']").childNodes[0].querySelector("input").click()""")
browser.execute_script("""document.querySelector("[class^='styles_header_settings_']").click()""")

Expand Down
36 changes: 30 additions & 6 deletions umalauncher/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
4: "Make a New Track",
5: "Grand Masters",
6: "Project L'Arc",
7: "U.A.F. Ready Go!"
7: "U.A.F. Ready GO!"
}

MOTIVATION_DICT = {
Expand Down Expand Up @@ -118,10 +118,10 @@
]

ORIENTATION_DICT = {
True: 's_game_position_portrait',
False: 's_game_position_landscape',
's_game_position_portrait': True,
's_game_position_landscape': False,
True: 'game_position_portrait',
False: 'game_position_landscape',
'game_position_portrait': True,
'game_position_landscape': False,
}

# Request packets contain keys that should not be kept for privacy reasons.
Expand Down Expand Up @@ -203,4 +203,28 @@
"1": "rgba(0, 0, 255, 0.1)",
"2": "rgba(255, 0, 0, 0.1)",
"3": "rgba(255, 255, 0, 0.1)",
}
}

DEFAULT_TRAINING_SECTIONS = (
(1, "cyan", "Pre-Debut"),
(13, "lightgreen", "Junior"),
(25, "salmon", "Classic"),
(37, "yellow", "Classic Summer"),
(41, "salmon", "Classic"),
(49, "plum", "Senior"),
(61, "yellow", "Senior Summer"),
(65, "plum", "Senior"),
(73, "gold", "URA Finals"),
(79, "black", "END")
)

DEFAULT_ARC_SECTIONS = (
(1, "cyan", "Pre-Debut"),
(13, "lightgreen", "Junior"),
(25, "salmon", "Classic"),
(37, "yellow", "Overseas Expedition"),
(44, "salmon", "Classic"),
(49, "plum", "Senior"),
(61, "yellow", "Overseas Expedition"),
(68, "black", "END")
)
35 changes: 20 additions & 15 deletions umalauncher/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ def on_new_preset(self):
def on_delete_preset(self):
if self.cmb_select_preset.count() > 1:
current_preset = self.cmb_select_preset.currentText()

# Ask the user if they are sure.
reply = qtw.QMessageBox.question(self, "Delete preset", f"Are you sure you want to delete preset '{current_preset}'?", qtw.QMessageBox.Yes | qtw.QMessageBox.No, qtw.QMessageBox.No)
if reply == qtw.QMessageBox.No:
return

new_preset_list = []
for preset in self.preset_list:
if preset.name != current_preset:
Expand Down Expand Up @@ -615,13 +621,13 @@ def load_settings(self):
self.verticalLayout.removeItem(self.verticalLayout.itemAt(i))

# Adding group boxes to the scroll area
settings_keys = self.settings_var[0].get_settings_keys()
settings_keys = self.settings_var[0].keys()
last_setting = settings_keys[-1]
for setting_key in settings_keys:
setting = getattr(self.settings_var[0], setting_key)
setting = self.settings_var[0][setting_key]

# Filter tab and priority
if setting.priority < 0 or setting.tab != self.tab:
if setting.hidden or setting.tab != self.tab:
continue

group_box, value_func = self.add_group_box(setting)
Expand All @@ -644,7 +650,7 @@ def load_settings(self):

def restore_defaults(self):
default_settings_var = type(self.settings_var[0])()
for setting_key in default_settings_var.get_settings_keys():
for setting_key in default_settings_var.keys():
setting = getattr(default_settings_var, setting_key)
if setting.priority < 0 or setting.tab != self.tab:
continue
Expand All @@ -666,7 +672,7 @@ def save_settings(self):

for key, value in new_settings_dict.items():
logger.debug(f"Setting {key} to {value}")
getattr(self.settings_var[0], key).value = value
self.settings_var[0][key].value = value
return True

def add_group_box(self, setting):
Expand Down Expand Up @@ -1062,22 +1068,21 @@ def init_ui(self, umasettings, general_var, preset_dict, selected_preset, new_pr
self.tabWidget.setSizePolicy(qtw.QSizePolicy.Preferred, qtw.QSizePolicy.Preferred)
self.tabWidget.currentChanged.connect(self.tab_changed)

unique_tabs = sorted(list({getattr(general_var[0], key).tab for key in general_var[0].get_settings_keys()}))
unique_tabs = sorted(list({getattr(general_var[0], key).tab for key in general_var[0].keys()}))

# Hack
unique_tabs.append(unique_tabs.pop(unique_tabs.index("English Patch")))

self.command_dicts = {
"English Patch": {
"patch_customize": lambda: umasettings.patch_customization(),
"patch_unpatch": lambda: umasettings.patch_unpatch(),
}
self.command_dict = {
"patch_customize": lambda: umasettings.patch_customization(),
"patch_unpatch": lambda: umasettings.patch_unpatch(),
"open_training_logs": lambda: util.open_folder(util.TRAINING_LOGS_FOLDER)
}

self.settings_widgets = []

for tab in unique_tabs:
tab_widget = UmaGeneralSettingsDialog(self, general_var, tab=tab, command_dict=self.command_dicts.get(tab, {}))
tab_widget = UmaGeneralSettingsDialog(self, general_var, tab=tab, command_dict=self.command_dict)
tab_widget.setObjectName(f"tab_{tab}")
self.settings_widgets.append(tab_widget)
self.tabWidget.addTab(tab_widget, tab.lstrip(" "))
Expand All @@ -1095,7 +1100,7 @@ def init_ui(self, umasettings, general_var, preset_dict, selected_preset, new_pr
default_preset=default_preset,
new_preset_class=new_preset_class,
preset_list=list(preset_dict.values()),
scenario_preset_dict=getattr(general_var[0], 's_training_helper_table_scenario_presets').value,
scenario_preset_dict=getattr(general_var[0], 'training_helper_table_scenario_presets').value,
row_types_enum=row_types_enum,
output_list=new_preset_list,
output_dict=new_scenario_preset_dict
Expand Down Expand Up @@ -1461,7 +1466,7 @@ def init_ui(self, settings, *args, **kwargs):

self.lbl_unique = qtw.QLabel(self.verticalLayoutWidget)
self.lbl_unique.setObjectName(u"lbl_unique")
self.lbl_unique.setText(self.settings['s_unique_id'])
self.lbl_unique.setText(self.settings['unique_id'])
self.lbl_unique.setAlignment(qtc.Qt.AlignCenter)

self.verticalLayout.addWidget(self.lbl_unique)
Expand Down Expand Up @@ -1492,7 +1497,7 @@ def update_check(self):

def on_refresh_id(self):
self.settings.regenerate_unique_id()
self.lbl_unique.setText(self.settings['s_unique_id'])
self.lbl_unique.setText(self.settings['unique_id'])


class UmaScenarioPresetDialog(UmaMainDialog):
Expand Down
14 changes: 9 additions & 5 deletions umalauncher/helper_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def create_helper_elements(self, data, last_data) -> str:
'team_data_set', # Aoharu
'ura_data_set', # URA
'arc_data_set', # Project L'Arc
'sport_data_set' # UAF Ready Go!
'sport_data_set' # UAF Ready GO!
]
for key in scenario_keys:
if key in data and 'command_info_array' in data[key]:
Expand Down Expand Up @@ -383,7 +383,7 @@ def create_helper_elements(self, data, last_data) -> str:
gained_energy = min(gained_energy, max_energy - energy)


# UAF Ready Go!
# UAF Ready GO!
uaf_sport_rank = {}
uaf_sport_gain = {}
uaf_current_active_effects = {}
Expand All @@ -392,6 +392,7 @@ def create_helper_elements(self, data, last_data) -> str:
uaf_sport_rank_total = {2100: 0, 2200: 0, 2300: 0}
uaf_required_rank_for_turn = {}
uaf_current_required_rank = -1
uaf_consultations_left = 0

if 'sport_data_set' in data:
sport_levels = data['sport_data_set'].get('training_array', [])
Expand Down Expand Up @@ -419,6 +420,8 @@ def create_helper_elements(self, data, last_data) -> str:
group_counts[group] += 1

uaf_sport_competition = f"{group_counts['1']}/{group_counts['2']}/{group_counts['3']}"

uaf_consultations_left = len(data['sport_data_set'].get('item_id_array', []))

uaf_required_rank_for_turn = mdb.get_uaf_required_rank_for_turn()
uaf_required_rank_for_turn.sort(key=lambda x: x[0], reverse=1)
Expand Down Expand Up @@ -548,17 +551,18 @@ def create_helper_elements(self, data, last_data) -> str:
"uaf_current_active_effects": uaf_current_active_effects,
"uaf_current_active_bonus": uaf_current_active_bonus,
"uaf_sport_competition": uaf_sport_competition,
"uaf_consultations_left": uaf_consultations_left,
"eval_dict": eval_dict,
"all_commands": all_commands
}

# Update preset if needed.
if self.carrotjuicer.threader.settings['s_training_helper_table_scenario_presets_enabled']:
scenario_preset = self.carrotjuicer.threader.settings['s_training_helper_table_scenario_presets'].get(str(scenario_id), None)
if self.carrotjuicer.threader.settings['training_helper_table_scenario_presets_enabled']:
scenario_preset = self.carrotjuicer.threader.settings['training_helper_table_scenario_presets'].get(str(scenario_id), None)
if scenario_preset and self.selected_preset.name != scenario_preset:
self.selected_preset = self.carrotjuicer.threader.settings.get_preset_with_name(scenario_preset)
else:
general_preset = self.carrotjuicer.threader.settings['s_training_helper_table_preset']
general_preset = self.carrotjuicer.threader.settings['training_helper_table_preset']
if self.selected_preset.name != general_preset:
self.selected_preset = self.carrotjuicer.threader.settings.get_preset_with_name(general_preset)

Expand Down
Loading

0 comments on commit 554cae8

Please sign in to comment.