Working scroll bar! Oh and two new items :)

This commit is contained in:
Pahimar 2015-04-05 09:57:46 -04:00
parent 8bf15be1ed
commit 5dd7f5a835
10 changed files with 88 additions and 14 deletions

View file

@ -10,6 +10,7 @@ import com.pahimar.ee3.reference.Colors;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Textures;
import com.pahimar.ee3.tileentity.TileEntityTransmutationTablet;
import com.pahimar.ee3.util.LogHelper;
import com.pahimar.repackage.cofh.lib.gui.GuiBase;
import com.pahimar.repackage.cofh.lib.gui.GuiColor;
import com.pahimar.repackage.cofh.lib.gui.element.ElementSlider;
@ -30,6 +31,7 @@ public class GuiTransmutationTablet extends GuiBase
private ElementTextField searchTextField;
private ElementStatefulButton sortOrderButton;
private ElementSlider slider;
protected int tickCount;
private static DecimalFormat energyValueDecimalFormat = new DecimalFormat("###,###,###,###,###.###");
@ -101,6 +103,14 @@ public class GuiTransmutationTablet extends GuiBase
}
}
@Override
public boolean onMouseWheel(int mouseX, int mouseY, int movement)
{
PacketHandler.INSTANCE.sendToServer(new MessageSliderElementUpdated(this));
LogHelper.info(tickCount);
return super.onMouseWheel(mouseX, mouseY, movement);
}
@Override
public void onStopDragging()
{
@ -113,6 +123,7 @@ public class GuiTransmutationTablet extends GuiBase
return _value;
}
};
slider.setName("scrollBar");
slider.backgroundColor = new GuiColor(0, 0, 0, 0).getColor();
slider.borderColor = new GuiColor(0, 0, 0, 0).getColor();
slider.setSliderSize(12, 15);
@ -130,6 +141,13 @@ public class GuiTransmutationTablet extends GuiBase
fontRendererObj.drawString(String.format("%s", energyValueDecimalFormat.format(tileEntityTransmutationTablet.getStoredEnergyValue().getEnergyValue())), 8, 150, Integer.parseInt(Colors.PURE_WHITE, 16));
}
@Override
public void updateScreen()
{
super.updateScreen();
tickCount++;
}
@Override
public void handleElementButtonClick(String buttonName, int mouseButton)
{

View file

@ -22,6 +22,8 @@ public class ModItems
public static final ItemEE matter = new ItemMatter();
public static final ItemEE gem = new ItemGem();
public static final ItemEE lootBall = new ItemLootBall();
public static final ItemEE knowledgeScroll = new ItemKnowledgeScroll();
public static final ItemEE potionLethe = new ItemPotionLethe();
public static final ItemToolEE shovelDarkMatter = new ItemDarkMatterShovel();
public static final ItemToolEE pickAxeDarkMatter = new ItemDarkMatterPickAxe();
@ -51,6 +53,8 @@ public class ModItems
GameRegistry.registerItem(matter, Names.Items.MATTER);
GameRegistry.registerItem(gem, Names.Items.GEM);
GameRegistry.registerItem(lootBall, Names.Items.LOOT_BALL);
GameRegistry.registerItem(knowledgeScroll, Names.Items.KNOWLEDGE_SCROLL);
GameRegistry.registerItem(potionLethe, Names.Items.POTION_LETHE);
GameRegistry.registerItem(shovelDarkMatter, Names.Tools.DARK_MATTER_SHOVEL);
GameRegistry.registerItem(pickAxeDarkMatter, Names.Tools.DARK_MATTER_PICKAXE);

View file

@ -12,10 +12,10 @@ import com.pahimar.ee3.knowledge.TransmutationKnowledge;
import com.pahimar.ee3.knowledge.TransmutationKnowledgeRegistry;
import com.pahimar.ee3.network.PacketHandler;
import com.pahimar.ee3.network.message.MessageTransmutationKnowledgeUpdate;
import com.pahimar.ee3.reference.Comparators;
import com.pahimar.ee3.tileentity.TileEntityTransmutationTablet;
import com.pahimar.ee3.util.FilterUtils;
import com.pahimar.ee3.util.ItemHelper;
import com.pahimar.ee3.util.LogHelper;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -35,6 +35,7 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
private float energyValue;
private String searchTerm;
private int sortOrder;
private int scrollBarPosition;
public ContainerTransmutationTablet(InventoryPlayer inventoryPlayer, TileEntityTransmutationTablet tileEntityTransmutationTablet)
{
@ -52,6 +53,7 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
inventoryTransmutationTablet = new InventoryTransmutationTablet(knownTransmutations);
this.sortOrder = 0;
this.scrollBarPosition = 0;
this.energyValue = tileEntityTransmutationTablet.getStoredEnergyValue().getEnergyValue();
this.addSlotToContainer(new SlotTabletInput(this, tileEntityTransmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_1, 62, 24));
@ -143,8 +145,12 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
{
sortOrder = updatedValue;
}
else if (valueType == 3)
{
scrollBarPosition = updatedValue;
}
if (valueType == 0 || valueType == 1 || valueType == 2)
if (valueType >= 0 && valueType <= 3)
{
updateInventory();
}
@ -163,7 +169,11 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
@Override
public void handleElementSliderUpdate(String elementName, int elementValue)
{
LogHelper.info(elementValue);
if (elementName.equals("scrollBar"))
{
this.scrollBarPosition = elementValue;
updateInventory();
}
}
public void handleTransmutationKnowledgeUpdate(TransmutationKnowledge transmutationKnowledge)
@ -182,26 +192,24 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
Set<ItemStack> filteredSet = FilterUtils.filterByNameContains(this.inventoryTransmutationTablet.getKnownTransmutations(), searchTerm);
List<ItemStack> filteredList = new ArrayList(FilterUtils.filterByEnergyValue(filteredSet, energyValue));
if (sortOrder == 0)
int adjustedStartIndex = (int) ((scrollBarPosition / 187f) * filteredList.size());
if (sortOrder >= 0 && sortOrder < Comparators.itemComparators.length)
{
Collections.sort(filteredList, ItemHelper.displayNameComparator);
}
else if (sortOrder == 1)
{
Collections.sort(filteredList, ItemHelper.energyValueComparator);
}
else if (sortOrder == 2)
{
Collections.sort(filteredList, ItemHelper.idComparator);
Collections.sort(filteredList, Comparators.itemComparators[sortOrder]);
}
if (filteredList.size() <= 30)
{
newInventory = filteredList.toArray(newInventory);
}
else if (adjustedStartIndex + 30 <= filteredList.size())
{
newInventory = filteredList.subList(adjustedStartIndex, adjustedStartIndex + 30).toArray(newInventory);
}
else
{
newInventory = filteredList.subList(0, 30).toArray(newInventory);
newInventory = filteredList.subList(filteredList.size() - 30, filteredList.size()).toArray(newInventory);
}
for (int i = 0; i < 30; i++)
@ -307,6 +315,12 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen
}
}
}
for (Object crafter : this.crafters)
{
ICrafting iCrafting = (ICrafting) crafter;
iCrafting.sendProgressBarUpdate(this, 2, sortOrder);
}
}
private class SlotAlchemicalTome extends Slot

View file

@ -0,0 +1,12 @@
package com.pahimar.ee3.item;
import com.pahimar.ee3.reference.Names;
public class ItemKnowledgeScroll extends ItemEE
{
public ItemKnowledgeScroll()
{
super();
this.setUnlocalizedName(Names.Items.KNOWLEDGE_SCROLL);
}
}

View file

@ -0,0 +1,12 @@
package com.pahimar.ee3.item;
import com.pahimar.ee3.reference.Names;
public class ItemPotionLethe extends ItemEE
{
public ItemPotionLethe()
{
super();
this.setUnlocalizedName(Names.Items.POTION_LETHE);
}
}

View file

@ -0,0 +1,10 @@
package com.pahimar.ee3.reference;
import com.pahimar.ee3.util.ItemHelper;
import java.util.Comparator;
public class Comparators
{
public static final Comparator[] itemComparators = {ItemHelper.displayNameComparator, ItemHelper.energyValueComparator, ItemHelper.idComparator};
}

View file

@ -51,6 +51,8 @@ public class Names
public static final String[] MATTER_SUBTYPES = {"Proto", "Dark", "Corporeal", "Kinetic", "Temporal", "Essentia", "Amorphous", "Void", "Omni"};
public static final String GEM = "gem";
public static final String[] GEM_SUBTYPES = {"Black", "Blue", "Green", "Grey", "Purple", "Red", "Yellow"};
public static final String KNOWLEDGE_SCROLL = "knowledgeScroll";
public static final String POTION_LETHE = "potionLethe";
}
public static final class Materials

View file

@ -57,6 +57,8 @@ item.ee3:gemPurple.name=Purple Gem [WIP]
item.ee3:gemRed.name=Red Gem [WIP]
item.ee3:gemYellow.name=Yellow Gem [WIP]
item.ee3:lootBall.name=Loot Ball [WIP]
item.ee3:knowledgeScroll.name=Scroll of Transmutation Knowledge [WIP]
item.ee3:potionLethe.name=Lethe Potion [WIP]
# Tools
item.ee3:shovelDarkMatter.name=Dark Matter Shovel [WIP]

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB