Make Soundings voyages playable with ship operations and guided tips

This commit is contained in:
josh
2026-11-27 22:24:17 -05:00
parent 4b870fb0ce
commit 33cdd6dfa7
37 changed files with 2734 additions and 126 deletions

View File

@@ -55,7 +55,7 @@ namespace Soundings
root = document.rootVisualElement;
root.style.flexGrow = 1;
root.style.unityFontDefinition = interfaceFont;
foreach (string sheet in new[] { "Soundings", "Shipwork", "Ledger", "FirstVoyageGuide" })
foreach (string sheet in new[] { "Soundings", "Shipwork", "Ledger", "FirstVoyageGuide", "Passage", "ServiceControls" })
{
StyleSheet stylesheet = Resources.Load<StyleSheet>(sheet);
if (stylesheet != null)
@@ -105,7 +105,9 @@ namespace Soundings
ledgerRecordOffset = 0;
ledgerAccounts = false;
worldChart = false;
ResetWeatherSelection();
tool = Facility.Cabin;
systemTools = false;
shipName = "Peregrine";
pendingStart = null;
harbor.ResetView(true);
@@ -173,6 +175,7 @@ namespace Soundings
private void Render()
{
string focus = (root.focusController?.focusedElement as VisualElement)?.name;
SetPassageFreeLook(false);
root.Clear();
bool showingHarbor = !title && company != null && HarborOnScreen;
harbor.SetVisible(showingHarbor);
@@ -287,7 +290,10 @@ namespace Soundings
scene.pickingMode = PickingMode.Ignore;
scene.SetEnabled(!paused);
if (underway != null)
{
DrawUnderway(scene);
DrawServiceNavigation(scene);
}
else
{
switch (page)
@@ -325,10 +331,11 @@ namespace Soundings
DrawHotbar(shell).SetEnabled(!paused);
if (fleetOpen)
DrawFleet(shell).SetEnabled(!paused);
if (!paused && !fleetOpen)
DrawGuide(shell);
}
if (!paused && !fleetOpen)
DrawGuide(shell);
if (!string.IsNullOrEmpty(notice))
{
var toast = Add(shell, "game-toast");
@@ -431,13 +438,9 @@ 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 (underway == null)
{
menu.Add(Action("Restart first voyage guide", () =>
{
paused = false;
RestartGuide();
}, "pause-command", "restart-guide"));
menu.Add(Action("Title screen", () =>
{
paused = fleetOpen = shipActionsOpen = false;
@@ -453,6 +456,7 @@ namespace Soundings
private void AttachCamera(VisualElement world)
{
int pointerId = -1;
bool freeLook = false;
Vector2 start = Vector2.zero, last = Vector2.zero;
bool dragging = false;
world.RegisterCallback<PointerDownEvent>(evt =>
@@ -460,6 +464,8 @@ namespace Soundings
if (paused || pointerId >= 0 || (evt.button != 0 && evt.button != 1))
return;
pointerId = evt.pointerId;
freeLook = underway != null && evt.button == 1;
SetPassageFreeLook(freeLook);
start = last = evt.localPosition;
dragging = false;
world.CapturePointer(pointerId);
@@ -473,7 +479,10 @@ namespace Soundings
if (dragging || (position - start).sqrMagnitude > 16)
{
dragging = true;
harbor.Orbit(position - last);
if (!freeLook)
harbor.Orbit(position - last);
else if (!passageCursorLocked)
harbor.Look(position - last);
}
last = position;
});
@@ -482,6 +491,8 @@ namespace Soundings
if (evt.pointerId != pointerId)
return;
pointerId = -1;
freeLook = false;
SetPassageFreeLook(false);
world.ReleasePointer(evt.pointerId);
if (!dragging && evt.button == 0 && underway == null && Ship != null &&
harbor.IsShipAt(new Vector2(evt.localPosition.x / world.resolvedStyle.width,
@@ -491,7 +502,18 @@ namespace Soundings
Render();
}
});
world.RegisterCallback<PointerCaptureOutEvent>(_ => pointerId = -1);
world.RegisterCallback<PointerCaptureOutEvent>(_ =>
{
pointerId = -1;
freeLook = false;
if (!passageCursorLocked || !Input.GetMouseButton(1))
SetPassageFreeLook(false);
});
world.RegisterCallback<PointerCancelEvent>(evt =>
{
if (evt.pointerId == pointerId)
world.ReleasePointer(pointerId);
});
world.RegisterCallback<WheelEvent>(evt =>
{
if (paused)
@@ -577,6 +599,7 @@ namespace Soundings
private void OnDestroy()
{
SetPassageFreeLook(false);
if (panel != null)
Destroy(panel);
}