* refactor: reorganize package structure and decouple framework packages ## Package Structure Reorganization - Reorganized 55 packages into categorized subdirectories: - packages/framework/ - Generic framework (Laya/Cocos compatible) - packages/engine/ - ESEngine core modules - packages/rendering/ - Rendering modules (WASM dependent) - packages/physics/ - Physics modules - packages/streaming/ - World streaming - packages/network-ext/ - Network extensions - packages/editor/ - Editor framework and plugins - packages/rust/ - Rust WASM engine - packages/tools/ - Build tools and SDK ## Framework Package Decoupling - Decoupled behavior-tree and blueprint packages from ESEngine dependencies - Created abstracted interfaces (IBTAssetManager, IBehaviorTreeAssetContent) - ESEngine-specific code moved to esengine/ subpath exports - Framework packages now usable with Cocos/Laya without ESEngine ## CI Configuration - Updated CI to only type-check and lint framework packages - Added type-check:framework and lint:framework scripts ## Breaking Changes - Package import paths changed due to directory reorganization - ESEngine integrations now use subpath imports (e.g., '@esengine/behavior-tree/esengine') * fix: update es-engine file path after directory reorganization * docs: update README to focus on framework over engine * ci: only build framework packages, remove Rust/WASM dependencies * fix: remove esengine subpath from behavior-tree and blueprint builds ESEngine integration code will only be available in full engine builds. Framework packages are now purely engine-agnostic. * fix: move network-protocols to framework, build both in CI * fix: update workflow paths from packages/core to packages/framework/core * fix: exclude esengine folder from type-check in behavior-tree and blueprint * fix: update network tsconfig references to new paths * fix: add test:ci:framework to only test framework packages in CI * fix: only build core and math npm packages in CI * fix: exclude test files from CodeQL and fix string escaping security issue
236 lines
5.3 KiB
TypeScript
236 lines
5.3 KiB
TypeScript
import { GTextField } from './GTextField';
|
|
import { InputTextField } from '../display/InputTextField';
|
|
import { FGUIEvents } from '../events/Events';
|
|
import type { ByteBuffer } from '../utils/ByteBuffer';
|
|
|
|
/**
|
|
* Keyboard type constants
|
|
* 键盘类型常量
|
|
*/
|
|
export const enum EKeyboardType {
|
|
Default = 'text',
|
|
Number = 'number',
|
|
Url = 'url',
|
|
Email = 'email',
|
|
Tel = 'tel',
|
|
Password = 'password'
|
|
}
|
|
|
|
/**
|
|
* GTextInput
|
|
*
|
|
* Editable text input component.
|
|
*
|
|
* 可编辑的文本输入组件
|
|
*
|
|
* Features:
|
|
* - Text input with IME support
|
|
* - Password mode
|
|
* - Character restriction
|
|
* - Max length
|
|
* - Placeholder text
|
|
*/
|
|
export class GTextInput extends GTextField {
|
|
protected declare _displayObject: InputTextField;
|
|
|
|
constructor() {
|
|
super();
|
|
}
|
|
|
|
protected createDisplayObject(): void {
|
|
const inputField = new InputTextField();
|
|
// Set both _displayObject and _textField since parent class uses _textField for color etc.
|
|
this._displayObject = inputField;
|
|
this._textField = inputField;
|
|
this._displayObject.gOwner = this;
|
|
|
|
// Forward events
|
|
inputField.on('input', () => {
|
|
this.emit(FGUIEvents.TEXT_CHANGED);
|
|
});
|
|
inputField.on('submit', () => {
|
|
this.emit(FGUIEvents.TEXT_SUBMIT);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get native input element
|
|
* 获取原生输入元素
|
|
*/
|
|
public get nativeInput(): InputTextField {
|
|
return this._displayObject;
|
|
}
|
|
|
|
/**
|
|
* Get/set password mode
|
|
* 获取/设置密码模式
|
|
*/
|
|
public get password(): boolean {
|
|
return this._displayObject.password;
|
|
}
|
|
|
|
public set password(value: boolean) {
|
|
if (this._displayObject) {
|
|
this._displayObject.password = value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get/set keyboard type
|
|
* 获取/设置键盘类型
|
|
*/
|
|
public get keyboardType(): string {
|
|
return this._displayObject.keyboardType;
|
|
}
|
|
|
|
public set keyboardType(value: string) {
|
|
if (this._displayObject) {
|
|
this._displayObject.keyboardType = value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get/set editable state
|
|
* 获取/设置可编辑状态
|
|
*/
|
|
public get editable(): boolean {
|
|
return this._displayObject.editable;
|
|
}
|
|
|
|
public set editable(value: boolean) {
|
|
if (this._displayObject) {
|
|
this._displayObject.editable = value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get/set max length
|
|
* 获取/设置最大长度
|
|
*/
|
|
public get maxLength(): number {
|
|
return this._displayObject.maxLength;
|
|
}
|
|
|
|
public set maxLength(value: number) {
|
|
if (this._displayObject) {
|
|
this._displayObject.maxLength = value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get/set placeholder text
|
|
* 获取/设置占位符文本
|
|
*/
|
|
public get promptText(): string {
|
|
return this._displayObject.promptText;
|
|
}
|
|
|
|
public set promptText(value: string) {
|
|
if (this._displayObject) {
|
|
this._displayObject.promptText = value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get/set placeholder color
|
|
* 获取/设置占位符颜色
|
|
*/
|
|
public get promptColor(): string {
|
|
return this._displayObject.promptColor;
|
|
}
|
|
|
|
public set promptColor(value: string) {
|
|
if (this._displayObject) {
|
|
this._displayObject.promptColor = value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get/set character restriction pattern
|
|
* 获取/设置字符限制模式
|
|
*/
|
|
public get restrict(): string {
|
|
return this._displayObject.restrict;
|
|
}
|
|
|
|
public set restrict(value: string) {
|
|
if (this._displayObject) {
|
|
this._displayObject.restrict = value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get/set single line mode
|
|
* 获取/设置单行模式
|
|
*/
|
|
public get singleLine(): boolean {
|
|
return this._singleLine;
|
|
}
|
|
|
|
public set singleLine(value: boolean) {
|
|
this._singleLine = value;
|
|
if (this._displayObject) {
|
|
this._displayObject.multiline = !value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Request focus
|
|
* 请求焦点
|
|
*/
|
|
public requestFocus(): void {
|
|
this._displayObject.focus();
|
|
super.requestFocus();
|
|
}
|
|
|
|
/**
|
|
* Clear focus
|
|
* 清除焦点
|
|
*/
|
|
public clearFocus(): void {
|
|
this._displayObject.blur();
|
|
}
|
|
|
|
/**
|
|
* Select all text
|
|
* 选择所有文本
|
|
*/
|
|
public selectAll(): void {
|
|
this._displayObject.selectAll();
|
|
}
|
|
|
|
public setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void {
|
|
super.setup_beforeAdd(buffer, beginPos);
|
|
|
|
buffer.seek(beginPos, 4);
|
|
|
|
let str = buffer.readS();
|
|
if (str) {
|
|
this.promptText = str;
|
|
}
|
|
|
|
str = buffer.readS();
|
|
if (str) {
|
|
this.restrict = str;
|
|
}
|
|
|
|
const iv = buffer.getInt32();
|
|
if (iv !== 0) {
|
|
this.maxLength = iv;
|
|
}
|
|
|
|
const keyboardTypeValue = buffer.getInt32();
|
|
if (keyboardTypeValue !== 0) {
|
|
if (keyboardTypeValue === 4) {
|
|
this.keyboardType = EKeyboardType.Number;
|
|
} else if (keyboardTypeValue === 3) {
|
|
this.keyboardType = EKeyboardType.Url;
|
|
}
|
|
}
|
|
|
|
if (buffer.readBool()) {
|
|
this.password = true;
|
|
}
|
|
}
|
|
}
|