Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLohrer committed Jan 3, 2024
2 parents 7248606 + 63aef16 commit 2f2699f
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 36 deletions.
1 change: 1 addition & 0 deletions src-tauri/src/app/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ async fn run_client(branch: String, login_data: LoginData, options: LauncherOpti
memory: percentage_of_total_memory(options.memory_percentage),
data_path: options.data_path_buf(),
custom_java_path: if !options.custom_java_path.is_empty() { Some(options.custom_java_path) } else { None },
custom_java_args: options.custom_java_args,
auth_player_name: login_data.username,
auth_uuid: login_data.uuid,
auth_access_token: login_data.mc_token,
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/minecraft/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ pub struct LaunchingParameter {
pub memory: i64,
pub data_path: PathBuf,
pub custom_java_path: Option<String>,
pub custom_java_args: String,
pub auth_player_name: String,
pub auth_uuid: String,
pub auth_access_token: String,
Expand Down
4 changes: 4 additions & 0 deletions src-tauri/src/minecraft/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ impl ArgumentDeclaration {
command_arguments.push("-XX:G1HeapRegionSize=32M".to_string());
command_arguments.push(format!("-Dnorisk.token={}", norisk_token));
command_arguments.push(format!("-Dnorisk.experimental={}", parameter.dev_mode));
for arg in parameter.custom_java_args.split(" ") {
println!("Added custom java arg: {:?}", arg);
command_arguments.push(arg.to_string());
}

match self {
ArgumentDeclaration::V14(_) => command_arguments.append(&mut vec!["-Djava.library.path=${natives_directory}".to_string(), "-cp".to_string(), "${classpath}".to_string()]),
Expand Down
10 changes: 6 additions & 4 deletions src/components/config/ConfigModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { invoke } from "@tauri-apps/api";
import ConfigRadioButton from "./inputs/ConfigRadioButton.svelte";
import ConfigTextInput from "./inputs/ConfigTextInput.svelte";
import ConfigFolderInput from "./inputs/ConfigFolderInput.svelte";
import { createEventDispatcher } from "svelte";
const dispatch = createEventDispatcher();
Expand Down Expand Up @@ -64,8 +65,9 @@
<ConfigSlider title="RAM" suffix="%" min={20} max={100} bind:value={options.memoryPercentage} step={1} />
<ConfigSlider title="Max Downloads" suffix="" min={1} max={50} bind:value={options.concurrentDownloads}
step={1} />
<ConfigTextInput title="Java Path" bind:value={options.customJavaPath} />
<ConfigTextInput title="Data Folder" bind:value={options.dataPath} />
<ConfigFolderInput title="Java Path" bind:value={options.customJavaPath} />
<ConfigTextInput title="Custom JVM args" bind:value={options.customJavaArgs} />
<ConfigFolderInput title="Data Folder" bind:value={options.dataPath} />
</div>
</div>
<!-- svelte-ignore a11y-autofocus -->
Expand Down Expand Up @@ -111,8 +113,8 @@
dialog {
background-color: var(--background-color);
border: 5px solid black;
width: 30em;
height: 37em;
width: 34em;
height: 42em;
border-radius: 0.2em;
padding: 0;
position: fixed; /* Fixierte Positionierung */
Expand Down
84 changes: 84 additions & 0 deletions src/components/config/inputs/ConfigFolderInput.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

<script>
import { open } from '@tauri-apps/api/dialog';
export let title;
export let value; // value of the text field
// Try to get user-desired folder path via system dialog
async function selectFolderPath() {
try {
const result = await open({
defaultPath: value,
directory: true,
})
if (result) {
value = result
}
} catch (e) {
alert("Failed to select folder using dialog")
}
}
</script>

<div class="input-container">
<h1>{title}</h1>
<div class="input-button-wrapper">
<!-- svelte-ignore a11y-autofocus -->
<input placeholder="Internal" autofocus={false} bind:value={value} type="text" class="nes-input" disabled>
<button on:click={selectFolderPath} aria-label="Select Folder">📂</button>
</div>
</div>

<style>
.input-button-wrapper {
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
}
input {
margin-right: 5px;
}
button {
outline: none;
background-color: transparent;
border: none;
text-align: center;
padding: 3.5px;
}
button:hover {
cursor: pointer;
}
.input-container {
display: flex;
flex-direction: column;
align-items: start;
}
.input-container h1 {
font-family: 'Press Start 2P', serif;
font-size: 18px;
margin-bottom: 0.8em;
cursor: default;
}
.nes-input {
font-family: 'Press Start 2P', serif;
font-size: 10px;
padding: 6px 8px;
border: 1px solid #212121;
background-color: var(--background-contrast-color);
width: 100%;
outline: none;
transition: background-color 0.3s ease-in-out;
}
.nes-input::placeholder {
color: var(--font-color);
}
</style>
34 changes: 2 additions & 32 deletions src/components/config/inputs/ConfigTextInput.svelte
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@

<script>
import { open } from '@tauri-apps/api/dialog';
export let title;
export let value; // value of the text field
// Try to get user-desired folder path via system dialog
async function selectFolderPath() {
try {
const result = await open({
defaultPath: value,
directory: true,
})
if (result) {
value = result
}
} catch (e) {
alert("Failed to select folder using dialog")
}
}
</script>

<div class="input-container">
<h1>{title}</h1>
<div class="input-button-wrapper">
<!-- svelte-ignore a11y-autofocus -->
<input placeholder="Internal" autofocus={false} bind:value={value} type="text" class="nes-input" disabled>
<button on:click={selectFolderPath} aria-label="Select Folder">📂</button>
<input placeholder="" autofocus={false} bind:value={value} type="text" class="nes-input">
</div>
</div>

Expand All @@ -37,23 +19,11 @@
flex-direction: row;
align-items: center;
}
input {
margin-right: 5px;
}
button {
outline: none;
background-color: transparent;
border: none;
text-align: center;
padding: 3.5px;
}
button:hover {
cursor: pointer;
}
.input-container {
display: flex;
flex-direction: column;
Expand Down

0 comments on commit 2f2699f

Please sign in to comment.