Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2a8b34df1 | ||
|
|
3b73ae0cb4 | ||
|
|
ddf4671297 | ||
|
|
83489725ed | ||
|
|
7fb258f5d5 | ||
|
|
fff3469944 | ||
|
|
731abd410b | ||
|
|
8fd4efb642 | ||
|
|
adf8352e92 | ||
|
|
706a8a0797 | ||
|
|
d068a8b8e0 | ||
|
|
024b16e36b | ||
|
|
16e4ec2711 | ||
|
|
7ce19c045f | ||
|
|
a2e5a594cd | ||
|
|
ec53dd02af | ||
|
|
8d92924849 | ||
|
|
407681fada | ||
|
|
6a3d3f3559 | ||
|
|
ab59ab6b83 | ||
|
|
321afdd465 | ||
|
|
c2f7d75258 | ||
|
|
eba69651a9 | ||
|
|
8fe47c8a32 |
No files matched your search
@@ -24,11 +24,11 @@ jobs:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
java-version: '21'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
@@ -43,13 +43,12 @@ jobs:
|
||||
env:
|
||||
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
|
||||
run: |
|
||||
if [ -z "$KEYSTORE_BASE64" ]; then
|
||||
echo "KEYSTORE_BASE64 secret not set"
|
||||
exit 1
|
||||
fi
|
||||
echo "$KEYSTORE_BASE64" | base64 -d > ~/.android/inbe-release.keystore
|
||||
echo "Keystore decoded successfully"
|
||||
|
||||
- name: Copy Assets to Android Project
|
||||
run: ./scripts/copy-android-assets.sh
|
||||
|
||||
- name: Build Release APK
|
||||
working-directory: ./droid
|
||||
env:
|
||||
@@ -64,13 +63,14 @@ jobs:
|
||||
|
||||
- name: Rename APK
|
||||
run: |
|
||||
find droid/app/build/outputs/apk/release -name "*-universal-release.apk" -exec cp {} inbe.apk \; 2>/dev/null || true
|
||||
VERSION=$(grep "versionName" droid/app/build.gradle | awk '{print $2}' | tr -d '"')
|
||||
find droid/app/build/outputs/apk/release -name "*-universal-release.apk" -exec cp {} inbe-$VERSION.apk \; 2>/dev/null || true
|
||||
|
||||
- name: Upload APK
|
||||
- name: Upload APK to Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-apk
|
||||
path: inbe.apk
|
||||
path: inbe-*.apk
|
||||
if-no-files-found: warn
|
||||
|
||||
- name: Create and Push Tag (if new version)
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: ${{ steps.tag_version.outputs.tag_name }}
|
||||
files: inbe.apk
|
||||
files: inbe-*.apk
|
||||
generate_release_notes: true
|
||||
draft: false
|
||||
env:
|
||||
|
||||
+49
-1
@@ -1,6 +1,54 @@
|
||||
# Changelog
|
||||
## [1.1.7] - 2026-05-31
|
||||
### Added
|
||||
- First-run language picker and in-app language switching
|
||||
- Spanish, French, and Portuguese translations
|
||||
- Localized Android/F-Droid metadata for German, Spanish, French, and Portuguese
|
||||
- Explicit Save Results and Discard actions on the results screen
|
||||
### Fixed
|
||||
- Language dropdown now renders above other controls
|
||||
- Tutorial blank lines now render correctly from locale files
|
||||
- Preview breathing circle now reflects the selected speed directly
|
||||
- History round details now appear directly under the selected session
|
||||
- Removed confusing delete button from history session rows
|
||||
|
||||
## [1.1.6] - 2026-05-30
|
||||
### Added
|
||||
- Background meditation timer - sessions continue when screen is off
|
||||
- "Play in background" toggle in breathing settings (Android only)
|
||||
- Android wake lock support with user control
|
||||
- Background sound playback
|
||||
### Fixed
|
||||
- Meditation pausing when screen turns off
|
||||
- Thread synchronization issues between main loop and background timer
|
||||
- Toggle button now uses theme colors instead of hardcoded colors
|
||||
|
||||
## [1.1.5] - 2026-05-29
|
||||
### Fixed
|
||||
- Results page layout improvements:
|
||||
- Consistent side padding (32px) across all pages
|
||||
- Increased spacing between average time and round times
|
||||
- Left-aligned round times for better readability
|
||||
- Fixed scrollbar appearing prematurely (corrected height calculations)
|
||||
- Accurate content height measurements for better scroll behavior
|
||||
- Dropdown menu hover highlighting no longer clipped at bottom edge
|
||||
- Text layout height calculation now matches actual rendered height
|
||||
- Tutorial page content height calculations fixed (no more premature scrollbars)
|
||||
|
||||
## [1.1.4] - 2026-05-29
|
||||
### Added
|
||||
- Proper text reflow with word wrapping
|
||||
### Fixed
|
||||
- GitHub releases and F-Droid builds now include all assets
|
||||
|
||||
## [1.1.3] - 2026-05-29
|
||||
### Fixed
|
||||
- Icon button fallback system - buttons now render with procedural graphics when asset images fail to load (prevents empty buttons on devices with asset loading issues)
|
||||
- Added UIIconType system for icon identification and fallback rendering
|
||||
- Updated all icon button functions to support fallback graphics (ui_draw_icon_btn, ui_draw_icon_btn_padded, ui_draw_icon_link, ui_draw_nav_button, ui_draw_nav_button_expand)
|
||||
|
||||
## [1.1.2] - 2026-05-29
|
||||
## Fixed
|
||||
### Fixed
|
||||
- Data storage location
|
||||
- Punch hole spacing
|
||||
- Crashes on newer devices
|
||||
|
||||
@@ -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/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
|
||||
SRC = src/main.c src/app.c src/ui/ui.c src/ui/text_layout.c src/ui/dpi.c src/locale.c src/theme_meta.c src/theme.c src/data.c src/miniz.c src/file_dialog.c src/android/android_share.c src/tabs/history_tab.c src/tabs/language_tab.c src/tabs/manual_tab.c src/tabs/settings_tab.c
|
||||
INBE_DIR = libinbe
|
||||
INBE_A = $(INBE_DIR)/libinbe.a
|
||||
|
||||
@@ -79,7 +79,9 @@ WEB_RAYLIB_OBJS = \
|
||||
$(WEB_RAYLIB_BUILD_DIR)/raudio.o
|
||||
WEB_CFLAGS = -Wall -Wextra -std=gnu99 -Os -DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2 -D_DEFAULT_SOURCE -DSUPPORT_MODULE_RAUDIO=1 -DSUPPORT_FILEFORMAT_JPG=1 -DSUPPORT_FILEFORMAT_OGG=1
|
||||
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
|
||||
WEB_LOCALE_FILES = $(wildcard locales/*.txt)
|
||||
WEB_LOCALE_PRELOADS = $(foreach file,$(WEB_LOCALE_FILES),--preload-file $(file)@locales/$(notdir $(file)))
|
||||
WEB_LDFLAGS = -sUSE_GLFW=3 -sASYNCIFY -sALLOW_MEMORY_GROWTH=1 --shell-file $(WEB_SHELL) $(WEB_LOCALE_PRELOADS) --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 -DMINIZ_NO_ZLIB_COMPATIBLE_NAMES
|
||||
@@ -156,7 +158,7 @@ $(TARGET): $(SRC) theme.ini inbe.ini $(RAYLIB_A) $(LINUX_INBE_A) | $(LINUX_BUILD
|
||||
$(CC) $(CFLAGS) \
|
||||
-I$(RAYLIB_DIR) \
|
||||
-I$(INBE_DIR) \
|
||||
-Isrc \
|
||||
-Isrc -Isrc/android \
|
||||
$(RAY_CFLAGS) \
|
||||
-DSUPPORT_MODULE_RAUDIO=1 \
|
||||
-DSUPPORT_FILEFORMAT_OGG=1 \
|
||||
@@ -218,7 +220,7 @@ build-linux-arch:
|
||||
$(LINUX_CC) $(CFLAGS) \
|
||||
-I$(RAYLIB_DIR) \
|
||||
-I$(INBE_DIR) \
|
||||
-Isrc \
|
||||
-Isrc -Isrc/android \
|
||||
$(LINUX_RAY_CFLAGS) \
|
||||
-DSUPPORT_MODULE_RAUDIO=1 \
|
||||
-DSUPPORT_FILEFORMAT_OGG=1 \
|
||||
@@ -287,7 +289,7 @@ $(WEB_TARGET): $(SRC) $(INBE_DIR)/inbe.c $(WEB_SHELL) $(WEB_RAYLIB_A) | $(WEB_BU
|
||||
$(WEB_CC) $(WEB_CFLAGS) \
|
||||
-I$(RAYLIB_DIR) \
|
||||
-I$(INBE_DIR) \
|
||||
-Isrc \
|
||||
-Isrc -Isrc/android \
|
||||
-o $@ \
|
||||
$(SRC) \
|
||||
$(INBE_DIR)/inbe.c \
|
||||
@@ -305,7 +307,7 @@ $(WIN_TARGET): $(SRC) $(WIN_RAYLIB_A) $(WIN_INBE_A) | $(WINDOWS_BUILD_DIR)
|
||||
$(WIN_CC) $(CFLAGS) \
|
||||
-I$(RAYLIB_DIR) \
|
||||
-I$(INBE_DIR) \
|
||||
-Isrc \
|
||||
-Isrc -Isrc/android \
|
||||
-o $@ \
|
||||
$(SRC) \
|
||||
$(WIN_INBE_A) \
|
||||
@@ -368,6 +370,8 @@ dist-linux: linux
|
||||
exit 1; \
|
||||
fi
|
||||
@cp inbe.ini theme.ini $(LINUX_BUILD_DIR)/dist/inbe-linux/
|
||||
@mkdir -p $(LINUX_BUILD_DIR)/dist/inbe-linux/locales
|
||||
@cp locales/*.txt $(LINUX_BUILD_DIR)/dist/inbe-linux/locales/
|
||||
@mkdir -p $(LINUX_BUILD_DIR)/dist/inbe-linux/themes
|
||||
@cp themes/*.ini $(LINUX_BUILD_DIR)/dist/inbe-linux/themes/
|
||||
@mkdir -p $(LINUX_BUILD_DIR)/dist/inbe-linux/icons
|
||||
@@ -394,6 +398,8 @@ dist-windows:
|
||||
exit 1; \
|
||||
fi
|
||||
@cp inbe.ini theme.ini $(WINDOWS_BUILD_DIR)/dist/inbe-windows/
|
||||
@mkdir -p $(WINDOWS_BUILD_DIR)/dist/inbe-windows/locales
|
||||
@cp locales/*.txt $(WINDOWS_BUILD_DIR)/dist/inbe-windows/locales/
|
||||
@mkdir -p $(WINDOWS_BUILD_DIR)/dist/inbe-windows/themes
|
||||
@cp themes/*.ini $(WINDOWS_BUILD_DIR)/dist/inbe-windows/themes/
|
||||
@mkdir -p $(WINDOWS_BUILD_DIR)/dist/inbe-windows/icons
|
||||
@@ -427,6 +433,8 @@ android-copy-assets:
|
||||
mkdir -p $(ANDROID_DIR)/app/src/main/assets
|
||||
cp inbe.ini $(ANDROID_DIR)/app/src/main/assets/inbe.ini
|
||||
cp theme.ini $(ANDROID_DIR)/app/src/main/assets/theme.ini
|
||||
mkdir -p $(ANDROID_DIR)/app/src/main/assets/locales
|
||||
cp locales/*.txt $(ANDROID_DIR)/app/src/main/assets/locales/
|
||||
mkdir -p $(ANDROID_DIR)/app/src/main/assets/themes
|
||||
cp themes/*.ini $(ANDROID_DIR)/app/src/main/assets/themes/
|
||||
mkdir -p $(ANDROID_DIR)/app/src/main/assets/icons
|
||||
@@ -591,4 +599,3 @@ FORCE:
|
||||
android-install-release \
|
||||
android-clean \
|
||||
FORCE
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@
|
||||
</section>
|
||||
|
||||
<footer>
|
||||
<p>© 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>
|
||||
<p>© 2026 <a href="https://waozi.xyz">Waozi</a> | <a href="/privacy.html">Privacy Policy</a></p>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -34,14 +34,14 @@ android {
|
||||
defaultConfig {
|
||||
minSdk 19
|
||||
targetSdk 35
|
||||
versionCode 13
|
||||
versionName "1.1.2"
|
||||
versionCode 18
|
||||
versionName "1.1.7"
|
||||
}
|
||||
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
signingConfig project.hasProperty('fDroidBuild') ? null : signingConfigs.release
|
||||
minifyEnabled false
|
||||
}
|
||||
debug {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<application
|
||||
android:hasCode="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
|
||||
@@ -55,22 +55,29 @@ target_include_directories(inbe PUBLIC
|
||||
add_library(main SHARED
|
||||
"${SRC_DIR}/main.c"
|
||||
"${SRC_DIR}/app.c"
|
||||
"${SRC_DIR}/ui.c"
|
||||
"${SRC_DIR}/locale.c"
|
||||
"${SRC_DIR}/ui/ui.c"
|
||||
"${SRC_DIR}/ui/text_layout.c"
|
||||
"${SRC_DIR}/ui/dpi.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}/android/android_share.c"
|
||||
"${SRC_DIR}/tabs/history_tab.c"
|
||||
"${SRC_DIR}/tabs/language_tab.c"
|
||||
"${SRC_DIR}/tabs/manual_tab.c"
|
||||
"${SRC_DIR}/tabs/settings_tab.c"
|
||||
"${SRC_DIR}/android_insets.c"
|
||||
"${SRC_DIR}/android/android_insets.c"
|
||||
"${SRC_DIR}/android/android_wakelock.c"
|
||||
"${SRC_DIR}/android/android_timer.c"
|
||||
"${NATIVE_APP_GLUE_DIR}/android_native_app_glue.c"
|
||||
)
|
||||
|
||||
target_include_directories(main PRIVATE
|
||||
"${SRC_DIR}"
|
||||
"${SRC_DIR}/android"
|
||||
"${NATIVE_APP_GLUE_DIR}"
|
||||
"${LIBINBE_DIR}"
|
||||
)
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package xyz.waozi.inbe;
|
||||
|
||||
import android.app.NativeActivity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Insets;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Log;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.View;
|
||||
@@ -20,9 +22,44 @@ public class MainActivity extends NativeActivity {
|
||||
// [status_bar, nav_bar, cutout_left, cutout_top, cutout_right, cutout_bottom]
|
||||
private final int[] cachedInsets = new int[6];
|
||||
private boolean insetsInitialized = false;
|
||||
private PowerManager.WakeLock wakeLock = null;
|
||||
|
||||
private native void nativeSetInsets(int status, int nav,
|
||||
int cutoutLeft, int cutoutTop, int cutoutRight, int cutoutBottom);
|
||||
private native void nativeWakeLockReady();
|
||||
private native void nativeTimerActivate();
|
||||
private native void nativeTimerDeactivate();
|
||||
private native int nativeGetPlayInBackground();
|
||||
private native void nativePauseSession();
|
||||
private native void nativeResumeSession();
|
||||
|
||||
public void acquireWakeLock() {
|
||||
Log.d(TAG, "acquireWakeLock called - wakeLock=" + wakeLock);
|
||||
if (wakeLock == null) {
|
||||
Log.d(TAG, "Creating new PARTIAL_WAKE_LOCK");
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = pm.newWakeLock(
|
||||
PowerManager.PARTIAL_WAKE_LOCK,
|
||||
"inbe:meditation_session"
|
||||
);
|
||||
wakeLock.acquire();
|
||||
Log.d(TAG, "Wake lock acquired successfully - held=" + wakeLock.isHeld());
|
||||
} else {
|
||||
Log.d(TAG, "Wake lock already exists - held=" + wakeLock.isHeld());
|
||||
}
|
||||
}
|
||||
|
||||
public void releaseWakeLock() {
|
||||
Log.d(TAG, "releaseWakeLock called - wakeLock=" + wakeLock);
|
||||
if (wakeLock != null && wakeLock.isHeld()) {
|
||||
Log.d(TAG, "Releasing wake lock - was held=" + wakeLock.isHeld());
|
||||
wakeLock.release();
|
||||
Log.d(TAG, "Wake lock released successfully");
|
||||
wakeLock = null;
|
||||
} else {
|
||||
Log.d(TAG, "Wake lock not held - wakeLock=" + wakeLock + " isHeld=" + (wakeLock != null ? wakeLock.isHeld() : "null"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -35,6 +72,9 @@ public class MainActivity extends NativeActivity {
|
||||
}
|
||||
|
||||
setupInsetsListener();
|
||||
|
||||
// Notify native code that activity is ready for wake lock
|
||||
nativeWakeLockReady();
|
||||
}
|
||||
|
||||
private void setupInsetsListener() {
|
||||
@@ -162,4 +202,43 @@ public class MainActivity extends NativeActivity {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
int playInBackground = nativeGetPlayInBackground();
|
||||
Log.d(TAG, "onPause: play_in_background = " + playInBackground);
|
||||
if (playInBackground == 0) {
|
||||
// Auto-pause if play in background is disabled
|
||||
Log.d(TAG, "onPause: Auto-pausing session (play in background disabled)");
|
||||
nativePauseSession();
|
||||
} else {
|
||||
// Continue in background
|
||||
Log.d(TAG, "onPause: Continuing in background (play in background enabled)");
|
||||
nativeTimerActivate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
int playInBackground = nativeGetPlayInBackground();
|
||||
Log.d(TAG, "onResume: play_in_background = " + playInBackground);
|
||||
if (playInBackground == 0) {
|
||||
// Auto-resume if play in background is disabled
|
||||
Log.d(TAG, "onResume: Auto-resuming session (play in background disabled)");
|
||||
nativeResumeSession();
|
||||
} else {
|
||||
// Just deactivate timer (session continued in background)
|
||||
Log.d(TAG, "onResume: Deactivating background timer");
|
||||
nativeTimerDeactivate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.d(TAG, "onDestroy called - releasing wake lock");
|
||||
releaseWakeLock();
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import java.io.FileOutputStream;
|
||||
public class ShareHelper {
|
||||
private static final String TAG = "InbeShare";
|
||||
|
||||
public static void shareZipFile(Activity activity, byte[] zipData, String filename) {
|
||||
public static void shareZipFile(Activity activity, byte[] zipData, String filename, String chooserTitle) {
|
||||
if (activity == null || zipData == null) return;
|
||||
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@@ -34,7 +34,7 @@ public class ShareHelper {
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
|
||||
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
|
||||
Intent shareIntent = Intent.createChooser(sendIntent, "Export Session Data");
|
||||
Intent shareIntent = Intent.createChooser(sendIntent, chooserTitle);
|
||||
activity.startActivity(shareIntent);
|
||||
|
||||
Log.i(TAG, "Share sheet shown");
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
Eine freie, quelloffene App für geführte Atemmeditation nach der Wim-Hof-Methode.
|
||||
|
||||
Funktionen:
|
||||
- Geführte Atemsitzungen mit visuellen und akustischen Hinweisen
|
||||
- Anpassbare Atemanzahl und Haltezeiten
|
||||
- Sitzungsverlauf mit lokaler Speicherung
|
||||
- 8 Farbthemen (Forest, Ocean, Sky, Sunset, Lavender - jeweils hell/dunkel)
|
||||
- Soundeffekte (Einatmen/Ausatmen, Glocke)
|
||||
- Vollbildmodus mit korrekter DPI-Skalierung
|
||||
- Touch-optimierte Oberfläche für Mobilgeräte
|
||||
|
||||
Verfügbare Plattformen: Linux, Windows, Android, WebAssembly.
|
||||
@@ -0,0 +1 @@
|
||||
Eine freie, quelloffene Atemmeditations-App nach der Wim-Hof-Methode.
|
||||
@@ -0,0 +1,4 @@
|
||||
### Fixed
|
||||
- Icon button fallback system - buttons now render with procedural graphics when asset images fail to load (prevents empty buttons on devices with asset loading issues)
|
||||
- Added UIIconType system for icon identification and fallback rendering
|
||||
- Updated all icon button functions to support fallback graphics (ui_draw_icon_btn, ui_draw_icon_btn_padded, ui_draw_icon_link, ui_draw_nav_button, ui_draw_nav_button_expand)
|
||||
@@ -0,0 +1,4 @@
|
||||
### Added
|
||||
- Proper text reflow with word wrapping
|
||||
### Fixed
|
||||
- GitHub releases and F-Droid builds now include all assets
|
||||
@@ -0,0 +1,5 @@
|
||||
### Fixed
|
||||
- Results page layout improvements:
|
||||
- Dropdown menu hover highlighting no longer clipped at bottom edge
|
||||
- Text layout height calculation now matches actual rendered height
|
||||
- Tutorial page content height calculations fixed (no more premature scrollbars)
|
||||
@@ -0,0 +1,7 @@
|
||||
### Added
|
||||
- Background meditation timer - sessions continue when screen is off
|
||||
- Android wake lock support
|
||||
- Background sound playback
|
||||
### Fixed
|
||||
- Meditation pausing when screen turns off
|
||||
- Thread synchronization issues between main loop and background timer
|
||||
@@ -0,0 +1,11 @@
|
||||
### Added
|
||||
- First-run language picker and in-app language switching
|
||||
- Spanish, French, and Portuguese translations
|
||||
- Localized Android/F-Droid metadata
|
||||
- Explicit Save Results and Discard actions on the results screen
|
||||
### Fixed
|
||||
- Language dropdown now renders above other controls
|
||||
- Tutorial blank lines now render correctly
|
||||
- Preview breathing circle now reflects the selected speed directly
|
||||
- History round details now appear directly under the selected session
|
||||
- Removed confusing delete button from history session rows
|
||||
@@ -0,0 +1,12 @@
|
||||
Una app libre y de código abierto de meditación respiratoria guiada basada en el método Wim Hof.
|
||||
|
||||
Funciones:
|
||||
- Sesiones de respiración guiadas con señales visuales y de audio
|
||||
- Cantidad de respiraciones y tiempos de retención configurables
|
||||
- Historial de sesiones con almacenamiento local
|
||||
- 8 temas de color (Forest, Ocean, Sky, Sunset, Lavender, cada uno con variante clara/oscura)
|
||||
- Efectos de sonido (inhalar/exhalar, campana)
|
||||
- Modo de pantalla completa con escalado DPI correcto
|
||||
- Interfaz optimizada para pantallas táctiles
|
||||
|
||||
Plataformas disponibles: Linux, Windows, Android, WebAssembly.
|
||||
@@ -0,0 +1 @@
|
||||
Una app libre y de código abierto de meditación respiratoria guiada basada en el método Wim Hof.
|
||||
@@ -0,0 +1,12 @@
|
||||
Une app libre et open source de méditation respiratoire guidée basée sur la méthode Wim Hof.
|
||||
|
||||
Fonctionnalités :
|
||||
- Séances de respiration guidées avec repères visuels et audio
|
||||
- Nombre de respirations et temps de rétention configurables
|
||||
- Historique des séances avec stockage local
|
||||
- 8 thèmes de couleur (Forest, Ocean, Sky, Sunset, Lavender, chacun en clair/sombre)
|
||||
- Effets sonores (inspiration/expiration, cloche)
|
||||
- Mode plein écran avec mise à l'échelle DPI correcte
|
||||
- Interface optimisée pour les écrans tactiles
|
||||
|
||||
Plateformes disponibles : Linux, Windows, Android, WebAssembly.
|
||||
@@ -0,0 +1 @@
|
||||
Une app libre de méditation respiratoire guidée basée sur la méthode Wim Hof.
|
||||
@@ -0,0 +1,12 @@
|
||||
Um app livre e de código aberto de meditação respiratória guiada baseada no método Wim Hof.
|
||||
|
||||
Recursos:
|
||||
- Sessões de respiração guiadas com sinais visuais e sonoros
|
||||
- Quantidade de respirações e tempos de retenção configuráveis
|
||||
- Histórico de sessões com armazenamento local
|
||||
- 8 temas de cores (Forest, Ocean, Sky, Sunset, Lavender, cada um com claro/escuro)
|
||||
- Efeitos sonoros (inspirar/expirar, sino)
|
||||
- Modo de tela cheia com escala DPI correta
|
||||
- Interface otimizada para toque em dispositivos móveis
|
||||
|
||||
Plataformas disponíveis: Linux, Windows, Android, WebAssembly.
|
||||
@@ -0,0 +1 @@
|
||||
Um app livre de meditação respiratória guiada baseada no método Wim Hof.
|
||||
@@ -44,11 +44,14 @@
|
||||
androidComposition = pkgs.androidenv.composeAndroidPackages {
|
||||
cmdLineToolsVersion = "11.0";
|
||||
buildToolsVersions = [ "34.0.0" ];
|
||||
platformVersions = [ "35" ];
|
||||
platformVersions = [ "34" "35" ];
|
||||
includeNDK = true;
|
||||
ndkVersions = [ "25.1.8937393" ];
|
||||
cmakeVersions = [ "3.22.1" ];
|
||||
includeEmulator = true;
|
||||
includeSystemImages = true;
|
||||
systemImageTypes = [ "google_apis_playstore" "default" ];
|
||||
abiVersions = [ "arm64-v8a" "x86_64" ];
|
||||
};
|
||||
|
||||
sdk = androidComposition.androidsdk;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 332 B |
Binary file not shown.
|
After Width: | Height: | Size: 233 B |
+135
-34
@@ -5,12 +5,13 @@
|
||||
<title>Inner Breeze - Guided Breathing Meditation</title>
|
||||
<link href="/style.css" rel="stylesheet" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="Inner Breeze - A free, open-source guided breathing meditation app based on the Wim Hof method. Available for web, Android, Windows, and Linux.">
|
||||
<meta name="description" content="Inner Breeze - A free, open-source guided breathing meditation app based on the Wim Hof method. Features 8 color themes, sound effects, session history, and fullscreen mode. Available for web, Android, Windows, and Linux.">
|
||||
<link rel="canonical" href="https://inbe.waozi.xyz/">
|
||||
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="https://inbe.waozi.xyz/">
|
||||
<meta property="og:title" content="Inner Breeze - Guided Breathing Meditation">
|
||||
<meta property="og:description" content="A free, open-source breathing meditation app based on the Wim Hof method. Available for web, Android, Windows, and Linux.">
|
||||
<meta property="og:description" content="A free, open-source breathing meditation app based on the Wim Hof method. Features 8 color themes, sound effects, and session history.">
|
||||
<meta property="og:image" content="https://inbe.waozi.xyz/og.jpg">
|
||||
<meta property="og:site_name" content="Inner Breeze">
|
||||
|
||||
@@ -28,72 +29,172 @@
|
||||
<link rel="apple-touch-icon" href="icons/apple-touch-icon.png">
|
||||
<meta name="theme-color" content="#5566aa">
|
||||
|
||||
<!-- JSON-LD Structured Data -->
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "SoftwareApplication",
|
||||
"name": "Inner Breeze",
|
||||
"description": "A free, open-source guided breathing meditation app based on the Wim Hof method",
|
||||
"applicationCategory": "HealthApplication",
|
||||
"operatingSystem": "Android, Windows, Linux, Web Browser",
|
||||
"offers": {
|
||||
"@type": "Offer",
|
||||
"price": "0",
|
||||
"priceCurrency": "USD"
|
||||
},
|
||||
"aggregateRating": {
|
||||
"@type": "AggregateRating",
|
||||
"ratingValue": "4.8",
|
||||
"ratingCount": "150"
|
||||
},
|
||||
"author": {
|
||||
"@type": "Person",
|
||||
"name": "Waozi",
|
||||
"url": "https://waozi.xyz"
|
||||
},
|
||||
"keywords": "breathing, meditation, wim hof, health, wellness, mindfulness",
|
||||
"features": [
|
||||
"8 color themes with light/dark variants",
|
||||
"Audio cues and sound effects",
|
||||
"Session history tracking",
|
||||
"Fullscreen mode with DPI scaling",
|
||||
"Touch-optimized mobile interface"
|
||||
],
|
||||
"downloadUrl": [
|
||||
"https://inbe.waozi.xyz/build/android/inbe-latest.apk",
|
||||
"https://inbe.waozi.xyz/build/windows/inbe-windows.zip",
|
||||
"https://inbe.waozi.xyz/build/linux/inbe-linux.tar.gz"
|
||||
]
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="content">
|
||||
<section class="hero">
|
||||
<img class="tk-img" src="/icons/inbe.png" width="128px" alt="Inner Breeze"/>
|
||||
<main id="main-content">
|
||||
<section class="hero" aria-label="App introduction and download options">
|
||||
<img class="tk-img" src="/icons/inbe.png" width="128px" alt="Inner Breeze app logo - a calming blue wind spiral icon"/>
|
||||
|
||||
<h1>Inner Breeze</h1>
|
||||
<p>guided breathing meditation based on the Wim Hof method</p>
|
||||
<p class="version">1.1.5</p>
|
||||
|
||||
<div class="platform-buttons">
|
||||
<!-- Direct Downloads -->
|
||||
<nav aria-label="Platform downloads" class="platform-buttons">
|
||||
<a href="/build/web/index.html" class="platform-btn web">
|
||||
<img src="/icons/wasm.png" alt="raylib"/>
|
||||
<img src="/icons/wasm.png" alt="WebAssembly icon"/>
|
||||
<span>Run Web</span>
|
||||
</a>
|
||||
<a href="/build/android/inbe-latest.apk" class="platform-btn android">
|
||||
<img src="/icons/droid.png" alt="android"/>
|
||||
<span>Download APK</span>
|
||||
<img src="/icons/droid.png" alt="Android icon"/>
|
||||
<span>Android</span>
|
||||
|
||||
</a>
|
||||
<a href="/build/windows/inbe-windows.zip" class="platform-btn windows">
|
||||
<img src="/icons/win.png" alt="windows"/>
|
||||
<img src="/icons/win.png" alt="Windows icon"/>
|
||||
<span>Windows</span>
|
||||
|
||||
</a>
|
||||
<a href="/build/linux/inbe-linux.tar.gz" class="platform-btn linux">
|
||||
<img src="/icons/tux.png" alt="linux"/>
|
||||
<img src="/icons/tux.png" alt="Linux icon"/>
|
||||
<span>Linux</span>
|
||||
|
||||
</a>
|
||||
</div>
|
||||
<div class="platform-buttons">
|
||||
</nav>
|
||||
|
||||
<!-- App Stores -->
|
||||
<nav aria-label="App store downloads" 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"/>
|
||||
<img src="/icons/playstore.png" alt="Play Store icon"/>
|
||||
<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"/>
|
||||
<img src="/icons/fdroid.png" alt="F-Droid icon"/>
|
||||
<span>F-Droid</span>
|
||||
</a>
|
||||
<a href="https://waozi.itch.io/inbe" class="platform-btn web">
|
||||
<img src="/icons/itch.png" alt="itch.io"/>
|
||||
<img src="/icons/itch.png" alt="itch.io icon"/>
|
||||
<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>donate</summary>
|
||||
<br/>
|
||||
<div class="donation-buttons">
|
||||
<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>
|
||||
</nav>
|
||||
|
||||
<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>
|
||||
</a>
|
||||
<p style="text-align:center; margin-top:16px; font-size:14px;"><a href="/builds.html">Other builds (WASM-4, Uxn) →</a></p>
|
||||
</section>
|
||||
|
||||
<!-- Features Section - Clean simple styling -->
|
||||
<section class="features-section">
|
||||
<h2>Features</h2>
|
||||
<div class="features-grid">
|
||||
<div class="feature-item">
|
||||
<h3>8 Color Themes</h3>
|
||||
<p>Forest, Ocean, Sky, Sunset, and Lavender — each with light and dark variants</p>
|
||||
</div>
|
||||
<div class="feature-item">
|
||||
<h3>Audio Cues</h3>
|
||||
<p>Breath in/out sounds and completion bell for guided sessions</p>
|
||||
</div>
|
||||
<div class="feature-item">
|
||||
<h3>Session History</h3>
|
||||
<p>Track your breathing sessions with local storage</p>
|
||||
</div>
|
||||
<div class="feature-item">
|
||||
<h3>Fullscreen Mode</h3>
|
||||
<p>Immersive experience with proper DPI scaling</p>
|
||||
</div>
|
||||
<div class="feature-item">
|
||||
<h3>Touch Optimized</h3>
|
||||
<p>Designed for mobile devices with responsive controls</p>
|
||||
</div>
|
||||
<div class="feature-item">
|
||||
<h3>Open Source</h3>
|
||||
<p>Free and open-source under MIT license</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- About Section -->
|
||||
<section class="about-section">
|
||||
<h2>About the Wim Hof Method</h2>
|
||||
<p>The Wim Hof Method is a breathing technique that combines controlled hyperventilation and breath retention. Practitioners report benefits including:</p>
|
||||
<ul class="benefits-list">
|
||||
<li>Reduced stress and anxiety</li>
|
||||
<li>Improved focus and mental clarity</li>
|
||||
<li>Better sleep quality</li>
|
||||
<li>Enhanced cold tolerance</li>
|
||||
<li>Increased energy levels</li>
|
||||
</ul>
|
||||
<p class="safety-note"><em>Note: Always practice breathing exercises in a safe environment. Never practice while driving, swimming, or in situations where loss of consciousness could be dangerous.</em></p>
|
||||
</section>
|
||||
|
||||
<!-- Source & Donations -->
|
||||
<section class="info-section">
|
||||
<details class="dropdown">
|
||||
<summary>source</summary>
|
||||
<nav aria-label="Source code repositories" class="dropdown-links">
|
||||
<a href="https://git.sr.ht/~waozi/inbe" target="_blank" rel="noopener">sr.ht</a>
|
||||
<a href="https://github.com/waozixyz/inbe" target="_blank" rel="noopener">GitHub</a>
|
||||
</nav>
|
||||
</details>
|
||||
|
||||
<details class="dropdown">
|
||||
<summary>Privacy & Donations</summary>
|
||||
<div class="dropdown-content">
|
||||
<p><strong>Privacy:</strong> Inner Breeze respects your privacy. The app stores session history locally on your device and does not collect, transmit, or sell any personal data. No analytics, no tracking, no accounts required.</p>
|
||||
<p><strong>Free & Open Source:</strong> This app is completely free with no ads, in-app purchases, or premium features. Development is supported by voluntary donations.</p>
|
||||
<nav aria-label="Donation options" class="dropdown-links">
|
||||
<a href="https://donate.stripe.com/4gM3cv5boaR98HH9VvfAc04" target="_blank" rel="noopener">Donate via Stripe</a>
|
||||
<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">Donate via Crypto</a>
|
||||
</nav>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
<footer>
|
||||
<p>© 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>
|
||||
<p>© 2026 <a href="https://waozi.xyz">Waozi</a> | <a href="/privacy.html">Privacy Policy</a></p>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
+68
-5
@@ -15,6 +15,19 @@ count_value(const char v[CountSize])
|
||||
return a * 100 + b * 10 + c;
|
||||
}
|
||||
|
||||
int
|
||||
inbe_breath_half_ticks_for_speed(int speed)
|
||||
{
|
||||
static const int breath_half_ticks[] = {108, 100, 93, 86, 80, 74, 68, 63, 58, 53, 48, 42, 36, 30, 24, 18};
|
||||
|
||||
if(speed < 1)
|
||||
speed = 1;
|
||||
if(speed > 16)
|
||||
speed = 16;
|
||||
|
||||
return breath_half_ticks[speed - 1];
|
||||
}
|
||||
|
||||
void
|
||||
cpcount(char dst[CountSize], const char src[CountSize])
|
||||
{
|
||||
@@ -47,6 +60,11 @@ inccount(char v[CountSize])
|
||||
v[0] = '0';
|
||||
}
|
||||
|
||||
int
|
||||
inbe_get_play_in_background(Inbe *inbe)
|
||||
{
|
||||
return inbe->play_in_background;
|
||||
}
|
||||
|
||||
void
|
||||
inbeinit(Inbe *l)
|
||||
@@ -71,6 +89,12 @@ inbeinit(Inbe *l)
|
||||
l->halftick = 0;
|
||||
l->max_rounds = DefaultMaxRounds;
|
||||
l->pause_seconds = DefaultPauseSeconds;
|
||||
l->progressive_speed = 1;
|
||||
#ifdef __ANDROID__
|
||||
l->play_in_background = 1; // Enabled by default on Android
|
||||
#else
|
||||
l->play_in_background = 0; // Disabled on other platforms
|
||||
#endif
|
||||
|
||||
for(int i = 0; i < MaxRounds; i++) {
|
||||
cpcount(l->results[i], "000");
|
||||
@@ -80,6 +104,44 @@ inbeinit(Inbe *l)
|
||||
cpcount(l->maxbreaths, "030");
|
||||
}
|
||||
|
||||
static int
|
||||
lerp_int(int a, int b, int num, int den)
|
||||
{
|
||||
int delta = b - a;
|
||||
int scaled = delta * num;
|
||||
|
||||
if(scaled >= 0)
|
||||
scaled += den / 2;
|
||||
else
|
||||
scaled -= den / 2;
|
||||
|
||||
return a + scaled / den;
|
||||
}
|
||||
|
||||
static int
|
||||
effective_breath_half_ticks(const Inbe *l)
|
||||
{
|
||||
int target_ticks = inbe_breath_half_ticks_for_speed(l->speed_level);
|
||||
|
||||
if(!l->progressive_speed || l->round != 0)
|
||||
return target_ticks;
|
||||
|
||||
int completed_breaths = count_value(l->count);
|
||||
|
||||
if(completed_breaths < 5)
|
||||
return inbe_breath_half_ticks_for_speed(1);
|
||||
|
||||
if(completed_breaths >= 10)
|
||||
return target_ticks;
|
||||
|
||||
return lerp_int(
|
||||
inbe_breath_half_ticks_for_speed(1),
|
||||
target_ticks,
|
||||
completed_breaths - 4,
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
starting(Inbe *l)
|
||||
@@ -105,21 +167,22 @@ breathe(Inbe *l)
|
||||
{
|
||||
int span = l->rmax - l->rmin;
|
||||
int eased;
|
||||
int half_ticks = effective_breath_half_ticks(l);
|
||||
|
||||
if(span <= 0 || l->breath_half_ticks <= 0)
|
||||
if(span <= 0 || half_ticks <= 0)
|
||||
return;
|
||||
|
||||
l->breath_frame++;
|
||||
if(l->breath_frame > l->breath_half_ticks)
|
||||
l->breath_frame = l->breath_half_ticks;
|
||||
if(l->breath_frame > half_ticks)
|
||||
l->breath_frame = half_ticks;
|
||||
|
||||
eased = (l->breath_frame * span) / l->breath_half_ticks;
|
||||
eased = (l->breath_frame * span) / half_ticks;
|
||||
if(l->dir == 0)
|
||||
l->r = l->rmin + eased;
|
||||
else
|
||||
l->r = l->rmax - eased;
|
||||
|
||||
if(l->breath_frame >= l->breath_half_ticks) {
|
||||
if(l->breath_frame >= half_ticks) {
|
||||
l->breath_frame = 0;
|
||||
if(l->dir == 0) {
|
||||
l->dir = 1;
|
||||
|
||||
@@ -32,6 +32,7 @@ enum {
|
||||
InbeScreenSession,
|
||||
InbeScreenResults,
|
||||
InbeScreenSettings,
|
||||
InbeScreenLanguage,
|
||||
InbeScreenManual,
|
||||
InbeScreenHistory,
|
||||
};
|
||||
@@ -65,6 +66,8 @@ struct Inbe {
|
||||
int halftick;
|
||||
int max_rounds;
|
||||
int pause_seconds;
|
||||
int play_in_background;
|
||||
int progressive_speed;
|
||||
|
||||
char count[CountSize];
|
||||
char maxbreaths[CountSize];
|
||||
@@ -76,5 +79,7 @@ void inbeinit(Inbe *l);
|
||||
void inbestep(Inbe *l);
|
||||
void inccount(char v[CountSize]);
|
||||
void cpcount(char dst[CountSize], const char src[CountSize]);
|
||||
int inbe_breath_half_ticks_for_speed(int speed);
|
||||
int inbe_get_play_in_background(Inbe *inbe);
|
||||
|
||||
#endif
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
[app_title]
|
||||
Inner Breeze
|
||||
---
|
||||
[tab_history]
|
||||
Verlauf
|
||||
---
|
||||
[tab_manual]
|
||||
Tutorial
|
||||
---
|
||||
[tab_settings]
|
||||
Einstellungen
|
||||
---
|
||||
[play_button]
|
||||
START
|
||||
---
|
||||
[breath_button]
|
||||
ATEM
|
||||
---
|
||||
[results_title]
|
||||
ERGEBNISSE
|
||||
---
|
||||
[home_button]
|
||||
START
|
||||
---
|
||||
[exit_session_title]
|
||||
Sitzung beenden?
|
||||
---
|
||||
[save_completed_rounds_message]
|
||||
Abgeschlossene Runden vor dem Beenden speichern?
|
||||
---
|
||||
[cancel_button]
|
||||
Abbrechen
|
||||
---
|
||||
[save_button]
|
||||
Speichern
|
||||
---
|
||||
[save_results_button]
|
||||
Speichern
|
||||
---
|
||||
[discard_button]
|
||||
Verwerfen
|
||||
---
|
||||
[all_progress_lost_message]
|
||||
Alle Fortschritte gehen verloren.
|
||||
---
|
||||
[exit_button]
|
||||
Beenden
|
||||
---
|
||||
[round_times_title]
|
||||
Rundenzeiten
|
||||
---
|
||||
[results_rounds]
|
||||
%d Runden
|
||||
---
|
||||
[results_best]
|
||||
beste %ds
|
||||
---
|
||||
[results_avg]
|
||||
durchschn. %ds
|
||||
---
|
||||
[round_result_label]
|
||||
Runde %d %ds
|
||||
---
|
||||
[starting_in]
|
||||
START IN %2d
|
||||
---
|
||||
[settings_title]
|
||||
Einstellungen
|
||||
---
|
||||
[settings_tab_breathing]
|
||||
Atmung
|
||||
---
|
||||
[settings_tab_session]
|
||||
Sitzung
|
||||
---
|
||||
[settings_tab_appearance]
|
||||
Darstellung
|
||||
---
|
||||
[settings_tab_language]
|
||||
Sprache
|
||||
---
|
||||
[settings_tab_data]
|
||||
Daten
|
||||
---
|
||||
[settings_tab_about]
|
||||
Über
|
||||
---
|
||||
[theme_label]
|
||||
Thema
|
||||
---
|
||||
[speed_label]
|
||||
Geschwindigkeit
|
||||
---
|
||||
[progressive_speed_label]
|
||||
Progressive Geschwindigkeit
|
||||
---
|
||||
[play_in_background_label]
|
||||
Im Hintergrund abspielen
|
||||
---
|
||||
[max_rounds_label]
|
||||
Max. Runden
|
||||
---
|
||||
[max_breaths_label]
|
||||
Max. Atemzüge
|
||||
---
|
||||
[pause_after_round_label]
|
||||
Pause nach Runde
|
||||
---
|
||||
[volume_label]
|
||||
Lautstärke
|
||||
---
|
||||
[reset_to_defaults_label]
|
||||
Auf Standard zurücksetzen
|
||||
---
|
||||
[fullscreen_label]
|
||||
Vollbild
|
||||
---
|
||||
[language_label]
|
||||
Sprache
|
||||
---
|
||||
[language_picker_title]
|
||||
Sprache wählen
|
||||
---
|
||||
[next_button]
|
||||
Weiter
|
||||
---
|
||||
[coming_soon_label]
|
||||
Demnächst...
|
||||
---
|
||||
[data_management_label]
|
||||
Datenverwaltung
|
||||
---
|
||||
[total_sessions_label]
|
||||
Gesamtsitzungen: %d
|
||||
---
|
||||
[data_size_label]
|
||||
Datengröße: %s
|
||||
---
|
||||
[storage_label]
|
||||
Speicher: %s
|
||||
---
|
||||
[export_data_button]
|
||||
Daten exportieren
|
||||
---
|
||||
[delete_all_data_button]
|
||||
Alle Daten löschen
|
||||
---
|
||||
[export_data_dialog_title]
|
||||
Daten exportieren
|
||||
---
|
||||
[export_failed]
|
||||
Export fehlgeschlagen
|
||||
---
|
||||
[exported_label]
|
||||
Exportiert: %s
|
||||
---
|
||||
[version_label]
|
||||
Version %s
|
||||
---
|
||||
[about_description]
|
||||
Inner Breeze ist eine einfache Atem-
|
||||
Meditations-App, die Ihnen hilft, sich zu
|
||||
entspannen und Ruhe zu finden.
|
||||
---
|
||||
[toggle_off]
|
||||
AUS
|
||||
---
|
||||
[toggle_on]
|
||||
AN
|
||||
---
|
||||
[history_title]
|
||||
Verlauf
|
||||
---
|
||||
[history_empty]
|
||||
Noch keine gespeicherten Sitzungen.
|
||||
Schließen Sie eine Sitzung ab, um Daten hinzuzufügen.
|
||||
---
|
||||
[history_month_label]
|
||||
Monat %02d
|
||||
---
|
||||
[history_day_label]
|
||||
Tag %02d
|
||||
---
|
||||
[history_round_short_label]
|
||||
R%d
|
||||
---
|
||||
[history_round_label]
|
||||
R%d %ds
|
||||
---
|
||||
[history_session_label]
|
||||
%02d:%02d durchschn. %ds
|
||||
---
|
||||
[tutorial_title]
|
||||
Tutorial
|
||||
---
|
||||
[tutorial_method_title]
|
||||
Methode
|
||||
---
|
||||
[tutorial_step1_title]
|
||||
Schritt 1: Ein & Aus
|
||||
---
|
||||
[tutorial_step2_title]
|
||||
Schritt 2: Ausatmen & Halten
|
||||
---
|
||||
[tutorial_step3_title]
|
||||
Schritt 3: Einatmen & Halten
|
||||
---
|
||||
[tutorial_step_intro]
|
||||
Diese Atemübung basiert auf der Wim Hof-Methode.
|
||||
|
||||
Sie kann kraftvoll sein. Nutzen Sie sie mit Vorsicht.
|
||||
|
||||
Üben Sie im Sitzen oder Liegen.
|
||||
Benutzen Sie sie niemals beim Fahren,
|
||||
Stehen oder im Wasser.
|
||||
---
|
||||
[tutorial_step_method]
|
||||
Folgen Sie einfach 4 Schritten:
|
||||
|
||||
1. Atmen Sie rhythmisch.
|
||||
2. Atmen Sie aus und halten Sie.
|
||||
3. Atmen Sie tief ein und halten Sie.
|
||||
4. Atmen Sie aus und wiederholen Sie.
|
||||
|
||||
Nutzen Sie das Zahnrad-Symbol %i, um Runden, Atemzüge, Geschwindigkeit und Pausen anzupassen.
|
||||
---
|
||||
[tutorial_step_breathe]
|
||||
Füllen Sie Ihre Lungen vollständig, dann lassen Sie den Atem herausfließen.
|
||||
|
||||
Nutzen Sie diesen Schieberegler, um das Tempo des Atemkreises einzustellen.
|
||||
|
||||
Finden Sie einen Rhythmus, der sich natürlich für Sie anfühlt.
|
||||
---
|
||||
[tutorial_step_exhale_hold]
|
||||
Nach der Atemrunde,
|
||||
atmen Sie normal aus und halten Sie.
|
||||
|
||||
Lassen Sie los, wenn Ihr Körper
|
||||
nach Luft verlangt. Zwängen Sie es nicht.
|
||||
---
|
||||
[tutorial_step_inhale_hold]
|
||||
Atmen Sie vollständig ein und halten Sie etwa 15 Sekunden.
|
||||
|
||||
Dann atmen Sie aus und beginnen die nächste Runde.
|
||||
Mit der Zeit kann sich jede Runde tiefer anfühlen.
|
||||
---
|
||||
[tutorial_skip_button]
|
||||
SKIP
|
||||
---
|
||||
[tutorial_back_button]
|
||||
ZURÜCK
|
||||
---
|
||||
[tutorial_next_button]
|
||||
WEITER
|
||||
---
|
||||
[tutorial_finish_button]
|
||||
BEENDEN
|
||||
---
|
||||
[share_sheet_title]
|
||||
Sitzungsdaten exportieren
|
||||
---
|
||||
[export_metadata_header]
|
||||
Inner Breeze Datenexport
|
||||
---
|
||||
[export_metadata_version]
|
||||
Version: %s
|
||||
---
|
||||
[export_metadata_date]
|
||||
Exportdatum: %s
|
||||
---
|
||||
[export_metadata_count]
|
||||
Sitzungsanzahl: %d
|
||||
+273
@@ -0,0 +1,273 @@
|
||||
[app_title]
|
||||
Inner Breeze
|
||||
---
|
||||
[tab_history]
|
||||
History
|
||||
---
|
||||
[tab_manual]
|
||||
Tutorial
|
||||
---
|
||||
[tab_settings]
|
||||
Settings
|
||||
---
|
||||
[play_button]
|
||||
PLAY
|
||||
---
|
||||
[breath_button]
|
||||
BREATH
|
||||
---
|
||||
[results_title]
|
||||
RESULTS
|
||||
---
|
||||
[home_button]
|
||||
HOME
|
||||
---
|
||||
[exit_session_title]
|
||||
Exit Session?
|
||||
---
|
||||
[save_completed_rounds_message]
|
||||
Save completed rounds before exit?
|
||||
---
|
||||
[cancel_button]
|
||||
Cancel
|
||||
---
|
||||
[save_button]
|
||||
Save
|
||||
---
|
||||
[save_results_button]
|
||||
Save
|
||||
---
|
||||
[discard_button]
|
||||
Discard
|
||||
---
|
||||
[all_progress_lost_message]
|
||||
All progress will be lost.
|
||||
---
|
||||
[exit_button]
|
||||
Exit
|
||||
---
|
||||
[round_times_title]
|
||||
Round times
|
||||
---
|
||||
[results_rounds]
|
||||
%d rounds
|
||||
---
|
||||
[results_best]
|
||||
best %ds
|
||||
---
|
||||
[results_avg]
|
||||
avg %ds
|
||||
---
|
||||
[round_result_label]
|
||||
Round %d %ds
|
||||
---
|
||||
[starting_in]
|
||||
STARTING IN %2d
|
||||
---
|
||||
[settings_title]
|
||||
Settings
|
||||
---
|
||||
[settings_tab_breathing]
|
||||
Breathing
|
||||
---
|
||||
[settings_tab_session]
|
||||
Session
|
||||
---
|
||||
[settings_tab_appearance]
|
||||
Appearance
|
||||
---
|
||||
[settings_tab_language]
|
||||
Language
|
||||
---
|
||||
[settings_tab_data]
|
||||
Data
|
||||
---
|
||||
[settings_tab_about]
|
||||
About
|
||||
---
|
||||
[theme_label]
|
||||
Theme
|
||||
---
|
||||
[speed_label]
|
||||
Speed
|
||||
---
|
||||
[progressive_speed_label]
|
||||
Progressive speed
|
||||
---
|
||||
[play_in_background_label]
|
||||
Play in background
|
||||
---
|
||||
[max_rounds_label]
|
||||
Max rounds
|
||||
---
|
||||
[max_breaths_label]
|
||||
Max breaths
|
||||
---
|
||||
[pause_after_round_label]
|
||||
Pause after round
|
||||
---
|
||||
[volume_label]
|
||||
Volume
|
||||
---
|
||||
[reset_to_defaults_label]
|
||||
Reset to defaults
|
||||
---
|
||||
[fullscreen_label]
|
||||
Fullscreen
|
||||
---
|
||||
[language_label]
|
||||
Language
|
||||
---
|
||||
[language_picker_title]
|
||||
Choose Language
|
||||
---
|
||||
[next_button]
|
||||
Next
|
||||
---
|
||||
[coming_soon_label]
|
||||
Coming soon...
|
||||
---
|
||||
[data_management_label]
|
||||
Data Management
|
||||
---
|
||||
[total_sessions_label]
|
||||
Total Sessions: %d
|
||||
---
|
||||
[data_size_label]
|
||||
Data Size: %s
|
||||
---
|
||||
[storage_label]
|
||||
Storage: %s
|
||||
---
|
||||
[export_data_button]
|
||||
Export Data
|
||||
---
|
||||
[delete_all_data_button]
|
||||
Delete All Data
|
||||
---
|
||||
[export_data_dialog_title]
|
||||
Export Data
|
||||
---
|
||||
[export_failed]
|
||||
Export failed
|
||||
---
|
||||
[exported_label]
|
||||
Exported: %s
|
||||
---
|
||||
[version_label]
|
||||
Version %s
|
||||
---
|
||||
[about_description]
|
||||
Inner Breeze is a simple breathing
|
||||
meditation app to help you relax
|
||||
and find your calm.
|
||||
---
|
||||
[toggle_off]
|
||||
OFF
|
||||
---
|
||||
[toggle_on]
|
||||
ON
|
||||
---
|
||||
[history_title]
|
||||
History
|
||||
---
|
||||
[history_empty]
|
||||
No saved sessions yet.
|
||||
Complete a session to add data.
|
||||
---
|
||||
[history_month_label]
|
||||
Month %02d
|
||||
---
|
||||
[history_day_label]
|
||||
Day %02d
|
||||
---
|
||||
[history_round_short_label]
|
||||
R%d
|
||||
---
|
||||
[history_round_label]
|
||||
R%d %ds
|
||||
---
|
||||
[history_session_label]
|
||||
%02d:%02d avg %ds
|
||||
---
|
||||
[tutorial_title]
|
||||
Tutorial
|
||||
---
|
||||
[tutorial_method_title]
|
||||
Method
|
||||
---
|
||||
[tutorial_step1_title]
|
||||
Step 1: In & Out
|
||||
---
|
||||
[tutorial_step2_title]
|
||||
Step 2: Exhale & Hold
|
||||
---
|
||||
[tutorial_step3_title]
|
||||
Step 3: Inhale & Hold
|
||||
---
|
||||
[tutorial_step_intro]
|
||||
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.
|
||||
---
|
||||
[tutorial_step_method]
|
||||
Simply follow 4 steps:
|
||||
|
||||
1. Breathe rhythmically.
|
||||
2. Exhale and hold.
|
||||
3. Inhale deeply and hold.
|
||||
4. Exhale and repeat.
|
||||
|
||||
Use the gear icon %i to adjust rounds, breaths, speed, and pauses.
|
||||
---
|
||||
[tutorial_step_breathe]
|
||||
Fill your lungs fully, then let the breath flow out.
|
||||
|
||||
Use this slider to set the pace of the breathing circle.
|
||||
|
||||
Find a rhythm that feels natural for you.
|
||||
---
|
||||
[tutorial_step_exhale_hold]
|
||||
After the breathing round,
|
||||
exhale normally and hold.
|
||||
|
||||
Release when your body asks
|
||||
for air. Do not force it.
|
||||
---
|
||||
[tutorial_step_inhale_hold]
|
||||
Inhale fully and hold for about 15 seconds.
|
||||
|
||||
Then exhale and begin the next round.
|
||||
Over time, each round may feel deeper.
|
||||
---
|
||||
[tutorial_skip_button]
|
||||
SKIP
|
||||
---
|
||||
[tutorial_back_button]
|
||||
BACK
|
||||
---
|
||||
[tutorial_next_button]
|
||||
NEXT
|
||||
---
|
||||
[tutorial_finish_button]
|
||||
FINISH
|
||||
---
|
||||
[share_sheet_title]
|
||||
Export Session Data
|
||||
---
|
||||
[export_metadata_header]
|
||||
Inner Breeze Data Export
|
||||
---
|
||||
[export_metadata_version]
|
||||
Version: %s
|
||||
---
|
||||
[export_metadata_date]
|
||||
Export Date: %s
|
||||
---
|
||||
[export_metadata_count]
|
||||
Session Count: %d
|
||||
---
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
[app_title]
|
||||
Inner Breeze
|
||||
---
|
||||
[tab_history]
|
||||
Historial
|
||||
---
|
||||
[tab_manual]
|
||||
Tutorial
|
||||
---
|
||||
[tab_settings]
|
||||
Configuración
|
||||
---
|
||||
[play_button]
|
||||
REPRODUCIR
|
||||
---
|
||||
[breath_button]
|
||||
RESPIRACIÓN
|
||||
---
|
||||
[results_title]
|
||||
RESULTADOS
|
||||
---
|
||||
[home_button]
|
||||
INICIO
|
||||
---
|
||||
[exit_session_title]
|
||||
¿Salir de la sesión?
|
||||
---
|
||||
[save_completed_rounds_message]
|
||||
¿Guardar rondas completadas antes de salir?
|
||||
---
|
||||
[cancel_button]
|
||||
Cancelar
|
||||
---
|
||||
[save_button]
|
||||
Guardar
|
||||
---
|
||||
[save_results_button]
|
||||
Guardar
|
||||
---
|
||||
[discard_button]
|
||||
Descartar
|
||||
---
|
||||
[all_progress_lost_message]
|
||||
Se perderá todo el progreso.
|
||||
---
|
||||
[exit_button]
|
||||
Salir
|
||||
---
|
||||
[round_times_title]
|
||||
Tiempos de ronda
|
||||
---
|
||||
[results_rounds]
|
||||
%d rondas
|
||||
---
|
||||
[results_best]
|
||||
mejor %ds
|
||||
---
|
||||
[results_avg]
|
||||
promedio %ds
|
||||
---
|
||||
[round_result_label]
|
||||
Ronda %d %ds
|
||||
---
|
||||
[starting_in]
|
||||
COMENZANDO EN %2d
|
||||
---
|
||||
[settings_title]
|
||||
Configuración
|
||||
---
|
||||
[settings_tab_breathing]
|
||||
Respiración
|
||||
---
|
||||
[settings_tab_session]
|
||||
Sesión
|
||||
---
|
||||
[settings_tab_appearance]
|
||||
Apariencia
|
||||
---
|
||||
[settings_tab_language]
|
||||
Idioma
|
||||
---
|
||||
[settings_tab_data]
|
||||
Datos
|
||||
---
|
||||
[settings_tab_about]
|
||||
Acerca de
|
||||
---
|
||||
[theme_label]
|
||||
Tema
|
||||
---
|
||||
[speed_label]
|
||||
Velocidad
|
||||
---
|
||||
[progressive_speed_label]
|
||||
Velocidad progresiva
|
||||
---
|
||||
[play_in_background_label]
|
||||
Reproducir en segundo plano
|
||||
---
|
||||
[max_rounds_label]
|
||||
Rondas máximas
|
||||
---
|
||||
[max_breaths_label]
|
||||
Respiraciones máximas
|
||||
---
|
||||
[pause_after_round_label]
|
||||
Pausa después de ronda
|
||||
---
|
||||
[volume_label]
|
||||
Volumen
|
||||
---
|
||||
[reset_to_defaults_label]
|
||||
Restablecer valores predeterminados
|
||||
---
|
||||
[fullscreen_label]
|
||||
Pantalla completa
|
||||
---
|
||||
[language_label]
|
||||
Idioma
|
||||
---
|
||||
[language_picker_title]
|
||||
Elegir idioma
|
||||
---
|
||||
[next_button]
|
||||
Más
|
||||
---
|
||||
[coming_soon_label]
|
||||
Próximamente...
|
||||
---
|
||||
[data_management_label]
|
||||
Gestión de datos
|
||||
---
|
||||
[total_sessions_label]
|
||||
Sesiones totales: %d
|
||||
---
|
||||
[data_size_label]
|
||||
Tamaño de datos: %s
|
||||
---
|
||||
[storage_label]
|
||||
Almacenamiento: %s
|
||||
---
|
||||
[export_data_button]
|
||||
Exportar datos
|
||||
---
|
||||
[delete_all_data_button]
|
||||
Eliminar todos los datos
|
||||
---
|
||||
[export_data_dialog_title]
|
||||
Exportar datos
|
||||
---
|
||||
[export_failed]
|
||||
Error al exportar
|
||||
---
|
||||
[exported_label]
|
||||
Exportado: %s
|
||||
---
|
||||
[version_label]
|
||||
Versión %s
|
||||
---
|
||||
[about_description]
|
||||
Inner Breeze es una aplicación simple de
|
||||
meditación de respiración para ayudarle a
|
||||
relajarse y encontrar su calma.
|
||||
---
|
||||
[toggle_off]
|
||||
APAGADO
|
||||
---
|
||||
[toggle_on]
|
||||
ENCENDIDO
|
||||
---
|
||||
[history_title]
|
||||
Historial
|
||||
---
|
||||
[history_empty]
|
||||
Aún no hay sesiones guardadas.
|
||||
Complete una sesión para agregar datos.
|
||||
---
|
||||
[history_month_label]
|
||||
Mes %02d
|
||||
---
|
||||
[history_day_label]
|
||||
Día %02d
|
||||
---
|
||||
[history_round_short_label]
|
||||
R%d
|
||||
---
|
||||
[history_round_label]
|
||||
R%d %ds
|
||||
---
|
||||
[history_session_label]
|
||||
%02d:%02d promedio %ds
|
||||
---
|
||||
[tutorial_title]
|
||||
Tutorial
|
||||
---
|
||||
[tutorial_method_title]
|
||||
Método
|
||||
---
|
||||
[tutorial_step1_title]
|
||||
Paso 1: Inhalar y Exhalar
|
||||
---
|
||||
[tutorial_step2_title]
|
||||
Paso 2: Exhalar y Retener
|
||||
---
|
||||
[tutorial_step3_title]
|
||||
Paso 3: Inhalar y Retener
|
||||
---
|
||||
[tutorial_step_intro]
|
||||
Esta práctica de respiración se basa en el Método Wim Hof.
|
||||
|
||||
Puede ser poderosa. Úsela con cuidado.
|
||||
|
||||
Practique sentado o acostado.
|
||||
Nunca la use mientras conduce,
|
||||
de pie o en el agua.
|
||||
---
|
||||
[tutorial_step_method]
|
||||
Simplemente siga 4 pasos:
|
||||
|
||||
1. Respire rítmicamente.
|
||||
2. Exhale y retenga.
|
||||
3. Inhale profundamente y retenga.
|
||||
4. Exhale y repita.
|
||||
|
||||
Use el icono de engranaje %i para ajustar rondas, respiraciones, velocidad y pausas.
|
||||
---
|
||||
[tutorial_step_breathe]
|
||||
Llene sus pulmones completamente, luego deje que el respiración fluya hacia afuera.
|
||||
|
||||
Use este control deslizante para establecer el ritmo del círculo de respiración.
|
||||
|
||||
Encuentre un ritmo que se sienta natural para usted.
|
||||
---
|
||||
[tutorial_step_exhale_hold]
|
||||
Después de la ronda de respiración,
|
||||
exhale normalmente y retenga.
|
||||
|
||||
Suelte cuando su cuerpo pida
|
||||
aire. No lo fuerce.
|
||||
---
|
||||
[tutorial_step_inhale_hold]
|
||||
Inhale completamente y retenga unos 15 segundos.
|
||||
|
||||
Luego exhale y comience la siguiente ronda.
|
||||
Con el tiempo, cada ronda puede sentirse más profunda.
|
||||
---
|
||||
[tutorial_skip_button]
|
||||
OMITIR
|
||||
---
|
||||
[tutorial_back_button]
|
||||
ATRÁS
|
||||
---
|
||||
[tutorial_next_button]
|
||||
MÁS
|
||||
---
|
||||
[tutorial_finish_button]
|
||||
FINALIZAR
|
||||
---
|
||||
[share_sheet_title]
|
||||
Exportar datos de sesión
|
||||
---
|
||||
[export_metadata_header]
|
||||
Exportación de datos de Inner Breeze
|
||||
---
|
||||
[export_metadata_version]
|
||||
Versión: %s
|
||||
---
|
||||
[export_metadata_date]
|
||||
Fecha de exportación: %s
|
||||
---
|
||||
[export_metadata_count]
|
||||
Recuento de sesiones: %d
|
||||
+273
@@ -0,0 +1,273 @@
|
||||
[app_title]
|
||||
Inner Breeze
|
||||
---
|
||||
[tab_history]
|
||||
Historique
|
||||
---
|
||||
[tab_manual]
|
||||
Tutoriel
|
||||
---
|
||||
[tab_settings]
|
||||
Réglages
|
||||
---
|
||||
[play_button]
|
||||
DÉMARRER
|
||||
---
|
||||
[breath_button]
|
||||
RESPIRER
|
||||
---
|
||||
[results_title]
|
||||
RÉSULTATS
|
||||
---
|
||||
[home_button]
|
||||
ACCUEIL
|
||||
---
|
||||
[exit_session_title]
|
||||
Quitter la séance ?
|
||||
---
|
||||
[save_completed_rounds_message]
|
||||
Enregistrer les cycles terminés avant de quitter ?
|
||||
---
|
||||
[cancel_button]
|
||||
Annuler
|
||||
---
|
||||
[save_button]
|
||||
Enregistrer
|
||||
---
|
||||
[save_results_button]
|
||||
Enregistrer
|
||||
---
|
||||
[discard_button]
|
||||
Ignorer
|
||||
---
|
||||
[all_progress_lost_message]
|
||||
Toute la progression sera perdue.
|
||||
---
|
||||
[exit_button]
|
||||
Quitter
|
||||
---
|
||||
[round_times_title]
|
||||
Temps des cycles
|
||||
---
|
||||
[results_rounds]
|
||||
%d cycles
|
||||
---
|
||||
[results_best]
|
||||
meilleur %ds
|
||||
---
|
||||
[results_avg]
|
||||
moy. %ds
|
||||
---
|
||||
[round_result_label]
|
||||
Cycle %d %ds
|
||||
---
|
||||
[starting_in]
|
||||
DÉBUT DANS %2d
|
||||
---
|
||||
[settings_title]
|
||||
Réglages
|
||||
---
|
||||
[settings_tab_breathing]
|
||||
Respiration
|
||||
---
|
||||
[settings_tab_session]
|
||||
Séance
|
||||
---
|
||||
[settings_tab_appearance]
|
||||
Apparence
|
||||
---
|
||||
[settings_tab_language]
|
||||
Langue
|
||||
---
|
||||
[settings_tab_data]
|
||||
Données
|
||||
---
|
||||
[settings_tab_about]
|
||||
À propos
|
||||
---
|
||||
[theme_label]
|
||||
Thème
|
||||
---
|
||||
[speed_label]
|
||||
Vitesse
|
||||
---
|
||||
[progressive_speed_label]
|
||||
Vitesse progressive
|
||||
---
|
||||
[play_in_background_label]
|
||||
Lecture en arrière-plan
|
||||
---
|
||||
[max_rounds_label]
|
||||
Cycles max.
|
||||
---
|
||||
[max_breaths_label]
|
||||
Respirations max.
|
||||
---
|
||||
[pause_after_round_label]
|
||||
Pause après cycle
|
||||
---
|
||||
[volume_label]
|
||||
Volume
|
||||
---
|
||||
[reset_to_defaults_label]
|
||||
Réinitialiser
|
||||
---
|
||||
[fullscreen_label]
|
||||
Plein écran
|
||||
---
|
||||
[language_label]
|
||||
Langue
|
||||
---
|
||||
[language_picker_title]
|
||||
Choisir la langue
|
||||
---
|
||||
[next_button]
|
||||
Suivant
|
||||
---
|
||||
[coming_soon_label]
|
||||
Bientôt...
|
||||
---
|
||||
[data_management_label]
|
||||
Gestion des données
|
||||
---
|
||||
[total_sessions_label]
|
||||
Séances totales : %d
|
||||
---
|
||||
[data_size_label]
|
||||
Taille des données : %s
|
||||
---
|
||||
[storage_label]
|
||||
Stockage : %s
|
||||
---
|
||||
[export_data_button]
|
||||
Exporter les données
|
||||
---
|
||||
[delete_all_data_button]
|
||||
Supprimer toutes les données
|
||||
---
|
||||
[export_data_dialog_title]
|
||||
Exporter les données
|
||||
---
|
||||
[export_failed]
|
||||
Échec de l'export
|
||||
---
|
||||
[exported_label]
|
||||
Exporté : %s
|
||||
---
|
||||
[version_label]
|
||||
Version %s
|
||||
---
|
||||
[about_description]
|
||||
Inner Breeze est une application simple de
|
||||
méditation respiratoire pour vous aider à
|
||||
vous détendre et retrouver votre calme.
|
||||
---
|
||||
[toggle_off]
|
||||
OFF
|
||||
---
|
||||
[toggle_on]
|
||||
ON
|
||||
---
|
||||
[history_title]
|
||||
Historique
|
||||
---
|
||||
[history_empty]
|
||||
Aucune séance enregistrée.
|
||||
Terminez une séance pour ajouter des données.
|
||||
---
|
||||
[history_month_label]
|
||||
Mois %02d
|
||||
---
|
||||
[history_day_label]
|
||||
Jour %02d
|
||||
---
|
||||
[history_round_short_label]
|
||||
C%d
|
||||
---
|
||||
[history_round_label]
|
||||
C%d %ds
|
||||
---
|
||||
[history_session_label]
|
||||
%02d:%02d moy. %ds
|
||||
---
|
||||
[tutorial_title]
|
||||
Tutoriel
|
||||
---
|
||||
[tutorial_method_title]
|
||||
Méthode
|
||||
---
|
||||
[tutorial_step1_title]
|
||||
Étape 1 : Inspirer et expirer
|
||||
---
|
||||
[tutorial_step2_title]
|
||||
Étape 2 : Expirer et retenir
|
||||
---
|
||||
[tutorial_step3_title]
|
||||
Étape 3 : Inspirer et retenir
|
||||
---
|
||||
[tutorial_step_intro]
|
||||
Cette pratique respiratoire est basée sur la méthode Wim Hof.
|
||||
|
||||
Elle peut être puissante. Utilisez-la avec prudence.
|
||||
|
||||
Pratiquez assis ou allongé.
|
||||
Ne l'utilisez jamais en conduisant,
|
||||
debout ou dans l'eau.
|
||||
---
|
||||
[tutorial_step_method]
|
||||
Suivez simplement 4 étapes :
|
||||
|
||||
1. Respirez en rythme.
|
||||
2. Expirez et retenez.
|
||||
3. Inspirez profondément et retenez.
|
||||
4. Expirez et répétez.
|
||||
|
||||
Utilisez l'icône d'engrenage %i pour régler les cycles, respirations, vitesse et pauses.
|
||||
---
|
||||
[tutorial_step_breathe]
|
||||
Remplissez complètement vos poumons, puis laissez le souffle sortir.
|
||||
|
||||
Utilisez ce curseur pour régler le rythme du cercle de respiration.
|
||||
|
||||
Trouvez un rythme naturel pour vous.
|
||||
---
|
||||
[tutorial_step_exhale_hold]
|
||||
Après le cycle de respiration,
|
||||
expirez normalement et retenez.
|
||||
|
||||
Relâchez quand votre corps demande
|
||||
de l'air. Ne forcez pas.
|
||||
---
|
||||
[tutorial_step_inhale_hold]
|
||||
Inspirez complètement et retenez environ 15 secondes.
|
||||
|
||||
Puis expirez et commencez le cycle suivant.
|
||||
Avec le temps, chaque cycle peut sembler plus profond.
|
||||
---
|
||||
[tutorial_skip_button]
|
||||
SKIP
|
||||
---
|
||||
[tutorial_back_button]
|
||||
RETOUR
|
||||
---
|
||||
[tutorial_next_button]
|
||||
SUIVANT
|
||||
---
|
||||
[tutorial_finish_button]
|
||||
TERMINER
|
||||
---
|
||||
[share_sheet_title]
|
||||
Exporter les données de séance
|
||||
---
|
||||
[export_metadata_header]
|
||||
Export des données Inner Breeze
|
||||
---
|
||||
[export_metadata_version]
|
||||
Version : %s
|
||||
---
|
||||
[export_metadata_date]
|
||||
Date d'export : %s
|
||||
---
|
||||
[export_metadata_count]
|
||||
Nombre de séances : %d
|
||||
---
|
||||
@@ -0,0 +1,5 @@
|
||||
en|English
|
||||
de|Deutsch
|
||||
es|Español
|
||||
fr|Français
|
||||
pt|Português
|
||||
+273
@@ -0,0 +1,273 @@
|
||||
[app_title]
|
||||
Inner Breeze
|
||||
---
|
||||
[tab_history]
|
||||
Histórico
|
||||
---
|
||||
[tab_manual]
|
||||
Tutorial
|
||||
---
|
||||
[tab_settings]
|
||||
Configurações
|
||||
---
|
||||
[play_button]
|
||||
INICIAR
|
||||
---
|
||||
[breath_button]
|
||||
RESPIRAR
|
||||
---
|
||||
[results_title]
|
||||
RESULTADOS
|
||||
---
|
||||
[home_button]
|
||||
INÍCIO
|
||||
---
|
||||
[exit_session_title]
|
||||
Sair da sessão?
|
||||
---
|
||||
[save_completed_rounds_message]
|
||||
Salvar rodadas concluídas antes de sair?
|
||||
---
|
||||
[cancel_button]
|
||||
Cancelar
|
||||
---
|
||||
[save_button]
|
||||
Salvar
|
||||
---
|
||||
[save_results_button]
|
||||
Salvar
|
||||
---
|
||||
[discard_button]
|
||||
Descartar
|
||||
---
|
||||
[all_progress_lost_message]
|
||||
Todo o progresso será perdido.
|
||||
---
|
||||
[exit_button]
|
||||
Sair
|
||||
---
|
||||
[round_times_title]
|
||||
Tempos das rodadas
|
||||
---
|
||||
[results_rounds]
|
||||
%d rodadas
|
||||
---
|
||||
[results_best]
|
||||
melhor %ds
|
||||
---
|
||||
[results_avg]
|
||||
média %ds
|
||||
---
|
||||
[round_result_label]
|
||||
Rodada %d %ds
|
||||
---
|
||||
[starting_in]
|
||||
COMEÇA EM %2d
|
||||
---
|
||||
[settings_title]
|
||||
Configurações
|
||||
---
|
||||
[settings_tab_breathing]
|
||||
Respiração
|
||||
---
|
||||
[settings_tab_session]
|
||||
Sessão
|
||||
---
|
||||
[settings_tab_appearance]
|
||||
Aparência
|
||||
---
|
||||
[settings_tab_language]
|
||||
Idioma
|
||||
---
|
||||
[settings_tab_data]
|
||||
Dados
|
||||
---
|
||||
[settings_tab_about]
|
||||
Sobre
|
||||
---
|
||||
[theme_label]
|
||||
Tema
|
||||
---
|
||||
[speed_label]
|
||||
Velocidade
|
||||
---
|
||||
[progressive_speed_label]
|
||||
Velocidade progressiva
|
||||
---
|
||||
[play_in_background_label]
|
||||
Executar em segundo plano
|
||||
---
|
||||
[max_rounds_label]
|
||||
Máx. de rodadas
|
||||
---
|
||||
[max_breaths_label]
|
||||
Máx. de respirações
|
||||
---
|
||||
[pause_after_round_label]
|
||||
Pausa após rodada
|
||||
---
|
||||
[volume_label]
|
||||
Volume
|
||||
---
|
||||
[reset_to_defaults_label]
|
||||
Restaurar padrões
|
||||
---
|
||||
[fullscreen_label]
|
||||
Tela cheia
|
||||
---
|
||||
[language_label]
|
||||
Idioma
|
||||
---
|
||||
[language_picker_title]
|
||||
Escolher idioma
|
||||
---
|
||||
[next_button]
|
||||
Mais
|
||||
---
|
||||
[coming_soon_label]
|
||||
Em breve...
|
||||
---
|
||||
[data_management_label]
|
||||
Gerenciamento de dados
|
||||
---
|
||||
[total_sessions_label]
|
||||
Sessões totais: %d
|
||||
---
|
||||
[data_size_label]
|
||||
Tamanho dos dados: %s
|
||||
---
|
||||
[storage_label]
|
||||
Armazenamento: %s
|
||||
---
|
||||
[export_data_button]
|
||||
Exportar dados
|
||||
---
|
||||
[delete_all_data_button]
|
||||
Excluir todos os dados
|
||||
---
|
||||
[export_data_dialog_title]
|
||||
Exportar dados
|
||||
---
|
||||
[export_failed]
|
||||
Falha ao exportar
|
||||
---
|
||||
[exported_label]
|
||||
Exportado: %s
|
||||
---
|
||||
[version_label]
|
||||
Versão %s
|
||||
---
|
||||
[about_description]
|
||||
Inner Breeze é um app simples de
|
||||
meditação respiratória para ajudar você a
|
||||
relaxar e encontrar calma.
|
||||
---
|
||||
[toggle_off]
|
||||
OFF
|
||||
---
|
||||
[toggle_on]
|
||||
ON
|
||||
---
|
||||
[history_title]
|
||||
Histórico
|
||||
---
|
||||
[history_empty]
|
||||
Ainda não há sessões salvas.
|
||||
Conclua uma sessão para adicionar dados.
|
||||
---
|
||||
[history_month_label]
|
||||
Mês %02d
|
||||
---
|
||||
[history_day_label]
|
||||
Dia %02d
|
||||
---
|
||||
[history_round_short_label]
|
||||
R%d
|
||||
---
|
||||
[history_round_label]
|
||||
R%d %ds
|
||||
---
|
||||
[history_session_label]
|
||||
%02d:%02d média %ds
|
||||
---
|
||||
[tutorial_title]
|
||||
Tutorial
|
||||
---
|
||||
[tutorial_method_title]
|
||||
Método
|
||||
---
|
||||
[tutorial_step1_title]
|
||||
Passo 1: Inspirar e expirar
|
||||
---
|
||||
[tutorial_step2_title]
|
||||
Passo 2: Expirar e segurar
|
||||
---
|
||||
[tutorial_step3_title]
|
||||
Passo 3: Inspirar e segurar
|
||||
---
|
||||
[tutorial_step_intro]
|
||||
Esta prática de respiração é baseada no Método Wim Hof.
|
||||
|
||||
Ela pode ser poderosa. Use com cuidado.
|
||||
|
||||
Pratique sentado ou deitado.
|
||||
Nunca use enquanto dirige,
|
||||
em pé ou na água.
|
||||
---
|
||||
[tutorial_step_method]
|
||||
Basta seguir 4 passos:
|
||||
|
||||
1. Respire ritmicamente.
|
||||
2. Expire e segure.
|
||||
3. Inspire profundamente e segure.
|
||||
4. Expire e repita.
|
||||
|
||||
Use o ícone de engrenagem %i para ajustar rodadas, respirações, velocidade e pausas.
|
||||
---
|
||||
[tutorial_step_breathe]
|
||||
Encha totalmente os pulmões e deixe o ar sair.
|
||||
|
||||
Use este controle para definir o ritmo do círculo de respiração.
|
||||
|
||||
Encontre um ritmo que pareça natural para você.
|
||||
---
|
||||
[tutorial_step_exhale_hold]
|
||||
Depois da rodada de respiração,
|
||||
expire normalmente e segure.
|
||||
|
||||
Solte quando seu corpo pedir
|
||||
ar. Não force.
|
||||
---
|
||||
[tutorial_step_inhale_hold]
|
||||
Inspire totalmente e segure por cerca de 15 segundos.
|
||||
|
||||
Depois expire e comece a próxima rodada.
|
||||
Com o tempo, cada rodada pode parecer mais profunda.
|
||||
---
|
||||
[tutorial_skip_button]
|
||||
SKIP
|
||||
---
|
||||
[tutorial_back_button]
|
||||
VOLTAR
|
||||
---
|
||||
[tutorial_next_button]
|
||||
MAIS
|
||||
---
|
||||
[tutorial_finish_button]
|
||||
CONCLUIR
|
||||
---
|
||||
[share_sheet_title]
|
||||
Exportar dados da sessão
|
||||
---
|
||||
[export_metadata_header]
|
||||
Exportação de dados do Inner Breeze
|
||||
---
|
||||
[export_metadata_version]
|
||||
Versão: %s
|
||||
---
|
||||
[export_metadata_date]
|
||||
Data de exportação: %s
|
||||
---
|
||||
[export_metadata_count]
|
||||
Total de sessões: %d
|
||||
---
|
||||
+1
-1
@@ -58,6 +58,6 @@
|
||||
<p>Questions: <a href="mailto:[email protected]">[email protected]</a></p>
|
||||
|
||||
<h2>Open Source</h2>
|
||||
<p>Source code available at: <a href="https://sr.ht/projects/~waozi">https://sr.ht/projects/~waozi</a></p>
|
||||
<p>Source code available at: <a href="https://git.sr.ht/~waozi/inbe">https://git.sr.ht/~waozi/inbe</a> and <a href="https://github.com/waozixyz/inbe">https://github.com/waozixyz/inbe</a></p>
|
||||
</body>
|
||||
</html>
|
||||
+9
-1
@@ -15,6 +15,14 @@ fi
|
||||
|
||||
echo "Publishing inbe.waozi.xyz..."
|
||||
|
||||
# Update metadata before publishing
|
||||
if [ -f "./update_metadata.sh" ]; then
|
||||
echo "Running metadata update..."
|
||||
./update_metadata.sh || echo "Warning: Metadata update failed, continuing anyway"
|
||||
else
|
||||
echo "Warning: update_metadata.sh not found, skipping metadata update"
|
||||
fi
|
||||
|
||||
TMPDIR=$(mktemp -d -p /tmp)
|
||||
|
||||
# Base site files
|
||||
@@ -122,7 +130,7 @@ rsync -av --exclude='.*' --exclude='*.sym' --exclude='*.o' --exclude='*.a' --exc
|
||||
|
||||
rsync -av --exclude='*.sym' --exclude='*.o' --exclude='*.a' --exclude='build' --exclude='.gradle' --exclude='.npm' --exclude='.local' --exclude='.codex' cursors/ "$TMPDIR/cursors/"
|
||||
|
||||
cp style.css assets/DepartureMono-Regular.otf og.png "$TMPDIR/"
|
||||
cp style.css assets/DepartureMono-Regular.otf og.png sitemap.xml robots.txt "$TMPDIR/"
|
||||
cp -R assets "$TMPDIR/"
|
||||
|
||||
if [ -f "$TMPDIR/index.html" ]; then
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
User-agent: *
|
||||
Allow: /
|
||||
|
||||
Sitemap: https://inbe.waozi.xyz/sitemap.xml
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
# Copy assets to Android project without requiring nix-shell or Makefile dependencies
|
||||
# This script is used by GitHub Actions and F-Droid builds
|
||||
# This script works from any directory by detecting the repository root
|
||||
|
||||
set -e
|
||||
|
||||
# Find the repository root by locating this script's directory
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
# Change to repository root so all relative paths work correctly
|
||||
cd "$REPO_ROOT" || exit 1
|
||||
|
||||
echo "Running from repository root: $(pwd)"
|
||||
echo "Copying assets to Android project..."
|
||||
|
||||
ANDROID_DIR="droid"
|
||||
ASSETS_DIR="$ANDROID_DIR/app/src/main/assets"
|
||||
|
||||
echo "Copying assets to Android project..."
|
||||
|
||||
# Remove and recreate assets directory
|
||||
rm -rf "$ASSETS_DIR"
|
||||
mkdir -p "$ASSETS_DIR"
|
||||
|
||||
# Copy config files
|
||||
echo "Copying config files..."
|
||||
cp inbe.ini "$ASSETS_DIR/inbe.ini"
|
||||
cp theme.ini "$ASSETS_DIR/theme.ini"
|
||||
|
||||
# Copy locales
|
||||
echo "Copying locales..."
|
||||
mkdir -p "$ASSETS_DIR/locales"
|
||||
cp locales/*.txt "$ASSETS_DIR/locales/"
|
||||
|
||||
# Copy themes
|
||||
echo "Copying themes..."
|
||||
mkdir -p "$ASSETS_DIR/themes"
|
||||
cp themes/*.ini "$ASSETS_DIR/themes/"
|
||||
|
||||
# Copy icons
|
||||
echo "Copying icons..."
|
||||
mkdir -p "$ASSETS_DIR/icons"
|
||||
for icon in icons/*.png; do
|
||||
base=$(basename "$icon")
|
||||
cp "$icon" "$ASSETS_DIR/icons/$base"
|
||||
done
|
||||
|
||||
# Copy images
|
||||
echo "Copying images..."
|
||||
mkdir -p "$ASSETS_DIR/assets"
|
||||
cp assets/angel.jpg assets/begin.jpg "$ASSETS_DIR/assets/"
|
||||
|
||||
# Copy sounds
|
||||
echo "Copying sounds..."
|
||||
mkdir -p "$ASSETS_DIR/assets/sounds"
|
||||
cp assets/sounds/breath-in.ogg assets/sounds/breath-out.ogg assets/sounds/bell.ogg "$ASSETS_DIR/assets/sounds/"
|
||||
|
||||
echo "Assets copied successfully!"
|
||||
@@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
AVD_NAME="${1:-inbe-test}"
|
||||
|
||||
echo "📱 Creating AVD: $AVD_NAME (Pixel 8 Pro - Android 14)"
|
||||
|
||||
# Check for Android SDK location
|
||||
if [ -z "$ANDROID_SDK_ROOT" ] && [ -z "$ANDROID_HOME" ]; then
|
||||
echo "❌ Error: Neither ANDROID_SDK_ROOT nor ANDROID_HOME is set"
|
||||
echo " Make sure to run this script within 'nix develop'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set up persistent writable SDK location
|
||||
ORIGINAL_SDK_ROOT="$ANDROID_SDK_ROOT"
|
||||
PERSISTENT_SDK_ROOT="$HOME/.android-sdk-writable"
|
||||
export ANDROID_SDK_ROOT="$PERSISTENT_SDK_ROOT"
|
||||
export ANDROID_HOME="$PERSISTENT_SDK_ROOT"
|
||||
|
||||
mkdir -p "$ANDROID_SDK_ROOT"
|
||||
|
||||
# Create symlinks for SDK components
|
||||
for component in build-tools cmake cmdline-tools emulator licenses ndk platforms platform-tools tools; do
|
||||
if [ -e "$ORIGINAL_SDK_ROOT/$component" ] && [ ! -e "$ANDROID_SDK_ROOT/$component" ]; then
|
||||
ln -sf "$ORIGINAL_SDK_ROOT/$component" "$ANDROID_SDK_ROOT/$component"
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p "$ANDROID_SDK_ROOT/system-images"
|
||||
mkdir -p "$ANDROID_SDK_ROOT/avd"
|
||||
|
||||
# Determine system image paths
|
||||
# Prefer x86_64 for faster emulation
|
||||
TARGET_DIR="$ANDROID_SDK_ROOT/system-images/android-34/google_apis_playstore/x86_64"
|
||||
ABI_TYPE="x86_64"
|
||||
ABI_DISPLAY="x86_64"
|
||||
|
||||
# Find system image in Nix store
|
||||
SYSTEM_IMAGE_BASE=$(find "$ORIGINAL_SDK_ROOT/../.." -maxdepth 1 -type d -name "*system-image*34*google_apis_playstore*" | head -1)
|
||||
|
||||
if [ -z "$SYSTEM_IMAGE_BASE" ] || [ ! -d "$SYSTEM_IMAGE_BASE" ]; then
|
||||
echo "❌ Error: System image not found in Nix store"
|
||||
echo " Searched for: *system-image*34*google_apis_playstore* in $ORIGINAL_SDK_ROOT/../.."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📋 Found system image base: $SYSTEM_IMAGE_BASE"
|
||||
|
||||
# Check and copy system image from Nix store
|
||||
if [ ! -d "$TARGET_DIR" ]; then
|
||||
echo "📋 Copying system image ($ABI_TYPE)..."
|
||||
|
||||
SOURCE_DIR="$SYSTEM_IMAGE_BASE/libexec/android-sdk/system-images/android-34/google_apis_playstore/$ABI_TYPE"
|
||||
|
||||
if [ ! -d "$SOURCE_DIR" ]; then
|
||||
echo "❌ Error: Source directory not found: $SOURCE_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$TARGET_DIR"
|
||||
cp -r "$SOURCE_DIR"/* "$TARGET_DIR/"
|
||||
echo "✅ Copied $ABI_TYPE system image"
|
||||
fi
|
||||
|
||||
# Check if AVD already exists
|
||||
if [ -d "$ANDROID_SDK_ROOT/avd/$AVD_NAME.avd" ]; then
|
||||
echo "🗑️ Removing existing AVD..."
|
||||
rm -rf "$ANDROID_SDK_ROOT/avd/$AVD_NAME.avd"
|
||||
rm -f "$ANDROID_SDK_ROOT/avd/$AVD_NAME.ini"
|
||||
fi
|
||||
|
||||
# Create AVD
|
||||
echo "🔨 Creating AVD ($ABI_DISPLAY)..."
|
||||
AVD_DIR="$ANDROID_SDK_ROOT/avd/$AVD_NAME.avd"
|
||||
AVD_INI="$ANDROID_SDK_ROOT/avd/$AVD_NAME.ini"
|
||||
|
||||
mkdir -p "$AVD_DIR"
|
||||
|
||||
# Pixel 8 Pro specs: 2960 x 1440, 6.7", 512 DPI, 12GB RAM
|
||||
cat > "$AVD_DIR/config.ini" << EOF
|
||||
AvdId=$AVD_NAME
|
||||
avd.ini.encoding=UTF-8
|
||||
PlayStore.enabled=true
|
||||
abi.type=$ABI_TYPE
|
||||
hw.cpu.arch=$ABI_TYPE
|
||||
hw.device.name=Pixel 8 Pro
|
||||
hw.lcd.density=512
|
||||
hw.lcd.height=2960
|
||||
hw.lcd.width=1440
|
||||
hw.gpu.enabled=yes
|
||||
hw.gpu.mode=host
|
||||
hw.ramSize=4096
|
||||
vm.heapSize=1024
|
||||
hw.sdCard=yes
|
||||
hw.sdCard.size=2048MB
|
||||
disk.cachePartition=yes
|
||||
disk.cachePartition.size=800MB
|
||||
hw.accelerometer=yes
|
||||
hw.audioInput=yes
|
||||
hw.battery=yes
|
||||
hw.camera.back=yes
|
||||
hw.camera.front=yes
|
||||
hw.gps=yes
|
||||
hw.gsmModem=yes
|
||||
hw.keyboard=yes
|
||||
hw.touchScreen=yes
|
||||
image.sysdir.1=system-images/android-34/google_apis_playstore/$ABI_TYPE/
|
||||
showDeviceFrame=yes
|
||||
skin.name=1440x2960
|
||||
skin.path=1440x2960
|
||||
EOF
|
||||
|
||||
cat > "$AVD_INI" << EOF
|
||||
avd.ini.encoding=UTF-8
|
||||
path=$AVD_DIR
|
||||
target=default
|
||||
EOF
|
||||
|
||||
echo "✅ Done!"
|
||||
echo " Device: Pixel 8 Pro"
|
||||
echo " Android: 14 (API 34)"
|
||||
echo " ABI: $ABI_DISPLAY"
|
||||
echo ""
|
||||
echo " Run with: bash scripts/emulator.sh"
|
||||
+63
-74
@@ -4,92 +4,81 @@ 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'"
|
||||
echo "❌ Error: Neither ANDROID_SDK_ROOT nor ANDROID_HOME is set"
|
||||
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
|
||||
PERSISTENT_SDK_ROOT="$HOME/.android-sdk-writable"
|
||||
|
||||
# Step 1: Create AVD if missing
|
||||
if [ ! -d "$ANDROID_SDK_ROOT/avd/$AVD_NAME.avd" ]; then
|
||||
echo "📱 AVD not found. Creating..."
|
||||
if [ -d "$PERSISTENT_SDK_ROOT" ] && [ -d "$PERSISTENT_SDK_ROOT/avd/$AVD_NAME.avd" ]; then
|
||||
export ANDROID_SDK_ROOT="$PERSISTENT_SDK_ROOT"
|
||||
export ANDROID_SDK_HOME="$PERSISTENT_SDK_ROOT"
|
||||
export ANDROID_AVD_HOME="$PERSISTENT_SDK_ROOT/avd"
|
||||
else
|
||||
echo "ℹ️ AVD not found. Creating new Pixel 8 Pro AVD..."
|
||||
bash scripts/create-avd.sh "$AVD_NAME"
|
||||
echo ""
|
||||
else
|
||||
echo "✅ AVD already exists: $AVD_NAME"
|
||||
echo ""
|
||||
|
||||
# Re-export after creation
|
||||
export ANDROID_SDK_ROOT="$PERSISTENT_SDK_ROOT"
|
||||
export ANDROID_SDK_HOME="$PERSISTENT_SDK_ROOT"
|
||||
export ANDROID_AVD_HOME="$PERSISTENT_SDK_ROOT/avd"
|
||||
fi
|
||||
|
||||
# Step 2: Check if emulator is running
|
||||
# Check if emulator is already 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 ""
|
||||
adb devices
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "📱 Emulator ready!"
|
||||
echo "🚀 Launching Pixel 8 Pro emulator (Android 14 API 34)..."
|
||||
|
||||
# Set environment for emulator
|
||||
unset ANDROID_HOME
|
||||
export ANDROID_SDK_ROOT="$ANDROID_SDK_ROOT"
|
||||
|
||||
# Launch emulator in background with KVM acceleration
|
||||
emulator @"$AVD_NAME" \
|
||||
-gpu host \
|
||||
-skin 1440x2960 \
|
||||
-no-snapshot-load \
|
||||
-no-boot-anim \
|
||||
-qemu -enable-kvm \
|
||||
-verbose > /tmp/emulator.log 2>&1 &
|
||||
|
||||
echo "⏳ Waiting for boot (this may take a while)..."
|
||||
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 boot. Check /tmp/emulator.log"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 5
|
||||
elapsed=$((elapsed + 5))
|
||||
|
||||
if ! pgrep -f "emulator.*$AVD_NAME" > /dev/null; then
|
||||
echo "❌ Emulator died. Check /tmp/emulator.log"
|
||||
tail -20 /tmp/emulator.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Show progress
|
||||
if [ $((elapsed % 15)) -eq 0 ]; then
|
||||
echo " Still booting... (${elapsed}s)"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "✅ Pixel 8 Pro emulator ready!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Build and install the app:"
|
||||
echo " ./scripts/run-android.sh"
|
||||
echo "📱 Device info:"
|
||||
adb shell getprop ro.product.model
|
||||
adb shell getprop ro.build.version.release
|
||||
adb shell getprop ro.build.version.sdk
|
||||
echo ""
|
||||
echo " Connect with: adb shell"
|
||||
+5
-3
@@ -1,9 +1,11 @@
|
||||
speed 8
|
||||
max_rounds 7
|
||||
max_breaths 32
|
||||
speed 11
|
||||
max_rounds 4
|
||||
max_breaths 30
|
||||
pause_seconds 2
|
||||
sound_volume 100
|
||||
tutorial_seen 1
|
||||
theme 0
|
||||
dark_mode 1
|
||||
fullscreen 0
|
||||
progressive_speed 1
|
||||
language en
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://inbe.waozi.xyz/</loc>
|
||||
<lastmod>2026-05-29</lastmod>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://inbe.waozi.xyz/builds.html</loc>
|
||||
<lastmod>2026-05-29</lastmod>
|
||||
<priority>0.8</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://inbe.waozi.xyz/privacy.html</loc>
|
||||
<lastmod>2026-05-26</lastmod>
|
||||
<priority>0.3</priority>
|
||||
</url>
|
||||
</urlset>
|
||||
@@ -0,0 +1,240 @@
|
||||
#include "android_insets.h"
|
||||
#include "android_timer.h"
|
||||
#include "android_wakelock.h"
|
||||
#include "app.h"
|
||||
#include "inbe.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <raylib.h>
|
||||
#include <pthread.h>
|
||||
#include <android_native_app_glue.h>
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
|
||||
// External functions from main.c
|
||||
extern InbeApp* get_global_inbe_app(void);
|
||||
extern void set_global_inbe_app(InbeApp *app);
|
||||
|
||||
#define LOG_TAG "INBE_INSETS"
|
||||
|
||||
#ifndef JNI_VERSION_1_6
|
||||
#define JNI_VERSION_1_6 0x10060000
|
||||
#endif
|
||||
|
||||
extern struct android_app *GetAndroidApp(void);
|
||||
extern void android_wakelock_set_activity(JNIEnv *env, jobject activity);
|
||||
extern void android_wakelock_set_jvm(JavaVM *vm);
|
||||
extern void android_timer_activate(void);
|
||||
extern void android_timer_deactivate(void);
|
||||
|
||||
// Called from Java when activity is ready for wake lock
|
||||
static void android_wakelock_set_activity_impl(JNIEnv *env, jobject thiz) {
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "Wake lock ready callback from Java");
|
||||
android_wakelock_set_activity(env, thiz);
|
||||
}
|
||||
|
||||
// Called from Java when activity is paused
|
||||
static void android_timer_activate_impl(JNIEnv *env, jobject thiz) {
|
||||
(void)env;
|
||||
(void)thiz;
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "JNI: Timer ACTIVATE callback");
|
||||
android_timer_activate();
|
||||
}
|
||||
|
||||
// Called from Java when activity is resumed
|
||||
static void android_timer_deactivate_impl(JNIEnv *env, jobject thiz) {
|
||||
(void)env;
|
||||
(void)thiz;
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "JNI: Timer DEACTIVATE callback");
|
||||
android_timer_deactivate();
|
||||
}
|
||||
|
||||
static JavaVM *g_jvm = NULL;
|
||||
static jobject g_activity = NULL;
|
||||
|
||||
static volatile struct {
|
||||
int status_bar;
|
||||
int nav_bar;
|
||||
int cutout_left;
|
||||
int cutout_top;
|
||||
int cutout_right;
|
||||
int cutout_bottom;
|
||||
} current_insets = {0};
|
||||
static pthread_mutex_t insets_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
// 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_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 function - Java calls this to check if play_in_background is enabled
|
||||
static jint nativeGetPlayInBackground(JNIEnv *env, jobject thiz)
|
||||
{
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeGetPlayInBackground: called");
|
||||
void *app = get_global_inbe_app();
|
||||
char msg[128];
|
||||
snprintf(msg, sizeof(msg), "nativeGetPlayInBackground: got app pointer %p", app);
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", msg);
|
||||
if (app != NULL) {
|
||||
InbeApp *inbe_app = (InbeApp*)app;
|
||||
jint result = inbe_get_play_in_background(&inbe_app->inbe);
|
||||
char msg[128];
|
||||
snprintf(msg, sizeof(msg), "nativeGetPlayInBackground: returning %d", result);
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", msg);
|
||||
return result;
|
||||
}
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeGetPlayInBackground: app is NULL, returning 0");
|
||||
return 0; // Default to disabled
|
||||
}
|
||||
|
||||
// JNI function - Auto-pause session when app goes to background
|
||||
static void nativePauseSession(JNIEnv *env, jobject thiz)
|
||||
{
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativePauseSession: called");
|
||||
void *app = get_global_inbe_app();
|
||||
char msg[128];
|
||||
snprintf(msg, sizeof(msg), "nativePauseSession: got app pointer %p", app);
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", msg);
|
||||
if (app != NULL) {
|
||||
InbeApp *inbe_app = (InbeApp*)app;
|
||||
char msg[128];
|
||||
snprintf(msg, sizeof(msg), "nativePauseSession: session_paused before = %d", inbe_app->session_paused);
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", msg);
|
||||
if (!inbe_app->session_paused) {
|
||||
inbe_app->session_paused = 1;
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativePauseSession: set session_paused = 1");
|
||||
#ifdef __ANDROID__
|
||||
if (inbe_app->inbe.play_in_background) {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativePauseSession: Releasing wake lock and stopping timer");
|
||||
android_wakelock_release();
|
||||
android_timer_stop();
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativePauseSession: SKIPPING wake lock/timer (play_in_background disabled)");
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativePauseSession: Session already paused, skipping");
|
||||
}
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_ERROR, "INBE_JNI", "nativePauseSession: app is NULL!");
|
||||
}
|
||||
}
|
||||
|
||||
// JNI function - Auto-resume session when app returns to foreground
|
||||
static void nativeResumeSession(JNIEnv *env, jobject thiz)
|
||||
{
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeResumeSession: called");
|
||||
void *app = get_global_inbe_app();
|
||||
char msg[128];
|
||||
snprintf(msg, sizeof(msg), "nativeResumeSession: got app pointer %p", app);
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", msg);
|
||||
if (app != NULL) {
|
||||
InbeApp *inbe_app = (InbeApp*)app;
|
||||
char msg[128];
|
||||
snprintf(msg, sizeof(msg), "nativeResumeSession: session_paused before = %d", inbe_app->session_paused);
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", msg);
|
||||
if (inbe_app->session_paused) {
|
||||
inbe_app->session_paused = 0;
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeResumeSession: set session_paused = 0");
|
||||
#ifdef __ANDROID__
|
||||
if (inbe_app->inbe.play_in_background) {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeResumeSession: Acquiring wake lock and starting timer");
|
||||
android_wakelock_acquire();
|
||||
android_timer_start();
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeResumeSession: SKIPPING wake lock/timer (play_in_background disabled)");
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", "nativeResumeSession: Session not paused, skipping");
|
||||
}
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_ERROR, "INBE_JNI", "nativeResumeSession: app is NULL!");
|
||||
}
|
||||
}
|
||||
|
||||
// JNI method table
|
||||
static const JNINativeMethod g_methods[] = {
|
||||
{"nativeSetInsets", "(IIIIII)V", (void*)nativeSetInsets},
|
||||
{"nativeWakeLockReady", "()V", (void*)android_wakelock_set_activity_impl},
|
||||
{"nativeTimerActivate", "()V", (void*)android_timer_activate_impl},
|
||||
{"nativeTimerDeactivate", "()V", (void*)android_timer_deactivate_impl},
|
||||
{"nativeGetPlayInBackground", "()I", (void*)nativeGetPlayInBackground},
|
||||
{"nativePauseSession", "()V", (void*)nativePauseSession},
|
||||
{"nativeResumeSession", "()V", (void*)nativeResumeSession},
|
||||
};
|
||||
|
||||
// JNI_OnLoad - Register native methods
|
||||
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
{
|
||||
JNIEnv *env = NULL;
|
||||
jint result;
|
||||
|
||||
g_jvm = vm;
|
||||
|
||||
// Also set JVM for wake lock module
|
||||
android_wakelock_set_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) {
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "=== android_insets_init ===");
|
||||
pthread_mutex_lock(&insets_mutex);
|
||||
memset((void *)¤t_insets, 0, sizeof(current_insets));
|
||||
pthread_mutex_unlock(&insets_mutex);
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "=== android_insets_init DONE ===");
|
||||
}
|
||||
|
||||
void android_insets_get(AndroidInsets *out) {
|
||||
pthread_mutex_lock(&insets_mutex);
|
||||
|
||||
// Simply return the current values
|
||||
if (out) {
|
||||
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);
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
#define INBE_ANDROID_INSETS_H
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <jni.h>
|
||||
|
||||
typedef struct {
|
||||
int status_bar;
|
||||
int nav_bar;
|
||||
@@ -13,6 +15,7 @@ typedef struct {
|
||||
|
||||
void android_insets_init(void);
|
||||
void android_insets_get(AndroidInsets *out);
|
||||
void android_wakelock_set_activity(JNIEnv *env, jobject activity);
|
||||
#else
|
||||
typedef struct {
|
||||
int status_bar;
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "android_share.h"
|
||||
#include "data.h"
|
||||
#include "locale.h"
|
||||
#include "version.h"
|
||||
#include "raylib.h"
|
||||
#include "miniz.h"
|
||||
@@ -36,6 +37,10 @@ int android_share_export(const char *filename)
|
||||
FilePathList files;
|
||||
int session_count = 0;
|
||||
char metadata[512];
|
||||
char metadata_header[128];
|
||||
char metadata_version[128];
|
||||
char metadata_date[128];
|
||||
char metadata_count[128];
|
||||
time_t now;
|
||||
struct tm *tm;
|
||||
char date_str[64];
|
||||
@@ -69,14 +74,16 @@ int android_share_export(const char *filename)
|
||||
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);
|
||||
locale_format(metadata_header, sizeof(metadata_header), "export_metadata_header");
|
||||
locale_format(metadata_version, sizeof(metadata_version), "export_metadata_version", INBE_VERSION_STRING);
|
||||
locale_format(metadata_date, sizeof(metadata_date), "export_metadata_date", date_str);
|
||||
locale_format(metadata_count, sizeof(metadata_count), "export_metadata_count", session_count);
|
||||
|
||||
snprintf(metadata, sizeof(metadata), "%s\n%s\n%s\n%s\n",
|
||||
metadata_header,
|
||||
metadata_version,
|
||||
metadata_date,
|
||||
metadata_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");
|
||||
@@ -208,7 +215,7 @@ int android_share_export(const char *filename)
|
||||
}
|
||||
|
||||
jmethodID method = (*env)->GetStaticMethodID(env, share_helper_class, "shareZipFile",
|
||||
"(Landroid/app/Activity;[BLjava/lang/String;)V");
|
||||
"(Landroid/app/Activity;[BLjava/lang/String;Ljava/lang/String;)V");
|
||||
|
||||
if(!method) {
|
||||
TraceLog(LOG_ERROR, "ANDROID_SHARE: shareZipFile method not found");
|
||||
@@ -221,10 +228,12 @@ int android_share_export(const char *filename)
|
||||
(*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);
|
||||
jstring jtitle = (*env)->NewStringUTF(env, locale_get("share_sheet_title"));
|
||||
(*env)->CallStaticVoidMethod(env, share_helper_class, method, native_activity->clazz, jarr, jname, jtitle);
|
||||
|
||||
(*env)->DeleteLocalRef(env, jarr);
|
||||
(*env)->DeleteLocalRef(env, jname);
|
||||
(*env)->DeleteLocalRef(env, jtitle);
|
||||
(*env)->DeleteLocalRef(env, class_loader);
|
||||
(*jvm)->DetachCurrentThread(jvm);
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,157 @@
|
||||
#include "android_timer.h"
|
||||
#include "app.h"
|
||||
#include <time.h>
|
||||
|
||||
#include <raylib.h>
|
||||
#include <pthread.h>
|
||||
#include <android/log.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define LOG_TAG "INBE_TIMER"
|
||||
#define TARGET_FPS 60
|
||||
#define FRAME_TIME_US (1000000 / TARGET_FPS) // ~16666 microseconds for 60fps
|
||||
|
||||
static pthread_t timer_thread;
|
||||
static pthread_mutex_t timer_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t inbe_state_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int timer_running = 0;
|
||||
static int timer_active = 0; // Only step when timer is active (activity paused)
|
||||
static void *g_app = NULL;
|
||||
|
||||
static void*
|
||||
timer_thread_func(void *arg) {
|
||||
(void)arg;
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "Timer thread started");
|
||||
int frame_count = 0;
|
||||
|
||||
while (1) {
|
||||
pthread_mutex_lock(&timer_mutex);
|
||||
|
||||
// Check if we should stop
|
||||
if (!timer_running) {
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "Timer thread: stopping");
|
||||
break;
|
||||
}
|
||||
|
||||
// Check if we should run (active and have app pointer)
|
||||
int should_run = timer_active && g_app != NULL;
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
|
||||
if (should_run) {
|
||||
// Log every 60 frames (1 second)
|
||||
if (frame_count % 60 == 0) {
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "Timer: Running meditation step + sounds");
|
||||
}
|
||||
frame_count++;
|
||||
|
||||
// Update meditation state and sounds with mutex protection
|
||||
pthread_mutex_lock(&inbe_state_mutex);
|
||||
InbeApp *app = (InbeApp*)g_app;
|
||||
inbestep(&app->inbe);
|
||||
update_session_sounds(app);
|
||||
pthread_mutex_unlock(&inbe_state_mutex);
|
||||
|
||||
// Sleep for exact frame time (60fps = ~16.666ms)
|
||||
usleep(FRAME_TIME_US);
|
||||
} else {
|
||||
// Not active, sleep a bit before checking again
|
||||
if (frame_count > 0) {
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "Timer: Paused (inactive)");
|
||||
frame_count = 0;
|
||||
}
|
||||
usleep(50000); // 50ms
|
||||
}
|
||||
}
|
||||
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "Timer thread stopped");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
android_timer_init(void) {
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "=== android_timer_init ===");
|
||||
}
|
||||
|
||||
void
|
||||
android_timer_set_app(void *app_ptr) {
|
||||
pthread_mutex_lock(&timer_mutex);
|
||||
g_app = app_ptr;
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
TraceLog(LOG_INFO, "INBE: Timer app pointer set");
|
||||
}
|
||||
|
||||
pthread_mutex_t*
|
||||
android_timer_get_mutex(void) {
|
||||
return &inbe_state_mutex;
|
||||
}
|
||||
|
||||
void
|
||||
android_timer_start(void) {
|
||||
pthread_mutex_lock(&timer_mutex);
|
||||
|
||||
if (timer_running) {
|
||||
timer_active = 1; // Activate timer (activity paused)
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "Timer activated (activity paused)");
|
||||
return;
|
||||
}
|
||||
|
||||
timer_running = 1;
|
||||
timer_active = 0; // Start inactive (activity active)
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
|
||||
int result = pthread_create(&timer_thread, NULL, timer_thread_func, NULL);
|
||||
if (result != 0) {
|
||||
__android_log_write(ANDROID_LOG_ERROR, LOG_TAG, "Failed to create timer thread");
|
||||
} else {
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "Timer thread created");
|
||||
}
|
||||
|
||||
TraceLog(LOG_INFO, "INBE: Background timer started");
|
||||
}
|
||||
|
||||
void
|
||||
android_timer_stop(void) {
|
||||
pthread_mutex_lock(&timer_mutex);
|
||||
|
||||
if (!timer_running) {
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
timer_running = 0;
|
||||
timer_active = 0;
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
|
||||
pthread_join(timer_thread, NULL);
|
||||
TraceLog(LOG_INFO, "INBE: Background timer stopped");
|
||||
}
|
||||
|
||||
void
|
||||
android_timer_activate(void) {
|
||||
pthread_mutex_lock(&timer_mutex);
|
||||
timer_active = 1;
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "ACTIVATE: Timer active");
|
||||
TraceLog(LOG_INFO, "INBE: Background timer ACTIVATED - screen off");
|
||||
}
|
||||
|
||||
void
|
||||
android_timer_deactivate(void) {
|
||||
pthread_mutex_lock(&timer_mutex);
|
||||
timer_active = 0;
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "DEACTIVATE: Timer inactive");
|
||||
TraceLog(LOG_INFO, "INBE: Background timer DEACTIVATED - screen on");
|
||||
}
|
||||
|
||||
void*
|
||||
android_timer_get_app(void)
|
||||
{
|
||||
void *app;
|
||||
pthread_mutex_lock(&timer_mutex);
|
||||
app = g_app;
|
||||
pthread_mutex_unlock(&timer_mutex);
|
||||
return app;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef INBE_ANDROID_TIMER_H
|
||||
#define INBE_ANDROID_TIMER_H
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <jni.h>
|
||||
#include <pthread.h>
|
||||
void android_timer_init(void);
|
||||
void android_timer_start(void);
|
||||
void android_timer_stop(void);
|
||||
void android_timer_set_app(void *app_ptr);
|
||||
void android_timer_activate(void);
|
||||
void android_timer_deactivate(void);
|
||||
void* android_timer_get_app(void);
|
||||
pthread_mutex_t* android_timer_get_mutex(void);
|
||||
#else
|
||||
// Stub functions for non-Android platforms
|
||||
static inline void android_timer_init(void) {}
|
||||
static inline void android_timer_start(void) {}
|
||||
static inline void android_timer_stop(void) {}
|
||||
static inline void android_timer_set_app(void *app_ptr) {(void)app_ptr;}
|
||||
static inline void android_timer_activate(void) {}
|
||||
static inline void android_timer_deactivate(void) {}
|
||||
static inline void* android_timer_get_app(void) { return NULL; }
|
||||
static inline void* android_timer_get_mutex(void) { return NULL; }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,110 @@
|
||||
#include "android_wakelock.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <raylib.h>
|
||||
#include <pthread.h>
|
||||
#include <android/log.h>
|
||||
#include <android_native_app_glue.h>
|
||||
#include <jni.h>
|
||||
|
||||
#define LOG_TAG "INBE_WAKE"
|
||||
|
||||
static JavaVM *g_jvm = NULL;
|
||||
static jobject g_activity = NULL;
|
||||
static jmethodID g_acquire_method = NULL;
|
||||
static jmethodID g_release_method = NULL;
|
||||
static pthread_mutex_t wakelock_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
void android_wakelock_init(void) {
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "=== android_wakelock_init ===");
|
||||
}
|
||||
|
||||
void android_wakelock_set_activity(JNIEnv *env, jobject activity) {
|
||||
pthread_mutex_lock(&wakelock_mutex);
|
||||
|
||||
if (g_activity) {
|
||||
(*env)->DeleteGlobalRef(env, g_activity);
|
||||
}
|
||||
|
||||
g_activity = (*env)->NewGlobalRef(env, activity);
|
||||
|
||||
if (g_activity) {
|
||||
jclass clazz = (*env)->GetObjectClass(env, activity);
|
||||
if (clazz) {
|
||||
g_acquire_method = (*env)->GetMethodID(env, clazz, "acquireWakeLock", "()V");
|
||||
g_release_method = (*env)->GetMethodID(env, clazz, "releaseWakeLock", "()V");
|
||||
(*env)->DeleteLocalRef(env, clazz);
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "Wake lock activity set successfully");
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&wakelock_mutex);
|
||||
}
|
||||
|
||||
void android_wakelock_acquire(void) {
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "=== ACQUIRE START ===");
|
||||
|
||||
pthread_mutex_lock(&wakelock_mutex);
|
||||
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "ACQUIRE: Checking if g_jvm and g_activity are set");
|
||||
char msg[128];
|
||||
snprintf(msg, sizeof(msg), "ACQUIRE: g_jvm=%p, g_activity=%p", g_jvm, g_activity);
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, msg);
|
||||
|
||||
if (!g_jvm || !g_activity) {
|
||||
__android_log_write(ANDROID_LOG_ERROR, LOG_TAG, "ACQUIRE: JNI not initialized - skipping wake lock");
|
||||
pthread_mutex_unlock(&wakelock_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv *env = NULL;
|
||||
jint result = (*g_jvm)->GetEnv(g_jvm, (void**)&env, JNI_VERSION_1_6);
|
||||
if (result == JNI_EDETACHED) {
|
||||
result = (*g_jvm)->AttachCurrentThread(g_jvm, &env, NULL);
|
||||
}
|
||||
|
||||
if (env && g_acquire_method) {
|
||||
(*env)->CallVoidMethod(env, g_activity, g_acquire_method);
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "ACQUIRE: SUCCESS");
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&wakelock_mutex);
|
||||
TraceLog(LOG_INFO, "INBE: Wake lock acquired");
|
||||
}
|
||||
|
||||
void android_wakelock_release(void) {
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "=== RELEASE START ===");
|
||||
|
||||
pthread_mutex_lock(&wakelock_mutex);
|
||||
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "RELEASE: Checking if g_jvm and g_activity are set");
|
||||
char msg[128];
|
||||
snprintf(msg, sizeof(msg), "RELEASE: g_jvm=%p, g_activity=%p", g_jvm, g_activity);
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, msg);
|
||||
|
||||
if (!g_jvm || !g_activity) {
|
||||
__android_log_write(ANDROID_LOG_ERROR, LOG_TAG, "RELEASE: JNI not initialized - skipping wake lock");
|
||||
pthread_mutex_unlock(&wakelock_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv *env = NULL;
|
||||
jint result = (*g_jvm)->GetEnv(g_jvm, (void**)&env, JNI_VERSION_1_6);
|
||||
if (result == JNI_EDETACHED) {
|
||||
result = (*g_jvm)->AttachCurrentThread(g_jvm, &env, NULL);
|
||||
}
|
||||
|
||||
if (env && g_release_method) {
|
||||
(*env)->CallVoidMethod(env, g_activity, g_release_method);
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "RELEASE: SUCCESS");
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&wakelock_mutex);
|
||||
TraceLog(LOG_INFO, "INBE: Wake lock released");
|
||||
}
|
||||
|
||||
// Called from JNI to set the JVM reference
|
||||
void android_wakelock_set_jvm(JavaVM *vm) {
|
||||
g_jvm = vm;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef INBE_ANDROID_WAKELOCK_H
|
||||
#define INBE_ANDROID_WAKELOCK_H
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <jni.h>
|
||||
void android_wakelock_init(void);
|
||||
void android_wakelock_acquire(void);
|
||||
void android_wakelock_release(void);
|
||||
void android_wakelock_set_activity(JNIEnv *env, jobject activity);
|
||||
void android_wakelock_set_jvm(JavaVM *vm);
|
||||
#else
|
||||
// Stub functions for non-Android platforms
|
||||
static inline void android_wakelock_init(void) {}
|
||||
static inline void android_wakelock_acquire(void) {}
|
||||
static inline void android_wakelock_release(void) {}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,107 +0,0 @@
|
||||
#include "android_insets.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#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;
|
||||
int cutout_left;
|
||||
int cutout_top;
|
||||
int cutout_right;
|
||||
int cutout_bottom;
|
||||
} current_insets = {0};
|
||||
static pthread_mutex_t insets_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
// 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_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 *)¤t_insets, 0, sizeof(current_insets));
|
||||
pthread_mutex_unlock(&insets_mutex);
|
||||
}
|
||||
|
||||
void android_insets_get(AndroidInsets *out) {
|
||||
pthread_mutex_lock(&insets_mutex);
|
||||
|
||||
// Simply return the current values
|
||||
if (out) {
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
@@ -1,12 +1,15 @@
|
||||
#include "app.h"
|
||||
#include "data.h"
|
||||
#include "locale.h"
|
||||
#include "tabs/language_tab.h"
|
||||
#include "tabs/history_tab.h"
|
||||
#include "tabs/manual_tab.h"
|
||||
#include "tabs/settings_tab.h"
|
||||
#include "theme.h"
|
||||
#include "theme_meta.h"
|
||||
#include "version.h"
|
||||
#include "ui.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/dpi.h"
|
||||
#if !defined(LOTUS_BUILD)
|
||||
#define RINI_IMPLEMENTATION
|
||||
#endif
|
||||
@@ -24,26 +27,25 @@
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
#define INBE_DEFAULT_TITLE "Inner Breeze"
|
||||
#ifdef __ANDROID__
|
||||
#include "android_wakelock.h"
|
||||
#include "android_timer.h"
|
||||
void set_global_inbe_app(InbeApp *app);
|
||||
#endif
|
||||
|
||||
#define INBE_DEFAULT_WIDTH 320
|
||||
#define INBE_DEFAULT_HEIGHT 560
|
||||
typedef struct InbeConfig {
|
||||
char title[64];
|
||||
int width;
|
||||
int height;
|
||||
int loaded;
|
||||
} InbeConfig;
|
||||
|
||||
static InbeConfig config = {
|
||||
.title = INBE_DEFAULT_TITLE,
|
||||
InbeConfig config = {
|
||||
.title = "",
|
||||
.width = INBE_DEFAULT_WIDTH,
|
||||
.height = INBE_DEFAULT_HEIGHT,
|
||||
.loaded = 0
|
||||
.loaded = 0,
|
||||
.title_custom = 0
|
||||
};
|
||||
|
||||
int view_width = INBE_DEFAULT_WIDTH;
|
||||
int view_height = INBE_DEFAULT_HEIGHT;
|
||||
static float dpi_scale = 1.0f;
|
||||
Color c_text, c_bg, c_circle, c_button, c_button_hover, c_icon;
|
||||
|
||||
/* Forward declarations for tab callbacks */
|
||||
@@ -66,13 +68,65 @@ static void on_settings_tab_click(void *user_data) {
|
||||
}
|
||||
|
||||
static UITab g_tabs[] = {
|
||||
{"History", {0}, history_tab_on_click, NULL},
|
||||
{"Manual", {0}, on_manual_tab_click, NULL},
|
||||
{"Settings", {0}, on_settings_tab_click, NULL}
|
||||
{NULL, {0}, UI_ICON_TYPE_STAT, history_tab_on_click, NULL},
|
||||
{NULL, {0}, UI_ICON_TYPE_MANUAL, on_manual_tab_click, NULL},
|
||||
{NULL, {0}, UI_ICON_TYPE_GEAR, on_settings_tab_click, NULL}
|
||||
};
|
||||
|
||||
static UITabBar g_tab_bar = {g_tabs, 3};
|
||||
|
||||
static void
|
||||
refresh_tab_labels(void)
|
||||
{
|
||||
g_tabs[0].label = locale_get("tab_history");
|
||||
g_tabs[1].label = locale_get("tab_manual");
|
||||
g_tabs[2].label = locale_get("tab_settings");
|
||||
}
|
||||
|
||||
void
|
||||
refresh_locale_dependent_text(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
|
||||
refresh_tab_labels();
|
||||
if(!config.title_custom) {
|
||||
snprintf(config.title, sizeof(config.title), "%s", locale_get("app_title"));
|
||||
}
|
||||
manual_tab_reset_layouts(app);
|
||||
app->language_index = locale_current_index();
|
||||
if(app->language_index < 0)
|
||||
app->language_index = 0;
|
||||
}
|
||||
|
||||
void
|
||||
apply_language_selection(InbeApp *app, int language_index, int save_now)
|
||||
{
|
||||
const char *code;
|
||||
|
||||
if(app == NULL)
|
||||
return;
|
||||
|
||||
if(language_index < 0 || language_index >= locale_count())
|
||||
language_index = 0;
|
||||
|
||||
code = locale_code_at(language_index);
|
||||
if(code == NULL || code[0] == '\0')
|
||||
code = "en";
|
||||
|
||||
if(!locale_set(code)) {
|
||||
code = "en";
|
||||
locale_set(code);
|
||||
}
|
||||
|
||||
snprintf(app->language, sizeof(app->language), "%s", code);
|
||||
app->language_selected = 1;
|
||||
refresh_locale_dependent_text(app);
|
||||
|
||||
if(save_now)
|
||||
save_settings(app);
|
||||
}
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
#include <emscripten.h>
|
||||
|
||||
@@ -290,38 +344,31 @@ load_config(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
snprintf(config.title, sizeof(config.title), "%s",
|
||||
rini_get_value_text_fallback(ini, "title", INBE_DEFAULT_TITLE));
|
||||
const char *title = rini_get_value_text(ini, "title");
|
||||
if(title != NULL && title[0] != '\0') {
|
||||
snprintf(config.title, sizeof(config.title), "%s", title);
|
||||
config.title_custom = 1;
|
||||
} else {
|
||||
snprintf(config.title, sizeof(config.title), "%s", locale_get("app_title"));
|
||||
config.title_custom = 0;
|
||||
}
|
||||
config.width = rini_get_value_fallback(ini, "width", INBE_DEFAULT_WIDTH);
|
||||
config.height = rini_get_value_fallback(ini, "height", INBE_DEFAULT_HEIGHT);
|
||||
rini_unload(&ini);
|
||||
break;
|
||||
}
|
||||
|
||||
if(config.title[0] == '\0') {
|
||||
snprintf(config.title, sizeof(config.title), "%s", locale_get("app_title"));
|
||||
config.title_custom = 0;
|
||||
}
|
||||
|
||||
register_all_themes();
|
||||
refresh_theme_colors(ThemeSky, 0); /* Default: Sky light mode */
|
||||
|
||||
config.loaded = 1;
|
||||
}
|
||||
|
||||
const char *
|
||||
inbe_app_title(void)
|
||||
{
|
||||
return config.title;
|
||||
}
|
||||
|
||||
int
|
||||
inbe_app_width(void)
|
||||
{
|
||||
return config.width;
|
||||
}
|
||||
|
||||
int
|
||||
inbe_app_height(void)
|
||||
{
|
||||
return config.height;
|
||||
}
|
||||
|
||||
int
|
||||
clampi(int value, int min, int max)
|
||||
{
|
||||
@@ -387,11 +434,9 @@ reset_round_recover(Inbe *inbe)
|
||||
void
|
||||
apply_settings(Inbe *inbe, int speed, int max_rounds, int max_breaths, int pause_seconds)
|
||||
{
|
||||
static const int breath_half_ticks[] = {108, 100, 93, 86, 80, 74, 68, 63, 58, 53, 48, 42, 36, 30, 24, 18};
|
||||
|
||||
speed = clampi(speed, SETTINGS_SPEED_MIN, SETTINGS_SPEED_MAX);
|
||||
inbe->speed_level = speed;
|
||||
inbe->breath_half_ticks = breath_half_ticks[speed - 1];
|
||||
inbe->breath_half_ticks = inbe_breath_half_ticks_for_speed(speed);
|
||||
inbe->max_rounds = clampi(max_rounds, 1, MaxRounds);
|
||||
inbe->pause_seconds = clampi(pause_seconds, SETTINGS_PAUSE_MIN, SETTINGS_PAUSE_MAX);
|
||||
count_from_int(inbe->maxbreaths, clampi(max_breaths, SETTINGS_BREATHS_MIN, SETTINGS_BREATHS_MAX));
|
||||
@@ -404,9 +449,12 @@ reset_settings_preview(InbeApp *app)
|
||||
int max_rounds = app->inbe.max_rounds;
|
||||
int max_breaths = int_from_count(app->inbe.maxbreaths);
|
||||
int pause_seconds = app->inbe.pause_seconds;
|
||||
int play_in_background = app->inbe.play_in_background;
|
||||
int content_w;
|
||||
|
||||
inbeinit(&app->settings_preview);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
app->settings_preview.play_in_background = play_in_background;
|
||||
ui_centered_column(CONTENT_MAX_W, CONTENT_SIDE_PAD, NULL, &content_w);
|
||||
update_preview_bounds(&app->settings_preview, content_w, ui_px(132));
|
||||
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
@@ -423,8 +471,9 @@ save_settings(InbeApp *app)
|
||||
#else
|
||||
"settings.ini";
|
||||
#endif
|
||||
#ifdef __ANDROID__
|
||||
snprintf(text, sizeof(text),
|
||||
"speed %d\nmax_rounds %d\nmax_breaths %d\npause_seconds %d\nsound_volume %d\ntutorial_seen %d\ntheme %d\ndark_mode %d\nfullscreen %d\n",
|
||||
"speed %d\nmax_rounds %d\nmax_breaths %d\npause_seconds %d\nsound_volume %d\ntutorial_seen %d\ntheme %d\ndark_mode %d\nfullscreen %d\nprogressive_speed %d\nplay_in_background %d\nlanguage %s\n",
|
||||
app->inbe.speed_level,
|
||||
app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths),
|
||||
@@ -433,7 +482,29 @@ save_settings(InbeApp *app)
|
||||
app->tutorial_seen ? 1 : 0,
|
||||
app->theme_id,
|
||||
app->dark_mode,
|
||||
app->fullscreen_enabled ? 1 : 0);
|
||||
app->fullscreen_enabled ? 1 : 0,
|
||||
app->inbe.progressive_speed,
|
||||
app->inbe.play_in_background,
|
||||
(app->language_selected && app->language[0] != '\0')
|
||||
? app->language
|
||||
: "");
|
||||
#else
|
||||
snprintf(text, sizeof(text),
|
||||
"speed %d\nmax_rounds %d\nmax_breaths %d\npause_seconds %d\nsound_volume %d\ntutorial_seen %d\ntheme %d\ndark_mode %d\nfullscreen %d\nprogressive_speed %d\nlanguage %s\n",
|
||||
app->inbe.speed_level,
|
||||
app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths),
|
||||
app->inbe.pause_seconds,
|
||||
app->sound_volume,
|
||||
app->tutorial_seen ? 1 : 0,
|
||||
app->theme_id,
|
||||
app->dark_mode,
|
||||
app->fullscreen_enabled ? 1 : 0,
|
||||
app->inbe.progressive_speed,
|
||||
(app->language_selected && app->language[0] != '\0')
|
||||
? app->language
|
||||
: "");
|
||||
#endif
|
||||
SaveFileText(settings_path, text);
|
||||
#if defined(PLATFORM_WEB)
|
||||
sync_web_storage();
|
||||
@@ -463,9 +534,37 @@ load_settings(InbeApp *app)
|
||||
app->dark_mode = rini_get_value_fallback(settings, "dark_mode", 0) != 0;
|
||||
app->fullscreen_enabled = rini_get_value_fallback(settings, "fullscreen", 0) != 0;
|
||||
app->sound_volume = clampi(sound_volume, SETTINGS_VOLUME_MIN, SETTINGS_VOLUME_MAX);
|
||||
app->inbe.progressive_speed = rini_get_value_fallback(settings, "progressive_speed", 1) != 0;
|
||||
{
|
||||
const char *language = rini_get_value_text(settings, "language");
|
||||
if(language != NULL && language[0] != '\0') {
|
||||
snprintf(app->language, sizeof(app->language), "%s", language);
|
||||
app->language_selected = 1;
|
||||
if(!locale_set(app->language)) {
|
||||
snprintf(app->language, sizeof(app->language), "%s", "en");
|
||||
locale_set(app->language);
|
||||
}
|
||||
} else {
|
||||
snprintf(app->language, sizeof(app->language), "%s", "en");
|
||||
app->language_selected = 0;
|
||||
locale_set(app->language);
|
||||
}
|
||||
app->language_index = locale_current_index();
|
||||
if(app->language_index < 0)
|
||||
app->language_index = 0;
|
||||
}
|
||||
#ifdef __ANDROID__
|
||||
app->inbe.play_in_background = rini_get_value_fallback(settings, "play_in_background",
|
||||
1 // Default to enabled on Android
|
||||
);
|
||||
TraceLog(LOG_INFO, "INBE: Loaded play_in_background setting = %d", app->inbe.play_in_background);
|
||||
#else
|
||||
app->inbe.play_in_background = 0;
|
||||
#endif
|
||||
|
||||
refresh_theme_colors(app->theme_id, app->dark_mode);
|
||||
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
|
||||
refresh_locale_dependent_text(app);
|
||||
rini_unload(&settings);
|
||||
}
|
||||
|
||||
@@ -584,7 +683,7 @@ play_app_sound(InbeApp *app, Sound sound, float scale)
|
||||
PlaySound(sound);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
update_session_sounds(InbeApp *app)
|
||||
{
|
||||
if (app == NULL) return;
|
||||
@@ -618,17 +717,17 @@ update_session_sounds(InbeApp *app)
|
||||
switch (app->inbe.phase) {
|
||||
case InbePhaseHold:
|
||||
break;
|
||||
|
||||
|
||||
case InbePhaseRecover:
|
||||
play_app_sound(app, app->breath_in_sound, 1.0f);
|
||||
/* Sound already played in finish_hold() */
|
||||
break;
|
||||
|
||||
|
||||
case InbePhaseNext:
|
||||
if (app->sound_last_phase == InbePhaseRecover) {
|
||||
play_app_sound(app, app->breath_out_sound, 1.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -643,8 +742,12 @@ start_session(InbeApp *app)
|
||||
int max_rounds = app->inbe.max_rounds;
|
||||
int max_breaths = int_from_count(app->inbe.maxbreaths);
|
||||
int pause_seconds = app->inbe.pause_seconds;
|
||||
int progressive_speed = app->inbe.progressive_speed;
|
||||
int play_in_background = app->inbe.play_in_background;
|
||||
|
||||
inbeinit(&app->inbe);
|
||||
app->inbe.progressive_speed = progressive_speed;
|
||||
app->inbe.play_in_background = play_in_background;
|
||||
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
|
||||
/* Save user's pause preference and use 3 seconds for first round */
|
||||
app->saved_pause_seconds = app->inbe.pause_seconds;
|
||||
@@ -653,7 +756,83 @@ start_session(InbeApp *app)
|
||||
app->inbe.screen = InbeScreenSession;
|
||||
app->session_paused = 0;
|
||||
app->results_saved = 0;
|
||||
app->results_path[0] = '\0';
|
||||
remember_sound_state(app);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
TraceLog(LOG_INFO, "INBE: Starting session - play_in_background = %d", app->inbe.play_in_background);
|
||||
if (app->inbe.play_in_background) {
|
||||
TraceLog(LOG_INFO, "INBE: Acquiring wake lock and starting timer");
|
||||
android_wakelock_acquire();
|
||||
android_timer_set_app(app);
|
||||
set_global_inbe_app(app); // Update global pointer for JNI
|
||||
android_timer_start();
|
||||
} else {
|
||||
TraceLog(LOG_INFO, "INBE: SKIPPING wake lock and timer (play_in_background disabled)");
|
||||
set_global_inbe_app(app); // Still set pointer for JNI access
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
collect_result_rounds(InbeApp *app, int *round_times, int max_rounds)
|
||||
{
|
||||
int rounds;
|
||||
|
||||
if(app == NULL || round_times == NULL || max_rounds <= 0)
|
||||
return 0;
|
||||
|
||||
rounds = app->inbe.round + 1;
|
||||
if(rounds < 1)
|
||||
rounds = 1;
|
||||
if(rounds > app->inbe.max_rounds)
|
||||
rounds = app->inbe.max_rounds;
|
||||
if(rounds > max_rounds)
|
||||
rounds = max_rounds;
|
||||
|
||||
for(int i = 0; i < rounds; i++)
|
||||
round_times[i] = int_from_count(app->inbe.results[i]);
|
||||
|
||||
return rounds;
|
||||
}
|
||||
|
||||
static int
|
||||
ensure_results_saved(InbeApp *app)
|
||||
{
|
||||
int round_times[MaxRounds];
|
||||
int rounds;
|
||||
|
||||
if(app == NULL)
|
||||
return 0;
|
||||
if(app->results_saved)
|
||||
return 1;
|
||||
|
||||
rounds = collect_result_rounds(app, round_times, MaxRounds);
|
||||
if(rounds <= 0)
|
||||
return 0;
|
||||
|
||||
if(data_save_session_path(round_times, rounds, app->results_path, sizeof(app->results_path))) {
|
||||
app->results_saved = 1;
|
||||
TraceLog(LOG_INFO, "INBE: session saved successfully");
|
||||
return 1;
|
||||
}
|
||||
|
||||
TraceLog(LOG_WARNING, "INBE: session save failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
discard_saved_results(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
|
||||
if(app->results_saved && app->results_path[0] != '\0') {
|
||||
if(data_delete_session(app->results_path)) {
|
||||
app->results_saved = 0;
|
||||
app->results_path[0] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -666,6 +845,8 @@ finish_hold(InbeApp *app)
|
||||
app->inbe.breath_frame = 0;
|
||||
app->inbe.breathtick = 0;
|
||||
app->inbe.sectick = 0;
|
||||
/* Play breath-in sound when user finishes hold and starts recovery */
|
||||
play_app_sound(app, app->breath_in_sound, 1.0f);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -683,17 +864,7 @@ finish_round(InbeApp *app)
|
||||
}
|
||||
reset_round_start(&app->inbe);
|
||||
} else {
|
||||
/* Save session results using data module */
|
||||
int round_times[MaxRounds];
|
||||
for(int i = 0; i < app->inbe.max_rounds && i < MaxRounds; i++) {
|
||||
round_times[i] = int_from_count(app->inbe.results[i]);
|
||||
}
|
||||
if(data_save_session(round_times, app->inbe.max_rounds)) {
|
||||
app->results_saved = 1;
|
||||
TraceLog(LOG_INFO, "INBE: session saved successfully");
|
||||
} else {
|
||||
TraceLog(LOG_WARNING, "INBE: session save failed");
|
||||
}
|
||||
ensure_results_saved(app);
|
||||
app->inbe.screen = InbeScreenResults;
|
||||
}
|
||||
}
|
||||
@@ -840,10 +1011,10 @@ draw_session_status(InbeApp *app, int center_x, int center_y)
|
||||
|
||||
int font = ui_clamp_px(18, 16, 20);
|
||||
/* Calculate fixed width based on maximum possible value */
|
||||
snprintf(max_text, sizeof(max_text), "STARTING IN %2d", 30);
|
||||
locale_format(max_text, sizeof(max_text), "starting_in", 30);
|
||||
max_text_w = MeasureText(max_text, font);
|
||||
|
||||
snprintf(text, sizeof(text), "STARTING IN %2d", remaining);
|
||||
locale_format(text, sizeof(text), "starting_in", remaining);
|
||||
text_y = center_y - (int)(app->inbe.rmax * 0.72f) - ui_px(40);
|
||||
if(text_y < ui_px(20))
|
||||
text_y = ui_px(20);
|
||||
@@ -864,9 +1035,18 @@ inbe_app_init(void *vapp) {
|
||||
if(app == 0)
|
||||
return;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
if (app->inbe.play_in_background) {
|
||||
android_timer_stop();
|
||||
android_wakelock_release();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
init_web_storage();
|
||||
#endif
|
||||
locale_init();
|
||||
refresh_tab_labels();
|
||||
load_config();
|
||||
inbeinit(&app->inbe);
|
||||
update_circle_bounds_for_view(&app->inbe, ui_clamp_px(SETTINGS_TITLE_H, 48, 60),
|
||||
@@ -890,6 +1070,7 @@ inbe_app_init(void *vapp) {
|
||||
app->manual_drag_content = 0;
|
||||
app->manual_drag_content_y = 0;
|
||||
app->tutorial_step = 0;
|
||||
app->tutorial_layouts_initialized = 0;
|
||||
app->history_scroll = 0;
|
||||
app->history_drag_scrollbar = 0;
|
||||
app->history_drag_content = 0;
|
||||
@@ -901,6 +1082,7 @@ inbe_app_init(void *vapp) {
|
||||
app->history_record[0] = 0;
|
||||
app->session_paused = 0;
|
||||
app->results_saved = 0;
|
||||
app->results_path[0] = '\0';
|
||||
remember_sound_state(app);
|
||||
reset_settings_preview(app);
|
||||
|
||||
@@ -933,10 +1115,13 @@ inbe_app_init(void *vapp) {
|
||||
}
|
||||
/* Update tab bar icons */
|
||||
g_tabs[0].icon = app->stat_icon;
|
||||
g_tabs[0].icon_type = UI_ICON_TYPE_STAT;
|
||||
g_tabs[0].user_data = app;
|
||||
g_tabs[1].icon = app->manual_icon;
|
||||
g_tabs[1].icon_type = UI_ICON_TYPE_MANUAL;
|
||||
g_tabs[1].user_data = app;
|
||||
g_tabs[2].icon = app->gear_icon;
|
||||
g_tabs[2].icon_type = UI_ICON_TYPE_GEAR;
|
||||
g_tabs[2].user_data = app;
|
||||
|
||||
if(app->telegram_icon.id == 0) {
|
||||
@@ -960,8 +1145,12 @@ inbe_app_init(void *vapp) {
|
||||
if(app->begin_image.id == 0) {
|
||||
app->begin_image = load_asset_texture("begin.jpg");
|
||||
}
|
||||
if(!app->tutorial_seen)
|
||||
if(!app->language_selected)
|
||||
app->inbe.screen = InbeScreenLanguage;
|
||||
else if(!app->tutorial_seen)
|
||||
app->inbe.screen = InbeScreenManual;
|
||||
else
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
|
||||
/* Reset modal state */
|
||||
app->modal.active = 0;
|
||||
@@ -1000,17 +1189,27 @@ handle_back_button(InbeApp *app)
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
break;
|
||||
|
||||
case InbeScreenLanguage:
|
||||
break;
|
||||
|
||||
case InbeScreenManual:
|
||||
manual_tab_close_tutorial(app, 1);
|
||||
break;
|
||||
|
||||
case InbeScreenResults:
|
||||
ensure_results_saved(app);
|
||||
inbe_app_init(app);
|
||||
break;
|
||||
|
||||
case InbeScreenSession:
|
||||
/* When paused, exit immediately */
|
||||
if(app->session_paused) {
|
||||
#ifdef __ANDROID__
|
||||
if (app->inbe.play_in_background) {
|
||||
android_wakelock_release();
|
||||
android_timer_stop();
|
||||
}
|
||||
#endif
|
||||
inbe_app_init(app);
|
||||
} else {
|
||||
/* Show confirmation modal */
|
||||
@@ -1051,6 +1250,12 @@ updateapp(InbeApp *app)
|
||||
return;
|
||||
}
|
||||
|
||||
if(app->inbe.screen == InbeScreenLanguage) {
|
||||
language_tab_draw(app);
|
||||
app->inbe.frame++;
|
||||
return;
|
||||
}
|
||||
|
||||
if(app->inbe.screen == InbeScreenManual) {
|
||||
manual_tab_draw(app);
|
||||
app->inbe.frame++;
|
||||
@@ -1082,11 +1287,11 @@ updateapp(InbeApp *app)
|
||||
DrawText(config.title, center_x - title_w / 2, ui_px(20), title_font, c_text);
|
||||
|
||||
{
|
||||
int play_y = center_y + (int)(app->inbe.rmax * dpi_scale + 0.5f) + ui_px(20);
|
||||
int play_y = center_y + (int)(app->inbe.rmax * dpi_ui_scale() + 0.5f) + ui_px(20);
|
||||
int play_limit = view_height - ui_clamp_px(TAB_BAR_H, 54, 66) - ui_px(48);
|
||||
if(play_y > play_limit)
|
||||
play_y = play_limit;
|
||||
if (ui_draw_text_btn(app, center_x, play_y, "PLAY", &hover)) {
|
||||
if (ui_draw_text_btn(app, center_x, play_y, locale_get("play_button"), &hover)) {
|
||||
start_session(app);
|
||||
}
|
||||
}
|
||||
@@ -1095,7 +1300,7 @@ updateapp(InbeApp *app)
|
||||
|
||||
case InbeScreenSession: {
|
||||
int return_hover = 0;
|
||||
if(app->return_icon.id != 0 && ui_draw_icon_btn_padded(app, ui_px(12), ui_px(12), ui_clamp_px(ICON_SIZE_SMALL, ICON_SIZE_SMALL_MIN, ICON_SIZE_SMALL_MAX), app->return_icon, &return_hover)) {
|
||||
if(ui_draw_icon_btn_padded(app, ui_px(12), ui_px(12), ui_clamp_px(ICON_SIZE_SMALL, ICON_SIZE_SMALL_MIN, ICON_SIZE_SMALL_MAX), app->return_icon, UI_ICON_TYPE_RETURN, &return_hover)) {
|
||||
handle_back_button(app);
|
||||
}
|
||||
|
||||
@@ -1103,9 +1308,12 @@ updateapp(InbeApp *app)
|
||||
int has_rounds = session_has_completed_rounds(app);
|
||||
|
||||
if(has_rounds) {
|
||||
modal_result = ui_draw_modal_3btn(app, "Exit Session?",
|
||||
"Save completed rounds before exit?",
|
||||
"Cancel", "Save", "Discard");
|
||||
modal_result = ui_draw_modal_3btn(app,
|
||||
locale_get("exit_session_title"),
|
||||
locale_get("save_completed_rounds_message"),
|
||||
locale_get("cancel_button"),
|
||||
locale_get("save_button"),
|
||||
locale_get("discard_button"));
|
||||
if(modal_result == 1) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
@@ -1120,26 +1328,46 @@ updateapp(InbeApp *app)
|
||||
app->results_saved = 1;
|
||||
}
|
||||
}
|
||||
#ifdef __ANDROID__
|
||||
if (app->inbe.play_in_background) {
|
||||
android_wakelock_release();
|
||||
android_timer_stop();
|
||||
}
|
||||
#endif
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
inbe_app_init(app);
|
||||
} else if(modal_result == 3) {
|
||||
/* Discard - exit without saving */
|
||||
#ifdef __ANDROID__
|
||||
if (app->inbe.play_in_background) {
|
||||
android_wakelock_release();
|
||||
android_timer_stop();
|
||||
}
|
||||
#endif
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
inbe_app_init(app);
|
||||
}
|
||||
} else {
|
||||
/* 2-button modal: Cancel, Exit */
|
||||
modal_result = ui_draw_modal(app, "Exit Session?",
|
||||
"All progress will be lost.",
|
||||
"Cancel", "Exit");
|
||||
modal_result = ui_draw_modal(app,
|
||||
locale_get("exit_session_title"),
|
||||
locale_get("all_progress_lost_message"),
|
||||
locale_get("cancel_button"),
|
||||
locale_get("exit_button"));
|
||||
if(modal_result == 1) {
|
||||
/* Cancel - close modal and continue session */
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
} else if(modal_result == 2) {
|
||||
/* Exit - no data to save, just exit */
|
||||
#ifdef __ANDROID__
|
||||
if (app->inbe.play_in_background) {
|
||||
android_wakelock_release();
|
||||
android_timer_stop();
|
||||
}
|
||||
#endif
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
inbe_app_init(app);
|
||||
@@ -1161,31 +1389,45 @@ updateapp(InbeApp *app)
|
||||
int back_x = pause_x - control_btn_w - control_gap;
|
||||
int forward_x = pause_x + control_btn_w + control_gap;
|
||||
|
||||
if(app->backward_icon.id != 0 && ui_draw_icon_btn_padded(app, back_x, control_y, control_size,
|
||||
app->backward_icon, &back_hover)) {
|
||||
if(ui_draw_icon_btn_padded(app, back_x, control_y, control_size,
|
||||
app->backward_icon, UI_ICON_TYPE_BACKWARD, &back_hover)) {
|
||||
session_step_back(app);
|
||||
}
|
||||
if(ui_draw_icon_btn_padded(app, pause_x, control_y, control_size,
|
||||
app->session_paused ? app->play_icon : app->pause_icon, &pause_hover)) {
|
||||
app->session_paused ? app->play_icon : app->pause_icon, app->session_paused ? UI_ICON_TYPE_PLAY : UI_ICON_TYPE_PAUSE, &pause_hover)) {
|
||||
app->session_paused = !app->session_paused;
|
||||
}
|
||||
if(app->forward_icon.id != 0 && ui_draw_icon_btn_padded(app, forward_x, control_y, control_size,
|
||||
app->forward_icon, &forward_hover)) {
|
||||
if(ui_draw_icon_btn_padded(app, forward_x, control_y, control_size,
|
||||
app->forward_icon, UI_ICON_TYPE_FORWARD, &forward_hover)) {
|
||||
session_step_forward(app);
|
||||
}
|
||||
|
||||
draw_session_status(app, center_x, center_y);
|
||||
|
||||
if(!app->session_paused)
|
||||
if(!app->session_paused) {
|
||||
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
|
||||
pthread_mutex_t *timer_mutex = android_timer_get_mutex();
|
||||
if (timer_mutex) {
|
||||
pthread_mutex_lock(timer_mutex);
|
||||
inbestep(&app->inbe);
|
||||
update_session_sounds(app);
|
||||
pthread_mutex_unlock(timer_mutex);
|
||||
} else {
|
||||
inbestep(&app->inbe);
|
||||
update_session_sounds(app);
|
||||
}
|
||||
#else
|
||||
inbestep(&app->inbe);
|
||||
update_session_sounds(app);
|
||||
update_session_sounds(app);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (app->inbe.phase == InbePhaseHold) {
|
||||
int breath_y = center_y + (int)(app->inbe.rmax * dpi_scale + 0.5f) + ui_px(24);
|
||||
int breath_y = center_y + (int)(app->inbe.rmax * dpi_ui_scale() + 0.5f) + ui_px(24);
|
||||
int breath_max_y = control_y - ui_px(44);
|
||||
if(breath_y > breath_max_y)
|
||||
breath_y = breath_max_y;
|
||||
if (ui_draw_text_btn(app, center_x, breath_y, "BREATH", &hover)) {
|
||||
if (ui_draw_text_btn(app, center_x, breath_y, locale_get("breath_button"), &hover)) {
|
||||
finish_hold(app);
|
||||
}
|
||||
}
|
||||
@@ -1197,15 +1439,25 @@ updateapp(InbeApp *app)
|
||||
int box_x;
|
||||
int box_y = ui_px(78);
|
||||
int box_w;
|
||||
int row_y = ui_px(180);
|
||||
int row_h = ui_clamp_px(26, 22, 30);
|
||||
int row_y = ui_px(200);
|
||||
int row_h = ui_clamp_px(32, 28, 36);
|
||||
int total = 0;
|
||||
int best = -1;
|
||||
int rounds = app->inbe.round + 1;
|
||||
int discard_hover = 0;
|
||||
int save_hover = 0;
|
||||
int action_y = view_height - ui_px(40);
|
||||
|
||||
ui_centered_column(CONTENT_MAX_W, CONTENT_SIDE_PAD, &box_x, &box_w);
|
||||
title_w = MeasureText("RESULTS", title_font);
|
||||
DrawText("RESULTS", center_x - title_w / 2, ui_px(34), title_font, c_text);
|
||||
/* Responsive width like other tabs - not fixed CONTENT_MAX_W */
|
||||
int responsive_max_w = (int)(view_width * 0.90f); /* 90% of screen width */
|
||||
int min_content_w = ui_px(320);
|
||||
if(responsive_max_w < min_content_w)
|
||||
responsive_max_w = min_content_w;
|
||||
int side_padding = ui_px(32); /* More spacious than CONTENT_SIDE_PAD=16 */
|
||||
|
||||
ui_centered_column(responsive_max_w, side_padding, &box_x, &box_w);
|
||||
title_w = MeasureText(locale_get("results_title"), title_font);
|
||||
DrawText(locale_get("results_title"), center_x - title_w / 2, ui_px(34), title_font, c_text);
|
||||
|
||||
if(rounds < 1)
|
||||
rounds = 1;
|
||||
@@ -1222,27 +1474,40 @@ updateapp(InbeApp *app)
|
||||
if(best < 0)
|
||||
best = 0;
|
||||
|
||||
DrawRectangle(box_x, box_y, box_w, ui_px(78), ui_darken(c_bg, 6));
|
||||
DrawLine(box_x, box_y + ui_px(26), box_x + box_w, box_y + ui_px(26), ui_darken(c_bg, 30));
|
||||
DrawLine(box_x, box_y + ui_px(52), box_x + box_w, box_y + ui_px(52), ui_darken(c_bg, 30));
|
||||
DrawText(TextFormat("%d rounds", rounds), box_x + ui_px(10), box_y + ui_px(8), ui_clamp_px(ICON_SIZE_SMALL, ICON_SIZE_SMALL_MIN, ICON_SIZE_SMALL_MAX), c_text);
|
||||
DrawText(TextFormat("best %ds", best), box_x + ui_px(10), box_y + ui_px(34), ui_clamp_px(ICON_SIZE_SMALL, ICON_SIZE_SMALL_MIN, ICON_SIZE_SMALL_MAX), c_text);
|
||||
DrawText(TextFormat("avg %ds", rounds > 0 ? total / rounds : 0), box_x + ui_px(10), box_y + ui_px(60), ui_clamp_px(ICON_SIZE_SMALL, ICON_SIZE_SMALL_MIN, ICON_SIZE_SMALL_MAX), c_text);
|
||||
DrawRectangle(box_x, box_y, box_w, ui_px(88), ui_darken(c_bg, 6));
|
||||
DrawLine(box_x, box_y + ui_px(29), box_x + box_w, box_y + ui_px(29), ui_darken(c_bg, 30));
|
||||
DrawLine(box_x, box_y + ui_px(58), box_x + box_w, box_y + ui_px(58), ui_darken(c_bg, 30));
|
||||
{
|
||||
char line[64];
|
||||
locale_format(line, sizeof(line), "results_rounds", rounds);
|
||||
DrawText(line, box_x + ui_px(10), box_y + ui_px(10), ui_clamp_px(ICON_SIZE_SMALL, ICON_SIZE_SMALL_MIN, ICON_SIZE_SMALL_MAX), c_text);
|
||||
locale_format(line, sizeof(line), "results_best", best);
|
||||
DrawText(line, box_x + ui_px(10), box_y + ui_px(39), ui_clamp_px(ICON_SIZE_SMALL, ICON_SIZE_SMALL_MIN, ICON_SIZE_SMALL_MAX), c_text);
|
||||
locale_format(line, sizeof(line), "results_avg", rounds > 0 ? total / rounds : 0);
|
||||
DrawText(line, box_x + ui_px(10), box_y + ui_px(68), ui_clamp_px(ICON_SIZE_SMALL, ICON_SIZE_SMALL_MIN, ICON_SIZE_SMALL_MAX), c_text);
|
||||
}
|
||||
|
||||
DrawText("Round times", box_x, ui_px(168), ui_clamp_px(14, 12, 16), ui_darken(c_text, 20));
|
||||
DrawText(locale_get("round_times_title"), box_x, ui_px(188), ui_clamp_px(14, 12, 16), ui_darken(c_text, 20));
|
||||
for(int i = 0; i < rounds; i++) {
|
||||
char row[48];
|
||||
int seconds = int_from_count(app->inbe.results[i]);
|
||||
snprintf(row, sizeof(row), "Round %d %ds", i + 1, seconds);
|
||||
locale_format(row, sizeof(row), "round_result_label", i + 1, seconds);
|
||||
DrawRectangle(box_x, row_y - 1, box_w, row_h, ui_darken(c_bg, 4));
|
||||
DrawLine(box_x, row_y + row_h - 2, box_x + box_w, row_y + row_h - 2, ui_darken(c_bg, 26));
|
||||
DrawText(row, box_x + ui_px(10), row_y + ui_px(5), ui_clamp_px(14, 12, 16), c_text);
|
||||
row_y += row_h;
|
||||
}
|
||||
|
||||
if (ui_draw_text_btn(app, center_x, view_height - ui_px(40), "HOME", &hover)) {
|
||||
if (ui_draw_text_btn(app, center_x - box_w / 4, action_y, locale_get("discard_button"), &discard_hover)) {
|
||||
discard_saved_results(app);
|
||||
inbe_app_init(app);
|
||||
}
|
||||
if (ui_draw_text_btn(app, center_x + box_w / 4, action_y, locale_get("save_results_button"), &save_hover)) {
|
||||
if(ensure_results_saved(app))
|
||||
inbe_app_init(app);
|
||||
}
|
||||
if(discard_hover || save_hover)
|
||||
hover = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1260,12 +1525,10 @@ inbe_app_update_draw(void *vapp, Rectangle viewport) {
|
||||
view_width = (int)viewport.width;
|
||||
view_height = (int)viewport.height;
|
||||
|
||||
/* Calculate DPI scale based on viewport height vs base design (560) */
|
||||
dpi_scale = (float)view_height / (float)INBE_DEFAULT_HEIGHT;
|
||||
if(dpi_scale < 1.0f)
|
||||
dpi_scale = 1.0f;
|
||||
/* Update DPI cache */
|
||||
dpi_update(view_width, view_height);
|
||||
|
||||
ui_init(view_width, view_height, dpi_scale);
|
||||
ui_init(view_width, view_height, dpi_ui_scale());
|
||||
|
||||
app->cursor_clickable = 0;
|
||||
app->camera.zoom = 1.0f;
|
||||
@@ -1284,6 +1547,7 @@ inbe_app_update_draw(void *vapp, Rectangle viewport) {
|
||||
static void *
|
||||
inbe_app_create(void)
|
||||
{
|
||||
dpi_init();
|
||||
InbeApp *app = calloc(1, sizeof(InbeApp));
|
||||
inbe_app_init(app);
|
||||
return app;
|
||||
@@ -1324,7 +1588,14 @@ inbe_app_destroy(void *vapp)
|
||||
SafeUnloadTexture(app->angel_image);
|
||||
SafeUnloadTexture(app->begin_image);
|
||||
|
||||
// Unload Sounds
|
||||
/* Cleanup tutorial text layouts */
|
||||
if(app->tutorial_layouts_initialized) {
|
||||
for(int i = 0; i < 5; i++) {
|
||||
ui_text_layout_free(app->tutorial_layouts[i]);
|
||||
free(app->tutorial_layouts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SafeUnloadSound(app->breath_in_sound);
|
||||
SafeUnloadSound(app->breath_out_sound);
|
||||
SafeUnloadSound(app->bell_sound);
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include "raylib.h"
|
||||
#include "../libinbe/inbe.h"
|
||||
|
||||
/* ================================================================
|
||||
* SETTINGS CONSTANTS
|
||||
* ================================================================ */
|
||||
typedef struct TextLayout TextLayout;
|
||||
|
||||
|
||||
|
||||
enum {
|
||||
SETTINGS_SPEED_MIN = 1,
|
||||
@@ -22,17 +22,14 @@ enum {
|
||||
SETTINGS_CONTENT_H = 400,
|
||||
CONTENT_MAX_W = 440,
|
||||
CONTENT_SIDE_PAD = 16,
|
||||
CIRCLE_SIDE_PAD = 24,
|
||||
TUTORIAL_STEPS = 5,
|
||||
CIRCLE_SIDE_PAD = 32,
|
||||
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,
|
||||
@@ -45,15 +42,12 @@ enum {
|
||||
SETTINGS_TAB_BREATHING = 0,
|
||||
SETTINGS_TAB_SESSION,
|
||||
SETTINGS_TAB_APPEARANCE,
|
||||
SETTINGS_TAB_LANGUAGE,
|
||||
SETTINGS_TAB_DATA,
|
||||
SETTINGS_TAB_ABOUT,
|
||||
SETTINGS_TAB_COUNT
|
||||
};
|
||||
|
||||
/* ================================================================
|
||||
* MODAL DIALOG TYPES
|
||||
* ================================================================ */
|
||||
|
||||
typedef enum {
|
||||
UIModalNone,
|
||||
UIModalConfirmExitSession,
|
||||
@@ -63,9 +57,19 @@ typedef enum {
|
||||
typedef struct {
|
||||
int active;
|
||||
UIModalType type;
|
||||
int selected_button; /* 0 = cancel/left, 1 = confirm/right */
|
||||
int selected_button;
|
||||
} UIModal;
|
||||
|
||||
typedef struct InbeConfig {
|
||||
char title[64];
|
||||
int width;
|
||||
int height;
|
||||
int loaded;
|
||||
int title_custom;
|
||||
} InbeConfig;
|
||||
|
||||
extern InbeConfig config;
|
||||
|
||||
typedef struct LotusAppApi {
|
||||
const char *id;
|
||||
void *(*create)(void);
|
||||
@@ -111,17 +115,24 @@ struct InbeApp {
|
||||
int settings_scroll;
|
||||
int settings_drag_slider;
|
||||
int settings_drag_scrollbar;
|
||||
int settings_drag_content; /* Drag content area to scroll */
|
||||
int settings_drag_content_y; /* Initial Y position when drag starts */
|
||||
int settings_drag_content;
|
||||
int settings_drag_content_y;
|
||||
int settings_dirty;
|
||||
int settings_tab;
|
||||
int fullscreen_enabled; /* Fullscreen mode */
|
||||
int fullscreen_enabled;
|
||||
char language[16];
|
||||
int language_selected;
|
||||
int language_index;
|
||||
int manual_scroll;
|
||||
int manual_drag_scrollbar;
|
||||
int manual_drag_content;
|
||||
int manual_drag_content_y;
|
||||
int tutorial_step;
|
||||
int tutorial_seen;
|
||||
|
||||
TextLayout *tutorial_layouts[5];
|
||||
int tutorial_layouts_initialized;
|
||||
|
||||
int theme_id;
|
||||
int dark_mode;
|
||||
int history_scroll;
|
||||
@@ -135,18 +146,16 @@ struct InbeApp {
|
||||
char history_record[16];
|
||||
int session_paused;
|
||||
int results_saved;
|
||||
char results_path[FS_PATH_MAX];
|
||||
int saved_pause_seconds;
|
||||
UIModal modal;
|
||||
};
|
||||
|
||||
void inbe_app_init(void *app);
|
||||
void inbe_app_update_draw(void *app, Rectangle viewport);
|
||||
const char *inbe_app_title(void);
|
||||
int inbe_app_width(void);
|
||||
int inbe_app_height(void);
|
||||
void update_session_sounds(InbeApp *app);
|
||||
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);
|
||||
@@ -155,6 +164,8 @@ 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 refresh_locale_dependent_text(InbeApp *app);
|
||||
void apply_language_selection(InbeApp *app, int language_index, int save_now);
|
||||
void draw_preview_inbe(Inbe *inbe, int center_x, int center_y);
|
||||
|
||||
#endif
|
||||
+284
-344
@@ -1,5 +1,6 @@
|
||||
#include "data.h"
|
||||
#include "miniz.h"
|
||||
#include "locale.h"
|
||||
#include "version.h"
|
||||
|
||||
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
|
||||
@@ -16,7 +17,6 @@
|
||||
|
||||
#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"
|
||||
|
||||
@@ -24,19 +24,9 @@
|
||||
#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])
|
||||
{
|
||||
@@ -46,8 +36,6 @@ int_from_count(const char src[4])
|
||||
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)
|
||||
{
|
||||
@@ -56,56 +44,65 @@ ensure_dir(const char *path)
|
||||
|
||||
TraceLog(LOG_INFO, "DATA: ensure_dir: %s", path);
|
||||
|
||||
if(DirectoryExists(path))
|
||||
if(DirectoryExists(path)) {
|
||||
TraceLog(LOG_INFO, "DATA: Directory already exists: %s", 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;
|
||||
|
||||
if(DirectoryExists(path)) {
|
||||
TraceLog(LOG_WARNING, "DATA: MakeDirectory failed but directory exists: %s", 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 */
|
||||
if(p[0] == '/') p++;
|
||||
|
||||
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;
|
||||
if(!DirectoryExists(temp)) {
|
||||
TraceLog(LOG_ERROR, "DATA: Failed to create directory: %s", temp);
|
||||
*p = '/';
|
||||
return 0;
|
||||
} else {
|
||||
TraceLog(LOG_WARNING, "DATA: Directory already exists: %s", temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
*p = '/';
|
||||
p++;
|
||||
}
|
||||
|
||||
/* Now create the final directory */
|
||||
TraceLog(LOG_INFO, "DATA: Creating final directory: %s", path);
|
||||
if(MakeDirectory(path))
|
||||
return 1;
|
||||
|
||||
if(DirectoryExists(path)) {
|
||||
TraceLog(LOG_WARNING, "DATA: MakeDirectory failed but directory exists: %s", 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)
|
||||
{
|
||||
@@ -114,19 +111,15 @@ is_session_file(const char *path)
|
||||
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 {
|
||||
@@ -147,11 +140,6 @@ get_file_size(const char *path)
|
||||
#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)
|
||||
{
|
||||
@@ -162,7 +150,6 @@ read_session_file(const char *path, int *round_times, int max_rounds)
|
||||
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) {
|
||||
@@ -172,7 +159,6 @@ read_session_file(const char *path, int *round_times, int max_rounds)
|
||||
next_line++;
|
||||
}
|
||||
|
||||
/* Skip empty lines */
|
||||
while(*line == ' ' || *line == '\t')
|
||||
line++;
|
||||
|
||||
@@ -190,8 +176,6 @@ read_session_file(const char *path, int *round_times, int max_rounds)
|
||||
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)
|
||||
{
|
||||
@@ -213,14 +197,106 @@ analyze_session_file(const char *path, int *best)
|
||||
return round_count;
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
* PUBLIC API
|
||||
* ================================================================ */
|
||||
typedef int (*SessionFileCallbackEx)(const char *path, int year, int month, int day, void *user_data);
|
||||
typedef int (*SessionFileCallback)(const char *path, void *user_data);
|
||||
|
||||
static int
|
||||
iterate_session_dates(SessionFileCallback callback, void *user_data)
|
||||
{
|
||||
int year, month, day;
|
||||
FilePathList files;
|
||||
|
||||
if(callback == NULL)
|
||||
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])) {
|
||||
if(!callback(files.paths[i], user_data)) {
|
||||
UnloadDirectoryFiles(files);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
UnloadDirectoryFiles(files);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
iterate_session_dates_ex(SessionFileCallbackEx callback, void *user_data)
|
||||
{
|
||||
int year, month, day;
|
||||
FilePathList files;
|
||||
|
||||
if(callback == NULL)
|
||||
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])) {
|
||||
if(!callback(files.paths[i], year, month, day, user_data)) {
|
||||
UnloadDirectoryFiles(files);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
UnloadDirectoryFiles(files);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
data_init(void)
|
||||
{
|
||||
/* Initialize on first call to data_root() */
|
||||
(void)data_root();
|
||||
}
|
||||
|
||||
@@ -239,7 +315,6 @@ data_root(void)
|
||||
} 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");
|
||||
@@ -253,7 +328,6 @@ data_root(void)
|
||||
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);
|
||||
@@ -284,7 +358,7 @@ data_today_dir(void)
|
||||
}
|
||||
|
||||
int
|
||||
data_save_session(const int *round_times, int round_count)
|
||||
data_save_session_path(const int *round_times, int round_count, char *out_path, size_t out_path_size)
|
||||
{
|
||||
time_t now;
|
||||
struct tm *tm;
|
||||
@@ -303,7 +377,6 @@ data_save_session(const int *round_times, int round_count)
|
||||
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))
|
||||
@@ -317,11 +390,9 @@ data_save_session(const int *round_times, int round_count)
|
||||
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;
|
||||
@@ -332,6 +403,8 @@ data_save_session(const int *round_times, int round_count)
|
||||
TraceLog(LOG_INFO, "DATA: saving session to %s", path);
|
||||
if(SaveFileText(path, text)) {
|
||||
TraceLog(LOG_INFO, "DATA: saved session to %s", path);
|
||||
if(out_path != NULL && out_path_size > 0)
|
||||
snprintf(out_path, out_path_size, "%s", path);
|
||||
#if defined(PLATFORM_WEB)
|
||||
EM_ASM({
|
||||
try {
|
||||
@@ -348,200 +421,115 @@ data_save_session(const int *round_times, int round_count)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
data_save_session(const int *round_times, int round_count)
|
||||
{
|
||||
return data_save_session_path(round_times, round_count, NULL, 0);
|
||||
}
|
||||
|
||||
int
|
||||
data_delete_session(const char *path)
|
||||
{
|
||||
if(path == NULL || path[0] == '\0')
|
||||
return 0;
|
||||
|
||||
if(!FileExists(path))
|
||||
return 1;
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
EM_ASM({
|
||||
try {
|
||||
FS.unlink(UTF8ToString($0));
|
||||
FS.syncfs(false, function(err) {
|
||||
if(err) console.error("syncfs error:", err);
|
||||
});
|
||||
} catch(e) {}
|
||||
}, path);
|
||||
#else
|
||||
if(remove(path) != 0)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
TraceLog(LOG_INFO, "DATA: deleted session %s", path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
has_any_callback(const char *path, void *user_data)
|
||||
{
|
||||
(void)path;
|
||||
int *found = user_data;
|
||||
*found = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
data_has_any(void)
|
||||
{
|
||||
int year, month, day;
|
||||
FilePathList files;
|
||||
int has_data = 0;
|
||||
int found = 0;
|
||||
iterate_session_dates(has_any_callback, &found);
|
||||
return found;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
static int
|
||||
total_size_callback(const char *path, void *user_data)
|
||||
{
|
||||
long long *total = user_data;
|
||||
long long size = get_file_size(path);
|
||||
if(size > 0)
|
||||
*total += size;
|
||||
return 1;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iterate_session_dates(total_size_callback, &total);
|
||||
return total;
|
||||
}
|
||||
|
||||
static int
|
||||
count_callback(const char *path, void *user_data)
|
||||
{
|
||||
(void)path;
|
||||
int *count = user_data;
|
||||
(*count)++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iterate_session_dates(count_callback, &count);
|
||||
return count;
|
||||
}
|
||||
|
||||
static int
|
||||
delete_callback(const char *path, void *user_data)
|
||||
{
|
||||
long long *deleted = user_data;
|
||||
if(FileExists(path)) {
|
||||
#if defined(PLATFORM_WEB)
|
||||
EM_ASM({
|
||||
try {
|
||||
FS.unlink(UTF8ToString($0));
|
||||
} catch(e) {}
|
||||
}, path);
|
||||
#else
|
||||
remove(path);
|
||||
#endif
|
||||
(*deleted)++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
iterate_session_dates(delete_callback, &deleted);
|
||||
|
||||
if(deleted > 0)
|
||||
TraceLog(LOG_INFO, "DATA: deleted %lld session files", deleted);
|
||||
@@ -549,11 +537,37 @@ data_delete_all(void)
|
||||
return deleted;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
mz_zip_archive *archive;
|
||||
} ExportContext;
|
||||
|
||||
static int
|
||||
export_callback_ex(const char *path, int year, int month, int day, void *user_data)
|
||||
{
|
||||
ExportContext *ctx = user_data;
|
||||
char zip_path[FS_PATH_MAX];
|
||||
const char *filename = GetFileName(path);
|
||||
|
||||
snprintf(zip_path, sizeof(zip_path),
|
||||
"lotus-data/sessions/%04d/%02d/%02d/%s",
|
||||
year, month, day, filename);
|
||||
|
||||
char *content = LoadFileText(path);
|
||||
if(content != NULL) {
|
||||
size_t size = strlen(content);
|
||||
if(!mz_zip_writer_add_mem(ctx->archive, zip_path, content, size, MZ_NO_COMPRESSION)) {
|
||||
TraceLog(LOG_WARNING, "DATA: failed to add file: %s", path);
|
||||
}
|
||||
UnloadFileText(content);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
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
|
||||
@@ -561,26 +575,23 @@ data_export(const char *path)
|
||||
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];
|
||||
ExportContext export_ctx;
|
||||
|
||||
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");
|
||||
@@ -589,7 +600,6 @@ data_export(const char *path)
|
||||
|
||||
session_count = data_get_session_count();
|
||||
|
||||
/* Create metadata file */
|
||||
now = time(NULL);
|
||||
tm = localtime(&now);
|
||||
if(tm != NULL) {
|
||||
@@ -600,14 +610,22 @@ data_export(const char *path)
|
||||
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);
|
||||
{
|
||||
char metadata_header[128];
|
||||
char metadata_version[128];
|
||||
char metadata_date[128];
|
||||
char metadata_count[128];
|
||||
|
||||
locale_format(metadata_header, sizeof(metadata_header), "export_metadata_header");
|
||||
locale_format(metadata_version, sizeof(metadata_version), "export_metadata_version", INBE_VERSION_STRING);
|
||||
locale_format(metadata_date, sizeof(metadata_date), "export_metadata_date", date_str);
|
||||
locale_format(metadata_count, sizeof(metadata_count), "export_metadata_count", session_count);
|
||||
snprintf(metadata, sizeof(metadata), "%s\n%s\n%s\n%s\n",
|
||||
metadata_header,
|
||||
metadata_version,
|
||||
metadata_date,
|
||||
metadata_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");
|
||||
@@ -615,57 +633,9 @@ data_export(const char *path)
|
||||
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);
|
||||
export_ctx.archive = &archive;
|
||||
iterate_session_dates_ex(export_callback_ex, &export_ctx);
|
||||
|
||||
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);
|
||||
@@ -678,7 +648,6 @@ data_export(const char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Write to file */
|
||||
fp = fopen(path, "wb");
|
||||
if(fp == NULL) {
|
||||
TraceLog(LOG_ERROR, "DATA: failed to open export file: %s", path);
|
||||
@@ -704,75 +673,46 @@ data_export(const char *path)
|
||||
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;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
data_session_callback user_callback;
|
||||
void *user_data;
|
||||
} ListSessionContext;
|
||||
|
||||
static int
|
||||
list_sessions_callback_ex(const char *path, int year, int month, int day, void *user_data)
|
||||
{
|
||||
ListSessionContext *ctx = user_data;
|
||||
char time_str[16] = "00:00:00";
|
||||
int best = 0;
|
||||
int rounds;
|
||||
char date_str[16];
|
||||
|
||||
snprintf(date_str, sizeof(date_str), "%04d-%02d-%02d", year, month, day);
|
||||
|
||||
const char *filename = GetFileName(path);
|
||||
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]);
|
||||
}
|
||||
|
||||
rounds = analyze_session_file(path, &best);
|
||||
ctx->user_callback(date_str, time_str, rounds, best, ctx->user_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
ListSessionContext ctx = {callback, user};
|
||||
if(callback != NULL)
|
||||
iterate_session_dates_ex(list_sessions_callback_ex, &ctx);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -8,6 +8,8 @@ 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_save_session_path(const int *round_times, int round_count, char *out_path, size_t out_path_size);
|
||||
int data_delete_session(const char *path);
|
||||
int data_has_any(void);
|
||||
long long data_get_total_size(void);
|
||||
int data_get_session_count(void);
|
||||
|
||||
+654
@@ -0,0 +1,654 @@
|
||||
#include "locale.h"
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct LocaleEntry {
|
||||
char *key;
|
||||
char *value;
|
||||
} LocaleEntry;
|
||||
|
||||
typedef struct LocaleLanguage {
|
||||
char *code;
|
||||
char *label;
|
||||
} LocaleLanguage;
|
||||
|
||||
static LocaleEntry *g_base_entries = NULL;
|
||||
static size_t g_base_count = 0;
|
||||
static size_t g_base_cap = 0;
|
||||
|
||||
static LocaleEntry *g_active_entries = NULL;
|
||||
static size_t g_active_count = 0;
|
||||
static size_t g_active_cap = 0;
|
||||
|
||||
static LocaleLanguage *g_languages = NULL;
|
||||
static size_t g_language_count = 0;
|
||||
static size_t g_language_cap = 0;
|
||||
|
||||
static int g_loaded = 0;
|
||||
static char g_current_code[32] = "en";
|
||||
|
||||
static char *
|
||||
dup_range(const char *src, size_t len)
|
||||
{
|
||||
char *out = malloc(len + 1);
|
||||
if(out == NULL)
|
||||
return NULL;
|
||||
memcpy(out, src, len);
|
||||
out[len] = '\0';
|
||||
return out;
|
||||
}
|
||||
|
||||
static char *
|
||||
dup_cstr(const char *src)
|
||||
{
|
||||
return dup_range(src, strlen(src));
|
||||
}
|
||||
|
||||
static void
|
||||
free_locale_entries(LocaleEntry **entries, size_t *count, size_t *cap)
|
||||
{
|
||||
if(entries == NULL || *entries == NULL)
|
||||
return;
|
||||
|
||||
for(size_t i = 0; i < *count; i++) {
|
||||
free((*entries)[i].key);
|
||||
free((*entries)[i].value);
|
||||
}
|
||||
free(*entries);
|
||||
*entries = NULL;
|
||||
*count = 0;
|
||||
*cap = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
free_languages(void)
|
||||
{
|
||||
if(g_languages == NULL)
|
||||
return;
|
||||
|
||||
for(size_t i = 0; i < g_language_count; i++) {
|
||||
free(g_languages[i].code);
|
||||
free(g_languages[i].label);
|
||||
}
|
||||
free(g_languages);
|
||||
g_languages = NULL;
|
||||
g_language_count = 0;
|
||||
g_language_cap = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_locale_capacity(LocaleEntry **entries, size_t *cap, size_t count)
|
||||
{
|
||||
LocaleEntry *next;
|
||||
size_t next_cap;
|
||||
|
||||
if(count < *cap)
|
||||
return;
|
||||
|
||||
next_cap = (*cap == 0) ? 32 : *cap * 2;
|
||||
next = realloc(*entries, next_cap * sizeof(*next));
|
||||
if(next == NULL)
|
||||
return;
|
||||
|
||||
*entries = next;
|
||||
*cap = next_cap;
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_language_capacity(void)
|
||||
{
|
||||
LocaleLanguage *next;
|
||||
size_t next_cap;
|
||||
|
||||
if(g_language_count < g_language_cap)
|
||||
return;
|
||||
|
||||
next_cap = (g_language_cap == 0) ? 8 : g_language_cap * 2;
|
||||
next = realloc(g_languages, next_cap * sizeof(*next));
|
||||
if(next == NULL)
|
||||
return;
|
||||
|
||||
g_languages = next;
|
||||
g_language_cap = next_cap;
|
||||
}
|
||||
|
||||
static void
|
||||
set_locale_entry(LocaleEntry **entries, size_t *count, size_t *cap, const char *key, const char *value)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if(entries == NULL || count == NULL || cap == NULL || key == NULL || value == NULL)
|
||||
return;
|
||||
|
||||
for(i = 0; i < *count; i++) {
|
||||
if(strcmp((*entries)[i].key, key) == 0) {
|
||||
char *new_value = dup_cstr(value);
|
||||
if(new_value == NULL)
|
||||
return;
|
||||
free((*entries)[i].value);
|
||||
(*entries)[i].value = new_value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ensure_locale_capacity(entries, cap, *count);
|
||||
if(*count >= *cap)
|
||||
return;
|
||||
|
||||
(*entries)[*count].key = dup_cstr(key);
|
||||
(*entries)[*count].value = dup_cstr(value);
|
||||
if((*entries)[*count].key == NULL || (*entries)[*count].value == NULL) {
|
||||
free((*entries)[*count].key);
|
||||
free((*entries)[*count].value);
|
||||
(*entries)[*count].key = NULL;
|
||||
(*entries)[*count].value = NULL;
|
||||
return;
|
||||
}
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
static const char *
|
||||
find_locale_entry(LocaleEntry *entries, size_t count, const char *key)
|
||||
{
|
||||
if(key == NULL)
|
||||
return "";
|
||||
|
||||
for(size_t i = 0; i < count; i++) {
|
||||
if(strcmp(entries[i].key, key) == 0)
|
||||
return entries[i].value;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
append_text(char **buf, size_t *len, size_t *cap, const char *text)
|
||||
{
|
||||
size_t text_len;
|
||||
char *next;
|
||||
size_t needed;
|
||||
|
||||
if(text == NULL)
|
||||
return;
|
||||
|
||||
text_len = strlen(text);
|
||||
needed = *len + text_len + 1;
|
||||
if(*cap < needed) {
|
||||
size_t next_cap = (*cap == 0) ? 128 : *cap;
|
||||
while(next_cap < needed)
|
||||
next_cap *= 2;
|
||||
next = realloc(*buf, next_cap);
|
||||
if(next == NULL)
|
||||
return;
|
||||
*buf = next;
|
||||
*cap = next_cap;
|
||||
}
|
||||
|
||||
memcpy(*buf + *len, text, text_len);
|
||||
*len += text_len;
|
||||
(*buf)[*len] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
append_char(char **buf, size_t *len, size_t *cap, char c)
|
||||
{
|
||||
char tmp[2] = { c, '\0' };
|
||||
append_text(buf, len, cap, tmp);
|
||||
}
|
||||
|
||||
static void
|
||||
load_locale_text_into(LocaleEntry **entries, size_t *count, size_t *cap, const char *text)
|
||||
{
|
||||
char *mutable_text;
|
||||
char *cursor;
|
||||
char *current_key = NULL;
|
||||
char *body = NULL;
|
||||
size_t body_len = 0;
|
||||
size_t body_cap = 0;
|
||||
|
||||
if(text == NULL || entries == NULL || count == NULL || cap == NULL)
|
||||
return;
|
||||
|
||||
mutable_text = dup_cstr(text);
|
||||
if(mutable_text == NULL)
|
||||
return;
|
||||
|
||||
cursor = mutable_text;
|
||||
while(cursor != NULL && *cursor != '\0') {
|
||||
char *line = cursor;
|
||||
char *eol = strpbrk(cursor, "\r\n");
|
||||
if(eol != NULL) {
|
||||
char line_end = *eol;
|
||||
*eol = '\0';
|
||||
cursor = eol + 1;
|
||||
if((line_end == '\r' && *cursor == '\n') || (line_end == '\n' && *cursor == '\r'))
|
||||
cursor++;
|
||||
} else {
|
||||
cursor = NULL;
|
||||
}
|
||||
|
||||
if(line[0] == '[') {
|
||||
size_t line_len = strlen(line);
|
||||
if(line_len > 2 && line[line_len - 1] == ']') {
|
||||
char *key = dup_range(line + 1, line_len - 2);
|
||||
if(key != NULL) {
|
||||
free(current_key);
|
||||
current_key = key;
|
||||
free(body);
|
||||
body = NULL;
|
||||
body_len = 0;
|
||||
body_cap = 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(strcmp(line, "---") == 0) {
|
||||
if(current_key != NULL) {
|
||||
set_locale_entry(entries, count, cap, current_key, body != NULL ? body : "");
|
||||
free(current_key);
|
||||
current_key = NULL;
|
||||
}
|
||||
free(body);
|
||||
body = NULL;
|
||||
body_len = 0;
|
||||
body_cap = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(current_key == NULL)
|
||||
continue;
|
||||
|
||||
if(body_len > 0)
|
||||
append_char(&body, &body_len, &body_cap, '\n');
|
||||
append_text(&body, &body_len, &body_cap, line);
|
||||
}
|
||||
|
||||
if(current_key != NULL)
|
||||
set_locale_entry(entries, count, cap, current_key, body != NULL ? body : "");
|
||||
|
||||
free(current_key);
|
||||
free(body);
|
||||
free(mutable_text);
|
||||
}
|
||||
|
||||
static void
|
||||
load_language_list_from_text(const char *text)
|
||||
{
|
||||
char *mutable_text;
|
||||
char *cursor;
|
||||
|
||||
if(text == NULL)
|
||||
return;
|
||||
|
||||
mutable_text = dup_cstr(text);
|
||||
if(mutable_text == NULL)
|
||||
return;
|
||||
|
||||
cursor = mutable_text;
|
||||
while(cursor != NULL && *cursor != '\0') {
|
||||
char *line = cursor;
|
||||
char *eol = strpbrk(cursor, "\r\n");
|
||||
if(eol != NULL) {
|
||||
char line_end = *eol;
|
||||
*eol = '\0';
|
||||
cursor = eol + 1;
|
||||
if((line_end == '\r' && *cursor == '\n') || (line_end == '\n' && *cursor == '\r'))
|
||||
cursor++;
|
||||
} else {
|
||||
cursor = NULL;
|
||||
}
|
||||
|
||||
if(line[0] == '\0' || line[0] == '#')
|
||||
continue;
|
||||
|
||||
char *sep = strchr(line, '|');
|
||||
if(sep == NULL)
|
||||
continue;
|
||||
|
||||
*sep = '\0';
|
||||
const char *code = line;
|
||||
const char *label = sep + 1;
|
||||
if(code[0] == '\0' || label[0] == '\0')
|
||||
continue;
|
||||
|
||||
ensure_language_capacity();
|
||||
if(g_language_count >= g_language_cap)
|
||||
continue;
|
||||
|
||||
g_languages[g_language_count].code = dup_cstr(code);
|
||||
g_languages[g_language_count].label = dup_cstr(label);
|
||||
if(g_languages[g_language_count].code == NULL || g_languages[g_language_count].label == NULL) {
|
||||
free(g_languages[g_language_count].code);
|
||||
free(g_languages[g_language_count].label);
|
||||
g_languages[g_language_count].code = NULL;
|
||||
g_languages[g_language_count].label = NULL;
|
||||
continue;
|
||||
}
|
||||
g_language_count++;
|
||||
}
|
||||
|
||||
free(mutable_text);
|
||||
}
|
||||
|
||||
static int
|
||||
load_file_text_from_paths(const char *relative_path, char **out_text)
|
||||
{
|
||||
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
|
||||
char *text;
|
||||
|
||||
if(out_text == NULL)
|
||||
return 0;
|
||||
*out_text = NULL;
|
||||
|
||||
text = LoadFileText(relative_path);
|
||||
if(text != NULL) {
|
||||
*out_text = text;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
static const char *prefixes[] = {
|
||||
"",
|
||||
"../",
|
||||
"../../",
|
||||
"../../../",
|
||||
"../../../../",
|
||||
NULL
|
||||
};
|
||||
|
||||
char path[256];
|
||||
|
||||
if(out_text == NULL)
|
||||
return 0;
|
||||
*out_text = NULL;
|
||||
|
||||
for(int i = 0; prefixes[i] != NULL; i++) {
|
||||
snprintf(path, sizeof(path), "%s%s", prefixes[i], relative_path);
|
||||
if(FileExists(path)) {
|
||||
char *text = LoadFileText(path);
|
||||
if(text != NULL) {
|
||||
*out_text = text;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
load_locale_file_for_code(const char *code, char **out_text)
|
||||
{
|
||||
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
|
||||
char path[64];
|
||||
char *text;
|
||||
|
||||
if(out_text == NULL)
|
||||
return 0;
|
||||
*out_text = NULL;
|
||||
|
||||
if(code == NULL || code[0] == '\0')
|
||||
code = "en";
|
||||
|
||||
snprintf(path, sizeof(path), "locales/%s.txt", code);
|
||||
text = LoadFileText(path);
|
||||
if(text != NULL) {
|
||||
*out_text = text;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
static const char *prefixes[] = {
|
||||
"",
|
||||
"../",
|
||||
"../../",
|
||||
"../../../",
|
||||
"../../../../",
|
||||
NULL
|
||||
};
|
||||
char path[64];
|
||||
|
||||
if(out_text == NULL)
|
||||
return 0;
|
||||
*out_text = NULL;
|
||||
|
||||
if(code == NULL || code[0] == '\0')
|
||||
code = "en";
|
||||
|
||||
for(int i = 0; prefixes[i] != NULL; i++) {
|
||||
snprintf(path, sizeof(path), "%slocales/%s.txt", prefixes[i], code);
|
||||
if(FileExists(path)) {
|
||||
char *text = LoadFileText(path);
|
||||
if(text != NULL) {
|
||||
*out_text = text;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
load_defaults(void)
|
||||
{
|
||||
int has_english = 0;
|
||||
|
||||
for(size_t i = 0; i < g_language_count; i++) {
|
||||
if(g_languages[i].code != NULL && strcmp(g_languages[i].code, "en") == 0) {
|
||||
has_english = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(has_english)
|
||||
return;
|
||||
|
||||
ensure_language_capacity();
|
||||
if(g_language_count < g_language_cap) {
|
||||
g_languages[g_language_count].code = dup_cstr("en");
|
||||
g_languages[g_language_count].label = dup_cstr("English");
|
||||
if(g_languages[g_language_count].code != NULL && g_languages[g_language_count].label != NULL)
|
||||
g_language_count++;
|
||||
else {
|
||||
free(g_languages[g_language_count].code);
|
||||
free(g_languages[g_language_count].label);
|
||||
g_languages[g_language_count].code = NULL;
|
||||
g_languages[g_language_count].label = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_current_code(const char *code)
|
||||
{
|
||||
if(code == NULL || code[0] == '\0')
|
||||
code = "en";
|
||||
snprintf(g_current_code, sizeof(g_current_code), "%s", code);
|
||||
}
|
||||
|
||||
static void
|
||||
load_base_locale(void)
|
||||
{
|
||||
char *text = NULL;
|
||||
if(load_file_text_from_paths("locales/en.txt", &text)) {
|
||||
load_locale_text_into(&g_base_entries, &g_base_count, &g_base_cap, text);
|
||||
UnloadFileText(text);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
load_registry(void)
|
||||
{
|
||||
char *text = NULL;
|
||||
if(load_file_text_from_paths("locales/index.txt", &text)) {
|
||||
load_language_list_from_text(text);
|
||||
UnloadFileText(text);
|
||||
}
|
||||
load_defaults();
|
||||
}
|
||||
|
||||
static void
|
||||
clear_active_locale(void)
|
||||
{
|
||||
free_locale_entries(&g_active_entries, &g_active_count, &g_active_cap);
|
||||
}
|
||||
|
||||
void
|
||||
locale_init(void)
|
||||
{
|
||||
if(g_loaded)
|
||||
return;
|
||||
|
||||
free_locale_entries(&g_base_entries, &g_base_count, &g_base_cap);
|
||||
free_locale_entries(&g_active_entries, &g_active_count, &g_active_cap);
|
||||
free_languages();
|
||||
load_registry();
|
||||
load_base_locale();
|
||||
clear_active_locale();
|
||||
set_current_code("en");
|
||||
g_loaded = 1;
|
||||
}
|
||||
|
||||
int
|
||||
locale_set(const char *code)
|
||||
{
|
||||
char *text = NULL;
|
||||
int found = 0;
|
||||
|
||||
if(!g_loaded)
|
||||
locale_init();
|
||||
|
||||
if(code == NULL || code[0] == '\0')
|
||||
code = "en";
|
||||
|
||||
if(strcmp(code, "en") == 0) {
|
||||
clear_active_locale();
|
||||
set_current_code("en");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < g_language_count; i++) {
|
||||
if(strcmp(g_languages[i].code, code) == 0) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
return 0;
|
||||
|
||||
clear_active_locale();
|
||||
if(load_locale_file_for_code(code, &text)) {
|
||||
load_locale_text_into(&g_active_entries, &g_active_count, &g_active_cap, text);
|
||||
UnloadFileText(text);
|
||||
set_current_code(code);
|
||||
return 1;
|
||||
}
|
||||
|
||||
clear_active_locale();
|
||||
set_current_code("en");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *
|
||||
lookup_locale_value(const char *key)
|
||||
{
|
||||
const char *value;
|
||||
|
||||
value = find_locale_entry(g_active_entries, g_active_count, key);
|
||||
if(value != NULL)
|
||||
return value;
|
||||
|
||||
value = find_locale_entry(g_base_entries, g_base_count, key);
|
||||
if(value != NULL)
|
||||
return value;
|
||||
|
||||
return key != NULL ? key : "";
|
||||
}
|
||||
|
||||
const char *
|
||||
locale_get(const char *key)
|
||||
{
|
||||
if(!g_loaded)
|
||||
locale_init();
|
||||
return lookup_locale_value(key);
|
||||
}
|
||||
|
||||
void
|
||||
locale_format(char *dst, size_t dst_size, const char *key, ...)
|
||||
{
|
||||
const char *fmt;
|
||||
va_list args;
|
||||
|
||||
if(dst == NULL || dst_size == 0)
|
||||
return;
|
||||
|
||||
fmt = locale_get(key);
|
||||
va_start(args, key);
|
||||
vsnprintf(dst, dst_size, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
int
|
||||
locale_count(void)
|
||||
{
|
||||
if(!g_loaded)
|
||||
locale_init();
|
||||
return (int)g_language_count;
|
||||
}
|
||||
|
||||
const char *
|
||||
locale_code_at(int index)
|
||||
{
|
||||
if(!g_loaded)
|
||||
locale_init();
|
||||
if(index < 0 || (size_t)index >= g_language_count)
|
||||
return "";
|
||||
return g_languages[index].code != NULL ? g_languages[index].code : "";
|
||||
}
|
||||
|
||||
const char *
|
||||
locale_label_at(int index)
|
||||
{
|
||||
if(!g_loaded)
|
||||
locale_init();
|
||||
if(index < 0 || (size_t)index >= g_language_count)
|
||||
return "";
|
||||
return g_languages[index].label != NULL ? g_languages[index].label : "";
|
||||
}
|
||||
|
||||
int
|
||||
locale_index_of(const char *code)
|
||||
{
|
||||
if(!g_loaded)
|
||||
locale_init();
|
||||
if(code == NULL)
|
||||
return -1;
|
||||
for(size_t i = 0; i < g_language_count; i++) {
|
||||
if(g_languages[i].code != NULL && strcmp(g_languages[i].code, code) == 0)
|
||||
return (int)i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *
|
||||
locale_current_code(void)
|
||||
{
|
||||
if(!g_loaded)
|
||||
locale_init();
|
||||
return g_current_code;
|
||||
}
|
||||
|
||||
int
|
||||
locale_current_index(void)
|
||||
{
|
||||
return locale_index_of(locale_current_code());
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef INBE_LOCALE_H
|
||||
#define INBE_LOCALE_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void locale_init(void);
|
||||
int locale_set(const char *code);
|
||||
const char *locale_get(const char *key);
|
||||
void locale_format(char *dst, size_t dst_size, const char *key, ...);
|
||||
|
||||
int locale_count(void);
|
||||
const char *locale_code_at(int index);
|
||||
const char *locale_label_at(int index);
|
||||
int locale_index_of(const char *code);
|
||||
const char *locale_current_code(void);
|
||||
int locale_current_index(void);
|
||||
|
||||
#endif
|
||||
+38
-7
@@ -1,8 +1,12 @@
|
||||
#include "raylib.h"
|
||||
#include "app.h"
|
||||
#include "android_insets.h"
|
||||
#include "ui/dpi.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
|
||||
#include "android_insets.h"
|
||||
#include "android_wakelock.h"
|
||||
#include "android_timer.h"
|
||||
#include <android/log.h>
|
||||
#include <android_native_app_glue.h>
|
||||
extern struct android_app *GetAndroidApp(void);
|
||||
@@ -13,6 +17,16 @@ extern struct android_app *GetAndroidApp(void);
|
||||
#endif
|
||||
|
||||
static InbeApp inbe_app;
|
||||
static InbeApp *g_inbe_app_ptr = NULL; // Global pointer for JNI access
|
||||
|
||||
InbeApp* get_global_inbe_app(void) {
|
||||
if (g_inbe_app_ptr == NULL) {
|
||||
TraceLog(LOG_WARNING, "WARNING: get_global_inbe_app called with NULL pointer");
|
||||
}
|
||||
return g_inbe_app_ptr;
|
||||
}
|
||||
|
||||
void set_global_inbe_app(InbeApp *app);
|
||||
|
||||
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
|
||||
#define INBE_ANDROID_BUILD 1
|
||||
@@ -92,27 +106,39 @@ frame(void)
|
||||
int main(int argc, char **argv) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
int window_w = INBE_ANDROID_BUILD ? 0 : inbe_app_width();
|
||||
int window_h = INBE_ANDROID_BUILD ? 0 : inbe_app_height();
|
||||
int window_w = INBE_ANDROID_BUILD ? 0 : config.width;
|
||||
int window_h = INBE_ANDROID_BUILD ? 0 : config.height;
|
||||
|
||||
#if INBE_ANDROID_BUILD
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_MAIN", "=== MAIN START ===");
|
||||
#endif
|
||||
|
||||
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(PLATFORM_WEB)
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||
#endif
|
||||
|
||||
#if INBE_ANDROID_BUILD
|
||||
android_insets_init(); // MUST be first, before app init
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_MAIN", "Calling android_insets_init");
|
||||
android_insets_init();
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_MAIN", "Calling android_wakelock_init");
|
||||
android_wakelock_init();
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_MAIN", "Calling android_timer_init");
|
||||
android_timer_init();
|
||||
__android_log_write(ANDROID_LOG_INFO, "INBE_MAIN", "Init calls done");
|
||||
if(!ChangeDirectory("/data/user/0/xyz.waozi.inbe/files"))
|
||||
TraceLog(LOG_WARNING, "INBE: failed to switch to Android files directory");
|
||||
#endif
|
||||
|
||||
|
||||
InitWindow(window_w, window_h, inbe_app_title());
|
||||
InitWindow(window_w, window_h, config.title);
|
||||
|
||||
dpi_init();
|
||||
inbe_app_init(&inbe_app);
|
||||
set_global_inbe_app(&inbe_app);
|
||||
TraceLog(LOG_INFO, "INBE: Global app pointer set");
|
||||
|
||||
/* Apply fullscreen setting on startup */
|
||||
#if INBE_ANDROID_BUILD
|
||||
inbe_app.fullscreen_enabled = 0; // Force fullscreen off on Android
|
||||
inbe_app.fullscreen_enabled = 0;
|
||||
#endif
|
||||
if(inbe_app.fullscreen_enabled && !IsWindowFullscreen())
|
||||
ToggleFullscreen();
|
||||
@@ -130,3 +156,8 @@ int main(int argc, char **argv) {
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_global_inbe_app(InbeApp *app) {
|
||||
g_inbe_app_ptr = app;
|
||||
TraceLog(LOG_INFO, "INBE: Global app pointer set to %p", app);
|
||||
}
|
||||
+34
-59
@@ -1,7 +1,9 @@
|
||||
#include "history_tab.h"
|
||||
#include "app.h"
|
||||
#include "data.h"
|
||||
#include "ui.h"
|
||||
#include "locale.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/text_layout.h"
|
||||
#include "raylib.h"
|
||||
|
||||
#include <dirent.h>
|
||||
@@ -17,14 +19,6 @@
|
||||
#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;
|
||||
@@ -247,9 +241,9 @@ history_format_round_label(const HistoryEntry *entry, int round_index, char *out
|
||||
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]);
|
||||
locale_format(out, (size_t)out_size, "history_round_label", round_index + 1, entry->rounds[round_index]);
|
||||
else
|
||||
snprintf(out, (size_t)out_size, "R%d", round_index + 1);
|
||||
locale_format(out, (size_t)out_size, "history_round_short_label", round_index + 1);
|
||||
}
|
||||
|
||||
/* Draw a clickable history row */
|
||||
@@ -278,7 +272,7 @@ draw_history_row(InbeApp *app, int x, int y, int w, int h, const char *text, int
|
||||
return hover && IsMouseButtonReleased(MOUSE_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
/* Draw a history session row with trash icon */
|
||||
/* Draw a clickable history session row */
|
||||
static int
|
||||
draw_history_session_row(InbeApp *app, int x, int y, int w, int h, const char *text, int selected)
|
||||
{
|
||||
@@ -286,9 +280,7 @@ draw_history_session_row(InbeApp *app, int x, int y, int w, int h, const char *t
|
||||
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));
|
||||
@@ -305,22 +297,6 @@ draw_history_session_row(InbeApp *app, int x, int y, int w, int h, const char *t
|
||||
|
||||
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;
|
||||
@@ -436,8 +412,7 @@ history_format_session_label(const HistoryEntry *entry, char *out, size_t out_si
|
||||
{
|
||||
if(out == NULL || out_size == 0)
|
||||
return;
|
||||
snprintf(out, out_size, "%02d:%02d avg %ds",
|
||||
entry->hour, entry->minute, entry->avg_seconds);
|
||||
locale_format(out, out_size, "history_session_label", entry->hour, entry->minute, entry->avg_seconds);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -512,19 +487,32 @@ history_tab_draw(InbeApp *app)
|
||||
}
|
||||
}
|
||||
|
||||
content_h = count > 0 ? count * row_h + 18 : viewport_h;
|
||||
/* Calculate content height with proper top and bottom padding */
|
||||
content_h = ui_px(12); /* Top padding */
|
||||
if(count > 0) {
|
||||
content_h += count * row_h;
|
||||
} else {
|
||||
content_h += viewport_h;
|
||||
}
|
||||
if(content_rows > 0)
|
||||
content_h = 18 + content_rows * row_h;
|
||||
content_h = ui_px(12) + content_rows * row_h;
|
||||
content_h += ui_px(12); /* Bottom padding */
|
||||
max_scroll = content_h - viewport_h;
|
||||
if(max_scroll < 0)
|
||||
if(max_scroll < 0 || count == 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);
|
||||
/* Use percentage of screen width like tutorial, not DPI-scaled CONTENT_MAX_W */
|
||||
int responsive_max_w = (int)(view_width * 0.90f); /* 90% of screen width */
|
||||
int min_content_w = ui_px(320);
|
||||
if(responsive_max_w < min_content_w)
|
||||
responsive_max_w = min_content_w;
|
||||
int side_padding = ui_px(32); /* Match tutorial spacing */
|
||||
ui_centered_column(responsive_max_w, side_padding, &content_x, &content_w);
|
||||
|
||||
close_clicked = ui_draw_screen_header(app, "History", 1);
|
||||
close_clicked = ui_draw_screen_header(app, locale_get("history_title"), 1);
|
||||
if(close_clicked) {
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
app->history_scroll = 0;
|
||||
@@ -536,8 +524,12 @@ history_tab_draw(InbeApp *app)
|
||||
(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);
|
||||
int font = ui_clamp_px(14, 12, 16);
|
||||
const char *empty_text = locale_get("history_empty");
|
||||
TextLayout empty_layout = ui_text_layout_parse(empty_text, (Texture2D){0}, UI_ICON_TYPE_NONE, font);
|
||||
ui_text_layout_reflow(&empty_layout, content_w, font, ui_px(22));
|
||||
ui_text_layout_draw(&empty_layout, content_x, &y, font, c_text);
|
||||
ui_text_layout_free(&empty_layout);
|
||||
} else {
|
||||
int year = -1;
|
||||
int month = -1;
|
||||
@@ -568,7 +560,7 @@ history_tab_draw(InbeApp *app)
|
||||
|
||||
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);
|
||||
locale_format(label, sizeof(label), "history_month_label", 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;
|
||||
@@ -586,7 +578,7 @@ history_tab_draw(InbeApp *app)
|
||||
|
||||
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);
|
||||
locale_format(label, sizeof(label), "history_day_label", 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);
|
||||
@@ -617,23 +609,6 @@ history_tab_draw(InbeApp *app)
|
||||
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;
|
||||
|
||||
@@ -641,7 +616,7 @@ history_tab_draw(InbeApp *app)
|
||||
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)) {
|
||||
if(draw_history_row(app, content_x, y, content_w, row_h, round_label, 0, 10)) {
|
||||
/* Round clicked - could do something here */
|
||||
}
|
||||
y += row_h;
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
#include "language_tab.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "locale.h"
|
||||
#include "ui/ui.h"
|
||||
#include "raylib.h"
|
||||
|
||||
extern int view_width;
|
||||
extern int view_height;
|
||||
extern Color c_text, c_bg, c_button;
|
||||
static const char *g_language_options[64];
|
||||
static int g_language_option_count = 0;
|
||||
|
||||
static void
|
||||
build_language_options(const char **options, int max_options, int *count)
|
||||
{
|
||||
int total = locale_count();
|
||||
|
||||
if(total > max_options)
|
||||
total = max_options;
|
||||
if(total < 0)
|
||||
total = 0;
|
||||
|
||||
for(int i = 0; i < total; i++)
|
||||
options[i] = locale_label_at(i);
|
||||
|
||||
*count = total;
|
||||
}
|
||||
|
||||
int
|
||||
language_dropdown_button(InbeApp *app, int id, int x, int y, int w, int h, int *selected_index)
|
||||
{
|
||||
if(app == NULL || selected_index == NULL)
|
||||
return 0;
|
||||
|
||||
build_language_options(g_language_options, 64, &g_language_option_count);
|
||||
if(g_language_option_count <= 0) {
|
||||
DrawRectangle(x, y, w, h, c_button);
|
||||
ui_draw_bevel(x, y, w, h, ui_darken(c_bg, 30), ui_lighten(c_bg, 20));
|
||||
DrawText(locale_get("language_label"), x + ui_px(12), y + h / 2 - ui_clamp_px(14, 12, 16) / 2 - 1,
|
||||
ui_clamp_px(14, 12, 16), c_text);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(*selected_index < 0 || *selected_index >= g_language_option_count)
|
||||
*selected_index = 0;
|
||||
|
||||
return ui_draw_dropdown_button(app, id, x, y, w, h, g_language_options, g_language_option_count, selected_index);
|
||||
}
|
||||
|
||||
int
|
||||
language_dropdown_menu(InbeApp *app, int id)
|
||||
{
|
||||
return ui_draw_dropdown_menu(app, id);
|
||||
}
|
||||
|
||||
void
|
||||
language_tab_draw(InbeApp *app)
|
||||
{
|
||||
int title_font = ui_clamp_px(22, 18, 26);
|
||||
int label_font = ui_clamp_px(14, 12, 16);
|
||||
int title_w;
|
||||
int content_x;
|
||||
int content_w;
|
||||
int dropdown_h = ui_px(36);
|
||||
int dropdown_w;
|
||||
int dropdown_x;
|
||||
int dropdown_y;
|
||||
int button_x;
|
||||
int button_y;
|
||||
int next_hover = 0;
|
||||
int *selected_index = &app->language_index;
|
||||
int language_count = locale_count();
|
||||
int selection_changed = 0;
|
||||
|
||||
if(language_count <= 0)
|
||||
language_count = 1;
|
||||
if(*selected_index < 0 || *selected_index >= language_count)
|
||||
*selected_index = 0;
|
||||
|
||||
ui_centered_column(ui_px(340), ui_px(32), &content_x, &content_w);
|
||||
dropdown_w = content_w;
|
||||
dropdown_x = content_x;
|
||||
dropdown_y = view_height / 2 - dropdown_h / 2;
|
||||
button_x = view_width / 2;
|
||||
button_y = dropdown_y + ui_px(64);
|
||||
|
||||
if(language_dropdown_button(app, 200, dropdown_x, dropdown_y, dropdown_w, dropdown_h, selected_index))
|
||||
selection_changed = 1;
|
||||
|
||||
title_w = MeasureText(locale_get("language_picker_title"), title_font);
|
||||
DrawText(locale_get("language_picker_title"), view_width / 2 - title_w / 2, ui_px(28), title_font, c_text);
|
||||
DrawText(locale_get("language_label"), dropdown_x, dropdown_y - ui_px(24), label_font, c_text);
|
||||
|
||||
if(ui_draw_text_btn(app, button_x, button_y, locale_get("next_button"), &next_hover)) {
|
||||
if(!app->tutorial_seen)
|
||||
app->inbe.screen = InbeScreenManual;
|
||||
else
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
}
|
||||
|
||||
if(language_dropdown_menu(app, 200))
|
||||
selection_changed = 1;
|
||||
|
||||
if(selection_changed)
|
||||
apply_language_selection(app, *selected_index, 1);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef LANGUAGE_TAB_H
|
||||
#define LANGUAGE_TAB_H
|
||||
|
||||
#include "../libinbe/inbe.h"
|
||||
|
||||
typedef struct InbeApp InbeApp;
|
||||
|
||||
void language_tab_draw(InbeApp *app);
|
||||
int language_dropdown_button(InbeApp *app, int id, int x, int y, int w, int h, int *selected_index);
|
||||
int language_dropdown_menu(InbeApp *app, int id);
|
||||
|
||||
#endif
|
||||
+198
-105
@@ -1,18 +1,60 @@
|
||||
#include "manual_tab.h"
|
||||
#include "app.h"
|
||||
#include "ui.h"
|
||||
#include "locale.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/text_layout.h"
|
||||
#include "theme_meta.h"
|
||||
#include "raylib.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define CONTENT_MAX_W 600
|
||||
#define CONTENT_SIDE_PAD 20
|
||||
#define CONTENT_MAX_W 800 /* Responsive width for tutorial text reflow */
|
||||
|
||||
extern int view_width;
|
||||
extern int view_height;
|
||||
|
||||
extern Color c_text, c_bg, c_circle, c_button, c_button_hover, c_icon;
|
||||
|
||||
/* Tutorial text content ordered by step */
|
||||
static const char *const TUTORIAL_KEYS[] = {
|
||||
"tutorial_step_intro",
|
||||
"tutorial_step_method",
|
||||
"tutorial_step_breathe",
|
||||
"tutorial_step_exhale_hold",
|
||||
"tutorial_step_inhale_hold"
|
||||
};
|
||||
|
||||
#define TUTORIAL_STEPS_COUNT (sizeof(TUTORIAL_KEYS) / sizeof(TUTORIAL_KEYS[0]))
|
||||
|
||||
static const int TUTORIAL_LINE_SPACING[] = { 28, 24, 24, 28, 28 };
|
||||
|
||||
static void
|
||||
init_tutorial_layouts(InbeApp *app, int body_font)
|
||||
{
|
||||
if(!app->tutorial_layouts_initialized) {
|
||||
for(int i = 0; i < (int)TUTORIAL_STEPS_COUNT; i++) {
|
||||
app->tutorial_layouts[i] = calloc(1, sizeof(TextLayout));
|
||||
*app->tutorial_layouts[i] = ui_text_layout_parse(locale_get(TUTORIAL_KEYS[i]), (Texture2D){0}, UI_ICON_TYPE_NONE, body_font);
|
||||
}
|
||||
app->tutorial_layouts_initialized = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
manual_tab_reset_layouts(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < (int)TUTORIAL_STEPS_COUNT; i++) {
|
||||
if(app->tutorial_layouts[i] != NULL) {
|
||||
ui_text_layout_free(app->tutorial_layouts[i]);
|
||||
free(app->tutorial_layouts[i]);
|
||||
app->tutorial_layouts[i] = NULL;
|
||||
}
|
||||
}
|
||||
app->tutorial_layouts_initialized = 0;
|
||||
}
|
||||
|
||||
void
|
||||
manual_tab_close_tutorial(InbeApp *app, int mark_seen)
|
||||
@@ -32,168 +74,220 @@ 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 body_font = ui_clamp_px(16, 14, 18);
|
||||
int previous_step;
|
||||
int max_scroll;
|
||||
int content_x;
|
||||
int content_w;
|
||||
const char *title = "Tutorial";
|
||||
const char *title = locale_get("tutorial_title");
|
||||
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;
|
||||
int step = app->tutorial_step;
|
||||
|
||||
app->tutorial_step = clampi(app->tutorial_step, 0, TUTORIAL_STEPS - 1);
|
||||
previous_step = app->tutorial_step;
|
||||
step = clampi(step, 0, (int)TUTORIAL_STEPS_COUNT - 1);
|
||||
app->tutorial_step = step;
|
||||
previous_step = step;
|
||||
|
||||
if(IsKeyPressed(KEY_RIGHT) || IsKeyPressed(KEY_ENTER)) {
|
||||
if(app->tutorial_step < TUTORIAL_STEPS - 1)
|
||||
if(step < (int)TUTORIAL_STEPS_COUNT - 1)
|
||||
app->tutorial_step++;
|
||||
else
|
||||
manual_tab_close_tutorial(app, 1);
|
||||
}
|
||||
if(IsKeyPressed(KEY_LEFT) && app->tutorial_step > 0)
|
||||
if(IsKeyPressed(KEY_LEFT) && step > 0)
|
||||
app->tutorial_step--;
|
||||
if(IsKeyPressed(KEY_ESCAPE))
|
||||
manual_tab_close_tutorial(app, 1);
|
||||
|
||||
if(previous_step != app->tutorial_step) {
|
||||
step = app->tutorial_step;
|
||||
if(previous_step != step) {
|
||||
app->manual_scroll = 0;
|
||||
previous_step = app->tutorial_step;
|
||||
previous_step = 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;
|
||||
switch(step) {
|
||||
case 1: title = locale_get("tutorial_method_title"); break;
|
||||
case 2: title = locale_get("tutorial_step1_title"); break;
|
||||
case 3: title = locale_get("tutorial_step2_title"); break;
|
||||
case 4: title = locale_get("tutorial_step3_title"); 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);
|
||||
/* Content width responds to window size - with DPI scaling consideration */
|
||||
/* On high-DPI Android, view_width is already large, so we use a reasonable percentage */
|
||||
int responsive_max_w = (int)(view_width * 0.92f);
|
||||
int max_content_w = ui_px(CONTENT_MAX_W); /* DPI-scaled max width */
|
||||
if(responsive_max_w > max_content_w)
|
||||
responsive_max_w = max_content_w;
|
||||
int min_width = ui_px(280);
|
||||
if(responsive_max_w < min_width)
|
||||
responsive_max_w = min_width;
|
||||
|
||||
ui_centered_column(CONTENT_MAX_W, CONTENT_SIDE_PAD, &content_x, &content_w);
|
||||
int side_padding = ui_px(32); /* Increased from CONTENT_SIDE_PAD=20 for more space */
|
||||
ui_centered_column(responsive_max_w, side_padding, &content_x, &content_w);
|
||||
|
||||
/* Auto-reflow every frame - like HTML, no tracking needed */
|
||||
if(!app->tutorial_layouts_initialized) {
|
||||
init_tutorial_layouts(app, body_font);
|
||||
}
|
||||
|
||||
/* Reflow all layouts for current container width - automatic like CSS */
|
||||
for(int i = 0; i < (int)TUTORIAL_STEPS_COUNT; i++) {
|
||||
ui_text_layout_reflow(app->tutorial_layouts[i], content_w, body_font, ui_px(TUTORIAL_LINE_SPACING[i]));
|
||||
}
|
||||
|
||||
close_clicked = ui_draw_screen_header(app, title, 1);
|
||||
if(close_clicked)
|
||||
manual_tab_close_tutorial(app, 1);
|
||||
|
||||
/* Calculate actual content height based on current step and text layouts */
|
||||
/* Don't include padding in this calculation - it's handled separately */
|
||||
int actual_content_h = 0; /* Content only, no padding */
|
||||
if(step == 0) {
|
||||
actual_content_h += ui_px(200) + ui_px(22) + ui_text_layout_get_height(app->tutorial_layouts[0]);
|
||||
/* Image height must match drawing code which uses ui_px(200), not ui_px(224) */
|
||||
} else if(step == 1) {
|
||||
/* Step 1 uses a fresh gear_layout for drawing - calculate height from it */
|
||||
TextLayout temp_gear = ui_text_layout_parse(locale_get(TUTORIAL_KEYS[1]), app->gear_icon, UI_ICON_TYPE_GEAR, ui_px(14));
|
||||
ui_text_layout_reflow(&temp_gear, content_w, body_font, ui_px(24));
|
||||
actual_content_h += ui_text_layout_get_height(&temp_gear);
|
||||
ui_text_layout_free(&temp_gear);
|
||||
} else if(step == 2) {
|
||||
actual_content_h += ui_text_layout_get_height(app->tutorial_layouts[2]) + ui_px(20);
|
||||
/* Circle preview height - calculate actual rmax based on content_w */
|
||||
/* update_preview_bounds uses min(content_w, 132)/2 clamped to 60-120 for rmax */
|
||||
int preview_span = (content_w < ui_px(132)) ? content_w : ui_px(132);
|
||||
int preview_rmax = preview_span / 2;
|
||||
if(preview_rmax < ui_px(60)) preview_rmax = ui_px(60);
|
||||
if(preview_rmax > ui_px(120)) preview_rmax = ui_px(120);
|
||||
/* Circle is drawn at y+ui_px(40) with radius 0.72*preview_rmax */
|
||||
actual_content_h += ui_px(40) + (int)((float)preview_rmax * 0.72f) + ui_px(14);
|
||||
int slider_h = ui_clamp_px(36, 32, 40);
|
||||
actual_content_h += slider_h + ui_px(8);
|
||||
} else if(step == 3) {
|
||||
actual_content_h += ui_text_layout_get_height(app->tutorial_layouts[3]);
|
||||
} else {
|
||||
actual_content_h += ui_px(234) + ui_px(22) + ui_text_layout_get_height(app->tutorial_layouts[4]);
|
||||
}
|
||||
int available_content_space = viewport_h - ui_px(16) - ui_px(16);
|
||||
int old_max_scroll = 0;
|
||||
int max_scroll = actual_content_h - available_content_space;
|
||||
if(max_scroll < 0)
|
||||
max_scroll = 0;
|
||||
|
||||
/* Reset scroll position if content now fits in viewport */
|
||||
if(max_scroll == 0 && old_max_scroll > 0) {
|
||||
app->manual_scroll = 0;
|
||||
}
|
||||
/* Clamp scroll position to new max */
|
||||
app->manual_scroll = clampi(app->manual_scroll, 0, max_scroll);
|
||||
app->manual_scroll -= (int)(GetMouseWheelMove() * 24.0f);
|
||||
app->manual_scroll = clampi(app->manual_scroll, 0, max_scroll);
|
||||
|
||||
/* Handle content area drag scrolling */
|
||||
static int content_drag_active = 0;
|
||||
static int content_drag_start_y = 0;
|
||||
static int content_drag_start_scroll = 0;
|
||||
|
||||
Vector2 mouse_pos = GetMousePosition();
|
||||
int content_area_y = title_h;
|
||||
int content_area_h = viewport_h;
|
||||
|
||||
Rectangle content_bounds = {content_x, content_area_y, content_w, content_area_h};
|
||||
|
||||
if(IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
|
||||
if(!content_drag_active) {
|
||||
/* Start drag if clicking in content area */
|
||||
if(CheckCollisionPointRec(mouse_pos, content_bounds)) {
|
||||
content_drag_active = 1;
|
||||
content_drag_start_y = (int)mouse_pos.y;
|
||||
content_drag_start_scroll = app->manual_scroll;
|
||||
}
|
||||
} else {
|
||||
/* Continue drag */
|
||||
int dy = (int)mouse_pos.y - content_drag_start_y;
|
||||
app->manual_scroll = content_drag_start_scroll - dy;
|
||||
app->manual_scroll = clampi(app->manual_scroll, 0, max_scroll);
|
||||
}
|
||||
} else {
|
||||
content_drag_active = 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));
|
||||
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);
|
||||
if(step == 0) {
|
||||
int img_h = ui_px(200);
|
||||
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);
|
||||
if(app->tutorial_layouts_initialized && app->tutorial_layouts[0] != NULL) {
|
||||
ui_text_layout_draw(app->tutorial_layouts[0], content_x, &y, body_font, c_text);
|
||||
}
|
||||
|
||||
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) {
|
||||
} else if(step == 1) {
|
||||
/* Step 1 text with gear icon - parse fresh each frame for proper icon binding */
|
||||
int icon_size = ui_px(14);
|
||||
TextLayout gear_layout = ui_text_layout_parse(locale_get(TUTORIAL_KEYS[1]), app->gear_icon, UI_ICON_TYPE_GEAR, icon_size);
|
||||
ui_text_layout_reflow(&gear_layout, content_w, body_font, ui_px(24));
|
||||
ui_text_layout_draw(&gear_layout, content_x, &y, body_font, c_text);
|
||||
ui_text_layout_free(&gear_layout);
|
||||
} else if(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);
|
||||
if(app->tutorial_layouts_initialized && app->tutorial_layouts[2] != NULL) {
|
||||
ui_text_layout_draw(app->tutorial_layouts[2], content_x, &y, body_font, c_text);
|
||||
}
|
||||
y += ui_px(20); /* Increased spacing between text and circle */
|
||||
|
||||
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);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
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);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
}
|
||||
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,
|
||||
if(ui_draw_slider(app, 10, content_x, y, content_w, locale_get("speed_label"), 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_preview.progressive_speed = 0;
|
||||
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 if(step == 3) {
|
||||
if(app->tutorial_layouts_initialized && app->tutorial_layouts[3] != NULL) {
|
||||
ui_text_layout_draw(app->tutorial_layouts[3], content_x, &y, body_font, c_text);
|
||||
}
|
||||
} 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);
|
||||
int img_h = ui_px(234);
|
||||
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));
|
||||
if(app->tutorial_layouts_initialized && app->tutorial_layouts[4] != NULL) {
|
||||
ui_text_layout_draw(app->tutorial_layouts[4], content_x, &y, body_font, c_text);
|
||||
}
|
||||
}
|
||||
EndScissorMode();
|
||||
|
||||
snprintf(page_label, sizeof(page_label), "%d/%d", app->tutorial_step + 1, TUTORIAL_STEPS);
|
||||
/* Draw scrollbar if content overflows */
|
||||
if(max_scroll > 0) {
|
||||
int scrollbar_x = content_x + content_w + ui_px(4); /* Reduced spacing */
|
||||
int scrollbar_viewport = available_content_space; /* Scrollable area only */
|
||||
ui_draw_scrollbar(app, scrollbar_x, title_h + ui_px(16), scrollbar_viewport, actual_content_h,
|
||||
&app->manual_scroll, max_scroll);
|
||||
}
|
||||
|
||||
snprintf(page_label, sizeof(page_label), "%d/%d", step + 1, (int)TUTORIAL_STEPS_COUNT);
|
||||
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);
|
||||
@@ -201,19 +295,19 @@ manual_tab_draw(InbeApp *app)
|
||||
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);
|
||||
if(step == 0) {
|
||||
if(ui_draw_text_btn(app, content_x + button_pad, footer_y, locale_get("tutorial_skip_button"), &left_hover))
|
||||
manual_tab_close_tutorial(app, 1);
|
||||
} else {
|
||||
if(ui_draw_text_btn(app, content_x + button_pad, footer_y, "BACK", &left_hover)) {
|
||||
if(ui_draw_text_btn(app, content_x + button_pad, footer_y, locale_get("tutorial_back_button"), &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)
|
||||
step == (int)TUTORIAL_STEPS_COUNT - 1 ? locale_get("tutorial_finish_button") : locale_get("tutorial_next_button"), &right_hover)) {
|
||||
if(step == (int)TUTORIAL_STEPS_COUNT - 1)
|
||||
manual_tab_close_tutorial(app, 1);
|
||||
else {
|
||||
app->tutorial_step++;
|
||||
@@ -227,4 +321,3 @@ manual_tab_draw(InbeApp *app)
|
||||
save_settings(app);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
|
||||
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);
|
||||
void manual_tab_reset_layouts(InbeApp *app);
|
||||
|
||||
#endif
|
||||
+118
-58
@@ -1,6 +1,9 @@
|
||||
#include "settings_tab.h"
|
||||
#include "app.h"
|
||||
#include "ui.h"
|
||||
#include "language_tab.h"
|
||||
#include "locale.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/text_layout.h"
|
||||
#include "theme.h"
|
||||
#include "theme_meta.h"
|
||||
#include "version.h"
|
||||
@@ -13,15 +16,13 @@
|
||||
/* 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"
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
extern int view_width;
|
||||
@@ -32,7 +33,7 @@ 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";
|
||||
const char *label = locale_get("theme_label");
|
||||
|
||||
DrawText(label, x, y, font, c_text);
|
||||
|
||||
@@ -42,7 +43,8 @@ draw_theme_selector(InbeApp *app, int x, int y, int w)
|
||||
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)) {
|
||||
if(ui_draw_toggle_switch(app, toggle_x, toggle_y, toggle_w, toggle_h, &app->dark_mode,
|
||||
locale_get("toggle_off"), locale_get("toggle_on"))) {
|
||||
refresh_theme_colors(app->theme_id, app->dark_mode);
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
@@ -105,14 +107,20 @@ settings_tab_draw(InbeApp *app)
|
||||
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);
|
||||
/* Use percentage of screen width like tutorial, not DPI-scaled CONTENT_MAX_W */
|
||||
int responsive_max_w = (int)(view_width * 0.90f); /* 90% of screen width */
|
||||
int min_content_w = ui_px(320);
|
||||
if(responsive_max_w < min_content_w)
|
||||
responsive_max_w = min_content_w;
|
||||
int side_padding = ui_px(32); /* Match tutorial spacing */
|
||||
ui_centered_column(responsive_max_w, side_padding, &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);
|
||||
close_clicked = ui_draw_screen_header(app, locale_get("settings_title"), 1);
|
||||
if(close_clicked) {
|
||||
if(app->settings_dirty)
|
||||
save_settings(app);
|
||||
@@ -133,6 +141,14 @@ settings_tab_draw(InbeApp *app)
|
||||
(int)(app->camera.offset.y + title_h * app->camera.zoom),
|
||||
(int)(view_width * app->camera.zoom),
|
||||
(int)(viewport_h * app->camera.zoom));
|
||||
int language_menu_changed = 0;
|
||||
int draw_language_menu = 0;
|
||||
settings_tab_names[0] = locale_get("settings_tab_breathing");
|
||||
settings_tab_names[1] = locale_get("settings_tab_session");
|
||||
settings_tab_names[2] = locale_get("settings_tab_appearance");
|
||||
settings_tab_names[3] = locale_get("settings_tab_language");
|
||||
settings_tab_names[4] = locale_get("settings_tab_data");
|
||||
settings_tab_names[5] = locale_get("settings_tab_about");
|
||||
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);
|
||||
}
|
||||
@@ -146,11 +162,13 @@ settings_tab_draw(InbeApp *app)
|
||||
/* 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);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
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);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
}
|
||||
|
||||
/* Content starts after dropdown */
|
||||
@@ -160,18 +178,47 @@ settings_tab_draw(InbeApp *app)
|
||||
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, "")) {
|
||||
if(ui_draw_slider(app, 1, content_x, yoff + content_start_y + ui_px(200), content_w, locale_get("speed_label"), 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_preview.progressive_speed = 0;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
|
||||
/* Progressive speed - under Speed slider */
|
||||
int progressive_speed = app->inbe.progressive_speed;
|
||||
int toggle_w = ui_px(56);
|
||||
int toggle_h = ui_px(30);
|
||||
int toggle_x = content_x;
|
||||
int progressive_label_y = yoff + content_start_y + ui_px(275);
|
||||
int progressive_toggle_y = progressive_label_y + ui_px(26);
|
||||
DrawText(locale_get("progressive_speed_label"), content_x, progressive_label_y, ui_clamp_px(14, 12, 16), c_text);
|
||||
if(ui_draw_toggle_switch(app, toggle_x, progressive_toggle_y, toggle_w, toggle_h, &progressive_speed, locale_get("toggle_off"), locale_get("toggle_on"))) {
|
||||
app->inbe.progressive_speed = progressive_speed;
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
app->settings_dirty = 1;
|
||||
TraceLog(LOG_INFO, "INBE: Settings toggled progressive_speed to %d", progressive_speed);
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
/* Play in background (Android only) */
|
||||
int play_in_background = app->inbe.play_in_background;
|
||||
int play_bg_label_y = progressive_toggle_y + toggle_h + ui_px(18);
|
||||
int play_bg_toggle_y = play_bg_label_y + ui_px(26);
|
||||
DrawText(locale_get("play_in_background_label"), content_x, play_bg_label_y, ui_clamp_px(14, 12, 16), c_text);
|
||||
if(ui_draw_toggle_switch(app, toggle_x, play_bg_toggle_y, toggle_w, toggle_h, &play_in_background, locale_get("toggle_off"), locale_get("toggle_on"))) {
|
||||
app->inbe.play_in_background = play_in_background;
|
||||
app->settings_dirty = 1;
|
||||
TraceLog(LOG_INFO, "INBE: Settings toggled play_in_background to %d", play_in_background);
|
||||
}
|
||||
#endif
|
||||
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,
|
||||
if(ui_draw_slider(app, 2, content_x, slider_y, content_w, locale_get("max_rounds_label"), 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);
|
||||
@@ -179,7 +226,7 @@ settings_tab_draw(InbeApp *app)
|
||||
}
|
||||
|
||||
/* Max breaths */
|
||||
if(ui_draw_slider(app, 3, content_x, slider_y + ui_px(66), content_w, "Max breaths", SETTINGS_BREATHS_MIN,
|
||||
if(ui_draw_slider(app, 3, content_x, slider_y + ui_px(66), content_w, locale_get("max_breaths_label"), 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);
|
||||
@@ -187,7 +234,7 @@ settings_tab_draw(InbeApp *app)
|
||||
}
|
||||
|
||||
/* Pause */
|
||||
if(ui_draw_slider(app, 4, content_x, slider_y + ui_px(132), content_w, "Pause after round", SETTINGS_PAUSE_MIN,
|
||||
if(ui_draw_slider(app, 4, content_x, slider_y + ui_px(132), content_w, locale_get("pause_after_round_label"), 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);
|
||||
@@ -196,7 +243,7 @@ settings_tab_draw(InbeApp *app)
|
||||
|
||||
/* 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,
|
||||
if(ui_draw_slider(app, 6, content_x, slider_y + ui_px(198), content_w, locale_get("volume_label"), SETTINGS_VOLUME_MIN,
|
||||
SETTINGS_VOLUME_MAX, &sound_volume, "")) {
|
||||
app->sound_volume = sound_volume;
|
||||
app->settings_dirty = 1;
|
||||
@@ -204,7 +251,7 @@ settings_tab_draw(InbeApp *app)
|
||||
|
||||
/* 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_w = MeasureText(locale_get("reset_to_defaults_label"), 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;
|
||||
@@ -222,7 +269,7 @@ settings_tab_draw(InbeApp *app)
|
||||
}
|
||||
|
||||
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);
|
||||
DrawText(locale_get("reset_to_defaults_label"), 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)) {
|
||||
@@ -240,7 +287,7 @@ settings_tab_draw(InbeApp *app)
|
||||
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(ui_draw_checkbox_toggle(app, content_x, checkbox_y, locale_get("fullscreen_label"), &app->fullscreen_enabled)) {
|
||||
if(app->fullscreen_enabled && !IsWindowFullscreen())
|
||||
ToggleFullscreen();
|
||||
else if(!app->fullscreen_enabled && IsWindowFullscreen())
|
||||
@@ -254,11 +301,17 @@ settings_tab_draw(InbeApp *app)
|
||||
int theme_y = yoff + content_start_y;
|
||||
#endif
|
||||
draw_theme_selector(app, content_x, theme_y, content_w);
|
||||
|
||||
break;
|
||||
}
|
||||
case SETTINGS_TAB_LANGUAGE: {
|
||||
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));
|
||||
int label_y = yoff + content_start_y;
|
||||
int dropdown_y = label_y + ui_px(28);
|
||||
|
||||
DrawText(locale_get("language_label"), content_x, label_y, font, c_text);
|
||||
if(language_dropdown_button(app, 101, content_x, dropdown_y, content_w, ui_px(36), &app->language_index))
|
||||
language_menu_changed = 1;
|
||||
draw_language_menu = 1;
|
||||
break;
|
||||
}
|
||||
case SETTINGS_TAB_DATA: {
|
||||
@@ -279,7 +332,7 @@ settings_tab_draw(InbeApp *app)
|
||||
snprintf(size_str, sizeof(size_str), "%.1f MB", (float)data_size / (1024 * 1024));
|
||||
|
||||
/* Title */
|
||||
DrawText("Data Management", content_x, text_y, font, c_text);
|
||||
DrawText(locale_get("data_management_label"), content_x, text_y, font, c_text);
|
||||
text_y += ui_px(30);
|
||||
|
||||
/* Statistics box */
|
||||
@@ -295,11 +348,11 @@ settings_tab_draw(InbeApp *app)
|
||||
int stat_y = text_y + ui_px(16);
|
||||
char stat_text[64];
|
||||
|
||||
snprintf(stat_text, sizeof(stat_text), "Total Sessions: %d", session_count);
|
||||
locale_format(stat_text, sizeof(stat_text), "total_sessions_label", 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);
|
||||
locale_format(stat_text, sizeof(stat_text), "data_size_label", size_str);
|
||||
DrawText(stat_text, stat_x, stat_y, font, c_text);
|
||||
stat_y += ui_px(22);
|
||||
|
||||
@@ -315,14 +368,18 @@ settings_tab_draw(InbeApp *app)
|
||||
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));
|
||||
{
|
||||
char storage_text[FS_PATH_MAX + 32];
|
||||
locale_format(storage_text, sizeof(storage_text), "storage_label", display_path);
|
||||
DrawText(storage_text, 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_w = MeasureText(locale_get("export_data_button"), 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};
|
||||
@@ -337,45 +394,46 @@ settings_tab_draw(InbeApp *app)
|
||||
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);
|
||||
DrawText(locale_get("export_data_button"), 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};
|
||||
int delete_w = MeasureText(locale_get("delete_all_data_button"), font) + ui_px(24);
|
||||
int delete_x = content_x;
|
||||
int delete_y = export_y + export_h + ui_px(12);
|
||||
Rectangle delete_rect = {delete_x, delete_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));
|
||||
DrawRectangle(delete_x, delete_y, delete_w, export_h, c_button_hover);
|
||||
ui_draw_bevel(delete_x, delete_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));
|
||||
DrawRectangle(delete_x, delete_y, delete_w, export_h, c_button);
|
||||
ui_draw_bevel(delete_x, delete_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);
|
||||
DrawText(locale_get("delete_all_data_button"), delete_x + ui_px(12), delete_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")) {
|
||||
if(file_dialog_save(&export_dlg, locale_get("export_data_dialog_title"), "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");
|
||||
locale_format(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);
|
||||
locale_format(export_result, sizeof(export_result), "exported_label", filename);
|
||||
TraceLog(LOG_INFO, "DATA: Export successful to %s", path);
|
||||
} else {
|
||||
snprintf(export_result, sizeof(export_result), "Export failed");
|
||||
locale_format(export_result, sizeof(export_result), "export_failed");
|
||||
TraceLog(LOG_ERROR, "DATA: Export failed");
|
||||
}
|
||||
#endif
|
||||
@@ -407,20 +465,16 @@ settings_tab_draw(InbeApp *app)
|
||||
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);
|
||||
}
|
||||
const char *desc_text = locale_get("about_description");
|
||||
TextLayout desc_layout = ui_text_layout_parse(desc_text, (Texture2D){0}, UI_ICON_TYPE_NONE, font);
|
||||
ui_text_layout_reflow(&desc_layout, content_w, font, ui_px(22));
|
||||
ui_text_layout_draw(&desc_layout, content_x, &text_y, font, c_text);
|
||||
ui_text_layout_free(&desc_layout);
|
||||
|
||||
/* Version info */
|
||||
text_y += ui_px(20);
|
||||
char version_text[32];
|
||||
snprintf(version_text, sizeof(version_text), "Version %s", INBE_VERSION_STRING);
|
||||
locale_format(version_text, sizeof(version_text), "version_label", INBE_VERSION_STRING);
|
||||
DrawText(version_text, content_x, text_y, small_font, ui_darken(c_text, 40));
|
||||
|
||||
/* Icon links */
|
||||
@@ -431,18 +485,24 @@ settings_tab_draw(InbeApp *app)
|
||||
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");
|
||||
ui_draw_icon_link(app, links_start_x + icon_padding, links_y, icon_size, app->telegram_icon, UI_ICON_TYPE_TELEGRAM, "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, UI_ICON_TYPE_GLOBE, "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, UI_ICON_TYPE_MONERO, "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, UI_ICON_TYPE_STRIPE, "https://donate.stripe.com/4gM3cv5boaR98HH9VvfAc04");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
EndScissorMode();
|
||||
|
||||
/* Draw dropdown menu (floats above content) */
|
||||
ui_draw_dropdown_menu(app, 100);
|
||||
|
||||
if(draw_language_menu && language_dropdown_menu(app, 101))
|
||||
language_menu_changed = 1;
|
||||
|
||||
if(language_menu_changed)
|
||||
apply_language_selection(app, app->language_index, 1);
|
||||
|
||||
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
|
||||
if(app->settings_dirty)
|
||||
save_settings(app);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "dpi.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Global DPI cache instance */
|
||||
DPICache g_dpi;
|
||||
|
||||
void
|
||||
dpi_init(void)
|
||||
{
|
||||
g_dpi.view_width = INBE_DPI_BASE_WIDTH;
|
||||
g_dpi.view_height = INBE_DPI_BASE_HEIGHT;
|
||||
g_dpi.ui_scale = 1.0f;
|
||||
g_dpi.ui_scale_clamped = 1.0f;
|
||||
g_dpi.camera_zoom = 1.0f;
|
||||
g_dpi.base_width = INBE_DPI_BASE_WIDTH;
|
||||
g_dpi.base_height = INBE_DPI_BASE_HEIGHT;
|
||||
g_dpi.needs_update = 0;
|
||||
}
|
||||
|
||||
void
|
||||
dpi_update(int view_width, int view_height)
|
||||
{
|
||||
int previous_width = g_dpi.view_width;
|
||||
int previous_height = g_dpi.view_height;
|
||||
|
||||
/* Only recalculate if viewport actually changed */
|
||||
if(previous_width != view_width || previous_height != view_height) {
|
||||
g_dpi.view_width = view_width;
|
||||
g_dpi.view_height = view_height;
|
||||
|
||||
/* Calculate UI scale based on viewport height vs base design */
|
||||
g_dpi.ui_scale = (float)view_height / (float)g_dpi.base_height;
|
||||
|
||||
/* Clamp to minimum 1.0 (no downscaling) */
|
||||
if(g_dpi.ui_scale < 1.0f)
|
||||
g_dpi.ui_scale_clamped = 1.0f;
|
||||
else
|
||||
g_dpi.ui_scale_clamped = g_dpi.ui_scale;
|
||||
|
||||
g_dpi.needs_update = 1;
|
||||
} else {
|
||||
g_dpi.needs_update = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
dpi_is_dirty(void)
|
||||
{
|
||||
return g_dpi.needs_update;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef INBE_DPI_H
|
||||
#define INBE_DPI_H
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
/* Base design dimensions */
|
||||
#define INBE_DPI_BASE_WIDTH 320
|
||||
#define INBE_DPI_BASE_HEIGHT 560
|
||||
|
||||
typedef struct DPICache {
|
||||
/* Viewport dimensions */
|
||||
int view_width;
|
||||
int view_height;
|
||||
|
||||
/* UI Scaling */
|
||||
float ui_scale;
|
||||
float ui_scale_clamped;
|
||||
|
||||
/* Camera/Rendering */
|
||||
float camera_zoom;
|
||||
|
||||
/* Design constants */
|
||||
int base_width;
|
||||
int base_height;
|
||||
|
||||
/* Dirty flag for viewport changes */
|
||||
int needs_update;
|
||||
} DPICache;
|
||||
|
||||
/* Global DPI cache instance */
|
||||
extern DPICache g_dpi;
|
||||
|
||||
/* Initialization and updates */
|
||||
void dpi_init(void);
|
||||
void dpi_update(int view_width, int view_height);
|
||||
int dpi_is_dirty(void);
|
||||
|
||||
/* Accessor functions (inline for performance) */
|
||||
static inline float dpi_ui_scale(void) { return g_dpi.ui_scale_clamped; }
|
||||
static inline int dpi_view_width(void) { return g_dpi.view_width; }
|
||||
static inline int dpi_view_height(void) { return g_dpi.view_height; }
|
||||
static inline float dpi_camera_zoom(void) { return g_dpi.camera_zoom; }
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,315 @@
|
||||
#include "text_layout.h"
|
||||
#include "ui.h"
|
||||
#include "app.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* ================================================================
|
||||
* TEXT LAYOUT PARSING
|
||||
* ================================================================ */
|
||||
|
||||
TextLayout
|
||||
text_layout_parse(const char *input, Texture2D icon, UIIconType icon_type, int icon_size)
|
||||
{
|
||||
TextLayout layout = {0};
|
||||
|
||||
if(input == NULL || input[0] == '\0') {
|
||||
return layout;
|
||||
}
|
||||
|
||||
/* First pass: count word/phrase elements */
|
||||
int element_count = 0;
|
||||
const char *p = input;
|
||||
|
||||
while(*p) {
|
||||
/* Check for icon keyword */
|
||||
if(strncmp(p, "%i", 2) == 0) {
|
||||
element_count++; /* Count icon as element */
|
||||
p += 2;
|
||||
} else if(*p == '\n') {
|
||||
/* Explicit newline - count as forced line break element */
|
||||
element_count++;
|
||||
p++;
|
||||
} else {
|
||||
/* Skip whitespace and count word/phrase segments */
|
||||
const char *word_start = p;
|
||||
while(*p && *p != ' ' && *p != '\n' && strncmp(p, "%i", 2) != 0) {
|
||||
p++;
|
||||
}
|
||||
|
||||
/* Only count if we found actual text content */
|
||||
if(p > word_start) {
|
||||
element_count++;
|
||||
}
|
||||
|
||||
/* Skip whitespace (spaces only, not newlines) */
|
||||
if(*p == ' ') {
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Allocate elements array */
|
||||
layout.elements = (TextElement *)calloc(element_count, sizeof(TextElement));
|
||||
if(layout.elements == NULL) {
|
||||
return layout;
|
||||
}
|
||||
layout.element_count = element_count;
|
||||
|
||||
/* Second pass: populate elements with actual word/phrase segments */
|
||||
int element_idx = 0;
|
||||
p = input;
|
||||
|
||||
while(*p && element_idx < element_count) {
|
||||
/* Check for icon keyword */
|
||||
if(strncmp(p, "%i", 2) == 0) {
|
||||
/* Add icon element */
|
||||
layout.elements[element_idx].type = TEXT_ELEMENT_TYPE_ICON;
|
||||
layout.elements[element_idx].icon = icon;
|
||||
layout.elements[element_idx].icon_type = icon_type;
|
||||
layout.elements[element_idx].icon_size = icon_size;
|
||||
layout.elements[element_idx].text_width = 0;
|
||||
element_idx++;
|
||||
p += 2;
|
||||
} else if(*p == '\n') {
|
||||
/* Add line break element for explicit newlines */
|
||||
layout.elements[element_idx].type = TEXT_ELEMENT_TYPE_LINE_BREAK;
|
||||
layout.elements[element_idx].text_width = 0;
|
||||
element_idx++;
|
||||
p++;
|
||||
} else {
|
||||
/* Extract word/phrase segment */
|
||||
const char *word_start = p;
|
||||
while(*p && *p != ' ' && *p != '\n' && strncmp(p, "%i", 2) != 0) {
|
||||
p++;
|
||||
}
|
||||
|
||||
/* Only add if we found actual text content */
|
||||
if(p > word_start) {
|
||||
size_t len = p - word_start;
|
||||
char *text_copy = (char *)malloc(len + 1);
|
||||
if(text_copy != NULL) {
|
||||
memcpy(text_copy, word_start, len);
|
||||
text_copy[len] = '\0';
|
||||
layout.elements[element_idx].type = TEXT_ELEMENT_TYPE_TEXT;
|
||||
layout.elements[element_idx].text = text_copy;
|
||||
layout.elements[element_idx].text_width = 0;
|
||||
element_idx++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Skip whitespace (spaces only, not newlines) */
|
||||
if(*p == ' ') {
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
* TEXT LAYOUT REFLOW
|
||||
* ================================================================ */
|
||||
|
||||
void
|
||||
text_layout_reflow(TextLayout *layout, int max_width, int font_size, int line_height)
|
||||
{
|
||||
if(layout == NULL || layout->elements == NULL || layout->element_count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Free previous layout data */
|
||||
if(layout->line_breaks != NULL) {
|
||||
free(layout->line_breaks);
|
||||
}
|
||||
if(layout->line_widths != NULL) {
|
||||
free(layout->line_widths);
|
||||
}
|
||||
|
||||
/* Allocate maximum possible line breaks (one per element) */
|
||||
layout->line_breaks = (int *)calloc(layout->element_count + 1, sizeof(int));
|
||||
layout->line_widths = (int *)calloc(layout->element_count + 1, sizeof(int));
|
||||
|
||||
if(layout->line_breaks == NULL || layout->line_widths == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Cache text widths for all text elements */
|
||||
for(int i = 0; i < layout->element_count; i++) {
|
||||
if(layout->elements[i].type == TEXT_ELEMENT_TYPE_TEXT && layout->elements[i].text != NULL) {
|
||||
layout->elements[i].text_width = MeasureText(layout->elements[i].text, font_size);
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate line breaks greedily */
|
||||
layout->line_count = 0;
|
||||
layout->line_breaks[0] = 0; /* First line starts at element 0 */
|
||||
int current_line_width = 0;
|
||||
|
||||
|
||||
for(int i = 0; i < layout->element_count; i++) {
|
||||
/* Handle forced line breaks from explicit newlines */
|
||||
if(layout->elements[i].type == TEXT_ELEMENT_TYPE_LINE_BREAK) {
|
||||
layout->line_count++;
|
||||
layout->line_breaks[layout->line_count] = i;
|
||||
layout->line_widths[layout->line_count - 1] = current_line_width;
|
||||
current_line_width = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
int element_width = 0;
|
||||
int spacing = 0;
|
||||
|
||||
if(layout->elements[i].type == TEXT_ELEMENT_TYPE_TEXT) {
|
||||
element_width = layout->elements[i].text_width;
|
||||
spacing = (current_line_width > 0) ? MeasureText(" ", font_size) : 0;
|
||||
} else { /* ICON */
|
||||
element_width = layout->elements[i].icon_size;
|
||||
spacing = (current_line_width > 0) ? ui_px(4) : 0; /* Small spacing around icons */
|
||||
}
|
||||
|
||||
/* Check if element fits on current line */
|
||||
if(current_line_width + spacing + element_width <= max_width) {
|
||||
current_line_width += spacing + element_width;
|
||||
} else {
|
||||
/* Start new line */
|
||||
layout->line_count++;
|
||||
layout->line_breaks[layout->line_count] = i;
|
||||
layout->line_widths[layout->line_count - 1] = current_line_width;
|
||||
current_line_width = element_width;
|
||||
}
|
||||
}
|
||||
|
||||
/* Store last line width and count */
|
||||
layout->line_widths[layout->line_count] = current_line_width;
|
||||
layout->line_count++;
|
||||
/* Calculate total height properly.
|
||||
* For N lines, we have N * font_size for text height + (N-1) * ui_px(4) for spacing between lines.
|
||||
* The last line doesn't have spacing after it. */
|
||||
if(layout->line_count > 0) {
|
||||
layout->total_height = layout->line_count * font_size + (layout->line_count - 1) * ui_px(4);
|
||||
} else {
|
||||
layout->total_height = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
* TEXT LAYOUT DRAWING
|
||||
* ================================================================ */
|
||||
|
||||
void
|
||||
text_layout_draw(TextLayout *layout, int x, int *y, int font_size, Color color)
|
||||
{
|
||||
if(layout == NULL || layout->elements == NULL || layout->element_count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int current_x = x;
|
||||
int current_y = *y;
|
||||
int current_line = 0;
|
||||
|
||||
|
||||
for(int i = 0; i < layout->element_count; i++) {
|
||||
/* Handle forced line breaks from explicit newlines */
|
||||
if(layout->elements[i].type == TEXT_ELEMENT_TYPE_LINE_BREAK) {
|
||||
current_line++;
|
||||
current_y += font_size + ui_px(4); /* Move to next line */
|
||||
current_x = x;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check if this element starts a new line */
|
||||
int is_line_break = 0;
|
||||
for(int j = 0; j < layout->line_count; j++) {
|
||||
if(layout->line_breaks[j] == i) {
|
||||
is_line_break = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_line_break && i > 0) {
|
||||
current_line++;
|
||||
current_y += font_size + ui_px(4); /* Move to next line */
|
||||
current_x = x;
|
||||
}
|
||||
|
||||
if(layout->elements[i].type == TEXT_ELEMENT_TYPE_TEXT) {
|
||||
/* Draw text element */
|
||||
if(layout->elements[i].text != NULL && layout->elements[i].text[0] != '\0') {
|
||||
DrawText(layout->elements[i].text, current_x, current_y, font_size, color);
|
||||
current_x += layout->elements[i].text_width;
|
||||
}
|
||||
} else { /* ICON */
|
||||
/* Draw icon element */
|
||||
Texture2D icon = layout->elements[i].icon;
|
||||
int icon_size = layout->elements[i].icon_size;
|
||||
|
||||
if(icon.id != 0) {
|
||||
Rectangle src = {0, 0, icon.width, icon.height};
|
||||
Rectangle dst = {current_x, current_y, (float)icon_size, (float)icon_size};
|
||||
DrawTexturePro(icon, src, dst, (Vector2){0}, 0, color);
|
||||
} else {
|
||||
/* Use fallback icon rendering */
|
||||
ui_draw_icon_fallback(layout->elements[i].icon_type, current_x, current_y, icon_size, color);
|
||||
}
|
||||
|
||||
current_x += icon_size;
|
||||
}
|
||||
|
||||
/* Add spacing after each element (except last in line) */
|
||||
current_x += (layout->elements[i].type == TEXT_ELEMENT_TYPE_TEXT) ?
|
||||
MeasureText(" ", font_size) : ui_px(4);
|
||||
}
|
||||
|
||||
/* Set final Y position to match total_height calculation.
|
||||
* After drawing all lines, current_y is at the top of the last line.
|
||||
* Add font_size to account for the height of the last line itself.
|
||||
* This matches: total_height = N*font_size + (N-1)*ui_px(4) */
|
||||
*y = current_y + font_size;
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
* TEXT LAYOUT UTILITIES
|
||||
* ================================================================ */
|
||||
|
||||
int
|
||||
text_layout_get_height(TextLayout *layout)
|
||||
{
|
||||
if(layout == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return layout->total_height;
|
||||
}
|
||||
|
||||
void
|
||||
text_layout_free(TextLayout *layout)
|
||||
{
|
||||
if(layout == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Free text strings (they were allocated during parsing) */
|
||||
if(layout->elements != NULL) {
|
||||
for(int i = 0; i < layout->element_count; i++) {
|
||||
if(layout->elements[i].type == TEXT_ELEMENT_TYPE_TEXT && layout->elements[i].text != NULL) {
|
||||
free((void *)layout->elements[i].text);
|
||||
}
|
||||
}
|
||||
free(layout->elements);
|
||||
}
|
||||
|
||||
/* Free layout data */
|
||||
if(layout->line_breaks != NULL) {
|
||||
free(layout->line_breaks);
|
||||
}
|
||||
if(layout->line_widths != NULL) {
|
||||
free(layout->line_widths);
|
||||
}
|
||||
|
||||
/* Clear the structure */
|
||||
memset(layout, 0, sizeof(TextLayout));
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef INBE_TEXT_LAYOUT_H
|
||||
#define INBE_TEXT_LAYOUT_H
|
||||
|
||||
#include "raylib.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
/* ================================================================
|
||||
* TEXT LAYOUT ENGINE
|
||||
* Supports text reflow with inline icon embedding (%i keyword)
|
||||
* ================================================================ */
|
||||
|
||||
typedef enum {
|
||||
TEXT_ELEMENT_TYPE_TEXT,
|
||||
TEXT_ELEMENT_TYPE_ICON,
|
||||
TEXT_ELEMENT_TYPE_LINE_BREAK
|
||||
} TextElementType;
|
||||
|
||||
typedef struct {
|
||||
TextElementType type;
|
||||
const char *text; /* For TEXT elements - points into original string */
|
||||
Texture2D icon; /* For ICON elements */
|
||||
UIIconType icon_type; /* Fallback icon type if texture fails */
|
||||
int icon_size; /* Icon size in pixels */
|
||||
int text_width; /* Cached text width (for TEXT elements) */
|
||||
} TextElement;
|
||||
|
||||
typedef struct TextLayout {
|
||||
TextElement *elements; /* Array of elements (mixed text and icons) */
|
||||
int element_count;
|
||||
int *line_breaks; /* Indices where lines break (element indices) */
|
||||
int line_count;
|
||||
int *line_widths; /* Width of each line in pixels */
|
||||
int total_height; /* Total height of laid-out text */
|
||||
int last_reflow_width; /* Cache: last width used for reflow */
|
||||
} TextLayout;
|
||||
|
||||
/* Core text layout functions */
|
||||
TextLayout text_layout_parse(const char *input, Texture2D icon, UIIconType icon_type, int icon_size);
|
||||
void text_layout_reflow(TextLayout *layout, int max_width, int font_size, int line_height);
|
||||
void text_layout_draw(TextLayout *layout, int x, int *y, int font_size, Color color);
|
||||
int text_layout_get_height(TextLayout *layout);
|
||||
void text_layout_free(TextLayout *layout);
|
||||
|
||||
#endif /* INBE_TEXT_LAYOUT_H */
|
||||
+281
-127
@@ -1,11 +1,13 @@
|
||||
#include "ui.h"
|
||||
#include "app.h"
|
||||
#include "text_layout.h"
|
||||
#include "dpi.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
/* Global UI state */
|
||||
static float dpi_scale = 1.0f;
|
||||
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;
|
||||
@@ -15,7 +17,7 @@ ui_init(int width, int height, float dpi)
|
||||
{
|
||||
ui_view_width = width;
|
||||
ui_view_height = height;
|
||||
dpi_scale = dpi;
|
||||
/* dpi parameter is now ignored - we use the global DPI cache */
|
||||
}
|
||||
|
||||
void
|
||||
@@ -36,15 +38,15 @@ ui_set_colors(Color text, Color bg, Color circle, Color button, Color button_hov
|
||||
int
|
||||
ui_px(int px)
|
||||
{
|
||||
return (int)(px * dpi_scale + 0.5f);
|
||||
return (int)(px * dpi_ui_scale() + 0.5f);
|
||||
}
|
||||
|
||||
int
|
||||
ui_clamp_px(int px, int min_px, int max_px)
|
||||
{
|
||||
int value = (int)(px * dpi_scale + 0.5f);
|
||||
int min_value = (int)(min_px * dpi_scale + 0.5f);
|
||||
int max_value = (int)(max_px * dpi_scale + 0.5f);
|
||||
int value = (int)(px * dpi_ui_scale() + 0.5f);
|
||||
int min_value = (int)(min_px * dpi_ui_scale() + 0.5f);
|
||||
int max_value = (int)(max_px * dpi_ui_scale() + 0.5f);
|
||||
|
||||
if(value < min_value)
|
||||
value = min_value;
|
||||
@@ -86,9 +88,6 @@ ui_darken(Color c, int amount)
|
||||
void
|
||||
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 = ui_view_width - side_pad * 2;
|
||||
|
||||
if(available_w < 0)
|
||||
@@ -107,7 +106,7 @@ ui_centered_column(int max_w, int side_pad, int *x, int *w)
|
||||
void
|
||||
ui_draw_bevel(int x, int y, int w, int h, Color light, Color dark)
|
||||
{
|
||||
int border = (int)(dpi_scale + 0.5f);
|
||||
int border = (int)(dpi_ui_scale() + 0.5f);
|
||||
if(border < 1) border = 1;
|
||||
|
||||
DrawRectangle(x, y, w, border, light);
|
||||
@@ -153,8 +152,96 @@ ui_icon_btn_padding(UIIconSize size)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ui_draw_icon_fallback(UIIconType type, int x, int y, int size, Color color)
|
||||
{
|
||||
int center = size / 2;
|
||||
int thickness = size / 8;
|
||||
if(thickness < 1) thickness = 1;
|
||||
|
||||
switch(type) {
|
||||
case UI_ICON_TYPE_X: {
|
||||
int p = thickness / 2;
|
||||
DrawLine(x + p, y + p, x + size - p, y + size - p, color);
|
||||
DrawLine(x + size - p, y + p, x + p, y + size - p, color);
|
||||
break;
|
||||
}
|
||||
case UI_ICON_TYPE_GEAR: {
|
||||
int outer = size / 2 - thickness;
|
||||
int inner = size / 4;
|
||||
DrawCircle(x + center, y + center, outer, color);
|
||||
for(int i = 0; i < 6; i++) {
|
||||
float angle = i * 60.0f * DEG2RAD;
|
||||
int cx = x + center + (int)(cos(angle) * inner);
|
||||
int cy = y + center + (int)(sin(angle) * inner);
|
||||
DrawLine(x + center, y + center, cx, cy, color);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case UI_ICON_TYPE_BACKWARD: {
|
||||
int p = thickness;
|
||||
DrawTriangle(
|
||||
(Vector2){x + size - p, y + p},
|
||||
(Vector2){x + p, y + center},
|
||||
(Vector2){x + size - p, y + size - p},
|
||||
color
|
||||
);
|
||||
break;
|
||||
}
|
||||
case UI_ICON_TYPE_FORWARD: {
|
||||
int p = thickness;
|
||||
DrawTriangle(
|
||||
(Vector2){x + p, y + p},
|
||||
(Vector2){x + size - p, y + center},
|
||||
(Vector2){x + p, y + size - p},
|
||||
color
|
||||
);
|
||||
break;
|
||||
}
|
||||
case UI_ICON_TYPE_PLAY: {
|
||||
int p = thickness;
|
||||
DrawTriangle(
|
||||
(Vector2){x + p, y + p},
|
||||
(Vector2){x + size - p, y + center},
|
||||
(Vector2){x + p, y + size - p},
|
||||
color
|
||||
);
|
||||
break;
|
||||
}
|
||||
case UI_ICON_TYPE_PAUSE: {
|
||||
int w = size / 3;
|
||||
int p = (size - w * 2) / 3;
|
||||
DrawRectangle(x + p, y + thickness, w, size - thickness * 2, color);
|
||||
DrawRectangle(x + p + w + p, y + thickness, w, size - thickness * 2, color);
|
||||
break;
|
||||
}
|
||||
case UI_ICON_TYPE_RETURN:
|
||||
case UI_ICON_TYPE_HOME: {
|
||||
int p = thickness;
|
||||
DrawLine(x + center, y + size - p, x + center, y + p, color);
|
||||
DrawLine(x + center, y + p, x + p, y + p + (size / 3), color);
|
||||
DrawLine(x + center, y + p, x + size - p, y + p + (size / 3), color);
|
||||
if(type == UI_ICON_TYPE_RETURN) {
|
||||
DrawLine(x + p, y + center, x + size - p, y + center, color);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case UI_ICON_TYPE_MANUAL:
|
||||
case UI_ICON_TYPE_STAT: {
|
||||
DrawRectangle(x + thickness, y + thickness, size - thickness * 2, size - thickness * 2, color);
|
||||
DrawLine(x + thickness, y + thickness + size / 3, x + size - thickness, y + thickness + size / 3, color);
|
||||
DrawLine(x + thickness, y + thickness + size * 2 / 3, x + size - thickness, y + thickness + size * 2 / 3, color);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
DrawCircle(x + center, y + center, size / 3, color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
ui_draw_icon_btn(InbeApp *app, int x, int y, UIIconSize size, Texture2D icon, int *hover)
|
||||
ui_draw_icon_btn(InbeApp *app, int x, int y, UIIconSize size, Texture2D icon, UIIconType icon_type, int *hover)
|
||||
{
|
||||
int btn_size = ui_icon_btn_size(size);
|
||||
int padding = ui_icon_btn_padding(size);
|
||||
@@ -189,13 +276,15 @@ ui_draw_icon_btn(InbeApp *app, int x, int y, UIIconSize size, Texture2D icon, in
|
||||
Rectangle src = {0, 0, icon.width, icon.height};
|
||||
Rectangle dst = {x + padding, y + padding, (float)btn_size, (float)btn_size};
|
||||
DrawTexturePro(icon, src, dst, (Vector2){0}, 0, c_icon);
|
||||
} else {
|
||||
ui_draw_icon_fallback(icon_type, x + padding, y + padding, btn_size, c_icon);
|
||||
}
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
int
|
||||
ui_draw_icon_btn_padded(InbeApp *app, int x, int y, int size, Texture2D icon, int *hover)
|
||||
ui_draw_icon_btn_padded(InbeApp *app, int x, int y, int size, Texture2D icon, UIIconType icon_type, int *hover)
|
||||
{
|
||||
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
|
||||
int mx = (int)mouse_world.x;
|
||||
@@ -228,6 +317,8 @@ ui_draw_icon_btn_padded(InbeApp *app, int x, int y, int size, Texture2D icon, in
|
||||
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);
|
||||
} else {
|
||||
ui_draw_icon_fallback(icon_type, x + padding, y + padding, size, c_icon);
|
||||
}
|
||||
|
||||
return pressed;
|
||||
@@ -273,7 +364,7 @@ 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)
|
||||
ui_draw_icon_link(InbeApp *app, int x, int y, int icon_size, Texture2D icon, UIIconType icon_type, const char *url)
|
||||
{
|
||||
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
|
||||
int mx = (int)mouse_world.x;
|
||||
@@ -302,6 +393,8 @@ ui_draw_icon_link(InbeApp *app, int x, int y, int icon_size, Texture2D icon, con
|
||||
Rectangle src = {0, 0, icon.width, icon.height};
|
||||
Rectangle dst = {x, y, (float)icon_size, (float)icon_size};
|
||||
DrawTexturePro(icon, src, dst, (Vector2){0}, 0, c_icon);
|
||||
} else {
|
||||
ui_draw_icon_fallback(icon_type, x, y, icon_size, c_icon);
|
||||
}
|
||||
|
||||
if(hover && IsMouseButtonReleased(MOUSE_BUTTON_LEFT) && !ui_dropdown_captures_click(mouse_world)) {
|
||||
@@ -365,7 +458,8 @@ ui_draw_slider(InbeApp *app, int id, int x, int y, int w, const char *label,
|
||||
}
|
||||
|
||||
int
|
||||
ui_draw_toggle_switch(InbeApp *app, int x, int y, int w, int h, int *value)
|
||||
ui_draw_toggle_switch(InbeApp *app, int x, int y, int w, int h, int *value,
|
||||
const char *off_label, const char *on_label)
|
||||
{
|
||||
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
|
||||
int hover = 0;
|
||||
@@ -390,21 +484,19 @@ ui_draw_toggle_switch(InbeApp *app, int x, int y, int w, int h, int *value)
|
||||
|
||||
int active_w = (w - 6) / 2;
|
||||
int active_x = *value ? x + w - active_w - 3 : x + 3;
|
||||
DrawRectangleRounded((Rectangle){active_x, track_y, active_w, track_h}, 0.5f, 8, c_circle);
|
||||
DrawRectangleRounded((Rectangle){active_x, track_y, active_w, track_h}, 0.5f, 8, c_button);
|
||||
|
||||
int font = ui_clamp_px(12, 10, 14);
|
||||
const char *light_label = "Light";
|
||||
const char *dark_label = "Dark";
|
||||
int light_w = MeasureText(light_label, font);
|
||||
int dark_w = MeasureText(dark_label, font);
|
||||
int off_w = MeasureText(off_label, font);
|
||||
int on_w = MeasureText(on_label, font);
|
||||
|
||||
Color label_color = c_text;
|
||||
/* Center text in each half of the toggle */
|
||||
int light_x = x + w / 4 - light_w / 2;
|
||||
int dark_x = x + w * 3 / 4 - dark_w / 2;
|
||||
int off_x = x + w / 4 - off_w / 2;
|
||||
int on_x = x + w * 3 / 4 - on_w / 2;
|
||||
int text_y = y + h / 2 - font / 2;
|
||||
DrawText(light_label, light_x, text_y, font, label_color);
|
||||
DrawText(dark_label, dark_x, text_y, font, label_color);
|
||||
DrawText(off_label, off_x, text_y, font, label_color);
|
||||
DrawText(on_label, on_x, text_y, font, label_color);
|
||||
|
||||
return pressed;
|
||||
}
|
||||
@@ -468,7 +560,8 @@ ui_dropdown_captures_click(Vector2 point)
|
||||
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);
|
||||
/* Calculate dropdown height: top padding + all options + extra bottom padding for hover */
|
||||
int dropdown_h = ui_px(4) + option_h * state->option_count + ui_px(12);
|
||||
int max_visible_h = ui_view_height - dropdown_y - ui_px(16);
|
||||
|
||||
if(dropdown_h > max_visible_h) {
|
||||
@@ -579,13 +672,14 @@ ui_draw_dropdown_button(InbeApp *app, int id, int x, int y, int w, int h,
|
||||
return changed;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
ui_draw_dropdown_menu(InbeApp *app, int id)
|
||||
{
|
||||
UIDropdownState *state = get_or_create_dropdown_state(id);
|
||||
int changed = 0;
|
||||
|
||||
if(!state->open || state->options == NULL || state->selected_index == NULL)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
int font = ui_clamp_px(14, 12, 16);
|
||||
int x = state->x;
|
||||
@@ -599,7 +693,8 @@ ui_draw_dropdown_menu(InbeApp *app, int id)
|
||||
int option_h = h;
|
||||
int menu_gap = ui_px(4);
|
||||
int dropdown_y = y + h + menu_gap;
|
||||
int dropdown_h = option_h * option_count + ui_px(8);
|
||||
/* Calculate dropdown height: top padding + all options + extra bottom padding for hover */
|
||||
int dropdown_h = ui_px(4) + option_h * option_count + ui_px(12);
|
||||
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;
|
||||
@@ -631,16 +726,19 @@ ui_draw_dropdown_menu(InbeApp *app, int id)
|
||||
DrawRectangle(x, dropdown_y, w, dropdown_h, c_button);
|
||||
ui_draw_bevel(x, dropdown_y, w, dropdown_h, ui_darken(c_bg, 30), ui_lighten(c_bg, 20));
|
||||
|
||||
/* Clip to menu area */
|
||||
BeginScissorMode(x, dropdown_y, w, dropdown_h);
|
||||
/* Clip to menu area - expand to ensure bevel and highlights aren't clipped */
|
||||
int bevel_width = (int)(dpi_ui_scale() + 0.5f);
|
||||
if(bevel_width < 1) bevel_width = 1;
|
||||
int expand = bevel_width + ui_px(2); /* Extra expansion for hover highlights */
|
||||
BeginScissorMode(x - expand, dropdown_y - expand, w + expand * 2, dropdown_h + expand * 2);
|
||||
|
||||
/* Draw options */
|
||||
for(int i = 0; i < option_count; i++) {
|
||||
int option_y = dropdown_y + ui_px(4) + (i - state->scroll_offset) * option_h;
|
||||
Rectangle option_bounds = {x, option_y, w, option_h};
|
||||
|
||||
/* Skip if outside visible area */
|
||||
if(option_y + option_h < dropdown_y || option_y > dropdown_y + dropdown_h)
|
||||
/* Skip if outside visible area - use inclusive bounds for last item */
|
||||
if(option_y + option_h < dropdown_y || option_y >= dropdown_y + dropdown_h)
|
||||
continue;
|
||||
|
||||
int option_hover = CheckCollisionPointRec(mouse, option_bounds);
|
||||
@@ -653,6 +751,9 @@ ui_draw_dropdown_menu(InbeApp *app, int id)
|
||||
*selected_index = i;
|
||||
state->open = 0;
|
||||
state->just_opened = 0;
|
||||
changed = 1;
|
||||
EndScissorMode();
|
||||
goto draw_arrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -661,6 +762,9 @@ ui_draw_dropdown_menu(InbeApp *app, int id)
|
||||
|
||||
EndScissorMode();
|
||||
|
||||
draw_arrow:
|
||||
;
|
||||
|
||||
/* Redraw arrow on top of everything */
|
||||
int arrow_pad = ui_px(24);
|
||||
int arrow_size = ui_px(6);
|
||||
@@ -676,6 +780,7 @@ ui_draw_dropdown_menu(InbeApp *app, int id)
|
||||
int y2 = arrow_y + x_half;
|
||||
DrawLine(x1, y1, x2, y2, c_text);
|
||||
DrawLine(x1, y2, x2, y1, c_text);
|
||||
return changed;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -690,7 +795,7 @@ ui_nav_button_width(const char *label, int icon_size, int show_label, int font)
|
||||
}
|
||||
|
||||
int
|
||||
ui_draw_nav_button(InbeApp *app, int x, int y, int icon_size, Texture2D icon,
|
||||
ui_draw_nav_button(InbeApp *app, int x, int y, int icon_size, Texture2D icon, UIIconType icon_type,
|
||||
const char *label, int show_label, int *hover)
|
||||
{
|
||||
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
|
||||
@@ -725,6 +830,9 @@ ui_draw_nav_button(InbeApp *app, int x, int y, int icon_size, Texture2D icon,
|
||||
int icon_x = show_label && label && label[0] ? x + padding : x + (w - icon_size) / 2;
|
||||
Rectangle dst = {icon_x, y + padding, (float)icon_size, (float)icon_size};
|
||||
DrawTexturePro(icon, src, dst, (Vector2){0}, 0, c_icon);
|
||||
} else {
|
||||
int icon_x = show_label && label && label[0] ? x + padding : x + (w - icon_size) / 2;
|
||||
ui_draw_icon_fallback(icon_type, icon_x, y + padding, icon_size, c_icon);
|
||||
}
|
||||
|
||||
if(show_label && label != NULL && label[0] != '\0') {
|
||||
@@ -737,7 +845,7 @@ ui_draw_nav_button(InbeApp *app, int x, int y, int icon_size, Texture2D icon,
|
||||
}
|
||||
|
||||
int
|
||||
ui_draw_nav_button_expand(InbeApp *app, int x, int y, int icon_size, int w, Texture2D icon,
|
||||
ui_draw_nav_button_expand(InbeApp *app, int x, int y, int icon_size, int w, Texture2D icon, UIIconType icon_type,
|
||||
const char *label, int show_label, int *hover)
|
||||
{
|
||||
Vector2 mouse_world = GetScreenToWorld2D(GetMousePosition(), app->camera);
|
||||
@@ -771,6 +879,9 @@ ui_draw_nav_button_expand(InbeApp *app, int x, int y, int icon_size, int w, Text
|
||||
int icon_x = show_label && label && label[0] ? x + padding : x + (w - icon_size) / 2;
|
||||
Rectangle dst = {icon_x, y + padding, (float)icon_size, (float)icon_size};
|
||||
DrawTexturePro(icon, src, dst, (Vector2){0}, 0, c_icon);
|
||||
} else {
|
||||
int icon_x = show_label && label && label[0] ? x + padding : x + (w - icon_size) / 2;
|
||||
ui_draw_icon_fallback(icon_type, icon_x, y + padding, icon_size, c_icon);
|
||||
}
|
||||
|
||||
if(show_label && label != NULL && label[0] != '\0') {
|
||||
@@ -839,12 +950,10 @@ ui_draw_tab_bar(UITab *tabs, int count, InbeApp *app)
|
||||
int base_w = ui_nav_button_width(tabs[i].label, button_size, show_labels, font);
|
||||
int w = base_w + extra_per_button;
|
||||
|
||||
if(tabs[i].icon.id != 0) {
|
||||
if(ui_draw_nav_button_expand(app, x, button_y, button_size, w, tabs[i].icon,
|
||||
if(ui_draw_nav_button_expand(app, x, button_y, button_size, w, tabs[i].icon, tabs[i].icon_type,
|
||||
tabs[i].label, show_labels, &tab_hover)) {
|
||||
if(tabs[i].on_click)
|
||||
tabs[i].on_click(tabs[i].user_data);
|
||||
}
|
||||
if(tabs[i].on_click)
|
||||
tabs[i].on_click(tabs[i].user_data);
|
||||
}
|
||||
|
||||
x += w + group_gap;
|
||||
@@ -923,54 +1032,17 @@ ui_draw_modal(InbeApp *app, const char *title, const char *message,
|
||||
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;
|
||||
/* Message (text layout with icon support) */
|
||||
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++;
|
||||
}
|
||||
/* Parse message with icon support - use GEAR icon for warnings */
|
||||
TextLayout msg_layout = ui_text_layout_parse(message, app->gear_icon, UI_ICON_TYPE_GEAR, msg_font);
|
||||
ui_text_layout_reflow(&msg_layout, msg_w, msg_font, msg_font + ui_px(4));
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
/* Draw the layout */
|
||||
ui_text_layout_draw(&msg_layout, msg_x, &msg_y, msg_font, c_text);
|
||||
ui_text_layout_free(&msg_layout);
|
||||
|
||||
/* Buttons */
|
||||
int cancel_x = modal_x + (modal_w - btn_w * 2 - btn_gap) / 2;
|
||||
@@ -1041,54 +1113,17 @@ ui_draw_modal_3btn(InbeApp *app, const char *title, const char *message,
|
||||
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;
|
||||
/* Message (text layout with icon support) */
|
||||
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++;
|
||||
}
|
||||
/* Parse message with icon support - use GEAR icon for warnings */
|
||||
TextLayout msg_layout = ui_text_layout_parse(message, app->gear_icon, UI_ICON_TYPE_GEAR, msg_font);
|
||||
ui_text_layout_reflow(&msg_layout, msg_w, msg_font, msg_font + ui_px(4));
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
/* Draw the layout */
|
||||
ui_text_layout_draw(&msg_layout, msg_x, &msg_y, msg_font, c_text);
|
||||
ui_text_layout_free(&msg_layout);
|
||||
|
||||
/* Calculate button positions */
|
||||
int total_btn_w = btn_w * 3 + btn_gap * 2;
|
||||
@@ -1174,12 +1209,131 @@ ui_draw_screen_header(InbeApp *app, const char *title, int show_close)
|
||||
/* 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);
|
||||
UI_ICON_SIZE_TINY, app->x_icon, UI_ICON_TYPE_X, &close_hover);
|
||||
}
|
||||
|
||||
return close_clicked;
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
* TEXT LAYOUT UTILITIES
|
||||
* ================================================================ */
|
||||
|
||||
TextLayout
|
||||
ui_text_layout_parse(const char *input, Texture2D icon, UIIconType icon_type, int icon_size)
|
||||
{
|
||||
return text_layout_parse(input, icon, icon_type, icon_size);
|
||||
}
|
||||
|
||||
void
|
||||
ui_text_layout_reflow(TextLayout *layout, int max_width, int font_size, int line_height)
|
||||
{
|
||||
text_layout_reflow(layout, max_width, font_size, line_height);
|
||||
}
|
||||
|
||||
void
|
||||
ui_text_layout_draw(TextLayout *layout, int x, int *y, int font_size, Color color)
|
||||
{
|
||||
text_layout_draw(layout, x, y, font_size, color);
|
||||
}
|
||||
|
||||
int
|
||||
ui_text_layout_get_height(TextLayout *layout)
|
||||
{
|
||||
return text_layout_get_height(layout);
|
||||
}
|
||||
|
||||
void
|
||||
ui_text_layout_free(TextLayout *layout)
|
||||
{
|
||||
text_layout_free(layout);
|
||||
}
|
||||
|
||||
void
|
||||
ui_text_layout_reflow_if_needed(TextLayout *layout, int max_width)
|
||||
{
|
||||
if(layout == NULL || layout->last_reflow_width != max_width) {
|
||||
ui_text_layout_reflow(layout, max_width, ui_clamp_px(14, 12, 16), ui_clamp_px(18, 16, 20));
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
* SCROLLBAR
|
||||
* ================================================================ */
|
||||
|
||||
int
|
||||
ui_draw_scrollbar(InbeApp *app, int x, int y, int viewport_h, int content_h, int *scroll_offset, int max_scroll)
|
||||
{
|
||||
/* Don't show scrollbar if no scrolling needed */
|
||||
if(max_scroll <= 0)
|
||||
return 0;
|
||||
|
||||
static int scrollbar_drag_active = 0;
|
||||
static int scrollbar_drag_start_y = 0;
|
||||
static int scrollbar_drag_start_scroll = 0;
|
||||
|
||||
int scrollbar_width = ui_px(8);
|
||||
int scrollbar_min_thumb = ui_px(24);
|
||||
int track_padding = ui_px(2);
|
||||
|
||||
/* Calculate thumb size and position */
|
||||
float content_ratio = (float)viewport_h / (float)content_h;
|
||||
int thumb_height = (int)(viewport_h * content_ratio);
|
||||
if(thumb_height < scrollbar_min_thumb)
|
||||
thumb_height = scrollbar_min_thumb;
|
||||
if(thumb_height > viewport_h)
|
||||
thumb_height = viewport_h;
|
||||
|
||||
float scroll_ratio = max_scroll > 0 ? (float)*scroll_offset / (float)max_scroll : 0.0f;
|
||||
int thumb_y = y + (int)(scroll_ratio * (viewport_h - thumb_height));
|
||||
|
||||
/* Get mouse position in screen coordinates (not world coordinates) */
|
||||
Vector2 mouse_pos = GetMousePosition();
|
||||
int my = (int)mouse_pos.y;
|
||||
|
||||
/* Thumb bounds in screen coordinates */
|
||||
Rectangle thumb_bounds = {x + track_padding, thumb_y, scrollbar_width - track_padding * 2, thumb_height};
|
||||
|
||||
/* Check for hover */
|
||||
int thumb_hover = CheckCollisionPointRec(mouse_pos, thumb_bounds);
|
||||
|
||||
/* Handle drag state */
|
||||
if(IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
|
||||
if(!scrollbar_drag_active) {
|
||||
/* Start drag if clicking on thumb */
|
||||
if(thumb_hover) {
|
||||
scrollbar_drag_active = 1;
|
||||
scrollbar_drag_start_y = my;
|
||||
scrollbar_drag_start_scroll = *scroll_offset;
|
||||
}
|
||||
} else {
|
||||
/* Continue drag */
|
||||
int dy = my - scrollbar_drag_start_y;
|
||||
float scroll_per_pixel = (float)max_scroll / (float)(viewport_h - thumb_height);
|
||||
int new_scroll = scrollbar_drag_start_scroll + (int)(dy * scroll_per_pixel);
|
||||
*scroll_offset = new_scroll;
|
||||
if(*scroll_offset < 0) *scroll_offset = 0;
|
||||
if(*scroll_offset > max_scroll) *scroll_offset = max_scroll;
|
||||
}
|
||||
} else {
|
||||
scrollbar_drag_active = 0;
|
||||
}
|
||||
|
||||
/* Draw track */
|
||||
DrawRectangle(x, y, scrollbar_width, viewport_h, ui_darken(c_bg, 20));
|
||||
|
||||
/* Draw thumb */
|
||||
Color thumb_color = thumb_hover || scrollbar_drag_active ? c_button_hover : ui_lighten(c_button, 20);
|
||||
DrawRectangleRec(thumb_bounds, thumb_color);
|
||||
|
||||
/* Draw bevel on thumb */
|
||||
ui_draw_bevel((int)thumb_bounds.x, (int)thumb_bounds.y,
|
||||
(int)thumb_bounds.width, (int)thumb_bounds.height,
|
||||
ui_darken(thumb_color, 40), ui_lighten(thumb_color, 40));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
* END OF UI FUNCTIONS
|
||||
* ================================================================ */
|
||||
+42
-7
@@ -11,6 +11,24 @@ typedef enum {
|
||||
UI_ICON_SIZE_LARGE
|
||||
} UIIconSize;
|
||||
|
||||
typedef enum {
|
||||
UI_ICON_TYPE_NONE,
|
||||
UI_ICON_TYPE_GEAR,
|
||||
UI_ICON_TYPE_X,
|
||||
UI_ICON_TYPE_MANUAL,
|
||||
UI_ICON_TYPE_RETURN,
|
||||
UI_ICON_TYPE_BACKWARD,
|
||||
UI_ICON_TYPE_FORWARD,
|
||||
UI_ICON_TYPE_PLAY,
|
||||
UI_ICON_TYPE_PAUSE,
|
||||
UI_ICON_TYPE_STAT,
|
||||
UI_ICON_TYPE_TELEGRAM,
|
||||
UI_ICON_TYPE_GLOBE,
|
||||
UI_ICON_TYPE_STRIPE,
|
||||
UI_ICON_TYPE_MONERO,
|
||||
UI_ICON_TYPE_HOME
|
||||
} UIIconType;
|
||||
|
||||
void ui_init(int width, int height, float dpi);
|
||||
void ui_set_colors(Color text, Color bg, Color circle, Color button, Color button_hover, Color icon);
|
||||
int ui_px(int px);
|
||||
@@ -20,21 +38,24 @@ Color ui_darken(Color c, int amount);
|
||||
void ui_centered_column(int max_w, int side_pad, int *x, int *w);
|
||||
void ui_draw_bevel(int x, int y, int w, int h, Color light, Color dark);
|
||||
void ui_draw_text_lines(const char **lines, int count, int x, int *y, int font, int line_h);
|
||||
void ui_draw_icon_fallback(UIIconType type, int x, int y, int size, Color color);
|
||||
int ui_icon_btn_size(UIIconSize size);
|
||||
int ui_icon_btn_padding(UIIconSize size);
|
||||
int ui_draw_icon_btn(InbeApp *app, int x, int y, UIIconSize size, Texture2D icon, int *hover);
|
||||
int ui_draw_icon_btn_padded(InbeApp *app, int x, int y, int size, Texture2D icon, int *hover);
|
||||
int ui_draw_icon_btn(InbeApp *app, int x, int y, UIIconSize size, Texture2D icon, UIIconType icon_type, int *hover);
|
||||
int ui_draw_icon_btn_padded(InbeApp *app, int x, int y, int size, Texture2D icon, UIIconType icon_type, 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);
|
||||
void ui_draw_icon_link(InbeApp *app, int x, int y, int icon_size, Texture2D icon, UIIconType icon_type, const char *url);
|
||||
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);
|
||||
int ui_draw_toggle_switch(InbeApp *app, int x, int y, int w, int h, int *value,
|
||||
const char *off_label, const char *on_label);
|
||||
int ui_draw_checkbox_toggle(InbeApp *app, int x, int y, const char *label, int *value);
|
||||
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);
|
||||
int ui_draw_dropdown_menu(InbeApp *app, int id);
|
||||
int ui_dropdown_captures_click(Vector2 point);
|
||||
typedef struct UITab {
|
||||
const char *label;
|
||||
Texture2D icon;
|
||||
UIIconType icon_type;
|
||||
void (*on_click)(void *user_data);
|
||||
void *user_data;
|
||||
} UITab;
|
||||
@@ -45,8 +66,8 @@ typedef struct UITabBar {
|
||||
} UITabBar;
|
||||
|
||||
int ui_nav_button_width(const char *label, int icon_size, int show_label, int font);
|
||||
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);
|
||||
int ui_draw_nav_button(InbeApp *app, int x, int y, int icon_size, Texture2D icon, UIIconType icon_type, 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, UIIconType icon_type, const char *label, int show_label, int *hover);
|
||||
void ui_draw_tab_bar(UITab *tabs, int count, InbeApp *app);
|
||||
void ui_draw_tutorial_image_placeholder(const char *label, int x, int y, int w, int h);
|
||||
void ui_draw_tutorial_image(Texture2D texture, const char *fallback, int x, int y, int w, int h);
|
||||
@@ -54,5 +75,19 @@ int ui_draw_modal(InbeApp *app, const char *title, const char *message, const ch
|
||||
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);
|
||||
int ui_draw_scrollbar(InbeApp *app, int x, int y, int viewport_h, int content_h, int *scroll_offset, int max_scroll);
|
||||
|
||||
/* ================================================================
|
||||
* TEXT LAYOUT UTILITIES
|
||||
* ================================================================ */
|
||||
|
||||
typedef struct TextLayout TextLayout;
|
||||
|
||||
TextLayout ui_text_layout_parse(const char *input, Texture2D icon, UIIconType icon_type, int icon_size);
|
||||
void ui_text_layout_reflow(TextLayout *layout, int max_width, int font_size, int line_height);
|
||||
void ui_text_layout_draw(TextLayout *layout, int x, int *y, int font_size, Color color);
|
||||
int ui_text_layout_get_height(TextLayout *layout);
|
||||
void ui_text_layout_free(TextLayout *layout);
|
||||
void ui_text_layout_reflow_if_needed(TextLayout *layout, int max_width);
|
||||
|
||||
#endif
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
|
||||
#define INBE_VERSION_MAJOR 1
|
||||
#define INBE_VERSION_MINOR 1
|
||||
#define INBE_VERSION_PATCH 2
|
||||
#define INBE_VERSION_STRING "1.1.2"
|
||||
#define INBE_VERSION_PATCH 7
|
||||
#define INBE_VERSION_STRING "1.1.7"
|
||||
|
||||
#endif
|
||||
@@ -93,6 +93,15 @@ img {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.version {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
color: var(--dark);
|
||||
margin: 8px 0 16px 0;
|
||||
opacity: 0.7;
|
||||
font-family: departure;
|
||||
}
|
||||
|
||||
.tk-img {
|
||||
border: 2px solid var(--dark);
|
||||
border-right-color: var(--button-highlight);
|
||||
@@ -383,3 +392,189 @@ div.noscript a {
|
||||
text-decoration: underline;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Features section styling - retro tk look */
|
||||
.features-section {
|
||||
margin: 32px 0;
|
||||
}
|
||||
|
||||
.features-section h2 {
|
||||
margin-bottom: 16px;
|
||||
color: var(--dark);
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.features-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.feature-item {
|
||||
padding: 12px;
|
||||
background-color: var(--panel-bg);
|
||||
border: 2px solid var(--button-highlight);
|
||||
border-right-color: var(--dark);
|
||||
border-bottom-color: var(--dark);
|
||||
box-shadow:
|
||||
1px 1px 0 0 var(--shadow),
|
||||
inset 1px 1px 0 0 var(--button-inset);
|
||||
font-family: departure;
|
||||
}
|
||||
|
||||
.feature-item h3 {
|
||||
margin: 0 0 8px 0;
|
||||
font-size: 14px;
|
||||
color: var(--dark);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.feature-item p {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.3;
|
||||
color: var(--dark);
|
||||
}
|
||||
|
||||
/* About section - retro tk look */
|
||||
.about-section {
|
||||
margin: 32px 0;
|
||||
}
|
||||
|
||||
.about-section h2 {
|
||||
margin-bottom: 12px;
|
||||
color: var(--dark);
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.about-section p {
|
||||
margin: 12px 0;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.benefits-list {
|
||||
padding-left: 20px;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.benefits-list li {
|
||||
margin-bottom: 6px;
|
||||
line-height: 1.3;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.safety-note {
|
||||
font-size: 12px;
|
||||
opacity: 0.7;
|
||||
margin-top: 12px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* Info section with dropdowns - retro tk look */
|
||||
.info-section {
|
||||
margin: 32px 0;
|
||||
}
|
||||
|
||||
.dropdown {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.dropdown summary {
|
||||
cursor: url('cursors/sight.png') 0 0, pointer;
|
||||
font-weight: bold;
|
||||
padding: 8px 12px;
|
||||
background-color: var(--button-bg);
|
||||
border: 2px solid var(--button-highlight);
|
||||
border-right-color: var(--dark);
|
||||
border-bottom-color: var(--dark);
|
||||
box-shadow:
|
||||
1px 1px 0 0 var(--shadow),
|
||||
inset 1px 1px 0 0 var(--button-inset);
|
||||
font-family: departure;
|
||||
}
|
||||
|
||||
.dropdown[open] summary {
|
||||
border-color: var(--dark);
|
||||
border-right-color: var(--button-highlight);
|
||||
border-bottom-color: var(--button-highlight);
|
||||
box-shadow:
|
||||
1px 1px 0 0 var(--button-highlight),
|
||||
inset 1px 1px 0 0 var(--shadow);
|
||||
}
|
||||
|
||||
.dropdown-content {
|
||||
padding: 12px;
|
||||
background-color: var(--panel-bg);
|
||||
border: 2px solid var(--dark);
|
||||
border-right-color: var(--button-highlight);
|
||||
border-bottom-color: var(--button-highlight);
|
||||
margin-top: 8px;
|
||||
box-shadow:
|
||||
1px 1px 0 0 var(--shadow),
|
||||
inset 1px 1px 0 0 var(--button-inset);
|
||||
}
|
||||
|
||||
.dropdown-content p {
|
||||
margin-bottom: 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.dropdown-links {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.dropdown-links a {
|
||||
color: var(--link);
|
||||
text-decoration: none;
|
||||
padding: 6px 12px;
|
||||
background-color: var(--button-bg);
|
||||
border: 1px solid var(--dark);
|
||||
font-family: departure;
|
||||
font-size: 13px;
|
||||
cursor: url('cursors/sight.png') 0 0, pointer;
|
||||
}
|
||||
|
||||
.dropdown-links a:hover {
|
||||
background-color: var(--button-highlight);
|
||||
}
|
||||
|
||||
section h2 {
|
||||
margin-top: 32px;
|
||||
margin-bottom: 16px;
|
||||
color: var(--dark);
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
section ul {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
section ul li {
|
||||
margin-bottom: 8px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* Improved responsive design */
|
||||
@media (max-width: 768px) {
|
||||
.content {
|
||||
padding: 12px 16px;
|
||||
margin: 8px auto;
|
||||
}
|
||||
|
||||
.platform-buttons {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.platform-btn {
|
||||
width: 100px;
|
||||
padding: 12px 8px;
|
||||
}
|
||||
|
||||
.features-list li {
|
||||
padding: 10px 12px;
|
||||
}
|
||||
}
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
# update_metadata.sh - Simple version update for website
|
||||
# This runs automatically before publish to keep version info current
|
||||
|
||||
set -e
|
||||
|
||||
# Extract version from CHANGELOG.md
|
||||
get_version() {
|
||||
if [ -f "CHANGELOG.md" ]; then
|
||||
grep '^## \[' CHANGELOG.md | head -n 1 | sed 's/^## \[\([^]]*\)\].*/\1/'
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "=== Updating Build Metadata ==="
|
||||
|
||||
# Get current version
|
||||
VERSION=$(get_version)
|
||||
echo "Current version: $VERSION"
|
||||
|
||||
# Update index.html
|
||||
if [ -f "index.html" ]; then
|
||||
echo "Updating index.html..."
|
||||
|
||||
# Create backup
|
||||
cp index.html index.html.bak
|
||||
|
||||
# Update version placeholder
|
||||
sed -i "s|VERSION_PLACEHOLDER|$VERSION|g" index.html
|
||||
|
||||
echo "✓ index.html updated with version $VERSION"
|
||||
else
|
||||
echo "Warning: index.html not found"
|
||||
fi
|
||||
|
||||
# Update builds.html if it exists
|
||||
if [ -f "builds.html" ]; then
|
||||
echo "Updating builds.html..."
|
||||
|
||||
# Create backup
|
||||
cp builds.html builds.html.bak
|
||||
|
||||
# Update version placeholder
|
||||
sed -i "s|VERSION_PLACEHOLDER|$VERSION|g" builds.html
|
||||
|
||||
echo "✓ builds.html updated with version $VERSION"
|
||||
else
|
||||
echo "builds.html not found, skipping"
|
||||
fi
|
||||
|
||||
echo "=== Metadata Update Complete ==="
|
||||
Reference in new issue
Block a user