Skip to content

Commit

Permalink
New IME config
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer committed Dec 20, 2024
1 parent 6e71dad commit a72662a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/main/java/net/minecraftforge/client/ForgeClientHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.cleanroommc.client.IMEHandler;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiScreenBook;
import net.minecraft.client.gui.inventory.GuiEditSign;
import net.minecraftforge.client.event.ColorHandlerEvent;
Expand Down Expand Up @@ -55,20 +56,31 @@ public static void registerItemHandlers(ColorHandlerEvent.Item event)
@SubscribeEvent
public static void didChangeGui(GuiOpenEvent event) {
boolean canInput;
if (event.getGui() == null) {
GuiScreen gui = event.getGui();
if (gui == null) {
// Ignore null GuiScreens
canInput = false;
} else if (event.getGui() instanceof GuiChat) {
} else if (gui instanceof GuiChat) {
// Skip, this should be handled by Focus
return;
} else {
// Vanilla GuiScreens
canInput = event.getGui() instanceof GuiScreenBook
|| event.getGui() instanceof GuiEditSign;
canInput = gui instanceof GuiScreenBook
|| gui instanceof GuiEditSign
|| guiInWhiteList(gui);

// TODO: Force enable map
}

IMEHandler.setIME(canInput);
}

private static boolean guiInWhiteList(GuiScreen gui) {
String current = gui.getClass().getName();
for (String guiClazz : ForgeModContainer.inputMethodGuiWhiteList) {
if (guiClazz.equals(current)) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
public static boolean disableVersionCheck = false;
public static boolean forgeLightPipelineEnabled = true;
public static boolean selectiveResourceReloadEnabled = false;
public static String[] inputMethodGuiWhiteList = new String[] {""};
@Deprecated // TODO remove in 1.13
public static boolean replaceVanillaBucketModel = true;
public static boolean zoomInMissingModelTextInGui = false;
Expand Down Expand Up @@ -370,6 +371,12 @@ private static void syncConfig(boolean load)
prop.setLanguageKey("forge.configgui.selectiveResourceReloadEnabled");
propOrder.add(prop.getName());

prop = config.get(Configuration.CATEGORY_CLIENT, "inputMethodGuiWhiteList", new String[]{},
"A list of modded gui classes considered as input method suitable.");
inputMethodGuiWhiteList = prop.getStringList();
prop.setLanguageKey("forge.configgui.inputMethodGuiWhiteList");
propOrder.add(prop.getName());

var categoryHudId = CATEGORY_CLIENT + Configuration.CATEGORY_SPLITTER + "hud";
var categoryHud = config.getCategory(categoryHudId);
categoryHud.setComment("Controls rendering of various HUD elements");
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/forge/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ forge.configgui.allowEmissiveItems=Allow Emissive Item Rendering
forge.configgui.allowEmissiveItems.tooltip=Allow item rendering to detect emissive quads and draw them properly. This allows glowing blocks to look the same in item form, but incurs a very slight performance hit.
forge.configgui.selectiveResourceReloadEnabled=Enable Selective Resource Loading
forge.configgui.selectiveResourceReloadEnabled.tooltip=When enabled, makes specific reload tasks such as language changing quicker to run.
forge.configgui.inputMethodGuiWhiteList=Input Method Gui White List
forge.configgui.inputMethodGuiWhiteList.tooltip=Classes in this list will be considered as input method suitable and allows input through IME.

forge.configgui.hud.category=HUD Settings
forge.configgui.hud.category.tooltip=Controls rendering of various HUD elements.
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/forge/lang/zh_cn.lang
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ forge.configgui.allowEmissiveItems=允许物品渲染发光效果
forge.configgui.allowEmissiveItems.tooltip=允许物品在渲染时检测并正确绘制带发光效果的纹理。启用此选项允许发光的方块的物品形态有和方块类似的发光效果,但会略微影响性能。
forge.configgui.selectiveResourceReloadEnabled=启用选择性资源加载
forge.configgui.selectiveResourceReloadEnabled.tooltip=启用此选项可令某些资源重载过程(例如语言切换)速度更快。
forge.configgui.inputMethodGuiWhiteList=输入法Gui白名单
forge.configgui.inputMethodGuiWhiteList.tooltip=列表中的类会被游戏视作可开启输入法输入。

forge.configgui.modID.tooltip=你想要定义设置覆盖的Mod ID。
forge.configgui.modID=Mod ID
Expand Down

0 comments on commit a72662a

Please sign in to comment.