Ready to merge
This commit is contained in:
@@ -38,6 +38,10 @@
|
||||
class="bg-green-600 hover:bg-green-700 px-4 py-2 rounded">
|
||||
Download Game
|
||||
</button>
|
||||
<button onclick="runGame({{ game.id }})"
|
||||
class="bg-green-600 hover:bg-green-700 px-4 py-2 rounded">
|
||||
Run Game
|
||||
</button>
|
||||
{% else %}
|
||||
<span class="bg-gray-600 px-4 py-2 rounded cursor-not-allowed">
|
||||
{% if current_user %}Demo Mode - No Downloads{% else %}Login to Download{% endif %}
|
||||
@@ -287,5 +291,34 @@
|
||||
alert('Download failed. Please try again.');
|
||||
}
|
||||
}
|
||||
|
||||
async function runGame(gameId) {
|
||||
const token = localStorage.getItem('authToken');
|
||||
if (!token) {
|
||||
showLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/run/${gameId}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
alert('Game is starting in your DOSBox environment.');
|
||||
} else if (response.status === 401) {
|
||||
localStorage.removeItem('authToken');
|
||||
showLogin();
|
||||
} else {
|
||||
alert('Failed to start the game. Please try again.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error starting game:', error);
|
||||
alert('Failed to start the game. Please try again.');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -480,6 +480,10 @@
|
||||
class="bg-green-600 hover:bg-green-700 px-4 py-2 rounded hidden">
|
||||
Download Game
|
||||
</button>
|
||||
<button onclick="runGameFromOverlay()"
|
||||
class="bg-green-600 hover:bg-green-700 px-4 py-2 rounded">
|
||||
Run Game
|
||||
</button>
|
||||
|
||||
<span id="gameDownloadDisabled" class="bg-gray-600 px-4 py-2 rounded cursor-not-allowed hidden">
|
||||
Demo Mode - No Downloads
|
||||
@@ -660,6 +664,34 @@
|
||||
alert('Download failed. Please try again.');
|
||||
}
|
||||
}
|
||||
async function runGame(gameId) {
|
||||
const token = localStorage.getItem('authToken');
|
||||
if (!token) {
|
||||
showLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/run/${gameId}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
alert('Game is starting in your DOSBox environment.');
|
||||
} else if (response.status === 401) {
|
||||
localStorage.removeItem('authToken');
|
||||
showLogin();
|
||||
} else {
|
||||
alert('Failed to start the game. Please try again.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error starting game:', error);
|
||||
alert('Failed to start the game. Please try again.');
|
||||
}
|
||||
}
|
||||
|
||||
// Track which covers are being loaded to prevent duplicates
|
||||
const loadingCovers = new Set();
|
||||
@@ -937,6 +969,10 @@
|
||||
if (!currentGameData) return;
|
||||
await downloadGame(currentGameData.id);
|
||||
}
|
||||
async function runGameFromOverlay() {
|
||||
if (!currentGameData) return;
|
||||
await runGame(currentGameData.id);
|
||||
}
|
||||
|
||||
function openScreenshotModalInOverlay() {
|
||||
if (!currentGameData || !currentGameData.metadata.screenshot) return;
|
||||
@@ -989,4 +1025,4 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user