2018-08-23 12:12:22 +00:00
|
|
|
import 'package:angular/angular.dart';
|
|
|
|
import 'package:angular_components/material_button/material_button.dart';
|
|
|
|
import 'package:angular_components/material_icon/material_icon.dart';
|
2018-08-27 21:03:35 +00:00
|
|
|
import 'package:angular_components/material_input/material_input.dart';
|
|
|
|
import 'package:angular_components/material_input/material_number_accessor.dart';
|
2018-08-23 12:12:22 +00:00
|
|
|
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';
|
|
|
|
|
|
|
|
@Component(
|
|
|
|
selector: "configuration",
|
|
|
|
templateUrl: "configuration_component.html",
|
2018-08-27 21:03:35 +00:00
|
|
|
styleUrls: [
|
|
|
|
"configuration_component.css"
|
|
|
|
],
|
2018-08-23 12:12:22 +00:00
|
|
|
directives: [
|
|
|
|
MaterialButtonComponent,
|
|
|
|
MaterialIconComponent,
|
|
|
|
MaterialSliderComponent,
|
2018-08-27 21:03:35 +00:00
|
|
|
MaterialTooltipDirective,
|
|
|
|
materialInputDirectives,
|
|
|
|
materialNumberInputDirectives,
|
|
|
|
NgModel
|
2018-08-23 12:12:22 +00:00
|
|
|
])
|
|
|
|
class ConfigurationComponent {
|
|
|
|
final ConfigurationService config;
|
|
|
|
|
2018-08-27 21:03:35 +00:00
|
|
|
int get width => config.gridSize.x;
|
|
|
|
void set width(num value) {
|
|
|
|
if (value == null || value <= 0) return;
|
|
|
|
config.setGridSize(x: value.toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
int get height => config.gridSize.y;
|
|
|
|
void set height(num value) {
|
|
|
|
if (value == null || value <= 0) return;
|
|
|
|
config.setGridSize(y: value.toInt());
|
|
|
|
}
|
|
|
|
|
2018-08-23 12:12:22 +00:00
|
|
|
int get simSpeed => config.simSpeed;
|
2018-08-27 21:03:35 +00:00
|
|
|
void set simSpeed(int value) => config.simSpeed = value;
|
2018-08-23 12:12:22 +00:00
|
|
|
|
|
|
|
String get speedSliderTooltip => "Simulation Speed: $simSpeed";
|
|
|
|
|
|
|
|
ConfigurationComponent(this.config);
|
|
|
|
|
|
|
|
void onEdgesClicked() {
|
|
|
|
config.toggleGrid();
|
|
|
|
}
|
|
|
|
}
|