Project

General

Profile

« Previous | Next » 

Revision 0501a4b8

Added by Leszek Koltunski over 3 years ago

Transpose the Object Popup

View differences:

src/main/java/org/distorted/objects/ObjectList.java
210 210
  private final int[] mObjectSizes, mMaxLevels, mSmallIconIDs, mMediumIconIDs, mBigIconIDs, mHugeIconIDs, mResourceIDs;
211 211
  private final Class<? extends TwistyObject> mObjectClass;
212 212
  private final Movement mObjectMovementClass;
213
  private final int mColumn, mNumSizes;
213
  private final int mRow, mNumSizes;
214 214
  private final int mFOV;
215 215

  
216 216
  private static final ObjectList[] objects;
......
252 252
  private static void setUpColAndRow()
253 253
    {
254 254
    mIndices = new int[NUM_OBJECTS];
255
    mColCount= 0;
255
    mRowCount= 0;
256 256

  
257 257
    for(int obj=0; obj<NUM_OBJECTS; obj++)
258 258
      {
259
      mIndices[obj] = objects[obj].mColumn;
260
      if( mIndices[obj]>=mColCount ) mColCount = mIndices[obj]+1;
259
      mIndices[obj] = objects[obj].mRow;
260
      if( mIndices[obj]>=mRowCount ) mRowCount = mIndices[obj]+1;
261 261
      }
262 262

  
263
    mRowCount = 0;
263
    mColCount = 0;
264 264

  
265
    for(int col=0; col<mColCount; col++)
265
    for(int row=0; row<mRowCount; row++)
266 266
      {
267
      int numObjects = computeNumObjectsInColumn(col);
268
      if( numObjects>mRowCount ) mRowCount = numObjects;
267
      int numObjects = computeNumObjectsInRow(row);
268
      if( numObjects>mColCount ) mColCount = numObjects;
269 269
      }
270 270
    }
271 271

  
272 272
///////////////////////////////////////////////////////////////////////////////////////////////////
273 273

  
274
  private static int computeNumObjectsInColumn(int column)
274
  private static int computeNumObjectsInRow(int row)
275 275
    {
276 276
    int num=0;
277 277

  
278 278
    for(int object=0; object<NUM_OBJECTS; object++)
279 279
      {
280
      if( objects[object].mColumn == column )
280
      if( objects[object].mRow == row )
281 281
        {
282 282
        num += objects[object].mNumSizes;
283 283
        }
......
492 492

  
493 493
///////////////////////////////////////////////////////////////////////////////////////////////////
494 494

  
495
  ObjectList(int[][] info, Class<? extends TwistyObject> object , Movement movement, int column, int fov)
495
  ObjectList(int[][] info, Class<? extends TwistyObject> object , Movement movement, int row, int fov)
496 496
    {
497 497
    mNumSizes = info.length;
498 498

  
......
517 517

  
518 518
    mObjectClass         = object;
519 519
    mObjectMovementClass = movement;
520
    mColumn              = column;
520
    mRow                 = row;
521 521
    mFOV                 = fov;
522 522
    }
523 523

  
src/main/java/org/distorted/states/RubikStatePlay.java
238 238
    objectGrid.setColumnCount(mColCount);
239 239
    objectGrid.setRowCount(mRowCount);
240 240

  
241
    int[] nextInColumn = new int[mColCount];
241
    int[] nextInRow = new int[mRowCount];
242 242

  
243 243
    for(int row=0; row<mRowCount; row++)
244 244
      {
245 245
      rowSpecs[row] = GridLayout.spec(row);
246
      nextInRow[row]= 0;
246 247
      }
247 248
    for(int col=0; col<mColCount; col++)
248 249
      {
249 250
      colSpecs[col] = GridLayout.spec(col);
250
      nextInColumn[col] =0;
251 251
      }
252 252

  
253 253
    mObjectPopup = new PopupWindow(act);
......
260 260
    int margin = (int)(width*RubikActivity.LARGE_MARGIN);
261 261
    mObjectSize = (int)(cubeWidth + 2*margin + 0.5f);
262 262

  
263
    for(int object = 0; object< ObjectList.NUM_OBJECTS; object++)
263
    for(int object=0; object< ObjectList.NUM_OBJECTS; object++)
264 264
      {
265 265
      final ObjectList list = ObjectList.getObject(object);
266 266
      final int[] sizes = list.getSizes();
267 267
      int[] icons = list.getIconIDs();
268 268
      int len = sizes.length;
269 269
      final int obj = object;
270
      int col = indices[object];
270
      int row = indices[object];
271 271

  
272 272
      for(int i=0; i<len; i++)
273 273
        {
......
293 293
            }
294 294
          });
295 295

  
296
        GridLayout.LayoutParams params = new GridLayout.LayoutParams(rowSpecs[nextInColumn[col]],colSpecs[col]);
296
        GridLayout.LayoutParams params = new GridLayout.LayoutParams(rowSpecs[row],colSpecs[nextInRow[row]]);
297 297
        params.bottomMargin = margin;
298 298
        params.topMargin    = margin;
299 299
        params.leftMargin   = margin;
300 300
        params.rightMargin  = margin;
301 301

  
302
        nextInColumn[col]++;
302
        nextInRow[row]++;
303 303

  
304 304
        objectGrid.addView(button, params);
305 305
        }

Also available in: Unified diff