Skip to content

Commit

Permalink
Caps Lock/한글 상태면 쌍자음으로 입력되던 문제 수정
Browse files Browse the repository at this point in the history
- 모두 소문자로 돌린 다음 shift modifier에 따라서 적절하게 처리
  • Loading branch information
sokcuri committed Jul 19, 2020
1 parent 6b1718c commit 5d94f46
Showing 1 changed file with 42 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,23 @@ boolean onBackspaceKeyPressed(GuiScreenEvent.KeyboardKeyPressedEvent.Pre event)
}

boolean onHangulCharTyped(GuiScreenEvent.KeyboardCharTypedEvent.Pre event) {
boolean shift = (event.getModifiers() & 0x01) == 1;

TextComponentWrapper comp = NaraeUtils.getTextComponent();
if (comp == null) return false;

int codePoint = event.getCodePoint();

if (codePoint >= 65 && codePoint <= 90) {
codePoint += 32;
}

if (codePoint >= 97 && codePoint <= 122) {
if (shift) {
codePoint -= 32;
}
}

int idx = QwertyLayout.getInstance().getLayoutString().indexOf(codePoint);
// System.out.println(String.format("idx: %d", idx));
if (idx == -1) {
Expand Down Expand Up @@ -310,43 +322,44 @@ public void cleanUp() {
}

private void drawCharAssembleBox(TextComponentWrapper comp) {
if (!(comp instanceof TextFieldWidgetWrapper)) {
return;
}
if (comp instanceof TextFieldWidgetWrapper) {
TextFieldWidgetWrapper wrapper = (TextFieldWidgetWrapper) comp;
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;

TextFieldWidgetWrapper wrapper = (TextFieldWidgetWrapper)comp;
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
boolean enableBackgroundDrawing = wrapper.getEnableBackgroundDrawing();
boolean isEnabled = wrapper.isEnabled();
int adjustedWidth = wrapper.getAdjustedWidth();
int cursorPosition = wrapper.getCursorPosition();
int lineScrollOffset = wrapper.getLineScrollOffset();
int selectionEnd = wrapper.getSelectionEnd();

boolean enableBackgroundDrawing = wrapper.getEnableBackgroundDrawing();
boolean isEnabled = wrapper.isEnabled();
int adjustedWidth = wrapper.getAdjustedWidth();
int cursorPosition = wrapper.getCursorPosition();
int lineScrollOffset = wrapper.getLineScrollOffset();
int selectionEnd = wrapper.getSelectionEnd();
int width = wrapper.getWidth();
int height = wrapper.getHeight();

int width = wrapper.getWidth();
int height = wrapper.getHeight();
String trimStr = wrapper.getText().substring(lineScrollOffset);

String trimStr = wrapper.getText().substring(lineScrollOffset);
int x = enableBackgroundDrawing ? wrapper.getX() + 4 : wrapper.getX();
int y = enableBackgroundDrawing ? wrapper.getY() + (height - 8) / 2 : wrapper.getY();
int specifiedOffset = selectionEnd - lineScrollOffset;

int x = enableBackgroundDrawing ? wrapper.getX() + 4 : wrapper.getX();
int y = enableBackgroundDrawing ? wrapper.getY() + (height - 8) / 2 : wrapper.getY();
int specifiedOffset = selectionEnd - lineScrollOffset;
if (!isEnabled || !wrapper.isFocused() || assemblePosition != cursorPosition) {
assemblePosition = -1;
}

if (!isEnabled || !wrapper.isFocused() || assemblePosition != cursorPosition) {
assemblePosition = -1;
if (assemblePosition == -1) return;
if (trimStr.isEmpty()) return;
if (cursorPosition == 0) return;
if (trimStr.length() == 0) return;
if (specifiedOffset == 0 || specifiedOffset - 1 >= trimStr.length()) return;
int startX = x + ObfuscatedMethod.$FontRenderer.getStringWidth.invoke(fontRenderer, trimStr.substring(0, specifiedOffset - 1));
int startY = y - 1;
int endX = x + ObfuscatedMethod.$FontRenderer.getStringWidth.invoke(fontRenderer, trimStr.substring(0, specifiedOffset)) - 1;
int endY = y + 1 + 9;
drawAssembleCharBox(startX, startY, endX, endY, x, width);
} else {
return;
}

if (assemblePosition == -1) return;
if (trimStr.isEmpty()) return;
if (cursorPosition == 0) return;
if (trimStr.length() == 0) return;
if (specifiedOffset == 0 || specifiedOffset - 1 >= trimStr.length()) return;
int startX = x + ObfuscatedMethod.$FontRenderer.getStringWidth.invoke(fontRenderer, trimStr.substring(0, specifiedOffset - 1));
int startY = y - 1;
int endX = x + ObfuscatedMethod.$FontRenderer.getStringWidth.invoke(fontRenderer, trimStr.substring(0, specifiedOffset)) - 1;
int endY = y + 1 + 9;
drawAssembleCharBox(startX, startY, endX, endY, x, width);
}

private void renderEndPhaseTick(TickEvent.RenderTickEvent event) {
Expand Down

0 comments on commit 5d94f46

Please sign in to comment.