Elin Decompiled Documentation EA 23.362 Stable
Loading...
Searching...
No Matches
LayerMod Class Reference
Inheritance diagram for LayerMod:
ELayer Layer IUISkin

Classes

class  HoverRelay
 
class  PreviewEntry
 

Public Member Functions

void RefreshLists ()
 
override void OnInit ()
 
void Search (string s)
 
void ClearSearch ()
 
void Refresh ()
 
override void OnKill ()
 
- Public Member Functions inherited from ELayer
override void OnBeforeAddLayer ()
 
void InitInspector ()
 
sealed override void Init ()
 
override void OnAfterAddLayer ()
 
void TryShowHelp ()
 
void AddLayerToUI (string id)
 
void TryShowHint (string _langHint=null)
 
void TalkHomeMemeber (string id)
 
void TalkMaid (string id)
 
override void OnRightClick ()
 
- Public Member Functions inherited from Layer
virtual string GetTextHeader (Window window)
 
virtual bool HeaderIsListOf (int id)
 
virtual void Init ()
 
virtual void OnInit ()
 
virtual void OnAfterInit ()
 
virtual void ApplySkin ()
 
void ShowScreenLock (string id)
 
void UpdateInput ()
 
virtual void OnUpdateInput ()
 
virtual void OnRightClick ()
 
virtual bool OnBack ()
 
virtual void OnChangeLayer ()
 
virtual void OnCreate ()
 
void _AddLayer (string id)
 
Layer AddLayer (string id)
 
T AddLayer< T > ()
 
T AddLayer< T > (string id)
 
T AddLayerDontCloseOthers< T > ()
 
T AddLayerDontCloseOthers< T > (string path)
 
Layer AddLayerDontCloseOthers (Layer l)
 
T GetOrAddLayer< T > ()
 
virtual void OnBeforeAddLayer ()
 
virtual void OnAfterAddLayer ()
 
Layer AddLayer (Layer l)
 
void ToggleLayer (string id)
 
T ToggleLayer< T > (string id=null)
 
void WaitAndClose ()
 
void OnClickClose ()
 
virtual void Close ()
 
void CloseLayers ()
 
void RemoveLayers (bool removeImportant=false)
 
bool RemoveLayer< T > ()
 
void RemoveLayer (Layer l)
 
virtual void OnKill ()
 
Layer SetOnKill (Action action)
 
void DisableClose ()
 
void Delay (float duration=0.05f)
 
Layer SetDelay (float d)
 
Layer GetLayer (string id)
 
T GetLayer< T > (bool fromTop=false)
 
Layer GetTopLayer ()
 
void SwitchContent (int idWindow, int i)
 
virtual void OnSwitchContent (Window window)
 
Layer SetTitles (string langList, string idHeaderRow=null)
 
bool IsBlockWidgetClick ()
 
bool IsHideHud ()
 
bool IsAllowGeneralInput ()
 
bool IsUseBlur ()
 
bool IsPointerOnLayer ()
 
void ApplySkin ()
 

Public Attributes

UIList list
 
UIList list2
 
UIText textRestart
 
UIText textNoResult
 
UIButton toggleDisableMods
 
UIButton buttonClearSearch
 
InputField inputSearch
 
UIScrollView panelScroll
 
UIHeader panelHeader
 
UINote panelNote
 
UIItem infoTitle
 
UIItem infoPreview
 
UIItem infoPreviewNote
 
UIItem infoAuthor
 
UIItem infoVersion
 
UIItem infoId
 
UIItem infoWorkshop
 
UIItem infoStatus
 
UIItem infoProblems
 
UIItem infoTags
 
UIItem infoRequires
 
UIItem infoIncompatible
 
UIItem infoLoadAfter
 
UIItem infoLoadBefore
 
UIItem infoDescription
 
GameObject infoSpace
 
Sprite spriteNoPreview
 
- Public Attributes inherited from Layer
Option option
 
UnityEvent onKill
 
Anime animeIn
 
Anime animeOut
 
bool closeOthers
 
bool defaultActionMode = true
 
Button screenLock
 
Layer parent
 
string idLayer
 
List< Layer > layers = new List<Layer>()
 
Vector2 lastParentPos
 
List< Window > windows = new List<Window>()
 
string langHint
 

Static Public Attributes

static LayerMod Instance
 
- Static Public Attributes inherited from Layer
static int skipInput
 
static bool closeOnRightClick
 
static bool rightClicked
 
static bool cancelKeyDown
 
static bool ignoreSounds
 
static Transform blurStopInstance
 
static string[] searchPath = new string[3] { "Layer", "Layer/Dialog", "Layer/LayerHome" }
 

Properties

ModManager manager [get]
 
bool HasFilter [get]
 
- Properties inherited from ELayer
static Core core [get]
 
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static FactionBranch Branch [get]
 
static Faction Home [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static CoreConfig config [get]
 
static GameSetting setting [get]
 
static ColorProfile Colors [get]
 
static SourceManager sources [get]
 
static World world [get]
 
static SoundManager Sound [get]
 
static CoreDebug debug [get]
 
bool IsFloat [get]
 
virtual string IdHelp [get]
 
- Properties inherited from Layer
Layer TopLayer [get]
 
string uid [get]
 
virtual RectTransform rectLayers [get]
 
virtual bool blockWidgetClick [get]
 

Private Member Functions

void Move (object row, int a)
 
void MoveTo (object row, object target)
 
void OnReorder (bool restart=true)
 
void RefreshBottomButtons ()
 
IEnumerable< BaseModPackage > ToggleTargets ()
 
void ToggleAll ()
 
UIList.Callback< object, ItemMod > CreateCallbacks (UIList target, bool builtin)
 
void SetModRow (ModPackage a, ItemMod b)
 
List< BaseModPackage > Members (ModGroup g)
 
IEnumerable< ModGroup > Groups ()
 
void SetMembersActive (ModGroup g, bool active)
 
void LeaveGroup (BaseModPackage p)
 
int GetGroupIndex (BaseModPackage anchor, bool last)
 
void NewGroup ()
 
void SetGroupRow (ModGroup g, ItemMod b)
 
void AddGroupButtons (UIContextMenu m, BaseModPackage a)
 
void SetGroup (BaseModPackage p, ModGroup g)
 
void CollapseAll ()
 
void InputGroupName (string text, Action< string > onInput)
 
bool Match (BaseModPackage p)
 
void InitSearchUI ()
 
void ClearSearchText ()
 
void CycleFilter ()
 
void RefreshFilterButton ()
 
void LateUpdate ()
 
PreviewEntry GetThumb (BaseModPackage p)
 
BaseModPackage FirstInfoTarget ()
 
void ShowInfo (BaseModPackage p)
 
void ShowPreview (BaseModPackage a)
 
void ShowPresetMenu ()
 
void SavePreset ()
 
void WritePreset (string name)
 
void SelectPreset (Action< FileInfo > onSelect)
 
void ApplyPresetFile (FileInfo file)
 
void DeletePreset (FileInfo file)
 
void CopyPreset ()
 
void PastePreset ()
 
void ConfirmPreset (ModLoadOrderPreset.Preset preset)
 
void ApplyPreset (ModLoadOrderPreset.Preset preset)
 

Static Private Member Functions

static string FilterLabel (ModSearch.Filter f)
 
static Texture2D LoadPreviewTexture (BaseModPackage p, bool mipmap, out ModPreview.PreviewType kind, out bool owns)
 
static Texture2D SteamPreview (BaseModPackage p)
 
static string DescribeEntries (List< ModLoadOrderPreset.Entry > entries, int max)
 

Private Attributes

UIButton buttonFilter
 
UIButton buttonCollapse
 
UIButton buttonToggleAll
 
BaseModPackage panelTarget
 
float timerSearch
 
bool wasSearchFocused
 
string lastSearch = ""
 
string[] searchTerms = Array.Empty<string>()
 
ModSearch.Filter filterMode
 
readonly Dictionary< BaseModPackage, string > searchCache = new Dictionary<BaseModPackage, string>()
 
readonly Dictionary< BaseModPackage, PreviewEntry > previews = new Dictionary<BaseModPackage, PreviewEntry>()
 

Static Private Attributes

const string urlWorkshopItem = "https://steamcommunity.com/sharedfiles/filedetails/?id="
 

Additional Inherited Members

- Static Public Member Functions inherited from ELayer
static int rnd (int a)
 
- Static Public Member Functions inherited from Layer
static T Create< T > ()
 
static T Create< T > (string path)
 
static Layer Create (string path)
 
- Protected Member Functions inherited from ELayer
sealed override void _Close ()
 
sealed override void Kill ()
 
- Protected Member Functions inherited from Layer
virtual void Awake ()
 
virtual void _Close ()
 
virtual void Kill ()
 
- Protected Attributes inherited from Layer
RectTransform _rect
 
bool isDestroyed
 

Detailed Description

Definition at line 11 of file LayerMod.cs.

Member Function Documentation

◆ AddGroupButtons()

void LayerMod.AddGroupButtons ( UIContextMenu  m,
BaseModPackage  a 
)
inlineprivate

Definition at line 751 of file LayerMod.cs.

752 {
753 m.AddButton("mod_group_new", delegate
754 {
755 InputGroupName("mod_group_default_name".lang(), delegate(string name)
756 {
757 SetGroup(a, new ModGroup
758 {
759 name = name
760 });
761 });
762 });
763 List<ModGroup> groups = (from g in Groups()
764 where g != a.@group
765 select g).ToList();
766 if (groups.Count > 0)
767 {
768 m.AddButton("mod_group_move", delegate
769 {
770 SE.Click();
771 Dialog.List("mod_group_select", groups, (ModGroup g) => g.name, delegate(int i, string _)
772 {
773 SetGroup(a, groups[i]);
774 return true;
775 }, canCancel: true);
776 });
777 }
778 if (a.group != null)
779 {
780 m.AddButton("mod_group_remove", delegate
781 {
782 SetGroup(a, null);
783 });
784 }
785 }
if(!match.Success)
Definition: Dialog.cs:7
IEnumerable< ModGroup > Groups()
Definition: LayerMod.cs:609
void InputGroupName(string text, Action< string > onInput)
Definition: LayerMod.cs:842
void SetGroup(BaseModPackage p, ModGroup g)
Definition: LayerMod.cs:787
string name
Definition: ModGroup.cs:6
void AddButton(Func< string > funcText, UnityAction action=null)

References UIContextMenu.AddButton(), BaseModPackage.group, Groups(), InputGroupName(), ModGroup.name, and SetGroup().

Referenced by SetModRow().

◆ ApplyPreset()

void LayerMod.ApplyPreset ( ModLoadOrderPreset::Preset  preset)
inlineprivate

Definition at line 1344 of file LayerMod.cs.

1345 {
1346 if (HasFilter)
1347 {
1348 ClearSearch();
1349 }
1350 ModLoadOrderPreset.ApplyResult applyResult = manager.ApplyPreset(preset);
1351 SE.Tab();
1352 textRestart.SetActive(enable: true);
1353 RefreshLists();
1354 string text = ELayer.core.version.GetText();
1355 if (!preset.gameVersion.IsEmpty() && preset.gameVersion != text)
1356 {
1357 ELayer.ui.Say("mod_preset_version_warn".lang(preset.gameVersion, text));
1358 }
1359 ELayer.ui.Say("mod_preset_applied".lang(preset.name, applyResult.enabled.ToString() ?? "", applyResult.missing.Count.ToString() ?? ""));
1360 }
Version version
Definition: BaseCore.cs:17
Definition: ELayer.cs:4
static Core core
Definition: ELayer.cs:7
static UI ui
Definition: ELayer.cs:21
void RefreshLists()
Definition: LayerMod.cs:274
bool HasFilter
Definition: LayerMod.cs:115
ModManager manager
Definition: LayerMod.cs:112
UIText textRestart
Definition: LayerMod.cs:40
void ClearSearch()
Definition: LayerMod.cs:910
ModLoadOrderPreset.ApplyResult ApplyPreset(ModLoadOrderPreset.Preset preset, bool disableOthers=true)
Definition: ModManager.cs:338
string GetText()
Definition: Version.cs:34

References ModManager.ApplyPreset(), ClearSearch(), ELayer.core, Version.GetText(), HasFilter, manager, RefreshLists(), textRestart, ELayer.ui, and BaseCore.version.

Referenced by ConfirmPreset().

◆ ApplyPresetFile()

void LayerMod.ApplyPresetFile ( FileInfo  file)
inlineprivate

Definition at line 1262 of file LayerMod.cs.

1263 {
1264 if (!manager.TryLoadPresetFile(file, out var preset, out var _))
1265 {
1266 Dialog.Ok("mod_preset_invalid");
1267 }
1268 else
1269 {
1270 ConfirmPreset(preset);
1271 }
1272 }
static Dialog Ok(string langDetail, Action action=null)
Definition: Dialog.cs:230
void ConfirmPreset(ModLoadOrderPreset.Preset preset)
Definition: LayerMod.cs:1315
bool TryLoadPresetFile(FileInfo file, out ModLoadOrderPreset.Preset preset, out string error)
Definition: ModManager.cs:314

References ConfirmPreset(), manager, Dialog.Ok(), and ModManager.TryLoadPresetFile().

Referenced by ShowPresetMenu().

◆ ClearSearch()

void LayerMod.ClearSearch ( )
inline

Definition at line 910 of file LayerMod.cs.

911 {
912 if ((bool)inputSearch)
913 {
914 inputSearch.SetTextWithoutNotify("");
915 }
916 if ((bool)buttonClearSearch)
917 {
918 buttonClearSearch.SetActive(enable: false);
919 }
920 lastSearch = "";
921 timerSearch = 0f;
922 searchTerms = Array.Empty<string>();
923 filterMode = ModSearch.Filter.All;
925 RefreshLists();
926 }
string lastSearch
Definition: LayerMod.cs:102
UIButton buttonClearSearch
Definition: LayerMod.cs:46
string[] searchTerms
Definition: LayerMod.cs:104
void RefreshFilterButton()
Definition: LayerMod.cs:936
ModSearch.Filter filterMode
Definition: LayerMod.cs:106
InputField inputSearch
Definition: LayerMod.cs:48
float timerSearch
Definition: LayerMod.cs:98

References buttonClearSearch, filterMode, inputSearch, lastSearch, RefreshFilterButton(), RefreshLists(), searchTerms, and timerSearch.

Referenced by ApplyPreset(), NewGroup(), and SetGroup().

◆ ClearSearchText()

void LayerMod.ClearSearchText ( )
inlineprivate

Definition at line 900 of file LayerMod.cs.

901 {
902 SE.Click();
903 if ((bool)inputSearch)
904 {
905 inputSearch.SetTextWithoutNotify("");
906 }
907 Search("");
908 }

References inputSearch, and Search.

Referenced by InitSearchUI().

◆ CollapseAll()

void LayerMod.CollapseAll ( )
inlineprivate

Definition at line 826 of file LayerMod.cs.

827 {
828 List<ModGroup> list = Groups().ToList();
829 if (list.Count == 0)
830 {
831 SE.BeepSmall();
832 return;
833 }
834 bool collapsed = list.Any((ModGroup g) => !g.collapsed);
835 foreach (ModGroup item in list)
836 {
837 item.collapsed = collapsed;
838 }
839 OnReorder(restart: false);
840 }
UIList list
Definition: LayerMod.cs:36
void OnReorder(bool restart=true)
Definition: LayerMod.cs:262
bool collapsed
Definition: ModGroup.cs:8

References ModGroup.collapsed, Groups(), item, list, and OnReorder().

Referenced by OnInit().

◆ ConfirmPreset()

void LayerMod.ConfirmPreset ( ModLoadOrderPreset::Preset  preset)
inlineprivate

Definition at line 1315 of file LayerMod.cs.

1316 {
1317 List<ModLoadOrderPreset.Entry> list = ModLoadOrderPreset.FindMissing(manager.packages, preset);
1318 if (list.Count == 0)
1319 {
1320 ApplyPreset(preset);
1321 return;
1322 }
1323 Dialog.YesNo("mod_preset_missing".lang(DescribeEntries(list, 15)), delegate
1324 {
1325 ApplyPreset(preset);
1326 }, null, "mod_preset_apply", "cancel");
1327 }
static Dialog YesNo(string langDetail, Action actionYes, Action actionNo=null, string langYes="yes", string langNo="no")
Definition: Dialog.cs:252
void ApplyPreset(ModLoadOrderPreset.Preset preset)
Definition: LayerMod.cs:1344
static string DescribeEntries(List< ModLoadOrderPreset.Entry > entries, int max)
Definition: LayerMod.cs:1329

References ApplyPreset(), DescribeEntries(), list, manager, and Dialog.YesNo().

Referenced by ApplyPresetFile(), and PastePreset().

◆ CopyPreset()

void LayerMod.CopyPreset ( )
inlineprivate

Definition at line 1288 of file LayerMod.cs.

1289 {
1290 ModLoadOrderPreset.Preset preset = ModLoadOrderPreset.Save(manager.packages, "", ELayer.core.version.GetText());
1291 if (preset.entries.Count == 0)
1292 {
1293 SE.BeepSmall();
1294 return;
1295 }
1296 GUIUtility.systemCopyBuffer = ModLoadOrderPreset.Serialize(preset);
1297 SE.Click();
1298 ELayer.ui.Say("mod_preset_copied");
1299 }

References ELayer.core, Version.GetText(), manager, ELayer.ui, and BaseCore.version.

Referenced by ShowPresetMenu().

◆ CreateCallbacks()

UIList.Callback< object, ItemMod > LayerMod.CreateCallbacks ( UIList  target,
bool  builtin 
)
inlineprivate

Definition at line 370 of file LayerMod.cs.

371 {
372 return new UIList.Callback<object, ItemMod>
373 {
374 onClick = delegate
375 {
376 },
377 onInstantiate = delegate(object row, ItemMod b)
378 {
379 if (row is ModGroup g)
380 {
381 SetGroupRow(g, b);
382 }
383 else
384 {
385 SetModRow((ModPackage)row, b);
386 }
387 },
388 onList = delegate
389 {
390 ModGroup modGroup = null;
391 if (!builtin && !HasFilter)
392 {
393 foreach (ModGroup emptyGroup in manager.emptyGroups)
394 {
395 if (emptyGroup.after == null)
396 {
397 target.Add(emptyGroup);
398 }
399 }
400 }
401 foreach (BaseModPackage package in manager.packages)
402 {
403 if (package.builtin == builtin && (builtin || Match(package)))
404 {
405 if (!HasFilter && package.group != modGroup)
406 {
407 modGroup = package.group;
408 if (modGroup != null)
409 {
410 target.Add(modGroup);
411 }
412 }
413 if (HasFilter || modGroup == null || !modGroup.collapsed)
414 {
415 target.Add(package);
416 }
417 if (!HasFilter)
418 {
419 foreach (ModGroup emptyGroup2 in manager.emptyGroups)
420 {
421 if (emptyGroup2.after == package)
422 {
423 target.Add(emptyGroup2);
424 }
425 }
426 }
427 }
428 }
429 },
430 onRefresh = Refresh,
431 onDragReorder = delegate(object row, int a)
432 {
433 if (row is ModGroup g)
434 {
435 SetMembersActive(g, active: true);
436 }
437 if (a != 0)
438 {
439 List<object> items = target.items;
440 int num = items.IndexOf(row);
441 MoveTo(row, items[Mathf.Clamp(num + a, 0, items.Count - 1)]);
442 }
443 },
444 canDragReorder = (object row) => !(row is BaseModPackage baseModPackage) || !baseModPackage.builtin
445 };
446 }
void MoveTo(object row, object target)
Definition: LayerMod.cs:176
bool Match(BaseModPackage p)
Definition: LayerMod.cs:861
void SetModRow(ModPackage a, ItemMod b)
Definition: LayerMod.cs:448
void Refresh()
Definition: LayerMod.cs:1362
void SetGroupRow(ModGroup g, ItemMod b)
Definition: LayerMod.cs:671
void SetMembersActive(ModGroup g, bool active)
Definition: LayerMod.cs:617
BaseModPackage after
Definition: ModGroup.cs:12
readonly List< ModGroup > emptyGroups
Definition: ModManager.cs:47
Definition: UIList.cs:9
List< object > items
Definition: UIList.cs:273
override void Add(object item)
Definition: UIList.cs:357

References UIList.Add(), ModGroup.after, BaseModPackage.builtin, ModManager.emptyGroups, BaseModPackage.group, HasFilter, UIList.items, manager, Match(), MoveTo(), Refresh(), SetGroupRow(), SetMembersActive(), and SetModRow().

Referenced by OnInit().

◆ CycleFilter()

void LayerMod.CycleFilter ( )
inlineprivate

Definition at line 928 of file LayerMod.cs.

929 {
930 SE.Click();
931 filterMode = ModSearch.Filters[(int)(filterMode + 1) % ModSearch.Filters.Length];
933 RefreshLists();
934 }

References filterMode, RefreshFilterButton(), and RefreshLists().

Referenced by InitSearchUI().

◆ DeletePreset()

void LayerMod.DeletePreset ( FileInfo  file)
inlineprivate

Definition at line 1274 of file LayerMod.cs.

1275 {
1276 string name = Path.GetFileNameWithoutExtension(file.Name);
1277 Dialog.YesNo("mod_preset_delete_confirm".lang(name), delegate
1278 {
1279 if (file.Exists)
1280 {
1281 file.Delete();
1282 }
1283 SE.Trash();
1284 ELayer.ui.Say("mod_preset_deleted".lang(name));
1285 });
1286 }

References ELayer.ui, and Dialog.YesNo().

Referenced by ShowPresetMenu().

◆ DescribeEntries()

static string LayerMod.DescribeEntries ( List< ModLoadOrderPreset::Entry >  entries,
int  max 
)
inlinestaticprivate

Definition at line 1329 of file LayerMod.cs.

1330 {
1331 StringBuilder stringBuilder = new StringBuilder();
1332 for (int i = 0; i < entries.Count && i < max; i++)
1333 {
1334 ModLoadOrderPreset.Entry entry = entries[i];
1335 stringBuilder.Append(entry.title.IsEmpty() ? entry.id : (entry.title + " (" + entry.id + ")")).Append('\n');
1336 }
1337 if (entries.Count > max)
1338 {
1339 stringBuilder.Append("mod_preset_more".lang((entries.Count - max).ToString() ?? "")).Append('\n');
1340 }
1341 return stringBuilder.ToString().TrimEnd();
1342 }

Referenced by ConfirmPreset().

◆ FilterLabel()

static string LayerMod.FilterLabel ( ModSearch::Filter  f)
inlinestaticprivate

Definition at line 945 of file LayerMod.cs.

946 {
947 return f switch
948 {
949 ModSearch.Filter.Enabled => "mod_filter_enabled",
950 ModSearch.Filter.Disabled => "mod_filter_disabled",
951 ModSearch.Filter.Problems => "mod_filter_problem",
952 ModSearch.Filter.Local => "mod_filter_local",
953 ModSearch.Filter.Workshop => "mod_filter_workshop",
954 _ => "all",
955 };
956 }

Referenced by RefreshFilterButton().

◆ FirstInfoTarget()

BaseModPackage LayerMod.FirstInfoTarget ( )
inlineprivate

Definition at line 1042 of file LayerMod.cs.

1043 {
1044 return list.items.OfType<BaseModPackage>().FirstOrDefault() ?? manager.packages.FirstOrDefault();
1045 }

References UIList.items, list, and manager.

Referenced by OnInit().

◆ GetGroupIndex()

int LayerMod.GetGroupIndex ( BaseModPackage  anchor,
bool  last 
)
inlineprivate

Definition at line 639 of file LayerMod.cs.

640 {
641 List<BaseModPackage> l = manager.packages;
642 return manager.emptyGroups.Count((ModGroup e) => l.IndexOf(e.after) < l.IndexOf(anchor) || (last && e.after == anchor));
643 }

References ModGroup.after, ModManager.emptyGroups, and manager.

Referenced by LeaveGroup(), and MoveTo().

◆ GetThumb()

PreviewEntry LayerMod.GetThumb ( BaseModPackage  p)
inlineprivate

Definition at line 982 of file LayerMod.cs.

983 {
984 if (previews.TryGetValue(p, out var value))
985 {
986 return value;
987 }
988 value = new PreviewEntry();
989 bool owns;
990 Texture2D texture2D = LoadPreviewTexture(p, mipmap: true, out value.kind, out owns);
991 if ((bool)texture2D)
992 {
993 Texture2D texture2D2 = ModPreview.Downscale(texture2D, 280, owns);
994 value.sprite = texture2D2.ToSprite();
995 value.ownsTexture = owns || texture2D2 != texture2D;
996 }
997 previews[p] = value;
998 return value;
999 }
static Texture2D LoadPreviewTexture(BaseModPackage p, bool mipmap, out ModPreview.PreviewType kind, out bool owns)
Definition: LayerMod.cs:1001
readonly Dictionary< BaseModPackage, PreviewEntry > previews
Definition: LayerMod.cs:110

References LoadPreviewTexture(), and previews.

Referenced by ShowInfo().

◆ Groups()

IEnumerable< ModGroup > LayerMod.Groups ( )
inlineprivate

Definition at line 609 of file LayerMod.cs.

610 {
611 return (from p in manager.packages
612 select p.@group into g
613 where g != null
614 select g).Distinct().Concat(manager.emptyGroups);
615 }

References ModManager.emptyGroups, and manager.

Referenced by AddGroupButtons(), CollapseAll(), and RefreshBottomButtons().

◆ InitSearchUI()

void LayerMod.InitSearchUI ( )
inlineprivate

Definition at line 870 of file LayerMod.cs.

871 {
872 if ((bool)inputSearch)
873 {
874 inputSearch.SetTextWithoutNotify("");
875 if (inputSearch.placeholder is Text text)
876 {
877 text.text = "mod_search".lang();
878 }
879 inputSearch.onValueChanged.AddListener(Search);
880 inputSearch.onSubmit.AddListener(Search);
881 }
882 if ((bool)buttonClearSearch)
883 {
885 }
886 buttonFilter = windows[0].AddBottomButton("mod_filter", CycleFilter);
888 }
UIButton buttonFilter
Definition: LayerMod.cs:90
void ClearSearchText()
Definition: LayerMod.cs:900
void CycleFilter()
Definition: LayerMod.cs:928
List< Window > windows
Definition: Layer.cs:116

References buttonClearSearch, buttonFilter, ClearSearchText(), CycleFilter(), inputSearch, RefreshFilterButton(), Search, and Layer.windows.

Referenced by OnInit().

◆ InputGroupName()

void LayerMod.InputGroupName ( string  text,
Action< string >  onInput 
)
inlineprivate

Definition at line 842 of file LayerMod.cs.

843 {
844 Dialog.InputName("mod_group_name", text, delegate(bool cancel, string s)
845 {
846 if (!cancel)
847 {
848 string text2 = (s ?? "").Trim();
849 if (text2.IsEmpty())
850 {
851 SE.BeepSmall();
852 }
853 else
854 {
855 onInput(text2);
856 }
857 }
858 });
859 }
static Dialog InputName(string langDetail, string text, Action< bool, string > onClose, InputType inputType=InputType.Default)
Definition: Dialog.cs:536

References Dialog.InputName().

Referenced by AddGroupButtons(), NewGroup(), and SetGroupRow().

◆ LateUpdate()

void LayerMod.LateUpdate ( )
inlineprivate

Definition at line 958 of file LayerMod.cs.

959 {
960 if (timerSearch > 0f)
961 {
963 if (timerSearch <= 0f)
964 {
965 timerSearch = 0f;
966 searchTerms = ModSearch.Terms(lastSearch);
967 RefreshLists();
968 }
969 }
970 if ((bool)inputSearch)
971 {
972 bool isFocused = inputSearch.isFocused;
973 EventSystem current = EventSystem.current;
974 if (wasSearchFocused && !isFocused && (bool)current && current.currentSelectedGameObject == inputSearch.gameObject)
975 {
976 current.SetSelectedGameObject(null);
977 }
978 wasSearchFocused = isFocused;
979 }
980 }
Definition: Core.cs:14
static float delta
Definition: Core.cs:17
bool wasSearchFocused
Definition: LayerMod.cs:100

References Core.delta, inputSearch, lastSearch, RefreshLists(), searchTerms, timerSearch, and wasSearchFocused.

◆ LeaveGroup()

void LayerMod.LeaveGroup ( BaseModPackage  p)
inlineprivate

Definition at line 629 of file LayerMod.cs.

630 {
631 ModGroup g = p.group;
632 if (g != null && !manager.packages.Any((BaseModPackage m) => m != p && m.group == g))
633 {
634 manager.emptyGroups.Insert(GetGroupIndex(p, last: false), g);
635 g.after = manager.packages.TakeWhile((BaseModPackage m) => m != p).LastOrDefault((BaseModPackage m) => !m.builtin);
636 }
637 }
int GetGroupIndex(BaseModPackage anchor, bool last)
Definition: LayerMod.cs:639

References BaseModPackage.builtin, ModManager.emptyGroups, GetGroupIndex(), BaseModPackage.group, and manager.

Referenced by Move(), MoveTo(), and SetGroup().

◆ LoadPreviewTexture()

static Texture2D LayerMod.LoadPreviewTexture ( BaseModPackage  p,
bool  mipmap,
out ModPreview::PreviewType  kind,
out bool  owns 
)
inlinestaticprivate

Definition at line 1001 of file LayerMod.cs.

1002 {
1003 kind = ModPreview.PreviewType.None;
1004 owns = true;
1005 FileInfo fileInfo = ModPreview.FindPreviewFile(p);
1006 if (fileInfo != null)
1007 {
1008 try
1009 {
1010 Texture2D texture2D = ModPreview.LoadTexture(File.ReadAllBytes(fileInfo.FullName), out kind, mipmap);
1011 if ((bool)texture2D)
1012 {
1013 return texture2D;
1014 }
1015 }
1016 catch (Exception ex)
1017 {
1018 Debug.LogWarning("#mod preview " + fileInfo.FullName + ": " + ex.Message);
1019 }
1020 }
1021 Texture2D texture2D2 = SteamPreview(p);
1022 if ((bool)texture2D2)
1023 {
1024 owns = false;
1025 if (kind == ModPreview.PreviewType.None)
1026 {
1027 kind = ModPreview.PreviewType.Jpeg;
1028 }
1029 }
1030 return texture2D2;
1031 }
static Texture2D SteamPreview(BaseModPackage p)
Definition: LayerMod.cs:1033

References Debug, and SteamPreview().

Referenced by GetThumb(), and ShowPreview().

◆ Match()

bool LayerMod.Match ( BaseModPackage  p)
inlineprivate

Definition at line 861 of file LayerMod.cs.

862 {
863 if (!searchCache.TryGetValue(p, out var value))
864 {
865 value = (searchCache[p] = ModSearch.BuildText(p));
866 }
867 return ModSearch.Match(p, value, searchTerms, filterMode);
868 }
readonly Dictionary< BaseModPackage, string > searchCache
Definition: LayerMod.cs:108

References filterMode, searchCache, and searchTerms.

Referenced by CreateCallbacks().

◆ Members()

List< BaseModPackage > LayerMod.Members ( ModGroup  g)
inlineprivate

Definition at line 604 of file LayerMod.cs.

605 {
606 return manager.packages.Where((BaseModPackage p) => p.group == g).ToList();
607 }

References BaseModPackage.group, and manager.

Referenced by Move(), MoveTo(), SetGroupRow(), and SetMembersActive().

◆ Move()

void LayerMod.Move ( object  row,
int  a 
)
inlineprivate

Definition at line 126 of file LayerMod.cs.

127 {
128 List<object> items = list.items;
129 int num = items.IndexOf(row);
130 if (a > 0 && row is ModGroup { collapsed: false } modGroup)
131 {
132 a += Members(modGroup).Count;
133 }
134 if (num < 0 || num + a < 0 || num + a >= items.Count)
135 {
136 SE.BeepSmall();
137 return;
138 }
139 object obj = items[num + a];
140 ModGroup modGroup2;
141 bool num2;
142 if (!HasFilter && row is BaseModPackage baseModPackage)
143 {
144 modGroup2 = (obj as BaseModPackage)?.group;
145 if (a <= 0)
146 {
147 if (baseModPackage.group == null)
148 {
149 num2 = modGroup2 != null;
150 goto IL_00b8;
151 }
152 }
153 else if (baseModPackage.group != null)
154 {
155 num2 = modGroup2 != baseModPackage.group;
156 goto IL_00b8;
157 }
158 }
159 goto IL_00de;
160 IL_00b8:
161 if (num2)
162 {
163 if (a > 0)
164 {
165 LeaveGroup(baseModPackage);
166 }
167 baseModPackage.group = ((a > 0) ? null : modGroup2);
168 OnReorder();
169 return;
170 }
171 goto IL_00de;
172 IL_00de:
173 MoveTo(row, obj);
174 }
List< BaseModPackage > Members(ModGroup g)
Definition: LayerMod.cs:604
void LeaveGroup(BaseModPackage p)
Definition: LayerMod.cs:629

References HasFilter, UIList.items, LeaveGroup(), list, Members(), MoveTo(), and OnReorder().

Referenced by SetGroupRow(), and SetModRow().

◆ MoveTo()

void LayerMod.MoveTo ( object  row,
object  target 
)
inlineprivate

Definition at line 176 of file LayerMod.cs.

177 {
178 List<BaseModPackage> packages = manager.packages;
179 List<ModGroup> emptyGroups = manager.emptyGroups;
180 List<object> items = this.list.items;
181 ModGroup modGroup = row as ModGroup;
182 BaseModPackage baseModPackage = target as BaseModPackage;
183 ModGroup modGroup2 = (target as ModGroup) ?? ((modGroup == null) ? null : baseModPackage?.group);
184 if (target == null || target == row || (baseModPackage != null && baseModPackage.builtin) || (modGroup != null && modGroup == modGroup2))
185 {
186 SE.BeepSmall();
187 RefreshLists();
188 return;
189 }
190 bool flag = items.IndexOf(row) < items.IndexOf(target);
191 List<BaseModPackage> block = ((modGroup != null) ? Members(modGroup) : new List<BaseModPackage> { (BaseModPackage)row });
192 bool flag2 = emptyGroups.Contains(modGroup2);
193 if (block.Count == 0)
194 {
195 (BaseModPackage, int) tuple = (modGroup.after, emptyGroups.IndexOf(modGroup));
196 emptyGroups.Remove(modGroup);
197 if (flag2)
198 {
199 modGroup.after = modGroup2.after;
200 emptyGroups.Insert(emptyGroups.IndexOf(modGroup2) + (flag ? 1 : 0), modGroup);
201 }
202 else
203 {
204 List<BaseModPackage> list = ((modGroup2 != null) ? Members(modGroup2) : null);
205 BaseModPackage edge = ((list == null || list.Count <= 0) ? baseModPackage : (flag ? list[^1] : list[0]));
206 modGroup.after = (flag ? edge : packages.TakeWhile((BaseModPackage p) => p != edge).LastOrDefault((BaseModPackage p) => !p.builtin));
207 emptyGroups.Insert(GetGroupIndex(modGroup.after, !flag), modGroup);
208 }
209 BaseModPackage after = modGroup.after;
210 int num = emptyGroups.IndexOf(modGroup);
211 var (baseModPackage2, num2) = tuple;
212 if (after == baseModPackage2 && num == num2)
213 {
214 SE.BeepSmall();
215 RefreshLists();
216 }
217 else
218 {
219 OnReorder(restart: false);
220 }
221 return;
222 }
223 bool flag3 = modGroup == null && flag && (flag2 || (modGroup2 != null && !modGroup2.collapsed));
224 ModGroup modGroup3 = ((modGroup != null) ? block[0].group : ((modGroup2 == null) ? baseModPackage.group : (flag3 ? modGroup2 : null)));
225 if (modGroup == null && modGroup3 != block[0].group)
226 {
227 LeaveGroup(block[0]);
228 }
229 int num3 = packages.IndexOf(block[0]);
230 BaseModPackage after2 = packages.TakeWhile((BaseModPackage p) => p != block[0]).LastOrDefault((BaseModPackage p) => !p.builtin);
231 foreach (BaseModPackage item in block)
232 {
233 packages.Remove(item);
234 }
235 List<BaseModPackage> list2 = ((modGroup2 != null) ? Members(modGroup2) : null);
236 bool flag4 = flag && !flag3;
237 BaseModPackage baseModPackage3 = ((list2 == null) ? baseModPackage : ((list2.Count == 0) ? null : (flag4 ? list2[^1] : list2[0])));
238 int num4 = ((baseModPackage3 != null) ? (packages.IndexOf(baseModPackage3) + (flag4 ? 1 : 0)) : ((flag2 && !block.Contains(modGroup2.after)) ? ((modGroup2.after != null) ? (packages.IndexOf(modGroup2.after) + 1) : packages.Count((BaseModPackage p) => p.builtin)) : num3));
239 if (!flag2 && num4 == num3 && modGroup3 == block[0].group)
240 {
241 SE.BeepSmall();
242 RefreshLists();
243 return;
244 }
245 packages.InsertRange(num4, block);
246 BaseModPackage baseModPackage4 = (flag2 ? modGroup2.after : null);
247 foreach (ModGroup item2 in emptyGroups)
248 {
249 if (block.Contains(item2.after) && (num4 != num3 || (flag2 && flag && emptyGroups.IndexOf(item2) <= emptyGroups.IndexOf(modGroup2))))
250 {
251 item2.after = after2;
252 }
253 else if ((baseModPackage3 != null && flag4 && item2.after == baseModPackage3) || (flag2 && !flag && item2.after == baseModPackage4 && emptyGroups.IndexOf(item2) >= emptyGroups.IndexOf(modGroup2)))
254 {
255 item2.after = block[^1];
256 }
257 }
258 block[0].group = modGroup3;
259 OnReorder();
260 }
UIList list2
Definition: LayerMod.cs:38

References ModGroup.after, block, BaseModPackage.builtin, ModGroup.collapsed, ModManager.emptyGroups, GetGroupIndex(), BaseModPackage.group, item, UIList.items, LeaveGroup(), list, list2, manager, Members(), OnReorder(), and RefreshLists().

Referenced by CreateCallbacks(), and Move().

◆ NewGroup()

void LayerMod.NewGroup ( )
inlineprivate

Definition at line 645 of file LayerMod.cs.

646 {
648 {
649 SE.BeepSmall();
650 return;
651 }
652 SE.Click();
653 InputGroupName("mod_group_default_name".lang(), delegate(string name)
654 {
655 if (HasFilter)
656 {
657 ClearSearch();
658 }
660 {
661 name = name,
662 after = manager.packages.LastOrDefault((BaseModPackage p) => !p.builtin)
663 };
665 OnReorder(restart: false);
666 list.dragScrollView.content.RebuildLayout(recursive: true);
667 list.dragScrollView.verticalNormalizedPosition = 0f;
668 });
669 }
static bool disableMod
Definition: ModManager.cs:41
UIScrollView dragScrollView
Definition: UIList.cs:313

References BaseModPackage.builtin, ClearSearch(), ModManager.disableMod, UIList.dragScrollView, ModManager.emptyGroups, HasFilter, InputGroupName(), item, list, manager, and OnReorder().

Referenced by OnInit().

◆ OnInit()

override void LayerMod.OnInit ( )
inlinevirtual

Reimplemented from Layer.

Definition at line 330 of file LayerMod.cs.

331 {
332 textRestart.SetActive(enable: false);
334 {
335 ELayer.config.other.disableMods = on;
337 textRestart.SetActive(enable: true);
338 });
339 Instance = this;
340 foreach (BaseModPackage package in manager.packages)
341 {
342 package.UpdateMeta(updateOnly: true);
343 searchCache[package] = ModSearch.BuildText(package);
344 }
345 list.dragScrollView = list.GetComponentInParent<UIScrollView>();
346 list.dragViewport = windows[0].Rect();
347 list.onDragBegin = delegate(object row)
348 {
349 if (row is ModGroup g)
350 {
351 SetMembersActive(g, active: false);
352 }
353 };
354 list.callbacks = CreateCallbacks(list, builtin: false);
355 list2.callbacks = CreateCallbacks(list2, builtin: true);
356 InitSearchUI();
357 buttonToggleAll = windows[0].AddBottomButton("mod_uncheck_all", ToggleAll);
358 windows[0].AddBottomButton("mod_preset", ShowPresetMenu);
359 windows[0].AddBottomButton("mod_group_new", NewGroup);
360 buttonCollapse = windows[0].AddBottomButton("mod_group_collapse_all", CollapseAll);
361 infoPreview.button1.SetOnClick(delegate
362 {
364 });
365 RefreshLists();
367 list.dragEdgeSize = list.callbacks.GetMold()?.Rect().sizeDelta.y ?? 34f;
368 }
UIList.ICallback callbacks
Definition: BaseList.cs:13
void UpdateMeta(bool updateOnly=false)
void Save()
Definition: CoreConfig.cs:852
OtherSetting other
Definition: CoreConfig.cs:639
static CoreConfig config
Definition: ELayer.cs:31
void ShowInfo(BaseModPackage p)
Definition: LayerMod.cs:1047
UIItem infoPreview
Definition: LayerMod.cs:58
void ShowPresetMenu()
Definition: LayerMod.cs:1182
void NewGroup()
Definition: LayerMod.cs:645
UIButton toggleDisableMods
Definition: LayerMod.cs:44
BaseModPackage panelTarget
Definition: LayerMod.cs:96
void ShowPreview(BaseModPackage a)
Definition: LayerMod.cs:1157
void CollapseAll()
Definition: LayerMod.cs:826
UIList.Callback< object, ItemMod > CreateCallbacks(UIList target, bool builtin)
Definition: LayerMod.cs:370
void ToggleAll()
Definition: LayerMod.cs:304
void InitSearchUI()
Definition: LayerMod.cs:870
UIButton buttonCollapse
Definition: LayerMod.cs:92
UIButton buttonToggleAll
Definition: LayerMod.cs:94
BaseModPackage FirstInfoTarget()
Definition: LayerMod.cs:1042
static LayerMod Instance
Definition: LayerMod.cs:34
void SetToggle(bool isOn, Action< bool > onToggle=null)
Definition: UIButton.cs:341
UIButton button1
Definition: UIItem.cs:18

References UIItem.button1, buttonCollapse, buttonToggleAll, BaseList.callbacks, CollapseAll(), ELayer.config, CreateCallbacks(), CoreConfig.OtherSetting.disableMods, FirstInfoTarget(), infoPreview, InitSearchUI(), Instance, list, list2, manager, NewGroup(), CoreConfig.other, panelTarget, RefreshLists(), CoreConfig.Save(), searchCache, SetMembersActive(), UIButton.SetToggle(), ShowInfo(), ShowPresetMenu(), ShowPreview(), textRestart, ToggleAll(), toggleDisableMods, BaseModPackage.UpdateMeta(), and Layer.windows.

◆ OnKill()

override void LayerMod.OnKill ( )
inlinevirtual

Reimplemented from Layer.

Definition at line 1366 of file LayerMod.cs.

1367 {
1368 if ((bool)TooltipManager.Instance)
1369 {
1370 TooltipManager.Instance.HideTooltips(immediate: true);
1371 }
1372 foreach (PreviewEntry value in previews.Values)
1373 {
1374 if ((bool)value.sprite)
1375 {
1376 if (value.ownsTexture)
1377 {
1378 UnityEngine.Object.Destroy(value.sprite.texture);
1379 }
1380 UnityEngine.Object.Destroy(value.sprite);
1381 }
1382 }
1383 previews.Clear();
1385 if (Instance == this)
1386 {
1387 Instance = null;
1388 }
1389 }
ModManager mods
Definition: Core.cs:39
void SaveLoadOrder()
Definition: ModManager.cs:106
static TooltipManager Instance
void HideTooltips(bool immediate=false)

References ELayer.core, TooltipManager.HideTooltips(), Instance, TooltipManager.Instance, Core.mods, LayerMod.PreviewEntry.ownsTexture, previews, ModManager.SaveLoadOrder(), and LayerMod.PreviewEntry.sprite.

◆ OnReorder()

void LayerMod.OnReorder ( bool  restart = true)
inlineprivate

Definition at line 262 of file LayerMod.cs.

263 {
264 SE.Tab();
265 if (restart)
266 {
267 textRestart.SetActive(enable: true);
268 }
269 manager.emptyGroups.RemoveAll((ModGroup g) => manager.packages.Any((BaseModPackage p) => p.group == g));
271 RefreshLists();
272 }

References ELayer.core, ModManager.emptyGroups, BaseModPackage.group, manager, Core.mods, RefreshLists(), ModManager.SaveLoadOrder(), and textRestart.

Referenced by CollapseAll(), Move(), MoveTo(), NewGroup(), SetGroup(), SetGroupRow(), and ToggleAll().

◆ PastePreset()

void LayerMod.PastePreset ( )
inlineprivate

Definition at line 1301 of file LayerMod.cs.

1302 {
1303 if (!ModLoadOrderPreset.TryParse(GUIUtility.systemCopyBuffer, out var preset, out var _))
1304 {
1305 Dialog.Ok("mod_preset_invalid");
1306 return;
1307 }
1308 if (preset.name.IsEmpty())
1309 {
1310 preset.name = "mod_preset_default_name".lang();
1311 }
1312 ConfirmPreset(preset);
1313 }

References ConfirmPreset(), and Dialog.Ok().

Referenced by ShowPresetMenu().

◆ Refresh()

void LayerMod.Refresh ( )
inline

Definition at line 1362 of file LayerMod.cs.

1363 {
1364 }

Referenced by CreateCallbacks(), and SetModRow().

◆ RefreshBottomButtons()

void LayerMod.RefreshBottomButtons ( )
inlineprivate

Definition at line 285 of file LayerMod.cs.

286 {
287 if ((bool)buttonCollapse)
288 {
289 buttonCollapse.mainText.text = (Groups().Any((ModGroup g) => !g.collapsed) ? "mod_group_collapse_all" : "mod_group_expand_all").lang();
290 buttonToggleAll.mainText.text = (ToggleTargets().Any((BaseModPackage p) => p.willActivate) ? "mod_uncheck_all" : "mod_check_all").lang();
291 windows[0].rectBottom.RebuildLayout(recursive: true);
292 }
293 }
IEnumerable< BaseModPackage > ToggleTargets()
Definition: LayerMod.cs:295

References buttonCollapse, ModGroup.collapsed, Groups(), ToggleTargets(), BaseModPackage.willActivate, and Layer.windows.

Referenced by RefreshLists(), and SetModRow().

◆ RefreshFilterButton()

void LayerMod.RefreshFilterButton ( )
inlineprivate

Definition at line 936 of file LayerMod.cs.

937 {
938 if ((bool)buttonFilter)
939 {
940 buttonFilter.mainText.text = "mod_filter".lang() + ": " + FilterLabel(filterMode).lang();
941 windows[0].rectBottom.RebuildLayout(recursive: true);
942 }
943 }
static string FilterLabel(ModSearch.Filter f)
Definition: LayerMod.cs:945

References buttonFilter, FilterLabel(), filterMode, and Layer.windows.

Referenced by ClearSearch(), CycleFilter(), and InitSearchUI().

◆ RefreshLists()

void LayerMod.RefreshLists ( )
inline

Definition at line 274 of file LayerMod.cs.

275 {
276 list.List();
277 list2.List();
278 if ((bool)textNoResult)
279 {
280 textNoResult.SetActive(HasFilter && list.items.Count == 0);
281 }
283 }
void RefreshBottomButtons()
Definition: LayerMod.cs:285
UIText textNoResult
Definition: LayerMod.cs:42
override void List()
Definition: UIList.cs:773

References HasFilter, UIList.items, list, UIList.List(), list2, RefreshBottomButtons(), and textNoResult.

Referenced by ApplyPreset(), ClearSearch(), CycleFilter(), LateUpdate(), MoveTo(), OnInit(), OnReorder(), and SetModRow().

◆ SavePreset()

void LayerMod.SavePreset ( )
inlineprivate

Definition at line 1210 of file LayerMod.cs.

1211 {
1212 Dialog.InputName("mod_preset_name", "mod_preset_default_name".lang(), delegate(bool cancel, string text)
1213 {
1214 if (!cancel)
1215 {
1216 string name = (text ?? "").Trim().SanitizeFileName().Trim();
1217 if (name.IsEmpty())
1218 {
1219 SE.BeepSmall();
1220 }
1221 else if (File.Exists(ModManager.GetPresetPath(name)))
1222 {
1223 Dialog.YesNo("mod_preset_overwrite".lang(name), delegate
1224 {
1225 WritePreset(name);
1226 });
1227 }
1228 else
1229 {
1230 WritePreset(name);
1231 }
1232 }
1233 });
1234 }
void WritePreset(string name)
Definition: LayerMod.cs:1236
static string GetPresetPath(string name)
Definition: ModManager.cs:287

References ModManager.GetPresetPath(), Dialog.InputName(), WritePreset(), and Dialog.YesNo().

Referenced by ShowPresetMenu().

◆ Search()

void LayerMod.Search ( string  s)
inline

Definition at line 890 of file LayerMod.cs.

891 {
892 lastSearch = s ?? "";
893 timerSearch = 0.15f;
894 if ((bool)buttonClearSearch)
895 {
896 buttonClearSearch.SetActive(!lastSearch.IsEmpty());
897 }
898 }

References buttonClearSearch, lastSearch, and timerSearch.

◆ SelectPreset()

void LayerMod.SelectPreset ( Action< FileInfo >  onSelect)
inlineprivate

Definition at line 1247 of file LayerMod.cs.

1248 {
1249 List<FileInfo> files = manager.ListPresets();
1250 if (files.Count == 0)
1251 {
1252 Dialog.Ok("mod_preset_none");
1253 return;
1254 }
1255 Dialog.List("mod_preset_select", files, (FileInfo f) => Path.GetFileNameWithoutExtension(f.Name), delegate(int i, string _)
1256 {
1257 onSelect(files[i]);
1258 return true;
1259 }, canCancel: true);
1260 }
List< FileInfo > ListPresets()
Definition: ModManager.cs:292

References ModManager.ListPresets(), manager, and Dialog.Ok().

Referenced by ShowPresetMenu().

◆ SetGroup()

void LayerMod.SetGroup ( BaseModPackage  p,
ModGroup  g 
)
inlineprivate

Definition at line 787 of file LayerMod.cs.

788 {
789 if (HasFilter)
790 {
791 ClearSearch();
792 }
793 List<BaseModPackage> packages = manager.packages;
794 List<ModGroup> emptyGroups = manager.emptyGroups;
795 ModGroup host = ((g != null && packages.Any((BaseModPackage m) => m.group == g)) ? g : p.group);
796 BaseModPackage baseModPackage = ((host == null) ? null : packages.LastOrDefault((BaseModPackage m) => m != p && m.group == host));
797 if (g != p.group)
798 {
799 LeaveGroup(p);
800 }
801 int num = packages.IndexOf(p);
802 BaseModPackage after = packages.TakeWhile((BaseModPackage m) => m != p).LastOrDefault((BaseModPackage m) => !m.builtin);
803 packages.Remove(p);
804 int num2 = ((!emptyGroups.Contains(g)) ? ((baseModPackage != null) ? (packages.IndexOf(baseModPackage) + 1) : num) : ((g.after == p) ? num : ((g.after != null) ? (packages.IndexOf(g.after) + 1) : packages.Count((BaseModPackage m) => m.builtin))));
805 packages.Insert(num2, p);
806 BaseModPackage baseModPackage2 = (emptyGroups.Contains(g) ? g.after : null);
807 foreach (ModGroup item in emptyGroups)
808 {
809 if (item.after == p && num2 != num)
810 {
811 item.after = after;
812 }
813 else if (emptyGroups.Contains(g) && item.after == baseModPackage2 && emptyGroups.IndexOf(item) >= emptyGroups.IndexOf(g))
814 {
815 item.after = p;
816 }
817 }
818 p.group = g;
819 if (g != null)
820 {
821 g.collapsed = false;
822 }
823 OnReorder();
824 }

References ModGroup.after, BaseModPackage.builtin, ClearSearch(), ModManager.emptyGroups, BaseModPackage.group, HasFilter, item, LeaveGroup(), manager, and OnReorder().

Referenced by AddGroupButtons().

◆ SetGroupRow()

void LayerMod.SetGroupRow ( ModGroup  g,
ItemMod  b 
)
inlineprivate

Definition at line 671 of file LayerMod.cs.

672 {
673 List<BaseModPackage> members = Members(g);
674 int on = members.Count((BaseModPackage p) => p.willActivate);
675 string s = ((members.Count == 0) ? "" : (g.collapsed ? "[+] " : "[-] ")) + g.name;
676 UIText mainText = b.buttonActivate.mainText;
677 mainText.fontStyle = FontStyle.Bold;
678 mainText.SetText(mainText.Fit(s, (members.Count > 0) ? (" (" + on + "/" + members.Count + ")") : ""), FontColor.Topic);
679 Color topic = mainText.color;
680 Color? color = g.color;
681 if (color.HasValue)
682 {
683 Color valueOrDefault = color.GetValueOrDefault();
684 mainText.SetText(mainText.text, valueOrDefault.Multiply(0.45f, 0f));
685 }
686 b.imageGroup.SetActive(enable: true);
687 b.imageGroup.color = (g.color ?? topic).SetAlpha(0.4f);
688 b.buttonActivate.subText.text = "";
689 b.buttonLock.mainText.text = "";
690 b.buttonUp.SetOnClick(delegate
691 {
692 Move(g, -1);
693 });
694 b.buttonDown.SetOnClick(delegate
695 {
696 Move(g, 1);
697 });
698 b.buttonToggle.SetToggle(on > 0 && on == members.Count);
699 b.buttonToggle.interactable = members.Count > 0;
700 b.buttonToggle.SetOnClick(delegate
701 {
702 foreach (BaseModPackage item in members)
703 {
704 item.willActivate = on != members.Count;
705 }
706 OnReorder();
707 });
708 b.buttonActivate.SetOnClick(delegate
709 {
710 g.collapsed = !g.collapsed;
711 OnReorder(restart: false);
712 });
713 b.buttonRename.SetActive(enable: true);
714 b.buttonRename.SetOnClick(delegate
715 {
716 InputGroupName(g.name, delegate(string name)
717 {
718 g.name = name;
719 OnReorder(restart: false);
720 });
721 });
722 b.buttonColor.SetActive(enable: true);
723 b.buttonColor.SetOnClick(delegate
724 {
725 ELayer.ui.AddLayer<LayerColorPicker>().SetColor(g.color ?? topic, topic, delegate(PickerState state, Color c)
726 {
727 c.a = topic.a;
728 g.color = ((c == topic) ? ((Color?)null) : new Color?(c));
729 if (state == PickerState.Confirm)
730 {
731 OnReorder(restart: false);
732 }
733 else
734 {
735 SetGroupRow(g, b);
736 }
737 });
738 });
739 b.buttonDisband.SetActive(enable: true);
740 b.buttonDisband.SetOnClick(delegate
741 {
742 foreach (BaseModPackage item2 in members)
743 {
744 item2.group = null;
745 }
746 manager.emptyGroups.Remove(g);
747 OnReorder(restart: false);
748 });
749 }
FontColor
Definition: FontColor.cs:2
PickerState
Definition: PickerState.cs:2
UIButton buttonColor
Definition: ItemMod.cs:21
UIButton buttonRename
Definition: ItemMod.cs:17
UIButton buttonActivate
Definition: ItemMod.cs:5
Image imageGroup
Definition: ItemMod.cs:29
UIButton buttonUp
Definition: ItemMod.cs:11
UIButton buttonToggle
Definition: ItemMod.cs:15
UIButton buttonDown
Definition: ItemMod.cs:13
UIButton buttonDisband
Definition: ItemMod.cs:19
void Move(object row, int a)
Definition: LayerMod.cs:126
Color? color
Definition: ModGroup.cs:10
UIText mainText
Definition: UIButton.cs:102
Definition: UIText.cs:6
void SetText(string s)
Definition: UIText.cs:163

References ItemMod.buttonActivate, ItemMod.buttonColor, ItemMod.buttonDisband, ItemMod.buttonDown, ItemMod.buttonRename, ItemMod.buttonToggle, ItemMod.buttonUp, ModGroup.collapsed, Color, ModGroup.color, ModManager.emptyGroups, ItemMod.imageGroup, InputGroupName(), item, UIButton.mainText, manager, Members(), Move(), ModGroup.name, OnReorder(), SetGroupRow(), UIText.SetText(), UIButton.SetToggle(), ELayer.ui, and BaseModPackage.willActivate.

Referenced by CreateCallbacks(), and SetGroupRow().

◆ SetMembersActive()

void LayerMod.SetMembersActive ( ModGroup  g,
bool  active 
)
inlineprivate

Definition at line 617 of file LayerMod.cs.

618 {
619 if (g.collapsed)
620 {
621 return;
622 }
623 foreach (BaseModPackage item in Members(g))
624 {
625 list.GetPair(item).component.SetActive(active);
626 }
627 }
ButtonPair GetPair(object item)
Definition: UIList.cs:370
Component component
Definition: UIList.cs:216

References ModGroup.collapsed, UIList.ButtonPair.component, UIList.GetPair(), item, list, and Members().

Referenced by CreateCallbacks(), and OnInit().

◆ SetModRow()

void LayerMod.SetModRow ( ModPackage  a,
ItemMod  b 
)
inlineprivate

Definition at line 448 of file LayerMod.cs.

449 {
450 b.package = a;
451 string s = ((a.group != null && !HasFilter) ? " " : "") + (ELayer.core.mods.packages.IndexOf(a) + 1) + ". " + (a.isInPackages ? "[Local] " : "") + a.title.IsEmpty(a.dirInfo.Name);
452 b.buttonActivate.mainText.SetText(b.buttonActivate.mainText.Fit(s), (!a.IsValidVersion() || a.blockedBy != null || !a.langDepError.IsEmpty()) ? FontColor.Bad : (a.activated ? FontColor.ButtonGeneral : FontColor.Passive));
453 b.buttonActivate.subText.text = a.version;
454 b.buttonLock.mainText.text = a.author;
455 ItemMod itemMod = ((a.group != null && !HasFilter) ? list.GetPair<ItemMod>(a.group) : null);
456 b.imageMember.SetActive(itemMod);
457 if ((bool)itemMod)
458 {
459 b.imageMember.color = itemMod.buttonActivate.mainText.color;
460 }
461 b.buttonUp.SetActive(!a.builtin);
462 b.buttonDown.SetActive(!a.builtin);
463 b.buttonConfig.SetActive(a.onBuildConfig != null);
464 b.buttonConfig.SetOnClick(delegate
465 {
467 });
468 b.buttonToggle.SetToggle(a.willActivate);
469 b.buttonUp.SetOnClick(delegate
470 {
471 Move(a, -1);
472 });
473 b.buttonDown.SetOnClick(delegate
474 {
475 Move(a, 1);
476 });
477 b.buttonActivate.GetOrCreate<HoverRelay>().onEnter = delegate
478 {
479 ShowInfo(a);
480 };
481 UIButton bt = b.buttonToggle;
482 bt.SetOnClick(delegate
483 {
484 a.willActivate = !a.willActivate;
485 bt.SetCheck(a.willActivate);
487 textRestart.SetActive(enable: true);
488 if (a.group != null && !HasFilter)
489 {
490 SetGroupRow(a.group, list.GetPair<ItemMod>(a.group));
491 }
493 });
494 bt.interactable = !a.builtin;
495 b.buttonActivate.onClick.AddListener(delegate
496 {
497 Refresh();
498 UIContextMenu uIContextMenu = ELayer.ui.CreateContextMenuInteraction().SetHighlightTarget(b.buttonActivate);
499 if (!a.builtin)
500 {
501 if (ELayer.debug.enable || (!BaseCore.IsOffline && a.isInPackages && !ELayer.core.version.demo))
502 {
503 uIContextMenu.AddButton("mod_publish", delegate
504 {
505 Core.TryWarnUpload(delegate
506 {
507 Dialog.YesNo("mod_publish_warn".lang(a.title, a.id, a.author), delegate
508 {
509 ELayer.core.steam.CreateUserContent(a);
510 });
511 });
512 });
513 }
514 uIContextMenu.AddButton(a.willActivate ? "mod_deactivate" : "mod_activate", delegate
515 {
516 SE.Click();
517 a.willActivate = !a.willActivate;
518 ELayer.core.mods.SaveLoadOrder();
519 RefreshLists();
520 textRestart.SetActive(enable: true);
521 });
522 if (!a.isInPackages && !a.workshopId.IsEmpty())
523 {
524 uIContextMenu.AddButton("mod_convert_local", delegate
525 {
526 SE.Click();
527 string path = ("Mod_" + a.workshopId + "_" + a.id).SanitizeDirectoryName();
528 string text = Path.Combine(BaseModManager.rootMod, path);
529 a.CopyContentTo(text);
530 ModPackage modPackage = manager.AddPackage(new DirectoryInfo(text), isInPackages: true);
531 modPackage.UpdateMeta(updateOnly: true);
532 searchCache[modPackage] = ModSearch.BuildText(modPackage);
533 manager.packages.Move(modPackage, manager.packages.IndexOf(a) - manager.packages.Count + 2);
534 modPackage.group = a.group;
535 modPackage.willActivate = false;
536 modPackage.activated = false;
538 RefreshLists();
539 textRestart.SetActive(enable: true);
540 });
541 }
542 if (a.isInPackages && a.IsSourceLocalizable)
543 {
544 uIContextMenu.AddButton("mod_export_text", delegate
545 {
546 SE.Click();
547 string text = a.UpdateSourceLocalizationFile(Lang.langCode, force: true);
548 ELayer.ui.Say(text);
549 });
550 }
551 AddGroupButtons(uIContextMenu, a);
552 }
553 if (a.onBuildConfig != null)
554 {
555 uIContextMenu.AddButton("config", delegate
556 {
557 SE.Click();
559 });
560 }
561 if (ModPreview.FindPreviewFile(a) != null || (bool)SteamPreview(a))
562 {
563 uIContextMenu.AddButton("mod_preview", delegate
564 {
565 ShowPreview(a);
566 });
567 }
568 if (!a.workshopId.IsEmpty())
569 {
570 uIContextMenu.AddButton("mod_info_workshop", delegate
571 {
572 SE.Click();
573 Application.OpenURL("https://steamcommunity.com/sharedfiles/filedetails/?id=" + a.workshopId.Trim());
574 });
575 }
576 if (!a.id.IsEmpty())
577 {
578 uIContextMenu.AddButton("mod_id_copy", delegate
579 {
580 SE.Click();
581 GUIUtility.systemCopyBuffer = a.id;
582 ELayer.ui.Say("mod_id_copied".lang(a.id));
583 });
584 }
585 uIContextMenu.AddButton("mod_info", delegate
586 {
587 SE.Click();
588 if (!a.dirInfo.Exists)
589 {
590 SE.BeepSmall();
591 ELayer.ui.Say(a.dirInfo.FullName);
592 }
593 else
594 {
595 string text = a.dirInfo.FullName + "/package.xml";
596 Util.ShowExplorer(File.Exists(text) ? text : a.dirInfo.FullName);
597 }
598 });
599 uIContextMenu.Show();
600 });
601 b.buttonLock.onClick.AddListener(Refresh);
602 }
static bool IsOffline
Definition: BaseCore.cs:9
static string rootMod
bool enable
Definition: CoreDebug.cs:302
static void TryWarnUpload(Action action)
Definition: Core.cs:864
static CoreDebug debug
Definition: ELayer.cs:43
UIButton buttonConfig
Definition: ItemMod.cs:23
Image imageMember
Definition: ItemMod.cs:31
UIButton buttonLock
Definition: ItemMod.cs:9
Definition: Lang.cs:7
static string langCode
Definition: Lang.cs:29
static void Open(ModPackage p)
void AddGroupButtons(UIContextMenu m, BaseModPackage a)
Definition: LayerMod.cs:751
ModPackage AddPackage(DirectoryInfo dir, bool isInPackages=false)
Definition: ModManager.cs:424
void CopyContentTo(string dir)
Definition: ModPackage.cs:25
override string UpdateSourceLocalizationFile(string lang, bool force=false)
Definition: ModPackage.cs:349
Action< UINote > onBuildConfig
Definition: ModPackage.cs:19
void SetCheck(bool check)
Definition: UIButton.cs:332
void Show(UIItem i)
Definition: Util.cs:10
static void ShowExplorer(string itemPath, bool selectFirstFile=false)
Definition: Util.cs:228
bool demo
Definition: Version.cs:15

References UIContextMenu.AddButton(), AddGroupButtons(), ModManager.AddPackage(), ItemMod.buttonActivate, ItemMod.buttonConfig, ItemMod.buttonDown, ItemMod.buttonLock, ItemMod.buttonToggle, ItemMod.buttonUp, ModPackage.CopyContentTo(), ELayer.core, ELayer.debug, Version.demo, CoreDebug.enable, UIList.GetPair(), HasFilter, if(), ItemMod.imageMember, BaseCore.IsOffline, Lang.langCode, list, UIButton.mainText, manager, Core.mods, Move(), ModPackage.onBuildConfig, LayerModConfig.Open(), Refresh(), RefreshBottomButtons(), RefreshLists(), BaseModManager.rootMod, ModManager.SaveLoadOrder(), searchCache, UIButton.SetCheck(), UIText.SetText(), UIButton.SetToggle(), UIContextMenu.Show(), ShowInfo(), ShowPreview(), SteamPreview(), textRestart, Core.TryWarnUpload(), ELayer.ui, ModPackage.UpdateSourceLocalizationFile(), Util, BaseCore.version, and Dialog.YesNo().

Referenced by CreateCallbacks().

◆ ShowInfo()

void LayerMod.ShowInfo ( BaseModPackage  p)
inlineprivate

Definition at line 1047 of file LayerMod.cs.

1048 {
1049 if (p == null || p == panelTarget)
1050 {
1051 return;
1052 }
1053 panelTarget = p;
1054 UIText text = infoTitle.text1;
1055 text.SetText(p.title.IsEmpty(p.dirInfo.Name));
1056 TextGenerationSettings generationSettings = text.GetGenerationSettings(new Vector2(text.rectTransform.rect.width, 0f));
1057 generationSettings.horizontalOverflow = HorizontalWrapMode.Wrap;
1058 TextGenerator cachedTextGeneratorForLayout = text.cachedTextGeneratorForLayout;
1059 cachedTextGeneratorForLayout.Populate(text.text, generationSettings);
1060 if (cachedTextGeneratorForLayout.lineCount < 2)
1061 {
1062 text.text += "\n";
1063 }
1064 if (cachedTextGeneratorForLayout.lineCount > 2)
1065 {
1066 string text2 = text.text;
1067 int num = cachedTextGeneratorForLayout.lines[2].startCharIdx;
1068 do
1069 {
1070 int length = --num - 0;
1071 string str = (text.text = text2.Substring(0, length).TrimEnd() + "..");
1072 cachedTextGeneratorForLayout.Populate(str, generationSettings);
1073 }
1074 while (num > 1 && cachedTextGeneratorForLayout.lineCount > 2);
1075 }
1076 PreviewEntry thumb = GetThumb(p);
1077 infoPreview.SetActive(enable: true);
1078 infoPreview.image1.sprite = thumb.sprite ?? spriteNoPreview;
1079 Image image = infoPreview.image1;
1080 Vector2 size = image.sprite.rect.size;
1081 infoPreview.image2.rectTransform.sizeDelta = size * Mathf.Min(image.rectTransform.rect.width / size.x, image.rectTransform.rect.height / size.y) + Vector2.one * 18f;
1082 SetTopic(infoAuthor, p.author.IsEmpty("-"), null);
1083 SetTopic(infoVersion, p.version.IsEmpty("-"), null);
1084 SetTopic(infoId, p.id, null);
1085 string text4 = ModLoadOrderPreset.WorkshopId(p);
1086 SetTopic(infoWorkshop, text4.IsEmpty() ? p.dirInfo.Name : text4, text4.IsEmpty() ? "mod_filter_local" : "mod_filter_workshop");
1087 SetTopic(infoStatus, (!p.builtin && !p.willActivate) ? "mod_filter_disabled".lang() : null, null);
1088 List<string> list = new List<string>();
1089 if (p.blockedBy != null)
1090 {
1091 list.Add("mod_info_blocked".lang(p.blockedBy.title.IsEmpty(p.blockedBy.id)));
1092 }
1093 if (!p.langDepError.IsEmpty())
1094 {
1095 string[] array = p.langDepError.Split('\t');
1096 list.Add(array[0].lang(string.Join("mod_info_or".lang(), array, 1, array.Length - 1)));
1097 }
1098 if (p.duplicateOf != null)
1099 {
1100 list.Add("mod_info_duplicate".lang(p.duplicateOf.title.IsEmpty(p.duplicateOf.dirInfo?.Name).IsEmpty(p.duplicateOf.id)));
1101 }
1102 if (!p.IsValidVersion())
1103 {
1104 list.Add("mod_info_old_version".lang(p.version, ELayer.core.versionMod.GetText()));
1105 }
1106 if (!p.parseError.IsEmpty())
1107 {
1108 list.Add("mod_info_parse_error".lang(p.parseError));
1109 }
1110 SetInfo(infoProblems, string.Join("\n", list));
1112 string[] tags = p.tags;
1113 SetTopic(item, (tags != null && tags.Length > 0) ? string.Join(", ", p.tags) : null, null);
1114 SetTopic(infoRequires, IdList(p.dependency, alternatives: true), null);
1115 SetTopic(infoIncompatible, IdList(p.incompatible, alternatives: false), null);
1116 SetTopic(infoLoadAfter, IdList(p.loadAfter, alternatives: false), null);
1117 SetTopic(infoLoadBefore, IdList(p.loadBefore, alternatives: false), null);
1118 infoSpace.SetActive(!p.description.IsEmpty());
1119 SetInfo(infoDescription, p.description);
1120 panelNote.Build();
1121 panelScroll.content.anchoredPosition = Vector2.zero;
1122 static string IdList(string[][] rows, bool alternatives)
1123 {
1124 if (rows == null)
1125 {
1126 return null;
1127 }
1128 string sep = (alternatives ? "mod_info_or".lang() : "\n");
1129 return string.Join("\n", from row in rows
1130 where row != null && row.Length > 0
1131 select string.Join(sep, row.Where((string id) => !id.IsEmpty())) into line
1132 where !line.IsEmpty()
1133 select line);
1134 }
1135 static void SetInfo(UIItem uIItem, string value)
1136 {
1137 uIItem.SetActive(!value.IsEmpty());
1138 if (!value.IsEmpty())
1139 {
1140 uIItem.text1.SetText(value);
1141 }
1142 }
1143 static void SetTopic(UIItem uIItem, string value, string lang)
1144 {
1145 uIItem.SetActive(!value.IsEmpty());
1146 if (!value.IsEmpty())
1147 {
1148 if (lang != null)
1149 {
1150 uIItem.text1.SetText(lang.lang());
1151 }
1152 uIItem.text2.SetText(value);
1153 }
1154 }
1155 }
Version versionMod
Definition: BaseCore.cs:21
DirectoryInfo dirInfo
string[][] loadAfter
BaseModPackage duplicateOf
string[][] loadBefore
string[][] dependency
BaseModPackage blockedBy
string[][] incompatible
UIItem infoProblems
Definition: LayerMod.cs:72
UIItem infoStatus
Definition: LayerMod.cs:70
UIItem infoIncompatible
Definition: LayerMod.cs:78
UIItem infoWorkshop
Definition: LayerMod.cs:68
UIItem infoDescription
Definition: LayerMod.cs:84
UIItem infoTitle
Definition: LayerMod.cs:56
PreviewEntry GetThumb(BaseModPackage p)
Definition: LayerMod.cs:982
UIItem infoTags
Definition: LayerMod.cs:74
UIItem infoLoadAfter
Definition: LayerMod.cs:80
Sprite spriteNoPreview
Definition: LayerMod.cs:88
UIItem infoVersion
Definition: LayerMod.cs:64
UIItem infoId
Definition: LayerMod.cs:66
UIItem infoLoadBefore
Definition: LayerMod.cs:82
GameObject infoSpace
Definition: LayerMod.cs:86
UINote panelNote
Definition: LayerMod.cs:54
UIItem infoRequires
Definition: LayerMod.cs:76
UIItem infoAuthor
Definition: LayerMod.cs:62
Definition: UIItem.cs:5
Image image1
Definition: UIItem.cs:14
UIText text2
Definition: UIItem.cs:8
UIText text1
Definition: UIItem.cs:6
void Build()
Definition: UINote.cs:49

References UIList.Add(), BaseModPackage.author, BaseModPackage.blockedBy, UINote.Build(), BaseModPackage.builtin, ELayer.core, BaseModPackage.dependency, BaseModPackage.description, BaseModPackage.dirInfo, BaseModPackage.duplicateOf, Version.GetText(), GetThumb(), BaseModPackage.id, UIItem.image1, BaseModPackage.incompatible, infoAuthor, infoDescription, infoId, infoIncompatible, infoLoadAfter, infoLoadBefore, infoPreview, infoProblems, infoRequires, infoSpace, infoStatus, infoTags, infoTitle, infoVersion, infoWorkshop, BaseModPackage.IsValidVersion(), item, BaseModPackage.langDepError, list, BaseModPackage.loadAfter, BaseModPackage.loadBefore, panelNote, panelTarget, BaseModPackage.parseError, UIText.SetText(), spriteNoPreview, BaseModPackage.tags, UIItem.text1, UIItem.text2, BaseModPackage.title, BaseModPackage.version, BaseCore.versionMod, and BaseModPackage.willActivate.

Referenced by OnInit(), and SetModRow().

◆ ShowPresetMenu()

void LayerMod.ShowPresetMenu ( )
inlineprivate

Definition at line 1182 of file LayerMod.cs.

1183 {
1184 SE.Click();
1186 {
1187 Dialog.Ok("mod_preset_disabled");
1188 return;
1189 }
1190 UIContextMenu uIContextMenu = ELayer.ui.CreateContextMenu();
1191 uIContextMenu.AddButton("mod_preset_save", SavePreset);
1192 uIContextMenu.AddButton("mod_preset_load", delegate
1193 {
1195 });
1196 uIContextMenu.AddButton("mod_preset_delete", delegate
1197 {
1199 });
1200 uIContextMenu.AddButton("mod_preset_copy", CopyPreset);
1201 uIContextMenu.AddButton("mod_preset_paste", PastePreset);
1202 uIContextMenu.AddButton("mod_preset_folder", delegate
1203 {
1204 Directory.CreateDirectory(CorePath.PathLoadOrderPreset);
1205 Util.ShowExplorer(CorePath.PathLoadOrderPreset, selectFirstFile: true);
1206 });
1207 uIContextMenu.Show();
1208 }
static string PathLoadOrderPreset
Definition: CorePath.cs:208
void SelectPreset(Action< FileInfo > onSelect)
Definition: LayerMod.cs:1247
void PastePreset()
Definition: LayerMod.cs:1301
void CopyPreset()
Definition: LayerMod.cs:1288
void ApplyPresetFile(FileInfo file)
Definition: LayerMod.cs:1262
void SavePreset()
Definition: LayerMod.cs:1210
void DeletePreset(FileInfo file)
Definition: LayerMod.cs:1274

References UIContextMenu.AddButton(), ApplyPresetFile(), CopyPreset(), DeletePreset(), ModManager.disableMod, Dialog.Ok(), PastePreset(), CorePath.PathLoadOrderPreset, SavePreset(), SelectPreset(), UIContextMenu.Show(), ELayer.ui, and Util.

Referenced by OnInit().

◆ ShowPreview()

void LayerMod.ShowPreview ( BaseModPackage  a)
inlineprivate

Definition at line 1157 of file LayerMod.cs.

1158 {
1159 SE.Click();
1160 ModPreview.PreviewType kind;
1161 bool owns;
1162 Texture2D tex = LoadPreviewTexture(a, mipmap: false, out kind, out owns);
1163 if (!tex)
1164 {
1165 SE.BeepSmall();
1166 ELayer.ui.Say("mod_preview_unsupported");
1167 return;
1168 }
1169 Sprite image = tex.ToSprite();
1170 LayerImage layerImage = ELayer.ui.AddLayer<LayerImage>();
1171 layerImage.SetImage(image);
1172 layerImage.SetOnKill(delegate
1173 {
1174 UnityEngine.Object.Destroy(tex);
1175 if (owns)
1176 {
1177 UnityEngine.Object.Destroy(tex);
1178 }
1179 });
1180 }
void SetImage(Sprite sprite)
Definition: LayerImage.cs:12
Layer SetOnKill(Action action)
Definition: Layer.cs:584

References LoadPreviewTexture(), LayerImage.SetImage(), Layer.SetOnKill(), and ELayer.ui.

Referenced by OnInit(), and SetModRow().

◆ SteamPreview()

static Texture2D LayerMod.SteamPreview ( BaseModPackage  p)
inlinestaticprivate

Definition at line 1033 of file LayerMod.cs.

1034 {
1035 if (!(p.item is WorkshopItem workshopItem) || !workshopItem.previewImage || workshopItem.previewImage.width <= 2)
1036 {
1037 return null;
1038 }
1039 return workshopItem.previewImage;
1040 }

References BaseModPackage.item.

Referenced by LoadPreviewTexture(), and SetModRow().

◆ ToggleAll()

void LayerMod.ToggleAll ( )
inlineprivate

Definition at line 304 of file LayerMod.cs.

305 {
307 {
308 Dialog.Ok("mod_preset_disabled");
309 return;
310 }
311 bool on = !ToggleTargets().Any((BaseModPackage p) => p.willActivate);
312 List<BaseModPackage> changed = (from p in ToggleTargets()
313 where p.willActivate != @on && (!@on || p.duplicateOf == null)
314 select p).ToList();
315 if (changed.Count == 0)
316 {
317 SE.BeepSmall();
318 return;
319 }
320 Dialog.YesNo((on ? "mod_check_all_confirm" : "mod_uncheck_all_confirm").lang(changed.Count.ToString() ?? ""), delegate
321 {
322 foreach (BaseModPackage item in changed)
323 {
324 item.willActivate = on;
325 }
326 OnReorder();
327 });
328 }

References ModManager.disableMod, item, Dialog.Ok(), OnReorder(), ToggleTargets(), BaseModPackage.willActivate, and Dialog.YesNo().

Referenced by OnInit().

◆ ToggleTargets()

IEnumerable< BaseModPackage > LayerMod.ToggleTargets ( )
inlineprivate

Definition at line 295 of file LayerMod.cs.

296 {
297 if (!HasFilter)
298 {
299 return manager.packages.Where((BaseModPackage p) => !p.builtin);
300 }
301 return list.items.OfType<BaseModPackage>();
302 }

References BaseModPackage.builtin, HasFilter, UIList.items, list, and manager.

Referenced by RefreshBottomButtons(), and ToggleAll().

◆ WritePreset()

void LayerMod.WritePreset ( string  name)
inlineprivate

Definition at line 1236 of file LayerMod.cs.

1237 {
1238 if (!manager.SavePreset(name, out var _))
1239 {
1240 SE.BeepSmall();
1241 return;
1242 }
1243 SE.Click();
1244 ELayer.ui.Say("mod_preset_saved".lang(name));
1245 }
bool SavePreset(string name, out string path)
Definition: ModManager.cs:301

References manager, ModManager.SavePreset(), and ELayer.ui.

Referenced by SavePreset().

Member Data Documentation

◆ buttonClearSearch

UIButton LayerMod.buttonClearSearch

Definition at line 46 of file LayerMod.cs.

Referenced by ClearSearch(), InitSearchUI(), and Search().

◆ buttonCollapse

UIButton LayerMod.buttonCollapse
private

Definition at line 92 of file LayerMod.cs.

Referenced by OnInit(), and RefreshBottomButtons().

◆ buttonFilter

UIButton LayerMod.buttonFilter
private

Definition at line 90 of file LayerMod.cs.

Referenced by InitSearchUI(), and RefreshFilterButton().

◆ buttonToggleAll

UIButton LayerMod.buttonToggleAll
private

Definition at line 94 of file LayerMod.cs.

Referenced by OnInit().

◆ filterMode

ModSearch.Filter LayerMod.filterMode
private

Definition at line 106 of file LayerMod.cs.

Referenced by ClearSearch(), CycleFilter(), Match(), and RefreshFilterButton().

◆ infoAuthor

UIItem LayerMod.infoAuthor

Definition at line 62 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoDescription

UIItem LayerMod.infoDescription

Definition at line 84 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoId

UIItem LayerMod.infoId

Definition at line 66 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoIncompatible

UIItem LayerMod.infoIncompatible

Definition at line 78 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoLoadAfter

UIItem LayerMod.infoLoadAfter

Definition at line 80 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoLoadBefore

UIItem LayerMod.infoLoadBefore

Definition at line 82 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoPreview

UIItem LayerMod.infoPreview

Definition at line 58 of file LayerMod.cs.

Referenced by OnInit(), and ShowInfo().

◆ infoPreviewNote

UIItem LayerMod.infoPreviewNote

Definition at line 60 of file LayerMod.cs.

◆ infoProblems

UIItem LayerMod.infoProblems

Definition at line 72 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoRequires

UIItem LayerMod.infoRequires

Definition at line 76 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoSpace

GameObject LayerMod.infoSpace

Definition at line 86 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoStatus

UIItem LayerMod.infoStatus

Definition at line 70 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoTags

UIItem LayerMod.infoTags

Definition at line 74 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoTitle

UIItem LayerMod.infoTitle

Definition at line 56 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoVersion

UIItem LayerMod.infoVersion

Definition at line 64 of file LayerMod.cs.

Referenced by ShowInfo().

◆ infoWorkshop

UIItem LayerMod.infoWorkshop

Definition at line 68 of file LayerMod.cs.

Referenced by ShowInfo().

◆ inputSearch

InputField LayerMod.inputSearch

Definition at line 48 of file LayerMod.cs.

Referenced by ClearSearch(), ClearSearchText(), InitSearchUI(), and LateUpdate().

◆ Instance

LayerMod LayerMod.Instance
static

Definition at line 34 of file LayerMod.cs.

Referenced by OnInit(), and OnKill().

◆ lastSearch

string LayerMod.lastSearch = ""
private

Definition at line 102 of file LayerMod.cs.

Referenced by ClearSearch(), LateUpdate(), and Search().

◆ list

◆ list2

UIList LayerMod.list2

Definition at line 38 of file LayerMod.cs.

Referenced by MoveTo(), OnInit(), and RefreshLists().

◆ panelHeader

UIHeader LayerMod.panelHeader

Definition at line 52 of file LayerMod.cs.

◆ panelNote

UINote LayerMod.panelNote

Definition at line 54 of file LayerMod.cs.

Referenced by ShowInfo().

◆ panelScroll

UIScrollView LayerMod.panelScroll

Definition at line 50 of file LayerMod.cs.

◆ panelTarget

BaseModPackage LayerMod.panelTarget
private

Definition at line 96 of file LayerMod.cs.

Referenced by OnInit(), and ShowInfo().

◆ previews

readonly Dictionary<BaseModPackage, PreviewEntry> LayerMod.previews = new Dictionary<BaseModPackage, PreviewEntry>()
private

Definition at line 110 of file LayerMod.cs.

Referenced by GetThumb(), and OnKill().

◆ searchCache

readonly Dictionary<BaseModPackage, string> LayerMod.searchCache = new Dictionary<BaseModPackage, string>()
private

Definition at line 108 of file LayerMod.cs.

Referenced by Match(), OnInit(), and SetModRow().

◆ searchTerms

string [] LayerMod.searchTerms = Array.Empty<string>()
private

Definition at line 104 of file LayerMod.cs.

Referenced by ClearSearch(), LateUpdate(), and Match().

◆ spriteNoPreview

Sprite LayerMod.spriteNoPreview

Definition at line 88 of file LayerMod.cs.

Referenced by ShowInfo().

◆ textNoResult

UIText LayerMod.textNoResult

Definition at line 42 of file LayerMod.cs.

Referenced by RefreshLists().

◆ textRestart

UIText LayerMod.textRestart

Definition at line 40 of file LayerMod.cs.

Referenced by ApplyPreset(), OnInit(), OnReorder(), and SetModRow().

◆ timerSearch

float LayerMod.timerSearch
private

Definition at line 98 of file LayerMod.cs.

Referenced by ClearSearch(), LateUpdate(), and Search().

◆ toggleDisableMods

UIButton LayerMod.toggleDisableMods

Definition at line 44 of file LayerMod.cs.

Referenced by OnInit().

◆ urlWorkshopItem

const string LayerMod.urlWorkshopItem = "https://steamcommunity.com/sharedfiles/filedetails/?id="
staticprivate

Definition at line 32 of file LayerMod.cs.

◆ wasSearchFocused

bool LayerMod.wasSearchFocused
private

Definition at line 100 of file LayerMod.cs.

Referenced by LateUpdate().

Property Documentation

◆ HasFilter

bool LayerMod.HasFilter
get

Definition at line 114 of file LayerMod.cs.

115 {
116 get
117 {
118 if (searchTerms.Length == 0)
119 {
120 return filterMode != ModSearch.Filter.All;
121 }
122 return true;
123 }
124 }

Referenced by ApplyPreset(), CreateCallbacks(), Move(), NewGroup(), RefreshLists(), SetGroup(), SetModRow(), and ToggleTargets().

◆ manager


The documentation for this class was generated from the following file: