Skip to content

Commit

Permalink
Update BetterMouseAndGamepad.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Kooluve authored Apr 8, 2024
1 parent f00210c commit d7a92b2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions BetterMouseAndGamepad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--- MOD_NAME: Better Mouse And Gamepad
--- MOD_ID: BetterMouseAndGamepad
--- MOD_AUTHOR: [Kooluve]
--- MOD_DESCRIPTION: V1.0.3 Make mouse and gamepad more efficient and easier to use. View "README.md" and "*.lua" file for all functions and settings.
--- MOD_DESCRIPTION: [V1.0.4] Make mouse and gamepad more efficient and easier to use. View "README.md" and "*.lua" file for all functions and settings. https://github.com/Kooluve/Better-Mouse-And-Gamepad
----------------------------------------------
------------MOD CODE -------------------------

Expand Down Expand Up @@ -91,6 +91,8 @@ R_cursor_up = {T = {x=0, y=0}, target = nil, time = 0.1, handled = true}
M_clicked = {handled = true}
M_cursor_down = {handled = true}
M_cursor_up = {handled = true}
Game_last_state = G.STATES.SPLASH
Game_state_change_to_selecting_hand = false --prevent repetitive playing card and discarding

--------------------------------------------------
------------LOVE2D FUNCTION REWRITING-------------
Expand Down Expand Up @@ -169,6 +171,14 @@ local update_ref = Controller.update
function Controller.update(self, dt)
update_ref(self, dt)

if Game_last_state ~= G.STATES.SELECTING_HAND and G.STATE == G.STATES.SELECTING_HAND then
Game_state_change_to_selecting_hand = true
end
if Game_last_state == G.STATES.SELECTING_HAND and G.STATE ~= G.STATES.SELECTING_HAND then
Game_state_change_to_selecting_hand = false
end
Game_last_state = G.STATE

if R_cursor_queue then
R_cursor_press(R_cursor_queue.x, R_cursor_queue.y)
R_cursor_queue = nil
Expand Down Expand Up @@ -427,20 +437,22 @@ end

function queue_U_wheel_press()
if C.locks.frame or not mod_functions_can["middle_mouse_button_up"] then return end
if not G.SETTINGS.paused and G.STATE == G.STATES.SELECTING_HAND then
if not G.SETTINGS.paused and G.STATE == G.STATES.SELECTING_HAND and Game_state_change_to_selecting_hand and C.cursor_down.target.states.drag.is == false then
local play_button = G.buttons:get_UIE_by_ID('play_button')
if play_button and play_button.config.button then
G.FUNCS.play_cards_from_highlighted()
Game_state_change_to_selecting_hand = false
end
end
end

function queue_D_wheel_press()
if C.locks.frame or not mod_functions_can["middle_mouse_button_down"] then return end
if not G.SETTINGS.paused and G.STATE == G.STATES.SELECTING_HAND then
if not G.SETTINGS.paused and G.STATE == G.STATES.SELECTING_HAND and Game_state_change_to_selecting_hand and C.cursor_down.target.states.drag.is == false then
local discard_button = G.buttons:get_UIE_by_ID('discard_button')
if discard_button and discard_button.config.button then
G.FUNCS.discard_cards_from_highlighted()
Game_state_change_to_selecting_hand = false
end
end
end
Expand Down

0 comments on commit d7a92b2

Please sign in to comment.