Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/dolphin-emu/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
SonofUgly committed Oct 14, 2017
2 parents 0ef75a9 + 2dfbf86 commit 0001ba4
Show file tree
Hide file tree
Showing 248 changed files with 5,209 additions and 3,604 deletions.
2 changes: 2 additions & 0 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ This project uses clang-format (stable branch) to check for common style issues.

## <a name="intro-formatting-issues"></a>Checking and fixing formatting issues

Windows users need to be careful about line endings. Windows users should configure git to checkout UNIX-style line endings to keep clang-format simple.

In most cases, clang-format can and **should** be used to automatically reformat code and solve most formatting issues.

- To run clang-format on all staged files:
Expand Down
4 changes: 0 additions & 4 deletions Source/Android/app/src/debug/res/values/strings.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import android.view.MenuInflater;
import android.view.MenuItem;

import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.adapters.FileAdapter;
import org.dolphinemu.dolphinemu.model.GameDatabase;
Expand All @@ -28,7 +27,7 @@
*/
public class AddDirectoryActivity extends AppCompatActivity implements FileAdapter.FileClickListener
{
public static final String KEY_CURRENT_PATH = BuildConfig.APPLICATION_ID + ".path";
private static final String KEY_CURRENT_PATH = "path";

private FileAdapter mAdapter;
private Toolbar mToolbar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.fragments.EmulationFragment;
import org.dolphinemu.dolphinemu.fragments.LoadStateFragment;
import org.dolphinemu.dolphinemu.fragments.MenuFragment;
import org.dolphinemu.dolphinemu.fragments.SaveStateFragment;
import org.dolphinemu.dolphinemu.fragments.SaveLoadStateFragment;
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.utils.Animations;
import org.dolphinemu.dolphinemu.utils.Java_GCAdapter;
import org.dolphinemu.dolphinemu.utils.Java_WiimoteAdapter;
Expand All @@ -53,14 +53,13 @@

public final class EmulationActivity extends AppCompatActivity
{
private static final String FRAGMENT_SUBMENU_TAG = "submenu";
private View mDecorView;
private ImageView mImageView;

private FrameLayout mFrameEmulation;
private LinearLayout mMenuLayout;

private String mSubmenuFragmentTag;

private SharedPreferences mPreferences;

// So that MainActivity knows which view to invalidate before the return animation.
Expand All @@ -69,9 +68,15 @@ public final class EmulationActivity extends AppCompatActivity
private boolean mDeviceHasTouchScreen;
private boolean mSystemUiVisible;
private boolean mMenuVisible;
private boolean mSubMenuVisible = false;

private static boolean mIsGameCubeGame;

private enum MenuType
{
SAVE, LOAD
}

/**
* Handlers are a way to pass a message to an Activity telling it to do something
* on the UI thread. This Handler responds to any message, even blank ones, by
Expand Down Expand Up @@ -150,8 +155,23 @@ public void handleMessage(Message msg)
buttonsActionsMap.append(R.id.menu_emulation_load_4, EmulationActivity.MENU_ACTION_LOAD_SLOT4);
buttonsActionsMap.append(R.id.menu_emulation_load_5, EmulationActivity.MENU_ACTION_LOAD_SLOT5);
buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT);
}

public static void launch(Activity activity, String path, String title, String screenshotPath, int position, View sharedView)
{
Intent launcher = new Intent(activity, EmulationActivity.class);

launcher.putExtra("SelectedGame", path);
launcher.putExtra("SelectedTitle", title);
launcher.putExtra("ScreenPath", screenshotPath);
launcher.putExtra("GridPosition", position);

ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
activity,
sharedView,
"image_game_screenshot");

activity.startActivityForResult(launcher, MainPresenter.REQUEST_EMULATE_GAME, options.toBundle());
}

@Override
Expand Down Expand Up @@ -293,7 +313,7 @@ public void run()

mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

mIsGameCubeGame = (NativeLibrary.GetPlatform(path) == 0);
mIsGameCubeGame = Platform.fromNativeInt(NativeLibrary.GetPlatform(path)) == Platform.GAMECUBE;
}

@Override
Expand Down Expand Up @@ -350,7 +370,7 @@ public void onBackPressed()
{
if (!mDeviceHasTouchScreen)
{
if (mSubmenuFragmentTag != null)
if (mSubMenuVisible)
{
removeSubMenu();
}
Expand Down Expand Up @@ -522,14 +542,14 @@ public void handleMenuAction(@MenuAction int menuAction)
case MENU_ACTION_SAVE_ROOT:
if (!mDeviceHasTouchScreen)
{
showMenu(SaveStateFragment.FRAGMENT_ID);
showMenu(SaveLoadStateFragment.SaveOrLoad.SAVE);
}
return;

case MENU_ACTION_LOAD_ROOT:
if (!mDeviceHasTouchScreen)
{
showMenu(LoadStateFragment.FRAGMENT_ID);
showMenu(SaveLoadStateFragment.SaveOrLoad.LOAD);
}
return;

Expand Down Expand Up @@ -862,68 +882,44 @@ public boolean onPreDraw()
});
}

private void showMenu(int menuId)
private void showMenu(SaveLoadStateFragment.SaveOrLoad saveOrLoad)
{
Fragment fragment;

switch (menuId)
{
case SaveStateFragment.FRAGMENT_ID:
fragment = SaveStateFragment.newInstance();
mSubmenuFragmentTag = SaveStateFragment.FRAGMENT_TAG;
break;

case LoadStateFragment.FRAGMENT_ID:
fragment = LoadStateFragment.newInstance();
mSubmenuFragmentTag = LoadStateFragment.FRAGMENT_TAG;
break;

default:
return;
}

Fragment fragment = SaveLoadStateFragment.newInstance(saveOrLoad);
getFragmentManager().beginTransaction()
.setCustomAnimations(R.animator.menu_slide_in, R.animator.menu_slide_out)
.replace(R.id.frame_submenu, fragment, mSubmenuFragmentTag)
.replace(R.id.frame_submenu, fragment, FRAGMENT_SUBMENU_TAG)
.commit();
mSubMenuVisible = true;
}

private void removeSubMenu()
{
if (mSubmenuFragmentTag != null)
{
final Fragment fragment = getFragmentManager().findFragmentByTag(mSubmenuFragmentTag);
final Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_SUBMENU_TAG);

if (fragment != null)
{
// When removing a fragment without replacement, its animation must be done
// manually beforehand.
Animations.fadeViewOutToRight(fragment.getView())
.withEndAction(new Runnable()
if (fragment != null)
{
// When removing a fragment without replacement, its animation must be done
// manually beforehand.
Animations.fadeViewOutToRight(fragment.getView())
.withEndAction(new Runnable()
{
@Override
public void run()
{
@Override
public void run()
if (mMenuVisible)
{
if (mMenuVisible)
{
getFragmentManager().beginTransaction()
.remove(fragment)
.commit();
}
getFragmentManager().beginTransaction()
.remove(fragment)
.commit();
}
});
}
else
{
Log.error("[EmulationActivity] Fragment not found, can't remove.");
}

mSubmenuFragmentTag = null;
}
});
}
else
{
Log.error("[EmulationActivity] Fragment Tag empty.");
Log.error("[EmulationActivity] Fragment not found, can't remove.");
}
mSubMenuVisible = false;
}

public String getSelectedTitle()
Expand All @@ -935,21 +931,4 @@ public static boolean isGameCubeGame()
{
return mIsGameCubeGame;
}

public static void launch(Activity activity, String path, String title, String screenshotPath, int position, View sharedView)
{
Intent launcher = new Intent(activity, EmulationActivity.class);

launcher.putExtra("SelectedGame", path);
launcher.putExtra("SelectedTitle", title);
launcher.putExtra("ScreenPath", screenshotPath);
launcher.putExtra("GridPosition", position);

ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
activity,
sharedView,
"image_game_screenshot");

activity.startActivityForResult(launcher, MainPresenter.REQUEST_EMULATE_GAME, options.toBundle());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.dolphinemu.dolphinemu.adapters;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v17.leanback.widget.ImageCardView;
import android.support.v17.leanback.widget.Presenter;
import android.support.v4.content.ContextCompat;
import android.view.ViewGroup;
import android.widget.ImageView;

Expand All @@ -16,18 +19,11 @@
*/
public final class GameRowPresenter extends Presenter
{
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent)
{
// Create a new view.
ImageCardView gameCard = new ImageCardView(parent.getContext())
{
@Override
public void setSelected(boolean selected)
{
setCardBackground(this, selected);
super.setSelected(selected);
}
};
ImageCardView gameCard = new ImageCardView(parent.getContext());

gameCard.setMainImageAdjustViewBounds(true);
gameCard.setMainImageDimensions(480, 320);
Expand All @@ -36,12 +32,11 @@ public void setSelected(boolean selected)
gameCard.setFocusable(true);
gameCard.setFocusableInTouchMode(true);

setCardBackground(gameCard, false);

// Use that view to create a ViewHolder.
return new TvGameViewHolder(gameCard);
}

@Override
public void onBindViewHolder(ViewHolder viewHolder, Object item)
{
TvGameViewHolder holder = (TvGameViewHolder) viewHolder;
Expand All @@ -64,45 +59,30 @@ public void onBindViewHolder(ViewHolder viewHolder, Object item)
holder.company = game.getCompany();
holder.screenshotPath = game.getScreenshotPath();

// Set the platform-dependent background color of the card
int backgroundId;
switch (game.getPlatform())
{
case Game.PLATFORM_GC:
holder.cardParent.setTag(R.color.dolphin_accent_gamecube);
case GAMECUBE:
backgroundId = R.drawable.tv_card_background_gamecube;
break;

case Game.PLATFORM_WII:
holder.cardParent.setTag(R.color.dolphin_accent_wii);
case WII:
backgroundId = R.drawable.tv_card_background_wii;
break;

case Game.PLATFORM_WII_WARE:
holder.cardParent.setTag(R.color.dolphin_accent_wiiware);
case WIIWARE:
backgroundId = R.drawable.tv_card_background_wiiware;
break;

default:
holder.cardParent.setTag(android.R.color.holo_red_dark);
break;
throw new AssertionError("Not reachable.");
}
Context context = holder.cardParent.getContext();
Drawable background = ContextCompat.getDrawable(context, backgroundId);
holder.cardParent.setInfoAreaBackground(background);
}

@Override
public void onUnbindViewHolder(ViewHolder viewHolder)
{
// no op
}

public void setCardBackground(ImageCardView view, boolean selected)
{
int backgroundColor;

if (selected)
{
// TODO: 7/20/15 Try using view tag to set color
backgroundColor = (int) view.getTag();
}
else
{
backgroundColor = R.color.tv_card_unselected;
}

view.setInfoAreaBackgroundColor(view.getResources().getColor(backgroundColor));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.text.style.ImageSpan;

import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.ui.platform.PlatformGamesFragment;

public class PlatformPagerAdapter extends FragmentPagerAdapter
Expand All @@ -32,7 +33,7 @@ public PlatformPagerAdapter(FragmentManager fm, Context context)
@Override
public Fragment getItem(int position)
{
return PlatformGamesFragment.newInstance(position);
return PlatformGamesFragment.newInstance(Platform.fromPosition(position));
}

@Override
Expand Down
Loading

0 comments on commit 0001ba4

Please sign in to comment.