mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 07:17:27 +00:00
Revamp Sound Selection Menu
This commit is contained in:
1 parent
14b430089e
commit
b3846e32c8
8 files changed
+108
-380
No files matched your search
@@ -4,10 +4,8 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||
import noppes.npcs.client.gui.util.IGuiData;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.Line;
|
||||
import noppes.npcs.controllers.data.Lines;
|
||||
@@ -15,12 +13,12 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData
|
||||
public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData, ISubGuiListener, ITextfieldListener
|
||||
{
|
||||
private Lines lines;
|
||||
private GuiNpcTextField field;
|
||||
private GuiNpcSoundSelection gui;
|
||||
|
||||
private int selectedId = -1;
|
||||
private GuiSoundSelection gui;
|
||||
|
||||
public GuiNPCLinesEdit(EntityNPCInterface npc, Lines lines)
|
||||
{
|
||||
super(npc);
|
||||
@@ -35,57 +33,63 @@ public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData
|
||||
String text = "";
|
||||
String sound = "";
|
||||
if(lines.lines.containsKey(i)){
|
||||
Line line = lines.lines.get(i);
|
||||
text = line.text;
|
||||
sound = line.sound;
|
||||
Line line = lines.lines.get(i);
|
||||
text = line.getText();
|
||||
sound = line.getSound();
|
||||
}
|
||||
addTextField(new GuiNpcTextField(i,this, fontRendererObj, guiLeft + 4, guiTop + 4 + i * 24, 200, 20,text));
|
||||
addTextField(new GuiNpcTextField(i + 8,this, fontRendererObj, guiLeft + 208, guiTop + 4 + i * 24, 146, 20,sound));
|
||||
addButton(new GuiNpcButton(i, guiLeft + 358, guiTop + 4 + i * 24, 60, 20, "gui.select"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
field = getTextField(button.id + 8);
|
||||
gui = new GuiNpcSoundSelection(this, field.getText());
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
selectedId = button.id + 8;
|
||||
setSubGui(new GuiSoundSelection(getTextField(selectedId).getText()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementClicked() {
|
||||
field.setText(gui.getSelected());
|
||||
saveLines();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
npc.advanced.readToNBT(compound);
|
||||
initGui();
|
||||
}
|
||||
|
||||
private void saveLines(){
|
||||
HashMap<Integer,Line> lines = new HashMap<Integer,Line>();
|
||||
for(int i = 0; i < 8; i++){
|
||||
GuiNpcTextField tf = getTextField(i);
|
||||
GuiNpcTextField tf2 = getTextField(i + 8);
|
||||
if(!tf.isEmpty()){
|
||||
Line line = new Line();
|
||||
line.text = tf.getText();
|
||||
line.sound = tf2.getText();
|
||||
lines.put(i, line);
|
||||
}
|
||||
|
||||
}
|
||||
this.lines.lines = lines;
|
||||
}
|
||||
|
||||
|
||||
private void saveLines(){
|
||||
HashMap<Integer,Line> lines = new HashMap<Integer,Line>();
|
||||
for(int i = 0; i < 8; i++){
|
||||
GuiNpcTextField tf = getTextField(i);
|
||||
GuiNpcTextField tf2 = getTextField(i + 8);
|
||||
if(!tf.isEmpty() || !tf2.isEmpty()){
|
||||
Line line = new Line();
|
||||
line.setText(tf.getText());
|
||||
line.setSound(tf2.getText());
|
||||
lines.put(i, line);
|
||||
}
|
||||
|
||||
}
|
||||
this.lines.lines = lines;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
saveLines();
|
||||
Client.sendData(EnumPacketServer.MainmenuAdvancedSave, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
GuiSoundSelection gss = (GuiSoundSelection) subgui;
|
||||
if(gss.selectedResource != null) {
|
||||
getTextField(selectedId).setText(gss.selectedResource.toString());
|
||||
saveLines();
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
saveLines();
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.audio.SoundRegistry;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class GuiNpcSoundSelection extends GuiNPCInterface {
|
||||
|
||||
public GuiNPCStringSlot slot;
|
||||
public String domain;
|
||||
private final GuiScreen parent;
|
||||
public GuiSelectionListener listener;
|
||||
|
||||
private String up = "..<" + StatCollector.translateToLocal("gui.up") + ">..";
|
||||
|
||||
private HashMap<String,List<String>> domains = new HashMap<String,List<String>>();
|
||||
|
||||
public GuiNpcSoundSelection(GuiScreen parent, String sound)
|
||||
{
|
||||
SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
|
||||
SoundRegistry registry = ObfuscationReflectionHelper.getPrivateValue(SoundHandler.class, handler, 4);
|
||||
|
||||
Set<ResourceLocation> set = registry.getKeys();
|
||||
for(ResourceLocation location : set){
|
||||
List<String> list = domains.get(location.getResourceDomain());
|
||||
if(list == null)
|
||||
domains.put(location.getResourceDomain(), list = new ArrayList<String>());
|
||||
list.add(location.getResourcePath());
|
||||
domains.put(location.getResourceDomain(), list);
|
||||
}
|
||||
drawDefaultBackground = false;
|
||||
this.parent = parent;
|
||||
if(parent instanceof GuiSelectionListener)
|
||||
listener = (GuiSelectionListener) parent;
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
String ss = "Current domain: " + domain;
|
||||
if(domain == null)
|
||||
ss = "Select domain";
|
||||
addLabel(new GuiNpcLabel(0,ss, width / 2 - (this.fontRendererObj.getStringWidth(ss)/2), 20, 0xffffff));
|
||||
|
||||
Collection<String> col = domains.keySet();
|
||||
|
||||
if(domain != null){
|
||||
col = domains.get(domain);
|
||||
if(!col.contains(up))
|
||||
col.add(up);
|
||||
}
|
||||
slot = new GuiNPCStringSlot(col, this, false, 18);
|
||||
slot.registerScrollButtons(4, 5);
|
||||
if(domain != null){
|
||||
this.addButton(new GuiNpcButton(1, width / 2 - 100, height - 27,198, 20, "gui.play"));
|
||||
this.addButton(new GuiNpcButton(3, width / 2 - 100, height - 50,98, 20, "gui.done"));
|
||||
}
|
||||
else
|
||||
this.addButton(new GuiNpcButton(4, width / 2 - 100, height - 50,98, 20, "gui.open"));
|
||||
|
||||
this.addButton(new GuiNpcButton(2, width / 2 + 2, height - 50,98, 20, "gui.cancel"));
|
||||
}
|
||||
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
slot.drawScreen(i, j, f);
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
public void doubleClicked() {
|
||||
if(slot.selected == null || slot.selected.isEmpty())
|
||||
return;
|
||||
if(slot.selected.equals(up)){
|
||||
domain = null;
|
||||
initGui();
|
||||
}
|
||||
else if(domain == null){
|
||||
domain = slot.selected;
|
||||
initGui();
|
||||
}
|
||||
else{
|
||||
if(parent instanceof GuiNPCInterface){
|
||||
((GuiNPCInterface)parent).elementClicked();
|
||||
}
|
||||
else if(this.parent instanceof GuiNPCInterface2){
|
||||
((GuiNPCInterface2)parent).elementClicked();
|
||||
}
|
||||
close();
|
||||
NoppesUtil.openGUI(player, parent);
|
||||
}
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
super.actionPerformed(guibutton);
|
||||
if(guibutton.id == 1){
|
||||
MusicController.Instance.stopMusic();
|
||||
MusicController.Instance.playSound(getSelected(), (float)player.posX, (float)player.posY, (float)player.posZ);
|
||||
}
|
||||
if(guibutton.id == 2){
|
||||
close();
|
||||
NoppesUtil.openGUI(player, parent);
|
||||
}
|
||||
if(guibutton.id == 3){
|
||||
if(slot.selected == null || slot.selected.equals(up))
|
||||
return;
|
||||
doubleClicked();
|
||||
}
|
||||
if(guibutton.id == 4){
|
||||
doubleClicked();
|
||||
}
|
||||
}
|
||||
public void save() {
|
||||
|
||||
}
|
||||
public void close() {
|
||||
this.save();
|
||||
super.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getSelected(){
|
||||
if(slot.selected == null || slot.selected.isEmpty())
|
||||
return "";
|
||||
return domain + ":" + slot.selected;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
|
||||
import noppes.npcs.client.gui.global.GuiNPCQuestSelection;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
@@ -17,7 +18,6 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
|
||||
public int dialogCategoryID;
|
||||
public Dialog dialog;
|
||||
private final GuiNPCManageDialogs parent;
|
||||
private GuiNpcSoundSelection gui;
|
||||
private GuiNPCQuestSelection questSelection;
|
||||
|
||||
public SubGuiNpcDialog(GuiNPCManageDialogs parent, Dialog dialog, int catId)
|
||||
@@ -79,7 +79,7 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
|
||||
if(!dialog.mail.subject.isEmpty())
|
||||
getButton(13).setDisplayText(dialog.mail.subject);
|
||||
}
|
||||
|
||||
|
||||
public void buttonEvent(GuiButton guibutton)
|
||||
{
|
||||
int id = guibutton.id;
|
||||
@@ -106,9 +106,7 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
|
||||
initGui();
|
||||
}
|
||||
if(id == 9 && dialog.id >= 0){
|
||||
gui = new GuiNpcSoundSelection(getParent(), getTextField(2).getText());
|
||||
gui.listener = this;
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
setSubGui(new GuiSoundSelection((getTextField(2).getText())));
|
||||
}
|
||||
if(id == 10){
|
||||
setSubGui(new SubGuiNpcCommand(dialog.command));
|
||||
@@ -169,12 +167,14 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
|
||||
else if(subgui instanceof SubGuiMailmanSendSetup){
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementClicked(){
|
||||
getTextField(2).setText(gui.getSelected());
|
||||
unFocused(getTextField(2));
|
||||
else if (subgui instanceof GuiSoundSelection){
|
||||
GuiSoundSelection gss = (GuiSoundSelection) subgui;
|
||||
if(gss.selectedResource != null) {
|
||||
getTextField(2).setText(gss.selectedResource.toString());
|
||||
unFocused(getTextField(2));
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,12 +3,13 @@ package noppes.npcs.client.gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.DataStats;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
|
||||
public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfieldListener
|
||||
public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfieldListener, ISubGuiListener
|
||||
{
|
||||
private DataStats stats;
|
||||
private GuiNpcSoundSelection gui;
|
||||
private GuiNpcTextField soundSelected = null;
|
||||
|
||||
public SubGuiNpcRangeProperties(DataStats stats)
|
||||
{
|
||||
@@ -112,20 +113,13 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementClicked(){
|
||||
getTextField(7).setText(gui.getSelected());
|
||||
unFocused(getTextField(7));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
int id = guibutton.id;
|
||||
if(id == 7)
|
||||
{
|
||||
gui = new GuiNpcSoundSelection(parent, getTextField(7).getText());
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
}
|
||||
if(id == 7){
|
||||
soundSelected = getTextField(7);
|
||||
setSubGui(new GuiSoundSelection(soundSelected.getText()));
|
||||
}
|
||||
if(id == 66)
|
||||
{
|
||||
close();
|
||||
@@ -134,4 +128,13 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
|
||||
stats.aimWhileShooting = ((GuiNpcButtonYesNo)guibutton).getBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
GuiSoundSelection gss = (GuiSoundSelection) subgui;
|
||||
if(gss.selectedResource != null) {
|
||||
soundSelected.setText(gss.selectedResource.toString());
|
||||
unFocused(soundSelected);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.audio.SoundRegistry;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SubGuiNpcSoundSelection extends SubGuiInterface {
|
||||
|
||||
public GuiNPCStringSlot slot;
|
||||
public String domain;
|
||||
private final GuiScreen parent;
|
||||
public GuiSelectionListener listener;
|
||||
|
||||
private String up = "..<" + StatCollector.translateToLocal("gui.up") + ">..";
|
||||
|
||||
private HashMap<String,List<String>> domains = new HashMap<String,List<String>>();
|
||||
|
||||
public SubGuiNpcSoundSelection(GuiScreen parent, String sound)
|
||||
{
|
||||
SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
|
||||
SoundRegistry registry = ObfuscationReflectionHelper.getPrivateValue(SoundHandler.class, handler, 4);
|
||||
|
||||
Set<ResourceLocation> set = registry.getKeys();
|
||||
for(ResourceLocation location : set){
|
||||
List<String> list = domains.get(location.getResourceDomain());
|
||||
if(list == null)
|
||||
domains.put(location.getResourceDomain(), list = new ArrayList<String>());
|
||||
list.add(location.getResourcePath());
|
||||
domains.put(location.getResourceDomain(), list);
|
||||
}
|
||||
drawDefaultBackground = false;
|
||||
this.parent = parent;
|
||||
if(parent instanceof GuiSelectionListener)
|
||||
listener = (GuiSelectionListener) parent;
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
String ss = "Current domain: " + domain;
|
||||
if(domain == null)
|
||||
ss = "Select domain";
|
||||
addLabel(new GuiNpcLabel(0,ss, width / 2 - (this.fontRendererObj.getStringWidth(ss)/2), 20, 0xffffff));
|
||||
|
||||
Collection<String> col = domains.keySet();
|
||||
|
||||
if(domain != null){
|
||||
col = domains.get(domain);
|
||||
if(!col.contains(up))
|
||||
col.add(up);
|
||||
}
|
||||
slot = new GuiNPCStringSlot(col, this, false, 18);
|
||||
slot.registerScrollButtons(4, 5);
|
||||
if(domain != null){
|
||||
this.addButton(new GuiNpcButton(1, width / 2 - 100, height - 27,198, 20, "gui.play"));
|
||||
this.addButton(new GuiNpcButton(3, width / 2 - 100, height - 50,98, 20, "gui.done"));
|
||||
}
|
||||
else
|
||||
this.addButton(new GuiNpcButton(4, width / 2 - 100, height - 50,98, 20, "gui.open"));
|
||||
|
||||
this.addButton(new GuiNpcButton(2, width / 2 + 2, height - 50,98, 20, "gui.cancel"));
|
||||
}
|
||||
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
slot.drawScreen(i, j, f);
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
public void doubleClicked() {
|
||||
if(slot.selected == null || slot.selected.isEmpty())
|
||||
return;
|
||||
if(slot.selected.equals(up)){
|
||||
domain = null;
|
||||
initGui();
|
||||
}
|
||||
else if(domain == null){
|
||||
domain = slot.selected;
|
||||
initGui();
|
||||
}
|
||||
else{
|
||||
if(parent instanceof GuiNPCInterface){
|
||||
((GuiNPCInterface)parent).elementClicked();
|
||||
}
|
||||
else if(this.parent instanceof GuiNPCInterface2){
|
||||
((GuiNPCInterface2)parent).elementClicked();
|
||||
}
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
super.actionPerformed(guibutton);
|
||||
if(guibutton.id == 1){
|
||||
MusicController.Instance.stopMusic();
|
||||
MusicController.Instance.playSound(getSelected(), (float)player.posX, (float)player.posY, (float)player.posZ);
|
||||
}
|
||||
if(guibutton.id == 2){
|
||||
close();
|
||||
}
|
||||
if(guibutton.id == 3){
|
||||
if(slot.selected == null || slot.selected.equals(up))
|
||||
return;
|
||||
doubleClicked();
|
||||
}
|
||||
if(guibutton.id == 4){
|
||||
doubleClicked();
|
||||
}
|
||||
}
|
||||
public void save() {
|
||||
|
||||
}
|
||||
|
||||
public void close() {
|
||||
this.save();
|
||||
super.close();
|
||||
}
|
||||
|
||||
public String getSelected(){
|
||||
if(slot.selected == null || slot.selected.isEmpty())
|
||||
return "";
|
||||
return domain + ":" + slot.selected;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,15 +3,13 @@ package noppes.npcs.client.gui.advanced;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.GuiNpcSoundSelection;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldListener
|
||||
public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldListener, ISubGuiListener
|
||||
{
|
||||
private GuiNpcSoundSelection gui;
|
||||
private GuiNpcTextField selectedField;
|
||||
public GuiNPCSoundsMenu(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
@@ -23,37 +21,36 @@ public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldList
|
||||
addLabel(new GuiNpcLabel(0,"advanced.idlesound", guiLeft + 5, guiTop + 20));
|
||||
addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 80, guiTop + 15, 200, 20, npc.advanced.idleSound));
|
||||
addButton(new GuiNpcButton(0, guiLeft + 290, guiTop + 15, 80, 20, "gui.selectSound"));
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(2,"advanced.angersound", guiLeft + 5, guiTop + 45));
|
||||
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 80, guiTop + 40, 200, 20, npc.advanced.angrySound));
|
||||
addButton(new GuiNpcButton(2, guiLeft + 290, guiTop + 40, 80, 20, "gui.selectSound"));
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(3,"advanced.hurtsound", guiLeft + 5, guiTop + 70));
|
||||
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 80, guiTop + 65, 200, 20, npc.advanced.hurtSound));
|
||||
addButton(new GuiNpcButton(3, guiLeft + 290, guiTop + 65, 80, 20, "gui.selectSound"));
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(4,"advanced.deathsound", guiLeft + 5, guiTop + 95));
|
||||
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 80, guiTop + 90, 200, 20, npc.advanced.deathSound));
|
||||
addButton(new GuiNpcButton(4, guiLeft + 290, guiTop + 90, 80, 20, "gui.selectSound"));
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(5,"advanced.stepsound", guiLeft + 5, guiTop + 120));
|
||||
addTextField(new GuiNpcTextField(5,this, fontRendererObj, guiLeft + 80, guiTop + 115, 200, 20, npc.advanced.stepSound));
|
||||
addButton(new GuiNpcButton(5, guiLeft + 290, guiTop + 115, 80, 20, "gui.selectSound"));
|
||||
|
||||
addLabel(new GuiNpcLabel(6,"advanced.haspitch", guiLeft + 5, guiTop + 150));
|
||||
addButton(new GuiNpcButton(6, guiLeft + 120, guiTop + 145, 80, 20, new String[]{"gui.no","gui.yes"}, npc.advanced.disablePitch?0:1));
|
||||
|
||||
|
||||
}
|
||||
public void buttonEvent(GuiButton button){
|
||||
|
||||
if(button.id == 6)
|
||||
npc.advanced.disablePitch =((GuiNpcButton)button).getValue() == 0;
|
||||
else{
|
||||
selectedField = getTextField(button.id);
|
||||
gui = new GuiNpcSoundSelection(this, selectedField.getText());
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
selectedField = getTextField(button.id);
|
||||
setSubGui(new GuiSoundSelection(selectedField.getText()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
@@ -68,13 +65,16 @@ public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldList
|
||||
if(textfield.id == 5)
|
||||
npc.advanced.stepSound = textfield.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementClicked(){
|
||||
selectedField.setText(gui.getSelected());
|
||||
unFocused(selectedField);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
GuiSoundSelection gss = (GuiSoundSelection) subgui;
|
||||
if(gss.selectedResource != null) {
|
||||
selectedField.setText(gss.selectedResource.toString());
|
||||
unFocused(selectedField);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.MainmenuAdvancedSave, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
@@ -3,9 +3,7 @@ package noppes.npcs.client.gui.roles;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
import noppes.npcs.client.gui.GuiNpcSoundSelection;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
@@ -15,7 +13,6 @@ import noppes.npcs.roles.JobBard;
|
||||
public class GuiNpcBard extends GuiNPCInterface2 implements ISubGuiListener
|
||||
{
|
||||
private JobBard job;
|
||||
private GuiNpcSoundSelection gui;
|
||||
|
||||
public GuiNpcBard(EntityNPCInterface npc)
|
||||
{
|
||||
@@ -52,10 +49,6 @@ public class GuiNpcBard extends GuiNPCInterface2 implements ISubGuiListener
|
||||
getTextField(3).enabled = job.hasOffRange;
|
||||
|
||||
}
|
||||
@Override
|
||||
public void elementClicked(){
|
||||
job.song = gui.getSelected();
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package noppes.npcs.client.gui.roles;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.GuiNpcSoundSelection;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
|
||||
public class SubGuiNpcConversationLine extends SubGuiInterface implements ITextfieldListener{
|
||||
public class SubGuiNpcConversationLine extends SubGuiInterface implements ITextfieldListener, ISubGuiListener {
|
||||
public String line;
|
||||
public String sound;
|
||||
private GuiNpcSoundSelection gui;
|
||||
|
||||
|
||||
public SubGuiNpcConversationLine(String line, String sound){
|
||||
this.line = line;
|
||||
this.sound = sound;
|
||||
@@ -21,31 +19,27 @@ public class SubGuiNpcConversationLine extends SubGuiInterface implements ITextf
|
||||
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(0, "Line", guiLeft + 4, guiTop+ 10));
|
||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 22, 200, 20, line));
|
||||
|
||||
addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + 55, 90, 20, "Select Sound"));
|
||||
addButton(new GuiNpcButton(2, guiLeft + 96, guiTop + 55, 20, 20, "X"));
|
||||
addLabel(new GuiNpcLabel(1, sound, guiLeft + 4, guiTop + 81));
|
||||
|
||||
|
||||
addButton(new GuiNpcButton(66, guiLeft + 162, guiTop + 192, 90, 20, "gui.done"));
|
||||
}
|
||||
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
line = textfield.getText();
|
||||
}
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
line = textfield.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementClicked(){
|
||||
sound = gui.getSelected();
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
int id = guibutton.id;
|
||||
if(id == 1){
|
||||
gui = new GuiNpcSoundSelection(parent, sound);
|
||||
NoppesUtil.openGUI(player, gui);
|
||||
setSubGui(new GuiSoundSelection(sound));
|
||||
}
|
||||
if(id == 2){
|
||||
sound = "";
|
||||
@@ -56,4 +50,12 @@ public class SubGuiNpcConversationLine extends SubGuiInterface implements ITextf
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
GuiSoundSelection gss = (GuiSoundSelection) subgui;
|
||||
if(gss.selectedResource != null) {
|
||||
sound = gss.selectedResource.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user