mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-11-23 06:02:55 +00:00
hotfix time
This commit is contained in:
parent
074af609bc
commit
ef1c2a5930
|
@ -43,13 +43,6 @@ for:
|
|||
only:
|
||||
- appveyor_build_worker_image: Visual Studio 2019
|
||||
|
||||
init:
|
||||
- ps: |
|
||||
if ($env:APPVEYOR_REPO_TAG -eq "true")
|
||||
{
|
||||
Update-AppveyorBuild -Version "$env:APPVEYOR_REPO_TAG_NAME"
|
||||
}
|
||||
|
||||
install:
|
||||
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
|
||||
- rustup-init -yv --default-toolchain %channel% --default-host %target%
|
||||
|
@ -69,7 +62,8 @@ for:
|
|||
- 'target -> Cargo.toml'
|
||||
|
||||
build_script:
|
||||
- set DRS_BUILD_VERSION_OVERRIDE=%APPVEYOR_BUILD_VERSION%
|
||||
#- set DRS_BUILD_VERSION_OVERRIDE=%APPVEYOR_BUILD_VERSION%
|
||||
- if "%APPVEYOR_REPO_TAG%" == "true" (set DRS_BUILD_VERSION_OVERRIDE=%APPVEYOR_REPO_TAG_NAME%) else (set DRS_BUILD_VERSION_OVERRIDE=%APPVEYOR_BUILD_VERSION%)
|
||||
- set CARGO_INCREMENTAL=1
|
||||
- cargo build --release --bin doukutsu-rs
|
||||
- mkdir release
|
||||
|
@ -111,7 +105,8 @@ for:
|
|||
- 'target -> Cargo.toml'
|
||||
|
||||
build_script:
|
||||
- export DRS_BUILD_VERSION_OVERRIDE=$APPVEYOR_BUILD_VERSION
|
||||
#- export DRS_BUILD_VERSION_OVERRIDE=$APPVEYOR_BUILD_VERSION
|
||||
- if [ "$APPVEYOR_REPO_TAG" = "true" ]; then export DRS_BUILD_VERSION_OVERRIDE=$APPVEYOR_REPO_TAG_NAME; else export DRS_BUILD_VERSION_OVERRIDE=$APPVEYOR_BUILD_VERSION; fi
|
||||
- CARGO_INCREMENTAL=1 cargo bundle --release --target $target
|
||||
- mkdir release
|
||||
- cp LICENSE ./release/LICENSE
|
||||
|
@ -126,13 +121,6 @@ for:
|
|||
only:
|
||||
- appveyor_build_worker_image: Ubuntu
|
||||
|
||||
init:
|
||||
- ps: |
|
||||
if ($env:APPVEYOR_REPO_TAG -eq "true")
|
||||
{
|
||||
Update-AppveyorBuild -Version "$env:APPVEYOR_REPO_TAG_NAME"
|
||||
}
|
||||
|
||||
install:
|
||||
- sudo apt-get update && sudo apt-get -y install libasound2-dev libudev-dev libgl1-mesa-dev pkg-config
|
||||
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -yv --default-toolchain $channel --default-host $target
|
||||
|
@ -152,7 +140,8 @@ for:
|
|||
- 'target -> Cargo.toml'
|
||||
|
||||
build_script:
|
||||
- export DRS_BUILD_VERSION_OVERRIDE=$APPVEYOR_BUILD_VERSION
|
||||
#- export DRS_BUILD_VERSION_OVERRIDE=$APPVEYOR_BUILD_VERSION
|
||||
- if [ "$APPVEYOR_REPO_TAG" = "true" ]; then export DRS_BUILD_VERSION_OVERRIDE=$APPVEYOR_REPO_TAG_NAME; else export DRS_BUILD_VERSION_OVERRIDE=$APPVEYOR_BUILD_VERSION; fi
|
||||
- RUSTFLAGS="-C link-arg=-s" CARGO_INCREMENTAL=1 cargo build --release --bin doukutsu-rs
|
||||
- mkdir release
|
||||
- cp LICENSE ./release/LICENSE
|
||||
|
|
|
@ -16,12 +16,16 @@ bench = false
|
|||
required-features = ["exe"]
|
||||
|
||||
[profile.release]
|
||||
lto = "thin"
|
||||
lto = "off"
|
||||
panic = "abort"
|
||||
codegen-units = 256
|
||||
incremental = true
|
||||
split-debuginfo = "packed"
|
||||
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 3
|
||||
overflow-checks = false
|
||||
codegen-units = 256
|
||||
|
||||
[package.metadata.bundle]
|
||||
name = "doukutsu-rs"
|
||||
|
|
|
@ -1,35 +1,52 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application android:allowBackup="true"
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:extractNativeLibs="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Doukutsurs">
|
||||
<activity android:name=".DownloadActivity"
|
||||
android:label="Download"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:theme="@style/Theme.Doukutsurs.NoActionBar"></activity>
|
||||
<activity android:name=".MainActivity"
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:exported="true"
|
||||
android:label="doukutsu-rs"
|
||||
android:launchMode="standard"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:exported="true">
|
||||
android:theme="@style/Theme.Doukutsurs.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data android:name="android.app.lib_name" android:value="drsandroid" />
|
||||
</activity>
|
||||
|
||||
<provider android:name=".DoukutsuDocumentsProvider"
|
||||
<activity
|
||||
android:name=".DownloadActivity"
|
||||
android:label="Download"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:theme="@style/Theme.Doukutsurs.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name=".GameActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:exported="true"
|
||||
android:launchMode="standard"
|
||||
android:screenOrientation="sensorLandscape">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="drsandroid" />
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name=".DoukutsuDocumentsProvider"
|
||||
android:authorities="${documentsAuthority}"
|
||||
android:exported="true"
|
||||
android:grantUriPermissions="true"
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.github.doukutsu_rs;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
@ -18,6 +19,7 @@ public class DownloadActivity extends AppCompatActivity {
|
|||
private ProgressBar progressBar;
|
||||
private DownloadThread downloadThread;
|
||||
private String basePath;
|
||||
private Handler handler = new Handler();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -55,7 +57,7 @@ public class DownloadActivity extends AppCompatActivity {
|
|||
|
||||
int fileLength = connection.getContentLength();
|
||||
if (fileLength == 0) {
|
||||
progressBar.setIndeterminate(true);
|
||||
handler.post(() -> progressBar.setIndeterminate(true));
|
||||
}
|
||||
|
||||
byte[] zipFile;
|
||||
|
@ -81,7 +83,7 @@ public class DownloadActivity extends AppCompatActivity {
|
|||
? String.format(Locale.ENGLISH, "Downloading... %d%% (%d/%d KiB, %d KiB/s)", downloaded * 100 / fileLength, downloaded / 1024, fileLength / 1024, speed)
|
||||
: String.format(Locale.ENGLISH, "Downloading... --%% (%d KiB, %d KiB/s)", downloaded / 1024, speed);
|
||||
|
||||
txtProgress.setText(text);
|
||||
handler.post(() -> txtProgress.setText(text));
|
||||
|
||||
downloadedLast = downloaded;
|
||||
last = now;
|
||||
|
@ -105,7 +107,8 @@ public class DownloadActivity extends AppCompatActivity {
|
|||
entryName = entryName.substring("CaveStory/".length());
|
||||
}
|
||||
|
||||
txtProgress.setText("Unpacking: " + entryName);
|
||||
final String s = entryName;
|
||||
handler.post(() -> txtProgress.setText("Unpacking: " + s));
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
new File(basePath + entryName).mkdirs();
|
||||
|
@ -122,14 +125,19 @@ public class DownloadActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
txtProgress.setText("Done!");
|
||||
handler.post(() -> txtProgress.setText("Done!"));
|
||||
|
||||
Intent intent = new Intent(DownloadActivity.this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
|
||||
startActivity(intent);
|
||||
DownloadActivity.this.finish();
|
||||
handler.post(() -> {
|
||||
Intent intent = new Intent(DownloadActivity.this, GameActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
DownloadActivity.this.finish();
|
||||
});
|
||||
} catch (Exception e) {
|
||||
if (txtProgress != null) txtProgress.setText(e.getMessage());
|
||||
handler.post(() -> {
|
||||
if (txtProgress != null)
|
||||
txtProgress.setText(e.getMessage());
|
||||
});
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (connection != null) connection.disconnect();
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
package io.github.doukutsu_rs;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.NativeActivity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.OrientationEventListener;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
public class GameActivity extends NativeActivity {
|
||||
private int[] displayInsets = new int[]{0, 0, 0, 0};
|
||||
private OrientationEventListener listener;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
listener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) {
|
||||
@Override
|
||||
public void onOrientationChanged(int orientation) {
|
||||
GameActivity.this.updateCutouts();
|
||||
}
|
||||
};
|
||||
|
||||
if (listener.canDetectOrientation()) {
|
||||
listener.enable();
|
||||
} else {
|
||||
listener = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (listener != null) {
|
||||
listener.disable();
|
||||
|
||||
listener = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
this.updateCutouts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
this.updateCutouts();
|
||||
}
|
||||
|
||||
private void updateCutouts() {
|
||||
this.displayInsets[0] = 0;
|
||||
this.displayInsets[1] = 0;
|
||||
this.displayInsets[2] = 0;
|
||||
this.displayInsets[3] = 0;
|
||||
|
||||
WindowInsets insets = getWindow().getDecorView().getRootWindowInsets();
|
||||
|
||||
if (insets != null) {
|
||||
this.displayInsets[0] = Math.max(this.displayInsets[0], insets.getStableInsetLeft());
|
||||
this.displayInsets[1] = Math.max(this.displayInsets[1], insets.getStableInsetTop());
|
||||
this.displayInsets[2] = Math.max(this.displayInsets[2], insets.getStableInsetRight());
|
||||
this.displayInsets[3] = Math.max(this.displayInsets[3], insets.getStableInsetBottom());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDK_INT >= Build.VERSION_CODES.P) {
|
||||
android.view.DisplayCutout cutout = insets.getDisplayCutout();
|
||||
|
||||
if (cutout != null) {
|
||||
this.displayInsets[0] = Math.max(this.displayInsets[0], cutout.getSafeInsetLeft());
|
||||
this.displayInsets[1] = Math.max(this.displayInsets[0], cutout.getSafeInsetTop());
|
||||
this.displayInsets[2] = Math.max(this.displayInsets[0], cutout.getSafeInsetRight());
|
||||
this.displayInsets[3] = Math.max(this.displayInsets[0], cutout.getSafeInsetBottom());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,119 +1,49 @@
|
|||
package io.github.doukutsu_rs;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.NativeActivity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.OrientationEventListener;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
public class MainActivity extends NativeActivity {
|
||||
private int[] displayInsets = new int[]{0, 0, 0, 0};
|
||||
private OrientationEventListener listener;
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
File f = new File(getFilesDir().getAbsolutePath() + "/data/");
|
||||
String[] list = f.list();
|
||||
if (!f.exists() || (list != null && list.length == 0)) {
|
||||
messageBox("Missing data files", "No data files found, would you like to download them?", () -> {
|
||||
Intent intent = new Intent(this, DownloadActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
this.finish();
|
||||
});
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
listener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) {
|
||||
@Override
|
||||
public void onOrientationChanged(int orientation) {
|
||||
MainActivity.this.updateCutouts();
|
||||
}
|
||||
};
|
||||
|
||||
if (listener.canDetectOrientation()) {
|
||||
listener.enable();
|
||||
}, this::launchGame);
|
||||
} else {
|
||||
listener = null;
|
||||
launchGame();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (listener != null) {
|
||||
listener.disable();
|
||||
|
||||
listener = null;
|
||||
}
|
||||
private void launchGame() {
|
||||
Intent intent = new Intent(this, GameActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
this.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
this.updateCutouts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
this.updateCutouts();
|
||||
}
|
||||
|
||||
private void updateCutouts() {
|
||||
this.displayInsets[0] = 0;
|
||||
this.displayInsets[1] = 0;
|
||||
this.displayInsets[2] = 0;
|
||||
this.displayInsets[3] = 0;
|
||||
|
||||
WindowInsets insets = getWindow().getDecorView().getRootWindowInsets();
|
||||
|
||||
if (insets != null) {
|
||||
this.displayInsets[0] = Math.max(this.displayInsets[0], insets.getStableInsetLeft());
|
||||
this.displayInsets[1] = Math.max(this.displayInsets[1], insets.getStableInsetTop());
|
||||
this.displayInsets[2] = Math.max(this.displayInsets[2], insets.getStableInsetRight());
|
||||
this.displayInsets[3] = Math.max(this.displayInsets[3], insets.getStableInsetBottom());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDK_INT >= Build.VERSION_CODES.P) {
|
||||
android.view.DisplayCutout cutout = insets.getDisplayCutout();
|
||||
|
||||
if (cutout != null) {
|
||||
this.displayInsets[0] = Math.max(this.displayInsets[0], cutout.getSafeInsetLeft());
|
||||
this.displayInsets[1] = Math.max(this.displayInsets[0], cutout.getSafeInsetTop());
|
||||
this.displayInsets[2] = Math.max(this.displayInsets[0], cutout.getSafeInsetRight());
|
||||
this.displayInsets[3] = Math.max(this.displayInsets[0], cutout.getSafeInsetBottom());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void messageBox(String title, String message, Runnable callback) {
|
||||
private void messageBox(String title, String message, Runnable yesCallback, Runnable noCallback) {
|
||||
this.runOnUiThread(() -> {
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
alert.setTitle(title);
|
||||
alert.setMessage(message);
|
||||
alert.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
|
||||
callback.run();
|
||||
});
|
||||
alert.setNegativeButton(android.R.string.no, (dialog, whichButton) -> {
|
||||
// hide
|
||||
});
|
||||
alert.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> yesCallback.run());
|
||||
alert.setNegativeButton(android.R.string.no, (dialog, whichButton) -> noCallback.run());
|
||||
alert.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
9
app/app/src/main/res/layout/activity_main.xml
Normal file
9
app/app/src/main/res/layout/activity_main.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -8,7 +8,7 @@ buildscript {
|
|||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:7.4.0"
|
||||
classpath "com.android.tools.build:gradle:7.3.1"
|
||||
classpath "gradle.plugin.com.github.willir.rust:plugin:0.3.4"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
|
1
build.rs
1
build.rs
|
@ -19,6 +19,7 @@ fn main() {
|
|||
if target.contains("i686") {
|
||||
// yet another hack
|
||||
println!("cargo:rustc-link-arg=/FORCE:MULTIPLE");
|
||||
println!("cargo:rustc-link-lib=shlwapi");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ edition = "2021"
|
|||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
lto = "off"
|
||||
codegen-units = 256
|
||||
incremental = true
|
||||
|
||||
[lib]
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#[cfg(target_os = "android")]
|
||||
#[cfg_attr(target_os = "android", ndk_glue::main())]
|
||||
pub fn android_main() {
|
||||
let resource_dir = std::path::PathBuf::from(ndk_glue::native_activity().internal_data_path().to_string_lossy().to_string());
|
||||
|
||||
std::env::set_current_dir(&resource_dir).unwrap();
|
||||
|
||||
let options = doukutsu_rs::game::LaunchOptions { server_mode: false, editor: false };
|
||||
|
||||
doukutsu_rs::game::init(options).unwrap();
|
||||
|
|
|
@ -6,15 +6,19 @@ edition = "2021"
|
|||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
#incremental = true
|
||||
codegen-units = 256
|
||||
incremental = true
|
||||
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 3
|
||||
overflow-checks = false
|
||||
incremental = true
|
||||
|
||||
[profile.dev.package."doukutsu-rs"]
|
||||
opt-level = 3
|
||||
lto = "off"
|
||||
overflow-checks = false
|
||||
codegen-units = 256
|
||||
incremental = true
|
||||
|
||||
[dependencies]
|
||||
|
|
|
@ -17,6 +17,7 @@ use crate::framework::{
|
|||
pub struct VanillaExtractor {
|
||||
exe_buffer: Vec<u8>,
|
||||
data_base_dir: String,
|
||||
root: PathBuf,
|
||||
}
|
||||
|
||||
const VANILLA_STAGE_COUNT: u32 = 95;
|
||||
|
@ -26,14 +27,33 @@ const VANILLA_STAGE_TABLE_SIZE: u32 = VANILLA_STAGE_COUNT * VANILLA_STAGE_ENTRY_
|
|||
|
||||
impl VanillaExtractor {
|
||||
pub fn from(ctx: &mut Context, exe_name: String, data_base_dir: String) -> Option<Self> {
|
||||
let mut vanilla_exe_path = env::current_exe().unwrap();
|
||||
vanilla_exe_path.pop();
|
||||
vanilla_exe_path.push(exe_name);
|
||||
#[cfg(not(any(target_os = "android", target_os = "horizon")))]
|
||||
let mut vanilla_exe_path = env::current_dir().unwrap();
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
let mut vanilla_exe_path = PathBuf::from(ndk_glue::native_activity().internal_data_path().to_string_lossy().to_string());
|
||||
|
||||
#[cfg(target_os = "horizon")]
|
||||
let mut vanilla_exe_path = PathBuf::from("sdmc:/switch/doukutsu-rs/");
|
||||
|
||||
vanilla_exe_path.push(&exe_name);
|
||||
|
||||
log::info!("Looking for vanilla game executable at {:?}", vanilla_exe_path);
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "horizon")))]
|
||||
if !vanilla_exe_path.is_file() {
|
||||
vanilla_exe_path = env::current_exe().unwrap();
|
||||
vanilla_exe_path.pop();
|
||||
vanilla_exe_path.push(&exe_name);
|
||||
}
|
||||
|
||||
if !vanilla_exe_path.is_file() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut root = vanilla_exe_path.clone();
|
||||
root.pop();
|
||||
|
||||
log::info!("Found vanilla game executable, attempting to extract resources.");
|
||||
|
||||
if filesystem::exists(ctx, format!("{}/stage.sect", data_base_dir.clone())) {
|
||||
|
@ -54,7 +74,7 @@ impl VanillaExtractor {
|
|||
return None;
|
||||
}
|
||||
|
||||
Some(Self { exe_buffer, data_base_dir })
|
||||
Some(Self { exe_buffer, data_base_dir, root })
|
||||
}
|
||||
|
||||
pub fn extract_data(&self) -> GameResult {
|
||||
|
@ -93,8 +113,7 @@ impl VanillaExtractor {
|
|||
}
|
||||
|
||||
for org in orgs.unwrap().data_files {
|
||||
let mut org_path = env::current_exe().unwrap();
|
||||
org_path.pop();
|
||||
let mut org_path = self.root.clone();
|
||||
org_path.push(self.data_base_dir.clone());
|
||||
org_path.push("Org/");
|
||||
|
||||
|
@ -130,8 +149,7 @@ impl VanillaExtractor {
|
|||
}
|
||||
|
||||
for bitmap in bitmaps.unwrap().data_files {
|
||||
let mut data_path = env::current_exe().unwrap();
|
||||
data_path.pop();
|
||||
let mut data_path = self.root.clone();
|
||||
data_path.push(self.data_base_dir.clone());
|
||||
|
||||
if self.deep_create_dir_if_not_exists(data_path.clone()).is_err() {
|
||||
|
@ -180,8 +198,7 @@ impl VanillaExtractor {
|
|||
|
||||
let byte_slice = &self.exe_buffer[start..end];
|
||||
|
||||
let mut stage_tbl_path = env::current_exe().unwrap();
|
||||
stage_tbl_path.pop();
|
||||
let mut stage_tbl_path = self.root.clone();
|
||||
stage_tbl_path.push(self.data_base_dir.clone());
|
||||
|
||||
if self.deep_create_dir_if_not_exists(stage_tbl_path.clone()).is_err() {
|
||||
|
|
|
@ -203,7 +203,7 @@ impl SettingsMenu {
|
|||
],
|
||||
),
|
||||
);
|
||||
#[cfg(not(all(target_os = "android", target_os = "horizon")))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "horizon")))]
|
||||
self.graphics.push_entry(
|
||||
GraphicsMenuEntry::WindowMode,
|
||||
MenuEntry::Options(
|
||||
|
|
Loading…
Reference in a new issue