City Of Heroes Demo Editor

Screenshots

Screenshot of the demo editor

Description

Demos in City of Heroes are recorded as text scripts. Players can edit these scripts to change events, camera angles and motions, and the time between events. You can even add things that didn't happen, such as substituting the air blimp for an alien space craft. The City of Heroes Demo Editor began life as a console program to stop the camera from moving ("Fix Camera"). The other features, including the Graphical User Interface, appeared as I needed them, including the backup facility that creates a backup copy of the demo file before it's changed by the program.

Still from a City Of Heroes video

Above is a still from one of the movies I made with the help of this utility. Fixing the camera to a single position simplfies making new camera movements within the demo.

Code Sample

public void stripChat() {
	System.out.print("Stripping Chat Text.........");
	File temp = makeTempFile();
	String info = null;
	
	BufferedWriter toFile = null;
	BufferedReader frmFile = null;
	
	try {
		//Copy demo file to temporary file
		copy(demoFile, temp);
		demoFile.delete();
		
		demoFile = new File(demoPath);
		
		toFile = writeFile(demoFile);
		frmFile = readFile(temp);
		String[] infos = null;
		int time = 0;
		
		//Read each line and skip it if it contains chat text
		while ((info = frmFile.readLine()) != null){
			infos = breakLine(info);
			if(!infos[FUNC].equals(CHAT)){
				infos[TIME] = String.valueOf(time + Integer.parseInt(infos[TIME]));
				toFile.write(makeLine(infos));
				toFile.newLine();
				toFile.flush();
				time = 0;
			} else {
				time += Integer.parseInt(infos[TIME]); //Add time difference between lines so that we don't get out of sync 
			}
		}
		
		System.out.println(" DONE");
		toFile.close();
		frmFile.close();
		
	} catch (IOException e){
		System.out.println("FAILED");
		System.out.println(e);
		System.out.println("I/O Error while processing line: " + info);
		
		if (toFile != null){
			//try to close the destination file
			try { toFile.close(); } catch (Exception e){ /*Do Nothing */}
		}
		if (frmFile != null){
			//try to close the source file
			try { frmFile.close(); } catch (Exception e){ /*Do Nothing*/}
		}
	}
}