Elin Decompiled Documentation EA 23.356.1 Nightly
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)
 
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 FitTitle (UIText text, string title, string suffix="")
 
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
 
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 706 of file LayerMod.cs.

707 {
708 m.AddButton("mod_group_new", delegate
709 {
710 InputGroupName("mod_group_default_name".lang(), delegate(string name)
711 {
712 SetGroup(a, new ModGroup
713 {
714 name = name
715 });
716 });
717 });
718 List<ModGroup> groups = (from g in Groups()
719 where g != a.@group
720 select g).ToList();
721 if (groups.Count > 0)
722 {
723 m.AddButton("mod_group_move", delegate
724 {
725 SE.Click();
726 Dialog.List("mod_group_select", groups, (ModGroup g) => g.name, delegate(int i, string _)
727 {
728 SetGroup(a, groups[i]);
729 return true;
730 }, canCancel: true);
731 });
732 }
733 if (a.group != null)
734 {
735 m.AddButton("mod_group_remove", delegate
736 {
737 SetGroup(a, null);
738 });
739 }
740 }
if(!match.Success)
Definition: Dialog.cs:7
IEnumerable< ModGroup > Groups()
Definition: LayerMod.cs:564
void InputGroupName(string text, Action< string > onInput)
Definition: LayerMod.cs:797
void SetGroup(BaseModPackage p, ModGroup g)
Definition: LayerMod.cs:742
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 1316 of file LayerMod.cs.

1317 {
1318 if (HasFilter)
1319 {
1320 ClearSearch();
1321 }
1322 ModLoadOrderPreset.ApplyResult applyResult = manager.ApplyPreset(preset);
1323 SE.Tab();
1324 textRestart.SetActive(enable: true);
1325 RefreshLists();
1326 string text = ELayer.core.version.GetText();
1327 if (!preset.gameVersion.IsEmpty() && preset.gameVersion != text)
1328 {
1329 ELayer.ui.Say("mod_preset_version_warn".lang(preset.gameVersion, text));
1330 }
1331 ELayer.ui.Say("mod_preset_applied".lang(preset.name, applyResult.enabled.ToString() ?? "", applyResult.missing.Count.ToString() ?? ""));
1332 }
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:272
bool HasFilter
Definition: LayerMod.cs:113
ModManager manager
Definition: LayerMod.cs:110
UIText textRestart
Definition: LayerMod.cs:40
void ClearSearch()
Definition: LayerMod.cs:882
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 1234 of file LayerMod.cs.

1235 {
1236 if (!manager.TryLoadPresetFile(file, out var preset, out var _))
1237 {
1238 Dialog.Ok("mod_preset_invalid");
1239 }
1240 else
1241 {
1242 ConfirmPreset(preset);
1243 }
1244 }
static Dialog Ok(string langDetail, Action action=null)
Definition: Dialog.cs:230
void ConfirmPreset(ModLoadOrderPreset.Preset preset)
Definition: LayerMod.cs:1287
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 882 of file LayerMod.cs.

883 {
884 if ((bool)inputSearch)
885 {
886 inputSearch.SetTextWithoutNotify("");
887 }
888 if ((bool)buttonClearSearch)
889 {
890 buttonClearSearch.SetActive(enable: false);
891 }
892 lastSearch = "";
893 timerSearch = 0f;
894 searchTerms = Array.Empty<string>();
895 filterMode = ModSearch.Filter.All;
897 RefreshLists();
898 }
string lastSearch
Definition: LayerMod.cs:100
UIButton buttonClearSearch
Definition: LayerMod.cs:46
string[] searchTerms
Definition: LayerMod.cs:102
void RefreshFilterButton()
Definition: LayerMod.cs:908
ModSearch.Filter filterMode
Definition: LayerMod.cs:104
InputField inputSearch
Definition: LayerMod.cs:48
float timerSearch
Definition: LayerMod.cs:96

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

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

◆ ClearSearchText()

void LayerMod.ClearSearchText ( )
inlineprivate

Definition at line 872 of file LayerMod.cs.

873 {
874 SE.Click();
875 if ((bool)inputSearch)
876 {
877 inputSearch.SetTextWithoutNotify("");
878 }
879 Search("");
880 }

References inputSearch, and Search.

Referenced by InitSearchUI().

◆ CollapseAll()

void LayerMod.CollapseAll ( )
inlineprivate

Definition at line 781 of file LayerMod.cs.

782 {
783 List<ModGroup> list = Groups().ToList();
784 if (list.Count == 0)
785 {
786 SE.BeepSmall();
787 return;
788 }
789 bool collapsed = list.Any((ModGroup g) => !g.collapsed);
790 foreach (ModGroup item in list)
791 {
792 item.collapsed = collapsed;
793 }
794 OnReorder(restart: false);
795 }
UIList list
Definition: LayerMod.cs:36
void OnReorder(bool restart=true)
Definition: LayerMod.cs:260
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 1287 of file LayerMod.cs.

1288 {
1289 List<ModLoadOrderPreset.Entry> list = ModLoadOrderPreset.FindMissing(manager.packages, preset);
1290 if (list.Count == 0)
1291 {
1292 ApplyPreset(preset);
1293 return;
1294 }
1295 Dialog.YesNo("mod_preset_missing".lang(DescribeEntries(list, 15)), delegate
1296 {
1297 ApplyPreset(preset);
1298 }, null, "mod_preset_apply", "cancel");
1299 }
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:1316
static string DescribeEntries(List< ModLoadOrderPreset.Entry > entries, int max)
Definition: LayerMod.cs:1301

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

Referenced by ApplyPresetFile(), and PastePreset().

◆ CopyPreset()

void LayerMod.CopyPreset ( )
inlineprivate

Definition at line 1260 of file LayerMod.cs.

1261 {
1262 ModLoadOrderPreset.Preset preset = ModLoadOrderPreset.Save(manager.packages, "", ELayer.core.version.GetText());
1263 if (preset.entries.Count == 0)
1264 {
1265 SE.BeepSmall();
1266 return;
1267 }
1268 GUIUtility.systemCopyBuffer = ModLoadOrderPreset.Serialize(preset);
1269 SE.Click();
1270 ELayer.ui.Say("mod_preset_copied");
1271 }

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 326 of file LayerMod.cs.

327 {
328 return new UIList.Callback<object, ItemMod>
329 {
330 onClick = delegate
331 {
332 },
333 onInstantiate = delegate(object row, ItemMod b)
334 {
335 if (row is ModGroup g)
336 {
337 SetGroupRow(g, b);
338 }
339 else
340 {
341 SetModRow((ModPackage)row, b);
342 }
343 },
344 onList = delegate
345 {
346 ModGroup modGroup = null;
347 if (!builtin && !HasFilter)
348 {
349 foreach (ModGroup emptyGroup in manager.emptyGroups)
350 {
351 if (emptyGroup.after == null)
352 {
353 target.Add(emptyGroup);
354 }
355 }
356 }
357 foreach (BaseModPackage package in manager.packages)
358 {
359 if (package.builtin == builtin && (builtin || Match(package)))
360 {
361 if (!HasFilter && package.group != modGroup)
362 {
363 modGroup = package.group;
364 if (modGroup != null)
365 {
366 target.Add(modGroup);
367 }
368 }
369 if (HasFilter || modGroup == null || !modGroup.collapsed)
370 {
371 target.Add(package);
372 }
373 if (!HasFilter)
374 {
375 foreach (ModGroup emptyGroup2 in manager.emptyGroups)
376 {
377 if (emptyGroup2.after == package)
378 {
379 target.Add(emptyGroup2);
380 }
381 }
382 }
383 }
384 }
385 },
386 onRefresh = Refresh,
387 onDragReorder = delegate(object row, int a)
388 {
389 if (row is ModGroup g)
390 {
391 SetMembersActive(g, active: true);
392 }
393 if (a != 0)
394 {
395 List<object> items = target.items;
396 int num = items.IndexOf(row);
397 MoveTo(row, items[Mathf.Clamp(num + a, 0, items.Count - 1)]);
398 }
399 },
400 canDragReorder = (object row) => !(row is BaseModPackage baseModPackage) || !baseModPackage.builtin
401 };
402 }
void MoveTo(object row, object target)
Definition: LayerMod.cs:174
bool Match(BaseModPackage p)
Definition: LayerMod.cs:833
void SetModRow(ModPackage a, ItemMod b)
Definition: LayerMod.cs:404
void Refresh()
Definition: LayerMod.cs:1334
void SetGroupRow(ModGroup g, ItemMod b)
Definition: LayerMod.cs:626
void SetMembersActive(ModGroup g, bool active)
Definition: LayerMod.cs:572
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 900 of file LayerMod.cs.

901 {
902 SE.Click();
903 filterMode = ModSearch.Filters[(int)(filterMode + 1) % ModSearch.Filters.Length];
905 RefreshLists();
906 }

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

Referenced by InitSearchUI().

◆ DeletePreset()

void LayerMod.DeletePreset ( FileInfo  file)
inlineprivate

Definition at line 1246 of file LayerMod.cs.

1247 {
1248 string name = Path.GetFileNameWithoutExtension(file.Name);
1249 Dialog.YesNo("mod_preset_delete_confirm".lang(name), delegate
1250 {
1251 if (file.Exists)
1252 {
1253 file.Delete();
1254 }
1255 SE.Trash();
1256 ELayer.ui.Say("mod_preset_deleted".lang(name));
1257 });
1258 }

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

Referenced by ShowPresetMenu().

◆ DescribeEntries()

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

Definition at line 1301 of file LayerMod.cs.

1302 {
1303 StringBuilder stringBuilder = new StringBuilder();
1304 for (int i = 0; i < entries.Count && i < max; i++)
1305 {
1306 ModLoadOrderPreset.Entry entry = entries[i];
1307 stringBuilder.Append(entry.title.IsEmpty() ? entry.id : (entry.title + " (" + entry.id + ")")).Append('\n');
1308 }
1309 if (entries.Count > max)
1310 {
1311 stringBuilder.Append("mod_preset_more".lang((entries.Count - max).ToString() ?? "")).Append('\n');
1312 }
1313 return stringBuilder.ToString().TrimEnd();
1314 }

Referenced by ConfirmPreset().

◆ FilterLabel()

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

Definition at line 917 of file LayerMod.cs.

918 {
919 return f switch
920 {
921 ModSearch.Filter.Enabled => "mod_filter_enabled",
922 ModSearch.Filter.Disabled => "mod_filter_disabled",
923 ModSearch.Filter.Problems => "mod_filter_problem",
924 ModSearch.Filter.Local => "mod_filter_local",
925 ModSearch.Filter.Workshop => "mod_filter_workshop",
926 _ => "all",
927 };
928 }

Referenced by RefreshFilterButton().

◆ FirstInfoTarget()

BaseModPackage LayerMod.FirstInfoTarget ( )
inlineprivate

Definition at line 1014 of file LayerMod.cs.

1015 {
1016 return list.items.OfType<BaseModPackage>().FirstOrDefault() ?? manager.packages.FirstOrDefault();
1017 }

References UIList.items, list, and manager.

Referenced by OnInit().

◆ FitTitle()

static string LayerMod.FitTitle ( UIText  text,
string  title,
string  suffix = "" 
)
inlinestaticprivate

Definition at line 816 of file LayerMod.cs.

817 {
818 TextGenerationSettings generationSettings = text.GetGenerationSettings(Vector2.zero);
819 TextGenerator cachedTextGeneratorForLayout = text.cachedTextGeneratorForLayout;
820 float num = text.rectTransform.rect.width * text.pixelsPerUnit;
821 if (cachedTextGeneratorForLayout.GetPreferredWidth(title + suffix, generationSettings) <= num)
822 {
823 return title + suffix;
824 }
825 int num2 = title.Length;
826 while (num2 > 1 && cachedTextGeneratorForLayout.GetPreferredWidth(title[..num2].TrimEnd() + ".." + suffix, generationSettings) > num)
827 {
828 num2--;
829 }
830 return title[..num2].TrimEnd() + ".." + suffix;
831 }
item3. title
Definition: UIBook.cs:640

References title.

Referenced by SetGroupRow(), and SetModRow().

◆ GetGroupIndex()

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

Definition at line 594 of file LayerMod.cs.

595 {
596 List<BaseModPackage> l = manager.packages;
597 return manager.emptyGroups.Count((ModGroup e) => l.IndexOf(e.after) < l.IndexOf(anchor) || (last && e.after == anchor));
598 }

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

Referenced by LeaveGroup(), and MoveTo().

◆ GetThumb()

PreviewEntry LayerMod.GetThumb ( BaseModPackage  p)
inlineprivate

Definition at line 954 of file LayerMod.cs.

955 {
956 if (previews.TryGetValue(p, out var value))
957 {
958 return value;
959 }
960 value = new PreviewEntry();
961 bool owns;
962 Texture2D texture2D = LoadPreviewTexture(p, mipmap: true, out value.kind, out owns);
963 if ((bool)texture2D)
964 {
965 Texture2D texture2D2 = ModPreview.Downscale(texture2D, 280, owns);
966 value.sprite = texture2D2.ToSprite();
967 value.ownsTexture = owns || texture2D2 != texture2D;
968 }
969 previews[p] = value;
970 return value;
971 }
static Texture2D LoadPreviewTexture(BaseModPackage p, bool mipmap, out ModPreview.PreviewType kind, out bool owns)
Definition: LayerMod.cs:973
readonly Dictionary< BaseModPackage, PreviewEntry > previews
Definition: LayerMod.cs:108

References LoadPreviewTexture(), and previews.

Referenced by ShowInfo().

◆ Groups()

IEnumerable< ModGroup > LayerMod.Groups ( )
inlineprivate

Definition at line 564 of file LayerMod.cs.

565 {
566 return (from p in manager.packages
567 select p.@group into g
568 where g != null
569 select g).Distinct().Concat(manager.emptyGroups);
570 }

References ModManager.emptyGroups, and manager.

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

◆ InitSearchUI()

void LayerMod.InitSearchUI ( )
inlineprivate

Definition at line 842 of file LayerMod.cs.

843 {
844 if ((bool)inputSearch)
845 {
846 inputSearch.SetTextWithoutNotify("");
847 if (inputSearch.placeholder is Text text)
848 {
849 text.text = "mod_search".lang();
850 }
851 inputSearch.onValueChanged.AddListener(Search);
852 inputSearch.onSubmit.AddListener(Search);
853 }
854 if ((bool)buttonClearSearch)
855 {
857 }
858 buttonFilter = windows[0].AddBottomButton("mod_filter", CycleFilter);
860 }
UIButton buttonFilter
Definition: LayerMod.cs:90
void ClearSearchText()
Definition: LayerMod.cs:872
void CycleFilter()
Definition: LayerMod.cs:900
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 797 of file LayerMod.cs.

798 {
799 Dialog.InputName("mod_group_name", text, delegate(bool cancel, string s)
800 {
801 if (!cancel)
802 {
803 string text2 = (s ?? "").Trim();
804 if (text2.IsEmpty())
805 {
806 SE.BeepSmall();
807 }
808 else
809 {
810 onInput(text2);
811 }
812 }
813 });
814 }
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 930 of file LayerMod.cs.

931 {
932 if (timerSearch > 0f)
933 {
935 if (timerSearch <= 0f)
936 {
937 timerSearch = 0f;
938 searchTerms = ModSearch.Terms(lastSearch);
939 RefreshLists();
940 }
941 }
942 if ((bool)inputSearch)
943 {
944 bool isFocused = inputSearch.isFocused;
945 EventSystem current = EventSystem.current;
946 if (wasSearchFocused && !isFocused && (bool)current && current.currentSelectedGameObject == inputSearch.gameObject)
947 {
948 current.SetSelectedGameObject(null);
949 }
950 wasSearchFocused = isFocused;
951 }
952 }
Definition: Core.cs:14
static float delta
Definition: Core.cs:17
bool wasSearchFocused
Definition: LayerMod.cs:98

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

◆ LeaveGroup()

void LayerMod.LeaveGroup ( BaseModPackage  p)
inlineprivate

Definition at line 584 of file LayerMod.cs.

585 {
586 ModGroup g = p.group;
587 if (g != null && !manager.packages.Any((BaseModPackage m) => m != p && m.group == g))
588 {
589 manager.emptyGroups.Insert(GetGroupIndex(p, last: false), g);
590 g.after = manager.packages.TakeWhile((BaseModPackage m) => m != p).LastOrDefault((BaseModPackage m) => !m.builtin);
591 }
592 }
int GetGroupIndex(BaseModPackage anchor, bool last)
Definition: LayerMod.cs:594

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 973 of file LayerMod.cs.

974 {
975 kind = ModPreview.PreviewType.None;
976 owns = true;
977 FileInfo fileInfo = ModPreview.FindPreviewFile(p);
978 if (fileInfo != null)
979 {
980 try
981 {
982 Texture2D texture2D = ModPreview.LoadTexture(File.ReadAllBytes(fileInfo.FullName), out kind, mipmap);
983 if ((bool)texture2D)
984 {
985 return texture2D;
986 }
987 }
988 catch (Exception ex)
989 {
990 Debug.LogWarning("#mod preview " + fileInfo.FullName + ": " + ex.Message);
991 }
992 }
993 Texture2D texture2D2 = SteamPreview(p);
994 if ((bool)texture2D2)
995 {
996 owns = false;
997 if (kind == ModPreview.PreviewType.None)
998 {
999 kind = ModPreview.PreviewType.Jpeg;
1000 }
1001 }
1002 return texture2D2;
1003 }
static Texture2D SteamPreview(BaseModPackage p)
Definition: LayerMod.cs:1005

References Debug, and SteamPreview().

Referenced by GetThumb(), and ShowPreview().

◆ Match()

bool LayerMod.Match ( BaseModPackage  p)
inlineprivate

Definition at line 833 of file LayerMod.cs.

834 {
835 if (!searchCache.TryGetValue(p, out var value))
836 {
837 value = (searchCache[p] = ModSearch.BuildText(p));
838 }
839 return ModSearch.Match(p, value, searchTerms, filterMode);
840 }
readonly Dictionary< BaseModPackage, string > searchCache
Definition: LayerMod.cs:106

References filterMode, searchCache, and searchTerms.

Referenced by CreateCallbacks().

◆ Members()

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

Definition at line 559 of file LayerMod.cs.

560 {
561 return manager.packages.Where((BaseModPackage p) => p.group == g).ToList();
562 }

References BaseModPackage.group, and manager.

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

◆ Move()

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

Definition at line 124 of file LayerMod.cs.

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

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 174 of file LayerMod.cs.

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

601 {
603 {
604 SE.BeepSmall();
605 return;
606 }
607 SE.Click();
608 InputGroupName("mod_group_default_name".lang(), delegate(string name)
609 {
610 if (HasFilter)
611 {
612 ClearSearch();
613 }
615 {
616 name = name,
617 after = manager.packages.LastOrDefault((BaseModPackage p) => !p.builtin)
618 };
620 OnReorder(restart: false);
621 list.dragScrollView.content.RebuildLayout(recursive: true);
622 list.dragScrollView.verticalNormalizedPosition = 0f;
623 });
624 }
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 287 of file LayerMod.cs.

288 {
289 textRestart.SetActive(enable: false);
291 {
292 ELayer.config.other.disableMods = on;
294 textRestart.SetActive(enable: true);
295 });
296 Instance = this;
297 foreach (BaseModPackage package in manager.packages)
298 {
299 package.UpdateMeta(updateOnly: true);
300 searchCache[package] = ModSearch.BuildText(package);
301 }
302 list.dragScrollView = list.GetComponentInParent<UIScrollView>();
303 list.dragViewport = windows[0].Rect();
304 list.onDragBegin = delegate(object row)
305 {
306 if (row is ModGroup g)
307 {
308 SetMembersActive(g, active: false);
309 }
310 };
311 list.callbacks = CreateCallbacks(list, builtin: false);
312 list2.callbacks = CreateCallbacks(list2, builtin: true);
313 InitSearchUI();
314 windows[0].AddBottomButton("mod_preset", ShowPresetMenu);
315 windows[0].AddBottomButton("mod_group_new", NewGroup);
316 buttonCollapse = windows[0].AddBottomButton("mod_group_collapse_all", CollapseAll);
317 infoPreview.button1.SetOnClick(delegate
318 {
320 });
321 RefreshLists();
323 list.dragEdgeSize = list.callbacks.GetMold()?.Rect().sizeDelta.y ?? 34f;
324 }
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:1019
UIItem infoPreview
Definition: LayerMod.cs:58
void ShowPresetMenu()
Definition: LayerMod.cs:1154
void NewGroup()
Definition: LayerMod.cs:600
UIButton toggleDisableMods
Definition: LayerMod.cs:44
BaseModPackage panelTarget
Definition: LayerMod.cs:94
void ShowPreview(BaseModPackage a)
Definition: LayerMod.cs:1129
void CollapseAll()
Definition: LayerMod.cs:781
UIList.Callback< object, ItemMod > CreateCallbacks(UIList target, bool builtin)
Definition: LayerMod.cs:326
void InitSearchUI()
Definition: LayerMod.cs:842
UIButton buttonCollapse
Definition: LayerMod.cs:92
BaseModPackage FirstInfoTarget()
Definition: LayerMod.cs:1014
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, 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, toggleDisableMods, BaseModPackage.UpdateMeta(), and Layer.windows.

◆ OnKill()

override void LayerMod.OnKill ( )
inlinevirtual

Reimplemented from Layer.

Definition at line 1338 of file LayerMod.cs.

1339 {
1340 if ((bool)TooltipManager.Instance)
1341 {
1342 TooltipManager.Instance.HideTooltips(immediate: true);
1343 }
1344 foreach (PreviewEntry value in previews.Values)
1345 {
1346 if ((bool)value.sprite)
1347 {
1348 if (value.ownsTexture)
1349 {
1350 UnityEngine.Object.Destroy(value.sprite.texture);
1351 }
1352 UnityEngine.Object.Destroy(value.sprite);
1353 }
1354 }
1355 previews.Clear();
1357 if (Instance == this)
1358 {
1359 Instance = null;
1360 }
1361 }
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 260 of file LayerMod.cs.

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

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

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

◆ PastePreset()

void LayerMod.PastePreset ( )
inlineprivate

Definition at line 1273 of file LayerMod.cs.

1274 {
1275 if (!ModLoadOrderPreset.TryParse(GUIUtility.systemCopyBuffer, out var preset, out var _))
1276 {
1277 Dialog.Ok("mod_preset_invalid");
1278 return;
1279 }
1280 if (preset.name.IsEmpty())
1281 {
1282 preset.name = "mod_preset_default_name".lang();
1283 }
1284 ConfirmPreset(preset);
1285 }

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

Referenced by ShowPresetMenu().

◆ Refresh()

void LayerMod.Refresh ( )
inline

Definition at line 1334 of file LayerMod.cs.

1335 {
1336 }

Referenced by CreateCallbacks(), and SetModRow().

◆ RefreshFilterButton()

void LayerMod.RefreshFilterButton ( )
inlineprivate

Definition at line 908 of file LayerMod.cs.

909 {
910 if ((bool)buttonFilter)
911 {
912 buttonFilter.mainText.text = "mod_filter".lang() + ": " + FilterLabel(filterMode).lang();
913 windows[0].rectBottom.RebuildLayout(recursive: true);
914 }
915 }
static string FilterLabel(ModSearch.Filter f)
Definition: LayerMod.cs:917

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

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

◆ RefreshLists()

void LayerMod.RefreshLists ( )
inline

Definition at line 272 of file LayerMod.cs.

273 {
274 list.List();
275 list2.List();
276 if ((bool)textNoResult)
277 {
278 textNoResult.SetActive(HasFilter && list.items.Count == 0);
279 }
280 if ((bool)buttonCollapse)
281 {
282 buttonCollapse.mainText.text = (Groups().Any((ModGroup g) => !g.collapsed) ? "mod_group_collapse_all" : "mod_group_expand_all").lang();
283 windows[0].rectBottom.RebuildLayout(recursive: true);
284 }
285 }
UIText textNoResult
Definition: LayerMod.cs:42
override void List()
Definition: UIList.cs:773

References buttonCollapse, ModGroup.collapsed, Groups(), HasFilter, UIList.items, list, UIList.List(), list2, textNoResult, and Layer.windows.

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

◆ SavePreset()

void LayerMod.SavePreset ( )
inlineprivate

Definition at line 1182 of file LayerMod.cs.

1183 {
1184 Dialog.InputName("mod_preset_name", "mod_preset_default_name".lang(), delegate(bool cancel, string text)
1185 {
1186 if (!cancel)
1187 {
1188 string name = (text ?? "").Trim().SanitizeFileName().Trim();
1189 if (name.IsEmpty())
1190 {
1191 SE.BeepSmall();
1192 }
1193 else if (File.Exists(ModManager.GetPresetPath(name)))
1194 {
1195 Dialog.YesNo("mod_preset_overwrite".lang(name), delegate
1196 {
1197 WritePreset(name);
1198 });
1199 }
1200 else
1201 {
1202 WritePreset(name);
1203 }
1204 }
1205 });
1206 }
void WritePreset(string name)
Definition: LayerMod.cs:1208
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 862 of file LayerMod.cs.

863 {
864 lastSearch = s ?? "";
865 timerSearch = 0.15f;
866 if ((bool)buttonClearSearch)
867 {
868 buttonClearSearch.SetActive(!lastSearch.IsEmpty());
869 }
870 }

References buttonClearSearch, lastSearch, and timerSearch.

◆ SelectPreset()

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

Definition at line 1219 of file LayerMod.cs.

1220 {
1221 List<FileInfo> files = manager.ListPresets();
1222 if (files.Count == 0)
1223 {
1224 Dialog.Ok("mod_preset_none");
1225 return;
1226 }
1227 Dialog.List("mod_preset_select", files, (FileInfo f) => Path.GetFileNameWithoutExtension(f.Name), delegate(int i, string _)
1228 {
1229 onSelect(files[i]);
1230 return true;
1231 }, canCancel: true);
1232 }
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 742 of file LayerMod.cs.

743 {
744 if (HasFilter)
745 {
746 ClearSearch();
747 }
748 List<BaseModPackage> packages = manager.packages;
749 List<ModGroup> emptyGroups = manager.emptyGroups;
750 ModGroup host = ((g != null && packages.Any((BaseModPackage m) => m.group == g)) ? g : p.group);
751 BaseModPackage baseModPackage = ((host == null) ? null : packages.LastOrDefault((BaseModPackage m) => m != p && m.group == host));
752 if (g != p.group)
753 {
754 LeaveGroup(p);
755 }
756 int num = packages.IndexOf(p);
757 BaseModPackage after = packages.TakeWhile((BaseModPackage m) => m != p).LastOrDefault((BaseModPackage m) => !m.builtin);
758 packages.Remove(p);
759 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))));
760 packages.Insert(num2, p);
761 BaseModPackage baseModPackage2 = (emptyGroups.Contains(g) ? g.after : null);
762 foreach (ModGroup item in emptyGroups)
763 {
764 if (item.after == p && num2 != num)
765 {
766 item.after = after;
767 }
768 else if (emptyGroups.Contains(g) && item.after == baseModPackage2 && emptyGroups.IndexOf(item) >= emptyGroups.IndexOf(g))
769 {
770 item.after = p;
771 }
772 }
773 p.group = g;
774 if (g != null)
775 {
776 g.collapsed = false;
777 }
778 OnReorder();
779 }

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 626 of file LayerMod.cs.

627 {
628 List<BaseModPackage> members = Members(g);
629 int on = members.Count((BaseModPackage p) => p.willActivate);
630 string title = ((members.Count == 0) ? "" : (g.collapsed ? "[+] " : "[-] ")) + g.name;
631 UIText mainText = b.buttonActivate.mainText;
632 mainText.fontStyle = FontStyle.Bold;
633 mainText.SetText(FitTitle(mainText, title, (members.Count > 0) ? (" (" + on + "/" + members.Count + ")") : ""), FontColor.Topic);
634 Color topic = mainText.color;
635 Color? color = g.color;
636 if (color.HasValue)
637 {
638 Color valueOrDefault = color.GetValueOrDefault();
639 mainText.SetText(mainText.text, valueOrDefault.Multiply(0.45f, 0f));
640 }
641 b.imageGroup.SetActive(enable: true);
642 b.imageGroup.color = (g.color ?? topic).SetAlpha(0.4f);
643 b.buttonActivate.subText.text = "";
644 b.buttonLock.mainText.text = "";
645 b.buttonUp.SetOnClick(delegate
646 {
647 Move(g, -1);
648 });
649 b.buttonDown.SetOnClick(delegate
650 {
651 Move(g, 1);
652 });
653 b.buttonToggle.SetToggle(on > 0 && on == members.Count);
654 b.buttonToggle.interactable = members.Count > 0;
655 b.buttonToggle.SetOnClick(delegate
656 {
657 foreach (BaseModPackage item in members)
658 {
659 item.willActivate = on != members.Count;
660 }
661 OnReorder();
662 });
663 b.buttonActivate.SetOnClick(delegate
664 {
665 g.collapsed = !g.collapsed;
666 OnReorder(restart: false);
667 });
668 b.buttonRename.SetActive(enable: true);
669 b.buttonRename.SetOnClick(delegate
670 {
671 InputGroupName(g.name, delegate(string name)
672 {
673 g.name = name;
674 OnReorder(restart: false);
675 });
676 });
677 b.buttonColor.SetActive(enable: true);
678 b.buttonColor.SetOnClick(delegate
679 {
680 ELayer.ui.AddLayer<LayerColorPicker>().SetColor(g.color ?? topic, topic, delegate(PickerState state, Color c)
681 {
682 c.a = topic.a;
683 g.color = ((c == topic) ? ((Color?)null) : new Color?(c));
684 if (state == PickerState.Confirm)
685 {
686 OnReorder(restart: false);
687 }
688 else
689 {
690 SetGroupRow(g, b);
691 }
692 });
693 });
694 b.buttonDisband.SetActive(enable: true);
695 b.buttonDisband.SetOnClick(delegate
696 {
697 foreach (BaseModPackage item2 in members)
698 {
699 item2.group = null;
700 }
701 manager.emptyGroups.Remove(g);
702 OnReorder(restart: false);
703 });
704 }
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:124
static string FitTitle(UIText text, string title, string suffix="")
Definition: LayerMod.cs:816
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, FitTitle(), ItemMod.imageGroup, InputGroupName(), item, UIButton.mainText, manager, Members(), Move(), ModGroup.name, OnReorder(), SetGroupRow(), UIText.SetText(), UIButton.SetToggle(), title, ELayer.ui, and BaseModPackage.willActivate.

Referenced by CreateCallbacks(), and SetGroupRow().

◆ SetMembersActive()

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

Definition at line 572 of file LayerMod.cs.

573 {
574 if (g.collapsed)
575 {
576 return;
577 }
578 foreach (BaseModPackage item in Members(g))
579 {
580 list.GetPair(item).component.SetActive(active);
581 }
582 }
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 404 of file LayerMod.cs.

405 {
406 b.package = a;
407 string title = ((a.group != null && !HasFilter) ? " " : "") + (ELayer.core.mods.packages.IndexOf(a) + 1) + ". " + (a.isInPackages ? "[Local] " : "") + a.title.IsEmpty(a.dirInfo.Name);
408 b.buttonActivate.mainText.SetText(FitTitle(b.buttonActivate.mainText, title), (!a.IsValidVersion() || a.blockedBy != null || !a.langDepError.IsEmpty()) ? FontColor.Bad : (a.activated ? FontColor.ButtonGeneral : FontColor.Passive));
409 b.buttonActivate.subText.text = a.version;
410 b.buttonLock.mainText.text = a.author;
411 ItemMod itemMod = ((a.group != null && !HasFilter) ? list.GetPair<ItemMod>(a.group) : null);
412 b.imageMember.SetActive(itemMod);
413 if ((bool)itemMod)
414 {
415 b.imageMember.color = itemMod.buttonActivate.mainText.color;
416 }
417 b.buttonUp.SetActive(!a.builtin);
418 b.buttonDown.SetActive(!a.builtin);
419 b.buttonConfig.SetActive(a.onBuildConfig != null);
420 b.buttonConfig.SetOnClick(delegate
421 {
423 });
424 b.buttonToggle.SetToggle(a.willActivate);
425 b.buttonUp.SetOnClick(delegate
426 {
427 Move(a, -1);
428 });
429 b.buttonDown.SetOnClick(delegate
430 {
431 Move(a, 1);
432 });
433 b.buttonActivate.GetOrCreate<HoverRelay>().onEnter = delegate
434 {
435 ShowInfo(a);
436 };
437 UIButton bt = b.buttonToggle;
438 bt.SetOnClick(delegate
439 {
440 a.willActivate = !a.willActivate;
441 bt.SetCheck(a.willActivate);
443 textRestart.SetActive(enable: true);
444 if (a.group != null && !HasFilter)
445 {
446 SetGroupRow(a.group, list.GetPair<ItemMod>(a.group));
447 }
448 });
449 bt.interactable = !a.builtin;
450 b.buttonActivate.onClick.AddListener(delegate
451 {
452 Refresh();
453 UIContextMenu uIContextMenu = ELayer.ui.CreateContextMenuInteraction().SetHighlightTarget(b.buttonActivate);
454 if (!a.builtin)
455 {
456 if (ELayer.debug.enable || (!BaseCore.IsOffline && a.isInPackages && !ELayer.core.version.demo))
457 {
458 uIContextMenu.AddButton("mod_publish", delegate
459 {
460 Core.TryWarnUpload(delegate
461 {
462 Dialog.YesNo("mod_publish_warn".lang(a.title, a.id, a.author), delegate
463 {
464 ELayer.core.steam.CreateUserContent(a);
465 });
466 });
467 });
468 }
469 uIContextMenu.AddButton(a.willActivate ? "mod_deactivate" : "mod_activate", delegate
470 {
471 SE.Click();
472 a.willActivate = !a.willActivate;
473 ELayer.core.mods.SaveLoadOrder();
474 RefreshLists();
475 textRestart.SetActive(enable: true);
476 });
477 if (!a.isInPackages && !a.workshopId.IsEmpty())
478 {
479 uIContextMenu.AddButton("mod_convert_local", delegate
480 {
481 SE.Click();
482 string path = ("Mod_" + a.workshopId + "_" + a.id).SanitizeDirectoryName();
483 string text = Path.Combine(BaseModManager.rootMod, path);
484 a.CopyContentTo(text);
485 ModPackage modPackage = manager.AddPackage(new DirectoryInfo(text), isInPackages: true);
486 modPackage.UpdateMeta(updateOnly: true);
487 searchCache[modPackage] = ModSearch.BuildText(modPackage);
488 manager.packages.Move(modPackage, manager.packages.IndexOf(a) - manager.packages.Count + 2);
489 modPackage.group = a.group;
490 modPackage.willActivate = false;
491 modPackage.activated = false;
493 RefreshLists();
494 textRestart.SetActive(enable: true);
495 });
496 }
497 if (a.isInPackages && a.IsSourceLocalizable)
498 {
499 uIContextMenu.AddButton("mod_export_text", delegate
500 {
501 SE.Click();
502 string text = a.UpdateSourceLocalizationFile(Lang.langCode, force: true);
503 ELayer.ui.Say(text);
504 });
505 }
506 AddGroupButtons(uIContextMenu, a);
507 }
508 if (a.onBuildConfig != null)
509 {
510 uIContextMenu.AddButton("config", delegate
511 {
512 SE.Click();
514 });
515 }
516 if (ModPreview.FindPreviewFile(a) != null || (bool)SteamPreview(a))
517 {
518 uIContextMenu.AddButton("mod_preview", delegate
519 {
520 ShowPreview(a);
521 });
522 }
523 if (!a.workshopId.IsEmpty())
524 {
525 uIContextMenu.AddButton("mod_info_workshop", delegate
526 {
527 SE.Click();
528 Application.OpenURL("https://steamcommunity.com/sharedfiles/filedetails/?id=" + a.workshopId.Trim());
529 });
530 }
531 if (!a.id.IsEmpty())
532 {
533 uIContextMenu.AddButton("mod_id_copy", delegate
534 {
535 SE.Click();
536 GUIUtility.systemCopyBuffer = a.id;
537 ELayer.ui.Say("mod_id_copied".lang(a.id));
538 });
539 }
540 uIContextMenu.AddButton("mod_info", delegate
541 {
542 SE.Click();
543 if (!a.dirInfo.Exists)
544 {
545 SE.BeepSmall();
546 ELayer.ui.Say(a.dirInfo.FullName);
547 }
548 else
549 {
550 string text = a.dirInfo.FullName + "/package.xml";
551 Util.ShowExplorer(File.Exists(text) ? text : a.dirInfo.FullName);
552 }
553 });
554 uIContextMenu.Show();
555 });
556 b.buttonLock.onClick.AddListener(Refresh);
557 }
static bool IsOffline
Definition: BaseCore.cs:9
static string rootMod
bool enable
Definition: CoreDebug.cs:302
static void TryWarnUpload(Action action)
Definition: Core.cs:859
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:706
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, FitTitle(), UIList.GetPair(), HasFilter, if(), ItemMod.imageMember, BaseCore.IsOffline, Lang.langCode, list, UIButton.mainText, manager, Core.mods, Move(), ModPackage.onBuildConfig, LayerModConfig.Open(), Refresh(), RefreshLists(), BaseModManager.rootMod, ModManager.SaveLoadOrder(), searchCache, UIButton.SetCheck(), UIText.SetText(), UIButton.SetToggle(), UIContextMenu.Show(), ShowInfo(), ShowPreview(), SteamPreview(), textRestart, title, 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 1019 of file LayerMod.cs.

1020 {
1021 if (p == null || p == panelTarget)
1022 {
1023 return;
1024 }
1025 panelTarget = p;
1026 UIText text = infoTitle.text1;
1027 text.SetText(p.title.IsEmpty(p.dirInfo.Name));
1028 TextGenerationSettings generationSettings = text.GetGenerationSettings(new Vector2(text.rectTransform.rect.width, 0f));
1029 generationSettings.horizontalOverflow = HorizontalWrapMode.Wrap;
1030 TextGenerator cachedTextGeneratorForLayout = text.cachedTextGeneratorForLayout;
1031 cachedTextGeneratorForLayout.Populate(text.text, generationSettings);
1032 if (cachedTextGeneratorForLayout.lineCount < 2)
1033 {
1034 text.text += "\n";
1035 }
1036 if (cachedTextGeneratorForLayout.lineCount > 2)
1037 {
1038 string text2 = text.text;
1039 int num = cachedTextGeneratorForLayout.lines[2].startCharIdx;
1040 do
1041 {
1042 int length = --num - 0;
1043 string str = (text.text = text2.Substring(0, length).TrimEnd() + "..");
1044 cachedTextGeneratorForLayout.Populate(str, generationSettings);
1045 }
1046 while (num > 1 && cachedTextGeneratorForLayout.lineCount > 2);
1047 }
1048 PreviewEntry thumb = GetThumb(p);
1049 infoPreview.SetActive(enable: true);
1050 infoPreview.image1.sprite = thumb.sprite ?? spriteNoPreview;
1051 Image image = infoPreview.image1;
1052 Vector2 size = image.sprite.rect.size;
1053 infoPreview.image2.rectTransform.sizeDelta = size * Mathf.Min(image.rectTransform.rect.width / size.x, image.rectTransform.rect.height / size.y) + Vector2.one * 18f;
1054 SetTopic(infoAuthor, p.author.IsEmpty("-"), null);
1055 SetTopic(infoVersion, p.version.IsEmpty("-"), null);
1056 SetTopic(infoId, p.id, null);
1057 string text4 = ModLoadOrderPreset.WorkshopId(p);
1058 SetTopic(infoWorkshop, text4.IsEmpty() ? p.dirInfo.Name : text4, text4.IsEmpty() ? "mod_filter_local" : "mod_filter_workshop");
1059 SetTopic(infoStatus, (!p.builtin && !p.willActivate) ? "mod_filter_disabled".lang() : null, null);
1060 List<string> list = new List<string>();
1061 if (p.blockedBy != null)
1062 {
1063 list.Add("mod_info_blocked".lang(p.blockedBy.title.IsEmpty(p.blockedBy.id)));
1064 }
1065 if (!p.langDepError.IsEmpty())
1066 {
1067 string[] array = p.langDepError.Split('\t');
1068 list.Add(array[0].lang(string.Join("mod_info_or".lang(), array, 1, array.Length - 1)));
1069 }
1070 if (p.duplicateOf != null)
1071 {
1072 list.Add("mod_info_duplicate".lang(p.duplicateOf.title.IsEmpty(p.duplicateOf.dirInfo?.Name).IsEmpty(p.duplicateOf.id)));
1073 }
1074 if (!p.IsValidVersion())
1075 {
1076 list.Add("mod_info_old_version".lang(p.version, ELayer.core.versionMod.GetText()));
1077 }
1078 if (!p.parseError.IsEmpty())
1079 {
1080 list.Add("mod_info_parse_error".lang(p.parseError));
1081 }
1082 SetInfo(infoProblems, string.Join("\n", list));
1084 string[] tags = p.tags;
1085 SetTopic(item, (tags != null && tags.Length > 0) ? string.Join(", ", p.tags) : null, null);
1086 SetTopic(infoRequires, IdList(p.dependency, alternatives: true), null);
1087 SetTopic(infoIncompatible, IdList(p.incompatible, alternatives: false), null);
1088 SetTopic(infoLoadAfter, IdList(p.loadAfter, alternatives: false), null);
1089 SetTopic(infoLoadBefore, IdList(p.loadBefore, alternatives: false), null);
1090 infoSpace.SetActive(!p.description.IsEmpty());
1091 SetInfo(infoDescription, p.description);
1092 panelNote.Build();
1093 panelScroll.content.anchoredPosition = Vector2.zero;
1094 static string IdList(string[][] rows, bool alternatives)
1095 {
1096 if (rows == null)
1097 {
1098 return null;
1099 }
1100 string sep = (alternatives ? "mod_info_or".lang() : "\n");
1101 return string.Join("\n", from row in rows
1102 where row != null && row.Length > 0
1103 select string.Join(sep, row.Where((string id) => !id.IsEmpty())) into line
1104 where !line.IsEmpty()
1105 select line);
1106 }
1107 static void SetInfo(UIItem uIItem, string value)
1108 {
1109 uIItem.SetActive(!value.IsEmpty());
1110 if (!value.IsEmpty())
1111 {
1112 uIItem.text1.SetText(value);
1113 }
1114 }
1115 static void SetTopic(UIItem uIItem, string value, string lang)
1116 {
1117 uIItem.SetActive(!value.IsEmpty());
1118 if (!value.IsEmpty())
1119 {
1120 if (lang != null)
1121 {
1122 uIItem.text1.SetText(lang.lang());
1123 }
1124 uIItem.text2.SetText(value);
1125 }
1126 }
1127 }
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:954
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 1154 of file LayerMod.cs.

1155 {
1156 SE.Click();
1158 {
1159 Dialog.Ok("mod_preset_disabled");
1160 return;
1161 }
1162 UIContextMenu uIContextMenu = ELayer.ui.CreateContextMenu();
1163 uIContextMenu.AddButton("mod_preset_save", SavePreset);
1164 uIContextMenu.AddButton("mod_preset_load", delegate
1165 {
1167 });
1168 uIContextMenu.AddButton("mod_preset_delete", delegate
1169 {
1171 });
1172 uIContextMenu.AddButton("mod_preset_copy", CopyPreset);
1173 uIContextMenu.AddButton("mod_preset_paste", PastePreset);
1174 uIContextMenu.AddButton("mod_preset_folder", delegate
1175 {
1176 Directory.CreateDirectory(CorePath.PathLoadOrderPreset);
1177 Util.ShowExplorer(CorePath.PathLoadOrderPreset, selectFirstFile: true);
1178 });
1179 uIContextMenu.Show();
1180 }
static string PathLoadOrderPreset
Definition: CorePath.cs:208
void SelectPreset(Action< FileInfo > onSelect)
Definition: LayerMod.cs:1219
void PastePreset()
Definition: LayerMod.cs:1273
void CopyPreset()
Definition: LayerMod.cs:1260
void ApplyPresetFile(FileInfo file)
Definition: LayerMod.cs:1234
void SavePreset()
Definition: LayerMod.cs:1182
void DeletePreset(FileInfo file)
Definition: LayerMod.cs:1246

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 1129 of file LayerMod.cs.

1130 {
1131 SE.Click();
1132 ModPreview.PreviewType kind;
1133 bool owns;
1134 Texture2D tex = LoadPreviewTexture(a, mipmap: false, out kind, out owns);
1135 if (!tex)
1136 {
1137 SE.BeepSmall();
1138 ELayer.ui.Say("mod_preview_unsupported");
1139 return;
1140 }
1141 Sprite image = tex.ToSprite();
1142 LayerImage layerImage = ELayer.ui.AddLayer<LayerImage>();
1143 layerImage.SetImage(image);
1144 layerImage.SetOnKill(delegate
1145 {
1146 UnityEngine.Object.Destroy(tex);
1147 if (owns)
1148 {
1149 UnityEngine.Object.Destroy(tex);
1150 }
1151 });
1152 }
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 1005 of file LayerMod.cs.

1006 {
1007 if (!(p.item is WorkshopItem workshopItem) || !workshopItem.previewImage || workshopItem.previewImage.width <= 2)
1008 {
1009 return null;
1010 }
1011 return workshopItem.previewImage;
1012 }

References BaseModPackage.item.

Referenced by LoadPreviewTexture(), and SetModRow().

◆ WritePreset()

void LayerMod.WritePreset ( string  name)
inlineprivate

Definition at line 1208 of file LayerMod.cs.

1209 {
1210 if (!manager.SavePreset(name, out var _))
1211 {
1212 SE.BeepSmall();
1213 return;
1214 }
1215 SE.Click();
1216 ELayer.ui.Say("mod_preset_saved".lang(name));
1217 }
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 RefreshLists().

◆ buttonFilter

UIButton LayerMod.buttonFilter
private

Definition at line 90 of file LayerMod.cs.

Referenced by InitSearchUI(), and RefreshFilterButton().

◆ filterMode

ModSearch.Filter LayerMod.filterMode
private

Definition at line 104 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 100 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 94 of file LayerMod.cs.

Referenced by OnInit(), and ShowInfo().

◆ previews

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

Definition at line 108 of file LayerMod.cs.

Referenced by GetThumb(), and OnKill().

◆ searchCache

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

Definition at line 106 of file LayerMod.cs.

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

◆ searchTerms

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

Definition at line 102 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 96 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 98 of file LayerMod.cs.

Referenced by LateUpdate().

Property Documentation

◆ HasFilter

bool LayerMod.HasFilter
get

Definition at line 112 of file LayerMod.cs.

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

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

◆ manager


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