2004-04-08 11:43:06 +02:00
|
|
|
/* Eliot */
|
|
|
|
/* Copyright (C) 1999 Antoine Fraboulet */
|
|
|
|
/* Antoine.Fraboulet@free.fr */
|
|
|
|
/* */
|
|
|
|
/* This program is free software; you can redistribute it and/or modify */
|
|
|
|
/* it under the terms of the GNU General Public License as published by */
|
|
|
|
/* the Free Software Foundation; either version 2 of the License, or */
|
|
|
|
/* (at your option) any later version. */
|
|
|
|
/* */
|
|
|
|
/* This program is distributed in the hope that it will be useful, */
|
|
|
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
|
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
|
|
/* GNU General Public License for more details. */
|
|
|
|
/* */
|
|
|
|
/* You should have received a copy of the GNU General Public License */
|
|
|
|
/* along with this program; if not, write to the Free Software */
|
2005-10-23 16:53:42 +02:00
|
|
|
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
2004-04-08 11:43:06 +02:00
|
|
|
|
2006-01-01 20:34:05 +01:00
|
|
|
/**
|
|
|
|
* \file main.cc
|
|
|
|
* \brief Eliot main entry point
|
|
|
|
* \author Antoine Fraboulet
|
|
|
|
* \date 2005
|
|
|
|
*/
|
|
|
|
|
2004-06-26 12:40:02 +02:00
|
|
|
#ifdef WIN32 // mingw32 hack
|
|
|
|
# undef Yield
|
|
|
|
# undef CreateDialog
|
|
|
|
#endif
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
2004-06-26 12:40:02 +02:00
|
|
|
#include <wx/wxprec.h>
|
|
|
|
#include <wx/wx.h>
|
|
|
|
#include <wx/app.h>
|
|
|
|
#include <wx/intl.h>
|
|
|
|
|
2004-04-08 11:43:06 +02:00
|
|
|
#include "ewx.h"
|
|
|
|
#include "configdb.h"
|
|
|
|
#include "mainframe.h"
|
2005-03-29 09:00:39 +02:00
|
|
|
#include "game_factory.h"
|
2004-04-08 11:43:06 +02:00
|
|
|
|
|
|
|
#include "eliot.xpm"
|
|
|
|
|
|
|
|
class EliotApp : public wxApp
|
|
|
|
{
|
|
|
|
private:
|
2008-01-12 21:42:25 +01:00
|
|
|
MainFrame *m_mainFrame;
|
2004-04-08 11:43:06 +02:00
|
|
|
protected:
|
2008-01-12 21:42:25 +01:00
|
|
|
wxLocale locale;
|
2004-04-08 11:43:06 +02:00
|
|
|
public:
|
2008-01-12 21:42:25 +01:00
|
|
|
virtual bool OnInit();
|
|
|
|
virtual int OnExit();
|
2004-04-08 11:43:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_APP(EliotApp)
|
|
|
|
|
|
|
|
bool
|
|
|
|
EliotApp::OnInit()
|
|
|
|
{
|
2008-01-12 21:42:25 +01:00
|
|
|
wxApp::OnInit();
|
2005-02-05 12:14:56 +01:00
|
|
|
srand(time(NULL));
|
|
|
|
SetVendorName(wxT("Afrab"));
|
|
|
|
SetAppName(wxString(wxT("eliot")) + wxT("-") + wxT(VERSION));
|
|
|
|
SetClassName(wxT("eliot"));
|
2004-04-08 11:43:06 +02:00
|
|
|
|
2008-01-12 21:42:25 +01:00
|
|
|
wxConfigBase::Get();
|
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
locale.Init();
|
2006-08-12 00:18:33 +02:00
|
|
|
|
2008-01-12 21:42:25 +01:00
|
|
|
// Search for translations in the installation directory
|
|
|
|
wxString catalogPath;
|
|
|
|
#ifdef WIN32
|
|
|
|
// Get the absolute path, as returned by GetFullPathName()
|
|
|
|
wchar_t path[MAX_PATH];
|
|
|
|
GetFullPathName(wstring(argv[0]).c_str(), MAX_PATH, path, NULL);
|
|
|
|
wchar_t *pos = wcsrchr(path, L'\\');
|
|
|
|
if (pos)
|
|
|
|
*pos = '\0';
|
|
|
|
catalogPath = wxU(path) + wxT("/locale");
|
|
|
|
#else
|
|
|
|
catalogPath = wxT(LOCALEDIR);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
wxLocale::AddCatalogLookupPathPrefix(catalogPath);
|
2008-01-08 14:52:32 +01:00
|
|
|
// No need to search in the current directory, it is already done by default
|
|
|
|
// wxLocale::AddCatalogLookupPathPrefix(wxT("."));
|
2006-08-12 00:18:33 +02:00
|
|
|
locale.AddCatalog(wxT("eliot"));
|
|
|
|
#ifdef __LINUX__
|
|
|
|
{
|
|
|
|
wxLogNull noLog;
|
2008-01-08 14:52:32 +01:00
|
|
|
locale.AddCatalog(wxT("fileutils"));
|
2006-08-12 00:18:33 +02:00
|
|
|
}
|
2004-04-08 11:43:06 +02:00
|
|
|
#endif
|
2008-01-08 14:52:32 +01:00
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
ConfigDB configdb;
|
|
|
|
configdb.setFirstDefault();
|
|
|
|
MainFrame *mainframe = new MainFrame(configdb.getFramePos(wxT(APPNAME)),
|
|
|
|
configdb.getFrameSize(wxT(APPNAME)));
|
|
|
|
mainframe->SetIcon(wxICON(eliot));
|
|
|
|
mainframe->Show(TRUE);
|
|
|
|
SetTopWindow(mainframe);
|
|
|
|
return TRUE;
|
2004-04-08 11:43:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
EliotApp::OnExit()
|
|
|
|
{
|
2005-03-29 09:00:39 +02:00
|
|
|
GameFactory::Destroy();
|
2008-01-08 14:52:32 +01:00
|
|
|
delete wxConfigBase::Set(NULL);
|
2008-01-12 21:42:25 +01:00
|
|
|
return wxApp::OnExit();
|
2004-04-08 11:43:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-01 20:34:05 +01:00
|
|
|
/// Local Variables:
|
|
|
|
/// mode: c++
|
|
|
|
/// mode: hs-minor
|
|
|
|
/// c-basic-offset: 4
|
|
|
|
/// indent-tabs-mode: nil
|
|
|
|
/// End:
|