Skip to content

Commit

Permalink
Merge pull request #51 from Fi0x/featureSkills
Browse files Browse the repository at this point in the history
Re-added buttons in skilltree gui
  • Loading branch information
Fi0x authored Jun 25, 2020
2 parents 462ec1e + 2366587 commit 0d650fe
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public boolean onBlockActivated(@Nonnull World worldIn, @Nonnull BlockPos pos, @
{
if(!worldIn.isRemote)
{
// PlayerMana playerMana = playerIn.getCapability(PlayerProperties.PLAYER_MANA, null);
// PacketHandler.INSTANCE.sendToServer(new PacketGetSkill(playerIn.getName(), playerMana.getSkillXP(), playerMana.getSkillpoints(), playerMana.getManaRegenRate(), playerMana.getManaEfficiency(), playerMana.maxManaMultiplier, playerMana.addedHP, playerMana.hpRegeneration));
Main.proxy.openSkilltreeGui(playerIn.getCapability(PlayerProperties.PLAYER_MANA, null));
}
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/com/fi0x/deepmagic/gui/GuiSkilltree.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public class GuiSkilltree extends GuiScreen
private int guiY;
private static final ResourceLocation backgroundTexture = new ResourceLocation(Reference.MOD_ID + ":textures/gui/skilltree_background.png");
private GuiButton buttonExit;
private GuiButton buttonAddMaxMana;
private GuiButton buttonAddManaRegenRate;
private GuiButton buttonAddManaEfficiency;
private GuiButton buttonAddMaxHP;
private GuiButton buttonAddHPRegen;
private GuiButton buttonAddSpellTier;

public GuiSkilltree(PlayerMana playerMana)
{
Expand All @@ -37,8 +43,21 @@ public void initGui()
buttonList.clear();
labelList.clear();
Keyboard.enableRepeatEvents(true);

buttonExit = new GuiButton(0, width/2 -20, guiY + backgroundHeight-30, 40, 20, I18n.format("Exit"));
buttonList.add(buttonExit);
buttonAddMaxMana = new GuiButton(1, guiX + 160, guiY + 5, 20, 20, I18n.format("+"));
buttonList.add(buttonAddMaxMana);
buttonAddManaRegenRate = new GuiButton(2, guiX + 160, guiY + 25, 20, 20, I18n.format("+"));
buttonList.add(buttonAddManaRegenRate);
buttonAddManaEfficiency = new GuiButton(3, guiX + 160, guiY + 45, 20, 20, I18n.format("+"));
buttonList.add(buttonAddManaEfficiency);
buttonAddMaxHP = new GuiButton(4, guiX + 160, guiY + 65, 20, 20, I18n.format("+"));
buttonList.add(buttonAddMaxHP);
buttonAddHPRegen = new GuiButton(5, guiX + 160, guiY + 85, 20, 20, I18n.format("+"));
buttonList.add(buttonAddHPRegen);
buttonAddSpellTier = new GuiButton(6, guiX + 160, guiY + 105, 20, 10, I18n.format("+"));
buttonList.add(buttonAddSpellTier);

GuiLabel labelMaxMana = new GuiLabel(this.fontRenderer, 101, guiX + 5, guiY + 5, 150, 20, 0);
labelMaxMana.addLine("Mana Capacity: " + (int) playerMana.getMaxMana());
Expand Down Expand Up @@ -66,6 +85,24 @@ public void initGui()
@Override
public void updateScreen()
{
if(playerMana.getSkillpoints() > 0)
{
buttonAddMaxMana.visible = true;
buttonAddManaRegenRate.visible = true;
buttonAddManaEfficiency.visible = true;
buttonAddMaxHP.visible = true;
buttonAddHPRegen.visible = true;
if(playerMana.getSpellTier() < 10) buttonAddSpellTier.visible = true;
else buttonAddSpellTier.visible = false;
} else
{
buttonAddMaxMana.visible = false;
buttonAddManaRegenRate.visible = false;
buttonAddManaEfficiency.visible = false;
buttonAddMaxHP.visible = false;
buttonAddHPRegen.visible = false;
buttonAddSpellTier.visible = false;
}
}

@Override
Expand All @@ -84,6 +121,16 @@ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, lo
protected void actionPerformed(@Nonnull GuiButton button)
{
if(button == buttonExit) mc.displayGuiScreen(null);
else
{
if(button == buttonAddMaxMana) playerMana.maxManaMultiplier++;
else if(button == buttonAddManaRegenRate) playerMana.setManaRegenRate(playerMana.getManaRegenRate() + 1);
else if(button == buttonAddManaEfficiency) playerMana.setManaEfficiency(playerMana.getManaEfficiency() + 1);
else if(button == buttonAddMaxHP) playerMana.addedHP++;
else if(button == buttonAddHPRegen) playerMana.hpRegeneration++;
else if(button == buttonAddSpellTier) playerMana.addSpellTier();
playerMana.removeSkillpoint();
}
}

@Override
Expand Down

0 comments on commit 0d650fe

Please sign in to comment.