Remove ConfigurationService
Replaced with direct access to both EngineService and SimulationService.
This commit is contained in:
parent
99ead8691b
commit
58971016da
7 changed files with 41 additions and 108 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:angular/angular.dart';
|
||||
import 'package:angular_components/material_button/material_button.dart';
|
||||
import 'package:angular_components/material_icon/material_icon.dart';
|
||||
|
|
@ -5,7 +7,8 @@ import 'package:angular_components/material_input/material_input.dart';
|
|||
import 'package:angular_components/material_input/material_number_accessor.dart';
|
||||
import 'package:angular_components/material_slider/material_slider.dart';
|
||||
import 'package:angular_components/material_tooltip/material_tooltip.dart';
|
||||
import 'package:rules_of_living/service/configuration_service.dart';
|
||||
import 'package:rules_of_living/service/engine_service.dart';
|
||||
import 'package:rules_of_living/service/simulation_service.dart';
|
||||
|
||||
@Component(
|
||||
selector: "configuration",
|
||||
|
|
@ -23,28 +26,29 @@ import 'package:rules_of_living/service/configuration_service.dart';
|
|||
NgModel
|
||||
])
|
||||
class ConfigurationComponent {
|
||||
final ConfigurationService config;
|
||||
final EngineService engine;
|
||||
final SimulationService sim;
|
||||
|
||||
int get width => config.gridSize.x;
|
||||
int get width => sim.gridSize.x;
|
||||
void set width(num value) {
|
||||
if (value == null || value <= 0) return;
|
||||
config.setGridSize(x: value.toInt());
|
||||
sim.gridSize = Point(value, sim.gridSize.y);
|
||||
}
|
||||
|
||||
int get height => config.gridSize.y;
|
||||
int get height => sim.gridSize.y;
|
||||
void set height(num value) {
|
||||
if (value == null || value <= 0) return;
|
||||
config.setGridSize(y: value.toInt());
|
||||
sim.gridSize = Point(sim.gridSize.x, value);
|
||||
}
|
||||
|
||||
int get simSpeed => config.simSpeed;
|
||||
void set simSpeed(int value) => config.simSpeed = value;
|
||||
int get simSpeed => engine.simSpeed;
|
||||
void set simSpeed(int value) => engine.simSpeed = value;
|
||||
|
||||
String get speedSliderTooltip => "Simulation Speed: $simSpeed";
|
||||
|
||||
ConfigurationComponent(this.config);
|
||||
ConfigurationComponent(this.engine, this.sim);
|
||||
|
||||
void onEdgesClicked() {
|
||||
config.toggleGrid();
|
||||
engine.toggleGrid();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class ControlsComponent {
|
|||
|
||||
void onRandomClicked() {
|
||||
sim.addRandomPattern();
|
||||
engine.stop();
|
||||
}
|
||||
|
||||
void onClearClicked() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'dart:html' as html;
|
||||
|
||||
import 'package:angular/angular.dart';
|
||||
import 'package:rules_of_living/service/configuration_service.dart';
|
||||
import 'package:rules_of_living/service/engine_service.dart';
|
||||
|
||||
@Component(
|
||||
selector: 'gol-simulation',
|
||||
|
|
@ -10,9 +10,9 @@ import 'package:rules_of_living/service/configuration_service.dart';
|
|||
providers: [],
|
||||
)
|
||||
class SimulationComponent implements OnInit {
|
||||
final ConfigurationService config;
|
||||
final EngineService engine;
|
||||
|
||||
SimulationComponent(this.config);
|
||||
SimulationComponent(this.engine);
|
||||
|
||||
@override
|
||||
void ngOnInit() {
|
||||
|
|
@ -29,6 +29,6 @@ class SimulationComponent implements OnInit {
|
|||
|
||||
the canvas did not load correctly :(
|
||||
''', canvas.width / 2 - 50, canvas.height / 2);
|
||||
config.canvas = canvas;
|
||||
engine.canvas = canvas;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue