Skip to content

Commit

Permalink
列車時刻表の表示バグ(の一部)修正
Browse files Browse the repository at this point in the history
  • Loading branch information
01397 committed Oct 27, 2019
1 parent 55eede2 commit 9a66b43
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 12 deletions.
15 changes: 15 additions & 0 deletions dist/js/DiagramParser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/js/DiagramParser.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/js/components/TrainSubview.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/js/components/TrainSubview.js.map

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions dist/js/components/TrainTimetableView.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/js/components/TrainTimetableView.js.map

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/DiagramParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,19 @@ export class StationTime {
result.firstStationIndex = result._data.findIndex(v => v);
return result;
}
public update() {
const data = this._data;
let s: number = null,
e: number;
for (let i = 0; i < data.length; i++) {
if (!(i in data)) continue;
if (s === null) s = i;
if (data[i].stopType === 3) delete data[i];
e = i;
}
this.firstStationIndex = s;
this.terminalStationIndex = e;
}
/**
* 始発駅番号(方向別!!)
*/
Expand Down
4 changes: 3 additions & 1 deletion src/components/TrainSubview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default class TrainSubview extends Subview {
track: null,
};
}
this.cellInfo.train.timetable.update();
this.updateMainView();
};
const radio = new Array(3).fill(0).map((v, i) => {
Expand Down Expand Up @@ -227,7 +228,7 @@ export default class TrainSubview extends Subview {
const stationIndex =
this.cellInfo.train.direction === 0 ? this.cellInfo.stationIndex : this.app.data.railway.stations.length - this.cellInfo.stationIndex - 1;
if (!this.cellInfo.train.timetable.data[stationIndex]) {
if (arrival.value !== '' || departure.value !== '') return;
//if (arrival.value !== '' || departure.value !== '') return;
this.cellInfo.train.timetable.data[stationIndex] = {
stopType: 1,
arrival: null,
Expand Down Expand Up @@ -260,6 +261,7 @@ export default class TrainSubview extends Subview {
departure.value = ttd.departure !== null ? numberToTimeString(ttd.departure, 'HH MM SS') : '';
delta.value = ttd.arrival !== null && ttd.departure !== null ? numberToTimeString(ttd.departure - ttd.arrival, 'HH MM SS') : '';
this.updateMainView();
this.cellInfo.train.timetable.update();
}
public focusField(type: string) {
let field = null;
Expand Down
8 changes: 5 additions & 3 deletions src/components/TrainTimetableView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export default class TrainTimetableView extends View {
{
label: '列車',
submenu: [
{ label: '左に列車を挿入', accelerator: 'Alt+Left', click: () => this.insertTrain(this.getActiveCell[0]) },
{ label: '右に列車を挿入', accelerator: 'Alt+Right', click: () => this.insertTrain(this.getActiveCell[0] + 1) },
{ label: '左に列車を挿入', accelerator: 'Alt+Left', click: () => this.insertTrain(this.getActiveCell().col) },
{ label: '右に列車を挿入', accelerator: 'Alt+Right', click: () => this.insertTrain(this.getActiveCell().col + 1) },
],
},
]);
Expand Down Expand Up @@ -509,7 +509,9 @@ export default class TrainTimetableView extends View {
}
private insertTrain(index: number) {
const trainList = this.app.data.railway.diagrams[this.diaIndex].trains[this.direction];
trainList.splice(index, 0, new Train());
const train = new Train();
train.direction = this.direction;
trainList.splice(index, 0, train);
this.update();
}
private selectCell(col: number, row: number, mode: 'select' | 'toggle' | 'adding' | 'deleting' = 'select') {
Expand Down

0 comments on commit 9a66b43

Please sign in to comment.