1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101open System.Globalization
open System.Threading
open Duets.Agents
open Duets.Cli.SceneIndex
open Duets.Cli.Components
open Duets.Cli.Text
open Duets.Cli.Scenes
/// Determines whether the given scene is out of gameplay (main menu, creators,
/// etc.) or not.
let private outOfGameplayScene scene =
match scene with
| Scene.MainMenu
| Scene.Settings
| Scene.CharacterCreator
| Scene.BandCreator _
| Scene.SkillEditor _
| Scene.WorldSelector _
| Scene.Exit _ -> true
| _ -> false
/// Saves the game to the savegame file only if the screen is not the main menu,
/// character creator or band creator, which still have unreliable data or
/// might not have data at all.
let saveIfNeeded skipSaving scene =
if not (outOfGameplayScene scene) && not skipSaving then
Savegame.save ()
else
()
let rec showScene skipSaving scene =
saveIfNeeded skipSaving scene
match scene with
| Scene.MainMenu -> MainMenu.mainMenu skipSaving |> showScene skipSaving
| Scene.Settings -> Settings.settings () |> showScene skipSaving
| Scene.Cheats -> Cheats.cheatsScene () |> showScene skipSaving
| Scene.CharacterCreator ->
NewGame.CharacterCreator.characterCreator () |> showScene skipSaving
| Scene.WorldSelector character ->
NewGame.WorldSelector.worldSelector character |> showScene skipSaving
| Scene.BandCreator(character, originCity) ->
NewGame.BandCreator.bandCreator character originCity
|> showScene skipSaving
| Scene.SkillEditor(character, characterMember, band, originCity) ->
NewGame.SkillEditor.skillEditor
character
characterMember
band
originCity
|> showScene skipSaving
| Scene.Phone -> Phone.Root.phoneScene () |> showScene skipSaving
| Scene.World ->
World.worldScene World.WorldMode.IgnoreDescription
|> showScene skipSaving
| Scene.WorldAfterMovement ->
World.worldScene World.WorldMode.ShowDescription |> showScene skipSaving
| Scene.Exit exitMode ->
match exitMode with
| ExitMode.SaveGame when not skipSaving ->
Savegame.saveSync ()
Log.dumpToFileSync ()
| _ -> ()
let private parseNoSavingArg args =
args |> Array.tryHead |> Option.exists (fun arg -> arg = "--no-saving")
[<EntryPoint>]
let main args =
let skipSaving = parseNoSavingArg args
LanguageModel.initialize
|> showProgressForFunc (Styles.progress "Initializing game...")
clearScreen ()
Stats.startTrackingTime ()
// Set default culture to UK for sane defaults :)
Thread.CurrentThread.CurrentCulture <- CultureInfo("en-UK")
try
Scene.MainMenu |> showScene skipSaving
with ex ->
"""
An irrecoverable error happened.
If you haven't been tinkering with the save file and you believe this is a bug,
please report it in the game's repository:
https://github.com/sleepyfran/duets/issues
And attach the following exception trace:
"""
|> Styles.danger
|> showMessage
ex |> showException
Stats.stopTrackingAndSave ()
0