FreeTrainの進化系を目指す
細かな不具合修正
| @@ -0,0 +1,13 @@ | ||
| 1 | +using nft.contributions.game; | |
| 2 | +using System; | |
| 3 | +using System.Collections.Generic; | |
| 4 | +using System.Diagnostics; | |
| 5 | +using System.Text; | |
| 6 | + | |
| 7 | +namespace nft.core.controller { | |
| 8 | + public class BuildTool { | |
| 9 | + public BuildTool(CtbGameTool contrib) { | |
| 10 | + Debug.WriteLine("I'm here!"); | |
| 11 | + } | |
| 12 | + } | |
| 13 | +} |
| @@ -662,27 +662,21 @@ | ||
| 662 | 662 | |
| 663 | 663 | internal class ContributionEnumerator<T> : IEnumerable<T> where T : Contribution |
| 664 | 664 | { |
| 665 | - readonly Type type; | |
| 665 | + readonly Type enumtype; | |
| 666 | 666 | readonly bool hideDisabled; |
| 667 | 667 | |
| 668 | 668 | public ContributionEnumerator() : this(true) { } |
| 669 | 669 | |
| 670 | 670 | public ContributionEnumerator(bool hideDisable) { |
| 671 | - this.type = this.type.GetGenericArguments()[0]; | |
| 671 | + this.enumtype = this.GetType().GetGenericArguments()[0]; | |
| 672 | 672 | this.hideDisabled = hideDisable; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | public IEnumerator<T> GetEnumerator() { |
| 676 | - if (type == null) { | |
| 677 | - foreach (T c in PluginManager.theInstance.contributionMap.Values) | |
| 676 | + foreach (Contribution c in PluginManager.theInstance.contributionMap.Values) { | |
| 677 | + if (enumtype.IsInstanceOfType(c)) { | |
| 678 | 678 | if (!hideDisabled || c.IsAttached) |
| 679 | - yield return c; | |
| 680 | - } else { | |
| 681 | - foreach (T c in PluginManager.theInstance.contributionMap.Values) { | |
| 682 | - if (type.IsInstanceOfType(c)) { | |
| 683 | - if (!hideDisabled || c.IsAttached) | |
| 684 | - yield return c; | |
| 685 | - } | |
| 679 | + yield return (T)c; | |
| 686 | 680 | } |
| 687 | 681 | } |
| 688 | 682 | } |
| @@ -50,8 +50,11 @@ | ||
| 50 | 50 | |
| 51 | 51 | public void RegisterCommand(string name, IHasNameAndID owner, CommandUI cui) { |
| 52 | 52 | string key = MakePath(owner, name); |
| 53 | + if (commands.ContainsKey(key)) { | |
| 54 | + Debug.WriteLine("command key="+key+" will be overwritten."); | |
| 55 | + } | |
| 53 | 56 | try { |
| 54 | - commands.Add(key, cui); | |
| 57 | + commands[key] = cui; | |
| 55 | 58 | } catch (Exception e) { |
| 56 | 59 | Debug.WriteLine(cui); |
| 57 | 60 | } |
| @@ -94,7 +94,7 @@ | ||
| 94 | 94 | |
| 95 | 95 | public int Set(ComboBox combo, bool hideDisabled, IListContribFilter filter) { |
| 96 | 96 | int n = 0; |
| 97 | - foreach (T c in GetArray(hideDisabled)) | |
| 97 | + foreach (T c in GetEnumerable(hideDisabled)) | |
| 98 | 98 | if (filter.IsValid(c)) { |
| 99 | 99 | combo.Items.Add(new AbstractItem(c)); |
| 100 | 100 | n++; |
| @@ -140,7 +140,7 @@ | ||
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - private IEnumerable<T> GetArray(bool hideDisabled) { | |
| 143 | + private IEnumerable<T> GetEnumerable(bool hideDisabled) { | |
| 144 | 144 | PluginManager pm = PluginManager.theInstance; |
| 145 | 145 | return pm.EnumContributions<T>(hideDisabled); |
| 146 | 146 | } |