-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLyrics.cpp
More file actions
105 lines (94 loc) · 2.52 KB
/
Lyrics.cpp
File metadata and controls
105 lines (94 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "pch.h"
#include "Lyrics.h"
LRCService::Lyrics::Lyrics()
{
LRCArray = gcnew System::Collections::Generic::List<LyricsLine^>();
unsyncedLyrics = gcnew System::String("");
}
void LRCService::Lyrics::AddSyncedLine(LyricsLine^ lrcLine)
{
if (isSynced)
{
LRCArray->Add(lrcLine);
}
else {
System::Diagnostics::Debug::WriteLine("LyricsService: WARN: Tried to add LyricsLine on an unsynced Lyrics object!");
setIsSynced(false);
}
}
void LRCService::Lyrics::AddUnsyncedLyrics(String^ lyrics)
{
unsyncedLyrics = lyrics;
isSynced = false;
}
bool LRCService::Lyrics::getIsSynced()
{
return isSynced;
}
void LRCService::Lyrics::setIsSynced(bool isSynced)
{
this->isSynced = isSynced;
}
void LRCService::Lyrics::updateActives(Int64 currentMilisecond, System::Windows::Forms::ListBox^ lstViewTarget)
{
if (isSynced && lstViewTarget->Items->Count == LRCArray->Count)
{
//Reverse loop
for (int i = LRCArray->Count - 1; i >= 0; i--)
{
//Is the miliseconds of the current item are LESS OR EQUAL than the current miliseconds then we assign that element to active
if (LRCArray[i]->getMiliseconds() <= currentMilisecond) {
LRCArray[i]->setIsActive(true);
if (lstViewTarget->SelectedIndex != i)
{
lstViewTarget->SelectedIndex = i;
}
//Now we set the previous element to inactive (If any)
if (i > 0)
{
LRCArray[i - 1]->setIsActive(false);
}
//And we exit the function
return;
}
}
}
else {
System::Diagnostics::Debug::WriteLine("LyricsService: WARN: Tried to update actives for an unsynced lyrics object!");
setIsSynced(false);
}
}
System::Collections::Generic::List<LRCService::LyricsLine^>^ LRCService::Lyrics::getArray()
{
return LRCArray;
}
void LRCService::Lyrics::populateList(System::Windows::Forms::ListBox^ lstViewTarget)
{
for (size_t i = 0; i < LRCArray->Count; i++)
{
lstViewTarget->Items->Add(LRCArray[i]->ToString());
}
}
void LRCService::Lyrics::clear()
{
LRCArray->Clear();
}
void LRCService::Lyrics::updateList(System::Windows::Forms::ListBox^ lstViewTarget)
{
if (lstViewTarget->Items->Count == LRCArray->Count)
{
for (size_t i = 0; i < lstViewTarget->Items->Count; i++)
{
if (lstViewTarget->SelectedItems->Contains(lstViewTarget->Items[i]) != LRCArray[i]->getIsActive()) {
//Lyrics is active here
lstViewTarget->SelectedItem = lstViewTarget->Items[i];
}
else {
//Lyrics is no longer active here
}
}
}
else {
Diagnostics::Debug::WriteLine("LyricsService: ERR: Tried to update list that doesnt match internal array size!");
}
}