Skip to content

Commit da01d96

Browse files
committed
Cursor bank and update deps
1 parent 40e5240 commit da01d96

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

Project.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,22 @@ repo = "https://github.com/Kyjor/JulGame.jl.git"
55
version = "0.1.0"
66

77
[deps]
8-
CImGui = "5d785b6c-b76f-510e-a07c-3070796c7e87"
98
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
109
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
11-
NativeFileDialog = "e1fe445b-aa65-4df4-81c1-2041507f0fd4"
1210
SimpleDirectMediaLayer = "98e33af6-2ee5-5afd-9e75-cbc738b767c4"
1311
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1412
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1513

1614
[compat]
1715
julia = "^1.9"
18-
CImGui = "^2.0"
1916
JSON3 = "^1"
20-
NativeFileDialog = "^0.2"
2117
SimpleDirectMediaLayer = "^0.5"
2218
Test = "^1"
2319

2420
[extras]
21+
CImGui = "5d785b6c-b76f-510e-a07c-3070796c7e87"
22+
NativeFileDialog = "e1fe445b-aa65-4df4-81c1-2041507f0fd4"
2523
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2624

2725
[targets]
28-
test = ["Test"]
26+
test = ["Test", "NativeFileDialog", "CImGui"]

src/editor/JulGameEditor/Components/CameraWindow.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ function show_camera_window(this::CameraWindow)
7373
this.camera.size = Vector2(this.camera.size.x, Float64(size_y32))
7474
end
7575

76-
CImGui.Text("Starting Coordinates: $(this.camera.startingCoordinates.x), $(this.camera.startingCoordinates.y)")
77-
7876
# camera background color
7977
# CImGui.Text("Background Color:")
8078
# color_r = UInt8(this.camera.backgroundColor[1])

src/engine/Input/Input.jl

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ module InputModule
3030
numHats
3131
button
3232

33+
# Cursor bank
34+
cursorBank::Dict{String, Ptr{SDL2.SDL_SystemCursor}} # Key is the name of the cursor, value is the SDL2 cursor
35+
3336
function Input()
3437
this = new()
3538

@@ -83,6 +86,9 @@ module InputModule
8386
this.yDir = 0
8487
this.button = 0
8588

89+
this.cursorBank = Dict{String, SDL2.SDL_SystemCursor}()
90+
create_cursor_bank(this)
91+
8692
return this
8793
end
8894
end
@@ -109,6 +115,7 @@ module InputModule
109115
continue
110116
end
111117

118+
insideAnyButton = false
112119
for screenButton in MAIN.scene.uiElements
113120
if split("$(typeof(screenButton))", ".")[end] != "ScreenButton"
114121
continue
@@ -129,9 +136,16 @@ module InputModule
129136
if !eventWasInsideThisButton
130137
continue
131138
end
139+
insideAnyButton = true
140+
141+
SDL2.SDL_SetCursor(this.cursorBank["hand"])
132142

133143
JulGame.UI.handle_event(screenButton, evt, x[1], y[1])
134144
end
145+
146+
if !insideAnyButton
147+
SDL2.SDL_SetCursor(this.cursorBank["arrow"])
148+
end
135149
end
136150

137151
handle_mouse_event(this, evt)
@@ -363,5 +377,19 @@ module InputModule
363377
end
364378
return false
365379
end
366-
380+
381+
function create_cursor_bank(this::Input)
382+
this.cursorBank["arrow"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_ARROW)
383+
this.cursorBank["ibeam"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_IBEAM)
384+
this.cursorBank["wait"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_WAIT)
385+
this.cursorBank["crosshair"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_CROSSHAIR)
386+
this.cursorBank["waitarrow"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_WAITARROW)
387+
this.cursorBank["sizeall"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_SIZEALL)
388+
this.cursorBank["sizenesw"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_SIZENESW)
389+
this.cursorBank["sizenwse"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_SIZENWSE)
390+
this.cursorBank["sizewe"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_SIZEWE)
391+
this.cursorBank["sizens"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_SIZENS)
392+
this.cursorBank["no"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_NO)
393+
this.cursorBank["hand"] = SDL2.SDL_CreateSystemCursor(SDL2.SDL_SYSTEM_CURSOR_HAND)
394+
end
367395
end

src/engine/UI/ScreenButton.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module ScreenButtonModule
1616
buttonUpSpritePath::String
1717
buttonUpTexture
1818
fontPath::Union{String, Ptr{Nothing}}
19+
isHovered::Bool
1920
isInitialized::Bool
2021
mouseOverSprite
2122
name::String
@@ -46,6 +47,7 @@ module ScreenButtonModule
4647
this.textTexture = C_NULL
4748
this.isInitialized = false
4849
this.persistentBetweenScenes = false
50+
this.isHovered = false
4951

5052
return this
5153
end

0 commit comments

Comments
 (0)