mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-05 16:16:18 -05:00
Merge remote-tracking branch 'WarmUpTill/master'
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <mutex>
|
||||
#include <fstream>
|
||||
#include <QDateTime>
|
||||
#include <QThread>
|
||||
#include "utility.hpp"
|
||||
|
||||
#define DEFAULT_INTERVAL 300
|
||||
@@ -23,6 +24,7 @@
|
||||
#define SCREEN_REGION_FUNC 4
|
||||
#define WINDOW_TITLE_FUNC 5
|
||||
#define MEDIA_FUNC 6
|
||||
#define TIME_FUNC 7
|
||||
|
||||
#define DEFAULT_PRIORITY_0 READ_FILE_FUNC
|
||||
#define DEFAULT_PRIORITY_1 ROUND_TRIP_FUNC
|
||||
@@ -31,6 +33,7 @@
|
||||
#define DEFAULT_PRIORITY_4 SCREEN_REGION_FUNC
|
||||
#define DEFAULT_PRIORITY_5 WINDOW_TITLE_FUNC
|
||||
#define DEFAULT_PRIORITY_6 MEDIA_FUNC
|
||||
#define DEFAULT_PRIORITY_7 TIME_FUNC
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -227,6 +230,26 @@ struct MediaSwitch {
|
||||
}
|
||||
};
|
||||
|
||||
struct TimeSwitch {
|
||||
OBSWeakSource scene;
|
||||
OBSWeakSource transition;
|
||||
QTime time;
|
||||
bool matched;
|
||||
bool usePreviousScene;
|
||||
string timeSwitchStr;
|
||||
|
||||
inline TimeSwitch(OBSWeakSource scene_, OBSWeakSource transition_,
|
||||
QTime time_, bool usePreviousScene_,
|
||||
string timeSwitchStr_)
|
||||
: scene(scene_),
|
||||
transition(transition_),
|
||||
time(time_),
|
||||
usePreviousScene(usePreviousScene_),
|
||||
timeSwitchStr(timeSwitchStr_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
typedef enum { NO_SWITCH = 0, SWITCH = 1, RANDOM_SWITCH = 2 } NoMatch;
|
||||
|
||||
/********************************************************************************
|
||||
@@ -281,10 +304,24 @@ struct SwitcherData {
|
||||
|
||||
vector<MediaSwitch> mediaSwitches;
|
||||
|
||||
vector<TimeSwitch> timeSwitches;
|
||||
|
||||
vector<int> functionNamesByPriority = vector<int>{
|
||||
DEFAULT_PRIORITY_0, DEFAULT_PRIORITY_1, DEFAULT_PRIORITY_2,
|
||||
DEFAULT_PRIORITY_3, DEFAULT_PRIORITY_4, DEFAULT_PRIORITY_5,
|
||||
DEFAULT_PRIORITY_6};
|
||||
DEFAULT_PRIORITY_6, DEFAULT_PRIORITY_7};
|
||||
|
||||
std::vector<std::string> threadPrioritiesNamesOrderdByPrio{
|
||||
"Lowest", "Low", "Normal", "High", "Highest", "Time critical",
|
||||
};
|
||||
std::map<std::string, int> threadPriorities = {
|
||||
{"Lowest", QThread::LowestPriority},
|
||||
{"Low", QThread::LowPriority},
|
||||
{"Normal", QThread::NormalPriority},
|
||||
{"High", QThread::HighPriority},
|
||||
{"Highest", QThread::HighestPriority},
|
||||
{"Time critical", QThread::TimeCriticalPriority},
|
||||
};
|
||||
|
||||
void Thread();
|
||||
void Start();
|
||||
@@ -315,6 +352,8 @@ struct SwitcherData {
|
||||
OBSWeakSource &transition, int &delay);
|
||||
void checkMediaSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkTimeSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
|
||||
void Prune()
|
||||
{
|
||||
@@ -401,6 +440,13 @@ struct SwitcherData {
|
||||
fileSwitches.erase(fileSwitches.begin() + i--);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < timeSwitches.size(); i++) {
|
||||
TimeSwitch &s = timeSwitches[i];
|
||||
if (!WeakSourceValid(s.scene) ||
|
||||
!WeakSourceValid(s.transition))
|
||||
timeSwitches.erase(timeSwitches.begin() + i--);
|
||||
}
|
||||
|
||||
if (!idleData.usePreviousScene &&
|
||||
!WeakSourceValid(idleData.scene) ||
|
||||
!WeakSourceValid(idleData.transition)) {
|
||||
|
||||
Reference in New Issue
Block a user