Added latest version information underneath current version in main menu.

This commit is contained in:
Matthew Bowra-Dean
2010-09-29 14:13:22 +13:00
committed by Chris Forbes
parent d8d987f844
commit 92fece01de
5 changed files with 45 additions and 12 deletions

View File

@@ -20,9 +20,12 @@ namespace OpenRA.Server
static class MasterServerQuery
{
public static event Action<GameServer[]> OnComplete = _ => { };
public static event Action<string> OnVersion = _ => { };
static GameServer[] Games = { };
static string Version = "";
static AutoResetEvent ev = new AutoResetEvent(false);
static AutoResetEvent ev2 = new AutoResetEvent(false);
public static void Refresh(string masterServerUrl)
{
@@ -30,9 +33,7 @@ namespace OpenRA.Server
{
try
{
var wc = new WebClient();
var data = wc.DownloadData(new Uri(masterServerUrl + "list.php"));
var str = Encoding.UTF8.GetString(data);
var str = GetData(new Uri(masterServerUrl + "list.php"));
var yaml = MiniYaml.FromString(str);
@@ -52,6 +53,32 @@ namespace OpenRA.Server
{
if (ev.WaitOne(TimeSpan.FromMilliseconds(0)))
OnComplete(Games);
if (ev2.WaitOne(TimeSpan.FromMilliseconds(0)))
OnVersion(Version);
}
static string GetData(Uri uri)
{
var wc = new WebClient();
var data = wc.DownloadData(uri);
return Encoding.UTF8.GetString(data);
}
public static void GetCurrentVersion(string masterServerUrl)
{
new Thread(() =>
{
try
{
Version = GetData(new Uri(masterServerUrl + "VERSION"));
}
catch
{
Version = "";
}
ev2.Set();
}).Start();
}
}

View File

@@ -9,6 +9,7 @@
#endregion
using OpenRA.FileFormats;
using OpenRA.Server;
namespace OpenRA.Widgets.Delegates
{
@@ -31,6 +32,8 @@ namespace OpenRA.Widgets.Delegates
var s = FileSystem.Open("VERSION");
version.Text = s.ReadAllText();
s.Close();
MasterServerQuery.OnVersion += v => { version.Text += "\nLatest: " + v; };
MasterServerQuery.GetCurrentVersion(Game.Settings.Server.MasterServer);
}
}
}

View File

@@ -67,9 +67,9 @@ Background@MAINMENU_BG:
Label@VERSION_STRING:
Id:VERSION_STRING
X:WINDOW_RIGHT - PARENT_LEFT - WIDTH - 15
Y:WINDOW_BOTTOM - PARENT_TOP - 25
Y:WINDOW_BOTTOM - PARENT_TOP - 65
Width:400
Height:35
Height:70
Text:
Align:Right
Bold:True

View File

@@ -67,9 +67,9 @@ Background@MAINMENU_BG:
Label@VERSION_STRING:
Id:VERSION_STRING
X:WINDOW_RIGHT - PARENT_LEFT - WIDTH - 15
Y:WINDOW_BOTTOM - PARENT_TOP - 25
Y:WINDOW_BOTTOM - PARENT_TOP - 65
Width:400
Height:35
Height:70
Text:
Align:Right
Bold:True

View File

@@ -33,7 +33,7 @@ esac
mv OpenRA.exe OpenRA-$VERSION.exe
../uploader.sh windows "$VERSION" OpenRA-$VERSION.exe "$FTPPATH" "$2" "$3"
else
msg "\E[31m" "Windows package build failed, refer to log."
msg "\E[31m" "Windows package build failed, refer to $PWD/package.log."
fi
popd &> /dev/null
) &
@@ -46,7 +46,7 @@ esac
if [ $? -eq 0 ]; then
../uploader.sh mac "$VERSION" OpenRA-$VERSION.zip "$FTPPATH" "$2" "$3"
else
msg "\E[31m" "OSX package build failed, refer to log."
msg "\E[31m" "OSX package build failed, refer to $PWD/package.log."
fi
popd &> /dev/null
) &
@@ -84,7 +84,7 @@ esac
pushd linux/pkgbuild/ &> /dev/null
sh buildpackage.sh "ftp.open-ra.org" "$FTPPATH/linux" "$2" "$3" "$VERSION" &> package.log
if [ $? -ne 0 ]; then
msg "\E[31m" "Arch-Linux package build failed, refer to log."
msg "\E[31m" "Arch-Linux package build failed, refer to $PWD/package.log."
fi
popd &> /dev/null
) &
@@ -95,7 +95,7 @@ esac
pushd linux/rpm/ &> /dev/null
sh buildpackage.sh "ftp.open-ra.org" "$FTPPATH/linux" "$2" "$3" "$VERSION" ~/rpmbuild &> package.log
if [ $? -ne 0 ]; then
msg "\E[31m" "RPM package build failed, refer to log."
msg "\E[31m" "RPM package build failed, refer to $PWD/package.log."
fi
popd &> /dev/null
) &
@@ -106,7 +106,7 @@ esac
pushd linux/deb/ &> /dev/null
./buildpackage.sh "ftp.open-ra.org" "$FTPPATH/linux" "$2" "$3" "$VERSION" ~/openra-package/built ~/debpackage &> package.log
if [ $? -ne 0 ]; then
msg "\E[31m" "deb package build failed, refer to log."
msg "\E[31m" "deb package build failed, refer to $PWD/package.log."
fi
popd &> /dev/null
) &
@@ -116,3 +116,6 @@ esac
wait
if [ "$TYPE" = "release" ]; then
wput --basename=../ -u ../VERSION ftp://ftp.open-ra.org/httpdocs/master/
fi