mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-16 17:05:03 +01:00
Add multi-region launcher support
Add custom launcher as well as support for both the original TW and JP launchers.
This commit is contained in:
98
www/erupe/js/charsel.js
Normal file
98
www/erupe/js/charsel.js
Normal file
@@ -0,0 +1,98 @@
|
||||
function createErrorAlert(message) {
|
||||
parent.postMessage(message, "*");
|
||||
}
|
||||
|
||||
function createCharListItem(name, uid, weapon, HR, GR, lastLogin, sex) {
|
||||
var topDiv = $('<div/>')
|
||||
.attr("href", "#")
|
||||
.attr("uid", uid)
|
||||
.addClass("char-list-entry list-group-item list-group-item-action flex-column align-items-start");
|
||||
|
||||
var topLine = $('<div/>')
|
||||
.addClass("d-flex w-100 justify-content-between")
|
||||
.append(
|
||||
$('<h5/>')
|
||||
.addClass("mb-1")
|
||||
.text(name)
|
||||
)
|
||||
.append(
|
||||
$('<small/>')
|
||||
.text('ID:' + uid)
|
||||
);
|
||||
|
||||
var bottomLine = $('<div/>')
|
||||
.addClass("d-flex w-100 justify-content-between")
|
||||
.append($('<small/>').text('Weapon: ' + weapon))
|
||||
.append($('<small/>').text('HR: ' + HR))
|
||||
.append($('<small/>').text('GR: ' + GR))
|
||||
.append($('<small/>').text('LastLogin: ' + lastLogin))
|
||||
.append($('<small/>').text('Sex: ' + sex));
|
||||
|
||||
topDiv.append(topLine);
|
||||
topDiv.append(bottomLine);
|
||||
|
||||
$("#characterlist").append(topDiv);
|
||||
}
|
||||
|
||||
$(function() {
|
||||
try {
|
||||
var charInfo = window.external.getCharacterInfo();
|
||||
} catch (e) {
|
||||
createErrorAlert("Error on getCharacterInfo!");
|
||||
}
|
||||
|
||||
try{
|
||||
// JQuery's parseXML isn't working properly on IE11, use the activeX XMLDOM instead.
|
||||
//$xmlDoc = $.parseXML(charInfo),
|
||||
$xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
|
||||
$xmlDoc.async = "false";
|
||||
$xmlDoc.loadXML(charInfo);
|
||||
|
||||
$xml = $($xmlDoc);
|
||||
} catch (e) {
|
||||
createErrorAlert("Error parsing character info xml!" + e);
|
||||
}
|
||||
|
||||
// Go over each "Character" element in the XML and then create a new list item for it.
|
||||
try {
|
||||
$($xml).find("Character").each(function(){
|
||||
createCharListItem(
|
||||
$(this).attr('name'),
|
||||
$(this).attr('uid'),
|
||||
$(this).attr('weapon'),
|
||||
$(this).attr('HR'),
|
||||
$(this).attr('GR'),
|
||||
$(this).attr('lastLogin'),
|
||||
$(this).attr('sex')
|
||||
);
|
||||
});
|
||||
} catch (e) {
|
||||
createErrorAlert("Error searching character info xml!");
|
||||
}
|
||||
|
||||
// Set the active character selection on click.
|
||||
$(".char-list-entry").click(function(){
|
||||
if(!$(this).hasClass("active")) {
|
||||
$(".char-list-entry.active").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
}
|
||||
});
|
||||
|
||||
$("#selectButton").on("click", function() {
|
||||
// Get the active character selection.
|
||||
var selectedUid = $(".char-list-entry.active").attr("uid");
|
||||
|
||||
// Call into the native launcher select function.
|
||||
try{
|
||||
window.external.selectCharacter(selectedUid, selectedUid)
|
||||
} catch(e) {
|
||||
createErrorAlert("Error on select character!");
|
||||
}
|
||||
|
||||
// If we didn't error before, just close the launcher to start the game.
|
||||
setTimeout(function(){
|
||||
window.external.exitLauncher();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
});
|
||||
38
www/erupe/js/login.js
Normal file
38
www/erupe/js/login.js
Normal file
@@ -0,0 +1,38 @@
|
||||
function createErrorAlert(message) {
|
||||
parent.postMessage(message, "*");
|
||||
}
|
||||
|
||||
|
||||
// Function to continually check if we got a login result yet,
|
||||
// then navigating to the character selection if we did.
|
||||
function checkAuthResult() {
|
||||
var loginResult = window.external.getLastAuthResult();
|
||||
console.log('|' + loginResult + '|');
|
||||
if(loginResult == "AUTH_PROGRESS") {
|
||||
setTimeout(checkAuthResult, 1500);
|
||||
} else if (loginResult == "AUTH_SUCCESS") {
|
||||
window.location.href = 'charsel.html'
|
||||
} else {
|
||||
createErrorAlert("Error logging in!");
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
// Login form submission.
|
||||
$("#loginform").submit(function(e){
|
||||
e.preventDefault();
|
||||
|
||||
username = $("#username").val();
|
||||
password = $("#password").val();
|
||||
|
||||
try{
|
||||
window.external.loginCog(username, password, password);
|
||||
} catch(e){
|
||||
createErrorAlert("Error on loginCog: " + e);
|
||||
}
|
||||
|
||||
checkAuthResult();
|
||||
});
|
||||
|
||||
});
|
||||
93
www/erupe/js/main.js
Normal file
93
www/erupe/js/main.js
Normal file
@@ -0,0 +1,93 @@
|
||||
// Helper function to dynamically create a bootstrap alert box.
|
||||
function createErrorAlert(message) {
|
||||
var tmpDiv = $('<div/>')
|
||||
.attr("id", "myAlertBoxID")
|
||||
.attr("role", "alert")
|
||||
.addClass("alert alert-danger alert-dismissible fade show")
|
||||
|
||||
tmpDiv.append(message);
|
||||
tmpDiv.append($("<button/>")
|
||||
.attr("type", "button")
|
||||
.addClass("close")
|
||||
.attr("data-dismiss", "alert")
|
||||
.attr("aria-label", "Close")
|
||||
.append($("<span/>")
|
||||
.attr("aria-hidden", "true")
|
||||
.text("×")
|
||||
));
|
||||
|
||||
$("#alertBox").append(tmpDiv);
|
||||
}
|
||||
|
||||
function doLauncherInitalize() {
|
||||
try{
|
||||
window.external.getMhfMutexNumber();
|
||||
} catch(e){
|
||||
createErrorAlert("Error getting Mhf mutex number! " + e);
|
||||
}
|
||||
|
||||
try{
|
||||
var serverListXml = window.external.getServerListXml();
|
||||
} catch(e){
|
||||
createErrorAlert("Error getting serverlist.xml! " + e);
|
||||
}
|
||||
|
||||
if(serverListXml == ""){
|
||||
createErrorAlert("Got empty serverlist.xml!");
|
||||
}
|
||||
console.log(serverListXml);
|
||||
|
||||
try{
|
||||
var lastServerIndex = window.external.getIniLastServerIndex();
|
||||
} catch(e){
|
||||
createErrorAlert("Error on getIniLastServerIndex: " + e);
|
||||
}
|
||||
console.log("Last server index:" + lastServerIndex);
|
||||
|
||||
try{
|
||||
window.external.setIniLastServerIndex(0);
|
||||
} catch(e){
|
||||
createErrorAlert("Error on setIniLastServerIndex: " + e);
|
||||
}
|
||||
|
||||
try{
|
||||
var mhfBootMode = window.external.getMhfBootMode();
|
||||
} catch(e){
|
||||
createErrorAlert("Error on getMhfBootMode: " + e);
|
||||
}
|
||||
console.log("mhfBootMode:" + mhfBootMode);
|
||||
|
||||
try{
|
||||
var userId = window.external.getUserId();
|
||||
} catch(e){
|
||||
createErrorAlert("Error on getUserId: " + e);
|
||||
}
|
||||
console.log("userId:" + userId);
|
||||
|
||||
try{
|
||||
var password = window.external.getPassword();
|
||||
} catch(e){
|
||||
createErrorAlert("Error on getPassword: " + e);
|
||||
}
|
||||
console.log("password:" + password);
|
||||
}
|
||||
|
||||
$(function() {
|
||||
// Setup the titlebar and exit button so that the window works how you would expect.
|
||||
$("#titlebar").on("click", function(e) {
|
||||
window.external.beginDrag(true);
|
||||
});
|
||||
|
||||
$("#exit").on("click", function(e) {
|
||||
window.external.closeWindow();
|
||||
});
|
||||
|
||||
// Setup the error message passthrough
|
||||
$(window).on("message onmessage", function(e) {
|
||||
var data = e.originalEvent.data;
|
||||
createErrorAlert(data)
|
||||
});
|
||||
|
||||
// Initialize the launcher by calling the native/external functions it exposes in the proper order.
|
||||
doLauncherInitalize();
|
||||
});
|
||||
Reference in New Issue
Block a user