├── .github
└── ISSUE_TEMPLATE.md
├── .gitignore
├── .npmignore
├── Gruntfile.js
├── LICENSE
├── README.md
├── build
├── phaser-input.d.ts
├── phaser-input.js
├── phaser-input.js.map
└── phaser-input.min.js
├── config
├── tsconfig.json
└── tslint.json
├── example
├── images
│ ├── bg.png
│ ├── btn_clean.png
│ └── inputfield.png
└── index.html
├── package-lock.json
├── package.json
├── ts
├── InputElement.ts
├── InputField.ts
├── Objects
│ ├── InputBox.ts
│ ├── SelectionHighlight.ts
│ └── TextMask.ts
├── Plugin.ts
└── definitions.d.ts
└── tslint.json
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Before opening this issue _please_ check we haven't already fixed it! Check the [Closed issues](https://github.com/azerion/phaser-input/issues?q=is%3Aissue+is%3Aclosed)
2 | This Issue is about (delete as applicable)
3 |
4 | * A bug in the API (always say which version you're using!)
5 | * An error in the documentation
6 | * An error in the example
7 | * A problem with my own code
8 |
9 | API errors must include example code showing what happens, and why you don't believe this is the expected behavior. Issues posted without code take _far_ longer to get resolved, _if ever_.
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .idea
3 | .tscache
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | Gruntfile.js
2 | example
3 | ts
4 | .idea
5 | .tscache
6 | .github
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function (grunt) {
2 | 'use strict';
3 |
4 | grunt.initConfig({
5 | //Get some details from the package.json
6 | pkg: grunt.file.readJSON('package.json'),
7 | banner: '/*!\n' +
8 | ' * <%= pkg.config.name %> - version <%= pkg.version %> \n' +
9 | ' * <%= pkg.description %>\n' +
10 | ' *\n' +
11 | ' * <%= pkg.author %>\n' +
12 | ' * Build at <%= grunt.template.today("dd-mm-yyyy") %>\n' +
13 | ' * Released under MIT License \n' +
14 | ' */\n',
15 | usebanner: {
16 | dist: {
17 | options: {
18 | position: 'top',
19 | banner: '<%= banner %>'
20 | },
21 | files: {
22 | src: [ 'build/*.js' ]
23 | }
24 | }
25 | },
26 | //Typescript settings per build
27 | ts: {
28 | options: {
29 | module: 'amd',
30 | target: 'es5',
31 | sourceMap: true,
32 | declaration: true,
33 | noImplicitAny: true
34 | },
35 | dist: {
36 | src: ['ts/**/*.ts'],
37 | dest: 'build/<%= pkg.config.name %>.js'
38 | }
39 | },
40 | watch: {
41 | files: ['ts/**/*.ts'],
42 | tasks: ['ts'],
43 | options: {
44 | livereload: true
45 | }
46 | },
47 | connect: {
48 | server: {
49 | options: {
50 | base: ['./build', './example'],
51 | port: 8080
52 | }
53 | }
54 | },
55 | uglify: {
56 | options: {
57 | compress: {
58 | sequences: true,
59 | dead_code: true,
60 | conditionals: true,
61 | booleans: true,
62 | unused: true,
63 | if_return: true,
64 | join_vars: true,
65 | drop_console: true
66 | },
67 | mangle: true,
68 | beautify: false
69 | },
70 | dist: {
71 | files: {
72 | 'build/<%= pkg.config.name %>.min.js': [
73 | 'build/<%= pkg.config.name %>.js'
74 | ]
75 | }
76 | }
77 | },
78 | clean: {
79 | dist: ['build']
80 | }
81 | });
82 |
83 | grunt.loadNpmTasks('grunt-contrib-clean');
84 | grunt.loadNpmTasks('grunt-contrib-uglify');
85 | grunt.loadNpmTasks('grunt-banner');
86 | grunt.loadNpmTasks('grunt-ts');
87 | grunt.loadNpmTasks('grunt-contrib-connect');
88 | grunt.loadNpmTasks('grunt-contrib-watch');
89 |
90 | //dist Build
91 | grunt.registerTask('dist', [
92 | 'clean:dist', //Clean the dist folder
93 | 'ts:dist',//Run typescript on the preprocessed files, for dist (client)
94 | 'uglify:dist', //Minify everything
95 | 'usebanner:dist' //Minify everything
96 | ]);
97 |
98 | grunt.registerTask('dev', [
99 | 'ts:dist',
100 | 'connect',
101 | 'watch'
102 | ]);
103 |
104 | };
105 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Azerion
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Phaser Input
2 | ============
3 | Phaser Input is a plugin for Phaser that allows you to use html input fields as Phaser object inside your Phaser game. It fills the blanks of CanvasInput (that only works on a canvas renderer) and appends it with full Phaser support!
4 | The best part is that it will also work on mobile devices!
5 |
6 | Key features:
7 |
8 | * Works on mobile and Desktop
9 | * Included TypeScript support
10 | * Also runs under WebGL renderer
11 | * Pure Phaser implementation
12 | * Easy configurable
13 | * Production hardened
14 |
15 | *Imporant*
16 | From here on this library will be published and updated under [@azerion/phaser-input](https://www.npmjs.com/package/@azerion/phaser-input) at NPM, the old [phaser-input](https://www.npmjs.com/package/phaser-input) will no longer be maintained.
17 | If you are comming from v1 you can read the migration guide at the bottom
18 |
19 | Getting Started
20 | ---------------
21 | First you want to get a fresh copy of the plugin. You can get it from this repo or from npm, ain't that handy.
22 | ```
23 | npm install @azerion/phaser-input --save-dev
24 | ```
25 |
26 | Next up you'd want to add it to your list of js sources you load into your game
27 | ```html
28 |
29 | ```
30 |
31 | After adding the script to the page you can activate it by enabling the plugin:
32 | ```javascript
33 | game.add.plugin(PhaserInput.Plugin);
34 | ```
35 |
36 | Usage
37 | -----
38 | ### Adding a InputField
39 | The simplest way of adding a input field is:
40 | ```javascript
41 | var input = game.add.inputField(10, 90);
42 | ```
43 |
44 | Ofcourse there are options available that can be used to style the input. They can be passes as an object as the third parameter.
45 |
46 | ```javascript
47 | var password = game.add.inputField(10, 90, {
48 | font: '18px Arial',
49 | fill: '#212121',
50 | fontWeight: 'bold',
51 | width: 150,
52 | padding: 8,
53 | borderWidth: 1,
54 | borderColor: '#000',
55 | borderRadius: 6,
56 | placeHolder: 'Password',
57 | type: PhaserInput.InputType.password
58 | });
59 | ```
60 |
61 | ### Using zoom
62 | Zooming is easy to enable on an input field, it can be passed to the InputField as a setting. But there are some caveats:
63 |
64 | First of all, it's only meant for mobile. Second; it modifies the scale and pivot of the world, and that might interfere with your resize.
65 |
66 | Also, when the keyboard is shown, sometimes a resize event will be triggered.
67 |
68 | Ideally you use a custom resize event, check for the static property `PhaserInput.KeyboardOpen` and don't resize when it's set to true.
69 |
70 | ### Using keyboard open/close signals
71 | Current version includes two event dispatchers that notify when a device keyboard is opened or closed.
72 |
73 | You can add listeners which trigger events based on this feedback.
74 |
75 | ```javascript
76 | PhaserInput.onKeyboardClose.addOnce(function() {
77 | this.resizeBackgroundImage();
78 | });
79 | ```
80 |
81 | ### Capture input events
82 | By default, input event will not bubble up to other elements
83 | This is controlled by an InputField property called `blockInput`.
84 | When set to false, the input event will trigger on the input element and move up to other elements listening for the event.
85 |
86 | e.g. An in-game sprite might be listening for keyboard events (W, A, S, D).
87 | If set to false, typing in input field will not trigger keyboard events for the sprite.
88 | So the sprite will not move when typing into input field.
89 |
90 |
91 | ### Toggle Enter key
92 | InputField has a property (`focusOutOnEnter`) that controls whether the input field will lose focus on pressing Enter.
93 | If set to true, pressing enter will end focus on the field (default is true).
94 |
95 |
96 | ### Current Limitations
97 | - Updates are slow when typing fast (type slower you!!)
98 | - Zoom modifies the pivot and scale of the world, so it might interfere with some stuff
99 |
100 | ## Properties
101 | - **x**: number (0 by default) The X-coordinate in the game
102 | - **y**: number (0 by default) The Y-coordinate in the game
103 | - **fill**: string (#fff by default) The color of the inputted text
104 | - **fillAlpha**: number (1 by default) Alpha of the textbox, 0 will hide the textbox and only show the text/placeholder/cursor
105 | - **width**: number (150 by default) The width of the text box (just like in the DOM, padding, borders add onto this width)
106 | - **height**: number (14 by default) The height of the text box (just like in the DOM, padding, borders add onto this height)
107 | - **padding**: number (0 by default) The padding in pixels around all 4 sides of the text input area.
108 | - **borderWidth**: number (1 by default) Size of the border
109 | - **borderColor**: string (#000 by default) Color of the border
110 | - **forceCase**: ForceCase (none by default) If we should force a certain case (either PhaserInput.ForceCase.upper or PhaserInput.ForceCase.lower)
111 | - **borderRadius**: number (0 by default) Create rounded corners by setting a border radius
112 | - **placeHolder**: string ('' by default) Text that will be shown before the user input's anything
113 | - **placeHolderColor**: string (#bfbebd by default) The color of the placeholder text
114 | - **type**: InputType (text by default) Either text, password or numeric
115 | - **backgroundColor**: string (#fff by default) The background color of the input box
116 | - **cursorColor**: string (#000 by default) The color of the blinking cursor
117 | - **font**: string (14px Arial by default) The font that is used for the input box, covers the input text, placeholder and cursor
118 | - **min**: string (none by default) The minimum number for the input field, only for number input fields
119 | - **max**: string (none by default) The maximum number for the number input field, or the maxLength for other input fields
120 | - **selectionColor**: string (rgba(179, 212, 253, 0.8) by default) The default color for the text selection highlight.
121 | - **zoom**: boolean (false by default) if we need to zoom onto the input field (mobile only).
122 |
123 | ### Browser Support
124 | Tested on:
125 | - Desktop
126 | * Chrome 48+
127 | * FireFox 44+
128 | * Safari 9+
129 | - Mobile
130 | * Chrome 48+
131 | * iOS 9+
132 |
133 | Migrating from v1
134 | -----------------
135 | the API of the objects is the same as before but the namespace changed. We decided to remove the Fabrique namespace, and house the plugin in it's own (PhaserInput).
136 | so:
137 | Fabrique.Plugins.Input
138 | becomes:
139 | PhaserInput.Plugin
140 |
141 | and all other references of Fabrique.Plugins can be replaced with PhaserInput.
142 | If you are still unsure how or what, both the example and this readme have been adjusted to work with the new namespace.
143 |
144 | FAQ
145 | ---
146 | ### I Don't see the cursor blinking!
147 | This is most likely due to you adding the input field to a custom Phaser object. According to the [Phaser docs](http://phaser.io/docs/2.6.2/Phaser.Sprite.html#update) the update function needs to be called manually in these cases.
148 |
149 | So add the following to your object and the cursor should work :)
150 |
151 | ```javascript
152 | update: function () {
153 | this._inputField.update();
154 | },
155 | ```
156 |
157 | ### How do I focus on the element?!
158 | Normally the element is only focused trough user interaction (due to mobile limitations) you can get around this by manually calling the focus method yourself:
159 | ```javascript
160 | var input = game.add.inputField(10, 90);
161 | //start with focus on the element
162 | input.startFocus();
163 |
164 | //and then end the focus
165 | input.endFocus();
166 | ```
167 | Please note that this will not work on mobile wihtout a user interaction
168 |
169 | ### Can I change the width later on in the code?
170 | Well thanks for asking, yes you can!
171 | ```javascript
172 | var input = game.add.inputField(10, 90);
173 | input.width = 200;
174 | ```
175 |
176 | ### Well then, is it also possible to set the value in code?
177 | Yes you can! The Inputfield has a setText function you can call to set any value you want!
178 | ```javascript
179 | var input = game.add.inputField(10, 90);
180 | input.setText("My custom text");
181 | ```
182 |
183 | Credits
184 | -------
185 | phaser-input is inspired by [CanvasInput](https://github.com/goldfire/CanvasInput)
186 |
187 | Disclaimer
188 | ----------
189 | We at Azerion just love playing and creating awesome games. We aren't affiliated with Phaser.io. We just needed some awesome input boxes in our awesome HTML5 games. Feel free to use it for enhancing your own awesome games!
190 |
191 | Phaser Input is distributed under the MIT license. All 3rd party libraries and components are distributed under their
192 | respective license terms.
193 |
--------------------------------------------------------------------------------
/build/phaser-input.d.ts:
--------------------------------------------------------------------------------
1 | declare module PhaserInput {
2 | enum InputType {
3 | text = 0,
4 | password = 1,
5 | number = 2,
6 | }
7 | class InputElement {
8 | private element;
9 | private keyUpCallback;
10 | private inputChangeCallback;
11 | private type;
12 | private id;
13 | private game;
14 | private focusIn;
15 | private focusOut;
16 | constructor(game: Phaser.Game, id: string, type?: InputType, value?: string, focusIn?: Phaser.Signal, focusOut?: Phaser.Signal);
17 | addKeyUpListener(callback: () => void): void;
18 | blockKeyDownEvents(): void;
19 | private preventKeyPropagation(evt);
20 | unblockKeyDownEvents(): void;
21 | removeEventListener(): void;
22 | destroy(): void;
23 | setMax(max: string, min?: string): void;
24 | value: string;
25 | focus(): void;
26 | blur(): void;
27 | readonly hasSelection: boolean;
28 | readonly caretStart: number;
29 | readonly caretEnd: number;
30 | getCaretPosition(): number;
31 | setCaretPosition(pos: number): void;
32 | }
33 | }
34 | declare module PhaserInput {
35 | enum ForceCase {
36 | none = 0,
37 | lower = 1,
38 | upper = 2,
39 | }
40 | interface InputOptions extends Phaser.PhaserTextStyle {
41 | x?: number;
42 | y?: number;
43 | placeHolder?: string;
44 | fillAlpha?: number;
45 | width?: number;
46 | height?: number;
47 | padding?: number;
48 | borderWidth?: number;
49 | borderColor?: string;
50 | borderRadius?: number;
51 | cursorColor?: string;
52 | placeHolderColor?: string;
53 | type?: InputType;
54 | forceCase?: ForceCase;
55 | min?: string;
56 | max?: string;
57 | textAlign?: string;
58 | selectionColor?: string;
59 | zoom?: boolean;
60 | }
61 | class InputField extends Phaser.Sprite {
62 | focusOutOnEnter: boolean;
63 | private placeHolder;
64 | private box;
65 | private textMask;
66 | private focus;
67 | private cursor;
68 | private text;
69 | private offscreenText;
70 | value: string;
71 | private inputOptions;
72 | private domElement;
73 | private selection;
74 | private windowScale;
75 | blockInput: boolean;
76 | focusIn: Phaser.Signal;
77 | focusOut: Phaser.Signal;
78 | width: number;
79 | constructor(game: Phaser.Game, x: number, y: number, inputOptions?: InputOptions);
80 | private updateTextAlignment();
81 | private checkDown(e);
82 | private blink;
83 | private cnt;
84 | update(): number;
85 | endFocus(): void;
86 | startFocus(): void;
87 | private keyUpProcessor();
88 | private updateText();
89 | private updateCursor();
90 | private getCaretPosition();
91 | private setCaretOnclick(e);
92 | private updateSelection();
93 | private zoomIn();
94 | private zoomOut();
95 | private keyListener(evt);
96 | destroy(destroyChildren?: boolean): void;
97 | resetText(): void;
98 | setText(text?: string): void;
99 | private getFormattedText(text);
100 | }
101 | }
102 | declare module PhaserInput {
103 | class InputBox extends Phaser.Graphics {
104 | private bgColor;
105 | private borderRadius;
106 | private borderColor;
107 | private borderWidth;
108 | private boxAlpha;
109 | private boxHeight;
110 | private padding;
111 | private boxWidth;
112 | constructor(game: Phaser.Game, inputOptions: InputOptions);
113 | resize(newWidth: number): void;
114 | private drawBox();
115 | }
116 | }
117 | declare module PhaserInput {
118 | class SelectionHighlight extends Phaser.Graphics {
119 | private inputOptions;
120 | constructor(game: Phaser.Game, inputOptions: InputOptions);
121 | updateSelection(rect: PIXI.Rectangle): void;
122 | static rgb2hex(color: {
123 | r: number;
124 | g: number;
125 | b: number;
126 | a: number;
127 | }): number;
128 | }
129 | }
130 | declare module PhaserInput {
131 | class TextMask extends Phaser.Graphics {
132 | private maskWidth;
133 | private maskHeight;
134 | constructor(game: Phaser.Game, inputOptions: InputOptions);
135 | resize(newWidth: number): void;
136 | private drawMask();
137 | }
138 | }
139 | declare module PhaserInput {
140 | var Zoomed: boolean;
141 | var KeyboardOpen: boolean;
142 | const onKeyboardOpen: Phaser.Signal;
143 | const onKeyboardClose: Phaser.Signal;
144 | interface InputFieldObjectFactory extends Phaser.GameObjectFactory {
145 | inputField: (x: number, y: number, inputOptions?: PhaserInput.InputOptions, group?: Phaser.Group) => PhaserInput.InputField;
146 | }
147 | interface InputFieldObjectCreator extends Phaser.GameObjectCreator {
148 | inputField: (x: number, y: number, inputOptions?: PhaserInput.InputOptions) => PhaserInput.InputField;
149 | }
150 | interface InputFieldGame extends Phaser.Game {
151 | add: InputFieldObjectFactory;
152 | make: InputFieldObjectCreator;
153 | }
154 | class Plugin extends Phaser.Plugin {
155 | static Zoomed: boolean;
156 | static KeyboardOpen: boolean;
157 | static onKeyboardOpen: Phaser.Signal;
158 | static onKeyboardClose: Phaser.Signal;
159 | constructor(game: Phaser.Game, parent: Phaser.PluginManager);
160 | private addInputFieldFactory();
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/build/phaser-input.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * phaser-input - version 2.0.5
3 | * Adds input boxes to Phaser like CanvasInput, but also works for WebGL and Mobile, made for Phaser only.
4 | *
5 | * Azerion
6 | * Build at 18-03-2019
7 | * Released under MIT License
8 | */
9 |
10 | var __extends = (this && this.__extends) || (function () {
11 | var extendStatics = Object.setPrototypeOf ||
12 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14 | return function (d, b) {
15 | extendStatics(d, b);
16 | function __() { this.constructor = d; }
17 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18 | };
19 | })();
20 | var PhaserInput;
21 | (function (PhaserInput) {
22 | var InputType;
23 | (function (InputType) {
24 | InputType[InputType["text"] = 0] = "text";
25 | InputType[InputType["password"] = 1] = "password";
26 | InputType[InputType["number"] = 2] = "number";
27 | })(InputType = PhaserInput.InputType || (PhaserInput.InputType = {}));
28 | var InputElement = (function () {
29 | function InputElement(game, id, type, value, focusIn, focusOut) {
30 | if (type === void 0) { type = InputType.text; }
31 | if (value === void 0) { value = ''; }
32 | var _this = this;
33 | this.id = id;
34 | this.type = type;
35 | this.game = game;
36 | this.focusIn = focusIn;
37 | this.focusOut = focusOut;
38 | var canvasTopX = this.game.canvas.getBoundingClientRect().top + document.body.scrollTop;
39 | this.element = document.createElement('input');
40 | this.element.id = id;
41 | this.element.style.position = 'absolute';
42 | this.element.style.top = canvasTopX + 'px';
43 | this.element.style.left = (-40).toString() + 'px';
44 | this.element.style.width = (10).toString() + 'px';
45 | this.element.style.height = (10).toString() + 'px';
46 | this.element.style.border = '0px';
47 | this.element.value = this.value;
48 | this.element.type = InputType[type];
49 | this.element.addEventListener('focusin', function () {
50 | if (_this.focusIn instanceof Phaser.Signal) {
51 | _this.focusIn.dispatch();
52 | }
53 | });
54 | this.element.addEventListener('focusout', function () {
55 | if (_this.focusOut instanceof Phaser.Signal) {
56 | _this.focusOut.dispatch();
57 | }
58 | });
59 | document.body.appendChild(this.element);
60 | }
61 | InputElement.prototype.addKeyUpListener = function (callback) {
62 | this.keyUpCallback = callback;
63 | document.addEventListener('keyup', this.keyUpCallback);
64 | this.element.addEventListener('input', this.keyUpCallback);
65 | };
66 | InputElement.prototype.blockKeyDownEvents = function () {
67 | document.addEventListener('keydown', this.preventKeyPropagation);
68 | };
69 | InputElement.prototype.preventKeyPropagation = function (evt) {
70 | if (evt.stopPropagation) {
71 | evt.stopPropagation();
72 | }
73 | else {
74 | event.cancelBubble = true;
75 | }
76 | };
77 | InputElement.prototype.unblockKeyDownEvents = function () {
78 | document.removeEventListener('keydown', this.preventKeyPropagation);
79 | };
80 | InputElement.prototype.removeEventListener = function () {
81 | document.removeEventListener('keyup', this.keyUpCallback);
82 | this.element.removeEventListener('input', this.keyUpCallback);
83 | };
84 | InputElement.prototype.destroy = function () {
85 | document.body.removeChild(this.element);
86 | };
87 | InputElement.prototype.setMax = function (max, min) {
88 | if (max === undefined) {
89 | return;
90 | }
91 | if (this.type === InputType.text || this.type === InputType.password) {
92 | this.element.maxLength = parseInt(max, 10);
93 | }
94 | else if (this.type === InputType.number) {
95 | this.element.max = max;
96 | if (min === undefined) {
97 | return;
98 | }
99 | this.element.min = min;
100 | }
101 | };
102 | Object.defineProperty(InputElement.prototype, "value", {
103 | get: function () {
104 | return this.element.value;
105 | },
106 | set: function (value) {
107 | this.element.value = value;
108 | },
109 | enumerable: true,
110 | configurable: true
111 | });
112 | InputElement.prototype.focus = function () {
113 | var _this = this;
114 | this.element.focus();
115 | if (!this.game.device.desktop && this.game.device.chrome) {
116 | var originalWidth_1 = window.innerWidth, originalHeight_1 = window.innerHeight;
117 | var kbAppeared_1 = false;
118 | var interval_1 = setInterval(function () {
119 | if (originalWidth_1 > window.innerWidth || originalHeight_1 > window.innerHeight) {
120 | kbAppeared_1 = true;
121 | }
122 | if (kbAppeared_1 && originalWidth_1 === window.innerWidth && originalHeight_1 === window.innerHeight) {
123 | if (_this.focusOut instanceof Phaser.Signal) {
124 | _this.focusOut.dispatch();
125 | }
126 | clearInterval(interval_1);
127 | }
128 | }, 50);
129 | }
130 | };
131 | InputElement.prototype.blur = function () {
132 | this.element.blur();
133 | };
134 | Object.defineProperty(InputElement.prototype, "hasSelection", {
135 | get: function () {
136 | if (this.type === InputType.number) {
137 | return false;
138 | }
139 | return this.element.selectionStart !== this.element.selectionEnd;
140 | },
141 | enumerable: true,
142 | configurable: true
143 | });
144 | Object.defineProperty(InputElement.prototype, "caretStart", {
145 | get: function () {
146 | return this.element.selectionEnd;
147 | },
148 | enumerable: true,
149 | configurable: true
150 | });
151 | Object.defineProperty(InputElement.prototype, "caretEnd", {
152 | get: function () {
153 | return this.element.selectionStart;
154 | },
155 | enumerable: true,
156 | configurable: true
157 | });
158 | InputElement.prototype.getCaretPosition = function () {
159 | if (this.type === InputType.number) {
160 | return -1;
161 | }
162 | return this.element.selectionStart;
163 | };
164 | InputElement.prototype.setCaretPosition = function (pos) {
165 | if (this.type === InputType.number) {
166 | return;
167 | }
168 | this.element.setSelectionRange(pos, pos);
169 | };
170 | return InputElement;
171 | }());
172 | PhaserInput.InputElement = InputElement;
173 | })(PhaserInput || (PhaserInput = {}));
174 | var PhaserInput;
175 | (function (PhaserInput) {
176 | var ForceCase;
177 | (function (ForceCase) {
178 | ForceCase[ForceCase["none"] = 0] = "none";
179 | ForceCase[ForceCase["lower"] = 1] = "lower";
180 | ForceCase[ForceCase["upper"] = 2] = "upper";
181 | })(ForceCase = PhaserInput.ForceCase || (PhaserInput.ForceCase = {}));
182 | var InputField = (function (_super) {
183 | __extends(InputField, _super);
184 | function InputField(game, x, y, inputOptions) {
185 | if (inputOptions === void 0) { inputOptions = {}; }
186 | var _this = _super.call(this, game, x, y) || this;
187 | _this.focusOutOnEnter = true;
188 | _this.placeHolder = null;
189 | _this.box = null;
190 | _this.focus = false;
191 | _this.value = '';
192 | _this.windowScale = 1;
193 | _this.blockInput = true;
194 | _this.focusIn = new Phaser.Signal();
195 | _this.focusOut = new Phaser.Signal();
196 | _this.blink = true;
197 | _this.cnt = 0;
198 | _this.inputOptions = inputOptions;
199 | _this.inputOptions.width = (typeof inputOptions.width === 'number') ? inputOptions.width : 150;
200 | _this.inputOptions.padding = (typeof inputOptions.padding === 'number') ? inputOptions.padding : 0;
201 | _this.inputOptions.textAlign = inputOptions.textAlign || 'left';
202 | _this.inputOptions.type = inputOptions.type || PhaserInput.InputType.text;
203 | _this.inputOptions.forceCase = (inputOptions.forceCase) ? inputOptions.forceCase : ForceCase.none;
204 | _this.inputOptions.borderRadius = (typeof inputOptions.borderRadius === 'number') ? inputOptions.borderRadius : 0;
205 | _this.inputOptions.height = (typeof inputOptions.height === 'number') ? inputOptions.height : 14;
206 | _this.inputOptions.fillAlpha = (inputOptions.fillAlpha === undefined) ? 1 : inputOptions.fillAlpha;
207 | _this.inputOptions.selectionColor = inputOptions.selectionColor || 'rgba(179, 212, 253, 0.8)';
208 | _this.inputOptions.zoom = (!game.device.desktop) ? inputOptions.zoom || false : false;
209 | _this.box = new PhaserInput.InputBox(_this.game, inputOptions);
210 | _this.setTexture(_this.box.generateTexture());
211 | _this.textMask = new PhaserInput.TextMask(_this.game, inputOptions);
212 | _this.addChild(_this.textMask);
213 | _this.domElement = new PhaserInput.InputElement(_this.game, 'phaser-input-' + (Math.random() * 10000 | 0).toString(), _this.inputOptions.type, _this.value, _this.focusIn, _this.focusOut);
214 | _this.domElement.setMax(_this.inputOptions.max, _this.inputOptions.min);
215 | _this.selection = new PhaserInput.SelectionHighlight(_this.game, _this.inputOptions);
216 | _this.selection.mask = _this.textMask;
217 | _this.addChild(_this.selection);
218 | if (inputOptions.placeHolder && inputOptions.placeHolder.length > 0) {
219 | _this.placeHolder = new Phaser.Text(game, _this.inputOptions.padding, _this.inputOptions.padding, inputOptions.placeHolder, {
220 | font: inputOptions.font || '14px Arial',
221 | fontWeight: inputOptions.fontWeight || 'normal',
222 | fill: inputOptions.placeHolderColor || '#bfbebd'
223 | });
224 | _this.placeHolder.mask = _this.textMask;
225 | _this.addChild(_this.placeHolder);
226 | }
227 | _this.cursor = new Phaser.Text(game, _this.inputOptions.padding, _this.inputOptions.padding - 2, '|', {
228 | font: inputOptions.font || '14px Arial',
229 | fontWeight: inputOptions.fontWeight || 'normal',
230 | fill: inputOptions.cursorColor || '#000000'
231 | });
232 | _this.cursor.visible = false;
233 | _this.addChild(_this.cursor);
234 | _this.text = new Phaser.Text(game, _this.inputOptions.padding, _this.inputOptions.padding, '', {
235 | font: inputOptions.font || '14px Arial',
236 | fontWeight: inputOptions.fontWeight || 'normal',
237 | fill: inputOptions.fill || '#000000'
238 | });
239 | _this.text.mask = _this.textMask;
240 | _this.addChild(_this.text);
241 | _this.offscreenText = new Phaser.Text(game, _this.inputOptions.padding, _this.inputOptions.padding, '', {
242 | font: inputOptions.font || '14px Arial',
243 | fontWeight: inputOptions.fontWeight || 'normal',
244 | fill: inputOptions.fill || '#000000'
245 | });
246 | _this.updateTextAlignment();
247 | _this.inputEnabled = true;
248 | _this.input.useHandCursor = true;
249 | _this.game.input.onDown.add(_this.checkDown, _this);
250 | _this.focusOut.add(function () {
251 | if (PhaserInput.KeyboardOpen) {
252 | _this.endFocus();
253 | if (_this.inputOptions.zoom) {
254 | _this.zoomOut();
255 | }
256 | }
257 | });
258 | return _this;
259 | }
260 | Object.defineProperty(InputField.prototype, "width", {
261 | get: function () {
262 | return this.inputOptions.width;
263 | },
264 | set: function (width) {
265 | this.inputOptions.width = width;
266 | this.box.resize(width);
267 | this.textMask.resize(width);
268 | this.updateTextAlignment();
269 | },
270 | enumerable: true,
271 | configurable: true
272 | });
273 | InputField.prototype.updateTextAlignment = function () {
274 | switch (this.inputOptions.textAlign) {
275 | case 'left':
276 | this.text.anchor.set(0, 0);
277 | this.text.x = this.inputOptions.padding;
278 | if (null !== this.placeHolder) {
279 | this.placeHolder.anchor.set(0, 0);
280 | }
281 | this.cursor.x = this.inputOptions.padding + this.getCaretPosition();
282 | break;
283 | case 'center':
284 | this.text.anchor.set(0.5, 0);
285 | this.text.x = this.inputOptions.padding + this.inputOptions.width / 2;
286 | if (null !== this.placeHolder) {
287 | this.placeHolder.anchor.set(0.5, 0);
288 | this.placeHolder.x = this.inputOptions.padding + this.inputOptions.width / 2;
289 | }
290 | this.cursor.x = this.inputOptions.padding + this.inputOptions.width / 2 - this.text.width / 2 + this.getCaretPosition();
291 | break;
292 | case 'right':
293 | this.text.anchor.set(1, 0);
294 | this.text.x = this.inputOptions.padding + this.inputOptions.width;
295 | if (null !== this.placeHolder) {
296 | this.placeHolder.anchor.set(1, 0);
297 | this.placeHolder.x = this.inputOptions.padding + this.inputOptions.width;
298 | }
299 | this.cursor.x = this.inputOptions.padding + this.inputOptions.width;
300 | break;
301 | }
302 | };
303 | InputField.prototype.checkDown = function (e) {
304 | if (!this.value) {
305 | this.resetText();
306 | }
307 | if (this.input.checkPointerOver(e)) {
308 | if (this.focus) {
309 | this.setCaretOnclick(e);
310 | return;
311 | }
312 | if (this.inputOptions.zoom && !PhaserInput.Zoomed) {
313 | this.zoomIn();
314 | }
315 | this.startFocus();
316 | }
317 | else {
318 | if (this.focus === true) {
319 | this.endFocus();
320 | if (this.inputOptions.zoom) {
321 | this.zoomOut();
322 | }
323 | }
324 | }
325 | };
326 | InputField.prototype.update = function () {
327 | this.text.update();
328 | if (this.placeHolder) {
329 | this.placeHolder.update();
330 | }
331 | if (!this.focus) {
332 | return;
333 | }
334 | if (this.cnt !== 30) {
335 | return this.cnt++;
336 | }
337 | this.cursor.visible = this.blink;
338 | this.blink = !this.blink;
339 | this.cnt = 0;
340 | };
341 | InputField.prototype.endFocus = function () {
342 | var _this = this;
343 | if (!this.focus) {
344 | return;
345 | }
346 | this.domElement.removeEventListener();
347 | if (this.blockInput === true) {
348 | this.domElement.unblockKeyDownEvents();
349 | }
350 | this.focus = false;
351 | if (this.value.length === 0 && null !== this.placeHolder) {
352 | this.placeHolder.visible = true;
353 | }
354 | this.cursor.visible = false;
355 | if (this.game.device.desktop) {
356 | setTimeout(function () {
357 | _this.domElement.blur();
358 | }, 0);
359 | }
360 | else {
361 | this.domElement.blur();
362 | }
363 | if (!this.game.device.desktop) {
364 | PhaserInput.KeyboardOpen = false;
365 | PhaserInput.onKeyboardClose.dispatch();
366 | }
367 | };
368 | InputField.prototype.startFocus = function () {
369 | var _this = this;
370 | this.focus = true;
371 | if (null !== this.placeHolder) {
372 | this.placeHolder.visible = false;
373 | }
374 | if (this.game.device.desktop) {
375 | setTimeout(function () {
376 | _this.keyUpProcessor();
377 | }, 0);
378 | }
379 | else {
380 | this.keyUpProcessor();
381 | }
382 | if (!this.game.device.desktop) {
383 | PhaserInput.KeyboardOpen = true;
384 | PhaserInput.onKeyboardOpen.dispatch();
385 | }
386 | };
387 | InputField.prototype.keyUpProcessor = function () {
388 | this.domElement.addKeyUpListener(this.keyListener.bind(this));
389 | this.domElement.focus();
390 | if (this.blockInput === true) {
391 | this.domElement.blockKeyDownEvents();
392 | }
393 | };
394 | InputField.prototype.updateText = function () {
395 | var text = '';
396 | if (this.inputOptions.type === PhaserInput.InputType.password) {
397 | for (var i = 0; i < this.value.length; i++) {
398 | text += '*';
399 | }
400 | }
401 | else if (this.inputOptions.type === PhaserInput.InputType.number) {
402 | var val = parseInt(this.value);
403 | if (val < parseInt(this.inputOptions.min)) {
404 | text = this.value = this.domElement.value = this.inputOptions.min;
405 | }
406 | else if (val > parseInt(this.inputOptions.max)) {
407 | text = this.value = this.domElement.value = this.inputOptions.max;
408 | }
409 | else {
410 | text = this.value;
411 | }
412 | }
413 | else {
414 | text = this.value;
415 | }
416 | this.text.setText(text);
417 | if (this.text.width > this.inputOptions.width) {
418 | this.text.anchor.x = 1;
419 | this.text.x = this.inputOptions.padding + this.inputOptions.width;
420 | }
421 | else {
422 | switch (this.inputOptions.textAlign) {
423 | case 'left':
424 | this.text.anchor.set(0, 0);
425 | this.text.x = this.inputOptions.padding;
426 | break;
427 | case 'center':
428 | this.text.anchor.set(0.5, 0);
429 | this.text.x = this.inputOptions.padding + this.inputOptions.width / 2;
430 | break;
431 | case 'right':
432 | this.text.anchor.set(1, 0);
433 | this.text.x = this.inputOptions.padding + this.inputOptions.width;
434 | break;
435 | }
436 | }
437 | };
438 | InputField.prototype.updateCursor = function () {
439 | if (this.text.width > this.inputOptions.width || this.inputOptions.textAlign === 'right') {
440 | this.cursor.x = this.inputOptions.padding + this.inputOptions.width;
441 | }
442 | else {
443 | switch (this.inputOptions.textAlign) {
444 | case 'left':
445 | this.cursor.x = this.inputOptions.padding + this.getCaretPosition();
446 | break;
447 | case 'center':
448 | this.cursor.x = this.inputOptions.padding + this.inputOptions.width / 2 - this.text.width / 2 + this.getCaretPosition();
449 | break;
450 | }
451 | }
452 | };
453 | InputField.prototype.getCaretPosition = function () {
454 | var caretPosition = this.domElement.getCaretPosition();
455 | if (-1 === caretPosition) {
456 | return this.text.width;
457 | }
458 | var text = this.value;
459 | if (this.inputOptions.type === PhaserInput.InputType.password) {
460 | text = '';
461 | for (var i = 0; i < this.value.length; i++) {
462 | text += '*';
463 | }
464 | }
465 | this.offscreenText.setText(text.slice(0, caretPosition));
466 | return this.offscreenText.width;
467 | };
468 | InputField.prototype.setCaretOnclick = function (e) {
469 | var localX = (this.text.toLocal(new PIXI.Point(e.x, e.y), this.game.world)).x;
470 | if (this.inputOptions.textAlign && this.inputOptions.textAlign === 'center') {
471 | localX += this.text.width / 2;
472 | }
473 | var characterWidth = this.text.width / this.value.length;
474 | var index = 0;
475 | for (var i = 0; i < this.value.length; i++) {
476 | if (localX >= i * characterWidth && localX <= (i + 1) * characterWidth) {
477 | index = i;
478 | break;
479 | }
480 | }
481 | if (localX > (this.value.length - 1) * characterWidth) {
482 | index = this.value.length;
483 | }
484 | this.startFocus();
485 | this.domElement.setCaretPosition(index);
486 | this.updateCursor();
487 | };
488 | InputField.prototype.updateSelection = function () {
489 | if (this.domElement.hasSelection) {
490 | var text = this.value;
491 | if (this.inputOptions.type === PhaserInput.InputType.password) {
492 | text = '';
493 | for (var i = 0; i < this.value.length; i++) {
494 | text += '*';
495 | }
496 | }
497 | text = text.substring(this.domElement.caretStart, this.domElement.caretEnd);
498 | this.offscreenText.setText(text);
499 | this.selection.updateSelection(this.offscreenText.getBounds());
500 | switch (this.inputOptions.textAlign) {
501 | case 'left':
502 | this.selection.x = this.inputOptions.padding;
503 | break;
504 | case 'center':
505 | this.selection.x = this.inputOptions.padding + this.inputOptions.width / 2 - this.text.width / 2;
506 | break;
507 | }
508 | }
509 | else {
510 | this.selection.clear();
511 | }
512 | };
513 | InputField.prototype.zoomIn = function () {
514 | if (PhaserInput.Zoomed) {
515 | return;
516 | }
517 | var bounds = this.getBounds();
518 | if (window.innerHeight > window.innerWidth) {
519 | this.windowScale = this.game.width / (bounds.width * 1.5);
520 | }
521 | else {
522 | this.windowScale = (this.game.width / 2) / (bounds.width * 1.5);
523 | }
524 | var offsetX = ((this.game.width - bounds.width * 1.5) / 2) / this.windowScale;
525 | this.game.world.scale.set(this.game.world.scale.x * this.windowScale, this.game.world.scale.y * this.windowScale);
526 | this.game.world.pivot.set(bounds.x - offsetX, bounds.y - this.inputOptions.padding * 2);
527 | PhaserInput.Zoomed = true;
528 | };
529 | InputField.prototype.zoomOut = function () {
530 | if (!PhaserInput.Zoomed) {
531 | return;
532 | }
533 | this.game.world.scale.set(this.game.world.scale.x / this.windowScale, this.game.world.scale.y / this.windowScale);
534 | this.game.world.pivot.set(0, 0);
535 | PhaserInput.Zoomed = false;
536 | };
537 | InputField.prototype.keyListener = function (evt) {
538 | this.value = this.getFormattedText(this.domElement.value);
539 | if (evt.keyCode === 13) {
540 | if (this.focusOutOnEnter) {
541 | this.endFocus();
542 | }
543 | return;
544 | }
545 | this.updateText();
546 | this.updateCursor();
547 | this.updateSelection();
548 | evt.preventDefault();
549 | };
550 | InputField.prototype.destroy = function (destroyChildren) {
551 | this.game.input.onDown.remove(this.checkDown, this);
552 | this.focusIn.removeAll();
553 | this.focusOut.removeAll();
554 | this.domElement.destroy();
555 | _super.prototype.destroy.call(this, destroyChildren);
556 | };
557 | InputField.prototype.resetText = function () {
558 | this.setText();
559 | };
560 | InputField.prototype.setText = function (text) {
561 | if (text === void 0) { text = ''; }
562 | if (null !== this.placeHolder) {
563 | if (text.length > 0) {
564 | this.placeHolder.visible = false;
565 | }
566 | else {
567 | this.placeHolder.visible = true;
568 | }
569 | }
570 | this.value = this.getFormattedText(text);
571 | this.domElement.value = this.value;
572 | this.updateText();
573 | this.updateCursor();
574 | this.endFocus();
575 | };
576 | InputField.prototype.getFormattedText = function (text) {
577 | switch (this.inputOptions.forceCase) {
578 | default:
579 | case ForceCase.none:
580 | return text;
581 | case ForceCase.lower:
582 | return text.toLowerCase();
583 | case ForceCase.upper:
584 | return text.toUpperCase();
585 | }
586 | };
587 | return InputField;
588 | }(Phaser.Sprite));
589 | PhaserInput.InputField = InputField;
590 | })(PhaserInput || (PhaserInput = {}));
591 | var PhaserInput;
592 | (function (PhaserInput) {
593 | var InputBox = (function (_super) {
594 | __extends(InputBox, _super);
595 | function InputBox(game, inputOptions) {
596 | var _this = _super.call(this, game, 0, 0) || this;
597 | _this.bgColor = (inputOptions.backgroundColor) ? parseInt(inputOptions.backgroundColor.slice(1), 16) : 0xffffff;
598 | _this.borderRadius = inputOptions.borderRadius = (typeof inputOptions.borderRadius === 'number') ? inputOptions.borderRadius : 0;
599 | _this.borderWidth = inputOptions.borderWidth = (typeof inputOptions.borderWidth === 'number') ? inputOptions.borderWidth : 1;
600 | _this.borderColor = (inputOptions.borderColor) ? parseInt(inputOptions.borderColor.slice(1), 16) : 0x959595;
601 | _this.boxAlpha = inputOptions.fillAlpha;
602 | _this.padding = inputOptions.padding;
603 | var height = inputOptions.height;
604 | var width = inputOptions.width;
605 | var height;
606 | if (inputOptions.font) {
607 | height = Math.max(parseInt(inputOptions.font.substr(0, inputOptions.font.indexOf('px')), 10), height);
608 | }
609 | _this.boxHeight = _this.padding * 2 + height;
610 | var width = inputOptions.width;
611 | _this.boxWidth = _this.padding * 2 + width;
612 | _this.drawBox();
613 | return _this;
614 | }
615 | InputBox.prototype.resize = function (newWidth) {
616 | this.boxWidth = this.padding * 2 + newWidth;
617 | this.drawBox();
618 | };
619 | InputBox.prototype.drawBox = function () {
620 | this.clear()
621 | .beginFill(this.bgColor, this.boxAlpha)
622 | .lineStyle(this.borderWidth, this.borderColor, this.boxAlpha);
623 | if (this.borderRadius > 0) {
624 | this.drawRoundedRect(0, 0, this.boxWidth, this.boxHeight, this.borderRadius);
625 | }
626 | else {
627 | this.drawRect(0, 0, this.boxWidth, this.boxHeight);
628 | }
629 | };
630 | return InputBox;
631 | }(Phaser.Graphics));
632 | PhaserInput.InputBox = InputBox;
633 | })(PhaserInput || (PhaserInput = {}));
634 | var PhaserInput;
635 | (function (PhaserInput) {
636 | var SelectionHighlight = (function (_super) {
637 | __extends(SelectionHighlight, _super);
638 | function SelectionHighlight(game, inputOptions) {
639 | var _this = _super.call(this, game, inputOptions.padding, inputOptions.padding) || this;
640 | _this.inputOptions = inputOptions;
641 | return _this;
642 | }
643 | SelectionHighlight.prototype.updateSelection = function (rect) {
644 | var color = Phaser.Color.webToColor(this.inputOptions.selectionColor);
645 | this.clear();
646 | this.beginFill(SelectionHighlight.rgb2hex(color), color.a);
647 | this.drawRect(rect.x, rect.y, rect.width, rect.height - this.inputOptions.padding);
648 | };
649 | SelectionHighlight.rgb2hex = function (color) {
650 | return parseInt(("0" + color.r.toString(16)).slice(-2) +
651 | ("0" + color.g.toString(16)).slice(-2) +
652 | ("0" + color.b.toString(16)).slice(-2), 16);
653 | };
654 | return SelectionHighlight;
655 | }(Phaser.Graphics));
656 | PhaserInput.SelectionHighlight = SelectionHighlight;
657 | })(PhaserInput || (PhaserInput = {}));
658 | var PhaserInput;
659 | (function (PhaserInput) {
660 | var TextMask = (function (_super) {
661 | __extends(TextMask, _super);
662 | function TextMask(game, inputOptions) {
663 | var _this = _super.call(this, game, inputOptions.padding, inputOptions.padding) || this;
664 | var height = inputOptions.height;
665 | if (inputOptions.font) {
666 | height = Math.max(parseInt(inputOptions.font.substr(0, inputOptions.font.indexOf('px')), 10), height);
667 | }
668 | _this.maskWidth = inputOptions.width;
669 | _this.maskHeight = height * 1.3;
670 | _this.drawMask();
671 | return _this;
672 | }
673 | TextMask.prototype.resize = function (newWidth) {
674 | this.maskWidth = newWidth;
675 | this.drawMask();
676 | };
677 | TextMask.prototype.drawMask = function () {
678 | this.clear()
679 | .beginFill(0x000000)
680 | .drawRect(0, 0, this.maskWidth, this.maskHeight)
681 | .endFill();
682 | };
683 | return TextMask;
684 | }(Phaser.Graphics));
685 | PhaserInput.TextMask = TextMask;
686 | })(PhaserInput || (PhaserInput = {}));
687 | var PhaserInput;
688 | (function (PhaserInput) {
689 | PhaserInput.Zoomed = false;
690 | PhaserInput.KeyboardOpen = false;
691 | PhaserInput.onKeyboardOpen = new Phaser.Signal();
692 | PhaserInput.onKeyboardClose = new Phaser.Signal();
693 | var Plugin = (function (_super) {
694 | __extends(Plugin, _super);
695 | function Plugin(game, parent) {
696 | var _this = _super.call(this, game, parent) || this;
697 | _this.addInputFieldFactory();
698 | return _this;
699 | }
700 | Plugin.prototype.addInputFieldFactory = function () {
701 | Phaser.GameObjectFactory.prototype.inputField = function (x, y, inputOptions, group) {
702 | if (group === undefined) {
703 | group = this.world;
704 | }
705 | var nineSliceObject = new PhaserInput.InputField(this.game, x, y, inputOptions);
706 | return group.add(nineSliceObject);
707 | };
708 | Phaser.GameObjectCreator.prototype.inputField = function (x, y, inputOptions) {
709 | return new PhaserInput.InputField(this.game, x, y, inputOptions);
710 | };
711 | };
712 | return Plugin;
713 | }(Phaser.Plugin));
714 | Plugin.Zoomed = false;
715 | Plugin.KeyboardOpen = false;
716 | Plugin.onKeyboardOpen = new Phaser.Signal();
717 | Plugin.onKeyboardClose = new Phaser.Signal();
718 | PhaserInput.Plugin = Plugin;
719 | })(PhaserInput || (PhaserInput = {}));
720 | //# sourceMappingURL=phaser-input.js.map
--------------------------------------------------------------------------------
/build/phaser-input.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"phaser-input.js","sourceRoot":"","sources":["../ts/InputElement.ts","../ts/InputField.ts","../ts/Objects/InputBox.ts","../ts/Objects/SelectionHighlight.ts","../ts/Objects/TextMask.ts","../ts/Plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,IAAO,WAAW,CAuLjB;AAvLD,WAAO,WAAW;IAEd,IAAY,SAIX;IAJD,WAAY,SAAS;QACjB,yCAAI,CAAA;QACJ,iDAAQ,CAAA;QACR,6CAAM,CAAA;IACV,CAAC,EAJW,SAAS,GAAT,qBAAS,KAAT,qBAAS,QAIpB;IAED;QAiBI,sBAAY,IAAiB,EAAE,EAAU,EAAE,IAAgC,EAAE,KAAkB,EAAE,OAAuB,EAAE,QAAwB;YAAvG,qBAAA,EAAA,OAAkB,SAAS,CAAC,IAAI;YAAE,sBAAA,EAAA,UAAkB;YAA/F,iBAiCC;YAhCG,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAEzB,IAAI,UAAU,GAAW,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;YAEhG,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAE/C,IAAI,CAAC,OAAO,CAAC,EAAE,G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,MAAM,CAAC,iBAAiB,CAAC,SAAU,CAAC,UAAU,GAAG,UAAU,CAAS,EAAE,CAAS,EAAE,YAAsC,EAAE,KAAoB;gBAC/K,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;oBACtB,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;gBACvB,CAAC;gBAED,IAAI,eAAe,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;gBAEhF,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;YACtC,CAAC,CAAC;YAEoC,MAAM,CAAC,iBAAiB,CAAC,SAAU,CAAC,UAAU,GAAG,UAAU,CAAS,EAAE,CAAS,EAAE,YAAsC;gBACzJ,MAAM,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;YACrE,CAAC,CAAC;QACN,CAAC;QAEL,aAAC;IAAD,CAAC,AAhCD,CAA4B,MAAM,CAAC,MAAM;IACvB,aAAM,GAAY,KAAK,CAAC;IACxB,mBAAY,GAAY,KAAK,CAAC;IAC9B,qBAAc,GAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;IACpD,sBAAe,GAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;IAJ1D,kBAAM,SAgClB,CAAA;AACL,CAAC,EApDM,WAAW,KAAX,WAAW,QAoDjB"}
--------------------------------------------------------------------------------
/build/phaser-input.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * phaser-input - version 2.0.5
3 | * Adds input boxes to Phaser like CanvasInput, but also works for WebGL and Mobile, made for Phaser only.
4 | *
5 | * Azerion
6 | * Build at 18-03-2019
7 | * Released under MIT License
8 | */
9 |
10 | var __extends=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])};return function(b,c){function d(){this.constructor=b}a(b,c),b.prototype=null===c?Object.create(c):(d.prototype=c.prototype,new d)}}(),PhaserInput;!function(a){var b;!function(a){a[a.text=0]="text",a[a.password=1]="password",a[a.number=2]="number"}(b=a.InputType||(a.InputType={}));var c=function(){function a(a,c,d,e,f,g){void 0===d&&(d=b.text),void 0===e&&(e="");var h=this;this.id=c,this.type=d,this.game=a,this.focusIn=f,this.focusOut=g;var i=this.game.canvas.getBoundingClientRect().top+document.body.scrollTop;this.element=document.createElement("input"),this.element.id=c,this.element.style.position="absolute",this.element.style.top=i+"px",this.element.style.left=(-40).toString()+"px",this.element.style.width=10..toString()+"px",this.element.style.height=10..toString()+"px",this.element.style.border="0px",this.element.value=this.value,this.element.type=b[d],this.element.addEventListener("focusin",function(){h.focusIn instanceof Phaser.Signal&&h.focusIn.dispatch()}),this.element.addEventListener("focusout",function(){h.focusOut instanceof Phaser.Signal&&h.focusOut.dispatch()}),document.body.appendChild(this.element)}return a.prototype.addKeyUpListener=function(a){this.keyUpCallback=a,document.addEventListener("keyup",this.keyUpCallback),this.element.addEventListener("input",this.keyUpCallback)},a.prototype.blockKeyDownEvents=function(){document.addEventListener("keydown",this.preventKeyPropagation)},a.prototype.preventKeyPropagation=function(a){a.stopPropagation?a.stopPropagation():event.cancelBubble=!0},a.prototype.unblockKeyDownEvents=function(){document.removeEventListener("keydown",this.preventKeyPropagation)},a.prototype.removeEventListener=function(){document.removeEventListener("keyup",this.keyUpCallback),this.element.removeEventListener("input",this.keyUpCallback)},a.prototype.destroy=function(){document.body.removeChild(this.element)},a.prototype.setMax=function(a,c){if(void 0!==a)if(this.type===b.text||this.type===b.password)this.element.maxLength=parseInt(a,10);else if(this.type===b.number){if(this.element.max=a,void 0===c)return;this.element.min=c}},Object.defineProperty(a.prototype,"value",{get:function(){return this.element.value},set:function(a){this.element.value=a},enumerable:!0,configurable:!0}),a.prototype.focus=function(){var a=this;if(this.element.focus(),!this.game.device.desktop&&this.game.device.chrome)var b=window.innerWidth,c=window.innerHeight,d=!1,e=setInterval(function(){(b>window.innerWidth||c>window.innerHeight)&&(d=!0),d&&b===window.innerWidth&&c===window.innerHeight&&(a.focusOut instanceof Phaser.Signal&&a.focusOut.dispatch(),clearInterval(e))},50)},a.prototype.blur=function(){this.element.blur()},Object.defineProperty(a.prototype,"hasSelection",{get:function(){return this.type===b.number?!1:this.element.selectionStart!==this.element.selectionEnd},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"caretStart",{get:function(){return this.element.selectionEnd},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"caretEnd",{get:function(){return this.element.selectionStart},enumerable:!0,configurable:!0}),a.prototype.getCaretPosition=function(){return this.type===b.number?-1:this.element.selectionStart},a.prototype.setCaretPosition=function(a){this.type!==b.number&&this.element.setSelectionRange(a,a)},a}();a.InputElement=c}(PhaserInput||(PhaserInput={}));var PhaserInput;!function(a){var b;!function(a){a[a.none=0]="none",a[a.lower=1]="lower",a[a.upper=2]="upper"}(b=a.ForceCase||(a.ForceCase={}));var c=function(c){function d(d,e,f,g){void 0===g&&(g={});var h=c.call(this,d,e,f)||this;return h.focusOutOnEnter=!0,h.placeHolder=null,h.box=null,h.focus=!1,h.value="",h.windowScale=1,h.blockInput=!0,h.focusIn=new Phaser.Signal,h.focusOut=new Phaser.Signal,h.blink=!0,h.cnt=0,h.inputOptions=g,h.inputOptions.width="number"==typeof g.width?g.width:150,h.inputOptions.padding="number"==typeof g.padding?g.padding:0,h.inputOptions.textAlign=g.textAlign||"left",h.inputOptions.type=g.type||a.InputType.text,h.inputOptions.forceCase=g.forceCase?g.forceCase:b.none,h.inputOptions.borderRadius="number"==typeof g.borderRadius?g.borderRadius:0,h.inputOptions.height="number"==typeof g.height?g.height:14,h.inputOptions.fillAlpha=void 0===g.fillAlpha?1:g.fillAlpha,h.inputOptions.selectionColor=g.selectionColor||"rgba(179, 212, 253, 0.8)",h.inputOptions.zoom=d.device.desktop?!1:g.zoom||!1,h.box=new a.InputBox(h.game,g),h.setTexture(h.box.generateTexture()),h.textMask=new a.TextMask(h.game,g),h.addChild(h.textMask),h.domElement=new a.InputElement(h.game,"phaser-input-"+(1e4*Math.random()|0).toString(),h.inputOptions.type,h.value,h.focusIn,h.focusOut),h.domElement.setMax(h.inputOptions.max,h.inputOptions.min),h.selection=new a.SelectionHighlight(h.game,h.inputOptions),h.selection.mask=h.textMask,h.addChild(h.selection),g.placeHolder&&g.placeHolder.length>0&&(h.placeHolder=new Phaser.Text(d,h.inputOptions.padding,h.inputOptions.padding,g.placeHolder,{font:g.font||"14px Arial",fontWeight:g.fontWeight||"normal",fill:g.placeHolderColor||"#bfbebd"}),h.placeHolder.mask=h.textMask,h.addChild(h.placeHolder)),h.cursor=new Phaser.Text(d,h.inputOptions.padding,h.inputOptions.padding-2,"|",{font:g.font||"14px Arial",fontWeight:g.fontWeight||"normal",fill:g.cursorColor||"#000000"}),h.cursor.visible=!1,h.addChild(h.cursor),h.text=new Phaser.Text(d,h.inputOptions.padding,h.inputOptions.padding,"",{font:g.font||"14px Arial",fontWeight:g.fontWeight||"normal",fill:g.fill||"#000000"}),h.text.mask=h.textMask,h.addChild(h.text),h.offscreenText=new Phaser.Text(d,h.inputOptions.padding,h.inputOptions.padding,"",{font:g.font||"14px Arial",fontWeight:g.fontWeight||"normal",fill:g.fill||"#000000"}),h.updateTextAlignment(),h.inputEnabled=!0,h.input.useHandCursor=!0,h.game.input.onDown.add(h.checkDown,h),h.focusOut.add(function(){a.KeyboardOpen&&(h.endFocus(),h.inputOptions.zoom&&h.zoomOut())}),h}return __extends(d,c),Object.defineProperty(d.prototype,"width",{get:function(){return this.inputOptions.width},set:function(a){this.inputOptions.width=a,this.box.resize(a),this.textMask.resize(a),this.updateTextAlignment()},enumerable:!0,configurable:!0}),d.prototype.updateTextAlignment=function(){switch(this.inputOptions.textAlign){case"left":this.text.anchor.set(0,0),this.text.x=this.inputOptions.padding,null!==this.placeHolder&&this.placeHolder.anchor.set(0,0),this.cursor.x=this.inputOptions.padding+this.getCaretPosition();break;case"center":this.text.anchor.set(.5,0),this.text.x=this.inputOptions.padding+this.inputOptions.width/2,null!==this.placeHolder&&(this.placeHolder.anchor.set(.5,0),this.placeHolder.x=this.inputOptions.padding+this.inputOptions.width/2),this.cursor.x=this.inputOptions.padding+this.inputOptions.width/2-this.text.width/2+this.getCaretPosition();break;case"right":this.text.anchor.set(1,0),this.text.x=this.inputOptions.padding+this.inputOptions.width,null!==this.placeHolder&&(this.placeHolder.anchor.set(1,0),this.placeHolder.x=this.inputOptions.padding+this.inputOptions.width),this.cursor.x=this.inputOptions.padding+this.inputOptions.width}},d.prototype.checkDown=function(b){if(this.value||this.resetText(),this.input.checkPointerOver(b)){if(this.focus)return void this.setCaretOnclick(b);this.inputOptions.zoom&&!a.Zoomed&&this.zoomIn(),this.startFocus()}else this.focus===!0&&(this.endFocus(),this.inputOptions.zoom&&this.zoomOut())},d.prototype.update=function(){if(this.text.update(),this.placeHolder&&this.placeHolder.update(),this.focus){if(30!==this.cnt)return this.cnt++;this.cursor.visible=this.blink,this.blink=!this.blink,this.cnt=0}},d.prototype.endFocus=function(){var b=this;this.focus&&(this.domElement.removeEventListener(),this.blockInput===!0&&this.domElement.unblockKeyDownEvents(),this.focus=!1,0===this.value.length&&null!==this.placeHolder&&(this.placeHolder.visible=!0),this.cursor.visible=!1,this.game.device.desktop?setTimeout(function(){b.domElement.blur()},0):this.domElement.blur(),this.game.device.desktop||(a.KeyboardOpen=!1,a.onKeyboardClose.dispatch()))},d.prototype.startFocus=function(){var b=this;this.focus=!0,null!==this.placeHolder&&(this.placeHolder.visible=!1),this.game.device.desktop?setTimeout(function(){b.keyUpProcessor()},0):this.keyUpProcessor(),this.game.device.desktop||(a.KeyboardOpen=!0,a.onKeyboardOpen.dispatch())},d.prototype.keyUpProcessor=function(){this.domElement.addKeyUpListener(this.keyListener.bind(this)),this.domElement.focus(),this.blockInput===!0&&this.domElement.blockKeyDownEvents()},d.prototype.updateText=function(){var b="";if(this.inputOptions.type===a.InputType.password)for(var c=0;cparseInt(this.inputOptions.max)?this.value=this.domElement.value=this.inputOptions.max:this.value}else b=this.value;if(this.text.setText(b),this.text.width>this.inputOptions.width)this.text.anchor.x=1,this.text.x=this.inputOptions.padding+this.inputOptions.width;else switch(this.inputOptions.textAlign){case"left":this.text.anchor.set(0,0),this.text.x=this.inputOptions.padding;break;case"center":this.text.anchor.set(.5,0),this.text.x=this.inputOptions.padding+this.inputOptions.width/2;break;case"right":this.text.anchor.set(1,0),this.text.x=this.inputOptions.padding+this.inputOptions.width}},d.prototype.updateCursor=function(){if(this.text.width>this.inputOptions.width||"right"===this.inputOptions.textAlign)this.cursor.x=this.inputOptions.padding+this.inputOptions.width;else switch(this.inputOptions.textAlign){case"left":this.cursor.x=this.inputOptions.padding+this.getCaretPosition();break;case"center":this.cursor.x=this.inputOptions.padding+this.inputOptions.width/2-this.text.width/2+this.getCaretPosition()}},d.prototype.getCaretPosition=function(){var b=this.domElement.getCaretPosition();if(-1===b)return this.text.width;var c=this.value;if(this.inputOptions.type===a.InputType.password){c="";for(var d=0;d=e*c&&(e+1)*c>=b){d=e;break}b>(this.value.length-1)*c&&(d=this.value.length),this.startFocus(),this.domElement.setCaretPosition(d),this.updateCursor()},d.prototype.updateSelection=function(){if(this.domElement.hasSelection){var b=this.value;if(this.inputOptions.type===a.InputType.password){b="";for(var c=0;cwindow.innerWidth?this.windowScale=this.game.width/(1.5*b.width):this.windowScale=this.game.width/2/(1.5*b.width);var c=(this.game.width-1.5*b.width)/2/this.windowScale;this.game.world.scale.set(this.game.world.scale.x*this.windowScale,this.game.world.scale.y*this.windowScale),this.game.world.pivot.set(b.x-c,b.y-2*this.inputOptions.padding),a.Zoomed=!0}},d.prototype.zoomOut=function(){a.Zoomed&&(this.game.world.scale.set(this.game.world.scale.x/this.windowScale,this.game.world.scale.y/this.windowScale),this.game.world.pivot.set(0,0),a.Zoomed=!1)},d.prototype.keyListener=function(a){return this.value=this.getFormattedText(this.domElement.value),13===a.keyCode?void(this.focusOutOnEnter&&this.endFocus()):(this.updateText(),this.updateCursor(),this.updateSelection(),void a.preventDefault())},d.prototype.destroy=function(a){this.game.input.onDown.remove(this.checkDown,this),this.focusIn.removeAll(),this.focusOut.removeAll(),this.domElement.destroy(),c.prototype.destroy.call(this,a)},d.prototype.resetText=function(){this.setText()},d.prototype.setText=function(a){void 0===a&&(a=""),null!==this.placeHolder&&(a.length>0?this.placeHolder.visible=!1:this.placeHolder.visible=!0),this.value=this.getFormattedText(a),this.domElement.value=this.value,this.updateText(),this.updateCursor(),this.endFocus()},d.prototype.getFormattedText=function(a){switch(this.inputOptions.forceCase){default:case b.none:return a;case b.lower:return a.toLowerCase();case b.upper:return a.toUpperCase()}},d}(Phaser.Sprite);a.InputField=c}(PhaserInput||(PhaserInput={}));var PhaserInput;!function(a){var b=function(a){function b(b,c){var d=a.call(this,b,0,0)||this;d.bgColor=c.backgroundColor?parseInt(c.backgroundColor.slice(1),16):16777215,d.borderRadius=c.borderRadius="number"==typeof c.borderRadius?c.borderRadius:0,d.borderWidth=c.borderWidth="number"==typeof c.borderWidth?c.borderWidth:1,d.borderColor=c.borderColor?parseInt(c.borderColor.slice(1),16):9803157,d.boxAlpha=c.fillAlpha,d.padding=c.padding;var e,e=c.height,f=c.width;c.font&&(e=Math.max(parseInt(c.font.substr(0,c.font.indexOf("px")),10),e)),d.boxHeight=2*d.padding+e;var f=c.width;return d.boxWidth=2*d.padding+f,d.drawBox(),d}return __extends(b,a),b.prototype.resize=function(a){this.boxWidth=2*this.padding+a,this.drawBox()},b.prototype.drawBox=function(){this.clear().beginFill(this.bgColor,this.boxAlpha).lineStyle(this.borderWidth,this.borderColor,this.boxAlpha),this.borderRadius>0?this.drawRoundedRect(0,0,this.boxWidth,this.boxHeight,this.borderRadius):this.drawRect(0,0,this.boxWidth,this.boxHeight)},b}(Phaser.Graphics);a.InputBox=b}(PhaserInput||(PhaserInput={}));var PhaserInput;!function(a){var b=function(a){function b(b,c){var d=a.call(this,b,c.padding,c.padding)||this;return d.inputOptions=c,d}return __extends(b,a),b.prototype.updateSelection=function(a){var c=Phaser.Color.webToColor(this.inputOptions.selectionColor);this.clear(),this.beginFill(b.rgb2hex(c),c.a),this.drawRect(a.x,a.y,a.width,a.height-this.inputOptions.padding)},b.rgb2hex=function(a){return parseInt(("0"+a.r.toString(16)).slice(-2)+("0"+a.g.toString(16)).slice(-2)+("0"+a.b.toString(16)).slice(-2),16)},b}(Phaser.Graphics);a.SelectionHighlight=b}(PhaserInput||(PhaserInput={}));var PhaserInput;!function(a){var b=function(a){function b(b,c){var d=a.call(this,b,c.padding,c.padding)||this,e=c.height;return c.font&&(e=Math.max(parseInt(c.font.substr(0,c.font.indexOf("px")),10),e)),d.maskWidth=c.width,d.maskHeight=1.3*e,d.drawMask(),d}return __extends(b,a),b.prototype.resize=function(a){this.maskWidth=a,this.drawMask()},b.prototype.drawMask=function(){this.clear().beginFill(0).drawRect(0,0,this.maskWidth,this.maskHeight).endFill()},b}(Phaser.Graphics);a.TextMask=b}(PhaserInput||(PhaserInput={}));var PhaserInput;!function(a){a.Zoomed=!1,a.KeyboardOpen=!1,a.onKeyboardOpen=new Phaser.Signal,a.onKeyboardClose=new Phaser.Signal;var b=function(b){function c(a,c){var d=b.call(this,a,c)||this;return d.addInputFieldFactory(),d}return __extends(c,b),c.prototype.addInputFieldFactory=function(){Phaser.GameObjectFactory.prototype.inputField=function(b,c,d,e){void 0===e&&(e=this.world);var f=new a.InputField(this.game,b,c,d);return e.add(f)},Phaser.GameObjectCreator.prototype.inputField=function(b,c,d){return new a.InputField(this.game,b,c,d)}},c}(Phaser.Plugin);b.Zoomed=!1,b.KeyboardOpen=!1,b.onKeyboardOpen=new Phaser.Signal,b.onKeyboardClose=new Phaser.Signal,a.Plugin=b}(PhaserInput||(PhaserInput={}));
--------------------------------------------------------------------------------
/config/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "amd",
4 | "target": "es5",
5 | "sourceMap": true,
6 | "noImplicitAny": true,
7 | "removeComments": false,
8 | "declaration": true,
9 | "preserveConstEnums": true
10 | }
11 | }
--------------------------------------------------------------------------------
/config/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "align": [
4 | true,
5 | "parameters",
6 | "statements"
7 | ],
8 | "ban": false,
9 | "class-name": true,
10 | "curly": true,
11 | "eofline": true,
12 | "forin": true,
13 | "indent": [
14 | true,
15 | "spaces"
16 | ],
17 | "interface-name": true,
18 | "jsdoc-format": true,
19 | "label-position": true,
20 | "label-undefined": true,
21 | "max-line-length": [
22 | true,
23 | 200
24 | ],
25 | "member-access": true,
26 | "no-any": false,
27 | "no-arg": true,
28 | "no-conditional-assignment": true,
29 | "no-consecutive-blank-lines": true,
30 | "no-console": [
31 | true,
32 | "debug",
33 | "info",
34 | "time",
35 | "timeEnd",
36 | "trace"
37 | ],
38 | "no-construct": true,
39 | "no-constructor-vars": true,
40 | "no-debugger": true,
41 | "no-duplicate-key": true,
42 | "no-duplicate-variable": true,
43 | "no-empty": true,
44 | "no-eval": true,
45 | "no-inferrable-types": false,
46 | "no-internal-module": false,
47 | "no-null-keyword": false,
48 | "no-require-imports": false,
49 | "no-shadowed-variable": true,
50 | "no-string-literal": false,
51 | "no-switch-case-fall-through": false,
52 | "no-trailing-whitespace": true,
53 | "no-unreachable": true,
54 | "no-unused-expression": true,
55 | "no-unused-variable": true,
56 | "no-use-before-declare": true,
57 | "no-var-keyword": true,
58 | "no-var-requires": true,
59 | "object-literal-sort-keys": false,
60 | "one-line": [
61 | true,
62 | "check-open-brace",
63 | "check-catch",
64 | "check-else",
65 | "check-finally",
66 | "check-whitespace"
67 | ],
68 | "quotemark": [
69 | true,
70 | "single",
71 | "avoid-escape"
72 | ],
73 | "radix": true,
74 | "semicolon": [
75 | true,
76 | "always"
77 | ],
78 | "switch-default": false,
79 | "trailing-comma": [
80 | true,
81 | {
82 | "multiline": "never",
83 | "singleline": "never"
84 | }
85 | ],
86 | "triple-equals": [
87 | true,
88 | "allow-null-check"
89 | ],
90 | "typedef": [
91 | true,
92 | "call-signature",
93 | "parameter",
94 | "arrow-parameter",
95 | "property-declaration",
96 | "variable-declaration",
97 | "member-variable-declaration"
98 | ],
99 | "typedef-whitespace": [
100 | true,
101 | {
102 | "call-signature": "nospace",
103 | "index-signature": "nospace",
104 | "parameter": "nospace",
105 | "property-declaration": "nospace",
106 | "variable-declaration": "nospace"
107 | },
108 | {
109 | "call-signature": "onespace",
110 | "index-signature": "onespace",
111 | "parameter": "onespace",
112 | "property-declaration": "onespace",
113 | "variable-declaration": "onespace"
114 | }
115 | ],
116 | "use-strict": false,
117 | "variable-name": [
118 | true,
119 | "allow-leading-underscore",
120 | "ban-keywords"
121 | ],
122 | "whitespace": [
123 | true,
124 | "check-branch",
125 | "check-decl",
126 | "check-operator",
127 | "check-separator",
128 | "check-type"
129 | ]
130 | }
131 | }
--------------------------------------------------------------------------------
/example/images/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azerion/phaser-input/08f1c327fe11341d91796d3acc43efc6ae7dea24/example/images/bg.png
--------------------------------------------------------------------------------
/example/images/btn_clean.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azerion/phaser-input/08f1c327fe11341d91796d3acc43efc6ae7dea24/example/images/btn_clean.png
--------------------------------------------------------------------------------
/example/images/inputfield.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/azerion/phaser-input/08f1c327fe11341d91796d3acc43efc6ae7dea24/example/images/inputfield.png
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Login example for Phaser Input
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
27 |
28 |
29 |
167 |
168 |
169 |
170 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@azerion/phaser-input",
3 | "author": "Azerion",
4 | "version": "2.0.5",
5 | "description": "Adds input boxes to Phaser like CanvasInput, but also works for WebGL and Mobile, made for Phaser only.",
6 | "contributors": [
7 | {
8 | "name": "Ale Bles",
9 | "email": "a.bles@azerion.com"
10 | }
11 | ],
12 | "repository": {
13 | "type": "git",
14 | "url": "git@github.com:azerion/phaser-input.git"
15 | },
16 | "licenses": [
17 | {
18 | "type": "MIT",
19 | "url": "https://github.com/azerion/phaser-input/raw/master/LICENSE"
20 | }
21 | ],
22 | "config": {
23 | "name": "phaser-input"
24 | },
25 | "devDependencies": {
26 | "@azerion/phaser-nineslice": "^2.0.0",
27 | "grunt": "1.0.x",
28 | "grunt-banner": "^0.6.0",
29 | "grunt-contrib-clean": "0.6.0",
30 | "grunt-contrib-connect": "^0.11.2",
31 | "grunt-contrib-uglify": "^0.11.0",
32 | "grunt-contrib-watch": "^0.6.1",
33 | "grunt-ts": "^6.0.0-beta.11",
34 | "phaser": "2.6.2",
35 | "typescript": "2.3.x"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ts/InputElement.ts:
--------------------------------------------------------------------------------
1 | module PhaserInput {
2 |
3 | export enum InputType {
4 | text,
5 | password,
6 | number
7 | }
8 |
9 | export class InputElement {
10 | private element: HTMLInputElement;
11 |
12 | private keyUpCallback: () => void;
13 |
14 | private inputChangeCallback: () => void;
15 |
16 | private type: InputType;
17 |
18 | private id: string;
19 |
20 | private game: Phaser.Game;
21 |
22 | private focusIn: Phaser.Signal;
23 |
24 | private focusOut: Phaser.Signal;
25 |
26 | constructor(game: Phaser.Game, id: string, type: InputType = InputType.text, value: string = '', focusIn?: Phaser.Signal, focusOut?: Phaser.Signal) {
27 | this.id = id;
28 | this.type = type;
29 | this.game = game;
30 | this.focusIn = focusIn;
31 | this.focusOut = focusOut;
32 |
33 | let canvasTopX: number = this.game.canvas.getBoundingClientRect().top + document.body.scrollTop;
34 |
35 | this.element = document.createElement('input');
36 |
37 | this.element.id = id;
38 | this.element.style.position = 'absolute';
39 | this.element.style.top = canvasTopX + 'px';
40 | this.element.style.left = (-40).toString() + 'px';
41 | this.element.style.width = (10).toString() + 'px';
42 | this.element.style.height = (10).toString() + 'px';
43 | this.element.style.border = '0px';
44 | this.element.value = this.value;
45 | this.element.type = InputType[type];
46 |
47 | this.element.addEventListener('focusin', (): void => {
48 | if (this.focusIn instanceof Phaser.Signal) {
49 | this.focusIn.dispatch();
50 | }
51 | });
52 | this.element.addEventListener('focusout', (): void => {
53 | if (this.focusOut instanceof Phaser.Signal) {
54 | this.focusOut.dispatch();
55 | }
56 | });
57 |
58 | document.body.appendChild(this.element);
59 | }
60 |
61 | public addKeyUpListener(callback: () => void): void {
62 | this.keyUpCallback = callback;
63 | document.addEventListener('keyup', this.keyUpCallback);
64 | this.element.addEventListener('input', this.keyUpCallback);
65 |
66 | }
67 |
68 | /**
69 | * Captures the keyboard event on keydown, used to prevent it going from input field to sprite
70 | **/
71 | public blockKeyDownEvents(): void {
72 | document.addEventListener('keydown', this.preventKeyPropagation);
73 | }
74 |
75 | /**
76 | * To prevent bubbling of keyboard event from input field to sprite
77 | **/
78 | private preventKeyPropagation(evt: KeyboardEvent): void{
79 | if(evt.stopPropagation){
80 | evt.stopPropagation();
81 | } else {
82 | //for IE < 9
83 | event.cancelBubble = true;
84 | }
85 | }
86 |
87 | /**
88 | * Remove listener that captures keydown keyboard events
89 | **/
90 | public unblockKeyDownEvents(): void {
91 | document.removeEventListener('keydown', this.preventKeyPropagation);
92 | }
93 |
94 | public removeEventListener(): void {
95 | document.removeEventListener('keyup', this.keyUpCallback);
96 | this.element.removeEventListener('input', this.keyUpCallback);
97 | }
98 |
99 | public destroy() {
100 | document.body.removeChild(this.element);
101 | }
102 |
103 | public setMax(max: string, min?: string) {
104 | if (max === undefined) {
105 | return;
106 | }
107 |
108 | if (this.type === InputType.text || this.type === InputType.password) {
109 | this.element.maxLength = parseInt(max, 10);
110 | } else if (this.type === InputType.number) {
111 | this.element.max = max;
112 | if (min === undefined) {
113 | return;
114 | }
115 |
116 | this.element.min = min;
117 | }
118 | }
119 |
120 | get value(): string {
121 | return this.element.value;
122 | }
123 |
124 | set value(value: string) {
125 | this.element.value = value;
126 | }
127 |
128 | public focus(): void {
129 | this.element.focus();
130 | if (!this.game.device.desktop && this.game.device.chrome) {
131 | let originalWidth = window.innerWidth,
132 | originalHeight = window.innerHeight;
133 |
134 | let kbAppeared: boolean = false;
135 | let interval: number = setInterval((): void => {
136 | if (originalWidth > window.innerWidth || originalHeight > window.innerHeight) {
137 | kbAppeared = true;
138 | }
139 |
140 | if (kbAppeared && originalWidth === window.innerWidth && originalHeight === window.innerHeight) {
141 | if (this.focusOut instanceof Phaser.Signal) {
142 | this.focusOut.dispatch();
143 | }
144 | clearInterval(interval);
145 | }
146 | }, 50);
147 | }
148 | }
149 |
150 | public blur(): void {
151 | this.element.blur();
152 | }
153 |
154 | get hasSelection () {
155 | if (this.type === InputType.number) {
156 | return false;
157 | }
158 |
159 | return this.element.selectionStart !== this.element.selectionEnd;
160 | }
161 |
162 | get caretStart() {
163 | return this.element.selectionEnd;
164 | }
165 |
166 | get caretEnd() {
167 | return this.element.selectionStart;
168 | }
169 |
170 | public getCaretPosition() {
171 | if (this.type === InputType.number) {
172 | return -1;
173 | }
174 | return this.element.selectionStart;
175 | }
176 |
177 | public setCaretPosition(pos: number) {
178 | if (this.type === InputType.number) {
179 | return ;
180 | }
181 | this.element.setSelectionRange(pos, pos);
182 | }
183 | }
184 | }
--------------------------------------------------------------------------------
/ts/InputField.ts:
--------------------------------------------------------------------------------
1 | module PhaserInput {
2 | import Text = Phaser.Text;
3 |
4 | export enum ForceCase {
5 | none,
6 | lower,
7 | upper
8 | }
9 |
10 | export interface InputOptions extends Phaser.PhaserTextStyle {
11 | x?: number;
12 | y?: number;
13 | placeHolder?: string;
14 | fillAlpha?: number;
15 | width?: number;
16 | height?: number;
17 | padding?: number;
18 | borderWidth?: number;
19 | borderColor?: string;
20 | borderRadius?: number;
21 | cursorColor?: string;
22 | placeHolderColor?: string;
23 | type?: InputType;
24 | forceCase?: ForceCase;
25 | min?: string;
26 | max?: string;
27 | textAlign?: string;
28 | selectionColor?: string;
29 | zoom?: boolean;
30 | }
31 |
32 | export class InputField extends Phaser.Sprite {
33 | public focusOutOnEnter: boolean = true;
34 |
35 | private placeHolder:Phaser.Text = null;
36 |
37 | private box: InputBox = null;
38 |
39 | private textMask: TextMask;
40 |
41 | private focus:boolean = false;
42 |
43 | private cursor:Phaser.Text;
44 |
45 | private text:Phaser.Text;
46 |
47 | private offscreenText: Phaser.Text;
48 |
49 | public value:string = '';
50 |
51 | private inputOptions: InputOptions;
52 |
53 | private domElement: InputElement;
54 |
55 | private selection: SelectionHighlight;
56 |
57 | private windowScale: number = 1;
58 |
59 | public blockInput: boolean = true;
60 |
61 | public focusIn: Phaser.Signal = new Phaser.Signal();
62 |
63 | public focusOut: Phaser.Signal = new Phaser.Signal();
64 |
65 | get width(): number {
66 | return this.inputOptions.width;
67 | }
68 |
69 | set width(width: number) {
70 | this.inputOptions.width = width;
71 | this.box.resize(width);
72 | this.textMask.resize(width);
73 | this.updateTextAlignment();
74 | }
75 |
76 | constructor(game:Phaser.Game, x:number, y:number, inputOptions:InputOptions = {}) {
77 | super(game, x, y);
78 |
79 | //Parse the options
80 | this.inputOptions = inputOptions;
81 | this.inputOptions.width = (typeof inputOptions.width === 'number') ? inputOptions.width : 150;
82 | this.inputOptions.padding = (typeof inputOptions.padding === 'number') ? inputOptions.padding : 0;
83 | this.inputOptions.textAlign = inputOptions.textAlign || 'left';
84 | this.inputOptions.type = inputOptions.type || InputType.text;
85 | this.inputOptions.forceCase = (inputOptions.forceCase) ? inputOptions.forceCase : ForceCase.none;
86 | this.inputOptions.borderRadius = (typeof inputOptions.borderRadius === 'number') ? inputOptions.borderRadius : 0;
87 | this.inputOptions.height = (typeof inputOptions.height === 'number') ? inputOptions.height : 14;
88 | this.inputOptions.fillAlpha = (inputOptions.fillAlpha === undefined) ? 1 : inputOptions.fillAlpha;
89 | this.inputOptions.selectionColor = inputOptions.selectionColor || 'rgba(179, 212, 253, 0.8)';
90 | this.inputOptions.zoom = (!game.device.desktop) ? inputOptions.zoom || false : false;
91 |
92 | //create the input box
93 | this.box = new InputBox(this.game, inputOptions);
94 | this.setTexture(this.box.generateTexture());
95 |
96 | //create the mask that will be used for the texts
97 | this.textMask = new TextMask(this.game, inputOptions);
98 | this.addChild(this.textMask);
99 |
100 | //Create the hidden dom elements
101 | this.domElement = new InputElement(this.game, 'phaser-input-' + (Math.random() * 10000 | 0).toString(),
102 | this.inputOptions.type, this.value, this.focusIn, this.focusOut);
103 | this.domElement.setMax(this.inputOptions.max, this.inputOptions.min);
104 |
105 | this.selection = new SelectionHighlight(this.game, this.inputOptions);
106 | this.selection.mask = this.textMask;
107 | this.addChild(this.selection);
108 |
109 | if (inputOptions.placeHolder && inputOptions.placeHolder.length > 0) {
110 | this.placeHolder = new Phaser.Text(game, this.inputOptions.padding, this.inputOptions.padding,
111 | inputOptions.placeHolder, {
112 | font: inputOptions.font || '14px Arial',
113 | fontWeight: inputOptions.fontWeight || 'normal',
114 | fill: inputOptions.placeHolderColor || '#bfbebd'
115 | });
116 | this.placeHolder.mask = this.textMask;
117 | this.addChild(this.placeHolder);
118 | }
119 |
120 | this.cursor = new Phaser.Text(game, this.inputOptions.padding, this.inputOptions.padding - 2, '|', {
121 | font: inputOptions.font || '14px Arial',
122 | fontWeight: inputOptions.fontWeight || 'normal',
123 | fill: inputOptions.cursorColor || '#000000'
124 | });
125 | this.cursor.visible = false;
126 | this.addChild(this.cursor);
127 |
128 | this.text = new Phaser.Text(game, this.inputOptions.padding, this.inputOptions.padding, '', {
129 | font: inputOptions.font || '14px Arial',
130 | fontWeight: inputOptions.fontWeight || 'normal',
131 | fill: inputOptions.fill || '#000000'
132 | });
133 | this.text.mask = this.textMask;
134 | this.addChild(this.text);
135 |
136 | this.offscreenText = new Phaser.Text(game, this.inputOptions.padding, this.inputOptions.padding, '', {
137 | font: inputOptions.font || '14px Arial',
138 | fontWeight: inputOptions.fontWeight || 'normal',
139 | fill: inputOptions.fill || '#000000'
140 | });
141 |
142 | this.updateTextAlignment();
143 |
144 | this.inputEnabled = true;
145 | this.input.useHandCursor = true;
146 |
147 | this.game.input.onDown.add(this.checkDown, this);
148 | this.focusOut.add((): void => {
149 | if (PhaserInput.KeyboardOpen) {
150 | this.endFocus();
151 | if (this.inputOptions.zoom) {
152 | this.zoomOut();
153 | }
154 | }
155 | });
156 | }
157 |
158 | private updateTextAlignment(): void {
159 | switch (this.inputOptions.textAlign) {
160 | case 'left':
161 | this.text.anchor.set(0, 0);
162 | this.text.x = this.inputOptions.padding;
163 | if (null !== this.placeHolder) {
164 | this.placeHolder.anchor.set(0, 0);
165 | }
166 | this.cursor.x = this.inputOptions.padding + this.getCaretPosition();
167 | break;
168 | case 'center':
169 | this.text.anchor.set(0.5, 0);
170 | this.text.x = this.inputOptions.padding + this.inputOptions.width / 2;
171 | if (null !== this.placeHolder) {
172 | this.placeHolder.anchor.set(0.5, 0);
173 | this.placeHolder.x = this.inputOptions.padding + this.inputOptions.width / 2;
174 | }
175 | this.cursor.x = this.inputOptions.padding + this.inputOptions.width / 2 - this.text.width / 2 + this.getCaretPosition();
176 | break;
177 | case 'right':
178 | this.text.anchor.set(1, 0);
179 | this.text.x = this.inputOptions.padding + this.inputOptions.width;
180 | if (null !== this.placeHolder) {
181 | this.placeHolder.anchor.set(1, 0);
182 | this.placeHolder.x = this.inputOptions.padding + this.inputOptions.width;
183 | }
184 | this.cursor.x = this.inputOptions.padding + this.inputOptions.width;
185 | break;
186 | }
187 | }
188 |
189 | /**
190 | * This is a generic input down handler for the game.
191 | * if the input object is clicked, we gain focus on it and create the dom element
192 | *
193 | * If there was focus on the element previously, but clicked outside of it, the element will loose focus
194 | * and no keyboard events will be registered anymore
195 | *
196 | * @param e Phaser.Pointer
197 | */
198 | private checkDown(e: Phaser.Pointer): void
199 | {
200 | if(!this.value){
201 | this.resetText();
202 | }
203 | if (this.input.checkPointerOver(e)) {
204 | if (this.focus) {
205 | this.setCaretOnclick(e);
206 | return;
207 | }
208 |
209 | if (this.inputOptions.zoom && !PhaserInput.Zoomed) {
210 | this.zoomIn();
211 | }
212 | this.startFocus();
213 | } else {
214 | if (this.focus === true) {
215 | this.endFocus();
216 | if (this.inputOptions.zoom) {
217 | this.zoomOut();
218 | }
219 | }
220 | }
221 | }
222 |
223 | /**
224 | * Update function makes the cursor blink, it uses two private properties to make it toggle
225 | *
226 | * @returns {number}
227 | */
228 | private blink:boolean = true;
229 | private cnt: number = 0;
230 | public update() {
231 | this.text.update();
232 | if (this.placeHolder) {
233 | this.placeHolder.update();
234 | }
235 | if (!this.focus) {
236 | return;
237 | }
238 |
239 | if (this.cnt !== 30) {
240 | return this.cnt++;
241 | }
242 |
243 | this.cursor.visible = this.blink;
244 | this.blink = !this.blink;
245 | this.cnt = 0;
246 | }
247 |
248 | /**
249 | * Focus is lost on the input element, we disable the cursor and remove the hidden input element
250 | */
251 | public endFocus() {
252 | if(!this.focus){
253 | return;
254 | }
255 |
256 | this.domElement.removeEventListener();
257 |
258 | if(this.blockInput === true) {
259 | this.domElement.unblockKeyDownEvents();
260 | }
261 |
262 | this.focus = false;
263 | if (this.value.length === 0 && null !== this.placeHolder) {
264 | this.placeHolder.visible = true;
265 | }
266 | this.cursor.visible = false;
267 |
268 | if (this.game.device.desktop) {
269 | //Timeout is a chrome hack
270 | setTimeout(() => {
271 | this.domElement.blur();
272 | }, 0);
273 | } else {
274 | this.domElement.blur();
275 | }
276 |
277 | if (!this.game.device.desktop) {
278 | PhaserInput.KeyboardOpen = false;
279 | PhaserInput.onKeyboardClose.dispatch();
280 | }
281 | }
282 |
283 | /**
284 | *
285 | */
286 | public startFocus() {
287 | this.focus = true;
288 |
289 | if (null !== this.placeHolder) {
290 | this.placeHolder.visible = false;
291 | }
292 |
293 | if (this.game.device.desktop) {
294 | //Timeout is a chrome hack
295 | setTimeout(() => {
296 | this.keyUpProcessor();
297 | }, 0);
298 | } else {
299 | this.keyUpProcessor();
300 | }
301 |
302 | if (!this.game.device.desktop) {
303 | PhaserInput.KeyboardOpen = true;
304 | PhaserInput.onKeyboardOpen.dispatch();
305 | }
306 | }
307 |
308 | private keyUpProcessor():void {
309 | this.domElement.addKeyUpListener(this.keyListener.bind(this));
310 | this.domElement.focus();
311 |
312 | if(this.blockInput === true) {
313 | this.domElement.blockKeyDownEvents();
314 | }
315 | }
316 |
317 | /**
318 | * Update the text value in the box, and make sure the cursor is positioned correctly
319 | */
320 | private updateText()
321 | {
322 | var text: string = '';
323 | if (this.inputOptions.type === InputType.password) {
324 | for (let i = 0; i < this.value.length; i++) {
325 | text += '*';
326 | }
327 | }else if (this.inputOptions.type === InputType.number) {
328 | var val = parseInt(this.value);
329 | if (val < parseInt(this.inputOptions.min)) {
330 | text = this.value = this.domElement.value = this.inputOptions.min;
331 | } else if (val > parseInt(this.inputOptions.max)) {
332 | text = this.value = this.domElement.value = this.inputOptions.max;
333 | } else {
334 | text = this.value;
335 | }
336 | } else {
337 | text = this.value;
338 | }
339 |
340 | this.text.setText(text);
341 |
342 | if (this.text.width > this.inputOptions.width) {
343 | this.text.anchor.x = 1;
344 | this.text.x = this.inputOptions.padding + this.inputOptions.width;
345 | } else {
346 | switch (this.inputOptions.textAlign) {
347 | case 'left':
348 | this.text.anchor.set(0, 0);
349 | this.text.x = this.inputOptions.padding;
350 | break;
351 | case 'center':
352 | this.text.anchor.set(0.5, 0);
353 | this.text.x = this.inputOptions.padding + this.inputOptions.width / 2;
354 | break;
355 | case 'right':
356 | this.text.anchor.set(1, 0);
357 | this.text.x = this.inputOptions.padding + this.inputOptions.width;
358 | break;
359 | }
360 | }
361 | }
362 |
363 | /**
364 | * Updates the position of the caret in the phaser input field
365 | */
366 | private updateCursor() {
367 | if (this.text.width > this.inputOptions.width || this.inputOptions.textAlign === 'right') {
368 | this.cursor.x = this.inputOptions.padding + this.inputOptions.width;
369 | } else {
370 | switch (this.inputOptions.textAlign) {
371 | case 'left':
372 | this.cursor.x = this.inputOptions.padding + this.getCaretPosition();
373 | break;
374 | case 'center':
375 | this.cursor.x = this.inputOptions.padding + this.inputOptions.width / 2 - this.text.width / 2 + this.getCaretPosition();
376 | break;
377 | }
378 | }
379 | }
380 |
381 | /**
382 | * Fetches the carrot position from the dom element. This one changes when you use the keyboard to navigate the element
383 | *
384 | * @returns {number}
385 | */
386 | private getCaretPosition() {
387 | var caretPosition: number = this.domElement.getCaretPosition();
388 | if (-1 === caretPosition) {
389 | return this.text.width;
390 | }
391 |
392 | var text = this.value;
393 | if (this.inputOptions.type === InputType.password) {
394 | text = '';
395 | for (let i = 0; i < this.value.length; i++) {
396 | text += '*';
397 | }
398 | }
399 |
400 | this.offscreenText.setText(text.slice(0, caretPosition));
401 |
402 | return this.offscreenText.width;
403 | }
404 |
405 | /**
406 | * Set the caret when a click was made in the input field
407 | *
408 | * @param e
409 | */
410 | private setCaretOnclick(e: Phaser.Pointer) {
411 | var localX: number = (this.text.toLocal(new PIXI.Point(e.x, e.y), this.game.world)).x;
412 | if (this.inputOptions.textAlign && this.inputOptions.textAlign === 'center') {
413 | localX += this.text.width / 2;
414 | }
415 |
416 | var characterWidth: number = this.text.width / this.value.length;
417 | var index: number = 0;
418 | for (let i: number = 0; i < this.value.length; i++) {
419 | if (localX >= i * characterWidth && localX <= (i + 1) * characterWidth) {
420 | index = i;
421 | break;
422 | }
423 | }
424 |
425 | if (localX > (this.value.length - 1) * characterWidth) {
426 | index = this.value.length;
427 | }
428 |
429 | this.startFocus();
430 |
431 | this.domElement.setCaretPosition(index);
432 |
433 | this.updateCursor();
434 | }
435 |
436 | /**
437 | * This checks if a select has been made, and if so highlight it with blue
438 | */
439 | private updateSelection(): void {
440 | if (this.domElement.hasSelection) {
441 | var text = this.value;
442 | if (this.inputOptions.type === InputType.password) {
443 | text = '';
444 | for (let i = 0; i < this.value.length; i++) {
445 | text += '*';
446 | }
447 | }
448 | text = text.substring(this.domElement.caretStart, this.domElement.caretEnd);
449 | this.offscreenText.setText(text);
450 |
451 | this.selection.updateSelection(this.offscreenText.getBounds());
452 |
453 | switch (this.inputOptions.textAlign) {
454 | case 'left':
455 | this.selection.x = this.inputOptions.padding;
456 | break;
457 | case 'center':
458 | this.selection.x = this.inputOptions.padding + this.inputOptions.width / 2 - this.text.width / 2;
459 | break;
460 | }
461 | } else {
462 | this.selection.clear();
463 | }
464 | }
465 |
466 | private zoomIn(): void {
467 | if (PhaserInput.Zoomed) {
468 | return;
469 | }
470 |
471 | let bounds: PIXI.Rectangle = this.getBounds();
472 | if (window.innerHeight > window.innerWidth) {
473 | this.windowScale = this.game.width / (bounds.width * 1.5);
474 | } else {
475 | this.windowScale = (this.game.width / 2) / (bounds.width * 1.5);
476 | }
477 |
478 | let offsetX: number = ((this.game.width - bounds.width * 1.5) / 2) / this.windowScale;
479 | this.game.world.scale.set(this.game.world.scale.x * this.windowScale, this.game.world.scale.y * this.windowScale);
480 | this.game.world.pivot.set(bounds.x - offsetX, bounds.y - this.inputOptions.padding * 2);
481 | PhaserInput.Zoomed = true;
482 | }
483 |
484 | private zoomOut(): void {
485 | if (!PhaserInput.Zoomed) {
486 | return;
487 | }
488 |
489 | this.game.world.scale.set(this.game.world.scale.x / this.windowScale, this.game.world.scale.y / this.windowScale);
490 | this.game.world.pivot.set(0, 0);
491 | PhaserInput.Zoomed = false;
492 | }
493 |
494 | /**
495 | * Event fired when a key is pressed, it takes the value from the hidden input field and adds it as its own
496 | */
497 | private keyListener(evt: KeyboardEvent)
498 | {
499 | this.value = this.getFormattedText(this.domElement.value);
500 | if (evt.keyCode === 13) {
501 | if(this.focusOutOnEnter) {
502 | this.endFocus();
503 | }
504 | return;
505 | }
506 |
507 | this.updateText();
508 | this.updateCursor();
509 | this.updateSelection();
510 |
511 | evt.preventDefault();
512 | }
513 |
514 | /**
515 | * We overwrite the destroy method because we want to delete the (hidden) dom element when the inputField was removed
516 | */
517 | public destroy(destroyChildren?: boolean) {
518 | this.game.input.onDown.remove(this.checkDown, this);
519 | this.focusIn.removeAll();
520 | this.focusOut.removeAll();
521 | this.domElement.destroy();
522 |
523 | super.destroy(destroyChildren);
524 | }
525 |
526 | /**
527 | * Resets the text to an empty value
528 | */
529 | public resetText() {
530 | this.setText();
531 | }
532 |
533 | public setText(text: string = ''): void {
534 | if (null !== this.placeHolder) {
535 | if (text.length > 0) {
536 | this.placeHolder.visible = false;
537 | } else {
538 | this.placeHolder.visible = true;
539 | }
540 | }
541 |
542 | this.value = this.getFormattedText(text);
543 | this.domElement.value = this.value;
544 | this.updateText();
545 | this.updateCursor();
546 | this.endFocus();
547 | }
548 |
549 | /**
550 | * Returns text formatted by rules stated in inputOptions
551 | * @param text
552 | */
553 | private getFormattedText(text: string): string {
554 | switch (this.inputOptions.forceCase) {
555 | default:
556 | case ForceCase.none:
557 | return text;
558 | case ForceCase.lower:
559 | return text.toLowerCase();
560 | case ForceCase.upper:
561 | return text.toUpperCase();
562 | }
563 | }
564 | }
565 | }
566 |
--------------------------------------------------------------------------------
/ts/Objects/InputBox.ts:
--------------------------------------------------------------------------------
1 | module PhaserInput {
2 | export class InputBox extends Phaser.Graphics {
3 | private bgColor: number;
4 | private borderRadius: number;
5 | private borderColor: number;
6 | private borderWidth: number;
7 | private boxAlpha: number;
8 | private boxHeight: number;
9 | private padding: number;
10 | private boxWidth: number;
11 |
12 | constructor(game: Phaser.Game, inputOptions: InputOptions) {
13 | super(game, 0, 0);
14 |
15 | this.bgColor = (inputOptions.backgroundColor) ? parseInt(inputOptions.backgroundColor.slice(1), 16) : 0xffffff;
16 | this.borderRadius = inputOptions.borderRadius = (typeof inputOptions.borderRadius === 'number') ? inputOptions.borderRadius : 0;
17 | this.borderWidth = inputOptions.borderWidth = (typeof inputOptions.borderWidth === 'number') ? inputOptions.borderWidth : 1;
18 | this.borderColor = (inputOptions.borderColor) ? parseInt(inputOptions.borderColor.slice(1), 16) : 0x959595;
19 | this.boxAlpha = inputOptions.fillAlpha;
20 | this.padding = inputOptions.padding;
21 |
22 | var height: number = inputOptions.height;
23 | var width: number = inputOptions.width;
24 |
25 | var height: number;
26 | if (inputOptions.font) {
27 | //fetch height from font;
28 | height = Math.max(parseInt(inputOptions.font.substr(0, inputOptions.font.indexOf('px')), 10), height);
29 | }
30 |
31 | this.boxHeight = this.padding * 2 + height;
32 | var width = inputOptions.width;
33 | this.boxWidth = this.padding * 2 + width;
34 |
35 | this.drawBox();
36 | }
37 |
38 | public resize(newWidth: number): void {
39 | this.boxWidth = this.padding * 2 + newWidth;
40 |
41 | this.drawBox();
42 | }
43 |
44 | private drawBox(): void {
45 | this.clear()
46 | .beginFill(this.bgColor, this.boxAlpha)
47 | .lineStyle(this.borderWidth, this.borderColor, this.boxAlpha);
48 |
49 | if (this.borderRadius > 0) {
50 | this.drawRoundedRect(0, 0, this.boxWidth, this.boxHeight, this.borderRadius);
51 | } else {
52 | this.drawRect(0, 0, this.boxWidth, this.boxHeight);
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/ts/Objects/SelectionHighlight.ts:
--------------------------------------------------------------------------------
1 | module PhaserInput {
2 | export class SelectionHighlight extends Phaser.Graphics {
3 | private inputOptions: InputOptions;
4 |
5 | constructor(game: Phaser.Game, inputOptions: InputOptions) {
6 | super(game, inputOptions.padding, inputOptions.padding);
7 |
8 | this.inputOptions = inputOptions;
9 | }
10 |
11 | public updateSelection(rect: PIXI.Rectangle): void {
12 | var color = Phaser.Color.webToColor(this.inputOptions.selectionColor);
13 |
14 | this.clear();
15 | this.beginFill(SelectionHighlight.rgb2hex(color), color.a);
16 | this.drawRect(rect.x, rect.y, rect.width, rect.height - this.inputOptions.padding);
17 | }
18 |
19 | public static rgb2hex(color: {r: number, g: number, b: number, a: number}): number {
20 | return parseInt(("0" + color.r.toString(16)).slice(-2) +
21 | ("0" + color.g.toString(16)).slice(-2) +
22 | ("0" + color.b.toString(16)).slice(-2), 16);
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/ts/Objects/TextMask.ts:
--------------------------------------------------------------------------------
1 | module PhaserInput {
2 | export class TextMask extends Phaser.Graphics {
3 | private maskWidth: number;
4 | private maskHeight: number;
5 |
6 | constructor(game: Phaser.Game, inputOptions: InputOptions) {
7 | super(game, inputOptions.padding, inputOptions.padding);
8 |
9 | var height = inputOptions.height;
10 |
11 | if (inputOptions.font) {
12 | //fetch height from font;
13 | height = Math.max(parseInt(inputOptions.font.substr(0, inputOptions.font.indexOf('px')), 10), height);
14 | }
15 | this.maskWidth = inputOptions.width;
16 | this.maskHeight = height * 1.3;
17 | this.drawMask();
18 | }
19 |
20 | public resize(newWidth: number): void {
21 | this.maskWidth = newWidth;
22 | this.drawMask();
23 | }
24 |
25 | private drawMask(): void {
26 | this.clear()
27 | .beginFill(0x000000)
28 | .drawRect(0, 0, this.maskWidth, this.maskHeight)
29 | .endFill();
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/ts/Plugin.ts:
--------------------------------------------------------------------------------
1 | module PhaserInput {
2 | export var Zoomed: boolean = false;
3 | export var KeyboardOpen: boolean = false;
4 | export const onKeyboardOpen: Phaser.Signal = new Phaser.Signal();
5 | export const onKeyboardClose: Phaser.Signal = new Phaser.Signal()
6 |
7 | export interface InputFieldObjectFactory extends Phaser.GameObjectFactory {
8 | inputField: (x: number, y: number, inputOptions?: PhaserInput.InputOptions, group?: Phaser.Group) => PhaserInput.InputField;
9 | }
10 |
11 | export interface InputFieldObjectCreator extends Phaser.GameObjectCreator {
12 | inputField: (x: number, y: number, inputOptions?: PhaserInput.InputOptions) => PhaserInput.InputField;
13 | }
14 |
15 | export interface InputFieldGame extends Phaser.Game {
16 | add: InputFieldObjectFactory;
17 | make: InputFieldObjectCreator;
18 | }
19 |
20 | export class Plugin extends Phaser.Plugin {
21 | public static Zoomed: boolean = false;
22 | public static KeyboardOpen: boolean = false;
23 | public static onKeyboardOpen: Phaser.Signal = new Phaser.Signal();
24 | public static onKeyboardClose: Phaser.Signal = new Phaser.Signal();
25 |
26 | constructor(game: Phaser.Game, parent: Phaser.PluginManager) {
27 | super(game, parent);
28 |
29 | this.addInputFieldFactory();
30 | }
31 |
32 | /**
33 | * Extends the GameObjectFactory prototype with the support of adding InputField. this allows us to add InputField methods to the game just like any other object:
34 | * game.add.InputField();
35 | */
36 | private addInputFieldFactory() {
37 | (Phaser.GameObjectFactory.prototype).inputField = function (x: number, y: number, inputOptions: PhaserInput.InputOptions, group?: Phaser.Group): PhaserInput.InputField {
38 | if (group === undefined) {
39 | group = this.world;
40 | }
41 |
42 | var nineSliceObject = new PhaserInput.InputField(this.game, x, y, inputOptions);
43 |
44 | return group.add(nineSliceObject);
45 | };
46 |
47 | (Phaser.GameObjectCreator.prototype).inputField = function (x: number, y: number, inputOptions: PhaserInput.InputOptions): PhaserInput.InputField {
48 | return new PhaserInput.InputField(this.game, x, y, inputOptions);
49 | };
50 | }
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ts/definitions.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "align": [
4 | true,
5 | "parameters",
6 | "statements"
7 | ],
8 | "ban": false,
9 | "class-name": true,
10 | "curly": true,
11 | "eofline": true,
12 | "forin": true,
13 | "indent": [
14 | true,
15 | "spaces"
16 | ],
17 | "interface-name": true,
18 | "jsdoc-format": true,
19 | "label-position": true,
20 | "label-undefined": true,
21 | "max-line-length": [
22 | true,
23 | 200
24 | ],
25 | "member-access": true,
26 | "no-any": false,
27 | "no-arg": true,
28 | "no-conditional-assignment": true,
29 | "no-consecutive-blank-lines": true,
30 | "no-console": [
31 | true,
32 | "debug",
33 | "info",
34 | "time",
35 | "timeEnd",
36 | "trace"
37 | ],
38 | "no-construct": true,
39 | "no-constructor-vars": true,
40 | "no-debugger": true,
41 | "no-duplicate-key": true,
42 | "no-duplicate-variable": true,
43 | "no-empty": true,
44 | "no-eval": true,
45 | "no-inferrable-types": false,
46 | "no-internal-module": false,
47 | "no-null-keyword": false,
48 | "no-require-imports": true,
49 | "no-shadowed-variable": true,
50 | "no-string-literal": false,
51 | "no-switch-case-fall-through": true,
52 | "no-trailing-whitespace": true,
53 | "no-unreachable": true,
54 | "no-unused-expression": true,
55 | "no-unused-variable": true,
56 | "no-use-before-declare": true,
57 | "no-var-keyword": true,
58 | "no-var-requires": true,
59 | "object-literal-sort-keys": false,
60 | "one-line": [
61 | true,
62 | "check-open-brace",
63 | "check-catch",
64 | "check-else",
65 | "check-finally",
66 | "check-whitespace"
67 | ],
68 | "quotemark": [
69 | true,
70 | "single",
71 | "avoid-escape"
72 | ],
73 | "radix": true,
74 | "semicolon": [
75 | true,
76 | "always"
77 | ],
78 | "switch-default": true,
79 | "trailing-comma": [
80 | true,
81 | {
82 | "multiline": "never",
83 | "singleline": "never"
84 | }
85 | ],
86 | "triple-equals": [
87 | true,
88 | "allow-null-check"
89 | ],
90 | "typedef": [
91 | true,
92 | "call-signature",
93 | "parameter",
94 | "arrow-parameter",
95 | "property-declaration",
96 | "variable-declaration",
97 | "member-variable-declaration"
98 | ],
99 | "typedef-whitespace": [
100 | true,
101 | {
102 | "call-signature": "nospace",
103 | "index-signature": "nospace",
104 | "parameter": "nospace",
105 | "property-declaration": "nospace",
106 | "variable-declaration": "nospace"
107 | },
108 | {
109 | "call-signature": "onespace",
110 | "index-signature": "onespace",
111 | "parameter": "onespace",
112 | "property-declaration": "onespace",
113 | "variable-declaration": "onespace"
114 | }
115 | ],
116 | "use-strict": false,
117 | "variable-name": [
118 | true,
119 | "allow-leading-underscore",
120 | "ban-keywords"
121 | ],
122 | "whitespace": [
123 | true,
124 | "check-branch",
125 | "check-decl",
126 | "check-operator",
127 | "check-separator",
128 | "check-type"
129 | ]
130 | }
131 | }
--------------------------------------------------------------------------------