Skip to content

Commit

Permalink
Create a new project in the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyjor committed Sep 5, 2024
1 parent 58e9b1c commit 75598b4
Show file tree
Hide file tree
Showing 5 changed files with 263 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ function game_loop(this::Main, startTime::Ref{UInt64} = Ref(UInt64(0)), lastPhys
function start_game_in_editor(this::Main, path::String)
this.isGameModeRunningInEditor = true
SceneBuilderModule.add_scripts_to_entities(path)
initialize_scripts_and_components(false)
initialize_scripts_and_components()

Check warning on line 684 in src/Main.jl

View check run for this annotation

Codecov / codecov/patch

src/Main.jl#L681-L684

Added lines #L681 - L684 were not covered by tests
end

function stop_game_in_editor(this::Main)
Expand Down
30 changes: 18 additions & 12 deletions src/editor/JulGameEditor/Editor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ module Editor
include.(filter(contains(r".jl$"), readdir(joinpath(@__DIR__, "Windows"); join=true)))

function run(is_test_mode::Bool=false)
info = init_sdl_and_imgui()
windowTitle = "JulGame Editor v0.1.0"

info = init_sdl_and_imgui(windowTitle)
window, renderer, ctx, io, clear_color = info[1], info[2], info[3], info[4], info[5]
startingSize = ImVec2(1920, 1080)
sceneTexture = SDL2.SDL_CreateTexture(renderer, SDL2.SDL_PIXELFORMAT_BGRA8888, SDL2.SDL_TEXTUREACCESS_TARGET, startingSize.x, startingSize.y)# SDL2.SDL_SetRenderTarget(renderer, sceneTexture)
Expand All @@ -35,7 +37,7 @@ module Editor
currentSceneMain = nothing
currentSceneName = ""
currentScenePath = ""
currentSelectedProjectPath = ""
currentSelectedProjectPath = Ref("")
gameInfo = []
##############################
# Hierarchy variables
Expand Down Expand Up @@ -64,11 +66,14 @@ module Editor

duplicationMode = false

# Engine Timing
startTime = Ref(UInt64(0))
lastPhysicsTime = Ref(UInt64(SDL2.SDL_GetTicks()))

# Dialogs
currentDialog::Base.RefValue{String} = Ref("")
newSceneText = Ref("")
newProjectText = Ref("")

try
while !quit
Expand All @@ -84,7 +89,7 @@ module Editor
################################# MAIN MENU BAR
events = Dict{String, Function}()
if currentSceneMain !== nothing
events["Save"] = save_scene_event(currentSceneMain.scene.entities, currentSceneMain.scene.uiElements, currentSelectedProjectPath, String(currentSceneName))
events["Save"] = save_scene_event(currentSceneMain.scene.entities, currentSceneMain.scene.uiElements, currentSelectedProjectPath[], String(currentSceneName))

Check warning on line 92 in src/editor/JulGameEditor/Editor.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Editor.jl#L92

Added line #L92 was not covered by tests
end
events["New-project"] = create_project_event(currentDialog)
events["Select-project"] = select_project_event(currentSceneMain, scenesLoadedFromFolder, currentDialog)
Expand Down Expand Up @@ -117,7 +122,7 @@ module Editor
JulGame.IS_EDITOR = true

Check warning on line 122 in src/editor/JulGameEditor/Editor.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Editor.jl#L122

Added line #L122 was not covered by tests
JulGame.PIXELS_PER_UNIT = 16
currentDialog[] = "Open Scene"
currentSelectedProjectPath = SceneLoaderModule.get_project_path_from_full_scene_path(scene)
currentSelectedProjectPath[] = SceneLoaderModule.get_project_path_from_full_scene_path(scene)

Check warning on line 125 in src/editor/JulGameEditor/Editor.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Editor.jl#L124-L125

Added lines #L124 - L125 were not covered by tests
else
currentDialog[] = "Open Scene"

Check warning on line 127 in src/editor/JulGameEditor/Editor.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Editor.jl#L127

Added line #L127 was not covered by tests
end
Expand All @@ -128,6 +133,10 @@ module Editor
CImGui.End()
end

if currentSelectedProjectPath[] != "" && unsafe_string(SDL2.SDL_GetWindowTitle(window)) != "$(windowTitle) - $(currentSelectedProjectPath[])"
newWindowTitle = "$(windowTitle) - $(currentSelectedProjectPath[])"
SDL2.SDL_SetWindowTitle(window, newWindowTitle)

Check warning on line 138 in src/editor/JulGameEditor/Editor.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Editor.jl#L137-L138

Added lines #L137 - L138 were not covered by tests
end
if currentDialog[] == "Open Scene"
#println("Opening scene: $(currentDialog[][2])")
if confirmation_dialog(currentDialog) == "ok" && currentSceneName != ""
Expand All @@ -142,26 +151,23 @@ module Editor
newSceneName = new_scene_dialog(currentDialog, newSceneText)
if newSceneName != ""
currentSceneName = newSceneName
currentScenePath = joinpath(currentSelectedProjectPath, "scenes", "$(newSceneName).json")
currentScenePath = joinpath(currentSelectedProjectPath[], "scenes", "$(newSceneName).json")
touch(currentScenePath)
file = open(currentScenePath, "w")
println(file, sceneJsonContents)
close(file)
JulGame.change_scene("$(String(currentSceneName)).json")
scenesLoadedFromFolder[] = get_all_scenes_from_folder(currentSelectedProjectPath)
scenesLoadedFromFolder[] = get_all_scenes_from_folder(currentSelectedProjectPath[])

Check warning on line 160 in src/editor/JulGameEditor/Editor.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Editor.jl#L151-L160

Added lines #L151 - L160 were not covered by tests
end
elseif currentDialog[] == "Select Project"
selectedProjectPath = select_project_dialog(currentDialog, scenesLoadedFromFolder)
if selectedProjectPath != ""
currentSceneMain = nothing

Check warning on line 165 in src/editor/JulGameEditor/Editor.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Editor.jl#L163-L165

Added lines #L163 - L165 were not covered by tests
end
elseif currentDialog[] == "New Project"
selectedProjectPath = create_project_dialog(currentDialog, scenesLoadedFromFolder)
selectedProjectPath = create_project_dialog(currentDialog, scenesLoadedFromFolder, currentSelectedProjectPath, newProjectText)
if selectedProjectPath != ""
println("Selected project path: $(selectedProjectPath)")

Check warning on line 170 in src/editor/JulGameEditor/Editor.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Editor.jl#L168-L170

Added lines #L168 - L170 were not covered by tests
#currentSceneMain = nothing
# currentSelectedProjectPath = selectedProjectPath
# scenesLoadedFromFolder[] = get_all_scenes_from_folder(currentSelectedProjectPath)
end
end

Expand All @@ -179,7 +185,7 @@ module Editor
sceneWindowSize = show_scene_window(currentSceneMain, sceneTexture, scrolling, zoom_level, duplicationMode, playMode)
if playMode[] != wasPlaying && currentSceneMain !== nothing
if playMode[]
JulGame.MainLoop.start_game_in_editor(currentSceneMain, currentSelectedProjectPath)
JulGame.MainLoop.start_game_in_editor(currentSceneMain, currentSelectedProjectPath[])
elseif !playMode[]
JulGame.MainLoop.stop_game_in_editor(currentSceneMain)
JulGame.change_scene(String(currentSceneName))

Check warning on line 191 in src/editor/JulGameEditor/Editor.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Editor.jl#L187-L191

Added lines #L187 - L191 were not covered by tests
Expand Down Expand Up @@ -443,7 +449,7 @@ module Editor
catch e
backup_file_name = backup_file_name = "$(replace(currentSceneName, ".json" => ""))-backup-$(replace(Dates.format(Dates.now(), "yyyy-mm-ddTHH:MM:SS"), ":" => "-")).json"
@info string("Backup file name: ", backup_file_name)
SceneWriterModule.serialize_entities(currentSceneMain.scene.entities, currentSceneMain.scene.uiElements, currentSelectedProjectPath, backup_file_name)
SceneWriterModule.serialize_entities(currentSceneMain.scene.entities, currentSceneMain.scene.uiElements, currentSelectedProjectPath[], backup_file_name)

Check warning on line 452 in src/editor/JulGameEditor/Editor.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Editor.jl#L452

Added line #L452 was not covered by tests
Base.show_backtrace(stderr, catch_backtrace())
@warn "Error in renderloop!" exception=e
finally
Expand Down
117 changes: 111 additions & 6 deletions src/editor/JulGameEditor/Utils/EditorUtils.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function init_sdl_and_imgui()
function init_sdl_and_imgui(windowTitle::String)
if SDL2.SDL_Init(SDL2.SDL_INIT_VIDEO | SDL2.SDL_INIT_TIMER | SDL2.SDL_INIT_GAMECONTROLLER) < 0
println("failed to init: ", unsafe_string(SDL2.SDL_GetError()));
end
SDL2.SDL_SetHint(SDL2.SDL_HINT_IME_SHOW_UI, "1")

window = SDL2.SDL_CreateWindow(
"JulGame Editor v0.1.0", SDL2.SDL_WINDOWPOS_CENTERED, SDL2.SDL_WINDOWPOS_CENTERED, 1280, 720,
windowTitle, SDL2.SDL_WINDOWPOS_CENTERED, SDL2.SDL_WINDOWPOS_CENTERED, 1280, 720,
SDL2.SDL_WINDOW_SHOWN | SDL2.SDL_WINDOW_RESIZABLE | SDL2.SDL_WINDOW_ALLOW_HIGHDPI
)
if window == C_NULL
Expand Down Expand Up @@ -182,20 +182,41 @@ function create_project_event(dialog)
return event
end

function create_project_dialog(dialog, scenesLoadedFromFolder)
function create_project_dialog(dialog, scenesLoadedFromFolder, selectedProjectPath, newProjectText)

Check warning on line 185 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L185

Added line #L185 was not covered by tests

CImGui.OpenPopup(dialog[])

Check warning on line 187 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L187

Added line #L187 was not covered by tests

if CImGui.BeginPopupModal(dialog[], C_NULL, CImGui.ImGuiWindowFlags_AlwaysAutoResize)
CImGui.Text("Are you sure you would like to open another project?\nIf you currently have a project open, any unsaved changes will be lost.\n\n")
CImGui.NewLine()
if CImGui.Button("OK", (120, 0))
text = text_input_single_line("Project Name", newProjectText)
newProjectText[] = strip(newProjectText[])
newProjectText[] = replace(newProjectText[], " " => "-")
newProjectText[] = replace(newProjectText[], "." => "-")
CImGui.NewLine()

Check warning on line 196 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L189-L196

Added lines #L189 - L196 were not covered by tests

if CImGui.Button("Open", (120, 0))
selectedProjectPath[] = choose_folder_with_dialog()

Check warning on line 199 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L198-L199

Added lines #L198 - L199 were not covered by tests
end
CImGui.SameLine()

Check warning on line 201 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L201

Added line #L201 was not covered by tests

newProjectPath = joinpath(selectedProjectPath[], newProjectText[])
CImGui.Text("Full Path: $(newProjectPath)")
CImGui.NewLine()

Check warning on line 205 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L203-L205

Added lines #L203 - L205 were not covered by tests

pathAlreadyExists = isdir(newProjectPath)
if !pathAlreadyExists && selectedProjectPath[] != "" && newProjectText[] != "" && CImGui.Button("Confirm", (120, 0))
CImGui.CloseCurrentPopup()
dialog[] = ""

Check warning on line 210 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L207-L210

Added lines #L207 - L210 were not covered by tests

projectPath = choose_folder_with_dialog() #|> (dir) -> (create_new_project(dir))
println("Project path: ", projectPath)
create_new_project(newProjectPath, newProjectText[])
scenesLoadedFromFolder[] = get_all_scenes_from_base_folder(joinpath(newProjectPath, newProjectText[]))

Check warning on line 213 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L212-L213

Added lines #L212 - L213 were not covered by tests
end

if pathAlreadyExists
CImGui.Text("The path already exists. Please choose a different name.")

Check warning on line 217 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L216-L217

Added lines #L216 - L217 were not covered by tests
end

CImGui.SetItemDefaultFocus()
CImGui.SameLine()
if CImGui.Button("Cancel",(120, 0))
Expand All @@ -207,6 +228,90 @@ function create_project_dialog(dialog, scenesLoadedFromFolder)
return ""

Check warning on line 228 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L228

Added line #L228 was not covered by tests
end

function create_new_project(newProjectPath, newProjectName)

Check warning on line 231 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L231

Added line #L231 was not covered by tests
# create the project folder
if !isdir(newProjectPath)
mkdir(newProjectPath)

Check warning on line 234 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L233-L234

Added lines #L233 - L234 were not covered by tests
end

# add the julia .gitignore file
gitignore = joinpath(newProjectPath, ".gitignore")
touch(gitignore)
file = open(gitignore, "w")
println(file, gitIgnoreFileContent)
close(file)

Check warning on line 242 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L238-L242

Added lines #L238 - L242 were not covered by tests

# create a readme file
readme = joinpath(newProjectPath, "README.md")
touch(readme)
file = open(readme, "w")
println(file, readMeFileContent(newProjectName))
close(file)

Check warning on line 249 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L245-L249

Added lines #L245 - L249 were not covered by tests

# create the inner project folder (same name as the project)
projectFolder = joinpath(newProjectPath, newProjectName)
mkdir(projectFolder)
if !isdir(projectFolder)
mkdir(projectFolder)

Check warning on line 255 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L252-L255

Added lines #L252 - L255 were not covered by tests
end

# create assets folder. Inside of the assets folder, we also create folders for fonts, images, and sounds
mkdir(joinpath(projectFolder, "assets"))
mkdir(joinpath(projectFolder, "assets", "fonts"))
mkdir(joinpath(projectFolder, "assets", "images"))
mkdir(joinpath(projectFolder, "assets", "sounds"))

Check warning on line 262 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L259-L262

Added lines #L259 - L262 were not covered by tests

# Todo: insert the default font into the fonts folder
# copy(joinpath(pwd(), "..", "Fonts", "FiraCode", "ttf", "FiraCode-Regular.ttf"), joinpath(projectFolder, "assets", "fonts", "FiraCode-Regular.ttf"))


# create the scenes folder
scenesFolder = joinpath(projectFolder, "scenes")
mkdir(scenesFolder)

Check warning on line 270 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L269-L270

Added lines #L269 - L270 were not covered by tests

#create default scene
defaultScene = joinpath(scenesFolder, "scene.json")
touch(defaultScene)
file = open(defaultScene, "w")
println(file, sceneJsonContents)
close(file)

Check warning on line 277 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L273-L277

Added lines #L273 - L277 were not covered by tests

# create the scripts folder
scriptsFolder = joinpath(projectFolder, "scripts")
mkdir(scriptsFolder)

Check warning on line 281 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L280-L281

Added lines #L280 - L281 were not covered by tests

# create the src folder
srcFolder = joinpath(projectFolder, "src")
mkdir(srcFolder)

Check warning on line 285 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L284-L285

Added lines #L284 - L285 were not covered by tests

# create the src files, one named after the project, and one named Run.jl
srcFile = joinpath(srcFolder, "$(newProjectName).jl")
touch(srcFile)
file = open(srcFile, "w")
println(file, mainFileContent(newProjectName))
close(file)

Check warning on line 292 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L288-L292

Added lines #L288 - L292 were not covered by tests

runFile = joinpath(srcFolder, "Run.jl")
touch(runFile)
file = open(runFile, "w")
println(file, runFileContent(newProjectName))
close(file)

Check warning on line 298 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L294-L298

Added lines #L294 - L298 were not covered by tests

# create precompile_app.jl
precompileFile = joinpath(srcFolder, "precompile_app.jl")
touch(precompileFile)
file = open(precompileFile, "w")
println(file, precompileFileContent(newProjectName))
close(file)

Check warning on line 305 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L301-L305

Added lines #L301 - L305 were not covered by tests

# create the project.toml file
projectToml = joinpath(projectFolder, "Project.toml")
touch(projectToml)
file = open(projectToml, "w")
println(file, projectTomlContent(newProjectName))
close(file)

Check warning on line 312 in src/editor/JulGameEditor/Utils/EditorUtils.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/EditorUtils.jl#L308-L312

Added lines #L308 - L312 were not covered by tests
end

function move_entities(entities, origin, destination)
if indexin([destination], origin) != [nothing]
return
Expand Down
112 changes: 111 additions & 1 deletion src/editor/JulGameEditor/Utils/FileContents.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,114 @@
sceneJsonContents = "{
\"Entities\": [ ],
\"UIElements\": [ ]
}"
}"


gitIgnoreFileContent = "# Files generated by invoking Julia with --code-coverage
*.jl.cov
*.jl.*.cov
# Files generated by invoking Julia with --track-allocation
*.jl.mem
# System-specific files and directories generated by the BinaryProvider and BinDeps packages
# They contain absolute paths specific to the host computer, and so should not be committed
deps/deps.jl
deps/build.log
deps/downloads/
deps/usr/
deps/src/
# Build artifacts for creating documentation generated by the Documenter package
docs/build/
docs/site/
# Build artifacts for PackageCompiler builds
/Build
# File generated by Pkg, the package manager, based on a corresponding Project.toml
# It records a fixed state of all packages used by the project. As such, it should not be
# committed for packages, but should be committed for applications that require a static
# environment.
Manifest.toml
"

function readMeFileContent(projectName)
return "# $projectName \n Made with JulGame.jl: https://github.com/Kyjor/JulGame.jl \nHow to run from command line: cd $projectName\\src then run \"julia Run.jl\""

Check warning on line 37 in src/editor/JulGameEditor/Utils/FileContents.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/FileContents.jl#L36-L37

Added lines #L36 - L37 were not covered by tests
end

function mainFileContent(projectName)
return "module $projectName

Check warning on line 41 in src/editor/JulGameEditor/Utils/FileContents.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/FileContents.jl#L40-L41

Added lines #L40 - L41 were not covered by tests
using JulGame
using JulGame.Math
function run()
JulGame.MAIN = JulGame.Main(Float64(1.0))
JulGame.PIXELS_PER_UNIT = 16
scene = SceneBuilderModule.Scene(\"scene.json\")
SceneBuilderModule.load_and_prepare_scene(scene, \"$projectName\", Vector2(1280, 720),Vector2(1920, 1080), false, 1.0, true, 60)
end
julia_main() = run()
end"
end

function runFileContent(projectName)
return "include(\"$projectName.jl\")

Check warning on line 57 in src/editor/JulGameEditor/Utils/FileContents.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/FileContents.jl#L56-L57

Added lines #L56 - L57 were not covered by tests
using .$projectName
$projectName.julia_main()"
end

function precompileFileContent(projectName)
return "using $projectName

Check warning on line 65 in src/editor/JulGameEditor/Utils/FileContents.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/FileContents.jl#L64-L65

Added lines #L64 - L65 were not covered by tests
$projectName.julia_main()"
end

function projectTomlContent(projectName)
return "name = \"$projectName\"

Check warning on line 71 in src/editor/JulGameEditor/Utils/FileContents.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/FileContents.jl#L70-L71

Added lines #L70 - L71 were not covered by tests
uuid = \"$(JulGame.generate_uuid())\"
authors = [\"Your Name Here\"]
version = \"0.1.0\"
[deps]
JulGame = \"4850f9bb-d191-4a1e-9f97-ee64062927c3\""
end

function newScriptContent(scriptName)
return "mutable struct $scriptName

Check warning on line 81 in src/editor/JulGameEditor/Utils/FileContents.jl

View check run for this annotation

Codecov / codecov/patch

src/editor/JulGameEditor/Utils/FileContents.jl#L80-L81

Added lines #L80 - L81 were not covered by tests
parent # do not remove this line, this is a reference to the entity that this script is attached to
# This is where you define your script's fields
# Example: speed::Float64
function $scriptName()
this = new() # do not remove this line
# this is where you initialize your script's fields
# Example: this.speed = 1.0
return this # do not remove this line
end
end
# This is called when a scene is loaded, or when script is added to an entity
# This is where you should register collision events or other events
# Do not remove this function
function JulGame.initialize(this::$scriptName)
end
# This is called every frame
# Do not remove this function
function JulGame.update(this::$scriptName, deltaTime)
end
# This is called when the script is removed from an entity (scene change, entity deletion)
# Do not remove this function
function JulGame.on_shutdown(this::$scriptName)
end
"
end
Loading

0 comments on commit 75598b4

Please sign in to comment.