Commit Graph

52 Commits

Author SHA1 Message Date
ice_iix e8558b427a Fix clippy::type_complexity, refactor type alias
Use a type alias to refactor the submit_funcs type definition, as a
vector of boxed SubmitFuncs. Note this type alias isn't used in the
parameterized add_submit_func() function because it accepts a trait, not
a type - no `dyn` keyword in this context, but it is needed in the type
definition.
2022-10-30 15:27:28 -07:00
iceiix bbbe58a112
Update to Rust 1.59.0 (#718)
* Update to Rust 1.59.0

* Fix clippy::single_char_pattern in console, ui/logo

* Fix clippy::needless_late_init in load_block_entities
2022-08-28 08:27:39 -07:00
ice_iix eb420c4896 Fix clippy::manual_str_repeat 2021-08-01 06:19:48 -07:00
iceiix c505903aed
ui: fix backspace on Windows, closes #481 (#482) 2021-01-17 18:32:13 -08:00
iceiix 0c65cc1e0d
ui: keyboard input fixes (#432, #476) (#477)
* Fix Cmd-V typing v, suppress key_type on ctrl/logo, closes #432
Only send key_type() when modifiers are not pressed.

* Fix backspace repeat and inserting ⌂, closes #476
Handle backspace in key_type instead of key_press, so we get
auto-repeat for free, and can suppress typing the character.
2021-01-16 14:11:17 -08:00
iceiix 4dd25de709
ui: click TextBox to focus, fixes #415 (#475)
Previously text boxes could only be focused by cycling through
focus with the tab key, now you can click with the mouse as well.
2021-01-15 16:42:20 -08:00
iceiix 503a98d7a8
Use instant over std::time, for wasm compat (#449)
Replace std::time with the `instant` crate, which bridges to std::time on
native but on wasm calls performance.now() instead of panicking.

A step towards 🕸️ Web support #446

* logo: replace SystemTime/UNIX_EPOCH with Instant
2020-12-27 15:06:03 -08:00
iceiix 0471eb3a82 Use web-sys for web backend (#444)
A small step for #446 🕸️ Web support, use web-sys to interface to the web.
Previously, we would try to use glutin on the web, which is not supported;
now glutin is only used on native: fixes #171 could not find Context in platform_impl.

winit is still used on both, but the GL context is created with web-sys and glow
(on the web), and created with glutin and used with glow (on native). stdweb is
no longer used, being replaced by web-sys.

Substantial refactoring to allow reusing the code between web/native:

* settings: use VirtualKeyCode from winit, not reexported from glutin
* std_or_web: remove broken localstoragefs/stdweb, add File placeholder
* render: disable skin_thread on wasm since we don't have threads

* gl: use glow types in gl wrapper (integers in native, but Web*Key in web)
* gl: web-sys WebGlUniformLocation does not implement Copy trait, so glow::UniformLocation doesn't so gl::Uniform can't
* gl: refactor context initialization, pass glow::Context to gl::init for consistency between native/web
* gl: update to glow with panicking tex_image_2d_multisample web-sys wrapper

* glsl: use shader version in GLSL for WebGL 2 and OpenGL 3.2

* shaders: add explicit float/int type conversions, required for WebGL
* shaders: specify mediump precision, required for WebGL
* shaders: specify fragment shader output locations for WebGL

* main: refactor handle_window_event to take a winit window, not glutin context
* main: handle resize outside of handle_window_event since it updates the glutin window (the only event which does this)
* main: use winit events in handle_window_event not reexported glutin events
* main: refactor game loop handling into tick_all()
* main: create winit window for WebGL, and use winit_window from glutin
* main: restore console_error_panic_hook,  mistakingly removed in (#260)
* main: remove force setting env RUST_BACKTRACE=1, no longer can set env on web

* www: index.js: fix wasm import path
* www: npm update, npm audit fix
* www: update readme to link to status on #446 🕸️ Web support
2020-12-26 13:43:21 -08:00
ice_iix 113abefd80 Fix unnecessary use of match with if let (single_match) 2020-07-02 17:22:24 -07:00
ice_iix 8fb5491e15 Add missing default implementations (new_without_default) 2020-06-29 18:42:07 -07:00
ice_iix fe5cb47d40 Fix redundant field names in struct initialization (redundant_field_names) 2020-06-29 18:07:12 -07:00
ice_iix c3038f82ce Remove redundant imports (single_component_path_imports) 2020-06-29 18:01:02 -07:00
iceiix 518b6a07f8
Reformat all source with cargo fmt (#335) 2020-06-21 12:17:24 -07:00
iceiix a020ed6f2c
Update to glutin 0.22.0-alpha5, remove wasm_stub (#260)
Update from glutin 0.21.x fork to glutin 0.22.0-alpha5 and corresponding
compatible version of winit. This removes our custom temporary wasm_stub
branches, back to mainline glutin and winit, and is a step towards WebAssembly
compatibility, most importantly merging the game loop and event loops as
required by winit _which now supports wasm_. Not yet functional on the web
because other web dependencies have to be added, see #171 and #34, but native
functionality is preserved.

* Update for 0.22 glutin API changes:

* Move game logic into event loop, run() replacing poll_events()

* Specify fullscreen Borderless mode

* Pass generic parameter of Event through handle_window_event
* hidpi_factor() replaces get_hidpi_factor()
* with_inner_size() replaces with_dimensions()
* No longer need to unwrap() LogicalSize
* set_cursor_grab/visible() replaces grab/hide_cursor()

* Fix modifiers deprecated warnings by destructuring only event fields we use, ignoring the rest with '..'

* Remove unnecessary mutability from events_loop

* Listen for ModifiersChanged event, fixing deprecated modifiers field

* Change to stdweb for web backend, replacing web-sys

* Pin to glutin =0.22.0-alpha5 and winit =0.20.0-alpha6
2020-01-05 17:56:32 -08:00
ice_iix b307843d2b Change to PCG random number generator algorithm
See http://www.pcg-random.org/ for benefits of PCG over xorshift
Updates #236 #183
2020-01-05 10:01:44 -08:00
ice_iix c88631b124 Fix bare trait objects warning, add explicit `dyn` 2019-11-02 15:46:06 -07:00
ice_iix b1cae32eed Update to rand 0.6.5 and migrate off deprecated methods. Closes #81
* Import from rand_xorshift crate

* Use shuffle/choose from SliceRandom trait

See https://rust-random.github.io/book/update-0.6.html
2019-05-08 19:32:05 -07:00
iceiix 2f2f35848a
Add support for compiling WebAssembly wasm32-unknown-unknown target (#92)
Note this only is the first step in web support, although the project compiles, it doesn't run!

Merging now to avoid branch divergence, until dependencies can be updated for wasm support.

* Add instructions to build for wasm32-unknown-unknown with wasm-pack in www/

* Update to rust-clipboard fork to compile with emscripten

https://github.com/aweinstock314/rust-clipboard/pull/62

* Exclude reqwest dependency in wasm32

* Exclude compiling clipboard pasting on wasm32

* Exclude reqwest-using code from wasm32

* Install wasm target with rustup in Travis CI

* Update to collision 0.19.0

Fixes wasm incompatibility in deprecated rustc-serialize crate: https://github.com/rustgd/collision-rs/issues/106

error[E0046]: not all trait items implemented, missing: `encode`
    --> github.com-1ecc6299db9ec823/rustc-serialize-0.3.24/src/serialize.rs:1358:1

* Increase travis_wait time even further, try 120 minutes

* Set RUST_BACKTRACE=1 in main

* Remove unused unneeded bzip2 features in zip crate

To fix wasm32-unknown-unknown target compile error:
error[E0432]: unresolved imports `libc::c_int`, `libc::c_uint`, `libc::c_void`, `libc::c_char`
 --> src/github.com-1ecc6299db9ec823/bzip2-sys-0.1.7/lib.rs:5:12
  |
5 | use libc::{c_int, c_uint, c_void, c_char};
  |            ^^^^^  ^^^^^^  ^^^^^^  ^^^^^^ no `c_char` in the root
  |            |      |       |
  |            |      |       no `c_void` in the root
  |            |      no `c_uint` in the root
  |            no `c_int` in the root

* flate2 use Rust backend

* Add console_error_panic_hook module for wasm backtraces

* Build using wasm-pack, wasm-bindgen, run with wasm-app

* Update to miniz_oxide 0.2.1, remove patch for https://github.com/Frommi/miniz_oxide/issues/42

* Update to official clipboard crate since https://github.com/aweinstock314/rust-clipboard/pull/62 was merged, but git revision pending release

* Update to branch of glutin attempting to build for wasm

https://github.com/iceiix/glutin/pull/1

* Update winit dependency of glutin to git master

https://github.com/iceiix/winit/pull/2

* Update to glutin branch with working (compiles, doesn't run) wasm_stub

* Add app name in title on web page

* Add wasm to Travis-CI test matrix

* Update glutin to fix Windows EGL compilation on AppVeyor

97797352b5
2019-03-03 08:32:36 -08:00
ice_iix 3a359267dd Fix backspace not deleting in textfields, but shows ⌂. Closes https://github.com/iceiix/steven/issues/55 2018-12-04 15:51:20 -08:00
iceiix c099a68168
Use glutin to replace sdl2 (#35)
* Add glutin dependency

* Create a glutin window

* Use the glutin window, basics work

* Store DPI factor on game object, update on Resized

* Use physical size for rendering only. Fixes UI scaled too small

Fixes https://github.com/iceiix/steven/pull/35#issuecomment-442683373
See also https://github.com/iceiix/steven/issues/22

* Begin adding mouse input events

* Listen for DeviceEvents

* Call hover_at on mouse motion

* Listen for CursorMoved window event, hovering works

Glutin has separate WindowEvent::CursorMoved and
DeviceEvent::MouseMotion events, for absolute cursor and relative mouse
motion, respectively, instead of SDL's Event::MouseMotion for both.

* Use tuple pattern matching instead of nested if for MouseInput

* Implement left clicking

* Use grab_cursor() to capture the cursor

* Hide the cursor when grabbing

* Implement MouseWheel event

* Listen for keyboard input, escape key release

* Keyboard input: console toggling, glutin calls backquote 'grave'

* Implement fullscreen in glutin, updates https://github.com/iceiix/steven/pull/31

* Update settings for glutin VirtualKeyCode

* Keyboard controls (note: must clear conf.cfg to use correct bindings)

* Move DeviceEvent match arm up higher for clarity

* Remove SDL

* Pass physical dimensions to renderer tick so blit_framebuffer can use full size but the ui is still sized logically.

* Listen for DeviceEvent::Text

* Implement text input using ReceivedCharacter window event, works

https://github.com/iceiix/steven/pull/35#issuecomment-443247267

* Request specific version of OpenGL, version 3.2

* Request OpenGL 3.2 but fallback to OpenGL ES 2.0 if available (not tested)

* Set core profile and depth 24-bits, stencil 0-bits

* Allow changing vsync, but require restarting (until https://github.com/tomaka/glutin/issues/693)

* Clarify specific Rust version requirement

* Import glutin::* in handle_window_event() to avoid overly repetitive code

* Linux in VM fix: manually calculate delta in MouseMotion

For the third issue on https://github.com/iceiix/steven/pull/35#issuecomment-443084458
https://github.com/tomaka/glutin/issues/1084 MouseMotion event returns absolute instead of relative values, when running Linux in a VM

* Heuristic to detect absolute/relative MouseMotion from delta:(xrel, yrel); use a higher scaling factor

* Add clipboard pasting with clipboard crate instead of sdl2

https://github.com/iceiix/steven/pull/35#issuecomment-443307295
2018-11-30 11:35:35 -08:00
ice_iix 77cd4ecf35 Use field init shorthand, instead of x:x, just x,
https://rust-lang-nursery.github.io/edition-guide/rust-2018/data-types/field-init-shorthand.html

find src -name '*.rs' -exec perl -pe 's/\b(\w+): \1,/$1,/g' -i {} \;
2018-11-04 13:43:30 -08:00
ice_iix a40cd43a2e Update to use crate:: for current crate, for Rust 2018 edition
From `cargo fix --edition`, see https://rust-lang-nursery.github.io/edition-guide/print.html#the-crate-keyword-refers-to-the-current-crate
2018-11-04 12:06:00 -08:00
ice_iix d2b59fbd10 Update to rand 0.5.5 for https://github.com/iceiix/steven/issues/4
Useful guide: https://github.com/rust-random/rand/blob/master/UPDATING.md
2018-09-30 19:05:20 -07:00
ice_iix 47aeb83da2 Use std::time instead of time crate for logo text, progress on https://github.com/iceiix/steven/issues/3 2018-09-29 20:01:13 -07:00
satoshinm 2f950a749c Fix use of deprecated Rc:would_unwrap 2017-05-14 09:58:34 +01:00
llogiq 5e0c041a71 Fixed another batch of clippy warnings
Those are mostly readability-related. Also did a cargo update.
2016-09-15 15:15:52 +01:00
Kyle Wood 8d95965d40 Enable paste in textboxes 2016-04-26 00:50:16 +01:00
Thinkofname a7caa50b6f Rewrite the UI system (Closes #12) 2016-04-24 12:29:25 +01:00
Thinkofname 380a844272 Implement a background for the option menus 2016-04-21 11:00:05 +01:00
Thinkofname 6f708d35f2 Remove unused 'use' 2016-04-03 00:44:45 +01:00
Thinkofname b975a01f30 Remove some unsafe code from the ui system 2016-04-02 20:08:21 +01:00
Thinkofname 357c695a3a Fix some lock ordering issues 2016-03-29 20:54:08 +01:00
Thinkofname c70f9548c6 Follow some of clippy's suggestions 2016-03-26 14:24:26 +00:00
Thinkofname 9f04c09a8f Switch from glutin to sdl2 2016-03-25 13:15:35 +00:00
Thinkofname 1fc161c53c Allow connecting to servers 2016-03-21 10:55:31 +00:00
Thinkofname ae2703418b Fully implement the login screen (Closes #6) 2016-03-20 23:43:31 +00:00
Thinkofname b418625a48 Work on login screen, added ui buttons and textboxes (plus tab fixes) 2016-03-20 20:17:21 +00:00
Thinkofdeath 70b6738d87 Update copyright 2016-03-16 18:25:35 +00:00
Thinkofdeath 3704b9eeb8 Reformat using rustfmt 2015-10-07 19:36:59 +01:00
Thinkofdeath 12a88b07b9 Base console implementation 2015-09-29 22:33:24 +01:00
Thinkofdeath 302af6393d Tidy up 2015-09-29 20:09:36 +01:00
Thinkofdeath bdfc002e99 Clean up 2015-09-28 23:37:14 +01:00
Thinkofdeath db1c687c53 Split up the ui system using include!
Not the nicest system but it works
2015-09-27 22:18:49 +01:00
Thinkofdeath 8a2c24796c Minor changes 2015-09-27 19:38:58 +01:00
Thinkofdeath fcacd91e3a Clean up 2015-09-25 15:20:55 +01:00
Thinkofdeath 0d3ff98ad5 Implement the refresh button 2015-09-25 14:48:35 +01:00
Thinkofdeath 3bcfc6aa4c Kinda functional server list 2015-09-25 14:00:49 +01:00
Thinkofdeath 93edfa3828 Base of server list 2015-09-23 20:16:25 +01:00
Thinkofdeath 876e88ec95 Basic logo impl 2015-09-21 21:11:30 +01:00
Thinkofdeath 64d0768fb4 Basic logo work 2015-09-21 13:08:06 +01:00
Thinkofdeath 1ab2683a53 Base of ui system 2015-09-18 22:02:08 +01:00
Thinkofdeath 72e27968eb Add license 2015-09-17 16:23:07 +01:00