diff --git a/.gitignore b/.gitignore index 1750ac1..73724a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,15 @@ .DS_Store *~ *# +*.a *.o *.so *.swp *.dylib *.dSYM *.dll +*.la +*.lib *.rlib *.dummy *.exe diff --git a/Cargo.lock b/Cargo.lock index 59161ab..96ff0c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,6 +33,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" +[[package]] +name = "anyhow" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" + [[package]] name = "autocfg" version = "1.1.0" @@ -332,7 +338,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 1.0.109", ] [[package]] @@ -343,7 +349,7 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -354,7 +360,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -612,6 +618,12 @@ dependencies = [ "xml-rs", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "glutin" version = "0.26.0" @@ -693,6 +705,15 @@ dependencies = [ "crunchy", ] +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "hermit-abi" version = "0.2.6" @@ -727,6 +748,30 @@ dependencies = [ "tiff", ] +[[package]] +name = "include_dir" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24b56e147e6187d61e9d0f039f10e070d0c0a887e24fe0bb9ca3f29bfde62cab" +dependencies = [ + "glob", + "include_dir_impl", + "proc-macro-hack", +] + +[[package]] +name = "include_dir_impl" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a0c890c85da4bab7bce4204c707396bbd3c6c8a681716a51c8814cfc2b682df" +dependencies = [ + "anyhow", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "instant" version = "0.1.12" @@ -751,6 +796,12 @@ dependencies = [ "libc", ] +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + [[package]] name = "jni-sys" version = "0.3.0" @@ -775,6 +826,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "json" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -996,7 +1053,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1109,7 +1166,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1176,6 +1233,50 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +[[package]] +name = "phf" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" +dependencies = [ + "phf_macros", + "phf_shared", + "proc-macro-hack", +] + +[[package]] +name = "phf_generator" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +dependencies = [ + "phf_shared", + "rand 0.8.5", +] + +[[package]] +name = "phf_macros" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.0.12" @@ -1193,7 +1294,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1391,6 +1492,12 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "proc-macro-crate" version = "0.1.5" @@ -1400,6 +1507,12 @@ dependencies = [ "toml", ] +[[package]] +name = "proc-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" + [[package]] name = "proc-macro2" version = "1.0.52" @@ -1441,6 +1554,27 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + [[package]] name = "rand_core" version = "0.3.1" @@ -1456,6 +1590,15 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "raw-window-handle" version = "0.3.4" @@ -1534,21 +1677,19 @@ dependencies = [ [[package]] name = "rust-2048" -version = "0.0.0" +version = "0.0.1" dependencies = [ + "json", "piston2d-opengl_graphics", "piston_window", "pistoncore-sdl2_window", "rand 0.3.23", - "rustc-serialize", + "serde", + "serde-generate", + "serde_derive", + "serde_json", ] -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" - [[package]] name = "rusttype" version = "0.9.3" @@ -1559,6 +1700,12 @@ dependencies = [ "owned_ttf_parser", ] +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + [[package]] name = "same-file" version = "1.0.6" @@ -1611,19 +1758,58 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.155" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8" +checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-generate" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5225c69f4a85eef7f9d9d1143c4893fadcb8c1e9fd0e1c88dc2db2519275b584" +dependencies = [ + "heck", + "include_dir", + "phf", + "serde", + "serde-reflection", + "textwrap", +] + +[[package]] +name = "serde-reflection" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05a5f801ac62a51a49d378fdb3884480041b99aced450b28990673e8ff99895" +dependencies = [ + "once_cell", + "serde", + "thiserror", +] [[package]] name = "serde_derive" -version = "1.0.155" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" +checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.8", +] + +[[package]] +name = "serde_json" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +dependencies = [ + "itoa", + "ryu", + "serde", ] [[package]] @@ -1651,6 +1837,12 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + [[package]] name = "slab" version = "0.4.8" @@ -1666,6 +1858,12 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +[[package]] +name = "smawk" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" + [[package]] name = "smithay-client-toolkit" version = "0.12.3" @@ -1721,6 +1919,27 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc02725fd69ab9f26eab07fad303e2497fad6fb9eba4f96c4d1687bdf704ad9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "textwrap" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd05616119e612a8041ef58f2b578906cc2531a6069047ae092cfb86a325d835" +dependencies = [ + "smawk", + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.39" @@ -1738,7 +1957,7 @@ checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1773,6 +1992,18 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + [[package]] name = "vecmath" version = "1.0.0" @@ -1826,7 +2057,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -1848,7 +2079,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index 4d5ca5e..0bfc319 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "rust-2048" -version = "0.0.0" +version = "0.0.1" +build = "build.rs" authors = ["coeuvre "] [[bin]] @@ -10,8 +11,12 @@ name = "rust-2048" path = "src/main.rs" [dependencies] -rustc-serialize = "0.3" +serde = { version = "1.0", features = ["derive"]} rand = "0.3.7" piston_window = "0.127.0" pistoncore-sdl2_window = "0.68.0" piston2d-opengl_graphics = "0.82.0" +serde-generate = "0.25.0" +json = "0.12.4" +serde_json = "1.0.94" +serde_derive = "1.0.158" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..c8458dd --- /dev/null +++ b/build.rs @@ -0,0 +1,45 @@ +use std::env; +use std::path::PathBuf; + +fn main() { + let target = env::var("TARGET").unwrap(); + if target.contains("pc-windows") { + let manifest_dir = + PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + let mut lib_dir = manifest_dir.clone(); + let mut dll_dir = manifest_dir.clone(); + if target.contains("msvc") { + lib_dir.push("msvc"); + dll_dir.push("msvc"); + } else { + lib_dir.push("gnu-mingw"); + dll_dir.push("gnu-mingw"); + } + lib_dir.push("lib"); + dll_dir.push("dll"); + if target.contains("x86_64") { + lib_dir.push("64"); + dll_dir.push("64"); + } else { + lib_dir.push("32"); + dll_dir.push("32"); + } + println!("cargo:rustc-link-search=all={}", + lib_dir.display()); + for entry in std::fs::read_dir(dll_dir).expect("Can't + read DLL dir") { + let entry_path = entry.expect("Invalid fs entry").path(); + let file_name_result = entry_path.file_name(); + let mut new_file_path = manifest_dir.clone(); + if let Some(file_name) = file_name_result { + let file_name = file_name.to_str().unwrap(); + if file_name.ends_with(".dll") { + new_file_path.push(file_name); + std::fs::copy(&entry_path, + new_file_path.as_path()).expect("Can't copy + from DLL dir"); + } + } + } + } +} \ No newline at end of file diff --git a/gnu-mingw/lib/32/libSDL2.a b/gnu-mingw/lib/32/libSDL2.a new file mode 100644 index 0000000..c65749e Binary files /dev/null and b/gnu-mingw/lib/32/libSDL2.a differ diff --git a/gnu-mingw/lib/32/libSDL2.dll.a b/gnu-mingw/lib/32/libSDL2.dll.a new file mode 100644 index 0000000..4277d1e Binary files /dev/null and b/gnu-mingw/lib/32/libSDL2.dll.a differ diff --git a/gnu-mingw/lib/32/libSDL2.la b/gnu-mingw/lib/32/libSDL2.la new file mode 100644 index 0000000..85e978d --- /dev/null +++ b/gnu-mingw/lib/32/libSDL2.la @@ -0,0 +1,41 @@ +# libSDL2.la - a libtool library file +# Generated by libtool (GNU libtool) 2.4.6 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='../bin/SDL2.dll' + +# Names of this library. +library_names='libSDL2.dll.a' + +# The name of the static archive. +old_library='libSDL2.a' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags='' + +# Libraries that this one depends upon. +dependency_libs=' -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid' + +# Names of additional weak libraries provided by this library +weak_library_names='' + +# Version information for libSDL2. +current=2600 +age=2600 +revision=4 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/Users/valve/release/SDL2/SDL2-2.26.4/i686-w64-mingw32/lib' diff --git a/gnu-mingw/lib/32/libSDL2_test.a b/gnu-mingw/lib/32/libSDL2_test.a new file mode 100644 index 0000000..78593c6 Binary files /dev/null and b/gnu-mingw/lib/32/libSDL2_test.a differ diff --git a/gnu-mingw/lib/32/libSDL2_test.la b/gnu-mingw/lib/32/libSDL2_test.la new file mode 100644 index 0000000..08392e7 --- /dev/null +++ b/gnu-mingw/lib/32/libSDL2_test.la @@ -0,0 +1,41 @@ +# libSDL2_test.la - a libtool library file +# Generated by libtool (GNU libtool) 2.4.6 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='' + +# Names of this library. +library_names='' + +# The name of the static archive. +old_library='libSDL2_test.a' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags='' + +# Libraries that this one depends upon. +dependency_libs='' + +# Names of additional weak libraries provided by this library +weak_library_names='' + +# Version information for libSDL2_test. +current=0 +age=0 +revision=0 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/Users/valve/release/SDL2/SDL2-2.26.4/i686-w64-mingw32/lib' diff --git a/gnu-mingw/lib/32/libSDL2main.a b/gnu-mingw/lib/32/libSDL2main.a new file mode 100644 index 0000000..bfcd9d6 Binary files /dev/null and b/gnu-mingw/lib/32/libSDL2main.a differ diff --git a/gnu-mingw/lib/32/libSDL2main.la b/gnu-mingw/lib/32/libSDL2main.la new file mode 100644 index 0000000..260751f --- /dev/null +++ b/gnu-mingw/lib/32/libSDL2main.la @@ -0,0 +1,41 @@ +# libSDL2main.la - a libtool library file +# Generated by libtool (GNU libtool) 2.4.6 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='' + +# Names of this library. +library_names='' + +# The name of the static archive. +old_library='libSDL2main.a' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags='' + +# Libraries that this one depends upon. +dependency_libs='' + +# Names of additional weak libraries provided by this library +weak_library_names='' + +# Version information for libSDL2main. +current=0 +age=0 +revision=0 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/Users/valve/release/SDL2/SDL2-2.26.4/i686-w64-mingw32/lib' diff --git a/gnu-mingw/lib/64/libSDL2.a b/gnu-mingw/lib/64/libSDL2.a new file mode 100644 index 0000000..51b9e72 Binary files /dev/null and b/gnu-mingw/lib/64/libSDL2.a differ diff --git a/gnu-mingw/lib/64/libSDL2.dll.a b/gnu-mingw/lib/64/libSDL2.dll.a new file mode 100644 index 0000000..bc67c8e Binary files /dev/null and b/gnu-mingw/lib/64/libSDL2.dll.a differ diff --git a/gnu-mingw/lib/64/libSDL2.la b/gnu-mingw/lib/64/libSDL2.la new file mode 100644 index 0000000..644f6cb --- /dev/null +++ b/gnu-mingw/lib/64/libSDL2.la @@ -0,0 +1,41 @@ +# libSDL2.la - a libtool library file +# Generated by libtool (GNU libtool) 2.4.6 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='../bin/SDL2.dll' + +# Names of this library. +library_names='libSDL2.dll.a' + +# The name of the static archive. +old_library='libSDL2.a' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags='' + +# Libraries that this one depends upon. +dependency_libs=' -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid' + +# Names of additional weak libraries provided by this library +weak_library_names='' + +# Version information for libSDL2. +current=2600 +age=2600 +revision=4 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/Users/valve/release/SDL2/SDL2-2.26.4/x86_64-w64-mingw32/lib' diff --git a/gnu-mingw/lib/64/libSDL2_test.a b/gnu-mingw/lib/64/libSDL2_test.a new file mode 100644 index 0000000..8b6be21 Binary files /dev/null and b/gnu-mingw/lib/64/libSDL2_test.a differ diff --git a/gnu-mingw/lib/64/libSDL2_test.la b/gnu-mingw/lib/64/libSDL2_test.la new file mode 100644 index 0000000..d5d99ec --- /dev/null +++ b/gnu-mingw/lib/64/libSDL2_test.la @@ -0,0 +1,41 @@ +# libSDL2_test.la - a libtool library file +# Generated by libtool (GNU libtool) 2.4.6 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='' + +# Names of this library. +library_names='' + +# The name of the static archive. +old_library='libSDL2_test.a' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags='' + +# Libraries that this one depends upon. +dependency_libs='' + +# Names of additional weak libraries provided by this library +weak_library_names='' + +# Version information for libSDL2_test. +current=0 +age=0 +revision=0 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/Users/valve/release/SDL2/SDL2-2.26.4/x86_64-w64-mingw32/lib' diff --git a/gnu-mingw/lib/64/libSDL2main.a b/gnu-mingw/lib/64/libSDL2main.a new file mode 100644 index 0000000..df93788 Binary files /dev/null and b/gnu-mingw/lib/64/libSDL2main.a differ diff --git a/gnu-mingw/lib/64/libSDL2main.la b/gnu-mingw/lib/64/libSDL2main.la new file mode 100644 index 0000000..92d726b --- /dev/null +++ b/gnu-mingw/lib/64/libSDL2main.la @@ -0,0 +1,41 @@ +# libSDL2main.la - a libtool library file +# Generated by libtool (GNU libtool) 2.4.6 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='' + +# Names of this library. +library_names='' + +# The name of the static archive. +old_library='libSDL2main.a' + +# Linker flags that cannot go in dependency_libs. +inherited_linker_flags='' + +# Libraries that this one depends upon. +dependency_libs='' + +# Names of additional weak libraries provided by this library +weak_library_names='' + +# Version information for libSDL2main. +current=0 +age=0 +revision=0 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/Users/valve/release/SDL2/SDL2-2.26.4/x86_64-w64-mingw32/lib' diff --git a/msvc/lib/32/SDL2.lib b/msvc/lib/32/SDL2.lib new file mode 100644 index 0000000..73c41c6 Binary files /dev/null and b/msvc/lib/32/SDL2.lib differ diff --git a/msvc/lib/64/SDL2.lib b/msvc/lib/64/SDL2.lib new file mode 100644 index 0000000..f966c7c Binary files /dev/null and b/msvc/lib/64/SDL2.lib differ diff --git a/src/app.rs b/src/app.rs index 3bcc472..e9d185c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,5 +1,4 @@ use std::path::{ Path, PathBuf }; - use piston_window::*; use opengl_graphics::GlGraphics; use opengl_graphics::Texture as GlTexture; diff --git a/src/board.rs b/src/board.rs index f9d2033..d5cc58d 100644 --- a/src/board.rs +++ b/src/board.rs @@ -93,7 +93,6 @@ impl<'a> Board<'a> { } } - // better but unstable: tiles.append(&mut tiles_need_added); while let Some(tile_to_add) = tiles_need_added.pop() { tiles.push(tile_to_add); } diff --git a/src/main.rs b/src/main.rs index d3ae7d8..bd7ffb4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -extern crate rustc_serialize; +extern crate serde; extern crate rand; extern crate piston_window; extern crate opengl_graphics; @@ -20,7 +20,6 @@ fn main() { let (width, height) = (settings.window_size[0], settings.window_size[1]); - // according to piston WindowSettings documentation, OpenGL::V3_2 is the default version let mut window: PistonWindow = WindowSettings::new("Rust-2048", [width, height]) .exit_on_esc(true) @@ -39,8 +38,6 @@ fn main() { } if let Some(ref args) = e.update_args() { - // TODO: only update if necessary - // println!("update"); app.update(args); } diff --git a/src/settings.rs b/src/settings.rs index 9218989..85856b0 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,9 +1,8 @@ - +use serde::{Deserialize, Serialize}; use std::env::current_exe; -use std::io::{BufWriter, BufReader, Write}; -use std::fs::{File}; +use std::fs::File; +use std::io::{BufReader, BufWriter, Write}; use std::path::Path; -use rustc_serialize::{ json, Encodable, Decodable }; static SETTING_FILENAME: &'static str = "settings.json"; @@ -125,7 +124,7 @@ impl Settings { } } -#[derive(RustcEncodable, RustcDecodable)] +#[derive(Serialize, Deserialize, Debug)] struct SettingsInJson { asset_folder: String, @@ -219,16 +218,6 @@ impl SettingsInJson { exe_path.pop(); let path = exe_path.join(Path::new(SETTING_FILENAME)); - // FIXME: use this if possible (.exists() is unstable in Rust 1.0.0) - /* if !path.as_path().exists() || !path.is_file() { - println!("Configuration file not found. Generating a default one."); - let default = SettingsInJson::default_settings(); - default.save(); - return default; - } - let file = File::open(&path).unwrap(); - let mut reader = BufReader::new(file); - */ let file = File::open(&path); match file { @@ -242,11 +231,11 @@ impl SettingsInJson { } let mut reader = BufReader::new(file.unwrap()); - // End FIXME - let mut decoder = json::Decoder::new(json::Json::from_reader(&mut reader).unwrap()); - Decodable::decode(&mut decoder).unwrap() + let decoder = serde_json::from_reader(&mut reader).unwrap(); + decoder } + pub fn save(&self) { let exe_path = current_exe(); @@ -260,7 +249,7 @@ impl SettingsInJson { let file = File::create(&path.with_file_name(SETTING_FILENAME)).unwrap(); let mut writer = BufWriter::new(file); - match json::encode(self) { + match serde_json::to_string(self) { Ok(encoded) => { if let Err(e) = writer.write(encoded.as_bytes()) { println!("WARNING: Failed to save settings: {}", e);