Revision ad9e8bb3
Added by Leszek Koltunski almost 5 years ago
src/main/java/org/distorted/magic/RubikRenderer.java | ||
---|---|---|
204 | 204 |
mSetQuatAccumulated = true; |
205 | 205 |
} |
206 | 206 |
|
207 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
208 |
// PUBLIC API |
|
209 | 207 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
210 | 208 |
// various things are done here delayed, 'after the next render' as not to be done mid-render and |
211 | 209 |
// cause artifacts. |
... | ... | |
328 | 326 |
} |
329 | 327 |
} |
330 | 328 |
|
329 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
330 |
// PUBLIC API |
|
331 | 331 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
332 | 332 |
|
333 | 333 |
public void effectFinished(final long effectID) |
... | ... | |
345 | 345 |
mCanRotate = true; |
346 | 346 |
mCanDrag = true; |
347 | 347 |
mCanUI = true; |
348 |
|
|
349 |
if( i==BaseEffect.Type.SCRAMBLE.ordinal() ) |
|
350 |
{ |
|
351 |
final RubikActivity act = (RubikActivity)mView.getContext(); |
|
352 |
|
|
353 |
act.runOnUiThread(new Runnable() |
|
354 |
{ |
|
355 |
@Override |
|
356 |
public void run() |
|
357 |
{ |
|
358 |
RubikState.switchState( act, RubikState.SOLV); |
|
359 |
} |
|
360 |
}); |
|
361 |
} |
|
348 | 362 |
break; |
349 | 363 |
} |
350 | 364 |
} |
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() ), |
|
29 |
MAIN ( null , new RubikStateMain() ), |
|
30 |
PLAY ( MAIN , new RubikStatePlay() ), |
|
31 |
SOLV ( PLAY , new RubikStateSolving() ), |
|
31 | 32 |
; |
32 | 33 |
|
33 | 34 |
public static final int LENGTH = values().length; |
... | ... | |
56 | 57 |
return sizes[ordinal]; |
57 | 58 |
} |
58 | 59 |
|
60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
61 |
|
|
62 |
public static RubikState getCurrentState() |
|
63 |
{ |
|
64 |
return mCurrentState; |
|
65 |
} |
|
66 |
|
|
59 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 68 |
|
61 | 69 |
public static void savePreferences(SharedPreferences.Editor editor) |
... | ... | |
75 | 83 |
|
76 | 84 |
public static void goBack(RubikActivity act) |
77 | 85 |
{ |
78 |
switchState(act, mCurrentState.getBack() );
|
|
86 |
switchState(act, mCurrentState.mBack );
|
|
79 | 87 |
} |
80 | 88 |
|
81 | 89 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
109 | 117 |
mClass = clazz; |
110 | 118 |
} |
111 | 119 |
|
112 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
113 |
|
|
114 |
public RubikState getBack() |
|
115 |
{ |
|
116 |
return mBack; |
|
117 |
} |
|
118 |
|
|
119 | 120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
120 | 121 |
|
121 | 122 |
public RubikStateAbstract getStateClass() |
src/main/java/org/distorted/uistate/RubikStateMain.java | ||
---|---|---|
23 | 23 |
import android.support.v4.app.FragmentManager; |
24 | 24 |
import android.util.DisplayMetrics; |
25 | 25 |
import android.view.LayoutInflater; |
26 |
import android.view.View; |
|
27 | 26 |
import android.widget.Button; |
28 | 27 |
import android.widget.LinearLayout; |
28 |
import android.widget.TextView; |
|
29 | 29 |
|
30 | 30 |
import org.distorted.dialog.RubikDialogMain; |
31 | 31 |
import org.distorted.magic.R; |
... | ... | |
70 | 70 |
// TOP //////////////////////////// |
71 | 71 |
LinearLayout layoutTop = act.findViewById(R.id.mainTitle); |
72 | 72 |
layoutTop.removeAllViews(); |
73 |
final View viewTop = inflater.inflate(R.layout.main_title, null); |
|
74 |
layoutTop.addView(viewTop); |
|
73 |
final TextView text = (TextView)inflater.inflate(R.layout.upper_text, null); |
|
74 |
text.setText(R.string.app_name); |
|
75 |
layoutTop.addView(text); |
|
75 | 76 |
|
76 | 77 |
// BOT //////////////////////////// |
77 | 78 |
LinearLayout layoutBot = act.findViewById(R.id.mainBar); |
src/main/java/org/distorted/uistate/RubikStateSolving.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.uistate; |
|
21 |
|
|
22 |
import android.content.SharedPreferences; |
|
23 |
import android.util.DisplayMetrics; |
|
24 |
import android.view.LayoutInflater; |
|
25 |
import android.widget.Button; |
|
26 |
import android.widget.LinearLayout; |
|
27 |
import android.widget.TextView; |
|
28 |
|
|
29 |
import org.distorted.magic.R; |
|
30 |
import org.distorted.magic.RubikActivity; |
|
31 |
|
|
32 |
import static android.view.View.INVISIBLE; |
|
33 |
|
|
34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
35 |
|
|
36 |
public class RubikStateSolving extends RubikStateAbstract |
|
37 |
{ |
|
38 |
public void leaveState(RubikActivity act) |
|
39 |
{ |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
44 |
|
|
45 |
public void enterState(RubikActivity act) |
|
46 |
{ |
|
47 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
48 |
|
|
49 |
// TOP //////////////////////////// |
|
50 |
LinearLayout layoutTop = act.findViewById(R.id.mainTitle); |
|
51 |
layoutTop.removeAllViews(); |
|
52 |
final TextView text = (TextView)inflater.inflate(R.layout.upper_text, null); |
|
53 |
text.setText(R.string.ready); |
|
54 |
layoutTop.addView(text); |
|
55 |
|
|
56 |
// BOT //////////////////////////// |
|
57 |
LinearLayout layoutBot = act.findViewById(R.id.mainBar); |
|
58 |
layoutBot.removeAllViews(); |
|
59 |
|
|
60 |
DisplayMetrics metrics = act.getResources().getDisplayMetrics(); |
|
61 |
float scale = metrics.density; |
|
62 |
int size = (int)(60*scale +0.5f); |
|
63 |
int padding = (int)(5*scale + 0.5f); |
|
64 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,size,0.5f); |
|
65 |
|
|
66 |
Button buttonL = new Button(act); |
|
67 |
buttonL.setLayoutParams(params); |
|
68 |
buttonL.setId(BUTTON_ID_BACK); |
|
69 |
buttonL.setPadding(padding,0,padding,0); |
|
70 |
buttonL.setText(R.string.back); |
|
71 |
buttonL.setOnClickListener(act); |
|
72 |
layoutBot.addView(buttonL); |
|
73 |
|
|
74 |
Button buttonR = new Button(act); |
|
75 |
buttonR.setLayoutParams(params); |
|
76 |
buttonR.setId(BUTTON_ID_BACK); |
|
77 |
buttonR.setPadding(padding,0,padding,0); |
|
78 |
buttonR.setText(R.string.back); |
|
79 |
buttonR.setOnClickListener(act); |
|
80 |
layoutBot.addView(buttonR); |
|
81 |
|
|
82 |
buttonL.setVisibility(INVISIBLE); |
|
83 |
} |
|
84 |
|
|
85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
86 |
|
|
87 |
public void savePreferences(SharedPreferences.Editor editor) |
|
88 |
{ |
|
89 |
|
|
90 |
} |
|
91 |
|
|
92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
93 |
|
|
94 |
public void restorePreferences(SharedPreferences preferences) |
|
95 |
{ |
|
96 |
|
|
97 |
} |
|
98 |
} |
src/main/res/layout/main_title.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<TextView xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:layout_width="fill_parent" |
|
4 |
android:layout_height="50dp" |
|
5 |
android:textAlignment="center" |
|
6 |
android:textSize="30sp" |
|
7 |
android:text="@string/app_name"/> |
src/main/res/layout/upper_text.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<TextView xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:layout_width="fill_parent" |
|
4 |
android:layout_height="50dp" |
|
5 |
android:textAlignment="center" |
|
6 |
android:textSize="30sp"/> |
src/main/res/values/strings.xml | ||
---|---|---|
12 | 12 |
<string name="back">Back</string> |
13 | 13 |
<string name="save">SAVE</string> |
14 | 14 |
<string name="ok">OK</string> |
15 |
<string name="ready">Ready?</string> |
|
15 | 16 |
<string name="sizechange_effect">Size Change Effect</string> |
16 | 17 |
<string name="solve_effect">Solve Effect</string> |
17 | 18 |
<string name="scramble_effect">Scramble Effect</string> |
Also available in: Unified diff
Beginnings of the 'Solving' state.