public static TileLoadResult Load(System.IO.Stream fromStream, out TileAnimation ani) { ani = null; try { var xml = new XmlSerializer(typeof(TileAnimation)); var streams = BlubbZipHelper.ExtractBlubbZip(fromStream, ""); if (streams.Count == 0) { return(TileLoadResult.NoEntryInArchiv); } foreach (var key in streams.Keys.Where(key => streams[key] != null && streams[key].Length != 0 && streams[key].CanSeek && streams[key].CanRead)) { streams[key].Seek(0, System.IO.SeekOrigin.Begin); ani = xml.Deserialize(streams[key]) as TileAnimation; streams[key].Dispose(); } } catch (Exception e) { ani = null; System.Diagnostics.Debug.WriteLine(e); return(TileLoadResult.UnkownError); } return(TileLoadResult.Success); }
public static TileAnimation LoadFromJson(JToken json, Point2D basePos) { var ani = new TileAnimation(); // RPG Maker XP animations are based on one tileset var tilesetSource = new TileCellSource(json["graphic"].ToString(), 0, 0, Constants.AnimationTilesetWidth, Constants.AnimationTilesetHeight); var tileset = EngineCore.ContentLoader.GetAnimationTileset(tilesetSource.TextureIndex); var tilesPerRow = tileset.Width / tilesetSource.Width; var frames = (JArray)json["frames"]; foreach (var frame in frames) { var frameImages = (JArray)frame; var tileFrame = new TileAnimationFrame(); foreach (var frameImage in frameImages) { /* * pattern: 1, // 1-based tile index * x: 0, // center-based x-offset * y: 16, // center-based y-offset * zoom: 30, // 100-based scale * rotation: 0, // 360-degree * opacity: 100 // 255 = full visible, 0 = full trans */ // Make index 0-based! var patIndex = (int)(frameImage["pattern"]) - 1; var patX = (int)(frameImage["x"]); var patY = (int)(frameImage["y"]); var patZoom = (int)(frameImage["zoom"]); var patRotation = (int)(frameImage["rotation"]); var patOpacity = (int)(frameImage["opacity"]); if (patIndex > 0) { tilesetSource.X = (patIndex % tilesPerRow) * tilesetSource.Width; tilesetSource.Y = (patIndex / tilesPerRow) * tilesetSource.Width; } else { tilesetSource.X = 0; tilesetSource.Y = 0; } var scale = patZoom / 100f; var pos = new Point2D(patX + basePos.X, patY + basePos.Y); var mirror = SpriteEffects.None; var col = new Color(Color.White.R, Color.White.G, Color.White.B, patOpacity); var isBackground = false; // TODO: How does RPG Maker handle this? var rot = (float)patRotation; var pattern = new TileAnimationFrameImage(tilesetSource.Clone() as TileCellSource, scale, pos, mirror, col, rot, isBackground); tileFrame.Add(pattern); } ani.Frames.Add(tileFrame); } return(ani); }
public TileAnimationLayer(int width, int height) { mLayoutMap = new TileAnimation[width][]; for (int x = 0; x < width; x++) { mLayoutMap[x] = new TileAnimation[height]; for (int y = 0; y < height; y++) mLayoutMap[x][y] = null; } }
public TileAnimationLayer(TileAnimation[][] existingMap, int newW, int newH) { mLayoutMap = new TileAnimation[newW][]; for (int x = 0; x < newW; x++) { mLayoutMap[x] = new TileAnimation[newH]; for (int y = 0; y < newH; y++) { if (existingMap == null || x >= existingMap.Length || y >= existingMap[x].Length) mLayoutMap[x][y] = null; else mLayoutMap[x][y] = existingMap[x][y]; } } }
public static TileLoadResult Load(System.IO.Stream fromStream, out TileAnimation ani) { ani = null; try { var xml = new XmlSerializer(typeof(TileAnimation)); var streams = BlubbZipHelper.ExtractBlubbZip(fromStream, ""); if (streams.Count == 0) return TileLoadResult.NoEntryInArchiv; foreach (var key in streams.Keys.Where(key => streams[key] != null && streams[key].Length != 0 && streams[key].CanSeek && streams[key].CanRead)) { streams[key].Seek(0, System.IO.SeekOrigin.Begin); ani = xml.Deserialize(streams[key]) as TileAnimation; streams[key].Dispose(); } } catch (Exception e) { ani = null; System.Diagnostics.Debug.WriteLine(e); return TileLoadResult.UnkownError; } return TileLoadResult.Success; }
private void comboAnimations_SelectedIndexChanged(object sender, EventArgs e) { #if DEBUG if (mCurrentLayer == -1 || comboAnimations.SelectedItem == null) { mPreviewAnimation = null; if (mCurrentLayer != -1) { mLastAnimationIndex[mCurrentLayer] = -1; } if (comboAnimations.Items.Count > 0) { comboAnimations.SelectedIndex = 0; } return; } mLastAnimationIndex[mCurrentLayer] = comboAnimations.SelectedIndex; mPreviewAnimation = EngineCore.ContentLoader.GetAnimation(FileLists.Instance.Animations[mLastAnimationIndex[mCurrentLayer]].Filename); RenderDisplayAnimations.Invalidate(); AdjustScrollBars(); #endif }
public void SetCell(Point point, TileAnimation Ani) { SetCell(point.X, point.Y, Ani); }
public void SetCell(int x, int y, TileAnimation Ani) { if (IsValidPoint(x, y) == false) return; mLayoutMap[x][y] = Ani.Clone() as TileAnimation; }
public TileAnimationLayer(TileAnimation[][] existingMap) { mLayoutMap = (TileAnimation[][])existingMap.Clone(); }
public static TileAnimation LoadFromJson(JToken json, Point2D basePos) { var ani = new TileAnimation(); // RPG Maker XP animations are based on one tileset var tilesetSource = new TileCellSource(json["graphic"].ToString(), 0, 0, Constants.AnimationTilesetWidth, Constants.AnimationTilesetHeight); var tileset = EngineCore.ContentLoader.GetAnimationTileset(tilesetSource.TextureIndex); var tilesPerRow = tileset.Width / tilesetSource.Width; var frames = (JArray)json["frames"]; foreach (var frame in frames) { var frameImages = (JArray)frame; var tileFrame = new TileAnimationFrame(); foreach (var frameImage in frameImages) { /* * pattern: 1, // 1-based tile index * x: 0, // center-based x-offset * y: 16, // center-based y-offset * zoom: 30, // 100-based scale * rotation: 0, // 360-degree * opacity: 100 // 255 = full visible, 0 = full trans */ // Make index 0-based! var patIndex = (int)(frameImage["pattern"]) - 1; var patX = (int)(frameImage["x"]); var patY = (int)(frameImage["y"]); var patZoom = (int)(frameImage["zoom"]); var patRotation = (int)(frameImage["rotation"]); var patOpacity = (int)(frameImage["opacity"]); if (patIndex > 0) { tilesetSource.X = (patIndex % tilesPerRow) * tilesetSource.Width; tilesetSource.Y = (patIndex / tilesPerRow) * tilesetSource.Width; } else { tilesetSource.X = 0; tilesetSource.Y = 0; } var scale = patZoom / 100f; var pos = new Point2D(patX + basePos.X, patY + basePos.Y); var mirror = SpriteEffects.None; var col = new Color(Color.White.R, Color.White.G, Color.White.B, patOpacity); var isBackground = false; // TODO: How does RPG Maker handle this? var rot = (float)patRotation; var pattern = new TileAnimationFrameImage(tilesetSource.Clone() as TileCellSource, scale, pos, mirror, col, rot, isBackground); tileFrame.Add(pattern); } ani.Frames.Add(tileFrame); } return ani; }
public static TileLoadResult Load(string filename, out TileAnimation ani) { using (var fileStream = System.IO.File.OpenRead(filename)) return Load(fileStream, out ani); }
public static TileLoadResult Load(string filename, out TileAnimation ani) { using (var fileStream = System.IO.File.OpenRead(filename)) return(Load(fileStream, out ani)); }
private void OpenAnimation(string fileName) { mSelectedAnimation = -1; mSelectedFrame = -1; SelectImagePreview(-1); if (TileAnimation.Load(fileName, out mAnimation) != TileLoadResult.Success) { mAnimation = new TileAnimation(); // avoid "null" crashes } ReloadAnimation(); }
private void menuEditorImportRpgMaker_Click(object sender, EventArgs e) { using (var frm = new FormImportRpgMaker()) { if (frm.ShowDialog(this) != DialogResult.OK) { return; } var selectedAnim = frm.SelectedAnimation; var newTileAnimation = TileAnimation.LoadFromJson(selectedAnim); mAnimation = newTileAnimation.Clone() as TileAnimation; // FIX: RPG Maker XP effects are based on a larger character /* foreach (var frame in mAnimation.Frames) { foreach (var image in frame) { if (image.Scale > 0.1f) { image.Scale = image.Scale * 0.5f; } } } */ ReloadAnimation(); } }
private void MenuEditorNew_Click(object sender, EventArgs e) { mSelectedAnimation = -1; mSelectedFrame = -1; SelectImagePreview(-1); mAnimation = new TileAnimation(); listFrameImages.Items.Clear(); listFrames.Items.Clear(); listFrames.Items.Add("Frame " + 1); cmbTilesets.SelectedIndex = 0; comboFrameCount.SelectedIndex = 0; listFrames.SelectedItem = 0; numFrameTime.Value = (int)(mAnimation.FrameLength * 1000f); }
public CompiledTileAnimationData(TileAnimation bani, TileLoadResult res) { CompiledData = bani; Result = res; }