wip
This commit is contained in:
@@ -12,7 +12,7 @@ const GAME_DIR_KEY = 'game-directory';
|
||||
// enum with install status
|
||||
enum InstallStatus {
|
||||
NotInstalled = 'NotInstalled',
|
||||
CheckingServer = 'CheckingServer',
|
||||
CheckingPeers = 'CheckingPeers',
|
||||
Downloading = 'Downloading',
|
||||
Unpacking = 'Unpacking',
|
||||
Installed = 'Installed',
|
||||
@@ -195,7 +195,7 @@ const App = () => {
|
||||
console.log(`✅ Game install for id=${id} started...`);
|
||||
// update install status in gameItems for this game
|
||||
setGameItems(prev => prev.map(item => item.id === id
|
||||
? { ...item, install_status: InstallStatus.CheckingServer }
|
||||
? { ...item, install_status: InstallStatus.CheckingPeers }
|
||||
: item));
|
||||
} else {
|
||||
// game is already being installed
|
||||
@@ -214,7 +214,7 @@ const App = () => {
|
||||
console.log(`✅ Game update for id=${id} started...`);
|
||||
// update install status in gameItems for this game
|
||||
setGameItems(prev => prev.map(item => item.id === id
|
||||
? { ...item, install_status: InstallStatus.CheckingServer }
|
||||
? { ...item, install_status: InstallStatus.CheckingPeers }
|
||||
: item));
|
||||
} else {
|
||||
// game is already being installed/updated
|
||||
@@ -228,20 +228,20 @@ const App = () => {
|
||||
const needsUpdate = (game: Game): boolean => {
|
||||
if (!game.installed) return false;
|
||||
|
||||
// Check if server has a version and we have a local version
|
||||
const serverVersion = game.eti_game_version;
|
||||
// Check if peers have a version and we have a local version
|
||||
const peerVersion = game.eti_game_version;
|
||||
const localVersion = game.local_version;
|
||||
|
||||
// If we don't have local version but server has one, we need update
|
||||
if (!localVersion && serverVersion) {
|
||||
// If we don't have local version but peers have one, we need update
|
||||
if (!localVersion && peerVersion) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we have both versions, compare them numerically
|
||||
if (localVersion && serverVersion) {
|
||||
if (localVersion && peerVersion) {
|
||||
const localNum = parseInt(localVersion, 10);
|
||||
const serverNum = parseInt(serverVersion, 10);
|
||||
return serverNum > localNum;
|
||||
const peerNum = parseInt(peerVersion, 10);
|
||||
return peerNum > localNum;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -264,7 +264,7 @@ const App = () => {
|
||||
<div className="fixed-header">
|
||||
<h1 className="align-center">SoftLAN Launcher</h1>
|
||||
<div className="main-header">
|
||||
{gameItems.length > 0 ? (
|
||||
{gameDir ? (
|
||||
<div className="search-settings-wrapper">
|
||||
<div></div>
|
||||
<div className="search-container">
|
||||
@@ -283,12 +283,21 @@ const App = () => {
|
||||
</div>
|
||||
) : (
|
||||
<div className="search-container">
|
||||
Waiting for connection to server...
|
||||
Please set a game directory to start scanning for games...
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid-container">
|
||||
{gameDir && filteredGames.length === 0 && gameItems.length === 0 ? (
|
||||
<div className="no-games-message">
|
||||
Scanning for games in your directory...
|
||||
</div>
|
||||
) : gameDir && filteredGames.length === 0 && gameItems.length > 0 ? (
|
||||
<div className="no-games-message">
|
||||
No games found matching your search.
|
||||
</div>
|
||||
) : null}
|
||||
{filteredGames.map((item) => {
|
||||
const uint8Array = new Uint8Array(item.thumbnail);
|
||||
const binaryString = uint8Array.reduce((acc, byte) => acc + String.fromCharCode(byte), '');
|
||||
@@ -312,12 +321,12 @@ const App = () => {
|
||||
}
|
||||
}}>
|
||||
{!item.installed
|
||||
? item.install_status === InstallStatus.CheckingServer ? 'Checking server...'
|
||||
? item.install_status === InstallStatus.CheckingPeers ? 'Checking peers...'
|
||||
: item.install_status === InstallStatus.Downloading ? 'Downloading...'
|
||||
: item.install_status === InstallStatus.Unpacking ? 'Unpacking...'
|
||||
: 'Install'
|
||||
: needsUpdate(item)
|
||||
? item.install_status === InstallStatus.CheckingServer ? 'Checking server...'
|
||||
? item.install_status === InstallStatus.CheckingPeers ? 'Checking peers...'
|
||||
: item.install_status === InstallStatus.Downloading ? 'Downloading...'
|
||||
: item.install_status === InstallStatus.Unpacking ? 'Unpacking...'
|
||||
: 'Update'
|
||||
|
||||
Reference in New Issue
Block a user