Skip to content
This repository was archived by the owner on Jan 3, 2020. It is now read-only.

Commit 81e36e1

Browse files
committed
to be continue...
1 parent 70b8245 commit 81e36e1

File tree

12 files changed

+297
-237
lines changed

12 files changed

+297
-237
lines changed

META-INF/MANIFEST.MF

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Manifest-Version: 1.0
2-
FMLCorePlugin: org.devinprogress.inputfix.TransformerLoader
3-
Created-By: 1.7.0 (Oracle Corporation)
2+
FMLCorePlugin: org.devinprogress.YAIF.TransformerLoader
3+
FMLCorePluginContainsFMLMod: true

README.MD

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
## Yet Another InputFix Mod
2-
Using ASM Transformer to hook into Minecraft, hoping to provide a universal solution available anywhere.
2+
Using ASM Transformer to hook into Minecraft, hoping to provide a universal solution to Minecraft IME issue.
33
Forge Required.
44

5-
## Bugs & TODOs
6-
7-
- IBus still not work.
8-
- Make it available for GuiEditSign & GuiEditBook
9-
- Complete the Bridge system
10-
115
## License
126
- GPLv3
137
- **NOT** allowed in ModPacks without my permission.
8+
- USE AT YOUR OWN RISK

src/java/org/devinprogress/inputfix/InputBox.java

-129
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
package org.devinprogress.inputfix;
1+
package org.devinprogress.YAIF.Bridges;
22

33
import net.minecraft.client.gui.GuiScreen;
44
import net.minecraft.client.gui.GuiTextField;
5+
import org.devinprogress.YAIF.InputFieldWrapper;
56

67
import javax.swing.*;
78

@@ -11,34 +12,40 @@
1112
public class CommonBridge implements IActionBridge{
1213
private GuiTextField txt=null;
1314

14-
public CommonBridge(GuiTextField textField,GuiScreen screen,InputFieldWrapper wrapper){
15+
public CommonBridge(GuiTextField textField,InputFieldWrapper wrapper){
1516
txt=textField;
1617
wrapper.DoActions(ActionFeedback.SetText,txt.getText());
1718

1819
}
1920
@Override
20-
public IActionBridge.ActionFeedback onEnter(JTextField txt) {
21-
//System.out.println("[Debug Bridge][onEnter]"+txt.getText());
21+
public IActionBridge.ActionFeedback onEnter(JTextField txt) { //send msg
2222
this.txt.setText(txt.getText());
2323
return IActionBridge.ActionFeedback.Quit;
2424
}
2525

2626
@Override
2727
public IActionBridge.ActionFeedback onEsc(JTextField txt) {
28-
//System.out.println("[Debug Bridge][onEsc]"+txt.getText());
2928
return IActionBridge.ActionFeedback.Quit;
3029
}
3130

3231
@Override
33-
public IActionBridge.ActionFeedback onChanged(JTextField txt) {
34-
//System.out.println("[Debug Bridge][onChange]"+txt.getText());
32+
public IActionBridge.ActionFeedback onChange(JTextField txt) {
3533
this.txt.setText(txt.getText());
3634
return IActionBridge.ActionFeedback.Nothing;
3735
}
3836

3937
@Override
4038
public IActionBridge.ActionFeedback onTab(JTextField txt) {
41-
//System.out.println("[Debug Bridge][onTab]"+txt.getText());
4239
return IActionBridge.ActionFeedback.Nothing;
4340
}
41+
42+
@Override
43+
public ActionFeedback onUp(JTextField txt) {
44+
return null;
45+
}
46+
47+
@Override
48+
public ActionFeedback onDown(JTextField txt) {
49+
return null;
50+
}
4451
}

src/java/org/devinprogress/inputfix/DebugBridge.java src/main/java/org/devinprogress/YAIF/Bridges/DebugBridge.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
package org.devinprogress.inputfix;
1+
package org.devinprogress.YAIF.Bridges;
22

33
import net.minecraft.client.gui.GuiScreen;
44
import net.minecraft.client.gui.GuiTextField;
5+
import org.devinprogress.YAIF.InputFieldWrapper;
56

67
import javax.swing.*;
78

@@ -26,7 +27,7 @@ public ActionFeedback onEsc(JTextField txt) {
2627
}
2728

2829
@Override
29-
public ActionFeedback onChanged(JTextField txt) {
30+
public ActionFeedback onChange(JTextField txt) {
3031
System.out.println("[Debug Bridge][onChange]"+txt.getText());
3132
return ActionFeedback.Nothing;
3233
}
@@ -36,4 +37,14 @@ public ActionFeedback onTab(JTextField txt) {
3637
System.out.println("[Debug Bridge][onTab]"+txt.getText());
3738
return ActionFeedback.Nothing;
3839
}
40+
41+
@Override
42+
public ActionFeedback onUp(JTextField txt) {
43+
return null;
44+
}
45+
46+
@Override
47+
public ActionFeedback onDown(JTextField txt) {
48+
return null;
49+
}
3950
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package org.devinprogress.YAIF.Bridges;
2+
3+
import cpw.mods.fml.client.FMLClientHandler;
4+
import net.minecraft.client.gui.GuiChat;
5+
import net.minecraft.client.gui.GuiTextField;
6+
import org.devinprogress.YAIF.InputFieldWrapper;
7+
import org.devinprogress.YAIF.YetAnotherInputFix;
8+
9+
import javax.swing.*;
10+
import java.lang.reflect.Field;
11+
import java.lang.reflect.Method;
12+
import java.util.logging.Logger;
13+
14+
/**
15+
* Created by recursiveg on 14-9-13.
16+
*/
17+
public class GuiChatBridge implements IActionBridge {
18+
private GuiChat screen=null;
19+
private GuiTextField txt=null;
20+
private InputFieldWrapper wrapper=null;
21+
22+
private static Method keyTypedMethod=null;
23+
24+
public GuiChatBridge(GuiTextField textField,GuiChat screen,InputFieldWrapper wrapper){
25+
this.screen=screen;
26+
txt=textField;
27+
this.wrapper=wrapper;
28+
wrapper.DoActions(ActionFeedback.SetText,txt.getText());
29+
30+
//TODO: use AccessTransformer instead of reflection
31+
if(keyTypedMethod==null){
32+
for(Method m:screen.getClass().getDeclaredMethods()){
33+
if(m.getParameterTypes().length==2&&m.getReturnType()==void.class&&m.getParameterTypes()[0]==char.class&&m.getParameterTypes()[1]==int.class){
34+
//The Method Desc "(CI)V" seem to be unique
35+
keyTypedMethod=m;
36+
keyTypedMethod.setAccessible(true);
37+
}
38+
}
39+
}
40+
}
41+
42+
@Override
43+
public ActionFeedback onEnter(JTextField txt) { //send
44+
this.txt.setText(txt.getText());
45+
/*try {
46+
keyTypedMethod.invoke(screen, '\n', 28);//Magic Numbers can be found at http://minecraft.gamepedia.com/Key_Codes
47+
}catch(Exception e){
48+
e.printStackTrace();
49+
}*/
50+
return ActionFeedback.Quit;
51+
}
52+
53+
@Override
54+
public ActionFeedback onEsc(JTextField txt) {
55+
/*try {
56+
keyTypedMethod.invoke(screen, ' ', 1);
57+
}catch(Exception e){
58+
e.printStackTrace();
59+
}*/
60+
return ActionFeedback.Quit;
61+
}
62+
63+
@Override
64+
public ActionFeedback onChange(JTextField txt) {
65+
this.txt.setText(txt.getText());
66+
return IActionBridge.ActionFeedback.Nothing;
67+
}
68+
69+
@Override
70+
public ActionFeedback onTab(JTextField txt) {
71+
YetAnotherInputFix.logger.info("Tab Completion not finished yet.");
72+
//TODO: Finish it.
73+
return null;//return null == return Nothing
74+
}
75+
76+
@Override
77+
public ActionFeedback onUp(JTextField txt) {
78+
try {
79+
keyTypedMethod.invoke(screen, ' ', 200);
80+
}catch(Exception e){
81+
e.printStackTrace();
82+
}
83+
wrapper.setTextNoEvent(this.txt.getText());
84+
return null;
85+
}
86+
87+
@Override
88+
public ActionFeedback onDown(JTextField txt) {
89+
try {
90+
keyTypedMethod.invoke(screen, ' ', 208);
91+
}catch(Exception e){
92+
e.printStackTrace();
93+
}
94+
wrapper.setTextNoEvent(this.txt.getText());
95+
return null;
96+
}
97+
}

src/java/org/devinprogress/inputfix/IActionBridge.java src/main/java/org/devinprogress/YAIF/Bridges/IActionBridge.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.devinprogress.inputfix;
1+
package org.devinprogress.YAIF.Bridges;
22

33
import javax.swing.*;
44

@@ -13,8 +13,12 @@ enum ActionFeedback{
1313
Quit,
1414
SetText
1515
}
16+
17+
//TODO: Maybe it's a better idea to make wrapper.txtField public?
1618
public ActionFeedback onEnter(final JTextField txt);
1719
public ActionFeedback onEsc(final JTextField txt);
18-
public ActionFeedback onChanged(final JTextField txt);
20+
public ActionFeedback onChange(final JTextField txt);
1921
public ActionFeedback onTab(final JTextField txt);
22+
public ActionFeedback onUp(final JTextField txt);
23+
public ActionFeedback onDown(final JTextField txt);
2024
}

0 commit comments

Comments
 (0)