Skip to content

Commit

Permalink
Lots of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rockisch committed Nov 24, 2023
1 parent 2cad836 commit b16e9ad
Show file tree
Hide file tree
Showing 21 changed files with 695 additions and 540 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ A custom Monster Hunter Frontier launcher.
- Multi-language support (currently EN and JP)
- Allows you to download your character data
- Allows servers to customize what icons and messages their users will see
- Allows you to open multiple clients on the same machine (you probably shouldn't though!)
- Automatic reauthentication when token expires
- Allows you to connect to the [new patch server](https://github.com/rockisch/mhf-patch-server) if enabled on your host
- Reauthentication when token expires (in-game auth can still expire)
- Can use HTTPS to connect to launcher servers (in-game connections are still insecure)
- Can use HTTPS to connect to the launcher and patch servers (in-game connections are still unnafected)
- ...and much more!

## Planned Features

- More styles! (PS4 Launcher, non-ZZ themes)
- Game updater/patcher
- More server-related 'commands' that are not supported in-game: Renaming character, save uploading, etc
- These will _all_ be opt-in by the server host

Expand Down
23 changes: 23 additions & 0 deletions locale/en.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ server-host-label = Host
server-launcher-port-label = Launcher Port
server-game-port-label = Game Port
server-game-folder-label = Server Game Path
server-game-version-label = Version
# Messages
announcements-label = Announcements
Expand All @@ -42,6 +43,7 @@ modern-style = Modern Style
game-folder-label = Game Folder
current-folder-label = Current Folder
list-remote-servers-label = List Remote Servers
list-remote-messages-label = List Global Messages
serverlist-url-label = Serverlist URL
# Characters page
Expand Down Expand Up @@ -87,3 +89,24 @@ bow-label = Bow
tonfa-label = Tonfa
switch-axe-label = Switch Axe
magnetic-spike-label = Magnetic Spike
# Launcher
endpoint-name-empty = Server name must not be empty
endpoint-host-empty = Server host must not be empty
endpoint-unique = Server names must be unique
file-error = Failed to manage files
path-folder-error = Path must be a directory
path-exists-error = The specified game folder does not exist
current-endpoint-error = Unable to fetch data from selected server
remote-endpoint-error = Unable to fetch remote servers
remote-messages-error = Unable to fetch global messages
launcher-network-error = Launcher failed to connect to launcher server
patcher-network-error = Patcher failed to connect to patcher server
patcher-file-error = Patcher failed to manage files in game folder
internal-error = Launcher error, check logs
# Remote
username-error = Username does not exist
password-error = Your password is incorrect
username-exists-error = Username already exists
username-password-empty-error = Username and password must not be empty
6 changes: 1 addition & 5 deletions messagelist.json
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
[
{

}
]
[]
2 changes: 1 addition & 1 deletion serverlist.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"name": "Rain (JP)", "host": "https://103.150.191.107", "game_port": "53312"}, {"name": "Hunsterverse (US)", "host": "https://129.213.54.221", "game_port": "53312"}, {"name": "Renewal (US)", "host": "https://70.80.86.24", "game_port": "53312"}, {"name": "Arca (SA)", "host": "https://54.207.29.25", "game_port": "53312"}, {"name": "Rain (US)", "host": "https://206.189.225.228", "game_port": "53312"}, {"name": "Rain (EU)", "host": "https://134.122.76.222", "game_port": "53312"}, {"name": "Ancient (SA)", "host": "https://34.201.100.139", "game_port": "53312"}, {"name": "Hunters Pariadise (EU)", "host": "https://109.190.118.174", "game_port": "53312"}, {"name": "Quick Hunt (US)", "host": "https://35.133.218.93", "game_port": "53312"}, {"name": "DoomServer (RU)", "host": "https://193.124.64.139", "game_port": "53312"}, {"name": "Wild Hunters (CU)", "host": "https://152.206.201.134", "game_port": "53312"}]
[]
1 change: 1 addition & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@ tauri-build = { version = "1.5", features = [] }

[dependencies]
log = "0.4"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_repr = "0.1"
reqwest = { version = "0.11", features = ["json", "gzip"] }
keyring = "2"
sha2 = "0.10"
tokio = { version = "1", features = ["macros"] }
tokio-util = { version = "0.7", features = [] }
tauri = { version = "1.5", features = ["api-all"] }
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }

# mhf-iel = { git = "https://github.com/rockisch/mhf-iel.git", rev = "9c0181f7c5fa24219ab5a9040cd079ecdbc1cb4a" }
mhf-iel = { path = "../../mhf-iel" }
sha2 = "0.10"
# fluent-fallback = "0.7"
mhf-iel = { git = "https://github.com/rockisch/mhf-iel.git", rev = "8c5a28f0824c862fc1f5f807415d94c71a6c2371" }

[features]
# by default Tauri runs in production mode
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![allow(clippy::needless_update)]
use crate::Endpoint;

pub const CLASSIC_STYLE: u32 = 0;
pub const MODERN_STYLE: u32 = 1;
pub const MODERN_STYLE: u32 = 0;
pub const CLASSIC_STYLE: u32 = 1;

pub const DEFAULT_SERVERLIST_URL: &str =
"https://raw.githubusercontent.com/rockisch/mhf-launcher/master/serverlist.json";
Expand All @@ -12,7 +12,7 @@ pub const DEFAULT_MESSAGELIST_URL: &str =
pub fn get_default_endpoints() -> Vec<Endpoint> {
vec![Endpoint {
name: "Localhost".into(),
host: "http://localhost".into(),
url: "http://localhost".into(),
is_remote: true,
..Default::default()
}]
Expand Down
33 changes: 20 additions & 13 deletions src-tauri/src/endpoint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, path::PathBuf};
use std::{collections::HashMap, path::PathBuf, str::FromStr};

use serde::{Deserialize, Serialize};

Expand All @@ -10,11 +10,12 @@ pub struct EndpointConfig {
#[derive(Default, Debug, Serialize, Deserialize, Clone, Eq, PartialOrd, Ord)]
#[serde(rename_all = "camelCase")]
pub struct Endpoint {
pub url: String,
pub name: String,
pub host: String,
pub launcher_port: Option<u16>,
pub game_port: Option<u16>,
pub game_folder: Option<PathBuf>,
pub version: mhf_iel::MhfVersion,
#[serde(default)]
pub is_remote: bool,
}
Expand All @@ -26,12 +27,19 @@ impl PartialEq for Endpoint {
}

impl Endpoint {
pub fn url(&self, path: &str) -> String {
pub fn host(&self) -> String {
reqwest::Url::from_str(&self.url)
.ok()
.and_then(|u| u.host().map(|h| h.to_string()))
.unwrap_or(self.url.to_owned())
}

pub fn get_url(&self, path: &str) -> String {
let port = self.launcher_port.unwrap_or(8080);
if self.host.contains("://") {
format!("{}:{}{}", self.host, port, path)
if self.url.contains("://") {
format!("{}:{}{}", self.url, port, path)
} else {
format!("http://{}:{}{}", self.host, port, path)
format!("http://{}:{}{}", self.url, port, path)
}
}
}
Expand All @@ -47,16 +55,15 @@ impl EndpointVecExt for Vec<Endpoint> {
fn check_valid(&self) -> Result<(), &'static str> {
for endpoint in self {
if endpoint.name.is_empty() {
return Err("Server name must not be empty");
} else if endpoint.host.is_empty() {
return Err("Server host must not be empty");
return Err("endpoint-name-empty");
} else if endpoint.url.is_empty() {
return Err("endpoint-host-empty");
} else if self.iter().filter(|e| e.name == endpoint.name).count() > 1 {
return Err("Server names must be unique");
return Err("endpoint-unique");
}
if let Some(game_folder) = endpoint.game_folder.as_ref() {
if !game_folder.exists() {
println!("{:?}", game_folder);
return Err("The specified game folder does not exist");
return Err("path-exists-error");
}
}
}
Expand All @@ -66,7 +73,7 @@ impl EndpointVecExt for Vec<Endpoint> {
fn extend_valid(&mut self, other: Self) {
self.reserve(other.len());
for endpoint in other {
if !endpoint.name.is_empty() && !endpoint.host.is_empty() && !self.contains(&endpoint) {
if !endpoint.name.is_empty() && !endpoint.url.is_empty() && !self.contains(&endpoint) {
self.push(endpoint)
}
}
Expand Down
Loading

0 comments on commit b16e9ad

Please sign in to comment.