Skip to content

Commit

Permalink
Option to color negative coords
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjabrain1 committed Mar 27, 2024
1 parent 9bda62a commit d54fbfc
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public BasicTriangulationPanel(StyleManager styleManager, NinjabrainBotPreferenc
certaintyPanel.setForegroundColor(styleManager.currentTheme.TEXT_COLOR_SLIGHTLY_WEAK);
currentAngleLabel.setForegroundColor(styleManager.currentTheme.TEXT_COLOR_SLIGHTLY_WEAK);
disposeHandler.add(preferences.strongholdDisplayType.whenModified().subscribeEDT(__ -> setResult(currentResult)));
disposeHandler.add(preferences.colorCodeNegativeCoords.whenModified().subscribeEDT(__ -> setResult(currentResult)));
disposeHandler.add(preferences.showAngleErrors.whenModified().subscribeEDT(this::setAngleUpdatesEnabled));
}

Expand Down Expand Up @@ -95,7 +96,7 @@ private void setChunkPrediction(ChunkPrediction prediction) {
mainTextLabel.setText(formatStrongholdCoords(prediction, preferences.strongholdDisplayType.get()));
certaintyPanel.setText(CERTAINTY_TEXT);
certaintyPanel.setColoredText(String.format(Locale.US, "%.1f%%", prediction.chunk.weight * 100.0), (float) prediction.chunk.weight);
netherLabel.setText(I18n.get("nether_coordinates", prediction.chunk.x * 2, prediction.chunk.z * 2, prediction.getNetherDistance()));
netherLabel.setText("<html>" + I18n.get("nether_coordinates", getFormattedCoords(prediction.chunk.x * 2, prediction.chunk.z * 2), prediction.getNetherDistance()) + "</html>");
currentAngleLabel.setText(prediction.formatTravelAngle(true));
currentAngleLabel.setColoredText(prediction.formatTravelAngleDiff(), prediction.getTravelAngleDiffColor());
}
Expand Down Expand Up @@ -127,20 +128,28 @@ public void dispose() {
disposeHandler.dispose();
}

private static String formatStrongholdCoords(ChunkPrediction chunkPrediction, StrongholdDisplayType strongholdDisplayType) {
private String formatStrongholdCoords(ChunkPrediction chunkPrediction, StrongholdDisplayType strongholdDisplayType) {
Chunk chunk = chunkPrediction.chunk;
int distance = chunkPrediction.getOverworldDistance();
switch (strongholdDisplayType) {
case FOURFOUR:
return I18n.get("location_blocks", chunk.fourFourX(), chunk.fourFourZ(), distance);
return "<html>" + I18n.get("location_blocks", getFormattedCoords(chunk.fourFourX(), chunk.fourFourZ()), distance) + "</html>";
case EIGHTEIGHT:
return I18n.get("location_blocks", chunk.eightEightX(), chunk.eightEightZ(), distance);
return "<html>" + I18n.get("location_blocks", getFormattedCoords(chunk.eightEightX(), chunk.eightEightZ()), distance) + "</html>";
case CHUNK:
return I18n.get("chunk_blocks", chunk.x, chunk.z, distance);
return "<html>" + I18n.get("chunk_blocks", getFormattedCoords(chunk.x, chunk.z), distance) + "</html>";
default:
break;
}
return I18n.get("chunk_blocks", chunk.x, chunk.z, distance);
return "<html>" + I18n.get("chunk_blocks", getFormattedCoords(chunk.x, chunk.z), distance) + "</html>";
}

private String getFormattedCoords(int x, int z){
if (preferences.colorCodeNegativeCoords.get()){
String xColor = x < 0 ? styleManager.currentTheme.COLOR_NEGATIVE.hex() : styleManager.currentTheme.TEXT_COLOR_SLIGHTLY_WEAK.hex();
String zColor = z < 0 ? styleManager.currentTheme.COLOR_NEGATIVE.hex() : styleManager.currentTheme.TEXT_COLOR_SLIGHTLY_WEAK.hex();
return String.format(Locale.US, "(<font color='%s'>%d</font>, <font color='%s'>%d</font>)", xColor, x, zColor, z);
}
return String.format(Locale.US, "(%d, %d)", x, z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
public class ChunkPanel extends ThemedPanel implements IDisposable {

private final MultipleChoicePreference<StrongholdDisplayType> strongholdDisplayType;
private final NinjabrainBotPreferences preferences;

private ChunkPrediction currentPrediction;

Expand All @@ -45,6 +46,7 @@ public class ChunkPanel extends ThemedPanel implements IDisposable {

private Subscription chunkPredictionSubscription;
private final Subscription strongholdDisplayTypeChangedSubscription;
private final Subscription colorCodeNegativeCoordsSubscription;

private final WrappedColor borderCol;

Expand All @@ -55,6 +57,7 @@ public ChunkPanel(StyleManager styleManager, NinjabrainBotPreferences preference
public ChunkPanel(StyleManager styleManager, NinjabrainBotPreferences preferences, ChunkPrediction p) {
super(styleManager);
this.styleManager = styleManager;
this.preferences = preferences;
strongholdDisplayType = preferences.strongholdDisplayType;
setOpaque(true);
location = new ThemedLabel(styleManager, true);
Expand All @@ -76,6 +79,7 @@ public ChunkPanel(StyleManager styleManager, NinjabrainBotPreferences preference
setPrediction(p);
setAngleUpdatesEnabled(preferences.showAngleUpdates.get());
strongholdDisplayTypeChangedSubscription = preferences.strongholdDisplayType.whenModified().subscribeEDT(__ -> setPrediction(currentPrediction));
colorCodeNegativeCoordsSubscription = preferences.colorCodeNegativeCoords.whenModified().subscribeEDT(__ -> setPrediction(currentPrediction));

borderCol = styleManager.currentTheme.COLOR_DIVIDER;
setBackgroundColor(styleManager.currentTheme.COLOR_SLIGHTLY_WEAK);
Expand Down Expand Up @@ -148,6 +152,7 @@ public void updateColors() {
super.updateColors();
angle.updateColor();
certainty.updateColors();
setPrediction(currentPrediction);
}

@Override
Expand All @@ -166,30 +171,39 @@ public void dispose() {
if (chunkPredictionSubscription != null)
chunkPredictionSubscription.dispose();
strongholdDisplayTypeChangedSubscription.dispose();
colorCodeNegativeCoordsSubscription.dispose();
}

private void setText(ChunkPrediction chunkPrediction) {
location.setText(formatStrongholdCoords(chunkPrediction.chunk, strongholdDisplayType.get()));
certainty.setText(chunkPrediction.formatCertainty(), (float) chunkPrediction.chunk.weight);
distance.setText(chunkPrediction.formatDistanceInPlayersDimension());
nether.setText(chunkPrediction.formatNether());
nether.setText(getFormattedCoords(chunkPrediction.xInNetherForDisplay(), chunkPrediction.zInNetherForDisplay()));
angle.setText(chunkPrediction.formatTravelAngle(false));
angle.setColoredText(chunkPrediction.formatTravelAngleDiff(), chunkPrediction.getTravelAngleDiffColor());
lastColor = chunkPrediction.chunk.weight;
}

private static String formatStrongholdCoords(Chunk chunk, StrongholdDisplayType strongholdDisplayType) {
private String formatStrongholdCoords(Chunk chunk, StrongholdDisplayType strongholdDisplayType) {
switch (strongholdDisplayType) {
case FOURFOUR:
return String.format(Locale.US, "(%d, %d)", chunk.fourFourX(), chunk.fourFourZ());
return getFormattedCoords(chunk.fourFourX(), chunk.fourFourZ());
case EIGHTEIGHT:
return String.format(Locale.US, "(%d, %d)", chunk.eightEightX(), chunk.eightEightZ());
return getFormattedCoords(chunk.eightEightX(), chunk.eightEightZ());
case CHUNK:
return String.format(Locale.US, "(%d, %d)", chunk.x, chunk.z);
return getFormattedCoords(chunk.x, chunk.z);
default:
break;
}
return String.format(Locale.US, "(%d, %d)", chunk.x, chunk.z);
return getFormattedCoords(chunk.x, chunk.z);
}

private String getFormattedCoords(int x, int z){
if (preferences.colorCodeNegativeCoords.get()){
String xColor = x < 0 ? styleManager.currentTheme.COLOR_NEGATIVE.hex() : styleManager.currentTheme.TEXT_COLOR_SLIGHTLY_WEAK.hex();
String zColor = z < 0 ? styleManager.currentTheme.COLOR_NEGATIVE.hex() : styleManager.currentTheme.TEXT_COLOR_SLIGHTLY_WEAK.hex();
return String.format(Locale.US, "<html>(<font color='%s'>%d</font>, <font color='%s'>%d</font>)</html>", xColor, x, zColor, z);
}
return String.format(Locale.US, "(%d, %d)", x, z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public int getTextSize(SizePreference p) {

column2.add(new DoublePreferencePanel(styleManager, I18n.get("settings.crosshair_correction"), preferences.crosshairCorrection));
column2.add(new CheckboxPanel(styleManager, I18n.get("settings.show_angle_errors"), preferences.showAngleErrors));
column2.add(new CheckboxPanel(styleManager, I18n.get("settings.color_negative_coords"), preferences.colorCodeNegativeCoords));
column2.add(new CheckboxPanel(styleManager, I18n.get("settings.use_advanced_stronghold_statistics"), preferences.useAdvStatistics));
column2.add(new CheckboxPanel(styleManager, I18n.get("settings.use_alternative_clipboard_reader"), preferences.altClipboardReader));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class NinjabrainBotPreferences {
public final BooleanPreference useAdvStatistics;
public final BooleanPreference altClipboardReader;
public final BooleanPreference useAltStd;
public final BooleanPreference colorCodeNegativeCoords;
public final BooleanPreference useTallRes;
public final BooleanPreference usePreciseAngle;
public final BooleanPreference useOverlay;
Expand Down Expand Up @@ -111,6 +112,7 @@ public NinjabrainBotPreferences(IPreferenceSource source) {
useAdvStatistics = new BooleanPreference("use_adv_statistics", true, source);
altClipboardReader = new BooleanPreference("alt_clipboard_reader", false, source);
useAltStd = new BooleanPreference("use_alt_std", false, source);
colorCodeNegativeCoords = new BooleanPreference("color_negative_coords", false, source);
useTallRes = new BooleanPreference("use_tall_res", false, source);
usePreciseAngle = new BooleanPreference("use_precise_angle", false, source);
useOverlay = new BooleanPreference("use_obs_overlay", false, source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ public String formatDistanceInPlayersDimension() {
return String.format(Locale.US, "%d", playerIsInNether ? getNetherDistance() : overworldDistance);
}

public String formatNether() {
return String.format(Locale.US, "(%d, %d)", (int) Math.floor(x / 8.0), (int) Math.floor(z / 8.0));
}

public String formatTravelAngle(boolean forBasic) {
if (forBasic) {
return String.format("%s: %.2f", I18n.get("current_angle"), travelAngle);
Expand Down Expand Up @@ -98,6 +94,14 @@ public double zInNether() {
return zInOverworld() / 8.0;
}

public int xInNetherForDisplay(){
return (int) Math.floor(x / 8.0);
}

public int zInNetherForDisplay(){
return (int) Math.floor(z / 8.0);
}

public int getOverworldDistance() {
return overworldDistance;
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/lang/I18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ settings.alt_standard_deviation=Alt. standard deviation:
settings.alt_std_on_last_angle=Alt. std on last angle:
settings.crosshair_correction=Crosshair correction:
settings.show_angle_errors=Show angle errors
settings.color_negative_coords=Display negative coords in a different color
settings.use_advanced_stronghold_statistics=Use advanced stronghold statistics
settings.use_alternative_clipboard_reader=Use alternative clipboard reader
settings.tall_resolution=Tall resolution
Expand Down Expand Up @@ -117,11 +118,11 @@ notificationsframe.new_version_available=New version available!
notificationsframe.download_button=Download .jar
notificationsframe.changelog_button=Open changelog (in browser)
notificationsframe.update_text=Version %s is available. After downloading the new jar you can delete this jar (your settings will automatically transfer). This notification can be disabled in the settings menu.
location_blocks=Location: (%d, %d), %d blocks away
chunk_blocks=Chunk: (%d, %d), %d blocks away
location_blocks=Location: %s, %d blocks away
chunk_blocks=Chunk: %s, %d blocks away
certainty=Certainty:
current_angle=Current angle
nether_coordinates=Nether coords: (%d, %d), %d blocks away
nether_coordinates=Nether coords: %s, %d blocks away
could_not_determine=Could not determine the stronghold chunk.
you_probably_misread=You probably misread one of the eyes.
blind_coords=Blind coords (%.0f, %.0f) are
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/lang/I18n_cs_CZ.properties
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ notificationsframe.new_version_available=Je dostupná nová verze!
notificationsframe.download_button=Stáhnou .jar
notificationsframe.changelog_button=Otevřít changelog v prohlížeči
notificationsframe.update_text=Verze %s je k dispozici. Po stažení nového .jar můžeš tento .jar smazat (tvoje nastavení se automaticky převedou). Toto oznámení můžeš vypnout v nastavení.
location_blocks=Umístění: (%d, %d), %d bloků daleko
chunk_blocks=Chunk: (%d, %d), %d bloků daleko
location_blocks=Umístění: %s, %d bloků daleko
chunk_blocks=Chunk: %s, %d bloků daleko
certainty=Jistota:
current_angle=Aktuální úhel
nether_coordinates=Netherové souřadnice: (%d, %d), %d bloků daleko
nether_coordinates=Netherové souřadnice: %s, %d bloků daleko
could_not_determine=Chunk strongholdu nebylo možno určit.
you_probably_misread=Nejšpíš jsi chybně změřil(a) jedno z očí.
blind_coords=Souřačnice pro blind (%.0f, %.0f) jsou
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/lang/I18n_es_ES.properties
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ notificationsframe.new_version_available=¡Nueva versión disponible!
notificationsframe.download_button=Descargar .jar
notificationsframe.changelog_button=Abrir registro de cambios (en el navegador)
notificationsframe.update_text=Versión %s está disponible. Después de descargar el nuevo jar, puedes eliminar este jar (tu configuración se transferirá automáticamente). Esta notificación se puede desactivar en el menú de configuración.
location_blocks=Posición: (%d, %d), %d bloques de distancia
chunk_blocks=Chunk: (%d, %d), %d bloques de distancia
location_blocks=Posición: %s, %d bloques de distancia
chunk_blocks=Chunk: %s, %d bloques de distancia
certainty=Certeza:
current_angle=Ángulo actual
nether_coordinates=Coordenadas Nether: (%d, %d), %d bloques de distancia
nether_coordinates=Coordenadas Nether: %s, %d bloques de distancia
could_not_determine=No se pudo determinar el chunk del stronghold.
you_probably_misread=Probablemente leíste mal uno de los ojos.
blind_coords=Coordenadas del blind (%.0f, %.0f) son
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/lang/I18n_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ notificationsframe.new_version_available=Nouvelle version disponible !
notificationsframe.download_button=Télécharger le .jar
notificationsframe.changelog_button=Ouvrir le journal de modifications (dans le navigateur)
notificationsframe.update_text=La version %s est disponible. Après avoir téléchargé le nouveau .jar, vous pouvez supprimer ce .jar (vos paramètres seront automatiquement sauvegardés). Cette notification peut être désactivée dans les paramètres.
location_blocks=Emplacement: (%d, %d), à %d blocs
chunk_blocks=Chunk: (%d, %d), à %d blocs
location_blocks=Emplacement: %s, à %d blocs
chunk_blocks=Chunk: %s, à %d blocs
certainty=Certitude:
current_angle=Angle actuel
nether_coordinates=Coordonnées du nether: (%d, %d), à %d blocs
nether_coordinates=Coordonnées du nether: %s, à %d blocs
could_not_determine=Le chunk du stronghold n'a pas pu être déterminé.
you_probably_misread=Vous avez probablement mal calculé l'un des yeux.
blind_coords=Les coordonnées de blind (%.0f, %.0f) sont
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/lang/I18n_it_IT.properties
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ notificationsframe.new_version_available=Nuova versione disponibile!
notificationsframe.download_button=Scarica .jar
notificationsframe.changelog_button=Apri changelog (in browser)
notificationsframe.update_text=Versione %s è disponibile. Dopo aver scaricato il nuovo jar puoi cancellare questo jar (le tue impostazioni saranno automaticamente trasferiti). Questa notifica può essere disabilitata nelle impostazioni.
location_blocks=Posizione: (%d, %d), %d blocchi
chunk_blocks=Chunk: (%d, %d), %d blocchi
location_blocks=Posizione: %s, %d blocchi
chunk_blocks=Chunk: %s, %d blocchi
certainty=Certezza:
current_angle=Angolo attuale
nether_coordinates=Coordinate Nether: (%d, %d), %d blocchi
nether_coordinates=Coordinate Nether: %s, %d blocchi
could_not_determine=Non è stato possibile determinare il chunk dello stronghold.
you_probably_misread=Hai probabilmente letto male uno degli occhi.
blind_coords=Coordinate blind (%.0f, %.0f) sono
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/lang/I18n_ja_JP.properties
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ notificationsframe.new_version_available=新しいバージョンが利用可能
notificationsframe.download_button=.jarをダウンロード
notificationsframe.changelog_button=変更ログを開く (ブラウザで)
notificationsframe.update_text=バージョン %s が利用可能です。 新しい jar をダウンロードした後、この jar を削除できます (設定は自動的に転送されます)。 この通知は、設定メニューで無効にすることができます。
location_blocks=場所: (%d, %d), %d ブロック先
chunk_blocks=チャンク: (%d, %d), %d ブロック先
location_blocks=場所: %s, %d ブロック先
chunk_blocks=チャンク: %s, %d ブロック先
certainty=確実:
current_angle=現在の角度
nether_coordinates=ネザー座標: (%d, %d), %d ブロック先
nether_coordinates=ネザー座標: %s, %d ブロック先
could_not_determine=拠点チャンクを特定できませんでした。
you_probably_misread=片方の目を読み違えたのでしょう。
blind_coords=ブラインド座標 (%.0f、%.0f) are
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/lang/I18n_ja_Ryukyuan.properties
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ notificationsframe.new_version_available=みーさるバージョンぬ利用可
notificationsframe.download_button=.jarダウンロード
notificationsframe.changelog_button=変更ログふぃらちゅん (ブラウザっし)
notificationsframe.update_text=バージョン %s やしが利用可能やいびーん。 みーさん jar ダウンロードさる後、くぬ jar 削除なやびーん (設定ー自動的に転送さりやびーん)。 くぬ通知ー、設定メニューっし無効なするくとぅがなやびーん。
location_blocks=ばす: (%d, %d), %d ブロック先
chunk_blocks=チャンク: (%d, %d), %d ブロック先
location_blocks=ばす: %s, %d ブロック先
chunk_blocks=チャンク: %s, %d ブロック先
certainty=確実:
current_angle=現在ぬ角度
nether_coordinates=ネザー座標: (%d, %d), %d ブロック先
nether_coordinates=ネザー座標: %s, %d ブロック先
could_not_determine=拠点チャンク特定なやびらんたん。
you_probably_misread=かたぐーぬみーゆみたげーたるぬやるはじ。
blind_coords=ブラインド座標 (%.0f、%.0f) are
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/lang/I18n_ko_KR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ notificationsframe.new_version_available=새로운 버전이 발견되었습니
notificationsframe.download_button=.jar 다운로드
notificationsframe.changelog_button=체인지로그 열기 (브라우저에서)
notificationsframe.update_text=새로운 버전%s 이 발견되었습니다. 새 .jar 파일을 다운로드한 후 이 .jar 파일을 삭제하세요(설정은 그대로 보존됨). 이 알림은 설정 메뉴에서 비활성화할 수 있습니다.
location_blocks=위치: (%d, %d), %d 블럭만큼 떨어짐
chunk_blocks=청크: (%d, %d), %d 블럭만큼 떨어짐
location_blocks=위치: %s, %d 블럭만큼 떨어짐
chunk_blocks=청크: %s, %d 블럭만큼 떨어짐
certainty=정확도:
current_angle=현재 각도
nether_coordinates=네더 좌표: (%d, %d), %d 블럭만큼 떨어짐
nether_coordinates=네더 좌표: %s, %d 블럭만큼 떨어짐
could_not_determine=엔더유적 청크를 계산할 수 없습니다.
you_probably_misread=한 엔더의 눈을 잘못 읽었을 수 있습니다.
blind_coords=블라인드 좌표(%.0f, %.0f)가
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/lang/I18n_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ notificationsframe.new_version_available=Nova versão disponível!
notificationsframe.download_button=Download .jar
notificationsframe.changelog_button=Abrir alterações (no navegador)
notificationsframe.update_text=A versão %s está disponível. Depois de baixar o novo jar, você pode excluí-lo (suas configurações serão transferidas automaticamente). Esta notificação pode ser desativada no menu de configurações.
location_blocks=Localização: (%d, %d), %d blocos
chunk_blocks=Chunk: (%d, %d), %d blocos
location_blocks=Localização: %s, %d blocos
chunk_blocks=Chunk: %s, %d blocos
certainty=Certeza:
current_angle=Ânguloa atual
nether_coordinates=Coord Nether: (%d, %d), %d blocos
nether_coordinates=Coord Nether: %s, %d blocos
could_not_determine=Não foi possível determinar a chuck da stronghold.
you_probably_misread=Você provavelmente errou um dos olhos.
blind_coords=Coord do blind (%.0f, %.0f) estão
Expand Down
Loading

0 comments on commit d54fbfc

Please sign in to comment.