Resize Window_Command

● ARCHIVED · READ-ONLY
Started by Jonruy 6 posts View original ↗
  1. I'm making a custom scene with three custom windows. One is a command window that lists nine options for factions to ally with, and then a basic window lists off some information about a faction that has been selected from the command window. I want the player to select two factions, then select some bonus options from both factions. For (supposed) simplicity, I want to use the same command and display windows for each of these options.

    Throughout this process, the command window has 9, 8, 4, and then 4 items in it. I want that window to resize itself after each choice. I found an archived thread that offered this snippet:

    self.height = fitting_height(@list.size)
    create_contents

    The first line is supposed to resize the menu, but has the side-effect of emptying the contents. The second line refills it. However, when I try to run it myself, I get an error at the first line mentioning a "disposed window." I'm not entirely sure why this is, since nothing is being disposed - at least as far as I understand it.

    Why doesn't this work? Is there a different method for resizing a command window?
  2. I'd try calling refresh instead of create_contents
  3. I already use refresh elsewhere in my code to update the list's contents. That doesn't explain why using self.height = anything causes an error.
  4. I'm having a different problem that seems to be related.

    I skipped over the last issue and finished writing out the rest of the scene. I get to the end after all of the player's choices have been made and the relevant variables and switches have been changed. I then have the scene terminate itself and I get the same "disposed window" error. This was particularly confusing to me since disposing windows is precisely what I'm trying to accomplish. I did some research into this particular error and someone mentioned that this kind of thing only seems to occur in response to a method executed by handlers.

    This is the common trend between both instances of this error in my scene. Resizing the command window and closing the scene are both executed by handlers of player commands in the command window. I guess this explains my issues (sort of), so how do I get around it? How can I trigger a method without using a handler for a menu command?
  5. Jonruy, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


    Please just edit your last post and add the extra information, rather than double posting.


    Maybe you're disposing the windows at the wrong time? Actually, when a scene closes, there's an automatic method that disposes the windows, so maybe you shouldn't be adding the command to do it at all. How does your script compare with the default ones, as far as window creation, refreshing and disposing, go? Do you do the same commands, in the same methods?
  6. The problem definitely occurs when I try to change the command window, I've definitely narrowed down the problem to that. It's initialize, update, and dispose methods straight up defer to the window_command that it inherits from via super and nothing else. it occurs when I try to terminate the scene, which is the proper way to end a scene, isn't it?

    #==============================================================================
    # ** Window_Factions
    #------------------------------------------------------------------------------
    #  This window is for selecting initial faction alliances.
    #==============================================================================

    class Window_Factions < Window_Command
      #--------------------------------------------------------------------------
      # * List the nine factions to ally with or four support personnel.
      #--------------------------------------------------------------------------  
      def make_command_list
        if $game_variables[12] == 2
          add_command("Hire Person 1", :person1)
          add_command("Hire Person 2", :person2)
          add_command("Hire Person 3", :person3)
          add_command("Hire Person 4", :person4)
        else
          check_approval(1, "View Guild",      :Guild)
          check_approval(2, "View Sacceris",   :Sacceris)
          check_approval(3, "View Isendra",    :Isendra)
          check_approval(4, "View Ashther",    :Ashther)
          check_approval(5, "View Champions",  :Champions)
          check_approval(6, "View Fraternity", :Fraternity)
          check_approval(7, "View Ettaia",     :Ettaia)
          check_approval(8, "View Sovereign",  :Sovereign)
          check_approval(9, "View Guardians",  :Guardians)
        end
      end
     
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize(x, y)
        super
      end
     
      #--------------------------------------------------------------------------
      # * Free
      #--------------------------------------------------------------------------
      def dispose
        super
      end
     
      #--------------------------------------------------------------------------
      # * Refresh
      #--------------------------------------------------------------------------
      def refresh
        super
      end
     
      #--------------------------------------------------------------------------
      # * Determine whether or not to add a faction.
      #--------------------------------------------------------------------------  
      def check_approval(variable, faction, symbol)
        if $game_variables[variable] < 10
          add_command(faction, symbol)
        end
      end
    end