Skip to content

Commit

Permalink
Version 1.9.2 (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVG207 authored Nov 29, 2023
2 parents d179e53 + e31dc92 commit 5b669e5
Show file tree
Hide file tree
Showing 11 changed files with 308 additions and 91 deletions.
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ outcome==1.2.0
packaging==23.0
pathvalidate==3.0.0
pefile==2023.2.7
Pillow>=10.0.1
Pillow==10.1.0
protobuf==4.22.1
psutil==5.9.5
pycparser==2.21
Expand All @@ -47,14 +47,14 @@ pywin32==306
pywin32-ctypes==0.2.2
PyYAML==6.0
requests==2.31.0
selenium==4.8.2
selenium==4.15.2
six==1.16.0
sniffio==1.3.0
sortedcontainers==2.4.0
soupsieve==2.4
trio==0.22.0
trio-websocket==0.9.2
urllib3>=1.26.18
Werkzeug>=3.0.1
urllib3==1.26.18
Werkzeug==3.0.1
win32-setctime==1.1.0
wsproto==1.2.0
6 changes: 5 additions & 1 deletion umalauncher/carrotjuicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,11 @@ def run(self):
while not self.should_stop:
time.sleep(0.25)

if not self.threader.settings["s_enable_carrotjuicer"]:
if not self.threader.settings["s_enable_carrotjuicer"] or not self.threader.settings['s_enable_browser']:
if self.browser and self.browser.alive():
self.browser.quit()
if self.skill_browser and self.skill_browser.alive():
self.skill_browser.quit()
continue

if self.browser and self.browser.alive():
Expand Down
64 changes: 32 additions & 32 deletions umalauncher/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,35 +143,35 @@
30000: "Platinum 4"
}

SCOUTING_SCORE_TO_RANK_DICT = {
0: "No rank",
60000: "E",
63000: "E1",
66000: "E2",
69000: "E3",
72000: "D",
76000: "D1",
80000: "D2",
85000: "D3",
90000: "C",
95000: "C1",
100000: "C2",
105000: "C3",
110000: "B",
115000: "B1",
120000: "B2",
125000: "B3",
130000: "A",
135000: "A1",
140000: "A2",
145000: "A3",
150000: "A4",
155000: "A5",
160000: "S",
165000: "S1",
170000: "S2",
180000: "S3",
190000: "S4",
200000: "S5",
210000: "SS"
}
SCOUTING_RANK_LIST = [
"No rank",
"E",
"E1",
"E2",
"E3",
"D",
"D1",
"D2",
"D3",
"C",
"C1",
"C2",
"C3",
"B",
"B1",
"B2",
"B3",
"A",
"A1",
"A2",
"A3",
"A4",
"A5",
"S",
"S1",
"S2",
"S3",
"S4",
"S5",
"SS"
]
61 changes: 38 additions & 23 deletions umalauncher/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,9 @@ def init_ui(self, settings_var, tab=" General", window_title="Change options", *

self.load_settings()

self.verticalSpacer = qtw.QSpacerItem(0, 0, qtw.QSizePolicy.Minimum, qtw.QSizePolicy.Expanding)
self.verticalLayout.addItem(self.verticalSpacer)

self.scrollArea.setWidget(self.scrollAreaWidgetContents)

self.btn_restore = qtw.QPushButton(self)
Expand Down Expand Up @@ -662,6 +665,18 @@ def save_settings(self):
return True

def add_group_box(self, setting):
# If the setting is a divider, add a horizontal line.
if setting.type == se.SettingType.DIVIDER:
line = qtw.QFrame(self.scrollAreaWidgetContents)
line.setObjectName(f"line_{setting.name}")
line.setMinimumHeight(16)
line.setLineWidth(0)
line.setMidLineWidth(2)
line.setFrameShape(qtw.QFrame.HLine)
line.setFrameShadow(qtw.QFrame.Sunken)
return line, None


grp_setting = qtw.QGroupBox(self.scrollAreaWidgetContents)
grp_setting.setObjectName(f"grp_setting_{setting.name}")
sizePolicy = qtw.QSizePolicy(qtw.QSizePolicy.Preferred, qtw.QSizePolicy.Fixed)
Expand Down Expand Up @@ -691,30 +706,30 @@ def add_group_box(self, setting):

horizontalLayout.addWidget(lbl_setting_description)

input_widgets = []
input_widgets = [None]
value_func = None
if setting.type == se.SettingType.MESSAGE:
input_widgets = [None]
elif setting.type == se.SettingType.BOOL:
input_widgets, value_func = self.add_checkbox(setting, grp_setting)
elif setting.type == se.SettingType.INT:
input_widgets, value_func = self.add_spinbox(setting, grp_setting)
elif setting.type == se.SettingType.STRING:
input_widgets, value_func = self.add_lineedit(setting, grp_setting)
elif setting.type == se.SettingType.COMBOBOX:
input_widgets, value_func = self.add_combobox(setting, grp_setting)
elif setting.type == se.SettingType.COLOR:
input_widgets, value_func = self.add_colorpicker(setting, grp_setting)
elif setting.type == se.SettingType.RADIOBUTTONS:
input_widgets, value_func = self.add_radiobuttons(setting, grp_setting)
elif setting.type == se.SettingType.FILEDIALOG:
input_widgets, value_func = self.add_filedialog(setting, grp_setting)
elif setting.type == se.SettingType.FOLDERDIALOG:
input_widgets, value_func = self.add_folderdialog(setting, grp_setting)
elif setting.type == se.SettingType.XYWHSPINBOXES:
input_widgets, value_func = self.add_multi_spinboxes(setting, grp_setting, ['Left', 'Top', 'Width', 'Height'])
elif setting.type == se.SettingType.LRTBSPINBOXES:
input_widgets, value_func = self.add_multi_spinboxes(setting, grp_setting, ['Left', 'Right', 'Top', 'Bottom'])

match setting.type:
case se.SettingType.BOOL:
input_widgets, value_func = self.add_checkbox(setting, grp_setting)
case se.SettingType.INT:
input_widgets, value_func = self.add_spinbox(setting, grp_setting)
case se.SettingType.STRING:
input_widgets, value_func = self.add_lineedit(setting, grp_setting)
case se.SettingType.COMBOBOX:
input_widgets, value_func = self.add_combobox(setting, grp_setting)
case se.SettingType.COLOR:
input_widgets, value_func = self.add_colorpicker(setting, grp_setting)
case se.SettingType.RADIOBUTTONS:
input_widgets, value_func = self.add_radiobuttons(setting, grp_setting)
case se.SettingType.FILEDIALOG:
input_widgets, value_func = self.add_filedialog(setting, grp_setting)
case se.SettingType.FOLDERDIALOG:
input_widgets, value_func = self.add_folderdialog(setting, grp_setting)
case se.SettingType.XYWHSPINBOXES:
input_widgets, value_func = self.add_multi_spinboxes(setting, grp_setting, ['Left', 'Top', 'Width', 'Height'])
case se.SettingType.LRTBSPINBOXES:
input_widgets, value_func = self.add_multi_spinboxes(setting, grp_setting, ['Left', 'Right', 'Top', 'Bottom'])

if not input_widgets:
logger.debug(f"{setting.type} not implemented for {setting.name}")
Expand Down
88 changes: 72 additions & 16 deletions umalauncher/horsium.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,86 @@

OLD_DRIVERS = []

def firefox_setup(helper_url):
firefox_service = FirefoxService()
def firefox_setup(helper_url, settings):
driver_path = None
if settings['s_enable_browser_override']:
new_path = settings['s_browser_custom_driver']
if new_path:
driver_path = new_path

firefox_service = FirefoxService(executable_path=driver_path)
firefox_service.creation_flags = CREATE_NO_WINDOW
profile = webdriver.FirefoxProfile(util.get_asset("ff_profile"))
options = webdriver.FirefoxOptions()
browser = webdriver.Firefox(service=firefox_service, firefox_profile=profile, options=options)
options.profile = profile

binary_path = None

if settings['s_enable_browser_override']:
binary_path = settings['s_browser_custom_binary']
if binary_path:
options.binary_location = binary_path

logger.debug(f"Firefox driver path: {driver_path}")
logger.debug(f"Firefox binary path: {binary_path}")

browser = webdriver.Firefox(service=firefox_service, options=options)
browser.get(helper_url)
return browser

def chromium_setup(service, options_class, driver_class, profile, helper_url):
def chromium_setup(service, options_class, driver_class, profile, helper_url, settings, binary_path=None):
service.creation_flags = CREATE_NO_WINDOW
options = options_class()

if binary_path:
options.binary_location = binary_path

options.add_argument("--user-data-dir=" + str(util.get_asset(profile)))
options.add_argument("--app=" + helper_url)
options.add_argument("--remote-debugging-port=9222")
options.add_argument("--new-window")

if not settings['s_enable_browser_override']:
options.add_argument("--app=" + helper_url)

browser = driver_class(service=service, options=options)

if settings['s_enable_browser_override']:
browser.get(helper_url)

return browser

def chrome_setup(helper_url):
def chrome_setup(helper_url, settings):
driver_path = None
if settings['s_enable_browser_override']:
new_path = settings['s_browser_custom_driver']
if new_path:
driver_path = new_path

binary_path = None
if settings['s_enable_browser_override']:
binary_path = settings['s_browser_custom_binary']

logger.debug(f"Chrome driver path: {driver_path}")
logger.debug(f"Chrome binary path: {binary_path}")

return chromium_setup(
service=ChromeService(),
service=ChromeService(executable_path=driver_path) if driver_path else ChromeService(),
options_class=webdriver.ChromeOptions,
driver_class=webdriver.Chrome,
profile="chr_profile",
helper_url=helper_url
helper_url=helper_url,
settings=settings,
binary_path=binary_path
)

def edge_setup(helper_url):
def edge_setup(helper_url, settings):
return chromium_setup(
service=EdgeService(),
options_class=webdriver.EdgeOptions,
driver_class=webdriver.Edge,
profile="edg_profile",
helper_url=helper_url
helper_url=helper_url,
settings=settings
)

BROWSER_LIST = {
Expand All @@ -77,24 +122,34 @@ class BrowserWindow:
def __init__(self, url, threader, rect=None, run_at_launch=None):
self.url = url
self.threader = threader
self.settings = threader.settings
self.driver: RemoteWebDriver = None
self.active_tab_handle = None
self.last_window_rect = {'x': rect[0], 'y': rect[1], 'width': rect[2], 'height': rect[3]} if rect else None
self.run_at_launch = run_at_launch
self.browser_name = "Auto"
self.latest_error = ""

self.ensure_tab_open()

def init_browser(self) -> RemoteWebDriver:
driver = None

if self.settings['s_enable_browser_override']:
selection = self.settings['s_custom_browser_type']
else:
selection = self.settings['s_selected_browser']
browser_name = [
browser
for browser, selected in self.threader.settings['s_selected_browser'].items()
for browser, selected in selection.items()
if selected
][0]
self.browser_name = browser_name

# Hack to convert override Chromium to Chrome
if browser_name == 'Other (Chromium)':
browser_name = 'Chrome'

browser_list = []
if browser_name == "Auto":
browser_list = BROWSER_LIST.items()
Expand All @@ -105,14 +160,15 @@ def init_browser(self) -> RemoteWebDriver:
browser_name, browser_setup = browser_data
try:
logger.info("Attempting " + str(browser_setup.__name__))
driver = browser_setup(self.url)
driver = browser_setup(self.url, self.settings)
self.browser_name = browser_name
break
except Exception:
except Exception as e:
logger.error("Failed to start browser")
logger.error(traceback.format_exc())
if not driver:
util.show_warning_box("Uma Launcher: Unable to start browser.", "Selected webbrowser cannot be started.")
self.latest_error = traceback.format_exception_only(type(e), e)[-1]
# if not driver:
# util.show_warning_box("Uma Launcher: Unable to start browser.", "Selected webbrowser cannot be started.")
return driver

def alive(self):
Expand Down Expand Up @@ -189,7 +245,7 @@ def wrapper(self, *args, **kwargs):
if self.driver:
return func(self, *args, **kwargs)

util.show_warning_box("Uma Launcher: Unable to reach browser.", "Webbrowser is unable to open.<br><br>If this problem persists, try restarting your computer<br>or selecting a different browser in the preferences.")
util.show_warning_box("Uma Launcher: Unable to reach browser.", f"Webbrowser is unable to open.<br><br>If this problem persists, try restarting your computer<br>or selecting a different browser in the preferences.<br><br>Extra info:<br>{self.latest_error}")
return wrapper

@ensure_focus
Expand Down
Loading

0 comments on commit 5b669e5

Please sign in to comment.