modified: Cargo.lock

modified:   Cargo.toml
	deleted:    public_release
	deleted:    sign_in
	modified:   src/main.rs
	renamed:    html -> src/www/html
	renamed:    loading_screen -> src/www/loading_screen
	renamed:    log_screen -> src/www/log_screen
	renamed:    logged_in -> src/www/logged_in
	renamed:    main_screen -> src/www/main_screen
	renamed:    profile_customization -> src/www/profile_customization
	new file:   src/www/public_release
	renamed:    settings -> src/www/settings
	new file:   src/www/sign_in.html
This commit is contained in:
Michael Wain 2025-03-11 15:59:44 +03:00
parent 495bcca71e
commit 4a5a9f85e7
14 changed files with 3606 additions and 253 deletions

3529
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -4,4 +4,6 @@ version = "0.1.0"
edition = "2024"
[dependencies]
web-view = { version = "0.7" }
winit = "0.30.9"
wry = "0.50.4"
tokio = { version = "1", features = ["full"] }

@ -1,77 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Minecraft Launcher</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 flex justify-center items-center h-screen">
<div class="bg-white shadow-lg rounded-xl p-6 w-96 text-center">
<h1 class="text-2xl font-semibold text-gray-700">Minecraft Launcher</h1>
<!-- Version Selection -->
<label class="block mt-4 text-gray-600">Select Version:</label>
<select id="mc-version" class="mt-2 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500">
<option value="latest">Latest Release</option>
<option value="1.20.1">1.20.1</option>
<option value="1.19.4">1.19.4</option>
<option value="1.18.2">1.18.2</option>
<option value="1.16.5">1.16.5</option>
<option value="1.12.2">1.12.2 (Modding)</option>
</select>
<!-- Download Button -->
<button onclick="downloadVersion()"
class="mt-4 w-full bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded transition">
⬇ Download Version
</button>
<!-- OR Divider -->
<div class="mt-4 text-gray-500 text-sm">or</div>
<!-- Add MultiMC Instance -->
<button onclick="addMultiMCInstance()"
class="mt-3 w-full bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded transition">
Add MultiMC Instance
</button>
<!-- Navigation Buttons -->
<div class="mt-6 flex gap-2">
<button onclick="goToSettings()"
class="w-1/2 bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded transition">
⚙ Settings
</button>
<button onclick="goToLogin()"
class="w-1/2 bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded transition">
🔑 Login
</button>
</div>
<p class="mt-4 text-sm text-gray-500">Minecraft Launcher v1.0</p>
</div>
<script>
function downloadVersion() {
const version = document.getElementById("mc-version").value;
alert(Downloading Minecraft ${version}...);
// In Rust, this should trigger the actual download.
}
function addMultiMCInstance() {
alert("Select a MultiMC instance folder.");
// In Rust, this should open a file picker.
}
function goToSettings() {
window.location.href = "settings.html";
}
function goToLogin() {
window.location.href = "login.html";
}
</script>
</body>
</html>

69
sign_in

@ -1,69 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Minecraft Launcher - Login</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 flex justify-center items-center h-screen">
<!-- Container -->
<div id="login-screen" class="bg-white shadow-lg rounded-xl p-6 w-96 text-center">
<h2 class="text-2xl font-semibold text-gray-700">Sign In</h2>
<!-- Username -->
<input type="text" placeholder="Username" class="mt-4 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500">
<!-- Password -->
<input type="password" placeholder="Password" class="mt-3 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500">
<!-- Sign In Button -->
<button onclick="showAccountSettings()"
class="mt-4 w-full bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded transition">
Sign In
</button>
<!-- Footer -->
<p class="mt-4 text-sm text-gray-500">Minecraft Launcher v1.0</p>
</div>
<!-- Account Settings Screen (Hidden by Default) -->
<div id="account-settings" class="bg-white shadow-lg rounded-xl p-6 w-96 text-center hidden">
<!-- User Avatar -->
<div class="flex flex-col items-center">
<img src="https://www.minecraft.net/etc.clientlibs/minecraft/clientlibs/main/resources/img/minecraft-creeper-face.jpg"
alt="User Avatar" class="w-16 h-16 rounded-full border-4 border-gray-300">
<h2 class="text-lg font-semibold mt-2 text-gray-700">Steve</h2>
</div>
<!-- Change Account Button -->
<button onclick="showLoginScreen()"
class="mt-4 w-full bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded transition">
🔄 Change Account
</button>
<!-- Log Out Button -->
<button onclick="showLoginScreen()"
class="mt-3 w-full bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-4 rounded transition">
🚪 Log Out
</button>
<!-- Footer -->
<p class="mt-4 text-sm text-gray-500">Minecraft Launcher v1.0</p>
</div>
<script>
function showAccountSettings() {
document.getElementById('login-screen').classList.add('hidden');
document.getElementById('account-settings').classList.remove('hidden');
}
function showLoginScreen() {
document.getElementById('account-settings').classList.add('hidden');
document.getElementById('login-screen').classList.remove('hidden');
}
</script>
</body>
</html>

@ -1,16 +1,41 @@
use web_view::Content;
use winit::application::ApplicationHandler;
use winit::event_loop::{ControlFlow, EventLoop};
use winit::event::{Event, WindowEvent};
use winit::platform::run_on_demand::EventLoopExtRunOnDemand;
use winit::window::{Window, WindowId};
use winit::event_loop::ActiveEventLoop;
use wry::WebViewBuilder;
#[derive(Default)]
struct App {
window: Option<Window>,
webview: Option<wry::WebView>,
}
impl ApplicationHandler for App {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
let window = event_loop.create_window(Window::default_attributes()).unwrap();
let webview = WebViewBuilder::new()
.with_html(include_str!("www/sign_in.html"))
.build(&window)
.unwrap();
self.window = Some(window);
self.webview = Some(webview);
}
fn window_event(&mut self, event_loop: &ActiveEventLoop, _window_id: WindowId, event: WindowEvent) {
match event {
WindowEvent::CloseRequested => {
event_loop.exit();
}
_ => {}
}
}
}
fn main() {
let html_content = String::from_utf8(std::fs::read("main_screen").unwrap()).unwrap();
web_view::builder()
.title("My Project")
.content(Content::Html(html_content))
.size(800, 600)
.resizable(false)
.debug(true)
.user_data(())
.invoke_handler(|_webview, _arg| Ok(()))
.run()
.unwrap();
}
let event_loop = EventLoop::new().unwrap();
let mut app = App::default();
event_loop.run_app(&mut app).unwrap();
}

33
src/www/public_release Normal file

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Minecraft Launcher</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 flex justify-center items-center h-screen">
<script>
function downloadVersion() {
const version = document.getElementById("mc-version").value;
// In Rust, this should trigger the actual download.
}
function addMultiMCInstance() {
alert("Select a MultiMC instance folder.");
// In Rust, this should open a file picker.
}
function goToSettings() {
window.location.href = "settings.html";
}
function goToLogin() {
window.location.href = "login.html";
}
</script>
</body>
</html>

94
src/www/sign_in.html Normal file

@ -0,0 +1,94 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Minecraft Launcher - Login</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 flex justify-center items-center h-screen">
<!-- Container -->
<div id="login-screen" class="bg-white shadow-lg rounded-xl p-6 w-96 text-center">
<h2 class="text-2xl font-semibold text-gray-700">CraftX v1.0</h2>
<!-- Username -->
<input type="text" placeholder="Username" class="mt-4 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500">
<!-- Password -->
<!-- <input type="password" placeholder="Password" class="mt-3 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500"> -->
<!-- Sign In Button -->
<button onclick="showAccountSettings()"
class="mt-4 w-full bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded transition">
Sign In
</button>
<!-- Footer -->
<p class="mt-4 text-sm text-gray-500">alterdekim</p>
</div>
<div id="main-screen" class="bg-white shadow-lg rounded-xl p-6 w-96 text-center hidden">
<h1 class="text-2xl font-semibold text-gray-700">Minecraft Launcher</h1>
<!-- Version Selection -->
<label class="block mt-4 text-gray-600">Select Version:</label>
<select id="mc-version" class="mt-2 w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500">
<option value="latest">Latest Release</option>
<option value="1.20.1">1.20.1</option>
<option value="1.19.4">1.19.4</option>
<option value="1.18.2">1.18.2</option>
<option value="1.16.5">1.16.5</option>
<option value="1.12.2">1.12.2 (Modding)</option>
</select>
<!-- Download Button -->
<button onclick="downloadVersion()"
class="mt-4 w-full bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded transition">
<i class="fa-solid fa-download"></i> Download Version
</button>
<!-- OR Divider -->
<div class="mt-4 text-gray-500 text-sm">or</div>
<!-- Add MultiMC Instance -->
<button onclick="addMultiMCInstance()"
class="mt-3 w-full bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded transition">
<i class="fa-solid fa-file-zipper"></i> Add MultiMC Instance
</button>
<!-- Navigation Buttons -->
<div class="mt-6 flex gap-2">
<button onclick="goToSettings()"
class="w-1/2 bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded transition">
<i class="fa-solid fa-gear"></i> Settings
</button>
<button onclick="showLoginScreen()"
class="w-1/2 bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded transition">
<i class="fa-solid fa-key"></i> Logout
</button>
</div>
<p class="mt-4 text-sm text-gray-500">alterdekim</p>
</div>
<script>
function showPlayScreen() {
window.ipc.postMessage("show_play_screen");
}
function showAccountSettings() {
document.getElementById('login-screen').classList.add('hidden');
document.getElementById('main-screen').classList.remove('hidden');
}
function showLoginScreen() {
document.getElementById('main-screen').classList.add('hidden');
document.getElementById('login-screen').classList.remove('hidden');
}
</script>
</body>
</html>