Launcher: tables in notes, the README roadmap, the server's EULA, and a macOS/Windows build workflow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
name: launcher
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: macos-latest
|
||||
artifact: horizon-launcher-macos-arm64
|
||||
binary: horizon-launcher
|
||||
- os: windows-latest
|
||||
artifact: horizon-launcher-windows-x64
|
||||
binary: horizon-launcher.exe
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: launcher
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: launcher
|
||||
- run: cargo build --release --locked
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}
|
||||
path: launcher/target/release/${{ matrix.binary }}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 107 KiB |
+21
-4
@@ -75,10 +75,16 @@ pub fn releases() -> Result<Vec<Release>, String> {
|
||||
pub fn roadmap() -> Result<String, String> {
|
||||
let url = format!("https://raw.githubusercontent.com/{REPO}/main/README.md");
|
||||
let readme = get(&url)?.into_string().map_err(|e| e.to_string())?;
|
||||
for title in ["## Roadmap", "## Project status"] {
|
||||
if let Some(start) = readme.lines().position(|l| l.trim() == title) {
|
||||
let section: Vec<&str> =
|
||||
readme.lines().skip(start + 1).take_while(|l| !l.starts_with("## ")).collect();
|
||||
let level = |l: &str| l.chars().take_while(|c| *c == '#').count();
|
||||
for title in ["Roadmap", "Project status"] {
|
||||
let lines: Vec<&str> = readme.lines().collect();
|
||||
if let Some(start) = lines.iter().position(|l| level(l) > 0 && l.trim_start_matches('#').trim() == title) {
|
||||
let depth = level(lines[start]);
|
||||
let section: Vec<&str> = lines[start + 1..]
|
||||
.iter()
|
||||
.take_while(|l| !(level(l) > 0 && level(l) <= depth))
|
||||
.copied()
|
||||
.collect();
|
||||
return Ok(section.join("\n").trim().to_string());
|
||||
}
|
||||
}
|
||||
@@ -257,6 +263,17 @@ pub fn server_command(tag: &str, folder: &Path) -> Command {
|
||||
cmd
|
||||
}
|
||||
|
||||
pub fn eula_agreed(folder: &Path) -> bool {
|
||||
fs::read_to_string(folder.join("eula.txt")).is_ok_and(|s| s.lines().any(|l| l.trim() == "eula=true"))
|
||||
}
|
||||
|
||||
/// Writes eula.txt as vanilla's server expects it, once the player agreed in the launcher.
|
||||
pub fn agree_eula(folder: &Path) -> Result<(), String> {
|
||||
fs::create_dir_all(folder).map_err(|e| e.to_string())?;
|
||||
let text = "#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).\neula=true\n";
|
||||
fs::write(folder.join("eula.txt"), text).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
pub enum Job {
|
||||
Prepare,
|
||||
|
||||
+46
-5
@@ -185,7 +185,15 @@ impl Launcher {
|
||||
}
|
||||
Job::Server => {
|
||||
self.server = None;
|
||||
self.server_error = error;
|
||||
let old = self.server_log.iter().any(|l| l.contains("unknown option --dedicated"));
|
||||
self.server_error = error.map(|e| {
|
||||
if old {
|
||||
"This version has no dedicated server. Pick a newer one.".to_string()
|
||||
} else {
|
||||
let tail = self.server_log.iter().rev().find(|l| !l.trim().is_empty());
|
||||
tail.map_or(e.clone(), |t| format!("{e}: {t}"))
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -646,8 +654,10 @@ impl Launcher {
|
||||
(Mode::Server, false) => "Start server",
|
||||
(Mode::Server, true) => "Stop server",
|
||||
};
|
||||
let mut play = button("play", play_label, Kind::Primary, &t).min_w(px(96.));
|
||||
if !prepared || self.preparing || (self.mode == Mode::Client && running) {
|
||||
let kind = if self.mode == Mode::Server && running { Kind::Secondary } else { Kind::Primary };
|
||||
let mut play = button("play", play_label, kind, &t).min_w(px(96.));
|
||||
let eula = self.settings.server_dir.as_ref().is_some_and(|d| backend::eula_agreed(d));
|
||||
if !prepared || self.preparing || (self.mode == Mode::Client && running) || (self.mode == Mode::Server && !eula) {
|
||||
play = disabled(play);
|
||||
} else {
|
||||
play = play.on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
|
||||
@@ -684,7 +694,7 @@ impl Launcher {
|
||||
.settings
|
||||
.minecraft_dir
|
||||
.as_deref()
|
||||
.map_or_else(|| div().text_color(t.muted).child("Not found"), |p| div().child(short(p)));
|
||||
.map_or_else(|| div().text_color(t.muted).child("Not found. Choose the official launcher's game folder."), |p| div().child(short(p)));
|
||||
let mut rows = div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
@@ -709,6 +719,37 @@ impl Launcher {
|
||||
))),
|
||||
&t,
|
||||
));
|
||||
let value = if eula {
|
||||
div().child("Agreed")
|
||||
} else {
|
||||
div().text_color(t.muted).child("Running a server needs your agreement to the Minecraft EULA.")
|
||||
};
|
||||
let mut actions = div().flex().gap(px(4.)).child(
|
||||
button("eula-read", "Read", Kind::Ghost, &t)
|
||||
.on_click(cx.listener(|_, _: &ClickEvent, _, cx| cx.open_url("https://aka.ms/MinecraftEULA"))),
|
||||
);
|
||||
if !eula {
|
||||
actions = actions.child(button("eula-agree", "Agree", Kind::Secondary, &t).on_click(cx.listener(
|
||||
|this, _: &ClickEvent, _, cx| {
|
||||
if let Some(dir) = &this.settings.server_dir {
|
||||
if let Err(e) = backend::agree_eula(dir) {
|
||||
this.server_error = Some(e);
|
||||
}
|
||||
}
|
||||
cx.notify();
|
||||
},
|
||||
)));
|
||||
}
|
||||
rows = rows.child(divider(&t)).child(
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap(px(16.))
|
||||
.py(px(12.))
|
||||
.child(div().w(px(150.)).flex_none().text_size(px(13.)).text_color(t.muted).child("Minecraft EULA"))
|
||||
.child(div().flex_1().min_w_0().text_size(px(13.)).text_color(t.text).child(value))
|
||||
.child(actions),
|
||||
);
|
||||
}
|
||||
rows = rows.child(divider(&t));
|
||||
|
||||
@@ -1126,7 +1167,7 @@ impl Render for Launcher {
|
||||
.flex_1()
|
||||
.h_full()
|
||||
.overflow_y_scroll()
|
||||
.child(div().flex().justify_center().px(px(40.)).py(px(36.)).child(div().w_full().max_w(px(760.)).child(content))),
|
||||
.child(div().flex().px(px(48.)).py(px(36.)).child(div().w_full().max_w(px(760.)).child(content))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ enum Block {
|
||||
Item(usize, Option<u64>, String, Vec<(Range<usize>, Span)>),
|
||||
Code(String),
|
||||
Rule,
|
||||
Table(Vec<Vec<(String, Vec<(Range<usize>, Span)>)>>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -28,6 +29,7 @@ pub fn render(source: &str, t: &Theme) -> AnyElement {
|
||||
let mut item: Option<(usize, Option<u64>)> = None;
|
||||
let mut heading = None;
|
||||
let mut code: Option<String> = None;
|
||||
let mut table: Option<Vec<Vec<(String, Vec<(Range<usize>, Span)>)>>> = None;
|
||||
let flush = |blocks: &mut Vec<Block>, text: &mut String, spans: &mut Vec<_>, item: &mut Option<(usize, Option<u64>)>, heading: Option<u8>| {
|
||||
if text.trim().is_empty() {
|
||||
text.clear();
|
||||
@@ -41,7 +43,7 @@ pub fn render(source: &str, t: &Theme) -> AnyElement {
|
||||
_ => Block::Paragraph(t, s),
|
||||
});
|
||||
};
|
||||
for event in Parser::new_ext(source, Options::ENABLE_STRIKETHROUGH) {
|
||||
for event in Parser::new_ext(source, Options::ENABLE_STRIKETHROUGH | Options::ENABLE_TABLES) {
|
||||
match event {
|
||||
Event::Start(Tag::Heading { level, .. }) => {
|
||||
heading = Some(match level {
|
||||
@@ -94,6 +96,21 @@ pub fn render(source: &str, t: &Theme) -> AnyElement {
|
||||
Event::SoftBreak => text.push(' '),
|
||||
Event::HardBreak => text.push('\n'),
|
||||
Event::Rule => blocks.push(Block::Rule),
|
||||
Event::Start(Tag::Table(_)) => {
|
||||
flush(&mut blocks, &mut text, &mut spans, &mut item, None);
|
||||
table = Some(Vec::new())
|
||||
}
|
||||
Event::Start(Tag::TableHead | Tag::TableRow) => {
|
||||
if let Some(t) = &mut table {
|
||||
t.push(Vec::new())
|
||||
}
|
||||
}
|
||||
Event::End(TagEnd::TableCell) => {
|
||||
if let Some(row) = table.as_mut().and_then(|t| t.last_mut()) {
|
||||
row.push((std::mem::take(&mut text), std::mem::take(&mut spans)));
|
||||
}
|
||||
}
|
||||
Event::End(TagEnd::Table) => blocks.push(Block::Table(table.take().unwrap_or_default())),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -148,6 +165,20 @@ pub fn render(source: &str, t: &Theme) -> AnyElement {
|
||||
.child(code.trim_end().to_string())
|
||||
.into_any_element(),
|
||||
Block::Rule => div().h(px(1.)).bg(t.border).my(px(8.)).into_any_element(),
|
||||
Block::Table(rows) => {
|
||||
let mut grid = div().flex().flex_col().my(px(4.)).border_t_1().border_color(t.border);
|
||||
for (i, row) in rows.into_iter().enumerate() {
|
||||
let mut line = div().flex().gap(px(16.)).py(px(8.)).border_b_1().border_color(t.border);
|
||||
let columns = row.len();
|
||||
for (j, (text, spans)) in row.into_iter().enumerate() {
|
||||
// Two-column tables keep a narrow first column; wider ones share the width.
|
||||
let cell = if j == 0 && columns > 1 { div().w(px(180.)).flex_none() } else if j + 1 < columns && columns > 2 { div().w(px(56.)).flex_none() } else { div().flex_1().min_w_0() };
|
||||
line = line.child(cell.when(i == 0, |d| d.text_color(t.text).font_weight(FontWeight::MEDIUM).text_size(px(12.5))).child(styled(text, spans)));
|
||||
}
|
||||
grid = grid.child(line);
|
||||
}
|
||||
grid.into_any_element()
|
||||
}
|
||||
});
|
||||
}
|
||||
column.into_any_element()
|
||||
|
||||
Reference in New Issue
Block a user