Skip to content

Commit cbf2afb

Browse files
committed
Major changes and improvements, release v0.6
1 parent 483c42e commit cbf2afb

35 files changed

+109
-482
lines changed

Corona/AndroidResources/res/mipmap-anydpi-v26/ic_launcher.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Corona/AndroidResources/res/values/values.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

Corona/Images.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 0 additions & 108 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Corona/Images.xcassets/Contents.json

Lines changed: 0 additions & 6 deletions
This file was deleted.
Binary file not shown.
-258 Bytes
Binary file not shown.
Binary file not shown.

Corona/LaunchScreen.storyboardc/designable.storyboard

Lines changed: 0 additions & 31 deletions
This file was deleted.

Corona/build.settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ settings =
4949
{
5050
['win32-sim'] =
5151
{
52-
url = 'https://github.com/ANSH3LL/plugin_hwcursor/releases/download/v0.5/win32-sim.tgz'
52+
url = 'https://github.com/ANSH3LL/plugin_hwcursor/releases/download/v0.6/win32-sim.tgz'
5353
}
5454
}
5555
},

Corona/main.lua

Lines changed: 26 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
-- New in this version
2+
3+
-- Call cursor.loadCursor with the path to the cursor and store
4+
-- the return value, which is a pointer to the cursor resource
5+
6+
-- Call cursor.setCursor and provide the pointer returned
7+
-- by cursor.loadCursor to set the cursor for the window
8+
19
local widget = require('widget')
210
local cursor = require('plugin.hwcursor')
311

4-
local hidden = false
512
cursor.initPlugin()
613

7-
-- New in this version
8-
9-
-- Call cursor.loadCursor the first time with the path to the cursor
10-
-- and store the return value, which is a pointer to the cursor resource (preload step)
11-
12-
-- Call cursor.loadCursor the second time with the previously returned pointer
13-
-- to actually set the cursor (usage step)
14+
local visible = false
1415

1516
-- Cursors must be preloaded before being used
1617
local cursors = {
@@ -24,9 +25,10 @@ display.newText(
2425
x = display.contentCenterX,
2526
y = 50,
2627
width = 300,
28+
fontSize = 20,
2729
align = 'center',
2830
font = native.systemFont,
29-
text = 'Press numbers 1-0 and keys q-r on your keyboard for windows-provided cursors'
31+
text = 'Hardware Cursor Plugin for Windows OS'
3032
}
3133
)
3234

@@ -51,9 +53,8 @@ widget.newButton(
5153
shape = 'roundedRect',
5254
x = display.contentCenterX,
5355
y = display.contentCenterY - 50,
54-
label = 'Custom cursor 1',
55-
-- Set cursor using stored pointer
56-
onRelease = function() cursor.loadCursor(cursors.cursor1) end,
56+
label = 'Custom static cursor',
57+
onRelease = function() cursor.setCursor(cursors.cursor1) end,
5758
labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0, 0.5 } },
5859
fillColor = { default = { 1, 0.2, 0.5, 0.7 }, over = { 1, 0.2, 0.5, 1 } }
5960
}
@@ -66,9 +67,8 @@ widget.newButton(
6667
shape = 'roundedRect',
6768
x = display.contentCenterX,
6869
y = display.contentCenterY,
69-
label = 'Custom cursor 2',
70-
-- Set cursor using stored pointer
71-
onRelease = function() cursor.loadCursor(cursors.cursor2) end,
70+
label = 'Custom animated cursor',
71+
onRelease = function() cursor.setCursor(cursors.cursor2) end,
7272
labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0, 0.5 } },
7373
fillColor = { default = { 1, 0.2, 0.5, 0.7 }, over = { 1, 0.2, 0.5, 1 } }
7474
}
@@ -81,9 +81,8 @@ widget.newButton(
8181
shape = 'roundedRect',
8282
x = display.contentCenterX,
8383
y = display.contentCenterY + 50,
84-
label = 'Custom cursor 3',
85-
-- Set cursor using stored pointer
86-
onRelease = function() cursor.loadCursor(cursors.cursor3) end,
84+
label = 'Custom huge cursor',
85+
onRelease = function() cursor.setCursor(cursors.cursor3) end,
8786
labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0, 0.5 } },
8887
fillColor = { default = { 1, 0.2, 0.5, 0.7 }, over = { 1, 0.2, 0.5, 1 } }
8988
}
@@ -98,12 +97,8 @@ widget.newButton(
9897
y = display.contentCenterY + 100,
9998
label = 'Show/Hide cursor',
10099
onRelease = function()
101-
if hidden then
102-
cursor.showCursor()
103-
else
104-
cursor.hideCursor()
105-
end
106-
hidden = not hidden
100+
cursor.setVisibility(visible)
101+
visible = not visible
107102
end,
108103
labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0, 0.5 } },
109104
fillColor = { default = { 1, 0.2, 0.5, 0.7 }, over = { 1, 0.2, 0.5, 1 } }
@@ -119,11 +114,7 @@ widget.newButton(
119114
y = display.contentCenterY + 150,
120115
label = 'Exit application',
121116
onRelease = function()
122-
-- Destroy all cursors before exiting
123-
for k, v in pairs(cursors) do
124-
cursor.destroyCursor(v)
125-
cursors[k] = nil
126-
end
117+
-- Free the plugin before calling "native.requestExit()"
127118
cursor.freePlugin()
128119
native.requestExit()
129120
end,
@@ -132,90 +123,13 @@ widget.newButton(
132123
}
133124
)
134125

135-
--[[
136-
widget.newButton(
137-
{
138-
width = 200,
139-
height = 30,
140-
shape = 'roundedRect',
141-
x = display.contentCenterX,
142-
y = display.contentCenterY + 200,
143-
label = 'Destroy cursor 1',
144-
onRelease = function()
145-
cursor.destroyCursor(cursors.cursor1)
146-
cursors.cursor1 = nil
147-
end,
148-
labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0, 0.5 } },
149-
fillColor = { default = { 1, 0.2, 0.5, 0.7 }, over = { 1, 0.2, 0.5, 1 } }
150-
}
151-
)
152-
153-
widget.newButton(
154-
{
155-
width = 200,
156-
height = 30,
157-
shape = 'roundedRect',
158-
x = display.contentCenterX,
159-
y = display.contentCenterY + 250,
160-
label = 'Destroy cursor 2',
161-
onRelease = function()
162-
cursor.destroyCursor(cursors.cursor2)
163-
cursors.cursor2 = nil
164-
end,
165-
labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0, 0.5 } },
166-
fillColor = { default = { 1, 0.2, 0.5, 0.7 }, over = { 1, 0.2, 0.5, 1 } }
167-
}
168-
)
169-
170-
widget.newButton(
171-
{
172-
width = 200,
173-
height = 30,
174-
shape = 'roundedRect',
175-
x = display.contentCenterX,
176-
y = display.contentCenterY + 300,
177-
label = 'Destroy cursor 3',
178-
onRelease = function()
179-
cursor.destroyCursor(cursors.cursor3)
180-
cursors.cursor3 = nil
181-
end,
182-
labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0, 0.5 } },
183-
fillColor = { default = { 1, 0.2, 0.5, 0.7 }, over = { 1, 0.2, 0.5, 1 } }
184-
}
185-
)
186-
]]--
187-
188-
Runtime:addEventListener('key',
126+
Runtime:addEventListener('system',
189127
function(event)
190-
if event.phase == 'up' then
191-
if event.keyName == '1' then
192-
cursor.loadWinCursor(cursor.ARROW)
193-
elseif event.keyName == '2' then
194-
cursor.loadWinCursor(cursor.POINTER)
195-
elseif event.keyName == '3' then
196-
cursor.loadWinCursor(cursor.CROSSHAIR)
197-
elseif event.keyName == '4' then
198-
cursor.loadWinCursor(cursor.IBEAM)
199-
elseif event.keyName == '5' then
200-
cursor.loadWinCursor(cursor.NOTALLOWED)
201-
elseif event.keyName == '6' then
202-
cursor.loadWinCursor(cursor.RESIZE)
203-
elseif event.keyName == '7' then
204-
cursor.loadWinCursor(cursor.WAIT)
205-
elseif event.keyName == '8' then
206-
cursor.loadWinCursor(cursor.HELP)
207-
elseif event.keyName == '9' then
208-
cursor.loadWinCursor(cursor.BUSY)
209-
elseif event.keyName == '0' then
210-
cursor.loadWinCursor(cursor.RESIZENESW)
211-
elseif event.keyName == 'q' then
212-
cursor.loadWinCursor(cursor.RESIZENS)
213-
elseif event.keyName == 'w' then
214-
cursor.loadWinCursor(cursor.RESIZENWSE)
215-
elseif event.keyName == 'e' then
216-
cursor.loadWinCursor(cursor.RESIZEWE)
217-
elseif event.keyName == 'r' then
218-
cursor.loadWinCursor(cursor.UPARROW)
128+
if event.type == 'applicationExit' then
129+
-- Free all cursor pointers before application exit (best practice)
130+
for k, v in pairs(cursors) do
131+
cursor.freeCursor(v)
132+
cursors[k] = nil
219133
end
220134
end
221135
end

0 commit comments

Comments
 (0)