Horloge / reveil [picwin]

Contenu du snippet

Voici ma première source en picwin, c'est une horloge qui fait également réveil :p Vous pouvez personnaliser les couleurs et le format de l'heure a partir du click droit :)

Comme je l'ai deja dit, c'est ma première picwin alors n'hésitez pas pour les critiques =]

Source / Exemple :


alias horloge {
  if ($window(@Time)) { window -c @Time }
  window -pdCBdk0 +Let @Time 0 0 215 95
  horloge_init
}
alias -l horloge_drawchiffre {
  if ($2 == 0) { ho_dl $calc(10 + $1) 10 $calc(45 + $1) 10 | ho_dl $calc(45 + $1) 10 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 60 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 10 $calc(10 + $1) 60 }
  elseif ($2 == 1) { ho_dl $calc(45 + $1) 10 $calc(45 + $1) 60 }
  elseif ($2 == 2) { ho_dl $calc(10 + $1) 10 $calc(45 + $1) 10 | ho_dl $calc(45 + $1) 10 $calc(45 + $1) 35 | ho_dl 5 $calc(10 + $1) 35 $calc(45 + $1) 35 | ho_dl $calc(10 + $1) 35 $calc(10 + $1) 60 | ho_dl $calc(10 + $1) 60 $calc(45 + $1) 60 }
  elseif ($2 == 3) { ho_dl $calc(10 + $1) 10 $calc(45 + $1) 10 | ho_dl $calc(45 + $1) 10 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 60 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 35 $calc(45 + $1) 35 }
  elseif ($2 == 4) { ho_dl $calc(10 + $1) 10 $calc(10 + $1) 35 | ho_dl $calc(45 + $1) 10 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 35 $calc(45 + $1) 35 }
  elseif ($2 == 5) { ho_dl $calc(10 + $1) 10 $calc(45 + $1) 10 | ho_dl $calc(10 + $1) 10 $calc(10 + $1) 35 | ho_dl $calc(10 + $1) 35 $calc(45 + $1) 35 | ho_dl $calc(45 + $1) 35 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 60 $calc(45 + $1) 60 }
  elseif ($2 == 6) { ho_dl $calc(10 + $1) 10 $calc(45 + $1) 10 | ho_dl $calc(10 + $1) 10 $calc(10 + $1) 60 | ho_dl $calc(10 + $1) 35 $calc(45 + $1) 35 | ho_dl $calc(45 + $1) 35 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 60 $calc(45 + $1) 60 }
  elseif ($2 == 7) { ho_dl $calc(45 + $1) 10 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 10 $calc(45 + $1) 10 }
  elseif ($2 == 8) { ho_dl $calc(10 + $1) 10 $calc(45 + $1) 10 | ho_dl $calc(45 + $1) 10 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 60 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 10 $calc(10 + $1) 60 | ho_dl $calc(10 + $1) 35 $calc(45 + $1) 35 }
  elseif ($2 == 9) { ho_dl $calc(10 + $1) 10 $calc(45 + $1) 10 | ho_dl $calc(45 + $1) 10 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 60 $calc(45 + $1) 60 | ho_dl $calc(10 + $1) 10 $calc(10 + $1) 35 | ho_dl $calc(10 + $1) 35 $calc(45 + $1) 35 }
}
alias -l horloge_delchiffre { drawrect -f @Time $hget(horloge,bgc) 0 $replacex($1,1,0,2,48,3,108,4,154) 0 50 $window(@Time).h }
alias horloge_afficheur {
  var %a $len($time($hget(horloge,fmt)))
  while (%a) {
    if ($mid($time,%a,1) != $chr(58)) { horloge_delchiffre $iif(%a > 3,$calc(%a - 1),%a) | horloge_drawchiffre $replacex(%a,1,0,2,45,4,105,5,150) $mid($time($hget(horloge,fmt)),%a,1) }
    dec %a
  }
  if ($time($hget(horloge,fmt)) == $hget(horloge,reveil)) { 
    if ($active == @Time) {
      var %a $chan(0)
      while (%a) { echo $chan(%a) 12[4REVEIL12]7 Il est $time($hget(horloge,fmt)) ! 12[4REVEIL12] | dec %a }
    }
    echo -a 12[4REVEIL12]7 Il est $time($hget(horloge,fmt)) ! 12[4REVEIL12]
  }
}
alias -l horloge_init {
  drawrect -f @Time $hget(horloge,bgc) 0 0 0 $window(@Time).w $window(@Time).h
  drawdot @Time $hget(horloge,pts) 5 105 30
  drawdot @Time $hget(horloge,pts) 5 105 45
  horloge_afficheur
  .timerhorloge 0 60 horloge_afficheur
}
alias -l ho_dl { drawline @Time $hget(horloge,ctext) 5 $1- }
menu @Time {
  Couleur
  .Texte:var %a $$input(Couleur du texte ? ( actuelle : $hget(horloge,ctext) ),e,Couleur du texte (chiffrage de 0 à 15)) | if (%a isnum) && (. !isin %a) && (%a >= 0 && %a <= 15) { hadd horloge ctext %a | hsave horloge $scriptdirhorloge | horloge_init } | else { echo -a [Horloge] : Couleur invalide }
  .Fond:var %a $$input(Couleur du fond ? ( actuelle : $hget(horloge,bgc) ),e,Couleur du fond (chiffrage de 0 à 15)) | if (%a isnum) && (. !isin %a) && (%a >= 0 && %a <= 15) { hadd horloge bgc %a | hsave horloge $scriptdirhorloge | horloge_init } | else { echo -a [Horloge] : Couleur invalide }
  .Deux Points:var %a $$input(Couleur des 2 points ? ( actuelle : $hget(horloge,pts) ),e,Couleur des 2 points (chiffrage de 0 à 15)) | if (%a isnum) && (. !isin %a) && (%a >= 0 && %a <= 15) { hadd horloge pts %a | hsave horloge $scriptdirhorloge | horloge_init } | else { echo -a [Horloge] : Couleur invalide }
  Format
  .Passer en mode $iif($hget(horloge,fmt) === $+(hh,$chr(58),nn),24h,12h) :hadd -m horloge fmt $replacexcs($hget(horloge,fmt),HH,hh,hh,HH) | hsave horloge $scriptdirhorloge | horloge_init
  Réveil
  .Définir un réveil:hadd -m horloge reveil $$input(Heure du réveil ? (sous le format Heure:minutes),e,Heure du réveil)
}
menu menubar,status,channel {
  -
  Horloge:horloge
}

on *:LOAD:{
  echo -a Horloge chargée !
  hadd -m horloge ctext 9 | hadd -m horloge bgc 2 | hadd -m horloge pts 4 | hadd -m horloge fmt HH:nn
  hsave horloge $scriptdirhorloge
  horloge
  .timer 1 2 .enable #horloge_start
}
#horloge_start off
on *:START:{
  hmake horloge
  $iif($exists($scriptdirhorloge),hload,hsave) horloge $scriptdirhorloge
}
#horloge_start end
on *:CLOSE:@Time:{ .timerhorloge off }

Conclusion :


Pour le lancer tapez /horloge ou accédez y depuis les menus Channel, Status, et MenuBar. L'addon se lancera dès son chargement ;)

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.