add cursor hovering and dragging status
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 667 B |
BIN
JCursor/Cursor1.png
Normal file
After Width: | Height: | Size: 447 B |
BIN
JCursor/Cursor2.png
Normal file
After Width: | Height: | Size: 504 B |
BIN
JCursor/CursorDrag.png
Normal file
After Width: | Height: | Size: 646 B |
BIN
JCursor/CursorDrag1.png
Normal file
After Width: | Height: | Size: 481 B |
BIN
JCursor/CursorDrag2.png
Normal file
After Width: | Height: | Size: 420 B |
BIN
JCursor/CursorHover.png
Normal file
After Width: | Height: | Size: 654 B |
BIN
JCursor/CursorHover1.png
Normal file
After Width: | Height: | Size: 487 B |
BIN
JCursor/CursorHover2.png
Normal file
After Width: | Height: | Size: 429 B |
@ -1,12 +1,55 @@
|
|||||||
--- STEAMODDED HEADER
|
--- STEAMODDED HEADER
|
||||||
--- MOD_NAME: J Cursor
|
--- MOD_NAME: J Cursor
|
||||||
--- MOD_ID: JCursor
|
--- MOD_ID: JCursor
|
||||||
--- MOD_AUTHOR: [Jie65535]
|
--- MOD_AUTHOR: [Jie65535, MarioMak967]
|
||||||
--- MOD_DESCRIPTION: Custom Cursor (./Mods/JCursor/Cursor.png)
|
--- MOD_DESCRIPTION: Custom Cursor (Mods/JCursor/Cursor.png CursorHover.png CursorDrag.png)
|
||||||
|
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
------------MOD CODE -------------------------
|
------------MOD CODE -------------------------
|
||||||
|
|
||||||
|
-- The x-coordinate in the cursor's hot spot.
|
||||||
|
local HOT_X = 20
|
||||||
|
-- The y-coordinate in the cursor's hot spot.
|
||||||
|
local HOT_Y = 4
|
||||||
|
|
||||||
|
local currentCursor
|
||||||
|
local function setCursor(cursor)
|
||||||
|
if currentCursor ~= cursor then
|
||||||
|
currentCursor = cursor
|
||||||
|
love.mouse.setCursor(cursor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local MOD_DIRECTORY = "/Mods/JCursor"
|
||||||
|
local function getCursor(state, hotx, hoty)
|
||||||
|
local filename = MOD_DIRECTORY .. "/" .. state .. ".png"
|
||||||
|
if love.filesystem.exists(filename) then
|
||||||
|
return love.mouse.newCursor(filename, hotx, hoty)
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local cursorDefault
|
||||||
|
local cursorHover
|
||||||
|
local cursorDrag
|
||||||
|
local function updateCursors()
|
||||||
|
cursorDefault = getCursor("Cursor", HOT_X, HOT_Y)
|
||||||
|
cursorHover = getCursor("CursorHover", HOT_X, HOT_Y)
|
||||||
|
cursorDrag = getCursor("CursorDrag", HOT_X, HOT_Y)
|
||||||
|
if cursorDefault then
|
||||||
|
setCursor(cursorDefault)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function G.FUNCS.refreshCursors(arg_736_0)
|
||||||
|
sendDebugMessage("refreshCursors")
|
||||||
|
updateCursors()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- init cursors
|
||||||
|
updateCursors()
|
||||||
|
|
||||||
|
|
||||||
SMODS.registerUIElement("JCursor", {
|
SMODS.registerUIElement("JCursor", {
|
||||||
{
|
{
|
||||||
n = G.UIT.R,
|
n = G.UIT.R,
|
||||||
@ -24,42 +67,91 @@ SMODS.registerUIElement("JCursor", {
|
|||||||
}),
|
}),
|
||||||
UIBox_button({
|
UIBox_button({
|
||||||
minw = 3.85,
|
minw = 3.85,
|
||||||
button = "refreshCursor",
|
button = "refreshCursors",
|
||||||
label = {
|
label = {
|
||||||
"Refresh cursor"
|
"Refresh cursor"
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
UIBox_button({
|
||||||
|
minw = 3.85,
|
||||||
|
button = "openJCursorGithub",
|
||||||
|
label = {
|
||||||
|
"Github"
|
||||||
|
}
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
local function getModDirectory()
|
|
||||||
return "/Mods/JCursor"
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getCursorFile()
|
|
||||||
return getModDirectory() .. "/Cursor.png"
|
|
||||||
end
|
|
||||||
|
|
||||||
local function setCursor(filename)
|
|
||||||
cursor = love.mouse.newCursor(filename, 0, 0)
|
|
||||||
love.mouse.setCursor(cursor)
|
|
||||||
end
|
|
||||||
|
|
||||||
function G.FUNCS.openModDirectory(arg_736_0)
|
function G.FUNCS.openModDirectory(arg_736_0)
|
||||||
sendDebugMessage("openModDirectory")
|
url = "file://" .. love.filesystem.getSaveDirectory() .. MOD_DIRECTORY
|
||||||
love.system.openURL("file://" .. love.filesystem.getSaveDirectory() .. getModDirectory())
|
sendDebugMessage("openModDirectory: " .. url)
|
||||||
|
love.system.openURL(url)
|
||||||
end
|
end
|
||||||
|
|
||||||
function G.FUNCS.refreshCursor(arg_736_0)
|
function G.FUNCS.openJCursorGithub(arg_736_0)
|
||||||
sendDebugMessage("refreshCursor")
|
sendDebugMessage("Open Github!")
|
||||||
setCursor(getCursorFile())
|
love.system.openURL("https://github.com/jie65535/JMods/tree/main/JCursor")
|
||||||
end
|
end
|
||||||
|
|
||||||
local defaultCursor = getCursorFile()
|
|
||||||
if love.filesystem.exists(defaultCursor) then
|
|
||||||
setCursor(defaultCursor)
|
|
||||||
|
local function myDrag()
|
||||||
|
if cursorDrag then
|
||||||
|
setCursor(cursorDrag)
|
||||||
|
-- sendDebugMessage("drag start!")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function myStopDrag()
|
||||||
|
if cursorDrag and cursorDefault and currentCursor == cursorDrag then
|
||||||
|
setCursor(cursorDefault)
|
||||||
|
-- sendDebugMessage("drag stop!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local hoverLevel = 0
|
||||||
|
local function myHover()
|
||||||
|
if cursorHover and currentCursor == cursorDefault and hoverLevel == 0 then
|
||||||
|
setCursor(cursorHover)
|
||||||
|
-- sendDebugMessage("hover start!")
|
||||||
|
end
|
||||||
|
hoverLevel = hoverLevel + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local function myStopHover()
|
||||||
|
if hoverLevel > 0 then
|
||||||
|
hoverLevel = hoverLevel - 1
|
||||||
|
end
|
||||||
|
if cursorHover
|
||||||
|
and cursorDefault
|
||||||
|
and currentCursor == cursorHover
|
||||||
|
and hoverLevel == 0
|
||||||
|
then
|
||||||
|
setCursor(cursorDefault)
|
||||||
|
-- sendDebugMessage("hover stop!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function injectCodeBefore(originalFunction, codeToInject)
|
||||||
|
return function(...)
|
||||||
|
codeToInject(...)
|
||||||
|
return originalFunction(...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Node.drag = injectCodeBefore(Node.drag, myDrag)
|
||||||
|
Node.stop_drag = injectCodeBefore(Node.stop_drag, myStopDrag)
|
||||||
|
-- Node.hover = injectCodeBefore(Node.hover, myHover)
|
||||||
|
-- Node.stop_hover = injectCodeBefore(Node.stop_hover, myStopHover)
|
||||||
|
|
||||||
|
Card.hover = injectCodeBefore(Card.hover, myHover)
|
||||||
|
Card.stop_hover = injectCodeBefore(Card.stop_hover, myStopHover)
|
||||||
|
|
||||||
|
-- UIElement.hover = injectCodeBefore(UIElement.hover, myHover)
|
||||||
|
-- UIElement.stop_hover = injectCodeBefore(UIElement.stop_hover, myStopHover)
|
||||||
|
|
||||||
sendDebugMessage("JCursor loaded!")
|
sendDebugMessage("JCursor loaded!")
|
||||||
|
|
||||||
|
23
JCursor/README.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# J Cursor
|
||||||
|
Custom Cursor
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
ModDir: `%AppData%\Balatro\Mods\JCursor\`
|
||||||
|
|
||||||
|
Change the default cursor by replacing the following files:
|
||||||
|
- `Cursor.png`
|
||||||
|
- `CursorDrag.png`
|
||||||
|
- `CursorHover.png`
|
||||||
|
|
||||||
|
Default cursors made by `@MarioMak967`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Modify the top constant of Lua to determine the cursor hot spot
|
||||||
|
```lua
|
||||||
|
-- The x-coordinate in the cursor's hot spot.
|
||||||
|
local HOT_X = 20
|
||||||
|
-- The y-coordinate in the cursor's hot spot.
|
||||||
|
local HOT_Y = 4
|
||||||
|
```
|