[ACE] Help with this window... contents not scrolling

● ARCHIVED · READ-ONLY
Started by Gleen 10 posts View original ↗
  1. Hello everyone, i made a window wich will draw every character present in $data_actor in a somewhat choose your starting party system. So this window, it draws the actor characters until it reaches maximum height and then it don't scroll to show the other characters. Here are some screens of what is happening instead:



    If you want to test it yourself, i made a example scene, just call SceneManager.call(Scene_PartySelect) and you'll see. here's my code:



    Code:
    class Window_CharList < Window_Selectable
      def initialize(x,y)
        super(x, y, 70, Graphics.height - y)
        @itens = []
        make_item_list
        select(0)
        activate
        refresh
      end
      def item_max
        @itens ? @itens.size : 1
      end
      def item
        @itens && index >= 0 ? @itens[index] : nil
      end
      def item_rect(index)
        rect = Rect.new
        rect.width = 38
        rect.height = 38
        rect.x = 4
        rect.y = index * rect.height
        rect
      end
      def make_item_list
        for i in 1...$data_actors.size
    	  @itens[i - 1] = $game_actors[i]
        end
      end
      def draw_item(index)
        item = @itens[index]
        if item
    	  rect = item_rect(index)
    	  draw_actor_graphic(item, 22, rect.y + 36)
        end
      end
      def refresh
        contents.clear
        for i in 0...@itens.size
    	  draw_item(i)
        end
      end
    end
    
    class Scene_PartySelect < Scene_MenuBase
      def start
        super
        create_all_windows
      end
      def create_all_windows
        @charlist_window = Window_CharLista.new(0,0)
        @charlist_window.set_handler(:cancel,    method(:return_scene))
      end
    end
    I don't know how to fix it, and neither if i was clear enough with my bad english, but if someone could fix it and/or tell me what i did wrong i'll be glad. Thanks in advice.
  2. It's because the size of the contents bitmap is not correct. It may or may not fix it to add the following to the Window_CharList class.



    Code:
    def contents_height
      item_max * 38
    end
    If not, you may need to add "create_contents" where you have "contents.clear" in addition to this.
  3. Thanks, now ithe window shows every character graphic but it still doesn't scroll. The rector goes out of screen while the window shows the same characters.
  4. Code:
    def item_height
      return 38
    end
    Add that the same place. Should do the trick now?
  5. Yes, it did! are thos methods inside the superclass Window_Selectable or Window_Base? Maybe i was blind thinking with was something within my code and not missing other funcionts...

    Anyway, thanks!
  6. item_height is defined in window_selectable and just returns line height by default. content_height is first defined in window_base but is overwritten by window_selectable. Actually, you can remove the overwrite I gave you because it will work just fine with the change to item_height. I've had this issue with the contents size before, so I kinda knew what was wrong right away.
  7. contents_height uses line_height in its calculations right
  8. Tsukihime said:
    contents_height uses line_height in its calculations right
    Nope. contents_height does not directly use line_height ever in it's formula. In Window_Base it is "height - standard_padding * 2", which is pretty much all of the window except the edges. Window_Selectable redefines it as "[super - super % item_height, row_max * item_height].max", which pretty much makes it only big enough for all the items the window holds, though Window_Selectable defines item_height as line_height by default (which is the problem that was occurring here). Window_HorzCommand and redefines it as "item_height" since all commands are arranged horizontally and there is no need to any more vertical space and Window_ChoiceList makes it "item_max * item_height" which is similar to how Window_Selectable defines it, but this one assumes all items will be arranged vertically. Each more or less holds objects in it's own way. With how it works, this window probably could have better been a child of Window_ChoiceList, however I personally prefer just using Window_Selectable in a case like this as well. RGSS3 is still a little annoying to me....
  9. That's strange then, because contents_height is the height of the bitmap that holds the items drawn on the window.

    Or, maybe item_height is used to draw the selection rectangle and offset is accordingly.

    But then that doesn't explain why you only need to specify the item_height and ignore the content_height.
  10. The window class he's using uses "item_height" in the calculation for "content_height", so there's no need to alter "content_height" as long as he's defined how tall the items are in "item_height".