Simplify version.cpp

Originally committed to SVN as r5526.
This commit is contained in:
Thomas Goyne 2011-07-27 22:52:37 +00:00
parent 3a4c48d8df
commit 1cacc33d2d
7 changed files with 73 additions and 182 deletions

View File

@ -7,4 +7,4 @@
#define BUILD_SVN_REVISION $WCREV$
#define BUILD_SVN_DATE "$WCDATE$"
#define BUILD_SVN_LOCALMODS $WCMODS?true:false$
#define BUILD_SVN_LOCALMODS $WCMODS?"M":""$

View File

@ -155,7 +155,7 @@ void AssFile::Load(const wxString &_filename,wxString charset,bool addToRecent)
}
// Add comments and set vars
AddComment(_T("Script generated by Aegisub ") + GetAegisubLongVersionString());
AddComment(wxString("Script generated by Aegisub ") + GetAegisubLongVersionString());
AddComment(_T("http://www.aegisub.org/"));
SetScriptInfo(_T("ScriptType"),_T("v4.00+"));

View File

@ -141,7 +141,7 @@ AboutScreen::AboutScreen(wxWindow *parent)
aboutString += translatorCredit;
aboutString += _T("\n") + libString;
aboutString += _("\nSee the help file for full credits.\n");
aboutString += wxString::Format(_("Built by %s on %s."), GetAegisubBuildCredit().c_str(), GetAegisubBuildTime().c_str());
aboutString += wxString::Format(_("Built by %s on %s."), GetAegisubBuildCredit(), GetAegisubBuildTime());
// Replace copyright symbol
wxChar copySymbol = 0xA9;

View File

@ -531,7 +531,7 @@ int AegisubApp::OnRun() {
wxDateTime time = wxDateTime::Now();
wxString timeStr = _T("---") + time.FormatISODate() + _T(" ") + time.FormatISOTime() + _T("------------------");
file << std::endl << timeStr.mb_str(csConvLocal);
file << "\nVER - " << GetAegisubLongVersionString().mb_str(wxConvUTF8);
file << "\nVER - " << GetAegisubLongVersionString();
file << "\nEXC - Aegisub has crashed with unhandled exception \"" << error.mb_str(csConvLocal) <<"\".\n";
int formatLen = timeStr.Length();
char dashes[1024];

View File

@ -212,7 +212,7 @@ void TXTSubtitleFormat::WriteFile(wxString filename,wxString encoding) { using n
bool strip_formatting = true;
TextFileWriter file(filename, encoding);
file.WriteLineToFile(_T("# Exported by Aegisub ") + GetAegisubShortVersionString());
file.WriteLineToFile(wxString("# Exported by Aegisub ") + GetAegisubShortVersionString());
// Write the file
for (list<AssEntry*>::iterator l = Line->begin(); l != Line->end(); ++l) {

View File

@ -36,193 +36,87 @@
#include "config.h"
#ifndef AGI_PRE
#include <wx/datetime.h>
#include <wx/string.h>
#endif
#include "version.h"
#ifdef __WINDOWS__
#include "../build/svn-revision.h"
#endif
#define STR_INT2(x) #x
#define STR_INT(x) STR_INT2(x)
#ifdef _DEBUG
#define DEBUG_SUFFIX " [DEBUG VERSION]"
#else
#ifndef BUILD_SVN_REVISION
/// DOCME
#define BUILD_SVN_REVISION 0
#define DEBUG_SUFFIX ""
#endif
#ifdef BUILD_CREDIT
#define BUILD_CREDIT_SUFFIX ", " BUILD_CREDIT
#else
#define BUILD_CREDIT_SUFFIX ""
#endif
#ifndef BUILD_SVN_DATE
#define BUILD_SVN_DATE __DATE__ " " __TIME__
#endif
/// DOCME
#define _T_rec(X) _T(X)
/// DOCME
#define _T_stringize(X) _T(#X)
/// DOCME
#define _T_int(X) _T_stringize(X)
/// DOCME
#define BUILD_TIMESTAMP _T_rec(__DATE__) _T(" ") _T_rec(__TIME__)
#ifndef BUILD_SVN_LOCALMODS
#define BUILD_SVN_LOCALMODS ""
#endif
// Define FINAL_RELEASE to mark a build as a "final" version, ie. not pre-release version
// In that case it won't include the SVN revision information
/// DOCME
struct VersionInfoStruct {
/// DOCME
const wxChar *VersionNumber;
/// DOCME
bool IsDebug;
/// DOCME
bool IsRelease;
/// DOCME
int SvnRev;
/// DOCME
const wxChar *BuildTime;
/// DOCME
const wxChar *BuildCredit;
/// DOCME
wxString LongVersionString;
/// DOCME
wxString ShortVersionString;
/// @brief // Generate the above data
///
VersionInfoStruct() {
wxString VersionStr;
SvnRev = BUILD_SVN_REVISION;
#ifdef BUILD_SVN_DATE
BuildTime = _T_rec(BUILD_SVN_DATE);
#else
BuildTime = BUILD_TIMESTAMP;
#endif
#ifdef BUILD_CREDIT
BuildCredit = _T(BUILD_CREDIT);
#else
BuildCredit = _T("");
#endif
#ifdef _DEBUG
IsDebug = true;
#else
IsDebug = false;
#endif
#ifdef FINAL_RELEASE
IsRelease = true;
VersionNumber = _T("3.0.0");
#define VERSION_NUMBER "3.0.0"
#else
IsRelease = false;
VersionNumber = _T("r") _T_int(BUILD_SVN_REVISION)
# ifdef BUILD_SVN_LOCALMODS
_T("M")
# endif
;
#define VERSION_NUMBER "r" STR_INT(BUILD_SVN_REVISION) BUILD_SVN_LOCALMODS
#endif
if (IsRelease)
{
// Short is used in about box
ShortVersionString = wxString::Format(_T("%s (built from SVN revision %d)"), VersionNumber, SvnRev);
// Long is used in title bar
LongVersionString = VersionNumber;
}
else
{
wxString buildcred;
const char *GetAegisubLongVersionString() {
#ifdef FINAL_RELEASE
return VERSION_NUMBER DEBUG_SUFFIX;
#else
return VERSION_NUMBER " (development version" BUILD_CREDIT_SUFFIX ")" DEBUG_SUFFIX;
#endif
}
const char *GetAegisubShortVersionString() {
#ifdef FINAL_RELEASE
return VERSION_NUMBER " (built from SVN revision r" #BUILD_SVN_REVISION BUILD_SVN_LOCALMODS ")" DEBUG_SUFFIX;
#else
return VERSION_NUMBER " (development version" BUILD_CREDIT_SUFFIX ")" DEBUG_SUFFIX;
#endif
}
const char *GetAegisubBuildTime() {
return BUILD_SVN_DATE;
}
const char *GetAegisubBuildCredit() {
#ifdef BUILD_CREDIT
buildcred += _T(", "); buildcred += BuildCredit;
return BUILD_CREDIT;
#else
return "";
#endif
ShortVersionString = wxString::Format(_T("%s (development version%s)"), VersionNumber, buildcred.c_str());
LongVersionString = ShortVersionString;
}
if (IsDebug)
{
ShortVersionString += _T(" [DEBUG VERSION]");
LongVersionString += _T(" [DEBUG VERSION]");
}
}
};
/// DOCME
VersionInfoStruct versioninfo;
/// @brief DOCME
/// @return
///
wxString GetAegisubLongVersionString() {
return versioninfo.LongVersionString;
}
/// @brief DOCME
/// @return
///
wxString GetAegisubShortVersionString() {
return versioninfo.ShortVersionString;
}
/// @brief DOCME
/// @return
///
wxString GetAegisubBuildTime() {
return versioninfo.BuildTime;
}
/// @brief DOCME
/// @return
///
wxString GetAegisubBuildCredit() {
return versioninfo.BuildCredit;
}
/// @brief DOCME
/// @return
///
bool GetIsOfficialRelease() {
return versioninfo.IsRelease;
#ifdef FINAL_RELEASE
return true;
#else
return false;
#endif
}
/// @brief DOCME
/// @return
///
wxString GetVersionNumber() {
return versioninfo.VersionNumber;
const char *GetVersionNumber() {
return VERSION_NUMBER;
}
/// @brief DOCME
///
int GetSVNRevision() {
return versioninfo.SvnRev;
#ifdef BUILD_SVN_REVISION
return BUILD_SVN_REVISION;
#else
return 0;
#endif
}

View File

@ -34,20 +34,17 @@
/// @ingroup main
///
class wxString;
// Version string appended in title bar of main window (quick identification of all elements of a build)
wxString GetAegisubLongVersionString();
// Version string used in About box, looks nicer
wxString GetAegisubShortVersionString();
// Timestamp of build, only shown in About box
wxString GetAegisubBuildTime();
// Name of who built the binary
wxString GetAegisubBuildCredit();
// Is release?
/// Version string appended in title bar of main window (quick identification of all elements of a build)
const char *GetAegisubLongVersionString();
/// Version string used in About box, looks nicer
const char *GetAegisubShortVersionString();
/// Timestamp of build, only shown in About box
const char *GetAegisubBuildTime();
/// Name of who built the binary
const char *GetAegisubBuildCredit();
/// Is release?
bool GetIsOfficialRelease();
// Version number
wxString GetVersionNumber();
// Get SVN revision
/// Version number
const char *GetVersionNumber();
/// Get SVN revision
int GetSVNRevision();