mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-09-23 08:32:51 +00:00
fix(lceonline): client not opening & webview window for lceonline login (#129)
This commit is contained in:
@@ -66,7 +66,7 @@ LCE Emerald Launcher is the easiest way to play Minecraft Legacy Console Edition
|
|||||||
| **Controller Support** | Full gamepad navigation support (keyboard support included) |
|
| **Controller Support** | Full gamepad navigation support (keyboard support included) |
|
||||||
| **Discord Rich Presence** | Show your current activity and game status on Discord |
|
| **Discord Rich Presence** | Show your current activity and game status on Discord |
|
||||||
| **Workshop** | Community content like DLCs, Textures, Skins and more |
|
| **Workshop** | Community content like DLCs, Textures, Skins and more |
|
||||||
| **Free Multiplayer** | Powered by LCELive, Emerald provides a free multiplayer service so you can play with anyone without port forwarding! |
|
| **Free Multiplayer** | Powered by LCEOnline, Emerald provides a free multiplayer service so you can play with anyone without port forwarding! |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ sudo apt install --reinstall libwebkit2gtk-4.1-0
|
|||||||
- **The Emerald Team** - Technical development and maintenance
|
- **The Emerald Team** - Technical development and maintenance
|
||||||
- **4J Studios & Mojang** - Original creators of Legacy Console Edition
|
- **4J Studios & Mojang** - Original creators of Legacy Console Edition
|
||||||
- **The LCE Community** - Research and foundations for LCE on PC
|
- **The LCE Community** - Research and foundations for LCE on PC
|
||||||
- **Veroxsity (Racoon)** - Original creator of LCELive
|
- **Str1k3r** - Original creator of LCEOnline
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"core:resources:default",
|
"core:resources:default",
|
||||||
"core:tray:default",
|
"core:tray:default",
|
||||||
"core:webview:default",
|
"core:webview:default",
|
||||||
|
"core:webview:allow-create-webview-window",
|
||||||
"core:window:default",
|
"core:window:default",
|
||||||
"core:window:allow-set-decorations",
|
"core:window:allow-set-decorations",
|
||||||
"core:window:allow-is-fullscreen",
|
"core:window:allow-is-fullscreen",
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ pub async fn launch_game(
|
|||||||
perform_instance_sync(&app, &instance_id).await?;
|
perform_instance_sync(&app, &instance_id).await?;
|
||||||
let working_dir = util::get_instance_working_dir(&app, &instance_id);
|
let working_dir = util::get_instance_working_dir(&app, &instance_id);
|
||||||
let config_val = config::load_config_raw(app.clone());
|
let config_val = config::load_config_raw(app.clone());
|
||||||
let lce_live = McServer { name: "LCELive Game".into(), ip: "127.0.0.1".into(), port: 61000 };
|
let lce_online = McServer { name: "LCEOnline Game".into(), ip: "127.0.0.1".into(), port: 61000 };
|
||||||
if !servers.iter().any(|s| s.ip == lce_live.ip && s.port == lce_live.port) {
|
if !servers.iter().any(|s| s.ip == lce_online.ip && s.port == lce_online.port) {
|
||||||
servers.push(lce_live);
|
servers.push(lce_online);
|
||||||
}
|
}
|
||||||
if let Some(ref saved) = config_val.saved_servers {
|
if let Some(ref saved) = config_val.saved_servers {
|
||||||
for s in saved {
|
for s in saved {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import {
|
|||||||
import ChooseInstanceModal from "../modals/ChooseInstanceModal";
|
import ChooseInstanceModal from "../modals/ChooseInstanceModal";
|
||||||
import { lceOnlineService } from "../../services/LceOnlineService";
|
import { lceOnlineService } from "../../services/LceOnlineService";
|
||||||
import { TauriService } from "../../services/TauriService";
|
import { TauriService } from "../../services/TauriService";
|
||||||
|
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||||
|
import { listen } from "@tauri-apps/api/event";
|
||||||
interface LceOnlineViewProps {
|
interface LceOnlineViewProps {
|
||||||
addFriendTarget?: string | null;
|
addFriendTarget?: string | null;
|
||||||
onClearAddFriendTarget?: () => void;
|
onClearAddFriendTarget?: () => void;
|
||||||
@@ -28,6 +30,7 @@ const LceOnlineView = memo(function LceOnlineView({
|
|||||||
const { playPressSound, playBackSound } = useAudio();
|
const { playPressSound, playBackSound } = useAudio();
|
||||||
const game = useGame();
|
const game = useGame();
|
||||||
const [isSignedIn, setIsSignedIn] = useState(lceOnlineService.signedIn);
|
const [isSignedIn, setIsSignedIn] = useState(lceOnlineService.signedIn);
|
||||||
|
const opened = useRef(false);
|
||||||
const [currentTab, setCurrentTab] = useState<
|
const [currentTab, setCurrentTab] = useState<
|
||||||
"friends" | "requests" | "invites"
|
"friends" | "requests" | "invites"
|
||||||
>("friends");
|
>("friends");
|
||||||
@@ -73,12 +76,29 @@ const LceOnlineView = memo(function LceOnlineView({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isSignedIn) {
|
if (isSignedIn) return;
|
||||||
TauriService.openUrl(
|
|
||||||
"https://mclegacyedition.xyz/internal/auth?appId=emerald_launcher",
|
if (!opened.current) {
|
||||||
);
|
opened.current = true;
|
||||||
}
|
new WebviewWindow('LCEOnline', {
|
||||||
}, []);
|
url: "https://mclegacyedition.xyz/internal/auth?appId=emerald_launcher",
|
||||||
|
width: 400,
|
||||||
|
height: 570,
|
||||||
|
resizable: false,
|
||||||
|
title: 'Emerald Legacy Launcher - LCEOnline',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const unlisten = listen<string[]>('deep-link', async (event) => {
|
||||||
|
const authUrl = event.payload.find(u => u.startsWith('emerald://'));
|
||||||
|
if (!authUrl) return;
|
||||||
|
const token = new URL(authUrl).searchParams.get('token');
|
||||||
|
if (token) setIsSignedIn(true);
|
||||||
|
(await WebviewWindow.getByLabel('LCEOnline'))?.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => { unlisten.then(f => f()); };
|
||||||
|
}, [isSignedIn]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!addFriendTarget) return;
|
if (!addFriendTarget) return;
|
||||||
@@ -619,6 +639,14 @@ const LceOnlineView = memo(function LceOnlineView({
|
|||||||
>
|
>
|
||||||
{renderContent()}
|
{renderContent()}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex justify-center pt-4 pb-2">
|
||||||
|
<img
|
||||||
|
src="/images/lceonline.png"
|
||||||
|
alt="LCEOnline"
|
||||||
|
className="h-5 opacity-70 cursor-pointer"
|
||||||
|
onClick={() => TauriService.openUrl("https://mclegacyedition.xyz/")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
|
|||||||
@@ -497,7 +497,7 @@ export function useGameManager({
|
|||||||
profile,
|
profile,
|
||||||
PARTNERSHIP_SERVERS,
|
PARTNERSHIP_SERVERS,
|
||||||
currentEdition?.lceOnline
|
currentEdition?.lceOnline
|
||||||
? extraLaunchArgs!.concat([
|
? (extraLaunchArgs ?? []).concat([
|
||||||
"-token",
|
"-token",
|
||||||
localStorage.getItem("lceonline_session")
|
localStorage.getItem("lceonline_session")
|
||||||
? JSON.parse(localStorage.getItem("lceonline_session")!).accessToken
|
? JSON.parse(localStorage.getItem("lceonline_session")!).accessToken
|
||||||
|
|||||||
@@ -1,17 +1,9 @@
|
|||||||
import { useState, useEffect, useRef } from "react";
|
import { useState, useEffect, useRef } from "react";
|
||||||
import { lceOnlineService } from "../services/LceOnlineService";
|
import { lceOnlineService } from "../services/LceOnlineService";
|
||||||
export function useLceOnlineNotifications() {
|
export function useLceOnlineNotifications() {
|
||||||
const [friendRequestMessage, setFriendRequestMessage] = useState<
|
const [friendRequestMessage, setFriendRequestMessage] = useState<string | null>(null);
|
||||||
string | null
|
|
||||||
>(null);
|
|
||||||
const [InviteMessage, setInviteMessage] = useState<string | null>(null);
|
const [InviteMessage, setInviteMessage] = useState<string | null>(null);
|
||||||
const [invites, setInvites] = useState<
|
const [invites, setInvites] = useState<Array<{ inviteid: string; from: { uuid: string; username: string; }; sessionid: string; }>>([]);
|
||||||
Array<{
|
|
||||||
inviteid: string;
|
|
||||||
from: { uuid: string; username: string };
|
|
||||||
sessionid: string;
|
|
||||||
}>
|
|
||||||
>([]);
|
|
||||||
const seenRequests = useRef<Set<string>>(new Set());
|
const seenRequests = useRef<Set<string>>(new Set());
|
||||||
const seenInvites = useRef<Set<string>>(new Set());
|
const seenInvites = useRef<Set<string>>(new Set());
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -24,7 +16,7 @@ export function useLceOnlineNotifications() {
|
|||||||
lists.requests.forEach((r: string) => {
|
lists.requests.forEach((r: string) => {
|
||||||
if (!seenRequests.current.has(r)) {
|
if (!seenRequests.current.has(r)) {
|
||||||
seenRequests.current.add(r);
|
seenRequests.current.add(r);
|
||||||
setFriendRequestMessage(`New Friend request from ${r}`);
|
setFriendRequestMessage(`${r} wants to be friends!`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
@@ -34,7 +26,7 @@ export function useLceOnlineNotifications() {
|
|||||||
invitesData.forEach((i) => {
|
invitesData.forEach((i) => {
|
||||||
if (!seenInvites.current.has(i.inviteid)) {
|
if (!seenInvites.current.has(i.inviteid)) {
|
||||||
seenInvites.current.add(i.inviteid);
|
seenInvites.current.add(i.inviteid);
|
||||||
setInviteMessage(`New invite from ${i.from.username}`);
|
setInviteMessage(`${i.from.username} invited you to play!`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch { }
|
} catch { }
|
||||||
@@ -47,7 +39,7 @@ export function useLceOnlineNotifications() {
|
|||||||
lists.requests.forEach((r: string) => {
|
lists.requests.forEach((r: string) => {
|
||||||
if (!seenRequests.current.has(r)) {
|
if (!seenRequests.current.has(r)) {
|
||||||
seenRequests.current.add(r);
|
seenRequests.current.add(r);
|
||||||
setFriendRequestMessage(`New Friend request from ${r}`);
|
setFriendRequestMessage(`${r} wants to be friends!`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
@@ -57,7 +49,7 @@ export function useLceOnlineNotifications() {
|
|||||||
invitesData.forEach((i) => {
|
invitesData.forEach((i) => {
|
||||||
if (!seenInvites.current.has(i.inviteid)) {
|
if (!seenInvites.current.has(i.inviteid)) {
|
||||||
seenInvites.current.add(i.inviteid);
|
seenInvites.current.add(i.inviteid);
|
||||||
setInviteMessage(`New invite from ${i.from.username}`);
|
setInviteMessage(`${i.from.username} invited you to play!`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|||||||
Reference in New Issue
Block a user