From 0915bfbb30124ad1ec2dc58f4a083e31696613fc Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Sat, 3 Jun 2023 20:41:06 -0400 Subject: [PATCH] Android: Convert Platform to Kotlin --- .../dolphinemu/ui/platform/Platform.java | 58 ------------------- .../dolphinemu/ui/platform/Platform.kt | 36 ++++++++++++ 2 files changed, 36 insertions(+), 58 deletions(-) delete mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/Platform.java create mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/Platform.kt diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/Platform.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/Platform.java deleted file mode 100644 index f561feb250..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/Platform.java +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -package org.dolphinemu.dolphinemu.ui.platform; - -import org.dolphinemu.dolphinemu.R; - -/** - * Enum to represent platform (eg GameCube, Wii). - */ -public enum Platform -{ - GAMECUBE(0, R.string.platform_gamecube, "GameCube Games"), - WII(1, R.string.platform_wii, "Wii Games"), - WIIWARE(2, R.string.platform_wiiware, "WiiWare Games"); - - private final int value; - private final int headerName; - private final String idString; - - Platform(int value, int headerName, String idString) - { - this.value = value; - this.headerName = headerName; - this.idString = idString; - } - - public static Platform fromInt(int i) - { - return values()[i]; - } - - public static Platform fromNativeInt(int i) - { - // TODO: Proper support for DOL and ELF files - boolean in_range = i >= 0 && i < values().length; - return values()[in_range ? i : WIIWARE.value]; - } - - public static Platform fromPosition(int position) - { - return values()[position]; - } - - public int toInt() - { - return value; - } - - public int getHeaderName() - { - return headerName; - } - - public String getIdString() - { - return idString; - } -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/Platform.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/Platform.kt new file mode 100644 index 0000000000..0bf3e0ea68 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/Platform.kt @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.ui.platform + +import org.dolphinemu.dolphinemu.R + +/** + * Enum to represent platform (eg GameCube, Wii). + */ +enum class Platform(private val value: Int, val headerName: Int, val idString: String) { + GAMECUBE(0, R.string.platform_gamecube, "GameCube Games"), + WII(1, R.string.platform_wii, "Wii Games"), + WIIWARE(2, R.string.platform_wiiware, "WiiWare Games"); + + fun toInt(): Int { + return value + } + + companion object { + fun fromInt(i: Int): Platform { + return values()[i] + } + + @JvmStatic + fun fromNativeInt(i: Int): Platform { + // TODO: Proper support for DOL and ELF files + val inRange = i >= 0 && i < values().size + return values()[if (inRange) i else WIIWARE.value] + } + + @JvmStatic + fun fromPosition(position: Int): Platform { + return values()[position] + } + } +}