mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-21 17:45:25 -04:00
deb802cfec
* For now, this is limited to instances inside custom objects. This will be made available in the future for all instances in scenes if this works well.
71 lines
1.6 KiB
TypeScript
71 lines
1.6 KiB
TypeScript
/*
|
|
* GDevelop JS Platform
|
|
* Copyright 2013-2023 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
|
* This project is released under the MIT License.
|
|
*/
|
|
namespace gdjs {
|
|
/** @category Behaviors > Default behaviors */
|
|
export interface TextContainer {
|
|
/**
|
|
* Get the text displayed by the object.
|
|
*/
|
|
getText(): string;
|
|
|
|
/**
|
|
* Set the text displayed by the object.
|
|
* @param text The new text
|
|
*/
|
|
setText(text: string): void;
|
|
}
|
|
|
|
/**
|
|
* A behavior that forwards the TextContainer interface to its object.
|
|
* @category Behaviors > Default behaviors
|
|
*/
|
|
export class TextContainerBehavior
|
|
extends gdjs.RuntimeBehavior
|
|
implements TextContainer
|
|
{
|
|
private object: gdjs.RuntimeObject & TextContainer;
|
|
|
|
constructor(
|
|
instanceContainer: gdjs.RuntimeInstanceContainer,
|
|
behaviorData,
|
|
owner: gdjs.RuntimeObject & TextContainer
|
|
) {
|
|
super(instanceContainer, behaviorData, owner);
|
|
this.object = owner;
|
|
}
|
|
|
|
usesLifecycleFunction(): boolean {
|
|
return false;
|
|
}
|
|
|
|
override applyBehaviorOverriding(behaviorData): boolean {
|
|
// Nothing to update.
|
|
return true;
|
|
}
|
|
|
|
onDeActivate() {}
|
|
|
|
onDestroy() {}
|
|
|
|
doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}
|
|
|
|
doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}
|
|
|
|
getText(): string {
|
|
return this.object.getText();
|
|
}
|
|
|
|
setText(text: string): void {
|
|
this.object.setText(text);
|
|
}
|
|
}
|
|
|
|
gdjs.registerBehavior(
|
|
'TextContainerCapability::TextContainerBehavior',
|
|
gdjs.TextContainerBehavior
|
|
);
|
|
}
|