From d077f7bbe6c5fe5ea757801fa4bc185ae9f49348 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 30 Dec 2024 19:17:06 +0800 Subject: [PATCH] More WA bindings added. [skip CI] --- Tools/WasmGen/gen.yue | 307 +++++---- Tools/dora-wa/vendor/dora/action.wa | 2 +- Tools/dora-wa/vendor/dora/align_node.wa | 26 +- Tools/dora-wa/vendor/dora/array.wa | 2 +- Tools/dora-wa/vendor/dora/audio.wa | 16 +- Tools/dora-wa/vendor/dora/body.wa | 2 +- Tools/dora-wa/vendor/dora/body_def.wa | 2 +- Tools/dora-wa/vendor/dora/camera_2d.wa | 41 +- Tools/dora-wa/vendor/dora/camera_otho.wa | 29 +- Tools/dora-wa/vendor/dora/clip_node.wa | 41 +- Tools/dora-wa/vendor/dora/controller.wa | 16 +- Tools/dora-wa/vendor/dora/db.wa | 61 +- Tools/dora-wa/vendor/dora/dbparams.wa | 29 +- Tools/dora-wa/vendor/dora/dbquery.wa | 32 +- Tools/dora-wa/vendor/dora/dbrecord.wa | 25 +- Tools/dora-wa/vendor/dora/dictionary.wa | 2 +- Tools/dora-wa/vendor/dora/director.wa | 64 +- Tools/dora-wa/vendor/dora/dora.wa | 89 +++ Tools/dora-wa/vendor/dora/dragon_bone.wa | 54 +- Tools/dora-wa/vendor/dora/draw_node.wa | 50 +- Tools/dora-wa/vendor/dora/effect.wa | 2 +- Tools/dora-wa/vendor/dora/effek_node.wa | 29 +- Tools/dora-wa/vendor/dora/entity.wa | 38 +- Tools/dora-wa/vendor/dora/grid.wa | 103 ++- Tools/dora-wa/vendor/dora/group.wa | 48 +- Tools/dora-wa/vendor/dora/http_client.wa | 51 +- Tools/dora-wa/vendor/dora/im_gui.wa | 627 +++++++++++++++++- Tools/dora-wa/vendor/dora/joint.wa | 62 +- Tools/dora-wa/vendor/dora/joint_def.wa | 64 +- Tools/dora-wa/vendor/dora/keyboard.wa | 16 +- Tools/dora-wa/vendor/dora/label.wa | 126 +++- Tools/dora-wa/vendor/dora/line.wa | 51 +- Tools/dora-wa/vendor/dora/model.wa | 83 ++- Tools/dora-wa/vendor/dora/motor_joint.wa | 34 +- Tools/dora-wa/vendor/dora/mouse.wa | 19 +- Tools/dora-wa/vendor/dora/move_joint.wa | 22 +- Tools/dora-wa/vendor/dora/node.wa | 2 +- Tools/dora-wa/vendor/dora/nvg.wa | 190 +++++- Tools/dora-wa/vendor/dora/observer.wa | 23 +- Tools/dora-wa/vendor/dora/particle.wa | 35 +- Tools/dora-wa/vendor/dora/pass.wa | 2 +- Tools/dora-wa/vendor/dora/physics_world.wa | 2 +- .../vendor/dora/platformer/behavior/tree.wa | 34 - .../vendor/dora/platformer/decision/tree.wa | 26 - Tools/dora-wa/vendor/dora/platformer/unit.wa | 72 -- .../vendor/dora/platformer/unit_action.wa | 28 - ..._update.wa => platformer_action_update.wa} | 32 +- ...d.wa => platformer_behavior_blackboard.wa} | 21 +- .../vendor/dora/platformer_behavior_tree.wa | 91 +++ .../bullet.wa => platformer_bullet.wa} | 53 +- ...bullet_def.wa => platformer_bullet_def.wa} | 77 ++- .../data.wa => platformer_data.wa} | 73 +- .../ai.wa => platformer_decision_ai.wa} | 25 +- .../vendor/dora/platformer_decision_tree.wa | 76 +++ .../face.wa => platformer_face.wa} | 41 +- ...amera.wa => platformer_platform_camera.wa} | 73 +- ..._world.wa => platformer_platform_world.wa} | 53 +- ...et_allow.wa => platformer_target_allow.wa} | 48 +- Tools/dora-wa/vendor/dora/platformer_unit.wa | 198 ++++++ .../vendor/dora/platformer_unit_action.wa | 94 +++ .../visual.wa => platformer_visual.wa} | 35 +- Tools/dora-wa/vendor/dora/playable.wa | 76 ++- Tools/dora-wa/vendor/dora/q_learner.wa | 45 +- Tools/dora-wa/vendor/dora/rect.wa | 2 +- Tools/dora-wa/vendor/dora/render_target.wa | 60 +- Tools/dora-wa/vendor/dora/scheduler.wa | 2 +- Tools/dora-wa/vendor/dora/spine.wa | 57 +- Tools/dora-wa/vendor/dora/sprite.wa | 11 +- Tools/dora-wa/vendor/dora/sprite_effect.wa | 2 +- Tools/dora-wa/vendor/dora/svg.wa | 35 +- Tools/dora-wa/vendor/dora/texture_2d.wa | 5 +- Tools/dora-wa/vendor/dora/tile_node.wa | 78 ++- Tools/dora-wa/vendor/dora/touch.wa | 37 +- Tools/dora-wa/vendor/dora/vertex_color.wa | 38 +- Tools/dora-wa/vendor/dora/vgnode.wa | 32 +- Tools/dora-wa/vendor/dora/vgpaint.wa | 19 +- Tools/dora-wa/vendor/dora/view.wa | 57 +- 77 files changed, 3856 insertions(+), 369 deletions(-) delete mode 100644 Tools/dora-wa/vendor/dora/platformer/behavior/tree.wa delete mode 100644 Tools/dora-wa/vendor/dora/platformer/decision/tree.wa delete mode 100644 Tools/dora-wa/vendor/dora/platformer/unit.wa delete mode 100644 Tools/dora-wa/vendor/dora/platformer/unit_action.wa rename Tools/dora-wa/vendor/dora/{platformer/action_update.wa => platformer_action_update.wa} (55%) rename Tools/dora-wa/vendor/dora/{platformer/behavior/blackboard.wa => platformer_behavior_blackboard.wa} (65%) create mode 100644 Tools/dora-wa/vendor/dora/platformer_behavior_tree.wa rename Tools/dora-wa/vendor/dora/{platformer/bullet.wa => platformer_bullet.wa} (56%) rename Tools/dora-wa/vendor/dora/{platformer/bullet_def.wa => platformer_bullet_def.wa} (54%) rename Tools/dora-wa/vendor/dora/{platformer/data.wa => platformer_data.wa} (53%) rename Tools/dora-wa/vendor/dora/{platformer/decision/ai.wa => platformer_decision_ai.wa} (61%) create mode 100644 Tools/dora-wa/vendor/dora/platformer_decision_tree.wa rename Tools/dora-wa/vendor/dora/{platformer/face.wa => platformer_face.wa} (54%) rename Tools/dora-wa/vendor/dora/{platformer/platform_camera.wa => platformer_platform_camera.wa} (53%) rename Tools/dora-wa/vendor/dora/{platformer/platform_world.wa => platformer_platform_world.wa} (54%) rename Tools/dora-wa/vendor/dora/{platformer/target_allow.wa => platformer_target_allow.wa} (53%) create mode 100644 Tools/dora-wa/vendor/dora/platformer_unit.wa create mode 100644 Tools/dora-wa/vendor/dora/platformer_unit_action.wa rename Tools/dora-wa/vendor/dora/{platformer/visual.wa => platformer_visual.wa} (61%) diff --git a/Tools/WasmGen/gen.yue b/Tools/WasmGen/gen.yue index cafdc7569..06e78f161 100755 --- a/Tools/WasmGen/gen.yue +++ b/Tools/WasmGen/gen.yue @@ -359,7 +359,11 @@ basicTypes = convertTo: -> error "unsupported" argType: "*string" returnType: "*string" - creturn: (name, fnArgId) -> "#{name}, _ := stack#{fnArgId}.PopStr()" + creturn: (name, fnArgId) -> "#{name}: *string = nil + #{name}_, #{name}_ok := stack#{fnArgId}.PopStr() + if #{name}_ok { + #{name} = &#{name}_ + }" cpass: -> error "unsupported" } NVGpaint: @@ -373,10 +377,10 @@ basicTypes = * -> error "unsupported" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> "VGPaintFrom(#{name})" + convertFrom: (name)-> "*VGPaintFrom(#{name})" convertTo: (name)-> "#{name}.GetRaw()" - argType: "NVGpaint" - returnType: "NVGpaint" + argType: "VGPaint" + returnType: "VGPaint" creturn: -> error "unsupported" cpass: -> error "unsupported" } @@ -391,11 +395,11 @@ basicTypes = * (fnArgId)-> "crate::dora::DBParams::from(stack#{fnArgId}.pop_i64().unwrap())" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: (name)-> "*DBParamsFrom(#{name})" + convertTo: (name)-> "#{name}.GetRaw()" argType: "DBParams" returnType: "DBParams" - creturn: (name, fnArgId)-> "#{name}, _ := DBParamsFrom(stack#{fnArgId}.PopI64())" + creturn: (name, fnArgId)-> "#{name}_raw, _ := stack#{fnArgId}.PopI64()\n\t\t#{name} := *DBParamsFrom(#{name}_raw)" cpass: -> error "unsupported" } DBRecord: @@ -409,11 +413,11 @@ basicTypes = * (fnArgId)-> "crate::dora::DBRecord::from(stack#{fnArgId}.pop_i64().unwrap())" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: (name)-> "*DBRecordFrom(#{name})" + convertTo: (name)-> "#{name}.GetRaw()" argType: "DBRecord" returnType: "DBRecord" - creturn: (name, fnArgId)-> "#{name}, _ := DBRecordFrom(stack#{fnArgId}.PopI64())" + creturn: (name, fnArgId)-> "#{name}_raw, _ := stack#{fnArgId}.PopI64()\n\t\t#{name} := *DBRecordFrom(#{name}_raw)" cpass: -> error "unsupported" } DBQuery: @@ -427,8 +431,8 @@ basicTypes = * -> error "unsupported" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: (name)-> "*DBQueryFrom(#{name})" + convertTo: (name)-> "#{name}.GetRaw()" argType: "DBQuery" returnType: "DBQuery" creturn: -> error "unsupported" @@ -549,8 +553,8 @@ basicTypes = * -> error "unsupported" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: (name)-> "*VertexColor(#{name})" + convertTo: (name)-> "#{name}.GetRaw()" argType: "VertexColor" returnType: "VertexColor" creturn: -> error "unsupported" @@ -567,8 +571,12 @@ basicTypes = * -> error "unsupported" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: (name)-> "FromDoraVertexColorBuf(#{name})" + convertTo: (name)-> "ToDoraVertexColorBuf(#{name})" + argType: "*[]VertexColor" + returnType: "*[]VertexColor" + creturn: -> error "unsupported" + cpass: -> error "unsupported" } ActionDef: * "i64" @@ -617,8 +625,12 @@ basicTypes = * -> error "unsupported" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: -> error "unsupported" + convertTo: (name)-> "ToDoraPlatformerBehaviorTreeBuf(#{name})" + argType: "*[]PlatformerBehaviorTree" + returnType: "*[]PlatformerBehaviorTree" + creturn: -> error "unsupported" + cpass: -> error "unsupported" } VecDTree: * "i64" @@ -631,8 +643,12 @@ basicTypes = * -> error "unsupported" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: -> error "unsupported" + convertTo: (name)-> "ToDoraPlatformerDecisionTreeBuf(#{name})" + argType: "*[]PlatformerDecisionTree" + returnType: "*[]PlatformerDecisionTree" + creturn: -> error "unsupported" + cpass: -> error "unsupported" } BlendFunc: * "i64" @@ -688,20 +704,6 @@ basicTypes = creturn: (name, fnArgId)-> "#{name}, _ := stack#{fnArgId}.PopI32()" cpass: -> error "unsupported" } - "Platformer::TargetAllow": - * "i64" - * (name)-> "*r_cast(#{name})" - * (name)-> "r_cast(new Platformer::TargetAllow{#{name}})" - * "&crate::dora::platformer::TargetAllow" - * "crate::dora::platformer::TargetAllow" - * (name)-> "#{name}.raw()" - * (name)-> "crate::dora::platformer::TargetAllow::from(#{name})" - * -> error "unsupported" - * -> error "unsupported" - * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name - } EntityEvent: * "i32" * (name)-> "s_cast(#{name})" @@ -713,8 +715,12 @@ basicTypes = * -> error "unsupported" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: (name)-> "EntityEvent{value: #{name}}" + convertTo: (name)-> "#{name}.ToValue()" + argType: "EntityEvent" + returnType: "EntityEvent" + creturn: -> error "unsupported" + cpass: -> error "unsupported" } TextureWrap: * "i32" @@ -767,6 +773,8 @@ basicTypes = convertTo: (name)-> "#{name}.ToValue()" argType: "EaseType" returnType: "EaseType" + creturn: -> error "unsupported" + cpass: -> error "unsupported" } Property: * "i32" @@ -783,6 +791,8 @@ basicTypes = convertTo: (name)-> "#{name}.ToValue()" argType: "Property" returnType: "Property" + creturn: -> error "unsupported" + cpass: -> error "unsupported" } TextAlign: * "i32" @@ -795,8 +805,12 @@ basicTypes = * -> error "unsupported" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: (name)-> "TextAlign{value: #{name}}" + convertTo: (name)-> "#{name}.ToValue()" + argType: "TextAlign" + returnType: "TextAlign" + creturn: -> error "unsupported" + cpass: -> error "unsupported" } BodyType: * "i32" @@ -813,6 +827,8 @@ basicTypes = convertTo: (name)-> "#{name}.ToValue()" argType: "BodyType" returnType: "BodyType" + creturn: -> error "unsupported" + cpass: -> error "unsupported" } "Platformer::Relation": * "i32" @@ -825,8 +841,12 @@ basicTypes = * -> error "unsupported" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: (name)-> "PlatformerRelation{value: #{name}}" + convertTo: (name)-> "#{name}.ToValue()" + argType: "PlatformerRelation" + returnType: "PlatformerRelation" + creturn: -> error "unsupported" + cpass: -> error "unsupported" } "Platformer::Behavior::Blackboard": * "i64" @@ -839,11 +859,11 @@ basicTypes = * (fnArgId)-> "&crate::dora::platformer::behavior::Blackboard::from(stack#{fnArgId}.pop_i64().unwrap()).unwrap()" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> "*BlackboardFrom(#{name})" + convertFrom: (name)-> "*PlatformerBehaviorBlackboardFrom(#{name})" convertTo: (name)-> "#{name}.GetRaw()" - argType: "Blackboard" - returnType: "Blackboard" - creturn: (name, fnArgId)-> "#{name}, _ := stack#{fnArgId}.PopI64()" + argType: "PlatformerBehaviorBlackboard" + returnType: "PlatformerBehaviorBlackboard" + creturn: (name, fnArgId)-> "#{name}_raw, _ := stack#{fnArgId}.PopI64()\n\t\t#{name} := *PlatformerBehaviorBlackboardFrom(#{name}_raw)" cpass: -> error "unsupported" } "Platformer::UnitAction": @@ -857,11 +877,41 @@ basicTypes = * (fnArgId)-> "&crate::dora::platformer::UnitAction::from(stack#{fnArgId}.pop_i64().unwrap()).unwrap()" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: (name, isOptional)-> "#{isOptional and '' or '*'}PlatformerUnitActionFrom(#{name})" + convertTo: (name)-> "#{name}.GetRaw()" + argType: "PlatformerUnitAction" + returnType: "PlatformerUnitAction" + creturn: (name, fnArgId)-> "#{name}_raw, _ := stack#{fnArgId}.PopI64()\n\t\t#{name} := *PlatformerUnitActionFrom(#{name}_raw)" + cpass: -> error "unsupported" + } + "Platformer::TargetAllow": + * "i64" + * (name)-> "*r_cast(#{name})" + * (name)-> "r_cast(new Platformer::TargetAllow{#{name}})" + * "&crate::dora::platformer::TargetAllow" + * "crate::dora::platformer::TargetAllow" + * (name)-> "#{name}.raw()" + * (name)-> "crate::dora::platformer::TargetAllow::from(#{name})" + * -> error "unsupported" + * -> error "unsupported" + * --[[10: wa type]] { + convertFrom: (name)-> "*PlatformerTargetAllowFrom(#{name})" + convertTo: (name)-> "#{name}.GetRaw()" + argType: "PlatformerTargetAllow" + returnType: "PlatformerTargetAllow" + creturn: -> error "unsupported" + cpass: -> error "unsupported" } void: {} + +toSnakeCase = (name)-> table.concat [sub\lower! for sub in (name\sub(1, 1)\lower! .. name\sub(2))\gsub("%d", "_%1")\gsub("%u", "_%1")\gsub("(%d)_", "%1")\gmatch "[^_]*"], "_" + +snakeToPascal = (snakeStr)-> + snakeStr + \gsub "_(%a)", (letter) -> letter\upper! + \gsub "^%l", (first) -> first\upper! + const WaTypeIndex = 10 getWaType = (dataType, waName): t -> if dataType == "void" @@ -870,13 +920,17 @@ getWaType = (dataType, waName): t -> if not waName if "*" == dataType\sub -1 waName = dataType\match "[^ \t*]+" + if waName + waName = snakeToPascal waName\gsub "::", "_" + elseif not t + print "missing type def:", dataType t ??= { convertFrom: (name)-> "*#{waName}From(#{name})" convertTo: (name)-> "#{name}.GetRaw()" argType: waName returnType: waName and "#{waName}" or "" creturn: (name, fnArgId)-> "#{name} := *#{waName}From(stack#{fnArgId}.PopObject().GetRaw())" - cpass: (name, fnArgId)-> "stack#{fnArgId}.Push(#{name})" + cpass: (name, fnArgId)-> "stack#{fnArgId}.Push(#{name}.Object)" } lastPos = 1 @@ -935,13 +989,6 @@ with io.open "Dora.h", "r" result = match File, codes -toSnakeCase = (name)-> table.concat [sub\lower! for sub in (name\sub(1, 1)\lower! .. name\sub(2))\gsub("%d", "_%1")\gsub("%u", "_%1")\gsub("(%d)_", "%1")\gmatch "[^_]*"], "_" - -snakeToPascal = (snakeStr)-> - snakeStr - \gsub "_(%a)", (letter) -> letter\upper! - \gsub "^%l", (first) -> first\upper! - if not result if lastPos > #codes lastPos = #codes - 1 @@ -1010,7 +1057,7 @@ else table.remove moduleScopes, #moduleScopes continue [_, _, clsNames] = cls - {clsName, clsNewName} = clsNames + [clsName, clsNewName] = clsNames clsNewName or= clsName if #moduleScopes > 0 moduleScope = table.concat moduleScopes, "::" @@ -1042,6 +1089,7 @@ else if clsParent clsParent = nameMap[clsParent] or clsParent clsNewName or= clsName + const waNewName = (cppNamespace .. clsNewName)\gsub "::", "" isSingleton = false isObject = false isValue = false @@ -1102,40 +1150,43 @@ impl I#{clsNewName} for #{clsNewName} { }" unless isTrait rustBinding[] = "impl #{clsNewName} {" waBinding[] = if isObject - "type #{clsNewName} struct { #{clsParent\sub 2} } -func #{clsNewName}From(raw: i64) => *#{clsNewName} { + "type #{waNewName} struct { #{clsParent\sub 2} } +func #{waNewName}From(raw: i64) => *#{waNewName} { if raw == 0 { return nil } - object := #{clsNewName}{} + object := #{waNewName}{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) result := &object return result } -func #{clsNewName}.GetTypeId() => i32 { +func #{waNewName}.GetTypeId() => i32 { return #{namespace}#{clsNewNameL}_type() }" else if isStatic or isSingleton - "type _#{clsNewName} struct { }\nglobal #{clsNewName} = _#{clsNewName}{}" + "type _#{waNewName} struct { }\nglobal #{waNewName} = _#{waNewName}{}" else - finalizer = toSnakeCase "#{clsNewName}Finalizer" - "type #{clsNewName} struct { raw: *i64 } -func #{clsNewName}.GetRaw() => i64 { - return *this.raw -} -func #{finalizer}(ptr: u32) { + finalizer = toSnakeCase "#{waNewName}Finalizer" + finalizerWrapper = if isValue + "func #{finalizer}(ptr: u32) { #{namespace}#{clsNewNameL}_release(GetPtr(ptr)) } -func #{clsNewName}From(raw: i64) => *#{clsNewName} { +" + else "" + finalizerCall = if isValue then " setFinalizer(item.raw, #{finalizer})\n" else "" + "type #{waNewName} struct { raw: *i64 } +func #{waNewName}.GetRaw() => i64 { + return *this.raw +} +#{finalizerWrapper}func #{waNewName}From(raw: i64) => *#{waNewName} { if raw == 0 { return nil } - item := #{clsNewName}{} + item := #{waNewName}{} item.raw = &raw - setFinalizer(item.raw, #{finalizer}) - result := &item +#{finalizerCall} result := &item return result }" rustExtern[] = "extern \"C\" {" @@ -1178,7 +1229,7 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { [itemType,] = clsItem switch itemType when "field" - [_, docs, labels, dataType, name, newName] = clsItem + const [_, docs, labels, dataType, name, newName] = clsItem funcName = name\sub(1, 1)\lower! .. name\sub 2 funcName = table.concat [sub\lower! for sub in funcName\gsub("%u", "_%1")\gmatch "[^_]*"], "_" funcNewName = newName or name @@ -1211,9 +1262,11 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { if funcNewName\sub(1, 1) == "_" pub = "pub(crate) " rustType = basicTypes[dataType] + waName = nil if rustType == nil and "*" == dataType\sub -1 dataTypeName = dataType\match "[^ \t*]+" rustName = nameMap[dataTypeName] or dataTypeName + waName = rustName rustType = getObjectType dataTypeName, rustName, false, isOptional if not isReadonly and not interfaces[rustName] objectUsed = nil @@ -1261,13 +1314,13 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { slfDecl = isStatic and "" or "&mut self, " slf = isStatic and "" or "self.raw(), " "#{docText}\t#{pub}fn #{rustSetterName}(#{slfDecl}val: #{rtTypeIn or rt}) {\n\t\tunsafe { #{cppSetterName}(#{slf}#{rtCast and rtCast('val') or 'val'}) };\n\t}" - waType = getWaType dataType, rustName + waType = getWaType dataType, waName waBinding[] = if isSingleton - "func _#{clsNewName}.#{waSetterName}(val: #{waType.argType}) {\n\t#{cppSetterName}(#{waType.convertTo 'val'})\n}" + "func _#{waNewName}.#{waSetterName}(val: #{waType.argType}) {\n\t#{cppSetterName}(#{waType.convertTo 'val'})\n}" elseif isStatic - "func #{clsNewName}#{waSetterName}(val: #{waType.argType}) {\n\t#{cppSetterName}(#{waType.convertTo 'val'})\n}" + "func #{waNewName}#{waSetterName}(val: #{waType.argType}) {\n\t#{cppSetterName}(#{waType.convertTo 'val'})\n}" else - "func #{clsNewName}.#{waSetterName}(val: #{waType.argType}) {\n\t#{cppSetterName}(*this.raw, #{waType.convertTo 'val'})\n}" + "func #{waNewName}.#{waSetterName}(val: #{waType.argType}) {\n\t#{cppSetterName}(*this.raw, #{waType.convertTo 'val'})\n}" docText = if #docs > 0 text = table.concat docs, '\n\t' '\t' .. text\sub(1, 4) .. 'Gets' .. text\sub(4) .. '\n' @@ -1313,7 +1366,7 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { slf = isStatic and "" or "self.raw()" item = "#{cppGetterName}(#{slf})" "#{docText}\t#{pub}fn #{rustGetterName}(#{slfDecl}) -> #{rtTypeOut or rt} {\n\t\treturn unsafe { #{rtCastFrom and rtCastFrom(item) or item} };\n\t}" - waType = assert getWaType dataType, rustName + waType = assert getWaType dataType, waName waReturnType = isOptional and "*#{waType.returnType}" or waType.returnType waReturn = (item) -> if isOptional @@ -1327,18 +1380,18 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { "\treturn #{waType.convertFrom item}" waBinding[] = if isSingleton item = "#{cppGetterName}()" - "func _#{clsNewName}.#{waGetterName}() => #{waReturnType} {\n#{waReturn item}\n}" + "func _#{waNewName}.#{waGetterName}() => #{waReturnType} {\n#{waReturn item}\n}" elseif isStatic item = "#{cppGetterName}()" - "func #{clsNewName}#{waGetterName}() => #{waReturnType} {\n#{waReturn item}\n}" + "func #{waNewName}#{waGetterName}() => #{waReturnType} {\n#{waReturn item}\n}" else item = "#{cppGetterName}(*this.raw)" - "func #{clsNewName}.#{waGetterName}() => #{waReturnType} {\n#{waReturn item}\n}" + "func #{waNewName}.#{waGetterName}() => #{waReturnType} {\n#{waReturn item}\n}" else error "\"#{dataType}\" is not supported." when "method" funcCount += 1 - [_, docs, labels, dataType, name, newName, args, constFlag] = clsItem + const [_, docs, labels, dataType, name, newName, args, constFlag] = clsItem funcNewName = newName or name funcName = name\sub(1, 1)\lower! .. name\sub 2 funcName = table.concat [sub\lower! for sub in funcName\gsub("%u", "_%1")\gmatch "[^_]*"], "_" @@ -1373,12 +1426,15 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { if funcNewName\sub(1,1) == "_" pub = "pub(crate) " rustType = basicTypes[dataType] + waName = nil if rustType == nil and "*" == dataType\sub -1 dataTypeName = dataType\match "[^ \t*]+" rustName = if isCreate + waName = (cppNamespace .. clsNewName)\gsub "::", "" clsNewName else - nameMap[dataTypeName] or dataTypeName + waName = nameMap[dataTypeName] or dataTypeName + waName rustType = getObjectType dataTypeName, rustName, isCreate, isOptional if rustType [rt, cast, castFrom, _, rtTypeOut, _, rtCastFrom] = rustType @@ -1394,9 +1450,9 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { rustTypeA = basicTypes[argType] if rustTypeA == nil and "*" == argType\sub -1 argTypeName = argType\match "[^ \t*]+" - rustName = nameMap[argTypeName] or argTypeName - rustTypeA = getObjectType argTypeName, rustName - objectUsed = nil unless interfaces[rustName] + rustArgName = nameMap[argTypeName] or argTypeName + rustTypeA = getObjectType argTypeName, rustArgName + objectUsed = nil unless interfaces[rustArgName] if rustTypeA [rtA, castA, _, rtTypeInA, _, rtCastA] = rustTypeA cppTypeA = cppTypes[rtA] @@ -1476,8 +1532,8 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { frRetType = basicTypes[freturnType] if frRetType == nil and "*" == freturnType\sub -1 freturnType = freturnType\sub 1, -2 - rustName = nameMap[freturnType] or freturnType - frRetType = getObjectType freturnType, rustName + frustName = nameMap[freturnType] or freturnType + frRetType = getObjectType freturnType, frustName if frRetType {frt, _2, _3, _4, frtTypeOut, _6, _7, _8, frPush} = frRetType callbackType = if frtTypeOut @@ -1592,7 +1648,7 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { else '' "#{docText}\t#{pub}fn #{rustFuncName}(#{argRtInDefs})#{rtOut and ' -> ' .. rtOut or ''} {\n#{argRtPrepare}\t\tunsafe { #{prefix}#{rtCastFrom and rtCastFrom(item, isOptional) or item}; }\n\t}" - waType = getWaType dataType, rustName + waType = getWaType dataType, waName waReturnType = if waType isOptional and " => *#{waType.returnType}" or do waType.returnType == "" and "" or " => #{waType.returnType}" @@ -1615,7 +1671,9 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { [argKind, argType, argName] = arg argName = toSnakeCase argName switch argKind when "variable" - wType = getWaType argType + fargTypeName = argType\match "[^ \t*]+" + fargTypeName = nameMap[fargTypeName] or fargTypeName + wType = getWaType argType, fargTypeName { :argName argType: wType.argType @@ -1630,15 +1688,19 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { [_, func, fname] = arg fname = toSnakeCase fname [freturnType, fargs] = func - rtpObj = getWaType(freturnType) + freturnTypeName = freturnType\match "[^ \t*]+" + freturnName = nameMap[freturnTypeName] or freturnTypeName + rtpObj = getWaType freturnType, freturnName rtp = freturnType == "void" and "" or " => #{rtpObj.returnType}" - callbackConverted = "func_id#{funcArgCount}, *stack#{funcArgCount}.raw" + callbackConverted = "func_id#{funcArgCount}" + callbackConverted ..= ", *stack#{funcArgCount}.raw" if #fargs > 0 or rtp ~= "" argTypeStrs = [] popArgs = [] popArgNames = [] for farg in *fargs [_, fargType, fargName] = farg - atp = switch fargType\match "[^ \t*]+" + fargTypeName = fargType\match "[^ \t*]+" + atp = switch fargTypeName when "Event" { convertFrom: -> error "unsupported" @@ -1648,16 +1710,10 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { creturn: (name, fnArgId)-> "#{name} := stack#{fnArgId}" cpass: -> error "unsupported" } - when "Platformer::Behavior::Blackboard", "Platformer::UnitAction" - getWaType fargType - when "DBRecord" - getWaType fargType - when "MLQState", "MLQAction" - getWaType fargType when nil error "\"#{fargType}\" is not supported." else - getWaType fargType + getWaType fargType, nameMap[fargTypeName] or fargTypeName argTypeStrs[] = "#{toSnakeCase fargName}: #{atp.argType}" if atp.creturn == nil print fargType @@ -1670,8 +1726,9 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { "#{fname}(#{table.concat popArgNames, ', ' })" else "result_ := #{fname}(#{table.concat popArgNames, ', ' })\n\t\t#{rtpObj.cpass 'result_', fnArgId}" - prepareArgs[] = " stack#{funcArgCount} := NewCallStack() - func_id#{funcArgCount} := PushFunction(func() { + if #fargs > 0 or rtp ~= "" + prepareArgs[] = " stack#{funcArgCount} := NewCallStack()" + prepareArgs[] = " func_id#{funcArgCount} := PushFunction(func() { #{popArgStr} #{callFunc} })" callbackName = fname @@ -1689,26 +1746,27 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { prepareStr = prepareStr == "" and "" or "#{prepareStr}\n" waBinding[] = if isSingleton item = "#{cppFuncName}(#{argsConverted})" - "func _#{clsNewName}.#{waFuncName}(#{argsList})#{waReturnType} { + "func _#{waNewName}.#{waFuncName}(#{argsList})#{waReturnType} { #{prepareStr} #{waReturn item} }" elseif isCreate + dealOptional = isOptional and "if raw == 0 {\n\t\treturn nil\n\t}\n\tobject := #{waNewName}{}" or "object := #{waNewName}{}" waFuncName = if funcNewName == "new" then "" else snakeToPascal funcNewName - "func New#{clsNewName}#{waFuncName}(#{argsList})#{waReturnType} { - object := #{clsNewName}{} - raw := #{cppFuncName}(#{argsConverted}) + "func New#{waNewName}#{waFuncName}(#{argsList})#{waReturnType} { +#{prepareStr} raw := #{cppFuncName}(#{argsConverted}) + #{dealOptional} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return #{isOptional and '&object' or 'object'} }" elseif isStatic item = "#{cppFuncName}(#{argsConverted})" - "func #{clsNewName}#{waFuncName}(#{argsList})#{waReturnType} { + "func #{waNewName}#{waFuncName}(#{argsList})#{waReturnType} { #{prepareStr} #{waReturn item} }" else item = "#{cppFuncName}(*this.raw#{argsConverted == "" and "" or ", " .. argsConverted})" - "func #{clsNewName}.#{waFuncName}(#{argsList})#{waReturnType} { + "func #{waNewName}.#{waFuncName}(#{argsList})#{waReturnType} { #{prepareStr} #{waReturn item} }" else @@ -1744,42 +1802,13 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { \write table.concat rustExtern, "\n" \write "\n" \write table.concat rustBinding, "\n" - close _f3 = with io.open "../dora-wa/vendor/dora/#{moduleScope ~= '' and moduleScope .. "/" .. moduleName or moduleName}.wa", "w" + moduleScope = table.concat [toSnakeCase(mod) for mod in *moduleScopes], "_" + close _f3 = with io.open "../dora-wa/vendor/dora/#{moduleScope ~= '' and moduleScope .. "_" .. moduleName or moduleName}.wa", "w" \write licenseText \write "\n\n" \write table.concat waExtern, "\n" - if moduleName in [ - "array" - "dictionary" - "app" - "node" - "scheduler" - "action_def" - "action" - "grabber" - "camera" - "sprite_effect" - "effect" - "pass" - "sprite" - "rect" - "texture_2d" - "ease" - "path" - "content" - "work_book" - "work_sheet" - "body_def" - "body" - "physics_world" - "sensor" - "fixture_def" - "buffer" - "c_45" - "cache" - ] - \write "\n" - \write table.concat waBinding, "\n" + \write "\n" + \write table.concat waBinding, "\n" rustExtern = [] rustBinding = [] waExtern = [] diff --git a/Tools/dora-wa/vendor/dora/action.wa b/Tools/dora-wa/vendor/dora/action.wa index 98587b4ae..c4eaee701 100644 --- a/Tools/dora-wa/vendor/dora/action.wa +++ b/Tools/dora-wa/vendor/dora/action.wa @@ -75,8 +75,8 @@ func Action.UpdateTo(elapsed: f32, reversed: bool) { action_update_to(*this.raw, elapsed, ToDoraBool(reversed)) } func NewAction(def: ActionDef) => Action { - object := Action{} raw := action_new(def.GetRaw()) + object := Action{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/align_node.wa b/Tools/dora-wa/vendor/dora/align_node.wa index 505c2b966..cb8399785 100644 --- a/Tools/dora-wa/vendor/dora/align_node.wa +++ b/Tools/dora-wa/vendor/dora/align_node.wa @@ -11,4 +11,28 @@ func alignnode_type() => i32 #wa:import dora alignnode_css func alignnode_css(slf: i64, style: i64) #wa:import dora alignnode_new -func alignnode_new(is_window_root: i32) => i64 \ No newline at end of file +func alignnode_new(is_window_root: i32) => i64 +type AlignNode struct { Node } +func AlignNodeFrom(raw: i64) => *AlignNode { + if raw == 0 { + return nil + } + object := AlignNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func AlignNode.GetTypeId() => i32 { + return alignnode_type() +} +func AlignNode.Css(style: string) { + alignnode_css(*this.raw, ToDoraString(style)) +} +func NewAlignNode(is_window_root: bool) => AlignNode { + raw := alignnode_new(ToDoraBool(is_window_root)) + object := AlignNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/array.wa b/Tools/dora-wa/vendor/dora/array.wa index 59212ad61..256cc8e36 100644 --- a/Tools/dora-wa/vendor/dora/array.wa +++ b/Tools/dora-wa/vendor/dora/array.wa @@ -75,8 +75,8 @@ func Array.FastRemoveAt(index: i32) => bool { return array_fast_remove_at(*this.raw, index) != 0 } func NewArray() => Array { - object := Array{} raw := array_new() + object := Array{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/audio.wa b/Tools/dora-wa/vendor/dora/audio.wa index 3cfdab197..b4ff887b0 100644 --- a/Tools/dora-wa/vendor/dora/audio.wa +++ b/Tools/dora-wa/vendor/dora/audio.wa @@ -13,4 +13,18 @@ func audio_stop(handle: i32) #wa:import dora audio_play_stream func audio_play_stream(filename: i64, looping: i32, cross_fade_time: f32) #wa:import dora audio_stop_stream -func audio_stop_stream(fade_time: f32) \ No newline at end of file +func audio_stop_stream(fade_time: f32) +type _Audio struct { } +global Audio = _Audio{} +func _Audio.Play(filename: string, looping: bool) => i32 { + return audio_play(ToDoraString(filename), ToDoraBool(looping)) +} +func _Audio.Stop(handle: i32) { + audio_stop(handle) +} +func _Audio.PlayStream(filename: string, looping: bool, cross_fade_time: f32) { + audio_play_stream(ToDoraString(filename), ToDoraBool(looping), cross_fade_time) +} +func _Audio.StopStream(fade_time: f32) { + audio_stop_stream(fade_time) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/body.wa b/Tools/dora-wa/vendor/dora/body.wa index 667bde412..f62fce9ba 100644 --- a/Tools/dora-wa/vendor/dora/body.wa +++ b/Tools/dora-wa/vendor/dora/body.wa @@ -181,8 +181,8 @@ func Body.OnContactFilter(filter: func(body: Body) => bool) { body_on_contact_filter(*this.raw, func_id0, *stack0.raw) } func NewBody(def: BodyDef, world: PhysicsWorld, pos: Vec2, rot: f32) => Body { - object := Body{} raw := body_new(def.GetRaw(), world.GetRaw(), pos.ToValue(), rot) + object := Body{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/body_def.wa b/Tools/dora-wa/vendor/dora/body_def.wa index b86c7fb39..620cb3bc4 100644 --- a/Tools/dora-wa/vendor/dora/body_def.wa +++ b/Tools/dora-wa/vendor/dora/body_def.wa @@ -220,8 +220,8 @@ func BodyDef.AttachDiskSensor(tag: i32, radius: f32) { bodydef_attach_disk_sensor(*this.raw, tag, radius) } func NewBodyDef() => BodyDef { - object := BodyDef{} raw := bodydef_new() + object := BodyDef{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/camera_2d.wa b/Tools/dora-wa/vendor/dora/camera_2d.wa index 93e04858a..5bbead0b9 100644 --- a/Tools/dora-wa/vendor/dora/camera_2d.wa +++ b/Tools/dora-wa/vendor/dora/camera_2d.wa @@ -21,4 +21,43 @@ func camera2d_set_position(slf: i64, val: i64); #wa:import dora camera2d_get_position func camera2d_get_position(slf: i64) => i64 #wa:import dora camera2d_new -func camera2d_new(name: i64) => i64 \ No newline at end of file +func camera2d_new(name: i64) => i64 +type Camera2D struct { Camera } +func Camera2DFrom(raw: i64) => *Camera2D { + if raw == 0 { + return nil + } + object := Camera2D{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Camera2D.GetTypeId() => i32 { + return camera2d_type() +} +func Camera2D.SetRotation(val: f32) { + camera2d_set_rotation(*this.raw, val) +} +func Camera2D.GetRotation() => f32 { + return camera2d_get_rotation(*this.raw) +} +func Camera2D.SetZoom(val: f32) { + camera2d_set_zoom(*this.raw, val) +} +func Camera2D.GetZoom() => f32 { + return camera2d_get_zoom(*this.raw) +} +func Camera2D.SetPosition(val: Vec2) { + camera2d_set_position(*this.raw, val.ToValue()) +} +func Camera2D.GetPosition() => Vec2 { + return Vec2FromValue(camera2d_get_position(*this.raw)) +} +func NewCamera2D(name: string) => Camera2D { + raw := camera2d_new(ToDoraString(name)) + object := Camera2D{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/camera_otho.wa b/Tools/dora-wa/vendor/dora/camera_otho.wa index 8e82a052a..377f7b3c4 100644 --- a/Tools/dora-wa/vendor/dora/camera_otho.wa +++ b/Tools/dora-wa/vendor/dora/camera_otho.wa @@ -13,4 +13,31 @@ func cameraotho_set_position(slf: i64, val: i64); #wa:import dora cameraotho_get_position func cameraotho_get_position(slf: i64) => i64 #wa:import dora cameraotho_new -func cameraotho_new(name: i64) => i64 \ No newline at end of file +func cameraotho_new(name: i64) => i64 +type CameraOtho struct { Camera } +func CameraOthoFrom(raw: i64) => *CameraOtho { + if raw == 0 { + return nil + } + object := CameraOtho{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func CameraOtho.GetTypeId() => i32 { + return cameraotho_type() +} +func CameraOtho.SetPosition(val: Vec2) { + cameraotho_set_position(*this.raw, val.ToValue()) +} +func CameraOtho.GetPosition() => Vec2 { + return Vec2FromValue(cameraotho_get_position(*this.raw)) +} +func NewCameraOtho(name: string) => CameraOtho { + raw := cameraotho_new(ToDoraString(name)) + object := CameraOtho{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/clip_node.wa b/Tools/dora-wa/vendor/dora/clip_node.wa index 23f55123b..674203601 100644 --- a/Tools/dora-wa/vendor/dora/clip_node.wa +++ b/Tools/dora-wa/vendor/dora/clip_node.wa @@ -21,4 +21,43 @@ func clipnode_set_inverted(slf: i64, val: i32); #wa:import dora clipnode_is_inverted func clipnode_is_inverted(slf: i64) => i32 #wa:import dora clipnode_new -func clipnode_new(stencil: i64) => i64 \ No newline at end of file +func clipnode_new(stencil: i64) => i64 +type ClipNode struct { Node } +func ClipNodeFrom(raw: i64) => *ClipNode { + if raw == 0 { + return nil + } + object := ClipNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func ClipNode.GetTypeId() => i32 { + return clipnode_type() +} +func ClipNode.SetStencil(val: Node) { + clipnode_set_stencil(*this.raw, val.GetRaw()) +} +func ClipNode.GetStencil() => Node { + return *NodeFrom(clipnode_get_stencil(*this.raw)) +} +func ClipNode.SetAlphaThreshold(val: f32) { + clipnode_set_alpha_threshold(*this.raw, val) +} +func ClipNode.GetAlphaThreshold() => f32 { + return clipnode_get_alpha_threshold(*this.raw) +} +func ClipNode.SetInverted(val: bool) { + clipnode_set_inverted(*this.raw, ToDoraBool(val)) +} +func ClipNode.IsInverted() => bool { + return clipnode_is_inverted(*this.raw) != 0 +} +func NewClipNode(stencil: Node) => ClipNode { + raw := clipnode_new(stencil.GetRaw()) + object := ClipNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/controller.wa b/Tools/dora-wa/vendor/dora/controller.wa index 9cc201807..c25e77849 100644 --- a/Tools/dora-wa/vendor/dora/controller.wa +++ b/Tools/dora-wa/vendor/dora/controller.wa @@ -13,4 +13,18 @@ func controller__is_button_up(controller_id: i32, name: i64) => i32 #wa:import dora controller__is_button_pressed func controller__is_button_pressed(controller_id: i32, name: i64) => i32 #wa:import dora controller__get_axis -func controller__get_axis(controller_id: i32, name: i64) => f32 \ No newline at end of file +func controller__get_axis(controller_id: i32, name: i64) => f32 +type _Controller struct { } +global Controller = _Controller{} +func _Controller.IsButtonDown(controller_id: i32, name: string) => bool { + return controller__is_button_down(controller_id, ToDoraString(name)) != 0 +} +func _Controller.IsButtonUp(controller_id: i32, name: string) => bool { + return controller__is_button_up(controller_id, ToDoraString(name)) != 0 +} +func _Controller.IsButtonPressed(controller_id: i32, name: string) => bool { + return controller__is_button_pressed(controller_id, ToDoraString(name)) != 0 +} +func _Controller.GetAxis(controller_id: i32, name: string) => f32 { + return controller__get_axis(controller_id, ToDoraString(name)) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/db.wa b/Tools/dora-wa/vendor/dora/db.wa index ac557b6a8..182b3ed1a 100644 --- a/Tools/dora-wa/vendor/dora/db.wa +++ b/Tools/dora-wa/vendor/dora/db.wa @@ -29,4 +29,63 @@ func db_query_with_params_async(sql: i64, params: i64, with_columns: i32, func0: #wa:import dora db_insert_async func db_insert_async(table_name: i64, values: i64, func0: i32, stack0: i64) #wa:import dora db_exec_async -func db_exec_async(sql: i64, values: i64, func0: i32, stack0: i64) \ No newline at end of file +func db_exec_async(sql: i64, values: i64, func0: i32, stack0: i64) +type _DB struct { } +global DB = _DB{} +func _DB.Exist(table_name: string) => bool { + return db_exist(ToDoraString(table_name)) != 0 +} +func _DB.ExistSchema(table_name: string, schema: string) => bool { + return db_exist_schema(ToDoraString(table_name), ToDoraString(schema)) != 0 +} +func _DB.Exec(sql: string) => i32 { + return db_exec(ToDoraString(sql)) +} +func _DB.Transaction(query: DBQuery) => bool { + return db_transaction(query.GetRaw()) != 0 +} +func _DB.TransactionAsync(query: DBQuery, callback: func(result: bool)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + result, _ := stack0.PopBool() + callback(result) + }) + db_transaction_async(query.GetRaw(), func_id0, *stack0.raw) +} +func _DB.Query(sql: string, with_columns: bool) => DBRecord { + return *DBRecordFrom(db_query(ToDoraString(sql), ToDoraBool(with_columns))) +} +func _DB.QueryWithParams(sql: string, params: Array, with_columns: bool) => DBRecord { + return *DBRecordFrom(db_query_with_params(ToDoraString(sql), params.GetRaw(), ToDoraBool(with_columns))) +} +func _DB.Insert(table_name: string, values: DBParams) { + db_insert(ToDoraString(table_name), values.GetRaw()) +} +func _DB.ExecWithRecords(sql: string, values: DBParams) => i32 { + return db_exec_with_records(ToDoraString(sql), values.GetRaw()) +} +func _DB.QueryWithParamsAsync(sql: string, params: Array, with_columns: bool, callback: func(result: DBRecord)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + result_raw, _ := stack0.PopI64() + result := *DBRecordFrom(result_raw) + callback(result) + }) + db_query_with_params_async(ToDoraString(sql), params.GetRaw(), ToDoraBool(with_columns), func_id0, *stack0.raw) +} +func _DB.InsertAsync(table_name: string, values: DBParams, callback: func(result: bool)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + result, _ := stack0.PopBool() + callback(result) + }) + db_insert_async(ToDoraString(table_name), values.GetRaw(), func_id0, *stack0.raw) +} +func _DB.ExecAsync(sql: string, values: DBParams, callback: func(row_changes: i64)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + rowChanges, _ := stack0.PopI64() + callback(rowChanges) + }) + db_exec_async(ToDoraString(sql), values.GetRaw(), func_id0, *stack0.raw) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/dbparams.wa b/Tools/dora-wa/vendor/dora/dbparams.wa index 45f4ad98f..3ff95b0b6 100644 --- a/Tools/dora-wa/vendor/dora/dbparams.wa +++ b/Tools/dora-wa/vendor/dora/dbparams.wa @@ -11,4 +11,31 @@ func dbparams_release(raw: i64) #wa:import dora dbparams_add func dbparams_add(slf: i64, params: i64) #wa:import dora dbparams_new -func dbparams_new() => i64 \ No newline at end of file +func dbparams_new() => i64 +type DBParams struct { raw: *i64 } +func DBParams.GetRaw() => i64 { + return *this.raw +} +func d_b_params_finalizer(ptr: u32) { + dbparams_release(GetPtr(ptr)) +} +func DBParamsFrom(raw: i64) => *DBParams { + if raw == 0 { + return nil + } + item := DBParams{} + item.raw = &raw + setFinalizer(item.raw, d_b_params_finalizer) + result := &item + return result +} +func DBParams.Add(params: Array) { + dbparams_add(*this.raw, params.GetRaw()) +} +func NewDBParams() => DBParams { + raw := dbparams_new() + object := DBParams{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/dbquery.wa b/Tools/dora-wa/vendor/dora/dbquery.wa index 0f1e456de..dd3dfd3b4 100644 --- a/Tools/dora-wa/vendor/dora/dbquery.wa +++ b/Tools/dora-wa/vendor/dora/dbquery.wa @@ -13,4 +13,34 @@ func dbquery_add_with_params(slf: i64, sql: i64, params: i64) #wa:import dora dbquery_add func dbquery_add(slf: i64, sql: i64) #wa:import dora dbquery_new -func dbquery_new() => i64 \ No newline at end of file +func dbquery_new() => i64 +type DBQuery struct { raw: *i64 } +func DBQuery.GetRaw() => i64 { + return *this.raw +} +func d_b_query_finalizer(ptr: u32) { + dbquery_release(GetPtr(ptr)) +} +func DBQueryFrom(raw: i64) => *DBQuery { + if raw == 0 { + return nil + } + item := DBQuery{} + item.raw = &raw + setFinalizer(item.raw, d_b_query_finalizer) + result := &item + return result +} +func DBQuery.AddWithParams(sql: string, params: DBParams) { + dbquery_add_with_params(*this.raw, ToDoraString(sql), params.GetRaw()) +} +func DBQuery.Add(sql: string) { + dbquery_add(*this.raw, ToDoraString(sql)) +} +func NewDBQuery() => DBQuery { + raw := dbquery_new() + object := DBQuery{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/dbrecord.wa b/Tools/dora-wa/vendor/dora/dbrecord.wa index e670acb6e..c733ca25a 100644 --- a/Tools/dora-wa/vendor/dora/dbrecord.wa +++ b/Tools/dora-wa/vendor/dora/dbrecord.wa @@ -11,4 +11,27 @@ func dbrecord_release(raw: i64) #wa:import dora dbrecord_is_valid func dbrecord_is_valid(slf: i64) => i32 #wa:import dora dbrecord_read -func dbrecord_read(slf: i64, record: i64) => i32 \ No newline at end of file +func dbrecord_read(slf: i64, record: i64) => i32 +type DBRecord struct { raw: *i64 } +func DBRecord.GetRaw() => i64 { + return *this.raw +} +func d_b_record_finalizer(ptr: u32) { + dbrecord_release(GetPtr(ptr)) +} +func DBRecordFrom(raw: i64) => *DBRecord { + if raw == 0 { + return nil + } + item := DBRecord{} + item.raw = &raw + setFinalizer(item.raw, d_b_record_finalizer) + result := &item + return result +} +func DBRecord.IsValid() => bool { + return dbrecord_is_valid(*this.raw) != 0 +} +func DBRecord.Read(record: Array) => bool { + return dbrecord_read(*this.raw, record.GetRaw()) != 0 +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/dictionary.wa b/Tools/dora-wa/vendor/dora/dictionary.wa index 352304544..617a92902 100644 --- a/Tools/dora-wa/vendor/dora/dictionary.wa +++ b/Tools/dora-wa/vendor/dora/dictionary.wa @@ -40,8 +40,8 @@ func Dictionary.Clear() { dictionary_clear(*this.raw) } func NewDictionary() => Dictionary { - object := Dictionary{} raw := dictionary_new() + object := Dictionary{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/director.wa b/Tools/dora-wa/vendor/dora/director.wa index 92f72f1ee..058f82323 100644 --- a/Tools/dora-wa/vendor/dora/director.wa +++ b/Tools/dora-wa/vendor/dora/director.wa @@ -37,4 +37,66 @@ func director_remove_camera(camera: i64) => i32 #wa:import dora director_clear_camera func director_clear_camera() #wa:import dora director_cleanup -func director_cleanup() \ No newline at end of file +func director_cleanup() +type _Director struct { } +global Director = _Director{} +func _Director.SetClearColor(val: Color) { + director_set_clear_color(val.ToARGB()) +} +func _Director.GetClearColor() => Color { + return ColorFromARGB(director_get_clear_color()) +} +func _Director.GetUi() => Node { + return *NodeFrom(director_get_ui()) +} +func _Director.GetUi_3d() => Node { + return *NodeFrom(director_get_ui_3d()) +} +func _Director.GetEntry() => Node { + return *NodeFrom(director_get_entry()) +} +func _Director.GetPostNode() => Node { + return *NodeFrom(director_get_post_node()) +} +func _Director.GetCurrentCamera() => Camera { + return *CameraFrom(director_get_current_camera()) +} +func _Director.SetFrustumCulling(val: bool) { + director_set_frustum_culling(ToDoraBool(val)) +} +func _Director.IsFrustumCulling() => bool { + return director_is_frustum_culling() != 0 +} +func _Director.Schedule(update_func: func(delta_time: f64) => bool) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + deltaTime, _ := stack0.PopF64() + result_ := update_func(deltaTime) + stack0.Push(result_) + }) + director_schedule(func_id0, *stack0.raw) +} +func _Director.SchedulePosted(update_func: func(delta_time: f64) => bool) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + deltaTime, _ := stack0.PopF64() + result_ := update_func(deltaTime) + stack0.Push(result_) + }) + director_schedule_posted(func_id0, *stack0.raw) +} +func _Director.PushCamera(camera: Camera) { + director_push_camera(camera.GetRaw()) +} +func _Director.PopCamera() { + director_pop_camera() +} +func _Director.RemoveCamera(camera: Camera) => bool { + return director_remove_camera(camera.GetRaw()) != 0 +} +func _Director.ClearCamera() { + director_clear_camera() +} +func _Director.Cleanup() { + director_cleanup() +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/dora.wa b/Tools/dora-wa/vendor/dora/dora.wa index a6cd0e9c0..03fa987ab 100644 --- a/Tools/dora-wa/vendor/dora/dora.wa +++ b/Tools/dora-wa/vendor/dora/dora.wa @@ -152,6 +152,39 @@ func ToDoraActionDefBuf(v: *[]ActionDef) => i64 { return ptr } +func ToDoraVertexColorBuf(v: *[]VertexColor) => i64 { + length := len(*v) + ptr := buf_new_i64(i32(length)) + vecs := make([]i64, length) + for i := 0; i < length; i++ { + vecs[i] = (*v)[i].GetRaw() + } + buf_write_ptr(ptr, waI64SliceToPtr(vecs)) + return ptr +} + +func ToDoraPlatformerBehaviorTreeBuf(v: *[]PlatformerBehaviorTree) => i64 { + length := len(*v) + ptr := buf_new_i64(i32(length)) + vecs := make([]i64, length) + for i := 0; i < length; i++ { + vecs[i] = (*v)[i].GetRaw() + } + buf_write_ptr(ptr, waI64SliceToPtr(vecs)) + return ptr +} + +func ToDoraPlatformerDecisionTreeBuf(v: *[]PlatformerDecisionTree) => i64 { + length := len(*v) + ptr := buf_new_i64(i32(length)) + vecs := make([]i64, length) + for i := 0; i < length; i++ { + vecs[i] = (*v)[i].GetRaw() + } + buf_write_ptr(ptr, waI64SliceToPtr(vecs)) + return ptr +} + func FromDoraI32Buf(v: i64) => *[]i32 { length := buf_len(v) buf := make([]i32, length) @@ -202,6 +235,17 @@ func FromDoraVec2Buf(v: i64) => *[]Vec2 { return &vecs } +func FromDoraVertexColorBuf(v: i64) => *[]VertexColor { + length := buf_len(v) + buf := make([]i64, length) + buf_read_ptr(waI64SliceToPtr(buf), v) + vecs := make([]VertexColor, length) + for i := 0; i < int(length); i++ { + vecs[i] = *VertexColorFrom(buf[i]) + } + return &vecs +} + /* Object */ #wa:import dora object_get_id @@ -1468,3 +1512,48 @@ func BodyType.ToValue() => i32 { global BodyTypeDynamic = BodyType{value: 0} global BodyTypeStatic = BodyType{value: 1} global BodyTypeKinematic = BodyType{value: 2} + +/* EntityEvent */ + +type EntityEvent :struct { + value: i32 +} + +func EntityEvent.ToValue() => i32 { + return this.value +} + +global EntityEventAdd = EntityEvent{value: 1} +global EntityEventChange = EntityEvent{value: 2} +global EntityEventAddOrChange = EntityEvent{value: 3} +global EntityEventRemove = EntityEvent{value: 4} + +/* TextAlign */ + +type TextAlign :struct { + value: i32 +} + +func TextAlign.ToValue() => i32 { + return this.value +} + +global TextAlignLeft = TextAlign{value: 0} +global TextAlignCenter = TextAlign{value: 1} +global TextAlignRight = TextAlign{value: 2} + +/* PlatformerRelation */ + +type PlatformerRelation :struct { + value: i32 +} + +func PlatformerRelation.ToValue() => i32 { + return this.value +} + +global PlatformerRelationUnknown = PlatformerRelation{value: 0} +global PlatformerRelationFriend = PlatformerRelation{value: 1} +global PlatformerRelationNeutral = PlatformerRelation{value: 2} +global PlatformerRelationEnemy = PlatformerRelation{value: 4} +global PlatformerRelationAny = PlatformerRelation{value: 7} diff --git a/Tools/dora-wa/vendor/dora/dragon_bone.wa b/Tools/dora-wa/vendor/dora/dragon_bone.wa index 82ed04a7b..7401ef2e2 100644 --- a/Tools/dora-wa/vendor/dora/dragon_bone.wa +++ b/Tools/dora-wa/vendor/dora/dragon_bone.wa @@ -23,4 +23,56 @@ func dragonbone_new(bone_str: i64) => i64 #wa:import dora dragonbone_get_looks func dragonbone_get_looks(bone_str: i64) => i64 #wa:import dora dragonbone_get_animations -func dragonbone_get_animations(bone_str: i64) => i64 \ No newline at end of file +func dragonbone_get_animations(bone_str: i64) => i64 +type DragonBone struct { Playable } +func DragonBoneFrom(raw: i64) => *DragonBone { + if raw == 0 { + return nil + } + object := DragonBone{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func DragonBone.GetTypeId() => i32 { + return dragonbone_type() +} +func DragonBone.SetHitTestEnabled(val: bool) { + dragonbone_set_hit_test_enabled(*this.raw, ToDoraBool(val)) +} +func DragonBone.IsHitTestEnabled() => bool { + return dragonbone_is_hit_test_enabled(*this.raw) != 0 +} +func DragonBone.ContainsPoint(x: f32, y: f32) => string { + return FromDoraString(dragonbone_contains_point(*this.raw, x, y)) +} +func DragonBone.IntersectsSegment(x_1: f32, y_1: f32, x_2: f32, y_2: f32) => string { + return FromDoraString(dragonbone_intersects_segment(*this.raw, x_1, y_1, x_2, y_2)) +} +func NewDragonBoneWithFiles(bone_file: string, atlas_file: string) => *DragonBone { + raw := dragonbone_with_files(ToDoraString(bone_file), ToDoraString(atlas_file)) + if raw == 0 { + return nil + } + object := DragonBone{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} +func NewDragonBone(bone_str: string) => *DragonBone { + raw := dragonbone_new(ToDoraString(bone_str)) + if raw == 0 { + return nil + } + object := DragonBone{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} +func DragonBoneGetLooks(bone_str: string) => *[]string { + return FromDoraStrBuf(dragonbone_get_looks(ToDoraString(bone_str))) +} +func DragonBoneGetAnimations(bone_str: string) => *[]string { + return FromDoraStrBuf(dragonbone_get_animations(ToDoraString(bone_str))) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/draw_node.wa b/Tools/dora-wa/vendor/dora/draw_node.wa index 284555dd8..5692a2881 100644 --- a/Tools/dora-wa/vendor/dora/draw_node.wa +++ b/Tools/dora-wa/vendor/dora/draw_node.wa @@ -27,4 +27,52 @@ func drawnode_draw_vertices(slf: i64, verts: i64) #wa:import dora drawnode_clear func drawnode_clear(slf: i64) #wa:import dora drawnode_new -func drawnode_new() => i64 \ No newline at end of file +func drawnode_new() => i64 +type DrawNode struct { Node } +func DrawNodeFrom(raw: i64) => *DrawNode { + if raw == 0 { + return nil + } + object := DrawNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func DrawNode.GetTypeId() => i32 { + return drawnode_type() +} +func DrawNode.SetDepthWrite(val: bool) { + drawnode_set_depth_write(*this.raw, ToDoraBool(val)) +} +func DrawNode.IsDepthWrite() => bool { + return drawnode_is_depth_write(*this.raw) != 0 +} +func DrawNode.SetBlendFunc(blend_func: BlendFunc) { + drawnode__set_blend_func(*this.raw, blend_func.ToValue()) +} +func DrawNode.GetBlendFunc() => BlendFunc { + return BlendFuncFrom(drawnode__get_blend_func(*this.raw)) +} +func DrawNode.DrawDot(pos: Vec2, radius: f32, color: Color) { + drawnode_draw_dot(*this.raw, pos.ToValue(), radius, color.ToARGB()) +} +func DrawNode.DrawSegment(from: Vec2, to: Vec2, radius: f32, color: Color) { + drawnode_draw_segment(*this.raw, from.ToValue(), to.ToValue(), radius, color.ToARGB()) +} +func DrawNode.DrawPolygon(verts: *[]Vec2, fill_color: Color, border_width: f32, border_color: Color) { + drawnode_draw_polygon(*this.raw, ToDoraVec2Buf(verts), fill_color.ToARGB(), border_width, border_color.ToARGB()) +} +func DrawNode.DrawVertices(verts: *[]VertexColor) { + drawnode_draw_vertices(*this.raw, ToDoraVertexColorBuf(verts)) +} +func DrawNode.Clear() { + drawnode_clear(*this.raw) +} +func NewDrawNode() => DrawNode { + raw := drawnode_new() + object := DrawNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/effect.wa b/Tools/dora-wa/vendor/dora/effect.wa index a6b19256f..98023fd39 100644 --- a/Tools/dora-wa/vendor/dora/effect.wa +++ b/Tools/dora-wa/vendor/dora/effect.wa @@ -45,8 +45,8 @@ func Effect.Clear() { effect_clear(*this.raw) } func NewEffect(vert_shader: string, frag_shader: string) => Effect { - object := Effect{} raw := effect_new(ToDoraString(vert_shader), ToDoraString(frag_shader)) + object := Effect{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/effek_node.wa b/Tools/dora-wa/vendor/dora/effek_node.wa index 0efa8c65f..931627f6c 100644 --- a/Tools/dora-wa/vendor/dora/effek_node.wa +++ b/Tools/dora-wa/vendor/dora/effek_node.wa @@ -13,4 +13,31 @@ func effeknode_play(slf: i64, filename: i64, pos: i64, z: f32) => i32 #wa:import dora effeknode_stop func effeknode_stop(slf: i64, handle: i32) #wa:import dora effeknode_new -func effeknode_new() => i64 \ No newline at end of file +func effeknode_new() => i64 +type EffekNode struct { Node } +func EffekNodeFrom(raw: i64) => *EffekNode { + if raw == 0 { + return nil + } + object := EffekNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func EffekNode.GetTypeId() => i32 { + return effeknode_type() +} +func EffekNode.Play(filename: string, pos: Vec2, z: f32) => i32 { + return effeknode_play(*this.raw, ToDoraString(filename), pos.ToValue(), z) +} +func EffekNode.Stop(handle: i32) { + effeknode_stop(*this.raw, handle) +} +func NewEffekNode() => EffekNode { + raw := effeknode_new() + object := EffekNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/entity.wa b/Tools/dora-wa/vendor/dora/entity.wa index d755180b8..a4ad00063 100644 --- a/Tools/dora-wa/vendor/dora/entity.wa +++ b/Tools/dora-wa/vendor/dora/entity.wa @@ -19,4 +19,40 @@ func entity_remove(slf: i64, key: i64) #wa:import dora entity_destroy func entity_destroy(slf: i64) #wa:import dora entity_new -func entity_new() => i64 \ No newline at end of file +func entity_new() => i64 +type Entity struct { Object } +func EntityFrom(raw: i64) => *Entity { + if raw == 0 { + return nil + } + object := Entity{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Entity.GetTypeId() => i32 { + return entity_type() +} +func EntityGetCount() => i32 { + return entity_get_count() +} +func Entity.GetIndex() => i32 { + return entity_get_index(*this.raw) +} +func EntityClear() { + entity_clear() +} +func Entity.Remove(key: string) { + entity_remove(*this.raw, ToDoraString(key)) +} +func Entity.Destroy() { + entity_destroy(*this.raw) +} +func NewEntity() => Entity { + raw := entity_new() + object := Entity{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/grid.wa b/Tools/dora-wa/vendor/dora/grid.wa index c990642cb..dc9ef02c3 100644 --- a/Tools/dora-wa/vendor/dora/grid.wa +++ b/Tools/dora-wa/vendor/dora/grid.wa @@ -49,4 +49,105 @@ func grid_with_texture_rect(texture: i64, texture_rect: i64, grid_x: i32, grid_y #wa:import dora grid_with_texture func grid_with_texture(texture: i64, grid_x: i32, grid_y: i32) => i64 #wa:import dora grid_with_file -func grid_with_file(clip_str: i64, grid_x: i32, grid_y: i32) => i64 \ No newline at end of file +func grid_with_file(clip_str: i64, grid_x: i32, grid_y: i32) => i64 +type Grid struct { Node } +func GridFrom(raw: i64) => *Grid { + if raw == 0 { + return nil + } + object := Grid{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Grid.GetTypeId() => i32 { + return grid_type() +} +func Grid.GetGridX() => i32 { + return grid_get_grid_x(*this.raw) +} +func Grid.GetGridY() => i32 { + return grid_get_grid_y(*this.raw) +} +func Grid.SetDepthWrite(val: bool) { + grid_set_depth_write(*this.raw, ToDoraBool(val)) +} +func Grid.IsDepthWrite() => bool { + return grid_is_depth_write(*this.raw) != 0 +} +func Grid.SetBlendFunc(blend_func: BlendFunc) { + grid__set_blend_func(*this.raw, blend_func.ToValue()) +} +func Grid.GetBlendFunc() => BlendFunc { + return BlendFuncFrom(grid__get_blend_func(*this.raw)) +} +func Grid.SetEffect(val: SpriteEffect) { + grid_set_effect(*this.raw, val.GetRaw()) +} +func Grid.GetEffect() => SpriteEffect { + return *SpriteEffectFrom(grid_get_effect(*this.raw)) +} +func Grid.SetTextureRect(val: Rect) { + grid_set_texture_rect(*this.raw, val.GetRaw()) +} +func Grid.GetTextureRect() => Rect { + return *RectFrom(grid_get_texture_rect(*this.raw)) +} +func Grid.SetTexture(val: Texture2D) { + grid_set_texture(*this.raw, val.GetRaw()) +} +func Grid.GetTexture() => *Texture2D { + ptr_ := grid_get_texture(*this.raw) + if ptr_ == 0 { + return nil + } + obj_ := *Texture2DFrom(ptr_) + return &obj_ +} +func Grid.SetPos(x: i32, y: i32, pos: Vec2, z: f32) { + grid_set_pos(*this.raw, x, y, pos.ToValue(), z) +} +func Grid.GetPos(x: i32, y: i32) => Vec2 { + return Vec2FromValue(grid_get_pos(*this.raw, x, y)) +} +func Grid.SetColor(x: i32, y: i32, color: Color) { + grid_set_color(*this.raw, x, y, color.ToARGB()) +} +func Grid.GetColor(x: i32, y: i32) => Color { + return ColorFromARGB(grid_get_color(*this.raw, x, y)) +} +func Grid.MoveUv(x: i32, y: i32, offset: Vec2) { + grid_move_uv(*this.raw, x, y, offset.ToValue()) +} +func NewGrid(width: f32, height: f32, grid_x: i32, grid_y: i32) => Grid { + raw := grid_new(width, height, grid_x, grid_y) + object := Grid{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} +func NewGridWithTextureRect(texture: Texture2D, texture_rect: Rect, grid_x: i32, grid_y: i32) => Grid { + raw := grid_with_texture_rect(texture.GetRaw(), texture_rect.GetRaw(), grid_x, grid_y) + object := Grid{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} +func NewGridWithTexture(texture: Texture2D, grid_x: i32, grid_y: i32) => Grid { + raw := grid_with_texture(texture.GetRaw(), grid_x, grid_y) + object := Grid{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} +func NewGridWithFile(clip_str: string, grid_x: i32, grid_y: i32) => *Grid { + raw := grid_with_file(ToDoraString(clip_str), grid_x, grid_y) + if raw == 0 { + return nil + } + object := Grid{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/group.wa b/Tools/dora-wa/vendor/dora/group.wa index ed5f0eda8..ca84a16a1 100644 --- a/Tools/dora-wa/vendor/dora/group.wa +++ b/Tools/dora-wa/vendor/dora/group.wa @@ -15,4 +15,50 @@ func entitygroup_get_first(slf: i64) => i64 #wa:import dora entitygroup_find func entitygroup_find(slf: i64, func0: i32, stack0: i64) => i64 #wa:import dora entitygroup_new -func entitygroup_new(components: i64) => i64 \ No newline at end of file +func entitygroup_new(components: i64) => i64 +type Group struct { Object } +func GroupFrom(raw: i64) => *Group { + if raw == 0 { + return nil + } + object := Group{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Group.GetTypeId() => i32 { + return group_type() +} +func Group.GetCount() => i32 { + return entitygroup_get_count(*this.raw) +} +func Group.GetFirst() => *Entity { + ptr_ := entitygroup_get_first(*this.raw) + if ptr_ == 0 { + return nil + } + obj_ := *EntityFrom(ptr_) + return &obj_ +} +func Group.Find(predicate: func(e: Entity) => bool) => *Entity { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + e := *EntityFrom(stack0.PopObject().GetRaw()) + result_ := predicate(e) + stack0.Push(result_) + }) + ptr_ := entitygroup_find(*this.raw, func_id0, *stack0.raw) + if ptr_ == 0 { + return nil + } + obj_ := *EntityFrom(ptr_) + return &obj_ +} +func NewGroup(components: *[]string) => Group { + raw := entitygroup_new(ToDoraStrBuf(components)) + object := Group{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/http_client.wa b/Tools/dora-wa/vendor/dora/http_client.wa index f8d2c4395..f43c2c3bf 100644 --- a/Tools/dora-wa/vendor/dora/http_client.wa +++ b/Tools/dora-wa/vendor/dora/http_client.wa @@ -13,4 +13,53 @@ func httpclient_post_with_headers_async(url: i64, headers: i64, json: i64, timeo #wa:import dora httpclient_get_async func httpclient_get_async(url: i64, timeout: f32, func0: i32, stack0: i64) #wa:import dora httpclient_download_async -func httpclient_download_async(url: i64, full_path: i64, timeout: f32, func0: i32, stack0: i64) \ No newline at end of file +func httpclient_download_async(url: i64, full_path: i64, timeout: f32, func0: i32, stack0: i64) +type _HttpClient struct { } +global HttpClient = _HttpClient{} +func _HttpClient.PostAsync(url: string, json: string, timeout: f32, callback: func(body: *string)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + body: *string = nil + body_, body_ok := stack0.PopStr() + if body_ok { + body = &body_ + } + callback(body) + }) + httpclient_post_async(ToDoraString(url), ToDoraString(json), timeout, func_id0, *stack0.raw) +} +func _HttpClient.PostWithHeadersAsync(url: string, headers: *[]string, json: string, timeout: f32, callback: func(body: *string)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + body: *string = nil + body_, body_ok := stack0.PopStr() + if body_ok { + body = &body_ + } + callback(body) + }) + httpclient_post_with_headers_async(ToDoraString(url), ToDoraStrBuf(headers), ToDoraString(json), timeout, func_id0, *stack0.raw) +} +func _HttpClient.GetAsync(url: string, timeout: f32, callback: func(body: *string)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + body: *string = nil + body_, body_ok := stack0.PopStr() + if body_ok { + body = &body_ + } + callback(body) + }) + httpclient_get_async(ToDoraString(url), timeout, func_id0, *stack0.raw) +} +func _HttpClient.DownloadAsync(url: string, full_path: string, timeout: f32, progress: func(interrupted: bool, current: i64, total: i64) => bool) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + interrupted, _ := stack0.PopBool() + current, _ := stack0.PopI64() + total, _ := stack0.PopI64() + result_ := progress(interrupted, current, total) + stack0.Push(result_) + }) + httpclient_download_async(ToDoraString(url), ToDoraString(full_path), timeout, func_id0, *stack0.raw) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/im_gui.wa b/Tools/dora-wa/vendor/dora/im_gui.wa index 068f7f520..870463e8f 100644 --- a/Tools/dora-wa/vendor/dora/im_gui.wa +++ b/Tools/dora-wa/vendor/dora/im_gui.wa @@ -417,4 +417,629 @@ func imgui_get_mouse_pos_on_opening_current_popup() => i64 #wa:import dora imgui_get_mouse_drag_delta func imgui_get_mouse_drag_delta(button: i32, lock_threshold: f32) => i64 #wa:import dora imgui_reset_mouse_drag_delta -func imgui_reset_mouse_drag_delta(button: i32) \ No newline at end of file +func imgui_reset_mouse_drag_delta(button: i32) +type _ImGui struct { } +global ImGui = _ImGui{} +func _ImGui.LoadFontTtfAsync(ttf_font_file: string, font_size: f32, glyph_ranges: string, handler: func(success: bool)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + success, _ := stack0.PopBool() + handler(success) + }) + imgui_load_font_ttf_async(ToDoraString(ttf_font_file), font_size, ToDoraString(glyph_ranges), func_id0, *stack0.raw) +} +func _ImGui.IsFontLoaded() => bool { + return imgui_is_font_loaded() != 0 +} +func _ImGui.ShowStats() { + imgui_show_stats() +} +func _ImGui.ShowConsole() { + imgui_show_console() +} +func _ImGui.BeginOpts(name: string, windows_flags: i32) => bool { + return imgui__begin_opts(ToDoraString(name), windows_flags) != 0 +} +func _ImGui.End() { + imgui__end() +} +func _ImGui.BeginChildOpts(str_id: string, size: Vec2, child_flags: i32, window_flags: i32) => bool { + return imgui__begin_child_opts(ToDoraString(str_id), size.ToValue(), child_flags, window_flags) != 0 +} +func _ImGui.BeginChildWithIdOpts(id: i32, size: Vec2, child_flags: i32, window_flags: i32) => bool { + return imgui__begin_child_with_id_opts(id, size.ToValue(), child_flags, window_flags) != 0 +} +func _ImGui.EndChild() { + imgui__end_child() +} +func _ImGui.SetNextWindowPosCenterOpts(set_cond: i32) { + imgui__set_next_window_pos_center_opts(set_cond) +} +func _ImGui.SetNextWindowSizeOpts(size: Vec2, set_cond: i32) { + imgui__set_next_window_size_opts(size.ToValue(), set_cond) +} +func _ImGui.SetNextWindowCollapsedOpts(collapsed: bool, set_cond: i32) { + imgui__set_next_window_collapsed_opts(ToDoraBool(collapsed), set_cond) +} +func _ImGui.SetWindowPosOpts(name: string, pos: Vec2, set_cond: i32) { + imgui__set_window_pos_opts(ToDoraString(name), pos.ToValue(), set_cond) +} +func _ImGui.SetWindowSizeOpts(name: string, size: Vec2, set_cond: i32) { + imgui__set_window_size_opts(ToDoraString(name), size.ToValue(), set_cond) +} +func _ImGui.SetWindowCollapsedOpts(name: string, collapsed: bool, set_cond: i32) { + imgui__set_window_collapsed_opts(ToDoraString(name), ToDoraBool(collapsed), set_cond) +} +func _ImGui.SetColorEditOptions(color_edit_flags: i32) { + imgui__set_color_edit_options(color_edit_flags) +} +func _ImGui.InputTextOpts(label: string, buffer: Buffer, input_text_flags: i32) => bool { + return imgui__input_text_opts(ToDoraString(label), buffer.GetRaw(), input_text_flags) != 0 +} +func _ImGui.InputTextMultilineOpts(label: string, buffer: Buffer, size: Vec2, input_text_flags: i32) => bool { + return imgui__input_text_multiline_opts(ToDoraString(label), buffer.GetRaw(), size.ToValue(), input_text_flags) != 0 +} +func _ImGui.TreeNodeExOpts(label: string, tree_node_flags: i32) => bool { + return imgui__tree_node_ex_opts(ToDoraString(label), tree_node_flags) != 0 +} +func _ImGui.TreeNodeExWithIdOpts(str_id: string, text: string, tree_node_flags: i32) => bool { + return imgui__tree_node_ex_with_id_opts(ToDoraString(str_id), ToDoraString(text), tree_node_flags) != 0 +} +func _ImGui.SetNextItemOpenOpts(is_open: bool, set_cond: i32) { + imgui__set_next_item_open_opts(ToDoraBool(is_open), set_cond) +} +func _ImGui.CollapsingHeaderOpts(label: string, tree_node_flags: i32) => bool { + return imgui__collapsing_header_opts(ToDoraString(label), tree_node_flags) != 0 +} +func _ImGui.SelectableOpts(label: string, selectable_flags: i32) => bool { + return imgui__selectable_opts(ToDoraString(label), selectable_flags) != 0 +} +func _ImGui.BeginPopupModalOpts(name: string, windows_flags: i32) => bool { + return imgui__begin_popup_modal_opts(ToDoraString(name), windows_flags) != 0 +} +func _ImGui.BeginPopupModalRetOpts(name: string, stack: CallStack, windows_flags: i32) => bool { + return imgui__begin_popup_modal_ret_opts(ToDoraString(name), stack.GetRaw(), windows_flags) != 0 +} +func _ImGui.BeginPopupContextItemOpts(name: string, popup_flags: i32) => bool { + return imgui__begin_popup_context_item_opts(ToDoraString(name), popup_flags) != 0 +} +func _ImGui.BeginPopupContextWindowOpts(name: string, popup_flags: i32) => bool { + return imgui__begin_popup_context_window_opts(ToDoraString(name), popup_flags) != 0 +} +func _ImGui.BeginPopupContextVoidOpts(name: string, popup_flags: i32) => bool { + return imgui__begin_popup_context_void_opts(ToDoraString(name), popup_flags) != 0 +} +func _ImGui.PushStyleColor(name: i32, color: Color) { + imgui__push_style_color(name, color.ToARGB()) +} +func _ImGui.PushStyleFloat(name: i32, val: f32) { + imgui__push_style_float(name, val) +} +func _ImGui.PushStyleVec2(name: i32, val: Vec2) { + imgui__push_style_vec2(name, val.ToValue()) +} +func _ImGui.Text(text: string) { + imgui_text(ToDoraString(text)) +} +func _ImGui.TextColored(color: Color, text: string) { + imgui_text_colored(color.ToARGB(), ToDoraString(text)) +} +func _ImGui.TextDisabled(text: string) { + imgui_text_disabled(ToDoraString(text)) +} +func _ImGui.TextWrapped(text: string) { + imgui_text_wrapped(ToDoraString(text)) +} +func _ImGui.LabelText(label: string, text: string) { + imgui_label_text(ToDoraString(label), ToDoraString(text)) +} +func _ImGui.BulletText(text: string) { + imgui_bullet_text(ToDoraString(text)) +} +func _ImGui.TreeNode(str_id: string, text: string) => bool { + return imgui__tree_node(ToDoraString(str_id), ToDoraString(text)) != 0 +} +func _ImGui.SetTooltip(text: string) { + imgui_set_tooltip(ToDoraString(text)) +} +func _ImGui.ImageOpts(clip_str: string, size: Vec2, tint_col: Color, border_col: Color) { + imgui_image_opts(ToDoraString(clip_str), size.ToValue(), tint_col.ToARGB(), border_col.ToARGB()) +} +func _ImGui.ImageButtonOpts(str_id: string, clip_str: string, size: Vec2, bg_col: Color, tint_col: Color) => bool { + return imgui_image_button_opts(ToDoraString(str_id), ToDoraString(clip_str), size.ToValue(), bg_col.ToARGB(), tint_col.ToARGB()) != 0 +} +func _ImGui.ColorButtonOpts(desc_id: string, col: Color, color_edit_flags: i32, size: Vec2) => bool { + return imgui__color_button_opts(ToDoraString(desc_id), col.ToARGB(), color_edit_flags, size.ToValue()) != 0 +} +func _ImGui.Columns(count: i32) { + imgui_columns(count) +} +func _ImGui.ColumnsOpts(count: i32, border: bool, str_id: string) { + imgui_columns_opts(count, ToDoraBool(border), ToDoraString(str_id)) +} +func _ImGui.BeginTableOpts(str_id: string, column: i32, outer_size: Vec2, inner_width: f32, table_flags: i32) => bool { + return imgui__begin_table_opts(ToDoraString(str_id), column, outer_size.ToValue(), inner_width, table_flags) != 0 +} +func _ImGui.TableNextRowOpts(min_row_height: f32, table_row_flag: i32) { + imgui__table_next_row_opts(min_row_height, table_row_flag) +} +func _ImGui.TableSetupColumnOpts(label: string, init_width_or_weight: f32, user_id: i32, table_column_flags: i32) { + imgui__table_setup_column_opts(ToDoraString(label), init_width_or_weight, user_id, table_column_flags) +} +func _ImGui.SetStyleBool(name: string, val: bool) { + imgui_set_style_bool(ToDoraString(name), ToDoraBool(val)) +} +func _ImGui.SetStyleFloat(name: string, val: f32) { + imgui_set_style_float(ToDoraString(name), val) +} +func _ImGui.SetStyleVec2(name: string, val: Vec2) { + imgui_set_style_vec2(ToDoraString(name), val.ToValue()) +} +func _ImGui.SetStyleColor(name: string, color: Color) { + imgui_set_style_color(ToDoraString(name), color.ToARGB()) +} +func _ImGui.BeginRetOpts(name: string, stack: CallStack, windows_flags: i32) => bool { + return imgui__begin_ret_opts(ToDoraString(name), stack.GetRaw(), windows_flags) != 0 +} +func _ImGui.CollapsingHeaderRetOpts(label: string, stack: CallStack, tree_node_flags: i32) => bool { + return imgui__collapsing_header_ret_opts(ToDoraString(label), stack.GetRaw(), tree_node_flags) != 0 +} +func _ImGui.SelectableRetOpts(label: string, stack: CallStack, size: Vec2, selectable_flags: i32) => bool { + return imgui__selectable_ret_opts(ToDoraString(label), stack.GetRaw(), size.ToValue(), selectable_flags) != 0 +} +func _ImGui.ComboRetOpts(label: string, stack: CallStack, items: *[]string, height_in_items: i32) => bool { + return imgui__combo_ret_opts(ToDoraString(label), stack.GetRaw(), ToDoraStrBuf(items), height_in_items) != 0 +} +func _ImGui.DragFloatRetOpts(label: string, stack: CallStack, v_speed: f32, v_min: f32, v_max: f32, display_format: string, slider_flags: i32) => bool { + return imgui__drag_float_ret_opts(ToDoraString(label), stack.GetRaw(), v_speed, v_min, v_max, ToDoraString(display_format), slider_flags) != 0 +} +func _ImGui.DragFloat2RetOpts(label: string, stack: CallStack, v_speed: f32, v_min: f32, v_max: f32, display_format: string, slider_flags: i32) => bool { + return imgui__drag_float2_ret_opts(ToDoraString(label), stack.GetRaw(), v_speed, v_min, v_max, ToDoraString(display_format), slider_flags) != 0 +} +func _ImGui.DragIntRetOpts(label: string, stack: CallStack, v_speed: f32, v_min: i32, v_max: i32, display_format: string, slider_flags: i32) => bool { + return imgui__drag_int_ret_opts(ToDoraString(label), stack.GetRaw(), v_speed, v_min, v_max, ToDoraString(display_format), slider_flags) != 0 +} +func _ImGui.DragInt2RetOpts(label: string, stack: CallStack, v_speed: f32, v_min: i32, v_max: i32, display_format: string, slider_flags: i32) => bool { + return imgui__drag_int2_ret_opts(ToDoraString(label), stack.GetRaw(), v_speed, v_min, v_max, ToDoraString(display_format), slider_flags) != 0 +} +func _ImGui.InputFloatRetOpts(label: string, stack: CallStack, step: f32, step_fast: f32, display_format: string, input_text_flags: i32) => bool { + return imgui__input_float_ret_opts(ToDoraString(label), stack.GetRaw(), step, step_fast, ToDoraString(display_format), input_text_flags) != 0 +} +func _ImGui.InputFloat2RetOpts(label: string, stack: CallStack, display_format: string, input_text_flags: i32) => bool { + return imgui__input_float2_ret_opts(ToDoraString(label), stack.GetRaw(), ToDoraString(display_format), input_text_flags) != 0 +} +func _ImGui.InputIntRetOpts(label: string, stack: CallStack, step: i32, step_fast: i32, input_text_flags: i32) => bool { + return imgui__input_int_ret_opts(ToDoraString(label), stack.GetRaw(), step, step_fast, input_text_flags) != 0 +} +func _ImGui.InputInt2RetOpts(label: string, stack: CallStack, input_text_flags: i32) => bool { + return imgui__input_int2_ret_opts(ToDoraString(label), stack.GetRaw(), input_text_flags) != 0 +} +func _ImGui.SliderFloatRetOpts(label: string, stack: CallStack, v_min: f32, v_max: f32, display_format: string, slider_flags: i32) => bool { + return imgui__slider_float_ret_opts(ToDoraString(label), stack.GetRaw(), v_min, v_max, ToDoraString(display_format), slider_flags) != 0 +} +func _ImGui.SliderFloat2RetOpts(label: string, stack: CallStack, v_min: f32, v_max: f32, display_format: string, slider_flags: i32) => bool { + return imgui__slider_float2_ret_opts(ToDoraString(label), stack.GetRaw(), v_min, v_max, ToDoraString(display_format), slider_flags) != 0 +} +func _ImGui.SliderIntRetOpts(label: string, stack: CallStack, v_min: i32, v_max: i32, format: string, slider_flags: i32) => bool { + return imgui__slider_int_ret_opts(ToDoraString(label), stack.GetRaw(), v_min, v_max, ToDoraString(format), slider_flags) != 0 +} +func _ImGui.SliderInt2RetOpts(label: string, stack: CallStack, v_min: i32, v_max: i32, display_format: string, slider_flags: i32) => bool { + return imgui__slider_int2_ret_opts(ToDoraString(label), stack.GetRaw(), v_min, v_max, ToDoraString(display_format), slider_flags) != 0 +} +func _ImGui.DragFloatRange2RetOpts(label: string, stack: CallStack, v_speed: f32, v_min: f32, v_max: f32, format: string, format_max: string, slider_flags: i32) => bool { + return imgui__drag_float_range2_ret_opts(ToDoraString(label), stack.GetRaw(), v_speed, v_min, v_max, ToDoraString(format), ToDoraString(format_max), slider_flags) != 0 +} +func _ImGui.DragIntRange2RetOpts(label: string, stack: CallStack, v_speed: f32, v_min: i32, v_max: i32, format: string, format_max: string, slider_flags: i32) => bool { + return imgui__drag_int_range2_ret_opts(ToDoraString(label), stack.GetRaw(), v_speed, v_min, v_max, ToDoraString(format), ToDoraString(format_max), slider_flags) != 0 +} +func _ImGui.VSliderFloatRetOpts(label: string, size: Vec2, stack: CallStack, v_min: f32, v_max: f32, format: string, slider_flags: i32) => bool { + return imgui__v_slider_float_ret_opts(ToDoraString(label), size.ToValue(), stack.GetRaw(), v_min, v_max, ToDoraString(format), slider_flags) != 0 +} +func _ImGui.VSliderIntRetOpts(label: string, size: Vec2, stack: CallStack, v_min: i32, v_max: i32, format: string, slider_flags: i32) => bool { + return imgui__v_slider_int_ret_opts(ToDoraString(label), size.ToValue(), stack.GetRaw(), v_min, v_max, ToDoraString(format), slider_flags) != 0 +} +func _ImGui.ColorEdit3RetOpts(label: string, stack: CallStack, color_edit_flags: i32) => bool { + return imgui__color_edit3_ret_opts(ToDoraString(label), stack.GetRaw(), color_edit_flags) != 0 +} +func _ImGui.ColorEdit4RetOpts(label: string, stack: CallStack, color_edit_flags: i32) => bool { + return imgui__color_edit4_ret_opts(ToDoraString(label), stack.GetRaw(), color_edit_flags) != 0 +} +func _ImGui.ScrollWhenDraggingOnVoid() { + imgui_scroll_when_dragging_on_void() +} +func _ImGui.SetNextWindowPosOpts(pos: Vec2, set_cond: i32, pivot: Vec2) { + imgui__set_next_window_pos_opts(pos.ToValue(), set_cond, pivot.ToValue()) +} +func _ImGui.SetNextWindowBgAlpha(alpha: f32) { + imgui_set_next_window_bg_alpha(alpha) +} +func _ImGui.ShowDemoWindow() { + imgui_show_demo_window() +} +func _ImGui.GetContentRegionAvail() => Vec2 { + return Vec2FromValue(imgui_get_content_region_avail()) +} +func _ImGui.GetWindowPos() => Vec2 { + return Vec2FromValue(imgui_get_window_pos()) +} +func _ImGui.GetWindowSize() => Vec2 { + return Vec2FromValue(imgui_get_window_size()) +} +func _ImGui.GetWindowWidth() => f32 { + return imgui_get_window_width() +} +func _ImGui.GetWindowHeight() => f32 { + return imgui_get_window_height() +} +func _ImGui.IsWindowCollapsed() => bool { + return imgui_is_window_collapsed() != 0 +} +func _ImGui.SetWindowFontScale(scale: f32) { + imgui_set_window_font_scale(scale) +} +func _ImGui.SetNextWindowSizeConstraints(size_min: Vec2, size_max: Vec2) { + imgui_set_next_window_size_constraints(size_min.ToValue(), size_max.ToValue()) +} +func _ImGui.SetNextWindowContentSize(size: Vec2) { + imgui_set_next_window_content_size(size.ToValue()) +} +func _ImGui.SetNextWindowFocus() { + imgui_set_next_window_focus() +} +func _ImGui.GetScrollX() => f32 { + return imgui_get_scroll_x() +} +func _ImGui.GetScrollY() => f32 { + return imgui_get_scroll_y() +} +func _ImGui.GetScrollMaxX() => f32 { + return imgui_get_scroll_max_x() +} +func _ImGui.GetScrollMaxY() => f32 { + return imgui_get_scroll_max_y() +} +func _ImGui.SetScrollX(scroll_x: f32) { + imgui_set_scroll_x(scroll_x) +} +func _ImGui.SetScrollY(scroll_y: f32) { + imgui_set_scroll_y(scroll_y) +} +func _ImGui.SetScrollHereY(center_y_ratio: f32) { + imgui_set_scroll_here_y(center_y_ratio) +} +func _ImGui.SetScrollFromPosY(pos_y: f32, center_y_ratio: f32) { + imgui_set_scroll_from_pos_y(pos_y, center_y_ratio) +} +func _ImGui.SetKeyboardFocusHere(offset: i32) { + imgui_set_keyboard_focus_here(offset) +} +func _ImGui.PopStyleColor(count: i32) { + imgui__pop_style_color(count) +} +func _ImGui.PopStyleVar(count: i32) { + imgui__pop_style_var(count) +} +func _ImGui.SetNextItemWidth(item_width: f32) { + imgui_set_next_item_width(item_width) +} +func _ImGui.PushItemWidth(item_width: f32) { + imgui__push_item_width(item_width) +} +func _ImGui.PopItemWidth() { + imgui__pop_item_width() +} +func _ImGui.CalcItemWidth() => f32 { + return imgui_calc_item_width() +} +func _ImGui.PushTextWrapPos(wrap_pos_x: f32) { + imgui__push_text_wrap_pos(wrap_pos_x) +} +func _ImGui.PopTextWrapPos() { + imgui__pop_text_wrap_pos() +} +func _ImGui.PushItemFlag(flag: i32, enabled: bool) { + imgui__push_item_flag(flag, ToDoraBool(enabled)) +} +func _ImGui.PopItemFlag() { + imgui__pop_item_flag() +} +func _ImGui.Separator() { + imgui_separator() +} +func _ImGui.SameLine(pos_x: f32, spacing_w: f32) { + imgui_same_line(pos_x, spacing_w) +} +func _ImGui.NewLine() { + imgui_new_line() +} +func _ImGui.Spacing() { + imgui_spacing() +} +func _ImGui.Dummy(size: Vec2) { + imgui_dummy(size.ToValue()) +} +func _ImGui.Indent(indent_w: f32) { + imgui_indent(indent_w) +} +func _ImGui.Unindent(indent_w: f32) { + imgui_unindent(indent_w) +} +func _ImGui.BeginGroup() { + imgui__begin_group() +} +func _ImGui.EndGroup() { + imgui__end_group() +} +func _ImGui.GetCursorPos() => Vec2 { + return Vec2FromValue(imgui_get_cursor_pos()) +} +func _ImGui.GetCursorPosX() => f32 { + return imgui_get_cursor_pos_x() +} +func _ImGui.GetCursorPosY() => f32 { + return imgui_get_cursor_pos_y() +} +func _ImGui.SetCursorPos(local_pos: Vec2) { + imgui_set_cursor_pos(local_pos.ToValue()) +} +func _ImGui.SetCursorPosX(x: f32) { + imgui_set_cursor_pos_x(x) +} +func _ImGui.SetCursorPosY(y: f32) { + imgui_set_cursor_pos_y(y) +} +func _ImGui.GetCursorStartPos() => Vec2 { + return Vec2FromValue(imgui_get_cursor_start_pos()) +} +func _ImGui.GetCursorScreenPos() => Vec2 { + return Vec2FromValue(imgui_get_cursor_screen_pos()) +} +func _ImGui.SetCursorScreenPos(pos: Vec2) { + imgui_set_cursor_screen_pos(pos.ToValue()) +} +func _ImGui.AlignTextToFramePadding() { + imgui_align_text_to_frame_padding() +} +func _ImGui.GetTextLineHeight() => f32 { + return imgui_get_text_line_height() +} +func _ImGui.GetTextLineHeightWithSpacing() => f32 { + return imgui_get_text_line_height_with_spacing() +} +func _ImGui.NextColumn() { + imgui_next_column() +} +func _ImGui.GetColumnIndex() => i32 { + return imgui_get_column_index() +} +func _ImGui.GetColumnOffset(column_index: i32) => f32 { + return imgui_get_column_offset(column_index) +} +func _ImGui.SetColumnOffset(column_index: i32, offset_x: f32) { + imgui_set_column_offset(column_index, offset_x) +} +func _ImGui.GetColumnWidth(column_index: i32) => f32 { + return imgui_get_column_width(column_index) +} +func _ImGui.GetColumnsCount() => i32 { + return imgui_get_columns_count() +} +func _ImGui.EndTable() { + imgui__end_table() +} +func _ImGui.TableNextColumn() => bool { + return imgui_table_next_column() != 0 +} +func _ImGui.TableSetColumnIndex(column_n: i32) => bool { + return imgui_table_set_column_index(column_n) != 0 +} +func _ImGui.TableSetupScrollFreeze(cols: i32, rows: i32) { + imgui_table_setup_scroll_freeze(cols, rows) +} +func _ImGui.TableHeadersRow() { + imgui_table_headers_row() +} +func _ImGui.BulletItem() { + imgui_bullet_item() +} +func _ImGui.TextLink(label: string) => bool { + return imgui_text_link(ToDoraString(label)) != 0 +} +func _ImGui.TextLinkOpenUrl(label: string, url: string) { + imgui_text_link_open_url(ToDoraString(label), ToDoraString(url)) +} +func _ImGui.SetWindowFocus(name: string) { + imgui_set_window_focus(ToDoraString(name)) +} +func _ImGui.SeparatorText(text: string) { + imgui_separator_text(ToDoraString(text)) +} +func _ImGui.TableHeader(label: string) { + imgui_table_header(ToDoraString(label)) +} +func _ImGui.PushId(str_id: string) { + imgui__push_id(ToDoraString(str_id)) +} +func _ImGui.PopId() { + imgui__pop_id() +} +func _ImGui.GetId(str_id: string) => i32 { + return imgui_get_id(ToDoraString(str_id)) +} +func _ImGui.Button(label: string, size: Vec2) => bool { + return imgui_button(ToDoraString(label), size.ToValue()) != 0 +} +func _ImGui.SmallButton(label: string) => bool { + return imgui_small_button(ToDoraString(label)) != 0 +} +func _ImGui.InvisibleButton(str_id: string, size: Vec2) => bool { + return imgui_invisible_button(ToDoraString(str_id), size.ToValue()) != 0 +} +func _ImGui.CheckboxRet(label: string, stack: CallStack) => bool { + return imgui__checkbox_ret(ToDoraString(label), stack.GetRaw()) != 0 +} +func _ImGui.RadioButtonRet(label: string, stack: CallStack, v_button: i32) => bool { + return imgui__radio_button_ret(ToDoraString(label), stack.GetRaw(), v_button) != 0 +} +func _ImGui.PlotLines(label: string, values: *[]f32) { + imgui_plot_lines(ToDoraString(label), ToDoraF32Buf(values)) +} +func _ImGui.PlotLinesOpts(label: string, values: *[]f32, values_offset: i32, overlay_text: string, scale_min: f32, scale_max: f32, graph_size: Vec2) { + imgui_plot_lines_opts(ToDoraString(label), ToDoraF32Buf(values), values_offset, ToDoraString(overlay_text), scale_min, scale_max, graph_size.ToValue()) +} +func _ImGui.PlotHistogram(label: string, values: *[]f32) { + imgui_plot_histogram(ToDoraString(label), ToDoraF32Buf(values)) +} +func _ImGui.PlotHistogramOpts(label: string, values: *[]f32, values_offset: i32, overlay_text: string, scale_min: f32, scale_max: f32, graph_size: Vec2) { + imgui_plot_histogram_opts(ToDoraString(label), ToDoraF32Buf(values), values_offset, ToDoraString(overlay_text), scale_min, scale_max, graph_size.ToValue()) +} +func _ImGui.ProgressBar(fraction: f32) { + imgui_progress_bar(fraction) +} +func _ImGui.ProgressBarOpts(fraction: f32, size_arg: Vec2, overlay: string) { + imgui_progress_bar_opts(fraction, size_arg.ToValue(), ToDoraString(overlay)) +} +func _ImGui.ListBoxRetOpts(label: string, stack: CallStack, items: *[]string, height_in_items: i32) => bool { + return imgui__list_box_ret_opts(ToDoraString(label), stack.GetRaw(), ToDoraStrBuf(items), height_in_items) != 0 +} +func _ImGui.SliderAngleRet(label: string, stack: CallStack, v_degrees_min: f32, v_degrees_max: f32) => bool { + return imgui__slider_angle_ret(ToDoraString(label), stack.GetRaw(), v_degrees_min, v_degrees_max) != 0 +} +func _ImGui.TreePush(str_id: string) { + imgui__tree_push(ToDoraString(str_id)) +} +func _ImGui.TreePop() { + imgui__tree_pop() +} +func _ImGui.Value(prefix: string, b: bool) { + imgui_value(ToDoraString(prefix), ToDoraBool(b)) +} +func _ImGui.MenuItem(label: string, shortcut: string, selected: bool, enabled: bool) => bool { + return imgui_menu_item(ToDoraString(label), ToDoraString(shortcut), ToDoraBool(selected), ToDoraBool(enabled)) != 0 +} +func _ImGui.OpenPopup(str_id: string) { + imgui_open_popup(ToDoraString(str_id)) +} +func _ImGui.BeginPopup(str_id: string) => bool { + return imgui__begin_popup(ToDoraString(str_id)) != 0 +} +func _ImGui.EndPopup() { + imgui__end_popup() +} +func _ImGui.GetTreeNodeToLabelSpacing() => f32 { + return imgui_get_tree_node_to_label_spacing() +} +func _ImGui.BeginListBox(label: string, size: Vec2) => bool { + return imgui__begin_list_box(ToDoraString(label), size.ToValue()) != 0 +} +func _ImGui.EndListBox() { + imgui__end_list_box() +} +func _ImGui.BeginDisabled() { + imgui__begin_disabled() +} +func _ImGui.EndDisabled() { + imgui__end_disabled() +} +func _ImGui.BeginTooltip() => bool { + return imgui__begin_tooltip() != 0 +} +func _ImGui.EndTooltip() { + imgui__end_tooltip() +} +func _ImGui.BeginMainMenuBar() => bool { + return imgui__begin_main_menu_bar() != 0 +} +func _ImGui.EndMainMenuBar() { + imgui__end_main_menu_bar() +} +func _ImGui.BeginMenuBar() => bool { + return imgui__begin_menu_bar() != 0 +} +func _ImGui.EndMenuBar() { + imgui__end_menu_bar() +} +func _ImGui.BeginMenu(label: string, enabled: bool) => bool { + return imgui__begin_menu(ToDoraString(label), ToDoraBool(enabled)) != 0 +} +func _ImGui.EndMenu() { + imgui__end_menu() +} +func _ImGui.CloseCurrentPopup() { + imgui_close_current_popup() +} +func _ImGui.PushClipRect(clip_rect_min: Vec2, clip_rect_max: Vec2, intersect_with_current_clip_rect: bool) { + imgui__push_clip_rect(clip_rect_min.ToValue(), clip_rect_max.ToValue(), ToDoraBool(intersect_with_current_clip_rect)) +} +func _ImGui.PopClipRect() { + imgui__pop_clip_rect() +} +func _ImGui.IsItemHovered() => bool { + return imgui_is_item_hovered() != 0 +} +func _ImGui.IsItemActive() => bool { + return imgui_is_item_active() != 0 +} +func _ImGui.IsItemClicked(mouse_button: i32) => bool { + return imgui_is_item_clicked(mouse_button) != 0 +} +func _ImGui.IsItemVisible() => bool { + return imgui_is_item_visible() != 0 +} +func _ImGui.IsAnyItemHovered() => bool { + return imgui_is_any_item_hovered() != 0 +} +func _ImGui.IsAnyItemActive() => bool { + return imgui_is_any_item_active() != 0 +} +func _ImGui.GetItemRectMin() => Vec2 { + return Vec2FromValue(imgui_get_item_rect_min()) +} +func _ImGui.GetItemRectMax() => Vec2 { + return Vec2FromValue(imgui_get_item_rect_max()) +} +func _ImGui.GetItemRectSize() => Vec2 { + return Vec2FromValue(imgui_get_item_rect_size()) +} +func _ImGui.SetNextItemAllowOverlap() { + imgui_set_next_item_allow_overlap() +} +func _ImGui.IsWindowHovered() => bool { + return imgui_is_window_hovered() != 0 +} +func _ImGui.IsWindowFocused() => bool { + return imgui_is_window_focused() != 0 +} +func _ImGui.IsRectVisible(size: Vec2) => bool { + return imgui_is_rect_visible(size.ToValue()) != 0 +} +func _ImGui.IsMouseDown(button: i32) => bool { + return imgui_is_mouse_down(button) != 0 +} +func _ImGui.IsMouseClicked(button: i32, repeat: bool) => bool { + return imgui_is_mouse_clicked(button, ToDoraBool(repeat)) != 0 +} +func _ImGui.IsMouseDoubleClicked(button: i32) => bool { + return imgui_is_mouse_double_clicked(button) != 0 +} +func _ImGui.IsMouseReleased(button: i32) => bool { + return imgui_is_mouse_released(button) != 0 +} +func _ImGui.IsMouseHoveringRect(r_min: Vec2, r_max: Vec2, clip: bool) => bool { + return imgui_is_mouse_hovering_rect(r_min.ToValue(), r_max.ToValue(), ToDoraBool(clip)) != 0 +} +func _ImGui.IsMouseDragging(button: i32, lock_threshold: f32) => bool { + return imgui_is_mouse_dragging(button, lock_threshold) != 0 +} +func _ImGui.GetMousePos() => Vec2 { + return Vec2FromValue(imgui_get_mouse_pos()) +} +func _ImGui.GetMousePosOnOpeningCurrentPopup() => Vec2 { + return Vec2FromValue(imgui_get_mouse_pos_on_opening_current_popup()) +} +func _ImGui.GetMouseDragDelta(button: i32, lock_threshold: f32) => Vec2 { + return Vec2FromValue(imgui_get_mouse_drag_delta(button, lock_threshold)) +} +func _ImGui.ResetMouseDragDelta(button: i32) { + imgui_reset_mouse_drag_delta(button) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/joint.wa b/Tools/dora-wa/vendor/dora/joint.wa index 7edc74b15..a2a686edd 100644 --- a/Tools/dora-wa/vendor/dora/joint.wa +++ b/Tools/dora-wa/vendor/dora/joint.wa @@ -35,4 +35,64 @@ func joint_get_world(slf: i64) => i64 #wa:import dora joint_destroy func joint_destroy(slf: i64) #wa:import dora joint_new -func joint_new(def: i64, item_dict: i64) => i64 \ No newline at end of file +func joint_new(def: i64, item_dict: i64) => i64 +type Joint struct { Object } +func JointFrom(raw: i64) => *Joint { + if raw == 0 { + return nil + } + object := Joint{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Joint.GetTypeId() => i32 { + return joint_type() +} +func JointDistance(collision: bool, body_a: Body, body_b: Body, anchor_a: Vec2, anchor_b: Vec2, frequency: f32, damping: f32) => Joint { + return *JointFrom(joint_distance(ToDoraBool(collision), body_a.GetRaw(), body_b.GetRaw(), anchor_a.ToValue(), anchor_b.ToValue(), frequency, damping)) +} +func JointFriction(collision: bool, body_a: Body, body_b: Body, world_pos: Vec2, max_force: f32, max_torque: f32) => Joint { + return *JointFrom(joint_friction(ToDoraBool(collision), body_a.GetRaw(), body_b.GetRaw(), world_pos.ToValue(), max_force, max_torque)) +} +func JointGear(collision: bool, joint_a: Joint, joint_b: Joint, ratio: f32) => Joint { + return *JointFrom(joint_gear(ToDoraBool(collision), joint_a.GetRaw(), joint_b.GetRaw(), ratio)) +} +func JointSpring(collision: bool, body_a: Body, body_b: Body, linear_offset: Vec2, angular_offset: f32, max_force: f32, max_torque: f32, correction_factor: f32) => Joint { + return *JointFrom(joint_spring(ToDoraBool(collision), body_a.GetRaw(), body_b.GetRaw(), linear_offset.ToValue(), angular_offset, max_force, max_torque, correction_factor)) +} +func JointMoveTarget(collision: bool, body: Body, target_pos: Vec2, max_force: f32, frequency: f32, damping: f32) => MoveJoint { + return *MoveJointFrom(joint_move_target(ToDoraBool(collision), body.GetRaw(), target_pos.ToValue(), max_force, frequency, damping)) +} +func JointPrismatic(collision: bool, body_a: Body, body_b: Body, world_pos: Vec2, axis_angle: f32, lower_translation: f32, upper_translation: f32, max_motor_force: f32, motor_speed: f32) => MotorJoint { + return *MotorJointFrom(joint_prismatic(ToDoraBool(collision), body_a.GetRaw(), body_b.GetRaw(), world_pos.ToValue(), axis_angle, lower_translation, upper_translation, max_motor_force, motor_speed)) +} +func JointPulley(collision: bool, body_a: Body, body_b: Body, anchor_a: Vec2, anchor_b: Vec2, ground_anchor_a: Vec2, ground_anchor_b: Vec2, ratio: f32) => Joint { + return *JointFrom(joint_pulley(ToDoraBool(collision), body_a.GetRaw(), body_b.GetRaw(), anchor_a.ToValue(), anchor_b.ToValue(), ground_anchor_a.ToValue(), ground_anchor_b.ToValue(), ratio)) +} +func JointRevolute(collision: bool, body_a: Body, body_b: Body, world_pos: Vec2, lower_angle: f32, upper_angle: f32, max_motor_torque: f32, motor_speed: f32) => MotorJoint { + return *MotorJointFrom(joint_revolute(ToDoraBool(collision), body_a.GetRaw(), body_b.GetRaw(), world_pos.ToValue(), lower_angle, upper_angle, max_motor_torque, motor_speed)) +} +func JointRope(collision: bool, body_a: Body, body_b: Body, anchor_a: Vec2, anchor_b: Vec2, max_length: f32) => Joint { + return *JointFrom(joint_rope(ToDoraBool(collision), body_a.GetRaw(), body_b.GetRaw(), anchor_a.ToValue(), anchor_b.ToValue(), max_length)) +} +func JointWeld(collision: bool, body_a: Body, body_b: Body, world_pos: Vec2, frequency: f32, damping: f32) => Joint { + return *JointFrom(joint_weld(ToDoraBool(collision), body_a.GetRaw(), body_b.GetRaw(), world_pos.ToValue(), frequency, damping)) +} +func JointWheel(collision: bool, body_a: Body, body_b: Body, world_pos: Vec2, axis_angle: f32, max_motor_torque: f32, motor_speed: f32, frequency: f32, damping: f32) => MotorJoint { + return *MotorJointFrom(joint_wheel(ToDoraBool(collision), body_a.GetRaw(), body_b.GetRaw(), world_pos.ToValue(), axis_angle, max_motor_torque, motor_speed, frequency, damping)) +} +func Joint.GetWorld() => PhysicsWorld { + return *PhysicsWorldFrom(joint_get_world(*this.raw)) +} +func Joint.Destroy() { + joint_destroy(*this.raw) +} +func NewJoint(def: JointDef, item_dict: Dictionary) => Joint { + raw := joint_new(def.GetRaw(), item_dict.GetRaw()) + object := Joint{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/joint_def.wa b/Tools/dora-wa/vendor/dora/joint_def.wa index 9e6e0fed8..e6c7b5a60 100644 --- a/Tools/dora-wa/vendor/dora/joint_def.wa +++ b/Tools/dora-wa/vendor/dora/joint_def.wa @@ -39,4 +39,66 @@ func jointdef_rope(collision: i32, body_a: i64, body_b: i64, anchor_a: i64, anch #wa:import dora jointdef_weld func jointdef_weld(collision: i32, body_a: i64, body_b: i64, world_pos: i64, frequency: f32, damping: f32) => i64 #wa:import dora jointdef_wheel -func jointdef_wheel(collision: i32, body_a: i64, body_b: i64, world_pos: i64, axis_angle: f32, max_motor_torque: f32, motor_speed: f32, frequency: f32, damping: f32) => i64 \ No newline at end of file +func jointdef_wheel(collision: i32, body_a: i64, body_b: i64, world_pos: i64, axis_angle: f32, max_motor_torque: f32, motor_speed: f32, frequency: f32, damping: f32) => i64 +type JointDef struct { Object } +func JointDefFrom(raw: i64) => *JointDef { + if raw == 0 { + return nil + } + object := JointDef{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func JointDef.GetTypeId() => i32 { + return jointdef_type() +} +func JointDef.SetCenter(val: Vec2) { + jointdef_set_center(*this.raw, val.ToValue()) +} +func JointDef.GetCenter() => Vec2 { + return Vec2FromValue(jointdef_get_center(*this.raw)) +} +func JointDef.SetPosition(val: Vec2) { + jointdef_set_position(*this.raw, val.ToValue()) +} +func JointDef.GetPosition() => Vec2 { + return Vec2FromValue(jointdef_get_position(*this.raw)) +} +func JointDef.SetAngle(val: f32) { + jointdef_set_angle(*this.raw, val) +} +func JointDef.GetAngle() => f32 { + return jointdef_get_angle(*this.raw) +} +func JointDefDistance(collision: bool, body_a: string, body_b: string, anchor_a: Vec2, anchor_b: Vec2, frequency: f32, damping: f32) => JointDef { + return *JointDefFrom(jointdef_distance(ToDoraBool(collision), ToDoraString(body_a), ToDoraString(body_b), anchor_a.ToValue(), anchor_b.ToValue(), frequency, damping)) +} +func JointDefFriction(collision: bool, body_a: string, body_b: string, world_pos: Vec2, max_force: f32, max_torque: f32) => JointDef { + return *JointDefFrom(jointdef_friction(ToDoraBool(collision), ToDoraString(body_a), ToDoraString(body_b), world_pos.ToValue(), max_force, max_torque)) +} +func JointDefGear(collision: bool, joint_a: string, joint_b: string, ratio: f32) => JointDef { + return *JointDefFrom(jointdef_gear(ToDoraBool(collision), ToDoraString(joint_a), ToDoraString(joint_b), ratio)) +} +func JointDefSpring(collision: bool, body_a: string, body_b: string, linear_offset: Vec2, angular_offset: f32, max_force: f32, max_torque: f32, correction_factor: f32) => JointDef { + return *JointDefFrom(jointdef_spring(ToDoraBool(collision), ToDoraString(body_a), ToDoraString(body_b), linear_offset.ToValue(), angular_offset, max_force, max_torque, correction_factor)) +} +func JointDefPrismatic(collision: bool, body_a: string, body_b: string, world_pos: Vec2, axis_angle: f32, lower_translation: f32, upper_translation: f32, max_motor_force: f32, motor_speed: f32) => JointDef { + return *JointDefFrom(jointdef_prismatic(ToDoraBool(collision), ToDoraString(body_a), ToDoraString(body_b), world_pos.ToValue(), axis_angle, lower_translation, upper_translation, max_motor_force, motor_speed)) +} +func JointDefPulley(collision: bool, body_a: string, body_b: string, anchor_a: Vec2, anchor_b: Vec2, ground_anchor_a: Vec2, ground_anchor_b: Vec2, ratio: f32) => JointDef { + return *JointDefFrom(jointdef_pulley(ToDoraBool(collision), ToDoraString(body_a), ToDoraString(body_b), anchor_a.ToValue(), anchor_b.ToValue(), ground_anchor_a.ToValue(), ground_anchor_b.ToValue(), ratio)) +} +func JointDefRevolute(collision: bool, body_a: string, body_b: string, world_pos: Vec2, lower_angle: f32, upper_angle: f32, max_motor_torque: f32, motor_speed: f32) => JointDef { + return *JointDefFrom(jointdef_revolute(ToDoraBool(collision), ToDoraString(body_a), ToDoraString(body_b), world_pos.ToValue(), lower_angle, upper_angle, max_motor_torque, motor_speed)) +} +func JointDefRope(collision: bool, body_a: string, body_b: string, anchor_a: Vec2, anchor_b: Vec2, max_length: f32) => JointDef { + return *JointDefFrom(jointdef_rope(ToDoraBool(collision), ToDoraString(body_a), ToDoraString(body_b), anchor_a.ToValue(), anchor_b.ToValue(), max_length)) +} +func JointDefWeld(collision: bool, body_a: string, body_b: string, world_pos: Vec2, frequency: f32, damping: f32) => JointDef { + return *JointDefFrom(jointdef_weld(ToDoraBool(collision), ToDoraString(body_a), ToDoraString(body_b), world_pos.ToValue(), frequency, damping)) +} +func JointDefWheel(collision: bool, body_a: string, body_b: string, world_pos: Vec2, axis_angle: f32, max_motor_torque: f32, motor_speed: f32, frequency: f32, damping: f32) => JointDef { + return *JointDefFrom(jointdef_wheel(ToDoraBool(collision), ToDoraString(body_a), ToDoraString(body_b), world_pos.ToValue(), axis_angle, max_motor_torque, motor_speed, frequency, damping)) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/keyboard.wa b/Tools/dora-wa/vendor/dora/keyboard.wa index 9f4a62016..cae85be8b 100644 --- a/Tools/dora-wa/vendor/dora/keyboard.wa +++ b/Tools/dora-wa/vendor/dora/keyboard.wa @@ -13,4 +13,18 @@ func keyboard__is_key_up(name: i64) => i32 #wa:import dora keyboard__is_key_pressed func keyboard__is_key_pressed(name: i64) => i32 #wa:import dora keyboard_update_ime_pos_hint -func keyboard_update_ime_pos_hint(win_pos: i64) \ No newline at end of file +func keyboard_update_ime_pos_hint(win_pos: i64) +type _Keyboard struct { } +global Keyboard = _Keyboard{} +func _Keyboard.IsKeyDown(name: string) => bool { + return keyboard__is_key_down(ToDoraString(name)) != 0 +} +func _Keyboard.IsKeyUp(name: string) => bool { + return keyboard__is_key_up(ToDoraString(name)) != 0 +} +func _Keyboard.IsKeyPressed(name: string) => bool { + return keyboard__is_key_pressed(ToDoraString(name)) != 0 +} +func _Keyboard.UpdateImePosHint(win_pos: Vec2) { + keyboard_update_ime_pos_hint(win_pos.ToValue()) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/label.wa b/Tools/dora-wa/vendor/dora/label.wa index 039c1e439..758b162d5 100644 --- a/Tools/dora-wa/vendor/dora/label.wa +++ b/Tools/dora-wa/vendor/dora/label.wa @@ -69,4 +69,128 @@ func label_get_automatic_width() => f32 #wa:import dora label_new func label_new(font_name: i64, font_size: i32, sdf: i32) => i64 #wa:import dora label_with_str -func label_with_str(font_str: i64) => i64 \ No newline at end of file +func label_with_str(font_str: i64) => i64 +type Label struct { Node } +func LabelFrom(raw: i64) => *Label { + if raw == 0 { + return nil + } + object := Label{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Label.GetTypeId() => i32 { + return label_type() +} +func Label.SetAlignment(val: TextAlign) { + label_set_alignment(*this.raw, val.ToValue()) +} +func Label.GetAlignment() => TextAlign { + return TextAlign{value: label_get_alignment(*this.raw)} +} +func Label.SetAlphaRef(val: f32) { + label_set_alpha_ref(*this.raw, val) +} +func Label.GetAlphaRef() => f32 { + return label_get_alpha_ref(*this.raw) +} +func Label.SetTextWidth(val: f32) { + label_set_text_width(*this.raw, val) +} +func Label.GetTextWidth() => f32 { + return label_get_text_width(*this.raw) +} +func Label.SetSpacing(val: f32) { + label_set_spacing(*this.raw, val) +} +func Label.GetSpacing() => f32 { + return label_get_spacing(*this.raw) +} +func Label.SetLineGap(val: f32) { + label_set_line_gap(*this.raw, val) +} +func Label.GetLineGap() => f32 { + return label_get_line_gap(*this.raw) +} +func Label.SetOutlineColor(val: Color) { + label_set_outline_color(*this.raw, val.ToARGB()) +} +func Label.GetOutlineColor() => Color { + return ColorFromARGB(label_get_outline_color(*this.raw)) +} +func Label.SetOutlineWidth(val: f32) { + label_set_outline_width(*this.raw, val) +} +func Label.GetOutlineWidth() => f32 { + return label_get_outline_width(*this.raw) +} +func Label.SetSmooth(val: Vec2) { + label_set_smooth(*this.raw, val.ToValue()) +} +func Label.GetSmooth() => Vec2 { + return Vec2FromValue(label_get_smooth(*this.raw)) +} +func Label.SetText(val: string) { + label_set_text(*this.raw, ToDoraString(val)) +} +func Label.GetText() => string { + return FromDoraString(label_get_text(*this.raw)) +} +func Label.SetBlendFunc(blend_func: BlendFunc) { + label__set_blend_func(*this.raw, blend_func.ToValue()) +} +func Label.GetBlendFunc() => BlendFunc { + return BlendFuncFrom(label__get_blend_func(*this.raw)) +} +func Label.SetDepthWrite(val: bool) { + label_set_depth_write(*this.raw, ToDoraBool(val)) +} +func Label.IsDepthWrite() => bool { + return label_is_depth_write(*this.raw) != 0 +} +func Label.SetBatched(val: bool) { + label_set_batched(*this.raw, ToDoraBool(val)) +} +func Label.IsBatched() => bool { + return label_is_batched(*this.raw) != 0 +} +func Label.SetEffect(val: SpriteEffect) { + label_set_effect(*this.raw, val.GetRaw()) +} +func Label.GetEffect() => SpriteEffect { + return *SpriteEffectFrom(label_get_effect(*this.raw)) +} +func Label.GetCharacterCount() => i32 { + return label_get_character_count(*this.raw) +} +func Label.GetCharacter(index: i32) => *Sprite { + ptr_ := label_get_character(*this.raw, index) + if ptr_ == 0 { + return nil + } + obj_ := *SpriteFrom(ptr_) + return &obj_ +} +func LabelGetAutomaticWidth() => f32 { + return label_get_automatic_width() +} +func NewLabel(font_name: string, font_size: i32, sdf: bool) => *Label { + raw := label_new(ToDoraString(font_name), font_size, ToDoraBool(sdf)) + if raw == 0 { + return nil + } + object := Label{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} +func LabelWithStr(font_str: string) => *Label { + ptr_ := label_with_str(ToDoraString(font_str)) + if ptr_ == 0 { + return nil + } + obj_ := *LabelFrom(ptr_) + return &obj_ +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/line.wa b/Tools/dora-wa/vendor/dora/line.wa index 0e452abb5..a6a731c47 100644 --- a/Tools/dora-wa/vendor/dora/line.wa +++ b/Tools/dora-wa/vendor/dora/line.wa @@ -25,4 +25,53 @@ func line_clear(slf: i64) #wa:import dora line_new func line_new() => i64 #wa:import dora line_with_vec_color -func line_with_vec_color(verts: i64, color: i32) => i64 \ No newline at end of file +func line_with_vec_color(verts: i64, color: i32) => i64 +type Line struct { Node } +func LineFrom(raw: i64) => *Line { + if raw == 0 { + return nil + } + object := Line{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Line.GetTypeId() => i32 { + return line_type() +} +func Line.SetDepthWrite(val: bool) { + line_set_depth_write(*this.raw, ToDoraBool(val)) +} +func Line.IsDepthWrite() => bool { + return line_is_depth_write(*this.raw) != 0 +} +func Line.SetBlendFunc(blend_func: BlendFunc) { + line__set_blend_func(*this.raw, blend_func.ToValue()) +} +func Line.GetBlendFunc() => BlendFunc { + return BlendFuncFrom(line__get_blend_func(*this.raw)) +} +func Line.Add(verts: *[]Vec2, color: Color) { + line_add(*this.raw, ToDoraVec2Buf(verts), color.ToARGB()) +} +func Line.Set(verts: *[]Vec2, color: Color) { + line_set(*this.raw, ToDoraVec2Buf(verts), color.ToARGB()) +} +func Line.Clear() { + line_clear(*this.raw) +} +func NewLine() => Line { + raw := line_new() + object := Line{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} +func NewLineWithVecColor(verts: *[]Vec2, color: Color) => Line { + raw := line_with_vec_color(ToDoraVec2Buf(verts), color.ToARGB()) + object := Line{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/model.wa b/Tools/dora-wa/vendor/dora/model.wa index 31e404d27..9d3e61cc9 100644 --- a/Tools/dora-wa/vendor/dora/model.wa +++ b/Tools/dora-wa/vendor/dora/model.wa @@ -43,4 +43,85 @@ func model_get_clip_file(filename: i64) => i64 #wa:import dora model_get_looks func model_get_looks(filename: i64) => i64 #wa:import dora model_get_animations -func model_get_animations(filename: i64) => i64 \ No newline at end of file +func model_get_animations(filename: i64) => i64 +type Model struct { Playable } +func ModelFrom(raw: i64) => *Model { + if raw == 0 { + return nil + } + object := Model{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Model.GetTypeId() => i32 { + return model_type() +} +func Model.GetDuration() => f32 { + return model_get_duration(*this.raw) +} +func Model.SetReversed(val: bool) { + model_set_reversed(*this.raw, ToDoraBool(val)) +} +func Model.IsReversed() => bool { + return model_is_reversed(*this.raw) != 0 +} +func Model.IsPlaying() => bool { + return model_is_playing(*this.raw) != 0 +} +func Model.IsPaused() => bool { + return model_is_paused(*this.raw) != 0 +} +func Model.HasAnimation(name: string) => bool { + return model_has_animation(*this.raw, ToDoraString(name)) != 0 +} +func Model.Pause() { + model_pause(*this.raw) +} +func Model.Resume() { + model_resume(*this.raw) +} +func Model.ResumeAnimation(name: string, looping: bool) { + model_resume_animation(*this.raw, ToDoraString(name), ToDoraBool(looping)) +} +func Model.Reset() { + model_reset(*this.raw) +} +func Model.UpdateTo(elapsed: f32, reversed: bool) { + model_update_to(*this.raw, elapsed, ToDoraBool(reversed)) +} +func Model.GetNodeByName(name: string) => Node { + return *NodeFrom(model_get_node_by_name(*this.raw, ToDoraString(name))) +} +func Model.EachNode(visitor_func: func(node: Node) => bool) => bool { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + node := *NodeFrom(stack0.PopObject().GetRaw()) + result_ := visitor_func(node) + stack0.Push(result_) + }) + return model_each_node(*this.raw, func_id0, *stack0.raw) != 0 +} +func NewModel(filename: string) => *Model { + raw := model_new(ToDoraString(filename)) + if raw == 0 { + return nil + } + object := Model{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} +func ModelDummy() => Model { + return *ModelFrom(model_dummy()) +} +func ModelGetClipFile(filename: string) => string { + return FromDoraString(model_get_clip_file(ToDoraString(filename))) +} +func ModelGetLooks(filename: string) => *[]string { + return FromDoraStrBuf(model_get_looks(ToDoraString(filename))) +} +func ModelGetAnimations(filename: string) => *[]string { + return FromDoraStrBuf(model_get_animations(ToDoraString(filename))) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/motor_joint.wa b/Tools/dora-wa/vendor/dora/motor_joint.wa index 18bd8ba8d..b510078e5 100644 --- a/Tools/dora-wa/vendor/dora/motor_joint.wa +++ b/Tools/dora-wa/vendor/dora/motor_joint.wa @@ -19,4 +19,36 @@ func motorjoint_get_force(slf: i64) => f32 #wa:import dora motorjoint_set_speed func motorjoint_set_speed(slf: i64, val: f32); #wa:import dora motorjoint_get_speed -func motorjoint_get_speed(slf: i64) => f32 \ No newline at end of file +func motorjoint_get_speed(slf: i64) => f32 +type MotorJoint struct { Joint } +func MotorJointFrom(raw: i64) => *MotorJoint { + if raw == 0 { + return nil + } + object := MotorJoint{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func MotorJoint.GetTypeId() => i32 { + return motorjoint_type() +} +func MotorJoint.SetEnabled(val: bool) { + motorjoint_set_enabled(*this.raw, ToDoraBool(val)) +} +func MotorJoint.IsEnabled() => bool { + return motorjoint_is_enabled(*this.raw) != 0 +} +func MotorJoint.SetForce(val: f32) { + motorjoint_set_force(*this.raw, val) +} +func MotorJoint.GetForce() => f32 { + return motorjoint_get_force(*this.raw) +} +func MotorJoint.SetSpeed(val: f32) { + motorjoint_set_speed(*this.raw, val) +} +func MotorJoint.GetSpeed() => f32 { + return motorjoint_get_speed(*this.raw) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/mouse.wa b/Tools/dora-wa/vendor/dora/mouse.wa index 8554a1699..04f286356 100644 --- a/Tools/dora-wa/vendor/dora/mouse.wa +++ b/Tools/dora-wa/vendor/dora/mouse.wa @@ -15,4 +15,21 @@ func mouse_is_right_button_pressed() => i32 #wa:import dora mouse_is_middle_button_pressed func mouse_is_middle_button_pressed() => i32 #wa:import dora mouse_get_wheel -func mouse_get_wheel() => i64 \ No newline at end of file +func mouse_get_wheel() => i64 +type _Mouse struct { } +global Mouse = _Mouse{} +func _Mouse.GetPosition() => Vec2 { + return Vec2FromValue(mouse_get_position()) +} +func _Mouse.IsLeftButtonPressed() => bool { + return mouse_is_left_button_pressed() != 0 +} +func _Mouse.IsRightButtonPressed() => bool { + return mouse_is_right_button_pressed() != 0 +} +func _Mouse.IsMiddleButtonPressed() => bool { + return mouse_is_middle_button_pressed() != 0 +} +func _Mouse.GetWheel() => Vec2 { + return Vec2FromValue(mouse_get_wheel()) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/move_joint.wa b/Tools/dora-wa/vendor/dora/move_joint.wa index 627ba6e56..3e3ad5d5f 100644 --- a/Tools/dora-wa/vendor/dora/move_joint.wa +++ b/Tools/dora-wa/vendor/dora/move_joint.wa @@ -11,4 +11,24 @@ func movejoint_type() => i32 #wa:import dora movejoint_set_position func movejoint_set_position(slf: i64, val: i64); #wa:import dora movejoint_get_position -func movejoint_get_position(slf: i64) => i64 \ No newline at end of file +func movejoint_get_position(slf: i64) => i64 +type MoveJoint struct { Joint } +func MoveJointFrom(raw: i64) => *MoveJoint { + if raw == 0 { + return nil + } + object := MoveJoint{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func MoveJoint.GetTypeId() => i32 { + return movejoint_type() +} +func MoveJoint.SetPosition(val: Vec2) { + movejoint_set_position(*this.raw, val.ToValue()) +} +func MoveJoint.GetPosition() => Vec2 { + return Vec2FromValue(movejoint_get_position(*this.raw)) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/node.wa b/Tools/dora-wa/vendor/dora/node.wa index a87e53c75..40ae72ff6 100644 --- a/Tools/dora-wa/vendor/dora/node.wa +++ b/Tools/dora-wa/vendor/dora/node.wa @@ -670,8 +670,8 @@ func Node.OnUpdate(update_func: func(delta_time: f64) => bool) { node_on_update(*this.raw, func_id0, *stack0.raw) } func NewNode() => Node { - object := Node{} raw := node_new() + object := Node{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/nvg.wa b/Tools/dora-wa/vendor/dora/nvg.wa index 0a9457c60..936e88a1f 100644 --- a/Tools/dora-wa/vendor/dora/nvg.wa +++ b/Tools/dora-wa/vendor/dora/nvg.wa @@ -129,4 +129,192 @@ func nvg_font_face(font: i64) #wa:import dora nvg_dora_ssr func nvg_dora_ssr() #wa:import dora nvg_get_dora_ssr -func nvg_get_dora_ssr(scale: f32) => i64 \ No newline at end of file +func nvg_get_dora_ssr(scale: f32) => i64 +type _Nvg struct { } +global Nvg = _Nvg{} +func _Nvg.Save() { + nvg_save() +} +func _Nvg.Restore() { + nvg_restore() +} +func _Nvg.Reset() { + nvg_reset() +} +func _Nvg.CreateImage(w: i32, h: i32, filename: string, image_flags: i32) => i32 { + return nvg__create_image(w, h, ToDoraString(filename), image_flags) +} +func _Nvg.CreateFont(name: string) => i32 { + return nvg_create_font(ToDoraString(name)) +} +func _Nvg.TextBounds(x: f32, y: f32, text: string, bounds: Rect) => f32 { + return nvg_text_bounds(x, y, ToDoraString(text), bounds.GetRaw()) +} +func _Nvg.TextBoxBounds(x: f32, y: f32, break_row_width: f32, text: string) => Rect { + return *RectFrom(nvg_text_box_bounds(x, y, break_row_width, ToDoraString(text))) +} +func _Nvg.Text(x: f32, y: f32, text: string) => f32 { + return nvg_text(x, y, ToDoraString(text)) +} +func _Nvg.TextBox(x: f32, y: f32, break_row_width: f32, text: string) { + nvg_text_box(x, y, break_row_width, ToDoraString(text)) +} +func _Nvg.StrokeColor(color: Color) { + nvg_stroke_color(color.ToARGB()) +} +func _Nvg.StrokePaint(paint: VGPaint) { + nvg_stroke_paint(paint.GetRaw()) +} +func _Nvg.FillColor(color: Color) { + nvg_fill_color(color.ToARGB()) +} +func _Nvg.FillPaint(paint: VGPaint) { + nvg_fill_paint(paint.GetRaw()) +} +func _Nvg.MiterLimit(limit: f32) { + nvg_miter_limit(limit) +} +func _Nvg.StrokeWidth(size: f32) { + nvg_stroke_width(size) +} +func _Nvg.LineCap(cap: i32) { + nvg__line_cap(cap) +} +func _Nvg.LineJoin(join: i32) { + nvg__line_join(join) +} +func _Nvg.GlobalAlpha(alpha: f32) { + nvg_global_alpha(alpha) +} +func _Nvg.ResetTransform() { + nvg_reset_transform() +} +func _Nvg.ApplyTransform(node: Node) { + nvg_apply_transform(node.GetRaw()) +} +func _Nvg.Translate(x: f32, y: f32) { + nvg_translate(x, y) +} +func _Nvg.Rotate(angle: f32) { + nvg_rotate(angle) +} +func _Nvg.SkewX(angle: f32) { + nvg_skew_x(angle) +} +func _Nvg.SkewY(angle: f32) { + nvg_skew_y(angle) +} +func _Nvg.Scale(x: f32, y: f32) { + nvg_scale(x, y) +} +func _Nvg.ImageSize(image: i32) => Size { + return SizeFromValue(nvg_image_size(image)) +} +func _Nvg.DeleteImage(image: i32) { + nvg_delete_image(image) +} +func _Nvg.LinearGradient(sx: f32, sy: f32, ex: f32, ey: f32, icol: Color, ocol: Color) => VGPaint { + return *VGPaintFrom(nvg_linear_gradient(sx, sy, ex, ey, icol.ToARGB(), ocol.ToARGB())) +} +func _Nvg.BoxGradient(x: f32, y: f32, w: f32, h: f32, r: f32, f: f32, icol: Color, ocol: Color) => VGPaint { + return *VGPaintFrom(nvg_box_gradient(x, y, w, h, r, f, icol.ToARGB(), ocol.ToARGB())) +} +func _Nvg.RadialGradient(cx: f32, cy: f32, inr: f32, outr: f32, icol: Color, ocol: Color) => VGPaint { + return *VGPaintFrom(nvg_radial_gradient(cx, cy, inr, outr, icol.ToARGB(), ocol.ToARGB())) +} +func _Nvg.ImagePattern(ox: f32, oy: f32, ex: f32, ey: f32, angle: f32, image: i32, alpha: f32) => VGPaint { + return *VGPaintFrom(nvg_image_pattern(ox, oy, ex, ey, angle, image, alpha)) +} +func _Nvg.Scissor(x: f32, y: f32, w: f32, h: f32) { + nvg_scissor(x, y, w, h) +} +func _Nvg.IntersectScissor(x: f32, y: f32, w: f32, h: f32) { + nvg_intersect_scissor(x, y, w, h) +} +func _Nvg.ResetScissor() { + nvg_reset_scissor() +} +func _Nvg.BeginPath() { + nvg_begin_path() +} +func _Nvg.MoveTo(x: f32, y: f32) { + nvg_move_to(x, y) +} +func _Nvg.LineTo(x: f32, y: f32) { + nvg_line_to(x, y) +} +func _Nvg.BezierTo(c_1x: f32, c_1y: f32, c_2x: f32, c_2y: f32, x: f32, y: f32) { + nvg_bezier_to(c_1x, c_1y, c_2x, c_2y, x, y) +} +func _Nvg.QuadTo(cx: f32, cy: f32, x: f32, y: f32) { + nvg_quad_to(cx, cy, x, y) +} +func _Nvg.ArcTo(x_1: f32, y_1: f32, x_2: f32, y_2: f32, radius: f32) { + nvg_arc_to(x_1, y_1, x_2, y_2, radius) +} +func _Nvg.ClosePath() { + nvg_close_path() +} +func _Nvg.PathWinding(dir: i32) { + nvg__path_winding(dir) +} +func _Nvg.Arc(cx: f32, cy: f32, r: f32, a_0: f32, a_1: f32, dir: i32) { + nvg__arc(cx, cy, r, a_0, a_1, dir) +} +func _Nvg.Rect(x: f32, y: f32, w: f32, h: f32) { + nvg_rect(x, y, w, h) +} +func _Nvg.RoundedRect(x: f32, y: f32, w: f32, h: f32, r: f32) { + nvg_rounded_rect(x, y, w, h, r) +} +func _Nvg.RoundedRectVarying(x: f32, y: f32, w: f32, h: f32, rad_top_left: f32, rad_top_right: f32, rad_bottom_right: f32, rad_bottom_left: f32) { + nvg_rounded_rect_varying(x, y, w, h, rad_top_left, rad_top_right, rad_bottom_right, rad_bottom_left) +} +func _Nvg.Ellipse(cx: f32, cy: f32, rx: f32, ry: f32) { + nvg_ellipse(cx, cy, rx, ry) +} +func _Nvg.Circle(cx: f32, cy: f32, r: f32) { + nvg_circle(cx, cy, r) +} +func _Nvg.Fill() { + nvg_fill() +} +func _Nvg.Stroke() { + nvg_stroke() +} +func _Nvg.FindFont(name: string) => i32 { + return nvg_find_font(ToDoraString(name)) +} +func _Nvg.AddFallbackFontId(base_font: i32, fallback_font: i32) => i32 { + return nvg_add_fallback_font_id(base_font, fallback_font) +} +func _Nvg.AddFallbackFont(base_font: string, fallback_font: string) => i32 { + return nvg_add_fallback_font(ToDoraString(base_font), ToDoraString(fallback_font)) +} +func _Nvg.FontSize(size: f32) { + nvg_font_size(size) +} +func _Nvg.FontBlur(blur: f32) { + nvg_font_blur(blur) +} +func _Nvg.TextLetterSpacing(spacing: f32) { + nvg_text_letter_spacing(spacing) +} +func _Nvg.TextLineHeight(line_height: f32) { + nvg_text_line_height(line_height) +} +func _Nvg.TextAlign(h_align: i32, v_align: i32) { + nvg__text_align(h_align, v_align) +} +func _Nvg.FontFaceId(font: i32) { + nvg_font_face_id(font) +} +func _Nvg.FontFace(font: string) { + nvg_font_face(ToDoraString(font)) +} +func _Nvg.DoraSsr() { + nvg_dora_ssr() +} +func _Nvg.GetDoraSsr(scale: f32) => Texture2D { + return *Texture2DFrom(nvg_get_dora_ssr(scale)) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/observer.wa b/Tools/dora-wa/vendor/dora/observer.wa index cb48b0f8a..7b1c5f1b1 100644 --- a/Tools/dora-wa/vendor/dora/observer.wa +++ b/Tools/dora-wa/vendor/dora/observer.wa @@ -9,4 +9,25 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #wa:import dora observer_type func observer_type() => i32 #wa:import dora entityobserver_new -func entityobserver_new(event: i32, components: i64) => i64 \ No newline at end of file +func entityobserver_new(event: i32, components: i64) => i64 +type Observer struct { Object } +func ObserverFrom(raw: i64) => *Observer { + if raw == 0 { + return nil + } + object := Observer{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Observer.GetTypeId() => i32 { + return observer_type() +} +func NewObserver(event: EntityEvent, components: *[]string) => Observer { + raw := entityobserver_new(event.ToValue(), ToDoraStrBuf(components)) + object := Observer{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/particle.wa b/Tools/dora-wa/vendor/dora/particle.wa index 20151b4d7..2eb8550a6 100644 --- a/Tools/dora-wa/vendor/dora/particle.wa +++ b/Tools/dora-wa/vendor/dora/particle.wa @@ -15,4 +15,37 @@ func particlenode_start(slf: i64) #wa:import dora particlenode_stop func particlenode_stop(slf: i64) #wa:import dora particlenode_new -func particlenode_new(filename: i64) => i64 \ No newline at end of file +func particlenode_new(filename: i64) => i64 +type Particle struct { Node } +func ParticleFrom(raw: i64) => *Particle { + if raw == 0 { + return nil + } + object := Particle{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Particle.GetTypeId() => i32 { + return particle_type() +} +func Particle.IsActive() => bool { + return particlenode_is_active(*this.raw) != 0 +} +func Particle.Start() { + particlenode_start(*this.raw) +} +func Particle.Stop() { + particlenode_stop(*this.raw) +} +func NewParticle(filename: string) => *Particle { + raw := particlenode_new(ToDoraString(filename)) + if raw == 0 { + return nil + } + object := Particle{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/pass.wa b/Tools/dora-wa/vendor/dora/pass.wa index 5ce20df57..c68d870e9 100644 --- a/Tools/dora-wa/vendor/dora/pass.wa +++ b/Tools/dora-wa/vendor/dora/pass.wa @@ -50,8 +50,8 @@ func Pass.SetColor(name: string, val: Color) { pass_set_color(*this.raw, ToDoraString(name), val.ToARGB()) } func NewPass(vert_shader: string, frag_shader: string) => Pass { - object := Pass{} raw := pass_new(ToDoraString(vert_shader), ToDoraString(frag_shader)) + object := Pass{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/physics_world.wa b/Tools/dora-wa/vendor/dora/physics_world.wa index e28e06f1a..c233a52b1 100644 --- a/Tools/dora-wa/vendor/dora/physics_world.wa +++ b/Tools/dora-wa/vendor/dora/physics_world.wa @@ -74,8 +74,8 @@ func PhysicsWorldGetScaleFactor() => f32 { return physicsworld_get_scale_factor() } func NewPhysicsWorld() => PhysicsWorld { - object := PhysicsWorld{} raw := physicsworld_new() + object := PhysicsWorld{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/platformer/behavior/tree.wa b/Tools/dora-wa/vendor/dora/platformer/behavior/tree.wa deleted file mode 100644 index f4fc71121..000000000 --- a/Tools/dora-wa/vendor/dora/platformer/behavior/tree.wa +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2024 Li Jin, dragon-fly@qq.com - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#wa:import dora platformer_behavior_tree_type -func platformer_behavior_tree_type() => i32 -#wa:import dora platformer_behavior_leaf_seq -func platformer_behavior_leaf_seq(nodes: i64) => i64 -#wa:import dora platformer_behavior_leaf_sel -func platformer_behavior_leaf_sel(nodes: i64) => i64 -#wa:import dora platformer_behavior_leaf_con -func platformer_behavior_leaf_con(name: i64, func0: i32, stack0: i64) => i64 -#wa:import dora platformer_behavior_leaf_act -func platformer_behavior_leaf_act(action_name: i64) => i64 -#wa:import dora platformer_behavior_leaf_command -func platformer_behavior_leaf_command(action_name: i64) => i64 -#wa:import dora platformer_behavior_leaf_wait -func platformer_behavior_leaf_wait(duration: f64) => i64 -#wa:import dora platformer_behavior_leaf_countdown -func platformer_behavior_leaf_countdown(time: f64, node: i64) => i64 -#wa:import dora platformer_behavior_leaf_timeout -func platformer_behavior_leaf_timeout(time: f64, node: i64) => i64 -#wa:import dora platformer_behavior_leaf_repeat -func platformer_behavior_leaf_repeat(times: i32, node: i64) => i64 -#wa:import dora platformer_behavior_leaf_repeat_forever -func platformer_behavior_leaf_repeat_forever(node: i64) => i64 -#wa:import dora platformer_behavior_leaf_retry -func platformer_behavior_leaf_retry(times: i32, node: i64) => i64 -#wa:import dora platformer_behavior_leaf_retry_until_pass -func platformer_behavior_leaf_retry_until_pass(node: i64) => i64 \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/decision/tree.wa b/Tools/dora-wa/vendor/dora/platformer/decision/tree.wa deleted file mode 100644 index 837f31636..000000000 --- a/Tools/dora-wa/vendor/dora/platformer/decision/tree.wa +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (c) 2024 Li Jin, dragon-fly@qq.com - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#wa:import dora platformer_decision_tree_type -func platformer_decision_tree_type() => i32 -#wa:import dora platformer_decision_leaf_sel -func platformer_decision_leaf_sel(nodes: i64) => i64 -#wa:import dora platformer_decision_leaf_seq -func platformer_decision_leaf_seq(nodes: i64) => i64 -#wa:import dora platformer_decision_leaf_con -func platformer_decision_leaf_con(name: i64, func0: i32, stack0: i64) => i64 -#wa:import dora platformer_decision_leaf_act -func platformer_decision_leaf_act(action_name: i64) => i64 -#wa:import dora platformer_decision_leaf_act_dynamic -func platformer_decision_leaf_act_dynamic(func0: i32, stack0: i64) => i64 -#wa:import dora platformer_decision_leaf_accept -func platformer_decision_leaf_accept() => i64 -#wa:import dora platformer_decision_leaf_reject -func platformer_decision_leaf_reject() => i64 -#wa:import dora platformer_decision_leaf_behave -func platformer_decision_leaf_behave(name: i64, root: i64) => i64 \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/unit.wa b/Tools/dora-wa/vendor/dora/platformer/unit.wa deleted file mode 100644 index 85bde956f..000000000 --- a/Tools/dora-wa/vendor/dora/platformer/unit.wa +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (c) 2024 Li Jin, dragon-fly@qq.com - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#wa:import dora platformer_unit_type -func platformer_unit_type() => i32 -#wa:import dora platformer_unit_set_playable -func platformer_unit_set_playable(slf: i64, val: i64); -#wa:import dora platformer_unit_get_playable -func platformer_unit_get_playable(slf: i64) => i64 -#wa:import dora platformer_unit_set_detect_distance -func platformer_unit_set_detect_distance(slf: i64, val: f32); -#wa:import dora platformer_unit_get_detect_distance -func platformer_unit_get_detect_distance(slf: i64) => f32 -#wa:import dora platformer_unit_set_attack_range -func platformer_unit_set_attack_range(slf: i64, val: i64); -#wa:import dora platformer_unit_get_attack_range -func platformer_unit_get_attack_range(slf: i64) => i64 -#wa:import dora platformer_unit_set_face_right -func platformer_unit_set_face_right(slf: i64, val: i32); -#wa:import dora platformer_unit_is_face_right -func platformer_unit_is_face_right(slf: i64) => i32 -#wa:import dora platformer_unit_set_receiving_decision_trace -func platformer_unit_set_receiving_decision_trace(slf: i64, val: i32); -#wa:import dora platformer_unit_is_receiving_decision_trace -func platformer_unit_is_receiving_decision_trace(slf: i64) => i32 -#wa:import dora platformer_unit_set_decision_tree -func platformer_unit_set_decision_tree(slf: i64, val: i64); -#wa:import dora platformer_unit_get_decision_tree -func platformer_unit_get_decision_tree(slf: i64) => i64 -#wa:import dora platformer_unit_is_on_surface -func platformer_unit_is_on_surface(slf: i64) => i32 -#wa:import dora platformer_unit_get_ground_sensor -func platformer_unit_get_ground_sensor(slf: i64) => i64 -#wa:import dora platformer_unit_get_detect_sensor -func platformer_unit_get_detect_sensor(slf: i64) => i64 -#wa:import dora platformer_unit_get_attack_sensor -func platformer_unit_get_attack_sensor(slf: i64) => i64 -#wa:import dora platformer_unit_get_unit_def -func platformer_unit_get_unit_def(slf: i64) => i64 -#wa:import dora platformer_unit_get_current_action -func platformer_unit_get_current_action(slf: i64) => i64 -#wa:import dora platformer_unit_get_width -func platformer_unit_get_width(slf: i64) => f32 -#wa:import dora platformer_unit_get_height -func platformer_unit_get_height(slf: i64) => f32 -#wa:import dora platformer_unit_get_entity -func platformer_unit_get_entity(slf: i64) => i64 -#wa:import dora platformer_unit_attach_action -func platformer_unit_attach_action(slf: i64, name: i64) => i64 -#wa:import dora platformer_unit_remove_action -func platformer_unit_remove_action(slf: i64, name: i64) -#wa:import dora platformer_unit_remove_all_actions -func platformer_unit_remove_all_actions(slf: i64) -#wa:import dora platformer_unit_get_action -func platformer_unit_get_action(slf: i64, name: i64) => i64 -#wa:import dora platformer_unit_each_action -func platformer_unit_each_action(slf: i64, func0: i32, stack0: i64) -#wa:import dora platformer_unit_start -func platformer_unit_start(slf: i64, name: i64) => i32 -#wa:import dora platformer_unit_stop -func platformer_unit_stop(slf: i64) -#wa:import dora platformer_unit_is_doing -func platformer_unit_is_doing(slf: i64, name: i64) => i32 -#wa:import dora platformer_unit_new -func platformer_unit_new(unit_def: i64, physics_world: i64, entity: i64, pos: i64, rot: f32) => i64 -#wa:import dora platformer_unit_with_store -func platformer_unit_with_store(unit_def_name: i64, physics_world_name: i64, entity: i64, pos: i64, rot: f32) => i64 \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/unit_action.wa b/Tools/dora-wa/vendor/dora/platformer/unit_action.wa deleted file mode 100644 index 120ae0b61..000000000 --- a/Tools/dora-wa/vendor/dora/platformer/unit_action.wa +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2024 Li Jin, dragon-fly@qq.com - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#wa:import dora platformer_unitaction_set_reaction -func platformer_unitaction_set_reaction(slf: i64, val: f32); -#wa:import dora platformer_unitaction_get_reaction -func platformer_unitaction_get_reaction(slf: i64) => f32 -#wa:import dora platformer_unitaction_set_recovery -func platformer_unitaction_set_recovery(slf: i64, val: f32); -#wa:import dora platformer_unitaction_get_recovery -func platformer_unitaction_get_recovery(slf: i64) => f32 -#wa:import dora platformer_unitaction_get_name -func platformer_unitaction_get_name(slf: i64) => i64 -#wa:import dora platformer_unitaction_is_doing -func platformer_unitaction_is_doing(slf: i64) => i32 -#wa:import dora platformer_unitaction_get_owner -func platformer_unitaction_get_owner(slf: i64) => i64 -#wa:import dora platformer_unitaction_get_elapsed_time -func platformer_unitaction_get_elapsed_time(slf: i64) => f32 -#wa:import dora platformer_unitaction_clear -func platformer_unitaction_clear() -#wa:import dora platformer_unitaction_add -func platformer_unitaction_add(name: i64, priority: i32, reaction: f32, recovery: f32, queued: i32, func0: i32, stack0: i64, func1: i32, stack1: i64, func2: i32, stack2: i64) \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/action_update.wa b/Tools/dora-wa/vendor/dora/platformer_action_update.wa similarity index 55% rename from Tools/dora-wa/vendor/dora/platformer/action_update.wa rename to Tools/dora-wa/vendor/dora/platformer_action_update.wa index 51f68ab7a..ac4392489 100644 --- a/Tools/dora-wa/vendor/dora/platformer/action_update.wa +++ b/Tools/dora-wa/vendor/dora/platformer_action_update.wa @@ -9,4 +9,34 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #wa:import dora platformer_actionupdate_type func platformer_actionupdate_type() => i32 #wa:import dora platformer_wasmactionupdate_new -func platformer_wasmactionupdate_new(func0: i32, stack0: i64) => i64 \ No newline at end of file +func platformer_wasmactionupdate_new(func0: i32, stack0: i64) => i64 +type PlatformerActionUpdate struct { Object } +func PlatformerActionUpdateFrom(raw: i64) => *PlatformerActionUpdate { + if raw == 0 { + return nil + } + object := PlatformerActionUpdate{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func PlatformerActionUpdate.GetTypeId() => i32 { + return platformer_actionupdate_type() +} +func NewPlatformerActionUpdate(update: func(owner: PlatformerUnit, action: PlatformerUnitAction, delta_time: f32) => bool) => PlatformerActionUpdate { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + owner := *PlatformerUnitFrom(stack0.PopObject().GetRaw()) + action_raw, _ := stack0.PopI64() + action := *PlatformerUnitActionFrom(action_raw) + deltaTime, _ := stack0.PopF32() + result_ := update(owner, action, deltaTime) + stack0.Push(result_) + }) + raw := platformer_wasmactionupdate_new(func_id0, *stack0.raw) + object := PlatformerActionUpdate{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/behavior/blackboard.wa b/Tools/dora-wa/vendor/dora/platformer_behavior_blackboard.wa similarity index 65% rename from Tools/dora-wa/vendor/dora/platformer/behavior/blackboard.wa rename to Tools/dora-wa/vendor/dora/platformer_behavior_blackboard.wa index 737f876e6..b100a20a9 100644 --- a/Tools/dora-wa/vendor/dora/platformer/behavior/blackboard.wa +++ b/Tools/dora-wa/vendor/dora/platformer_behavior_blackboard.wa @@ -9,4 +9,23 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #wa:import dora platformer_behavior_blackboard_get_delta_time func platformer_behavior_blackboard_get_delta_time(slf: i64) => f64 #wa:import dora platformer_behavior_blackboard_get_owner -func platformer_behavior_blackboard_get_owner(slf: i64) => i64 \ No newline at end of file +func platformer_behavior_blackboard_get_owner(slf: i64) => i64 +type PlatformerBehaviorBlackboard struct { raw: *i64 } +func PlatformerBehaviorBlackboard.GetRaw() => i64 { + return *this.raw +} +func PlatformerBehaviorBlackboardFrom(raw: i64) => *PlatformerBehaviorBlackboard { + if raw == 0 { + return nil + } + item := PlatformerBehaviorBlackboard{} + item.raw = &raw + result := &item + return result +} +func PlatformerBehaviorBlackboard.GetDeltaTime() => f64 { + return platformer_behavior_blackboard_get_delta_time(*this.raw) +} +func PlatformerBehaviorBlackboard.GetOwner() => PlatformerUnit { + return *PlatformerUnitFrom(platformer_behavior_blackboard_get_owner(*this.raw)) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer_behavior_tree.wa b/Tools/dora-wa/vendor/dora/platformer_behavior_tree.wa new file mode 100644 index 000000000..95f385378 --- /dev/null +++ b/Tools/dora-wa/vendor/dora/platformer_behavior_tree.wa @@ -0,0 +1,91 @@ +/* Copyright (c) 2024 Li Jin, dragon-fly@qq.com + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#wa:import dora platformer_behavior_tree_type +func platformer_behavior_tree_type() => i32 +#wa:import dora platformer_behavior_leaf_seq +func platformer_behavior_leaf_seq(nodes: i64) => i64 +#wa:import dora platformer_behavior_leaf_sel +func platformer_behavior_leaf_sel(nodes: i64) => i64 +#wa:import dora platformer_behavior_leaf_con +func platformer_behavior_leaf_con(name: i64, func0: i32, stack0: i64) => i64 +#wa:import dora platformer_behavior_leaf_act +func platformer_behavior_leaf_act(action_name: i64) => i64 +#wa:import dora platformer_behavior_leaf_command +func platformer_behavior_leaf_command(action_name: i64) => i64 +#wa:import dora platformer_behavior_leaf_wait +func platformer_behavior_leaf_wait(duration: f64) => i64 +#wa:import dora platformer_behavior_leaf_countdown +func platformer_behavior_leaf_countdown(time: f64, node: i64) => i64 +#wa:import dora platformer_behavior_leaf_timeout +func platformer_behavior_leaf_timeout(time: f64, node: i64) => i64 +#wa:import dora platformer_behavior_leaf_repeat +func platformer_behavior_leaf_repeat(times: i32, node: i64) => i64 +#wa:import dora platformer_behavior_leaf_repeat_forever +func platformer_behavior_leaf_repeat_forever(node: i64) => i64 +#wa:import dora platformer_behavior_leaf_retry +func platformer_behavior_leaf_retry(times: i32, node: i64) => i64 +#wa:import dora platformer_behavior_leaf_retry_until_pass +func platformer_behavior_leaf_retry_until_pass(node: i64) => i64 +type PlatformerBehaviorTree struct { Object } +func PlatformerBehaviorTreeFrom(raw: i64) => *PlatformerBehaviorTree { + if raw == 0 { + return nil + } + object := PlatformerBehaviorTree{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func PlatformerBehaviorTree.GetTypeId() => i32 { + return platformer_behavior_tree_type() +} +func PlatformerBehaviorTreeSeq(nodes: *[]PlatformerBehaviorTree) => PlatformerBehaviorTree { + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_seq(ToDoraPlatformerBehaviorTreeBuf(nodes))) +} +func PlatformerBehaviorTreeSel(nodes: *[]PlatformerBehaviorTree) => PlatformerBehaviorTree { + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_sel(ToDoraPlatformerBehaviorTreeBuf(nodes))) +} +func PlatformerBehaviorTreeCon(name: string, handler: func(blackboard: PlatformerBehaviorBlackboard) => bool) => PlatformerBehaviorTree { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + blackboard_raw, _ := stack0.PopI64() + blackboard := *PlatformerBehaviorBlackboardFrom(blackboard_raw) + result_ := handler(blackboard) + stack0.Push(result_) + }) + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_con(ToDoraString(name), func_id0, *stack0.raw)) +} +func PlatformerBehaviorTreeAct(action_name: string) => PlatformerBehaviorTree { + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_act(ToDoraString(action_name))) +} +func PlatformerBehaviorTreeCommand(action_name: string) => PlatformerBehaviorTree { + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_command(ToDoraString(action_name))) +} +func PlatformerBehaviorTreeWait(duration: f64) => PlatformerBehaviorTree { + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_wait(duration)) +} +func PlatformerBehaviorTreeCountdown(time: f64, node: PlatformerBehaviorTree) => PlatformerBehaviorTree { + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_countdown(time, node.GetRaw())) +} +func PlatformerBehaviorTreeTimeout(time: f64, node: PlatformerBehaviorTree) => PlatformerBehaviorTree { + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_timeout(time, node.GetRaw())) +} +func PlatformerBehaviorTreeRepeat(times: i32, node: PlatformerBehaviorTree) => PlatformerBehaviorTree { + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_repeat(times, node.GetRaw())) +} +func PlatformerBehaviorTreeRepeatForever(node: PlatformerBehaviorTree) => PlatformerBehaviorTree { + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_repeat_forever(node.GetRaw())) +} +func PlatformerBehaviorTreeRetry(times: i32, node: PlatformerBehaviorTree) => PlatformerBehaviorTree { + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_retry(times, node.GetRaw())) +} +func PlatformerBehaviorTreeRetryUntilPass(node: PlatformerBehaviorTree) => PlatformerBehaviorTree { + return *PlatformerBehaviorTreeFrom(platformer_behavior_leaf_retry_until_pass(node.GetRaw())) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/bullet.wa b/Tools/dora-wa/vendor/dora/platformer_bullet.wa similarity index 56% rename from Tools/dora-wa/vendor/dora/platformer/bullet.wa rename to Tools/dora-wa/vendor/dora/platformer_bullet.wa index 8f78d4990..168ff9dc6 100644 --- a/Tools/dora-wa/vendor/dora/platformer/bullet.wa +++ b/Tools/dora-wa/vendor/dora/platformer_bullet.wa @@ -29,4 +29,55 @@ func platformer_bullet_get_face(slf: i64) => i64 #wa:import dora platformer_bullet_destroy func platformer_bullet_destroy(slf: i64) #wa:import dora platformer_bullet_new -func platformer_bullet_new(def: i64, owner: i64) => i64 \ No newline at end of file +func platformer_bullet_new(def: i64, owner: i64) => i64 +type PlatformerBullet struct { Body } +func PlatformerBulletFrom(raw: i64) => *PlatformerBullet { + if raw == 0 { + return nil + } + object := PlatformerBullet{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func PlatformerBullet.GetTypeId() => i32 { + return platformer_bullet_type() +} +func PlatformerBullet.SetTargetAllow(val: i32) { + platformer_bullet_set_target_allow(*this.raw, val) +} +func PlatformerBullet.GetTargetAllow() => i32 { + return platformer_bullet_get_target_allow(*this.raw) +} +func PlatformerBullet.IsFaceRight() => bool { + return platformer_bullet_is_face_right(*this.raw) != 0 +} +func PlatformerBullet.SetHitStop(val: bool) { + platformer_bullet_set_hit_stop(*this.raw, ToDoraBool(val)) +} +func PlatformerBullet.IsHitStop() => bool { + return platformer_bullet_is_hit_stop(*this.raw) != 0 +} +func PlatformerBullet.GetEmitter() => PlatformerUnit { + return *PlatformerUnitFrom(platformer_bullet_get_emitter(*this.raw)) +} +func PlatformerBullet.GetBulletDef() => PlatformerBulletDef { + return *PlatformerBulletDefFrom(platformer_bullet_get_bullet_def(*this.raw)) +} +func PlatformerBullet.SetFace(val: Node) { + platformer_bullet_set_face(*this.raw, val.GetRaw()) +} +func PlatformerBullet.GetFace() => Node { + return *NodeFrom(platformer_bullet_get_face(*this.raw)) +} +func PlatformerBullet.Destroy() { + platformer_bullet_destroy(*this.raw) +} +func NewPlatformerBullet(def: PlatformerBulletDef, owner: PlatformerUnit) => PlatformerBullet { + raw := platformer_bullet_new(def.GetRaw(), owner.GetRaw()) + object := PlatformerBullet{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/bullet_def.wa b/Tools/dora-wa/vendor/dora/platformer_bullet_def.wa similarity index 54% rename from Tools/dora-wa/vendor/dora/platformer/bullet_def.wa rename to Tools/dora-wa/vendor/dora/platformer_bullet_def.wa index f847bd083..a20de3e43 100644 --- a/Tools/dora-wa/vendor/dora/platformer/bullet_def.wa +++ b/Tools/dora-wa/vendor/dora/platformer_bullet_def.wa @@ -45,4 +45,79 @@ func platformer_bulletdef_set_as_circle(slf: i64, radius: f32) #wa:import dora platformer_bulletdef_set_velocity func platformer_bulletdef_set_velocity(slf: i64, angle: f32, speed: f32) #wa:import dora platformer_bulletdef_new -func platformer_bulletdef_new() => i64 \ No newline at end of file +func platformer_bulletdef_new() => i64 +type PlatformerBulletDef struct { Object } +func PlatformerBulletDefFrom(raw: i64) => *PlatformerBulletDef { + if raw == 0 { + return nil + } + object := PlatformerBulletDef{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func PlatformerBulletDef.GetTypeId() => i32 { + return platformer_bulletdef_type() +} +func PlatformerBulletDef.SetTag(val: string) { + platformer_bulletdef_set_tag(*this.raw, ToDoraString(val)) +} +func PlatformerBulletDef.GetTag() => string { + return FromDoraString(platformer_bulletdef_get_tag(*this.raw)) +} +func PlatformerBulletDef.SetEndEffect(val: string) { + platformer_bulletdef_set_end_effect(*this.raw, ToDoraString(val)) +} +func PlatformerBulletDef.GetEndEffect() => string { + return FromDoraString(platformer_bulletdef_get_end_effect(*this.raw)) +} +func PlatformerBulletDef.SetLifeTime(val: f32) { + platformer_bulletdef_set_life_time(*this.raw, val) +} +func PlatformerBulletDef.GetLifeTime() => f32 { + return platformer_bulletdef_get_life_time(*this.raw) +} +func PlatformerBulletDef.SetDamageRadius(val: f32) { + platformer_bulletdef_set_damage_radius(*this.raw, val) +} +func PlatformerBulletDef.GetDamageRadius() => f32 { + return platformer_bulletdef_get_damage_radius(*this.raw) +} +func PlatformerBulletDef.SetHighSpeedFix(val: bool) { + platformer_bulletdef_set_high_speed_fix(*this.raw, ToDoraBool(val)) +} +func PlatformerBulletDef.IsHighSpeedFix() => bool { + return platformer_bulletdef_is_high_speed_fix(*this.raw) != 0 +} +func PlatformerBulletDef.SetGravity(val: Vec2) { + platformer_bulletdef_set_gravity(*this.raw, val.ToValue()) +} +func PlatformerBulletDef.GetGravity() => Vec2 { + return Vec2FromValue(platformer_bulletdef_get_gravity(*this.raw)) +} +func PlatformerBulletDef.SetFace(val: PlatformerFace) { + platformer_bulletdef_set_face(*this.raw, val.GetRaw()) +} +func PlatformerBulletDef.GetFace() => PlatformerFace { + return *PlatformerFaceFrom(platformer_bulletdef_get_face(*this.raw)) +} +func PlatformerBulletDef.GetBodyDef() => BodyDef { + return *BodyDefFrom(platformer_bulletdef_get_body_def(*this.raw)) +} +func PlatformerBulletDef.GetVelocity() => Vec2 { + return Vec2FromValue(platformer_bulletdef_get_velocity(*this.raw)) +} +func PlatformerBulletDef.SetAsCircle(radius: f32) { + platformer_bulletdef_set_as_circle(*this.raw, radius) +} +func PlatformerBulletDef.SetVelocity(angle: f32, speed: f32) { + platformer_bulletdef_set_velocity(*this.raw, angle, speed) +} +func NewPlatformerBulletDef() => PlatformerBulletDef { + raw := platformer_bulletdef_new() + object := PlatformerBulletDef{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/data.wa b/Tools/dora-wa/vendor/dora/platformer_data.wa similarity index 53% rename from Tools/dora-wa/vendor/dora/platformer/data.wa rename to Tools/dora-wa/vendor/dora/platformer_data.wa index 89775ce30..1bc405b04 100644 --- a/Tools/dora-wa/vendor/dora/platformer/data.wa +++ b/Tools/dora-wa/vendor/dora/platformer_data.wa @@ -51,4 +51,75 @@ func platformer_data_is_player(body: i64) => i32 #wa:import dora platformer_data_is_terrain func platformer_data_is_terrain(body: i64) => i32 #wa:import dora platformer_data_clear -func platformer_data_clear() \ No newline at end of file +func platformer_data_clear() +type _PlatformerData struct { } +global PlatformerData = _PlatformerData{} +func _PlatformerData.GetGroupFirstPlayer() => i32 { + return platformer_data_get_group_first_player() +} +func _PlatformerData.GetGroupLastPlayer() => i32 { + return platformer_data_get_group_last_player() +} +func _PlatformerData.GetGroupHide() => i32 { + return platformer_data_get_group_hide() +} +func _PlatformerData.GetGroupDetectPlayer() => i32 { + return platformer_data_get_group_detect_player() +} +func _PlatformerData.GetGroupTerrain() => i32 { + return platformer_data_get_group_terrain() +} +func _PlatformerData.GetGroupDetection() => i32 { + return platformer_data_get_group_detection() +} +func _PlatformerData.GetStore() => Dictionary { + return *DictionaryFrom(platformer_data_get_store()) +} +func _PlatformerData.SetShouldContact(group_a: i32, group_b: i32, contact: bool) { + platformer_data_set_should_contact(group_a, group_b, ToDoraBool(contact)) +} +func _PlatformerData.GetShouldContact(group_a: i32, group_b: i32) => bool { + return platformer_data_get_should_contact(group_a, group_b) != 0 +} +func _PlatformerData.SetRelation(group_a: i32, group_b: i32, relation: PlatformerRelation) { + platformer_data_set_relation(group_a, group_b, relation.ToValue()) +} +func _PlatformerData.GetRelationByGroup(group_a: i32, group_b: i32) => PlatformerRelation { + return PlatformerRelation{value: platformer_data_get_relation_by_group(group_a, group_b)} +} +func _PlatformerData.GetRelation(body_a: Body, body_b: Body) => PlatformerRelation { + return PlatformerRelation{value: platformer_data_get_relation(body_a.GetRaw(), body_b.GetRaw())} +} +func _PlatformerData.IsEnemyGroup(group_a: i32, group_b: i32) => bool { + return platformer_data_is_enemy_group(group_a, group_b) != 0 +} +func _PlatformerData.IsEnemy(body_a: Body, body_b: Body) => bool { + return platformer_data_is_enemy(body_a.GetRaw(), body_b.GetRaw()) != 0 +} +func _PlatformerData.IsFriendGroup(group_a: i32, group_b: i32) => bool { + return platformer_data_is_friend_group(group_a, group_b) != 0 +} +func _PlatformerData.IsFriend(body_a: Body, body_b: Body) => bool { + return platformer_data_is_friend(body_a.GetRaw(), body_b.GetRaw()) != 0 +} +func _PlatformerData.IsNeutralGroup(group_a: i32, group_b: i32) => bool { + return platformer_data_is_neutral_group(group_a, group_b) != 0 +} +func _PlatformerData.IsNeutral(body_a: Body, body_b: Body) => bool { + return platformer_data_is_neutral(body_a.GetRaw(), body_b.GetRaw()) != 0 +} +func _PlatformerData.SetDamageFactor(damage_type: i32, defence_type: i32, bounus: f32) { + platformer_data_set_damage_factor(damage_type, defence_type, bounus) +} +func _PlatformerData.GetDamageFactor(damage_type: i32, defence_type: i32) => f32 { + return platformer_data_get_damage_factor(damage_type, defence_type) +} +func _PlatformerData.IsPlayer(body: Body) => bool { + return platformer_data_is_player(body.GetRaw()) != 0 +} +func _PlatformerData.IsTerrain(body: Body) => bool { + return platformer_data_is_terrain(body.GetRaw()) != 0 +} +func _PlatformerData.Clear() { + platformer_data_clear() +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/decision/ai.wa b/Tools/dora-wa/vendor/dora/platformer_decision_ai.wa similarity index 61% rename from Tools/dora-wa/vendor/dora/platformer/decision/ai.wa rename to Tools/dora-wa/vendor/dora/platformer_decision_ai.wa index 8e105b608..917d5e24c 100644 --- a/Tools/dora-wa/vendor/dora/platformer/decision/ai.wa +++ b/Tools/dora-wa/vendor/dora/platformer_decision_ai.wa @@ -19,4 +19,27 @@ func platformer_decision_ai_get_nearest_unit_distance(relation: i32) => f32 #wa:import dora platformer_decision_ai_get_units_in_attack_range func platformer_decision_ai_get_units_in_attack_range() => i64 #wa:import dora platformer_decision_ai_get_bodies_in_attack_range -func platformer_decision_ai_get_bodies_in_attack_range() => i64 \ No newline at end of file +func platformer_decision_ai_get_bodies_in_attack_range() => i64 +type _PlatformerDecisionAI struct { } +global PlatformerDecisionAI = _PlatformerDecisionAI{} +func _PlatformerDecisionAI.GetUnitsByRelation(relation: PlatformerRelation) => Array { + return *ArrayFrom(platformer_decision_ai_get_units_by_relation(relation.ToValue())) +} +func _PlatformerDecisionAI.GetDetectedUnits() => Array { + return *ArrayFrom(platformer_decision_ai_get_detected_units()) +} +func _PlatformerDecisionAI.GetDetectedBodies() => Array { + return *ArrayFrom(platformer_decision_ai_get_detected_bodies()) +} +func _PlatformerDecisionAI.GetNearestUnit(relation: PlatformerRelation) => PlatformerUnit { + return *PlatformerUnitFrom(platformer_decision_ai_get_nearest_unit(relation.ToValue())) +} +func _PlatformerDecisionAI.GetNearestUnitDistance(relation: PlatformerRelation) => f32 { + return platformer_decision_ai_get_nearest_unit_distance(relation.ToValue()) +} +func _PlatformerDecisionAI.GetUnitsInAttackRange() => Array { + return *ArrayFrom(platformer_decision_ai_get_units_in_attack_range()) +} +func _PlatformerDecisionAI.GetBodiesInAttackRange() => Array { + return *ArrayFrom(platformer_decision_ai_get_bodies_in_attack_range()) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer_decision_tree.wa b/Tools/dora-wa/vendor/dora/platformer_decision_tree.wa new file mode 100644 index 000000000..2cafaa4b3 --- /dev/null +++ b/Tools/dora-wa/vendor/dora/platformer_decision_tree.wa @@ -0,0 +1,76 @@ +/* Copyright (c) 2024 Li Jin, dragon-fly@qq.com + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#wa:import dora platformer_decision_tree_type +func platformer_decision_tree_type() => i32 +#wa:import dora platformer_decision_leaf_sel +func platformer_decision_leaf_sel(nodes: i64) => i64 +#wa:import dora platformer_decision_leaf_seq +func platformer_decision_leaf_seq(nodes: i64) => i64 +#wa:import dora platformer_decision_leaf_con +func platformer_decision_leaf_con(name: i64, func0: i32, stack0: i64) => i64 +#wa:import dora platformer_decision_leaf_act +func platformer_decision_leaf_act(action_name: i64) => i64 +#wa:import dora platformer_decision_leaf_act_dynamic +func platformer_decision_leaf_act_dynamic(func0: i32, stack0: i64) => i64 +#wa:import dora platformer_decision_leaf_accept +func platformer_decision_leaf_accept() => i64 +#wa:import dora platformer_decision_leaf_reject +func platformer_decision_leaf_reject() => i64 +#wa:import dora platformer_decision_leaf_behave +func platformer_decision_leaf_behave(name: i64, root: i64) => i64 +type PlatformerDecisionTree struct { Object } +func PlatformerDecisionTreeFrom(raw: i64) => *PlatformerDecisionTree { + if raw == 0 { + return nil + } + object := PlatformerDecisionTree{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func PlatformerDecisionTree.GetTypeId() => i32 { + return platformer_decision_tree_type() +} +func PlatformerDecisionTreeSel(nodes: *[]PlatformerDecisionTree) => PlatformerDecisionTree { + return *PlatformerDecisionTreeFrom(platformer_decision_leaf_sel(ToDoraPlatformerDecisionTreeBuf(nodes))) +} +func PlatformerDecisionTreeSeq(nodes: *[]PlatformerDecisionTree) => PlatformerDecisionTree { + return *PlatformerDecisionTreeFrom(platformer_decision_leaf_seq(ToDoraPlatformerDecisionTreeBuf(nodes))) +} +func PlatformerDecisionTreeCon(name: string, handler: func(unit: PlatformerUnit) => bool) => PlatformerDecisionTree { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + unit := *PlatformerUnitFrom(stack0.PopObject().GetRaw()) + result_ := handler(unit) + stack0.Push(result_) + }) + return *PlatformerDecisionTreeFrom(platformer_decision_leaf_con(ToDoraString(name), func_id0, *stack0.raw)) +} +func PlatformerDecisionTreeAct(action_name: string) => PlatformerDecisionTree { + return *PlatformerDecisionTreeFrom(platformer_decision_leaf_act(ToDoraString(action_name))) +} +func PlatformerDecisionTreeActDynamic(handler: func(unit: PlatformerUnit) => string) => PlatformerDecisionTree { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + unit := *PlatformerUnitFrom(stack0.PopObject().GetRaw()) + result_ := handler(unit) + stack0.Push(result_) + }) + return *PlatformerDecisionTreeFrom(platformer_decision_leaf_act_dynamic(func_id0, *stack0.raw)) +} +func PlatformerDecisionTreeAccept() => PlatformerDecisionTree { + return *PlatformerDecisionTreeFrom(platformer_decision_leaf_accept()) +} +func PlatformerDecisionTreeReject() => PlatformerDecisionTree { + return *PlatformerDecisionTreeFrom(platformer_decision_leaf_reject()) +} +func PlatformerDecisionTreeBehave(name: string, root: PlatformerBehaviorTree) => PlatformerDecisionTree { + return *PlatformerDecisionTreeFrom(platformer_decision_leaf_behave(ToDoraString(name), root.GetRaw())) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/face.wa b/Tools/dora-wa/vendor/dora/platformer_face.wa similarity index 54% rename from Tools/dora-wa/vendor/dora/platformer/face.wa rename to Tools/dora-wa/vendor/dora/platformer_face.wa index dac017c47..60809fbfa 100644 --- a/Tools/dora-wa/vendor/dora/platformer/face.wa +++ b/Tools/dora-wa/vendor/dora/platformer_face.wa @@ -15,4 +15,43 @@ func platformer_face_to_node(slf: i64) => i64 #wa:import dora platformer_face_new func platformer_face_new(face_str: i64, point: i64, scale: f32, angle: f32) => i64 #wa:import dora platformer_face_with_func -func platformer_face_with_func(func0: i32, stack0: i64, point: i64, scale: f32, angle: f32) => i64 \ No newline at end of file +func platformer_face_with_func(func0: i32, stack0: i64, point: i64, scale: f32, angle: f32) => i64 +type PlatformerFace struct { Object } +func PlatformerFaceFrom(raw: i64) => *PlatformerFace { + if raw == 0 { + return nil + } + object := PlatformerFace{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func PlatformerFace.GetTypeId() => i32 { + return platformer_face_type() +} +func PlatformerFace.AddChild(face: PlatformerFace) { + platformer_face_add_child(*this.raw, face.GetRaw()) +} +func PlatformerFace.ToNode() => Node { + return *NodeFrom(platformer_face_to_node(*this.raw)) +} +func NewPlatformerFace(face_str: string, point: Vec2, scale: f32, angle: f32) => PlatformerFace { + raw := platformer_face_new(ToDoraString(face_str), point.ToValue(), scale, angle) + object := PlatformerFace{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} +func NewPlatformerFaceWithFunc(create_func: func() => Node, point: Vec2, scale: f32, angle: f32) => PlatformerFace { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + result_ := create_func() + stack0.Push(result_.Object) + }) + raw := platformer_face_with_func(func_id0, *stack0.raw, point.ToValue(), scale, angle) + object := PlatformerFace{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/platform_camera.wa b/Tools/dora-wa/vendor/dora/platformer_platform_camera.wa similarity index 53% rename from Tools/dora-wa/vendor/dora/platformer/platform_camera.wa rename to Tools/dora-wa/vendor/dora/platformer_platform_camera.wa index 829889950..5316bd5c3 100644 --- a/Tools/dora-wa/vendor/dora/platformer/platform_camera.wa +++ b/Tools/dora-wa/vendor/dora/platformer_platform_camera.wa @@ -39,4 +39,75 @@ func platformer_platformcamera_get_follow_target(slf: i64) => i64 #wa:import dora platformer_platformcamera_set_follow_target_null func platformer_platformcamera_set_follow_target_null(slf: i64) #wa:import dora platformer_platformcamera_new -func platformer_platformcamera_new(name: i64) => i64 \ No newline at end of file +func platformer_platformcamera_new(name: i64) => i64 +type PlatformerPlatformCamera struct { Camera } +func PlatformerPlatformCameraFrom(raw: i64) => *PlatformerPlatformCamera { + if raw == 0 { + return nil + } + object := PlatformerPlatformCamera{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func PlatformerPlatformCamera.GetTypeId() => i32 { + return platformer_platformcamera_type() +} +func PlatformerPlatformCamera.SetPosition(val: Vec2) { + platformer_platformcamera_set_position(*this.raw, val.ToValue()) +} +func PlatformerPlatformCamera.GetPosition() => Vec2 { + return Vec2FromValue(platformer_platformcamera_get_position(*this.raw)) +} +func PlatformerPlatformCamera.SetRotation(val: f32) { + platformer_platformcamera_set_rotation(*this.raw, val) +} +func PlatformerPlatformCamera.GetRotation() => f32 { + return platformer_platformcamera_get_rotation(*this.raw) +} +func PlatformerPlatformCamera.SetZoom(val: f32) { + platformer_platformcamera_set_zoom(*this.raw, val) +} +func PlatformerPlatformCamera.GetZoom() => f32 { + return platformer_platformcamera_get_zoom(*this.raw) +} +func PlatformerPlatformCamera.SetBoundary(val: Rect) { + platformer_platformcamera_set_boundary(*this.raw, val.GetRaw()) +} +func PlatformerPlatformCamera.GetBoundary() => Rect { + return *RectFrom(platformer_platformcamera_get_boundary(*this.raw)) +} +func PlatformerPlatformCamera.SetFollowRatio(val: Vec2) { + platformer_platformcamera_set_follow_ratio(*this.raw, val.ToValue()) +} +func PlatformerPlatformCamera.GetFollowRatio() => Vec2 { + return Vec2FromValue(platformer_platformcamera_get_follow_ratio(*this.raw)) +} +func PlatformerPlatformCamera.SetFollowOffset(val: Vec2) { + platformer_platformcamera_set_follow_offset(*this.raw, val.ToValue()) +} +func PlatformerPlatformCamera.GetFollowOffset() => Vec2 { + return Vec2FromValue(platformer_platformcamera_get_follow_offset(*this.raw)) +} +func PlatformerPlatformCamera.SetFollowTarget(val: Node) { + platformer_platformcamera_set_follow_target(*this.raw, val.GetRaw()) +} +func PlatformerPlatformCamera.GetFollowTarget() => *Node { + ptr_ := platformer_platformcamera_get_follow_target(*this.raw) + if ptr_ == 0 { + return nil + } + obj_ := *NodeFrom(ptr_) + return &obj_ +} +func PlatformerPlatformCamera.SetFollowTargetNull() { + platformer_platformcamera_set_follow_target_null(*this.raw) +} +func NewPlatformerPlatformCamera(name: string) => PlatformerPlatformCamera { + raw := platformer_platformcamera_new(ToDoraString(name)) + object := PlatformerPlatformCamera{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/platform_world.wa b/Tools/dora-wa/vendor/dora/platformer_platform_world.wa similarity index 54% rename from Tools/dora-wa/vendor/dora/platformer/platform_world.wa rename to Tools/dora-wa/vendor/dora/platformer_platform_world.wa index 08e1179f7..b877ca3c9 100644 --- a/Tools/dora-wa/vendor/dora/platformer/platform_world.wa +++ b/Tools/dora-wa/vendor/dora/platformer_platform_world.wa @@ -29,4 +29,55 @@ func platformer_platformworld_remove_layer(slf: i64, order: i32) #wa:import dora platformer_platformworld_remove_all_layers func platformer_platformworld_remove_all_layers(slf: i64) #wa:import dora platformer_platformworld_new -func platformer_platformworld_new() => i64 \ No newline at end of file +func platformer_platformworld_new() => i64 +type PlatformerPlatformWorld struct { PhysicsWorld } +func PlatformerPlatformWorldFrom(raw: i64) => *PlatformerPlatformWorld { + if raw == 0 { + return nil + } + object := PlatformerPlatformWorld{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func PlatformerPlatformWorld.GetTypeId() => i32 { + return platformer_platformworld_type() +} +func PlatformerPlatformWorld.GetCamera() => PlatformerPlatformCamera { + return *PlatformerPlatformCameraFrom(platformer_platformworld_get_camera(*this.raw)) +} +func PlatformerPlatformWorld.MoveChild(child: Node, new_order: i32) { + platformer_platformworld_move_child(*this.raw, child.GetRaw(), new_order) +} +func PlatformerPlatformWorld.GetLayer(order: i32) => Node { + return *NodeFrom(platformer_platformworld_get_layer(*this.raw, order)) +} +func PlatformerPlatformWorld.SetLayerRatio(order: i32, ratio: Vec2) { + platformer_platformworld_set_layer_ratio(*this.raw, order, ratio.ToValue()) +} +func PlatformerPlatformWorld.GetLayerRatio(order: i32) => Vec2 { + return Vec2FromValue(platformer_platformworld_get_layer_ratio(*this.raw, order)) +} +func PlatformerPlatformWorld.SetLayerOffset(order: i32, offset: Vec2) { + platformer_platformworld_set_layer_offset(*this.raw, order, offset.ToValue()) +} +func PlatformerPlatformWorld.GetLayerOffset(order: i32) => Vec2 { + return Vec2FromValue(platformer_platformworld_get_layer_offset(*this.raw, order)) +} +func PlatformerPlatformWorld.SwapLayer(order_a: i32, order_b: i32) { + platformer_platformworld_swap_layer(*this.raw, order_a, order_b) +} +func PlatformerPlatformWorld.RemoveLayer(order: i32) { + platformer_platformworld_remove_layer(*this.raw, order) +} +func PlatformerPlatformWorld.RemoveAllLayers() { + platformer_platformworld_remove_all_layers(*this.raw) +} +func NewPlatformerPlatformWorld() => PlatformerPlatformWorld { + raw := platformer_platformworld_new() + object := PlatformerPlatformWorld{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/target_allow.wa b/Tools/dora-wa/vendor/dora/platformer_target_allow.wa similarity index 53% rename from Tools/dora-wa/vendor/dora/platformer/target_allow.wa rename to Tools/dora-wa/vendor/dora/platformer_target_allow.wa index 1a6d6b1fa..6f54f5187 100644 --- a/Tools/dora-wa/vendor/dora/platformer/target_allow.wa +++ b/Tools/dora-wa/vendor/dora/platformer_target_allow.wa @@ -21,4 +21,50 @@ func platformer_targetallow_to_value(slf: i64) => i32 #wa:import dora platformer_targetallow_new func platformer_targetallow_new() => i64 #wa:import dora platformer_targetallow_with_value -func platformer_targetallow_with_value(value: i32) => i64 \ No newline at end of file +func platformer_targetallow_with_value(value: i32) => i64 +type PlatformerTargetAllow struct { raw: *i64 } +func PlatformerTargetAllow.GetRaw() => i64 { + return *this.raw +} +func platformer_target_allow_finalizer(ptr: u32) { + platformer_targetallow_release(GetPtr(ptr)) +} +func PlatformerTargetAllowFrom(raw: i64) => *PlatformerTargetAllow { + if raw == 0 { + return nil + } + item := PlatformerTargetAllow{} + item.raw = &raw + setFinalizer(item.raw, platformer_target_allow_finalizer) + result := &item + return result +} +func PlatformerTargetAllow.SetTerrainAllowed(val: bool) { + platformer_targetallow_set_terrain_allowed(*this.raw, ToDoraBool(val)) +} +func PlatformerTargetAllow.IsTerrainAllowed() => bool { + return platformer_targetallow_is_terrain_allowed(*this.raw) != 0 +} +func PlatformerTargetAllow.Allow(relation: PlatformerRelation, allow: bool) { + platformer_targetallow_allow(*this.raw, relation.ToValue(), ToDoraBool(allow)) +} +func PlatformerTargetAllow.IsAllow(relation: PlatformerRelation) => bool { + return platformer_targetallow_is_allow(*this.raw, relation.ToValue()) != 0 +} +func PlatformerTargetAllow.ToValue() => i32 { + return platformer_targetallow_to_value(*this.raw) +} +func NewPlatformerTargetAllow() => PlatformerTargetAllow { + raw := platformer_targetallow_new() + object := PlatformerTargetAllow{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} +func NewPlatformerTargetAllowWithValue(value: i32) => PlatformerTargetAllow { + raw := platformer_targetallow_with_value(value) + object := PlatformerTargetAllow{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer_unit.wa b/Tools/dora-wa/vendor/dora/platformer_unit.wa new file mode 100644 index 000000000..29adada89 --- /dev/null +++ b/Tools/dora-wa/vendor/dora/platformer_unit.wa @@ -0,0 +1,198 @@ +/* Copyright (c) 2024 Li Jin, dragon-fly@qq.com + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#wa:import dora platformer_unit_type +func platformer_unit_type() => i32 +#wa:import dora platformer_unit_set_playable +func platformer_unit_set_playable(slf: i64, val: i64); +#wa:import dora platformer_unit_get_playable +func platformer_unit_get_playable(slf: i64) => i64 +#wa:import dora platformer_unit_set_detect_distance +func platformer_unit_set_detect_distance(slf: i64, val: f32); +#wa:import dora platformer_unit_get_detect_distance +func platformer_unit_get_detect_distance(slf: i64) => f32 +#wa:import dora platformer_unit_set_attack_range +func platformer_unit_set_attack_range(slf: i64, val: i64); +#wa:import dora platformer_unit_get_attack_range +func platformer_unit_get_attack_range(slf: i64) => i64 +#wa:import dora platformer_unit_set_face_right +func platformer_unit_set_face_right(slf: i64, val: i32); +#wa:import dora platformer_unit_is_face_right +func platformer_unit_is_face_right(slf: i64) => i32 +#wa:import dora platformer_unit_set_receiving_decision_trace +func platformer_unit_set_receiving_decision_trace(slf: i64, val: i32); +#wa:import dora platformer_unit_is_receiving_decision_trace +func platformer_unit_is_receiving_decision_trace(slf: i64) => i32 +#wa:import dora platformer_unit_set_decision_tree +func platformer_unit_set_decision_tree(slf: i64, val: i64); +#wa:import dora platformer_unit_get_decision_tree +func platformer_unit_get_decision_tree(slf: i64) => i64 +#wa:import dora platformer_unit_is_on_surface +func platformer_unit_is_on_surface(slf: i64) => i32 +#wa:import dora platformer_unit_get_ground_sensor +func platformer_unit_get_ground_sensor(slf: i64) => i64 +#wa:import dora platformer_unit_get_detect_sensor +func platformer_unit_get_detect_sensor(slf: i64) => i64 +#wa:import dora platformer_unit_get_attack_sensor +func platformer_unit_get_attack_sensor(slf: i64) => i64 +#wa:import dora platformer_unit_get_unit_def +func platformer_unit_get_unit_def(slf: i64) => i64 +#wa:import dora platformer_unit_get_current_action +func platformer_unit_get_current_action(slf: i64) => i64 +#wa:import dora platformer_unit_get_width +func platformer_unit_get_width(slf: i64) => f32 +#wa:import dora platformer_unit_get_height +func platformer_unit_get_height(slf: i64) => f32 +#wa:import dora platformer_unit_get_entity +func platformer_unit_get_entity(slf: i64) => i64 +#wa:import dora platformer_unit_attach_action +func platformer_unit_attach_action(slf: i64, name: i64) => i64 +#wa:import dora platformer_unit_remove_action +func platformer_unit_remove_action(slf: i64, name: i64) +#wa:import dora platformer_unit_remove_all_actions +func platformer_unit_remove_all_actions(slf: i64) +#wa:import dora platformer_unit_get_action +func platformer_unit_get_action(slf: i64, name: i64) => i64 +#wa:import dora platformer_unit_each_action +func platformer_unit_each_action(slf: i64, func0: i32, stack0: i64) +#wa:import dora platformer_unit_start +func platformer_unit_start(slf: i64, name: i64) => i32 +#wa:import dora platformer_unit_stop +func platformer_unit_stop(slf: i64) +#wa:import dora platformer_unit_is_doing +func platformer_unit_is_doing(slf: i64, name: i64) => i32 +#wa:import dora platformer_unit_new +func platformer_unit_new(unit_def: i64, physics_world: i64, entity: i64, pos: i64, rot: f32) => i64 +#wa:import dora platformer_unit_with_store +func platformer_unit_with_store(unit_def_name: i64, physics_world_name: i64, entity: i64, pos: i64, rot: f32) => i64 +type PlatformerUnit struct { Body } +func PlatformerUnitFrom(raw: i64) => *PlatformerUnit { + if raw == 0 { + return nil + } + object := PlatformerUnit{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func PlatformerUnit.GetTypeId() => i32 { + return platformer_unit_type() +} +func PlatformerUnit.SetPlayable(val: Playable) { + platformer_unit_set_playable(*this.raw, val.GetRaw()) +} +func PlatformerUnit.GetPlayable() => Playable { + return *PlayableFrom(platformer_unit_get_playable(*this.raw)) +} +func PlatformerUnit.SetDetectDistance(val: f32) { + platformer_unit_set_detect_distance(*this.raw, val) +} +func PlatformerUnit.GetDetectDistance() => f32 { + return platformer_unit_get_detect_distance(*this.raw) +} +func PlatformerUnit.SetAttackRange(val: Size) { + platformer_unit_set_attack_range(*this.raw, val.ToValue()) +} +func PlatformerUnit.GetAttackRange() => Size { + return SizeFromValue(platformer_unit_get_attack_range(*this.raw)) +} +func PlatformerUnit.SetFaceRight(val: bool) { + platformer_unit_set_face_right(*this.raw, ToDoraBool(val)) +} +func PlatformerUnit.IsFaceRight() => bool { + return platformer_unit_is_face_right(*this.raw) != 0 +} +func PlatformerUnit.SetReceivingDecisionTrace(val: bool) { + platformer_unit_set_receiving_decision_trace(*this.raw, ToDoraBool(val)) +} +func PlatformerUnit.IsReceivingDecisionTrace() => bool { + return platformer_unit_is_receiving_decision_trace(*this.raw) != 0 +} +func PlatformerUnit.SetDecisionTree(val: string) { + platformer_unit_set_decision_tree(*this.raw, ToDoraString(val)) +} +func PlatformerUnit.GetDecisionTree() => string { + return FromDoraString(platformer_unit_get_decision_tree(*this.raw)) +} +func PlatformerUnit.IsOnSurface() => bool { + return platformer_unit_is_on_surface(*this.raw) != 0 +} +func PlatformerUnit.GetGroundSensor() => Sensor { + return *SensorFrom(platformer_unit_get_ground_sensor(*this.raw)) +} +func PlatformerUnit.GetDetectSensor() => Sensor { + return *SensorFrom(platformer_unit_get_detect_sensor(*this.raw)) +} +func PlatformerUnit.GetAttackSensor() => Sensor { + return *SensorFrom(platformer_unit_get_attack_sensor(*this.raw)) +} +func PlatformerUnit.GetUnitDef() => Dictionary { + return *DictionaryFrom(platformer_unit_get_unit_def(*this.raw)) +} +func PlatformerUnit.GetCurrentAction() => PlatformerUnitAction { + return *PlatformerUnitActionFrom(platformer_unit_get_current_action(*this.raw)) +} +func PlatformerUnit.GetWidth() => f32 { + return platformer_unit_get_width(*this.raw) +} +func PlatformerUnit.GetHeight() => f32 { + return platformer_unit_get_height(*this.raw) +} +func PlatformerUnit.GetEntity() => Entity { + return *EntityFrom(platformer_unit_get_entity(*this.raw)) +} +func PlatformerUnit.AttachAction(name: string) => PlatformerUnitAction { + return *PlatformerUnitActionFrom(platformer_unit_attach_action(*this.raw, ToDoraString(name))) +} +func PlatformerUnit.RemoveAction(name: string) { + platformer_unit_remove_action(*this.raw, ToDoraString(name)) +} +func PlatformerUnit.RemoveAllActions() { + platformer_unit_remove_all_actions(*this.raw) +} +func PlatformerUnit.GetAction(name: string) => *PlatformerUnitAction { + ptr_ := platformer_unit_get_action(*this.raw, ToDoraString(name)) + if ptr_ == 0 { + return nil + } + obj_ := *PlatformerUnitActionFrom(ptr_) + return &obj_ +} +func PlatformerUnit.EachAction(visitor_func: func(action: PlatformerUnitAction)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + action_raw, _ := stack0.PopI64() + action := *PlatformerUnitActionFrom(action_raw) + visitor_func(action) + }) + platformer_unit_each_action(*this.raw, func_id0, *stack0.raw) +} +func PlatformerUnit.Start(name: string) => bool { + return platformer_unit_start(*this.raw, ToDoraString(name)) != 0 +} +func PlatformerUnit.Stop() { + platformer_unit_stop(*this.raw) +} +func PlatformerUnit.IsDoing(name: string) => bool { + return platformer_unit_is_doing(*this.raw, ToDoraString(name)) != 0 +} +func NewPlatformerUnit(unit_def: Dictionary, physics_world: PhysicsWorld, entity: Entity, pos: Vec2, rot: f32) => PlatformerUnit { + raw := platformer_unit_new(unit_def.GetRaw(), physics_world.GetRaw(), entity.GetRaw(), pos.ToValue(), rot) + object := PlatformerUnit{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} +func NewPlatformerUnitWithStore(unit_def_name: string, physics_world_name: string, entity: Entity, pos: Vec2, rot: f32) => PlatformerUnit { + raw := platformer_unit_with_store(ToDoraString(unit_def_name), ToDoraString(physics_world_name), entity.GetRaw(), pos.ToValue(), rot) + object := PlatformerUnit{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer_unit_action.wa b/Tools/dora-wa/vendor/dora/platformer_unit_action.wa new file mode 100644 index 000000000..6fd129526 --- /dev/null +++ b/Tools/dora-wa/vendor/dora/platformer_unit_action.wa @@ -0,0 +1,94 @@ +/* Copyright (c) 2024 Li Jin, dragon-fly@qq.com + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#wa:import dora platformer_unitaction_set_reaction +func platformer_unitaction_set_reaction(slf: i64, val: f32); +#wa:import dora platformer_unitaction_get_reaction +func platformer_unitaction_get_reaction(slf: i64) => f32 +#wa:import dora platformer_unitaction_set_recovery +func platformer_unitaction_set_recovery(slf: i64, val: f32); +#wa:import dora platformer_unitaction_get_recovery +func platformer_unitaction_get_recovery(slf: i64) => f32 +#wa:import dora platformer_unitaction_get_name +func platformer_unitaction_get_name(slf: i64) => i64 +#wa:import dora platformer_unitaction_is_doing +func platformer_unitaction_is_doing(slf: i64) => i32 +#wa:import dora platformer_unitaction_get_owner +func platformer_unitaction_get_owner(slf: i64) => i64 +#wa:import dora platformer_unitaction_get_elapsed_time +func platformer_unitaction_get_elapsed_time(slf: i64) => f32 +#wa:import dora platformer_unitaction_clear +func platformer_unitaction_clear() +#wa:import dora platformer_unitaction_add +func platformer_unitaction_add(name: i64, priority: i32, reaction: f32, recovery: f32, queued: i32, func0: i32, stack0: i64, func1: i32, stack1: i64, func2: i32, stack2: i64) +type PlatformerUnitAction struct { raw: *i64 } +func PlatformerUnitAction.GetRaw() => i64 { + return *this.raw +} +func PlatformerUnitActionFrom(raw: i64) => *PlatformerUnitAction { + if raw == 0 { + return nil + } + item := PlatformerUnitAction{} + item.raw = &raw + result := &item + return result +} +func PlatformerUnitAction.SetReaction(val: f32) { + platformer_unitaction_set_reaction(*this.raw, val) +} +func PlatformerUnitAction.GetReaction() => f32 { + return platformer_unitaction_get_reaction(*this.raw) +} +func PlatformerUnitAction.SetRecovery(val: f32) { + platformer_unitaction_set_recovery(*this.raw, val) +} +func PlatformerUnitAction.GetRecovery() => f32 { + return platformer_unitaction_get_recovery(*this.raw) +} +func PlatformerUnitAction.GetName() => string { + return FromDoraString(platformer_unitaction_get_name(*this.raw)) +} +func PlatformerUnitAction.IsDoing() => bool { + return platformer_unitaction_is_doing(*this.raw) != 0 +} +func PlatformerUnitAction.GetOwner() => PlatformerUnit { + return *PlatformerUnitFrom(platformer_unitaction_get_owner(*this.raw)) +} +func PlatformerUnitAction.GetElapsedTime() => f32 { + return platformer_unitaction_get_elapsed_time(*this.raw) +} +func PlatformerUnitActionClear() { + platformer_unitaction_clear() +} +func PlatformerUnitActionAdd(name: string, priority: i32, reaction: f32, recovery: f32, queued: bool, available: func(owner: PlatformerUnit, action: PlatformerUnitAction) => bool, create: func(owner: PlatformerUnit, action: PlatformerUnitAction) => PlatformerActionUpdate, stop: func(owner: PlatformerUnit, action: PlatformerUnitAction)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + owner := *PlatformerUnitFrom(stack0.PopObject().GetRaw()) + action_raw, _ := stack0.PopI64() + action := *PlatformerUnitActionFrom(action_raw) + result_ := available(owner, action) + stack0.Push(result_) + }) + stack1 := NewCallStack() + func_id1 := PushFunction(func() { + owner := *PlatformerUnitFrom(stack1.PopObject().GetRaw()) + action_raw, _ := stack1.PopI64() + action := *PlatformerUnitActionFrom(action_raw) + result_ := create(owner, action) + stack1.Push(result_.Object) + }) + stack2 := NewCallStack() + func_id2 := PushFunction(func() { + owner := *PlatformerUnitFrom(stack2.PopObject().GetRaw()) + action_raw, _ := stack2.PopI64() + action := *PlatformerUnitActionFrom(action_raw) + stop(owner, action) + }) + platformer_unitaction_add(ToDoraString(name), priority, reaction, recovery, ToDoraBool(queued), func_id0, *stack0.raw, func_id1, *stack1.raw, func_id2, *stack2.raw) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/platformer/visual.wa b/Tools/dora-wa/vendor/dora/platformer_visual.wa similarity index 61% rename from Tools/dora-wa/vendor/dora/platformer/visual.wa rename to Tools/dora-wa/vendor/dora/platformer_visual.wa index 3d223dfeb..cb15bd7af 100644 --- a/Tools/dora-wa/vendor/dora/platformer/visual.wa +++ b/Tools/dora-wa/vendor/dora/platformer_visual.wa @@ -17,4 +17,37 @@ func platformer_visual_stop(slf: i64) #wa:import dora platformer_visual_auto_remove func platformer_visual_auto_remove(slf: i64) => i64 #wa:import dora platformer_visual_new -func platformer_visual_new(name: i64) => i64 \ No newline at end of file +func platformer_visual_new(name: i64) => i64 +type PlatformerVisual struct { Node } +func PlatformerVisualFrom(raw: i64) => *PlatformerVisual { + if raw == 0 { + return nil + } + object := PlatformerVisual{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func PlatformerVisual.GetTypeId() => i32 { + return platformer_visual_type() +} +func PlatformerVisual.IsPlaying() => bool { + return platformer_visual_is_playing(*this.raw) != 0 +} +func PlatformerVisual.Start() { + platformer_visual_start(*this.raw) +} +func PlatformerVisual.Stop() { + platformer_visual_stop(*this.raw) +} +func PlatformerVisual.AutoRemove() => PlatformerVisual { + return *PlatformerVisualFrom(platformer_visual_auto_remove(*this.raw)) +} +func NewPlatformerVisual(name: string) => PlatformerVisual { + raw := platformer_visual_new(ToDoraString(name)) + object := PlatformerVisual{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/playable.wa b/Tools/dora-wa/vendor/dora/playable.wa index 239d73c43..580d96f3e 100644 --- a/Tools/dora-wa/vendor/dora/playable.wa +++ b/Tools/dora-wa/vendor/dora/playable.wa @@ -39,4 +39,78 @@ func playable_set_slot(slf: i64, name: i64, item: i64) #wa:import dora playable_get_slot func playable_get_slot(slf: i64, name: i64) => i64 #wa:import dora playable_new -func playable_new(filename: i64) => i64 \ No newline at end of file +func playable_new(filename: i64) => i64 +type Playable struct { Node } +func PlayableFrom(raw: i64) => *Playable { + if raw == 0 { + return nil + } + object := Playable{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Playable.GetTypeId() => i32 { + return playable_type() +} +func Playable.SetLook(val: string) { + playable_set_look(*this.raw, ToDoraString(val)) +} +func Playable.GetLook() => string { + return FromDoraString(playable_get_look(*this.raw)) +} +func Playable.SetSpeed(val: f32) { + playable_set_speed(*this.raw, val) +} +func Playable.GetSpeed() => f32 { + return playable_get_speed(*this.raw) +} +func Playable.SetRecovery(val: f32) { + playable_set_recovery(*this.raw, val) +} +func Playable.GetRecovery() => f32 { + return playable_get_recovery(*this.raw) +} +func Playable.SetFliped(val: bool) { + playable_set_fliped(*this.raw, ToDoraBool(val)) +} +func Playable.IsFliped() => bool { + return playable_is_fliped(*this.raw) != 0 +} +func Playable.GetCurrent() => string { + return FromDoraString(playable_get_current(*this.raw)) +} +func Playable.GetLastCompleted() => string { + return FromDoraString(playable_get_last_completed(*this.raw)) +} +func Playable.GetKey(name: string) => Vec2 { + return Vec2FromValue(playable_get_key(*this.raw, ToDoraString(name))) +} +func Playable.Play(name: string, looping: bool) => f32 { + return playable_play(*this.raw, ToDoraString(name), ToDoraBool(looping)) +} +func Playable.Stop() { + playable_stop(*this.raw) +} +func Playable.SetSlot(name: string, item: Node) { + playable_set_slot(*this.raw, ToDoraString(name), item.GetRaw()) +} +func Playable.GetSlot(name: string) => *Node { + ptr_ := playable_get_slot(*this.raw, ToDoraString(name)) + if ptr_ == 0 { + return nil + } + obj_ := *NodeFrom(ptr_) + return &obj_ +} +func NewPlayable(filename: string) => *Playable { + raw := playable_new(ToDoraString(filename)) + if raw == 0 { + return nil + } + object := Playable{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/q_learner.wa b/Tools/dora-wa/vendor/dora/q_learner.wa index 427be3064..2dd7a9a86 100644 --- a/Tools/dora-wa/vendor/dora/q_learner.wa +++ b/Tools/dora-wa/vendor/dora/q_learner.wa @@ -19,4 +19,47 @@ func mlqlearner_pack(hints: i64, values: i64) => i64 #wa:import dora mlqlearner_unpack func mlqlearner_unpack(hints: i64, state: i64) => i64 #wa:import dora mlqlearner_new -func mlqlearner_new(gamma: f64, alpha: f64, max_q: f64) => i64 \ No newline at end of file +func mlqlearner_new(gamma: f64, alpha: f64, max_q: f64) => i64 +type QLearner struct { Object } +func QLearnerFrom(raw: i64) => *QLearner { + if raw == 0 { + return nil + } + object := QLearner{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func QLearner.GetTypeId() => i32 { + return qlearner_type() +} +func QLearner.Update(state: i64, action: i32, reward: f64) { + mlqlearner_update(*this.raw, state, action, reward) +} +func QLearner.GetBestAction(state: i64) => i32 { + return mlqlearner_get_best_action(*this.raw, state) +} +func QLearner.VisitMatrix(handler: func(state: i64, action: i32, q: f64)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + state, _ := stack0.PopI64() + action, _ := stack0.PopI32() + q, _ := stack0.PopF64() + handler(state, action, q) + }) + mlqlearner_visit_matrix(*this.raw, func_id0, *stack0.raw) +} +func QLearnerPack(hints: *[]i32, values: *[]i32) => i64 { + return mlqlearner_pack(ToDoraI32Buf(hints), ToDoraI32Buf(values)) +} +func QLearnerUnpack(hints: *[]i32, state: i64) => *[]i32 { + return FromDoraI32Buf(mlqlearner_unpack(ToDoraI32Buf(hints), state)) +} +func NewQLearner(gamma: f64, alpha: f64, max_q: f64) => QLearner { + raw := mlqlearner_new(gamma, alpha, max_q) + object := QLearner{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/rect.wa b/Tools/dora-wa/vendor/dora/rect.wa index b9a251398..6962ee5d7 100644 --- a/Tools/dora-wa/vendor/dora/rect.wa +++ b/Tools/dora-wa/vendor/dora/rect.wa @@ -190,8 +190,8 @@ func Rect.Equals(other: Rect) => bool { return rect_equals(*this.raw, other.GetRaw()) != 0 } func NewRect(origin: Vec2, size: Size) => Rect { - object := Rect{} raw := rect_new(origin.ToValue(), size.ToValue()) + object := Rect{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/render_target.wa b/Tools/dora-wa/vendor/dora/render_target.wa index 72335cb4c..23817548b 100644 --- a/Tools/dora-wa/vendor/dora/render_target.wa +++ b/Tools/dora-wa/vendor/dora/render_target.wa @@ -27,4 +27,62 @@ func rendertarget_render_clear_with_target(slf: i64, target: i64, color: i32, de #wa:import dora rendertarget_save_async func rendertarget_save_async(slf: i64, filename: i64, func0: i32, stack0: i64) #wa:import dora rendertarget_new -func rendertarget_new(width: i32, height: i32) => i64 \ No newline at end of file +func rendertarget_new(width: i32, height: i32) => i64 +type RenderTarget struct { Object } +func RenderTargetFrom(raw: i64) => *RenderTarget { + if raw == 0 { + return nil + } + object := RenderTarget{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func RenderTarget.GetTypeId() => i32 { + return rendertarget_type() +} +func RenderTarget.GetWidth() => i32 { + return rendertarget_get_width(*this.raw) +} +func RenderTarget.GetHeight() => i32 { + return rendertarget_get_height(*this.raw) +} +func RenderTarget.SetCamera(val: Camera) { + rendertarget_set_camera(*this.raw, val.GetRaw()) +} +func RenderTarget.GetCamera() => *Camera { + ptr_ := rendertarget_get_camera(*this.raw) + if ptr_ == 0 { + return nil + } + obj_ := *CameraFrom(ptr_) + return &obj_ +} +func RenderTarget.GetTexture() => Texture2D { + return *Texture2DFrom(rendertarget_get_texture(*this.raw)) +} +func RenderTarget.Render(target: Node) { + rendertarget_render(*this.raw, target.GetRaw()) +} +func RenderTarget.RenderClear(color: Color, depth: f32, stencil: i32) { + rendertarget_render_clear(*this.raw, color.ToARGB(), depth, stencil) +} +func RenderTarget.RenderClearWithTarget(target: Node, color: Color, depth: f32, stencil: i32) { + rendertarget_render_clear_with_target(*this.raw, target.GetRaw(), color.ToARGB(), depth, stencil) +} +func RenderTarget.SaveAsync(filename: string, handler: func(success: bool)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + success, _ := stack0.PopBool() + handler(success) + }) + rendertarget_save_async(*this.raw, ToDoraString(filename), func_id0, *stack0.raw) +} +func NewRenderTarget(width: i32, height: i32) => RenderTarget { + raw := rendertarget_new(width, height) + object := RenderTarget{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/scheduler.wa b/Tools/dora-wa/vendor/dora/scheduler.wa index 5b419d70f..2951b4a31 100644 --- a/Tools/dora-wa/vendor/dora/scheduler.wa +++ b/Tools/dora-wa/vendor/dora/scheduler.wa @@ -50,8 +50,8 @@ func Scheduler.Update(delta_time: f64) => bool { return scheduler_update(*this.raw, delta_time) != 0 } func NewScheduler() => Scheduler { - object := Scheduler{} raw := scheduler_new() + object := Scheduler{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/spine.wa b/Tools/dora-wa/vendor/dora/spine.wa index 040203d31..33bb760c5 100644 --- a/Tools/dora-wa/vendor/dora/spine.wa +++ b/Tools/dora-wa/vendor/dora/spine.wa @@ -25,4 +25,59 @@ func spine_new(spine_str: i64) => i64 #wa:import dora spine_get_looks func spine_get_looks(spine_str: i64) => i64 #wa:import dora spine_get_animations -func spine_get_animations(spine_str: i64) => i64 \ No newline at end of file +func spine_get_animations(spine_str: i64) => i64 +type Spine struct { Playable } +func SpineFrom(raw: i64) => *Spine { + if raw == 0 { + return nil + } + object := Spine{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Spine.GetTypeId() => i32 { + return spine_type() +} +func Spine.SetHitTestEnabled(val: bool) { + spine_set_hit_test_enabled(*this.raw, ToDoraBool(val)) +} +func Spine.IsHitTestEnabled() => bool { + return spine_is_hit_test_enabled(*this.raw) != 0 +} +func Spine.SetBoneRotation(name: string, rotation: f32) => bool { + return spine_set_bone_rotation(*this.raw, ToDoraString(name), rotation) != 0 +} +func Spine.ContainsPoint(x: f32, y: f32) => string { + return FromDoraString(spine_contains_point(*this.raw, x, y)) +} +func Spine.IntersectsSegment(x_1: f32, y_1: f32, x_2: f32, y_2: f32) => string { + return FromDoraString(spine_intersects_segment(*this.raw, x_1, y_1, x_2, y_2)) +} +func NewSpineWithFiles(skel_file: string, atlas_file: string) => *Spine { + raw := spine_with_files(ToDoraString(skel_file), ToDoraString(atlas_file)) + if raw == 0 { + return nil + } + object := Spine{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} +func NewSpine(spine_str: string) => *Spine { + raw := spine_new(ToDoraString(spine_str)) + if raw == 0 { + return nil + } + object := Spine{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} +func SpineGetLooks(spine_str: string) => *[]string { + return FromDoraStrBuf(spine_get_looks(ToDoraString(spine_str))) +} +func SpineGetAnimations(spine_str: string) => *[]string { + return FromDoraStrBuf(spine_get_animations(ToDoraString(spine_str))) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/sprite.wa b/Tools/dora-wa/vendor/dora/sprite.wa index 98e58b030..ca75e94c8 100644 --- a/Tools/dora-wa/vendor/dora/sprite.wa +++ b/Tools/dora-wa/vendor/dora/sprite.wa @@ -126,29 +126,32 @@ func Sprite.SetEffectAsDefault() { sprite_set_effect_as_default(*this.raw) } func NewSprite() => Sprite { - object := Sprite{} raw := sprite_new() + object := Sprite{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object } func NewSpriteWithTextureRect(texture: Texture2D, texture_rect: Rect) => Sprite { - object := Sprite{} raw := sprite_with_texture_rect(texture.GetRaw(), texture_rect.GetRaw()) + object := Sprite{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object } func NewSpriteWithTexture(texture: Texture2D) => Sprite { - object := Sprite{} raw := sprite_with_texture(texture.GetRaw()) + object := Sprite{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object } func NewSpriteWithFile(clip_str: string) => *Sprite { - object := Sprite{} raw := sprite_with_file(ToDoraString(clip_str)) + if raw == 0 { + return nil + } + object := Sprite{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return &object diff --git a/Tools/dora-wa/vendor/dora/sprite_effect.wa b/Tools/dora-wa/vendor/dora/sprite_effect.wa index 4fd8f5245..cccd9ac9a 100644 --- a/Tools/dora-wa/vendor/dora/sprite_effect.wa +++ b/Tools/dora-wa/vendor/dora/sprite_effect.wa @@ -25,8 +25,8 @@ func SpriteEffect.GetTypeId() => i32 { return spriteeffect_type() } func NewSpriteEffect(vert_shader: string, frag_shader: string) => SpriteEffect { - object := SpriteEffect{} raw := spriteeffect_new(ToDoraString(vert_shader), ToDoraString(frag_shader)) + object := SpriteEffect{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return object diff --git a/Tools/dora-wa/vendor/dora/svg.wa b/Tools/dora-wa/vendor/dora/svg.wa index ade40854e..dfef38493 100644 --- a/Tools/dora-wa/vendor/dora/svg.wa +++ b/Tools/dora-wa/vendor/dora/svg.wa @@ -15,4 +15,37 @@ func svgdef_get_height(slf: i64) => f32 #wa:import dora svgdef_render func svgdef_render(slf: i64) #wa:import dora svgdef_new -func svgdef_new(filename: i64) => i64 \ No newline at end of file +func svgdef_new(filename: i64) => i64 +type SVG struct { Object } +func SVGFrom(raw: i64) => *SVG { + if raw == 0 { + return nil + } + object := SVG{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func SVG.GetTypeId() => i32 { + return svg_type() +} +func SVG.GetWidth() => f32 { + return svgdef_get_width(*this.raw) +} +func SVG.GetHeight() => f32 { + return svgdef_get_height(*this.raw) +} +func SVG.Render() { + svgdef_render(*this.raw) +} +func NewSVG(filename: string) => *SVG { + raw := svgdef_new(ToDoraString(filename)) + if raw == 0 { + return nil + } + object := SVG{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/texture_2d.wa b/Tools/dora-wa/vendor/dora/texture_2d.wa index 57be60f90..a6338af2a 100644 --- a/Tools/dora-wa/vendor/dora/texture_2d.wa +++ b/Tools/dora-wa/vendor/dora/texture_2d.wa @@ -35,8 +35,11 @@ func Texture2D.GetHeight() => i32 { return texture2d_get_height(*this.raw) } func NewTexture2DWithFile(filename: string) => *Texture2D { - object := Texture2D{} raw := texture2d_with_file(ToDoraString(filename)) + if raw == 0 { + return nil + } + object := Texture2D{} object.raw = &raw setFinalizer(object.raw, ObjectFinalizer) return &object diff --git a/Tools/dora-wa/vendor/dora/tile_node.wa b/Tools/dora-wa/vendor/dora/tile_node.wa index 1aebfafa9..6c5b02cf4 100644 --- a/Tools/dora-wa/vendor/dora/tile_node.wa +++ b/Tools/dora-wa/vendor/dora/tile_node.wa @@ -31,4 +31,80 @@ func tilenode_new(tmx_file: i64) => i64 #wa:import dora tilenode_with_with_layer func tilenode_with_with_layer(tmx_file: i64, layer_name: i64) => i64 #wa:import dora tilenode_with_with_layers -func tilenode_with_with_layers(tmx_file: i64, layer_names: i64) => i64 \ No newline at end of file +func tilenode_with_with_layers(tmx_file: i64, layer_names: i64) => i64 +type TileNode struct { Node } +func TileNodeFrom(raw: i64) => *TileNode { + if raw == 0 { + return nil + } + object := TileNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func TileNode.GetTypeId() => i32 { + return tilenode_type() +} +func TileNode.SetDepthWrite(val: bool) { + tilenode_set_depth_write(*this.raw, ToDoraBool(val)) +} +func TileNode.IsDepthWrite() => bool { + return tilenode_is_depth_write(*this.raw) != 0 +} +func TileNode.SetBlendFunc(blend_func: BlendFunc) { + tilenode__set_blend_func(*this.raw, blend_func.ToValue()) +} +func TileNode.GetBlendFunc() => BlendFunc { + return BlendFuncFrom(tilenode__get_blend_func(*this.raw)) +} +func TileNode.SetEffect(val: SpriteEffect) { + tilenode_set_effect(*this.raw, val.GetRaw()) +} +func TileNode.GetEffect() => SpriteEffect { + return *SpriteEffectFrom(tilenode_get_effect(*this.raw)) +} +func TileNode.SetFilter(val: TextureFilter) { + tilenode_set_filter(*this.raw, val.ToValue()) +} +func TileNode.GetFilter() => TextureFilter { + return TextureFilter{value: tilenode_get_filter(*this.raw)} +} +func TileNode.GetLayer(layer_name: string) => *Dictionary { + ptr_ := tilenode_get_layer(*this.raw, ToDoraString(layer_name)) + if ptr_ == 0 { + return nil + } + obj_ := *DictionaryFrom(ptr_) + return &obj_ +} +func NewTileNode(tmx_file: string) => *TileNode { + raw := tilenode_new(ToDoraString(tmx_file)) + if raw == 0 { + return nil + } + object := TileNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} +func NewTileNodeWithWithLayer(tmx_file: string, layer_name: string) => *TileNode { + raw := tilenode_with_with_layer(ToDoraString(tmx_file), ToDoraString(layer_name)) + if raw == 0 { + return nil + } + object := TileNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} +func NewTileNodeWithWithLayers(tmx_file: string, layer_names: *[]string) => *TileNode { + raw := tilenode_with_with_layers(ToDoraString(tmx_file), ToDoraStrBuf(layer_names)) + if raw == 0 { + return nil + } + object := TileNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return &object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/touch.wa b/Tools/dora-wa/vendor/dora/touch.wa index d834ed0b9..a5028aa7b 100644 --- a/Tools/dora-wa/vendor/dora/touch.wa +++ b/Tools/dora-wa/vendor/dora/touch.wa @@ -21,4 +21,39 @@ func touch_get_delta(slf: i64) => i64 #wa:import dora touch_get_location func touch_get_location(slf: i64) => i64 #wa:import dora touch_get_world_location -func touch_get_world_location(slf: i64) => i64 \ No newline at end of file +func touch_get_world_location(slf: i64) => i64 +type Touch struct { Object } +func TouchFrom(raw: i64) => *Touch { + if raw == 0 { + return nil + } + object := Touch{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Touch.GetTypeId() => i32 { + return touch_type() +} +func Touch.SetEnabled(val: bool) { + touch_set_enabled(*this.raw, ToDoraBool(val)) +} +func Touch.IsEnabled() => bool { + return touch_is_enabled(*this.raw) != 0 +} +func Touch.IsFirst() => bool { + return touch_is_first(*this.raw) != 0 +} +func Touch.GetId() => i32 { + return touch_get_id(*this.raw) +} +func Touch.GetDelta() => Vec2 { + return Vec2FromValue(touch_get_delta(*this.raw)) +} +func Touch.GetLocation() => Vec2 { + return Vec2FromValue(touch_get_location(*this.raw)) +} +func Touch.GetWorldLocation() => Vec2 { + return Vec2FromValue(touch_get_world_location(*this.raw)) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/vertex_color.wa b/Tools/dora-wa/vendor/dora/vertex_color.wa index 7d2ce24e4..fe607ed11 100644 --- a/Tools/dora-wa/vendor/dora/vertex_color.wa +++ b/Tools/dora-wa/vendor/dora/vertex_color.wa @@ -17,4 +17,40 @@ func vertexcolor_set_color(slf: i64, val: i32); #wa:import dora vertexcolor_get_color func vertexcolor_get_color(slf: i64) => i32 #wa:import dora vertexcolor_new -func vertexcolor_new(vec: i64, color: i32) => i64 \ No newline at end of file +func vertexcolor_new(vec: i64, color: i32) => i64 +type VertexColor struct { raw: *i64 } +func VertexColor.GetRaw() => i64 { + return *this.raw +} +func vertex_color_finalizer(ptr: u32) { + vertexcolor_release(GetPtr(ptr)) +} +func VertexColorFrom(raw: i64) => *VertexColor { + if raw == 0 { + return nil + } + item := VertexColor{} + item.raw = &raw + setFinalizer(item.raw, vertex_color_finalizer) + result := &item + return result +} +func VertexColor.SetVertex(val: Vec2) { + vertexcolor_set_vertex(*this.raw, val.ToValue()) +} +func VertexColor.GetVertex() => Vec2 { + return Vec2FromValue(vertexcolor_get_vertex(*this.raw)) +} +func VertexColor.SetColor(val: Color) { + vertexcolor_set_color(*this.raw, val.ToARGB()) +} +func VertexColor.GetColor() => Color { + return ColorFromARGB(vertexcolor_get_color(*this.raw)) +} +func NewVertexColor(vec: Vec2, color: Color) => VertexColor { + raw := vertexcolor_new(vec.ToValue(), color.ToARGB()) + object := VertexColor{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/vgnode.wa b/Tools/dora-wa/vendor/dora/vgnode.wa index 95b8ea181..8335d31a8 100644 --- a/Tools/dora-wa/vendor/dora/vgnode.wa +++ b/Tools/dora-wa/vendor/dora/vgnode.wa @@ -13,4 +13,34 @@ func vgnode_get_surface(slf: i64) => i64 #wa:import dora vgnode_render func vgnode_render(slf: i64, func0: i32) #wa:import dora vgnode_new -func vgnode_new(width: f32, height: f32, scale: f32, edge_aa: i32) => i64 \ No newline at end of file +func vgnode_new(width: f32, height: f32, scale: f32, edge_aa: i32) => i64 +type VGNode struct { Node } +func VGNodeFrom(raw: i64) => *VGNode { + if raw == 0 { + return nil + } + object := VGNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func VGNode.GetTypeId() => i32 { + return vgnode_type() +} +func VGNode.GetSurface() => Sprite { + return *SpriteFrom(vgnode_get_surface(*this.raw)) +} +func VGNode.Render(render_func: func()) { + func_id0 := PushFunction(func() { + render_func() + }) + vgnode_render(*this.raw, func_id0) +} +func NewVGNode(width: f32, height: f32, scale: f32, edge_aa: i32) => VGNode { + raw := vgnode_new(width, height, scale, edge_aa) + object := VGNode{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/vgpaint.wa b/Tools/dora-wa/vendor/dora/vgpaint.wa index 38521e349..376617d61 100644 --- a/Tools/dora-wa/vendor/dora/vgpaint.wa +++ b/Tools/dora-wa/vendor/dora/vgpaint.wa @@ -7,4 +7,21 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #wa:import dora vgpaint_release -func vgpaint_release(raw: i64) \ No newline at end of file +func vgpaint_release(raw: i64) +type VGPaint struct { raw: *i64 } +func VGPaint.GetRaw() => i64 { + return *this.raw +} +func v_g_paint_finalizer(ptr: u32) { + vgpaint_release(GetPtr(ptr)) +} +func VGPaintFrom(raw: i64) => *VGPaint { + if raw == 0 { + return nil + } + item := VGPaint{} + item.raw = &raw + setFinalizer(item.raw, v_g_paint_finalizer) + result := &item + return result +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/view.wa b/Tools/dora-wa/vendor/dora/view.wa index b0420f773..82f4843f3 100644 --- a/Tools/dora-wa/vendor/dora/view.wa +++ b/Tools/dora-wa/vendor/dora/view.wa @@ -37,4 +37,59 @@ func view_set_post_effect_null() #wa:import dora view_set_vsync func view_set_vsync(val: i32) #wa:import dora view_is_vsync -func view_is_vsync() => i32 \ No newline at end of file +func view_is_vsync() => i32 +type _View struct { } +global View = _View{} +func _View.GetSize() => Size { + return SizeFromValue(view_get_size()) +} +func _View.GetStandardDistance() => f32 { + return view_get_standard_distance() +} +func _View.GetAspectRatio() => f32 { + return view_get_aspect_ratio() +} +func _View.SetNearPlaneDistance(val: f32) { + view_set_near_plane_distance(val) +} +func _View.GetNearPlaneDistance() => f32 { + return view_get_near_plane_distance() +} +func _View.SetFarPlaneDistance(val: f32) { + view_set_far_plane_distance(val) +} +func _View.GetFarPlaneDistance() => f32 { + return view_get_far_plane_distance() +} +func _View.SetFieldOfView(val: f32) { + view_set_field_of_view(val) +} +func _View.GetFieldOfView() => f32 { + return view_get_field_of_view() +} +func _View.SetScale(val: f32) { + view_set_scale(val) +} +func _View.GetScale() => f32 { + return view_get_scale() +} +func _View.SetPostEffect(val: SpriteEffect) { + view_set_post_effect(val.GetRaw()) +} +func _View.GetPostEffect() => *SpriteEffect { + ptr_ := view_get_post_effect() + if ptr_ == 0 { + return nil + } + obj_ := *SpriteEffectFrom(ptr_) + return &obj_ +} +func _View.SetPostEffectNull() { + view_set_post_effect_null() +} +func _View.SetVsync(val: bool) { + view_set_vsync(ToDoraBool(val)) +} +func _View.IsVsync() => bool { + return view_is_vsync() != 0 +} \ No newline at end of file