diff src/main.cpp @ 9:ae89ce4793d8

add satellite-view.
author pyon@macmini
date Wed, 31 Oct 2018 20:10:29 +0900
parents 29829e98d510
children 36811fd22bd2
line wrap: on
line diff
--- a/src/main.cpp	Tue Oct 30 17:26:02 2018 +0900
+++ b/src/main.cpp	Wed Oct 31 20:10:29 2018 +0900
@@ -1,6 +1,7 @@
 // Filename   : main.cpp
-// Last Change: 2018-10-26 金 13:14:54.
+// Last Change: 2018-10-31 水 15:18:12.
 //
+
 #include "id.h"
 #include "main.h"
 #include "auth.h"
@@ -24,29 +25,19 @@
 
     wxImage::AddHandler( new wxJPEGHandler );
     wxImage::AddHandler( new wxPNGHandler  );
+	wxFileSystem::AddHandler( new wxZipFSHandler );
 	InitSetting();
 
 	// Main Window
 	MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxEmptyString, wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE );
 	mainframe->SetServer( m_serveraddr, m_serverport );
-	mainframe->GetDB();
+	if ( !mainframe->GetDB() ) {
+		mainframe->Destroy();
+		return true;
+	}
 
 	// Splash Screen
-	wxFileSystem::AddHandler( new wxZipFSHandler );
-	wxFileSystem* fs = new wxFileSystem();
-	wxString archive = wxT( "file:///./myapp.bin" );
-	for ( int i = 0; i < 11; i++ ) {
-		wxFSFile* file = fs->OpenFile( archive + wxString::Format( wxT( "#zip:startup%02d.png" ), i ) );
-		if ( file ) {
-			wxInputStream* s = file->GetStream();
-			wxImage image( *s, wxBITMAP_TYPE_PNG );
-			wxBitmap bmp = wxBitmap( image );
-			wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 2000, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP );
-			delete file;
-		}
-		wxMilliSleep( 150 );
-	}
-	delete fs;
+	SplashScreen( splash );
 
 	// User Dialgo
     AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "Who are you ?" ), wxDefaultPosition, wxDefaultSize, wxCAPTION );
@@ -64,6 +55,7 @@
 			srand( seed );
 			int n = rand() % 13;
 			wxFileSystem* fs = new wxFileSystem();
+			wxString archive = wxT( "file:///./myapp.bin" );
 			wxFSFile* file = fs->OpenFile( archive + wxString::Format( wxT( "#zip:%02d.jpg" ), n ) );
 			if ( file ) {
 				wxInputStream* s = file->GetStream();
@@ -114,12 +106,16 @@
 		config->Read( wxT( "address" ), &m_serveraddr );
 		config->Read( wxT( "port" ),    &m_serverport );
 	}
-    delete config;
 
     if ( m_serveraddr.IsSameAs( wxEmptyString, false ) ) {
         m_serveraddr = wxT( "192.168.21.151" );	// nginx
         m_serverport = 80;
 	}
+
+    config->SetPath( wxT( "/Misc" ) );
+    config->Read( wxT( "splash" ), &splash );
+
+    delete config;
 }
 
 void MyApp::SaveSetting()
@@ -134,6 +130,26 @@
     delete config;
 }
 
+void MyApp::SplashScreen( int ms )
+{
+	if ( ms < 0 ) return;
+
+	wxFileSystem* fs = new wxFileSystem();
+	wxString archive = wxT( "file:///./myapp.bin" );
+	for ( int i = 0; i < 11; i++ ) {
+		wxFSFile* file = fs->OpenFile( archive + wxString::Format( wxT( "#zip:startup%02d.png" ), i ) );
+		if ( file ) {
+			wxInputStream* s = file->GetStream();
+			wxImage image( *s, wxBITMAP_TYPE_PNG );
+			wxBitmap bmp = wxBitmap( image );
+			wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 2000, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP );
+			delete file;
+		}
+		wxMilliSleep( ms );
+	}
+	delete fs;
+}
+
 void MyApp::RemoveFile( wxString pattern )
 {
 	wxString file = wxFindFirstFile( pattern );