Revision 00af5060
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/dialogs/RubikDialogScoresPagerAdapter.java | ||
---|---|---|
30 | 30 |
import android.view.ViewGroup; |
31 | 31 |
import android.widget.LinearLayout; |
32 | 32 |
|
33 |
import org.distorted.main.R; |
|
33 | 34 |
import org.distorted.scores.RubikScores; |
34 | 35 |
import org.distorted.scores.RubikScoresDownloader; |
35 | 36 |
import org.distorted.objects.ObjectList; |
37 |
import org.distorted.states.RubikStatePlay; |
|
36 | 38 |
|
37 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
38 | 40 |
|
39 | 41 |
class RubikDialogScoresPagerAdapter extends PagerAdapter implements RubikScoresDownloader.Receiver |
40 | 42 |
{ |
41 |
private FragmentActivity mAct; |
|
42 |
private RubikDialogScores mDialog; |
|
43 |
private RubikDialogScoresView[] mViews; |
|
44 |
private ViewPager mViewPager; |
|
45 |
private int mNumTabs; |
|
46 |
private boolean mIsSubmitting; |
|
43 |
private final FragmentActivity mAct;
|
|
44 |
private final RubikDialogScores mDialog;
|
|
45 |
private final RubikDialogScoresView[] mViews;
|
|
46 |
private final ViewPager mViewPager;
|
|
47 |
private final int mNumTabs;
|
|
48 |
private final boolean mIsSubmitting;
|
|
47 | 49 |
private int mToDoTab, mToDoLvl; |
48 | 50 |
|
49 | 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
50 | 52 |
|
51 |
private void addSection(int tab, int level, final RubikDialogScoresView view, final String[] country, final String[] name, final float[] time) |
|
53 |
private void addSection(int tab, int level, int lastLevel, final RubikDialogScoresView view, final String[] country, final String[] name, final float[] time)
|
|
52 | 54 |
{ |
53 |
final LinearLayout section = view.createSection(mAct, tab, level, country, name, time); |
|
55 |
String title = level==lastLevel-1 ? |
|
56 |
mAct.getString(R.string.level_full) : |
|
57 |
mAct.getString(R.string.lv_placeholder,level+1); |
|
58 |
|
|
59 |
final LinearLayout section = view.createSection(mAct, tab, title, level, country, name, time); |
|
54 | 60 |
|
55 | 61 |
mAct.runOnUiThread(new Runnable() |
56 | 62 |
{ |
... | ... | |
73 | 79 |
|
74 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
75 | 81 |
|
76 |
private void getNext(int currentTab, int[] toDoTab, int[] maxTab) |
|
82 |
private void getNext(int currentTab, int[] toDoTab, int[] maxTab, int[] lastTab)
|
|
77 | 83 |
{ |
78 | 84 |
if( toDoTab[currentTab]<maxTab[currentTab] ) |
79 | 85 |
{ |
80 | 86 |
mToDoTab = currentTab; |
81 |
mToDoLvl = toDoTab[currentTab]; |
|
87 |
mToDoLvl = toDoTab[currentTab]<maxTab[currentTab]-1 ? toDoTab[currentTab] : lastTab[currentTab]-1;
|
|
82 | 88 |
toDoTab[currentTab]++; |
83 | 89 |
} |
84 | 90 |
else |
... | ... | |
88 | 94 |
if( toDoTab[tab]<maxTab[tab] ) |
89 | 95 |
{ |
90 | 96 |
mToDoTab = tab; |
91 |
mToDoLvl = toDoTab[tab]; |
|
97 |
mToDoLvl = toDoTab[tab]<maxTab[tab]-1 ? toDoTab[tab] : lastTab[tab]-1;
|
|
92 | 98 |
toDoTab[tab]++; |
93 | 99 |
break; |
94 | 100 |
} |
... | ... | |
102 | 108 |
{ |
103 | 109 |
prepareView(); |
104 | 110 |
|
111 |
int MAX = RubikStatePlay.LEVELS_SHOWN; |
|
105 | 112 |
int toDo=0; |
106 | 113 |
int[] toDoTab = new int[mNumTabs]; |
107 | 114 |
int[] maxTab = new int[mNumTabs]; |
115 |
int[] lastTab = new int[mNumTabs]; |
|
108 | 116 |
|
109 | 117 |
for(int i=0; i<mNumTabs; i++) |
110 | 118 |
{ |
111 | 119 |
int object = ObjectList.unpackObject(i); |
112 | 120 |
int sizeIndex= ObjectList.unpackSizeIndex(i); |
113 |
maxTab[i] = ObjectList.getMaxLevel(object, sizeIndex); |
|
121 |
lastTab[i] = ObjectList.getMaxLevel(object, sizeIndex); |
|
122 |
maxTab[i] = Math.min(lastTab[i],MAX); |
|
114 | 123 |
toDoTab[i] = 0; |
115 | 124 |
|
116 | 125 |
toDo += maxTab[i]; |
... | ... | |
119 | 128 |
while( toDo>0 ) |
120 | 129 |
{ |
121 | 130 |
toDo--; |
122 |
getNext(mViewPager.getCurrentItem(),toDoTab,maxTab); |
|
123 |
addSection( mToDoTab,mToDoLvl, mViews[mToDoTab], |
|
131 |
getNext(mViewPager.getCurrentItem(),toDoTab,maxTab,lastTab);
|
|
132 |
addSection( mToDoTab,mToDoLvl, lastTab[mToDoTab], mViews[mToDoTab],
|
|
124 | 133 |
country[mToDoTab][mToDoLvl],name[mToDoTab][mToDoLvl],time[mToDoTab][mToDoLvl]); |
125 | 134 |
} |
126 | 135 |
} |
src/main/java/org/distorted/dialogs/RubikDialogScoresView.java | ||
---|---|---|
76 | 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
77 | 77 |
|
78 | 78 |
@SuppressLint("DefaultLocale") |
79 |
LinearLayout createSection(FragmentActivity act, int tab, int level, final String[] country, final String[] name, final float[] time) |
|
79 |
LinearLayout createSection(FragmentActivity act, int tab, String title, int level, final String[] country, final String[] name, final float[] time)
|
|
80 | 80 |
{ |
81 | 81 |
LinearLayout levelLayout = (LinearLayout)inflate(act, R.layout.dialog_scores_scramble_title, null); |
82 | 82 |
TextView text = levelLayout.findViewById(R.id.scoresScrambleTitle); |
83 |
text.setText(act.getString(R.string.lv_placeholder,level+1));
|
|
83 |
text.setText(title);
|
|
84 | 84 |
|
85 | 85 |
int size = (int)(mHeight*RubikActivity.SCORES_LEVEL_TEXT); |
86 | 86 |
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
src/main/java/org/distorted/objects/ObjectList.java | ||
---|---|---|
153 | 153 |
MEGA ( |
154 | 154 |
new int[][] { |
155 | 155 |
{3 , 21, R.raw.mega3, R.drawable.ui_small_mega3, R.drawable.ui_medium_mega3, R.drawable.ui_big_mega3, R.drawable.ui_huge_mega3} , |
156 |
{5 , 25, R.raw.mega5, R.drawable.ui_small_mega5, R.drawable.ui_medium_mega5, R.drawable.ui_big_mega5, R.drawable.ui_huge_mega5} ,
|
|
156 |
{5 , 35, R.raw.mega5, R.drawable.ui_small_mega5, R.drawable.ui_medium_mega5, R.drawable.ui_big_mega5, R.drawable.ui_huge_mega5} ,
|
|
157 | 157 |
}, |
158 | 158 |
TwistyMegaminx.class, |
159 | 159 |
new MovementMinx(), |
src/main/java/org/distorted/states/RubikStatePlay.java | ||
---|---|---|
45 | 45 |
|
46 | 46 |
public class RubikStatePlay extends RubikStateBase |
47 | 47 |
{ |
48 |
private static final int LEVELS_SHOWN = 10;
|
|
49 |
public static final int DEF_OBJECT= ObjectList.CUBE.ordinal();
|
|
50 |
public static final int DEF_SIZE = 3;
|
|
48 |
public static final int LEVELS_SHOWN = 10;
|
|
49 |
public static final int DEF_OBJECT= ObjectList.CUBE.ordinal(); |
|
50 |
public static final int DEF_SIZE = 3; |
|
51 | 51 |
|
52 | 52 |
private static final int[] BUTTON_LABELS = { R.string.scores, R.string.patterns, R.string.solver, R.string.tutorials, R.string.about }; |
53 | 53 |
private static final int NUM_BUTTONS = BUTTON_LABELS.length; |
54 |
private static final float LAST_BUTTON = 1.4f; |
|
54 | 55 |
|
55 | 56 |
private ImageButton mObjButton, mMenuButton, mSolveButton; |
56 | 57 |
private Button mPlayButton; |
... | ... | |
173 | 174 |
final int levelsShown = Math.min(maxLevel,LEVELS_SHOWN); |
174 | 175 |
|
175 | 176 |
mPlayPopup.showAsDropDown(view, margin, margin); |
176 |
mPlayPopup.update(view, mPlayLayoutWidth, (int)(levelsShown*(mMenuItemSize+margin)+2*margin));
|
|
177 |
mPlayPopup.update(view, mPlayLayoutWidth, (int)(levelsShown*(mMenuItemSize+margin)+3*margin+mMenuItemSize*(LAST_BUTTON-1.0f)));
|
|
177 | 178 |
|
178 | 179 |
mPlayPopup.setFocusable(true); |
179 | 180 |
mPlayPopup.update(); |
... | ... | |
493 | 494 |
{ |
494 | 495 |
int sizeIndex = ObjectList.getSizeIndex(mObject,mSize); |
495 | 496 |
int maxLevel = ObjectList.getMaxLevel(mObject, sizeIndex); |
496 |
String[] levels = new String[maxLevel]; |
|
497 |
int numLevel = Math.min(maxLevel, LEVELS_SHOWN); |
|
498 |
String[] levels = new String[numLevel]; |
|
497 | 499 |
|
498 |
for(int i=0; i<maxLevel; i++)
|
|
500 |
for(int i=0; i<numLevel-1; i++)
|
|
499 | 501 |
{ |
500 | 502 |
levels[i] = act.getString(R.string.lv_placeholder,i+1); |
501 | 503 |
} |
502 | 504 |
|
503 |
if( mLevelValue>maxLevel ) mLevelValue=1; |
|
505 |
levels[numLevel-1] = act.getString(R.string.level_full); |
|
506 |
|
|
507 |
if( mLevelValue>maxLevel || mLevelValue<1 || |
|
508 |
(mLevelValue<maxLevel || mLevelValue>LEVELS_SHOWN ) ) |
|
509 |
{ |
|
510 |
mLevelValue=1; |
|
511 |
} |
|
504 | 512 |
|
505 | 513 |
float width = act.getScreenWidthInPixels(); |
506 | 514 |
int margin = (int)(width*RubikActivity.MARGIN); |
... | ... | |
510 | 518 |
pM.setMargins(margin, 0, margin, margin); |
511 | 519 |
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( mPlayLayoutWidth - 2*padding, (int)mMenuItemSize); |
512 | 520 |
pT.setMargins(margin, margin, margin, margin); |
513 |
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( mPlayLayoutWidth - 2*padding, (int)mMenuItemSize);
|
|
521 |
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( mPlayLayoutWidth - 2*padding, (int)(mMenuItemSize*LAST_BUTTON) );
|
|
514 | 522 |
pB.setMargins(margin, margin, margin, 2*margin); |
515 | 523 |
|
516 | 524 |
mPlayLayout.removeAllViews(); |
517 | 525 |
|
518 | 526 |
RubikScores scores = RubikScores.getInstance(); |
519 | 527 |
|
520 |
for(int i=0; i<maxLevel; i++)
|
|
528 |
for(int i=0; i<numLevel; i++)
|
|
521 | 529 |
{ |
522 |
final int but = i;
|
|
530 |
final int scrambles = i<numLevel-1 ? i+1 : maxLevel;
|
|
523 | 531 |
Button button = new Button(act); |
524 |
button.setLayoutParams(i==0 ? pT : (i==maxLevel-1 ? pB : pM));
|
|
532 |
button.setLayoutParams(i==0 ? pT : (i==numLevel-1 ? pB : pM));
|
|
525 | 533 |
button.setText(levels[i]); |
526 | 534 |
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize); |
527 | 535 |
|
... | ... | |
534 | 542 |
public void onClick(View v) |
535 | 543 |
{ |
536 | 544 |
mPlayPopup.dismiss(); |
537 |
mLevelValue = but+1;
|
|
545 |
mLevelValue = scrambles;
|
|
538 | 546 |
act.getPreRender().scrambleObject(mLevelValue); |
539 | 547 |
} |
540 | 548 |
}); |
src/main/res/values-de/strings.xml | ||
---|---|---|
37 | 37 |
<string name="tutorial">Sehen Sie sich ein Lernprogramm an?</string> |
38 | 38 |
<string name="tutorials">Lernprogrammen</string> |
39 | 39 |
<string name="view">Sehen</string> |
40 |
<string name="level_full">Volles Scramble</string> |
|
40 | 41 |
|
41 | 42 |
<string name="credits1">Open Source App, die mit der Distorted Graphics Library entwickelt wurde. Lizenziert unter <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL Version 2</a> oder wie gewünscht einer späteren Version.</string> |
42 | 43 |
<string name="credits2">Hübsche Muster von Walter Randelshofer. Sehen Sie <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
src/main/res/values-es/strings.xml | ||
---|---|---|
37 | 37 |
<string name="tutorial">¿Ver un tutorial?</string> |
38 | 38 |
<string name="tutorials">Tutoriales</string> |
39 | 39 |
<string name="view">Ver</string> |
40 |
<string name="level_full">Revuelto Completo</string> |
|
40 | 41 |
|
41 | 42 |
<string name="credits1">Aplicación de código abierto desarrollada con la biblioteca de gráficos de Distorted. Con licencia <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL versión 2</a> o, a tu elección, cualquier versión posterior.</string> |
42 | 43 |
<string name="credits2">Pretty Patterns por Walter Randelshofer. Mira <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
src/main/res/values-fr/strings.xml | ||
---|---|---|
37 | 37 |
<string name="tutorial">Regarder un tutoriel?</string> |
38 | 38 |
<string name="tutorials">Tutoriels</string> |
39 | 39 |
<string name="view">Regarder</string> |
40 |
<string name="level_full">Brouillage Complet</string> |
|
40 | 41 |
|
41 | 42 |
<string name="credits1">Appli Open Source développée à l\'aide de la bibliothèque graphique Distorted. Sous licence <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL version 2</a> ou - à votre choix - toute version ultérieure.</string> |
42 | 43 |
<string name="credits2">Pretty Patterns par Walter Randelshofer. Voir <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
src/main/res/values-ja/strings.xml | ||
---|---|---|
37 | 37 |
<string name="tutorial">チュートリアルを見ますか?</string> |
38 | 38 |
<string name="tutorials">チュートリアル</string> |
39 | 39 |
<string name="view">見る</string> |
40 |
<string name="level_full">フルスクランブル</string> |
|
40 | 41 |
|
41 | 42 |
<string name="credits1">ディストートグラフィックのライブラリを使用して開発されたオープンソースアプリ。<a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL バージョン 2</a>でライセンスされているか、または-オプション-それ以降のすべてのバージョン。</string> |
42 | 43 |
<string name="credits2">Pretty Patterns 沿って Walter Randelshofer. 見る <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
src/main/res/values-ko/strings.xml | ||
---|---|---|
37 | 37 |
<string name="tutorial">튜토리얼을 보시겠습니까?</string> |
38 | 38 |
<string name="tutorials">튜토리얼</string> |
39 | 39 |
<string name="view">보다</string> |
40 |
<string name="level_full">풀 스크램블</string> |
|
40 | 41 |
|
41 | 42 |
<string name="credits1">왜곡된 그래픽 라이브러리를 사용하여 개발된 오픈 소스 앱. <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL 버전 2</a> 또는 귀하의 선택에 따라 최신 버전으로 라이센스가 부여됩니다.</string> |
42 | 43 |
<string name="credits2">Pretty Patterns 으로 Walter Randelshofer. 보다 <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
src/main/res/values-pl/strings.xml | ||
---|---|---|
37 | 37 |
<string name="tutorial">Zobacz tutorial?</string> |
38 | 38 |
<string name="tutorials">Tutoriale</string> |
39 | 39 |
<string name="view">Zobacz</string> |
40 |
<string name="level_full">Pełne Pomieszanie</string> |
|
40 | 41 |
|
41 | 42 |
<string name="credits1">Aplikacja open-source napisana wykorzystując bibliotekę Distorted. Licencja: <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL wersja 2</a> albo jakakolwiek poźniejsza.</string> |
42 | 43 |
<string name="credits2">Piękne Wzory Waltera Randelshofera. Zobacz <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
src/main/res/values-ru/strings.xml | ||
---|---|---|
37 | 37 |
<string name="tutorial">Смотрите учебник?</string> |
38 | 38 |
<string name="tutorials">Учебники</string> |
39 | 39 |
<string name="view">Смотри</string> |
40 |
<string name="level_full">Полная Схватка</string> |
|
40 | 41 |
|
41 | 42 |
<string name="credits1">Приложение с открытым исходным кодом, разработанное с использованием библиотеки графики Искажений. Лицензируется согласно <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">версии 2 GPL</a> или любой более поздней версии по вашему выбору.</string> |
42 | 43 |
<string name="credits2">Pretty Patterns по Walter Randelshofer. Смотри <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
src/main/res/values-zh-rCN/strings.xml | ||
---|---|---|
37 | 37 |
<string name="tutorial">观看教程?</string> |
38 | 38 |
<string name="tutorials">讲解</string> |
39 | 39 |
<string name="view">看</string> |
40 |
<string name="level_full">级满</string> |
|
40 | 41 |
|
41 | 42 |
<string name="credits1">此应用程式原始码开发使用Distorted图型库。根据<a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">通用公共许可版本2</a>或者任何更新版本(根据您的选择)进行许可。</string> |
42 | 43 |
<string name="credits2">Pretty Patterns by Werner Randelshofer. 請看 <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
src/main/res/values-zh-rTW/strings.xml | ||
---|---|---|
37 | 37 |
<string name="tutorial">觀看教程?</string> |
38 | 38 |
<string name="tutorials">講解</string> |
39 | 39 |
<string name="view">看</string> |
40 |
<string name="level_full">級滿</string> |
|
40 | 41 |
|
41 | 42 |
<string name="credits1">此應用程式原始碼開發使用Distorted圖型庫。根據<a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">通用公共許可版本2</a>或者任何更新版本(根據您的選擇)進行許可。</string> |
42 | 43 |
<string name="credits2">Pretty Patterns by Werner Randelshofer. 請看 <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
... | ... | |
56 | 57 |
<string name="solver_cube3_error9">求解器中斷!</string> |
57 | 58 |
|
58 | 59 |
<string name="ms_placeholder">%1$d 毫秒</string> |
59 |
<string name="lv_placeholder">级别 %1$d</string>
|
|
60 |
<string name="lv_placeholder">級別 %1$d</string>
|
|
60 | 61 |
<string name="tm_placeholder">%1$02d:%2$02d</string> |
61 | 62 |
<string name="ap_placeholder">%1$s %2$s</string> |
62 | 63 |
<string name="ti_placeholder">%1$.2f 秒</string> |
src/main/res/values/strings.xml | ||
---|---|---|
38 | 38 |
<string name="tutorial">Watch a tutorial?</string> |
39 | 39 |
<string name="tutorials">Tutorials</string> |
40 | 40 |
<string name="view">View</string> |
41 |
<string name="level_full">Full Scramble</string> |
|
41 | 42 |
|
42 | 43 |
<string name="credits1">Open Source app developed using the Distorted graphics library. Licensed under <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL version 2</a> or - at your option - any later version.</string> |
43 | 44 |
<string name="credits2">Pretty Patterns by Walter Randelshofer. See <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
Also available in: Unified diff
Always use only (max) 10 levels - (max) 9 'initial' Levels + Full Scramble.