Help with windows

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
I wanted to play with windows, So I built this really basic thing:

 


Code:
class Game_Interpreter
  def call_sample
    SceneManager.call(Scene_Sample)
  end
end
 
class Sample < Window_Base
  def initialize(x, y, width, height)
    super
  end
end
 
class Scene_Sample < Scene_MenuBase
  
  def start
    super
    create_window
  end
  
  def create_window
    @window = Sample.new(122, 122, 122, 122)
  end
  
end
 

calling: call_sample will open your window, how ever hitting esc, like on any other window, won't close it.....I've seen numerous scripts do this and no one seems to have a dispose method built for their windows (probably because the parent class has dispose already defined. There seems to be limited tutorials on windows on YouTube and on-line. This is one area I don't understand of RGSS 3. How are they doing it? How are they closing windows when you hit esc?

 
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
Well, if you're talking about other custom scenes do it, then you'll want to look in the update method. Update is where you would usually check for things, because that is called at every frame in the game. You first need to add a method called update in your sample scene, and make sure it calls super!! If you don't the game will freeze. Then, in the body of update, simply do:

if Input.trigger?:) SceneManager.returnendAlso, you don't need to add your scene to the game interpreter for you to be able to call it. You could just put the SceneManager.call statement in an event and it'll all work fine.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
You can either use Window_Selectable and give it a cancel handler, or check for cancel on update.


I would prefer the handlers since it handles the update checking for you, but maybe that is unnecessary in your case.
 
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
I know, I have even created a module at one point (for a different script) where you call the module.method, which would then call the scene. I put it in GI because I was testing something I saw in a popular script. 

Ive never seen people check in their update method if the user has entered some kind of input....then again windows are a mystery to me.

the cancel one I have seen a million times....
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
Ive never seen people check in their update method if the user has entered some kind of input....then again windows are a mystery to me.
I was talking about the Scene's update, not the window. Though I suppose you could have one in your window for closing that window specifically.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
I know, I have even created a module at one point (for a different script) where you call the module.method, which would then call the scene.
quite unnecessary too... just use

SceneManager.call(Scene_Sample)directly... XD

anyway, yeah ur missing a handler to close the window... you could maybe alias or overwrite the terminate method to add the @window.dispose call...
 
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
I know. But Telling some one to call SceneManager.call(class) is (in my books) bad. I would rather you just call: call_sample. and be done with it. :D

I created the update method in the scene. All is well now. Thanks.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I know. But Telling some one to call SceneManager.call(class) is (in my books) bad. I would rather you just call: call_sample. and be done with it. :D
What if I added extra logic to SceneManager.call under the assumption that all scene transitions go through this thing?
 
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
Half the scripts  have seen on here, including some written by mods and popular scriptors would fail epically. While I see your point and am in no way blind to it, I can't see a reason - or haven't found a script that does this, to alter the SceneManager.call(). Name me one good reason you'd modify it and how it would benefit RGSS3 or what extra functionality you could add to it.

I haven't come a across a script that does this, if such a script exists. Again, I feel unsafe about calling SceneManager.call() to begin with, so many scripts today are doing: call $bla.open or open_window....

Any ways, I digress, I require help, this time with a rectangle for selecting objects. I has the two windows:

class Game_Interpreter def call_currency_window SceneManager.call(Scene_Currencies) endendclass List_Currencies < Window_Selectable def initialize(x, y, width, height) super @data = [] refresh end def cols return 1 end def item_max @data ? @data.size : 1 end def enable?(item) true end def draw_item(index) currency = @data[index] if currency rect = item_rect_for_text(index) puts rect 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 endclass Currency_Description < Window_Base def initialize(x, y, width, height) super endendclass 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) end def create_description_window @currency_description = Currency_Description.new(@currency_list.width, 0, Graphics.width - @currency_list.width, Graphics.height) end def update super if Input.trigger?:) SceneManager.return end end end again, this time, you call via: call_currency_window. This is a list of currencies in one window and eventually description in another. What I cant get to work is the rectangle for selecting. When I puts rect I'll get something like <4, 0 ,118, 24> and <4, 24, 118, 24> the list will populate properly as it should, but alas no rectangle. I understand the information in <> to mean x,y, width, height? so where my rectangle?

Also - As of late I have been asking the community questions like a mad man on a mission. would it even, once things are polished, cleaned up and tested properly, be worth sharing, since you have, from my threads enough of the script(s) to be like "Ya i can build better. don't bother"?
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Sorry, I was thinking something else. I thought you were changing the scene directly instead of going through SceneManager.call but then realized I was looking at something else.


As for when I might change that method, it might make more sense to change post_transfer or pre_transfer in the scene.
 
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
Sorry, I was thinking something else. I thought you were changing the scene directly instead of going through SceneManager.call but then realized I was looking at something else.

As for when I might change that method, it might make more sense to change post_transfer or pre_transfer in the scene.
that would make sense. and as for my rect not drawing?
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
You need to activate the window (@window.active) and set the cursor to one of the items (@window.select(0))
 
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
I figured as much. how ever, I found an issue with that.

When you do something like:

@currency_list.index = 0 (or in your case, select(0)) the index doesn't update. I'm not sure why. Or how I can make it update. But the idea is to do something where I add the following method to Currency_Description and do:

def data=(index)    return if @data == index    @data = index    refresh #typical refresh method, nothing special.endThis would allow me to then update the Currency_Description  window based on the current selected currency in the list window. the issue is that when I puts index, it's always at 0, regardless of where the selection box (cursor) is. Should it not update? base on cursor location? Or is that for me to do? if so how do I go about that?

this idea is based off of MA's Quest Dialogue, where as you scroll through the quests the quest description window updates. I've looked through his code and the list and description window all see fairly basic, you grab the index from the list item based on where the cursor is (not sure how teats determined) and from there it passes the index from, def item @data[index] end to the, in my case, data method.

The only issue I am having is I cannot get the index value, when the cursor is moved, to update. =.=
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
@currency_list.index = 0 (or in your case, select(0))
Take a look at how `select` is defined.
 
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
Take a look at how `select` is defined.
.select only sets the index if the index is set. that is: self.index = index if index using this, the index still does not update upon selecting other items in the list.

.index=(index) sets the index, updates the cursor and calls the update help method.

in either case, in the root .select, puts self.index much like puts index in the .index method will update. How ever when I then do

@currency_description.data = @currency_list.item  I only get ONE item back regardless of if the cursor moves down or up. every time the cursor moves I should get an item back. Can you explain in more  detail why I am not getting more then one object back?
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I filled in some details since the script could not run stand-alone (hardcoding data source and drawing some arbitrary text)

I then added in the select call during window creation in the scene.

class Game_Interpreter def call_currency_window SceneManager.call(Scene_Currencies) endendclass List_Currencies < Window_Selectable def initialize(x, y, width, height) super @data = [] refresh end def cols return 1 end def item_max @data ? @data.size : 1 end def enable?(item) true end def draw_item(index) currency = @data[index] if currency rect = item_rect_for_text(index) puts rect draw_text(rect, index) end end def make_item_list @data = [1,2,3] end def refresh make_item_list create_contents draw_all_items end endclass Currency_Description < Window_Base def initialize(x, y, width, height) super endendclass 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) @currency_list.activate end def create_description_window @currency_description = Currency_Description.new(@currency_list.width, 0, Graphics.width - @currency_list.width, Graphics.height) end def update super if Input.trigger?:) SceneManager.return end end end
I also just read this

Also - As of late I have been asking the community questions like a mad man on a mission. would it even, once things are polished, cleaned up and tested properly, be worth sharing, since you have, from my threads enough of the script(s) to be like "Ya i can build better. don't bother"?
I don't understand what you are trying to say. Some commas make it difficult.

I use my own scripts as reference because it's probably faster than having to explain how I thought of the problem. It isn't to deter you from publishing your own or coming up with your own solutions to a problem.
 
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
That does not help me, this is what I have:

class Game_Interpreter def call_sample SceneManager.call(Scene_Currencies) endendclass 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 endclass Currency_Description < Window_Base def initialize(x, y, width, height) super end def data=(index) puts index return if @content == index @content = index refresh end def refresh contents.clear create_contents return if @content end endclass 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
Notice: @currency_description.data = @currency_list.item in the scene

Lets assume your array, for @data, in make_item_list looks like this: [Apple, Banana].

When you move up or down the list you should see:


Apple
Banana


I only See:

Apple

Regardless of if I move up or down the list. Please explain that.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I cannot reproduce your issue with the script you have posted, and so I can't explain why you're having issues when I don't know why you're having them in the first place. Perhaps there is a typo somewhere in your data source?

The script doesn't run, so I have manually hardcoded things to fit your examples.

I changed line 41 to

@data = ["Apple", "Banana"]and changed line 36 to

Code:
draw_text(rect, currency)
And I see
 
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
No. Thats not what I mean.

Ok, lets try this again:

@data = [#<someclassobject @text="test" @description = "I am tests description">, #<some class object @text="apple" @description = "I am tests description">,]

Now, take that, make a quick class object with text and description. List @text in the list side, now select apple, in the big window you should (I havent built this in) be able to print out the description for apple.

Since I haven't built that, lets out put it to the CONSOLE.

def data=(index)     put indexendEach time you move up and down the list now, the console should say #<someclassobject>xxxxxx where the xxxx changes based on the object passed through. this is not the case for me.  can you tell me why?

Note: someclassobject is just an example for a class object you would create your self. for example:

Code:
 class Object_Test    attr_reader :test    attr_reader :description     def initialize(test, description)        @test = test        @description = description    endend 
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Each time you move up and down the list now
Maybe I am missing something but how are you updating your currency description window when you move your cursor around?

From my understanding, your cursor moves around in the currency list window.

When does this come into play?

Code:
def data=(index)     put indexend
Assuming this is in the currency description window class
 
Last edited by a moderator:

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