mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 15:20:08 +02:00
almost done
This commit is contained in:
parent
f210be32dc
commit
a5f9283bde
4 changed files with 105 additions and 34 deletions
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
- (double) getProgressPercentage
|
- (double) getProgressPercentage
|
||||||
{
|
{
|
||||||
return (self.progressPercentage * .90) + (self.taskProgressPercentage * .10);
|
return (self.progressPercentage * 0.50) + (self.taskProgressPercentage * 0.50);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) downloadDomainContent:(NSString *)domainContentUrl
|
- (void) downloadDomainContent:(NSString *)domainContentUrl
|
||||||
|
@ -24,9 +24,9 @@
|
||||||
|
|
||||||
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite {
|
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite {
|
||||||
CGFloat prog = (float)totalBytesWritten/totalBytesExpectedToWrite;
|
CGFloat prog = (float)totalBytesWritten/totalBytesExpectedToWrite;
|
||||||
NSLog(@"domain content downloaded %d%%", (int)(100.0*prog));
|
NSLog(@"domain content downloaded %f", (100.0*prog));
|
||||||
|
|
||||||
self.progressPercentage = (100.0 * prog);
|
self.progressPercentage = (int)(100.0 * prog);
|
||||||
[[Launcher sharedLauncher] updateProgressIndicator];
|
[[Launcher sharedLauncher] updateProgressIndicator];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updatePercentage:(NSTimer*) timer {
|
- (void) updatePercentage:(NSTimer*) timer {
|
||||||
self.taskProgressPercentage += 3.0;
|
self.taskProgressPercentage += 4.0;
|
||||||
[[Launcher sharedLauncher] updateProgressIndicator];
|
[[Launcher sharedLauncher] updateProgressIndicator];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
@implementation LatestBuildRequest
|
@implementation LatestBuildRequest
|
||||||
|
|
||||||
- (NSInteger) getCurrentVersion {
|
- (NSInteger) getCurrentVersion {
|
||||||
NSInteger currentVersion;
|
/*NSInteger currentVersion;
|
||||||
@try {
|
@try {
|
||||||
NSString* interfaceAppPath = [[Launcher.sharedLauncher getAppPath] stringByAppendingString:@"interface.app"];
|
NSString* interfaceAppPath = [[Launcher.sharedLauncher getAppPath] stringByAppendingString:@"interface.app"];
|
||||||
NSError * error = nil;
|
NSError * error = nil;
|
||||||
|
@ -19,8 +19,8 @@
|
||||||
} @catch (NSException *exception) {
|
} @catch (NSException *exception) {
|
||||||
NSLog(@"an exception was thrown: %@", exception);
|
NSLog(@"an exception was thrown: %@", exception);
|
||||||
currentVersion = [Settings.sharedSettings latestBuildVersion];
|
currentVersion = [Settings.sharedSettings latestBuildVersion];
|
||||||
}
|
}*/
|
||||||
return currentVersion;
|
return [Settings.sharedSettings latestBuildVersion];//currentVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) requestLatestBuildInfo {
|
- (void) requestLatestBuildInfo {
|
||||||
|
|
|
@ -34,6 +34,7 @@ typedef enum LoginErrorTypes
|
||||||
@property (nonatomic, retain) NSString* domainURL;
|
@property (nonatomic, retain) NSString* domainURL;
|
||||||
@property (nonatomic, retain) NSString* domainContentUrl;
|
@property (nonatomic, retain) NSString* domainContentUrl;
|
||||||
@property (nonatomic, retain) NSString* domainScriptsUrl;
|
@property (nonatomic, retain) NSString* domainScriptsUrl;
|
||||||
|
@property (nonatomic, retain) NSString* interfaceDownloadUrl;
|
||||||
@property (nonatomic, retain) DownloadInterface* downloadInterface;
|
@property (nonatomic, retain) DownloadInterface* downloadInterface;
|
||||||
@property (nonatomic, retain) CredentialsRequest* credentialsRequest;
|
@property (nonatomic, retain) CredentialsRequest* credentialsRequest;
|
||||||
@property (nonatomic, retain) DownloadDomainContent* downloadDomainContent;
|
@property (nonatomic, retain) DownloadDomainContent* downloadDomainContent;
|
||||||
|
@ -44,9 +45,13 @@ typedef enum LoginErrorTypes
|
||||||
@property (nonatomic) BOOL waitingForCredentialReponse;
|
@property (nonatomic) BOOL waitingForCredentialReponse;
|
||||||
@property (nonatomic) BOOL gotCredentialResponse;
|
@property (nonatomic) BOOL gotCredentialResponse;
|
||||||
@property (nonatomic) BOOL waitingForInterfaceToTerminate;
|
@property (nonatomic) BOOL waitingForInterfaceToTerminate;
|
||||||
|
@property (nonatomic) BOOL shouldDownloadInterface;
|
||||||
|
@property (nonatomic) BOOL latestBuildRequestFinished;
|
||||||
|
@property (nonatomic, assign) NSTimer* updateProgressIndicatorTimer;
|
||||||
@property (nonatomic, assign, readwrite) ProcessState processState;
|
@property (nonatomic, assign, readwrite) ProcessState processState;
|
||||||
@property (nonatomic, assign, readwrite) LoginError loginError;
|
@property (nonatomic, assign, readwrite) LoginError loginError;
|
||||||
@property (nonatomic, assign) NSProgressIndicator* progressIndicator;
|
@property (nonatomic, assign) NSProgressIndicator* progressIndicator;
|
||||||
|
@property (nonatomic) double progressTarget;
|
||||||
|
|
||||||
- (NSProgressIndicator*) getProgressView;
|
- (NSProgressIndicator*) getProgressView;
|
||||||
- (void) setProgressView:(NSProgressIndicator*) aProgressIndicator;
|
- (void) setProgressView:(NSProgressIndicator*) aProgressIndicator;
|
||||||
|
@ -79,9 +84,13 @@ typedef enum LoginErrorTypes
|
||||||
- (NSString*) getDownloadContentFilename;
|
- (NSString*) getDownloadContentFilename;
|
||||||
- (NSString*) getDownloadScriptsFilename;
|
- (NSString*) getDownloadScriptsFilename;
|
||||||
- (NSString*) getDownloadFilename;
|
- (NSString*) getDownloadFilename;
|
||||||
|
- (void) startUpdateProgressIndicatorTimer;
|
||||||
|
- (void) endUpdateProgressIndicatorTimer;
|
||||||
- (BOOL) isLoadedIn;
|
- (BOOL) isLoadedIn;
|
||||||
- (NSString*) getAppPath;
|
- (NSString*) getAppPath;
|
||||||
- (void) updateProgressIndicator;
|
- (void) updateProgressIndicator;
|
||||||
|
- (void) setShouldDownloadInterface:(BOOL) shouldDownlaod;
|
||||||
|
- (BOOL) getShouldDownloadInterface;
|
||||||
|
|
||||||
+ (id) sharedLauncher;
|
+ (id) sharedLauncher;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -40,6 +40,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
self.gotCredentialResponse = FALSE;
|
self.gotCredentialResponse = FALSE;
|
||||||
self.waitingForCredentialReponse = FALSE;
|
self.waitingForCredentialReponse = FALSE;
|
||||||
self.waitingForInterfaceToTerminate = FALSE;
|
self.waitingForInterfaceToTerminate = FALSE;
|
||||||
|
self.latestBuildRequestFinished = FALSE;
|
||||||
self.userToken = nil;
|
self.userToken = nil;
|
||||||
self.progressIndicator = nil;
|
self.progressIndicator = nil;
|
||||||
self.processState = DOWNLOADING_INTERFACE;
|
self.processState = DOWNLOADING_INTERFACE;
|
||||||
|
@ -87,16 +88,23 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
double oldValue = progressIndicator.doubleValue;
|
double oldValue = progressIndicator.doubleValue;
|
||||||
double contentPercentage = [self.downloadDomainContent getProgressPercentage];
|
double contentPercentage = [self.downloadDomainContent getProgressPercentage];
|
||||||
double interfacePercentage = [self.downloadInterface getProgressPercentage];
|
double interfacePercentage = [self.downloadInterface getProgressPercentage];
|
||||||
double currentTotalPercentage = (contentPercentage * 0.5) + (interfacePercentage * 0.5);
|
double currentTotalPercentage = self.progressTarget;
|
||||||
|
if (self.shouldDownloadInterface) {
|
||||||
|
currentTotalPercentage = (contentPercentage * 0.5) + (interfacePercentage * 0.5);
|
||||||
|
} else {
|
||||||
|
currentTotalPercentage = contentPercentage;
|
||||||
|
}
|
||||||
|
self.progressTarget = currentTotalPercentage;
|
||||||
|
|
||||||
//[progressIndicator incrementBy: (currentTotalPercentage - oldValue)];
|
//[progressIndicator incrementBy: (currentTotalPercentage - oldValue)];
|
||||||
progressIndicator.doubleValue = [self lerp:oldValue :currentTotalPercentage :0.7];
|
//progressIndicator.doubleValue = [self lerp:oldValue :currentTotalPercentage :0.7];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (double) lerp:(double) pointA :(double) pointB :(double) interp
|
- (double) lerp:(double) pointA :(double) pointB :(double) interp
|
||||||
{
|
{
|
||||||
|
//NSLog(@"PointA: %f PointB: %f interp: %f", pointA, pointB, interp);
|
||||||
double lerpValue = pointA + interp * (pointB - pointA);
|
double lerpValue = pointA + interp * (pointB - pointA);
|
||||||
NSLog(@"----> lerp value: %f", lerpValue);
|
//NSLog(@"----> lerp value: %f", lerpValue);
|
||||||
return lerpValue;
|
return lerpValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +138,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
|
|
||||||
-(NSProgressIndicator*) getProgressView
|
-(NSProgressIndicator*) getProgressView
|
||||||
{
|
{
|
||||||
NSLog(@"Getting progressIndicator %@", self.progressIndicator);
|
//NSLog(@"Getting progressIndicator %@", self.progressIndicator);
|
||||||
return self.progressIndicator;
|
return self.progressIndicator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,19 +150,12 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
|
|
||||||
- (void) checkLoginStatus
|
- (void) checkLoginStatus
|
||||||
{
|
{
|
||||||
if ([self isLoadedIn]) {
|
[self.latestBuildRequest requestLatestBuildInfo];
|
||||||
Launcher* sharedLauncher = [Launcher sharedLauncher];
|
[NSTimer scheduledTimerWithTimeInterval:2.0
|
||||||
[sharedLauncher setCurrentProcessState:CHECKING_UPDATE];
|
target:self
|
||||||
ProcessScreen* processScreen = [[ProcessScreen alloc] initWithNibName:@"ProcessScreen" bundle:nil];
|
selector:@selector(onSplashScreenTimerFinished:)
|
||||||
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: processScreen];
|
userInfo:nil
|
||||||
[self.latestBuildRequest requestLatestBuildInfo];
|
repeats:NO];
|
||||||
} else {
|
|
||||||
[NSTimer scheduledTimerWithTimeInterval:2.0
|
|
||||||
target:self
|
|
||||||
selector:@selector(onSplashScreenTimerFinished:)
|
|
||||||
userInfo:nil
|
|
||||||
repeats:NO];
|
|
||||||
}
|
|
||||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];
|
[[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +179,31 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
return self.scriptsFilename;
|
return self.scriptsFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) startUpdateProgressIndicatorTimer
|
||||||
|
{
|
||||||
|
self.progressTarget = 0.0;
|
||||||
|
self.updateProgressIndicatorTimer = [NSTimer scheduledTimerWithTimeInterval: 0.0016
|
||||||
|
target: self
|
||||||
|
selector: @selector(updateIndicator:)
|
||||||
|
userInfo:nil
|
||||||
|
repeats: YES];
|
||||||
|
|
||||||
|
[[NSRunLoop mainRunLoop] addTimer:self.updateProgressIndicatorTimer forMode:NSRunLoopCommonModes];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) endUpdateProgressIndicatorTimer
|
||||||
|
{
|
||||||
|
[self.updateProgressIndicatorTimer invalidate];
|
||||||
|
self.updateProgressIndicatorTimer = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) updateIndicator:(NSTimer*) timer
|
||||||
|
{
|
||||||
|
NSProgressIndicator* progressIndicator = [self getProgressView];
|
||||||
|
double oldValue = progressIndicator.doubleValue;
|
||||||
|
progressIndicator.doubleValue = [self lerp:oldValue :self.progressTarget :0.3];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)didTerminateApp:(NSNotification *)notification {
|
- (void)didTerminateApp:(NSNotification *)notification {
|
||||||
if (self.waitingForInterfaceToTerminate) {
|
if (self.waitingForInterfaceToTerminate) {
|
||||||
NSString* appName = [notification.userInfo valueForKey:@"NSApplicationName"];
|
NSString* appName = [notification.userInfo valueForKey:@"NSApplicationName"];
|
||||||
|
@ -232,6 +258,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
- (void) displayNameEntered:(NSString*)aDiplayName
|
- (void) displayNameEntered:(NSString*)aDiplayName
|
||||||
{
|
{
|
||||||
self.processState = DOWNLOADING_INTERFACE;
|
self.processState = DOWNLOADING_INTERFACE;
|
||||||
|
[self startUpdateProgressIndicatorTimer];
|
||||||
ProcessScreen* processScreen = [[ProcessScreen alloc] initWithNibName:@"ProcessScreen" bundle:nil];
|
ProcessScreen* processScreen = [[ProcessScreen alloc] initWithNibName:@"ProcessScreen" bundle:nil];
|
||||||
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: processScreen];
|
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: processScreen];
|
||||||
[self.downloadDomainContent downloadDomainContent:self.domainContentUrl];
|
[self.downloadDomainContent downloadDomainContent:self.domainContentUrl];
|
||||||
|
@ -240,8 +267,12 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
|
|
||||||
- (void) domainContentDownloadFinished
|
- (void) domainContentDownloadFinished
|
||||||
{
|
{
|
||||||
//.[self.downloadScripts downloadScripts:self.domainScriptsUrl];
|
if (self.shouldDownloadInterface) {
|
||||||
[self.latestBuildRequest requestLatestBuildInfo];
|
[self.downloadInterface downloadInterface: self.interfaceDownloadUrl];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[self interfaceFinishedDownloading];
|
||||||
|
//[self.latestBuildRequest requestLatestBuildInfo];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) domainScriptsDownloadFinished
|
- (void) domainScriptsDownloadFinished
|
||||||
|
@ -268,10 +299,14 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
|
|
||||||
- (void) interfaceFinishedDownloading
|
- (void) interfaceFinishedDownloading
|
||||||
{
|
{
|
||||||
if (self.processState == DOWNLOADING_INTERFACE) {
|
[self endUpdateProgressIndicatorTimer];
|
||||||
self.processState = RUNNING_INTERFACE_AFTER_DOWNLOAD;
|
NSProgressIndicator* progressIndicator = [self getProgressView];
|
||||||
|
progressIndicator.doubleValue = self.progressTarget;
|
||||||
|
Launcher* sharedLauncher = [Launcher sharedLauncher];
|
||||||
|
if ([sharedLauncher currentProccessState] == DOWNLOADING_INTERFACE) {
|
||||||
|
[sharedLauncher setCurrentProcessState: RUNNING_INTERFACE_AFTER_DOWNLOAD];
|
||||||
} else {
|
} else {
|
||||||
self.processState = RUNNING_INTERFACE_AFTER_UPDATE;
|
[sharedLauncher setCurrentProcessState: RUNNING_INTERFACE_AFTER_UPDATE];
|
||||||
}
|
}
|
||||||
ProcessScreen* processScreen = [[ProcessScreen alloc] initWithNibName:@"ProcessScreen" bundle:nil];
|
ProcessScreen* processScreen = [[ProcessScreen alloc] initWithNibName:@"ProcessScreen" bundle:nil];
|
||||||
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: processScreen];
|
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: processScreen];
|
||||||
|
@ -310,17 +345,34 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
|
|
||||||
- (void) shouldDownloadLatestBuild:(BOOL) shouldDownload :(NSString*) downloadUrl
|
- (void) shouldDownloadLatestBuild:(BOOL) shouldDownload :(NSString*) downloadUrl
|
||||||
{
|
{
|
||||||
if (shouldDownload) {
|
self.shouldDownloadInterface = shouldDownload;
|
||||||
|
self.interfaceDownloadUrl = downloadUrl;
|
||||||
|
self.latestBuildRequestFinished = TRUE;
|
||||||
|
NSLog(@"------> FINISHED ->>>>>>>>");
|
||||||
|
/*if (shouldDownload) {
|
||||||
[self.downloadInterface downloadInterface: downloadUrl];
|
[self.downloadInterface downloadInterface: downloadUrl];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
[self launchInterface];
|
[self launchInterface];*/
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)onSplashScreenTimerFinished:(NSTimer *)timer
|
-(void)onSplashScreenTimerFinished:(NSTimer *)timer
|
||||||
{
|
{
|
||||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];
|
if ([self isLoadedIn]) {
|
||||||
[self showLoginScreen];
|
Launcher* sharedLauncher = [Launcher sharedLauncher];
|
||||||
|
[sharedLauncher setCurrentProcessState:CHECKING_UPDATE];
|
||||||
|
NSLog(@"Should Downlaod: %@", self.shouldDownloadInterface ? @"True" : @"False");
|
||||||
|
if (self.shouldDownloadInterface) {
|
||||||
|
ProcessScreen* processScreen = [[ProcessScreen alloc] initWithNibName:@"ProcessScreen" bundle:nil];
|
||||||
|
[[[[NSApplication sharedApplication] windows] objectAtIndex:0] setContentViewController: processScreen];
|
||||||
|
[self.downloadInterface downloadInterface: self.interfaceDownloadUrl];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[self interfaceFinishedDownloading];
|
||||||
|
} else {
|
||||||
|
[[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE];
|
||||||
|
[self showLoginScreen];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setCurrentProcessState:(ProcessState)aProcessState
|
-(void)setCurrentProcessState:(ProcessState)aProcessState
|
||||||
|
@ -402,7 +454,11 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
}
|
}
|
||||||
[workspace launchApplicationAtURL:url options:NSWorkspaceLaunchNewInstance configuration:[NSDictionary dictionaryWithObject:arguments forKey:NSWorkspaceLaunchConfigurationArguments] error:&error];
|
[workspace launchApplicationAtURL:url options:NSWorkspaceLaunchNewInstance configuration:[NSDictionary dictionaryWithObject:arguments forKey:NSWorkspaceLaunchConfigurationArguments] error:&error];
|
||||||
|
|
||||||
[NSApp terminate:self];
|
NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval: 3.0
|
||||||
|
target: self
|
||||||
|
selector: @selector(exitLauncher:)
|
||||||
|
userInfo:nil
|
||||||
|
repeats: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ProcessState) currentProccessState
|
- (ProcessState) currentProccessState
|
||||||
|
@ -410,4 +466,10 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
|
||||||
return self.processState;
|
return self.processState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void) exitLauncher:(NSTimer*) timer
|
||||||
|
{
|
||||||
|
[NSApp terminate:self];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue