-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathGuiTalkingSelection.java
85 lines (80 loc) · 2.51 KB
/
GuiTalkingSelection.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
package net.minecraft.src;
import java.util.Iterator;
import java.util.Vector;
import net.minecraft.client.Minecraft;
public class GuiTalkingSelection extends GuiTalking {
private final int BUTTON_HEIGHT=20;
private final int BUTTON_DEFAULT_WIDTH=200;
public GuiTalkingSelection(SessionBase script,String[] preLoadMsg,EnumFaces facePar){
this(script,facePar);
this.Mesg=preLoadMsg;
this.textSpeed=0;
this.face=facePar;
}
public GuiTalkingSelection(SessionBase script,EnumFaces facePar) {
super(script);
SessionCondition condSession=(SessionCondition)mainScript;
this.sessionOptions=condSession.optionText;
waitingForOption=true;
this.face=facePar;
CharaImagePath = mainScript.getFacePath() + (face.toString())
+ ".png";
// TODO Auto-generated constructor stub
}
public void initGui()
{
controlList.clear();
this.updateControlList();
}
protected void updateControlList(){
final int heightInit=height / 4;
final int widthPos;
final int diff=24;
int buttonHeightPos=heightInit+48;
if (this.sessionOptions==null) controlList.clear();
else{
int contSize=sessionOptions.size();
int buttonWidth=getButtonWidth(sessionOptions);
widthPos=(width-buttonWidth)/2;
switch (contSize){
case 1:
buttonHeightPos+=diff;
case 2:
buttonHeightPos+=(diff/2);
}
for (int i=0;i<contSize && i<3;i++){
controlList.add(new GuiButton(i+1,widthPos, buttonHeightPos,buttonWidth,BUTTON_HEIGHT,this.sessionOptions.get(i)));
buttonHeightPos+=diff;
}
}
}
private int getButtonWidth(Vector<String> parmOptions) {
int result=BUTTON_DEFAULT_WIDTH;
int tmp;
for (int i=0;i<parmOptions.size();i++){
tmp=this.fontRenderer.getStringWidth(parmOptions.get(i));
if (tmp>result) result=tmp;
}
return result;
}
protected void actionPerformed(GuiButton par1GuiButton)
{
((SessionCondition)this.mainScript).optionToken(par1GuiButton.id-1);
testAndSwapGui();
}
protected boolean testAndSwapGui() {
boolean result = false;
if (!(mainScript instanceof SessionCondition)) {
Minecraft Corl = ModLoader.getMinecraftInstance();
Corl.displayGuiScreen(null);
Corl.displayGuiScreen(new GuiTalking(this.mainScript));
result=true;
}
return result;
}
public void updateScreen() {
super.updateScreen();
if (this.msgCompletedIndex>=0)this.msgShowCounts=this.Mesg[this.msgCompletedIndex].length();
else this.msgShowCounts=this.Mesg[0].length();
}
}