Skip to content

Commit

Permalink
Merge pull request #663 from tonybaloney/winter
Browse files Browse the repository at this point in the history
Add winter theme and differentiate between light and dark high-contrast themes correctly
  • Loading branch information
tonybaloney authored Jan 27, 2025
2 parents 31a98f8 + 8279690 commit 0ea9d8e
Show file tree
Hide file tree
Showing 30 changed files with 183 additions and 37 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[![Visual Studio Marketplace Installs](https://img.shields.io/visual-studio-marketplace/i/tonybaloney.vscode-pets?logo=visualstudio)](https://marketplace.visualstudio.com/items?itemName=tonybaloney.vscode-pets&WT.mc_id=python-17801-anthonyshaw)
[![Visual Studio Marketplace Downloads](https://img.shields.io/visual-studio-marketplace/d/tonybaloney.vscode-pets?logo=visualstudio)](https://marketplace.visualstudio.com/items?itemName=tonybaloney.vscode-pets&WT.mc_id=python-17801-anthonyshaw)

![screenshot](https://github.com/tonybaloney/vscode-pets/raw/main/docs/source/_static/screenshot.gif)
![screenshot](https://github.com/tonybaloney/vscode-pets/raw/main/docs/source/_static/winter.gif)

## Installation

Expand Down Expand Up @@ -60,6 +60,8 @@ Visit the [Crowdin Project](https://crowdin.com/project/vscode-pets) in case you

The cat animations were designed by [seethingswarm](https://seethingswarm.itch.io/catset). The dog media assets for this extension were designed by [NVPH Studio](https://nvph-studio.itch.io/dog-animation-4-different-dogs).

The winter theme is original artwork by [Kiana Mosser](https://www.instagram.com/kianamosser/) created for VS Code Pets.

The forest theme was designed by [edermunizz](https://edermunizz.itch.io/free-pixel-art-forest). The castle assets were created using artwork by [GuttyKreum](https://guttykreum.itch.io/gothic-castle-game-assets).

[Marc Duiker](https://twitter.com/marcduiker) created the Clippy, Rocky, Zappy, rubber duck, snake, cockatiel, Ferris the crab, and Mod the dotnet bot media assets.
Expand Down
Binary file added docs/source/_static/winter-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/winter.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,9 @@ Set ``vscode-pets.theme`` to ``"castle"`` for them to roam the ramparts!
Set ``vscode-pets.theme`` to ``"beach"`` for your friends to play by the ocean.

.. image:: _static/beach-pose.png

Set ``vscode-pets.theme`` to ``"winter"`` for your pets roam around the snowy mountains.

.. image:: _static/winter.gif

If you find the snowfall too distracting, you can disable special effects in settings.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/backgrounds/winter/background-dark-nano.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/backgrounds/winter/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/backgrounds/winter/foreground-dark-nano.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/backgrounds/winter/foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 17 additions & 4 deletions media/pets.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,26 @@ textarea::placeholder {
color: var(--vscode-input-placeholderForeground);
}

#petCanvas{
position:fixed;
bottom:0;
left:0;
#petCanvasContainer {
position: relative;
width: 100%;
height: 100%;
}

#petCanvasContainer canvas {
position: fixed;
bottom: 0;
left: 0;
z-index: 3;
}

#ballCanvas {
z-index: 3;
}
#effectCanvas {
z-index: 4;
}

img.pet {
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@
"none",
"forest",
"castle",
"beach"
"beach",
"winter"
],
"default": "none",
"description": "Background theme assets for your pets"
Expand All @@ -237,6 +238,11 @@
"type": "boolean",
"default": false,
"description": "Throw ball with mouse"
},
"vscode-pets.disableEffects": {
"type": "boolean",
"default": false,
"description": "Disable special effects like snowfall"
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const enum ColorThemeKind {
light = 1,
dark = 2,
highContrast = 3,
highContrastLight = 4,
}

export class WebviewMessage {
Expand Down Expand Up @@ -141,4 +142,10 @@ export const ALL_SCALES = [
PetSize.medium,
PetSize.large,
];
export const ALL_THEMES = [Theme.none, Theme.forest, Theme.castle, Theme.beach];
export const ALL_THEMES = [
Theme.none,
Theme.forest,
Theme.castle,
Theme.beach,
Theme.winter,
];
51 changes: 48 additions & 3 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ function getThrowWithMouseConfiguration(): boolean {
.get<boolean>('throwBallWithMouse', true);
}

function getEffectsDisabledConfiguration(): boolean {
return vscode.workspace
.getConfiguration('vscode-pets')
.get<boolean>('disableEffects', false);
}

function updatePanelDisableEffects(): void {
const panel = getPetPanel();
if (panel !== undefined) {
panel.updateDisableEffects(getEffectsDisabledConfiguration());
}
}

function updatePanelThrowWithMouse(): void {
const panel = getPetPanel();
if (panel !== undefined) {
Expand Down Expand Up @@ -300,6 +313,7 @@ export function activate(context: vscode.ExtensionContext) {
getConfiguredTheme(),
getConfiguredThemeKind(),
getThrowWithMouseConfiguration(),
getEffectsDisabledConfiguration(),
);

if (PetPanel.currentPanel) {
Expand Down Expand Up @@ -346,6 +360,7 @@ export function activate(context: vscode.ExtensionContext) {
getConfiguredTheme(),
getConfiguredThemeKind(),
getThrowWithMouseConfiguration(),
getEffectsDisabledConfiguration(),
);
updateExtensionPositionContext().catch((e) => {
console.error(e);
Expand Down Expand Up @@ -636,6 +651,10 @@ export function activate(context: vscode.ExtensionContext) {
if (e.affectsConfiguration('vscode-pets.throwBallWithMouse')) {
updatePanelThrowWithMouse();
}

if (e.affectsConfiguration('vscode-pets.disableEffects')) {
updatePanelDisableEffects();
}
},
),
);
Expand All @@ -658,6 +677,7 @@ export function activate(context: vscode.ExtensionContext) {
getConfiguredTheme(),
getConfiguredThemeKind(),
getThrowWithMouseConfiguration(),
getEffectsDisabledConfiguration(),
);
},
});
Expand Down Expand Up @@ -700,6 +720,7 @@ interface IPetPanel {
updateTheme(newTheme: Theme, themeKind: vscode.ColorThemeKind): void;
update(): void;
setThrowWithMouse(newThrowWithMouse: boolean): void;
updateDisableEffects(disableEffects: boolean): void;
}

class PetWebviewContainer implements IPetPanel {
Expand All @@ -711,6 +732,7 @@ class PetWebviewContainer implements IPetPanel {
protected _theme: Theme;
protected _themeKind: vscode.ColorThemeKind;
protected _throwBallWithMouse: boolean;
protected _disableEffects: boolean;

constructor(
extensionUri: vscode.Uri,
Expand All @@ -720,6 +742,7 @@ class PetWebviewContainer implements IPetPanel {
theme: Theme,
themeKind: ColorThemeKind,
throwBallWithMouse: boolean,
disableEffects: boolean,
) {
this._extensionUri = extensionUri;
this._petColor = color;
Expand All @@ -728,6 +751,7 @@ class PetWebviewContainer implements IPetPanel {
this._theme = theme;
this._themeKind = themeKind;
this._throwBallWithMouse = throwBallWithMouse;
this._disableEffects = disableEffects;
}

public petColor(): PetColor {
Expand All @@ -754,6 +778,10 @@ class PetWebviewContainer implements IPetPanel {
return this._throwBallWithMouse;
}

public disableEffects(): boolean {
return this._disableEffects;
}

public updatePetColor(newColor: PetColor) {
this._petColor = newColor;
}
Expand All @@ -779,6 +807,14 @@ class PetWebviewContainer implements IPetPanel {
});
}

public updateDisableEffects(disableEffects: boolean): void {
this._disableEffects = disableEffects;
void this.getWebview().postMessage({
command: 'disable-effects',
disabled: disableEffects,
});
}

public throwBall() {
void this.getWebview().postMessage({
command: 'throw-ball',
Expand Down Expand Up @@ -900,12 +936,14 @@ class PetWebviewContainer implements IPetPanel {
<title>VS Code Pets</title>
</head>
<body>
<canvas id="petCanvas"></canvas>
<canvas id="effectCanvas"></canvas>
<div id="petCanvasContainer">
<canvas id="ballCanvas"></canvas>
<canvas id="effectCanvas"></canvas>
</div>
<div id="petsContainer"></div>
<div id="foreground"></div>
<script nonce="${nonce}" src="${scriptUri}"></script>
<script nonce="${nonce}">petApp.petPanelApp("${basePetUri}", "${this.theme()}", ${this.themeKind()}, "${this.petColor()}", "${this.petSize()}", "${this.petType()}", ${this.throwBallWithMouse()});</script>
<script nonce="${nonce}">petApp.petPanelApp("${basePetUri}", "${this.theme()}", ${this.themeKind()}, "${this.petColor()}", "${this.petSize()}", "${this.petType()}", ${this.throwBallWithMouse()}, ${this.disableEffects()});</script>
</body>
</html>`;
}
Expand Down Expand Up @@ -943,6 +981,7 @@ class PetPanel extends PetWebviewContainer implements IPetPanel {
theme: Theme,
themeKind: ColorThemeKind,
throwBallWithMouse: boolean,
disableEffects: boolean,
) {
const column = vscode.window.activeTextEditor
? vscode.window.activeTextEditor.viewColumn
Expand Down Expand Up @@ -981,6 +1020,7 @@ class PetPanel extends PetWebviewContainer implements IPetPanel {
theme,
themeKind,
throwBallWithMouse,
disableEffects,
);
}

Expand Down Expand Up @@ -1014,6 +1054,7 @@ class PetPanel extends PetWebviewContainer implements IPetPanel {
theme: Theme,
themeKind: ColorThemeKind,
throwBallWithMouse: boolean,
disableEffects: boolean,
) {
PetPanel.currentPanel = new PetPanel(
panel,
Expand All @@ -1024,6 +1065,7 @@ class PetPanel extends PetWebviewContainer implements IPetPanel {
theme,
themeKind,
throwBallWithMouse,
disableEffects,
);
}

Expand All @@ -1036,6 +1078,7 @@ class PetPanel extends PetWebviewContainer implements IPetPanel {
theme: Theme,
themeKind: ColorThemeKind,
throwBallWithMouse: boolean,
disableEffects: boolean,
) {
super(
extensionUri,
Expand All @@ -1045,6 +1088,7 @@ class PetPanel extends PetWebviewContainer implements IPetPanel {
theme,
themeKind,
throwBallWithMouse,
disableEffects,
);

this._panel = panel;
Expand Down Expand Up @@ -1153,6 +1197,7 @@ async function createPetPlayground(context: vscode.ExtensionContext) {
getConfiguredTheme(),
getConfiguredThemeKind(),
getThrowWithMouseConfiguration(),
getEffectsDisabledConfiguration(),
);
if (PetPanel.currentPanel) {
var collection = PetSpecification.collectionFromMemento(
Expand Down
Loading

0 comments on commit 0ea9d8e

Please sign in to comment.