I belong to a club that makes games at university. Since the number of people who know the specifications of the game launcher (hereinafter, the game launcher is sometimes called the launcher) that has been used for exhibiting games at school festivals for many years has decreased, I tried to recreate it from scratch. It was. There are various things that I couldn't make in time, but I would like to talk about them because they have taken shape. This article doesn't really touch on the design side of the launcher. ** I will mainly talk about how to automatically load, the folder structure of data, and the difficult points. ** I wish I could explain it in an easy-to-understand manner even if the language I am trying to create is not Java.
~~ A nice header was pasted in the blank part on the day, but for some reason I will hide it ;; ~~-IDEs such as Eclipse -Java runtime environment In Java, a Jar file is created when a Jar executable file for application is generated. The latest execution environment (jdk or jre) must be set in order to start the Jar file. It is troublesome because the setting is required even on the computer that launches the launcher. Also, use the framework to keep your design clean! Please refer to: https://www.sejuku.net/blog/60411
It's basically the same as Java. Integrated development environment IDE and execution environment for its language. And you have to check in advance whether it works on a computer that works properly when it becomes a launcher. Also, you will need to check from the program whether the exe file etc. works properly. Search for "OOO GUI" etc. to see if you can create the design you want.
Let's think about the necessary functions in advance. For example, in the case of my launcher ・ Like function ・ Fixed phrase function ・ A function to preferentially display works that have not been played much yet ・ Automatic loading function for games, etc. (Actually, it also supports videos, etc.) Especially for the last part, I thought it would be nice if not only I could update the launcher but everyone could update it by looking at the specifications.
I will introduce the folder structure of my launcher. Let's think about it properly because it is a launcher of the automatic loading function.
project ├src ├data │ └ images (images used for launcher, etc.) │ └ logs (folder for saving the number of likes and play time of works) └ExhibitionDatas └Games │ └ Game data └Graphics └ Video data, etc.
In my launcher, I used a file called launcher_config.ini (property file in java) to explain the work on the launcher and how to operate it. Specifically, it looks like the following.
The ini file is basically in text format, "Name" = value It's like writing it like a text file. With this, you can manipulate the output on the launcher by tweaking this text without having to mess with the contents of the launcher. If you ask someone who wants to put a game in the launcher to create this ini file, you will be able to play the game on the launcher!
First of all, the prepared class ・ Game data class (class that saves the contents of the ini file almost as it is) ・ Game data manager class (class that manages all game data classes) Required functions etc. ・ Function to read ini file Reference: https://qiita.com/motoki1990/items/2b643ea854624b09712c ・ File search function is.
qiita.java
private ArrayList<String> fileSearch(String path, String fileName){
File dir = new File(path);
File files[] = dir.listFiles();
for(int i=0; i<files.length; i++){
if(files[i].isDirectory()){ //Recursion for directories
fileSearch(path+"/"+files[i].getName(), fileName);
}else{
if(file_name.equals(fileName)){ //Output if the specified file is found
resultPaths.add(dir.getAbsolutePath()+"/");
}
}
}
return resultPaths;
}
First, pass the folder determined by the file search function (ExhibitionData because we want to read the game data this time) and the name of the ini file (launcher_config.ini in my case) to the file search function. ↓ The path to the ini file will be returned, and the game data manager class will use it. Put the data of the obtained path file in all game data classes. At this time, use the function that reads the ini file ↓ Launcher launched ↓ If the action to start the game is taken, the game data manager will Read and execute the path to the executable file of the game data class of the game to be started ↓ Launcher does not process while the game is running
Is the main flow. You may be able to execute the executable in various ways in java In the case of I, I used a standard Java library called ProcessingBuilder. In a nutshell, you will be able to do what you can with cmd. Therefore, you can execute it by using this and passing the path of the game executable file as an argument. Since ProcessingBuilder always manages whether it is running or not, you can set the launcher not to work during that time (convenient!)
At first, there were some that could be done using Processing Builder and some that could not. I did not know the cause, but if you just type the path to the executable file, you can execute it with cmd In processingBuilder, if you first move to the file where the executable file exists and then enter the name of the executable file It seems that it can be executed. In particular $ asdf / test / hogehoge / game.exe (← Processing Builder bugs) ↓ $ cd asdf/test/hogehoge $ game.exe It's like that. If anyone has the same content, please try it.
that's all, It was the first post. From the next time, I will do my best to write it a little more concisely. If you have any questions, please do.
Sites that have been very helpful: https://qiita.com/massoumen/items/66d26b08333aeae1c0ea
Recommended Posts