-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b402d5
commit f579ee6
Showing
13 changed files
with
202 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
templates/ui/tweaker/gameobjects/inputfield/GenerateInputFieldClass.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import Sizer from '../../../sizer/Sizer.js'; | ||
|
||
var GenerateInputFieldClass = function (BaseClass) { | ||
if (BaseClass === undefined) { | ||
BaseClass = Sizer; | ||
} | ||
|
||
class InputFiled extends BaseClass { | ||
get bindingTarget() { | ||
return this.getParentSizer().bindingTarget; | ||
} | ||
|
||
get bindingKey() { | ||
return this.getParentSizer().bindTargetKey; | ||
} | ||
|
||
get value() { | ||
return this._value; | ||
} | ||
|
||
validate(newValue) { | ||
if (this.syncValueFlag || !this.validateCallback) { | ||
return true; | ||
} | ||
return this.validateCallback(newValue, this._value, this.bindingTarget, this.bindingKey); | ||
} | ||
|
||
getFotmatText(value) { | ||
if (this.textFormatCallback) { | ||
value = this.textFormatCallback(value); | ||
} else { | ||
value = value.toString(); | ||
} | ||
return value; | ||
} | ||
|
||
set value(value) { | ||
if (this._value === value) { | ||
return; | ||
} | ||
if (!this.validate(value)) { | ||
value = this._value; // Back to previous value | ||
} | ||
|
||
if (this.displayValueCallback) { | ||
this.displayValueCallback(this, value) | ||
} | ||
|
||
if (this._value === value) { | ||
return; | ||
} | ||
|
||
var oldValue = this._value; | ||
this._value = value; | ||
|
||
if (!this.syncValueFlag) { | ||
this.emit('valuechange', value, oldValue, this.bindingTarget, this.bindingKey); | ||
} | ||
} | ||
|
||
getValue() { | ||
return this.value; | ||
} | ||
|
||
setValue(value) { | ||
this.value = value; | ||
return this; | ||
} | ||
|
||
/* | ||
Internal method invoked when | ||
- inputRow.setBindingTarget(target), or | ||
- inputRow.syncTargetValue() | ||
*/ | ||
syncValue(value) { | ||
this.syncValueFlag = true; | ||
this.value = value; | ||
this.syncValueFlag = false; | ||
|
||
return this; | ||
} | ||
|
||
setup(config, setDefaults) { | ||
if (setDefaults === undefined) { | ||
setDefaults = false; | ||
} | ||
|
||
if (setDefaults || config.hasOwnProperty('format')) { | ||
this.setTextFormatCallback(config.format); | ||
} | ||
|
||
if (setDefaults || config.hasOwnProperty('onValidate')) { | ||
this.setValidateCallback(config.onValidate); | ||
} | ||
|
||
if (this.setupCallback) { | ||
this.setupCallback(this, config, setDefaults); | ||
} | ||
|
||
return this; | ||
} | ||
|
||
setSetupCallback(callback) { | ||
this.setupCallback = callback; | ||
return this; | ||
} | ||
|
||
setDisplayValueCallback(callback) { | ||
this.displayValueCallback = callback; | ||
return this; | ||
} | ||
|
||
setTextFormatCallback(callback) { | ||
this.textFormatCallback = callback; | ||
return this; | ||
} | ||
|
||
setValidateCallback(callback) { | ||
this.validateCallback = callback; | ||
return this; | ||
} | ||
} | ||
|
||
return InputFiled; | ||
} | ||
|
||
export default GenerateInputFieldClass; |
110 changes: 0 additions & 110 deletions
110
templates/ui/tweaker/gameobjects/inputfield/InputFieldBase.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.