Post news Report RSS Doomverse Dev Log #2: File Structures

Just overviewing the file structure system I am implementing for the launcher.

Posted by on

Hey all!

So for this entry, you won't see much changes in UI. This is mostly changes to the internal workings of the code and the file structures.

The File Structure


A screenshot showing the layout of the ~/doomverse/ folder

Screen Shot 2023 05 12 at 9 12 2


Folders

I made a variable in the code that refers to a system files folder that stores IWADS and other mods. Currently, it's located at ~/doomverse/. The folders consist of the following:

  • Assets Folder: As of now, it only stores data for the cover art. I might use this for other things in the future, but as of now I can't think of anything else to put in here.
  • Games Folder: This folder contains sub folders containing the files for a specific mod. Say you create an instance with Brutal Doom and BTSX under the name "Brutal BTSX" The necessary mod files will be stored in "games/brutal-btsx"
  • IWADS Folder: This folder stores game files, so DOOM.WAD, DOOM2.WAD, PLUTONIA.WAD, TNT.WAD, and even freedoom wads. When the program is first run, it will ask you to import your game files, and they will be put in this folder. This can avoid having duplicates of the same file for different instances.
  • Ports Folder: This folder stores the source ports the user may download. I plan on adding a feature where you can download different source ports (even specific versions) all within the launcher, and it will be downloaded to this ports folder. This should hopefully prevent having the user to have to navigate through a bunch of files to find their source port.

Files

  • Games.cfg: This file stores the launch parameters for each mod instance, as well as data for the library view. Currently, games.cfg is not serving any purpose and has been replaced by profiles.json. I switched to json because I could add more depth to the file as opposed to a .cfg file.

Example entry in games.cfg:

Example of an entry in .cfg


Example entry in profiles.json:

Example of an entry in profiles.json


As you can probably tell, the json file goes into a lot more detail about user preferences, mostly due to it's ability to nest objects. That's why I decided to replace .cfg with .json. I also have more experience storing data with .json. Furthermore, the server runs on electron.js, a javascript framework, and json objects were basically made for javascript so it makes the most sense to use json instead.

Parsing the Files


Looking for Base Games

Every time the application is launched, it looks in the ~/doomverse/iwads folder to see which games are currently in that folder. For each file in that folder, get the name. If the name matches doom.wad, doom2.wad, plutonia.wad, or tnt.wad, add it to the config file. If they already exist, ignore it. Now we can begin loading the library for the user to see.

Loading the Library

In order for the user to see their games in their library, a series of functions must be called to parse through the config files. The base games have been added to the config files on top of whatever mod configurations the user already had in there. A function on the server side goes through each one, grabs the name, author, year, and cover art, and sends the data to the client. Every time the client receives game information, it creates a clickable div in the HTML containing the cover art, name, author, year, etc. This process is almost instant, but once it's done you would be greeted with your library.

Launching Games

When any of the game covers are clicked, it triggers a function on the client side called launchGame(). It then gets the name of the game you clicked, and tells the server to launch the game. On the server side, it parses through the user config file starting with the game's source port, base game, mods, then flags. Essentially, it constructs a command that is then executed using the OS module. This maybe isn't the best way to do it, but if y'all can think of another way that would be great.


Anyways, that's all I have to say for this entry. I added some more information because before it was pretty sparse. I was scared about reaching the character limit, but I think that was a one time occurrence because I haven't run into the problem again.

If you have any questions or suggestions, feel free to comment or reach out to me on Discord at rantintosh#0001

Thanks for reading!

Post comment Comments
IONBiscuit
IONBiscuit - - 4 comments

This is cool, following you so I can keep updated

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: