public override void OnInitialization() { this.Children.Add(this.Editor = new AreasetEditorHidden()); this.Children.Remove(this.Editor); this.Children.Add(this.AlignmentButtons = new Alignment ( new Label("Areaset:"), new Button("Add", () => { this.Parent.ReleaseKey(Key.MouseLeft); File f = this.Parent.OpenFile("png"); if (f != null) { this.Editor.TilesetSource = GameBase.LoadImageSource(f.Bytes); this.EditorShown = true; } }), new Button("Open", () => { this.Parent.ReleaseKey(Key.MouseLeft); File f = this.Parent.OpenFile("meka"); if (f != null) { this.Editor.Load(MekaItem.FromBytesEncrypted(f.Bytes)); this.EditorShown = true; } }) ) { Spacing = 3 }); }
public void Load(byte[] _bytes) { if (this.LevelProperties != null) { MekaItem file = MekaItem.FromBytesEncrypted(_bytes); this.Properties = PropertySaver.Load(PropertyReflector.GetPropertyTypes(this.LevelProperties), file["Properties"].Children /*file.Contains("Info") ? file["Info"].Children : new List<MekaItem>()*/); } }
public void Load(byte[] _bytes) { MekaItem info = MekaItem.FromBytesEncrypted(_bytes)["Info"]; this.BoxTitle.Content = info["Title"].Content; this.BoxAuthor.Content = info["Author"].Content; this.BoxWidth.Value = info["Width"].Content.To <int>(); this.BoxHeight.Value = info["Height"].Content.To <int>(); this.BoxOnLoad.Content = info["OnLoad"].Content; this.BoxOnEnter.Content = info["OnEnter"].Content; this.BoxOnExit.Content = info["OnExit"].Content; }
public void Test(string _entrance) { File f = this.Parent.Save(this._Export(), "meka"); if (f != null) { this.Parent._TestStarted = true; this.Parent.FixedResolution = this.StartFixedResolution; //this.Parent.IgnoreMouseWithoutFocus = this.StartIgnoreMouseWithoutFocus; this.Parent.MouseLimitedToScreen = this.StartMouseLimitedToScreen; this.Parent.ScaleMode = this.StartScaleMode; this.Parent.UseMultipleRenderers = this.StartUseMultipleRenderers; this.Parent.Entities.Remove(this); this.Parent.StartTest(new LevelSource(this.Parent, MekaItem.FromBytesEncrypted(this._Export())), this.Parent.SavePath, _entrance); } }
public override void OnInitialization() { this.Children.Add(this.Editor = new AnimationEditorHidden()); this.Children.Remove(this.Editor); this.Children.Add(this.AlignmentButtons = new Alignment ( new Label("Animation:"), new Button("Add", () => { this.Parent.ReleaseKey(Key.MouseLeft); File f = this.Parent.OpenFile("png"); if (f != null) { this.Editor.SpritesheetSource = GameBase.LoadImageSource(f.Bytes); this.AnimationShown = true; } }), new Button("Open", () => { this.Parent.ReleaseKey(Key.MouseLeft); File f = this.Parent.OpenFile("meka"); if (f != null) { MekaItem file = MekaItem.FromBytesEncrypted(f.Bytes); this.Editor.SpritesheetSource = GameBase.LoadImageSource(file["Spriteset"].Children[0].Data); this.Editor.BoxSprites.Value = file["Spriteset"]["Count"].To <int>(); this.Editor.BoxSpeed.Value = file["Speed"].To <int>(); this.Editor.BoxRepeated.Checked = file.Contains("Repeated"); this.AnimationShown = true; } }) ) { Spacing = 3 }); }
internal void _Load(byte[] _bytes) { foreach (Entity c in this.Children) { c.Kill(); } MekaItem level = MekaItem.FromBytesEncrypted(_bytes); this.Layers = new Bunch <Layer>(); Bunch <string> areasets = level["Areasets"].Children.Select(item => item.Content).ToBunch(); foreach (MekaItem layer in level["Layers"].Children) { Layer l = new Layer(this.Areasets, this.Parent.TileSize, this.DefaultTile) { SizeChangedLayer = true }; l.LoadFromImage(GameBase.LoadImageSource(layer["Tiles"].Data), areasets); foreach (MekaItem entity in layer["Entities"].Children) { EntityIcon i = new EntityIcon(l, Editor.EntityTypes.First(item => item.Name == entity.Name), _dragged: false) { LoadInfo = entity }; //i.LoadFromItem(entity); l.Entities.Add(i); this.Children.Add(i); } this.Layers.Add(l); if (layer.Contains("Main")) { this.MainLayer = l; } } this.SwitchToLayer(this.Layers.IndexOf(this.MainLayer)); this.Editor.LayerList.NeedsUpdate = true; this.Editor.LevelPreview.NeedsUpdate = true; this.UpdateFrame(); //ImageSource tiles = new ImageSource(level["Tiles"].Data); //this.Size = tiles.Size; //for (int x = 0; x < tiles.Size.X; x++) //{ // for (int y = 0; y < tiles.Size.Y; y++) // //this.Draw(new Point(x, y), Beth.FromEndian(tiles[x, y].Bytes.Sub(0, 3))); // this.Layer[x, y] = Beth.FromEndian(tiles[x, y].Bytes.Sub(0, 3)); //} //this.Editor.EntityEditor.Select(null); //foreach (MekaItem entity in level["Entities"].Children) //{ // EntityIcon e = new EntityIcon(Editor.EntityTypes.First(item => item.Name == entity.Name), _dragged: false); // e.Position = entity["Settings"]["Position"].To<Vector>(); // foreach (MekaItem property in entity["Properties"].Children) // e.Properties.First(item => item.Name == property.Name).Value = property.Content; // this.Children.Add(e); //} }