Project

General

Profile

« Previous | Next » 

Revision 2ac63f09

Added by Leszek Koltunski 9 months ago

Move all the strings from objlib to the app.
Upgrade AGP from 8.1.4 to 8.3.2

View differences:

src/main/java/org/distorted/objectlib/effects/BaseEffect.java
19 19
import org.distorted.objectlib.effects.objectchange.ObjectChangeEffect;
20 20
import org.distorted.objectlib.effects.solve.SolveEffect;
21 21
import org.distorted.objectlib.effects.win.WinEffect;
22
import org.distorted.objectlib.R;
23 22
import org.distorted.objectlib.helpers.OperatingSystemInterface;
24 23
import org.distorted.objectlib.main.ObjectPreRender;
25 24

  
......
29 28
  {
30 29
  public enum Type
31 30
    {
32
    SIZECHANGE    ( 20, 1, R.string.objectchange_effect , ObjectChangeEffect.class),
33
    SOLVE         ( 20, 1, R.string.solve_effect        , SolveEffect.class       ),
34
    SCRAMBLE      ( 60, 1, R.string.scramble_effect     , ScrambleEffect.class    ),
35
    FAST_SCRAMBLE ( 20, 0, R.string.fast_scramble_effect, FastScrambleEffect.class),
36
    PRESENT       (100, 0, R.string.present_effect      , PresentEffect.class     ),
37
    WIN           ( 20, 1, R.string.win_effect          , WinEffect.class         ),
38
    RESTICKER     ( 20, 0, R.string.resticker_effect    , RestickerEffect.class   ),
31
    SIZECHANGE    ( 20, 1, ObjectChangeEffect.class),
32
    SOLVE         ( 20, 1, SolveEffect.class       ),
33
    SCRAMBLE      ( 60, 1, ScrambleEffect.class    ),
34
    FAST_SCRAMBLE ( 20, 0, FastScrambleEffect.class),
35
    PRESENT       (100, 0, PresentEffect.class     ),
36
    WIN           ( 20, 1, WinEffect.class         ),
37
    RESTICKER     ( 20, 0, RestickerEffect.class   ),
39 38
    ;
40 39

  
41 40
    private final int mDefaultPos, mDefaultType;
42 41
    private final Class<? extends BaseEffect> mClass;
43
    private final int mText;
44 42
    private int mCurrentPos, mCurrentType;
45 43

  
46
    Type(int dPos, int dType, int text, Class<? extends BaseEffect> clazz )
44
    Type(int dPos, int dType, Class<? extends BaseEffect> clazz )
47 45
      {
48 46
      mDefaultPos  = mCurrentPos = dPos;
49 47
      mDefaultType = mCurrentType= dType;
50
      mText        = text;
51 48
      mClass       = clazz;
52 49
      }
53 50

  
......
69 66

  
70 67
  ////////////////////////////////////////////////////////////////////////////////
71 68

  
72
    public int getText()
73
      {
74
      return mText;
75
      }
76

  
77
  ////////////////////////////////////////////////////////////////////////////////
78

  
79
    public int getCurrentPos()
80
      {
81
      return mCurrentPos;
82
      }
83

  
84
  ////////////////////////////////////////////////////////////////////////////////
85

  
86
    public int getCurrentType()
87
      {
88
      return mCurrentType;
89
      }
90

  
91
  ////////////////////////////////////////////////////////////////////////////////
92

  
93
    public void setCurrentPos(int pos)
94
      {
95
      mCurrentPos = pos;
96
      }
97

  
98
  ////////////////////////////////////////////////////////////////////////////////
99

  
100
    public void setCurrentType(int type)
101
      {
102
      mCurrentType = type;
103
      }
69
    public int getCurrentPos() { return mCurrentPos; }
70
    public int getCurrentType() { return mCurrentType; }
71
    public void setCurrentPos(int pos) { mCurrentPos = pos; }
72
    public void setCurrentType(int type) { mCurrentType = type; }
104 73

  
105 74
  ////////////////////////////////////////////////////////////////////////////////
106 75

  
src/main/java/org/distorted/objectlib/objects/TwistyRex.java
364 364

  
365 365
  public float getStickerStroke()
366 366
    {
367
    return isInIconMode() ? 0.25f : 0.12f;
367
    return isInIconMode() ? 0.21f : 0.12f;
368 368
    }
369 369

  
370 370
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/solvers/verifiers/ImplementedVerifierList.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 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.objectlib.solvers.verifiers;
11

  
12
import static org.distorted.objectlib.metadata.ListObjects.*;
13

  
14
import org.distorted.objectlib.helpers.OperatingSystemInterface;
15
import org.distorted.objectlib.main.TwistyObject;
16
import org.distorted.objectlib.metadata.*;
17

  
18
import java.lang.reflect.Constructor;
19
import java.lang.reflect.InvocationTargetException;
20

  
21
///////////////////////////////////////////////////////////////////////////////////////////////////
22

  
23
public enum ImplementedVerifierList
24
{
25
  CUBE2          (CUBE_2.ordinal(), SolverTablebaseCUBE2.class  ),
26
  CU232          (CU_232.ordinal(), SolverTablebaseCU232.class  ),
27
  CU323          (CU_323.ordinal(), SolverTablebaseCU323.class  ),
28
  PYRAMINX       (PYRA_3.ordinal(), SolverTablebasePYRA3.class  ),
29
  SKEWB          (SKEW_2.ordinal(), SolverTablebaseSKEW2.class  ),
30
  PYRAMINX_DUO   (PDUO_2.ordinal(), SolverTablebasePDUO2.class  ),
31
  IVY            (IVY_2.ordinal() , SolverTablebaseIVY2.class   ),
32
  DIAMOND        (DIAM_2.ordinal(), SolverTablebaseDIAM2.class  ),
33
  JING2          (JING_2.ordinal(), SolverTablebaseJING2.class  ),
34
  DINO6          (DINO_3.ordinal(), SolverTablebaseDINO6.class  ),
35
  DINO4          (DIN4_3.ordinal(), SolverTablebaseDINO4.class  ),
36
  PDIA           (PDIA_3.ordinal(), SolverTablebasePDIA3.class  ),
37

  
38
  CUBE3_KOCIEMBA (CUBE_3.ordinal(), SolverKociembaCUBE3.class   ),
39

  
40
  CUBE3_ALGO     (CUBE_3.ordinal(), SolverAlgorithmicCUBE3.class),
41
  KILO3_ALGO     (KILO_3.ordinal(), SolverAlgorithmicKILO3.class),
42
  ;
43

  
44
  public static final int NUM_OBJECTS = values().length;
45

  
46
  private final int mObjectOrdinal;
47
  private final Class<? extends SolverAbstract> mClass;
48

  
49
  private static final ImplementedVerifierList[] objects;
50

  
51
  static
52
    {
53
    objects = new ImplementedVerifierList[NUM_OBJECTS];
54
    int i=0;
55

  
56
    for( ImplementedVerifierList object: ImplementedVerifierList.values())
57
      {
58
      objects[i++] = object;
59
      }
60
    }
61

  
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

  
64
  public static ImplementedVerifierList getSolver(int solverOrdinal)
65
    {
66
    return objects[solverOrdinal];
67
    }
68

  
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

  
71
  public static int[] getSolverOrdinals(int objectOrdinal)
72
    {
73
    int num = 0;
74

  
75
    for(int o=0; o<NUM_OBJECTS; o++)
76
      if( objects[o].mObjectOrdinal==objectOrdinal ) num++;
77

  
78
    if( num>0 )
79
      {
80
      int[] ret = new int[num];
81
      int index = 0;
82

  
83
      for(int o=0; o<NUM_OBJECTS; o++)
84
        if( objects[o].mObjectOrdinal==objectOrdinal ) ret[index++] = o;
85

  
86
      return ret;
87
      }
88
    return null;
89
    }
90

  
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92

  
93
  ImplementedVerifierList(int object, final Class<? extends SolverAbstract> clazz)
94
    {
95
    mObjectOrdinal= object;
96
    mClass        = clazz;
97
    }
98

  
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100
// certain objects have certain cubits locked - for example, the Cube3's centers of
101
// sides always have the same color.
102
// If a certain cubit is locked, return the color (index into it's FACE_COLORS array) it
103
// must have. Otherwise return -1.
104

  
105
  public static int cubitIsLocked(int object, int cubit)
106
    {
107
    if( object == MetadataCUBE_3.INDEX )
108
      {
109
      if( cubit==20 ) return 0; // center of the right  face
110
      if( cubit==21 ) return 1; // center of the left   face
111
      if( cubit==22 ) return 2; // center of the up     face
112
      if( cubit==23 ) return 3; // center of the bottom face
113
      if( cubit==24 ) return 4; // center of the front  face
114
      if( cubit==25 ) return 5; // center of the back   face
115
      }
116

  
117
    return -1;
118
    }
119

  
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121

  
122
  public int getObjectOrdinal() { return mObjectOrdinal; }
123

  
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

  
126
  public SolverAbstract create(OperatingSystemInterface os, TwistyObject object)
127
    {
128
    try
129
      {
130
      Constructor<?>[] cons = mClass.getConstructors();
131

  
132
      if( cons.length==1 )
133
        {
134
        Object[] parameters = new Object[] { os,object };
135
        return (SolverAbstract)cons[0].newInstance(parameters);
136
        }
137
      else
138
        {
139
        android.util.Log.e("SolvingList", "ERROR! number of SolverAbstract constructors="+cons.length);
140
        }
141
      }
142
    catch(IllegalAccessException iae)
143
      {
144
      android.util.Log.e("SolvingList", "Illegal Access Exception: "+iae.getMessage());
145
      }
146
    catch(InstantiationException ie)
147
      {
148
      android.util.Log.e("SolvingList", "Instantiation Exception: "+ie.getMessage());
149
      }
150
    catch(InvocationTargetException ite)
151
      {
152
      android.util.Log.e("SolvingList", "Invocation Target Exception: "+ite.getMessage());
153
      }
154

  
155
    return null;
156
    }
157
}
src/main/java/org/distorted/objectlib/solvers/verifiers/SolvingList.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 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.objectlib.solvers.verifiers;
11

  
12
import static org.distorted.objectlib.metadata.ListObjects.*;
13

  
14
import org.distorted.objectlib.R;
15
import org.distorted.objectlib.helpers.OperatingSystemInterface;
16
import org.distorted.objectlib.main.TwistyObject;
17
import org.distorted.objectlib.metadata.*;
18

  
19
import java.lang.reflect.Constructor;
20
import java.lang.reflect.InvocationTargetException;
21

  
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

  
24
public enum SolvingList
25
{
26
  CUBE2          (CUBE_2.ordinal(), SolverTablebaseCUBE2.class  , R.string.solver_cube2_title, R.string.solver_cube2_description),
27
  CUBE3_KOCIEMBA (CUBE_3.ordinal(), SolverKociembaCUBE3.class   , R.string.solver_cube3_title, R.string.solver_cube3_description),
28
  CUBE3_ALGO     (CUBE_3.ordinal(), SolverAlgorithmicCUBE3.class, R.string.solver_3algo_title, R.string.solver_3algo_description),
29
  CU232          (CU_232.ordinal(), SolverTablebaseCU232.class  , R.string.solver_cu232_title, R.string.solver_cu232_description),
30
  CU323          (CU_323.ordinal(), SolverTablebaseCU323.class  , R.string.solver_cu323_title, R.string.solver_cu323_description),
31
  PYRAMINX       (PYRA_3.ordinal(), SolverTablebasePYRA3.class  , R.string.solver_pyra3_title, R.string.solver_pyra3_description),
32
  SKEWB          (SKEW_2.ordinal(), SolverTablebaseSKEW2.class  , R.string.solver_skew2_title, R.string.solver_skew2_description),
33
  PYRAMINX_DUO   (PDUO_2.ordinal(), SolverTablebasePDUO2.class  , R.string.solver_pduo2_title, R.string.solver_pduo2_description),
34
  IVY            (IVY_2.ordinal() , SolverTablebaseIVY2.class   , R.string.solver_ivy_title  , R.string.solver_ivy_description  ),
35
  DIAMOND        (DIAM_2.ordinal(), SolverTablebaseDIAM2.class  , R.string.solver_diam2_title, R.string.solver_diam2_description),
36
  JING2          (JING_2.ordinal(), SolverTablebaseJING2.class  , R.string.solver_jing2_title, R.string.solver_jing2_description),
37
  DINO6          (DINO_3.ordinal(), SolverTablebaseDINO6.class  , R.string.solver_dino6_title, R.string.solver_dino6_description),
38
  DINO4          (DIN4_3.ordinal(), SolverTablebaseDINO4.class  , R.string.solver_dino4_title, R.string.solver_dino4_description),
39
  PDIA           (PDIA_3.ordinal(), SolverTablebasePDIA3.class  , R.string.solver_pdia_title , R.string.solver_pdia_description ),
40
  KILO3_ALGO     (KILO_3.ordinal(), SolverAlgorithmicKILO3.class, R.string.solver_kilo3_title, R.string.solver_kilo3_description),
41
  ;
42

  
43
  public static final int NUM_OBJECTS = values().length;
44

  
45
  private final int mObjectOrdinal;
46
  private final Class<? extends SolverAbstract> mClass;
47
  private final int mTitle;
48
  private final int mDescription;
49

  
50
  private static final SolvingList[] objects;
51

  
52
  static
53
    {
54
    objects = new SolvingList[NUM_OBJECTS];
55
    int i=0;
56

  
57
    for( SolvingList object: SolvingList.values())
58
      {
59
      objects[i++] = object;
60
      }
61
    }
62

  
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

  
65
  public static SolvingList getSolver(int solverOrdinal)
66
    {
67
    return objects[solverOrdinal];
68
    }
69

  
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

  
72
  public static int[] getSolverOrdinals(int objectOrdinal)
73
    {
74
    int num = 0;
75

  
76
    for(int o=0; o<NUM_OBJECTS; o++)
77
      if( objects[o].mObjectOrdinal==objectOrdinal ) num++;
78

  
79
    if( num>0 )
80
      {
81
      int[] ret = new int[num];
82
      int index = 0;
83

  
84
      for(int o=0; o<NUM_OBJECTS; o++)
85
        if( objects[o].mObjectOrdinal==objectOrdinal ) ret[index++] = o;
86

  
87
      return ret;
88
      }
89
    return null;
90
    }
91

  
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

  
94
  SolvingList(int object, final Class<? extends SolverAbstract> clazz, int title, int descripton)
95
    {
96
    mObjectOrdinal= object;
97
    mClass        = clazz;
98
    mTitle        = title;
99
    mDescription  = descripton;
100
    }
101

  
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103
// certain objects have certain cubits locked - for example, the Cube3's centers of
104
// sides always have the same color.
105
// If a certain cubit is locked, return the color (index into it's FACE_COLORS array) it
106
// must have. Otherwise return -1.
107

  
108
  public static int cubitIsLocked(int object, int cubit)
109
    {
110
    if( object == MetadataCUBE_3.INDEX )
111
      {
112
      if( cubit==20 ) return 0; // center of the right  face
113
      if( cubit==21 ) return 1; // center of the left   face
114
      if( cubit==22 ) return 2; // center of the up     face
115
      if( cubit==23 ) return 3; // center of the bottom face
116
      if( cubit==24 ) return 4; // center of the front  face
117
      if( cubit==25 ) return 5; // center of the back   face
118
      }
119

  
120
    return -1;
121
    }
122

  
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

  
125
  public int getObjectOrdinal() { return mObjectOrdinal; }
126
  public int getTitle() { return mTitle; }
127
  public int getDescription() { return mDescription; }
128

  
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

  
131
  public SolverAbstract create(OperatingSystemInterface os, TwistyObject object)
132
    {
133
    try
134
      {
135
      Constructor<?>[] cons = mClass.getConstructors();
136

  
137
      if( cons.length==1 )
138
        {
139
        Object[] parameters = new Object[] { os,object };
140
        return (SolverAbstract)cons[0].newInstance(parameters);
141
        }
142
      else
143
        {
144
        android.util.Log.e("SolvingList", "ERROR! number of SolverAbstract constructors="+cons.length);
145
        }
146
      }
147
    catch(IllegalAccessException iae)
148
      {
149
      android.util.Log.e("SolvingList", "Illegal Access Exception: "+iae.getMessage());
150
      }
151
    catch(InstantiationException ie)
152
      {
153
      android.util.Log.e("SolvingList", "Instantiation Exception: "+ie.getMessage());
154
      }
155
    catch(InvocationTargetException ite)
156
      {
157
      android.util.Log.e("SolvingList", "Invocation Target Exception: "+ite.getMessage());
158
      }
159

  
160
    return null;
161
    }
162
}
src/main/res/values/strings.xml
1
<resources>
2
    <string name="objectchange_effect">Object Change Effect</string>
3
    <string name="solve_effect">Solve Effect</string>
4
    <string name="scramble_effect">Scramble Effect</string>
5
    <string name="fast_scramble_effect">Fast Scramble Effect</string>
6
    <string name="present_effect">Present Effect</string>
7
    <string name="win_effect">Win Effect</string>
8
    <string name="resticker_effect">Resticker Effect</string>
9

  
10

  
11
    <string name="solver_cube3_title" translatable="false">Kociemba Solver</string>
12
    <string name="solver_3algo_title" translatable="false">3x3 Beginner</string>
13
    <string name="solver_pduo2_title" translatable="false">Pyraminx Duo Solver</string>
14
    <string name="solver_pyra3_title" translatable="false">Pyraminx Solver</string>
15
    <string name="solver_ivy_title" translatable="false">Ivy Solver</string>
16
    <string name="solver_cu232_title" translatable="false">2x2x3 Cuboid Solver</string>
17
    <string name="solver_cu323_title" translatable="false">3x3x2 Cuboid Solver</string>
18
    <string name="solver_diam2_title" translatable="false">Skewb Diamond Solver</string>
19
    <string name="solver_cube2_title" translatable="false">2x2 Cube Solver</string>
20
    <string name="solver_skew2_title" translatable="false">Skewb Solver</string>
21
    <string name="solver_jing2_title" translatable="false">Jing Pyraminx Solver</string>
22
    <string name="solver_dino6_title" translatable="false">6-color Dino Solver</string>
23
    <string name="solver_dino4_title" translatable="false">4-color Dino Solver</string>
24
    <string name="solver_pdia_title" translatable="false">Pyraminx Diamond Solver</string>
25
    <string name="solver_kilo3_title" translatable="false">Kilominx Solver</string>
26

  
27
    <string name="solver_cube3_description">A near-perfect, instantaneous, two-phase 3x3x3 solver.\nAuthor: Herbert Kociemba.</string>
28
    <string name="solver_3algo_description">Implementation of the beginner algorithm. 7 phases. Produces solutions that are about 100 moves long.\nAuthor: Leszek Koltunski.</string>
29
    <string name="solver_pduo2_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
30
    <string name="solver_ivy_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
31
    <string name="solver_cu232_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
32
    <string name="solver_pyra3_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
33
    <string name="solver_diam2_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
34
    <string name="solver_cube2_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
35
    <string name="solver_skew2_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
36
    <string name="solver_jing2_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
37
    <string name="solver_dino6_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
38
    <string name="solver_dino4_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
39
    <string name="solver_pdia_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
40
    <string name="solver_cu323_description">A perfect, instantaneous solver.\nAuthor: Leszek Koltunski.</string>
41
    <string name="solver_kilo3_description">Implementation of the beginner algorithm. 5 phases. Produces solutions that are about 70 moves long.\nAuthor: Leszek Koltunski.</string>
42
</resources>

Also available in: Unified diff