Skip to content
Permalink
Browse files

Start work on the add server page.

  • Loading branch information...
roncli committed Jun 28, 2015
1 parent c6c2cf4 commit edced2795e4bfc40f40461fa75914d8b40fdc4a6
@@ -4,6 +4,7 @@
var app = angular.module("ddsn", []),
data = {
serverTab: "news",
addServerMenuTab: "saved",
settingsMenuTab: "descent3",
settings: {
descent3: {
@@ -73,6 +74,48 @@ var app = angular.module("ddsn", []),
};
});

app.directive("addServerSaved", function() {
return {
restrict: "E",
templateUrl: "/templates/add-server-saved.htm"
};
});

app.directive("addServerServer", function() {
return {
restrict: "E",
templateUrl: "/templates/add-server-server.htm"
};
});

app.directive("addServerGame", function() {
return {
restrict: "E",
templateUrl: "/templates/add-server-game.htm"
};
});

app.directive("addServerAllowed", function() {
return {
restrict: "E",
templateUrl: "/templates/add-server-allowed.htm"
};
});

app.directive("addServerModifications", function() {
return {
restrict: "E",
templateUrl: "/templates/add-server-modifications.htm"
};
});

app.directive("addServerLaunch", function() {
return {
restrict: "E",
templateUrl: "/templates/add-server-launch.htm"
};
});

app.directive("settingsDescent3", function() {
return {
restrict: "E",
@@ -94,14 +137,18 @@ var app = angular.module("ddsn", []),
$("button.server-tab").removeClass("btn-success").addClass("btn-primary");
$(ev.currentTarget).removeClass("btn-primary").addClass("btn-success");
data.serverTab = screen;
//scope.$apply();
};

$scope.openAddServer = function(ev, screen) {
$("button.add-server-menu-tab").removeClass("btn-success").addClass("btn-primary");
$(ev.currentTarget).removeClass("btn-primary").addClass("btn-success");
data.addServerMenuTab = screen;
};

$scope.openSettings = function(ev, screen) {
$("button.settings-menu-tab").removeClass("btn-success").addClass("btn-primary");
$(ev.currentTarget).removeClass("btn-primary").addClass("btn-success");
data.settingsMenuTab = screen;
//scope.$apply();
};

$scope.updateSettingsDescent3Path = function() {
No changes.
No changes.
No changes.
No changes.
No changes.
@@ -0,0 +1,33 @@
<div class="input-group">
<span class="input-group-addon" style="white-space: nowrap; width: 1px;">IP address:</span>
<span class="input-group-addon" style="width: 100%; padding: 0;">
<select class="form-control" ng-model="data.settings.addServer.server.ip">
<option value="">Default</option>
<option ng-repeat="network in data.settings.interfaces" value="{{network.ip}}">{{network.ip}} - {{network.name}}</option>
</select>
</span>
</div>
<div class="input-group">
<span class="input-group-addon">Server port:</span>
<input type="number" min="0" max="65535" class="form-control" placeholder="Port between 0 and 65535" ng-model="data.settings.addServer.server.port" ng-blur="updateAddServerServerPort()" />
</div>
<div class="input-group">
<span class="input-group-addon">GameSpy port:</span>
<input type="number" min="0" max="65535" class="form-control" placeholder="GameSpy port between 0 and 65535" ng-model="data.settings.addServer.server.gamespyport" ng-blur="updateAddServerServerGamespyport()" />
</div>
<div class="input-group">
<span class="input-group-addon">Server framerate:</span>
<input type="number" min="1" max="999" class="form-control" placeholder="Frames per second between 1 and 999" ng-model="data.settings.addServer.server.framerate" ng-blur="updateAddServerServerFramerate()" />
</div>
<div class="input-group">
<span class="input-group-addon" style="white-space: nowrap; width: 1px;">Ship logos and audio taunts:</span>
<span class="input-group-addon" style="width: 100%; text-align: left;">
<input type="checkbox" ng-model="data.settings.addServer.server.noMultiBmp" ng-true-value="false" ng-false-value="true" />
</span>
</div>
<div class="input-group">
<span class="input-group-addon" style="white-space: nowrap; width: 1px;">Use player messages:</span>
<span class="input-group-addon" style="width: 100%; text-align: left;">
<input type="checkbox" ng-model="data.settings.addServer.server.playerMessages" />
</span>
</div>
@@ -1,20 +1,26 @@
<ul class="nav nav-pills">
<li role="presentation">
<button class="btn btn-success"><span class="glyphicon glyphicon-hdd"></span> Saved Servers</button>
<button class="add-server-menu-tab btn btn-success saved" ng-click="openAddServer($event, 'saved')"><span class="glyphicon glyphicon-hdd"></span> Saved Servers</button>
</li>
<li role="presentation">
<button class="btn btn-primary"><span class="glyphicon glyphicon-wrench"></span> Server Options</button>
<button class="add-server-menu-tab btn btn-primary server" ng-click="openAddServer($event, 'server')"><span class="glyphicon glyphicon-wrench"></span> Server Options</button>
</li>
<li role="presentation">
<button class="btn btn-primary"><span class="glyphicon glyphicon-th-list"></span> Game Options</button>
<button class="add-server-menu-tab btn btn-primary game" ng-click="openAddServer($event, 'game')"><span class="glyphicon glyphicon-th-list"></span> Game Options</button>
</li>
<li role="presentation">
<button class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span> Allowed Objects</button>
<button class="add-server-menu-tab btn btn-primary allowed" ng-click="openAddServer($event, 'allowed')"><span class="glyphicon glyphicon-ok"></span> Allowed Objects</button>
</li>
<li role="presentation">
<button class="btn btn-primary"><span class="glyphicon glyphicon-tasks"></span> Modifications</button>
<button class="add-server-menu-tab btn btn-primary modifications" ng-click="openAddServer($event, 'modifications')"><span class="glyphicon glyphicon-tasks"></span> Modifications</button>
</li>
<li role="presentation">
<button class="btn btn-primary"><span class="glyphicon glyphicon-share"></span> Launch Server</button>
<button class="add-server-menu-tab btn btn-primary launch" ng-click="openAddServer($event, 'launch')"><span class="glyphicon glyphicon-share"></span> Launch Server</button>
</li>
</ul>
</ul><br />
<add-server-saved ng-if="data.addServerMenuTab === 'saved'"></add-server-saved>
<add-server-server ng-if="data.addServerMenuTab === 'server'"></add-server-server>
<add-server-game ng-if="data.addServerMenuTab === 'game'"></add-server-game>
<add-server-allowed ng-if="data.addServerMenuTab === 'allowed'"></add-server-allowed>
<add-server-modifications ng-if="data.addServerMenuTab === 'modifications'"></add-server-modifications>
<add-server-launch ng-if="data.addServerMenuTab === 'launch'"></add-server-launch>
@@ -1,5 +1,5 @@
<div ng-class="{true: 'input-group', false: 'input-group has-error'}[data.settings.descent3.pathValid]">
<span class="input-group-addon">Enter the path to your Descent 3 folder:</span>
<input class="form-control" placeholder="Your Descent 3 folder" type="text" ng-model="data.settings.descent3.path" ng-blur="updateSettingsDescent3Path()" />
<input type="text" class="form-control" placeholder="Your Descent 3 folder" ng-model="data.settings.descent3.path" ng-blur="updateSettingsDescent3Path()" />
</div>
<div class="alert alert-danger" role="alert" ng-if="!data.settings.descent3.pathValid"><span class="glyphicon glyphicon-alert"></span> Could not find Descent 3 in the directory specified.</div>
@@ -3,7 +3,8 @@ var cluster = require("cluster"),
WebSocket = require("ws"),
fs = require("fs"),
path = require("path"),
os = require("os");
os = require("os"),
Launcher = require("descent3launcher");

module.exports = function() {
"use strict";
@@ -49,11 +50,37 @@ module.exports = function() {
case "initialize":
// Read in settings JSON.
fs.exists("./settings.json", function(exists) {
var interfaces = os.networkInterfaces(),
key,

addInterface = function(network) {
if (network.family === "IPv4") {
settings.interfaces.push({
name: key,
ip: network.address
});
}
};

// Get saved settings.
if (exists) {
settings = require("./settings.json");
} else {
settings = {};
}

// Get default settings.
settings.default = Launcher.defaultOptions;
settings.addServer = Launcher.defaultOptions;

// Get network interfaces.
settings.interfaces = [];
for (key in interfaces) {
if (interfaces.hasOwnProperty(key)) {
interfaces[key].forEach(addInterface);
}
}

ws.send(JSON.stringify({
message: "settings",
settings: settings

0 comments on commit edced27

Please sign in to comment.
You can’t perform that action at this time.