mirror of
https://github.com/TheEntropyShard/JDarkroom.git
synced 2024-11-23 13:26:20 +03:00
Changed way of getting time
This commit is contained in:
parent
bbd3dfe47e
commit
995dcd8969
2 changed files with 18 additions and 13 deletions
|
@ -36,6 +36,12 @@ public enum Decoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = (bytes[15] >> 3) & 0b111;
|
int index = (bytes[15] >> 3) & 0b111;
|
||||||
|
/*int index = 0;
|
||||||
|
|
||||||
|
String num = Integer.toBinaryString(bytes[15]);
|
||||||
|
if(num.length() <= 3) num += "000000";
|
||||||
|
System.out.println(num);
|
||||||
|
index = Integer.parseInt(num.substring(0, 4), 2) & 0b111;*/
|
||||||
|
|
||||||
byte firstRoundKey = DecodingData.KEY[index];
|
byte firstRoundKey = DecodingData.KEY[index];
|
||||||
byte secondRoundKey = DecodingData.KEY[DecodingData.KEY.length - 1 - index];
|
byte secondRoundKey = DecodingData.KEY[DecodingData.KEY.length - 1 - index];
|
||||||
|
@ -63,14 +69,7 @@ public enum Decoder {
|
||||||
bytes[byteInd] ^= (1 << bitInd);
|
bytes[byteInd] ^= (1 << bitInd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Decoder.getGameInfo(bytes);
|
return Decoder.readCode(bytes) + "_" + Decoder.readTotalPlaytime(bytes);
|
||||||
}
|
|
||||||
|
|
||||||
public static String getGameInfo(byte[] bytes) {
|
|
||||||
String resultLabel = I18N.getString("resultLabel");
|
|
||||||
String[] internetCodes = Decoder.readCode(bytes).split("_");
|
|
||||||
String totalPlaytime = Decoder.readTotalPlaytime(bytes);
|
|
||||||
return String.format(resultLabel, internetCodes[0], internetCodes[1], totalPlaytime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String readCode(byte[] bytes) {
|
public static String readCode(byte[] bytes) {
|
||||||
|
@ -100,8 +99,12 @@ public enum Decoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String readTotalPlaytime(byte[] bytes) {
|
public static String readTotalPlaytime(byte[] bytes) {
|
||||||
return (bytes[14] < 10 ? "0" + bytes[14] : "" + bytes[14]) + ":" +
|
int time = ((bytes[14] * 60 + bytes[13]) * 60 + bytes[15]);
|
||||||
(bytes[13] < 10 ? "0" + bytes[13] : "" + bytes[13]) + ":" +
|
int h = (int) Math.floor(time / 3600.0f);
|
||||||
(bytes[15] < 10 ? "0" + bytes[15] : "" + bytes[15]);
|
int m = (int) Math.floor(time % 3600 / 60.0f);
|
||||||
|
int s = (int) Math.floor(time % 3600 % 60);
|
||||||
|
return (h < 10 ? "0" + h : "" + h) + ":" +
|
||||||
|
(m < 10 ? "0" + m : "" + m) + ":" +
|
||||||
|
(s < 10 ? "0" + s : "" + s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ public final class View extends JPanel {
|
||||||
|
|
||||||
private final JLabel resultLabel;
|
private final JLabel resultLabel;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public View() {
|
public View() {
|
||||||
this.setPreferredSize(new Dimension(View.WIDTH, View.HEIGHT));
|
this.setPreferredSize(new Dimension(View.WIDTH, View.HEIGHT));
|
||||||
|
|
||||||
|
@ -87,6 +86,7 @@ public final class View extends JPanel {
|
||||||
public synchronized void drop(DropTargetDropEvent dtde) {
|
public synchronized void drop(DropTargetDropEvent dtde) {
|
||||||
dtde.acceptDrop(DnDConstants.ACTION_COPY);
|
dtde.acceptDrop(DnDConstants.ACTION_COPY);
|
||||||
try {
|
try {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
List<File> droppedFiles = (List<File>)
|
List<File> droppedFiles = (List<File>)
|
||||||
dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
|
dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
|
||||||
String code = SaveFileReader.findInSave(droppedFiles.get(0));
|
String code = SaveFileReader.findInSave(droppedFiles.get(0));
|
||||||
|
@ -152,7 +152,9 @@ public final class View extends JPanel {
|
||||||
if(text.length() != 16) {
|
if(text.length() != 16) {
|
||||||
resultLabel.setText(I18N.getString("incorrectCodeLength"));
|
resultLabel.setText(I18N.getString("incorrectCodeLength"));
|
||||||
} else {
|
} else {
|
||||||
resultLabel.setText(Decoder.decodeInternetCode(text));
|
String rl = I18N.getString("resultLabel");
|
||||||
|
String[] data = Decoder.decodeInternetCode(text).split("_");
|
||||||
|
resultLabel.setText(String.format(rl, data[0], data[1], data[2]));
|
||||||
}
|
}
|
||||||
cardLayout.show(View.this, "resultPanel");
|
cardLayout.show(View.this, "resultPanel");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue