Page 1 of 1

OpenWindowScreen:

Posted: Sat Oct 29, 2022 1:28 am
by samxxx
;.............................................................................................................................
OpenWindow(1,200,100,500,500,"Test",#PB_Window_SystemMenu)
;
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
;...........................................................................................................................
;TWO Questions:
; 1) How can I make this OpenWindowScreen show up in color like Black or Red:
;2) What is the best way to get to the help-file?

Re: OpenWindowScreen:

Posted: Sat Oct 29, 2022 1:35 am
by idle

Code: Select all

;Putins broken clock, any key to activate, esc to end 
;fair use claimed for the intro to the Final Countdown by Europe 
EnableExplicit 

InitSprite()
InitKeyboard() 
InitMouse() 
InitSound() 
UseOGGSoundDecoder()

Global font
Global event,ct,sc,bput=0
Global width, height 
Global snd,spath.s 

Procedure DisplayMessageCenter(window,msg.s,color=255,scale.f=1.00)
  
  Protected spriteNumber,tempImage,fontsTextWidth,fontsTextHeight,cx,cy
  
  tempImage = CreateImage(#PB_Any,1,1)    ;if you need to get the size of a font in pixels         
  
  If tempImage
    If StartDrawing(ImageOutput(tempImage)) ;draw to the temp image 
      DrawingFont(FontID(font))             ;with the selected font  
      fontsTextWidth = TextWidth(msg)       ;get the width and height in pixles     
      fontsTextHeight = TextHeight(msg)  
      StopDrawing()  
      spriteNumber = CreateSprite(#PB_Any,fontsTextWidth,fontsTextHeight) ;create the sprite of required size 
      If spriteNumber 
        If StartDrawing(SpriteOutput(spriteNumber))   ;now you can draw the text to the sprite 
          DrawingFont(FontID(font)) 
          DrawText(0,0,msg,color)
          StopDrawing()
          TransparentSpriteColor(spriteNumber,0)
          cx= (WindowWidth(window) - (fontsTextWidth*scale)) / 2   
          cy = (WindowHeight(window)- (fontsTextHeight*scale)) / 2        
          ZoomSprite(spriteNumber,fontsTextWidth*scale,fontsTextHeight*scale)  
          DisplayTransparentSprite(spriteNumber,cx,cy)
        EndIf   
        FreeSprite(spriteNumber)
      EndIf  
    EndIf  
    FreeImage(tempImage)      
  EndIf 
  
EndProcedure 

spath = GetTemporaryDirectory() + "countdown.ogg" 
If FileSize(spath) > 0 
  LoadSound(0,spath) 
ElseIf ReceiveHTTPFile("https://dnscope.io/idlefiles/countdown.ogg",spath) 
  LoadSound(0,spath) 
EndIf   
  
ExamineDesktops() 
width = DesktopWidth(0)
height = DesktopHeight(0) 

font = LoadFont(#PB_Any,"arial",height/8,#PB_Font_HighQuality)

OpenWindow(0,0,0,width,height,"Putin de merde clock",#PB_Window_ScreenCentered | #PB_Window_BorderLess) 
OpenWindowedScreen(WindowID(0),0,0,width,height) 

Repeat 
  Repeat 
    event=WindowEvent()
    If event=#PB_Event_CloseWindow
      End
    EndIf
  Until event=0
  
  ExamineKeyboard() 
  ExamineMouse() 
    
  If bput > 0   
    ClearScreen((ct%64)*2)
    DisplayMessageCenter(0,FormatDate("%hh:%ii:%ss", Date()-ct),RGB(0,192,0),0.025*sc)
    ct+1  
  Else 
    ClearScreen(0)
    DisplayMessageCenter(0,FormatDate("%hh:%ii:%ss", Date()),RGB(0,192,0))
    ct=0
  EndIf 
   
  sc+1 
  sc%60
  FlipBuffers()
  
  If KeyboardInkey()
    bput ! 1
    If bput 
      If IsSound(0) 
        PlaySound(0) 
      EndIf 
    ElseIf IsSound(0)   
      StopSound(0) 
    EndIf   
    
  EndIf  
  
Until KeyboardPushed(#PB_Key_Escape)     



Re: OpenWindowScreen:

Posted: Sat Oct 29, 2022 2:26 am
by Demivec
samxxx wrote: Sat Oct 29, 2022 1:28 am ;.............................................................................................................................
OpenWindow(1,200,100,500,500,"Test",#PB_Window_SystemMenu)
;
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
;...........................................................................................................................
;TWO Questions:
; 1) How can I make this OpenWindowScreen show up in color like Black or Red:
;2) What is the best way to get to the help-file?
Question #1: Use ClearScreen(color) before drawing each screen of images.

Code: Select all

InitSprite()
InitKeyboard()
InitMouse()

OpenWindow(1,200,100,500,500,"Test",#PB_Window_SystemMenu)
;
OpenWindowedScreen(WindowID(1), 0, 0, 500, 500)

Repeat
  Repeat
    event = WindowEvent()
    If event = #PB_Event_CloseWindow
      End
    EndIf
  Until event = 0
  
  ClearScreen(RGB(0, 0, 0)) ;for black or RGB(255, 0, 0) for red
  
  FlipBuffers()
  
ForEver
Question #2: Use F1 key in the IDE or Select 'Help' on the Help Menu.

Re: OpenWindowScreen:

Posted: Sat Oct 29, 2022 3:40 am
by Olli
:shock:

:D

@idle

I don't know who the joker is who played a joke on you in the translation of your comment in the first line of source code, but the translation is not commercial... This could be translated by this << 5h1tty wh0r3 clock >>... :o

Re: OpenWindowScreen:

Posted: Sat Oct 29, 2022 4:49 am
by idle
Olli wrote: Sat Oct 29, 2022 3:40 am :shock:

:D

@idle

I don't know who the joker is who played a joke on you in the translation of your comment in the first line of source code, but the translation is not commercial... This could be translated by this << 5h1tty wh0r3 clock >>... :o
I would translate it as Putin's shitty clock but it implies the rude phrase you alluded to

Re: OpenWindowScreen:

Posted: Sat Oct 29, 2022 11:18 am
by Olli
idle wrote: Sat Oct 29, 2022 4:49 am
Olli wrote: Sat Oct 29, 2022 3:40 am :shock:

:D

@idle

I don't know who the joker is who played a joke on you in the translation of your comment in the first line of source code, but the translation is not commercial... This could be translated by this << 5h1tty wh0r3 clock >>... :o
I would translate it as Putin's shitty clock but it implies the rude phrase you alluded to
le/la/les something de merde à somebody
I give you all the rest on private message, and I will read the code when I ll have time to read it.