Compare commits

...
Author SHA1 Message Date
Thomas Guimbretiere f28ed4c274 Added coloring for enchanted items. 2013-10-24 18:38:57 +02:00
Thomas Guimbretiere fc3606b71c When adding a widget, it is now possible to specify a render priority (LOW, MEDIUM, HIGH).
Widgets will be rendered in the order of insert in each category (allows to have forground widgets which are not mouse stealing).
Fixed again the Config HUD screen using that.
2013-10-24 17:38:35 +02:00
Thomas Guimbretiere aeff9c1039 Might have fixed IAmOmicron bug.
Fixed HUD config screen.
2013-10-24 17:22:17 +02:00
Thomas Guimbretiere 9fd13c9ca1 Fixed enchant mod detection.
Changed default key from RSHIFT to I
2013-10-24 17:12:42 +02:00
Thomas Guimbretiere ac1cc77258 Item enchantments done. 2013-10-24 16:31:39 +02:00
Thomas Guimbretiere e6005e55af First shot at partial enchant screen. 2013-10-24 15:48:44 +02:00
Thomas Guimbretiere 62ec48ba21 Added a ViewTable widget to display data in a table shape 2013-10-24 15:25:23 +02:00
Thomas Guimbretiere 7ab8981dde All layouts depend on LayoutBase.
LayoutBase now allows for a background gradient. (setBackgroundColors)
To handle multilayers, widget rendering is done from the start of the list to
the end (in the order of insert), but widget lookup is done in revert order (
last inserted widget will be returned first).
Added utility class for reverse lookup (ReverseIterator).
2013-10-24 11:39:35 +02:00
Thomas Guimbretiere f8202e8fa8 Fixed cropping layout. 2013-10-24 03:22:41 +02:00
Thomas Guimbretiere b18fb9df61 Fixed dragging on the HUD. 2013-10-24 02:20:29 +02:00
Thomas Guimbretiere b4ca299115 Better handling of dragging when leaving the widget (moved some dragging identification to canvas). 2013-10-24 02:08:56 +02:00
Thomas Guimbretiere b0104482bb More adjustement on dragging. 2013-10-24 01:58:37 +02:00
Thomas Guimbretiere ef9ee6441d Fixed some mouse handling (keeping the drag going when on the main widget, stopping the drag on leaving, etc). 2013-10-24 01:52:02 +02:00
Thomas Guimbretiere 4ad3e92fae Mouse handling of the escalator. 2013-10-24 01:42:54 +02:00
Thomas Guimbretiere 098c88676e Corrected order of msg sending for GEOM_CHANGED (post change)
Cursor is now working properly.
2013-10-24 01:12:10 +02:00
Thomas Guimbretiere 4b05b017f7 Moved setPos / setSize to IWidget.
Modifying the geometry now triggers a GEOM_CHANGED event.
2013-10-23 22:19:19 +02:00
Thomas Guimbretiere a92a5dde3c ViewportScrollable is now its own class. 2013-10-23 21:21:34 +02:00
Thomas Guimbretiere a6890c5824 Test widget is bounded on mousewheel.
Added a possibility of setting up the steping (in px).
2013-10-23 20:51:26 +02:00
Thomas Guimbretiere e87d08a789 Reverse lookup for mouse move & drag. 2013-10-23 20:39:31 +02:00
Thomas Guimbretiere 65d8ef8c63 Fixed a couple of button bugs. 2013-10-23 20:33:56 +02:00
Thomas Guimbretiere 878a00b16b Reverse lookup on click/release. 2013-10-23 20:28:37 +02:00
Thomas Guimbretiere 984b26c7fd Reverse lookup for MouseEnter/MouseLeave 2013-10-23 20:16:42 +02:00
Thomas Guimbretiere b2cc1e02d7 Added inverted lookup for MouseWheel.
getWidgetAtPosition does return the deepest widget, so mouse events should check the parent for implementation, not the childrens !
2013-10-23 20:09:27 +02:00
Thomas Guimbretiere 83c7ef6aa9 Corrected a position bug in ItemStackDisplay
Added LayoutCropping (cropping layout using scissors).
2013-10-22 12:05:49 +02:00
Thomas Guimbretiere 6fca3468e2 Cleanup 2013-10-22 11:25:51 +02:00
Thomas Guimbretiere d134aba573 Added scalable ItemStack display. 2013-10-22 11:02:41 +02:00
Thomas Guimbretiere 8f32c0c770 Cleanup 2013-10-22 00:32:56 +02:00
Thomas Guimbretiere e0a5da865f Linked the HUD config screen to the Waila config screen. 2013-10-21 22:56:55 +02:00
Thomas Guimbretiere 69a62e6edf And finally, the scale. Can be adjusted between 0.1 and 2.0. 2013-10-21 22:42:26 +02:00
Thomas Guimbretiere a6da4adc08 Alpha is now configurable too.
Colors can be changed from the config file.
2013-10-21 22:09:43 +02:00
Thomas Guimbretiere 2d3768423f Widgets are now stored in a LinkedHashMap (for proper sorting).
Better Save/Load of GL State (includes colors).
Restored all the buttons on the config screen.
Config is now saved properly and used.
Possibility to reset to defaults.
2013-10-21 20:03:24 +02:00
Thomas Guimbretiere cb2491f3f3 Fixed dragging when other widgets are present. 2013-10-21 18:31:45 +02:00
Thomas Guimbretiere 9248b75a0c Draggable picture in the position config screen is now using relative positions.
Should be behaving like you would expect.
2013-10-21 18:08:16 +02:00
Thomas Guimbretiere fc46634fcc Shorter enum names
Mouse pos is now a double for finer control (?)
2013-10-21 02:54:59 +02:00
Thomas Guimbretiere 9df8f252c0 Changed the position/size type to an enum to make it clearer 2013-10-21 02:28:34 +02:00
Thomas Guimbretiere a844fb4815 Added default configs.
Killed the config screen (again)
2013-10-21 01:49:45 +02:00
Thomas Guimbretiere 58266d3cd1 More advance in the hud config screen. 2013-10-20 17:35:48 +02:00
Thomas Guimbretiere 94a22bf6ca Reworked the event system. Now events are pushed upward to the first widget which can treat them.
No more slots. Best practice is to create a LayoutBase derived class, and handle the events in there.
2013-10-20 17:08:08 +02:00
Thomas Guimbretiere 32a50e112b Singals and slots are now enums.
Added a few widgets to the config screen.
2013-10-20 16:34:32 +02:00
Thomas Guimbretiere 6dbcf366bd Added basic inter-widget signal passing.
LabelFixedFont now has a setText slot (to change text to first signal argument).
PictureMovable will emit onDragX/onDragY events when dragged.
WidgetBase now has slots to move the widget around (setPosX, setPosY).
WidgetGeometry allows to change the position of the widget without having to recreate the geom
Added a CounterInteger widget to store integer data. Slots to change the value and signals to advertise the change.
2013-10-20 12:14:48 +02:00
Thomas Guimbretiere 24efba751d Added a PictureMovable widget, that you can drag and drop around. Area of action is constrainted by the parent.
Added getTop() getBottom() to IWidget interface (shortcuts for getPos().getY() and getPos().getY() + getSize().getY() )
2013-10-19 15:38:51 +02:00
Thomas Guimbretiere e681b98231 Fix alignment for Module choice 2013-10-18 20:20:46 +02:00
Thomas Guimbretiere 30d88b4c45 Readded support for remote config keys.
Moved keyboard handling out of the old UI package.
2013-10-18 12:18:51 +02:00
Thomas Guimbretiere 9a13ff7898 Fixed derp in calling wrong recipe method. 2013-10-18 11:59:11 +02:00
Thomas Guimbretiere 91ac3a9e32 Fixed recipe lookup for blocks with metadata. If not recipe is found with meta, we lookup recipes without meta. 2013-10-18 11:56:32 +02:00
Thomas Guimbretiere 1036c7c0c0 Added the final missing config screens. Config keybind now popups up the new screens.
Still need to remake the server bound config buttons.
2013-10-18 11:51:16 +02:00
Thomas Guimbretiere c03d9183a8 Added main config screen.
Added clicky sound on buttons.
2013-10-18 02:25:47 +02:00
Thomas Guimbretiere 5da91bea2d Fixed MouseEnter/MouseLeave and getWidgetAtPosition logic.
Buttons labels now have the proper color.
Fixed ID:Metadata HEADER bug.
2013-10-18 02:05:19 +02:00
Thomas Guimbretiere c2ceb365d9 Derp 2013-10-18 00:58:23 +02:00
Thomas Guimbretiere 4488c37149 Added a ButtonContainer with label handling.
Created the basic Waila config screen.
2013-10-18 00:58:03 +02:00
Thomas Guimbretiere 3c3fcad888 Screen change button
More test classes in gui.testing
2013-10-17 22:17:13 +02:00
Thomas Guimbretiere 391cfe8290 Added buttons linked to config options (specific to Waila). 2013-10-17 21:47:56 +02:00
Thomas Guimbretiere 8c2ff2b56f Vertical spacing of buttons is now absolute 2013-10-17 21:21:38 +02:00
Thomas Guimbretiere d9a16ba7fa Added per-coordinate abs/frac capabilities for pos & size in WidgetGeometry 2013-10-17 21:16:50 +02:00
Thomas Guimbretiere 3b906f4de8 Moved buttons to their own package. 2013-10-17 21:03:49 +02:00
Thomas Guimbretiere 0496543d70 Added a button container for easy grid-layout buttons 2013-10-17 21:01:12 +02:00
Thomas Guimbretiere e9cc68d2b1 Added 2 types of buttons (boolean & integer) to the widgets. 2013-10-17 20:10:16 +02:00
Thomas Guimbretiere 8a5dc45240 Added a PictureSwitch widget, switching between 2 pictures on mouse over. 2013-10-11 22:03:36 +02:00
Thomas Guimbretiere d23855b263 Added show,hide to widgets.
Renamed Label to LabelFixedFont
2013-10-11 21:54:44 +02:00
Thomas Guimbretiere 5601fcdf7b Added Label widget.
Reworked WidgetGeometry to allow for separate pos/size computation method.
2013-10-11 21:43:58 +02:00
Thomas Guimbretiere a87d3b9de7 Nothing is absolute anymore. Everything is relative to the parent, in full or fractional value 2013-10-11 15:24:01 +02:00
Thomas Guimbretiere 67775bad84 Added ENTER and LEAVE events. 2013-10-11 15:19:24 +02:00
Thomas Guimbretiere 3d004700fb Mouse event handling. 2013-10-11 14:50:07 +02:00
Thomas Guimbretiere b3b2024ce7 Generic structure of new widgets is up.
Test screen with a test texture is done.
2013-10-09 22:58:39 +02:00
Thomas Guimbretiere c1cfb94a0d Setup basic testing framework for the new UI system. 2013-10-09 15:52:26 +02:00
Thomas Guimbretiere 029d141872 Bumped version
May have fixed a light prb when looking at ents.
2013-10-04 20:33:58 +02:00
Thomas Guimbretiere ed93c68fb9 Added registration methods for tail changes along with proper calls to the registrated classes. 2013-10-04 20:02:27 +02:00
Thomas Guimbretiere 4b8acb517e Added "getWailaTail" to the API 2013-10-04 19:55:26 +02:00
Thomas Guimbretiere 419308e2ac Rearranged inworld recipe check to prevent crash on NEI cache loading. 2013-10-04 19:48:55 +02:00
Thomas Guimbretiere 8dc890421d More adjusting and desactivation of NEI overlay. 2013-10-04 18:55:19 +02:00
Thomas Guimbretiere fe90900b55 Adjusted the block discovery system a bit. 2013-10-04 16:30:55 +02:00
Thomas Guimbretiere 1d9807e6d6 Added in-world recipe/usage lookup. 2013-10-04 16:02:21 +02:00
Thomas Guimbretiere 58931febc4 Fixed the proxy raytracing. 2013-10-04 15:04:59 +02:00
Thomas Guimbretiere d72dfa5775 Added support for entities.
Added missing files.
2013-10-04 14:55:01 +02:00
Thomas Guimbretiere dbf49534da Added liquid raytracing 2013-10-04 13:33:59 +02:00
Thomas Guimbretiere aad38c1eac Added a new block recovery test by using a fresh block if the block do not have a TE. 2013-10-04 13:07:08 +02:00
Thomas Guimbretiere c0727b2157 Moved overlay renderer from NEI to Waila for easier handling. 2013-10-02 18:00:53 +02:00
Thomas Guimbretiere 3085f7442a Added tag 1.3.9_1.6.2 for changeset 1e7cde94ccce 2013-09-04 00:12:37 +02:00
103 changed files with 3938 additions and 295 deletions

No files matched your search

+171
View File
@@ -0,0 +1,171 @@
package mcp.mobius.waila;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import org.lwjgl.input.Keyboard;
import codechicken.core.Profiler;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.api.API;
import codechicken.nei.forge.GuiContainerManager;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiUsageRecipe;
import codechicken.nei.recipe.ICraftingHandler;
import codechicken.nei.recipe.ProfilerRecipeHandler;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.screens.config.ScreenConfig;
import mcp.mobius.waila.gui.screens.config.ScreenHUDConfig;
import mcp.mobius.waila.gui.screens.config.ScreenWailaConfig;
import mcp.mobius.waila.gui.screens.info.ScreenEnchants;
import mcp.mobius.waila.gui.testing.ScreenTest;
import mcp.mobius.waila.handlers.nei.HandlerEnchants;
import mcp.mobius.waila.overlay.RayTracing;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumMovingObjectType;
import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.registry.LanguageRegistry;
public class ConfigKeyHandler extends KeyHandler {
static boolean firstInventory = true;
public ConfigKeyHandler()
{
super(new KeyBinding[]{
new KeyBinding(Constants.BIND_WAILA_CFG, Keyboard.KEY_NUMPAD0),
new KeyBinding(Constants.BIND_WAILA_SHOW, Keyboard.KEY_NUMPAD1),
new KeyBinding(Constants.BIND_WAILA_LIQUID, Keyboard.KEY_NUMPAD2),
new KeyBinding(Constants.BIND_WAILA_RECIPE, Keyboard.KEY_NUMPAD3),
new KeyBinding(Constants.BIND_WAILA_USAGE, Keyboard.KEY_NUMPAD4),
new KeyBinding(Constants.BIND_WAILA_TESTING, Keyboard.KEY_NUMPAD9),
}, new boolean[]{
false,
false,
false,
false,
false,
false
});
LanguageRegistry.instance().addStringLocalization(Constants.BIND_WAILA_CFG, "[Waila] Config screen");
LanguageRegistry.instance().addStringLocalization(Constants.BIND_WAILA_SHOW, "[Waila] Show/Hide");
LanguageRegistry.instance().addStringLocalization(Constants.BIND_WAILA_LIQUID, "[Waila] Show liquids");
LanguageRegistry.instance().addStringLocalization(Constants.BIND_WAILA_RECIPE, "[Waila] Show recipe");
LanguageRegistry.instance().addStringLocalization(Constants.BIND_WAILA_USAGE, "[Waila] Show usage");
LanguageRegistry.instance().addStringLocalization(Constants.BIND_WAILA_TESTING, "[Waila] Testing");
//LanguageRegistry.instance().addStringLocalization(Constants.BIND_SCREEN_ENCH, "[Waila] Show enchant screen");
//LanguageRegistry.instance().addStringLocalization("key.wailatedump", "[Waila] Dump server TE");
GuiContainerManager.addInputHandler(new HandlerEnchants());
API.addKeyBind(Constants.BIND_SCREEN_ENCH, Keyboard.KEY_I);
}
@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {
if (!tickEnd) return;
Minecraft mc = Minecraft.getMinecraft();
if (kb.keyDescription == Constants.BIND_WAILA_CFG){
if(mc.currentScreen == null)
mc.displayGuiScreen(new ScreenConfig(mc.currentScreen));
}
if (kb.keyDescription == Constants.BIND_WAILA_TESTING){
if(mc.currentScreen == null)
mc.displayGuiScreen(new ScreenEnchants(mc.currentScreen));
}
if (mc.currentScreen != null)
return;
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && ConfigHandler.instance().getConfig(Constants.CFG_WAILA_MODE)){
boolean status = ConfigHandler.instance().getConfig(Constants.CFG_WAILA_SHOW);
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_SHOW, !status);
}
else if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig(Constants.CFG_WAILA_MODE)){
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_SHOW, true);
}
else if (kb.keyDescription == Constants.BIND_WAILA_LIQUID){
boolean status = ConfigHandler.instance().getConfig(Constants.CFG_WAILA_LIQUID);
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_LIQUID, !status);
}
else if (kb.keyDescription == Constants.BIND_WAILA_RECIPE){
this.openRecipeGUI(true);
}
else if (kb.keyDescription == Constants.BIND_WAILA_USAGE){
this.openRecipeGUI(false);
}
}
public void openRecipeGUI(boolean recipe){
Minecraft mc = Minecraft.getMinecraft();
boolean uiResult;
String msg;
if ((RayTracing.raytracedTarget != null) && (RayTracing.raytracedTarget.typeOfHit == EnumMovingObjectType.TILE)){
List<ItemStack> stacks = RayTracing.getIdentifierItems();
if (stacks.size() > 0){
mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
if (firstInventory){
try {Thread.sleep(1000);} catch (Exception e){};
firstInventory = false;
}
if(recipe)
if(!GuiCraftingRecipe.openRecipeGui("item", stacks.get(0).copy())){
ItemStack target = stacks.get(0).copy();
target.setItemDamage(0);
if(!GuiCraftingRecipe.openRecipeGui("item", target)){
mc.thePlayer.addChatMessage("\u00a7f\u00a7oNo recipe found.");
mc.displayGuiScreen((GuiScreen)null);
mc.setIngameFocus();
}
}
if(!recipe)
if(!GuiUsageRecipe.openRecipeGui("item", stacks.get(0).copy())){
ItemStack target = stacks.get(0).copy();
target.setItemDamage(0);
if(!GuiUsageRecipe.openRecipeGui("item", target)){
mc.thePlayer.addChatMessage("\u00a7f\u00a7oNo usage found.");
mc.displayGuiScreen((GuiScreen)null);
mc.setIngameFocus();
}
}
}
}
}
@Override
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {
if (!tickEnd) return;
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig(Constants.CFG_WAILA_MODE)){
ConfigHandler.instance().setConfig(Constants.CFG_WAILA_SHOW, false);
}
}
@Override
public EnumSet<TickType> ticks() {
return EnumSet.of(TickType.CLIENT);
}
@Override
public String getLabel() {
return "Waila Config Screen Keybind";
}
}
+23 -4
View File
@@ -5,11 +5,30 @@ public final class Constants {
public static String BIND_SCREEN_TECH = "showtechtree";
public static String BIND_SCREEN_ENCH = "showenchant";
public static String BIND_WAILA_CFG = "key.wailaconfig";
public static String BIND_WAILA_SHOW = "key.wailadisplay";
public static String BIND_WAILA_CFG = "key.wailaconfig";
public static String BIND_WAILA_SHOW = "key.wailadisplay";
public static String BIND_WAILA_LIQUID = "waila.key.liquid";
public static String BIND_WAILA_RECIPE = "waila.key.recipe";
public static String BIND_WAILA_USAGE = "waila.key.usage";
public static String BIND_WAILA_TESTING= "waila.key.testing";
public static String CFG_NEI_SHOW = "world.highlight_tips";
public static String CFG_NEI_SHOW = "world.highlight_tips";
public static String BIND_NEI_SHOW = "keys.world.highlight_tips";
public static String CFG_WAILA_SHOW = "waila.cfg.show";
public static String CFG_WAILA_MODE = "waila.cfg.showmode";
public static String CFG_WAILA_LIQUID = "waila.cfg.liquid";
public static String CFG_WAILA_METADATA = "waila.cfg.metadata";
public static String CFG_WAILA_POSX = "waila.cfg.posx";
public static String CFG_WAILA_POSY = "waila.cfg.posy";
public static String CFG_WAILA_SCALE = "waila.cfg.scale";
public static String CFG_WAILA_ALPHA = "waila.cfg.alpha";
public static String CFG_WAILA_BGCOLOR = "waila.cfg.bgcolor";
public static String CFG_WAILA_GRADIENT1 = "waila.cfg.gradient1";
public static String CFG_WAILA_GRADIENT2 = "waila.cfg.gradient2";
public static String CFG_WAILA_FONTCOLOR = "waila.cfg.fontcolor";
}
+12 -8
View File
@@ -9,6 +9,8 @@ import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.forge.GuiContainerManager;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.addons.appeng.AppEngModule;
import mcp.mobius.waila.addons.betterbarrels.BetterBarrelsModule;
@@ -19,13 +21,14 @@ import mcp.mobius.waila.addons.ic2.IC2Module;
import mcp.mobius.waila.addons.thaumcraft.ThaumcraftModule;
import mcp.mobius.waila.addons.twilightforest.TwilightForestModule;
import mcp.mobius.waila.addons.vanillamc.HUDHandlerVanilla;
import mcp.mobius.waila.gui.ConfigKeyHandler;
import mcp.mobius.waila.handlers.HUDHandlerExternal;
import mcp.mobius.waila.handlers.HUDHandlerWaila;
import mcp.mobius.waila.gui_old.NEI.HandlerTechTree;
import mcp.mobius.waila.gui_old.NEI.HandlerWiki;
import mcp.mobius.waila.handlers.SummaryProviderDefault;
import mcp.mobius.waila.handlers.HandlerTechTree;
import mcp.mobius.waila.handlers.TooltipHandlerWaila;
import mcp.mobius.waila.handlers.HandlerWiki;
import mcp.mobius.waila.handlers.hud.HUDHandlerExternal;
import mcp.mobius.waila.handlers.hud.HUDHandlerWaila;
import mcp.mobius.waila.handlers.nei.HandlerEnchants;
import mcp.mobius.waila.handlers.tooltip.TooltipHandlerWaila;
import mcp.mobius.waila.overlay.WailaTickHandler;
import mcp.mobius.waila.server.ProxyServer;
public class ProxyClient extends ProxyServer {
@@ -35,6 +38,8 @@ public class ProxyClient extends ProxyServer {
@Override
public void registerHandlers(){
TickRegistry.registerTickHandler(new WailaTickHandler(), Side.CLIENT);
GuiContainerManager.addTooltipHandler(new TooltipHandlerWaila());
API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.HEADER);
API.registerHighlightHandler(new HUDHandlerExternal(), ItemInfo.Layout.BODY);
@@ -45,9 +50,8 @@ public class ProxyClient extends ProxyServer {
// We mute the default keybind for displaying the tooltip
NEIClientConfig.getSetting(Constants.BIND_NEI_SHOW).setIntValue(Keyboard.KEY_NONE);
NEIClientConfig.getSetting(Constants.CFG_NEI_SHOW).setBooleanValue(false);
//GuiContainerManager.addInputHandler(new TechTreeHandler());
//API.addKeyBind(Constants.BIND_ENCH, "Display enchantements", Keyboard.KEY_RSHIFT);
//API.addKeyBind(Constants.BIND_WIKI, "Display wiki", Keyboard.KEY_RSHIFT);
//API.addKeyBind(Constants.BIND_TECH, "Display techtree", Keyboard.KEY_RSHIFT);
+20 -1
View File
@@ -80,5 +80,24 @@ public class ConfigHandler implements IWailaConfigHandler {
@Override
public boolean getConfig(String key){
return this.getConfig(key, true);
}
}
public int getConfigInt(String key){
mod_Waila.instance.config.load();
Property prop = mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, 0);
return prop.getInt();
}
@Override
public void setConfig(String key, boolean value){
mod_Waila.instance.config.load();
mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, true).set(value);;
mod_Waila.instance.config.save();
}
public void setConfigInt(String key, int value){
mod_Waila.instance.config.load();
mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, key, 0).set(value);;
mod_Waila.instance.config.save();
}
}
@@ -11,16 +11,13 @@ import java.util.Set;
import java.util.logging.Level;
import au.com.bytecode.opencsv.CSVReader;
import net.minecraft.block.Block;
import codechicken.nei.api.API;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.api.IWailaSummaryProvider;
import mcp.mobius.waila.handlers.HUDHandlerExternal;
import mcp.mobius.waila.handlers.hud.HUDHandlerExternal;
public class ExternalModulesHandler implements IWailaRegistrar {
@@ -87,12 +84,14 @@ public class ExternalModulesHandler implements IWailaRegistrar {
this.bodyBlockProviders.get(block).add(dataProvider);
}
@Override
public void registerTailProvider(IWailaDataProvider dataProvider, int blockID) {
if (!this.tailProviders.containsKey(blockID))
this.tailProviders.put(blockID, new ArrayList<IWailaDataProvider>());
this.tailProviders.get(blockID).add(dataProvider);
}
@Override
public void registerTailProvider(IWailaDataProvider dataProvider, Class block) {
if (!this.tailBlockProviders.containsKey(block))
this.tailBlockProviders.put(block, new ArrayList<IWailaDataProvider>());
@@ -41,4 +41,9 @@ public class HUDAppEngMonitor implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -15,7 +15,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.api.ItemInfo.Layout;
@@ -56,4 +55,9 @@ public class HUDHandlerBBContent implements IWailaDataProvider {
}
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -35,4 +35,9 @@ public class HUDHandlerBCEngine implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -1,6 +1,7 @@
package mcp.mobius.waila.addons.buildcraft;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import mcp.mobius.waila.api.IWailaConfigHandler;
@@ -40,4 +41,9 @@ public class HUDHandlerBCIPowerReceptor implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -31,6 +31,11 @@ public class HUDHandlerBCPipes implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
public boolean hasPartialKey(NBTTagCompound tag, String key){
Map tagMap = (Map)Reflect.getFieldValue("net.minecraft.nbt.NBTTagCompound", "tagMap", tag);
for (Object k : tagMap.keySet())
@@ -8,6 +8,7 @@ import java.util.logging.Level;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
@@ -55,6 +56,11 @@ public class HUDHandlerBCTanks implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
public FluidTankInfo getTank(IWailaDataAccessor accessor){
FluidTankInfo tank = null;
@@ -41,4 +41,9 @@ public class HUDHandlerStorage implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -24,4 +24,9 @@ public class HUDHandlerGravestone implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -24,6 +24,9 @@ public class HUDHandlerDoor implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -57,6 +57,11 @@ public class HUDHandlerIC2IEnergySink implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
public boolean canUpgrade(NBTTagCompound tag){
if (tag.hasKey("InvSlots"))
@@ -42,6 +42,11 @@ public class HUDHandlerIC2IEnergySource implements IWailaDataProvider {
if (accessor.getNBTData().hasKey("storage") && !IC2Module.IEnergyStorage.isInstance(accessor.getTileEntity()))
currenttip.add(String.format("Storage : %s EU", accessor.getNBTInteger(accessor.getNBTData(), "storage")));
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -42,6 +42,11 @@ public class HUDHandlerIC2IEnergyStorage implements IWailaDataProvider {
if ((capacity != -1) && (stored != -1))
currenttip.add(String.format("%s/%s EU", stored, capacity));
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -35,4 +35,9 @@ public class HUDHandlerCapacitor implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -24,4 +24,8 @@ public class HUDHandlerLeaves implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -23,4 +23,8 @@ public class HUDHandlerPlants implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -23,5 +23,9 @@ public class TwilightForestGenericOverride implements IWailaDataProvider {
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
}
@@ -114,6 +114,11 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return currenttip;
}
public static void register(){
ExternalModulesHandler.instance().addConfig("VanillaMC", "vanilla.spawntype", "Spawner type");
+1
View File
@@ -29,4 +29,5 @@ public interface IWailaBlock {
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
}
@@ -23,4 +23,6 @@ public interface IWailaConfigHandler {
/* Returns the current value of an option (true/false) with a default value true if not set*/
public boolean getConfig(String key);
public void setConfig(String key, boolean value);
}
@@ -8,6 +8,7 @@ public interface IWailaRegistrar {
/* Register a IWailaDataProvider for the given blockID, either for the Head section or the Body section */
public void registerHeadProvider (IWailaDataProvider dataProvider, int blockID);
public void registerBodyProvider (IWailaDataProvider dataProvider, int blockID);
public void registerTailProvider (IWailaDataProvider dataProvider, int blockID);
/* Register a stack overrider for the given blockID */
public void registerStackProvider(IWailaDataProvider dataProvider, int blockID);
@@ -17,6 +18,7 @@ public interface IWailaRegistrar {
/* Same thing, but works on a class hierarchy instead */
public void registerHeadProvider (IWailaDataProvider dataProvider, Class block);
public void registerBodyProvider (IWailaDataProvider dataProvider, Class block);
public void registerTailProvider (IWailaDataProvider dataProvider, Class block);
public void registerDocTextFile (String filename);
@@ -1,72 +0,0 @@
package mcp.mobius.waila.gui;
import java.util.EnumSet;
import org.lwjgl.input.Keyboard;
import codechicken.nei.NEIClientConfig;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.addons.ConfigHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.registry.LanguageRegistry;
public class ConfigKeyHandler extends KeyHandler {
public ConfigKeyHandler()
{
super(new KeyBinding[]{
new KeyBinding(Constants.BIND_WAILA_CFG, Keyboard.KEY_NUMPAD0),
new KeyBinding(Constants.BIND_WAILA_SHOW, Keyboard.KEY_NUMPAD1),
//new KeyBinding("key.wailatedump", Keyboard.KEY_NUMPAD1),
}, new boolean[]{
false,
false,
//false
});
LanguageRegistry.instance().addStringLocalization(Constants.BIND_WAILA_CFG, "[Waila] Config screen");
LanguageRegistry.instance().addStringLocalization(Constants.BIND_WAILA_SHOW, "[Waila] Show/Hide");
//LanguageRegistry.instance().addStringLocalization("key.wailatedump", "[Waila] Dump server TE");
}
@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {
if (!tickEnd) return;
Minecraft mc = Minecraft.getMinecraft();
if (kb.keyDescription == Constants.BIND_WAILA_CFG){
if(mc.currentScreen == null)
mc.displayGuiScreen(new GuiConfigScreen(mc.currentScreen));
}
else if (kb.keyDescription == Constants.BIND_WAILA_SHOW && ConfigHandler.instance().getConfig("waila.showmode")){
boolean status = NEIClientConfig.getSetting(Constants.CFG_NEI_SHOW).getBooleanValue();
NEIClientConfig.getSetting(Constants.CFG_NEI_SHOW).setBooleanValue(!status);
}
else if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig("waila.showmode")){
NEIClientConfig.getSetting(Constants.CFG_NEI_SHOW).setBooleanValue(true);
}
}
@Override
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {
if (!tickEnd) return;
if (kb.keyDescription == Constants.BIND_WAILA_SHOW && !ConfigHandler.instance().getConfig("waila.showmode")){
NEIClientConfig.getSetting(Constants.CFG_NEI_SHOW).setBooleanValue(false);
}
}
@Override
public EnumSet<TickType> ticks() {
return EnumSet.of(TickType.CLIENT);
}
@Override
public String getLabel() {
return "Waila Config Screen Keybind";
}
}
-23
View File
@@ -1,23 +0,0 @@
package mcp.mobius.waila.gui;
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
import net.minecraft.client.gui.GuiScreen;
public class GuiConfigScreen extends BaseWailaScreen {
public GuiConfigScreen(GuiScreen _parentGui) {
super(_parentGui);
}
@Override
/* We init the GUI data here (buttons, etc) */
public void initGui()
{
buttonList.add(new ButtonChangeScreen(200, width / 2 - 100, height / 6 + 168, "Done", null));
ContainerButtons container = new ContainerButtons(this, 5, height/2-10, width - 10, height);
container.addButton(new ButtonChangeScreen(201, "Waila", new GuiWailaConfig(this) ));
container.addButton(new ButtonChangeScreen(202, "Modules", new GuiModules(this)));
}
}
@@ -1,33 +0,0 @@
package mcp.mobius.waila.gui;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
import mcp.mobius.waila.gui.widget_old.ButtonConfigOption;
import mcp.mobius.waila.gui.widget_old.ButtonConfigRemote;
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
import net.minecraft.client.gui.GuiScreen;
public class GuiModuleOptions extends BaseWailaScreen {
private String modName;
public GuiModuleOptions(GuiScreen _parentGui, String _modName) {
super(_parentGui);
this.modName = _modName;
}
@Override
public void initGui()
{
buttonList.add(new ButtonChangeScreen(200, width / 2 - 100, height / 6 + 168, "Back", this.parentGui));
ContainerButtons container = new ContainerButtons(this, 5, 0, width - 10, height);
for (String key:ConfigHandler.instance().getConfigKeys(this.modName).keySet()){
if (ConfigHandler.instance().isServerRequired(key))
container.addButton(new ButtonConfigRemote(-1, "No", "Yes", ConfigHandler.instance().getConfigKeys(this.modName).get(key), key ));
else
container.addButton(new ButtonConfigOption(-1, "No", "Yes", ConfigHandler.instance().getConfigKeys(this.modName).get(key), key ));
}
}
}
-31
View File
@@ -1,31 +0,0 @@
package mcp.mobius.waila.gui;
import java.util.HashMap;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
import net.minecraft.client.gui.GuiScreen;
public class GuiModules extends BaseWailaScreen {
private HashMap<String, GuiScreen> screens = new HashMap<String, GuiScreen>();
public GuiModules(GuiScreen _parentGui) {
super(_parentGui);
for (String key : ConfigHandler.instance().getModuleNames())
screens.put(key, new GuiModuleOptions(this, key));
}
@Override
public void initGui()
{
buttonList.add(new ButtonChangeScreen(200, width / 2 - 100, height / 6 + 168, "Back", this.parentGui));
ContainerButtons container = new ContainerButtons(this, 5, 0, width - 10, height);
for (String key : ConfigHandler.instance().getModuleNames())
container.addButton(new ButtonChangeScreen(-1, key, screens.get(key)));
}
}
-29
View File
@@ -1,29 +0,0 @@
package mcp.mobius.waila.gui;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
import mcp.mobius.waila.gui.widget_old.ButtonConfigNEI;
import mcp.mobius.waila.gui.widget_old.ButtonConfigOption;
import mcp.mobius.waila.gui.widget_old.ContainerButtons;
import net.minecraft.client.gui.GuiScreen;
public class GuiWailaConfig extends BaseWailaScreen {
public GuiWailaConfig(GuiScreen _parentGui) {
super(_parentGui);
// TODO Auto-generated constructor stub
}
@Override
public void initGui()
{
buttonList.add(new ButtonChangeScreen(200, width / 2 - 100, height / 6 + 168, "Back", this.parentGui));
ContainerButtons container = new ContainerButtons(this, 5, 0, width - 10, height);
container.addButton(new ButtonConfigNEI(-1, "Hidden", "Shown", "Show/Hide Waila", Constants.CFG_NEI_SHOW ));
container.addButton(new ButtonConfigOption(-1, "Maintained", "Toggled", "Toggle/Maintained", "waila.showmode" ));
container.addButton(new ButtonConfigOption(-1, "Hidden", "Visible", "Show ID:Metadata", "waila.showmetadata", false ));
}
}
+101
View File
@@ -0,0 +1,101 @@
package mcp.mobius.waila.gui.events;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Mouse;
import mcp.mobius.waila.gui.interfaces.IWidget;
public class MouseEvent {
public enum EventType {NONE, MOVE, CLICK, RELEASED, DRAG, WHEEL, ENTER, LEAVE};
public long timestamp;
public Minecraft mc;
public IWidget srcwidget;
public IWidget trgwidget;
public double x,y;
public int z;
public static int buttonCount = Mouse.getButtonCount();
public boolean[] buttonState = new boolean[buttonCount];
public EventType type;
public int button = -1;
public MouseEvent(IWidget widget){
this.srcwidget = widget;
this.timestamp = System.nanoTime();
this.mc = Minecraft.getMinecraft();
this.x = (double)Mouse.getEventX() * (double)this.srcwidget.getSize().getX() / (double)this.mc.displayWidth;
this.y = (double)this.srcwidget.getSize().getY() - (double)Mouse.getEventY() * (double)this.srcwidget.getSize().getY() / (double)this.mc.displayHeight - 1.0;
//this.x = Mouse.getEventX();
//this.y = Mouse.getEventY();
//System.out.printf("%s %s\n", this.x, this.y);
//this.z = Mouse.getEventDWheel();
this.z = Mouse.getDWheel();
for (int i = 0; i < buttonCount; i++)
buttonState[i] = Mouse.isButtonDown(i);
this.trgwidget = this.srcwidget.getWidgetAtCoordinates(this.x, this.y);
}
public String toString(){
String retstring = String.format("MOUSE %s : [%s] [ %.2f %.2f %d ] [", this.type, this.timestamp, this.x, this.y, this.z);
if (this.buttonCount < 5)
for (int i = 0; i < this.buttonCount; i++)
retstring += String.format(" %s ", this.buttonState[i]);
else
for (int i = 0; i < 5; i++)
retstring += String.format(" %s ", this.buttonState[i]);
retstring += "]";
if (this.button != -1)
retstring += String.format(" Button %s", this.button);
return retstring;
}
// Returns the event type based on the previous mouse event.
public EventType getEventType(MouseEvent me){
this.type = EventType.NONE;
if (this.trgwidget != me.trgwidget){
this.type = EventType.ENTER;
return this.type;
}
if (this.z != 0){
this.type = EventType.WHEEL;
return this.type;
}
for (int i = 0; i < this.buttonCount; i++){
if (this.buttonState[i] != me.buttonState[i]){
if (this.buttonState[i] == true)
this.type = EventType.CLICK;
else
this.type = EventType.RELEASED;
this.button = i;
return this.type;
}
}
//MOVE & DRAG EVENTS (we moved the mouse and button 0 was clicked or not)
if ((this.x != me.x) || (this.y != me.y)){
if (this.buttonState[0] == true)
this.type = EventType.DRAG;
else
this.type = EventType.MOVE;
return this.type;
}
return this.type;
}
}
@@ -0,0 +1,37 @@
package mcp.mobius.waila.gui.helpers;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import com.google.common.collect.Lists;
public class ReverseIterator<T> implements Iterable<T> {
private ListIterator<T> listIterator;
public ReverseIterator(Collection<T> wrappedList) {
List list = Lists.newArrayList(wrappedList);
this.listIterator = list.listIterator(wrappedList.size());
}
public Iterator<T> iterator() {
return new Iterator<T>() {
public boolean hasNext() {
return listIterator.hasPrevious();
}
public T next() {
return listIterator.previous();
}
public void remove() {
listIterator.remove();
}
};
}
}
@@ -0,0 +1,7 @@
package mcp.mobius.waila.gui.helpers;
public class UIException extends RuntimeException {
public UIException(String message) {
super(message);
}
}
@@ -0,0 +1,58 @@
package mcp.mobius.waila.gui.helpers;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.renderer.Tessellator;
public class UIHelper {
public static void drawTexture(int posX, int posY, int sizeX, int sizeY)
{
UIHelper.drawTexture(posX, posY, sizeX, sizeY, 0, 0, 256, 256);
}
public static void drawTexture(int posX, int posY, int sizeX, int sizeY, int texU, int texV, int texSizeU, int texSizeV)
{
float zLevel = 0.0F;
float f = 0.00390625F;
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
tess.addVertexWithUV((double)(posX + 0), (double)(posY + sizeY), (double)zLevel, texU*f, (texV + texSizeV)*f);
tess.addVertexWithUV((double)(posX + sizeX), (double)(posY + sizeY), (double)zLevel, (texU + texSizeU)*f, (texV + texSizeV)*f);
tess.addVertexWithUV((double)(posX + sizeX), (double)(posY + 0), (double)zLevel, (texU + texSizeU)*f, texV*f);
tess.addVertexWithUV((double)(posX + 0), (double)(posY + 0), (double)zLevel, texU*f, texV*f);
tess.draw();
}
public static void drawGradientRect(int minx, int miny, int maxx, int maxy, int zlevel, int color1, int color2)
{
float alpha1 = (float)(color1 >> 24 & 255) / 255.0F;
float red1 = (float)(color1 >> 16 & 255) / 255.0F;
float green1 = (float)(color1 >> 8 & 255) / 255.0F;
float blue1 = (float)(color1 & 255) / 255.0F;
float alpha2 = (float)(color2 >> 24 & 255) / 255.0F;
float red2 = (float)(color2 >> 16 & 255) / 255.0F;
float green2 = (float)(color2 >> 8 & 255) / 255.0F;
float blue2 = (float)(color2 & 255) / 255.0F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glShadeModel(GL11.GL_SMOOTH);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(red1, green1, blue1, alpha1);
tessellator.addVertex((double)maxx, (double)miny, (double)zlevel);
tessellator.addVertex((double)minx, (double)miny, (double)zlevel);
tessellator.setColorRGBA_F(red2, green2, blue2, alpha2);
tessellator.addVertex((double)minx, (double)maxy, (double)zlevel);
tessellator.addVertex((double)maxx, (double)maxy, (double)zlevel);
tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
}
@@ -0,0 +1,8 @@
package mcp.mobius.waila.gui.interfaces;
public enum CType {
REL_X,
REL_Y,
RELXY,
ABSXY;
}
@@ -0,0 +1,64 @@
package mcp.mobius.waila.gui.interfaces;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import org.lwjgl.util.Point;
public interface IWidget {
// Should all the coordinates, sizes, etc be % or absolute values ?
// Should we allow 2 methods for an absolute referencing (screen pos) and relative one (parent pos) ?
IWidget getParent();
void setParent(IWidget parent);
IWidget setGeometry(WidgetGeometry geom);
WidgetGeometry getGeometry();
IWidget setPos(double x, double y);
IWidget setPos(double x, double y, boolean fracX, boolean fracY);
IWidget setSize(double sx, double sy);
IWidget setSize(double sx, double sy, boolean fracX, boolean fracY);
IWidget adjustSize();
Point getPos();
Point getSize();
int getRight();
int getLeft();
int getTop();
int getBottom();
void draw();
void draw(Point pos);
void show();
void hide();
void setAlpha(float alpha);
float getAlpha();
boolean shouldRender();
IWidget addWidget(String name, IWidget widget);
IWidget addWidget(String name, IWidget widget, RenderPriority priority);
IWidget getWidget(String name);
IWidget delWidget(String name);
IWidget getWidgetAtCoordinates(double posX, double posY);
boolean isWidgetAtCoordinates(double posx, double posy);
void handleMouseInput();
void onMouseClick(MouseEvent event);
void onMouseDrag(MouseEvent event);
void onMouseMove(MouseEvent event);
void onMouseRelease(MouseEvent event);
void onMouseWheel(MouseEvent event);
void onMouseEnter(MouseEvent event);
void onMouseLeave(MouseEvent event);
void emit(Signal signal, Object... params);
void onWidgetEvent(IWidget srcwidget, Signal signal, Object... params);
//boolean onMouseEnter();
//boolean onMouseMoved();
//boolean onMouseLeave();
}
@@ -0,0 +1,7 @@
package mcp.mobius.waila.gui.interfaces;
public enum RenderPriority {
LOW,
MEDIUM,
HIGH;
}
@@ -0,0 +1,8 @@
package mcp.mobius.waila.gui.interfaces;
public enum Signal {
DRAGGED,
CLICKED,
VALUE_CHANGED,
GEOM_CHANGED;
}
@@ -0,0 +1,5 @@
package mcp.mobius.waila.gui.interfaces;
public enum WAlign {
LEFT,CENTER,RIGHT,TOP,BOTTOM;
}
@@ -0,0 +1,90 @@
package mcp.mobius.waila.gui.screens;
import java.util.HashMap;
import org.lwjgl.input.Mouse;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.widgets.LayoutCanvas;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
public abstract class ScreenBase extends GuiScreen{
protected GuiScreen parent; // Return screen if available.
protected Minecraft mc; // Minecraft instance
protected HashMap<String, IWidget> widgets; // List of widgets on this ui
public ScreenBase(GuiScreen parent) {
this.parent = parent;
this.mc = Minecraft.getMinecraft();
this.widgets = new HashMap<String, IWidget>();
this.addWidget("canvas", new LayoutCanvas());
Mouse.getDWheel(); // We init the DWheel method (getDWheel returns the value since the last call, so we have to call it once on ui creation)
}
/////////////////////
// WIDGET HANDLING //
/////////////////////
public IWidget addWidget(String name, IWidget widget){
this.widgets.put(name, widget);
return this.getWidget(name);
}
public IWidget getWidget(String name){
return this.widgets.get(name);
}
public IWidget delWidget(String name){
IWidget widget = this.getWidget(name);
this.widgets.remove(widget);
return widget;
}
public IWidget getRoot(){
return this.getWidget("canvas");
}
/////////////////////
// DRAWING METHODS //
/////////////////////
@Override
public void drawScreen(int i, int j, float f) {
this.drawDefaultBackground(); //The dark background common to most of the UIs
super.drawScreen(i, j, f);
for (IWidget widget: this.widgets.values())
widget.draw();
}
// Used to easily display a UI without having to mess with mc handle.
public void display(){
this.mc.displayGuiScreen(this);
}
/////////////////////
// INPUT METHODS //
/////////////////////
//Keyboard handling. Basic one is just returning to the previous UI when Esc is pressed
@Override
public void keyTyped(char keyChar, int keyID)
{
if (keyID == 1)
if (this.parent == null){
this.mc.displayGuiScreen((GuiScreen)null);
this.mc.setIngameFocus();
} else
this.mc.displayGuiScreen(this.parent);
}
@Override
public void handleMouseInput()
{
this.getRoot().handleMouseInput();
}
}
@@ -0,0 +1,32 @@
package mcp.mobius.waila.gui.screens.config;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import mcp.mobius.waila.gui.widgets.buttons.ButtonBooleanConfig;
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainer;
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainerLabel;
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
import net.minecraft.client.gui.GuiScreen;
public class ScreenConfig extends ScreenBase {
public ScreenConfig(GuiScreen parent){
super(parent);
this.getRoot().addWidget("ButtonContainer", new ButtonContainer(this.getRoot(), 2, 100, 25.0));
this.getRoot().getWidget("ButtonContainer").setGeometry(new WidgetGeometry(50.0, 50.0, 50.0, 30.0, CType.RELXY, CType.REL_X, WAlign.CENTER, WAlign.CENTER));
ButtonContainer buttonContainer = ((ButtonContainer)this.getRoot().getWidget("ButtonContainer"));
buttonContainer.addButton( new ButtonScreenChange(this.getRoot(), "Waila", new ScreenWailaConfig(this)));
buttonContainer.addButton( new ButtonScreenChange(this.getRoot(), "Modules", new ScreenModuleChoice(this)));
this.getRoot().addWidget("LayoutBack", new LayoutBase(this.getRoot()));
this.getRoot().getWidget("LayoutBack").setGeometry(new WidgetGeometry(0.0, 80.0, 100.0, 20.0, CType.RELXY, CType.RELXY));
this.getRoot().getWidget("LayoutBack").addWidget("ButtonBack", new ButtonScreenChange(this.getRoot().getWidget("LayoutBack"), "Back", this.parent));
this.getRoot().getWidget("LayoutBack").getWidget("ButtonBack").setGeometry(new WidgetGeometry(50.0, 50.0, 100.0, 20.0, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
}
}
@@ -0,0 +1,254 @@
package mcp.mobius.waila.gui.screens.config;
import org.lwjgl.util.Point;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.RenderPriority;
import mcp.mobius.waila.gui.interfaces.Signal;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.LayoutMargin;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import mcp.mobius.waila.gui.widgets.buttons.ButtonLabel;
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
import mcp.mobius.waila.gui.widgets.movable.PictureMovableRC;
import net.minecraft.client.gui.GuiScreen;
public class ScreenHUDConfig extends ScreenBase {
private class EventCanvas extends LayoutBase{
IWidget draggedWidget = null;
float scale;
public EventCanvas(IWidget parent, GuiScreen prevScreen){
super(parent);
this.setGeometry(new WidgetGeometry(0.0,0.0,100.0,100.0,CType.RELXY, CType.RELXY));
/*
IWidget layoutX = this.addWidget("LayoutX", new LayoutBase(this));
layoutX.setGeometry(new WidgetGeometry(40.0,50.0,20,60, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
layoutX.addWidget("ButtonXAdd", new ButtonLabel(null, "+")).setGeometry(new WidgetGeometry(0.0, 0.0,20,20, CType.RELXY, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
layoutX.addWidget("ButtonXSub", new ButtonLabel(null, "-")).setGeometry(new WidgetGeometry(0.0,100.0,20,20, CType.RELXY, CType.ABSXY, WAlign.LEFT, WAlign.BOTTOM));
layoutX.addWidget("ValueDisplayX", new LabelFixedFont(null, "0")).setGeometry(new WidgetGeometry(50.0,50.0,20,20, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
*/
/*
IWidget layoutY = this.addWidget("LayoutY", new LayoutBase(this));
layoutY.setGeometry(new WidgetGeometry(50.0,50.0,20,60,CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
layoutY.addWidget("ButtonYAdd", new ButtonLabel(null, "+")).setGeometry(new WidgetGeometry(0.0, 0.0,20,20, CType.RELXY, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
layoutY.addWidget("ButtonYSub", new ButtonLabel(null, "-")).setGeometry(new WidgetGeometry(0.0,100.0,20,20, CType.RELXY, CType.ABSXY, WAlign.LEFT, WAlign.BOTTOM));
layoutY.addWidget("ValueDisplayY", new LabelFixedFont(null, "0")).setGeometry(new WidgetGeometry(50.0,50.0,20,20, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
*/
double picX = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_POSX) / 100.0;
double picY = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_POSY) / 100.0;
float picAlpha = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_ALPHA) / 100.0f;
scale = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_SCALE) / 100.0f;
int picSX = (int)(180 / this.rez.getScaleFactor() * scale), picSY = (int)(62 / this.rez.getScaleFactor() * scale);
this.addWidget("Layout", new LayoutMargin(null), RenderPriority.HIGH);
((LayoutMargin)this.getWidget("Layout")).setMargins(picSX/2, picSX/2, picSY/2, picSY/2);
this.getWidget("Layout").addWidget("Picture", new PictureMovableRC(null, "waila:textures/config_template.png")).setGeometry(new WidgetGeometry(picX, picY, picSX, picSY,CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
this.addWidget("TextTuto1", new LabelFixedFont(null, "Drag the HUD to setup its position.")).setGeometry(new WidgetGeometry(50.0, 30.0,20,20, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));;
IWidget layoutX = this.addWidget("LayoutX", new LayoutBase(this));
layoutX.setGeometry(new WidgetGeometry(35.0,50.0,20,80,CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
layoutX.addWidget("LabelX", new LabelFixedFont(null, "X")) .setGeometry(new WidgetGeometry(50.0, 0.0,20,20, CType.REL_X, CType.ABSXY, WAlign.CENTER, WAlign.TOP));
layoutX.addWidget("ButtonXAdd", new ButtonLabel(null, "+")) .setGeometry(new WidgetGeometry(0.0, 10.0,20,20, CType.REL_X, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
layoutX.addWidget("ValueDisplayX", new LabelFixedFont(null, "0")) .setGeometry(new WidgetGeometry(50.0, 40.0,20,20, CType.REL_X, CType.ABSXY, WAlign.CENTER, WAlign.TOP));
layoutX.addWidget("ButtonXSub", new ButtonLabel(null, "-")) .setGeometry(new WidgetGeometry(0.0, 60.0,20,20, CType.REL_X, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
IWidget layoutY = this.addWidget("LayoutY", new LayoutBase(this));
layoutY.setGeometry(new WidgetGeometry(45.0,50.0,20,80,CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
layoutY.addWidget("LabelY", new LabelFixedFont(null, "Y")) .setGeometry(new WidgetGeometry(50.0, 0.0,20,20, CType.REL_X, CType.ABSXY, WAlign.CENTER, WAlign.TOP));
layoutY.addWidget("ButtonYAdd", new ButtonLabel(null, "+")) .setGeometry(new WidgetGeometry(0.0, 10.0,20,20, CType.REL_X, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
layoutY.addWidget("ValueDisplayY", new LabelFixedFont(null, "0")) .setGeometry(new WidgetGeometry(50.0, 40.0,20,20, CType.REL_X, CType.ABSXY, WAlign.CENTER, WAlign.TOP));
layoutY.addWidget("ButtonYSub", new ButtonLabel(null, "-")) .setGeometry(new WidgetGeometry(0.0, 60.0,20,20, CType.REL_X, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
IWidget layoutAlpha = this.addWidget("LayoutAlpha", new LayoutBase(this));
layoutAlpha.setGeometry(new WidgetGeometry(55.0,50.0,20,80,CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
layoutAlpha.addWidget("LabelAlpha", new LabelFixedFont(null, "Alpha")).setGeometry(new WidgetGeometry(50.0, 0.0,20,20, CType.REL_X, CType.ABSXY, WAlign.CENTER, WAlign.TOP));
layoutAlpha.addWidget("ButtonAlphaAdd", new ButtonLabel(null, "+")) .setGeometry(new WidgetGeometry(0.0, 10.0,20,20, CType.REL_X, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
layoutAlpha.addWidget("ValueDisplayAlpha", new LabelFixedFont(null, "0")) .setGeometry(new WidgetGeometry(50.0, 40.0,20,20, CType.REL_X, CType.ABSXY, WAlign.CENTER, WAlign.TOP));
layoutAlpha.addWidget("ButtonAlphaSub", new ButtonLabel(null, "-")) .setGeometry(new WidgetGeometry(0.0, 60.0,20,20, CType.REL_X, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
IWidget layoutScale = this.addWidget("LayoutScale", new LayoutBase(this));
layoutScale.setGeometry(new WidgetGeometry(65.0,50.0,20,80,CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
layoutScale.addWidget("LabelScale", new LabelFixedFont(null, "Scale")).setGeometry(new WidgetGeometry(50.0, 0.0,20,20, CType.REL_X, CType.ABSXY, WAlign.CENTER, WAlign.TOP));
layoutScale.addWidget("ButtonScaleAdd", new ButtonLabel(null, "+")) .setGeometry(new WidgetGeometry(0.0, 10.0,20,20, CType.REL_X, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
layoutScale.addWidget("ValueDisplayScale", new LabelFixedFont(null, "0")) .setGeometry(new WidgetGeometry(50.0, 40.0,20,20, CType.REL_X, CType.ABSXY, WAlign.CENTER, WAlign.TOP));
layoutScale.addWidget("ButtonScaleSub", new ButtonLabel(null, "-")) .setGeometry(new WidgetGeometry(0.0, 60.0,20,20, CType.REL_X, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
this.addWidget("ButtonCancel", new ButtonScreenChange(null, "Cancel", prevScreen)).setGeometry(new WidgetGeometry(70.0,97.0,75,20, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.BOTTOM));
this.addWidget("ButtonOk", new ButtonScreenChange(null, "Ok", prevScreen)).setGeometry(new WidgetGeometry(30.0,97.0,75,20, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.BOTTOM));
this.addWidget("ButtonDefault",new ButtonLabel(null, "Default")).setGeometry(new WidgetGeometry(50.0,97.0,75,20, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.BOTTOM));
((LabelFixedFont)this.getWidget("LayoutX").getWidget("ValueDisplayX")).setText(String.format("%.2f", picX));
((LabelFixedFont)this.getWidget("LayoutY").getWidget("ValueDisplayY")).setText(String.format("%.2f", picY));
((LabelFixedFont)this.getWidget("LayoutAlpha").getWidget("ValueDisplayAlpha")).setText(String.format("%.2f", picAlpha));
((LabelFixedFont)this.getWidget("LayoutScale").getWidget("ValueDisplayScale")).setText(String.format("%.2f", scale));
this.getWidget("Layout").getWidget("Picture").setAlpha(picAlpha);
}
@Override
public IWidget getWidgetAtCoordinates(double posX, double posY){
if (this.getWidget("Layout").getWidget("Picture").isWidgetAtCoordinates(posX, posY))
return this.getWidget("Layout").getWidget("Picture");
else
return super.getWidgetAtCoordinates(posX, posY);
}
@Override
public void onMouseClick(MouseEvent event){
//System.out.println(this.getWidgetAtCoordinates(event.x, event.y));
if ((event.button == 0) && (this.getWidget("Layout").getWidget("Picture").isWidgetAtCoordinates(event.x, event.y))){
this.getWidget("Layout").getWidget("Picture").onMouseClick(event);
this.draggedWidget = this.getWidget("Layout").getWidget("Picture");
}
else
super.onMouseClick(event);
}
@Override
public void onMouseDrag(MouseEvent event){
//if ((this.getWidgetAtCoordinates(event.x, event.y) == this) && (this.draggedWidget != null)){
if (this.draggedWidget != null){
this.draggedWidget.onMouseDrag(event);
} else {
super.onMouseDrag(event);
}
}
@Override
public void onMouseRelease(MouseEvent event){
if (event.button == 0)
this.draggedWidget = null;
super.onMouseRelease(event);
}
private void updateData(){
((LabelFixedFont)this.getWidget("LayoutX").getWidget("ValueDisplayX")).setText(String.format("%.2f", this.getWidget("Layout").getWidget("Picture").getGeometry().getRawPos().getX()));
((LabelFixedFont)this.getWidget("LayoutY").getWidget("ValueDisplayY")).setText(String.format("%.2f", this.getWidget("Layout").getWidget("Picture").getGeometry().getRawPos().getY()));
((LabelFixedFont)this.getWidget("LayoutAlpha").getWidget("ValueDisplayAlpha")).setText(String.format("%.2f", this.getWidget("Layout").getWidget("Picture").getAlpha()));
((LabelFixedFont)this.getWidget("LayoutScale").getWidget("ValueDisplayScale")).setText(String.format("%.2f", scale));
}
@Override
public void onWidgetEvent(IWidget srcwidget, Signal signal, Object... params){
if (this.getWidget("Layout") == null) return;
if (srcwidget.equals(this.getWidget("Layout").getWidget("Picture")) && signal == Signal.DRAGGED){
this.draggedWidget = this.getWidget("Layout").getWidget("Picture");
this.updateData();
}
if (signal == Signal.CLICKED){
IWidget picture = this.getWidget("Layout").getWidget("Picture");
double pictureX = picture.getGeometry().getRawPos().getX();
double pictureY = picture.getGeometry().getRawPos().getY();
double pixelToPercentX = 100.0D / picture.getParent().getSize().getX();
double pixelToPercentY = 100.0D / picture.getParent().getSize().getY();
if (srcwidget.equals(this.getWidget("LayoutX").getWidget("ButtonXAdd"))){
double newPos = Math.min(pictureX + pixelToPercentX, 100.0);
picture.setPos(newPos, pictureY);
}
if (srcwidget.equals(this.getWidget("LayoutX").getWidget("ButtonXSub"))){
double newPos = Math.max(pictureX - pixelToPercentX, 0.0);
picture.setPos(newPos, pictureY);
}
if (srcwidget.equals(this.getWidget("LayoutY").getWidget("ButtonYAdd"))){
double newPos = Math.min(pictureY + pixelToPercentY, 100.0);
picture.setPos(pictureX, newPos);
}
if (srcwidget.equals(this.getWidget("LayoutY").getWidget("ButtonYSub"))){
double newPos = Math.max(pictureY - pixelToPercentY, 0.0);
picture.setPos(pictureX, newPos);
}
if (srcwidget.equals(this.getWidget("LayoutAlpha").getWidget("ButtonAlphaAdd")))
picture.setAlpha(Math.min(picture.getAlpha() + 0.05f, 1.0f));
if (srcwidget.equals(this.getWidget("LayoutAlpha").getWidget("ButtonAlphaSub")))
picture.setAlpha(Math.max(picture.getAlpha() - 0.05f, 0.0f));
if (srcwidget.equals(this.getWidget("LayoutScale").getWidget("ButtonScaleAdd"))){
scale += 0.05f;
scale = Math.max(0.10f, scale);
scale = Math.min(2.00f, scale);
int picSX = (int)(180 / this.rez.getScaleFactor() * scale), picSY = (int)(62 / this.rez.getScaleFactor() * scale);
picture.setSize(picSX, picSY);
((LayoutMargin)this.getWidget("Layout")).setMargins(picSX/2, picSX/2, picSY/2, picSY/2);
}
if (srcwidget.equals(this.getWidget("LayoutScale").getWidget("ButtonScaleSub"))){
scale -= 0.05f;
scale = Math.max(0.10f, scale);
scale = Math.min(2.00f, scale);
int picSX = (int)(180 / this.rez.getScaleFactor() * scale), picSY = (int)(62 / this.rez.getScaleFactor() * scale);
picture.setSize(picSX, picSY);
((LayoutMargin)this.getWidget("Layout")).setMargins(picSX/2, picSX/2, picSY/2, picSY/2);
}
//picture.emit(Signal.DRAGGED, picture.getPos());
this.updateData();
}
if (srcwidget.equals(this.getWidget("ButtonOk")) && signal == Signal.CLICKED){
ConfigHandler.instance().setConfigInt(Constants.CFG_WAILA_POSX, (int)(this.getWidget("Layout").getWidget("Picture").getGeometry().getRawPos().getX() * 100.0));
ConfigHandler.instance().setConfigInt(Constants.CFG_WAILA_POSY, (int)(this.getWidget("Layout").getWidget("Picture").getGeometry().getRawPos().getY() * 100.0));
ConfigHandler.instance().setConfigInt(Constants.CFG_WAILA_ALPHA, (int)(this.getWidget("Layout").getWidget("Picture").getAlpha() * 100.0));
ConfigHandler.instance().setConfigInt(Constants.CFG_WAILA_SCALE, (int)(scale * 100.0));
mod_Waila.alpha = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_ALPHA);
mod_Waila.posX = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_POSX);
mod_Waila.posY = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_POSY);
mod_Waila.scale = ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_SCALE) / 100.0f;
mod_Waila.updateColors();
}
if (srcwidget.equals(this.getWidget("ButtonDefault")) && signal == Signal.CLICKED){
this.getWidget("Layout").getWidget("Picture").setPos(50.0, 1.0);
this.getWidget("Layout").getWidget("Picture").setAlpha(0.8f);
this.scale = 1.0f;
int picSX = (int)(180 / this.rez.getScaleFactor() * scale), picSY = (int)(62 / this.rez.getScaleFactor() * scale);
this.getWidget("Layout").getWidget("Picture").setSize(picSX, picSY);
((LayoutMargin)this.getWidget("Layout")).setMargins(picSX/2, picSX/2, picSY/2, picSY/2);
this.updateData();
}
}
}
public ScreenHUDConfig(GuiScreen parent){
super(parent);
this.getRoot().addWidget("EventCanvas", new EventCanvas(this.getRoot(), parent));
}
}
@@ -0,0 +1,32 @@
package mcp.mobius.waila.gui.screens.config;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainer;
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
import mcp.mobius.waila.gui_old.widget_old.ButtonChangeScreen;
import net.minecraft.client.gui.GuiScreen;
public class ScreenModuleChoice extends ScreenBase {
public ScreenModuleChoice(GuiScreen parent){
super(parent);
this.getRoot().addWidget("ButtonContainer", new ButtonContainer(this.getRoot(), 3, 100, 25.0));
this.getRoot().getWidget("ButtonContainer").setGeometry(new WidgetGeometry(50.0, 20.0, 400.0, 60.0, CType.RELXY, CType.REL_Y, WAlign.CENTER, WAlign.TOP));
ButtonContainer buttonContainer = ((ButtonContainer)this.getRoot().getWidget("ButtonContainer"));
for (String key : ConfigHandler.instance().getModuleNames())
buttonContainer.addButton( new ButtonScreenChange(this.getRoot(), key, new ScreenModuleConfig(this, key)));
this.getRoot().addWidget("LayoutBack", new LayoutBase(this.getRoot()));
this.getRoot().getWidget("LayoutBack").setGeometry(new WidgetGeometry(0.0, 80.0, 100.0, 20.0, CType.RELXY, CType.RELXY));
this.getRoot().getWidget("LayoutBack").addWidget("ButtonBack", new ButtonScreenChange(this.getRoot().getWidget("LayoutBack"), "Back", this.parent));
this.getRoot().getWidget("LayoutBack").getWidget("ButtonBack").setGeometry(new WidgetGeometry(50.0, 50.0, 100.0, 20.0, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
}
}
@@ -0,0 +1,49 @@
package mcp.mobius.waila.gui.screens.config;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import mcp.mobius.waila.gui.widgets.buttons.ButtonBooleanConfig;
import mcp.mobius.waila.gui.widgets.buttons.ButtonBooleanConfigRemote;
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainer;
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainerLabel;
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
import mcp.mobius.waila.gui_old.widget_old.ButtonConfigOption;
import mcp.mobius.waila.gui_old.widget_old.ButtonConfigRemote;
import net.minecraft.client.gui.GuiScreen;
public class ScreenModuleConfig extends ScreenBase {
private String modName;
public ScreenModuleConfig(GuiScreen parent, String modname){
super(parent);
this.modName = modname;
this.getRoot().addWidget("ButtonContainer", new ButtonContainerLabel(this.getRoot(), 2, 100, 25.0));
this.getRoot().getWidget("ButtonContainer").setGeometry(new WidgetGeometry(0.0, 20.0, 100.0, 60.0, CType.RELXY, CType.RELXY, WAlign.LEFT, WAlign.TOP));
ButtonContainerLabel buttonContainer = ((ButtonContainerLabel)this.getRoot().getWidget("ButtonContainer"));
for (String key:ConfigHandler.instance().getConfigKeys(this.modName).keySet()){
if (ConfigHandler.instance().isServerRequired(key))
buttonContainer.addButton(new ButtonBooleanConfigRemote(this.getRoot(), key, "No", "Yes"), ConfigHandler.instance().getConfigKeys(this.modName).get(key));
else
buttonContainer.addButton(new ButtonBooleanConfig(this.getRoot(), key, "No", "Yes"), ConfigHandler.instance().getConfigKeys(this.modName).get(key));
//buttonContainer.addButton(new ButtonConfigRemote(-1, "No", "Yes", ConfigHandler.instance().getConfigKeys(this.modName).get(key), key ));
//else
//buttonContainer.addButton(new ButtonConfigOption(-1, "No", "Yes", ConfigHandler.instance().getConfigKeys(this.modName).get(key), key ));
}
this.getRoot().addWidget("LayoutBack", new LayoutBase(this.getRoot()));
this.getRoot().getWidget("LayoutBack").setGeometry(new WidgetGeometry(0.0, 80.0, 100.0, 20.0, CType.RELXY, CType.RELXY));
this.getRoot().getWidget("LayoutBack").addWidget("ButtonBack", new ButtonScreenChange(this.getRoot().getWidget("LayoutBack"), "Back", this.parent));
this.getRoot().getWidget("LayoutBack").getWidget("ButtonBack").setGeometry(new WidgetGeometry(50.0, 50.0, 100.0, 20.0, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
}
}
@@ -0,0 +1,40 @@
package mcp.mobius.waila.gui.screens.config;
import net.minecraft.client.gui.GuiScreen;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import mcp.mobius.waila.gui.widgets.buttons.ButtonBooleanConfig;
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainerLabel;
import mcp.mobius.waila.gui.widgets.buttons.ButtonIntegerConfig;
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
public class ScreenWailaConfig extends ScreenBase {
public ScreenWailaConfig(GuiScreen parent){
super(parent);
this.getRoot().addWidget("ButtonContainer", new ButtonContainerLabel(this.getRoot(), 2, 100, 25.0));
this.getRoot().getWidget("ButtonContainer").setGeometry(new WidgetGeometry(0.0, 10.0, 100.0, 50.0, CType.RELXY, CType.RELXY));
ButtonContainerLabel buttonContainer = ((ButtonContainerLabel)this.getRoot().getWidget("ButtonContainer"));
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Constants.CFG_WAILA_SHOW, true, true, "Hidden", "Visible"), "Show/Hide Waila");
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Constants.CFG_WAILA_MODE, true, true, "Maintained", "Toggled"), "Toggled/Maintained");
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Constants.CFG_WAILA_METADATA, true, false,"Hidden", "Visible"), "Show ID:Metadata");
buttonContainer.addButton( new ButtonBooleanConfig(this.getRoot(), Constants.CFG_WAILA_LIQUID, true, false,"Hidden", "Visible"), "Liquids");
this.getRoot().addWidget("LayoutConfigPos", new LayoutBase(this.getRoot()));
this.getRoot().getWidget("LayoutConfigPos").setGeometry(new WidgetGeometry(0.0, 50.0, 100.0, 20.0, CType.RELXY, CType.RELXY));
this.getRoot().getWidget("LayoutConfigPos").addWidget("ButtonConfigPos", new ButtonScreenChange(null, "Configure aspect ...", new ScreenHUDConfig(this)));
this.getRoot().getWidget("LayoutConfigPos").getWidget("ButtonConfigPos").setGeometry(new WidgetGeometry(50.0, 50.0, 150.0, 20.0, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
this.getRoot().addWidget("LayoutBack", new LayoutBase(this.getRoot()));
this.getRoot().getWidget("LayoutBack").setGeometry(new WidgetGeometry(0.0, 80.0, 100.0, 20.0, CType.RELXY, CType.RELXY));
this.getRoot().getWidget("LayoutBack").addWidget("ButtonBack", new ButtonScreenChange(null, "Back", this.parent));
this.getRoot().getWidget("LayoutBack").getWidget("ButtonBack").setGeometry(new WidgetGeometry(50.0, 50.0, 100.0, 20.0, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
}
}
@@ -0,0 +1,73 @@
package mcp.mobius.waila.gui.screens.info;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.ItemStackDisplay;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.ViewTable;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
public class ScreenEnchants extends ScreenBase {
public ScreenEnchants(GuiScreen parent) {
super(parent);
this.getRoot().addWidget("Layout_Title", new LayoutBase(null))
.setGeometry(new WidgetGeometry(50.0, 10.0, 50.0, 32.0, CType.REL_X, CType.REL_X, WAlign.CENTER, WAlign.TOP));
this.getRoot().getWidget("Layout_Title").addWidget("ItemStack", new ItemStackDisplay(null))
.setGeometry(new WidgetGeometry(0.0, 0.0, 32.0, 32.0, CType.ABSXY, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
this.getRoot().getWidget("Layout_Title").addWidget("LabelName", new LabelFixedFont(null, "None"))
.setGeometry(new WidgetGeometry(40.0, 4.0, 16.0, 16.0, CType.ABSXY, CType.ABSXY, WAlign.LEFT, WAlign.TOP));
this.getRoot().getWidget("Layout_Title").addWidget("LabelEnchantability", new LabelFixedFont(null, "None"))
.setGeometry(new WidgetGeometry(40.0, 22.0, 16.0, 16.0, CType.ABSXY, CType.REL_X, WAlign.LEFT, WAlign.BOTTOM));
this.getRoot().addWidget("Table", new ViewTable(null))
.setGeometry(new WidgetGeometry(50.0, 50.0, 90.0, 90.0, CType.REL_X, CType.RELXY, WAlign.CENTER, WAlign.TOP));
((ViewTable)this.getRoot().getWidget("Table"))
.setColumnsTitle("\u00a7a\u00a7oName","\u00a7a\u00a7oMin lvl","\u00a7a\u00a7oMax lvl","\u00a7a\u00a7oWeight", "\u00a7a\u00a7oMod")
.setColumnsWidth(35.0, 10.0, 10.0, 10.0, 35.0)
.setColumnsAlign(WAlign.LEFT, WAlign.CENTER, WAlign.CENTER, WAlign.CENTER, WAlign.LEFT);
}
public ViewTable getTable(){
return (ViewTable)this.getRoot().getWidget("Table");
}
public ScreenEnchants addRow(String...strings ){
this.getTable().addRow(strings);
return this;
}
public ScreenEnchants setStack(ItemStack stack){
((ItemStackDisplay)this.getRoot().getWidget("Layout_Title").getWidget("ItemStack")).setStack(stack);
this.getRoot().getWidget("Layout_Title").adjustSize();
return this;
}
public ScreenEnchants setName(String name){
((LabelFixedFont)this.getRoot().getWidget("Layout_Title").getWidget("LabelName")).setText(name);
this.getRoot().getWidget("Layout_Title").adjustSize();
return this;
}
public ScreenEnchants setEnchantability(String value){
((LabelFixedFont)this.getRoot().getWidget("Layout_Title").getWidget("LabelEnchantability")).setText(String.format("Enchantability : %s", value));
this.getRoot().getWidget("Layout_Title").adjustSize();
return this;
}
/*
public ScreenEnchants setStack(ItemStack stack){
((ItemStackDisplay)this.getRoot().getWidget("ItemStack")).setStack(stack);
return this;
}
*/
}
@@ -0,0 +1,70 @@
package mcp.mobius.waila.gui.testing;
import org.lwjgl.util.Point;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.helpers.UIException;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.ItemStackDisplay;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.LayoutCropping;
import mcp.mobius.waila.gui.widgets.PictureDisplay;
import mcp.mobius.waila.gui.widgets.PictureSwitch;
import mcp.mobius.waila.gui.widgets.ViewTable;
import mcp.mobius.waila.gui.widgets.ViewportScrollable;
import mcp.mobius.waila.gui.widgets.WidgetBase;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import mcp.mobius.waila.gui.widgets.buttons.ButtonBoolean;
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainerLabel;
import mcp.mobius.waila.gui.widgets.buttons.ButtonInteger;
import mcp.mobius.waila.gui.widgets.buttons.ButtonIntegerConfig;
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
import mcp.mobius.waila.gui.widgets.movable.PictureMovableRC;
import net.minecraft.block.Block;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
public class ScreenTest extends ScreenBase {
public ScreenTest(GuiScreen parent) {
super(parent);
this.getRoot().addWidget("Test", new ViewTable(null))
.setGeometry(new WidgetGeometry(50.0, 50.0, 90.0, 90.0, CType.RELXY, CType.RELXY, WAlign.CENTER, WAlign.CENTER));
((ViewTable)this.getRoot().getWidget("Test"))
.setColumnsTitle("Column1","Column2","Column3")
.setColumnsWidth(30.0,30.0,30.0)
.setColumnsAlign(WAlign.CENTER, WAlign.CENTER, WAlign.CENTER)
.addRow("test1", "test2", "test3")
.addRow("test1", "test2", "test3")
.addRow("test1", "test2", "test3")
.addRow("test1", "test2", "test3")
.addRow("test1", "test2", "test3")
.addRow("test1", "test2", "test3")
.addRow("test1", "test2", "test3")
.addRow("test1", "test2", "test3")
.addRow("test1", "test2", "test3")
.addRow("test1", "test2", "test3");
/*
this.getRoot().addWidget("Test", new Row(null)).setGeometry(new WidgetGeometry(50.0, 50.0, 90.0, 20.0, CType.RELXY, CType.REL_X, WAlign.CENTER, WAlign.CENTER));
((Row)this.getRoot().getWidget("Test")).setColumnsText("aabbbbbbbbbbbbbbbbbbbbbbbbb","bb","cc");
((Row)this.getRoot().getWidget("Test")).setColumnsWidth(30.0,30.0,30.0);
((Row)this.getRoot().getWidget("Test")).setColumnsAlign(WAlign.LEFT, WAlign.CENTER, WAlign.CENTER);
*/
//this.getRoot().addWidget("TestLayout", new LayoutBase(null)).setGeometry(new WidgetGeometry(50.0, 50.0, 90.0, 90.0, CType.RELXY, CType.RELXY, WAlign.CENTER, WAlign.CENTER));
//((LayoutBase)this.getRoot().getWidget("TestLayout")).setBackgroundColors(0xff505050, 0xff505050);
//this.getRoot().addWidget("Layout", new ViewportScrollable(null)).setGeometry(new WidgetGeometry(50.0,50.0,75.0,75.0,CType.RELXY, CType.RELXY, WAlign.CENTER, WAlign.CENTER));
//((ViewportScrollable)this.getRoot().getWidget("Layout")).attachWidget(new PictureSwitch(this.getRoot(), "waila:textures/test.png", "waila:textures/test_solar.png")).setSize(900, 900);
}
}
@@ -0,0 +1,29 @@
package mcp.mobius.waila.gui.testing;
import net.minecraft.client.gui.GuiScreen;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import mcp.mobius.waila.gui.widgets.buttons.ButtonContainerLabel;
import mcp.mobius.waila.gui.widgets.buttons.ButtonIntegerConfig;
public class ScreenTest2 extends ScreenBase {
public ScreenTest2(GuiScreen parent) {
super(parent);
//this.getRoot().addWidget("Picture", new PictureSwitch(this.getRoot(), "waila:textures/test.png", "waila:textures/test_solar.png"));
//this.getRoot().addWidget("Button", new ButtonInteger(this.getRoot(), "Val0", "Val1", "Val2"));
//this.getRoot().getWidget("Button").setGeometry(new WidgetGeometry(50.0D, 50.0D, 100.0D, 20.0D, true, false, WidgetAlign.CENTER, WidgetAlign.CENTER));
this.getRoot().addWidget("Buttons", new ButtonContainerLabel(this.getRoot(), 2, 100, 30.0));
this.getRoot().getWidget("Buttons").setGeometry(new WidgetGeometry(0.0, 0.0, 100.0, 50.0, CType.RELXY, CType.RELXY));
//((ButtonContainer)this.getRoot().getWidget("Buttons")).addButton(new ButtonIntegerConfig(this.getRoot(), "testconfig", true, 0, "Val0", "Val1", "Val2"));
this.getRoot().addWidget("Text", new LabelFixedFont(this.getRoot(), "waila:textures/test.png"));
this.getRoot().getWidget("Text").setGeometry(new WidgetGeometry(50.0D, 10.0D, 50.0D, 50.0D, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.TOP));
}
}
@@ -0,0 +1,49 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.gui.interfaces.IWidget;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.Point;
import codechicken.nei.forge.GuiContainerManager;
public class ItemStackDisplay extends WidgetBase {
ItemStack stack = null;
public ItemStackDisplay(IWidget parent){
this(parent, null);
}
public ItemStackDisplay(IWidget parent, ItemStack stack){
super(parent);
this.stack = stack;
this.setSize(16, 16);
}
public void setStack(ItemStack stack){
this.stack = stack;
}
public ItemStack getStack(){
return this.stack;
}
@Override
public void draw(Point pos) {
if (this.stack == null) return;
float scaleX = this.getSize().getX()/16.0f;
float scaleY = this.getSize().getY()/16.0f;
GL11.glPushMatrix();
GL11.glScalef(scaleX, scaleY, 1.0f);
RenderHelper.enableGUIStandardItemLighting();
GuiContainerManager.drawItem((int)(pos.getX()/scaleX), (int)(pos.getY()/scaleX), this.stack);
GL11.glPopMatrix();
}
}
@@ -0,0 +1,57 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.Signal;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.util.Point;
public class LabelFixedFont extends WidgetBase {
protected String text = "";
protected int color;
public LabelFixedFont(IWidget parent, String text){
super(parent);
this.setText(text);
this.color = 0xFFFFFF;
}
public LabelFixedFont(IWidget parent, String text, int color){
super(parent);
this.setText(text);
this.color = color;
}
@Override
public IWidget setGeometry(WidgetGeometry geom){
this.geom = geom;
this.updateGeometry();
return this;
}
public void setText(String text){
this.text = text;
this.updateGeometry();
}
public void setColor(int color){
this.color = color;
}
private void updateGeometry(){
if (this.geom == null)
this.geom = new WidgetGeometry(0,0,50,50, CType.ABSXY, CType.ABSXY);
this.geom = new WidgetGeometry(this.geom.x, this.geom.y, this.mc.fontRenderer.getStringWidth(this.text), 8, this.geom.posType, CType.ABSXY, this.geom.alignX, this.geom.alignY);
}
@Override
public void draw(Point pos) {
this.saveGLState();
this.mc.fontRenderer.drawString(this.text, pos.getX(), pos.getY(), this.color);
this.loadGLState();
}
}
@@ -0,0 +1,47 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.gui.interfaces.IWidget;
import org.lwjgl.util.Point;
public class LayoutBase extends WidgetBase {
protected int bgcolor1 = 0x00000000;
protected int bgcolor2 = 0x00000000;
protected boolean renderBG;
public LayoutBase(IWidget parent){
super(parent);
}
@Override
public void draw(Point pos) {
if (this.renderBG)
UIHelper.drawGradientRect(this.getLeft(), this.getTop(), this.getRight(), this.getBottom(), 0, this.bgcolor1, this.bgcolor2);
}
public void setBackgroundColors(int bg1, int bg2){
this.bgcolor1 = bg1;
this.bgcolor2 = bg2;
this.renderBG = true;
}
/*
@Override
public void onMouseEnter(MouseEvent event) {
IWidget widget = this.getWidgetAtCoordinates(event.x, event.y);
if (widget != null && widget != this)
widget.onMouseEnter(event);
}
@Override
public void onMouseLeave(MouseEvent event) {
IWidget widget = this.getWidgetAtCoordinates(event.x, event.y);
if (widget != null && widget != this)
widget.onMouseLeave(event);
}
*/
}
@@ -0,0 +1,122 @@
package mcp.mobius.waila.gui.widgets;
import net.minecraft.client.gui.ScaledResolution;
import org.lwjgl.input.Mouse;
import org.lwjgl.util.Point;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.events.MouseEvent.EventType;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.Signal;
public class LayoutCanvas extends LayoutBase{
private MouseEvent lastMouseEvent;
private IWidget draggedWidget = null;
public LayoutCanvas(){
super(null);
this.setGeometry(0, 0, this.rez.getScaledWidth(), this.rez.getScaledHeight(), CType.ABSXY, CType.ABSXY);
Mouse.getDWheel(); // This is to "calibrate" the DWheel
this.lastMouseEvent = new MouseEvent(this);
}
@Override
public void draw(){
this.rez = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
this.setGeometry(0, 0, this.rez.getScaledWidth(), this.rez.getScaledHeight(), CType.ABSXY, CType.ABSXY);
/*
this.draw(this.getPos());
for (IWidget widget: this.widgets.values())
if (widget.shouldRender())
widget.draw();
*/
super.draw();
this.handleMouseInput();
}
@Override
public void draw(Point pos) { super.draw(pos); }
@Override
public void handleMouseInput(){
// Here we are going to generate the require mouse events we will pass down to all the other widgets
// This is more or less where the magic happens. If you want mouse support for a widget, it should be
// attached to a canvas like this one, or any inheriting one.
MouseEvent event = new MouseEvent(this);
EventType type = event.getEventType(this.lastMouseEvent);
IWidget targetWidget = this.getWidgetAtCoordinates(event.x, event.y);
switch (type){
case CLICK:
if (targetWidget != null)
targetWidget.onMouseClick(event);
//this.onMouseClick(event);
break;
case DRAG:
if (targetWidget != null)
targetWidget.onMouseDrag(event);
//this.onMouseDrag(event);
break;
case MOVE:
if (targetWidget != null)
targetWidget.onMouseMove(event);
//this.onMouseMove(event);
break;
case RELEASED:
if (targetWidget != null)
targetWidget.onMouseRelease(event);
//this.onMouseRelease(event);
break;
case WHEEL:
if (targetWidget != null)
targetWidget.onMouseWheel(event);
//this.onMouseWheel(event);
break;
case ENTER:
if (event.trgwidget != null)
event.trgwidget.onMouseEnter(event);
if (this.lastMouseEvent.trgwidget != null){
event.type = EventType.LEAVE;
this.lastMouseEvent.trgwidget.onMouseLeave(event);
}
break;
case NONE:
break;
default:
break;
}
this.lastMouseEvent = event;
}
@Override
public void onWidgetEvent(IWidget srcwidget, Signal signal, Object... params){
if (signal == Signal.DRAGGED)
this.draggedWidget = srcwidget;
else
super.onWidgetEvent(srcwidget, signal, params);
}
@Override
public void onMouseRelease(MouseEvent event){
if(event.button == 0)
this.draggedWidget = null;
super.onMouseRelease(event);
}
@Override
public void onMouseDrag(MouseEvent event){
if (this.draggedWidget != null)
this.draggedWidget.onMouseDrag(event);
else
super.onMouseDrag(event);
}
}
@@ -0,0 +1,68 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.gui.interfaces.IWidget;
import net.minecraft.client.gui.ScaledResolution;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.Point;
public class LayoutCropping extends LayoutBase {
int xOffset = 0;
int yOffset = 0;
public LayoutCropping(IWidget parent){
super(parent);
}
public void setOffsets(int xoffset, int yoffset){
this.xOffset = xoffset;
this.yOffset = yoffset;
}
@Override
public void draw(){
this.rez = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
this.saveGLState();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1.0f, 1.0f, 1.0f, this.alpha);
this.draw(this.getPos());
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor(this.getPos().getX()*this.rez.getScaleFactor(), (this.rez.getScaledHeight() - (this.getPos().getY() + this.getSize().getY())) * this.rez.getScaleFactor(), this.getSize().getX()*this.rez.getScaleFactor(), this.getSize().getY()*this.rez.getScaleFactor());
//GL11.glScissor(this.getPos().getX()*this.rez.getScaleFactor(), this.getPos().getY()*this.rez.getScaleFactor(), this.getSize().getX()*this.rez.getScaleFactor(), this.getSize().getY()*this.rez.getScaleFactor());
GL11.glTranslatef(xOffset, yOffset, 0.0f);
/*
for (IWidget widget: this.widgets.values())
if (widget.shouldRender())
widget.draw();
*/
for (IWidget widget: this.renderQueue_LOW.values())
if (widget.shouldRender())
widget.draw();
for (IWidget widget: this.renderQueue_MEDIUM.values())
if (widget.shouldRender())
widget.draw();
for (IWidget widget: this.renderQueue_HIGH.values())
if (widget.shouldRender())
widget.draw();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
this.loadGLState();
}
@Override
public void draw(Point pos) { super.draw(pos); }
}
@@ -0,0 +1,43 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.WAlign;
import org.lwjgl.util.Point;
public class LayoutMargin extends LayoutBase {
int left = 0;
int right = 0;
int top = 0;
int bottom = 0;
public LayoutMargin(IWidget parent){
super (parent);
this.setGeometry(new WidgetGeometry(0,0,0,0,CType.ABSXY,CType.ABSXY,WAlign.CENTER,WAlign.CENTER));
}
public void setMargins(int left, int right, int top, int bottom){
this.left = left;
this.right = right;
this.top = top;
this.bottom = bottom;
}
@Override
public Point getSize(){
Point parentSize = this.parent.getSize();
return new Point(parentSize.getX() - left - right, parentSize.getY() - top - bottom);
}
@Override
public Point getPos(){
Point parentPos = this.parent.getPos();
return new Point(parentPos.getX() + left, parentPos.getY() + top);
}
@Override
public void draw(Point pos) { super.draw(pos); }
}
@@ -0,0 +1,31 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.gui.interfaces.IWidget;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.Point;
public class PictureDisplay extends WidgetBase {
protected ResourceLocation texture;
public PictureDisplay(IWidget parent, String uri){
super(parent);
this.texture = new ResourceLocation(uri);
}
@Override
public void draw(Point pos) {
this.saveGLState();
GL11.glPushMatrix();
this.texManager.func_110577_a(texture);
UIHelper.drawTexture(pos.getX(), pos.getY(), this.getSize().getX(), this.getSize().getY());
GL11.glPopMatrix();
this.loadGLState();
}
}
@@ -0,0 +1,49 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.gui.interfaces.IWidget;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.Point;
public class PictureSwitch extends WidgetBase {
private ResourceLocation texture1;
private ResourceLocation texture2;
private boolean mouseOver = false;
public PictureSwitch(IWidget parent, String uri1, String uri2){
super(parent);
this.texture1 = new ResourceLocation(uri1);
this.texture2 = new ResourceLocation(uri2);
}
@Override
public void draw(Point pos) {
this.saveGLState();
ResourceLocation texture = mouseOver ? this.texture2 : this.texture1;
GL11.glPushMatrix();
this.texManager.func_110577_a(texture);
UIHelper.drawTexture(pos.getX(), pos.getY(), this.getSize().getX(), this.getSize().getY());
GL11.glPopMatrix();
this.loadGLState();
}
@Override
public void onMouseEnter(MouseEvent event){
//System.out.printf("%s %s\n", this, event);
mouseOver = true;
}
@Override
public void onMouseLeave(MouseEvent event){
//System.out.printf("%s %s\n", this, event);
mouseOver = false;
}
}
+201
View File
@@ -0,0 +1,201 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.gui.helpers.UIException;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.WAlign;
import org.lwjgl.util.Point;
public class ViewTable extends WidgetBase{
public class Cell extends WidgetBase{
public Cell(IWidget parent, String text, WAlign align){
super(parent);
//this.addWidget("Crop", new LayoutCropping(null)).setGeometry(new WidgetGeometry(50.0, 50.0, 90.0, 100.0, CType.RELXY, CType.RELXY, WAlign.CENTER, WAlign.CENTER));
switch(align){
case CENTER:
//this.getWidget("Crop").addWidget("Text", new LabelFixedFont(null, text))
this.addWidget("Text", new LabelFixedFont(null, text))
.setGeometry(new WidgetGeometry(50.0, 50.0, 100.0, 100.0, CType.RELXY, CType.RELXY, WAlign.CENTER, WAlign.CENTER));
break;
case LEFT:
//this.getWidget("Crop").addWidget("Text", new LabelFixedFont(null, text))
this.addWidget("Text", new LabelFixedFont(null, text))
.setGeometry(new WidgetGeometry(5.0, 50.0, 95.0, 100.0, CType.RELXY, CType.RELXY, WAlign.LEFT, WAlign.CENTER));
break;
case RIGHT:
//this.getWidget("Crop").addWidget("Text", new LabelFixedFont(null, text))
this.addWidget("Text", new LabelFixedFont(null, text))
.setGeometry(new WidgetGeometry(5.0, 50.0, 95.0, 100.0, CType.RELXY, CType.RELXY, WAlign.RIGHT, WAlign.CENTER));
break;
default:
throw new UIException(String.format("Unexpected align value : %s", align));
}
}
@Override
public void draw(Point pos){}
}
public class Row extends WidgetBase{
int ncolumns = -1;
double[] widths;
String[] texts;
WAlign[] aligns;
boolean init = false;
int bgcolor1 = 0x50505050;
int bgcolor2 = 0x50505050;
public Row(IWidget parent){
super(parent);
this.addWidget("Background", new LayoutBase(null)).setGeometry(new WidgetGeometry(50.0, 50.0, 100.0, 100.0, CType.RELXY, CType.RELXY, WAlign.CENTER, WAlign.CENTER));
((LayoutBase)this.getWidget("Background")).setBackgroundColors(this.bgcolor1, this.bgcolor2);
}
public Row setColumnsWidth(double... widths){
if (this.ncolumns == -1)
this.ncolumns = widths.length;
else if(this.ncolumns != widths.length){
throw new UIException(String.format("Number of columns mismatch. Expecting %d, got %d", this.ncolumns, widths.length));
}
this.widths = widths;
return this;
}
public Row setColumnsText(String...strings ){
if (this.ncolumns == -1)
this.ncolumns = strings.length;
else if(this.ncolumns != strings.length){
throw new UIException(String.format("Number of columns mismatch. Expecting %d, got %d", this.ncolumns, strings.length));
}
this.texts = strings;
return this;
}
public Row setColumnsAlign(WAlign... aligns ){
if (this.ncolumns == -1)
this.ncolumns = aligns.length;
else if(this.ncolumns != aligns.length){
throw new UIException(String.format("Number of columns mismatch. Expecting %d, got %d", this.ncolumns, aligns.length));
}
this.aligns = aligns;
return this;
}
public Row setColors(int bg1, int bg2){
this.bgcolor1 = bg1;
this.bgcolor2 = bg2;
((LayoutBase)this.getWidget("Background")).setBackgroundColors(this.bgcolor1, this.bgcolor2);
return this;
}
@Override
public void draw(){
if (!init)
{
double currentOffset = 0.0;
for (int i = 0; i < this.ncolumns; i++){
if (!this.widgets.containsKey(String.format("Cell_%02d", i))){
Cell cell = (Cell)(this.addWidget(String.format("Cell_%02d", i), new Cell(null, this.texts[i], this.aligns[i])));
cell.setGeometry(new WidgetGeometry(currentOffset, 50.0, this.widths[i], 100.0, CType.RELXY, CType.RELXY, WAlign.LEFT, WAlign.CENTER));
currentOffset += this.widths[i];
}
}
init = true;
}
super.draw();
}
@Override
public void draw(Point pos){}
}
int ncolumns = -1;
int nrows = 0;
double[] widths;
String[] texts;
WAlign[] aligns;
boolean init = false;
public ViewTable(IWidget parent){
super(parent);
this.addWidget("Titles", new Row(null)).setGeometry(new WidgetGeometry(0.0, 0.0, 100.0, 16.0, CType.REL_X, CType.REL_X, WAlign.LEFT, WAlign.TOP));
((Row)this.getWidget("Titles")).setColors(0x00000000, 0x00000000);
this.addWidget("Viewport", new ViewportScrollable(null)).setGeometry(new WidgetGeometry(0.0, 16.0, 100.0, 90.0, CType.REL_X, CType.RELXY, WAlign.LEFT, WAlign.TOP));
((ViewportScrollable)(this.getWidget("Viewport"))).attachWidget(new LayoutBase(null)).setGeometry(new WidgetGeometry(0.0, 0.0, 100.0, 0.0, CType.RELXY, CType.REL_X, WAlign.LEFT, WAlign.TOP));
}
@Override
public void draw(Point pos){}
public ViewTable setColumnsWidth(double... widths){
if (this.ncolumns == -1)
this.ncolumns = widths.length;
else if(this.ncolumns != widths.length){
throw new UIException(String.format("Number of columns mismatch. Expecting %d, got %d", this.ncolumns, widths.length));
}
this.widths = widths;
((Row)this.getWidget("Titles")).setColumnsWidth(widths);
return this;
}
public ViewTable setColumnsTitle(String...strings ){
if (this.ncolumns == -1)
this.ncolumns = strings.length;
else if(this.ncolumns != strings.length){
throw new UIException(String.format("Number of columns mismatch. Expecting %d, got %d", this.ncolumns, strings.length));
}
this.texts = strings;
((Row)this.getWidget("Titles")).setColumnsText(strings);
return this;
}
public ViewTable setColumnsAlign(WAlign... aligns ){
if (this.ncolumns == -1)
this.ncolumns = aligns.length;
else if(this.ncolumns != aligns.length){
throw new UIException(String.format("Number of columns mismatch. Expecting %d, got %d", this.ncolumns, aligns.length));
}
this.aligns = aligns;
((Row)this.getWidget("Titles")).setColumnsAlign(aligns);
return this;
}
public ViewTable addRow(String...strings ){
IWidget tableLayout = ((ViewportScrollable)(this.getWidget("Viewport"))).getAttachedWidget();
tableLayout.setSize(100.0, (this.nrows + 1) * 16);
Row newRow = (Row)new Row(null);
newRow.setColumnsWidth(this.widths);
newRow.setColumnsText(strings);
newRow.setColumnsAlign(this.aligns);
if(this.nrows % 2 == 1)
newRow.setColors(0x50808080, 0x50808080);
newRow.setGeometry(new WidgetGeometry(0.0, 16*this.nrows, 100.0, 16, CType.REL_X, CType.REL_X, WAlign.LEFT, WAlign.TOP));
tableLayout.addWidget(String.format("Row_%03d", this.nrows), newRow);
this.nrows += 1;
return this;
}
}
@@ -0,0 +1,179 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.Signal;
import mcp.mobius.waila.gui.interfaces.WAlign;
import org.lwjgl.opengl.Display;
import org.lwjgl.util.Point;
public class ViewportScrollable extends WidgetBase {
public class Escalator extends WidgetBase{
int yOffset = 0;
int sizeCursor = 8;
int maxValue = 0;
int step = 0;
boolean drag = false;
public Escalator(IWidget parent, int step){
this.parent = parent;
this.step = step;
}
public void setOffset(int yoffset){
this.yOffset = yoffset;
}
public void setMaxValue(int value){
this.maxValue = value;
}
public void setStep(int step){
this.step = step;
}
@Override
public void draw(Point pos) {
UIHelper.drawGradientRect(this.getLeft(), this.getTop(), this.getRight(), this.getBottom(), 1, 0xff999999, 0xff999999);
int offsetScaled = (int)(((double)this.getSize().getY() - (double)sizeCursor + 1) / (double)this.maxValue * (yOffset));
UIHelper.drawGradientRect(this.getLeft(), this.getTop() + offsetScaled, this.getRight(), this.getTop() + offsetScaled + sizeCursor, 1, 0xffffffff, 0xffffffff);
}
@Override
public void onMouseClick(MouseEvent event){
if (event.button == 0){
int offsetScaled = this.getTop() + (int)(((double)this.getSize().getY() - (double)sizeCursor + 1) / (double)this.maxValue * (yOffset));
this.drag = false;
if (event.y < offsetScaled)
this.yOffset += this.step;
else if (event.y > offsetScaled + sizeCursor)
this.yOffset -= this.step;
else
this.drag = true;
this.emit(Signal.VALUE_CHANGED, this.yOffset);
} else {
super.onMouseClick(event);
}
}
@Override
public void onMouseRelease(MouseEvent event){
if (event.button == 0)
this.drag = false;
super.onMouseRelease(event);
}
@Override
public void onMouseDrag(MouseEvent event){
if (this.drag){
int relativeY = (int)event.y - this.getTop();
double factor = ((double)this.getSize().getY() - (double)sizeCursor + 1) / (double)this.maxValue;
this.yOffset = (int)(relativeY / factor);
this.yOffset = Math.max(this.yOffset, this.maxValue);
this.yOffset = Math.min(this.yOffset, 0);
this.emit(Signal.VALUE_CHANGED, this.yOffset);
this.emit(Signal.DRAGGED, this);
}
else
super.onMouseDrag(event);
}
}
IWidget attachedWidget = null;
int yOffset = 0;
int step = 5;
public ViewportScrollable( IWidget parent){
super(parent);
this.addWidget("Cropping", new LayoutCropping(null)).setGeometry(new WidgetGeometry(0.0, 0.0, 100.0, 100.0, CType.RELXY, CType.RELXY, WAlign.LEFT, WAlign.TOP));
this.addWidget("Escalator", new Escalator(null, this.step * 5)).setGeometry(new WidgetGeometry(100.0, 0, 8, 100.0, CType.RELXY, CType.REL_Y, WAlign.RIGHT, WAlign.TOP)).hide();
}
public IWidget attachWidget(IWidget widget){
this.attachedWidget = this.getWidget("Cropping").addWidget("Cropped", widget);
return this.attachedWidget;
}
public IWidget getAttachedWidget(){
return this.attachedWidget;
}
public IWidget setStep(int step){
this.step = step;
((Escalator)this.getWidget("Escalator")).setStep(this.step * 5);
return this;
}
@Override
public void draw(Point pos) {}
@Override
public void draw(){
//if (Display.wasResized())
if ((this.attachedWidget != null) && (this.attachedWidget.getSize().getY() > this.getSize().getY()))
this.getWidget("Escalator").show();
else
this.getWidget("Escalator").hide();
super.draw();
}
@Override
public void onMouseWheel(MouseEvent event){
this.yOffset += event.z / 120.0 * this.step;
this.yOffset = Math.max(this.yOffset, this.getSize().getY() - this.attachedWidget.getSize().getY());
this.yOffset = Math.min(this.yOffset, 0);
((LayoutCropping)this.getWidget("Cropping")).setOffsets(0, this.yOffset);
((Escalator)this.getWidget("Escalator")).setOffset(this.yOffset);
}
@Override
public void onWidgetEvent(IWidget srcwidget, Signal signal, Object... params){
if (srcwidget.equals(this.attachedWidget) && signal == Signal.GEOM_CHANGED){
((Escalator)this.getWidget("Escalator")).setMaxValue(this.getSize().getY() - srcwidget.getSize().getY());
}
else if (srcwidget.equals(this.getWidget("Escalator")) && signal == Signal.VALUE_CHANGED){
this.yOffset = (Integer)params[0];
((LayoutCropping)this.getWidget("Cropping")).setOffsets(0, this.yOffset);
}
else
super.onWidgetEvent(srcwidget, signal, params);
}
@Override
public void onMouseDrag(MouseEvent event){
if (this.getWidget("Escalator").shouldRender() && ((Escalator)this.getWidget("Escalator")).drag)
this.getWidget("Escalator").onMouseDrag(event);
else
super.onMouseDrag(event);
}
@Override
public void onMouseClick(MouseEvent event){
if (event.button == 0){
if (!this.getWidget("Escalator").isWidgetAtCoordinates(event.x, event.y)){
((Escalator)this.getWidget("Escalator")).drag = false;
super.onMouseClick(event);
}
else
this.getWidget("Escalator").onMouseClick(event);
}
else
super.onMouseClick(event);
}
}
@@ -0,0 +1,362 @@
package mcp.mobius.waila.gui.widgets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.Point;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.texture.TextureManager;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.helpers.ReverseIterator;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.RenderPriority;
import mcp.mobius.waila.gui.interfaces.Signal;
public abstract class WidgetBase implements IWidget {
protected IWidget parent;
protected WidgetGeometry geom;
protected LinkedHashMap<String, IWidget> widgets = new LinkedHashMap<String, IWidget>();
protected LinkedHashMap<String, IWidget> renderQueue_HIGH = new LinkedHashMap<String, IWidget>();
protected LinkedHashMap<String, IWidget> renderQueue_MEDIUM = new LinkedHashMap<String, IWidget>();
protected LinkedHashMap<String, IWidget> renderQueue_LOW = new LinkedHashMap<String, IWidget>();
protected Minecraft mc;
protected TextureManager texManager;
protected ScaledResolution rez;
protected boolean hasBlending;
protected boolean hasLight;
protected int boundTexIndex;
protected boolean isRendering = true;
protected float alpha = 1.0f;
public WidgetBase(){
this.setParent(null);
this.mc = Minecraft.getMinecraft();
this.rez = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
this.texManager = this.mc.renderEngine;
this.setGeometry(new WidgetGeometry(0, 0, 50, 50, CType.ABSXY, CType.ABSXY));
}
public WidgetBase(IWidget parent){
this.setParent(parent);
this.mc = Minecraft.getMinecraft();
this.rez = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
this.texManager = this.mc.renderEngine;
this.setGeometry(new WidgetGeometry(0, 0, 50, 50, CType.ABSXY, CType.ABSXY));
}
/////////////////////
// WIDGET HANDLING //
/////////////////////
@Override
public IWidget addWidget(String name, IWidget widget){
return this.addWidget(name, widget, RenderPriority.MEDIUM);
}
@Override
public IWidget addWidget(String name, IWidget widget, RenderPriority priority){
widget.setParent(this);
this.widgets.put(name, widget);
switch(priority){
case LOW:
this.renderQueue_LOW.put(name, widget);
break;
case HIGH:
this.renderQueue_HIGH.put(name, widget);
break;
case MEDIUM:
this.renderQueue_MEDIUM.put(name, widget);
break;
}
return this.getWidget(name);
}
@Override
public IWidget getWidget(String name){
return this.widgets.get(name);
}
@Override
public IWidget delWidget(String name){
IWidget widget = this.getWidget(name);
this.widgets.remove(widget);
return widget;
}
@Override
public IWidget getWidgetAtCoordinates(double posX, double posY){
for (IWidget widget : new ReverseIterator<IWidget>(this.widgets.values()))
if ((posX >= widget.getPos().getX()) &&
(posX <= widget.getPos().getX() + widget.getSize().getX()) &&
(posY >= widget.getPos().getY()) &&
(posY <= widget.getPos().getY() + widget.getSize().getY()))
return widget.getWidgetAtCoordinates(posX, posY);
if ((posX >= this.getPos().getX()) &&
(posX <= this.getPos().getX() + this.getSize().getX()) &&
(posY >= this.getPos().getY()) &&
(posY <= this.getPos().getY() + this.getSize().getY()))
return this;
return null;
}
@Override
public boolean isWidgetAtCoordinates(double posx, double posy){
if (this.getLeft() > posx) return false;
if (this.getRight() < posx) return false;
if (this.getTop() > posy) return false;
if (this.getBottom() < posy) return false;
return true;
}
///////////////////////
// IWIDGET INTERFACE //
///////////////////////
@Override
public IWidget getParent() { return this.parent; }
@Override
public void setParent(IWidget parent) { this.parent = parent; }
@Override
public void draw(){
this.saveGLState();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1.0f, 1.0f, 1.0f, this.alpha);
this.draw(this.getPos());
/*
for (IWidget widget: this.widgets.values())
if (widget.shouldRender())
widget.draw();
*/
for (IWidget widget: this.renderQueue_LOW.values())
if (widget.shouldRender())
widget.draw();
for (IWidget widget: this.renderQueue_MEDIUM.values())
if (widget.shouldRender())
widget.draw();
for (IWidget widget: this.renderQueue_HIGH.values())
if (widget.shouldRender())
widget.draw();
this.loadGLState();
}
@Override
public abstract void draw(Point pos);
@Override
public IWidget setGeometry(WidgetGeometry geom) {
this.geom = geom;
this.emit(Signal.GEOM_CHANGED, this.geom);
return this;
}
public IWidget setGeometry(double x, double y, double sx, double sy, CType fp, CType fs){
this.setGeometry(new WidgetGeometry (x, y, sx, sy, fp, fs));
this.emit(Signal.GEOM_CHANGED, this.geom);
return this;
}
@Override
public WidgetGeometry getGeometry() { return this.geom; }
@Override
public Point getPos() { return this.geom.getPos(this.parent); }
@Override
public Point getSize() { return this.geom.getSize(this.parent); }
@Override
public int getLeft() { return this.getPos().getX(); }
@Override
public int getRight() { return this.getPos().getX() + this.getSize().getX(); }
@Override
public int getTop() { return this.getPos().getY(); }
@Override
public int getBottom() { return this.getPos().getY() + this.getSize().getY(); }
@Override
public IWidget setPos(double x, double y){
return this.setPos(x, y, this.geom.fracPosX, this.geom.fracPosY);
}
@Override
public IWidget setPos(double x, double y, boolean fracX, boolean fracY){
this.geom.setPos(x, y, fracX, fracY);
this.emit(Signal.GEOM_CHANGED, this.geom);
return this;
};
@Override
public IWidget setSize(double sx, double sy){
return this.setSize(sx, sy, this.geom.fracSizeX, this.geom.fracSizeY);
}
@Override
public IWidget setSize(double sx, double sy, boolean fracX, boolean fracY){
this.geom.setSize(sx, sy, fracX, fracY);
this.emit(Signal.GEOM_CHANGED, this.geom);
return this;
};
@Override
public IWidget adjustSize(){
int minleft = 9999;
int maxright = 0;
int mintop = 9999;
int maxbottom = 0;
for (IWidget widget : this.widgets.values()){
minleft = Math.min(minleft, widget.getLeft());
maxright = Math.max(maxright, widget.getRight());
mintop = Math.min(mintop, widget.getTop());
maxbottom = Math.max(maxbottom, widget.getBottom());
}
this.setSize(maxright - minleft, maxbottom - mintop, false, false);
this.emit(Signal.GEOM_CHANGED, this.geom);
return this;
}
////////////////////////////
// SOME RENDERING HELPERS //
////////////////////////////
protected void saveGLState(){
hasBlending = GL11.glGetBoolean(GL11.GL_BLEND);
hasLight = GL11.glGetBoolean(GL11.GL_LIGHTING);
boundTexIndex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
GL11.glPushMatrix();
}
protected void loadGLState(){
if (hasBlending) GL11.glEnable(GL11.GL_BLEND); else GL11.glDisable(GL11.GL_BLEND);
if (hasLight) GL11.glEnable(GL11.GL_LIGHTING); else GL11.glDisable(GL11.GL_LIGHTING);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, boundTexIndex);
GL11.glPopMatrix();
GL11.glPopAttrib();
//GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
@Override
public void setAlpha(float alpha){this.alpha = alpha;};
@Override
public float getAlpha(){return this.alpha;};
@Override
public void show(){this.isRendering = true;};
@Override
public void hide(){this.isRendering = false;};
@Override
public boolean shouldRender(){return this.isRendering;};
////////////////////
// INPUT HANDLING //
////////////////////
@Override
public void handleMouseInput(){}
@Override
public void onMouseClick(MouseEvent event) {
//System.out.printf("%s %s\n", this, event);
if (this.parent != null)
this.parent.onMouseClick(event);
//IWidget widget = this.getWidgetAtCoordinates(event.x, event.y);
//if (widget != null && widget != this)
// widget.onMouseClick(event);
}
@Override
public void onMouseDrag(MouseEvent event) {
//System.out.printf("%s %s\n", this, event);
if (this.parent != null)
this.parent.onMouseDrag(event);
//IWidget widget = this.getWidgetAtCoordinates(event.x, event.y);
//if (widget != null && widget != this)
// widget.onMouseDrag(event);
}
@Override
public void onMouseMove(MouseEvent event) {
//System.out.printf("%s %s\n", this, event);
if (this.parent != null)
this.parent.onMouseMove(event);
//IWidget widget = this.getWidgetAtCoordinates(event.x, event.y);
//if (widget != null && widget != this)
// widget.onMouseMove(event);
}
@Override
public void onMouseRelease(MouseEvent event) {
//System.out.printf("%s %s\n", this, event);
if (this.parent != null)
this.parent.onMouseRelease(event);
//IWidget widget = this.getWidgetAtCoordinates(event.x, event.y);
//if (widget != null && widget != this)
// widget.onMouseRelease(event);
}
@Override
public void onMouseWheel(MouseEvent event) {
//System.out.printf("%s %s\n", this, event);
if (this.parent != null)
this.parent.onMouseWheel(event);
}
@Override
public void onMouseEnter(MouseEvent event) {
//System.out.printf("%s %s\n", this, event);
if (this.parent != null)
this.parent.onMouseEnter(event);
}
@Override
public void onMouseLeave(MouseEvent event) {
//System.out.printf("%s %s\n", this, event);
if (this.parent != null)
this.parent.onMouseLeave(event);
}
@Override
public void emit(Signal signal, Object... params) {
if(this.parent != null)
this.parent.onWidgetEvent(this, signal, params);
}
@Override
public void onWidgetEvent(IWidget srcwidget, Signal signal, Object... params) {
if (this.parent != null)
this.parent.onWidgetEvent(srcwidget, signal, params);
}
}
@@ -0,0 +1,186 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.WAlign;
import net.minecraft.util.MathHelper;
import org.lwjgl.util.Point;
//public class WidgetGeometry implements Cloneable{
public class WidgetGeometry{
//public enum Align {LEFT, CENTER, RIGHT, TOP, BOTTOM};
double x = -1;
double y = -1;
double sx = -1;
double sy = -1;
CType posType;
CType sizeType;
boolean fracPosX = false;
boolean fracPosY = false;
boolean fracSizeX = false;
boolean fracSizeY = false;
WAlign alignX;
WAlign alignY;
public class PointDouble{
double x; double y;
public PointDouble(double x, double y){ this.x = x; this.y = y;};
public double getX(){return this.x;}
public double getY(){return this.y;}
public String toString(){return String.format("PointDouble : %.5f %.5f", this.x, this.y);}
}
public WidgetGeometry(double x, double y, double sx, double sy, CType fracPos, CType fracSize){
this(x, y, sx, sy, fracPos, fracSize, WAlign.LEFT, WAlign.TOP);
}
public WidgetGeometry(double x, double y, double sx, double sy, CType fracPos, CType fracSize, WAlign alignX, WAlign alignY){
this.x = x;
this.y = y;
this.sx = sx;
this.sy = sy;
this.posType = fracPos;
this.sizeType = fracSize;
switch(fracPos){
case REL_X:
this.fracPosX = true;
break;
case RELXY:
this.fracPosX = true;
this.fracPosY = true;
break;
case REL_Y:
this.fracPosY = true;
break;
default:
break;
}
switch(fracSize){
case REL_X:
this.fracSizeX = true;
break;
case RELXY:
this.fracSizeX = true;
this.fracSizeY = true;
break;
case REL_Y:
this.fracSizeY = true;
break;
default:
break;
}
this.alignX = alignX;
this.alignY = alignY;
}
public void setPos(double x, double y, boolean fracX, boolean fracY){
this.x = x;
this.y = y;
this.fracPosX = fracX;
this.fracPosY = fracY;
}
public void setSize(double sx, double sy, boolean fracSizeX, boolean fracSizeY){
this.sx = sx;
this.sy = sy;
this.fracSizeX = fracSizeX;
this.fracSizeY = fracSizeY;
}
public PointDouble getRawPos(){
return new PointDouble(this.x, this.y);
}
public Point getUnalignedPos(IWidget parent){
int x = -1;
if (this.fracPosX)
x = MathHelper.ceiling_double_int(parent.getPos().getX() + parent.getSize().getX() * this.x / 100D);
if (!this.fracPosX && parent != null)
x = parent.getPos().getX() + (int)this.x;
if (!this.fracPosX && parent == null)
x = (int)this.x;
int y = -1;
if (this.fracPosY)
y = MathHelper.ceiling_double_int(parent.getPos().getY() + parent.getSize().getY() * this.y / 100D);
if (!this.fracPosY && parent != null)
y = parent.getPos().getY() + (int)this.y;
if (!this.fracPosY && parent == null)
y = (int)this.y;
return new Point(x,y);
}
public Point getPos(IWidget parent){
int x = -1;
if (this.fracPosX)
x = MathHelper.ceiling_double_int(parent.getPos().getX() + parent.getSize().getX() * this.x / 100D);
if (!this.fracPosX && parent != null)
x = parent.getPos().getX() + (int)this.x;
if (!this.fracPosX && parent == null)
x = (int)this.x;
int y = -1;
if (this.fracPosY)
y = MathHelper.ceiling_double_int(parent.getPos().getY() + parent.getSize().getY() * this.y / 100D);
if (!this.fracPosY && parent != null)
y = parent.getPos().getY() + (int)this.y;
if (!this.fracPosY && parent == null)
y = (int)this.y;
if (this.alignX == WAlign.CENTER)
x -= this.getSize(parent).getX() / 2;
if (this.alignY == WAlign.CENTER)
y -= this.getSize(parent).getY() / 2;
if (this.alignX == WAlign.RIGHT)
x -= this.getSize(parent).getX() - 1;
if (this.alignY == WAlign.BOTTOM)
y -= this.getSize(parent).getY() - 1;
return new Point(x,y);
}
public Point getSize(IWidget parent){
int sx = -1;
if (this.fracSizeX)
sx = MathHelper.ceiling_double_int(parent.getSize().getX() * this.sx / 100D);
if (!this.fracSizeX)
sx = (int)this.sx;
int sy = -1;
if (this.fracSizeY)
sy = MathHelper.ceiling_double_int(parent.getSize().getY() * this.sy / 100D);
if (!this.fracSizeY)
sy = (int)this.sy;
return new Point(sx,sy);
}
public String toString(){
return String.format("Geometry : [%s %s] [%s %s] [%s %s] [%s %s]", this.x, this.y, this.sx, this.sy, this.posType, this.sizeType, this.alignX, this.alignY);
}
//@Override
//public WidgetGeometry clone() throws CloneNotSupportedException{
// return (WidgetGeometry)super.clone();
//}
}
@@ -0,0 +1,73 @@
package mcp.mobius.waila.gui.widgets.buttons;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.Signal;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.WidgetBase;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.Point;
public abstract class ButtonBase extends WidgetBase {
protected boolean mouseOver = false;
protected static ResourceLocation widgetsTexture = new ResourceLocation("textures/gui/widgets.png");
public ButtonBase(IWidget parent){
super(parent);
}
@Override
public void draw() {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
for (IWidget widget : this.widgets.values())
if (widget instanceof LabelFixedFont)
if (this.mouseOver)
((LabelFixedFont)widget).setColor(0xffffa0);
else
((LabelFixedFont)widget).setColor(0xffffff);
super.draw();
}
@Override
public void draw(Point pos) {
this.saveGLState();
int texOffset = 0;
if (this.mouseOver)
texOffset = 1;
this.mc.func_110434_K().func_110577_a(widgetsTexture);
UIHelper.drawTexture(this.getPos().getX(), this.getPos().getY(), this.getSize().getX(), this.getSize().getY(), 0, 66 + texOffset*20, 200, 20);
this.loadGLState();
}
@Override
public void onMouseEnter(MouseEvent event){
mouseOver = true;
}
@Override
public void onMouseLeave(MouseEvent event){
mouseOver = false;
}
@Override
public IWidget getWidgetAtCoordinates(double posX, double posY){
return this;
}
@Override
public void onMouseClick(MouseEvent event){
if (event.button == 0)
this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
this.emit(Signal.CLICKED, event.button);
}
}
@@ -0,0 +1,43 @@
package mcp.mobius.waila.gui.widgets.buttons;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.util.Point;
public class ButtonBoolean extends ButtonBase {
protected boolean state = false;
public ButtonBoolean(IWidget parent, String textFalse, String textTrue){
super(parent);
this.addWidget("LabelFalse", new LabelFixedFont(this, textFalse));
this.getWidget("LabelFalse").setGeometry(new WidgetGeometry(50.0D, 50.0D, 100.0D, 20.0D, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
this.addWidget("LabelTrue", new LabelFixedFont(this, textTrue));
this.getWidget("LabelTrue").hide();
this.getWidget("LabelTrue").setGeometry(new WidgetGeometry(50.0D, 50.0D, 100.0D, 20.0D, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
}
@Override
public void onMouseClick(MouseEvent event){
super.onMouseClick(event);
if (event.button == 0)
this.state = !this.state;
if (this.state){
this.getWidget("LabelTrue").show();
this.getWidget("LabelFalse").hide();
} else {
this.getWidget("LabelTrue").hide();
this.getWidget("LabelFalse").show();
}
}
}
@@ -0,0 +1,46 @@
package mcp.mobius.waila.gui.widgets.buttons;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.Property;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.interfaces.IWidget;
public class ButtonBooleanConfig extends ButtonBoolean {
private String configKey;
private boolean instant;
public ButtonBooleanConfig(IWidget parent, String configKey, String textFalse, String textTrue){
this(parent, configKey, true, true, textFalse, textTrue);
}
public ButtonBooleanConfig(IWidget parent, String configKey, boolean instant, boolean state_, String textFalse, String textTrue){
super(parent, textFalse, textTrue);
this.configKey = configKey;
this.instant = instant;
mod_Waila.instance.config.load();
Property prop = mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, this.configKey, state_);
this.state = prop.getBoolean(state_);
if (this.state){
this.getWidget("LabelTrue").show();
this.getWidget("LabelFalse").hide();
} else {
this.getWidget("LabelTrue").hide();
this.getWidget("LabelFalse").show();
}
}
@Override
public void onMouseClick(MouseEvent event){
super.onMouseClick(event);
if (this.instant){
mod_Waila.instance.config.getCategory(Configuration.CATEGORY_GENERAL).put(this.configKey, new Property(this.configKey,String.valueOf(this.state),Property.Type.BOOLEAN));
mod_Waila.instance.config.save();
}
}
}
@@ -0,0 +1,52 @@
package mcp.mobius.waila.gui.widgets.buttons;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.Point;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.Property;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
public class ButtonBooleanConfigRemote extends ButtonBooleanConfig {
public ButtonBooleanConfigRemote(IWidget parent, String configKey, String textFalse, String textTrue){
this(parent, configKey, true, true, textFalse, textTrue);
}
public ButtonBooleanConfigRemote(IWidget parent, String configKey, boolean instant, boolean state_, String textFalse, String textTrue){
super(parent, configKey, instant, state_, textFalse, textTrue);
if (!mod_Waila.instance.serverPresent)
this.state = false;
if (this.state){
this.getWidget("LabelTrue").show();
this.getWidget("LabelFalse").hide();
} else {
this.getWidget("LabelTrue").hide();
this.getWidget("LabelFalse").show();
}
}
@Override
public void onMouseClick(MouseEvent event){
if (mod_Waila.instance.serverPresent)
super.onMouseClick(event);
}
@Override
public void draw(Point pos) {
if (mod_Waila.instance.serverPresent)
super.draw(pos);
else{
this.saveGLState();
int texOffset = -1;
this.mc.func_110434_K().func_110577_a(widgetsTexture);
UIHelper.drawTexture(this.getPos().getX(), this.getPos().getY(), this.getSize().getX(), this.getSize().getY(), 0, 66 + texOffset*20, 200, 20);
this.loadGLState();
}
}
}
@@ -0,0 +1,50 @@
package mcp.mobius.waila.gui.widgets.buttons;
import org.lwjgl.util.Point;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.WidgetBase;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
public class ButtonContainer extends WidgetBase {
private int nButtons = 0;
private int columns;
private int buttonSize;
private double spacing;
public ButtonContainer(IWidget parent, int columns, int buttonSize, double spacing){
super (parent);
this.columns = columns;
this.spacing = spacing;
this.buttonSize = buttonSize;
}
public void addButton(ButtonBase button){
String buttonName = String.format("Button_%d", nButtons);
String layoutName = String.format("Layout_%d", nButtons);
String layoutLabelName = String.format("LayoutLabel_%d", nButtons);
String labelName = String.format("Label_%d", nButtons);
this.addWidget(layoutName, new LayoutBase(this));
this.addWidget(layoutLabelName, new LayoutBase(this));
int column = this.nButtons % this.columns;
int row = this.nButtons / this.columns;
double sizeColumn = 100.0 / this.columns;
this.getWidget(layoutName).setGeometry(new WidgetGeometry(sizeColumn * column, spacing * row, sizeColumn, spacing, CType.REL_X, CType.REL_X, WAlign.LEFT, WAlign.TOP));
this.getWidget(layoutName).addWidget(buttonName, button);
this.getWidget(layoutName).getWidget(buttonName).setGeometry(new WidgetGeometry(50.0, 50.0, buttonSize, 20.0, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
this.nButtons += 1;
}
@Override
public void draw(Point pos) {}
}
@@ -0,0 +1,55 @@
package mcp.mobius.waila.gui.widgets.buttons;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.WidgetBase;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import org.lwjgl.util.Point;
//TODO : THIS CLASS IS WIP AND CAN'T WORK RIGHT NOW
public class ButtonContainerLabel extends WidgetBase {
private int nButtons = 0;
private int columns;
private int buttonSize;
private double spacing;
public ButtonContainerLabel(IWidget parent, int columns, int buttonSize, double spacing){
super (parent);
this.columns = columns;
this.spacing = spacing;
this.buttonSize = buttonSize;
}
public void addButton(ButtonBase button, String label){
String buttonName = String.format("Button_%d", nButtons);
String layoutName = String.format("Layout_%d", nButtons);
String layoutLabelName = String.format("LayoutLabel_%d", nButtons);
String labelName = String.format("Label_%d", nButtons);
this.addWidget(layoutName, new LayoutBase(this));
this.addWidget(layoutLabelName, new LayoutBase(this));
int column = (this.nButtons % this.columns) * 2;
int row = this.nButtons / this.columns;
double sizeColumn = 100.0 / (this.columns * 2);
this.getWidget(layoutName).setGeometry(new WidgetGeometry(sizeColumn * (column + 1), spacing * row, sizeColumn, spacing, CType.REL_X, CType.REL_X, WAlign.LEFT, WAlign.TOP));
this.getWidget(layoutName).addWidget(buttonName, button);
this.getWidget(layoutName).getWidget(buttonName).setGeometry(new WidgetGeometry(50.0, 50.0, buttonSize, 20.0, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
this.getWidget(layoutLabelName).setGeometry(new WidgetGeometry(sizeColumn * column, spacing * row, sizeColumn, spacing, CType.REL_X, CType.REL_X, WAlign.LEFT, WAlign.TOP));
this.getWidget(layoutLabelName).addWidget(labelName, new LabelFixedFont(this, label));
this.getWidget(layoutLabelName).getWidget(labelName).setGeometry(new WidgetGeometry(50.0, 50.0, buttonSize, 20.0, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
this.nButtons += 1;
}
@Override
public void draw(Point pos) {}
}
@@ -0,0 +1,49 @@
package mcp.mobius.waila.gui.widgets.buttons;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.util.Point;
public class ButtonInteger extends ButtonBase {
protected int state = 0;
protected int nStates;
public ButtonInteger(IWidget parent, String... texts){
super(parent);
this.nStates = texts.length;
for (int i = 0; i < texts.length; i++){
String labelName = String.format("Label_%d", i);
this.addWidget(labelName, new LabelFixedFont(this, texts[i]));
this.getWidget(labelName).hide();
this.getWidget(labelName).setGeometry(new WidgetGeometry(50.0D, 50.0D, 100.0D, 20.0D, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
}
this.getWidget("Label_0").show();
}
@Override
public void onMouseClick(MouseEvent event){
super.onMouseClick(event);
if (event.button == 0)
this.state += 1;
if (this.state >= this.nStates)
this.state = 0;
for (int i = 0; i < this.nStates; i++)
this.getWidget(String.format("Label_%d", i)).hide();
this.getWidget(String.format("Label_%d", state)).show();
}
}
@@ -0,0 +1,47 @@
package mcp.mobius.waila.gui.widgets.buttons;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.Property;
import org.lwjgl.util.Point;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.widgets.WidgetBase;
public class ButtonIntegerConfig extends ButtonInteger {
private String configKey;
private boolean instant;
public ButtonIntegerConfig(IWidget parent, String configKey, String... texts){
this(parent, configKey, true, 0, texts);
}
public ButtonIntegerConfig(IWidget parent, String configKey, boolean instant, int state_, String... texts){
super(parent, texts);
this.configKey = configKey;
this.instant = instant;
mod_Waila.instance.config.load();
Property prop = mod_Waila.instance.config.get(Configuration.CATEGORY_GENERAL, this.configKey, state_);
this.state = prop.getInt();
for (int i = 0; i < this.nStates; i++)
this.getWidget(String.format("Label_%d", i)).hide();
this.getWidget(String.format("Label_%d", state)).show();
}
@Override
public void onMouseClick(MouseEvent event){
super.onMouseClick(event);
if (this.instant){
mod_Waila.instance.config.getCategory(Configuration.CATEGORY_GENERAL).put(this.configKey, new Property(this.configKey,String.valueOf(this.state),Property.Type.INTEGER));
mod_Waila.instance.config.save();
}
}
}
@@ -0,0 +1,24 @@
package mcp.mobius.waila.gui.widgets.buttons;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import net.minecraft.client.gui.GuiScreen;
public class ButtonLabel extends ButtonBase {
public ButtonLabel(IWidget parent, String text){
super(parent);
this.addWidget("Label", new LabelFixedFont(this, text));
this.getWidget("Label").setGeometry(new WidgetGeometry(50.0D, 50.0D, 100.0D, 20.0D, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
}
@Override
public void onMouseClick(MouseEvent event){
super.onMouseClick(event);
}
}
@@ -0,0 +1,31 @@
package mcp.mobius.waila.gui.widgets.buttons;
import net.minecraft.client.gui.GuiScreen;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
public class ButtonScreenChange extends ButtonBase {
GuiScreen linkedScreen;
public ButtonScreenChange(IWidget parent, String text, GuiScreen linkedscreen){
super(parent);
this.linkedScreen = linkedscreen;
this.addWidget("Label", new LabelFixedFont(this, text));
this.getWidget("Label").setGeometry(new WidgetGeometry(50.0D, 50.0D, 100.0D, 20.0D, CType.RELXY, CType.ABSXY, WAlign.CENTER, WAlign.CENTER));
}
@Override
public void onMouseClick(MouseEvent event){
super.onMouseClick(event);
if (event.button == 0)
this.mc.displayGuiScreen(this.linkedScreen);
}
}
@@ -0,0 +1,68 @@
package mcp.mobius.waila.gui.widgets.movable;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.Signal;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.widgets.WidgetBase;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import mcp.mobius.waila.gui.widgets.WidgetGeometry.PointDouble;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.Point;
// A movable picture setup especially for centered relative positions.
public class PictureMovableRC extends WidgetBase {
private double offsetX, offsetY;
protected ResourceLocation texture;
public PictureMovableRC(IWidget parent, String uri) {
super(parent);
this.texture = new ResourceLocation(uri);
}
@Override
public void onMouseClick(MouseEvent event){
this.offsetX = event.x - this.geom.getUnalignedPos(this.parent).getX();
this.offsetY = event.y - this.geom.getUnalignedPos(this.parent).getY();
//System.out.printf("%s %s\n", this.offsetX, this.offsetY);
}
@Override
public void onMouseDrag(MouseEvent event){
double newX = event.x - this.offsetX ;
double newY = event.y - this.offsetY ;
newX = Math.max(newX, this.parent.getLeft());
newY = Math.max(newY, this.parent.getTop());
newX = Math.min(newX, this.parent.getRight());
newY = Math.min(newY, this.parent.getBottom());
this.setPos(((newX - this.parent.getLeft()) / this.parent.getSize().getX()) * 100.0, ((newY - this.parent.getTop())/ this.parent.getSize().getY()) * 100.0);
//System.out.printf("%s\n", this.parent.getGeometry());
//System.out.printf("%s %s\n", this.parent.getPos(), this.parent.getSize());
this.emit(Signal.DRAGGED, this.getPos());
}
@Override
public void draw(Point pos) {
this.saveGLState();
GL11.glPushMatrix();
this.texManager.func_110577_a(texture);
UIHelper.drawTexture(pos.getX(), pos.getY(), this.getSize().getX(), this.getSize().getY());
GL11.glPopMatrix();
this.loadGLState();
}
}
@@ -1,13 +1,13 @@
package mcp.mobius.waila.gui;
package mcp.mobius.waila.gui_old;
import java.util.Collection;
import java.util.HashMap;
import org.lwjgl.input.Mouse;
import mcp.mobius.waila.gui.widget.IWidget;
import mcp.mobius.waila.gui.widget_old.Button2States;
import mcp.mobius.waila.gui.widget_old.ButtonChangeScreen;
import mcp.mobius.waila.gui_old.widget.IWidget;
import mcp.mobius.waila.gui_old.widget_old.Button2States;
import mcp.mobius.waila.gui_old.widget_old.ButtonChangeScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
@@ -26,8 +26,8 @@ public class BaseWailaScreen extends GuiScreen{
private int lastMousePosY = -1;
private static int buttonCount = Mouse.getButtonCount();
private boolean[] lastButtonStates = new boolean[buttonCount];
private IWidget[] focusWidget = new IWidget[buttonCount];
private IWidget mainFocusWidget = null;
private IWidget[] focusWidget = new IWidget[buttonCount];
private IWidget mainFocusWidget = null;
@@ -1,8 +1,8 @@
package mcp.mobius.waila.gui;
package mcp.mobius.waila.gui_old;
import mcp.mobius.waila.gui.widget.ContainerTable;
import mcp.mobius.waila.gui.widget.Label;
import mcp.mobius.waila.gui.widget.StackDisplay;
import mcp.mobius.waila.gui_old.widget.ContainerTable;
import mcp.mobius.waila.gui_old.widget.Label;
import mcp.mobius.waila.gui_old.widget.StackDisplay;
import net.minecraft.client.gui.GuiScreen;
public class GuiEnchantScreen extends BaseWailaScreen {
@@ -1,17 +1,17 @@
package mcp.mobius.waila.gui;
package mcp.mobius.waila.gui_old;
import mcp.mobius.waila.gui.widget.ContainerTable;
import mcp.mobius.waila.gui.widget.Label;
import mcp.mobius.waila.gui.widget.StackDisplay;
import mcp.mobius.waila.gui.widget.WikiReader;
import mcp.mobius.waila.gui_old.widget.ContainerTable;
import mcp.mobius.waila.gui_old.widget.Label;
import mcp.mobius.waila.gui_old.widget.StackDisplay;
import mcp.mobius.waila.gui_old.widget.WikiReader;
import net.minecraft.client.gui.GuiScreen;
public class GuiIngameWiki extends BaseWailaScreen {
public WikiReader widReader = null;
public StackDisplay widStack = null;
public WikiReader widReader = null;
public StackDisplay widStack = null;
public ContainerTable widTable = null;
public Label widItemName = null;
public Label widItemName = null;
public GuiIngameWiki(GuiScreen _parentGui) {
super(_parentGui);
@@ -1,7 +1,6 @@
package mcp.mobius.waila.gui;
package mcp.mobius.waila.gui_old;
import mcp.mobius.waila.gui.widget.DraggableViewport;
import mcp.mobius.waila.gui.widget.StackDisplay;
import mcp.mobius.waila.gui_old.widget.DraggableViewport;
import net.minecraft.client.gui.GuiScreen;
public class GuiTechTree extends BaseWailaScreen {
@@ -1,4 +1,4 @@
package mcp.mobius.waila.handlers;
package mcp.mobius.waila.gui_old.NEI;
import java.util.ArrayList;
import java.util.HashMap;
@@ -1,11 +1,11 @@
package mcp.mobius.waila.handlers;
package mcp.mobius.waila.gui_old.NEI;
import java.lang.reflect.Method;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.gui.GuiEnchantScreen;
import mcp.mobius.waila.gui.widget.Label;
import mcp.mobius.waila.gui_old.GuiEnchantScreen;
import mcp.mobius.waila.gui_old.widget.Label;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.enchantment.Enchantment;
@@ -1,14 +1,14 @@
package mcp.mobius.waila.handlers;
package mcp.mobius.waila.gui_old.NEI;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.gui.GuiIngameWiki;
import mcp.mobius.waila.gui.GuiTechTree;
import mcp.mobius.waila.gui.widget.ComponentDisplay;
import mcp.mobius.waila.gui.widget.StackDisplay;
import mcp.mobius.waila.gui_old.GuiIngameWiki;
import mcp.mobius.waila.gui_old.GuiTechTree;
import mcp.mobius.waila.gui_old.widget.ComponentDisplay;
import mcp.mobius.waila.gui_old.widget.StackDisplay;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.handlers;
package mcp.mobius.waila.gui_old.NEI;
import java.util.LinkedHashMap;
@@ -7,8 +7,9 @@ import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.gui.GuiIngameWiki;
import mcp.mobius.waila.gui.widget.Label;
import mcp.mobius.waila.gui_old.GuiIngameWiki;
import mcp.mobius.waila.gui_old.widget.Label;
import mcp.mobius.waila.handlers.SummaryProvider;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget;
package mcp.mobius.waila.gui_old.widget;
import java.util.Collection;
import java.util.HashMap;
@@ -1,8 +1,8 @@
package mcp.mobius.waila.gui.widget;
package mcp.mobius.waila.gui_old.widget;
import java.util.ArrayList;
import mcp.mobius.waila.handlers.CraftingTreeNode;
import mcp.mobius.waila.gui_old.NEI.CraftingTreeNode;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget;
package mcp.mobius.waila.gui_old.widget;
import java.util.ArrayList;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget;
package mcp.mobius.waila.gui_old.widget;
import org.lwjgl.opengl.GL11;
@@ -1,13 +1,13 @@
package mcp.mobius.waila.gui.widget;
package mcp.mobius.waila.gui_old.widget;
import java.util.Collection;
public interface IWidget {
int getWidth();
int getHeight();
int getWidth();
int getHeight();
String getLabel();
int getPosX();
int getPosY();
int getPosX();
int getPosY();
void setWidth(int width);
void setHeight(int height);
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget;
package mcp.mobius.waila.gui_old.widget;
import net.minecraft.client.gui.GuiScreen;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget;
package mcp.mobius.waila.gui_old.widget;
import org.lwjgl.opengl.GL11;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget;
package mcp.mobius.waila.gui_old.widget;
import net.minecraft.client.gui.GuiScreen;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget;
package mcp.mobius.waila.gui_old.widget;
import java.util.ArrayList;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget_old;
package mcp.mobius.waila.gui_old.widget_old;
import org.lwjgl.opengl.GL11;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget_old;
package mcp.mobius.waila.gui_old.widget_old;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget_old;
package mcp.mobius.waila.gui_old.widget_old;
import codechicken.nei.NEIClientConfig;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget_old;
package mcp.mobius.waila.gui_old.widget_old;
import mcp.mobius.waila.mod_Waila;
import net.minecraftforge.common.Configuration;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget_old;
package mcp.mobius.waila.gui_old.widget_old;
import mcp.mobius.waila.mod_Waila;
import net.minecraft.client.Minecraft;
@@ -1,4 +1,4 @@
package mcp.mobius.waila.gui.widget_old;
package mcp.mobius.waila.gui_old.widget_old;
import java.util.ArrayList;
@@ -1,12 +1,14 @@
package mcp.mobius.waila.handlers;
package mcp.mobius.waila.handlers.hud;
import java.util.List;
import mcp.mobius.waila.WailaExceptionHandler;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import mcp.mobius.waila.addons.ExternalModulesHandler;
import mcp.mobius.waila.api.IWailaBlock;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.handlers.DataAccessor;
import mcp.mobius.waila.network.Packet0x01TERequest;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
@@ -74,7 +76,13 @@ public class HUDHandlerExternal implements IHighlightHandler {
return ((IWailaBlock)block).getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
}
}
else if (layout == Layout.FOOTER)
try{
return ((IWailaBlock)block).getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
}
}
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(blockID)){
@@ -95,6 +103,19 @@ public class HUDHandlerExternal implements IHighlightHandler {
}
}
if (layout == Layout.FOOTER && ExternalModulesHandler.instance().hasTailProviders(blockID)){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getTailProviders(blockID))
try{
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
}
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(block)){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(block))
try{
@@ -113,6 +134,17 @@ public class HUDHandlerExternal implements IHighlightHandler {
}
}
if (layout == Layout.FOOTER && ExternalModulesHandler.instance().hasTailProviders(block)){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getTailProviders(block))
try{
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
}
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(accessor.getTileEntity())){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(accessor.getTileEntity()))
try{
@@ -130,6 +162,16 @@ public class HUDHandlerExternal implements IHighlightHandler {
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
}
if (layout == Layout.FOOTER && ExternalModulesHandler.instance().hasTailProviders(accessor.getTileEntity())){
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getTailProviders(accessor.getTileEntity()))
try{
currenttip = dataProvider.getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
}
return currenttip;
}
@@ -1,6 +1,8 @@
package mcp.mobius.waila.handlers;
package mcp.mobius.waila.handlers.hud;
import java.util.List;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.addons.ConfigHandler;
import net.minecraft.entity.player.EntityPlayer;
@@ -24,7 +26,7 @@ public class HUDHandlerWaila implements IHighlightHandler {
String modName = mod_Waila.instance.getModName(itemStack);
if (modName != null && !modName.equals(""))
currenttip.add("\u00a79\u00a7o" + modName);
} else if (layout == Layout.HEADER && ConfigHandler.instance().getConfig("waila.showmetadata", false)){
} else if (layout == Layout.HEADER && ConfigHandler.instance().getConfig(Constants.CFG_WAILA_METADATA, false)){
if (currenttip.size() == 0)
currenttip.add("< Unnamed >");
else{
@@ -33,6 +35,6 @@ public class HUDHandlerWaila implements IHighlightHandler {
}
}
return currenttip;
};
}
}
@@ -0,0 +1,139 @@
package mcp.mobius.waila.handlers.nei;
import java.util.Map;
import java.util.logging.Level;
import mcp.mobius.waila.Constants;
import mcp.mobius.waila.mod_Waila;
import mcp.mobius.waila.gui.screens.info.ScreenEnchants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.forge.IContainerInputHandler;
public class HandlerEnchants implements IContainerInputHandler {
@Override
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) { return false; }
@Override
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) { }
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
ItemStack stackover = gui.manager.getStackMouseOver();
if(stackover == null)
return false;
if(keyID == NEIClientConfig.getKeyBinding(Constants.BIND_SCREEN_ENCH)){
//try{
int itemEnchantability = stackover.getItem().getItemEnchantability();
if (itemEnchantability == 0){return false;}
Minecraft mc = Minecraft.getMinecraft();
ScreenEnchants screen = new ScreenEnchants(mc.currentScreen);
screen.setStack(stackover);
screen.setName(stackover.getDisplayName());
screen.setEnchantability(String.valueOf(itemEnchantability));
Enchantment[] enchants = null;
if (stackover.getItem() == Item.book)
enchants = Enchantment.enchantmentsBookList;
else
enchants = Enchantment.enchantmentsList;
for(Enchantment enchant : enchants){
boolean isCompatible = true;
int level = 0;
boolean isApplied = false;
if (enchant == null){continue;}
if (enchant.canApplyAtEnchantingTable(stackover) || stackover.getItem() == Item.book){
if (stackover.isItemEnchanted()){
Map stackenchants = EnchantmentHelper.getEnchantments(stackover);
for (Object id : stackenchants.keySet()){
if (!enchant.canApplyTogether(Enchantment.enchantmentsList[(Integer)id]))
isCompatible = false;
if ((Integer)id == enchant.effectId){
isApplied = true;
level = (Integer)stackenchants.get(id);
}
}
}
for (int lvl = enchant.getMinLevel(); lvl <= enchant.getMaxLevel(); lvl++){
int minEnchantEnchantability = enchant.getMinEnchantability(lvl);
int maxEnchantEnchantability = enchant.getMaxEnchantability(lvl);
int minItemEnchantability = 1;
int meanItemEnchantability = 1 + itemEnchantability/4;
int maxItemEnchantability = 1 + itemEnchantability/2;
int minModifiedEnchantability = (int)(0.85*minItemEnchantability + 0.5);
int meanModifiedEnchantability = (int)(1.00*meanItemEnchantability + 0.5);
int maxModifiedEnchantability = (int)(1.15*maxItemEnchantability + 0.5);
int minLevel = (int) ((minEnchantEnchantability - minModifiedEnchantability)/1.15);
int maxLevel = (int) ((maxEnchantEnchantability - maxModifiedEnchantability)/0.85);
int meanMinLevel = (int) ((minEnchantEnchantability - meanModifiedEnchantability)/1.0);
int meanMaxLevel = (int) ((maxEnchantEnchantability - meanModifiedEnchantability)/1.0);
String colorcode = isCompatible ? "\u00a7f" : "\u00a7c";
if (isApplied && lvl == level)
colorcode = "\u00a7e";
screen.addRow(colorcode + enchant.getTranslatedName(lvl),
colorcode + String.valueOf(minLevel),
colorcode + String.valueOf(maxLevel),
colorcode + String.valueOf(enchant.getWeight()),
"\u00a79\u00a7o"+ this.getEnchantModName(enchant));
}
}
}
mc.displayGuiScreen(screen);
}
return false;
}
public String getEnchantModName(Enchantment enchant){
String enchantPath = enchant.getClass().getProtectionDomain().getCodeSource().getLocation().toString();
//mod_Waila.log.log(Level.INFO, enchantPath);
String enchantModName = "<Unknown>";
for (String s: mod_Waila.instance.modSourceList.keySet())
if (enchantPath.contains(s))
enchantModName = mod_Waila.instance.modSourceList.get(s);
if (enchantModName.equals("Minecraft Coder Pack"))
enchantModName = "Minecraft";
return enchantModName;
}
@Override
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) { return false; }
@Override
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) { }
@Override
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) { }
@Override
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { return false; }
@Override
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { }
@Override
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) { }
}
@@ -1,4 +1,4 @@
package mcp.mobius.waila.handlers;
package mcp.mobius.waila.handlers.tooltip;
import java.util.List;
import mcp.mobius.waila.mod_Waila;
+42 -2
View File
@@ -2,6 +2,7 @@ package mcp.mobius.waila;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import mcp.mobius.waila.addons.ConfigHandler;
@@ -14,6 +15,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.Property;
import codechicken.core.CommonUtils;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.IMCCallback;
@@ -33,7 +35,7 @@ import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.ItemData;
@Mod(modid="Waila", name="Waila", version="1.3.9")
@Mod(modid="Waila", name="Waila", version="1.4.0_dev")
@NetworkMod(channels = {"Waila"},clientSideRequired=false, serverSideRequired=false, connectionHandler = WailaConnectionHandler.class,
packetHandler = WailaPacketHandler.class, versionBounds="[1.3.0,)")
@@ -51,10 +53,37 @@ public class mod_Waila {
public boolean serverPresent = false;
public HashMap<String, String> modSourceList = new HashMap<String, String>();
public static int posX;
public static int posY;
public static int alpha;
public static int bgcolor;
public static int gradient1;
public static int gradient2;
public static int fontcolor;
public static float scale;
@PreInit
public void preInit(FMLPreInitializationEvent event) {
config = new Configuration(event.getSuggestedConfigurationFile());
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SHOW, true);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_MODE, true);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, false);
config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_METADATA, false);
posX = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX, 5000).getInt();
posY = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY, 100).getInt();
alpha = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_ALPHA, 80).getInt();
bgcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_BGCOLOR, 0x100010).getInt();
gradient1 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT1, 0x5000ff).getInt();
gradient2 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT2, 0x28007f).getInt();
fontcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_FONTCOLOR, 0xA0A0A0).getInt();
scale = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_SCALE, 100).getInt() / 100.0f;
config.save();
updateColors();
}
@Init
@@ -77,8 +106,12 @@ public class mod_Waila {
for (ModContainer mod : Loader.instance().getModList()) {
this.modSourceList.put(mod.getSource().getName(), mod.getName());
System.out.printf("%s\n", mod.getSource().getName());
//log.log(Level.INFO, String.format("%s %s", mod.getSource().getName(), mod.getName()));
}
this.modSourceList.put("1.6.2.jar", "Minecraft");
this.modSourceList.put("1.6.3.jar", "Minecraft");
this.modSourceList.put("1.6.4.jar", "Minecraft");
// for (String s : this.modSourceList.keySet())
// if (this.modSourceList.get(s) == "Minecraft Coder Pack")
@@ -155,5 +188,12 @@ public class mod_Waila {
}
}
public static void updateColors(){
alpha = (int)(ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_ALPHA) / 100.0f * 256) << 24;
bgcolor = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_BGCOLOR);
gradient1 = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_GRADIENT1);
gradient2 = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_GRADIENT2);
fontcolor = alpha + ConfigHandler.instance().getConfigInt(Constants.CFG_WAILA_FONTCOLOR);
}
}
@@ -22,32 +22,38 @@ public class WailaPacketHandler implements IPacketHandler {
@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player){
if (packet.channel.equals("Waila")) {
byte header = this.getHeader(packet);
if (header == 0x00){
mod_Waila.log.info("Received server authentication msg. Remote sync will be activated");
mod_Waila.instance.serverPresent = true;
}
else if (header == 0x01){
Packet0x01TERequest castedPacket = new Packet0x01TERequest(packet);
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
TileEntity entity = DimensionManager.getWorld(castedPacket.worldID).getBlockTileEntity(castedPacket.posX, castedPacket.posY, castedPacket.posZ);
//TileEntity entity = server.worldServers[castedPacket.worldID].getBlockTileEntity(castedPacket.posX, castedPacket.posY, castedPacket.posZ);
if (entity != null){
try{
NBTTagCompound tag = new NBTTagCompound();
entity.writeToNBT(tag);
PacketDispatcher.sendPacketToPlayer(Packet0x02TENBTData.create(tag), player);
}catch(Throwable e){
WailaExceptionHandler.handleErr(e, entity.getClass().toString(), null);
}
}
}
else if (header == 0x02){
Packet0x02TENBTData castedPacket = new Packet0x02TENBTData(packet);
DataAccessor.instance.remoteNbt = castedPacket.tag;
}
}
try{
if (packet.channel.equals("Waila")) {
byte header = this.getHeader(packet);
if (header == 0x00){
mod_Waila.log.info("Received server authentication msg. Remote sync will be activated");
mod_Waila.instance.serverPresent = true;
}
else if (header == 0x01){
Packet0x01TERequest castedPacket = new Packet0x01TERequest(packet);
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
TileEntity entity = DimensionManager.getWorld(castedPacket.worldID).getBlockTileEntity(castedPacket.posX, castedPacket.posY, castedPacket.posZ);
//TileEntity entity = server.worldServers[castedPacket.worldID].getBlockTileEntity(castedPacket.posX, castedPacket.posY, castedPacket.posZ);
if (entity != null){
try{
NBTTagCompound tag = new NBTTagCompound();
entity.writeToNBT(tag);
PacketDispatcher.sendPacketToPlayer(Packet0x02TENBTData.create(tag), player);
}catch(Throwable e){
WailaExceptionHandler.handleErr(e, entity.getClass().toString(), null);
}
}
}
else if (header == 0x02){
Packet0x02TENBTData castedPacket = new Packet0x02TENBTData(packet);
DataAccessor.instance.remoteNbt = castedPacket.tag;
}
}
}
catch (Exception e){
return;
}
}
public byte getHeader(Packet250CustomPayload packet){
Loaded 100 of 103 files, more files were not shown because too many files have changed in this diff. Show more