Compare commits

..

No commits in common. "2803ac03dbe7366836f175112a119cad7a0942bd" and "bd327c86f33eca1c4e30fcc632ed0f260086ccee" have entirely different histories.

4 changed files with 9 additions and 104 deletions

View file

@ -1,6 +1,5 @@
[workspace] [workspace]
members = ["kubi", "kubi-server", "kubi-shared", "kubi-logging", "kubi-pool"] members = ["kubi", "kubi-server", "kubi-shared", "kubi-logging", "kubi-pool"]
default-members = ["kubi"]
resolver = "2" resolver = "2"
[profile.release-with-debug] [profile.release-with-debug]

View file

@ -55,32 +55,31 @@ please note that android support is highly experimental!\
gamepad, mouse input is currently borked, and proper touch controls are not available.\ gamepad, mouse input is currently borked, and proper touch controls are not available.\
srgb and blending are broken too, which leads to many rendering issues srgb and blending are broken too, which leads to many rendering issues
prerequisites: Android SDK, NDK, command line tools, platform-tools, latest JDK\ prerequisites: Android SDK, command line tools, NDK, platform-tools, latest JDK\
(make sure that your `PATH`, `ANDROID_HOME` and `ANDROID_NDK_ROOT` variables are configured properly) (make sure that your $PATH variable is configured properly)
**Setup:** **Setup:**
latest unpublished (git) version of cargo-apk is required
```bash ```bash
cargo install --git https://github.com/rust-mobile/cargo-apk cargo-apk cargo install cargo-apk
rustup target add aarch64-linux-android cargo target add aarch64-linux-android
``` ```
**Build:** **Build:**
`--no-default-features` is required for keyboard input!\ `--no-default-features` is required for keyboard input!\
(`prefer-raw-events` feature *must* be disabled on android)\ (`prefer-raw-events` feature *must* be disabled on android)
Mouse input is not implemented, touch only! Mouse input is not implemented, touch only!
```bash ```bash
cargo apk build -p kubi --lib --no-default-features cargo apk build -p kubi --no-default-features
``` ```
**Run on device (using adb):** **Run:**
```bash ```bash
cargo apk run -p kubi --lib --no-default-features cargo apk run -p kubi --no-default-features
``` ```
<h2>touch controls</h2> <h2>touch controls</h2>

View file

@ -1,92 +0,0 @@
use glam::{Vec2, vec2, Vec4};
use shipyard::Unique;
pub enum UiSize {
Auto,
Percentage(f32),
Pixels(f32),
}
struct LayoutInfo {
position: Vec2,
max_preferred_size: Vec2,
}
struct Response {
size: Vec2
}
pub trait UiElement {
fn process(&self, layout: &LayoutInfo, draw: &mut Vec<UiDrawCall>) -> Response;
fn measure(&self, layout: &LayoutInfo) -> Option<Response> { None }
}
pub enum LayoutDirection {
Horizontal,
Vertical
}
pub struct LayoutBox {
pub direction: LayoutDirection,
pub gap: f32,
pub elements: Vec<Box<dyn UiElement>>,
}
struct ProgressBar {
size: (UiSize, UiSize),
value: f32,
color_foreground: Vec4,
color_background: Vec4,
}
const BAR_HEIGHT: f32 = 20.0;
impl UiElement for ProgressBar {
fn measure(&self, layout: &LayoutInfo) -> Option<Response> {
let width = match self.size.0 {
UiSize::Auto => layout.max_preferred_size.x,
UiSize::Percentage(p) => layout.max_preferred_size.x * p,
UiSize::Pixels(p) => p,
};
let height = match self.size.1 {
UiSize::Auto => BAR_HEIGHT,
UiSize::Percentage(p) => layout.max_preferred_size.y * p,
UiSize::Pixels(p) => p,
};
let size = Vec2::new(width, height);
Some(Response { size })
}
fn process(&self, layout: &LayoutInfo, draw: &mut Vec<UiDrawCall>) -> Response {
let measure = self.measure(layout).unwrap();
draw.push(UiDrawCall::Rectangle {
position: layout.position,
size: measure.size,
color: self.color_background
});
draw.push(UiDrawCall::Rectangle {
position: layout.position,
size: measure.size * vec2(self.value, 1.0),
color: self.color_foreground
});
measure
}
}
enum UiDrawCall {
Rectangle {
///Position in pixels
position: Vec2,
///Size in pixels
size: Vec2,
///Color (RGBA)
color: Vec4,
}
}
#[derive(Unique)]
struct UiDrawCalls {
pub calls: Vec<UiDrawCall>,
}

View file

@ -30,7 +30,6 @@ pub(crate) mod cursor_lock;
pub(crate) mod control_flow; pub(crate) mod control_flow;
pub(crate) mod state; pub(crate) mod state;
pub(crate) mod gui; pub(crate) mod gui;
pub(crate) mod gui_v2;
pub(crate) mod networking; pub(crate) mod networking;
pub(crate) mod init; pub(crate) mod init;
pub(crate) mod color; pub(crate) mod color;