Made commodity display names localizable via descriptions.plist. Probably missed some cases.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1356 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
65574daac5
commit
77cde62c7b
@ -994,6 +994,8 @@
|
||||
<string>g</string>
|
||||
<key>cargo-kilograms-symbol</key>
|
||||
<string>kg</string>
|
||||
<key>commodity-quantity-none</key>
|
||||
<string>—</string>
|
||||
|
||||
<!-- System data screen -->
|
||||
<key>sysdata-planet-name-@</key>
|
||||
@ -1160,7 +1162,7 @@
|
||||
<key>manifest-none</key>
|
||||
<string> None.</string>
|
||||
<key>manifest-cargo-d-d</key>
|
||||
<string>Cargo %dt (%dt):</string>
|
||||
<string>Cargo %d t (%d t):</string>
|
||||
<key>manifest-passengers-d-d</key>
|
||||
<string>Passengers %d (%d):</string>
|
||||
<key>manifest-contracts</key>
|
||||
@ -1309,6 +1311,41 @@
|
||||
<string>For rescuing %@, %@, their insurance pays %.1f credits.</string>
|
||||
<key>capture-reward-for-@@-f-credits</key>
|
||||
<string>For capturing %@, %@, you’re paid a bounty of %.1f credits.</string>
|
||||
|
||||
|
||||
<!-- Commodity names -->
|
||||
<key>commodity-name Food</key>
|
||||
<string>Food</string>
|
||||
<key>commodity-name Textiles</key>
|
||||
<string>Textiles</string>
|
||||
<key>commodity-name Radioactives</key>
|
||||
<string>Radioactives</string>
|
||||
<key>commodity-name Slaves</key>
|
||||
<string>Slaves</string>
|
||||
<key>commodity-name Liquor/Wines</key>
|
||||
<string>Liquor/Wines</string>
|
||||
<key>commodity-name Luxuries</key>
|
||||
<string>Luxuries</string>
|
||||
<key>commodity-name Narcotics</key>
|
||||
<string>Narcotics</string>
|
||||
<key>commodity-name Computers</key>
|
||||
<string>Computers</string>
|
||||
<key>commodity-name Machinery</key>
|
||||
<string>Machinery</string>
|
||||
<key>commodity-name Alloys</key>
|
||||
<string>Alloys</string>
|
||||
<key>commodity-name Firearms</key>
|
||||
<string>Firearms</string>
|
||||
<key>commodity-name Furs</key>
|
||||
<string>Furs</string>
|
||||
<key>commodity-name Minerals</key>
|
||||
<string>Minerals</string>
|
||||
<key>commodity-name Gold</key>
|
||||
<string>Gold</string>
|
||||
<key>commodity-name Platinum</key>
|
||||
<string>Platinum</string>
|
||||
<key>commodity-name Gem-Stones</key>
|
||||
<string>Gem-Stones</string>
|
||||
<key>commodity-name Alien Items</key>
|
||||
<string>Alien Items</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -3351,7 +3351,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
int result = [super dumpCargo];
|
||||
if (result != CARGO_NOT_CARGO)
|
||||
{
|
||||
[UNIVERSE addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-ejected]") ,[UNIVERSE nameForCommodity:result]] forCount:3.0];
|
||||
[UNIVERSE addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-ejected]") ,[UNIVERSE displayNameForCommodity:result]] forCount:3.0];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -3377,7 +3377,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
[pod release];
|
||||
if (contents != CARGO_NOT_CARGO)
|
||||
{
|
||||
[UNIVERSE addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-ready-to-eject]"), [UNIVERSE nameForCommodity:contents]] forCount:3.0];
|
||||
[UNIVERSE addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[@-ready-to-eject]"), [UNIVERSE displayNameForCommodity:contents]] forCount:3.0];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3486,7 +3486,7 @@ double scoopSoundPlayTime = 0.0;
|
||||
if (damage_to < [cargo count])
|
||||
{
|
||||
ShipEntity* pod = (ShipEntity*)[cargo objectAtIndex:damage_to];
|
||||
NSString* cargo_desc = [UNIVERSE nameForCommodity:[pod commodityType]];
|
||||
NSString* cargo_desc = [UNIVERSE displayNameForCommodity:[pod commodityType]];
|
||||
if (!cargo_desc)
|
||||
return;
|
||||
[UNIVERSE clearPreviousMessage];
|
||||
@ -4164,8 +4164,8 @@ double scoopSoundPlayTime = 0.0;
|
||||
NSString* units = [NSString stringWithString:tons];
|
||||
if (unit == UNITS_KILOGRAMS) units = [NSString stringWithString:kilograms];
|
||||
if (unit == UNITS_GRAMS) units = [NSString stringWithString:grams];
|
||||
NSString* desc = (NSString *)[(NSArray *)[shipCommodityData objectAtIndex:i] objectAtIndex:MARKET_NAME];
|
||||
[manifest addObject:[NSString stringWithFormat:@"%d%@ x %@", in_hold[i], units, desc]];
|
||||
NSString *desc = CommodityDisplayNameForCommodityArray([shipCommodityData arrayAtIndex:i]);
|
||||
[manifest addObject:[NSString stringWithFormat:@"%d %@ x %@", in_hold[i], units, desc]];
|
||||
}
|
||||
}
|
||||
|
||||
@ -5491,13 +5491,14 @@ static int last_outfitting_index;
|
||||
|
||||
// GUI stuff
|
||||
{
|
||||
GuiDisplayGen *gui = [UNIVERSE gui];
|
||||
OOGUIRow start_row = GUI_ROW_MARKET_START;
|
||||
OOGUIRow row = start_row;
|
||||
unsigned i;
|
||||
unsigned n_commodities = [shipCommodityData count];
|
||||
OOCargoQuantity in_hold[n_commodities];
|
||||
|
||||
GuiDisplayGen *gui = [UNIVERSE gui];
|
||||
OOGUIRow start_row = GUI_ROW_MARKET_START;
|
||||
OOGUIRow row = start_row;
|
||||
unsigned i;
|
||||
unsigned n_commodities = [shipCommodityData count];
|
||||
OOCargoQuantity in_hold[n_commodities];
|
||||
NSArray *marketDef = nil;
|
||||
|
||||
// following changed to work whether docked or not
|
||||
|
||||
for (i = 0; i < n_commodities; i++)
|
||||
@ -5526,23 +5527,26 @@ static int last_outfitting_index;
|
||||
|
||||
for (i = 0; i < n_commodities; i++)
|
||||
{
|
||||
NSString* desc = [NSString stringWithFormat:@" %@ ",(NSString *)[(NSArray *)[localMarket objectAtIndex:i] objectAtIndex:MARKET_NAME]];
|
||||
int available_units = [[[localMarket objectAtIndex:i] objectAtIndex:MARKET_QUANTITY] intValue];
|
||||
int units_in_hold = in_hold[i];
|
||||
int price_per_unit = [[[localMarket objectAtIndex:i] objectAtIndex:MARKET_PRICE] intValue];
|
||||
OOMassUnit unit = [[[localMarket objectAtIndex:i] objectAtIndex:MARKET_UNITS] intValue];
|
||||
NSString* available = (available_units > 0) ? [NSString stringWithFormat:@"%d",available_units] : @"-";
|
||||
NSString* price = [NSString stringWithFormat:@" %.1f ",0.1*price_per_unit];
|
||||
NSString* owned = (units_in_hold > 0) ? [NSString stringWithFormat:@"%d",units_in_hold] : @"-";
|
||||
NSString* units = @"t";
|
||||
if (unit == UNITS_KILOGRAMS) units = @"kg";
|
||||
if (unit == UNITS_GRAMS) units = @"g";
|
||||
NSString* units_available = [NSString stringWithFormat:@" %@ %@ ",available,units];
|
||||
NSString* units_owned = [NSString stringWithFormat:@" %@ %@ ",owned,units];
|
||||
|
||||
marketDef = [localMarket arrayAtIndex:i];
|
||||
|
||||
NSString* desc = [NSString stringWithFormat:@" %@ ", CommodityDisplayNameForCommodityArray(marketDef)];
|
||||
OOCargoQuantity available_units = [marketDef unsignedIntAtIndex:MARKET_QUANTITY];
|
||||
OOCargoQuantity units_in_hold = in_hold[i];
|
||||
OOCreditsQuantity price_per_unit = [marketDef unsignedIntAtIndex:MARKET_PRICE];
|
||||
OOMassUnit unit = [marketDef unsignedIntAtIndex:MARKET_UNITS];
|
||||
|
||||
NSString* available = (available_units > 0) ? [NSString stringWithFormat:@"%d",available_units] : DESC(@"commodity-quantity-none");
|
||||
NSString* price = [NSString stringWithFormat:@" %.1f ",0.1 * price_per_unit];
|
||||
NSString* owned = (units_in_hold > 0) ? [NSString stringWithFormat:@"%d",units_in_hold] : DESC(@"commodity-quantity-none");
|
||||
NSString* units = DESC(@"cargo-tons-symbol");
|
||||
if (unit == UNITS_KILOGRAMS) units = DESC(@"cargo-kilograms-symbol");
|
||||
if (unit == UNITS_GRAMS) units = DESC(@"cargo-grams-symbol");
|
||||
NSString* units_available = [NSString stringWithFormat:@" %@ %@ ",available, units];
|
||||
NSString* units_owned = [NSString stringWithFormat:@" %@ %@ ",owned, units];
|
||||
|
||||
if (unit == UNITS_TONS)
|
||||
current_cargo += units_in_hold;
|
||||
|
||||
|
||||
[gui setKey:[NSString stringWithFormat:@"%d",i] forRow:row];
|
||||
[gui setArray:[NSArray arrayWithObjects: desc, price, units_available, units_owned, nil] forRow:row++];
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
|
||||
int contract_amount = [(NSNumber*)[contract_info objectForKey:CONTRACT_KEY_CARGO_AMOUNT] intValue];
|
||||
|
||||
NSMutableArray* manifest = [NSMutableArray arrayWithArray:shipCommodityData];
|
||||
NSMutableArray* commodityInfo = [NSMutableArray arrayWithArray:(NSArray *)[manifest objectAtIndex:contract_cargo_type]];
|
||||
NSMutableArray* commodityInfo = [NSMutableArray arrayWithArray:[manifest arrayAtIndex:contract_cargo_type]];
|
||||
int quantity_on_hand = [(NSNumber *)[commodityInfo objectAtIndex:MARKET_QUANTITY] intValue];
|
||||
|
||||
if (equal_seeds( system_seed, [UNIVERSE systemSeedForSystemNumber:dest]))
|
||||
|
@ -26,6 +26,7 @@ MA 02110-1301, USA.
|
||||
|
||||
#import "Universe.h"
|
||||
#import "OOCollectionExtractors.h"
|
||||
#import "OOConstToString.h"
|
||||
|
||||
|
||||
@implementation PlayerEntity (ScriptMethods)
|
||||
@ -98,7 +99,7 @@ MA 02110-1301, USA.
|
||||
commodityArray = [UNIVERSE commidityDataForType:type];
|
||||
if (commodityArray == nil) return;
|
||||
|
||||
OOLog(@"script.debug.note.awardCargo", @"Going to award cargo: %d x '%@'", amount, [commodityArray stringAtIndex:MARKET_NAME]);
|
||||
OOLog(@"script.debug.note.awardCargo", @"Going to award cargo: %d x '%@'", amount, CommodityDisplayNameForCommodityArray(commodityArray));
|
||||
|
||||
unit = [commodityArray intAtIndex:MARKET_UNITS];
|
||||
|
||||
|
@ -71,3 +71,6 @@ NSString *LegalStatusToString(int legalStatus) CONST_FUNC;
|
||||
NSString *AlertConditionToString(OOAlertCondition alertCondition) CONST_FUNC;
|
||||
|
||||
NSString *ShaderSettingToDisplayString(OOShaderSetting setting) CONST_FUNC;
|
||||
|
||||
NSString *CommodityDisplayNameForSymbolicName(NSString *symbolicName);
|
||||
NSString *CommodityDisplayNameForCommodityArray(NSArray *commodityDefinition);
|
||||
|
@ -508,3 +508,35 @@ NSString *ShaderSettingToDisplayString(OOShaderSetting setting)
|
||||
|
||||
return @"??";
|
||||
}
|
||||
|
||||
|
||||
NSString *CommodityDisplayNameForSymbolicName(NSString *symbolicName)
|
||||
{
|
||||
static NSMutableDictionary *cache = nil;
|
||||
NSString *result = nil;
|
||||
NSString *key = nil;
|
||||
|
||||
if (symbolicName == nil) return nil;
|
||||
if (cache == nil) cache = [[NSMutableDictionary alloc] init];
|
||||
|
||||
// Look for cached result
|
||||
result = [cache objectForKey:symbolicName];
|
||||
|
||||
// If no cached result, look up in descriptions.plist and add to cache.
|
||||
// If no entry is found in descriptions.plist, the symbolic name is used.
|
||||
if (result == nil)
|
||||
{
|
||||
key = [@"commodity-name " stringByAppendingString:symbolicName];
|
||||
result = [UNIVERSE descriptionForKey:key];
|
||||
if (result == nil) result = symbolicName;
|
||||
[cache setObject:result forKey:symbolicName];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
NSString *CommodityDisplayNameForCommodityArray(NSArray *commodityDefinition)
|
||||
{
|
||||
return CommodityDisplayNameForSymbolicName([commodityDefinition stringAtIndex:MARKET_NAME]);
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ MA 02110-1301, USA.
|
||||
{
|
||||
// eaten all of this cargo!
|
||||
NSString* ms = [NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[trumbles-eat-@]"),
|
||||
[UNIVERSE nameForCommodity:[selectedCargopod commodityType]]];
|
||||
[UNIVERSE displayNameForCommodity:[selectedCargopod commodityType]]];
|
||||
|
||||
[UNIVERSE addMessage: ms forCount: 4.5];
|
||||
[cargopods removeObject:selectedCargopod];
|
||||
|
@ -337,7 +337,8 @@ enum
|
||||
|
||||
- (NSArray *) commidityDataForType:(OOCargoType)type;
|
||||
- (OOCargoType) commodityForName:(NSString *) co_name;
|
||||
- (NSString *) nameForCommodity:(OOCargoType) co_type;
|
||||
- (NSString *) symbolicNameForCommodity:(OOCargoType) co_type;
|
||||
- (NSString *) displayNameForCommodity:(OOCargoType) co_type;
|
||||
- (OOMassUnit) unitsForCommodity:(OOCargoType) co_type;
|
||||
- (NSString *) describeCommodity:(OOCargoType) co_type amount:(OOCargoQuantity) co_amount;
|
||||
|
||||
|
@ -3036,7 +3036,7 @@ if (cachedStation)
|
||||
|
||||
co_amount = [self getRandomAmountOfCommodity:co_type];
|
||||
|
||||
ShipEntity* special_container = [self newShipWithRole: [self nameForCommodity:co_type]];
|
||||
ShipEntity* special_container = [self newShipWithRole: [self symbolicNameForCommodity:co_type]];
|
||||
if (special_container)
|
||||
{
|
||||
[container release];
|
||||
@ -3160,7 +3160,7 @@ if (cachedStation)
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) nameForCommodity:(OOCargoType) co_type
|
||||
- (NSString *) symbolicNameForCommodity:(OOCargoType) co_type
|
||||
{
|
||||
NSArray *commodity = [self commidityDataForType:co_type];
|
||||
|
||||
@ -3170,6 +3170,12 @@ if (cachedStation)
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) displayNameForCommodity:(OOCargoType) co_type
|
||||
{
|
||||
return CommodityDisplayNameForSymbolicName([self symbolicNameForCommodity:co_type]);
|
||||
}
|
||||
|
||||
|
||||
- (OOMassUnit) unitsForCommodity:(OOCargoType)co_type
|
||||
{
|
||||
NSArray *commodity = [self commidityDataForType:co_type];
|
||||
@ -3205,7 +3211,7 @@ if (cachedStation)
|
||||
}
|
||||
if (co_amount != 1) unitDesc = [unitDesc stringByAppendingString:@"s"];
|
||||
|
||||
typeDesc = [commodity stringAtIndex:MARKET_NAME];
|
||||
typeDesc = CommodityDisplayNameForCommodityArray(commodity);
|
||||
|
||||
return [NSString stringWithFormat:@"%d %@ %@",co_amount, unitDesc, typeDesc];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user