Skip to content

Commit a72662a

Browse files
New IME config
1 parent 6e71dad commit a72662a

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

src/main/java/net/minecraftforge/client/ForgeClientHandler.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import com.cleanroommc.client.IMEHandler;
2323
import net.minecraft.client.gui.GuiChat;
24+
import net.minecraft.client.gui.GuiScreen;
2425
import net.minecraft.client.gui.GuiScreenBook;
2526
import net.minecraft.client.gui.inventory.GuiEditSign;
2627
import net.minecraftforge.client.event.ColorHandlerEvent;
@@ -55,20 +56,31 @@ public static void registerItemHandlers(ColorHandlerEvent.Item event)
5556
@SubscribeEvent
5657
public static void didChangeGui(GuiOpenEvent event) {
5758
boolean canInput;
58-
if (event.getGui() == null) {
59+
GuiScreen gui = event.getGui();
60+
if (gui == null) {
5961
// Ignore null GuiScreens
6062
canInput = false;
61-
} else if (event.getGui() instanceof GuiChat) {
63+
} else if (gui instanceof GuiChat) {
6264
// Skip, this should be handled by Focus
6365
return;
6466
} else {
6567
// Vanilla GuiScreens
66-
canInput = event.getGui() instanceof GuiScreenBook
67-
|| event.getGui() instanceof GuiEditSign;
68+
canInput = gui instanceof GuiScreenBook
69+
|| gui instanceof GuiEditSign
70+
|| guiInWhiteList(gui);
6871

69-
// TODO: Force enable map
7072
}
7173

7274
IMEHandler.setIME(canInput);
7375
}
76+
77+
private static boolean guiInWhiteList(GuiScreen gui) {
78+
String current = gui.getClass().getName();
79+
for (String guiClazz : ForgeModContainer.inputMethodGuiWhiteList) {
80+
if (guiClazz.equals(current)) {
81+
return true;
82+
}
83+
}
84+
return false;
85+
}
7486
}

src/main/java/net/minecraftforge/common/ForgeModContainer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
114114
public static boolean disableVersionCheck = false;
115115
public static boolean forgeLightPipelineEnabled = true;
116116
public static boolean selectiveResourceReloadEnabled = false;
117+
public static String[] inputMethodGuiWhiteList = new String[] {""};
117118
@Deprecated // TODO remove in 1.13
118119
public static boolean replaceVanillaBucketModel = true;
119120
public static boolean zoomInMissingModelTextInGui = false;
@@ -370,6 +371,12 @@ private static void syncConfig(boolean load)
370371
prop.setLanguageKey("forge.configgui.selectiveResourceReloadEnabled");
371372
propOrder.add(prop.getName());
372373

374+
prop = config.get(Configuration.CATEGORY_CLIENT, "inputMethodGuiWhiteList", new String[]{},
375+
"A list of modded gui classes considered as input method suitable.");
376+
inputMethodGuiWhiteList = prop.getStringList();
377+
prop.setLanguageKey("forge.configgui.inputMethodGuiWhiteList");
378+
propOrder.add(prop.getName());
379+
373380
var categoryHudId = CATEGORY_CLIENT + Configuration.CATEGORY_SPLITTER + "hud";
374381
var categoryHud = config.getCategory(categoryHudId);
375382
categoryHud.setComment("Controls rendering of various HUD elements");

src/main/resources/assets/forge/lang/en_us.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ forge.configgui.allowEmissiveItems=Allow Emissive Item Rendering
9191
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.
9292
forge.configgui.selectiveResourceReloadEnabled=Enable Selective Resource Loading
9393
forge.configgui.selectiveResourceReloadEnabled.tooltip=When enabled, makes specific reload tasks such as language changing quicker to run.
94+
forge.configgui.inputMethodGuiWhiteList=Input Method Gui White List
95+
forge.configgui.inputMethodGuiWhiteList.tooltip=Classes in this list will be considered as input method suitable and allows input through IME.
9496

9597
forge.configgui.hud.category=HUD Settings
9698
forge.configgui.hud.category.tooltip=Controls rendering of various HUD elements.

src/main/resources/assets/forge/lang/zh_cn.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ forge.configgui.allowEmissiveItems=允许物品渲染发光效果
9191
forge.configgui.allowEmissiveItems.tooltip=允许物品在渲染时检测并正确绘制带发光效果的纹理。启用此选项允许发光的方块的物品形态有和方块类似的发光效果,但会略微影响性能。
9292
forge.configgui.selectiveResourceReloadEnabled=启用选择性资源加载
9393
forge.configgui.selectiveResourceReloadEnabled.tooltip=启用此选项可令某些资源重载过程(例如语言切换)速度更快。
94+
forge.configgui.inputMethodGuiWhiteList=输入法Gui白名单
95+
forge.configgui.inputMethodGuiWhiteList.tooltip=列表中的类会被游戏视作可开启输入法输入。
9496

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

0 commit comments

Comments
 (0)