This commit is contained in:
@@ -19820,6 +19820,9 @@ cr.plugins_.SenaPlugin = function (runtime) {
|
||||
instanceProto.onCreate = function () {
|
||||
console.log("🔥 LOAD CALLBACK FIRED");
|
||||
window["SenaTrigger"] = this;
|
||||
this.widthArray = [];
|
||||
this.slotInstances = [];
|
||||
this.slotPositions = [];
|
||||
this.sdk = null;
|
||||
this.isPaused = false;
|
||||
this.pauseTime = 0;
|
||||
@@ -19874,6 +19877,15 @@ cr.plugins_.SenaPlugin = function (runtime) {
|
||||
};
|
||||
Cnds.prototype.OnMessage = function () {
|
||||
return true;
|
||||
};
|
||||
Cnds.prototype.OnWordLayoutFinished = function () {
|
||||
return true;
|
||||
};
|
||||
Cnds.prototype.OnSlotLayoutFinished = function () {
|
||||
return true;
|
||||
};
|
||||
Cnds.prototype.OnSlotLayoutFinished2 = function () {
|
||||
return true;
|
||||
};
|
||||
pluginProto.cnds = new Cnds();
|
||||
function Acts() {}
|
||||
@@ -19915,6 +19927,12 @@ Acts.prototype.Load = function () {
|
||||
console.error("SenaSDK not found");
|
||||
this.isLoading = false;
|
||||
}
|
||||
};
|
||||
Acts.prototype.SetObjectWidth = function (index, width) {
|
||||
if (!this.widthArray) {
|
||||
this.widthArray = [];
|
||||
}
|
||||
this.widthArray[index] = width;
|
||||
};
|
||||
Acts.prototype.Start = function () {
|
||||
var self = this;
|
||||
@@ -20029,8 +20047,19 @@ Acts.prototype.Load = function () {
|
||||
type,
|
||||
groupGap
|
||||
) {
|
||||
var widthArray = this.widthArray || [];
|
||||
if (!widthArray.length) {
|
||||
console.warn("widthArray empty, fallback to objectWidth");
|
||||
widthArray = new Array(count).fill(objectWidth);
|
||||
}
|
||||
this.calculatedPositions = [];
|
||||
if (count <= 0) return;
|
||||
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) {
|
||||
@@ -20048,22 +20077,46 @@ Acts.prototype.Load = function () {
|
||||
}
|
||||
var baseY = 0;
|
||||
if (type === "word") {
|
||||
baseY = groupGap || (rowGap * rows.length); // word always below slot
|
||||
baseY = groupGap || (rowGap * rows.length);
|
||||
}
|
||||
var index = 0;
|
||||
for (var r = 0; r < rows.length; r++) {
|
||||
var itemsInRow = rows[r];
|
||||
var rowWidth = itemsInRow * objectWidth + (itemsInRow - 1) * margin;
|
||||
var startX = (maxWidth - rowWidth) / 2;
|
||||
var rowWidth = 0;
|
||||
for (var i = 0; i < itemsInRow; i++) {
|
||||
rowWidth += widthArray[index + i] || objectWidth;
|
||||
}
|
||||
rowWidth += (itemsInRow - 1) * margin;
|
||||
var startX = (maxWidth - rowWidth) / 2;
|
||||
var currentX = startX;
|
||||
for (var i = 0; i < itemsInRow; i++) {
|
||||
var w = widthArray[index] || objectWidth;
|
||||
this.calculatedPositions.push({
|
||||
x: startX + i * (objectWidth + margin) + objectWidth / 2,
|
||||
x: currentX + w / 2,
|
||||
y: baseY + r * rowGap
|
||||
});
|
||||
currentX += w + margin;
|
||||
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) {
|
||||
if (this.sdk && this.sdk.loadLevelG5) {
|
||||
@@ -20113,6 +20166,22 @@ Acts.prototype.Load = function () {
|
||||
};
|
||||
pluginProto.acts = new Acts();
|
||||
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) {
|
||||
if (this.sdk) {
|
||||
ret.set_string(this.sdk.getQuestionValue() || "");
|
||||
@@ -25162,10 +25231,10 @@ cr.getObjectRefTable = function () { return [
|
||||
cr.plugins_.Browser,
|
||||
cr.plugins_.JSON,
|
||||
cr.plugins_.Function,
|
||||
cr.plugins_.SpriteFontPlus,
|
||||
cr.plugins_.SenaPlugin,
|
||||
cr.plugins_.Sprite,
|
||||
cr.plugins_.Touch,
|
||||
cr.plugins_.SpriteFontPlus,
|
||||
cr.behaviors.Fade,
|
||||
cr.behaviors.DragnDrop,
|
||||
cr.behaviors.Rex_MoveTo,
|
||||
@@ -25194,30 +25263,37 @@ cr.getObjectRefTable = function () { return [
|
||||
cr.plugins_.Sprite.prototype.exps.X,
|
||||
cr.plugins_.Sprite.prototype.exps.Y,
|
||||
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.exps["int"],
|
||||
cr.system_object.prototype.exps.loopindex,
|
||||
cr.plugins_.SenaPlugin.prototype.exps.getHintType,
|
||||
cr.plugins_.SenaPlugin.prototype.exps.getHintValue,
|
||||
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.plugins_.Sprite.prototype.acts.SetBoolInstanceVar,
|
||||
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.acts.AddVar,
|
||||
cr.plugins_.Sprite.prototype.acts.SetY,
|
||||
cr.plugins_.SenaPlugin.prototype.exps.getOptionsType,
|
||||
cr.plugins_.SenaPlugin.prototype.acts.CalcObjectPositions,
|
||||
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_.Sprite.prototype.cnds.IsVisible,
|
||||
cr.system_object.prototype.cnds.CompareVar,
|
||||
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.behaviors.DragnDrop.prototype.acts.SetEnabled,
|
||||
cr.plugins_.Function.prototype.acts.CallFunction,
|
||||
@@ -25229,7 +25305,6 @@ cr.getObjectRefTable = function () { return [
|
||||
cr.plugins_.SenaPlugin.prototype.cnds.OnResume,
|
||||
cr.plugins_.Function.prototype.cnds.OnFunction,
|
||||
cr.system_object.prototype.cnds.For,
|
||||
cr.system_object.prototype.cnds.PickByComparison,
|
||||
cr.system_object.prototype.exps.left,
|
||||
cr.system_object.prototype.exps.len,
|
||||
cr.plugins_.SenaPlugin.prototype.acts.Finish,
|
||||
@@ -25249,8 +25324,10 @@ cr.getObjectRefTable = function () { return [
|
||||
cr.behaviors.DragnDrop.prototype.cnds.OnDrop,
|
||||
cr.plugins_.Sprite.prototype.cnds.IsBoolInstanceVarSet,
|
||||
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.plugins_.SenaPlugin.prototype.acts.PostMessage,
|
||||
cr.behaviors.Rex_MoveTo.prototype.acts.SetMaxSpeed,
|
||||
cr.behaviors.DragnDrop.prototype.cnds.IsDragging,
|
||||
cr.system_object.prototype.cnds.EveryTick,
|
||||
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": [
|
||||
"data.js",
|
||||
"c2runtime.js",
|
||||
@@ -21,7 +21,6 @@
|
||||
"images/panel_pause-sheet0.png",
|
||||
"images/layer-sheet0.png",
|
||||
"images/newwordpng-sheet0.png",
|
||||
"images/khungnen-sheet0.png",
|
||||
"media/click.ogg",
|
||||
"media/correct.ogg",
|
||||
"media/error-010-206498.ogg",
|
||||
|
||||
@@ -814,7 +814,7 @@ SenaSDK.prototype.start = function () {
|
||||
if (self.shuffle && self.data?.options) {
|
||||
self.shuffleArray(self.data.options);
|
||||
}
|
||||
self.startTime = Date.now();
|
||||
// self.startTime = Date.now();
|
||||
};
|
||||
|
||||
SenaSDK.prototype.markUserInteraction = function () {
|
||||
@@ -870,8 +870,8 @@ SenaSDK.prototype.end = function (answer, callback) {
|
||||
|
||||
// ========== STANDARD GAMES (Quiz/Sort/Fill) ==========
|
||||
|
||||
self.endTime = Date.now();
|
||||
const duration = (self.endTime - self.startTime) / 1000;
|
||||
// self.endTime = Date.now();
|
||||
// const duration = (self.endTime - self.startTime) / 1000;
|
||||
|
||||
const answerStr = String(answer || '');
|
||||
const userAnswers = answerStr.includes('|')
|
||||
@@ -918,21 +918,19 @@ SenaSDK.prototype.end = function (answer, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
// Check time limit
|
||||
if (self.timeLimit > 0 && duration > self.timeLimit) {
|
||||
isCorrect = false;
|
||||
console.log('🎮 Sena SDK: Time limit exceeded');
|
||||
}
|
||||
// // Check time limit
|
||||
// if (self.timeLimit > 0 && duration > self.timeLimit) {
|
||||
// isCorrect = false;
|
||||
// console.log('🎮 Sena SDK: Time limit exceeded');
|
||||
// }
|
||||
|
||||
const result = {
|
||||
isCorrect: isCorrect,
|
||||
duration: duration,
|
||||
correctAnswer: correctAnswers.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);
|
||||
return result;
|
||||
};
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user