forked from Icclear/OsuBot-3.0
-
Notifications
You must be signed in to change notification settings - Fork 1
/
program.cpp
91 lines (68 loc) · 1.81 KB
/
program.cpp
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
#include "program.hpp"
Program::Program()
{
Error = Osu.getError();
LoadSongList();
PlayingThread = new std::thread(Program::checkForPlaying, this);
PlayManagerCloser = nullptr;
}
Program::~Program()
{
if(Running && PlayManagerCloser != nullptr)
{
PlayManagerCloser->StopPlaying();
}
Running = false;
while(!PlayingThread->joinable())
Sleep(10);
PlayingThread->join(); //Todo: Somehow terminate that thread.
delete PlayingThread;
}
void Program::LoadSongList()
{
SongFolderList.clear();
char szBuffer[MAX_PATH];
GetCurrentDirectory(MAX_PATH, szBuffer);
SetCurrentDirectory(Osu.getSongPath().c_str());
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile("*.", &fd);
// Get all sub-folders:
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
char* pszName = fd.cFileName;
if (_stricmp(pszName, ".") != 0 && _stricmp(pszName, "..") != 0)
{
SongFolderList.push_back(pszName);
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
// Set the current folder back to what it was:
SetCurrentDirectory(szBuffer);
}
void Program::LoadBeatmap(std::string BeatmapPath)
{
LoadedBeatmap.LoadBeatmap(BeatmapPath);
}
void Program::checkForPlaying()
{
while(Running)
{
if(LoadedBeatmap.isLoaded())
{
Osu.readPlaying(Playing);
if(Playing)
{
Playmanagement Play(LoadedBeatmap, Osu);
Play.setAuto(AutoEnabled);
Play.setRelax(RelaxEnabled);
PlayManagerCloser = &Play;
Play.StartPlaying();
PlayManagerCloser = nullptr;
}
}
Sleep(100);
}
}