Skip to content

Commit

Permalink
Add vscode-pets.change-pet-size commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-Hopkinson committed Aug 24, 2024
1 parent f3aa711 commit 88e7143
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@
"command": "vscode-pets.roll-call",
"title": "Roll-call",
"category": "Pet Coding"
},
{
"command": "vscode-pets.change-pet-size",
"title": "Change pet size",
"category": "Pet Coding"
}
],
"configuration": [
Expand Down
51 changes: 51 additions & 0 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,57 @@ export function activate(context: vscode.ExtensionContext) {
),
);

context.subscriptions.push(
vscode.commands.registerCommand(
'vscode-pets.change-pet-size',
async () => {
const panel = getPetPanel();
if (panel !== undefined) {
// show quick pick of all the pets
const petList = PetSpecification.collectionFromMemento(
context,
getConfiguredSize(DEFAULT_PET_SCALE),
);
const selectedPet = await vscode.window.showQuickPick(
petList.map((pet) => ({
label: pet.name,
description: `${pet.color} ${pet.type}`,
value: pet,
})),
{
placeHolder: vscode.l10n.t('Select a pet'),
},
);
if (selectedPet === undefined) {
return;
}
const selectedSize = await vscode.window.showQuickPick(
Object.values(PetSize).map((value) => ({
label: value,
value: value,
})),
{
placeHolder: 'Select a size',
},
);
if (selectedSize === undefined) {
return;
}
selectedPet.value.size = selectedSize.value;
panel.spawnPet(selectedPet.value);
await storeCollectionAsMemento(context, petList);
} else {
await createPetPlayground(context);
await vscode.window.showInformationMessage(
vscode.l10n.t(
"A Pet Playground has been created. You can now use the 'Change Pet Size' Command to change the size of the pets.",
),
);
}
},
),
);

// Listening to configuration changes
context.subscriptions.push(
vscode.workspace.onDidChangeConfiguration(
Expand Down

0 comments on commit 88e7143

Please sign in to comment.