launcher: a skin and a cape for each offline name
Settings > Account's Skin... shows the front of an offline name's skin and cape, takes a skin PNG (64x64 or 64x32) and a cape PNG (64x32 or 22x17), and picks classic or slim arms. The launcher keeps copies in skins/ and gives the game HORIZON_OFFLINE_SKIN, HORIZON_OFFLINE_SKIN_MODEL and HORIZON_OFFLINE_CAPE when that name plays. CLI and MCP: account skin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+77
-1
@@ -93,6 +93,25 @@ enum AccountCmd {
|
||||
Offline { name: Option<String> },
|
||||
/// Forget one of your offline names
|
||||
ForgetOffline { name: String },
|
||||
/// Show or set an offline name's skin and cape: a 64x64 (or 64x32) skin PNG, a 64x32 cape
|
||||
/// PNG, the model. Kept by the launcher and given to the game when that name plays
|
||||
Skin {
|
||||
name: String,
|
||||
/// The skin's PNG
|
||||
file: Option<PathBuf>,
|
||||
/// classic or slim arms
|
||||
#[arg(long)]
|
||||
model: Option<String>,
|
||||
/// The cape's PNG
|
||||
#[arg(long)]
|
||||
cape: Option<PathBuf>,
|
||||
/// Back to the default skin
|
||||
#[arg(long)]
|
||||
no_skin: bool,
|
||||
/// Take the cape off
|
||||
#[arg(long)]
|
||||
no_cape: bool,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
@@ -963,9 +982,11 @@ fn execute(command: Cmd, as_json: bool) -> Result<(), String> {
|
||||
}
|
||||
cmd.args(arg);
|
||||
let started = std::time::Instant::now();
|
||||
if let Some(name) = Accounts::load().name_arg() {
|
||||
let accounts = Accounts::load();
|
||||
if let Some(name) = accounts.name_arg() {
|
||||
cmd.arg("--name").arg(name);
|
||||
}
|
||||
cmd.envs(accounts.look_env());
|
||||
let played = attached(horizon_launcher::launch::wrap(cmd, &instance.launch));
|
||||
if let Err(e) = instances::record_play(&instance.id, started.elapsed()) {
|
||||
eprintln!("Play time not saved: {e}");
|
||||
@@ -1332,6 +1353,61 @@ fn account_command(action: AccountCmd, as_json: bool) -> Result<(), String> {
|
||||
None => println!("The game plays offline, as the name it made up."),
|
||||
}
|
||||
}
|
||||
AccountCmd::Skin {
|
||||
name,
|
||||
file,
|
||||
model,
|
||||
cape,
|
||||
no_skin,
|
||||
no_cape,
|
||||
} => {
|
||||
use horizon_launcher::skins::{self, Model};
|
||||
let name = accounts
|
||||
.offline
|
||||
.iter()
|
||||
.find(|n| n.eq_ignore_ascii_case(&name))
|
||||
.cloned()
|
||||
.ok_or_else(|| {
|
||||
format!("No offline name {name}: add it with `account offline {name}`.")
|
||||
})?;
|
||||
let model = match model.as_deref() {
|
||||
None => None,
|
||||
Some("classic") => Some(Model::Classic),
|
||||
Some("slim") => Some(Model::Slim),
|
||||
Some(m) => return Err(format!("{m}: say classic or slim")),
|
||||
};
|
||||
let mut look = accounts.look(&name);
|
||||
if let Some(file) = &file {
|
||||
skins::keep(&skins::dir(), &name, file, false)?;
|
||||
look.skin = true;
|
||||
}
|
||||
if let Some(file) = &cape {
|
||||
skins::keep(&skins::dir(), &name, file, true)?;
|
||||
look.cape = true;
|
||||
}
|
||||
if let Some(m) = model {
|
||||
look.model = m;
|
||||
}
|
||||
look.skin &= !no_skin;
|
||||
look.cape &= !no_cape;
|
||||
accounts
|
||||
.looks
|
||||
.insert(name.to_ascii_lowercase(), look.clone());
|
||||
accounts.save()?;
|
||||
if as_json {
|
||||
json(serde_json::json!({
|
||||
"name": name, "skin": look.skin, "cape": look.cape, "model": look.model.name(),
|
||||
}));
|
||||
} else {
|
||||
let say = |on: bool, what: &str| if on { what.to_string() } else { "none".into() };
|
||||
println!(
|
||||
"{name}: skin {} ({} arms), cape {}",
|
||||
say(look.skin, "kept"),
|
||||
look.model.name(),
|
||||
say(look.cape, "kept")
|
||||
);
|
||||
}
|
||||
}
|
||||
AccountCmd::ForgetOffline { name } => {
|
||||
accounts.remove_offline(&name)?;
|
||||
accounts.save()?;
|
||||
|
||||
Reference in New Issue
Block a user