主题
UI JS API 完整参考
说明:以下 API 均为 BUI 脚本环境可用。若在普通脚本里调用,请确认已注入 BUI 环境。
1. 全局函数(BUIJsGlobals)
UI 管理
requestOpenUI(templateId, initialState?)closeUI(templateId?)(仅本地关闭)requestCloseUI(templateId?)(通知服务端)dispatchServerAction(actionName, payload?, onSuccess?, onError?)
聊天相关
chatSend(message, addRecent?) -> BooleanchatHistory(limit?) -> List<String>chatRecentHistory() -> List<String>chatScroll(lines)chatLinesPerPage() -> IntchatBackgroundColor() -> Int
生命周期
onMounted(cb)onUnmounted(cb)onActivated(cb)onDeactivated(cb)
响应式
ref(id) -> UIElementWrapper?computed(name, deps, getter)/computed(store, name, deps, getter)watch(key, cb)/watch(store, key, cb)nextTick(cb)useSuspense(asyncFn)
依赖注入
provide(key, value)inject(key, defaultValue?)provideGlobal(key, value)
Query
useQuery(key, action, payload?, options?, store?)usePrefetch(key, action, payload?, options?, store?)invalidateQueries(predicate?, store?)setQueryData(key, data, store?)getQueryData(key, store?)
动画
animate(element, name, options?)enter(element, name?, options?)leave(element, name?, options?)stopAnimation(element)isAnimating(element) -> Boolean
拖放
useDraggable(element, options?)useDroppable(element, options?)startDrag(data, texture?)getDragData() -> anyisDragging() -> BooleancancelDrag()
元素/文本创建
createElement(tag, props?) -> UIElementWrappercreateComponent(name) -> UIElementWrappercreateTranslatable(key, ...args) -> ComponentWrapperemptyComponent() -> ComponentWrapper
2. 全局对象
2.1 internalSyncStore(只读)
getId()/getScope()get(key)/getOrDefault(key, def)/has(key)/keys()getState()(仅 sync:*)
2.2 localStorage
setItem/setJsongetItem/getItemOrDefaultgetInt/getIntOrDefaultgetDouble/getDoubleOrDefaultgetBoolean/getBooleanOrDefaultgetAnygetJson/getJsonOrDefaulthasItem/removeItem/clearkeys/length
2.3 Texture(工厂对象)
Texture.empty()Texture.color(color)Texture.resource(path)Texture.sprite(path)Texture.gradient(from, to, horizontal?)Texture.sdf(radius?, color?, borderColor?, stroke?)Texture.sdfRect(radius?, color?, borderColor?, stroke?)Texture.icon(name)/Texture.iconFrom(modId, name)Texture.builtinSprite(name)Texture.group(...textures)Texture.border(color, width?)Texture.text(text, color?)Texture.animation(path, cellSize?, from?, to?, ticksPerFrame?)Texture.animationWithParams(...)Texture.progress(value?)Texture.progressWithTextures(empty, filled)Texture.autoProgress(empty?, filled?)Texture.wrap(texture)
2.4 hotkeys(UI 热键)
hotkeys.register(options, callback?) -> idhotkeys.unregister(id) -> Booleanhotkeys.clear()hotkeys.list() -> List<String>
2.5 sound(UI 音效)
sound.play(id, volume?, pitch?, loop?)sound.playAt(id, x, y, z, volume?, pitch?, loop?)sound.stop(id)
sound 的
id必须是 sound/ 目录下相对路径,不允许带behemiron:或sound/前缀。
3. Store / Texture 包装器
3.1 UIStoreWrapper(defineStore/useStore 返回)
getId/getScopeget/set/getOrDefault/has/remove/keyssetState/getStategetComputedwatchon/once/emit/offdispatchresetunwrap
3.2 TextureWrapper(Texture.xxx() 返回)
- 通用:
unwrap/copy/setColor/rotate/scale/transform - 资源纹理:
getSubTexture - Sprite:
setSprite/setBorder/setBorderLTRB/setWrapMode - Gradient:
setColorFrom/setColorTo/setHorizontal - SDF:
setRadius/setRadiusCorners/setStroke/setBorderColor - Border:
setBorderWidth - Text:
updateText/setDropShadow/setBackgroundColor/setTextWidth/setRollSpeed/setTextType - Animation:
setAnimationTexture/setCellSize/setAnimationRange/setAnimationSpeed - Progress:
setProgressTextures/setProgress/setFillDirection
4. 组件包装器完整列表
所有组件至少拥有
UIElementWrapper的通用方法。 下方为每个组件用途与典型用法,并列出其完整方法签名与参数说明。
ButtonWrapper
用途:按钮交互与样式控制
典型用法:const btn = ref("ok"); btn.setOnClick(() => sound.play("ui/confirm"))
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
setText(text: ComponentWrapper) | text(ComponentWrapper) | 无 | 无 |
setTextString(text: String) | text(String) | 无 | 按翻译 key 解析 |
setTextLiteral(text: String) | text(String) | 无 | 按字面文本,不走翻译 |
noText() | 无 | 无 | 无 |
enableText() | 无 | 无 | 无 |
getState() | 无 | 无 | 无 |
isPressed() | 无 | 无 | 无 |
isHoveredState() | 无 | 无 | 无 |
setBaseTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setHoverTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setPressedTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setTextColor(color: Int) | color(Int) | 无 | 无 |
setFontSize(size: Float) | size(Float) | 无 | 无 |
setOnClick(listener: UIEventListener) | listener(UIEventListener) | 无 | 回调在 UI 线程触发 |
addPreIcon(icon: IGuiTexture) | icon(IGuiTexture) | 无 | 无 |
addPostIcon(icon: IGuiTexture) | icon(IGuiTexture) | 无 | 无 |
ColorSelectorWrapper
用途:颜色选择器(拾色器)
典型用法:const picker = ref("color"); picker.setOnColorChangeListener(c => {})
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getValue(): Int = selector.getValue() | 无 | 无 | 无 |
setValue(value: Int) | value(Int) | 无 | 无 |
setValueSilent(value: Int) | value(Int) | 无 | 不触发通知/回调 |
getColor(): Int = selector.getColor() | 无 | 无 | 无 |
setColor(argb: Int) | argb(Int) | 无 | 无 |
setColorSilent(argb: Int) | argb(Int) | 无 | 不触发通知/回调 |
getAlpha(): Int = (getValue() shr 24) | 无 | 无 | 无 |
getRed(): Int = (getValue() shr 16) | 无 | 无 | 无 |
getGreen(): Int = (getValue() shr 8) | 无 | 无 | 无 |
getBlue(): Int = getValue() | 无 | 无 | 无 |
getHexString(): String = String.format("#%08x", getValue()) | 无 | 无 | 无 |
setOnColorChangeListener(listener: (Int) -> Unit) | listener((Int) -> Unit) | 无 | 回调在 UI 线程触发 |
getPickerContainer(): UIElementWrapper = UIElementWrapperFactory.wrap(selector.pickerContainer) | 无 | 无 | 无 |
getColorPreview(): UIElementWrapper = UIElementWrapperFactory.wrap(selector.colorPreview) | 无 | 无 | 无 |
getTextContainer(): UIElementWrapper = UIElementWrapperFactory.wrap(selector.textContainer) | 无 | 无 | 无 |
getHexTextField(): TextFieldWrapper = TextFieldWrapper(selector.hexTextField) | 无 | 无 | 无 |
ComponentWrapper
用途:富文本/聊天组件构造
典型用法:const c = Component.literal("完成").color("#ffcc00")
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getString() | 无 | 无 | 无 |
append(text: String) | text(String) | 无 | 无 |
appendComponent(other: ComponentWrapper) | other(ComponentWrapper) | 无 | 无 |
appendMC(other: Component) | other(Component) | 无 | 无 |
color(color: String) | color(String) | 无 | 无 |
colorInt(color: Int) | color(Int) | 无 | 无 |
bold(value: Boolean = true) | 无 | value=true | 无 |
italic(value: Boolean = true) | 无 | value=true | 无 |
underlined(value: Boolean = true) | 无 | value=true | 无 |
strikethrough(value: Boolean = true) | 无 | value=true | 无 |
obfuscated(value: Boolean = true) | 无 | value=true | 无 |
font(fontId: String) | fontId(String) | 无 | 无 |
clickOpenUrl(url: String) | url(String) | 无 | 无 |
clickRunCommand(command: String) | command(String) | 无 | 无 |
clickSuggestCommand(command: String) | command(String) | 无 | 无 |
clickCopyToClipboard(text: String) | text(String) | 无 | 无 |
hoverText(text: String) | text(String) | 无 | 无 |
hoverComponent(other: ComponentWrapper) | other(ComponentWrapper) | 无 | 无 |
copy() | 无 | 无 | 无 |
unwrap() | 无 | 无 | 无 |
unwrapMutable() | 无 | 无 | 无 |
literal(text: String) | text(String) | 无 | 无 |
translatable(key: String, vararg args: Any) | key(String);vararg args(Any) | 无 | 无 |
empty() | 无 | 无 | 无 |
wrap(component: Component) | component(Component) | 无 | 无 |
DialogWrapper
用途:模态对话框与按钮区域
典型用法:const dlg = ref("confirm"); dlg.show()
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
show(parent: UIElement) | parent(UIElement) | 无 | 无 |
showWithWrapper(parent: UIElementWrapper) | parent(UIElementWrapper) | 无 | 无 |
close() | 无 | 无 | 无 |
setTitle(title: String) | title(String) | 无 | 无 |
setAutoClose(autoClose: Boolean) | autoClose(Boolean) | 无 | 无 |
darkenBackground() | 无 | 无 | 无 |
setDialogWidth(width: Float) | width(Float) | 无 | 无 |
addContent(content: UIElement) | content(UIElement) | 无 | 无 |
addContentWrapper(content: UIElementWrapper) | content(UIElementWrapper) | 无 | 无 |
addButton(button: UIElement) | button(UIElement) | 无 | 无 |
addButtonWrapper(button: UIElementWrapper) | button(UIElementWrapper) | 无 | 无 |
getOverlay(): UIElementWrapper = UIElementWrapper(dialog.overlay) | 无 | 无 | 无 |
getTitleBar(): UIElementWrapper = UIElementWrapper(dialog.titleBar) | 无 | 无 | 无 |
getContentContainer(): UIElementWrapper = UIElementWrapper(dialog.contentContainer) | 无 | 无 | 无 |
getButtonContainer(): UIElementWrapper = UIElementWrapper(dialog.buttonContainer) | 无 | 无 | 无 |
setOnClose(callback: () -> Unit) | callback(() -> Unit) | 无 | 回调在 UI 线程触发 |
DisplaySlotWrapper
用途:物品展示槽(仅显示)
典型用法:const slot = ref("preview"); slot.setItem(item)
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
setItem(item: ItemStackWrapper?) | item(ItemStackWrapper?) | 无 | 无 |
bindItem(getter: () -> ItemStackWrapper?) | getter(() -> ItemStackWrapper?) | 无 | 无 |
getItem() | 无 | 无 | 无 |
hasItem(): Boolean = !slot.getItem() | 无 | 无 | 无 |
setItemScale(scale: Float) | scale(Float) | 无 | 无 |
getItemScale() | 无 | 无 | 无 |
setHoverOverlay(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setShowItemTooltips(show: Boolean) | show(Boolean) | 无 | 无 |
isShowItemTooltips(): Boolean = slot.slotStyle.showItemTooltips() | 无 | 无 | 无 |
EntityViewWrapper
用途:UI 内渲染实体模型
典型用法:const view = ref("entity"); view.setPlayer()
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
setEntity(value: Any?) | value(Any?) | 无 | 无 |
setEntityId(id: Int) | id(Int) | 无 | 无 |
setEntityUuid(uuid: String) | uuid(String) | 无 | 无 |
setPlayer(value: Any?) | value(Any?) | 无 | 无 |
setFitMode(mode: String) | mode(String) | 无 | 无 |
setAnchor(anchor: String) | anchor(String) | 无 | 无 |
setFramePadding(value: Float) | value(Float) | 无 | 无 |
setBBoxScale(value: Float) | value(Float) | 无 | 无 |
setRotationMode(mode: String) | mode(String) | 无 | 无 |
setYaw(value: Float) | value(Float) | 无 | 无 |
setPitch(value: Float) | value(Float) | 无 | 无 |
setRotateClampYaw(value: Float) | value(Float) | 无 | 无 |
setRotateClampPitch(value: Float) | value(Float) | 无 | 无 |
setWheelZoom(value: Boolean) | value(Boolean) | 无 | 无 |
setZoom(value: Float) | value(Float) | 无 | 无 |
setZoomMin(value: Float) | value(Float) | 无 | 无 |
setZoomMax(value: Float) | value(Float) | 无 | 无 |
setZoomSpeed(value: Float) | value(Float) | 无 | 无 |
FieldWrapper
用途:表单字段配置与校验
典型用法:const field = ref("name"); field.setValidateOnBlur(true)
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getName() | 无 | 无 | 无 |
setName(name: String) | name(String) | 无 | 无 |
setValidateOnChange(validate: Boolean) | validate(Boolean) | 无 | 无 |
isValidateOnChange() | 无 | 无 | 无 |
setValidateOnBlur(validate: Boolean) | validate(Boolean) | 无 | 无 |
isValidateOnBlur() | 无 | 无 | 无 |
getError() | 无 | 无 | 无 |
isTouched() | 无 | 无 | 无 |
getValue(): Any? = field.getValue() | 无 | 无 | 无 |
setValue(value: Any?) | value(Any?) | 无 | 无 |
validate(): String? = field.validate() | 无 | 无 | 无 |
validateAsync(onComplete: (String?) -> Unit) | onComplete((String?) -> Unit) | 无 | 无 |
clearError() | 无 | 无 | 无 |
reset() | 无 | 无 | 无 |
FormWrapper
用途:表单容器(校验/提交/重置)
典型用法:const form = ref("form"); form.submit()
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
get(name: String) | name(String) | 无 | 无 |
set(name: String, value: Any?) | name(String);value(Any?) | 无 | 无 |
setValueAndValidate(name: String, value: Any?) | name(String);value(Any?) | 无 | 无 |
getValues(): Map<String, Any?> = form.getValues() | 无 | 无 | 无 |
setValues(values: Map<String, Any?>) | values(Map<String, Any?>) | 无 | 无 |
setInitialValues(values: Map<String, Any?>) | values(Map<String, Any?>) | 无 | 无 |
getInitialValues() | 无 | 无 | 无 |
getError(name: String): String? = form.getError(name) | name(String) | 无 | 无 |
setError(name: String, error: String?) | name(String);error(String?) | 无 | 无 |
getErrors(): Map<String, String?> = form.getErrors() | 无 | 无 | 无 |
clearErrors() | 无 | 无 | 无 |
isValid() | 无 | 无 | 无 |
isDirty() | 无 | 无 | 无 |
isSubmitting() | 无 | 无 | 无 |
isValidating() | 无 | 无 | 无 |
isTouched(name: String): Boolean = form.isTouched(name) | name(String) | 无 | 无 |
validateFieldSync(name: String): String? = form.validateFieldSync(name) | name(String) | 无 | 无 |
validateField(name: String, onComplete: (String?) -> Unit) | name(String);onComplete((String?) -> Unit) | 无 | 无 |
validateSync(): Boolean = form.validateSync() | 无 | 无 | 无 |
validate(onComplete: (Boolean) -> Unit) | onComplete((Boolean) -> Unit) | 无 | 无 |
submit() | 无 | 无 | 无 |
submitSync() | 无 | 无 | 无 |
setOnSubmit(callback: (Map<String, Any?>) -> Unit) | callback((Map<String, Any?>) -> Unit) | 无 | 回调在 UI 线程触发 |
setOnSubmitFailed(callback: () -> Unit) | callback(() -> Unit) | 无 | 回调在 UI 线程触发 |
setOnValuesChange(callback: (String, Any?, Any?) -> Unit) | callback((String, Any?, Any?) -> Unit) | 无 | 回调在 UI 线程触发 |
reset() | 无 | 无 | 无 |
resetTo(values: Map<String, Any?>) | values(Map<String, Any?>) | 无 | 无 |
GraphViewWrapper
用途:可缩放/平移的画布容器
典型用法:const graph = ref("graph"); graph.setAllowZoom(true); graph.fit()
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getOffsetX() | 无 | 无 | 无 |
setOffsetX(offsetX: Float) | offsetX(Float) | 无 | 无 |
getOffsetY() | 无 | 无 | 无 |
setOffsetY(offsetY: Float) | offsetY(Float) | 无 | 无 |
getScale() | 无 | 无 | 无 |
setScale(scale: Float) | scale(Float) | 无 | 无 |
addContentChild(child: UIElementWrapper) | child(UIElementWrapper) | 无 | 无 |
removeContentChild(child: UIElementWrapper) | child(UIElementWrapper) | 无 | 无 |
clearAllContentChildren() | 无 | 无 | 无 |
getContentRoot(): UIElementWrapper = UIElementWrapperFactory.wrap(graph.contentRoot) | 无 | 无 | 无 |
fitToChildren(padding: Float, minScaleBound: Float) | padding(Float);minScaleBound(Float) | 无 | 无 |
fit(minX: Float, minY: Float, maxX: Float, maxY: Float, minScaleBound: Float) | minX(Float);minY(Float);maxX(Float);maxY(Float);minScaleBound(Float) | 无 | 无 |
screenToWorld(screenX: Float, screenY: Float) | screenX(Float);screenY(Float) | 无 | 无 |
worldToScreen(worldX: Float, worldY: Float) | worldX(Float);worldY(Float) | 无 | 无 |
setAllowZoom(allow: Boolean) | allow(Boolean) | 无 | 无 |
isAllowZoom(): Boolean = graph.graphViewStyle.allowZoom() | 无 | 无 | 无 |
setAllowPan(allow: Boolean) | allow(Boolean) | 无 | 无 |
isAllowPan(): Boolean = graph.graphViewStyle.allowPan() | 无 | 无 | 无 |
setMinScale(scale: Float) | scale(Float) | 无 | 无 |
getMinScale(): Float = graph.graphViewStyle.minScale() | 无 | 无 | 无 |
setMaxScale(scale: Float) | scale(Float) | 无 | 无 |
getMaxScale(): Float = graph.graphViewStyle.maxScale() | 无 | 无 | 无 |
setGridTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setGridSize(size: Float) | size(Float) | 无 | 无 |
getGridSize(): Float = graph.graphViewStyle.gridSize() | 无 | 无 | 无 |
InventorySlotsWrapper
用途:玩家背包与快捷栏显示
典型用法:const inv = ref("inv"); inv.getHotbar()
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getRowCount() | 无 | 无 | 无 |
getRow(index: Int) | index(Int) | 无 | 无 |
getHotbar(): UIElementWrapper = UIElementWrapperFactory.wrap(inventory.hotbar) | 无 | 无 | 无 |
getTotalSlotCount() | 无 | 无 | 无 |
getMainSlotCount() | 无 | 无 | 无 |
getHotbarSlotCount() | 无 | 无 | 无 |
ItemSlotWrapper
用途:交互式物品槽位
典型用法:const slot = ref("slot"); slot.setItem(item)
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
setItem(item: ItemStackWrapper?) | item(ItemStackWrapper?) | 无 | 无 |
getItem() | 无 | 无 | 无 |
hasItem(): Boolean = !slot.getValue() | 无 | 无 | 无 |
setHoverOverlay(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setShowItemTooltips(show: Boolean) | show(Boolean) | 无 | 无 |
isShowItemTooltips(): Boolean = slot.slotStyle.showItemTooltips() | 无 | 无 | 无 |
setPlayerSlot(playerSlot: Boolean) | playerSlot(Boolean) | 无 | 无 |
isPlayerSlot(): Boolean = slot.slotStyle.isPlayerSlot() | 无 | 无 | 无 |
setQuickMovePriority(priority: Int) | priority(Int) | 无 | 无 |
getQuickMovePriority(): Int = slot.slotStyle.quickMovePriority() | 无 | 无 | 无 |
setAcceptQuickMove(accept: Boolean) | accept(Boolean) | 无 | 无 |
isAcceptQuickMove(): Boolean = slot.slotStyle.acceptQuickMove() | 无 | 无 | 无 |
LabelWrapper
用途:文本标签(可动态更新)
典型用法:const label = ref("hp"); label.setValueString("HP: 100")
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
isTickable() | 无 | 无 | 无 |
setTickable(tickable: Boolean) | tickable(Boolean) | 无 | 无 |
getValue(): ComponentWrapper = ComponentWrapper.wrap(label.getValue()) | 无 | 无 | 无 |
getValueString(): String = label.getValue() | 无 | 无 | 无 |
setValue(value: ComponentWrapper) | value(ComponentWrapper) | 无 | 无 |
setValueString(value: String) | value(String) | 无 | 无 |
MenuWrapper
用途:树形菜单/导航组件
典型用法:const menu = ref("menu"); menu.setOnNodeClicked(id => {})
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getRoot() | 无 | 无 | 无 |
close() | 无 | 无 | 无 |
setAutoClose(autoClose: Boolean) | autoClose(Boolean) | 无 | 无 |
isAutoClose() | 无 | 无 | 无 |
setUiProvider(provider: (Any?) -> UIElementWrapper) | provider((Any?) -> UIElementWrapper) | 无 | 无 |
setNodeTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setLeafTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setNodeHoverTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setLeafHoverTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setArrowIcon(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setOnNodeClicked(callback: (Any?) -> Unit) | callback((Any?) -> Unit) | 无 | 回调在 UI 线程触发 |
setOnClose(callback: () -> Unit) | callback(() -> Unit) | 无 | 回调在 UI 线程触发 |
setTextureProvider(provider: (Any?) -> IGuiTexture) | provider((Any?) -> IGuiTexture) | 无 | 无 |
setHoverTextureProvider(provider: (Any?) -> IGuiTexture) | provider((Any?) -> IGuiTexture) | 无 | 无 |
ProgressBarWrapper
用途:进度条显示
典型用法:const bar = ref("hpBar"); bar.setProgress(0.75)
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getValue() | 无 | 无 | 无 |
setValue(value: Float) | value(Float) | 无 | 无 |
setProgress(value: Float) | value(Float) | 无 | 无 |
getNormalizedValue(): Float = progressBar.getNormalizedValue() | 无 | 无 | 无 |
getMinValue() | 无 | 无 | 无 |
setMinValue(minValue: Float) | minValue(Float) | 无 | 无 |
getMaxValue() | 无 | 无 | 无 |
setMaxValue(maxValue: Float) | maxValue(Float) | 无 | 无 |
setRange(minValue: Float, maxValue: Float) | minValue(Float);maxValue(Float) | 无 | 无 |
setFillDirection(direction: String) | direction(String) | 无 | 无 |
getFillDirection(): String = progressBar.progressBarStyle.fillDirection() | 无 | 无 | 无 |
setInterpolate(interpolate: Boolean) | interpolate(Boolean) | 无 | 无 |
isInterpolate(): Boolean = progressBar.progressBarStyle.interpolate() | 无 | 无 | 无 |
setInterpolateStep(step: Float) | step(Float) | 无 | 无 |
getLabel(): LabelWrapper = LabelWrapper(progressBar.label) | 无 | 无 | 无 |
getBar(): UIElementWrapper = UIElementWrapper(progressBar.bar) | 无 | 无 | 无 |
getBarContainer(): UIElementWrapper = UIElementWrapper(progressBar.barContainer) | 无 | 无 | 无 |
ScrollerViewWrapper
用途:可滚动容器
典型用法:const view = ref("list"); view.setMode("VERTICAL")
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
addScrollViewChild(child: UIElement) | child(UIElement) | 无 | 无 |
addScrollViewChildWrapper(child: UIElementWrapper) | child(UIElementWrapper) | 无 | 无 |
addScrollViewChildAt(child: UIElement, index: Int) | child(UIElement);index(Int) | 无 | 无 |
removeScrollViewChild(child: UIElement) | child(UIElement) | 无 | 无 |
removeScrollViewChildWrapper(child: UIElementWrapper) | child(UIElementWrapper) | 无 | 无 |
clearAllScrollViewChildren() | 无 | 无 | 无 |
hasScrollViewChild(child: UIElement) | child(UIElement) | 无 | 无 |
getContainerWidth(): Float = scrollerView.getContainerWidth() | 无 | 无 | 无 |
getContainerHeight(): Float = scrollerView.getContainerHeight() | 无 | 无 | 无 |
setMode(mode: String) | mode(String) | 无 | 无 |
getMode(): String = scrollerView.scrollerViewStyle.mode() | 无 | 无 | 无 |
setVerticalScrollDisplay(display: String) | display(String) | 无 | 无 |
setHorizontalScrollDisplay(display: String) | display(String) | 无 | 无 |
setAdaptiveWidth(adaptive: Boolean) | adaptive(Boolean) | 无 | 无 |
setAdaptiveHeight(adaptive: Boolean) | adaptive(Boolean) | 无 | 无 |
setScrollerViewMargin(margin: Float) | margin(Float) | 无 | 无 |
setMinScrollPixel(pixel: Float) | pixel(Float) | 无 | 无 |
setMaxScrollPixel(pixel: Float) | pixel(Float) | 无 | 无 |
getViewPort(): UIElementWrapper = UIElementWrapper(scrollerView.viewPort) | 无 | 无 | 无 |
getViewContainer(): UIElementWrapper = UIElementWrapper(scrollerView.viewContainer) | 无 | 无 | 无 |
scrollToTop() | 无 | 无 | 无 |
scrollToBottom() | 无 | 无 | 无 |
setVerticalScrollNormalized(value: Float) | value(Float) | 无 | 无 |
ScrollerWrapper
用途:滚动条控制
典型用法:const scroller = ref("scroller"); scroller.setValue(0.5)
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getValue() | 无 | 无 | 无 |
setValue(value: Float) | value(Float) | 无 | 无 |
setValueSilent(value: Float) | value(Float) | 无 | 不触发通知/回调 |
getNormalizedValue(): Float = scroller.getNormalizedValue() | 无 | 无 | 无 |
setNormalizedValue(normalizedValue: Float) | normalizedValue(Float) | 无 | 无 |
scrollValue(normalizedValue: Float) | normalizedValue(Float) | 无 | 无 |
getMinValue() | 无 | 无 | 无 |
getMaxValue() | 无 | 无 | 无 |
setRange(minValue: Float, maxValue: Float) | minValue(Float);maxValue(Float) | 无 | 无 |
setScrollBarSize(size: Float) | size(Float) | 无 | 无 |
getScrollBarSize(): Float = scroller.scrollerStyle.scrollBarSize() | 无 | 无 | 无 |
setScrollDelta(delta: Float) | delta(Float) | 无 | 无 |
getScrollDelta(): Float = scroller.scrollerStyle.scrollDelta() | 无 | 无 | 无 |
isDragging() | 无 | 无 | 无 |
setOnValueChanged(listener: (Float) -> Unit) | listener((Float) -> Unit) | 无 | 回调在 UI 线程触发 |
getHeadButton(): ButtonWrapper = ButtonWrapper(scroller.headButton) | 无 | 无 | 无 |
getTailButton(): ButtonWrapper = ButtonWrapper(scroller.tailButton) | 无 | 无 | 无 |
getScrollBar(): ButtonWrapper = ButtonWrapper(scroller.scrollBar) | 无 | 无 | 无 |
getScrollContainer(): UIElementWrapper = UIElementWrapperFactory.wrap(scroller.scrollContainer) | 无 | 无 | 无 |
createVertical() | 无 | 无 | 无 |
createHorizontal() | 无 | 无 | 无 |
SearchComponentWrapper
用途:搜索式下拉选择
典型用法:const search = ref("search"); search.setOnValueChanged(v => {})
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getValue(): Any? = search.getValue() | 无 | 无 | 无 |
setValue(value: Any?) | value(Any?) | 无 | 无 |
setValueSilent(value: Any?) | value(Any?) | 无 | 不触发通知/回调 |
setSelected(value: Any?) | value(Any?) | 无 | 无 |
isOpen(): Boolean = search.isOpen() | 无 | 无 | 无 |
showSearch() | 无 | 无 | 无 |
hideSearch() | 无 | 无 | 无 |
setCandidateUIProvider(provider: (Any?) -> UIElementWrapper) | provider((Any?) -> UIElementWrapper) | 无 | 无 |
setFocusOverlay(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setMaxItemCount(count: Int) | count(Int) | 无 | 无 |
getMaxItemCount(): Int = search.searchStyle.maxItemCount() | 无 | 无 | 无 |
setScrollerViewHeight(height: Float) | height(Float) | 无 | 无 |
setShowOverlay(show: Boolean) | show(Boolean) | 无 | 无 |
setCloseAfterSelect(close: Boolean) | close(Boolean) | 无 | 无 |
setOnValueChanged(callback: (Any?) -> Unit) | callback((Any?) -> Unit) | 无 | 回调在 UI 线程触发 |
getTextField(): TextFieldWrapper = TextFieldWrapper(search.textField) | 无 | 无 | 无 |
getPreview(): UIElementWrapper = UIElementWrapperFactory.wrap(search.preview) | 无 | 无 | 无 |
getDialog(): UIElementWrapper = UIElementWrapperFactory.wrap(search.dialog) | 无 | 无 | 无 |
getScrollerView(): ScrollerViewWrapper = ScrollerViewWrapper(search.scrollerView) | 无 | 无 | 无 |
SelectorWrapper
用途:下拉选择器
典型用法:const sel = ref("type"); sel.setCandidates(["A", "B"])
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getValue() | 无 | 无 | 无 |
setSelected(value: T?) | value(T?) | 无 | 无 |
setSelectedSilent(value: T?) | value(T?) | 无 | 不触发通知/回调 |
getCandidates() | 无 | 无 | 无 |
setCandidates(candidates: List<T>) | candidates(List<T>) | 无 | 无 |
getCandidateCount() | 无 | 无 | 无 |
isOpen(): Boolean = selector.isOpen() | 无 | 无 | 无 |
open() | 无 | 无 | 无 |
close() | 无 | 无 | 无 |
toggle() | 无 | 无 | 无 |
setMaxItemCount(count: Int) | count(Int) | 无 | 无 |
getMaxItemCount(): Int = selector.selectorStyle.maxItemCount() | 无 | 无 | 无 |
setScrollerViewHeight(height: Float) | height(Float) | 无 | 无 |
setShowOverlay(show: Boolean) | show(Boolean) | 无 | 无 |
setCloseAfterSelect(close: Boolean) | close(Boolean) | 无 | 无 |
setOnValueChanged(callback: (T?) -> Unit) | callback((T?) -> Unit) | 无 | 回调在 UI 线程触发 |
SplitViewWrapper
用途:分割面板(左右/上下)
典型用法:const split = ref("split"); split.setPercentage(0.3)
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getPercentage(): Float = splitView.getPercentage() | 无 | 无 | 无 |
setPercentage(percentage: Float) | percentage(Float) | 无 | 无 |
setBorderSize(size: Float) | size(Float) | 无 | 无 |
getBorderSize() | 无 | 无 | 无 |
setMinPercentage(min: Float) | min(Float) | 无 | 无 |
getMinPercentage() | 无 | 无 | 无 |
setMaxPercentage(max: Float) | max(Float) | 无 | 无 |
getMaxPercentage() | 无 | 无 | 无 |
setFirst(element: UIElementWrapper) | element(UIElementWrapper) | 无 | 无 |
setSecond(element: UIElementWrapper) | element(UIElementWrapper) | 无 | 无 |
getFirst(): UIElementWrapper = UIElementWrapperFactory.wrap(splitView.first) | 无 | 无 | 无 |
getSecond(): UIElementWrapper = UIElementWrapperFactory.wrap(splitView.second) | 无 | 无 | 无 |
createHorizontal() | 无 | 无 | 无 |
createVertical() | 无 | 无 | 无 |
SwitchWrapper
用途:开关控件
典型用法:const sw = ref("switch"); sw.setOn(true)
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
isOn() | 无 | 无 | 无 |
setOn(on: Boolean) | on(Boolean) | 无 | 回调在 UI 线程触发 |
setOnSilent(on: Boolean) | on(Boolean) | 无 | 不触发通知/回调 |
getValue(): Boolean = switch.getValue() | 无 | 无 | 无 |
setValue(value: Boolean) | value(Boolean) | 无 | 无 |
setValueSilent(value: Boolean) | value(Boolean) | 无 | 不触发通知/回调 |
setBaseTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setPressedTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setMarkTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setUnmarkTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setOnSwitchChanged(callback: (Boolean) -> Unit) | callback((Boolean) -> Unit) | 无 | 回调在 UI 线程触发 |
TabViewWrapper
用途:标签页容器
典型用法:const tabs = ref("tabs"); tabs.setOnTabSelected(tab => {})
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
addTab(tab: Tab, content: UIElement, index: Int = -1) | 无 | index=-1 | 无 |
addTabWithWrappers(tab: UIElementWrapper, content: UIElementWrapper, index: Int = -1) | 无 | index=-1 | 无 |
removeTab(tab: Tab) | tab(Tab) | 无 | 无 |
removeTabWrapper(tab: UIElementWrapper) | tab(UIElementWrapper) | 无 | 无 |
clear() | 无 | 无 | 无 |
selectTab(tab: Tab) | tab(Tab) | 无 | 无 |
selectTabWrapper(tab: UIElementWrapper) | tab(UIElementWrapper) | 无 | 无 |
selectTabByIndex(index: Int) | index(Int) | 无 | 无 |
getSelectedTab() | 无 | 无 | 无 |
getTabCount(): Int = tabView.getTabCount() | 无 | 无 | 无 |
getTabAt(index: Int) | index(Int) | 无 | 无 |
getContentOf(tab: Tab) | tab(Tab) | 无 | 无 |
getTabHeaderContainer(): UIElementWrapper = UIElementWrapper(tabView.tabHeaderContainer) | 无 | 无 | 无 |
getTabScroller(): ScrollerViewWrapper = ScrollerViewWrapper(tabView.tabScroller) | 无 | 无 | 无 |
getTabContentContainer(): UIElementWrapper = UIElementWrapper(tabView.tabContentContainer) | 无 | 无 | 无 |
setOnTabSelected(callback: (Tab) -> Unit) | callback((Tab) -> Unit) | 无 | 回调在 UI 线程触发 |
TabWrapper
用途:单个标签页按钮
典型用法:const tab = ref("tab1"); tab.setTextLiteral("装备")
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
isSelected() | 无 | 无 | 无 |
setSelected(selected: Boolean) | selected(Boolean) | 无 | 无 |
setText(text: ComponentWrapper) | text(ComponentWrapper) | 无 | 无 |
setTextString(text: String) | text(String) | 无 | 按翻译 key 解析 |
setTextLiteral(text: String) | text(String) | 无 | 按字面文本,不走翻译 |
setDynamicText(provider: () -> ComponentWrapper) | provider(() -> ComponentWrapper) | 无 | 无 |
setTextColor(color: Int) | color(Int) | 无 | 无 |
setFontSize(size: Float) | size(Float) | 无 | 无 |
setBaseTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setHoverTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setSelectedTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setOnTabSelected(callback: () -> Unit) | callback(() -> Unit) | 无 | 回调在 UI 线程触发 |
setOnTabUnselected(callback: () -> Unit) | callback(() -> Unit) | 无 | 回调在 UI 线程触发 |
hasTabView(): Boolean = tab.getTabView() | 无 | 无 | 无 |
getContent() | 无 | 无 | 无 |
TagFieldWrapper
用途:NBT/Tag 输入框
典型用法:const tag = ref("tag"); tag.setCompoundTagOnly()
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getValue(): Tag = field.getValue() | 无 | 无 | 无 |
setValue(value: Tag?) | value(Tag?) | 无 | 无 |
setValueSilent(value: Tag?) | value(Tag?) | 无 | 不触发通知/回调 |
getValueAsString(): String = field.getValue().toString() | 无 | 无 | 无 |
setTagValidator(validator: (Tag) -> Boolean) | validator((Tag) -> Boolean) | 无 | 无 |
setCompoundTagOnly() | 无 | 无 | 无 |
setListOnly() | 无 | 无 | 无 |
setAny() | 无 | 无 | 无 |
setTagResponder(responder: (Tag) -> Unit) | responder((Tag) -> Unit) | 无 | 无 |
getTextField(): TextFieldWrapper = TextFieldWrapper(field.textField) | 无 | 无 | 无 |
TextAreaWrapper
用途:多行文本输入
典型用法:const area = ref("desc"); area.setText("hello")
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getValue(): Array<String> = textArea.getValue() | 无 | 无 | 无 |
getValueAsString(): String = textArea.getValue().joinToString("\n") | 无 | 无 | 无 |
setLines(lines: List<String>) | lines(List<String>) | 无 | 无 |
setLinesArray(lines: Array<String>) | lines(Array<String>) | 无 | 无 |
setText(text: String) | text(String) | 无 | 无 |
getLines(): List<String> = textArea.getLines() | 无 | 无 | 无 |
getLineCount(): Int = textArea.getLines() | 无 | 无 | 无 |
getCursorLine() | 无 | 无 | 无 |
getCursorCol() | 无 | 无 | 无 |
setCursor(line: Int, col: Int) | line(Int);col(Int) | 无 | 无 |
hasSelection(): Boolean = textArea.hasSelection() | 无 | 无 | 无 |
getSelectionStart() | 无 | 无 | 无 |
getSelectionEnd() | 无 | 无 | 无 |
isError() | 无 | 无 | 无 |
isEditable(): Boolean = textArea.isEditable() | 无 | 无 | 无 |
getScrollX() | 无 | 无 | 无 |
getScrollY() | 无 | 无 | 无 |
setTextColor(color: Int) | color(Int) | 无 | 无 |
setFontSize(size: Float) | size(Float) | 无 | 无 |
setPlaceholder(placeholder: String) | placeholder(String) | 无 | 无 |
setLineSpacing(spacing: Float) | spacing(Float) | 无 | 无 |
pushHistory() | 无 | 无 | 无 |
setOnLinesChanged(callback: (Array<String>) -> Unit) | callback((Array<String>) -> Unit) | 无 | 回调在 UI 线程触发 |
TextElementWrapper
用途:文本元素基础能力
典型用法:const text = ref("title"); text.setTextString("标题")
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getText(): ComponentWrapper = ComponentWrapper.wrap(textElement.text) | 无 | 无 | 无 |
getTextString() | 无 | 无 | 无 |
setText(text: ComponentWrapper) | text(ComponentWrapper) | 无 | 无 |
setTextString(text: String) | text(String) | 无 | 按翻译 key 解析 |
setTextLiteral(text: String) | text(String) | 无 | 按字面文本,不走翻译 |
setTextColor(color: Int) | color(Int) | 无 | 无 |
getTextColor(): Int = textElement.textStyle.textColor() | 无 | 无 | 无 |
setFontSize(size: Float) | size(Float) | 无 | 无 |
getFontSize(): Float = textElement.textStyle.fontSize() | 无 | 无 | 无 |
setTextShadow(shadow: Boolean) | shadow(Boolean) | 无 | 无 |
hasTextShadow(): Boolean = textElement.textStyle.textShadow() | 无 | 无 | 无 |
setAdaptiveWidth(adaptive: Boolean) | adaptive(Boolean) | 无 | 无 |
setAdaptiveHeight(adaptive: Boolean) | adaptive(Boolean) | 无 | 无 |
TextFieldWrapper
用途:单行文本输入
典型用法:const input = ref("name"); input.setText("Steve")
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getText() | 无 | 无 | 无 |
getRawText() | 无 | 无 | 无 |
setText(text: String) | text(String) | 无 | 无 |
setTextSilent(text: String) | text(String) | 无 | 不触发通知/回调 |
getValue(): String = textField.getValue() | 无 | 无 | 无 |
getCursorPosition() | 无 | 无 | 无 |
setCursorPosition(pos: Int) | pos(Int) | 无 | 无 |
getSelectionStart() | 无 | 无 | 无 |
getSelectionEnd() | 无 | 无 | 无 |
setSelection(start: Int, end: Int) | start(Int);end(Int) | 无 | 无 |
getSelectedText(): String = textField.getHighlighted() | 无 | 无 | 无 |
selectAll() | 无 | 无 | 无 |
isError() | 无 | 无 | 无 |
isEditable(): Boolean = textField.isEditable() | 无 | 无 | 无 |
setAnyString() | 无 | 无 | 无 |
setNumbersOnlyInt(minValue: Int = Int.MIN_VALUE, maxValue: Int = Int.MAX_VALUE) | 无 | minValue=Int.MIN_VALUE;maxValue=Int.MAX_VALUE | 无 |
setNumbersOnlyFloat(minValue: Float = -Float.MAX_VALUE, maxValue: Float = Float.MAX_VALUE) | 无 | minValue=-Float.MAX_VALUE;maxValue=Float.MAX_VALUE | 无 |
setResourceLocationOnly() | 无 | 无 | 无 |
setTextColor(color: Int) | color(Int) | 无 | 无 |
getTextColor(): Int = textField.textFieldStyle.textColor() | 无 | 无 | 无 |
setFontSize(size: Float) | size(Float) | 无 | 无 |
getFontSize(): Float = textField.textFieldStyle.fontSize() | 无 | 无 | 无 |
setPlaceholder(placeholder: String) | placeholder(String) | 无 | 无 |
setOnTextChanged(callback: (String) -> Unit) | callback((String) -> Unit) | 无 | 回调在 UI 线程触发 |
ToggleWrapper
用途:带文本的开关按钮
典型用法:const toggle = ref("agree"); toggle.setOn(true)
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
isOn() | 无 | 无 | 无 |
setOn(on: Boolean) | on(Boolean) | 无 | 回调在 UI 线程触发 |
setOnSilent(on: Boolean) | on(Boolean) | 无 | 不触发通知/回调 |
getValue(): Boolean = toggle.getValue() | 无 | 无 | 无 |
setValue(value: Boolean) | value(Boolean) | 无 | 无 |
setValueSilent(value: Boolean) | value(Boolean) | 无 | 不触发通知/回调 |
setText(text: ComponentWrapper) | text(ComponentWrapper) | 无 | 无 |
setTextString(text: String) | text(String) | 无 | 按翻译 key 解析 |
setTextLiteral(text: String) | text(String) | 无 | 按字面文本,不走翻译 |
noText() | 无 | 无 | 无 |
enableText() | 无 | 无 | 无 |
setMarkTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setUnmarkTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setBaseTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setHoverTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setOnToggleChanged(callback: (Boolean) -> Unit) | callback((Boolean) -> Unit) | 无 | 回调在 UI 线程触发 |
hasToggleGroup() | 无 | 无 | 无 |
TreeListWrapper
用途:树形列表
典型用法:const tree = ref("tree"); tree.setOnSelectedChanged(nodes => {})
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
setRoot(root: Any?) | root(Any?) | 无 | 无 |
getRoot() | 无 | 无 | 无 |
reloadList() | 无 | 无 | 无 |
getSelected(): List<Any?> = tree.getSelected().toList() | 无 | 无 | 无 |
getSelectedFirst(): Any? = tree.getSelected().firstOrNull() | 无 | 无 | 无 |
isNodeSelected(node: Any?) | node(Any?) | 无 | 无 |
setSupportMultipleSelection(support: Boolean) | support(Boolean) | 无 | 无 |
isSupportMultipleSelection() | 无 | 无 | 无 |
isNodeExpanded(node: Any?) | node(Any?) | 无 | 无 |
expandNode(node: Any?) | node(Any?) | 无 | 无 |
collapseNode(node: Any?) | node(Any?) | 无 | 无 |
setStaticTree(static: Boolean) | static(Boolean) | 无 | 无 |
isStaticTree() | 无 | 无 | 无 |
setNodeUISupplier(supplier: (Any?) -> UIElementWrapper) | supplier((Any?) -> UIElementWrapper) | 无 | 无 |
setTextTemplate(textMapper: (Any?) -> ComponentWrapper) | textMapper((Any?) -> ComponentWrapper) | 无 | 无 |
setNodeTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setHoverTexture(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setExpandIcon(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setCollapseIcon(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
setOnSelectedChanged(callback: (List<Any?>) -> Unit) | callback((List<Any?>) -> Unit) | 无 | 回调在 UI 线程触发 |
setOnDoubleClickNode(callback: (Any?) -> Unit) | callback((Any?) -> Unit) | 无 | 回调在 UI 线程触发 |
setOnNodeUICreated(callback: (Any?, UIElementWrapper) -> Unit) | callback((Any?);UIElementWrapper) -> Unit(Any) | 无 | 回调在 UI 线程触发 |
UIElementWrapper
用途:所有 UI 元素的基础控制
典型用法:const root = ref("root"); root.addClass("active")
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
getId() | 无 | 无 | 无 |
setId(id: String) | id(String) | 无 | 无 |
isVisible() | 无 | 无 | 无 |
setVisible(visible: Boolean) | visible(Boolean) | 无 | 无 |
isActive() | 无 | 无 | 无 |
setActive(active: Boolean) | active(Boolean) | 无 | 无 |
isFocused() | 无 | 无 | 无 |
isHovered() | 无 | 无 | 无 |
isDisplayed() | 无 | 无 | 无 |
getPositionX() | 无 | 无 | 无 |
getPositionY() | 无 | 无 | 无 |
getWidth() | 无 | 无 | 无 |
getHeight() | 无 | 无 | 无 |
setWidth(width: Float) | width(Float) | 无 | 无 |
setHeight(height: Float) | height(Float) | 无 | 无 |
setSize(width: Float, height: Float) | width(Float);height(Float) | 无 | 无 |
addClass(vararg classNames: String) | vararg classNames(String) | 无 | 无 |
removeClass(vararg classNames: String) | vararg classNames(String) | 无 | 无 |
toggleClass(className: String) | className(String) | 无 | 无 |
hasClass(className: String): Boolean = element.hasClass(className) | 无 | className=element.hasClass(className | 无 |
getClasses(): List<String> = element.classes.toList() | 无 | 无 | 无 |
setBackground(texture: IGuiTexture) | texture(IGuiTexture) | 无 | 无 |
focus() | 无 | 无 | 无 |
blur() | 无 | 无 | 无 |
show() | 无 | 无 | 无 |
hide() | 无 | 无 | 无 |
getProperty(key: String): T? = element.getProperty(key) | 无 | key=element.getProperty(key | 无 |
setProperty(key: String, value: Any?) | key(String);value(Any?) | 无 | 无 |
hasProperty(key: String): Boolean = element.hasProperty(key) | 无 | key=element.hasProperty(key | 无 |
removeProperty(key: String) | key(String) | 无 | 无 |
addEventListener(eventType: String, listener: UIEventListener) | eventType(String);listener(UIEventListener) | 无 | 无 |
removeEventListener(eventType: String, listener: UIEventListener) | eventType(String);listener(UIEventListener) | 无 | 无 |
getChildCount(): Int = element.childCount() | 无 | 无 | 无 |
getParent() | 无 | 无 | 无 |
getChildAt(index: Int) | index(Int) | 无 | 无 |
getChildren() | 无 | 无 | 无 |
addChild(child: UIElementWrapper) | child(UIElementWrapper) | 无 | 无 |
addChildElement(child: UIElement) | child(UIElement) | 无 | 无 |
addChildAt(child: UIElementWrapper, index: Int) | child(UIElementWrapper);index(Int) | 无 | 无 |
removeChild(child: UIElementWrapper) | child(UIElementWrapper) | 无 | 无 |
removeChildElement(child: UIElement) | child(UIElement) | 无 | 无 |
clearChildren() | 无 | 无 | 无 |
hasChild(child: UIElementWrapper) | child(UIElementWrapper) | 无 | 无 |
unwrap() | 无 | 无 | 无 |
UIElementWrapperFactory
用途:包装/解包原始元素与 Store
典型用法:const raw = UIElementWrapperFactory.unwrap(ref("root"))
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
wrap(element: UIElement) | element(UIElement) | 无 | 无 |
wrapStore(store: UIStore) | store(UIStore) | 无 | 无 |
unwrap(wrapper: UIElementWrapper) | wrapper(UIElementWrapper) | 无 | 无 |
unwrapStore(wrapper: UIStoreWrapper) | wrapper(UIStoreWrapper) | 无 | 无 |
isWrapper(obj: Any?) | obj(Any?) | 无 | 无 |
resolveElement(obj: Any?) | obj(Any?) | 无 | 无 |
VirtualListWrapper
用途:大数据虚拟列表
典型用法:const list = ref("list"); list.setItems(items)
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
setItems(items: List<Any?>) | items(List<Any?>) | 无 | 无 |
getItemCount(): Int = list.getItemCount() | 无 | 无 | 无 |
refresh() | 无 | 无 | 无 |
setItemHeight(height: Float) | height(Float) | 无 | 无 |
getItemHeight() | 无 | 无 | 无 |
setBuffer(buffer: Int) | buffer(Int) | 无 | 无 |
getBuffer() | 无 | 无 | 无 |
setRenderItem(renderer: (Any?, Int) -> UIElementWrapper) | renderer((Any?);Int) -> UIElementWrapper(Any) | 无 | 无 |
scrollToIndex(index: Int) | index(Int) | 无 | 无 |
scrollToIndexWithAlign(index: Int, align: String) | index(Int);align(String) | 无 | 无 |
scrollToTop() | 无 | 无 | 无 |
scrollToBottom() | 无 | 无 | 无 |
getTotalHeight(): Float = list.getTotalHeight() | 无 | 无 | 无 |
PonderElementWrapper
用途:Ponder 场景视图(无播放控制)
典型用法:const p = ref("ponder"); p.setSceneId("mymod:scene")
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
setSceneId(sceneId: String?) | sceneId(String?) | 无 | 传空/空白则清空场景 |
setAutoTickScene(value: Boolean) | value(Boolean) | 无 | true 为自动播放 |
setOwnsScene(value: Boolean) | value(Boolean) | 无 | true 为自动 dispose |
setPartialTickOverride(value: Float?) | value(Float?) | 无 | null 为使用渲染 partialTick |
clearPartialTickOverride() | 无 | 无 | 等同于设置为 null |
setRenderSceneOverlay(value: Boolean) | value(Boolean) | 无 | 控制 overlay 显示 |
setZoomEnabled(value: Boolean) | value(Boolean) | 无 | 控制滚轮缩放 |
setPlatformFlash(value: Float) | value(Float) | 无 | 底板闪光强度 |
setScreenOffset(value: Double) | value(Double) | 无 | 场景滑动偏移 |
setScreenOffsetProvider(provider: (Float) -> Double) | provider((Float) -> Double) | 无 | 回调返回偏移 |
PonderPlayerWrapper
用途:Ponder 播放器(带控制条)
典型用法:const player = ref("player"); player.setComponentId("minecraft:piston")
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
setComponentId(componentId: String?) | componentId(String?) | 无 | 传空/空白则清空 |
setPlaying(value: Boolean) | value(Boolean) | 无 | 播放/暂停 |
play() | 无 | 无 | 等同 setPlaying(true) |
pause() | 无 | 无 | 等同 setPlaying(false) |
isPlaying() | 无 | 无 | 无 |
setComfyReadingEnabled(value: Boolean) | value(Boolean) | 无 | 慢速阅读模式 |
isComfyReadingEnabled() | 无 | 无 | 无 |
replay() | 无 | 无 | 重播当前场景 |
prevScene() | 无 | 无 | 切换到上一个场景 |
nextScene() | 无 | 无 | 切换到下一个场景 |
jumpToScene(index: Int) | index(Int) | 无 | 跳转到指定场景 |
seekToTime(time: Int) | time(Int) | 无 | 跳转到指定时间点 |
seekToPercent(percent: Float) | percent(Float) | 无 | 0~1 的进度 |
getSceneCount() | 无 | 无 | 返回场景数量 |
getSceneIndex() | 无 | 无 | 返回当前索引 |
getSceneIds() | 无 | 无 | 返回场景 ID 列表 |
getSceneTitles() | 无 | 无 | 返回标题列表 |
getCurrentSceneId() | 无 | 无 | 返回当前场景 ID |
getCurrentSceneTitle() | 无 | 无 | 返回当前场景标题 |
getCurrentTime() | 无 | 无 | 当前播放时间(tick) |
getTotalTime() | 无 | 无 | 当前场景总时长(tick) |
getProgress() | 无 | 无 | 当前场景进度(0~1) |
setReferredTagId(tagId: String?) | tagId(String?) | 无 | 关联标签(可选) |
setOnCloseRequested(callback: () -> Unit) | callback(() -> Unit) | 无 | 点击关闭按钮时触发 |
setOnTagClicked(callback: (String) -> Unit) | callback((String) -> Unit) | 无 | 参数为 tagId 字符串 |
PonderRuntimeUIWrapper
用途:Ponder 运行时导航 UI(标签索引/章节/播放器)
典型用法:const ui = ref("ponderRuntime"); ui.openTagIndex()
方法签名:
| 方法 | 参数 | 默认值 | 注意事项 |
|---|---|---|---|
openIndex() | 无 | 无 | 进入索引页 |
openTagIndex() | 无 | 无 | 进入标签索引页 |
openTag(tagId: String) | tagId(String) | 无 | 资源 ID(namespace:path) |
openChapter(chapterId: String) | chapterId(String) | 无 | 资源 ID(namespace:path) |
openComponent(componentId: String, referredTagId?: String, chapterId?: String) | componentId(String);referredTagId(String?);chapterId(String?) | 无 | 资源 ID(namespace:path) |
setOnExit(callback: () -> Unit) | callback(() -> Unit) | 无 | 点击返回/退出时触发 |