Skip to content

Commit b8dc259

Browse files
committed
wip: initial about screen and layer picker
1 parent f01fba1 commit b8dc259

10 files changed

Lines changed: 929 additions & 476 deletions

File tree

Cargo.lock

Lines changed: 430 additions & 368 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sandpolis-mobile/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ crate-type = ["lib", "cdylib"]
1616
bevy = { workspace = true }
1717
rustls = { workspace = true }
1818
tokio = { workspace = true }
19-
sandpolis = { path = "../sandpolis", version = "8.0.0", features = [
19+
sandpolis = { path = "../sandpolis", version = "8.0.0", default-features = false, features = [
2020
"client",
2121
"client-gui",
2222
"agent",
23+
"layer-desktop",
24+
"layer-inventory",
25+
"layer-power",
26+
"layer-shell",
2327
] }
2428
sandpolis-database = { path = "../sandpolis-database", version = "0.0.1" }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

sandpolis-mobile/android/local.properties

Lines changed: 0 additions & 8 deletions
This file was deleted.

sandpolis-mobile/shell.nix

Lines changed: 81 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,94 @@
1-
{ pkgs ? import <nixpkgs> { config.allowUnfree = true; } }:
1+
{ pkgs ? import <nixpkgs> {
2+
config.allowUnfree = true;
3+
overlays = [
4+
(import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
5+
];
6+
}
7+
}:
28

39
with pkgs;
410

511
let
12+
# Android SDK with minimal components needed for building APKs
613
android-nixpkgs = callPackage <android-nixpkgs> { channel = "stable"; };
714

815
android-sdk = android-nixpkgs.sdk (sdkPkgs:
916
with sdkPkgs; [
10-
cmdline-tools-latest
11-
build-tools-34-0-0
12-
platform-tools
13-
platforms-android-34
14-
emulator
15-
cmake-3-22-1
16-
ndk-26-1-10909125
17+
cmdline-tools-latest # SDK manager
18+
build-tools-34-0-0 # Required by gradle
19+
platforms-android-34 # API 34 for compilation
20+
ndk-26-1-10909125 # Native compilation for Rust
1721
]);
1822

23+
# Rust toolchain with Android targets
24+
rust-android = rust-bin.stable.latest.default.override {
25+
extensions = [ "rust-src" ];
26+
targets = [ "aarch64-linux-android" ];
27+
};
28+
1929
in mkShell {
20-
buildInputs = [ android-studio android-sdk jdk ];
21-
nativeBuildInputs =
22-
[ cargo cargo-ndk rustc rust-analyzer rustfmt clippy rustup ];
30+
buildInputs = [
31+
android-sdk
32+
jdk17 # Required by gradle
33+
gradle # APK assembly
34+
cargo-ndk # Builds Rust for Android targets
35+
rust-android # Rust with Android targets
36+
cmake # Required by aws-lc-sys for crypto
37+
pkg-config # Required for library detection
38+
zlib # System zlib to avoid NDK build issues
39+
clang # Host C compiler for build scripts
40+
llvmPackages.bintools # Host linker
41+
];
42+
43+
# Android SDK/NDK environment variables
44+
ANDROID_HOME = "${android-sdk}/share/android-sdk";
45+
ANDROID_SDK_ROOT = "${android-sdk}/share/android-sdk";
46+
ANDROID_NDK_ROOT = "${android-sdk}/share/android-sdk/ndk/26.1.10909125";
47+
NDK_HOME = "${android-sdk}/share/android-sdk/ndk/26.1.10909125";
48+
49+
# Configure cargo-ndk to use system zlib instead of building it
50+
ZLIB_SYS_STATIC = "0";
51+
PKG_CONFIG_ALLOW_CROSS = "1";
52+
53+
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${android-sdk}/share/android-sdk/build-tools/34.0.0/aapt2";
2354

24-
GRADLE_OPTS =
25-
"-Dorg.gradle.project.android.aapt2FromMavenOverride=${android-sdk}/share/android-sdk/build-tools/34.0.0/aapt2";
55+
shellHook = ''
56+
# Generate local.properties with Nix store paths
57+
cat > android/local.properties <<EOF
58+
sdk.dir=$ANDROID_SDK_ROOT
59+
ndk.dir=$ANDROID_NDK_ROOT
60+
EOF
61+
62+
# Set host compilers for build scripts (before cargo-ndk overrides them)
63+
export CC_x86_64_unknown_linux_gnu=${pkgs.clang}/bin/clang
64+
export CXX_x86_64_unknown_linux_gnu=${pkgs.clang}/bin/clang++
65+
export AR_x86_64_unknown_linux_gnu=${pkgs.llvmPackages.bintools}/bin/ar
66+
67+
# Welcome message with build instructions
68+
echo "Android build environment ready"
69+
echo "Rust version: $(rustc --version)"
70+
echo ""
71+
echo "To build APK:"
72+
echo " # Debug build:"
73+
echo " cargo ndk -t arm64-v8a -o android/app/src/main/jniLibs build"
74+
echo " cd android && ./gradlew assembleDebug"
75+
echo ""
76+
echo " # Release build:"
77+
echo " cargo ndk -t arm64-v8a -o android/app/src/main/jniLibs build --release"
78+
echo " cd android && ./gradlew assembleRelease"
79+
echo ""
80+
echo "APK output: android/app/build/outputs/apk/"
81+
'';
2682
}
83+
84+
# Usage:
85+
# nix-shell Enter development environment
86+
#
87+
# Build APK:
88+
# Debug: cargo ndk -t arm64-v8a -o android/app/src/main/jniLibs build && cd android && ./gradlew assembleDebug
89+
# Release: cargo ndk -t arm64-v8a -o android/app/src/main/jniLibs build --release && cd android && ./gradlew assembleRelease
90+
#
91+
# To add debugging tools, include in buildInputs:
92+
# - platform-tools (for adb, fastboot)
93+
# - emulator (for Android Virtual Device)
94+
# - android-studio (for GUI development)

sandpolis/src/client/gui/edges.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub fn render_edges(
5959
// Color based on layer
6060
let color = match edge.layer {
6161
Layer::Network => Color::srgb(0.3, 0.8, 1.0), // Cyan
62+
#[cfg(feature = "layer-filesystem")]
6263
Layer::Filesystem => Color::srgb(0.3, 1.0, 0.3), // Green
6364
Layer::Desktop => Color::srgb(1.0, 0.5, 0.3), // Orange
6465
_ => Color::srgb(0.6, 0.6, 0.6), // Gray
@@ -101,6 +102,7 @@ pub fn update_edges_for_layer(
101102
}
102103
}
103104
}
105+
#[cfg(feature = "layer-filesystem")]
104106
Layer::Filesystem => {
105107
// TODO: Query filesystem connections (file transfer paths)
106108
// For now, no edges

sandpolis/src/client/gui/input.rs

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -468,56 +468,3 @@ pub fn handle_keymap(
468468
}
469469
});
470470
}
471-
472-
/// Switch to another layer from keypress
473-
pub fn handle_layer_change(
474-
mut contexts: EguiContexts,
475-
keyboard_input: Res<ButtonInput<KeyCode>>,
476-
mut current_layer: ResMut<CurrentLayer>,
477-
time: Res<Time>,
478-
mut timer: ResMut<LayerChangeTimer>,
479-
mut windows: Query<&mut Window>,
480-
) {
481-
// Don't handle layer change if egui wants keyboard input
482-
let Ok(ctx) = contexts.ctx_mut() else {
483-
return;
484-
};
485-
if ctx.wants_keyboard_input() {
486-
return;
487-
}
488-
489-
// TODO don't allow change while timer is running
490-
491-
#[cfg(feature = "layer-filesystem")]
492-
if keyboard_input.pressed(KeyCode::KeyF) {
493-
**current_layer = Layer::Filesystem;
494-
timer.reset();
495-
}
496-
#[cfg(feature = "layer-package")]
497-
if keyboard_input.pressed(KeyCode::KeyP) {
498-
**current_layer = Layer::Package;
499-
timer.reset();
500-
}
501-
#[cfg(feature = "layer-desktop")]
502-
if keyboard_input.pressed(KeyCode::KeyD) {
503-
**current_layer = Layer::Desktop;
504-
timer.reset();
505-
}
506-
507-
// Now show the current layer for a few seconds
508-
if !timer.tick(time.delta()).finished() {
509-
let _window_size = windows.single_mut().unwrap().size();
510-
// TODO util
511-
// egui::Window::new("Current layer")
512-
// .id(egui::Id::new("current_layer"))
513-
// .pivot(egui::Align2::CENTER_CENTER)
514-
// .resizable(false)
515-
// .movable(false)
516-
// .collapsible(false)
517-
// .title_bar(false)
518-
// .fixed_pos(egui::Pos2::new(window_size.x / 2.0, window_size.y -
519-
// 30.0)) .show(contexts.ctx_mut(), |ui| {
520-
// ui.label(format!("{:?}", **current_layer));
521-
// });
522-
}
523-
}

0 commit comments

Comments
 (0)