156 lines
No EOL
3.8 KiB
JavaScript
156 lines
No EOL
3.8 KiB
JavaScript
// True numeric value binding
|
|
ko.bindingHandlers.numericValue = {
|
|
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
|
|
var underlyingObservable = valueAccessor();
|
|
var interceptor = ko.dependentObservable({
|
|
read: underlyingObservable,
|
|
write: function (value) {
|
|
if (!isNaN(value)) {
|
|
underlyingObservable(parseFloat(value));
|
|
}
|
|
}
|
|
});
|
|
ko.bindingHandlers.value.init(element, function () {
|
|
return interceptor
|
|
}, allBindingsAccessor, viewModel, bindingContext);
|
|
},
|
|
update: ko.bindingHandlers.value.update
|
|
};
|
|
|
|
var editor = ace.edit("config-editor");
|
|
editor.setTheme("ace/theme/monokai");
|
|
editor.session.setMode("ace/mode/javascript");
|
|
|
|
var viewmodel = ko.mapping.fromJS({
|
|
// Server Argument Section
|
|
"BaseServerArgs": "",
|
|
"AdditionalCmdLineParams": "",
|
|
|
|
// World Options
|
|
"WorldFriendlyName": "New Server",
|
|
"WorldAtlasId": "",
|
|
"WorldAtlasPassword": "",
|
|
"ModIDs": "",
|
|
|
|
// Grid Options
|
|
"gridSize": 1000,
|
|
"totalGridsX": 1,
|
|
"totalGridsY": 1,
|
|
"coordsScaling": 0.000000000001,
|
|
"globalTransitionMinZ": 0.0,
|
|
|
|
// Image Paths
|
|
"backgroundImgPath": "image.png",
|
|
"discoZonesImagePath": "image.png",
|
|
|
|
// URL Options
|
|
"MetaWorldURL": "",
|
|
"AuthListURL": "",
|
|
"MapImageURL": "",
|
|
|
|
// Time Options
|
|
"Day0": "2019-01-09 20:28:56",
|
|
"bUseUTCTime": false,
|
|
"columnUTCOffset": 0.0,
|
|
"lastImageOverride": "0001-01-01T00:00:00",
|
|
|
|
// Info Options
|
|
"showServerInfo": false,
|
|
"showDiscoZoneInfo": false,
|
|
"showShipPathsInfo": false,
|
|
"showIslandNames": false,
|
|
"showLines": false,
|
|
"showBackground": false,
|
|
|
|
// S3 Options
|
|
"LocalS3URL": "",
|
|
"LocalS3AccessKeyId": "",
|
|
"LocalS3SecretKey": "",
|
|
"LocalS3BucketName": "",
|
|
"LocalS3Region": "",
|
|
|
|
// Unsorted...
|
|
"globalGameplaySetup": "",
|
|
"shipPathsIdGenerator": 1,
|
|
"idGenerator": 127,
|
|
"regionsIdGenerator": 0,
|
|
|
|
// Tribe Log Tab
|
|
"TribeLogConfig": {
|
|
// Main Options
|
|
"MaxRedisEntries": 1000,
|
|
"BackupMode": "off",
|
|
"MaxFileHistory": 10,
|
|
"HttpBackupURL": "",
|
|
"HttpAPIKey": "",
|
|
|
|
//S3 Options
|
|
"S3URL": "",
|
|
"S3AccessKeyId": "",
|
|
"S3SecretKey": "",
|
|
"S3BucketName": "",
|
|
"S3KeyPrefix": ""
|
|
},
|
|
|
|
// Travel Data Tab
|
|
"TravelDataConfig": {
|
|
// Main Options
|
|
"BackupMode": "off",
|
|
"MaxFileHistory": 10,
|
|
"HttpBackupURL": "",
|
|
"HttpAPIKey": "",
|
|
|
|
//S3 Options
|
|
"S3URL": "",
|
|
"S3AccessKeyId": "",
|
|
"S3SecretKey": "",
|
|
"S3BucketName": "",
|
|
"S3KeyPrefix": ""
|
|
},
|
|
|
|
"SharedLogConfig": {
|
|
"FetchRateSec": 60,
|
|
"SnapshotCleanupSec": 900,
|
|
"SnapshotRateSec": 1800,
|
|
"SnapshotExpirationHours": 48,
|
|
"BackupMode": "off",
|
|
"MaxFileHistory": 10,
|
|
"HttpBackupURL": "",
|
|
"HttpAPIKey": "",
|
|
"S3URL": "",
|
|
"S3AccessKeyId": "",
|
|
"S3SecretKey": "",
|
|
"S3BucketName": "",
|
|
"S3KeyPrefix": ""
|
|
},
|
|
|
|
"DatabaseConnections": [],
|
|
"servers": [],
|
|
"spawnerOverrideTemplates": [],
|
|
"shipPaths": [],
|
|
"serverTemplates": [],
|
|
|
|
// ?!?!
|
|
"OverrideShooterGameModeDefaultGameIni": {}
|
|
});
|
|
ko.applyBindings(viewmodel);
|
|
|
|
updateEditor();
|
|
|
|
ko.computed(function () {
|
|
return ko.toJSON(viewmodel);
|
|
}).subscribe(function () {
|
|
updateEditor();
|
|
});
|
|
|
|
editor.on("change", function () {
|
|
setTimeout(function () {
|
|
ko.mapping.fromJSON(editor.getValue(), viewmodel);
|
|
}, 100);
|
|
});
|
|
|
|
function updateEditor() {
|
|
var interim = ko.mapping.toJS(viewmodel);
|
|
interim.coordsScaling = Number(interim.coordsScaling).toFixed(12);
|
|
editor.setValue(ko.toJSON(interim, null, 2));
|
|
} |