FreeTrainの進化系を目指す
匿名コントリビューション CtbAnonymous の定義とサンプル実装
| @@ -15,6 +15,11 @@ | ||
| 15 | 15 | <name>TestBinaryModule</name> |
| 16 | 16 | <class name="nft.debug.TestBinaryModule" codebase=".Core"/> |
| 17 | 17 | </contribution> |
| 18 | + <contribution type="factory" id="F_Anonymous"> | |
| 19 | + <name>Anonymous</name> | |
| 20 | + <description>Independent contributions decrared without specific factroy.</description> | |
| 21 | + <implementation name="nft.framework.plugin.CtbAnonymousCtbFactory"/> | |
| 22 | + </contribution> | |
| 18 | 23 | <contribution type="factory" id="F_SubForm"> |
| 19 | 24 | <name>SubForm</name> |
| 20 | 25 | <description>Child GUI forms</description> |
| @@ -269,6 +274,12 @@ | ||
| 269 | 274 | <command menupath="HELP\DEBUG|TEST" /> |
| 270 | 275 | </contribution--> |
| 271 | 276 | |
| 277 | + <contribution type="Anonymous" id="Test_CtbAnonymous"> | |
| 278 | + <name>匿名コントリビューション</name> | |
| 279 | + <description>ファクトリ宣言を必要としない、孤立したコントリビューションのサンプル</description> | |
| 280 | + <class name="nft.debug.TestAnonymousCtb" codebase=".Core"/> | |
| 281 | + </contribution> | |
| 282 | + | |
| 272 | 283 | <contribution type="Command" id="C_CreateNewMap"> |
| 273 | 284 | <name>新規マップ作成</name> |
| 274 | 285 | <class name="nft.ui.core.CreateMapForm" codebase=".UI"/> |
| @@ -14,4 +14,23 @@ | ||
| 14 | 14 | <class name="nft.ui.WinFormManager" codebase=".UI"/> |
| 15 | 15 | <description>Form Manager based on System.Windows.Forms</description> |
| 16 | 16 | </module> |
| 17 | + <module name="Game Time Calendar"> | |
| 18 | + <class name="nft.core.schedule.GameCalender" codebase=".Core"/> | |
| 19 | + <description>Calendar For Game World</description> | |
| 20 | + <preference> | |
| 21 | + <param name="UseRealDaysInMonth" type="Boolean"> | |
| 22 | + <comment>If false, Each month have %SimpefiedDaysInMonth% days</comment> | |
| 23 | + <default>false</default> | |
| 24 | + </param> | |
| 25 | + <param name="SimplifiedDaysInMonth" type="Integer"> | |
| 26 | + <comment>Not used if %UseRealDaysInMonth% is true</comment> | |
| 27 | + <default>7</default> | |
| 28 | + </param> | |
| 29 | + <param name="RevisonWeightForDaysInMonth" type="Float"> | |
| 30 | + <note>Not used if UseRealDaysInMonth is true</note> | |
| 31 | + <!--Not used if UseRealDaysInMonth is true--> | |
| 32 | + <default>7</default> | |
| 33 | + </param> | |
| 34 | + </preference> | |
| 35 | + </module> | |
| 17 | 36 | </modules> |
| \ No newline at end of file |
| @@ -0,0 +1,48 @@ | ||
| 1 | +using System; | |
| 2 | +using System.Collections; | |
| 3 | +using System.Diagnostics; | |
| 4 | +using System.Drawing; | |
| 5 | +using System.Reflection; | |
| 6 | +using System.Xml; | |
| 7 | +using nft.framework; | |
| 8 | +using nft.framework.plugin; | |
| 9 | +using nft.core.game; | |
| 10 | +using nft.core.geometry; | |
| 11 | +using nft.core.structure; | |
| 12 | +using nft.util; | |
| 13 | +using nft.framework.drawing; | |
| 14 | +using System.Text; | |
| 15 | +using System.IO; | |
| 16 | +using System.Collections.Generic; | |
| 17 | +using nft.core.view; | |
| 18 | + | |
| 19 | +namespace nft.contributions.graphics | |
| 20 | +{ | |
| 21 | + /// <summary> | |
| 22 | + /// CtbCliffTextureFactory の概要の説明です。 | |
| 23 | + /// </summary> | |
| 24 | + public class CtbDefaultSceneConditionFactory : CtbCustomCtbFactory, IConditionFactory | |
| 25 | + { | |
| 26 | + public CtbDefaultSceneConditionFactory(Plugin p, ParamsReader contrib) | |
| 27 | + : base(p, contrib) { | |
| 28 | + } | |
| 29 | + | |
| 30 | + protected override Contribution Create(Plugin owner, ParamsReader e) | |
| 31 | + { | |
| 32 | + ParamsReader src = e["src"]; | |
| 33 | + if(!src.IsNull){ | |
| 34 | + e.OverWrite("name","Image:"+src.InnerText); | |
| 35 | + } else { | |
| 36 | + e.OverWrite("name","<unknown>"); | |
| 37 | + } | |
| 38 | + return new CtbImageResource(owner, e); | |
| 39 | + } | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + public ISceneCondition CreateCondition(ParamsReader reader) | |
| 44 | + { | |
| 45 | + throw new NotImplementedException(); | |
| 46 | + } | |
| 47 | + } | |
| 48 | +} |
| @@ -0,0 +1,16 @@ | ||
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Text; | |
| 4 | +using nft.framework.plugin; | |
| 5 | +using nft.framework; | |
| 6 | +using System.Diagnostics; | |
| 7 | + | |
| 8 | +namespace nft.debug | |
| 9 | +{ | |
| 10 | + public class TestAnonymousCtb : CtbAnonymous | |
| 11 | + { | |
| 12 | + public TestAnonymousCtb(Plugin owner, ParamsReader contrib):base(owner, contrib) { | |
| 13 | + Debug.WriteLine("TestAnonymousCtb instance created."); | |
| 14 | + } | |
| 15 | + } | |
| 16 | +} |
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | using System.Text; |
| 4 | 4 | using nft.framework.drawing; |
| 5 | 5 | using nft.framework; |
| 6 | +using nft.core.schedule; | |
| 6 | 7 | |
| 7 | 8 | namespace nft.core.view |
| 8 | 9 | { |
| @@ -14,7 +15,8 @@ | ||
| 14 | 15 | |
| 15 | 16 | public interface ISceneParams |
| 16 | 17 | { |
| 17 | - DateTime Datetime { get; } | |
| 18 | + //DateTime Datetime { get; } | |
| 19 | + Time Time { get; } | |
| 18 | 20 | Object Weather { get; } |
| 19 | 21 | ZoomScale ZoomScale { get; } |
| 20 | 22 | } |
| @@ -21,7 +23,10 @@ | ||
| 21 | 23 | |
| 22 | 24 | public interface IConditionFactory |
| 23 | 25 | { |
| 26 | + string Name { get; } | |
| 27 | + | |
| 24 | 28 | ISceneCondition CreateCondition(ParamsReader reader); |
| 29 | + | |
| 25 | 30 | } |
| 26 | 31 | |
| 27 | 32 | public interface ISceneCondition |
| @@ -0,0 +1,56 @@ | ||
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Text; | |
| 4 | +using System.Xml; | |
| 5 | +using nft.util; | |
| 6 | +using System.Diagnostics; | |
| 7 | + | |
| 8 | +namespace nft.framework.plugin { | |
| 9 | + /// <summary> | |
| 10 | + /// Instantiate a Contribution class by custom method (maybe according to the description of XML element) | |
| 11 | + /// The Contribution should be an instance of specified baseType. | |
| 12 | + /// <seealso cref="CustomContributionFactory"/> | |
| 13 | + /// </summary> | |
| 14 | + [PrimitiveContribution] | |
| 15 | + public sealed class CtbAnonymousCtbFactory : Contribution, IContributionFactory { | |
| 16 | + public CtbAnonymousCtbFactory(Plugin p, ParamsReader e) | |
| 17 | + : base(p, e) { | |
| 18 | + } | |
| 19 | + | |
| 20 | + #region IContributionFactory メンバ | |
| 21 | + public Type OutputType { get { return typeof(CtbAnonymous); } } | |
| 22 | + | |
| 23 | + public Contribution load(Plugin owner, ParamsReader reader) { | |
| 24 | + Type required = OutputType; | |
| 25 | + Type t = PluginUtil.loadTypeFromManifest(reader["class"]); | |
| 26 | + if (!t.IsSubclassOf(required)) | |
| 27 | + { | |
| 28 | + string templ = Main.resources["xml.class_cast_error"].stringValue; | |
| 29 | + object[] a2 = new object[] { t.FullName, required.Name, reader.SourceURI }; | |
| 30 | + throw new InvalidCastException(string.Format(templ, a2)); | |
| 31 | + } | |
| 32 | + CtbAnonymous result = null; | |
| 33 | + try | |
| 34 | + { | |
| 35 | + // give XmlNode as first argument of constructor. | |
| 36 | + result = Activator.CreateInstance(t, new object[] { reader }) as CtbAnonymous; | |
| 37 | + } | |
| 38 | + catch (Exception e) | |
| 39 | + { | |
| 40 | + Debug.WriteLine(e.Message); | |
| 41 | + Debug.WriteLine(e.StackTrace); | |
| 42 | + string templ = Main.resources["xml.class_load_error"].stringValue; | |
| 43 | + throw new Exception(string.Format(templ, t.FullName, reader.SourceURI), e); | |
| 44 | + } | |
| 45 | + return result; | |
| 46 | + } | |
| 47 | + #endregion | |
| 48 | + } | |
| 49 | + | |
| 50 | + public class CtbAnonymous : Contribution { | |
| 51 | + public CtbAnonymous(Plugin owner, ParamsReader contrib) | |
| 52 | + : base(owner, contrib) | |
| 53 | + { | |
| 54 | + } | |
| 55 | + } | |
| 56 | +} |