Changes for compatibility with FT1.2 (DSO changes).

ver1_5_1
Da Woon Jung 2005-11-24 16:49:55 +00:00
parent b70f9d7f10
commit bb9b27c7f9
3 changed files with 40 additions and 36 deletions

View File

@ -14,7 +14,7 @@
#include "celestiacore.h"
#include "celestia.h"
#include "selection.h"
#include "starBrowser.h"
#include "starbrowser.h"
@implementation BrowserWindowController
@ -36,18 +36,29 @@ static CelestiaCore *appCore;
- (NSDictionary*) deepSkyDict
{
int objCount = 100;
NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity: objCount];
int objCount;
NSMutableDictionary* newDict;
int i = 0;
DeepSkyCatalog* catalog = appCore->getSimulation()->getUniverse()->getDeepSkyCatalog();
for (DeepSkyCatalog::const_iterator iter = catalog->begin();
i<objCount && iter != catalog->end(); iter++)
DSODatabase* catalog = appCore->getSimulation()->getUniverse()->getDSOCatalog();
DeepSkyObject *obj;
NSString *name;
objCount = catalog->size();
if (objCount > 100)
objCount = 100;
newDict = [NSMutableDictionary dictionaryWithCapacity: objCount];
for (; i < objCount; ++i)
{
DeepSkyObject* obj = *iter;
NSString* name = [NSString stringWithStdString: obj->getName() ];
[newDict setObject: name forKey: name];
i++;
obj = catalog->getDSO(i);
if (obj)
{
name = [NSString stringWithStdString:
catalog->getDSOName(obj)];
[newDict setObject: name forKey: name];
}
}
[newDict setObject: [[newDict allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] forKey: @"_keys" ];
[newDict setObject: @"" forKey: @"_path" ];
return newDict;

View File

@ -6,20 +6,19 @@
// Copyright (c) 2002 Chris Laurel. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CelestiaVector.h"
@interface CelestiaGalaxy : NSObject {
NSValue* _data;
}
-(NSString*)type;
-(void)setType:(NSString*)s;
//-(void)setType:(NSString*)s;
-(NSString *)name;
-(CelestiaVector*)orientation;
-(void)setOrientation:(CelestiaVector*)q;
-(CelestiaVector*)position;
-(void)setPosition:(CelestiaVector*)q;
-(void)setName:(NSString*)s;
//-(void)setName:(NSString*)s;
-(NSNumber *)radius;
-(void)setRadius:(NSNumber*)r;
-(NSNumber *)detail;

View File

@ -10,8 +10,10 @@
#import "CelestiaGalaxy_PrivateAPI.h"
#import "CelestiaVector_PrivateAPI.h"
#import "NSString_ObjCPlusPlus.h"
#import "CelestiaAppCore.h"
#include "celestiacore.h"
NSDictionary* galaxyTypeDict;
@implementation CelestiaGalaxy(PrivateAPI)
-(CelestiaGalaxy*)initWithGalaxy:(Galaxy*)g
{
@ -30,10 +32,7 @@ NSDictionary* galaxyTypeDict;
*/
@implementation CelestiaGalaxy
+(void)initialize
{
galaxyTypeDict = [[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:Galaxy::S0],@"S0",[NSNumber numberWithInt:Galaxy::Sa],@"Sa",[NSNumber numberWithInt:Galaxy::Sb],@"Sb",[NSNumber numberWithInt:Galaxy::Sc],@"Sc",[NSNumber numberWithInt:Galaxy::SBa],@"SBa",[NSNumber numberWithInt:Galaxy::SBb],@"SBb",[NSNumber numberWithInt:Galaxy::SBc],@"SBc",[NSNumber numberWithInt:Galaxy::E0],@"E0",[NSNumber numberWithInt:Galaxy::E1],@"E1",[NSNumber numberWithInt:Galaxy::E2],@"E2",[NSNumber numberWithInt:Galaxy::E2],@"E3",[NSNumber numberWithInt:Galaxy::E2],@"E4",[NSNumber numberWithInt:Galaxy::E2],@"E5",[NSNumber numberWithInt:Galaxy::E2],@"E6",[NSNumber numberWithInt:Galaxy::E2],@"E7",[NSNumber numberWithInt:Galaxy::Irr],@"Irr",nil,nil] retain];
}
-(void)dealloc
{
if (_data != nil) {
@ -44,22 +43,17 @@ NSDictionary* galaxyTypeDict;
}
-(NSString*)type
{
NSArray* keys = [galaxyTypeDict allKeys];
NSNumber* n = [NSNumber numberWithInt:[self galaxy]->getType()];
unsigned int i;
for (i=0;i<[keys count];i++) {
if ([[galaxyTypeDict objectForKey:[keys objectAtIndex:i]] isEqualToNumber:n])
return [keys objectAtIndex:i];
}
return @"Unknown";
}
-(void)setType:(NSString*)s
{
[self galaxy]->setType((Galaxy::GalaxyType)[[galaxyTypeDict objectForKey:s] intValue]);
return [NSString stringWithUTF8String:[self galaxy]->getType()];
}
//-(void)setType:(NSString*)s
//{
// [self galaxy]->setType([s stdString]);
//}
-(NSString *)name
{
return [NSString stringWithStdString:[self galaxy]->getName()];
return [NSString stringWithStdString:[[CelestiaAppCore sharedAppCore] appCore]->getSimulation()->getUniverse()->getDSOCatalog()->getDSOName([self galaxy])];
}
-(CelestiaVector*)orientation
{
@ -77,10 +71,10 @@ NSDictionary* galaxyTypeDict;
{
[self galaxy]->setPosition([q point3d]);
}
-(void)setName:(NSString*)s
{
[self galaxy]->setName([s stdString]);
}
//-(void)setName:(NSString*)s
//{
// [self galaxy]->setName([s stdString]);
//}
-(NSNumber *)radius
{
return [NSNumber numberWithFloat:[self galaxy]->getRadius()];
@ -97,4 +91,4 @@ NSDictionary* galaxyTypeDict;
{
[self galaxy]->setDetail([d floatValue]);
}
@end
@end