Add internal resources
This commit is contained in:
parent
1ab2683a53
commit
81b62d9ce4
|
@ -2,6 +2,7 @@
|
||||||
name = "steven"
|
name = "steven"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = [ "Thinkofdeath <thinkofdeath@spigotmc.org>" ]
|
authors = [ "Thinkofdeath <thinkofdeath@spigotmc.org>" ]
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
|
|
|
@ -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<String>, 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"normal": { "model": "missing_block" }
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
|
@ -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
|
|
@ -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" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 126 KiB |
Binary file not shown.
After Width: | Height: | Size: 288 B |
|
@ -63,6 +63,15 @@ fn main() {
|
||||||
let mut last_frame = time::now();
|
let mut last_frame = time::now();
|
||||||
let frame_time = (time::Duration::seconds(1).num_nanoseconds().unwrap() as f64) / 60.0;
|
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() {
|
while !window.should_close() {
|
||||||
{ resource_manager.write().unwrap().tick(); }
|
{ resource_manager.write().unwrap().tick(); }
|
||||||
let now = time::now();
|
let now = time::now();
|
||||||
|
|
|
@ -240,8 +240,6 @@ impl TextureManager {
|
||||||
self.textures.get(name).map(|v| v.clone())
|
self.textures.get(name).map(|v| v.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Animated textures
|
|
||||||
|
|
||||||
fn load_texture(&mut self, name: &str) {
|
fn load_texture(&mut self, name: &str) {
|
||||||
let (plugin, name) = if let Some(pos) = name.find(':') {
|
let (plugin, name) = if let Some(pos) = name.find(':') {
|
||||||
(&name[..pos], &name[pos+1..])
|
(&name[..pos], &name[pos+1..])
|
||||||
|
@ -271,7 +269,7 @@ impl TextureManager {
|
||||||
return;
|
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<u8>) -> Option<AnimatedTexture> {
|
fn load_animation(&mut self, plugin: &str, name: &str, img: &image::DynamicImage, data: Vec<u8>) -> Option<AnimatedTexture> {
|
||||||
|
@ -366,10 +364,18 @@ impl TextureManager {
|
||||||
(index, rect.unwrap())
|
(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 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 {
|
let t = Texture {
|
||||||
name: name.to_owned(),
|
name: full_name.to_owned(),
|
||||||
version: self.version,
|
version: self.version,
|
||||||
atlas: missing.atlas,
|
atlas: missing.atlas,
|
||||||
x: missing.x,
|
x: missing.x,
|
||||||
|
@ -382,7 +388,7 @@ impl TextureManager {
|
||||||
rel_height: 1.0,
|
rel_height: 1.0,
|
||||||
is_rel: false,
|
is_rel: false,
|
||||||
};
|
};
|
||||||
self.textures.insert(name.to_owned(), t.clone());
|
self.textures.insert(full_name.to_owned(), t.clone());
|
||||||
t
|
t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,10 @@ use std::io;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
|
|
||||||
|
mod internal {
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/resources.rs"));
|
||||||
|
}
|
||||||
|
|
||||||
const RESOURCES_VERSION: &'static str = "15w37a";
|
const RESOURCES_VERSION: &'static str = "15w37a";
|
||||||
|
|
||||||
pub trait Pack {
|
pub trait Pack {
|
||||||
|
@ -41,6 +45,7 @@ impl Manager {
|
||||||
version: 0,
|
version: 0,
|
||||||
vanilla_chan: None,
|
vanilla_chan: None,
|
||||||
};
|
};
|
||||||
|
m.add_pack(Box::new(InternalPack));
|
||||||
m.download_vanilla();
|
m.download_vanilla();
|
||||||
m
|
m
|
||||||
}
|
}
|
||||||
|
@ -168,6 +173,17 @@ impl Pack for DirPack {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct InternalPack;
|
||||||
|
|
||||||
|
impl Pack for InternalPack {
|
||||||
|
fn open(&self, name: &str) -> Option<Box<io::Read>> {
|
||||||
|
match internal::get_file(name) {
|
||||||
|
Some(val) => Some(Box::new(io::Cursor::new(val))),
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct ProgressRead<T> {
|
struct ProgressRead<T> {
|
||||||
read: T,
|
read: T,
|
||||||
total: u64,
|
total: u64,
|
||||||
|
|
Loading…
Reference in New Issue