-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMenu.java
More file actions
144 lines (132 loc) · 2.82 KB
/
CMenu.java
File metadata and controls
144 lines (132 loc) · 2.82 KB
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
package org.millardps.InventoryManagement;
import java.util.ArrayList;
public class CMenu {
private static ArrayList<CMenu> Menu = new ArrayList<CMenu>();
private static int CBarHeight;
private BI cMenu;
private String text;
private ArrayList<CMenu> cMenuOptions = new ArrayList<CMenu>();
private int siz;
private CMenu WrapCMenu;
private int height;
private boolean inCMenu;
private boolean isOn;
public CMenu(int size, String word){
if(Menu.isEmpty()){
cMenu = new BI(size, 20, 0, 0, true, false);
Menu.add(this);
text = word;
//drawText();
}
else{
BI b = Menu.get(Menu.size() - 1).getCMenu();
cMenu = new BI(size, 20, b.getSX()+size, 0, true, false);
Menu.add(this);
text = word;
}
siz = size;
height = (int) cMenu.getBuffImage().getHeight();
inCMenu = false;
isOn =false;
}
public boolean isOn(){
return isOn;
}
public void setIsOn(boolean k){
isOn = k;
}
public void setCBarHeight(int x){
CBarHeight = x;
}
public String getText(){
return text;
}
public void setText(String txt){
text = txt;
}
public BI getCMenu(){
return cMenu;
}
public void setInCMenu(boolean k){
inCMenu = k;
}
public boolean getInCMenu(){
return inCMenu;
}
public void setWrappingCMenu(CMenu m){
WrapCMenu = m;
}
public CMenu getWrappingCMenu(){
return WrapCMenu;
}
public boolean hasWrapper(){
if(WrapCMenu != null){
return true;
}
else{
return false;
}
}
public void add(CMenu k, boolean inCbar){
k.setInCMenu(true);
k.setWrappingCMenu(this);
if(inCbar){
int height = CBarHeight;
for(int i = 0; i< cMenuOptions.size(); i++){
height+=cMenuOptions.get(i).getCMenu().getBuffImage().getHeight();
}
k.getCMenu().setSY(height);
k.getCMenu().setSX(this.getCMenu().getSX());
}
else{
k.getCMenu().setSX(this.getCMenu().getSX() + this.getCMenu().getBuffImage().getWidth());
k.getCMenu().setSY(this.getCMenu().getSY() + this.getCMenu().getBuffImage().getHeight() * cMenuOptions.size() + 2);
}
cMenuOptions.add(k);
}
public void drawText(){
if(text != null){
for(int i = 0; i < Menu.size(); i++){
if(Menu.get(i) == this){
System.out.println("Drawn " + i );
break;
}
}
// uses xy coordinates relative to the BufferedImage
cMenu.getBuffImage().getGraphics().drawString(text, 0, 0 + 10);
}
else{
for(int i = 0; i < Menu.size(); i++){
if(Menu.get(i) == this){
if(Menu.get(i).getText() == null){
System.out.println("NULL " + i );
break;
}
}
}
}
}
public int centerTextX(){
int pL = text.length() * 10;
int padding = (siz - pL)/2;
return padding;
}
public int centerTextY(){
int pL= 10;
int padding = ( height- pL)/2;
return padding;
}
public void remove(CMenu k){
for(int i = 0; i< Menu.size(); i++){
if(Menu.get(i) == k){
Menu.remove(i);
}
}
}
public static ArrayList<CMenu> getMenus(){
return Menu;
}
public ArrayList<CMenu> getCMenuOptions(){
return cMenuOptions;
}
}