Upgraded build system, and introduced start of map selection modes.

This commit is contained in:
Andrew Lalis 2022-06-04 16:47:49 +02:00
parent 9b6eb7b667
commit 1cf5ed50fc
3 changed files with 33 additions and 10 deletions

View File

@ -32,6 +32,8 @@ const LOG_DIR = "./log";
const API_LOG = LOG_DIR ~ "/api_build.txt";
const APP_LOG = LOG_DIR ~ "/app_build.txt";
const GITHUB_PROPS_FILE = "github_token.properties";
int main(string[] args) {
string ver = getVersion();
if (ver is null) {
@ -135,7 +137,7 @@ void createRelease(string ver, string description) {
data.object["generate_release_notes"] = JSONValue(false);
auto rq = Request();
auto props = Properties("github_token.properties");
auto props = Properties(GITHUB_PROPS_FILE);
string username = props["username"];
string token = props["token"];
rq.authenticator = new BasicAuthentication(username, token);
@ -148,13 +150,21 @@ void createRelease(string ver, string description) {
string responseBody = cast(string) response.responseBody;
JSONValue responseData = parseJSON(responseBody);
print("Created release %s", responseData["url"].str);
// Use the "upload-asset.sh" script to upload the asset, since internal requests api is broken.
string command = format!"./upload-asset.sh github_api_token=%s owner=andrewlalis repo=RailSignalAPI tag=v%s filename=%s"(
token,
ver,
"./target/rail-signal-" ~ ver ~ ".jar"
long releaseId = responseData["id"].integer;
string uploadUrl = format!"https://uploads.github.com/repos/andrewlalis/RailSignalAPI/releases/%d/assets?name=%s"(
releaseId,
"rail-signal-" ~ ver ~ ".jar"
);
runOrQuit(command);
print("Uploading JAR file to %s", uploadUrl);
auto f = File("./target/rail-signal-" ~ ver ~ ".jar", "rb");
ulong assetSize = f.size();
rq.addHeaders(["Content-Length": format!"%d"(assetSize)]);
auto assetResponse = rq.post(uploadUrl, f.byChunk(4096));
if (assetResponse.code == 201) {
print("JAR file uploaded successfully.");
} else {
error("An error occurred while uploading the JAR file.");
}
} else {
error("An error occurred while creating the release.");
writeln(response.responseBody);

View File

@ -10,7 +10,7 @@
</parent>
<groupId>nl.andrewl</groupId>
<artifactId>rail-signal-api</artifactId>
<version>2.2.1</version>
<version>2.3.0</version>
<name>rail-signal-api</name>
<description>A simple API for tracking rail traffic in signalled blocks.</description>
<properties>

View File

@ -14,6 +14,9 @@ const HOVER_RADIUS = 10;
export let LAST_MOUSE_POINT = null;
const SELECTION_MODE_NORMAL = 1;
const SELECTION_MODE_CHOOSE = 2;
let selectionMode = SELECTION_MODE_NORMAL;
const componentSelectionListeners = new Map();
/**
@ -72,8 +75,18 @@ function onMouseDown(event) {
* @param {MouseEvent} event
*/
function onMouseUp(event) {
const finishingDrag = camPanNonzero();
if (selectionMode === SELECTION_MODE_NORMAL) {
handleNormalSelectionMouseUp(event);
}
camPanFinish();
}
/**
* Handles the mouse up event in normal selection mode. This means changing the
* set of selected components.
* @param {MouseEvent} event
*/
function handleNormalSelectionMouseUp(event) {
if (MAP_COMPONENTS_HOVERED.length > 0) {
if (!event.shiftKey) {// If the user isn't holding SHIFT, clear the set of selected components first.
MAP_RAIL_SYSTEM.selectedComponents.length = 0;
@ -89,7 +102,7 @@ function onMouseUp(event) {
}
}
componentSelectionListeners.forEach(callback => callback(MAP_RAIL_SYSTEM.selectedComponents));
} else if (!finishingDrag) {
} else if (!camPanNonzero()) {
MAP_RAIL_SYSTEM.selectedComponents.length = 0;
}
}