diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index 184b966885..bede7f3818 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -9,6 +9,7 @@ import android.content.SharedPreferences; import android.graphics.Rect; import android.os.Build; import android.os.Bundle; +import android.util.Pair; import android.util.SparseIntArray; import android.view.InputDevice; import android.view.KeyEvent; @@ -33,12 +34,14 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import androidx.preference.PreferenceManager; +import androidx.recyclerview.widget.LinearLayoutManager; import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.databinding.ActivityEmulationBinding; import org.dolphinemu.dolphinemu.databinding.DialogInputAdjustBinding; import org.dolphinemu.dolphinemu.databinding.DialogIrSensitivityBinding; +import org.dolphinemu.dolphinemu.databinding.DialogSkylandersManagerBinding; import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.IntSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; @@ -46,6 +49,10 @@ import org.dolphinemu.dolphinemu.features.settings.model.StringSetting; import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity; import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile; +import org.dolphinemu.dolphinemu.features.skylanders.SkylanderConfig; +import org.dolphinemu.dolphinemu.features.skylanders.model.Skylander; +import org.dolphinemu.dolphinemu.features.skylanders.ui.SkylanderSlot; +import org.dolphinemu.dolphinemu.features.skylanders.ui.SkylanderSlotAdapter; import org.dolphinemu.dolphinemu.fragments.EmulationFragment; import org.dolphinemu.dolphinemu.fragments.MenuFragment; import org.dolphinemu.dolphinemu.fragments.SaveLoadStateFragment; @@ -63,6 +70,7 @@ import org.dolphinemu.dolphinemu.utils.ThemeHelper; import java.io.File; import java.lang.annotation.Retention; +import java.util.ArrayList; import java.util.List; import static java.lang.annotation.RetentionPolicy.SOURCE; @@ -75,6 +83,8 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP private static final String BACKSTACK_NAME_MENU = "menu"; private static final String BACKSTACK_NAME_SUBMENU = "submenu"; public static final int REQUEST_CHANGE_DISC = 1; + public static final int REQUEST_SKYLANDER_FILE = 2; + public static final int REQUEST_CREATE_SKYLANDER = 3; private EmulationFragment mEmulationFragment; @@ -101,6 +111,10 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP public static final String EXTRA_SYSTEM_MENU = "SystemMenu"; public static final String EXTRA_USER_PAUSED_EMULATION = "sUserPausedEmulation"; public static final String EXTRA_MENU_TOAST_SHOWN = "MenuToastShown"; + public static final String EXTRA_SKYLANDER_SLOT = "SkylanderSlot"; + public static final String EXTRA_SKYLANDER_ID = "SkylanderId"; + public static final String EXTRA_SKYLANDER_VAR = "SkylanderVar"; + public static final String EXTRA_SKYLANDER_NAME = "SkylanderName"; @Retention(SOURCE) @IntDef( @@ -115,7 +129,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP MENU_ACTION_RESET_OVERLAY, MENU_SET_IR_RECENTER, MENU_SET_IR_MODE, MENU_SET_IR_SENSITIVITY, MENU_ACTION_CHOOSE_DOUBLETAP, MENU_ACTION_MOTION_CONTROLS, MENU_ACTION_PAUSE_EMULATION, MENU_ACTION_UNPAUSE_EMULATION, MENU_ACTION_OVERLAY_CONTROLS, - MENU_ACTION_SETTINGS}) + MENU_ACTION_SETTINGS, MENU_ACTION_SKYLANDERS}) public @interface MenuAction { } @@ -156,6 +170,15 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP public static final int MENU_ACTION_UNPAUSE_EMULATION = 33; public static final int MENU_ACTION_OVERLAY_CONTROLS = 34; public static final int MENU_ACTION_SETTINGS = 35; + public static final int MENU_ACTION_SKYLANDERS = 36; + + private Skylander mSkylanderData = new Skylander(-1, -1, "Slot"); + + private int mSkylanderSlot = -1; + + private DialogSkylandersManagerBinding mSkylandersBinding; + + private static List sSkylanderSlots = new ArrayList<>(); private static final SparseIntArray buttonsActionsMap = new SparseIntArray(); @@ -361,6 +384,14 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP if (NativeLibrary.IsGameMetadataValid()) setTitle(NativeLibrary.GetCurrentTitleDescription()); + + if (sSkylanderSlots.isEmpty()) + { + for (int i = 0; i < 8; i++) + { + sSkylanderSlots.add(new SkylanderSlot(getString(R.string.skylander_slot, i + 1), i)); + } + } } @Override @@ -373,6 +404,10 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP outState.putStringArray(EXTRA_SELECTED_GAMES, mPaths); outState.putBoolean(EXTRA_USER_PAUSED_EMULATION, sUserPausedEmulation); outState.putBoolean(EXTRA_MENU_TOAST_SHOWN, mMenuToastShown); + outState.putInt(EXTRA_SKYLANDER_SLOT, mSkylanderSlot); + outState.putInt(EXTRA_SKYLANDER_ID, mSkylanderData.getId()); + outState.putInt(EXTRA_SKYLANDER_VAR, mSkylanderData.getVar()); + outState.putString(EXTRA_SKYLANDER_NAME, mSkylanderData.getName()); super.onSaveInstanceState(outState); } @@ -381,6 +416,10 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP mPaths = savedInstanceState.getStringArray(EXTRA_SELECTED_GAMES); sUserPausedEmulation = savedInstanceState.getBoolean(EXTRA_USER_PAUSED_EMULATION); mMenuToastShown = savedInstanceState.getBoolean(EXTRA_MENU_TOAST_SHOWN); + mSkylanderSlot = savedInstanceState.getInt(EXTRA_SKYLANDER_SLOT); + mSkylanderData = new Skylander(savedInstanceState.getInt(EXTRA_SKYLANDER_ID), + savedInstanceState.getInt(EXTRA_SKYLANDER_VAR), + savedInstanceState.getString(EXTRA_SKYLANDER_NAME)); } @Override @@ -486,13 +525,40 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP protected void onActivityResult(int requestCode, int resultCode, Intent result) { super.onActivityResult(requestCode, resultCode, result); - if (requestCode == REQUEST_CHANGE_DISC) + // If the user picked a file, as opposed to just backing out. + if (resultCode == RESULT_OK) { - // If the user picked a file, as opposed to just backing out. - if (resultCode == RESULT_OK) + if (requestCode == REQUEST_CHANGE_DISC) { NativeLibrary.ChangeDisc(result.getData().toString()); } + else if (requestCode == REQUEST_SKYLANDER_FILE) + { + Pair slot = + SkylanderConfig.loadSkylander(sSkylanderSlots.get(mSkylanderSlot).getPortalSlot(), + result.getData().toString()); + clearSkylander(mSkylanderSlot); + sSkylanderSlots.get(mSkylanderSlot).setPortalSlot(slot.first); + sSkylanderSlots.get(mSkylanderSlot).setLabel(slot.second); + mSkylandersBinding.skylandersManager.getAdapter().notifyItemChanged(mSkylanderSlot); + mSkylanderSlot = -1; + mSkylanderData = Skylander.BLANK_SKYLANDER; + } + else if (requestCode == REQUEST_CREATE_SKYLANDER) + { + if (!(mSkylanderData.getId() == -1) && !(mSkylanderData.getVar() == -1)) + { + Pair slot = SkylanderConfig.createSkylander(mSkylanderData.getId(), + mSkylanderData.getVar(), + result.getData().toString(), sSkylanderSlots.get(mSkylanderSlot).getPortalSlot()); + clearSkylander(mSkylanderSlot); + sSkylanderSlots.get(mSkylanderSlot).setPortalSlot(slot.first); + sSkylanderSlots.get(mSkylanderSlot).setLabel(slot.second); + mSkylandersBinding.skylandersManager.getAdapter().notifyItemChanged(mSkylanderSlot); + mSkylanderSlot = -1; + mSkylanderData = Skylander.BLANK_SKYLANDER; + } + } } } @@ -773,6 +839,10 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP SettingsActivity.launch(this, MenuTag.SETTINGS); break; + case MENU_ACTION_SKYLANDERS: + showSkylanderPortalSettings(); + break; + case MENU_ACTION_EXIT: mEmulationFragment.stopEmulation(); break; @@ -1110,6 +1180,33 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP .show(); } + private void showSkylanderPortalSettings() + { + mSkylandersBinding = + DialogSkylandersManagerBinding.inflate(getLayoutInflater()); + mSkylandersBinding.skylandersManager.setLayoutManager(new LinearLayoutManager(this)); + + mSkylandersBinding.skylandersManager.setAdapter( + new SkylanderSlotAdapter(sSkylanderSlots, this)); + + new MaterialAlertDialogBuilder(this) + .setTitle(R.string.skylanders_manager) + .setView(mSkylandersBinding.getRoot()) + .show(); + } + + public void setSkylanderData(int id, int var, String name, int slot) + { + mSkylanderData = new Skylander(id, var, name); + mSkylanderSlot = slot; + } + + public void clearSkylander(int slot) + { + sSkylanderSlots.get(slot).setLabel(getString(R.string.skylander_slot, slot + 1)); + mSkylandersBinding.skylandersManager.getAdapter().notifyItemChanged(slot); + } + private void resetOverlay() { new MaterialAlertDialogBuilder(this) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java index 18ad9529c7..76925a1429 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java @@ -89,6 +89,9 @@ public enum BooleanSetting implements AbstractBooleanSetting MAIN_DEBUG_JIT_REGISTER_CACHE_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitRegisterCacheOff", false), + MAIN_EMULATE_SKYLANDER_PORTAL(Settings.FILE_DOLPHIN, Settings.SECTION_EMULATED_USB_DEVICES, + "EmulateSkylanderPortal", false), + MAIN_SHOW_GAME_TITLES(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "ShowGameTitles", true), MAIN_USE_BLACK_BACKGROUNDS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, @@ -273,6 +276,7 @@ public enum BooleanSetting implements AbstractBooleanSetting MAIN_RAM_OVERRIDE_ENABLE, MAIN_CUSTOM_RTC_ENABLE, MAIN_DSP_JIT, + MAIN_EMULATE_SKYLANDER_PORTAL, }; private static final Set NOT_RUNTIME_EDITABLE = diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java index d042ae32f5..ebdaf70691 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java @@ -42,6 +42,7 @@ public class Settings implements Closeable public static final String SECTION_GFX_HACKS = "Hacks"; public static final String SECTION_DEBUG = "Debug"; + public static final String SECTION_EMULATED_USB_DEVICES = "EmulatedUSBDevices"; public static final String SECTION_STEREOSCOPY = "Stereoscopy"; diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java index 679265c34d..ada1e0e000 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java @@ -263,7 +263,9 @@ public final class SettingsFragmentPresenter { sl.add(new SubmenuSetting(mContext, R.string.gcpad_settings, MenuTag.GCPAD_TYPE)); if (mSettings.isWii()) + { sl.add(new SubmenuSetting(mContext, R.string.wiimote_settings, MenuTag.WIIMOTE)); + } } sl.add(new HeaderSetting(mContext, R.string.setting_clear_info, 0)); @@ -633,6 +635,10 @@ public final class SettingsFragmentPresenter R.string.wiimote_scanning, R.string.wiimote_scanning_description)); sl.add(new SwitchSetting(mContext, BooleanSetting.MAIN_WIIMOTE_ENABLE_SPEAKER, R.string.wiimote_speaker, R.string.wiimote_speaker_description)); + + sl.add(new HeaderSetting(mContext, R.string.emulated_usb_devices, 0)); + sl.add(new SwitchSetting(mContext, BooleanSetting.MAIN_EMULATE_SKYLANDER_PORTAL, + R.string.emulate_skylander_portal, 0)); } private void addAdvancedSettings(ArrayList sl) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/SkylanderConfig.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/SkylanderConfig.java new file mode 100644 index 0000000000..285e017a8f --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/SkylanderConfig.java @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.skylanders; + +import android.util.Pair; + +import org.dolphinemu.dolphinemu.features.skylanders.model.SkylanderPair; + +import java.util.Map; + +public class SkylanderConfig +{ + public static final Map LIST_SKYLANDERS; + public static final Map REVERSE_LIST_SKYLANDERS; + + static + { + LIST_SKYLANDERS = getSkylanderMap(); + REVERSE_LIST_SKYLANDERS = getInverseSkylanderMap(); + } + + public static native Map getSkylanderMap(); + + public static native Map getInverseSkylanderMap(); + + public static native boolean removeSkylander(int slot); + + public static native Pair loadSkylander(int slot, String fileName); + + public static native Pair createSkylander(int id, int var, String fileName, + int slot); +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/model/Skylander.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/model/Skylander.java new file mode 100644 index 0000000000..b4c96a1a13 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/model/Skylander.java @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.skylanders.model; + +public class Skylander +{ + private SkylanderPair mPair; + private String mName; + + public final static Skylander BLANK_SKYLANDER = new Skylander(-1, -1, "Blank"); + + public Skylander(int id, int var, String name) + { + mPair = new SkylanderPair(id, var); + mName = name; + } + + public String getName() + { + return mName; + } + + public void setName(String name) + { + this.mName = name; + } + + public int getId() + { + return mPair.getId(); + } + + public int getVar() + { + return mPair.getVar(); + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/model/SkylanderPair.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/model/SkylanderPair.java new file mode 100644 index 0000000000..e4fca37afd --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/model/SkylanderPair.java @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.skylanders.model; + +import androidx.annotation.Nullable; + +public class SkylanderPair +{ + private int mId; + private int mVar; + + public SkylanderPair(int id, int var) + { + mId = id; + mVar = var; + } + + public int getId() + { + return mId; + } + + public void setId(int mId) + { + this.mId = mId; + } + + public int getVar() + { + return mVar; + } + + public void setVar(int mVar) + { + this.mVar = mVar; + } + + @Override public int hashCode() + { + return (mId << 16) + mVar; + } + + @Override public boolean equals(@Nullable Object obj) + { + if (!(obj instanceof SkylanderPair)) + return false; + SkylanderPair pairObj = (SkylanderPair) obj; + if (pairObj.getId() != mId) + return false; + if (pairObj.getVar() != mVar) + return false; + return true; + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/ui/SkylanderSlot.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/ui/SkylanderSlot.java new file mode 100644 index 0000000000..857c077106 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/ui/SkylanderSlot.java @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.skylanders.ui; + +public class SkylanderSlot +{ + private String mLabel; + private final int mSlotNum; + private int mPortalSlot; + + public SkylanderSlot(String label, int slot) + { + mLabel = label; + mSlotNum = slot; + mPortalSlot = -1; + } + + public String getLabel() + { + return mLabel; + } + + public void setLabel(String label) + { + mLabel = label; + } + + public int getSlotNum() + { + return mSlotNum; + } + + public int getPortalSlot() + { + return mPortalSlot; + } + + public void setPortalSlot(int mPortalSlot) + { + this.mPortalSlot = mPortalSlot; + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/ui/SkylanderSlotAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/ui/SkylanderSlotAdapter.java new file mode 100644 index 0000000000..65171ab112 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/skylanders/ui/SkylanderSlotAdapter.java @@ -0,0 +1,160 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.skylanders.ui; + +import android.content.Intent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + +import org.dolphinemu.dolphinemu.R; +import org.dolphinemu.dolphinemu.activities.EmulationActivity; +import org.dolphinemu.dolphinemu.databinding.DialogCreateSkylanderBinding; +import org.dolphinemu.dolphinemu.databinding.ListItemSkylanderSlotBinding; +import org.dolphinemu.dolphinemu.features.skylanders.SkylanderConfig; +import org.dolphinemu.dolphinemu.features.skylanders.model.SkylanderPair; + +import java.util.ArrayList; +import java.util.List; + +public class SkylanderSlotAdapter extends RecyclerView.Adapter + implements AdapterView.OnItemClickListener +{ + public static class ViewHolder extends RecyclerView.ViewHolder + { + public ListItemSkylanderSlotBinding binding; + + public ViewHolder(@NonNull ListItemSkylanderSlotBinding binding) + { + super(binding.getRoot()); + this.binding = binding; + } + } + + private final List mSlots; + private final EmulationActivity mActivity; + + private DialogCreateSkylanderBinding mBinding; + + public SkylanderSlotAdapter(List slots, EmulationActivity context) + { + mSlots = slots; + mActivity = context; + } + + @NonNull + @Override + public SkylanderSlotAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) + { + LayoutInflater inflater = LayoutInflater.from(parent.getContext()); + ListItemSkylanderSlotBinding binding = + ListItemSkylanderSlotBinding.inflate(inflater, parent, false); + return new ViewHolder(binding); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) + { + SkylanderSlot slot = mSlots.get(position); + holder.binding.textSkylanderName.setText(slot.getLabel()); + + holder.binding.buttonClearSkylander.setOnClickListener(v -> + { + SkylanderConfig.removeSkylander(slot.getPortalSlot()); + mActivity.clearSkylander(slot.getSlotNum()); + }); + + holder.binding.buttonLoadSkylander.setOnClickListener(v -> + { + Intent loadSkylander = new Intent(Intent.ACTION_OPEN_DOCUMENT); + loadSkylander.addCategory(Intent.CATEGORY_OPENABLE); + loadSkylander.setType("*/*"); + mActivity.setSkylanderData(0, 0, "", position); + mActivity.startActivityForResult(loadSkylander, EmulationActivity.REQUEST_SKYLANDER_FILE); + }); + + LayoutInflater inflater = LayoutInflater.from(mActivity); + mBinding = DialogCreateSkylanderBinding.inflate(inflater); + + List skylanderNames = new ArrayList<>(SkylanderConfig.REVERSE_LIST_SKYLANDERS.keySet()); + skylanderNames.sort(String::compareToIgnoreCase); + + mBinding.skylanderDropdown.setAdapter( + new ArrayAdapter<>(mActivity, R.layout.support_simple_spinner_dropdown_item, + skylanderNames)); + mBinding.skylanderDropdown.setOnItemClickListener(this); + + holder.binding.buttonCreateSkylander.setOnClickListener(v -> + { + if (mBinding.getRoot().getParent() != null) + { + ((ViewGroup) mBinding.getRoot().getParent()).removeAllViews(); + } + AlertDialog createDialog = new MaterialAlertDialogBuilder(mActivity) + .setTitle(R.string.create_skylander_title) + .setView(mBinding.getRoot()) + .setPositiveButton(R.string.create_skylander, null) + .setNegativeButton(R.string.cancel, null) + .show(); + createDialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE).setOnClickListener( + v1 -> + { + if (!mBinding.skylanderId.getText().toString().isBlank() && + !mBinding.skylanderVar.getText().toString().isBlank()) + { + Intent createSkylander = new Intent(Intent.ACTION_CREATE_DOCUMENT); + createSkylander.addCategory(Intent.CATEGORY_OPENABLE); + createSkylander.setType("*/*"); + int id = Integer.parseInt(mBinding.skylanderId.getText().toString()); + int var = Integer.parseInt(mBinding.skylanderVar.getText().toString()); + String name = SkylanderConfig.LIST_SKYLANDERS.get(new SkylanderPair(id, var)); + if (name != null) + { + createSkylander.putExtra(Intent.EXTRA_TITLE, + name + ".sky"); + mActivity.setSkylanderData(id, var, name, position); + } + else + { + createSkylander.putExtra(Intent.EXTRA_TITLE, + "Unknown(ID" + id + "Var" + var + ").sky"); + mActivity.setSkylanderData(id, var, "Unknown", position); + } + mActivity.startActivityForResult(createSkylander, + EmulationActivity.REQUEST_CREATE_SKYLANDER); + createDialog.dismiss(); + } + else + { + Toast.makeText(mActivity, R.string.invalid_skylander, + Toast.LENGTH_SHORT).show(); + } + }); + }); + + } + + @Override + public int getItemCount() + { + return mSlots.size(); + } + + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) + { + SkylanderPair skylanderIdVar = + SkylanderConfig.REVERSE_LIST_SKYLANDERS.get(parent.getItemAtPosition(position)); + mBinding.skylanderId.setText(String.valueOf(skylanderIdVar.getId())); + mBinding.skylanderVar.setText(String.valueOf(skylanderIdVar.getVar())); + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java index 16da69db43..fc3ba9dac0 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java @@ -60,6 +60,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener buttonsActionsMap.append(R.id.menu_change_disc, EmulationActivity.MENU_ACTION_CHANGE_DISC); buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT); buttonsActionsMap.append(R.id.menu_settings, EmulationActivity.MENU_ACTION_SETTINGS); + buttonsActionsMap.append(R.id.menu_skylanders, EmulationActivity.MENU_ACTION_SKYLANDERS); } private FragmentIngameMenuBinding mBinding; @@ -110,6 +111,12 @@ public final class MenuFragment extends Fragment implements View.OnClickListener if (!getArguments().getBoolean(KEY_WII, true)) { mBinding.menuRefreshWiimotes.setVisibility(View.GONE); + mBinding.menuSkylanders.setVisibility(View.GONE); + } + + if (!BooleanSetting.MAIN_EMULATE_SKYLANDER_PORTAL.getBooleanGlobal()) + { + mBinding.menuSkylanders.setVisibility(View.GONE); } LinearLayout options = mBinding.layoutOptions; diff --git a/Source/Android/app/src/main/res/drawable/ic_clear.xml b/Source/Android/app/src/main/res/drawable/ic_clear.xml new file mode 100644 index 0000000000..847cda185b --- /dev/null +++ b/Source/Android/app/src/main/res/drawable/ic_clear.xml @@ -0,0 +1,9 @@ + + + diff --git a/Source/Android/app/src/main/res/drawable/ic_load.xml b/Source/Android/app/src/main/res/drawable/ic_load.xml new file mode 100644 index 0000000000..a4d17e72a8 --- /dev/null +++ b/Source/Android/app/src/main/res/drawable/ic_load.xml @@ -0,0 +1,9 @@ + + + diff --git a/Source/Android/app/src/main/res/layout/dialog_create_skylander.xml b/Source/Android/app/src/main/res/layout/dialog_create_skylander.xml new file mode 100644 index 0000000000..b367fbb278 --- /dev/null +++ b/Source/Android/app/src/main/res/layout/dialog_create_skylander.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/Android/app/src/main/res/layout/dialog_skylanders_manager.xml b/Source/Android/app/src/main/res/layout/dialog_skylanders_manager.xml new file mode 100644 index 0000000000..517399ff3a --- /dev/null +++ b/Source/Android/app/src/main/res/layout/dialog_skylanders_manager.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml b/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml index df5a104cef..0619f22087 100644 --- a/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml +++ b/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml @@ -101,6 +101,11 @@ android:text="@string/emulation_change_disc" style="@style/InGameMenuOption" /> +