Skip to content

Commit

Permalink
android add video support, optimize ui
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriSizuku committed Feb 26, 2023
1 parent 1769bdc commit 0d27099
Show file tree
Hide file tree
Showing 20 changed files with 202 additions and 136 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ jobs:
cache: gradle

- name: build onsyuri_android
env:
SIGN_KEY_ALIAS: ${{ secrets.SIGN_KEY_ALIAS }}
SIGN_KEY_PASS: ${{ secrets.SIGN_KEY_PASS }}
SIGN_STORE_PASS: ${{ secrets.SIGN_STORE_PASS }}
run: cd script && bash ./cross_android.sh

- name: prepare to release
run: cp ./build_android/outputs/apk/debug/*.apk ${{ env.BUILD_NAME }}.apk
run: cp ./build_android/outputs/apk/release/*.apk ${{ env.BUILD_NAME }}.apk

- name: create release
uses: ncipollo/release-action@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ script/*.json

# android
local.properties
sign.properties
src/onsyuri_android/.gradle
src/onsyuri_android/local.properties
src/onsyuri_android/.idea/caches
Expand Down
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,43 @@ Online Onscripter game demo: [lifegame](https://blog.schnee.moe/static/lifegame.

![onsyuri_webtest_mo2](screenshot/onsyuri_mo2_webtest.png)

New features or plans:
New features :

- develop
- [x] clear camke project structure
- [x] well documention for develop and usage
- [x] scripts to compile or cross compile without pain
- [x] vscode project for multi enviroment
- [x] vscode and android studio project for multi enviroment
- [x] ci in github action to automaticly build
- platform
- [x] windows
- [x] x86, x64 (local compile by msys2, static link)
- [x] x86, x64 (corss compile by mingw64, mingw32 from linux, static link)
- [x] x86, x64 (local or cross compile by mingw, static link)
- [x] lua script and animation
- [x] video by system player
- [x] linux
- [x] x86, x64 (local compile, static or dynamic link)
- [x] arm, aarch64 (cross compile, SDL2 build from raspberrypi, static link)
- [x] lua scirpt and animation
- [x] web (by emscripten)
- [x] fs to save in indexdb
- [x] web lua script support
- [x] lazy load by ~~BrowserFS or worker~~ async fetch to avoid block the audio
- [x] support mobile web with touch, with webui menu
- [x] lua script and animation
- [x] mobile web with touch, with webui menu
- [x] android
- [x] support SDK level above 21 (android 5.1, Lolipop)
- [x] support extern SD card by [SAF](https://github.com/YuriSizuku/android-SafFile)
- [x] support non-english charactor in path
- [x] SDK level above 21 (android 5.1, Lolipop)
- [x] extern SD card by [SAF](https://github.com/YuriSizuku/android-SafFile), and scoped storage
- [x] non-english charactor in path
- [x] lua script and animation
- [x] video by system player
- [x] psv, see [psv-Onscripter](https://github.com/YuriSizuku/psv-OnscripterJH)
- render
- [x] support fullscreen by `--fullscreen` or `alt+enter`, scretch to fullscreen by `--fullscreen2` or `f10`
- [x] support arbitary resolution `--width`, `--height`
- [x] fullscreen by `--fullscreen` or `alt+enter`, scretch to fullscreen by `--fullscreen2` or `f10`
- [x] arbitary resolution `--width`, `--height`
- [x] gles2 sharpness rendering by `--sharpness 1.0` parameter, fix bug on windows
- other
- [x] support `nt2`, `nt3` encryption format by Mine
- [x] support long click or touch to invoke menu
- [x] `nt2`, `nt3` script encryption (Mine exclusive format)
- [x] long click or touch to invoke menu
- onsjh bug fix
- [x] fix some bugs in origin version (can not read `00.txt` problem)
- [x] fix lua animation problem
- [x] fix android onresume gles null pointer
Expand Down Expand Up @@ -116,6 +121,8 @@ onsyuri_index.json

```
![onsyuri_mo2_webtest3](screenshot/onsyuri_mo2_webtest3.jpg)
It will load the game according to `onsyuri_index.json`, whitch is deifned by `<meta onsyuri_index="onsyuri_index.json">` in `onsyuri.html`.
``` json
Expand All @@ -136,16 +143,14 @@ It will load the game according to `onsyuri_index.json`, whitch is deifned by `<
This can be generated by `onsyuri_index.py`.
![onsyuri_mo2_webtest3](screenshot/onsyuri_mo2_webtest3.jpg)
~~Futhremoe, use `make_xhrfs_index > onsyuri_lazyload.json` after `npm i -g browserfs`~~ deprecated.
### (4) android
Install the apk, use `3 figures|long touch` for invoke menu, `4 figures` to invoke skip.
You can either put game into `/storage/emulated/0/Android/data/com.yuri.onscripter/files`, or any directory by `saf`.
![onsyuri_ui_androidtest1](screenshot/onsyuri_ui_androidtest1.jpg)
![onsyuri_ui_androidtest1](screenshot/onsyuri_ui_androidtest2.jpg)
## 2. Build
Expand Down Expand Up @@ -296,5 +301,5 @@ chmod +x ./gradlew && ./gradlew assembleDebug
## 5. Todo
- video support (future plan)
- preloading (future plan)
- ~~video support (future plan)~~ partly finish by invoke system player
- web preloading (future plan)
Binary file added screenshot/onsyuri_ui_androidtest2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion script/cross_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fi

# config and build project
if [ -z "$BUILD_TYPE" ]; then BUILD_TYPE=MinSizeRel; fi
if [ -z "$TARGETS" ]; then TARGETS=assembleDebug; fi
if [ -z "$TARGETS" ]; then TARGETS=assembleRelease; fi

pushd ${CMAKELISTS_PATH}/src/onsyuri_android
echo "ANDROID_HOME=$ANDROID_HOME"
Expand Down
59 changes: 30 additions & 29 deletions src/onsyuri/ONScripter_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,6 @@ int ONScripter::playMPEG(const char *filename, bool click_flag, bool loop_flag)
return 0;
}

#ifdef ANDROID
playVideoAndroid(filename);
return 0;
#endif

#ifdef IOS
char *absolute_filename = new char[ strlen(archive_path) + strlen(filename) + 1 ];
sprintf( absolute_filename, "%s%s", archive_path, filename );
playVideoIOS(absolute_filename, click_flag, loop_flag);
delete[] absolute_filename;
#endif

int ret = 0;
#if defined(USE_SMPEG)
stopSMPEG();
Expand Down Expand Up @@ -372,17 +360,24 @@ int ONScripter::playMPEG(const char *filename, bool click_flag, bool loop_flag)
delete[] pixel_buf;
SDL_DestroyMutex(oi.mutex);
texture = SDL_CreateTextureFromSurface(renderer, accumulation_surface);
#elif !defined(WINRT) && (defined(WIN32) || defined(_WIN32))
char filename2[256];
strcpy(filename2, filename);
for (unsigned int i=0; i<strlen(filename2); i++)
if (filename2[i] == '/' || filename2[i] == '\\')
filename2[i] = DELIMITER;
system(filename2);
#elif !defined(IOS)
#else
char *absolute_filename = new char[ strlen(archive_path) + strlen(filename) + 1 ];
sprintf( absolute_filename, "%s%s", archive_path, filename );
for (int i=0;i<strlen( absolute_filename );i++) {
if ( absolute_filename[i] == '/' || absolute_filename[i] == '\\' )
absolute_filename[i] = DELIMITER;
}
#if !defined(WINRT) && (defined(WIN32) || defined(_WIN32))
system(absolute_filename);
#elif defined(IOS)
playVideoIOS(absolute_filename, click_flag, loop_flag);
#elif defined(ANDROID)
playVideoAndroid(absolute_filename);
#else
utils::printError( "mpegplay command is disabled.\n" );
#endif

delete[] absolute_filename;
#endif
return ret;
}

Expand All @@ -399,18 +394,24 @@ int ONScripter::playAVI( const char *filename, bool click_flag )
return 0;
}

#ifdef ANDROID
playVideoAndroid(filename);
return 0;
#endif

int ret = 0;
char *absolute_filename = new char[ strlen(archive_path) + strlen(filename) + 1 ];
sprintf( absolute_filename, "%s%s", archive_path, filename );
for (int i=0;i<strlen( absolute_filename );i++) {
if ( absolute_filename[i] == '/' || absolute_filename[i] == '\\' )
absolute_filename[i] = DELIMITER;
}
#if !defined(WINRT) && (defined(WIN32) || defined(_WIN32))
system(filename);
system(absolute_filename);
#elif defined(IOS)
playVideoIOS(absolute_filename, click_flag, loop_flag);
#elif defined(ANDROID)
playVideoAndroid(absolute_filename);
#else
utils::printError( "avi command is disabled.\n" );
#endif

return 0;
delete[] absolute_filename;
return ret;
}

void ONScripter::stopBGM( bool continue_flag )
Expand Down
2 changes: 1 addition & 1 deletion src/onsyuri/onscripter_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ int main(int argc, char *argv[])
argv++;
parseOption(argc - 1, argv);

utils::printInfo("ONScripter Yuri %s, (Jh %s, Ons %s, %d.%02d)\n",
utils::printInfo("ONScripter Yuri %s, (Jh%s,Ons%s,NSC%d.%02d)\n",
ONS_YURI_VERSION, ONS_JH_VERSION,
ONS_VERSION, NSC_VERSION / 100, NSC_VERSION % 100);

Expand Down
2 changes: 1 addition & 1 deletion src/onsyuri/version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define ONS_YURI_VERSION "0.7.1"
#define ONS_JH_VERSION "0.8.0"
#define ONS_YURI_VERSION "0.7.0"
#define ONS_VERSION "20181218"
#define NSC_VERSION 296
1 change: 1 addition & 0 deletions src/onsyuri_android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 0 additions & 25 deletions src/onsyuri_android/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion src/onsyuri_android/app/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
Expand All @@ -26,6 +27,15 @@
android:screenOrientation="sensorLandscape"
android:configChanges="screenSize|orientation|keyboardHidden">
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
</application>

</manifest>
18 changes: 17 additions & 1 deletion src/onsyuri_android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,36 @@ android {
}
}
versionCode 1
versionName '0.7'
versionName '0.7.1'
}
signingConfigs {
release {
storeFile file('sign.jks')
def signPropsFile = file('sign.properties')
if (signPropsFile.exists()) {
Properties signProps = new Properties()
signProps.load(new FileInputStream(signPropsFile))
keyAlias signProps['SIGN_KEY_ALIAS']
keyPassword signProps['SIGN_KEY_PASS']
storePassword signProps['SIGN_STORE_PASS']
}
else {
keyAlias System.getenv("SIGN_KEY_ALIAS")
keyPassword System.getenv("SIGN_KEY_PASS")
storePassword System.getenv("SIGN_STORE_PASS")
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
debuggable true
signingConfig signingConfigs.release
}
}

Expand Down
Loading

0 comments on commit 0d27099

Please sign in to comment.