Module RandomTrainSimWorld2.main
Class SaveLoco
java.lang.Object
com.github.freddyyj.randomtrainsimworld.config.SaveLoco
public class SaveLoco extends Object
Class for managing savefile.
Don't create this object. Use
Main.setSaveFilePath(String) or Main.saveAs(String) instead.-
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidaddLocomotive(String route, String loco)Add locomotive to route.voidaddRoute(String route)Add route to savefile.voidaddWeather(String weather)Add weather to savefile.ArrayList<String>getLocomotive(String route)Get locomotive list that unselected.ArrayList<String>getRoute()Get route list that unselected.ArrayList<String>getWeather()Get weather list that unselected.booleanhasSavefile()booleanisChanged()voidreload()Reload savefile.voidremoveLocomotive(String route, String loco)Remove locomotive from route.voidremoveRoute(String route)Remove route from savefile.voidremoveWeather(String weather)Remove weather from savefile.voidsave()Save savefile.voidsave(File file)Save savefile at specificFile.voidsetFilePath(String path)Set savefile path.
-
Constructor Details
-
SaveLoco
Constructor with route listRoute list most has all routes.
- Parameters:
routes- list of all routes
-
SaveLoco
Constructor with route list and savefile pathRoute list most has all routes.
- Parameters:
routes- list of all routesdefaultPath- savefile path- Throws:
PermissionDeniedException- If save file cannot accessibleFileNotFoundException- If save file not existIOException- If IO errors occurred
-
-
Method Details
-
hasSavefile
public boolean hasSavefile() -
reload
Reload savefile.- Throws:
FileNotFoundException
-
setFilePath
Set savefile path.- Parameters:
path- file path
-
getRoute
Get route list that unselected.- Returns:
- unselected route list
-
getLocomotive
Get locomotive list that unselected.- Returns:
- unselected locomotive list
-
getWeather
Get weather list that unselected.- Returns:
- unselected weather list
-
addRoute
Add route to savefile.This route must be unselected.
- Parameters:
route- unselected route name
-
addLocomotive
Add locomotive to route.Locomotive must be unselected.
- Parameters:
route- route of locomotiveloco- locomotive name
-
addWeather
Add weather to savefile.Weather must be unselected.
- Parameters:
weather- weather name
-
removeRoute
Remove route from savefile.Route must be selected.
- Parameters:
route- route name
-
removeLocomotive
Remove locomotive from route.Locomotive must be selected.
- Parameters:
route- route of locomotiveloco- locomotive name
-
removeWeather
Remove weather from savefile.Weather must be selected.
- Parameters:
weather- weather name
-
save
Save savefile.- Throws:
IOException
-
save
Save savefile at specificFile.- Parameters:
file- savefile file- Throws:
IOException
-
isChanged
public boolean isChanged()
-