Skip to content

Commit

Permalink
폰트 설정 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sokcuri committed Sep 10, 2019
1 parent 9f049a3 commit c59de4b
Show file tree
Hide file tree
Showing 64 changed files with 8,110 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.6.0
폰트 변경기능 추가

## 0.5.0
옵티파인 1.14.4_HD_U_F4_pre3 호환
- 옵티파인과 함께 쓸 때 한글 채팅이 정상 작동하지 않는 문제 수정
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* [홈페이지](https://github.com/sokcuri/NaraeChat)
* [다운로드](https://github.com/sokcuri/NaraeChat/releases)
* [업데이트 기록](CHANGELOG.md)
* 버전: 1.14.4-0.5.0 (2019-08-29)
* 버전: 1.14.4-0.6.0 (2019-09-10)
* 마인크래프트 : 1.14.4
* 포지 : 1.14.4-28.0.55
* [라이센스 : LGPL 3.0](LICENSE.txt)
Expand All @@ -16,13 +16,14 @@
* 한영 키로 한글/영어 전환 가능
* 한글 상태에서도 모든 키를 조작 가능
* 자판 상태 인디케이터 기능
* 폰트 변경 기능

## 옵션
* 인 게임 키 설정 란에서 한글/영어 전환 키를 변경할 수 있습니다
* 폰트 변경은 마인크래프트 옵션 > 언어 > 폰트에서 변경 가능합니다

## 미구현 기능
* 세벌식 키보드 자판
* 상세한 설정 창
* 한자 키 기능

## 설치 방법
Expand Down
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ apply plugin: 'eclipse'
apply plugin: 'maven-publish'

compileJava.options.encoding = 'UTF-8'
version = '1.14.4-0.5.0'
version = '1.14.4-0.6.0'
group = 'kr.neko.sokcuri.naraechat' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'naraechat'

Expand Down Expand Up @@ -85,7 +85,6 @@ minecraft {
}
}
}

dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
Expand All @@ -94,6 +93,7 @@ dependencies {
compile 'net.java.dev.jna:jna:4.1.0'
compile 'net.java.dev.jna:jna-platform:4.1.0'
compile 'org.apache.commons:commons-text:1.7'
compile 'org.apache.pdfbox:fontbox:2.0.2'

// You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier"
Expand All @@ -114,7 +114,6 @@ dependencies {
// http://www.gradle.org/docs/current/userguide/dependency_management.html

}

// Example for how to get properties into the manifest for reading by the runtime..
jar {
manifest {
Expand All @@ -129,7 +128,6 @@ jar {
])
}
}

// Example configuration to allow publishing using the maven-publish task
// we define a custom artifact that is sourced from the reobfJar output task
// and then declare that to be published
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package kr.neko.sokcuri.naraechat.Config;

import kr.neko.sokcuri.naraechat.Config.ConfigHelper;
import kr.neko.sokcuri.naraechat.Fonts.FontManager;
import net.minecraft.client.settings.AbstractOption;
import net.minecraft.client.settings.SliderPercentageOption;

public abstract class AbstractNaraeOption extends AbstractOption {
public AbstractNaraeOption(String translationKeyIn) {
super(translationKeyIn);
}

public static final SliderPercentageOption FONT_SIZE = new SliderPercentageOption("options.naraechat.fontsize", 8.0D, 15.0D, 1.0F, (gameSettings) -> {
return (double) FontManager.instance.fontSize;
}, (gameSettings, value) -> {
FontManager.instance.fontSize = value.floatValue();
ConfigHelper.setFontSize(value.floatValue());
}, (gameSettings, sliderPercentageOption) -> {
double d0 = sliderPercentageOption.get(gameSettings);
return "Font Size: " + String.format("%.0f", d0) + "pt";
});

public static final SliderPercentageOption OVER_SAMPLE = new SliderPercentageOption("options.naraechat.oversample", 0.0D, 8.0D, 0.1F, (gameSettings) -> {
return (double) FontManager.instance.overSample;
}, (gameSettings, value) -> {
FontManager.instance.overSample = value.floatValue();
ConfigHelper.setOversample(value.floatValue());
}, (gameSettings, sliderPercentageOption) -> {
double d0 = sliderPercentageOption.get(gameSettings);
return "Over Sample : " + String.format("%.1f", d0) + "pt";
});

public static final SliderPercentageOption SHIFT_X = new SliderPercentageOption("options.naraechat.shiftx", -5.0D, 5.0D, 0.1F, (gameSettings) -> {
return (double) FontManager.instance.shiftX;
}, (gameSettings, value) -> {
FontManager.instance.shiftX = value.floatValue();
ConfigHelper.setShiftX(value.floatValue());
}, (gameSettings, sliderPercentageOption) -> {
double d0 = sliderPercentageOption.get(gameSettings);
return "ShiftX : " + String.format("%.1f", d0) + "px";
});

public static final SliderPercentageOption SHIFT_Y = new SliderPercentageOption("options.naraechat.shifty", -5.0D, 5.0D, 0.1F, (gameSettings) -> {
return (double) FontManager.instance.shiftY;
}, (gameSettings, value) -> {
FontManager.instance.shiftY = value.floatValue();
ConfigHelper.setShiftY(value.floatValue());
}, (gameSettings, sliderPercentageOption) -> {
double d0 = sliderPercentageOption.get(gameSettings);
return "ShiftY : " + String.format("%.1f", d0) + "px";
});
}
111 changes: 111 additions & 0 deletions src/main/java/kr/neko/sokcuri/naraechat/Config/ConfigHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package kr.neko.sokcuri.naraechat.Config;

import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.config.ModConfig;
import org.ini4j.Wini;

import java.io.File;
import java.io.IOException;

public final class ConfigHelper {
private static Wini ini;

static {
try {
File file = new File("naraechat.ini");
if(!file.exists())
{
file.createNewFile();
setFontFamily("맑은 고딕");
setFontSize(12.0f);
setOversample(4.0f);
setShiftX(-0.3f);
setShiftY(0.3f);
}
ini = new Wini(file);
} catch (IOException e) {
e.printStackTrace();
}
}

public static ModConfig clientConfig;

public static void bakeClient(final ModConfig config) {
clientConfig = config;
}

public static String getFontFamily() {
String fontFamily = ini.get("font", "fontfamily", String.class);
return fontFamily;
}

public static void setFontFamily(final String value) {
ini.put("font", "fontfamily", value);
try {
ini.store();
} catch (IOException e) {
e.printStackTrace();
}
}

public static float getFontSize() {
float size = ini.get("font", "fontsize", float.class);
if (size == 0) size = 12.0f;
return size;
}

public static void setFontSize(final float value) {
ini.put("font", "fontsize", value);
try {
ini.store();
} catch (IOException e) {
e.printStackTrace();
}
}

public static float getOversample() {
float oversample = ini.get("font", "oversample", float.class);
if (oversample == 0) oversample = 4.0f;
return oversample;
}

public static void setOversample(final float value) {
ini.put("font", "oversample", value);
try {
ini.store();
} catch (IOException e) {
e.printStackTrace();
}
}

public static float getShiftX() {
return ini.get("font", "shiftx", float.class);
}

public static void setShiftX(final float value) {
ini.put("font", "shiftx", value);
try {
ini.store();
} catch (IOException e) {
e.printStackTrace();
}
}

public static float getShiftY() {
return ini.get("font", "shifty", float.class);
}

public static void setShiftY(final float value) {
ini.put("font", "shifty", value);
try {
ini.store();
} catch (IOException e) {
e.printStackTrace();
}
}

public static void setValueAndSave(final ModConfig modConfig, final String path, final Object newValue) {
modConfig.getConfigData().set(path, newValue);
modConfig.save();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package kr.neko.sokcuri.naraechat.Config;

import kr.neko.sokcuri.naraechat.Fonts.NaraeFontSettings;
import net.minecraft.client.GameSettings;
import net.minecraft.client.gui.screen.LanguageScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.widget.button.OptionButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.LanguageManager;

public class LanguageScreenOverride extends LanguageScreen {
private final Screen parentScreen;
private final GameSettings game_settings_3;
private final LanguageManager languageManager;

public LanguageScreenOverride(Screen screen, GameSettings gameSettingsObj, LanguageManager manager) {
super(screen, gameSettingsObj, manager);

this.parentScreen = screen;
this.game_settings_3 = gameSettingsObj;
this.languageManager = manager;
}

@Override
protected void init() {
super.init();

Widget fontConfBtn = new Button(this.width / 2 - 155, this.height - 38, 150, 20, I18n.format("options.naraechat.font"), (p_213037_1_) -> {
NaraeFontSettings.scrollbarPosition = 0.0f;
this.minecraft.displayGuiScreen(new NaraeFontSettings(this, this.game_settings_3, languageManager));
});

for (Widget button : this.buttons) {
if (button instanceof OptionButton) {
this.buttons.add(this.buttons.indexOf(button), fontConfBtn);
this.children.add(this.children.indexOf(button), fontConfBtn);
this.buttons.remove(button);
this.children.remove(button);
break;
}
}
}

@Override
public void render(int p_render_1_, int p_render_2_, float p_render_3_) {
super.render(p_render_1_, p_render_2_, p_render_3_);
}
}
Loading

0 comments on commit c59de4b

Please sign in to comment.