Android version bug fix
This commit is contained in:
parent
2add42c1cb
commit
5cbe7a345e
23
Readme.md
23
Readme.md
@ -203,3 +203,26 @@ CPack Error: Cannot initialize the generator NSIS
|
|||||||
|
|
||||||
То нужно установить nsis отсюда: https://nsis.sourceforge.io/Download
|
То нужно установить nsis отсюда: https://nsis.sourceforge.io/Download
|
||||||
|
|
||||||
|
|
||||||
|
# Steam windows
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake -DSTEAMSDK=ON ..
|
||||||
|
cmake --build . --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
# Steam Linux
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -it --rm -v "${PWD}:/work2" -w /work2 registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest bash
|
||||||
|
|
||||||
|
|
||||||
|
apt-get update
|
||||||
|
apt-get install libboost-dev libeigen3-dev liblua5.4-dev libzip-dev libglu1-mesa-dev
|
||||||
|
|
||||||
|
|
||||||
|
cmake -DSTEAMSDK=ON -DCMAKE_BUILD_TYPE=Release ..
|
||||||
|
cmake --build . -j 4
|
||||||
|
|
||||||
|
```
|
||||||
|
|||||||
127
optimize_android_resources.py
Normal file
127
optimize_android_resources.py
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
optimize_web_resources.py - Resize PNG images for the web build.
|
||||||
|
|
||||||
|
Copies <src> to <dst>/resources/, then downscales all PNG files:
|
||||||
|
- resources/w/ui/img/** -> 1/8 original size
|
||||||
|
- all other PNGs -> 1/4 original size
|
||||||
|
|
||||||
|
Files listed in EXCEPTIONS are copied unchanged.
|
||||||
|
|
||||||
|
Usage (manual):
|
||||||
|
python optimize_web_resources.py [--src resources] [--dst web_resources]
|
||||||
|
|
||||||
|
Usage (CMake):
|
||||||
|
${Python3_EXECUTABLE} optimize_web_resources.py --src <abs_src> --dst <abs_dst>
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
try:
|
||||||
|
from PIL import Image
|
||||||
|
except ImportError:
|
||||||
|
raise SystemExit("Pillow is required: pip install Pillow")
|
||||||
|
|
||||||
|
# Paths relative to the resources directory — these files are never resized.
|
||||||
|
EXCEPTIONS = {
|
||||||
|
"loading.png",
|
||||||
|
"loading_land003_en.png",
|
||||||
|
"loading_land003_ru.png",
|
||||||
|
"black.png",
|
||||||
|
"transparent.png",
|
||||||
|
"w/blue.png",
|
||||||
|
"w/red.png",
|
||||||
|
"w/spark.png",
|
||||||
|
"w/star.png",
|
||||||
|
"w/star_red.png",
|
||||||
|
"w/white.png",
|
||||||
|
"w/ui/img/main/aboutPage003android.png",
|
||||||
|
"w/ui_en/img/main/aboutPage003android.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Path prefixes (relative to resources root, forward-slash) that get 8x reduction.
|
||||||
|
HIGH_REDUCTION_PREFIXES = (
|
||||||
|
"w/ui/img",
|
||||||
|
)
|
||||||
|
|
||||||
|
LOW_REDUCTION_POSTFIXES = (
|
||||||
|
"texAtlas002.png",
|
||||||
|
"Building_work014.png",
|
||||||
|
"Building_Floors_tex004.png",
|
||||||
|
"Building_Walls_tex006.png",
|
||||||
|
"asphalt003small.png",
|
||||||
|
"Ext_Building004.png",
|
||||||
|
"Plane3_tex002.png",
|
||||||
|
"darklands_building002.png",
|
||||||
|
"Staircase001.png",
|
||||||
|
"Staircase_Obj002.png"
|
||||||
|
)
|
||||||
|
|
||||||
|
def _resize_factor(rel: str) -> int:
|
||||||
|
norm = rel.replace("\\", "/")
|
||||||
|
for prefix in HIGH_REDUCTION_PREFIXES:
|
||||||
|
if norm.startswith(prefix):
|
||||||
|
return 4
|
||||||
|
for prefix in LOW_REDUCTION_POSTFIXES:
|
||||||
|
if norm.endswith(prefix):
|
||||||
|
return 1
|
||||||
|
return 4
|
||||||
|
|
||||||
|
|
||||||
|
def _next_pot(n: int) -> int:
|
||||||
|
if n < 1:
|
||||||
|
return 1
|
||||||
|
p = 1
|
||||||
|
while p < n:
|
||||||
|
p <<= 1
|
||||||
|
return p
|
||||||
|
|
||||||
|
|
||||||
|
def optimize(src_dir: str, dst_parent: str) -> None:
|
||||||
|
src_dir = os.path.abspath(src_dir)
|
||||||
|
dst_resources = os.path.join(os.path.abspath(dst_parent), "resources")
|
||||||
|
|
||||||
|
print(f"Copying {src_dir} -> {dst_resources}")
|
||||||
|
if os.path.exists(dst_resources):
|
||||||
|
shutil.rmtree(dst_resources)
|
||||||
|
shutil.copytree(src_dir, dst_resources)
|
||||||
|
|
||||||
|
total = 0
|
||||||
|
for root, _dirs, files in os.walk(dst_resources):
|
||||||
|
for filename in files:
|
||||||
|
if not filename.lower().endswith(".png"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
full_path = os.path.join(root, filename)
|
||||||
|
rel = os.path.relpath(full_path, dst_resources).replace("\\", "/")
|
||||||
|
|
||||||
|
if rel in EXCEPTIONS:
|
||||||
|
print(f" skip (exception): {rel}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
factor = _resize_factor(rel)
|
||||||
|
|
||||||
|
with Image.open(full_path) as img:
|
||||||
|
orig_w, orig_h = img.size
|
||||||
|
new_w = _next_pot(max(1, orig_w // factor))
|
||||||
|
new_h = _next_pot(max(1, orig_h // factor))
|
||||||
|
resized = img.resize((new_w, new_h), Image.LANCZOS)
|
||||||
|
resized.save(full_path)
|
||||||
|
|
||||||
|
print(f" {rel}: {orig_w}x{orig_h} -> {new_w}x{new_h} (/{factor} + POT)")
|
||||||
|
total += 1
|
||||||
|
|
||||||
|
print(f"Done. Resized {total} PNG file(s).")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser(description="Optimize PNG images for web build")
|
||||||
|
parser.add_argument("--src", default="resources",
|
||||||
|
help="Source resources directory (default: resources)")
|
||||||
|
parser.add_argument("--dst", default="web_resources",
|
||||||
|
help="Destination parent directory; will contain a 'resources' subdir "
|
||||||
|
"(default: web_resources)")
|
||||||
|
args = parser.parse_args()
|
||||||
|
optimize(args.src, args.dst)
|
||||||
3
proj-android/.gitignore
vendored
3
proj-android/.gitignore
vendored
@ -61,6 +61,5 @@ app/jni/libpng
|
|||||||
app/jni/SDL
|
app/jni/SDL
|
||||||
app/jni/zlib
|
app/jni/zlib
|
||||||
|
|
||||||
app/src/main/assets/resources
|
app/src/main/assets
|
||||||
app/src/main/assets/audio
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY');
|
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY')
|
||||||
def buildAsApplication = !buildAsLibrary
|
def buildAsApplication = !buildAsLibrary
|
||||||
if (buildAsApplication) {
|
if (buildAsApplication) {
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
@ -15,8 +15,8 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 37
|
targetSdkVersion 37
|
||||||
versionCode 1
|
versionCode 3
|
||||||
versionName "1.0"
|
versionName "1.0.6"
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
/*ndkBuild {
|
/*ndkBuild {
|
||||||
arguments "APP_PLATFORM=android-19"
|
arguments "APP_PLATFORM=android-19"
|
||||||
@ -31,7 +31,10 @@ android {
|
|||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
// Enables code optimizations.
|
||||||
|
minifyEnabled = true
|
||||||
|
// Enables resource shrinking.
|
||||||
|
shrinkResources = true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
proj-android/app/proguard-rules.pro
vendored
18
proj-android/app/proguard-rules.pro
vendored
@ -16,18 +16,21 @@
|
|||||||
# public *;
|
# public *;
|
||||||
#}
|
#}
|
||||||
|
|
||||||
-keep,includedescriptorclasses,allowoptimization class fishrungames.shadowoverbishkek.SDLInputConnection {
|
# SDL2 specific rules
|
||||||
|
-keep class org.libsdl.app.** { *; }
|
||||||
|
|
||||||
|
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLInputConnection {
|
||||||
void nativeCommitText(java.lang.String, int);
|
void nativeCommitText(java.lang.String, int);
|
||||||
void nativeGenerateScancodeForUnichar(char);
|
void nativeGenerateScancodeForUnichar(char);
|
||||||
}
|
}
|
||||||
|
|
||||||
-keep,includedescriptorclasses class fishrungames.shadowoverbishkek.SDLActivity {
|
-keep,includedescriptorclasses class org.libsdl.app.SDLActivity {
|
||||||
# for some reason these aren't compatible with allowoptimization modifier
|
# for some reason these aren't compatible with allowoptimization modifier
|
||||||
boolean supportsRelativeMouse();
|
boolean supportsRelativeMouse();
|
||||||
void setWindowStyle(boolean);
|
void setWindowStyle(boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
-keep,includedescriptorclasses,allowoptimization class fishrungames.shadowoverbishkek.SDLActivity {
|
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLActivity {
|
||||||
java.lang.String nativeGetHint(java.lang.String); # Java-side doesn't use this, so it gets minified, but C-side still tries to register it
|
java.lang.String nativeGetHint(java.lang.String); # Java-side doesn't use this, so it gets minified, but C-side still tries to register it
|
||||||
boolean onNativeSoftReturnKey();
|
boolean onNativeSoftReturnKey();
|
||||||
void onNativeKeyboardFocusLost();
|
void onNativeKeyboardFocusLost();
|
||||||
@ -62,7 +65,7 @@
|
|||||||
boolean showTextInput(int, int, int, int);
|
boolean showTextInput(int, int, int, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
-keep,includedescriptorclasses,allowoptimization class fishrungames.shadowoverbishkek.HIDDeviceManager {
|
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.HIDDeviceManager {
|
||||||
boolean initialize(boolean, boolean);
|
boolean initialize(boolean, boolean);
|
||||||
boolean openDevice(int);
|
boolean openDevice(int);
|
||||||
int sendOutputReport(int, byte[]);
|
int sendOutputReport(int, byte[]);
|
||||||
@ -71,7 +74,7 @@
|
|||||||
void closeDevice(int);
|
void closeDevice(int);
|
||||||
}
|
}
|
||||||
|
|
||||||
-keep,includedescriptorclasses,allowoptimization class fishrungames.shadowoverbishkek.SDLAudioManager {
|
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLAudioManager {
|
||||||
int[] getAudioOutputDevices();
|
int[] getAudioOutputDevices();
|
||||||
int[] getAudioInputDevices();
|
int[] getAudioInputDevices();
|
||||||
int[] audioOpen(int, int, int, int, int);
|
int[] audioOpen(int, int, int, int, int);
|
||||||
@ -90,9 +93,12 @@
|
|||||||
native void addAudioDevice(boolean, int);
|
native void addAudioDevice(boolean, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
-keep,includedescriptorclasses,allowoptimization class fishrungames.shadowoverbishkek.SDLControllerManager {
|
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLControllerManager {
|
||||||
void pollInputDevices();
|
void pollInputDevices();
|
||||||
void pollHapticDevices();
|
void pollHapticDevices();
|
||||||
void hapticRun(int, float, int);
|
void hapticRun(int, float, int);
|
||||||
void hapticStop(int);
|
void hapticStop(int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Keep our main activity
|
||||||
|
-keep class fishrungames.shadowoverbishkek.ShadowOverBishkekActivity { *; }
|
||||||
|
|||||||
@ -19,7 +19,7 @@ android.r8.strictFullModeForKeepRules=false
|
|||||||
android.sdk.defaultTargetSdkToCompileSdkIfUnset=false
|
android.sdk.defaultTargetSdkToCompileSdkIfUnset=false
|
||||||
android.uniquePackageNames=false
|
android.uniquePackageNames=false
|
||||||
android.usesSdkInManifest.disallowed=false
|
android.usesSdkInManifest.disallowed=false
|
||||||
org.gradle.jvmargs=-Xmx1536m
|
org.gradle.jvmargs=-Xmx4096m
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
|
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
|||||||
@ -302,7 +302,7 @@ set(CPACK_PACKAGE_VENDOR "Fish Run Games")
|
|||||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Shadow Over Bishkek Demo Version")
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Shadow Over Bishkek Demo Version")
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR "1")
|
set(CPACK_PACKAGE_VERSION_MAJOR "1")
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR "0")
|
set(CPACK_PACKAGE_VERSION_MINOR "0")
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH "3")
|
set(CPACK_PACKAGE_VERSION_PATCH "5")
|
||||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Fish Run Games/Shadow Over Bishkek Demo")
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Fish Run Games/Shadow Over Bishkek Demo")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -125,7 +125,7 @@
|
|||||||
"y": 10,
|
"y": 10,
|
||||||
"width": 160,
|
"width": 160,
|
||||||
"height": 36,
|
"height": 36,
|
||||||
"text": "v. 1.0.4",
|
"text": "v. 1.0.6",
|
||||||
"fontSize": 24,
|
"fontSize": 24,
|
||||||
"textCentered": false,
|
"textCentered": false,
|
||||||
"topAligned": true,
|
"topAligned": true,
|
||||||
|
|||||||
@ -116,7 +116,7 @@
|
|||||||
"y": 10,
|
"y": 10,
|
||||||
"width": 160,
|
"width": 160,
|
||||||
"height": 36,
|
"height": 36,
|
||||||
"text": "v. 1.0.4",
|
"text": "v. 1.0.6",
|
||||||
"fontSize": 24,
|
"fontSize": 24,
|
||||||
"textCentered": false,
|
"textCentered": false,
|
||||||
"topAligned": true,
|
"topAligned": true,
|
||||||
|
|||||||
@ -125,7 +125,7 @@
|
|||||||
"y": 10,
|
"y": 10,
|
||||||
"width": 160,
|
"width": 160,
|
||||||
"height": 36,
|
"height": 36,
|
||||||
"text": "v. 1.0.4",
|
"text": "v. 1.0.6",
|
||||||
"fontSize": 24,
|
"fontSize": 24,
|
||||||
"textCentered": false,
|
"textCentered": false,
|
||||||
"topAligned": true,
|
"topAligned": true,
|
||||||
|
|||||||
@ -125,7 +125,7 @@
|
|||||||
"y": 10,
|
"y": 10,
|
||||||
"width": 160,
|
"width": 160,
|
||||||
"height": 36,
|
"height": 36,
|
||||||
"text": "v. 1.0.4",
|
"text": "v. 1.0.6",
|
||||||
"fontSize": 24,
|
"fontSize": 24,
|
||||||
"textCentered": false,
|
"textCentered": false,
|
||||||
"topAligned": true,
|
"topAligned": true,
|
||||||
|
|||||||
@ -23,6 +23,7 @@ int Environment::height = CONST_DEFAULT_HEIGHT;
|
|||||||
float Environment::zoom = DEFAULT_ZOOM;
|
float Environment::zoom = DEFAULT_ZOOM;
|
||||||
|
|
||||||
bool Environment::enableLogging = false;
|
bool Environment::enableLogging = false;
|
||||||
|
//bool Environment::enableLogging = true;
|
||||||
|
|
||||||
SDL_Window* Environment::window = nullptr;
|
SDL_Window* Environment::window = nullptr;
|
||||||
|
|
||||||
|
|||||||
11
src/Game.cpp
11
src/Game.cpp
@ -101,12 +101,16 @@ namespace FRG
|
|||||||
FRG::BindOpenGlFunctions();
|
FRG::BindOpenGlFunctions();
|
||||||
FRG::CheckGlError(__FILE__, __LINE__);
|
FRG::CheckGlError(__FILE__, __LINE__);
|
||||||
renderer.InitOpenGL();
|
renderer.InitOpenGL();
|
||||||
|
//logger() << "Android test step 1 " << std::endl;
|
||||||
|
|
||||||
#if defined(EMSCRIPTEN)
|
#if defined(EMSCRIPTEN) || defined(__ANDROID__)
|
||||||
// These shaders and loading.png are preloaded separately (not from zip),
|
// These shaders and loading.png are preloaded separately (not from zip),
|
||||||
// so they are available immediately without waiting for resources.zip.
|
// so they are available immediately without waiting for resources.zip.
|
||||||
|
//logger() << "Android test step 1 " << std::endl;
|
||||||
renderer.shaderManager.AddShaderFromFiles("defaultColor", "resources/shaders/defaultColor.vertex", "resources/shaders/defaultColor_web.fragment", "");
|
renderer.shaderManager.AddShaderFromFiles("defaultColor", "resources/shaders/defaultColor.vertex", "resources/shaders/defaultColor_web.fragment", "");
|
||||||
|
//logger() << "Android test step 2 " << std::endl;
|
||||||
renderer.shaderManager.AddShaderFromFiles("default", "resources/shaders/default.vertex", "resources/shaders/default_web.fragment", "");
|
renderer.shaderManager.AddShaderFromFiles("default", "resources/shaders/default.vertex", "resources/shaders/default_web.fragment", "");
|
||||||
|
//logger() << "Android test step 3 " << std::endl;
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
renderer.shaderManager.AddShaderFromFiles("defaultColor", "resources/shaders/defaultColor.vertex", "resources/shaders/defaultColor_desktop.fragment", CONST_ZIP_FILE);
|
renderer.shaderManager.AddShaderFromFiles("defaultColor", "resources/shaders/defaultColor.vertex", "resources/shaders/defaultColor_desktop.fragment", CONST_ZIP_FILE);
|
||||||
renderer.shaderManager.AddShaderFromFiles("default", "resources/shaders/default.vertex", "resources/shaders/default_desktop.fragment", CONST_ZIP_FILE);
|
renderer.shaderManager.AddShaderFromFiles("default", "resources/shaders/default.vertex", "resources/shaders/default_desktop.fragment", CONST_ZIP_FILE);
|
||||||
@ -116,12 +120,13 @@ namespace FRG
|
|||||||
renderer.shaderManager.AddShaderFromFiles("default", "resources/shaders/default.vertex", "resources/shaders/default_desktop.fragment", CONST_ZIP_FILE);
|
renderer.shaderManager.AddShaderFromFiles("default", "resources/shaders/default.vertex", "resources/shaders/default_desktop.fragment", CONST_ZIP_FILE);
|
||||||
#endif
|
#endif
|
||||||
loadingTexture = renderer.textureManager.LoadFromPng("resources/loading.png", "");
|
loadingTexture = renderer.textureManager.LoadFromPng("resources/loading.png", "");
|
||||||
|
//logger() << "Android test step 4 " << std::endl;
|
||||||
loadingProgressBarFrameTexture = renderer.textureManager.LoadFromPng(
|
loadingProgressBarFrameTexture = renderer.textureManager.LoadFromPng(
|
||||||
"resources/loadingProgressBarFrame.png", "", true);
|
"resources/loadingProgressBarFrame.png", "", true);
|
||||||
loadingProgressBarTexture = renderer.textureManager.LoadFromPng(
|
loadingProgressBarTexture = renderer.textureManager.LoadFromPng(
|
||||||
"resources/loadingProgressBar.png", "", true);
|
"resources/loadingProgressBar.png", "", true);
|
||||||
|
|
||||||
|
//logger() << "Android test step 5 " << std::endl;
|
||||||
float minDimension;
|
float minDimension;
|
||||||
float width = Environment::projectionWidth;
|
float width = Environment::projectionWidth;
|
||||||
float height = Environment::projectionHeight;
|
float height = Environment::projectionHeight;
|
||||||
@ -1941,4 +1946,4 @@ namespace FRG
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace FRG
|
} // namespace
|
||||||
Loading…
Reference in New Issue
Block a user