Skip to content

Commit

Permalink
re-run eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitalita committed Oct 2, 2023
1 parent 4065424 commit 7e29bf8
Show file tree
Hide file tree
Showing 27 changed files with 1,472 additions and 1,394 deletions.
12 changes: 6 additions & 6 deletions src/papyrus-lang-vscode/src/CreationKitInfoProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ function getDefaultPapyrusConfigForGame(game: PapyrusGame): ICreationKitPapyrusC
sScriptCompiledFolder,
};
case PapyrusGame.starfield:
// TODO: Starfield: verify what these are when the CK comes out
return {
sScriptSourceFolder: '.\\Data\\Scripts\\Source\\',
sCompilerFolder,
sScriptCompiledFolder,
};
// TODO: Starfield: verify what these are when the CK comes out
return {
sScriptSourceFolder: '.\\Data\\Scripts\\Source\\',
sCompilerFolder,
sScriptCompiledFolder,
};
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/papyrus-lang-vscode/src/ExtensionConfigProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { injectable, interfaces } from 'inversify';
import { workspace, Disposable } from 'vscode';
import { eventToValueObservable } from './common/vscode/reactive/Events';
import { Observable } from 'rxjs';
import { filter } from 'rxjs/operators';
import { PapyrusGame } from './PapyrusGame';
import { FindGamePath } from './common/GameHelpers';
export interface IGameConfig {
readonly enabled: boolean;
readonly creationKitIniFiles: string[];
Expand Down
49 changes: 20 additions & 29 deletions src/papyrus-lang-vscode/src/PapyrusGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const displayNames = new Map([
[PapyrusGame.fallout4, 'Fallout 4'],
[PapyrusGame.skyrim, 'Skyrim'],
[PapyrusGame.skyrimSpecialEdition, 'Skyrim Special Edition/Anniversary Edition'],
[PapyrusGame.starfield, 'Starfield']
[PapyrusGame.starfield, 'Starfield'],
]);

export function getDisplayNameForGame(game: PapyrusGame) {
Expand All @@ -23,13 +23,11 @@ const shortDisplayNames = new Map([
[PapyrusGame.starfield, 'Starfield'],
]);

const scriptExtenderNames = new Map(
[
[PapyrusGame.fallout4, 'F4SE'],
[PapyrusGame.skyrimSpecialEdition, 'SKSE'],
[PapyrusGame.starfield, 'SFSE']
]
);
const scriptExtenderNames = new Map([
[PapyrusGame.fallout4, 'F4SE'],
[PapyrusGame.skyrimSpecialEdition, 'SKSE'],
[PapyrusGame.starfield, 'SFSE'],
]);

export function getScriptExtenderName(game: PapyrusGame) {
return scriptExtenderNames.get(game);
Expand Down Expand Up @@ -61,13 +59,9 @@ export function getGames(): PapyrusGame[] {
return (Object.keys(PapyrusGame) as (keyof typeof PapyrusGame)[]).map((k) => PapyrusGame[k]);
}

const commonOldRegPrefix = `\\SOFTWARE\\${
process.arch === 'x64' ? 'WOW6432Node\\' : ''
}Bethesda Softworks\\`

const commonOldRegPrefix = `\\SOFTWARE\\${process.arch === 'x64' ? 'WOW6432Node\\' : ''}Bethesda Softworks\\`;

export function getRegistryKeyForGame(game: PapyrusGame) {

switch (game) {
case PapyrusGame.fallout4:
return commonOldRegPrefix + 'Fallout4';
Expand All @@ -76,18 +70,18 @@ export function getRegistryKeyForGame(game: PapyrusGame) {
case PapyrusGame.skyrimSpecialEdition:
return commonOldRegPrefix + 'Skyrim Special Edition';
case PapyrusGame.starfield:
return '\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 1716740'
return '\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 1716740';
}
}

export function getInstalledPathRegVal(game:PapyrusGame){
export function getInstalledPathRegVal(game: PapyrusGame) {
switch (game) {
case PapyrusGame.fallout4:
case PapyrusGame.skyrim:
case PapyrusGame.skyrimSpecialEdition:
return 'installed path';
case PapyrusGame.starfield:
return 'InstallLocation'
return 'InstallLocation';
}
}

Expand All @@ -106,7 +100,6 @@ export function getDevelopmentCompilerFolderForGame(game: PapyrusGame) {
}

export function getDefaultFlagsFileNameForGame(game: PapyrusGame) {

switch (game) {
case PapyrusGame.fallout4:
return 'Institute_Papyrus_Flags.flg';
Expand All @@ -117,14 +110,13 @@ export function getDefaultFlagsFileNameForGame(game: PapyrusGame) {
case PapyrusGame.starfield:
return 'Starfield_Papyrus_Flags.flg';
}

}

const executableNames = new Map([
[PapyrusGame.skyrim, 'Skyrim.exe'],
[PapyrusGame.fallout4, 'Fallout4.exe'],
[PapyrusGame.skyrimSpecialEdition, 'SkyrimSE.exe'],
[PapyrusGame.starfield, 'Starfield.exe']
[PapyrusGame.starfield, 'Starfield.exe'],
]);

export function getExecutableNameForGame(game: PapyrusGame) {
Expand Down Expand Up @@ -157,19 +149,18 @@ export function getGameCustomIniName(game: PapyrusGame): string {
}
}


// TODO: Support VR
export enum GameVariant {
Steam = "Steam",
GOG = "GOG",
Epic = "Epic Games",
GamePass = "Game Pass"
Steam = 'Steam',
GOG = 'GOG',
Epic = 'Epic Games',
GamePass = 'Game Pass',
}

/**
* returns the name of the Game Save folder for the given variant
* Resides in "%USERPROFILE%\Documents\My Games"
*
*
* @param game
* @param variant
* @returns string - the name of the game save folder
Expand All @@ -192,10 +183,10 @@ export function GetUserGameFolderName(game: PapyrusGame, variant: GameVariant) {
case PapyrusGame.starfield:
switch (variant) {
case GameVariant.Steam:
return "Starfield";
case GameVariant.GamePass: // TODO: Starfield: verify what this is
return "Starfield";
return 'Starfield';
case GameVariant.GamePass: // TODO: Starfield: verify what this is
return 'Starfield';
}
}
return "";
return '';
}
134 changes: 70 additions & 64 deletions src/papyrus-lang-vscode/src/common/GameHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import path from "path";
import { getRegistryKeyForGame, PapyrusGame, GameVariant, GetUserGameFolderName, getScriptExtenderName, getInstalledPathRegVal } from "../PapyrusGame";
import * as fs from "fs";
import { promisify } from "util";
import { AddressLibAssetSuffix, AddressLibraryF4SEModName, AddressLibraryName, AddressLibrarySKSEAEModName, AddressLibrarySKSEModName } from "./constants";
import { INIData } from "./INIHelpers";
import { getHomeFolder, getRegistryValueData } from "./OSHelpers";
import { get } from "http";
import path from 'path';
import {
getRegistryKeyForGame,
PapyrusGame,
GameVariant,
GetUserGameFolderName,
getScriptExtenderName,
getInstalledPathRegVal,
} from '../PapyrusGame';
import * as fs from 'fs';
import { promisify } from 'util';
import {
AddressLibAssetSuffix,
AddressLibraryF4SEModName,
AddressLibraryName,
AddressLibrarySKSEAEModName,
AddressLibrarySKSEModName,
} from './constants';
import { INIData } from './INIHelpers';
import { getHomeFolder, getRegistryValueData } from './OSHelpers';

const exists = promisify(fs.exists);
const readdir = promisify(fs.readdir);
Expand Down Expand Up @@ -44,32 +56,28 @@ export function getAddressLibNames(game: PapyrusGame): AddressLibraryName[] {
}

export function CheckIfDebuggingIsEnabledInIni(game: PapyrusGame, iniData: INIData) {
let check = (
iniData.Papyrus.bLoadDebugInformation === 1 &&
iniData.Papyrus.bEnableTrace === 1 &&
iniData.Papyrus.bEnableLogging === 1
);
if (game == PapyrusGame.starfield) {
check = check && (
iniData.Papyrus.bEnableRemoteDebugging === 1 &&
iniData.Papyrus.iRemoteDebuggingPort === 20548 // TODO: Starfield: make this dynamic
)
}
return check;
let check =
iniData.Papyrus.bLoadDebugInformation === 1 &&
iniData.Papyrus.bEnableTrace === 1 &&
iniData.Papyrus.bEnableLogging === 1;
if (game == PapyrusGame.starfield) {
check = check && iniData.Papyrus.bEnableRemoteDebugging === 1 && iniData.Papyrus.iRemoteDebuggingPort === 20548; // TODO: Starfield: make this dynamic
}
return check;
}

export function TurnOnDebuggingInIni(game: PapyrusGame, iniData: INIData) {
const _ini = structuredClone(iniData);
_ini.Papyrus.bLoadDebugInformation = 1;
_ini.Papyrus.bEnableTrace = 1;
_ini.Papyrus.bEnableLogging = 1;
if (game === PapyrusGame.starfield){
_ini.Papyrus.bRemoteDebuggingLogVerbose = 1;
_ini.Papyrus.bEnableRemoteDebugging = 1;
_ini.Papyrus.iRemoteDebuggingPort = 20548; // TODO: STarfield: make this dynamic
}
return _ini;
const _ini = structuredClone(iniData);

_ini.Papyrus.bLoadDebugInformation = 1;
_ini.Papyrus.bEnableTrace = 1;
_ini.Papyrus.bEnableLogging = 1;
if (game === PapyrusGame.starfield) {
_ini.Papyrus.bRemoteDebuggingLogVerbose = 1;
_ini.Papyrus.bEnableRemoteDebugging = 1;
_ini.Papyrus.iRemoteDebuggingPort = 20548; // TODO: STarfield: make this dynamic
}
return _ini;
}

export async function FindUserGamePath(game: PapyrusGame, variant: GameVariant): Promise<string | null> {
Expand Down Expand Up @@ -171,43 +179,41 @@ async function findSkyrimSEGOG(): Promise<string | null> {
}

async function FindGameSteamPath(game: PapyrusGame): Promise<string | null> {
const key = getRegistryKeyForGame(game);
const val = getInstalledPathRegVal(game);
const pathValue = await getRegistryValueData(key, val);
if (pathValue && (await exists(pathValue))) {
return pathValue;
}
return null;
const key = getRegistryKeyForGame(game);
const val = getInstalledPathRegVal(game);
const pathValue = await getRegistryValueData(key, val);
if (pathValue && (await exists(pathValue))) {
return pathValue;
}
return null;
}

export async function FindGamePath(game: PapyrusGame)
{
switch (game) {
case PapyrusGame.fallout4:
case PapyrusGame.skyrim:
return FindGameSteamPath(game);
export async function FindGamePath(game: PapyrusGame) {
switch (game) {
case PapyrusGame.fallout4:
case PapyrusGame.skyrim:
return FindGameSteamPath(game);
// TODO: support gamepass version of starfield
case PapyrusGame.starfield:
return FindGameSteamPath(game);
case PapyrusGame.skyrimSpecialEdition: {
let path = await FindGameSteamPath(game);
if (path) {
return path;
}
path = await findSkyrimSEGOG();
if (path) {
return path;
}
path = await findSkyrimSEEpic();
if (path) {
return path;
case PapyrusGame.starfield:
return FindGameSteamPath(game);
case PapyrusGame.skyrimSpecialEdition: {
let path = await FindGameSteamPath(game);
if (path) {
return path;
}
path = await findSkyrimSEGOG();
if (path) {
return path;
}
path = await findSkyrimSEEpic();
if (path) {
return path;
}
}
}
default:
break;
}
return null;

default:
break;
}
return null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/papyrus-lang-vscode/src/common/MO2Lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function getIDFromNXMHandlerName(nxmName: string): MO2LongGameID | undefined {
const _nxmName = nxmName.toLowerCase().replace(/ /g, '');
switch (_nxmName) {
case 'starfield':
return 'Starfield'
return 'Starfield';
case 'skyrimse':
case 'skyrimspecialedition':
return 'Skyrim Special Edition';
Expand Down
2 changes: 1 addition & 1 deletion src/papyrus-lang-vscode/src/common/PathResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export function getPluginDllName(game: PapyrusGame, legacy = false) {
case PapyrusGame.skyrimSpecialEdition:
return 'DarkId.Papyrus.DebugServer.Skyrim.dll';
default:
throw new Error("Debugging plugin not implemented for game " + game);
throw new Error('Debugging plugin not implemented for game ' + game);
}
}

Expand Down
38 changes: 19 additions & 19 deletions src/papyrus-lang-vscode/src/common/colorizer/colorizer.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import * as chalk_d from 'chalk'
import * as chalk_d from 'chalk';
import get from 'lodash.get';
import { ColorizerOptions, Token } from './types';

interface ColorMap {
[key: string]: string;
[key: string]: string;
}

const defaultColors: ColorMap = {
BRACE: 'gray',
BRACKET: 'gray',
COLON: 'gray',
COMMA: 'gray',
STRING_KEY: 'magenta',
STRING_LITERAL: 'yellow',
NUMBER_LITERAL: 'green',
BOOLEAN_LITERAL: 'cyan',
NULL_LITERAL: 'white'
BRACE: 'gray',
BRACKET: 'gray',
COLON: 'gray',
COMMA: 'gray',
STRING_KEY: 'magenta',
STRING_LITERAL: 'yellow',
NUMBER_LITERAL: 'green',
BOOLEAN_LITERAL: 'cyan',
NULL_LITERAL: 'white',
};

const nonForcedChalk = new chalk_d.default.constructor();
const forcedChalk = new chalk_d.default.constructor({ enabled: true, level: 2 });
export function colorize(tokens: Token[], options?: ColorizerOptions): string {
const colors = options?.colors || {};
const colors = options?.colors || {};

return tokens.reduce((acc, token) => {
const chalk : chalk_d.Chalk = options?.forceColor ? forcedChalk : nonForcedChalk;
const colorKey = colors[token.type] || defaultColors[token.type];
const colorFn = colorKey && colorKey[0] === '#' ? chalk.hex(colorKey) : get(chalk, colorKey);
return tokens.reduce((acc, token) => {
const chalk: chalk_d.Chalk = options?.forceColor ? forcedChalk : nonForcedChalk;
const colorKey = colors[token.type] || defaultColors[token.type];
const colorFn = colorKey && colorKey[0] === '#' ? chalk.hex(colorKey) : get(chalk, colorKey);

return acc + (colorFn ? colorFn(token.value) : token.value);
}, '');
}
return acc + (colorFn ? colorFn(token.value) : token.value);
}, '');
}
Loading

0 comments on commit 7e29bf8

Please sign in to comment.