workshopping some stuff atm, doesnt work
This commit is contained in:
		
							parent
							
								
									ce8dd2ebed
								
							
						
					
					
						commit
						48547a2c66
					
				
					 6 changed files with 92 additions and 2 deletions
				
			
		|  | @ -13,6 +13,7 @@ import me.kawaiizenbo.moonlight.module.Module_; | |||
| import me.kawaiizenbo.moonlight.module.settings.BooleanSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.DoubleSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.Setting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.StringSetting; | ||||
| import me.kawaiizenbo.moonlight.ui.clickgui.CategoryPane; | ||||
| import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen; | ||||
| import me.kawaiizenbo.moonlight.util.ColorUtils; | ||||
|  | @ -60,7 +61,10 @@ public class Moonlight implements ModInitializer | |||
|                 else if (s instanceof DoubleSetting) | ||||
|                 { | ||||
|                     ((DoubleSetting)s).value = (Double)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name); | ||||
| 
 | ||||
|                 } | ||||
| 				else if (s instanceof StringSetting) | ||||
|                 { | ||||
|                     ((StringSetting)s).value = (String)((Map<String, Object>)((Map<String, Object>)((Map<String, Object>)CONFIG.config.get("modules")).get(m.name)).get("settings")).get(s.name); | ||||
|                 } | ||||
| 			} | ||||
| 		} | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ package me.kawaiizenbo.moonlight.module; | |||
| import java.util.ArrayList; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.module.settings.BooleanSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.KeycodeSetting; | ||||
| import me.kawaiizenbo.moonlight.module.settings.Setting; | ||||
| import me.kawaiizenbo.moonlight.ui.ModulesListOverlay; | ||||
| import net.minecraft.client.MinecraftClient; | ||||
|  | @ -19,6 +20,7 @@ public abstract class Module_ | |||
|     public ArrayList<Setting> settings; | ||||
|      | ||||
|     public BooleanSetting showInModulesList = new BooleanSetting("Show in Modules List", true); | ||||
|     public KeycodeSetting keybind = new KeycodeSetting("Keybind", 0); | ||||
| 
 | ||||
|     public Module_(String name, String description, Category category) | ||||
|     { | ||||
|  | @ -27,6 +29,7 @@ public abstract class Module_ | |||
|         this.category = category; | ||||
|         settings = new ArrayList<>(); | ||||
|         settings.add(showInModulesList); | ||||
|         settings.add(keybind); | ||||
|     } | ||||
| 
 | ||||
|     public void onEnable() { ModulesListOverlay.INSTANCE.update(); } | ||||
|  |  | |||
|  | @ -7,6 +7,7 @@ import net.minecraft.text.Text; | |||
| 
 | ||||
| public class ColorSetting extends Setting | ||||
| { | ||||
|     // this is unfinished, please use 3 DoubleSettings instead | ||||
|     public int value; | ||||
|     public int r; | ||||
|     public int g; | ||||
|  |  | |||
|  | @ -0,0 +1,40 @@ | |||
| package me.kawaiizenbo.moonlight.module.settings; | ||||
| 
 | ||||
| import me.kawaiizenbo.moonlight.ui.clickgui.KeybindScreen; | ||||
| import net.minecraft.client.MinecraftClient; | ||||
| import net.minecraft.client.font.TextRenderer; | ||||
| import net.minecraft.client.gui.DrawContext; | ||||
| import net.minecraft.text.Text; | ||||
| 
 | ||||
| public class KeycodeSetting extends Setting  | ||||
| { | ||||
|     public int value; | ||||
| 
 | ||||
|     public KeycodeSetting(String name, int value) | ||||
|     { | ||||
|         this.name = name; | ||||
|         this.value = value; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| 	public void mouseClicked(double mouseX, double mouseY, int button)  | ||||
|     { | ||||
| 		if (hovered((int)mouseX, (int)mouseY) && button == 0)  | ||||
|         { | ||||
| 			KeybindScreen kbs = new KeybindScreen(); | ||||
|             MinecraftClient.getInstance().setScreen(kbs); | ||||
|             this.value = kbs.returnedKeycode; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|     @Override | ||||
|     public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY, TextRenderer textRenderer)  | ||||
|     { | ||||
|         super.render(drawContext, x, y, mouseX, mouseY, textRenderer); | ||||
|         drawContext.drawTextWithShadow(textRenderer, Text.literal(name), x+2, y+8, 0xFFFFFF); | ||||
|         String key = java.awt.event.KeyEvent.getKeyText(value); | ||||
|         if (value == 0) key = ""; | ||||
|         int twidth = textRenderer.getWidth(key); | ||||
|         drawContext.drawTextWithShadow(textRenderer, key, x+190-twidth, y+8, 0xFFFFFF); | ||||
|     } | ||||
| } | ||||
|  | @ -2,5 +2,11 @@ package me.kawaiizenbo.moonlight.module.settings; | |||
| 
 | ||||
| public class StringSetting extends Setting | ||||
| { | ||||
|      | ||||
|     public String value; | ||||
| 
 | ||||
|     public StringSetting(String name, String value) | ||||
|     { | ||||
|         this.name = name; | ||||
|         this.value = value; | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -0,0 +1,36 @@ | |||
| package me.kawaiizenbo.moonlight.ui.clickgui; | ||||
| 
 | ||||
| import net.minecraft.client.gui.DrawContext; | ||||
| import net.minecraft.client.gui.screen.Screen; | ||||
| import net.minecraft.text.Text; | ||||
| 
 | ||||
| public class KeybindScreen extends Screen | ||||
| { | ||||
|     public int returnedKeycode = 0; | ||||
| 
 | ||||
|     public KeybindScreen() | ||||
|     { | ||||
|         super(Text.literal("Keybind Selector")); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| 	public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)  | ||||
| 	{ | ||||
| 		this.renderBackground(drawContext, mouseX, mouseY, delta); | ||||
|         drawContext.drawCenteredTextWithShadow(textRenderer, "Press any key", width/2, height/2, 0xFFFFFFFF); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public boolean keyPressed(int keyCode, int scanCode, int modifiers) | ||||
|     { | ||||
|         returnedKeycode = keyCode; | ||||
|         this.close(); | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
| 	public boolean shouldPause()  | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 kawaiizenbo
						kawaiizenbo