Updated pixi.
Maybe fixed a case from interpolation that a sprite could not be cleaned up. Need to make a better system for controlling sprites. Added binds for arrow keys to scroll multiline text. Added support for colorto tween changing tint not just alpha.
This commit is contained in:
parent
2287163a34
commit
d356f17adb
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
|||||||
/
|
/
|
||||||
web.config
|
web.config
|
||||||
/Js/Typed
|
/Js/Typed
|
||||||
|
/Js/[Pp]ixi.js
|
||||||
/node_modules
|
/node_modules
|
||||||
/Js/XduPlayer.js
|
/Js/XduPlayer.js
|
||||||
/Js/XduPlayer.min.js.map
|
/Js/XduPlayer.min.js.map
|
||||||
|
27
Js/Common.js
27
Js/Common.js
@ -158,11 +158,12 @@ class commonFunctions {
|
|||||||
let color = '';
|
let color = '';
|
||||||
name = name.substring(1);
|
name = name.substring(1);
|
||||||
if(name.length === 8) {
|
if(name.length === 8) {
|
||||||
color = name.slice(0, 6);
|
color = parseInt(name.slice(0, 6), 16);
|
||||||
alpha = name.slice(6, 8);
|
alpha = parseInt(name.slice(6, 8), 16) / 255;
|
||||||
|
} else {
|
||||||
|
color = parseInt(name, 16);
|
||||||
|
alpha = 1;
|
||||||
}
|
}
|
||||||
color = parseInt(color, 16);
|
|
||||||
alpha = parseInt(alpha, 16) / 255;
|
|
||||||
return { color, alpha };
|
return { color, alpha };
|
||||||
} else {
|
} else {
|
||||||
switch(name.toLowerCase()) {
|
switch(name.toLowerCase()) {
|
||||||
@ -184,6 +185,15 @@ class commonFunctions {
|
|||||||
return [r/255, g/255, b/255];
|
return [r/255, g/255, b/255];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static componentToHex(c) {
|
||||||
|
var hex = parseInt(c).toString(16);
|
||||||
|
return hex.length == 1 ? "0" + hex : hex;
|
||||||
|
}
|
||||||
|
|
||||||
|
static rgbToHex(rgb) {
|
||||||
|
return `#${this.componentToHex(rgb[0] * 255)}${this.componentToHex(rgb[1]* 255)}${this.componentToHex(rgb[2]* 255)}`;
|
||||||
|
}
|
||||||
|
|
||||||
static convertUtageTextTags(text) {
|
static convertUtageTextTags(text) {
|
||||||
text = text.replace(/<speed.*?>|<\/speed>/g, "");
|
text = text.replace(/<speed.*?>|<\/speed>/g, "");
|
||||||
text = text.replace(/\\n/g, "<br/>")
|
text = text.replace(/\\n/g, "<br/>")
|
||||||
@ -317,6 +327,15 @@ class commonFunctions {
|
|||||||
}
|
}
|
||||||
retval.speed = Number(retval.speed);
|
retval.speed = Number(retval.speed);
|
||||||
}
|
}
|
||||||
|
let indexC = props.indexOf("color=");
|
||||||
|
if(indexC !== -1) {
|
||||||
|
retval.color = "";
|
||||||
|
for(let i = indexC + 6; i < props.length; ++i) {
|
||||||
|
if(props[i] == " ") { break; }
|
||||||
|
retval.color += props[i];
|
||||||
|
}
|
||||||
|
retval.color = retval.color;
|
||||||
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -333,7 +333,11 @@ function dialogScrollDown(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onBodyKey(event) {
|
function onBodyKey(event) {
|
||||||
if(event.code.toLowerCase() === "space") {
|
if(event.code.toLowerCase() === "arrowdown") {
|
||||||
|
dialogScrollDown(event)
|
||||||
|
} else if(event.code.toLowerCase() === "arrowup") {
|
||||||
|
dialogScrollUp(event);
|
||||||
|
} else if(event.code.toLowerCase() === "space") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
player.onMainClick(event);
|
player.onMainClick(event);
|
||||||
|
30
Js/Pixi.min.js
vendored
30
Js/Pixi.min.js
vendored
File diff suppressed because one or more lines are too long
88
Js/Player.js
88
Js/Player.js
@ -18,7 +18,6 @@ class Player {
|
|||||||
|
|
||||||
this.currentCharacters = {};
|
this.currentCharacters = {};
|
||||||
this.layers = {};
|
this.layers = {};
|
||||||
this.sprites = {};
|
|
||||||
this.currentCommand = undefined;
|
this.currentCommand = undefined;
|
||||||
this.runEvent = false;
|
this.runEvent = false;
|
||||||
this.secondTicker = 1000;
|
this.secondTicker = 1000;
|
||||||
@ -433,17 +432,11 @@ class Player {
|
|||||||
if(pos >= 1) {
|
if(pos >= 1) {
|
||||||
pos = 1;
|
pos = 1;
|
||||||
toRemove.push(i);
|
toRemove.push(i);
|
||||||
if(l.post) {
|
let postRes = postLerpAction(l)
|
||||||
let split = l.post.split('|');
|
if(postRes === "continue") {
|
||||||
switch(split[0].toLowerCase()) {
|
continue;
|
||||||
case "destroy":
|
} else if(postRes === "break") {
|
||||||
l.object.destroy();
|
false;
|
||||||
continue;
|
|
||||||
case "clearshader":
|
|
||||||
l.object.filters = null;
|
|
||||||
l.object.alpha = Number(split[1]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch(l.type) {
|
switch(l.type) {
|
||||||
@ -476,6 +469,18 @@ class Player {
|
|||||||
l.object.filters[0].uniforms.time = pos;
|
l.object.filters[0].uniforms.time = pos;
|
||||||
l.object.filters[0].apply();
|
l.object.filters[0].apply();
|
||||||
} catch(error) {}
|
} catch(error) {}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "tint": {
|
||||||
|
let lRgb = commonFunctions.hexToRgb(l.initV);
|
||||||
|
let fRgb = commonFunctions.hexToRgb(l.finalV);
|
||||||
|
let newR = commonFunctions.lerp(lRgb[0], fRgb[0], pos, inter);
|
||||||
|
let newG = commonFunctions.lerp(lRgb[1], fRgb[1], pos, inter);
|
||||||
|
let newB = commonFunctions.lerp(lRgb[2], fRgb[2], pos, inter);
|
||||||
|
let hexValue = commonFunctions.rgbToHex([newR, newG, newB]);
|
||||||
|
let newValue = commonFunctions.getColorFromName(hexValue).color;
|
||||||
|
l.object.tint = newValue;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
let newValue = commonFunctions.lerp(l.initV, l.finalV, pos, inter);
|
let newValue = commonFunctions.lerp(l.initV, l.finalV, pos, inter);
|
||||||
@ -497,6 +502,7 @@ class Player {
|
|||||||
} catch(error) {
|
} catch(error) {
|
||||||
//If we got an exception during this it probably means the object doesnt exist anymore so just remove it.
|
//If we got an exception during this it probably means the object doesnt exist anymore so just remove it.
|
||||||
toRemove.push(i);
|
toRemove.push(i);
|
||||||
|
postLerpAction(this.lerpTargets[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(let i = toRemove.length - 1; i > -1; --i) {
|
for(let i = toRemove.length - 1; i > -1; --i) {
|
||||||
@ -505,6 +511,24 @@ class Player {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function postLerpAction(postLerp) {
|
||||||
|
try {
|
||||||
|
if(!postLerp || !postLerp.object || !postLerp.post) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
let split = postLerp.post.split('|');
|
||||||
|
switch(split[0].toLowerCase()) {
|
||||||
|
case "destroy":
|
||||||
|
postLerp.object.destroy({children: true});
|
||||||
|
return 'continue';
|
||||||
|
case "clearshader":
|
||||||
|
postLerp.object.filters = null;
|
||||||
|
postLerp.object.alpha = Number(split[1]);
|
||||||
|
return 'break';
|
||||||
|
}
|
||||||
|
} catch(error) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Processes a line from the mission tsv
|
//Processes a line from the mission tsv
|
||||||
@ -621,7 +645,7 @@ class Player {
|
|||||||
} else {
|
} else {
|
||||||
//clear the sprite for the bg currently in use.
|
//clear the sprite for the bg currently in use.
|
||||||
for(let i = 0; i < container.children.length; ++i) {
|
for(let i = 0; i < container.children.length; ++i) {
|
||||||
container.children[i].destroy();
|
container.children[i].destroy({children: true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
container.visible = true;
|
container.visible = true;
|
||||||
@ -895,6 +919,7 @@ class Player {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "darkaura01": //312000111
|
case "darkaura01": //312000111
|
||||||
|
this.audio.stopSound('Se_不幸のオーラ(ヴォォオンン)');
|
||||||
this.audio.playSound('Se_不幸のオーラ(ヴォォオンン)', 'Se');
|
this.audio.playSound('Se_不幸のオーラ(ヴォォオンン)', 'Se');
|
||||||
this.waitTime = 2500;
|
this.waitTime = 2500;
|
||||||
break;
|
break;
|
||||||
@ -902,7 +927,9 @@ class Player {
|
|||||||
this.audio.playSound('Se_サムシング・ニューの叫び声(アアア”ア”ア”)', 'Se');
|
this.audio.playSound('Se_サムシング・ニューの叫び声(アアア”ア”ア”)', 'Se');
|
||||||
let c = this.currentCharacters['キャラ中央'];
|
let c = this.currentCharacters['キャラ中央'];
|
||||||
this.waitTime = 4000;
|
this.waitTime = 4000;
|
||||||
this.lerpTargets.push({type: 'alpha', object: c.sprite, curTime: 0, time: 3000, finalV: 0, initV: 1, post: "destroy" });
|
if(c) {
|
||||||
|
this.lerpTargets.push({type: 'alpha', object: c.sprite, curTime: 0, time: 3000, finalV: 0, initV: 1, post: "destroy" });
|
||||||
|
}
|
||||||
let customCommand = { Command: "", Arg1: cur.Arg1, Arg2: this.defaultCharPattern, Arg3: 'キャラ中央', Arg6: 3 };
|
let customCommand = { Command: "", Arg1: cur.Arg1, Arg2: this.defaultCharPattern, Arg3: 'キャラ中央', Arg6: 3 };
|
||||||
this.checkPutCharacterScreen(customCommand, false, true);
|
this.checkPutCharacterScreen(customCommand, false, true);
|
||||||
break;
|
break;
|
||||||
@ -1245,13 +1272,24 @@ class Player {
|
|||||||
case "colorto": {
|
case "colorto": {
|
||||||
let props = commonFunctions.getPropertiesFromTweenCommand(cur.Arg3);
|
let props = commonFunctions.getPropertiesFromTweenCommand(cur.Arg3);
|
||||||
if(props.alpha != undefined) {
|
if(props.alpha != undefined) {
|
||||||
|
this.cancelLerpOfType('alpha', curChar.sprite);
|
||||||
if(props.time) {
|
if(props.time) {
|
||||||
this.lerpTargets.push({type: 'alpha', object: curChar.sprite, curTime: 0 - (props.delay || 0), time: props.time,
|
this.lerpTargets.push({type: 'alpha', object: curChar.sprite, curTime: 0 - (props.delay || 0), time: props.time,
|
||||||
finalV: props.alpha, initV: curChar.sprite.alpha });
|
finalV: props.alpha, initV: curChar.sprite.alpha });
|
||||||
} else {
|
} else {
|
||||||
curChar.sprite.alpha = props.alpha;
|
curChar.sprite.alpha = props.alpha;
|
||||||
}
|
}
|
||||||
this.cancelLerpOfType('alpha', curChar.sprite);
|
|
||||||
|
}
|
||||||
|
if(props.color != undefined) {
|
||||||
|
this.cancelLerpOfType('tint', curChar.sprite);
|
||||||
|
let color = commonFunctions.getColorFromName(props.color);
|
||||||
|
if(props.time) {
|
||||||
|
this.lerpTargets.push({type: 'tint', object: curChar.sprite, curTime: 0 - (props.delay || 0), time: props.time,
|
||||||
|
finalV: color.color, initV: curChar.sprite.tint });
|
||||||
|
} else {
|
||||||
|
curChar.sprite.tint = color.color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1414,17 +1452,9 @@ class Player {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
this.pixi.app.ticker.remove(this.onPixiTick, this);
|
this.pixi.app.ticker.remove(this.onPixiTick, this);
|
||||||
this.pixi.app.stage.children.forEach(function(child) { child.destroy(true, true, true); });
|
|
||||||
for(let tex of Object.keys(PIXI.utils.TextureCache)) {
|
|
||||||
if(PIXI.utils.TextureCache[tex]) {
|
|
||||||
PIXI.utils.TextureCache[tex].destroy(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
utage.currentPlayingFile.length = 0;
|
utage.currentPlayingFile.length = 0;
|
||||||
this.loader.reset();
|
|
||||||
this.currentCharacters = {};
|
this.currentCharacters = {};
|
||||||
this.layers = {};
|
this.layers = {};
|
||||||
this.sprites = {};
|
|
||||||
this.currentCommand = undefined;
|
this.currentCommand = undefined;
|
||||||
this.runEvent = false;
|
this.runEvent = false;
|
||||||
this.secondTicker = 1000;
|
this.secondTicker = 1000;
|
||||||
@ -1438,6 +1468,18 @@ class Player {
|
|||||||
this.text.resetAll();
|
this.text.resetAll();
|
||||||
this.audio.resetAll();
|
this.audio.resetAll();
|
||||||
this.utage.resetTranslations();
|
this.utage.resetTranslations();
|
||||||
|
this.pixi.app.stage.children.forEach(function(child) { child.destroy({children: true, texture: true, baseTexture: true}); });
|
||||||
|
for(let tex of Object.keys(PIXI.utils.TextureCache)) {
|
||||||
|
if(PIXI.utils.TextureCache[tex]) {
|
||||||
|
PIXI.utils.TextureCache[tex].destroy(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(let tex of Object.keys(PIXI.utils.BaseTextureCache)) {
|
||||||
|
if(PIXI.utils.BaseTextureCache[tex]) {
|
||||||
|
PIXI.utils.BaseTextureCache[tex].destroy(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.loader.reset();
|
||||||
resolve();
|
resolve();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit d32d5bb518df5af9ad666bbfbc9de1e873521db8
|
Subproject commit 9785aafc39465a98f1c60b0656133cba3ef44ce6
|
Loading…
x
Reference in New Issue
Block a user