-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [MIRROR] Alt click refactor (#2029) * Alt click refactor * Some early conflict removal * Big modular refactor * Update console.dm * Update paper.dm --------- Co-authored-by: Jeremiah <[email protected]> Co-authored-by: Mal <[email protected]> * FF modular alt clicks --------- Co-authored-by: NovaBot <[email protected]> Co-authored-by: Jeremiah <[email protected]> Co-authored-by: Mal <[email protected]> Co-authored-by: Iajret <[email protected]>
- Loading branch information
1 parent
4458de8
commit cc106e3
Showing
263 changed files
with
1,349 additions
and
1,427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// Action has succeeded, preventing further alt click interaction | ||
#define CLICK_ACTION_SUCCESS (1<<0) | ||
/// Action failed, preventing further alt click interaction | ||
#define CLICK_ACTION_BLOCKING (1<<1) | ||
/// Either return state | ||
#define CLICK_ACTION_ANY (CLICK_ACTION_SUCCESS | CLICK_ACTION_BLOCKING) | ||
|
||
/// Use NONE for continue interaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* ### Base proc for alt click interaction. | ||
* | ||
* If you wish to add custom `click_alt` behavior for a single type, use that proc. | ||
*/ | ||
/mob/proc/base_click_alt(atom/target) | ||
SHOULD_NOT_OVERRIDE(TRUE) | ||
|
||
var/turf/tile = isturf(target) ? target : get_turf(target) | ||
|
||
if(isobserver(src) || isrevenant(src)) | ||
open_lootpanel(tile) | ||
return | ||
|
||
if(!isturf(target) && can_perform_action(target, (target.interaction_flags_click | SILENT_ADJACENCY))) | ||
if(SEND_SIGNAL(target, COMSIG_CLICK_ALT, src) & CLICK_ACTION_ANY) | ||
return | ||
|
||
if(target.click_alt(src) & CLICK_ACTION_ANY) | ||
return | ||
|
||
open_lootpanel(tile) | ||
|
||
|
||
/// Helper for opening the lootpanel | ||
/mob/proc/open_lootpanel(turf/target) | ||
if(HAS_TRAIT(src, TRAIT_MOVE_VENTCRAWLING)) | ||
return | ||
|
||
var/datum/lootpanel/panel = client?.loot_panel | ||
if(isnull(panel)) | ||
return | ||
|
||
panel.open(target) | ||
|
||
|
||
/** | ||
* ## Custom alt click interaction | ||
* Override this to change default alt click behavior. Return `CLICK_ACTION_SUCCESS`, `CLICK_ACTION_BLOCKING` or `NONE`. | ||
* | ||
* ### Guard clauses | ||
* Consider adding `interaction_flags_click` before adding unique guard clauses. | ||
* | ||
* ### Return flags | ||
* Forgetting your return will cause the default alt click behavior to occur thereafter. | ||
* | ||
* The difference between NONE and BLOCKING can get hazy, but I like to keep NONE limited to guard clauses and "never" cases. | ||
* | ||
* A good usage for BLOCKING over NONE is when it's situational for the item and there's some feedback indicating this. | ||
* | ||
* ### Examples: | ||
* User is a ghost, alt clicks on item with special disk eject: NONE | ||
* | ||
* Machine broken, no feedback: NONE | ||
* | ||
* Alt click a pipe to max output but its already max: BLOCKING | ||
* | ||
* Alt click a gun that normally works, but is out of ammo: BLOCKING | ||
* | ||
* User unauthorized, machine beeps: BLOCKING | ||
* | ||
* @param {mob} user - The person doing the alt clicking. | ||
*/ | ||
/atom/proc/click_alt(mob/user) | ||
SHOULD_CALL_PARENT(FALSE) | ||
return NONE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.