Project

General

Profile

« Previous | Next » 

Revision 400ff34d

Added by Leszek Koltunski over 2 years ago

Move the 'currObject' from RubikScreenPlay (WTF?) to RubikObjectList.

View differences:

src/main/java/org/distorted/objects/RubikObjectList.java
19 19

  
20 20
package org.distorted.objects;
21 21

  
22
import android.content.SharedPreferences;
23

  
24
import org.distorted.main.RubikActivity;
22 25
import org.distorted.objectlib.main.ObjectConstants;
23 26
import org.distorted.objectlib.main.ObjectType;
27
import org.distorted.screens.RubikScreenPlay;
28
import org.distorted.screens.ScreenList;
24 29

  
25 30
import java.util.ArrayList;
26 31
import static org.distorted.objectlib.main.ObjectType.NUM_OBJECTS;
......
29 34

  
30 35
public class RubikObjectList
31 36
{
37
  public static final int DEF_OBJECT= ObjectConstants.CUBE_3;
38

  
32 39
  public static int MAX_LEVEL;
33 40

  
34 41
  private static RubikObjectList mType;
35 42
  private static int mNumObjects;
36 43
  private static ArrayList<RubikObject> mObjects;
44
  private static int mObject = DEF_OBJECT;
37 45

  
38 46
  static
39 47
    {
......
99 107
    return type.getNumScramble();
100 108
    }
101 109

  
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

  
112
  public static void savePreferences(SharedPreferences.Editor editor)
113
    {
114
    RubikObject object = getObject(mObject);
115

  
116
    if( object!=null )
117
      {
118
      editor.putString("statePlay_objName", object.getName() );
119
      }
120
    }
121

  
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

  
124
  public static void restorePreferences(SharedPreferences preferences)
125
    {
126
    RubikObject object = getObject(DEF_OBJECT);
127
    String defName = object==null ? "CUBE_3" : object.getName();
128
    String objName= preferences.getString("statePlay_objName",defName);
129
    mObject = getOrdinal(objName);
130

  
131
    if( mObject<0 || mObject>=mNumObjects ) mObject = DEF_OBJECT;
132
    }
133

  
134
///////////////////////////////////////////////////////////////////////////////////////////////////
135

  
136
  public static boolean setCurrObject(RubikActivity act, int ordinal)
137
    {
138
    if( mObject!=ordinal )
139
      {
140
      mObject = ordinal;
141
      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
142
      play.setCurrObject(act);
143
      return true;
144
      }
145

  
146
    return false;
147
    }
148

  
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150

  
151
  public static int getCurrObject()
152
    {
153
    return mObject;
154
    }
155

  
102 156
///////////////////////////////////////////////////////////////////////////////////////////////////
103 157

  
104 158
  public static RubikObject getObject(int ordinal)

Also available in: Unified diff