Revision 53f23b64
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/dialog/RubikDialogNewRecord.java | ||
|---|---|---|
| 85 | 85 |
RubikStatePlay play = (RubikStatePlay) RubikState.PLAY.getStateClass(); |
| 86 | 86 |
int object = play.getObject(); |
| 87 | 87 |
int size = play.getSize(); |
| 88 |
int sizeIndex = RubikObjectList.getSizeIndex(object,size); |
|
| 88 | 89 |
|
| 89 |
bundle.putInt("tab", RubikObjectList.pack(object,size) );
|
|
| 90 |
bundle.putInt("tab", RubikObjectList.pack(object,sizeIndex) );
|
|
| 90 | 91 |
bundle.putBoolean("submitting", true);
|
| 91 | 92 |
|
| 92 | 93 |
RubikDialogScores scoresDiag = new RubikDialogScores(); |
| src/main/java/org/distorted/dialog/RubikDialogPattern.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.dialog; |
|
| 21 |
|
|
| 22 |
import android.app.Dialog; |
|
| 23 |
import android.content.DialogInterface; |
|
| 24 |
import android.os.Bundle; |
|
| 25 |
import android.support.annotation.NonNull; |
|
| 26 |
import android.support.v4.app.FragmentActivity; |
|
| 27 |
import android.support.v4.view.ViewPager; |
|
| 28 |
import android.support.v7.app.AlertDialog; |
|
| 29 |
import android.support.v7.app.AppCompatDialogFragment; |
|
| 30 |
import android.support.design.widget.TabLayout; |
|
| 31 |
import android.view.LayoutInflater; |
|
| 32 |
import android.view.View; |
|
| 33 |
import android.view.Window; |
|
| 34 |
import android.view.WindowManager; |
|
| 35 |
import android.widget.ImageView; |
|
| 36 |
import android.widget.TextView; |
|
| 37 |
|
|
| 38 |
import org.distorted.magic.R; |
|
| 39 |
import org.distorted.patterns.RubikPattern; |
|
| 40 |
|
|
| 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 42 |
|
|
| 43 |
public class RubikDialogPattern extends AppCompatDialogFragment |
|
| 44 |
{
|
|
| 45 |
RubikDialogPatternPagerAdapter mPagerAdapter; |
|
| 46 |
|
|
| 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 48 |
|
|
| 49 |
@Override |
|
| 50 |
public void onStart() |
|
| 51 |
{
|
|
| 52 |
super.onStart(); |
|
| 53 |
|
|
| 54 |
Window window = getDialog().getWindow(); |
|
| 55 |
window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, |
|
| 56 |
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); |
|
| 57 |
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 61 |
|
|
| 62 |
@NonNull |
|
| 63 |
@Override |
|
| 64 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 65 |
{
|
|
| 66 |
FragmentActivity act = getActivity(); |
|
| 67 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 68 |
|
|
| 69 |
LayoutInflater layoutInflater = act.getLayoutInflater(); |
|
| 70 |
TextView tv = (TextView) layoutInflater.inflate(R.layout.dialog_title, null); |
|
| 71 |
tv.setText(R.string.patterns); |
|
| 72 |
builder.setCustomTitle(tv); |
|
| 73 |
|
|
| 74 |
builder.setCancelable(true); |
|
| 75 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
|
| 76 |
{
|
|
| 77 |
@Override |
|
| 78 |
public void onClick(DialogInterface dialog, int which) |
|
| 79 |
{
|
|
| 80 |
|
|
| 81 |
} |
|
| 82 |
}); |
|
| 83 |
|
|
| 84 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 85 |
final View view = inflater.inflate(R.layout.dialog_tabbed, null); |
|
| 86 |
builder.setView(view); |
|
| 87 |
|
|
| 88 |
ViewPager viewPager = view.findViewById(R.id.viewpager); |
|
| 89 |
TabLayout tabLayout = view.findViewById(R.id.sliding_tabs); |
|
| 90 |
mPagerAdapter = new RubikDialogPatternPagerAdapter(act, viewPager, this); |
|
| 91 |
tabLayout.setupWithViewPager(viewPager); |
|
| 92 |
|
|
| 93 |
int[] iconID = { R.drawable.cube2, R.drawable.cube3, R.drawable.cube4, R.drawable.cube5 };
|
|
| 94 |
|
|
| 95 |
for(int i=0; i< RubikPattern.NUM_CUBES; i++) |
|
| 96 |
{
|
|
| 97 |
ImageView imageView = new ImageView(act); |
|
| 98 |
imageView.setImageResource(iconID[i]); |
|
| 99 |
TabLayout.Tab tab = tabLayout.getTabAt(i); |
|
| 100 |
if(tab!=null) tab.setCustomView(imageView); |
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
return builder.create(); |
|
| 104 |
} |
|
| 105 |
|
|
| 106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 107 |
|
|
| 108 |
public static String getDialogTag() |
|
| 109 |
{
|
|
| 110 |
return "DialogPattern"; |
|
| 111 |
} |
|
| 112 |
} |
|
| src/main/java/org/distorted/dialog/RubikDialogPatternPagerAdapter.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2020 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.dialog; |
|
| 21 |
|
|
| 22 |
import android.support.annotation.NonNull; |
|
| 23 |
import android.support.v4.app.FragmentActivity; |
|
| 24 |
import android.support.v4.view.PagerAdapter; |
|
| 25 |
import android.support.v4.view.ViewPager; |
|
| 26 |
import android.view.View; |
|
| 27 |
import android.view.ViewGroup; |
|
| 28 |
|
|
| 29 |
import org.distorted.patterns.RubikPattern; |
|
| 30 |
|
|
| 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 32 |
|
|
| 33 |
class RubikDialogPatternPagerAdapter extends PagerAdapter |
|
| 34 |
{
|
|
| 35 |
private FragmentActivity mAct; |
|
| 36 |
private RubikDialogPatternView[] mViews; |
|
| 37 |
private RubikDialogPattern mDialog; |
|
| 38 |
private int mNumTabs; |
|
| 39 |
|
|
| 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 41 |
|
|
| 42 |
private String[] createCategories(int pos) |
|
| 43 |
{
|
|
| 44 |
RubikPattern pattern = RubikPattern.getInstance(); |
|
| 45 |
int numCat = pattern.getNumCategories(pos); |
|
| 46 |
|
|
| 47 |
String[] ret = new String[numCat]; |
|
| 48 |
|
|
| 49 |
for(int i=0; i<numCat; i++) |
|
| 50 |
{
|
|
| 51 |
ret[i] = pattern.getCategoryName(pos,i); |
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
return ret; |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 58 |
|
|
| 59 |
RubikDialogPatternPagerAdapter(FragmentActivity act, ViewPager viewPager, RubikDialogPattern dialog) |
|
| 60 |
{
|
|
| 61 |
mAct = act; |
|
| 62 |
mDialog = dialog; |
|
| 63 |
mNumTabs = RubikPattern.NUM_CUBES; |
|
| 64 |
mViews = new RubikDialogPatternView[mNumTabs]; |
|
| 65 |
|
|
| 66 |
viewPager.setAdapter(this); |
|
| 67 |
viewPager.setOffscreenPageLimit(mNumTabs-1); |
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 71 |
|
|
| 72 |
@Override |
|
| 73 |
@NonNull |
|
| 74 |
public Object instantiateItem(@NonNull ViewGroup collection, final int position) |
|
| 75 |
{
|
|
| 76 |
String[] categories = createCategories(position); |
|
| 77 |
mViews[position] = new RubikDialogPatternView(mAct, mDialog, categories); |
|
| 78 |
collection.addView(mViews[position]); |
|
| 79 |
|
|
| 80 |
return mViews[position]; |
|
| 81 |
} |
|
| 82 |
|
|
| 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 84 |
|
|
| 85 |
@Override |
|
| 86 |
public void destroyItem(ViewGroup collection, int position, @NonNull Object view) |
|
| 87 |
{
|
|
| 88 |
collection.removeView((View) view); |
|
| 89 |
} |
|
| 90 |
|
|
| 91 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 92 |
|
|
| 93 |
@Override |
|
| 94 |
public int getCount() |
|
| 95 |
{
|
|
| 96 |
return mNumTabs; |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 100 |
|
|
| 101 |
@Override |
|
| 102 |
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) |
|
| 103 |
{
|
|
| 104 |
return view == object; |
|
| 105 |
} |
|
| 106 |
} |
|
| src/main/java/org/distorted/dialog/RubikDialogPatternView.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2020 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.dialog; |
|
| 21 |
|
|
| 22 |
import android.content.Context; |
|
| 23 |
import android.support.v4.app.FragmentActivity; |
|
| 24 |
import android.util.AttributeSet; |
|
| 25 |
import android.util.DisplayMetrics; |
|
| 26 |
import android.view.View; |
|
| 27 |
import android.widget.Button; |
|
| 28 |
import android.widget.FrameLayout; |
|
| 29 |
import android.widget.LinearLayout; |
|
| 30 |
|
|
| 31 |
import org.distorted.magic.R; |
|
| 32 |
import org.distorted.magic.RubikActivity; |
|
| 33 |
import org.distorted.uistate.RubikState; |
|
| 34 |
|
|
| 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 36 |
|
|
| 37 |
public class RubikDialogPatternView extends FrameLayout |
|
| 38 |
{
|
|
| 39 |
private LinearLayout mLayout; |
|
| 40 |
private RubikDialogPattern mDialog; |
|
| 41 |
|
|
| 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 43 |
|
|
| 44 |
public RubikDialogPatternView(Context context, AttributeSet attrs, int defStyle) |
|
| 45 |
{
|
|
| 46 |
super(context, attrs, defStyle); |
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 50 |
|
|
| 51 |
public RubikDialogPatternView(Context context, AttributeSet attrs) |
|
| 52 |
{
|
|
| 53 |
super(context, attrs); |
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 57 |
|
|
| 58 |
public RubikDialogPatternView(FragmentActivity act, RubikDialogPattern dialog, String[] categories) |
|
| 59 |
{
|
|
| 60 |
super(act); |
|
| 61 |
|
|
| 62 |
mDialog = dialog; |
|
| 63 |
View tab = inflate( act, R.layout.dialog_tab, null); |
|
| 64 |
mLayout = tab.findViewById(R.id.tabLayout); |
|
| 65 |
createSection(act,categories); |
|
| 66 |
|
|
| 67 |
addView(tab); |
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 71 |
|
|
| 72 |
private void createSection(final FragmentActivity act, final String[] categories) |
|
| 73 |
{
|
|
| 74 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
|
| 75 |
final float scale = metrics.density; |
|
| 76 |
int margin = (int)(3*scale + 0.5f); |
|
| 77 |
LinearLayout.LayoutParams bParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT); |
|
| 78 |
bParams.setMargins(margin, margin, margin, margin); |
|
| 79 |
|
|
| 80 |
final RubikActivity ract = (RubikActivity)getContext(); |
|
| 81 |
|
|
| 82 |
for(String category: categories) |
|
| 83 |
{
|
|
| 84 |
Button button = new Button(act); |
|
| 85 |
button.setLayoutParams(bParams); |
|
| 86 |
button.setText(category); |
|
| 87 |
|
|
| 88 |
button.setOnClickListener( new View.OnClickListener() |
|
| 89 |
{
|
|
| 90 |
@Override |
|
| 91 |
public void onClick(View view) |
|
| 92 |
{
|
|
| 93 |
RubikState.switchState(ract,RubikState.PATT); |
|
| 94 |
mDialog.dismiss(); |
|
| 95 |
} |
|
| 96 |
}); |
|
| 97 |
|
|
| 98 |
mLayout.addView(button); |
|
| 99 |
} |
|
| 100 |
} |
|
| 101 |
} |
|
| src/main/java/org/distorted/dialog/RubikDialogSetName.java | ||
|---|---|---|
| 122 | 122 |
RubikStatePlay play = (RubikStatePlay) RubikState.PLAY.getStateClass(); |
| 123 | 123 |
int object = play.getObject(); |
| 124 | 124 |
int size = play.getSize(); |
| 125 |
int sizeIndex = RubikObjectList.getSizeIndex(object,size); |
|
| 125 | 126 |
|
| 126 | 127 |
Bundle bundle = new Bundle(); |
| 127 |
bundle.putInt("tab", RubikObjectList.pack(object,size) );
|
|
| 128 |
bundle.putInt("tab", RubikObjectList.pack(object,sizeIndex) );
|
|
| 128 | 129 |
bundle.putBoolean("submitting", true);
|
| 129 | 130 |
|
| 130 | 131 |
RubikDialogScores scores = new RubikDialogScores(); |
| src/main/java/org/distorted/magic/RubikActivity.java | ||
|---|---|---|
| 26 | 26 |
import android.view.View; |
| 27 | 27 |
|
| 28 | 28 |
import org.distorted.dialog.RubikDialogAbout; |
| 29 |
import org.distorted.dialog.RubikDialogPattern; |
|
| 30 | 29 |
import org.distorted.dialog.RubikDialogScores; |
| 31 | 30 |
import org.distorted.dialog.RubikDialogEffects; |
| 32 | 31 |
import org.distorted.effect.BaseEffect; |
| ... | ... | |
| 88 | 87 |
scores.setCountry(this); |
| 89 | 88 |
} |
| 90 | 89 |
|
| 90 |
boolean success = false; |
|
| 91 | 91 |
RubikStatePlay play = (RubikStatePlay)RubikState.PLAY.getStateClass(); |
| 92 | 92 |
int object = play.getObject(); |
| 93 | 93 |
int size = play.getSize(); |
| ... | ... | |
| 96 | 96 |
{
|
| 97 | 97 |
RubikObjectList obj = RubikObjectList.getObject(object); |
| 98 | 98 |
int[] sizes = obj.getSizes(); |
| 99 |
int sizeIndex = RubikObjectList.getSizeIndex(object,size); |
|
| 99 | 100 |
|
| 100 |
if( size>=0 && size<sizes.length )
|
|
| 101 |
if( sizeIndex>=0 && sizeIndex<sizes.length )
|
|
| 101 | 102 |
{
|
| 102 |
view.getRenderer().createObject( obj, sizes[size] ); |
|
| 103 |
success = true; |
|
| 104 |
view.getRenderer().createObject( obj, size ); |
|
| 103 | 105 |
} |
| 106 |
|
|
| 107 |
} |
|
| 108 |
|
|
| 109 |
if( !success ) |
|
| 110 |
{
|
|
| 111 |
RubikObjectList obj = RubikObjectList.getObject(RubikStatePlay.DEF_OBJECT); |
|
| 112 |
int s = RubikStatePlay.DEF_SIZE; |
|
| 113 |
|
|
| 114 |
play.setObjectAndSize(obj,s); |
|
| 115 |
view.getRenderer().createObject(obj,s); |
|
| 104 | 116 |
} |
| 105 | 117 |
} |
| 106 | 118 |
|
| ... | ... | |
| 163 | 175 |
// PUBLIC API |
| 164 | 176 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 165 | 177 |
|
| 166 |
public void setCanRotate(boolean can)
|
|
| 178 |
public void changeObject(RubikObjectList object, int size)
|
|
| 167 | 179 |
{
|
| 168 | 180 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
| 169 | 181 |
RubikRenderer renderer = view.getRenderer(); |
| 170 | 182 |
|
| 171 |
renderer.setCanRotate(can); |
|
| 172 |
} |
|
| 173 |
|
|
| 174 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 175 |
|
|
| 176 |
public void changeObject(int object, int size) |
|
| 177 |
{
|
|
| 178 |
RubikObjectList obj = RubikObjectList.getObject(object); |
|
| 179 |
int objectSize = obj.getSizes()[size]; |
|
| 180 |
|
|
| 181 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
|
| 182 |
RubikRenderer renderer = view.getRenderer(); |
|
| 183 |
|
|
| 184 | 183 |
if( renderer.canDrag() ) |
| 185 | 184 |
{
|
| 186 |
renderer.createObject(obj,objectSize);
|
|
| 185 |
renderer.createObject(object,size);
|
|
| 187 | 186 |
} |
| 188 | 187 |
} |
| 189 | 188 |
|
| ... | ... | |
| 217 | 216 |
RubikStatePlay play = (RubikStatePlay) RubikState.PLAY.getStateClass(); |
| 218 | 217 |
int object = play.getObject(); |
| 219 | 218 |
int size = play.getSize(); |
| 219 |
int sizeIndex = RubikObjectList.getSizeIndex(object,size); |
|
| 220 | 220 |
|
| 221 | 221 |
Bundle bundle = new Bundle(); |
| 222 |
bundle.putInt("tab", RubikObjectList.pack(object,size) );
|
|
| 222 |
bundle.putInt("tab", RubikObjectList.pack(object,sizeIndex) );
|
|
| 223 | 223 |
bundle.putBoolean("submitting", false);
|
| 224 | 224 |
|
| 225 | 225 |
RubikDialogScores scores = new RubikDialogScores(); |
| ... | ... | |
| 231 | 231 |
|
| 232 | 232 |
public void Patterns(View v) |
| 233 | 233 |
{
|
| 234 |
RubikDialogPattern diag = new RubikDialogPattern(); |
|
| 235 |
diag.show(getSupportFragmentManager(), null); |
|
| 234 |
RubikState.switchState(this,RubikState.PATT); |
|
| 236 | 235 |
} |
| 237 | 236 |
|
| 238 | 237 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/magic/RubikRenderer.java | ||
|---|---|---|
| 161 | 161 |
|
| 162 | 162 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 163 | 163 |
|
| 164 |
boolean createObject(RubikObjectList object, int size)
|
|
| 164 |
void createObject(RubikObjectList object, int size)
|
|
| 165 | 165 |
{
|
| 166 | 166 |
if( (object!=mNextObject || mNextSize!=size) && size>0 ) |
| 167 | 167 |
{
|
| 168 | 168 |
mChangeObject = true; |
| 169 | 169 |
mNextObject = object; |
| 170 | 170 |
mNextSize = size; |
| 171 |
return true; |
|
| 172 | 171 |
} |
| 173 |
|
|
| 174 |
return false; |
|
| 175 | 172 |
} |
| 176 | 173 |
|
| 177 | 174 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/magic/RubikSurfaceView.java | ||
|---|---|---|
| 162 | 162 |
|
| 163 | 163 |
private void setUpDragOrRotate(float x, float y) |
| 164 | 164 |
{
|
| 165 |
boolean rota = mRenderer.canRotate(); |
|
| 166 |
boolean drag = mRenderer.canDrag(); |
|
| 167 |
|
|
| 168 |
if( !rota && drag ) |
|
| 165 |
if( !RubikState.canRotate() ) |
|
| 169 | 166 |
{
|
| 170 | 167 |
mDragging = true; |
| 171 | 168 |
mBeginningRotation = false; |
| ... | ... | |
| 180 | 177 |
if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint1,rotatedCamera) ) |
| 181 | 178 |
{
|
| 182 | 179 |
mDragging = false; |
| 183 |
mBeginningRotation = rota;
|
|
| 180 |
mBeginningRotation = mRenderer.canRotate();
|
|
| 184 | 181 |
mContinuingRotation = false; |
| 185 | 182 |
} |
| 186 | 183 |
else |
| 187 | 184 |
{
|
| 188 |
mDragging = drag;
|
|
| 185 |
mDragging = mRenderer.canDrag();
|
|
| 189 | 186 |
mBeginningRotation = false; |
| 190 | 187 |
mContinuingRotation = false; |
| 191 | 188 |
} |
| src/main/java/org/distorted/object/RubikObjectList.java | ||
|---|---|---|
| 141 | 141 |
{
|
| 142 | 142 |
if( objects[i].name().equals(name) ) |
| 143 | 143 |
{
|
| 144 |
int s = getSize(i,size);
|
|
| 145 |
return pack(i,s); |
|
| 144 |
int sizeIndex = getSizeIndex(i,size);
|
|
| 145 |
return pack(i,sizeIndex);
|
|
| 146 | 146 |
} |
| 147 | 147 |
} |
| 148 | 148 |
} |
| ... | ... | |
| 198 | 198 |
|
| 199 | 199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 200 | 200 |
|
| 201 |
public static int getSize(int ordinal, int size) |
|
| 201 |
public static int getSizeIndex(int ordinal, int size)
|
|
| 202 | 202 |
{
|
| 203 | 203 |
int[] sizes = objects[ordinal].getSizes(); |
| 204 | 204 |
int len = sizes.length; |
| src/main/java/org/distorted/patterns/RubikPattern.java | ||
|---|---|---|
| 26 | 26 |
|
| 27 | 27 |
public class RubikPattern |
| 28 | 28 |
{
|
| 29 |
private static final int MIN_CUBE = 2;
|
|
| 30 |
private static final int MAX_CUBE = 5;
|
|
| 31 |
public static final int NUM_CUBES = MAX_CUBE-MIN_CUBE+1;
|
|
| 29 |
public static final int MIN_CUBE = 2;
|
|
| 30 |
public static final int MAX_CUBE = 5;
|
|
| 31 |
public static final int NUM_CUBES = MAX_CUBE-MIN_CUBE+1; |
|
| 32 | 32 |
|
| 33 | 33 |
private int[] numCategories = new int[NUM_CUBES]; |
| 34 | 34 |
private static String buffer=""; |
| src/main/java/org/distorted/scores/RubikScores.java | ||
|---|---|---|
| 199 | 199 |
{
|
| 200 | 200 |
String recordStr, subStr, nameStr, sizeStr, timeStr, submStr; |
| 201 | 201 |
int start, end, equals, underscore, comma; |
| 202 |
int object, size, subm; |
|
| 202 |
int object, sizeIndex, subm;
|
|
| 203 | 203 |
long time; |
| 204 | 204 |
|
| 205 | 205 |
for(int scramble=0; scramble<MAX_SCRAMBLE; scramble++) |
| ... | ... | |
| 231 | 231 |
|
| 232 | 232 |
if( object>=0 && object< NUM_OBJECTS ) |
| 233 | 233 |
{
|
| 234 |
size = RubikObjectList.getSize(object,Integer.parseInt(sizeStr));
|
|
| 234 |
sizeIndex = RubikObjectList.getSizeIndex(object,Integer.parseInt(sizeStr));
|
|
| 235 | 235 |
time = Long.parseLong(timeStr); |
| 236 | 236 |
subm = Integer.parseInt(submStr); |
| 237 | 237 |
|
| 238 |
if( size>=0 && size<MAX_SIZE && subm>=0 && subm<=1 )
|
|
| 238 |
if( sizeIndex>=0 && sizeIndex<MAX_SIZE && subm>=0 && subm<=1 )
|
|
| 239 | 239 |
{
|
| 240 |
mRecords [object][size][scramble] = time; |
|
| 241 |
mSubmitted[object][size][scramble] = subm; |
|
| 240 |
mRecords [object][sizeIndex][scramble] = time;
|
|
| 241 |
mSubmitted[object][sizeIndex][scramble] = subm;
|
|
| 242 | 242 |
} |
| 243 | 243 |
else |
| 244 | 244 |
{
|
| 245 |
android.util.Log.e("solv", "error: size="+size+" subm="+subm);
|
|
| 245 |
android.util.Log.e("solv", "error: size="+sizeIndex+" subm="+subm);
|
|
| 246 | 246 |
} |
| 247 | 247 |
} |
| 248 | 248 |
else |
| src/main/java/org/distorted/uistate/RubikState.java | ||
|---|---|---|
| 26 | 26 |
|
| 27 | 27 |
public enum RubikState |
| 28 | 28 |
{
|
| 29 |
MAIN ( null , new RubikStateMain() ), |
|
| 30 |
PLAY ( MAIN , new RubikStatePlay() ), |
|
| 31 |
SOLV ( PLAY , new RubikStateSolving() ), |
|
| 32 |
PATT ( MAIN , new RubikStatePattern() ), |
|
| 29 |
MAIN ( null , true , new RubikStateMain() ),
|
|
| 30 |
PLAY ( MAIN , true , new RubikStatePlay() ),
|
|
| 31 |
SOLV ( PLAY , true , new RubikStateSolving() ),
|
|
| 32 |
PATT ( MAIN , false, new RubikStatePattern() ),
|
|
| 33 | 33 |
; |
| 34 | 34 |
|
| 35 | 35 |
public static final int LENGTH = values().length; |
| 36 | 36 |
private final RubikState mBack; |
| 37 |
private boolean mCanRotate; |
|
| 37 | 38 |
private final RubikStateAbstract mClass; |
| 38 | 39 |
private static final RubikState[] sizes; |
| 39 | 40 |
|
| ... | ... | |
| 65 | 66 |
return mCurrState; |
| 66 | 67 |
} |
| 67 | 68 |
|
| 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 70 |
|
|
| 71 |
public static boolean canRotate() |
|
| 72 |
{
|
|
| 73 |
return mCurrState.mCanRotate; |
|
| 74 |
} |
|
| 75 |
|
|
| 68 | 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 69 | 77 |
|
| 70 | 78 |
public static void savePreferences(SharedPreferences.Editor editor) |
| ... | ... | |
| 112 | 120 |
|
| 113 | 121 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 114 | 122 |
|
| 115 |
RubikState(RubikState back, RubikStateAbstract clazz) |
|
| 123 |
RubikState(RubikState back, boolean canRotate, RubikStateAbstract clazz)
|
|
| 116 | 124 |
{
|
| 117 |
mBack = back; |
|
| 118 |
mClass = clazz; |
|
| 125 |
mBack = back; |
|
| 126 |
mCanRotate = canRotate; |
|
| 127 |
mClass = clazz; |
|
| 119 | 128 |
} |
| 120 | 129 |
|
| 121 | 130 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/uistate/RubikStatePattern.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.uistate; |
| 21 | 21 |
|
| 22 |
import android.content.Context; |
|
| 22 | 23 |
import android.content.SharedPreferences; |
| 23 |
import android.support.v4.app.FragmentManager;
|
|
| 24 |
import android.graphics.drawable.BitmapDrawable;
|
|
| 24 | 25 |
import android.util.DisplayMetrics; |
| 26 |
import android.view.Gravity; |
|
| 25 | 27 |
import android.view.LayoutInflater; |
| 26 | 28 |
import android.view.View; |
| 27 | 29 |
import android.widget.Button; |
| 30 |
import android.widget.ImageButton; |
|
| 28 | 31 |
import android.widget.LinearLayout; |
| 32 |
import android.widget.PopupWindow; |
|
| 29 | 33 |
import android.widget.TextView; |
| 30 | 34 |
|
| 31 |
import org.distorted.dialog.RubikDialogPattern; |
|
| 32 | 35 |
import org.distorted.magic.R; |
| 33 | 36 |
import org.distorted.magic.RubikActivity; |
| 37 |
import org.distorted.object.RubikObjectList; |
|
| 38 |
import org.distorted.patterns.RubikPattern; |
|
| 34 | 39 |
|
| 35 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 36 | 41 |
|
| 37 | 42 |
public class RubikStatePattern extends RubikStateAbstract |
| 38 | 43 |
{
|
| 39 |
private TextView mText; |
|
| 44 |
private ImageButton mObjButton; |
|
| 45 |
private Button mBackButton; |
|
| 46 |
private PopupWindow mPopup; |
|
| 47 |
private int mLayoutWidth, mLayoutHeight; |
|
| 48 |
private LinearLayout mLayout; |
|
| 49 |
private int mSize; |
|
| 40 | 50 |
|
| 41 | 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 42 | 52 |
|
| ... | ... | |
| 49 | 59 |
|
| 50 | 60 |
void leaveState(RubikActivity act) |
| 51 | 61 |
{
|
| 52 |
act.setCanRotate(true); |
|
| 62 |
RubikStatePlay play = (RubikStatePlay)RubikState.PLAY.getStateClass(); |
|
| 63 |
|
|
| 64 |
if( !play.setObjectAndSize(RubikObjectList.CUBE, mSize) ) |
|
| 65 |
{
|
|
| 66 |
int object= play.getObject(); |
|
| 67 |
int size = play.getSize(); |
|
| 68 |
|
|
| 69 |
act.changeObject(RubikObjectList.getObject(object),size); |
|
| 70 |
} |
|
| 53 | 71 |
} |
| 54 | 72 |
|
| 55 | 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 56 | 74 |
|
| 57 | 75 |
void enterState(final RubikActivity act) |
| 58 | 76 |
{
|
| 59 |
act.setCanRotate(false); |
|
| 77 |
RubikStatePlay play = (RubikStatePlay)RubikState.PLAY.getStateClass(); |
|
| 78 |
int obj = play.getObject(); |
|
| 79 |
int size = play.getSize(); |
|
| 80 |
|
|
| 81 |
if( size>=RubikPattern.MIN_CUBE && size<=RubikPattern.MAX_CUBE && obj==RubikObjectList.CUBE.ordinal() ) |
|
| 82 |
{
|
|
| 83 |
mSize = size; |
|
| 84 |
} |
|
| 85 |
else |
|
| 86 |
{
|
|
| 87 |
mSize = RubikStatePlay.DEF_SIZE; |
|
| 88 |
act.changeObject(RubikObjectList.CUBE,mSize); |
|
| 89 |
} |
|
| 60 | 90 |
|
| 61 | 91 |
LayoutInflater inflater = act.getLayoutInflater(); |
| 62 | 92 |
|
| 63 | 93 |
// TOP //////////////////////////// |
| 64 | 94 |
LinearLayout layoutTop = act.findViewById(R.id.mainTitle); |
| 65 | 95 |
layoutTop.removeAllViews(); |
| 66 |
mText = (TextView)inflater.inflate(R.layout.upper_text, null);
|
|
| 67 |
mText.setText(R.string.patterns);
|
|
| 68 |
layoutTop.addView(mText);
|
|
| 96 |
TextView text = (TextView)inflater.inflate(R.layout.upper_text, null);
|
|
| 97 |
text.setText(R.string.patterns);
|
|
| 98 |
layoutTop.addView(text);
|
|
| 69 | 99 |
|
| 70 | 100 |
// BOT //////////////////////////// |
| 101 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
|
| 102 |
final float scale = metrics.density; |
|
| 103 |
|
|
| 104 |
if( mObjButton==null ) setupObjectButton(act,scale); |
|
| 105 |
|
|
| 71 | 106 |
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft); |
| 72 | 107 |
layoutLeft.removeAllViews(); |
| 108 |
layoutLeft.addView(mObjButton); |
|
| 109 |
|
|
| 110 |
if( mBackButton==null ) setupBackButton(act,scale); |
|
| 111 |
|
|
| 73 | 112 |
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight); |
| 74 | 113 |
layoutRight.removeAllViews(); |
| 114 |
layoutRight.addView(mBackButton); |
|
| 75 | 115 |
|
| 76 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
|
| 77 |
float scale = metrics.density; |
|
| 78 |
int padding = (int)(5*scale + 0.5f); |
|
| 79 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
| 116 |
if( mPopup==null ) setupPopupWindow(act, scale); |
|
| 117 |
} |
|
| 80 | 118 |
|
| 81 |
Button button = new Button(act); |
|
| 82 |
button.setLayoutParams(params); |
|
| 83 |
button.setId(BUTTON_ID_BACK); |
|
| 84 |
button.setPadding(padding,0,padding,0); |
|
| 85 |
button.setText(R.string.back); |
|
| 119 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 86 | 120 |
|
| 87 |
button.setOnClickListener( new View.OnClickListener() |
|
| 121 |
private void setupObjectButton(final RubikActivity act, final float scale) |
|
| 122 |
{
|
|
| 123 |
int padding = (int)(3*scale + 0.5f); |
|
| 124 |
LinearLayout.LayoutParams objectParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
| 125 |
mObjButton = new ImageButton(act); |
|
| 126 |
mObjButton.setLayoutParams(objectParams); |
|
| 127 |
mObjButton.setPadding(padding,0,padding,0); |
|
| 128 |
mObjButton.setImageResource(R.drawable.cube_menu); |
|
| 129 |
|
|
| 130 |
mObjButton.setOnClickListener( new View.OnClickListener() |
|
| 131 |
{
|
|
| 132 |
@Override |
|
| 133 |
public void onClick(View view) |
|
| 134 |
{
|
|
| 135 |
int total = RubikPattern.NUM_CUBES; |
|
| 136 |
boolean vertical = act.isVertical(); |
|
| 137 |
mLayout.setOrientation(vertical ? LinearLayout.VERTICAL:LinearLayout.HORIZONTAL); |
|
| 138 |
|
|
| 139 |
int height = view.getHeight(); |
|
| 140 |
int width = view.getWidth(); |
|
| 141 |
int laywid = mLayoutWidth * (vertical? 1:total); |
|
| 142 |
int layhei = mLayoutHeight* (vertical? total:1); |
|
| 143 |
|
|
| 144 |
mPopup.showAsDropDown(view, (width-laywid)/2, -height-layhei, Gravity.LEFT); |
|
| 145 |
} |
|
| 146 |
}); |
|
| 147 |
} |
|
| 148 |
|
|
| 149 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 150 |
|
|
| 151 |
private void setupBackButton(final RubikActivity act, final float scale) |
|
| 152 |
{
|
|
| 153 |
int padding = (int)(3*scale + 0.5f); |
|
| 154 |
LinearLayout.LayoutParams backParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
| 155 |
mBackButton = new Button(act); |
|
| 156 |
mBackButton.setLayoutParams(backParams); |
|
| 157 |
mBackButton.setId(BUTTON_ID_BACK); |
|
| 158 |
mBackButton.setPadding(padding,0,padding,0); |
|
| 159 |
mBackButton.setText(R.string.back); |
|
| 160 |
|
|
| 161 |
mBackButton.setOnClickListener( new View.OnClickListener() |
|
| 88 | 162 |
{
|
| 89 | 163 |
@Override |
| 90 | 164 |
public void onClick(View v) |
| 91 | 165 |
{
|
| 92 | 166 |
RubikState.goBack(act); |
| 93 |
|
|
| 94 |
FragmentManager mana = act.getSupportFragmentManager(); |
|
| 95 |
RubikDialogPattern diag = new RubikDialogPattern(); |
|
| 96 |
diag.show( mana, RubikDialogPattern.getDialogTag() ); |
|
| 97 | 167 |
} |
| 98 | 168 |
}); |
| 169 |
} |
|
| 170 |
|
|
| 171 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 172 |
|
|
| 173 |
private void setupPopupWindow(final RubikActivity act, final float scale) |
|
| 174 |
{
|
|
| 175 |
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
|
| 176 |
final View layout = layoutInflater.inflate(R.layout.popup_objects, null); |
|
| 177 |
mLayout = layout.findViewById(R.id.popup); |
|
| 99 | 178 |
|
| 100 |
layoutRight.addView(button); |
|
| 179 |
mPopup = new PopupWindow(act); |
|
| 180 |
mPopup.setContentView(layout); |
|
| 181 |
mPopup.setFocusable(true); |
|
| 182 |
int margin = (int)(5*scale + 0.5f); |
|
| 183 |
|
|
| 184 |
BitmapDrawable bd = (BitmapDrawable) act.getResources().getDrawable(R.drawable.cube2); |
|
| 185 |
int cubeWidth = bd.getIntrinsicWidth(); |
|
| 186 |
int cubeHeight = bd.getIntrinsicHeight(); |
|
| 187 |
|
|
| 188 |
mLayoutWidth = (int)(cubeWidth + 2*margin + 0.5f); |
|
| 189 |
mLayoutHeight= (int)(cubeHeight+ 2*margin + 0.5f); |
|
| 190 |
|
|
| 191 |
final int[] icons = {R.drawable.cube2, R.drawable.cube3, R.drawable.cube4, R.drawable.cube5 };
|
|
| 192 |
final int[] sizes = {2,3,4,5};
|
|
| 193 |
int len = icons.length; |
|
| 194 |
|
|
| 195 |
for(int i=0; i<len; i++) |
|
| 196 |
{
|
|
| 197 |
final int size = i; |
|
| 198 |
|
|
| 199 |
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); |
|
| 200 |
p.setMargins(margin, margin, margin, margin); |
|
| 201 |
|
|
| 202 |
ImageButton button = new ImageButton(act); |
|
| 203 |
button.setLayoutParams(p); |
|
| 204 |
|
|
| 205 |
button.setBackgroundResource(icons[i]); |
|
| 206 |
button.setOnClickListener( new View.OnClickListener() |
|
| 207 |
{
|
|
| 208 |
@Override |
|
| 209 |
public void onClick(View v) |
|
| 210 |
{
|
|
| 211 |
mSize = sizes[size]; |
|
| 212 |
act.changeObject(RubikObjectList.CUBE,sizes[size]); |
|
| 213 |
mPopup.dismiss(); |
|
| 214 |
} |
|
| 215 |
}); |
|
| 216 |
|
|
| 217 |
mLayout.addView(button); |
|
| 218 |
} |
|
| 101 | 219 |
} |
| 102 | 220 |
|
| 103 | 221 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 104 | 222 |
|
| 105 | 223 |
public void savePreferences(SharedPreferences.Editor editor) |
| 106 | 224 |
{
|
| 225 |
mObjButton = null; |
|
| 226 |
mBackButton= null; |
|
| 107 | 227 |
|
| 228 |
if( mPopup!=null ) |
|
| 229 |
{
|
|
| 230 |
mPopup.dismiss(); |
|
| 231 |
mPopup = null; |
|
| 232 |
} |
|
| 108 | 233 |
} |
| 109 | 234 |
|
| 110 | 235 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/uistate/RubikStatePlay.java | ||
|---|---|---|
| 43 | 43 |
private static final int MIN_SCRAMBLE = 1; |
| 44 | 44 |
private static final int DEF_SCRAMBLE = 1; |
| 45 | 45 |
public static final int MAX_SCRAMBLE = 18; |
| 46 |
private static final int DEF_OBJECT = RubikObjectList.CUBE.ordinal();
|
|
| 47 |
private static final int DEF_SIZE = 1; // i.e. the second from the list of CUBE's sizes
|
|
| 46 |
public static final int DEF_OBJECT = RubikObjectList.CUBE.ordinal();
|
|
| 47 |
public static final int DEF_SIZE = 3;
|
|
| 48 | 48 |
|
| 49 | 49 |
private ImageButton mObjButton; |
| 50 | 50 |
private Button mBackButton; |
| ... | ... | |
| 174 | 174 |
|
| 175 | 175 |
for(int object=0; object<RubikObjectList.NUM_OBJECTS; object++) |
| 176 | 176 |
{
|
| 177 |
RubikObjectList list = RubikObjectList.getObject(object); |
|
| 178 |
int[] sizes = list.getSizes(); |
|
| 177 |
final RubikObjectList list = RubikObjectList.getObject(object);
|
|
| 178 |
final int[] sizes = list.getSizes();
|
|
| 179 | 179 |
int[] icons = list.getIconIDs(); |
| 180 | 180 |
int len = sizes.length; |
| 181 | 181 |
final int obj = object; |
| ... | ... | |
| 197 | 197 |
public void onClick(View v) |
| 198 | 198 |
{
|
| 199 | 199 |
mObject = obj; |
| 200 |
mSize = size; |
|
| 201 |
act.changeObject(obj,size);
|
|
| 200 |
mSize = sizes[size];
|
|
| 201 |
act.changeObject(list,sizes[size]);
|
|
| 202 | 202 |
mPopup.dismiss(); |
| 203 | 203 |
} |
| 204 | 204 |
}); |
| ... | ... | |
| 226 | 226 |
if( mPopup!=null ) |
| 227 | 227 |
{
|
| 228 | 228 |
mPopup.dismiss(); |
| 229 |
mPopup = null;
|
|
| 229 |
mPopup = null; |
|
| 230 | 230 |
} |
| 231 | 231 |
} |
| 232 | 232 |
|
| ... | ... | |
| 239 | 239 |
mSize = preferences.getInt("statePlay_size" , DEF_SIZE );
|
| 240 | 240 |
} |
| 241 | 241 |
|
| 242 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 243 |
|
|
| 244 |
public boolean setObjectAndSize(RubikObjectList obj, int size) |
|
| 245 |
{
|
|
| 246 |
boolean success = false; |
|
| 247 |
|
|
| 248 |
for( int s: obj.getSizes() ) |
|
| 249 |
if( s==size ) |
|
| 250 |
{
|
|
| 251 |
success = true; |
|
| 252 |
break; |
|
| 253 |
} |
|
| 254 |
|
|
| 255 |
if( success ) |
|
| 256 |
{
|
|
| 257 |
mObject = obj.ordinal(); |
|
| 258 |
mSize = size; |
|
| 259 |
} |
|
| 260 |
|
|
| 261 |
return success; |
|
| 262 |
} |
|
| 263 |
|
|
| 242 | 264 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 243 | 265 |
|
| 244 | 266 |
public int getPicker() |
| src/main/java/org/distorted/uistate/RubikStateSolving.java | ||
|---|---|---|
| 29 | 29 |
|
| 30 | 30 |
import org.distorted.magic.R; |
| 31 | 31 |
import org.distorted.magic.RubikActivity; |
| 32 |
import org.distorted.object.RubikObjectList; |
|
| 32 | 33 |
import org.distorted.scores.RubikScores; |
| 33 | 34 |
|
| 34 | 35 |
import java.util.Timer; |
| ... | ... | |
| 173 | 174 |
int object = play.getObject(); |
| 174 | 175 |
int size = play.getSize(); |
| 175 | 176 |
int scramble= play.getPicker(); |
| 177 |
int realSize= RubikObjectList.getSizeIndex(object,size); |
|
| 176 | 178 |
|
| 177 |
boolean isNew = mScores.setRecord(object, size, scramble, timeTaken);
|
|
| 179 |
boolean isNew = mScores.setRecord(object, realSize, scramble, timeTaken);
|
|
| 178 | 180 |
|
| 179 | 181 |
return isNew ? timeTaken : -timeTaken; |
| 180 | 182 |
} |
Also available in: Unified diff
Progress with Pretty Patterns - do away with the tabbed dialog!