Skip to content

Commit db20ecb

Browse files
Merge pull request #40 from georgeistes/ui-ux-patch-1
Buttons and Health features
2 parents 71cadde + 704ccfb commit db20ecb

File tree

14 files changed

+415
-54
lines changed

14 files changed

+415
-54
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# .github/workflows/publish.yml
21
name: Publish VSCode Extension
32

43
on:
@@ -17,7 +16,9 @@ jobs:
1716
with:
1817
node-version: 18.x
1918

20-
- run: npm install
19+
- run: npm install # install the extension deps
20+
21+
- run: cd live2d-container && npm install # install overlay deps
2122

2223
- name: Publish Extension
2324
run: npm run deploy

.github/workflows/test.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.vscode/tasks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"tasks": [
66
{
77
"type": "npm",
8-
"script": "watch",
9-
"problemMatcher": "$tsc-watch",
8+
"script": "compile",
109
"isBackground": true,
10+
"problemMatcher": "$tsc-watch",
1111
"presentation": {
1212
"reveal": "never"
1313
},

assets/audio/break_reminder.mp3

72.3 KB
Binary file not shown.

assets/audio/quit.mp3

64.5 KB
Binary file not shown.

assets/audio/rest_reminder.mp3

73.1 KB
Binary file not shown.

live2d-container/ActionButtons.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,39 @@
4545
height: 24px;
4646
object-fit: contain;
4747
}
48+
49+
.action-button {
50+
position: relative;
51+
}
52+
53+
.action-button .tooltip {
54+
position: absolute;
55+
background-color: rgba(0, 0, 0, 0.8);
56+
color: white;
57+
padding: 5px 10px;
58+
border-radius: 4px;
59+
font-size: 12px;
60+
white-space: nowrap;
61+
opacity: 0;
62+
visibility: hidden;
63+
transition: opacity 0.2s ease, visibility 0.2s ease;
64+
pointer-events: none;
65+
z-index: 1000;
66+
}
67+
68+
.action-button:hover .tooltip {
69+
opacity: 1;
70+
visibility: visible;
71+
}
72+
73+
.action-buttons-container.left .tooltip {
74+
left: calc(100% + 10px);
75+
transform: translateY(-50%);
76+
top: 50%;
77+
}
78+
79+
.action-buttons-container.right .tooltip {
80+
right: calc(100% + 10px);
81+
transform: translateY(-50%);
82+
top: 50%;
83+
}

live2d-container/ActionButtons.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ class ActionButton {
1515
this.element.style.backgroundColor = backgroundColor;
1616

1717
if (tooltip) {
18-
this.element.title = tooltip;
18+
const tooltipElement = document.createElement('div');
19+
tooltipElement.className = 'tooltip';
20+
tooltipElement.textContent = tooltip;
21+
this.element.appendChild(tooltipElement);
1922
}
2023

2124
if (icon) {

live2d-container/MusicPlayer.js

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,45 @@
66
*/
77
export class MusicPlayer {
88
constructor() {
9-
// Lofi Girl's streaming URL
109
this.audioUrl = "https://play.streamafrica.net/lofiradio";
1110
this.audio = new Audio(this.audioUrl);
1211
this.isPlaying = false;
13-
14-
// Loop the music
1512
this.audio.loop = true;
13+
14+
// Set initial volume to 0
15+
this.audio.volume = 0;
16+
this.fadeInterval = null;
17+
this.fadeDuration = 1000; // 1 second fade
18+
}
19+
20+
fadeIn() {
21+
clearInterval(this.fadeInterval);
22+
let volume = 0;
23+
this.audio.volume = volume;
24+
25+
this.fadeInterval = setInterval(() => {
26+
volume += 0.05;
27+
if (volume >= 1) {
28+
volume = 1;
29+
clearInterval(this.fadeInterval);
30+
}
31+
this.audio.volume = volume;
32+
}, this.fadeDuration / 20);
33+
}
34+
35+
fadeOut() {
36+
clearInterval(this.fadeInterval);
37+
let volume = this.audio.volume;
38+
39+
this.fadeInterval = setInterval(() => {
40+
volume -= 0.05;
41+
if (volume <= 0) {
42+
volume = 0;
43+
clearInterval(this.fadeInterval);
44+
this.audio.pause();
45+
}
46+
this.audio.volume = volume;
47+
}, this.fadeDuration / 20);
1648
}
1749

1850
toggleMusic() {
@@ -26,12 +58,13 @@ export class MusicPlayer {
2658

2759
play() {
2860
this.audio.play()
61+
.then(() => this.fadeIn())
2962
.catch(error => console.error("Error playing music:", error));
3063
this.isPlaying = true;
3164
}
3265

3366
stop() {
34-
this.audio.pause();
67+
this.fadeOut();
3568
this.isPlaying = false;
3669
}
3770
}

live2d-container/index.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const loadModel = async (url) => {
157157
window.electronAPI.onCloseButton();
158158
},
159159
icon: createSVGElement(Icons.CLOSE),
160-
tooltip: 'Close'
160+
tooltip: 'Quit Cheerleader'
161161
});
162162

163163
buttonManager.addButton({
@@ -187,19 +187,24 @@ const loadModel = async (url) => {
187187
// Initialize music player
188188
const musicPlayer = new MusicPlayer();
189189

190+
// Since it modifies the innerHTML it should take care not to overwrite the tooltip
190191
buttonManager.addButton({
191-
onClick: () => {
192+
onClick: (event) => {
192193
const isPlaying = musicPlayer.toggleMusic();
193-
// Update the icon based on play state
194+
// Find the icon element and update only its content
194195
const button = event.currentTarget;
195196
if (button) {
196-
button.innerHTML = isPlaying ?
197-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/></svg>' :
198-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8 5v14l11-7z"/></svg>';
197+
// Clear existing icon content while preserving tooltip
198+
const iconSVG = button.querySelector('svg');
199+
if (iconSVG) {
200+
iconSVG.innerHTML = isPlaying ?
201+
'<path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/>' :
202+
'<path d="M8 5v14l11-7z"/>';
203+
}
199204
}
200205
},
201206
icon: createSVGElement('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8 5v14l11-7z"/></svg>'),
202-
tooltip: 'Toggle Lofi Music'
207+
tooltip: "Toggle Lofi Music"
203208
});
204209

205210
buttonManager.addButton({
@@ -215,7 +220,7 @@ const loadModel = async (url) => {
215220
window.electronAPI.runVSCodeCommand("cheerleader.rubberDuckVoice");
216221
},
217222
icon: createSVGElement(Icons.RUBBER_DUCK),
218-
tooltip: "Rubber Duck",
223+
tooltip: "Rubber Duck Debugger",
219224
});
220225

221226
buttonManager.addButton({

0 commit comments

Comments
 (0)