source: AE/Installer/trunk/source/aeinstallerapp.cpp@ 397

Last change on this file since 397 was 393, checked in by iritscen, 15 years ago

Implemented escapePath() to fix path bug on Mac side.

File size: 5.7 KB
Line 
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
16using 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
43IMPLEMENT_APP( AEInstallerApp )
44////@end implement app
45
46
47/*
48 * AEInstallerApp type definition
49 */
50
51IMPLEMENT_CLASS( AEInstallerApp, wxApp )
52
53
54/*
55 * AEInstallerApp event table definition
56 */
57
58BEGIN_EVENT_TABLE( AEInstallerApp, wxApp )
59
60////@begin AEInstallerApp event table entries
61////@end AEInstallerApp event table entries
62
63END_EVENT_TABLE()
64
65
66/*
67 * Constructor for AEInstallerApp
68 */
69
70AEInstallerApp::AEInstallerApp()
71{
72 Init();
73}
74
75
76/*
77 * Member initialisation
78 */
79
80void AEInstallerApp::Init()
81{
82 ////@begin AEInstallerApp member initialisation
83 ////@end AEInstallerApp member initialisation
84}
85
86/*
87 * Initialisation for AEInstallerApp
88 */
89
90bool 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 // test for the third-party mono framework, because without it, on Mac, we are up a creek
115 char monoCommand[300] = "which mono >> ";
116 strcat(monoCommand, escapePath(system_complete("mono_check.log").string()).c_str());
117 system(monoCommand);
118 fstream file;
119 file.open("mono_check.log");
120 string line;
121 int line_count = 0;
122 while (!file.eof())
123 {
124 line_count++;
125 getline(file, line);
126 }
127 file.close();
128 remove("mono_check.log");
129
130 if (line_count <= 1) // this means that "which mono" returned nothing -- abort! abort! abort!
131 {
132 wxMessageDialog* MonoDialogOfDeath = new wxMessageDialog(TheWindow, "You don't have 'mono' installed! 'mono' is a command-line tool required by the Edition. You can download it from:\nhttp://www.go-mono.com/mono-downloads/download.html (OS X 10.4+) or\nhttp://edt.oni2.net/AE/MonoFramework10.3.dmg (OS X 10.3)\n\nPlease install 'mono', then open this Installer again.", "AE Installer Alert", wxOK | wxICON_EXCLAMATION , wxDefaultPosition);
133 MonoDialogOfDeath->ShowModal();
134 TheWindow->Close();
135 return true; // it's quittin' time, Joe
136 }
137#endif
138
139 //anything after this is done after the window appears...
140
141 if ( !exists("../GameDataFolder") )
142 {
143 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);
144
145 if (YesNoDialog->ShowModal() == wxID_NO) // if the user said no...
146 TheWindow->Close();
147 else
148 {
149 TheWindow->InstallButton->Disable();
150 TheWindow->ReglobalizeButton->Disable();
151
152#ifdef WIN32
153 boost::thread thrd3(globalizeData);
154 //globalizeData();
155 //boost::thread::create_thread(&globalizeData);
156 // boost::thread_group Tg;
157 // Tg.create_thread( &globalizeData(), this );
158#else
159 globalizeData();
160#endif
161
162 TheWindow->InstallButton->Enable();
163 TheWindow->ReglobalizeButton->Enable();
164 }
165 }
166
167 return true;
168}
169
170
171void setStatusArea( string s ) {
172 wxString wxs(s.c_str(), wxConvUTF8);
173
174 TheWindow->StatusArea->SetStatusText( wxs );
175 //TheWindow->StatusArea->SetStatusText(s.c_str());
176 //StatusArea->SetStatusText(_(s.c_str()));
177 //(*TheStatusBar)->SetStatusText(_(s.c_str()));
178 //AEInstallerApp::
179 // TheWindow->StatusArea->SetStatusText("hi");
180 //mainWindow
181 //itemFrame1->StatusArea->SetStatusText(_"lol");
182 //MainWindow.StatusArea->SetStatusText("hi");
183 // class AbstractStatusNotifier { public: virtual void NotifyStatus(const wxString &statusString) = 0; };
184 //class StatusBarStatusNotifier : public AbstractStatusNotifier { wxStatusBar *statusbar; StatusBarStatusNotifier(wxStatusBar *bar) : statusbar(bar) { } ;
185 //void NotifyStatus(const wxString &status) { statusbar->SetStatus(status); } }
186
187
188 //MainWindow::StatusArea->
189 //MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1);
190
191 //MainWindow::StatusBar->SetLabel("Importing Files...");
192 //StatusBar->SetLabel(s);
193 //->SetLabel(s);
194
195}
196
197
198/*
199 * Cleanup for AEInstallerApp
200 */
201
202int AEInstallerApp::OnExit()
203{
204 ////@begin AEInstallerApp cleanup
205 return wxApp::OnExit();
206 ////@end AEInstallerApp cleanup
207}
208void doglobalizeData() {
209 //TheWindow->Disable();
210 globalizeData();
211#ifdef WIN32
212 while(1) Sleep(-1);
213#endif
214 //TheWindow->Enable();
215 //setStatusArea((string)"Test1");
216}
Note: See TracBrowser for help on using the repository browser.