diff --git a/Cargo.toml b/Cargo.toml index 51d5a8a..27dceb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "steven" version = "0.0.1" authors = [ "Thinkofdeath " ] +build = "build.rs" [dependencies] rustc-serialize = "0.3" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..6635b12 --- /dev/null +++ b/build.rs @@ -0,0 +1,37 @@ +use std::env; +use std::fs; +use std::path::Path; +use std::io::BufWriter; +use std::io::Write; + +fn main() { + let out_dir = env::var("OUT_DIR").unwrap(); + let dest = Path::new(&out_dir); + + let base = Path::new("resources"); + let mut out = Vec::new(); + build_map(&mut out, &base); + + let mut file = BufWriter::new(fs::File::create(&dest.join("resources.rs")).unwrap()); + write!(file, "pub fn get_file(name: &str) -> Option<&'static [u8]> {{\n").unwrap(); + write!(file, " match name {{\n").unwrap(); + for entry in &out { + let entry = entry.replace("\\", "/"); + let short = &entry["resources/".len()..]; + write!(file, " {:?} => Some(include_bytes!(\"../{}\")),\n", short, entry).unwrap(); + } + write!(file, " _ => None\n }}\n}}\n").unwrap(); + +} + +fn build_map(out: &mut Vec, path: &Path) { + let files = fs::read_dir(path).unwrap(); + for entry in files { + let entry = entry.unwrap(); + if fs::metadata(entry.path()).unwrap().is_dir() { + build_map(out, &entry.path()); + } else { + out.push(entry.path().to_str().unwrap().to_owned()); + } + } +} diff --git a/resources/assets/minecraft/texts/splashes.txt b/resources/assets/minecraft/texts/splashes.txt new file mode 100644 index 0000000..241e3e1 --- /dev/null +++ b/resources/assets/minecraft/texts/splashes.txt @@ -0,0 +1,52 @@ +I blame Xor +Its not a bug its a feature! +Don't go to #think, tis a silly place +Tested! (In production) +Not in scala! +Its steven not phteven! +Now webscale! +Meow +I bet one of cindy's cats broke it! +=^.^= +ಠ_ಠ +Commit reverted in 5..4..3... +Latest is greatest! +[This space is intentionally left blank] +ThinkBot: .... *Thinkofdeath damn it +Now with more bugs! +I blame Mojang +The logo is totally not ascii art rendered as textures +Look, it works on my machine. +Open Source! https://github.com/thinkofdeath/steven +Built with Go! +try { } catch (Exception e) { } +panic(recover()) +// Abandon hope all ye who enter here +Its like I'm racing vanilla to see who can have the most bugs +Using ascii art for the logo seemed like a bad idea at first +... and still does. +Help! I'm trapped in the splash text! +Linux support! +Windows support! +Mac support! (in theory) +Come chat on IRC! +Knowing Murphy's Law doesn't help +Minecraft Multi-processing: breaking three things at once +Silly Mortal... +Software isn't released. It's allowed to escape. +General System Error: Please sacrifice a cow and two chickens to continue +Do you want to build a client? +sudo rm -rf --no-preserve-root / +Thinkofdeath.getClass().getField("sanity").set(Thinkofdeath, null); +Now with potatoes! +And then you cleanse them in a ball of atomic fire! +I'm a little matrix, square and stout, +this is my transpose, this is my count. +var f = function() { return f; }; +unsafe.allocateObject(Unsafe.class); +:(){ :|:& };: +You must pay to view this content. +No touchy the topic +Ceci n'est pas un splash. +Xor is not actually a cat. +The MD5 of md_5 is e14cfacdd442a953343ebd8529138680 diff --git a/resources/assets/minecraft/textures/font/ascii.png b/resources/assets/minecraft/textures/font/ascii.png new file mode 100644 index 0000000..67fdbf1 Binary files /dev/null and b/resources/assets/minecraft/textures/font/ascii.png differ diff --git a/resources/assets/steven/blockstates/missing_block.json b/resources/assets/steven/blockstates/missing_block.json new file mode 100644 index 0000000..4458eec --- /dev/null +++ b/resources/assets/steven/blockstates/missing_block.json @@ -0,0 +1,5 @@ +{ + "variants": { + "normal": { "model": "missing_block" } + } +} diff --git a/resources/assets/steven/logo/logo.txt b/resources/assets/steven/logo/logo.txt new file mode 100644 index 0000000..597bb68 --- /dev/null +++ b/resources/assets/steven/logo/logo.txt @@ -0,0 +1,16 @@ + SSSSSSSSSSSSSSS tttt + SS:::::::::::::::S ttt:::t +S:::::SSSSSS::::::S t:::::t +S:::::S SSSSSSS t:::::t +S:::::S ttttttt:::::ttttttt eeeeeeeeeeee vvvvvvv vvvvvvv eeeeeeeeeeee nnnn nnnnnnnn +S:::::S t:::::::::::::::::t ee::::::::::::ee v:::::v v:::::v ee::::::::::::ee n:::nn::::::::nn + S::::SSSS t:::::::::::::::::t e::::::eeeee:::::ee v:::::v v:::::v e::::::eeeee:::::een::::::::::::::nn + SS::::::SSSSS tttttt:::::::tttttt e::::::e e:::::e v:::::v v:::::v e::::::e e:::::enn:::::::::::::::n + SSS::::::::SS t:::::t e:::::::eeeee::::::e v:::::v v:::::v e:::::::eeeee::::::e n:::::nnnn:::::n + SSSSSS::::S t:::::t e:::::::::::::::::e v:::::v v:::::v e:::::::::::::::::e n::::n n::::n + S:::::S t:::::t e::::::eeeeeeeeeee v:::::v:::::v e::::::eeeeeeeeeee n::::n n::::n + S:::::S t:::::t tttttte:::::::e v:::::::::v e:::::::e n::::n n::::n +SSSSSSS S:::::S t::::::tttt:::::te::::::::e v:::::::v e::::::::e n::::n n::::n +S::::::SSSSSS:::::S tt::::::::::::::t e::::::::eeeeeeee v:::::v e::::::::eeeeeeee n::::n n::::n +S:::::::::::::::SS tt:::::::::::tt ee:::::::::::::e v:::v ee:::::::::::::e n::::n n::::n + SSSSSSSSSSSSSSS ttttttttttt eeeeeeeeeeeeee vvv eeeeeeeeeeeeee nnnnnn nnnnnn \ No newline at end of file diff --git a/resources/assets/steven/logo/textures.txt b/resources/assets/steven/logo/textures.txt new file mode 100644 index 0000000..ca8606b --- /dev/null +++ b/resources/assets/steven/logo/textures.txt @@ -0,0 +1,22 @@ +blocks/cobblestone +blocks/netherrack +blocks/dirt +blocks/planks_oak +blocks/brick +blocks/snow +blocks/sand +blocks/gravel +blocks/hardened_clay +blocks/clay +blocks/bedrock +blocks/obsidian +blocks/end_stone +blocks/stone_andesite +blocks/dirt_podzol_top +blocks/portal +blocks/prismarine_rough +blocks/soul_sand +blocks/lava_still +blocks/hay_block_top +blocks/log_acacia +blocks/red_sandstone_carved \ No newline at end of file diff --git a/resources/assets/steven/models/block/missing_block.json b/resources/assets/steven/models/block/missing_block.json new file mode 100644 index 0000000..f8cc2cb --- /dev/null +++ b/resources/assets/steven/models/block/missing_block.json @@ -0,0 +1,18 @@ +{ + "textures": { + "all": "missing_texture" + }, + "elements": [ + { "from": [ 0, 0, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "texture": "#all", "cullface": "down" }, + "up": { "texture": "#all", "cullface": "up" }, + "north": { "texture": "#all", "cullface": "north" }, + "south": { "texture": "#all", "cullface": "south" }, + "west": { "texture": "#all", "cullface": "west" }, + "east": { "texture": "#all", "cullface": "east" } + } + } + ] +} diff --git a/resources/assets/steven/textures/environment/clouds.png b/resources/assets/steven/textures/environment/clouds.png new file mode 100644 index 0000000..aace0d3 Binary files /dev/null and b/resources/assets/steven/textures/environment/clouds.png differ diff --git a/resources/assets/steven/textures/gui/cog.png b/resources/assets/steven/textures/gui/cog.png new file mode 100644 index 0000000..58ffa0d Binary files /dev/null and b/resources/assets/steven/textures/gui/cog.png differ diff --git a/src/main.rs b/src/main.rs index 90359b6..3ac3c11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,6 +63,15 @@ fn main() { let mut last_frame = time::now(); let frame_time = (time::Duration::seconds(1).num_nanoseconds().unwrap() as f64) / 60.0; + // Test stuff + let img = ui::Image::new( + render::Renderer::get_texture(renderer.get_textures_ref(), "steven:gui/cog"), + 50.0, 50.0, 100.0, 100.0, + 0.0, 0.0, 1.0, 1.0, + 255, 255, 255 + ); + let img_ref = ui_container.add(img); + while !window.should_close() { { resource_manager.write().unwrap().tick(); } let now = time::now(); diff --git a/src/render/mod.rs b/src/render/mod.rs index ebde8c6..281c1d4 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -240,8 +240,6 @@ impl TextureManager { self.textures.get(name).map(|v| v.clone()) } - // TODO: Animated textures - fn load_texture(&mut self, name: &str) { let (plugin, name) = if let Some(pos) = name.find(':') { (&name[..pos], &name[pos+1..]) @@ -271,7 +269,7 @@ impl TextureManager { return; } } - self.insert_texture_dummy(name); + self.insert_texture_dummy(plugin, name); } fn load_animation(&mut self, plugin: &str, name: &str, img: &image::DynamicImage, data: Vec) -> Option { @@ -366,10 +364,18 @@ impl TextureManager { (index, rect.unwrap()) } - fn insert_texture_dummy(&mut self, name: &str) -> Texture { + fn insert_texture_dummy(&mut self, plugin: &str, name: &str) -> Texture { let missing = self.get_texture("steven:missing_texture").unwrap(); + + let mut full_name = String::new(); + if plugin != "minecraft" { + full_name.push_str(plugin); + full_name.push_str(":"); + } + full_name.push_str(name); + let t = Texture { - name: name.to_owned(), + name: full_name.to_owned(), version: self.version, atlas: missing.atlas, x: missing.x, @@ -382,7 +388,7 @@ impl TextureManager { rel_height: 1.0, is_rel: false, }; - self.textures.insert(name.to_owned(), t.clone()); + self.textures.insert(full_name.to_owned(), t.clone()); t } } diff --git a/src/resources.rs b/src/resources.rs index d7a9887..5a840b4 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -21,6 +21,10 @@ use std::io; use std::fs; use std::sync::mpsc; +mod internal { + include!(concat!(env!("OUT_DIR"), "/resources.rs")); +} + const RESOURCES_VERSION: &'static str = "15w37a"; pub trait Pack { @@ -41,6 +45,7 @@ impl Manager { version: 0, vanilla_chan: None, }; + m.add_pack(Box::new(InternalPack)); m.download_vanilla(); m } @@ -168,6 +173,17 @@ impl Pack for DirPack { } } +struct InternalPack; + +impl Pack for InternalPack { + fn open(&self, name: &str) -> Option> { + match internal::get_file(name) { + Some(val) => Some(Box::new(io::Cursor::new(val))), + None => None, + } + } +} + struct ProgressRead { read: T, total: u64,