/// <summary> /// Add an line as a commented animation line. /// </summary> /// <param name="name"></param> private void AddAnimation(String name) { animation_t newAnim; newAnim = new animation_t(); newAnim.Name = name; newAnim.isComment = true; newAnim.nextAnim = null; AddAnimationToStack(newAnim); }
private void AddAnimation(String name, int startFrame, int frameCount, String loopFrame, String frameSpeed) { animation_t newAnim; newAnim = new animation_t(); newAnim.Name = name; newAnim.startFrame = startFrame; newAnim.frameCount = frameCount; newAnim.loopFrame = loopFrame; newAnim.frameSpeed = frameSpeed; newAnim.isComment = false; newAnim.nextAnim = null; AddAnimationToStack(newAnim); }
private void AddAnimationToStack(animation_t newAnim) { if (animationList == null) {//first animation animationList = newAnim; } else { animation_t currentList = animationList; while (currentList.nextAnim != null) { currentList = currentList.nextAnim; } currentList.nextAnim = newAnim; } }
private void SaveAnimationsToFile(StreamWriter outStream) { for (animation_t currentAnimation = animationList; currentAnimation != null; currentAnimation = currentAnimation.nextAnim) { if (currentAnimation.isComment) { outStream.WriteLine(currentAnimation.Name); } else { outStream.WriteLine("{0,-37}\t{1}\t{2}\t{3}\t{4}", currentAnimation.Name, currentAnimation.startFrame, currentAnimation.frameCount, currentAnimation.loopFrame, currentAnimation.frameSpeed); } } outStream.Close(); }
private void ActionMergeCfgs(object obj, EventArgs ea) { FileStream baseFileStream, addFileStream, outFileStream; try { baseFileStream = new FileStream(baseFile.Text, FileMode.Open, FileAccess.Read); } catch (FileNotFoundException e) {//bad base file MessageBox.Show(e.Message, "Primary File Load Error"); return; } try { addFileStream = new FileStream(addFile.Text, FileMode.Open, FileAccess.Read); } catch (FileNotFoundException e) {//bad add file MessageBox.Show(e.Message, "Secondary File Load Error"); return; } try { outFileStream = new FileStream(outFile.Text, FileMode.Create, FileAccess.Write); } catch (Exception e) {//bad add file MessageBox.Show(e.Message, "Output File Save Error"); return; } StreamReader baseIn = new StreamReader(baseFileStream); LoadAnimationsFromFile(baseIn, baseFile.Text, 0); baseIn.Close(); //determine the frame offset for the additional file. int frameOffset = 0; animation_t currentAnim = animationList; if (currentAnim == null) { MessageBox.Show("No animation data was found in the primary file!\nContinuing to secondary file.", "Merging Error"); } else { for (; currentAnim != null; currentAnim = currentAnim.nextAnim) { if (!currentAnim.isComment) { int currentAnimOffset = currentAnim.startFrame + currentAnim.frameCount - 1; if (currentAnimOffset >= frameOffset) { frameOffset = currentAnimOffset + 1; } } } if (frameOffset == 0) { MessageBox.Show("No animation frames used in the primary file!\nContinuing to secondary file.", "Merging Error"); } //adjusting for root frame removal. //This occurs if the user uses the -o option for glamerge and there was a root frame if (addRoot.Checked) { frameOffset--; } } StreamReader addIn = new StreamReader(addFileStream); LoadAnimationsFromFile(addIn, addFile.Text, frameOffset); addIn.Close(); StreamWriter output = new StreamWriter(outFileStream); SaveAnimationsToFile(output); //delete the animation list animationList = null; MessageBox.Show("Successfully merged animation.cfg files."); }