@name DGPC2 @inputs Power Memory User:entity [SM SL SR]:wirelink Mouse1 Mouse2 @model models\props/cs_office/computer_caseB.mdl # CORE @persist Status:string # KEY BOARD @persist CanKeyBoard [ActiveKeyBoard ActiveUnKeyBoard]:array # EGP @persist Screen:array # DISPLAY @persist Ind [CS_Default CS_DG_OS ColorScheme]:array Loading_Ind Loading_list:table @persist Window_Ind [Window_Obj Text_Obj]:table Text_Ind Button_Obj:table Button_Index:array @persist ButtonsActive LastCur:vector2 CheckBox_Obj:table CheckBox_Index:array # LOGIN @persist Password:string Win_CreatePassword KS_Password:string PasswordKey Key_Pass Key_Enter:string @persist FirstEnter Key_Message Win_Login # DESKTOP @persist Cursor StartmenuList:table StartMenu_Buttons:array Programs:table CPU_info:array Gadgets:table @persist Win_CPUinfo Win_StartMenu Win_Gadgets Win_Programs Program_Buttons:array # GADGETS @persist Gad_Time Gad_Time_txt:vector2 Gad_Cpu Gad_Cpu_Bar # PROGRAMS # =================================== # PONG # ----------------- @persist [PONG_MultiList PONG_MenuList]:table [CS_PONG PONG_MenuButtons PONG_Menu_Contents PONG_Base PONG_Paddles]:array @persist PONG_P1_Score PONG_P2_Score PONG_P1_Txt PONG_P2_Txt PONG_BALL PONG_P2_Name:string PONG_SinglePlayer @persist PONG_PaddleSpeed PONG_BallSpeed PONG_Paddle_Direction PONG_BallDir PONG_BallOffset PONG_Ball @persist PONG_clk_release PONG_clk_move PONG_IsHoster PONG_SearchingGames PONG_SV_Index PONG_Awaiting PONG_CLIENT @persist [PONG_Server_Contents PONG_ServerButtons]:array PONG_ServerInfo:table PONG_Conneted PONG_Opponent PONG_askList:array # ----------------- # =================================== # BOOTSTRAPPER @persist PC_on PC_shutting ShutTextInd Boot_count Boot_Loading Boot_Loader # ROUTER @persist Rout_Port:string Rout_DGPCs:array if( duped() ){ print( "Nope, it's just chuck testa." ) selfDestructAll() } # ROUTER -- Easily Hackable #[=================================]# if( first() ){ dsSetScope(2) dsJoinGroup("DG-WIFI") dsSend("DGPC_Joined","DG-WIFI",array( owner():name(),entity():id() ) ) function rout_UD_Connected(){ dsSend("GetConnected","DG-WIFI",entity()) } function rout_array(S:string,E:number,A:array){ dsSend("SendArray","DG-WIFI",table(S,E,A)) } function rout_number(S:string,E:number,N){ dsSend("SendNumber","DG-WIFI",table(S,E,N)) } } if( dsClk( "UD_Connected" ) ){ Rout_DGPCs = dsGetArray() } #[---------------------------------]# # ROUTER END #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # CORE #[=================================]# if( first() ){ function stopall(){ ActiveUnKeyBoard = array() CanKeyBoard = 0 ActiveKeyBoard = array() KeyBoard_Ind = 0 Ind = 0 Loading_Ind = 0 Loading_list = table() Window_Ind = 0 Window_Obj = table() Text_Obj = table() Text_Ind = 0 Button_Obj = table() Button_Index = array() ButtonsActive = 0 Win_CreatePassword = 0 KS_Password = "" PasswordKey = 0 Key_Pass = 0 Key_Enter = "" FirstEnter = 0 Key_Message = 0 Win_Login = 0 Cursor = 0 StartMenu_Buttons = array() Win_CPUinfo = 0 Win_StartMenu = 0 Gad_Time = 0 Gad_Time_txt = vec2() Gad_Cpu = 0 Gad_Cpu_Bar = 0 PC_shutting = 0 ShutTextInd = 0 Boot_count = 0 Boot_Loading = 0 Boot_Loader = 0 CheckBox_Obj = table() CheckBox_Index = array() PONG_SearchingGames = 0 PONG_IsHoster = 0 } } #[---------------------------------]# # CORE END #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # EGP #[=================================]# if( first() ){ Screen = array( SL,SM,SR ) function array:egpClear(){ foreach(K,V:wirelink = This){ V:egpClear() } } function array:egpColor(I:number,C:vector){ foreach(K,V:wirelink = This){ V:egpColor(I,C) } } function array:egpBox(I:number,P:vector2,S:vector2){ foreach(K,V:wirelink = This){ Pe = P+vec2(512-512*(K-1),0) V:egpBox(I,Pe,S) } } function array:egpText(I:number,S:string,P:vector2){ foreach(K,V:wirelink = This){ Pe = P+vec2(512-512*(K-1),0) V:egpText(I,S,Pe) } } function array:egpSize(I:number,S:vector2){ foreach(K,V:wirelink = This){ V:egpSize(I,S) } } function array:egpSize(I,S){ foreach(K,V:wirelink = This){ V:egpSize(I,S) } } function array:egpAlign(I,Ho,Ve){ foreach(K,V:wirelink = This){ V:egpAlign(I,Ho,Ve) } } function array:egpLine(I:number,P1:vector2,P2:vector2){ foreach(K,V:wirelink = This){ P1e = P1+vec2(512-512*(K-1),0) P2e = P2+vec2(512-512*(K-1),0) V:egpLine(I,P1e,P2e) } } function array:egpRoundedBox(I:number,P:vector2,S:vector2){ foreach(K,V:wirelink = This){ Pe = P+vec2(512-512*(K-1),0) V:egpRoundedBox(I,Pe,S) } } function array:egpCircle(I:number,P:vector2,S:vector2){ foreach(K,V:wirelink = This){ Pe = P+vec2(512-512*(K-1),0) V:egpCircle(I,Pe,S) } } function array:egpSetText(I:number,S:string){ foreach(K,V:wirelink = This){ V:egpSetText(I,S) } } function array:egpAlpha(I,A){ foreach(K,V:wirelink = This){ V:egpAlpha(I,A) } } function array:egpMaterial(I:number,S:string){ foreach(K,V:wirelink = This){ V:egpMaterial(I,S) } } function array:egpPos(I:number,P:vector2){ foreach(K,V:wirelink = This){ Pe = P+vec2(512-512*(K-1),0) V:egpPos(I,Pe) } } function array:egpAngle(I,A){ foreach(K,V:wirelink = This){ V:egpAngle(I,A) } } function array:egpRemove(I){ foreach(K,V:wirelink = This){ V:egpRemove(I) } } function array:egpPoly(I:number,R:array){ foreach(K,V:wirelink = This){ V:egpPoly(I,R) } } function array:egpParent(I,O){ foreach(K,V:wirelink = This){ V:egpParent(I,O) } } function array:egpRadius(I,R){ foreach(K,V:wirelink = This){ V:egpRadius(I,R) } } function array:egpOrder(I,O){ foreach(K,V:wirelink = This){ V:egpOrder(I,O) } } function array:egpParentToCursor(I){ foreach(K,V:wirelink = This){ V:egpParentToCursor(I) } } } #[---------------------------------]# # EGP END #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # KEY BOARD #[=================================]# if( first() ){ # Keyboard functions function number key_clk( S:string ){ CanKeyBoard = 1 ActiveKeyBoard:pushString( S ) return ActiveKeyBoard:count() } function key_remove( I ){ ActiveKeyBoard:remove(I) if( ActiveKeyBoard:count() == 0 ){ CanKeyBoard = 0 } } function number key_unclk( S:string ){ ActiveUnKeyBoard:pushString( S ) return ActiveUnKeyBoard:count() } function unkey_remove( I ){ ActiveUnKeyBoard:remove(I) } function number between( I,X,Y ){ if( I>=X && I<=Y ){ return 1 } else{ return 0 } } function string filter_general( S:string ){ if( Memory == 127 ){ return S:left( S:length()-1 ) } elseif( between( Memory,65,90 ) || between( Memory,97,122 ) || between( Memory,48,57 ) ){ return S+toChar(Memory) } else{ return S } } function buttonclicks(){ foreach( K,V:string = Button_Index ){ local O = Button_Obj[K,array] local Cur = vec2() if( O[10,wirelink] ){ Cur = O[10,wirelink]:egpCursor(User) } else{ Cur = SM:egpCursor(User) } local Cx = Cur:x() local Cy = Cur:y() local T = O[1,number] local X = O[3,number] local Y = O[4,number] local W = O[5,number] if( T ){ local H = O[6,number] if( between(Cx,X-W/2,X+W/2) && between(Cy,Y-H/2,Y+H/2) ){ timer( V,0 ) } }else{ if( abs(Cx-X) < W && abs(Cy-Y) < W ){ timer( V,0 ) } } } } #key_clk( "Debug" ) } if( inputClk() ){ if( CanKeyBoard ){ if( Memory ){ foreach( K,V:string = ActiveKeyBoard ){ timer(V,0) } } if( !Memory ){ foreach( K,V:string = ActiveUnKeyBoard ){ timer(V,0) } } } } if( clk( "Debug" ) ){ print( toChar( Memory )+" : "+Memory ) } #[---------------------------------]# # KEY BOARD END #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # DISPLAY #[=================================]# if( first() ){ CS_Default = array( vec(), # 1 Black vec(255,255,255), # 2 White vec(255,80,80), # 3 Red vec(50,50,50) # 4 Dark Grey ) CS_DG_OS = array( vec(), # 1 Black vec(255,255,255), # 2 White vec(255,80,80), # 3 Red vec(50,50,50), # 4 Dark Grey vec(50,50,190), # 5 Blue 1 vec(120,120,255), # 6 Blue 2 vec(255,255,190), # 7 Pale Yellow vec(150,255,150), # 8 Pale Green vec(255,150,150), # 9 Pale Red vec(255,255,80), # 10 Yellow vec(80,255,80), # 11 Green vec(80,80,255), # 12 Blue vec(255,150,40), # 13 Orange vec(100,100,100), # 14 Cursor Grey vec(255,40,40) # 15 Close Hover Red ) ColorScheme = CS_Default function sclear(){ Screen:egpClear() } function vector colorScheme( I ){ return ColorScheme[I,vector] } function color( I,C ){ Screen:egpColor(I,colorScheme(C)) } function number d_index(I){ if( I ){ return I }else{ Ind++ return Ind } } function number box( X,Y,W,H,C,I ){ local XInd = d_index(I) Screen:egpBox(XInd,vec2(X,Y),vec2(W,H)) color(XInd,C) return XInd } function number text( T:string,S,X,Y,C,AH,AV,I ){ local XInd = d_index(I) Screen:egpText(XInd,T,vec2(X,Y)) Screen:egpSize(XInd,S) Screen:egpAlign(XInd,AH,AV) color(XInd,C) return XInd } function number line( X1,Y1,X2,Y2,C,I ){ local XInd = d_index(I) Screen:egpLine(XInd,vec2(X1,Y1),vec2(X2,Y2)) color(XInd,C) return XInd } function number roundedbox( X,Y,W,H,C,I ){ local XInd = d_index(I) Screen:egpRoundedBox( XInd,vec2(X,Y),vec2(W,H) ) color(XInd,C) return XInd } function number circle( X,Y,W,H,C,I ){ local XInd = d_index(I) Screen:egpCircle( XInd,vec2(X,Y),vec2(W,H) ) color(XInd,C) return XInd } function removeobj( I ){ Screen:egpRemove(I) } function removegroup( A:array ){ foreach( K,V:number = A ){ removeobj( V ) } } function textobj( S:string,I ){ Screen:egpSetText(I,S) } function alphaobj( A,I ){ Screen:egpAlpha(I,A) } function texture( T:string,I ){ Screen:egpMaterial(I,T) } function posobj( X,Y,I ){ Screen:egpPos(I,vec2(X,Y)) } function rotateobj( R,I ){ Screen:egpAngle(I,R) } function sizeobj( W,H,I ){ Screen:egpSize(I,vec2(W,H)) } # Buttons! function number button_add( S:string,T,X,Y,W,H,C,Ho,Obj ){ Button_Index:pushString( S ) Button_Obj:pushArray( array( T,S,X,Y,W,H,C,Ho,Obj ) ) ButtonsActive = 1 timer( "ButtonHighlights", 100 ) return Button_Index:count() } function vector2 button_circle(S:string,X,Y,R,C,H){ local Cir = circle(X,Y,R,R,C,0) local But = button_add( S,0,X,Y,R,R,C,H,Cir ) return vec2(But,Cir) } function vector2 button_box(S:string,X,Y,W,H,C,CH){ local Box = box(X,Y,W,H,C,0) local But = button_add( S,1,X,Y,W,H,C,CH,Box ) return vec2(But,Box) } function button_remove(S:string){ local I = 0 foreach( K,V:string = Button_Index ){ if( S == V ){ I = K break } } if( I ){ Screen:egpRemove( Button_Obj[I,array][9,number] ) Button_Index:removeString(I) Button_Obj:removeArray(I) } } # Check Boxes!!! function number checkbox_add( ON:string,OFF:string,X,Y,On,Off,Set ){ local Outline = box(X,Y,30,30,1,0) local Cl = Off if( Set ){ Cl = On } local Box = box(X,Y,34,34,Cl,0) CheckBox_Index:pushString( ON ) CheckBox_Obj:pushArray( array( ON,OFF,X,Y,Set,On,Off,Outline,Box ) ) return CheckBox_Index:count() } function checkbox_remove(S:string){ local I = 0 foreach( K,V:string = CheckBox_Index ){ if( S == V ){ I = K break } } if( I ){ for( F=1,2 ){ Screen:egpRemove( CheckBox_Obj[I,array][7+F,number] ) } CheckBox_Index:removeString(I) CheckBox_Obj:removeArray(I) } } function checkboxclicks(){ foreach( K,V:string = CheckBox_Index ){ local O = CheckBox_Obj[K,array] local Cur = vec2() if( O[10,wirelink] ){ Cur = O[10,wirelink]:egpCursor(User) } else{ Cur = SM:egpCursor(User) } local Cx = Cur:x() local Cy = Cur:y() local X = O[3,number] local Y = O[4,number] if( between(Cx,X-15,X+15) && between(Cy,Y-15,Y+15) ){ O[5,number] = !O[5,number] if( O[5,number] ){ timer( O[1,string],0 ) color( O[9,number],O[6,number] ) }else{ timer( O[2,string],0 ) color( O[9,number],O[7,number] ) } } } } function number poly(S:array,X,Y,C){ Ind++ Screen:egpBox(Ind,vec2(X,Y),vec2(10,10)) local Box = Ind alphaobj( 0,Box ) Ind++ Screen:egpPoly(Ind,S) Screen:egpParent(Ind,Box) return Box } function vector2 textshadow( T:string,S,X,Y,C1,C2,A,D,AH,AV ){ local Shad = text( T,S,X+D,Y+D,C2,AH,AV,0 ) alphaobj( A,Shad ) local Txt = text( T,S,X,Y,C1,AH,AV,0 ) return vec2(Txt,Shad) } # Loading Bar! function number loading_create( X,Y,W,H,D,C1,C2,P ){ Loading_Ind++ local BO = box( X,Y,W,H,C1,0 ), local B = box( X,Y,W-D,H-D,C2,0 ) Loading_list[Loading_Ind,array] = array( box( X,Y,clamp(W*P-D,0,W-D),H-D,1,0 ), X,Y,W,H,D,BO,B ) return Loading_Ind } function loading_remove( I ){ Screen:egpRemove( Loading_list[I,array][1,number] ) Screen:egpRemove( Loading_list[I,array][7,number] ) Screen:egpRemove( Loading_list[I,array][8,number] ) Loading_list:removeArray( I ) } function loading_update( I:number,P:number,C:number,DC:vector ){ local Col = vec() if( C ){ Col = colorScheme(C) }else{ Col = DC } local A = Loading_list[I,array] local Ld = A[1,number] local X = A[2,number] local Y = A[3,number] local W = A[4,number] local H = A[5,number] local D = A[6,number] local Nw = clamp(W*P-D,0,W-D) local Nh = H-D sizeobj( Nw,Nh,Ld ) posobj(X+(Nw-W+D)/2,Y,Ld) Screen:egpColor(Ld,Col) } # Enter text! function vector2 text_create( Clk:string,X,Y,W,H,S,C ){ Text_Ind++ Text_Obj[Text_Ind,array] = array( box( X,Y,W,H,1,0 ), box( X,Y,W-6,H-6,7,0 ), text( "",S,X-W/2+6,Y-H/2+6,C,0,0,0 ) ) local K = key_clk( Clk ) return vec2(Text_Ind,K) } function text_remove( I ){ Text_Obj:removeArray( I ) } # Windows... function number window_create( X,Y,W,H ){ Window_Ind++ Window_Obj[Window_Ind,array] = array( roundedbox( X,Y,W,H,1,0 ), roundedbox( X,Y,W-6,H-6,2,0 ) ) Screen:egpRadius(Ind-1,5) Screen:egpRadius(Ind,5) return Window_Ind } function window_contents( I:number,R:array ){ Window_Obj[I,array] = Window_Obj[I,array]:add( R ) } function window_close( I ){ if( I ){ removegroup( Window_Obj[I,array] ) } } # SINGLE SCREEN DRAW # ========================== function number box( Sc:wirelink,X,Y,W,H,C,I ){ local XInd = d_index(I) Sc:egpBox(XInd,vec2(X,Y),vec2(W,H)) color(XInd,C) return XInd } function number text( Sc:wirelink,T:string,S,X,Y,C,AH,AV,I ){ local XInd = d_index(I) Sc:egpText(XInd,T,vec2(X,Y)) Sc:egpSize(XInd,S) Sc:egpAlign(XInd,AH,AV) color(XInd,C) return XInd } function texture( Sc:wirelink,T:string,I ){ Sc:egpMaterial(I,T) } function rotateobj( Sc:wirelink,R,I ){ Sc:egpAngle(I,R) } function number circle( Sc:wirelink,X,Y,W,H,C,I ){ local XInd = d_index(I) Sc:egpCircle( XInd,vec2(X,Y),vec2(W,H) ) color(XInd,C) return XInd } function alphaobj( Sc:wirelink,A,I ){ Sc:egpAlpha(I,A) } # Buttons! function number button_add( Sc:wirelink,S:string,T,X,Y,W,H,C,Ho,Obj ){ Button_Index:pushString( S ) Button_Obj:pushArray( array( T,S,X,Y,W,H,C,Ho,Obj,Sc ) ) ButtonsActive = 1 timer( "ButtonHighlights", 100 ) return Button_Index:count() } function vector2 button_circle(Sc:wirelink,S:string,X,Y,R,C,H){ local Cir = circle(Sc,X,Y,R,R,C,0) local But = button_add( Sc,S,0,X,Y,R,R,C,H,Cir ) return vec2(But,Cir) } function vector2 button_box(Sc:wirelink,S:string,X,Y,W,H,C,CH){ local Box = box(Sc,X,Y,W,H,C,0) local But = button_add( Sc,S,1,X,Y,W,H,C,CH,Box ) return vec2(But,Box) } # BACKGROUNDS # ========================== function bg_dgos(){ foreach(K,V:wirelink = Screen){ box( V,256,256,512,512,5,0 ) local G = box( V,256,256,800,800,6,0 ) texture( V,"gui/gradient",G ) rotateobj( V,45,G ) for( I=1,10 ){ local X = randint(0,512) local Y = randint(0,512) local S = randint(20,64) local C = circle( V,X,Y,S,S,2,0 ) alphaobj(V,10,C) } } } } if( inputClk() ){ if( Mouse1 ){ checkboxclicks() buttonclicks() } if( Memory == 9 ){ checkboxclicks() buttonclicks() } } # BUTTON HIGHLIGHTS if( clk("ButtonHighlights") ){ local Moving = 0 foreach( K,V:wirelink = Screen ){ local Cur = V:egpCursor(User) if( Cur != LastCur ){ LastCur = Cur Moving = 1 } } if( Moving ){ foreach( K,V:string = Button_Index ){ local O = Button_Obj[K,array] local Cur = vec2() if( O[10,wirelink] ){ Cur = O[10,wirelink]:egpCursor(User) } else{ Cur = SM:egpCursor(User) } local Cx = Cur:x() local Cy = Cur:y() local T = O[1,number] local X = O[3,number] local Y = O[4,number] local W = O[5,number] if( T ){ local H = O[6,number] if( between(Cx,X-W/2,X+W/2) && between(Cy,Y-H/2,Y+H/2) ){ color(O[9,number],O[8,number]) }else{ color(O[9,number],O[7,number]) } }else{ if( abs(Cx-X) < W && abs(Cy-Y) < W ){ color(O[9,number],O[8,number]) }else{ color(O[9,number],O[7,number]) } } } } if( ButtonsActive ){ timer( "ButtonHighlights", 100 ) } } #[---------------------------------]# # DISPLAY END #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # LOGIN #[=================================]# if( first() ){ function string password_str( S:string ){ return "*":repeat( S:length() ) } function passwordbox( Enter:string,X,Y,W,H,S ){ local V = text_create( "K_password",X,Y,W,H,S,1 ) PasswordKey = V:x() Key_Pass = V:y() Key_Enter = Enter } function password_ask(){ Win_Login = window_create( 256,250,350,150 ) window_contents( Win_Login, array( text( "Login",30,135,190,1,0,0,0 ), line(120,218,395,218,1,0), text( "Please type your password and hit enter.",16,130,230,1,0,0,0 ), Ind,Ind+1,Ind+2,Ind+3 )) passwordbox( "PW_login",256,270,300,30,20 ) } function password_create(){ Win_CreatePassword = window_create( 256,250,350,150 ) window_contents( Win_CreatePassword, array( text( "Create a password",30,135,190,1,0,0,0 ), line(120,218,395,218,1,0), text( "Type password and hit enter to apply.",16,130,230,1,0,0,0 ), Ind,Ind+1,Ind+2,Ind+3 )) passwordbox( "PW_newpassword",256,270,300,30,20 ) } function login(){ Status = "login" sclear() bg_dgos() if( Password ){ password_ask() }else{ password_create() } } } if( Status == "login" ){ if( clk( "PW_login" ) ){ local Bar = Text_Obj[PasswordKey,array][2,number] if( !FirstEnter ){ Key_Message = text( "",16,130,295,1,0,0,0 ) window_contents( Win_Login, array( Key_Message) ) FirstEnter = 1 } if( KS_Password == Password ){ color( Bar, 8 ) key_remove( Key_Pass ) textobj( "Password Correct!", Key_Message ) timer("winc_login",1000) }else{ color( Bar, 9 ) textobj( "Password Incorrect!", Key_Message ) } } if( clk( "PW_newpassword" ) ){ local Bar = Text_Obj[PasswordKey,array][2,number] color( Bar, 8 ) key_remove( Key_Pass ) Password = KS_Password print( "DGPC: Password now is set to "+Password ) window_contents( Win_CreatePassword, array( text( "Password saved! Applying Settings",16,130,295,1,0,0,0 ) )) timer("winc_createpassword",2000) } if( clk( "K_password" ) ){ if( Memory == 13 ){ timer(Key_Enter,0) }else{ local Tx = Text_Obj[PasswordKey,array][3,number] KS_Password = filter_general(KS_Password):left(25) textobj(password_str( KS_Password ),Tx) } } if( clk("winc_createpassword") ){ KS_Password = "" window_close( Win_CreatePassword ) password_ask() } if( clk("winc_login") ){ KS_Password = "" window_close( Win_Login ) textshadow( "Welcome",60,256,200,2,1,255,2,1,0 ) textshadow( User:name(),40,256,260,2,1,255,2,1,0 ) timer( "desktop", 2000 ) } } #[---------------------------------]# # LOGIN END #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # DESKTOP #[=================================]# if( first() ){ # Le Registry Gadgets = table( array( "Time", "gg_time", "gg_timerm" ), array( "CPU", "gg_cpu", "gg_cpurm" ) ) StartmenuList = table( array( "Info", "sm_info" ), array( "Programs", "sm_programs" ), array( "Gadgets", "sm_gadgets" ), array( "Settings", "sm_settings" ), array( "Log out", "sm_logout" ), array( "Shut Down", "sm_shutdown" ) ) Programs = table( array( "Music Player", "pg_musicplayer" ), array( "Pong", "pg_pong" ) ) function taskbar(){ local H = 34 box(SM,256,512-(H+4)/2,512,H+4,1,0) local Gr = box(SM,256,512-H/2,H,512,2,2) texture( SM,"gui/gradient",Gr ) rotateobj( SM,-90,Gr ) local Bx = box(SM,256,512-H/2,512,H,6,0) alphaobj( SM,200,Bx ) } function starticon(){ local H = 34 local X = H/1.5 local Y = 512-H/1.5 local S = 18 local O = S/2+1 circle(SM,X,Y,H,H,1,0) button_circle(SM,"but_StartMenu",X,Y,H-4,2,13) box(SM,X,Y,S*2+6,S*2+6,1,0) box(SM,X-O,Y-O,S,S,3,0) box(SM,X+O,Y-O,S,S,10,0) box(SM,X+O,Y+O,S,S,11,0) box(SM,X-O,Y+O,S,S,12,0) } function topcur(){ Screen:egpOrder( Cursor, 10000000 ) } function number tocursor(A:array,C){ Ind++ Screen:egpPoly(Ind,A) Screen:egpParentToCursor( Ind ) Screen:egpOrder( Ind, 10000000 ) color( Ind,C ) return Ind } function cursor(){ local A = array( vec2(0,0), vec2(0,30), vec2(9,24), vec2(14,35), vec2(17,34), vec2(12,24), vec2(21,24) ) Cursor = tocursor(A,14) } function window_startmenu(){ Win_StartMenu = window_create( 100,280,200,350 ) local ML = array() StartMenu_Buttons = array() for( I=1,StartmenuList:count() ){ local V = StartmenuList[I,array] local S = V[2,string] button_box(S,100,122+I*50,180,40,7,8) StartMenu_Buttons:pushString( S ) ML = ML:add( array( text( V[1,string],28,100,135+I*50,1,1,2,0 ) )) } ML = ML:add(array( text( "DGPC2",28,100,135,1,1,2,0 ), line( 50,133,150,133,1,0 ) )) window_contents( Win_StartMenu, ML ) topcur() } function winc_startmenu(){ window_close( Win_StartMenu ) Win_StartMenu = 0 window_close( Win_Programs ) Win_Programs = 0 foreach( K,V:string = StartMenu_Buttons ){ button_remove(V) } foreach( K,V:string = Program_Buttons ){ button_remove(V) } } CPU_info = array( "Created by DGrouse, 29/05/2014", "Last updated: 11/06/2014", "Version: 1.3", "Program Count: "+Programs:count(), "Gadget Count: "+Gadgets:count() ) function window_CPUinfo(){ Win_CPUinfo = window_create( 256,250,350,150 ) button_box("wc_CPUinfo",410,192,20,20,3,15) local W = array() foreach(K,V:string = CPU_info){ W:pushNumber( text( V,20,100,215+K*20,1,0,2,0 ) ) } W = W:add(array( text( "DGPC2",30,256,210,1,1,2,0 ) )) window_contents( Win_CPUinfo,W ) topcur() } function winc_CPUinfo(){ button_remove("wc_CPUinfo") window_close( Win_CPUinfo ) } function logout(){ stopAllTimers() stopall() sclear() login() } function window_Programs(){ Win_Programs = window_create( 300,280,200,350 ) local ML = array() Program_Buttons = array() for( I=1,Programs:count() ){ local V = Programs[I,array] local S = V[2,string] button_box(S,300,122+I*50,180,40,7,8) Program_Buttons:pushString( S ) ML = ML:add( array( text( V[1,string],28,300,135+I*50,1,1,2,0 ) )) } ML = ML:add(array( text( "Programs",28,300,135,1,1,2,0 ), line( 250,133,350,133,1,0 ) )) window_contents( Win_StartMenu, ML ) topcur() } function window_Gadgets(){ Win_Gadgets = window_create( 256,250,350,150 ) button_box("wc_Gadgets",410,192,20,20,3,15) local W = array() checkbox_add( "gg_cpuon","gg_cpurm",130,240,11,3,Gad_Cpu ) checkbox_add( "gg_timeon","gg_timerm",130,280,11,3,Gad_Time ) W = W:add(array( text( "DGPC2 - Gadgets",30,256,210,1,1,2,0 ), line( 142,210,380,210,1,0 ), text( "CPU Process Display",25,150,252,0,0,2,0 ), text( "Time",25,150,292,0,0,2,0 ) )) window_contents( Win_Gadgets,W ) topcur() } function winc_Gadgets(){ button_remove("wc_Gadgets") checkbox_remove("gg_cpuon") checkbox_remove("gg_timeon") window_close( Win_Gadgets ) } } if( Status == "desktop" ){ if( clk( "sm_programs" ) ){ window_Programs() } if( clk( "gg_cpuon" ) ){ timer("gg_cpu",0) Gad_Cpu = 1 } if( clk( "gg_timeon" ) ){ timer("gg_time",0) Gad_Time = 1 } if( clk( "sm_gadgets" ) ){ winc_startmenu() window_Gadgets() } if( clk( "wc_Gadgets" ) ){ winc_Gadgets() } if( clk( "sm_logout" ) ){ logout() } if( clk( "gg_cpurm" ) ){ Gad_Cpu = 0 stoptimer("gg_cpu") loading_remove( Gad_Cpu_Bar ) Gad_Cpu_Bar = 0 } if( clk( "gg_cpu" ) ){ local P = ops()/1000 local DC = vec( P*255,255-P*255,0 ) if( !Gad_Cpu_Bar ){ Gad_Cpu_Bar = loading_create( 360,495,90,24,6,1,4,P ) } loading_update( Gad_Cpu_Bar,P*100,0,DC ) topcur() if( Gad_Cpu ){ timer("gg_cpu",1000) } } if( clk( "gg_timerm" ) ){ Gad_Time = 0 stoptimer("gg_time") Screen:egpRemove(Gad_Time_txt:x()) Screen:egpRemove(Gad_Time_txt:y()) } if( clk( "gg_time" ) ){ local H = time("hour") local M = time("min") local E = "am" if( H == 0 ){ E = "am" H = 12 }elseif( H > 12 ){ E = "am" H = H-12 } Screen:egpRemove(Gad_Time_txt:x()) Screen:egpRemove(Gad_Time_txt:y()) Gad_Time_txt = textshadow(H+":"+M+E,24,500,505,2,1,255,1,2,2) topcur() if( Gad_Time ){ timer("gg_time",60000) } } if( clk( "wc_CPUinfo" ) ){ winc_CPUinfo() } if( clk( "sm_info" ) ){ winc_startmenu() window_CPUinfo() } if( clk("but_StartMenu") ){ if( Win_StartMenu ){ winc_startmenu() }else{ window_startmenu() } } } if( clk( "desktop" ) ){ Status = "desktop" sclear() bg_dgos() taskbar() starticon() key_clk( "TabClick" ) cursor() } #[---------------------------------]# # DESKTOP END #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # PROGRAMS #[=================================]# # 2 PONG #---------------------------------------- if( first() ){ PONG_PaddleSpeed = 20 PONG_BallSpeed = 8 PONG_MenuList = table( array( "Singleplayer", "pong_single" ), array( "Multiplayer", "pong_multi" ), array( "Settings", "pong_settings" ), array( "Quit", "pong_quit" ) ) PONG_MultiList = table( array( "Create Game", "pong_creategame" ), array( "Refresh", "pong_refreshmp" ), array( "Back", "pong_multiback" ) ) CS_PONG = array( vec(), # 1 Black vec(255,255,255), # 2 White vec(255,40,40), # 3 Red vec(40,255,40), # 4 Green vec(40,40,255), # 5 Blue vec(100,100,100), # 6 Grey vec(255,120,30), # 7 Orange vec(0,0,80) # 8 Blue ) function bg_pong(){ #box( 256,256,512,512,8,0 ) local G = box( 256,900,2000,2000,8,0 ) texture( "gui/gradient",G ) rotateobj( 90,G ) } function pong_main_menu(){ PONG_Menu_Contents = array( text( SM,"PONG",60,100,55,2,1,0,0 ) ) for( I=1,PONG_MenuList:count() ){ local V = PONG_MenuList[I,array] local S = V[2,string] button_box(SM,S,100,122+I*50,180,40,6,7) PONG_MenuButtons:pushString( S ) PONG_Menu_Contents:pushNumber( text( SM,V[1,string],28,100,135+I*50,1,1,3,0 ) ) } } function pong_mm_close(){ removegroup( PONG_Menu_Contents ) foreach( K,V:string = PONG_MenuButtons ){ button_remove(V) } } function pong_mpm_close(){ removegroup( PONG_Server_Contents ) foreach( K,V:string = PONG_ServerButtons ){ button_remove(V) } } function string pong_SetName2(){ local P2Name = "Unconnected" if( PONG_SinglePlayer ){ P2Name = "CPU" }else{ if( PONG_P2_Name != "" ){ P2Name = PONG_P2_Name } } return P2Name } function pong_base(){ PONG_P1_Score = 0 PONG_P2_Score = 0 local P2Name = pong_SetName2() PONG_P1_Txt = text(User:name()+": "+PONG_P1_Score,30,5,15,2,0,0,0) PONG_P2_Txt = text(P2Name+": "+PONG_P2_Score,30,507,15,2,2,0,0) PONG_Base = array( line(3,50,509,50,2,0), PONG_P1_Txt, PONG_P2_Txt ) PONG_clk_move = key_clk( "pong_move" ) PONG_clk_release = key_unclk( "pong_release" ) } function pong_SetUp(){ local W = 30 local H = 100 local D = 40 PONG_Paddles = array( box(D,256,W,H,4,0), box(512-D,256,W,H,3,0) ) PONG_Ball = circle(256,256,10,10,5,0) if( randint(0,1) ){ PONG_BallDir = 1 if( PONG_SinglePlayer ){ timer( "pong_moveCPU",100 ) } }else{ PONG_BallDir = -1 } PONG_BallOffset = randint(0,5) PONG_BallSpeed = 8 timer( "pong_moveball", 1000 ) } function pong_paddlemove( I,D ){ local O = PONG_Paddles[I,number] local P = SM:egpPos(O) if( between( P:y()+PONG_PaddleSpeed*D,100,462 ) ){ SM:egpPos( O,P+vec2(0,PONG_PaddleSpeed*D) ) if( PONG_IsHoster && !PONG_SinglePlayer ){ P = SM:egpPos(O) rout_array( "pong_CL_Paddle",PONG_CLIENT,array(I,P) ) } } } function pong_clear(){ removegroup( PONG_Paddles ) removeobj( PONG_Ball ) stoptimer("pong_movepaddle") stoptimer("pong_moveCPU") stoptimer("pong_moveball") } function pong_gametomenu(){ pong_clear() removegroup( PONG_Base ) unkey_remove( PONG_clk_release ) key_remove( PONG_clk_move ) pong_main_menu() PONG_SinglePlayer = 0 } function pong_nextround(){ pong_clear() pong_SetUp() local P2Name = pong_SetName2() textobj(User:name()+": "+PONG_P1_Score,PONG_P1_Txt) textobj(P2Name+": "+PONG_P2_Score,PONG_P2_Txt) } function pong_moveball(){ local P = SM:egpPos(PONG_Ball) SM:egpPos( PONG_Ball,P+vec2(PONG_BallSpeed*PONG_BallDir,PONG_BallOffset) ) } function pong_walls(){ local Y = SM:egpPos(PONG_Ball):y() if( PONG_BallOffset > 0 ){ if( Y > 502 ){ PONG_BallOffset = -PONG_BallOffset } }else{ if( Y < 60 ){ PONG_BallOffset = -PONG_BallOffset } } } function pong_point(){ local X = SM:egpPos(PONG_Ball):x() if( PONG_BallDir > 0 ){ if( X > 512 ){ PONG_P1_Score++ pong_nextround() } }else{ if( X < 0 ){ PONG_P2_Score++ pong_nextround() } } } function number pong_collision(I1,I2){ local P1 = SM:egpPos(I1) local P2 = SM:egpPos(I2) if( between( P1:x(),P2:x()-20,P2:x()+20 ) && between( P1:y(),P2:y()-55,P2:y()+55 ) ){ return 1 } return 0 } function pong_ballcollisionPaddle( P ){ if( pong_collision( PONG_Ball,PONG_Paddles[P,number] ) ){ PONG_BallDir = -PONG_BallDir PONG_BallSpeed = clamp(PONG_BallSpeed+1,8,29) local PY = SM:egpPos( PONG_Paddles[P,number] ):y() local BY = SM:egpPos( PONG_Ball ):y() PONG_BallOffset = PONG_BallOffset+(BY-PY)*0.2 if( P == 1 ){ entity():soundPlay(0,0.2,"synth/tri.wav") soundPitch(0,80) soundVolume(0,0.05) if( PONG_SinglePlayer ){ timer( "pong_moveCPU",100 ) } }else{ entity():soundPlay(0,0.2,"synth/tri.wav") soundVolume(0,0.05) } } } function pong_ballcollision(){ if( PONG_BallDir > 0 ){ pong_ballcollisionPaddle( 2 ) }else{ pong_ballcollisionPaddle( 1 ) } } function pong_refreshMP(){ timer("pong_refreshDelay",500) } function pong_mpm(){ PONG_Menu_Contents = array( text( SM,"PONG",60,100,55,2,1,0,0 ), text( SM,"Servers",60,360,20,2,1,0,0 ) ) for( I=1,PONG_MultiList:count() ){ local V = PONG_MultiList[I,array] local S = V[2,string] button_box(SM,S,100,122+I*50,180,40,6,7) PONG_MenuButtons:pushString( S ) PONG_Menu_Contents:pushNumber( text( SM,V[1,string],28,100,135+I*50,1,1,3,0 ) ) } PONG_SearchingGames = 1 pong_refreshMP() } function pong_sv_list_add( N ){ local Match = 0 for( I=1,PONG_ServerInfo:count() ){ if( PONG_ServerInfo[I,array][1,number] == N ){ Match = 1 } } if( !Match ){ local Nx = entity(N):owner():name() local Nm = Nx+" ["+N+"]" PONG_SV_Index++ local S = "pong_JoinGame"+PONG_SV_Index PONG_ServerInfo:pushArray( array(N,Nx) ) button_box(SM,S,350,100+PONG_SV_Index*50,290,40,6,7) PONG_ServerButtons:pushString( S ) PONG_Server_Contents:pushNumber( text( SM,Nm,28,350,113+PONG_SV_Index*50,1,1,3,0 ) ) } } function pong_ClientSetUp(){ local W = 30 local H = 100 local D = 40 PONG_Paddles = array( box(D,256,W,H,4,0), box(512-D,256,W,H,3,0) ) PONG_Ball = circle(256,256,10,10,5,0) } function pong_RequestConnect( A:array ){ rout_number( "pong_Pconnected",A[1,number],entity():id() ) } function pong_paddleMPmove( Dir ){ rout_number( "pong_SV_movepaddle",PONG_Opponent,Dir ) } function pong_connect( A:array ){ pong_mpm_close() pong_mm_close() PONG_P2_Name = A[1,string] PONG_Conneted = 1 PONG_Opponent = A[2,number] pong_base() pong_ClientSetUp() timer( "pong_moveMPpaddle",100 ) } } if( Status == "pong" ){ if( dsClk( "pong_CL_Paddle" ) ){ local A = dsGetArray() local I = A[1,number] local P = A[2,vector2] SM:egpPos( PONG_Paddles[I,number],P ) } if( dsClk( "pong_CL_Ball" ) ){ local A = dsGetArray() SM:egpPos(PONG_Ball,A[1,vector2]) } if( dsClk( "pong_SV_movepaddle" ) ){ pong_paddlemove( 2,dsGetNumber() ) } if( clk( "pong_moveMPpaddle" ) ){ pong_paddleMPmove( PONG_Paddle_Direction ) timer( "pong_moveMPpaddle",100 ) } if( dsClk( "pong_StartMPGame" ) ){ local A = dsGetArray() pong_connect( A ) } if( dsClk( "pong_Pconnected" ) ){ if( PONG_IsHoster ){ local C = dsGetNumber() rout_array( "pong_StartMPGame",C,array( User:name(), entity():id() ) ) PONG_P2_Name = entity(C):owner():name() PONG_CLIENT = C removeobj( PONG_Awaiting ) pong_SetUp() } } for(I=1,PONG_ServerInfo:count()){ if( clk("pong_JoinGame"+I) ){ pong_RequestConnect( PONG_ServerInfo[I,array] ) } } if( clk("pong_refreshDelay") ){ if( PONG_SearchingGames ){ pong_mpm_close() PONG_SV_Index = 0 PONG_ServerInfo:clear() rout_UD_Connected() } } if( clk("pong_creategame") ){ PONG_IsHoster = 1 pong_mm_close() pong_mpm_close() pong_base() PONG_Awaiting = PONG_Base:pushNumber( text("Awaiting Opponent",30,256,256,2,1,0,0) ) } if( clk("pong_refreshmp") ){ pong_refreshMP() } if( dsClk( "UD_Connected" ) ){ if( PONG_SearchingGames ){ local C = 0 PONG_askList = array() foreach(K,V:number = Rout_DGPCs){ if( V != entity():id() ){ C++ PONG_askList:pushNumber( V ) timer( "pong_askHost"+C,200*C ) } } } } foreach( K,V:number = PONG_askList ){ if( clk( "pong_askHost"+K ) ){ rout_number( "pong_host",V,entity():id() ) if( K == PONG_askList:count() ){ PONG_askList:clear() } } } if( dsClk( "pong_host" ) ){ local C = dsGetNumber() if( PONG_IsHoster ){ rout_number( "pong_AmHoster",C,entity():id() ) } } if( dsClk( "pong_AmHoster" ) ){ if( !PONG_IsHoster && PONG_SearchingGames ){ pong_sv_list_add( dsGetNumber() ) } } if( clk("pong_multiback") ){ pong_mm_close() pong_mpm_close() pong_main_menu() PONG_SearchingGames = 0 PONG_IsHoster = 0 } if( clk("pong_multi") ){ pong_mm_close() pong_mpm() } if( clk("pong_quit") ){ pong_mm_close() ColorScheme = CS_DG_OS timer("desktop",0) } if( clk("pong_move") ){ if( Memory == 119 ){ PONG_Paddle_Direction = -1 } if( Memory == 115 ){ PONG_Paddle_Direction = 1 } if( Memory == 154 ){ pong_gametomenu() } timer( "pong_movepaddle",0 ) } if( clk( "pong_moveCPU" ) ){ if( PONG_BallDir > 0 ){ local Dir = 0 local PY = SM:egpPos( PONG_Paddles[2,number] ):y() local BY = SM:egpPos( PONG_Ball ):y() if( abs(BY-PY) > 10 ){ if( BY > PY ){ Dir = 1 }else{ Dir = -1 } } pong_paddlemove( 2,Dir ) timer( "pong_moveCPU",100 ) } } if( clk( "pong_movepaddle" ) ){ if( PONG_IsHoster || PONG_SinglePlayer ){ pong_paddlemove( 1,PONG_Paddle_Direction ) timer( "pong_movepaddle",100 ) } } if( clk( "pong_moveball" ) ){ pong_moveball() pong_ballcollision() pong_walls() pong_point() if( !PONG_SinglePlayer ){ rout_array( "pong_CL_Ball",PONG_CLIENT,array(SM:egpPos(PONG_Ball)) ) } timer( "pong_moveball", 100 ) } if( clk("pong_release") ){ if( PONG_Paddle_Direction != 0 ){ PONG_Paddle_Direction = 0 stoptimer( "pong_movepaddle" ) } } if( clk( "pong_single" ) ){ pong_mm_close() PONG_SinglePlayer = 1 pong_base() pong_SetUp() } } if( clk( "pg_pong" ) ){ Status = "pong" stopAllTimers() sclear() stopall() ColorScheme = CS_PONG bg_pong() pong_main_menu() } #---------------------------------------- # PONG END #[---------------------------------]# # PROGRAMS END #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # BOOT STRAPPER #[=================================]# if( first() ){ sclear() Boot_Pos = array(vec2(-1,0),vec2(0,1),vec2(1,0),vec2(0,-1)) function screen_booting(){ ColorScheme = CS_Default text( "DGrouse Industries",40,100,80,2,0,0,0 ) line( 90,120,430,120,2,0 ) text( "DGPC2",40,190,150,2,0,0,0 ) text( "Loading Resources",30,130,250,2,0,0,0 ) Boot_Loader = loading_create( 256,300,300,30,6,2,4,0.5 ) Boot_Loading = 1 timer("boot_loading",100) } function boot(){ sclear() screen_booting() } function shutdown(){ stopAllTimers() stopall() sclear() PC_on = 0 } } if( inputClk() ){ if( Power ){ if( PC_on ){ PC_shutting = 1 ShutTextInd = text( "Shutting Down",65,50,10,3,0,0,0 ) timer("shutting",3000) } else{ PC_on = 1 boot() } } if( !Power ){ if( PC_shutting ){ PC_shutting = 0 Screen:egpRemove(ShutTextInd) stoptimer("shutting") } } } if( clk("boot_loading") ){ Boot_count = Boot_count+5 loading_update( Boot_Loader,Boot_count/100,2,vec() ) if( Boot_count >= 100 ){ Boot_Loading = 0 Boot_count = 0 ColorScheme = CS_DG_OS loading_remove( Boot_Loader ) #timer( "pg_pong", 100 ) login() } if( Boot_Loading ){ timer("boot_loading",100) } } if( clk("boot_login") ){ sclear() S_booting = 0 Boot_count = 0 } if( clk("shutting") ){ shutdown() } if( clk( "sm_shutdown" ) ){ shutdown() } #[---------------------------------]# # BOOT STRAPPER END #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx