Monday, May 4, 2009

Under The Hood: Building S.E.D.S. 2.0 (Part 2)

Work continues on the next version of the Source Engine Demo Saver; in the meantime, I continue to give a look "Under The Hood" at the process of putting the program together. Today, we dive headfirst into the shallow end of Visual C#.

Part 2 - S.E.D.S. + C# in 10 Days or Less

After looking into VBasic and C++, I ended up settling on Visual C#. I started putting together S.E.D.S. 2.0 in C# on April 17th, 2009 using the Express Edition. S.E.D.S. 2.0 was released on April 25th, 8 days later. My understanding of coding being rather simplistic, I did a bit of looking around online, read some documents, and then sat down to write out the goals I wanted the program to achieve and the methods by which to achieve them. For example, I needed the S.E.D.S. to grab the demo files in a specified directory, rename them, and move them to a new directory with the current date. That's the goal, and the methodology for achieving it I wrote as follows:

User-Specifies Directory (USD) > Find USD > Find ".dem" files in USD > Find Current Date > Create Directory w/Current Date IF Needed > Move ".dem" files to Dated Directory > Find Current Time > Rename ".dem" files with Current Time

From this point, I set out to learn how to perform each step and then put it all together. MSDN was probably the most useful resource, but because my understanding of even the basic lingo was lacking, Google was used often to fill in gaps or view examples of code for modification and implementation of existing functions. In the end, Version 2.0 made use of this primary code block to save demos:

Click the image for full-size.

My coding is probably sloppy in places; such is the fate of most amateur workings, but I hope to improve upon it. More importantly for me was that it was functional; it achieved my goals in what was fairly simple. Even though it had looked very confusing on the outside, learning to work in Visual C# wasn't quite so daunting after I had taken the dive in.

Another great thing about working in Visual C# was making use of Windows Forms. It functions and looks much better than the original console version of the S.E.D.S. did. After getting the core aspects of it working, I set out to put together an installer to get the needed files ready for saving:

The above is the Version 2.0 installer; I hope to reinvent it in the next publicly released version to be a bit more flexible. The function of the installer will also be improved upon. The tasks the Installer sets out to work on are adding a line to the autoexec.cfg file that calls for the seds.cfg file, and to copy the program seds.cfg file to the "cfg" directory for the chosen games. This prevents the S.E.D.S. from overwriting user autoexec files (many people use their autoexec for other things, myself included) while still allowing me to update the seds.cfg in future editions for better functionality (which is also coming down the pipes with the next version).

Join me next time as we look at preventing and fixing the PEBKAC with a Help File, a look at the seds.cfg file in 2.0, and a coat of paint on S.E.D.S. 2.0.

Continued in Part 3 - PEBKAC, Files, and Finishing Touches

No comments:

Post a Comment

Questions? Comments? Suggestions? Leave a message.