Add fleet save slots and rotatable onboard venues
This commit is contained in:
@@ -61,13 +61,13 @@ namespace Soundings
|
||||
root = document.rootVisualElement;
|
||||
root.style.flexGrow = 1;
|
||||
root.style.unityFontDefinition = interfaceFont;
|
||||
foreach (string sheet in new[] { "Soundings", "Shipwork", "Ledger", "FirstVoyageGuide", "Passage", "ServiceControls", "FleetOverview" })
|
||||
foreach (string sheet in new[] { "Soundings", "Shipwork", "Ledger", "FirstVoyageGuide", "Passage", "ServiceControls", "FleetOverview", "Careers" })
|
||||
{
|
||||
StyleSheet stylesheet = Resources.Load<StyleSheet>(sheet);
|
||||
if (stylesheet != null)
|
||||
root.styleSheets.Add(stylesheet);
|
||||
}
|
||||
company = autoSmoke ? null : Load();
|
||||
InitializeCareers();
|
||||
Render();
|
||||
if (exportClips)
|
||||
StartCoroutine(ExportPortClips(arguments[clipArgument + 1]));
|
||||
@@ -75,39 +75,14 @@ namespace Soundings
|
||||
StartCoroutine(VisualSmoke());
|
||||
}
|
||||
|
||||
private Company Load()
|
||||
{
|
||||
if (!PlayerPrefs.HasKey(SaveKey))
|
||||
return null;
|
||||
try
|
||||
{
|
||||
Company loaded = JsonUtility.FromJson<Company>(PlayerPrefs.GetString(SaveKey));
|
||||
if (loaded != null && loaded.CanLoad())
|
||||
{
|
||||
loaded.RestoreHullDecks();
|
||||
return loaded;
|
||||
}
|
||||
}
|
||||
catch (ArgumentException exception)
|
||||
{
|
||||
Debug.LogWarning("Could not read the company save. " + exception.Message);
|
||||
}
|
||||
Notify("The company save could not be read.", true);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
if (autoSmoke)
|
||||
return;
|
||||
PlayerPrefs.SetString(SaveKey, JsonUtility.ToJson(company));
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
private void StartCompany(bool financed)
|
||||
private void StartCompany(bool financed, string name = null)
|
||||
{
|
||||
ResetFleetPassages();
|
||||
company = Company.Start(financed);
|
||||
careerId = Guid.NewGuid().ToString("N");
|
||||
careerName = name ?? AvailableCareerName(financed ? "Shipyard career" : "Meridian Line");
|
||||
careerMenu = CareerMenu.Closed;
|
||||
careerError = null;
|
||||
title = paused = fleetOpen = shipActionsOpen = false;
|
||||
page = financed ? 2 : 0;
|
||||
yardSelection = 1;
|
||||
@@ -212,7 +187,9 @@ namespace Soundings
|
||||
DrawPause();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(focus) && root.Q<VisualElement>(focus) != null)
|
||||
if (careerMenu != CareerMenu.Closed)
|
||||
DrawCareerMenu();
|
||||
else if (!string.IsNullOrEmpty(focus) && root.Q<VisualElement>(focus) != null)
|
||||
root.schedule.Execute(() => root.Q<VisualElement>(focus)?.Focus());
|
||||
}
|
||||
|
||||
@@ -241,22 +218,22 @@ namespace Soundings
|
||||
|
||||
if (pendingStart.HasValue)
|
||||
{
|
||||
AddDisplay(intro, "Replace this company?", "title-question");
|
||||
AddText(intro, "A new career replaces your saved fleet and voyages.", "title-confirm-copy");
|
||||
intro.Add(Action("Start a new career", () => StartCompany(pendingStart.Value), "primary title-command", "replace"));
|
||||
intro.Add(Action("Keep my company", () => { pendingStart = null; Render(); }, "title-command", "keep"));
|
||||
AddDisplay(intro, "Name your new career", "title-question");
|
||||
CareerNameField(intro);
|
||||
if (!string.IsNullOrEmpty(careerError))
|
||||
AddText(intro, careerError, "career-save-error");
|
||||
intro.Add(Action("Start a new career", StartNamedCareer, "primary title-command", "replace"));
|
||||
intro.Add(Action("Back", () => { pendingStart = null; careerError = null; Render(); }, "title-command", "keep"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (company != null)
|
||||
intro.Add(Action("Continue career", () =>
|
||||
{
|
||||
title = false;
|
||||
page = Ship == null ? 2 : 0;
|
||||
ResetItinerary();
|
||||
Notify(null);
|
||||
Render();
|
||||
}, "primary title-command", "resume"));
|
||||
{
|
||||
Button resume = Action("Continue career", () => LoadCareer(careerId), "primary title-command", "resume");
|
||||
resume.tooltip = careerName;
|
||||
intro.Add(resume);
|
||||
intro.Add(Action("Load game", () => OpenCareerMenu(CareerMenu.Load), "title-command", "career-load-open"));
|
||||
}
|
||||
|
||||
StartOption(intro, "Take the helm", "Used coastal ship / $135,000 cash / No debt", false);
|
||||
StartOption(intro, "Start from the shipyard", "Empty fleet / $580,000 cash / $500,000 loan", true);
|
||||
@@ -276,13 +253,11 @@ namespace Soundings
|
||||
{
|
||||
Button option = Action("", () =>
|
||||
{
|
||||
if (company == null)
|
||||
StartCompany(financed);
|
||||
else
|
||||
{
|
||||
pendingStart = financed;
|
||||
Render();
|
||||
}
|
||||
pendingStart = financed;
|
||||
careerNameDraft = AvailableCareerName(financed ? "Shipyard career" : "Meridian Line");
|
||||
careerError = null;
|
||||
Notify(null);
|
||||
Render();
|
||||
}, "career-option", financed ? "start-financed" : "start-used");
|
||||
AddText(option, titleText, "career-option-name");
|
||||
AddText(option, description, "career-option-balance");
|
||||
@@ -431,19 +406,15 @@ namespace Soundings
|
||||
GameIcon(menu, "anchor");
|
||||
AddDisplay(menu, "Paused", "pause-title");
|
||||
menu.Add(Action("Resume", () => { paused = false; Render(); }, "primary pause-command", "resume-game"));
|
||||
menu.Add(Action("Restart first voyage guide", RestartGuide, "pause-command", "restart-guide"));
|
||||
if (fleetPassages.Count == 0 && underway == null)
|
||||
{
|
||||
menu.Add(Action("Title screen", () =>
|
||||
{
|
||||
paused = fleetOpen = shipActionsOpen = false;
|
||||
title = true;
|
||||
Notify(null);
|
||||
Render();
|
||||
}, "pause-command", "return-title"));
|
||||
}
|
||||
var saving = Add(menu, "career-pause-actions");
|
||||
saving.Add(Action("Save game", SaveFromPause, "pause-command", "career-save"));
|
||||
saving.Add(Action("Save as…", () => OpenCareerMenu(CareerMenu.SaveAs), "pause-command", "career-save-as"));
|
||||
menu.Add(Action("Load game", () => OpenCareerMenu(CareerMenu.Load), "pause-command", "career-load-open"));
|
||||
menu.Add(Action("Save and return to title", () => SaveAndLeave(false), "pause-command", "return-title"));
|
||||
if (!Application.isEditor && Application.platform != RuntimePlatform.WebGLPlayer)
|
||||
menu.Add(Action("Quit to desktop", () => Application.Quit(), "pause-command", "quit-game"));
|
||||
menu.Add(Action("Save and quit", () => SaveAndLeave(true), "pause-command", "quit-game"));
|
||||
menu.Add(Action("Restart first voyage guide", RestartGuide, "pause-command", "restart-guide"));
|
||||
AddNotice(menu);
|
||||
}
|
||||
|
||||
private void AttachCamera(VisualElement world)
|
||||
|
||||
Reference in New Issue
Block a user