Skip to content

Commit

Permalink
VERSION: Encapsulate the version information more
Browse files Browse the repository at this point in the history
They're now more opaque functions in the Version namespace.
  • Loading branch information
DrMcCoy committed Oct 16, 2016
1 parent 359b34b commit 46ba4e1
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 26 deletions.
9 changes: 5 additions & 4 deletions src/cline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,19 @@ Job parseCommandLine(const std::vector<Common::UString> &argv) {
Common::UString createVersionText() {
Common::UString text;

text += Common::UString::format("%s\n", PHAETHON_NAMEVERSIONFULL);
text += Common::UString::format("%s\n", PHAETHON_URL);
text += Common::UString::format("%s\n", Version::getProjectNameVersionFull());
text += Common::UString::format("%s\n", Version::getProjectURL());
text += Common::UString::format("\n");
text += Common::UString::format("%s", PHAETHON_AUTHORS);
text += Common::UString::format("%s", Version::getProjectAuthors());

return text;
}

Common::UString createHelpText(const Common::UString &name) {
Common::UString text;

text += Common::UString::format("%s - A FLOSS resource explorer for BioWare's Aurora engine games\n", PHAETHON_NAME);
text += Common::UString::format("%s - A FLOSS resource explorer for BioWare's Aurora engine games\n",
Version::getProjectName());
text += Common::UString::format("Usage: %s [options] [<path>]\n", name.c_str());
text += Common::UString::format(" -h --help Display this text and exit.\n");
text += Common::UString::format(" -v --version Display version information and exit.");
Expand Down
2 changes: 1 addition & 1 deletion src/gui/about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ wxBEGIN_EVENT_TABLE(AboutDialog, wxDialog)
wxEND_EVENT_TABLE()

AboutDialog::AboutDialog(wxWindow *parent) :
wxDialog(parent, wxID_ANY, Common::UString("About ") + PHAETHON_NAME) {
wxDialog(parent, wxID_ANY, Common::UString("About ") + Version::getProjectName()) {

wxGenericStaticText *msg = new wxGenericStaticText(this, wxID_ANY, wxEmptyString);

Expand Down
6 changes: 4 additions & 2 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ void MainWindow::createLayout() {
menuFile->AppendSeparator();
menuFile->Append(menuFileClose);
menuFile->AppendSeparator();
menuFile->Append(kEventMenuFileQuit, wxT("&Quit\tCtrl-Q"), Common::UString("Quit ") + PHAETHON_NAME);
menuFile->Append(kEventMenuFileQuit, wxT("&Quit\tCtrl-Q"),
Common::UString("Quit ") + Version::getProjectName());


wxMenu *menuHelp = new wxMenu;
menuHelp->Append(kEventMenuHelpAbout, wxT("&About\tF1"), Common::UString("About ") + PHAETHON_NAME);
menuHelp->Append(kEventMenuHelpAbout, wxT("&About\tF1"),
Common::UString("About ") + Version::getProjectName());

wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(menuFile, wxT("&File"));
Expand Down
2 changes: 1 addition & 1 deletion src/phaethon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bool Phaethon::OnInit() {
initSubsystems();

GUI::MainWindow *mainWindow =
new GUI::MainWindow(PHAETHON_NAMEVERSION, wxDefaultPosition, wxSize(800, 600));
new GUI::MainWindow(Version::getProjectNameVersion(), wxDefaultPosition, wxSize(800, 600));

mainWindow->Show(true);
if (!_path.empty())
Expand Down
46 changes: 37 additions & 9 deletions src/version/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,44 @@
#define PHAETHON_REV PHAETHON_DISTRO
#endif

const char *PHAETHON_NAME = PACKAGE_NAME;
const char *PHAETHON_VERSION = PACKAGE_VERSION;
const char *PHAETHON_NAMEVERSION = PACKAGE_NAME " " PACKAGE_VERSION PHAETHON_REVSEP PHAETHON_REV;
const char *PHAETHON_NAMEVERSIONFULL = PACKAGE_NAME " " PACKAGE_VERSION PHAETHON_REVSEP PHAETHON_REV " [" PHAETHON_REVDESC "] (" PHAETHON_BUILDDATE ")";
const char *PHAETHON_COPYRIGHTYEAR = "2014-2016";
const char *PHAETHON_URL = "https://xoreos.org/";

const char *PHAETHON_AUTHORS =
"Copyright (c) 2010-2016 by the xoreos team.\n"
namespace Version {

static const char *kProjectName = PACKAGE_NAME;
static const char *kProjectVersion = PACKAGE_VERSION;
static const char *kProjectNameVersion = PACKAGE_NAME " " PACKAGE_VERSION PHAETHON_REVSEP PHAETHON_REV;
static const char *kProjectNameVersionFull = PACKAGE_NAME " " PACKAGE_VERSION PHAETHON_REVSEP PHAETHON_REV " [" PHAETHON_REVDESC "] (" PHAETHON_BUILDDATE ")";

static const char *kProjectURL = "https://xoreos.org/";

static const char *kProjectAuthors =
"Copyright (c) 2014-2016 by the xoreos team.\n"
"Please see the AUTHORS file for details.\n"
"\n"
"This is free software; see the source for copying conditions. There is NO\n"
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.";

const char *getProjectName() {
return kProjectName;
}

const char *getProjectVersion() {
return kProjectVersion;
}

const char *getProjectNameVersion() {
return kProjectNameVersion;
}

const char *getProjectNameVersionFull() {
return kProjectNameVersionFull;
}

const char *getProjectURL() {
return kProjectURL;
}

const char *getProjectAuthors() {
return kProjectAuthors;
}

} // End of namespace Version
19 changes: 10 additions & 9 deletions src/version/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,26 @@
#ifndef VERSION_VERSION_H
#define VERSION_VERSION_H

namespace Version {

// "Phaethon"
extern const char *PHAETHON_NAME;
const char *getProjectName();

// "0.0.0+2197.g19f9c1b"
extern const char *PHAETHON_VERSION;
const char *getProjectVersion();

// "Phaethon 0.0.0+2197.g19f9c1b"
extern const char *PHAETHON_NAMEVERSION;
const char *getProjectNameVersion();

// "Phaethon 0.0.0+2197.g19f9c1b [0.0.0+2197.g19f9c1b] (2014-06-28T00:35:43)"
extern const char *PHAETHON_NAMEVERSIONFULL;

// "2014"
extern const char *PHAETHON_COPYRIGHTYEAR;
const char *getProjectNameVersionFull();

// "https://..."
extern const char *PHAETHON_URL;
const char *getProjectURL();

// Very shortened authors/copyright message
extern const char *PHAETHON_AUTHORS;
const char *getProjectAuthors();

} // End of namespace Version

#endif // VERSION_VERSION_H

0 comments on commit 46ba4e1

Please sign in to comment.