Moved Scale consts to their own files for better docs navigation

This commit is contained in:
Richard Davey 2019-01-31 11:11:35 +00:00
parent 3b52b8387e
commit 537d58a858
7 changed files with 293 additions and 142 deletions

View file

@ -1,139 +0,0 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* Phaser Scale Manager constants.
*
* @name Phaser.Scale.ScaleModes
* @enum {integer}
* @memberof Phaser
* @readonly
* @since 3.16.0
*/
module.exports = {
/**
* No scaling happens at all. The canvas is set to the size given in the game config and Phaser doesn't change it
* again from that point on. If you change the canvas size, either via CSS, or directly via code, then you need
* to call the Scale Managers `resize` method to give the new dimensions, or input events will stop working.
*
* @name Phaser.Scale.NONE
* @enum {integer}
* @since 3.16.0
*/
NONE: 0,
/**
*
*
* @name Phaser.Scale.WIDTH_CONTROLS_HEIGHT
* @enum {integer}
* @since 3.16.0
*/
WIDTH_CONTROLS_HEIGHT: 1,
/**
*
*
* @name Phaser.Scale.HEIGHT_CONTROLS_WIDTH
* @enum {integer}
* @since 3.16.0
*/
HEIGHT_CONTROLS_WIDTH: 2,
/**
*
*
* @name Phaser.Scale.FIT
* @enum {integer}
* @since 3.16.0
*/
FIT: 3,
/**
*
*
* @name Phaser.Scale.ENVELOP
* @enum {integer}
* @since 3.16.0
*/
ENVELOP: 4,
/**
* Canvas is resized to fit all available parent space, regardless of aspect ratio.
*
* @name Phaser.Scale.RESIZE
* @enum {integer}
* @since 3.16.0
*/
RESIZE: 5,
/**
* Canvas is not centered within the parent.
*
* @name Phaser.Scale.NO_CENTER
* @enum {integer}
* @since 3.16.0
*/
NO_CENTER: 0,
/**
* Canvas is centered both horizontally and vertically within the parent.
*
* @name Phaser.Scale.CENTER_BOTH
* @enum {integer}
* @since 3.16.0
*/
CENTER_BOTH: 1,
/**
* Canvas is centered horizontally within the parent.
*
* @name Phaser.Scale.CENTER_HORIZONTALLY
* @enum {integer}
* @since 3.16.0
*/
CENTER_HORIZONTALLY: 2,
/**
* Canvas is centered vertically within the parent.
*
* @name Phaser.Scale.CENTER_VERTICALLY
* @enum {integer}
* @since 3.16.0
*/
CENTER_VERTICALLY: 3,
/**
* Browser is in landscape orientation.
*
* @name Phaser.Scale.LANDSCAPE
* @enum {string}
* @since 3.16.0
*/
LANDSCAPE: 'landscape-primary',
/**
* Browser is in portrait orientation.
*
* @name Phaser.Scale.PORTRAIT
* @enum {string}
* @since 3.16.0
*/
PORTRAIT: 'portrait-primary',
/**
* Calculate the zoom value based on the maximum multiplied game size that will
* fit into the parent, or browser window if no parent is set.
*
* @name Phaser.Scale.MAX_ZOOM
* @enum {integer}
* @since 3.16.0
*/
MAX_ZOOM: -1
};

View file

@ -0,0 +1,70 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* Phaser Scale Manager constants for centering the game canvas.
*
* @namespace Phaser.Scale.Center
* @memberof Phaser.Scale
* @since 3.16.0
*/
module.exports = {
/**
* The game canvas is not centered within the parent by Phaser.
* You can still center it yourself via CSS.
*
* @name Phaser.Scale.Center.NO_CENTER
* @type {integer}
* @const
* @since 3.16.0
*/
NO_CENTER: 0,
/**
* The game canvas is centered both horizontally and vertically within the parent.
* To do this, the parent has to have a bounds that can be calculated and not be empty.
*
* Centering is achieved by setting the margin left and top properties of the
* game canvas, and does not factor in any other CSS styles you may have applied.
*
* @name Phaser.Scale.Center.CENTER_BOTH
* @type {integer}
* @const
* @since 3.16.0
*/
CENTER_BOTH: 1,
/**
* The game canvas is centered horizontally within the parent.
* To do this, the parent has to have a bounds that can be calculated and not be empty.
*
* Centering is achieved by setting the margin left and top properties of the
* game canvas, and does not factor in any other CSS styles you may have applied.
*
* @name Phaser.Scale.Center.CENTER_HORIZONTALLY
* @type {integer}
* @const
* @since 3.16.0
*/
CENTER_HORIZONTALLY: 2,
/**
* The game canvas is centered both vertically within the parent.
* To do this, the parent has to have a bounds that can be calculated and not be empty.
*
* Centering is achieved by setting the margin left and top properties of the
* game canvas, and does not factor in any other CSS styles you may have applied.
*
* @name Phaser.Scale.Center.CENTER_VERTICALLY
* @type {integer}
* @const
* @since 3.16.0
*/
CENTER_VERTICALLY: 3
};

View file

@ -0,0 +1,37 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* Phaser Scale Manager constants for orientation.
*
* @namespace Phaser.Scale.Orientation
* @memberof Phaser.Scale
* @since 3.16.0
*/
module.exports = {
/**
* A landscape orientation.
*
* @name Phaser.Scale.Orientation.LANDSCAPE
* @type {string}
* @const
* @since 3.16.0
*/
LANDSCAPE: 'landscape-primary',
/**
* A portrait orientation.
*
* @name Phaser.Scale.Orientation.PORTRAIT
* @type {string}
* @const
* @since 3.16.0
*/
PORTRAIT: 'portrait-primary'
};

View file

@ -0,0 +1,82 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* Phaser Scale Manager constants for the different scale modes available.
*
* @namespace Phaser.Scale.ScaleModes
* @memberof Phaser.Scale
* @since 3.16.0
*/
module.exports = {
/**
* No scaling happens at all. The canvas is set to the size given in the game config and Phaser doesn't change it
* again from that point on. If you change the canvas size, either via CSS, or directly via code, then you need
* to call the Scale Managers `resize` method to give the new dimensions, or input events will stop working.
*
* @name Phaser.Scale.ScaleModes.NONE
* @type {integer}
* @const
* @since 3.16.0
*/
NONE: 0,
/**
* The height is automatically adjusted based on the width.
*
* @name Phaser.Scale.ScaleModes.WIDTH_CONTROLS_HEIGHT
* @type {integer}
* @const
* @since 3.16.0
*/
WIDTH_CONTROLS_HEIGHT: 1,
/**
* The width is automatically adjusted based on the height.
*
* @name Phaser.Scale.ScaleModes.HEIGHT_CONTROLS_WIDTH
* @type {integer}
* @const
* @since 3.16.0
*/
HEIGHT_CONTROLS_WIDTH: 2,
/**
* The width and height are automatically adjusted to fit inside the given target area,
* while keeping the aspect ratio. Depending on the aspect ratio there may be some space
* inside the area which is not covered.
*
* @name Phaser.Scale.ScaleModes.FIT
* @type {integer}
* @const
* @since 3.16.0
*/
FIT: 3,
/**
* The width and height are automatically adjusted to make the size cover the entire target
* area while keeping the aspect ratio. This may extend further out than the target size.
*
* @name Phaser.Scale.ScaleModes.ENVELOP
* @type {integer}
* @const
* @since 3.16.0
*/
ENVELOP: 4,
/**
* The Canvas is resized to fit all available _parent_ space, regardless of aspect ratio.
*
* @name Phaser.Scale.ScaleModes.RESIZE
* @type {integer}
* @const
* @since 3.16.0
*/
RESIZE: 5
};

View file

@ -0,0 +1,58 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* Phaser Scale Manager constants for zoom modes.
*
* @namespace Phaser.Scale.Zoom
* @memberof Phaser.Scale
* @since 3.16.0
*/
module.exports = {
/**
* The game canvas will not be zoomed by Phaser.
*
* @name Phaser.Scale.Zoom.NO_ZOOM
* @type {integer}
* @const
* @since 3.16.0
*/
NO_ZOOM: 1,
/**
* The game canvas will be 2x zoomed by Phaser.
*
* @name Phaser.Scale.Zoom.ZOOM_2X
* @type {integer}
* @const
* @since 3.16.0
*/
ZOOM_2X: 2,
/**
* The game canvas will be 4x zoomed by Phaser.
*
* @name Phaser.Scale.Zoom.ZOOM_4X
* @type {integer}
* @const
* @since 3.16.0
*/
ZOOM_4X: 4,
/**
* Calculate the zoom value based on the maximum multiplied game size that will
* fit into the parent, or browser window if no parent is set.
*
* @name Phaser.Scale.Zoom.MAX_ZOOM
* @type {integer}
* @const
* @since 3.16.0
*/
MAX_ZOOM: -1
};

16
src/scale/const/index.js Normal file
View file

@ -0,0 +1,16 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var CONST = {
CENTER: require('./CENTER_CONST'),
ORIENTATION: require('./ORIENTATION_CONST'),
SCALE_MODE: require('./SCALE_MODE_CONST'),
ZOOM: require('./ZOOM_CONST')
};
module.exports = CONST;

View file

@ -5,18 +5,45 @@
*/
var Extend = require('../utils/object/Extend');
var ScaleModes = require('./const');
var CONST = require('./const');
/**
* @namespace Phaser.Scale
*
* @borrows Phaser.Scale.Center.NO_CENTER as Phaser.Scale.NO_CENTER
* @borrows Phaser.Scale.Center.CENTER_BOTH as Phaser.Scale.CENTER_BOTH
* @borrows Phaser.Scale.Center.CENTER_HORIZONTALLY as Phaser.Scale.CENTER_HORIZONTALLY
* @borrows Phaser.Scale.Center.CENTER_VERTICALLY as Phaser.Scale.CENTER_VERTICALLY
*
* @borrows Phaser.Scale.Orientation.LANDSCAPE as Phaser.Scale.LANDSCAPE
* @borrows Phaser.Scale.Orientation.PORTRAIT as Phaser.Scale.PORTRAIT
*
* @borrows Phaser.Scale.ScaleModes.NONE as Phaser.Scale.NONE
* @borrows Phaser.Scale.ScaleModes.WIDTH_CONTROLS_HEIGHT as Phaser.Scale.WIDTH_CONTROLS_HEIGHT
* @borrows Phaser.Scale.ScaleModes.HEIGHT_CONTROLS_WIDTH as Phaser.Scale.HEIGHT_CONTROLS_WIDTH
* @borrows Phaser.Scale.ScaleModes.FIT as Phaser.Scale.FIT
* @borrows Phaser.Scale.ScaleModes.ENVELOP as Phaser.Scale.ENVELOP
* @borrows Phaser.Scale.ScaleModes.RESIZE as Phaser.Scale.RESIZE
*
* @borrows Phaser.Scale.Zoom.NO_ZOOM as Phaser.Scale.NO_ZOOM
* @borrows Phaser.Scale.Zoom.ZOOM_2X as Phaser.Scale.ZOOM_2X
* @borrows Phaser.Scale.Zoom.ZOOM_4X as Phaser.Scale.ZOOM_4X
* @borrows Phaser.Scale.Zoom.MAX_ZOOM as Phaser.Scale.MAX_ZOOM
*/
var Scale = {
ScaleManager: require('./ScaleManager')
Center: require('./const/CENTER_CONST'),
Orientation: require('./const/ORIENTATION_CONST'),
ScaleManager: require('./ScaleManager'),
ScaleModes: require('./const/SCALE_MODE_CONST'),
Zoom: require('./const/ZOOM_CONST')
};
Scale = Extend(false, Scale, ScaleModes);
Scale = Extend(false, Scale, CONST.CENTER);
Scale = Extend(false, Scale, CONST.ORIENTATION);
Scale = Extend(false, Scale, CONST.SCALE_MODE);
Scale = Extend(false, Scale, CONST.ZOOM);
module.exports = Scale;