Skip to content

Commit

Permalink
ViewerGUI: Add support for --starting-row and --starting-column options.
Browse files Browse the repository at this point in the history
For #76.
  • Loading branch information
kingjon3377 committed Nov 10, 2020
1 parent 6453967 commit 7f81a77
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ shared class ViewerGUIFactory() satisfies GUIDriverFactory {
longDescription = "Look at the map visually. This is probably the app you want.";
includeInCLIList = false;
includeInGUIList = true;
supportedOptions = [ "--current-turn=NN", "--background=image.png" ];
supportedOptions = [ "--current-turn=NN", "--background=image.png", "--starting-row=NN --starting-column=NN"];
};

"Ask the user to choose a file or files."
Expand Down Expand Up @@ -175,6 +175,26 @@ shared class ViewerGUI(model, options) satisfies ViewerDriver {
getFindDialog)()), "find next");
menuHandler.registerWindowShower(aboutDialog(frame, frame.windowName),
"about");
// TODO: We'd like to have the starting position stored in the map
// file, in system preferences, or some such, or simply default to HQ.
if (options.hasOption("--starting-row"), options.hasOption("--starting-column")) {
value startingRow = Integer.parse(options.getArgument("--starting-row"));
value startingCol = Integer.parse(options.getArgument("--starting-column"));
if (is Integer startingRow, is Integer startingCol) {
value starting = Point(startingRow, startingCol);
if (starting in model.mapDimensions) {
model.selection = starting;
} else {
log.warn("Starting coordinates must be within the map's dimensions");
}
} else {
log.warn("Arguments to --starting-row and --starting-column must be numeric");
}
} else if (options.hasOption("--starting-row")) {
log.warn("--starting-row requires --starting-column");
} else if (options.hasOption("--starting-column")) {
log.warn("--starting-column requires --starting-row");
}
log.trace("About to show viewer GUI window");
frame.showWindow();
}
Expand Down

0 comments on commit 7f81a77

Please sign in to comment.