public void KnotFileIOContent_Test() { KnotFileIO fileIO = new KnotFileIO (); Knot knot = fileIO.Load (TestHelper.TestResourcesDirectory + "AllDir.knot"); Assert.AreEqual (knot.MetaData.Name, "AllDir"); Assert.AreEqual (knot.Count (), 6); }
public void SavegameLoader_Load_Test() { // Erstelle einen Parser für das Dateiformat KnotFileIO fileFormat = new KnotFileIO (); // Erstelle einen Spielstand-Loader loader = new SavegameLoader<Knot, KnotMetaData> (fileFormat, "index-SavegameLoader_Tests"); // Suche nach Spielständen loader.FindSavegames (AddSavegameToList); }
public void SavegameLoader_InvalidIndex_Test() { // Erstelle einen Parser für das Dateiformat KnotFileIO fileFormat = new KnotFileIO (); // Erstelle einen Spielstand-Loader loader = new SavegameLoader<Knot, KnotMetaData> (fileFormat, "{}''!!^?`´##~%%&&$!\\//\\//"); // Suche nach Spielständen loader.FindSavegames (AddSavegameToList); }
public void KnotFileO_Test() { Random random = new Random (); String randomname = random.Next (100000).ToString (); Knot testKnot = KnotGenerator.coloredKnot (randomname); KnotFileIO fileIO = new KnotFileIO (); fileIO.Save (testKnot, true); Assert.IsTrue (testKnot.Equals (fileIO.Load (testKnot.MetaData.Filename))); Assert.IsTrue (testKnot.MetaData.Equals (fileIO.LoadMetaData (testKnot.MetaData.Filename))); //Sollte nun im Cache sein Assert.IsTrue (testKnot.Equals (fileIO.Load (testKnot.MetaData.Filename))); Assert.Catch (() => { fileIO.Save (KnotGenerator.noMetadataKnot ("test"), true); }); }
/// <summary> /// Erzeugt ein neues CreativeLoadScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt. /// </summary> public CreativeLoadScreen(GameCore game) : base(game) { savegameMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu); savegameMenu.Bounds.Position = ScreenContentBounds.Position; savegameMenu.Bounds.Size = new ScreenPoint (this, 0.300f, ScreenContentBounds.Size.Relative.Y); savegameMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f); savegameMenu.ItemAlignX = HorizontalAlignment.Left; savegameMenu.ItemAlignY = VerticalAlignment.Center; savegameMenu.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc; savegameMenu.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc; savegameMenu.RelativeItemHeight = Design.DataItemHeight; lines.AddPoints (.000f, .050f, .030f, .970f, .620f, .895f, .740f, .970f, .760f, .895f, .880f, .970f, .970f, .050f, 1.000f); title = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: "Load Knot"); title.Bounds.Position = ScreenTitleBounds.Position; title.Bounds.Size = ScreenTitleBounds.Size; title.ForegroundColorFunc = (s) => Color.White; infoTitle = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: "Knot Info:"); infoTitle.Bounds.Position = new ScreenPoint (this, 0.45f, 0.62f); infoTitle.Bounds.Size = new ScreenPoint (this, 0.900f, 0.050f); infoTitle.ForegroundColorFunc = (s) => Color.White; knotInfo = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu); knotInfo.Bounds.Position = new ScreenPoint (this, 0.47f, 0.70f); knotInfo.Bounds.Size = new ScreenPoint (this, 0.300f, 0.500f); knotInfo.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f); knotInfo.ItemAlignX = HorizontalAlignment.Left; knotInfo.ItemAlignY = VerticalAlignment.Center; // Erstelle einen Parser für das Dateiformat KnotFileIO fileFormat = new KnotFileIO (); // Erstelle einen Spielstand-Loader loader = new SavegameLoader<Knot, KnotMetaData> (fileFormat, "index-knots"); // Preview Bounds previewBounds = new Bounds (this, 0.45f, 0.1f, 0.48f, 0.5f); previewWorld = new World ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.GameWorld, bounds: previewBounds ); previewRenderer = new KnotRenderer (screen: this, position: Vector3.Zero); previewWorld.Add (previewRenderer); previewBorder = new Border ( screen: this, drawOrder: DisplayLayer.GameWorld, bounds: previewBounds, lineWidth: 2, padding: 0 ); previewInput = new KnotInputHandler (screen: this, world: previewWorld); previewMouseHandler = new ModelMouseHandler (screen: this, world: previewWorld); backButton = new Button ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, name: "Back", onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(s is CreativeLoadScreen)).ElementAt (0) ); backButton.AddKey (Keys.Escape); backButton.SetCoordinates (left: 0.770f, top: 0.910f, right: 0.870f, bottom: 0.960f); backButton.AlignX = HorizontalAlignment.Center; startButton = new Button ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, name: "Load", onClick: (time) => NextScreen = new CreativeModeScreen (game: Game, knot: loader.FileFormat.Load (previewKnotMetaData.Filename)) ); startButton.IsVisible = false; startButton.AddKey (Keys.Enter); startButton.SetCoordinates (left: 0.630f, top: 0.910f, right: 0.730f, bottom: 0.960f); startButton.AlignX = HorizontalAlignment.Center; }
/// <summary> /// Erzeugt eine neue Instanz eines ChallengeCreateScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt game. /// </summary> public ChallengeCreateScreen(GameCore game) : base(game) { startKnotMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu); startKnotMenu.Bounds = ScreenContentBounds.FromLeft (0.47f).FromTop (0.98f); startKnotMenu.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc; startKnotMenu.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc; startKnotMenu.RelativeItemHeight = Design.DataItemHeight; targetKnotMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu); targetKnotMenu.Bounds = ScreenContentBounds.FromRight (0.47f).FromTop (0.98f); targetKnotMenu.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc; targetKnotMenu.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc; targetKnotMenu.RelativeItemHeight = Design.DataItemHeight; challengeName = new InputItem (this, DisplayLayer.ScreenUI + DisplayLayer.MenuItem, "Name:", String.Empty); challengeName.Bounds.Position = ScreenContentBounds.Position + ScreenContentBounds.Size.OnlyY + new ScreenPoint (this, 0f, 0.050f); challengeName.Bounds.Size = new ScreenPoint (this, 0.375f, 0.040f); challengeName.OnValueChanged += () => TryConstructChallenge (); challengeName.NameWidth = 0.2f; challengeName.ValueWidth = 0.8f; createButton = new Button ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, name: "Create!", onClick: OnCreateChallenge ); createButton.Bounds.Position = ScreenContentBounds.Position + ScreenContentBounds.FromLeft (0.50f).Size + new ScreenPoint (this, 0f, 0.050f); createButton.Bounds.Size = new ScreenPoint (this, 0.125f, 0.050f); createButtonBorder = new Border (this, DisplayLayer.ScreenUI + DisplayLayer.MenuItem, createButton, 4, 4); createButton.AlignX = HorizontalAlignment.Center; startKnotMenu.Bounds.Padding = targetKnotMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f); startKnotMenu.ItemAlignX = targetKnotMenu.ItemAlignX = HorizontalAlignment.Left; startKnotMenu.ItemAlignY = targetKnotMenu.ItemAlignY = VerticalAlignment.Center; lines.AddPoints (.000f, .050f, .030f, .970f, .760f, .895f, .880f, .970f, .970f, .050f, 1.000f); title = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: "Create Challenge"); title.Bounds.Position = ScreenTitleBounds.Position; title.Bounds.Size = ScreenTitleBounds.Size; title.ForegroundColorFunc = (s) => Color.White; // Erstelle einen Parser für das Dateiformat KnotFileIO fileFormat = new KnotFileIO (); // Erstelle einen Spielstand-Loader loader = new SavegameLoader<Knot, KnotMetaData> (fileFormat, "index-knots"); backButton = new Button ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, name: "Back", onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(s is ChallengeCreateScreen)).ElementAt (0) ); backButton.AddKey (Keys.Escape); backButton.SetCoordinates (left: 0.770f, top: 0.910f, right: 0.870f, bottom: 0.960f); backButton.AlignX = HorizontalAlignment.Center; }
public static void SaveSquareKnot(int numberOfEdges, string knotName) { Knot knot = null; KnotFileIO knotFileIO = new KnotFileIO (); knotFileIO.Save (knot, true); }
public static void LoadSquareKnot(string knotName) { KnotFileIO knotFileIO = new KnotFileIO (); knot = knotFileIO.Load (knotName); }
static ExtremeKnots() { knotFileIO = new KnotFileIO (); //testKnotNames = new List<string>(); Console.WriteLine (knotFileIO); }
public void KnotFileLoad_Test() { KnotFileIO fileIO = new KnotFileIO (); Assert.DoesNotThrow (() => { fileIO.Load (TestHelper.TestResourcesDirectory + "AllDir.knot"); }); Assert.Throws<FileNotFoundException>(() => { fileIO.Load (TestHelper.TestResourcesDirectory + "NotExistent.knot"); }); }