Skip to content

Commit

Permalink
Allow parameters in room actions
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Dec 4, 2023
1 parent 5ca526a commit ad336b0
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions addons/io_hubs_addon/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ def execute(self, context):


def get_url_params(context):
params = "new"
params = ""
if context.scene.hubs_scene_debugger_room_create_prefs.new_loader:
params = f'{params}&newLoader'
params = f'{params}newLoader'
if context.scene.hubs_scene_debugger_room_create_prefs.ecs_debug:
params = f'{params}&ecsDebug'
if context.scene.hubs_scene_debugger_room_create_prefs.vr_entry_type:
Expand Down Expand Up @@ -179,16 +179,6 @@ def create_browser_instance(context):
options.binary_location = chrome_path
web_driver = webdriver.Chrome(options=options)

params = "new"
if context.scene.hubs_scene_debugger_room_create_prefs.new_loader:
params = f'{params}&newLoader'
if context.scene.hubs_scene_debugger_room_create_prefs.ecs_debug:
params = f'{params}&ecsDebug'
if context.scene.hubs_scene_debugger_room_create_prefs.vr_entry_type:
params = f'{params}&vr_entry_type=2d_now'
if context.scene.hubs_scene_debugger_room_create_prefs.debug_local_scene:
params = f'{params}&debugLocalScene'


class HubsCreateRoomOperator(bpy.types.Operator):
bl_idname = "hubs_scene.create_room"
Expand All @@ -207,7 +197,8 @@ def execute(self, context):
create_browser_instance(context)
prefs = get_addon_pref(context)
hubs_instance_url = prefs.hubs_instances[prefs.hubs_instance_idx].url
web_driver.get(f'{hubs_instance_url}?{get_url_params(context)}')
web_driver.get(
f'{hubs_instance_url}?new&{get_url_params(context)}')

return {'FINISHED'}

Expand Down Expand Up @@ -236,7 +227,15 @@ def execute(self, context):
if not isWebdriverAlive():
create_browser_instance(context)

web_driver.get(room_url)
params = get_url_params(context)
if params:
if "?" in room_url:
web_driver.get(f'{room_url}&{params}')
else:
web_driver.get(f'{room_url}?{params}')
else:
web_driver.get(room_url)

return {'FINISHED'}

except Exception as err:
Expand Down Expand Up @@ -309,19 +308,6 @@ def draw(self, context: Context):
col.operator(HubsSceneDebuggerInstanceRemove.bl_idname,
icon='REMOVE', text="")

box = self.layout.box()
row = box.row()
col = row.column(heading="Room flags:")
col.enabled = not isWebdriverAlive()
col.use_property_split = True
col.prop(context.scene.hubs_scene_debugger_room_create_prefs,
"new_loader")
col.prop(context.scene.hubs_scene_debugger_room_create_prefs,
"ecs_debug")
col.prop(context.scene.hubs_scene_debugger_room_create_prefs,
"vr_entry_type")
col.prop(context.scene.hubs_scene_debugger_room_create_prefs,
"debug_local_scene")
row = box.row()
col = row.column()
col.operator(HubsCreateRoomOperator.bl_idname,
Expand Down Expand Up @@ -450,6 +436,19 @@ def draw(self, context):
row.alignment = "CENTER"
row.label(text="Waiting for room...")

box = self.layout.box()
row = box.row()
col = row.column(heading="Room flags:")
col.use_property_split = True
col.prop(context.scene.hubs_scene_debugger_room_create_prefs,
"new_loader")
col.prop(context.scene.hubs_scene_debugger_room_create_prefs,
"ecs_debug")
col.prop(context.scene.hubs_scene_debugger_room_create_prefs,
"vr_entry_type")
col.prop(context.scene.hubs_scene_debugger_room_create_prefs,
"debug_local_scene")

else:
row = main_box.row()
row.alert = True
Expand Down Expand Up @@ -514,6 +513,7 @@ def execute(self, context):
if isWebdriverAlive():
if web_driver.current_url:
url = web_driver.current_url
url = url.split("?")[0]

new_room.name = "Room Name"
new_room.url = url
Expand Down

0 comments on commit ad336b0

Please sign in to comment.