@@ -43,6 +43,44 @@ private int SpaceUsed
4343 public MainWindow ( )
4444 {
4545 InitializeComponent ( ) ;
46+
47+ WalkCheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . Walk , true ) ;
48+ ChocoboWalkCheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . ChocoboWalk , true ) ;
49+ BlackChocoboFlyCheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . BlackChocoboFly , true ) ;
50+ BlackChocoboLandCheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . BlackChocoboLand , true ) ;
51+ HovercraftCheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . Hovercraft , true ) ;
52+ AirshipFlyCheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . AirshipFly , true ) ;
53+ Walk2CheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . Walk2 , true ) ;
54+ BigWhaleFlyCheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . BigWhaleFly , true ) ;
55+ ObscuresHalfCheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . ObscuresHalf , true ) ;
56+ AirshipLandCheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . AirshipLand , true ) ;
57+ EnemyEncountersCheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . EnemyEncounters , true ) ;
58+ EntranceCheckBox . Checked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . Entrance , true ) ;
59+
60+ WalkCheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . Walk , false ) ;
61+ ChocoboWalkCheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . ChocoboWalk , false ) ;
62+ BlackChocoboFlyCheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . BlackChocoboFly , false ) ;
63+ BlackChocoboLandCheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . BlackChocoboLand , false ) ;
64+ HovercraftCheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . Hovercraft , false ) ;
65+ AirshipFlyCheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . AirshipFly , false ) ;
66+ Walk2CheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . Walk2 , false ) ;
67+ BigWhaleFlyCheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . BigWhaleFly , false ) ;
68+ ObscuresHalfCheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . ObscuresHalf , false ) ;
69+ AirshipLandCheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . AirshipLand , false ) ;
70+ EnemyEncountersCheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . EnemyEncounters , false ) ;
71+ EntranceCheckBox . Unchecked += ( sender , e ) => OnPropertyCheckBoxCheckChanged ( WorldTileProperties . Entrance , false ) ;
72+ }
73+
74+ private void OnPropertyCheckBoxCheckChanged ( WorldTileProperties property , bool isChecked )
75+ {
76+ if ( isChecked )
77+ {
78+ _rom . Tileset . TileProperties [ _selectedTile ] |= ( ushort ) property ;
79+ }
80+ else
81+ {
82+ _rom . Tileset . TileProperties [ _selectedTile ] &= ( ushort ) ~ property ;
83+ }
4684 }
4785
4886 private void OpenButton_Click ( object sender , RoutedEventArgs e )
@@ -97,11 +135,19 @@ private void Tileset_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
97135
98136 _selectedTile = 16 * y + x ;
99137
138+ HighlightSelectedTile ( x , y ) ;
139+
140+ CheckTilePropertyBoxes ( ) ;
141+ TilePropertiesGrid . Visibility = Visibility . Visible ;
142+ }
143+
144+ private void HighlightSelectedTile ( int x , int y )
145+ {
100146 var tileGroup = ( DrawingGroup ) ( ( DrawingImage ) Tileset . Source ) . Drawing ;
101147 tileGroup . Children . Remove ( _selectedTileDrawing ) ;
102148
103149 var geometry = new GeometryGroup ( ) ;
104- geometry . Children . Add ( new RectangleGeometry ( new Rect ( new Point ( 16 * x , 16 * y ) , new Size ( 16 , 16 ) ) ) ) ;
150+ geometry . Children . Add ( new RectangleGeometry ( new Rect ( new Point ( 16 * x + 1 , 16 * y + 1 ) , new Size ( 14 , 14 ) ) ) ) ;
105151 _selectedTileDrawing = new GeometryDrawing
106152 {
107153 Geometry = geometry ,
@@ -112,6 +158,24 @@ private void Tileset_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
112158 tileGroup . Children . Add ( _selectedTileDrawing ) ;
113159 }
114160
161+ private void CheckTilePropertyBoxes ( )
162+ {
163+ var tileProperties = ( WorldTileProperties ) _rom . Tileset . TileProperties [ _selectedTile ] ;
164+
165+ WalkCheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . Walk ) ;
166+ ChocoboWalkCheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . ChocoboWalk ) ;
167+ BlackChocoboFlyCheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . BlackChocoboFly ) ;
168+ BlackChocoboLandCheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . BlackChocoboLand ) ;
169+ HovercraftCheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . Hovercraft ) ;
170+ AirshipFlyCheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . AirshipFly ) ;
171+ Walk2CheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . Walk2 ) ;
172+ BigWhaleFlyCheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . BigWhaleFly ) ;
173+ ObscuresHalfCheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . ObscuresHalf ) ;
174+ AirshipLandCheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . AirshipLand ) ;
175+ EnemyEncountersCheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . EnemyEncounters ) ;
176+ EntranceCheckBox . IsChecked = tileProperties . HasFlag ( WorldTileProperties . Entrance ) ;
177+ }
178+
115179 private void Map_MouseLeftButtonDown ( object sender , MouseButtonEventArgs e )
116180 {
117181 if ( _selectedTile == - 1 )
@@ -225,7 +289,6 @@ private void LoadOverworldTiles()
225289 }
226290
227291 Map . Source = new DrawingImage ( rowGroup ) ;
228- Map . Stretch = Stretch . None ;
229292 }
230293 }
231294}
0 commit comments