Konsolen Gui in BB+

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

TheMatrix

Betreff: Konsolen Gui in BB+

BeitragMi, Okt 25, 2006 20:58
Antworten mit Zitat
Benutzer-Profile anzeigen
Moinsen,

da ich momentan noch an meinem Raumschiff Shooter sitze, hatte ich die Idee mal eine vernünftige Konsole zu proggen. Und ich muss sagen, ich bin mit meinem Ergebnis sehr zufrieden Laughing

Hier mal ein paar Infos zu den wichtigsten Funktionen:

create_console(x,y)
- Diese Funktion erstellt die Konsole mit den angegebenen Größen

set_console(x,y)
- Sie positioniert die Konsole an den angegebenen Koordinaten

draw_console$()
- Zeichnet die Konsole. Diese Funktion gibt zusätzlich noch den Input des Users zurück, nachdem mit Enter bestätigt wurde.

writelog(string$)
- Schreibt einen Text in die Konsole
Parameter die mit in dem String übertragen werden können:
%n = Erzeugt einen Zeilenumbruch im String
%offen = Lässt den String für weitere Einträge ins Log offen

console_visible = (0/1)
- Wenn die Variabel auf 1 gesetzt ist, wird die Konsole angezeigt. Bei 0 wird sie versteckt.

save_log(pfad$)
- Der komplette Log gespeichert. Für pfad$ können noch Überordner angegeben werden.

Die Konsole kann zusätlich noch durch anklicken auf den Titelbalken verschoben werden.

Der
Code: [AUSKLAPPEN]

Graphics 640,480,16,2
SetBuffer BackBuffer()

Const key_back = 14, key_return = 28
Const key_up = 200, key_down = 208, key_right = 205, key_left = 203
Const key_pos = 199, key_entf = 211, key_end = 207, key_tab = 15, key_f1 = 59
Const key_umschalt = 42

Gosub Initial_Input : Dim input_ausnahme$(255) : Global input_ausnahmen
setinputcolor(0,0,0) : setmarkcolor(170,170,170)

Global console_img,console_x, console_y, console_x2, console_y2, console_click, message_anzahl, message_zeiger, message_zeiger_e, temp_mx, temp_my
Global sli1_size#, sli1_max, up1, down1, sli1_items, sli1_step#, sli1_ende, sli1, output_y, input_image, input_image_x, ende_button
Global console_visible = 1, font
Global message_weiter

Dim console_message$(1000)
Dim oldmessage$(1000)
Type gadget
 Field x
 Field y
 Field sizex
 Field sizey
 Field unpressed
 Field pressed
 Field caption$
 Field hide
 Field group
 Field art
 Field style
 Field data1
 Field data2
 Field data3
End Type
Global button.gadget
Global mdown, event_art, event_source

create_console(500,400)
setconsole(100,50)

For a=1 To 50
 Color 255,0,0 : writelog("Eintrag "+Str$(a))
Next

x=100
While Not KeyHit(1)
Cls
Color 255,0,0
If console_visible = 0 Then Text 0,0,"Bitte 'Enter' drücken, damit Konsole wieder sichtbar"
Text 0,15,"Mit F1 kann das Log gespeichert werden"
If KeyDown(key_return) Then console_visible = 1
If KeyDown(key_f1) Then save_log
ausgabe$ = draw_console$()


Delay 5
Flip
Wend

Function setconsole(x,y)
 ox = console_x : oy = console_y

 movegadgetx up1,((ox-x))*-1
 movegadgety up1,(oy-y)*-1

 movegadgetx down1,(ox-x)*-1
 movegadgety down1,(oy-y)*-1

 movegadgetx sli1,(ox-x)*-1
 movegadgety sli1,(oy-y)*-1

 movegadgetx ende_button,(ox-x)*-1
 movegadgety ende_button,(oy-y)*-1

 console_x = x : console_y = y


End Function

Function create_console(x,y)
If x<110 Then x=110
If y<110 Then y=100
temp_x = console_x
temp_y = console_y
; Slider




    If up1>0
     findgadget up1   : FreeImage up1 : FreeImage button\pressed : Delete button
    findgadget down1 : FreeImage down1 : FreeImage button\pressed : Delete button
     findgadget sli1  : FreeImage sli1 : FreeImage button\pressed : Delete button   
     findgadget ende_button : FreeImage ende_button : FreeImage button\pressed : Delete button
    Else
    sli1_max=1
   sli1_items=1
    End If

   sli1_x=temp_x+x-21 : sli1_y=temp_y+21
    sli1_size#=y-42
   sli1_step#     = (sli1_size#-42)/sli1_max
   sli1_ende    = sli1_max


   up1          = create_button("gr:up",sli1_x,sli1_y,20,20,0)
   down1        = create_button("gr:down",sli1_x,sli1_y+(sli1_size#-21),20,20,0)
   sli1         = create_button("-",sli1_x,(sli1_y+20),20,sli1_step#*sli1_items,0)
    ; End-Button
    ende_button = create_button("-->",temp_x+x-58,temp_y+2,37,16,0)

   

 If console_img Then console_img=0
 console_x2 = x: console_y2=y
 ouput_y = y-42
 If console_img = 0
   console_img = CreateImage(x,y) : SetBuffer ImageBuffer(console_img)
   setfontsize 10,"Comic Sans MS"
   Color 50,50,50       : Rect 0,0,x,y
   
   ; Kopf
   rot = 175 : gruen = 205 : blau = 235
   rot_ende = 50 : gruen_ende = 80 : blau_ende = 110

    size_y# = 20
    rot_step#   = (rot-rot_ende)/size_y#
    gruen_Step# = (gruen-gruen_ende)/size_y#
    blau_Step#  = (blau-blau_ende)/size_y#

   For a=1 To size_y#
   
     Color rot-rot_step#*a, gruen-gruen_step#*a, blau-blau_step#*a
    Line 1,a,x-2,a

   Next
    setfontsize 16,"Comic Sans MS"
   Color 220,220,220 : Text 10,2,"Konsole"

   ; Ausgabe Feld
   rot = 255 : gruen = 255 : blau = 255
   rot_ende = 170 : gruen_ende = 170 : blau_ende = 170

    size_y# = y-42
    rot_step#   = (rot-rot_ende)/size_y#
    gruen_Step# = (gruen-gruen_ende)/size_y#
    blau_Step#  = (blau-blau_ende)/size_y#

   For a=1 To size_y#
   
     Color rot-rot_step#*a, gruen-gruen_step#*a, blau-blau_step#*a
    Line 1,20+a,x-2,20+a

   Next


    ; Input Feld
   rot = 150 : gruen = 150 : blau = 150
   rot_ende = 255 : gruen_ende = 255 : blau_ende = 255

    size_y# = y-(y-20)
    rot_step#   = (rot-rot_ende)/size_y#
    gruen_Step# = (gruen-gruen_ende)/size_y#
    blau_Step#  = (blau-blau_ende)/size_y#


   For a=0 To size_y#
   
     Color rot-rot_step#*a, gruen-gruen_step#*a, blau-blau_step#*a
    Line 1,(y-22)+a,x-2,(y-22)+a

   Next

   Color 50,50,50 : Line 0,y-22,x,y-22

   ; Slider Hintergrund
   rot = 90 : gruen = 120 : blau = 150
   rot_ende = 0 : gruen_ende = 30 : blau_ende = 60

    size_x# = 19
    rot_step#   = (rot-rot_ende)/size_y#
    gruen_Step# = (gruen-gruen_ende)/size_y#
    blau_Step#  = (blau-blau_ende)/size_y#

   For a=0 To size_x#
   
     Color rot-rot_step#*a, gruen-gruen_step#*a, blau-blau_step#*a
    Line (x-21)+a,21,(x-21)+a,y-22

   Next

    ; Glätten der Konsole
   Color 0,0,0
    For w=180 To 270
     ; Kante links
     x2 = -9+Sin(w)*10
    y2 = -9+Cos(w)*10
     Color 0,0,0   : Rect x2,y2,20,20
    Color 50,50,50 : Plot x2+19,y2+19

    ; Kante rechts
    x2 = (x-11)+Sin(w-90)*10
    y2 = -9+Cos(w-90)*10
    Color 0,0,0   : Rect x2,y2,20,20
    Color 50,50,50 : Plot x2,y2+19

 
    ; Kante links unten   
     x2 = -9+Sin(w+90)*10
    y2 = (y-11)+Cos(w+90)*10
    Color 0,0,0   : Rect x2,y2,20,20
    Color 50,50,50 : Plot x2+19,y2


    ; Kante rechts unten   
    x2 = (x-11)+Sin(w+180)*10
    y2 = (y-11)+Cos(w+180)*10
    Color 0,0,0   : Rect x2,y2,20,20
    Color 50,50,50 : Plot x2,y2




    Next


   SetBuffer BackBuffer()
 End If

End Function

Function draw_console$()
If console_visible=1
 x  = console_x  : y  = console_y

DrawImage console_img,console_x,console_y
 
 draw_gadgets

 x2 = console_x2 : y2 = sli1_size#

 
i = message_zeiger : If i = 0 Then i=1

 If y2/15<message_zeiger_e-i Then message_zeiger_e=i+(y2/15)
 
 For a=i To message_zeiger_e
   st$ = console_message$(a)
   Text x+3,y+22,st$ : y=y+15
 Next
 message_zeiger = i

 x  = console_x  : y  = console_y
 x2 = console_x2 : y2 = console_y2
 mx = MouseX() : my = MouseY()
 If mx>=x And mx<x+(x2-65) And my>=y And my<y+22
  If MouseDown(1) And mdown=0 And event_source = 0 Then mdown=3 : temp_mx = mx-x : temp_my = my-y
 End If

 If mdown=3 Then setconsole(mx-temp_mx,my-temp_my)
 If MouseDown(1)=0 Then mdown=0


; Neu skalieren der Konsole
 
; If mx>=x+x2-10 And mx<x+x2 And my>=y+y2-10 And my<y+y2
;  If MouseDown(1) And mdown=0 Then mdown=4
; End If
 
; If mx>=x And mx<x+10 And my>=y+y2-10 And my<y+y2
;  If MouseDown(1) And mdown=0 Then mdown=5
; End If

 

 If mdown>3
  If mdown=4 Then create_console x2+(mx-(x+x2)),y2+(my-(y+y2))

  If mdown=5
   difx = mx-x : dify = (my-(y+y2))
   create_console x2-difx,y2+dify

   If x2-difx<=110 Then difx=0
   setconsole console_x+difx,console_y
  End If

  anz = message_anzahl
  message_anzahl = 0
  message_zeiger = 0
  message_zeiger_e = 0

;  For a=1 To anz
;   oldmessage$(a)=console_message$(a)
;  Next

; For a=1 To anz
;   Writelog(oldmessage$(a))
;  Next

  refresh_slider : event_source = sli1 : event_art = $400
 End If
 If mdown=4 And MouseDown(1)=0 Then mdown=0


 es = event_source
 ev = event_art
 
  mz = MouseZSpeed()
 If ev=$401 Or mz<>0

  If es = up1 Or mz>0
   If message_zeiger>1
     movegadgety sli1,sli1_step#*-1 : message_zeiger=message_zeiger-1 : message_zeiger_e = message_zeiger_e-1
    End If
  End If

  If es=down1 Or mz<0
   If message_zeiger_e<message_anzahl
     movegadgety sli1,sli1_step# : message_zeiger=message_zeiger+1 : message_zeiger_e = message_zeiger_e+1
    End If
  End If

  If es = ende_button Then console_visible=0
 End If

 If ev=$400
  Select es
   Case sli1
   findgadget sli1 : sizey = button\sizey
   newy = my-sizey/2

   findgadget up1   : y4 = button\y : If newy<y4+21 Then newy = y4+21
    findgadget down1 : y4 = button\y : If newy+sizey>y4 Then newy = y4-sizey

    message_zeiger   = ((newy-console_y)-42)/sli1_step#

    message_zeiger_e = message_zeiger+(y2-42)/15
    positiongadgety sli1,newy
   
  End Select
 End If


 ; Input Handler
 Color 0,0,0
 Text console_x+8,console_y+console_y2-18,">" : st$ = Input2$("",console_x+17,console_y+console_y2-18,255,console_x2)
 If KeyDown(key_return) And st$<>"" Then st2$ = clearinput$() : writelog(">"+st2$)
 End If

  Return st2$
End Function

Function writelog(st$)
 x2 = console_x2-30
 y2 = sli1_size#-15

 ma = message_anzahl

 If message_weiter=1
  st$ = console_message$(ma)+st$ : message_weiter=0
  ma = ma-1
 End If

  For a=1 To Len(st$)
   z$ = Mid$(st$,a,1)
   If z$ ="%"
    If Mid$(st$,a+1,1)="n" Then eintrag = 1 : f = 1
    If Mid$(st$,a+1,5)="offen" Then message_weiter=1 : f = 5 : eintrag=1
    If f>0 Then a=a+f : ok=0
   Else
    ok=1
   End If
   If ok=1
      st2$ = st2$ + z$ : If StringWidth(st2$)>=x2-4 Or a >= Len(St$) Then eintrag=1
   End If
   If eintrag Then ma = ma + 1 : console_message$(ma)=st2$ : st2$="" : eintrag=0

  Next
  mz  = message_zeiger
  mze = message_zeiger_e
 
  mz = ma-(y2/15)
  If mz<1 Then mz = 1

 mze = mz + (y2/15)

 If mze>ma Then mze =ma

 message_anzahl = ma
 message_zeiger = mz
 message_zeiger_e = mze

refresh_slider()

End Function

Function create_button(st$,x,y,x2,y2,group=0,art=0, style=0)

 button = New gadget
 button\x = x
 button\y = y
 button\sizex = x2
 button\sizey = y2
 button\caption$ = st$
 button\group = group
 button\art = art
 button\style = style

 If art=0
; Draw Routine - Unpressed
 button\unpressed = CreateImage(x2,y2) : SetBuffer ImageBuffer(button\unpressed)
 Color 80,80,80 : Rect 0,0,x2,y2

   rot = 175 : gruen = 205 : blau = 235
   rot_ende = 50 : gruen_ende = 80 : blau_ende = 110

    size_x# = x2-2
    rot_step#   = (rot-rot_ende)/size_x#
    gruen_Step# = (gruen-gruen_ende)/size_x#
    blau_Step#  = (blau-blau_ende)/size_x#

   For a=1 To size_x#
   
     Color rot-rot_step#*a, gruen-gruen_step#*a, blau-blau_step#*a
    Line a,1,a,y2-2

   Next

 If st$="gr:up" Then draw_pfeil_up 0,(y2/2)-5: button\caption$="" : n=1
 If st$="gr:down" Then draw_pfeil_down 0,(y2/2)-1: button\caption$="" : n=2
 setfontsize 13,"Arial"
 If n=0 Then Color 0,0,0 : Text x2/2,(y2/2)-(FontHeight()/2),st$,1

; Pressed
 button\pressed = CreateImage(x2,y2) : SetBuffer ImageBuffer(button\pressed)
 Color 40,40,40 : Rect 0,0,x2,y2

   rot = 120 : gruen = 150 : blau = 180
   rot_ende = 0 : gruen_ende = 30 : blau_ende = 60

    size_x# = x2-2
    rot_step#   = (rot-rot_ende)/size_x#
    gruen_Step# = (gruen-gruen_ende)/size_x#
    blau_Step#  = (blau-blau_ende)/size_x#

   For a=1 To size_x#
   
     Color rot-rot_step#*a, gruen-gruen_step#*a, blau-blau_step#*a
    Line a,1,a,y2-2

   Next

 If n=1 Then draw_pfeil_up 0,(y2/2)-5: button\caption$="" : st$=""
 If n=2 Then draw_pfeil_down 0,(y2/2)-1: button\caption$="" : st$=""
 setfontsize 15,"Arial"

 Color 0,0,0 : Text 1+x2/2,1+(y2/2)-(FontHeight()/2),st$,1
 End If

 SetBuffer BackBuffer()
 Return button\unpressed
End Function

Function draw_gadgets(gr=0)

 mx = MouseX() : my = MouseY()

 If event_source>0 And mdown=0 Then event_source=0 : event_art=0
 For button=Each gadget
  If button\hide=0 And gr=button\group
  x = button\x : y = button\y : x2 = button\sizex : y2 = button\sizey

   If mx>=x And mx<x+x2 And my>=y And my<y+y2

    If event_source=0 And MouseDown(1) And mdown=0 Then event_source = button\unpressed : mdown=1

    If event_source=button\unpressed
     event_art = $400 : clicked=1
     If MouseDown(1)=0 Then event_art=$401 : event_source = button\unpressed : mdown=0
    End If

  End If

  If clicked=1 Then img = button\pressed : clicked=2 Else img = button\unpressed
  DrawBlock img,x,y
  End If
 Next
 If MouseDown(1)=0 And mdown=1 Then mdown=0

End Function

Function hide_gadget(gadget,s=1)
 findgadget gadget; : button\hide = s
End Function

Function show_gadget(gadget)
 hide_gadget(gadget,0)
End Function

Function draw_pfeil_down(x,y)
Color 0,0,0
s = 2
sx = 20 : sxm=sx/2
b = 5
sy = 20

For z=y To y+sy
s=s+1 : b=b-2
For a=x To x+sx
 If a>s And a<sx-s And (a<sxm-b/2 Or a>sxm+b/2) Then Plot a,z
Next
Next
End Function

Function draw_pfeil_up(x,y)
Color 0,0,0
y=y-14
s = 2
sx = 20 : sxm=sx/2
b = 5
sy = 20
For z=y+sy To y Step-1
s=s+1 : b=b-2
For a=x To x+sx
 If a>s And a<sx-s And (a<sxm-b/2 Or a>sxm+b/2) Then Plot a,z
Next
Next
End Function

Function movegadgety(gadget,y)
 For button=Each gadget
  If button\unpressed = gadget Then button\y=button\y+y : Exit
 Next
End Function

Function positiongadgetY(gadget,y)
 findgadget gadget : button\y = y
End Function

Function movegadgetx(gadget,x)
 For button=Each gadget
  If button\unpressed = gadget Then button\x=button\x+x : Exit
 Next
End Function

Function setgadgetcaption(gadget,st$)
 findgadget gadget : button\caption$ = st$
 refreshgadget gadget
End Function

Function findgadget(gadget)
 For button=Each gadget
  If button\unpressed = gadget Then Return gadget
 Next
End Function

Function refreshgadget(gadget)
 findgadget gadget
 x2 = button\sizex : y2 = button\sizey : st$ = button\caption$
 If button\art=0
  FreeImage button\unpressed
  n = CreateImage(x2,y2) : SetBuffer ImageBuffer(n)

    rot = 175 : gruen = 205 : blau = 235
   rot_ende = 50 : gruen_ende = 80 : blau_ende = 110

    size_x# = x2-2
    rot_step#   = (rot-rot_ende)/size_x#
    gruen_Step# = (gruen-gruen_ende)/size_x#
    blau_Step#  = (blau-blau_ende)/size_x#

   For a=1 To size_x#
   
     Color rot-rot_step#*a, gruen-gruen_step#*a, blau-blau_step#*a
    Line a,1,a,y2-2

   Next


  Color 0,0,0 : Text x2/2,(y2/2)-(FontHeight()/2),st$,1
  button\unpressed = n

  FreeImage button\pressed
  n = CreateImage(x2,y2) : SetBuffer ImageBuffer(n)

   rot = 120 : gruen = 150 : blau = 180
   rot_ende = 0 : gruen_ende = 30 : blau_ende = 60

    size_x# = x2-2
    rot_step#   = (rot-rot_ende)/size_x#
    gruen_Step# = (gruen-gruen_ende)/size_x#
    blau_Step#  = (blau-blau_ende)/size_x#

   For a=1 To size_x#
   
     Color rot-rot_step#*a, gruen-gruen_step#*a, blau-blau_step#*a
    Line a,1,a,y2-2

   Next



  Color 0,0,0 : Text 1+x2/2,1+(y2/2)-(FontHeight()/2),st$,1
  button\pressed = n
 
 End If

 SetBuffer BackBuffer()
End Function

Function setfontsize(s, st$ ="Comic Sans MS")
  FreeFont font
  font = LoadFont(st$,s,s) : SetFont font
End Function

Function input2$(zu$,tx,ty, max_zeichen=255, Input_size_x = 0)
; Ein Image, damit man mehr schreiben kann als vorgesehen
If input_image=0 And Input_size_x>0
 input_image = CreateImage(2300,FontHeight()+1) : MaskImage input_image,255,0,255
 input_image_x = 0
End If

If zu$<>"" And input_ini=0 Then input_ini=1 : input_text$=zu$ : input_cursor=Len(zu$) : mark=1 : start_mark=0 : end_mark=Len(zu$)
st$ = input_text$ : cur = input_cursor
If mark=1
 dif=cur-start_mark
 end_mark=start_mark+dif
 If start_mark<end_mark Then start = start_mark : ende = end_mark Else start=end_mark : ende = start_mark
 If dif<0 Then dif=dif*-1
 If start>0
  x2 = StringWidth(Left$(st$,start))
  x3 = StringWidth(Mid$(st$,start,dif))
 Else
  x2 = 0
  x3 = StringWidth(Mid$(st$,1,dif))
 End If

 If Input_image>0
  SetBuffer ImageBuffer(Input_image) : ClsColor 255,0,255 : Cls
    Color mark_color_r,mark_color_g,mark_color_b
    If dif<>0 Then Rect x2,0,x3,FontHeight()
  SetBuffer BackBuffer()
 Else
    Color mark_color_r,mark_color_g,mark_color_b
    If dif<>0 Then Rect tx+x2,ty,x3,FontHeight()
 End If
 
End If

k = GetKey() : a$ = Chr$(k) : s = Len(st$)
ok=1
For i=1 To input_ausnahmen
 ok=0 : aa$ = input_ausnahme$(i)
 If Asc(aa$)=k Then ok=1 : Exit

Next


If k>=32 And k<255 And Len(st$)<max_zeichen And ok=1
 If cur>0 Then l$ = Mid$(st$,cur,1)
 key_timer_input = MilliSecs()+80
 If mark=1 And dif<>0 Then st$=Left$(st$,start)+Right$(st$,Len(st$)-ende) : cur=start : mark=0
 If mark=1 And dif=0 Then mark=0
 If Len(st$)<max_zeichen
  If s>0 Then st$=Left$(st$,cur)+a$+Right$(st$,Len(st$)-cur) Else st$=a
 End If
 cur = cur+1
 key=1

End If

If MilliSecs()>=key_timer_input
key_timer_input=MilliSecs()+80
    If KeyDown(key_back)
     If ((mark=1 And dif=0) Or mark=0) And cur>0 Then st$ = Left$(st$,cur-1)+Right$(st$,Len(st$)-cur) : cur = cur-1 : mark=0
     If mark=1 And dif<>0 Then st$ = Left$(st$,start)+Right$(st$,Len(st$)-ende) : cur = start : mark=0
    cursor=0 : cursor_timer=0

    End If
   If cur>0
    If KeyDown(key_left) Then cur=cur-1 : key=1 :  cursor=0 : cursor_timer=0

   End If

    If KeyDown(key_entf)
     If ((mark=1 And dif=0) Or mark=0) And s>0 And cur<s And mark=0 Then st$ = Left$(st$,cur)+Right$(st$,(Len(st$)-cur)-1) : mark=0 : key=1
     If mark=1 And dif<>0 Then mark=0 : st$=Left$(st$,start)+Right$(st$,Len(st$)-ende) : cur = start
    End If

   If cur<Len(st$) Then If KeyDown(key_right) Then cur=cur+1 : key=1
    If KeyDown(key_pos) Then cur=0 : key=1
    If KeyDown(key_end) Then cur=Len(st$) : key=1

    If KeyDown(key_umschalt)
     If mark=0 Then mark=1 : start_mark=cur
     umschalt=1
    Else
     If key=1 Then mark=0 : key=0
    End If : key=0
    If mark=0 Then start=0 : ende=0 : dif=0

End If


lx = StringWidth(Left$(st$,cur))
If MilliSecs()>=cursor_timer
 cursor_timer = MilliSecs()+250
 If cursor=1 Then cursor=0 Else cursor=1
End If

Color input_color_r, input_color_g, input_color_b
If cursor>=1 And Input_image=0 Then Line tx+lx,ty,tx+lx,ty+FontHeight()

input_text$=st$ : input_cursor=cur

Input_size_x = input_size_x-25
If lx-Input_image_x>=Input_size_x Then input_image_x = lx-Input_size_x
If lx-input_image_x<0 Then Input_image_x = lx+(lx-input_image_x)

If Input_image_x<0 Then Input_image_x=0
If Input_size_x>0
   SetBuffer ImageBuffer(Input_image)
    If mark=0 Then ClsColor 255,0,255 : Cls

     Color input_color_r, input_color_g, input_color_b : Text 0,0,st$
      If cursor=1 Then Line lx,0,lx,FontHeight()

    SetBuffer BackBuffer()
   sx = input_image_x
   ex = Input_size_x+1

   DrawImageRect Input_image,tx,ty,sx,0,ex,FontHeight()
Else
   Text tx,ty,st$
End If

Return st$
End Function

Function setmarkcolor(r,g,b)
 mark_color_r=r : mark_color_g=g : mark_color_b=b
End Function

Function setinputcolor(r,g,b)
 input_color_r=r : input_color_g=g : input_color_b=g
End Function

Function ClearInput$()
 st$ = input_text$ : mark=0 : input_cursor=0 : input_ini=0
 input_text$=""
 Return st$
End Function


Function setinputausnahme$(option)
 Select option
  ; nur Zahlen
  Case 1
   addinputzeichen("von 48 bis 57")
  ; Nur Buchstaben
  Case 2
   addinputzeichen("von 65 bis 90","von 97 bis 122","ä","Ä","ö","Ö","ü","Ü")
   add$("ß") : add$(" ")
 End Select
End Function

.Initial_Input

 Global key_timer_input, start_mark, end_mark, mark, cursor_timer, cursor, input_text$, input_cursor
 Global input_color_r, input_color_g, input_color_b, mark_color_r,mark_color_g,mark_color_b, input_ini

Return

Function addinputzeichen$(a$="",b$="",c$="",d$="",e$="",f$="",g$="",h$="",i$="",j$="")
 For var=1 To 10

  Select var
   Case 1 : st$ = a$
   Case 2 : st$ = b$
   Case 3 : st$ = c$
   Case 4 : st$ = d$
   Case 5 : st$ = e$
   Case 6 : st$ = f$
   Case 7 : st$ = g$
   Case 8 : st$ = h$
   Case 9 : st$ = i$
   Case 10 : st$ = j$
  End Select

  If st$<>""

   If Left$(st$,3)="von"
    For ascii = Mid(st$,5,3) To Right(st$,3)
     add$(Chr$(ascii))
    Next : Goto befehlistok
   End If
 
   add$(st$)
   
  Else
   Exit
  End If
 .befehlistok
 Next
End Function

Function add$(a$)
 i = input_ausnahmen+1
 input_ausnahmen = i
 input_ausnahme$(i)=a$
End Function

Function save_log(p$="%NO DIR")
If p$ = "%NO DIR" Then p$ = CurrentDir$() Else ChangeDir p$
f = WriteFile("Logfile.txt")
For a=1 To message_anzahl
 st$ = console_message$(a)
 WriteLine(f,st$)
Next
CloseFile f
End Function

Function refresh_slider()
  ma  = message_anzahl
  mz  = message_zeiger
  mze = message_zeiger_e
  y2  = console_y2 - 42
 ; Slider neu zeichnen

 sli1_max   = ma
 sli1_items = y2/15

 If sli1_items>=sli1_max Then sli1_items = sli1_max

 sli1_step# = (sli1_size#-42)/sli1_max
 sli1_ende  = sli1_max
 findgadget down1 : down1_y = button\y

 findgadget sli1
  button\sizey = sli1_step#*sli1_items
  button\y     = down1_y-button\sizey

 refreshgadget sli1
End Function


Ich hoffe ihr könnt ebenfalls etwas mit dem Code anfangen. Über positive Äusserungen, Fragen oder Verbesserung würde ich mich freuen.

TheMatrix
  • Zuletzt bearbeitet von TheMatrix am Mi, Okt 25, 2006 23:04, insgesamt einmal bearbeitet

BlitzChecker

BeitragMi, Okt 25, 2006 22:22
Antworten mit Zitat
Benutzer-Profile anzeigen
joa, ist schon nicht schlecht.
was aber n bisschen nervt, ist, dass wenn man in die Titelleiste oder die Scrollbar klickt, der Mittelwert genommen wird. Das erschwert das scrollen erheblich.
Aber sonst: Nice Work!
www.xairro.com

TheMatrix

BeitragMi, Okt 25, 2006 22:40
Antworten mit Zitat
Benutzer-Profile anzeigen
Danke, für mich hatte das erst einmal mit dem Mittelwert gereicht( die Faulheit siegte Rolling Eyes ), aber ich werds natürlich nochmal für dich einbaun Wink .
°_° °.° °~° °v° .. -.-

BlitzChecker

BeitragMi, Okt 25, 2006 22:43
Antworten mit Zitat
Benutzer-Profile anzeigen
thx, ich freu mich schon drauf Very Happy
www.xairro.com

TheMatrix

BeitragMi, Okt 25, 2006 23:06
Antworten mit Zitat
Benutzer-Profile anzeigen
So, wie versprochen dran gefixt und fertiggestellt. Das waren gerade mal 2 Variabeln, die ich da noch hinzufügen mussten Rolling Eyes . Aber mir gefällts irgendwie so auch besser Surprised

Thx
°_° °.° °~° °v° .. -.-

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group