From 7d7776f16eb29a60c8a3ca292f7ff6d29995ef5d Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 3 May 2025 18:49:39 -0400 Subject: [PATCH] Add setup page to download generated LauncherTweaks configs --- resources/templates/launchertweaks.toml | 7 +++++ resources/templates/setup.html | 20 +++++++++++++ resources/templates/web_base.html | 3 ++ src/bin/kawari-web.rs | 37 +++++++++++++++++++++++++ src/config.rs | 6 ++++ 5 files changed, 73 insertions(+) create mode 100644 resources/templates/launchertweaks.toml create mode 100644 resources/templates/setup.html diff --git a/resources/templates/launchertweaks.toml b/resources/templates/launchertweaks.toml new file mode 100644 index 0000000..08633b7 --- /dev/null +++ b/resources/templates/launchertweaks.toml @@ -0,0 +1,7 @@ +launcher_url = "http://{{ launcher_url }}/v700/" +disable_webview2_install = {{ enable_webview2 }} +disable_boot_version_check = true +force_http = true +game_patch_server = "{{ game_patch_server }}" +boot_patch_server = "{{ boot_patch_server }}" +extra_game_arguments = " /DEV.LobbyHost04 =127.0.0.1 /DEV.LobbyPort04 ={{ lobby_port }}" diff --git a/resources/templates/setup.html b/resources/templates/setup.html new file mode 100644 index 0000000..cb13c1e --- /dev/null +++ b/resources/templates/setup.html @@ -0,0 +1,20 @@ +{% extends "web_base.html" %} + +{% block title %}Kawari - Setup{% endblock %} + +{% block webbody %} +
+

Official Launcher

+ +

First, download LauncherTweaks and place the winmm.dll next to ffxivboot64.exe. Download the config below, and place it in the same folder.

+ +

Download Config (WebView2)

+

Download Config (IE)

+ +

If you're using Linux and have problems with WebView2, download the "IE" config. If you don't know what this means, then download the WebView2 config.

+ +

Astra

+ +

Instructions coming soon!

+
+{% endblock %} diff --git a/resources/templates/web_base.html b/resources/templates/web_base.html index 367bf17..bf75652 100644 --- a/resources/templates/web_base.html +++ b/resources/templates/web_base.html @@ -15,6 +15,9 @@ + diff --git a/src/bin/kawari-web.rs b/src/bin/kawari-web.rs index 2b28b7e..219972b 100644 --- a/src/bin/kawari-web.rs +++ b/src/bin/kawari-web.rs @@ -1,3 +1,4 @@ +use axum::extract::Query; use axum::response::Html; use axum::{Router, routing::get}; use kawari::config::get_config; @@ -37,6 +38,18 @@ fn setup_default_environment() -> Environment<'static> { .expect("Failed to find template!"), ) .unwrap(); + env.add_template_owned( + "setup.html", + std::fs::read_to_string("resources/templates/setup.html") + .expect("Failed to find template!"), + ) + .unwrap(); + env.add_template_owned( + "launchertweaks.toml", + std::fs::read_to_string("resources/templates/launchertweaks.toml") + .expect("Failed to find template!"), + ) + .unwrap(); env } @@ -70,6 +83,28 @@ async fn world_status() -> Html { ) } +async fn setup() -> Html { + let environment = setup_default_environment(); + let template = environment.get_template("setup.html").unwrap(); + Html(template.render({}).unwrap()) +} + +#[derive(Deserialize)] +#[allow(dead_code)] +struct Params { + r#type: String, +} + +async fn launcher_config(Query(params): Query) -> String { + let config = get_config(); + + let environment = setup_default_environment(); + let template = environment.get_template("launchertweaks.toml").unwrap(); + template + .render(context! { launcher_url => config.launcher.server_name, enable_webview2 => if params.r#type == "webview2" { false } else { true }, game_patch_server => config.patch.game_server_name, boot_patch_server => config.patch.boot_server_name, lobby_port => config.lobby.port }) + .unwrap() +} + #[tokio::main] async fn main() { tracing_subscriber::fmt::init(); @@ -77,6 +112,8 @@ async fn main() { let app = Router::new() .route("/", get(root)) .route("/worldstatus", get(world_status)) + .route("/setup", get(setup)) + .route("/launcherconfig", get(launcher_config)) .nest_service("/static", ServeDir::new("resources/static")); let config = get_config(); diff --git a/src/config.rs b/src/config.rs index 3062004..8a91722 100644 --- a/src/config.rs +++ b/src/config.rs @@ -132,6 +132,8 @@ pub struct PatchConfig { /// ... /// ``` pub patches_location: String, + pub game_server_name: String, + pub boot_server_name: String, } impl Default for PatchConfig { @@ -141,6 +143,8 @@ impl Default for PatchConfig { listen_address: "127.0.0.1".to_string(), patch_dl_url: "patch-dl.ffxiv.localhost".to_string(), patches_location: String::new(), + boot_server_name: "patch-bootver.ffxiv.localhost".to_string(), + game_server_name: "patch-gamever.ffxiv.localhost".to_string(), } } } @@ -284,6 +288,7 @@ impl WorldConfig { pub struct LauncherConfig { pub port: u16, pub listen_address: String, + pub server_name: String, } impl Default for LauncherConfig { @@ -291,6 +296,7 @@ impl Default for LauncherConfig { Self { port: 5802, listen_address: "127.0.0.1".to_string(), + server_name: "launcher.ffxiv.localhost".to_string(), } } }