@csegames/camelot-unchained
Version:
Camelot Unchained Client Library
1,245 lines (1,224 loc) • 2.15 MB
JavaScript
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var BuildingBlueprint_1 = require("./classes/BuildingBlueprint");
var client_1 = require("../core/client");
var events_1 = require("../events");
var restApi = require("../restapi");
var blueprintsLoaded = false;
var blueprintsRequested = false;
var blueprintsList = [];
function loadBlueprints() {
client_1.default.OnNewBlueprint(function (index, name) {
var current = new Date().getTime();
// special case, this is not a real blueprint
if (name === 'Small Control Island') return;
var blueprint = new BuildingBlueprint_1.default({
index: index,
name: name
});
blueprintsList.push(blueprint);
if (blueprintsLoaded) {
events_1.default.fire(events_1.default.buildingEventTopics.handlesBlueprints, { blueprints: blueprintsList });
}
});
client_1.default.RequestBlueprints();
}
function requestBlueprintCopy() {
client_1.default.CopyBlueprint();
}
exports.requestBlueprintCopy = requestBlueprintCopy;
function requestBlueprintPaste() {
client_1.default.PasteBlueprint();
}
exports.requestBlueprintPaste = requestBlueprintPaste;
function fireHandleBlueprints() {
events_1.default.fire(events_1.default.buildingEventTopics.handlesBlueprints, { blueprints: blueprintsList });
}
function requestBlueprintDelete(blueprint) {
// no feedback on this delete, we just call it and cross our fingers
client_1.default.DeleteLocalBlueprint(blueprint.name);
// there is no client.OnDeleteBlueprint
// so we will just remove the blueprint and hope the delete really worked
for (var index = 0; index <= blueprintsList.length; index++) {
var bp = blueprintsList[index];
if (bp.name === blueprint.name) {
blueprintsList.splice(index, 1);
fireHandleBlueprints();
return;
}
}
}
exports.requestBlueprintDelete = requestBlueprintDelete;
function requestBlueprintSave(name) {
client_1.default.SaveBlueprint(name);
}
exports.requestBlueprintSave = requestBlueprintSave;
function requestBlueprintSelect(blueprint) {
client_1.default.SelectBlueprint(blueprint.index);
events_1.default.fire(events_1.default.buildingEventTopics.handlesBlueprintSelect, { blueprint: blueprint });
}
exports.requestBlueprintSelect = requestBlueprintSelect;
function requestBlueprintIcon(blueprint) {
restApi.blueprints.getBlueprintIcon(blueprint.index).then(function (icon) {
blueprint.icon = icon;
fireHandleBlueprints();
}, function () {
fireHandleBlueprints();
});
}
exports.requestBlueprintIcon = requestBlueprintIcon;
function requestBlueprints() {
if (!blueprintsRequested) {
blueprintsRequested = false;
loadBlueprints();
}
if (blueprintsLoaded) {
fireHandleBlueprints();
} else {
// we are waiting till the blueprintsList has not updated for 2 seconds before declaring that the blueprints are loaded
// we are only firing off the event periodically to avoid re-rendering the list possibly 100s of times on startup.
// The blueprints are loaded using the client.OnNewBlueprint() event which fires for every blueprint
waitForBlueprintsToLoad();
}
}
exports.requestBlueprints = requestBlueprints;
function waitForBlueprintsToLoad() {
var lastSize = blueprintsList.length;
setTimeout(function () {
if (lastSize === blueprintsList.length) {
blueprintsLoaded = true;
fireHandleBlueprints();
} else {
waitForBlueprintsToLoad();
}
}, 2000);
}
},{"../core/client":61,"../events":101,"../restapi":126,"./classes/BuildingBlueprint":5}],2:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var client_1 = require("../core/client");
function changeMode(mode) {
client_1.default.SetBuildingMode(mode);
}
exports.changeMode = changeMode;
function commit() {
client_1.default.CommitBlock();
}
exports.commit = commit;
function undo() {
client_1.default.UndoCube();
}
exports.undo = undo;
function redo() {
client_1.default.RedoCube();
}
exports.redo = redo;
function rotateX() {
client_1.default.BlockRotateX();
}
exports.rotateX = rotateX;
function rotateY() {
client_1.default.BlockRotateY();
}
exports.rotateY = rotateY;
function rotateZ() {
client_1.default.BlockRotateZ();
}
exports.rotateZ = rotateZ;
function flipX() {
client_1.default.BlockFlipX();
}
exports.flipX = flipX;
function flipY() {
client_1.default.BlockFlipY();
}
exports.flipY = flipY;
function flipZ() {
client_1.default.BlockFlipZ();
}
exports.flipZ = flipZ;
},{"../core/client":61}],3:[function(require,module,exports){
"use strict";
function __export(m) {
for (var p in m) {
if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
}
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var BuildingMaterial_1 = require("./classes/BuildingMaterial");
var BuildingBlock_1 = require("./classes/BuildingBlock");
var client_1 = require("../core/client");
var events_1 = require("../events");
var materialsLoaded = false;
var materialsRequested = false;
var numBlocksToLoad = 0;
var loadCallbacks = [];
var materialsMap = {};
var materialsList = [];
var blocks = {};
// tslint:disable-next-line
var BLANK_IMAGE = 'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuOWwzfk4AAALxSURBVHhe5dlLiI1xGMfx30pCRFkJCyXFYiRSsmBByWIipMiOWYiNjZSirCxcsrUZuUzKZSGxULNT5JJsKaXspJlcVsd7zDn1zPN+z5n38v/bPIvP5nee37//M73TnN5Rp9MJDcNIMIwEw0gwjATDSDCMBMNIMIwEw0gwjATDSDCMBMNIMIwEw8akHYXNhU1gBXaqkrYWuufvLKH5ijBsTDr470j2BjtVSNfdWdYe7FSEYSvShLmcdx47w0ij7gzrKnZqwLA1adpc0tuIHSItLnwzXesjdmrCsDVpxFzUm8QOke65rrUQOzVhmIR00VzWO4MdSxpzHWsXdhrAMBnptbm0tx47XdLawh8za13GTkMYJiMtMBf3nmKnS3rmZvve4XwLGCYlHTELeKdg/qybsZaX5lvCMDnpllnC+llYbea2mc+80VlnJoJhFtIXs4x118x8dp/1Jf29tzDMQtpiFvJOF+64rO8VnpcIhtlI58xiVa3CsxLBMCvpuVluLofxjIQwzEpaUvjdW3CYG9hPDMPspP1mUfIWexlg+F9I18zC3hh2MsAwu5lviN97y5IfhfnYTQzD7KT7vUWHeYjdxDDMSjphlpxL+atyYhhmI60xy1W1Ds9KBMNspJdmMWuy8Mhlfe/xrEQwzEK6YJbyFvVmvrq870rpvEQwTE7abpbxjpm5ve4za/esMxPBMDlpyixiPYHZQa/Ap0qzCWCYlDRulvBmHn1Lmlf4ZGasx6X5ljBMZvg/Sg5hp0va52at49hpCMMkpGXm0t4EdizpputYS7HTAIZJDH8jXH70vZkf4KCvyx+w0wCGrQ1/8TH40feko65rXcJOTRi2Im0wl/TGsTOM9MCdYY1gpwYMW5F+mQta3T+Fcz/6nrTSnOFNY6cGDBsb/GKzq/qj70kn3VnWbexUhGEj0gFzKa/+o+9JL9yZVuP/GWAYCYaRYBgJhpFgGAmGkWAYCYaRYBgJhpFgGAmGkWAYCYaRYBhHR38Boj2hpYws8QsAAAAASUVORK5CYII=';
function getBlockForShapeId(shapeId, blocks) {
for (var i in blocks) {
var block = blocks[i];
if (block.shapeId === shapeId) {
return block;
}
}
return blocks[0];
}
function getShapeIdFromBlockId(id) {
return id >> 21 & 31;
}
function getMaterialIdFromBlockId(id) {
return id >> 2 & 4095;
}
function recieveMaterials(subsRecieved) {
for (var i in subsRecieved) {
var id = parseInt(i, 10);
var material = new BuildingMaterial_1.default({
id: id,
icon: subsRecieved[i],
tags: [],
blocks: []
});
materialsMap[id] = material;
materialsList.push(material);
}
client_1.default.RequestBlocks();
}
function recieveBlocks(blocksRecieved) {
for (var i in blocksRecieved) {
numBlocksToLoad++;
var id = parseInt(i, 10);
blocks[id] = {
id: id,
icon: blocksRecieved[i],
materialTags: [],
shapeTags: []
};
}
for (var i in blocksRecieved) {
var id = parseInt(i, 10);
client_1.default.RequestBlockTags(id);
}
}
function recieveBlockTags(id, tags) {
var block = blocks[id];
block.shapeId = getShapeIdFromBlockId(id);
block.shapeTags = tags.Shapes;
block.materialId = getMaterialIdFromBlockId(id);
block.materialTags = tags.Types;
var material = materialsMap[block.materialId];
if (material == null) {
console.log('unknown material ' + block.materialId + ' for block ' + id + '-' + tags.Types.join(','));
} else {
material.tags = tags.Types;
material.blocks.push(block);
}
if (--numBlocksToLoad === 0) {
// finished loading shapes and types
events_1.default.fire(events_1.default.buildingEventTopics.handlesBlocks, { materials: materialsList });
}
}
function getBlockForBlockId(blockid) {
var matId = getMaterialIdFromBlockId(blockid);
var shapeId = getShapeIdFromBlockId(blockid);
var sub = materialsMap[matId];
if (sub == null) return null;
// select by shape instead of by block id, it is more reliable, the block id sent back
// can have extra information stored in it
return getBlockForShapeId(shapeId, sub.blocks);
}
exports.getBlockForBlockId = getBlockForBlockId;
function getMaterialForBlockId(blockid) {
var matId = getMaterialIdFromBlockId(blockid);
return materialsMap[matId];
}
exports.getMaterialForBlockId = getMaterialForBlockId;
function requestBlockSelect(block) {
client_1.default.ChangeBlockType(block.id);
}
exports.requestBlockSelect = requestBlockSelect;
// some blocks don't show up in the list retrieved by Request Substances or RequestBlocks
// make up the information based on the block id, so we can at least display the shape and material type to the user
// returning this information as a promise in case it is possible to request meta data on the material
function getMissingMaterial(blockid) {
var block = new BuildingBlock_1.default({
id: blockid,
shapeId: getShapeIdFromBlockId(blockid),
materialId: getMaterialIdFromBlockId(blockid),
icon: BLANK_IMAGE
});
blocks[block.id] = block;
var material = new BuildingMaterial_1.default({ id: block.materialId, blocks: [block], icon: BLANK_IMAGE });
materialsMap[material.id] = material;
materialsList.push(material);
events_1.default.fire(events_1.default.buildingEventTopics.handlesBlocks, { materials: materialsList });
return { material: material, block: block };
}
exports.getMissingMaterial = getMissingMaterial;
function requestMaterials() {
if (!materialsRequested) {
materialsRequested = false;
client_1.default.OnReceiveSubstances(recieveMaterials);
client_1.default.OnReceiveBlocks(recieveBlocks);
client_1.default.OnReceiveBlockTags(recieveBlockTags);
client_1.default.RequestSubstances();
}
}
exports.requestMaterials = requestMaterials;
__export(require("./blueprints"));
__export(require("./building-actions"));
},{"../core/client":61,"../events":101,"./blueprints":1,"./building-actions":2,"./classes/BuildingBlock":4,"./classes/BuildingMaterial":6}],4:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var BuildingBlock = function () {
function BuildingBlock(block) {
if (block === void 0) {
block = {};
}
this.id = block.id;
this.icon = block.icon;
this.shapeId = block.shapeId;
this.shapeTags = block.shapeTags || [];
this.materialId = block.materialId;
this.materialTags = block.materialTags || [];
}
BuildingBlock.create = function () {
var a = new BuildingBlock();
return a;
};
return BuildingBlock;
}();
exports.default = BuildingBlock;
},{}],5:[function(require,module,exports){
"use strict";
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var BuildingBlueprint = function () {
function BuildingBlueprint(block) {
if (block === void 0) {
block = {};
}
this.name = block.name;
this.icon = block.icon;
this.index = block.index;
}
BuildingBlueprint.create = function () {
var a = new BuildingBlueprint();
return a;
};
return BuildingBlueprint;
}();
exports.default = BuildingBlueprint;
},{}],6:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var BuildingMaterial = function () {
function BuildingMaterial(substance) {
if (substance === void 0) {
substance = {};
}
this.id = substance.id;
this.icon = substance.icon;
this.tags = substance.tags || [];
this.blocks = substance.blocks || [];
}
BuildingMaterial.prototype.getBlockForShape = function (shapeId) {
for (var i in this.blocks) {
var block = this.blocks[i];
if (block.shapeId === shapeId) {
return block;
}
}
};
BuildingMaterial.create = function () {
var a = new BuildingMaterial();
return a;
};
return BuildingMaterial;
}();
exports.default = BuildingMaterial;
},{}],7:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var BuildingEventTopics_1 = require("./BuildingEventTopics");
var client_1 = require("../../core/client");
var building = require("../../building/building");
function run(emitter, topic) {
if (client_1.default.OnBlockSelected) {
client_1.default.OnBlockSelected(function (blockid) {
var material = building.getMaterialForBlockId(blockid);
var block = building.getBlockForBlockId(blockid);
if (material) {
emitter.emit(topic, { material: material, block: block });
} else {
emitter.emit(topic, building.getMissingMaterial(blockid));
}
});
}
}
var BlockSelectListener = function () {
function BlockSelectListener() {
this.listening = false;
this.topic = BuildingEventTopics_1.default.handlesBlockSelect;
}
BlockSelectListener.prototype.start = function (emitter) {
if (!this.listening) {
this.listening = true;
run(emitter, this.topic);
}
};
return BlockSelectListener;
}();
exports.default = BlockSelectListener;
},{"../../building/building":3,"../../core/client":61,"./BuildingEventTopics":10}],8:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var BuildingEventTopics_1 = require("./BuildingEventTopics");
var client_1 = require("../../core/client");
function run(emitter, topic) {
if (client_1.default.OnBlockSelected) {
client_1.default.OnCopyBlueprint(function () {
emitter.emit(BuildingEventTopics_1.default.handlesBlueprintCopy, {});
});
}
}
var BlockSelectListener = function () {
function BlockSelectListener() {
this.listening = false;
this.topic = BuildingEventTopics_1.default.handlesBlueprintCopy;
}
BlockSelectListener.prototype.start = function (emitter) {
if (!this.listening) {
this.listening = true;
run(emitter, this.topic);
}
};
return BlockSelectListener;
}();
exports.default = BlockSelectListener;
},{"../../core/client":61,"./BuildingEventTopics":10}],9:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var BuildingEventTopics_1 = require("./BuildingEventTopics");
var client_1 = require("../../core/client");
function run(emitter, topic) {
if (client_1.default.OnBlockSelected) {
client_1.default.OnBlueprintSelected(function () {
// todo: how can i tell which blueprint was selected? There are no parameters. Also, it never seems to be called
console.log('OnBlueprintSelected: ' + JSON.stringify([].slice.call(arguments)));
});
}
}
var BlockSelectListener = function () {
function BlockSelectListener() {
this.listening = false;
this.topic = BuildingEventTopics_1.default.handlesBlueprintSelect;
}
BlockSelectListener.prototype.start = function (emitter) {
if (!this.listening) {
this.listening = true;
run(emitter, this.topic);
}
};
return BlockSelectListener;
}();
exports.default = BlockSelectListener;
},{"../../core/client":61,"./BuildingEventTopics":10}],10:[function(require,module,exports){
"use strict";
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var BuildingEventTopics = {
handlesBuildingMode: 'building-mode',
handlesBlockSelect: 'block-select',
handlesBlocks: 'block-updated',
handlesBlueprintSelect: 'blueprint-select',
handlesBlueprintCopy: 'blueprint-copy',
handlesBlueprints: 'blueprint-updated'
};
exports.default = BuildingEventTopics;
},{}],11:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var BuildingEventTopics_1 = require("./BuildingEventTopics");
var client_1 = require("../../core/client");
function run(emitter, topic) {
if (client_1.default.OnBlockSelected) {
client_1.default.OnBuildingModeChanged(function (mode) {
emitter.emit(topic, { mode: mode });
});
}
}
var BuildingModeListener = function () {
function BuildingModeListener() {
this.listening = false;
this.topic = BuildingEventTopics_1.default.handlesBuildingMode;
}
BuildingModeListener.prototype.start = function (emitter) {
if (!this.listening) {
this.listening = true;
run(emitter, this.topic);
}
};
return BuildingModeListener;
}();
exports.default = BuildingModeListener;
},{"../../core/client":61,"./BuildingEventTopics":10}],12:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var building = require("./building");
exports.building = building;
var BuildingMaterial_1 = require("./classes/BuildingMaterial");
exports.BuildingMaterial = BuildingMaterial_1.default;
var BuildingBlock_1 = require("./classes/BuildingBlock");
exports.BuildingBlock = BuildingBlock_1.default;
var BuildingBlueprint_1 = require("./classes/BuildingBlueprint");
exports.BuildingBlueprint = BuildingBlueprint_1.default;
},{"./building":3,"./classes/BuildingBlock":4,"./classes/BuildingBlueprint":5,"./classes/BuildingMaterial":6}],13:[function(require,module,exports){
"use strict";
// Typescript conversion based on https://github.com/thiagoc7/react-animate.css
// which is under the MIT license as indicated below
//
// The MIT License (MIT)
//
// Copyright (c) 2015 Ryan Florence
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
var __extends = undefined && undefined.__extends || function () {
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) {
if (b.hasOwnProperty(p)) d[p] = b[p];
}
};
return function (d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var react_transition_group_1 = require("react-transition-group");
var Animate = function (_super) {
__extends(Animate, _super);
function Animate() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.renderStyle = function (animationEnter, animationLeave, durationEnter, durationLeave) {
return "\n .default-enter {\n opacity: 0;\n }\n .default-enter." + animationEnter + " {\n animation-duration: " + durationEnter / 1000 + "s;\n animation-fill-mode: both;\n opacity: 1;\n }\n .default-leave {\n opacity: 1;\n }\n .default-leave." + animationLeave + " {\n animation-duration: " + durationLeave / 1000 + "s;\n animation-fill-mode: both;\n }\n ";
};
return _this;
}
Animate.prototype.render = function () {
var _a = this.props,
children = _a.children,
animationEnter = _a.animationEnter,
animationLeave = _a.animationLeave,
durationEnter = _a.durationEnter,
durationLeave = _a.durationLeave;
return React.createElement(react_transition_group_1.CSSTransitionGroup, { key: this.props.key, component: this.props.component ? this.props.component : 'div', transitionName: {
enter: 'default-enter',
enterActive: animationEnter,
leave: 'default-leave',
leaveActive: animationLeave
}, transitionEnterTimeout: durationEnter, transitionLeaveTimeout: durationLeave, className: "" + (this.props.className ? this.props.className : '') }, React.createElement("style", { dangerouslySetInnerHTML: { __html: this.renderStyle(animationEnter, animationLeave, durationEnter, durationLeave) } }), children);
};
return Animate;
}(React.Component);
exports.default = Animate;
},{"react":237,"react-transition-group":232}],14:[function(require,module,exports){
"use strict";
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var __assign = undefined && undefined.__assign || Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var defaultStyle = {
position: 'absolute',
height: '100%'
};
function renderCUIcon(props) {
var internalProps = props.props || {};
return React.createElement("span", { style: __assign({ position: 'relative' }, props.iconContainer), className: props.className }, React.createElement("span", { className: props.icon, style: __assign({}, defaultStyle, props.iconStyle) }), React.createElement("div", __assign({ style: props.iconContainer }, internalProps)));
}
exports.renderCUIcon = renderCUIcon;
exports.CUIcon = renderCUIcon;
exports.default = exports.CUIcon;
},{"react":237}],15:[function(require,module,exports){
"use strict";
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var aphrodite_1 = require("aphrodite");
exports.defaultCardStyle = {
card: {
backgroundColor: '#3c3c3c',
color: '#ececec',
padding: '10px',
margin: '1em',
borderRadius: '2px'
},
levelOne: {
boxShadow: '0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)',
transition: 'all 0.3s cubic-bezier(.25,.8,.25,1)'
},
levelTwo: {
boxShadow: '0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)',
transition: 'all 0.3s cubic-bezier(.25,.8,.25,1)'
},
levelThree: {
boxShadow: '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)',
transition: 'all 0.3s cubic-bezier(.25,.8,.25,1)'
},
levelFour: {
boxShadow: '0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22)',
transition: 'all 0.3s cubic-bezier(.25,.8,.25,1)'
},
levelFive: {
boxShadow: '0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)',
transition: 'all 0.3s cubic-bezier(.25,.8,.25,1)'
}
};
var CardLevel;
(function (CardLevel) {
CardLevel[CardLevel["One"] = 0] = "One";
CardLevel[CardLevel["Two"] = 1] = "Two";
CardLevel[CardLevel["Three"] = 2] = "Three";
CardLevel[CardLevel["Four"] = 3] = "Four";
CardLevel[CardLevel["Five"] = 4] = "Five";
})(CardLevel = exports.CardLevel || (exports.CardLevel = {}));
exports.Card = function (props) {
var ss = aphrodite_1.StyleSheet.create(exports.defaultCardStyle);
var custom = aphrodite_1.StyleSheet.create(props.styles || {});
var level = props.level || CardLevel.One;
var levelCSS = ss.levelOne;
var customLevelCSS = custom.levelOne;
switch (level) {
case CardLevel.Two:
levelCSS = ss.levelTwo;
customLevelCSS = custom.levelTwo;
break;
case CardLevel.Three:
levelCSS = ss.levelThree;
customLevelCSS = custom.levelThree;
break;
case CardLevel.Four:
levelCSS = ss.levelFour;
customLevelCSS = custom.levelFour;
break;
case CardLevel.Five:
levelCSS = ss.levelFive;
customLevelCSS = custom.levelFive;
break;
}
return React.createElement("div", { className: aphrodite_1.css(ss.card, levelCSS, custom.card, customLevelCSS) }, props.children);
};
exports.default = exports.Card;
},{"aphrodite":159,"react":237}],16:[function(require,module,exports){
"use strict";
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var _this = undefined;
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var _1 = require("../");
var SVGSprite_1 = require("./SVGSprite");
var aphrodite_1 = require("aphrodite");
var lodash_1 = require("lodash");
var defaultStyle = {
icon: {
fill: 'white',
height: '100%',
width: '100%'
}
};
exports.ClassIcon = function (props) {
var ss = aphrodite_1.StyleSheet.create(lodash_1.merge(defaultStyle, props.style || {}));
switch (_this.props.playerClass) {
case _1.Archetype.Blackguard:
return React.createElement(SVGSprite_1.default, { sprite: 'images/class-icons.svg#archer-class-icon', svgClass: aphrodite_1.css(ss.icon) });
case _1.Archetype.BlackKnight:
return React.createElement(SVGSprite_1.default, { sprite: 'images/class-icons.svg#heavy-class-icon', svgClass: aphrodite_1.css(ss.icon) });
case _1.Archetype.Empath:
return React.createElement(SVGSprite_1.default, { sprite: 'images/class-icons.svg#heal-class-icon', svgClass: aphrodite_1.css(ss.icon) });
default:
return React.createElement("h1", null, "Invalid Class");
}
};
exports.default = exports.ClassIcon;
},{"../":121,"./SVGSprite":43,"aphrodite":159,"lodash":216,"react":237}],17:[function(require,module,exports){
"use strict";
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
var __extends = undefined && undefined.__extends || function () {
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) {
if (b.hasOwnProperty(p)) d[p] = b[p];
}
};
return function (d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var aphrodite_1 = require("aphrodite");
exports.defaultCollapsingListStyle = {
CollapsingList: {
height: '100%',
webkitUserSelect: 'none',
userSelect: 'none',
pointerEvents: 'all',
color: 'white'
},
title: {
cursor: 'pointer'
},
collapseButton: {
display: 'inline-block',
color: 'white',
width: '15px'
},
body: {},
listContainer: {},
listFooter: {},
listItem: {
display: 'flex',
alignItems: 'center',
marginLeft: '10px'
}
};
var CollapsingList = function (_super) {
__extends(CollapsingList, _super);
function CollapsingList(props) {
var _this = _super.call(this, props) || this;
_this.onToggleCollapse = function () {
if (typeof _this.props.collapsed !== "boolean") {
_this.setState(function (state, props) {
if (state.collapsed) {
// Show
if (_this.props.onToggleCollapse) _this.props.onToggleCollapse(false);
return {
collapsed: false
};
}
// Hide
if (_this.props.onToggleCollapse) _this.props.onToggleCollapse(true);
return {
collapsed: true
};
});
} else if (_this.props.onToggleCollapse) {
_this.props.onToggleCollapse(!_this.props.collapsed);
}
};
_this.state = {
collapsed: props.defaultCollapsed || false
};
return _this;
}
CollapsingList.prototype.render = function () {
var _this = this;
var ss = aphrodite_1.StyleSheet.create(exports.defaultCollapsingListStyle);
var custom = aphrodite_1.StyleSheet.create(this.props.styles || {});
var animationClass = this.props.animationClass && aphrodite_1.StyleSheet.create(this.props.animationClass(this.props.collapsed));
var collapsed = typeof this.props.collapsed === 'boolean' ? this.props.collapsed : this.state.collapsed;
return React.createElement("div", { className: aphrodite_1.css(ss.CollapsingList, custom.CollapsingList) }, React.createElement("div", { className: aphrodite_1.css(ss.titleContainer, custom.titleContainer) }, typeof this.props.title === 'string' ? React.createElement("span", { className: aphrodite_1.css(ss.title, custom.title), onClick: this.onToggleCollapse }, React.createElement("div", { className: aphrodite_1.css(ss.collapseButton, custom.collapseButton) }, this.props.collapsed ? '+' : '-'), this.props.title) : React.createElement("span", { className: aphrodite_1.css(ss.title, custom.title), onClick: this.onToggleCollapse }, this.props.title(this.props.collapsed))), React.createElement("div", { className: aphrodite_1.css(ss.body, custom.body, animationClass && animationClass.anim), style: !animationClass ? this.props.collapsed ? { display: 'none' } : {} : {} }, this.props.renderListHeader && React.createElement("div", { className: aphrodite_1.css(ss.listHeader, custom.listHeader) }, this.props.renderListHeader()), React.createElement("div", { className: aphrodite_1.css(ss.listContainer, custom.listContainer) }, this.props.items.map(function (item, i) {
if (!_this.props.renderListItem) {
if (typeof item === 'string') {
return React.createElement("div", { key: i, className: aphrodite_1.css(ss.listItem, custom.listItem) }, item);
}
return React.createElement("div", { key: i, className: aphrodite_1.css(ss.listItem, custom.listItem) }, Object.keys(item).map(function (key) {
return React.createElement("div", { key: key }, item[key]);
}));
}
return _this.props.renderListItem(item, i);
})), this.props.renderListFooter && React.createElement("div", { className: aphrodite_1.css(ss.listFooter, custom.listFooter) }, this.props.renderListFooter())));
};
return CollapsingList;
}(React.Component);
exports.CollapsingList = CollapsingList;
exports.default = CollapsingList;
},{"aphrodite":159,"react":237}],18:[function(require,module,exports){
"use strict";
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var __extends = undefined && undefined.__extends || function () {
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) {
if (b.hasOwnProperty(p)) d[p] = b[p];
}
};
return function (d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = undefined && undefined.__assign || Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
/*
* Usage:
*
* Wrap any element with this component and you'll get a confirmation
* dialog popup when the element inside is clicked.
*
* <ConfirmDialog onConfirm={() => Do something }
* onCancel={() => Do something}
* content={(props: any) => <div>Are you sure?</div>}
* cancelOnClickOutside={true} >
* <button>Click Me!</button>
* </ConfirmDialog>
*
*/
var React = require("react");
var aphrodite_1 = require("aphrodite");
var lodash_1 = require("lodash");
var defaultStyles = {
container: {
position: 'fixed',
top: '0',
bottom: '0',
left: '0',
right: '0',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
cursor: 'default',
backgroundColor: 'rgba(0, 0, 0, 0.4)'
},
dialog: {
backgroundColor: '#444',
minWidth: '250px',
minHeight: '100px',
display: 'flex',
flexDirection: 'column'
},
content: {
padding: '10px',
flex: '1 1 auto'
},
buttons: {
display: 'flex',
flex: '0 0 auto',
justifyContent: 'space-around',
alignItems: 'center',
width: '100%',
padding: '10px 20px'
},
confirmButton: {
padding: '5px 10px',
cursor: 'pointer',
':hover': {
backgroundColor: 'rgba(0, 0, 0, 0.2)'
}
},
cancelButton: {
padding: '5px 10px',
cursor: 'pointer',
':hover': {
backgroundColor: 'rgba(0, 0, 0, 0.2)'
}
}
};
var ConfirmDialog = function (_super) {
__extends(ConfirmDialog, _super);
function ConfirmDialog(props) {
var _this = _super.call(this, props) || this;
_this.mouseOver = false;
_this.show = function () {
_this.setState({
hidden: false
});
_this.mouseOver = false;
};
_this.hide = function () {
_this.setState({
hidden: true
});
window.removeEventListener('mousedown', _this.windowMouseDown);
_this.mouseOver = false;
};
_this.confirm = function () {
_this.hide();
_this.props.onConfirm();
};
_this.cancel = function () {
_this.hide();
_this.props.onCancel();
};
_this.onMouseEnter = function () {
_this.mouseOver = true;
};
_this.onMouseleave = function () {
_this.mouseOver = false;
};
_this.windowMouseDown = function () {
if (_this.state.cancelOnClickOutside && !_this.state.hidden && !_this.mouseOver) {
_this.cancel();
}
};
_this.clicked = function () {
if (!_this.state.hidden) return;
_this.show();
window.addEventListener('mousedown', _this.windowMouseDown);
};
_this.state = {
hidden: true,
cancelOnClickOutside: _this.props.cancelOnClickOutside || false
};
return _this;
}
ConfirmDialog.prototype.render = function () {
var ss = aphrodite_1.StyleSheet.create(lodash_1.merge(defaultStyles, this.props.style || {}));
return React.createElement("div", { onClick: this.clicked, style: { display: 'inline-block' } }, this.props.children, this.state.hidden ? null : React.createElement("div", { className: aphrodite_1.css(ss.container) }, React.createElement("div", { className: aphrodite_1.css(ss.dialog), onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseleave }, React.createElement("div", { className: aphrodite_1.css(ss.content) }, React.createElement(this.props.content, __assign({}, this.props.contentProps))), React.createElement("div", { className: aphrodite_1.css(ss.buttons) }, React.createElement("div", { className: aphrodite_1.css(ss.confirmButton), onClick: this.confirm }, this.props.confirmButtonContent || 'Confirm'), React.createElement("div", { className: aphrodite_1.css(ss.cancelButton), onClick: this.cancel }, this.props.cancelButtonContent || 'Cancel')))));
};
ConfirmDialog.prototype.componentWillUnmount = function () {
window.removeEventListener('mousedown', this.windowMouseDown);
};
return ConfirmDialog;
}(React.Component);
exports.ConfirmDialog = ConfirmDialog;
exports.default = ConfirmDialog;
},{"aphrodite":159,"lodash":216,"react":237}],19:[function(require,module,exports){
"use strict";
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var __extends = undefined && undefined.__extends || function () {
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) {
if (b.hasOwnProperty(p)) d[p] = b[p];
}
};
return function (d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = undefined && undefined.__assign || Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var _ = require("lodash");
var utils_1 = require("../utils");
var aphrodite_1 = require("aphrodite");
var defaultStyles = {
contextMenu: {
backgroundColor: '#4d573e',
border: '1px solid darken(#4d573e, 20%)',
color: '#ececec',
'z-index': '9998'
}
};
var ContextMenu = function (_super) {
__extends(ContextMenu, _super);
function ContextMenu(props) {
var _this = _super.call(this, props) || this;
_this.mouseOverElement = false;
_this.hide = function () {
if (_this.props.onContextMenuContentHide) _this.props.onContextMenuContentHide();
_this.setState({ hidden: true });
window.removeEventListener('keydown', _this.onKeyDown);
window.removeEventListener('mousedown', _this.onMouseDown);
};
_this.show = function (clientX, clientY) {
if (_this.props.onContextMenuContentShow) _this.props.onContextMenuContentShow();
_this.setState({
hidden: false,
wndRegion: utils_1.windowQuadrant(clientX, clientY),
x: clientX,
y: clientY
});
};
_this.onKeyDown = function (e) {
if (e.which === 27 && !_this.state.hidden) {
// escape, close this
_this.hide();
}
};
_this.onMouseDown = function (e) {
if (!_this.mouseOverElement && !_this.state.hidden) {
_this.hide();
}
};
_this.onMouseEnter = function () {
_this.mouseOverElement = true;
};
_this.onMouseLeave = function () {
_this.mouseOverElement = false;
};
_this.onContextMenu = function (e) {
if (!_this.state.hidden) _this.hide();
_this.show(e.clientX, e.clientY);
window.addEventListener('keydown', _this.onKeyDown);
window.addEventListener('mousedown', _this.onMouseDown);
};
_this.computeStyle = function () {
switch (_this.state.wndRegion) {
case utils_1.Quadrant.TopLeft:
return {
position: 'fixed',
left: _this.state.x + _this.state.offsetLeft + "px",
top: _this.state.y + _this.state.offsetTop + "px"
};
case utils_1.Quadrant.TopRight:
return {
position: 'fixed',
right: window.window.innerWidth - _this.state.x + _this.state.offsetRight + "px",
top: _this.state.y + _this.state.offsetTop + "px"
};
case utils_1.Quadrant.BottomLeft:
return {
position: 'fixed',
left: _this.state.x + _this.state.offsetLeft + "px",
bottom: window.window.innerHeight - _this.state.y + _this.state.offsetBottom + "px"
};
case utils_1.Quadrant.BottomRight:
return {
position: 'fixed',
right: window.window.innerWidth - _this.state.x + _this.state.offsetRight + "px",
bottom: window.window.innerHeight - _this.state.y + _this.state.offsetBottom + "px"
};
}
};
_this.state = {
x: -99999,
y: -99999,
wndRegion: utils_1.Quadrant.TopLeft,
hidden: true,
offsetLeft: _this.props.offsetLeft || 10,
offsetTop: _this.props.offsetTop || 10,
offsetRight: _this.props.offsetRight || 5,
offsetBottom: _this.props.offsetBottom || 5
};
return _this;
}
ContextMenu.prototype.render = function () {
var ss = aphrodite_1.StyleSheet.create({
contextMenu: __assign({}, defaultStyles.contextMenu, this.props.style || {})
});
var contentProps = this.props.contentProps || {};
return React.createElement("div", { onContextMenu: this.onContextMenu, onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave, style: { display: 'inline-block' } }, this.props.children, this.state.hidden ? null : React.createElement("div", { className: aphrodite_1.css(ss.contextMenu), style: this.computeStyle() }, React.createElement(this.props.content, __assign({ close: this.hide }, contentProps))));
};
ContextMenu.prototype.shouldComponentUpdate = function (nextProps, nextState) {
return !_.isEqual(nextProps, this.props) || !_.isEqual(nextState, this.state);
};
ContextMenu.prototype.componentWillUnmount = function () {
// unreg window handlers
window.removeEventListener('keydown', this.onKeyDown);
window.removeEventListener('mousedown', this.onMouseDown);
};
return ContextMenu;
}(React.Component);
exports.ContextMenu = ContextMenu;
exports.default = ContextMenu;
},{"../utils":143,"aphrodite":159,"lodash":216,"react":237}],20:[function(require,module,exports){
"use strict";
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var __extends = undefined && undefined.__extends || function () {
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) {
if (b.hasOwnProperty(p)) d[p] = b[p];
}
};
return function (d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __assign = undefined && undefined.__assign || Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
/*
* Usage:
*
* Wrap any element with this component and you'll get a confirmation
* dialog popup when the element inside is clicked.
*
* <Dialog content={(props: any) => <div>Are you sure?</div>}
* cancelOnClickOutside={true} >
* <button>Click Me!</button>
* </Dialog>
*
*/
var React = require("react");
var aphrodite_1 = require("aphrodite");
exports.defaultDialogStyle = {
container: {
position: 'fixed',
top: '0',
bottom: '0',
left: '0',
right: '0',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
cursor: 'default',
backgroundColor: 'rgba(0, 0, 0, 0.4)',
zIndex: 99999
},
dialog: {
backgroundColor: '#444',
minWidth: '250px',
minHeight: '100px',
display: 'flex',
flexDirection: 'column'
},
contentWrapper: {
flex: '1 1 auto'
}
};
var Dialog = function (_super) {
__extends(Dialog, _super);
function Dialog(props) {
var _this = _super.call(this, props) || this;
_this.mouseOver = false;
_this.show = function () {
_this.setState({
hidden: false
});
_this.mouseOver = false;