Reset Scroll Bar positioning when searching via Textfield

This commit is contained in:
Kam committed 2024-03-29 04:50:47 -04:00
1 parent 44f91da175
commit 5a7bd08403
11 files changed
+47 -31

No files matched your search

@@ -137,6 +137,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
return;
search = getTextField(55).getText().toLowerCase();
scrollAnimations.setList(getSearchList());
scrollAnimations.resetScroll();
}
}
}
@@ -101,6 +101,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
return;
catSearch = getTextField(55).getText().toLowerCase();
catScroll.setList(getCatSearch());
catScroll.resetScroll();
}
}
if(getTextField(66) != null){
@@ -109,6 +110,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
return;
diagSearch = getTextField(66).getText().toLowerCase();
dialogScroll.setList(getDiagSearch());
dialogScroll.resetScroll();
}
}
}
@@ -147,6 +147,7 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat
return;
search = getTextField(55).getText().toLowerCase();
scrollFactions.setList(getSearchList());
scrollFactions.resetScroll();
}
}
}
@@ -17,9 +17,9 @@ public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollDa
private GuiCustomScroll scroll;
private List<String> data = new ArrayList<String>();
private String search = "";
public static GuiScreen Instance;
public GuiNPCManageLinkedNpc(EntityNPCInterface npc){
super(npc);
Instance = this;
@@ -29,10 +29,10 @@ public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollDa
@Override
public void initGui(){
super.initGui();
this.addButton(new GuiNpcButton(1,guiLeft + 358, guiTop + 38, 58, 20, "gui.add"));
this.addButton(new GuiNpcButton(2,guiLeft + 358, guiTop + 61, 58, 20, "gui.remove"));
if(scroll == null){
scroll = new GuiCustomScroll(this,0,0);
scroll.setSize(143, 185);
@@ -54,6 +54,7 @@ public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollDa
return;
search = getTextField(55).getText().toLowerCase();
scroll.setList(getSearchList());
scroll.resetScroll();
}
}
}
@@ -80,7 +81,7 @@ public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollDa
if(scroll.hasSelected())
Client.sendData(EnumPacketServer.LinkedRemove, scroll.getSelected());
}
}
@Override
@@ -99,12 +100,12 @@ public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollDa
@Override
public void setSelected(String selected) {
}
@Override
public void save() {
}
}
@@ -106,6 +106,7 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup,
return;
catSearch = getTextField(55).getText().toLowerCase();
catScroll.setList(getCatSearch());
catScroll.resetScroll();
}
}
if(getTextField(66) != null){
@@ -114,6 +115,7 @@ public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup,
return;
questSearch = getTextField(66).getText().toLowerCase();
questScroll.setList(getQuestSearch());
questScroll.resetScroll();
}
}
}
@@ -21,7 +21,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
private Tag tag = new Tag();
private String selected = null;
private String search = "";
public GuiNPCManageTags(EntityNPCInterface npc)
{
super(npc);
@@ -31,10 +31,10 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
public void initGui()
{
super.initGui();
this.addButton(new GuiNpcButton(0,guiLeft + 368, guiTop + 8, 45, 20, "gui.add"));
this.addButton(new GuiNpcButton(1,guiLeft + 368, guiTop + 32, 45, 20, "gui.remove"));
if(scrollTags == null){
scrollTags = new GuiCustomScroll(this,0, 0);
scrollTags.setSize(143, 185);
@@ -46,7 +46,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
if (tag.id == -1)
return;
this.addTextField(new GuiNpcTextField(0, this, guiLeft + 40, guiTop + 4, 136, 20, tag.name));
getTextField(0).setMaxStringLength(20);
addLabel(new GuiNpcLabel(0,"gui.name", guiLeft + 8, guiTop + 9));
@@ -60,7 +60,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
addButton(new GuiNpcButton(10, guiLeft + 50, guiTop + 30, 60, 20, color));
addLabel(new GuiNpcLabel(1,"gui.color", guiLeft + 8, guiTop + 35));
getButton(10).setTextColor(tag.color);
addLabel(new GuiNpcLabel(3,"faction.hidden", guiLeft + 8, guiTop + 59));
this.addButton(new GuiNpcButton(3,guiLeft + 50, guiTop + 54, 60, 20, new String[]{"gui.no","gui.yes"},tag.hideTag?1:0));
}
@@ -75,6 +75,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
return;
search = getTextField(55).getText().toLowerCase();
scrollTags.setList(getSearchList());
scrollTags.resetScroll();
}
}
}
@@ -100,7 +101,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
while(data.containsKey(name))
name += "_";
Tag tag = new Tag(-1, name, 0x00FF00);
NBTTagCompound compound = new NBTTagCompound();
tag.writeNBT(compound);
Client.sendData(EnumPacketServer.TagSave, compound);
@@ -125,28 +126,28 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
public void setGuiData(NBTTagCompound compound) {
this.tag = new Tag();
tag.readNBT(compound);
setSelected(tag.name);
initGui();
}
@Override
public void setData(Vector<String> list, HashMap<String, Integer> data) {
String name = scrollTags.getSelected();
this.data = data;
scrollTags.setList(getSearchList());
if(name != null)
scrollTags.setSelected(name);
}
@Override
public void setSelected(String selected) {
this.selected = selected;
scrollTags.setSelected(selected);
}
@Override
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
if(guiCustomScroll.id == 0)
@@ -156,21 +157,21 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
Client.sendData(EnumPacketServer.TagGet, data.get(selected));
}
}
public void save() {
if(selected != null && data.containsKey(selected) && tag != null){
NBTTagCompound compound = new NBTTagCompound();
tag.writeNBT(compound);
Client.sendData(EnumPacketServer.TagSave, compound);
}
}
@Override
public void unFocused(GuiNpcTextField guiNpcTextField) {
if(tag.id == -1)
if(tag.id == -1)
return;
if(guiNpcTextField.id == 0) {
String name = guiNpcTextField.getText();
if(!name.isEmpty() && !data.containsKey(name)){
@@ -191,8 +192,8 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
}
tag.color = color;
guiNpcTextField.setTextColor(tag.color);
}
}
}
@Override
@@ -25,7 +25,7 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS
private String selected = null;
private ResourceLocation slot;
private String search = "";
public GuiNpcManageRecipes(EntityNPCInterface npc,ContainerManageRecipes container){
super(npc,container);
this.container = container;
@@ -39,7 +39,7 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS
@Override
public void initGui(){
super.initGui();
if(scroll == null)
scroll = new GuiCustomScroll(this,0,0);
scroll.setSize(130, 180);
@@ -57,7 +57,7 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS
this.addLabel(new GuiNpcLabel(0, "gui.ignoreDamage", guiLeft + 86, guiTop + 32));
this.addButton(new GuiNpcButtonYesNo(5,guiLeft + 114, guiTop + 40, 50, 20, container.recipe.ignoreDamage));
this.addLabel(new GuiNpcLabel(1, "gui.ignoreNBT", guiLeft + 86, guiTop + 82));
this.addButton(new GuiNpcButtonYesNo(6,guiLeft + 114, guiTop + 90, 50, 20, container.recipe.ignoreNBT));
@@ -120,6 +120,7 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS
return;
search = getTextField(55).getText().toLowerCase();
scroll.setList(getSearchList());
scroll.resetScroll();
}
}
}
@@ -154,7 +155,7 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS
super.drawGuiContainerBackgroundLayer(f, x, y);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(slot);
for(int i = 0; i < container.width;i++){
for(int j = 0; j < container.width;j++){
drawTexturedModalRect(guiLeft + i*18 + 7, guiTop + j*18 + 34, 0, 0, 18, 18);
@@ -170,11 +171,11 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS
this.getTextField(0).enabled = name != null;
this.getButton(5).setEnabled(name != null);
if(name != null)
scroll.setSelected(name);
}
@Override
public void setSelected(String selected) {
this.selected = selected;
@@ -95,6 +95,7 @@ public class GuiNpcNaturalSpawns extends GuiNPCInterface2 implements IGuiData, I
return;
search = getTextField(55).getText().toLowerCase();
scrollNaturalSpawns.setList(getSearchList());
scrollNaturalSpawns.resetScroll();
}
}
}
@@ -102,6 +102,7 @@ public class GuiDialogSelection extends SubGuiInterface implements ICustomScroll
return;
catSearch = getTextField(33).getText().toLowerCase();
scrollCategories.setList(getCatSearch());
scrollCategories.resetScroll();
}
}
if(getTextField(44) != null){
@@ -110,6 +111,7 @@ public class GuiDialogSelection extends SubGuiInterface implements ICustomScroll
return;
dialogSearch = getTextField(44).getText().toLowerCase();
scrollDialogs.setList(getDialogSearch());
scrollDialogs.resetScroll();
}
}
}
@@ -102,6 +102,7 @@ public class GuiQuestSelection extends SubGuiInterface implements ICustomScrollL
return;
catSearch = getTextField(33).getText().toLowerCase();
scrollCategories.setList(getCatSearch());
scrollCategories.resetScroll();
}
}
if(getTextField(44) != null){
@@ -110,6 +111,7 @@ public class GuiQuestSelection extends SubGuiInterface implements ICustomScrollL
return;
questSearch = getTextField(44).getText().toLowerCase();
scrollQuests.setList(getQuestSearch());
scrollQuests.resetScroll();
}
}
}
@@ -139,6 +139,7 @@ public class GuiSoundSelection extends SubGuiInterface implements ICustomScrollL
return;
catSearch = getTextField(55).getText().toLowerCase();
scrollCategories.setList(getCatSearch());
scrollCategories.resetScroll();
}
}
if(getTextField(66) != null){
@@ -147,6 +148,7 @@ public class GuiSoundSelection extends SubGuiInterface implements ICustomScrollL
return;
soundSearch = getTextField(66).getText().toLowerCase();
scrollSounds.setList(getSoundSearch());
scrollSounds.resetScroll();
}
}
}