Skip to content

Commit

Permalink
Merge pull request #2218 from Thorium-Sim/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
alexanderson1993 authored May 25, 2019
2 parents faab947 + 5dfafad commit 397ef2c
Show file tree
Hide file tree
Showing 42 changed files with 1,375 additions and 90 deletions.
1 change: 1 addition & 0 deletions client/public/cardIcons/Interface.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 6 additions & 7 deletions client/src/components/client/simulatorData.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class SimulatorData extends Component {
const { simulators } = data;
if (loading || !simulators) return null;
if (!simulators[0]) return <div>No Simulator</div>;
console.log(simulators[0].stations);
const station = simulators[0].stations.find(s => s.name === name);
return (
<SubscriptionHelper
Expand All @@ -90,13 +91,11 @@ class SimulatorData extends Component {
})
}
>
{
<Client
{...this.props}
simulator={simulators[0]}
station={station || this.props.station}
/>
}
<Client
{...this.props}
simulator={simulators[0]}
station={station || this.props.station}
/>
</SubscriptionHelper>
);
}}
Expand Down
43 changes: 43 additions & 0 deletions client/src/components/core/menubar/DynamicPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,43 @@ class DynamicPicker extends Component {
if (value === "change") {
return this.setState({ modal: true });
}
if (value === "export") {
const href = `${window.location.protocol}//${
window.location.hostname
}:${parseInt(window.location.port, 10) + 1}/exportCoreLayout/${
this.state.layout
}`;
window.open(href);
return;
}
if (value === "import") {
this.fileRef.current.click();
return;
}
this.setState({ layout: value });
this.props.onChange(
JSON.parse(coreLayouts.find(l => l.id === value).config)
);
};
handleImport = evt => {
const data = new FormData();
Array.from(evt.target.files).forEach((f, index) =>
data.append(`files[${index}]`, f)
);
fetch(
`${window.location.protocol}//${window.location.hostname}:${parseInt(
window.location.port,
10
) + 1}/importCoreLayout`,
{
method: "POST",
body: data
}
).then(() => {
window.location.reload();
});
};
fileRef = React.createRef();
render() {
const { modal } = this.state;
const {
Expand All @@ -93,6 +125,13 @@ class DynamicPicker extends Component {
})
}
/>
<input
hidden
type="file"
ref={this.fileRef}
value=""
onChange={this.handleImport}
/>
<select
value={this.state.layout}
className="btn btn-warning btn-sm"
Expand All @@ -111,6 +150,10 @@ class DynamicPicker extends Component {
Delete Core Layout
</option>
<option value="change">Reorder Core Layouts</option>
<option value="export" disabled={this.state.layout === "nothing"}>
Export Core Layout
</option>
<option value="import">Import Core Layout</option>
</select>
{modal && (
<MosaicConfig
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/layouts/LayoutBlack/cardSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component, Fragment } from "react";
import { Tooltip } from "reactstrap";

const spregex = /.*.{8}-.{4}-.{4}-.{4}-.{12}/gi;
const intregex = /interface-.{8}-.{4}-.{4}-.{4}-.{12}/gi;
const intregex = /interface-id:.{8}-.{4}-.{4}-.{4}-.{12}/gi;
class CardButton extends Component {
state = {};
card = React.createRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CardSwitcher extends Component {
}
}

const intregex = /interface-.{8}-.{4}-.{4}-.{4}-.{12}/gi;
const intregex = /interface-id:.{8}-.{4}-.{4}-.{4}-.{12}/gi;
const spregex = /.*.{8}-.{4}-.{4}-.{4}-.{12}/gi;

const CardButton = props => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from "react";

const spregex = /.*.{8}-.{4}-.{4}-.{4}-.{12}/gi;
const intregex = /interface-.{8}-.{4}-.{4}-.{4}-.{12}/gi;
const intregex = /interface-id:.{8}-.{4}-.{4}-.{4}-.{12}/gi;
class CardSwitcher extends Component {
state = {};
render() {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/layouts/LayoutLine/cardSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component, Fragment } from "react";
import { Tooltip } from "reactstrap";

const spregex = /.*.{8}-.{4}-.{4}-.{4}-.{12}/gi;
const intregex = /interface-.{8}-.{4}-.{4}-.{4}-.{12}/gi;
const intregex = /interface-id:.{8}-.{4}-.{4}-.{4}-.{12}/gi;
class CardButton extends Component {
state = {};
card = React.createRef();
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/layouts/cardRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function renderCards(props) {
function getCompName(name) {
const cleanedName = name
.replace("software-panel-", "")
.replace("interface-", "");
.replace("interface-id:", "");
if (props.simulator.panels.includes(cleanedName)) {
return "SoftwarePanels";
}
Expand Down Expand Up @@ -60,7 +60,7 @@ export default function renderCards(props) {
return (
<CardHolder
component={Views.Interface}
interfaceId={card.component.replace("interface-", "")}
interfaceId={card.component.replace("interface-id:", "")}
{...props}
key={card.name}
/>
Expand Down
19 changes: 18 additions & 1 deletion client/src/components/views/DamageControl/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ class DamageControlCore extends Component {
});
//this.toggleDamage(e, s, true)
};
renderEngineSpeed = system => {
if (system.type !== "Engine") return null;
const engines = this.props.data.engines;
const engine = engines.find(e => e.id === system.id);
const speedIndex =
system.power.powerLevels.filter(p => p <= system.power.power).length - 1;
const maxSpeed = engine.speeds[speedIndex]
? engine.speeds[speedIndex].number
: 0;
return `(${maxSpeed})`;
};
damageOption = (e, option) => {
const { system } = this.state.context;
if (option === "destroy") {
Expand Down Expand Up @@ -287,7 +298,7 @@ class DamageControlCore extends Component {
onContextMenu={e => this.setContext(e, s)}
style={this.systemStyle(s)}
>
{this.systemName(s)}
{this.systemName(s)} {this.renderEngineSpeed(s)}
</td>
<td>
{(s.power.power || s.power.power === 0) && (
Expand Down Expand Up @@ -418,6 +429,12 @@ const SYSTEMS_QUERY = gql`
reactors(simulatorId: $simulatorId) {
...PowerData
}
engines(simulatorId: $simulatorId) {
id
speeds {
number
}
}
systems(simulatorId: $simulatorId) {
id
name
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/views/Interfaces/interfaces.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from "react";

import "./style.scss";
import * as comps from "./components";

function parseComponents({ components, config, values }) {
Expand All @@ -23,6 +23,7 @@ class Interfaces extends Component {
const components = parseComponents(iFace);
return (
<div
className="interface-card"
style={{
backgroundColor: "black",
width: deviceWidth,
Expand Down
5 changes: 5 additions & 0 deletions client/src/components/views/Interfaces/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.cardContainer .interface-card {
max-width: 100%;
max-height: 100%;
border: solid 1px rgba(255, 255, 255, 0.5);
}
35 changes: 18 additions & 17 deletions client/src/components/views/TractorBeam/core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Component } from "react";
import { Container } from "reactstrap";
import gql from "graphql-tag.macro";
import { graphql, withApollo } from "react-apollo";
import { InputField, OutputField } from "../../generic/core";
Expand Down Expand Up @@ -93,7 +92,7 @@ class TractorBeamCore extends Component {
const tractorBeam = this.props.data.tractorBeam[0];
if (!tractorBeam) return <p>No Tractor Beam</p>;
return (
<Container className="tractor-beam-core">
<div className="tractor-beam-core">
<SubscriptionHelper
subscribe={() =>
this.props.data.subscribeToMore({
Expand Down Expand Up @@ -133,21 +132,23 @@ class TractorBeamCore extends Component {
{tractorBeam.targetLabel}
</InputField>
</div>
<label>Strength: {Math.round(tractorBeam.strength * 100)}</label>
<label>
Stress: {Math.round(tractorBeam.stress * 100)}{" "}
<input
style={{ width: "50%", float: "right" }}
onChange={this.setStress}
onMouseUp={this.updateStress}
defaultValue={tractorBeam.stress}
type="range"
min="0"
max="1"
step="0.01"
/>
</label>
</Container>
<div>
<label>Strength: {Math.round(tractorBeam.strength * 100)}</label>
<label>
Stress: {Math.round(tractorBeam.stress * 100)}{" "}
<input
style={{ width: "50%", float: "right" }}
onChange={this.setStress}
onMouseUp={this.updateStress}
defaultValue={tractorBeam.stress}
type="range"
min="0"
max="1"
step="0.01"
/>
</label>
</div>
</div>
);
}
}
Expand Down
5 changes: 2 additions & 3 deletions client/src/components/views/TractorBeam/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@
}
.tractor-beam-core {
label {
display: block;
float: left;
width: 100%;
width: 90%;
margin-right: 20px;
}
}

Expand Down
Loading

0 comments on commit 397ef2c

Please sign in to comment.