diff --git a/Images/PLAY.bmp b/Images/PLAY.bmp new file mode 100644 index 0000000..f2da6cc Binary files /dev/null and b/Images/PLAY.bmp differ diff --git a/Images/STOP.bmp b/Images/STOP.bmp new file mode 100644 index 0000000..88cfa9f Binary files /dev/null and b/Images/STOP.bmp differ diff --git a/animate.lfm b/animate.lfm index bdb8eae..e9518e7 100644 --- a/animate.lfm +++ b/animate.lfm @@ -12,10 +12,85 @@ object AnimationForm: TAnimationForm LCLVersion = '3.4.0.0' object Panel1: TPanel Left = 32 - Height = 144 + Height = 209 Top = 8 - Width = 144 + Width = 208 + ClientHeight = 209 + ClientWidth = 208 TabOrder = 6 + object FPSTrackBar: TTrackBar + Left = 168 + Height = 128 + Top = 8 + Width = 25 + Max = 60 + Min = 1 + OnChange = FPSTrackBarChange + Orientation = trVertical + Position = 1 + TickMarks = tmTopLeft + TabOrder = 0 + end + object Image2: TImage + Left = 88 + Height = 32 + Top = 168 + Width = 32 + OnClick = StopButtonClick + Picture.Data = { + 07544269746D617076020000424D760200000000000076000000280000002000 + 0000200000000100040000000000000200000000000000000000000000000000 + 000000000000AA00000000AA0000AAAA00000000AA00AA00AA000055AA00AAAA + AA0055555500FA55550055FA5500FAFA55005555FA00FA55FA0055FAFA00FAFA + FA00000000000000000000000000000000000FF0000000000000000000000000 + 00000FF000000000000000000000000000000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FF7777777777777777777777777 + 00000FF777700000000000000000777700000FF7777000000000000000007777 + 00000FF777700000000000000000777700000FF7777000000000000000007777 + 00000FF777700000000000000000777700000FF7777000000000000000007777 + 00000FF777700000000000000000777700000FF7777000000000000000007777 + 00000FF777700000000000000000777700000FF7777000000000000000007777 + 00000FF777700000000000000000777700000FF7777000000000000000007777 + 00000FF777700000000000000000777700000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FFFFFFFFFFFFFFFFFFFFFFFFFFF + FF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000 + 0000 + } + end + object Image1: TImage + Left = 48 + Height = 32 + Top = 168 + Width = 32 + OnClick = PlayButtonClick + Picture.Data = { + 07544269746D617076020000424D760200000000000076000000280000002000 + 0000200000000100040000000000000200000000000000000000000000000000 + 000000000000AA00000000AA0000AAAA00000000AA00AA00AA000055AA00AAAA + AA0055555500FA55550055FA5500FAFA55005555FA00FA55FA0055FAFA00FAFA + FA00000000000000000000000000000000000FF0000000000000000000000000 + 00000FF000000000000000000000000000000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FF7777777777777777777777777 + 00000FF777777777707777777777777700000FF7777777777007777777777777 + 00000FF777777777700077777777777700000FF7777777777000077777777777 + 00000FF777777777700000777777777700000FF7777777777000000777777777 + 00000FF777777777700000007777777700000FF7777777777000000777777777 + 00000FF777777777700000777777777700000FF7777777777000077777777777 + 00000FF777777777700077777777777700000FF7777777777007777777777777 + 00000FF777777777707777777777777700000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FF7777777777777777777777777 + 00000FF777777777777777777777777700000FFFFFFFFFFFFFFFFFFFFFFFFFFF + FF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000 + 0000 + } + end end object TopSplitter: TSplitter AnchorSideLeft.Control = Owner @@ -78,7 +153,7 @@ object AnimationForm: TAnimationForm Color = 15790320 ParentBackground = False ParentColor = False - TabOrder = 3 + TabOrder = 1 object SpriteListView: TListView AnchorSideLeft.Control = LeftPanel AnchorSideTop.Control = LeftPanel @@ -103,6 +178,7 @@ object AnimationForm: TAnimationForm ViewStyle = vsIcon OnDblClick = SpriteListViewDblClick OnDragDrop = SpriteListViewDragDrop + OnDragOver = SpriteListViewDragOver end end object MiddlePanel: TPanel @@ -121,7 +197,7 @@ object AnimationForm: TAnimationForm Caption = 'MiddlePanel' ClientHeight = 493 ClientWidth = 768 - TabOrder = 4 + TabOrder = 2 object CurrentAnimListView: TListView AnchorSideLeft.Control = MiddlePanel AnchorSideTop.Control = MiddlePanel @@ -168,7 +244,7 @@ object AnimationForm: TAnimationForm Caption = 'RightPanel' ClientHeight = 493 ClientWidth = 191 - TabOrder = 5 + TabOrder = 3 object AllAnimListView: TListView AnchorSideLeft.Control = RightPanel AnchorSideTop.Control = RightPanel @@ -178,7 +254,6 @@ object AnimationForm: TAnimationForm AnchorSideBottom.Side = asrBottom Left = 1 Height = 491 - Hint = 'My Hint' Top = 1 Width = 189 Anchors = [akTop, akLeft, akRight, akBottom] @@ -196,16 +271,16 @@ object AnimationForm: TAnimationForm end end object CurrentAnimationImageList: TImageList - Left = 816 - Top = 64 + Left = 808 + Top = 592 end object AnimThumbImageList: TImageList - Left = 816 - Top = 8 + Left = 792 + Top = 520 end object PopupMenu1: TPopupMenu - Left = 392 - Top = 144 + Left = 424 + Top = 664 object CopyMenu: TMenuItem Caption = 'Copy' OnClick = CopyMenuClick @@ -224,16 +299,16 @@ object AnimationForm: TAnimationForm end end object PopupMenu2: TPopupMenu - Left = 264 - Top = 144 + Left = 224 + Top = 664 object CopyFromThumbView: TMenuItem Caption = 'Copy' OnClick = CopyFromThumbViewClick end end object PopupMenu3: TPopupMenu - Left = 840 - Top = 136 + Left = 816 + Top = 664 object NewAnimationMenu: TMenuItem Caption = 'New Animation' OnClick = NewAnimationMenuClick @@ -246,12 +321,12 @@ object AnimationForm: TAnimationForm object Timer1: TTimer OnTimer = Timer1Timer OnStartTimer = Timer1StartTimer - Left = 216 - Top = 56 + Left = 224 + Top = 312 end object MainMenu1: TMainMenu - Left = 296 - Top = 56 + Left = 312 + Top = 312 object MenuItem1: TMenuItem Caption = 'File' object MenuItem8: TMenuItem @@ -295,15 +370,15 @@ object AnimationForm: TAnimationForm end end object SelectDirectoryDialog1: TSelectDirectoryDialog - Left = 352 - Top = 56 + Left = 384 + Top = 328 end object SaveDialog1: TSaveDialog - Left = 525 - Top = 21 + Left = 624 + Top = 424 end object OpenDialog1: TOpenDialog - Left = 608 - Top = 32 + Left = 616 + Top = 344 end end diff --git a/animate.pas b/animate.pas index b192e06..5479c8e 100644 --- a/animate.pas +++ b/animate.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Buttons, ExtCtrls, - ComCtrls, Menus, StdCtrls,AnimBase,rmthumb,rwpng,fileprops; + ComCtrls, Menus, StdCtrls, Arrow,AnimBase,rmthumb,rwpng,fileprops; type @@ -20,6 +20,8 @@ TAnimationForm = class(TForm) DeleteMenu: TMenuItem; CopyFromThumbView: TMenuItem; AnimDeleteMenu: TMenuItem; + Image1: TImage; + Image2: TImage; MainMenu1: TMainMenu; MenuItem1: TMenuItem; MenuItem10: TMenuItem; @@ -51,10 +53,12 @@ TAnimationForm = class(TForm) TopSplitter: TSplitter; LeftSplitter: TSplitter; RightSplitter: TSplitter; + FPSTrackBar: TTrackBar; procedure AddFrameMenuClick(Sender: TObject); procedure AllAnimListViewClick(Sender: TObject); procedure AllAnimListViewShowHint(Sender: TObject; HintInfo: PHintInfo); procedure AnimDeleteMenuClick(Sender: TObject); + procedure Arrow1Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure CopyFromThumbViewClick(Sender: TObject); procedure CopyMenuClick(Sender: TObject); @@ -77,15 +81,21 @@ TAnimationForm = class(TForm) procedure MenuItem9Click(Sender: TObject); procedure NewAnimationMenuClick(Sender: TObject); procedure PasteMenuClick(Sender: TObject); + procedure PlayButtonClick(Sender: TObject); procedure SpriteListViewDblClick(Sender: TObject); procedure SpriteListViewDragDrop(Sender, Source: TObject; X, Y: Integer); + procedure SpriteListViewDragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure StopButtonClick(Sender: TObject); procedure Timer1StartTimer(Sender: TObject); procedure Timer1Timer(Sender: TObject); + procedure FPSTrackBarChange(Sender: TObject); private public AnimFrameCounter : integer; + FPSDelay : integer; procedure LoadImageThumbList; procedure LoadCurrentAnimList; @@ -118,7 +128,7 @@ procedure TAnimationForm.FormCreate(Sender: TObject); // CurrentAnimListView.Hint:='hello2'; // CurrentAnimListView.ShowHint:=true; - + FPSDelay:=1000 Div FPSTrackBar.Position; end; procedure TAnimationForm.FormPaint(Sender: TObject); @@ -299,6 +309,11 @@ procedure TAnimationForm.PasteMenuClick(Sender: TObject); end; end; +procedure TAnimationForm.PlayButtonClick(Sender: TObject); +begin + Timer1.Enabled:=true; +end; + procedure TAnimationForm.SpriteListViewDblClick(Sender: TObject); begin // ShowMessage(IntToStr((Sender as TListView).ItemIndex)); @@ -394,14 +409,23 @@ procedure TAnimationForm.SpriteListViewDragDrop(Sender, Source: TObject; X, end; +procedure TAnimationForm.SpriteListViewDragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + +end; + +procedure TAnimationForm.StopButtonClick(Sender: TObject); +begin + Timer1.Enabled:=false; +end; + procedure TAnimationForm.Timer1StartTimer(Sender: TObject); begin AnimFrameCounter:=0; -// if AnimateBase.GetFrameCount > 0 then AnimFrameCounter:=1; -// if AnimFrameCounter > 0 then CurrentAnimationImageList.Draw(Panel1.Canvas,10,10,AnimateBase.GetImageIndex(AnimFrameCounter-1),true); -// info.Caption:=IntToStr(AnimFrameCounter); + end; procedure TAnimationForm.Timer1Timer(Sender: TObject); @@ -417,13 +441,14 @@ procedure TAnimationForm.Timer1Timer(Sender: TObject); if AnimateBase.GetFrameCount > 0 then begin ImageIndex:=AnimateBase.GetImageIndex(AnimFrameCounter-1); - // if ImageIndex <> -1 then - // begin - CurrentAnimationImageList.Draw(Panel1.Canvas,10,10,ImageIndex,true); - // end; -// if AnimFrameCounter > 0 then info.Caption:='Frame: '+IntToStr(AnimFrameCounter-1)+' Image Index:'+IntToStr(ImageIndex)+' Frame count'+IntToStr(AnimateBase.GetFrameCount); + CurrentAnimationImageList.Draw(Panel1.Canvas,10,10,ImageIndex,true); + end; +end; - end; +procedure TAnimationForm.FPSTrackBarChange(Sender: TObject); +begin + FPSDelay:=1000 div FPSTrackBar.Position; + Timer1.Interval:=FPSDelay; end; procedure TAnimationForm.FormActivate(Sender: TObject); @@ -431,7 +456,6 @@ procedure TAnimationForm.FormActivate(Sender: TObject); LoadImageThumbList; LoadCurrentAnimList; LoadAnimThumbList; - SpriteListView.Repaint; CurrentAnimListView.Repaint; AllAnimListView.Repaint; @@ -447,9 +471,6 @@ procedure TAnimationForm.AddFrame(ImageIndex : integer); CurrentAnimListView.Repaint; LoadAnimThumbList; AllAnimListView.Repaint; - -// CurrentAnimListView.AddItem('Frame '+IntToStr(AnimateBase.GetFrameCount),self); -// CurrentAnimListView.Items[AnimateBase.GetFrameCount-1].ImageIndex:=ImageIndex; end; @@ -541,6 +562,12 @@ procedure TAnimationForm.CurrentAnimListViewDragDrop(Sender, Source: TObject; end; end; +procedure TAnimationForm.CurrentAnimListViewDragOver(Sender, Source: TObject; + X, Y: Integer; State: TDragState; var Accept: Boolean); +begin + +end; + procedure TAnimationForm.AllAnimListViewShowHint(Sender: TObject; HintInfo: PHintInfo); begin @@ -556,6 +583,11 @@ procedure TAnimationForm.AnimDeleteMenuClick(Sender: TObject); if index > -1 then DeleteAnimation(index); end; +procedure TAnimationForm.Arrow1Click(Sender: TObject); +begin + +end; + procedure TAnimationForm.Button1Click(Sender: TObject); begin // Panel1.Canvas.Draw(10,10,AnimThumbImageList. @@ -597,11 +629,7 @@ procedure TAnimationForm.CopyMenuClick(Sender: TObject); -procedure TAnimationForm.CurrentAnimListViewDragOver(Sender, Source: TObject; - X, Y: Integer; State: TDragState; var Accept: Boolean); -begin -end; procedure TAnimationForm.DeleteMenuClick(Sender: TObject); var diff --git a/animbase.pas b/animbase.pas index 7800ee5..e41f593 100644 --- a/animbase.pas +++ b/animbase.pas @@ -76,6 +76,9 @@ interface procedure Save(filename : string); procedure Open(filename : string); + + procedure WriteAnimations(var F : File; count : word); + procedure ReadAnimations(var F: File; count : word;InsertMode : boolean); end; var @@ -302,6 +305,42 @@ procedure TAnimateBase.DeleteFrame(FrameIndex : integer); end; end; +procedure TAnimateBase.WriteAnimations(var F : File; count : word); +var + i : word; +begin +// Blockwrite(f,Animations.AnimCount,sizeof(Animations.AnimCount)); + Blockwrite(f,Animations.CurrentAnimation,sizeof(Animations.CurrentAnimation)); + + for i:=0 to Count-1 do + begin + Blockwrite(f,Animations.AnimationList[i],sizeof(Animations.AnimationList[i])); + end; +end; + + +procedure TAnimateBase.ReadAnimations(var F: File; count : word;InsertMode : boolean); +var + i : word; + canimation : integer; +begin +// Blockread(f,Animations.AnimCount,sizeof(Animations.AnimCount)); + if NOT InsertMode then Animations.AnimCount:=count; + + if InsertMode then Blockread(f,canimation,sizeof(canimation)) + else Blockread(f,Animations.CurrentAnimation,sizeof(Animations.CurrentAnimation)); + + for i:=0 to Count-1 do + begin + if InsertMode then + begin + AddAnimation; + Blockread(f,Animations.AnimationList[Animations.AnimCount-1],sizeof(Animations.AnimationList[Animations.AnimCount-1])); + end + else Blockread(f,Animations.AnimationList[i],sizeof(Animations.AnimationList[i])) + end; +end; + procedure TAnimateBase.Save(filename : string); var F : file; @@ -309,7 +348,7 @@ procedure TAnimateBase.Save(filename : string); begin Assign(f,filename); Rewrite(f,1); - Blockwrite(f,Animations.AnimCount,sizeof(Animations.AnimCount)); +// Blockwrite(f,Animations.AnimCount,sizeof(Animations.AnimCount)); Blockwrite(f,Animations.CurrentAnimation,sizeof(Animations.CurrentAnimation)); for i:=0 to Animations.AnimCount-1 do diff --git a/mapeditor.lfm b/mapeditor.lfm index e7b9e1d..6897766 100644 --- a/mapeditor.lfm +++ b/mapeditor.lfm @@ -1,11 +1,11 @@ object MapEdit: TMapEdit - Left = 395 + Left = 237 Height = 860 Top = 153 - Width = 1333 + Width = 1491 Caption = 'Map Editor' ClientHeight = 860 - ClientWidth = 1333 + ClientWidth = 1491 DoubleBuffered = True Menu = MainMenu1 OnActivate = FormActivate @@ -24,11 +24,11 @@ object MapEdit: TMapEdit Left = 0 Height = 860 Top = 0 - Width = 258 + Width = 289 Anchors = [akTop, akLeft, akRight, akBottom] Caption = 'LeftPanel' ClientHeight = 860 - ClientWidth = 258 + ClientWidth = 289 ParentFont = False TabOrder = 3 object SelectedTilePanel: TPanel @@ -40,10 +40,10 @@ object MapEdit: TMapEdit Left = 1 Height = 221 Top = 1 - Width = 256 + Width = 287 Anchors = [akTop, akLeft, akRight, akBottom] ClientHeight = 221 - ClientWidth = 256 + ClientWidth = 287 ParentFont = False TabOrder = 0 object SelectedTileImage: TImage @@ -67,7 +67,7 @@ object MapEdit: TMapEdit Left = 1 Height = 9 Top = 222 - Width = 256 + Width = 287 Align = alNone Anchors = [akLeft, akRight] AutoSnap = False @@ -86,11 +86,11 @@ object MapEdit: TMapEdit Left = 1 Height = 628 Top = 231 - Width = 256 + Width = 287 Anchors = [akTop, akLeft, akRight, akBottom] Caption = 'LeftBottomPanel' ClientHeight = 628 - ClientWidth = 256 + ClientWidth = 287 ParentColor = False ParentFont = False TabOrder = 2 @@ -98,7 +98,7 @@ object MapEdit: TMapEdit Left = 1 Height = 626 Top = 1 - Width = 254 + Width = 285 Align = alClient Color = 15790320 Columns = <> @@ -121,14 +121,14 @@ object MapEdit: TMapEdit AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = Owner AnchorSideBottom.Side = asrBottom - Left = 1217 + Left = 1169 Height = 860 Top = 0 - Width = 116 + Width = 322 Anchors = [akTop, akLeft, akRight, akBottom] Caption = 'RightPanel' ClientHeight = 860 - ClientWidth = 116 + ClientWidth = 322 ParentColor = False ParentFont = False TabOrder = 0 @@ -136,14 +136,19 @@ object MapEdit: TMapEdit Left = 1 Height = 858 Top = 1 - Width = 114 + Width = 320 Align = alClient + AutoSort = False Color = 15790320 Columns = <> + IconOptions.AutoArrange = True + LargeImages = MapImageList + LargeImagesWidth = 256 ParentFont = False PopupMenu = ExportMapsPropsMenu ReadOnly = True TabOrder = 0 + ViewStyle = vsIcon OnClick = MapListViewClick end end @@ -151,7 +156,7 @@ object MapEdit: TMapEdit AnchorSideTop.Control = Owner AnchorSideBottom.Control = Owner AnchorSideBottom.Side = asrBottom - Left = 258 + Left = 289 Height = 860 Top = 0 Width = 9 @@ -164,7 +169,7 @@ object MapEdit: TMapEdit AnchorSideTop.Control = Owner AnchorSideBottom.Control = Owner AnchorSideBottom.Side = asrBottom - Left = 1208 + Left = 1160 Height = 860 Top = 0 Width = 9 @@ -178,17 +183,17 @@ object MapEdit: TMapEdit AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = Owner AnchorSideRight.Control = RightSplitter - Left = 267 + Left = 298 Height = 126 Top = 0 - Width = 941 + Width = 862 Anchors = [akTop, akLeft, akRight] ClientHeight = 126 - ClientWidth = 941 + ClientWidth = 862 ParentFont = False TabOrder = 4 object Panel1: TPanel - Left = 792 + Left = 713 Height = 96 Top = 13 Width = 112 @@ -229,7 +234,7 @@ object MapEdit: TMapEdit end end object TileZoom: TTrackBar - Left = 906 + Left = 827 Height = 99 Hint = 'Zoom Level' Top = 13 @@ -247,7 +252,7 @@ object MapEdit: TMapEdit TabOrder = 0 end object Panel2: TPanel - Left = 360 + Left = 281 Height = 96 Top = 13 Width = 424 @@ -455,7 +460,7 @@ object MapEdit: TMapEdit Left = 16 Height = 23 Top = 16 - Width = 334 + Width = 255 Align = alNone Anchors = [akTop, akLeft, akRight] BorderSpacing.Around = 10 @@ -467,7 +472,7 @@ object MapEdit: TMapEdit Left = 16 Height = 23 Top = 48 - Width = 334 + Width = 255 Align = alNone Anchors = [akTop, akLeft, akRight] BorderSpacing.Around = 10 @@ -483,14 +488,14 @@ object MapEdit: TMapEdit AnchorSideRight.Control = RightSplitter AnchorSideBottom.Control = Owner AnchorSideBottom.Side = asrBottom - Left = 267 + Left = 298 Height = 734 Top = 126 - Width = 941 + Width = 862 Anchors = [akTop, akLeft, akRight, akBottom] Caption = 'MiddlePanel' ClientHeight = 734 - ClientWidth = 941 + ClientWidth = 862 ParentColor = False ParentFont = False TabOrder = 5 @@ -498,7 +503,7 @@ object MapEdit: TMapEdit Left = 1 Height = 732 Top = 1 - Width = 939 + Width = 860 HorzScrollBar.Increment = 10 HorzScrollBar.Page = 105 HorzScrollBar.Tracking = True @@ -508,7 +513,7 @@ object MapEdit: TMapEdit Align = alClient BorderStyle = bsNone ClientHeight = 732 - ClientWidth = 939 + ClientWidth = 860 ParentFont = False TabOrder = 0 object MapPaintBox: TPaintBox @@ -782,4 +787,8 @@ object MapEdit: TMapEdit Left = 70 Top = 240 end + object MapImageList: TImageList + Left = 1072 + Top = 160 + end end diff --git a/mapeditor.pas b/mapeditor.pas index b1486c5..48128b7 100644 --- a/mapeditor.pas +++ b/mapeditor.pas @@ -9,12 +9,18 @@ interface ComCtrls, Menus,rmthumb,mapcore,rwmap,mapexiportprops,rmcodegen,drawprocs,rmtools,rmclipboard, rmconfig; +const + AddImage = 1; + InsertImage = 2; + UpdateImage = 3; + type { TMapEdit } TMapEdit = class(TForm) CopyToClipBoard: TMenuItem; GroupBox1: TGroupBox; + MapImageList: TImageList; MenuItem15: TMenuItem; CloneMap: TMenuItem; Properties: TMenuItem; @@ -122,6 +128,7 @@ TMapEdit = class(TForm) RightSplitter: TSplitter; TileZoom: TTrackBar; + procedure Button1Click(Sender: TObject); procedure CheckBoxDisplayGridChange(Sender: TObject); procedure CloneMapClick(Sender: TObject); procedure CopyToClipBoardClick(Sender: TObject); @@ -244,6 +251,10 @@ TMapEdit = class(TForm) function ExportTextFileToClipboard(Sender: TObject) : boolean; + procedure MapPreviewPlotTile(MPCanvas : TCanvas;mx,my : integer;var TTile : TileRec); + Procedure UpdateMapPreviewImageIcons(var ImageList : TImageList; MapIndex,ImageAction : integer); + + end; var @@ -419,6 +430,8 @@ procedure TMapEdit.CheckBoxDisplayGridChange(Sender: TObject); MapPaintBox.Invalidate; end; + + procedure TMapEdit.CloneMapClick(Sender: TObject); begin MapCoreBase.CloneMap; @@ -613,42 +626,7 @@ procedure TMapEdit.ClearMapClick(Sender: TObject); MapPaintBox.Invalidate; end; -procedure TMapEdit.MapListViewClick(Sender: TObject); -var - item : TListItem; - zs,tw,th : integer; -begin - if (MapListView.SelCount > 0) then - begin - item:=MapListView.LastSelected; - MapCoreBase.SetMapScrollHorizPos(MapCoreBase.GetCurrentMap,MapScrollBox.HorzScrollBar.Position); - MapCoreBase.SetMapScrollVertPos(MapCoreBase.GetCurrentMap,MapScrollBox.VertScrollBar.Position); - MapCoreBase.SetCurrentMap(item.Index); - CurrentMap:=MapCoreBase.GetCurrentMap; - - tw:=MapCoreBase.GetMapTileWidth(CurrentMap); - th:=MapCoreBase.GetMapTileHeight(CurrentMap); - zs:=MapCoreBase.GetZoomSize(CurrentMap); - MapCoreBase.SetZoomSize(CurrentMap,zs); - TileZoom.Position:=zs; - MapCoreBase.SetMapTileSize(CurrentMap,tw,th); - - TileWidth:=MapCoreBase.GetZoomMapTileWidth(CurrentMap); - TileHeight:=MapCoreBase.GetZoomMapTileHeight(CurrentMap); - - UpdatePageSize; - MapScrollBox.HorzScrollBar.Position:=MapCoreBase.GetMapScrollHorizPos(MapCoreBase.GetCurrentMap); - MapScrollBox.VertScrollBar.Position:=MapCoreBase.GetMapScrollVertPos(MapCoreBase.GetCurrentMap); - SetDrawTool(MapCoreBase.GetMapDrawTool(CurrentMap)); - TileMode:=MapCoreBase.GetMapTileMode(CurrentMap); - UpdateToolSelectionIcons; - UpdateMenus; - UpdateEditMenus; - //UpdateMapView; - MapPaintBox.Invalidate; - end; -end; Procedure TMapEdit.DrawGrid; var @@ -950,6 +928,8 @@ procedure TMapEdit.ReSizeMapClick(Sender: TObject); UpdatePageSize; // UpdateMapView; MapPaintBox.Invalidate; + UpdateMapPreviewImageIcons(MapImageList,CurrentMap,UpdateImage); + MapListView.Repaint; end; procedure TMapEdit.TileModeDrawClick(Sender: TObject); @@ -1210,21 +1190,118 @@ procedure TMapEdit.UpdateTileView; end; end; + +procedure TMapEdit.Button1Click(Sender: TObject); +begin + UpdateMapPreviewImageIcons(MapImageList,MapCoreBase.GetCurrentMap,AddImage); +// ShowMessage('working'); +end; + +procedure TMapEdit.MapPreviewPlotTile(MPCanvas : TCanvas;mx,my : integer;var TTile : TileRec); +var + gx,gy : integer; +begin + gx:=mx*TileWidth; + gy:=my*TileHeight; + TileImageList.Draw(MPCanvas,gx,gy,TTile.ImageIndex,true); +end; + +Procedure TMapEdit.UpdateMapPreviewImageIcons(var ImageList : TImageList; MapIndex,ImageAction : integer); +var + i,j : integer; + T : TileRec; + SrcBitMap,DstBitMap : TBitMap; +begin + SrcBitMap:=TBitMap.Create; + SrcBitMap.SetSize(MapCoreBase.GetMapWidth(MapIndex)*TileWidth,MapCoreBase.GetMapHeight(MapIndex)*TileHeight); + + DstBitMap:=TBitMap.Create; + DstBitMap.SetSize(256,256); + + for j:=0 to MapCoreBase.GetMapWidth(MapIndex)-1 do + begin + for i:=0 to MapCoreBase.GetMapHeight(MapIndex)-1 do + begin + MapCoreBase.GetMapTile(MapIndex,i,j,T); + if T.ImageIndex > TileClear then //we don't care about missing tile here + begin + MapPreviewPlotTile(SrcBitMap.Canvas,i,j,T); + end; + end; + end; + DstBitMap.canvas.CopyRect(Rect(0, 0, DstBitMap.Width, DstBitMap.Height), SrcBitMap.Canvas, Rect(0, 0, SrcBitMap.Width, SrcBitMap.Height)); +// MapImageList.clear; + + if ImageAction = AddImage then + begin + ImageList.add(DstBitMap,nil); + end + else if ImageAction = UpdateImage then + begin + ImageList.Replace(MapIndex,DstBitMap,nil,false); + end; +// MapListView.Repaint; + SrcBitMap.Free; + DstBitMap.Free; + +end; + +procedure TMapEdit.MapListViewClick(Sender: TObject); +var + item : TListItem; + zs,tw,th : integer; +begin + if (MapListView.SelCount > 0) then + begin + item:=MapListView.LastSelected; + MapCoreBase.SetMapScrollHorizPos(MapCoreBase.GetCurrentMap,MapScrollBox.HorzScrollBar.Position); + MapCoreBase.SetMapScrollVertPos(MapCoreBase.GetCurrentMap,MapScrollBox.VertScrollBar.Position); + + MapCoreBase.SetCurrentMap(item.Index); + CurrentMap:=MapCoreBase.GetCurrentMap; + + tw:=MapCoreBase.GetMapTileWidth(CurrentMap); + th:=MapCoreBase.GetMapTileHeight(CurrentMap); + zs:=MapCoreBase.GetZoomSize(CurrentMap); + MapCoreBase.SetZoomSize(CurrentMap,zs); + TileZoom.Position:=zs; + MapCoreBase.SetMapTileSize(CurrentMap,tw,th); + + TileWidth:=MapCoreBase.GetZoomMapTileWidth(CurrentMap); + TileHeight:=MapCoreBase.GetZoomMapTileHeight(CurrentMap); + + UpdatePageSize; + MapScrollBox.HorzScrollBar.Position:=MapCoreBase.GetMapScrollHorizPos(MapCoreBase.GetCurrentMap); + MapScrollBox.VertScrollBar.Position:=MapCoreBase.GetMapScrollVertPos(MapCoreBase.GetCurrentMap); + SetDrawTool(MapCoreBase.GetMapDrawTool(CurrentMap)); + TileMode:=MapCoreBase.GetMapTileMode(CurrentMap); + UpdateToolSelectionIcons; + UpdateMenus; + UpdateEditMenus; + //UpdateMapView; + MapPaintBox.Invalidate; + end; +end; + Procedure TMapEdit.UpdateMapListView; var i,count : integer; begin count:=MapCoreBase.GetMapCount; MapListView.items.Clear; + MapListView.LargeImages.Width:=256; + MapListView.LargeImages.Height:=256; - for i:=1 to count do + MapImageList.Clear; + MapImageList.Width:=256; + MapImageList.Height:=256; + For i:=0 to count-1 do begin MapListView.Items.Add; - end; - - For i:=0 to MapListView.Items.Count-1 do - begin MapListView.Items[i].Caption:='Map '+IntToStr(i+1); + MapListView.Items[i].ImageIndex:=i; + + UpdateMapPreviewImageIcons(MapImageList,i,AddImage); end; end; @@ -1475,6 +1552,8 @@ procedure TMapEdit.MPaintBoxMouseUp(Sender: TObject; Button: TMouseButton; DrawShapeEllipse,DrawShapeFEllipse:MPaintBoxMouseUpXYX2Y2Tool(Sender,Button,Shift,X,Y); end; + UpdateMapPreviewImageIcons(MapImageList,CurrentMap,UpdateImage); + MapListView.Repaint; end; procedure TMapEdit.ToolGridIconClick(Sender: TObject); @@ -1498,6 +1577,8 @@ procedure TMapEdit.ToolHFLIPButtonClick(Sender: TObject); MapCoreBase.GetMapClipAreaCoords(MapCoreBase.GetCurrentMap,ca); MapCoreBase.Hflip(MapCoreBase.GetCurrentMap,ca.x,ca.y,ca.x2,ca.y2 ); MapPaintBox.Invalidate; + UpdateMapPreviewImageIcons(MapImageList,CurrentMap,UpdateImage); + MapListView.Repaint; end; procedure TMapEdit.ToolIconClick(Sender: TObject); @@ -1551,6 +1632,8 @@ procedure TMapEdit.ToolScrollDownIconClick(Sender: TObject); MapCoreBase.GetMapClipAreaCoords(MapCoreBase.GetCurrentMap,ca); MapCoreBase.ScrollDown(MapCoreBase.GetCurrentMap,ca.x,ca.y,ca.x2,ca.y2 ); MapPaintBox.Invalidate; + UpdateMapPreviewImageIcons(MapImageList,CurrentMap,UpdateImage); + MapListView.Repaint; end; procedure TMapEdit.ToolScrollLeftIconClick(Sender: TObject); @@ -1560,6 +1643,8 @@ procedure TMapEdit.ToolScrollLeftIconClick(Sender: TObject); MapCoreBase.GetMapClipAreaCoords(MapCoreBase.GetCurrentMap,ca); MapCoreBase.ScrollLeft(MapCoreBase.GetCurrentMap,ca.x,ca.y,ca.x2,ca.y2 ); MapPaintBox.Invalidate; + UpdateMapPreviewImageIcons(MapImageList,CurrentMap,UpdateImage); + MapListView.Repaint; end; procedure TMapEdit.ToolScrollRightIconClick(Sender: TObject); @@ -1569,6 +1654,8 @@ procedure TMapEdit.ToolScrollRightIconClick(Sender: TObject); MapCoreBase.GetMapClipAreaCoords(MapCoreBase.GetCurrentMap,ca); MapCoreBase.ScrollRight(MapCoreBase.GetCurrentMap,ca.x,ca.y,ca.x2,ca.y2 ); MapPaintBox.Invalidate; + UpdateMapPreviewImageIcons(MapImageList,CurrentMap,UpdateImage); + MapListView.Repaint; end; procedure TMapEdit.ToolScrollUpIconClick(Sender: TObject); @@ -1578,12 +1665,16 @@ procedure TMapEdit.ToolScrollUpIconClick(Sender: TObject); MapCoreBase.GetMapClipAreaCoords(MapCoreBase.GetCurrentMap,ca); MapCoreBase.ScrollUp(MapCoreBase.GetCurrentMap,ca.x,ca.y,ca.x2,ca.y2 ); MapPaintBox.Invalidate; + UpdateMapPreviewImageIcons(MapImageList,CurrentMap,UpdateImage); + MapListView.Repaint; end; procedure TMapEdit.ToolUndoIconClick(Sender: TObject); begin MapCoreBase.Undo(MapCoreBase.GetCurrentMap); MapPaintBox.Invalidate; + UpdateMapPreviewImageIcons(MapImageList,CurrentMap,UpdateImage); + MapListView.Repaint; end; procedure TMapEdit.ToolVFLIPButtonClick(Sender: TObject); @@ -1593,6 +1684,8 @@ procedure TMapEdit.ToolVFLIPButtonClick(Sender: TObject); MapCoreBase.GetMapClipAreaCoords(MapCoreBase.GetCurrentMap,ca); MapCoreBase.Vflip(MapCoreBase.GetCurrentMap,ca.x,ca.y,ca.x2,ca.y2 ); MapPaintBox.Invalidate; + UpdateMapPreviewImageIcons(MapImageList,CurrentMap,UpdateImage); + MapListView.Repaint; end; Procedure TMapEdit.LoadResourceIcons; diff --git a/rm.lpi b/rm.lpi index b13450e..1ff1011 100644 --- a/rm.lpi +++ b/rm.lpi @@ -335,7 +335,6 @@ - diff --git a/rmabout.pas b/rmabout.pas index 26a1f4f..dfc01c5 100644 --- a/rmabout.pas +++ b/rmabout.pas @@ -8,8 +8,8 @@ interface Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,lclintf; Const - ProgramName ='Raster Master v4.3 R110'; - ProgramLicense = 'Released September 25 - 2024 under MIT License'; + ProgramName ='Raster Master v4.4 R111'; + ProgramLicense = 'Released September 30 - 2024 under MIT License'; type diff --git a/rmmain.lfm b/rmmain.lfm index 0738634..b6712ee 100644 --- a/rmmain.lfm +++ b/rmmain.lfm @@ -1,7 +1,7 @@ object RMMainForm: TRMMainForm - Left = 45 + Left = 113 Height = 1057 - Top = 25 + Top = 234 Width = 1824 Align = alClient Caption = 'Raster Master' @@ -1527,12 +1527,16 @@ object RMMainForm: TRMMainForm Top = 592 end object ExportPropsMenu: TPopupMenu - Left = 1624 - Top = 40 + Left = 168 + Top = 376 object NewImage: TMenuItem Caption = 'New Image' OnClick = NewClick end + object DeleteImage: TMenuItem + Caption = 'Delete' + OnClick = DeleteImageClick + end object ExportInclude: TMenuItem Caption = 'Export Include' OnClick = ThumbPopUpMenuExportClick diff --git a/rmmain.pas b/rmmain.pas index e27c77e..fbd8c7d 100644 --- a/rmmain.pas +++ b/rmmain.pas @@ -75,6 +75,7 @@ TRMMainForm = class(TForm) gccRayLibCustom: TMenuItem; EditProperties: TMenuItem; BAMRGBPutData: TMenuItem; + DeleteImage: TMenuItem; SpriteAnimationMenu: TMenuItem; SpriteExportMenu: TMenuItem; SoundGenerator: TMenuItem; @@ -345,6 +346,7 @@ TRMMainForm = class(TForm) Shift: TShiftState); procedure ColorPalette1GetHintText(Sender: TObject; AColor: TColor; var AText: String); + procedure DeleteImageClick(Sender: TObject); procedure EditClearClick(Sender: TObject); procedure EditCloneClick(Sender: TObject); procedure EditCopyClick(Sender: TObject); @@ -517,6 +519,7 @@ TRMMainForm = class(TForm) public procedure UpdateImportedImage; + procedure DeleteImageByIndex(index : integer); end; @@ -1357,6 +1360,41 @@ procedure TRMMainForm.ColorPalette1GetHintText(Sender: TObject; AColor: TColor; end; end; +procedure TRMMainForm.DeleteImageClick(Sender: TObject); + var + item : TListItem; + index : integer; + begin + if ImageThumbBase.GetCount = 1 then + begin + if (Listview1.SelCount > 0) then + begin + Clear; + end + else + begin + if MessageDlg('No Image Selected', 'Delete Current Image?', mtConfirmation, + [mbYes, mbNo],0) = mrNo then Exit; + Clear; + end; + // display message to select clear as it is the only item + end + else + begin + if (Listview1.SelCount = 0) then + begin + if MessageDlg('No Image Selected','Please Select Image to Delete', mtConfirmation, [mbOk],0) = mrOk then exit; + end; + + if MessageDlg('Delete Selected Image', 'Are you sure you want to do this?', mtConfirmation, [mbYes, mbNo],0) = mrNo then exit; + + item:=ListView1.LastSelected; + index:=item.index; + + DeleteImageByIndex(index); + end; +end; + procedure TRMMainForm.ColorPalette1ColorPick(Sender: TObject; AColor: TColor; Shift: TShiftState); begin @@ -3638,6 +3676,7 @@ procedure TRMMainForm.DeleteAllClick(Sender: TObject); ActualBox.Height:=ImgHeight; RMCoreBase.SetWidth(ImgWidth); RMCoreBase.SetHeight(ImgHeight); + RMDrawTools.SetZoomSize(1); RMCoreBase.ClearBuf(0); RMCoreBase.SetCurColor(1); @@ -4084,39 +4123,12 @@ procedure TRMMainForm.UpdateThumbView; Listview1.Refresh; end; -procedure TRMMainForm.FileDeleteClick(Sender: TObject); -var - item : TListItem; - i,index : integer; -begin - if ImageThumbBase.GetCount = 1 then - begin - if (Listview1.SelCount > 0) then - begin - Clear; - end - else - begin - if MessageDlg('No Image Selected', 'Delete Current Image?', mtConfirmation, - [mbYes, mbNo],0) = mrNo then Exit; - Clear; - end; - // display message to select clear as it is the only item - end - else - begin - if (Listview1.SelCount = 0) then - begin - if MessageDlg('No Image Selected','Please Select Image to Delete', mtConfirmation, [mbOk],0) = mrOk then exit; - end; - - if MessageDlg('Delete Selected Image', 'Are you sure you want to do this?', mtConfirmation, [mbYes, mbNo],0) = mrNo then exit; - - item:=ListView1.LastSelected; - index:=item.index; - if index > -1 then - begin +procedure TRMMainForm.DeleteImageByIndex(index : integer); +var i: integer; +begin +if index > -1 then +begin listview1.Items.Delete(index); imagelist1.Delete(index); @@ -4137,12 +4149,6 @@ procedure TRMMainForm.FileDeleteClick(Sender: TObject); ActualBox.Width:=RMCoreBase.GetWidth; ActualBox.Height:=RMCoreBase.GetHeight; - //RMDrawTools.SetZoomSize(1); - //RMDrawTools.DrawGrid(ZoomPaintBox.Canvas,0,0,ZoomPaintBox.Width,ZoomPaintBox.Height,0); - //RMDrawTools.SetZoomMaxX(ZoomPaintBox.Width); - //RMDrawTools.SetZoomMaxY(ZoomPaintBox.Height); - //ZoomSize:=RMDrawTools.GetZoomSize; - ZoomPaintBox.Width:=1; ZoomPaintBox.Height:=1; ZoomPaintBox.Width:=RMDrawTools.GetZoomPageWidth; @@ -4159,6 +4165,40 @@ procedure TRMMainForm.FileDeleteClick(Sender: TObject); UpdateZoomArea; UpdateEditMenu; end; +end; + +procedure TRMMainForm.FileDeleteClick(Sender: TObject); +var + item : TListItem; + index : integer; +begin + if ImageThumbBase.GetCount = 1 then + begin + if (Listview1.SelCount > 0) then + begin + Clear; + end + else + begin + if MessageDlg('No Image Selected', 'Delete Current Image?', mtConfirmation, + [mbYes, mbNo],0) = mrNo then Exit; + Clear; + end; + // display message to select clear as it is the only item + end + else + begin + if (Listview1.SelCount = 0) then + begin + if MessageDlg('No Image Selected','Please Select Image to Delete', mtConfirmation, [mbOk],0) = mrOk then exit; + end; + + if MessageDlg('Delete Selected Image', 'Are you sure you want to do this?', mtConfirmation, [mbYes, mbNo],0) = mrNo then exit; + + item:=ListView1.LastSelected; + index:=item.index; + + DeleteImageByIndex(index); end; end; @@ -4177,8 +4217,6 @@ procedure TRMMainForm.TMTPaletteCommandsClick(Sender: TObject); end; - - procedure TRMMainForm.NewClick(Sender: TObject); begin if ImageThumbBase.GetCount >= MaxThumbImages then exit; diff --git a/rmthumb.pas b/rmthumb.pas index df5c139..ea45957 100644 --- a/rmthumb.pas +++ b/rmthumb.pas @@ -1,7 +1,7 @@ Unit rmthumb; Interface - uses rmcore,rmtools,graphics,controls,types,dialogs,sysutils,mapcore,rwmap; + uses rmcore,rmtools,graphics,controls,types,dialogs,sysutils,mapcore,rwmap,animbase; Const RMProjectSig = 'RMP'; @@ -51,7 +51,7 @@ version : word; ImageCount : word; MapCount : word; - Future1 : word; //try and future proof changing project file + AnimCount : word; //try and future proof changing project file Future2 : word; Future3 : word; end; @@ -675,6 +675,8 @@ procedure TImageThumb.OpenProject(filename : string;insertmode : boolean); end; ReadAllMapsF(F,head.MapCount,insertmode); + + if head.AnimCount > 0 then AnimateBase.ReadAnimations(F,head.AnimCount,InsertMode); end; {$I-} close(f); @@ -696,7 +698,7 @@ procedure TImageThumb.SaveProject(filename : string); head.ImageCount:=count; head.MapCount:=MapCoreBase.GetMapCount; - head.Future1:=0; + head.AnimCount:=AnimateBase.GetAnimationCount; head.Future2:=0; head.Future3:=0; @@ -710,7 +712,10 @@ procedure TImageThumb.SaveProject(filename : string); begin WriteImageToProject(F,i); end; + WriteAllMapsF(F); + + if AnimateBase.GetAnimationCount > 0 then AnimateBase.WriteAnimations(F,AnimateBase.GetAnimationCount); {$I-} close(f); {$I+}