diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index 0e554546..0e96e9af 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -8,22 +8,22 @@ plugins {
}
android {
- namespace = "su.xash.engine"
+ namespace = "su.xash.engine"
ndkVersion = "28.0.13004108"
compileSdk = 35
- defaultConfig {
- applicationId = "su.xash.engine"
- versionName = "0.21"
- versionCode = getBuildNum()
- minSdk = 21
- targetSdk = 35
- }
+ defaultConfig {
+ applicationId = "su.xash.engine"
+ versionName = "0.21"
+ versionCode = getBuildNum()
+ minSdk = 21
+ targetSdk = 35
+ }
- compileOptions {
+ compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
- }
+ }
kotlinOptions {
jvmTarget = "11"
@@ -73,23 +73,23 @@ android {
)
}
- release {
- isMinifyEnabled = true
- isShrinkResources = true
- proguardFiles(
- getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
- )
- }
+ release {
+ isMinifyEnabled = true
+ isShrinkResources = true
+ proguardFiles(
+ getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
+ )
+ }
- register("asan") {
- initWith(getByName("debug"))
- }
+ register("asan") {
+ initWith(getByName("debug"))
+ }
- register("continuous") {
- initWith(getByName("release"))
- applicationIdSuffix = ".test"
- }
- }
+ register("continuous") {
+ initWith(getByName("release"))
+ applicationIdSuffix = ".test"
+ }
+ }
}
dependencies {
@@ -102,13 +102,13 @@ dependencies {
implementation(libs.preference.ktx)
implementation(libs.swiperefreshlayout)
- implementation(libs.acra.http)
+ implementation(libs.acra.http)
}
fun getBuildNum(): Int {
- val now = LocalDateTime.now()
- val releaseDate = LocalDateTime.of(2015, Month.APRIL, 1, 0, 0, 0)
- val qBuildNum = releaseDate.until(now, ChronoUnit.DAYS)
- val minuteOfDay = now.hour * 60 + now.minute
- return (qBuildNum * 10000 + minuteOfDay).toInt()
+ val now = LocalDateTime.now()
+ val releaseDate = LocalDateTime.of(2015, Month.APRIL, 1, 0, 0, 0)
+ val qBuildNum = releaseDate.until(now, ChronoUnit.DAYS)
+ val minuteOfDay = now.hour * 60 + now.minute
+ return (qBuildNum * 10000 + minuteOfDay).toInt()
}
diff --git a/android/app/src/debug/res/values/strings.xml b/android/app/src/debug/res/values/strings.xml
index 40f3ebc7..b3ef5b7f 100644
--- a/android/app/src/debug/res/values/strings.xml
+++ b/android/app/src/debug/res/values/strings.xml
@@ -1,4 +1,4 @@
- Xash3D FWGS (Test)
+ Xash3D FWGS (Test)
diff --git a/android/app/src/main/java/su/xash/engine/AndroidBug5497Workaround.java b/android/app/src/main/java/su/xash/engine/AndroidBug5497Workaround.java
index 951d63cf..008a58ec 100644
--- a/android/app/src/main/java/su/xash/engine/AndroidBug5497Workaround.java
+++ b/android/app/src/main/java/su/xash/engine/AndroidBug5497Workaround.java
@@ -6,44 +6,44 @@ import android.view.View;
import android.widget.FrameLayout;
public class AndroidBug5497Workaround {
- // For more information, see https://code.google.com/p/android/issues/detail?id=5497
- // To use this class, simply invoke assistActivity() on an Activity that already has its content view set.
+ // For more information, see https://code.google.com/p/android/issues/detail?id=5497
+ // To use this class, simply invoke assistActivity() on an Activity that already has its content view set.
- public static void assistActivity(Activity activity) {
- new AndroidBug5497Workaround(activity);
- }
+ public static void assistActivity(Activity activity) {
+ new AndroidBug5497Workaround(activity);
+ }
- private View mChildOfContent;
- private int usableHeightPrevious;
- private FrameLayout.LayoutParams frameLayoutParams;
+ private View mChildOfContent;
+ private int usableHeightPrevious;
+ private FrameLayout.LayoutParams frameLayoutParams;
- private AndroidBug5497Workaround(Activity activity) {
- FrameLayout content = activity.findViewById(android.R.id.content);
- mChildOfContent = content.getChildAt(0);
- mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(this::possiblyResizeChildOfContent);
- frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
- }
+ private AndroidBug5497Workaround(Activity activity) {
+ FrameLayout content = activity.findViewById(android.R.id.content);
+ mChildOfContent = content.getChildAt(0);
+ mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(this::possiblyResizeChildOfContent);
+ frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
+ }
- private void possiblyResizeChildOfContent() {
- int usableHeightNow = computeUsableHeight();
- if (usableHeightNow != usableHeightPrevious) {
- int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
- int heightDifference = usableHeightSansKeyboard - usableHeightNow;
- if (heightDifference > (usableHeightSansKeyboard / 4)) {
- // keyboard probably just became visible
- frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
- } else {
- // keyboard probably just became hidden
- frameLayoutParams.height = usableHeightSansKeyboard;
- }
- mChildOfContent.requestLayout();
- usableHeightPrevious = usableHeightNow;
- }
- }
+ private void possiblyResizeChildOfContent() {
+ int usableHeightNow = computeUsableHeight();
+ if (usableHeightNow != usableHeightPrevious) {
+ int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
+ int heightDifference = usableHeightSansKeyboard - usableHeightNow;
+ if (heightDifference > (usableHeightSansKeyboard / 4)) {
+ // keyboard probably just became visible
+ frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
+ } else {
+ // keyboard probably just became hidden
+ frameLayoutParams.height = usableHeightSansKeyboard;
+ }
+ mChildOfContent.requestLayout();
+ usableHeightPrevious = usableHeightNow;
+ }
+ }
- private int computeUsableHeight() {
- Rect r = new Rect();
- mChildOfContent.getWindowVisibleDisplayFrame(r);
- return (r.bottom - r.top);
- }
-}
\ No newline at end of file
+ private int computeUsableHeight() {
+ Rect r = new Rect();
+ mChildOfContent.getWindowVisibleDisplayFrame(r);
+ return (r.bottom - r.top);
+ }
+}
diff --git a/android/app/src/main/java/su/xash/engine/DedicatedService.kt b/android/app/src/main/java/su/xash/engine/DedicatedService.kt
index 4462af43..aaf67d60 100644
--- a/android/app/src/main/java/su/xash/engine/DedicatedService.kt
+++ b/android/app/src/main/java/su/xash/engine/DedicatedService.kt
@@ -4,8 +4,8 @@ import android.app.Service
import android.content.Intent
import android.os.IBinder
-class DedicatedService: Service() {
- override fun onBind(intent: Intent?): IBinder? {
- TODO("Not yet implemented")
- }
-}
\ No newline at end of file
+class DedicatedService : Service() {
+ override fun onBind(intent: Intent?): IBinder? {
+ TODO("Not yet implemented")
+ }
+}
diff --git a/android/app/src/main/java/su/xash/engine/MainActivity.kt b/android/app/src/main/java/su/xash/engine/MainActivity.kt
index 5ed7fd7d..cecf7105 100644
--- a/android/app/src/main/java/su/xash/engine/MainActivity.kt
+++ b/android/app/src/main/java/su/xash/engine/MainActivity.kt
@@ -10,26 +10,26 @@ import androidx.navigation.ui.setupActionBarWithNavController
import su.xash.engine.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
- private lateinit var binding: ActivityMainBinding
- private lateinit var appBarConfiguration: AppBarConfiguration
- private lateinit var navController: NavController
+ private lateinit var binding: ActivityMainBinding
+ private lateinit var appBarConfiguration: AppBarConfiguration
+ private lateinit var navController: NavController
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
- binding = ActivityMainBinding.inflate(layoutInflater)
- setContentView(binding.root)
+ binding = ActivityMainBinding.inflate(layoutInflater)
+ setContentView(binding.root)
- setSupportActionBar(binding.toolbar)
+ setSupportActionBar(binding.toolbar)
- val navHostFragment =
- supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment
- navController = navHostFragment.navController
- appBarConfiguration = AppBarConfiguration(navController.graph)
- setupActionBarWithNavController(navController, appBarConfiguration)
- }
+ val navHostFragment =
+ supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment
+ navController = navHostFragment.navController
+ appBarConfiguration = AppBarConfiguration(navController.graph)
+ setupActionBarWithNavController(navController, appBarConfiguration)
+ }
- override fun onSupportNavigateUp(): Boolean {
- return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
- }
+ override fun onSupportNavigateUp(): Boolean {
+ return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
+ }
}
diff --git a/android/app/src/main/java/su/xash/engine/MainApplication.kt b/android/app/src/main/java/su/xash/engine/MainApplication.kt
index b17c5088..3ecb28fe 100644
--- a/android/app/src/main/java/su/xash/engine/MainApplication.kt
+++ b/android/app/src/main/java/su/xash/engine/MainApplication.kt
@@ -8,21 +8,21 @@ import org.acra.data.StringFormat
import org.acra.ktx.initAcra
class MainApplication : Application() {
- override fun attachBaseContext(base: Context?) {
- super.attachBaseContext(base)
+ override fun attachBaseContext(base: Context?) {
+ super.attachBaseContext(base)
- if (!BuildConfig.DEBUG) {
- initAcra {
- buildConfigClass = BuildConfig::class.java
- reportFormat = StringFormat.JSON
+ if (!BuildConfig.DEBUG) {
+ initAcra {
+ buildConfigClass = BuildConfig::class.java
+ reportFormat = StringFormat.JSON
- httpSender {
- uri = "http://bodis.pp.ua:5000/report"
- }
- }
- } else {
- // enable strict mode to detect memory leaks etc.
- StrictMode.enableDefaults();
- }
- }
-}
\ No newline at end of file
+ httpSender {
+ uri = "http://bodis.pp.ua:5000/report"
+ }
+ }
+ } else {
+ // enable strict mode to detect memory leaks etc.
+ StrictMode.enableDefaults();
+ }
+ }
+}
diff --git a/android/app/src/main/java/su/xash/engine/XashActivity.java b/android/app/src/main/java/su/xash/engine/XashActivity.java
index ff4b8c76..f8592630 100644
--- a/android/app/src/main/java/su/xash/engine/XashActivity.java
+++ b/android/app/src/main/java/su/xash/engine/XashActivity.java
@@ -13,136 +13,135 @@ import android.view.WindowManager;
import org.libsdl.app.SDLActivity;
public class XashActivity extends SDLActivity {
- private boolean mUseVolumeKeys;
- private String mPackageName;
- private static final String TAG = "XashActivity";
+ private boolean mUseVolumeKeys;
+ private String mPackageName;
+ private static final String TAG = "XashActivity";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
- //getWindow().addFlags(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES);
- getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
- }
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+ //getWindow().addFlags(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES);
+ getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
+ }
- AndroidBug5497Workaround.assistActivity(this);
- }
+ AndroidBug5497Workaround.assistActivity(this);
+ }
- @Override
- public void onDestroy()
- {
- super.onDestroy();
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
- // Now that we don't exit from native code, we need to exit here, resetting
- // application state (actually global variables that we don't cleanup on exit)
- //
- // When the issue with global variables will be resolved, remove that exit() call
- System.exit(0);
- }
+ // Now that we don't exit from native code, we need to exit here, resetting
+ // application state (actually global variables that we don't cleanup on exit)
+ //
+ // When the issue with global variables will be resolved, remove that exit() call
+ System.exit(0);
+ }
- @Override
- protected String[] getLibraries() {
- return new String[]{"SDL2", "xash"};
- }
+ @Override
+ protected String[] getLibraries() {
+ return new String[]{"SDL2", "xash"};
+ }
- @SuppressLint("HardwareIds")
- private String getAndroidID() {
- return Secure.getString(getContentResolver(), Secure.ANDROID_ID);
- }
+ @SuppressLint("HardwareIds")
+ private String getAndroidID() {
+ return Secure.getString(getContentResolver(), Secure.ANDROID_ID);
+ }
- @SuppressLint("ApplySharedPref")
- private void saveAndroidID(String id) {
- getSharedPreferences("xash_preferences", MODE_PRIVATE).edit().putString("xash_id", id).commit();
- }
+ @SuppressLint("ApplySharedPref")
+ private void saveAndroidID(String id) {
+ getSharedPreferences("xash_preferences", MODE_PRIVATE).edit().putString("xash_id", id).commit();
+ }
- private String loadAndroidID() {
- return getSharedPreferences("xash_preferences", MODE_PRIVATE).getString("xash_id", "");
- }
+ private String loadAndroidID() {
+ return getSharedPreferences("xash_preferences", MODE_PRIVATE).getString("xash_id", "");
+ }
- @Override
- public String getCallingPackage() {
- if (mPackageName != null) {
- return mPackageName;
- }
+ @Override
+ public String getCallingPackage() {
+ if (mPackageName != null) {
+ return mPackageName;
+ }
- return super.getCallingPackage();
- }
+ return super.getCallingPackage();
+ }
- private AssetManager getAssets(boolean isEngine) {
- AssetManager am = null;
+ private AssetManager getAssets(boolean isEngine) {
+ AssetManager am = null;
- if (isEngine) {
- am = getAssets();
- } else {
- try {
- am = getPackageManager().getResourcesForApplication(getCallingPackage()).getAssets();
- } catch (Exception e) {
- Log.e(TAG, "Unable to load mod assets!");
- e.printStackTrace();
- }
- }
+ if (isEngine) {
+ am = getAssets();
+ } else {
+ try {
+ am = getPackageManager().getResourcesForApplication(getCallingPackage()).getAssets();
+ } catch (Exception e) {
+ Log.e(TAG, "Unable to load mod assets!");
+ e.printStackTrace();
+ }
+ }
- return am;
- }
+ return am;
+ }
- private String[] getAssetsList(boolean isEngine, String path) {
- AssetManager am = getAssets(isEngine);
+ private String[] getAssetsList(boolean isEngine, String path) {
+ AssetManager am = getAssets(isEngine);
- try {
- return am.list(path);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ try {
+ return am.list(path);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
- return new String[]{};
- }
+ return new String[]{};
+ }
- @Override
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (SDLActivity.mBrokenLibraries) {
- return false;
- }
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ if (SDLActivity.mBrokenLibraries) {
+ return false;
+ }
- int keyCode = event.getKeyCode();
- if (!mUseVolumeKeys) {
- if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
- keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
- keyCode == KeyEvent.KEYCODE_CAMERA ||
- keyCode == KeyEvent.KEYCODE_ZOOM_IN ||
- keyCode == KeyEvent.KEYCODE_ZOOM_OUT) {
- return false;
- }
- }
+ int keyCode = event.getKeyCode();
+ if (!mUseVolumeKeys) {
+ if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
+ keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
+ keyCode == KeyEvent.KEYCODE_CAMERA ||
+ keyCode == KeyEvent.KEYCODE_ZOOM_IN ||
+ keyCode == KeyEvent.KEYCODE_ZOOM_OUT) {
+ return false;
+ }
+ }
- return getWindow().superDispatchKeyEvent(event);
- }
+ return getWindow().superDispatchKeyEvent(event);
+ }
- // TODO: REMOVE LATER, temporary launchers support?
- @Override
- protected String[] getArguments() {
- String gamedir = getIntent().getStringExtra("gamedir");
- if (gamedir == null) gamedir = "valve";
- nativeSetenv("XASH3D_GAME", gamedir);
+ // TODO: REMOVE LATER, temporary launchers support?
+ @Override
+ protected String[] getArguments() {
+ String gamedir = getIntent().getStringExtra("gamedir");
+ if (gamedir == null) gamedir = "valve";
+ nativeSetenv("XASH3D_GAME", gamedir);
- String gamelibdir = getIntent().getStringExtra("gamelibdir");
- if (gamelibdir != null) nativeSetenv("XASH3D_GAMELIBDIR", gamelibdir);
+ String gamelibdir = getIntent().getStringExtra("gamelibdir");
+ if (gamelibdir != null) nativeSetenv("XASH3D_GAMELIBDIR", gamelibdir);
- String pakfile = getIntent().getStringExtra("pakfile");
- if (pakfile != null) nativeSetenv("XASH3D_EXTRAS_PAK2", pakfile);
+ String pakfile = getIntent().getStringExtra("pakfile");
+ if (pakfile != null) nativeSetenv("XASH3D_EXTRAS_PAK2", pakfile);
- mUseVolumeKeys = getIntent().getBooleanExtra("usevolume", false);
- mPackageName = getIntent().getStringExtra("package");
+ mUseVolumeKeys = getIntent().getBooleanExtra("usevolume", false);
+ mPackageName = getIntent().getStringExtra("package");
- String[] env = getIntent().getStringArrayExtra("env");
- if (env != null) {
- for (int i = 0; i < env.length; i += 2)
- nativeSetenv(env[i], env[i + 1]);
- }
+ String[] env = getIntent().getStringArrayExtra("env");
+ if (env != null) {
+ for (int i = 0; i < env.length; i += 2)
+ nativeSetenv(env[i], env[i + 1]);
+ }
- String argv = getIntent().getStringExtra("argv");
- if (argv == null) argv = "-console -log";
- return argv.split(" ");
- }
+ String argv = getIntent().getStringExtra("argv");
+ if (argv == null) argv = "-console -log";
+ return argv.split(" ");
+ }
}
diff --git a/android/app/src/main/java/su/xash/engine/adapters/GameAdapter.kt b/android/app/src/main/java/su/xash/engine/adapters/GameAdapter.kt
index dacb5a43..d89e87bb 100644
--- a/android/app/src/main/java/su/xash/engine/adapters/GameAdapter.kt
+++ b/android/app/src/main/java/su/xash/engine/adapters/GameAdapter.kt
@@ -14,64 +14,64 @@ import su.xash.engine.ui.library.LibraryViewModel
class GameAdapter(private val libraryViewModel: LibraryViewModel) :
- ListAdapter(DiffCallback()) {
+ ListAdapter(DiffCallback()) {
- override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GameAdapter.GameViewHolder {
- val binding = CardGameBinding.inflate(LayoutInflater.from(parent.context), parent, false)
- return GameViewHolder(binding)
- }
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GameAdapter.GameViewHolder {
+ val binding = CardGameBinding.inflate(LayoutInflater.from(parent.context), parent, false)
+ return GameViewHolder(binding)
+ }
- override fun onBindViewHolder(holder: GameAdapter.GameViewHolder, position: Int) {
- return holder.bind(getItem(position))
- }
+ override fun onBindViewHolder(holder: GameAdapter.GameViewHolder, position: Int) {
+ return holder.bind(getItem(position))
+ }
- private class DiffCallback : DiffUtil.ItemCallback() {
- override fun areItemsTheSame(oldItem: Game, newItem: Game): Boolean {
- return oldItem.basedir.name == newItem.basedir.name
- }
+ private class DiffCallback : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(oldItem: Game, newItem: Game): Boolean {
+ return oldItem.basedir.name == newItem.basedir.name
+ }
- override fun areContentsTheSame(oldItem: Game, newItem: Game): Boolean {
- return oldItem.basedir.name == newItem.basedir.name && oldItem.installed == newItem.installed
- }
+ override fun areContentsTheSame(oldItem: Game, newItem: Game): Boolean {
+ return oldItem.basedir.name == newItem.basedir.name && oldItem.installed == newItem.installed
+ }
- }
+ }
- inner class GameViewHolder(val binding: CardGameBinding) :
- RecyclerView.ViewHolder(binding.root) {
- fun bind(game: Game) {
- binding.apply {
- gameTitle.text = game.title
+ inner class GameViewHolder(val binding: CardGameBinding) :
+ RecyclerView.ViewHolder(binding.root) {
+ fun bind(game: Game) {
+ binding.apply {
+ gameTitle.text = game.title
- if (game.icon != null) {
- gameIcon.setImageBitmap(game.icon)
- } else {
- gameIcon.visibility = View.GONE
- }
+ if (game.icon != null) {
+ gameIcon.setImageBitmap(game.icon)
+ } else {
+ gameIcon.visibility = View.GONE
+ }
- if (game.cover != null) {
- gameCover.setImageBitmap(game.cover)
- } else {
- gameCover.visibility = View.GONE
- }
+ if (game.cover != null) {
+ gameCover.setImageBitmap(game.cover)
+ } else {
+ gameCover.visibility = View.GONE
+ }
- if (!game.installed) {
- launchButton.visibility = View.GONE
- settingsButton.visibility = View.GONE
- progressIndicator.visibility = View.VISIBLE
- return
- }
+ if (!game.installed) {
+ launchButton.visibility = View.GONE
+ settingsButton.visibility = View.GONE
+ progressIndicator.visibility = View.VISIBLE
+ return
+ }
- settingsButton.setOnClickListener {
- libraryViewModel.setSelectedGame(game)
- it.findNavController()
- .navigate(R.id.action_libraryFragment_to_gameSettingsFragment)
- }
+ settingsButton.setOnClickListener {
+ libraryViewModel.setSelectedGame(game)
+ it.findNavController()
+ .navigate(R.id.action_libraryFragment_to_gameSettingsFragment)
+ }
- root.setOnClickListener { libraryViewModel.startEngine(it.context, game) }
- launchButton.setOnClickListener {
- libraryViewModel.startEngine(it.context, game)
- }
- }
- }
- }
-}
\ No newline at end of file
+ root.setOnClickListener { libraryViewModel.startEngine(it.context, game) }
+ launchButton.setOnClickListener {
+ libraryViewModel.startEngine(it.context, game)
+ }
+ }
+ }
+ }
+}
diff --git a/android/app/src/main/java/su/xash/engine/model/BackgroundBitmap.kt b/android/app/src/main/java/su/xash/engine/model/BackgroundBitmap.kt
index d7443070..d2726974 100644
--- a/android/app/src/main/java/su/xash/engine/model/BackgroundBitmap.kt
+++ b/android/app/src/main/java/su/xash/engine/model/BackgroundBitmap.kt
@@ -9,81 +9,81 @@ import java.util.Scanner
object BackgroundBitmap {
- private const val BACKGROUND_ROWS = 3
- private const val BACKGROUND_COLUMNS = 4
- private const val BACKGROUND_WIDTH = 800
- private const val BACKGROUND_HEIGHT = 600
+ private const val BACKGROUND_ROWS = 3
+ private const val BACKGROUND_COLUMNS = 4
+ private const val BACKGROUND_WIDTH = 800
+ private const val BACKGROUND_HEIGHT = 600
- fun createBackground(ctx: Context, file: DocumentFile): Bitmap {
- var bitmap =
- Bitmap.createBitmap(BACKGROUND_WIDTH, BACKGROUND_HEIGHT, Bitmap.Config.ARGB_8888)
- var canvas = Canvas(bitmap)
- var x: Int
- var y = 0
- var width: Int
- var height = 0
+ fun createBackground(ctx: Context, file: DocumentFile): Bitmap {
+ var bitmap =
+ Bitmap.createBitmap(BACKGROUND_WIDTH, BACKGROUND_HEIGHT, Bitmap.Config.ARGB_8888)
+ var canvas = Canvas(bitmap)
+ var x: Int
+ var y = 0
+ var width: Int
+ var height = 0
- var bgLayout = file.findFile("resource")?.findFile("HD_BackgroundLayout.txt")
- if (bgLayout == null) {
- bgLayout = file.findFile("resource")?.findFile("BackgroundLayout.txt")
- }
+ var bgLayout = file.findFile("resource")?.findFile("HD_BackgroundLayout.txt")
+ if (bgLayout == null) {
+ bgLayout = file.findFile("resource")?.findFile("BackgroundLayout.txt")
+ }
- if (bgLayout == null) {
- val dir = file.findFile("resource")?.findFile("background")
- for (i in 0 until BACKGROUND_ROWS) {
- x = 0
- for (j in 0 until BACKGROUND_COLUMNS) {
- val filename = "${BACKGROUND_WIDTH}_${i + 1}_${'a' + j}_loading.tga"
- val bmpFile = dir?.findFile(filename)
- val bmpImage = loadTga(ctx, bmpFile!!)
+ if (bgLayout == null) {
+ val dir = file.findFile("resource")?.findFile("background")
+ for (i in 0 until BACKGROUND_ROWS) {
+ x = 0
+ for (j in 0 until BACKGROUND_COLUMNS) {
+ val filename = "${BACKGROUND_WIDTH}_${i + 1}_${'a' + j}_loading.tga"
+ val bmpFile = dir?.findFile(filename)
+ val bmpImage = loadTga(ctx, bmpFile!!)
- canvas.drawBitmap(bmpImage, x.toFloat(), y.toFloat(), null)
- x += bmpImage.width
- height = bmpImage.height
+ canvas.drawBitmap(bmpImage, x.toFloat(), y.toFloat(), null)
+ x += bmpImage.width
+ height = bmpImage.height
- }
- y += height
- }
- return bitmap
- }
+ }
+ y += height
+ }
+ return bitmap
+ }
- ctx.contentResolver.openInputStream(bgLayout.uri).use { inputStream ->
- Scanner(inputStream).use { scanner ->
- while (scanner.hasNext()) {
- when (val str = scanner.next()) {
- "resolution" -> {
- width = scanner.nextInt()
- height = scanner.nextInt()
- bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
- canvas = Canvas(bitmap)
- }
+ ctx.contentResolver.openInputStream(bgLayout.uri).use { inputStream ->
+ Scanner(inputStream).use { scanner ->
+ while (scanner.hasNext()) {
+ when (val str = scanner.next()) {
+ "resolution" -> {
+ width = scanner.nextInt()
+ height = scanner.nextInt()
+ bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
+ canvas = Canvas(bitmap)
+ }
- else -> {
- var bmpFile = file
- str.split("/").forEach { bmpFile = bmpFile.findFile(it)!! }
- //skip
- scanner.next()
- x = scanner.nextInt()
- y = scanner.nextInt()
- val bmp = loadTga(ctx, bmpFile)
- canvas.drawBitmap(bmp, x.toFloat(), y.toFloat(), null)
- }
- }
- }
- }
- }
- return bitmap
- }
+ else -> {
+ var bmpFile = file
+ str.split("/").forEach { bmpFile = bmpFile.findFile(it)!! }
+ //skip
+ scanner.next()
+ x = scanner.nextInt()
+ y = scanner.nextInt()
+ val bmp = loadTga(ctx, bmpFile)
+ canvas.drawBitmap(bmp, x.toFloat(), y.toFloat(), null)
+ }
+ }
+ }
+ }
+ }
+ return bitmap
+ }
- private fun loadTga(ctx: Context, file: DocumentFile): Bitmap {
- ctx.contentResolver.openInputStream(file.uri).use {
- val buffer = it?.readBytes()
- val pixels = TGAReader.read(buffer, TGAReader.ARGB)
+ private fun loadTga(ctx: Context, file: DocumentFile): Bitmap {
+ ctx.contentResolver.openInputStream(file.uri).use {
+ val buffer = it?.readBytes()
+ val pixels = TGAReader.read(buffer, TGAReader.ARGB)
- val width = TGAReader.getWidth(buffer)
- val height = TGAReader.getHeight(buffer)
+ val width = TGAReader.getWidth(buffer)
+ val height = TGAReader.getHeight(buffer)
- return Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.ARGB_8888)
- }
- }
-}
\ No newline at end of file
+ return Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.ARGB_8888)
+ }
+ }
+}
diff --git a/android/app/src/main/java/su/xash/engine/model/Game.kt b/android/app/src/main/java/su/xash/engine/model/Game.kt
index d8a389c7..dc4b307e 100644
--- a/android/app/src/main/java/su/xash/engine/model/Game.kt
+++ b/android/app/src/main/java/su/xash/engine/model/Game.kt
@@ -12,111 +12,111 @@ import su.xash.engine.XashActivity
class Game(val ctx: Context, val basedir: DocumentFile, var installed: Boolean = true) {
- private var iconName = "game.ico"
- var title = "Unknown Game"
- var icon: Bitmap? = null
- var cover: Bitmap? = null
+ private var iconName = "game.ico"
+ var title = "Unknown Game"
+ var icon: Bitmap? = null
+ var cover: Bitmap? = null
- private val pref = ctx.getSharedPreferences(basedir.name, Context.MODE_PRIVATE)
+ private val pref = ctx.getSharedPreferences(basedir.name, Context.MODE_PRIVATE)
- init {
- basedir.findFile("gameinfo.txt")?.let {
- parseGameInfo(it)
- } ?: basedir.findFile("liblist.gam")?.let { parseGameInfo(it) }
+ init {
+ basedir.findFile("gameinfo.txt")?.let {
+ parseGameInfo(it)
+ } ?: basedir.findFile("liblist.gam")?.let { parseGameInfo(it) }
- basedir.findFile(iconName)
- ?.let { icon = MediaStore.Images.Media.getBitmap(ctx.contentResolver, it.uri) }
+ basedir.findFile(iconName)
+ ?.let { icon = MediaStore.Images.Media.getBitmap(ctx.contentResolver, it.uri) }
- try {
- cover = BackgroundBitmap.createBackground(ctx, basedir)
- } catch (e: Exception) {
- e.printStackTrace()
- }
- }
+ try {
+ cover = BackgroundBitmap.createBackground(ctx, basedir)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
- fun startEngine(ctx: Context) {
- ctx.startActivity(Intent(ctx, XashActivity::class.java).apply {
- flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
- putExtra("gamedir", basedir.name)
- putExtra("argv", pref.getString("arguments", "-console -log"))
- putExtra("usevolume", pref.getBoolean("use_volume_buttons", false))
- //.putExtra("gamelibdir", getGameLibDir(context))
- //.putExtra("package", getPackageName()) }
- })
- }
+ fun startEngine(ctx: Context) {
+ ctx.startActivity(Intent(ctx, XashActivity::class.java).apply {
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
+ putExtra("gamedir", basedir.name)
+ putExtra("argv", pref.getString("arguments", "-console -log"))
+ putExtra("usevolume", pref.getBoolean("use_volume_buttons", false))
+ //.putExtra("gamelibdir", getGameLibDir(context))
+ //.putExtra("package", getPackageName()) }
+ })
+ }
- private fun parseGameInfo(file: DocumentFile) {
- ctx.contentResolver.openInputStream(file.uri).use { inputStream ->
- inputStream?.bufferedReader().use { reader ->
- reader?.forEachLine {
- val tokens = it.split("\\s+".toRegex(), limit = 2)
- if (tokens.size >= 2) {
- val k = tokens[0]
- val v = tokens[1].trim('"')
+ private fun parseGameInfo(file: DocumentFile) {
+ ctx.contentResolver.openInputStream(file.uri).use { inputStream ->
+ inputStream?.bufferedReader().use { reader ->
+ reader?.forEachLine {
+ val tokens = it.split("\\s+".toRegex(), limit = 2)
+ if (tokens.size >= 2) {
+ val k = tokens[0]
+ val v = tokens[1].trim('"')
- if (k == "title" || k == "game") title = v
- if (k == "icon") iconName = v
- }
- }
- }
- }
- }
+ if (k == "title" || k == "game") title = v
+ if (k == "icon") iconName = v
+ }
+ }
+ }
+ }
+ }
- private fun getPackageName(): String? {
+ private fun getPackageName(): String? {
// return if (mDbEntry != null) {
// mDbEntry.getPackageName()
// } else null
- return null
- }
+ return null
+ }
- private fun getGameLibDir(ctx: Context): String? {
- val pkgName = getPackageName()
- if (pkgName != null) {
- val pkgInfo: PackageInfo = try {
- ctx.packageManager.getPackageInfo(pkgName, 0)
- } catch (e: PackageManager.NameNotFoundException) {
- e.printStackTrace()
- ctx.startActivity(
- Intent(
- Intent.ACTION_VIEW, Uri.parse("market://details?id=$pkgName")
- ).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
- )
- return null
- }
- return pkgInfo.applicationInfo.nativeLibraryDir
- }
- return ctx.applicationInfo.nativeLibraryDir
- }
+ private fun getGameLibDir(ctx: Context): String? {
+ val pkgName = getPackageName()
+ if (pkgName != null) {
+ val pkgInfo: PackageInfo = try {
+ ctx.packageManager.getPackageInfo(pkgName, 0)
+ } catch (e: PackageManager.NameNotFoundException) {
+ e.printStackTrace()
+ ctx.startActivity(
+ Intent(
+ Intent.ACTION_VIEW, Uri.parse("market://details?id=$pkgName")
+ ).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
+ )
+ return null
+ }
+ return pkgInfo.applicationInfo.nativeLibraryDir
+ }
+ return ctx.applicationInfo.nativeLibraryDir
+ }
- companion object {
- fun getGames(ctx: Context, file: DocumentFile): List {
- val games = mutableListOf()
+ companion object {
+ fun getGames(ctx: Context, file: DocumentFile): List {
+ val games = mutableListOf()
- if (checkIfGamedir(file)) {
- games.add(Game(ctx, file))
- } else {
- file.listFiles().forEach {
- if (it.isDirectory) {
- if (checkIfGamedir(it)) {
- games.add(Game(ctx, it))
- }
- }
- }
- }
+ if (checkIfGamedir(file)) {
+ games.add(Game(ctx, file))
+ } else {
+ file.listFiles().forEach {
+ if (it.isDirectory) {
+ if (checkIfGamedir(it)) {
+ games.add(Game(ctx, it))
+ }
+ }
+ }
+ }
- return games
- }
+ return games
+ }
- fun checkIfGamedir(file: DocumentFile): Boolean {
- // exclude unfinished downloads
- if (file.name?.startsWith('.') == true)
- return false
+ fun checkIfGamedir(file: DocumentFile): Boolean {
+ // exclude unfinished downloads
+ if (file.name?.startsWith('.') == true)
+ return false
- file.findFile("liblist.gam")?.let { return true }
- file.findFile("gameinfo.txt")?.let { return true }
- return false
- }
- }
+ file.findFile("liblist.gam")?.let { return true }
+ file.findFile("gameinfo.txt")?.let { return true }
+ return false
+ }
+ }
}
// Intent intent = new Intent("su.xash.engine.MOD");
diff --git a/android/app/src/main/java/su/xash/engine/model/ModDatabase.kt b/android/app/src/main/java/su/xash/engine/model/ModDatabase.kt
index a7720598..8fed465e 100644
--- a/android/app/src/main/java/su/xash/engine/model/ModDatabase.kt
+++ b/android/app/src/main/java/su/xash/engine/model/ModDatabase.kt
@@ -5,55 +5,55 @@ import org.json.JSONObject
import java.io.InputStream
class ModDatabase(inputStream: InputStream) {
- val entries = mutableListOf()
+ val entries = mutableListOf()
- companion object {
- const val VERSION = 1
+ companion object {
+ const val VERSION = 1
- fun getFilename(): String {
- return "v${VERSION}.json"
- }
- }
+ fun getFilename(): String {
+ return "v${VERSION}.json"
+ }
+ }
- init {
- inputStream.bufferedReader().use {
- val jsonArray = JSONArray(it.readText())
+ init {
+ inputStream.bufferedReader().use {
+ val jsonArray = JSONArray(it.readText())
- for (i in 0.. {
- try {
- startActivity(
- Intent(Intent.ACTION_VIEW).setDataAndType(
- null, "vnd.android.document/directory"
- )
- )
- }
- catch(e: ActivityNotFoundException) {
- Toast.makeText(getActivity(), R.string.library_fragment_no_file_manager, Toast.LENGTH_LONG).show()
- }
- }
+ override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
+ when (menuItem.itemId) {
+ R.id.action_browse -> {
+ startActivity(
+ Intent(Intent.ACTION_VIEW).setDataAndType(
+ null, "vnd.android.document/directory"
+ )
+ )
+ }
- R.id.action_install -> {
- findNavController().navigate(R.id.action_libraryFragment_to_setupFragment)
- }
+ R.id.action_install -> {
+ findNavController().navigate(R.id.action_libraryFragment_to_setupFragment)
+ }
- R.id.action_settings -> {
- findNavController().navigate(R.id.action_libraryFragment_to_appSettingsFragment)
- }
- }
+ R.id.action_settings -> {
+ findNavController().navigate(R.id.action_libraryFragment_to_appSettingsFragment)
+ }
+ }
- return false
- }
+ return false
+ }
}
diff --git a/android/app/src/main/java/su/xash/engine/ui/library/LibraryViewModel.kt b/android/app/src/main/java/su/xash/engine/ui/library/LibraryViewModel.kt
index b82c8321..90af9d0c 100644
--- a/android/app/src/main/java/su/xash/engine/ui/library/LibraryViewModel.kt
+++ b/android/app/src/main/java/su/xash/engine/ui/library/LibraryViewModel.kt
@@ -2,126 +2,118 @@ package su.xash.engine.ui.library
import android.app.Application
import android.content.Context
-import android.content.SharedPreferences
import android.net.Uri
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
-import androidx.lifecycle.ViewModel
-import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.viewModelScope
-import androidx.preference.PreferenceManager
import androidx.work.Data
import androidx.work.OneTimeWorkRequestBuilder
-import androidx.work.OutOfQuotaPolicy
import androidx.work.WorkInfo
import androidx.work.WorkManager
import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import su.xash.engine.model.Game
import su.xash.engine.model.ModDatabase
import su.xash.engine.workers.FileCopyWorker
import su.xash.engine.workers.KEY_FILE_URI
-import java.util.Locale
const val TAG_INSTALL = "TAG_INSTALL"
class LibraryViewModel(application: Application) : AndroidViewModel(application) {
- val installedGames: LiveData> get() = _installedGames
- private val _installedGames = MutableLiveData(emptyList())
+ val installedGames: LiveData> get() = _installedGames
+ private val _installedGames = MutableLiveData(emptyList())
- val downloads: LiveData> get() = _downloads
- private val _downloads = MutableLiveData(emptyList())
+ val downloads: LiveData> get() = _downloads
+ private val _downloads = MutableLiveData(emptyList())
- val isReloading: LiveData get() = _isReloading
- private val _isReloading = MutableLiveData(false)
+ val isReloading: LiveData get() = _isReloading
+ private val _isReloading = MutableLiveData(false)
- private val workManager = WorkManager.getInstance(application.applicationContext)
- val workInfos: LiveData> = workManager.getWorkInfosByTagLiveData(TAG_INSTALL)
+ private val workManager = WorkManager.getInstance(application.applicationContext)
+ val workInfos: LiveData> = workManager.getWorkInfosByTagLiveData(TAG_INSTALL)
- val selectedItem: LiveData get() = _selectedItem
- private val _selectedItem = MutableLiveData()
+ val selectedItem: LiveData get() = _selectedItem
+ private val _selectedItem = MutableLiveData()
- val appPreferences = application.getSharedPreferences("app_preferences", Context.MODE_PRIVATE)
- val modDb: ModDatabase
+ val appPreferences = application.getSharedPreferences("app_preferences", Context.MODE_PRIVATE)
+ val modDb: ModDatabase
- init {
- modDb = application.assets.open(ModDatabase.getFilename()).use { ModDatabase(it) }
- reloadGames(application.applicationContext)
- }
+ init {
+ modDb = application.assets.open(ModDatabase.getFilename()).use { ModDatabase(it) }
+ reloadGames(application.applicationContext)
+ }
- fun reloadGames(ctx: Context) {
- if (isReloading.value == true) {
- return
- }
- _isReloading.value = true
+ fun reloadGames(ctx: Context) {
+ if (isReloading.value == true) {
+ return
+ }
+ _isReloading.value = true
- viewModelScope.launch {
- withContext(Dispatchers.IO) {
- val games = mutableListOf()
- val root = DocumentFile.fromFile(ctx.getExternalFilesDir(null)!!)
+ viewModelScope.launch {
+ withContext(Dispatchers.IO) {
+ val games = mutableListOf()
+ val root = DocumentFile.fromFile(ctx.getExternalFilesDir(null)!!)
- val installedGames = Game.getGames(ctx, root)
- .filter { p -> _downloads.value?.any { p.basedir.name == it.basedir.name } == false }
+ val installedGames = Game.getGames(ctx, root)
+ .filter { p -> _downloads.value?.any { p.basedir.name == it.basedir.name } == false }
- games.addAll(installedGames)
- downloads.value?.let { games.addAll(it) }
+ games.addAll(installedGames)
+ downloads.value?.let { games.addAll(it) }
- _installedGames.postValue(games)
- _isReloading.postValue(false)
- }
- }
- }
+ _installedGames.postValue(games)
+ _isReloading.postValue(false)
+ }
+ }
+ }
- fun refreshDownloads(ctx: Context) {
- viewModelScope.launch {
- withContext(Dispatchers.IO) {
- val games = mutableListOf()
+ fun refreshDownloads(ctx: Context) {
+ viewModelScope.launch {
+ withContext(Dispatchers.IO) {
+ val games = mutableListOf()
- workInfos.value?.filter {
- it.state == WorkInfo.State.RUNNING && !it.progress.getString(FileCopyWorker.Input)
- .isNullOrEmpty()
- }?.forEach {
- val uri = Uri.parse(it.progress.getString(FileCopyWorker.Input))
- val file = DocumentFile.fromTreeUri(ctx, uri)
- games.addAll(Game.getGames(ctx, file!!))
- games.forEach { g -> g.installed = false }
- }
+ workInfos.value?.filter {
+ it.state == WorkInfo.State.RUNNING && !it.progress.getString(FileCopyWorker.Input)
+ .isNullOrEmpty()
+ }?.forEach {
+ val uri = Uri.parse(it.progress.getString(FileCopyWorker.Input))
+ val file = DocumentFile.fromTreeUri(ctx, uri)
+ games.addAll(Game.getGames(ctx, file!!))
+ games.forEach { g -> g.installed = false }
+ }
- _downloads.postValue(games)
- }
- }
- }
+ _downloads.postValue(games)
+ }
+ }
+ }
- fun installGame(uri: Uri) {
- val data = Data.Builder().putString(KEY_FILE_URI, uri.toString()).build()
- val request = OneTimeWorkRequestBuilder().run {
- setInputData(data)
- addTag(TAG_INSTALL)
- build()
- }
- workManager.enqueue(request)
- }
+ fun installGame(uri: Uri) {
+ val data = Data.Builder().putString(KEY_FILE_URI, uri.toString()).build()
+ val request = OneTimeWorkRequestBuilder().run {
+ setInputData(data)
+ addTag(TAG_INSTALL)
+ build()
+ }
+ workManager.enqueue(request)
+ }
- fun setSelectedGame(game: Game) {
- _selectedItem.value = game
- }
+ fun setSelectedGame(game: Game) {
+ _selectedItem.value = game
+ }
- fun uninstallGame(game: Game) {
- viewModelScope.launch {
- withContext(Dispatchers.IO) {
- game.installed = false
- game.basedir.delete()
- _installedGames.postValue(_installedGames.value)
- }
- }
- }
+ fun uninstallGame(game: Game) {
+ viewModelScope.launch {
+ withContext(Dispatchers.IO) {
+ game.installed = false
+ game.basedir.delete()
+ _installedGames.postValue(_installedGames.value)
+ }
+ }
+ }
- fun startEngine(ctx: Context, game: Game) {
- game.startEngine(ctx)
- }
-}
\ No newline at end of file
+ fun startEngine(ctx: Context, game: Game) {
+ game.startEngine(ctx)
+ }
+}
diff --git a/android/app/src/main/java/su/xash/engine/ui/settings/AppSettingsFragment.kt b/android/app/src/main/java/su/xash/engine/ui/settings/AppSettingsFragment.kt
index 57dcfe01..7bdb08a8 100644
--- a/android/app/src/main/java/su/xash/engine/ui/settings/AppSettingsFragment.kt
+++ b/android/app/src/main/java/su/xash/engine/ui/settings/AppSettingsFragment.kt
@@ -8,24 +8,24 @@ import androidx.fragment.app.Fragment
import su.xash.engine.databinding.FragmentAppSettingsBinding
class AppSettingsFragment : Fragment() {
- private var _binding: FragmentAppSettingsBinding? = null
- private val binding get() = _binding!!
+ private var _binding: FragmentAppSettingsBinding? = null
+ private val binding get() = _binding!!
- override fun onCreateView(
- inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
- ): View? {
- _binding = FragmentAppSettingsBinding.inflate(inflater, container, false)
- return binding.root
- }
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
+ ): View? {
+ _binding = FragmentAppSettingsBinding.inflate(inflater, container, false)
+ return binding.root
+ }
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- childFragmentManager.beginTransaction()
- .add(binding.settingsFragment.id, AppSettingsPreferenceFragment()).commit();
- }
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ childFragmentManager.beginTransaction()
+ .add(binding.settingsFragment.id, AppSettingsPreferenceFragment()).commit();
+ }
- override fun onDestroyView() {
- super.onDestroyView()
- _binding = null
- }
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
+ }
}
diff --git a/android/app/src/main/java/su/xash/engine/ui/settings/AppSettingsPreferenceFragment.kt b/android/app/src/main/java/su/xash/engine/ui/settings/AppSettingsPreferenceFragment.kt
index c60513fc..3d61560f 100644
--- a/android/app/src/main/java/su/xash/engine/ui/settings/AppSettingsPreferenceFragment.kt
+++ b/android/app/src/main/java/su/xash/engine/ui/settings/AppSettingsPreferenceFragment.kt
@@ -5,8 +5,8 @@ import androidx.preference.PreferenceFragmentCompat
import su.xash.engine.R
class AppSettingsPreferenceFragment() : PreferenceFragmentCompat() {
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- preferenceManager.sharedPreferencesName = "app_preferences";
- setPreferencesFromResource(R.xml.app_preferences, rootKey);
- }
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ preferenceManager.sharedPreferencesName = "app_preferences";
+ setPreferencesFromResource(R.xml.app_preferences, rootKey);
+ }
}
diff --git a/android/app/src/main/java/su/xash/engine/ui/settings/GameSettingsFragment.kt b/android/app/src/main/java/su/xash/engine/ui/settings/GameSettingsFragment.kt
index eecfa04a..dd7bd2fb 100644
--- a/android/app/src/main/java/su/xash/engine/ui/settings/GameSettingsFragment.kt
+++ b/android/app/src/main/java/su/xash/engine/ui/settings/GameSettingsFragment.kt
@@ -12,53 +12,53 @@ import su.xash.engine.databinding.FragmentGameSettingsBinding
import su.xash.engine.ui.library.LibraryViewModel
class GameSettingsFragment : Fragment() {
- private var _binding: FragmentGameSettingsBinding? = null
- private val binding get() = _binding!!
+ private var _binding: FragmentGameSettingsBinding? = null
+ private val binding get() = _binding!!
- private val libraryViewModel: LibraryViewModel by activityViewModels()
+ private val libraryViewModel: LibraryViewModel by activityViewModels()
- override fun onCreateView(
- inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
- ): View? {
- _binding = FragmentGameSettingsBinding.inflate(inflater, container, false)
- return binding.root
- }
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
+ ): View? {
+ _binding = FragmentGameSettingsBinding.inflate(inflater, container, false)
+ return binding.root
+ }
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
- val game = libraryViewModel.selectedItem.value!!
+ val game = libraryViewModel.selectedItem.value!!
- binding.gameCard.apply {
- gameTitle.text = game.title
+ binding.gameCard.apply {
+ gameTitle.text = game.title
- if (game.icon != null) {
- gameIcon.setImageBitmap(game.icon)
- } else {
- gameIcon.visibility = View.GONE
- }
+ if (game.icon != null) {
+ gameIcon.setImageBitmap(game.icon)
+ } else {
+ gameIcon.visibility = View.GONE
+ }
- if (game.cover != null) {
- gameCover.setImageBitmap(game.cover)
- } else {
- gameCover.visibility = View.GONE
- }
+ if (game.cover != null) {
+ gameCover.setImageBitmap(game.cover)
+ } else {
+ gameCover.visibility = View.GONE
+ }
- buttonsContainer.visibility = View.GONE
- }
+ buttonsContainer.visibility = View.GONE
+ }
- childFragmentManager.beginTransaction()
- .add(binding.settingsFragment.id, GameSettingsPreferenceFragment(game))
- .commit();
+ childFragmentManager.beginTransaction()
+ .add(binding.settingsFragment.id, GameSettingsPreferenceFragment(game))
+ .commit();
- binding.bottomNavigation.menu.findItem(R.id.action_uninstall).setOnMenuItemClickListener {
- libraryViewModel.uninstallGame(game)
- findNavController().popBackStack()
- }
- }
+ binding.bottomNavigation.menu.findItem(R.id.action_uninstall).setOnMenuItemClickListener {
+ libraryViewModel.uninstallGame(game)
+ findNavController().popBackStack()
+ }
+ }
- override fun onDestroyView() {
- super.onDestroyView()
- _binding = null
- }
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
+ }
}
diff --git a/android/app/src/main/java/su/xash/engine/ui/settings/GameSettingsPreferenceFragment.kt b/android/app/src/main/java/su/xash/engine/ui/settings/GameSettingsPreferenceFragment.kt
index 00316756..7e765078 100644
--- a/android/app/src/main/java/su/xash/engine/ui/settings/GameSettingsPreferenceFragment.kt
+++ b/android/app/src/main/java/su/xash/engine/ui/settings/GameSettingsPreferenceFragment.kt
@@ -8,33 +8,33 @@ import su.xash.engine.R
import su.xash.engine.model.Game
class GameSettingsPreferenceFragment(val game: Game) : PreferenceFragmentCompat() {
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- preferenceManager.sharedPreferencesName = game.basedir.name;
- setPreferencesFromResource(R.xml.game_preferences, rootKey);
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ preferenceManager.sharedPreferencesName = game.basedir.name;
+ setPreferencesFromResource(R.xml.game_preferences, rootKey);
- val packageList = findPreference("package_name")!!
- packageList.entries = arrayOf(getString(R.string.app_name))
- packageList.entryValues = arrayOf(requireContext().packageName)
+ val packageList = findPreference("package_name")!!
+ packageList.entries = arrayOf(getString(R.string.app_name))
+ packageList.entryValues = arrayOf(requireContext().packageName)
- if (packageList.value == null) {
- packageList.setValueIndex(0);
- }
+ if (packageList.value == null) {
+ packageList.setValueIndex(0);
+ }
- val separatePackages = findPreference("separate_libraries")!!
- val clientPackage = findPreference("client_package")!!
- val serverPackage = findPreference("server_package")!!
- separatePackages.setOnPreferenceChangeListener { _, newValue ->
- if (newValue == true) {
- packageList.isVisible = false
- clientPackage.isVisible = true
- serverPackage.isVisible = true
- } else {
- packageList.isVisible = true
- clientPackage.isVisible = false
- serverPackage.isVisible = false
- }
+ val separatePackages = findPreference("separate_libraries")!!
+ val clientPackage = findPreference("client_package")!!
+ val serverPackage = findPreference("server_package")!!
+ separatePackages.setOnPreferenceChangeListener { _, newValue ->
+ if (newValue == true) {
+ packageList.isVisible = false
+ clientPackage.isVisible = true
+ serverPackage.isVisible = true
+ } else {
+ packageList.isVisible = true
+ clientPackage.isVisible = false
+ serverPackage.isVisible = false
+ }
- true
- }
- }
+ true
+ }
+ }
}
diff --git a/android/app/src/main/java/su/xash/engine/ui/setup/SetupFragment.kt b/android/app/src/main/java/su/xash/engine/ui/setup/SetupFragment.kt
index 8d6a886d..e15f9dc0 100644
--- a/android/app/src/main/java/su/xash/engine/ui/setup/SetupFragment.kt
+++ b/android/app/src/main/java/su/xash/engine/ui/setup/SetupFragment.kt
@@ -12,37 +12,37 @@ import su.xash.engine.ui.setup.pages.LocationPageFragment
import su.xash.engine.ui.setup.pages.WelcomePageFragment
class SetupFragment : Fragment() {
- private var _binding: FragmentSetupBinding? = null
- private val binding get() = _binding!!
- private val setupViewModel: SetupViewModel by activityViewModels()
+ private var _binding: FragmentSetupBinding? = null
+ private val binding get() = _binding!!
+ private val setupViewModel: SetupViewModel by activityViewModels()
- private lateinit var setupPageAdapter: SetupPageAdapter
+ private lateinit var setupPageAdapter: SetupPageAdapter
- override fun onCreateView(
- inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
- ): View? {
- _binding = FragmentSetupBinding.inflate(inflater, container, false)
- return binding.root
- }
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
+ ): View? {
+ _binding = FragmentSetupBinding.inflate(inflater, container, false)
+ return binding.root
+ }
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- setupPageAdapter = SetupPageAdapter(this)
- binding.viewPager.isUserInputEnabled = false
- binding.viewPager.adapter = setupPageAdapter
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ setupPageAdapter = SetupPageAdapter(this)
+ binding.viewPager.isUserInputEnabled = false
+ binding.viewPager.adapter = setupPageAdapter
- setupViewModel.pageNumber.observe(viewLifecycleOwner) {
- binding.viewPager.setCurrentItem(it, true)
- }
- }
+ setupViewModel.pageNumber.observe(viewLifecycleOwner) {
+ binding.viewPager.setCurrentItem(it, true)
+ }
+ }
- override fun onDestroyView() {
- super.onDestroyView()
- _binding = null
- }
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
+ }
}
class SetupPageAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
- val pages = listOf(WelcomePageFragment(), LocationPageFragment())
- override fun getItemCount(): Int = 2
- override fun createFragment(position: Int): Fragment = pages[position]
+ val pages = listOf(WelcomePageFragment(), LocationPageFragment())
+ override fun getItemCount(): Int = 2
+ override fun createFragment(position: Int): Fragment = pages[position]
}
diff --git a/android/app/src/main/java/su/xash/engine/ui/setup/SetupViewModel.kt b/android/app/src/main/java/su/xash/engine/ui/setup/SetupViewModel.kt
index fbf5025c..94779cc0 100644
--- a/android/app/src/main/java/su/xash/engine/ui/setup/SetupViewModel.kt
+++ b/android/app/src/main/java/su/xash/engine/ui/setup/SetupViewModel.kt
@@ -10,16 +10,16 @@ import su.xash.engine.MainApplication
import su.xash.engine.model.Game
class SetupViewModel(application: Application) : AndroidViewModel(application) {
- val pageNumber: LiveData get() = _pageNumber
- private val _pageNumber = MutableLiveData(0)
+ val pageNumber: LiveData get() = _pageNumber
+ private val _pageNumber = MutableLiveData(0)
- fun checkIfGameDir(uri: Uri): Boolean {
- val ctx = getApplication().applicationContext
- val file = DocumentFile.fromTreeUri(ctx, uri)!!
- return Game.checkIfGamedir(file)
- }
+ fun checkIfGameDir(uri: Uri): Boolean {
+ val ctx = getApplication().applicationContext
+ val file = DocumentFile.fromTreeUri(ctx, uri)!!
+ return Game.checkIfGamedir(file)
+ }
- fun setPageNumber(pos: Int) {
- _pageNumber.value = pos
- }
+ fun setPageNumber(pos: Int) {
+ _pageNumber.value = pos
+ }
}
diff --git a/android/app/src/main/java/su/xash/engine/ui/setup/pages/LocationPageFragment.kt b/android/app/src/main/java/su/xash/engine/ui/setup/pages/LocationPageFragment.kt
index e4204f0a..a5b1f72d 100644
--- a/android/app/src/main/java/su/xash/engine/ui/setup/pages/LocationPageFragment.kt
+++ b/android/app/src/main/java/su/xash/engine/ui/setup/pages/LocationPageFragment.kt
@@ -16,44 +16,47 @@ import su.xash.engine.ui.library.LibraryViewModel
import su.xash.engine.ui.setup.SetupViewModel
class LocationPageFragment : Fragment() {
- private var _binding: PageLocationBinding? = null
- private val binding get() = _binding!!
- private val setupViewModel: SetupViewModel by activityViewModels()
- private val libraryViewModel: LibraryViewModel by activityViewModels()
+ private var _binding: PageLocationBinding? = null
+ private val binding get() = _binding!!
+ private val setupViewModel: SetupViewModel by activityViewModels()
+ private val libraryViewModel: LibraryViewModel by activityViewModels()
- override fun onCreateView(
- inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
- ): View? {
- _binding = PageLocationBinding.inflate(inflater, container, false)
- return binding.root
- }
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
+ ): View? {
+ _binding = PageLocationBinding.inflate(inflater, container, false)
+ return binding.root
+ }
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- binding.pageButton.setOnClickListener {
- getGamesDirectory.launch(null)
- }
- }
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ binding.pageButton.setOnClickListener {
+ getGamesDirectory.launch(null)
+ }
+ }
- override fun onDestroyView() {
- super.onDestroyView()
- _binding = null
- }
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
+ }
- private val getGamesDirectory =
- registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) {
- it?.let {
- if (!setupViewModel.checkIfGameDir(it)) {
- MaterialAlertDialogBuilder(requireContext()).apply {
- setTitle(R.string.error)
- setMessage(R.string.setup_location_empty)
- setPositiveButton(R.string.ok) { dialog, _ -> dialog.dismiss() }
- show()
- }
- } else {
- requireContext().contentResolver.takePersistableUriPermission(it, Intent.FLAG_GRANT_READ_URI_PERMISSION)
- libraryViewModel.installGame(it)
- findNavController().navigate(R.id.action_setupFragment_to_libraryFragment)
- }
- }
- }
+ private val getGamesDirectory =
+ registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) {
+ it?.let {
+ if (!setupViewModel.checkIfGameDir(it)) {
+ MaterialAlertDialogBuilder(requireContext()).apply {
+ setTitle(R.string.error)
+ setMessage(R.string.setup_location_empty)
+ setPositiveButton(R.string.ok) { dialog, _ -> dialog.dismiss() }
+ show()
+ }
+ } else {
+ requireContext().contentResolver.takePersistableUriPermission(
+ it,
+ Intent.FLAG_GRANT_READ_URI_PERMISSION
+ )
+ libraryViewModel.installGame(it)
+ findNavController().navigate(R.id.action_setupFragment_to_libraryFragment)
+ }
+ }
+ }
}
diff --git a/android/app/src/main/java/su/xash/engine/ui/setup/pages/WelcomePageFragment.kt b/android/app/src/main/java/su/xash/engine/ui/setup/pages/WelcomePageFragment.kt
index 7b901fb8..09327b6b 100644
--- a/android/app/src/main/java/su/xash/engine/ui/setup/pages/WelcomePageFragment.kt
+++ b/android/app/src/main/java/su/xash/engine/ui/setup/pages/WelcomePageFragment.kt
@@ -10,26 +10,26 @@ import su.xash.engine.databinding.PageWelcomeBinding
import su.xash.engine.ui.setup.SetupViewModel
class WelcomePageFragment : Fragment() {
- private var _binding: PageWelcomeBinding? = null
- private val binding get() = _binding!!
- private val setupViewModel: SetupViewModel by activityViewModels()
+ private var _binding: PageWelcomeBinding? = null
+ private val binding get() = _binding!!
+ private val setupViewModel: SetupViewModel by activityViewModels()
- override fun onCreateView(
- inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
- ): View? {
- _binding = PageWelcomeBinding.inflate(inflater, container, false)
- return binding.root
- }
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
+ ): View? {
+ _binding = PageWelcomeBinding.inflate(inflater, container, false)
+ return binding.root
+ }
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- binding.pageButton.setOnClickListener {
- setupViewModel.setPageNumber(1)
- }
- setupViewModel.setPageNumber(0)
- }
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ binding.pageButton.setOnClickListener {
+ setupViewModel.setPageNumber(1)
+ }
+ setupViewModel.setPageNumber(0)
+ }
- override fun onDestroyView() {
- super.onDestroyView()
- _binding = null
- }
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
+ }
}
diff --git a/android/app/src/main/java/su/xash/engine/util/TGAReader.java b/android/app/src/main/java/su/xash/engine/util/TGAReader.java
index 1e9f7d3f..c396315b 100644
--- a/android/app/src/main/java/su/xash/engine/util/TGAReader.java
+++ b/android/app/src/main/java/su/xash/engine/util/TGAReader.java
@@ -18,572 +18,572 @@ import java.io.IOException;
public final class TGAReader {
- public static final Order ARGB = new Order(16, 8, 0, 24);
- public static final Order ABGR = new Order(0, 8, 16, 24);
+ public static final Order ARGB = new Order(16, 8, 0, 24);
+ public static final Order ABGR = new Order(0, 8, 16, 24);
- public static int getWidth(byte[] buffer) {
- return (buffer[12] & 0xFF) | (buffer[13] & 0xFF) << 8;
- }
+ public static int getWidth(byte[] buffer) {
+ return (buffer[12] & 0xFF) | (buffer[13] & 0xFF) << 8;
+ }
- public static int getHeight(byte[] buffer) {
- return (buffer[14] & 0xFF) | (buffer[15] & 0xFF) << 8;
- }
+ public static int getHeight(byte[] buffer) {
+ return (buffer[14] & 0xFF) | (buffer[15] & 0xFF) << 8;
+ }
- public static int[] read(byte[] buffer, Order order) throws IOException {
+ public static int[] read(byte[] buffer, Order order) throws IOException {
- // header
+ // header
// int idFieldLength = buffer[0] & 0xFF;
// int colormapType = buffer[1] & 0xFF;
- int type = buffer[2] & 0xFF;
- int colormapOrigin = (buffer[3] & 0xFF) | (buffer[4] & 0xFF) << 8;
- int colormapLength = (buffer[5] & 0xFF) | (buffer[6] & 0xFF) << 8;
- int colormapDepth = buffer[7] & 0xFF;
+ int type = buffer[2] & 0xFF;
+ int colormapOrigin = (buffer[3] & 0xFF) | (buffer[4] & 0xFF) << 8;
+ int colormapLength = (buffer[5] & 0xFF) | (buffer[6] & 0xFF) << 8;
+ int colormapDepth = buffer[7] & 0xFF;
// int originX = (buffer[8] & 0xFF) | (buffer[9] & 0xFF) << 8; // unsupported
// int originY = (buffer[10] & 0xFF) | (buffer[11] & 0xFF) << 8; // unsupported
- int width = getWidth(buffer);
- int height = getHeight(buffer);
- int depth = buffer[16] & 0xFF;
- int descriptor = buffer[17] & 0xFF;
+ int width = getWidth(buffer);
+ int height = getHeight(buffer);
+ int depth = buffer[16] & 0xFF;
+ int descriptor = buffer[17] & 0xFF;
- int[] pixels;
+ int[] pixels;
- // data
- switch (type) {
- case COLORMAP: {
- int imageDataOffset = 18 + (colormapDepth / 8) * colormapLength;
- pixels = createPixelsFromColormap(width, height, colormapDepth, buffer, imageDataOffset, buffer, colormapOrigin, descriptor, order);
- }
- break;
- case RGB:
- pixels = createPixelsFromRGB(width, height, depth, buffer, 18, descriptor, order);
- break;
- case GRAYSCALE:
- pixels = createPixelsFromGrayscale(width, height, depth, buffer, 18, descriptor, order);
- break;
- case COLORMAP_RLE: {
- int imageDataOffset = 18 + (colormapDepth / 8) * colormapLength;
- byte[] decodeBuffer = decodeRLE(width, height, depth, buffer, imageDataOffset);
- pixels = createPixelsFromColormap(width, height, colormapDepth, decodeBuffer, 0, buffer, colormapOrigin, descriptor, order);
- }
- break;
- case RGB_RLE: {
- byte[] decodeBuffer = decodeRLE(width, height, depth, buffer, 18);
- pixels = createPixelsFromRGB(width, height, depth, decodeBuffer, 0, descriptor, order);
- }
- break;
- case GRAYSCALE_RLE: {
- byte[] decodeBuffer = decodeRLE(width, height, depth, buffer, 18);
- pixels = createPixelsFromGrayscale(width, height, depth, decodeBuffer, 0, descriptor, order);
- }
- break;
- default:
- throw new IOException("Unsupported image type: " + type);
- }
+ // data
+ switch (type) {
+ case COLORMAP: {
+ int imageDataOffset = 18 + (colormapDepth / 8) * colormapLength;
+ pixels = createPixelsFromColormap(width, height, colormapDepth, buffer, imageDataOffset, buffer, colormapOrigin, descriptor, order);
+ }
+ break;
+ case RGB:
+ pixels = createPixelsFromRGB(width, height, depth, buffer, 18, descriptor, order);
+ break;
+ case GRAYSCALE:
+ pixels = createPixelsFromGrayscale(width, height, depth, buffer, 18, descriptor, order);
+ break;
+ case COLORMAP_RLE: {
+ int imageDataOffset = 18 + (colormapDepth / 8) * colormapLength;
+ byte[] decodeBuffer = decodeRLE(width, height, depth, buffer, imageDataOffset);
+ pixels = createPixelsFromColormap(width, height, colormapDepth, decodeBuffer, 0, buffer, colormapOrigin, descriptor, order);
+ }
+ break;
+ case RGB_RLE: {
+ byte[] decodeBuffer = decodeRLE(width, height, depth, buffer, 18);
+ pixels = createPixelsFromRGB(width, height, depth, decodeBuffer, 0, descriptor, order);
+ }
+ break;
+ case GRAYSCALE_RLE: {
+ byte[] decodeBuffer = decodeRLE(width, height, depth, buffer, 18);
+ pixels = createPixelsFromGrayscale(width, height, depth, decodeBuffer, 0, descriptor, order);
+ }
+ break;
+ default:
+ throw new IOException("Unsupported image type: " + type);
+ }
- return pixels;
+ return pixels;
- }
+ }
- private static final int COLORMAP = 1;
- private static final int RGB = 2;
- private static final int GRAYSCALE = 3;
- private static final int COLORMAP_RLE = 9;
- private static final int RGB_RLE = 10;
- private static final int GRAYSCALE_RLE = 11;
+ private static final int COLORMAP = 1;
+ private static final int RGB = 2;
+ private static final int GRAYSCALE = 3;
+ private static final int COLORMAP_RLE = 9;
+ private static final int RGB_RLE = 10;
+ private static final int GRAYSCALE_RLE = 11;
- private static final int RIGHT_ORIGIN = 0x10;
- private static final int UPPER_ORIGIN = 0x20;
+ private static final int RIGHT_ORIGIN = 0x10;
+ private static final int UPPER_ORIGIN = 0x20;
- private static byte[] decodeRLE(int width, int height, int depth, byte[] buffer, int offset) {
- int elementCount = depth / 8;
- byte[] elements = new byte[elementCount];
- int decodeBufferLength = elementCount * width * height;
- byte[] decodeBuffer = new byte[decodeBufferLength];
- int decoded = 0;
- while (decoded < decodeBufferLength) {
- int packet = buffer[offset++] & 0xFF;
- if ((packet & 0x80) != 0) { // RLE
- for (int i = 0; i < elementCount; i++) {
- elements[i] = buffer[offset++];
- }
- int count = (packet & 0x7F) + 1;
- for (int i = 0; i < count; i++) {
- for (int j = 0; j < elementCount; j++) {
- decodeBuffer[decoded++] = elements[j];
- }
- }
- } else { // RAW
- int count = (packet + 1) * elementCount;
- for (int i = 0; i < count; i++) {
- decodeBuffer[decoded++] = buffer[offset++];
- }
- }
- }
- return decodeBuffer;
- }
+ private static byte[] decodeRLE(int width, int height, int depth, byte[] buffer, int offset) {
+ int elementCount = depth / 8;
+ byte[] elements = new byte[elementCount];
+ int decodeBufferLength = elementCount * width * height;
+ byte[] decodeBuffer = new byte[decodeBufferLength];
+ int decoded = 0;
+ while (decoded < decodeBufferLength) {
+ int packet = buffer[offset++] & 0xFF;
+ if ((packet & 0x80) != 0) { // RLE
+ for (int i = 0; i < elementCount; i++) {
+ elements[i] = buffer[offset++];
+ }
+ int count = (packet & 0x7F) + 1;
+ for (int i = 0; i < count; i++) {
+ for (int j = 0; j < elementCount; j++) {
+ decodeBuffer[decoded++] = elements[j];
+ }
+ }
+ } else { // RAW
+ int count = (packet + 1) * elementCount;
+ for (int i = 0; i < count; i++) {
+ decodeBuffer[decoded++] = buffer[offset++];
+ }
+ }
+ }
+ return decodeBuffer;
+ }
- private static int[] createPixelsFromColormap(int width, int height, int depth, byte[] bytes, int offset, byte[] palette, int colormapOrigin, int descriptor, Order order) throws IOException {
- int[] pixels;
- int rs = order.redShift;
- int gs = order.greenShift;
- int bs = order.blueShift;
- int as = order.alphaShift;
- switch (depth) {
- case 24:
- pixels = new int[width * height];
- if ((descriptor & RIGHT_ORIGIN) != 0) {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int colormapIndex = bytes[offset + width * i + j] &
- 0xFF - colormapOrigin;
- int color = 0xFFFFFFFF;
- if (colormapIndex >= 0) {
- int index = 3 * colormapIndex + 18;
- int b = palette[index] & 0xFF;
- int g = palette[index + 1] & 0xFF;
- int r = palette[index + 2] & 0xFF;
- int a = 0xFF;
- color = (r << rs) | (g << gs) | (b << bs) | (a << as);
- }
- pixels[width * i + (width - j - 1)] = color;
- }
- }
- } else {
- // LowerRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int colormapIndex = bytes[offset + width * i + j] &
- 0xFF - colormapOrigin;
- int color = 0xFFFFFFFF;
- if (colormapIndex >= 0) {
- int index = 3 * colormapIndex + 18;
- int b = palette[index] & 0xFF;
- int g = palette[index + 1] & 0xFF;
- int r = palette[index + 2] & 0xFF;
- int a = 0xFF;
- color = (r << rs) | (g << gs) | (b << bs) | (a << as);
- }
- pixels[width * (height - i - 1) + (width - j - 1)] = color;
- }
- }
- }
- } else {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int colormapIndex = bytes[offset + width * i + j] &
- 0xFF - colormapOrigin;
- int color = 0xFFFFFFFF;
- if (colormapIndex >= 0) {
- int index = 3 * colormapIndex + 18;
- int b = palette[index] & 0xFF;
- int g = palette[index + 1] & 0xFF;
- int r = palette[index + 2] & 0xFF;
- int a = 0xFF;
- color = (r << rs) | (g << gs) | (b << bs) | (a << as);
- }
- pixels[width * i + j] = color;
- }
- }
- } else {
- // LowerLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int colormapIndex = bytes[offset + width * i + j] &
- 0xFF - colormapOrigin;
- int color = 0xFFFFFFFF;
- if (colormapIndex >= 0) {
- int index = 3 * colormapIndex + 18;
- int b = palette[index] & 0xFF;
- int g = palette[index + 1] & 0xFF;
- int r = palette[index + 2] & 0xFF;
- int a = 0xFF;
- color = (r << rs) | (g << gs) | (b << bs) | (a << as);
- }
- pixels[width * (height - i - 1) + j] = color;
- }
- }
- }
- }
- break;
- case 32:
- pixels = new int[width * height];
- if ((descriptor & RIGHT_ORIGIN) != 0) {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int colormapIndex = bytes[offset + width * i + j] &
- 0xFF - colormapOrigin;
- int color = 0xFFFFFFFF;
- if (colormapIndex >= 0) {
- int index = 4 * colormapIndex + 18;
- int b = palette[index] & 0xFF;
- int g = palette[index + 1] & 0xFF;
- int r = palette[index + 2] & 0xFF;
- int a = palette[index + 3] & 0xFF;
- color = (r << rs) | (g << gs) | (b << bs) | (a << as);
- }
- pixels[width * i + (width - j - 1)] = color;
- }
- }
- } else {
- // LowerRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int colormapIndex = bytes[offset + width * i + j] &
- 0xFF - colormapOrigin;
- int color = 0xFFFFFFFF;
- if (colormapIndex >= 0) {
- int index = 4 * colormapIndex + 18;
- int b = palette[index] & 0xFF;
- int g = palette[index + 1] & 0xFF;
- int r = palette[index + 2] & 0xFF;
- int a = palette[index + 3] & 0xFF;
- color = (r << rs) | (g << gs) | (b << bs) | (a << as);
- }
- pixels[width * (height - i - 1) + (width - j - 1)] = color;
- }
- }
- }
- } else {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int colormapIndex = bytes[offset + width * i + j] &
- 0xFF - colormapOrigin;
- int color = 0xFFFFFFFF;
- if (colormapIndex >= 0) {
- int index = 4 * colormapIndex + 18;
- int b = palette[index] & 0xFF;
- int g = palette[index + 1] & 0xFF;
- int r = palette[index + 2] & 0xFF;
- int a = palette[index + 3] & 0xFF;
- color = (r << rs) | (g << gs) | (b << bs) | (a << as);
- }
- pixels[width * i + j] = color;
- }
- }
- } else {
- // LowerLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int colormapIndex = bytes[offset + width * i + j] &
- 0xFF - colormapOrigin;
- int color = 0xFFFFFFFF;
- if (colormapIndex >= 0) {
- int index = 4 * colormapIndex + 18;
- int b = palette[index] & 0xFF;
- int g = palette[index + 1] & 0xFF;
- int r = palette[index + 2] & 0xFF;
- int a = palette[index + 3] & 0xFF;
- color = (r << rs) | (g << gs) | (b << bs) | (a << as);
- }
- pixels[width * (height - i - 1) + j] = color;
- }
- }
- }
- }
- break;
- default:
- throw new IOException("Unsupported depth:" + depth);
- }
- return pixels;
- }
+ private static int[] createPixelsFromColormap(int width, int height, int depth, byte[] bytes, int offset, byte[] palette, int colormapOrigin, int descriptor, Order order) throws IOException {
+ int[] pixels;
+ int rs = order.redShift;
+ int gs = order.greenShift;
+ int bs = order.blueShift;
+ int as = order.alphaShift;
+ switch (depth) {
+ case 24:
+ pixels = new int[width * height];
+ if ((descriptor & RIGHT_ORIGIN) != 0) {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int colormapIndex = bytes[offset + width * i + j] &
+ 0xFF - colormapOrigin;
+ int color = 0xFFFFFFFF;
+ if (colormapIndex >= 0) {
+ int index = 3 * colormapIndex + 18;
+ int b = palette[index] & 0xFF;
+ int g = palette[index + 1] & 0xFF;
+ int r = palette[index + 2] & 0xFF;
+ int a = 0xFF;
+ color = (r << rs) | (g << gs) | (b << bs) | (a << as);
+ }
+ pixels[width * i + (width - j - 1)] = color;
+ }
+ }
+ } else {
+ // LowerRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int colormapIndex = bytes[offset + width * i + j] &
+ 0xFF - colormapOrigin;
+ int color = 0xFFFFFFFF;
+ if (colormapIndex >= 0) {
+ int index = 3 * colormapIndex + 18;
+ int b = palette[index] & 0xFF;
+ int g = palette[index + 1] & 0xFF;
+ int r = palette[index + 2] & 0xFF;
+ int a = 0xFF;
+ color = (r << rs) | (g << gs) | (b << bs) | (a << as);
+ }
+ pixels[width * (height - i - 1) + (width - j - 1)] = color;
+ }
+ }
+ }
+ } else {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int colormapIndex = bytes[offset + width * i + j] &
+ 0xFF - colormapOrigin;
+ int color = 0xFFFFFFFF;
+ if (colormapIndex >= 0) {
+ int index = 3 * colormapIndex + 18;
+ int b = palette[index] & 0xFF;
+ int g = palette[index + 1] & 0xFF;
+ int r = palette[index + 2] & 0xFF;
+ int a = 0xFF;
+ color = (r << rs) | (g << gs) | (b << bs) | (a << as);
+ }
+ pixels[width * i + j] = color;
+ }
+ }
+ } else {
+ // LowerLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int colormapIndex = bytes[offset + width * i + j] &
+ 0xFF - colormapOrigin;
+ int color = 0xFFFFFFFF;
+ if (colormapIndex >= 0) {
+ int index = 3 * colormapIndex + 18;
+ int b = palette[index] & 0xFF;
+ int g = palette[index + 1] & 0xFF;
+ int r = palette[index + 2] & 0xFF;
+ int a = 0xFF;
+ color = (r << rs) | (g << gs) | (b << bs) | (a << as);
+ }
+ pixels[width * (height - i - 1) + j] = color;
+ }
+ }
+ }
+ }
+ break;
+ case 32:
+ pixels = new int[width * height];
+ if ((descriptor & RIGHT_ORIGIN) != 0) {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int colormapIndex = bytes[offset + width * i + j] &
+ 0xFF - colormapOrigin;
+ int color = 0xFFFFFFFF;
+ if (colormapIndex >= 0) {
+ int index = 4 * colormapIndex + 18;
+ int b = palette[index] & 0xFF;
+ int g = palette[index + 1] & 0xFF;
+ int r = palette[index + 2] & 0xFF;
+ int a = palette[index + 3] & 0xFF;
+ color = (r << rs) | (g << gs) | (b << bs) | (a << as);
+ }
+ pixels[width * i + (width - j - 1)] = color;
+ }
+ }
+ } else {
+ // LowerRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int colormapIndex = bytes[offset + width * i + j] &
+ 0xFF - colormapOrigin;
+ int color = 0xFFFFFFFF;
+ if (colormapIndex >= 0) {
+ int index = 4 * colormapIndex + 18;
+ int b = palette[index] & 0xFF;
+ int g = palette[index + 1] & 0xFF;
+ int r = palette[index + 2] & 0xFF;
+ int a = palette[index + 3] & 0xFF;
+ color = (r << rs) | (g << gs) | (b << bs) | (a << as);
+ }
+ pixels[width * (height - i - 1) + (width - j - 1)] = color;
+ }
+ }
+ }
+ } else {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int colormapIndex = bytes[offset + width * i + j] &
+ 0xFF - colormapOrigin;
+ int color = 0xFFFFFFFF;
+ if (colormapIndex >= 0) {
+ int index = 4 * colormapIndex + 18;
+ int b = palette[index] & 0xFF;
+ int g = palette[index + 1] & 0xFF;
+ int r = palette[index + 2] & 0xFF;
+ int a = palette[index + 3] & 0xFF;
+ color = (r << rs) | (g << gs) | (b << bs) | (a << as);
+ }
+ pixels[width * i + j] = color;
+ }
+ }
+ } else {
+ // LowerLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int colormapIndex = bytes[offset + width * i + j] &
+ 0xFF - colormapOrigin;
+ int color = 0xFFFFFFFF;
+ if (colormapIndex >= 0) {
+ int index = 4 * colormapIndex + 18;
+ int b = palette[index] & 0xFF;
+ int g = palette[index + 1] & 0xFF;
+ int r = palette[index + 2] & 0xFF;
+ int a = palette[index + 3] & 0xFF;
+ color = (r << rs) | (g << gs) | (b << bs) | (a << as);
+ }
+ pixels[width * (height - i - 1) + j] = color;
+ }
+ }
+ }
+ }
+ break;
+ default:
+ throw new IOException("Unsupported depth:" + depth);
+ }
+ return pixels;
+ }
- private static int[] createPixelsFromRGB(int width, int height, int depth, byte[] bytes, int offset, int descriptor, Order order) throws IOException {
- int[] pixels;
- int rs = order.redShift;
- int gs = order.greenShift;
- int bs = order.blueShift;
- int as = order.alphaShift;
- switch (depth) {
- case 24:
- pixels = new int[width * height];
- if ((descriptor & RIGHT_ORIGIN) != 0) {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int index = offset + 3 * width * i + 3 * j;
- int b = bytes[index] & 0xFF;
- int g = bytes[index + 1] & 0xFF;
- int r = bytes[index + 2] & 0xFF;
- int a = 0xFF;
- pixels[width * i + (width - j - 1)] = (r << rs) |
- (g << gs) |
- (b << bs) |
- (a << as);
- }
- }
- } else {
- // LowerRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int index = offset + 3 * width * i + 3 * j;
- int b = bytes[index] & 0xFF;
- int g = bytes[index + 1] & 0xFF;
- int r = bytes[index + 2] & 0xFF;
- int a = 0xFF;
- pixels[width * (height - i - 1) + (width - j - 1)] = (r << rs) |
- (g << gs) |
- (b << bs) |
- (a << as);
- }
- }
- }
- } else {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int index = offset + 3 * width * i + 3 * j;
- int b = bytes[index] & 0xFF;
- int g = bytes[index + 1] & 0xFF;
- int r = bytes[index + 2] & 0xFF;
- int a = 0xFF;
- pixels[width * i + j] = (r << rs) |
- (g << gs) |
- (b << bs) |
- (a << as);
- }
- }
- } else {
- // LowerLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int index = offset + 3 * width * i + 3 * j;
- int b = bytes[index] & 0xFF;
- int g = bytes[index + 1] & 0xFF;
- int r = bytes[index + 2] & 0xFF;
- int a = 0xFF;
- pixels[width * (height - i - 1) + j] = (r << rs) |
- (g << gs) |
- (b << bs) |
- (a << as);
- }
- }
- }
- }
- break;
- case 32:
- pixels = new int[width * height];
- if ((descriptor & RIGHT_ORIGIN) != 0) {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int index = offset + 4 * width * i + 4 * j;
- int b = bytes[index] & 0xFF;
- int g = bytes[index + 1] & 0xFF;
- int r = bytes[index + 2] & 0xFF;
- int a = bytes[index + 3] & 0xFF;
- pixels[width * i + (width - j - 1)] = (r << rs) |
- (g << gs) |
- (b << bs) |
- (a << as);
- }
- }
- } else {
- // LowerRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int index = offset + 4 * width * i + 4 * j;
- int b = bytes[index] & 0xFF;
- int g = bytes[index + 1] & 0xFF;
- int r = bytes[index + 2] & 0xFF;
- int a = bytes[index + 3] & 0xFF;
- pixels[width * (height - i - 1) + (width - j - 1)] = (r << rs) |
- (g << gs) |
- (b << bs) |
- (a << as);
- }
- }
- }
- } else {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int index = offset + 4 * width * i + 4 * j;
- int b = bytes[index] & 0xFF;
- int g = bytes[index + 1] & 0xFF;
- int r = bytes[index + 2] & 0xFF;
- int a = bytes[index + 3] & 0xFF;
- pixels[width * i + j] = (r << rs) |
- (g << gs) |
- (b << bs) |
- (a << as);
- }
- }
- } else {
- // LowerLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int index = offset + 4 * width * i + 4 * j;
- int b = bytes[index] & 0xFF;
- int g = bytes[index + 1] & 0xFF;
- int r = bytes[index + 2] & 0xFF;
- int a = bytes[index + 3] & 0xFF;
- pixels[width * (height - i - 1) + j] = (r << rs) |
- (g << gs) |
- (b << bs) |
- (a << as);
- }
- }
- }
- }
- break;
- default:
- throw new IOException("Unsupported depth:" + depth);
- }
- return pixels;
- }
+ private static int[] createPixelsFromRGB(int width, int height, int depth, byte[] bytes, int offset, int descriptor, Order order) throws IOException {
+ int[] pixels;
+ int rs = order.redShift;
+ int gs = order.greenShift;
+ int bs = order.blueShift;
+ int as = order.alphaShift;
+ switch (depth) {
+ case 24:
+ pixels = new int[width * height];
+ if ((descriptor & RIGHT_ORIGIN) != 0) {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int index = offset + 3 * width * i + 3 * j;
+ int b = bytes[index] & 0xFF;
+ int g = bytes[index + 1] & 0xFF;
+ int r = bytes[index + 2] & 0xFF;
+ int a = 0xFF;
+ pixels[width * i + (width - j - 1)] = (r << rs) |
+ (g << gs) |
+ (b << bs) |
+ (a << as);
+ }
+ }
+ } else {
+ // LowerRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int index = offset + 3 * width * i + 3 * j;
+ int b = bytes[index] & 0xFF;
+ int g = bytes[index + 1] & 0xFF;
+ int r = bytes[index + 2] & 0xFF;
+ int a = 0xFF;
+ pixels[width * (height - i - 1) + (width - j - 1)] = (r << rs) |
+ (g << gs) |
+ (b << bs) |
+ (a << as);
+ }
+ }
+ }
+ } else {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int index = offset + 3 * width * i + 3 * j;
+ int b = bytes[index] & 0xFF;
+ int g = bytes[index + 1] & 0xFF;
+ int r = bytes[index + 2] & 0xFF;
+ int a = 0xFF;
+ pixels[width * i + j] = (r << rs) |
+ (g << gs) |
+ (b << bs) |
+ (a << as);
+ }
+ }
+ } else {
+ // LowerLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int index = offset + 3 * width * i + 3 * j;
+ int b = bytes[index] & 0xFF;
+ int g = bytes[index + 1] & 0xFF;
+ int r = bytes[index + 2] & 0xFF;
+ int a = 0xFF;
+ pixels[width * (height - i - 1) + j] = (r << rs) |
+ (g << gs) |
+ (b << bs) |
+ (a << as);
+ }
+ }
+ }
+ }
+ break;
+ case 32:
+ pixels = new int[width * height];
+ if ((descriptor & RIGHT_ORIGIN) != 0) {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int index = offset + 4 * width * i + 4 * j;
+ int b = bytes[index] & 0xFF;
+ int g = bytes[index + 1] & 0xFF;
+ int r = bytes[index + 2] & 0xFF;
+ int a = bytes[index + 3] & 0xFF;
+ pixels[width * i + (width - j - 1)] = (r << rs) |
+ (g << gs) |
+ (b << bs) |
+ (a << as);
+ }
+ }
+ } else {
+ // LowerRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int index = offset + 4 * width * i + 4 * j;
+ int b = bytes[index] & 0xFF;
+ int g = bytes[index + 1] & 0xFF;
+ int r = bytes[index + 2] & 0xFF;
+ int a = bytes[index + 3] & 0xFF;
+ pixels[width * (height - i - 1) + (width - j - 1)] = (r << rs) |
+ (g << gs) |
+ (b << bs) |
+ (a << as);
+ }
+ }
+ }
+ } else {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int index = offset + 4 * width * i + 4 * j;
+ int b = bytes[index] & 0xFF;
+ int g = bytes[index + 1] & 0xFF;
+ int r = bytes[index + 2] & 0xFF;
+ int a = bytes[index + 3] & 0xFF;
+ pixels[width * i + j] = (r << rs) |
+ (g << gs) |
+ (b << bs) |
+ (a << as);
+ }
+ }
+ } else {
+ // LowerLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int index = offset + 4 * width * i + 4 * j;
+ int b = bytes[index] & 0xFF;
+ int g = bytes[index + 1] & 0xFF;
+ int r = bytes[index + 2] & 0xFF;
+ int a = bytes[index + 3] & 0xFF;
+ pixels[width * (height - i - 1) + j] = (r << rs) |
+ (g << gs) |
+ (b << bs) |
+ (a << as);
+ }
+ }
+ }
+ }
+ break;
+ default:
+ throw new IOException("Unsupported depth:" + depth);
+ }
+ return pixels;
+ }
- private static int[] createPixelsFromGrayscale(int width, int height, int depth, byte[] bytes, int offset, int descriptor, Order order) throws IOException {
- int[] pixels;
- int rs = order.redShift;
- int gs = order.greenShift;
- int bs = order.blueShift;
- int as = order.alphaShift;
- switch (depth) {
- case 8:
- pixels = new int[width * height];
- if ((descriptor & RIGHT_ORIGIN) != 0) {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int e = bytes[offset + width * i + j] & 0xFF;
- int a = 0xFF;
- pixels[width * i + (width - j - 1)] = (e << rs) |
- (e << gs) |
- (e << bs) |
- (a << as);
- }
- }
- } else {
- // LowerRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int e = bytes[offset + width * i + j] & 0xFF;
- int a = 0xFF;
- pixels[width * (height - i - 1) + (width - j - 1)] = (e << rs) |
- (e << gs) |
- (e << bs) |
- (a << as);
- }
- }
- }
- } else {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int e = bytes[offset + width * i + j] & 0xFF;
- int a = 0xFF;
- pixels[width * i + j] = (e << rs) |
- (e << gs) |
- (e << bs) |
- (a << as);
- }
- }
- } else {
- // LowerLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int e = bytes[offset + width * i + j] & 0xFF;
- int a = 0xFF;
- pixels[width * (height - i - 1) + j] = (e << rs) |
- (e << gs) |
- (e << bs) |
- (a << as);
- }
- }
- }
- }
- break;
- case 16:
- pixels = new int[width * height];
- if ((descriptor & RIGHT_ORIGIN) != 0) {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int e = bytes[offset + 2 * width * i + 2 * j] & 0xFF;
- int a = bytes[offset + 2 * width * i + 2 * j + 1] & 0xFF;
- pixels[width * i + (width - j - 1)] = (e << rs) |
- (e << gs) |
- (e << bs) |
- (a << as);
- }
- }
- } else {
- // LowerRight
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int e = bytes[offset + 2 * width * i + 2 * j] & 0xFF;
- int a = bytes[offset + 2 * width * i + 2 * j + 1] & 0xFF;
- pixels[width * (height - i - 1) + (width - j - 1)] = (e << rs) |
- (e << gs) |
- (e << bs) |
- (a << as);
- }
- }
- }
- } else {
- if ((descriptor & UPPER_ORIGIN) != 0) {
- // UpperLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int e = bytes[offset + 2 * width * i + 2 * j] & 0xFF;
- int a = bytes[offset + 2 * width * i + 2 * j + 1] & 0xFF;
- pixels[width * i + j] = (e << rs) |
- (e << gs) |
- (e << bs) |
- (a << as);
- }
- }
- } else {
- // LowerLeft
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
- int e = bytes[offset + 2 * width * i + 2 * j] & 0xFF;
- int a = bytes[offset + 2 * width * i + 2 * j + 1] & 0xFF;
- pixels[width * (height - i - 1) + j] = (e << rs) |
- (e << gs) |
- (e << bs) |
- (a << as);
- }
- }
- }
- }
- break;
- default:
- throw new IOException("Unsupported depth:" + depth);
- }
- return pixels;
- }
+ private static int[] createPixelsFromGrayscale(int width, int height, int depth, byte[] bytes, int offset, int descriptor, Order order) throws IOException {
+ int[] pixels;
+ int rs = order.redShift;
+ int gs = order.greenShift;
+ int bs = order.blueShift;
+ int as = order.alphaShift;
+ switch (depth) {
+ case 8:
+ pixels = new int[width * height];
+ if ((descriptor & RIGHT_ORIGIN) != 0) {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int e = bytes[offset + width * i + j] & 0xFF;
+ int a = 0xFF;
+ pixels[width * i + (width - j - 1)] = (e << rs) |
+ (e << gs) |
+ (e << bs) |
+ (a << as);
+ }
+ }
+ } else {
+ // LowerRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int e = bytes[offset + width * i + j] & 0xFF;
+ int a = 0xFF;
+ pixels[width * (height - i - 1) + (width - j - 1)] = (e << rs) |
+ (e << gs) |
+ (e << bs) |
+ (a << as);
+ }
+ }
+ }
+ } else {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int e = bytes[offset + width * i + j] & 0xFF;
+ int a = 0xFF;
+ pixels[width * i + j] = (e << rs) |
+ (e << gs) |
+ (e << bs) |
+ (a << as);
+ }
+ }
+ } else {
+ // LowerLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int e = bytes[offset + width * i + j] & 0xFF;
+ int a = 0xFF;
+ pixels[width * (height - i - 1) + j] = (e << rs) |
+ (e << gs) |
+ (e << bs) |
+ (a << as);
+ }
+ }
+ }
+ }
+ break;
+ case 16:
+ pixels = new int[width * height];
+ if ((descriptor & RIGHT_ORIGIN) != 0) {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int e = bytes[offset + 2 * width * i + 2 * j] & 0xFF;
+ int a = bytes[offset + 2 * width * i + 2 * j + 1] & 0xFF;
+ pixels[width * i + (width - j - 1)] = (e << rs) |
+ (e << gs) |
+ (e << bs) |
+ (a << as);
+ }
+ }
+ } else {
+ // LowerRight
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int e = bytes[offset + 2 * width * i + 2 * j] & 0xFF;
+ int a = bytes[offset + 2 * width * i + 2 * j + 1] & 0xFF;
+ pixels[width * (height - i - 1) + (width - j - 1)] = (e << rs) |
+ (e << gs) |
+ (e << bs) |
+ (a << as);
+ }
+ }
+ }
+ } else {
+ if ((descriptor & UPPER_ORIGIN) != 0) {
+ // UpperLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int e = bytes[offset + 2 * width * i + 2 * j] & 0xFF;
+ int a = bytes[offset + 2 * width * i + 2 * j + 1] & 0xFF;
+ pixels[width * i + j] = (e << rs) |
+ (e << gs) |
+ (e << bs) |
+ (a << as);
+ }
+ }
+ } else {
+ // LowerLeft
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ int e = bytes[offset + 2 * width * i + 2 * j] & 0xFF;
+ int a = bytes[offset + 2 * width * i + 2 * j + 1] & 0xFF;
+ pixels[width * (height - i - 1) + j] = (e << rs) |
+ (e << gs) |
+ (e << bs) |
+ (a << as);
+ }
+ }
+ }
+ }
+ break;
+ default:
+ throw new IOException("Unsupported depth:" + depth);
+ }
+ return pixels;
+ }
- private TGAReader() {
- }
+ private TGAReader() {
+ }
- public static final class Order {
- Order(int redShift, int greenShift, int blueShift, int alphaShift) {
- this.redShift = redShift;
- this.greenShift = greenShift;
- this.blueShift = blueShift;
- this.alphaShift = alphaShift;
- }
+ public static final class Order {
+ Order(int redShift, int greenShift, int blueShift, int alphaShift) {
+ this.redShift = redShift;
+ this.greenShift = greenShift;
+ this.blueShift = blueShift;
+ this.alphaShift = alphaShift;
+ }
- public int redShift;
- public int greenShift;
- public int blueShift;
- public int alphaShift;
- }
+ public int redShift;
+ public int greenShift;
+ public int blueShift;
+ public int alphaShift;
+ }
-}
\ No newline at end of file
+}
diff --git a/android/app/src/main/java/su/xash/engine/workers/FileCopyWorker.kt b/android/app/src/main/java/su/xash/engine/workers/FileCopyWorker.kt
index 00603ce2..ce7569e7 100644
--- a/android/app/src/main/java/su/xash/engine/workers/FileCopyWorker.kt
+++ b/android/app/src/main/java/su/xash/engine/workers/FileCopyWorker.kt
@@ -12,86 +12,87 @@ import kotlinx.coroutines.withContext
const val KEY_FILE_URI = "KEY_FILE_URI"
class FileCopyWorker(ctx: Context, params: WorkerParameters) : CoroutineWorker(ctx, params) {
- companion object {
- const val Input = "Input"
- const val Progress = "Progress"
- }
+ companion object {
+ const val Input = "Input"
+ const val Progress = "Progress"
+ }
- private var fileCount = 0
- private var fileCopied = 0
+ private var fileCount = 0
+ private var fileCopied = 0
- override suspend fun doWork(): Result {
- withContext(Dispatchers.IO) {
- val fileUri = inputData.getString(KEY_FILE_URI)
- setProgress(workDataOf(Input to fileUri))
+ override suspend fun doWork(): Result {
+ withContext(Dispatchers.IO) {
+ val fileUri = inputData.getString(KEY_FILE_URI)
+ setProgress(workDataOf(Input to fileUri))
- val uri = Uri.parse(fileUri)
- val source = DocumentFile.fromTreeUri(applicationContext, uri)
+ val uri = Uri.parse(fileUri)
+ val source = DocumentFile.fromTreeUri(applicationContext, uri)
- fileCount = source?.countDirFiles() ?: return@withContext Result.failure()
+ fileCount = source?.countDirFiles() ?: return@withContext Result.failure()
- setProgress(workDataOf(Progress to 0f))
+ setProgress(workDataOf(Progress to 0f))
- val gamedir = source.name!!
- val externalFilesDir = DocumentFile.fromFile(applicationContext.getExternalFilesDir(null)!!)
+ val gamedir = source.name!!
+ val externalFilesDir =
+ DocumentFile.fromFile(applicationContext.getExternalFilesDir(null)!!)
- // create a directory to store staged files
- val target = externalFilesDir.createDirectory(".$gamedir")!!
+ // create a directory to store staged files
+ val target = externalFilesDir.createDirectory(".$gamedir")!!
- source.copyDirTo(applicationContext, this@FileCopyWorker, target)
+ source.copyDirTo(applicationContext, this@FileCopyWorker, target)
- target.renameTo(gamedir)
+ target.renameTo(gamedir)
- setProgress(workDataOf(Progress to 1f))
- }
- return Result.success()
- }
+ setProgress(workDataOf(Progress to 1f))
+ }
+ return Result.success()
+ }
- suspend fun fileCopied(count: Int) {
- if(count == 0)
- return
+ suspend fun fileCopied(count: Int) {
+ if (count == 0)
+ return
- fileCopied += count
- val percentage: Float = fileCopied.toFloat() / fileCount.toFloat();
- setProgress(workDataOf(Progress to percentage))
- }
+ fileCopied += count
+ val percentage: Float = fileCopied.toFloat() / fileCount.toFloat();
+ setProgress(workDataOf(Progress to percentage))
+ }
}
fun DocumentFile.countDirFiles(): Int {
- var count: Int = 0
+ var count: Int = 0
- listFiles().forEach {
- if (it.isDirectory)
- count += it.countDirFiles()
- else
- count++
- }
+ listFiles().forEach {
+ if (it.isDirectory)
+ count += it.countDirFiles()
+ else
+ count++
+ }
- return count
+ return count
}
fun DocumentFile.copyFileTo(ctx: Context, file: DocumentFile) {
- val outFile = file.createFile("application", name!!)!!
+ val outFile = file.createFile("application", name!!)!!
- ctx.contentResolver.openOutputStream(outFile.uri).use { os ->
- ctx.contentResolver.openInputStream(uri).use {
- it?.copyTo(os!!)
- }
- }
+ ctx.contentResolver.openOutputStream(outFile.uri).use { os ->
+ ctx.contentResolver.openInputStream(uri).use {
+ it?.copyTo(os!!)
+ }
+ }
}
suspend fun DocumentFile.copyDirTo(ctx: Context, worker: FileCopyWorker, dir: DocumentFile) {
- var count: Int = 0
+ var count: Int = 0
- listFiles().forEach {
- if (it.isDirectory) {
- val outDir = dir.createDirectory(it.name!!)!!
- it.copyDirTo(ctx, worker, outDir)
- } else {
- it.copyFileTo(ctx, dir)
- count++
- }
- }
+ listFiles().forEach {
+ if (it.isDirectory) {
+ val outDir = dir.createDirectory(it.name!!)!!
+ it.copyDirTo(ctx, worker, outDir)
+ } else {
+ it.copyFileTo(ctx, dir)
+ count++
+ }
+ }
- worker.fileCopied(count)
+ worker.fileCopied(count)
}
diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml
index 3879b823..338a67aa 100644
--- a/android/app/src/main/res/layout/activity_main.xml
+++ b/android/app/src/main/res/layout/activity_main.xml
@@ -1,35 +1,35 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ xmlns:tools="http://schemas.android.com/tools">
-
+
-
+
-
+
-
-
\ No newline at end of file
+
+
diff --git a/android/app/src/main/res/layout/card_game.xml b/android/app/src/main/res/layout/card_game.xml
index 853b30e7..e8441e8c 100644
--- a/android/app/src/main/res/layout/card_game.xml
+++ b/android/app/src/main/res/layout/card_game.xml
@@ -1,111 +1,111 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ style="@style/Widget.Material3.CardView.Filled"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp">
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
diff --git a/android/app/src/main/res/layout/edit_text_preference.xml b/android/app/src/main/res/layout/edit_text_preference.xml
index 55d2bd17..82a5262c 100644
--- a/android/app/src/main/res/layout/edit_text_preference.xml
+++ b/android/app/src/main/res/layout/edit_text_preference.xml
@@ -1,30 +1,30 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
\ No newline at end of file
+
+
diff --git a/android/app/src/main/res/layout/fragment_app_settings.xml b/android/app/src/main/res/layout/fragment_app_settings.xml
index 0e738e9d..a9d905f2 100644
--- a/android/app/src/main/res/layout/fragment_app_settings.xml
+++ b/android/app/src/main/res/layout/fragment_app_settings.xml
@@ -1,14 +1,13 @@
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingHorizontal="8dp">
-
-
\ No newline at end of file
+
+
diff --git a/android/app/src/main/res/layout/fragment_game_settings.xml b/android/app/src/main/res/layout/fragment_game_settings.xml
index af1a003d..4ba31d9b 100644
--- a/android/app/src/main/res/layout/fragment_game_settings.xml
+++ b/android/app/src/main/res/layout/fragment_game_settings.xml
@@ -1,39 +1,39 @@
+ 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">
-
+
-
+
-
+
-
+
-
-
\ No newline at end of file
+
+
diff --git a/android/app/src/main/res/layout/fragment_library.xml b/android/app/src/main/res/layout/fragment_library.xml
index ade658da..25b7cd57 100644
--- a/android/app/src/main/res/layout/fragment_library.xml
+++ b/android/app/src/main/res/layout/fragment_library.xml
@@ -1,23 +1,23 @@
+ 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"
+ android:id="@+id/swipeRefresh">
-
+
-
-
+
+
-
\ No newline at end of file
+
diff --git a/android/app/src/main/res/layout/fragment_setup.xml b/android/app/src/main/res/layout/fragment_setup.xml
index 644a5b6f..4ada2dc6 100644
--- a/android/app/src/main/res/layout/fragment_setup.xml
+++ b/android/app/src/main/res/layout/fragment_setup.xml
@@ -1,11 +1,10 @@
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
-
-
\ No newline at end of file
+
+
diff --git a/android/app/src/main/res/layout/list_preference.xml b/android/app/src/main/res/layout/list_preference.xml
index 2a181013..78eb2fd2 100644
--- a/android/app/src/main/res/layout/list_preference.xml
+++ b/android/app/src/main/res/layout/list_preference.xml
@@ -1,19 +1,20 @@
-
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
-
-
\ No newline at end of file
+
+
+
+
diff --git a/android/app/src/main/res/layout/page_location.xml b/android/app/src/main/res/layout/page_location.xml
index 8659f4f5..8d6efb10 100644
--- a/android/app/src/main/res/layout/page_location.xml
+++ b/android/app/src/main/res/layout/page_location.xml
@@ -1,51 +1,50 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
-
+
-
+
-
+
-
-
\ No newline at end of file
+
+
diff --git a/android/app/src/main/res/layout/page_welcome.xml b/android/app/src/main/res/layout/page_welcome.xml
index eeeeb0da..505e4528 100644
--- a/android/app/src/main/res/layout/page_welcome.xml
+++ b/android/app/src/main/res/layout/page_welcome.xml
@@ -1,51 +1,50 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
-
+
-
+
-
+
-
-
\ No newline at end of file
+
+
diff --git a/android/app/src/main/res/layout/switch_preference.xml b/android/app/src/main/res/layout/switch_preference.xml
index 4ab4364b..2789fbb4 100644
--- a/android/app/src/main/res/layout/switch_preference.xml
+++ b/android/app/src/main/res/layout/switch_preference.xml
@@ -1,23 +1,23 @@
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
-
+
-
-
\ No newline at end of file
+
+
diff --git a/android/app/src/main/res/menu/menu_game_settings.xml b/android/app/src/main/res/menu/menu_game_settings.xml
index 3a7c782b..b911e828 100644
--- a/android/app/src/main/res/menu/menu_game_settings.xml
+++ b/android/app/src/main/res/menu/menu_game_settings.xml
@@ -1,14 +1,14 @@
\ No newline at end of file
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+
+
diff --git a/android/app/src/main/res/menu/menu_library.xml b/android/app/src/main/res/menu/menu_library.xml
index a1830010..5d122658 100644
--- a/android/app/src/main/res/menu/menu_library.xml
+++ b/android/app/src/main/res/menu/menu_library.xml
@@ -1,19 +1,19 @@
\ No newline at end of file
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+
+
+
diff --git a/android/app/src/main/res/navigation/nav_graph.xml b/android/app/src/main/res/navigation/nav_graph.xml
index d3d1b930..b27cb6f5 100644
--- a/android/app/src/main/res/navigation/nav_graph.xml
+++ b/android/app/src/main/res/navigation/nav_graph.xml
@@ -1,38 +1,37 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/nav_graph"
+ android:label="@string/library"
+ app:startDestination="@id/libraryFragment">
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/res/values-pt-rBR/strings.xml b/android/app/src/main/res/values-pt-rBR/strings.xml
index 75f3bfd5..e124fd42 100644
--- a/android/app/src/main/res/values-pt-rBR/strings.xml
+++ b/android/app/src/main/res/values-pt-rBR/strings.xml
@@ -1,26 +1,26 @@
- Ok
- Cancelar
- Próximo
- Navegar
+ Ok
+ Cancelar
+ Próximo
+ Navegar
Biblioteca
Dedicado
- Erro!
- Configurar
- Configurações
- Configurações do jogo
- Argumentos de linha de comando
- Usar botões de volume no jogo
- Bem vindo ao Xash3D FWGS!
- Agora, nós vamos guiá-lo durante o processo de instalação.
- Jogos
- Selecione a pasta onde seus jogos estão localizados.
- A pasta selecionada não contem nenhum jogo.
- A pasta selecionada é invalida.
- Bibliotecas de pacotes
- Bibliotecas de pacotes separados
- Pacotes de Cliente
- Pacotes de Servidor
- Usar ícones ao inves de imagens de fundo
+ Erro!
+ Configurar
+ Configurações
+ Configurações do jogo
+ Argumentos de linha de comando
+ Usar botões de volume no jogo
+ Bem vindo ao Xash3D FWGS!
+ Agora, nós vamos guiá-lo durante o processo de instalação.
+ Jogos
+ Selecione a pasta onde seus jogos estão localizados.
+ A pasta selecionada não contem nenhum jogo.
+ A pasta selecionada é invalida.
+ Bibliotecas de pacotes
+ Bibliotecas de pacotes separados
+ Pacotes de Cliente
+ Pacotes de Servidor
+ Usar ícones ao inves de imagens de fundo
diff --git a/android/app/src/main/res/values-ru/strings.xml b/android/app/src/main/res/values-ru/strings.xml
index 613ca432..b4c40b4b 100644
--- a/android/app/src/main/res/values-ru/strings.xml
+++ b/android/app/src/main/res/values-ru/strings.xml
@@ -1,26 +1,26 @@
- Отмена
- ОК
- Далее
- Обзор
+ Отмена
+ ОК
+ Далее
+ Обзор
Библиотека
Выделенный
- Ошибка!
- Установка
- Настройки
- Настройки игры
- Аргументы командной строки
- Использовать кнопки громкости
- Добро пожаловать в Xash3D FWGS!
- Теперь мы ознакомим вас с процессом установки.
- Игры
- Выберите папку, в которой находятся ваши игры.
- Выбранный каталог не содержит ни одной игры.
- Выбранный каталог недопустим.
- Пакет библиотек
- Библиотеки из отдельных пакетов
- Пакет клиента
- Пакет сервера
- Использовать иконки вместо фона
+ Ошибка!
+ Установка
+ Настройки
+ Настройки игры
+ Аргументы командной строки
+ Использовать кнопки громкости
+ Добро пожаловать в Xash3D FWGS!
+ Теперь мы ознакомим вас с процессом установки.
+ Игры
+ Выберите папку, в которой находятся ваши игры.
+ Выбранный каталог не содержит ни одной игры.
+ Выбранный каталог недопустим.
+ Пакет библиотек
+ Библиотеки из отдельных пакетов
+ Пакет клиента
+ Пакет сервера
+ Использовать иконки вместо фона
diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml
index a0f62624..c692d368 100644
--- a/android/app/src/main/res/values/colors.xml
+++ b/android/app/src/main/res/values/colors.xml
@@ -1,9 +1,9 @@
- #F74843
- #FB7E14
- #000000
- #151515
- #292929
+ #F74843
+ #FB7E14
+ #000000
+ #151515
+ #292929
diff --git a/android/app/src/main/res/values/ic_launcher_background.xml b/android/app/src/main/res/values/ic_launcher_background.xml
index 8a9d7629..e01ae6da 100644
--- a/android/app/src/main/res/values/ic_launcher_background.xml
+++ b/android/app/src/main/res/values/ic_launcher_background.xml
@@ -1,4 +1,4 @@
- #F74843
-
\ No newline at end of file
+ #F74843
+
diff --git a/android/app/src/main/res/values/themes.xml b/android/app/src/main/res/values/themes.xml
index 32040065..e3eeb1ba 100644
--- a/android/app/src/main/res/values/themes.xml
+++ b/android/app/src/main/res/values/themes.xml
@@ -1,17 +1,18 @@
-
-
\ No newline at end of file
+
+
diff --git a/android/app/src/main/res/xml/app_preferences.xml b/android/app/src/main/res/xml/app_preferences.xml
index 561f80d2..31a414a9 100644
--- a/android/app/src/main/res/xml/app_preferences.xml
+++ b/android/app/src/main/res/xml/app_preferences.xml
@@ -1,8 +1,7 @@
-
-
-
\ No newline at end of file
+
+
+
diff --git a/android/app/src/main/res/xml/game_preferences.xml b/android/app/src/main/res/xml/game_preferences.xml
index 0a6cb551..73e7a047 100644
--- a/android/app/src/main/res/xml/game_preferences.xml
+++ b/android/app/src/main/res/xml/game_preferences.xml
@@ -1,42 +1,41 @@
-
-
+
+
-
+
-
+
-
+
-
+
-
+