Help with windows

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
Ok lets try this one more time

  • Run these scripts - do not modify them in any way, run them in a new game
  • Create an event and use:  call_sample to open the window
  • MAKE SURE YOU HAVE THE CONSOLE OPEN
Script One
#==============================================================================# ** DataManager#------------------------------------------------------------------------------# This is your customization module where you give your new currency a name# and set it's max value.#==============================================================================module CURR CURR_HASH = { 'GC' => { :full_name => 'Guild Currency', :max => 9999, :description => 'Example Stuffs', }, 'GC2' => { :full_name => 'Guild Currency', :max => 9999, :description => 'Example Stuffs', }, } MENU_VOCAB = 'Currencies' MENU_ENABLED = true end#==============================================================================# ** DataManager#------------------------------------------------------------------------------# This module manages the database and game objects. Almost all of the # global variables used by the game are initialized by this module.#==============================================================================class << DataManager #-------------------------------------------------------------------------- # * Create Game Objects #-------------------------------------------------------------------------- alias kalacious_currency_game_objects create_game_objects def create_game_objects kalacious_currency_game_objects $kc_currency = Game_Currency.new endendclass Game_Currency attr_reader :currency def initialize @currencies = [] create end def create CURR::CURR_HASH.each do |key, value| currency = Create_CurrencyObject.new(key, value[:full_name], value[:max], value[:description], 0) @currencies.push(currency) end end def currencies @currencies end def currency(curr_vocab) if @currencies.any? @currencies.each do |currency| if currency.curr_sym == curr_vocab return currency end end end end def increase(curr_vocab, value) if @currencies.any? @currencies.each do |currency| if currency.curr_sym == curr_vocab currency.value = [[currency.value + value, 0].max, currency.max].min end end end end def decrease(curr_vocab, value) if @currencies.any? @currencies.each do |currency| if currency.curr_sym == curr_vocab increase(curr_vocab, -value) end end end end def set(curr_vocab, value) if @currencies.any? @currencies.each do |currency| if currency.curr_sym == curr_vocab currency.value = [[value, 0].max, currency.max].min end end end end def value(curr_vocab) if @currencies.any? @currencies.each do |currency| if currency.curr_sym == curr_vocab return currency.value end end end end def delete(curr_vocab) @currencies.delete_if {|x, *_| x == curr_vocab } end endclass Create_CurrencyObject attr_reader :curr_sym attr_reader :full_name attr_reader :max attr_reader :description attr_accessor :value def initialize(curr_sym, full_name, max, description, value = 0) @curr_sym = curr_sym @full_name = full_name @max = max @description = description @value = value end end
Script Two

class Game_Interpreter  def call_sample    SceneManager.call(Scene_Currencies)  endend class List_Currencies < Window_Selectable    def initialize(x, y, width, height)    super    @data = []    activate    refresh  end    def col_max    return 1  end   def item_max    @data ? @data.size : 1  end    def enable?(item)    true  end    def item    @data && index >= 0 ? @data[index] : nil  end    def draw_item(index)    currency = @data[index]    if currency      rect = item_rect_for_text(index)      draw_text(rect, currency.value.to_s+currency.curr_sym)    end  end      def make_item_list    @data = $kc_currency.currencies  end    def refresh    make_item_list    create_contents    draw_all_items  end end class Currency_Description < Window_Base  def initialize(x, y, width, height)    super  end    def data=(index)    puts index.curr_sym    return if @content == index    @content = index    refresh  end    def refresh    contents.clear    create_contents    return if @content  end  end class Scene_Currencies < Scene_MenuBase    def start    super    create_currencies_window    create_description_window  end    def create_currencies_window    @currency_list = List_Currencies.new(0, 0, 150, Graphics.height)    @currency_list.select(0)  end    def create_description_window    @currency_description = Currency_Description.new(@currency_list.width, 0,       Graphics.width - @currency_list.width, Graphics.height)    @currency_description.data = @currency_list.item  end    def update    super    if Input.trigger?:)      SceneManager.return    end  end  end
What you should see when you launch the window,, in the console, is: GC Move down to 0GC2, the console should update and display GC2. But it does not.

If we pay attention to Scene_Currency, in the create_description_window method we see that I am telling window to populate data based on the current item in the currency_list:

  def create_description_window    @currency_description = Currency_Description.new(@currency_list.width, 0,       Graphics.width - @currency_list.width, Graphics.height)    @currency_description.data = @currency_list.item  endWe see that, in the Currency_Description class, we have a method called:

Code:
  def data=(index)    puts index.curr_sym    return if @content == index    @content = index    refresh  end
this updates to tell the console: you have selected GC. now move the cursor down and you don't see the next item in the list in the console: GC2, when you should. why? because I am telling it to update based on: @currency_description.data = @currency_list.itemOr at least I think I am telling it to.

Does this make better sense?
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Ok, I see the problem now.

The code you said updates the description window:

def create_description_window @currency_description = Currency_Description.new(@currency_list.width, 0, Graphics.width - @currency_list.width, Graphics.height) @currency_description.data = @currency_list.item endYour create_description_window appears to be only called once, when the scene's `start` method is called.There does not seem to be any other instance where that specific line is called.
 
Last edited by a moderator:

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
Ok so should I be calling: @currency_description.data = @currency_list.item in the Scenes update?
 

edit the scene's update method would not be a wise choice, I believe it would be the update_all_windows but im not sure.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
There are several ways to do it

1. Create handlers that are fired whenever you press the direction keys

2. Pass a reference of your description window to the currency window so that when the cursor changes, you want to update the description window as well

RM's scripts uses the second approach for most of the window updating since it's easier.

In Scene_Item there is

Code:
  def create_item_window    wy = @category_window.y + @category_window.height    wh = Graphics.height - wy    @item_window = Window_ItemList.new(0, wy, Graphics.width, wh)    @item_window.viewport = @viewport    @item_window.help_window = @help_window    @item_window.set_handler(:ok,     method(:on_item_ok))    @item_window.set_handler(:cancel, method(:on_item_cancel))    @category_window.item_window = @item_window  end
and then in the category window's update method
Code:
def update  super  @item_window.category = current_symbol if @item_windowend
To update the item list window's variables.
 
Last edited by a moderator:

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
Thank you. This made WAY more sense. I have now decided to go in a whole different direction with the window :D
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top