Revision fad10885
Added by Leszek Koltunski over 3 years ago
| src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java | ||
|---|---|---|
| 27 | 27 |
import org.distorted.external.RubikNetwork; |
| 28 | 28 |
import org.distorted.external.RubikUpdates; |
| 29 | 29 |
import org.distorted.objectlib.json.JsonReader; |
| 30 |
import org.distorted.objects.MainEntry; |
|
| 31 |
import org.distorted.objects.MainEntryList; |
|
| 32 |
import org.distorted.objects.RubikObject; |
|
| 33 | 30 |
import org.distorted.objects.RubikObjectList; |
| 34 | 31 |
import org.distorted.screens.RubikScreenPlay; |
| 35 | 32 |
import org.distorted.screens.ScreenList; |
| ... | ... | |
| 218 | 215 |
mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess); |
| 219 | 216 |
if( success ) |
| 220 | 217 |
{
|
| 221 |
int numObjects = RubikObjectList.getNumObjects(); |
|
| 222 |
int ordinal = numObjects-1; |
|
| 223 |
RubikObject rubikObject = RubikObjectList.getObject(ordinal); |
|
| 224 |
MainEntry entry = new MainEntry(rubikObject,ordinal); |
|
| 225 |
MainEntryList list = MainEntryList.getInstance(); |
|
| 226 |
list.addEntry(entry); |
|
| 227 |
} |
|
| 228 |
|
|
| 229 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "2");
|
|
| 218 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "2");
|
|
| 230 | 219 |
|
| 231 |
RubikNetwork network = RubikNetwork.getInstance(); |
|
| 232 |
network.updateDone(mInfo.mObjectShortName); |
|
| 220 |
RubikNetwork network = RubikNetwork.getInstance();
|
|
| 221 |
network.updateDone(mInfo.mObjectShortName);
|
|
| 233 | 222 |
|
| 234 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "3");
|
|
| 223 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "3");
|
|
| 235 | 224 |
|
| 236 |
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass(); |
|
| 237 |
play.recreatePopup(); |
|
| 225 |
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
|
|
| 226 |
play.recreatePopup();
|
|
| 238 | 227 |
|
| 239 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "4");
|
|
| 228 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "4");
|
|
| 240 | 229 |
|
| 241 |
makeProgress(100,R.string.success); |
|
| 230 |
makeProgress(100,R.string.success);
|
|
| 242 | 231 |
|
| 243 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "5");
|
|
| 232 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "5");
|
|
| 233 |
} |
|
| 234 |
else |
|
| 235 |
{
|
|
| 236 |
displayError(R.string.saveError); |
|
| 237 |
} |
|
| 244 | 238 |
} |
| 245 | 239 |
else |
| 246 | 240 |
{
|
| src/main/java/org/distorted/main/RubikActivity.java | ||
|---|---|---|
| 81 | 81 |
public static final float MENU_SMALL_TEXT_SIZE= 0.035f; |
| 82 | 82 |
public static final float TAB_WIDTH = 0.100f; |
| 83 | 83 |
public static final float TAB_HEIGHT = 0.100f; |
| 84 |
public static final float MENU_BUTTON_HEIGHT = 0.120f;
|
|
| 84 |
public static final float MENU_BUTTON_HEIGHT = 0.115f;
|
|
| 85 | 85 |
|
| 86 | 86 |
public static final int FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
| 87 | 87 |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| src/main/java/org/distorted/objects/MainEntry.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2022 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
| 7 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
| 8 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 9 |
|
|
| 10 |
package org.distorted.objects; |
|
| 11 |
|
|
| 12 |
import android.app.Activity; |
|
| 13 |
import android.graphics.drawable.Drawable; |
|
| 14 |
import android.widget.ImageButton; |
|
| 15 |
|
|
| 16 |
import org.distorted.main.RubikActivity; |
|
| 17 |
|
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
public class MainEntry |
|
| 21 |
{
|
|
| 22 |
public final static int TYPE_OBJECT = 0; |
|
| 23 |
public final static int TYPE_CREATOR = 1; |
|
| 24 |
|
|
| 25 |
private final RubikObject mObject; |
|
| 26 |
private final int mType; |
|
| 27 |
private final int mIconID; |
|
| 28 |
private final int mOridnal; |
|
| 29 |
private Drawable mIconDrawable; |
|
| 30 |
private boolean mPrepared; |
|
| 31 |
|
|
| 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 33 |
|
|
| 34 |
public MainEntry(RubikObject object, int ordinal) |
|
| 35 |
{
|
|
| 36 |
mType = TYPE_OBJECT; |
|
| 37 |
mIconID = 0; |
|
| 38 |
mOridnal = ordinal; |
|
| 39 |
mIconDrawable = null; |
|
| 40 |
mObject = object; |
|
| 41 |
mPrepared = false; |
|
| 42 |
} |
|
| 43 |
|
|
| 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 45 |
|
|
| 46 |
public MainEntry(int type, int iconID) |
|
| 47 |
{
|
|
| 48 |
mType = type; |
|
| 49 |
mIconID = iconID; |
|
| 50 |
mOridnal = -1; |
|
| 51 |
mIconDrawable = null; |
|
| 52 |
mObject = null; |
|
| 53 |
mPrepared = false; |
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 57 |
|
|
| 58 |
private void prepare(Activity act) |
|
| 59 |
{
|
|
| 60 |
mIconDrawable = act.getDrawable(mIconID); |
|
| 61 |
mPrepared = true; |
|
| 62 |
} |
|
| 63 |
|
|
| 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 65 |
// PUBLIC API |
|
| 66 |
|
|
| 67 |
public void setIconTo(RubikActivity act, ImageButton button) |
|
| 68 |
{
|
|
| 69 |
if( mType==TYPE_OBJECT ) |
|
| 70 |
{
|
|
| 71 |
if( mObject!=null ) mObject.setIconTo(act,button); |
|
| 72 |
else android.util.Log.e("D", "MainListEntry: object null!!");
|
|
| 73 |
} |
|
| 74 |
else if( mType==TYPE_CREATOR ) |
|
| 75 |
{
|
|
| 76 |
if( !mPrepared ) prepare(act); |
|
| 77 |
button.setBackground(mIconDrawable); |
|
| 78 |
} |
|
| 79 |
} |
|
| 80 |
|
|
| 81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 82 |
|
|
| 83 |
public int getType() |
|
| 84 |
{
|
|
| 85 |
return mType; |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 89 |
|
|
| 90 |
public int getOrdinal() |
|
| 91 |
{
|
|
| 92 |
return mOridnal; |
|
| 93 |
} |
|
| 94 |
} |
|
| src/main/java/org/distorted/objects/MainEntryList.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2022 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
| 7 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
| 8 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 9 |
|
|
| 10 |
package org.distorted.objects; |
|
| 11 |
|
|
| 12 |
import org.distorted.main.R; |
|
| 13 |
|
|
| 14 |
import java.util.ArrayList; |
|
| 15 |
|
|
| 16 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 17 |
|
|
| 18 |
public class MainEntryList |
|
| 19 |
{
|
|
| 20 |
private final ArrayList<MainEntry> mList; |
|
| 21 |
private static MainEntryList mThis; |
|
| 22 |
|
|
| 23 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 24 |
|
|
| 25 |
private MainEntryList() |
|
| 26 |
{
|
|
| 27 |
mList = new ArrayList<>(); |
|
| 28 |
|
|
| 29 |
int numObjects = RubikObjectList.getNumObjects(); |
|
| 30 |
|
|
| 31 |
for(int i=0; i<numObjects; i++) |
|
| 32 |
{
|
|
| 33 |
RubikObject object = RubikObjectList.getObject(i); |
|
| 34 |
|
|
| 35 |
if( object!=null ) |
|
| 36 |
{
|
|
| 37 |
MainEntry entry = new MainEntry(object,i); |
|
| 38 |
mList.add(entry); |
|
| 39 |
|
|
| 40 |
String name = object.getLowerName(); |
|
| 41 |
|
|
| 42 |
if( name!=null && name.equals("ban4_3") )
|
|
| 43 |
{
|
|
| 44 |
MainEntry creator = new MainEntry(MainEntry.TYPE_CREATOR, R.drawable.plus); |
|
| 45 |
mList.add(creator); |
|
| 46 |
} |
|
| 47 |
} |
|
| 48 |
} |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 52 |
|
|
| 53 |
public static MainEntryList getInstance() |
|
| 54 |
{
|
|
| 55 |
if( mThis==null ) mThis = new MainEntryList(); |
|
| 56 |
return mThis; |
|
| 57 |
} |
|
| 58 |
|
|
| 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 60 |
|
|
| 61 |
public void addEntry(MainEntry entry) |
|
| 62 |
{
|
|
| 63 |
mList.add(entry); |
|
| 64 |
} |
|
| 65 |
|
|
| 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 67 |
|
|
| 68 |
public int getNumOfEntries() |
|
| 69 |
{
|
|
| 70 |
return mList.size(); |
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 74 |
|
|
| 75 |
public MainEntry getEntry(int index) |
|
| 76 |
{
|
|
| 77 |
return mList.get(index); |
|
| 78 |
} |
|
| 79 |
} |
|
| src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
|---|---|---|
| 43 | 43 |
import org.distorted.dialogs.RubikDialogTutorial; |
| 44 | 44 |
import org.distorted.helpers.TransparentImageButton; |
| 45 | 45 |
import org.distorted.objectlib.main.ObjectControl; |
| 46 |
import org.distorted.objects.MainEntry; |
|
| 47 |
import org.distorted.objects.MainEntryList; |
|
| 48 | 46 |
import org.distorted.objects.RubikObject; |
| 49 | 47 |
import org.distorted.objects.RubikObjectList; |
| 50 | 48 |
|
| ... | ... | |
| 56 | 54 |
{
|
| 57 | 55 |
public static final int NUM_COLUMNS = 5; |
| 58 | 56 |
public static final int LEVELS_SHOWN = 8; |
| 59 |
private static final int NUM_BUTTONS = 5;
|
|
| 57 |
private static final int NUM_BUTTONS = 6;
|
|
| 60 | 58 |
private static final int[] mLocation = new int[2]; |
| 61 | 59 |
|
| 62 | 60 |
private TransparentImageButton mObjButton, mMenuButton, mSolveButton, mScrambleButton; |
| ... | ... | |
| 173 | 171 |
|
| 174 | 172 |
private void setupObjectWindow(final RubikActivity act, final float width, final float height) |
| 175 | 173 |
{
|
| 176 |
MainEntryList list = MainEntryList.getInstance(); |
|
| 177 |
int numEntries = list.getNumOfEntries(); |
|
| 178 |
mRowCount = (numEntries + NUM_COLUMNS-1) / NUM_COLUMNS; |
|
| 174 |
int numObjects = RubikObjectList.getNumObjects(); |
|
| 175 |
mRowCount = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS; |
|
| 179 | 176 |
mColCount = NUM_COLUMNS; |
| 180 | 177 |
|
| 181 | 178 |
int cubeSize = (int)(width/9); |
| ... | ... | |
| 211 | 208 |
colSpecs[col] = GridLayout.spec(col); |
| 212 | 209 |
} |
| 213 | 210 |
|
| 214 |
for(int entry=0; entry<numEntries; entry++)
|
|
| 211 |
for(int object=0; object<numObjects; object++)
|
|
| 215 | 212 |
{
|
| 216 |
final MainEntry mainEntry = list.getEntry(entry); |
|
| 217 |
int row = entry/NUM_COLUMNS; |
|
| 213 |
final int ordinal = object; |
|
| 214 |
final RubikObject rObject = RubikObjectList.getObject(object); |
|
| 215 |
int row = object/NUM_COLUMNS; |
|
| 218 | 216 |
ImageButton button = new ImageButton(act); |
| 219 |
if( mainEntry!=null ) mainEntry.setIconTo(act,button);
|
|
| 217 |
if( rObject!=null ) rObject.setIconTo(act,button);
|
|
| 220 | 218 |
|
| 221 | 219 |
button.setOnClickListener( new View.OnClickListener() |
| 222 | 220 |
{
|
| ... | ... | |
| 225 | 223 |
{
|
| 226 | 224 |
if( act.getControl().isUINotBlocked() && ScreenList.getCurrentScreen()== ScreenList.PLAY ) |
| 227 | 225 |
{
|
| 228 |
int type = mainEntry!=null ? mainEntry.getType() : -1; |
|
| 229 |
|
|
| 230 |
if( type==MainEntry.TYPE_OBJECT ) |
|
| 231 |
{
|
|
| 232 |
int ordinal = mainEntry.getOrdinal(); |
|
| 233 |
RubikObjectList.setCurrObject(ordinal); |
|
| 234 |
act.changeObject(ordinal,true); |
|
| 235 |
if( mMenuPopup!=null ) setupLevelColors(act); |
|
| 236 |
mMovesController.clearMoves(act); |
|
| 237 |
} |
|
| 238 |
else if( type==MainEntry.TYPE_CREATOR ) |
|
| 239 |
{
|
|
| 240 |
act.switchToBandagedCreator(); |
|
| 241 |
} |
|
| 226 |
RubikObjectList.setCurrObject(ordinal); |
|
| 227 |
act.changeObject(ordinal,true); |
|
| 228 |
if( mMenuPopup!=null ) setupLevelColors(act); |
|
| 229 |
mMovesController.clearMoves(act); |
|
| 242 | 230 |
} |
| 243 | 231 |
|
| 244 | 232 |
if( mObjectPopup!=null ) mObjectPopup.dismiss(); |
| ... | ... | |
| 433 | 421 |
} |
| 434 | 422 |
}); |
| 435 | 423 |
|
| 424 |
Button bandaged = layout.findViewById(R.id.menuBandaged); |
|
| 425 |
bandaged.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize); |
|
| 426 |
bandaged.setOnClickListener( new View.OnClickListener() |
|
| 427 |
{
|
|
| 428 |
@Override |
|
| 429 |
public void onClick(View v) |
|
| 430 |
{
|
|
| 431 |
mMenuPopup.dismiss(); |
|
| 432 |
act.switchToBandagedCreator(); |
|
| 433 |
} |
|
| 434 |
}); |
|
| 435 |
|
|
| 436 | 436 |
Button about = layout.findViewById(R.id.menuAbout); |
| 437 | 437 |
about.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize); |
| 438 | 438 |
about.setOnClickListener( new View.OnClickListener() |
| src/main/res/layout/popup_menu.xml | ||
|---|---|---|
| 54 | 54 |
android:backgroundTint="@color/dark_grey" |
| 55 | 55 |
android:gravity="center"/> |
| 56 | 56 |
|
| 57 |
<Button |
|
| 58 |
android:id="@+id/menuBandaged" |
|
| 59 |
android:text="@string/bandaged" |
|
| 60 |
android:layout_width="match_parent" |
|
| 61 |
android:layout_height="0dp" |
|
| 62 |
android:layout_weight="1.0" |
|
| 63 |
android:paddingRight="10dp" |
|
| 64 |
android:paddingLeft="10dp" |
|
| 65 |
android:singleLine="true" |
|
| 66 |
android:backgroundTint="@color/dark_grey" |
|
| 67 |
android:gravity="center"/> |
|
| 68 |
|
|
| 57 | 69 |
<Button |
| 58 | 70 |
android:id="@+id/menuAbout" |
| 59 | 71 |
android:text="@string/about" |
Also available in: Unified diff
Move the 'bandaged' button back to the main menu.