fix: new UI/UX
This commit is contained in:
parent
0c6491590e
commit
bc24525cec
@ -917,21 +917,29 @@ class SessionPresetServerAdd(bpy.types.Operator):
|
||||
def poll(cls, context):
|
||||
return True
|
||||
|
||||
def invoke(self, context, event):
|
||||
assert(context)
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
# TODO: menu pour rentrer le nom
|
||||
# TODO: override en label pour prévenir (icon) si jamais ce nom existe déjà
|
||||
|
||||
col = layout.column()
|
||||
settings = utils.get_preferences()
|
||||
col.prop(settings, "server_name", text="server name")
|
||||
|
||||
|
||||
def execute(self, context):
|
||||
assert(context)
|
||||
|
||||
settings = utils.get_preferences()
|
||||
|
||||
if settings.server_name in settings.server_preset.keys():
|
||||
|
||||
bpy.ops.session.preset_server_overwrite('INVOKE_DEFAULT')
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
new_server = settings.server_preset.add()
|
||||
|
||||
settings = utils.get_preferences()
|
||||
|
||||
existing_preset = settings.server_preset.get(settings.server_name)
|
||||
new_server = existing_preset if existing_preset else settings.server_preset.add()
|
||||
new_server.name = settings.server_name
|
||||
new_server.server_ip = settings.ip
|
||||
new_server.server_port = settings.port
|
||||
@ -941,6 +949,41 @@ class SessionPresetServerAdd(bpy.types.Operator):
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
# class SessionPresetServerOverwrite(bpy.types.Operator):
|
||||
# bl_idname = "session.preset_server_overwrite"
|
||||
# bl_description = "Overwrite the server preset that already has this name" # TODO : or increment the name
|
||||
# bl_label = "Overwrite server preset ?"
|
||||
# bl_options = {'REGISTER'}
|
||||
|
||||
# @classmethod
|
||||
# def poll(cls, context):
|
||||
# return True
|
||||
|
||||
# def execute(self, context):
|
||||
# assert(context)
|
||||
|
||||
# settings = utils.get_preferences()
|
||||
|
||||
# old_server = settings.server_preset.get(settings.server_name)
|
||||
|
||||
# old_server.server_ip = settings.ip
|
||||
# old_server.server_port = settings.port
|
||||
# old_server.server_password = settings.password
|
||||
|
||||
# settings.server_preset_interface = settings.server_name
|
||||
|
||||
# self.report({'INFO'}, "Server overwrite")
|
||||
|
||||
# return {'FINISHED'}
|
||||
|
||||
# def invoke(self, context, event):
|
||||
# assert(context)
|
||||
|
||||
# settings = utils.get_preferences()
|
||||
|
||||
# return context.window_manager.invoke_confirm(self, event)
|
||||
|
||||
class SessionPresetServerRemove(bpy.types.Operator):
|
||||
"""Remove a server to the server list preset"""
|
||||
bl_idname = "session.preset_server_remove"
|
||||
@ -960,43 +1003,6 @@ class SessionPresetServerRemove(bpy.types.Operator):
|
||||
settings.server_preset.remove(settings.server_preset.find(settings.server_preset_interface))
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class SessionPresetServerOverwrite(bpy.types.Operator):
|
||||
bl_idname = "session.preset_server_overwrite"
|
||||
bl_description = "Overwrite the server preset that already has this name" # TODO : or increment the name
|
||||
bl_label = "Overwrite server preset ?"
|
||||
bl_options = {'REGISTER'}
|
||||
|
||||
prop1: bpy.props.BoolProperty()
|
||||
prop2: bpy.props.BoolProperty()
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return True
|
||||
|
||||
def execute(self, context):
|
||||
assert(context)
|
||||
|
||||
settings = utils.get_preferences()
|
||||
|
||||
old_server = settings.server_preset.get(settings.server_name)
|
||||
|
||||
old_server.server_ip = settings.ip
|
||||
old_server.server_port = settings.port
|
||||
old_server.server_password = settings.password
|
||||
|
||||
settings.server_preset_interface = settings.server_name
|
||||
|
||||
self.report({'INFO'}, "Server overwrite")
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
assert(context)
|
||||
|
||||
settings = utils.get_preferences()
|
||||
|
||||
return context.window_manager.invoke_confirm(self, event)
|
||||
|
||||
|
||||
|
||||
@ -1024,7 +1030,7 @@ classes = (
|
||||
SessionPurgeOperator,
|
||||
SessionPresetServerAdd,
|
||||
SessionPresetServerRemove,
|
||||
SessionPresetServerOverwrite,
|
||||
# SessionPresetServerOverwrite,
|
||||
)
|
||||
|
||||
def update_external_dependencies():
|
||||
|
@ -33,6 +33,19 @@ from replication.interface import session
|
||||
IP_REGEX = re.compile("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
|
||||
HOSTNAME_REGEX = re.compile("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$")
|
||||
|
||||
DEFAULT_PRESETS = {
|
||||
"localhost" : {
|
||||
"server_ip": "localhost",
|
||||
"server_port": 5555,
|
||||
"server_password": "admin"
|
||||
},
|
||||
"public session" : {
|
||||
"server_ip": "51.75.71.183",
|
||||
"server_port": 5555,
|
||||
"server_password": "admin"
|
||||
},
|
||||
}
|
||||
|
||||
def randomColor():
|
||||
"""Generate a random color """
|
||||
r = random.random()
|
||||
@ -152,7 +165,7 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
||||
ip: bpy.props.StringProperty(
|
||||
name="ip",
|
||||
description='Distant host ip',
|
||||
default="127.0.0.1",
|
||||
default="localhost",
|
||||
update=update_ip)
|
||||
username: bpy.props.StringProperty(
|
||||
name="Username",
|
||||
@ -170,7 +183,7 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
||||
server_name: bpy.props.StringProperty(
|
||||
name="server_name",
|
||||
description="Custom name of the server",
|
||||
default='local host',
|
||||
default='localhost',
|
||||
)
|
||||
password: bpy.props.StringProperty(
|
||||
name="password",
|
||||
@ -458,21 +471,13 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
||||
new_db.bl_name = type_module_class.bl_id
|
||||
|
||||
# custom at launch server preset
|
||||
def generate_server_preset_localhost(self):
|
||||
new_server = self.server_preset.add()
|
||||
|
||||
new_server.name = "local host"
|
||||
new_server.server_ip = "127.0.0.1"
|
||||
new_server.server_port = 5555
|
||||
new_server.server_password = "admin"
|
||||
|
||||
def generate_server_preset_publicsession(self):
|
||||
new_server = self.server_preset.add()
|
||||
|
||||
new_server.name = "public session"
|
||||
new_server.server_ip = "51.75.71.183"
|
||||
new_server.server_port = 5555
|
||||
new_server.server_password = "admin"
|
||||
def generate_default_presets(self):
|
||||
for preset_name, preset_data in DEFAULT_PRESETS.items():
|
||||
new_server = self.server_preset.add()
|
||||
new_server.name = preset_name
|
||||
new_server.server_ip = preset_data.get('server_ip')
|
||||
new_server.server_port = preset_data.get('server_port')
|
||||
new_server.server_password = preset_data.get('server_password',None)
|
||||
|
||||
|
||||
def client_list_callback(scene, context):
|
||||
@ -588,11 +593,8 @@ def register():
|
||||
prefs.generate_supported_types()
|
||||
|
||||
# at launch server presets
|
||||
if 'local host' not in prefs.server_preset:
|
||||
prefs.generate_server_preset_localhost()
|
||||
prefs.generate_default_presets()
|
||||
|
||||
if 'public session' not in prefs.server_preset:
|
||||
prefs.generate_server_preset_publicsession()
|
||||
|
||||
|
||||
def unregister():
|
||||
|
@ -156,7 +156,13 @@ class SESSION_PT_settings_network(bpy.types.Panel):
|
||||
row = layout.row()
|
||||
row.prop(runtime_settings, "session_mode", expand=True)
|
||||
row = layout.row()
|
||||
|
||||
col = row.row(align=True)
|
||||
col.prop(settings, "server_preset_interface", text="")
|
||||
col.operator("session.preset_server_add", icon='ADD', text="")
|
||||
col.operator("session.preset_server_remove", icon='REMOVE', text="")
|
||||
|
||||
row = layout.row()
|
||||
box = row.box()
|
||||
|
||||
if runtime_settings.session_mode == 'HOST':
|
||||
@ -172,15 +178,6 @@ class SESSION_PT_settings_network(bpy.types.Panel):
|
||||
row = box.row()
|
||||
row.operator("session.start", text="HOST").host = True
|
||||
else:
|
||||
|
||||
row = box.row()
|
||||
row.prop(settings, "server_preset_interface", text="Preset")
|
||||
col = row.row(align=True)
|
||||
col.operator("session.preset_server_add", icon='ADD', text="")
|
||||
col.operator("session.preset_server_remove", icon='REMOVE', text="")
|
||||
|
||||
row = box.row()
|
||||
row.prop(settings, "server_name", text="name")
|
||||
row = box.row()
|
||||
row.prop(settings, "ip", text="IP")
|
||||
row = box.row()
|
||||
@ -208,7 +205,7 @@ class SESSION_PT_overwrite_server(bpy.types.Panel):
|
||||
|
||||
settings = get_preferences()
|
||||
|
||||
layout.operator(settings.SessionPresetServerOverwrite.bl_idname)
|
||||
# layout.operator(settings.SessionPresetServerOverwrite.bl_idname)
|
||||
|
||||
class SESSION_PT_settings_user(bpy.types.Panel):
|
||||
bl_idname = "MULTIUSER_SETTINGS_USER_PT_panel"
|
||||
|
Loading…
Reference in New Issue
Block a user