Bootstrap Chameleon Logo

Variable Placeholder

VariablePlaceholder

变量占位符

JSON文件中的变量在运行时被替换成一个变量的值。下面是TPython中可以的的变量占位符:

"%"

使用最多的占位符,它可以被替换成各种不同的值,具体取决于它所在的控件。 例如SSpinBox中,会被替换为SpinBox的值,按照SSPinBox的类型,可以是float或者int;而在SColorPicker中会被替换成颜色的值。其他文本控件中,会被替换成对应的字符串。

SSpinBox.OnValueChanged SSlider.OnValueChanged SColorPicker.OnColorCommitted SCheckBox.OnCheckStateChanged SExpandableArea.OnAreaExpansionChanged SBreadcrumbTrail.OnCrumbClick SSearchBox.OnTextChanged SEditableText.OnTextChanged SEditableTextBox.OnTextChanged SMultiLineEditableText.OnTextChanged SMultiLineEditableTextBox.OnTextChanged SSearchBox.OnTextCommitted SEditableText.OnTextCommitted SEditableTextBox.OnTextCommitted SMultiLineEditableText.OnTextCommitted SMultiLineEditableTextBox.OnTextCommitted

"%JsonPath"

在Chameleon的界面JSON文件中,我们在"InitPyCmd"中有一个固定写法。例如MinimalExample中的写法:

"InitPyCmd": "import Example; chameleon_example = Example.MinimalExample.MinimalExample(%JsonPath)"

其中的"%JsonPath"在运行时会被替换成当前JSON文件的路径。以便MinimalExample这个类可以获得当前JSON文件的路径。该路径是区分各个ChameleonData实例的唯一标识。

"%actors"

SDropTarget.OnDrop 用于获取用户拖拽的Actor,功能可被"%**kwargs"取代,具体可参考:Drag and Drop Area

"%assets"

SDropTarget.OnDrop 和"%actors"一样,用于获取用户拖拽的资源,功能可被"%**kwargs"取代,具体可参考:Drag and Drop Area

"%folders"

SDropTarget.OnDrop 用户获取用户的拖拽的文件夹,功能可被"%**kwargs"取代,具体可参考:Drag and Drop Area

"%assets_folders"

SDropTarget.OnDrop 用户获取用的拖拽的资源文件夹,功能可被"%**kwargs"取代, 具体:Drag and Drop Area

"%**kwargs"

SDropTarget.OnDrop 运行时会被一个字典值替代,其中key为类型,值为实际物体或者资源的值; 具体:Drag and Drop Area

"%Index"

"%Index" 用户在SListView和STreeView中获取用户点击的Item的索引,具体可参考:List View

SListView.OnSelectedChanged SListView.OnMouseButtonDoubleClick SListView.OnSelectedChanged SListView.OnMouseButtonDoubleClick STreeView.OnSelectedChanged STreeView.OnMouseButtonDoubleClick

"%Item"

和"%Index"一样,用于获取用户点击的Item,具体可参考:List View

SListView.OnSelectionChanged SListView.OnMouseButtonDoubleClick STreeView.OnSelectionChanged

"%uv"

"%uv" 用于获取用户在SImage中点击的UV坐标,具体可参考:Use Images and Image Brush

SImage.OnMouseEnter SImage.OnMouseMove

"%mouse_flags"

同样,"%mouse_flags",用于获取鼠标的按键状态,具体可参考:Use Images and Image Brush

SImage.OnMouseEnter SImage.OnMouseMove SImage.OnMouseLeave

"%WidgetPath"

"%WidgetPath" 用于获取用户点击的SButton的路径,具体可参考: Buttons

SButton.OnClick

"%SelectionType"

"%SelectionType" 用于获取SComboBox的值发生改变的原因。可能的值有:

  • "OnKeyPress"
  • "OnNavigation"
  • "OnMouseClick"
  • "Direct"

SComboBox.OnSelectionChanged

"%map_change_type"

Chameleon Tool中的"OnMapChangedCmd",用于在Map切换时执行Python命令。

用途:

  • 感知关卡切换,并同步更新界面
  • Chameleon工具在关卡切换时清理引用,避免内存泄露或者内存泄露检查触发的崩溃

具体可见OnCloseCallback

  • "LoadMap"
  • "SaveMap"
  • "NewMap"
  • "TearDownWorld"

"%world"

Chameleon Tool中的"OnMapChangedCmd"。和上面的"%map_change_type"一样,用于获取新的世界(关卡)信息。

Extra
在MenuItem中还有"%asset_paths", "%context", "%floatArgs", "%intArgs", "%paths", "%strArgs", "%tool_path"这些占位符,其作用已经完全可被其他工具取代,不再推荐使用。

Keywords

除了变量占位符,"Content","Slots"等关键字,Slate组件中还有一些常见的关键字,或者说是属性名称。以下是其中比较创建常见的关键字。。

  • "Text"
  • "HAlign"
  • "VAlign"
  • "FillColumn"
  • "Padding"
  • "ColorAndOpacity"
  • "WidthOverride"
  • "HeightOverride"
  • "MinDesiredWidth"
  • "MaxDesiredWidth"
  • "MinDesiredHeight"
  • "MaxDesiredHeight"
  • "AutoHeight"
  • "AutoWidth"
  • "ContentPadding"
  • "Orientation"
  • "Thickness"
  • "Font"
  • "Justification"
  • "ShadowOffset"
  • "ShadowColorAndOpacity",
  • "TextStyle"
  • "HintText"
  • "IsReadOnly"
  • "SelectAllTextWhenFocused",
  • "AutoWrapText"
  • "CheckBoxStyle"
  • "FillWidth"
  • "FillHeight"
  • "ItemHeight"
  • "Margin"
  • "IsChecked"
  • "ToolTipText"
  • "OnTextChanged"
  • "OnTextCommitted"
  • "DelayChangeNotificationWhi
  • "Visibility"
  • "Size"
  • "ButtonColorAndOpacity",
  • "ForegroundColor"
  • "BackgroundColor"
  • "MinDesiredSlotWidth"
  • "MinDesiredSlotHeight"
  • "SlotPadding"
  • "ImagePath"
  • "ImagePathInPlugin"
  • "ButtonContent"
  • "OnGetMenuContent"
  • "HasDownArrow"
  • "HighlightText"
  • "WrapTextAt"
  • "WrappingPolicy"
  • "LineHeightPercentage"
  • "Marshaller"
  • "RichText"
  • "DecoratorStyleSet"
  • "ButtonStyle"
  • "Style"
  • "Position"
  • "EnableAnimatedScrolling"
  • "OnTick"
  • "BorderBackgroundColor"
  • "BorderImage"
  • "BodyBorderImage"
  • "HeaderPadding"
  • "AllowAnimatedTransition"
  • "InitiallyCollapsed"
  • "MinWidth"
  • "HeaderContent"
  • "BodyContent"
  • "MinAspectRatio"
  • "MaxAspectRatio"

NOTE
组件独有的关键字未完全包含再其中,可以参考组件自身的API文档

目前支持的SWidget组件有以下43个:

[SWidget](

SMultiLineEditableText SRichTextBlock SColorBlock SColorWheel SImage SProgressBar SSpacer SSlider STextBlock SBox SCanvas SGridPanel SUniformGridPanel SOverlay SUniformWrapPanel SSplitter SHorizontalBox SVerticalBox SComboButton SComboBox SEditableText SHeader SBreadcrumbTrail SCheckBox SColorPicker SDropTarget SScrollBox SSpinBox SThrobber SExpandableArea SBorder SHeaderRow SSeparator SButton SHyperlink SMultiLineEditableTextBox" SEditableTextBox SSearchBox SListView SListView STreeView SDetailsView SWebBrowser