1
1
using AvaGui . Models ;
2
+ using Avalonia . Media . Imaging ;
2
3
using OpenLoco . Common . Logging ;
3
4
using OpenLoco . Dat ;
4
5
using OpenLoco . Dat . FileParsing ;
@@ -17,7 +18,7 @@ namespace AvaGui.ViewModels
17
18
{
18
19
public record HexAnnotationLine ( string Address , string Data , int ? SelectionStart , int ? SelectionEnd ) ;
19
20
20
- public record AnimationSequence ( string Name , int StartIndex , int EndIndex ) ;
21
+ public record AnimationSequence ( string Name , int StartIndex , int EndIndex , int CurrentFrame = 0 ) ;
21
22
22
23
public class DatObjectEditorViewModel : ReactiveObject , ILocoFileViewModel
23
24
{
@@ -34,6 +35,24 @@ public class DatObjectEditorViewModel : ReactiveObject, ILocoFileViewModel
34
35
[ Reactive ]
35
36
public ObservableCollection < AnimationSequence > CurrentAnimations { get ; set ; }
36
37
38
+ public AnimationSequence CurrentAnimation => CurrentAnimations [ 0 ] ;
39
+
40
+ [ Reactive ]
41
+ public int CurrentFrame { get ; set ; }
42
+
43
+ [ Reactive ]
44
+ public Bitmap ? CurrentAnimationFrame
45
+ {
46
+ get
47
+ {
48
+ if ( ExtraContentViewModel is ImageTableViewModel itvm )
49
+ {
50
+ return itvm . Images [ CurrentFrame ] ;
51
+ }
52
+ return null ;
53
+ }
54
+ }
55
+
37
56
ObjectEditorModel Model { get ; init ; }
38
57
39
58
[ Reactive ]
@@ -82,6 +101,9 @@ public DatObjectEditorViewModel(FileSystemItem currentFile, ObjectEditorModel mo
82
101
83
102
_ = this . WhenAnyValue ( o => o . CurrentlySelectedHexAnnotation )
84
103
. Subscribe ( _ => UpdateHexDumpView ( ) ) ;
104
+
105
+ _ = this . WhenAnyValue ( o => o . CurrentFrame )
106
+ . Subscribe ( _ => this . RaisePropertyChanged ( nameof ( CurrentAnimationFrame ) ) ) ;
85
107
}
86
108
87
109
public void UpdateHexDumpView ( )
@@ -125,11 +147,13 @@ public void LoadObject()
125
147
var ( treeView , annotationIdentifiers ) = AnnotateFile ( cf . Filename , false , null ) ;
126
148
CurrentHexAnnotations = new ( treeView ) ;
127
149
DATDumpAnnotationIdentifiers = annotationIdentifiers ;
150
+ CurrentAnimations = [ new AnimationSequence ( "Normal" , 0 , 63 ) ] ;
128
151
}
129
152
else
130
153
{
131
154
StringTableViewModel = null ;
132
155
ExtraContentViewModel = null ;
156
+ CurrentAnimations = [ ] ;
133
157
}
134
158
}
135
159
else
0 commit comments