Compare commits

...
22 Commits
Author SHA1 Message Date
waozi 81032a9dcc bug fix 2026-05-29 09:20:11 -03:00
waozi 2be97ca801 release fix 2026-05-29 09:14:19 -03:00
waozi 324d18fdfb fix inset 2026-05-29 09:11:47 -03:00
waozi 6889777cff increase inset 2026-05-29 07:50:08 -03:00
waozi ea78b73c86 move scripts 2026-05-29 07:26:04 -03:00
waozi 1e5768f6b4 fix data issue 2026-05-29 07:23:00 -03:00
waozi 612f431376 bug fix 2026-05-28 23:58:22 -03:00
waozi f13a88b94e improve website 2026-05-28 18:48:19 -03:00
waozi e7d9843e94 add itch script 2026-05-28 18:14:25 -03:00
waozi ae438d7c14 rm dependency tracker 2026-05-28 16:31:51 -03:00
waozi 879f058d7a fix bug 2026-05-28 14:44:10 -03:00
waozi f208429e08 fix script 2026-05-28 14:38:41 -03:00
waozi 827780347b fastlane changelog 2026-05-28 14:37:35 -03:00
waozi 791ca2eba9 fix versioning 2026-05-28 14:35:31 -03:00
waozi 7d3d4d588b add descriptions 2026-05-28 12:37:07 -03:00
waozi eec36173c8 fix dropdown passthrough 2026-05-28 10:48:38 -03:00
waozi a21bc16bcd update version 2026-05-28 10:20:02 -03:00
waozi 79a9f92e35 make file sharing work 2026-05-28 10:19:50 -03:00
waozi fc77fa2aea implemnet clean zip export 2026-05-28 04:14:31 -03:00
waozi e21f49cf4d wip data management 2026-05-28 02:55:45 -03:00
waozi a9f2cbb464 refactor code 2026-05-28 02:34:07 -03:00
waozi a0b86526a2 add return button func on android 2026-05-28 01:12:11 -03:00
63 changed files with 13654 additions and 2109 deletions

No files matched your search

+34
View File
@@ -1,4 +1,38 @@
# Changelog
## [1.1.2] - 2026-05-29
## Fixed
- Data storage location
- Punch hole spacing
- Crashes on newer devices
## [1.1.1] - 2026-05-28
### Fixed
- Slider focus now properly releases when mouse button is released (prevented adjusting sliders when clicking outside)
## [1.1.0] - 2026-05-28
### Added
- Tiny version bump
### Fixed
- Changelog extraction now correctly populates fastlane metadata
## [1.0.9] - 2026-05-28
### Added
- Android share sheet for data export (native Intent integration)
- Direct sharing to Telegram, Downloads, or any app that handles ZIP files
- FileProvider support for secure file sharing on Android 7.0+
### Fixed
- ZIP export now uses native Android share sheet instead of saving to private storage
- JNI class loading fix for ShareHelper on native threads
## [1.0.8] - 2026-05-28
### Added
- Android back button support with screen-aware behavior
- Confirmation modal when exiting active sessions (Save & Exit, Discard, or Cancel)
- Session data preservation: completed rounds can be saved before exiting
### Fixed
- Modal text word wrap to handle last word correctly
- Back button closes modal (cancel action) when pressed during confirmation
## [1.0.7] - 2026-05-27
### Added
- F-Droid metadata (screenshots, feature graphic, icon)
+3 -2
View File
@@ -1,7 +1,7 @@
CC = gcc
WINDRES = windres
SRC = src/main.c src/app.c src/ui.c src/theme_meta.c src/theme.c
SRC = src/main.c src/app.c src/ui.c src/theme_meta.c src/theme.c src/data.c src/miniz.c src/file_dialog.c src/android_share.c src/tabs/history_tab.c src/tabs/manual_tab.c src/tabs/settings_tab.c
INBE_DIR = libinbe
INBE_A = $(INBE_DIR)/libinbe.a
@@ -82,7 +82,7 @@ WEB_SHELL = src/web_shell.html
WEB_LDFLAGS = -sUSE_GLFW=3 -sASYNCIFY -sALLOW_MEMORY_GROWTH=1 --shell-file $(WEB_SHELL) --preload-file [email protected] --preload-file [email protected] --preload-file themes/sky.ini@themes/sky.ini --preload-file themes/sky_dark.ini@themes/sky_dark.ini --preload-file themes/ocean.ini@themes/ocean.ini --preload-file themes/ocean_dark.ini@themes/ocean_dark.ini --preload-file themes/forest.ini@themes/forest.ini --preload-file themes/forest_dark.ini@themes/forest_dark.ini --preload-file themes/sunset.ini@themes/sunset.ini --preload-file themes/sunset_dark.ini@themes/sunset_dark.ini --preload-file themes/lavender.ini@themes/lavender.ini --preload-file themes/lavender_dark.ini@themes/lavender_dark.ini --preload-file themes/cherry.ini@themes/cherry.ini --preload-file themes/cherry_dark.ini@themes/cherry_dark.ini --preload-file icons/gear.png@icons/gear.png --preload-file icons/x.png@icons/x.png --preload-file icons/manual.png@icons/manual.png --preload-file icons/return.png@icons/return.png --preload-file icons/backward.png@icons/backward.png --preload-file icons/forward.png@icons/forward.png --preload-file icons/play.png@icons/play.png --preload-file icons/pause.png@icons/pause.png --preload-file icons/stat.png@icons/stat.png --preload-file icons/home.png@icons/home.png --preload-file icons/trash.png@icons/trash.png --preload-file icons/telegram.png@icons/telegram.png --preload-file icons/globe.png@icons/globe.png --preload-file icons/stripe.png@icons/stripe.png --preload-file icons/monero.png@icons/monero.png --preload-file assets/angel.jpg@assets/angel.jpg --preload-file assets/begin.jpg@assets/begin.jpg --preload-file assets/sounds/breath-in.ogg@assets/sounds/breath-in.ogg --preload-file assets/sounds/breath-out.ogg@assets/sounds/breath-out.ogg --preload-file assets/sounds/bell.ogg@assets/sounds/bell.ogg
INBE_RAYLIB_CONFIG = $(filter-out -DSUPPORT_MODULE_RAUDIO=0 -DSUPPORT_FILEFORMAT_PNG=0 -DSUPPORT_FILEFORMAT_JPG=0 -DSUPPORT_FILEFORMAT_OGG=0,$(RAY_RAYLIB_CONFIG)) -DSUPPORT_MODULE_RAUDIO=1 -DSUPPORT_FILEFORMAT_JPG=1 -DSUPPORT_FILEFORMAT_OGG=1
CFLAGS = -Wall -Wextra -std=c99 -Os -ffunction-sections -fdata-sections -DSUPPORT_FILEFORMAT_JPG=1
CFLAGS = -Wall -Wextra -std=c99 -Os -ffunction-sections -fdata-sections -DSUPPORT_FILEFORMAT_JPG=1 -DMINIZ_NO_ZLIB_COMPATIBLE_NAMES
LDFLAGS = -Wl,--gc-sections -s
.NOTPARALLEL:
@@ -591,3 +591,4 @@ FORCE:
android-install-release \
android-clean \
FORCE
+22
View File
@@ -50,6 +50,28 @@ make android
make web
```
### Android Emulator Testing
For automated testing with camera notch (cutout) support:
```bash
# Enter the development shell and run everything automatically
nix develop
./scripts/emulator.sh # Creates AVD, launches emulator, builds & runs app
```
This single script handles:
- AVD creation (if missing)
- Emulator launch
- APK build
- App installation and launch
The AVD is configured with:
- **Device**: Pixel 6 (punch-hole camera style)
- **Display**: 1080×2400 @ 420dpi
- **RAM**: 4GB with hardware acceleration
- **Cutout**: Punch-hole camera for testing window insets
### Platform-Specific Notes
- **Linux**: Requires SDL2 runtime libraries
+72
View File
@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<head>
<title>Inner Breeze - All Builds</title>
<link href="/style.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Inner Breeze - All available builds and implementations.">
<link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png">
<meta name="theme-color" content="#5566aa">
</head>
<body>
<div class="content">
<section>
<h1>All Builds</h1>
<p><a href="/">← Back to Inner Breeze</a></p>
</section>
<section>
<div class="platform-section">
<div class="platform-header">
<img src="/icons/ray.png" alt="raylib"/>
<div>
<strong><a href="https://raylib.com">Raylib</a></strong>
<p>A C library for video game programming - the primary implementation.</p>
</div>
</div>
<div class="downloads-grid">
<a href="/build/web/index.html" class="download-item">Web (WASM)</a>
<a href="/build/linux/inbe-linux.tar.gz" class="download-item">Linux</a>
<a href="/build/windows/inbe-windows.zip" class="download-item">Windows</a>
<a href="/build/android/inbe-latest.apk" class="download-item">Android APK</a>
</div>
</div>
<div class="platform-section">
<div class="platform-header">
<img src="/icons/wasm4.png" alt="wasm4"/>
<div>
<strong><a href="https://wasm4.org">WASM-4</a></strong>
<p>A tiny fantasy console that runs WebAssembly cartridges.</p>
</div>
</div>
<div class="downloads-grid">
<a href="/wasm4/build/index.html" class="download-item">Web</a>
<a href="/wasm4/build/cart.wasm" class="download-item">cart.wasm</a>
<a href="/wasm4/build/inbe-windows.zip" class="download-item">Windows</a>
<a href="/wasm4/build/inbe-linux.tar.gz" class="download-item">Linux</a>
</div>
</div>
<div class="platform-section">
<div class="platform-header">
<img src="/icons/uxn.png" alt="uxn"/>
<div>
<strong><a href="https://100r.co/site/uxn.html">Uxn</a></strong>
<p>A small virtual computer; <code>.rom</code> runs in a Uxn emulator.</p>
</div>
</div>
<div class="downloads-grid">
<a href="/uxn/index.html" class="download-item">Web</a>
<a href="/uxn/inbe.rom" class="download-item">inbe.rom</a>
</div>
</div>
</section>
<footer>
<p>&copy; 2026 <a href="https://waozi.xyz">Waozi</a> | <a href="https://git.sr.ht/~waozi/inbe" target="_blank" rel="noopener">hosted on sr.ht</a></p>
</footer>
</div>
</body>
</html>
+12 -2
View File
@@ -7,6 +7,11 @@ android {
compileSdk 35
ndkVersion "25.1.8937393"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
def keystorePropsFile = rootProject.file("local.properties")
def keystoreProps = new Properties()
if (keystorePropsFile.exists()) {
@@ -29,8 +34,8 @@ android {
defaultConfig {
minSdk 19
targetSdk 35
versionCode 8
versionName "1.0.7"
versionCode 13
versionName "1.1.2"
}
@@ -59,6 +64,10 @@ android {
universalApk true
}
}
dependenciesInfo {
includeInApk = false
}
}
gradle.taskGraph.whenReady { taskGraph ->
@@ -70,4 +79,5 @@ gradle.taskGraph.whenReady { taskGraph ->
}
dependencies {
implementation 'androidx.core:core:1.12.0'
}
+14 -4
View File
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:hasCode="false"
android:hasCode="true"
android:icon="@mipmap/ic_launcher"
android:label="Inner Breeze"
android:roundIcon="@mipmap/ic_launcher_round">
<activity
android:name="android.app.NativeActivity"
android:name="xyz.waozi.inbe.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
android:windowLayoutInDisplayCutoutMode="shortEdges">
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:windowLayoutInDisplayCutoutMode="never">
<meta-data
android:name="android.app.lib_name"
android:value="main" />
@@ -20,5 +20,15 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="xyz.waozi.inbe.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
+7
View File
@@ -58,6 +58,13 @@ add_library(main SHARED
"${SRC_DIR}/ui.c"
"${SRC_DIR}/theme_meta.c"
"${SRC_DIR}/theme.c"
"${SRC_DIR}/data.c"
"${SRC_DIR}/miniz.c"
"${SRC_DIR}/file_dialog.c"
"${SRC_DIR}/android_share.c"
"${SRC_DIR}/tabs/history_tab.c"
"${SRC_DIR}/tabs/manual_tab.c"
"${SRC_DIR}/tabs/settings_tab.c"
"${SRC_DIR}/android_insets.c"
"${NATIVE_APP_GLUE_DIR}/android_native_app_glue.c"
)
@@ -0,0 +1,165 @@
package xyz.waozi.inbe;
import android.app.NativeActivity;
import android.graphics.Insets;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.DisplayCutout;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
public class MainActivity extends NativeActivity {
private static final String TAG = "InbeMainActivity";
static {
System.loadLibrary("main");
}
// [status_bar, nav_bar, cutout_left, cutout_top, cutout_right, cutout_bottom]
private final int[] cachedInsets = new int[6];
private boolean insetsInitialized = false;
private native void nativeSetInsets(int status, int nav,
int cutoutLeft, int cutoutTop, int cutoutRight, int cutoutBottom);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
synchronized (cachedInsets) {
for (int i = 0; i < 6; i++) {
cachedInsets[i] = 0;
}
}
setupInsetsListener();
}
private void setupInsetsListener() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final View decorView = getWindow().getDecorView();
// 1. Primary listener for runtime inset modifications (swiping, rotating)
decorView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
updateInsets(insets);
return insets;
}
});
// 2. Startup safety net: Catches frame sizing on the initial layout pass
decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
WindowInsets insets = decorView.getRootWindowInsets();
if (insets != null) {
updateInsets(insets);
}
}
decorView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
// 3. Force synchronous scheduling update pass
decorView.post(new Runnable() {
@Override
public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
decorView.requestApplyInsets();
}
}
});
} else {
fallbackForOldPhones();
}
}
private void fallbackForOldPhones() {
int statusBarHeight = 0;
int navBarHeight = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
int navResourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
if (navResourceId > 0) {
navBarHeight = getResources().getDimensionPixelSize(navResourceId);
}
synchronized (cachedInsets) {
cachedInsets[0] = statusBarHeight;
cachedInsets[1] = navBarHeight;
cachedInsets[2] = 0;
cachedInsets[3] = 0;
cachedInsets[4] = 0;
cachedInsets[5] = 0;
}
insetsInitialized = true;
nativeSetInsets(statusBarHeight, navBarHeight, 0, 0, 0, 0);
}
private void updateInsets(WindowInsets insets) {
if (insets == null) return;
try {
int statusBar = 0;
int navBar = 0;
int cLeft = 0, cTop = 0, cRight = 0, cBottom = 0;
// System bar calculations
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Insets systemBars = insets.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars());
statusBar = systemBars.top;
navBar = systemBars.bottom;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
statusBar = insets.getSystemWindowInsetTop();
navBar = insets.getSystemWindowInsetBottom();
}
// Display cutout calculations
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
DisplayCutout cutout = insets.getDisplayCutout();
if (cutout != null) {
cLeft = cutout.getSafeInsetLeft();
cTop = cutout.getSafeInsetTop();
cRight = cutout.getSafeInsetRight();
cBottom = cutout.getSafeInsetBottom();
}
}
synchronized (cachedInsets) {
cachedInsets[0] = statusBar;
cachedInsets[1] = navBar;
cachedInsets[2] = cLeft;
cachedInsets[3] = cTop;
cachedInsets[4] = cRight;
cachedInsets[5] = cBottom;
}
insetsInitialized = true;
nativeSetInsets(statusBar, navBar, cLeft, cTop, cRight, cBottom);
} catch (Exception e) {
Log.e(TAG, "Error structuralizing window layout properties: " + e.getMessage());
}
}
/**
* Called from native code via JNI to pull array memory safely.
* * @return Array copy containing [status, nav, left, top, right, bottom]
*/
public int[] getInsetsNative() {
int[] result = new int[6];
synchronized (cachedInsets) {
System.arraycopy(cachedInsets, 0, result, 0, 6);
}
return result;
}
}
@@ -0,0 +1,47 @@
package xyz.waozi.inbe;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import androidx.core.content.FileProvider;
import java.io.File;
import java.io.FileOutputStream;
public class ShareHelper {
private static final String TAG = "InbeShare";
public static void shareZipFile(Activity activity, byte[] zipData, String filename) {
if (activity == null || zipData == null) return;
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
File cacheFile = new File(activity.getCacheDir(), filename);
FileOutputStream fos = new FileOutputStream(cacheFile);
fos.write(zipData);
fos.close();
Uri contentUri = FileProvider.getUriForFile(
activity,
"xyz.waozi.inbe.fileprovider",
cacheFile
);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("application/zip");
sendIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Intent shareIntent = Intent.createChooser(sendIntent, "Export Session Data");
activity.startActivity(shareIntent);
Log.i(TAG, "Share sheet shown");
} catch (Exception e) {
Log.e(TAG, "Share failed", e);
}
}
});
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<cache-path name="cache" path="." />
</paths>
@@ -1 +1,6 @@
### Added
- Initial release
- Breathing exercise tutorial with 5 steps
- Configurable settings: speed (1-9), rounds (1-10), breaths (15-80), pause duration (0-30s)
- Session history tracking and statistics
- Support for Linux, Windows, Android, and WebAssembly platforms
@@ -0,0 +1,7 @@
### Added
- Android share sheet for data export (native Intent integration)
- Direct sharing to Telegram, Downloads, or any app that handles ZIP files
- FileProvider support for secure file sharing on Android 7.0+
### Fixed
- ZIP export now uses native Android share sheet instead of saving to private storage
- JNI class loading fix for ShareHelper on native threads
@@ -0,0 +1,4 @@
### Added
- Tiny version bump
### Fixed
- Changelog extraction now correctly populates fastlane metadata
@@ -0,0 +1,2 @@
### Fixed
- Slider focus now properly releases when mouse button is released (prevented adjusting sliders when clicking outside)
@@ -0,0 +1,3 @@
- Data storage location
- Punch hole spacing
- Crashes on newer devices
@@ -1 +1,3 @@
### Fixed
- Fixed WebAssembly local storage persistence
- Updated Android target SDK version
@@ -1 +1,7 @@
### Fixed
- Fixed "Starting in" countdown text positioning (now displays above circle)
- Fixed first round to always use 3-second countdown regardless of settings
- Fixed slider knob vertical centering (DPI scaling issue)
- Fixed slider touch hit area scaling for better mobile interaction
- Fixed speed meter position in tutorial (removed double DPI scaling)
- Fixed results screen DPI scaling for consistent appearance
@@ -1 +1,9 @@
### Fixed
- Improved DPI scaling for scrollbars (width and thumb height now scale properly)
- Fixed scrollbar not appearing on tall viewports/settings screens (content height now scales correctly)
- Fixed X icon too small on mobile (increased max size from 18px to 28px for better touch targets)
- Improved scrollbar thumb touch hit area for easier grabbing
- Fixed missing breath sounds during recovery phase (breath in at start, breath out after 15-second hold)
### Added
- Added external links in settings (Telegram, Website, Monero, Stripe donation)
- Added content-area drag scrolling for mobile (click and drag anywhere to scroll)
@@ -1 +1,9 @@
### Added
- Centralized icon size management system (SMALL, MEDIUM, LARGE)
- Standardized icon button functions for consistent sizing
### Fixed
- Improved accessibility with larger icons for older users (+25-37%)
- DPI scaling for all button padding and bevel borders on mobile
- X button positioning and scaling on high DPI screens
- Button dimensions and icon centering across all screens
- Missing icons (telegram, globe, stripe, monero, home, trash) in WebAssembly build
@@ -1 +1,8 @@
### Added
- Theme system with 8 color themes (Forest, Ocean, Sky, Sunset, Lavender - each with light/dark variants)
- Settings dropdown menu for easier navigation
- Improved fullscreen mode with better DPI scaling
### Fixed
- Touch input scaling for dropdown menus and toggle switches
- Tab bar positioning on Android (now accounts for system navbar)
- Removed toggle switch circle indicator for cleaner UI
@@ -1 +1,4 @@
### Fixed
- Bell now plays before the last breath (at maxbreaths - 1) instead of after
- Session history not loading and potential segfault due to path buffer overflow (increased HISTORY_PATH_SIZE from 96 to 256)
- Tutorial text clarified to explicitly mention Wim Hof Method
@@ -1 +1,4 @@
### Added
- F-Droid metadata (screenshots, feature graphic, icon)
- Automatic version tag generation for releases
- Fastlane changelog integration
@@ -0,0 +1,7 @@
### Added
- Android back button support with screen-aware behavior
- Confirmation modal when exiting active sessions (Save & Exit, Discard, or Cancel)
- Session data preservation: completed rounds can be saved before exiting
### Fixed
- Modal text word wrap to handle last word correctly
- Back button closes modal (cancel action) when pressed during confirmation
@@ -0,0 +1,12 @@
A free, open-source guided breathing meditation app based on the Wim Hof method.
Features:
- Guided breathing sessions with visual and audio cues
- Configurable breath counts and hold times
- Session history with local storage
- 8 color themes (Forest, Ocean, Sky, Sunset, Lavender - each with light/dark variants)
- Sound effects (breath in/out, bell)
- Fullscreen mode with proper DPI scaling
- Touch-optimized UI for mobile devices
Available platforms: Linux, Windows, Android, WebAssembly.
@@ -0,0 +1 @@
A free, open-source guided breathing meditation app based on the Wim Hof method.
+3 -1
View File
@@ -48,6 +48,7 @@
includeNDK = true;
ndkVersions = [ "25.1.8937393" ];
cmakeVersions = [ "3.22.1" ];
includeEmulator = true;
};
sdk = androidComposition.androidsdk;
@@ -94,6 +95,7 @@
targetPkgs = pkgs: with pkgs; [
SDL2
SDL2.dev
butler
cmake
emscripten
gcc
@@ -144,7 +146,7 @@
export RAY_RAYLIB_CONFIG="-DSUPPORT_SCREEN_CAPTURE=0 -DSUPPORT_COMPRESSION_API=0 -DSUPPORT_AUTOMATION_EVENTS=0 -DSUPPORT_CLIPBOARD_IMAGE=0 -DSUPPORT_FILEFORMAT_BMP=0 -DSUPPORT_FILEFORMAT_GIF=0 -DSUPPORT_FILEFORMAT_QOI=0 -DSUPPORT_FILEFORMAT_DDS=0 -DSUPPORT_FILEFORMAT_TTF=0"
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH"
export PATH="$ANDROID_HOME/cmdline-tools/11.0/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$PATH"
export WEB_CC="emcc"
export WEB_AR="emar"
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

+17 -50
View File
@@ -32,7 +32,7 @@
<body>
<div class="content">
<section>
<section class="hero">
<img class="tk-img" src="/icons/inbe.png" width="128px" alt="Inner Breeze"/>
<h1>Inner Breeze</h1>
@@ -56,66 +56,33 @@
<span>Linux</span>
</a>
</div>
<div class="platform-buttons">
<a href="https://play.google.com/store/apps/details?id=xyz.waozi.inbe" class="platform-btn android">
<img src="/icons/playstore.png" alt="play store"/>
<span>Play Store</span>
</a>
<a href="https://f-droid.org/packages/xyz.waozi.inbe/" class="platform-btn android">
<img src="/icons/fdroid.png" alt="F-Droid"/>
<span>F-Droid</span>
</a>
<a href="https://waozi.itch.io/inbe" class="platform-btn web">
<img src="/icons/itch.png" alt="itch.io"/>
<span>itch.io</span>
</a>
</div>
<p style="text-align:center; margin-top:8px; font-size:14px;"><a href="/builds.html">Other builds (WASM-4, Uxn) →</a></p>
</section>
<section>
<details>
<summary>All implementations</summary>
<br/>
<div class="platform-section">
<div class="platform-header">
<img src="/icons/ray.png" alt="raylib"/>
<div>
<strong><a href="https://raylib.com">Raylib</a></strong>
<p>A C library for video game programming - the primary implementation.</p>
</div>
</div>
<div class="downloads-grid">
<a href="/build/web/index.html" class="download-item">Web (WASM)</a>
<a href="/build/linux/inbe-linux.tar.gz" class="download-item">Linux</a>
<a href="/build/windows/inbe-windows.zip" class="download-item">Windows</a>
<a href="/build/android/inbe-latest.apk" class="download-item">Android APK</a>
</div>
</div>
<div class="platform-section">
<div class="platform-header">
<img src="/icons/wasm4.png" alt="wasm4"/>
<div>
<strong><a href="https://wasm4.org">WASM-4</a></strong>
<p>A tiny fantasy console that runs WebAssembly cartridges.</p>
</div>
</div>
<div class="downloads-grid">
<a href="/wasm4/build/index.html" class="download-item">Web</a>
<a href="/wasm4/build/cart.wasm" class="download-item">cart.wasm</a>
<a href="/wasm4/build/inbe-windows.zip" class="download-item">Windows</a>
<a href="/wasm4/build/inbe-linux.tar.gz" class="download-item">Linux</a>
</div>
</div>
<div class="platform-section">
<div class="platform-header">
<img src="/icons/uxn.png" alt="uxn"/>
<div>
<strong><a href="https://100r.co/site/uxn.html">Uxn</a></strong>
<p>A small virtual computer; <code>.rom</code> runs in a Uxn emulator.</p>
</div>
</div>
<div class="downloads-grid">
<a href="/uxn/index.html" class="download-item">Web</a>
<a href="/uxn/inbe.rom" class="download-item">inbe.rom</a>
</div>
</div>
</details>
<details>
<summary>donate</summary>
<br/>
<div class="donation-buttons">
<!-- Stripe Redirect Button -->
<a href="https://donate.stripe.com/4gM3cv5boaR98HH9VvfAc04" target="_blank" rel="noopener" class="platform-btn stripe-btn">
<img src="/icons/stripe.png" alt="stripe" class="platform-icon-btn"/>
<span>Donate via Stripe</span>
</a>
<!-- Trocador Monero Redirect Button -->
<a href="https://trocador.app/en/anonpay/?ticker_to=xmr&network_to=Mainnet&address=86CbC3d4a2GhT9auh6X99JhmhTMFKVVk8Q9cLrKTHkBu8LLkoNWgkBeAT3YZrvDM6NczYe8brUJNsTiFmwpWDZYnFG5kzSH&donation=True&simple_mode=True&amount=0.1&name=Inner+Breeze&[email protected]&ticker_from=xmr&network_from=Mainnet&buttonbgcolor=445588&textcolor=ffffff&bgcolor=eaeaffff" target="_blank" rel="noopener" class="platform-btn xmr-btn">
<img src="/icons/monero.png" alt="monero" class="platform-icon-btn"/>
<span>Donate via Crypto</span>
+1 -1
View File
@@ -33,7 +33,7 @@ enum {
InbeScreenResults,
InbeScreenSettings,
InbeScreenManual,
InbeScreenHistory
InbeScreenHistory,
};
enum {
+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
# Publish inbe HTML5 to itch.io using butler
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# Check if butler is installed
if ! command -v butler &> /dev/null; then
echo "Error: 'butler' command not found"
echo "Install it from: https://itch.io/docs/butler/"
exit 1
fi
WEB_BUILD_DIR="build/web"
# Verify the web build exists
if [ ! -f "$WEB_BUILD_DIR/index.html" ]; then
echo "Error: Web build not found at $WEB_BUILD_DIR/index.html"
echo "Run 'make web' first."
exit 1
fi
# Read version from src/version.h
VERSION=$(grep INBE_VERSION_STRING src/version.h | grep -o '"[^"]*"' | tr -d '"')
if [ -z "$VERSION" ]; then
echo "Error: Could not determine version from src/version.h"
exit 1
fi
ITCH_USER="waozi"
ITCH_GAME="inbe"
ITCH_CHANNEL="html5"
echo "Publishing inbe v$VERSION ($ITCH_CHANNEL) to itch.io..."
echo " User: $ITCH_USER"
echo " Game: $ITCH_GAME"
echo " Channel: $ITCH_CHANNEL"
echo " Build dir: $WEB_BUILD_DIR"
echo ""
butler push "$WEB_BUILD_DIR" "$ITCH_USER/$ITCH_GAME:$ITCH_CHANNEL" --userversion "$VERSION"
echo "✓ Published inbe v$VERSION to https://$ITCH_USER.itch.io/$ITCH_GAME"
-23
View File
@@ -1,23 +0,0 @@
#!/usr/bin/env bash
# Exit immediately if a command exits with a non-zero status
set -e
# 1. Define paths and package configuration
APK_PATH="build/android/app-universal-debug.apk"
# TODO: Replace with your actual Android package name from AndroidManifest.xml
PACKAGE_NAME="xyz.waozi.inbe"
LAUNCHER_ACTIVITY="android.app.NativeActivity"
echo "🔄 Waiting for device..."
adb wait-for-device
echo "📦 Installing universal debug APK..."
# The -r flag replaces the existing application if it's already there
adb install -r "$APK_PATH"
echo "🚀 Launching application..."
# Starts the main activity
adb shell am start -n "$PACKAGE_NAME/$LAUNCHER_ACTIVITY"
echo "✅ Done!"
+95
View File
@@ -0,0 +1,95 @@
#!/usr/bin/env bash
set -e
AVD_NAME="inbe-test"
echo "🚀 Android Emulator Manager"
echo " This script handles emulator creation and launching"
echo " Use './scripts/run-android.sh' to build and install the app"
echo ""
# Check for Android SDK location
if [ -z "$ANDROID_SDK_ROOT" ] && [ -z "$ANDROID_HOME" ]; then
echo "❌ Error: Neither ANDROID_SDK_ROOT nor ANDROID_HOME environment variable is set"
echo " Make sure to run this script within 'nix develop'"
exit 1
fi
# Set up writable SDK location
WRITABLE_SDK="/mnt/storage/Android/Sdk"
if [ -d "$WRITABLE_SDK" ] && [ -w "$WRITABLE_SDK" ]; then
export ANDROID_SDK_ROOT="$WRITABLE_SDK"
export ANDROID_SDK_HOME="$WRITABLE_SDK"
export ANDROID_AVD_HOME="$WRITABLE_SDK/avd"
echo "📂 Using writable Android SDK: $ANDROID_SDK_ROOT"
else
echo "❌ Error: No writable Android SDK location found"
exit 1
fi
# Step 1: Create AVD if missing
if [ ! -d "$ANDROID_SDK_ROOT/avd/$AVD_NAME.avd" ]; then
echo "📱 AVD not found. Creating..."
bash scripts/create-avd.sh "$AVD_NAME"
echo ""
else
echo "✅ AVD already exists: $AVD_NAME"
echo ""
fi
# Step 2: Check if emulator is running
if adb devices | grep -q "emulator"; then
echo "✅ Emulator already running"
echo ""
echo "To stop the emulator:"
echo " adb emu kill"
else
echo "🚀 Launching emulator..."
# Set environment for emulator (unset ANDROID_HOME to avoid conflicts)
unset ANDROID_HOME
export ANDROID_SDK_ROOT="$ANDROID_SDK_ROOT"
# Launch emulator in background
emulator @"$AVD_NAME" \
-gpu host \
-skin 1080x2400 \
-no-snapshot-load \
-no-boot-anim \
-show-kernel \
-verbose > /tmp/emulator.log 2>&1 &
echo "⏳ Waiting for emulator to boot..."
timeout_seconds=120
elapsed=0
while ! adb shell getprop sys.boot_completed 2>/dev/null | grep -q "1"; do
if [ $elapsed -ge $timeout_seconds ]; then
echo "❌ Timeout waiting for emulator to boot"
echo " Check /tmp/emulator.log for details"
exit 1
fi
echo -n "⏳ "
date +"%T"
sleep 5
elapsed=$((elapsed + 5))
# Check if emulator process died
if ! pgrep -f "emulator.*$AVD_NAME" > /dev/null; then
echo "❌ Emulator process died"
echo " Check /tmp/emulator.log for details"
exit 1
fi
done
echo "✅ Emulator booted successfully"
echo ""
fi
echo "📱 Emulator ready!"
echo ""
echo "Next steps:"
echo " 1. Build and install the app:"
echo " ./scripts/run-android.sh"
+64
View File
@@ -0,0 +1,64 @@
#!/usr/bin/env bash
set -e
APK_PATH="build/android/app-universal-debug.apk"
PACKAGE_NAME="xyz.waozi.inbe"
echo "🚀 Android App Builder & Installer"
echo " This script builds the APK and installs it to your chosen device"
echo ""
# Build APK
echo "🔨 Building APK..."
make android-debug
echo "✅ APK built: $APK_PATH"
echo ""
# Get list of connected devices
mapfile -t DEVICES < <(adb devices | grep -v "List" | grep -v "^$" | awk '{print $1}')
if [ ${#DEVICES[@]} -eq 0 ]; then
echo "❌ No Android devices found"
echo " Connect a device or start an emulator:"
echo " ./scripts/emulator.sh"
exit 1
fi
echo "📱 Found ${#DEVICES[@]} device(s):"
for i in "${!DEVICES[@]}"; do
DEVICE_ID="${DEVICES[$i]}"
# Get device info
DEVICE_NAME=$(adb -s "$DEVICE_ID" shell getprop ro.product.model 2>/dev/null | tr -d '\r')
DEVICE_ANDROID=$(adb -s "$DEVICE_ID" shell getprop ro.build.version.release 2>/dev/null | tr -d '\r')
echo " [$i] $DEVICE_ID"
echo " Model: $DEVICE_NAME"
echo " Android: $DEVICE_ANDROID"
echo ""
done
# Select device
if [ ${#DEVICES[@]} -eq 1 ]; then
SELECTED_DEVICE="${DEVICES[0]}"
echo "✅ Using only available device"
else
echo -n "👉 Select device number [0-$((${#DEVICES[@]}-1))]: "
read -r SELECTION
SELECTED_DEVICE="${DEVICES[$SELECTION]}"
fi
echo ""
echo "📦 Installing APK to $SELECTED_DEVICE..."
adb -s "$SELECTED_DEVICE" install -r "$APK_PATH"
echo "🚀 Launching app..."
adb -s "$SELECTED_DEVICE" shell am start -n "$PACKAGE_NAME/.MainActivity"
echo ""
echo "🎉 App is running!"
echo ""
echo "To rebuild and reinstall:"
echo " ./scripts/run-android.sh"
echo ""
echo "To view logs:"
echo " adb -s $SELECTED_DEVICE logcat | grep inbe"
+6 -6
View File
@@ -1,9 +1,9 @@
speed 6
max_rounds 4
max_breaths 30
speed 8
max_rounds 7
max_breaths 32
pause_seconds 2
sound_volume 36
sound_volume 100
tutorial_seen 1
theme 5
dark_mode 0
theme 0
dark_mode 1
fullscreen 0
+64 -26
View File
@@ -5,9 +5,17 @@
#include <raylib.h>
#include <pthread.h>
#include <android_native_app_glue.h>
#include <jni.h>
#ifndef JNI_VERSION_1_6
#define JNI_VERSION_1_6 0x10060000
#endif
extern struct android_app *GetAndroidApp(void);
static JavaVM *g_jvm = NULL;
static jobject g_activity = NULL;
static volatile struct {
int status_bar;
int nav_bar;
@@ -17,53 +25,83 @@ static volatile struct {
int cutout_bottom;
} current_insets = {0};
static pthread_mutex_t insets_mutex = PTHREAD_MUTEX_INITIALIZER;
static int insets_initialized = 0;
static void query_insets_ndk(void) {
if (insets_initialized) return;
struct android_app *app = GetAndroidApp();
if (!app || !app->window) {
insets_initialized = 0;
return;
}
insets_initialized = 1;
int density = AConfiguration_getDensity(app->config);
/* Status bar: ~24dp, Navbar: ~48dp */
int status_height_px = (24 * density + 160) / 160;
int nav_height_px = (48 * density + 160) / 160;
// JNI function - Java calls this to push inset values
static void nativeSetInsets(JNIEnv *env, jobject thiz,
jint status_bar, jint nav_bar,
jint cutout_left, jint cutout_top, jint cutout_right, jint cutout_bottom)
{
TraceLog(LOG_INFO, "INBE: Java insets: status=%d, nav=%d, cutout_top=%d",
status_bar, nav_bar, cutout_top);
pthread_mutex_lock(&insets_mutex);
current_insets.status_bar = status_height_px;
current_insets.nav_bar = nav_height_px;
current_insets.cutout_left = 0;
current_insets.cutout_top = 0;
current_insets.cutout_right = 0;
current_insets.cutout_bottom = 0;
current_insets.status_bar = status_bar;
current_insets.nav_bar = nav_bar;
current_insets.cutout_left = cutout_left;
current_insets.cutout_top = cutout_top;
current_insets.cutout_right = cutout_right;
current_insets.cutout_bottom = cutout_bottom;
pthread_mutex_unlock(&insets_mutex);
// Memory barrier to ensure all threads see the updated values
__sync_synchronize();
}
// JNI method table
static const JNINativeMethod g_methods[] = {
{"nativeSetInsets", "(IIIIII)V", (void*)nativeSetInsets},
};
// JNI_OnLoad - Register native methods
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
{
JNIEnv *env = NULL;
jint result;
g_jvm = vm;
result = (*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6);
if (result != JNI_OK) {
TraceLog(LOG_ERROR, "INBE: Failed to get JNI environment");
return result;
}
// Find the MainActivity class
jclass clazz = (*env)->FindClass(env, "xyz/waozi/inbe/MainActivity");
if (clazz == NULL) {
TraceLog(LOG_ERROR, "INBE: Failed to find MainActivity class");
return JNI_ERR;
}
// Register native methods
result = (*env)->RegisterNatives(env, clazz, g_methods, sizeof(g_methods) / sizeof(g_methods[0]));
if (result != JNI_OK) {
TraceLog(LOG_ERROR, "INBE: Failed to register native methods");
return result;
}
return JNI_VERSION_1_6;
}
void android_insets_init(void) {
pthread_mutex_lock(&insets_mutex);
memset((void *)&current_insets, 0, sizeof(current_insets));
pthread_mutex_unlock(&insets_mutex);
insets_initialized = 0;
}
void android_insets_get(AndroidInsets *out) {
query_insets_ndk();
pthread_mutex_lock(&insets_mutex);
// Simply return the current values
if (out) {
pthread_mutex_lock(&insets_mutex);
out->status_bar = current_insets.status_bar;
out->nav_bar = current_insets.nav_bar;
out->cutout_left = current_insets.cutout_left;
out->cutout_top = current_insets.cutout_top;
out->cutout_right = current_insets.cutout_right;
out->cutout_bottom = current_insets.cutout_bottom;
pthread_mutex_unlock(&insets_mutex);
}
pthread_mutex_unlock(&insets_mutex);
}
#endif
-2
View File
@@ -23,8 +23,6 @@ typedef struct {
int cutout_bottom;
} AndroidInsets;
static inline void android_insets_init(void) {}
static inline void android_insets_get(AndroidInsets *out) { (void)out; }
#endif
#endif
+242
View File
@@ -0,0 +1,242 @@
#include "android_share.h"
#include "data.h"
#include "version.h"
#include "raylib.h"
#include "miniz.h"
#include <time.h>
#include <stdlib.h>
#include <string.h>
#define FS_PATH_MAX 512
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
#include <android/native_activity.h>
#include <android_native_app_glue.h>
extern struct android_app *GetAndroidApp(void);
static int is_session_file(const char *path)
{
const char *filename;
if(path == NULL)
return 0;
filename = GetFileName(path);
return strncmp(filename, "inbe-", 5) == 0;
}
int android_share_export(const char *filename)
{
struct android_app *app;
mz_zip_archive archive;
void *zip_data;
size_t zip_size;
int year, month, day;
FilePathList files;
int session_count = 0;
char metadata[512];
time_t now;
struct tm *tm;
char date_str[64];
app = GetAndroidApp();
if(app == NULL || app->activity == NULL) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: GetAndroidApp failed");
return 0;
}
if(!data_has_any()) {
TraceLog(LOG_WARNING, "ANDROID_SHARE: no data to export");
return 0;
}
memset(&archive, 0, sizeof(archive));
if(!mz_zip_writer_init_heap(&archive, 0, 0)) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: failed to initialize ZIP archive");
return 0;
}
session_count = data_get_session_count();
now = time(NULL);
tm = localtime(&now);
if(tm != NULL) {
snprintf(date_str, sizeof(date_str), "%04d-%02d-%02d %02d:%02d:%02d",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
} else {
strcpy(date_str, "Unknown");
}
snprintf(metadata, sizeof(metadata),
"Inner Breeze Data Export\n"
"Version: %s\n"
"Export Date: %s\n"
"Session Count: %d\n",
INBE_VERSION_STRING,
date_str,
session_count);
if(!mz_zip_writer_add_mem(&archive, "lotus-data/metadata.txt", metadata, strlen(metadata), MZ_NO_COMPRESSION)) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: failed to write metadata");
mz_zip_writer_end(&archive);
return 0;
}
for(year = 1970; year <= 2100; year++) {
char year_path[FS_PATH_MAX];
snprintf(year_path, sizeof(year_path), "%s/%04d", data_root(), year);
if(!DirectoryExists(year_path))
continue;
for(month = 1; month <= 12; month++) {
char month_path[FS_PATH_MAX];
snprintf(month_path, sizeof(month_path), "%s/%02d", year_path, month);
if(!DirectoryExists(month_path))
continue;
for(day = 1; day <= 31; day++) {
char day_path[FS_PATH_MAX];
snprintf(day_path, sizeof(day_path), "%s/%02d", month_path, day);
if(!DirectoryExists(day_path))
continue;
files = LoadDirectoryFiles(day_path);
for(unsigned int i = 0; i < files.count; i++) {
if(is_session_file(files.paths[i])) {
char *content;
char zip_path[FS_PATH_MAX];
const char *fname = GetFileName(files.paths[i]);
snprintf(zip_path, sizeof(zip_path),
"lotus-data/sessions/%04d/%02d/%02d/%s",
year, month, day, fname);
content = LoadFileText(files.paths[i]);
if(content != NULL) {
size_t size = strlen(content);
if(!mz_zip_writer_add_mem(&archive, zip_path, content, size, MZ_NO_COMPRESSION)) {
TraceLog(LOG_WARNING, "ANDROID_SHARE: failed to add file: %s", files.paths[i]);
}
UnloadFileText(content);
}
}
}
UnloadDirectoryFiles(files);
}
}
}
if(!mz_zip_writer_finalize_heap_archive(&archive, &zip_data, &zip_size)) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: failed to finalize ZIP archive");
mz_zip_writer_end(&archive);
return 0;
}
if(zip_data == NULL || zip_size == 0) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: failed to get ZIP data");
mz_zip_writer_end(&archive);
return 0;
}
TraceLog(LOG_INFO, "ANDROID_SHARE: calling Java to share %zu bytes", zip_size);
ANativeActivity *native_activity = app->activity;
JavaVM *jvm = native_activity->vm;
JNIEnv *env = NULL;
if((*jvm)->AttachCurrentThread(jvm, &env, NULL) != JNI_OK) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: failed to attach thread");
mz_zip_writer_end(&archive);
return 0;
}
/* Use class loader to find ShareHelper - needed when called from native threads */
jclass activity_class = (*env)->FindClass(env, "android/app/Activity");
if(!activity_class) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: Activity class not found");
(*jvm)->DetachCurrentThread(jvm);
mz_zip_writer_end(&archive);
return 0;
}
jmethodID get_class_loader = (*env)->GetMethodID(env, activity_class, "getClassLoader", "()Ljava/lang/ClassLoader;");
if(!get_class_loader) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: getClassLoader method not found");
(*jvm)->DetachCurrentThread(jvm);
mz_zip_writer_end(&archive);
return 0;
}
jobject class_loader = (*env)->CallObjectMethod(env, native_activity->clazz, get_class_loader);
if(!class_loader) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: getClassLoader returned null");
(*jvm)->DetachCurrentThread(jvm);
mz_zip_writer_end(&archive);
return 0;
}
jclass class_loader_class = (*env)->FindClass(env, "java/lang/ClassLoader");
if(!class_loader_class) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: ClassLoader class not found");
(*jvm)->DetachCurrentThread(jvm);
mz_zip_writer_end(&archive);
return 0;
}
jmethodID load_class = (*env)->GetMethodID(env, class_loader_class, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
if(!load_class) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: loadClass method not found");
(*jvm)->DetachCurrentThread(jvm);
mz_zip_writer_end(&archive);
return 0;
}
jstring class_name = (*env)->NewStringUTF(env, "xyz.waozi.inbe.ShareHelper");
jclass share_helper_class = (jclass)(*env)->CallObjectMethod(env, class_loader, load_class, class_name);
(*env)->DeleteLocalRef(env, class_name);
if(!share_helper_class) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: ShareHelper class not found via class loader");
(*jvm)->DetachCurrentThread(jvm);
mz_zip_writer_end(&archive);
return 0;
}
jmethodID method = (*env)->GetStaticMethodID(env, share_helper_class, "shareZipFile",
"(Landroid/app/Activity;[BLjava/lang/String;)V");
if(!method) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: shareZipFile method not found");
(*jvm)->DetachCurrentThread(jvm);
mz_zip_writer_end(&archive);
return 0;
}
jbyteArray jarr = (*env)->NewByteArray(env, zip_size);
(*env)->SetByteArrayRegion(env, jarr, 0, zip_size, (jbyte*)zip_data);
jstring jname = (*env)->NewStringUTF(env, filename);
(*env)->CallStaticVoidMethod(env, share_helper_class, method, native_activity->clazz, jarr, jname);
(*env)->DeleteLocalRef(env, jarr);
(*env)->DeleteLocalRef(env, jname);
(*env)->DeleteLocalRef(env, class_loader);
(*jvm)->DetachCurrentThread(jvm);
mz_zip_writer_end(&archive);
TraceLog(LOG_INFO, "ANDROID_SHARE: share sheet triggered");
return 1;
}
#else
int android_share_export(const char *filename) {
(void)filename;
return 0;
}
#endif
+8
View File
@@ -0,0 +1,8 @@
#ifndef ANDROID_SHARE_H
#define ANDROID_SHARE_H
/* Export data using Android share sheet
* Returns: 1 on success (share sheet shown), 0 on failure */
int android_share_export(const char *filename);
#endif
+191 -1718
View File
File diff suppressed because it is too large. Load diff
+74 -1
View File
@@ -4,6 +4,68 @@
#include "raylib.h"
#include "../libinbe/inbe.h"
/* ================================================================
* SETTINGS CONSTANTS
* ================================================================ */
enum {
SETTINGS_SPEED_MIN = 1,
SETTINGS_SPEED_MAX = 16,
SETTINGS_BREATHS_MIN = 15,
SETTINGS_BREATHS_MAX = 80,
SETTINGS_PAUSE_MIN = 0,
SETTINGS_PAUSE_MAX = 30,
SETTINGS_VOLUME_MIN = 0,
SETTINGS_VOLUME_MAX = 100,
SETTINGS_TITLE_H = 50,
TAB_BAR_H = 58,
SETTINGS_CONTENT_H = 400,
CONTENT_MAX_W = 440,
CONTENT_SIDE_PAD = 16,
CIRCLE_SIDE_PAD = 24,
TUTORIAL_STEPS = 5,
FS_PATH_MAX = 512
};
enum {
/* Icon sizes (base values in logical pixels) */
ICON_SIZE_SMALL = 22,
ICON_SIZE_MEDIUM = 26,
ICON_SIZE_LARGE = 30,
/* Min/max ranges for DPI scaling */
ICON_SIZE_SMALL_MIN = 20,
ICON_SIZE_SMALL_MAX = 36,
ICON_SIZE_MEDIUM_MIN = 24,
ICON_SIZE_MEDIUM_MAX = 40,
ICON_SIZE_LARGE_MIN = 28,
ICON_SIZE_LARGE_MAX = 44
};
enum {
SETTINGS_TAB_BREATHING = 0,
SETTINGS_TAB_SESSION,
SETTINGS_TAB_APPEARANCE,
SETTINGS_TAB_DATA,
SETTINGS_TAB_ABOUT,
SETTINGS_TAB_COUNT
};
/* ================================================================
* MODAL DIALOG TYPES
* ================================================================ */
typedef enum {
UIModalNone,
UIModalConfirmExitSession,
UIModalConfirmDeleteData,
} UIModalType;
typedef struct {
int active;
UIModalType type;
int selected_button; /* 0 = cancel/left, 1 = confirm/right */
} UIModal;
typedef struct LotusAppApi {
const char *id;
void *(*create)(void);
@@ -30,7 +92,6 @@ struct InbeApp {
Texture2D pause_icon;
Texture2D stat_icon;
Texture2D home_icon;
Texture2D trash_icon;
Texture2D telegram_icon;
Texture2D globe_icon;
Texture2D stripe_icon;
@@ -75,6 +136,7 @@ struct InbeApp {
int session_paused;
int results_saved;
int saved_pause_seconds;
UIModal modal;
};
void inbe_app_init(void *app);
@@ -84,4 +146,15 @@ int inbe_app_width(void);
int inbe_app_height(void);
const LotusAppApi *inbe_app_api(void);
/* Helper functions */
int clampi(int x, int min, int max);
int int_from_count(const char src[4]);
void count_from_int(char dst[4], int value);
void save_settings(InbeApp *app);
void reset_settings_preview(InbeApp *app);
void update_preview_bounds(Inbe *inbe, int content_w, int max_h);
void apply_settings(Inbe *inbe, int speed, int max_rounds, int max_breaths, int pause_seconds);
void refresh_theme_colors(int theme_id, int dark_mode);
void draw_preview_inbe(Inbe *inbe, int center_x, int center_y);
#endif
+778
View File
@@ -0,0 +1,778 @@
#include "data.h"
#include "miniz.h"
#include "version.h"
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
#include "android_share.h"
#endif
#include "raylib.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#define FS_PATH_MAX 512
/* Suppress GCC format-truncation warnings - paths are safely sized in practice */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
#if defined(PLATFORM_WEB)
#include <emscripten.h>
#endif
/* ================================================================
* INTERNAL STATE
* ================================================================ */
static char g_data_root[FS_PATH_MAX] = "";
static char g_today_dir[FS_PATH_MAX] = "";
/* ================================================================
* INTERNAL HELPER FUNCTIONS
* ================================================================ */
/* Convert a 3-digit count string to integer
* String format: "000" to "999" */
static int __attribute__((unused))
int_from_count(const char src[4])
{
int a = (src[0] >= '0' && src[0] <= '9') ? src[0] - '0' : 0;
int b = (src[1] >= '0' && src[1] <= '9') ? src[1] - '0' : 0;
int c = (src[2] >= '0' && src[2] <= '9') ? src[2] - '0' : 0;
return a * 100 + b * 10 + c;
}
/* Ensure directory exists (creates parent directories recursively)
* Returns: 1 if directory exists or was created, 0 on failure */
static int
ensure_dir(const char *path)
{
if(path == NULL || path[0] == '\0')
return 0;
TraceLog(LOG_INFO, "DATA: ensure_dir: %s", path);
if(DirectoryExists(path))
return 1;
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
/* On Android, just create the full path directly - Raylib's MakeDirectory handles recursion */
TraceLog(LOG_INFO, "DATA: Creating final directory: %s", path);
if(MakeDirectory(path))
return 1;
TraceLog(LOG_ERROR, "DATA: failed to create directory: %s", path);
return 0;
#else
char temp[FS_PATH_MAX];
char *p;
/* Make a temporary copy to modify */
strncpy(temp, path, sizeof(temp) - 1);
temp[sizeof(temp) - 1] = '\0';
/* Create parent directories first */
p = temp;
if(p[0] == '/') p++; /* Skip root if absolute path */
while((p = strchr(p, '/')) != NULL) {
*p = '\0';
if(!DirectoryExists(temp)) {
TraceLog(LOG_INFO, "DATA: Creating directory: %s", temp);
if(!MakeDirectory(temp)) {
/* Parent directory creation failed */
TraceLog(LOG_ERROR, "DATA: Failed to create directory: %s", temp);
*p = '/';
return 0;
}
}
*p = '/';
p++;
}
/* Now create the final directory */
TraceLog(LOG_INFO, "DATA: Creating final directory: %s", path);
if(MakeDirectory(path))
return 1;
TraceLog(LOG_ERROR, "DATA: failed to create directory: %s", path);
return 0;
#endif
}
/* Check if a path refers to a session file (starts with "inbe-")
* Handles both filenames and full paths */
static int
is_session_file(const char *path)
{
const char *filename;
if(path == NULL)
return 0;
/* Extract filename from full path */
filename = GetFileName(path);
return strncmp(filename, "inbe-", 5) == 0;
}
/* Get file size in bytes
* Returns: File size in bytes, or -1 on error */
static long long
get_file_size(const char *path)
{
#if defined(PLATFORM_WEB)
/* Web platform: use JS to get file size */
int size = 0;
EM_ASM({
try {
var path = UTF8ToString($0);
if(FS.analyzePath(path).exists) {
var stat = FS.stat(path);
setValue($1, stat.size, 'i64');
setValue($2, 1, 'i32');
}
} catch(e) {}
}, path, &size, &size);
return (long long)size;
#else
struct stat st;
if(stat(path, &st) == 0)
return (long long)st.st_size;
return -1;
#endif
}
/* Read a session file and parse round times
* path: Full path to session file
* round_times: Output array for round times
* max_rounds: Maximum rounds to read
* Returns: Number of rounds read, or -1 on error */
static int
read_session_file(const char *path, int *round_times, int max_rounds)
{
char *content;
int round_count = 0;
content = LoadFileText(path);
if(content == NULL)
return -1;
/* Parse each line as a round time */
char *line = content;
char *next_line;
while(line != NULL && round_count < max_rounds) {
next_line = strchr(line, '\n');
if(next_line != NULL) {
*next_line = '\0';
next_line++;
}
/* Skip empty lines */
while(*line == ' ' || *line == '\t')
line++;
if(*line != '\0') {
int seconds = atoi(line);
if(seconds >= 0 && seconds <= 999) {
round_times[round_count++] = seconds;
}
}
line = next_line;
}
UnloadFileText(content);
return round_count;
}
/* Count total rounds and find best time in a session file
* Returns: Number of rounds, sets *best to best time */
static int
analyze_session_file(const char *path, int *best)
{
int round_times[MaxRounds];
int round_count;
round_count = read_session_file(path, round_times, MaxRounds);
if(round_count <= 0) {
*best = 0;
return 0;
}
*best = 0;
for(int i = 0; i < round_count; i++) {
if(round_times[i] > *best)
*best = round_times[i];
}
return round_count;
}
/* ================================================================
* PUBLIC API
* ================================================================ */
void
data_init(void)
{
/* Initialize on first call to data_root() */
(void)data_root();
}
const char *
data_root(void)
{
if(g_data_root[0] != '\0')
return g_data_root;
#if defined(PLATFORM_WEB)
snprintf(g_data_root, sizeof(g_data_root), "/home/lotus");
EM_ASM({
try {
FS.mkdir('/home');
FS.mkdir('/home/lotus');
} catch(e) {}
});
#elif defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
/* On Android, use app's files directory which is already created */
snprintf(g_data_root, sizeof(g_data_root), "/data/data/xyz.waozi.inbe/files/lotus");
#else
const char *xdg = getenv("XDG_DATA_HOME");
const char *home = getenv("HOME");
if(xdg != NULL && xdg[0] != '\0')
snprintf(g_data_root, sizeof(g_data_root), "%s/lotus", xdg);
else if(home != NULL && home[0] != '\0')
snprintf(g_data_root, sizeof(g_data_root), "%s/.local/share/lotus", home);
else
snprintf(g_data_root, sizeof(g_data_root), ".local/lotus");
#endif
/* Ensure root directory exists */
ensure_dir(g_data_root);
TraceLog(LOG_INFO, "DATA: root directory: %s", g_data_root);
return g_data_root;
}
const char *
data_today_dir(void)
{
time_t now;
struct tm *tm;
char dir_year[FS_PATH_MAX];
char dir_month[FS_PATH_MAX];
now = time(NULL);
tm = localtime(&now);
if(tm == NULL)
return data_root();
snprintf(dir_year, sizeof(dir_year), "%s/%04d",
data_root(), tm->tm_year + 1900);
snprintf(dir_month, sizeof(dir_month), "%s/%02d",
dir_year, tm->tm_mon + 1);
snprintf(g_today_dir, sizeof(g_today_dir), "%s/%02d",
dir_month, tm->tm_mday);
return g_today_dir;
}
int
data_save_session(const int *round_times, int round_count)
{
time_t now;
struct tm *tm;
char dir_year[FS_PATH_MAX];
char dir_month[FS_PATH_MAX];
char dir_day[FS_PATH_MAX];
char path[FS_PATH_MAX];
char text[MaxRounds * 8];
int offset = 0;
if(round_times == NULL || round_count <= 0 || round_count > MaxRounds)
return 0;
now = time(NULL);
tm = localtime(&now);
if(tm == NULL)
return 0;
/* Create directory structure: YYYY/MM/DD */
snprintf(dir_year, sizeof(dir_year), "%s/%04d",
data_root(), tm->tm_year + 1900);
if(!ensure_dir(dir_year))
return 0;
snprintf(dir_month, sizeof(dir_month), "%s/%02d", dir_year, tm->tm_mon + 1);
if(!ensure_dir(dir_month))
return 0;
snprintf(dir_day, sizeof(dir_day), "%s/%02d", dir_month, tm->tm_mday);
if(!ensure_dir(dir_day))
return 0;
/* Create session filename: inbe-HHMMSS */
snprintf(path, sizeof(path), "%s/inbe-%02d%02d%02d",
dir_day, tm->tm_hour, tm->tm_min, tm->tm_sec);
/* Build session content */
for(int i = 0; i < round_count; i++) {
if(offset >= (int)sizeof(text) - 8)
break;
offset += snprintf(text + offset, sizeof(text) - (size_t)offset,
"%d\n", round_times[i]);
}
TraceLog(LOG_INFO, "DATA: saving session to %s", path);
if(SaveFileText(path, text)) {
TraceLog(LOG_INFO, "DATA: saved session to %s", path);
#if defined(PLATFORM_WEB)
EM_ASM({
try {
FS.syncfs(false, function(err) {
if(err) console.error("syncfs error:", err);
});
} catch(e) {}
});
#endif
return 1;
} else {
TraceLog(LOG_ERROR, "DATA: failed to save session to %s", path);
return 0;
}
}
int
data_has_any(void)
{
int year, month, day;
FilePathList files;
int has_data = 0;
/* Scan year directories (1970-2100 covers reasonable range) */
for(year = 1970; year <= 2100; year++) {
char year_path[FS_PATH_MAX];
snprintf(year_path, sizeof(year_path), "%s/%04d", data_root(), year);
if(!DirectoryExists(year_path))
continue;
/* Scan month directories */
for(month = 1; month <= 12; month++) {
char month_path[FS_PATH_MAX];
snprintf(month_path, sizeof(month_path), "%s/%02d", year_path, month);
if(!DirectoryExists(month_path))
continue;
/* Scan day directories */
for(day = 1; day <= 31; day++) {
char day_path[FS_PATH_MAX];
snprintf(day_path, sizeof(day_path), "%s/%02d", month_path, day);
if(!DirectoryExists(day_path))
continue;
/* Check for session files */
files = LoadDirectoryFiles(day_path);
for(unsigned int i = 0; i < files.count; i++) {
if(is_session_file(files.paths[i])) {
has_data = 1;
break;
}
}
UnloadDirectoryFiles(files);
if(has_data)
break;
}
if(has_data)
break;
}
if(has_data)
break;
}
return has_data;
}
long long
data_get_total_size(void)
{
long long total = 0;
int year, month, day;
FilePathList files;
/* Scan all year/month/day directories and sum file sizes */
for(year = 1970; year <= 2100; year++) {
char year_path[FS_PATH_MAX];
snprintf(year_path, sizeof(year_path), "%s/%04d", data_root(), year);
if(!DirectoryExists(year_path))
continue;
for(month = 1; month <= 12; month++) {
char month_path[FS_PATH_MAX];
snprintf(month_path, sizeof(month_path), "%s/%02d", year_path, month);
if(!DirectoryExists(month_path))
continue;
for(day = 1; day <= 31; day++) {
char day_path[FS_PATH_MAX];
snprintf(day_path, sizeof(day_path), "%s/%02d", month_path, day);
if(!DirectoryExists(day_path))
continue;
files = LoadDirectoryFiles(day_path);
for(unsigned int i = 0; i < files.count; i++) {
if(is_session_file(files.paths[i])) {
long long size = get_file_size(files.paths[i]);
if(size > 0)
total += size;
}
}
UnloadDirectoryFiles(files);
}
}
}
return total;
}
int
data_get_session_count(void)
{
int count = 0;
int year, month, day;
FilePathList files;
/* Count all session files */
for(year = 1970; year <= 2100; year++) {
char year_path[FS_PATH_MAX];
snprintf(year_path, sizeof(year_path), "%s/%04d", data_root(), year);
if(!DirectoryExists(year_path))
continue;
for(month = 1; month <= 12; month++) {
char month_path[FS_PATH_MAX];
snprintf(month_path, sizeof(month_path), "%s/%02d", year_path, month);
if(!DirectoryExists(month_path))
continue;
for(day = 1; day <= 31; day++) {
char day_path[FS_PATH_MAX];
snprintf(day_path, sizeof(day_path), "%s/%02d", month_path, day);
if(!DirectoryExists(day_path))
continue;
files = LoadDirectoryFiles(day_path);
for(unsigned int i = 0; i < files.count; i++) {
if(is_session_file(files.paths[i]))
count++;
}
UnloadDirectoryFiles(files);
}
}
}
return count;
}
long long
data_delete_all(void)
{
long long deleted = 0;
int year, month, day;
FilePathList files;
/* Delete all session files */
for(year = 1970; year <= 2100; year++) {
char year_path[FS_PATH_MAX];
snprintf(year_path, sizeof(year_path), "%s/%04d", data_root(), year);
if(!DirectoryExists(year_path))
continue;
for(month = 1; month <= 12; month++) {
char month_path[FS_PATH_MAX];
snprintf(month_path, sizeof(month_path), "%s/%02d", year_path, month);
if(!DirectoryExists(month_path))
continue;
for(day = 1; day <= 31; day++) {
char day_path[FS_PATH_MAX];
snprintf(day_path, sizeof(day_path), "%s/%02d", month_path, day);
if(!DirectoryExists(day_path))
continue;
files = LoadDirectoryFiles(day_path);
for(unsigned int i = 0; i < files.count; i++) {
if(is_session_file(files.paths[i])) {
if(FileExists(files.paths[i])) {
/* Delete the file */
#if defined(PLATFORM_WEB)
EM_ASM({
try {
FS.unlink(UTF8ToString($0));
} catch(e) {}
}, files.paths[i]);
#else
remove(files.paths[i]);
#endif
deleted++;
}
}
}
UnloadDirectoryFiles(files);
}
}
}
if(deleted > 0)
TraceLog(LOG_INFO, "DATA: deleted %lld session files", deleted);
return deleted;
}
int
data_export(const char *path)
{
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
/* On Android: use share sheet instead of file path */
(void)path;
return android_share_export("inbe-export.zip");
#else
mz_zip_archive archive;
FILE *fp;
void *zip_data;
size_t zip_size;
int year, month, day;
FilePathList files;
int session_count = 0;
char metadata[512];
time_t now;
struct tm *tm;
char date_str[64];
if(path == NULL || path[0] == '\0') {
TraceLog(LOG_ERROR, "DATA: export path is empty");
return 0;
}
/* Check if any data exists */
if(!data_has_any()) {
TraceLog(LOG_WARNING, "DATA: no data to export");
return 0;
}
/* Initialize ZIP archive */
memset(&archive, 0, sizeof(archive));
if(!mz_zip_writer_init_heap(&archive, 0, 0)) {
TraceLog(LOG_ERROR, "DATA: failed to initialize ZIP archive");
return 0;
}
session_count = data_get_session_count();
/* Create metadata file */
now = time(NULL);
tm = localtime(&now);
if(tm != NULL) {
snprintf(date_str, sizeof(date_str), "%04d-%02d-%02d %02d:%02d:%02d",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
} else {
strcpy(date_str, "Unknown");
}
snprintf(metadata, sizeof(metadata),
"Inner Breeze Data Export\n"
"Version: %s\n"
"Export Date: %s\n"
"Session Count: %d\n",
INBE_VERSION_STRING,
date_str,
session_count);
if(!mz_zip_writer_add_mem(&archive, "lotus-data/metadata.txt", metadata, strlen(metadata), MZ_NO_COMPRESSION)) {
TraceLog(LOG_ERROR, "DATA: failed to write metadata");
mz_zip_writer_end(&archive);
return 0;
}
/* Add all session files to ZIP */
for(year = 1970; year <= 2100; year++) {
char year_path[FS_PATH_MAX];
snprintf(year_path, sizeof(year_path), "%s/%04d", data_root(), year);
if(!DirectoryExists(year_path))
continue;
for(month = 1; month <= 12; month++) {
char month_path[FS_PATH_MAX];
snprintf(month_path, sizeof(month_path), "%s/%02d", year_path, month);
if(!DirectoryExists(month_path))
continue;
for(day = 1; day <= 31; day++) {
char day_path[FS_PATH_MAX];
snprintf(day_path, sizeof(day_path), "%s/%02d", month_path, day);
if(!DirectoryExists(day_path))
continue;
files = LoadDirectoryFiles(day_path);
for(unsigned int i = 0; i < files.count; i++) {
if(is_session_file(files.paths[i])) {
char *content;
char zip_path[FS_PATH_MAX];
const char *filename = GetFileName(files.paths[i]);
/* Build path inside ZIP */
snprintf(zip_path, sizeof(zip_path),
"lotus-data/sessions/%04d/%02d/%02d/%s",
year, month, day, filename);
/* Read file content */
content = LoadFileText(files.paths[i]);
if(content != NULL) {
size_t size = strlen(content);
if(!mz_zip_writer_add_mem(&archive, zip_path, content, size, MZ_NO_COMPRESSION)) {
TraceLog(LOG_WARNING, "DATA: failed to add file: %s", files.paths[i]);
}
UnloadFileText(content);
}
}
}
UnloadDirectoryFiles(files);
}
}
}
/* Finalize heap archive and get buffer */
if(!mz_zip_writer_finalize_heap_archive(&archive, &zip_data, &zip_size)) {
TraceLog(LOG_ERROR, "DATA: failed to finalize ZIP archive");
mz_zip_writer_end(&archive);
return 0;
}
if(zip_data == NULL || zip_size == 0) {
TraceLog(LOG_ERROR, "DATA: failed to get ZIP data");
mz_zip_writer_end(&archive);
return 0;
}
/* Write to file */
fp = fopen(path, "wb");
if(fp == NULL) {
TraceLog(LOG_ERROR, "DATA: failed to open export file: %s", path);
mz_zip_writer_end(&archive);
return 0;
}
if(fwrite(zip_data, 1, zip_size, fp) != zip_size) {
TraceLog(LOG_ERROR, "DATA: failed to write ZIP data");
fclose(fp);
mz_zip_writer_end(&archive);
return 0;
}
fclose(fp);
mz_zip_writer_end(&archive);
TraceLog(LOG_INFO, "DATA: exported %d sessions to %s", session_count, path);
return 1;
#endif
}
int
data_import(const char *path)
{
/* TODO: Implement ZIP import
* For now, this is a placeholder */
TraceLog(LOG_WARNING, "DATA: import not yet implemented");
(void)path;
return 0;
}
void
data_list_sessions(data_session_callback callback, void *user)
{
int year, month, day;
FilePathList files;
if(callback == NULL)
return;
/* Scan all directories and call callback for each session */
for(year = 1970; year <= 2100; year++) {
char year_path[FS_PATH_MAX];
snprintf(year_path, sizeof(year_path), "%s/%04d", data_root(), year);
if(!DirectoryExists(year_path))
continue;
for(month = 1; month <= 12; month++) {
char month_path[FS_PATH_MAX];
snprintf(month_path, sizeof(month_path), "%s/%02d", year_path, month);
if(!DirectoryExists(month_path))
continue;
for(day = 1; day <= 31; day++) {
char day_path[FS_PATH_MAX];
char date_str[16];
snprintf(day_path, sizeof(day_path), "%s/%02d", month_path, day);
if(!DirectoryExists(day_path))
continue;
snprintf(date_str, sizeof(date_str), "%04d-%02d-%02d",
year, month, day);
files = LoadDirectoryFiles(day_path);
for(unsigned int i = 0; i < files.count; i++) {
if(is_session_file(files.paths[i])) {
char time_str[16] = "00:00:00";
int best = 0;
int rounds;
/* Parse time from filename (inbe-HHMMSS) */
const char *filename = GetFileName(files.paths[i]);
if(strlen(filename) >= 10) {
snprintf(time_str, sizeof(time_str), "%c%c:%c%c:%c%c",
filename[5], filename[6],
filename[7], filename[8],
filename[9], filename[10]);
}
/* Analyze session file */
rounds = analyze_session_file(files.paths[i], &best);
/* Call callback */
callback(date_str, time_str, rounds, best, user);
}
}
UnloadDirectoryFiles(files);
}
}
}
}
#pragma GCC diagnostic pop
+22
View File
@@ -0,0 +1,22 @@
#ifndef DATA_H
#define DATA_H
#include <stddef.h>
#include "../libinbe/inbe.h"
void data_init(void);
const char *data_root(void);
const char *data_today_dir(void);
int data_save_session(const int *round_times, int round_count);
int data_has_any(void);
long long data_get_total_size(void);
int data_get_session_count(void);
long long data_delete_all(void);
int data_export(const char *path);
int data_import(const char *path);
typedef void (*data_session_callback)(const char *date, const char *time,
int rounds, int best, void *user);
void data_list_sessions(data_session_callback callback, void *user);
#endif
+136
View File
@@ -0,0 +1,136 @@
#include "file_dialog.h"
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#if defined(_WIN32)
/* Windows headers must be included first, before any raylib includes */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <shlobj.h>
#else
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#endif
/* Simple DirectoryExists implementation to avoid pulling in raylib.h */
/* Only used on Linux */
#if !defined(_WIN32) && !defined(__APPLE__)
static int DirectoryExists(const char *path)
{
struct stat st;
return (stat(path, &st) == 0 && S_ISDIR(st.st_mode));
}
#endif
void file_dialog_init(FileDialog *dlg)
{
if(dlg == NULL)
return;
dlg->active = 0;
dlg->mode = 0;
dlg->path[0] = '\0';
dlg->filename[0] = '\0';
dlg->cursor = 0;
}
static void get_default_export_path(char *path, size_t size, const char *filename)
{
(void)filename; /* Will use in the Windows path */
#if defined(_WIN32)
char home[MAX_PATH];
/* CSIDL_DOWNLOADS = 0x0006 */
if(SHGetFolderPathA(NULL, 0x0006, NULL, 0, home) == S_OK) {
snprintf(path, size, "%s\\%s", home, filename);
} else {
snprintf(path, size, "%s", filename);
}
#elif defined(__APPLE__)
const char *base = getenv("HOME");
if(base != NULL) {
snprintf(path, size, "%s/Downloads/%s", base, filename);
} else {
snprintf(path, size, "%s", filename);
}
#else
/* Linux and other Unix-like systems */
const char *base = getenv("HOME");
if(base != NULL) {
/* Try Downloads first, fall back to home */
char downloads[512];
snprintf(downloads, sizeof(downloads), "%s/Downloads", base);
if(DirectoryExists(downloads)) {
snprintf(path, size, "%s/%s", downloads, filename);
} else {
snprintf(path, size, "%s/%s", base, filename);
}
} else {
/* Fallback to current directory */
struct passwd *pw = getpwuid(getuid());
if(pw != NULL && pw->pw_dir != NULL) {
snprintf(path, size, "%s/%s", pw->pw_dir, filename);
} else {
snprintf(path, size, "%s", filename);
}
}
#endif
}
int file_dialog_save(FileDialog *dlg, const char *title, const char *default_filename)
{
char full_path[512];
time_t now;
struct tm *tm;
char date_str[32];
char generated_filename[128];
(void)title; /* Not used in simple implementation */
(void)default_filename; /* Will generate our own */
if(dlg == NULL)
return 0;
/* Generate filename with timestamp */
now = time(NULL);
tm = localtime(&now);
if(tm != NULL) {
snprintf(date_str, sizeof(date_str), "%04d-%02d-%02d",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday);
snprintf(generated_filename, sizeof(generated_filename),
"inbe-export-%s.zip", date_str);
} else {
strcpy(generated_filename, "inbe-export.zip");
}
/* Get default export path */
get_default_export_path(full_path, sizeof(full_path), generated_filename);
/* Store the path */
strncpy(dlg->path, full_path, sizeof(dlg->path) - 1);
dlg->path[sizeof(dlg->path) - 1] = '\0';
/* Extract filename for display */
const char *slash = strrchr(full_path, '/');
if(slash == NULL)
slash = strrchr(full_path, '\\');
if(slash != NULL) {
strncpy(dlg->filename, slash + 1, sizeof(dlg->filename) - 1);
} else {
strncpy(dlg->filename, generated_filename, sizeof(dlg->filename) - 1);
}
dlg->filename[sizeof(dlg->filename) - 1] = '\0';
/* Auto-confirm for simple implementation */
return 1;
}
const char *file_dialog_get_path(FileDialog *dlg)
{
if(dlg == NULL)
return NULL;
return dlg->path;
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef FILE_DIALOG_H
#define FILE_DIALOG_H
/* File dialog state */
typedef struct {
int active;
int mode; /* 0 = save, 1 = load */
char path[512];
char filename[128];
int cursor;
} FileDialog;
/* Initialize file dialog */
void file_dialog_init(FileDialog *dlg);
/* Show save file dialog
* dlg: Dialog state
* title: Dialog title
* default_filename: Suggested filename
* Returns: 1 if user confirmed, 0 if cancelled */
int file_dialog_save(FileDialog *dlg, const char *title, const char *default_filename);
/* Get the selected path
* dlg: Dialog state
* Returns: Full path to selected file */
const char *file_dialog_get_path(FileDialog *dlg);
#endif
+18 -3
View File
@@ -2,6 +2,12 @@
#include "app.h"
#include "android_insets.h"
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
#include <android/log.h>
#include <android_native_app_glue.h>
extern struct android_app *GetAndroidApp(void);
#endif
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -14,7 +20,9 @@ static InbeApp inbe_app;
#define INBE_ANDROID_BUILD 0
#endif
#if INBE_ANDROID_BUILD
static AndroidInsets insets;
#endif
static void
frame(void)
@@ -52,12 +60,14 @@ frame(void)
BeginDrawing();
ClearBackground(BLACK);
BeginScissorMode(content_x, content_y, content_width, content_height);
inbe_app_update_draw(&inbe_app, (Rectangle){
(float)content_x,
(float)content_y,
(float)content_width,
(float)content_height
});
EndScissorMode();
if(inbe_app.cursor_clickable)
SetMouseCursor(MOUSE_CURSOR_POINTING_HAND);
else
@@ -88,17 +98,22 @@ int main(int argc, char **argv) {
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(PLATFORM_WEB)
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
#endif
InitWindow(window_w, window_h, inbe_app_title());
#if INBE_ANDROID_BUILD
android_insets_init(); // MUST be first, before app init
if(!ChangeDirectory("/data/user/0/xyz.waozi.inbe/files"))
TraceLog(LOG_WARNING, "INBE: failed to switch to Android files directory");
android_insets_init();
#endif
InitWindow(window_w, window_h, inbe_app_title());
inbe_app_init(&inbe_app);
/* Apply fullscreen setting on startup */
#if INBE_ANDROID_BUILD
inbe_app.fullscreen_enabled = 0; // Force fullscreen off on Android
#endif
if(inbe_app.fullscreen_enabled && !IsWindowFullscreen())
ToggleFullscreen();
@@ -114,4 +129,4 @@ int main(int argc, char **argv) {
CloseWindow();
#endif
return 0;
}
}
+7909
View File
File diff suppressed because it is too large. Load diff
+1510
View File
File diff suppressed because it is too large. Load diff
+666
View File
@@ -0,0 +1,666 @@
#include "history_tab.h"
#include "app.h"
#include "data.h"
#include "ui.h"
#include "raylib.h"
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#define FS_PATH_MAX 512
/* Suppress GCC format-truncation warnings - paths are safely sized in practice */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
#define CONTENT_MAX_W 440
#define CONTENT_SIDE_PAD 16
#define SETTINGS_TITLE_H 60
#define TAB_BAR_H 54
#define ICON_SIZE_SMALL 16
#define ICON_SIZE_SMALL_MIN 14
#define ICON_SIZE_SMALL_MAX 18
/* Viewport dimensions - set by inbe_app_update_draw before calling draw functions */
extern int view_width;
extern int view_height;
/* Theme colors - set by ui_set_colors */
extern Color c_text, c_bg, c_circle, c_button, c_button_hover, c_icon;
/* ================================================================
* INTERNAL HELPER FUNCTIONS
* ================================================================ */
/* Check if a directory name consists only of digits */
static int
name_is_digits(const char *name, int len)
{
int i;
if(name == NULL)
return 0;
for(i = 0; i < len; i++) {
if(name[i] == '\0' || name[i] < '0' || name[i] > '9')
return 0;
}
return name[len] == '\0';
}
/* Compare two history entries for sorting (newest first) */
static int
compare_history_entries(const void *a, const void *b)
{
const HistoryEntry *ea = a;
const HistoryEntry *eb = b;
return strcmp(eb->path, ea->path);
}
/* Scan a day directory for session files */
static void
scan_history_day(HistoryEntry *entries, int *count, int year, int month, int day, const char *path)
{
DIR *dir = opendir(path);
struct dirent *ent;
char child[FS_PATH_MAX];
if(dir == NULL)
return;
while((ent = readdir(dir)) != NULL && *count < HISTORY_MAX_SESSIONS) {
if(ent->d_name[0] == '.')
continue;
snprintf(child, sizeof(child), "%s/%s", path, ent->d_name);
if(strncmp(ent->d_name, "inbe-", 5) == 0) {
/* Parse filename and add entry */
const char *name = ent->d_name;
int hh = 0, mm = 0, ss = 0;
if(sscanf(name, "inbe-%2d%2d%2d", &hh, &mm, &ss) == 3) {
HistoryEntry entry;
memset(&entry, 0, sizeof(entry));
snprintf(entry.path, sizeof(entry.path), "%s", child);
entry.year = year;
entry.month = month;
entry.day = day;
entry.hour = hh;
entry.minute = mm;
entry.second = ss;
history_load_session_file(child, &entry);
if(entry.round_count > 0) {
entries[*count] = entry;
(*count)++;
}
}
}
}
closedir(dir);
}
/* Scan entire history tree and populate entries array */
static void
scan_history_tree(HistoryEntry *entries, int *count)
{
DIR *years = opendir(data_root());
struct dirent *year;
char ypath[FS_PATH_MAX];
char mpath[FS_PATH_MAX];
char dpath[FS_PATH_MAX];
*count = 0;
if(years == NULL)
return;
while((year = readdir(years)) != NULL && *count < HISTORY_MAX_SESSIONS) {
if(!name_is_digits(year->d_name, 4))
continue;
snprintf(ypath, sizeof(ypath), "%s/%s", data_root(), year->d_name);
DIR *months = opendir(ypath);
struct dirent *month;
if(months == NULL)
continue;
while((month = readdir(months)) != NULL && *count < HISTORY_MAX_SESSIONS) {
if(!name_is_digits(month->d_name, 2))
continue;
snprintf(mpath, sizeof(mpath), "%s/%s", ypath, month->d_name);
DIR *days = opendir(mpath);
struct dirent *day;
if(days == NULL)
continue;
while((day = readdir(days)) != NULL && *count < HISTORY_MAX_SESSIONS) {
if(!name_is_digits(day->d_name, 2))
continue;
snprintf(dpath, sizeof(dpath), "%s/%s", mpath, day->d_name);
scan_history_day(entries, count, atoi(year->d_name), atoi(month->d_name), atoi(day->d_name), dpath);
}
closedir(days);
}
closedir(months);
}
closedir(years);
}
/* Check if history has entry for specific year */
static int
history_has_year(const HistoryEntry *entries, int count, int year)
{
for(int i = 0; i < count; i++) {
if(entries[i].year == year)
return 1;
}
return 0;
}
/* Check if history has entry for specific month */
static int
history_has_month(const HistoryEntry *entries, int count, int year, int month)
{
for(int i = 0; i < count; i++) {
if(entries[i].year == year && entries[i].month == month)
return 1;
}
return 0;
}
/* Check if history has entry for specific day */
static int
history_has_day_only(const HistoryEntry *entries, int count, int year, int month, int day)
{
for(int i = 0; i < count; i++) {
if(entries[i].year == year && entries[i].month == month && entries[i].day == day)
return 1;
}
return 0;
}
/* Count year rows in history */
static int
history_count_year_rows(const HistoryEntry *entries, int count)
{
int rows = 0;
int last_year = 0;
for(int i = 0; i < count; i++) {
if(i == 0 || entries[i].year != last_year) {
rows++;
last_year = entries[i].year;
}
}
return rows;
}
/* Count month rows for a specific year */
static int
history_count_month_rows(const HistoryEntry *entries, int count, int year)
{
int rows = 0;
int last_month = 0;
int seen = 0;
for(int i = 0; i < count; i++) {
if(entries[i].year != year)
continue;
if(!seen || entries[i].month != last_month) {
rows++;
last_month = entries[i].month;
seen = 1;
}
}
return rows;
}
/* Count day rows for a specific month */
static int
history_count_day_rows(const HistoryEntry *entries, int count, int year, int month)
{
int rows = 0;
int last_day = 0;
int seen = 0;
for(int i = 0; i < count; i++) {
if(entries[i].year != year || entries[i].month != month)
continue;
if(!seen || entries[i].day != last_day) {
rows++;
last_day = entries[i].day;
seen = 1;
}
}
return rows;
}
/* Count session records for a specific day */
static int
history_count_record_rows(const HistoryEntry *entries, int count, int year, int month, int day)
{
int rows = 0;
for(int i = 0; i < count; i++) {
if(entries[i].year == year && entries[i].month == month && entries[i].day == day)
rows++;
}
return rows;
}
/* Format round label (e.g., "R1 45s") */
static void
history_format_round_label(const HistoryEntry *entry, int round_index, char *out, int out_size)
{
if(out == NULL || out_size <= 0)
return;
if(round_index >= 0 && round_index < entry->round_count)
snprintf(out, (size_t)out_size, "R%d %ds", round_index + 1, entry->rounds[round_index]);
else
snprintf(out, (size_t)out_size, "R%d", round_index + 1);
}
/* Draw a clickable history row */
static int
draw_history_row(InbeApp *app, int x, int y, int w, int h, const char *text, int selected, int indent)
{
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
int mx = (int)mouse_world.x;
int my = (int)mouse_world.y;
int hover = 0;
if(mx > x && mx < x + w && my > y && my < y + h) {
DrawRectangle(x, y, w, h, selected ? c_button_hover : ui_darken(c_button_hover, 6));
ui_draw_bevel(x, y, w, h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
hover = 1;
app->cursor_clickable = 1;
if(IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
ui_draw_bevel(x, y, w, h, ui_lighten(c_button_hover, 40), ui_darken(c_button_hover, 40));
}
} else {
DrawRectangle(x, y, w, h, selected ? c_button : ui_darken(c_bg, 6));
ui_draw_bevel(x, y, w, h, ui_lighten(c_button, 28), ui_darken(c_button, 20));
}
DrawText(text, x + ui_px(indent), y + ui_px(6), ui_clamp_px(14, 12, 16), c_text);
return hover && IsMouseButtonReleased(MOUSE_BUTTON_LEFT);
}
/* Draw a history session row with trash icon */
static int
draw_history_session_row(InbeApp *app, int x, int y, int w, int h, const char *text, int selected)
{
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
int mx = (int)mouse_world.x;
int my = (int)mouse_world.y;
int hover = 0;
int icon_size = ui_clamp_px(ICON_SIZE_SMALL, ICON_SIZE_SMALL_MIN, ICON_SIZE_SMALL_MAX);
int font = ui_clamp_px(14, 12, 16);
(void)font;
if(mx > x && mx < x + w && my > y && my < y + h) {
DrawRectangle(x, y, w, h, selected ? c_button_hover : ui_darken(c_button_hover, 6));
ui_draw_bevel(x, y, w, h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
hover = 1;
app->cursor_clickable = 1;
if(IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
ui_draw_bevel(x, y, w, h, ui_lighten(c_button_hover, 40), ui_darken(c_button_hover, 40));
}
} else {
DrawRectangle(x, y, w, h, selected ? c_button : ui_darken(c_bg, 6));
ui_draw_bevel(x, y, w, h, ui_lighten(c_button, 28), ui_darken(c_button, 20));
}
DrawText(text, x + ui_px(46), y + ui_px(6), font, c_text);
if(app->x_icon.id != 0) {
int trash_x = x + w - icon_size - ui_px(8);
int trash_y = y + (h - icon_size) / 2;
Rectangle src = {0, 0, app->x_icon.width, app->x_icon.height};
Rectangle dst = {trash_x, trash_y, (float)icon_size, (float)icon_size};
if(mx > trash_x && mx < trash_x + icon_size && my > trash_y && my < trash_y + icon_size) {
app->cursor_clickable = 1;
DrawTexturePro(app->x_icon, src, dst, (Vector2){0}, 0, ui_darken(c_icon, 30));
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
return 2;
} else {
DrawTexturePro(app->x_icon, src, dst, (Vector2){0}, 0, c_icon);
}
}
if(hover && IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
return 1;
return 0;
}
/* ================================================================
* PUBLIC API
* ================================================================ */
void
history_tab_on_click(void *user_data)
{
InbeApp *app = user_data;
history_open_latest(app);
app->inbe.screen = InbeScreenHistory;
}
void
history_open_latest(InbeApp *app)
{
HistoryEntry entries[HISTORY_MAX_SESSIONS];
int count = 0;
time_t now;
struct tm *tm;
scan_history_tree(entries, &count);
qsort(entries, (size_t)count, sizeof(entries[0]), compare_history_entries);
if(count > 0) {
now = time(NULL);
tm = localtime(&now);
if(tm != NULL) {
for(int i = 0; i < count; i++) {
if(entries[i].year == tm->tm_year + 1900 &&
entries[i].month == tm->tm_mon + 1 &&
entries[i].day == tm->tm_mday) {
app->history_year = entries[i].year;
app->history_month = entries[i].month;
app->history_day = entries[i].day;
app->history_level = 2;
app->history_record[0] = 0;
app->history_scroll = 0;
return;
}
}
}
app->history_year = entries[0].year;
app->history_month = entries[0].month;
app->history_day = entries[0].day;
app->history_level = 2;
app->history_record[0] = 0;
app->history_scroll = 0;
return;
}
now = time(NULL);
tm = localtime(&now);
if(tm != NULL) {
app->history_year = tm->tm_year + 1900;
app->history_month = tm->tm_mon + 1;
app->history_day = tm->tm_mday;
} else {
app->history_year = 0;
app->history_month = 0;
app->history_day = 0;
}
app->history_level = 0;
history_clear_record_selection(app);
app->history_scroll = 0;
}
void
history_load_session_file(const char *path, HistoryEntry *entry)
{
FILE *file;
int value;
int total = 0;
int count = 0;
if(entry == NULL)
return;
entry->round_count = 0;
entry->avg_seconds = 0;
for(int i = 0; i < MaxRounds; i++)
entry->rounds[i] = 0;
file = fopen(path, "r");
if(file == NULL)
return;
while(count < MaxRounds && fscanf(file, "%d", &value) == 1) {
entry->rounds[count] = value;
total += value;
count++;
}
fclose(file);
entry->round_count = count;
if(count > 0)
entry->avg_seconds = total / count;
}
void
history_clear_record_selection(InbeApp *app)
{
app->history_record[0] = 0;
}
void
history_format_session_label(const HistoryEntry *entry, char *out, size_t out_size)
{
if(out == NULL || out_size == 0)
return;
snprintf(out, out_size, "%02d:%02d avg %ds",
entry->hour, entry->minute, entry->avg_seconds);
}
void
history_tab_draw(InbeApp *app)
{
HistoryEntry entries[HISTORY_MAX_SESSIONS];
int count = 0;
int title_h = ui_screen_header_height();
int tab_h = ui_clamp_px(TAB_BAR_H, 54, 66);
int viewport_h = view_height - title_h - tab_h;
int row_h = ui_clamp_px(28, 24, 32);
int content_rows = 0;
int content_h = 0;
int max_scroll;
int close_clicked = 0;
int y;
int has_year = 0;
int has_month = 0;
int has_day = 0;
int selected_index = -1;
int content_x;
int content_w;
scan_history_tree(entries, &count);
qsort(entries, (size_t)count, sizeof(entries[0]), compare_history_entries);
if(count > 0) {
if(app->history_level <= 0 || app->history_year == 0) {
history_open_latest(app);
} else if(app->history_level == 1 && !history_has_year(entries, count, app->history_year)) {
history_open_latest(app);
} else if(app->history_level == 2 && !history_has_month(entries, count, app->history_year, app->history_month)) {
history_open_latest(app);
} else if(app->history_level >= 3 &&
!history_has_day_only(entries, count, app->history_year, app->history_month, app->history_day)) {
history_open_latest(app);
}
}
has_year = history_has_year(entries, count, app->history_year);
has_month = history_has_month(entries, count, app->history_year, app->history_month);
has_day = history_has_day_only(entries, count, app->history_year, app->history_month, app->history_day);
if(count > 0 && has_day && app->history_level >= 3) {
for(int i = 0; i < count; i++) {
char record_name[16];
if(entries[i].year != app->history_year ||
entries[i].month != app->history_month ||
entries[i].day != app->history_day)
continue;
snprintf(record_name, sizeof(record_name), "inbe-%02d%02d%02d",
entries[i].hour, entries[i].minute, entries[i].second);
if(strcmp(app->history_record, record_name) == 0) {
selected_index = i;
break;
}
}
}
content_rows = history_count_year_rows(entries, count);
if(count > 0 && has_year && app->history_level >= 1) {
content_rows += history_count_month_rows(entries, count, app->history_year);
if(has_month && app->history_level >= 2) {
content_rows += history_count_day_rows(entries, count, app->history_year, app->history_month);
if(has_day && app->history_level >= 3) {
content_rows += history_count_record_rows(entries, count,
app->history_year, app->history_month,
app->history_day);
if(selected_index >= 0)
content_rows += entries[selected_index].round_count;
}
}
}
content_h = count > 0 ? count * row_h + 18 : viewport_h;
if(content_rows > 0)
content_h = 18 + content_rows * row_h;
max_scroll = content_h - viewport_h;
if(max_scroll < 0)
max_scroll = 0;
app->history_scroll -= (int)(GetMouseWheelMove() * 24.0f);
app->history_scroll = (app->history_scroll < 0) ? 0 : (app->history_scroll > max_scroll ? max_scroll : app->history_scroll);
ui_centered_column(CONTENT_MAX_W, CONTENT_SIDE_PAD, &content_x, &content_w);
close_clicked = ui_draw_screen_header(app, "History", 1);
if(close_clicked) {
app->inbe.screen = InbeScreenStart;
app->history_scroll = 0;
}
BeginScissorMode((int)app->camera.offset.x,
(int)(app->camera.offset.y + title_h * app->camera.zoom),
(int)(view_width * app->camera.zoom),
(int)(viewport_h * app->camera.zoom));
y = title_h + ui_px(12) - app->history_scroll;
if(count == 0) {
DrawText("No saved sessions yet.", content_x, y, ui_clamp_px(14, 12, 16), c_text);
DrawText("Complete a session to add data.", content_x, y + ui_px(22), ui_clamp_px(14, 12, 16), c_text);
} else {
int year = -1;
int month = -1;
int day = -1;
for(int i = 0; i < count; i++) {
char label[HISTORY_TEXT_SIZE];
if(entries[i].year != year) {
int selected = app->history_year == entries[i].year && app->history_level >= 1;
snprintf(label, sizeof(label), "%04d", entries[i].year);
if(draw_history_row(app, content_x, y, content_w, row_h, label, selected, 10)) {
app->history_year = entries[i].year;
app->history_month = 0;
app->history_day = 0;
history_clear_record_selection(app);
app->history_level = 1;
app->history_scroll = 0;
}
y += row_h;
year = entries[i].year;
month = -1;
day = -1;
}
if(app->history_level < 1 || entries[i].year != app->history_year)
continue;
if(entries[i].month != month) {
int selected = app->history_month == entries[i].month && app->history_level >= 2;
snprintf(label, sizeof(label), "Month %02d", entries[i].month);
if(draw_history_row(app, content_x, y, content_w, row_h, label, selected, 22)) {
app->history_month = entries[i].month;
app->history_day = 0;
history_clear_record_selection(app);
app->history_level = 2;
app->history_scroll = 0;
}
y += row_h;
month = entries[i].month;
day = -1;
}
if(app->history_level < 2 || entries[i].month != app->history_month)
continue;
if(entries[i].day != day) {
int selected = app->history_day == entries[i].day && app->history_level >= 3;
snprintf(label, sizeof(label), "Day %02d", entries[i].day);
if(draw_history_row(app, content_x, y, content_w, row_h, label, selected, 34)) {
app->history_day = entries[i].day;
history_clear_record_selection(app);
app->history_level = 3;
app->history_scroll = 0;
}
y += row_h;
day = entries[i].day;
}
if(app->history_level < 3 || entries[i].day != app->history_day)
continue;
{
char time_label[HISTORY_TEXT_SIZE];
char record_name[16];
int selected;
int result;
snprintf(record_name, sizeof(record_name), "inbe-%02d%02d%02d",
entries[i].hour, entries[i].minute, entries[i].second);
history_format_session_label(&entries[i], time_label, sizeof(time_label));
selected = strcmp(app->history_record, record_name) == 0;
result = draw_history_session_row(app, content_x, y, content_w, row_h, time_label, selected);
if(result == 1) {
snprintf(app->history_record, sizeof(app->history_record), "inbe-%02d%02d%02d",
entries[i].hour, entries[i].minute, entries[i].second);
app->history_level = 3;
selected_index = i;
} else if(result == 2) {
char dir_day[FS_PATH_MAX];
char path[FS_PATH_MAX];
snprintf(dir_day, sizeof(dir_day), "%s/%04d/%02d/%02d",
data_root(), entries[i].year, entries[i].month, entries[i].day);
snprintf(path, sizeof(path), "%s/%s", dir_day, record_name);
remove(path);
scan_history_tree(entries, &count);
qsort(entries, (size_t)count, sizeof(entries[0]), compare_history_entries);
selected_index = -1;
app->history_record[0] = 0;
if(count == 0) {
app->history_level = 0;
app->history_year = 0;
app->history_month = 0;
app->history_day = 0;
}
}
y += row_h;
if(selected_index == i) {
for(int r = 0; r < entries[i].round_count; r++) {
char round_label[HISTORY_TEXT_SIZE];
history_format_round_label(&entries[i], r, round_label, sizeof(round_label));
if(draw_history_row(app, content_x, y, content_w, row_h, round_label, 0, 46)) {
/* Round clicked - could do something here */
}
y += row_h;
}
}
}
}
}
EndScissorMode();
/* Draw scrollbar if needed */
if(max_scroll > 0) {
int scrollbar_w = ui_clamp_px(6, 4, 8);
int scrollbar_h = (viewport_h * viewport_h) / (content_h + viewport_h);
int scrollbar_x = content_x + content_w + ui_px(10);
int scrollbar_y = title_h + (app->history_scroll * (viewport_h - scrollbar_h)) / max_scroll;
DrawRectangle(scrollbar_x, scrollbar_y, scrollbar_w, scrollbar_h, ui_darken(c_text, 40));
}
}
#pragma GCC diagnostic pop
+49
View File
@@ -0,0 +1,49 @@
#ifndef HISTORY_TAB_H
#define HISTORY_TAB_H
#include <stddef.h>
#include "../libinbe/inbe.h"
typedef struct InbeApp InbeApp;
/* History constants */
enum {
HISTORY_MAX_SESSIONS = 48,
HISTORY_PATH_SIZE = 512,
HISTORY_TEXT_SIZE = 96,
};
/* History entry structure */
typedef struct HistoryEntry {
char path[HISTORY_PATH_SIZE];
int year;
int month;
int day;
int hour;
int minute;
int second;
int round_count;
int best;
int avg_seconds;
int rounds[MaxRounds];
} HistoryEntry;
/* Draw the history tab */
void history_tab_draw(InbeApp *app);
/* Handle tab click - switch to history screen */
void history_tab_on_click(void *user_data);
/* Open the latest session in history viewer */
void history_open_latest(InbeApp *app);
/* Load a session file and populate a history entry */
void history_load_session_file(const char *path, HistoryEntry *entry);
/* Clear the record selection in history viewer */
void history_clear_record_selection(InbeApp *app);
/* Format session label for display (e.g., "14:30 5 rounds 45s") */
void history_format_session_label(const HistoryEntry *entry, char *out, size_t out_size);
#endif
+230
View File
@@ -0,0 +1,230 @@
#include "manual_tab.h"
#include "app.h"
#include "ui.h"
#include "theme_meta.h"
#include "raylib.h"
#include <stdio.h>
#define CONTENT_MAX_W 600
#define CONTENT_SIDE_PAD 20
extern int view_width;
extern int view_height;
extern Color c_text, c_bg, c_circle, c_button, c_button_hover, c_icon;
void
manual_tab_close_tutorial(InbeApp *app, int mark_seen)
{
if(mark_seen && !app->tutorial_seen) {
app->tutorial_seen = 1;
save_settings(app);
}
app->tutorial_step = 0;
app->manual_scroll = 0;
app->inbe.screen = InbeScreenStart;
}
void
manual_tab_draw(InbeApp *app)
{
int title_h = ui_screen_header_height();
int tab_h = ui_clamp_px(54, 54, 66);
int viewport_h = view_height - title_h - tab_h;
int content_h = 430;
int body_font = ui_clamp_px(13, 11, 14);
int previous_step;
int max_scroll;
int content_x;
int content_w;
const char *title = "Tutorial";
int footer_y = view_height - ui_px(38);
int footer_mid_y = footer_y + ui_px(7);
char page_label[16];
int close_clicked = 0;
app->tutorial_step = clampi(app->tutorial_step, 0, TUTORIAL_STEPS - 1);
previous_step = app->tutorial_step;
if(IsKeyPressed(KEY_RIGHT) || IsKeyPressed(KEY_ENTER)) {
if(app->tutorial_step < TUTORIAL_STEPS - 1)
app->tutorial_step++;
else
manual_tab_close_tutorial(app, 1);
}
if(IsKeyPressed(KEY_LEFT) && app->tutorial_step > 0)
app->tutorial_step--;
if(IsKeyPressed(KEY_ESCAPE))
manual_tab_close_tutorial(app, 1);
if(previous_step != app->tutorial_step) {
app->manual_scroll = 0;
previous_step = app->tutorial_step;
}
switch(app->tutorial_step) {
case 1: title = "Method"; content_h = 275; break;
case 2: title = "Step 1: In & Out"; content_h = 315; break;
case 3: title = "Step 2: Exhale & Hold"; content_h = 205; break;
case 4: title = "Step 3: Inhale & Hold"; content_h = 440; break;
default: break;
}
max_scroll = ui_px(content_h) - viewport_h;
if(max_scroll < 0)
max_scroll = 0;
app->manual_scroll -= (int)(GetMouseWheelMove() * 24.0f);
app->manual_scroll = clampi(app->manual_scroll, 0, max_scroll);
ui_centered_column(CONTENT_MAX_W, CONTENT_SIDE_PAD, &content_x, &content_w);
close_clicked = ui_draw_screen_header(app, title, 1);
if(close_clicked)
manual_tab_close_tutorial(app, 1);
BeginScissorMode((int)app->camera.offset.x,
(int)(app->camera.offset.y + title_h * app->camera.zoom),
(int)(view_width * app->camera.zoom),
(int)(viewport_h * app->camera.zoom));
int y = title_h + ui_px(16) - app->manual_scroll;
if(app->tutorial_step == 0) {
const char *lines[] = {
"This breathing practice is based on",
"the Wim Hof Method.",
"",
"It can be powerful. Use it with care.",
"",
"Practice sitting or lying down.",
"Never use it while driving,",
"standing, or in water."
};
int img_h = ui_px(240);
ui_draw_tutorial_image(app->angel_image, "angel.jpg", content_x, y, content_w, img_h);
y += img_h + ui_px(22);
ui_draw_text_lines(lines, 8, content_x, &y, body_font, ui_px(20));
} else if(app->tutorial_step == 1) {
const char *lines[] = {
"Simply follow 4 steps:",
"",
"1. Breathe rhythmically.",
"2. Exhale and hold.",
"3. Inhale deeply and hold.",
"4. Exhale and repeat."
};
ui_draw_text_lines(lines, 6, content_x, &y, body_font, ui_px(19));
y += ui_px(12);
const char *before_gear = "Use the gear icon";
DrawText(before_gear, content_x, y, body_font, c_text);
if(app->gear_icon.id != 0) {
int icon_size = ui_px(14);
int gear_y = y - icon_size / 2 + ui_px(5);
int gear_x = content_x + MeasureText(before_gear, body_font) + ui_px(4);
Rectangle src = {0, 0, app->gear_icon.width, app->gear_icon.height};
Rectangle dst = {gear_x, gear_y, icon_size, icon_size};
DrawTexturePro(app->gear_icon, src, dst, (Vector2){0}, 0, c_icon);
}
const char *after_gear = " to adjust rounds,";
DrawText(after_gear, content_x + MeasureText(before_gear, body_font) + ui_px(4) + ui_px(14) + ui_px(4), y, body_font, c_text);
y += ui_px(19);
const char *settings_lines2[] = {
"breaths, speed, and pauses."
};
ui_draw_text_lines(settings_lines2, 1, content_x, &y, body_font, ui_px(19));
} else if(app->tutorial_step == 2) {
int speed = app->inbe.speed_level;
const char *lines[] = {
"Fill your lungs fully, then",
"let the breath flow out.",
"",
"Use this slider to set the",
"pace of the breathing circle."
};
ui_draw_text_lines(lines, 5, content_x, &y, body_font, ui_px(19));
y += ui_px(8);
update_preview_bounds(&app->settings_preview, content_w, ui_px(132));
apply_settings(&app->settings_preview, speed, app->inbe.max_rounds,
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
inbestep(&app->settings_preview);
if(app->settings_preview.phase != InbePhaseBreathe) {
reset_settings_preview(app);
update_preview_bounds(&app->settings_preview, content_w, ui_px(132));
apply_settings(&app->settings_preview, speed, app->inbe.max_rounds,
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
}
draw_preview_inbe(&app->settings_preview, content_x + content_w / 2, y + ui_px(40));
y += (int)(app->settings_preview.rmax * 0.72f) + ui_px(54);
if(ui_draw_slider(app, 10, content_x, y, content_w, "Speed", SETTINGS_SPEED_MIN,
SETTINGS_SPEED_MAX, &speed, "")) {
apply_settings(&app->inbe, speed, app->inbe.max_rounds,
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
apply_settings(&app->settings_preview, speed, app->inbe.max_rounds,
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
app->settings_dirty = 1;
}
} else if(app->tutorial_step == 3) {
const char *lines[] = {
"After the breathing round,",
"exhale normally and hold.",
"",
"Release when your body asks",
"for air. Do not force it."
};
ui_draw_text_lines(lines, 5, content_x, &y, body_font, ui_px(20));
} else {
const char *lines[] = {
"Inhale fully and hold for",
"about 15 seconds.",
"",
"Then exhale and begin the",
"next round. Over time, each",
"round may feel deeper."
};
int img_h = ui_px(250);
ui_draw_tutorial_image(app->begin_image, "begin.jpg", content_x, y, content_w, img_h);
y += img_h + ui_px(22);
ui_draw_text_lines(lines, 6, content_x, &y, body_font, ui_px(20));
}
EndScissorMode();
snprintf(page_label, sizeof(page_label), "%d/%d", app->tutorial_step + 1, TUTORIAL_STEPS);
DrawText(page_label,
view_width / 2 - MeasureText(page_label, ui_clamp_px(14, 14, 16)) / 2,
footer_mid_y, ui_clamp_px(14, 14, 16), c_text);
int left_hover = 0;
int right_hover = 0;
int button_pad = ui_px(48);
if(app->tutorial_step == 0) {
if(ui_draw_text_btn(app, content_x + button_pad, footer_y, "SKIP", &left_hover))
manual_tab_close_tutorial(app, 1);
} else {
if(ui_draw_text_btn(app, content_x + button_pad, footer_y, "BACK", &left_hover)) {
app->tutorial_step--;
app->manual_scroll = 0;
}
}
if(ui_draw_text_btn(app, content_x + content_w - button_pad, footer_y,
app->tutorial_step == TUTORIAL_STEPS - 1 ? "FINISH" : "NEXT", &right_hover)) {
if(app->tutorial_step == TUTORIAL_STEPS - 1)
manual_tab_close_tutorial(app, 1);
else {
app->tutorial_step++;
app->manual_scroll = 0;
}
}
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
app->settings_drag_slider = 0;
if(app->settings_dirty)
save_settings(app);
}
}
+14
View File
@@ -0,0 +1,14 @@
#ifndef MANUAL_TAB_H
#define MANUAL_TAB_H
#include "../libinbe/inbe.h"
typedef struct InbeApp InbeApp;
/* Draw the manual/tutorial screen */
void manual_tab_draw(InbeApp *app);
/* Close the tutorial, optionally marking it as seen */
void manual_tab_close_tutorial(InbeApp *app, int mark_seen);
#endif
+450
View File
@@ -0,0 +1,450 @@
#include "settings_tab.h"
#include "app.h"
#include "ui.h"
#include "theme.h"
#include "theme_meta.h"
#include "version.h"
#include "data.h"
#include "file_dialog.h"
#include "raylib.h"
#include <stdio.h>
#include <string.h>
/* Theme colors - set by ui_set_colors */
extern Color c_text, c_bg, c_circle, c_button, c_button_hover, c_icon;
#define CONTENT_MAX_W 600
#define CONTENT_SIDE_PAD 20
static const char *settings_tab_names[] = {
"Breathing",
"Session",
"Appearance",
"Data",
"About"
};
extern int view_width;
extern int view_height;
static void
draw_theme_selector(InbeApp *app, int x, int y, int w)
{
int font = ui_clamp_px(14, 12, 16);
int small_font = ui_clamp_px(12, 10, 14);
const char *label = "Theme";
DrawText(label, x, y, font, c_text);
/* Light/Dark toggle */
int toggle_w = ui_px(100);
int toggle_h = ui_px(28);
int toggle_x = x + w - toggle_w;
int toggle_y = y - 2;
if(ui_draw_toggle_switch(app, toggle_x, toggle_y, toggle_w, toggle_h, &app->dark_mode)) {
refresh_theme_colors(app->theme_id, app->dark_mode);
app->settings_dirty = 1;
}
int circle_size = ui_px(36);
int circle_spacing = ui_px(24);
int row_spacing = ui_px(36);
int per_row = 3;
int row_width = per_row * circle_size + (per_row - 1) * circle_spacing;
int start_x = x + (w - row_width) / 2;
int circle_y = y + ui_px(64);
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
for(int i = 0; i < THEME_COUNT; i++) {
int row = i / per_row;
int col = i % per_row;
int cx = start_x + col * (circle_size + circle_spacing) + circle_size / 2;
int cy = circle_y + row * (circle_size + row_spacing);
/* Draw circle - get color from Lotus */
const char *scope = app->dark_mode ? g_themes[i].dark_scope : g_themes[i].light_scope;
Color theme_color = theme_get(scope, "circle");
DrawCircle(cx, cy, circle_size / 2, theme_color);
/* Draw selection ring */
if(app->theme_id == i) {
DrawCircleLines(cx, cy, circle_size / 2 + 2, c_text);
} else {
DrawCircleLines(cx, cy, circle_size / 2 + 1, ui_darken(c_bg, 30));
}
/* Check for click */
Rectangle bounds = {cx - circle_size / 2 - 4, cy - circle_size / 2 - 4, circle_size + 8, circle_size + 8};
if(CheckCollisionPointRec(mouse_world, bounds) && IsMouseButtonPressed(MOUSE_BUTTON_LEFT) &&
!ui_dropdown_captures_click(mouse_world)) {
app->theme_id = i;
refresh_theme_colors(app->theme_id, app->dark_mode);
app->settings_dirty = 1;
}
if(CheckCollisionPointRec(mouse_world, bounds))
app->cursor_clickable = 1;
/* Draw theme name below */
const char *name = g_themes[i].name;
int name_w = MeasureText(name, small_font);
DrawText(name, cx - name_w / 2, cy + circle_size / 2 + ui_px(6), small_font, c_text);
}
}
void
settings_tab_draw(InbeApp *app)
{
int title_h = ui_screen_header_height();
int viewport_h = view_height - title_h;
int close_clicked = 0;
int content_x;
int content_w;
static FileDialog export_dlg;
static int export_dlg_initialized = 0;
static char export_result[128] = ""; /* Store export result message */
ui_centered_column(CONTENT_MAX_W, CONTENT_SIDE_PAD, &content_x, &content_w);
/* Reset slider drag state when mouse is released */
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
app->settings_drag_slider = 0;
}
close_clicked = ui_draw_screen_header(app, "Settings", 1);
if(close_clicked) {
if(app->settings_dirty)
save_settings(app);
app->inbe.screen = InbeScreenStart;
}
/* Initialize export dialog on first call */
if(!export_dlg_initialized) {
file_dialog_init(&export_dlg);
export_dlg_initialized = 1;
}
/* Dropdown for tab selection */
int dropdown_h = ui_px(36);
int dropdown_y = title_h + ui_px(8);
BeginScissorMode((int)app->camera.offset.x,
(int)(app->camera.offset.y + title_h * app->camera.zoom),
(int)(view_width * app->camera.zoom),
(int)(viewport_h * app->camera.zoom));
if(ui_draw_dropdown_button(app, 100, content_x, dropdown_y, content_w, dropdown_h, settings_tab_names, SETTINGS_TAB_COUNT, &app->settings_tab)) {
reset_settings_preview(app);
}
int yoff = ui_px(16);
int speed = app->inbe.speed_level;
int max_rounds = app->inbe.max_rounds;
int max_breaths = int_from_count(app->inbe.maxbreaths);
int pause_seconds = app->inbe.pause_seconds;
/* Update preview for breathing tab */
update_preview_bounds(&app->settings_preview, content_w, ui_px(240));
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
inbestep(&app->settings_preview);
if(app->settings_preview.phase != InbePhaseBreathe) {
reset_settings_preview(app);
update_preview_bounds(&app->settings_preview, content_w, ui_px(240));
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
}
/* Content starts after dropdown */
int content_start_y = dropdown_y + dropdown_h;
switch(app->settings_tab) {
case SETTINGS_TAB_BREATHING: {
draw_preview_inbe(&app->settings_preview, content_x + content_w / 2, yoff + content_start_y + ui_px(100));
if(ui_draw_slider(app, 1, content_x, yoff + content_start_y + ui_px(200), content_w, "Speed", SETTINGS_SPEED_MIN, SETTINGS_SPEED_MAX, &speed, "")) {
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
app->settings_dirty = 1;
}
break;
}
case SETTINGS_TAB_SESSION: {
int slider_y = yoff + content_start_y + ui_px(20);
/* Max rounds */
if(ui_draw_slider(app, 2, content_x, slider_y, content_w, "Max rounds", 1,
MaxRounds, &max_rounds, "")) {
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
app->settings_dirty = 1;
}
/* Max breaths */
if(ui_draw_slider(app, 3, content_x, slider_y + ui_px(66), content_w, "Max breaths", SETTINGS_BREATHS_MIN,
SETTINGS_BREATHS_MAX, &max_breaths, "")) {
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
app->settings_dirty = 1;
}
/* Pause */
if(ui_draw_slider(app, 4, content_x, slider_y + ui_px(132), content_w, "Pause after round", SETTINGS_PAUSE_MIN,
SETTINGS_PAUSE_MAX, &pause_seconds, "s")) {
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
app->settings_dirty = 1;
}
/* Volume */
int sound_volume = app->sound_volume;
if(ui_draw_slider(app, 6, content_x, slider_y + ui_px(198), content_w, "Volume", SETTINGS_VOLUME_MIN,
SETTINGS_VOLUME_MAX, &sound_volume, "")) {
app->sound_volume = sound_volume;
app->settings_dirty = 1;
}
/* Reset to defaults button */
int reset_y = slider_y + ui_px(265);
int reset_w = MeasureText("Reset to defaults", ui_clamp_px(14, 12, 16)) + ui_px(24);
int reset_h = ui_px(36);
int reset_x = content_x + content_w - reset_w;
int reset_hover = 0;
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
Rectangle reset_bounds = {reset_x, reset_y, reset_w, reset_h};
if(CheckCollisionPointRec(mouse_world, reset_bounds)) {
DrawRectangle(reset_x, reset_y, reset_w, reset_h, c_button_hover);
ui_draw_bevel(reset_x, reset_y, reset_w, reset_h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
reset_hover = 1;
app->cursor_clickable = 1;
} else {
DrawRectangle(reset_x, reset_y, reset_w, reset_h, c_button);
ui_draw_bevel(reset_x, reset_y, reset_w, reset_h, ui_lighten(c_button, 40), ui_darken(c_button, 40));
}
int reset_font = ui_clamp_px(14, 12, 16);
DrawText("Reset to defaults", reset_x + ui_px(12), reset_y + reset_h / 2 - reset_font / 2 - 1, reset_font, c_text);
if(reset_hover && IsMouseButtonReleased(MOUSE_BUTTON_LEFT) &&
!ui_dropdown_captures_click(mouse_world)) {
/* Reset to default values */
speed = 6;
max_rounds = DefaultMaxRounds;
max_breaths = DefaultMaxBreaths;
pause_seconds = DefaultPauseSeconds;
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
app->settings_dirty = 1;
}
break;
}
case SETTINGS_TAB_APPEARANCE: {
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(PLATFORM_WEB)
int checkbox_y = yoff + content_start_y;
if(ui_draw_checkbox_toggle(app, content_x, checkbox_y, "Fullscreen", &app->fullscreen_enabled)) {
if(app->fullscreen_enabled && !IsWindowFullscreen())
ToggleFullscreen();
else if(!app->fullscreen_enabled && IsWindowFullscreen())
ToggleFullscreen();
app->settings_dirty = 1;
}
/* Theme selector - below fullscreen */
int theme_y = yoff + content_start_y + ui_px(50);
#else
int theme_y = yoff + content_start_y;
#endif
draw_theme_selector(app, content_x, theme_y, content_w);
int font = ui_clamp_px(14, 12, 16);
int label_y = theme_y + ui_px(220);
DrawText("Language", content_x, label_y, font, c_text);
DrawText("Coming soon...", content_x, label_y + ui_px(30), font, ui_darken(c_text, 40));
break;
}
case SETTINGS_TAB_DATA: {
int font = ui_clamp_px(14, 12, 16);
int text_y = yoff + content_start_y;
int session_count = data_get_session_count();
long long data_size = data_get_total_size();
char size_str[32];
int hover_export = 0;
int hover_delete = 0;
/* Format data size */
if(data_size < 1024)
snprintf(size_str, sizeof(size_str), "%lld B", data_size);
else if(data_size < 1024 * 1024)
snprintf(size_str, sizeof(size_str), "%.1f KB", (float)data_size / 1024);
else
snprintf(size_str, sizeof(size_str), "%.1f MB", (float)data_size / (1024 * 1024));
/* Title */
DrawText("Data Management", content_x, text_y, font, c_text);
text_y += ui_px(30);
/* Statistics box */
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID)
int stats_box_h = ui_px(90);
#else
int stats_box_h = ui_px(66); /* Smaller on Android (no storage line) */
#endif
DrawRectangle(content_x, text_y, content_w, stats_box_h, ui_darken(c_bg, 8));
ui_draw_bevel(content_x, text_y, content_w, stats_box_h, ui_lighten(c_bg, 35), ui_darken(c_bg, 45));
int stat_x = content_x + ui_px(16);
int stat_y = text_y + ui_px(16);
char stat_text[64];
snprintf(stat_text, sizeof(stat_text), "Total Sessions: %d", session_count);
DrawText(stat_text, stat_x, stat_y, font, c_text);
stat_y += ui_px(22);
snprintf(stat_text, sizeof(stat_text), "Data Size: %s", size_str);
DrawText(stat_text, stat_x, stat_y, font, c_text);
stat_y += ui_px(22);
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID)
const char *storage_path = data_root();
/* Replace /home/user/ with ~ for display */
const char *display_path = storage_path;
char home_buf[FS_PATH_MAX];
if (strncmp(storage_path, "/home/", 6) == 0) {
const char *slash_after_user = strchr(storage_path + 6, '/');
if (slash_after_user != NULL) {
snprintf(home_buf, sizeof(home_buf), "~%s", slash_after_user);
display_path = home_buf;
}
}
DrawText(TextFormat("Storage: %s", display_path), stat_x, stat_y, ui_clamp_px(12, 10, 14), ui_darken(c_text, 40));
#endif
text_y += stats_box_h + ui_px(24);
/* Export button */
int export_h = ui_px(36);
int export_w = MeasureText("Export Data", font) + ui_px(24);
int export_x = content_x;
int export_y = text_y;
Rectangle export_rect = {export_x, export_y, export_w, export_h};
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
if(CheckCollisionPointRec(mouse_world, export_rect)) {
DrawRectangle(export_x, export_y, export_w, export_h, c_button_hover);
ui_draw_bevel(export_x, export_y, export_w, export_h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
hover_export = 1;
app->cursor_clickable = 1;
} else {
DrawRectangle(export_x, export_y, export_w, export_h, c_button);
ui_draw_bevel(export_x, export_y, export_w, export_h, ui_lighten(c_button, 40), ui_darken(c_button, 40));
}
DrawText("Export Data", export_x + ui_px(12), export_y + export_h / 2 - font / 2 - 1, font, c_text);
/* Delete All button */
int delete_w = MeasureText("Delete All Data", font) + ui_px(24);
int delete_x = content_x + content_w - delete_w;
Rectangle delete_rect = {delete_x, export_y, delete_w, export_h};
if(CheckCollisionPointRec(mouse_world, delete_rect)) {
DrawRectangle(delete_x, export_y, delete_w, export_h, c_button_hover);
ui_draw_bevel(delete_x, export_y, delete_w, export_h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
hover_delete = 1;
app->cursor_clickable = 1;
} else {
DrawRectangle(delete_x, export_y, delete_w, export_h, c_button);
ui_draw_bevel(delete_x, export_y, delete_w, export_h, ui_lighten(c_button, 40), ui_darken(c_button, 40));
}
DrawText("Delete All Data", delete_x + ui_px(12), export_y + export_h / 2 - font / 2 - 1, font, c_text);
/* Handle button clicks */
if(hover_export && IsMouseButtonReleased(MOUSE_BUTTON_LEFT) &&
!ui_dropdown_captures_click(mouse_world)) {
if(file_dialog_save(&export_dlg, "Export Data", "inbe-export.zip")) {
const char *path = file_dialog_get_path(&export_dlg);
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
/* On Android: don't show success message (share sheet is the feedback) */
if(path != NULL && data_export(path)) {
TraceLog(LOG_INFO, "DATA: Export successful (share sheet shown)");
} else {
snprintf(export_result, sizeof(export_result), "Export failed");
TraceLog(LOG_ERROR, "DATA: Export failed");
}
#else
/* Other platforms: show success message */
if(path != NULL && data_export(path)) {
const char *filename = GetFileName(path);
snprintf(export_result, sizeof(export_result), "Exported: %s", filename);
TraceLog(LOG_INFO, "DATA: Export successful to %s", path);
} else {
snprintf(export_result, sizeof(export_result), "Export failed");
TraceLog(LOG_ERROR, "DATA: Export failed");
}
#endif
}
}
if(hover_delete && IsMouseButtonReleased(MOUSE_BUTTON_LEFT) &&
!ui_dropdown_captures_click(mouse_world)) {
if(data_has_any()) {
app->modal.active = 1;
app->modal.type = UIModalConfirmDeleteData;
app->modal.selected_button = 0;
}
}
/* Draw export result message under Export button */
if(export_result[0] != '\0') {
int result_font = ui_clamp_px(12, 10, 14);
int result_x = export_x;
int result_y = export_y + export_h + ui_px(8);
DrawText(export_result, result_x, result_y, result_font, c_text);
}
break;
}
case SETTINGS_TAB_ABOUT: {
int font = ui_clamp_px(14, 12, 16);
int small_font = ui_clamp_px(12, 10, 14);
int text_y = yoff + content_start_y;
/* App description */
const char *desc_lines[] = {
"Inner Breeze is a simple breathing",
"meditation app to help you relax",
"and find your calm."
};
for(int i = 0; i < 3; i++) {
DrawText(desc_lines[i], content_x, text_y, font, c_text);
text_y += ui_px(22);
}
/* Version info */
text_y += ui_px(20);
char version_text[32];
snprintf(version_text, sizeof(version_text), "Version %s", INBE_VERSION_STRING);
DrawText(version_text, content_x, text_y, small_font, ui_darken(c_text, 40));
/* Icon links */
int links_y = text_y + ui_px(40);
int icon_size = ui_clamp_px(ICON_SIZE_LARGE, ICON_SIZE_LARGE_MIN, ICON_SIZE_LARGE_MAX);
int icon_padding = ui_px(4);
int icon_spacing = ui_px(20);
int icon_btn_w = icon_size + icon_padding * 2;
int total_w = icon_btn_w * 4 + icon_spacing * 3;
int links_start_x = content_x + (content_w - total_w) / 2;
ui_draw_icon_link(app, links_start_x + icon_padding, links_y, icon_size, app->telegram_icon, "https://t.me/lotusinbe");
ui_draw_icon_link(app, links_start_x + icon_btn_w + icon_spacing + icon_padding, links_y, icon_size, app->globe_icon, "https://inbe.waozi.xyz/");
ui_draw_icon_link(app, links_start_x + (icon_btn_w + icon_spacing) * 2 + icon_padding, links_y, icon_size, app->monero_icon, "https://trocador.app/en/anonpay/?ticker_to=xmr&network_to=Mainnet&address=86CbC3d4a2GhT9auh6X99JhmhTMFKVVk8Q9cLrKTHkBu8LLkoNWgkBeAT3YZrvDM6NczYe8brUJNsTiFmwpWDZYnFG5kzSH&donation=True&simple_mode=True&amount=0.1&name=Inner+Breeze&[email protected]&ticker_from=xmr&network_from=Mainnet&buttonbgcolor=445588&textcolor=ffffff&bgcolor=eaeaffff");
ui_draw_icon_link(app, links_start_x + (icon_btn_w + icon_spacing) * 3 + icon_padding, links_y, icon_size, app->stripe_icon, "https://donate.stripe.com/4gM3cv5boaR98HH9VvfAc04");
break;
}
}
EndScissorMode();
/* Draw dropdown menu (floats above content) */
ui_draw_dropdown_menu(app, 100);
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
if(app->settings_dirty)
save_settings(app);
}
}
+11
View File
@@ -0,0 +1,11 @@
#ifndef SETTINGS_TAB_H
#define SETTINGS_TAB_H
#include "../libinbe/inbe.h"
typedef struct InbeApp InbeApp;
/* Draw the settings screen */
void settings_tab_draw(InbeApp *app);
#endif
+62 -21
View File
@@ -133,43 +133,64 @@ static LotusThemeValue *scope_add_value(LotusThemeScope *scope, const char *key,
static void load_scope_file(LotusThemeScope *scope)
{
FILE *file;
char line[256];
char *fileText;
char *cursor;
char lineBuffer[256];
if(scope == NULL || scope->path[0] == '\0')
return;
file = fopen(scope->path, "r");
if(file == NULL)
// Use raylib's file loading which works with Android assets
fileText = LoadFileText(scope->path);
if(fileText == NULL || fileText[0] == '\0') {
TraceLog(LOG_WARNING, "THEME: Failed to load theme file: %s", scope->path);
return;
}
while(fgets(line, sizeof(line), file) != NULL) {
// Parse line by line
cursor = fileText;
while(*cursor != '\0') {
// Extract single line
char *newline = strchr(cursor, '\n');
if(newline != NULL) {
*newline = '\0'; // Temporarily null-terminate
strncpy(lineBuffer, cursor, sizeof(lineBuffer) - 1);
lineBuffer[sizeof(lineBuffer) - 1] = '\0';
*newline = '\n'; // Restore for next iteration
cursor = newline + 1;
} else {
strncpy(lineBuffer, cursor, sizeof(lineBuffer) - 1);
lineBuffer[sizeof(lineBuffer) - 1] = '\0';
cursor += strlen(cursor);
}
// Parse line (same logic as before)
char *line_cursor = lineBuffer;
char key[LOTUS_THEME_NAME_SIZE];
char value[32];
char *cursor = line;
int key_len = 0;
Color color;
while(isspace((unsigned char)*cursor))
cursor++;
if(*cursor == '#' || *cursor == '\0')
while(isspace((unsigned char)*line_cursor))
line_cursor++;
if(*line_cursor == '#' || *line_cursor == '\0')
continue;
while(*cursor != '\0' && !isspace((unsigned char)*cursor) &&
while(*line_cursor != '\0' && !isspace((unsigned char)*line_cursor) &&
key_len < LOTUS_THEME_NAME_SIZE - 1) {
key[key_len++] = *cursor++;
key[key_len++] = *line_cursor++;
}
key[key_len] = '\0';
while(isspace((unsigned char)*cursor))
cursor++;
if(*cursor == '"')
cursor++;
while(isspace((unsigned char)*line_cursor))
line_cursor++;
if(*line_cursor == '"')
line_cursor++;
int value_len = 0;
while(*cursor != '\0' && *cursor != '"' && *cursor != '\n' &&
!isspace((unsigned char)*cursor) && value_len < (int)sizeof(value) - 1) {
value[value_len++] = *cursor++;
while(*line_cursor != '\0' && *line_cursor != '"' && *line_cursor != '\n' &&
!isspace((unsigned char)*line_cursor) && value_len < (int)sizeof(value) - 1) {
value[value_len++] = *line_cursor++;
}
value[value_len] = '\0';
@@ -177,7 +198,7 @@ static void load_scope_file(LotusThemeScope *scope)
scope_add_value(scope, key, color);
}
fclose(file);
UnloadFileText(fileText);
}
LotusThemeScope *theme_register_scope(const char *name, const char *path)
@@ -202,10 +223,30 @@ Color theme_get(const char *scope_name, const char *key)
if(value != NULL)
return value->value;
fprintf(stderr, "missing theme color: %s.%s\n",
fprintf(stderr, "missing theme color: %s.%s, using clean light sky default\n",
scope_name != NULL ? scope_name : "(null)",
key != NULL ? key : "(null)");
abort();
// Use clean light sky theme colors as defaults
if(key != NULL) {
if(strstr(key, "background") != NULL)
return (Color){0xE2, 0xEE, 0xFC, 0xFF}; // #E2EEFCFF
if(strstr(key, "text") != NULL || strstr(key, "foreground") != NULL)
return (Color){0x24, 0x48, 0x7C, 0xFF}; // #24487CFF
if(strstr(key, "circle") != NULL)
return (Color){0x7E, 0xB7, 0xE6, 0xFF}; // #7EB7E6FF
if(strstr(key, "button_hover") != NULL)
return (Color){0x68, 0x9E, 0xD7, 0xFF}; // #689ED7FF
if(strstr(key, "button") != NULL)
return (Color){0xA6, 0xCF, 0xF2, 0xFF}; // #A6CFF2FF
if(strstr(key, "icon") != NULL)
return (Color){0xE2, 0xEE, 0xFC, 0xFF}; // #E2EEFCFF
if(strstr(key, "link") != NULL)
return (Color){0x4A, 0x90, 0xE2, 0xFF}; // #4A90E2FF
}
// Default fallback: sky background
return (Color){0xE2, 0xEE, 0xFC, 0xFF};
}
bool theme_set_color(const char *scope_name, const char *key, Color color)
+421 -117
View File
@@ -1,33 +1,20 @@
#include "ui.h"
#include "android_insets.h"
#include "app.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Constants */
enum {
ICON_SIZE_SMALL = 22,
ICON_SIZE_MEDIUM = 26,
ICON_SIZE_LARGE = 30,
ICON_SIZE_SMALL_MIN = 20,
ICON_SIZE_SMALL_MAX = 36,
ICON_SIZE_MEDIUM_MIN = 24,
ICON_SIZE_MEDIUM_MAX = 40,
ICON_SIZE_LARGE_MIN = 28,
ICON_SIZE_LARGE_MAX = 44
};
/* Global UI state */
static float dpi_scale = 1.0f;
static int view_width = 320;
static int view_height = 560;
static int ui_view_width = 320;
static int ui_view_height = 560;
static Color c_text, c_bg, c_circle, c_button, c_button_hover, c_icon;
void
ui_init(int width, int height, float dpi)
{
view_width = width;
view_height = height;
ui_view_width = width;
ui_view_height = height;
dpi_scale = dpi;
}
@@ -102,7 +89,7 @@ ui_centered_column(int max_w, int side_pad, int *x, int *w)
max_w = (int)(max_w * dpi_scale + 0.5f);
side_pad = (int)(side_pad * dpi_scale + 0.5f);
int available_w = view_width - side_pad * 2;
int available_w = ui_view_width - side_pad * 2;
if(available_w < 0)
available_w = 0;
@@ -112,7 +99,7 @@ ui_centered_column(int max_w, int side_pad, int *x, int *w)
max_w = 0;
if(x != NULL)
*x = (view_width - max_w) / 2;
*x = (ui_view_width - max_w) / 2;
if(w != NULL)
*w = max_w;
}
@@ -189,7 +176,7 @@ ui_draw_icon_btn(InbeApp *app, int x, int y, UIIconSize size, Texture2D icon, in
if(mb) {
ui_draw_bevel(x, y, w, h, ui_lighten(c_button_hover, 40), ui_darken(c_button_hover, 40));
}
if(released) {
if(released && !ui_dropdown_captures_click(mouse_world)) {
pressed = 1;
}
} else {
@@ -208,21 +195,81 @@ ui_draw_icon_btn(InbeApp *app, int x, int y, UIIconSize size, Texture2D icon, in
}
int
ui_draw_icon_btn_small(InbeApp *app, int x, int y, Texture2D icon, int *hover)
ui_draw_icon_btn_padded(InbeApp *app, int x, int y, int size, Texture2D icon, int *hover)
{
return ui_draw_icon_btn(app, x, y, UI_ICON_SIZE_SMALL, icon, hover);
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
int mx = (int)mouse_world.x;
int my = (int)mouse_world.y;
int mb = IsMouseButtonDown(MOUSE_BUTTON_LEFT);
int released = IsMouseButtonReleased(MOUSE_BUTTON_LEFT);
int padding = ui_px(10);
int w = size + padding * 2;
int h = size + padding * 2;
int pressed = 0;
if(mx > x && mx < x + w && my > y && my < y + h) {
DrawRectangle(x, y, w, h, c_button_hover);
ui_draw_bevel(x, y, w, h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
*hover = 1;
app->cursor_clickable = 1;
if(mb) {
ui_draw_bevel(x, y, w, h, ui_lighten(c_button_hover, 40), ui_darken(c_button_hover, 40));
}
if(released && !ui_dropdown_captures_click(mouse_world)) {
pressed = 1;
}
} else {
DrawRectangle(x, y, w, h, c_button);
ui_draw_bevel(x, y, w, h, ui_lighten(c_button, 40), ui_darken(c_button, 20));
*hover = 0;
}
if(icon.id != 0) {
Rectangle src = {0, 0, icon.width, icon.height};
Rectangle dst = {x + padding, y + padding, (float)size, (float)size};
DrawTexturePro(icon, src, dst, (Vector2){0}, 0, c_icon);
}
return pressed;
}
int
ui_draw_icon_btn_medium(InbeApp *app, int x, int y, Texture2D icon, int *hover)
ui_draw_text_btn(InbeApp *app, int x, int y, const char *label, int *hover)
{
return ui_draw_icon_btn(app, x, y, UI_ICON_SIZE_MEDIUM, icon, hover);
}
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
int mx = (int)mouse_world.x;
int my = (int)mouse_world.y;
int
ui_draw_icon_btn_large(InbeApp *app, int x, int y, Texture2D icon, int *hover)
{
return ui_draw_icon_btn(app, x, y, UI_ICON_SIZE_LARGE, icon, hover);
int mb = IsMouseButtonDown(MOUSE_BUTTON_LEFT);
int released = IsMouseButtonReleased(MOUSE_BUTTON_LEFT);
int font = ui_clamp_px(20, 16, 22);
int w = (int)MeasureText(label, font) + ui_px(20);
int h = ui_clamp_px(30, 26, 34);
x = x - w / 2;
int pressed = 0;
if(mx > x && mx < x + w && my > y && my < y + h) {
DrawRectangle(x, y, w, h, c_button_hover);
ui_draw_bevel(x, y, w, h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
*hover = 1;
app->cursor_clickable = 1;
if(mb) {
ui_draw_bevel(x, y, w, h, ui_lighten(c_button_hover, 40), ui_darken(c_button_hover, 40));
}
if(released && !ui_dropdown_captures_click(mouse_world)) {
pressed = 1;
}
} else {
DrawRectangle(x, y, w, h, c_button);
ui_draw_bevel(x, y, w, h, ui_lighten(c_button, 40), ui_darken(c_button, 40));
*hover = 0;
}
DrawText(label, x + ui_px(10), y + ui_px(5), font, c_text);
return pressed;
}
void
@@ -257,7 +304,7 @@ ui_draw_icon_link(InbeApp *app, int x, int y, int icon_size, Texture2D icon, con
DrawTexturePro(icon, src, dst, (Vector2){0}, 0, c_icon);
}
if(hover && IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
if(hover && IsMouseButtonReleased(MOUSE_BUTTON_LEFT) && !ui_dropdown_captures_click(mouse_world)) {
OpenURL(url);
}
}
@@ -266,16 +313,6 @@ ui_draw_icon_link(InbeApp *app, int x, int y, int icon_size, Texture2D icon, con
* CONTROLS
* ================================================================ */
static int
clampi(int value, int min, int max)
{
if(value < min)
return min;
if(value > max)
return max;
return value;
}
int
ui_draw_slider(InbeApp *app, int id, int x, int y, int w, const char *label,
int min, int max, int *value, const char *suffix)
@@ -303,7 +340,7 @@ ui_draw_slider(InbeApp *app, int id, int x, int y, int w, const char *label,
if(CheckCollisionPointRec(mouse_world, hit)) {
app->cursor_clickable = 1;
if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && !ui_dropdown_captures_click(mouse_world))
app->settings_drag_slider = id;
}
@@ -339,7 +376,7 @@ ui_draw_toggle_switch(InbeApp *app, int x, int y, int w, int h, int *value)
app->cursor_clickable = 1;
}
int pressed = hover && IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
int pressed = hover && IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && !ui_dropdown_captures_click(mouse_world);
if(pressed)
*value = !(*value);
@@ -386,7 +423,7 @@ ui_draw_checkbox_toggle(InbeApp *app, int x, int y, const char *label, int *valu
app->cursor_clickable = 1;
}
int pressed = hover && IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
int pressed = hover && IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && !ui_dropdown_captures_click(mouse_world);
if(pressed)
*value = !(*value);
@@ -420,6 +457,35 @@ typedef struct UIDropdownState {
static UIDropdownState dropdown_states[MAX_DROPDOWNS];
static int dropdown_state_count = 0;
/* Check if any dropdown is currently open and the given point is within its menu bounds.
* Other UI elements should call this to avoid handling clicks that should go to dropdowns. */
int
ui_dropdown_captures_click(Vector2 point)
{
for(int i = 0; i < dropdown_state_count; i++) {
UIDropdownState *state = &dropdown_states[i];
if(state->open && state->option_count > 0) {
int option_h = state->h;
int menu_gap = ui_px(4);
int dropdown_y = state->y + state->h + menu_gap;
int dropdown_h = option_h * state->option_count + ui_px(8);
int max_visible_h = ui_view_height - dropdown_y - ui_px(16);
if(dropdown_h > max_visible_h) {
int visible_options = (max_visible_h - ui_px(8)) / option_h;
if(visible_options < 1)
visible_options = 1;
dropdown_h = visible_options * option_h + ui_px(8);
}
Rectangle menu_bounds = {state->x, dropdown_y, state->w, dropdown_h};
if(CheckCollisionPointRec(point, menu_bounds))
return 1;
}
}
return 0;
}
static UIDropdownState *
get_or_create_dropdown_state(int id)
{
@@ -534,7 +600,7 @@ ui_draw_dropdown_menu(InbeApp *app, int id)
int menu_gap = ui_px(4);
int dropdown_y = y + h + menu_gap;
int dropdown_h = option_h * option_count + ui_px(8);
int max_visible_h = view_height - dropdown_y - ui_px(16);
int max_visible_h = ui_view_height - dropdown_y - ui_px(16);
int need_scroll = dropdown_h > max_visible_h;
int visible_options = option_count;
@@ -612,69 +678,6 @@ ui_draw_dropdown_menu(InbeApp *app, int id)
DrawLine(x1, y2, x2, y1, c_text);
}
void
ui_draw_scrollbar(InbeApp *app, int *scroll, int content_h, int viewport_h,
int *drag_scrollbar, int *drag_content, int *drag_content_y)
{
if(content_h <= viewport_h)
return;
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
int bar_w = ui_px(8);
int bar_x = view_width - bar_w;
int bar_y = 0;
int bar_h = viewport_h;
int thumb_h = (viewport_h * bar_h) / content_h;
int min_thumb_h = ui_px(32);
if(thumb_h < min_thumb_h)
thumb_h = min_thumb_h;
int max_scroll = content_h - viewport_h;
int thumb_y = bar_y + (*scroll * (bar_h - thumb_h)) / max_scroll;
int hit_w = ui_px(16);
Rectangle thumb = {(float)(bar_x - (hit_w - bar_w) / 2), (float)thumb_y, (float)hit_w, (float)thumb_h};
Rectangle content_area = {(float)0, (float)bar_y, (float)bar_x, (float)bar_h};
DrawRectangle(bar_x, bar_y, bar_w, bar_h, ui_darken(c_bg, 18));
DrawRectangle(bar_x, thumb_y, bar_w, thumb_h, c_button_hover);
if(CheckCollisionPointRec(mouse_world, thumb)) {
app->cursor_clickable = 1;
if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
*drag_scrollbar = 1;
}
if(*drag_scrollbar && IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
int usable = bar_h - thumb_h;
int y = (int)mouse_world.y - bar_y - thumb_h / 2;
y = clampi(y, 0, usable);
*scroll = (y * max_scroll) / usable;
return;
}
if(CheckCollisionPointRec(mouse_world, content_area)) {
if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
*drag_content = 1;
*drag_content_y = (int)mouse_world.y;
}
}
if(*drag_content && IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
int delta = *drag_content_y - (int)mouse_world.y;
*scroll += delta;
*scroll = clampi(*scroll, 0, max_scroll);
*drag_content_y = (int)mouse_world.y;
}
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
*drag_scrollbar = 0;
*drag_content = 0;
}
}
/* ================================================================
* NAVIGATION
* ================================================================ */
int
ui_nav_button_width(const char *label, int icon_size, int show_label, int font)
{
@@ -787,15 +790,13 @@ void
ui_draw_tab_bar(UITab *tabs, int count, InbeApp *app)
{
int bar_h = ui_clamp_px(58, 54, 66);
AndroidInsets insets = {0};
android_insets_get(&insets);
int bar_y = view_height - bar_h;
int bar_y = ui_view_height - bar_h;
int button_size = ui_clamp_px(ICON_SIZE_LARGE, ICON_SIZE_LARGE_MIN, ICON_SIZE_LARGE_MAX);
int button_h = button_size + ui_px(12);
int font = ui_clamp_px(14, 12, 16);
int side_margin = ui_px(16);
int group_gap = ui_px(10);
int available_w = view_width - side_margin * 2;
int available_w = ui_view_width - side_margin * 2;
/* Calculate widths with labels */
int group_w_label = 0;
@@ -817,16 +818,21 @@ ui_draw_tab_bar(UITab *tabs, int count, InbeApp *app)
int show_labels = group_w_label <= available_w;
int base_group_w = show_labels ? group_w_label : group_w_no_label;
/* Calculate extra space to distribute among buttons */
int extra_w = available_w - base_group_w;
/* Calculate extra space and distribute evenly among buttons */
int extra_w = available_w - base_group_w - group_gap * (count - 1);
int extra_per_button = count > 0 ? extra_w / count : 0;
int remainder = count > 0 ? extra_w % count : 0;
int group_x = side_margin;
/* Calculate total width with extra space included */
int total_w = base_group_w + extra_per_button * count + group_gap * (count - 1);
/* Center the tab group - remainder adds extra left margin for true centering */
int group_x = side_margin + (available_w - total_w) / 2 + remainder / 2;
int button_y = bar_y + (bar_h - button_h) / 2;
int tab_hover = 0;
DrawRectangle(0, bar_y, view_width, bar_h, ui_darken(c_bg, 10));
DrawLine(0, bar_y, view_width, bar_y, ui_darken(c_bg, 42));
DrawRectangle(0, bar_y, ui_view_width, bar_h, ui_darken(c_bg, 10));
DrawLine(0, bar_y, ui_view_width, bar_y, ui_darken(c_bg, 42));
int x = group_x;
for(int i = 0; i < count; i++) {
@@ -879,3 +885,301 @@ ui_draw_tutorial_image(Texture2D texture, const char *fallback, int x, int y, in
ui_draw_bevel(x, y, w, h, ui_darken(c_bg, 45), ui_lighten(c_bg, 35));
DrawTexturePro(texture, src, dst, (Vector2){0}, 0, WHITE);
}
/* ================================================================
* MODAL DIALOGS
* ================================================================ */
int
ui_draw_modal(InbeApp *app, const char *title, const char *message,
const char *cancel_btn, const char *confirm_btn)
{
int modal_w = ui_px(280);
int modal_h = ui_px(160);
int modal_x = (ui_view_width - modal_w) / 2;
int modal_y = (ui_view_height - modal_h) / 2;
int title_font = ui_clamp_px(16, 14, 18);
int msg_font = ui_clamp_px(14, 12, 16);
int btn_font = ui_clamp_px(14, 12, 16);
int btn_h = ui_clamp_px(36, 32, 40);
int btn_w = ui_px(100);
int btn_gap = ui_px(12);
int title_h = ui_px(32);
int msg_y = modal_y + title_h;
int btn_y = modal_y + modal_h - btn_h - ui_px(16);
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
int mx = (int)mouse_world.x;
int my = (int)mouse_world.y;
/* Dim background */
DrawRectangle(0, 0, ui_view_width, ui_view_height, (Color){0, 0, 0, 180});
/* Modal background */
DrawRectangle(modal_x, modal_y, modal_w, modal_h, c_button);
ui_draw_bevel(modal_x, modal_y, modal_w, modal_h, ui_lighten(c_button, 40), ui_darken(c_button, 40));
/* Title */
int title_w = MeasureText(title, title_font);
DrawText(title, modal_x + (modal_w - title_w) / 2, modal_y + ui_px(12), title_font, c_text);
/* Message (word wrap) */
const char *msg = message;
int msg_x = modal_x + ui_px(16);
int msg_w = modal_w - ui_px(32);
int line_y = msg_y;
char word_buf[64];
int word_len = 0;
int line_w = 0;
int msg_lines = 0;
while(*msg && msg_lines < 4) {
if(*msg == ' ' || *msg == '\0' || *msg == '\n') {
if(word_len > 0) {
word_buf[word_len] = '\0';
int word_w = MeasureText(word_buf, msg_font);
if(line_w == 0 || line_w + word_w <= msg_w) {
DrawText(word_buf, msg_x + line_w, line_y, msg_font, c_text);
line_w += word_w + MeasureText(" ", msg_font);
} else {
line_y += msg_font + ui_px(4);
DrawText(word_buf, msg_x, line_y, msg_font, c_text);
line_w = word_w;
msg_lines++;
}
word_len = 0;
}
if(*msg == '\n') {
line_y += msg_font + ui_px(4);
line_w = 0;
msg_lines++;
}
} else if(word_len < (int)sizeof(word_buf) - 1) {
word_buf[word_len++] = *msg;
}
msg++;
}
/* Draw any remaining word after loop ends */
if(word_len > 0 && msg_lines < 4) {
word_buf[word_len] = '\0';
int word_w = MeasureText(word_buf, msg_font);
if(line_w == 0 || line_w + word_w <= msg_w) {
DrawText(word_buf, msg_x + line_w, line_y, msg_font, c_text);
} else {
line_y += msg_font + ui_px(4);
DrawText(word_buf, msg_x, line_y, msg_font, c_text);
}
}
/* Buttons */
int cancel_x = modal_x + (modal_w - btn_w * 2 - btn_gap) / 2;
int confirm_x = cancel_x + btn_w + btn_gap;
int result = 0;
/* Cancel button */
if(mx >= cancel_x && mx < cancel_x + btn_w && my >= btn_y && my < btn_y + btn_h) {
DrawRectangle(cancel_x, btn_y, btn_w, btn_h, c_button_hover);
ui_draw_bevel(cancel_x, btn_y, btn_w, btn_h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
app->cursor_clickable = 1;
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
result = 1;
} else {
DrawRectangle(cancel_x, btn_y, btn_w, btn_h, c_button);
ui_draw_bevel(cancel_x, btn_y, btn_w, btn_h, ui_lighten(c_button, 40), ui_darken(c_button, 40));
}
int cancel_text_w = MeasureText(cancel_btn, btn_font);
DrawText(cancel_btn, cancel_x + (btn_w - cancel_text_w) / 2, btn_y + (btn_h - btn_font) / 2 - 1, btn_font, c_text);
/* Confirm button */
if(mx >= confirm_x && mx < confirm_x + btn_w && my >= btn_y && my < btn_y + btn_h) {
DrawRectangle(confirm_x, btn_y, btn_w, btn_h, c_button_hover);
ui_draw_bevel(confirm_x, btn_y, btn_w, btn_h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
app->cursor_clickable = 1;
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
result = 2;
} else {
DrawRectangle(confirm_x, btn_y, btn_w, btn_h, c_circle);
ui_draw_bevel(confirm_x, btn_y, btn_w, btn_h, ui_lighten(c_circle, 40), ui_darken(c_circle, 40));
}
int confirm_text_w = MeasureText(confirm_btn, btn_font);
DrawText(confirm_btn, confirm_x + (btn_w - confirm_text_w) / 2, btn_y + (btn_h - btn_font) / 2 - 1, btn_font, c_text);
return result;
}
int
ui_draw_modal_3btn(InbeApp *app, const char *title, const char *message,
const char *left_btn, const char *middle_btn, const char *right_btn)
{
int modal_w = ui_px(300);
int modal_h = ui_px(160);
int modal_x = (ui_view_width - modal_w) / 2;
int modal_y = (ui_view_height - modal_h) / 2;
int title_font = ui_clamp_px(16, 14, 18);
int msg_font = ui_clamp_px(14, 12, 16);
int btn_font = ui_clamp_px(14, 12, 16);
int btn_h = ui_clamp_px(36, 32, 40);
int btn_w = ui_px(90);
int btn_gap = ui_px(8);
int title_h = ui_px(32);
int msg_y = modal_y + title_h;
int btn_y = modal_y + modal_h - btn_h - ui_px(16);
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
int mx = (int)mouse_world.x;
int my = (int)mouse_world.y;
/* Dim background */
DrawRectangle(0, 0, ui_view_width, ui_view_height, (Color){0, 0, 0, 180});
/* Modal background */
DrawRectangle(modal_x, modal_y, modal_w, modal_h, c_button);
ui_draw_bevel(modal_x, modal_y, modal_w, modal_h, ui_lighten(c_button, 40), ui_darken(c_button, 40));
/* Title */
int title_w = MeasureText(title, title_font);
DrawText(title, modal_x + (modal_w - title_w) / 2, modal_y + ui_px(12), title_font, c_text);
/* Message (word wrap) - same as 2-button version */
const char *msg = message;
int msg_x = modal_x + ui_px(16);
int msg_w = modal_w - ui_px(32);
int line_y = msg_y;
char word_buf[64];
int word_len = 0;
int line_w = 0;
int msg_lines = 0;
while(*msg && msg_lines < 4) {
if(*msg == ' ' || *msg == '\0' || *msg == '\n') {
if(word_len > 0) {
word_buf[word_len] = '\0';
int word_w = MeasureText(word_buf, msg_font);
if(line_w == 0 || line_w + word_w <= msg_w) {
DrawText(word_buf, msg_x + line_w, line_y, msg_font, c_text);
line_w += word_w + MeasureText(" ", msg_font);
} else {
line_y += msg_font + ui_px(4);
DrawText(word_buf, msg_x, line_y, msg_font, c_text);
line_w = word_w;
msg_lines++;
}
word_len = 0;
}
if(*msg == '\n') {
line_y += msg_font + ui_px(4);
line_w = 0;
msg_lines++;
}
} else if(word_len < (int)sizeof(word_buf) - 1) {
word_buf[word_len++] = *msg;
}
msg++;
}
/* Draw any remaining word after loop ends */
if(word_len > 0 && msg_lines < 4) {
word_buf[word_len] = '\0';
int word_w = MeasureText(word_buf, msg_font);
if(line_w == 0 || line_w + word_w <= msg_w) {
DrawText(word_buf, msg_x + line_w, line_y, msg_font, c_text);
} else {
line_y += msg_font + ui_px(4);
DrawText(word_buf, msg_x, line_y, msg_font, c_text);
}
}
/* Calculate button positions */
int total_btn_w = btn_w * 3 + btn_gap * 2;
int left_x = modal_x + (modal_w - total_btn_w) / 2;
int middle_x = left_x + btn_w + btn_gap;
int right_x = middle_x + btn_w + btn_gap;
int result = 0;
/* Left button (Cancel) */
if(mx >= left_x && mx < left_x + btn_w && my >= btn_y && my < btn_y + btn_h) {
DrawRectangle(left_x, btn_y, btn_w, btn_h, c_button_hover);
ui_draw_bevel(left_x, btn_y, btn_w, btn_h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
app->cursor_clickable = 1;
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
result = 1;
} else {
DrawRectangle(left_x, btn_y, btn_w, btn_h, c_button);
ui_draw_bevel(left_x, btn_y, btn_w, btn_h, ui_lighten(c_button, 40), ui_darken(c_button, 40));
}
int left_text_w = MeasureText(left_btn, btn_font);
DrawText(left_btn, left_x + (btn_w - left_text_w) / 2, btn_y + (btn_h - btn_font) / 2 - 1, btn_font, c_text);
/* Middle button (Save) - primary action */
if(mx >= middle_x && mx < middle_x + btn_w && my >= btn_y && my < btn_y + btn_h) {
DrawRectangle(middle_x, btn_y, btn_w, btn_h, c_button_hover);
ui_draw_bevel(middle_x, btn_y, btn_w, btn_h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
app->cursor_clickable = 1;
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
result = 2;
} else {
DrawRectangle(middle_x, btn_y, btn_w, btn_h, c_circle);
ui_draw_bevel(middle_x, btn_y, btn_w, btn_h, ui_lighten(c_circle, 40), ui_darken(c_circle, 40));
}
int middle_text_w = MeasureText(middle_btn, btn_font);
DrawText(middle_btn, middle_x + (btn_w - middle_text_w) / 2, btn_y + (btn_h - btn_font) / 2 - 1, btn_font, c_text);
/* Right button (Discard) */
if(mx >= right_x && mx < right_x + btn_w && my >= btn_y && my < btn_y + btn_h) {
DrawRectangle(right_x, btn_y, btn_w, btn_h, c_button_hover);
ui_draw_bevel(right_x, btn_y, btn_w, btn_h, ui_darken(c_button_hover, 40), ui_lighten(c_button_hover, 40));
app->cursor_clickable = 1;
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
result = 3;
} else {
DrawRectangle(right_x, btn_y, btn_w, btn_h, c_button);
ui_draw_bevel(right_x, btn_y, btn_w, btn_h, ui_lighten(c_button, 40), ui_darken(c_button, 40));
}
int right_text_w = MeasureText(right_btn, btn_font);
DrawText(right_btn, right_x + (btn_w - right_text_w) / 2, btn_y + (btn_h - btn_font) / 2 - 1, btn_font, c_text);
return result;
}
/* ================================================================
* SCREEN HEADER (TITLE BAR)
* ================================================================ */
int
ui_screen_header_height(void)
{
return ui_clamp_px(60, 48, 60);
}
int
ui_draw_screen_header(InbeApp *app, const char *title, int show_close)
{
(void)c_bg; /* unused */
int title_h = ui_screen_header_height();
int title_font = ui_clamp_px(16, 14, 18);
int close_hover = 0;
int close_clicked = 0;
/* Draw header background */
DrawRectangle(0, 0, ui_view_width, title_h, ui_darken(c_bg, 14));
DrawLine(0, title_h - 1, ui_view_width, title_h - 1, ui_darken(c_bg, 42));
/* Draw centered title */
int title_w = MeasureText(title, title_font);
int title_y = (title_h - title_font) / 2;
DrawText(title, (ui_view_width - title_w) / 2, title_y, title_font, c_text);
/* Draw close button if requested */
if(show_close) {
close_clicked = ui_draw_icon_btn(app, ui_view_width - ui_px(40) - ui_icon_btn_padding(UI_ICON_SIZE_TINY), ui_px(8),
UI_ICON_SIZE_TINY, app->x_icon, &close_hover);
}
return close_clicked;
}
/* ================================================================
* END OF UI FUNCTIONS
* ================================================================ */
+11 -102
View File
@@ -4,7 +4,6 @@
#include "raylib.h"
#include "app.h"
/* Icon Size Enum */
typedef enum {
UI_ICON_SIZE_TINY,
UI_ICON_SIZE_SMALL,
@@ -12,104 +11,27 @@ typedef enum {
UI_ICON_SIZE_LARGE
} UIIconSize;
/* ================================================================
* INITIALIZATION
* ================================================================ */
/* Initialize UI library with viewport dimensions and DPI scale */
void ui_init(int width, int height, float dpi);
/* Update theme colors used by UI library */
void ui_set_colors(Color text, Color bg, Color circle, Color button, Color button_hover, Color icon);
/* ================================================================
* DPI SCALING
* ================================================================ */
/* Convert logical pixels to physical pixels based on DPI scaling */
int ui_px(int px);
/* Convert logical pixels to physical pixels with min/max clamping */
int ui_clamp_px(int px, int min_px, int max_px);
/* ================================================================
* COLOR HELPERS
* ================================================================ */
/* Lighten a color by a specified amount */
Color ui_lighten(Color c, int amount);
/* Darken a color by a specified amount */
Color ui_darken(Color c, int amount);
/* ================================================================
* LAYOUT HELPERS
* ================================================================ */
/* Calculate centered column position and width */
void ui_centered_column(int max_w, int side_pad, int *x, int *w);
/* Draw a bevel border effect using rectangles */
void ui_draw_bevel(int x, int y, int w, int h, Color light, Color dark);
/* Draw multiple text lines with incremental y position */
void ui_draw_text_lines(const char **lines, int count, int x, int *y, int font, int line_h);
/* ================================================================
* ICON BUTTONS
* ================================================================ */
/* Get icon button size with DPI scaling */
int ui_icon_btn_size(UIIconSize size);
/* Get icon button padding */
int ui_icon_btn_padding(UIIconSize size);
/* Draw a standard icon button with consistent sizing */
int ui_draw_icon_btn(InbeApp *app, int x, int y, UIIconSize size, Texture2D icon, int *hover);
/* Convenience wrapper for small icon buttons */
int ui_draw_icon_btn_small(InbeApp *app, int x, int y, Texture2D icon, int *hover);
/* Convenience wrapper for medium icon buttons */
int ui_draw_icon_btn_medium(InbeApp *app, int x, int y, Texture2D icon, int *hover);
/* Convenience wrapper for large icon buttons */
int ui_draw_icon_btn_large(InbeApp *app, int x, int y, Texture2D icon, int *hover);
/* Draw an icon link button that opens a URL when clicked */
int ui_draw_icon_btn_padded(InbeApp *app, int x, int y, int size, Texture2D icon, int *hover);
int ui_draw_text_btn(InbeApp *app, int x, int y, const char *label, int *hover);
void ui_draw_icon_link(InbeApp *app, int x, int y, int icon_size, Texture2D icon, const char *url);
/* ================================================================
* CONTROLS
* ================================================================ */
/* Draw a slider control with label and value display */
int ui_draw_slider(InbeApp *app, int id, int x, int y, int w, const char *label,
int min, int max, int *value, const char *suffix);
/* Draw a toggle switch (typically for light/dark mode) */
int ui_draw_slider(InbeApp *app, int id, int x, int y, int w, const char *label, int min, int max, int *value, const char *suffix);
int ui_draw_toggle_switch(InbeApp *app, int x, int y, int w, int h, int *value);
/* Draw a checkbox toggle with label */
int ui_draw_checkbox_toggle(InbeApp *app, int x, int y, const char *label, int *value);
/* Draw a dropdown button only (call inside scissor mode) */
int ui_draw_dropdown_button(InbeApp *app, int id, int x, int y, int w, int h,
const char **options, int option_count, int *selected_index);
/* Draw a dropdown menu (call outside scissor mode, after button) */
int ui_draw_dropdown_button(InbeApp *app, int id, int x, int y, int w, int h, const char **options, int option_count, int *selected_index);
void ui_draw_dropdown_menu(InbeApp *app, int id);
/* Draw a scrollbar with thumb and handle content dragging */
void ui_draw_scrollbar(InbeApp *app, int *scroll, int content_h, int viewport_h,
int *drag_scrollbar, int *drag_content, int *drag_content_y);
/* ================================================================
* NAVIGATION
* ================================================================ */
/* Tab definition for tab bar */
int ui_dropdown_captures_click(Vector2 point);
typedef struct UITab {
const char *label;
Texture2D icon;
@@ -122,28 +44,15 @@ typedef struct UITabBar {
int count;
} UITabBar;
/* Calculate width of navigation buttons with optional label */
int ui_nav_button_width(const char *label, int icon_size, int show_label, int font);
/* Draw a navigation button with icon and optional label */
int ui_draw_nav_button(InbeApp *app, int x, int y, int icon_size, Texture2D icon,
const char *label, int show_label, int *hover);
/* Draw a navigation button with explicit width (expands to fill space) */
int ui_draw_nav_button_expand(InbeApp *app, int x, int y, int icon_size, int w, Texture2D icon,
const char *label, int show_label, int *hover);
/* Draw the bottom tab bar - automatic, data-driven */
int ui_draw_nav_button(InbeApp *app, int x, int y, int icon_size, Texture2D icon, const char *label, int show_label, int *hover);
int ui_draw_nav_button_expand(InbeApp *app, int x, int y, int icon_size, int w, Texture2D icon, const char *label, int show_label, int *hover);
void ui_draw_tab_bar(UITab *tabs, int count, InbeApp *app);
/* ================================================================
* TUTORIAL HELPERS
* ================================================================ */
/* Draw a placeholder for tutorial images */
void ui_draw_tutorial_image_placeholder(const char *label, int x, int y, int w, int h);
/* Draw tutorial images with fallback to placeholder */
void ui_draw_tutorial_image(Texture2D texture, const char *fallback, int x, int y, int w, int h);
int ui_draw_modal(InbeApp *app, const char *title, const char *message, const char *cancel_btn, const char *confirm_btn);
int ui_draw_modal_3btn(InbeApp *app, const char *title, const char *message, const char *left_btn, const char *middle_btn, const char *right_btn);
int ui_draw_screen_header(InbeApp *app, const char *title, int show_close);
int ui_screen_header_height(void);
#endif
+3 -3
View File
@@ -2,8 +2,8 @@
#define INBE_VERSION_H
#define INBE_VERSION_MAJOR 1
#define INBE_VERSION_MINOR 0
#define INBE_VERSION_PATCH 4
#define INBE_VERSION_STRING "1.0.4"
#define INBE_VERSION_MINOR 1
#define INBE_VERSION_PATCH 2
#define INBE_VERSION_STRING "1.1.2"
#endif
+22 -6
View File
@@ -6,17 +6,17 @@
:root {
--page-bg: #000000;
--page-tile: url('/icons/tile.png');
--page-tile: url('/icons/tile2.png');
--page-tile-opacity: 0.32;
--panel-bg: #ffffea;
--dark: #557777;
--panel-bg: #E2EEFC;
--dark: #24487C;
--shadow: #000000;
--light: #ffffff;
--button-bg: #d9d9d9;
--button-bg: #A6CFF2;
--button-highlight: #ffffff;
--button-inset: #ffffff;
--link: #1133aa;
--link-hover: #0044cc;
--link: #4A90E2;
--link-hover: #689ED7;
}
html, body {
@@ -62,6 +62,14 @@ body::before {
2px 2px 0 0 var(--light);
}
.hero {
text-align: center;
}
.hero img {
margin: 0 auto;
}
section {
margin-bottom: 80px;
}
@@ -81,6 +89,10 @@ img {
image-rendering: pixelated;
}
.hero .tk-img {
margin-bottom: 24px;
}
.tk-img {
border: 2px solid var(--dark);
border-right-color: var(--button-highlight);
@@ -278,6 +290,10 @@ input[type="text"] {
background-color: var(--button-highlight);
}
details {
text-align: center;
}
.donation-buttons {
display: flex;
justify-content: space-around;
+39 -13
View File
@@ -19,13 +19,19 @@ fi
# Get latest version for gradle update
LATEST_VERSION=$(echo "$VERSIONS" | head -n 1)
# versionCode = patch + 1 (since 1.0.0 = code 1)
VERSION_CODE=$(($(echo "$LATEST_VERSION" | cut -d. -f3) + 1))
# Get current versionName
# Get current gradle values
CURRENT_NAME=$(grep "versionName" "$GRADLE_FILE" | sed 's/.*"\([^"]*\)".*/\1/')
CURRENT_CODE=$(grep "versionCode" "$GRADLE_FILE" | awk '{print $2}')
# Android versionCode: just increment by 1 for new versions
# If version hasn't changed, keep the same code
if [ "$LATEST_VERSION" = "$CURRENT_NAME" ]; then
VERSION_CODE=$CURRENT_CODE
else
VERSION_CODE=$((CURRENT_CODE + 1))
fi
echo "Updating to: $LATEST_VERSION (code $VERSION_CODE)"
echo "Current: $CURRENT_NAME (code $CURRENT_CODE)"
@@ -35,13 +41,30 @@ sed -i "s/versionName \"$CURRENT_NAME\"/versionName \"$LATEST_VERSION\"/" "$GRAD
echo "✓ Updated $GRADLE_FILE"
# Update version.h
VERSION_H_FILE="src/version.h"
MAJOR=$(echo "$LATEST_VERSION" | cut -d. -f1)
MINOR=$(echo "$LATEST_VERSION" | cut -d. -f2)
PATCH=$(echo "$LATEST_VERSION" | cut -d. -f3)
sed -i "s/^#define INBE_VERSION_MAJOR .*/#define INBE_VERSION_MAJOR $MAJOR/" "$VERSION_H_FILE"
sed -i "s/^#define INBE_VERSION_MINOR .*/#define INBE_VERSION_MINOR $MINOR/" "$VERSION_H_FILE"
sed -i "s/^#define INBE_VERSION_PATCH .*/#define INBE_VERSION_PATCH $PATCH/" "$VERSION_H_FILE"
sed -i "s/^#define INBE_VERSION_STRING .*/#define INBE_VERSION_STRING \"$LATEST_VERSION\"/" "$VERSION_H_FILE"
echo "✓ Updated $VERSION_H_FILE"
# Create changelog directory
mkdir -p "$CHANGELOG_DIR"
# Generate only missing changelog files
# Generate changelog files (position-based: oldest = 1, newest = N)
# Reverse versions so oldest is processed first
TOTAL_VERSIONS=$(echo "$VERSIONS" | wc -l)
POSITION=0
while IFS= read -r VERSION; do
# versionCode = patch + 1
CODE=$(($(echo "$VERSION" | cut -d. -f3) + 1))
POSITION=$((POSITION + 1))
# Calculate position from end (newest gets highest number)
CODE=$((TOTAL_VERSIONS - POSITION + 1))
OUTPUT_FILE="$CHANGELOG_DIR/$CODE.txt"
# Skip if file already exists
@@ -50,17 +73,20 @@ while IFS= read -r VERSION; do
fi
# Extract changelog content for this version
CHANGELOG_CONTENT=$(awk -v version="[$VERSION]" '
CHANGELOG_CONTENT=$(awk -v ver="$VERSION" '
BEGIN { in_section=0 }
/^## \[/ {
if (found) exit
if ($0 ~ "\\[\\[" version "\\]\\]") {
found=1
if (in_section) exit
if (index($0, ver) > 0) {
in_section=1
next
}
}
found && /^### / { subsection=1 }
found { print }
' "$CHANGELOG_FILE" | sed '1d;/^$/d' | head -n -1)
in_section {
# Print section headers and bullet points
if (/^### / || /^- /) print
}
' "$CHANGELOG_FILE")
echo "$CHANGELOG_CONTENT" > "$OUTPUT_FILE"
echo "✓ Created $OUTPUT_FILE"