v1.4.0: added date and version to rankings pages
This commit is contained in:
@@ -44,11 +44,16 @@ import com.watabou.utils.Bundle;
|
|||||||
import com.watabou.utils.FileUtils;
|
import com.watabou.utils.FileUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public enum Rankings {
|
public enum Rankings {
|
||||||
|
|
||||||
@@ -77,6 +82,18 @@ public enum Rankings {
|
|||||||
|
|
||||||
Record rec = new Record();
|
Record rec = new Record();
|
||||||
|
|
||||||
|
//we trim version to just the numbers, ignoring alpha/beta, etc.
|
||||||
|
Pattern p = Pattern.compile("\\d+\\.\\d+\\.\\d+");
|
||||||
|
Matcher m = p.matcher(ShatteredPixelDungeon.version);
|
||||||
|
if (m.find()) {
|
||||||
|
rec.version = "v" + m.group();
|
||||||
|
} else {
|
||||||
|
rec.version = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT, Locale.ROOT);
|
||||||
|
rec.date = format.format(new Date(Game.realTime));
|
||||||
|
|
||||||
rec.cause = cause;
|
rec.cause = cause;
|
||||||
rec.win = win;
|
rec.win = win;
|
||||||
rec.heroClass = Dungeon.hero.heroClass;
|
rec.heroClass = Dungeon.hero.heroClass;
|
||||||
@@ -433,6 +450,9 @@ public enum Rankings {
|
|||||||
private static final String SEED = "custom_seed";
|
private static final String SEED = "custom_seed";
|
||||||
private static final String DAILY = "daily";
|
private static final String DAILY = "daily";
|
||||||
|
|
||||||
|
private static final String DATE = "date";
|
||||||
|
private static final String VERSION = "version";
|
||||||
|
|
||||||
public Class cause;
|
public Class cause;
|
||||||
public boolean win;
|
public boolean win;
|
||||||
|
|
||||||
@@ -451,6 +471,9 @@ public enum Rankings {
|
|||||||
public String customSeed;
|
public String customSeed;
|
||||||
public boolean daily;
|
public boolean daily;
|
||||||
|
|
||||||
|
public String date;
|
||||||
|
public String version;
|
||||||
|
|
||||||
public String desc(){
|
public String desc(){
|
||||||
if (win){
|
if (win){
|
||||||
if (ascending){
|
if (ascending){
|
||||||
@@ -474,7 +497,7 @@ public enum Rankings {
|
|||||||
public void restoreFromBundle( Bundle bundle ) {
|
public void restoreFromBundle( Bundle bundle ) {
|
||||||
|
|
||||||
if (bundle.contains( CAUSE )) {
|
if (bundle.contains( CAUSE )) {
|
||||||
cause = bundle.getClass( CAUSE );
|
cause = bundle.getClass( CAUSE );
|
||||||
} else {
|
} else {
|
||||||
cause = null;
|
cause = null;
|
||||||
}
|
}
|
||||||
@@ -490,6 +513,13 @@ public enum Rankings {
|
|||||||
depth = bundle.getInt( DEPTH );
|
depth = bundle.getInt( DEPTH );
|
||||||
ascending = bundle.getBoolean( ASCEND );
|
ascending = bundle.getBoolean( ASCEND );
|
||||||
|
|
||||||
|
if (bundle.contains( DATE )){
|
||||||
|
date = bundle.getString( DATE );
|
||||||
|
version = bundle.getString( VERSION );
|
||||||
|
} else {
|
||||||
|
date = version = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (bundle.contains(DATA)) gameData = bundle.getBundle(DATA);
|
if (bundle.contains(DATA)) gameData = bundle.getBundle(DATA);
|
||||||
if (bundle.contains(ID)) gameID = bundle.getString(ID);
|
if (bundle.contains(ID)) gameID = bundle.getString(ID);
|
||||||
|
|
||||||
@@ -513,6 +543,9 @@ public enum Rankings {
|
|||||||
bundle.put( DEPTH, depth );
|
bundle.put( DEPTH, depth );
|
||||||
bundle.put( ASCEND, ascending );
|
bundle.put( ASCEND, ascending );
|
||||||
|
|
||||||
|
bundle.put( DATE, date );
|
||||||
|
bundle.put( VERSION, version );
|
||||||
|
|
||||||
if (gameData != null) bundle.put( DATA, gameData );
|
if (gameData != null) bundle.put( DATA, gameData );
|
||||||
bundle.put( ID, gameID );
|
bundle.put( ID, gameID );
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-2
@@ -165,7 +165,23 @@ public class WndRanking extends WndTabbed {
|
|||||||
title.setRect( 0, 0, WIDTH, 0 );
|
title.setRect( 0, 0, WIDTH, 0 );
|
||||||
add( title );
|
add( title );
|
||||||
|
|
||||||
float pos = title.bottom() + GAP + 1;
|
if (Dungeon.seed != -1){
|
||||||
|
GAP--;
|
||||||
|
}
|
||||||
|
|
||||||
|
float pos = title.bottom() + 1;
|
||||||
|
|
||||||
|
RenderedTextBlock date = PixelScene.renderTextBlock(record.date, 7);
|
||||||
|
date.hardlight(0xCCCCCC);
|
||||||
|
date.setPos(0, pos);
|
||||||
|
add(date);
|
||||||
|
|
||||||
|
RenderedTextBlock version = PixelScene.renderTextBlock(record.version, 7);
|
||||||
|
version.hardlight(0xCCCCCC);
|
||||||
|
version.setPos(WIDTH-version.width(), pos);
|
||||||
|
add(version);
|
||||||
|
|
||||||
|
pos = date.bottom()+5;
|
||||||
|
|
||||||
NumberFormat num = NumberFormat.getInstance(Locale.US);
|
NumberFormat num = NumberFormat.getInstance(Locale.US);
|
||||||
pos = statSlot( this, Messages.get(this, "score"), num.format( Statistics.totalScore ), pos );
|
pos = statSlot( this, Messages.get(this, "score"), num.format( Statistics.totalScore ), pos );
|
||||||
@@ -178,7 +194,7 @@ public class WndRanking extends WndTabbed {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
scoreInfo.setSize(16, 16);
|
scoreInfo.setSize(16, 16);
|
||||||
scoreInfo.setPos(WIDTH-scoreInfo.width(), pos-14);
|
scoreInfo.setPos(WIDTH-scoreInfo.width(), pos-10-GAP);
|
||||||
add(scoreInfo);
|
add(scoreInfo);
|
||||||
pos += GAP;
|
pos += GAP;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user