Implement use skin action.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Cryville.Crtr.Browsing.UI;
|
||||
using Cryville.Crtr.Config;
|
||||
using Cryville.Crtr.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -16,14 +17,23 @@ namespace Cryville.Crtr.Browsing.Actions {
|
||||
return true;
|
||||
}
|
||||
public override void Invoke(Uri uri, IChartDetail resource) {
|
||||
Invoke(resource.RulesetId);
|
||||
}
|
||||
|
||||
public static bool HasTab(string ruleset) {
|
||||
int tabId;
|
||||
var master = ResourceBrowserMaster.Instance;
|
||||
if (master == null) return false;
|
||||
return _rulesetTabs.TryGetValue(ruleset, out tabId) && master.HasTab(tabId);
|
||||
}
|
||||
public static void Invoke(string ruleset, Action<RulesetConfig> overrides = null) {
|
||||
var master = ResourceBrowserMaster.Instance;
|
||||
var ruleset = resource.RulesetId;
|
||||
int tabId;
|
||||
if (_rulesetTabs.TryGetValue(ruleset, out tabId) && master.TryOpenTab(tabId))
|
||||
return;
|
||||
var browser = Object.Instantiate(master.m_configBrowserPrefab).GetComponent<RulesetConfigBrowser>();
|
||||
try {
|
||||
browser.Load(ruleset);
|
||||
browser.Load(ruleset, overrides);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Dialog.Show(null, ex.Message);
|
||||
@@ -32,6 +42,7 @@ namespace Cryville.Crtr.Browsing.Actions {
|
||||
return;
|
||||
}
|
||||
_rulesetTabs[ruleset] = master.AddAndOpenTab(string.Format("Config: {0}", ruleset), browser);
|
||||
browser.InitAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
33
Assets/Cryville/Crtr/Browsing/Actions/UseSkinAction.cs
Normal file
33
Assets/Cryville/Crtr/Browsing/Actions/UseSkinAction.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Cryville.Crtr.Browsing.UI;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Crtr.Browsing.Actions {
|
||||
internal class UseSkinAction : ResourceAction<ISkinDetail> {
|
||||
readonly RulesetConfigBrowser _destination;
|
||||
public UseSkinAction() : this(null) { }
|
||||
public UseSkinAction(RulesetConfigBrowser destination) {
|
||||
_destination = destination;
|
||||
}
|
||||
|
||||
public override string Name { get { return "Use"; } }
|
||||
|
||||
public override int Priority { get { return -100; } }
|
||||
|
||||
public override bool CanInvoke(Uri uri, ISkinDetail resource) {
|
||||
if (_destination == null) {
|
||||
return !OpenConfigAction.HasTab(resource.RulesetId);
|
||||
}
|
||||
return _destination.RulesetName == resource.RulesetId;
|
||||
}
|
||||
|
||||
public override void Invoke(Uri uri, ISkinDetail resource) {
|
||||
if (_destination == null) {
|
||||
OpenConfigAction.Invoke(resource.RulesetId, config => config.generic.Skin = resource.Name);
|
||||
}
|
||||
else {
|
||||
_destination.SetSkin(resource.Name);
|
||||
OpenConfigAction.Invoke(resource.RulesetId, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Cryville/Crtr/Browsing/Actions/UseSkinAction.cs.meta
Normal file
11
Assets/Cryville/Crtr/Browsing/Actions/UseSkinAction.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac898133ecfdb3f42bdade958381cd1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user