-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4748 from MistakeNot4892/feature/intents
Moves intent selector under hands, reshuffles inventory.
- Loading branch information
Showing
11 changed files
with
171 additions
and
114 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
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 |
---|---|---|
@@ -1,68 +1,117 @@ | ||
// Sub-element used for clickable intent selection. | ||
/obj/screen/intent_button | ||
layer = FLOAT_LAYER | ||
plane = FLOAT_PLANE | ||
icon = 'icons/screen/intents.dmi' | ||
icon_state = "blank" | ||
requires_ui_style = FALSE | ||
screen_loc = null // Technically a screen element, but we use vis_contents to draw them. | ||
var/obj/screen/intent/parent | ||
var/decl/intent/intent | ||
var/selected | ||
|
||
/obj/screen/intent_button/Initialize(mapload, mob/_owner, decl/ui_style/ui_style, ui_color, ui_alpha, ui_cat, intent_owner) | ||
parent = intent_owner | ||
. = ..() | ||
|
||
/obj/screen/intent_button/Destroy() | ||
parent = null | ||
intent = null | ||
return ..() | ||
|
||
/obj/screen/intent_button/proc/set_selected(decl/intent/_intent) | ||
intent = _intent | ||
selected = TRUE | ||
update_icon() | ||
|
||
/obj/screen/intent_button/proc/set_deselected(decl/intent/_intent) | ||
intent = _intent | ||
selected = FALSE | ||
update_icon() | ||
|
||
/obj/screen/intent_button/handle_click(mob/user, params) | ||
. = ..() | ||
if(. && intent && parent) | ||
parent.set_intent(intent) | ||
|
||
/obj/screen/intent_button/examine(mob/user, distance) | ||
SHOULD_CALL_PARENT(FALSE) | ||
if(desc) | ||
to_chat(user, desc) | ||
|
||
/obj/screen/intent_button/on_update_icon() | ||
. = ..() | ||
screen_loc = null | ||
if(intent) | ||
name = intent.name | ||
desc = intent.desc | ||
icon = intent.icon | ||
icon_state = selected ? intent.icon_state : "[intent.icon_state]_off" | ||
|
||
/obj/screen/intent | ||
name = "intent" | ||
icon = 'icons/mob/screen/styles/intents.dmi' | ||
icon_state = "intents" | ||
icon = 'icons/screen/intents.dmi' | ||
icon_state = "blank" | ||
screen_loc = ui_acti | ||
requires_ui_style = FALSE | ||
apply_screen_overlay = FALSE | ||
var/intent_width = 16 | ||
var/intent_height = 16 | ||
var/list/intent_selectors | ||
|
||
/obj/screen/intent/Initialize(mapload, mob/_owner, decl/ui_style/ui_style, ui_color, ui_alpha, ui_cat) | ||
. = ..() | ||
update_icon() | ||
// Hide from right-click. | ||
name = "" | ||
verbs.Cut() | ||
|
||
/obj/screen/intent/Destroy() | ||
QDEL_NULL(intent_selectors) | ||
vis_contents.Cut() | ||
return ..() | ||
|
||
/obj/screen/intent/handle_click(mob/user, params) | ||
/obj/screen/intent/proc/set_intent(decl/intent/intent) | ||
var/mob/owner = owner_ref?.resolve() | ||
if(!istype(owner) || QDELETED(owner) || user != owner || !params) | ||
return | ||
params = params2list(params) | ||
if(owner.set_intent(get_intent_by_position(owner.get_available_intents(), text2num(params["icon-x"]), text2num(params["icon-y"])))) | ||
if(istype(owner) && istype(intent)) | ||
owner.set_intent(intent) | ||
update_icon() | ||
|
||
/obj/screen/intent/proc/get_intent_by_position(list/intents, icon_x, icon_y) | ||
if(icon_y <= 16) | ||
if(icon_x <= 16) | ||
return intents[1] | ||
return intents[2] | ||
else if(icon_x <= 16) | ||
return intents[3] | ||
return intents[4] | ||
|
||
/obj/screen/intent/proc/apply_intent_overlay_offset(image/overlay, index) | ||
switch(index) | ||
if(2) | ||
overlay.pixel_x = 16 | ||
if(3) | ||
overlay.pixel_y = 16 | ||
if(4) | ||
overlay.pixel_x = 16 | ||
overlay.pixel_y = 16 | ||
/obj/screen/intent/proc/apply_intent_button_offset(atom/intent_button, index, intent_count) | ||
intent_button.pixel_z = 0 | ||
intent_button.pixel_w = 0 | ||
intent_button.pixel_y = 0 | ||
intent_button.pixel_x = -((intent_count * intent_width)/2) + ((index-1) * intent_width) | ||
|
||
/obj/screen/intent/proc/get_intent_button(index) | ||
. = (index >= 1 && index <= length(intent_selectors)) ? intent_selectors[index] : null | ||
if(!.) | ||
. = new /obj/screen/intent_button(null, owner_ref?.resolve(), null, null, null, null, src) | ||
LAZYADD(intent_selectors, .) | ||
|
||
/obj/screen/intent/on_update_icon() | ||
..() | ||
|
||
var/mob/owner = owner_ref?.resolve() | ||
if(!istype(owner) || QDELETED(owner)) | ||
return | ||
|
||
var/decl/intent/owner_intent = owner.get_intent() | ||
var/i = 0 | ||
var/image/I | ||
for(var/decl/intent/intent as anything in owner.get_available_intents()) | ||
var/i = 1 | ||
var/list/all_intents = owner.get_available_intents() | ||
for(var/decl/intent/intent as anything in all_intents) | ||
var/obj/screen/intent_button/intent_button = get_intent_button(i) | ||
if(intent == owner_intent) | ||
I = image(intent.icon, intent.icon_state) | ||
intent_button.set_selected(intent) | ||
else | ||
I = image(intent.icon, "[intent.icon_state]_off") | ||
intent_button.set_deselected(intent) | ||
i++ | ||
apply_intent_overlay_offset(I, i) | ||
add_overlay(I) | ||
compile_overlays() | ||
apply_intent_button_offset(intent_button, i, length(all_intents)) | ||
add_vis_contents(intent_button) | ||
|
||
/obj/screen/intent/binary | ||
icon = 'icons/mob/screen/styles/intents_wide.dmi' | ||
if(i < length(intent_selectors)) | ||
for(var/index = i+1 to length(intent_selectors)) | ||
remove_vis_contents(intent_selectors[index]) | ||
|
||
/obj/screen/intent/binary/get_intent_by_position(list/intents, icon_x, icon_y) | ||
if(icon_y <= 16) | ||
return intents[1] | ||
return intents[2] | ||
|
||
/obj/screen/intent/binary/apply_intent_overlay_offset(image/overlay, index) | ||
if(index == 2) | ||
overlay.pixel_y = 16 | ||
/obj/screen/intent/binary | ||
intent_width = 32 |
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.