ID:268790
 
var
midx = 2
midy = 2

mob
var/tmp //vars used to keep track of objects displayed
obj
curitem
curitemnum = 1
itemmenuup = 0
obj/item_menu
top
__s_t = new()
mid
__s_m = new()
bot
__s_b = new()
left
__s_l = new()
right
__s_r = new()
tl
__s_tl = new()
tr
__s_tr = new()
bl
__s_bl = new()
br
__s_br = new()
use
__s_use = new()
lb
__s_lb = new()
rb
__s_rb = new()

proc
DispItemMenu()
if(!itemmenuup) //if the menu isn't on
client.screen += __s_t //add the menu
client.screen += __s_m
client.screen += __s_b
client.screen += __s_l
client.screen += __s_r
client.screen += __s_tl
client.screen += __s_tr
client.screen += __s_bl
client.screen += __s_br
client.screen += __s_use

if(contents.len > 1) //olny use the buttons if there's more than 1 item
client.screen += __s_lb
client.screen += __s_rb

if(!curitem && contents.len) //set the inital item if needed
curitem = contents[curitemnum]

if(curitem) //display initial item if needed
client.screen += curitem

itemmenuup = 1
else //if it is on
client.screen -= __s_t //remove it
client.screen -= __s_m
client.screen -= __s_b
client.screen -= __s_l
client.screen -= __s_r
client.screen -= __s_tl
client.screen -= __s_tr
client.screen -= __s_bl
client.screen -= __s_br
client.screen -= __s_use
client.screen -= __s_lb
client.screen -= __s_rb

if(curitem) //remove displayed item if needed
client.screen -= curitem
itemmenuup = 0


obj
New()
.=..() //do any other stuff in new
screen_loc="[midx],[midy]" //set the screen_loc to the 'mid' tile so the objects show up
proc
Use(mob/M) //proc called when it is used(M is the person using it)

obj/item_menu //menu part definitions
name = ""
icon = 'item_menu.dmi'
top
icon_state = "top"
New()
. = ..()
screen_loc = "[midx],[midy + 1]"
mid
icon_state = "mid"
New()
. = ..()
screen_loc = "[midx],[midy]"
bot
icon_state = "bottom"
New()
. = ..()
screen_loc = "[midx],[midy - 1]"
left
icon_state = "left"
New()
. = ..()
screen_loc = "[midx - 1],[midy]"
right
icon_state = "right"
New()
. = ..()
screen_loc = "[midx + 1],[midy]"
tr
icon_state = "topright"
New()
. = ..()
screen_loc = "[midx + 1],[midy + 1]"
tl
icon_state = "topleft"
New()
. = ..()
screen_loc = "[midx - 1],[midy + 1]"
br
icon_state = "bottomright"
New()
. = ..()
screen_loc = "[midx + 1],[midy - 1]"
bl
icon_state = "bottomleft"
New()
. = ..()
screen_loc = "[midx - 1],[midy - 1]"
use
icon_state = "use"
New()
. = ..()
screen_loc = "[midx],[midy - 1]"
MouseEntered() //change the icon state if it's hovered over
icon_state = "useo"
MouseExited()
icon_state = "use"
Click()
if(usr.curitem) //if there's a selected item...
usr.curitem.Use(usr) //use it
usr.client.screen -= usr.curitem

if(usr.contents.len) //if there's anything in the contents at all
if(usr.curitemnum > usr.contents.len) //if item was deleted
usr.curitemnum = 1 //and the position is
usr.curitem = usr.contents[usr.curitemnum] //no longer valid
usr.client.screen += usr.curitem

else
usr.curitem = usr.contents[usr.curitemnum]
usr.client.screen += usr.curitem

if(usr.contents.len == 1) //remove the buttons if needed
usr.client.screen -= usr.__s_lb
usr.client.screen -= usr.__s_rb

else
usr.curitemnum = 1
usr.DispItemMenu() //remove item menu


lb
icon_state = "leftb"
New()
. = ..()
screen_loc = "[midx - 1],[midy]"
MouseEntered()
icon_state = "leftbo"
MouseExited()
icon_state = "leftb"
Click()
usr.client.screen -= usr.curitem //remove the currently displayed item
usr.curitemnum-- //find the index of the item "below" the current one
if(usr.curitemnum <= 0) //if it's invalid
usr.curitemnum = usr.contents.len //set it to the "top" item

if(usr.contents.len) //if there's anything in contents
usr.curitem = usr.contents[usr.curitemnum] //set the curitem var
usr.client.screen += usr.curitem //display the new one

else
usr.curitemnum = 1
usr.DispItemMenu() //remove item menu

rb
icon_state = "rightb"
New()
. = ..()
screen_loc = "[midx + 1],[midy]"
MouseEntered()
icon_state = "rightbo"
MouseExited()
icon_state = "rightb"
Click()
usr.client.screen -= usr.curitem //remove the currently displayed item
usr.curitemnum++ //find the index of the item "above" the current one
if(usr.curitemnum >= usr.contents.len+1) //if it's invalid
usr.curitemnum = 1 //set it to the "bottom" item

if(usr.contents.len) //if there's anything in contents
usr.curitem = usr.contents[usr.curitemnum] //set the curitem var
usr.client.screen += usr.curitem //display the new one

else
usr.curitemnum = 1
usr.DispItemMenu() //remove item menu

obj //demo objs
New()
. = ..()
screen_loc = "[midx],[midy]" //set the obj's screen_loc to the middle panel's
stick
icon = 'stick.dmi'
Use(mob/M)
M << "You hit yourself with the stick!"
verb
Get()
set src in oview(0)
src.loc = usr
usr << "You get the [name]!"

sorry if the code is long and a thanks to destroy for making it

ok i fiannly got everything working but one thing if the menu is up when i pick up the item it will not show the item in it untill i close and reopen it how can i make it so i DONT have to do that?


Dave