Touch interface for phones and tablets; category toolbar for mouse and touch
- touch.rs: gesture recognition (tap, double tap, long press, drag, two-finger pan/pinch/rotate) - Touch mode: Auto (touch device or first touch) / On / Off in Settings -> Game - Larger interface factor on touch screens, top bar wraps, smaller minimap, fewer messages - Toolbar grouped into categories with pop-up rows and a menu button, also on the desktop - Long press shows information or drops held units; double tap with the hand slaps - Savegame name via the browser's text dialog when the name field is tapped - Touch help texts (EN/DE) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6f037294c0
commit
af6be62805
10 files changed
+744
-152
No files matched your search
@@ -14,6 +14,8 @@ mod imp {
|
||||
extern "C" {
|
||||
fn dc_storage_get(key: *const u8, key_len: u32) -> i32;
|
||||
fn dc_storage_take(dst: *mut u8);
|
||||
fn dc_coarse_pointer() -> i32;
|
||||
fn dc_prompt(t: *const u8, tl: u32, d: *const u8, dl: u32) -> i32;
|
||||
fn dc_storage_set(key: *const u8, key_len: u32, val: *const u8, val_len: u32);
|
||||
fn dc_cache_set(key: *const u8, key_len: u32, val: *const u8, val_len: u32);
|
||||
fn dc_download(name: *const u8, name_len: u32, data: *const u8, data_len: u32);
|
||||
@@ -55,6 +57,24 @@ mod imp {
|
||||
}
|
||||
}
|
||||
|
||||
// phones and tablets: the main pointer is a finger
|
||||
pub fn coarse_pointer() -> bool {
|
||||
unsafe { dc_coarse_pointer() != 0 }
|
||||
}
|
||||
|
||||
// asks for a text with the browser's dialog; None when cancelled
|
||||
pub fn prompt(title: &str, default: &str) -> Option<String> {
|
||||
unsafe {
|
||||
let n = dc_prompt(title.as_ptr(), title.len() as u32, default.as_ptr(), default.len() as u32);
|
||||
if n < 0 {
|
||||
return None;
|
||||
}
|
||||
let mut buf = vec![0u8; n as usize];
|
||||
dc_storage_take(buf.as_mut_ptr());
|
||||
String::from_utf8(buf).ok()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn storage_set(key: &str, val: &str) {
|
||||
unsafe { dc_storage_set(key.as_ptr(), key.len() as u32, val.as_ptr(), val.len() as u32) }
|
||||
}
|
||||
@@ -96,6 +116,12 @@ mod imp {
|
||||
pub fn storage_get(key: &str) -> Option<String> {
|
||||
STORE.with(|s| s.borrow().get(key).cloned())
|
||||
}
|
||||
pub fn prompt(_title: &str, _default: &str) -> Option<String> {
|
||||
None
|
||||
}
|
||||
pub fn coarse_pointer() -> bool {
|
||||
false
|
||||
}
|
||||
pub fn storage_set(key: &str, val: &str) {
|
||||
STORE.with(|s| s.borrow_mut().insert(key.to_string(), val.to_string()));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user