forked from clarabstract/factorio-calc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.jsx
120 lines (104 loc) · 3.51 KB
/
options.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* global React,App*/
App.Options = class Options extends React.Component {
state = {
showOptions: false
}
showOptions = (ev) => {
ev.preventDefault();
this.setState({showOptions: true});
}
hideOptions = (ev) => {
ev.preventDefault();
this.setState({showOptions: false});
}
setOption = (ev) => {
var value = ev.target.value;
if (ev.target.name == "alwaysShowDecimals") {
value = ev.target.value == "true";
}
this.props.options[ev.target.name] = value;
this.props.onChangeOptions(this.props.options);
}
render() {
if (this.state.showOptions) {
var oldBeltOptions = [
<option key="3.8" value="3.8">Basic (slow corners)</option>,
<option key="5.7" value="5.7">Basic (straight)</option>,
<option key="6.3" value="6.3">Fast (slow corners)</option>,
<option key="9.4" value="9.4">Fast (straight)</option>,
<option key="8.3" value="8.3">Express (slow corners)</option>,
<option key="14.2" value="14.2">Express (straight)</option>
];
var newBeltOptions = [
<option key="6.66" value="6.66">Basic</option>,
<option key="13.33" value="13.33">Fast</option>,
<option key="20.00" value="20.00">Express</option>
];
var beltOptions;
if (window.CURRENT_LIB == "core-0-11-3" || window.CURRENT_LIB == "core-0-10-2" || window.CURRENT_LIB == "core-0-9-8") {
beltOptions = oldBeltOptions;
} else {
beltOptions = newBeltOptions;
}
return (
<div>
<a onClick={this.hideOptions} href="">
<span className="glyphicon glyphicon-collapse-down"></span>
Hide options
</a>
<div id="options">
<label>Assembler level:</label>
<select
value={this.props.options.asslvl}
name="asslvl"
onChange={this.setOption}>
<option value="0.5">1 (0.5 modifier)</option>
<option value="0.75">2 (0.75 modifier)</option>
<option value="1.25">3 (1.25 modifier)</option>
</select>
<label>Smelter level:</label>
<select
value={this.props.options.smeltlvl}
name="smeltlvl"
onChange={this.setOption}>
<option value="1">Stone</option>
<option value="2">Steel / Electric</option>
</select>
<label>Belt speed:</label>
<select
value={this.props.options.beltlvl}
name="beltlvl"
onChange={this.setOption}>
{beltOptions}
</select>
<label>Difficulty:</label>
<select
value={this.props.options.difficulty}
name="difficulty"
onChange={this.setOption}>
<option value="normal">Normal</option>
<option value="expensive">Expensive</option>
</select>
<label>Show Decimals:</label>
<select
value={this.props.options.alwaysShowDecimals + ""}
name="alwaysShowDecimals"
onChange={this.setOption}>
<option value="false">Automatic</option>
<option value="true">Always</option>
</select>
</div>
</div>
);
} else {
return (
<p>
<a onClick={this.showOptions} href="">
<span className="glyphicon glyphicon-expand"></span>
Show options
</a>
</p>
);
}
}
};