| 1 |
5a4ee169
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
// Copyright 2023 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.dialogs;
|
| 11 |
|
|
|
| 12 |
|
|
import android.app.Dialog;
|
| 13 |
|
|
import android.view.View;
|
| 14 |
|
|
import android.view.Window;
|
| 15 |
|
|
import android.view.WindowManager;
|
| 16 |
|
|
import android.widget.LinearLayout;
|
| 17 |
|
|
import android.widget.TextView;
|
| 18 |
|
|
|
| 19 |
|
|
import androidx.fragment.app.FragmentActivity;
|
| 20 |
|
|
|
| 21 |
1c04d054
|
leszek
|
import org.distorted.main.MainActivity;
|
| 22 |
5a4ee169
|
leszek
|
import org.distorted.main.R;
|
| 23 |
|
|
|
| 24 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 25 |
|
|
|
| 26 |
8477cf44
|
leszek
|
public class DialogCreators extends DialogAbstract
|
| 27 |
5a4ee169
|
leszek
|
{
|
| 28 |
|
|
private enum BandagedObjectDescription
|
| 29 |
|
|
{
|
| 30 |
10dccf68
|
leszek
|
CUBOID ( org.distorted.objectlib.R.drawable.cu_232, R.string.creator_cuboid_title , R.string.creator_cuboid_desc ),
|
| 31 |
|
|
PYRAMINX ( org.distorted.objectlib.R.drawable.pyra_3, R.string.creator_pyraminx_title, R.string.creator_pyraminx_desc ),
|
| 32 |
|
|
MEGAMINX ( org.distorted.objectlib.R.drawable.mega_3, R.string.creator_megaminx_title, R.string.creator_megaminx_desc ),
|
| 33 |
|
|
OCTAHEDRON ( org.distorted.objectlib.R.drawable.diam_2, R.string.creator_octahedron_title, R.string.creator_octahedron_desc ),
|
| 34 |
65a24dca
|
leszek
|
SKEWB ( org.distorted.objectlib.R.drawable.skew_2, R.string.creator_skewb_title, R.string.creator_skewb_desc ),
|
| 35 |
5a4ee169
|
leszek
|
;
|
| 36 |
|
|
|
| 37 |
|
|
public static final int NUM_OBJECTS = values().length;
|
| 38 |
|
|
private static final BandagedObjectDescription[] objects;
|
| 39 |
|
|
|
| 40 |
|
|
final int mIcon, mTitle, mDescription;
|
| 41 |
|
|
|
| 42 |
|
|
BandagedObjectDescription(int icon, int title, int descripton)
|
| 43 |
|
|
{
|
| 44 |
|
|
mIcon = icon;
|
| 45 |
|
|
mTitle = title;
|
| 46 |
|
|
mDescription = descripton;
|
| 47 |
|
|
}
|
| 48 |
|
|
|
| 49 |
|
|
static
|
| 50 |
|
|
{
|
| 51 |
|
|
int i=0;
|
| 52 |
|
|
objects = new BandagedObjectDescription[NUM_OBJECTS];
|
| 53 |
|
|
for( BandagedObjectDescription object: BandagedObjectDescription.values() ) objects[i++] = object;
|
| 54 |
|
|
}
|
| 55 |
|
|
|
| 56 |
|
|
////////////////////////////////////////////////////////////////////////
|
| 57 |
|
|
|
| 58 |
|
|
static int getIcon(int ordinal)
|
| 59 |
|
|
{
|
| 60 |
|
|
return objects[ordinal].mIcon;
|
| 61 |
|
|
}
|
| 62 |
|
|
|
| 63 |
|
|
////////////////////////////////////////////////////////////////////////
|
| 64 |
|
|
|
| 65 |
|
|
static int getTitle(int ordinal)
|
| 66 |
|
|
{
|
| 67 |
|
|
return objects[ordinal].mTitle;
|
| 68 |
|
|
}
|
| 69 |
|
|
|
| 70 |
|
|
////////////////////////////////////////////////////////////////////////
|
| 71 |
|
|
|
| 72 |
|
|
static int getDescription(int ordinal)
|
| 73 |
|
|
{
|
| 74 |
|
|
return objects[ordinal].mDescription;
|
| 75 |
|
|
}
|
| 76 |
|
|
}
|
| 77 |
|
|
|
| 78 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 79 |
|
|
|
| 80 |
|
|
@Override
|
| 81 |
|
|
public void onResume()
|
| 82 |
|
|
{
|
| 83 |
|
|
super.onResume();
|
| 84 |
|
|
|
| 85 |
|
|
Window window = getDialog().getWindow();
|
| 86 |
|
|
|
| 87 |
|
|
if( window!=null )
|
| 88 |
|
|
{
|
| 89 |
|
|
WindowManager.LayoutParams params = window.getAttributes();
|
| 90 |
|
|
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
|
| 91 |
1c04d054
|
leszek
|
params.height = (int)( mHeight*0.90f);
|
| 92 |
5a4ee169
|
leszek
|
window.setAttributes(params);
|
| 93 |
|
|
}
|
| 94 |
|
|
}
|
| 95 |
|
|
|
| 96 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 97 |
|
|
|
| 98 |
10dccf68
|
leszek
|
public int getResource() { return R.layout.dialog_scrollable_panes; }
|
| 99 |
|
|
public int getTitleResource() { return R.string.creators; }
|
| 100 |
|
|
public boolean hasArgument() { return false; }
|
| 101 |
|
|
public int getPositive() { return R.string.ok; }
|
| 102 |
|
|
public int getNegative() { return -1; }
|
| 103 |
|
|
public void positiveAction() { }
|
| 104 |
|
|
public void negativeAction() { }
|
| 105 |
|
|
public static String getDialogTag() { return "DialogCreators"; }
|
| 106 |
5a4ee169
|
leszek
|
|
| 107 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 108 |
|
|
|
| 109 |
|
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
| 110 |
|
|
{
|
| 111 |
|
|
int margin= (int)(mHeight*0.010f);
|
| 112 |
|
|
int padd = (int)(mHeight*0.010f);
|
| 113 |
|
|
int font = (int)(mHeight*0.025f);
|
| 114 |
|
|
|
| 115 |
|
|
LinearLayout layout= view.findViewById(R.id.dialog_scrollable_main_layout);
|
| 116 |
|
|
TextView text = view.findViewById(R.id.dialog_scrollable_message);
|
| 117 |
|
|
text.setVisibility(View.GONE);
|
| 118 |
|
|
|
| 119 |
|
|
LinearLayout.LayoutParams pV = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
| 120 |
|
|
pV.setMargins(margin, margin, margin, 0);
|
| 121 |
|
|
LinearLayout.LayoutParams pL = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
| 122 |
|
|
pL.setMargins(margin, margin, margin, margin);
|
| 123 |
|
|
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
| 124 |
|
|
pT.setMargins(0,0,0,2*margin);
|
| 125 |
|
|
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
|
| 126 |
|
|
pB.setMargins(0,2*margin,0,0);
|
| 127 |
|
|
|
| 128 |
|
|
int num = BandagedObjectDescription.NUM_OBJECTS;
|
| 129 |
1c04d054
|
leszek
|
MainActivity ract = (MainActivity) getContext();
|
| 130 |
5a4ee169
|
leszek
|
|
| 131 |
|
|
for(int i=0; i<num; i++)
|
| 132 |
|
|
{
|
| 133 |
|
|
int icon = BandagedObjectDescription.getIcon(i);
|
| 134 |
|
|
int title = BandagedObjectDescription.getTitle(i);
|
| 135 |
|
|
int description = BandagedObjectDescription.getDescription(i);
|
| 136 |
8477cf44
|
leszek
|
DialogCreatorView pane = new DialogCreatorView(ract,this,i,icon,title,description, padd, font, (i==num-1?pL:pV),pT,pB);
|
| 137 |
5a4ee169
|
leszek
|
layout.addView(pane.getView());
|
| 138 |
|
|
}
|
| 139 |
|
|
}
|
| 140 |
|
|
}
|