├── .gitignore ├── .travis.yml ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── lib ├── clibpp.nim └── macroutils.nim ├── macros ├── bpasync.nim ├── uedelegate.nim └── uetypes.nim ├── modules ├── core │ ├── actor.nim │ ├── ai │ │ └── navigationtypes.nim │ ├── animation.nim │ ├── camera │ │ ├── anim.nim │ │ ├── shake.nim │ │ └── types.nim │ ├── canvas.nim │ ├── character.nim │ ├── commandlet.nim │ ├── commandline.nim │ ├── components │ │ ├── actor.nim │ │ ├── audio.nim │ │ ├── billboard.nim │ │ ├── brush.nim │ │ ├── camera.nim │ │ ├── capsule.nim │ │ ├── charactermovement.nim │ │ ├── childactor.nim │ │ ├── componentdecls.nim │ │ ├── curves.nim │ │ ├── drawfrustum.nim │ │ ├── input.nim │ │ ├── mesh.nim │ │ ├── movement.nim │ │ ├── navmovement.nim │ │ ├── particlesystem.nim │ │ ├── pathfollowing.nim │ │ ├── pawnmovement.nim │ │ ├── pawnnoiseemitter.nim │ │ ├── primitive.nim │ │ ├── scene.nim │ │ ├── shape.nim │ │ ├── skeletalmesh.nim │ │ ├── skinnedmesh.nim │ │ ├── sphere.nim │ │ ├── springarm.nim │ │ ├── staticmesh.nim │ │ ├── textrender.nim │ │ └── timeline.nim │ ├── consolemanager.nim │ ├── containers │ │ ├── array.nim │ │ ├── attribute.nim │ │ ├── enumasbyte.nim │ │ ├── map.nim │ │ ├── optional.nim │ │ ├── refcountptr.nim │ │ ├── set.nim │ │ ├── sharedptr.nim │ │ ├── subclassof.nim │ │ └── weakptr.nim │ ├── controller.nim │ ├── core │ │ ├── globals.nim │ │ ├── hal │ │ │ ├── genericplatformfile.nim │ │ │ ├── genericplatformmisc.nim │ │ │ └── platformfilemanager.nim │ │ ├── object.nim │ │ ├── player.nim │ │ └── timermanager.nim │ ├── coremodule.nim │ ├── defaultpawn.nim │ ├── engine │ │ ├── brush.nim │ │ ├── engine.nim │ │ ├── hud.nim │ │ ├── material.nim │ │ ├── physicsvolume.nim │ │ ├── staticmeshactor.nim │ │ ├── texture.nim │ │ └── volume.nim │ ├── enginetypes.nim │ ├── gamemode.nim │ ├── gameplayutils.nim │ ├── gamestate.nim │ ├── gameusersettings.nim │ ├── info.nim │ ├── input │ │ └── inputcoretypes.nim │ ├── internationalization.nim │ ├── kismet │ │ ├── blueprintasyncactionbase.nim │ │ └── gameplaystatics.nim │ ├── level.nim │ ├── logging.nim │ ├── math │ │ ├── box.nim │ │ ├── box2d.nim │ │ ├── math.nim │ │ └── transformcalculus2d.nim │ ├── misc.nim │ ├── net │ │ ├── connection.nim │ │ └── nettypes.nim │ ├── paths.nim │ ├── pawn.nim │ ├── perfstats.nim │ ├── physics │ │ └── types.nim │ ├── playercameramanager.nim │ ├── playercontroller.nim │ ├── playerinput.nim │ ├── playerstate.nim │ ├── sceneinterface.nim │ ├── slate │ │ ├── arrangedwidget.nim │ │ ├── cursorreply.nim │ │ ├── curvesequence.nim │ │ ├── enums.nim │ │ ├── events.nim │ │ ├── hittestgrid.nim │ │ ├── itooltip.nim │ │ ├── margin.nim │ │ ├── navigationreply.nim │ │ ├── popupmethodreply.nim │ │ ├── reply.nim │ │ ├── replybase.nim │ │ ├── sboxpanel.nim │ │ ├── scompoundwidget.nim │ │ ├── slate.nim │ │ ├── slateapplication.nim │ │ ├── slateapplicationbase.nim │ │ ├── slatecolor.nim │ │ ├── slatelayouttransform.nim │ │ ├── slatetypes.nim │ │ ├── slatewidgetstyle.nim │ │ ├── slotbase.nim │ │ ├── soverlay.nim │ │ ├── structs.nim │ │ ├── swidgetswitcher.nim │ │ ├── swindow.nim │ │ ├── virtualkeyboardentry.nim │ │ ├── visibility.nim │ │ ├── widget.nim │ │ └── widgetcaching.nim │ ├── sound │ │ └── base.nim │ ├── spectatorpawn.nim │ ├── strings.nim │ ├── touchinterface.nim │ ├── world.nim │ └── worldsettings.nim ├── editor │ ├── editor.nim │ └── editormodule.nim ├── gamemenubuilder │ ├── gamemenubuilder.nim │ ├── gamemenubuildermodule.nim │ ├── gamemenupage.nim │ └── gamemenupagewidget.nim └── umg │ ├── anchors.nim │ ├── button.nim │ ├── canvaspanelslot.nim │ ├── contentwidget.nim │ ├── image.nim │ ├── panelslot.nim │ ├── panelwidget.nim │ ├── propertybinding.nim │ ├── slatewrappertypes.nim │ ├── sobjectwidget.nim │ ├── umgmodule.nim │ ├── userwidget.nim │ ├── widget.nim │ ├── widgetnavigation.nim │ ├── widgettransform.nim │ └── widgettree.nim ├── stubs ├── .vscode │ ├── settings.json │ └── tasks.json ├── build.cmd ├── build.sh └── config.nims ├── tools └── uebuild │ ├── nimfiles │ └── NimGameEngine.nim │ ├── uebuild.nim │ └── usage.txt ├── ue4.nim ├── ue4.nim.cfg ├── ue4editor.nim ├── ue4editor.nim.cfg ├── ue4gamemenubuilder.nim ├── ue4gamemenubuilder.nim.cfg ├── ue4umg.nim └── ue4umg.nim.cfg /.gitignore: -------------------------------------------------------------------------------- 1 | nimcache 2 | nimsuggest.log 3 | .DS_Store 4 | tools/uebuild/uebuild 5 | tools/uebuild/uebuild\.exe 6 | 7 | *.ilk 8 | *.pdb 9 | 10 | .vscode/.browse* 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: c 3 | os: 4 | - linux 5 | install: 6 | - git clone https://github.com/nim-lang/Nim.git 7 | - cd Nim 8 | - git checkout devel 9 | - sh ci/build.sh 10 | - cd .. 11 | 12 | before_script: 13 | - git clone https://github.com/pragmagic/NimPlatformerGame.git 14 | - export PATH="`pwd`/Nim/bin":$PATH 15 | - export NIMUE_HOME="`pwd`" 16 | - export NIM_HOME="`pwd`/Nim/" 17 | - export UE4_HOME=/Not/Used/Anyway 18 | - set -e 19 | 20 | script: 21 | - cd NimPlatformerGame 22 | - nim compilenim 23 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "editor.tabSize": 2, 4 | "editor.rulers": [120], 5 | "editor.insertSpaces": true, 6 | "editor.detectIndentation": false, 7 | "files.eol": "\n", 8 | "files.trimTrailingWhitespace": true, 9 | "nim.project": ["ue4.nim", "ue4umg.nim", "ue4gamemenubuilder", "ue4editor"], 10 | "nim.buildCommand": "cpp", 11 | "nim.licenseString": "# Copyright 2016 Xored Software, Inc.\n\n" 12 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | nimue4 - Nim programming language integration for UE4 2 | 3 | The MIT License 4 | 5 | Copyright (c) 2016 Xored Software Inc. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 8 | associated documentation files (the "Software"), to deal in the Software without restriction, 9 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all copies or substantial 14 | portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 17 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH 20 | THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | The Software makes use of or includes portions of: 23 | 24 | 1. Nim programming language (https://github.com/nim-lang/Nim/). Licensed under the MIT License. Copyright (c) 2006-2016 Andreas Rumpf. 25 | 2. clibpp library (https://github.com/onionhammer/clibpp). Licensed under the MIT License. Copyright (c) 2014 onionhammer. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nim Integration for Unreal Engine 4 [![Build Status](https://travis-ci.org/pragmagic/nimue4.svg?branch=master)](https://travis-ci.org/pragmagic/nimue4) 2 | 3 | This repo contains Nim library and tools that allow to create Unreal Engine 4 games on [Nim programming language](http://nim-lang.org/). 4 | 5 | 6 | The integration is in early development, so breaking changes are possible - backward compatibility is not guaranteed yet. 7 | 8 | 9 | This integration is being used by an indie development team to create a mobile strategy game. That game runs on iOS, Android, Windows and Mac. 10 | 11 | ## Why Nim? 12 | 13 | Nim is a native programming language that allows excellent programming productivity while not sacrificing the application's performance. It compiles directly into C++, so almost all the features UE4 provides can be made available in Nim. 14 | 15 | 16 | Nim's syntax and semantics are simple and elegant, so Nim can be easily taught to scripters in game development teams. Nim also has rich support for meta-programming, allowing you to extend capabilities of Nim, which is great for the variety of domains a game developer usually encounters. 17 | 18 | ## Features 19 | 20 | * Gameplay programming (most of the basic classes are available, more wrappers coming soon) 21 | * Blueprint support 22 | * Delegate declaration and usage support 23 | * Support for UProperty and UFunction macros and their specifiers 24 | 25 | The integration lacks support for: 26 | 27 | * Creating editor extensions (coming soon) 28 | * Creating Unreal plug-ins with Nim 29 | * Debugging Nim code directly. But since Nim functions map to C++ functions clearly, you can use existing C++ debugging and profiling tools. 30 | 31 | ## Getting Started 32 | 33 | See the [Getting Started](https://github.com/pragmagic/nimue4/wiki/Getting-Started) page on the wiki. 34 | 35 | If you are new to Nim, make sure to see the [Learn section](http://nim-lang.org/learn.html) of the Nim's website. 36 | 37 | See [NimPlatformerGame](https://github.com/pragmagic/NimPlatformerGame) repo for a sample of a game written on Nim. 38 | 39 | ## Documentation 40 | 41 | See the repo's [wiki](https://github.com/pragmagic/nimue4/wiki/) for nimue4 documentation. 42 | 43 | See the Nim website's [documentation section](http://nim-lang.org/documentation.html) for the Nim language documentation. 44 | 45 | ## Community 46 | [![Join Nim Gitter channel](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/nim-lang/Nim) 47 | 48 | If you have any questions or feedback for nimue4, feel free to submit an issue on GitHub. 49 | 50 | * [Gitter](https://gitter.im/nim-lang/Nim) - you can discuss Nim and nimue4 here in real-time. 51 | * The [Nim forum](http://forum.nim-lang.org/) - a place where you can ask questions and discuss Nim. 52 | 53 | ## Roadmap 54 | 55 | High priority roadmap items include: 56 | 57 | * Automated generation of wrappers for UE4 types 58 | * UE4 plug-in that improves editor experience when working with Nim projects 59 | 60 | ## License 61 | 62 | This project is licensed under the MIT license. Read [LICENSE](https://github.com/pragmagic/nimue4/blob/master/LICENSE) file for details. 63 | 64 | Copyright (c) 2016 Xored Software, Inc. 65 | -------------------------------------------------------------------------------- /macros/bpasync.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Xored Software, Inc. 2 | 3 | import macros, strutils 4 | import "../lib/macroutils" 5 | import uetypes, uedelegate 6 | 7 | macro blueprintAsync*(function: untyped): untyped = 8 | function.expectKind(nnkProcDef) 9 | let category = function.removeStrPragma("category") 10 | if category == nil: 11 | parseError(function, "blueprint function must have .category pragma") 12 | 13 | function.expectKind(nnkProcDef) 14 | function.params.expectMinLen(1) 15 | function.params[0].expectKind(nnkBracketExpr) 16 | if not function.params[0][0].eqIdent("Future"): 17 | parseError(function, "Return type must be Future[T]") 18 | 19 | let procName = $(extractIdent(function.name).ident) 20 | let returnType = function.params[0][1] 21 | var procArgs = newSeq[(NimNode, NimNode)]() 22 | # will be seq of (argNameNode, argTypeNode) 23 | for node in function.params: 24 | if node.kind == nnkIdentDefs: 25 | let argType = node[^2] 26 | for i in 0..Loop->Loop->Loop.... but when you want it to end, you can relink 35 | ## next section of Loop to be End to finish the montage, in which case, it stops looping by Loop->End. 36 | ## @param SectionNameToChange : This should be the name of the Montage Section after which you want to insert a new next section 37 | ## @param NextSection : new next section 38 | 39 | proc montage_SetPlayRate(montage: ptr UAnimMontage, newPlayRate: cfloat = 1.0'f32) 40 | ## Change AnimMontage play rate. NewPlayRate = 1.0 is the default playback rate. 41 | 42 | proc montage_IsActive(montage: ptr UAnimMontage): bool 43 | ## Returns true if the animation montage is active. If the Montage reference is NULL, it will return true if any Montage is active. 44 | 45 | proc montage_IsPlaying(montage: ptr UAnimMontage): bool 46 | ## Returns true if the animation montage is currently active and playing. 47 | ## If reference is NULL, it will return true is ANY montage is currently active and playing. 48 | 49 | proc montage_GetCurrentSection(montage: ptr UAnimMontage): FName 50 | ## Returns the name of the current animation montage section. 51 | 52 | var onMontageBlendingOut: FOnMontageBlendingOutStartedMCDelegate 53 | ## Called when a montage starts blending out, whether interrupted or finished 54 | 55 | var onMontageStarted: FOnMontageStartedMCDelegate 56 | ## Called when a montage has started 57 | 58 | var onMontageEnded: FOnMontageEndedMCDelegate 59 | ## Called when a montage has ended, whether interrupted or finished 60 | 61 | # TODO 62 | 63 | wclass(UAnimSequenceBase of UAnimationAsset, header: "Animation/AnimSequenceBase.h", notypedef): 64 | method getPlayLength(): cfloat 65 | #Returns the total play length of the montage, if played back with a speed of 1.0. -------------------------------------------------------------------------------- /modules/core/camera/anim.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UCameraAnim of UObject, header: "Camera/CameraAnim.h"): 4 | ## A predefined animation to be played on a camera 5 | var cameraInterpGroup: ptr UInterpGroup 6 | ## The UInterpGroup that holds our actual interpolation data. 7 | #if WITH_EDITORONLY_DATA 8 | var previewInterpGroup: ptr UInterpGroup 9 | ## This is to preview and they only exists in editor 10 | #endif 11 | var animLength: cfloat 12 | ## Length, in seconds. 13 | var boundingBox: FBox 14 | ## AABB in local space. 15 | 16 | var bRelativeToInitialTransform: bool 17 | ## If true, assume all transform keys are intended be offsets from the start of the animation. This allows the animation to be authored at any world location and be applied as a delta to the camera. 18 | ## If false, assume all transform keys are authored relative to the world origin. Positions will be directly applied as deltas to the camera. 19 | 20 | var baseFOV: cfloat 21 | ## The FOV 22 | 23 | var basePostProcessSettings: FPostProcessSettings 24 | ## Default PP settings to put on the animated camera. For modifying PP without keyframes. 25 | 26 | var basePostProcessBlendWeight: cfloat 27 | ## Default PP blend weight to put on the animated camera. For modifying PP without keyframes. 28 | 29 | proc createFromInterpGroup(srcGroup: ptr UInterpGroup, inMatineeActor: ptr AMatineeActor): bool 30 | ## Construct a camera animation from an InterpGroup. The InterpGroup must control a CameraActor. 31 | ## Used by the editor to "export" a camera animation from a normal Matinee scene. 32 | 33 | proc getAABB(baseLoc: FVector, baseRot: FRotator, scale: cfloat): FBox {.noSideEffect.} 34 | ## Gets AABB of the camera's path. Useful for rough testing if you can play an animation at a certain 35 | ## location in the world without penetrating geometry. 36 | ## @return Returns the local-space axis-aligned bounding box of the entire motion of this animation. 37 | -------------------------------------------------------------------------------- /modules/core/camera/shake.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UCameraShake of UObject, header: "Camera/CameraShake.h"): 4 | discard 5 | 6 | # TODO -------------------------------------------------------------------------------- /modules/core/camera/types.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | ECameraProjectionMode {.header: "Camera/CameraTypes.h", importcpp: "ECameraProjectionMode::Type"} = enum 5 | Perspective, 6 | Orthographic 7 | 8 | ECameraAnimPlaySpace {.header: "Camera/CameraTypes.h", importcpp: "ECameraAnimPlaySpace".} = enum 9 | CameraLocal, ## This anim is applied in camera space. 10 | World, ## This anim is applied in world space. 11 | UserDefined, ## This anim is applied in a user-specified space (defined by UserPlaySpaceMatrix). 12 | 13 | wclass(FMinimalViewInfo, header: "Camera/CameraTypes.h", bycopy): 14 | var location: FVector 15 | ## Location 16 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Camera) 17 | var rotation: FRotator 18 | ## Rotation 19 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Camera) 20 | var FOV: cfloat 21 | ## The field of view (in degrees) in perspective mode (ignored in Orthographic mode) 22 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Camera) 23 | var orthoWidth: cfloat 24 | ## The desired width (in world units) of the orthographic view (ignored in Perspective mode) 25 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Camera) 26 | var orthoNearClipPlane: cfloat 27 | ## The near plane distance of the orthographic view (in world units) 28 | ## UPROPERTY(Interp, EditAnywhere, BlueprintReadWrite, Category=Camera) 29 | var orthoFarClipPlane: cfloat 30 | ## The far plane distance of the orthographic view (in world units) 31 | ## UPROPERTY(Interp, EditAnywhere, BlueprintReadWrite, Category=Camera) 32 | var aspectRatio: cfloat 33 | ## Aspect Ratio (Width/Height); ignored unless bConstrainAspectRatio is true 34 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Camera) 35 | var bConstrainAspectRatio: bool 36 | ## If bConstrainAspectRatio is true, black bars will be added if the destination view has a different aspect ratio than this camera requested. 37 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Camera) 38 | var bUseFieldOfViewForLOD: bool 39 | ## If true, account for the field of view angle when computing which level of detail to use for meshes. 40 | ## UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadWrite, Category=CameraSettings) 41 | var projectionMode: ECameraProjectionMode 42 | ## The type of camera 43 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Camera) 44 | var postProcessBlendWeight: cfloat 45 | ## Indicates if PostProcessSettings should be applied. 46 | ## UPROPERTY(BlueprintReadWrite, Category = Camera) 47 | var postProcessSettings: FPostProcessSettings 48 | ## Post-process settings to use if PostProcessBlendWeight is non-zero. 49 | ## UPROPERTY(BlueprintReadWrite, Category = Camera) 50 | 51 | proc equals(otherInfo: FMinimalViewInfo): bool {.noSideEffect.} 52 | ## Is this equivalent to the other one? 53 | 54 | proc blendViewInfo(otherInfo: FMinimalViewInfo, otherWeight: cfloat) 55 | ## Blends view information 56 | ## Note: booleans are orred together, instead of blending 57 | 58 | proc applyBlendWeight(weight: cfloat) 59 | ## Applies weighting to this view, in order to be blended with another one. Equals to this *= Weight. 60 | 61 | proc addWeightedViewInfo(otherView: FMinimalViewInfo, weight: cfloat) 62 | ## Combines this view with another one which will be weighted. Equals to this += OtherView * Weight. 63 | 64 | # proc calculateProjectionMatrixGivenView*(viewInfo: FMinimalViewInfo, aspectRatioAxisConstraint: EAspectRatioAxisConstraint, 65 | # viewport: FViewport, inOutProjectionData: FSceneViewProjectionData) 66 | # ## Calculates the projection matrix (and potentially a constrained view rectangle) given a FMinimalViewInfo and partially configured projection data (must have the view rect already set) 67 | 68 | 69 | # TODO 70 | -------------------------------------------------------------------------------- /modules/core/commandlet.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Xored Software, Inc. 2 | 3 | wclass(UCommandlet of UObject, header: "Commandlets/Commandlet.h", notypedef): 4 | proc main(params: FString): int32 5 | ## Entry point for your commandlet 6 | ## @params - the string containing the parameters for the commandlet -------------------------------------------------------------------------------- /modules/core/commandline.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | proc getCommandLine*(): wstring {. 4 | importcpp: "FCommandLine::Get()", header: "Misc/CommandLine.h".} 5 | ## Returns an edited version of the executable's command line with the game name and certain other parameters removed. -------------------------------------------------------------------------------- /modules/core/components/billboard.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UBillboardComponent of UPrimitiveComponent, header: "Components/BillboardComponent.h", notypedef): 4 | ## A 2d texture that will be rendered always facing the camera. 5 | ## UCLASS(ClassGroup=Rendering, collapsecategories, 6 | ## hidecategories=(Object,Activation,"Components|Activation",Physics,Collision,Lighting,Mesh,PhysicsVolume), 7 | ## editinlinenew, meta=(BlueprintSpawnableComponent)) 8 | 9 | var sprite: ptr UTexture2D 10 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Sprite) 11 | 12 | var bIsScreenSizeScaled: bool 13 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Sprite) 14 | 15 | var screenSize: cfloat 16 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Sprite) 17 | 18 | var U: cfloat 19 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Sprite) 20 | 21 | var UL: cfloat 22 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Sprite) 23 | 24 | var V: cfloat 25 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Sprite) 26 | 27 | var VL: cfloat 28 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Sprite) 29 | 30 | #if WITH_EDITORONLY_DATA 31 | var spriteInfo: FSpriteCategoryInfo 32 | ## Sprite category information regarding the component 33 | ## UPROPERTY() 34 | 35 | var bUseInEditorScaling: bool 36 | ## Whether to use in-editor arrow scaling (i.e. to be affected by the global arrow scale) 37 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Sprite) 38 | #endif // WITH_EDITORONLY_DATA 39 | 40 | 41 | method setSprite(newSprite: ptr UTexture2D) 42 | ## Change the sprite texture used by this component 43 | ## UFUNCTION(BlueprintCallable, Category="Rendering|Components|Sprite") 44 | 45 | method setUV(newU, newUL, newV, newVL: int32) 46 | ## Change the sprite's UVs 47 | ## UFUNCTION(BlueprintCallable, Category="Rendering|Components|Sprite") 48 | 49 | method setSpriteAndUV(newSprite: ptr UTexture2D; newU, newUL, newV, newVL: int32) 50 | ## Change the sprite texture and the UV's used by this component 51 | ## UFUNCTION(BlueprintCallable, Category="Rendering|Components|Sprite") 52 | 53 | #if WITH_EDITORONLY_DATA 54 | proc setEditorScale(inEditorScale: cfloat) {.isStatic.} 55 | ## Set the scale that we use when rendering in-editor 56 | 57 | var EditorScale {.isStatic.}: cfloat 58 | ## The scale we use when rendering in-editor 59 | #endif 60 | -------------------------------------------------------------------------------- /modules/core/components/brush.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UBrushComponent of UPrimitiveComponent, header: "Components/BrushComponent.h", notypedef): 4 | ## A brush component defines a shape that can be modified within the editor. They are used both as part of BSP building, and for volumes. 5 | ## @see https://docs.unrealengine.com/latest/INT/Engine/Actors/Volumes 6 | ## @see https://docs.unrealengine.com/latest/INT/Engine/Actors/Brushes 7 | 8 | var brush: ptr UModel 9 | var brushBodySetup: ptr UBodySetup 10 | ## Description of collision 11 | 12 | #if WITH_EDITOR 13 | proc requestUpdateBrushCollision() 14 | ## If the transform mirroring no longer reflects the body setup, request its recalculation 15 | #endif 16 | 17 | proc buildSimpleBrushCollision() 18 | ## Create the AggGeom collection-of-convex-primitives from the Brush UModel data. 19 | -------------------------------------------------------------------------------- /modules/core/components/camera.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UCameraComponent of USceneComponent, header: "Camera/CameraComponent.h", notypedef): 4 | ## Represents a camera viewpoint and settings, such as projection type, field of view, and post-process overrides. 5 | ## The default behavior for an actor used as the camera view target is 6 | ## to look for an attached camera component and use its location, rotation, and settings. 7 | var fieldOfView: cfloat 8 | ## The horizontal field of view (in degrees) in perspective mode (ignored in Orthographic mode) 9 | ## UPROPERTY(Interp, EditAnywhere, BlueprintReadWrite, Category=CameraSettings, 10 | ## meta=(UIMin = "5.0", UIMax = "170", ClampMin = "0.001", ClampMax = "360.0")) 11 | 12 | var orthoWidth: cfloat 13 | ## The desired width (in world units) of the orthographic view (ignored in Perspective mode) 14 | ## UPROPERTY(Interp, EditAnywhere, BlueprintReadWrite, Category=CameraSettings) 15 | 16 | var orthoNearClipPlane: cfloat 17 | ## The near plane distance of the orthographic view (in world units) 18 | ## UPROPERTY(Interp, EditAnywhere, BlueprintReadWrite, Category=CameraSettings) 19 | 20 | var orthoFarClipPlane: cfloat 21 | ## The far plane distance of the orthographic view (in world units) 22 | ## UPROPERTY(Interp, EditAnywhere, BlueprintReadWrite, Category=CameraSettings) 23 | 24 | var aspectRatio: cfloat 25 | ## Aspect Ratio (Width/Height) 26 | ## UPROPERTY(Interp, EditAnywhere, BlueprintReadWrite, Category=CameraSettings, 27 | ## meta=(ClampMin = "0.1", ClampMax = "100.0", EditCondition="bConstrainAspectRatio")) 28 | 29 | var bConstrainAspectRatio: bool 30 | ## If bConstrainAspectRatio is true, black bars will be added if the destination view has 31 | ## a different aspect ratio than this camera requested. 32 | ## UPROPERTY(Interp, EditAnywhere, BlueprintReadWrite, Category=CameraSettings) 33 | 34 | var bUseFieldOfViewForLOD: bool 35 | ## If true, account for the field of view angle when computing which level of detail to use for meshes. 36 | ## UPROPERTY(Interp, EditAnywhere, AdvancedDisplay, BlueprintReadWrite, Category=CameraSettings) 37 | 38 | var bUsePawnControlRotation: bool 39 | ## If this camera component is placed on a pawn, should it use the view/control rotation of the pawn where possible? 40 | ## @see APawn::GetViewRotation() 41 | ## 42 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=CameraSettings) 43 | 44 | var projectionMode: ECameraProjectionMode 45 | ## The type of camera 46 | ## UPROPERTY(Interp, EditAnywhere, BlueprintReadWrite, Category=CameraSettings) 47 | 48 | var postProcessBlendWeight: cfloat 49 | ## Indicates if PostProcessSettings should be used when using this Camera to view through. 50 | ## UPROPERTY(Interp, EditAnywhere, BlueprintReadWrite, Category=CameraSettings, meta=(UIMin = "0.0", UIMax = "1.0")) 51 | 52 | var postProcessSettings: FPostProcessSettings 53 | ## Post process settings to use for this camera. Don't forget to check the properties you want to override 54 | ## UPROPERTY(Interp, BlueprintReadWrite, Category=CameraSettings) 55 | 56 | proc getCameraView(deltaTime: cfloat; desiredView: var FMinimalViewInfo) 57 | ## Returns camera's Point of View. 58 | ## Called by Camera class. Subclass and postprocess to add any effects. 59 | ## 60 | ## UFUNCTION(BlueprintCallable, Category=Camera) 61 | 62 | proc addOrUpdateBlendable(inBlendableObject: ptr IBlendableInterface; 63 | inWeight: cfloat = 1.0) 64 | ## Adds an Blendable (implements IBlendableInterface) to the array of Blendables (if it doesn't exist) and update the weight 65 | ## UFUNCTION(BlueprintCallable, Category="Rendering") 66 | 67 | #protected: 68 | 69 | #if WITH_EDITORONLY_DATA: 70 | var drawFrustum: ptr UDrawFrustumComponent 71 | ## The frustum component used to show visually where the camera field of view is 72 | ## UPROPERTY(transient) 73 | 74 | var cameraMesh: ptr UStaticMesh 75 | ## UPROPERTY(transient) 76 | var proxyMeshComponent: ptr UStaticMeshComponent 77 | ## The camera mesh to show visually where the camera is placed 78 | ## UPROPERTY(transient) 79 | 80 | # public: 81 | proc setCameraMesh(mesh: ptr UStaticMesh) 82 | #endif // WITH_EDITORONLY_DATA 83 | 84 | #if WITH_EDITORONLY_DATA 85 | proc refreshVisualRepresentation() 86 | ## Refreshes the visual components to match the component state 87 | proc overrideFrustumColor(overrideColor: FColor) 88 | proc restoreFrustumColor() 89 | #endif -------------------------------------------------------------------------------- /modules/core/components/capsule.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UCapsuleComponent of UShapeComponent, header: "Components/CapsuleComponent.h", notypedef): 4 | ## A capsule generally used for simple collision. Bounds are rendered as lines in the editor. 5 | proc setCapsuleSize(inRadius: cfloat; inHalfHeight: cfloat; 6 | bUpdateOverlaps: bool = true) 7 | ## Change the capsule size. This is the unscaled size, before component scale is applied. 8 | ## @param InRadius : radius of end-cap hemispheres and center cylinder. 9 | ## @param InHalfHeight : half-height, from capsule center to end of top or bottom hemisphere. 10 | ## @param bUpdateOverlaps: if true and this shape is registered and collides, updates touching array for owner actor. 11 | ## 12 | ## UFUNCTION(BlueprintCallable, Category="Components|Capsule") 13 | 14 | proc setCapsuleRadius(radius: cfloat; bUpdateOverlaps: bool = true) 15 | ## Set the capsule radius. This is the unscaled radius, before component scale is applied. 16 | ## If this capsule collides, updates touching array for owner actor. 17 | ## @param Radius : radius of end-cap hemispheres and center cylinder. 18 | ## @param bUpdateOverlaps: if true and this shape is registered and collides, updates touching array for owner actor. 19 | ## 20 | ## UFUNCTION(BlueprintCallable, Category="Components|Capsule") 21 | 22 | proc setCapsuleHalfHeight(halfHeight: cfloat; bUpdateOverlaps: bool = true) 23 | ## Set the capsule half-height. This is the unscaled half-height, before component scale is applied. 24 | ## If this capsule collides, updates touching array for owner actor. 25 | ## @param HalfHeight : half-height, from capsule center to end of top or bottom hemisphere. 26 | ## @param bUpdateOverlaps: if true and this shape is registered and collides, updates touching array for owner actor. 27 | ## 28 | ## UFUNCTION(BlueprintCallable, Category="Components|Capsule") 29 | 30 | proc getScaledCapsuleRadius(): cfloat {.noSideEffect.} 31 | ## @return the capsule radius scaled by the component scale. 32 | ## UFUNCTION(BlueprintCallable, Category="Components|Capsule") 33 | 34 | proc getScaledCapsuleHalfHeight(): cfloat {.noSideEffect.} 35 | ## @return the capsule half height scaled by the component scale. 36 | ## UFUNCTION(BlueprintCallable, Category="Components|Capsule") 37 | 38 | proc getScaledCapsuleSize(outRadius: var cfloat; outHalfHeight: var cfloat) {. 39 | noSideEffect.} 40 | ## @return the capsule radius and half height scaled by the component scale. 41 | ## UFUNCTION(BlueprintCallable, Category="Components|Capsule") 42 | 43 | proc getUnscaledCapsuleRadius(): cfloat {.noSideEffect.} 44 | ## @return the capsule radius, ignoring component scaling. 45 | ## UFUNCTION(BlueprintCallable, Category="Components|Capsule") 46 | 47 | proc getUnscaledCapsuleHalfHeight(): cfloat {.noSideEffect.} 48 | ## @return the capsule half height, ignoring component scaling. 49 | ## UFUNCTION(BlueprintCallable, Category="Components|Capsule") 50 | 51 | proc getUnscaledCapsuleSize(outRadius: var cfloat; outHalfHeight: var cfloat) {. 52 | noSideEffect.} 53 | ## @return the capsule radius and half height, ignoring component scaling. 54 | ## UFUNCTION(BlueprintCallable, Category="Components|Capsule") 55 | 56 | proc getShapeScale(): cfloat {.noSideEffect.} 57 | ## Get the scale used by this shape. This is a uniform scale that is the minimum of any non-uniform scaling. 58 | ## @return the scale used by this shape. 59 | ## UFUNCTION(BlueprintCallable, Category="Components|Capsule") 60 | 61 | proc initCapsuleSize(inRadius: cfloat; inHalfHeight: cfloat) 62 | ## Sets the capsule size without triggering a render or physics update. 63 | ## This is the preferred method when initializing a component in a class constructor. 64 | -------------------------------------------------------------------------------- /modules/core/components/childactor.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UChildActorComponent of USceneComponent, header: "Components/ChildActorComponent.h"): 4 | proc createChildActor() 5 | proc getChildActor(): ptr AActor {.noSideEffect.} 6 | proc getChildActorTemplate(): ptr AActor {.noSideEffect.} 7 | proc getChildActorName(): FName {.noSideEffect.} 8 | proc destroyChildActor() 9 | -------------------------------------------------------------------------------- /modules/core/components/curves.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Xored Software, Inc. 2 | 3 | wclass(UCurveVector of UCurveBase, header: "Curves/CurveVector.h", notypedef): 4 | 5 | proc getVectorValue(inTime: float32): FVector 6 | ## Evaluate this float curve at the specified time 7 | 8 | wclass(UCurveLinearColor of UCurveBase, header: "Curves/CurveLinearColor.h", notypedef): 9 | 10 | proc getLinearColorValue(inTime: float32): FLinearColor 11 | ## Evaluate this color curve at the specified time 12 | 13 | wclass(UCurveFloat of UCurveBase, header: "Curves/CurveFloat.h", notypedef): 14 | 15 | proc getFloatValue(inTime: float32): float32 16 | ## Evaluate this float curve at the specified time 17 | -------------------------------------------------------------------------------- /modules/core/components/drawfrustum.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UDrawFrustumComponent of UPrimitiveComponent, header:"Components/DrawFrustumComponent.h", notypedef): 4 | ## Utility component for drawing a view frustum. 5 | ## Origin is at the component location, frustum points down position X axis. 6 | ## UCLASS(collapsecategories, hidecategories=Object, editinlinenew, MinimalAPI) 7 | 8 | var frustumColor: FColor 9 | ## Color to draw the wireframe frustum. 10 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=DrawFrustumComponent) 11 | 12 | var frustumAngle: cfloat 13 | ## Angle of longest dimension of view shape. 14 | ## If the angle is 0 then an orthographic projection is used 15 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=DrawFrustumComponent) 16 | 17 | var frustumAspectRatio: cfloat 18 | ## Ratio of horizontal size over vertical size. 19 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=DrawFrustumComponent) 20 | 21 | var frustumStartDist: cfloat 22 | ## Distance from origin to start drawing the frustum. 23 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=DrawFrustumComponent) 24 | 25 | var frustumEndDist: cfloat 26 | ## Distance from origin to stop drawing the frustum. 27 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=DrawFrustumComponent) 28 | 29 | var texture: ptr UTexture 30 | ## optional texture to show on the near plane 31 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=DrawFrustumComponent) 32 | -------------------------------------------------------------------------------- /modules/core/components/mesh.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UMeshComponent of UPrimitiveComponent, header: "Components/MeshComponent.h", notypedef): 4 | 5 | method getMaterials(): TArray[ptr UMaterialInterface] -------------------------------------------------------------------------------- /modules/core/components/navmovement.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UNavMovementComponent of UMovementComponent, header: "GameFramework/NavMovementComponent.h", notypedef): 4 | ## NavMovementComponent defines base functionality for MovementComponents 5 | ## that move any 'agent' that may be involved in AI pathfinding. 6 | 7 | var navAgentProps: FNavAgentProperties 8 | ## Properties that define how the component can move. 9 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Movement Capabilities", meta=(DisplayName="Movement Capabilities", Keywords="Nav Agent")) 10 | 11 | var bUpdateNavAgentWithOwnersCollision: bool 12 | ## If set to true NavAgentProps' radius and height will be updated with Owner's collision capsule size 13 | ## UPROPERTY(EditAnywhere, Category=MovementComponent) 14 | 15 | var movementState: FMovementProperties 16 | ## Expresses runtime state of character's movement. Put all temporal changes to movement properties here 17 | ## UPROPERTY() 18 | 19 | var pathFollowingComp: TWeakObjectPtr[UPathFollowingComponent] 20 | ## Associated path following component 21 | 22 | method stopActiveMovement() 23 | ## Stops applying further movement (usually zeros acceleration). 24 | ## UFUNCTION(BlueprintCallable, Category="Pawn|Components|PawnMovement") 25 | 26 | proc stopMovementKeepPathing() 27 | ## Stops movement immediately (reset velocity) but keeps following current path 28 | ## UFUNCTION(BlueprintCallable, Category="Components|Movement") 29 | 30 | proc setUpdateNavAgentWithOwnersCollisions(bUpdateWithOwner: bool) 31 | 32 | proc shouldUpdateNavAgentWithOwnersCollision(): bool {.noSideEffect.} 33 | proc updateNavAgent(inOwner: AActor) 34 | proc updateNavAgent(capsuleComponent: UCapsuleComponent) 35 | 36 | proc getActorLocation(): FVector {.noSideEffect.} 37 | ## @returns location of controlled actor - meaning center of collision bounding box 38 | 39 | proc getActorFeetLocation(): FVector {.noSideEffect.} 40 | ## @returns location of controlled actor's "feet" meaning center of bottom of collision bounding box 41 | 42 | proc getActorFeetLocationBased(): FBasedPosition {.noSideEffect.} 43 | ## @returns based location of controlled actor 44 | 45 | method getActorNavLocation(): FVector {.noSideEffect.} 46 | ## @returns navigation location of controlled actor 47 | 48 | method requestDirectMove(moveVelocity: FVector; bForceMaxSpeed: bool) 49 | ## Request direct movement 50 | 51 | method canStopPathFollowing(): bool {.noSideEffect.} 52 | ## Check if current move target can be reached right now if positions are matching 53 | ## (e.g. performing scripted move and can't stop) 54 | 55 | proc getNavAgentPropertiesRef(): var FNavAgentProperties 56 | ## @returns the NavAgentProps 57 | 58 | proc resetMoveState() 59 | ## Resets runtime movement state to character's movement capabilities 60 | 61 | method canStartPathFollowing(): bool {.noSideEffect.} 62 | ## @return true if path following can start 63 | 64 | proc canEverCrouch(): bool {.noSideEffect.} 65 | ## @return true if component can crouch 66 | 67 | proc canEverJump(): bool {.noSideEffect.} 68 | ## @return true if component can jump 69 | 70 | proc canEverMoveOnGround(): bool {.noSideEffect.} 71 | ## @return true if component can move along the ground (walk, drive, etc) 72 | 73 | proc canEverSwim(): bool {.noSideEffect.} 74 | ## @return true if component can swim 75 | 76 | proc canEverFly(): bool {.noSideEffect.} 77 | ## @return true if component can fly 78 | 79 | proc isJumpAllowed(): bool {.noSideEffect.} 80 | ## @return true if component is allowed to jump 81 | 82 | proc setJumpAllowed(bAllowed: bool) 83 | ## @param bAllowed true if component is allowed to jump 84 | 85 | method isCrouching(): bool {.noSideEffect.} 86 | ## @return true if currently crouching 87 | ## UFUNCTION(BlueprintCallable, Category="AI|Components|NavMovement") 88 | 89 | method isFalling(): bool {.noSideEffect.} 90 | ## @return true if currently falling (not flying, in a non-fluid volume, and not on the ground) 91 | ## UFUNCTION(BlueprintCallable, Category="AI|Components|NavMovement") 92 | 93 | method isMovingOnGround(): bool {.noSideEffect.} 94 | ## @return true if currently moving on the ground (e.g. walking or driving) 95 | ## UFUNCTION(BlueprintCallable, Category="AI|Components|NavMovement") 96 | 97 | method isSwimming(): bool {.noSideEffect.} 98 | ## @return true if currently swimming (moving through a fluid volume) 99 | ## UFUNCTION(BlueprintCallable, Category="AI|Components|NavMovement") 100 | 101 | method isFlying(): bool {.noSideEffect.} 102 | ## @return true if currently flying (moving through a non-fluid volume without resting on the ground) 103 | ## UFUNCTION(BlueprintCallable, Category="AI|Components|NavMovement") -------------------------------------------------------------------------------- /modules/core/components/pathfollowing.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | # TODO 4 | -------------------------------------------------------------------------------- /modules/core/components/pawnmovement.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UPawnMovementComponent of UNavMovementComponent, header: "GameFramework/PawnMovementComponent.h", notypedef): 4 | ## PawnMovementComponent can be used to update movement for an associated Pawn. 5 | ## It also provides ways to accumulate and read directional input in a generic way (with AddInputVector(), ConsumeInputVector(), etc). 6 | ## @see APawn 7 | 8 | var pawnOwner: ptr APawn 9 | 10 | method addInputVector(worldVector: FVector; bForce: bool = false) 11 | ## Adds the given vector to the accumulated input in world space. Input vectors are usually between 0 and 1 in magnitude. 12 | ## They are accumulated during a frame then applied as acceleration during the movement update. 13 | ## 14 | ## @param WorldDirection Direction in world space to apply input 15 | ## @param ScaleValue Scale to apply to input. This can be used for analog input, ie a value of 0.5 applies half the normal value. 16 | ## @param bForce If true always add the input, ignoring the result of IsMoveInputIgnored(). 17 | ## @see APawn::AddMovementInput() 18 | ## UFUNCTION(BlueprintCallable, Category="Pawn|Components|PawnMovement") 19 | 20 | proc getPendingInputVector(): FVector {.noSideEffect.} 21 | ## Return the pending input vector in world space. This is the most up-to-date value of the input vector, pending ConsumeMovementInputVector() which clears it. 22 | ## PawnMovementComponents implementing movement usually want to use either this or ConsumeInputVector() as these functions represent the most recent state of input. 23 | ## @return The pending input vector in world space. 24 | ## @see AddInputVector(), ConsumeInputVector(), GetLastInputVector() 25 | ## UFUNCTION(BlueprintCallable, Category="Pawn|Components|PawnMovement", meta=(Keywords="GetInput")) 26 | 27 | proc getLastInputVector(): FVector {.noSideEffect.} 28 | ## Return the last input vector in world space that was processed by ConsumeInputVector(), which is usually done by the Pawn or PawnMovementComponent. 29 | ## Any user that needs to know about the input that last affected movement should use this function. 30 | ## @return The last input vector in world space that was processed by ConsumeInputVector(). 31 | ## @see AddInputVector(), ConsumeInputVector(), GetPendingInputVector() 32 | ## UFUNCTION(BlueprintCallable, Category="Pawn|Components|PawnMovement", meta=(Keywords="GetInput")) 33 | 34 | method consumeInputVector(): FVector 35 | ## Returns the pending input vector and resets it to zero. 36 | ## This should be used during a movement update (by the Pawn or PawnMovementComponent) to prevent accumulation of control input between frames. 37 | ## Copies the pending input vector to the saved input vector (GetLastMovementInputVector()). 38 | ## @return The pending input vector. 39 | ## UFUNCTION(BlueprintCallable, Category="Pawn|Components|PawnMovement") 40 | 41 | method IsMoveInputIgnored(): bool {.noSideEffect.} 42 | ## Helper to see if move input is ignored. 43 | ## If there is no Pawn or UpdatedComponent, returns true, otherwise defers to the Pawn's implementation of IsMoveInputIgnored(). 44 | ## UFUNCTION(BlueprintCallable, Category="Pawn|Components|PawnMovement") 45 | 46 | proc getPawnOwner(): ptr APawn {.noSideEffect.} 47 | ## Return the Pawn that owns UpdatedComponent. 48 | ## UFUNCTION(BlueprintCallable, Category="Pawn|Components|PawnMovement") 49 | 50 | method notifyBumpedPawn(bumpedPawn: ptr APawn) 51 | ## Notify of collision in case we want to react, such as waking up avoidance or pathing code. -------------------------------------------------------------------------------- /modules/core/components/pawnnoiseemitter.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UPawnNoiseEmitterComponent of UActorComponent, header: "Components/PawnNoiseEmitterComponent.h", notypedef): 4 | ## PawnNoiseEmitterComponent tracks noise event data used by SensingComponents to hear a Pawn. 5 | ## This component is intended to exist on either a Pawn or its Controller. It does nothing on network clients. 6 | ## UCLASS(ClassGroup=AI, meta=(BlueprintSpawnableComponent)) 7 | 8 | var bAIPerceptionSystemCompatibilityMode: bool 9 | ## If set to true (default value) will notify AIPerceptionSystem about noise events 10 | ## otherwise only PawnSensingComponents will be able to pick up noises generated by this component 11 | ## UPROPERTY(EditDefaultsOnly, Category = "AI|Perception", AdvancedDisplay) 12 | 13 | var lastRemoteNoisePosition: FVector 14 | ## Most recent noise made by this pawn not at its own location 15 | 16 | var noiseLifetime: cfloat 17 | ## After this amount of time, new sound events will overwrite previous sounds even if 18 | ## they are not louder (allows old sounds to decay) 19 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Noise Settings") 20 | 21 | method makeNoise(noiseMaker: ptr AActor; loudness: cfloat, noiseLocation: var FVector) 22 | ## Cache noises instigated by the owning pawn for AI sensing 23 | ## @param NoiseMaker - is the actual actor which made the noise 24 | ## @param Loudness - is the relative loudness of the noise (0.0 to 1.0) 25 | ## @param NoiseLocation - is the position of the noise 26 | ## UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category="Audio|Components|PawnNoiseEmitter") 27 | 28 | proc getLastNoiseVolume(bSourceWithinNoiseEmitter: bool): cfloat {.noSideEffect.} 29 | proc getLastNoiseTime(bSourceWithinNoiseEmitter: bool): cfloat {.noSideEffect.} -------------------------------------------------------------------------------- /modules/core/components/shape.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UShapeComponent of UPrimitiveComponent, header: "Components/ShapeComponent.h", notypedef): 4 | ## ShapeComponent is a PrimitiveComponent that is represented by a simple geometrical shape (sphere, capsule, box, etc). 5 | ## UCLASS(abstract, hidecategories=(Object,LOD,Lighting,TextureStreaming,Activation,"Components|Activation"), 6 | ## editinlinenew, meta=(BlueprintSpawnableComponent), showcategories=(Mobility)) 7 | 8 | var shapeColor: FColor 9 | ## UPROPERTY(EditAnywhere, AdvancedDisplay, BlueprintReadOnly, Category=Shape) 10 | ## Color used to draw the shape. 11 | 12 | var shapeBodySetup: ptr UBodySetup 13 | ## Description of collision 14 | ## UPROPERTY(transient, duplicatetransient) 15 | 16 | var bDrawOnlyIfSelected: bool 17 | ## Only show this component if the actor is selected 18 | ## UPROPERTY() 19 | 20 | var bShouldCollideWhenPlacing: bool 21 | ## If true it allows Collision when placing even if collision is not enabled 22 | ## UPROPERTY() 23 | 24 | var bDynamicObstacle: bool 25 | ## If set, shape will be exported for navigation as dynamic modifier instead of using regular collision data 26 | ## UPROPERTY(EditAnywhere, Category = Navigation) 27 | 28 | var areaClass: ptr UClass 29 | ## Navigation area type (empty = default obstacle) 30 | ## UPROPERTY(EditAnywhere, Category = Navigation) 31 | 32 | method updateBodySetup() 33 | ## Update the body setup parameters based on shape information 34 | -------------------------------------------------------------------------------- /modules/core/components/skeletalmesh.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(USkeletalMeshComponent of USkinnedMeshComponent, header: "Components/SkeletalMeshComponent.h", notypedef): 4 | var bounds: FBoxSphereBounds 5 | var animScriptInstance: ptr UAnimInstance 6 | var globalAnimRateScale: float32 7 | 8 | method setSkeletalMesh(newMesh: ptr USkeletalMesh, bReinitPose:bool) 9 | ## Change the SkeletalMesh that is rendered for this Component. Will re-initialize the animation tree etc. 10 | ## @param newMesh - New mesh to set for this component 11 | ## @param bReinitPose - Whether we should keep current pose or reinitialize. 12 | 13 | method setAnimation(newAnimToPlay: ptr UAnimationAsset) 14 | method playAnimation(newAnimToPlay: ptr UAnimationAsset, bLooping: bool) 15 | 16 | method play(bLooping: bool) 17 | method stop() 18 | 19 | method getPlayRate(): float32 {.noSideEffect.} 20 | method setPlayRate(rate: float32) 21 | 22 | method setPosition(pos: float32, bFireNotifies: bool = true) 23 | method getPosition(): float32 {.noSideEffect.} 24 | 25 | # TODO -------------------------------------------------------------------------------- /modules/core/components/skinnedmesh.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | -------------------------------------------------------------------------------- /modules/core/components/sphere.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(USphereComponent of UShapeComponent, header: "Components/SphereComponents.h", notypedef): 4 | ## A sphere generally used for simple collision. 5 | ## Bounds are rendered as lines in the editor. 6 | ## 7 | ## UCLASS(ClassGroup="Collision", editinlinenew, hidecategories=(Object,LOD,Lighting,TextureStreaming), 8 | ## meta=(DisplayName="Sphere Collision", BlueprintSpawnableComponent)) 9 | 10 | proc setSphereRadius(inSphereRadius: cfloat; bUpdateOverlaps: bool = true) 11 | ## Change the sphere radius. This is the unscaled radius, before component scale is applied. 12 | ## @param InSphereRadius: the new sphere radius 13 | ## @param bUpdateOverlaps: if true and this shape is registered and collides, 14 | ## updates touching array for owner actor. 15 | ## 16 | ## UFUNCTION(BlueprintCallable, Category="Components|Sphere") 17 | 18 | proc getScaledSphereRadius(): cfloat {.noSideEffect.} 19 | ## @return the radius of the sphere, with component scale applied. 20 | ## UFUNCTION(BlueprintCallable, Category="Components|Sphere") 21 | 22 | proc getUnscaledSphereRadius(): cfloat {.noSideEffect.} 23 | ## @return the radius of the sphere, ignoring component scale. 24 | ## UFUNCTION(BlueprintCallable, Category="Components|Sphere") 25 | 26 | proc getShapeScale(): cfloat {.noSideEffect.} 27 | ## Get the scale used by this shape. 28 | ## This is a uniform scale that is the minimum of any non-uniform scaling. 29 | ## @return the scale used by this shape. 30 | ## UFUNCTION(BlueprintCallable, Category="Components|Sphere") 31 | 32 | proc initSphereRadius(inSphereRadius: cfloat) 33 | ## Sets the sphere radius without triggering a render or physics update. -------------------------------------------------------------------------------- /modules/core/components/staticmesh.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UStaticMesh of UObject, header: "Engine/StaticMesh.h", notypedef): 4 | proc getBounds(): FBoxSphereBounds {.noSideEffect.} 5 | ## UFUNCTION( BlueprintPure, Category="StaticMesh" ) 6 | 7 | proc getBoundingBox(): FBox {.noSideEffect.} 8 | ## UFUNCTION(BlueprintCallable, Category="StaticMesh") 9 | ## Returns the bounding box, in local space including bounds extension(s), of the StaticMesh asset 10 | 11 | wclass(UStaticMeshComponent of UMeshComponent, header: "Components/StaticMeshComponent.h", notypedef): 12 | proc setStaticMesh(mesh: ptr UStaticMesh) 13 | proc getStaticMesh(): ptr UStaticMesh {.noSideEffect.} 14 | -------------------------------------------------------------------------------- /modules/core/consolemanager.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(TConsoleVariableData[T], header: "HAL/IConsoleManager.h", bycopy): 4 | ## T: int32, float 5 | proc initTConsoleVariableData(defaultValue: T): TConsoleVariableData[T] {.constructor.} 6 | 7 | proc getValueOnGameThread(): T 8 | ## faster than GetValueOnAnyThread() 9 | 10 | proc getValueOnRenderThread(): T 11 | ## faster than GetValueOnAnyThread() 12 | 13 | proc getValueOnAnyThread(bForceGameThread = false): T 14 | ## convenient, for better performance consider using GetValueOnGameThread() or GetValueOnRenderThread() 15 | 16 | wclass(IConsoleManager, header: "HAL/IConsoleManager.h"): 17 | proc findTConsoleVariableDataInt(name: wstring): ptr TConsoleVariableData[int32] 18 | ## Find a typed console variable (faster access to the value, no virtual function call) 19 | ## @param Name must not be 0 20 | ## @return 0 if the object wasn't found 21 | 22 | proc findTConsoleVariableDataFloat(name: wstring): ptr TConsoleVariableData[float] 23 | ## Find a typed console variable (faster access to the value, no virtual function call) 24 | ## @param Name must not be 0 25 | ## @return 0 if the object wasn't found 26 | 27 | proc getConsoleManager*(): var IConsoleManager {. 28 | importcpp: "IConsoleManager::Get()", header: "HAL/IConsoleManager.h".} 29 | ## Returns the singleton for the console manager 30 | -------------------------------------------------------------------------------- /modules/core/containers/array.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(TArray[T], header: "Containers/Array.h", bycopy): 4 | proc capacity(): uint32 {.noSideEffect, cppname: "Max".} 5 | ## number of items that can fit in the array without memory reallocation 6 | proc slack(): int32 {.noSideEffect, cppname: "GetSlack".} 7 | ## `capacity` - `len` 8 | proc len(): int32 {.noSideEffect, cppname: "Num".} 9 | ## number of items in the array 10 | proc add(item: T) {.cppname: "Push".} 11 | proc add[OtherT](other: TArray[OtherT]) {.cppname: "Append".} 12 | proc add(arrPtr: ptr T, count: Natural) {.cppname: "Append".} 13 | 14 | proc pop(): T 15 | 16 | proc `[]`(i: Natural): var T {.noSideEffect.} 17 | proc `[]=`(i: Natural, val: T) 18 | 19 | proc find(item: T): int32 {.noSideEffect.} 20 | 21 | proc rfind(item: T): int32 {.noSideEffect, cppname: "FindLast".} 22 | 23 | proc `==`(other: TArray[T]): bool {.noSideEffect.} 24 | proc `!=`(other: TArray[T]): bool {.noSideEffect.} 25 | 26 | proc insert(other: TArray[T], i: Natural): int32 {.discardable.} 27 | proc insert(item: T, i: Natural): int32 {.discardable.} 28 | 29 | proc clear() {.cppname: "Empty".} 30 | 31 | proc setLen(newLen: Natural) {.cppname: "SetNum".} 32 | 33 | proc append[OtherT](other: TArray[OtherT]) 34 | proc append(arrPtr: ptr T, count: Natural) 35 | 36 | proc remove(item: T): int32 {.discardable.} 37 | ## Removes all items equal to the specified item, preserving order. 38 | ## Optimized for series of matches and non-matches. 39 | ## Returns the number of items removed 40 | 41 | proc removeFirst(item: T): int32 {.discardable.} 42 | ## Removes the first item equal to the specified item, preserving order. 43 | ## Returns the number of items removed 44 | 45 | proc removeFirstSwap(item: T): int32 {.discardable.} 46 | ## Removes the first item equal to the specified item, not preserving order, but more efficiently 47 | ## Returns the number of items removed 48 | 49 | proc removeSwap(item: T): int32 {.discardable.} 50 | ## Removes all items equal to the specified item, not preserving order 51 | ## Returns the number of items removed 52 | 53 | proc swap(i1: Natural, i2: Natural) 54 | 55 | proc sort() 56 | 57 | proc reserve(capacity: Natural) 58 | 59 | proc getData(): ptr T 60 | 61 | proc isValidIndex(i: Natural): bool {.noSideEffect.} 62 | ## Tests if index is valid, i.e. greater than zero and less than number of 63 | ## elements in array. 64 | 65 | proc fill(val: T, times: Natural) {.cppname: "Init".} 66 | ## Sets the size of the array, filling it with the given element. 67 | 68 | proc deleteInternal[T](arr: var TArray[T], i: Natural, count: Natural = 1) {.importcpp: "RemoveAt", header: "Containers/Array.h".} 69 | proc delInternal[T](arr: var TArray[T], i: Natural, count: Natural = 1) {.importcpp: "RemoveAtSwap", header: "Containers/Array.h".} 70 | 71 | proc delete*[T](arr: var TArray[T], i: Natural) {.inline.} = 72 | arr.deleteInternal(i) 73 | 74 | proc delete*[T](arr: var TArray[T], first, last: Natural) {.inline.} = 75 | arr.deleteInternal(first, last - first + 1) 76 | 77 | proc del*[T](arr: var TArray[T], i: Natural) {.importcpp: "RemoveAtSwap", header: "Containers/Array.h".} 78 | 79 | proc del*[T](arr: var TArray[T], first, last: Natural) {.inline.} = 80 | arr.delInternal(first, last - first + 1) 81 | 82 | proc initArrayInternal[T](arr: var TArray[T], val: T, size: int32) {.importcpp: "#.Init(@)", nodecl.} 83 | 84 | type 85 | TArrayIterator {.importcpp: "TArray<'0>::TIterator".} [T] = object 86 | TArrayConstIterator {.importcpp: "TArray<'0>::TConstIterator".} [T] = object 87 | TAnyArrayIterator[T] = TArrayIterator[T] or TArrayConstIterator[T] 88 | 89 | proc isValid[T](it: TAnyArrayIterator[T]): bool {.noSideEffect, importcpp: "((bool)(#))", header: "Containers/Array.h".} 90 | proc next[T](it: var TAnyArrayIterator[T]) {.importcpp: "(++#)", header: "Containers/Array.h".} 91 | 92 | proc value[T](it: TArrayIterator[T]): var T {.noSideEffect, importcpp: "(*#)", header: "Containers/Array.h".} 93 | proc value[T](it: TArrayConstIterator[T]): T {.noSideEffect, importcpp: "(*#)", header: "Containers/Array.h".} 94 | 95 | proc initArray*[T](): TArray[T] {.importcpp: "'0(@)", constructor, nodecl.} 96 | 97 | proc initArray*[T](initCapacity: Natural): TArray[T] = 98 | result = initArray[T]() 99 | result.reserve(initCapacity) 100 | 101 | proc initArray*[T](val: T, size: Natural): TArray[T] = 102 | initArrayInternal[T](result, val, int32(size)) 103 | 104 | iterator items*[T](arr: TArray[T]): T = 105 | for i in 0 .. ", bycopy.}[T] = object 5 | 6 | proc value*[T](this: TEnumAsByte[T]): T {.noSideEffect, importcpp: "GetValue", 7 | header: "Containers/EnumAsByte.h".} 8 | 9 | proc initTEnumAsByte*[T: enum](e: T): TEnumAsByte[T] {.importcpp: "TEnumAsByte<'1 >(@)", nodecl, constructor.} 10 | 11 | converter toEnum*[T](container: TEnumAsByte[T]): T = 12 | result = container.value() 13 | 14 | converter asByte*[T: enum](t: T): TEnumAsByte[T] = 15 | result = initTEnumAsByte(t) 16 | -------------------------------------------------------------------------------- /modules/core/containers/map.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(TPair[K, V], header: "Containers/Map.h", bycopy): 4 | var key: K 5 | var value: V 6 | 7 | proc `==`(other: TPair[K, V]): bool {.noSideEffect.} 8 | proc `!=`(other: TPair[K, V]): bool {.noSideEffect.} 9 | 10 | wclass(TMap[K, V], header: "Containers/Map.h", bycopy): 11 | proc append(other: TMap[K, V]) 12 | 13 | proc `[]`(key: K): var V 14 | proc `[]=`(key: K, value: V) {.cppname: "Add".} 15 | proc add(key: K, value: V) 16 | 17 | proc equals(other: TMap[K, V]): bool {.noSideEffect, cppname: "OrderIndependentCompareEqual".} 18 | ## Order-independent comparison 19 | 20 | proc reset() 21 | ## Remove all elements from the map, leaving the current capacity 22 | 23 | proc clear(nextExpectedSize: Natural = 0) {.cppname: "Empty".} 24 | ## Remove all elements from the map, setting new capacity 25 | 26 | proc reserve(capacity: Natural) 27 | ## Reserve memory enough to hold the specified number of elements in the map 28 | 29 | proc len(): int32 {.noSideEffect, cppname: "Num".} 30 | ## Current number of items in the map 31 | 32 | proc del(key: K): int32 {.discardable, cppname: "Remove".} 33 | ## Removes value associated with the key in the map, if any. Returns the number of items removed 34 | 35 | proc contains(key: K): bool {.noSideEffect.} 36 | 37 | proc getOrDefault*[K, V](map: TMap[K, V], key: K): V = 38 | if map.contains(key): 39 | return map[key] 40 | 41 | type 42 | TMapIterator {.importcpp: "TMap<'0, '1>::TIterator", header: "Containers/Map.h".} [K, V] = object 43 | 44 | proc key[K, V](it: TMapIterator[K, V]): K {. 45 | noSideEffect, importcpp: "#.Key(@)", header: "Containers/Map.h".} 46 | proc value[K, V](it: TMapIterator[K, V]): V {.noSideEffect, importcpp: "#.Value(@)", header: "Containers/Map.h".} 47 | proc pair[K, V](it: TMapIterator[K, V]): TPair[K, V] {.noSideEffect, importcpp: "(*#)", header: "Containers/Map.h".} 48 | proc isValid[K, V](it: TMapIterator[K, V]): bool {.noSideEffect, importcpp: "((bool)(#))", header: "Containers/Map.h".} 49 | proc next[K, V](it: var TMapIterator[K, V]) {.importcpp: "(++#)", header: "Containers/Map.h".} 50 | 51 | proc initIterator[K, V](map: TMap[K, V]): TMapIterator[K, V] {.importcpp:"#.CreateIterator(@)", header: "Containers/Map.h".} 52 | 53 | proc keysInternal[K, V](map: TMap[K, V], outArr: var TArray[K]) {.importcpp:"#.GetKeys(@)", header: "Containers/Map.h".} 54 | proc keys*[K, V](map: TMap[K, V]): TArray[K] = 55 | result = initArray(map.len) 56 | keysInternal(map, result) 57 | 58 | iterator keys*[K, V](map: TMap[K, V]): K = 59 | var it = map.initIterator() 60 | while it.isValid: 61 | yield it.key() 62 | it.next() 63 | 64 | iterator pairs*[K, V](map: TMap[K, V]): (K, V) = 65 | var it = map.initIterator() 66 | while it.isValid: 67 | let pair = it.pair() 68 | yield (pair.key, pair.value) 69 | it.next() 70 | 71 | iterator values*[K, V](map: TMap[K, V]): V = 72 | var it = map.initIterator() 73 | while it.isValid: 74 | yield it.value() 75 | it.next() 76 | 77 | # TODO: mpairs, mvalues? 78 | 79 | proc initMap*[K, V](): TMap[K, V] {.importcpp: "'0(@)", constructor, header: "Containers/Map.h".} 80 | proc initMap*[K, V](initialCapacity: Natural): TMap[K, V] = 81 | result = initMap[K, V]() 82 | result.reserve(initialCapacity) 83 | 84 | # TODO: TMultiMap, FScriptMap 85 | -------------------------------------------------------------------------------- /modules/core/containers/optional.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(TOptional[T], header: "Misc/Optional.h", bycopy): 4 | ## When we have an optional value isSet() returns true, and getValue() is meaningful. 5 | ## Otherwise getValue() is not meaningful. 6 | proc initTOptional(val: T): TOptional[T] {.constructor.} 7 | proc isSet(): bool {.noSideEffect.} 8 | proc getValue(): T {.noSideEffect.} 9 | proc `==`(other: TOptional[T]): bool {.noSideEffect.} 10 | proc reset() 11 | -------------------------------------------------------------------------------- /modules/core/containers/refcountptr.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | TRefCountPtr* {.header: "Templates/RefCounting.h", importcpp.} [out T] = object 5 | 6 | # TODO 7 | -------------------------------------------------------------------------------- /modules/core/containers/set.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | FSetElementId {.importcpp: "FSetElementId".} = object 5 | TSetIterator {.importcpp: "TSet<'0>::TIterator".} [T] = object 6 | TSetConstIterator {.importcpp: "TSet<'0>::TConstIterator".} [T] = object 7 | TAnySetIterator[T] = TSetIterator[T] or TSetConstIterator[T] 8 | 9 | wclass(TSet[T], header: "Containers/Set.h", bycopy): 10 | ## A set with an optional KeyFuncs parameters for customizing how the elements are compared and searched. E.g. 11 | ## You can specify a mapping from elements to keys if you want to find elements by specifying a subset of the element type. 12 | ## It uses a TSparseArray of the elements, and also links the elements into a hash with a number of 13 | ## buckets proportional to the number of elements. Addition, removal, and finding are O(1). 14 | 15 | proc len(): int32 {.noSideEffect, cppname: "Num".} 16 | ## The number of elements. 17 | 18 | proc contains(key: T): bool {.noSideEffect.} 19 | 20 | proc incl(key: T) {.cppname: "Add".} 21 | proc add(key: T) 22 | 23 | proc toArray(): TArray[T] {.cppname: "Array".} 24 | 25 | proc findId(key: T): FSetElementId {.noSideEffect.} 26 | proc remove(id: FSetElementId) 27 | 28 | proc clear() {.cppname: "Empty".} 29 | 30 | proc union(s: TSet[T]): TSet[T] 31 | proc intersection(s: TSet[T]): TSet[T] {.cppname: "Intersect".} 32 | proc difference(s: TSet[T]): TSet[T] 33 | proc createConstIterator(): TSetConstIterator[T] 34 | 35 | proc excl*[T](s: var TSet[T], val: T) {.inline.} = 36 | let id = s.findId(val) 37 | if id != nil: 38 | s.remove(id) 39 | 40 | proc `+`*[T](s1, s2: TSet[T]): TSet[T] {.inline.} = 41 | ## Alias for `union(s1, s2) <#union>`_. 42 | result = union(s1, s2) 43 | 44 | proc `*`*[T](s1, s2: TSet[T]): TSet[T] {.inline.} = 45 | ## Alias for `intersection(s1, s2) <#intersection>`_. 46 | result = intersection(s1, s2) 47 | 48 | proc `-`*[T](s1, s2: TSet[T]): TSet[T] {.inline.} = 49 | ## Alias for `difference(s1, s2) <#difference>`_. 50 | result = difference(s1, s2) 51 | 52 | proc isValid[T](it: TAnySetIterator[T]): bool {.noSideEffect, importcpp: "((bool)(#))", header: "Containers/Set.h".} 53 | proc next[T](it: var TAnySetIterator[T]) {.importcpp: "(++#)", header: "Containers/Set.h".} 54 | proc value[T](it: TSetIterator[T]): var T {.noSideEffect, importcpp: "(*#)", header: "Containers/Set.h".} 55 | proc value[T](it: TSetConstIterator[T]): T {.noSideEffect, importcpp: "(*#)", header: "Containers/Set.h".} 56 | 57 | proc initSet*[T](): TSet[T] {.importcpp: "TSet", constructor, header: "Containers/Set.h".} 58 | {.deprecated: [makeSet: initSet].} 59 | 60 | iterator items*[T](s: TSet[T]): T = 61 | var it = s.createConstIterator() 62 | while it.isValid(): 63 | yield it.value 64 | it.next 65 | 66 | proc `$`*[T](st: TSet[T]): string = 67 | let comma = rope(", ") 68 | var isFirst = true 69 | var r = rope("[") 70 | for item in st.items(): 71 | if not isFirst: 72 | r.add(comma) 73 | else: 74 | isFirst = false 75 | r.add($item) 76 | r.add("]") 77 | result = $r 78 | 79 | # TODO: might have to manually implement many procs here 80 | # so that they work properly with Nim (non-C++) types 81 | -------------------------------------------------------------------------------- /modules/core/containers/sharedptr.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | TSharedRef* {.importcpp, header: "Templates/SharedPointer.h", bycopy.} [out T] = object 5 | TSharedPtr* {.importcpp, header: "Templates/SharedPointer.h", bycopy.} [out T] = object 6 | TSharedFromThis* {.importcpp, header: "Templates/SharedPointer.h", bycopy.} [out T] = object {.inheritable.} 7 | 8 | wclass(TSharedRef[T], header: "Templates/SharedPointer.h", notypedef): 9 | proc getSharedReferenceCount(): int32 {.noSideEffect.} 10 | ## Returns the number of shared references to this object (including this reference.) 11 | ## IMPORTANT: Not necessarily fast! Should only be used for debugging purposes! 12 | ## 13 | ## @return Number of shared references to the object (including this reference.) 14 | 15 | proc IsUnique(): bool {.noSideEffect.} 16 | ## Returns true if this is the only shared reference to this object. Note that there may be 17 | ## outstanding weak references left. 18 | ## IMPORTANT: Not necessarily fast! Should only be used for debugging purposes! 19 | ## 20 | ## @return True if there is only one shared reference to the object, and this is it! 21 | 22 | proc get(): var T 23 | 24 | wclass(TSharedPtr[T], header: "Templates/SharedPointer.h", notypedef): 25 | proc initTSharedPtr(): TSharedPtr[T] {.constructor.} 26 | ## initializes nil ptr 27 | 28 | proc getSharedReferenceCount(): int32 {.noSideEffect.} 29 | ## Returns the number of shared references to this object (including this reference.) 30 | ## IMPORTANT: Not necessarily fast! Should only be used for debugging purposes! 31 | ## 32 | ## @return Number of shared references to the object (including this reference.) 33 | 34 | proc IsUnique(): bool {.noSideEffect.} 35 | ## Returns true if this is the only shared reference to this object. Note that there may be 36 | ## outstanding weak references left. 37 | ## IMPORTANT: Not necessarily fast! Should only be used for debugging purposes! 38 | ## 39 | ## @return True if there is only one shared reference to the object, and this is it! 40 | 41 | proc get(): ptr T 42 | proc isValid(): bool 43 | proc toSharedRef(): TSharedRef[T] 44 | proc reset() 45 | 46 | converter toPtr*[T](reference: TSharedRef[T]): ptr T {.importcpp: "(& #.Get())", nodecl.} 47 | converter toPtr*[T](sharedPtr: TSharedPtr[T]): ptr T {.importcpp: "#.Get()", nodecl.} 48 | 49 | converter toSharedPtr*[T](sharedRef: TSharedRef[T]): TSharedPtr[T] {.importcpp: "(#)", nodecl.} 50 | 51 | proc makeShareable*[T](p: ptr T): TSharedPtr[T] {.importc: "MakeShareable", header: "Templates/SharedPointer.h".} 52 | 53 | wclass(TSharedFromThis[T], header: "Templates/SharedPointer.h", notypedef): 54 | proc asShared(): TSharedRef[T] 55 | 56 | # TODO -------------------------------------------------------------------------------- /modules/core/containers/subclassof.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type TSubclassOf* {.header: "CoreUObject.h", importcpp: "TSubclassOf"} [out T] = object 4 | 5 | converter toUClassPtr*(cont: TSubclassOf): ptr UClass {.header: "CoreUObject.h", importcpp: "#".} 6 | -------------------------------------------------------------------------------- /modules/core/containers/weakptr.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | TWeakObjectPtr* {.importc, header: "UObject/WeakObjectPtrTemplates.h", bycopy.} [out T] = object 5 | TAutoWeakObjectPtr* {.importc, header: "UObject/WeakObjectPtrTemplates.h", bycopy.} [out T] = object 6 | TWeakPtr* {.importc, header: "Templates/SharedPointer.h", bycopy.} [out T] = object 7 | 8 | wclass(TWeakObjectPtr[T], header: "UObject/WeakObjectPtrTemplates.h", notypedef): 9 | proc isValid(bEvenIfPendingKill, bThreadsafeTest: bool = false): bool {.noSideEffect.} 10 | ## Test if this points to a live UObject 11 | ## @param bEvenIfPendingKill, if this is true, pendingkill objects are considered valid 12 | ## @param bThreadsafeTest, if true then function will just give you information whether referenced 13 | ## UObject is gone forever (@return false) or if it is still there (@return true, no object flags checked). 14 | ## @return true if Get() would return a valid non-null pointer 15 | 16 | proc isStale(bIncludingIfPendingKill, bThreadsafeTest: bool = false): bool {.noSideEffect.} 17 | ## Slightly different than !IsValid(), returns true if this used to point to a UObject, but doesn't any more and has not been assigned or reset in the mean time. 18 | ## @param bIncludingIfPendingKill, if this is true, pendingkill objects are considered stale 19 | ## @param bThreadsafeTest, set it to true when testing outside of Game Thread. Results in false if WeakObjPtr point to an existing object (no flags checked) 20 | ## @return true if this used to point at a real object but no longer does. 21 | 22 | proc get(): ptr T 23 | proc reset() 24 | 25 | proc set*[T](weakPtr: var TWeakObjectPtr[T], p: ptr T) {.importcpp: "(# = #)", nodecl.} 26 | 27 | converter toWeakPtr*[T](p: ptr T): TWeakObjectPtr[T] {.importcpp: "(#)", nodecl.} 28 | converter toPtr*[T](p: TWeakObjectPtr[T]): ptr T {.importcpp: "(#.Get())", nodecl.} 29 | 30 | wclass(TAutoWeakObjectPtr[T], header: "UObject/WeakObjectPtrTemplates.h", notypedef): 31 | proc initTAutoWeakObjectPtr(): TAutoWeakObjectPtr[T] {.constructor.} 32 | proc initTAutoWeakObjectPtr(p: ptr T): TAutoWeakObjectPtr[T] {.constructor.} 33 | proc initTAutoWeakObjectPtr(weakPtr: TWeakObjectPtr[T]): TAutoWeakObjectPtr[T] {.constructor.} 34 | proc get(): ptr T 35 | 36 | converter toPtr*[T](p: TAutoWeakObjectPtr[T]): ptr T {.importcpp: "(#)", nodecl.} 37 | 38 | wclass(TWeakPtr[T], header: "Templates/SharedPointer.h", notypedef): 39 | ## TWeakPtr is a non-intrusive reference-counted weak object pointer. This weak pointer will be 40 | ## conditionally thread-safe when the optional Mode template argument is set to ThreadSafe. 41 | 42 | proc initTWeakPtr(): TWeakPtr[T] {.constructor.} 43 | 44 | proc initTWeakPtr[OtherT](inSharedRef: TSharedRef[OtherT]): TWeakPtr[T] 45 | ## Constructs a weak pointer from a shared reference 46 | ## 47 | ## @param InSharedRef The shared reference to create a weak pointer from 48 | 49 | proc initTWeakPtr[OtherT](inSharedPtr: TSharedPtr[OtherT]): TWeakPtr[T] 50 | ## Constructs a weak pointer from a shared pointer 51 | ## 52 | ## @param InSharedPtr The shared pointer to create a weak pointer from 53 | 54 | proc initTWeakPtr[OtherT](inWeakPtr: TWeakPtr[OtherT]): TWeakPtr[T] 55 | ## Constructs a weak pointer from a weak pointer of another type. 56 | ## This constructor is intended to allow derived-to-base conversions. 57 | ## 58 | ## @param InWeakPtr The weak pointer to create a weak pointer from 59 | 60 | proc initTWeakPtr(inWeakPtr: TWeakPtr[T]): TWeakPtr[T] 61 | 62 | proc pin(): TSharedPtr[T] {.noSideEffect.} 63 | ## Converts this weak pointer to a shared pointer that you can use to access the object (if it 64 | ## hasn't expired yet.) Remember, if there are no more shared references to the object, the 65 | ## returned shared pointer will not be valid. You should always check to make sure the returned 66 | ## pointer is valid before trying to dereference the shared pointer! 67 | ## 68 | ## @return Shared pointer for this object (will only be valid if still referenced!) 69 | 70 | proc isValid(): bool {.noSideEffect.} 71 | ## Checks to see if this weak pointer actually has a valid reference to an object 72 | ## 73 | ## @return True if the weak pointer is valid and a pin operator would have succeeded 74 | 75 | proc reset() 76 | ## Resets this weak pointer, removing a weak reference to the object. If there are no other shared 77 | ## or weak references to the object, then the tracking object will be destroyed. 78 | 79 | proc hasSameObject(inOtherPtr: pointer): bool 80 | ## Returns true if the object this weak pointer points to is the same as the specified object pointer. 81 | 82 | converter toWeakPtr*[T](p: TSharedRef[T]): TWeakPtr[T] {.importcpp: "(#)", nodecl.} 83 | converter toWeakPtr*[T](p: TSharedPtr[T]): TWeakPtr[T] {.importcpp: "(#)", nodecl.} 84 | -------------------------------------------------------------------------------- /modules/core/core/globals.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | var gFrameCounter* {.importcpp: "GFrameCounter", header: "CoreGlobals.h".}: uint64 4 | var gLog* {.importcpp: "GLog", header: "CoreGlobals.h".}: ptr FOutputDeviceRedirector 5 | 6 | var gEngine* {.importcpp: "GEngine", header: "EngineGlobals.h".}: ptr UEngine 7 | ## Global engine pointer. Can be 0 so don't use without checking. 8 | 9 | var gWorld* {.importcpp: "GWorld", header: "Engine/World.h".}: ptr UWorld 10 | ## Global UWorld pointer. Use of this pointer should be avoided whenever possible. 11 | 12 | var gDisallowNetworkTravel* {.importcpp: "GDisallowNetworkTravel", header: "EngineGlobals.h".}: bool 13 | ## when set, disallows all network travel (pending level rejects all client travel attempts) 14 | 15 | var gGPUFrameTime* {.importcpp: "GGPUFrameTime", header: "EngineGlobals.h".}: uint32 16 | ## The GPU time taken to render the last frame. Same metric as FPlatformTime::Cycles(). 17 | 18 | var gGameplayTagsManager* {.importcpp: "GGPUFrameTime", header: "EngineGlobals.h".}: ptr UGameplayTagsManager 19 | ## A reference to the ability system so we do not need to get the module every time we access the tag manager. 20 | 21 | declareBuiltinDelegate(FApplicationLifetimeDelegate, dkMulticast, "Misc/CoreDelegates.h") 22 | 23 | var gApplicationHasEnteredForegroundDelegate* {.importcpp: "FCoreDelegates::ApplicationHasEnteredForegroundDelegate", header: "Misc/CoreDelegates.h".}: FApplicationLifetimeDelegate 24 | ## This is called when the application is being backgrounded (e.g., due to switching 25 | ## to another app or closing it via the home button) 26 | ## The game should release shared resources, save state, etc..., since it can be 27 | ## terminated from the background state without any further warning. 28 | 29 | var gApplicationWillEnterBackgroundDelegate* {.importcpp: "FCoreDelegates::ApplicationWillEnterBackgroundDelegate", header: "Misc/CoreDelegates.h".}: FApplicationLifetimeDelegate 30 | ## Called when the application is returning to the foreground (reverse any processing done in the EnterBackground delegate) -------------------------------------------------------------------------------- /modules/core/core/hal/genericplatformmisc.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | proc getUniqueDeviceId*(): FString {.importcpp: "FPlatformMisc::GetUniqueDeviceId(@)", header: "GenericPlatform/GenericPlatformMisc.h", nodecl.} 4 | 5 | proc getDeviceId*(): FString {.importcpp: "FPlatformMisc::GetDeviceId(@)", header: "GenericPlatform/GenericPlatformMisc.h", nodecl.} 6 | 7 | proc requestExit*(force: bool) {.importcpp: "FGenericPlatformMisc::RequestExit(@)", header: "GenericPlatform/GenericPlatformMisc.h".} -------------------------------------------------------------------------------- /modules/core/core/player.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UPlayer of UObject, header: "Engine/Player.h"): 4 | var playerController: ptr APlayerController 5 | ## The actor this player controls. 6 | var currentNetSpeed: int32 7 | ## The current speed of the connection 8 | var configuredInternetSpeed: int32 9 | var configuredLanSpeed: int32 10 | 11 | method exec(inWorld: ptr UWorld, cmd: wstring, ar: var FOutputDevice) 12 | method switchController(pc: ptr APlayerController) 13 | ## Dynamically assign Controller to Player and set viewport. 14 | ## `pc`: new player controller to assign to player 15 | 16 | method consoleCommand(cmd: FString, bWriteToLog: bool = true): FString {.discardable.} 17 | ## Executes the exec() command 18 | ## 19 | ## @param `cmd` command to execute (string of commands optionally separated by a | (pipe)) 20 | ## @param `bWriteToLog` write out to the log 21 | 22 | wclass(ULocalPlayer of UPlayer, header: "Engine/LocalPlayer.h"): 23 | discard 24 | 25 | # TODO -------------------------------------------------------------------------------- /modules/core/defaultpawn.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | ## ============================================================================= 4 | ## DefaultPawns are simple pawns that can fly around the world. 5 | ## ============================================================================= 6 | 7 | wclass(ADefaultPawn of APawn, header: "GameFramework/DefaultPawn.h", notypedef): 8 | ## DefaultPawn implements a simple Pawn with spherical collision and built-in flying movement. 9 | ## @see UFloatingPawnMovement 10 | 11 | method moveForward(val: cfloat) 12 | ## Input callback to move forward in local space (or backward if Val is negative). 13 | ## @param Val Amount of movement in the forward direction (or backward if negative). 14 | ## @see APawn::AddMovementInput() 15 | ## 16 | ## UFUNCTION(BlueprintCallable, Category="Pawn") 17 | 18 | method moveRight(val: cfloat) 19 | ## Input callback to strafe right in local space (or left if Val is negative). 20 | ## @param Val Amount of movement in the right direction (or left if negative). 21 | ## @see APawn::AddMovementInput() 22 | ## 23 | ## UFUNCTION(BlueprintCallable, Category="Pawn") 24 | 25 | method moveUp_World(val: cfloat) 26 | ## Input callback to move up in world space (or down if Val is negative). 27 | ## @param Val Amount of movement in the world up direction (or down if negative). 28 | ## @see APawn::AddMovementInput() 29 | ## 30 | ## UFUNCTION(BlueprintCallable, Category="Pawn") 31 | 32 | proc turnAtRate(rate: cfloat) 33 | ## Called via input to turn at a given rate. 34 | ## @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate 35 | ## 36 | ## UFUNCTION(BlueprintCallable, Category="Pawn") 37 | 38 | proc lookUpAtRate(rate: cfloat) 39 | ## Called via input to look up at a given rate (or down if Rate is negative). 40 | ## @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate 41 | ## 42 | ## UFUNCTION(BlueprintCallable, Category="Pawn") 43 | 44 | var baseTurnRate: cfloat 45 | ## Base turn rate, in deg/sec. Other scaling may affect final turn rate. 46 | ## UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Pawn") 47 | 48 | var baseLookUpRate: cfloat 49 | ## Base lookup rate, in deg/sec. Other scaling may affect final lookup rate. 50 | ## UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Pawn") 51 | 52 | var movementComponentName {.isStatic.}: FName 53 | ## Name of the MovementComponent. 54 | ## Use this name if you want to use a different class (with ObjectInitializer.SetDefaultSubobjectClass). 55 | 56 | var collisionComponentName {.isStatic.}: FName 57 | ## Name of the CollisionComponent. 58 | 59 | var meshComponentName {.isStatic.}: FName 60 | ## Name of the MeshComponent. 61 | ## Use this name if you want to prevent creation of 62 | ## the component (with ObjectInitializer.DoNotCreateDefaultSubobject). 63 | 64 | var bAddDefaultMovementBindings: bool 65 | ## If true, adds default input bindings for movement and camera look. 66 | ## UPROPERTY(Category=Pawn, EditAnywhere, BlueprintReadOnly) 67 | 68 | proc getCollisionComponent(): ptr USphereComponent {.noSideEffect.} 69 | ## Returns CollisionComponent subobject 70 | 71 | proc getMeshComponent(): ptr UStaticMeshComponent {.noSideEffect.} 72 | ## Returns MeshComponent subobject * -------------------------------------------------------------------------------- /modules/core/engine/engine.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | 4 | wclass(UEngine of UObject, header: "Engine/Engine.h", notypedef): 5 | proc getWorldFromContextObject*(obj: ptr UObject, bChecked: bool = true): ptr UWorld 6 | ## Obtain a world object pointer from an object with has a world context. 7 | proc getFirstLocalPlayerController*(inWorld: ptr UWorld): ptr APlayerController 8 | proc getMainAudioDevice*(): ptr FAudioDevice 9 | proc getGameUserSettings*(): ptr UGameUserSettings 10 | 11 | proc setClientTravel(inWorld: ptr UWorld, nextURL: wstring, travelType: ETravelType) 12 | 13 | proc addOnScreenDebugMessage*(key: uint64, timeToDisplay: float32, displayColor: FColor, 14 | debugMessage: FString, bNewerOnTop: bool = false, textScale: FVector2D = vec2D(1.0, 1.0)) 15 | # TODO: interface the rest 16 | -------------------------------------------------------------------------------- /modules/core/engine/hud.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | FHUDHitBox* {.header: "GameFramework/HUDHitBox.h", importcpp.} = object 5 | 6 | wclass(AHUD, header: "GameFramework/HUD.h", notypedef): 7 | var playerOwner: ptr APlayerController 8 | ## PlayerController which owns this HUD. 9 | var canvas: ptr UCanvas 10 | ## Canvas to Draw HUD on. Only valid during PostRender() event. 11 | var debugCanvas: ptr UCanvas 12 | ## 'Foreground' debug canvas, will draw in front of Slate UI. 13 | 14 | proc addHitBox(position, size: FVector2D; inName: FName, bConsumesInput: bool, priority: int32 = 0) {.importcpp.} 15 | ## Add a hitbox to the hud 16 | ## @param Position Coordinates of the top left of the hit box. 17 | ## @param Size Size of the hit box. 18 | ## @param Name Name of the hit box. 19 | ## @param bConsumesInput Whether click processing should continue if this hit box is clicked. 20 | ## @param Priority The priority of the box used for layering. Larger values are considered first. Equal values are considered in the order they were added. 21 | 22 | proc getHitBoxAtCoordinates*(hud: ptr AHUD, inHitLocation: FVector2D, bConsumingInput: bool = false): ptr FHUDHitBox {. 23 | noSideEffect, importcpp: "(const_cast(#.GetHitBoxAtCoordinates(@)))", header: "GameFramework/HUD.h".} 24 | ## Find the first hitbox containing the given coordinates. 25 | ## @param InHitLocation Coordinates to check 26 | ## @param bConsumingInput If true will return the first hitbox that would consume input at this coordinate 27 | ## @return returns the hitbox at the given coordinates or NULL if none match. -------------------------------------------------------------------------------- /modules/core/engine/material.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UMaterialInstanceDynamic of UMaterialInstance, header: "Materials/MaterialInstanceDynamic.h", notypedef): 4 | 5 | proc k2_CopyMaterialInstanceParameters(source: ptr UMaterialInterface) 6 | ## Copies over parameters given a material interface (copy each instance following the hierarchy) 7 | ## Very slow implementation, avoid using at runtime. Hopefully we can replace ity later with something like CopyInterpParameters() 8 | ## The output is the object itself (this). 9 | 10 | proc copyInterpParameters(source: ptr UMaterialInterface) 11 | ## Copies over parameters given a material instance (only copy from the instance, not following the hierarchy) 12 | ## much faster than K2_CopyMaterialInstanceParameters(), 13 | ## The output is the object itself (this). 14 | ## @param Source ignores the call if 0 15 | 16 | proc copyParameterOverrides(materialInstance: ptr UMaterialInstance) 17 | ## Copy parameter values from another material instance. This will copy only parameters explicitly overridden in that material instance!! 18 | ## @param materialInstance material instance to copy parameters. 19 | 20 | proc setScalarParameterValue(parameterName: FName, value: float32) 21 | proc setTextureParameterValue(parameterName: FName, value: ptr UTexture) 22 | proc setVectorParameterValue(parameterName: FName, value: FLinearColor) -------------------------------------------------------------------------------- /modules/core/engine/physicsvolume.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(APhysicsVolume of AVolume, header: "GameFramework/PhysicsVolume.h"): 4 | ## PhysicsVolume: A bounding volume which affects actor physics. 5 | ## Each AActor is affected at any time by one PhysicsVolume. 6 | 7 | method postInitializeComponents() 8 | method destroyed() 9 | method endPlay(endPlayReason: EEndPlayReason) 10 | 11 | #====================================================================================== 12 | # Character Movement related properties 13 | #====================================================================================== 14 | 15 | var terminalVelocity: cfloat 16 | ## Terminal velocity of pawns using CharacterMovement when falling. 17 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=CharacterMovement) 18 | 19 | var priority: int32 20 | ## Determines which PhysicsVolume takes precedence if they overlap (higher number = higher priority). 21 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=CharacterMovement) 22 | 23 | var fluidFriction: cfloat 24 | ## This property controls the amount of friction applied by the volume as pawns using CharacterMovement move through it. The higher this value, the harder it will feel to move through 25 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=CharacterMovement) 26 | 27 | var bWaterVolume: bool 28 | ## True if this volume contains a fluid like water 29 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=CharacterMovement) 30 | 31 | #====================================================================================== 32 | # Physics related properties 33 | #====================================================================================== 34 | 35 | var bPhysicsOnContact: bool 36 | ## By default, the origin of an AActor must be inside a PhysicsVolume for it to affect the actor. However if this flag is true, the other actor only has to touch the volume to be affected by it. 37 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Volume) 38 | 39 | method getGravityZ(): cfloat {.noSideEffect.} 40 | ## @Returns the Z component of the current world gravity. 41 | 42 | method actorEnteredVolume(other: ptr AActor) 43 | ## Called when actor enters a volume 44 | 45 | method actorLeavingVolume(other: ptr AActor) 46 | ## Called when actor leaves a volume, Other can be NULL 47 | 48 | method isOverlapInVolume(testComponent: USceneComponent): bool {.noSideEffect.} 49 | ## Given a known overlap with the given component, validate that it meets the rules imposed by bPhysicsOnContact. 50 | 51 | type 52 | ADefaultPhysicsVolume {.importcpp, header: "GameFramework/DefaultPhysicsVolume.h".} = object of APhysicsVolume 53 | ## DefaultPhysicsVolume determines the physical effects an actor will experience 54 | ## if they are not inside any user specified PhysicsVolume 55 | -------------------------------------------------------------------------------- /modules/core/engine/staticmeshactor.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(AStaticMeshActor of AActor, header: "Engine/StaticMeshActor.h"): 4 | var bStaticMeshReplicateMovement: bool 5 | var navigationGeometryGatheringMode: ENavDataGatheringMode 6 | 7 | proc setMobility(inMobility: EComponentMobility) 8 | proc getStaticMeshComponent(): ptr UStaticMeshComponent {.noSideEffect.} 9 | ## Returns StaticMeshComponent subobject 10 | -------------------------------------------------------------------------------- /modules/core/engine/texture.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | FUpdateTextureRegion2D* {.importcpp, header: "RHI.h", bycopy.} = object 5 | ## specifies an update region for a texture 6 | destX* {.importcpp: "DestX".}: uint32 7 | ## X offset in texture 8 | destY* {.importcpp: "DestY".}: uint32 9 | ## Y offset in texture 10 | 11 | srcX* {.importcpp: "SrcX".}: int32 12 | ## X offset in source image data 13 | srcY* {.importcpp: "SrcY".}: int32 14 | ## Y offset in source image data 15 | 16 | width* {.importcpp: "Width".}: uint32 17 | ## width of region to copy 18 | height* {.importcpp: "Height".}: uint32 19 | ## height of region to copy 20 | EPixelFormat* {.importcpp, header: "PixelFormat.h".} = enum 21 | pfUnknown 22 | pfA32B32G32R32F 23 | pfB8G8R8A8 24 | pfG8 25 | pfG16 26 | pfDXT1 27 | pfDXT3 28 | pfDXT5 29 | pfUYVY 30 | pfFloatRGB 31 | pfFloatRGBA 32 | pfDepthStencil 33 | pfShadowDepth 34 | pfR32_FLOAT 35 | pfG16R16 36 | pfG16R16F 37 | pfG16R16F_FILTER 38 | pfG32R32F 39 | pfA2B10G10R10 40 | pfA16B16G16R16 41 | pfD24 42 | pfR16F 43 | pfR16F_FILTER 44 | pfBC5 45 | pfV8U8 46 | pfA1 47 | pfFloatR11G11B10 48 | pfA8 49 | pfR32_UINT 50 | pfR32_SINT 51 | pfPVRTC2 52 | pfPVRTC4 53 | pfR16_UINT 54 | pfR16_SINT 55 | pfR16G16B16A16_UINT 56 | pfR16G16B16A16_SINT 57 | pfR5G6B5_UNORM 58 | pfR8G8B8A8 59 | pfA8R8G8B8 60 | ## Only used for legacy loading; do NOT use! 61 | pfBC4 62 | pfR8G8 63 | pfATC_RGB 64 | pfATC_RGBA_E 65 | pfATC_RGBA_I 66 | pfX24_G8 67 | ## Used for creating SRVs to alias a DepthStencil buffer to read Stencil. Don't use for creating textures. 68 | pfETC1 69 | pfETC2_RGB 70 | pfETC2_RGBA 71 | pfR32G32B32A32_UINT 72 | pfR16G16_UINT 73 | pfASTC_4x4 74 | pfASTC_6x6 75 | pfASTC_8x8 76 | pfASTC_10x10 77 | pfASTC_12x12 78 | pfBC6H 79 | pfBC7 80 | pfMAX 81 | 82 | proc initFUpdateTextureRegion2D*(destX, destY: int32; srcX, srcY: int32; width, height: uint32): FUpdateTextureRegion2D {. 83 | importcpp: "FUpdateTextureRegion2D(uint32(#), uint32(#), @)", constructor, nodecl.} 84 | 85 | wclass(UTexture of UObject, header: "Engine/Texture.h", notypedef): 86 | method updateResource() 87 | method getSurfaceWidth(): cfloat {.noSideEffect.} 88 | method getSurfaceHeight(): cfloat {.noSideEffect.} 89 | method createResource(): ptr FTextureResource 90 | method getMaterialType(): EMaterialValueType 91 | method getAverageBrightness(bIgnoreTrueBlack, bUseGrayscale: bool): cfloat 92 | 93 | wclass(UTexture2D of UTexture, header: "Engine/Texture2D.h", notypedef): 94 | proc updateTextureRegions(mipIndex: int32, numRegions: uint32, regions: ptr FUpdateTextureRegion2D, srcPitch: uint32, srcBpp: uint32, srcData: ptr uint8) 95 | 96 | 97 | proc updateTextureRegions*(texture: ptr UTexture2D, numRegions: uint32, regions: ptr FUpdateTextureRegion2D, srcPitch, srcBpp: uint32, srcData: ptr uint8, regionsMayChange: bool = false) = 98 | if not regionsMayChange: 99 | texture.updateTextureRegions(numRegions, regions, srcPitch, srcBpp, srcData) 100 | else: 101 | {.emit: """ 102 | const uint32 regionsSize = `numRegions` * sizeof(FUpdateTextureRegion2D); 103 | FUpdateTextureRegion2D* SrcData = (FUpdateTextureRegion2D*) FMemory::Malloc(regionsSize); 104 | FMemory::Memcpy(SrcData, `regions`, regionsSize); 105 | 106 | auto DataCleanup = [](uint8* InSrcData, const FUpdateTextureRegion2D* Regions) 107 | { 108 | FMemory::Free((void *) Regions); 109 | }; 110 | `texture`->UpdateTextureRegions(0, `numRegions`, SrcData, `srcPitch`, `srcBpp`, `srcData`, DataCleanup); 111 | """.} 112 | 113 | 114 | proc createTransientTexture*(sizeX, sizeY: int32; format: EPixelFormat = pfB8G8R8A8): ptr UTexture2D {. 115 | importcpp: "UTexture2D::CreateTransient(@)", nodecl.} 116 | -------------------------------------------------------------------------------- /modules/core/engine/volume.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | AVolume {.header: "GameFramework/Volume.h", importcpp.} = object of ABrush 5 | 6 | #if WITH_EDITOR 7 | ## Delegate used for notifications when a volumes initial shape changes 8 | declareBuiltinDelegate(FOnVolumeShapeChanged, dkMulticast, "GameFramework/Volume.h", volume: var AVolume) 9 | #endif 10 | 11 | wclass(AVolume of ABrush, header: "GameFramework/Volume.h", notypedef): 12 | ## An editable 3D volume placed in a level. Different types of volumes perform different functions 13 | ## @see https://docs.unrealengine.com/latest/INT/Engine/Actors/Volumes 14 | ## UCLASS(showcategories=Collision, hidecategories=(Brush, Physics), abstract, ConversionRoot) 15 | 16 | #if WITH_EDITOR 17 | proc getOnVolumeShapeChangedDelegate(): var FOnVolumeShapeChanged 18 | ## Function to get the 'Volume imported' delegate 19 | #endif 20 | 21 | proc encompassesPoint(point: FVector, sphereRadius: cfloat, outDistanceToPoint: ptr cfloat): bool 22 | ## @returns true if a sphere/point (with optional radius CheckRadius) overlaps this volume -------------------------------------------------------------------------------- /modules/core/gameplayutils.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | proc spawnSoundAttached*(sound: ptr USoundBase, attachToComponent: ptr USceneComponent, 4 | attachPointName: FName = NAME_None, location: FVector = ForceInit, 5 | rotation: FRotator = zeroRotator, locationType = EAttachLocation.KeepRelativeOffset, 6 | bStopWhenAttachedToDestroyed = false, volumeMultiplier: cfloat = 1.0'f32, pitchMultiplier: cfloat = 1.0'f32, 7 | startTime: cfloat = 0.0'f32, attenuationSettings: ptr USoundAttenuation = nil, 8 | concurrencySettings: ptr USoundConcurrency = nil): ptr UAudioComponent {. 9 | header: "Kismet/GameplayStatics.h", importc: "UGameplayStatics::SpawnSoundAttached".} 10 | ## Plays a sound attached to and following the specified component. This is a fire and forget sound. Replication is also not handled at this point. 11 | ## @param Sound - sound to play 12 | ## @param AttachComponent - Component to attach to. 13 | ## @param AttachPointName - Optional named point within the AttachComponent to play the sound at 14 | ## @param Location - Depending on the value of Location Type this is either a relative offset from the attach component/point or an absolute world position that will be translated to a relative offset 15 | ## @param Rotation - Depending on the value of Location Type this is either a relative offset from the attach component/point or an absolute world rotation that will be translated to a relative offset 16 | ## @param LocationType - Specifies whether Location is a relative offset or an absolute world position 17 | ## @param bStopWhenAttachedToDestroyed - Specifies whether the sound should stop playing when the owner of the attach to component is destroyed. 18 | ## @param VolumeMultiplier - Volume multiplier 19 | ## @param PitchMultiplier - PitchMultiplier 20 | ## @param StartTime - How far in to the sound to begin playback at 21 | ## @param AttenuationSettings - Override attenuation settings package to play sound with 22 | ## @param ConcurrencySettings - Override concurrency settings package to play sound with 23 | ## @return An audio component to manipulate the spawned sound -------------------------------------------------------------------------------- /modules/core/gamestate.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(AGameState of AInfo, header: "GameFramework/GameState.h", notypedef): 4 | var gameModeClass: TSubclassOf[AGameMode] 5 | ## Class of the server's game mode, assigned by GameMode. 6 | ## UPROPERTY(replicatedUsing=OnRep_GameModeClass) 7 | 8 | var authorityGameMode: ptr AGameMode 9 | ## Instance of the current game mode, exists only on the server. For non-authority clients, this will be NULL. 10 | ## UPROPERTY(Transient, BlueprintReadOnly, Category=GameState) 11 | 12 | var spectatorClass: TSubclassOf[ASpectatorPawn] 13 | ## Class used by spectators, assigned by GameMode. 14 | ## UPROPERTY(replicatedUsing=OnRep_SpectatorClass) 15 | 16 | proc getMatchState(): FName {.noSideEffect.} 17 | ## Code to deal with the match state machine 18 | ## Returns the current match state, this is an accessor to protect the state machine flow 19 | 20 | proc hasMatchStarted(): bool {.noSideEffect.} 21 | ## Returns true if the match state is InProgress or later 22 | 23 | proc isMatchInProgress(): bool {.noSideEffect.} 24 | ## Returns true if we're in progress 25 | 26 | proc hasMatchEnded(): bool {.noSideEffect.} 27 | ## Returns true if match is WaitingPostMatch or later 28 | 29 | proc setMatchState(newState: FName) 30 | ## Updates the match state and calls the appropriate transition functions, only valid on server 31 | 32 | var elapsedTime: int32 33 | ## Elapsed game time since match has started. 34 | ## UPROPERTY(replicatedUsing=OnRep_ElapsedTime, BlueprintReadOnly, Category = GameState) 35 | 36 | var playerArray: TArray[ptr APlayerState] 37 | ## Array of all PlayerStates, maintained on both server and clients (PlayerStates are always relevant) 38 | ## UPROPERTY(BlueprintReadOnly, Category=GameState) 39 | 40 | proc onRep_GameModeClass() 41 | ## GameMode class notification callback. 42 | ## UFUNCTION() 43 | 44 | proc onRep_SpectatorClass() 45 | ## Callback when we receive the spectator class 46 | ## UFUNCTION() 47 | 48 | proc onRep_MatchState() 49 | ## Match state has changed 50 | ## UFUNCTION() 51 | 52 | proc onRep_ElapsedTime() 53 | ## Gives clients the chance to do something when time gets updates 54 | ## UFUNCTION() 55 | 56 | 57 | proc getDefaultGameMode(): ptr AGameMode {.noSideEffect.} 58 | ## Helper to return the default object of the GameMode class corresponding to this GameState 59 | 60 | proc receivedGameModeClass() 61 | ## Called when the GameClass property is set (at startup for the server, after the variable has been replicated on clients) 62 | 63 | proc receivedSpectatorClass() 64 | ## Called when the SpectatorClass property is set (at startup for the server, after the variable has been replicated on clients) 65 | 66 | proc seamlessTravelTransitionCheckpoint(bToTransitionMap: bool) 67 | ## Called during seamless travel transition twice (once when the transition map is loaded, once when destination map is loaded) 68 | 69 | proc addPlayerState(playerState: ptr APlayerState) 70 | ## Add PlayerState to the PlayerArray 71 | 72 | proc removePlayerState(playerState: ptr APlayerState) 73 | ## Remove PlayerState from the PlayerArray. 74 | 75 | proc defaultTimer() 76 | ## Called periodically, overridden by subclasses 77 | 78 | proc shouldShowGore(): bool {.noSideEffect.} 79 | ## Should players show gore? 80 | 81 | proc getServerWorldTimeSeconds(): cfloat {.noSideEffect.} 82 | ## Returns the simulated TimeSeconds on the server 83 | ## UFUNCTION(BlueprintCallable, Category=GameState) 84 | 85 | proc updateServerTimeSeconds() 86 | ## Called periodically to update ReplicatedWorldTimeSeconds 87 | 88 | proc onRep_ReplicatedWorldTimeSeconds() 89 | ## Allows clients to calculate ServerWorldTimeSecondsDelta 90 | ## UFUNCTION() 91 | 92 | var replicatedWorldTimeSeconds: cfloat 93 | ## Server TimeSeconds. Useful for syncing up animation and gameplay. 94 | ## UPROPERTY(replicatedUsing=OnRep_ReplicatedWorldTimeSeconds, transient) 95 | 96 | var serverWorldTimeSecondsDelta: cfloat 97 | ## The difference from the local world's TimeSeconds and the server world's TimeSeconds. 98 | ## UPROPERTY(transient) 99 | 100 | var serverWorldTimeSecondsUpdateFrequency: cfloat 101 | ## Frequency that the server updates the replicated TimeSeconds from the world. Set to zero to disable periodic updates. 102 | ## UPROPERTY(EditDefaultsOnly, Category=GameState) 103 | 104 | var timerHandle_DefaultTimer: FTimerHandle 105 | ## Handle for efficient management of DefaultTimer timer 106 | 107 | var timerHandle_UpdateServerTimeSeconds: FTimerHandle 108 | ## Handle for efficient management of the UpdateServerTimeSeconds timer 109 | 110 | var matchState: FName 111 | ## What match state we are currently in 112 | ## UPROPERTY(ReplicatedUsing=OnRep_MatchState, BlueprintReadOnly, VisibleInstanceOnly, Category = GameState) 113 | 114 | var previousMatchState: FName 115 | ## Previous map state, used to handle if multiple transitions happen per frame 116 | ## UPROPERTY(BlueprintReadOnly, VisibleInstanceOnly, Category = GameState) 117 | 118 | proc handleMatchIsWaitingToStart() 119 | ## Called when the state transitions to WaitingToStart 120 | 121 | proc handleMatchHasStarted() 122 | ## Called when the state transitions to InProgress 123 | 124 | proc handleMatchHasEnded() 125 | ## Called when the map transitions to WaitingPostMatch 126 | 127 | proc handleLeavingMap() 128 | ## Called when the match transitions to LeavingMap 129 | -------------------------------------------------------------------------------- /modules/core/info.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(AInfo of AActor, header: "GameFramework/Info.h", notypedef): 4 | ## Info is the base class of an Actor that isn't meant to have a physical 5 | ## representation in the world, used primarily for "manager" type classes 6 | ## that hold settings data about the world, but might need to be an Actor 7 | ## for replication purposes. 8 | 9 | # when defined(WITH_EDITORONLY_DATA) 10 | proc getSpriteComponent(): ptr UBillboardComponent {.noSideEffect.} 11 | ## Returns SpriteComponent subobject 12 | -------------------------------------------------------------------------------- /modules/core/internationalization.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Xored Software, Inc. 2 | 3 | proc getCurrentCultureName*(): FString {.importcpp: "FInternationalization::Get().GetCurrentCulture()->GetName()", header: "Internationalization/Internationalization.h".} 4 | -------------------------------------------------------------------------------- /modules/core/kismet/blueprintasyncactionbase.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Xored Software, Inc. 2 | 3 | wclass(UBlueprintAsyncActionBase of UObject, header: "Kismet/BlueprintAsyncActionBase.h"): 4 | method activate() 5 | ## Called to trigger the action once the delegates have been bound -------------------------------------------------------------------------------- /modules/core/kismet/gameplaystatics.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Xored Software, Inc. 2 | 3 | proc setGlobalTimeDilation*(worldContextObject: ptr UObject, timeDilation: cfloat) {. 4 | header: "Kismet/GameplayStatics.h", importcpp:"UGameplayStatics::SetGlobalTimeDilation(@)".} 5 | 6 | proc getGlobalTimeDilation*(worldContextObject: ptr UObject): cfloat {. 7 | header: "Kismet/GameplayStatics.h", importcpp:"UGameplayStatics::GetGlobalTimeDilation(@)".} -------------------------------------------------------------------------------- /modules/core/logging.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | proc ueFatal*(s: string) {.importcpp: "UE_LOG(LogTemp, Fatal, TEXT(\"%s\"), UTF8_TO_TCHAR((#)->data))", nodecl.} 4 | proc ueError*(s: string) {.importcpp: "UE_LOG(LogTemp, Error, TEXT(\"%s\"), UTF8_TO_TCHAR((#)->data))", nodecl.} 5 | proc ueWarning*(s: string) {.importcpp: "UE_LOG(LogTemp, Warning, TEXT(\"%s\"), UTF8_TO_TCHAR((#)->data))", nodecl.} 6 | proc ueDisplay*(s: string) {.importcpp: "UE_LOG(LogTemp, Display, TEXT(\"%s\"), UTF8_TO_TCHAR((#)->data))", nodecl.} 7 | proc ueLog*(s: string) {.importcpp: "UE_LOG(LogTemp, Log, TEXT(\"%s\"), UTF8_TO_TCHAR((#)->data))", nodecl.} 8 | proc ueVerbose*(s: string) {.importcpp: "UE_LOG(LogTemp, Verbose, TEXT(\"%s\"), UTF8_TO_TCHAR((#)->data))", nodecl.} 9 | proc ueVeryVerbose*(s: string) {.importcpp: "UE_LOG(LogTemp, VeryVerbose, TEXT(\"%s\"), UTF8_TO_TCHAR((#)->data))", nodecl.} 10 | -------------------------------------------------------------------------------- /modules/core/net/connection.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | UNetConnection* {.header: "Engine/NetConnection.h", importcpp: "UNetConnection".} = object of UObject 5 | # TODO -------------------------------------------------------------------------------- /modules/core/net/nettypes.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | ELifetimeCondition {.size: sizeof(cint), importcpp: "ELifetimeCondition", header: "UObject/CoreNet.h".} = enum 5 | ## Secondary condition to check before considering the replication of a lifetime property. 6 | COND_None = 0, ## This property has no condition, and will send anytime it changes 7 | COND_InitialOnly = 1, ## This property will only attempt to send on the initial bunch 8 | COND_OwnerOnly = 2, ## This property will only send to the actor's owner 9 | COND_SkipOwner = 3, ## This property send to every connection EXCEPT the owner 10 | COND_SimulatedOnly = 4, ## This property will only send to simulated actors 11 | COND_AutonomousOnly = 5, ## This property will only send to autonomous actors 12 | COND_SimulatedOrPhysics = 6, ## This property will send to simulated OR bRepPhysics actors 13 | COND_InitialOrOwner = 7, ## This property will send on the initial packet, or to the actors owner 14 | COND_Custom = 8, 15 | ## This property has no particular condition, but wants the ability to toggle on/off via SetCustomIsActiveOverride 16 | COND_Max = 9, 17 | 18 | ELifetimeRepNotifyCondition {.size: sizeof(cint), 19 | importcpp: "ELifetimeRepNotifyCondition", 20 | header: "UObject/CoreNet.h".} = enum 21 | REPNOTIFY_OnChanged = 0, ## Only call the property's RepNotify function if it changes from the local value 22 | REPNOTIFY_Always = 1, ## Always Call the property's RepNotify function when it is received from the server 23 | 24 | wclass(IRepChangedPropertyTracker, header: "UObject/CoreNet.h"): 25 | method setCustomIsActiveOverride(repIndex: uint16, bIsActive: bool) 26 | 27 | wclass(FLifetimeProperty, header: "UObject/CoreNet.h"): 28 | ## This class is used to track a property that is marked to be replicated for the lifetime of the actor channel. 29 | ## This doesn't mean the property will necessarily always be replicated, it just means: 30 | ## "check this property for replication for the life of the actor, and I don't want to think about it anymore" 31 | ## A secondary condition can also be used to skip replication based on the condition results 32 | var repIndex: uint16; 33 | var condition: ELifetimeCondition 34 | var repNotifyCondition: ELifetimeRepNotifyCondition 35 | 36 | proc makeFLifetimeProperty(): FLifetimeProperty {.constructor.} 37 | proc makeFLifetimeProperty(inRepIndex: int32): FLifetimeProperty {.constructor.} 38 | proc makeFLifetimeProperty(inRepIndex: int32, 39 | inCondition: ELifetimeCondition, 40 | inRepNotifyCondition: ELifetimeRepNotifyCondition = REPNOTIFY_OnChanged): FLifetimeProperty {.constructor.} 41 | 42 | proc `==`(other: var FLifetimeProperty) {.noSideEffect.} 43 | 44 | wclass(IOnlinePlatformData, header: "OnlineSubsystemTypes.h"): 45 | proc `==`(other: var IOnlinePlatformData): bool {.noSideEffect.} 46 | proc `!=`(other: var IOnlinePlatformData): bool {.noSideEffect.} 47 | 48 | method getBytes(): ptr uint8 {.noSideEffect.} 49 | ## Get the raw byte representation of this opaque data 50 | ## This data is platform dependent and shouldn't be manipulated directly 51 | ## 52 | ## @return byte array of size GetSize() 53 | 54 | method getSize(): int32 {.noSideEffect.} 55 | ## Get the size of the opaque data 56 | ## 57 | ## @return size in bytes of the data representation 58 | 59 | method isValid(): bool {.noSideEffect.} 60 | ## Check the validity of the opaque data 61 | ## 62 | ## @return true if this is well formed data, false otherwise 63 | 64 | method toString(): FString {.noSideEffect.} 65 | ## Platform specific conversion to string representation of data 66 | ## 67 | ## @return data in string form 68 | 69 | method toDebugString(): FString {.noSideEffect.} 70 | ## Get a human readable representation of the opaque data 71 | ## Shouldn't be used for anything other than logging/debugging 72 | ## 73 | ## @return data in string form 74 | 75 | wclass(FUniqueNetId of IOnlinePlatformData, header: "OnlineSubsystemTypes.h"): 76 | proc getHexEncodedString(): FString {.noSideEffect.} 77 | 78 | wclass(FUniqueNetIdRepl, header: "GameFramework/OnlineReplStructs.h"): 79 | discard 80 | 81 | # TODO: a lot more types -------------------------------------------------------------------------------- /modules/core/paths.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | proc gameContentDir*(): FString {.header: "Misc/Paths.h", importcpp:"FPaths::GameContentDir()".} 4 | proc gameConfigDir*(): FString {.header: "Misc/Paths.h", importcpp:"FPaths::GameConfigDir()".} 5 | proc gameLogDir*(): FString {.header: "Misc/Paths.h", importcpp:"FPaths::GameLogDir()".} 6 | proc gameUserDir*(): FString {.header: "Misc/Paths.h", importcpp:"FPaths::GameUserDir()".} 7 | proc gameSavedDir*(): FString {.header: "Misc/Paths.h", importcpp:"FPaths::GameSavedDir()".} 8 | 9 | # TODO: the rest 10 | 11 | var gEngineIni* {.nodecl, importcpp: "GGameIni".}: FString ## Engine ini filename 12 | var gEditorIni* {.nodecl importcpp: "GEditorIni".}: FString ## Editor ini filename 13 | var gEditorKeyBindingsIni* {.nodecl, importcpp: "GEditorKeyBindingsIni".}: FString ## Editor Key Bindings ini file 14 | var gEditorLayoutIni* {.nodecl, importcpp: "GEditorLayoutIni".}: FString ## Editor UI Layout ini filename 15 | var gEditorSettingsIni* {.nodecl, importcpp: "GEditorSettingsIni".}: FString ## Editor Settings ini filename 16 | 17 | # Editor per-project ini files - stored per project. 18 | var gEditorPerProjectIni* {.nodecl, importcpp: "GEditorPerProjectIni".}: FString ## Editor User Settings ini filename 19 | 20 | var gCompatIni* {.nodecl, importcpp: "GCompatIni".}: FString 21 | var gLightmassIni* {.nodecl, importcpp: "GLightmassIni".}: FString ## Lightmass settings ini filename 22 | var gScalabilityIni* {.nodecl, importcpp: "GScalabilityIni".}: FString ## Scalability settings ini filename 23 | var gInputIni* {.nodecl, importcpp: "GInputIni".}: FString ## Input ini filename 24 | var gGameIni* {.nodecl, importcpp: "GGameIni".}: FString ## Game ini filename 25 | var gGameUserSettingsIni* {.nodecl, importcpp: "GGameUserSettingsIni".}: FString ## User Game Settings ini filename 26 | -------------------------------------------------------------------------------- /modules/core/perfstats.nim: -------------------------------------------------------------------------------- 1 | template declarePerfStatGroup*(name: string) = 2 | {.emit: "DECLARE_STATS_GROUP(TEXT(\"$#\"), STATGROUP_$#, STATCAT_Advanced);".format(name, name).} 3 | 4 | template declarePerfCycleStat*(group: string, name: string) = 5 | {.emit: "DECLARE_CYCLE_STAT(TEXT(\"$#\"), STAT_$#, STATGROUP_$#);".format(name, name, group).} 6 | 7 | template scopeCycleCounter*(name: string) = 8 | {.emit: "SCOPE_CYCLE_COUNTER(STAT_$#);".format(name).} 9 | -------------------------------------------------------------------------------- /modules/core/playercameramanager.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | FCameraCacheEntry* {.header: "Camera/PlayerCameraManager.h", importcpp, size: sizeof(cint).} = object 5 | ## Cached camera POV info, stored as optimization so we only 6 | ## need to do a full camera update once per tick. 7 | timeStamp* {.importcpp: "TimeStamp".}: cfloat 8 | ## World time this entry was created. 9 | POV*: FMinimalViewInfo 10 | ## Camera POV to cache. 11 | 12 | wclass(FTViewTarget, header: "Camera/PlayerCameraManager.h", bycopy): 13 | ## A ViewTarget is the primary actor the camera is associated with. 14 | var target: ptr AActor 15 | ## Target Actor used to compute POV 16 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=TViewTarget) 17 | 18 | var POV: FMinimalViewInfo 19 | ## Computed point of view 20 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=TViewTarget) 21 | 22 | proc setNewTarget(newTarget: ptr AActor) 23 | 24 | proc getTargetPawn(): ptr APawn {.noSideEffect.} 25 | 26 | proc equal(otherTarget: FTViewTarget): bool {.noSideEffect.} 27 | 28 | proc checkViewTarget(owningController: ptr APlayerController) 29 | ## Make sure ViewTarget is valid 30 | 31 | # protected: 32 | var playerState: ptr APlayerState 33 | ## PlayerState (used to follow same player through pawn transitions, etc., when spectating) 34 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=TViewTarget) 35 | 36 | wclass(FViewTargetTransitionParams, header: "Camera/PlayerCameraManager.h", bycopy, notypedef): 37 | proc getBlendAlpha(TimePct: cfloat): cfloat 38 | ## For a given linear blend value (blend percentage), return the final blend alpha with the requested function applied 39 | 40 | # TODO: interface APlayerCameraManager itself -------------------------------------------------------------------------------- /modules/core/slate/arrangedwidget.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FArrangedWidget, header: "SlateCore.h", bycopy): 4 | ## A pair: Widget and its Geometry. Widgets populate an list of WidgetGeometries 5 | ## when they arrange their children. See SWidget::ArrangeChildren. 6 | 7 | proc initFArrangedWidget(inWidget: TSharedRef[SWidget], inGeometry: FGeometry): FArrangedWidget {.constructor.} 8 | 9 | proc toString(): FString {.noSideEffect.} 10 | ## Gets the string representation of the Widget and corresponding Geometry. 11 | ## 12 | ## @return String representation. 13 | 14 | proc `==`(other: FArrangedWidget): bool {.noSideEffect.} 15 | ## Compares this widget arrangement with another for equality. 16 | ## 17 | ## @param Other The other arrangement to compare with. 18 | ## @return true if the two arrangements are equal, false otherwise. 19 | 20 | var geometry: FGeometry 21 | ## The widget's geometry. 22 | 23 | var widget: TSharedRef[SWidget] 24 | ## The widget that is being arranged. 25 | 26 | var nullArrangedWidget* {.importcpp: "FArrangedWidget::NullWidget", header: "SlateCore.h".}: FArrangedWidget 27 | 28 | wclass(FWidgetAndPointer of FArrangedWidget, header: "SlateCore.h", bycopy): 29 | proc initFWidgetAndPointer(): FWidgetAndPointer {.constructor.} 30 | proc initFWidgetAndPointer(inWidget: FArrangedWidget, inPosition: TSharedPtr[FVirtualPointerPosition]): FWidgetAndPointer {.constructor.} 31 | 32 | var pointerPosition: TSharedPtr[FVirtualPointerPosition] 33 | -------------------------------------------------------------------------------- /modules/core/slate/cursorreply.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FCursorReply of TReplyBase[FCursorReply], header: "SlateCore.h"): 4 | ## A reply to the OnQueryCursor event. 5 | 6 | proc getCursorWindow(): TSharedPtr[SWindow] {.noSideEffect.} 7 | ## @return The window to render the Cursor Widget in. 8 | 9 | proc getCursorWidget(): TSharedPtr[SWidget] {.noSideEffect.} 10 | ## @return The custom Cursor Widget to render if set and the event was handled. 11 | 12 | proc getCursorType(): EMouseCursor {.noSideEffect.} 13 | ## @return The requested MouseCursor if no custom widget is set and the event was handled. 14 | 15 | proc setCursorWidget(inCursorWindow: TSharedPtr[SWindow], inCursorWidget: TSharedPtr[SWidget]) 16 | ## Set the Cursor Widget, used by slate application to set the cursor widget if the MapCursor returns a widget. 17 | 18 | proc unhandledFCursorReply*(): FCursorReply {.importcpp: "FCursorReply::Unhandled()", header: "SlateCore.h", noSideEffect.} 19 | ## Makes a NULL response meaning no prefersce. 20 | ## i.e. If your widget returns this, its parent will get to decide what the cursor shoudl be. 21 | ## This is the default behavior for a widget. 22 | 23 | proc initCursorReply*(inCursor: EMouseCursor): FCursorReply {.importcpp: "FCursorReply::Cursor(@)", header: "SlateCore.h", noSideEffect.} 24 | ## Respond with a specific cursor. 25 | ## This cursor will be used and no other widgets will be asked. 26 | -------------------------------------------------------------------------------- /modules/core/slate/hittestgrid.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(ICustomHitTestPath, header: "Input/HittestGrid.h"): 4 | method getBubblePathAndVirtualCursors(inGeometry: FGeometry, desktopSpaceCoordinate: FVector2D, bIgnoreEnabledStatus: bool): TArray[FWidgetAndPointer] 5 | 6 | method arrangeChildren(arrangedChildren: FArrangedChildren) 7 | 8 | method translateMouseCoordinateFor3DChild(childWidget: TSharedRef[SWidget], viewportGeometry: FGeometry, 9 | screenSpaceMouseCoordinate: FVector2D, lastScreenSpaceMouseCoordinate: FVector2D): TSharedPtr[FVirtualPointerPosition] 10 | 11 | wclass(FHittestGrid, header: "Input/HittestGrid.h", bycopy): 12 | proc initFHittestGrid(): FHittestGrid 13 | 14 | proc getBubblePath(desktopSpaceCoordinate: FVector2D, cursorRadius: float32, bIgnoreEnabledStatus: bool): TArray[FWidgetAndPointer] 15 | ## Given a Slate Units coordinate in virtual desktop space, perform a hittest 16 | ## and return the path along which the corresponding event would be bubbled. 17 | 18 | proc clearGridForNewFrame(hittestArea: FSlateRect) 19 | ## Clear the hittesting area and prepare to execute a new frame. 20 | ## Depending on monitor arrangement, the area to be hittested could begin 21 | ## in the negative coordinates. 22 | ## 23 | ## @param HittestArea Size in Slate Units of the area we are considering for hittesting. 24 | 25 | proc insertWidget(parentHittestIndex: int32, visibility: EVisibility, widget: FArrangedWidget, 26 | inWindowOffset: FVector2D, inClippingRect: FSlateRect): int32 27 | ## Add Widget into the hittest data structure so that we can later make queries about it. 28 | 29 | proc insertCustomHitTestPath(customHitTestPath: TSharedRef[ICustomHitTestPath], widgetIndex: int32) 30 | 31 | proc findNextFocusableWidget(startingWidget: FArrangedWidget, direction: EUINavigation, 32 | navigationReply: FNavigationReply, ruleWidget: FArrangedWidget): TSharedPtr[SWidget] 33 | ## Finds the next focusable widget by searching through the hit test grid 34 | ## 35 | ## @param StartingWidget This is the widget we are starting at, and navigating from. 36 | ## @param Direction The direction we should search in. 37 | ## @param NavigationReply The Navigation Reply to specify a boundary rule for the search. 38 | ## @param RuleWidget The Widget that is applying the boundary rule, used to get the bounds of the Rule. 39 | -------------------------------------------------------------------------------- /modules/core/slate/itooltip.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(IToolTip, header: "SlateCore.h"): 4 | ## Interface for tool tips. 5 | method asWidget(): TSharedRef[SWidget] 6 | ## Gets the widget that this tool tip represents. 7 | ## 8 | ## @return The tool tip widget. 9 | 10 | method getContentWidget(): TSharedRef[SWidget] 11 | ## Gets the tool tip's content widget. 12 | ## 13 | ## @return The content widget. 14 | 15 | method setContentWidget(inContentWidget: TSharedRef[SWidget]) 16 | ## Sets the tool tip's content widget. 17 | ## 18 | ## @param InContentWidget The new content widget to set. 19 | 20 | method isEmpty(): bool 21 | ## Checks whether this tool tip has no content to display right now. 22 | ## 23 | ## @return true if the tool tip has no content to display, false otherwise. 24 | 25 | method isInteractive() 26 | ## Checks whether this tool tip can be made interactive by the user (by holding Ctrl). 27 | ## 28 | ## @return true if it is an interactive tool tip, false otherwise. 29 | 30 | method onOpening() 31 | ## Called when the tooltip widget is about to be requested for opening. 32 | 33 | method onClosed() 34 | ## Called when the tooltip widget is closed and the tooltip is no longer needed. 35 | -------------------------------------------------------------------------------- /modules/core/slate/margin.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FMargin, header: "SlateCore.h", bycopy): 4 | ## Describes the space around a Widget. 5 | var left: float32 6 | ## Holds the margin to the left. 7 | var top: float32 8 | ## Holds the margin to the top. 9 | var right: float32 10 | ## Holds the margin to the right. 11 | var bottom: float32 12 | ## Holds the margin to the bottom. 13 | 14 | proc initFMargin(): FMargin {.constructor.} 15 | ## Default constructor. 16 | ## 17 | ## The default margin size is zero on all four sides.. 18 | 19 | proc initFMargin(unifromMargin: float32): FMargin {.constructor.} 20 | ## Construct a Margin with uniform space on all sides 21 | 22 | proc initFMargin(horizontal, vertical: float32): FMargin {.constructor.} 23 | ## Construct a Margin where Horizontal describes Left and Right spacing while Vertical describes Top and Bottom spacing 24 | 25 | proc initFMargin(inLeft, inTop, inRight, inBottom: float32): FMargin {.constructor.} 26 | ## Construct a Margin where the spacing on each side is individually specified. 27 | 28 | # provide versions with Nim-friendly names, too 29 | proc margin(): FMargin {.constructor.} 30 | ## Default constructor. 31 | ## 32 | ## The default margin size is zero on all four sides.. 33 | 34 | proc margin(unifromMargin: float32): FMargin {.constructor.} 35 | ## Construct a Margin with uniform space on all sides 36 | 37 | proc margin(horizontal, vertical: float32): FMargin {.constructor.} 38 | ## Construct a Margin where Horizontal describes Left and Right spacing while Vertical describes Top and Bottom spacing 39 | 40 | proc margin(inLeft, inTop, inRight, inBottom: float32): FMargin {.constructor.} 41 | ## Construct a Margin where the spacing on each side is individually specified. 42 | 43 | proc `*`(scale: float32): FMargin {.noSideEffect.} 44 | ## Multiply the margin by a scalar. 45 | ## 46 | ## @param Scale How much to scale the margin. 47 | ## @return An FMargin where each value is scaled by Scale. 48 | 49 | proc `+`(inDelta: FMargin): FMargin {.noSideEffect.} 50 | ## Adds another margin to this margin. 51 | ## 52 | ## @param Other The margin to add. 53 | ## @return A margin that represents this margin plus the other margin. 54 | 55 | proc `-`(other: FMargin): FMargin {.noSideEffect.} 56 | ## Subtracts another margin from this margin. 57 | ## 58 | ## @param Other The margin to subtract. 59 | ## @return A margin that represents this margin minues the other margin. 60 | 61 | proc `==`(other: FMargin): bool {.noSideEffect.} 62 | ## Compares this margin with another for equality. 63 | ## 64 | ## @param Other The other margin. 65 | ## @return true if the two margins are equal, false otherwise. 66 | 67 | proc `!=`(other: FMargin): bool {.noSideEffect.} 68 | ## Compares this margin with another for inequality. 69 | ## 70 | ## @param Other The other margin. 71 | ## @return true if the two margins are not equal, false otherwise. 72 | 73 | proc getDesiredSize(): FVector2D {.noSideEffect.} 74 | ## Gets the margin's total size. 75 | ## 76 | ## @return Cumulative margin size. 77 | 78 | proc getTotalSpaceAlong(): float32 {.noSideEffect.} 79 | ## Gets the total horizontal or vertical margin. 80 | ## 81 | ## @return Cumulative horizontal margin. 82 | -------------------------------------------------------------------------------- /modules/core/slate/navigationreply.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | EUINavigationRule* {.importcpp, header: "SlateCore.h", pure, size: sizeof(uint8).} = enum 5 | Escape, 6 | ## Allow the movement to continue in that direction, seeking the next navigable widget automatically. 7 | Explicit, 8 | ## Move to a specific widget. 9 | Wrap, 10 | ## Wrap movement inside this container, causing the movement to cycle around from the opposite side, 11 | ## if the navigation attempt would have escaped. 12 | Stop, 13 | ## Stops movement in this direction 14 | Custom, 15 | ## Custom navigation handled by user code. 16 | Invalid 17 | ## Invalid Rule 18 | 19 | declareBuiltinDelegate(FNavigationDelegate, dkSimpleRetVal, "SlateCore.h", TSharedPtr[SWidget], nav: EUINavigation) 20 | 21 | wclass(FNavigationReply, header: "SlateCore.h"): 22 | ## A FNavigationReply is something that a Slate navigation event returns to the system to notify it about the boundary rules for navigation. 23 | ## For example, a widget may handle an OnNavigate event by asking the system to wrap if it's boundary is hit. 24 | ## To do this, return FNavigationReply::Wrap(). 25 | 26 | proc getHandler(): TSharedPtr[SWidget] 27 | ## The widget that ultimately specified the boundary rule for the navigation 28 | 29 | proc getBoundaryRule(): EUINavigationRule 30 | ## Get the navigation boundary rule. 31 | 32 | proc getFocusRecipient(): TSharedPtr[SWidget] 33 | ## If the event replied with a constant explicit boundary rule this returns the desired focus recipient. 34 | ## Otherwise returns an invalid pointer. 35 | 36 | proc getFocusDelegate(): FNavigationDelegate 37 | ## If the event replied with a delegate explicit boundary rule this returns the delegate to get the focus recipient. 38 | ## Delegate will be unbound if a constant widget was provided. 39 | 40 | proc explicitNavigationReply*(inFocusRecipient: TSharedPtr[SWidget]): FNavigationReply {.importcpp: "FNavigationReply::Explicit(@)", header: "SlateCore.h".} 41 | ## An event should return a FNavigationReply::Explicit() to let the system know to navigate to an explicit widget at the bounds of this widget. 42 | 43 | proc customNavigationReply*(inFocusDelegate: FNavigationDelegate): FNavigationReply {.importcpp: "FNavigationReply::Custom(@)", header: "SlateCore.h".} 44 | ## An event should return a FNavigationReply::Custom() to let the system know to call a custom delegate to get the widget to navigate to. 45 | proc wrapNavigationReply*(): FNavigationReply {.importcpp: "FNavigationReply::Wrap(@)", header: "SlateCore.h".} 46 | ## An event should return a FNavigationReply::Wrap() to let the system know to wrap at the bounds of this widget. 47 | proc stopNavigationReply*(): FNavigationReply {.importcpp: "FNavigationReply::Stop(@)", header: "SlateCore.h".} 48 | ## An event should return a FNavigationReply::Stop() to let the system know to stop at the bounds of this widget. 49 | proc escapeNavigationReply*(): FNavigationReply {.importcpp: "FNavigationReply::Escape(@)", header: "SlateCore.h".} 50 | ## An event should return a FNavigationReply::Escape() to let the system know that a navigation can escape the bounds of this widget. 51 | -------------------------------------------------------------------------------- /modules/core/slate/popupmethodreply.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | EPopupMethod* {.importcpp, header: "Input/PopupMethodReply.h", pure, size: sizeof(uint8).} = enum 5 | CreateNewWindow, 6 | ## Creating a new window allows us to place popups outside of the window in which the menu anchor resides. 7 | UseCurrentWindow 8 | ## Place the popup into the current window. Applications that intend to run in fullscreen cannot create new windows, so they must use this method.. 9 | 10 | EShouldThrottle* {.importcpp, header: "Input/PopupMethodReply.h", pure, size: sizeof(uint8).} = enum 11 | No, 12 | Yes 13 | 14 | wclass(FPopupMethodReply of TReplyBase[FPopupMethodReply], header: "Input/PopupMethodReply.h"): 15 | ## Reply informs Slate how it should express the popup: by creating a new window or by reusing the existing window. 16 | 17 | proc setShouldThrottle(inShouldThrottle: EShouldThrottle): var FPopupMethodReply {.discardable.} 18 | ## Specify whether we should throttle the engine ticking s.t. the UI is most responsive when this popup is up. 19 | 20 | proc getShouldThrottle(): EShouldThrottle 21 | ## Should we throttle the engine? 22 | 23 | proc GetPopupMethod(): EPopupMethod {.noSideEffect.} 24 | ## Which method to use for the popup: new window or reuse current window 25 | 26 | proc isSet(): bool 27 | ## Alias for IsEventHandled for situations where this is used as optional 28 | 29 | proc initFPopupMethodReply(): FPopupMethodReply {.constructor.} 30 | 31 | proc unhandledFPopupMethodReply*(): FPopupMethodReply {.importcpp: "FPopupMethodReply::Unhandled()", header: "Input/PopupMethodReply.h".} 32 | ## Create a reply that signals not having an opinion about the popup method 33 | 34 | proc useMethodReply*(withMethod: EPopupMethod): FPopupMethodReply{.importcpp: "FPopupMethodReply::UseMethod(@)", header: "Input/PopupMethodReply.h".} 35 | ## Create a reply that specifies how a popup should be handled. 36 | -------------------------------------------------------------------------------- /modules/core/slate/replybase.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FReplyBase, header: "SlateCore.h"): 4 | proc isEventHandled(): bool {.noSideEffect.} 5 | ## @return true if this this reply is a result of the event being handled; false otherwise. 6 | 7 | proc getHandler(): TSharedPtr[SWidget] {.noSideEffect.} 8 | ## The widget that ultimately handled the event 9 | 10 | # protected: 11 | 12 | proc initFReplyBase(inIsHandled: bool): FReplyBase {.constructor.} 13 | ## A reply can be handled or unhandled. 14 | ## Any widget handling events decides whether it has handled the event. 15 | 16 | var bIsHandled: bool 17 | ## Has a widget handled an event. 18 | 19 | var eventHandler: TSharedPtr[SWidget] 20 | ## Widget that handled the event that generated this reply. 21 | 22 | wclass(TReplyBase[ReplyType] of FReplyBase, header: "SlateCore.h"): 23 | proc initTReplyBase(bIsHandled: bool): TReplyBase {.constructor.} 24 | 25 | # protected: 26 | proc setHandler(inHandler: TSharedRef[SWidget]): var ReplyType 27 | ## Set the widget that handled the event; undefined if never handled. 28 | ## This method is to be used by SlateApplication only! 29 | 30 | proc me(): var ReplyType 31 | ## @return a reference to this reply 32 | 33 | wclass(FNoReply of TReplyBase[FNoReply], header: "SlateCore.h"): 34 | ## A reply type for events that return a void reply. e.g. OnMouseLeave() 35 | proc initFNoReply(): FNoReply {.constructor.} 36 | 37 | proc unhandledFNoReply*(): FNoReply {.noSideEffect, importcpp: "FNoReply::Unhandled()", header: "SlateCore.h".} 38 | -------------------------------------------------------------------------------- /modules/core/slate/sboxpanel.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FBoxPanelSlot of TSlotBase[FBoxPanelSlot], header: "SlateCore.h", cppname: "SBoxPanel::Slot"): 4 | var sizeParam: FSizeParam 5 | ## How much space this slot should occupy along panel's direction. 6 | ## When SizeRule is SizeRule_Auto, the widget's DesiredSize will be used as the space required. 7 | ## When SizeRule is SizeRule_Stretch, the available space will be distributed proportionately between 8 | ## peer Widgets depending on the Value property. Available space is space remaining after all the 9 | ## peers' SizeRule_Auto requirements have been satisfied. 10 | 11 | var hAlignment: EHorizontalAlignment 12 | ## Horizontal positioning of child within the allocated slot 13 | 14 | var vAlignment: EVerticalAlignment 15 | ## Vertical positioning of child within the allocated slot 16 | 17 | var slotPadding: TAttribute[FMargin] 18 | ## The padding to add around the child. 19 | 20 | var maxSize: TAttribute[float] 21 | ## The max size that this slot can be (0 if no max) 22 | 23 | proc `[]`(inChildWidget: TSharedRef[SWidget]): var FBoxPanelSlot 24 | 25 | wclass(SBoxPanel of SPanel, header: "SlateCore.h"): 26 | ## A BoxPanel contains one child and describes how that child should be arranged on the screen. 27 | 28 | proc removeSlot[W: SWidget](slotWidget: TSharedRef[W]): int32 29 | ## Removes a slot from this box panel which contains the specified SWidget 30 | ## 31 | ## @param SlotWidget The widget to match when searching through the slots 32 | ## @returns The index in the children array where the slot was removed and -1 if no slot was found matching the widget 33 | 34 | proc clearChildren() 35 | ## Removes all children from the box. 36 | 37 | wclass(FHorizontalBoxSlot of FBoxPanelSlot, header: "SlateCore.h", cppname: "SHorizontalBox::Slot"): 38 | proc initFHorizontalBoxSlot(): FHorizontalBoxSlot {.constructor.} 39 | 40 | proc autoWidth(): var FHorizontalBoxSlot {.discardable.} 41 | proc maxWidth(inMaxWidth: TAttribute[float32]): var FHorizontalBoxSlot {.discardable.} 42 | proc fillWidth(stretchCoefficient: TAttribute[float32]): var FHorizontalBoxSlot {.discardable.} 43 | 44 | proc hAlign(inHAlignment: EHorizontalAlignment): var FHorizontalBoxSlot {.discardable.} 45 | proc vAlign(inVAlignment: EVerticalAlignment): var FHorizontalBoxSlot {.discardable.} 46 | 47 | proc padding(uniform: float32): var FHorizontalBoxSlot {.discardable.} 48 | proc padding(horizontal, vertical: float32): var FHorizontalBoxSlot {.discardable.} 49 | proc padding(left, top, right, bottom: float32): var FHorizontalBoxSlot {.discardable.} 50 | proc padding(inPadding: TAttribute[FMargin]): var FHorizontalBoxSlot {.discardable.} 51 | 52 | proc `[]`(inWidget: TSharedRef[SWidget]): var FHorizontalBoxSlot {.discardable.} 53 | proc expose(outVarToInit: var ptr FHorizontalBoxSlot): var FHorizontalBoxSlot {.discardable.} 54 | 55 | proc newFHorizontalBoxSlot*(): ptr FHorizontalBoxSlot {.importcpp: "(& SHorizontalBox::Slot())", header: "SlateCore.h".} 56 | 57 | wclass(SHorizontalBox of SBoxPanel, header: "SlateCore.h"): 58 | ## A Horizontal Box Panel. See SBoxPanel for more info. 59 | 60 | var fVisibility {.cppname: "_Visibility".}: EVisibility 61 | 62 | proc visibility(visibility: EVisibility): var SHorizontalBox 63 | ## Sets visibility 64 | 65 | proc addSlot(): var FHorizontalBoxSlot 66 | proc insertSlot(index: int32 = INDEX_NONE): var FHorizontalBoxSlot 67 | proc numSlots(): int32 {.noSideEffect.} 68 | 69 | wclass(FVerticalBoxSlot of FBoxPanelSlot, header: "SlateCore.h", cppname: "SHorizontalBox::Slot"): 70 | proc initFVerticalBoxSlot(): FVerticalBoxSlot {.constructor.} 71 | 72 | proc autoHeight(): var FVerticalBoxSlot {.discardable.} 73 | proc maxHeight(inMaxHeight: TAttribute[float32]): var FVerticalBoxSlot {.discardable.} 74 | proc fillHeight(stretchCoefficient: TAttribute[float32]): var FVerticalBoxSlot {.discardable.} 75 | 76 | proc hAlign(inHAlignment: EHorizontalAlignment): var FVerticalBoxSlot {.discardable.} 77 | proc vAlign(inVAlignment: EVerticalAlignment): var FVerticalBoxSlot {.discardable.} 78 | 79 | proc padding(uniform: float32): var FVerticalBoxSlot {.discardable.} 80 | proc padding(horizontal, vertical: float32): var FVerticalBoxSlot {.discardable.} 81 | proc padding(left, top, right, bottom: float32): var FVerticalBoxSlot {.discardable.} 82 | proc padding(inPadding: TAttribute[FMargin]): var FVerticalBoxSlot {.discardable.} 83 | 84 | proc `[]`(inWidget: TSharedRef[SWidget]): var FVerticalBoxSlot {.discardable.} 85 | proc expose(outVarToInit: var ptr FVerticalBoxSlot): var FVerticalBoxSlot {.discardable.} 86 | 87 | proc newFVerticalBoxSlot*(): ptr FVerticalBoxSlot {.importcpp: "(& SVerticalBox::Slot())", header: "SlateCore.h".} 88 | 89 | wclass(SVerticalBox of SBoxPanel, header: "SlateCore.h"): 90 | ## A Vertical Box Panel. See SBoxPanel for more info. 91 | var fVisibility {.cppname: "_Visibility".}: EVisibility 92 | proc visibility(visibility: EVisibility): var SHorizontalBox 93 | ## Sets visibility 94 | 95 | proc addSlot(): var FHorizontalBoxSlot 96 | proc insertSlot(index: int32 = INDEX_NONE): var FHorizontalBoxSlot 97 | proc numSlots(): int32 {.noSideEffect.} 98 | -------------------------------------------------------------------------------- /modules/core/slate/scompoundwidget.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(SCompoundWidget of SWidget, header: "SlateCore.h", notypedef): 4 | ## A CompoundWidget is the base from which most non-primitive widgets should be built. 5 | ## CompoundWidgets have a protected member named ChildSlot. 6 | proc getContentScale(): FVector2D 7 | ## Returns the size scaling factor for this widget. 8 | ## 9 | ## @return Size scaling factor. 10 | 11 | proc setContentScale(inContentScale: TAttribute[FVector2D]) 12 | ## Sets the content scale for this widget. 13 | ## 14 | ## @param InContentScale Content scaling factor. 15 | 16 | proc getColorAndOpacity(): FLinearColor 17 | ## Gets the widget's color. 18 | 19 | proc setColorAndOpacity(inColorAndOpacity: TAttribute[FLinearColor]) 20 | ## Sets the widget's color. 21 | ## 22 | ## @param InColorAndOpacity The ColorAndOpacity to be applied to this widget and all its contents. 23 | 24 | proc setForegroundColor(inForegroundColor: TAttribute[FSlateColor]) 25 | ## Sets the widget's foreground color. 26 | ## 27 | ## @param InColor The color to set. 28 | 29 | # protected: 30 | 31 | var childSlot: FSimpleSlot 32 | ## The slot that contains this widget's descendants. 33 | 34 | var contentScale: TAttribute[FVector2D] 35 | ## The layout scale to apply to this widget's contents; useful for animation. 36 | 37 | var colorAndOpacity: TAttribute[FLinearColor] 38 | ## The color and opacity to apply to this widget and all its descendants. 39 | 40 | var foregroundColor: TAttribute[FSlateColor] 41 | ##Optional foreground color that will be inherited by all of this widget's contents -------------------------------------------------------------------------------- /modules/core/slate/slate.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | ISlateMetaData* {.header: "SlateCore.h", importcpp, inheritable.} = object 5 | FNavigationMetaData* {.header: "SlateCore.h", importcpp.} = object of ISlateMetaData 6 | FPaintArgs* {.header: "SlateCore.h", importcpp, bycopy.} = object 7 | 8 | FSlotBase* {.header: "SlateCore.h", importcpp, inheritable, bycopy.} = object 9 | FArrangedChildren* {.header: "SlateCore.h", importcpp.} = object 10 | FWidgetPath* {.header: "SlateCore.h", importcpp, bycopy.} = object 11 | FChildren* {.header: "SlateCore.h", importcpp.} = object 12 | FGeometry* {.header: "SlateCore.h", importcpp.} = object 13 | FSlateRect* {.header: "SlateCore.h", importcpp, bycopy.} = object 14 | FSimpleSlot* {.header: "SlateCore.h", importcpp, bycopy.} = object 15 | 16 | FDragDropEvent* {.header: "SlateCore.h", importcpp, bycopy.} = object 17 | FDragDropOperation* {.importcpp, header: "SlateCore.h", importcpp, bycopy.} = object 18 | 19 | FSlateWindowElementList* {.header: "SlateCore.h", importcpp, bycopy.} = object 20 | FWidgetStyle* {.header: "SlateCore.h", importcpp, bycopy.} = object 21 | FSlateBrush* {.header: "SlateCore.h", importcpp.} = object 22 | FSlateFontInfo* {.header: "SlateCore.h", importcpp, bycopy.} = object 23 | 24 | FCachedWidgetNode* {.header: "Layout/WidgetCaching.h", importcpp, bycopy.} = object 25 | FWeakWidgetPath* {.header: "SlateCore.h", importcpp, bycopy.} = object 26 | FWindowStyle* {.header: "SlateCore.h", importcpp, bycopy.} = object 27 | 28 | FSlateSound* {.header: "SlateCore.h", importcpp, bycopy.} = object 29 | 30 | FSlateRenderTransform* = FTransform2D 31 | 32 | type 33 | SWidget* {.header: "SlateCore.h", importcpp, inheritable.} = object 34 | 35 | SLeafWidget* {.header: "SlateCore.h", importcpp, inheritable.} = object of SWidget 36 | SCompoundWidget* {.header: "SlateCore.h", importcpp, inheritable.} = object of SWidget 37 | SWindow* {.header: "SlateCore.h", importcpp, inheritable.} = object of SCompoundWidget 38 | SUserWidget* {.header: "SlateCore.h", importcpp, inheritable.} = object of SCompoundWidget 39 | 40 | SPanel* {.header: "SlateCore.h", importcpp, inheritable.} = object of SWidget 41 | # panel is not wrapped on purpose - it only overrides SWidget methods, 42 | # not providing anything new 43 | 44 | SOverlay* {.header: "SlateCore.h", importcpp, inheritable.} = object of SPanel 45 | 46 | type 47 | ISlateViewport* {.header: "SlateCore.h", importcpp, inheritable.} = object 48 | # TODO 49 | 50 | var nullWidget* {.importcpp: "SNullWidget::NullWidget", header: "SlateCore.h".}: TSharedRef[SWidget] 51 | 52 | proc slateNew*[W: SWidget](): TSharedRef[W] {.importcpp: "SNew('*0)", header: "SlateCore.h".} 53 | 54 | include visibility 55 | include slatecolor 56 | include enums 57 | include structs 58 | include margin 59 | include slatewidgetstyle 60 | include slatetypes 61 | include itooltip 62 | include slatelayouttransform 63 | 64 | declareBuiltinDelegate(FWidgetActiveTimerDelegate, dkSimpleRetVal, "SlateCore.h", 65 | EActiveTimerReturnType, inCurrentTime: float64, inDeltaTime: float32) 66 | 67 | include events 68 | include virtualkeyboardentry 69 | 70 | include curvesequence 71 | 72 | # replies 73 | include replybase 74 | include reply 75 | include cursorreply 76 | include popupmethodreply 77 | include navigationreply 78 | 79 | include slateapplicationbase 80 | include slateapplication 81 | 82 | include arrangedwidget 83 | include widget 84 | include slotbase 85 | include soverlay 86 | include hittestgrid 87 | 88 | include scompoundwidget 89 | include sboxpanel 90 | include swindow 91 | 92 | include swidgetswitcher 93 | 94 | # TODO: many classes not wrapped 95 | -------------------------------------------------------------------------------- /modules/core/slate/slateapplication.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FSlateApplication, header: "Framework/Application/SlateApplication.h", bycopy): 4 | proc setAllUserFocusToGameViewport(reasonFocusIsChanging = EFocusCause.SetDirectly) 5 | ## Sets all users focus to the SWidget representing the currently active game viewport 6 | 7 | proc getDragTriggerDistance(): float32 {.noSideEffect.} 8 | ## @return the deadzone size for dragging in screen pixels (aka virtual desktop pixels) 9 | 10 | proc setDragTriggerDistance(screenPixels: float32) 11 | ## Set the size of the deadzone for dragging in screen pixels 12 | 13 | proc getFSlateApplication*(): ptr FSlateApplication {. 14 | importcpp: "(& FSlateApplication::Get())", header: "Framework/Application/SlateApplication.h".} 15 | ## Returns the current instance of the application. The application should have been initialized before 16 | ## this method is called 17 | ## 18 | ## @return Reference to the application 19 | -------------------------------------------------------------------------------- /modules/core/slate/slateapplicationbase.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(IWindowTitleBar, header: "SlateCore.h"): 4 | ## Interface for window title bars. 5 | method flash() 6 | 7 | # TODO -------------------------------------------------------------------------------- /modules/core/slate/slatecolor.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | ESlateColorStylingMode* {.importcpp: "ESlateColorStylingMode::Type", header: "SlateCore.h", pure.} = enum 5 | ## Enumerates types of color values that can be held by Slate color. 6 | ## 7 | ## Should we use the specified color? If not, then which color from the style should we use. 8 | UseColor_Specified, 9 | ## Color value is stored in this Slate color. 10 | UseColor_Specified_Link, 11 | ## Color value is stored in the linked color. 12 | UseColor_Foreground, 13 | ## Use the widget's foreground color. 14 | UseColor_Foreground_Subdued 15 | ## Use the widget's subdued color. 16 | 17 | wclass(FSlateColor, header: "SlateCore.h", bycopy): 18 | ## A Slate color can be a directly specified value, or the color can be pulled from a WidgetStyle. 19 | proc initFSlateColor(): FSlateColor {.constructor.} 20 | ## Default constructor. 21 | ## 22 | ## Uninitialized Slate colors are Fuchsia by default. 23 | proc initFSlateColor(inColor: FLinearColor): FSlateColor {.constructor.} 24 | ## Creates a new Slate color with the specified values. 25 | ## 26 | ## @param InColor The color value to assign. 27 | proc initFSlateColor(inColor: TSharedRef[FLinearColor]): FSlateColor {.constructor.} 28 | ## Creates a new Slate color that is linked to the given values. 29 | ## 30 | ## @param InColor The color value to assign. 31 | proc getColor(inWidgetStyle: FWidgetStyle): FLinearColor {.noSideEffect.} 32 | ## Gets the color value represented by this Slate color. 33 | ## 34 | ## @param InWidgetStyle The widget style to use when this color represents a foreground or subdued color. 35 | ## @return The color value. 36 | ## @see GetSpecifiedColor 37 | 38 | proc getSpecifiedColor(): FLinearColor {.noSideEffect.} 39 | ## Gets the specified color value. 40 | ## 41 | ## @return The specified color value. 42 | ## @see GetColor, IsColorSpecified 43 | 44 | proc isColorSpecified(): bool {.noSideEffect.} 45 | ## Checks whether the values for this color have been specified. 46 | ## 47 | ## @return true if specified, false otherwise. 48 | ## @see GetSpecifiedColor 49 | 50 | proc `==`(other: FSlateColor): bool {.noSideEffect.} 51 | ## Compares this color with another for equality. 52 | ## 53 | ## @param Other The other color. 54 | ## 55 | ## @return true if the two colors are equal, false otherwise. 56 | 57 | proc `!=`(other: FSlateColor): bool {.noSideEffect.} 58 | ## Compares this color with another for inequality. 59 | ## 60 | ## @param Other The other color. 61 | ## 62 | ## @return false if the two colors are equal, true otherwise. 63 | 64 | proc serializeFromMismatchedTag(tag: FPropertyTag, ar: var FArchive): bool 65 | ## Used to upgrade an FColor or FLinearColor property to an FSlateColor property 66 | 67 | proc initUseForegroundColor*(): FSlateColor {.importcpp: "FSlateColor::UseForeground()", header: "SlateCore.h".} 68 | ## @returns an FSlateColor that is the widget's foreground. 69 | 70 | proc initUseSubduedForeground*(): FSlateColor {.importcpp: "FSlateColor::UseSubduedForeground()", header: "SlateCore.h".} 71 | ## @returns an FSlateColor that is the subdued version of the widget's foreground. 72 | -------------------------------------------------------------------------------- /modules/core/slate/slatelayouttransform.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FSlateLayoutTransform, header: "Rendering/SlateLayoutTransform.h", bycopy): 4 | ## Represents a 2D transformation in the following order: scale then translate. 5 | ## Used by FGeometry for it's layout transformations. 6 | ## 7 | ## Matrix form looks like: 8 | ## [Vx Vy 1] * [ S 0 0 ] 9 | ## [ 0 S 0 ] 10 | ## [ Tx Ty 1 ] 11 | ## 12 | proc initFSlateLayoutTransform(inScale: float32 = 1.0'f32, inTranslation = initFVector2D(ForceInit)): FSlateLayoutTransform {.constructor.} 13 | ## Ctor from a scale followed by translate. Shortcut to Concatenate(InScale, InTranslation). 14 | 15 | proc initFSlateLayoutTransform(inTranslation: FVector2D, inScale: float32 = 1.0'f32): FSlateLayoutTransform {.constructor.} 16 | ## Ctor from a 2D translation followed by a scale. Shortcut to Concatenate(InTranslation, InScale). 17 | ## While this is the opposite order we internally store them, we can represent this correctly. 18 | 19 | proc getTranslation(): FVector2D {.noSideEffect.} 20 | ## Access to the 2D translation 21 | 22 | proc getScale(): float32 {.noSideEffect.} 23 | ## Access to the scale. 24 | 25 | proc toMatrix(): FMatrix {.noSideEffect.} 26 | ## Support for converting to an FMatrix. 27 | 28 | proc transformPoint(point: FVector2D): FVector2D 29 | ## 2D transform support. 30 | 31 | proc transformVector(vector: FVector2D): FVector2D 32 | ## 2D transform support. 33 | 34 | proc concatenate(rhs: FSlateLayoutTransform): FSlateLayoutTransform {.noSideEffect.} 35 | ## This works by transforming the origin through LHS then RHS. 36 | ## In matrix form, looks like this: 37 | ## [ Sa 0 0 ] [ Sb 0 0 ] 38 | ## [ 0 Sa 0 ] * [ 0 Sb 0 ] 39 | ## [ Tax Tay 1 ] [ Tbx Tby 1 ] 40 | 41 | proc inverse(): FSlateLayoutTransform {.noSideEffect.} 42 | ## Invert the transform/scale. 43 | 44 | proc `==`(other: FSlateLayoutTransform): bool {.noSideEffect.} 45 | proc `!=`(other: FSlateLayoutTransform): bool {.noSideEffect.} 46 | -------------------------------------------------------------------------------- /modules/core/slate/slatetypes.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | EConsumeMouseWheel* {.importcpp, header: "SlateCore.h", pure.} = enum 5 | ## Used to determine how we should handle mouse wheel input events when someone scrolls. 6 | WhenScrollingPossible, 7 | ## Only consume the mouse wheel event when we actually scroll some amount. 8 | Always, 9 | ## Always consume mouse wheel event even if we don't scroll at all. 10 | Never, 11 | ## Never consume the mouse wheel 12 | 13 | ESlateCheckBoxType* {.importcpp: "ESlateCheckBoxType::Type", header: "SlateCore.h", pure.} = enum 14 | ## Type of check box 15 | CheckBox, 16 | ## Traditional check box with check button and label (or other content) 17 | ToggleButton, 18 | ## Toggle button. You provide button content (such as an image), and the user can press to toggle it. 19 | 20 | ECheckBoxState* {.importcpp, header: "SlateCore.h", pure, size: sizeof(uint8).} = enum 21 | ## Current state of the check box 22 | Unchecked, 23 | ## Unchecked 24 | Checked, 25 | ## Checked 26 | Undetermined 27 | ## Neither checked nor unchecked 28 | 29 | wclass(FButtonStyle of FSlateWidgetStyle, header: "SlateCore.h", bycopy): 30 | var normal: FSlateBrush 31 | ## Button appearance when the button is not hovered or pressed 32 | 33 | var hovered: FSlateBrush 34 | ## Button appearance when hovered 35 | 36 | var pressed: FSlateBrush 37 | ## Button appearance when pressed 38 | 39 | var disabled: FSlateBrush 40 | ## Button appearance when disabled, by default this is set to an invalid resource when that is the case default disabled drawing is used. 41 | 42 | var normalPadding: FMargin 43 | ## Padding that accounts for the border in the button's background image. 44 | ## When this is applied, the content of the button should appear flush 45 | ## with the button's border. Use this padding when the button is not pressed. 46 | 47 | var pressedPadding: FMargin 48 | ## Same as NormalPadding but used when the button is pressed. Allows for moving the content to match 49 | ## any "movement" in the button's border image. 50 | 51 | var pressedSlateSound: FSlateSound 52 | ## The sound the button should play when pressed 53 | 54 | var hoveredSlateSound: FSlateSound 55 | ## The sound the button should play when initially hovered over 56 | 57 | # TODO: most not wrapped 58 | -------------------------------------------------------------------------------- /modules/core/slate/slatewidgetstyle.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FSlateWidgetStyle, header: "SlateCore.h", bycopy): 4 | ## Base structure for widget styles. 5 | proc initFSlateWidgetStyle(): FSlateWidgetStyle {.constructor.} 6 | ## Default constructor. 7 | 8 | method getResources(outBrushes: var TArray[ptr FSlateBrush]) {.noSideEffect.} 9 | ## Gets the brush resources associated with this style. 10 | ## 11 | ## This method must be implemented by inherited structures. 12 | ## 13 | ## @param OutBrushes The brush resources. 14 | 15 | method getTypeName(): FName {.noSideEffect.} 16 | ## Gets the name of this style. 17 | ## 18 | ## This method must be implemented by inherited structures. 19 | ## 20 | ## @return Widget style name. 21 | -------------------------------------------------------------------------------- /modules/core/slate/slotbase.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FSlotBase, header: "SlateCore.h", notypedef): 4 | proc initFSlotBase(): FSlotBase {.constructor.} 5 | 6 | proc initFSlotBase(inWidget: TSharedRef[SWidget]): FSlotBase {.constructor.} 7 | 8 | proc attachWidget(inWidget: TSharedRef[SWidget]) 9 | 10 | proc getWidget(): TSharedRef[SWidget] {.noSideEffect.} 11 | ## Access the widget in the current slot. 12 | ## There will always be a widget in the slot; sometimes it is 13 | ## the SNullWidget instance. 14 | 15 | proc detachWidget(): TSharedPtr[SWidget] 16 | ## Remove the widget from its current slot. 17 | ## The removed widget is returned so that operations could be performed on it. 18 | ## If the null widget was being stored, an invalid shared ptr is returned instead. 19 | 20 | wclass(TSlotBase[T] of FSlotBase, header: "SlateCore.h"): 21 | proc initTSlotBase(): TSlotBase[T] {.constructor.} 22 | proc initTSlotBase(inWidget: TSharedRef[SWidget]): TSlotBase[T] 23 | 24 | # TODO: uncomment after Nim issue is fixed: https://github.com/nim-lang/Nim/issues/4673 25 | # proc `[]`(inChildWidget: TSharedRef[SWidget]): var T 26 | # proc expose(outVarToInit: var ptr T): var T 27 | -------------------------------------------------------------------------------- /modules/core/slate/soverlay.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FOverlaySlot of TSlotBase[FOverlaySlot], header: "SlateCore.h", cppname: "SOverlay::FOverlaySlot"): 4 | ## A slot that support alignment of content and padding and z-order 5 | proc initFOverlaySlot(): FOverlaySlot {.constructor.} 6 | 7 | proc hAlign(inHAlignment: EHorizontalAlignment): var FOverlaySlot {.discardable.} 8 | proc vAlign(inVAlignment: EVerticalAlignment): var FOverlaySlot {.discardable.} 9 | proc padding(uniform: float32): var FOverlaySlot {.discardable.} 10 | proc padding(horizontal, vertical: float32): var FOverlaySlot {.discardable.} 11 | proc padding(left, top, right, bottom: float32): var FOverlaySlot {.discardable.} 12 | proc padding(inPadding: TAttribute[FMargin]): var FOverlaySlot {.discardable.} 13 | 14 | var hAlignment: EHorizontalAlignment 15 | ## The child widget contained in this slot. 16 | var vAlignment: EVerticalAlignment 17 | var slotPadding: TAttribute[FMargin] 18 | 19 | var zOrder: int32 20 | ## Slots with larger ZOrder values will draw above slots with smaller ZOrder values. Slots 21 | ## with the same ZOrder will simply draw in the order they were added. Currently this only 22 | ## works for overlay slots that are added dynamically with AddWidget() and RemoveWidget() 23 | 24 | proc `[]`(inChildWidget: TSharedRef[SWidget]): var FOverlaySlot 25 | 26 | wclass(SOverlay of SPanel, header: "SlateCore.h", notypedef): 27 | ## Implements an overlay widget. 28 | ## 29 | ## Overlay widgets allow for layering several widgets on top of each other. 30 | ## Each slot of an overlay represents a layer that can contain one widget. 31 | ## The slots will be rendered on top of each other in the order they are declared in code. 32 | ## 33 | ## Usage: 34 | ## SNew(SOverlay) 35 | ## + SOverlay::Slot(SNew(SMyWidget1)) 36 | ## + SOverlay::Slot(SNew(SMyWidget2)) 37 | ## + SOverlay::Slot(SNew(SMyWidget3)) 38 | ## 39 | ## Note that SWidget3 will be drawn on top of SWidget2 and SWidget1. 40 | 41 | proc getNumWidgets(): int32 {.noSideEffect.} 42 | ## Returns the number of child widgets 43 | 44 | proc removeSlot(widget: TSharedRef[SWidget]): bool 45 | ## Removes a widget from this overlay. 46 | ## 47 | ## @param Widget The widget content to remove 48 | 49 | proc addSlot(zOrder: int32 = INDEX_NONE): var FOverlaySlot 50 | ## Adds a slot at the specified location (ignores Z-order) 51 | 52 | proc removeSlot(zOrder: int32 = INDEX_NONE) 53 | ## Removes a slot at the specified location 54 | 55 | proc clearChildren() 56 | ## Removes all children from the overlay 57 | 58 | proc newFOverlaySlot(): ptr FOverlaySlot {.importcpp: "(& SOverlay::Slot())", header: "SlateCore.h".} 59 | ## @return a new slot. Slots contain children for SOverlay 60 | -------------------------------------------------------------------------------- /modules/core/slate/structs.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FOptionalSize, header: "SlateCore.h", bycopy): 4 | ## Structure for optional floating point sizes. 5 | proc initFOptionalSize(): FOptionalSize {.constructor.} 6 | ## Creates an unspecified size. 7 | 8 | proc initFOptionalSize(specifiedSize: float32): FOptionalSize {.constructor.} 9 | ## Creates a size with the specified value. 10 | ## 11 | ## @param SpecifiedSize The size to set. 12 | 13 | proc isSet(): bool 14 | ## Checks whether the size is set. 15 | ## 16 | ## @return true if the size is set, false if it is unespecified. 17 | ## @see Get 18 | 19 | proc get(): float32 20 | ## Gets the value of the size. 21 | ## 22 | ## Before calling this method, check with IsSet() whether the size is actually specified. 23 | ## Unspecified sizes a value of -1.0f will be returned. 24 | ## 25 | ## @see IsSet 26 | 27 | type 28 | ESizeRule* {.importcpp: "FSizeParam::ESizeRule", header: "SlateCore.h".} = enum 29 | SizeRule_Auto, 30 | SizeRule_Stretch 31 | 32 | wclass(FSizeParam, header: "SlateCore.h", bycopy): 33 | ## Base structure for size parameters. 34 | ## 35 | ## Describes a way in which a parent widget allocates available space to its child widgets. 36 | ## 37 | ## When SizeRule is SizeRule_Auto, the widget's DesiredSize will be used as the space required. 38 | ## When SizeRule is SizeRule_Stretch, the available space will be distributed proportionately between 39 | ## peer Widgets depending on the Value property. Available space is space remaining after all the 40 | ## peers' SizeRule_Auto requirements have been satisfied. 41 | ## 42 | ## FSizeParam cannot be constructed directly - see FStretch, FAuto, and FAspectRatio 43 | 44 | var sizeRule: ESizeRule 45 | ## The sizing rule to use. 46 | 47 | var value: TAttribute[float32] 48 | ## The actual value this size parameter stores. 49 | ## 50 | ## This value can be driven by a delegate. It is only used for the Stretch mode. 51 | 52 | proc initFSizeParam(inTypeOfSize: ESizeRule, inValue: TAttribute[float32]) 53 | ## Hidden constructor. 54 | ## 55 | ## Use FAspectRatio, FAuto, FStretch to instantiate size parameters. 56 | ## 57 | ## @see FAspectRatio, FAuto, FStretch 58 | 59 | wclass(FStretch of FSizeParam, header: "SlateCore.h", bycopy): 60 | ## Structure for size parameters with SizeRule = SizeRule_Stretch. 61 | ## 62 | ## @see FAspectRatio 63 | ## @see FAuto 64 | proc initFStretch(stretchAmount: TAttribute[float32]): FStretch {.constructor.} 65 | proc initFStretch(): FStretch 66 | 67 | wclass(FAuto of FSizeParam, header: "SlateCore.h", bycopy): 68 | ## Structure for size parameters with SizeRule = SizeRule_Auto. 69 | ## 70 | ## @see FAspectRatio, FStretch 71 | proc initFAuto(): FAuto {.constructor.} 72 | -------------------------------------------------------------------------------- /modules/core/slate/swidgetswitcher.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FWidgetSwitcherSlot of TSlotBase[FWidgetSwitcherSlot], header: "SlateBasics.h", cppname: "SWidgetSwitcher::FSlot"): 4 | proc hAlign(inHAlignment: EHorizontalAlignment): var FWidgetSwitcherSlot {.discardable.} 5 | proc vAlign(inVAlignment: EVerticalAlignment): var FWidgetSwitcherSlot {.discardable.} 6 | 7 | proc padding(uniform: float32): var FWidgetSwitcherSlot {.discardable.} 8 | proc padding(horizontal, vertical: float32): var FWidgetSwitcherSlot {.discardable.} 9 | proc padding(left, top, right, bottom: float32): var FWidgetSwitcherSlot {.discardable.} 10 | proc padding(inPadding: TAttribute[FMargin]): var FWidgetSwitcherSlot {.discardable.} 11 | 12 | proc `[]`(inChildWidget: TSharedRef[SWidget]): var FWidgetSwitcherSlot 13 | 14 | wclass(SWidgetSwitcher of SPanel, header: "SlateBasics.h"): 15 | ## Implements a widget switcher. 16 | ## 17 | ## A widget switcher is like a tab control, but without tabs. At most one widget is visible at time. 18 | proc addSlot(slotIndex: int32 = INDEX_NONE ): var FWidgetSwitcherSlot 19 | ## Adds a slot to the widget switcher at the specified location. 20 | ## 21 | ## @param SlotIndex The index at which to insert the slot, or INDEX_NONE to append. 22 | 23 | proc getActiveWidget(): TSharedPtr[SWidget] {.noSideEffect.} 24 | ## Gets the active widget. 25 | ## 26 | ## @return Active widget. 27 | 28 | proc getActiveWidgetIndex(): int32 {.noSideEffect.} 29 | ## Gets the slot index of the currently active widget. 30 | ## 31 | ## @return The slot index, or INDEX_NONE if no widget is active. 32 | 33 | proc getNumWidgets(): int32 {.noSideEffect.} 34 | ## Gets the number of widgets that this switcher manages. 35 | ## 36 | ## @return Number of widgets. 37 | 38 | proc getWidget(slotIndex: int32): TSharedPtr[SWidget] {.noSideEffect.} 39 | ## Gets the widget in the specified slot. 40 | ## 41 | ## @param SlotIndex The slot index of the widget to get. 42 | ## @return The widget, or nullptr if the slot does not exist. 43 | 44 | proc getWidgetIndex(widget: TSharedRef[SWidget]): int32 {.noSideEffect.} 45 | ## Gets the slot index of the specified widget. 46 | ## 47 | ## @param Widget The widget to get the index for. 48 | ## @return The slot index, or INDEX_NONE if the widget does not exist. 49 | 50 | proc removeSlot(widgetToRemove: TSharedRef[SWidget]): int32 {.discardable.} 51 | ## Removes a slot with the corresponding widget in it. 52 | ## Returns the index where the widget was found, otherwise -1. 53 | ## 54 | ## @param Widget The widget to find and remove. 55 | 56 | proc setActiveWidget(widget: TSharedRef[SWidget]) 57 | ## Sets the active widget. 58 | ## 59 | ## @param Widget The widget to activate. 60 | 61 | proc setActiveWidgetIndex(index: int32) 62 | ## Activates the widget at the specified index. 63 | ## 64 | ## @param Index The slot index. 65 | 66 | proc newFWidgetSwitcherSlot*(): ptr FWidgetSwitcherSlot {.importcpp: "(& SWidgetSwitcher::Slot())", header: "SlateBasics.h".} 67 | -------------------------------------------------------------------------------- /modules/core/slate/virtualkeyboardentry.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | EKeyboardType* {.importcpp, header: "SlateBasics.h".} = enum 5 | Keyboard_Default, 6 | Keyboard_Number, 7 | Keyboard_Web, 8 | Keyboard_Email, 9 | Keyboard_Password, 10 | Keyboard_AlphaNumeric, 11 | 12 | ESetTextType* {.importcpp, header: "SlateBasics.h", pure, size: sizeof(uint8).} = enum 13 | Changed, 14 | Commited 15 | 16 | wclass(IVirtualKeyboardEntry, header: "SlateBasics.h"): 17 | method setTextFromVirtualKeyboard(inNewText: FText, setTextType: ESetTextType, commitType: ETextCommitType) 18 | ## Sets the text to that entered by the virtual keyboard 19 | ## 20 | ## @param InNewText The new text 21 | ## @param SetTextType Set weather we want to send a TextChanged event after or a TextCommitted event 22 | ## @param CommitType If we are sending a TextCommitted event, what commit type is it 23 | 24 | method getText(): FText {.noSideEffect.} 25 | ## Returns the text. 26 | ## 27 | ## @return Text 28 | 29 | method getHintText(): FText {.noSideEffect.} 30 | ## Returns the hint text. 31 | ## 32 | ## @return HintText 33 | 34 | method getVirtualKeyboardType(): EKeyboardType {.noSideEffect.} 35 | ## Returns the virtual keyboard type. 36 | ## 37 | ## @return VirtualKeyboardType 38 | 39 | method isMultilineEntry(): bool {.noSideEffect.} 40 | ## Returns whether the entry is multi-line 41 | ## 42 | ## @return Whether the entry is multi-line 43 | -------------------------------------------------------------------------------- /modules/core/slate/visibility.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(EVisibility, header: "SlateCore.h"): 4 | ## Is an entity visible? 5 | proc initEVisibility(): EVisibility {.constructor.} 6 | ## Default constructor. 7 | ## 8 | ## The default visibility is 'visible'. 9 | 10 | proc `==`(other: EVisibility): bool {.noSideEffect.} 11 | 12 | proc `!=`(other: EVisibility) 13 | 14 | proc areChildrenHitTestVisible(): bool {.noSideEffect.} 15 | 16 | proc isHitTestVisible(): bool {.noSideEffect.} 17 | 18 | proc isVisible(): bool {.noSideEffect.} 19 | 20 | proc toString(): FString {.noSideEffect.} 21 | 22 | # Default widget visibility - visible and can interactive with the cursor 23 | var VisibilityVisible* {.importcpp: "EVisibility::Visible", header: "SlateCore.h".}: EVisibility 24 | 25 | # Not visible and takes up no space in the layout; can never be clicked on because it takes up no space. 26 | var VisibilityCollapsed* {.importcpp: "EVisibility::Visible", header: "SlateCore.h".}: EVisibility 27 | 28 | # Not visible, but occupies layout space. Not interactive for obvious reasons. 29 | var VisibilityHidden* {.importcpp: "EVisibility::Hidden", header: "SlateCore.h".}: EVisibility 30 | 31 | # Visible to the user, but only as art. The cursors hit tests will never see this widget. 32 | var VisibilityHitTestInvisible* {.importcpp: "EVisibility::HitTestInvisible", header: "SlateCore.h".}: EVisibility 33 | 34 | # Same as HitTestInvisible, but doesn't apply to child widgets. 35 | var VisibilitySelfHitTestInvisible* {.importcpp: "EVisibility::SelfHitTestInvisible", header: "SlateCore.h".}: EVisibility 36 | 37 | # Any visibility will do 38 | var VisibilityAll* {.importcpp: "EVisibility::All", header: "SlateCore.h".}: EVisibility 39 | -------------------------------------------------------------------------------- /modules/core/slate/widgetcaching.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | -------------------------------------------------------------------------------- /modules/core/sound/base.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type EMaxConcurrentResolutionRule {.size: sizeof(cint), 4 | header: "Sound/SoundBase.h", 5 | importcpp: "EMaxConcurrentResolutionRule::Type".} = enum 6 | PreventNew, 7 | ## When Max Concurrent sounds are active do not start a new sound. 8 | StopOldest, 9 | ## When Max Concurrent sounds are active stop the oldest and start a new one. 10 | StopFarthestThenPreventNew, 11 | ## When Max Concurrent sounds are active stop the furthest sound. If all sounds are the same distance then do not start a new sound. 12 | StopFarthestThenOldest, 13 | ## When Max Concurrent sounds are active stop the furthest sound. If all sounds are the same distance then stop the oldest. 14 | 15 | wclass(USoundBase of UObject, header: "Sound/SoundBase.h", notypedef): 16 | var bDebug: bool 17 | ## When "stat sounds -debug" has been specified, draw this sound's attenuation shape when the sound is audible. 18 | ## For debugging purpose only. 19 | ## UPROPERTY(EditAnywhere, Category=Playback) 20 | 21 | var maxConcurrentResolutionRule: EMaxConcurrentResolutionRule 22 | ## If we try to play a new version of this sound when at the max concurrent count how should it be resolved. 23 | ## UPROPERTY(EditAnywhere, Category=Playback) 24 | 25 | var maxConcurrentPlayCount: int32 26 | ## Maximum number of times this sound can be played concurrently. 27 | ## UPROPERTY(EditAnywhere, Category=Playback) 28 | 29 | var duration: cfloat 30 | ## Duration of sound in seconds. 31 | ## UPROPERTY(Category=Info, AssetRegistrySearchable, VisibleAnywhere, BlueprintReadOnly) 32 | 33 | # AWARE: deps 34 | # var attenuationSettings: ptr USoundAttenuation 35 | # ## Attenuation settings package for the sound 36 | # ## UPROPERTY(EditAnywhere, Category=Attenuation) 37 | 38 | var currentPlayCount: int32 39 | ## Number of times this cue is currently being played. 40 | 41 | method isPlayable(): bool {.noSideEffect.} 42 | ## Returns whether the sound base is set up in a playable manner 43 | 44 | # AWARE: deps 45 | # method getAttenuationSettingsToApply(): ptr FAttenuationSettings {.noSideEffect.} 46 | # ## Returns a pointer to the attenuation settings that are to be applied for this node 47 | 48 | proc isAudible(sourceLocation: FVector; listenerLocation: FVector; 49 | sourceActor: ptr AActor; bIsOccluded: var bool; bCheckOcclusion: bool): bool 50 | ## Checks to see if a location is audible 51 | 52 | # AWARE: deps 53 | # proc isAudibleSimple(audioDevice: ptr FAudioDevice; location: FVector; 54 | # inAttenuationSettings: ptr USoundAttenuation = nil): bool 55 | # ## Does a simple range check to all listeners to test hearability 56 | # ## 57 | # ## @param Location Location to check against 58 | # ## @param AttenuationSettings Optional Attenuation override if not using settings from the sound 59 | 60 | method getMaxAudibleDistance(): cfloat 61 | ## Returns the farthest distance at which the sound could be heard 62 | 63 | method getDuration(): cfloat 64 | ## Returns the length of the sound 65 | 66 | method getVolumeMultiplier(): cfloat 67 | method getPitchMultiplier(): cfloat 68 | 69 | # AWARE: deps 70 | # method parse(audioDevice: ptr FAudioDevice; NodeWaveInstanceHash: UPTRINT; 71 | # activeSound: var FActiveSound; ParseParams: FSoundParseParameters; 72 | # waveInstances: var TArray[ptr FWaveInstance]) 73 | # ## Parses the Sound to generate the WaveInstances to play 74 | 75 | # method getSoundClass(): ptr USoundClass {.noSideEffect.} 76 | # ## Returns the SoundClass used for this sound -------------------------------------------------------------------------------- /modules/core/spectatorpawn.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | # TODO -------------------------------------------------------------------------------- /modules/core/touchinterface.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type FTouchInputControl* {.header: "GameFramework/TouchInterface.h", importcpp.} = object 4 | image1*: UTexture2D 5 | ## UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="For sticks, this is the Thumb")) 6 | 7 | image2*: UTexture2D 8 | ## UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="For sticks, this is the Background")) 9 | 10 | center*: FVector2D 11 | ## UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The center point of the control (if <= 1.0, it's relative to screen, > 1.0 is absolute)")) 12 | 13 | visualSize*: FVector2D 14 | ## UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The size of the control (if <= 1.0, it's relative to screen, > 1.0 is absolute)")) 15 | 16 | thumbSize*: FVector2D 17 | ## UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="For sticks, the size of the thumb (if <= 1.0, it's relative to screen, > 1.0 is absolute)")) 18 | 19 | interactionSize*: FVector2D 20 | ## UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The interactive size of the control (if <= 1.0, it's relative to screen, > 1.0 is absolute)")) 21 | 22 | inputScale*: FVector2D 23 | ## UPROPERTY(EditAnywhere, Category = "Control", meta = (ToolTip = "The scale for control input")) 24 | 25 | mainInputKey*: FKey 26 | ## UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The main input to send from this control (for sticks, this is the horizontal axis)")) 27 | 28 | altInputKey*: FKey 29 | ## UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The alternate input to send from this control (for sticks, this is the vertical axis)")) 30 | 31 | proc makeFTouchInputControl(): FTouchInputControl {.header: "GameFramework/TouchInterface.h", constructor, importcpp.} 32 | 33 | type UTouchInterface* {.header: "GameFramework/TouchInterface.h", importcpp.} = object of UObject 34 | ## Defines an interface by which touch input can be controlled using any number of buttons and virtual joysticks 35 | 36 | controls*: TArray[FTouchInputControl] 37 | ## UPROPERTY(EditAnywhere, Category="TouchInterface") 38 | 39 | ActiveOpacity*: cfloat 40 | ## UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="Opacity (0.0 - 1.0) of all controls while any control is active")) 41 | 42 | InactiveOpacity*: cfloat 43 | ## UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="Opacity (0.0 - 1.0) of all controls while no controls are active")) 44 | 45 | TimeUntilDeactive*: cfloat 46 | ## UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="How long after user interaction will all controls fade out to Inactive Opacity")) 47 | 48 | TimeUntilReset*: cfloat 49 | ## UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="How long after going inactive will controls reset/recenter themselves (0.0 will disable this feature)")) 50 | 51 | ActivationDelay*: cfloat 52 | ## UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="How long after joystick enabled for touch (0.0 will disable this feature)")) 53 | 54 | bPreventRecenter*: bool 55 | ## UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="Whether to prevent joystick re-center")) 56 | 57 | StartupDelay*: cfloat 58 | ## UPROPERTY(EditAnywhere, Category = "TouchInterface", meta = (ToolTip = "Delay at startup before virtual joystick is drawn")) 59 | -------------------------------------------------------------------------------- /modules/editor/editor.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | declareBuiltinDelegate(FOnPostSaveWorld, dkMulticast, "Editor.h", saveFlags: uint32, world: ptr UWorld, bSuccess: bool) 4 | 5 | var postSaveWorld* {.header: "Editor.h", importcpp: "FEditorDelegates::PostSaveWorld".}: FOnPostSaveWorld 6 | 7 | -------------------------------------------------------------------------------- /modules/editor/editormodule.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | import ue4 4 | import macros 5 | import "../../lib/macroutils" 6 | 7 | include editor -------------------------------------------------------------------------------- /modules/gamemenubuilder/gamemenubuilder.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(IGameMenuBuilderModule, header: "GameMenuBuilder.h"): 4 | ## The public interface to game menu builder module 5 | 6 | proc getIGameMenuBuilderModule*(): ptr IGameMenuBuilderModule {. 7 | importcpp: "(& IGameMenuBuilderModule::Get())", header: "GameMenuBuilder.h".} 8 | ## Singleton-like access to this module's interface. This is just for convenience! 9 | ## Beware of calling this during the shutdown phase, though. Your module might have been unloaded already. 10 | ## 11 | ## @return Returns singleton instance, loading the module on demand if needed 12 | -------------------------------------------------------------------------------- /modules/gamemenubuilder/gamemenubuildermodule.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | import ue4 4 | import macros 5 | import "../../lib/macroutils" 6 | 7 | type 8 | SGameMenuPageWidget* {.header: "SGameMenuPageWidget.h", importcpp.} = object of SCompoundWidget 9 | 10 | include gamemenubuilder 11 | include gamemenupage 12 | include gamemenupagewidget 13 | -------------------------------------------------------------------------------- /modules/gamemenubuilder/gamemenupagewidget.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | EPanelState {.importcpp: "EPanelState::Type", header: "GameMenuBuilder.h".} = enum 5 | Opening, 6 | ## Menu is opening. 7 | Open, 8 | ## Menu is open. 9 | Closing, 10 | ## Menu is closing. 11 | Closed 12 | ## Menu is closed. 13 | 14 | declareBuiltinDelegate(FPanelStateChanged, dkSimple, "GameMenuBuilder.h", state: bool) 15 | 16 | wclass(FMenuPanel, header: "GameMenuBuilder.h", bycopy): 17 | ## Simple class to contain the menu panels/animations 18 | proc initFMenuPanel(): FMenuPanel {.constructor.} 19 | 20 | proc tick(delta: float) 21 | 22 | # proc closePanel(ownerWidget: TSharedRef[SWidget]) 23 | # ## Close the panel 24 | 25 | # proc openPanel(ownerWidget: TSharedRef[SWidget]) 26 | # ## Open the panel 27 | 28 | proc forcePanelOpen() 29 | ## Force the panel to be fully open. 30 | 31 | proc forcePanelClosed() 32 | ## Force the panel to be fully closed. 33 | 34 | # proc setStyle(inStyle: ptr FGameMenuStyle) 35 | 36 | var onStateChanged: FPanelStateChanged 37 | ## Delegate called when the panel becomes open or closed. 38 | 39 | # var animationHandle: FCurveHandle 40 | # ## Animation curve/handle for panel animation. 41 | 42 | var currentState: EPanelState 43 | ## The current state of the panel. 44 | 45 | wclass(SGameMenuPageWidget, header: "GameMenuBuilder.h", notypedef): 46 | proc onMainPanelStateChange(bWasOpened: bool) 47 | ## Callback handler for when the state of the main panel changes. 48 | ## 49 | ## @param bWasOpened whether the panel was opened or closed. is TRUE if panel opened. 50 | 51 | proc onSubPanelStateChange(bWasOpened: bool) 52 | ## Callback handler for when the state of the sub panel changes.b 53 | ## 54 | ## @param bWasOpened whether the panel was opened or closed. is TRUE if panel opened. 55 | 56 | proc setupAnimations() 57 | ## Setups misc animation sequences. 58 | 59 | proc enterSubMenu(inSubMenu: TSharedPtr[FGameMenuPage]) 60 | ## Make the currently selected menu sub menu new main menu if valid. 61 | 62 | proc menuGoBack(bIsCancel: bool = false) 63 | ## Go back the the previous menu. 64 | ## 65 | ## @param bIsCancel if true will be treated as CANCEL (IE escape pressed). 66 | 67 | proc confirmMenuItem() 68 | ## Confirms current menu item and performs an action. Will also play selection sound. 69 | 70 | proc buildAndShowMenu(inMenu: TSharedPtr[FGameMenuPage]) 71 | ## Show the given menu and make it the current menu. 72 | ## 73 | ## @param InMenu The menu to show and set as the current menu. If this is NULL Current menu will be used if valid. 74 | 75 | proc hideMenu() 76 | ## Hide the menu. 77 | 78 | proc updateArrows(inMenuItem: TSharedPtr[FGameMenuItem]) 79 | ## Updates arrows visibility for multi-choice menu item. 80 | ## 81 | ## @param InMenuItem The item to update. 82 | 83 | proc changeOption(inMoveBy: int32) 84 | ## Change the currently selection option of the currently selected menu item. 85 | ## 86 | ## @param InMoveBy Number to change the option by. 87 | 88 | proc lockControls(bEnable: bool) 89 | ## disable/enable moving around menu. 90 | 91 | proc openMainPanel(inMenu: TSharedPtr[FGameMenuPage]) 92 | ## Set the current menu and 'open' it as the main panel. 93 | ## 94 | ## @param InMenu The menu to open and set as current. 95 | 96 | proc selectItem(inSelection: int32): bool 97 | ## Select a given item from an index 98 | ## 99 | ## @param InSelection The index of the item to select 100 | ## @returns true if selection changed. 101 | 102 | proc resetMenu() 103 | 104 | var myGameViewport: TWeakObjectPtr[UGameViewportClient] 105 | ## The viewport I am attached to. 106 | 107 | proc getCurrentMenu(): TSharedPtr[FGameMenuPage] 108 | -------------------------------------------------------------------------------- /modules/umg/anchors.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FAnchors, header: "Widgets/Layout/Anchors.h", bycopy): 4 | ## Describes how a widget is anchored. 5 | 6 | var minimum: FVector2D 7 | ##Holds the minimum anchors, left + top. 8 | 9 | var maximum: FVector2D 10 | ## Holds the maximum anchors, right + bottom. 11 | 12 | proc initFAnchors(): FAnchors {.constructor.} 13 | ## Default constructor. 14 | ## 15 | ## The default margin size is zero on all four sides.. 16 | 17 | proc initFAnchors(unifromAnchors: float32): FAnchors {.constructor.} 18 | ## Construct a Anchors with uniform space on all sides 19 | 20 | proc initFAnchors(horizontal, vertical: float32): FAnchors {.constructor.} 21 | ## Construct a Anchors where Horizontal describes Left and Right spacing while Vertical describes Top and Bottom spacing 22 | 23 | proc initFAnchors(minX, minY, maxX, maxY: float32): FAnchors {.constructor.} 24 | ## Construct Anchors where the spacing on each side is individually specified. 25 | 26 | proc isStretchedVertical(): bool {.noSideEffect.} 27 | ## Returns true if the anchors represent a stretch along the vertical axis 28 | 29 | proc isStretchedHorizontal(): bool {.noSideEffect.} 30 | ## Returns true if the anchors represent a stretch along the horizontal axis 31 | -------------------------------------------------------------------------------- /modules/umg/button.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | declareBuiltinDelegate(FOnButtonClickedEvent, dkDynamicMulticast, "UMG.h") 4 | declareBuiltinDelegate(FOnButtonPressedEvent, dkDynamicMulticast, "UMG.h") 5 | declareBuiltinDelegate(FOnButtonReleasedEvent, dkDynamicMulticast, "UMG.h") 6 | declareBuiltinDelegate(FOnButtonHoverEvent, dkDynamicMulticast, "UMG.h") 7 | 8 | wclass(UButton of UContentWidget, header: "UMG.h"): 9 | ## The button is a click-able primitive widget to enable basic interaction, you 10 | ## can place any other widget inside a button to make a more complex and 11 | ## interesting click-able element in your UI. 12 | ## 13 | ## * Single Child 14 | ## * Clickable 15 | 16 | var widgetStyle: FButtonStyle 17 | ## The button style used at runtime 18 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Appearance", meta=( DisplayName="Style" )) 19 | 20 | var colorAndOpacity: FLinearColor 21 | ## The color multiplier for the button content 22 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Appearance", meta=( sRGB="true" )) 23 | 24 | var backgroundColor: FLinearColor 25 | ## The color multiplier for the button background 26 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Appearance", meta=( sRGB="true" )) 27 | 28 | var clickMethod: TEnumAsByte[EButtonClickMethod] 29 | ## The type of mouse action required by the user to trigger the buttons 'Click' 30 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Interaction", AdvancedDisplay) 31 | 32 | var touchMethod: TEnumAsByte[EButtonTouchMethod] 33 | ## The type of touch action required by the user to trigger the buttons 'Click' 34 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Interaction", AdvancedDisplay) 35 | 36 | var isFocusable: bool 37 | ## Sometimes a button should only be mouse-clickable and never keyboard focusable. 38 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Interaction") 39 | 40 | var onClicked: FOnButtonClickedEvent 41 | ## Called when the button is clicked 42 | ## UPROPERTY(BlueprintAssignable, Category="Button|Event") 43 | 44 | var onPressed: FOnButtonPressedEvent 45 | ## Called when the button is pressed 46 | ## UPROPERTY(BlueprintAssignable, Category="Button|Event") 47 | 48 | var onReleased: FOnButtonReleasedEvent 49 | ## Called when the button is released 50 | ## UPROPERTY(BlueprintAssignable, Category="Button|Event") 51 | 52 | var onHovered: FOnButtonHoverEvent 53 | ## UPROPERTY( BlueprintAssignable, Category = "Button|Event" ) 54 | 55 | var onUnhovered: FOnButtonHoverEvent 56 | ## UPROPERTY( BlueprintAssignable, Category = "Button|Event" ) 57 | 58 | proc setStyle(inStyle: FButtonStyle) 59 | ## Sets the color multiplier for the button background 60 | ## UFUNCTION(BlueprintCallable, Category="Button|Appearance") 61 | 62 | proc setColorAndOpacity(inColorAndOpacity: FLinearColor) 63 | ## Sets the color multiplier for the button content 64 | ## UFUNCTION(BlueprintCallable, Category="Button|Appearance") 65 | 66 | proc setBackgroundColor(inBackgroundColor: FLinearColor) 67 | ## Sets the color multiplier for the button background 68 | ## UFUNCTION(BlueprintCallable, Category="Button|Appearance") 69 | 70 | proc isPressed(): bool {.noSideEffect.} 71 | ## Returns true if the user is actively pressing the button. 72 | ## Do not use this for detecting 'Clicks', use the OnClicked event instead. 73 | ## 74 | ## @return true if the user is actively pressing the button otherwise false. 75 | ## UFUNCTION(BlueprintCallable, Category="Button") 76 | 77 | wclass(UButtonSlot of UPanelSlot, header: "UMG.h"): 78 | ## The Slot for the UButtonSlot, contains the widget displayed in a button's single slot 79 | 80 | var padding: FMargin 81 | ## The padding area between the slot and the content it contains. 82 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Layout|Button Slot") 83 | 84 | var horizontalAlignment: EHorizontalAlignment 85 | ## The alignment of the object horizontally. 86 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Layout|Button Slot") 87 | 88 | var verticalAlignment: EVerticalAlignment 89 | ## The alignment of the object vertically. 90 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Layout|Button Slot") 91 | 92 | proc setPadding(inPadding: FMargin) 93 | ## UFUNCTION(BlueprintCallable, Category="Layout|Button Slot") 94 | 95 | proc setHorizontalAlignment(inHorizontalAlignment: EHorizontalAlignment) 96 | ## UFUNCTION(BlueprintCallable, Category="Layout|Button Slot") 97 | 98 | proc setVerticalAlignment(inVerticalAlignment: EVerticalAlignment) 99 | ## UFUNCTION(BlueprintCallable, Category="Layout|Button Slot") 100 | -------------------------------------------------------------------------------- /modules/umg/canvaspanelslot.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UCanvasPanelSlot of UPanelSlot, header: "Components/CanvasPanelSlot.h"): 4 | proc getPosition(): FVector2D 5 | proc setPosition(inPosition: FVector2D) 6 | -------------------------------------------------------------------------------- /modules/umg/contentwidget.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UContentWidget of UPanelWidget, header: "UMG.h"): 4 | proc getContentSlot(): ptr UPanelSlot {.noSideEffect.} 5 | ## UFUNCTION(BlueprintCallable, Category="Widget|Panel") 6 | -------------------------------------------------------------------------------- /modules/umg/image.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UImage of UWidget, header: "UMG.h"): 4 | ## The image widget allows you to display a Slate Brush, or texture or material in the UI. 5 | ## 6 | ## * No Children 7 | 8 | var brush: FSlateBrush 9 | ## Image to draw 10 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Appearance) 11 | 12 | var brushDelegate: FGetSlateBrush 13 | ## A bindable delegate for the Image. 14 | 15 | var colorAndOpacity: FLinearColor 16 | ## Color and opacity 17 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Appearance, meta=( sRGB="true") ) 18 | 19 | var colorAndOpacityDelegate: FGetLinearColor 20 | ## A bindable delegate for the ColorAndOpacity. 21 | 22 | var onMouseButtonDownEvent: FOnPointerEvent 23 | ## UPROPERTY(EditAnywhere, Category=Events, meta=( IsBindableEvent="True" )) 24 | 25 | proc setColorAndOpacity(inColorAndOpacity: FLinearColor ) 26 | ## UFUNCTION(BlueprintCallable, Category="Appearance") 27 | 28 | proc setOpacity(inOpacity: float32) 29 | ## UFUNCTION(BlueprintCallable, Category="Appearance") 30 | 31 | proc setBrush(inBrush: FSlateBrush) 32 | ## UFUNCTION(BlueprintCallable, Category="Appearance") 33 | 34 | proc setBrushFromTexture(texture: ptr UTexture2D, bMatchSize: bool = false) 35 | ## UFUNCTION(BlueprintCallable, Category="Appearance") 36 | 37 | proc setBrushFromMaterial(material: ptr UMaterialInterface) 38 | ## UFUNCTION(BlueprintCallable, Category="Appearance") 39 | 40 | proc getDynamicMaterial(): ptr UMaterialInstanceDynamic 41 | ## UFUNCTION(BlueprintCallable, Category="Appearance") 42 | -------------------------------------------------------------------------------- /modules/umg/panelslot.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UPanelSlot of UVisual, header: "UMG.h"): 4 | ## The base class for all Slots in UMG. 5 | var parent: ptr UPanelWidget 6 | var content: ptr UWidget 7 | 8 | proc isDesignTime(): bool {.noSideEffect.} 9 | 10 | method synchronizeProperties() 11 | ## Applies all properties to the live slot if possible. 12 | -------------------------------------------------------------------------------- /modules/umg/panelwidget.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UPanelWidget of UWidget, header: "UMG.h", notypedef): 4 | ## The base class for all UMG panel widgets. Panel widgets layout a collection of child widgets. 5 | # protected: 6 | 7 | var slots: TArray[ptr UPanelSlot] 8 | ## The slots in the widget holding the child widgets of this panel. 9 | 10 | # public: 11 | proc getChildrenCount(): int32 {.noSideEffect.} 12 | ## Gets number of child widgets in the container. 13 | 14 | proc getChildAt(index: int32): ptr UWidget {.noSideEffect.} 15 | ## Gets the widget at an index. 16 | ## @param Index The index of the widget. 17 | ## @return The widget at the given index, or nothing if there is no widget there. 18 | ## UFUNCTION(BlueprintCallable, Category="Widget|Panel") 19 | 20 | proc getChildIndex(content: ptr UWidget): int32 {.noSideEffect.} 21 | ## Gets the index of a specific child widget 22 | ## UFUNCTION(BlueprintCallable, Category="Widget|Panel") 23 | 24 | proc hasChild(content: ptr UWidget): bool {.noSideEffect.} 25 | ## @return true if panel contains this widget 26 | ## UFUNCTION(BlueprintCallable, Category="Widget|Panel") 27 | 28 | proc removeChildAt(index: int32): bool 29 | ## Removes a child by it's index. 30 | ## UFUNCTION(BlueprintCallable, Category="Widget|Panel") 31 | 32 | proc addChild(content: ptr UWidget): ptr UPanelSlot 33 | ## Adds a new child widget to the container. Returns the base slot type, 34 | ## requires casting to turn it into the type specific to the container. 35 | ## UFUNCTION(BlueprintCallable, Category="Widget|Panel") 36 | 37 | proc replaceChildAt(index: int32, content: ptr UWidget): bool 38 | ## Swaps the widget out of the slot at the given index, replacing it with a different widget. 39 | ## 40 | ## @param Index the index at which to replace the child content with this new Content. 41 | ## @param Content The content to replace the child with. 42 | ## @return true if the index existed and the child could be replaced. 43 | 44 | #if WITH_EDITOR 45 | 46 | method replaceChild(currentChild, newChild: ptr UWidget): bool 47 | ## Swaps the child widget out of the slot, and replaces it with the new child widget. 48 | ## @param CurrentChild The existing child widget being removed. 49 | ## @param NewChild The new child widget being inserted. 50 | ## @return true if the CurrentChild was found and the swap occurred, otherwise false. 51 | 52 | proc insertChildAt(index: int32, content: ptr UWidget): ptr UPanelSlot 53 | ## Inserts a widget at a specific index. This does not update the live slate version, it requires 54 | ## a rebuild of the whole UI to see a change. 55 | 56 | proc shiftChild(index: int32, child: ptr UWidget) 57 | ## Moves the child widget from its current index to the new index provided. 58 | 59 | proc setDesignerFlags(newFlags: EWidgetDesignFlags) 60 | #endif 61 | 62 | proc removeChild(content: ptr UWidget): bool 63 | ## Removes a specific widget from the container. 64 | ## @return true if the widget was found and removed. 65 | ## UFUNCTION(BlueprintCallable, Category="Widget|Panel") 66 | 67 | proc hasAnyChildren(): bool {.noSideEffect.} 68 | ## @return true if there are any child widgets in the panel 69 | ## UFUNCTION(BlueprintCallable, Category="Widget|Panel") 70 | 71 | proc clearChildren() 72 | ## Remove all child widgets from the panel widget. 73 | ## UFUNCTION(BlueprintCallable, Category="Widget|Panel") 74 | 75 | proc getSlots(): TArray[ptr UPanelSlot] {.noSideEffect.} 76 | ## The slots in the widget holding the child widgets of this panel. 77 | 78 | proc canHaveMultipleChildren(): bool {.noSideEffect.} 79 | ## @returns true if the panel supports more than one child. 80 | 81 | proc canAddMoreChildren(): bool {.noSideEffect.} 82 | ## @returns true if the panel can accept another child widget. 83 | 84 | #if WITH_EDITOR 85 | method lockToPanelOnDrag(): bool {.noSideEffect.} 86 | #endif 87 | 88 | # protected: 89 | 90 | method getSlotClass(): ptr UClass {.noSideEffect.} 91 | 92 | method onSlotAdded(slot: ptr UPanelSlot) 93 | 94 | method onSlotRemoved(slot: ptr UPanelSlot) 95 | 96 | var bCanHaveMultipleChildren: bool 97 | ## Can this panel allow for multiple children? 98 | -------------------------------------------------------------------------------- /modules/umg/propertybinding.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FDynamicPropertyPath, header: "UMG.h", bycopy): 4 | proc initFDynamicPropertyPath(): FDynamicPropertyPath {.constructor.} 5 | 6 | proc initFDynamicPropertyPath(path: FString): FDynamicPropertyPath 7 | 8 | proc initFDynamicPropertyPath(propertyChain: TArray[FString]): FDynamicPropertyPath 9 | 10 | proc isValid(): bool {.noSideEffect.} 11 | 12 | proc getValue[T](inContainer: ptr UObject, outValue: var T): bool {.noSideEffect.} 13 | 14 | proc getValue[T](inContainer: ptr UObject, outValue: var T, outProperty: var ptr UProperty): bool {.noSideEffect.} 15 | 16 | wclass(UPropertyBinding of UObject, header: "UMG.h"): 17 | method isSupportedSource(property: ptr UProperty): bool {.noSideEffect.} 18 | method isSupportedDestination(property: ptr UProperty): bool {.noSideEffect.} 19 | 20 | # method bindProperty(property: ptr UProperty, delegate: ptr FScriptDelegate) 21 | 22 | # public: 23 | var sourceObject: TWeakObjectPtr[UObject] 24 | ## The source object to use as the initial container to resolve the Source Property Path on. 25 | 26 | var sourcePath: FDynamicPropertyPath 27 | ## The property path to trace to resolve this binding on the Source Object 28 | 29 | var destinationProperty: FName 30 | ## Used to determine if a binding already exists on the object and if this binding can be safely removed. 31 | -------------------------------------------------------------------------------- /modules/umg/slatewrappertypes.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | type 4 | ESlateVisibility* {.importcpp, header: "UMG.h", pure, size: sizeof(uint8).} = enum 5 | ## Is an entity visible? 6 | Visible, 7 | ## Default widget visibility - visible and can interactive with the cursor 8 | Collapsed, 9 | ## Not visible and takes up no space in the layout; can never be clicked on because it takes up no space. 10 | Hidden, 11 | ## Not visible, but occupies layout space. Not interactive for obvious reasons. 12 | HitTestInvisible, 13 | ## Visible to the user, but only as art. The cursors hit tests will never see this widget. 14 | SelfHitTestInvisible 15 | ## Same as HitTestInvisible, but doesn't apply to child widgets. 16 | 17 | ESlateSizeRule* {.importcpp: "ESlateSizeRule::Type", header: "UMG.h", pure.} = enum 18 | ## The sizing options of UWidgets 19 | Automatic, 20 | ## Only requests as much room as it needs based on the widgets desired size. 21 | Fill 22 | ## Greedily attempts to fill all available room based on the percentage value 0..1 23 | 24 | EVirtualKeyboardType* {.importcpp: "EVirtualKeyboardType::Type", header: "UMG.h", pure.} = enum 25 | Default, 26 | Number, 27 | Web, 28 | Email, 29 | Password, 30 | AlphaNumeric 31 | 32 | proc asKeyboardType*(inType: EVirtualKeyboardType): EKeyboardType {.importcpp: "EVirtualKeyboardType::AsKeyboardType(@)", header: "UMG.h".} 33 | 34 | wclass(FEventReply, header: "UMG.h", bycopy): 35 | ## Allows users to handle events and return information to the underlying UI layer. 36 | 37 | proc initFEventReply(isHandled: bool = false): FEventReply {.constructor.} 38 | var nativeReply: FReply 39 | 40 | wclass(FSlateChildSize, header: "UMG.h"): 41 | ## A struct exposing size param related properties to UMG. 42 | 43 | var value: float32 44 | ## The parameter of the size rule. 45 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Appearance, meta=( UIMin="0", UIMax="1" )) 46 | 47 | var sizeRule: TEnumAsByte[ESlateSizeRule] 48 | ## The sizing rule of the content. 49 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Appearance) 50 | 51 | proc initFSlateChildSize(): FSlateChildSize {.constructor.} 52 | proc initFSlateChildSize(InSizeRule: ESlateSizeRule): FSlateChildSize {.constructor.} 53 | -------------------------------------------------------------------------------- /modules/umg/sobjectwidget.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(SObjectWidget of SCompoundWidget, header: "UMG.h"): 4 | ## The SObjectWidget allows UMG to insert an SWidget into the hierarchy that manages the lifetime of the 5 | ## UMG UWidget that created it. Once the SObjectWidget is destroyed it frees the reference it holds to 6 | ## The UWidget allowing it to be garbage collected. It also forwards the slate events to the UUserWidget 7 | ## so that it can forward them to listeners. 8 | proc resetWidget() 9 | proc getWidgetObject(): ptr UUserWidget {.noSideEffect.} 10 | proc setPadding(inMargin: TAttribute[FMargin]) 11 | -------------------------------------------------------------------------------- /modules/umg/umgmodule.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | import ue4 4 | 5 | {.push stackTrace:off.} 6 | 7 | wclass(UVisual of UObject, header: "UMG.h"): 8 | method releaseSlateResources(bReleaseChildren: bool) 9 | 10 | type 11 | UWidget* {.importcpp, header: "UMG.h".} = object of UVisual 12 | UPanelWidget* {.importcpp, header: "UMG.h".} = object of UWidget 13 | UUserWidget* {.importcpp, header: "UMG.h".} = object of UWidget 14 | 15 | include slatewrappertypes 16 | include widgettransform 17 | include sobjectwidget 18 | include propertybinding 19 | 20 | include widgettree 21 | include widgetnavigation 22 | 23 | include anchors 24 | 25 | include panelslot 26 | include canvaspanelslot 27 | include widget 28 | include userwidget 29 | include panelwidget 30 | include contentwidget 31 | 32 | include image 33 | include button 34 | 35 | {.pop.} -------------------------------------------------------------------------------- /modules/umg/userwidget.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UUserWidget of UWidget, header: "Blueprint/UserWidget.h", notypedef): 4 | proc addToViewport(zOrder: int32 = 0) 5 | ## Adds it to the game's viewport and fills the entire screen, unless SetDesiredSizeInViewport is called 6 | ## to explicitly set the size. 7 | ## 8 | ## @param ZOrder The higher the number, the more on top this widget will be. 9 | 10 | proc addToPlayerScreen(zOrder: int32 = 0): bool {.discardable.} 11 | ## Adds the widget to the game's viewport in a section dedicated to the player. This is valuable in a split screen 12 | ## game where you need to only show a widget over a player's portion of the viewport. 13 | ## 14 | ## @param ZOrder The higher the number, the more on top this widget will be. 15 | 16 | proc removeFromViewport() 17 | ## Removes the widget from the viewport. 18 | 19 | method removeFromParent() 20 | ## Removes the widget from its parent widget. If this widget was added to the player's screen or the viewport 21 | ## it will also be removed from those containers. 22 | 23 | method nativeDestruct() 24 | 25 | proc setPositionInViewport(position: FVector2D, bRemoveDPIScale: bool = true) 26 | ## Sets the widgets position in the viewport. 27 | ## @param Position The 2D position to set the widget to in the viewport. 28 | ## @param bRemoveDPIScale If you've already calculated inverse DPI, set this to false. 29 | ## Otherwise inverse DPI is applied to the position so that when the location is scaled 30 | ## by DPI, it ends up in the expected position. 31 | 32 | proc setDesiredSizeInViewport(size: FVector2D) 33 | 34 | proc setAnchorsInViewport(anchors: FAnchors) 35 | 36 | proc setAlignmentInViewport(alignment: FVector2D) 37 | 38 | proc getIsVisible(): bool {.noSideEffect.} 39 | 40 | proc isInViewport(): bool {.noSideEffect.} 41 | ## @return true if the widget was added to the viewport using AddToViewport. 42 | 43 | proc createWidget*[T: UUserWidget](world: ptr UWorld): ptr T {.importcpp: "CreateWidget<'*0>(@)", header: "Blueprint/UserWidget.h".} 44 | proc createWidget*[T: UUserWidget](world: ptr UWorld, class: ptr UClass): ptr T {.importcpp: "CreateWidget<'*0>(@)", header: "Blueprint/UserWidget.h".} 45 | proc createWidget*[T: UUserWidget](owningPlayer: ptr APlayerController): ptr T {.importcpp: "CreateWidget<'*0>(@)", header: "Blueprint/UserWidget.h".} 46 | proc createWidget*[T: UUserWidget](owningPlayer: ptr APlayerController, class: ptr UClass): ptr T {.importcpp: "CreateWidget<'*0>(@)", header: "Blueprint/UserWidget.h".} 47 | proc createWidget*[T: UUserWidget](owningGame: ptr UGameInstance): ptr T {.importcpp: "CreateWidget<'*0>(@)", header: "Blueprint/UserWidget.h".} 48 | proc createWidget*[T: UUserWidget](owningGame: ptr UGameInstance, class: ptr UClass): ptr T {.importcpp: "CreateWidget<'*0>(@)", header: "Blueprint/UserWidget.h".} -------------------------------------------------------------------------------- /modules/umg/widgetnavigation.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FWidgetNavigationData, header: "UMG.h", bycopy): 4 | var rule: EUINavigationRule 5 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Navigation") 6 | 7 | var widgetToFocus: FName 8 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Navigation") 9 | 10 | var widget: TWeakObjectPtr[UWidget] 11 | 12 | wclass(UWidgetNavigation of UObject, header: "UMG.h"): 13 | var up: FWidgetNavigationData 14 | ## Happens when the user presses up arrow, joystick, d-pad. 15 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Navigation") 16 | 17 | var down: FWidgetNavigationData 18 | ## Happens when the user presses down arrow, joystick, d-pad. 19 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Navigation") 20 | 21 | var left: FWidgetNavigationData 22 | ## Happens when the user presses left arrow, joystick, d-pad. 23 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Navigation") 24 | 25 | var right: FWidgetNavigationData 26 | ## Happens when the user presses right arrow, joystick, d-pad. 27 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Navigation") 28 | 29 | var next: FWidgetNavigationData 30 | ## Happens when the user presses Tab. 31 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Navigation") 32 | 33 | var previous: FWidgetNavigationData 34 | ## Happens when the user presses Shift+Tab. 35 | ## UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Navigation") 36 | 37 | #if WITH_EDITOR 38 | proc getNavigationData(nav: EUINavigation): var FWidgetNavigationData 39 | proc getNavigationRule(nav:EUINavigation): EUINavigationRule 40 | #endif 41 | 42 | proc resolveExplictRules(widgetTree: ptr UWidgetTree) 43 | ## Resolve widget names 44 | 45 | proc updateMetaData(metaData: TSharedRef[FNavigationMetaData]) 46 | ## Updates a slate metadata object to match this configured navigation ruleset. 47 | 48 | proc isDefault(): bool {.noSideEffect.} 49 | ## @return true if the configured navigation object is the same as an un-customized navigation rule set. 50 | -------------------------------------------------------------------------------- /modules/umg/widgettransform.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(FWidgetTransform, header: "UMG.h", bycopy): 4 | ## Describes the standard transformation of a widget 5 | 6 | var translation: FVector2D 7 | ## The amount to translate the widget in slate units 8 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Transform, meta=( Delta = "1" )) 9 | 10 | var scale: FVector2D 11 | ## The scale to apply to the widget 12 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Transform, meta=( UIMin = "-5", UIMax = "5", Delta = "0.05" )) 13 | 14 | var shear: FVector2D 15 | ## The amount to shear the widget in slate units 16 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Transform, meta=( UIMin = "-89", ClampMin = "-89", UIMax = "89", ClampMax = "89", Delta = "1" )) 17 | 18 | var angle: float32 19 | ## The angle in degrees to rotate 20 | ## UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Transform, meta=( UIMin = "-180", UIMax = "180", Delta = "1" )) 21 | 22 | proc initFWidgetTransform(): FWidgetTransform {.constructor.} 23 | proc initFWidgetTransform(inTranslation, inScale, inShear: FVector2D; inAngle: float32): FWidgetTransform {.constructor.} 24 | 25 | proc isIdentity(): bool {.noSideEffect.} 26 | 27 | proc `==`(other: FWidgetTransform): bool {.noSideEffect.} 28 | proc `!=`(other: FWidgetTransform): bool {.noSideEffect.} 29 | 30 | proc toSlateRenderTransform(): FSlateRenderTransform {.noSideEffect.} 31 | -------------------------------------------------------------------------------- /modules/umg/widgettree.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | wclass(UWidgetTree of UObject, header: "UMG.h"): 4 | proc findWidget(name: FName): ptr UWidget {.noSideEffect.} 5 | ## Finds the widget in the tree by name. 6 | 7 | proc findWidget(inWidget: TSharedRef[SWidget]): ptr UWidget {.noSideEffect.} 8 | ## Finds a widget in the tree using the native widget as the key. 9 | 10 | proc findWidget[T: UWidget](name: FName): ptr T {.noSideEffect.} 11 | ## Finds the widget in the tree by name and casts the return to the desired type. 12 | 13 | proc removeWidget(widget: ptr UWidget): bool 14 | ## Removes the widget from the hierarchy and all sub widgets. 15 | 16 | proc findWidgetParent(widget: ptr UWidget, outChildIndex: int32): ptr UPanelWidget 17 | ## Gets the parent widget of a given widget, and potentially the child index. 18 | 19 | proc getAllWidgets(widgets: TArray[ptr UWidget]) {.noSideEffect.} 20 | ## Gathers all the widgets in the tree recursively 21 | 22 | proc constructWidget[T: UWidget](): ptr T 23 | ## Constructs the widget, and adds it to the tree. 24 | 25 | proc constructWidget[T: UWidget](widgetType: TSubclassOf[UWidget], widgetName: FName = NAME_None): ptr T 26 | ## Constructs the widget, and adds it to the tree. 27 | 28 | proc getChildWidgets*(parent: ptr UWidget, widgets: var TArray[ptr UWidget]) {.importcpp: "UWidgetTree::GetChildWidgets(@)", header: "UMG.h".} 29 | ## Gathers descendant child widgets of a parent widget. 30 | -------------------------------------------------------------------------------- /stubs/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "Binaries/**": true, 4 | "Build/**": true, 5 | "Intermediate/Build/**": true, 6 | "Intermediate/ReimportCache/**": true, 7 | "Content/Developers/**": true, 8 | "Content/Collections/**": true, 9 | "**/nimcache/**": true, 10 | "**/.nimgen/**": true 11 | }, 12 | "search.exclude": { 13 | "**/*.uasset": true, 14 | "**/*.psd": true 15 | }, 16 | "files.trimTrailingWhitespace": true, 17 | "editor.tabSize": 2, 18 | "editor.insertSpaces": true, 19 | "editor.rulers": [ 120 ], 20 | "files.eol": "\n", 21 | "nim.buildOnSave": false, 22 | "nim.lintOnSave": true, 23 | "nim.buildCommand": "cpp", 24 | "nim.project": "Intermediate/Nim/MyProjectRoot.nim" 25 | } 26 | -------------------------------------------------------------------------------- /stubs/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "echoCommand": true, 4 | "command": "${workspaceRoot}/build.cmd", 5 | "options": { 6 | "cwd": "${workspaceRoot}" 7 | }, 8 | "osx": { 9 | "command": "${workspaceRoot}/build.sh" 10 | }, 11 | "isShellCommand": true, 12 | "tasks": [ 13 | { 14 | "taskName": "deploy", 15 | "isBuildCommand": true, 16 | "showOutput": "silent" 17 | }, 18 | { 19 | "taskName": "build", 20 | "isBuildCommand": false, 21 | "showOutput": "silent" 22 | }, 23 | { 24 | "taskName": "clean", 25 | "isBuildCommand": false, 26 | "showOutput": "silent" 27 | } 28 | ], 29 | "problemMatcher": { 30 | "fileLocation": [ 31 | "relative", 32 | "${workspaceRoot}" 33 | ], 34 | "severity": "error", 35 | "pattern": { 36 | "regexp": "^([^(]*)\\(((\\d+)(, (\\d+))?)\\)\\s*((Warning|Error|Hint):)?(.*)$", 37 | "file": 1, 38 | "line": 3, 39 | "column": 5, 40 | "message": 8 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /stubs/build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set NIM_HOME=C:\Program Files (x86)\Nim\ rem change this 4 | set NIMUE_HOME=C:\Users\jdoe\nimue4\ rem change this 5 | set VS_HOME=C:\Program Files (x86)\Microsoft Visual Studio 14.0 6 | set UE4_HOME=C:\Program Files (x86)\Epic Games\4.12 7 | 8 | set PATH=%PATH%;%NIM_HOME%\bin\ 9 | 10 | call "%VS_HOME%\VC\bin\x86_amd64\vcvarsx86_amd64.bat" 11 | nim %* 12 | -------------------------------------------------------------------------------- /stubs/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export NIMUE_HOME=/Path/To/nimue4/ # change this 4 | export NIM_HOME=/Path/To/Nim/ # change this 5 | export UE4_HOME=/Users/Shared/UnrealEngine/4.12/ 6 | 7 | nim "$@" 8 | -------------------------------------------------------------------------------- /stubs/config.nims: -------------------------------------------------------------------------------- 1 | import strutils, ospaths 2 | 3 | mode = ScriptMode.Verbose 4 | 5 | proc getEnvOrRaise(envKey: string): string = 6 | if existsEnv(envKey): 7 | result = getEnv(envKey) 8 | else: 9 | raise newException(OSError, "Mandatory environment variable is not set: " & envKey) 10 | 11 | proc paramString(): string = 12 | result = "" 13 | for i in 1 .. UGameEngine::Tick(`delta`, `isIdleMode`);".} 33 | actualFrameTime = epochTime() - actualFrameTime 34 | 35 | var allowedGcTime = max(0.001, min(this.maxFrameTime - actualFrameTime - 0.002, 0.006)) 36 | block: 37 | scopeCycleCounter(PERF_NIM_GC) 38 | GC_step(int(allowedGcTime * 1_000_000), false, 0) 39 | -------------------------------------------------------------------------------- /tools/uebuild/usage.txt: -------------------------------------------------------------------------------- 1 | Wrapper around Unreal Build Tool (UBT) that compiles and prepares Nim files 2 | before passing further to UBT 3 | 4 | uebuild [options] [command=deploy] [custom UBT options] 5 | 6 | Command: 7 | deploy build the project with hot redeploy 8 | precook build the editor for further cooking 9 | clean clean Nim and UE generated files 10 | compilenim compile Nim files only, without invoking UBT 11 | 12 | Options: 13 | -d, --projectDir directory with .uproject file 14 | -e, --engineDir UE4 root directory 15 | -p, --platform platform to build for; current platform by default; 16 | valid values: Win32, Win64, WinRT, WinRT_ARM, UWP, 17 | Mac, XboxOne, PS4, IOS, Android, HTML5, Linux, 18 | AllDesktop, TVOS 19 | -t, --target UE4 target; "{ProjectName}Editor" by default 20 | -m, --mode build mode; "Development" by default; valid values: 21 | Debug, DebugGame, Development, Shipping, Test 22 | --cpu (optional) override cpu architecture; automatically detected from 'platform' by default; 23 | valid value: arm, arm64, i386, amd64 -------------------------------------------------------------------------------- /ue4.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | when not defined(CPP): 4 | {.error: "Must be compiled with cpp switch".} 5 | 6 | import macros, typetraits, lib/macroutils, lib/clibpp 7 | import sequtils, strutils 8 | 9 | # these exports are needed for some templates to work 10 | export strutils.format, strutils.split, strutils.join, strutils.capitalizeAscii 11 | export sequtils.map 12 | export typetraits.name 13 | export expandObjReference 14 | export macroutils.toCppSubstitution 15 | 16 | const withEditor* = defined(editor) 17 | 18 | {.hints: off.} 19 | 20 | # {.hint[XDeclaredButNotUsed]: off.} <- didn't work 21 | import macros/uetypes 22 | import macros/uedelegate 23 | import macros/bpasync 24 | import modules/core/coremodule 25 | 26 | export uetypes 27 | export uedelegate 28 | export bpasync 29 | export coremodule 30 | export clibpp 31 | # {.hint[XDeclaredButNotUsed]: on.} 32 | {.hints: on.} 33 | -------------------------------------------------------------------------------- /ue4.nim.cfg: -------------------------------------------------------------------------------- 1 | --define:CPP 2 | --path:"$projectpath" 3 | -------------------------------------------------------------------------------- /ue4editor.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | import modules/editor/editormodule 4 | export editormodule 5 | -------------------------------------------------------------------------------- /ue4editor.nim.cfg: -------------------------------------------------------------------------------- 1 | --define:CPP 2 | --path:"$projectpath" 3 | -------------------------------------------------------------------------------- /ue4gamemenubuilder.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | import modules/gamemenubuilder/gamemenubuildermodule 4 | export gamemenubuildermodule 5 | -------------------------------------------------------------------------------- /ue4gamemenubuilder.nim.cfg: -------------------------------------------------------------------------------- 1 | --define:CPP 2 | --path:"$projectpath" 3 | -------------------------------------------------------------------------------- /ue4umg.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Xored Software, Inc. 2 | 3 | import modules/umg/umgmodule 4 | export umgmodule 5 | -------------------------------------------------------------------------------- /ue4umg.nim.cfg: -------------------------------------------------------------------------------- 1 | --define:CPP 2 | --path:"$projectpath" 3 | --------------------------------------------------------------------------------