Add multi-stop voyages, a live chart, and named port announcements

This commit is contained in:
josh
2026-11-27 23:41:08 -05:00
parent cc7620c431
commit 9500813df4
111 changed files with 2037 additions and 38 deletions

View File

@@ -53,7 +53,14 @@ namespace Soundings
private void OpenVoyageChart()
{
int port = destination >= 0 ? destination : Ship?.Port ?? 0;
itineraryEditorShip = null;
int planned = Ship?.Itinerary?.NextPort ?? -1;
int port = planned >= 0 ? planned : destination >= 0 ? destination : Ship?.Port ?? 0;
if (planned >= 0 && destination != planned)
{
destination = planned;
SetRecommendedFuel();
}
worldChart = port >= Market.StarterPortCount || (Ship?.Port ?? 0) >= Market.StarterPortCount;
inspectedPort = port;
chartScrollPosition = 0;
@@ -75,6 +82,8 @@ namespace Soundings
var switches = Add(board, "chart-scopes");
switches.Add(Action("Atlantic", () => ChangeChart(false), worldChart ? "chart-scope" : "chart-scope chart-scope-current", "chart-atlantic"));
switches.Add(Action("World", () => ChangeChart(true), worldChart ? "chart-scope chart-scope-current" : "chart-scope", "chart-world"));
if (Ship != null)
DrawItineraryButton(switches, Ship);
for (int i = 0; i < ChartPortCount; i++)
{
@@ -90,6 +99,13 @@ namespace Soundings
styles += " chart-port-locked";
if (selected)
styles += " chart-port-selected";
if (Ship?.Itinerary is CruiseItinerary itinerary)
{
if (IsPendingCall(itinerary, i))
styles += " chart-port-planned";
if (i == itinerary.NextPort)
styles += " chart-port-next";
}
var marker = Action("", () => InspectChartPort(portId), styles, "port-" + i);
marker.tooltip = $"{port.Name} · {(berth ? "Current port" : cleared ? "Permit held" : "Permit required")}";
@@ -99,7 +115,7 @@ namespace Soundings
var light = Add(marker, "chart-pin-light");
light.pickingMode = PickingMode.Ignore;
var caption = AddText(marker, port.Name, point.x > .77f ? "chart-pin-label chart-pin-label-west" : "chart-pin-label");
caption.EnableInClassList("chart-pin-label-on-focus", worldChart && !selected && !berth);
caption.EnableInClassList("chart-pin-label-on-focus", worldChart && !selected && !berth && Ship?.Itinerary?.NextPort != i);
plot.Add(marker);
}
@@ -118,7 +134,10 @@ namespace Soundings
var contents = Add(folio, "chart-folio-content");
AddText(contents, "LOOK UP PORT", "chart-paper-kicker");
AddChartDirectory(contents);
DrawPortFolio(board, contents);
if (EditingItinerary)
DrawItineraryFolio(contents, Ship);
else
DrawPortFolio(board, contents);
}
private static void ChartKey(VisualElement legend, string name, string color)
@@ -154,11 +173,15 @@ namespace Soundings
Voyage quote = ship == null ? null : company.Forecast(ship, selected);
bool permitted = company.Permits[selected];
bool eligible = ship == null || ship.HullIndex >= port.MinimumHull;
int nextCall = ship?.Itinerary?.NextPort ?? -1;
AddDisplay(parent, port.Name, "chart-port-name");
AddText(parent, $"{port.Country} · {port.Region}", "chart-paper-caption");
if (quote != null && permitted && eligible)
if (nextCall >= 0)
DrawNextCall(parent, ship.Itinerary, selected);
if (quote != null && permitted && eligible && (nextCall < 0 || selected == nextCall))
{
DrawVoyageFolio(board, parent, ship, quote);
return;
@@ -199,7 +222,7 @@ namespace Soundings
AddText(parent, "Assign a vessel to plan a sailing.", "chart-paper-note");
parent.Add(Action("Visit shipyard", () => ChangePage(2), "chart-ink-button chart-wide-button"));
}
else
else if (nextCall < 0)
{
AddText(parent, $"There is no direct route from {Market.Ports[ship.Port].Name}. Select a linked port to plan this sailing.", "chart-paper-note");
}
@@ -209,10 +232,13 @@ namespace Soundings
private void InspectChartPort(int port)
{
if (port >= Market.StarterPortCount)
worldChart = true;
if (port != inspectedPort)
chartScrollPosition = 0;
inspectedPort = port;
if (Ship != null && Market.TryDistance(Ship.Port, port, out _) && destination != port)
if (Ship != null && !EditingItinerary && Ship.Itinerary?.HasNext != true
&& Market.TryDistance(Ship.Port, port, out _) && destination != port)
{
destination = port;
SetRecommendedFuel();
@@ -304,9 +330,11 @@ namespace Soundings
painter.Stroke();
}
int berth = Ship?.Port ?? -1;
Ship ship = Ship;
int berth = ship?.Port ?? -1;
int selectionOrigin = EditingItinerary && ship != null ? ItineraryTail(ship) : berth;
bool CanShow(Lane lane) => lane.A < ChartPortCount && lane.B < ChartPortCount;
bool IsSelected(Lane lane) => berth >= 0 && lane.Other(berth) == inspectedPort;
bool IsSelected(Lane lane) => selectionOrigin >= 0 && lane.Other(selectionOrigin) == inspectedPort;
foreach (Lane lane in Market.Lanes)
{
@@ -323,6 +351,29 @@ namespace Soundings
DrawLane(lane, new Color(.98f, .75f, .38f, 1), 2.3f);
}
if (ship?.Itinerary is CruiseItinerary itinerary)
{
int from = itinerary.Origin;
for (int i = 0; i < itinerary.TotalStops; i++)
{
int to = itinerary.Stops[i];
var route = new Lane(from, to, 0);
if (i != itinerary.CompletedStops && CanShow(route))
{
Color color = i < itinerary.CompletedStops ? new Color(.48f, .64f, .61f, .74f) : new Color(.48f, .88f, .78f);
DrawLane(route, color, 2.4f);
}
from = to;
}
var nextRoute = new Lane(berth, itinerary.NextPort, 0);
if (itinerary.HasNext && CanShow(nextRoute))
{
DrawLane(nextRoute, new Color(.94f, .74f, .40f, .23f), 8);
DrawLane(nextRoute, new Color(1f, .85f, .55f), 3f);
}
}
DrawCompass(painter, new Vector2(width - 69, height - 76), 34);
void DrawLane(Lane lane, Color color, float thickness)