mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-13 02:10:04 +00:00
added config modal, bumped version
This commit is contained in:
parent
171177b606
commit
6a7b029539
@ -115,6 +115,11 @@ body {
|
||||
border-color: #6699ff;
|
||||
}
|
||||
|
||||
#of-editconfigmodal > .modal-dialog > .modal-content {
|
||||
background-color: #093363;
|
||||
border-color: #6699ff;
|
||||
}
|
||||
|
||||
#of-addversionmodal > .modal-dialog > .modal-content {
|
||||
background-color: #093363;
|
||||
border-color: #6699ff;
|
||||
|
@ -14,7 +14,8 @@ var cacheRoot = path.join(
|
||||
userData,
|
||||
"/../../LocalLow/Unity/Web Player/Cache"
|
||||
);
|
||||
var offlineRoot = path.join(cacheRoot, "Offline");
|
||||
var offlineRootDefault = path.join(cacheRoot, "Offline");
|
||||
var offlineRoot = offlineRootDefault;
|
||||
|
||||
var cdnString = "http://cdn.dexlabs.systems/ff/big";
|
||||
|
||||
@ -292,6 +293,38 @@ function restoreDefaultVersions() {
|
||||
handleCache("hash-check");
|
||||
}
|
||||
|
||||
function editConfig() {
|
||||
var jsonToModify = JSON.parse(remotefs.readJsonSync(configPath));
|
||||
|
||||
jsonToModify["autoupdate-check"] = $("#editconfig-autoupdate").prop("checked");
|
||||
jsonToModify["cache-swapping"] = $("#editconfig-cacheswapping").prop("checked");
|
||||
jsonToModify["enable-offline-cache"] = $("#editconfig-enableofflinecache").prop("checked");
|
||||
jsonToModify["verify-offline-cache"] = $("#editconfig-verifyofflinecache").prop("checked");
|
||||
|
||||
var dirInput = $("#editconfig-offlinecachelocation:text").val();
|
||||
|
||||
jsonToModify["offline-cache-location"] = (
|
||||
remotefs.existsSync(dirInput) &&
|
||||
remotefs.statSync(dirInput).isDirectory()
|
||||
) ? dirInput : offlineRoot;
|
||||
|
||||
remotefs.writeFileSync(configPath, JSON.stringify(jsonToModify, null, 4));
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
function validateCacheLocation() {
|
||||
var input = document.getElementById("editconfig-offlinecachelocation");
|
||||
var button = document.getElementById("editconfig-savebutton");
|
||||
|
||||
input.classList.remove("invalidinput");
|
||||
button.removeAttribute("disabled");
|
||||
|
||||
if (!remotefs.existsSync(input.value) || !remotefs.statSync(input.value).isDirectory()) {
|
||||
input.classList.add("invalidinput");
|
||||
button.setAttribute("disabled", "");
|
||||
}
|
||||
}
|
||||
|
||||
function loadGameVersions() {
|
||||
var versionJson = remotefs.readJsonSync(versionsPath);
|
||||
versionArray = versionJson["versions"];
|
||||
@ -304,6 +337,16 @@ function loadGameVersions() {
|
||||
function loadConfig() {
|
||||
// Load config object globally
|
||||
config = remotefs.readJsonSync(configPath);
|
||||
|
||||
$("#editconfig-autoupdate").prop("checked", config["autoupdate-check"]);
|
||||
$("#editconfig-cacheswapping").prop("checked", config["cache-swapping"]);
|
||||
$("#editconfig-enableofflinecache").prop("checked", config["enable-offline-cache"]);
|
||||
$("#editconfig-verifyofflinecache").prop("checked", config["verify-offline-cache"]);
|
||||
|
||||
offlineRoot = config["offline-cache-location"] || offlineRootDefault;
|
||||
$("#editconfig-offlinecachelocation:text").val(offlineRoot);
|
||||
|
||||
validateCacheLocation();
|
||||
}
|
||||
|
||||
function loadServerList() {
|
||||
@ -685,7 +728,7 @@ function prepGameInfo(serverUUID) {
|
||||
}
|
||||
}
|
||||
|
||||
if (config["always-use-cdn"]) {
|
||||
if (!config["enable-offline-cache"]) {
|
||||
// if we always ignore the offline cache, just use the URL
|
||||
setGameInfo(serverInfo, versionInfo.url);
|
||||
return;
|
||||
@ -898,3 +941,8 @@ $("#of-deleteversionmodal").on("show.bs.modal", function (e) {
|
||||
$("#of-editcacheconfigmodal").on("show.bs.modal", function (e) {
|
||||
if (!cacheSizes) handleCache("hash-check");
|
||||
});
|
||||
|
||||
$("#of-editconfigmodal").on("show.bs.modal", function (e) {
|
||||
// best to keep this synced on modal show
|
||||
loadConfig();
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"autoupdate-check": true,
|
||||
"cache-swapping": true,
|
||||
"always-use-cdn": true,
|
||||
"enable-offline-cache": false,
|
||||
"verify-offline-cache": false,
|
||||
"last-version-initialized": "1.5"
|
||||
"last-version-initialized": "1.6"
|
||||
}
|
||||
|
95
index.html
95
index.html
@ -108,6 +108,18 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-4 d-inline-flex justify-content-end">
|
||||
<button
|
||||
class="btn btn-primary mr-1"
|
||||
data-toggle="modal"
|
||||
data-bs-tooltip=""
|
||||
data-placement="bottom"
|
||||
id="of-editconfig-button"
|
||||
type="button"
|
||||
title="Edit Configuration"
|
||||
data-target="#of-editconfigmodal"
|
||||
>
|
||||
<i class="fas fa-cog"></i>
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-primary mr-1"
|
||||
data-toggle="modal"
|
||||
@ -469,6 +481,87 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="modal fade"
|
||||
role="dialog"
|
||||
tabindex="-1"
|
||||
id="of-editconfigmodal"
|
||||
>
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Edit Configuration</h4>
|
||||
<button
|
||||
type="button"
|
||||
class="close"
|
||||
data-dismiss="modal"
|
||||
aria-label="Close"
|
||||
>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="editconfig-form" class="needs-validation">
|
||||
<label for="editconfig-autoupdate"
|
||||
>Automatically update the client:</label
|
||||
><input
|
||||
class="form-control form-row w-75"
|
||||
type="checkbox"
|
||||
id="editconfig-autoupdate"
|
||||
/>
|
||||
<label for="editconfig-cacheswapping"
|
||||
>Swap game caches to avoid unnecessary downloads:</label
|
||||
><input
|
||||
class="form-control form-row w-75"
|
||||
type="checkbox"
|
||||
id="editconfig-cacheswapping"
|
||||
/>
|
||||
<label for="editconfig-enableofflinecache"
|
||||
>Use offline caches when they are available:</label
|
||||
><input
|
||||
class="form-control form-row w-75"
|
||||
type="checkbox"
|
||||
id="editconfig-enableofflinecache"
|
||||
/>
|
||||
<label for="editconfig-verifyofflinecache"
|
||||
>Verify offline caches every time they are loaded:</label
|
||||
><input
|
||||
class="form-control form-row w-75"
|
||||
type="checkbox"
|
||||
id="editconfig-verifyofflinecache"
|
||||
/>
|
||||
<label for="editconfig-offlinecachelocation"
|
||||
>Select Offline Cache Location:</label
|
||||
><input
|
||||
class="form-control form-row w-75"
|
||||
id="editconfig-offlinecachelocation"
|
||||
type="text"
|
||||
oninput="validateCacheLocator()"
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button
|
||||
class="btn btn-primary border rounded border-primary btn-danger border-danger"
|
||||
id="editconfig-cancel"
|
||||
type="button"
|
||||
data-dismiss="modal"
|
||||
>
|
||||
Cancel</button
|
||||
><button
|
||||
class="btn btn-primary border rounded border-primary btn-success border-success"
|
||||
id="editconfig-savebutton"
|
||||
type="submit"
|
||||
data-dismiss="modal"
|
||||
form="editconfig-form"
|
||||
onclick="editConfig();"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="modal fade"
|
||||
role="dialog"
|
||||
@ -478,7 +571,7 @@
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Edit Cache Config</h4>
|
||||
<h4 class="modal-title">Edit Game Builds</h4>
|
||||
<button
|
||||
type="button"
|
||||
class="close"
|
||||
|
6
index.js
6
index.js
@ -32,7 +32,7 @@ var hashPath = path.join(userData, "hashes.json");
|
||||
|
||||
function initialSetup(firstTime) {
|
||||
if (!firstTime) {
|
||||
// Migration from pre-1.5
|
||||
// Migration from pre-1.6
|
||||
// Back everything up, just in case
|
||||
fs.copySync(configPath, configPath + ".bak");
|
||||
fs.copySync(serversPath, serversPath + ".bak");
|
||||
@ -93,8 +93,8 @@ app.on("ready", function () {
|
||||
initialSetup(true);
|
||||
} else {
|
||||
var config = fs.readJsonSync(configPath);
|
||||
if (config["last-version-initialized"] !== "1.5") {
|
||||
console.log("Pre-1.5 config detected. Running migration.");
|
||||
if (config["last-version-initialized"] !== "1.6") {
|
||||
console.log("Pre-1.6 config detected. Running migration.");
|
||||
initialSetup(false);
|
||||
} else {
|
||||
showMainWindow();
|
||||
|
Loading…
Reference in New Issue
Block a user