2018-08-22 18:16:31 +00:00
|
|
|
import 'package:angular/angular.dart';
|
|
|
|
import 'package:angular_components/angular_components.dart';
|
2018-10-18 09:58:38 +00:00
|
|
|
import 'package:rules_of_living/service/engine_service.dart';
|
2018-10-18 10:05:02 +00:00
|
|
|
import 'package:rules_of_living/service/simulation_service.dart';
|
2018-08-22 18:16:31 +00:00
|
|
|
|
|
|
|
@Component(
|
|
|
|
selector: 'sim-controls',
|
|
|
|
templateUrl: "controls_component.html",
|
2018-08-23 10:38:34 +00:00
|
|
|
directives: [
|
|
|
|
coreDirectives,
|
|
|
|
MaterialButtonComponent,
|
|
|
|
MaterialIconComponent,
|
|
|
|
MaterialTooltipDirective
|
|
|
|
],
|
2018-08-22 18:16:31 +00:00
|
|
|
providers: [],
|
|
|
|
styleUrls: const ["controls_component.css"],
|
|
|
|
)
|
|
|
|
class ControlsComponent {
|
2018-10-18 09:59:36 +00:00
|
|
|
final EngineService engine;
|
2018-10-18 10:05:02 +00:00
|
|
|
final SimulationService sim;
|
2018-08-23 07:33:15 +00:00
|
|
|
|
2018-10-18 10:05:02 +00:00
|
|
|
ControlsComponent(this.engine, this.sim);
|
2018-08-22 18:16:31 +00:00
|
|
|
|
|
|
|
void onStartClicked() {
|
2018-10-18 09:59:36 +00:00
|
|
|
engine.toggleRunning();
|
2018-08-22 18:16:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void onStepClicked() {
|
2018-10-18 09:59:36 +00:00
|
|
|
engine.step();
|
2018-08-22 18:16:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void onResetClicked() {
|
2018-10-18 10:05:02 +00:00
|
|
|
sim.reset();
|
2018-08-22 18:16:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void onRandomClicked() {
|
2018-10-18 10:05:02 +00:00
|
|
|
sim.addRandomPattern();
|
2018-10-18 10:51:35 +00:00
|
|
|
engine.stop();
|
2018-08-22 18:16:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void onClearClicked() {
|
2018-10-19 18:01:52 +00:00
|
|
|
sim.reset();
|
2018-08-22 18:16:31 +00:00
|
|
|
}
|
|
|
|
}
|