Skip to content

Commit

Permalink
Merge pull request #44 from Nexus-Mods/1.12.x
Browse files Browse the repository at this point in the history
improved formatPlaytime fallback
  • Loading branch information
insomnious authored Jul 30, 2024
2 parents e17ccff + 07630b8 commit 9974ff1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.8.7] - 2024-07-30

- Fixed native plugins added to plugins.txt file when Starfield.ccc is present

## [0.8.6] - 2024-07-29

- Adding fallback to playtime parser
- Adding fallback to playtime parser. ([#16139](https://github.com/Nexus-Mods/Vortex/issues/16139))

## [0.8.5] - 2024-07-29

Expand Down Expand Up @@ -173,6 +177,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

- Initial release for basic mod support

[0.8.7]: https://github.com/Nexus-Mods/game-starfield/releases/tag/v0.8.7
[0.8.6]: https://github.com/Nexus-Mods/game-starfield/releases/tag/v0.8.6
[0.8.5]: https://github.com/Nexus-Mods/game-starfield/releases/tag/v0.8.5
[0.7.1]: https://github.com/Nexus-Mods/game-starfield/releases/tag/v0.7.1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "starfield",
"version": "0.8.6",
"version": "0.8.7",
"description": "Vortex Extension for Starfield",
"author": "Nexus Mods",
"private": true,
Expand Down
1 change: 0 additions & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'path';
import { resolveNativePlugins } from './util';
import { util } from 'vortex-api';

export const DEBUG_ENABLED = false;
Expand Down
10 changes: 8 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,19 @@ export const resolveNativePlugins = async (api: types.IExtensionApi): Promise<st
const state = api.getState();
const discovery = selectors.discoveryByGame(state, GAME_ID);
const cccFilePath = PLUGINS_CCC_PATTERN.replace('{{prefix}}', discovery?.path || '');
const defaultNatives = [].concat(NATIVE_PLUGINS, NATIVE_MID_PLUGINS);
try {
await fs.statAsync(cccFilePath);
const data = await fs.readFileAsync(cccFilePath, 'utf8');
const lines = data.split('\r\n').filter(plugin => plugin !== '');
const lines = data.split('\r\n').filter(plugin => plugin !== '').map(l => l.toLowerCase());
for (const native of defaultNatives) {
if (!lines.includes(native)) {
lines.push(native);
}
}
return lines;
} catch (err) {
return [].concat(NATIVE_PLUGINS, NATIVE_MID_PLUGINS);
return defaultNatives;
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/views/Saves/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export const formatPlaytime = (playtime: string): string => {
// 0d.0h.4m.0 days.0 hours.4 minutes
const regexp = /(\d+)d\.(\d+)h\.(\d+)m\.\d+ days\.\d+ hours\.\d+ minutes/g;
const match = playtime.matchAll(regexp);
if (!match || !match?.[0]) {
return playtime;
}
const groups = [...match][0];
if (groups.length < 4) {
if (groups !== undefined || groups.length < 4) {
return playtime;
}
return `${groups[1]}d ${groups[2]}h ${groups[3]}m`;
Expand Down

0 comments on commit 9974ff1

Please sign in to comment.