1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2024 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.objects;
|
11
|
|
12
|
import static org.distorted.main.MainSettingsPopup.*;
|
13
|
|
14
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
15
|
|
16
|
public class RubikObjectCategories
|
17
|
{
|
18
|
private final int mNumCategories;
|
19
|
private int[][] mObjectIndices;
|
20
|
private int[] mIconIDs;
|
21
|
private String[] mTitles;
|
22
|
|
23
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
24
|
|
25
|
public RubikObjectCategories(int sortMode)
|
26
|
{
|
27
|
switch(sortMode)
|
28
|
{
|
29
|
case SORT_CATEGORY : buildSortCategory(); break;
|
30
|
case SORT_DIFFICULTY: buildSortDifficulty(); break;
|
31
|
case SORT_AUTHOR : buildSortAuthor(); break;
|
32
|
case SORT_YEAR : buildSortYear(); break;
|
33
|
}
|
34
|
|
35
|
mNumCategories = mObjectIndices.length;
|
36
|
|
37
|
switch(sortMode)
|
38
|
{
|
39
|
case SORT_CATEGORY : buildIconsCategory(); break;
|
40
|
case SORT_DIFFICULTY: buildIconsDifficulty(); break;
|
41
|
case SORT_AUTHOR : buildTitleAuthor(); break;
|
42
|
case SORT_YEAR : buildTitleYear(); break;
|
43
|
}
|
44
|
}
|
45
|
|
46
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47
|
|
48
|
private void buildSortCategory()
|
49
|
{
|
50
|
|
51
|
}
|
52
|
|
53
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54
|
|
55
|
private void buildSortDifficulty()
|
56
|
{
|
57
|
|
58
|
}
|
59
|
|
60
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61
|
|
62
|
private void buildSortAuthor()
|
63
|
{
|
64
|
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
|
69
|
private void buildSortYear()
|
70
|
{
|
71
|
|
72
|
}
|
73
|
|
74
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
75
|
|
76
|
private void buildIconsCategory()
|
77
|
{
|
78
|
|
79
|
}
|
80
|
|
81
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
82
|
|
83
|
private void buildIconsDifficulty()
|
84
|
{
|
85
|
|
86
|
}
|
87
|
|
88
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
89
|
|
90
|
private void buildTitleAuthor()
|
91
|
{
|
92
|
mTitles = new String[mNumCategories];
|
93
|
|
94
|
for(int t=0; t<mNumCategories; t++)
|
95
|
{
|
96
|
int obj = mObjectIndices[t][0];
|
97
|
RubikObject object = RubikObjectList.getObject(obj);
|
98
|
|
99
|
}
|
100
|
}
|
101
|
|
102
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
103
|
|
104
|
private void buildTitleYear()
|
105
|
{
|
106
|
|
107
|
}
|
108
|
|
109
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
110
|
// PUBLIC API
|
111
|
|
112
|
public int getNumCategories()
|
113
|
{
|
114
|
return mNumCategories;
|
115
|
}
|
116
|
|
117
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
118
|
|
119
|
public boolean hasIcons()
|
120
|
{
|
121
|
return mIconIDs!=null;
|
122
|
}
|
123
|
|
124
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
125
|
|
126
|
public int getIconId(int category)
|
127
|
{
|
128
|
return ( mIconIDs!=null && category>=0 && category<mNumCategories ) ? mIconIDs[category] : -1;
|
129
|
}
|
130
|
|
131
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
132
|
|
133
|
public String getTitle(int category)
|
134
|
{
|
135
|
return (mTitles!=null && category>=0 && category<mNumCategories) ? mTitles[category] : null;
|
136
|
}
|
137
|
|
138
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
139
|
|
140
|
public int getNumObjects(int category)
|
141
|
{
|
142
|
return (category>=0 && category<mNumCategories) ? mObjectIndices[category].length : 0;
|
143
|
}
|
144
|
|
145
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
146
|
|
147
|
public int getObjectIndex(int category, int index)
|
148
|
{
|
149
|
if( category>=0 && category<mNumCategories )
|
150
|
{
|
151
|
int[] objects = mObjectIndices[category];
|
152
|
if( index>=0 && index<objects.length ) return objects[index];
|
153
|
}
|
154
|
|
155
|
return -1;
|
156
|
}
|
157
|
|
158
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
159
|
|
160
|
public int getCategory(int objectIndex)
|
161
|
{
|
162
|
int numC = mObjectIndices.length;
|
163
|
|
164
|
for(int c=0; c<numC; c++)
|
165
|
{
|
166
|
int[] objects = mObjectIndices[c];
|
167
|
int len = objects.length;
|
168
|
|
169
|
for(int o=0; o<len; o++)
|
170
|
if( o==objectIndex ) return c;
|
171
|
}
|
172
|
|
173
|
return -1;
|
174
|
}
|
175
|
|
176
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
177
|
|
178
|
public int getPosInCat(int category, int objectIndex)
|
179
|
{
|
180
|
int[] objects = mObjectIndices[category];
|
181
|
int len = objects.length;
|
182
|
|
183
|
for(int o=0; o<len; o++)
|
184
|
if( o==objectIndex ) return o;
|
185
|
|
186
|
return -1;
|
187
|
}
|
188
|
}
|