Skip to content

Commit

Permalink
feature: screenbutton isActive and cleaned up editor field overwriting
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyjor committed Jan 12, 2025
1 parent 035893f commit 59965b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/engine/SceneManagement/SceneBuilder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,22 +246,18 @@ module SceneBuilderModule
constructor = Base.invokelatest(getfield, module_name, Symbol(script.name))
newScript = Base.invokelatest(constructor)
scriptFields = get(script, "fields", Dict())

@debug("getting fields for: $(script)")
for (key, value) in scriptFields
ftype = nothing
try
ftype = fieldtype(typeof(newScript), Symbol(key))
if ftype == Float64
value = Float64(value)
elseif ftype == Int32
value = Int32(value)
elseif ftype == Int64
value = Int64(value)
elseif ftype == EditorExport
@debug("type: $(ftype)")
if ftype <: EditorExport
@debug "Overwriting $(key) to $(value) using scene file"
Base.invokelatest(setfield!, newScript, key, EditorExport(value))
@info "Overwriting $(key) to $(value) using scene file"
continue
elseif value === nothing
@debug "Value is nothing"
continue
end
catch e
Expand Down
6 changes: 6 additions & 0 deletions src/engine/UI/ScreenButton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module ScreenButtonModule
buttonUpSpritePath::String
buttonUpTexture
fontPath::Union{String, Ptr{Nothing}}
isActive::Bool
isHovered::Bool
isInitialized::Bool
mouseOverSprite
Expand Down Expand Up @@ -48,6 +49,7 @@ module ScreenButtonModule
this.isInitialized = false
this.persistentBetweenScenes = false
this.isHovered = false
this.isActive = true

return this
end
Expand All @@ -58,6 +60,10 @@ module ScreenButtonModule
UI.initialize(this)
end

if !this.isActive
return
end

if !this.mouseOverSprite && this.currentTexture == this.buttonDownTexture
#TODO: this.currentTexture = this.buttonUpTexture
end
Expand Down

0 comments on commit 59965b0

Please sign in to comment.