Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26b70d29c4 | ||
|
|
c94cdf679a | ||
|
|
a5d1725ee7 | ||
|
|
23662003da | ||
|
|
34ed92a647 | ||
|
|
2760ab4897 | ||
|
|
6e306a9bed | ||
|
|
13a5ede027 |
@@ -1,37 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# Installe (ou met à jour) l'entrée de menu "Farm Tracker" pointant vers l'AppImage déjà construit.
|
||||
set -e
|
||||
# Installation initiale de Farm Tracker (AppImage + entrée de menu).
|
||||
# À lancer une seule fois. Les mises à jour suivantes sont automatiques.
|
||||
set -euo pipefail
|
||||
|
||||
APPDIR="/home/shamiiow/GitHub/farm-tracker-app/dist"
|
||||
APPIMAGE=$(ls "$APPDIR"/*.AppImage 2>/dev/null | head -n1)
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
DIST_DIR="$SCRIPT_DIR/dist"
|
||||
|
||||
if [ -z "$APPIMAGE" ]; then
|
||||
echo "Aucun fichier .AppImage trouvé dans : $APPDIR"
|
||||
echo "Lance d'abord (depuis le dossier du projet) : npm run dist"
|
||||
# Trouve l'AppImage dans dist/
|
||||
APPIMAGE_SRC=$(ls "$DIST_DIR"/*.AppImage 2>/dev/null | head -n1)
|
||||
if [ -z "$APPIMAGE_SRC" ]; then
|
||||
echo "Aucun .AppImage trouvé dans dist/. Lance d'abord : npm run dist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chmod +x "$APPIMAGE"
|
||||
# Chemin stable — indépendant de la version
|
||||
INSTALL_DIR="$HOME/.local/bin"
|
||||
STABLE_PATH="$INSTALL_DIR/farm-tracker.AppImage"
|
||||
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
cp "$APPIMAGE_SRC" "$STABLE_PATH"
|
||||
chmod +x "$STABLE_PATH"
|
||||
|
||||
# Entrée de menu
|
||||
DESKTOP_DIR="$HOME/.local/share/applications"
|
||||
mkdir -p "$DESKTOP_DIR"
|
||||
DESKTOP_FILE="$DESKTOP_DIR/farm-tracker.desktop"
|
||||
|
||||
cat > "$DESKTOP_FILE" << INNEREOF
|
||||
cat > "$DESKTOP_DIR/farm-tracker.desktop" << EOF
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Farm Tracker
|
||||
Comment=Suivi de loot Minecraft en direct
|
||||
Exec="$APPIMAGE" %U
|
||||
Exec="$STABLE_PATH" %U
|
||||
Icon=applications-games
|
||||
Terminal=false
|
||||
Categories=Game;Utility;
|
||||
StartupWMClass=farm-tracker
|
||||
INNEREOF
|
||||
EOF
|
||||
|
||||
chmod +x "$DESKTOP_FILE"
|
||||
chmod +x "$DESKTOP_DIR/farm-tracker.desktop"
|
||||
update-desktop-database "$DESKTOP_DIR" >/dev/null 2>&1 || true
|
||||
|
||||
echo "Entrée installée : $DESKTOP_FILE"
|
||||
echo "AppImage détecté : $APPIMAGE"
|
||||
echo "Cherche \"Farm Tracker\" dans ton menu d'applications (déconnexion/reconnexion parfois nécessaire selon le bureau)."
|
||||
echo "Installé dans : $STABLE_PATH"
|
||||
echo "Entrée de menu : $DESKTOP_DIR/farm-tracker.desktop"
|
||||
echo ""
|
||||
echo "Les prochaines mises à jour s'installeront automatiquement sans rien retoucher."
|
||||
|
||||
99
main.js
99
main.js
@@ -103,6 +103,85 @@ function resolveAssetUrl(release) {
|
||||
return asset ? asset.browser_download_url : null;
|
||||
}
|
||||
|
||||
function sendUpdateProgress(percent, status, error) {
|
||||
if (mainWindow && !mainWindow.isDestroyed())
|
||||
mainWindow.webContents.send('update-progress', { percent, status, error });
|
||||
}
|
||||
|
||||
function downloadFileWithProgress(url, destPath, onProgress) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const follow = (currentUrl, redirects) => {
|
||||
if (redirects > 5) return reject(new Error('Trop de redirections'));
|
||||
const mod = currentUrl.startsWith('https') ? require('https') : require('http');
|
||||
const req = mod.get(currentUrl, { timeout: 120000, headers: { 'User-Agent': 'farm-tracker-updater' } }, (res) => {
|
||||
if ([301, 302, 307, 308].includes(res.statusCode))
|
||||
return follow(res.headers.location, redirects + 1);
|
||||
if (res.statusCode !== 200)
|
||||
return reject(new Error(`HTTP ${res.statusCode}`));
|
||||
const total = parseInt(res.headers['content-length'] || '0', 10);
|
||||
let downloaded = 0;
|
||||
const file = fs.createWriteStream(destPath);
|
||||
res.on('data', chunk => {
|
||||
downloaded += chunk.length;
|
||||
file.write(chunk);
|
||||
if (total > 0 && onProgress) onProgress(Math.round(downloaded / total * 100));
|
||||
});
|
||||
res.on('end', () => file.close(() => resolve(destPath)));
|
||||
res.on('error', err => { file.close(); try { fs.unlinkSync(destPath); } catch (_) {} reject(err); });
|
||||
});
|
||||
req.on('error', reject);
|
||||
req.on('timeout', () => { req.destroy(); reject(new Error('Timeout')); });
|
||||
};
|
||||
follow(url, 0);
|
||||
});
|
||||
}
|
||||
|
||||
async function downloadAndInstall(downloadUrl, version) {
|
||||
if (!app.isPackaged) {
|
||||
dialog.showMessageBox(mainWindow, {
|
||||
type: 'info', title: 'Mode développement',
|
||||
message: 'Auto-install non disponible en mode dev.',
|
||||
buttons: ['OK']
|
||||
});
|
||||
return;
|
||||
}
|
||||
const ext = process.platform === 'win32' ? '.exe' : '.AppImage';
|
||||
const tmpPath = path.join(app.getPath('temp'), `farm-tracker-${version}${ext}`);
|
||||
try {
|
||||
sendUpdateProgress(0, 'downloading');
|
||||
await downloadFileWithProgress(downloadUrl, tmpPath, pct => sendUpdateProgress(pct, 'downloading'));
|
||||
sendUpdateProgress(100, 'installing');
|
||||
if (process.platform === 'linux') {
|
||||
fs.chmodSync(tmpPath, 0o755);
|
||||
const stablePath = path.join(require('os').homedir(), '.local', 'bin', 'farm-tracker.AppImage');
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(stablePath), { recursive: true });
|
||||
fs.copyFileSync(tmpPath, stablePath);
|
||||
fs.chmodSync(stablePath, 0o755);
|
||||
fs.unlinkSync(tmpPath);
|
||||
app.relaunch({ execPath: stablePath });
|
||||
} catch (_) {
|
||||
// fallback: remplace l'AppImage courant si la copie vers bin/ échoue
|
||||
const fallback = process.env.APPIMAGE;
|
||||
if (fallback) {
|
||||
fs.copyFileSync(tmpPath, fallback);
|
||||
fs.unlinkSync(tmpPath);
|
||||
app.relaunch({ execPath: fallback });
|
||||
} else {
|
||||
app.relaunch({ execPath: tmpPath });
|
||||
}
|
||||
}
|
||||
app.exit(0);
|
||||
} else if (process.platform === 'win32') {
|
||||
const { spawn } = require('child_process');
|
||||
spawn(tmpPath, ['/S'], { detached: true, stdio: 'ignore' }).unref();
|
||||
app.quit();
|
||||
}
|
||||
} catch (e) {
|
||||
sendUpdateProgress(0, 'error', e.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function showUpdateDialog(version, downloadUrl, ignoreSnooze = false) {
|
||||
const current = app.getVersion();
|
||||
if (!isNewerVersion(version, current)) return false;
|
||||
@@ -117,14 +196,14 @@ async function showUpdateDialog(version, downloadUrl, ignoreSnooze = false) {
|
||||
type: 'info',
|
||||
title: 'Mise à jour disponible',
|
||||
message: `Version ${version} disponible`,
|
||||
detail: `Version actuelle : ${current}`,
|
||||
buttons: ['Télécharger', 'Me rappeler dans...'],
|
||||
detail: `Version actuelle : ${current}\nL'application se relancera automatiquement après la mise à jour.`,
|
||||
buttons: ['Installer maintenant', 'Me rappeler dans...'],
|
||||
defaultId: 0,
|
||||
cancelId: 1
|
||||
});
|
||||
|
||||
if (response === 0) {
|
||||
shell.openExternal(downloadUrl);
|
||||
downloadAndInstall(downloadUrl, version);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -181,7 +260,21 @@ function createWindow() {
|
||||
mainWindow.loadFile(path.join(__dirname, 'renderer', 'index.html'));
|
||||
}
|
||||
|
||||
function selfInstallLinux() {
|
||||
if (process.platform !== 'linux' || !app.isPackaged) return;
|
||||
const appImagePath = process.env.APPIMAGE;
|
||||
if (!appImagePath) return;
|
||||
const stablePath = path.join(require('os').homedir(), '.local', 'bin', 'farm-tracker.AppImage');
|
||||
if (appImagePath === stablePath) return;
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(stablePath), { recursive: true });
|
||||
fs.copyFileSync(appImagePath, stablePath);
|
||||
fs.chmodSync(stablePath, 0o755);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
selfInstallLinux();
|
||||
createWindow();
|
||||
setTimeout(() => checkForUpdates(false), 5000);
|
||||
});
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "farm-tracker",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "farm-tracker",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.3",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"dist": "^0.1.2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "farm-tracker",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.5",
|
||||
"description": "Suivi de loot Minecraft en direct, avec sauvegarde automatique des stats et des chances de drop.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -24,5 +24,6 @@ contextBridge.exposeInMainWorld('api', {
|
||||
loadSessionHistory: () => ipcRenderer.invoke('load-session-history'),
|
||||
saveSessionHistory: (obj) => ipcRenderer.invoke('save-session-history', obj),
|
||||
|
||||
checkUpdateManual: () => ipcRenderer.invoke('check-update-manual')
|
||||
checkUpdateManual: () => ipcRenderer.invoke('check-update-manual'),
|
||||
onUpdateProgress: (cb) => ipcRenderer.on('update-progress', (_, data) => cb(data))
|
||||
});
|
||||
|
||||
@@ -299,6 +299,32 @@
|
||||
font-family:var(--font-mono);font-size:11px;margin-bottom:5px;}
|
||||
.live-chart-header .chart-label{color:var(--text-dim);}
|
||||
.live-chart-header .chart-val{font-size:12px;font-weight:600;}
|
||||
|
||||
/* ---------- Timers ---------- */
|
||||
.timer-add-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:4px;}
|
||||
.timer-add-row input{background:var(--bg-panel-2);border:1px solid var(--border);color:var(--text);
|
||||
font-family:var(--font-body);font-size:13px;padding:7px 10px;min-width:0;}
|
||||
.timer-add-row input:focus{outline:2px solid var(--gold);outline-offset:0;}
|
||||
.timer-add-row input::placeholder{color:var(--text-dim);}
|
||||
.timer-config-list{display:flex;flex-direction:column;gap:6px;margin-top:12px;}
|
||||
.timer-config-row{display:flex;align-items:center;gap:10px;padding:8px 10px;
|
||||
background:var(--bg-panel-2);border:1px solid var(--border);}
|
||||
.timer-config-mob{flex:1;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
||||
.timer-config-dur{font-family:var(--font-mono);font-size:12px;color:var(--text-dim);white-space:nowrap;}
|
||||
.timer-active-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:10px;margin-top:12px;}
|
||||
.timer-card{background:var(--bg-panel-2);border:2px solid var(--border);padding:14px 16px;}
|
||||
.timer-card.timer-ok{border-color:var(--moss);}
|
||||
.timer-card.timer-warn{border-color:var(--paused);}
|
||||
.timer-card.timer-done{border-color:var(--boss);background:rgba(224,85,107,.07);}
|
||||
.timer-card-mob{font-size:13px;font-weight:600;margin-bottom:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
||||
.timer-card-countdown{font-family:var(--font-mono);font-size:32px;font-weight:700;line-height:1;letter-spacing:.04em;}
|
||||
.timer-card-countdown.timer-ok{color:var(--moss);}
|
||||
.timer-card-countdown.timer-warn{color:var(--paused);}
|
||||
.timer-card-countdown.timer-done{color:var(--boss);}
|
||||
.timer-card-sub{font-size:11px;color:var(--text-dim);margin-top:5px;}
|
||||
.timer-card-bar{height:3px;background:var(--border);margin-top:10px;overflow:hidden;}
|
||||
.timer-card-bar-fill{height:100%;transition:width .9s linear;}
|
||||
.timer-empty-msg{color:var(--text-dim);font-size:13px;padding:20px 0;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -356,6 +382,12 @@
|
||||
<span class="app-tile-desc">Statistiques des sessions passées et évolution du farm au fil du temps.</span>
|
||||
<span class="app-tile-status" id="tileHistoryStatus">● 0 session</span>
|
||||
</button>
|
||||
<button class="app-tile" id="tileTimers">
|
||||
<span class="app-tile-icon">⏱</span>
|
||||
<span class="app-tile-title">Timers</span>
|
||||
<span class="app-tile-desc">Compte à rebours automatique au kill — idéal pour les respawns de boss.</span>
|
||||
<span class="app-tile-status" id="tileTimersStatus">● 0 timer</span>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -528,6 +560,21 @@
|
||||
<p class="hero-number" id="histTotalTime">0h 00m</p>
|
||||
<p class="hero-sub" id="histAvgTime">moy. 0h / session</p>
|
||||
</div>
|
||||
<div class="hero-stat">
|
||||
<p class="eyebrow">Kills/min moyen</p>
|
||||
<p class="hero-number" id="histAvgRate">0</p>
|
||||
<p class="hero-sub" id="histBestRate">meilleur 0/min</p>
|
||||
</div>
|
||||
<div class="hero-stat">
|
||||
<p class="eyebrow">Exp totale</p>
|
||||
<p class="hero-number" id="histTotalExp">0</p>
|
||||
<p class="hero-sub" id="histAvgExp">moy. 0 / session</p>
|
||||
</div>
|
||||
<div class="hero-stat">
|
||||
<p class="eyebrow">Kamas totaux</p>
|
||||
<p class="hero-number" id="histTotalKamas">0</p>
|
||||
<p class="hero-sub" id="histAvgKamas">moy. 0 / session</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="histEmptyState">
|
||||
@@ -552,7 +599,7 @@
|
||||
|
||||
<div class="charts-2col" style="margin-bottom:14px;">
|
||||
<div class="panel">
|
||||
<h2>Kills / heure</h2>
|
||||
<h2>Kills / min</h2>
|
||||
<div class="chart-wrap" id="chartRate"></div>
|
||||
<div class="chart-label-row" id="chartRateLabels"></div>
|
||||
</div>
|
||||
@@ -577,10 +624,13 @@
|
||||
<th>Date</th>
|
||||
<th class="r">Durée</th>
|
||||
<th class="r">Kills</th>
|
||||
<th class="r">Kills/h</th>
|
||||
<th class="r">K/min</th>
|
||||
<th class="r">Exp</th>
|
||||
<th class="r">Cols kill</th>
|
||||
<th class="r">Exp/min</th>
|
||||
<th class="r">Kamas</th>
|
||||
<th class="r">Cols/min</th>
|
||||
<th>Mob principal</th>
|
||||
<th>Top item</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="histSessionsBody"></tbody>
|
||||
@@ -603,6 +653,32 @@
|
||||
|
||||
</section>
|
||||
|
||||
<!-- ============ ÉCRAN 5 : Timers ============ -->
|
||||
<section class="app-screen" id="appTimers" hidden>
|
||||
|
||||
<div class="panel" style="margin-bottom:14px;">
|
||||
<div class="panel-head-row">
|
||||
<h2>Ajouter un timer</h2>
|
||||
</div>
|
||||
<div class="timer-add-row">
|
||||
<input type="text" id="timerMobInput" placeholder="Nom du mob (ex: Skeleton)" style="flex:2;">
|
||||
<input type="text" id="timerDurInput" placeholder="Durée (ex: 5:00 ou 90)" style="flex:1;max-width:130px;">
|
||||
<button class="btn-ghost" id="timerAddBtn">Ajouter</button>
|
||||
</div>
|
||||
<div id="timerConfigList" class="timer-config-list"></div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-head-row">
|
||||
<h2>Comptes à rebours actifs</h2>
|
||||
<div class="spacer"></div>
|
||||
<span style="font-family:var(--font-mono);font-size:10px;color:var(--text-dim);">se déclenchent automatiquement au kill</span>
|
||||
</div>
|
||||
<div id="timerActiveGrid" class="timer-active-grid"></div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Modal 1 : confirmation sync -->
|
||||
@@ -732,7 +808,8 @@
|
||||
hub: $('hubScreen'),
|
||||
farmTracker: $('appFarmTracker'),
|
||||
dropBoard: $('appDropBoard'),
|
||||
history: $('appHistory')
|
||||
history: $('appHistory'),
|
||||
timers: $('appTimers')
|
||||
};
|
||||
const homeBtn = $('homeBtn');
|
||||
const changeFolderBtn = $('changeFolderBtn');
|
||||
@@ -768,6 +845,7 @@
|
||||
$('tileFarmTracker').addEventListener('click', () => showScreen('farmTracker'));
|
||||
$('tileDropBoard').addEventListener('click', () => { showScreen('dropBoard'); renderDropBoard(); });
|
||||
$('tileHistory').addEventListener('click', () => { showScreen('history'); renderHistoryScreen(); });
|
||||
$('tileTimers').addEventListener('click', () => { showScreen('timers'); renderTimerScreen(); });
|
||||
|
||||
const globalState = { logPath: null, serverUrl: '', clientId: '' };
|
||||
let sessionHistory = { type: 'farm-tracker-session-history', version: 1, sessions: [] };
|
||||
@@ -1200,6 +1278,7 @@
|
||||
state.mobCounts.set(mobPlain, (state.mobCounts.get(mobPlain) || 0) + 1);
|
||||
state.expTotal += exp;
|
||||
state.killCols += col;
|
||||
triggerTimer(mobPlain);
|
||||
|
||||
if (!state.dropStats.has(mobPlain)) state.dropStats.set(mobPlain, {kills: 0, items: new Map()});
|
||||
const dropEntry = state.dropStats.get(mobPlain);
|
||||
@@ -1834,8 +1913,15 @@
|
||||
histEmpty.hidden=true; histHero.hidden=false; histCharts.hidden=false; histPanel.hidden=false;
|
||||
const totalKills=sessions.reduce((s,x)=>s+x.totalKills,0);
|
||||
const totalMs=sessions.reduce((s,x)=>s+x.durationMs,0);
|
||||
const totalExp=sessions.reduce((s,x)=>s+(x.totalExp||0),0);
|
||||
const totalKamas=sessions.reduce((s,x)=>s+(x.sellTotal||0),0);
|
||||
const avgKills=Math.round(totalKills/sessions.length);
|
||||
const avgMs=totalMs/sessions.length;
|
||||
const avgExp=Math.round(totalExp/sessions.length);
|
||||
const avgKamas=Math.round(totalKamas/sessions.length);
|
||||
const ratesPerMin=sessions.filter(s=>s.durationMs>0).map(s=>s.totalKills/(s.durationMs/60000));
|
||||
const avgRate=ratesPerMin.length?ratesPerMin.reduce((a,b)=>a+b,0)/ratesPerMin.length:0;
|
||||
const bestRate=ratesPerMin.length?Math.max(...ratesPerMin):0;
|
||||
$('histTotalSessions').textContent=fmt(sessions.length);
|
||||
$('histTotalKills').textContent=fmt(totalKills);
|
||||
$('histAvgKills').textContent='moy. '+fmt(avgKills)+' / session';
|
||||
@@ -1843,12 +1929,18 @@
|
||||
$('histTotalTime').textContent=tH+'h '+String(tM).padStart(2,'0')+'m';
|
||||
const aH=Math.floor(avgMs/3600000),aM=Math.floor((avgMs%3600000)/60000);
|
||||
$('histAvgTime').textContent='moy. '+(aH>0?aH+'h ':'')+String(aM).padStart(2,'0')+'m / session';
|
||||
$('histAvgRate').textContent=fmt(avgRate,1)+'/min';
|
||||
$('histBestRate').textContent='meilleur '+fmt(bestRate,1)+'/min';
|
||||
$('histTotalExp').textContent=fmtShort(totalExp);
|
||||
$('histAvgExp').textContent='moy. '+fmtShort(avgExp)+' / session';
|
||||
$('histTotalKamas').textContent=fmtShort(totalKamas);
|
||||
$('histAvgKamas').textContent='moy. '+fmtShort(avgKamas)+' / session';
|
||||
const kAvgEl=$('histKillsAvgLabel');
|
||||
if (kAvgEl) kAvgEl.textContent='moy. '+fmt(avgKills)+' kills';
|
||||
renderSvgChart($('chartKills'),sessions,s=>s.totalKills,'#9B5DE5',null,$('chartKillsLabels'));
|
||||
renderSvgChart($('chartRate'),sessions,s=>{
|
||||
const h=s.durationMs/3600000; return h>0?Math.round(s.totalKills/h):0;
|
||||
},'#5DB7E5',v=>fmtShort(v)+'/h',$('chartRateLabels'));
|
||||
const min=s.durationMs/60000; return min>0?Math.round(s.totalKills/min*10)/10:0;
|
||||
},'#5DB7E5',v=>fmt(v,1)+'/min',$('chartRateLabels'));
|
||||
renderSvgChart($('chartExp'),sessions,s=>s.totalExp,'#F2C94C',v=>fmtShort(v),$('chartExpLabels'));
|
||||
const tbody=$('histSessionsBody');
|
||||
tbody.innerHTML='';
|
||||
@@ -1859,16 +1951,23 @@
|
||||
+' '+d.toLocaleTimeString('fr-FR',{hour:'2-digit',minute:'2-digit'});
|
||||
const dH=Math.floor(s.durationMs/3600000),dM=Math.floor((s.durationMs%3600000)/60000);
|
||||
const durStr=dH>0?dH+'h'+String(dM).padStart(2,'0')+'m':dM+'min';
|
||||
const killsPerH=s.durationMs>0?Math.round(s.totalKills/(s.durationMs/3600000)):0;
|
||||
const minElapsed=s.durationMs/60000;
|
||||
const killsPerMin=minElapsed>0?Math.round(s.totalKills/minElapsed*10)/10:0;
|
||||
const expPerMin=minElapsed>0?Math.round(s.totalExp/minElapsed):0;
|
||||
const colsPerMin=minElapsed>0?Math.round((s.killCols||0)/minElapsed*10)/10:0;
|
||||
const topItemName=s.topItems&&s.topItems.length?s.topItems[0].name+' ×'+s.topItems[0].qty:'—';
|
||||
const tr=document.createElement('tr');
|
||||
tr.innerHTML=
|
||||
'<td>'+escHtml(dateStr)+'</td>'+
|
||||
'<td class="r mono">'+escHtml(durStr)+'</td>'+
|
||||
'<td class="r hl">'+fmt(s.totalKills)+'</td>'+
|
||||
'<td class="r mono">'+fmt(killsPerH)+'/h</td>'+
|
||||
'<td class="r mono">'+fmt(s.totalExp)+'</td>'+
|
||||
'<td class="r mono">'+fmt(s.killCols)+'</td>'+
|
||||
'<td class="dim">'+escHtml(s.topMob||'—')+'</td>';
|
||||
'<td class="r mono">'+fmt(killsPerMin,1)+'/min</td>'+
|
||||
'<td class="r mono">'+fmtShort(s.totalExp)+'</td>'+
|
||||
'<td class="r mono">'+fmtShort(expPerMin)+'/min</td>'+
|
||||
'<td class="r mono">'+(s.sellTotal?fmtShort(Math.round(s.sellTotal)):'—')+'</td>'+
|
||||
'<td class="r mono">'+fmt(colsPerMin,1)+'/min</td>'+
|
||||
'<td class="dim">'+escHtml(s.topMob||'—')+'</td>'+
|
||||
'<td class="dim" title="'+escHtml(topItemName)+'">'+escHtml(topItemName.length>22?topItemName.slice(0,20)+'…':topItemName)+'</td>';
|
||||
tbody.appendChild(tr);
|
||||
}
|
||||
}
|
||||
@@ -1881,6 +1980,132 @@
|
||||
renderHistoryScreen();
|
||||
});
|
||||
|
||||
// ======================================================================
|
||||
// TIMERS
|
||||
// ======================================================================
|
||||
|
||||
let timerConfigs = JSON.parse(localStorage.getItem('timerConfigs') || '[]');
|
||||
// activeTimers : Map<configId, { endsAt: number, durationSec: number, mobName: string }>
|
||||
const activeTimers = new Map();
|
||||
let timerClockId = null;
|
||||
|
||||
function saveTimerConfigs(){
|
||||
localStorage.setItem('timerConfigs', JSON.stringify(timerConfigs));
|
||||
updateTimerTileStatus();
|
||||
}
|
||||
|
||||
function parseDuration(str){
|
||||
str = str.trim();
|
||||
if (str.includes(':')) {
|
||||
const parts = str.split(':');
|
||||
const m = parseInt(parts[0], 10) || 0;
|
||||
const s = parseInt(parts[1], 10) || 0;
|
||||
return m * 60 + s;
|
||||
}
|
||||
return parseInt(str, 10) || 0;
|
||||
}
|
||||
|
||||
function fmtCountdown(sec){
|
||||
if (sec <= 0) return 'PRÊT';
|
||||
const m = Math.floor(sec / 60), s = sec % 60;
|
||||
return String(m).padStart(2,'0') + ':' + String(s).padStart(2,'0');
|
||||
}
|
||||
|
||||
function updateTimerTileStatus(){
|
||||
const el = $('tileTimersStatus');
|
||||
if (el) el.textContent = '● ' + timerConfigs.length + ' timer' + (timerConfigs.length !== 1 ? 's' : '');
|
||||
}
|
||||
|
||||
function triggerTimer(mobPlain){
|
||||
for (const cfg of timerConfigs){
|
||||
if (cfg.mobName.toLowerCase() === mobPlain.toLowerCase()){
|
||||
const endsAt = Date.now() + cfg.durationSec * 1000;
|
||||
activeTimers.set(cfg.id, { endsAt, durationSec: cfg.durationSec, mobName: cfg.mobName });
|
||||
renderTimerActiveGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function startTimerClock(){
|
||||
if (timerClockId) return;
|
||||
timerClockId = setInterval(() => {
|
||||
if (activeTimers.size > 0) renderTimerActiveGrid();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function renderTimerActiveGrid(){
|
||||
const grid = $('timerActiveGrid');
|
||||
if (!grid) return;
|
||||
if (activeTimers.size === 0){
|
||||
grid.innerHTML = '<p class="timer-empty-msg">Aucun timer actif — tue un mob configuré pour démarrer un compte à rebours.</p>';
|
||||
return;
|
||||
}
|
||||
const now = Date.now();
|
||||
let html = '';
|
||||
for (const [id, timer] of activeTimers){
|
||||
const remaining = Math.max(0, Math.ceil((timer.endsAt - now) / 1000));
|
||||
const pct = Math.max(0, remaining / timer.durationSec * 100);
|
||||
const cls = remaining <= 0 ? 'timer-done' : pct < 25 ? 'timer-warn' : 'timer-ok';
|
||||
const barColor = remaining <= 0 ? 'var(--boss)' : pct < 25 ? 'var(--paused)' : 'var(--moss)';
|
||||
html +=
|
||||
'<div class="timer-card '+cls+'" data-timer-id="'+escHtml(id)+'">' +
|
||||
'<div class="timer-card-mob">'+escHtml(timer.mobName)+'</div>' +
|
||||
'<div class="timer-card-countdown '+cls+'">'+fmtCountdown(remaining)+'</div>' +
|
||||
'<div class="timer-card-sub">'+(remaining<=0?'Respawn disponible !':'reste '+fmtCountdown(remaining))+'</div>'+
|
||||
'<div class="timer-card-bar"><div class="timer-card-bar-fill" style="width:'+pct.toFixed(1)+'%;background:'+barColor+';"></div></div>'+
|
||||
'</div>';
|
||||
}
|
||||
grid.innerHTML = html;
|
||||
}
|
||||
|
||||
function renderTimerConfigList(){
|
||||
const list = $('timerConfigList');
|
||||
if (!list) return;
|
||||
if (!timerConfigs.length){ list.innerHTML = ''; return; }
|
||||
list.innerHTML = timerConfigs.map(cfg => {
|
||||
const m = Math.floor(cfg.durationSec/60), s = cfg.durationSec%60;
|
||||
const durStr = m > 0 ? m+'min'+(s>0?' '+s+'s':'') : s+'s';
|
||||
return '<div class="timer-config-row">' +
|
||||
'<span class="timer-config-mob">'+escHtml(cfg.mobName)+'</span>' +
|
||||
'<span class="timer-config-dur">'+escHtml(durStr)+'</span>' +
|
||||
'<button class="btn-ghost small danger" data-del-timer="'+escHtml(cfg.id)+'">✕</button>' +
|
||||
'</div>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function renderTimerScreen(){
|
||||
renderTimerConfigList();
|
||||
renderTimerActiveGrid();
|
||||
startTimerClock();
|
||||
}
|
||||
|
||||
$('timerAddBtn').addEventListener('click', () => {
|
||||
const mobName = $('timerMobInput').value.trim();
|
||||
const durationSec = parseDuration($('timerDurInput').value);
|
||||
if (!mobName || durationSec <= 0) return;
|
||||
timerConfigs.push({ id: generateUUID(), mobName, durationSec });
|
||||
saveTimerConfigs();
|
||||
$('timerMobInput').value = '';
|
||||
$('timerDurInput').value = '';
|
||||
renderTimerConfigList();
|
||||
});
|
||||
|
||||
$('timerMobInput').addEventListener('keydown', e => { if (e.key === 'Enter') $('timerAddBtn').click(); });
|
||||
$('timerDurInput').addEventListener('keydown', e => { if (e.key === 'Enter') $('timerAddBtn').click(); });
|
||||
|
||||
$('timerConfigList').addEventListener('click', e => {
|
||||
const id = e.target.dataset.delTimer;
|
||||
if (!id) return;
|
||||
timerConfigs = timerConfigs.filter(c => c.id !== id);
|
||||
activeTimers.delete(id);
|
||||
saveTimerConfigs();
|
||||
renderTimerConfigList();
|
||||
renderTimerActiveGrid();
|
||||
});
|
||||
|
||||
updateTimerTileStatus();
|
||||
startTimerClock();
|
||||
|
||||
async function initFarmTracker(logPath, resetCounters){
|
||||
if (!ft) ft = createFarmTracker();
|
||||
await ft.start(logPath, resetCounters);
|
||||
@@ -2002,6 +2227,35 @@
|
||||
})();
|
||||
|
||||
})();
|
||||
|
||||
// ---------- Progression de mise à jour ----------
|
||||
if (window.api && window.api.onUpdateProgress) {
|
||||
const overlay = document.createElement('div');
|
||||
overlay.id = 'updateOverlay';
|
||||
overlay.style.cssText = 'position:fixed;inset:0;background:rgba(11,15,12,0.94);z-index:9999;display:none;align-items:center;justify-content:center;flex-direction:column;gap:18px;';
|
||||
overlay.innerHTML =
|
||||
'<div style="font-family:var(--font-mono);color:var(--text);font-size:14px;letter-spacing:.04em;" id="updateOverlayText">Téléchargement de la mise à jour…</div>' +
|
||||
'<div style="width:320px;height:5px;background:var(--bg-panel-2);border:1px solid var(--border);">' +
|
||||
'<div id="updateProgressBar" style="height:100%;background:var(--corrupt);width:0%;transition:width .25s;"></div>' +
|
||||
'</div>' +
|
||||
'<div style="font-family:var(--font-mono);color:var(--text-dim);font-size:12px;" id="updateOverlayPct">0%</div>';
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
window.api.onUpdateProgress(({ percent, status, error }) => {
|
||||
const bar = document.getElementById('updateProgressBar');
|
||||
const pct = document.getElementById('updateOverlayPct');
|
||||
const txt = document.getElementById('updateOverlayText');
|
||||
if (status === 'error') {
|
||||
overlay.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
overlay.style.display = 'flex';
|
||||
bar.style.width = percent + '%';
|
||||
pct.textContent = percent + '%';
|
||||
txt.textContent = status === 'installing' ? 'Installation… l\'application va redémarrer.' : 'Téléchargement de la mise à jour…';
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -21,7 +21,9 @@ const VERSION = pkg.version;
|
||||
const TAG = `v${VERSION}`;
|
||||
|
||||
const DIST = path.join(__dirname, '..', 'dist');
|
||||
const ASSETS = fs.readdirSync(DIST).filter(f => f.endsWith('.AppImage') || (f.endsWith('.exe') && !f.endsWith('.blockmap')));
|
||||
const ASSETS = fs.readdirSync(DIST).filter(f =>
|
||||
(f.endsWith('.AppImage') || (f.endsWith('.exe') && !f.endsWith('.blockmap'))) && f.includes(VERSION)
|
||||
);
|
||||
|
||||
if (!ASSETS.length) {
|
||||
console.error('Aucun binaire trouvé dans dist/. Lance "npm run dist" et "npm run dist:win" d\'abord.');
|
||||
|
||||
56
tools/release.sh
Executable file
56
tools/release.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# ---------- Token ----------
|
||||
TOKEN="${GITEA_TOKEN:-}"
|
||||
if [ -z "$TOKEN" ] && [ -f ".gitea-token" ]; then
|
||||
TOKEN=$(tr -d '[:space:]' < .gitea-token)
|
||||
fi
|
||||
if [ -z "$TOKEN" ]; then
|
||||
read -rsp "Token Gitea : " TOKEN
|
||||
echo
|
||||
fi
|
||||
|
||||
# ---------- Version ----------
|
||||
CURRENT=$(node -p "require('./package.json').version")
|
||||
if [ -n "${1:-}" ]; then
|
||||
VERSION="$1"
|
||||
else
|
||||
echo "Version actuelle : v$CURRENT"
|
||||
read -rp "Nouvelle version [patch / minor / major / X.Y.Z] : " VERSION
|
||||
fi
|
||||
|
||||
npm version "$VERSION" --no-git-tag-version --silent
|
||||
NEW=$(node -p "require('./package.json').version")
|
||||
echo "→ v$NEW"
|
||||
|
||||
# ---------- Build ----------
|
||||
echo ""
|
||||
echo "Nettoyage des anciens binaires..."
|
||||
find dist -maxdepth 1 \( -name "*.AppImage" -o -name "*.exe" -o -name "*.blockmap" \) -delete 2>/dev/null || true
|
||||
|
||||
echo "Build Linux (AppImage)..."
|
||||
npm run dist --silent
|
||||
|
||||
if command -v wine &>/dev/null; then
|
||||
echo "Build Windows (exe)..."
|
||||
npm run dist:win --silent
|
||||
else
|
||||
echo "(Wine non trouvé — build Windows ignoré)"
|
||||
fi
|
||||
|
||||
# ---------- Release Gitea ----------
|
||||
echo ""
|
||||
GITEA_TOKEN="$TOKEN" node tools/release.js
|
||||
|
||||
# ---------- Git ----------
|
||||
git add package.json package-lock.json
|
||||
git commit -m "chore: release v$NEW" --quiet
|
||||
git remote set-url origin "https://shamiiow:${TOKEN}@git.shamiiow.com/shamiiow/farm-tracker-sao.git"
|
||||
git push --quiet
|
||||
git remote set-url origin "https://git.shamiiow.com/shamiiow/farm-tracker-sao.git"
|
||||
|
||||
echo ""
|
||||
echo "Release v$NEW publiée."
|
||||
Reference in New Issue
Block a user