refactor: Update Unity to 2022.3.62
This commit is contained in:
@@ -31,7 +31,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
OnReset();
|
||||
}
|
||||
protected override void OnReset() {
|
||||
if (_cover != null) _cover.Cancel();
|
||||
_cover?.Cancel();
|
||||
if (m_icon.sprite != null && m_icon.sprite != m_iconPlaceholder) {
|
||||
Destroy(m_icon.sprite.texture);
|
||||
Destroy(m_icon.sprite);
|
||||
|
@@ -79,8 +79,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
protected override void OnEnable() {
|
||||
base.OnEnable();
|
||||
m_layoutMinWidth = GetTargetLayoutMinWidth();
|
||||
if (_tweener == null)
|
||||
_tweener = new PropertyTweener<float>(
|
||||
_tweener ??= new PropertyTweener<float>(
|
||||
() => m_layoutMinWidth,
|
||||
v => UpdateLayoutMinWidth(v),
|
||||
Tweeners.Float.With(EasingFunctions.OutQuad)
|
||||
|
@@ -72,7 +72,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
}
|
||||
|
||||
void DestroyDynamicResources() {
|
||||
if (_image != null) _image.Cancel();
|
||||
_image?.Cancel();
|
||||
if (m_cover.sprite != null && m_cover.sprite != m_coverPlaceholder) {
|
||||
Destroy(m_cover.sprite.texture);
|
||||
Destroy(m_cover.sprite);
|
||||
|
@@ -34,8 +34,8 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
IResourceAction _importAction;
|
||||
readonly IResourceAction[] _importActionArray = new IResourceAction[1];
|
||||
|
||||
readonly HashSet<int> _selectedItems = new HashSet<int>();
|
||||
readonly Dictionary<int, BrowserItem> _items = new Dictionary<int, BrowserItem>();
|
||||
readonly HashSet<int> _selectedItems = new();
|
||||
readonly Dictionary<int, BrowserItem> _items = new();
|
||||
|
||||
bool _destroyed;
|
||||
protected virtual void Start() {
|
||||
@@ -52,10 +52,10 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
}
|
||||
|
||||
void OnEnable() {
|
||||
if (_manager != null) _manager.Activate();
|
||||
_manager?.Activate();
|
||||
}
|
||||
void OnDisable() {
|
||||
if (_manager != null) _manager.Deactivate();
|
||||
_manager?.Deactivate();
|
||||
}
|
||||
|
||||
public void Init(IPathedResourceManager<IResourceMeta> manager) {
|
||||
|
@@ -21,8 +21,8 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
internal GameObject m_configBrowserPrefab;
|
||||
|
||||
BrowserTab _currentTab;
|
||||
readonly Dictionary<int, BrowserTab> _tabMap = new Dictionary<int, BrowserTab>();
|
||||
readonly Dictionary<BrowserTab, ResourceBrowser> _tabs = new Dictionary<BrowserTab, ResourceBrowser>();
|
||||
readonly Dictionary<int, BrowserTab> _tabMap = new();
|
||||
readonly Dictionary<BrowserTab, ResourceBrowser> _tabs = new();
|
||||
|
||||
public ActionManager Actions { get; private set; }
|
||||
|
||||
@@ -77,8 +77,7 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
return _tabMap.ContainsKey(id);
|
||||
}
|
||||
public bool TryOpenTab(int id) {
|
||||
BrowserTab tab;
|
||||
if (_tabMap.TryGetValue(id, out tab)) {
|
||||
if (_tabMap.TryGetValue(id, out BrowserTab tab)) {
|
||||
OnTabClicked(tab);
|
||||
return true;
|
||||
}
|
||||
|
@@ -31,21 +31,21 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
|
||||
public void Load(string rulesetName, Action<RulesetConfig> overrides = null) {
|
||||
RulesetName = rulesetName;
|
||||
FileInfo file = new FileInfo(Path.Combine(
|
||||
FileInfo file = new(Path.Combine(
|
||||
Game.GameDataPath, "rulesets", rulesetName, ".umgr"
|
||||
));
|
||||
if (!file.Exists) {
|
||||
throw new FileNotFoundException("Ruleset for the resource not found\nMake sure you have imported the ruleset");
|
||||
}
|
||||
DirectoryInfo dir = file.Directory;
|
||||
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
||||
using (StreamReader reader = new(file.FullName, Encoding.UTF8)) {
|
||||
_ruleset = JsonConvert.DeserializeObject<RulesetDefinition>(reader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
if (_ruleset.format != RulesetDefinition.CURRENT_FORMAT) throw new FormatException("Invalid ruleset file version");
|
||||
_ruleset.LoadPdt(dir);
|
||||
}
|
||||
FileInfo cfgfile = new FileInfo(Path.Combine(
|
||||
FileInfo cfgfile = new(Path.Combine(
|
||||
Game.GameDataPath, "config", "rulesets", rulesetName + ".json"
|
||||
));
|
||||
if (!cfgfile.Exists) {
|
||||
@@ -53,11 +53,10 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
_rscfg = new RulesetConfig();
|
||||
}
|
||||
else {
|
||||
using (StreamReader cfgreader = new StreamReader(cfgfile.FullName, Encoding.UTF8)) {
|
||||
_rscfg = JsonConvert.DeserializeObject<RulesetConfig>(cfgreader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
}
|
||||
using StreamReader cfgreader = new(cfgfile.FullName, Encoding.UTF8);
|
||||
_rscfg = JsonConvert.DeserializeObject<RulesetConfig>(cfgreader.ReadToEnd(), new JsonSerializerSettings() {
|
||||
MissingMemberHandling = MissingMemberHandling.Error
|
||||
});
|
||||
}
|
||||
|
||||
overrides?.Invoke(_rscfg);
|
||||
@@ -92,12 +91,11 @@ namespace Cryville.Crtr.Browsing.UI {
|
||||
void OnDisable() {
|
||||
if (_loaded) {
|
||||
m_inputConfigPanel.SaveTo(_rscfg.inputs);
|
||||
FileInfo cfgFile = new FileInfo(Path.Combine(
|
||||
FileInfo cfgFile = new(Path.Combine(
|
||||
Game.GameDataPath, "config", "rulesets", RulesetName + ".json"
|
||||
));
|
||||
using (StreamWriter cfgWriter = new StreamWriter(cfgFile.FullName, false, Encoding.UTF8)) {
|
||||
cfgWriter.Write(JsonConvert.SerializeObject(_rscfg, Game.GlobalJsonSerializerSettings));
|
||||
}
|
||||
using StreamWriter cfgWriter = new(cfgFile.FullName, false, Encoding.UTF8);
|
||||
cfgWriter.Write(JsonConvert.SerializeObject(_rscfg, Game.GlobalJsonSerializerSettings));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user