Don't spam logs and replays all over my home directory kthx.
Logs and replays are written to subdirectories of the "Support" folder. Default location is <game dir>/Support/; Can be overridden on game start.
This commit is contained in:
@@ -37,14 +37,20 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static class Log
|
public static class Log
|
||||||
{
|
{
|
||||||
public static string LogPathPrefix = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar;
|
static string LogPathPrefix = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar;
|
||||||
static Dictionary<string, ChannelInfo> channels = new Dictionary<string,ChannelInfo>();
|
static Dictionary<string, ChannelInfo> channels = new Dictionary<string,ChannelInfo>();
|
||||||
|
|
||||||
static Log()
|
public static string LogPath
|
||||||
{
|
{
|
||||||
AddChannel("debug", "openra.log.txt", false, false);
|
get { return LogPathPrefix; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
LogPathPrefix = value;
|
||||||
|
if (!Directory.Exists(LogPathPrefix))
|
||||||
|
Directory.CreateDirectory(LogPathPrefix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddChannel(string channelName, string filename, bool upload, bool diff)
|
public static void AddChannel(string channelName, string filename, bool upload, bool diff)
|
||||||
{
|
{
|
||||||
if (channels.ContainsKey(channelName)) return;
|
if (channels.ContainsKey(channelName)) return;
|
||||||
@@ -57,7 +63,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
writer = File.CreateText(LogPathPrefix + filename);
|
writer = File.CreateText(LogPathPrefix + filename);
|
||||||
}
|
}
|
||||||
catch(IOException e){ filename = new Random().Next().ToString() + filename; }
|
catch(IOException){ filename = new Random().Next().ToString() + filename; }
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.AutoFlush = true;
|
writer.AutoFlush = true;
|
||||||
|
|||||||
@@ -563,7 +563,14 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
|
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
|
||||||
|
|
||||||
LoadUserSettings(settings);
|
LoadUserSettings(settings);
|
||||||
|
|
||||||
|
Log.LogPath = SupportDir + "Logs" + Path.DirectorySeparatorChar;
|
||||||
|
Log.AddChannel("perf", "perf.log", false, false);
|
||||||
|
Log.AddChannel("debug", "debug.log", false, false);
|
||||||
|
Log.AddChannel("sync", "syncreport.log", true, true);
|
||||||
|
|
||||||
|
|
||||||
LobbyInfo.GlobalSettings.Mods = Settings.InitialMods;
|
LobbyInfo.GlobalSettings.Mods = Settings.InitialMods;
|
||||||
|
|
||||||
// Load the default mod to access required files
|
// Load the default mod to access required files
|
||||||
@@ -596,7 +603,6 @@ namespace OpenRA
|
|||||||
|
|
||||||
ResetTimer();
|
ResetTimer();
|
||||||
|
|
||||||
Log.AddChannel("sync", "openra.syncreport.txt", true, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadUserSettings(Settings settings)
|
static void LoadUserSettings(Settings settings)
|
||||||
@@ -636,13 +642,26 @@ namespace OpenRA
|
|||||||
|
|
||||||
Chrome.rootWidget.CloseWindow();
|
Chrome.rootWidget.CloseWindow();
|
||||||
Chrome.rootWidget.OpenWindow("MAINMENU_BG");
|
Chrome.rootWidget.OpenWindow("MAINMENU_BG");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string SupportDir
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
// Unless the user has specified otherwise, put support files in a subdirectory of the game install
|
||||||
|
if (Settings.SupportDir == null)
|
||||||
|
return Environment.CurrentDirectory + Path.DirectorySeparatorChar + "Support" + Path.DirectorySeparatorChar;
|
||||||
|
|
||||||
|
// Custom paths are relative to the home directory (My Documents under windows)
|
||||||
|
return Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar + Settings.SupportDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static int GetGameId()
|
internal static int GetGameId()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string s = File.ReadAllText(Log.LogPathPrefix + "openra.gameid");
|
string s = File.ReadAllText(SupportDir + "currentgameid");
|
||||||
return int.Parse(s);
|
return int.Parse(s);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@@ -653,7 +672,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
internal static void SetGameId(int id)
|
internal static void SetGameId(int id)
|
||||||
{
|
{
|
||||||
var file = File.CreateText(Log.LogPathPrefix + "openra.gameid");
|
var file = File.CreateText(SupportDir + "currentgameid");
|
||||||
file.Write(id);
|
file.Write(id);
|
||||||
file.Flush();
|
file.Flush();
|
||||||
file.Close();
|
file.Close();
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ namespace OpenRA.GameRules
|
|||||||
{
|
{
|
||||||
public class UserSettings
|
public class UserSettings
|
||||||
{
|
{
|
||||||
|
public readonly string SupportDir = null;
|
||||||
|
|
||||||
// Debug settings
|
// Debug settings
|
||||||
public bool UnitDebug = false;
|
public bool UnitDebug = false;
|
||||||
public bool PathDebug = true;
|
public bool PathDebug = true;
|
||||||
|
|||||||
@@ -62,10 +62,9 @@ namespace OpenRA.Network
|
|||||||
public OrderManager( IConnection conn, string replayFilename )
|
public OrderManager( IConnection conn, string replayFilename )
|
||||||
: this( conn )
|
: this( conn )
|
||||||
{
|
{
|
||||||
string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
|
string path = Game.SupportDir + "Replays" + Path.DirectorySeparatorChar;
|
||||||
+ Path.DirectorySeparatorChar + ".openra";
|
|
||||||
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
||||||
replaySaveFile = File.Create( path + Path.DirectorySeparatorChar + replayFilename );
|
replaySaveFile = File.Create( path + replayFilename );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IssueOrders( Order[] orders )
|
public void IssueOrders( Order[] orders )
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
// brutal hack
|
// brutal hack
|
||||||
Application.CurrentCulture = CultureInfo.InvariantCulture;
|
Application.CurrentCulture = CultureInfo.InvariantCulture;
|
||||||
Log.AddChannel("perf", "openra.perf.txt", false, false);
|
|
||||||
|
|
||||||
if (Debugger.IsAttached || args.Contains("--just-die"))
|
if (Debugger.IsAttached || args.Contains("--just-die"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ fi
|
|||||||
|
|
||||||
# Run the game
|
# Run the game
|
||||||
cd "${GAME_PATH}"
|
cd "${GAME_PATH}"
|
||||||
${EXE_PATH}mono "OpenRA.Game.exe" InitialMods=$MOD
|
${EXE_PATH}mono "OpenRA.Game.exe" InitialMods=$MOD SupportDir=Library/"Application Support"/OpenRA/
|
||||||
|
|
||||||
# Did we crash?
|
# Did we crash?
|
||||||
STATUS=$?
|
STATUS=$?
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ fi
|
|||||||
cd "$SUPPORT_PATH"
|
cd "$SUPPORT_PATH"
|
||||||
mkdir -p "${2}"
|
mkdir -p "${2}"
|
||||||
|
|
||||||
if [ -e "downloads/${1}" ]; then
|
if [ -e "Downloads/${1}" ]; then
|
||||||
/usr/bin/osascript << EOT
|
/usr/bin/osascript << EOT
|
||||||
tell application "Terminal"
|
tell application "Terminal"
|
||||||
activate
|
activate
|
||||||
do script "cd \"${SUPPORT_PATH}\"; unzip -o \"downloads/${1}\" -d \"${2}\"; touch done; exit;"
|
do script "cd \"${SUPPORT_PATH}\"; unzip -o \"Downloads/${1}\" -d \"${2}\"; touch done; exit;"
|
||||||
end tell
|
end tell
|
||||||
EOT
|
EOT
|
||||||
# Hack around osascript returning before the download finishes
|
# Hack around osascript returning before the download finishes
|
||||||
@@ -66,7 +66,7 @@ EOT`
|
|||||||
/usr/bin/osascript << EOT
|
/usr/bin/osascript << EOT
|
||||||
tell application "Terminal"
|
tell application "Terminal"
|
||||||
activate
|
activate
|
||||||
do script "cd \"${SUPPORT_PATH}\"; curl --create-dirs -o \"./downloads/${1}\" \"${5}\"; unzip -o \"downloads/${1}\" -d \"${2}\"; touch done; exit;"
|
do script "cd \"${SUPPORT_PATH}\"; curl --create-dirs -o \"./Downloads/${1}\" \"${5}\"; unzip -o \"Downloads/${1}\" -d \"${2}\"; touch done; exit;"
|
||||||
end tell
|
end tell
|
||||||
EOT
|
EOT
|
||||||
# Hack around osascript returning before the download finishes
|
# Hack around osascript returning before the download finishes
|
||||||
|
|||||||
Reference in New Issue
Block a user