Skip to content

Commit

Permalink
gamelog_recording_name_improvement
Browse files Browse the repository at this point in the history
See merge request main/Sumatra!1820

sumatra-commit: 8ffe115e30f0ee907a8ecd3c18bb8eb112d9cd45
  • Loading branch information
g3force authored and TIGERs GitLab committed Apr 19, 2024
1 parent bdec270 commit 7de8c58
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@
public class GameLogRecorder extends AModule
{
private final GameLogWriter writer = new GameLogWriter(GameLogType.LOG_FILE);
private String matchType = "";
private String matchStage = "";
private String teamYellow = "";
private String teamBlue = "";


/**
* @param match type of match
* @param stage stage of match
* @param yellow name of yellow team
* @param blue name of blue team
*/
public void setMatchInfo(String match, String stage, String yellow, String blue)
{
matchType = match;
matchStage = stage;
teamYellow = yellow;
teamBlue = blue;
}


@Override
Expand All @@ -26,7 +45,7 @@ public void setRecording(boolean enable)
{
if (enable && !writer.isOpen())
{
writer.open();
writer.open(matchType, matchStage, teamYellow, teamBlue);
} else if (!enable && writer.isOpen())
{
writer.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public class GameLogWriter
/**
* Open a gamelog for writing using current date/time as filename.
*/
public void open()
public void open(String matchType, String stage, String teamYellow, String teamBlue)
{
SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
dt.setTimeZone(TimeZone.getDefault());

open(dt.format(new Date()));
String filename = dt.format(new Date()) + String.format("-%s-%s-%s-vs-%s", matchType, stage, teamYellow, teamBlue);
open(filename);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public static BerkeleyDb withCustomLocation(final Path customLocation)


/**
* @param matchType type of match
* @param stage stage of game
* @param matchType type of match
* @param stage stage of game
* @param teamYellow name of yellow team
* @param teamBlue name of blue team
* @return the default name for a new database
Expand All @@ -123,9 +123,7 @@ public static String getDefaultName(String matchType, String stage, String teamY
{
SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
dt.setTimeZone(TimeZone.getDefault());
return dt.format(new Date()) + String.format("-%s-%s-%s-vs-%s", matchType, stage,
teamYellow.replace(" ", "_"),
teamBlue.replace(" ", "_"));
return dt.format(new Date()) + String.format("-%s-%s-%s-vs-%s", matchType, stage, teamYellow, teamBlue);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public class RecordManager extends AModule implements IRefereeObserver
private final List<IBerkeleyRecorderHook> hooks = new CopyOnWriteArrayList<>();
private long lastCommandCounter = -1;
private BerkeleyAsyncRecorder recorder = null;
private String teamYellow = "";
private String teamBlue = "";
private String matchType = "";
private String matchStage = "";
protected String teamYellow = "";
protected String teamBlue = "";
protected String matchType = "";
protected String matchStage = "";

@Configurable(defValue = "false", comment = "Automatically compress recordings after they were closed")
private static boolean compressOnClose = false;
Expand Down Expand Up @@ -169,8 +169,8 @@ public void onNewRefereeMsg(final SslGcRefereeMessage.Referee refMsg)
{
if (refMsg != null && recorder == null)
{
teamYellow = refMsg.getYellow().getName();
teamBlue = refMsg.getBlue().getName();
teamYellow = refMsg.getYellow().getName().replace(" ", "_");
teamBlue = refMsg.getBlue().getName().replace(" ", "_");
matchType = refMsg.getMatchType().toString();
matchStage = refMsg.getStage().toString().replace("_PRE", "");
}
Expand Down

0 comments on commit 7de8c58

Please sign in to comment.