comparison src/main.cpp @ 5:e3b10fb860b3

release v1.0.
author pyon@macmini
date Mon, 22 Oct 2018 22:17:02 +0900
parents 06342fc544e4
children 9a8b581c1993
comparison
equal deleted inserted replaced
4:06342fc544e4 5:e3b10fb860b3
1 // Filename : main.cpp 1 // Filename : main.cpp
2 // Last Change: 2018-10-12 金 16:17:39. 2 // Last Change: 2018-10-22 月 16:14:28.
3 // 3 //
4 #include "id.h" 4 #include "id.h"
5 #include "main.h" 5 #include "main.h"
6 #include "auth.h" 6 #include "auth.h"
7 #include "rsearcher.h" 7 #include "rsearcher.h"
24 24
25 wxImage::AddHandler( new wxJPEGHandler ); 25 wxImage::AddHandler( new wxJPEGHandler );
26 wxImage::AddHandler( new wxPNGHandler ); 26 wxImage::AddHandler( new wxPNGHandler );
27 InitSetting(); 27 InitSetting();
28 28
29 wxBitmap bmp; 29 // Splash Screen
30 if ( bmp.LoadFile( wxT( "./image/startup.png" ), wxBITMAP_TYPE_PNG ) ){ 30 wxFileSystem::AddHandler( new wxZipFSHandler );
31 wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 4000, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP ); 31 wxFileSystem* fs = new wxFileSystem();
32 wxString archive = wxT( "file:///./myapp.bin" );
33 for ( int i = 0; i < 11; i++ ) {
34 wxFSFile* file = fs->OpenFile( archive + wxString::Format( wxT( "#zip:startup%02d.png" ), i ) );
35 if ( file ) {
36 wxInputStream* s = file->GetStream();
37 wxImage image( *s, wxBITMAP_TYPE_PNG );
38 wxBitmap bmp = wxBitmap( image );
39 wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 3000, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP );
40 delete file;
41 }
42 wxMilliSleep( 250 );
32 } 43 }
33 44
34 AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "Check User" ), wxDefaultPosition, wxDefaultSize, wxCAPTION ); 45 unsigned int seed = (unsigned int)time( 0 );
46 srand( seed );
47 int n = rand() % 13;
48 wxFSFile* file = fs->OpenFile( archive + wxString::Format( wxT( "#zip:%02d.jpg" ), n ) );
49 if ( file ) {
50 wxInputStream* s = file->GetStream();
51 wxFileOutputStream of( wxT( "./image/hello.jpg" ) );
52 s->Read( of );
53 delete file;
54 }
55 delete fs;
56
57 // Login Dialog
58 AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "Who are you ?" ), wxDefaultPosition, wxDefaultSize, wxCAPTION );
35 authdlg->SetServer( m_server ); 59 authdlg->SetServer( m_server );
36 60 if ( !authdlg->LoadDB() ) {
37 MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxT( "Re:Searcher" ), wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE ); 61 authdlg->Destroy();
38 mainframe->SetServer( m_server ); 62 return false;
39 63 }
40 if ( develop ) {
41 authdlg->InDevelop( true );
42 mainframe->InDevelop( true );
43 }
44 64
45 if ( authdlg->ShowModal() == wxID_OK ) { 65 if ( authdlg->ShowModal() == wxID_OK ) {
66 wxString ui = wxString::Format( wxT( "./image/" ) + authdlg->GetUser() + wxT( ".jpg" ) );
67 if ( wxFileExists( ui ) ) wxCopyFile( ui, wxT( "./image/hello.jpg" ), true );
68
69 // Main Window
70 MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxEmptyString, wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE );
71 mainframe->InDevelop( true );
72 mainframe->SetServer( m_server );
46 mainframe->SetUser( authdlg->GetUser() ); 73 mainframe->SetUser( authdlg->GetUser() );
74 mainframe->LoadDB();
75 mainframe->SetTitle( wxT( "Re:Searcher - " ) + authdlg->GetUser() );
47 mainframe->Show( true ); 76 mainframe->Show( true );
48 } else { 77 //mainframe->Destroy();
49 mainframe->Destroy();
50 } 78 }
51 authdlg->Destroy(); 79 authdlg->Destroy();
52 80
53 return true; 81 return true;
54 } 82 }