Project

General

Profile

« Previous | Next » 

Revision 121f1ba9

Added by Leszek Koltunski 11 months ago

progress with shape icons.

View differences:

src/main/java/org/distorted/objects/RubikObjectCategories.java
35 35
    R.drawable.difficulty5,
36 36
    };
37 37

  
38
  public static final int[] CATEGORY_IMAGES =
39
    {
40
    R.drawable.difficulty1,
41
    R.drawable.difficulty2,
42
    R.drawable.difficulty3,
43
    R.drawable.difficulty4,
44
    R.drawable.difficulty5,
45
    };
46

  
47 38
  protected final int mNumCategories;
48 39
  protected int[] mIconIDs;
49 40
  protected String[] mTitles;
src/main/java/org/distorted/objects/RubikObjectCategoriesShape.java
9 9

  
10 10
package org.distorted.objects;
11 11

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

  
14
import org.distorted.main.R;
15

  
12 16
import java.util.Arrays;
13 17

  
14 18
///////////////////////////////////////////////////////////////////////////////////////////////////
......
64 68
  private int digestCategory(int cat)
65 69
    {
66 70
    int shape = (cat & 0x7);
67
    int axis  = (cat & 0x1f) >> 3;
68
    return (shape<<2) + axis;   // only shape and axis sorted by shape
71

  
72
    switch(shape)
73
      {
74
      case CATEGORY_SHAPE_HEX: int axis  = (cat & 0x1f) >> 3;
75
                               return (shape<<2) + axis;
76
      case CATEGORY_SHAPE_BAL: return (CATEGORY_SHAPE_OTH<<2);
77
      case CATEGORY_SHAPE_TET:
78
      case CATEGORY_SHAPE_OCT:
79
      case CATEGORY_SHAPE_DOD:
80
      case CATEGORY_SHAPE_ICO:
81
      case CATEGORY_SHAPE_OTH: return (shape<<2);
82
      }
83

  
84
    android.util.Log.e("D", "digestCategory: unknown shape "+shape);
85
    return 0;
86
    }
87

  
88

  
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90

  
91
  private int getImage(int cat)
92
    {
93
    int shape = (cat & 0x1f) >> 2;
94

  
95
    switch(shape)
96
      {
97
      case CATEGORY_SHAPE_HEX: int axis  = (cat & 0x3);
98
                                    if( axis==CATEGORY_AXIS_FACE>>3 ) return R.drawable.shape_hex_face;
99
                               else if( axis==CATEGORY_AXIS_CORN>>3 ) return R.drawable.shape_hex_corn;
100
                               else if( axis==CATEGORY_AXIS_EDGE>>3 ) return R.drawable.shape_hex_edge;
101
                               else                                   return R.drawable.shape_hex_other;
102
      case CATEGORY_SHAPE_BAL:
103
      case CATEGORY_SHAPE_TET:
104
      case CATEGORY_SHAPE_OCT:
105
      case CATEGORY_SHAPE_DOD:
106
      case CATEGORY_SHAPE_ICO:
107
      case CATEGORY_SHAPE_OTH: return R.drawable.shape_hex_other;
108
      }
109

  
110
    android.util.Log.e("D", "getImage: unknown shape "+shape);
111
    return 0;
69 112
    }
70 113

  
71 114
///////////////////////////////////////////////////////////////////////////////////////////////////
......
97 140
      RubikObject object = RubikObjectList.getObject(obj);
98 141
      int cat = object==null ? 0 : object.getCategory();
99 142
      int category = digestCategory(cat);
100
      mIconIDs[t] = CATEGORY_IMAGES[category%5];  //TODO
143
      mIconIDs[t] = getImage(category);
101 144
      }
102 145
    }
103 146
}

Also available in: Unified diff