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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue