Skip to content

Commit

Permalink
Added Gui list view titles and fixed some small gui bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLittleKitty committed Dec 3, 2016
1 parent d1e9c53 commit d4a5a02
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class EditSnitchListsGui extends GuiScreen
{
private GuiScreen parentScreen;

private final String title;
private final int titleWidth;

private SnitchListsGui snitchListGUI;
private SnitchMaster snitchMaster;
private Collection<SnitchList> snitchLists;
Expand All @@ -26,19 +29,27 @@ public class EditSnitchListsGui extends GuiScreen
private static final int RENDER_ON_BUTTON_WIDTH = GuiConstants.SMALL_BUTTON_WIDTH;
private static final int RENDER_OFF_BUTTON_WIDTH = GuiConstants.SMALL_BUTTON_WIDTH;

public EditSnitchListsGui(GuiScreen guiscreen, SnitchMaster snitchMaster, Collection<SnitchList> listsToDisplay, boolean fullList)
public EditSnitchListsGui(GuiScreen guiscreen, SnitchMaster snitchMaster, Collection<SnitchList> listsToDisplay, boolean fullList, String title)
{
this.parentScreen = guiscreen;
this.snitchMaster = snitchMaster;
this.fullList = fullList;
snitchLists = listsToDisplay;
this.title = title;
this.titleWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(title);
}

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.snitchListGUI.drawScreen(mouseX, mouseY, partialTicks);

int yPos = 16 - (mc.fontRendererObj.FONT_HEIGHT/2);
int xPos = (this.width/2) - (titleWidth/2);

mc.fontRendererObj.drawString(title, xPos ,yPos, 16777215);

super.drawScreen(mouseX, mouseY, partialTicks);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.gmail.nuclearcat1337.snitch_master.snitches.Snitch;
import com.gmail.nuclearcat1337.snitch_master.snitches.SnitchList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;

Expand All @@ -15,6 +16,9 @@
*/
public class EditSnitchesGui extends GuiScreen
{
private final String title;
private final int titleWidth;

private GuiScreen parentScreen;
private Collection<Snitch> snitches;

Expand All @@ -23,10 +27,12 @@ public class EditSnitchesGui extends GuiScreen
private static final int DONE_BUTTON_WIDTH = GuiConstants.SMALL_BUTTON_WIDTH*3;
//private static final int NEW_BUTTON_WIDTH = GuiConstants.SMALL_BUTTON_WIDTH;

public EditSnitchesGui(GuiScreen guiscreen, Collection<Snitch> snitches)
public EditSnitchesGui(GuiScreen guiscreen, Collection<Snitch> snitches, String title)
{
this.parentScreen = guiscreen;
this.snitches = snitches;
this.title = title;
this.titleWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(title);
}

@Override
Expand All @@ -36,8 +42,13 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks)
this.snitchesGui.drawScreen(mouseX, mouseY, partialTicks);
super.drawScreen(mouseX, mouseY, partialTicks);

int yPos = 16 - (mc.fontRendererObj.FONT_HEIGHT/2);
int xPos = (this.width/2) - (titleWidth/2);

mc.fontRendererObj.drawString(title, xPos ,yPos, 16777215);

int index = snitchesGui.getSlotIndexFromScreenCoords(mouseX,mouseY);
if(index > 0)
if(index >= 0)
{
Snitch snitch = snitchesGui.getSnitchForIndex(index);
if(mouseX >= snitchesGui.getCoordsLeftBound() && mouseX <= snitchesGui.getCoordsRightBound())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ public void actionPerformed(GuiButton button)
// break;
case 2: //"View Snitch Lists"
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new EditSnitchListsGui(this,snitchMaster,snitchMaster.getSnitchLists().asCollection(),true));
this.mc.displayGuiScreen(new EditSnitchListsGui(this,snitchMaster,snitchMaster.getSnitchLists().asCollection(),true, "All Snitch Lists"));
break;
case 3: //"View Snitches"
this.mc.displayGuiScreen(new EditSnitchesGui(this,snitchMaster.getSnitches()));
this.mc.displayGuiScreen(new EditSnitchesGui(this,snitchMaster.getSnitches(),"All Snitches"));
break;
case 4: //"Done"
this.mc.displayGuiScreen((GuiScreen) null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void actionPerformed(GuiButton button)
//Handles any things that need to happen when lists change. (saving, etc)
lists.snitchListChanged();

Minecraft.getMinecraft().displayGuiScreen(new EditSnitchListsGui(null,snitchMaster,snitchMaster.getSnitchLists().asCollection(),true));
Minecraft.getMinecraft().displayGuiScreen(new EditSnitchListsGui(null,snitchMaster,snitchMaster.getSnitchLists().asCollection(),true, "All Snitch Lists"));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public SnitchGui(EditSnitchesGui parentScreen, Collection<Snitch> snitchesToDisp

protected void drawListHeader(int xPosition, int yPosition, Tessellator tessalator)
{
yPosition = yPosition + this.getSlotHeight();
yPosition = yPosition;// + this.getSlotHeight();
String root = ChatFormatting.UNDERLINE + "" + ChatFormatting.BOLD;
int nameWidth = mc.fontRendererObj.getStringWidth(root+ NAME_HEADER);
int groupWidth = mc.fontRendererObj.getStringWidth(root+ GROUP_HEADER);
Expand Down Expand Up @@ -214,7 +214,7 @@ private SnitchEntry(Snitch snitch)

public void drawEntry(int slotIndex, int xPosition, int yPosition, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
{
int yFinal = yPosition + (slotHeight + mc.fontRendererObj.FONT_HEIGHT); /// 2;
int yFinal = yPosition + ((slotHeight - mc.fontRendererObj.FONT_HEIGHT) /2); //+ (slotHeight + mc.fontRendererObj.FONT_HEIGHT); /// 2;

int workingWidth = (width-xPosition);
int xPos = xPosition + (workingWidth/2) - (entryWidth/2);
Expand Down Expand Up @@ -285,7 +285,7 @@ public boolean mousePressed(int index, int xPos, int yPos, int mouseEvent, int r
if(snitch.getAttachedSnitchLists().size() > 0)
{
//Sorry im cheating by using the static instance but im lazy and its only 1 line right? right? :(
mc.displayGuiScreen(new EditSnitchListsGui(cancelToScreen, SnitchMaster.instance, snitch.getAttachedSnitchLists(), false));
mc.displayGuiScreen(new EditSnitchListsGui(cancelToScreen, SnitchMaster.instance, snitch.getAttachedSnitchLists(), false, "Snitch Lists for Snitch: "+(snitch.getSnitchName().isEmpty() ? "[Not Named]" : snitch.getSnitchName())));
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,52 +212,53 @@ private SnitchListEntry(SnitchList snitchList, int index)

public void drawEntry(int slotIndex, int xPosition, int yPosition, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
{
int yFinal = yPosition + (slotHeight + SnitchListsGui.this.mc.fontRendererObj.FONT_HEIGHT) / 2;
int stringYPosition = yPosition + ((slotHeight - SnitchListsGui.this.mc.fontRendererObj.FONT_HEIGHT) / 2);
yPosition = yPosition + ((slotHeight - GuiConstants.STANDARD_BUTTON_HEIGHT) /2);

int workingWidth = (width-xPosition);
int xPos = xPosition + (workingWidth/2) - (entryWidth/2);

upButton.yPosition = yPosition + (upButton.height/3);
upButton.yPosition = yPosition;// + (upButton.height/3);
upButton.xPosition = xPos;

xPos += upButton.width + GuiConstants.SMALL_SEPARATION_DISTANCE;

toggleRenderButton.displayString = snitchList.shouldRenderSnitches() ? "On" : "Off";
toggleRenderButton.yPosition = yPosition + (toggleRenderButton.height/3);
toggleRenderButton.yPosition = yPosition;// + (toggleRenderButton.height/3);
toggleRenderButton.xPosition = xPos;

xPos += toggleRenderButton.width + GuiConstants.SMALL_SEPARATION_DISTANCE;

downButton.yPosition = yPosition + (downButton.height/3);
downButton.yPosition = yPosition;// + (downButton.height/3);
downButton.xPosition = xPos;

xPos += downButton.width + (GuiConstants.STANDARD_SEPARATION_DISTANCE*2);

this.upButton.drawButton(SnitchListsGui.this.mc, mouseX, mouseY);
this.downButton.drawButton(SnitchListsGui.this.mc, mouseX, mouseY);
this.toggleRenderButton.drawButton(SnitchListsGui.this.mc, mouseX, mouseY);

int stringWidth = mc.fontRendererObj.getStringWidth(snitchList.getListName());

int namePos = xPos + (NAME_COLUMN_WIDTH /2) - (stringWidth/2);

mc.fontRendererObj.drawString(snitchList.getListName(), namePos ,yFinal,16777215);
mc.fontRendererObj.drawString(snitchList.getListName(), namePos , stringYPosition,16777215);

xPos += NAME_COLUMN_WIDTH + (GuiConstants.STANDARD_SEPARATION_DISTANCE*2);

editColorButton.yPosition = yPosition + (editColorButton.height/3);
editColorButton.yPosition = yPosition;// + (editColorButton.height/3);
editColorButton.xPosition = xPos;

xPos += EDIT_COLOR_BUTTON_WIDTH + (GuiConstants.STANDARD_SEPARATION_DISTANCE*2);

editQualifierButton.yPosition = yPosition + (editQualifierButton.height/3);
editQualifierButton.yPosition = yPosition;// + (editQualifierButton.height/3);
editQualifierButton.xPosition = xPos;

xPos += EDIT_QUALIFIER_BUTTON_WIDTH + (GuiConstants.STANDARD_SEPARATION_DISTANCE*2);

viewSnitchesButton.yPosition = yPosition +(viewSnitchesButton.height/3);
viewSnitchesButton.yPosition = yPosition;// +(viewSnitchesButton.height/3);
viewSnitchesButton.xPosition = xPos;


this.upButton.drawButton(SnitchListsGui.this.mc, mouseX, mouseY);
this.downButton.drawButton(SnitchListsGui.this.mc, mouseX, mouseY);
this.toggleRenderButton.drawButton(SnitchListsGui.this.mc, mouseX, mouseY);
this.editColorButton.drawButton(SnitchListsGui.this.mc, mouseX, mouseY);
this.editQualifierButton.drawButton(SnitchListsGui.this.mc, mouseX, mouseY);
this.viewSnitchesButton.drawButton(SnitchListsGui.this.mc, mouseX, mouseY);
Expand Down Expand Up @@ -308,7 +309,7 @@ public boolean mousePressed(int index, int xPos, int yPos, int mouseEvent, int r
if(snitches.isEmpty())
viewSnitchesButton.displayString = "None";
else
mc.displayGuiScreen(new EditSnitchesGui(cancelToScreen,snitches));
mc.displayGuiScreen(new EditSnitchesGui(cancelToScreen,snitches,"Snitches for Snitch List: "+snitchList.getListName()));
return true;
}

Expand Down

0 comments on commit d4a5a02

Please sign in to comment.