This commit is contained in:
@@ -19820,6 +19820,9 @@ cr.plugins_.SenaPlugin = function (runtime) {
|
|||||||
instanceProto.onCreate = function () {
|
instanceProto.onCreate = function () {
|
||||||
console.log("🔥 LOAD CALLBACK FIRED");
|
console.log("🔥 LOAD CALLBACK FIRED");
|
||||||
window["SenaTrigger"] = this;
|
window["SenaTrigger"] = this;
|
||||||
|
this.widthArray = [];
|
||||||
|
this.slotInstances = [];
|
||||||
|
this.slotPositions = [];
|
||||||
this.sdk = null;
|
this.sdk = null;
|
||||||
this.isPaused = false;
|
this.isPaused = false;
|
||||||
this.pauseTime = 0;
|
this.pauseTime = 0;
|
||||||
@@ -19875,6 +19878,15 @@ cr.plugins_.SenaPlugin = function (runtime) {
|
|||||||
Cnds.prototype.OnMessage = function () {
|
Cnds.prototype.OnMessage = function () {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
Cnds.prototype.OnWordLayoutFinished = function () {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
Cnds.prototype.OnSlotLayoutFinished = function () {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
Cnds.prototype.OnSlotLayoutFinished2 = function () {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
pluginProto.cnds = new Cnds();
|
pluginProto.cnds = new Cnds();
|
||||||
function Acts() {}
|
function Acts() {}
|
||||||
Acts.prototype.Load = function () {
|
Acts.prototype.Load = function () {
|
||||||
@@ -19915,6 +19927,12 @@ Acts.prototype.Load = function () {
|
|||||||
console.error("SenaSDK not found");
|
console.error("SenaSDK not found");
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
Acts.prototype.SetObjectWidth = function (index, width) {
|
||||||
|
if (!this.widthArray) {
|
||||||
|
this.widthArray = [];
|
||||||
|
}
|
||||||
|
this.widthArray[index] = width;
|
||||||
};
|
};
|
||||||
Acts.prototype.Start = function () {
|
Acts.prototype.Start = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
@@ -20019,52 +20037,87 @@ Acts.prototype.Load = function () {
|
|||||||
this.totalPausedTime = 0;
|
this.totalPausedTime = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Acts.prototype.CalcObjectPositions = function (
|
Acts.prototype.CalcObjectPositions = function (
|
||||||
count,
|
count,
|
||||||
objectWidth,
|
objectWidth,
|
||||||
margin,
|
margin,
|
||||||
maxWidth,
|
maxWidth,
|
||||||
rowBreak,
|
rowBreak,
|
||||||
rowGap,
|
rowGap,
|
||||||
type,
|
type,
|
||||||
groupGap
|
groupGap
|
||||||
) {
|
) {
|
||||||
this.calculatedPositions = [];
|
var widthArray = this.widthArray || [];
|
||||||
if (count <= 0) return;
|
if (!widthArray.length) {
|
||||||
var rows = [];
|
console.warn("widthArray empty, fallback to objectWidth");
|
||||||
if (rowBreak > 0) {
|
widthArray = new Array(count).fill(objectWidth);
|
||||||
for (var i = 0; i < count; i += rowBreak) {
|
}
|
||||||
rows.push(Math.min(rowBreak, count - i));
|
this.calculatedPositions = [];
|
||||||
}
|
if (count <= 0) {
|
||||||
|
this.runtime.trigger(
|
||||||
|
cr.plugins_.SenaPlugin.prototype.cnds.OnCalculateFinished,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var rows = [];
|
||||||
|
if (rowBreak > 0) {
|
||||||
|
for (var i = 0; i < count; i += rowBreak) {
|
||||||
|
rows.push(Math.min(rowBreak, count - i));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (count <= 5) {
|
||||||
|
rows.push(count);
|
||||||
} else {
|
} else {
|
||||||
if (count <= 5) {
|
var top = Math.ceil((count + 1) / 2);
|
||||||
rows.push(count);
|
var bottom = count - top;
|
||||||
} else {
|
rows.push(top);
|
||||||
var top = Math.ceil((count + 1) / 2);
|
rows.push(bottom);
|
||||||
var bottom = count - top;
|
|
||||||
rows.push(top);
|
|
||||||
rows.push(bottom);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var baseY = 0;
|
}
|
||||||
if (type === "word") {
|
var baseY = 0;
|
||||||
baseY = groupGap || (rowGap * rows.length); // word always below slot
|
if (type === "word") {
|
||||||
|
baseY = groupGap || (rowGap * rows.length);
|
||||||
|
}
|
||||||
|
var index = 0;
|
||||||
|
for (var r = 0; r < rows.length; r++) {
|
||||||
|
var itemsInRow = rows[r];
|
||||||
|
var rowWidth = 0;
|
||||||
|
for (var i = 0; i < itemsInRow; i++) {
|
||||||
|
rowWidth += widthArray[index + i] || objectWidth;
|
||||||
}
|
}
|
||||||
var index = 0;
|
rowWidth += (itemsInRow - 1) * margin;
|
||||||
for (var r = 0; r < rows.length; r++) {
|
var startX = (maxWidth - rowWidth) / 2;
|
||||||
var itemsInRow = rows[r];
|
var currentX = startX;
|
||||||
var rowWidth = itemsInRow * objectWidth + (itemsInRow - 1) * margin;
|
for (var i = 0; i < itemsInRow; i++) {
|
||||||
var startX = (maxWidth - rowWidth) / 2;
|
var w = widthArray[index] || objectWidth;
|
||||||
for (var i = 0; i < itemsInRow; i++) {
|
this.calculatedPositions.push({
|
||||||
this.calculatedPositions.push({
|
x: currentX + w / 2,
|
||||||
x: startX + i * (objectWidth + margin) + objectWidth / 2,
|
y: baseY + r * rowGap
|
||||||
y: baseY + r * rowGap
|
});
|
||||||
});
|
currentX += w + margin;
|
||||||
index++;
|
index++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
console.log("Calculated positions (multi-row):", this.calculatedPositions);
|
}
|
||||||
};
|
console.log("Calculated positions:", this.calculatedPositions);
|
||||||
|
if (type === "word") {
|
||||||
|
this.runtime.trigger(
|
||||||
|
cr.plugins_.SenaPlugin.prototype.cnds.OnWordLayoutFinished,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
} else if (type === "slot") {
|
||||||
|
this.runtime.trigger(
|
||||||
|
cr.plugins_.SenaPlugin.prototype.cnds.OnSlotLayoutFinished,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (type === "slot2") {
|
||||||
|
this.runtime.trigger(
|
||||||
|
cr.plugins_.SenaPlugin.prototype.cnds.OnSlotLayoutFinished2,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
Acts.prototype.LoadLevelG5 = function (levelIndex) {
|
Acts.prototype.LoadLevelG5 = function (levelIndex) {
|
||||||
if (this.sdk && this.sdk.loadLevelG5) {
|
if (this.sdk && this.sdk.loadLevelG5) {
|
||||||
this.sdk.loadLevelG5(levelIndex);
|
this.sdk.loadLevelG5(levelIndex);
|
||||||
@@ -20113,6 +20166,22 @@ Acts.prototype.Load = function () {
|
|||||||
};
|
};
|
||||||
pluginProto.acts = new Acts();
|
pluginProto.acts = new Acts();
|
||||||
function Exps() {}
|
function Exps() {}
|
||||||
|
Exps.prototype.getObjectWidthByIndex = function (ret, index) {
|
||||||
|
if (!this.runtime) {
|
||||||
|
ret.set_float(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var instances = this.runtime.getCurrentEventStack().current_event.solModifiers;
|
||||||
|
if (!instances) {
|
||||||
|
ret.set_float(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.widthArray && this.widthArray[index] !== undefined) {
|
||||||
|
ret.set_float(this.widthArray[index]);
|
||||||
|
} else {
|
||||||
|
ret.set_float(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
Exps.prototype.getQuestionValue = function (ret) {
|
Exps.prototype.getQuestionValue = function (ret) {
|
||||||
if (this.sdk) {
|
if (this.sdk) {
|
||||||
ret.set_string(this.sdk.getQuestionValue() || "");
|
ret.set_string(this.sdk.getQuestionValue() || "");
|
||||||
@@ -25162,10 +25231,10 @@ cr.getObjectRefTable = function () { return [
|
|||||||
cr.plugins_.Browser,
|
cr.plugins_.Browser,
|
||||||
cr.plugins_.JSON,
|
cr.plugins_.JSON,
|
||||||
cr.plugins_.Function,
|
cr.plugins_.Function,
|
||||||
|
cr.plugins_.SpriteFontPlus,
|
||||||
cr.plugins_.SenaPlugin,
|
cr.plugins_.SenaPlugin,
|
||||||
cr.plugins_.Sprite,
|
cr.plugins_.Sprite,
|
||||||
cr.plugins_.Touch,
|
cr.plugins_.Touch,
|
||||||
cr.plugins_.SpriteFontPlus,
|
|
||||||
cr.behaviors.Fade,
|
cr.behaviors.Fade,
|
||||||
cr.behaviors.DragnDrop,
|
cr.behaviors.DragnDrop,
|
||||||
cr.behaviors.Rex_MoveTo,
|
cr.behaviors.Rex_MoveTo,
|
||||||
@@ -25194,30 +25263,37 @@ cr.getObjectRefTable = function () { return [
|
|||||||
cr.plugins_.Sprite.prototype.exps.X,
|
cr.plugins_.Sprite.prototype.exps.X,
|
||||||
cr.plugins_.Sprite.prototype.exps.Y,
|
cr.plugins_.Sprite.prototype.exps.Y,
|
||||||
cr.plugins_.Sprite.prototype.acts.SetPos,
|
cr.plugins_.Sprite.prototype.acts.SetPos,
|
||||||
cr.plugins_.SenaPlugin.prototype.acts.CalcObjectPositions,
|
|
||||||
cr.system_object.prototype.exps["int"],
|
|
||||||
cr.plugins_.Sprite.prototype.exps.Width,
|
|
||||||
cr.system_object.prototype.cnds.Repeat,
|
cr.system_object.prototype.cnds.Repeat,
|
||||||
|
cr.system_object.prototype.exps["int"],
|
||||||
cr.system_object.prototype.exps.loopindex,
|
cr.system_object.prototype.exps.loopindex,
|
||||||
cr.plugins_.SenaPlugin.prototype.exps.getHintType,
|
cr.plugins_.SenaPlugin.prototype.exps.getHintType,
|
||||||
cr.plugins_.SenaPlugin.prototype.exps.getHintValue,
|
cr.plugins_.SenaPlugin.prototype.exps.getHintValue,
|
||||||
cr.system_object.prototype.acts.CreateObject,
|
cr.system_object.prototype.acts.CreateObject,
|
||||||
cr.plugins_.SenaPlugin.prototype.exps.getPosXbyIndex,
|
|
||||||
cr.plugins_.SenaPlugin.prototype.exps.getPosYbyIndex,
|
|
||||||
cr.system_object.prototype.cnds.Compare,
|
cr.system_object.prototype.cnds.Compare,
|
||||||
cr.plugins_.Sprite.prototype.acts.SetBoolInstanceVar,
|
cr.plugins_.Sprite.prototype.acts.SetBoolInstanceVar,
|
||||||
cr.plugins_.Sprite.prototype.acts.SetAnimFrame,
|
cr.plugins_.Sprite.prototype.acts.SetAnimFrame,
|
||||||
|
cr.plugins_.Sprite.prototype.acts.SetWidth,
|
||||||
|
cr.plugins_.SpriteFontPlus.prototype.exps.TextWidth,
|
||||||
|
cr.plugins_.SenaPlugin.prototype.acts.SetObjectWidth,
|
||||||
|
cr.plugins_.Sprite.prototype.exps.Width,
|
||||||
|
cr.plugins_.SpriteFontPlus.prototype.acts.Destroy,
|
||||||
cr.system_object.prototype.cnds.Else,
|
cr.system_object.prototype.cnds.Else,
|
||||||
cr.system_object.prototype.acts.AddVar,
|
cr.plugins_.SenaPlugin.prototype.acts.CalcObjectPositions,
|
||||||
cr.plugins_.Sprite.prototype.acts.SetY,
|
|
||||||
cr.plugins_.SenaPlugin.prototype.exps.getOptionsType,
|
|
||||||
cr.plugins_.SenaPlugin.prototype.exps.getOptionsValue,
|
cr.plugins_.SenaPlugin.prototype.exps.getOptionsValue,
|
||||||
|
cr.plugins_.Sprite.prototype.acts.SetY,
|
||||||
|
cr.plugins_.SenaPlugin.prototype.exps.getPosYbyIndex,
|
||||||
|
cr.plugins_.SenaPlugin.prototype.cnds.OnWordLayoutFinished,
|
||||||
|
cr.plugins_.SenaPlugin.prototype.exps.getOptionsType,
|
||||||
|
cr.plugins_.SenaPlugin.prototype.exps.getPosXbyIndex,
|
||||||
|
cr.plugins_.SenaPlugin.prototype.cnds.OnSlotLayoutFinished,
|
||||||
|
cr.system_object.prototype.acts.AddVar,
|
||||||
|
cr.plugins_.SenaPlugin.prototype.cnds.OnSlotLayoutFinished2,
|
||||||
|
cr.system_object.prototype.cnds.ForEach,
|
||||||
|
cr.system_object.prototype.cnds.PickByComparison,
|
||||||
cr.plugins_.Touch.prototype.cnds.OnTouchObject,
|
cr.plugins_.Touch.prototype.cnds.OnTouchObject,
|
||||||
cr.plugins_.Sprite.prototype.cnds.IsVisible,
|
cr.plugins_.Sprite.prototype.cnds.IsVisible,
|
||||||
cr.system_object.prototype.cnds.CompareVar,
|
cr.system_object.prototype.cnds.CompareVar,
|
||||||
cr.plugins_.Audio.prototype.acts.Play,
|
cr.plugins_.Audio.prototype.acts.Play,
|
||||||
cr.plugins_.SenaPlugin.prototype.acts.SetData,
|
|
||||||
cr.plugins_.SenaPlugin.prototype.acts.PostMessage,
|
|
||||||
cr.plugins_.SenaPlugin.prototype.acts.PauseGame,
|
cr.plugins_.SenaPlugin.prototype.acts.PauseGame,
|
||||||
cr.behaviors.DragnDrop.prototype.acts.SetEnabled,
|
cr.behaviors.DragnDrop.prototype.acts.SetEnabled,
|
||||||
cr.plugins_.Function.prototype.acts.CallFunction,
|
cr.plugins_.Function.prototype.acts.CallFunction,
|
||||||
@@ -25229,7 +25305,6 @@ cr.getObjectRefTable = function () { return [
|
|||||||
cr.plugins_.SenaPlugin.prototype.cnds.OnResume,
|
cr.plugins_.SenaPlugin.prototype.cnds.OnResume,
|
||||||
cr.plugins_.Function.prototype.cnds.OnFunction,
|
cr.plugins_.Function.prototype.cnds.OnFunction,
|
||||||
cr.system_object.prototype.cnds.For,
|
cr.system_object.prototype.cnds.For,
|
||||||
cr.system_object.prototype.cnds.PickByComparison,
|
|
||||||
cr.system_object.prototype.exps.left,
|
cr.system_object.prototype.exps.left,
|
||||||
cr.system_object.prototype.exps.len,
|
cr.system_object.prototype.exps.len,
|
||||||
cr.plugins_.SenaPlugin.prototype.acts.Finish,
|
cr.plugins_.SenaPlugin.prototype.acts.Finish,
|
||||||
@@ -25249,8 +25324,10 @@ cr.getObjectRefTable = function () { return [
|
|||||||
cr.behaviors.DragnDrop.prototype.cnds.OnDrop,
|
cr.behaviors.DragnDrop.prototype.cnds.OnDrop,
|
||||||
cr.plugins_.Sprite.prototype.cnds.IsBoolInstanceVarSet,
|
cr.plugins_.Sprite.prototype.cnds.IsBoolInstanceVarSet,
|
||||||
cr.plugins_.Sprite.prototype.cnds.PickDistance,
|
cr.plugins_.Sprite.prototype.cnds.PickDistance,
|
||||||
cr.behaviors.Rex_MoveTo.prototype.acts.SetMaxSpeed,
|
cr.plugins_.SenaPlugin.prototype.acts.SetData,
|
||||||
cr.system_object.prototype.exps.str,
|
cr.system_object.prototype.exps.str,
|
||||||
|
cr.plugins_.SenaPlugin.prototype.acts.PostMessage,
|
||||||
|
cr.behaviors.Rex_MoveTo.prototype.acts.SetMaxSpeed,
|
||||||
cr.behaviors.DragnDrop.prototype.cnds.IsDragging,
|
cr.behaviors.DragnDrop.prototype.cnds.IsDragging,
|
||||||
cr.system_object.prototype.cnds.EveryTick,
|
cr.system_object.prototype.cnds.EveryTick,
|
||||||
cr.plugins_.Sprite.prototype.acts.SetVisible,
|
cr.plugins_.Sprite.prototype.acts.SetVisible,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB |
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": 1772008087,
|
"version": 1772175811,
|
||||||
"fileList": [
|
"fileList": [
|
||||||
"data.js",
|
"data.js",
|
||||||
"c2runtime.js",
|
"c2runtime.js",
|
||||||
@@ -21,7 +21,6 @@
|
|||||||
"images/panel_pause-sheet0.png",
|
"images/panel_pause-sheet0.png",
|
||||||
"images/layer-sheet0.png",
|
"images/layer-sheet0.png",
|
||||||
"images/newwordpng-sheet0.png",
|
"images/newwordpng-sheet0.png",
|
||||||
"images/khungnen-sheet0.png",
|
|
||||||
"media/click.ogg",
|
"media/click.ogg",
|
||||||
"media/correct.ogg",
|
"media/correct.ogg",
|
||||||
"media/error-010-206498.ogg",
|
"media/error-010-206498.ogg",
|
||||||
|
|||||||
@@ -814,7 +814,7 @@ SenaSDK.prototype.start = function () {
|
|||||||
if (self.shuffle && self.data?.options) {
|
if (self.shuffle && self.data?.options) {
|
||||||
self.shuffleArray(self.data.options);
|
self.shuffleArray(self.data.options);
|
||||||
}
|
}
|
||||||
self.startTime = Date.now();
|
// self.startTime = Date.now();
|
||||||
};
|
};
|
||||||
|
|
||||||
SenaSDK.prototype.markUserInteraction = function () {
|
SenaSDK.prototype.markUserInteraction = function () {
|
||||||
@@ -870,8 +870,8 @@ SenaSDK.prototype.end = function (answer, callback) {
|
|||||||
|
|
||||||
// ========== STANDARD GAMES (Quiz/Sort/Fill) ==========
|
// ========== STANDARD GAMES (Quiz/Sort/Fill) ==========
|
||||||
|
|
||||||
self.endTime = Date.now();
|
// self.endTime = Date.now();
|
||||||
const duration = (self.endTime - self.startTime) / 1000;
|
// const duration = (self.endTime - self.startTime) / 1000;
|
||||||
|
|
||||||
const answerStr = String(answer || '');
|
const answerStr = String(answer || '');
|
||||||
const userAnswers = answerStr.includes('|')
|
const userAnswers = answerStr.includes('|')
|
||||||
@@ -918,21 +918,19 @@ SenaSDK.prototype.end = function (answer, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check time limit
|
// // Check time limit
|
||||||
if (self.timeLimit > 0 && duration > self.timeLimit) {
|
// if (self.timeLimit > 0 && duration > self.timeLimit) {
|
||||||
isCorrect = false;
|
// isCorrect = false;
|
||||||
console.log('🎮 Sena SDK: Time limit exceeded');
|
// console.log('🎮 Sena SDK: Time limit exceeded');
|
||||||
}
|
// }
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
isCorrect: isCorrect,
|
isCorrect: isCorrect,
|
||||||
duration: duration,
|
correctAnswer: correctAnswers.join(' | '),
|
||||||
correctAnswer: correctAnswers.join(' | '),
|
userAnswer: userAnswers.join(' | ')
|
||||||
userAnswer: userAnswers.join(' | ')
|
};
|
||||||
};
|
|
||||||
|
|
||||||
console.log(`🎮 Sena SDK: Result: ${isCorrect ? 'CORRECT' : 'INCORRECT'} (${duration}s)`);
|
console.log(`🎮 Sena SDK: Result: ${isCorrect ? 'CORRECT' : 'INCORRECT'}`);
|
||||||
|
|
||||||
if (callback) callback(result.isCorrect);
|
if (callback) callback(result.isCorrect);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user