Skip to content

Commit

Permalink
Merge pull request OpenWebGAL#166 from MakinoharaShoko/4.X-dev
Browse files Browse the repository at this point in the history
改变效果应用的逻辑
  • Loading branch information
MakinoharaShoko authored Apr 16, 2022
2 parents b45ec99 + 5414d49 commit 6469958
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 61 deletions.
44 changes: 22 additions & 22 deletions src/Components/Stage/MainStage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@ export const MainStage: FC = () => {
const stageStore = useStore(stageStateStore);
const GuiState = useStore(GuiStateStore);
useEffect(() => {
// const effectList: Array<IEffect> = stageStore.stageState.effects;
const effectList: Array<IEffect> = stageStore.stageState.effects;

// 设置效果
setTimeout(() => {
const bg = document.getElementById('MainStage_bg_MainContainer');
// effectList.forEach(effect => {
// const target = document.getElementById(effect.target);
// if (target) {
// if (effect.filter !== '') {
// target.style.filter = effect.filter;
// }
// if (effect.transform !== '') {
// target.style.transform = effect.transform;
// }
// }
// });
if (stageStore.stageState.bgTransform !== '') {
if(bg){
bg.style.transform = stageStore.stageState.bgTransform;
}
}
if (stageStore.stageState.bgFilter !== '') {
if(bg){
bg.style.filter= stageStore.stageState.bgFilter;
// const bg = document.getElementById('MainStage_bg_MainContainer');
effectList.forEach(effect => {
const target = document.getElementById(effect.target);
if (target) {
if (effect.filter !== '') {
target.style.filter = effect.filter;
}
if (effect.transform !== '') {
target.style.transform = effect.transform;
}
}
}
});
// if (stageStore.stageState.bgTransform !== '') {
// if(bg){
// bg.style.transform = stageStore.stageState.bgTransform;
// }
// }
// if (stageStore.stageState.bgFilter !== '') {
// if(bg){
// bg.style.filter= stageStore.stageState.bgFilter;
// }
// }
}, 100);
});
return <div className={styles.MainStage_main}>
Expand Down
34 changes: 17 additions & 17 deletions src/Core/controller/gamePlay/scripts/setBgFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ import { logger } from '@/Core/util/logger';
*/
export const setBgFilter = (sentence: ISentence): IPerform => {
const stageStore = getRef('stageRef');
// const effectList: Array<IEffect> = __.cloneDeep(stageStore.stageState.effects);
// let isTargetSet = false;
// effectList.forEach((e) => {
// if (e.target === 'MainStage_bg_MainContainer') {
// logger.warn('已存在效果,正在修改');
// isTargetSet = true;
// e.filter = sentence.content;
// }
// });
// if (!isTargetSet) {
// effectList.push({
// target: 'MainStage_bg_MainContainer',
// transform: '',
// filter: sentence.content
// });
// }
stageStore.setStage('bgFilter', sentence.content);
const effectList: Array<IEffect> =stageStore.stageState.effects;
let isTargetSet = false;
effectList.forEach((e) => {
if (e.target === 'MainStage_bg_MainContainer') {
logger.warn('已存在效果,正在修改');
isTargetSet = true;
e.filter = sentence.content;
}
});
if (!isTargetSet) {
effectList.push({
target: 'MainStage_bg_MainContainer',
transform: '',
filter: sentence.content
});
}
// stageStore.setStage('bgFilter', sentence.content);
return {
performName: 'none',
duration: 0,
Expand Down
32 changes: 16 additions & 16 deletions src/Core/controller/gamePlay/scripts/setBgTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ import * as __ from 'lodash';
*/
export const setBgTransform = (sentence: ISentence): IPerform => {
const stageStore = getRef('stageRef');
// const effectList: Array<IEffect> = __.cloneDeep(stageStore.stageState.effects);
// let isTargetSet = false;
// effectList.forEach((e) => {
// if (e.target === 'MainStage_bg_MainContainer') {
// isTargetSet = true;
// e.transform = sentence.content;
// }
// });
// if (!isTargetSet) {
// effectList.push({
// target: 'MainStage_bg_MainContainer',
// transform: sentence.content,
// filter: ''
// });
// }
const effectList: Array<IEffect> = stageStore.stageState.effects;
let isTargetSet = false;
effectList.forEach((e) => {
if (e.target === 'MainStage_bg_MainContainer') {
isTargetSet = true;
e.transform = sentence.content;
}
});
if (!isTargetSet) {
effectList.push({
target: 'MainStage_bg_MainContainer',
transform: sentence.content,
filter: ''
});
}
// stageStore.setStage('effects', effectList);
stageStore.setStage('bgTransform',sentence.content);
// stageStore.setStage('bgTransform',sentence.content);
return {
performName: 'none',
duration: 0,
Expand Down
5 changes: 3 additions & 2 deletions src/Core/interface/stateInterface/stageInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { IRunPerform } from '../coreInterface/performInterface';
* @interface IGameVar
*/
export interface IGameVar {
[propName: string]: string | boolean | number // 游戏内变量可以是字符串、布尔值、数字
key:string // 变量名称是字符串
value: string | boolean | number // 游戏内变量可以是字符串、布尔值、数字
}

/**
Expand Down Expand Up @@ -44,7 +45,7 @@ export interface IStageState {
vocal: string // 语音 文件地址(相对或绝对)
bgm: string // 背景音乐 文件地址(相对或绝对)
miniAvatar: string // 小头像 文件地址(相对或绝对)
GameVar: IGameVar // 游戏内变量
GameVar: Array<IGameVar> // 游戏内变量
effects: Array<IEffect> // 应用的变换
bgTransform:string,
bgFilter:string,
Expand Down
8 changes: 4 additions & 4 deletions src/Core/store/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export const initState: IStageState = {
showText: '', // 文字
showName: '', // 人物名
command: '', // 语句指令
choose: [], // 选项列表
choose: [], // 选项列表,现在不用,先预留
vocal: '', // 语音 文件地址(相对或绝对)
bgm: '', // 背景音乐 文件地址(相对或绝对)
miniAvatar: '', // 小头像 文件地址(相对或绝对)
GameVar: {}, // 游戏内变量
GameVar: [], // 游戏内变量
effects: [], // 应用的效果
bgFilter:'',
bgTransform:'',
bgFilter:'', // 现在不用,先预留
bgTransform:'', // 现在不用,先预留
PerformList: [], // 要启动的演出列表
};

Expand Down

0 comments on commit 6469958

Please sign in to comment.