Added loading, changing and saving keys. Only some TODOs left!
This commit is contained in:
@@ -13,7 +13,6 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|||||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
import de.skate702.craftingkeys.config.Config;
|
import de.skate702.craftingkeys.config.Config;
|
||||||
import de.skate702.craftingkeys.config.GuiConfig;
|
|
||||||
import de.skate702.craftingkeys.config.GuiConfigHandler;
|
import de.skate702.craftingkeys.config.GuiConfigHandler;
|
||||||
import de.skate702.craftingkeys.manager.*;
|
import de.skate702.craftingkeys.manager.*;
|
||||||
import de.skate702.craftingkeys.proxies.CraftingKeysProxy;
|
import de.skate702.craftingkeys.proxies.CraftingKeysProxy;
|
||||||
@@ -109,7 +108,7 @@ public class CraftingKeys {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onGuiOpened(GuiOpenEvent event) {
|
public void onGuiOpened(GuiOpenEvent event) {
|
||||||
if (event.gui instanceof GuiMainMenu) {
|
if (event.gui instanceof GuiMainMenu) {
|
||||||
event.gui = new GuiConfig(); // Delete this!
|
//event.gui = new GuiConfig(); // Delete this!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +121,7 @@ public class CraftingKeys {
|
|||||||
public void onTick(TickEvent.ClientTickEvent tick) {
|
public void onTick(TickEvent.ClientTickEvent tick) {
|
||||||
|
|
||||||
if (Util.client.currentScreen == null) {
|
if (Util.client.currentScreen == null) {
|
||||||
// Util.client.thePlayer.openGui(instance, 702, Util.client.theWorld, 0, 0, 0);
|
Util.client.thePlayer.openGui(instance, 702, Util.client.theWorld, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get current Screen, then test
|
// Get current Screen, then test
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package de.skate702.craftingkeys.config;
|
|||||||
|
|
||||||
import de.skate702.craftingkeys.util.LanguageLocalizer;
|
import de.skate702.craftingkeys.util.LanguageLocalizer;
|
||||||
import de.skate702.craftingkeys.util.Logger;
|
import de.skate702.craftingkeys.util.Logger;
|
||||||
|
import de.skate702.craftingkeys.util.Util;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
@@ -19,7 +21,7 @@ public class GuiConfig extends GuiScreen {
|
|||||||
private static final Color pureWhite = new Color(255, 255, 255, 255);
|
private static final Color pureWhite = new Color(255, 255, 255, 255);
|
||||||
private static final Color lightGray = new Color(128, 128, 128, 255);
|
private static final Color lightGray = new Color(128, 128, 128, 255);
|
||||||
private static final Color highlight = new Color(86, 144, 72, 255);
|
private static final Color highlight = new Color(86, 144, 72, 255);
|
||||||
int[] keyValues;
|
private int[] keyValues = new int[]{};
|
||||||
private int guiBasePosition;
|
private int guiBasePosition;
|
||||||
private int guiShowBasePosition;
|
private int guiShowBasePosition;
|
||||||
private int guiShowBaseHeight;
|
private int guiShowBaseHeight;
|
||||||
@@ -30,6 +32,7 @@ public class GuiConfig extends GuiScreen {
|
|||||||
private int buttonSaveID = 901;
|
private int buttonSaveID = 901;
|
||||||
private int buttonAbortID = 902;
|
private int buttonAbortID = 902;
|
||||||
private ArrayList<GuiButton> configButtons;
|
private ArrayList<GuiButton> configButtons;
|
||||||
|
private int selectedButtonID = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
@@ -127,17 +130,59 @@ public class GuiConfig extends GuiScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(GuiButton button) {
|
public void actionPerformed(GuiButton button) {
|
||||||
if (button.id == buttonAbortID) {
|
if (button.id == buttonAbortID) {
|
||||||
Logger.warn("actionPerformed(b)", "Not implemented yet");
|
Logger.info("actionPerformed(b)", "Closing Crafting Keys GUI now!");
|
||||||
|
Util.client.thePlayer.closeScreen();
|
||||||
|
mc.thePlayer.closeScreen();
|
||||||
|
Util.client.displayGuiScreen(null);
|
||||||
} else if (button.id == buttonSaveID) {
|
} else if (button.id == buttonSaveID) {
|
||||||
Logger.warn("actionPerformed(b)", "Not implemented yet");
|
save();
|
||||||
|
Logger.info("actionPerformed(b)", "Saving & closing Crafting Keys GUI now!");
|
||||||
|
Util.client.thePlayer.closeScreen();
|
||||||
|
} else if (button.id >= 0 && button.id <= 11) {
|
||||||
|
if (selectedButtonID == -1) {
|
||||||
|
selectedButtonID = button.id;
|
||||||
|
configButtons.get(selectedButtonID).displayString = "...";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void save() {
|
||||||
|
Config.keyTopLeft.set(keyValues[0]);
|
||||||
|
Config.keyTopCenter.set(keyValues[1]);
|
||||||
|
Config.keyTopRight.set(keyValues[2]);
|
||||||
|
Config.keyCenterLeft.set(keyValues[3]);
|
||||||
|
Config.keyCenterCenter.set(keyValues[4]);
|
||||||
|
Config.keyCenterRight.set(keyValues[5]);
|
||||||
|
Config.keyLowerLeft.set(keyValues[6]);
|
||||||
|
Config.keyLowerCenter.set(keyValues[7]);
|
||||||
|
Config.keyLowerRight.set(keyValues[8]);
|
||||||
|
Config.keyInteract.set(keyValues[9]);
|
||||||
|
Config.keyStack.set(keyValues[10]);
|
||||||
|
Config.keyDrop.set(keyValues[11]);
|
||||||
|
Config.syncConfig();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(char character, int keyCode) {
|
public void keyTyped(char character, int keyCode) {
|
||||||
|
|
||||||
|
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||||
|
selectedButtonID = -1;
|
||||||
|
drawKeyValues();
|
||||||
|
} else if (selectedButtonID != -1) {
|
||||||
|
if (!ArrayUtils.contains(keyValues, keyCode)) { // No double keys
|
||||||
|
keyValues[selectedButtonID] = keyCode;
|
||||||
|
selectedButtonID = -1;
|
||||||
|
drawKeyValues();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Lang files
|
||||||
|
// TODO: Config files
|
||||||
|
// TODO: Crafting symbols
|
||||||
|
// TODO: KeyBindings
|
||||||
|
|
||||||
private void drawCraftingTable() {
|
private void drawCraftingTable() {
|
||||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||||
mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/crafting_table.png"));
|
mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/crafting_table.png"));
|
||||||
@@ -230,19 +275,21 @@ public class GuiConfig extends GuiScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initKeyValues() {
|
private void initKeyValues() {
|
||||||
keyValues = new int[]{
|
if (keyValues.length == 0) {
|
||||||
Config.keyTopLeft.getInt(),
|
keyValues = new int[]{
|
||||||
Config.keyTopCenter.getInt(),
|
Config.keyTopLeft.getInt(),
|
||||||
Config.keyTopRight.getInt(),
|
Config.keyTopCenter.getInt(),
|
||||||
Config.keyCenterLeft.getInt(),
|
Config.keyTopRight.getInt(),
|
||||||
Config.keyCenterCenter.getInt(),
|
Config.keyCenterLeft.getInt(),
|
||||||
Config.keyCenterRight.getInt(),
|
Config.keyCenterCenter.getInt(),
|
||||||
Config.keyLowerLeft.getInt(),
|
Config.keyCenterRight.getInt(),
|
||||||
Config.keyLowerCenter.getInt(),
|
Config.keyLowerLeft.getInt(),
|
||||||
Config.keyLowerRight.getInt(),
|
Config.keyLowerCenter.getInt(),
|
||||||
Config.keyInteract.getInt(),
|
Config.keyLowerRight.getInt(),
|
||||||
Config.keyStack.getInt(),
|
Config.keyInteract.getInt(),
|
||||||
Config.keyDrop.getInt()};
|
Config.keyStack.getInt(),
|
||||||
|
Config.keyDrop.getInt()};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawKeyValues() {
|
private void drawKeyValues() {
|
||||||
|
|||||||
Reference in New Issue
Block a user