mirror of
https://github.com/HappyTanuki/BumbleCee.git
synced 2025-10-26 01:45:15 +00:00
와 이제 진짜 진짜 버그 다 고친 듯?
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef _ASYNCDOWNLOADMANAGER_HPP_
|
||||
#define _ASYNCDOWNLOADMANAGER_HPP_
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
@@ -55,6 +53,4 @@ private:
|
||||
std::vector<std::thread> worker_thread;
|
||||
bool terminate;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef _CONSOLEUTILS_HPP_
|
||||
#define _CONSOLEUTILS_HPP_
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <queue>
|
||||
@@ -35,6 +33,4 @@ public:
|
||||
return tokens;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
84
include/Utils/QueuedMusicListEmbedProvider.hpp
Normal file
84
include/Utils/QueuedMusicListEmbedProvider.hpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
#include <dpp/dpp.h>
|
||||
#include <Queue/MusicQueueElement.hpp>
|
||||
#include <cmath>
|
||||
|
||||
namespace bumbleBee {
|
||||
class QueuedMusicListEmbedProvider {
|
||||
public:
|
||||
static std::queue<dpp::embed> makeEmbed(std::list<std::shared_ptr<MusicQueueElement>> queue, std::list<std::shared_ptr<MusicQueueElement>>::iterator np, bool repeat) {
|
||||
std::queue<dpp::embed> returnValue;
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator it = queue.begin();
|
||||
if (queue.size() == 0) {
|
||||
dpp::embed embed = makeEmbedPart(queue, np, repeat, it);
|
||||
returnValue.push(embed);
|
||||
return returnValue;
|
||||
}
|
||||
for (int i = 0; i < std::ceil(queue.size() / 5.0); i++) {
|
||||
dpp::embed embed = makeEmbedPart(queue, np, repeat, it);
|
||||
returnValue.push(embed);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
static int distance(const std::list<std::shared_ptr<MusicQueueElement>>::iterator a, const std::list<std::shared_ptr<MusicQueueElement>>::iterator b) {
|
||||
int i = 0;
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator mutatea = a;
|
||||
while (mutatea++ == b)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
private:
|
||||
static dpp::embed makeEmbedPart(
|
||||
std::list<std::shared_ptr<MusicQueueElement>> queue,
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator np,
|
||||
bool repeat,
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator startIter) {
|
||||
dpp::embed embed = dpp::embed()
|
||||
.set_color(dpp::colors::sti_blue);
|
||||
|
||||
if (queue.begin() == queue.end()) {
|
||||
embed
|
||||
.set_title("큐가 비었습니다!")
|
||||
.set_timestamp(time(0));
|
||||
|
||||
if (repeat)
|
||||
embed.add_field(":repeat:","");
|
||||
|
||||
return embed;
|
||||
}
|
||||
|
||||
int startIndex = distance(queue.begin(), startIter) + 1;
|
||||
int index = startIndex;
|
||||
|
||||
for (; (index < startIndex + 5) && startIter != queue.end() && index < queue.size()+1; startIter++, index++) { //iter로 순회하면 왠지 모르게 이상한 값을 읽을 때가 있음 이유는 나도 몰?루
|
||||
if (*startIter == *np)
|
||||
embed.add_field (
|
||||
"np",
|
||||
"",
|
||||
true
|
||||
);
|
||||
else
|
||||
embed.add_field (
|
||||
std::to_string(index),
|
||||
"",
|
||||
true
|
||||
);
|
||||
embed.add_field (
|
||||
(*startIter)->embed.title,
|
||||
(*startIter)->embed.description,
|
||||
true
|
||||
)
|
||||
.add_field("","");
|
||||
}
|
||||
|
||||
if (startIter == queue.end() || index >= queue.size()+1) {
|
||||
embed.set_timestamp(time(0));
|
||||
if (repeat)
|
||||
embed.add_field(":repeat:","");
|
||||
}
|
||||
|
||||
return embed;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef _VERSIONCHECKUTILS_HPP_
|
||||
#define _VERSIONCHECKUTILS_HPP_
|
||||
#include <dpp/dpp.h>
|
||||
#include "ConsoleUtils.hpp"
|
||||
#include "../Settings/SettingsManager.hpp"
|
||||
@@ -73,5 +71,4 @@ public:
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user