Oolite
Loading...
Searching...
No Matches
PlayerEntity(OOLoadSavePrivate) Category Reference

Instance Methods

(void) - setGuiToLoadCommanderScreen
(void) - setGuiToSaveCommanderScreen:
(void) - setGuiToOverwriteScreen:
(void) - lsCommanders:directory:pageNumber:highlightName:
(void) - showCommanderShip:
(int) - findIndexOfCommander:
(void) - nativeSavePlayer:
(BOOL) - existingNativeSave:
(void) - writePlayerToPath:
(NSComparisonResult) - sortCommanders [implementation]

Detailed Description

Definition at line 63 of file PlayerEntityLoadSave.m.

Method Documentation

◆ existingNativeSave:

- (BOOL) existingNativeSave: (NSString*) cdrName

Extends class PlayerEntity.

Definition at line 987 of file PlayerEntityLoadSave.m.

987 :(NSString*)cdrName
988{
989 NSString* dir = [[UNIVERSE gameController] playerFileDirectory];
990
991 NSString* savePath = [dir stringByAppendingPathComponent:[cdrName stringByAppendingPathExtension:@"oolite-save"]];
992 return [[NSFileManager defaultManager] fileExistsAtPath:savePath];
993}

◆ findIndexOfCommander:

- (int) findIndexOfCommander: (NSString*) cdrName

Extends class PlayerEntity.

Definition at line 1114 of file PlayerEntityLoadSave.m.

1114 :(NSString*)cdrName
1115{
1116 unsigned i;
1117 for (i = 0; i < [cdrDetailArray count]; i++) {
1118 NSString* currentName = [[cdrDetailArray oo_dictionaryAtIndex:i] oo_stringForKey:@"player_save_name" defaultValue:[[cdrDetailArray oo_dictionaryAtIndex:i] oo_stringForKey:@"player_name"]];
1119 if ([cdrName compare:currentName] == NSOrderedSame) {
1120 return i;
1121 }
1122 }
1123
1124 // not found!
1125 return -1;
1126}

References int().

Here is the call graph for this function:

◆ lsCommanders:directory:pageNumber:highlightName:

- (void) lsCommanders: (GuiDisplayGen*) gui
directory: (NSString*) directory
pageNumber: (int) page
highlightName: (NSString*) highlightName 

Extends class PlayerEntity.

Definition at line 823 of file PlayerEntityLoadSave.m.

823 :(GuiDisplayGen*)gui
824 directory:(NSString*)directory
825 pageNumber:(int)page
826 highlightName:(NSString*)highlightName
827{
828 NSFileManager* cdrFileManager = [NSFileManager defaultManager];
829 int rangeStart = STARTROW;
830 unsigned lastIndex;
831 unsigned i;
832 int row = STARTROW;
833
834 // cdrArray defined in PlayerEntity.h
835 NSArray* cdrArray = [cdrFileManager commanderContentsOfPath:directory];
836
837 // get commander details so a brief rundown of the commander's details may
838 // be displayed.
839 if (!cdrDetailArray)
840 cdrDetailArray = [[NSMutableArray alloc] init]; // alloc retains this so the retain further on in the code was unnecessary
841 else
842 [cdrDetailArray removeAllObjects];
843
844 [cdrDetailArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
845 @"YES", @"isParentFolder",
846 [directory stringByDeletingLastPathComponent], @"saved_game_path", nil]];
847
848 for (i = 0; i < [cdrArray count]; i++) {
849 NSString* path = [cdrArray objectAtIndex:i];
850 BOOL exists, isDirectory = NO;
851
852 exists = [cdrFileManager fileExistsAtPath:path isDirectory:&isDirectory];
853
854 if (exists) {
855 if (!isDirectory && [[[path pathExtension] lowercaseString] isEqualToString:@"oolite-save"]) {
856 NSDictionary* cdr = OODictionaryFromFile(path);
857 if (cdr) {
858 // okay use the same dictionary but add a 'saved_game_path' attribute
859 NSMutableDictionary* cdr1 = [NSMutableDictionary dictionaryWithDictionary:cdr];
860 [cdr1 setObject:@"YES" forKey:@"isSavedGame"];
861 [cdr1 setObject:path forKey:@"saved_game_path"];
862 [cdrDetailArray addObject:cdr1];
863 }
864 }
865 if (isDirectory && ![[path lastPathComponent] hasPrefix:@"."]) {
866 [cdrDetailArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"YES", @"isFolder", path, @"saved_game_path", nil]];
867 }
868 }
869 }
870
871 if (![cdrDetailArray count]) {
872 // Empty directory; tell the user and exit immediately.
873 [gui setText:DESC(@"loadsavescreen-no-commanders-found") forRow:STARTROW align:GUI_ALIGN_CENTER];
874 return;
875 }
876
877 [cdrDetailArray sortUsingFunction:sortCommanders context:NULL];
878
879 // Do we need to highlight a name?
880 int highlightRowOnPage = STARTROW;
881 int highlightIdx = 0;
882 if (highlightName) {
883 highlightIdx = [self findIndexOfCommander:highlightName];
884 if (highlightIdx < 0) {
885 OOLog(@"save.list.commanders.commanderNotFound", @"Commander %@ doesn't exist, very bad", highlightName);
886 highlightIdx = 0;
887 }
888
889 // figure out what page we need to be on
890 page = highlightIdx / NUMROWS;
891 highlightRowOnPage = highlightIdx % NUMROWS + STARTROW;
892 }
893
894 // We now know for certain what page we're on -
895 // set the first index of the first commander on this page.
896 unsigned firstIndex = page * NUMROWS;
897
898 // Set up the GUI.
899 OOGUITabSettings tabStop;
900 tabStop[0] = 0;
901 tabStop[1] = 160;
902 tabStop[2] = 270;
903 [gui setTabStops:tabStop];
904
905 // clear text lines here
906 for (i = EXITROW; i < ENDROW + 1; i++) {
907 [gui setText:@"" forRow:i align:GUI_ALIGN_LEFT];
908 [gui setColor:[OOColor yellowColor] forRow:i];
909 [gui setKey:GUI_KEY_SKIP forRow:i];
910 }
911
912 [gui setColor:[OOColor greenColor] forRow:LABELROW];
913 [gui setArray:[NSArray arrayWithObjects:DESC(@"loadsavescreen-commander-name"), DESC(@"loadsavescreen-rating"), nil]
914 forRow:LABELROW];
915
916 if (page) {
917 [gui setColor:[OOColor greenColor] forRow:STARTROW - 1];
918 [gui setArray:[NSArray arrayWithObjects:DESC(@"gui-back"), @" <-- ", nil]
919 forRow:STARTROW - 1];
920 [gui setKey:GUI_KEY_OK forRow:STARTROW - 1];
921 rangeStart = STARTROW - 1;
922 }
923
924 if ([self status] == STATUS_START_GAME) {
925 [gui setArray:[NSArray arrayWithObjects:DESC(@"oolite-loadsave-exit"), @" <----- ", nil] forRow:EXITROW];
926 [gui setColor:[OOColor redColor] forRow:EXITROW];
927 [gui setKey:GUI_KEY_OK forRow:EXITROW];
928 rangeStart = EXITROW;
929 }
930
931 if (firstIndex + NUMROWS >= [cdrDetailArray count]) {
932 lastIndex = [cdrDetailArray count];
933 [gui setSelectableRange:NSMakeRange(rangeStart, rangeStart + NUMROWS + 2)];
934 } else {
935 lastIndex = (page * NUMROWS) + NUMROWS;
936 [gui setColor:[OOColor greenColor] forRow:ENDROW];
937 [gui setArray:[NSArray arrayWithObjects:DESC(@"gui-more"), @" --> ", nil]
938 forRow:ENDROW];
939 [gui setKey:GUI_KEY_OK forRow:ENDROW];
940 [gui setSelectableRange:NSMakeRange(rangeStart, MOREROW)];
941 }
942
943 for (i = firstIndex; i < lastIndex; i++) {
944 NSDictionary* cdr = [cdrDetailArray objectAtIndex:i];
945 if ([cdr oo_boolForKey:@"isSavedGame"]) {
946 NSString* ratingDesc = OODisplayRatingStringFromKillCount([cdr oo_unsignedIntForKey:@"ship_kills"]);
947 [gui setArray:[NSArray arrayWithObjects:
948 [NSString stringWithFormat:@" %@ ", [cdr oo_stringForKey:@"player_save_name" defaultValue:[cdr oo_stringForKey:@"player_name"]]],
949 [NSString stringWithFormat:@" %@ ", ratingDesc],
950 nil]
951 forRow:row];
952 if ([[self lastsaveName] isEqualToString:[cdr oo_stringForKey:@"player_save_name" defaultValue:[cdr oo_stringForKey:@"player_name"]]]) {
953 highlightRowOnPage = row;
954 }
955
956 [gui setKey:GUI_KEY_OK forRow:row];
957 row++;
958 }
959 if ([cdr oo_boolForKey:@"isParentFolder"]) {
960 [gui setArray:[NSArray arrayWithObjects:
961 [NSString stringWithFormat:@" (..) %@ ", [[cdr oo_stringForKey:@"saved_game_path"] lastPathComponent]],
962 @"",
963 nil]
964 forRow:row];
965 [gui setColor:[OOColor orangeColor] forRow:row];
966 [gui setKey:GUI_KEY_OK forRow:row];
967 row++;
968 }
969 if ([cdr oo_boolForKey:@"isFolder"]) {
970 [gui setArray:[NSArray arrayWithObjects:
971 [NSString stringWithFormat:@" >> %@ ", [[cdr oo_stringForKey:@"saved_game_path"] lastPathComponent]],
972 @"",
973 nil]
974 forRow:row];
975 [gui setColor:[OOColor orangeColor] forRow:row];
976 [gui setKey:GUI_KEY_OK forRow:row];
977 row++;
978 }
979 }
980 [gui setSelectedRow:highlightRowOnPage];
981 highlightIdx = (highlightRowOnPage - STARTROW) + (currentPage * NUMROWS);
982 // show the first ship, this will be the selected row
983 [self showCommanderShip:highlightIdx];
984}
OOGUITabStop OOGUITabSettings[GUI_MAX_COLUMNS]
#define OOLog(class, format,...)
Definition OOLogging.h:84
NSDictionary * OODictionaryFromFile(NSString *path)
unsigned count
#define ENDROW
#define EXITROW
#define NUMROWS
#define STARTROW
NSString * OODisplayRatingStringFromKillCount(unsigned kills)
BOOL setSelectedRow:(OOGUIRow row)
void setText:forRow:align:(NSString *str,[forRow] OOGUIRow row,[align] OOGUIAlignment alignment)
void setSelectableRange:(NSRange range)
void setColor:forRow:(OOColor *color,[forRow] OOGUIRow row)
void setTabStops:(OOGUITabSettings stops)
void setArray:forRow:(NSArray *arr,[forRow] OOGUIRow row)
void setKey:forRow:(NSString *str,[forRow] OOGUIRow row)
OOColor * orangeColor()
Definition OOColor.m:289
OOColor * redColor()
Definition OOColor.m:259
OOColor * greenColor()
Definition OOColor.m:264
OOColor * yellowColor()
Definition OOColor.m:279
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

References count, ENDROW, EXITROW, PlayerEntity::findIndexOfCommander:, OOColor::greenColor, NUMROWS, OODictionaryFromFile(), OODisplayRatingStringFromKillCount(), OOLog, OOColor::orangeColor, OOColor::redColor, GuiDisplayGen::setArray:forRow:, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setKey:forRow:, GuiDisplayGen::setSelectableRange:, GuiDisplayGen::setSelectedRow:, GuiDisplayGen::setTabStops:, GuiDisplayGen::setText:forRow:align:, PlayerEntity::showCommanderShip:, STARTROW, and OOColor::yellowColor.

Here is the call graph for this function:

◆ nativeSavePlayer:

- (void) nativeSavePlayer: (NSString*) cdrName

Extends class PlayerEntity.

Definition at line 718 of file PlayerEntityLoadSave.m.

718 :(NSString*)cdrName
719{
720 NSString* dir = [[UNIVERSE gameController] playerFileDirectory];
721 NSString* savePath = [dir stringByAppendingPathComponent:[cdrName stringByAppendingPathExtension:@"oolite-save"]];
722
723 [self doScriptEvent:OOJSID("playerWillSaveGame") withArgument:@"STANDARD_SAVE"];
724
725 [self setLastsaveName:cdrName];
726
727 [self writePlayerToPath:savePath];
728}

References ShipEntity::doScriptEvent:withArgument:, PlayerEntity::setLastsaveName:, and PlayerEntity::writePlayerToPath:.

Here is the call graph for this function:

◆ setGuiToLoadCommanderScreen

- (void) setGuiToLoadCommanderScreen

Extends class PlayerEntity.

Definition at line 730 of file PlayerEntityLoadSave.m.

731{
732 GuiDisplayGen* gui = [UNIVERSE gui];
733 NSString* dir = [[UNIVERSE gameController] playerFileDirectory];
734
735 gui_screen = GUI_SCREEN_LOAD;
736
737 [gui clear];
738 [gui setTitle:DESC(@"loadscreen-title")];
739
740 currentPage = 0;
741 [self lsCommanders:gui directory:dir pageNumber:currentPage highlightName:nil];
742
743 [gui setForegroundTextureKey:@"docked_overlay"];
744 [gui setBackgroundTextureKey:@"load_save"];
745
746 [[UNIVERSE gameView] suppressKeysUntilKeyUp];
747
748 [self setShowDemoShips:YES];
749 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
750}
BOOL setBackgroundTextureKey:(NSString *key)
BOOL setForegroundTextureKey:(NSString *key)
void setTitle:(NSString *str)

References GuiDisplayGen::clear, PlayerEntity::lsCommanders:directory:pageNumber:highlightName:, GuiDisplayGen::setBackgroundTextureKey:, GuiDisplayGen::setForegroundTextureKey:, setGuiToLoadCommanderScreen, PlayerEntity::setShowDemoShips:, and GuiDisplayGen::setTitle:.

Referenced by setGuiToLoadCommanderScreen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGuiToOverwriteScreen:

- (void) setGuiToOverwriteScreen: (NSString*) cdrName

Extends class PlayerEntity.

Definition at line 782 of file PlayerEntityLoadSave.m.

782 :(NSString*)cdrName
783{
784 GuiDisplayGen* gui = [UNIVERSE gui];
785 MyOpenGLView* gameView = [UNIVERSE gameView];
786
787 // Don't poll controls
788 pollControls = NO;
789
790 gui_screen = GUI_SCREEN_SAVE_OVERWRITE;
791
792 [gui clear];
793 [gui setTitle:[NSString stringWithFormat:DESC(@"overwrite-save-commander-@"), cdrName]];
794
795 [gui setText:[NSString stringWithFormat:DESC(@"overwritescreen-commander-@-already-exists-overwrite-query"), cdrName]
796 forRow:SAVE_OVERWRITE_WARN_ROW
797 align:GUI_ALIGN_CENTER];
798
799 [gui setText:DESC(@"overwritescreen-yes") forRow:SAVE_OVERWRITE_YES_ROW align:GUI_ALIGN_CENTER];
800 [gui setKey:GUI_KEY_OK forRow:SAVE_OVERWRITE_YES_ROW];
801
802 [gui setText:DESC(@"overwritescreen-no") forRow:SAVE_OVERWRITE_NO_ROW align:GUI_ALIGN_CENTER];
803 [gui setKey:GUI_KEY_OK forRow:SAVE_OVERWRITE_NO_ROW];
804
805 [gui setSelectableRange:NSMakeRange(SAVE_OVERWRITE_YES_ROW, 2)];
806 [gui setSelectedRow:SAVE_OVERWRITE_NO_ROW];
807
808 // We can only leave this screen by answering yes or no, or esc. Therefore
809 // use a specific overlay, to allow visual reminders of the available options.
810 [gui setForegroundTextureKey:@"overwrite_overlay"];
811 [gui setBackgroundTextureKey:@"load_save"];
812
813 [self setShowDemoShips:NO];
814 [gameView setStringInput:gvStringInputNo];
815 [UNIVERSE enterGUIViewModeWithMouseInteraction:NO]; // FIXME: should be YES, but was NO before introducing new mouse mode stuff. If set to YES, choices can be selected but not activated.
816}
void setStringInput:(enum StringInput value)

References GuiDisplayGen::clear, GuiDisplayGen::setBackgroundTextureKey:, GuiDisplayGen::setForegroundTextureKey:, GuiDisplayGen::setKey:forRow:, GuiDisplayGen::setSelectableRange:, GuiDisplayGen::setSelectedRow:, PlayerEntity::setShowDemoShips:, MyOpenGLView::setStringInput:, GuiDisplayGen::setText:forRow:align:, and GuiDisplayGen::setTitle:.

Here is the call graph for this function:

◆ setGuiToSaveCommanderScreen:

- (void) setGuiToSaveCommanderScreen: (NSString*) cdrName

Extends class PlayerEntity.

Definition at line 752 of file PlayerEntityLoadSave.m.

752 :(NSString*)cdrName
753{
754 GuiDisplayGen* gui = [UNIVERSE gui];
755 MyOpenGLView* gameView = [UNIVERSE gameView];
756 NSString* dir = [[UNIVERSE gameController] playerFileDirectory];
757
758 pollControls = NO;
759 gui_screen = GUI_SCREEN_SAVE;
760
761 [gui clear];
762 [gui setTitle:DESC(@"savescreen-title")];
763
764 currentPage = 0;
765 [self lsCommanders:gui directory:dir pageNumber:currentPage highlightName:nil];
766
767 [gui setText:DESC(@"savescreen-commander-name") forRow:INPUTROW];
768 [gui setColor:[OOColor cyanColor] forRow:INPUTROW];
769 [gui setShowTextCursor:YES];
770 [gui setCurrentRow:INPUTROW];
771
772 [gui setForegroundTextureKey:@"docked_overlay"];
773 [gui setBackgroundTextureKey:@"load_save"];
774
775 [gameView setTypedString:cdrName];
776 [gameView suppressKeysUntilKeyUp];
777
778 [self setShowDemoShips:YES];
779 [UNIVERSE enterGUIViewModeWithMouseInteraction:YES];
780}
void setText:forRow:(NSString *str,[forRow] OOGUIRow row)
void setShowTextCursor:(BOOL yesno)
void setCurrentRow:(OOGUIRow value)
void setTypedString:(NSString *value)
OOColor * cyanColor()
Definition OOColor.m:274

References GuiDisplayGen::clear, OOColor::cyanColor, PlayerEntity::lsCommanders:directory:pageNumber:highlightName:, GuiDisplayGen::setBackgroundTextureKey:, GuiDisplayGen::setColor:forRow:, GuiDisplayGen::setCurrentRow:, GuiDisplayGen::setForegroundTextureKey:, PlayerEntity::setShowDemoShips:, GuiDisplayGen::setShowTextCursor:, GuiDisplayGen::setText:forRow:, GuiDisplayGen::setTitle:, MyOpenGLView::setTypedString:, and MyOpenGLView::suppressKeysUntilKeyUp.

Here is the call graph for this function:

◆ showCommanderShip:

- (void) showCommanderShip: (int) cdrArrayIndex

Extends class PlayerEntity.

Definition at line 996 of file PlayerEntityLoadSave.m.

996 :(int)cdrArrayIndex
997{
998 GuiDisplayGen* gui = [UNIVERSE gui];
999 [UNIVERSE removeDemoShips];
1000 NSDictionary* cdr = [cdrDetailArray objectAtIndex:cdrArrayIndex];
1001
1002 [gui setText:@"" forRow:CDRDESCROW align:GUI_ALIGN_LEFT];
1003 [gui setText:@"" forRow:CDRDESCROW + 1 align:GUI_ALIGN_LEFT];
1004 [gui setText:@"" forRow:CDRDESCROW + 2 align:GUI_ALIGN_LEFT];
1005
1006 if ([cdr oo_boolForKey:@"isFolder"]) {
1007 NSString* folderDesc = [NSString stringWithFormat:DESC(@"loadsavescreen-hold-@-and-press-return-to-open-folder-@"), @COMMAND_MODIFIER_KEY, [[cdr oo_stringForKey:@"saved_game_path"] lastPathComponent]];
1008 [gui setColor:[OOColor orangeColor] forRow:CDRDESCROW];
1009 [gui addLongText:folderDesc startingAtRow:CDRDESCROW align:GUI_ALIGN_LEFT];
1010 return;
1011 }
1012
1013 if ([cdr oo_boolForKey:@"isParentFolder"]) {
1014 NSString* folderDesc = [NSString stringWithFormat:DESC(@"loadsavescreen-hold-@-and-press-return-to-open-parent-folder-@"), @COMMAND_MODIFIER_KEY, [[cdr oo_stringForKey:@"saved_game_path"] lastPathComponent]];
1015 [gui setColor:[OOColor orangeColor] forRow:CDRDESCROW];
1016 [gui addLongText:folderDesc startingAtRow:CDRDESCROW align:GUI_ALIGN_LEFT];
1017 return;
1018 }
1019 [gui setColor:[gui colorFromSetting:nil defaultValue:nil] forRow:CDRDESCROW];
1020
1021 if (![cdr oo_boolForKey:@"isSavedGame"])
1022 return; // don't show things that aren't saved games
1023
1024 if ([self dockedStation] == nil)
1025 [self setDockedAtMainStation];
1026
1027 // Display the commander's ship.
1028 NSString* shipDesc = [cdr oo_stringForKey:@"ship_desc"];
1029 NSString* shipName = nil;
1030 NSDictionary* shipDict = nil;
1031 NSString* rating = nil;
1032 uint16_t personality = PersonalityForCommanderDict(cdr);
1033
1034 shipDict = [[OOShipRegistry sharedRegistry] shipInfoForKey:shipDesc];
1035 if (shipDict != nil) {
1036 NSMutableDictionary* dict = [[NSMutableDictionary alloc] initWithCapacity:[shipDict count] + 1];
1037 [dict setDictionary:shipDict];
1038 id subEntStatus = [cdr objectForKey:@"subentities_status"];
1039 // don't add it to the dictionary if there's no subentities_status key
1040 if (subEntStatus != nil)
1041 [dict setObject:subEntStatus forKey:@"subentities_status"];
1042 [self showShipyardModel:shipDesc shipData:dict personality:personality];
1043 [dict release];
1044 shipName = [shipDict oo_stringForKey:@"display_name"];
1045 if (shipName == nil)
1046 shipName = [shipDict oo_stringForKey:KEY_NAME];
1047 } else {
1048 [self showShipyardModel:@"oolite-unknown-ship" shipData:nil personality:personality];
1049 shipName = [cdr oo_stringForKey:@"ship_name" defaultValue:@"unknown"];
1050 if (![[UNIVERSE useAddOns] isEqualToString:SCENARIO_OXP_DEFINITION_ALL]) {
1051 shipName = [shipName stringByAppendingString:@" - OXPs disabled or not installed"];
1052 } else {
1053 shipName = [shipName stringByAppendingString:@" - OXP not installed"];
1054 }
1055 }
1056
1057 // Make a short description of the commander
1058 NSString* legalDesc = OODisplayStringFromLegalStatus([cdr oo_intForKey:@"legal_status"]);
1059
1060 rating = KillCountToRatingAndKillString([cdr oo_unsignedIntForKey:@"ship_kills"]);
1061 OOCreditsQuantity money = OODeciCreditsFromObject([cdr objectForKey:@"credits"]);
1062
1063 // Nikos - Add some more information in the load game screen (current location, galaxy number and timestamp).
1064 //-------------------------------------------------------------------------------------------------------------------------
1065
1066 int galNumber;
1067 NSString* timeStamp = nil;
1068 NSString* locationName = [cdr oo_stringForKey:@"current_system_name"];
1069
1070 // If there is no key containing the name of the current system in
1071 // the savefile, calculating what it should have been is going to
1072 // be tricky now that system generation isn't seed based - but
1073 // this implies a save game well over 5 years old.
1074 if (locationName == nil) {
1075 // Leaving the location blank in this case is probably okay
1076 locationName = @"";
1077 }
1078
1079 galNumber = [cdr oo_intForKey:@"galaxy_number"] + 1; // Galaxy numbering starts at 0.
1080
1081 NSString* locationGov = @"";
1082 NSString* locationEco = @"";
1083 NSString* locationTL = [cdr objectForKey:@"current_system_techlevel"] ? [NSString stringWithFormat:@"%u", [cdr oo_unsignedIntForKey:@"current_system_techlevel"] + 1] : nil;
1084 if (locationTL) {
1085 locationGov = [NSString stringWithFormat:@"%c", [cdr oo_unsignedCharForKey:@"current_system_government"]];
1086 locationEco = [NSString stringWithFormat:@" %c", (7 - [cdr oo_unsignedCharForKey:@"current_system_economy"]) + 16];
1087 } else
1088 locationTL = @"";
1089
1090 timeStamp = ClockToString([cdr oo_doubleForKey:@"ship_clock" defaultValue:PLAYER_SHIP_CLOCK_START], NO);
1091
1092 //-------------------------------------------------------------------------------------------------------------------------
1093
1094 NSString* cdrDesc = nil;
1095
1096 cdrDesc = [NSString stringWithFormat:DESC(@"loadsavescreen-commander-@-rated-@-has-@-legal-status-@-ship-@-location-@-g-@-eco-@-gov-@-tl-@-timestamp-@"),
1097 [cdr oo_stringForKey:@"player_name"],
1098 rating,
1099 OOCredits(money),
1100 legalDesc,
1101 shipName,
1102 locationName,
1103 galNumber,
1104 locationEco,
1105 locationGov,
1106 locationTL,
1107 timeStamp];
1108
1109 //-------------------------------------------------------------------------------------------------------------------------
1110
1111 [gui addLongText:cdrDesc startingAtRow:CDRDESCROW align:GUI_ALIGN_LEFT];
1112}
return nil
NSString * ClockToString(double clock, BOOL adjusting)
uint64_t OOCreditsQuantity
Definition OOTypes.h:160
OOCreditsQuantity OODeciCreditsFromObject(id object)
static uint16_t PersonalityForCommanderDict(NSDictionary *dict)
NSString * OODisplayStringFromLegalStatus(int legalStatus)
NSString * KillCountToRatingAndKillString(unsigned kills)
#define PLAYER_SHIP_CLOCK_START
#define SCENARIO_OXP_DEFINITION_ALL
#define UNIVERSE
Definition Universe.h:827
OOColor * colorFromSetting:defaultValue:(NSString *setting,[defaultValue] OOColor *def)
OOGUIRow addLongText:startingAtRow:align:(NSString *str,[startingAtRow] OOGUIRow row,[align] OOGUIAlignment alignment)
OOShipRegistry * sharedRegistry()
NSDictionary * shipInfoForKey:(NSString *key)

References GuiDisplayGen::addLongText:startingAtRow:align:, ClockToString(), GuiDisplayGen::colorFromSetting:defaultValue:, KillCountToRatingAndKillString(), nil, OODeciCreditsFromObject(), OODisplayStringFromLegalStatus(), OOColor::orangeColor, PersonalityForCommanderDict(), PLAYER_SHIP_CLOCK_START, SCENARIO_OXP_DEFINITION_ALL, GuiDisplayGen::setColor:forRow:, PlayerEntity::setDockedAtMainStation, GuiDisplayGen::setText:forRow:align:, OOShipRegistry::sharedRegistry, OOShipRegistry::shipInfoForKey:, PlayerEntity::showShipyardModel:shipData:personality:, and UNIVERSE.

Here is the call graph for this function:

◆ sortCommanders

- (NSComparisonResult) sortCommanders (id) cdr1
(id) cdr2
(void *) context 
implementation

Extends class PlayerEntity.

Definition at line 818 of file PlayerEntityLoadSave.m.

819{
820 return [[cdr1 objectForKey:@"saved_game_path"] localizedCompare:[cdr2 objectForKey:@"saved_game_path"]];
821}

◆ writePlayerToPath:

- (void) writePlayerToPath: (NSString*) path

Extends class PlayerEntity.

Definition at line 683 of file PlayerEntityLoadSave.m.

683 :(NSString*)path
684{
685 NSString* errDesc = nil;
686 NSDictionary* dict = nil;
687 BOOL didSave = NO;
688 [[UNIVERSE gameView] resetTypedString];
689
690 if (!path) {
691 OOLog(@"save.failed", @"***** SAVE ERROR: %s called with nil path.", __PRETTY_FUNCTION__);
692 return;
693 }
694
695 dict = [self commanderDataDictionary];
696 if (dict == nil)
697 errDesc = @"could not construct commander data dictionary.";
698 else
699 didSave = [dict writeOOXMLToFile:path atomically:YES errorDescription:&errDesc];
700 if (didSave) {
701 [UNIVERSE clearPreviousMessage]; // allow this to be given time and again
702 [UNIVERSE addMessage:DESC(@"game-saved") forCount:2];
703 [save_path autorelease];
704 save_path = [path copy];
705 [[UNIVERSE gameController] setPlayerFileToLoad:save_path];
706 [[UNIVERSE gameController] setPlayerFileDirectory:save_path];
707 // no duplicated autosave immediately after a save.
708 [UNIVERSE setAutoSaveNow:NO];
709 } else {
710 OOLog(@"save.failed", @"***** SAVE ERROR: %@", errDesc);
711 [NSException raise:@"OoliteException"
712 format:@"Attempt to save game to file '%@' failed: %@", path, errDesc];
713 }
714 [[UNIVERSE gameView] suppressKeysUntilKeyUp];
715 [self setGuiToStatusScreen];
716}

References PlayerEntity::commanderDataDictionary, nil, OOLog, and PlayerEntity::setGuiToStatusScreen.

Here is the call graph for this function:

The documentation for this category was generated from the following file: