Skip to content

Commit

Permalink
feat: StateViewerに駅リスト・時刻表・スタフの編集を試せるボタンを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic9045 committed Apr 9, 2022
1 parent 61df383 commit 16dd6e1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows.Forms;

using Automatic9045.AtsEx.PluginHost;
using Automatic9045.AtsEx.PluginHost.ClassWrappers;

namespace Automatic9045.VehiclePlugins.StateViewer
{
Expand All @@ -15,10 +16,10 @@ public partial class StateForm : Form
private IApp App;
private IBveHacker BveHacker;

private IVehicle Vehicle;
private IRoute Route;
private AtsEx.PluginHost.IVehicle Vehicle;
private AtsEx.PluginHost.IRoute Route;

public StateForm(IApp app, IBveHacker bveHacker, IVehicle vehicle, IRoute route)
public StateForm(IApp app, IBveHacker bveHacker, AtsEx.PluginHost.IVehicle vehicle, AtsEx.PluginHost.IRoute route)
{
App = app;
BveHacker = bveHacker;
Expand Down Expand Up @@ -67,6 +68,36 @@ private void OnKeyDown(object sender, KeyEventArgs e)
}
}

private void OnButtonClicked(object sender, EventArgs e)
{
IStationList stations = BveHacker.CurrentScenarioProvider.Route.Stations;
if (stations.Count == 0) return;
stations.RemoveAt(stations.Count - 1);

if (stations.Count == 0)
{
RemoveLastStationButton.Enabled = false;
}
else
{
IStation lastStation = stations.Last() as IStation;
lastStation.DepertureTime = int.MaxValue; // 終点の発車時刻は int.MaxValue に設定する
lastStation.Pass = false;
lastStation.IsTerminal = true;
}

ITimeTable timeTable = BveHacker.CurrentScenarioProvider.TimeTable;
timeTable.NameTexts = new string[stations.Count + 1];
timeTable.NameTextWidths = new int[stations.Count + 1];
timeTable.ArrivalTimeTexts = new string[stations.Count + 1];
timeTable.ArrivalTimeTextWidths = new int[stations.Count + 1];
timeTable.DepertureTimeTexts = new string[stations.Count + 1];
timeTable.DepertureTimeTextWidths = new int[stations.Count + 1];
timeTable.Update();

BveHacker.UpdateDiagram();
}

private void Elapse(EventArgs e)
{
if (!TimeValue.Focused) TimeValue.Text = Route.Time.ToString("HH:mm:ss");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public partial class StateForm : Form
protected Label DisplaySpeedKey;
protected Label DisplaySpeedValue;

protected Button RemoveLastStationButton;

protected void InitializeComponent()
{
MaximizeBox = false;
Expand Down Expand Up @@ -220,6 +222,16 @@ protected void InitializeComponent()
};
DisplaySpeedValue.KeyDown += OnKeyDown;
Controls.Add(DisplaySpeedValue);

RemoveLastStationButton = new Button()
{
Left = 16,
Top = 304,
Width = 80,
Text = "駅を減らす",
};
RemoveLastStationButton.Click += OnButtonClicked;
Controls.Add(RemoveLastStationButton);
}
}
}

0 comments on commit 16dd6e1

Please sign in to comment.