From b1221c7c84f8aa5df4fc7a620f0fcb7215575969 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 27 Aug 2018 23:03:35 +0200 Subject: [PATCH] Add Grid Size Input to Configuration Bar Fixes #37 --- lib/components/configuration_component.dart | 25 ++++++++++++++++++--- lib/components/configuration_component.html | 20 +++++++++++++++-- lib/service/configuration_service.dart | 2 ++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/lib/components/configuration_component.dart b/lib/components/configuration_component.dart index bd3ae0c..cc1ecd1 100644 --- a/lib/components/configuration_component.dart +++ b/lib/components/configuration_component.dart @@ -1,6 +1,8 @@ import 'package:angular/angular.dart'; import 'package:angular_components/material_button/material_button.dart'; import 'package:angular_components/material_icon/material_icon.dart'; +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'; @@ -8,18 +10,35 @@ import 'package:rules_of_living/service/configuration_service.dart'; @Component( selector: "configuration", templateUrl: "configuration_component.html", - styleUrls: ["configuration_component.css"], + styleUrls: [ + "configuration_component.css" + ], directives: [ MaterialButtonComponent, MaterialIconComponent, MaterialSliderComponent, - MaterialTooltipDirective + MaterialTooltipDirective, + materialInputDirectives, + materialNumberInputDirectives, + NgModel ]) class ConfigurationComponent { final ConfigurationService config; + 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()); + } + int get simSpeed => config.simSpeed; - int set simSpeed(int value) => config.simSpeed = value; + void set simSpeed(int value) => config.simSpeed = value; String get speedSliderTooltip => "Simulation Speed: $simSpeed"; diff --git a/lib/components/configuration_component.html b/lib/components/configuration_component.html index a17261d..d8a3e8b 100644 --- a/lib/components/configuration_component.html +++ b/lib/components/configuration_component.html @@ -1,5 +1,21 @@
- - + + + + Ruleset: + + +
\ No newline at end of file diff --git a/lib/service/configuration_service.dart b/lib/service/configuration_service.dart index 880cf45..e11a5e8 100644 --- a/lib/service/configuration_service.dart +++ b/lib/service/configuration_service.dart @@ -38,4 +38,6 @@ class ConfigurationService { y = y ?? _es.engine.gridSize.y; _es.engine.gridSize = Point(x, y); } + + Point get gridSize => _es.engine.gridSize; }