-
Notifications
You must be signed in to change notification settings - Fork 4
/
OCardBase.java
261 lines (234 loc) · 5.83 KB
/
OCardBase.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import javax.swing.JScrollPane;
public class OCardBase extends OObject {
OStack stack;
BufferedImage pict;
Boolean showPict = true;
MyLabel label;
OPicture picture;
String bitmapName;
boolean changed;
//ボタン、フィールド情報
ArrayList<OObject> partsList;
ArrayList<OButton> btnList;
ArrayList<OField> fldList;
ArrayList<JScrollPane> paneList = new ArrayList<JScrollPane>();
@Override
public void clean(){
//stack.mainPane.removeAll(); //すでに新しいスタックを読み込んでいるのでremoveしてはいけない
stack = null;
pict = null;
label = null;
picture = null;
bitmapName = null;
partsList = null;
btnList = null;
fldList = null;
paneList = null;
}
public OCardBase(OStack st){
stack = st;
}
static void buidParts(OCardBase cdbase){
for(int i=cdbase.partsList.size()-1; i>=0; i--){
OObject obj = cdbase.partsList.get(i);
if(obj.getClass()==OButton.class){
OButton.buildOButton((OButton)obj);
}
else{
OField.buildOField((OField)obj);
}
}
}
public OButton GetBtnbyId(int btnId) {
for(int i=0; i<btnList.size(); i++){
if(btnId==btnList.get(i).id)
return btnList.get(i);
}
return null;
}
public OButton GetBtnbyNum(int number) {
if(number-1>=0 && number-1<btnList.size())
{
return btnList.get(number-1);
}
return null;
}
public OButton GetBtn(String name) {
if(name.equals("Continue Saved Game")){
System.out.println("Continue Saved Game");
}
for(int i=0; i<btnList.size(); i++){
if(0==btnList.get(i).name.compareToIgnoreCase(name))
return btnList.get(i);
}
return null;
}
public OField GetFldbyId(int fldId) {
for(int i=0; i<fldList.size(); i++){
if(fldId==fldList.get(i).id)
return fldList.get(i);
}
return null;
}
public OField GetFldbyNum(int number) {
if(number-1>=0 && number-1<fldList.size())
{
return fldList.get(number-1);
}
return null;
}
public OField GetFld(String name) {
for(int i=0; i<fldList.size(); i++){
if(0==fldList.get(i).name.compareToIgnoreCase(name))
return fldList.get(i);
}
return null;
}
public OObject GetPartbyId(int pid) {
for(int i=0; i<partsList.size(); i++){
if(pid==partsList.get(i).id)
return partsList.get(i);
}
return null;
}
OBackground getBg(){
OBackground bg = null;
if(this.objectType.equals("background")) bg = (OBackground)this;
else if(this.objectType.equals("card")) {
OCard cd = (OCard)this;
if(cd.bg != null) {bg = cd.bg;}
else { bg = cd.stack.GetBackgroundbyId(cd.bgid); }
}
return bg;
}
public OButton GetBgBtnbyId(int btnId) {
OBackground bg = getBg();
for(int i=0; i<bg.btnList.size(); i++){
if(btnId==bg.btnList.get(i).id)
return bg.btnList.get(i);
}
return null;
}
public OButton GetBgBtnbyNum(int number) {
OBackground bg = getBg();
if(number-1>=0 && number-1<bg.btnList.size())
{
return bg.btnList.get(number-1);
}
return null;
}
public OButton GetBgBtn(String name) {
OBackground bg = getBg();
for(int i=0; i<bg.btnList.size(); i++){
if(0==bg.btnList.get(i).name.compareToIgnoreCase(name))
return bg.btnList.get(i);
}
return null;
}
public OField GetBgFldbyId(int fldId) {
OBackground bg = getBg();
for(int i=0; i<bg.fldList.size(); i++){
if(fldId==bg.fldList.get(i).id)
return bg.fldList.get(i);
}
return null;
}
public OField GetBgFldbyNum(int number) {
OBackground bg = getBg();
if(number-1>=0 && number-1<bg.fldList.size())
{
return bg.fldList.get(number-1);
}
return null;
}
public OField GetBgFld(String name) {
OBackground bg = getBg();
for(int i=0; i<bg.fldList.size(); i++){
if(0==bg.fldList.get(i).name.compareToIgnoreCase(name))
return bg.fldList.get(i);
}
return null;
}
public int GetNumberof(OButton obj) {
for(int number=0; number < btnList.size(); number++)
{
if(btnList.get(number).id==obj.id){
return number+1;
}
}
return 0;
}
public int GetNumberof(OField obj) {
for(int number=0; number < fldList.size(); number++)
{
if(fldList.get(number).id==obj.id){
return number+1;
}
}
return 0;
}
public int GetNumberofParts(OObject obj) {
for(int number=0; number < partsList.size(); number++)
{
if(partsList.get(number).id==obj.id &&
partsList.get(number).objectType.equals(obj.objectType)){
return number+1;
}
}
return 0;
}
public void removeData(){
PCARDFrame.pc.mainPane.removeAll();
for(int i=0; i<btnList.size(); i++) {
if(btnList.get(i).btn!=null) {
//PCARD.pc.mainPane.remove(btnList.get(i).btn);
btnList.get(i).btn.btnData = null;
btnList.get(i).btn=null;
}
if(btnList.get(i).chkbox!=null) {
//PCARD.pc.mainPane.remove(btnList.get(i).chkbox);
btnList.get(i).chkbox.btnData = null;
btnList.get(i).chkbox=null;
}
if(btnList.get(i).radio!=null) {
//PCARD.pc.mainPane.remove(btnList.get(i).radio);
btnList.get(i).radio.btnData = null;
btnList.get(i).radio=null;
}
if(btnList.get(i).popup!=null) {
//PCARD.pc.mainPane.remove(btnList.get(i).popup);
btnList.get(i).popup.btnData = null;
btnList.get(i).popup=null;
}
//btnList.get(i).card = null;
//btnList.get(i).bkgd = null;
}
for(int i=0; i<fldList.size(); i++) {
if(fldList.get(i).fld!=null){
//PCARD.pc.mainPane.remove(fldList.get(i).fld);
fldList.get(i).fld.fldData = null;
fldList.get(i).fld=null;
}
//fldList.get(i).card = null;
//fldList.get(i).bkgd = null;
}
for(int i=0; i<paneList.size(); i++) {
//PCARD.pc.mainPane.remove(paneList.get(i));
}
for(int i=0; i<paneList.size(); i++) {
paneList.remove(i);
}
if(label!=null) {
//PCARD.pc.mainPane.remove(label);
label.cd = null;
label=null;
pict=null;
picture=null;
}
for(int i=0;i<OButton.btnGroup.length; i++){
OButton.btnGroup[i] = null;
}
}
}