Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: samples/dartcombat/views.dart

Issue 12473003: Remove deprecated StringBuffer.add, addAll and addCharCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dartcombatlib; 5 part of dartcombatlib;
6 6
7 /** Base class for all views. */ 7 /** Base class for all views. */
8 class View { 8 class View {
9 Document doc; 9 Document doc;
10 View(this.doc) {} 10 View(this.doc) {}
(...skipping 11 matching lines...) Expand all
22 PlayerState this.state, Element rootNode) 22 PlayerState this.state, Element rootNode)
23 : super(rootNode.document), _rootNode = rootNode { 23 : super(rootNode.document), _rootNode = rootNode {
24 render(); 24 render();
25 } 25 }
26 26
27 /** Create an initial visual representation of this view. */ 27 /** Create an initial visual representation of this view. */
28 void render() { 28 void render() {
29 String cell = "<div class='icons water'></div>"; 29 String cell = "<div class='icons water'></div>";
30 StringBuffer _cells = new StringBuffer(); 30 StringBuffer _cells = new StringBuffer();
31 for (int i = 0 ; i < state.localGrid.cells.length; i++) { 31 for (int i = 0 ; i < state.localGrid.cells.length; i++) {
32 _cells.add(cell); 32 _cells.write(cell);
33 } 33 }
34 String cells = _cells.toString(); 34 String cells = _cells.toString();
35 String row = "<div class='hbox'>${cells}</div>"; 35 String row = "<div class='hbox'>${cells}</div>";
36 StringBuffer _rows = new StringBuffer(); 36 StringBuffer _rows = new StringBuffer();
37 for (int i = 0 ; i < state.localGrid.cells.length; i++) { 37 for (int i = 0 ; i < state.localGrid.cells.length; i++) {
38 _rows.add(row); 38 _rows.write(row);
39 } 39 }
40 String rows = _rows.toString(); 40 String rows = _rows.toString();
41 String table = "<div class='vbox'>${rows}</div>"; 41 String table = "<div class='vbox'>${rows}</div>";
42 _rootNode.innerHtml = table; 42 _rootNode.innerHtml = table;
43 43
44 // Attaches listeners onto this view. 44 // Attaches listeners onto this view.
45 new PlaceBoatView(state, _rootNode).attach(); 45 new PlaceBoatView(state, _rootNode).attach();
46 } 46 }
47 47
48 /** Adds to this view the respresentation of a missed shot. */ 48 /** Adds to this view the respresentation of a missed shot. */
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 EnemyGridView( 172 EnemyGridView(
173 PlayerState this.state, Element rootNode) 173 PlayerState this.state, Element rootNode)
174 : super(rootNode.document), 174 : super(rootNode.document),
175 _enemyReady = false, 175 _enemyReady = false,
176 _rootNode = rootNode { 176 _rootNode = rootNode {
177 177
178 String cell = "<div class='icons water'></div>"; 178 String cell = "<div class='icons water'></div>";
179 StringBuffer _cells = new StringBuffer(); 179 StringBuffer _cells = new StringBuffer();
180 for (int i = 0 ; i < state.enemyGrid.cells.length; i++) { 180 for (int i = 0 ; i < state.enemyGrid.cells.length; i++) {
181 _cells.add(cell); 181 _cells.write(cell);
182 } 182 }
183 String cells = _cells.toString(); 183 String cells = _cells.toString();
184 String row = "<div class='hbox'>${cells}</div>"; 184 String row = "<div class='hbox'>${cells}</div>";
185 StringBuffer _rows = new StringBuffer(); 185 StringBuffer _rows = new StringBuffer();
186 for (int i = 0 ; i < state.enemyGrid.cells.length; i++) { 186 for (int i = 0 ; i < state.enemyGrid.cells.length; i++) {
187 _rows.add(row); 187 _rows.write(row);
188 } 188 }
189 String rows = _rows.toString(); 189 String rows = _rows.toString();
190 String table = "<div class='vbox'>${rows}</div>"; 190 String table = "<div class='vbox'>${rows}</div>";
191 _rootNode.innerHtml = 191 _rootNode.innerHtml =
192 "${table}<div class='notready'>ENEMY IS NOT READY</div>"; 192 "${table}<div class='notready'>ENEMY IS NOT READY</div>";
193 statusBar = new ShootingStatusView(state, doc); 193 statusBar = new ShootingStatusView(state, doc);
194 _rootNode.nodes.add(statusBar._rootNode); 194 _rootNode.nodes.add(statusBar._rootNode);
195 _rootNode.onClick.listen((MouseEvent e) { 195 _rootNode.onClick.listen((MouseEvent e) {
196 handleClick(mouseEvent); 196 handleClick(mouseEvent);
197 }, false); 197 }, false);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 node.style.setProperty("left", "${xoffset}px"); 295 node.style.setProperty("left", "${xoffset}px");
296 } 296 }
297 297
298 /** Create a div node with a given class name. */ 298 /** Create a div node with a given class name. */
299 static Element createDiv(String className) { 299 static Element createDiv(String className) {
300 Element node = new Element.tag("div"); 300 Element node = new Element.tag("div");
301 node.attributes["class"] = className; 301 node.attributes["class"] = className;
302 return node; 302 return node;
303 } 303 }
304 } 304 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698