Skip to content

Commit

Permalink
MekaTool Radial Profiles
Browse files Browse the repository at this point in the history
Rebased, cleaned up, and squashed.
Squashed commits:
MekaTool radial profiles kinda working, more GUI work needed
Added packet to save mekatool profile, save client config, gui fixes
Small changes to the enum
Added profile hud string and removed handle mode key from efficiency module
  • Loading branch information
mewacaser committed May 11, 2022
1 parent 5cf9f6e commit c03dc4c
Show file tree
Hide file tree
Showing 17 changed files with 260 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/api/java/mekanism/api/NBTConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ private NBTConstants() {
public static final String MODE = "mode";
public static final String MODID = "modID";
public static final String MODULES = "modules";
public static final String MODULE_PROFILE = "profile_";
public static final String NAME = "name";
public static final String NUM_POWERING = "numPowering";
public static final String ORIGINAL_LOCATION = "originalLocation";
Expand Down
4 changes: 2 additions & 2 deletions src/datagen/generated/mekanism/.cache/cache
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ f5e3eb6799a15d0b72969547614dfc51dac53419 assets/mekanism/blockstates/tin_ore.jso
8b4570f0148089999c54bb9695f9c94346455c7a assets/mekanism/blockstates/uranium_hexafluoride.json
246c1904e7699b01a3a20f2a2b79b35b5d99aec9 assets/mekanism/blockstates/uranium_ore.json
40c623e2db3159e7355b25f422c719294eca4b64 assets/mekanism/blockstates/uranium_oxide.json
bea6255817af835f4823d936dc933eabc4c7a851 assets/mekanism/lang/en_ud.json
6a09a4d5d34a6a95acbeed71722f670a8d58ffdc assets/mekanism/lang/en_us.json
d954dc7586949a27ee01657221059c9c8488f844 assets/mekanism/lang/en_ud.json
bc7d2534099d173d18880ee2b124420a907bf3f5 assets/mekanism/lang/en_us.json
beea3be5a8af802be66d456a7a648678bede0f02 assets/mekanism/models/block/brine.json
beea3be5a8af802be66d456a7a648678bede0f02 assets/mekanism/models/block/chlorine.json
dcf97575f9590e37cd289a662002e3bc903953a2 assets/mekanism/models/block/deepslate_ore/fluorite.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@
"gui.mekanism.liquid": "%s :p\u1D09nb\u1D09\uA780",
"gui.mekanism.max": "%s :x\u0250W",
"gui.mekanism.max_output": "\u0287/%s :\u0287nd\u0287nO x\u0250W",
"gui.mekanism.mekatool_options": "s\u01DD\uA781\u1D09\u025Fo\u0279\u0500 \uA781oo\u27D8\u0250\u029E\u01DDW",
"gui.mekanism.min": "%s :u\u1D09W",
"gui.mekanism.move_down": "u\u028Do\u15E1 \u01DD\u028CoW",
"gui.mekanism.move_up": "d\u2229 \u01DD\u028CoW",
Expand Down Expand Up @@ -1132,6 +1133,7 @@
"module.mekanism.mode_change": "%2$s :o\u0287 p\u01DDd\u026Fnq %1$s",
"module.mekanism.module_tweaker": "\u0279\u01DD\u029E\u0250\u01DD\u028D\u27D8 \u01DD\uA781npoW",
"module.mekanism.nutritional_injection_unit": "\u0287\u1D09u\u2229 uo\u1D09\u0287\u0254\u01DD\u027EuI \uA781\u0250uo\u1D09\u0287\u1D09\u0279\u0287nN",
"module.mekanism.profile_selected": "%s :\u01DD\uA781\u1D09\u025Fo\u0279\u0500",
"module.mekanism.purification.beneficial": "\uA781\u0250\u1D09\u0254\u1D09\u025F\u01DDu\u01DD\u15FA \u01DD\u028Co\u026F\u01DD\u1D1A",
"module.mekanism.purification.harmful": "\uA781n\u025F\u026F\u0279\u0250H \u01DD\u028Co\u026F\u01DD\u1D1A",
"module.mekanism.purification.neutral": "\uA781\u0250\u0279\u0287n\u01DDN \u01DD\u028Co\u026F\u01DD\u1D1A",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@
"gui.mekanism.liquid": "Liquid: %1$s",
"gui.mekanism.max": "Max: %1$s",
"gui.mekanism.max_output": "Max Output: %1$s/t",
"gui.mekanism.mekatool_options": "MekaTool Profiles",
"gui.mekanism.min": "Min: %1$s",
"gui.mekanism.move_down": "Move Down",
"gui.mekanism.move_up": "Move Up",
Expand Down Expand Up @@ -1132,6 +1133,7 @@
"module.mekanism.mode_change": "%1$s bumped to: %2$s",
"module.mekanism.module_tweaker": "Module Tweaker",
"module.mekanism.nutritional_injection_unit": "Nutritional Injection Unit",
"module.mekanism.profile_selected": "Profile: %1$s",
"module.mekanism.purification.beneficial": "Remove Beneficial",
"module.mekanism.purification.harmful": "Remove Harmful",
"module.mekanism.purification.neutral": "Remove Neutral",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ private void addMisc() {
add(MekanismLang.COLOR_PICKER, "Color Picker");
add(MekanismLang.HELMET_OPTIONS, "Helmet Options");
add(MekanismLang.HUD_OVERLAY, "HUD Overlay:");
add(MekanismLang.MEKATOOL_OPTIONS, "MekaTool Profiles");
add(MekanismLang.OPACITY, "Opacity");
add(MekanismLang.DEFAULT, "Default");
add(MekanismLang.WARNING, "Warning");
Expand Down Expand Up @@ -1251,6 +1252,7 @@ private void addMisc() {
add(MekanismLang.MODULE_HANDLE_MODE_CHANGE, "Handle Mode Key");
add(MekanismLang.MODULE_RENDER_HUD, "Show in HUD");
add(MekanismLang.MODULE_MODE, "Mode");
add(MekanismLang.MODULE_PROFILE_SELECTED, "Profile: %1$s");
add(MekanismLang.MODULE_BONUS_ATTACK_DAMAGE, "Bonus Attack Damage");
add(MekanismLang.MODULE_FARMING_RADIUS, "Farming Radius");
add(MekanismLang.MODULE_JUMP_BOOST, "Jump Boost");
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/mekanism/client/gui/GuiModuleTweaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import mekanism.client.gui.element.slot.GuiSlot;
import mekanism.client.gui.element.slot.SlotType;
import mekanism.client.gui.element.window.GuiMekaSuitHelmetOptions;
import mekanism.client.gui.element.window.GuiMekaToolOptions;
import mekanism.common.MekanismLang;
import mekanism.common.content.gear.Module;
import mekanism.common.inventory.container.ModuleTweakerContainer;
Expand All @@ -19,6 +20,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.lwjgl.glfw.GLFW;

Expand Down Expand Up @@ -64,7 +66,12 @@ private void onModuleSelected(Module<?> module) {
}

private void openOptions() {
addWindow(new GuiMekaSuitHelmetOptions(this, getWidth() / 2 - 140 / 2, getHeight() / 2 - 90 / 2));
Item item = getStack(selected).getItem();
if(item == MekanismItems.MEKASUIT_HELMET.get()) {
addWindow(new GuiMekaSuitHelmetOptions(this, getWidth() / 2 - 140 / 2, getHeight() / 2 - 90 / 2));
} else if(item == MekanismItems.MEKA_TOOL.get()) {
addWindow(new GuiMekaToolOptions(this, getWidth() / 2 - 140 / 2, getHeight() / 2 - 90 / 2, menu.slots.get(selected).getSlotIndex()));
}
}

@Override
Expand Down Expand Up @@ -121,7 +128,7 @@ private void select(int index) {
selected = index;
ItemStack stack = getStack(index);
scrollList.updateList(stack, true);
optionsButton.active = stack.getItem() == MekanismItems.MEKASUIT_HELMET.get();
optionsButton.active = (stack.getItem() == MekanismItems.MEKASUIT_HELMET.get()) || (stack.getItem() == MekanismItems.MEKA_TOOL.get());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ private Runnable getCallback(ModuleConfigData<?> configData, int dataIndex) {
return () -> {
if (currentModule != null) {//Shouldn't be null but validate just in case
Mekanism.packetHandler().sendToServer(PacketUpdateModuleSettings.create(slotIdSupplier.getAsInt(), currentModule.getData(), dataIndex, configData));
// If we want to have it sync changes to current mode from the client we would put it here
// if (currentModule.getContainer().getItem() instanceof ISaveModeItem saveModeItem /* TODO && MekanismConfig.client.mekaModeSync.get() */) {
// Mekanism.packetHandler().sendToServer(new PacketSaveMode(slotIdSupplier.getAsInt(), ItemDataUtils.getInt(currentModule.getContainer(), NBTConstants.MODE)));
// }
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package mekanism.client.gui.element.window;

import com.mojang.blaze3d.vertex.PoseStack;
import mekanism.client.gui.IGuiWrapper;
import mekanism.client.gui.element.button.TranslationButton;
import mekanism.client.gui.element.text.GuiTextField;
import mekanism.common.Mekanism;
import mekanism.common.MekanismLang;
import mekanism.common.config.MekanismConfig;
import mekanism.common.inventory.container.SelectedWindowData.WindowType;
import mekanism.common.item.gear.ItemMekaTool.MekaToolMode;
import mekanism.common.network.to_server.PacketSaveMode;
import mekanism.common.util.text.InputValidator;

public class GuiMekaToolOptions extends GuiWindow {

private static final int HEIGHT = 12;
private static final int WIDTH = 64;

public GuiMekaToolOptions(IGuiWrapper gui, int x, int y, int slotId) {
super(gui, x, y, 140, 115, WindowType.MEKA_TOOL_MODES);
interactionStrategy = InteractionStrategy.NONE;

for (MekaToolMode mode : MekaToolMode.values()) {
GuiTextField profileName = new GuiTextField(gui, relativeX + 7, relativeY + 20 + HEIGHT * mode.ordinal(), WIDTH, HEIGHT);
profileName.setText(MekanismConfig.client.mekaModeNames.get().get(mode.ordinal()));
profileName.setMaxLength(10);
profileName.setInputValidator(InputValidator.LETTER_OR_DIGIT);
profileName.addCheckmarkButton(() -> {
if (!profileName.getText().isBlank()) {
MekanismConfig.client.mekaModeNames.get().set(mode.ordinal(), profileName.getText());
// save the updated config info
MekanismConfig.client.save();
}
});
addChild(profileName);
addChild(new TranslationButton(gui, relativeX + 7 + WIDTH, relativeY + 20 + HEIGHT * mode.ordinal(), 32, HEIGHT,
MekanismLang.BUTTON_SAVE, () -> Mekanism.packetHandler().sendToServer(new PacketSaveMode(slotId, mode.ordinal()))));
}
}

@Override
public void renderForeground(PoseStack matrix, int mouseX, int mouseY) {
super.renderForeground(matrix, mouseX, mouseY);

drawTitleText(matrix, MekanismLang.MEKATOOL_OPTIONS.translate(), 6);
}
}
2 changes: 2 additions & 0 deletions src/main/java/mekanism/common/MekanismLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public enum MekanismLang implements ILangEntry {
COLOR_PICKER("gui", "color_picker"),
RGB("gui", "rgb"),
HELMET_OPTIONS("gui", "helmet_options"),
MEKATOOL_OPTIONS("gui", "mekatool_options"),
HUD_OVERLAY("gui", "hud_overlay"),
OPACITY("gui", "opacity"),
DEFAULT("gui", "default"),
Expand Down Expand Up @@ -765,6 +766,7 @@ public enum MekanismLang implements ILangEntry {
MODULE_HANDLE_MODE_CHANGE("module", "handle_mode_change"),
MODULE_RENDER_HUD("module", "render_hud"),
MODULE_MODE("module", "mode"),
MODULE_PROFILE_SELECTED("module", "profile_selected"),
MODULE_BONUS_ATTACK_DAMAGE("module", "bonus_attack_damage"),
MODULE_FARMING_RADIUS("module", "farming_radius"),
MODULE_JUMP_BOOST("module", "jump_boost"),
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/mekanism/common/config/ClientConfig.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package mekanism.common.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mekanism.common.config.value.CachedBooleanValue;
import mekanism.common.config.value.CachedConfigValue;
import mekanism.common.config.value.CachedEnumValue;
import mekanism.common.config.value.CachedFloatValue;
import mekanism.common.config.value.CachedIntValue;
Expand Down Expand Up @@ -49,6 +52,7 @@ public class ClientConfig extends BaseMekanismConfig {
public final CachedFloatValue hudJitter;
public final CachedBooleanValue hudCompassEnabled;
public final Map<String, CachedWindowPosition> lastWindowPositions = new HashMap<>();
public final CachedConfigValue<List<String>> mekaModeNames;

public final CachedEnumValue<ListSortType> qioItemViewerSortType;
public final CachedEnumValue<SortDirection> qioItemViewerSortDirection;
Expand Down Expand Up @@ -110,6 +114,8 @@ public class ClientConfig extends BaseMekanismConfig {
.defineInRange("hudJitter", 6F, 1F, 100F));
hudCompassEnabled = CachedBooleanValue.wrap(this, builder.comment("Display a fancy compass when the MekaSuit is worn.")
.define("mekaSuitHelmetCompass", true));
mekaModeNames = CachedConfigValue.wrap(this, builder.comment("Meka Tool mode names.")
.define("mekaModeNames", new ArrayList<>(List.of("Mode1", "Mode2", "Mode3", "Mode4", "Mode5", "Mode6"))));
builder.comment("Last Window Positions. In general these values should not be modified manually.").push(GUI_WINDOW_CATEGORY);
for (WindowType windowType : WindowType.values()) {
for (String savePath : windowType.getSavePaths()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public enum WindowType {
CONFIRMATION("confirmation"),
CRAFTING("crafting", IQIOCraftingWindowHolder.MAX_CRAFTING_WINDOWS),
MEKA_SUIT_HELMET("mekaSuitHelmet"),
MEKA_TOOL_MODES("mekaToolModes"),
RENAME("rename"),
SKIN_SELECT("skinSelect"),
SIDE_CONFIG("sideConfig"),
Expand Down
Loading

0 comments on commit c03dc4c

Please sign in to comment.