Revision adbd16d9
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/dialogs/RubikDialogFreePlaySettings.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.dialogs; |
|
21 |
|
|
22 |
import android.app.Dialog; |
|
23 |
import android.content.DialogInterface; |
|
24 |
import android.os.Bundle; |
|
25 |
import android.util.DisplayMetrics; |
|
26 |
import android.util.TypedValue; |
|
27 |
import android.view.LayoutInflater; |
|
28 |
import android.view.View; |
|
29 |
import android.view.Window; |
|
30 |
import android.widget.AdapterView; |
|
31 |
import android.widget.ArrayAdapter; |
|
32 |
import android.widget.Button; |
|
33 |
import android.widget.Spinner; |
|
34 |
import android.widget.TextView; |
|
35 |
|
|
36 |
import androidx.annotation.NonNull; |
|
37 |
import androidx.appcompat.app.AlertDialog; |
|
38 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
39 |
import androidx.fragment.app.FragmentActivity; |
|
40 |
|
|
41 |
import org.distorted.main.RubikActivity; |
|
42 |
import org.distorted.screens.RubikScreenFreePlay; |
|
43 |
import org.distorted.main.R; |
|
44 |
import org.distorted.screens.ScreenList; |
|
45 |
|
|
46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
47 |
|
|
48 |
public class RubikDialogFreePlaySettings extends AppCompatDialogFragment implements AdapterView.OnItemSelectedListener |
|
49 |
{ |
|
50 |
private int mAnimPos, mScraPos; |
|
51 |
private float mTextSize; |
|
52 |
|
|
53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
54 |
|
|
55 |
private String[] createScrambleModes() |
|
56 |
{ |
|
57 |
int len = RubikScreenFreePlay.DEPTHS.length; |
|
58 |
String[] ret = new String[len]; |
|
59 |
|
|
60 |
for(int i=0; i<len; i++) |
|
61 |
{ |
|
62 |
ret[i] = String.valueOf(RubikScreenFreePlay.DEPTHS[i]); |
|
63 |
} |
|
64 |
|
|
65 |
return ret; |
|
66 |
} |
|
67 |
|
|
68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
69 |
|
|
70 |
private void configureView(FragmentActivity act, View view, float textSize, int scraPos, int animPos) |
|
71 |
{ |
|
72 |
TextView text1 = view.findViewById(R.id.bandaged_text_depth); |
|
73 |
text1.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
74 |
TextView text2 = view.findViewById(R.id.bandaged_text_animation); |
|
75 |
text2.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); |
|
76 |
|
|
77 |
mScraPos = scraPos; |
|
78 |
mAnimPos = animPos; |
|
79 |
|
|
80 |
Spinner scramble = view.findViewById(R.id.bandaged_spinner_scramble); |
|
81 |
scramble.setOnItemSelectedListener(this); |
|
82 |
String[] scrambleModes = createScrambleModes(); |
|
83 |
|
|
84 |
ArrayAdapter<String> scrambleAdapter = new ArrayAdapter<>(act, R.layout.spinner_item, scrambleModes ); |
|
85 |
scrambleAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
86 |
scramble.setAdapter(scrambleAdapter); |
|
87 |
scramble.setSelection(mScraPos); |
|
88 |
|
|
89 |
Spinner animation = view.findViewById(R.id.bandaged_spinner_animation); |
|
90 |
animation.setOnItemSelectedListener(this); |
|
91 |
String[] animationModes = { "ON" , "OFF" }; |
|
92 |
|
|
93 |
ArrayAdapter<String> animationAdapter = new ArrayAdapter<>(act, R.layout.spinner_item, animationModes ); |
|
94 |
animationAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
95 |
animation.setAdapter(animationAdapter); |
|
96 |
animation.setSelection(mAnimPos); |
|
97 |
} |
|
98 |
|
|
99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
100 |
|
|
101 |
@Override |
|
102 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
|
103 |
{ |
|
104 |
int spinnerID = parent.getId(); |
|
105 |
|
|
106 |
((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,mTextSize); |
|
107 |
|
|
108 |
if( spinnerID == R.id.bandaged_spinner_scramble ) |
|
109 |
{ |
|
110 |
mScraPos = pos; |
|
111 |
} |
|
112 |
else if( spinnerID == R.id.bandaged_spinner_animation ) |
|
113 |
{ |
|
114 |
mAnimPos = pos; |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
119 |
|
|
120 |
@Override |
|
121 |
public void onNothingSelected(AdapterView<?> parent) { } |
|
122 |
|
|
123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
124 |
|
|
125 |
@NonNull |
|
126 |
@Override |
|
127 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
128 |
{ |
|
129 |
FragmentActivity act = getActivity(); |
|
130 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
131 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
132 |
|
|
133 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
134 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
135 |
final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
136 |
final float okSize = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE; |
|
137 |
mTextSize = displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE; |
|
138 |
|
|
139 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
|
140 |
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
141 |
tv.setText(R.string.settings); |
|
142 |
builder.setCustomTitle(tv); |
|
143 |
|
|
144 |
Bundle args = getArguments(); |
|
145 |
int scraPos, animPos; |
|
146 |
|
|
147 |
try |
|
148 |
{ |
|
149 |
scraPos = args.getInt("scraPos"); |
|
150 |
animPos = args.getInt("animPos"); |
|
151 |
} |
|
152 |
catch(Exception e) |
|
153 |
{ |
|
154 |
scraPos = 0; |
|
155 |
animPos = 0; |
|
156 |
} |
|
157 |
|
|
158 |
builder.setCancelable(true); |
|
159 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
|
160 |
{ |
|
161 |
@Override |
|
162 |
public void onClick(DialogInterface dialog, int which) |
|
163 |
{ |
|
164 |
RubikScreenFreePlay free = (RubikScreenFreePlay) ScreenList.FREE.getScreenClass(); |
|
165 |
|
|
166 |
if( free!=null ) |
|
167 |
{ |
|
168 |
free.setScrambleDepth(mScraPos); |
|
169 |
free.setAnimationMode(mAnimPos); |
|
170 |
} |
|
171 |
} |
|
172 |
}); |
|
173 |
|
|
174 |
final View view = inflater.inflate(R.layout.dialog_settings, null); |
|
175 |
configureView(act,view,mTextSize,scraPos,animPos); |
|
176 |
builder.setView(view); |
|
177 |
|
|
178 |
Dialog dialog = builder.create(); |
|
179 |
dialog.setCanceledOnTouchOutside(false); |
|
180 |
Window window = dialog.getWindow(); |
|
181 |
|
|
182 |
if( window!=null ) |
|
183 |
{ |
|
184 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
185 |
} |
|
186 |
|
|
187 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
188 |
{ |
|
189 |
@Override |
|
190 |
public void onShow(DialogInterface dialog) |
|
191 |
{ |
|
192 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
193 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize); |
|
194 |
} |
|
195 |
}); |
|
196 |
|
|
197 |
return dialog; |
|
198 |
} |
|
199 |
} |
src/main/java/org/distorted/main/RubikObjectLibInterface.java | ||
---|---|---|
45 | 45 |
import org.distorted.external.RubikScores; |
46 | 46 |
import org.distorted.objects.RubikObject; |
47 | 47 |
import org.distorted.objects.RubikObjectList; |
48 |
import org.distorted.screens.RubikScreenFreePlay; |
|
48 | 49 |
import org.distorted.screens.RubikScreenPlay; |
49 | 50 |
import org.distorted.screens.RubikScreenReady; |
50 | 51 |
import org.distorted.screens.RubikScreenSolver; |
... | ... | |
264 | 265 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
265 | 266 |
play.addMove(mAct.get(), axis, row, angle); |
266 | 267 |
} |
268 |
if( ScreenList.getCurrentScreen()== ScreenList.FREE ) |
|
269 |
{ |
|
270 |
RubikScreenFreePlay free = (RubikScreenFreePlay) ScreenList.FREE.getScreenClass(); |
|
271 |
free.addMove(mAct.get(), axis, row, angle); |
|
272 |
} |
|
267 | 273 |
} |
268 | 274 |
|
269 | 275 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
308 | 314 |
RubikScreenSolving solv = (RubikScreenSolving) ScreenList.SOLV.getScreenClass(); |
309 | 315 |
solv.reddenLock(mAct.get()); |
310 | 316 |
} |
317 |
else if( curr==ScreenList.FREE ) |
|
318 |
{ |
|
319 |
RubikScreenFreePlay free = (RubikScreenFreePlay) ScreenList.FREE.getScreenClass(); |
|
320 |
free.reddenLock(mAct.get()); |
|
321 |
} |
|
311 | 322 |
} |
312 | 323 |
|
313 | 324 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/screens/RubikScreenFreePlay.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2022 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.screens; |
|
21 |
|
|
22 |
import java.util.Random; |
|
23 |
|
|
24 |
import android.content.SharedPreferences; |
|
25 |
import android.os.Bundle; |
|
26 |
import android.view.View; |
|
27 |
import android.widget.LinearLayout; |
|
28 |
|
|
29 |
import org.distorted.dialogs.RubikDialogFreePlaySettings; |
|
30 |
import org.distorted.helpers.TransparentImageButton; |
|
31 |
import org.distorted.main.R; |
|
32 |
import org.distorted.main.RubikActivity; |
|
33 |
import org.distorted.objectlib.main.ObjectControl; |
|
34 |
import org.distorted.objectlib.main.TwistyObject; |
|
35 |
|
|
36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
37 |
|
|
38 |
public class RubikScreenFreePlay extends RubikScreenBase |
|
39 |
{ |
|
40 |
public static final int[] DEPTHS = new int[] {20,50,100,200,500,1000}; |
|
41 |
public static final int ANIMATION_ON = 0; |
|
42 |
public static final int ANIMATION_OFF = 1; |
|
43 |
|
|
44 |
private TransparentImageButton mBackButton, mScrambleButton, mSolveButton, mSettingsButton; |
|
45 |
private int[][] mMoves; |
|
46 |
private Random mRnd; |
|
47 |
private int mAnimationMode; |
|
48 |
private int mScrambleDepth; |
|
49 |
|
|
50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
51 |
|
|
52 |
void leaveScreen(final RubikActivity act) |
|
53 |
{ |
|
54 |
|
|
55 |
} |
|
56 |
|
|
57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
58 |
|
|
59 |
void enterScreen(final RubikActivity act) |
|
60 |
{ |
|
61 |
int width = act.getScreenWidthInPixels(); |
|
62 |
|
|
63 |
LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT); |
|
64 |
LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT); |
|
65 |
LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT); |
|
66 |
|
|
67 |
// UPPER PANE ///////////// |
|
68 |
|
|
69 |
setupSolveButton(act); |
|
70 |
setupSettingsButton(act); |
|
71 |
setupScrambleButton(act); |
|
72 |
|
|
73 |
LinearLayout layoutUpper = act.findViewById(R.id.upperBar); |
|
74 |
|
|
75 |
LinearLayout layoutLeftU = new LinearLayout(act); |
|
76 |
layoutLeftU.setLayoutParams(paramsL); |
|
77 |
LinearLayout layoutMidU = new LinearLayout(act); |
|
78 |
layoutMidU.setLayoutParams(paramsM); |
|
79 |
LinearLayout layoutRightU= new LinearLayout(act); |
|
80 |
layoutRightU.setLayoutParams(paramsR); |
|
81 |
|
|
82 |
layoutLeftU.addView(mSolveButton); |
|
83 |
layoutMidU.addView(mSettingsButton); |
|
84 |
layoutRightU.addView(mScrambleButton); |
|
85 |
|
|
86 |
layoutUpper.removeAllViews(); |
|
87 |
layoutUpper.addView(layoutLeftU); |
|
88 |
layoutUpper.addView(layoutMidU); |
|
89 |
layoutUpper.addView(layoutRightU); |
|
90 |
|
|
91 |
// LOWER PANE ///////////// |
|
92 |
|
|
93 |
setupBackButton(act); |
|
94 |
createBottomPane(act,mBackButton,null); |
|
95 |
} |
|
96 |
|
|
97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
98 |
|
|
99 |
private void setupBackButton(final RubikActivity act) |
|
100 |
{ |
|
101 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_smallback,R.drawable.ui_medium_smallback, R.drawable.ui_big_smallback, R.drawable.ui_huge_smallback); |
|
102 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
103 |
mBackButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params); |
|
104 |
|
|
105 |
mBackButton.setOnClickListener( new View.OnClickListener() |
|
106 |
{ |
|
107 |
@Override |
|
108 |
public void onClick(View v) |
|
109 |
{ |
|
110 |
ScreenList.goBack(act); |
|
111 |
} |
|
112 |
}); |
|
113 |
} |
|
114 |
|
|
115 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
116 |
|
|
117 |
private void setupSettingsButton(final RubikActivity act) |
|
118 |
{ |
|
119 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_settings,R.drawable.ui_medium_settings, R.drawable.ui_big_settings, R.drawable.ui_huge_settings); |
|
120 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
|
121 |
mSettingsButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params); |
|
122 |
|
|
123 |
mSettingsButton.setOnClickListener( new View.OnClickListener() |
|
124 |
{ |
|
125 |
@Override |
|
126 |
public void onClick(View v) |
|
127 |
{ |
|
128 |
Bundle bundle = new Bundle(); |
|
129 |
bundle.putInt("scraPos", mScrambleDepth ); |
|
130 |
bundle.putInt("animPos", mAnimationMode ); |
|
131 |
|
|
132 |
RubikDialogFreePlaySettings setDiag = new RubikDialogFreePlaySettings(); |
|
133 |
setDiag.setArguments(bundle); |
|
134 |
setDiag.show(act.getSupportFragmentManager(), null); |
|
135 |
} |
|
136 |
}); |
|
137 |
} |
|
138 |
|
|
139 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
140 |
|
|
141 |
private void setupSolveButton(final RubikActivity act) |
|
142 |
{ |
|
143 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_solve,R.drawable.ui_medium_cube_solve, R.drawable.ui_big_cube_solve, R.drawable.ui_huge_cube_solve); |
|
144 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
145 |
mSolveButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE,params); |
|
146 |
|
|
147 |
mSolveButton.setOnClickListener( new View.OnClickListener() |
|
148 |
{ |
|
149 |
@Override |
|
150 |
public void onClick(View v) |
|
151 |
{ |
|
152 |
ObjectControl control = act.getControl(); |
|
153 |
if( mAnimationMode==ANIMATION_OFF ) control.solveOnly(); |
|
154 |
if( mAnimationMode==ANIMATION_ON ) control.solveObject(); |
|
155 |
mMovesController.clearMoves(act); |
|
156 |
} |
|
157 |
}); |
|
158 |
} |
|
159 |
|
|
160 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
161 |
|
|
162 |
private void setupScrambleButton(final RubikActivity act) |
|
163 |
{ |
|
164 |
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_scramble,R.drawable.ui_medium_cube_scramble, R.drawable.ui_big_cube_scramble, R.drawable.ui_huge_cube_scramble); |
|
165 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
166 |
mScrambleButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params); |
|
167 |
|
|
168 |
mScrambleButton.setOnClickListener( new View.OnClickListener() |
|
169 |
{ |
|
170 |
@Override |
|
171 |
public void onClick(View v) |
|
172 |
{ |
|
173 |
ObjectControl control = act.getControl(); |
|
174 |
TwistyObject object = control.getObject(); |
|
175 |
|
|
176 |
int depth = DEPTHS[mScrambleDepth]; |
|
177 |
|
|
178 |
if( mAnimationMode==ANIMATION_OFF ) |
|
179 |
{ |
|
180 |
if( mMoves==null || mMoves.length<depth ) mMoves = new int[depth][3]; |
|
181 |
if( mRnd==null ) mRnd = new Random(); |
|
182 |
|
|
183 |
for(int move=0; move<depth; move++) |
|
184 |
{ |
|
185 |
object.randomizeNewScramble(mMoves, mRnd, move, depth); |
|
186 |
} |
|
187 |
for(int move=0; move<depth; move++) |
|
188 |
{ |
|
189 |
int row = mMoves[move][1]; |
|
190 |
mMoves[move][1] = (1<<row); |
|
191 |
} |
|
192 |
|
|
193 |
control.initializeObject(mMoves); |
|
194 |
} |
|
195 |
|
|
196 |
if( mAnimationMode==ANIMATION_ON ) |
|
197 |
{ |
|
198 |
control.scrambleObject(depth); |
|
199 |
} |
|
200 |
} |
|
201 |
}); |
|
202 |
} |
|
203 |
|
|
204 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
205 |
|
|
206 |
public void savePreferences(SharedPreferences.Editor editor) |
|
207 |
{ |
|
208 |
editor.putInt("freePlayScreen_scramble" , mScrambleDepth); |
|
209 |
editor.putInt("freePlayScreen_animation", mAnimationMode); |
|
210 |
} |
|
211 |
|
|
212 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
213 |
|
|
214 |
public void restorePreferences(SharedPreferences preferences) |
|
215 |
{ |
|
216 |
mScrambleDepth = preferences.getInt("freePlayScreen_scramble" ,3); |
|
217 |
mAnimationMode = preferences.getInt("freePlayScreen_animation",ANIMATION_OFF); |
|
218 |
} |
|
219 |
|
|
220 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
221 |
|
|
222 |
public void setAnimationMode(int mode) |
|
223 |
{ |
|
224 |
mAnimationMode = mode; |
|
225 |
} |
|
226 |
|
|
227 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
228 |
|
|
229 |
public void setScrambleDepth(int depth) |
|
230 |
{ |
|
231 |
mScrambleDepth = depth; |
|
232 |
} |
|
233 |
} |
src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
---|---|---|
64 | 64 |
public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Updatee |
65 | 65 |
{ |
66 | 66 |
public static final int NUM_COLUMNS = 5; |
67 |
public static final int LEVELS_SHOWN = 10;
|
|
67 |
public static final int LEVELS_SHOWN = 8;
|
|
68 | 68 |
|
69 | 69 |
private static final int[] BUTTON_LABELS = { R.string.scores, |
70 | 70 |
R.string.patterns, |
... | ... | |
74 | 74 |
R.string.about }; |
75 | 75 |
private static final int NUM_BUTTONS = BUTTON_LABELS.length; |
76 | 76 |
|
77 |
private static final float LAST_BUTTON = 1.5f;
|
|
77 |
private static final float BIG_BUTTON = 1.5f;
|
|
78 | 78 |
private static final int[] mLocation = new int[2]; |
79 | 79 |
|
80 | 80 |
private TransparentImageButton mObjButton, mMenuButton, mSolveButton, mScrambleButton; |
... | ... | |
194 | 194 |
popupView.setSystemUiVisibility(RubikActivity.FLAGS); |
195 | 195 |
final int object = RubikObjectList.getCurrObject(); |
196 | 196 |
final int dbLevel = RubikObjectList.getDBLevel(object); |
197 |
final int levelsShown = Math.min(dbLevel,LEVELS_SHOWN); |
|
198 |
final int popupHeight = (int)(levelsShown*(mMenuItemSize+margin)+3*margin+mMenuItemSize*(LAST_BUTTON-1.0f));
|
|
197 |
final int levelsShown = Math.min(dbLevel,LEVELS_SHOWN)+1;
|
|
198 |
final int popupHeight = (int)(levelsShown*(mMenuItemSize+margin)+4*margin+2*mMenuItemSize*(BIG_BUTTON-1.0f));
|
|
199 | 199 |
final int realHeight = Math.min(popupHeight,maxHeight); |
200 | 200 |
displayPopup(act,view,mPlayPopup,mPlayLayoutWidth,realHeight,margin,margin); |
201 | 201 |
} |
... | ... | |
237 | 237 |
|
238 | 238 |
private void setupObjectWindow(final RubikActivity act, final float width, final float height) |
239 | 239 |
{ |
240 |
int cubeWidth = (int)(width/9);
|
|
241 |
int margin = (int)(width*RubikActivity.LARGE_MARGIN); |
|
242 |
mObjectSize = (int)(cubeWidth + 2*margin + 0.5f);
|
|
240 |
int cubeSize = (int)(width/9);
|
|
241 |
int margin = (int)(width*RubikActivity.LARGE_MARGIN);
|
|
242 |
mObjectSize = (int)(cubeSize + 2*margin + 0.5f);
|
|
243 | 243 |
mMaxRowCount = (int)((height-1.8f*mUpperBarHeight)/mObjectSize); |
244 | 244 |
|
245 | 245 |
LinearLayout view = (LinearLayout)inflate( act, R.layout.popup_object, null); |
... | ... | |
303 | 303 |
params.leftMargin = margin; |
304 | 304 |
params.rightMargin = margin; |
305 | 305 |
|
306 |
params.width = cubeWidth;
|
|
307 |
params.height= cubeWidth;
|
|
306 |
params.width = cubeSize;
|
|
307 |
params.height= cubeSize;
|
|
308 | 308 |
|
309 | 309 |
nextInRow[row]++; |
310 | 310 |
|
... | ... | |
603 | 603 |
{ |
604 | 604 |
int currObject = RubikObjectList.getCurrObject(); |
605 | 605 |
int dbLevel = RubikObjectList.getDBLevel(currObject); |
606 |
int numLevel= Math.min(dbLevel, LEVELS_SHOWN); |
|
606 |
int numLevel= Math.min(dbLevel, LEVELS_SHOWN)+1;
|
|
607 | 607 |
RubikScores scores = RubikScores.getInstance(); |
608 | 608 |
|
609 | 609 |
for(int i=0; i<numLevel; i++) |
610 | 610 |
{ |
611 |
int level = i<numLevel-1 ? i+1 : dbLevel;
|
|
611 |
int level = i<numLevel-1 ? i : dbLevel; |
|
612 | 612 |
Button button = (Button)mPlayLayout.getChildAt(i); |
613 | 613 |
int icon = scores.isSolved(currObject, level-1) ? R.drawable.ui_solved : R.drawable.ui_notsolved; |
614 | 614 |
button.setCompoundDrawablesWithIntrinsicBounds(icon,0,0,0); |
... | ... | |
624 | 624 |
int dbLevel = RubikObjectList.getDBLevel(currObject); |
625 | 625 |
RubikObject object = RubikObjectList.getObject(currObject); |
626 | 626 |
int numScrambles = object==null ? 0 : object.getNumScramble(); |
627 |
int numLevel = Math.min(dbLevel, LEVELS_SHOWN); |
|
627 |
int numLevel = Math.min(dbLevel, LEVELS_SHOWN)+1;
|
|
628 | 628 |
String[] levels = new String[numLevel]; |
629 | 629 |
|
630 |
for(int i=0; i<numLevel-1; i++) |
|
631 |
{ |
|
632 |
levels[i] = act.getString(R.string.lv_placeholder,i+1); |
|
633 |
} |
|
634 |
|
|
635 |
if( numLevel>0 ) |
|
636 |
{ |
|
637 |
levels[numLevel-1] = act.getString(R.string.level_full); |
|
638 |
} |
|
630 |
levels[0] = act.getString(R.string.free_play); |
|
631 |
for(int i=1; i<numLevel-1; i++) levels[i] = act.getString(R.string.lv_placeholder,i); |
|
632 |
levels[numLevel-1] = act.getString(R.string.level_full); |
|
639 | 633 |
|
640 | 634 |
if( mLevelValue>dbLevel || mLevelValue<1 || |
641 |
(mLevelValue<dbLevel || mLevelValue>LEVELS_SHOWN ) ) |
|
642 |
{ |
|
643 |
mLevelValue=1; |
|
644 |
} |
|
635 |
(mLevelValue<dbLevel || mLevelValue>LEVELS_SHOWN ) ) mLevelValue=1; |
|
645 | 636 |
|
646 | 637 |
float width = act.getScreenWidthInPixels(); |
647 | 638 |
int margin = (int)(width*RubikActivity.SMALL_MARGIN); |
648 | 639 |
int padding = (int)(width*RubikActivity.PADDING); |
649 | 640 |
int butWidth = mPlayLayoutWidth - 2*padding; |
650 | 641 |
int butHeight= (int)mMenuItemSize; |
651 |
int lastButH = (int)(mMenuItemSize*LAST_BUTTON) ;
|
|
642 |
int bigButH = (int)(mMenuItemSize*BIG_BUTTON) ;
|
|
652 | 643 |
|
653 | 644 |
LinearLayout.LayoutParams pM = new LinearLayout.LayoutParams( butWidth, butHeight ); |
654 | 645 |
pM.setMargins(margin, 0, margin, margin); |
655 |
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( butWidth, butHeight ); |
|
656 |
pT.setMargins(margin, margin, margin, margin); |
|
657 |
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( butWidth, lastButH ); |
|
646 |
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( butWidth, bigButH ); |
|
658 | 647 |
pB.setMargins(margin, margin, margin, 2*margin); |
659 | 648 |
|
660 | 649 |
mPlayLayout.removeAllViews(); |
661 | 650 |
|
662 |
RubikScores scores = RubikScores.getInstance(); |
|
663 |
|
|
664 | 651 |
for(int i=0; i<numLevel; i++) |
665 | 652 |
{ |
666 |
final int level = i<numLevel-1 ? i+1 : dbLevel;
|
|
667 |
final int scrambles = i<numLevel-1 ? i+1 : numScrambles;
|
|
653 |
final int level = i<numLevel-1 ? i : dbLevel; |
|
654 |
final int scrambles = i<numLevel-1 ? i : numScrambles; |
|
668 | 655 |
Button button = new Button(act); |
669 |
button.setLayoutParams(i==0 ? pT : (i==numLevel-1 ? pB : pM));
|
|
656 |
button.setLayoutParams(i==0 ? pB : (i==numLevel-1 ? pB : pM));
|
|
670 | 657 |
button.setText(levels[i]); |
671 | 658 |
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize); |
672 | 659 |
|
673 |
int icon = scores.isSolved(currObject, level-1) ? R.drawable.ui_solved : R.drawable.ui_notsolved; |
|
674 |
button.setCompoundDrawablesWithIntrinsicBounds(icon,0,0,0); |
|
675 |
|
|
676 | 660 |
button.setOnClickListener( new View.OnClickListener() |
677 | 661 |
{ |
678 | 662 |
@Override |
... | ... | |
683 | 667 |
if(control.isUINotBlocked()) |
684 | 668 |
{ |
685 | 669 |
if( mPlayPopup!=null ) mPlayPopup.dismiss(); |
686 |
mLevelValue = level; |
|
687 |
mShouldReactToEndOfScrambling = true; |
|
688 |
control.scrambleObject(scrambles); |
|
670 |
|
|
671 |
if( level>0 ) |
|
672 |
{ |
|
673 |
mLevelValue = level; |
|
674 |
mShouldReactToEndOfScrambling = true; |
|
675 |
control.scrambleObject(scrambles); |
|
676 |
} |
|
677 |
else |
|
678 |
{ |
|
679 |
ScreenList.switchScreen(act, ScreenList.FREE); |
|
680 |
} |
|
689 | 681 |
} |
690 | 682 |
} |
691 | 683 |
}); |
src/main/java/org/distorted/screens/ScreenList.java | ||
---|---|---|
38 | 38 |
SOLU ( SVER , MODE_DRAG , new RubikScreenSolution() ), |
39 | 39 |
READ ( PLAY , MODE_ROTATE , new RubikScreenReady() ), |
40 | 40 |
DONE ( PLAY , MODE_DRAG , new RubikScreenDone() ), |
41 |
FREE ( PLAY , MODE_ROTATE , new RubikScreenFreePlay() ), |
|
41 | 42 |
; |
42 | 43 |
|
43 | 44 |
public static final int LENGTH = values().length; |
src/main/res/values-de/strings.xml | ||
---|---|---|
36 | 36 |
<string name="networkError">Netzwerkfehler</string> |
37 | 37 |
<string name="success">Erfolg</string> |
38 | 38 |
<string name="view">Sehen</string> |
39 |
<string name="free_play">Freies Spiel</string> |
|
39 | 40 |
<string name="level_full">Volles Scramble</string> |
40 | 41 |
<string name="save_object">Speichern</string> |
41 | 42 |
<string name="save_object_really">Möchten Sie diesen Cube speichern?</string> |
src/main/res/values-es/strings.xml | ||
---|---|---|
36 | 36 |
<string name="networkError">Error de red</string> |
37 | 37 |
<string name="success">Éxito</string> |
38 | 38 |
<string name="view">Ver</string> |
39 |
<string name="free_play">Juego libre</string> |
|
39 | 40 |
<string name="level_full">Revuelto Completo</string> |
40 | 41 |
<string name="save_object">Guardar</string> |
41 | 42 |
<string name="save_object_really">¿Quieres guardar este Cubo?</string> |
src/main/res/values-fr/strings.xml | ||
---|---|---|
36 | 36 |
<string name="networkError">Erreur réseau</string> |
37 | 37 |
<string name="success">Succès</string> |
38 | 38 |
<string name="view">Regarder</string> |
39 |
<string name="free_play">Jeu libre</string> |
|
39 | 40 |
<string name="level_full">Brouillage Complet</string> |
40 | 41 |
<string name="save_object">Enregistrer</string> |
41 | 42 |
<string name="save_object_really">Voulez-vous enregistrer ce Cube?</string> |
src/main/res/values-ja/strings.xml | ||
---|---|---|
36 | 36 |
<string name="networkError">ネットワークエラー</string> |
37 | 37 |
<string name="success">成功</string> |
38 | 38 |
<string name="view">見る</string> |
39 |
<string name="free_play">無料プレイ</string> |
|
39 | 40 |
<string name="level_full">フルスクランブル</string> |
40 | 41 |
<string name="save_object">保存</string> |
41 | 42 |
<string name="save_object_really">このキューブを保存しますか?</string> |
src/main/res/values-ko/strings.xml | ||
---|---|---|
36 | 36 |
<string name="networkError">네트워크 오류</string> |
37 | 37 |
<string name="success">성공</string> |
38 | 38 |
<string name="view">보다</string> |
39 |
<string name="free_play">게임</string> |
|
39 | 40 |
<string name="level_full">풀 스크램블</string> |
40 | 41 |
<string name="save_object">저장</string> |
41 | 42 |
<string name="save_object_really">이 큐브를 저장하시겠습니까?</string> |
src/main/res/values-pl/strings.xml | ||
---|---|---|
36 | 36 |
<string name="networkError">Błąd sieci</string> |
37 | 37 |
<string name="success">Sukces</string> |
38 | 38 |
<string name="view">Zobacz</string> |
39 |
<string name="free_play">Zabawa z Kostką</string> |
|
39 | 40 |
<string name="level_full">Pełne Pomieszanie</string> |
40 | 41 |
<string name="save_object">Zapisz</string> |
41 | 42 |
<string name="save_object_really">Chcesz zapisać tą kostkę?</string> |
src/main/res/values-ru/strings.xml | ||
---|---|---|
36 | 36 |
<string name="networkError">Ошибка сети</string> |
37 | 37 |
<string name="success">Успех</string> |
38 | 38 |
<string name="view">Смотри</string> |
39 |
<string name="free_play">Игра с кубом</string> |
|
39 | 40 |
<string name="level_full">Полная Схватка</string> |
40 | 41 |
<string name="save_object">Сохранять</string> |
41 | 42 |
<string name="save_object_really">Вы хотите сохранить этот куб?</string> |
src/main/res/values-zh-rCN/strings.xml | ||
---|---|---|
36 | 36 |
<string name="networkError">網絡錯誤</string> |
37 | 37 |
<string name="success">成功</string> |
38 | 38 |
<string name="view">看</string> |
39 |
<string name="free_play">玩立方体</string> |
|
39 | 40 |
<string name="level_full">级满</string> |
40 | 41 |
<string name="save_object">保存</string> |
41 | 42 |
<string name="save_object_really">你想保存这个多维数据集吗?</string> |
src/main/res/values-zh-rTW/strings.xml | ||
---|---|---|
36 | 36 |
<string name="networkError">網絡錯誤</string> |
37 | 37 |
<string name="success">成功</string> |
38 | 38 |
<string name="view">看</string> |
39 |
<string name="free_play">玩立方體</string> |
|
39 | 40 |
<string name="level_full">級滿</string> |
40 | 41 |
<string name="save_object">保存</string> |
41 | 42 |
<string name="save_object_really">你想保存這個多維數據集嗎?</string> |
src/main/res/values/strings.xml | ||
---|---|---|
37 | 37 |
<string name="networkError">Network Error</string> |
38 | 38 |
<string name="success">Success</string> |
39 | 39 |
<string name="view">View</string> |
40 |
<string name="free_play">Free Play</string> |
|
40 | 41 |
<string name="level_full">Full Scramble</string> |
41 | 42 |
<string name="save_object">Save</string> |
42 | 43 |
<string name="save_object_really">Do you want to save this Cube?</string> |
Also available in: Unified diff
New 'Free Play' screen.