Skip to content

Commit

Permalink
Fixed textbox bug and show some errors in debug window for editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyjor committed Aug 3, 2024
1 parent b41f85a commit 50f0728
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 107 deletions.
1 change: 1 addition & 0 deletions src/SceneManagement/SceneWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module SceneWriterModule
"""
function serialize_entities(entities::Array, uiElements::Array, projectPath, sceneName)

println("Serializing entities")
entitiesDict = []
uiElementsDict = []

Expand Down
3 changes: 2 additions & 1 deletion src/UI/TextBox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ module TextBoxModule
end

function UI.load_font(this::TextBox, basePath::String, fontPath::String)
# println("loading font from $(fontPath)")
println("loading font from base: $(basePath)")
println("loading font from $(fontPath)")
this.font = CallSDLFunction(SDL2.TTF_OpenFont, joinpath(basePath, fontPath), this.fontSize)
if this.font == C_NULL
return
Expand Down
8 changes: 7 additions & 1 deletion src/editor/JulGameEditor/Components/ComponentInputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,13 @@ function show_textbox_fields(textbox)
end
textbox.fontPath = currentTextInTextBox

CImGui.Button("Load Font") && (UI.load_font(textbox, joinpath(BasePath), joinpath("Fonts", "FiraCode", "ttf", "FiraCode-Regular.ttf")))
basePath = joinpath(BasePath, "assets", "fonts")
fontPath = joinpath(strip(String(textbox.fontPath)))
if strip(String(currentTextInTextBox)) == "" || joinpath(strip(String(currentTextInTextBox))) == joinpath("Fonts", "FiraCode", "ttf", "FiraCode-Regular.ttf")
basePath = joinpath(pwd(), "..")
fontPath = joinpath("Fonts", "FiraCode", "ttf", "FiraCode-Regular.ttf")
end
CImGui.Button("Load Font") && (UI.load_font(textbox, basePath, fontPath))
else
show_textbox_fields(textbox, field)
end
Expand Down
3 changes: 2 additions & 1 deletion src/editor/JulGameEditor/Components/ScreenButtonFields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ function show_screenbutton_fields(selectedScreenButton, screenButtonField)
@c CImGui.InputInt("$(screenButtonField) y", &y, 1)

if x != Value.x || y != Value.y
selectedScreenButton.setVector2Value(screenButtonField, convert(Float64, x), convert(Float64, y))
#selectedScreenButton.setVector2Value(screenButtonField, convert(Float64, x), convert(Float64, y))
setfield!(selectedScreenButton, screenButtonField, Vector2(x, y))
# JulGame.update_text(selectedScreenButton, selectedScreenButton.text)
end
elseif fieldName == "autoSizeText" || fieldName == "isCentered"
Expand Down
3 changes: 2 additions & 1 deletion src/editor/JulGameEditor/Components/TextBoxFields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ function show_textbox_fields(selectedTextBox, textBoxField)
@c CImGui.InputInt("$(textBoxField) y", &y, 1)

if x != Value.x || y != Value.y
selectedTextBox.setVector2Value(textBoxField, convert(Float64, x), convert(Float64, y))
#selectedTextBox.setVector2Value(textBoxField, convert(Float64, x), convert(Float64, y))
setfield!(selectedTextBox, textBoxField, Vector2(x, y))
JulGame.update_text(selectedTextBox, selectedTextBox.text)
end
elseif fieldName == "autoSizeText" || fieldName == "isCenteredX" || fieldName == "isCenteredY" || fieldName == "isWorldEntity"
Expand Down
198 changes: 108 additions & 90 deletions src/editor/JulGameEditor/Editor.jl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/editor/JulGameEditor/Windows/DebugWindow.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function show_debug_window(latestExceptions::Vector{String} = String[])
function show_debug_window(latestExceptions)
@cstatic begin
CImGui.Begin("Debug")
CImGui.Text("The latest 10 exceptions are:")
Expand Down
2 changes: 1 addition & 1 deletion src/editor/JulGameEditor/src/JulGameEditor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ module JulGameEditor
julia_main() = run()
end
# Uncomment to allow for direct execution of this file. If you want to build this project with PackageCompiler, comment the line below
#JulGameEditor.run()
JulGameEditor.run()
22 changes: 11 additions & 11 deletions src/editor/JulGameEditor/src/imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ Collapsed=0

[Window][Debug]
Pos=453,808
Size=1050,272
Size=861,272
Collapsed=0
DockId=0x00000003,0

[Window][Scene]
Pos=453,19
Size=1050,787
Size=861,787
Collapsed=0
DockId=0x00000002,0

Expand All @@ -43,13 +43,13 @@ Collapsed=0

[Window][Controls]
Pos=453,808
Size=1050,272
Size=861,272
Collapsed=0
DockId=0x00000003,1

[Window][Dear ImGui Demo]
Pos=1505,19
Size=415,1061
Pos=1316,19
Size=604,1061
Collapsed=0
DockId=0x0000000A,1

Expand Down Expand Up @@ -87,8 +87,8 @@ Size=1920,1061
Collapsed=0

[Window][Scene List]
Pos=1505,19
Size=415,1061
Pos=1316,19
Size=604,1061
Collapsed=0
DockId=0x0000000A,0

Expand Down Expand Up @@ -164,14 +164,14 @@ Column 2 Weight=1.0000

[Docking][Data]
DockSpace ID=0x7C6B3D9B Window=0xA87D555D Pos=0,19 Size=1920,1061 Split=X
DockNode ID=0x00000007 Parent=0x7C6B3D9B SizeRef=1503,828 Split=X
DockNode ID=0x00000007 Parent=0x7C6B3D9B SizeRef=1314,828 Split=X
DockNode ID=0x00000004 Parent=0x00000007 SizeRef=451,828 Split=Y Selected=0xC7219E3D
DockNode ID=0x00000006 Parent=0x00000004 SizeRef=316,503 Selected=0x29EABFBD
DockNode ID=0x0000000B Parent=0x00000004 SizeRef=316,556 Selected=0x60AF69E6
DockNode ID=0x00000005 Parent=0x00000007 SizeRef=1050,828 Split=Y
DockNode ID=0x0000000B Parent=0x00000004 SizeRef=316,556 Selected=0xC7219E3D
DockNode ID=0x00000005 Parent=0x00000007 SizeRef=861,828 Split=Y
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1440,787 Selected=0xE192E354
DockNode ID=0x00000003 Parent=0x00000005 SizeRef=1440,272 CentralNode=1 Selected=0x67284010
DockNode ID=0x00000008 Parent=0x7C6B3D9B SizeRef=415,828 Split=Y Selected=0xD04A4B96
DockNode ID=0x00000008 Parent=0x7C6B3D9B SizeRef=604,828 Split=Y Selected=0xD04A4B96
DockNode ID=0x00000009 Parent=0x00000008 SizeRef=503,414 Selected=0xD04A4B96
DockNode ID=0x0000000A Parent=0x00000008 SizeRef=503,412 Selected=0x77FEF510

0 comments on commit 50f0728

Please sign in to comment.