Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Ultrawide to Demo Mode #119

Merged
merged 23 commits into from
May 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cfc4aa1
Fixing upgrade/hire tests referenced in #109.
luigi-rosso May 2, 2019
5cf71d9
Adding a WideButton enabled property.
luigi-rosso May 2, 2019
1cd8ed2
Using package import for style.dart.
luigi-rosso May 2, 2019
2a095be
Merge pull request #113 from luigi-rosso/clamp_character_columns
efortuna May 2, 2019
0d0f12c
Merge pull request #110 from luigi-rosso/fix_tests
efortuna May 2, 2019
5f0b139
fixed WideButton
efortuna May 3, 2019
4fdeb01
Bump cost of upgrading founders. #78
luigi-rosso May 3, 2019
de10307
Reward user more based on task, allow user to hire right after shippi…
luigi-rosso May 3, 2019
63fb1ab
Fixed for loop and static analysis issue with clamped value.
luigi-rosso May 3, 2019
fb5495f
Move conditional out of loop.
luigi-rosso May 3, 2019
482f2c7
Update pubspec.yaml
efortuna May 3, 2019
4120198
Upgrade to provider 2.0.0
filiph May 3, 2019
86ccc9c
Fix formatting
filiph May 3, 2019
68032f3
Merge pull request #117 from 2d-inc/provider_upgrade
filiph May 3, 2019
85dfeeb
Merge branch 'master' into balancing
efortuna May 3, 2019
b907e53
Merge pull request #116 from luigi-rosso/balancing
efortuna May 3, 2019
26c2b86
Adding ultrawide layout.
luigi-rosso May 4, 2019
b7658db
Formatting.
luigi-rosso May 4, 2019
5e249f4
Fixing analysis issue.
luigi-rosso May 4, 2019
d452687
Unnecessary listener.
luigi-rosso May 4, 2019
5c27f7e
Merge branch 'demo' of github.com:2d-inc/dev_rpg into demo
luigi-rosso May 4, 2019
4768c6b
Merge branch 'ultrawide' of github.com:luigi-rosso/dev_rpg into demo
luigi-rosso May 4, 2019
cd4d781
Fixing autoplay hiring.
luigi-rosso May 4, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions lib/src/about_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,6 @@ class _AboutScreenState extends State<AboutScreen> {
Colors.white.withOpacity(0.15),
label: 'DONE',
),
CheckboxListTile(
title: const Text("Is Demo TV"),
value:
RpgLayoutBuilder.forcedLayout ==
RpgLayout.demoTv,
onChanged: (value) => setState(() =>
RpgLayoutBuilder.forcedLayout =
value
? RpgLayout.demoTv
: null),
),
],
),
),
Expand Down
196 changes: 102 additions & 94 deletions lib/src/code_chomper/code_chomper.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
library chompy;

import 'dart:math';

import 'package:flare_flutter/flare_actor.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
Expand All @@ -13,6 +15,7 @@ const TextStyle chompTextStyle =
TextStyle(fontFamily: 'SpaceMonoRegular', fontSize: 12, color: chompBlue);
const double _keyDefaultWidth = 32;
const double _keyPadding = 5;
const double _maxWidth = 1000;

/// The main screen for the code chomper mini game.
class CodeChomper extends StatefulWidget {
Expand Down Expand Up @@ -43,106 +46,111 @@ class _CodeChomperState extends State<CodeChomper> {
padding: EdgeInsets.only(
top: devicePadding.top + 11,
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: [
Row(
child: Center(
child: Container(
constraints: const BoxConstraints(maxWidth: _maxWidth),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: [
const Text(
'CODE CHOMPER: ',
style: chompTextStyle,
),
Text(
'ACTIVE',
style: chompTextStyle.apply(
fontFamily: 'SpaceMonoBold',
color: const Color.fromRGBO(206, 83, 83, 1),
),
),
Expanded(child: Container()),
Container(
width: 120,
height: 10,
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(Radius.circular(5)),
color: chompBlue.withOpacity(0.24),
),
child: Row(
children: [
for (int i = 0; i < 5; i++)
Container(
margin:
const EdgeInsets.only(left: 3, right: 3),
height: 3,
width: 18,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(1.5),
Row(
children: [
const Text(
'CODE CHOMPER: ',
style: chompTextStyle,
),
Text(
'ACTIVE',
style: chompTextStyle.apply(
fontFamily: 'SpaceMonoBold',
color: const Color.fromRGBO(206, 83, 83, 1),
),
),
Expanded(child: Container()),
Container(
width: 120,
height: 10,
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(Radius.circular(5)),
color: chompBlue.withOpacity(0.24),
),
child: Row(
children: [
for (int i = 0; i < 5; i++)
Container(
margin: const EdgeInsets.only(
left: 3, right: 3),
height: 3,
width: 18,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(1.5),
),
color: chompBlue,
),
),
color: chompBlue,
),
],
),
),
],
),
const SizedBox(height: 6),
Container(height: 1, color: chompBlue),
const SizedBox(height: 6),
Row(
children: [
for (int i = 0; i < 3; i++)
Expanded(
child: Container(
margin: EdgeInsets.only(right: i == 2 ? 0 : 5),
height: 1,
color: chompBlue.withOpacity(0.5),
),
],
),
),
],
),
],
),
const SizedBox(height: 6),
Container(height: 1, color: chompBlue),
const SizedBox(height: 6),
Row(
),
Expanded(
child: Stack(
children: [
for (int i = 0; i < 3; i++)
Expanded(
child: Container(
margin: EdgeInsets.only(right: i == 2 ? 0 : 5),
height: 1,
color: chompBlue.withOpacity(0.5),
),
),
],
),
],
),
),
Expanded(
child: Stack(
children: [
Positioned.fill(
child: Column(
children: [
// Game renderer goes here
Expanded(
child: CodeChomperScreen(_chomperController),
),
Positioned.fill(
child: Column(
children: [
// Game renderer goes here
Expanded(
child: CodeChomperScreen(_chomperController),
),

GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: (details) {
if (_chomperController
.addCode(details.globalPosition)) {
setState(() {
_isGameOver = true;
});
}
},
child: _ChompyKeyboard(),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: (details) {
if (_chomperController
.addCode(details.globalPosition)) {
setState(() {
_isGameOver = true;
});
}
},
child: _ChompyKeyboard(),
),
],
),
],
),
),
Positioned.fill(
child: _GameOverScreen(isGameOver: _isGameOver),
),
Positioned.fill(
child: _GameOverScreen(isGameOver: _isGameOver),
),
],
),
],
),
),
],
),
],
),
),
),
);
Expand Down Expand Up @@ -209,8 +217,8 @@ class _ChompyKeyboard extends StatelessWidget {
Widget build(BuildContext context) {
var media = MediaQuery.of(context);
var devicePadding = media.padding;
var defaultKeysPerRow =
(media.size.width / (_keyDefaultWidth + _keyPadding)).floor();
var width = min(_maxWidth, media.size.width);
var defaultKeysPerRow = (width / (_keyDefaultWidth + _keyPadding)).floor();

return Container(
color: Colors.black.withOpacity(0.33),
Expand Down Expand Up @@ -244,11 +252,11 @@ class _ChompyKeyboard extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_ChompyKey(media.size.width / 5),
_ChompyKey(width / 5),
const SizedBox(width: 2),
_ChompyKey(media.size.width / 2),
_ChompyKey(width / 2),
const SizedBox(width: 2),
_ChompyKey(media.size.width / 5),
_ChompyKey(width / 5),
],
),
SizedBox(height: devicePadding.bottom),
Expand Down
9 changes: 4 additions & 5 deletions lib/src/game_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class _GameScreenState extends State<GameScreen> {
case DemoModeAction.showCharacterModal:
// Hire any available character.
for (final character in world.characterPool.children) {
if (character.canUpgrade) {
character.upgrade();
if (character.canUpgradeOrHire) {
character.hire();
break;
}
}
Expand Down Expand Up @@ -113,9 +113,8 @@ class _GameScreenState extends State<GameScreen> {
_scheduleInactivityTimer(context);
},
child: RpgLayoutBuilder(
builder: (context, layout) => layout != RpgLayout.slim
? GameScreenWide(layout == RpgLayout.demoTv)
: GameScreenSlim(),
builder: (context, layout) =>
layout == RpgLayout.slim ? GameScreenSlim() : GameScreenWide(),
),
);
}
Expand Down
30 changes: 20 additions & 10 deletions lib/src/game_screen/add_task_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ class AddTaskButton extends StatefulWidget {
final String label;
final int count;
final VoidCallback onPressed;
final double scale;

const AddTaskButton(this.label,
{Key key, this.count = 0, this.icon, this.color, this.onPressed})
: super(key: key);
const AddTaskButton(
this.label, {
Key key,
this.count = 0,
this.icon,
this.color,
this.onPressed,
this.scale = 1.0,
}) : super(key: key);

@override
_AddTaskButtonState createState() => _AddTaskButtonState();
Expand Down Expand Up @@ -53,7 +60,7 @@ class _AddTaskButtonState extends State<AddTaskButton> {
onTap: isDisabled ? null : onTap,
child: AnimatedContainer(
duration: const Duration(milliseconds: 100),
height: 40,
height: 40 * widget.scale,
padding: const EdgeInsets.symmetric(horizontal: 8),
decoration: BoxDecoration(
boxShadow: isDisabled
Expand All @@ -65,7 +72,7 @@ class _AddTaskButtonState extends State<AddTaskButton> {
blurRadius: _isPressed ? 10 : 15,
spreadRadius: 0),
],
borderRadius: const BorderRadius.all(Radius.circular(20)),
borderRadius: BorderRadius.all(Radius.circular(20 * widget.scale)),
color: isDisabled
? disabledTaskColor.withOpacity(0.10)
: _isPressed ? widget.color.withOpacity(0.8) : widget.color,
Expand All @@ -80,16 +87,17 @@ class _AddTaskButtonState extends State<AddTaskButton> {
widget.label,
style: buttonTextStyle.apply(
fontSizeDelta: -2,
fontSizeFactor: widget.scale,
color: isDisabled ? disabledTaskColor : Colors.white),
),
),
isDisabled
? Container()
: Container(
constraints: const BoxConstraints(
minWidth: 26,
minHeight: 26,
maxHeight: 26,
constraints: BoxConstraints(
minWidth: 26 * widget.scale,
minHeight: 26 * widget.scale,
maxHeight: 26 * widget.scale,
),
decoration: const BoxDecoration(
shape: BoxShape.circle,
Expand All @@ -98,7 +106,9 @@ class _AddTaskButtonState extends State<AddTaskButton> {
child: Center(
child: Text(widget.count.toString(),
style: buttonTextStyle.apply(
fontSizeDelta: -2, color: widget.color)),
fontSizeDelta: -2,
fontSizeFactor: widget.scale,
color: widget.color)),
),
),
],
Expand Down
9 changes: 5 additions & 4 deletions lib/src/game_screen/character_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,21 +170,22 @@ class UpgradeHireButton extends StatelessWidget {
Widget build(BuildContext context) {
var character = Provider.of<Character>(context);
return WideButton(
enabled: character.canUpgradeOrHire,
onPressed: () {
if (character.canUpgrade && character.upgrade()) {
if (character.upgradeOrHire()) {
_controls.play('success');
}
},
paddingTweak: const EdgeInsets.only(right: -7),
background: character.canUpgrade
background: character.canUpgradeOrHire
? const Color.fromRGBO(84, 114, 239, 1)
: contentColor.withOpacity(0.1),
child: Row(
children: [
Text(
character.isHired ? 'UPGRADE' : 'HIRE',
style: buttonTextStyle.apply(
color: character.canUpgrade
color: character.canUpgradeOrHire
? Colors.white
: contentColor.withOpacity(0.25),
),
Expand All @@ -203,7 +204,7 @@ class UpgradeHireButton extends StatelessWidget {
character.upgradeCost.toString(),
style: buttonTextStyle.apply(
fontSizeDelta: -2,
color: character.canUpgrade
color: character.canUpgradeOrHire
? const Color.fromRGBO(241, 241, 241, 1)
: contentColor.withOpacity(0.25),
),
Expand Down
Loading