Files
GdevelopMMOTestv1/Export/Extensions/TextInput/textinputruntimeobject.js
T

3 lines
8.3 KiB
JavaScript

var gdjs;(function(i){const d=["text","email","password","number","telephone number","url","search","text area"],l=["left","center","right"],n=r=>{const e=r.toLowerCase();return d.includes(e)?r:"text"},o=r=>{if(!r)return"left";const e=r.toLowerCase();return l.includes(e)?r:"left"},p=300,h=30,s=(r,e,t)=>Math.max(0,Math.min(e/2-t,r));class g extends i.RuntimeObject{constructor(e,t,u){super(e,t,u);this.opacity=255;this._width=p;this._height=h;this._string=t.content.initialValue,this._placeholder=t.content.placeholder,this._fontResourceName=t.content.fontResourceName,this._fontSize=t.content.fontSize||20,this._inputType=n(t.content.inputType),this._textColor=i.rgbOrHexToRGBColor(t.content.textColor),this._fillColor=i.rgbOrHexToRGBColor(t.content.fillColor),this._fillOpacity=t.content.fillOpacity,this._borderColor=i.rgbOrHexToRGBColor(t.content.borderColor),this._borderOpacity=t.content.borderOpacity,this._borderWidth=t.content.borderWidth,this._disabled=e.getGame().isInGameEdition()?!0:t.content.disabled,this._readOnly=t.content.readOnly,this._spellCheck=t.content.spellCheck!==void 0?t.content.spellCheck:!1,this._textAlign=o(t.content.textAlign),this._maxLength=t.content.maxLength||0,this._paddingX=t.content.paddingX!==void 0?t.content.paddingX:2,this._paddingY=t.content.paddingY!==void 0?t.content.paddingY:1,this._isSubmitted=!1,this._renderer=new i.TextInputRuntimeObjectRenderer(this,e),this.onCreated()}getRendererObject(){return null}updateFromObjectData(e,t){return e.content.initialValue!==t.content.initialValue&&this._string===e.content.initialValue&&this.setString(t.content.initialValue),e.content.placeholder!==t.content.placeholder&&this.setPlaceholder(t.content.placeholder),e.content.fontResourceName!==t.content.fontResourceName&&this.setFontResourceName(t.content.fontResourceName),e.content.fontSize!==t.content.fontSize&&this.setFontSize(t.content.fontSize),e.content.inputType!==t.content.inputType&&this.setInputType(t.content.inputType),e.content.textColor!==t.content.textColor&&this.setTextColor(t.content.textColor),e.content.fillColor!==t.content.fillColor&&this.setFillColor(t.content.fillColor),e.content.fillOpacity!==t.content.fillOpacity&&this.setFillOpacity(t.content.fillOpacity),e.content.borderColor!==t.content.borderColor&&this.setBorderColor(t.content.borderColor),e.content.borderOpacity!==t.content.borderOpacity&&this.setBorderOpacity(t.content.borderOpacity),e.content.borderWidth!==t.content.borderWidth&&this.setBorderWidth(t.content.borderWidth),e.content.disabled!==t.content.disabled&&this.setDisabled(t.content.disabled),e.content.readOnly!==t.content.readOnly&&this.setReadOnly(t.content.readOnly),t.content.spellCheck!==void 0&&e.content.spellCheck!==t.content.spellCheck&&this.setSpellCheck(t.content.spellCheck),t.content.maxLength!==void 0&&e.content.maxLength!==t.content.maxLength&&this.setMaxLength(t.content.maxLength),t.content.textAlign&&e.content.textAlign!==t.content.textAlign&&(this._textAlign=t.content.textAlign),t.content.paddingX!==void 0&&e.content.paddingX!==t.content.paddingX&&this.setPaddingX(t.content.paddingX),t.content.paddingY!==void 0&&e.content.paddingY!==t.content.paddingY&&this.setPaddingY(t.content.paddingY),!0}getNetworkSyncData(e){return{...super.getNetworkSyncData(e),opa:this.getOpacity(),txt:this.getText(),frn:this.getFontResourceName(),fs:this.getFontSize(),place:this.getPlaceholder(),it:this.getInputType(),tc:this.getTextColor(),fc:this.getFillColor(),fo:this.getFillOpacity(),bc:this.getBorderColor(),bo:this.getBorderOpacity(),bw:this.getBorderWidth(),dis:this.isDisabled(),ro:this.isReadOnly(),sc:this.isSpellCheckEnabled()}}updateFromNetworkSyncData(e,t){super.updateFromNetworkSyncData(e,t),e.opa!==void 0&&this.setOpacity(e.opa),e.txt!==void 0&&this.setText(e.txt),e.frn!==void 0&&this.setFontResourceName(e.frn),e.fs!==void 0&&this.setFontSize(e.fs),e.place!==void 0&&this.setPlaceholder(e.place),e.it!==void 0&&this.setInputType(e.it),e.tc!==void 0&&this.setTextColor(e.tc),e.fc!==void 0&&this.setFillColor(e.fc),e.fo!==void 0&&this.setFillOpacity(e.fo),e.bc!==void 0&&this.setBorderColor(e.bc),e.bo!==void 0&&this.setBorderOpacity(e.bo),e.bw!==void 0&&this.setBorderWidth(e.bw),e.dis!==void 0&&this.setDisabled(e.dis),e.ro!==void 0&&this.setReadOnly(e.ro),e.sc!==void 0&&this.setSpellCheck(e.sc)}updatePreRender(e){this._isSubmitted=!1,this._renderer.updatePreRender()}extraInitializationFromInitialInstance(e){for(const t of e.stringProperties)t.name==="initialValue"?this.setString(t.value):t.name==="placeholder"&&this.setPlaceholder(t.value);e.customSize&&(this.setWidth(e.width),this.setHeight(e.height),this._renderer.updatePadding()),this.setOpacity(e.opacity===void 0?255:e.opacity)}onScenePaused(e){this._renderer.onScenePaused()}onSceneResumed(e){this._renderer.onSceneResumed()}onDestroyed(){super.onDestroyed(),this._renderer.onDestroy()}setOpacity(e){this.opacity=Math.max(0,Math.min(255,e)),this._renderer.updateOpacity()}getOpacity(){return this.opacity}setSize(e,t){this.setWidth(e),this.setHeight(t)}setWidth(e){this._width=e,this._renderer.updatePadding()}setHeight(e){this._height=e,this._renderer.updatePadding()}getWidth(){return this._width}getHeight(){return this._height}getString(){return this.getText()}setString(e){this.setText(e)}getText(){return this._string}setText(e){e!==this._string&&(this._string=e,this._renderer.updateString())}onRendererInputValueChanged(e){this._string=e}onRendererFormSubmitted(){this._isSubmitted=!0}getFontResourceName(){return this._fontResourceName}setFontResourceName(e){this._fontResourceName!==e&&(this._fontResourceName=e,this._renderer.updateFont())}getFontSize(){return this._fontSize}setFontSize(e){this._fontSize=e}getPlaceholder(){return this._placeholder}setPlaceholder(e){e!==this._placeholder&&(this._placeholder=e,this._renderer.updatePlaceholder())}getInputType(){return this._inputType}setInputType(e){const t=e.toLowerCase();t!==this._inputType&&(this._inputType=n(t),this._renderer.updateInputType())}setTextColor(e){this._textColor=i.rgbOrHexToRGBColor(e),this._renderer.updateTextColor()}getTextColor(){return this._textColor[0]+";"+this._textColor[1]+";"+this._textColor[2]}_getRawTextColor(){return this._textColor}setFillColor(e){this._fillColor=i.rgbOrHexToRGBColor(e),this._renderer.updateFillColorAndOpacity()}getFillColor(){return this._fillColor[0]+";"+this._fillColor[1]+";"+this._fillColor[2]}_getRawFillColor(){return this._fillColor}setFillOpacity(e){this._fillOpacity=Math.max(0,Math.min(255,e)),this._renderer.updateFillColorAndOpacity()}getFillOpacity(){return this._fillOpacity}setBorderColor(e){this._borderColor=i.rgbOrHexToRGBColor(e),this._renderer.updateBorderColorAndOpacity()}getBorderColor(){return this._borderColor[0]+";"+this._borderColor[1]+";"+this._borderColor[2]}_getRawBorderColor(){return this._borderColor}setBorderOpacity(e){this._borderOpacity=Math.max(0,Math.min(255,e)),this._renderer.updateBorderColorAndOpacity()}getBorderOpacity(){return this._borderOpacity}setBorderWidth(e){this._borderWidth=Math.max(0,e),this._renderer.updateBorderWidth()}getBorderWidth(){return this._borderWidth}setDisabled(e){this.getInstanceContainer().getGame().isInGameEdition()||(this._disabled=e,this._renderer.updateDisabled())}isDisabled(){return this._disabled}setReadOnly(e){this._readOnly=e,this._renderer.updateReadOnly()}isReadOnly(){return this._readOnly}setSpellCheck(e){this._spellCheck=e,this._renderer.updateSpellCheck()}isSpellCheckEnabled(){return this._spellCheck}isFocused(){return this._renderer.isFocused()}isSubmitted(){return this._isSubmitted}getMaxLength(){return this._maxLength}setMaxLength(e){this._maxLength!==e&&(this._maxLength=e,this._renderer.updateMaxLength())}getPaddingX(){return s(this._paddingX,this._width,this._borderWidth)}setPaddingX(e){if(this._paddingX!==e){if(e<0){this._paddingX=0;return}this._paddingX=e,this._renderer.updatePadding()}}getPaddingY(){return s(this._paddingY,this._height,this._borderWidth)}setPaddingY(e){if(this._paddingY!==e){if(e<0){this._paddingY=0;return}this._paddingY=e,this._renderer.updatePadding()}}getTextAlign(){return this._textAlign}setTextAlign(e){const t=o(e);t!==this._textAlign&&(this._textAlign=t,this._renderer.updateTextAlign())}focus(){this.isFocused()||this.getInstanceContainer().getGame().getInputManager().clearAllPressedKeys(),this._renderer.focus()}}i.TextInputRuntimeObject=g,i.registerObject("TextInput::TextInputObject",i.TextInputRuntimeObject)})(gdjs||(gdjs={}));
//# sourceMappingURL=textinputruntimeobject.js.map