Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,29 @@ export const ToggleSourceFilterEffectType: EffectType<EffectProperties> =
categories: ["common"]
},
optionsTemplate: `
<eos-container header="Filters">
<eos-container ng-show="missingSources.length > 0">
<div class="effect-info alert alert-warning">
<p><b>Warning!</b>
Cannot find {{missingSources.length}} sources in this effect. Ensure the correct profile or scene collection is loaded in OBS, and OBS is running.
</p>
</div>
</eos-container>
<setting-container ng-show="missingSources.length > 0" header="Missing Filters ({{missingSources.length}})" collapsed="true">
<div ng-repeat="filterName in missingSources track by $index">
<div class="list-item" style="display: flex;border: 2px solid #3e4045;box-shadow: none;border-radius: 8px;padding: 5px 5px;">
<div class="pl-5">
<span>Source: {{filterName.sourceName}},</span>
<span>Name: {{filterName.filterName}},</span>
<span>Action: {{getMissingActionDisplay(filterName.action)}}</span>
</div>
<div>
<button class="btn btn-danger" ng-click="deleteSceneAtIndex($index)"><i class="far fa-trash"></i></button>
</div>
</div>
</div>
</setting-container>

<eos-container header="Filters" pad-top="missingSources.length > 0">
<div class="effect-setting-container">
<div class="input-group">
<span class="input-group-addon">Filter</span>
Expand Down Expand Up @@ -76,13 +98,15 @@ export const ToggleSourceFilterEffectType: EffectType<EffectProperties> =

$scope.searchText = "";

$scope.missingSources = [];

if ($scope.effect.selectedFilters == null) {
$scope.effect.selectedFilters = [];
}

$scope.filterIsSelected = (sourceName: string, filterName: string) => {
return $scope.effect.selectedFilters.some(
(s) => s.sourceName === sourceName && s.filterName === filterName
s => s.sourceName === sourceName && s.filterName === filterName
);
};

Expand All @@ -92,7 +116,7 @@ export const ToggleSourceFilterEffectType: EffectType<EffectProperties> =
) => {
if ($scope.filterIsSelected(sourceName, filterName)) {
$scope.effect.selectedFilters = $scope.effect.selectedFilters.filter(
(s) => !(s.sourceName === sourceName && s.filterName === filterName)
s => !(s.sourceName === sourceName && s.filterName === filterName)
);
} else {
$scope.effect.selectedFilters.push({
Expand All @@ -109,7 +133,7 @@ export const ToggleSourceFilterEffectType: EffectType<EffectProperties> =
action: "toggle" | boolean
) => {
const selectedFilter = $scope.effect.selectedFilters.find(
(s) => s.sourceName === sourceName && s.filterName === filterName
s => s.sourceName === sourceName && s.filterName === filterName
);
if (selectedFilter != null) {
selectedFilter.action = action;
Expand All @@ -121,8 +145,11 @@ export const ToggleSourceFilterEffectType: EffectType<EffectProperties> =
filterName: string
) => {
const selectedFilter = $scope.effect.selectedFilters.find(
(s) => s.sourceName === sourceName && s.filterName === filterName
s => s.sourceName === sourceName && s.filterName === filterName
);

$scope.missingSources = $scope.missingSources.filter(item => item !== selectedFilter);

if (selectedFilter == null) {
return "";
}
Expand All @@ -136,11 +163,27 @@ export const ToggleSourceFilterEffectType: EffectType<EffectProperties> =
return "Disable";
};

$scope.getMissingActionDisplay = (
selectedFilter: unknown
) => {
console.log(selectedFilter);
if (selectedFilter == null) {
return "";
}
if (selectedFilter === "toggle") {
return "Toggle";
}
if (selectedFilter === true) {
return "Enable";
}
return "Disable";
};

const capitalizeWords = (input: string) =>
input
.split(" ")
.map(
(w) => w[0].toLocaleUpperCase() + w.substr(1).toLocaleLowerCase()
w => w[0].toLocaleUpperCase() + w.substr(1).toLocaleLowerCase()
)
.join(" ");

Expand All @@ -153,12 +196,25 @@ export const ToggleSourceFilterEffectType: EffectType<EffectProperties> =
$scope.searchText = searchText;
}
$scope.sourceListFiltered = ($scope.sourceList as Array<OBSSource>).filter((source: OBSSource) => {
return source.filters.some(filter => {
return source.filters.some((filter) => {
return filter.name.toLowerCase().includes(searchText.toLowerCase());
});
});
};

$scope.deleteSceneAtIndex = (index: number) => {
$scope.effect.selectedFilters = $scope.effect.selectedFilters.filter(
item => item !== $scope.missingSources [index]
);
$scope.missingSources.splice(index, 1);
};

$scope.getStoredData = () => {
for (const filterName of $scope.effect.selectedFilters) {
$scope.missingSources.push(filterName);
}
};

$scope.getSourceList = () => {
$scope.isObsConfigured = backendCommunicator.fireEventSync("obs-is-configured");

Expand All @@ -171,6 +227,7 @@ export const ToggleSourceFilterEffectType: EffectType<EffectProperties> =
};

$scope.getSourceList();
$scope.getStoredData();
},
optionsValidator: () => {
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,27 @@ export const ToggleSourceMutedEffectType: EffectType<EffectProperties> =
categories: ["common"]
},
optionsTemplate: `
<eos-container header="Audio Sources">
<eos-container ng-show="missingSources.length > 0">
<div class="effect-info alert alert-warning">
<p><b>Warning!</b>
Cannot find {{missingSources.length}} sources in this effect. Ensure the correct profile or scene collection is loaded in OBS, and OBS is running.
</p>
</div>
</eos-container>
<setting-container ng-show="missingSources.length > 0" header="Missing Audio Sources ({{missingSources.length}})" collapsed="true">
<div ng-repeat="sourceList in missingSources track by $index">
<div class="list-item" style="display: flex;border: 2px solid #3e4045;box-shadow: none;border-radius: 8px;padding: 5px 5px;">
<div class="pl-5">
<span>Source: {{sourceList.sourceName}}</span>
</div>
<div>
<button class="btn btn-danger" ng-click="deleteSceneAtIndex($index)"><i class="far fa-trash"></i></button>
</div>
</div>
</div>
</setting-container>

<eos-container header="Audio Sources" pad-top="missingSources.length > 0">
<firebot-input model="searchText" input-title="Filter" disable-variables="true"></firebot-input>
<div>
<button class="btn btn-link" ng-click="getSourceList()">Refresh Sources</button>
Expand Down Expand Up @@ -61,20 +81,22 @@ export const ToggleSourceMutedEffectType: EffectType<EffectProperties> =

$scope.sourceList = null;

$scope.missingSources = [];

if ($scope.effect.selectedSources == null) {
$scope.effect.selectedSources = [];
}

$scope.sourceIsSelected = (sourceName: string) => {
return $scope.effect.selectedSources.some(
(s) => s.sourceName === sourceName
s => s.sourceName === sourceName
);
};

$scope.toggleSourceSelected = (sourceName: string) => {
if ($scope.sourceIsSelected(sourceName)) {
$scope.effect.selectedSources = $scope.effect.selectedSources.filter(
(s) => !(s.sourceName === sourceName)
s => !(s.sourceName === sourceName)
);
} else {
$scope.effect.selectedSources.push({
Expand All @@ -89,7 +111,7 @@ export const ToggleSourceMutedEffectType: EffectType<EffectProperties> =
action: "toggle" | boolean
) => {
const selectedSource = $scope.effect.selectedSources.find(
(s) => s.sourceName === sourceName
s => s.sourceName === sourceName
);
if (selectedSource != null) {
selectedSource.action = action;
Expand All @@ -98,8 +120,11 @@ export const ToggleSourceMutedEffectType: EffectType<EffectProperties> =

$scope.getSourceActionDisplay = (sourceName: string) => {
const selectedSource = $scope.effect.selectedSources.find(
(s) => s.sourceName === sourceName
s => s.sourceName === sourceName
);

$scope.missingSources = $scope.missingSources.filter(item => item !== selectedSource);

if (selectedSource == null) {
return "";
}
Expand All @@ -117,14 +142,27 @@ export const ToggleSourceMutedEffectType: EffectType<EffectProperties> =
input
.split(" ")
.map(
(w) => w[0].toLocaleUpperCase() + w.substr(1).toLocaleLowerCase()
w => w[0].toLocaleUpperCase() + w.substr(1).toLocaleLowerCase()
)
.join(" ");

$scope.formatSourceType = (type: string) => {
return capitalizeWords((type ?? "").replace(/_/, " "));
};

$scope.deleteSceneAtIndex = (index: number) => {
$scope.effect.selectedSources = $scope.effect.selectedSources.filter(
item => item !== $scope.missingSources [index]
);
$scope.missingSources.splice(index, 1);
};

$scope.getStoredData = () => {
for (const sceneName of $scope.effect.selectedSources) {
$scope.missingSources.push(sceneName);
}
};

$scope.getSourceList = () => {
$scope.isObsConfigured = backendCommunicator.fireEventSync("obs-is-configured");

Expand All @@ -136,6 +174,7 @@ export const ToggleSourceMutedEffectType: EffectType<EffectProperties> =
};

$scope.getSourceList();
$scope.getStoredData();
},
optionsValidator: () => {
return [];
Expand Down
Loading