• 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

Revision30 (tree)
Time2015-03-20 11:23:21
Authorc477

Log Message

ビュー周りの整備(途上)

Change Summary

Incremental Difference

--- trunk/framework/TODO.txt (revision 29)
+++ trunk/framework/TODO.txt (revision 30)
@@ -1,5 +1,5 @@
11 ・凹型(interior)/凸型(exterior)に分かれた3Dオブジェクト(線路など用)
2-・選択UIの基本、ステータス表示の基本 InputController<-*SitePicker 見た目=skin
2+・選択UIの基本、ステータス表示の基本 IInputHandler-ITargetSelector<-*SitePicker 見た目=skin
33 ・[済]MRT昼夜同時描画/HitTest用マップ
44
55 ◎開発メモ
--- trunk/framework/debug/TestViewDrawer.cs (revision 29)
+++ trunk/framework/debug/TestViewDrawer.cs (revision 30)
@@ -22,7 +22,7 @@
2222 surface = null;
2323 }
2424
25- protected override void DrawCore(ISurfaceOld surfDest, Graphics g, IView owner, Rectangle rctDest, Region requestSrc) {
25+ protected override void DrawCore(ISurfaceOld surfDest, Graphics g, IView_old owner, Rectangle rctDest, Region requestSrc) {
2626 if (surface != null) {
2727 IGraphicManagerOld gm = GlobalModules.GraphicManagerOld;
2828 DrawParams dp = new DrawParams(surfDest, rctDest.Location);
@@ -42,7 +42,7 @@
4242 }
4343 }
4444
45- public override void Attach(IView view) {
45+ public override void Attach(IView_old view) {
4646 base.Attach(view);
4747 imgRef.AddRef();
4848 if (surface == null) {
@@ -51,7 +51,7 @@
5151 }
5252 }
5353
54- public override void Detach(IView view) {
54+ public override void Detach(IView_old view) {
5555 base.Detach(view);
5656 imgRef.ReleaseRef();
5757 if (AttachedViewCount == 0) {
--- trunk/framework/res/about.html (revision 29)
+++ trunk/framework/res/about.html (revision 30)
@@ -16,7 +16,7 @@
1616 <div align="right">cCopyright by <a href="mailto:rc-nao@rocket.ne.jp">C477</a> and <a href="mailto:kk@kohsuke.org">
1717 K.Kawaguchi</a> et al, 2002-
1818 <br>
19- <a href="http://www.rocket.ne.jp/%7Enao/">http://www.rocket.ne.jp/~nao</a>
19+ <a href="http://sourceforge.jp/users/c477/pf/NeoFT.Workshop/wiki/FrontPage">http://sourceforge.jp/users/c477/pf/NeoFT.Workshop/wiki/FrontPage</a>
2020 </div>
2121 <hr align="left" size="0">
2222 <strong>NeoFT</strong> is a free software, many codes and resources are
--- trunk/framework/framework/drawing/IViewDrawer.cs (revision 29)
+++ trunk/framework/framework/drawing/IViewDrawer.cs (revision 30)
@@ -10,10 +10,11 @@
1010 /// <summary>
1111 /// IDrawableView is drawing delegate for DrawablePanel
1212 /// </summary>
13- public interface IViewDrawer : IDisposable{
14- void Attach(IView view);
15- void Detach(IView view);
16- void Draw(Graphics g, IView owner, Rectangle destArea, Region requestSrc);
13+ [Obsolete]
14+ public interface IViewDrawer_old : IDisposable{
15+ void Attach(IView_old view);
16+ void Detach(IView_old view);
17+ void Draw(Graphics g, IView_old owner, Rectangle destArea, Region requestSrc);
1718 Size ContentSize { get; }
1819 Size ScrollUnit { get; }
1920 }
@@ -21,7 +22,8 @@
2122 /// <summary>
2223 /// the container of IViewDrawer should implements IView
2324 /// </summary>
24- public interface IView {
25+ [Obsolete]
26+ public interface IView_old {
2527 /// <summary>
2628 /// visible area of IViewDrawer content on this IView.
2729 /// </summary>
@@ -52,8 +54,8 @@
5254 /// <summary>
5355 /// Abstract class of IViewDrawer
5456 /// </summary>
55- public abstract class ViewDrawerBase : IViewDrawer{
56- protected List<IView> views = new List<IView>(4);
57+ public abstract class ViewDrawerBase : IViewDrawer_old{
58+ protected List<IView_old> views = new List<IView_old>(4);
5759 protected ISurfaceOld backSurface;
5860 protected bool doubleBuffered = true;
5961
@@ -62,19 +64,19 @@
6264
6365 public abstract Size ScrollUnit { get; }
6466
65- public virtual void Attach(IView view) {
67+ public virtual void Attach(IView_old view) {
6668 if (!views.Contains(view)) {
6769 views.Add(view);
6870 }
6971 }
7072
71- public virtual void Detach(IView view) {
73+ public virtual void Detach(IView_old view) {
7274 if (views.Contains(view)) {
7375 views.Remove(view);
7476 }
7577 }
7678
77- public virtual void Draw(Graphics g, IView owner, Rectangle destArea, Region requestSrc) {
79+ public virtual void Draw(Graphics g, IView_old owner, Rectangle destArea, Region requestSrc) {
7880 if (DoubleBuffered) {
7981 if (OffscreenSurface == null) {
8082 backSurface = PrepareOffscreenSurface();
@@ -109,12 +111,12 @@
109111 }
110112
111113 protected virtual void NotifyUpdated(Region updateRgn, bool callbackImmediately) {
112- foreach (IView vw in views) {
114+ foreach (IView_old vw in views) {
113115 vw.NotifyUpdate(updateRgn, callbackImmediately);
114116 }
115117 }
116118
117- protected abstract void DrawCore(ISurfaceOld surfDest, Graphics g, IView owner, Rectangle rctDest, Region requestSrc);
119+ protected abstract void DrawCore(ISurfaceOld surfDest, Graphics g, IView_old owner, Rectangle rctDest, Region requestSrc);
118120
119121 public bool DoubleBuffered {
120122 get { return doubleBuffered; }
--- trunk/core/core/game/PointerEventArgs.cs (nonexistent)
+++ trunk/core/core/game/PointerEventArgs.cs (revision 30)
@@ -0,0 +1,36 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Text;
4+using System.Windows.Forms;
5+using nft.framework.drawing;
6+
7+namespace nft.core.game {
8+ public class PointerEventArgs : EventArgs{
9+ protected MouseEventArgs eventOrg;
10+ protected IGame game;
11+ protected ISurface surface;
12+
13+ public PointerEventArgs(IGame gm, ISurface surf) {
14+ this.game = gm;
15+ this.surface = surf;
16+ }
17+
18+ public IGame Game {
19+ get {
20+ return game;
21+ }
22+ }
23+
24+ public ISurface Surface {
25+ get {
26+ return surface;
27+ }
28+ }
29+
30+ public MouseEventArgs OriginalEventArgs {
31+ get {
32+ return eventOrg;
33+ }
34+ }
35+ }
36+}
--- trunk/core/core/game/IGame.cs (revision 29)
+++ trunk/core/core/game/IGame.cs (revision 30)
@@ -19,6 +19,8 @@
1919 Clock Clock {get;}
2020 IClimateController ClimateController {get;}
2121 string Name {get;set;}
22+ IPointerHandler ActiveController {get; set;}
2223 //World world {get;}
24+ ViewCollection Views {get;}
2325 }
2426 }
--- trunk/core/core/game/GameManager.cs (revision 29)
+++ trunk/core/core/game/GameManager.cs (revision 30)
@@ -11,6 +11,8 @@
1111 using nft.framework.drawing;
1212 using System.Drawing;
1313 using nft.impl.view;
14+using nft.core.view;
15+using nft.core.geometry;
1416
1517 namespace nft.core.game
1618 {
@@ -57,8 +59,7 @@
5759 _curGame = newgame;
5860 _curMode = mode;
5961 //theFrame.SetSubTitle( );
60- GameViewPanel f = new GameViewPanel((GameImpl)_curGame);
61- theFrame.AddView(_curGame.Name, f);
62+ _curGame.Views.OpenNew();
6263 _curGame.Start();
6364 }
6465
--- trunk/core/core/game/ViewCollection.cs (nonexistent)
+++ trunk/core/core/game/ViewCollection.cs (revision 30)
@@ -0,0 +1,91 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Text;
4+using nft.core.view;
5+using nft.core.geometry;
6+using nft.framework;
7+
8+namespace nft.core.game {
9+ public class ViewCollection : IEnumerable<IView>{
10+ static protected IGameViewFactory ViewFactory {
11+ get {
12+ return GlobalModules.GetModule(typeof(IGameViewFactory)) as IGameViewFactory;
13+ }
14+ }
15+
16+ protected List<IView> views;
17+ protected IGame game;
18+ public ViewCollection(IGame _game) {
19+ game = _game;
20+ views = new List<IView>();
21+ }
22+
23+ public IGame Game {
24+ get {
25+ return game;
26+ }
27+ }
28+
29+ public virtual IView ActiveView {
30+ get {
31+ return views.Count > 0 ? views[0] : null;
32+ }
33+ set {
34+ if (value != null) {
35+ SetActive(value);
36+ }
37+ }
38+ }
39+
40+ public IView OpenNew() {
41+ IView v = CreateView();
42+ if (Add(v)) {
43+ return v;
44+ }else{
45+ v.Close();
46+ return null;
47+ }
48+ }
49+
50+ public void CloseAll() {
51+ foreach (IView v in views) {
52+ v.Close();
53+ }
54+ views.Clear();
55+ }
56+
57+#region protected methods for override
58+ protected virtual bool Add(IView v) {
59+ SetActive(v);
60+ return true;
61+ }
62+
63+ protected virtual bool Remove(IView v) {
64+ return views.Remove(v);
65+ }
66+
67+ protected virtual void SetActive(IView v) {
68+ if (views.Contains(v)) {
69+ views.Remove(v);
70+ }
71+ views.Insert(0, v);
72+ }
73+
74+ protected virtual IView CreateView() {
75+ return ViewFactory.Create(game, Location.UNPLACED);
76+ }
77+#endregion
78+
79+ #region IEnumerable implementation
80+ public IEnumerator<IView> GetEnumerator()
81+ {
82+ return views.GetEnumerator();
83+ }
84+
85+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
86+ {
87+ return GetEnumerator();
88+ }
89+ #endregion
90+ }
91+}
--- trunk/core/core/game/IQuarterView.cs (revision 29)
+++ trunk/core/core/game/IQuarterView.cs (revision 30)
@@ -7,10 +7,11 @@
77 using nft.framework.drawing;
88
99 namespace nft.core.game {
10+ [Obsolete]
1011 public interface IQuarterView {
1112 ViewFactor ViewFactor { get; }
1213 Control TargetControl { get; }
13- Location GetHitSprite(IView v, Point pt, out object tag);
14+ Location GetHitSprite(IView_old v, Point pt, out object tag);
1415 /*
1516 Location ConvertMousePos(IView v, Point pt);
1617 Location ConvertMousePos(IView v, Point pt, int unitHeight);
--- trunk/core/core/game/IPointerHandler.cs (nonexistent)
+++ trunk/core/core/game/IPointerHandler.cs (revision 30)
@@ -0,0 +1,13 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Text;
4+
5+namespace nft.core.game {
6+ public interface IPointerHandler {
7+ void OnAttach(IGame g);
8+ void OnDetach(IGame g);
9+ void OnMouseButtonDown(PointerEventArgs args);
10+ void OnMouseButtonUp(PointerEventArgs args);
11+ void OnMouseMove(PointerEventArgs args);
12+ }
13+}
--- trunk/core/core/view/IView.cs (nonexistent)
+++ trunk/core/core/view/IView.cs (revision 30)
@@ -0,0 +1,20 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Text;
4+using nft.impl.view;
5+using nft.core.geometry;
6+
7+namespace nft.core.view {
8+ public interface IView {
9+ SceneBuilder SceneBuilder {
10+ get;
11+ }
12+
13+ InterCardinalDirection UpperDirection {
14+ get;
15+ set;
16+ }
17+
18+ void Close();
19+ }
20+}
--- trunk/core/core/view/IGameViewFactory.cs (nonexistent)
+++ trunk/core/core/view/IGameViewFactory.cs (revision 30)
@@ -0,0 +1,13 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Text;
4+using nft.framework;
5+using nft.core.game;
6+using nft.core.geometry;
7+
8+namespace nft.core.view {
9+ public interface IGameViewFactory : IGlobalModule{
10+ IView Create(IGame game, Location center);
11+ IView Create(IGame game, Location center, int width, int height);
12+ }
13+}
--- trunk/core/core/view/ITargetSelector.cs (revision 29)
+++ trunk/core/core/view/ITargetSelector.cs (revision 30)
@@ -19,7 +19,7 @@
1919 this.status = stat;
2020 }
2121
22- EventTypes Status {
22+ EventTypes EventType {
2323 get {
2424 return status;
2525 }
--- trunk/core/core/structure/StructureCollection.cs (nonexistent)
+++ trunk/core/core/structure/StructureCollection.cs (revision 30)
@@ -0,0 +1,83 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Text;
4+using nft.core.geometry;
5+
6+namespace nft.core.structure {
7+ public class StructureCollection {
8+ protected List<Lot> list;
9+
10+ public StructureCollection() {
11+ }
12+
13+ public void Add(Lot l) {
14+ list.Add(l);
15+ }
16+
17+ public void Remove(Lot l) {
18+ list.Remove(l);
19+ }
20+
21+ public List<Lot> GetCollidings(Lot l) {
22+ List<Lot> result = new List<Lot>();
23+ foreach (Lot l2 in list) {
24+ if (l2 == l) continue;
25+ if (l2.IsCollide(l)) {
26+ // TODO more detalied evaluations.
27+ result.Add(l2);
28+ }
29+ }
30+ return result;
31+ }
32+
33+ public StructuresEnumerator GetEnumeratorForView(Rect3D region) {
34+ return new StructuresEnumerator(this, region);
35+ }
36+
37+ public class StructuresEnumerator : IEnumerable<Lot> {
38+ StructureCollection lots;
39+ Rect3D region;
40+ internal protected StructuresEnumerator(StructureCollection lots, Rect3D region) {
41+ this.lots = lots;
42+ this.region = region;
43+ }
44+
45+ public IEnumerator<Lot> GetEnumerator() {
46+ foreach(Lot l in lots.list){
47+ if(region.IsIntersect(l.Bounds)){
48+ yield return l;
49+ }
50+ }
51+ yield break;
52+ }
53+
54+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
55+ return GetEnumerator();
56+ }
57+ }
58+ public class PlanarStructuresEnumerator : IEnumerable<Lot> {
59+ StructureCollection lots;
60+ Rect3D region;
61+ internal protected PlanarStructuresEnumerator(StructureCollection lots, Rect3D region) {
62+ this.lots = lots;
63+ this.region = region;
64+ }
65+
66+ public IEnumerator<Lot> GetEnumerator() {
67+ foreach (Lot l in lots.list) {
68+ Rect3D r3d = l.Bounds;
69+ if (region.X>r3d.X2 || region.X2<r3d.X || region.Y>r3d.Y2 || region.Y2<r3d.Y) {
70+ continue; // Planar area (x,y) is outside of region
71+ }
72+ yield return l;
73+ }
74+ }
75+
76+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
77+ return GetEnumerator();
78+ }
79+ }
80+ }
81+
82+
83+}
--- trunk/core/core/structure/Lot.cs (revision 29)
+++ trunk/core/core/structure/Lot.cs (revision 30)
@@ -25,5 +25,21 @@
2525 public readonly object Category;
2626 public readonly int Level;
2727 public readonly Rect3D Bounds;
28+
29+ public virtual bool IsCollide(Lot other) {
30+ return Bounds.IsIntersect(other.Bounds) && other.IsCollideDetail(this);
31+ }
32+
33+ /// <summary>
34+ /// This method will called for advanced collision check,
35+ /// and sholud be called ONLY when 'other' collide with the bounds of this lot.
36+ /// So the simplest way is 'return true' if inside of this bounds is completely exclusive.
37+ /// Or override in inherited class to implement complexed collision check.
38+ /// </summary>
39+ /// <param name="other"></param>
40+ /// <returns></returns>
41+ internal protected virtual bool IsCollideDetail(Lot other) {
42+ return true;
43+ }
2844 }
2945 }
--- trunk/core/core_modules.xml (revision 29)
+++ trunk/core/core_modules.xml (revision 30)
@@ -14,6 +14,10 @@
1414 <class name="nft.ui.WinFormManager" codebase=".UI"/>
1515 <description>Form Manager based on System.Windows.Forms</description>
1616 </module>
17+ <module name="Game View Factory">
18+ <class name="nft.impl.view.GameViewFactory" codebase=".Core"/>
19+ <description>Default Game View Factory which produces GameViewPanel (based on System.Windows.Forms)</description>
20+ </module>
1721 <module name="Game Time Calendar">
1822 <class name="nft.core.schedule.Calendar" codebase=".Core"/>
1923 <description>Calendar For Game World</description>
--- trunk/core/impl/game/TerrainMapImpl.cs (revision 29)
+++ trunk/core/impl/game/TerrainMapImpl.cs (revision 30)
@@ -6,6 +6,7 @@
66 using System.Collections.Generic;
77 using ICDir = nft.core.geometry.InterCardinalDirection;
88 using ITerrainPiece = nft.core.geometry.ITerrainPiece;
9+using nft.core.structure;
910
1011 namespace nft.impl.game
1112 {
@@ -12,8 +13,8 @@
1213 /// <summary>
1314 /// TerrainMapImplは実際に地形データを配列に展開して保持する。
1415 /// </summary>
15- [Serializable]
16- public class TerrainMapImpl : ITerrainMap {
16+ [Serializable]
17+ public class TerrainMapImpl : ITerrainMap {
1718 protected delegate bool DiscontinuousChecker(TerrainMapImpl map, int x, int y);
1819 static protected DiscontinuousChecker[] checker;
1920 static TerrainMapImpl() {
@@ -28,9 +29,11 @@
2829 protected short[,] water;
2930 protected int heightOffset;
3031 protected Size3D size;
32+ protected StructureCollection structures = new StructureCollection();
3133
32- public TerrainMapImpl(ITerrainMap source) :
33- this(source, new Rectangle(0,0,source.Size.sx, source.Size.sy)) {}
34+ public TerrainMapImpl(ITerrainMap source) :
35+ this(source, new Rectangle(0, 0, source.Size.sx, source.Size.sy)) {
36+ }
3437
3538 public TerrainMapImpl(ITerrainMap source, Rectangle region) {
3639 this.heightOffset = source.HeightOffset;
@@ -42,8 +45,8 @@
4245 }
4346 this.size = new Size3D(sx, sy, source.Size.sz);
4447 this.hmap = new TerrainPiecePair[sx, sy];
45- int ox = region.Left;
46- int oy = region.Top;
48+ int ox = region.Left;
49+ int oy = region.Top;
4750
4851 for (int x = 0; x < sx; x++) {
4952 for (int y = 0; y < sy; y++) {
@@ -50,7 +53,7 @@
5053 hmap[x, y] = TerrainPiecePair.CreatePair(source, ox + x, oy + y, 1.0, CreatePiece);
5154 }
5255 }
53- }
56+ }
5457
5558 protected virtual TerrainPieceE CreatePiece(int ne, int nw, int sw, int se) {
5659 return new TerrainPieceE(ne, nw, sw, se);
@@ -60,19 +63,23 @@
6063 Dispose(false);
6164 }
6265
63- #region ITerrainMap メンバ
64- public Size3D Size { get{ return size; } }
66+ #region ITerrainMap メンバ
67+ public Size3D Size {
68+ get {
69+ return size;
70+ }
71+ }
6572
66- public int Height(int x, int y) {
73+ public int Height(int x, int y) {
6774 TerrainPiecePair pair = this[x, y];
6875 if (pair != null) {
6976 return (short)pair.MeanHeight;
7077 } else {
71- string t = string.Format("Height({0},{1}): argument out of range.",x,y);
72- Debug.WriteLine(t);
73- return -1;
74- }
75- }
78+ string t = string.Format("Height({0},{1}): argument out of range.", x, y);
79+ Debug.WriteLine(t);
80+ return -1;
81+ }
82+ }
7683
7784 public int DetailedHeight(double x, double y) {
7885 throw new NotImplementedException();
@@ -90,7 +97,11 @@
9097 }
9198 }
9299
93- public bool IsDetailedHeight { get { return false; } }
100+ public bool IsDetailedHeight {
101+ get {
102+ return false;
103+ }
104+ }
94105
95106 public int WaterDepth(int x, int y) {
96107 try {
@@ -103,21 +114,34 @@
103114 }
104115
105116 public int HeightOffset {
106- get { return heightOffset; }
117+ get {
118+ return heightOffset;
119+ }
107120 }
108121
109122 #endregion
110123
124+ public StructureCollection Structures {
125+ get {
126+ return structures;
127+ }
128+ }
129+
130+ public void GetObjectEnumerator(Rect3D hint, out IEnumerable<TerrainPiecePair> terrains, out IEnumerable<Lot> structures) {
131+ terrains = new TerrainPairEnumerator(this, hint);
132+ structures = this.structures.GetEnumeratorForView(hint);
133+ }
134+
111135 public IEnumerable<ITerrainPiece> this[int x, int y, ICDir viewupper] {
112136 get {
113137 try {
114138 return hmap[x, y].GetPieces(viewupper);
115139 } catch (IndexOutOfRangeException) {
116- Debug.WriteLine("The location (" + x + ", y=" + y + ") is OUTSIDE of the map{ size:(" + hmap.GetUpperBound(0) + "," + hmap.GetUpperBound(1)+")}");
140+ Debug.WriteLine("The location (" + x + ", y=" + y + ") is OUTSIDE of the map{ size:(" + hmap.GetUpperBound(0) + "," + hmap.GetUpperBound(1) + ")}");
117141 return NullEnumerator();
118142 }
119143 }
120- }
144+ }
121145
122146 [Obsolete]
123147 public bool IsCliffedBounds(Direction4 cellside, int x, int y) {
@@ -142,7 +166,7 @@
142166 }
143167 protected Rectangle[] districts;
144168 */
145-
169+
146170 // for fail safe
147171 static protected IEnumerable<ITerrainPiece> NullEnumerator() {
148172 yield break;
@@ -198,7 +222,7 @@
198222 }
199223
200224 static protected bool IsEastSideDiscontinuous(TerrainMapImpl map, int x, int y) {
201- if ( y < 0 || y >= map.Size.sy || x < 0 || map.Size.sx - x <= 1)
225+ if (y < 0 || y >= map.Size.sy || x < 0 || map.Size.sx - x <= 1)
202226 return true;
203227 try {
204228 TerrainPiecePair p1 = map[x, y];
@@ -244,5 +268,29 @@
244268 }
245269 }
246270 #endregion
271+
272+ public class TerrainPairEnumerator : IEnumerable<TerrainPiecePair> {
273+ TerrainMapImpl map;
274+ Rect3D region;
275+ internal protected TerrainPairEnumerator(TerrainMapImpl map, Rect3D region) {
276+ this.map = map;
277+ this.region = region;
278+ }
279+
280+ public IEnumerator<TerrainPiecePair> GetEnumerator() {
281+ int x2 = region.X2;
282+ int y2 = region.Y2;
283+ for (int y = region.Y; y < y2; y++) {
284+ for (int x = region.X; x < x2; x++) {
285+ yield return map.hmap[x, y];
286+ }
287+ }
288+ }
289+
290+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
291+ return GetEnumerator();
292+ }
293+ }
294+
247295 }
248296 }
--- trunk/core/impl/game/GameImpl.cs (revision 29)
+++ trunk/core/impl/game/GameImpl.cs (revision 30)
@@ -18,6 +18,8 @@
1818
1919 protected string name;
2020 protected TerrainMapImpl terrains;
21+ protected IPointerHandler activeHandler;
22+ protected ViewCollection views;
2123
2224 public GameImpl(string name, ITerrainMap map, Calendar cal) {
2325 if (cal == null) cal = Calendar.ActiveCalendar;
@@ -28,6 +30,7 @@
2830 this.terrains = (TerrainMapImpl)map;
2931 else
3032 this.terrains = new TerrainMapImpl(map);
33+ this.views = new ViewCollection(this);
3134 }
3235
3336 public GameImpl(ITerrainMap map, Calendar cal)
@@ -87,6 +90,25 @@
8790 set{ name = value; }
8891 }
8992
90- #endregion
91- }
93+ public IPointerHandler ActiveController {
94+ get {
95+ return activeHandler;
96+ }
97+ set {
98+ if (activeHandler != null) {
99+ activeHandler.OnDetach(this);
100+ }
101+ activeHandler = value;
102+ activeHandler.OnAttach(this);
103+ }
104+ }
105+
106+ public ViewCollection Views {
107+ get {
108+ return views;
109+ }
110+ }
111+ #endregion
112+
113+ }
92114 }
--- trunk/core/impl/view/GameViewPanel.cs (revision 29)
+++ trunk/core/impl/view/GameViewPanel.cs (revision 30)
@@ -1,7 +1,6 @@
11 using System;
22 using System.Collections.Generic;
33 using System.Text;
4-using nft.framework.drawing;
54 using nft.impl.game;
65 using nft.core.geometry;
76 using nft.core;
@@ -10,10 +9,12 @@
109 using System.Drawing;
1110 using System.Windows.Forms;
1211 using nft.core.game;
12+using nft.core.view;
13+using nft.framework.drawing;
1314
1415 namespace nft.impl.view
1516 {
16- public class GameViewPanel : UserControl
17+ public class GameViewPanel : UserControl, IView
1718 {
1819 SceneBuilder builder;
1920 bool prepared;
@@ -34,6 +35,7 @@
3435 }
3536 }
3637
38+ #region IView implementations
3739 public SceneBuilder SceneBuilder {
3840 get { return builder; }
3941 }
@@ -46,6 +48,11 @@
4648 }
4749 }
4850
51+ public void Close() {
52+ this.Dispose();
53+ }
54+ #endregion
55+
4956 void OnTouchPanelScroll(object sender, ScrollEventArgs e) {
5057 UpdateScrollParams(false);
5158 }
@@ -184,6 +191,7 @@
184191 protected override void OnPaintBackground(PaintEventArgs e) {
185192 }
186193 #endregion
194+
187195 }
188196
189197 /// <summary>
--- trunk/core/impl/view/GameViewFactory.cs (nonexistent)
+++ trunk/core/impl/view/GameViewFactory.cs (revision 30)
@@ -0,0 +1,42 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Text;
4+using nft.framework;
5+using nft.core.view;
6+using nft.ui.mainframe;
7+using nft.impl.game;
8+using nft.core.geometry;
9+
10+namespace nft.impl.view {
11+ public class GameViewFactory : IGameViewFactory {
12+ protected MainFrame MainFrame {
13+ get {
14+ return Main.mainFrame as MainFrame;
15+ }
16+ }
17+
18+ public GameViewFactory(ParamsReader node) {
19+ }
20+
21+ #region IGameViewFactory implementation
22+ public Type RegistType {
23+ get {
24+ return typeof(IGameViewFactory);
25+ }
26+ }
27+
28+ public IView Create(core.game.IGame game, Location center) {
29+ GameViewPanel f = new GameViewPanel((GameImpl)game);
30+ MainFrame.AddView(game.Name, f);
31+ if (center != Location.UNPLACED) {
32+ // TODO scroll to the initial location
33+ }
34+ return f;
35+ }
36+
37+ public IView Create(core.game.IGame game, Location center, int width, int height) {
38+ throw new NotImplementedException();
39+ }
40+ #endregion
41+ }
42+}
--- trunk/core/impl/selectors/CubeSelectorBase.cs (nonexistent)
+++ trunk/core/impl/selectors/CubeSelectorBase.cs (revision 30)
@@ -0,0 +1,68 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Text;
4+using nft.core.view;
5+using nft.impl.game;
6+using nft.core.game;
7+
8+namespace nft.impl.selectors {
9+ public class CubeSelectorBase : ITargetSelector, IPointerHandler {
10+ IGame game;
11+ public CubeSelectorBase() {
12+ }
13+
14+ protected TerrainMapImpl TerrainMap {
15+ get {
16+ return ((GameImpl)game).TerrainMap;
17+ }
18+ }
19+
20+ #region ITargetSelector implementation
21+ public int MaxPhases {
22+ get {
23+ return 1;
24+ }
25+ }
26+
27+ public int CurrentPhase {
28+ get {
29+ return 1;
30+ }
31+ }
32+
33+ public object CurrentSelection {
34+ get {
35+ throw new NotImplementedException();
36+ }
37+ }
38+
39+ public event TargetSelectorEvent OnSelectionChanged;
40+
41+ public event TargetSelectorEvent OnPhaseChanged;
42+
43+ public event TargetSelectorEvent OnViewChanged;
44+ #endregion
45+
46+ #region IPointerHandler implementation
47+ public void OnAttach(IGame g) {
48+ this.game = g;
49+ }
50+
51+ public void OnDetach(IGame g) {
52+ this.game = null;
53+ }
54+
55+ public void OnMouseButtonDown(PointerEventArgs args) {
56+ throw new NotImplementedException();
57+ }
58+
59+ public void OnMouseButtonUp(PointerEventArgs args) {
60+ throw new NotImplementedException();
61+ }
62+
63+ public void OnMouseMove(PointerEventArgs args) {
64+ throw new NotImplementedException();
65+ }
66+ #endregion
67+ }
68+}