| 1 |
///////////////////////////////////////////////////////////////////////////// |
| 2 |
// Name: aeinstallerapp.cpp |
| 3 |
// Purpose: |
| 4 |
// Author: |
| 5 |
// Modified by: |
| 6 |
// Created: 07/05/2009 17:23:39 |
| 7 |
// RCS-ID: |
| 8 |
// Copyright: |
| 9 |
// Licence: |
| 10 |
///////////////////////////////////////////////////////////////////////////// |
| 11 |
#include "boost/thread.hpp" |
| 12 |
#include <boost/thread/mutex.hpp> |
| 13 |
#include <fstream> |
| 14 |
#include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations |
| 15 |
#include "boost/lexical_cast.hpp" //int -> string |
| 16 |
using namespace boost::filesystem; |
| 17 |
// For compilers that support precompilation, includes "wx/wx.h". |
| 18 |
#include "wx/wxprec.h" |
| 19 |
|
| 20 |
#ifdef __BORLANDC__ |
| 21 |
#pragma hdrstop |
| 22 |
#endif |
| 23 |
|
| 24 |
#ifndef WX_PRECOMP |
| 25 |
#include "wx/wx.h" |
| 26 |
#endif |
| 27 |
|
| 28 |
////@begin includes |
| 29 |
////@end includes |
| 30 |
|
| 31 |
#include "aeinstallerapp.h" |
| 32 |
#include <string> |
| 33 |
|
| 34 |
////@begin XPM images |
| 35 |
////@end XPM images |
| 36 |
|
| 37 |
|
| 38 |
/* |
| 39 |
* Application instance implementation |
| 40 |
*/ |
| 41 |
|
| 42 |
////@begin implement app |
| 43 |
IMPLEMENT_APP( AEInstallerApp ) |
| 44 |
////@end implement app |
| 45 |
|
| 46 |
|
| 47 |
/* |
| 48 |
* AEInstallerApp type definition |
| 49 |
*/ |
| 50 |
|
| 51 |
IMPLEMENT_CLASS( AEInstallerApp, wxApp ) |
| 52 |
|
| 53 |
|
| 54 |
/* |
| 55 |
* AEInstallerApp event table definition |
| 56 |
*/ |
| 57 |
|
| 58 |
BEGIN_EVENT_TABLE( AEInstallerApp, wxApp ) |
| 59 |
|
| 60 |
////@begin AEInstallerApp event table entries |
| 61 |
////@end AEInstallerApp event table entries |
| 62 |
|
| 63 |
END_EVENT_TABLE() |
| 64 |
|
| 65 |
|
| 66 |
/* |
| 67 |
* Constructor for AEInstallerApp |
| 68 |
*/ |
| 69 |
|
| 70 |
AEInstallerApp::AEInstallerApp() |
| 71 |
{ |
| 72 |
Init(); |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
/* |
| 77 |
* Member initialisation |
| 78 |
*/ |
| 79 |
|
| 80 |
void AEInstallerApp::Init() |
| 81 |
{ |
| 82 |
////@begin AEInstallerApp member initialisation |
| 83 |
////@end AEInstallerApp member initialisation |
| 84 |
} |
| 85 |
|
| 86 |
/* |
| 87 |
* Initialisation for AEInstallerApp |
| 88 |
*/ |
| 89 |
|
| 90 |
bool AEInstallerApp::OnInit() |
| 91 |
{ |
| 92 |
////@begin AEInstallerApp initialisation |
| 93 |
// Remove the comment markers above and below this block |
| 94 |
// to make permanent changes to the code. |
| 95 |
|
| 96 |
#if wxUSE_XPM |
| 97 |
wxImage::AddHandler(new wxXPMHandler); |
| 98 |
#endif |
| 99 |
#if wxUSE_LIBPNG |
| 100 |
wxImage::AddHandler(new wxPNGHandler); |
| 101 |
#endif |
| 102 |
#if wxUSE_LIBJPEG |
| 103 |
wxImage::AddHandler(new wxJPEGHandler); |
| 104 |
#endif |
| 105 |
#if wxUSE_GIF |
| 106 |
wxImage::AddHandler(new wxGIFHandler); |
| 107 |
#endif |
| 108 |
MainWindow* mainWindow = new MainWindow( NULL ); |
| 109 |
mainWindow->Show(true); |
| 110 |
////@end AEInstallerApp initialisation |
| 111 |
TheWindow = mainWindow; |
| 112 |
|
| 113 |
#ifndef WIN32 |
| 114 |
// CIP: test for the third-party mono framework, because without it, on Mac, we are up a creek |
| 115 |
|
| 116 |
|
| 117 |
if (!monoPresent) // abort! abort! abort! |
| 118 |
{ |
| 119 |
// CIP: disable window controls, present alert with URL to download mono, alert window has one button, "Quit" |
| 120 |
} |
| 121 |
#endif |
| 122 |
|
| 123 |
//anything after this is done after the window appears... |
| 124 |
if ( !exists("../GameDataFolder") ) { |
| 125 |
wxMessageDialog* YesNoDialog = new wxMessageDialog(TheWindow, "You haven't globalized yet! \nYou must globalize to use the Anniversary Edition framework. \nWould you like to globalize now? (This could take a while...)\n(Selecting \"No\" will exit this program...)", "AE Installer Alert", wxYES_NO | wxICON_EXCLAMATION , wxDefaultPosition); |
| 126 |
|
| 127 |
if (YesNoDialog->ShowModal() == wxID_NO) { //if the user said no... |
| 128 |
TheWindow->Close(); |
| 129 |
} |
| 130 |
else { |
| 131 |
TheWindow->InstallButton->Disable(); |
| 132 |
TheWindow->ReglobalizeButton->Disable(); |
| 133 |
|
| 134 |
#ifdef WIN32 |
| 135 |
|
| 136 |
boost::thread thrd3(globalizeData); |
| 137 |
//globalizeData(); |
| 138 |
//boost::thread::create_thread(&globalizeData); |
| 139 |
// boost::thread_group Tg; |
| 140 |
// Tg.create_thread( &globalizeData(), this ); |
| 141 |
#else |
| 142 |
globalizeData(); |
| 143 |
#endif |
| 144 |
|
| 145 |
TheWindow->InstallButton->Enable(); |
| 146 |
TheWindow->ReglobalizeButton->Enable(); |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
return true; |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
void setStatusArea( string s ) { |
| 155 |
wxString wxs(s.c_str(), wxConvUTF8); |
| 156 |
|
| 157 |
TheWindow->StatusArea->SetStatusText( wxs ); |
| 158 |
//TheWindow->StatusArea->SetStatusText(s.c_str()); |
| 159 |
//StatusArea->SetStatusText(_(s.c_str())); |
| 160 |
//(*TheStatusBar)->SetStatusText(_(s.c_str())); |
| 161 |
//AEInstallerApp:: |
| 162 |
// TheWindow->StatusArea->SetStatusText("hi"); |
| 163 |
//mainWindow |
| 164 |
//itemFrame1->StatusArea->SetStatusText(_"lol"); |
| 165 |
//MainWindow.StatusArea->SetStatusText("hi"); |
| 166 |
// class AbstractStatusNotifier { public: virtual void NotifyStatus(const wxString &statusString) = 0; }; |
| 167 |
//class StatusBarStatusNotifier : public AbstractStatusNotifier { wxStatusBar *statusbar; StatusBarStatusNotifier(wxStatusBar *bar) : statusbar(bar) { } ; |
| 168 |
//void NotifyStatus(const wxString &status) { statusbar->SetStatus(status); } } |
| 169 |
|
| 170 |
|
| 171 |
//MainWindow::StatusArea-> |
| 172 |
//MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1); |
| 173 |
|
| 174 |
//MainWindow::StatusBar->SetLabel("Importing Files..."); |
| 175 |
//StatusBar->SetLabel(s); |
| 176 |
//->SetLabel(s); |
| 177 |
|
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
/* |
| 182 |
* Cleanup for AEInstallerApp |
| 183 |
*/ |
| 184 |
|
| 185 |
int AEInstallerApp::OnExit() |
| 186 |
{ |
| 187 |
////@begin AEInstallerApp cleanup |
| 188 |
return wxApp::OnExit(); |
| 189 |
////@end AEInstallerApp cleanup |
| 190 |
} |
| 191 |
void doglobalizeData() { |
| 192 |
//TheWindow->Disable(); |
| 193 |
globalizeData(); |
| 194 |
#ifdef WIN32 |
| 195 |
while(1) Sleep(-1); |
| 196 |
#endif |
| 197 |
//TheWindow->Enable(); |
| 198 |
//setStatusArea((string)"Test1"); |
| 199 |
} |