미디어위키:Gadget-UE4.js: 두 판 사이의 차이
잔글편집 요약 없음 |
잔글편집 요약 없음 |
||
44번째 줄: | 44번째 줄: | ||
asyncJSLoader("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js", "text/javascript") | asyncJSLoader("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js", "text/javascript") | ||
.then(function (data) { | .then(function (data) { | ||
asyncJSLoader("https:/ | asyncJSLoader("https://"+liberty_gamepath + liberty_gamename, "text/javascript") | ||
.then(function (data) { | .then(function (data) { | ||
console.log("UE4 Game Loaded!"); | console.log("UE4 Game Loaded!"); |
2024년 1월 20일 (토) 13:35 판
/**
* Unreal Engine 4 loader
* 2024년 12월 31일 이전까지 완전 작동을 목표로 개발 예정
* 제작자: [[사용자:senouis]]
**/
function asyncJSLoader(url, type) {
return new Promise(function (resolve, reject) {
try {
var scriptElement = document.createElement("script");
scriptElement.src = url;
scriptElement.async = true; // force asynchronous loading
scriptElement.type = type;
var contextsection = document.getElementById("mw-content-text");
scriptElement.addEventListener("load", function (ev) {
resolve({ status: true });
});
scriptElement.addEventListener("error", function (ev) {
reject({
status: false,
message: "Failed to load the script"
});
});
contextsection.appendChild(scriptElement);
} catch (e) {
reject(e);
}
});
}
var liberty_gamepath = document.getElementById("libertygame-gamepath").innerText;
var liberty_gamename = document.getElementById("libertygame-gamename").innerText;
function UE4_loadElement() {
try {
var canvasparent = document.getElementById("mainarea"); // first element of mediawiki contents
// Add game canvas to div
var canvasElem = document.createElement("canvas");
canvasElem.tabindex = 0;
canvasElem.className = "emscripten";
canvasElem.id = "canvas";
canvasElem.addEventListener("contextmenu", function (event) {event.preventDefault();});
canvasElem.style.display = "none";
canvasparent.appendChild(canvasElem);
// now load js files from external server
asyncJSLoader("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js", "text/javascript")
.then(function (data) {
asyncJSLoader("https://"+liberty_gamepath + liberty_gamename, "text/javascript")
.then(function (data) {
console.log("UE4 Game Loaded!");
});
});
} catch (e){
console.log("initiating Unreal Engine 4 for libertygame failed, stop loading elements...");
}
}
$(UE4_loadElement);