Skip to content

Commit

Permalink
Optional Pet Size
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-Hopkinson committed Apr 12, 2023
1 parent 6cd3842 commit c3e229c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const EXTRA_PETS_KEY = 'vscode-pets.extra-pets';
const EXTRA_PETS_KEY_TYPES = EXTRA_PETS_KEY + '.types';
const EXTRA_PETS_KEY_COLORS = EXTRA_PETS_KEY + '.colors';
const EXTRA_PETS_KEY_NAMES = EXTRA_PETS_KEY + '.names';
const DEFAULT_PET_SCALE = PetSize.nano;
const DEFAULT_PET_SCALE = PetSize.medium;
const DEFAULT_COLOR = PetColor.brown;
const DEFAULT_PET_TYPE = PetType.cat;
const DEFAULT_POSITION = ExtPosition.panel;
Expand Down Expand Up @@ -49,7 +49,7 @@ class PetQuickPickItem implements vscode.QuickPickItem {

let webviewViewProvider: PetWebviewViewProvider;

function getConfiguredSize(petSize: PetSize): PetSize {
function getConfiguredSize(petSize?: PetSize | any): PetSize {
var size = vscode.workspace
.getConfiguration('vscode-pets')
.get<PetSize>('petSize', petSize);
Expand Down Expand Up @@ -127,15 +127,15 @@ export class PetSpecification {
var type = vscode.workspace
.getConfiguration('vscode-pets')
.get<PetType>('petType', DEFAULT_PET_TYPE);

var size = vscode.workspace
.getConfiguration('vscode-pets')
.get<PetSize>('petSize');
if (ALL_PETS.lastIndexOf(type) === -1) {
type = DEFAULT_PET_TYPE;
}

return new PetSpecification(
color,
type,
getConfiguredSize(DEFAULT_PET_SCALE),
);
return new PetSpecification(color, type, getConfiguredSize(size));
}

static collectionFromMemento(
Expand Down Expand Up @@ -544,6 +544,11 @@ export function activate(context: vscode.ExtensionContext) {
return;
}

// store the selectedSize in the vscode.workspace
vscode.workspace
.getConfiguration('vscode-pets')
.update('petSize', selectedSize.value);

const name = await vscode.window.showInputBox({
placeHolder: vscode.l10n.t('Leave blank for a random name'),
prompt: vscode.l10n.t('Name your pet'),
Expand Down

0 comments on commit c3e229c

Please sign in to comment.