From 7d1883b7651fb2cec87c6648ae00a3bf16a57dba Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sat, 16 Sep 2017 08:11:35 -0500 Subject: [PATCH] Add a save function --- SpriteLibrary/SpriteDatabase.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/SpriteLibrary/SpriteDatabase.cs b/SpriteLibrary/SpriteDatabase.cs index 90b0bc3..5e3475f 100644 --- a/SpriteLibrary/SpriteDatabase.cs +++ b/SpriteLibrary/SpriteDatabase.cs @@ -40,6 +40,22 @@ namespace SpriteLibrary LoadSpriteInfo(); } + internal void Save() + { + if(!DoesResourceExist(Filename)) + { + //we will try to save it as a file + try + { + WriteToXmlFile>(Filename, SpriteInfoList); + } + catch (Exception e) + { + throw new Exception("SpriteDatabase failed to save: Filename:" + Filename +"\n" + "ERROR: " + e.ToString(), e); + } + } + } + public void SetSnapGridSize(Size GridSize) { if (GridSize.Width <= 0) return;