Started working on the new config GUI. Looks pretty nice!
This commit is contained in:
@@ -11,15 +11,21 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import de.skate702.craftingkeys.config.Config;
|
||||
import de.skate702.craftingkeys.config.GuiConfig;
|
||||
import de.skate702.craftingkeys.config.GuiConfigHandler;
|
||||
import de.skate702.craftingkeys.manager.*;
|
||||
import de.skate702.craftingkeys.proxies.CraftingKeysProxy;
|
||||
import de.skate702.craftingkeys.util.Logger;
|
||||
import de.skate702.craftingkeys.util.Util;
|
||||
import net.minecraft.client.gui.GuiEnchantment;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiMerchant;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.*;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
/**
|
||||
* The Main Class of the Mod with the important onTick-Method. Some Methods are
|
||||
@@ -69,8 +75,9 @@ public class CraftingKeys {
|
||||
public void load(FMLInitializationEvent event) {
|
||||
|
||||
// Registering
|
||||
proxy.registerRenderers();
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiConfigHandler());
|
||||
Logger.info("load(e)", "Registered Mod.");
|
||||
|
||||
}
|
||||
@@ -84,6 +91,11 @@ public class CraftingKeys {
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be executed when the Config is changed. Update!
|
||||
*
|
||||
* @param eventArgs Input event from FML
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
|
||||
if (eventArgs.modID.equals(MODID)) {
|
||||
@@ -92,6 +104,18 @@ public class CraftingKeys {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method listens on GUIs open. Just to test my own gui!
|
||||
*
|
||||
* @param event Some Forge input event
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public void onGuiOpened(GuiOpenEvent event) {
|
||||
if (event.gui instanceof GuiMainMenu) {
|
||||
event.gui = new GuiConfig(); // Delete this!
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be executed every Ingame Tick.
|
||||
*
|
||||
@@ -100,6 +124,10 @@ public class CraftingKeys {
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent tick) {
|
||||
|
||||
if (Util.client.currentScreen == null) {
|
||||
// Util.client.thePlayer.openGui(instance, 702, Util.client.theWorld, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Get current Screen, then test
|
||||
GuiScreen currentScreen = Util.client.currentScreen;
|
||||
|
||||
|
||||
@@ -1,6 +1,46 @@
|
||||
package de.skate702.craftingkeys.config;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class GuiConfig extends GuiScreen {
|
||||
|
||||
public static final int GuiID = 702;
|
||||
private GuiTextField testText;
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
|
||||
buttonList.add((new GuiButton(0, width / 2 - 58, height / 2 - 84, 19, 18, "Q")));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
|
||||
//GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
//GL11.glTranslatef(0.0f, 0.0f, -1.0f);
|
||||
|
||||
Color pureWhite = new Color(255, 255, 255, 255);
|
||||
//drawWorldBackground(0);
|
||||
drawDefaultBackground();
|
||||
|
||||
drawCenteredString(fontRendererObj, "Crafting Keys Config", width / 2, height / 2 - 115, pureWhite.getRGB());
|
||||
|
||||
mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/crafting_table.png"));
|
||||
drawTexturedModalRect(width / 2 - 86, height / 2 - 100, 1, 0, 174, 80);
|
||||
|
||||
drawHorizontalLine(width / 2 - 110, width / 2 + 110, height / 2 - 20, pureWhite.getRGB());
|
||||
|
||||
drawCenteredString(fontRendererObj, "Configure your keys here. Click \"Save\" when finished!", width / 2, height / 2 - 10, pureWhite.getRGB());
|
||||
|
||||
//drawRect(width / 2 - 100, width / 2 + 100, height / 2 - 5, height / 2 + 5, pureWhite.getRGB());
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package de.skate702.craftingkeys.config;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GuiConfigHandler implements IGuiHandler {
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (ID == GuiConfig.GuiID) {
|
||||
return new GuiConfig();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
*/
|
||||
public class CraftingKeysClientProxy extends CraftingKeysProxy {
|
||||
|
||||
@Override
|
||||
public void registerRenderers() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSlotClick(PlayerControllerMP controller, int windowId, int slot, int rightClick, int action,
|
||||
EntityPlayer player) {
|
||||
|
||||
@@ -12,13 +12,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
*/
|
||||
public class CraftingKeysProxy {
|
||||
|
||||
/**
|
||||
* Register Renderers (not needed here).
|
||||
*/
|
||||
public void registerRenderers() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Minecraft call to send a mouse click to a GUI. [Based on INVTW]
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user