• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

FreeTrainの進化系を目指す


Commit MetaInfo

Revision20 (tree)
Time2014-04-13 22:49:24
Authorc477

Log Message

Replace entries of contribution factories to declaration of contributions.
xmlでcontribution宣言方法を整理(basetypeとかimplementationとか紛らわしいのでclass属性に統一)。
factory-class指定はオプション。

Change Summary

Incremental Difference

--- trunk/plugins/test/plugin.xml (revision 19)
+++ trunk/plugins/test/plugin.xml (revision 20)
@@ -4,17 +4,15 @@
44 <author>C477</author>
55 <homepage>http://www.rocket.ne.jp/~nao/</homepage>
66
7- <contribution type="factory" id="test1">
7+ <declare-contribution>
88 <name>dummy</name>
9- <class name="nft.framework.plugin.FixedClassContributionFactory"/>
10- <implementation name="nft.framework.plugin.DummyContribution" />
11- </contribution>
9+ <class name="nft.framework.plugin.DummyContribution" />
10+ </declare-contribution>
1211
13- <contribution type="factory" id="test2">
14- <name>test_dummy</name>
15- <class name="nft.framework.plugin.FixedClassContributionFactory"/>
16- <implementation name="nft.framework.plugin.DummyContribution" />
17- </contribution>
12+ <declare-contribution type="test_dummy">
13+ <name>dummy2</name>
14+ <class name="nft.framework.plugin.DummyContribution" />
15+ </declare-contribution>
1816
1917 <contribution type="Image" id="tex112x136x96">
2018 <src>cube112x136x96.bmp</src>
--- trunk/plugins/system/plugin.xml (revision 19)
+++ trunk/plugins/system/plugin.xml (revision 20)
@@ -15,88 +15,73 @@
1515 <name>TestBinaryModule</name>
1616 <class name="nft.debug.TestBinaryModule" codebase=".Core"/>
1717 </contribution>
18- <contribution type="factory" id="F_Anonymous">
18+ <declare-contribution>
1919 <name>Anonymous</name>
2020 <description>Independent contributions decrared without specific factroy.</description>
21- <implementation name="nft.framework.plugin.CtbAnonymousCtbFactory"/>
22- </contribution>
23- <contribution type="factory" id="F_Dummy">
21+ <factory-class name="nft.framework.plugin.CtbAnonymousCtbFactory"/>
22+ </declare-contribution>
23+ <declare-contribution type="ignore">
2424 <name>Dummy(for debug)</name>
2525 <description>dummy contribtions for debug/development purpose.</description>
26- <implementation name="nft.framework.plugin.DummyContributionFactory"/>
27- <declare type="ignore"/>
28- </contribution>
29- <contribution type="factory" id="F_SubForm">
26+ <factory-class name="nft.framework.plugin.DummyContributionFactory"/>
27+ </declare-contribution>
28+ <declare-contribution>
3029 <name>SubForm</name>
3130 <description>Child GUI forms</description>
32- <implementation name="nft.contributions.ui.CtbSubform"/>
33- </contribution>
34- <contribution type="factory" id="F_MenuItems">
31+ <class name="nft.contributions.ui.CtbSubform"/>
32+ </declare-contribution>
33+ <declare-contribution type="MenuItems">
3534 <name>Menu items</name>
36- <implementation name="nft.contributions.ui.CtbMenuItem"/>
37- <declare type="MenuItems"/>
38- </contribution>
39- <contribution type="factory" id="F_ToolButtons">
35+ <class name="nft.contributions.ui.CtbMenuItem"/>
36+ </declare-contribution>
37+ <declare-contribution type="ToolButtons">
4038 <name>Tool buttons</name>
41- <implementation name="nft.contributions.ui.CtbToolButton"/>
42- <declare type="ToolButtons"/>
43- </contribution>
44- <contribution type="factory" id="F_Command">
39+ <class name="nft.contributions.ui.CtbToolButton"/>
40+ </declare-contribution>
41+ <declare-contribution type="Command">
4542 <name>User commands</name>
46- <implementation name="nft.contributions.ui.CtbCommandEntity"/>
47- <declare type="Command"/>
48- </contribution>
49- <contribution type="factory" id="F_CommandUI">
43+ <class name="nft.contributions.ui.CtbCommandEntity"/>
44+ </declare-contribution>
45+ <declare-contribution type="CommandUI">
5046 <name>Command UIs</name>
51- <implementation name="nft.contributions.ui.CtbCommandUI"/>
52- <declare type="CommandUI"/>
53- </contribution>
54- <contribution type="factory" id="F_CommandUIGroup">
47+ <class name="nft.contributions.ui.CtbCommandUI"/>
48+ </declare-contribution>
49+ <declare-contribution type="CommandUIGroup">
5550 <name>Command UI Group definition</name>
56- <implementation name="nft.contributions.ui.CtbCommandUIGroup"/>
57- <declare type="CommandUIGroup"/>
58- </contribution>
59- <contribution type="factory" id="F_ImageSource">
51+ <class name="nft.contributions.ui.CtbCommandUIGroup"/>
52+ </declare-contribution>
53+ <declare-contribution type="Image">
6054 <name>Image Resources</name>
61- <basetype name="nft.contributions.graphics.CtbImageResource" codebase=".Core"/>
62- <declare type="Image"/>
63- </contribution>
64- <contribution type="factory" id="F_TerrainGenerator">
55+ <class name="nft.contributions.graphics.CtbImageResource" codebase=".Core"/>
56+ </declare-contribution>
57+ <declare-contribution type="TerrainGenerator">
6558 <name>Terrain generators</name>
66- <class name="nft.framework.plugin.InheritableContributionFactory"/>
67- <basetype name="nft.contributions.game.CtbTerrainGenerator" codebase=".Core"/>
68- <declare type="TerrainGenerator"/>
69- </contribution>
70- <contribution type="factory" id="F_WorldDivider">
59+ <class name="nft.contributions.game.CtbTerrainGenerator" codebase=".Core"/>
60+ </declare-contribution>
61+ <declare-contribution type="WorldDivider">
7162 <name>World dividers</name>
72- <class name="nft.framework.plugin.InheritableContributionFactory"/>
73- <basetype name="nft.contributions.game.CtbWorldDivider" codebase=".Core"/>
74- <declare type="WorldDivider"/>
75- </contribution>
76- <contribution type="factory" id="F_GroundTextrue">
63+ <class name="nft.contributions.game.CtbWorldDivider" codebase=".Core"/>
64+ </declare-contribution>
65+ <declare-contribution type="GroundTexture">
7766 <name>Terrain(ground) textrue sets</name>
78- <class name="nft.contributions.terrain.CtbGroundTextureFactory" codebase=".Core"/>
79- <basetype name="nft.contributions.terrain.CtbSimpleGroundTexture" codebase=".Core"/>
80- <declare type="GroundTexture"/>
81- </contribution>
82- <contribution type="factory" id="F_CliffTexture">
67+ <class name="nft.contributions.terrain.CtbSimpleGroundTexture" codebase=".Core"/>
68+ <factory-class name="nft.contributions.terrain.CtbGroundTextureFactory" codebase=".Core"/>
69+ </declare-contribution>
70+ <declare-contribution type="CliffTexture">
8371 <name>Cliff texture sets</name>
84- <class name="nft.contributions.terrain.CtbCliffTextureFactory" codebase=".Core"/>
85- <basetype name="nft.contributions.terrain.CtbSimpleCliffTexture" codebase=".Core"/>
86- <declare type="CliffTexture"/>
87- </contribution>
88- <contribution type="factory" id="F_HeightCutPlaneTexture">
72+ <class name="nft.contributions.terrain.CtbSimpleCliffTexture" codebase=".Core"/>
73+ <factory-class name="nft.contributions.terrain.CtbCliffTextureFactory" codebase=".Core"/>
74+ </declare-contribution>
75+ <declare-contribution type="HeightCutPlaneTexture">
8976 <name>Height-cut plane texture sets</name>
90- <class name="nft.contributions.terrain.CtbHeightCutPlaneTextureFactory" codebase=".Core"/>
91- <basetype name="nft.contributions.terrain.CtbHeightCutPlaneTexture" codebase=".Core"/>
92- <declare type="HeightCutPlaneTexture"/>
93- </contribution>
94- <contribution type="factory" id="F_HeightCutSlopeTexture">
77+ <class name="nft.contributions.terrain.CtbHeightCutPlaneTexture" codebase=".Core"/>
78+ <factory-class name="nft.contributions.terrain.CtbHeightCutPlaneTextureFactory" codebase=".Core"/>
79+ </declare-contribution>
80+ <declare-contribution type="HeightCutSlopeTexture">
9581 <name>Height-cut slope (terrain) texture sets</name>
96- <class name="nft.contributions.terrain.CtbHeightCutSlopeTextureFactory" codebase=".Core"/>
97- <basetype name="nft.contributions.terrain.CtbHeightCutSlopeTexture" codebase=".Core"/>
98- <declare type="HeightCutSlopeTexture"/>
99- </contribution>
82+ <class name="nft.contributions.terrain.CtbHeightCutSlopeTexture" codebase=".Core"/>
83+ <factory-class name="nft.contributions.terrain.CtbHeightCutSlopeTextureFactory" codebase=".Core"/>
84+ </declare-contribution>
10085
10186 <contribution type="MenuItems" id="BaseMenu">
10287 <name>システム基本メニュー</name>
--- trunk/framework/TODO.txt (revision 19)
+++ trunk/framework/TODO.txt (revision 20)
@@ -1,5 +1,5 @@
11 ・凹型(interior)/凸型(exterior)に分かれた3Dオブジェクト(線路など用)
2-・選択UIの基本、ステータス表示の基本
2+・選択UIの基本、ステータス表示の基本 InputController<-*SitePicker 見た目=skin
33 ・MRT昼夜同時描画/HitTest用マップ
44
55 ◎開発メモ
@@ -75,11 +75,12 @@
7575 ・Q.いつフィルタを掛けるか。
7676  A.OffScreenSerfaceを更新時に。→XNAのPSで
7777
78-■MultiRenderTargetの用途割り当てについて
78+■MultiRenderTargetの用途割り当てについて(XNA4/HiDefでは最大4つ)
7979 ゲームビュー&プレコンバインドでは下記
8080 0:RGB=昼間色、A=透過情報
81-1:RGB=ID塗り分け、A=深度
82-2:RGB=夜間色、A=照り返し
81+1:AR=グループ内ID GB=ID塗り分け
82+2:RGB=夜間色、A=
83+3:RGB=照り返し、A=深度
8384
8485 IDは24bit枠
8586 ・地形は(x-y)値(16bit)+0xff
--- trunk/framework/framework/plugin/InheritableContributionFactory.cs (revision 19)
+++ trunk/framework/framework/plugin/InheritableContributionFactory.cs (revision 20)
@@ -21,7 +21,7 @@
2121 }
2222
2323 public InheritableContributionFactory( ParamsReader e) :
24- this( PluginUtil.loadTypeFromManifest(e["basetype"])) {}
24+ this( PluginUtil.loadTypeFromManifest(e["class"])) {}
2525
2626
2727 private readonly Type baseType;
--- trunk/framework/framework/plugin/CtbCustomCtbFactory.cs (revision 19)
+++ trunk/framework/framework/plugin/CtbCustomCtbFactory.cs (revision 20)
@@ -15,7 +15,7 @@
1515 public abstract class CtbCustomCtbFactory : Contribution, IContributionFactory {
1616 public CtbCustomCtbFactory(Plugin p, ParamsReader e)
1717 : base(p, e) {
18- baseType = PluginUtil.loadTypeFromManifest(e["basetype"]);
18+ baseType = PluginUtil.loadTypeFromManifest(e["class"]);
1919 }
2020
2121 #region IContributionFactory メンバ
--- trunk/framework/framework/plugin/PluginManager.cs (revision 19)
+++ trunk/framework/framework/plugin/PluginManager.cs (revision 20)
@@ -216,6 +216,7 @@
216216 try
217217 {
218218 LoadBinaries(p, p._reader);
219+ LoadCtbDeclarations(p, p._reader);
219220 }
220221 catch( Exception e )
221222 {
@@ -367,6 +368,40 @@
367368 }
368369
369370 /// <summary>
371+ /// Load declaration of contributions from this plug-in
372+ /// </summary>
373+ internal void LoadCtbDeclarations(Plugin p, ParamsReader _reader) {
374+ // locate contribution factories first,
375+ // because we'll need them to load contributions.
376+ foreach (ParamsReader ctb_reader in _reader.EnumChildren("declare-contribution")) {
377+ //string type = ctb_reader["type"].InnerText;
378+ try {
379+ Contribution cb = null;
380+ // load a contribution factory
381+ NotifyStartParse(p, ctb_reader);
382+ string regtype= ctb_reader["type|name"].InnerText;
383+ object[] args = new object[] { ctb_reader };
384+ // create and register contribution factory
385+ IContributionFactory factory =
386+ PluginUtil.createCtbFactory(p, ctb_reader);
387+ AddContributionFactory(regtype, factory);
388+ cb = factory as Contribution;
389+ // Register dummy contribution (in order to list on Dialog).
390+ if (cb == null) {
391+ cb = new CtbContributionDefiner(p, ctb_reader);
392+ }
393+
394+ cb.Attach();
395+ cb._state = InstallationState.Ready;
396+ } catch (Exception e) {
397+ p._state = InstallationState.FatalError;
398+ string msg = MakeContribExceptionMessage(p, ctb_reader);
399+ throw new Exception(msg, e);
400+ }
401+ }
402+ }
403+
404+ /// <summary>
370405 /// Loads class type contributions from this plug-in
371406 /// </summary>
372407 internal void LoadBinaries(Plugin p, ParamsReader _reader) {
@@ -376,29 +411,9 @@
376411 string type = ctb_reader["type"].InnerText;
377412 try {
378413 Contribution cb = null;
379- // load a contribution factory
380- if ("factory".Equals(type)) {
414+ // load binary module contribution.
415+ if ("binary".Equals(type)) {
381416 NotifyStartParse(p, ctb_reader);
382- ParamsReader nd = ctb_reader["declare"];
383- string regtype;
384- if (!nd.IsNull) {
385- regtype = nd["type"].InnerText;
386- } else {
387- // use name property for alternative.
388- regtype = ctb_reader["name"].InnerText;
389- }
390- object[] args = new object[] { ctb_reader };
391- // create and register contribution factory
392- IContributionFactory factory =
393- PluginUtil.createCtbFactory(p, ctb_reader);
394- AddContributionFactory(regtype, factory);
395- cb = factory as Contribution;
396- // Register dummy contribution (in order to list on Dialog).
397- if (cb == null) {
398- cb = new CtbContributionDefiner(p, ctb_reader);
399- }
400- } else if ("binary".Equals(type)) {
401- NotifyStartParse(p, ctb_reader);
402417 cb = PluginUtil.createContributionObject(p, ctb_reader) as BinaryModule;
403418 if (cb == null) {
404419 // create dummy module for list Dialog
@@ -429,7 +444,7 @@
429444 try {
430445 count++;
431446 string type = ctb_reader["type"].InnerText;
432- if ("factory".Equals(type) || "binary".Equals(type)) continue; // ignore
447+ if ("binary".Equals(type) /* || "factory".Equals(type)*/) continue; // ignore
433448
434449 NotifyStartParse(p, ctb_reader);
435450 IContributionFactory factory = GetContributionFactory(type);
--- trunk/framework/framework/plugin/PluginUtil.cs (revision 19)
+++ trunk/framework/framework/plugin/PluginUtil.cs (revision 20)
@@ -33,7 +33,10 @@
3333 }
3434
3535 public static IContributionFactory createCtbFactory(Plugin p, ParamsReader elm) {
36- ParamsReader el = elm["class"];
36+ ParamsReader el = elm["factory-class"];
37+ if (elm["id"].IsNull) {
38+ elm.OverWrite("id", "factory#" + elm["name|type"]);
39+ }
3740 if (el.IsNull) // should use default factory.
3841 return new DefaultContributionFactory(p, elm);
3942 Type t = loadTypeFromManifest(el);
--- trunk/framework/framework/plugin/CtbAnonymousCtbFactory.cs (revision 19)
+++ trunk/framework/framework/plugin/CtbAnonymousCtbFactory.cs (revision 20)
@@ -33,7 +33,7 @@
3333 try
3434 {
3535 // give XmlNode as first argument of constructor.
36- result = Activator.CreateInstance(t, new object[] { reader }) as CtbAnonymous;
36+ result = Activator.CreateInstance(t, new object[] { owner, reader }) as CtbAnonymous;
3737 }
3838 catch (Exception e)
3939 {
--- trunk/framework/framework/plugin/CustomContributionFactory.cs (revision 19)
+++ trunk/framework/framework/plugin/CustomContributionFactory.cs (revision 20)
@@ -16,7 +16,7 @@
1616 }
1717
1818 public CustomContributionFactory(ParamsReader e)
19- : this(PluginUtil.loadTypeFromManifest(e["basetype"])) { }
19+ : this(PluginUtil.loadTypeFromManifest(e["class"])) { }
2020
2121
2222 private readonly Type baseType;
--- trunk/framework/framework/plugin/ContributionFactory.cs (revision 19)
+++ trunk/framework/framework/plugin/ContributionFactory.cs (revision 20)
@@ -29,9 +29,9 @@
2929 internal protected DefaultContributionFactory(Plugin p, ParamsReader elm)
3030 : base(p, elm)
3131 {
32- ParamsReader nd = elm["basetype|implementation"];
32+ ParamsReader nd = elm["class|implementation"];
3333 if (nd.IsNull) {
34- throw new PluginXmlException(p, elm, "<basetype> is required for ContributionFactory.");
34+ throw new PluginXmlException(p, elm, "Contribution class must be specified by 'name' attribute in the <class> element.");
3535 }
3636 this.baseType = PluginUtil.loadTypeFromManifest(nd);
3737 }
@@ -41,13 +41,23 @@
4141
4242 public Contribution load(Plugin owner, ParamsReader e)
4343 {
44- Contribution contrib = (Contribution)Activator.CreateInstance(baseType, new object[] { owner, e });
45- if( baseType.IsInstanceOfType(contrib) )
46- return contrib;
47- else
48- throw new PluginXmlException(owner, e, string.Format(
49- "{0} is incorrect for this contribution (expected:{1})",
50- contrib.GetType().FullName, baseType.FullName ));
44+ ParamsReader r = e["class"];
45+ Type prodtype;
46+ if (r.IsNull) {
47+ prodtype = this.baseType;
48+ } else {
49+ object[] args = new object[] { owner, e };
50+ prodtype = PluginUtil.loadTypeFromManifest(r);
51+ if (!prodtype.IsSubclassOf(baseType)) {
52+ /*
53+ throw new PluginXmlException(owner, e, string.Format(
54+ "{0} is incorrect for this contribution (expected:{1})", prodtype.FullName, baseType.FullName));
55+ */
56+ prodtype = this.baseType;
57+ }
58+ }
59+ Contribution contrib = (Contribution)Activator.CreateInstance(prodtype, new object[] { owner, e });
60+ return contrib;
5161 }
5262
5363 public override string Description {