Scrollliste erstellen

  • GM 8

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Scrollliste erstellen

    Hi,

    der titel sagt ja schon alles.. ich hab eben einen text und will den nach oben und unten scrollen. wie mach ich jetzt bloß das? ich hab gehört das würde mit nem view gehen, jedoch klappt das bei mir alles nicht?
  • Würde dir empfehlen das was du haben willst auf eine Surface zu zeichnen.



    Hier hab ich eine art skript an dem ich grad arbeite, ich wollte es bald veröffentlichen.

    Es zeichnet die eine vollfunktionsfähige Scrollbar mit Knöpfen, Schieber und lässt sich auch per Scrollrad bedienen.

    das teil ist noch eher in der Testphase aber vieleicht kannst dus brauchen.

    Im Grunde brauchst du nur die oberen komentierten Werten zu verändern.



    Spoiler anzeigen


    GML-Quellcode

    1. var mb_str_h, surface;
    2. surface = Your surface // write here the name of the surface, the width is not important
    3. mb_str_h = surface_get_height(surface);
    4. var xc_origin, yc_origin, width, yc_end, all_height, height, left;
    5. left = 100 // the offset on the left side
    6. xc_origin = view_xview[0]+view_wview[0]-40; // here write the origin where the bar starts!
    7. yc_origin = view_yview[0]+50; // the upper offset
    8. yc_end = view_yview[0]+view_hview[0]-155; // where all ends
    9. width = 12; // the width of the bar (a even number is recomended)
    10. all_height = yc_end-yc_origin;
    11. height = all_height-2*width-2;
    12. if mb_str_h < all_height
    13. draw_surface(surface,left,yc_origin)
    14. else
    15. {
    16. draw_set_alpha(0.6);
    17. draw_set_color(c_black);
    18. draw_rectangle(xc_origin,yc_origin,xc_origin+width,yc_origin+width+1,true);
    19. draw_rectangle(xc_origin,yc_end-width-1,xc_origin+width,yc_end,true);
    20. draw_set_color(ret(click_bar,make_color_rgb(192,192,192),make_color_rgb(86,90,160)));
    21. draw_rectangle(xc_origin,yc_origin+width+2,xc_origin+width,yc_end-width-2,false);
    22. draw_set_color(make_color_rgb(149,149,149));
    23. draw_rectangle(xc_origin,yc_origin+width+2,xc_origin+width,yc_end-width-2,true);
    24. var bar_length;
    25. bar_length = round((all_height/mb_str_h)*height);
    26. if mouse_check_button(mb_left) && on_bar = 0
    27. {
    28. if mouse_x >= xc_origin && mouse_x <= xc_origin+width &&
    29. mouse_y >= yc_origin+width+1 && mouse_y <= yc_end-width-1
    30. on_bar = 1
    31. else on_bar = 0;
    32. }
    33. if mouse_check_button_released(mb_left)
    34. on_bar = 0;
    35. if on_bar
    36. {
    37. if mouse_y-(yc_origin+width+1) >= bar_pos && mouse_y-(yc_origin+width+1) <= bar_pos+bar_length or mouse_x <= xc_origin or mouse_x > xc_origin+width
    38. {
    39. bar_pos = round(mouse_y-bar_length/2-(yc_origin+width+1));
    40. if mouse_y < yc_origin+width+1+bar_length/2 then bar_pos = 0;
    41. if mouse_y > yc_end-width-1-bar_length/2 then bar_pos = height-bar_length;
    42. click_bar = 0;
    43. }
    44. else
    45. if (mouse_y < bar_pos && mouse_y > yc_origin+width+1) or (mouse_y > bar_pos+bar_length && mouse_y < yc_end-width-1)
    46. {
    47. click_bar = 1;
    48. if mouse_y > yc_origin+width+1+height/2
    49. bar_pos += 1+mb_str_h/100
    50. else bar_pos -= 1+mb_str_h/100;
    51. if bar_pos < 0 bar_pos = 0;
    52. if bar_pos > height-bar_length-2 bar_pos = height-2-bar_length;
    53. }
    54. }
    55. else click_bar = 0;
    56. if click_bar = 1 draw_set_alpha(0.9)
    57. draw_set_color(make_color_rgb(149,149,149));
    58. draw_rectangle(xc_origin,yc_origin+width+1+bar_pos,xc_origin+width,yc_origin+width+1+bar_pos+bar_length,false);
    59. draw_set_color(c_black);
    60. draw_rectangle(xc_origin,yc_origin+width+1+bar_pos,xc_origin+width,yc_origin+width+1+bar_pos+bar_length,true);
    61. draw_line(xc_origin+2,round(yc_origin+width+1+bar_pos+bar_length/2-2),xc_origin+width-1,round(yc_origin+width+1+bar_pos+bar_length/2-2));
    62. draw_line(xc_origin+2,round(yc_origin+width+1+bar_pos+bar_length/2),xc_origin+width-1,round(yc_origin+width+1+bar_pos+bar_length/2));
    63. draw_line(xc_origin+2,round(yc_origin+width+1+bar_pos+bar_length/2+2),xc_origin+width-1,round(yc_origin+width+1+bar_pos+bar_length/2+2));
    64. draw_surface_part(surface,0,round((bar_pos/((height-2)-bar_length))*(mb_str_h-(all_height-8))),view_wview[0],all_height,left,yc_origin);
    65. draw_set_alpha(0.6);
    66. var down_press, up_press;
    67. if mouse_check_button_pressed(mb_left)
    68. {
    69. if mouse_x > xc_origin && mouse_y > yc_origin
    70. && mouse_x < xc_origin+width && mouse_y < yc_origin+width+1
    71. up_press = 1;
    72. if mouse_x > xc_origin && mouse_y > yc_end-width-1
    73. && mouse_x < xc_origin+width && mouse_y < yc_end
    74. down_press = 1;
    75. }
    76. draw_set_color(ret(up_press,c_silver,make_color_rgb(86,90,160)));
    77. draw_rectangle(xc_origin+1,yc_origin+1,xc_origin+width-1,yc_origin+width,false);
    78. draw_set_color(ret(down_press,c_silver,make_color_rgb(86,90,160)));
    79. draw_rectangle(xc_origin+1,yc_end-width,xc_origin+width-1,yc_end-1,false);
    80. draw_set_alpha(0.9);
    81. draw_set_color(ret(down_press,c_black,c_white));
    82. draw_line_width(xc_origin+round(width/2),yc_end-4,xc_origin+width-2,yc_end-width+3,2);
    83. draw_line_width(xc_origin+round(width/2),yc_end-4,xc_origin+2,yc_end-width+3,2);
    84. draw_set_color(ret(up_press,c_black,c_white));
    85. draw_line_width(xc_origin+round(width/2),yc_origin+4,xc_origin+width-2,yc_origin+width-2,2);
    86. draw_line_width(xc_origin+round(width/2),yc_origin+4,xc_origin+2,yc_origin+width-2,2);
    87. if down_press = 1 or mouse_wheel_down()
    88. {
    89. bar_pos += mb_str_h/150;
    90. if bar_pos > height-bar_length bar_pos = height-bar_length;
    91. }
    92. if up_press = 1 or mouse_wheel_up()
    93. {
    94. bar_pos -= mb_str_h/150;
    95. if bar_pos < 0 bar_pos = 0;
    96. }
    97. draw_set_alpha(1);
    Alles anzeigen




    Du brauchst noch dieses script namens ret



    Spoiler anzeigen


    GML-Quellcode

    1. if argument0 return argument2 else return argument1;




    // Zusammengeschoben vom Moderator Ihres
    Vertrauens...

    Edit:
    oh, na toll wurde schon verschoben...

    Editieren nicht mehr möglich.

    Das mit den zeilenabständen passiert bei mir immer, weis einer worans liegt? //<-- ...der an dieser Stelle leider auch nicht weiterhelfen kann. =(

    Willst du auf diese Drachen und -eier klicken?
    Sie werden sich freuen ;)