Problem: Window cursor below background

● ARCHIVED · READ-ONLY
Started by AuronAD 6 posts View original ↗
  1. Hi there!

    As the title implies, I have a problem with the window cursor, when I'm trying to use a picture instead of the windowskin-color in the background. My goal is to make something similar to this:


    Using the "Emerald Skill Tree" Source Code as template.

    Relevant code snippets:

    class Window_CST_Trees < Window_Selectable...def initialize(tree_id) super(0, 48, 7 * 24 + 24, Graphics.height - 48) self.opacity = 0 #Only this is relevant, because it causes the windowskin to become invisible @tree_id = tree_id @data = [] if EME::SKILL_TREES::FIRST_SELECT_ACTOR and $game_party.menu_actor != nil @actor = $game_party.menu_actor else if $game_party.members[$game_party.est_last_actor_index] != nil @actor = $game_party.members[$game_party.est_last_actor_index] else @actor = $game_party.members[0] end end @trees = EME::SKILL_TREES::Trees @trees_per_actor = EME::SKILL_TREES::Trees_Per_Actor @objects = EME::SKILL_TREES::objects refresh end... def refresh make_tree_data create_contents background = Cache.picture("Hintergrund") rect = Rect.new(0,0,self.width, self.height) contents.blt(0, 0, background, rect, 255) draw_all_items select_last endend The code gives following result:


    Please don't mind the window in the upper right corner, it's under construction ;)

    On first sight it seems to fulfill it's job, but compared to the original, it misses the blinking cursor over the tree items. When I remove the 

    background = Cache.picture("Hintergrund")rect = Rect.new(0,0,self.width, self.height)contents.blt(0, 0, background, rect, 255)part of the refresh method, the cursor is visible and blinks. After investigating it for quit a bit I found, that the update-method of the super-superclass "Window" is responsible for the cursor-display. Only problem here is, that it's in the engine-blackbox and i couldn't find the source code to the Window.update method to overwrite it.

    To conclude this poorly written post (not native english speaker) my question to you is: How do I get to display the cursor above the generated background-bitmap?

    I'm gratefull for any advice/solutions!


    EDIT: I'm using RGSS3 :)


  2. Is this what you mean? I don't really understand what you want ? :|

    How do I get to display the cursor above the generated background-bitmap?
    Well, the slime image is a bitmap and the cursor is above it, but I don't know about background bitmap that you mention above.. :( Sorry.
    Oh yeah, if you change the opacity of the window to 0, then it would be like this :

    Spoiler
    The cursor is above the slime isn't it? Just in your case the bitmap is big and fill all the window contents, and in my case I only using a slime as a bitmap example. But sorry If I made a mistake.
  3. Sorry that I didn't explain it good enough.



    Here you see the cursor around the tree item icons. I simply want to see the cursor above my tree items. Maybe you need the full code to understand, here you go (credits to emerald, from which I adapted my code), I marked the important class:
     

    #============================================================================## Scene_Menu# Adds the handler to access the skill trees scene from the menu.#============================================================================class Scene_Menu alias aur_cst_personal_ok on_personal_ok def on_personal_ok if @command_window.current_symbol == :custskilltrees SceneManager.call(Scene_CustomSkillTrees) else aur_cst_personal_ok end endend#============================================================================## Window_CST_Selection# Window which enables the player to select the different trees.#============================================================================class Window_CST_Selection < Window_Command attr_accessor :actor_id def initialize @actor_id = 0 super(400, 0) @opacity = 0 end def window_width Graphics.width end def col_max return 3 end def update super case current_symbol when :tree_1 $game_party.est_last_tree_id = 0 when :tree_2 $game_party.est_last_tree_id = 1 when :tree_3 $game_party.est_last_tree_id = 2 end end def make_command_list if EME::SKILL_TREES::Trees_Per_Actor.include?(@actor_id) add_command(EME::SKILL_TREES::Trees_Per_Actor[@actor_id][3], :tree_1) if EME::SKILL_TREES::Trees_Per_Actor[@actor_id][0] != nil add_command(EME::SKILL_TREES::Trees_Per_Actor[@actor_id][4], :tree_2) if EME::SKILL_TREES::Trees_Per_Actor[@actor_id][1] != nil add_command(EME::SKILL_TREES::Trees_Per_Actor[@actor_id][5], :tree_3) if EME::SKILL_TREES::Trees_Per_Actor[@actor_id][2] != nil end end alias aur_cst_i_need_something_original refresh def refresh aur_cst_i_need_something_original clear_command_list make_command_list end alias aur_cst_cursor_left cursor_left def cursor_left(wrap = false) SceneManager.scene.switch_to_tree aur_cst_cursor_left(wrap) end alias aur_cst_cursor_right cursor_right def cursor_right(wrap = false) SceneManager.scene.switch_to_tree aur_cst_cursor_right(wrap) end end# THIS IS THE CLASS THAT MATTERS!#============================================================================## Window_CST_Trees# Window which enables the player to select and upgrade skills.#============================================================================class Window_CST_Trees < Window_Selectable attr_reader :data attr_reader :objects attr_reader :trees attr_reader :trees_per_actor attr_accessor :actor attr_accessor :tree_id attr_accessor :previous_skill attr_accessor :window_selection def initialize(tree_id) super(0, 48, 7 * 24 + 24, Graphics.height - 48) self.opacity = 0 @tree_id = tree_id @data = [] if EME::SKILL_TREES::FIRST_SELECT_ACTOR and $game_party.menu_actor != nil @actor = $game_party.menu_actor else if $game_party.members[$game_party.est_last_actor_index] != nil @actor = $game_party.members[$game_party.est_last_actor_index] else @actor = $game_party.members[0] end end @trees = EME::SKILL_TREES::Trees @trees_per_actor = EME::SKILL_TREES::Trees_Per_Actor @objects = EME::SKILL_TREES::objects refresh end def item_max @data ? @data.size : 1 end def col_max return 7 end def item_width return 24 end def item_height return 24 end def spacing return 0 end def select_last if @data[$game_party.est_last_object_index] != nil and @objects[@data[$game_party.est_last_object_index]][0] != "arrow_object" select($game_party.est_last_object_index) else current_element = 0 last_element = @data.size - 1 loop do if current_element <= last_element if @data[current_element] != nil and @objects[@data[current_element]][0] != "arrow_object" select(current_element) return else current_element += 1 end else self.unselect end end end end alias eme_est_process_ok process_ok def process_ok if current_skill_not_maxed? eme_est_process_ok else Sound.play_buzzer end end alias eme_est_cursor_down cursor_down def cursor_down(wrap = false) loop do if @index + col_max > @data.size - 1 @index = 0 if @data[@index] != nil and @objects[@data[@index]][0] != "arrow_object" select(0) break else cursor_right(wrap) break end elsif @data[@index + col_max] != nil and @objects[@data[index + col_max]][0] != "arrow_object" eme_est_cursor_down(wrap) break else self.index += col_max self.index = 0 if index > item_max end end $game_party.est_last_object_index = @index end alias eme_est_cursor_up cursor_up def cursor_up(wrap = false) loop do if @index - col_max < 0 @index = item_max if @data[@index] != nil and @objects[@data[@index]][0] != "arrow_object" select(item_max) break else cursor_left(wrap) break end elsif @data[index - col_max] != nil and @objects[@data[index - col_max]][0] != "arrow_object" eme_est_cursor_up(wrap) break else @index -= col_max @index = 0 if @index < 0 end end $game_party.est_last_object_index = @index end alias eme_est_cursor_right cursor_right def cursor_right(wrap = false) switch_window = false loop do if index + 1 > @data.size - 1 self.index = 0 switch_window = true if @data[index] != nil and @objects[@data[index]][0] != "arrow_object" break end elsif @data[index + 1] != nil and @objects[@data[index + 1]][0] != "arrow_object" break else self.index += 1 self.index = 0 if index > item_max end end $game_party.est_last_object_index = @index if not switch_window eme_est_cursor_right(wrap) end end alias eme_est_cursor_left cursor_left def cursor_left(wrap = false) switch_window = false loop do if index - 1 < 0 self.index = @data.size - 1 switch_window = true break# Original Code:#~ if @data[index] != nil and @objects[@data[index]][0] != "arrow_object"#~ select(@data.size - 1)#~ return#~ end elsif @data[index - 1] != nil and @objects[@data[index - 1]][0] != "arrow_object" break else self.index -= 1 self.index = 0 if index > item_max end end eme_est_cursor_left(wrap) $game_party.est_last_object_index = @index end def enable_arrow?(arrow_object) for i in 2...arrow_object.size return false unless enable_skill?(@objects[arrow_object], true) end return true end def enable_skill?(skill_object, used_in_enable_arrow) return true if @actor.est_skill_maxed?(skill_object, @tree_id) requirements = skill_object[@actor.est_skill_level(skill_object, @tree_id) + 2] requirements.each {|requirement| case requirement[0] when "poüints" return false unless used_in_enable_arrow or @actor.tree_points >= requirement[1] when "tree_points" return false unless @actor.points_per_tree[requirement[1]] >= requirement[2] when "tree_skill_level" return false unless @actor.est_skill_level(@objects[requirement[1]], @tree_id) >= requirement[2] or @actor.est_skill_maxed?(@objects[requirement[1]], @tree_id) when "level" case requirement[1] when "=" return false unless @actor.level == requirement[2] when ">" return false unless @actor.level > requirement[2] when ">=" return false unless @actor.level >= requirement[2] when "<" return false unless @actor.level < requirement[2] when "<=" return false unless @actor.level <= requirement[2] when "!=" return false unless @actor.level != requirement[2] end when "skill" return false unless @actor.skill_learn?($data_skills[requirement[1]]) when "switch" if requirement[2] return false unless $game_switches[requirement[1]] else return false if $game_switches[requirement[1]] end when "variable" case requirement[2] when "=" return false unless $game_variables[requirement[1]] == requirement[3] when ">" return false unless $game_variables[requirement[1]] > requirement[3] when ">=" return false unless $game_variables[requirement[1]] >= requirement[3] when "<" return false unless $game_variables[requirement[1]] < requirement[3] when "<=" return false unless $game_variables[requirement[1]] <= requirement[3] when "!=" return false unless $game_variables[requirement[1]] != requirement[3] end end } return true end def current_item_enabled? return false if @data[index] == nil case @objects[@data[index]][0] when "skill_object" return true if enable_skill?(@objects[@data[index]], false) when "arrow_object" return true if enable_arrow?(@objects[@data[index]]) end return false end def current_skill_not_maxed? return false if @data[index] == nil case @objects[@data[index]][0] when "skill_object" return true unless @actor.est_skill_maxed?(@objects[@data[index]], @tree_id) end return false end def make_tree_data id = @actor.id if EME::SKILL_TREES::ACTOR_OR_CLASSES == 0 id = @actor.class_id if EME::SKILL_TREES::ACTOR_OR_CLASSES == 1 if @trees_per_actor[id] != nil if @trees_per_actor[id][@tree_id] != nil @data = @trees[@trees_per_actor[id][@tree_id]] elsif @trees_per_actor[@actor.id][0] != nil @tree_id = 0 @data = @trees[@trees_per_actor[id][@tree_id]] elsif @trees_per_actor[@actor.id][1] != nil @tree_id = 1 @data = @trees[@trees_per_actor[id][@tree_id]] elsif @trees_per_actor[@actor.id][2] != nil @tree_id = 2 @data = @trees[@trees_per_actor[id][@tree_id]] else @data = nil end else @data = nil end end def draw_item(index) if @data[index] != nil object = @objects[@data[index]] rect = item_rect(index) rect.width -= 4 if object[0] == "arrow_object" draw_icon(object[1], rect.x, rect.y, enable_arrow?(object)) elsif object[0] == "skill_object" skill_level = @actor.est_skill_level(object, @tree_id) skill_level_2 = [skill_level - 1, 0].max draw_icon($data_skills[object[1][skill_level_2]].icon_index, rect.x, rect.y, enable_skill?(object, false)) contents.font.size = 16 unless EME::SKILL_TREES::LEVEL_DISPLAY_TYPE == 0 unless @actor.est_skill_maxed?(object, @tree_id) if EME::SKILL_TREES::LEVEL_DISPLAY_TYPE == 1 draw_text(rect.x + 2, rect.y + 4, 24, line_height, skill_level.to_s) else max_skill_level = @actor.est_skill_max_level(object) draw_text(rect.x + 2, rect.y + 4, 24, line_height, skill_level.to_s+"/"+max_skill_level.to_s) end else draw_text(rect.x + 2, rect.y + 4, 24, line_height, "MAX") end end end end end def refresh make_tree_data create_contents #background = Cache.picture("Hintergrund") #rect = Rect.new(0,0,self.width, self.height) #contents.blt(0, 0, background, rect, 255) draw_all_items select_last end def update super end end#============================================================================## Scene_CustomSkillTrees#============================================================================class Scene_CustomSkillTrees < Scene_MenuBase#~ def start#~ super#~ @selwindow = Window_Tree_Selection.new#~ @selwindow.viewport = @viewport#~ @selwindow.opacity = 0#~ #~ @skill_tree_bg = Sprite.new#~ @skill_tree_bg.bitmap = Cache.picture("Hintergrund")#~ @skill_tree_bg.x = 0#~ @skill_tree_bg.y = 0#~ @skill_tree_bg.zoom_x = ( Graphics.width.to_f / 544 )#~ @skill_tree_bg.zoom_y = ( Graphics.height.to_f / 416 )#~ @skill_tree_bg.opacity = 255#~ @skill_tree_bg.visible = true #~ end def start super return_scene unless anyone_with_trees next_actor unless actor_has_trees create_skill_trees create_skill_trees_selection @skill_trees_selection.deactivate @skill_trees_selection.unselect @skill_tree.activate end def actor_has_trees if EME::SKILL_TREES::FIRST_SELECT_ACTOR and $game_party.menu_actor != nil actor = $game_party.menu_actor else if $game_party.members[$game_party.est_last_actor_index] != nil actor = $game_party.members[$game_party.est_last_actor_index] else actor = $game_party.members[0] end end hash = EME::SKILL_TREES::Trees_Per_Actor return (hash.has_key?(actor.id) and (hash[actor.id][0] != nil or hash[actor.id][1] != nil or hash[actor.id][2] != nil)) end def anyone_with_trees hash = EME::SKILL_TREES::Trees_Per_Actor $game_party.members.each{|member| return true if hash.has_key?(member.id) and (hash[member.id][0] != nil or hash[member.id][1] != nil or hash[member.id][2] != nil)} return false end def update super @skill_tree.active ? @last_window = "trees" : @last_window = "selection" any_change = false any_change_2 = false#~ if @info_window.skill_object != @skill_tree.objects[@skill_tree.data[@skill_tree.index]] and @skill_tree.objects[@skill_tree.data[@skill_tree.index]] != nil#~ @info_window.skill_object = @skill_tree.objects[@skill_tree.data[@skill_tree.index]]#~ any_change_2 = true#~ end#~ if @info_window.tree_id != $game_party.est_last_tree_id#~ @info_window.tree_id = $game_party.est_last_tree_id#~ any_change = true#~ end if @skill_tree.tree_id != $game_party.est_last_tree_id @skill_tree.tree_id = $game_party.est_last_tree_id any_change = true end if any_change @skill_tree.refresh @skill_tree.select_last#~ @info_window.skill_object = @skill_tree.objects[@skill_tree.data[@skill_tree.index]] @skill_tree.unselect end#~ @info_window.refresh if any_change or any_change_2#~ if Input.press?:)X)#~ @info_window.oy -= 2 unless @info_window.oy == 0#~ elsif Input.press?:)Y)#~ @info_window.oy += 2 unless @info_window.oy == @info_window.contents_height - @info_window.original_contents_height#~ end end def create_skill_trees @skill_tree = Window_CST_Trees.new($game_party.est_last_tree_id) @skill_tree.viewport = @viewport @skill_tree.set_handler:)ok, method:)learn_skill)) @skill_tree.set_handler:)cancel, method:)switch_to_selection)) @skill_tree.set_handler:)pageup, method:)actor_left)) @skill_tree.set_handler:)pagedown, method:)actor_right)) end def create_skill_trees_selection @skill_trees_selection = Window_CST_Selection.new @skill_trees_selection.actor_id = @skill_tree.actor.id if EME::SKILL_TREES::ACTOR_OR_CLASSES == 0 @skill_trees_selection.actor_id = @skill_tree.actor.class_id if EME::SKILL_TREES::ACTOR_OR_CLASSES == 1 @skill_trees_selection.clear_command_list @skill_trees_selection.make_command_list @skill_trees_selection.refresh @skill_trees_selection.viewport = @viewport @skill_trees_selection.set_handler:)ok, method:)switch_to_tree)) @skill_trees_selection.set_handler:)cancel, method:)return_scene)) @skill_trees_selection.set_handler:)pageup, method:)actor_left)) @skill_trees_selection.set_handler:)pagedown, method:)actor_right)) end def create_info_window#~ @info_window = Window_EST_Information.new#~ @info_window.actor = @skill_tree.actor#~ @info_window.tree_id = @skill_tree.tree_id#~ @info_window.skill_object = @skill_tree.objects[@skill_tree.data[@skill_tree.index]]#~ @info_window.refresh#~ @info_window.viewport = @viewport end def switch_to_tree @skill_trees_selection.deactivate @skill_trees_selection.unselect @skill_tree.activate @skill_tree.select_last end def switch_to_selection @skill_tree.deactivate @skill_tree.unselect @skill_trees_selection.activate id = @skill_tree.tree_id if EME::SKILL_TREES::ACTOR_OR_CLASSES == 0 id -= 1 if EME::SKILL_TREES::Trees_Per_Actor[@skill_tree.actor.id][1] == nil and id > 1 id -= 1 if EME::SKILL_TREES::Trees_Per_Actor[@skill_tree.actor.id][0] == nil else id -= 1 if EME::SKILL_TREES::Trees_Per_Actor[@skill_tree.actor.class_id][1] == nil and id > 1 id -= 1 if EME::SKILL_TREES::Trees_Per_Actor[@skill_tree.actor.class_id][0] == nil end @skill_trees_selection.select(id || 0) end def actor_left hash = EME::SKILL_TREES::Trees_Per_Actor $game_party.menu_actor = @skill_tree.actor loop do $game_party.menu_actor_prev id = $game_party.menu_actor.id break if (hash.has_key?(id) and (hash[id][0] != nil or hash[id][1] != nil or hash[id][2] != nil)) end @skill_tree.actor = $game_party.menu_actor if (@skill_trees_selection.actor_id != @skill_tree.actor.id and EME::SKILL_TREES::ACTOR_OR_CLASSES == 0) or (@skill_trees_selection.actor_id != @skill_tree.actor.class_id and EME::SKILL_TREES::ACTOR_OR_CLASSES == 1) @skill_trees_selection.actor_id = @skill_tree.actor.id if EME::SKILL_TREES::ACTOR_OR_CLASSES == 0 @skill_trees_selection.actor_id = @skill_tree.actor.class_id if EME::SKILL_TREES::ACTOR_OR_CLASSES == 1#~ @info_window.actor = @skill_tree.actor @actor = @skill_tree.actor @skill_tree.refresh @skill_trees_selection.refresh#~ @info_window.refresh $game_party.est_last_actor_index = $game_party.members.index(@skill_tree.actor) end @last_window == "trees" ? @skill_tree.activate : @skill_trees_selection.activate @skill_tree.unselect unless @skill_tree.active end def actor_right hash = EME::SKILL_TREES::Trees_Per_Actor $game_party.menu_actor = @skill_tree.actor loop do $game_party.menu_actor_next id = $game_party.menu_actor.id break if (hash.has_key?(id) and (hash[id][0] != nil or hash[id][1] != nil or hash[id][2] != nil)) end @skill_tree.actor = $game_party.menu_actor if (@skill_trees_selection.actor_id != @skill_tree.actor.id and EME::SKILL_TREES::ACTOR_OR_CLASSES == 0) or (@skill_trees_selection.actor_id != @skill_tree.actor.class_id and EME::SKILL_TREES::ACTOR_OR_CLASSES == 1) @skill_trees_selection.actor_id = @skill_tree.actor.id if EME::SKILL_TREES::ACTOR_OR_CLASSES == 0 @skill_trees_selection.actor_id = @skill_tree.actor.class_id if EME::SKILL_TREES::ACTOR_OR_CLASSES == 1#~ @info_window.actor = @skill_tree.actor @actor = @skill_tree.actor @skill_tree.refresh @skill_trees_selection.refresh#~ @info_window.refresh $game_party.est_last_actor_index = $game_party.members.index(@skill_tree.actor) end @last_window == "trees" ? @skill_tree.activate : @skill_trees_selection.activate @skill_tree.unselect unless @skill_tree.active end def learn_skill object = @skill_tree.objects[@skill_tree.data[@skill_tree.index]] unless @actor.est_skill_maxed?(object, @skill_tree.tree_id) current_element = 0 cost = 0 loop do if object[@actor.est_skill_level(object, @skill_tree.tree_id) + 2][current_element][0] == "points" cost = object[@actor.est_skill_level(object, @skill_tree.tree_id) + 2][current_element][1] break else current_element += 1 end end @actor.tree_points -= cost @actor.points_per_tree[@skill_tree.tree_id] += cost @actor.tree_skills[@skill_tree.tree_id].push(object[1][@actor.est_skill_level(object, @skill_tree.tree_id)]) previous_level = [@actor.est_skill_level(object, @skill_tree.tree_id) - 2, 0].max @actor.forget_tree_skill(object[1][previous_level]) unless @actor.est_skill_level(object, @skill_tree.tree_id) == 1 or @actor.est_learned_elswhere?(object[1][previous_level], @skill_tree.tree_id) @actor.learn_tree_skill(object[1][@actor.est_skill_level(object, @skill_tree.tree_id) - 1]) @skill_tree.refresh#~ @info_window.refresh @skill_tree.activate end endend
    Do you need more information? Did you add your bitmap on the same way i added mine?
    Thank you for the help!
  4. Err.. First is, I still don't get what you mean with tree item, did you mean the small icon skill in the left window? I can see that it's already have a small rectangle cursor on the left icon, then if the example above is not what you wanted, I'm sorry because I think I can't help you further because actually I'm quite busy at this time :( (I'm still working on my own script), but yes I make the slime bitmap the way you made :) .
     

    Code:
    background = Cache.picture("Hintergrund") # similar like thisrect = Rect.new(0,0,self.width, self.height)contents.blt(0, 0, background, rect, 255)
  5. Ok, so let's begin from scratch:

    I want to use a skill tree in my game. Therefore I discovered "Emeralds Skill Tree" script (link in my first post), but I wanted to use a sprite/bitmap isntead of the windowskin, to make it look like the first picture i posted in my first post. Like i showed in the second picture of my first post I managed to set a background picture.
    BUT the blinking cursor above the skill items (yes i mean the little icons in the second picture of my first post) is not visible. When I remove the background picture and let the window opacity at 0 the cursor is there. then it looks like this:



    So how do I let the cursor appear/be drawn in front of the bitmap I used as background?
    I hope it's clear now^^
  6. Hmm.. Okay that;s clear enough, but to do that I believe you need to do a work around. Right now I can't think a better method except this:
    You need to make a dummy window that act as a replacement for the real window(the window which you override with your bitmap thing), the dummy window should be a window selectable, exactly same like the real window, and all the mechanism must work the same like the real window, for example: if you press the down arrow and the cursor in real window will change to another skill below it, then your dummy window will do the same thing(act like this dummy fella also has that tree skill icon,  but without a method handler, because we don't need that right?). I talk about two window that active the same time. Remember, the cursor rect size in the dummy window must be same with the cursor rect size in the real window. Then the last thing to do is put your dummy window position exactly at the same position with the real window, and adjust it's "z"(you know the z value) bigger than the real window, so it will override the real window,(and the bitmap). After that turn the opacity to 0. That should do it I believe.