allow extensions to sort themselves in UI

and other installed extensions will be on top now (including some resolution related UI extensions)
This commit is contained in:
lllyasviel 2024-02-17 08:15:29 -08:00
parent 07659efd88
commit ae51178629
10 changed files with 23 additions and 0 deletions

View File

@ -56,6 +56,8 @@ class ControlNetCachedParameters:
class ControlNetForForgeOfficial(scripts.Script): class ControlNetForForgeOfficial(scripts.Script):
sorting_priority = 10
def title(self): def title(self):
return "ControlNet" return "ControlNet"

View File

@ -7,6 +7,8 @@ opDynamicThresholdingNode = DynamicThresholdingNode().patch
class DynamicThresholdingForForge(scripts.Script): class DynamicThresholdingForForge(scripts.Script):
sorting_priority = 11
def title(self): def title(self):
return "DynamicThresholding (CFG-Fix) Integrated" return "DynamicThresholding (CFG-Fix) Integrated"

View File

@ -43,6 +43,8 @@ opFreeU_V2 = FreeU_V2()
class FreeUForForge(scripts.Script): class FreeUForForge(scripts.Script):
sorting_priority = 12
def title(self): def title(self):
return "FreeU Integrated" return "FreeU Integrated"

View File

@ -8,6 +8,8 @@ opHyperTile = HyperTile()
class HyperTileForForge(scripts.Script): class HyperTileForForge(scripts.Script):
sorting_priority = 13
def title(self): def title(self):
return "HyperTile Integrated" return "HyperTile Integrated"

View File

@ -8,6 +8,8 @@ opPatchModelAddDownscale = PatchModelAddDownscale()
class KohyaHRFixForForge(scripts.Script): class KohyaHRFixForForge(scripts.Script):
sorting_priority = 14
def title(self): def title(self):
return "Kohya HRFix Integrated" return "Kohya HRFix Integrated"

View File

@ -7,6 +7,8 @@ opModelSamplerLatentMegaModifier = ModelSamplerLatentMegaModifier().mega_modify
class LatentModifierForForge(scripts.Script): class LatentModifierForForge(scripts.Script):
sorting_priority = 15
def title(self): def title(self):
return "LatentModifier Integrated" return "LatentModifier Integrated"

View File

@ -8,6 +8,8 @@ opTiledDiffusion = TiledDiffusion().apply
class MultiDiffusionForForge(scripts.Script): class MultiDiffusionForForge(scripts.Script):
sorting_priority = 16
def title(self): def title(self):
return "MultiDiffusion Integrated" return "MultiDiffusion Integrated"

View File

@ -8,6 +8,8 @@ opSelfAttentionGuidance = SelfAttentionGuidance()
class SAGForForge(scripts.Script): class SAGForForge(scripts.Script):
sorting_priority = 12.5
def title(self): def title(self):
return "SelfAttentionGuidance Integrated" return "SelfAttentionGuidance Integrated"

View File

@ -10,6 +10,8 @@ def sdp(q, k, v, transformer_options):
class StyleAlignForForge(scripts.Script): class StyleAlignForForge(scripts.Script):
sorting_priority = 17
def title(self): def title(self):
return "StyleAlign Integrated" return "StyleAlign Integrated"

View File

@ -94,6 +94,9 @@ class Script:
controls = None controls = None
"""A list of controls retured by the ui().""" """A list of controls retured by the ui()."""
sorting_priority = 0
"""Larger number will appear downwards in the UI."""
def title(self): def title(self):
"""this function should return the title of the script. This is what will be displayed in the dropdown menu.""" """this function should return the title of the script. This is what will be displayed in the dropdown menu."""
@ -695,6 +698,8 @@ class ScriptRunner:
if scriptlist is None: if scriptlist is None:
scriptlist = self.alwayson_scripts scriptlist = self.alwayson_scripts
scriptlist = sorted(scriptlist, key=lambda x: x.sorting_priority)
for script in scriptlist: for script in scriptlist:
if script.alwayson and script.section != section: if script.alwayson and script.section != section:
continue continue