Made the wheel system generic, so future coders can make different wheel types.

I gave the talk wheel to aliens, monkeys and cyborgs.
This commit is contained in:
phil235
2016-09-16 14:45:05 +02:00
parent 1cadec44bf
commit 143e4ce172
10 changed files with 194 additions and 156 deletions

View File

@@ -51,17 +51,17 @@
#define ui_storage1 "CENTER+1:18,SOUTH:5"
#define ui_storage2 "CENTER+2:20,SOUTH:5"
#define ui_borg_sensor "CENTER-3:16, SOUTH:5" //borgs
#define ui_borg_lamp "CENTER-4:16, SOUTH:5" //borgies
#define ui_borg_thrusters "CENTER-5:16, SOUTH:5"//borgies
#define ui_inv1 "CENTER-2:16,SOUTH:5" //borgs
#define ui_inv2 "CENTER-1 :16,SOUTH:5" //borgs
#define ui_inv3 "CENTER :16,SOUTH:5" //borgs
#define ui_borg_module "CENTER+1:16,SOUTH:5"
#define ui_borg_store "CENTER+2:16,SOUTH:5" //borgs
#define ui_borg_camera "CENTER+3:21,SOUTH:5" //borgs
#define ui_borg_album "CENTER+4:21,SOUTH:5" //borgs
#define ui_borg_sensor "CENTER-3:16, SOUTH:5" //borgs
#define ui_borg_lamp "CENTER-4:16, SOUTH:5" //borgs
#define ui_borg_thrusters "CENTER-5:16, SOUTH:5" //borgs
#define ui_inv1 "CENTER-2:16,SOUTH:5" //borgs
#define ui_inv2 "CENTER-1 :16,SOUTH:5" //borgs
#define ui_inv3 "CENTER :16,SOUTH:5" //borgs
#define ui_borg_module "CENTER+1:16,SOUTH:5" //borgs
#define ui_borg_store "CENTER+2:16,SOUTH:5" //borgs
#define ui_borg_camera "CENTER+3:21,SOUTH:5" //borgs
#define ui_borg_album "CENTER+4:21,SOUTH:5" //borgs
#define ui_borg_talk_wheel "CENTER+4:21,SOUTH+1:5" //borgs
#define ui_monkey_head "CENTER-4:13,SOUTH:5" //monkey
#define ui_monkey_mask "CENTER-3:14,SOUTH:5" //monkey
@@ -69,6 +69,7 @@
#define ui_alien_storage_l "CENTER-2:14,SOUTH:5"//alien
#define ui_alien_storage_r "CENTER+1:18,SOUTH:5"//alien
#define ui_alien_talk_wheel "EAST-3:26,SOUTH:5" //alien
#define ui_drone_drop "CENTER+1:18,SOUTH:5" //maintenance drones
#define ui_drone_pull "CENTER+2:2,SOUTH:5" //maintenance drones

View File

@@ -70,6 +70,11 @@
H.leap_icon.screen_loc = ui_alien_storage_r
static_inventory += H.leap_icon
using = new/obj/screen/wheel/talk
using.screen_loc = ui_alien_talk_wheel
wheels += using
static_inventory += using
using = new /obj/screen/drop()
using.icon = 'icons/mob/screen_alien.dmi'
using.screen_loc = ui_drop_throw

View File

@@ -21,6 +21,11 @@
pull_icon.screen_loc = ui_pull_resist
hotkeybuttons += pull_icon
using = new/obj/screen/wheel/talk
using.screen_loc = ui_alien_talk_wheel
wheels += using
static_inventory += using
zone_select = new /obj/screen/zone_sel/alien()
zone_select.update_icon(mymob)
static_inventory += zone_select

View File

@@ -33,7 +33,7 @@
var/obj/screen/throw_icon
var/obj/screen/module_store_icon
var/obj/screen/talk_wheel/talk_wheel_icon
var/list/wheels = list() //list of the wheel screen objects
var/list/static_inventory = list() //the screen objects which are static
var/list/toggleable_inventory = list() //the screen objects which can be hidden
@@ -66,8 +66,7 @@
qdel(module_store_icon)
module_store_icon = null
qdel(talk_wheel_icon)
talk_wheel_icon = null
wheels = null //all wheels are also in static_inventory
if(static_inventory.len)
for(var/thing in static_inventory)
@@ -204,7 +203,18 @@
return
/datum/hud/proc/persistant_inventory_update(mob/viewer)
return
if(!mymob)
return
var/mob/living/L = mymob
var/mob/screenmob = viewer || L
for(var/X in wheels)
var/obj/screen/wheel/W = X
if(W.toggled)
screenmob.client.screen |= W.buttons_list
else
screenmob.client.screen -= W.buttons_list
//Triggered when F12 is pressed (Unless someone changed something in the DMF)
/mob/verb/button_pressed_F12()

View File

@@ -95,9 +95,10 @@
using.icon = ui_style
static_inventory += using
talk_wheel_icon = new/obj/screen/talk_wheel
talk_wheel_icon.icon = ui_style
static_inventory += talk_wheel_icon
using = new/obj/screen/wheel/talk
using.icon = ui_style
wheels += using
static_inventory += using
using = new /obj/screen/inventory/area_creator
using.icon = ui_style
@@ -361,6 +362,7 @@
/datum/hud/human/persistant_inventory_update(mob/viewer)
if(!mymob)
return
..()
var/mob/living/carbon/human/H = mymob
var/mob/screenmob = viewer || H
@@ -401,16 +403,12 @@
if(hud_version != HUD_STYLE_NOHUD)
for(var/obj/item/I in H.held_items)
I.screen_loc = ui_hand_position(H.get_held_index_of_item(I))
H.client.screen += I
screenmob.client.screen += I
else
for(var/obj/item/I in H.held_items)
I.screen_loc = null
H.client.screen -= I
screenmob.client.screen -= I
if(talk_wheel_icon.toggled)
H.client.screen |= talk_wheel_icon.talk_boxes
else
H.client.screen -= talk_wheel_icon.talk_boxes
/mob/living/carbon/human/verb/toggle_hotkey_verbs()
set category = "OOC"

View File

@@ -16,6 +16,11 @@
using.screen_loc = ui_movi
static_inventory += using
using = new/obj/screen/wheel/talk
using.icon = ui_style
wheels += using
static_inventory += using
using = new /obj/screen/drop()
using.icon = ui_style
using.screen_loc = ui_drop_throw

View File

@@ -93,6 +93,11 @@
var/mob/living/silicon/robot/mymobR = mymob
var/obj/screen/using
using = new/obj/screen/wheel/talk
using.screen_loc = ui_borg_talk_wheel
wheels += using
static_inventory += using
//Radio
using = new /obj/screen/robot/radio()
using.screen_loc = ui_borg_radio

View File

@@ -46,134 +46,6 @@
M.swap_hand()
return 1
/obj/screen/talk_wheel
name = "talk wheel"
layer = HUD_LAYER
icon_state = "talk_wheel"
screen_loc = "11:6,2:-11"
var/obj/screen/talk/talk_boxes
var/toggled = 0
/obj/screen/talk_wheel/New()
..()
talk_boxes = new ()
talk_boxes.wheel = src
/obj/screen/talk_wheel/Destroy()
qdel(talk_boxes)
talk_boxes = null
return ..()
/obj/screen/talk_wheel/Click()
if(world.time <= usr.next_move)
return
if(usr.stat)
return
if(ishuman(usr))
var/mob/living/carbon/human/H = usr
if(toggled)
H.client.screen -= talk_boxes
else
H.client.screen |= talk_boxes
toggled = !toggled
/obj/screen/talk
name = "talk option"
icon_state = "x3"
screen_loc = "8,8"
layer = HUD_LAYER
mouse_opacity = 2
var/talk_cooldown = 0
var/obj/screen/talk_wheel/wheel
/obj/screen/talk/New()
..()
var/image/I = image("icon" = icon, "icon_state" = "talk_help")
I.pixel_x = -32
I.pixel_y = 32
add_overlay(I)
var/image/J = image("icon" = icon, "icon_state" = "talk_hello")
J.pixel_x = 0
J.pixel_y = 32
add_overlay(J)
var/image/K = image("icon" = icon, "icon_state" = "talk_bye")
K.pixel_x = 32
K.pixel_y = 32
add_overlay(K)
var/image/L = image("icon" = icon, "icon_state" = "talk_come")
L.pixel_x = -32
L.pixel_y = 0
add_overlay(L)
var/image/N = image("icon" = icon, "icon_state" = "talk_thx")
N.pixel_x = 32
N.pixel_y = 0
add_overlay(N)
var/image/O = image("icon" = icon, "icon_state" = "talk_out")
O.pixel_x = -32
O.pixel_y = -32
add_overlay(O)
var/image/P = image("icon" = icon, "icon_state" = "talk_stop")
P.pixel_x = 0
P.pixel_y = -32
add_overlay(P)
var/image/Q = image("icon" = icon, "icon_state" = "talk_yes_no")
Q.pixel_x = 32
Q.pixel_y = -32
add_overlay(Q)
/obj/screen/talk/Destroy()
wheel = null
return ..()
/obj/screen/talk/Click(location, control,params)
if(ishuman(usr))
if(usr.stat)
return
var/mob/living/carbon/human/H = usr
var/word_spoken = ""
var/list/PL = params2list(params)
var/icon_x = text2num(PL["icon-x"])
var/icon_y = text2num(PL["icon-y"])
switch(icon_y)
if(1 to 32)
switch(icon_x)
if(1 to 32)
usr.client.screen -= src
wheel.toggled = !wheel.toggled
return
if(33 to 64)
word_spoken = pick("Thanks.", "Thanks!", "Thank you.")
else
word_spoken = pick("Come.", "Follow me.")
if(33 to 64)
switch(icon_x)
if(1 to 32)
word_spoken = pick("Hi.", "Hello.")
if(33 to 64)
word_spoken = pick("Bye.", "Goodbye.")
else
word_spoken = pick("Help!", "Help me!")
else
switch(icon_x)
if(1 to 32)
word_spoken = pick("Stop!", "Halt!")
if(33 to 64)
if(icon_y < -16)
word_spoken = "No."
else
word_spoken = "Yes."
else
word_spoken = pick("Go away!", "Out!", "Get out!")
if(word_spoken && talk_cooldown < world.time)
talk_cooldown = world.time + 10
H.say(word_spoken)
/obj/screen/inventory/craft
name = "crafting menu"
icon = 'icons/mob/screen_midnight.dmi'
@@ -608,3 +480,139 @@
/obj/screen/healthdoll
name = "health doll"
screen_loc = ui_healthdoll
/obj/screen/wheel
name = "wheel"
layer = HUD_LAYER
icon_state = ""
screen_loc = null //if you make a new wheel, remember to give it a screen_loc
var/list/buttons_names = list() //list of the names for each button, its length is the amount of buttons.
var/toggled = 0 //wheel is hidden/shown
var/wheel_buttons_type //the type of buttons used with this wheel.
var/list/buttons_list = list()
/obj/screen/wheel/New()
..()
build_options()
//we create the buttons for the wheel and place them in a square spiral fashion.
/obj/screen/wheel/proc/build_options()
var/obj/screen/wheel_button/close_wheel/CW = new ()
buttons_list += CW //the close option
CW.wheel = src
var/list/offset_x_list = list()
var/list/offset_y_list = list()
var/num = 1
var/N = 1
var/M = 0
var/sign = -1
my_loop:
while(offset_y_list.len < buttons_names.len)
for(var/i=1, i<=num, i++)
offset_y_list += N
offset_x_list += M
if(offset_y_list.len == buttons_names.len)
break my_loop
if(N != 0)
N = 0
M = -sign
else
N = sign
M = 0
sign = -sign
num++
var/screenx = 8
var/screeny = 8
for(var/i = 1, i <= buttons_names.len, i++)
var/obj/screen/wheel_button/WB = new wheel_buttons_type()
WB.wheel = src
buttons_list += WB
screenx += offset_x_list[i]
screeny += offset_y_list[i]
WB.screen_loc = "[screenx], [screeny]"
set_button(WB, i)
/obj/screen/wheel/proc/set_button(obj/screen/wheel_button/WB, button_number)
WB.name = buttons_names[button_number]
return
/obj/screen/wheel/Destroy()
for(var/obj/screen/S in buttons_list)
qdel(S)
return ..()
/obj/screen/wheel/Click()
if(world.time <= usr.next_move)
return
if(usr.stat)
return
if(isliving(usr))
var/mob/living/L = usr
if(toggled)
L.client.screen -= buttons_list
else
L.client.screen |= buttons_list
toggled = !toggled
/obj/screen/wheel/talk
name = "talk wheel"
icon_state = "talk_wheel"
screen_loc = "11:6,2:-11"
wheel_buttons_type = /obj/screen/wheel_button/talk
buttons_names = list("help","hello","bye","stop","thanks","come","out", "yes", "no")
var/list/word_messages = list(list("Help!","Help me!"), list("Hello.", "Hi."), list("Bye.", "Goodbye."),\
list("Stop!", "Halt!"), list("Thanks.", "Thanks!", "Thank you."), \
list("Come.", "Follow me."), list("Out!", "Go away!", "Get out!"), \
list("Yes.", "Affirmative."), list("No.", "Negative"))
/obj/screen/wheel/talk/set_button(obj/screen/wheel_button/WB, button_number)
..()
var/obj/screen/wheel_button/talk/T = WB //we already know what type the button is exactly.
T.icon_state = "talk_[T.name]"
T.word_messages = word_messages[button_number]
/obj/screen/wheel_button
name = "default wheel button"
screen_loc = "8,8"
layer = HUD_LAYER
mouse_opacity = 2
var/obj/screen/wheel/wheel
/obj/screen/wheel_button/Destroy()
wheel = null
return ..()
/obj/screen/wheel_button/close_wheel
name = "close wheel"
icon_state = "x3"
/obj/screen/wheel_button/close_wheel/Click()
if(isliving(usr))
var/mob/living/L = usr
L.client.screen -= wheel.buttons_list
wheel.toggled = !wheel.toggled
/obj/screen/wheel_button/talk
name = "talk option"
icon_state = "talk_help"
var/talk_cooldown = 0
var/list/word_messages = list()
/obj/screen/wheel_button/talk/Click(location, control,params)
if(isliving(usr))
var/mob/living/L = usr
if(L.stat)
return
if(word_messages.len && talk_cooldown < world.time)
talk_cooldown = world.time + 10
L.say(pick(word_messages))