diff --git a/docsSite/docs/getting-started/manage-files.md b/docsSite/docs/getting-started/manage-files.md index 37b15b0e..8fc905e9 100644 --- a/docsSite/docs/getting-started/manage-files.md +++ b/docsSite/docs/getting-started/manage-files.md @@ -15,7 +15,7 @@ import Image2 from './img/open-file-2.png'; - **RLOG (.rlog)** - Legacy, produced by AdvantageKit 2022. :::info -Hoot log files can only be opened after agreeing to CTRE's [terms and conditions](https://PLACEHOLDER). AdvantageScope displays a prompt to confirm agreement to these terms when opening a Hoot log file for the first time. +Hoot log files can only be opened after agreeing to CTRE's [end user license agreement](https://raw.githubusercontent.com/CrossTheRoadElec/Phoenix-Releases/refs/heads/master/CTRE_LICENSE.txt). AdvantageScope displays a prompt to confirm agreement to these terms when opening a Hoot log file for the first time. ::: ## Opening Logs diff --git a/src/hub/dataSources/HistoricalDataSource.ts b/src/hub/dataSources/HistoricalDataSource.ts index 747ac8cf..3832fe05 100644 --- a/src/hub/dataSources/HistoricalDataSource.ts +++ b/src/hub/dataSources/HistoricalDataSource.ts @@ -67,11 +67,6 @@ export class HistoricalDataSource { this.refreshCallback = refreshCallback; // Post message to start reading - if (path.endsWith(".hoot") && window.platform === "win32" && window.platformArch !== "x64") { - this.customError = "CTRE does not support Hoot file decoding on Windows for ARM."; - this.setStatus(HistoricalDataSourceStatus.Error); - return; - } if (this.path.endsWith(".dsevents")) { this.path = this.path.slice(0, -8) + "dslog"; } diff --git a/src/main/main.ts b/src/main/main.ts index 5ac4aadd..0b38740d 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -1,22 +1,22 @@ import { hex } from "color-convert"; import { + app, BrowserWindow, BrowserWindowConstructorOptions, + clipboard, + dialog, FileFilter, Menu, MenuItem, MessageChannelMain, MessagePortMain, - TitleBarOverlay, - TouchBar, - TouchBarSlider, - app, - clipboard, - dialog, nativeImage, nativeTheme, powerMonitor, - shell + shell, + TitleBarOverlay, + TouchBar, + TouchBarSlider } from "electron"; import fs from "fs"; import jsonfile from "jsonfile"; @@ -81,7 +81,7 @@ import { shouldPromptBetaSurvey } from "./betaUtil"; import { getOwletDownloadStatus, startOwletDownloadLoop } from "./owletDownloadLoop"; -import { checkHootIsPro, convertHoot } from "./owletInterface"; +import { checkHootIsPro, convertHoot, CTRE_LICENSE_URL } from "./owletInterface"; // Global variables let hubWindows: BrowserWindow[] = []; // Ordered by last focus time (recent first) @@ -93,6 +93,7 @@ let satelliteWindows: { [id: string]: BrowserWindow[] } = {}; let windowPorts: { [id: number]: MessagePortMain } = {}; let hubTouchBarSliders: { [id: number]: TouchBarSlider } = {}; let hubExportingIds: Set = new Set(); +let ctreLicensePrompt: Promise | null = null; let stateTracker = new StateTracker(); let updateChecker = new UpdateChecker(); @@ -326,29 +327,50 @@ async function handleHubMessage(window: BrowserWindow, message: NamedMessage) { } else if (path.endsWith(".hoot")) { // Hoot, convert to WPILOG targetCount += 1; + + // Prompt for CTRE license if not accepted let prefs: Preferences = jsonfile.readFileSync(PREFS_FILENAME); if (!prefs.ctreLicenseAccepted) { - let response = await new Promise((resolve) => - dialog - .showMessageBox(window, { - type: "info", - title: "Alert", - message: "CTRE Terms & Conditions", - detail: - "Hoot log file decoding requires agreement to CTRE's terms and conditions. Please navigate to the address below to view the full license agreement.\n\n", - checkboxLabel: "I Agree", - icon: WINDOW_ICON - }) - .then((response) => resolve(response)) - ); - // if (response.checkboxChecked) { - // prefs.ctreLicenseAccepted = true; - // jsonfile.writeFileSync(PREFS_FILENAME, prefs); - // sendAllPreferences(); - // } + if (ctreLicensePrompt === null) { + ctreLicensePrompt = new Promise(async (resolve) => { + while (true) { + let response = await new Promise((resolve) => + dialog + .showMessageBox(window, { + type: "question", + title: "Alert", + message: "CTRE License Agreement", + detail: + "Hoot log file decoding requires agreement to CTRE's end user license agreement. Please click the button below to view the full license agreement, then check the box if you agree to the terms.", + checkboxLabel: "I Agree", + buttons: ["View License", "OK"], + defaultId: 1, + icon: WINDOW_ICON + }) + .then((response) => resolve(response)) + ); + if (response.response === 1) { + if (response.checkboxChecked) { + prefs.ctreLicenseAccepted = true; + jsonfile.writeFileSync(PREFS_FILENAME, prefs); + sendAllPreferences(); + } + resolve(); + break; + } else { + shell.openExternal(CTRE_LICENSE_URL); + } + } + }); + } + await ctreLicensePrompt; + ctreLicensePrompt = null; } + + // Check for license and open file + prefs = jsonfile.readFileSync(PREFS_FILENAME); if (!prefs.ctreLicenseAccepted) { - errorMessage = "Hoot log files cannot be decoded without agreeing to CTRE's terms and conditions."; + errorMessage = "Hoot log files cannot be decoded without agreeing to CTRE's end user license agreement."; completedCount++; sendIfReady(); } else { diff --git a/src/main/owletInterface.ts b/src/main/owletInterface.ts index f8dd2f69..b9e92c22 100644 --- a/src/main/owletInterface.ts +++ b/src/main/owletInterface.ts @@ -5,6 +5,9 @@ import path from "path"; import { createUUID } from "../shared/util"; import { OWLET_STORAGE } from "./owletDownloadLoop"; +export const CTRE_LICENSE_URL = + "https://raw.githubusercontent.com/CrossTheRoadElec/Phoenix-Releases/refs/heads/master/CTRE_LICENSE.txt"; + /** * Converts a Hoot log to WPILOG *