-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
150 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,70 @@ | ||
// Ionic Starter App | ||
//noinspection JSHint | ||
(function(angular){ | ||
"use strict"; | ||
|
||
// angular.module is a global place for creating, registering and retrieving Angular modules | ||
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html) | ||
// the 2nd parameter is an array of 'requires' | ||
// 'starter.services' is found in services.js | ||
// 'starter.controllers' is found in controllers.js | ||
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services']) | ||
// Ionic Starter App | ||
|
||
.run(function($ionicPlatform) { | ||
$ionicPlatform.ready(function() { | ||
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard | ||
// for form inputs) | ||
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { | ||
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); | ||
} | ||
if (window.StatusBar) { | ||
// org.apache.cordova.statusbar required | ||
StatusBar.styleDefault(); | ||
} | ||
}); | ||
}) | ||
// angular.module is a global place for creating, registering and retrieving Angular modules | ||
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html) | ||
// the 2nd parameter is an array of 'requires' | ||
// 'starter.services' is found in services.js | ||
// 'starter.controllers' is found in controllers.js | ||
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services']) | ||
|
||
.config(function($stateProvider, $urlRouterProvider) { | ||
.run(function($ionicPlatform) { | ||
$ionicPlatform.ready(function() { | ||
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard | ||
// for form inputs) | ||
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { | ||
window.cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); | ||
} | ||
if (window.StatusBar) { | ||
// org.apache.cordova.statusbar required | ||
window.StatusBar.styleDefault(); | ||
} | ||
}); | ||
}) | ||
|
||
// Ionic uses AngularUI Router which uses the concept of states | ||
// Learn more here: https://github.com/angular-ui/ui-router | ||
// Set up the various states which the app can be in. | ||
// Each state's controller can be found in controllers.js | ||
$stateProvider | ||
.config(function($stateProvider, $urlRouterProvider) { | ||
|
||
// setup an abstract state for the tabs directive | ||
.state('tab', { | ||
url: "/tab", | ||
abstract: true, | ||
templateUrl: "templates/tabs.html" | ||
}) | ||
// Ionic uses AngularUI Router which uses the concept of states | ||
// Learn more here: https://github.com/angular-ui/ui-router | ||
// Set up the various states which the app can be in. | ||
// Each state's controller can be found in controllers.js | ||
$stateProvider | ||
|
||
// Each tab has its own nav history stack: | ||
// setup an abstract state for the tabs directive | ||
.state('tab', { | ||
url: "/tab", | ||
abstract: true, | ||
templateUrl: "templates/tabs.html" | ||
}) | ||
|
||
.state('tab.map', { | ||
url: '/map', | ||
views: { | ||
'tab-map': { | ||
templateUrl: 'templates/tab-map.html', | ||
controller: 'MapCtrl' | ||
} | ||
} | ||
}) | ||
// Each tab has its own nav history stack: | ||
|
||
.state('tab.settings', { | ||
url: '/settings', | ||
views: { | ||
'tab-settings': { | ||
templateUrl: 'templates/tab-settings.html', | ||
controller: 'SettingsCtrl' | ||
} | ||
} | ||
}); | ||
.state('tab.map', { | ||
url: '/map', | ||
views: { | ||
'tab-map': { | ||
templateUrl: 'templates/tab-map.html', | ||
controller: 'MapCtrl' | ||
} | ||
} | ||
}) | ||
|
||
// if none of the above states are matched, use this as the fallback | ||
$urlRouterProvider.otherwise('/tab/map'); | ||
.state('tab.settings', { | ||
url: '/settings', | ||
views: { | ||
'tab-settings': { | ||
templateUrl: 'templates/tab-settings.html', | ||
controller: 'SettingsCtrl' | ||
} | ||
} | ||
}); | ||
|
||
}); | ||
// if none of the above states are matched, use this as the fallback | ||
$urlRouterProvider.otherwise('/tab/map'); | ||
|
||
}); | ||
|
||
})(angular); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
//noinspection JSHint | ||
(function (Catan) { | ||
"use strict"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
//noinspection JSHint | ||
(function(Catan) { | ||
"use strict"; | ||
|
||
Catan.Generator = {}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
//noinspection JSHint | ||
(function(Catan){ | ||
"use strict"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,51 @@ | ||
angular.module('starter.controllers', []) | ||
//noinspection JSHint | ||
(function (angular, Catan) { | ||
"use strict"; | ||
|
||
.controller('MapCtrl', function($scope, $ionicPlatform, Settings) { | ||
$scope.generate = function() { | ||
var canvas = document.querySelector('.canvas'); | ||
canvas.width = document.querySelector('.canvas-container').offsetWidth; | ||
canvas.height = document.querySelector('.canvas-container').offsetHeight; | ||
var map = Catan.Generator.Map.generate(Settings.getTileTrioScoreLimit(), Settings.getHarborGenerationStrategy()); | ||
Catan.UI.drawMap(map, canvas); | ||
}; | ||
}) | ||
angular.module('starter.controllers', []) | ||
|
||
.controller('SettingsCtrl', function($scope, Settings) { | ||
$scope.tileTrioScoreLimitOptions = [ | ||
{id: 11, label: 'High (slower)'}, | ||
{id: 12, label: 'Normal'}, | ||
{id: 13, label: 'Low (faster)'} | ||
]; | ||
var selectedTileTrioScoreLimitValue = Settings.getTileTrioScoreLimit(); | ||
$scope.selectedTileTrioScoreLimit = null; | ||
for (var i = 0 ; i < $scope.tileTrioScoreLimitOptions.length ; i++) { | ||
if ($scope.tileTrioScoreLimitOptions[i].id === selectedTileTrioScoreLimitValue) { | ||
$scope.selectedTileTrioScoreLimit = $scope.tileTrioScoreLimitOptions[i]; | ||
} | ||
} | ||
$scope.updateTileTrioScoreLimit = function() { | ||
Settings.setTileTrioScoreLimit(this.selectedTileTrioScoreLimit.id); | ||
}; | ||
.controller('MapCtrl', function ($scope, $ionicPlatform, Settings) { | ||
$scope.generate = function () { | ||
var canvas = document.querySelector('.canvas'); | ||
canvas.width = document.querySelector('.canvas-container').offsetWidth; | ||
canvas.height = document.querySelector('.canvas-container').offsetHeight; | ||
var map = Catan.Generator.Map.generate(Settings.getTileTrioScoreLimit(), Settings.getHarborGenerationStrategy()); | ||
Catan.UI.drawMap(map, canvas); | ||
}; | ||
}) | ||
|
||
.controller('SettingsCtrl', function ($scope, Settings) { | ||
$scope.tileTrioScoreLimitOptions = [ | ||
{id: 11, label: 'High (slower)'}, | ||
{id: 12, label: 'Normal'}, | ||
{id: 13, label: 'Low (faster)'} | ||
]; | ||
var selectedTileTrioScoreLimitValue = Settings.getTileTrioScoreLimit(); | ||
$scope.selectedTileTrioScoreLimit = null; | ||
for (var i = 0; i < $scope.tileTrioScoreLimitOptions.length; i++) { | ||
if ($scope.tileTrioScoreLimitOptions[i].id === selectedTileTrioScoreLimitValue) { | ||
$scope.selectedTileTrioScoreLimit = $scope.tileTrioScoreLimitOptions[i]; | ||
} | ||
} | ||
$scope.updateTileTrioScoreLimit = function () { | ||
Settings.setTileTrioScoreLimit(this.selectedTileTrioScoreLimit.id); | ||
}; | ||
|
||
|
||
$scope.harborGenerationStrategyOptions = [ | ||
{id: 'separate-tiles', label: 'Separate Tiles'}, | ||
{id: 'coast-bars', label: 'Coast Bars'} | ||
]; | ||
var selectedHarborGenerationStrategyValue = Settings.getHarborGenerationStrategy(); | ||
$scope.selectedHarborGenerationStrategy = null; | ||
for (i = 0 ; i < $scope.harborGenerationStrategyOptions.length ; i++) { | ||
if ($scope.harborGenerationStrategyOptions[i].id === selectedHarborGenerationStrategyValue) { | ||
$scope.selectedHarborGenerationStrategy = $scope.harborGenerationStrategyOptions[i]; | ||
} | ||
} | ||
$scope.updateHarborGenerationStrategy = function() { | ||
Settings.setHarborGenerationStrategy(this.selectedHarborGenerationStrategy.id); | ||
}; | ||
}); | ||
$scope.harborGenerationStrategyOptions = [ | ||
{id: 'separate-tiles', label: 'Separate Tiles'}, | ||
{id: 'coast-bars', label: 'Coast Bars'} | ||
]; | ||
var selectedHarborGenerationStrategyValue = Settings.getHarborGenerationStrategy(); | ||
$scope.selectedHarborGenerationStrategy = null; | ||
for (i = 0; i < $scope.harborGenerationStrategyOptions.length; i++) { | ||
if ($scope.harborGenerationStrategyOptions[i].id === selectedHarborGenerationStrategyValue) { | ||
$scope.selectedHarborGenerationStrategy = $scope.harborGenerationStrategyOptions[i]; | ||
} | ||
} | ||
$scope.updateHarborGenerationStrategy = function () { | ||
Settings.setHarborGenerationStrategy(this.selectedHarborGenerationStrategy.id); | ||
}; | ||
}); | ||
|
||
})(angular, Catan); |
Oops, something went wrong.