Skip to content

Commit

Permalink
Merge pull request #2551 from Thorium-Sim/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
alexanderson1993 authored Oct 1, 2019
2 parents 8164f9b + 227e1a6 commit f4a8aaf
Show file tree
Hide file tree
Showing 36 changed files with 1,248 additions and 186 deletions.
76 changes: 17 additions & 59 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions client/public/cardIcons/Records.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 28 additions & 65 deletions client/src/components/macros/addTask.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import React, { Fragment, Component } from "react";
import { Query } from "react-apollo";
import {
Badge,
ListGroup,
ListGroupItem,
Input,
Button
} from "helpers/reactstrap";
import { Badge, ListGroup, ListGroupItem, Input } from "helpers/reactstrap";
import gql from "graphql-tag.macro";
import uuid from "uuid";
import ValueInput from "../views/Tasks/core/ValueInput";
import FontAwesome from "react-fontawesome";
import EventName from "containers/FlightDirector/MissionConfig/EventName";
import EventPicker from "containers/FlightDirector/MissionConfig/EventPicker";
import ConfigureMacro from "../views/Tasks/core/ConfigureMacro";

import { ConfigureMacro as ConfigMacro } from "containers/FlightDirector/TaskTemplates/taskConfig.js";
/*
input TaskInput {
simulatorId: ID
Expand Down Expand Up @@ -48,6 +38,12 @@ const QUERY = gql`
event
delay
}
preMacros {
id
args
event
delay
}
}
}
`;
Expand All @@ -74,7 +70,8 @@ class TasksCore extends Component {
const {
definition: selectedDefinition,
values: requiredValues = {},
macros = []
macros = [],
preMacros = []
} = taskInput;
const { configureMacroId } = this.state;
const definitionGroups = taskDefinitions
Expand Down Expand Up @@ -179,7 +176,8 @@ class TasksCore extends Component {
);
this.updateTask({
values: template.values,
macros: template.macros
macros: template.macros,
preMacros: template.preMacros
});
this.setState({ forcedKey: Math.random() });
}}
Expand Down Expand Up @@ -274,58 +272,23 @@ class TasksCore extends Component {
)}
<hr />
<div>
<label>
Macros{" "}
<small>Will be triggered when task is complete</small>
</label>
<EventPicker
className={"btn btn-sm btn-success"}
handleChange={e => {
const { value: event } = e.target;
this.updateTask({
macros: macros
.map(({ __typename, ...rest }) => rest)
.concat({
event,
args: "{}",
delay: 0,
id: uuid.v4()
})
});
}}
<ConfigMacro
action={({ variables: { macros } }) =>
this.updateTask({ macros })
}
id={"id"}
macros={macros}
client={client}
/>
<ConfigMacro
pre
action={({ variables: { macros } }) =>
this.updateTask({ preMacros: macros })
}
id={"id"}
macros={preMacros}
client={client}
/>
{macros.map(m => (
<div
key={m.id}
style={{
display: "flex",
alignItems: "center",
justifyContent: "space-between"
}}
>
<span>
<EventName id={m.event} label={m.event} />
</span>{" "}
<Button
size="sm"
color="warning"
onClick={() =>
this.setState({ configureMacroId: m.id })
}
>
Configure Macro
</Button>{" "}
<FontAwesome
name="ban"
className="text-danger"
onClick={() =>
this.updateTask({
macros: macros.filter(mm => mm.id !== m.id)
})
}
/>
</div>
))}
</div>
</Fragment>
)}
Expand Down
13 changes: 12 additions & 1 deletion client/src/components/views/CrmFighter/joystick.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ import { withApollo } from "react-apollo";
function useDraggable(callback, upCallback = () => {}) {
function mouseup() {
document.removeEventListener("mouseup", mouseup);
document.removeEventListener("touchend", mouseup);
document.removeEventListener("mousemove", callback);
document.removeEventListener("touchmove", callback);
upCallback();
}
function mousedown() {
document.addEventListener("mouseup", mouseup);
document.addEventListener("touchend", mouseup);
document.addEventListener("mousemove", callback);
document.addEventListener("touchmove", callback);
}
useEffect(() => {
return () => {
document.removeEventListener("mouseup", mouseup);
document.removeEventListener("touchend", mouseup);
document.removeEventListener("mousemove", callback);
document.removeEventListener("touchmove", callback);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down Expand Up @@ -52,7 +58,11 @@ const Joystick = ({ client, id, clientId }) => {
const mousedown = useDraggable(
e => {
if (!parentRef.current) return;
const { clientX, clientY } = e;
const {
touches: [{ clientX: touchClientX, clientY: touchClientY }] = [{}],
clientX = touchClientX,
clientY = touchClientY
} = e;
const {
left,
top,
Expand Down Expand Up @@ -97,6 +107,7 @@ const Joystick = ({ client, id, clientId }) => {
className={`joystick-handle ${returning ? "returning" : ""}`}
onTransitionEnd={() => setReturning(false)}
onMouseDown={mousedown}
onTouchStart={mousedown}
style={{
transform: `translate(${position.x}px, ${position.y}px)`
}}
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/views/CrmFighter/phaserCharging.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ function useMouseHold(callback, mouseupCallback = () => {}) {
function mouseup(e) {
activeRef.current = false;
document.removeEventListener("mouseup", mouseup);
document.removeEventListener("touchend", mouseup);
mouseupCallback();
}

function mousedown(e) {
activeRef.current = true;
document.addEventListener("mouseup", mouseup);
document.addEventListener("touchend", mouseup);
}
useAnimationFrame(delta => {
callback(delta);
Expand Down Expand Up @@ -63,7 +65,7 @@ const PhaserCharging = ({ id, clientId, client, phaserLevel = 0 }) => {
/>
</div>

<Button color="warning" onMouseDown={mousedown}>
<Button color="warning" onMouseDown={mousedown} onTouchStart={mousedown}>
Charge
</Button>
</div>
Expand Down
1 change: 1 addition & 0 deletions client/src/components/views/DamageControl/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
}
}
.damageReport-text {
user-select: text;
white-space: pre-line;
font-family: monospace;
font-size: 18px;
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/views/Messaging/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
height: 100%;
flex: 1 1 auto;
padding: 1.25rem;
* {
user-select: text;
}
}
.list-group-item {
&.selected {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/views/OfficerLog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Printable from "helpers/printable";

import "./style.scss";

const stardate = date => {
export const stardate = date => {
var calculatedDate = new Date(date).getTime() / 1000 / 60 / 60 / 30 / 2;
var subtraction = Math.floor(calculatedDate);
var finalDate = (calculatedDate - subtraction) * 100000;
Expand Down
Loading

0 comments on commit f4a8aaf

Please sign in to comment.