#define FRAME_DELAY 2 #include "Content\\ShellScripts\\ScriptStrings.h" #define _DEF_CHECKBOX_HIGHLIGHT_COLOR packcolor (255,255,0,255) // jcem s_textbutton { GUI_CREATE { location = 320,240 region = 0,0 to 32,32 int id = 0 int facecolor = 0xccffffff //deeefe int glowcolor = 0xeeffffff //0xcc9cd0fc int depressedcolor = 0xffffffff int current_color = facecolor int textsize = 1 int textcolor = 0xffffffff int theight = 8 int twidth string typeface = localize$(IDS_F_GEN_TEXTBUTTON) //localize$(IDS_F_GEN_TEXTBUTTON) string text int gwidth pane p_glow = WPATH "glow.tga" alphamode (p_glow) = am_alpha_oneone origin (p_glow) = getwidth(p_glow)/2, getheight(p_glow)/2 color (p_glow) = 20, 80, 100, 255 font3d gFont3d = FPATH typeface sound btnRolloverSound = SPATH "sfx_button7.wav" // delay is frame based not time based int delay = FRAME_DELAY int time_delayed = 0 framerate = 2 int disabled = 0 } GUI_INIT { if disabled == 1 { textcolor = 0x44ffffff color (p_glow) = 0, 40, 50, 255 } if disabled == 0 { textcolor = current_color color (p_glow) = 20, 80, 100, 255 } print3d_attributes = gFont3d, 0xffffffff,textsize,0,1,0,0,just_center twidth = getprint3dwidth(text) theight = getprint3dheight(text) region = 0,0 to twidth + 5, theight scale (p_glow) = ((twidth * getwidth(p_glow)) / 100) + (twidth / 3), 125, 100 } REGION_ENTERED { if disabled == 0 { textcolor = glowcolor color (p_glow) = 40, 150, 180, 255 play btnRolloverSound, 1 } } REGION_EXITED { if disabled == 0 { textcolor = facecolor color (p_glow) = 20, 80, 100, 255 } } LBUTTON_UPDATE { if disabled == 0 { if (time_delayed == delay) { if (mouse.left == BUTTON_PRESSED) { textcolor = depressedcolor color (p_glow) = 20, 150, 175, 50 } if (mouse.left == BUTTON_RELEASED) { textcolor = glowcolor color (p_glow) = 20, 120, 150, 50 } if (mouse.left == BUTTON_CLICKED) { mail(id) } } } } GUI_EXECUTE { if (time_delayed < delay) time_delayed++ } GUI_DRAW { render p_glow, location.x + (twidth / 2), location.y + (theight / 2) + 3 print3d_attributes = gFont3d, textcolor,textsize,1,1,0,0,just_center lprint3d_margins = region lprint3d_position = 0,-2 print3d text } } s_invisiblebutton { GUI_CREATE { location = 320,240 region = 0,0 to 32,32 int id = 0 //A R G B int invisible_color = 0x00ffffff int height = 10 int width = 10 sound btnRolloverSound = SPATH "sfx_button7.wav" // delay is frame based not time based int delay = FRAME_DELAY int time_delayed = 0 framerate = 2 } GUI_INIT { region = 0,0 to width, height } REGION_ENTERED { play btnRolloverSound, 1 } REGION_EXITED { } LBUTTON_UPDATE { if (time_delayed == delay) { if (mouse.left == BUTTON_CLICKED) { mail(id) } } } GUI_EXECUTE { if (time_delayed < delay) time_delayed++ } GUI_DRAW { setpencolor(invisible_color) drawrect region } } s_text3dglowbutton { GUI_CREATE { location = 320,240 region = 0,0 to 32,32 int id = 0 //A R G B int facecolor = 0x66000000 int glowcolor = 0xcc000000 int depressedcolor = 0xff000000 int bordercolor = 0xffffffff int current_color = facecolor int textsize = 1 int textcolor = 0xffffffff int theight = 8 int twidth = 8 int frame = true int offset string typeface = localize$(IDS_F_GEN_BUTTON) string text font3d gFont3d = FPATH typeface sound btnRolloverSound = SPATH "sfx_button7.wav" // delay is frame based not time based int delay = FRAME_DELAY int time_delayed = 0 framerate = 2 } GUI_INIT { gFont3d = FPATH typeface print3d_attributes = gFont3d, 0xffffffff,textsize,0,1,0,0,just_center offset = ((region.p2.y-getprint3dheight(text))/2)+2 theight = getprint3dheight(text) region = 0,0 to twidth+theight, theight*2 } REGION_ENTERED { current_color = glowcolor play btnRolloverSound, 1 } REGION_EXITED { current_color = facecolor } LBUTTON_UPDATE { if (time_delayed == delay) { if (mouse.left == BUTTON_PRESSED) { current_color = depressedcolor } if (mouse.left == BUTTON_RELEASED) { current_color = glowcolor } if (mouse.left == BUTTON_CLICKED) { mail(id) } } } GUI_EXECUTE { if (time_delayed < delay) time_delayed++ } GUI_DRAW { if (frame) { setpencolor(current_color) ldrawrect region setpencolor(bordercolor) ldrawframe region drawframe location.x+region.p1.x+1, location.y+region.p1.y+1 to location.x+region.p2.x-1, location.y+region.p2.y-1 } print3d_attributes = gFont3d, textcolor,textsize,1,1,0,0,just_center lprint3d_margins = region lprint3d_position = 0,(theight / 2) - 2 //+offset print3d text } } s_text3dglowbuttonwrap { GUI_CREATE { location = 320,240 region = 0,0 to 32,32 int id = 0 //A R G B int facecolor = 0x66000000 int glowcolor = 0xcc000000 int depressedcolor = 0xff000000 int bordercolor = 0xffffffff int current_color = facecolor int textsize = 1 int textcolor = 0xffffffff int theight = 8 int twidth = 8 int offset string typeface = localize$(IDS_F_GEN_BUTTON) string text font3d gFont3d = FPATH typeface sound btnRolloverSound = SPATH "sfx_button7.wav" // delay is frame based not time based int delay = FRAME_DELAY int time_delayed = 0 framerate = 2 } GUI_INIT { print3d_attributes = gFont3d, 0xffffffff,textsize,0,1,0,0,just_center offset = ((region.p2.y-getprint3dheight(text))/2)+2 theight = 20 region = 0,0 to twidth+theight, theight*2 } REGION_ENTERED { current_color = glowcolor play btnRolloverSound, 1 } REGION_EXITED { current_color = facecolor } LBUTTON_UPDATE { if (time_delayed == delay) { if (mouse.left == BUTTON_PRESSED) { current_color = depressedcolor } if (mouse.left == BUTTON_RELEASED) { current_color = glowcolor } if (mouse.left == BUTTON_CLICKED) { mail(id) } } } GUI_EXECUTE { if (time_delayed < delay) time_delayed++ } GUI_DRAW { setpencolor(current_color) ldrawrect region setpencolor(bordercolor) ldrawframe region drawframe location.x+region.p1.x+1, location.y+region.p1.y+1 to location.x+region.p2.x-1, location.y+region.p2.y-1 print3d_attributes = gFont3d, textcolor,textsize,1,1,0,0,just_center lprint3d_margins = region lprint3d_position = 0,(theight / 4) - 2 //offset print3d text } } // Draws the multi-state buttons s_multistatepane { GUI_CREATE { int id = 0 pane p_pane bitmap b_states string file // 4 states - // 0 enabled off // 1 enabled focus // 2 enabled on // 3 disabled int total_states int state = 0 int buttonsize int textsize = 1 int textcolor = 0xffffffff int theight = 8 int twidth = 8 int offset string typeface = localize$(IDS_F_GEN_BUTTON) string text font3d gFont3d = FPATH typeface sound btnRolloverSound = SPATH "sfx_button7.wav" int nRollover = 0 // A flag to set if using c_rollover int nHelpID = -1 // delay is frame based not time based int delay = FRAME_DELAY int time_delayed = 0 framerate = 2 } GUI_INIT { b_states = file buttonsize = getheight(b_states)/total_states p_pane = getwidth(b_states), buttonsize, true, volatile blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) region = 0,0 to getwidth(b_states),buttonsize alphamode(p_pane)=am_alpha_alphainvalpha print3d_attributes = gFont3d, textcolor, textsize, 0, 1, 0, 0, just_center theight = getprint3dheight(text) if state != 3 { color(p_pane) = packcolor(255, 255, 255, 255) textcolor = packcolor(255, 255, 255, 255) } else { color(p_pane) = packcolor(255, 255, 255, 100) textcolor = packcolor(255, 255, 255, 100) } } GUI_ACTIVATE { if state != 3 { color(p_pane) = packcolor(255, 255, 255, 255) textcolor = packcolor(255, 255, 255, 255) } else { color(p_pane) = packcolor(255, 255, 255, 100) textcolor = packcolor(255, 255, 255, 100) } } GUI_MAILBOX { if (getmessage() == 1) { state = 0 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } } REGION_ENTERED { if (nRollover) { // Make sure the rollover is clean before giving our help id mail (nMSG_CLEARHELP,oRollover) oRollover.nHelpID = nHelpID mail (nMSG_INPUT_RESID,oRollover) } if (state != 3) { state = 1 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) play btnRolloverSound, 1 } if exists(@infobox@) { mail(id, @infobox@) } } REGION_EXITED { if (nRollover) { if (oRollover.nHelpID == nHelpID ) mail (nMSG_CLEARHELP,oRollover) } if (state != 3) { if (!gotfocus(this)) { state = 0 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } } if exists(@infobox@) { if (@infobox@id == id) mail(-1, @infobox@) } } LBUTTON_UPDATE { if (time_delayed == delay) { if (state != 3) { if (mouse.left == BUTTON_PRESSED) { state = 2 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) // mail(state) } if (mouse.left == BUTTON_RELEASED) { state = 1 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) // mail(state) } if mouse.left == BUTTON_CLICKED { mail(state) } } } } GUI_FOCUS { if (state != 3) { state = 1 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } } GUI_UNFOCUS { if (state != 3) { state = 0 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } } GUI_CHAR { if (state != 3) { if getchar() == char("\n") mail(state) } } GUI_EXECUTE { if (time_delayed < delay) time_delayed++ if state != 3 { color(p_pane) = packcolor(255, 255, 255, 255) textcolor = packcolor(255, 255, 255, 255) } else { color(p_pane) = packcolor(255, 255, 255, 100) textcolor = packcolor(255, 255, 255, 100) } } GUI_DRAW { render p_pane, location print3d_attributes = gFont3d, textcolor,textsize,0,1,0,0,just_center lprint3d_margins = region lprint3d_position = 0,((buttonsize/2) - (theight/2)) - 1 print3d text } } s_multistatepanetoggle { GUI_CREATE { font3d gFont3d = FPATH localize$(IDS_F_GEN_BUTTON) location = 320,240,5 int id = 0 pane p_pane bitmap b_states string file int total_states int state = 0 int buttonsize int toggle int textsize = 1 int textcolor = 0xffffffff int theight = 8 int twidth = 8 string text int nRollover = 0 // A flag to set if using c_rollover int nHelpID = -1 sound btnRolloverSound = SPATH "sfx_button7.wav" sound btnPressedSound = SPATH "sfx_button5.wav" // delay is frame based not time based int delay = FRAME_DELAY int time_delayed = 0 framerate = 2 } GUI_INIT { b_states = file buttonsize = getheight(b_states)/total_states p_pane = getwidth(b_states), buttonsize, true, volatile alphamode (p_pane) = am_alpha_alphainvalpha blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) region = 0,0 to getwidth(b_states),buttonsize } GUI_MAILBOX { if (getmessage() == 1) { //spew "turning off" state = 0 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } else { //spew "turning on" state = 2 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } } REGION_ENTERED { if (nRollover) { oRollover.nHelpID = nHelpID mail (nMSG_INPUT_RESID,oRollover) } if (state != 3) { if state != 2 { state = 1 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) play btnRolloverSound, 1 } } if exists(@infobox@) { mail(id, @infobox@) } } REGION_EXITED { if (nRollover) { mail (nMSG_CLEARHELP,oRollover) } if (state != 3) { if state != 2 { state = 0 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } } if exists(@infobox@) { mail(-1, @infobox@) } } LBUTTON_UPDATE { if (time_delayed == delay) { if (state != 3) { if (mouse.left == BUTTON_CLICKED) { state = 2 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) mail(id) play btnPressedSound, 1 } } } } GUI_EXECUTE { if (time_delayed < delay) time_delayed++ } GUI_DRAW { render p_pane, location if (state != 3) print3d_attributes = gFont3d, textcolor,textsize,0,1,0,0,just_center else { int half_textcolor = 0x77777777 print3d_attributes = gFont3d, half_textcolor,textsize,0,1,0,0,just_center } lprint3d_margins = region lprint3d_position = 0,((buttonsize/2) - (theight/2)) - 5 print3d text } } s_checkbox { GUI_CREATE { font3d gFont3d = FPATH localize$(IDS_F_GEN_CHECKBOX) location = 320,240,5 int id = 0 pane p_pane bitmap b_states string file // 4 states - // 0 enabled off // 1 enabled focus // 2 enabled on // 3 disabled int total_states int state = 0 int buttonsize int toggle int textsize = 1 int textcolor = 0xffffffff int textcolor_focused = _DEF_CHECKBOX_HIGHLIGHT_COLOR // jcem - 0xffffffff int theight = 8 int twidth = 8 string text sound btnRolloverSound = SPATH "sfx_button7.wav" sound btnPressedSound = SPATH "sfx_button5.wav" // delay is frame based not time based int delay = FRAME_DELAY int time_delayed = 0 framerate = 2 } GUI_INIT { b_states = file buttonsize = getheight(b_states)/total_states p_pane = getwidth(b_states), buttonsize, true, volatile alphamode (p_pane) = am_alpha_alphainvalpha blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) region = 0,0 to getwidth(b_states),buttonsize } GUI_MAILBOX { if (getmessage() == 9999) { if (state != 3) { if state != 2 { state = 2 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) if exists(@Mechbay@) { mail(1) } else { mail(id) } play btnPressedSound, 1 } else { state = 1 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) if exists(@Mechbay@) { mail(0) } else { mail(id) } play btnPressedSound, 1 } } } else { if (getmessage() == 1) { spew "turning off" state = 0 } else { spew "turning on" state = 2 } blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } } REGION_ENTERED { if (state == 0) { state = 1 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) play btnRolloverSound, 1 } if exists(@infobox@) { mail(id, @infobox@) } } REGION_EXITED { if (state == 1) { state = 0 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } if exists(@infobox@) { mail(-1, @infobox@) } } LBUTTON_UPDATE { if (time_delayed == delay) { if (mouse.left == BUTTON_CLICKED) { focus(this) mail(9999, this) } } } GUI_FOCUS { if (state == 0) { state = 1 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } } GUI_UNFOCUS { if (state == 1) { state = 0 blit b_states(0,buttonsize*state to getwidth(b_states), buttonsize*(state+1)), 0,0 on p_pane update(p_pane) } } GUI_CHAR { int key = getchar() if key == char(" ") //enter is pressed to select the current lit item { mail(9999, this) } // tab section if you have our GOS Script tab routine if (key == 9) //9 is the value of a tab { mail(M_TABEVENT,parent) } } GUI_EXECUTE { if (time_delayed < delay) time_delayed++ } GUI_DRAW { int ccc render p_pane, location if gotfocus(this) ccc = textcolor_focused else ccc = textcolor print3d_attributes = gFont3d, ccc,textsize,0,1,0,0,just_left print3d_margins = location.x, location.y to location.x + getprint3dwidth(text)+buttonsize+8, location.y+getprint3dheight(text)+3 lprint3d_position = buttonsize + 10, -1 print3d text } }