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_REVISION $WCREV$
#define BUILD_SVN_DATE "$WCDATE$" #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 // 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/")); AddComment(_T("http://www.aegisub.org/"));
SetScriptInfo(_T("ScriptType"),_T("v4.00+")); SetScriptInfo(_T("ScriptType"),_T("v4.00+"));

View file

@ -141,7 +141,7 @@ AboutScreen::AboutScreen(wxWindow *parent)
aboutString += translatorCredit; aboutString += translatorCredit;
aboutString += _T("\n") + libString; aboutString += _T("\n") + libString;
aboutString += _("\nSee the help file for full credits.\n"); 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 // Replace copyright symbol
wxChar copySymbol = 0xA9; wxChar copySymbol = 0xA9;

View file

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

View file

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

View file

@ -36,193 +36,87 @@
#include "config.h" #include "config.h"
#ifndef AGI_PRE
#include <wx/datetime.h>
#include <wx/string.h>
#endif
#include "version.h" #include "version.h"
#ifdef __WINDOWS__ #ifdef __WINDOWS__
#include "../build/svn-revision.h" #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 #else
#define DEBUG_SUFFIX ""
#ifndef BUILD_SVN_REVISION
/// DOCME
#define BUILD_SVN_REVISION 0
#endif #endif
#ifdef BUILD_CREDIT
#define BUILD_CREDIT_SUFFIX ", " BUILD_CREDIT
#else
#define BUILD_CREDIT_SUFFIX ""
#endif #endif
#ifndef BUILD_SVN_DATE
#define BUILD_SVN_DATE __DATE__ " " __TIME__
#endif
/// DOCME #ifndef BUILD_SVN_LOCALMODS
#define _T_rec(X) _T(X) #define BUILD_SVN_LOCALMODS ""
#endif
/// 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__)
// Define FINAL_RELEASE to mark a build as a "final" version, ie. not pre-release version // 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 // 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 #ifdef FINAL_RELEASE
IsRelease = true; #define VERSION_NUMBER "3.0.0"
VersionNumber = _T("3.0.0");
#else #else
IsRelease = false; #define VERSION_NUMBER "r" STR_INT(BUILD_SVN_REVISION) BUILD_SVN_LOCALMODS
VersionNumber = _T("r") _T_int(BUILD_SVN_REVISION)
# ifdef BUILD_SVN_LOCALMODS
_T("M")
# endif
;
#endif #endif
if (IsRelease) const char *GetAegisubLongVersionString() {
{ #ifdef FINAL_RELEASE
// Short is used in about box return VERSION_NUMBER DEBUG_SUFFIX;
ShortVersionString = wxString::Format(_T("%s (built from SVN revision %d)"), VersionNumber, SvnRev); #else
// Long is used in title bar return VERSION_NUMBER " (development version" BUILD_CREDIT_SUFFIX ")" DEBUG_SUFFIX;
LongVersionString = VersionNumber; #endif
} }
else
{ const char *GetAegisubShortVersionString() {
wxString buildcred; #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 #ifdef BUILD_CREDIT
buildcred += _T(", "); buildcred += BuildCredit; return BUILD_CREDIT;
#else
return "";
#endif #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() { bool GetIsOfficialRelease() {
return versioninfo.IsRelease; #ifdef FINAL_RELEASE
return true;
#else
return false;
#endif
} }
const char *GetVersionNumber() {
/// @brief DOCME return VERSION_NUMBER;
/// @return
///
wxString GetVersionNumber() {
return versioninfo.VersionNumber;
} }
/// @brief DOCME
///
int GetSVNRevision() { 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 /// @ingroup main
/// ///
class wxString; /// Version string appended in title bar of main window (quick identification of all elements of a build)
const char *GetAegisubLongVersionString();
// Version string appended in title bar of main window (quick identification of all elements of a build) /// Version string used in About box, looks nicer
wxString GetAegisubLongVersionString(); const char *GetAegisubShortVersionString();
// Version string used in About box, looks nicer /// Timestamp of build, only shown in About box
wxString GetAegisubShortVersionString(); const char *GetAegisubBuildTime();
// Timestamp of build, only shown in About box /// Name of who built the binary
wxString GetAegisubBuildTime(); const char *GetAegisubBuildCredit();
// Name of who built the binary /// Is release?
wxString GetAegisubBuildCredit();
// Is release?
bool GetIsOfficialRelease(); bool GetIsOfficialRelease();
// Version number /// Version number
wxString GetVersionNumber(); const char *GetVersionNumber();
// Get SVN revision /// Get SVN revision
int GetSVNRevision(); int GetSVNRevision();