File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -367,12 +367,25 @@ - (NSString*)getFormatString:(NSString*)format {
367367 // Default format does not provide any units
368368 NSString *defaultFormat = settingValueType == SettingValueTypeNumber ? @" %.2f " : @" %i " ;
369369
370- // Workaround!! Before Kodi 18.x an older format ("%i ms") was used. The new format ("{0:d} ms") needs
371- // an updated parser. Until this is implemented just display the value itself, without the unit.
372- if (format.length > 0 && AppDelegate.instance .serverVersion < 18 ) {
373- return format;
370+ // Identify fmt-like format string
371+ if (format.length && [format rangeOfString: @" {" ].location != NSNotFound && [format rangeOfString: @" }" ].location != NSNotFound ) {
372+ // Gather range for unit which is added after last "}"
373+ NSRange range;
374+ range.location = [format rangeOfString: @" }" options: NSBackwardsSearch].location + 1 ;
375+ range.length = format.length - range.location ;
376+
377+ // Extract unit and make percent character is formatted correctly
378+ NSString *unit = [format substringWithRange: range];
379+ unit = [unit stringByReplacingOccurrencesOfString: @" %" withString: @" %% " ];
380+
381+ // Build std format string, appending the fmt format string's unit
382+ format = [defaultFormat stringByAppendingString: unit];
383+ }
384+ // Fallback to default in case no format is defined or we missed to identify fmt-style format (which is used for Kodi 18 and later)
385+ else if (!format.length || AppDelegate.instance .serverVersion >= 18 ) {
386+ format = defaultFormat;
374387 }
375- return defaultFormat ;
388+ return format ;
376389}
377390
378391- (NSString *)getStringForSliderItem : (id )item value : (float )value {
You can’t perform that action at this time.
0 commit comments