Skip to content

Commit

Permalink
new UIExtender replcaed with UIExtender.Create
Browse files Browse the repository at this point in the history
Added the ability to disable specific Prefabs and Mixins
Added the ability to deregister UIExtender
Added the ability to get another mods UIExtender
Updated PUML diagrams
  • Loading branch information
Aragas committed Jan 7, 2024
1 parent 9a9b2d1 commit 8e7791f
Show file tree
Hide file tree
Showing 109 changed files with 3,877 additions and 3,667 deletions.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--Development Variables-->
<PropertyGroup>
<!--Module Version-->
<Version>2.8.1</Version>
<Version>2.9.0</Version>
<!--Harmony Version-->
<HarmonyVersion>2.2.2</HarmonyVersion>
<HarmonyExtensionsVersion>3.2.0.77</HarmonyExtensionsVersion>
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---------------------------------------------------------------------------------------------------
Version: 2.9.0
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.1.6,v1.2.8
* Added the ability to disable specific Prefabs and Mixins, also to deregister a mods UIExtender
---------------------------------------------------------------------------------------------------
Version: 2.8.1
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.1.6,v1.2.8
* Added UpdateInfo
Expand Down
Binary file modified docs/articles/Interface/Overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions docs/articles/Interface/Overview.puml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
@startuml

SubModule --* UIExtender
SubModule --* ViewModelMixinClasses
SubModule --* PrefabExtensionClasses
!include ViewModelMixin.puml
!include Prefab.puml

class ViewModelMixinClasses {
[ViewModelMixin]
}
SubModule --* UIExtenderEx
UIExtenderEx --* UIExtenderExRuntime
UIExtenderExRuntime --* ViewModelComponent
UIExtenderExRuntime --* PrefabComponent

class PrefabExtensionClasses {
[PrefabExtension("Movie", "XPath")]
}
ViewModelComponent ..|> MyVMMixin : Uses
PrefabComponent ..|> MyPrefabComponent : Uses

ViewModelMixinClasses --|> BaseViewModelMixin
PrefabExtensionClasses --|> IPrefabExtension
class SubModule {
UIExtenderEx _uiExtenderEx = UIExtenderEx.Create("MyMod");
}

@enduml
Binary file added docs/articles/Interface/Prefab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions docs/articles/Interface/Prefab.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@startuml

MyPrefabComponent --* v2.PrefabExtensionInsertPatch
MyPrefabComponent --* v2.PrefabExtensionSetAttributePatch
MyPrefabComponent --* v1.CustomPatch
MyPrefabComponent --* v1.InsertPatch
MyPrefabComponent --* v1.PrefabExtensionInsertAsSiblingPatch
MyPrefabComponent --* v1.PrefabExtensionReplacePatch
MyPrefabComponent --* v1.PrefabExtensionSetAttributePatch
v1.CustomPatch --* v1.IPrefabPatch
v1.InsertPatch --* v1.IPrefabPatch
v1.PrefabExtensionInsertAsSiblingPatch --* v1.IPrefabPatch
v1.PrefabExtensionReplacePatch --* v1.IPrefabPatch
v1.PrefabExtensionSetAttributePatch --* v1.IPrefabPatch

class MyPrefabComponent {
[PrefabExtension("Movie", "XPath")]
}
abstract class v2.PrefabExtensionInsertPatch {
+ {abstract} InsertType Type
+ {abstract} int Index
}
abstract class v2.PrefabExtensionSetAttributePatch {
+ {abstract} List<Attribute> Attributes
}
abstract class v1.CustomPatch<T> {
+ {abstract} string Id
+ {abstract} void Apply(T obj)
}
abstract class v1.InsertPatch {
+ {abstract} string Id
+ {abstract} int Position
+ {abstract} XmlDocument GetPrefabExtension()
}
abstract class v1.PrefabExtensionInsertAsSiblingPatch {
+ {abstract} string Id
+ {abstract} InsertType Type
+ {abstract} XmlDocument GetPrefabExtension()
}
abstract class v1.PrefabExtensionReplacePatch {
+ {abstract} string Id
+ {abstract} XmlDocument GetPrefabExtension()
}
abstract class v1.PrefabExtensionSetAttributePatch {
+ {abstract} string Id
+ {abstract} string Attribute
+ {abstract} string Value
}
interface v1.IPrefabPatch {
+ string Id
}

@enduml
Binary file removed docs/articles/Interface/PrefabExtension.png
Binary file not shown.
33 changes: 0 additions & 33 deletions docs/articles/Interface/PrefabExtension.puml

This file was deleted.

Binary file modified docs/articles/Interface/ViewModelMixin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 19 additions & 6 deletions docs/articles/Interface/ViewModelMixin.puml
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
@startuml
class BaseViewModelMixin<T: ViewModel> {

}

interface IViewModelMixin {
MyVMMixin --* BaseViewModelMixin
BaseViewModelMixin --* IViewModel

class MyVMMixin {
[ViewModelMixin]
}
abstract class BaseViewModelMixin<TViewModel> {
# TViewModel? ViewModel
+ BaseViewModelMixin(TViewModel vm)
+ void OnRefresh()
+ void OnFinalize()
# void OnPropertyChanged(string? propertyName = null)
# void OnPropertyChangedWithValue(object value, string? propertyName = null)
# TValue? GetPrivate<TValue>(string name)
# void SetPrivate<TValue>(string name, TValue? value)
# bool SetField<T>(ref T field, T value, string propertyName)
}
interface IViewModel {
+ void OnRefresh()
+ void OnFinalize()
}

BaseViewModelMixin --|> IViewModelMixin

@enduml
Binary file removed docs/articles/Runtime/ExtendedVMRuntime.png
Binary file not shown.
45 changes: 0 additions & 45 deletions docs/articles/Runtime/ExtendedVMRuntime.puml

This file was deleted.

Binary file modified docs/articles/Runtime/Overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 16 additions & 33 deletions docs/articles/Runtime/Overview.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,37 @@ class UIExtender {

class UIExtenderRuntime {
+ ModuleName
- _userMessages
}

class PrefabComponent {
- _moduleName
- _moviePatches
- _enabledPatches
~ RegisterPatch()
~ Deregister()
~ Enable()
~ Disable()
~ ProcessMovieIfNeeded()
~ ForceReloadMovies()
}

class ViewModelComponent {
- _assemblyBuilder
- _mixins
- _mixinInstanceCache
- _moduleName
- _harmony
~ Mixins
~ MixinInstanceCache
~ MixinInstanceRefreshFromConstructorCache
- _mixinTypeEnabled
- _mixinTypePropertyCache
- _mixinTypeMethodCache
~ RegisterViewModelMixin()
~ ExtendsViewModelType()
~ ExtendedViewModelForType()
~ MixinInstanceForObject()
~ Deregister()
~ Enable()
~ Disable()
~ InitializeMixinsForVMInstance()
~ RefreshMixinsForVMInstance()
~ FinalizeMixinsForVMInstance()
~ DestructMixinsForVMInstance()
}

class CodePatcherComponent {
- _harmony
- _patchesAssemblyBuilder
- _transpilers
- _postfixes
~ AddViewModelInstantiationPatch()
~ AddViewModelRefreshPatch()
~ AddWidgetLoadPatch()
~ AddViewModelExecutePatch()
~ ApplyPatches()
}

class CodePatchesAssemblyBuilder {
- _assemblyBuilder
~ AddTranspiler()
~ AddPostfix()
~ SaveAndLoadLibraryType()
}

UIExtender --* UIExtenderRuntime
UIExtenderRuntime --* PrefabComponent
UIExtenderRuntime --* ViewModelComponent
UIExtenderRuntime --* CodePatcherComponent

CodePatcherComponent --* CodePatchesAssemblyBuilder

@enduml
Binary file modified docs/articles/Runtime/PrefabPatching.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 22 additions & 14 deletions docs/articles/Runtime/PrefabPatching.puml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
@startuml
loop for each Patch
CodePatcher -> Patch: apply with Harmony
alt widget load patch transpiler
Patch -> Patch: find marks of existing patch
alt existing patch found
Patch -> Patch: replace existing call with new DynamicMethod\nwhich calls both both previous and current `ProcessMovieDocumentIfNeeded`
else otherwise
Patch -> Patch: replace beginning of method with mark,\ncall to `LoadXmlDocument` and `ProcessMovieDocumentIfNeeded`
end
else otherwise
note over Patch
See `VMPatching` diagram.
endnote
end

actor Game

Game -> SubModule: OnBeforeInitialModuleScreenSetAsRoot()
SubModule -> UIExtender: Register()
UIExtender -> PrefabComponent: Register(Type[] prefabTypes)
PrefabComponent --> UIExtender
UIExtender --> SubModule
SubModule --> Game

...

Game -> WidgetPrefab: LoadFrom()
WidgetPrefab -> WidgetPrefabPatch: Harmony intercepts LoadFrom()
WidgetPrefabPatch -> PrefabComponent: ProcessMovieIfNeeded()
loop All registered Prefab
PrefabComponent -> Prefab: Apply XML transformation
Prefab --> PrefabComponent
end
PrefabComponent --> WidgetPrefabPatch
WidgetPrefabPatch --> WidgetPrefab
WidgetPrefab --> Game

@enduml
Binary file modified docs/articles/Runtime/Registration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 10 additions & 17 deletions docs/articles/Runtime/Registration.puml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@startuml

actor UserLibrary
actor Game

UserLibrary -> UIExtender: Register()
Game -> SubModule: OnBeforeInitialModuleScreenSetAsRoot()
SubModule -> UIExtender: Register()

UIExtender -> UIExtender: Find attributed types in calling assembly
UIExtender -> UIExtender: Find attributed types
UIExtender -> UIExtender: Create runtime for module and store it
UIExtender -> UIExtenderRuntime: Register()
loop for each type
Expand All @@ -13,28 +14,20 @@ loop for each type
PrefabComponent --> UIExtenderRuntime
PrefabComponent -> PrefabComponent: store extension for later
PrefabComponent --> UIExtenderRuntime
UIExtenderRuntime -> GauntletMoviePatch: Register(AutoGenName)
GauntletMoviePatch --> UIExtenderRuntime
else if view model extension
UIExtenderRuntime -> ViewModelComponent: RegisterViewModelMixin()
ViewModelComponent -> ViewModelComponent: store mixin for later
ViewModelComponent --> UIExtenderRuntime
end
end
UIExtenderRuntime -> UIExtenderRuntime: <b>Patching</b> (see separate diagram)
UIExtenderRuntime -> UIExtenderRuntime: <b>Patching</b> (see separate diagram)
note over UIExtenderRuntime
See `VMPatching` and `PrefabPatching` diagrams.
See `ViewModelPatching` and `PrefabPatching` diagrams.
endnote
UIExtenderRuntime --> UIExtender
UIExtender --> UserLibrary

...

UserLibrary -> UIExtender: Verify()
UIExtender -> UIExtenderRuntime: Verify()
alt any errors encountered during registration
UIExtenderRuntime -> UIExtenderRuntime: display errors to the user
end
UIExtenderRuntime --> UIExtender
UIExtender --> UserLibrary

UIExtender --> SubModule
SubModule --> Game

@enduml
Binary file removed docs/articles/Runtime/VMPatching.png
Binary file not shown.
Loading

0 comments on commit 8e7791f

Please sign in to comment.