diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.kt index e0938b975d..e65e507a99 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.kt @@ -35,10 +35,12 @@ class EmulatedController private constructor(private val pointer: Long) : Contro external fun clearSettings() - external fun loadProfile(path: String) + external fun loadProfile(path: String, profileName: String) external fun saveProfile(path: String) + external fun getProfileName(): String + external fun getProfileKey(): String external fun getUserProfileDirectoryPath(): String diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileDialogPresenter.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileDialogPresenter.kt index 5c0a50a8b8..33a16313bf 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileDialogPresenter.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileDialogPresenter.kt @@ -11,7 +11,7 @@ import org.dolphinemu.dolphinemu.R import org.dolphinemu.dolphinemu.databinding.DialogInputStringBinding import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivityView -import org.dolphinemu.dolphinemu.utils.DirectoryInitialization +import org.dolphinemu.dolphinemu.utils.Log import java.io.File import java.util.Locale @@ -47,9 +47,11 @@ class ProfileDialogPresenter { .setMessage(context.getString(R.string.input_profile_confirm_load, profileName)) .setPositiveButton(R.string.yes) { _: DialogInterface?, _: Int -> menuTag.correspondingEmulatedController - .loadProfile(getProfilePath(profileName, stock)) + .loadProfile(getProfilePath(profileName, stock), profileName) (dialog!!.requireActivity() as SettingsActivityView).onControllerSettingsChanged() dialog.dismiss() + + Log.error("Loaded Profile: $profileName, ${menuTag.correspondingEmulatedController.getProfileName()}") } .setNegativeButton(R.string.no, null) .show() diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.kt index 01c4796e68..be2d2826f5 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.kt @@ -14,7 +14,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.Settings */ abstract class SettingsItem { val name: CharSequence - val description: CharSequence + var description: CharSequence /** * Base constructor. @@ -71,6 +71,15 @@ abstract class SettingsItem { setting!!.delete(settings) } + /** + * Update Description of this SettingsItem + * + * @param description New text string to be displayed as this Setting's description. + */ + open fun updateDescription(description: String) { + this.description = description + } + companion object { const val TYPE_HEADER = 0 const val TYPE_SWITCH = 1 diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt index 25acccb2fc..f4b92efda6 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt @@ -34,7 +34,6 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.* import org.dolphinemu.dolphinemu.model.GpuDriverMetadata import org.dolphinemu.dolphinemu.ui.main.MainPresenter import org.dolphinemu.dolphinemu.utils.* -import java.util.* import kotlin.collections.ArrayList import kotlin.math.ceil import kotlin.math.floor @@ -2265,7 +2264,6 @@ class SettingsFragmentPresenter( private fun addWiimoteSubSettings(sl: ArrayList, wiimoteNumber: Int) { val wiimote = EmulatedController.getWiimote(wiimoteNumber) - if (!TextUtils.isEmpty(gameId)) { addControllerPerGameSettings(sl, wiimote, wiimoteNumber) } else { @@ -2438,15 +2436,24 @@ class SettingsFragmentPresenter( 0, true ) { clearControllerSettings(controller) }) - sl.add( - RunRunnable( - context, - R.string.input_profiles, - 0, - 0, - 0, - true - ) { fragmentView.showDialogFragment(ProfileDialog.create(menuTag)) }) + + + val profileSelector = RunRunnable( + context, + R.string.input_profiles, + 0, + 0, + 0, + true + ) { fragmentView.showDialogFragment(ProfileDialog.create(menuTag)) } + + sl.add(profileSelector) + profileSelector.updateDescription(context.getString(R.string.input_profiles_descríption, controller.getProfileName())) + + /*var l = "" + ProfileDialogPresenter(menuTag).getProfileNames(false).forEach { l+= "$it, " } + Log.error("Profile: ${}") + Log.error("Profiles: $l")*/ updateOldControllerSettingsWarningVisibility(controller) } diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index 51406cd7e3..925cae7158 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -37,6 +37,7 @@ Profile You haven\'t created any profiles yet. Profiles + Loaded Profile: %1$s (New Profile) Load Save diff --git a/Source/Android/jni/Input/EmulatedController.cpp b/Source/Android/jni/Input/EmulatedController.cpp index 495a376f69..9bf76098e8 100644 --- a/Source/Android/jni/Input/EmulatedController.cpp +++ b/Source/Android/jni/Input/EmulatedController.cpp @@ -121,7 +121,7 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_loadProfile( - JNIEnv* env, jobject obj, jstring j_path) + JNIEnv* env, jobject obj, jstring j_path, jstring j_profileName) { ControllerEmu::EmulatedController* controller = EmulatedControllerFromJava(env, obj); @@ -129,6 +129,7 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro ini.Load(GetJString(env, j_path)); controller->LoadConfig(ini.GetOrCreateSection("Profile")); + controller->SetProfileName(GetJString(env, j_profileName)); controller->UpdateReferences(g_controller_interface); controller->GetConfig()->GenerateControllerTextures(); } @@ -154,6 +155,14 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro return ToJString(env, EmulatedControllerFromJava(env, obj)->GetConfig()->GetProfileKey()); } + +JNIEXPORT jstring JNICALL + Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getProfileName( + JNIEnv* env, jobject obj) +{ + return ToJString(env, EmulatedControllerFromJava(env, obj)->GetProfileName()); +} + JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getUserProfileDirectoryPath( JNIEnv* env, jobject obj) diff --git a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h index 466906da04..9b873aef1b 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h @@ -244,6 +244,9 @@ public: void LoadConfig(Common::IniFile::Section* sec); void SaveConfig(Common::IniFile::Section* sec); + std::string GetProfileName(){ return m_profile_name; } + void SetProfileName(std::string name){ m_profile_name = name; } + bool IsDefaultDeviceConnected() const; const ciface::Core::DeviceQualifier& GetDefaultDevice() const; void SetDefaultDevice(const std::string& device); @@ -269,5 +272,6 @@ protected: private: ciface::Core::DeviceQualifier m_default_device; bool m_default_device_is_connected{false}; + std::string m_profile_name = ""; }; } // namespace ControllerEmu