Allow customisable extra column
parent
7040e8bc40
commit
4c1144603d
|
@ -1411,7 +1411,9 @@
|
|||
"price-column-title" = "Price:";
|
||||
"for-sale-column-title" = "For sale:";
|
||||
"in-hold-column-title" = "In hold:";
|
||||
"oolite-legality-column-title" = "Legal?";
|
||||
"oolite-legality-column-title" = "Legal:";
|
||||
"oolite-extras-column-title" = "";
|
||||
// "oolite-extras-column-title" = "Extra:"; // title for column is for OXPs
|
||||
"oolite-legality-clear" = "—";
|
||||
"oolite-legality-export" = "Ex"; // legal to export
|
||||
"oolite-legality-import" = "Im"; // legal to import
|
||||
|
@ -1439,9 +1441,12 @@
|
|||
"oolite-market-sorter-5" = "Unit mass";
|
||||
|
||||
"oolite-commodity-no-comment" = "No additional information available";
|
||||
"oolite-commodity-no-short-comment" = "";
|
||||
// "oolite-commodity-no-short-comment" = "—"; // blank for column is for OXPs
|
||||
"oolite-commodity-info-return" = "Press '[oolite_key_market_info]' to return to commodity list";
|
||||
"oolite-commodity-information-@" = "Commodity: %@";
|
||||
"oolite-commodity-contracted-d-@" = "Total cargo contracts: %d %@";
|
||||
"oolite-commodity-illegal" = "It is illegal to export this good from Cooperative stations.";
|
||||
|
||||
// System data screen
|
||||
"sysdata-planet-name-@" = "Data on %@";
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
"legality_import" = 0;
|
||||
"trumble_opinion" = 0.01;
|
||||
"sort_order" = 400;
|
||||
"comment" = "[oolite-commodity-illegal]";
|
||||
};
|
||||
|
||||
"liquor_wines" = {
|
||||
|
@ -128,6 +129,7 @@
|
|||
"legality_import" = 0;
|
||||
"trumble_opinion" = 1.05;
|
||||
"sort_order" = 700;
|
||||
"comment" = "[oolite-commodity-illegal]";
|
||||
};
|
||||
|
||||
"computers" = {
|
||||
|
@ -200,6 +202,7 @@
|
|||
"legality_import" = 0;
|
||||
"trumble_opinion" = 0;
|
||||
"sort_order" = 1100;
|
||||
"comment" = "[oolite-commodity-illegal]";
|
||||
};
|
||||
|
||||
"furs" = {
|
||||
|
|
|
@ -9653,15 +9653,24 @@ static NSString *last_outfitting_key=nil;
|
|||
GuiDisplayGen *gui = [UNIVERSE gui];
|
||||
OOGUITabSettings tab_stops;
|
||||
tab_stops[0] = 0;
|
||||
tab_stops[1] = 172;
|
||||
tab_stops[2] = 262;
|
||||
tab_stops[3] = 316;
|
||||
tab_stops[4] = 436;
|
||||
/* tab_stops[1] = 137;
|
||||
tab_stops[2] = 217;
|
||||
tab_stops[3] = 271;
|
||||
tab_stops[4] = 381;
|
||||
tab_stops[5] = 431; */
|
||||
tab_stops[1] = 137;
|
||||
tab_stops[2] = 187;
|
||||
tab_stops[3] = 267;
|
||||
tab_stops[4] = 321;
|
||||
tab_stops[5] = 431;
|
||||
[gui setTabStops:tab_stops];
|
||||
|
||||
[gui setColor:[OOColor greenColor] forRow:GUI_ROW_MARKET_KEY];
|
||||
[gui setArray:[NSArray arrayWithObjects: DESC(@"commodity-column-title"), OOPadStringToEms(DESC(@"price-column-title"),3.5),
|
||||
OOPadStringToEms(DESC(@"for-sale-column-title"),3.75), OOPadStringToEms(DESC(@"in-hold-column-title"),5.75), DESC(@"oolite-legality-column-title"), DESC(@"oolite-extras-column-title"), nil] forRow:GUI_ROW_MARKET_KEY];
|
||||
[gui setArray:[NSArray arrayWithObjects: DESC(@"commodity-column-title"), DESC(@"oolite-extras-column-title"), OOPadStringToEms(DESC(@"price-column-title"),3.5),
|
||||
OOPadStringToEms(DESC(@"for-sale-column-title"),3.75), OOPadStringToEms(DESC(@"in-hold-column-title"),5.75), DESC(@"oolite-legality-column-title"), nil] forRow:GUI_ROW_MARKET_KEY];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -9713,8 +9722,10 @@ static NSString *last_outfitting_key=nil;
|
|||
}
|
||||
legaldesc = [NSString stringWithFormat:@" %@ ",legaldesc];
|
||||
|
||||
NSString *extradesc = [shipCommodityData shortCommentForGood:good];
|
||||
|
||||
[gui setKey:good forRow:row];
|
||||
[gui setArray:[NSArray arrayWithObjects: desc, price, units_available, units_owned, legaldesc, nil] forRow:row++];
|
||||
[gui setArray:[NSArray arrayWithObjects: desc, extradesc, price, units_available, units_owned, legaldesc, nil] forRow:row++];
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ static NSString * const kOOCommoditySortOrder = @"sort_order";
|
|||
static NSString * const kOOCommodityCapacity = @"capacity";
|
||||
static NSString * const kOOCommodityScript = @"market_script";
|
||||
static NSString * const kOOCommodityComment = @"comment";
|
||||
static NSString * const kOOCommodityShortComment = @"short_comment";
|
||||
// next one cannot be set from file - named for compatibility
|
||||
static NSString * const kOOCommodityKey = @"key";
|
||||
|
||||
|
|
|
@ -49,9 +49,11 @@ MA 02110-1301, USA.
|
|||
- (BOOL) removeQuantity:(OOCargoQuantity)quantity forGood:(OOCommodityType)good;
|
||||
- (void) removeAllGoods;
|
||||
- (BOOL) setComment:(NSString *)comment forGood:(OOCommodityType)good;
|
||||
- (BOOL) setShortComment:(NSString *)comment forGood:(OOCommodityType)good;
|
||||
|
||||
- (NSString *) nameForGood:(OOCommodityType)good;
|
||||
- (NSString *) commentForGood:(OOCommodityType)good;
|
||||
- (NSString *) shortCommentForGood:(OOCommodityType)good;
|
||||
- (OOCreditsQuantity) priceForGood:(OOCommodityType)good;
|
||||
- (OOCargoQuantity) quantityForGood:(OOCommodityType)good;
|
||||
- (OOMassUnit) massUnitForGood:(OOCommodityType)good;
|
||||
|
|
|
@ -155,6 +155,17 @@ NSComparisonResult goodsSorter(NSString *a, NSString *b, void *context);
|
|||
}
|
||||
|
||||
|
||||
- (BOOL) setShortComment:(NSString *)comment forGood:(OOCommodityType)good
|
||||
{
|
||||
NSMutableDictionary *definition = [_commodityList oo_mutableDictionaryForKey:good];
|
||||
if (definition == nil)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
[definition setObject:comment forKey:kOOCommodityShortComment];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) nameForGood:(OOCommodityType)good
|
||||
{
|
||||
|
@ -178,6 +189,17 @@ NSComparisonResult goodsSorter(NSString *a, NSString *b, void *context);
|
|||
}
|
||||
|
||||
|
||||
- (NSString *) shortCommentForGood:(OOCommodityType)good
|
||||
{
|
||||
NSDictionary *definition = [_commodityList oo_dictionaryForKey:good];
|
||||
if (definition == nil)
|
||||
{
|
||||
return OOExpand(@"[oolite-unknown-commodity-name]");
|
||||
}
|
||||
return OOExpand([definition oo_stringForKey:kOOCommodityShortComment defaultValue:@"[oolite-commodity-no-short-comment]"]);
|
||||
}
|
||||
|
||||
|
||||
- (OOCreditsQuantity) priceForGood:(OOCommodityType)good
|
||||
{
|
||||
NSDictionary *definition = [_commodityList oo_dictionaryForKey:good];
|
||||
|
|
|
@ -36,8 +36,11 @@ MA 02110-1301, USA.
|
|||
static JSObject *sManifestPrototype;
|
||||
static JSObject *sManifestObject;
|
||||
|
||||
static JSBool ManifestInformation(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ManifestSetInformation(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ManifestComment(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ManifestSetComment(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ManifestShortComment(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool ManifestSetShortComment(JSContext *context, uintN argc, jsval *vp);
|
||||
|
||||
|
||||
static JSBool ManifestDeleteProperty(JSContext *context, JSObject *this, jsid propID, jsval *value);
|
||||
static JSBool ManifestGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value);
|
||||
|
@ -78,8 +81,10 @@ static JSPropertySpec sManifestProperties[] =
|
|||
static JSFunctionSpec sManifestMethods[] =
|
||||
{
|
||||
// JS name Function min args
|
||||
{ "information", ManifestInformation, 1 },
|
||||
{ "setInformation", ManifestSetInformation, 2 },
|
||||
{ "shortComment", ManifestShortComment, 1 },
|
||||
{ "setShortComment", ManifestSetShortComment, 2 },
|
||||
{ "comment", ManifestComment, 1 },
|
||||
{ "setComment", ManifestSetComment, 2 },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
@ -224,7 +229,7 @@ static JSBool ManifestSetProperty(JSContext *context, JSObject *this, jsid propI
|
|||
}
|
||||
|
||||
|
||||
static JSBool ManifestInformation(JSContext *context, uintN argc, jsval *vp)
|
||||
static JSBool ManifestComment(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_NATIVE_ENTER(context)
|
||||
|
||||
|
@ -237,7 +242,7 @@ static JSBool ManifestInformation(JSContext *context, uintN argc, jsval *vp)
|
|||
}
|
||||
if (good == nil)
|
||||
{
|
||||
OOJSReportBadArguments(context, @"Manifest", @"information", MIN(argc, 1U), OOJS_ARGV, nil, @"good");
|
||||
OOJSReportBadArguments(context, @"Manifest", @"comment", MIN(argc, 1U), OOJS_ARGV, nil, @"good");
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -249,7 +254,7 @@ static JSBool ManifestInformation(JSContext *context, uintN argc, jsval *vp)
|
|||
}
|
||||
|
||||
|
||||
static JSBool ManifestSetInformation(JSContext *context, uintN argc, jsval *vp)
|
||||
static JSBool ManifestSetComment(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_NATIVE_ENTER(context)
|
||||
|
||||
|
@ -264,7 +269,7 @@ static JSBool ManifestSetInformation(JSContext *context, uintN argc, jsval *vp)
|
|||
}
|
||||
if (good == nil || information == nil)
|
||||
{
|
||||
OOJSReportBadArguments(context, @"Manifest", @"setInformation", MIN(argc, 2U), OOJS_ARGV, nil, @"good and information text");
|
||||
OOJSReportBadArguments(context, @"Manifest", @"setComment", MIN(argc, 2U), OOJS_ARGV, nil, @"good and information text");
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -274,3 +279,55 @@ static JSBool ManifestSetInformation(JSContext *context, uintN argc, jsval *vp)
|
|||
|
||||
OOJS_NATIVE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ManifestShortComment(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_NATIVE_ENTER(context)
|
||||
|
||||
OOCommodityType good = nil;
|
||||
NSString * information = nil;
|
||||
|
||||
if (argc > 0)
|
||||
{
|
||||
good = OOStringFromJSValue(context, OOJS_ARGV[0]);
|
||||
}
|
||||
if (good == nil)
|
||||
{
|
||||
OOJSReportBadArguments(context, @"Manifest", @"shortComment", MIN(argc, 1U), OOJS_ARGV, nil, @"good");
|
||||
return NO;
|
||||
}
|
||||
|
||||
information = [[PLAYER shipCommodityData] shortCommentForGood:good];
|
||||
|
||||
OOJS_RETURN_OBJECT(information);
|
||||
|
||||
OOJS_NATIVE_EXIT
|
||||
}
|
||||
|
||||
|
||||
static JSBool ManifestSetShortComment(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_NATIVE_ENTER(context)
|
||||
|
||||
BOOL OK;
|
||||
OOCommodityType good = nil;
|
||||
NSString * information = nil;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
good = OOStringFromJSValue(context, OOJS_ARGV[0]);
|
||||
information = OOStringFromJSValue(context, OOJS_ARGV[1]);
|
||||
}
|
||||
if (good == nil || information == nil)
|
||||
{
|
||||
OOJSReportBadArguments(context, @"Manifest", @"setShortComment", MIN(argc, 2U), OOJS_ARGV, nil, @"good and information text");
|
||||
return NO;
|
||||
}
|
||||
|
||||
OK = [[PLAYER shipCommodityData] setShortComment:information forGood:good];
|
||||
|
||||
OOJS_RETURN_BOOL(OK);
|
||||
|
||||
OOJS_NATIVE_EXIT
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue