Project

General

Profile

« Previous | Next » 

Revision 337f4660

Added by Leszek Koltunski 6 months ago

remove 'MESH_NICE'

View differences:

src/main/java/org/distorted/bandaged/BandagedCreatorActivity.java
287 287

  
288 288
      if( !assets.noJsonStream() )
289 289
        {
290
        TwistyObject object = new TwistyJson( TwistyObject.MESH_NICE, TwistyObject.MODE_NORM, null, null, 1.0f, assets);
290
        TwistyObject object = new TwistyJson( TwistyObject.MODE_NORM, null, null, 1.0f, assets);
291 291

  
292 292
        if( !object.getError() )
293 293
          {
src/main/java/org/distorted/bandaged/BandagedPlayActivity.java
235 235
      {
236 236
      RubikFiles files = RubikFiles.getInstance();
237 237

  
238
      int meshState          = TwistyObject.MESH_NICE;
239 238
      int iconMode           = TwistyObject.MODE_NORM;
240 239
      InputStream jsonStream = files.openFile(this,name+"_object.json");
241 240
      InitAssets asset       = new InitAssets(jsonStream,null,null);
242 241
      int ordinal            = 0; // if jsonStream!=null, this doesn't matter
243 242

  
244
      control.changeIfDifferent(ordinal,name,meshState,iconMode,asset);
243
      control.changeIfDifferent(ordinal,name,iconMode,asset);
245 244
      }
246 245

  
247 246
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/config/ConfigActivity.java
187 187
      {
188 188
      if( object!=null )
189 189
        {
190
        int meshState          = object.getMeshState();
191 190
        int iconMode           = TwistyObject.MODE_NORM;
192 191
        InputStream jsonStream = object.getObjectStream(this);
193 192
        InputStream meshStream = object.getMeshStream(this);
194 193
        String name            = object.getUpperName();
195 194
        InitAssets asset       = new InitAssets(jsonStream,meshStream,null);
196
        control.changeIfDifferent(ordinal,name,meshState,iconMode,asset);
195
        control.changeIfDifferent(ordinal,name,iconMode,asset);
197 196
        }
198 197
      }
199 198

  
......
210 209
      changeIfDifferent(object,ordinal,control);
211 210
      }
212 211

  
213
///////////////////////////////////////////////////////////////////////////////////////////////////
214

  
215
    public void changeMeshState(RubikObject object, int ordinal)
216
      {
217
      if( object!=null )
218
        {
219
        ConfigSurfaceView view = findViewById(R.id.configSurfaceView);
220
        ObjectControl control = view.getObjectControl();
221

  
222
        int meshState          = object.getMeshState();
223
        int iconMode           = TwistyObject.MODE_NORM;
224
        InputStream jsonStream = object.getObjectStream(this);
225
        InputStream meshStream = object.getMeshStream(this);
226
        InitAssets asset       = new InitAssets(jsonStream,meshStream,null);
227

  
228
        control.changeObject(ordinal,meshState,iconMode,asset);
229
        }
230
      }
231

  
232 212
///////////////////////////////////////////////////////////////////////////////////////////////////
233 213

  
234 214
    public int getHeightBar()
src/main/java/org/distorted/dialogs/RubikDialogPatternListAdapter.java
17 17
import android.widget.BaseExpandableListAdapter;
18 18
import android.widget.TextView;
19 19

  
20
import org.distorted.main_old.RubikActivity;
20
import org.distorted.main.MainActivity;
21 21
import org.distorted.objectlib.patterns.RubikPattern;
22 22
import org.distorted.main.R;
23 23

  
......
26 26
class RubikDialogPatternListAdapter extends BaseExpandableListAdapter
27 27
  {
28 28
  private final Context mContext;
29
  private final int mTab, mHeight;
29
  private final int mTab, mWidth;
30 30

  
31 31
///////////////////////////////////////////////////////////////////////////////////////////////////
32 32

  
33
  public RubikDialogPatternListAdapter(Context context, int tab, int height)
33
  public RubikDialogPatternListAdapter(Context context, int tab, int width)
34 34
    {
35 35
    mContext = context;
36 36
    mTab     = tab;
37
    mHeight  = height;
37
    mWidth   = width;
38 38
    }
39 39

  
40 40
///////////////////////////////////////////////////////////////////////////////////////////////////
......
67 67
      view = infalInflater.inflate(R.layout.dialog_pattern_child_item, null);
68 68
      }
69 69

  
70
    int size = (int)(mHeight* RubikActivity.PATTERN_CHILD_TEXT);
70
    int size = (int)(mWidth*MainActivity.PATTERN_CHILD_TEXT);
71 71

  
72 72
    TextView childItem = view.findViewById(R.id.child);
73 73
    childItem.setText(childName);
......
124 124
      view = inf.inflate(R.layout.dialog_pattern_group_item, null);
125 125
      }
126 126

  
127
    int size = (int)(mHeight* RubikActivity.PATTERN_GROUP_TEXT);
127
    int size = (int)(mWidth*MainActivity.PATTERN_GROUP_TEXT);
128 128

  
129 129
    TextView heading = view.findViewById(R.id.heading);
130 130
    heading.setText(groupName);
src/main/java/org/distorted/dialogs/RubikDialogPatternSingle.java
85 85
    android.util.Log.e("D", "prepareBody: object "+mArgument);
86 86

  
87 87
    final PatternActivity pact = (PatternActivity)getContext();
88
    int height = pact!=null ? pact.getScreenHeightInPixels() : 100;
88
    int width = pact!=null ? pact.getScreenWidthInPixels() : 100;
89 89
    final ObjectControl control = pact!=null ? pact.getControl() : null;
90 90

  
91 91
    RubikPattern pattern = RubikPattern.getInstance();
92 92
    mExpandedGroup = pattern.recallExpanded(mPatternOrdinal);
93 93

  
94 94
    mListView = view.findViewById(R.id.patternListView);
95
    RubikDialogPatternListAdapter listAdapter = new RubikDialogPatternListAdapter(act,mPatternOrdinal,height);
95
    RubikDialogPatternListAdapter listAdapter = new RubikDialogPatternListAdapter(act,mPatternOrdinal,width);
96 96
    mListView.setAdapter(listAdapter);
97 97

  
98 98
    if( mExpandedGroup>=0 ) mListView.expandGroup(mExpandedGroup);
src/main/java/org/distorted/dialogs/RubikDialogPatternView.java
66 66
    View tab = inflate( act, R.layout.dialog_pattern_tab, null);
67 67

  
68 68
    mListView = tab.findViewById(R.id.patternListView);
69
    RubikDialogPatternListAdapter listAdapter = new RubikDialogPatternListAdapter(act,mTab, ract.getScreenHeightInPixels());
69
    RubikDialogPatternListAdapter listAdapter = new RubikDialogPatternListAdapter(act,mTab, ract.getScreenWidthInPixels());
70 70
    mListView.setAdapter(listAdapter);
71 71

  
72 72
    if( mExpandedGroup>=0 )
src/main/java/org/distorted/main/MainActivity.java
43 43
import org.distorted.external.RubikNetwork;
44 44
import org.distorted.external.RubikScores;
45 45
import org.distorted.external.RubikUpdates;
46
import org.distorted.main_old.RubikSurfaceView;
47 46
import org.distorted.messaging.RubikInAppMessanging;
48
import org.distorted.objectlib.main.ObjectControl;
49 47
import org.distorted.objects.RubikObjectList;
50 48
import org.distorted.patternui.PatternActivity;
51 49
import org.distorted.solverui.SolverActivity;
......
55 53

  
56 54
public class MainActivity extends AppCompatActivity implements RubikNetwork.Updatee
57 55
{
56
    public static final float PATTERN_CHILD_TEXT  = 0.038f;
57
    public static final float PATTERN_GROUP_TEXT  = 0.060f;
58

  
58 59
    public static final float RATIO_BAR = 0.080f;
59 60
    public static final int FLAGS =  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
60 61
                                   | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
......
253 254
        RubikScores scores = RubikScores.getInstance();
254 255
        scores.incrementNumRuns();
255 256
        scores.setCountry(this);
256
        RubikObjectList.restoreMeshState(preferences);
257 257
        }
258 258

  
259 259
      if( !mOldVersion.equals(mCurrVersion) ) displayNovelties();
......
303 303
      editor.putString("appVersion", mCurrVersion );
304 304

  
305 305
      RubikObjectList.savePreferences(editor);
306
      RubikObjectList.saveMeshState(editor);
307 306

  
308 307
      boolean success = editor.commit();
309 308
      if( !success ) android.util.Log.e("D", "Failed to save preferences");
src/main/java/org/distorted/main/MainScrollGrid.java
58 58
        @Override
59 59
        public void onClick(View v)
60 60
          {
61
          android.util.Log.e("D", "clicked on child "+ordinal);
62

  
61 63
          int w = displaymetrics.widthPixels;
62 64
          int h = displaymetrics.heightPixels;
63 65
          MainObjectPopup popup = new MainObjectPopup(act,ordinal,w,h);
src/main/java/org/distorted/main_old/RubikActivity.java
58 58
import org.distorted.screens.RubikScreenPlay;
59 59
import org.distorted.tutorials.TutorialActivity;
60 60

  
61
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
62

  
63 61
///////////////////////////////////////////////////////////////////////////////////////////////////
64 62

  
65 63
public class RubikActivity extends AppCompatActivity
......
264 262
        RubikScores scores = RubikScores.getInstance();
265 263
        scores.incrementNumRuns();
266 264
        scores.setCountry(this);
267
        RubikObjectList.restoreMeshState(preferences);
265
        //RubikObjectList.restoreMeshState(preferences);
268 266
        }
269 267

  
270 268
      int object = RubikObjectList.getCurrObject();
......
325 323
        }
326 324

  
327 325
      RubikObjectList.savePreferences(editor);
328
      RubikObjectList.saveMeshState(editor);
326
      //RubikObjectList.saveMeshState(editor);
329 327
      ScreenList.savePreferences(editor);
330 328
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
331 329
      OSInterface os = view.getInterface();
......
573 571
    public void changeIfDifferent(int ordinal, ObjectControl control)
574 572
      {
575 573
      RubikObject object = RubikObjectList.getObject(ordinal);
576
      int meshState = object!=null ? object.getMeshState() : MESH_NICE;
574
      //int meshState = object!=null ? object.getMeshState() : MESH_NICE;
577 575
      int iconMode  = TwistyObject.MODE_NORM;
578 576
      InputStream jsonStream = object==null ? null : object.getObjectStream(this);
579 577
      InputStream meshStream = object==null ? null : object.getMeshStream(this);
......
582 580
      OSInterface os = view.getInterface();
583 581
      InitAssets asset = new InitAssets(jsonStream,meshStream,os);
584 582

  
585
      control.changeIfDifferent(ordinal,name,meshState,iconMode,asset);
583
      control.changeIfDifferent(ordinal,name,iconMode,asset);
586 584
      }
587 585

  
588 586
///////////////////////////////////////////////////////////////////////////////////////////////////
......
635 633

  
636 634
        if( object!=null )
637 635
          {
638
          int meshState = object.getMeshState();
639 636
          int iconMode  = TwistyObject.MODE_NORM;
640 637
          InputStream jsonStream = object.getObjectStream(this);
641 638
          InputStream meshStream = object.getMeshStream(this);
......
643 640
          OSInterface os         = view.getInterface();
644 641
          InitAssets asset       = new InitAssets(jsonStream,meshStream,os);
645 642
          ObjectControl control  = getControl();
646
          control.changeObject(-1,meshState,iconMode,asset);
643
          control.changeObject(-1,iconMode,asset);
647 644
          }
648 645
        }
649 646
      }
src/main/java/org/distorted/objects/RubikObject.java
31 31
import org.distorted.objectlib.patterns.RubikPatternList;
32 32
import org.distorted.solvers.ImplementedSolversList;
33 33

  
34
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
35 34
import static org.distorted.main_old.RubikActivity.SHOW_DOWNLOADED_DEBUG;
36 35

  
37 36
///////////////////////////////////////////////////////////////////////////////////////////////////
......
49 48
  private int mJsonID, mMeshID, mExtrasID;
50 49
  private int mObjectVersion, mExtrasVersion;
51 50
  private int mNumScramble;
52
  private int mMeshState;
53 51
  private int mExtrasOrdinal;
54 52
  private int mSolverOrdinal;
55 53

  
......
73 71
    mPatterns = RubikPatternList.getPatterns(patternOrdinal);
74 72

  
75 73
    mSolverOrdinal = ImplementedSolversList.getSolverOrdinal(ordinal);
76

  
77
    mMeshState = MESH_NICE;
78 74
    mExtrasOrdinal = -1;
79 75

  
80 76
    mObjectVersion = ObjectType.getObjectVersion(ordinal);
......
96 92
    mExtrasVersion = object.extrasVersion;
97 93

  
98 94
    mPatterns      = null;
99
    mMeshState     = MESH_NICE;
100 95
    mExtrasOrdinal = -1;
101 96
    mSolverOrdinal = -1;
102 97

  
......
166 161
    return mExtrasOrdinal;
167 162
    }
168 163

  
169
///////////////////////////////////////////////////////////////////////////////////////////////////
170

  
171
  public void setMeshState(int state)
172
    {
173
    mMeshState = state;
174
    }
175

  
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177

  
178
  public int getMeshState()
179
    {
180
    return mMeshState;
181
    }
182

  
183 164
///////////////////////////////////////////////////////////////////////////////////////////////////
184 165
// PUBLIC API
185 166

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

  
23 23
import static org.distorted.main_old.RubikActivity.SHOW_IAP_DEBUG;
24 24
import static org.distorted.main_old.RubikActivity.USE_IAP;
25
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
26 25
import static org.distorted.objectlib.main.ObjectType.NUM_OBJECTS;
27 26
import static org.distorted.main_old.RubikActivity.SHOW_DOWNLOADED_DEBUG;
28 27
import static org.distorted.screens.RubikScreenPlay.LEVELS_SHOWN;
......
232 231
      }
233 232
    }
234 233

  
235
///////////////////////////////////////////////////////////////////////////////////////////////////
236

  
237
  public static void setMeshState(int ordinal, int state)
238
    {
239
    if( ordinal>=0 && ordinal<mNumObjects ) mObjects.get(ordinal).setMeshState(state);
240
    }
241

  
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

  
244
  public static int getMeshState(int ordinal)
245
    {
246
    return (ordinal>=0 && ordinal<mNumObjects) ? mObjects.get(ordinal).getMeshState() : MESH_NICE;
247
    }
248

  
249
///////////////////////////////////////////////////////////////////////////////////////////////////
250

  
251
  public static void saveMeshState(SharedPreferences.Editor editor)
252
    {
253
    for(int i=0; i<mNumObjects; i++)
254
      {
255
      RubikObject obj = getObject(i);
256

  
257
      if( obj!=null )
258
        {
259
        String name = obj.getUpperName();
260
        editor.putInt("rol_"+name, obj.getMeshState() );
261
        }
262
      }
263
    }
264

  
265 234
///////////////////////////////////////////////////////////////////////////////////////////////////
266 235

  
267 236
  public static boolean thereAreLockedObjects()
......
437 406
    if( USE_IAP && justStarted ) restoreFreedObjects(preferences);
438 407
    }
439 408

  
440
///////////////////////////////////////////////////////////////////////////////////////////////////
441

  
442
  public static void restoreMeshState(SharedPreferences preferences)
443
    {
444
    for(int i=0; i<mNumObjects; i++)
445
      {
446
      RubikObject obj = getObject(i);
447

  
448
      if( obj!=null )
449
        {
450
        String name  = obj.getUpperName();
451
        int meshState= preferences.getInt("rol_"+name,MESH_NICE);
452
        obj.setMeshState(meshState);
453
        }
454
      }
455
    }
456

  
457 409
///////////////////////////////////////////////////////////////////////////////////////////////////
458 410

  
459 411
  public static void firstUpgradeMarkAllSolvedAsFree()
src/main/java/org/distorted/patternui/PatternActivity.java
9 9

  
10 10
package org.distorted.patternui;
11 11

  
12
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
13

  
14 12
import android.content.SharedPreferences;
15 13
import android.os.Build;
16 14
import android.os.Bundle;
......
51 49
    private static final int ACTIVITY_NUMBER = 1;
52 50
    private static final float RATIO_INSET= 0.09f;
53 51

  
54
    private boolean mJustStarted;
55 52
    private static int mScreenWidth, mScreenHeight;
56 53
    private int mCurrentApiVersion;
57 54
    private int mHeightUpperBar;
......
68 65
      setContentView(R.layout.pattern);
69 66
      hideNavigationBar();
70 67

  
71
      mJustStarted = true;
72 68
      Bundle b = getIntent().getExtras();
73 69
      mObjectOrdinal = b!=null ? b.getInt("obj") : 0;
74 70

  
......
197 193
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
198 194
      restorePreferences(preferences);
199 195
      ScreenList.setScreen(this);
200

  
201
      if( mJustStarted )
202
        {
203
        mJustStarted = false;
204
        RubikObjectList.restoreMeshState(preferences);
205
        }
206 196
      }
207 197

  
208 198
///////////////////////////////////////////////////////////////////////////////////////////////////
......
302 292
      OSInterface os = view.getInterface();
303 293
      InitAssets asset = new InitAssets(jsonStream,meshStream,os);
304 294

  
305
      control.changeIfDifferent(mObjectOrdinal,name,MESH_NICE,iconMode,asset);
295
      control.changeIfDifferent(mObjectOrdinal,name,iconMode,asset);
306 296
      }
307 297
}
src/main/java/org/distorted/purchase/PurchaseActivity.java
224 224
      {
225 225
      if( object!=null )
226 226
        {
227
        int meshState          = object.getMeshState();
228 227
        int iconMode           = TwistyObject.MODE_NORM;
229 228
        InputStream jsonStream = object.getObjectStream(this);
230 229
        InputStream meshStream = object.getMeshStream(this);
231 230
        String name            = object.getUpperName();
232 231
        InitAssets asset       = new InitAssets(jsonStream,meshStream,null);
233
        control.changeIfDifferent(ordinal,name,meshState,iconMode,asset);
232
        control.changeIfDifferent(ordinal,name,iconMode,asset);
234 233
        }
235 234
      }
236 235

  
src/main/java/org/distorted/solverui/SolverActivity.java
9 9

  
10 10
package org.distorted.solverui;
11 11

  
12
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
13

  
14 12
import android.content.SharedPreferences;
15 13
import android.os.Build;
16 14
import android.os.Bundle;
......
201 199
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
202 200
      restorePreferences(preferences,mJustStarted);
203 201
      ScreenList.setScreen(this);
204

  
205
      if( mJustStarted )
206
        {
207
        mJustStarted = false;
208
        RubikObjectList.restoreMeshState(preferences);
209
        }
210 202
      }
211 203

  
212 204
///////////////////////////////////////////////////////////////////////////////////////////////////
......
231 223
        }
232 224

  
233 225
      RubikObjectList.savePreferences(editor);
234
      RubikObjectList.saveMeshState(editor);
235 226
      ScreenList.savePreferences(editor);
236 227
      SolverSurfaceView view = findViewById(R.id.solverSurfaceView);
237 228
      OSInterface os = view.getInterface();
......
330 321
      OSInterface os = view.getInterface();
331 322
      InitAssets asset = new InitAssets(jsonStream,meshStream,os);
332 323

  
333
      control.changeIfDifferent(mObjectOrdinal,name,MESH_NICE,iconMode,asset);
324
      control.changeIfDifferent(mObjectOrdinal,name,iconMode,asset);
334 325
      }
335 326

  
336 327
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/tutorials/TutorialActivity.java
37 37
import org.distorted.os.OSInterface;
38 38
import org.distorted.purchase.PurchaseActivity;
39 39

  
40
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
41

  
42 40
///////////////////////////////////////////////////////////////////////////////////////////////////
43 41

  
44 42
public class TutorialActivity extends AppCompatActivity
......
217 215
    private void changeIfDifferent(int ordinal,ObjectControl control)
218 216
      {
219 217
      RubikObject object = RubikObjectList.getObject(ordinal);
220
      int meshState = object!=null ? object.getMeshState() : MESH_NICE;
221 218
      int iconMode  = TwistyObject.MODE_NORM;
222 219
      InputStream jsonStream = object==null ? null : object.getObjectStream(this);
223 220
      InputStream meshStream = object==null ? null : object.getMeshStream(this);
......
225 222
      TutorialSurfaceView view = findViewById(R.id.tutorialSurfaceView);
226 223
      OSInterface os = view.getInterface();
227 224
      InitAssets asset = new InitAssets(jsonStream,meshStream,os);
228
      control.changeIfDifferent(ordinal,name,meshState,iconMode,asset);
225
      control.changeIfDifferent(ordinal,name,iconMode,asset);
229 226
      }
230 227

  
231 228
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff