• R/O
  • SSH
  • HTTPS

nlgp1: Commit


Commit MetaInfo

Revision604 (tree)
Time2010-11-20 17:58:09
Authorbiikame

Log Message

Dictionaryが追加順序を保持するという前提を仕様

Change Summary

Incremental Difference

--- trunk/Nlgp1/Nlgp1.Common/StageData.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.Common/StageData.cs (revision 604)
@@ -40,6 +40,11 @@
4040 private set;
4141 }
4242
43+ public IEnumerable< LayerData > Layers {
44+ get {
45+ return this.LayerTable.Values;
46+ }
47+ }
4348 /// <summary>
4449 /// レイヤを取得します。
4550 /// </summary>
@@ -46,7 +51,7 @@
4651 /// <param name="name">レイヤ名</param>
4752 /// <returns>レイヤ</returns>
4853 public LayerData GetLayer( string name ) {
49- return this.Layers.Single( layer => layer.Name == name );
54+ return this.LayerTable[ name ];
5055 }
5156
5257 /// <summary>
@@ -71,8 +76,8 @@
7176 public int ChipCount {
7277 get {
7378 int value = 0;
74- foreach( LayerData layer in this.Layers ) {
75- value += layer.Chips.Length;
79+ foreach( LayerData layer in this.LayerTable.Values ) {
80+ value += layer.ChipTable.Count;
7681 }
7782 return value;
7883 }
@@ -81,7 +86,7 @@
8186 /// <summary>
8287 /// レイヤセットを取得します。
8388 /// </summary>
84- public LayerData[] Layers {
89+ public Dictionary< string , LayerData > LayerTable {
8590 get;
8691 set;
8792 }
@@ -106,8 +111,8 @@
106111 /// </summary>
107112 /// <param name="name">レイヤ名</param>
108113 /// <returns>チップセット</returns>
109- public LayerChipData[] GetChips( string name ) {
110- return GetLayer( name ).Chips;
114+ public IEnumerable< LayerChipData > GetChips( string name ) {
115+ return LayerTable[ name ].Chips;
111116 }
112117
113118 #region マップの取得
@@ -115,7 +120,7 @@
115120 /// 指定のレイヤーのチップを参照します。
116121 /// </summary>
117122 public LayerChipData[,] GetMap( string name ) {
118- return GetLayer( name ).Map;
123+ return LayerTable[ name ].Map;
119124 }
120125
121126 /// <summary>
--- trunk/Nlgp1/Nlgp1.Common/DataLoader.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.Common/DataLoader.cs (revision 604)
@@ -26,18 +26,18 @@
2626 StageData stageData = new StageData( stageElement.GetAttribute( "Index" ).ToInt32() );
2727 int mapRowCount = stageElement.GetChildElement( "MapRowCount" ).GetText().ToInt32();
2828 int mapColumnCount = stageElement.GetChildElement( "MapColumnCount" ).GetText().ToInt32();
29- List< LayerData > layerDataList = new List< LayerData >();
29+ stageData.LayerTable = new Dictionary< string , LayerData >();
3030 XmlElement layersElement = stageElement.GetChildElement( "Layers" );
3131 foreach( XmlElement layerElement in layersElement.GetChildElements( "Layer" ) ) {
3232 LayerData layerData = new LayerData( layerElement.GetAttribute( "Name" ) );
3333 string chipsetPath = Path.Combine( Path.GetDirectoryName( path ) , layerElement.GetChildElement( "ChipsetPath" ).GetText() );
3434 string chipsetImagePath;
35- LayerChipData[] chipDatas;
36- LoadLayerChipsetFromFile( out chipsetImagePath , out chipDatas , chipsetPath );
35+ SortedDictionary< int , LayerChipData > chipTableData;
36+ LoadLayerChipsetFromFile( out chipsetImagePath , out chipTableData , chipsetPath );
3737 layerData.ChipsetImagePath = chipsetImagePath;
38- layerData.Chips = chipDatas;
38+ layerData.ChipTable = chipTableData;
3939 layerData.Map = new LayerChipData[ mapRowCount , mapColumnCount ];
40- LayerChipData noneChipData = layerData.Chips[ 0 ];
40+ LayerChipData noneChipData = layerData.ChipTable[ 0 ];
4141 for( int i = 0; i < layerData.Map.GetLength( 0 ); ++i ) {
4242 for( int j = 0; j < layerData.Map.GetLength( 1 ); ++j ) {
4343 layerData.Map[ i , j ] = noneChipData;
@@ -47,20 +47,19 @@
4747 int rowIndex = rowElement.GetAttribute( "Index" ).ToInt32();
4848 foreach( XmlElement columnElement in rowElement.GetChildElements( "Column" ) ) {
4949 int columnIndex = columnElement.GetAttribute( "Index" ).ToInt32();
50- layerData.Map[ rowIndex , columnIndex ] = layerData.Chips[ columnElement.GetText().ToInt32() ];
50+ layerData.Map[ rowIndex , columnIndex ] = layerData.ChipTable[ columnElement.GetText().ToInt32() ];
5151 }
5252 }
53- layerDataList.Add( layerData );
53+ stageData.LayerTable.Add( layerData.Name , layerData );
5454 };
55- stageData.Layers = layerDataList.ToArray();
5655 return stageData;
5756 }
5857
59- private static void LoadLayerChipsetFromFile( out string imagePath , out LayerChipData[] chipDatas , string path ) {
58+ private static void LoadLayerChipsetFromFile( out string imagePath , out SortedDictionary< int , LayerChipData > chipTableData , string path ) {
6059 XmlDocument document = LoadDocumentFromFile( path );
6160 XmlElement chipsetElement = document.GetChildElement( "LayerChipset" );
6261 imagePath = Path.Combine( Path.GetDirectoryName( path ) , chipsetElement.GetChildElement( "ImagePath" ).GetText() );
63- Dictionary< int , LayerChipData > chipDataTable = new Dictionary< int , LayerChipData >();
62+ chipTableData = new SortedDictionary< int , LayerChipData >();
6463 XmlElement chipsElement = chipsetElement.GetChildElement( "Chips" );
6564 foreach( XmlElement chipElement in chipsElement.GetChildElements( "Chip" ) ) {
6665 LayerChipData chipData = new LayerChipData( chipElement.GetAttribute( "Index" ).ToInt32() );
@@ -68,9 +67,8 @@
6867 chipData.Summary = chipElement.GetChildElement( "Summary" ).GetText();
6968 chipData.Type = chipElement.GetChildElement( "Type" ).GetText().ToEnum< LayerChipType >();
7069 chipData.Friction = chipElement.GetChildElement( "Friction" ).GetText().ToDouble();
71- chipDataTable.Add( chipData.Index , chipData );
70+ chipTableData.Add( chipData.Index , chipData );
7271 }
73- chipDatas = chipDataTable.ToSequence();
7472 }
7573
7674 private static XmlDocument LoadDocumentFromFile( string path ) {
@@ -97,13 +95,12 @@
9795 }
9896
9997 var layerNames = Enum.GetNames( typeof( LayerType ) );
100- List< LayerData > layerList = new List< LayerData >();
98+ stage.LayerTable = new Dictionary< string , LayerData >();
10199 for( int i = 0 ; i < layerNames.Length ; i++ ) {
102100 var name = layerNames[i];
103101 var layer = LoadLayer( document , Path.GetDirectoryName( path ) , name );
104- layerList.Add( layer );
102+ stage.LayerTable[ name ] = layer;
105103 }
106- stage.Layers = layerList.ToArray();
107104
108105 return stage;
109106 }
@@ -122,9 +119,9 @@
122119 var chipsetPath = Path.Combine( currentPath , chipsetFile.Replace( currentPath , string.Empty ).Trim( '\\' ).Replace( "..\\" , string.Empty ) );
123120 var chipsetImagePath = LoadLayerChipsetImagePath( chipsetPath );
124121
125- var chips = LoadLayerChipTable( chipsetPath );
126- var map = LoadMap( document , mapXmlPath , chips );
127- return new LayerData( name , chipsetPath , chipsetImagePath , chips , map );
122+ var chipTable = LoadLayerChipTable( chipsetPath );
123+ var map = LoadMap( document , mapXmlPath , chipTable.Values );
124+ return new LayerData( name , chipsetPath , chipsetImagePath , chipTable , map );
128125 }
129126
130127 /// <summary>
@@ -154,7 +151,7 @@
154151 /// </summary>
155152 /// <param name="path">チップセットへのパス</param>
156153 /// <returns>チップの配列</returns>
157- private static LayerChipData[] LoadLayerChipTable( string path ) {
154+ private static SortedDictionary< int , LayerChipData > LoadLayerChipTable( string path ) {
158155 if( string.IsNullOrEmpty( path ) )
159156 return null;
160157 if( File.Exists( path ) == false )
@@ -184,7 +181,7 @@
184181 chipTable.Add( chip.Index , chip );
185182 }
186183
187- return chipTable.ToSequence();
184+ return chipTable;
188185 }
189186
190187 /// <summary>
@@ -215,9 +212,9 @@
215212 /// </summary>
216213 /// <param name="document">XMLドキュメント</param>
217214 /// <param name="xmlPath">マップのXMLパス</param>
218- /// <param name="chipDatas">チップの配列</param>
215+ /// <param name="chips">チップの配列</param>
219216 /// <returns>マップ</returns>
220- private static LayerChipData[,] LoadMap( XmlDocument document , string xmlPath , LayerChipData[] chips ) {
217+ private static LayerChipData[,] LoadMap( XmlDocument document , string xmlPath , IEnumerable< LayerChipData > chips ) {
221218 var data = document.TryXmlPath( xmlPath );
222219 if( string.IsNullOrEmpty( data ) )
223220 return null;
--- trunk/Nlgp1/Nlgp1.Common/Utility.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.Common/Utility.cs (revision 604)
@@ -263,7 +263,7 @@
263263 }
264264
265265 public static T[] ToSequence< T >( this IDictionary< int , T > source ) {
266- T[] target = new T[ source.Max( item => item.Key ) + 1 ];
266+ T[] target = new T[ source.Max( item => item.Key ) ];
267267 foreach( var item in source ) {
268268 target[ item.Key ] = item.Value;
269269 }
--- trunk/Nlgp1/Nlgp1.Common/LayerData.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.Common/LayerData.cs (revision 604)
@@ -20,13 +20,13 @@
2020 /// <param name="name">レイヤ名</param>
2121 /// <param name="chipsetPath">チップセットへのパス</param>
2222 /// <param name="chipsetImagePath">イメージへのパス</param>
23- /// <param name="chipDatas">すべてのチップ</param>
23+ /// <param name="chips">すべてのチップ</param>
2424 /// <param name="map">マップ</param>
25- public LayerData( string name , string chipsetPath , string chipsetImagePath , LayerChipData[] chips , LayerChipData[,] map ) {
25+ public LayerData( string name , string chipsetPath , string chipsetImagePath , SortedDictionary< int , LayerChipData > chipTable , LayerChipData[,] map ) {
2626 this.Name = name;
2727 this.ChipsetPath = chipsetPath;
2828 this.ChipsetImagePath = chipsetImagePath;
29- this.Chips = chips;
29+ this.ChipTable = chipTable;
3030 this.Map = map;
3131 }
3232
@@ -54,10 +54,15 @@
5454 /// <summary>
5555 /// すべてのチップ
5656 /// </summary>
57- public LayerChipData[] Chips {
57+ public SortedDictionary< int , LayerChipData > ChipTable {
5858 get;
5959 set;
6060 }
61+ public IEnumerable< LayerChipData > Chips {
62+ get {
63+ return this.ChipTable.Values;
64+ }
65+ }
6166 /// <summary>
6267 /// マップ
6368 /// </summary>
--- trunk/Nlgp1/Nlgp1.Common/DataSaver.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.Common/DataSaver.cs (revision 604)
@@ -51,12 +51,12 @@
5151 document.Save( path );
5252 }
5353
54- private static void SaveLayerChipsetToFile( string path , string imagePath , LayerChipData[] chipDatas ) {
54+ private static void SaveLayerChipsetToFile( string path , string imagePath , IEnumerable< LayerChipData > chipsData ) {
5555 XmlDocument document = CreateDocument();
5656 XmlElement chipsetElement = document.AddChildElement( "LayerChipset" );
5757 chipsetElement.AddChildElement( "ImagePath" ).SetText( Utility.GetRelativePath( imagePath , Path.GetDirectoryName( path ) ) );
5858 XmlElement chipsNode = chipsetElement.AddChildElement( "Chips" );
59- foreach( LayerChipData chipData in chipDatas ) {
59+ foreach( LayerChipData chipData in chipsData ) {
6060 XmlElement chipElement = chipsNode.AddChildElement( "Chip" );
6161 chipElement.SetAttribute( "Index" , chipData.Index.ToString() );
6262 chipElement.AddChildElement( "Name" ).SetText( chipData.Name );
--- trunk/Nlgp1/Nlgp1.StageEditor/Notifies/NotifyLoader.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Notifies/NotifyLoader.cs (revision 604)
@@ -23,15 +23,13 @@
2323
2424 foreach( var layerData in stageData.Layers ) {
2525 var layerNotify = LayerInstance.Add( layerData.Name );
26- Dictionary< int , LayerChipNotify > chipNotifyTable = new Dictionary< int , LayerChipNotify >();
2726 foreach( var chipData in layerData.Chips ) {
28- var chipNotify = ChipsetInstance.Add( layerNotify , chipData.Index );
2927 var chipProperty = new LayerChipProperty();
3028 chipProperty.Name = chipData.Name;
3129 chipProperty.Friction = chipData.Friction;
3230 chipProperty.Type = chipData.Type.ToString();
3331 chipProperty.Summary = chipData.Summary;
34- chipNotify.SetProperty( chipProperty );
32+ ChipsetInstance.Add( layerNotify , new LayerChipNotify( chipData.Index , chipProperty ) );
3533 }
3634 layerNotify.ChipsetPath = layerData.ChipsetPath;
3735 LayerInstance.LoadImage( layerNotify , layerData.ChipsetImagePath );
@@ -39,12 +37,12 @@
3937 var mapNotify = new LayerChipNotify[ mapData.GetLength( 0 ) , mapData.GetLength( 1 ) ];
4038 for( int y = 0 ; y < mapNotify.GetLength( 0 ) ; y++ ) {
4139 for( int x = 0 ; x < mapNotify.GetLength( 1 ) ; x++ ) {
42- mapNotify[ y , x ] = layerNotify.ChipList[ mapData[ y , x ].Index ];
40+ mapNotify[ y , x ] = layerNotify.ChipTable[ mapData[ y , x ].Index ];
4341 }
4442 }
4543 LayerInstance.SetMap( layerNotify , mapNotify );
4644
47- editor.SetCurrentChip( layerNotify , layerNotify.ChipList[ 0 ] );
45+ editor.SetCurrentChip( layerNotify , layerNotify.ChipTable[ 0 ] );
4846 }
4947
5048 LayerInstance.SetCurrentLayer( 0 );
--- trunk/Nlgp1/Nlgp1.StageEditor/Notifies/LayerNotify.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Notifies/LayerNotify.cs (revision 604)
@@ -5,7 +5,6 @@
55 using System.ComponentModel;
66 using System.Drawing;
77 using Nlgp1.StageEditor.Notifies.LayerChipProperties;
8-using Nlgp1.Common;
98
109 namespace Nlgp1.StageEditor.Notifies {
1110 public class LayerNotify : INotifyPropertyChanged {
@@ -24,11 +23,17 @@
2423 get;
2524 private set;
2625 }
27- public List< LayerChipNotify > ChipList {
26+ public IEnumerable< LayerChipNotify > Chips {
27+ get {
28+ return this.ChipTable.Values;
29+ }
30+ }
31+ public LayerChipNotify[,] Map {
2832 get;
2933 private set;
3034 }
31- public LayerChipNotify[,] Map {
35+
36+ public SortedDictionary< int , LayerChipNotify > ChipTable {
3237 get;
3338 private set;
3439 }
@@ -36,7 +41,7 @@
3641 public LayerNotify( int row , int column ) {
3742 if( row > 0 && column > 0 ) {
3843 this.ChipsetImage = new ChipsetImage();
39- this.ChipList = new List< LayerChipNotify >();
44+ this.ChipTable = new SortedDictionary< int , LayerChipNotify >();
4045
4146 this.Map = new LayerChipNotify[ row , column ];
4247 for( int i = 0; i < this.Map.GetLength( 0 ); ++i ) {
@@ -49,7 +54,7 @@
4954 this.Name = "None";
5055 this.Map = new LayerChipNotify[ row , column ];
5156 this.ChipsetImage = ChipsetImage.None;
52- this.ChipList = new List< LayerChipNotify >();
57+ this.ChipTable = new SortedDictionary< int , LayerChipNotify >();
5358 }
5459 }
5560
@@ -64,28 +69,32 @@
6469 }
6570
6671 #region チップ操作
67- public LayerChipNotify AddChip( int chipIndex ) {
68- var createdChip = new LayerChipNotify( chipIndex );
69- this.ChipList.Add( createdChip );
70- var chipSequence = ChipList.ToDictionary( chip => chip.Index ).ToSequence();
71- this.ChipList.Clear();
72- this.ChipList.AddRange( chipSequence );
72+ public LayerChipNotify CreateChip() {
73+ return new LayerChipNotify( ChipTable.Keys.Max() + 1 );
74+ }
75+
76+ public void AddChip( LayerChipNotify chip ) {
77+ this.ChipTable.Add( chip.Index , chip );
7378 OnPropertyChanged( "AddChipData" );
74- return createdChip;
7579 }
7680
77- public void RemoveChip() {
78- if( this.ChipList.Count <= 1 )
81+ public void RemoveChip( LayerChipNotify removedChip ) {
82+ if( ChipTable.Count <= 1 )
7983 return;
8084
85+ if( removedChip == LayerChipNotify.None ) {
86+ ChipTable.Remove( removedChip.Index );
87+ OnPropertyChanged( "RemoveChipData" );
88+ return;
89+ }
8190
82- LayerChipNotify removedChip = this.ChipList[ this.ChipList.Count - 1 ];
83- this.ChipList.RemoveAt( this.ChipList.Count - 1 );
8491
92+ ChipTable.Remove( removedChip.Index );
93+
8594 for( int i = 0; i < this.Map.GetLength( 0 ); ++i ) {
8695 for( int j = 0; j < this.Map.GetLength( 1 ); ++j ) {
8796 if( this.Map[ i , j ] == removedChip ) {
88- this.Map[ i , j ] = this.ChipList[ 0 ];
97+ this.Map[ i , j ] = this.ChipTable[ 0 ];
8998 }
9099 }
91100 }
@@ -94,15 +103,21 @@
94103 }
95104
96105 public LayerChipNotify GetPreviousChip( LayerChipNotify chip ) {
106+ if( Chips.Contains( chip ) == false )
107+ return Chips.First();
108+
97109 var index = chip.Index;
98110 index = Math.Max( index - 1 , 0 );
99- return ChipList[index];
111+ return ChipTable[index];
100112 }
101113
102114 public LayerChipNotify GetNextChip( LayerChipNotify chip ) {
115+ if( Chips.Contains( chip ) == false )
116+ return Chips.Last();
117+
103118 var index = chip.Index;
104- index = Math.Min( index + 1 , ChipList.Count - 1 );
105- return ChipList[index];
119+ index = Math.Min( index + 1 , ChipTable.Count - 1 );
120+ return ChipTable[index];
106121 }
107122 #endregion
108123
@@ -120,7 +135,7 @@
120135 }
121136 public void SetChip(int chipIndex, int row, int column)
122137 {
123- this.SetChip( this.ChipList[ chipIndex ] , row , column );
138+ this.SetChip( this.ChipTable[ chipIndex ] , row , column );
124139 }
125140 //ID返す
126141 public int GetChipIndex(int row, int column)
--- trunk/Nlgp1/Nlgp1.StageEditor/Notifies/LayerChipNotify.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Notifies/LayerChipNotify.cs (revision 604)
@@ -43,6 +43,11 @@
4343 this.Property = chipProperty;
4444 }
4545
46+ public LayerChipNotify( int index , LayerChipProperty chipProperty ) {
47+ this.Index = index;
48+ this.Property = chipProperty;
49+ }
50+
4651 public void SetIndex( int index ) {
4752 this.Index = index;
4853
--- trunk/Nlgp1/Nlgp1.StageEditor/Notifies/NotifySaver.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Notifies/NotifySaver.cs (revision 604)
@@ -18,31 +18,29 @@
1818
1919 var stageData = new StageData( 0 );
2020
21- List< LayerData > layerDataList = new List< LayerData >();
21+ stageData.LayerTable = new Dictionary< string , LayerData >();
2222 foreach( var layerNotify in stageNotify.LayerList ) {
2323 var layerData = new LayerData( layerNotify.Name );
2424 layerData.ChipsetPath = layerNotify.ChipsetPath;
2525 layerData.ChipsetImagePath = layerNotify.ChipsetImage.Path;
26- Dictionary< int , LayerChipData > chipDataTable = new Dictionary< int ,LayerChipData >();
27- foreach( var chipNotify in layerNotify.ChipList ) {
26+ layerData.ChipTable = new SortedDictionary< int ,LayerChipData >();
27+ foreach( var chipNotify in layerNotify.Chips ) {
2828 var chipData = new LayerChipData( chipNotify.Index );
2929 chipData.Name = chipNotify.Property.Name;
3030 chipData.Summary = chipNotify.Property.Summary;
3131 chipData.Type = chipNotify.Property.Type.ToEnum< LayerChipType >();
3232 chipData.Friction = chipNotify.Property.Friction;
33- chipDataTable.Add( chipData.Index , chipData );
33+ layerData.ChipTable.Add( chipData.Index , chipData );
3434 }
35- layerData.Chips = chipDataTable.ToSequence();
3635 var mapNotify = layerNotify.Map;
3736 layerData.Map = new LayerChipData[ mapNotify.GetLength( 0 ) , mapNotify.GetLength( 1 ) ];
3837 for( int y = 0 ; y < mapNotify.GetLength( 0 ) ; y++ ) {
3938 for( int x = 0 ; x < mapNotify.GetLength( 1 ) ; x++ ) {
40- layerData.Map[ y , x ] = layerData.Chips[ mapNotify[ y , x ].Index ];
39+ layerData.Map[ y , x ] = layerData.ChipTable[ mapNotify[ y , x ].Index ];
4140 }
4241 }
43- layerDataList.Add( layerData );
42+ stageData.LayerTable.Add( layerData.Name , layerData );
4443 }
45- stageData.Layers = layerDataList.ToArray();
4644
4745 stageData.Save( path );
4846 stageNotify.SetPath( path );
@@ -65,8 +63,8 @@
6563
6664 var sameChipFunc = new Action( () => {
6765 foreach( var layer in layerList )
68- foreach( var chip1 in layer.ChipList )
69- foreach( var chip2 in layer.ChipList ) {
66+ foreach( var chip1 in layer.Chips )
67+ foreach( var chip2 in layer.Chips ) {
7068 if( chip1 == chip2 )
7169 continue;
7270 if( chip1.Property.Name != chip2.Property.Name )
--- trunk/Nlgp1/Nlgp1.StageEditor/Controls/LayerAdderControl.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Controls/LayerAdderControl.cs (revision 604)
@@ -12,6 +12,8 @@
1212 {
1313 public partial class LayerAdderControl : UserControl
1414 {
15+ private IEnumerable< int > validIndexList;
16+
1517 public LayerAdderControl()
1618 {
1719 InitializeComponent();
@@ -43,6 +45,7 @@
4345
4446 private void UpdateValidList(LayerNotify layer)
4547 {
48+ this.validIndexList = layer.ChipTable.Keys;
4649 }
4750
4851 private void AddButton_Click(object sender, EventArgs e)
--- trunk/Nlgp1/Nlgp1.StageEditor/Controls/LayerChipsetControl.Designer.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Controls/LayerChipsetControl.Designer.cs (revision 604)
@@ -81,6 +81,7 @@
8181 this.DeleteButton.TabIndex = 2;
8282 this.DeleteButton.Text = "削除";
8383 this.DeleteButton.UseVisualStyleBackColor = true;
84+
8485 //
8586 // ImageLoadButton
8687 //
@@ -110,7 +111,7 @@
110111 // CommandPanel
111112 //
112113 this.CommandPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
113- | System.Windows.Forms.AnchorStyles.Right)));
114+ | System.Windows.Forms.AnchorStyles.Right)));
114115 this.CommandPanel.Controls.Add(this.SettingButton);
115116 this.CommandPanel.Controls.Add(this.DeleteButton);
116117 this.CommandPanel.Controls.Add(this.ImageLoadButton);
--- trunk/Nlgp1/Nlgp1.StageEditor/Controls/MotionImageCreaterForm.Designer.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Controls/MotionImageCreaterForm.Designer.cs (revision 604)
@@ -263,7 +263,7 @@
263263 // chipSetSave
264264 //
265265 this.chipSetSave.DefaultExt = "png";
266- this.chipSetSave.FileName = "chipDatas.png";
266+ this.chipSetSave.FileName = "chips.png";
267267 this.chipSetSave.Filter = "PNGファイル|*.png";
268268 this.chipSetSave.RestoreDirectory = true;
269269 this.chipSetSave.Title = "チップセットの保存";
--- trunk/Nlgp1/Nlgp1.StageEditor/Controls/LayerChipsetControl.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Controls/LayerChipsetControl.cs (revision 604)
@@ -12,7 +12,7 @@
1212 public partial class LayerChipsetControl : UserControl {
1313 private int chipSize = 1;
1414 private ChipsetImage chipsetImage = ChipsetImage.None;
15- private List< LayerChipNotify > chipList = new List< LayerChipNotify >();
15+ private SortedDictionary< int , LayerChipNotify > chipTable = new SortedDictionary< int , LayerChipNotify >();
1616 private LayerNotify currentLayer = LayerNotify.None;
1717 private LayerChipNotify currentChip = LayerChipNotify.None;
1818
@@ -75,7 +75,7 @@
7575 this.currentLayer = editor.CurrentLayer;
7676 this.currentChip = editor.CurrentChip;
7777 this.chipsetImage = currentLayer.ChipsetImage;
78- this.chipList = currentLayer.ChipList;
78+ this.chipTable = currentLayer.ChipTable;
7979
8080 this.CommandPanel.Visible = ( currentLayer != LayerNotify.None );
8181
@@ -85,13 +85,13 @@
8585 #endregion
8686
8787 private void UpdateSize( object sender , EventArgs e ) {
88- if( chipList.Count == 0 )
88+ if( chipTable.Count == 0 )
8989 return;
9090
9191 var clientWidth = ThumbnailClientWidth;
9292 var clientHeight = ChipThumbnailBase.Height;
9393
94- var chipNum = chipList.Count;
94+ var chipNum = chipTable.Count;
9595
9696 var width = ( clientWidth / chipSize ) * chipSize;
9797 var column = width / chipSize;
@@ -124,10 +124,10 @@
124124 var y = e.Y / chipSize;
125125 var gridNumber = x + y * column;
126126
127- if( gridNumber >= chipList.Count )
127+ if( gridNumber >= chipTable.Count )
128128 return;
129129
130- var chip = chipList[gridNumber];
130+ var chip = chipTable[gridNumber];
131131
132132 OnChipClicked( chip );
133133 }
@@ -139,7 +139,7 @@
139139
140140 var gridPen = Pens.Black;
141141 var i = 0;
142- foreach( var chip in chipList ) {
142+ foreach( var chip in chipTable.Values ) {
143143 var x = ( i % column ) * chipSize;
144144 var y = ( i / column ) * chipSize;
145145 var imageNumber = chip.Index;
--- trunk/Nlgp1/Nlgp1.StageEditor/Controls/StageEditorForm.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Controls/StageEditorForm.cs (revision 604)
@@ -615,7 +615,7 @@
615615 {
616616 for (int j = 0; j < layer.Map.GetLength( 1 ); j++)
617617 {
618- layer.Map[ i , j ] = layer.ChipList[ 0 ];
618+ layer.Map[ i , j ] = layer.ChipTable[ 0 ];
619619 }
620620 }
621621 }
@@ -643,7 +643,7 @@
643643 targetMap[i, j] = sourceMap[i, j];
644644 }
645645 else {
646- targetMap[i, j] = layer.ChipList[0];
646+ targetMap[i, j] = layer.ChipTable[0];
647647 }
648648 }
649649 }
--- trunk/Nlgp1/Nlgp1.StageEditor/Controls/Events/LayersetControlEvent.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Controls/Events/LayersetControlEvent.cs (revision 604)
@@ -6,7 +6,6 @@
66 using Nlgp1.StageEditor.Controls;
77 using System.Windows.Forms;
88 using Nlgp1.StageEditor.Instances;
9-using Nlgp1.StageEditor.Notifies.LayerChipProperties;
109
1110 namespace Nlgp1.StageEditor.Controls.Events
1211 {
@@ -18,7 +17,7 @@
1817 {
1918 var layer = LayerInstance.Add(e.Name);
2019 //LayerController.Add(e.Name, e.DefaultChipID);
21- ChipsetInstance.Add(layer);
20+ ChipsetInstance.Add(layer, layer.CreateChip());
2221 };
2322
2423 layersetControl.LayerTabSelected += (sender, e) =>
--- trunk/Nlgp1/Nlgp1.StageEditor/Controls/Events/LayerChipsetControlEvent.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Controls/Events/LayerChipsetControlEvent.cs (revision 604)
@@ -6,7 +6,6 @@
66 using Nlgp1.StageEditor.Controls;
77 using System.Windows.Forms;
88 using Nlgp1.StageEditor.Instances;
9-using Nlgp1.StageEditor.Notifies.LayerChipProperties;
109
1110 namespace Nlgp1.StageEditor.Controls.Events
1211 {
@@ -15,7 +14,7 @@
1514 public static void Initialize(LayerChipsetControl chipsetControl, EditorNotify editor, StageNotify stage)
1615 {
1716 var commandTable = new Dictionary<string, Action>();
18- commandTable["Add"] = () => ChipsetInstance.Add(editor.CurrentLayer);
17+ commandTable["Add"] = () => ChipsetInstance.Add(editor.CurrentLayer, editor.CurrentLayer.CreateChip());
1918 commandTable["Delete"] = () =>
2019 {
2120 var response = MessageBox.Show("本当に削除しますか?ステージは保存されてないかもしれませんよ?", "確認", MessageBoxButtons.YesNoCancel);
@@ -26,7 +25,7 @@
2625 }
2726 else if (response == DialogResult.Yes)
2827 {
29- ChipsetInstance.Remove(editor.CurrentLayer);
28+ ChipsetInstance.Remove(editor.CurrentLayer, editor.CurrentChip);
3029 }
3130
3231 };
--- trunk/Nlgp1/Nlgp1.StageEditor/Controls/Events/LayerControlEvent.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Controls/Events/LayerControlEvent.cs (revision 604)
@@ -26,7 +26,7 @@
2626 CommanTable["Clear"] = () => {
2727 for( int i = 0 ; i < layer.Map.GetLength( 0 ) ; i++ ) {
2828 for( int j = 0 ; j < layer.Map.GetLength( 1 ) ; j++ ) {
29- layer.Map[ i , j ] = layer.ChipList[ 0 ];
29+ layer.Map[ i , j ] = layer.ChipTable[ 0 ];
3030 }
3131 }
3232 layer.OnPropertyChanged( "SetGridData" );
--- trunk/Nlgp1/Nlgp1.StageEditor/Instances/LayerChipsetInstance.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Instances/LayerChipsetInstance.cs (revision 604)
@@ -21,37 +21,28 @@
2121 ChipsetInstance.editor = editor;
2222 }
2323
24- public static LayerChipNotify Add(LayerNotify layer)
24+ public static void Add(LayerNotify layer, LayerChipNotify chip )
2525 {
26- return ChipsetInstance.Add(layer, layer.ChipList.Count);
27- }
28-
29- public static LayerChipNotify Add(LayerNotify layer, int chipIndex)
30- {
31- var chip = layer.AddChip(chipIndex);
3226 chip.PropertyChanged += stageEditor.MapControl.ChipData_PropertyChanged;
3327 chip.PropertyChanged += stageEditor.LayerChipControl.ChipData_PropertyChanged;
3428 chip.PropertyChanged += stageEditor.LayerChipsetControl.ChipData_PropertyChanged;
3529
30+ layer.AddChip(chip);
3631 editor.SetCurrentChip(layer, chip);
3732 if (editor.CurrentLayer == layer)
3833 {
3934 editor.CurrentChip = chip;
4035 }
41- return chip;
4236 }
4337
44- private static void InitializeChip(LayerChipNotify chip) {
45- }
46-
47- public static void Remove(LayerNotify layer)
38+ public static void Remove(LayerNotify layer, LayerChipNotify chip)
4839 {
49- var previousChip = layer.GetPreviousChip(editor.CurrentChip);
50- layer.RemoveChip();
51- editor.SetCurrentChip(layer, previousChip);
40+ var prevChip = layer.GetPreviousChip(editor.CurrentChip);
41+ layer.RemoveChip(chip);
42+ editor.SetCurrentChip(layer, prevChip);
5243 if (editor.CurrentLayer == layer)
5344 {
54- editor.CurrentChip = previousChip;
45+ editor.CurrentChip = prevChip;
5546 }
5647 }
5748
--- trunk/Nlgp1/Nlgp1.StageEditor/Instances/LayerInstance.cs (revision 603)
+++ trunk/Nlgp1/Nlgp1.StageEditor/Instances/LayerInstance.cs (revision 604)
@@ -11,10 +11,10 @@
1111 {
1212 public static class LayerInstance
1313 {
14- private class Data
14+ private class LayerData
1515 {
1616 public LayerNotify layer;
17- public LayerSettingNotify layerSetting;
17+ public LayerSettingNotify viewerSetting;
1818 public LayerTabPage layerTabPage;
1919 }
2020
@@ -21,7 +21,7 @@
2121 private static StageEditorForm stageEditor;
2222 private static StageNotify stage;
2323 private static EditorNotify editor;
24- private static Dictionary<LayerNotify, Data> layerDataTable;
24+ private static Dictionary<LayerNotify, LayerData> layerDataTable;
2525
2626 public static void Initialize(StageEditorForm stageEditor, EditorNotify editor, StageNotify stage)
2727 {
@@ -28,7 +28,7 @@
2828 LayerInstance.stageEditor = stageEditor;
2929 LayerInstance.stage = stage;
3030 LayerInstance.editor = editor;
31- LayerInstance.layerDataTable = new Dictionary<LayerNotify, Data>();
31+ LayerInstance.layerDataTable = new Dictionary<LayerNotify, LayerData>();
3232 }
3333
3434 public static void LoadImage(LayerNotify layer, string path)
@@ -39,23 +39,23 @@
3939 public static LayerNotify Add(string name)
4040 {
4141 var layer = stage.CreateLayer(name);
42- var layerSetting = editor.CreateLayerSetting();
42+ var viewerSetting = editor.CreateLayerSetting();
4343 var layerTabPage = stageEditor.LayersetControl.CreateLayer(name);
44- LayerControlEvent.Initialize(layerTabPage, layer, layerSetting);
44+ LayerControlEvent.Initialize(layerTabPage, layer, viewerSetting);
4545
4646 stageEditor.LayersetControl.AddLayer(layerTabPage);
4747 stage.AddLayer(layer);
48- editor.AddLayer(layer, layerSetting);
48+ editor.AddLayer(layer, viewerSetting);
4949
5050 layer.PropertyChanged += stageEditor.MapControl.ChipGridData_PropertyChanged;
5151 layer.PropertyChanged += stageEditor.LayerChipControl.ChipGridData_PropertyChanged;
5252 layer.PropertyChanged += stageEditor.LayerChipsetControl.ChipGridData_PropertyChanged;
5353 layer.PropertyChanged += stageEditor.LayersetControl.ChipGridData_PropertyChanged;
54- layerSetting.PropertyChanged += stageEditor.MapControl.ViewSettingData_PropertyChanged;
54+ viewerSetting.PropertyChanged += stageEditor.MapControl.ViewSettingData_PropertyChanged;
5555
56- var data = new Data();
56+ var data = new LayerData();
5757 data.layer = layer;
58- data.layerSetting = layerSetting;
58+ data.viewerSetting = viewerSetting;
5959 data.layerTabPage = layerTabPage;
6060 layerDataTable[layer] = data;
6161
Show on old repository browser