croupier: Remove old files/imports/comments
These are remnants of earlier experiments with Sky.
Change-Id: I6ab1ef84dc35c9d23806e748391a586423eb7e9f
diff --git a/lib/card.dart b/lib/card.dart
deleted file mode 100644
index 48d815e..0000000
--- a/lib/card.dart
+++ /dev/null
@@ -1,113 +0,0 @@
-library card;
-
-import 'package:sky/widgets/basic.dart';
-import 'dart:sky' as sky;
-import 'package:vector_math/vector_math.dart' as vector_math;
-
-import 'my_button.dart';
-
-class Card {
- String deck;
- String identifier;
-
- Card(this.deck, this.identifier);
- Card.fromString(String data) {
- List<String> parts = data.split(" ");
- assert(parts.length == 2);
- this
- ..deck = parts[0]
- ..identifier = parts[1];
- }
-
- toString() => "${deck} ${identifier}";
-
- get string => toString();
-}
-
-class CardComponent extends StatefulComponent {
- // Stateful components
- double dx;
- double dy;
- bool faceUp;
- bool scrolling;
-
- final Card card;
- final Function pointerUpCb;
-
- static Widget imageFromCard(Card c, bool faceUp) {
- String imageName = "${c.deck}/${faceUp ? 'up' : 'down'}/${c.identifier}.png";
- return new NetworkImage(src: imageName);
- }
-
- CardComponent(this.card, bool faceUp, [this.pointerUpCb = null]) {
- this.faceUp = faceUp;
- dx = 0.0;
- dy = 0.0;
- scrolling = false;
- }
-
- void syncFields(CardComponent other) {
- this.dx = other.dx;
- this.dy = other.dy;
- this.faceUp = other.faceUp;
- }
-
- void _onPressed(sky.Event e) {
- setState(() {
- this.faceUp = !this.faceUp;
- });
- }
-
- void _onPointerDown(sky.Event e) {
- setState(() {
- scrolling = true;
- });
- }
-
- void _onPointerMove(sky.Event e) {
- sky.PointerEvent ge = e as sky.PointerEvent;
- setState(() {
- dx += ge.dx;
- dy += ge.dy;
- });
- }
-
- void _onPointerUp(sky.Event e) {
- //sky.PointerEvent pe = e as sky.PointerEvent;
- setState(() {
- if (this.pointerUpCb != null) {
- pointerUpCb(this.dx, this.dy, this.faceUp);
- }
- this.dx = 0.0;
- this.dy = 0.0;
- this.faceUp = true;
- scrolling = false;
- });
- }
-
- Widget build() {
- return new Container(
- child: /*new Container(
- child: */new MyButton(
- child: imageFromCard(this.card, faceUp),
- onPressed: _onPressed,
- onPointerDown: _onPointerDown,
- onPointerMove: _onPointerMove,
- onPointerUp: _onPointerUp
- ),
- padding: const EdgeDims.all(8.0),
- //margin: const EdgeDims.symmetric(horizontal: 8.0),
- decoration: new BoxDecoration(
- backgroundColor: (this.scrolling ? const Color(0xFFFF0000) : const Color(0xFF0000FF)),
- borderRadius: 5.0
- ),
- transform: new vector_math.Matrix4.identity().translate(dx, dy)
- );
- }
-}
-
-// I think we should be free to move cards around the screen as we please.
-// However, that doesn't mean we can tap them willy nilly or let go of them so easily.
-// I propose that.
-// Card follows you onScroll.
-// But onPressed and on
\ No newline at end of file
diff --git a/lib/components/board.dart b/lib/components/board.dart
index 22baa95..8a5aaeb 100644
--- a/lib/components/board.dart
+++ b/lib/components/board.dart
@@ -1,8 +1,10 @@
import './card.dart' show Card;
import '../logic/card.dart' as logic_card;
+
+import 'dart:math' as math;
+
import 'package:sky/widgets.dart' as widgets;
import 'package:vector_math/vector_math.dart' as vector_math;
-import 'dart:math' as math;
import 'package:sky/theme/colors.dart' as colors;
const double cardHeight = 96.0;
diff --git a/lib/components/card.dart b/lib/components/card.dart
index f482ca9..9554583 100644
--- a/lib/components/card.dart
+++ b/lib/components/card.dart
@@ -14,6 +14,9 @@
}
static widgets.Widget imageFromCard(logic_card.Card c, bool faceUp) {
+ // TODO(alexfandrianto): If we allow an optional prefix in front of this,
+ // we would be able to have multiple skins of the same deck.
+ // TODO(alexfandrianto): Better card organization?
String imageName = "${c.deck}/${faceUp ? 'up' : 'down'}/${c.identifier}.png";
return new widgets.NetworkImage(src: imageName);
}
diff --git a/lib/components/card_collection.dart b/lib/components/card_collection.dart
index 27d0bcc..0058cce 100644
--- a/lib/components/card_collection.dart
+++ b/lib/components/card_collection.dart
@@ -20,8 +20,6 @@
CardCollectionComponent(this.cards, this.faceUp, this.orientation, this.parentCallback);
void syncConstructorArguments(CardCollectionComponent other) {
- //assert(false); // Why do we need to do this?
- //status = other.status;
cards = other.cards;
orientation = other.orientation;
faceUp = other.faceUp;
@@ -59,42 +57,15 @@
}
Widget build() {
- // Let's just do horizontal for now, it's too complicated otherwise.
-
- /*double cardDelta = card_constants.CARD_WIDTH;
- if (cards.length > 6) {
- //cardDelta = card_constants.CARD_WIDTH / cards.length; // just make it tiny
- cardDelta -= card_constants.CARD_WIDTH * (cards.length - 6) / cards.length;
- }*/
-
List<Widget> cardComponents = new List<Widget>();
cardComponents.add(new Text(status));
for (int i = 0; i < cards.length; i++) {
- // Positioned seems correct, but it causes an error when rendering. Constraints aren't matched?
- /*cardComponents.add(new Positioned(
- top: 0.0,
- // left: i * cardDelta,
- child: new Draggable<Card>(Card(cards[i], faceUp))
- ));*/
- /*cardComponents.add(new Transform(
- transform: new vector_math.Matrix4.identity().translate(i * cardDelta, 40.0),
- child: new CardComponent(cards[i], faceUp)
- ));*/
cardComponents.add(new Draggable<Card>(new Card(cards[i], faceUp))); // flex
}
-
- // Just draw a stack of cards...
- //return new Stack(cardComponents);
-
-
- /*List<Widget> cardComponents = new List<Widget>();
- for (int i = 0; i < cards.length; i++) {
- cardComponents.add(new Draggable<Card>(new Card(cards[i], faceUp)));
- }
- return new Flex(cardComponents);*/
-
// Let's draw a stack of cards with DragTargets.
+ // TODO(alexfandrianto): In many cases, card collections shouldn't have draggable cards.
+ // Additionally, it may be worthwhile to restrict it to 1 at a time.
return new DragTarget<Card>(
onAccept: _handleAccept,
builder: (List<Card> data, _) {
@@ -110,7 +81,7 @@
),
height: 80.0,
margin: new EdgeDims.all(10.0),
- child: wrapCards(cardComponents)//new Stack(cardComponents)
+ child: wrapCards(cardComponents)
);
}
);
diff --git a/lib/components/card_constants.dart b/lib/components/card_constants.dart
deleted file mode 100644
index 380718c..0000000
--- a/lib/components/card_constants.dart
+++ /dev/null
@@ -1,2 +0,0 @@
-const double CARD_HEIGHT = 120.0;
-const double CARD_WIDTH = 90.0;
\ No newline at end of file
diff --git a/lib/components/croupier.dart b/lib/components/croupier.dart
index b06ae24..7313003 100644
--- a/lib/components/croupier.dart
+++ b/lib/components/croupier.dart
@@ -1,8 +1,10 @@
import '../logic/croupier.dart' as logic_croupier;
import '../logic/game.dart' as logic_game;
+import 'game.dart' show GameComponent;
+
import 'package:sky/widgets.dart' show FlatButton;
import 'package:sky/widgets/basic.dart';
-import 'game.dart' show GameComponent;
+
import 'dart:sky' as sky;
class CroupierComponent extends StatefulComponent {
diff --git a/lib/components/draggable.dart b/lib/components/draggable.dart
index 4415645..ad4cbec 100644
--- a/lib/components/draggable.dart
+++ b/lib/components/draggable.dart
@@ -1,5 +1,6 @@
-import 'package:sky/widgets.dart' as widgets;
import 'dart:sky' as sky;
+
+import 'package:sky/widgets.dart' as widgets;
import 'package:vector_math/vector_math.dart' as vector_math;
class Draggable<T extends widgets.Widget> extends widgets.StatefulComponent {
diff --git a/lib/components/game.dart b/lib/components/game.dart
index dc0daf2..5eb4c5b 100644
--- a/lib/components/game.dart
+++ b/lib/components/game.dart
@@ -1,10 +1,12 @@
import '../logic/card.dart' show Card;
import '../logic/game.dart' show Game, GameType, Viewer, HeartsGame, HeartsPhase;
+import 'board.dart' show Board;
import 'card_collection.dart' show CardCollectionComponent, Orientation;
+
import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets.dart' show FlatButton;
import 'package:sky/theme/colors.dart' as colors;
-import 'board.dart' show Board;
+
class GameComponent extends StatefulComponent {
Game game;
@@ -29,6 +31,7 @@
return buildHearts();
case GameType.Board:
// Does NOT work in checked mode since it has a Stack of Positioned Stack with Positioned Widgets.
+ // Issue and possible workaround? https://github.com/domokit/sky_engine/issues/732
return new Board(1, [2,3,4], [1, 2, 3, 4]);
default:
return null; // unsupported
@@ -55,49 +58,19 @@
Widget buildProto() {
List<Widget> cardCollections = new List<Widget>();
- // debugString
cardCollections.add(new Text(game.debugString));
for (int i = 0; i < 4; i++) {
List<Card> cards = game.cardCollections[i];
CardCollectionComponent c = new CardCollectionComponent(cards, game.playerNumber == i, Orientation.horz, _updateGameCallback);
-
- /*cardCollections.add(new Positioned(
- top: i * (card_constants.CARD_HEIGHT + 20.0),
- child: c
- ));*/
-
- /*cardCollections.add(new Transform(
- transform: new vector_math.Matrix4.identity().translate(0.0, i * (card_constants.CARD_HEIGHT + 20.0)),
- child: c
- ));*/
-
cardCollections.add(c); // flex
}
- // game.cardCollections[4] is a discard pile
- /*cardCollections.add(new Transform(
- transform: new vector_math.Matrix4.identity().translate(0.0, 4 * (card_constants.CARD_HEIGHT + 20.0)),
- child: new Container(
- decoration: new BoxDecoration(backgroundColor: colors.Green[500], borderRadius: 5.0),
- child: new CardCollectionComponent(game.cardCollections[4], true, Orientation.horz, _parentHandleAccept)
- )
- ));*/
- /*cardCollections.add(new Positioned(
- top: 4 * (card_constants.CARD_HEIGHT + 20.0),
- child: new Container(
- decoration: new BoxDecoration(backgroundColor: colors.Green[500], borderRadius: 5.0),
- child: new CardCollectionComponent(game.cardCollections[4], true, Orientation.horz)
- )
- ));*/
-
cardCollections.add(new Container(
decoration: new BoxDecoration(backgroundColor: colors.Green[500], borderRadius: 5.0),
child: new CardCollectionComponent(game.cardCollections[4], true, Orientation.show1, _updateGameCallback)
));
- // game.cardCollections[5] is just not shown
-
cardCollections.add(new FlatButton(
child: new Text('Switch View'),
onPressed: _switchPlayersCallback
@@ -105,7 +78,7 @@
return new Container(
decoration: new BoxDecoration(backgroundColor: colors.Pink[500]),
- child: new Flex(cardCollections, direction: FlexDirection.vertical)//new Stack(cardCollections)
+ child: new Flex(cardCollections, direction: FlexDirection.vertical)
);
}
@@ -137,7 +110,7 @@
case HeartsPhase.Score:
return showBoard();
default:
- assert(false); // What?
+ assert(false);
return null;
}
}
diff --git a/lib/main.dart b/lib/main.dart
index 173d822..718f454 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,21 +1,8 @@
-//import 'package:sky/widgets/basic.dart';
-
-//import 'card.dart' as card;
-//import 'my_button.dart';
-//import 'dart:sky' as sky;
-//import 'package:vector_math/vector_math.dart' as vector_math;
-//import 'package:sky/theme/colors.dart' as colors;
import 'package:sky/widgets.dart';
-//import 'logic/game.dart' show Game, HeartsCommand;
-//import 'components/game.dart' show GameComponent;
import 'logic/croupier.dart' show Croupier;
import 'components/croupier.dart' show CroupierComponent;
-//import 'dart:io';
-//import 'dart:convert';
-//import 'dart:async';
-
class CroupierApp extends App {
Croupier croupier;
@@ -26,7 +13,7 @@
Widget build() {
return new Container(
decoration: new BoxDecoration(
- backgroundColor: const Color(0xFF0000FF),
+ backgroundColor: const Color(0xFF6666FF),
borderRadius: 5.0
),
child: new CroupierComponent(this.croupier)
@@ -35,32 +22,5 @@
}
void main() {
- print('started');
- CroupierApp app = new CroupierApp();
-
- // Had difficulty reading from a file, so I can use this to simulate it.
- // Seems like only NetworkImage exists, but why not also have NetworkFile?
- /*List<String> commands = <String>[
- "Deal:0:classic h1:classic h2:classic h3:classic h4:END",
- "Deal:1:classic d1:classic d2:classic d3:classic d4:END",
- "Deal:2:classic s1:classic s2:classic s3:classic s4:END",
- "Deal:3:classic c1:classic c2:classic c3:classic c4:END",
- "Pass:0:1:classic h2:classic h3:END",
- "Pass:1:2:classic d1:classic d4:END",
- "Play:0:classic h1:END",
- "Play:1:classic d3:END",
- "Play:2:classic d4:END",
- "Play:3:classic c2:END"
- ];
- new Future.delayed(new Duration(seconds: 2)).then((_) {
- for (var i = 0; i < commands.length; i++) {
- new Future.delayed(new Duration(seconds: 1*i)).then((_) {
- app.game.gamelog.add(new HeartsCommand(commands[i]));
- });
- }
- });*/
-
-
- runApp(app);
- print('running');
+ runApp(new CroupierApp());
}
\ No newline at end of file
diff --git a/lib/menu.png b/lib/menu.png
deleted file mode 100644
index 38ee213..0000000
--- a/lib/menu.png
+++ /dev/null
Binary files differ
diff --git a/lib/my_button.dart b/lib/my_button.dart
deleted file mode 100644
index c04bf97..0000000
--- a/lib/my_button.dart
+++ /dev/null
@@ -1,63 +0,0 @@
-import 'package:sky/widgets/basic.dart';
-
-final BoxDecoration _decoration = new BoxDecoration(
- backgroundColor: const Color(0xFFFF00FF),
- borderRadius: 5.0/*,
- gradient: new LinearGradient(
- endPoints: [ Point.origin, const Point(0.0, 36.0) ],
- colors: [ const Color(0xFFEEEEEE), const Color(0xFFCCCCCC) ]
- )*/
-);
-
-class MyButton extends Component {
- final Widget child;
- final Function onPressed;
- final Function onPointerDown;
- final Function onPointerMove;
- final Function onPointerUp;
-
- MyButton({this.child, this.onPressed, this.onPointerDown, this.onPointerMove, this.onPointerUp});
-
- Container makeContainer() {
- return new Container(
- //height: 36.0,
- //padding: const EdgeDims.all(8.0),
- //margin: const EdgeDims.symmetric(horizontal: 8.0),
- decoration: _decoration,
- child: new Center(
- child: this.child
- )
- );
- }
-
- Widget build() {
- return new Listener(
- // Listeners have these possibly fields https://github.com/domokit/sky_engine/blob/2e8843893b9c1cef0f0f9d9e00d384fca7a70d23/sky/packages/sky/lib/widgets/framework.dart
- onGestureTap: (e) {
- print('MyButton was tapped!');
- if (this.onPressed != null) {
- this.onPressed(e);
- }
- },
- onPointerDown: (e) {
- print('MyButton was scrolled!');
- if (this.onPointerDown != null) {
- this.onPointerDown(e);
- }
- },
- onPointerMove: (e) {
- print('MyButton continues to be scrolled!');
- if (this.onPointerMove != null) {
- this.onPointerMove(e);
- }
- },
- onPointerUp: (e) {
- print('MyButton pointer up!');
- if (this.onPointerUp != null) {
- this.onPointerUp(e);
- }
- },
- child: makeContainer()
- );
- }
-}
\ No newline at end of file
diff --git a/lib/search.png b/lib/search.png
deleted file mode 100644
index 9c81036..0000000
--- a/lib/search.png
+++ /dev/null
Binary files differ