Skip to content

Commit

Permalink
Release Candidate 1!
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynious committed Jan 12, 2014
1 parent 141c3ec commit 7fef3a2
Show file tree
Hide file tree
Showing 26 changed files with 284 additions and 72 deletions.
4 changes: 4 additions & 0 deletions java/com/dynious/soundscool/SoundsCool.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.dynious.soundscool.block.ModBlocks;
import com.dynious.soundscool.command.CommandSoundsCool;
import com.dynious.soundscool.creativetab.CreativeTabSoundsCool;
import com.dynious.soundscool.handler.GuiHandler;
import com.dynious.soundscool.handler.SoundHandler;
import com.dynious.soundscool.lib.Reference;
Expand All @@ -14,6 +15,7 @@
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraft.creativetab.CreativeTabs;

@Mod(modid = Reference.modid, name = Reference.name, version = Reference.version)
public class SoundsCool
Expand All @@ -24,6 +26,8 @@ public class SoundsCool
@SidedProxy(clientSide = Reference.clientProxy, serverSide = Reference.commonProxy)
public static CommonProxy proxy;

public static CreativeTabs tabSoundsCool = new CreativeTabSoundsCool(CreativeTabs.getNextID(), Reference.modid);

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
Expand Down
42 changes: 41 additions & 1 deletion java/com/dynious/soundscool/block/BlockSoundPlayer.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
package com.dynious.soundscool.block;

import com.dynious.soundscool.SoundsCool;
import com.dynious.soundscool.lib.Names;
import com.dynious.soundscool.lib.Reference;
import com.dynious.soundscool.tileentity.TileSoundPlayer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

public class BlockSoundPlayer extends BlockContainer
{
public BlockSoundPlayer()
{
super(Material.field_151576_e);
this.func_149647_a(CreativeTabs.tabBlock);
this.func_149647_a(SoundsCool.tabSoundsCool);
this.func_149663_c(Names.soundPlayer);
}

@Override
Expand Down Expand Up @@ -69,4 +77,36 @@ public void func_149695_a(World world, int x, int y, int z, Block block)
((TileSoundPlayer)tile).setPowered(world.isBlockIndirectlyGettingPowered(x, y, z));
}
}

private IIcon blockTop;
private IIcon blockSide;

//registerIcons()
@Override
@SideOnly(Side.CLIENT)
public void func_149651_a(IIconRegister iconRegister)
{
blockTop = iconRegister.registerIcon(Reference.modid + ":" + String.format("%s_top", getUnwrappedUnlocalizedName(this.func_149739_a())));
blockSide = iconRegister.registerIcon(Reference.modid + ":" + String.format("%s_side", getUnwrappedUnlocalizedName(this.func_149739_a())));
}

//getIcon()
@Override
@SideOnly(Side.CLIENT)
public IIcon func_149691_a(int side, int metaData)
{
if (ForgeDirection.getOrientation(side) == ForgeDirection.UP || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN)
{
return blockTop;
}
else
{
return blockSide;
}
}

protected String getUnwrappedUnlocalizedName(String unlocalizedName)
{
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class GuiLocalSoundsList extends GuiScrollingList

public GuiLocalSoundsList(IListGui parent, int listWidth)
{
super(parent.getMinecraftInstance(), listWidth, parent.getWidth(), 32, parent.getHeight() - 32 + 4, 10, 35);
super(parent.getMinecraftInstance(), listWidth, parent.getWidth(), 32, parent.getHeight() - 64, 10, 35);
this.parent = parent;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.dynious.soundscool.client.gui;

import com.dynious.soundscool.handler.NetworkHandler;
import com.dynious.soundscool.sound.Sound;
import cpw.mods.fml.client.GuiScrollingList;
import net.minecraft.client.renderer.Tessellator;

Expand All @@ -10,7 +11,7 @@ public class GuiRemoteSoundsList extends GuiScrollingList

public GuiRemoteSoundsList(IListGui parent, int listWidth)
{
super(parent.getMinecraftInstance(), listWidth, parent.getWidth(), 32, parent.getHeight() - 32 + 4, 10, 35);
super(parent.getMinecraftInstance(), listWidth, parent.getWidth(), 32, parent.getHeight() - 32, 10, 35);
this.parent = parent;
}

Expand Down Expand Up @@ -47,11 +48,11 @@ protected int getContentHeight()
@Override
protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5)
{
String sound = NetworkHandler.uploadedSounds.get(listIndex);
Sound sound = NetworkHandler.uploadedSounds.get(listIndex);
if (sound != null)
{
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(sound, listWidth - 10), this.left + 3 , var3 + 2, 0xFFFFFF);
//this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(NetworkHandler.hasServerSound(sound.getSoundName())? "Uploaded": "Not uploaded", listWidth - 10), this.left + 3 , var3 + 12, 0xCCCCCC);
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(sound.getSoundName(), listWidth - 10), this.left + 3 , var3 + 2, 0xFFFFFF);
this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(sound.getCategory(), listWidth - 10), this.left + 3 , var3 + 12, 0xCCCCCC);
}
}
}
52 changes: 44 additions & 8 deletions java/com/dynious/soundscool/client/gui/GuiSoundPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

import com.dynious.soundscool.SoundsCool;
import com.dynious.soundscool.handler.NetworkHandler;
import com.dynious.soundscool.network.packet.client.ClientPlaySoundPacket;
import com.dynious.soundscool.handler.SoundHandler;
import com.dynious.soundscool.network.packet.client.GetUploadedSoundsPacket;
import com.dynious.soundscool.network.packet.client.SoundPlayerPlayPacket;
import com.dynious.soundscool.network.packet.client.SoundPlayerSelectPacket;
import com.dynious.soundscool.sound.Sound;
import com.dynious.soundscool.tileentity.TileSoundPlayer;
import cpw.mods.fml.common.network.FMLOutboundHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import org.apache.commons.io.FileUtils;

@SideOnly(Side.CLIENT)
public class GuiSoundPlayer extends GuiScreen implements IListGui
{
private GuiRemoteSoundsList soundsList;
Expand All @@ -30,14 +33,34 @@ public void initGui()
{
super.initGui();
soundsList = new GuiRemoteSoundsList(this, 150);
this.field_146292_n.add(new GuiButton(0, this.field_146294_l / 2 - 75, this.field_146295_m - 38, "Play"));
this.field_146292_n.add(new GuiButton(0, getWidth() / 2, getHeight() - 42, I18n.getStringParams("gui.done")));
this.field_146292_n.add(new GuiButton(1, getWidth() / 2, getHeight() - 72, "Play"));
}

@Override
public void drawScreen(int p_571_1_, int p_571_2_, float p_571_3_)
{
this.soundsList.drawScreen(p_571_1_, p_571_2_, p_571_3_);
super.drawScreen(p_571_1_, p_571_2_, p_571_3_);

Sound sound = tile.getSelectedSound();
if (sound != null)
{
this.getFontRenderer().drawString(sound.getSoundName(), getWidth()/2 + 100 - (this.getFontRenderer().getStringWidth(sound.getSoundName())/2), 30, 0xFFFFFF);

boolean hasSound = SoundHandler.getSound(sound.getSoundName()) != null;
String uploaded = hasSound? "Downloaded": "Not downloaded";
this.getFontRenderer().drawString(uploaded, getWidth()/2 + + 100 - (this.getFontRenderer().getStringWidth(uploaded)/2), 60, hasSound? 0x00FF00: 0xFF0000);

String category = NetworkHandler.uploadedSounds.get(tile.getSelectedIndex()).getCategory();
this.getFontRenderer().drawString(category, getWidth()/2 + 100 - (this.getFontRenderer().getStringWidth(category)/2), 90, 0xFFFFFF);

if (sound.getSoundLocation() != null)
{
String space = FileUtils.byteCountToDisplaySize(sound.getSoundLocation().length());
this.getFontRenderer().drawString(space, getWidth()/2 + 100 - (this.getFontRenderer().getStringWidth(space)/2), 120, 0xFFFFFF);
}
}
}

@Override
Expand All @@ -47,7 +70,14 @@ protected void func_146284_a(GuiButton button)
switch (button.field_146127_k)
{
case 0:
SoundsCool.proxy.getChannel().writeOutbound(new SoundPlayerPlayPacket(tile));
this.field_146297_k.func_147108_a(null);
this.field_146297_k.setIngameFocus();
break;
case 1:
if (tile.getSelectedSound() != null)
{
SoundsCool.proxy.getChannel().writeOutbound(new SoundPlayerPlayPacket(tile));
}
break;
}
}
Expand All @@ -73,13 +103,13 @@ public void selectSoundIndex(int selected)
@Override
public boolean soundIndexSelected(int var1)
{
return tile.getSelected() == var1;
return tile.getSelectedIndex() == var1;
}

@Override
public int getWidth()
{
return field_146295_m;
return field_146294_l;
}

@Override
Expand All @@ -93,4 +123,10 @@ public void drawBackground()
{
func_146276_q_();
}

@Override
public boolean doesGuiPauseGame()
{
return false;
}
}
38 changes: 33 additions & 5 deletions java/com/dynious/soundscool/client/gui/GuiSounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.dynious.soundscool.SoundsCool;
import com.dynious.soundscool.client.audio.SoundPlayer;
import com.dynious.soundscool.handler.NetworkHandler;
import com.dynious.soundscool.handler.SoundHandler;
import com.dynious.soundscool.helper.NetworkHelper;
import com.dynious.soundscool.network.packet.client.GetUploadedSoundsPacket;
Expand All @@ -12,6 +13,7 @@
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import org.apache.commons.io.FileUtils;

import javax.swing.*;

Expand All @@ -34,10 +36,10 @@ public void initGui()
{
super.initGui();
soundsList = new GuiLocalSoundsList(this, 150);
this.field_146292_n.add(new GuiButton(0, this.field_146294_l / 2 - 75, this.field_146295_m - 38, I18n.getStringParams("gui.done")));
this.field_146292_n.add(new GuiButton(1, this.field_146294_l / 2 - 75, 38, "Select File"));
this.field_146292_n.add(new GuiButton(2, this.field_146294_l / 2 - 75, field_146295_m/2 - 20, "Play Sound"));
this.field_146292_n.add(new GuiButton(3, this.field_146294_l / 2 - 75, field_146295_m/2 + 20, "Upload"));
this.field_146292_n.add(new GuiButton(0, getWidth() / 2, getHeight() - 42, I18n.getStringParams("gui.done")));
this.field_146292_n.add(new GuiButton(1, 10, getHeight() - 42, 150, 20, "Select File"));
this.field_146292_n.add(new GuiButton(2, getWidth() / 2, getHeight() - 102, "Play Sound"));
this.field_146292_n.add(new GuiButton(3, getWidth() / 2, getHeight() - 72, "Upload"));
fileChooser = new JFileChooser(Minecraft.getMinecraft().mcDataDir);
}

Expand All @@ -46,6 +48,26 @@ public void drawScreen(int p_571_1_, int p_571_2_, float p_571_3_)
{
this.soundsList.drawScreen(p_571_1_, p_571_2_, p_571_3_);
super.drawScreen(p_571_1_, p_571_2_, p_571_3_);

if (selectedSound != null)
{
this.getFontRenderer().drawString(selectedSound.getSoundName(), getWidth()/2 + 100 - (this.getFontRenderer().getStringWidth(selectedSound.getSoundName())/2), 30, 0xFFFFFF);

boolean hasSound = NetworkHandler.hasServerSound(selectedSound.getSoundName());
String uploaded = hasSound? "Uploaded": "Not uploaded";
this.getFontRenderer().drawString(uploaded, getWidth()/2 + + 100 - (this.getFontRenderer().getStringWidth(uploaded)/2), 60, hasSound? 0x00FF00: 0xFF0000);

if (selectedSound.getCategory() != null)
{
this.getFontRenderer().drawString(selectedSound.getCategory(), getWidth()/2 + 100 - (this.getFontRenderer().getStringWidth(selectedSound.getCategory())/2), 90, 0xFFFFFF);
}

if (selectedSound.getSoundLocation() != null)
{
String space = FileUtils.byteCountToDisplaySize(selectedSound.getSoundLocation().length());
this.getFontRenderer().drawString(space, getWidth()/2 + 100 - (this.getFontRenderer().getStringWidth(space)/2), 120, 0xFFFFFF);
}
}
}

@Override
Expand Down Expand Up @@ -120,7 +142,7 @@ public boolean soundIndexSelected(int var1)
@Override
public int getWidth()
{
return field_146295_m;
return field_146294_l;
}

@Override
Expand All @@ -134,4 +156,10 @@ public void drawBackground()
{
func_146276_q_();
}

@Override
public boolean doesGuiPauseGame()
{
return false;
}
}
3 changes: 0 additions & 3 deletions java/com/dynious/soundscool/command/CommandSoundsCool.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.dynious.soundscool.command;

import com.dynious.soundscool.SoundsCool;
import com.dynious.soundscool.helper.NetworkHelper;
import com.dynious.soundscool.lib.Commands;
import com.dynious.soundscool.network.packet.server.OpenGUIPacket;
import com.dynious.soundscool.network.packet.server.SoundNotFoundPacket;
import cpw.mods.fml.common.network.FMLOutboundHandler;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
Expand Down
29 changes: 29 additions & 0 deletions java/com/dynious/soundscool/creativetab/CreativeTabSoundsCool.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.dynious.soundscool.creativetab;

import com.dynious.soundscool.block.ModBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;

public class CreativeTabSoundsCool extends CreativeTabs
{
public CreativeTabSoundsCool(int id, String name)
{
super(id, name);
}

@Override
public Item getTabIconItem()
{
return null;
}

@SideOnly(Side.CLIENT)
public ItemStack func_151244_d()
{
return new ItemStack(ModBlocks.soundPlayer);
}
}
2 changes: 0 additions & 2 deletions java/com/dynious/soundscool/handler/GuiHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int
switch(ID)
{
case 0:
System.out.println("Opening GUI");
return new GuiSounds(player);
case 1:
System.out.println("Opening GUI");
TileEntity tile = world.func_147438_o(x, y, z);
if (tile != null && tile instanceof TileSoundPlayer)
{
Expand Down
Loading

0 comments on commit 7fef3a2

Please sign in to comment.