I was just wondering if its possible to wrap images and indent them like the wrapping done for the text? I am making a script where instead of text, I would be using images as selectable menu items. The first route I did to achieve this is to make sure that the vocab name of the menu is nil or simply "". Is there a way to substitute the wrapping to an image instead, so they automatically get placed when I change the col_max for example?
I've seen this made by Yami and Galv but I seem not to get the whole idea.
Image Wrapper from Text
● ARCHIVED · READ-ONLY
-
-
i think they draw it using
item_rect(index).x and item_rect(index).y.
for pointing where the image placed.
i do a little bit different with my phone script though. since i want to animate the 'image' up and down when hovering the choice.
and support multiple page (sprite don't like this >.<). this is the extra miles that i need to add >.<:
example window class from my EST - PHONE MENU ENGINE
class Window_PhoneCommand < Window_Command attr_accessor :need_redraw attr_reader :page include ESTRIOLE::pHONE def initialize(dx,dy,dw,dh,page) @height = dh @width = dw @dx = dx @dy = dy @page = page super(dx,dy) self.opacity = 0 self.z = PHONE_Z+30 create_phone_icons end def create_phone_icons(dispose = false) dispose_phone_icons if dispose @icons = {} @icons_posx = {} @icons_posy = {} for i in 0..$game_party.phone_menu(@page).size-1 @icons = Sprite.new @icons.bitmap = Cache.system(FOLDER_PATH+$game_party.phone_menu(@page)+".png") rescue Cache.system(FOLDER_PATH+"#{RESCUE_IMG}.png") @icons.x = @dx + item_rect(i).x + standard_padding @icons.y = @dy + item_rect(i).y + standard_padding @icons.z = PHONE_Z+31 @icons_posx = @icons.x @icons_posy = @icons.y @icons.color = Color.new(0, 0, 0, 100) if !command_enabled?(i) @icons.color = Color.new(0, 0, 0, 0) if command_enabled?(i) end @move_icon = 0 end def update super update_icon_animation if self.active == true end def dispose super dispose_phone_icons end def dispose_phone_icons for i in 0..@icons.size-1 @icons.bitmap.dispose if @icons && @icons.bitmap @icons.dispose if @icons @icons=nil end end def update_icon_animation if @need_redraw == true for i in 0..@icons.size-1 @icons.color = Color.new(0, 0, 0, 100) if !command_enabled?(i) @icons.color = Color.new(0, 0, 0, 0) if command_enabled?(i) && @icons end @need_redraw = false end return if !@icons[@index] @icons[@index].y=@icons[@index].y-1 if(@move_icon>=0&&@move_icon<=7) @icons[@index].y=@icons[@index].y+1 if(@move_icon>=8&&@move_icon<=15) @move_icon += 1 @move_icon=0 if @move_icon > 15 end def reset_icon_pos i = 0 @icons.each do |icon| @icons.x = @icons_posx @icons.y = @icons_posy i += 1 end @move_icon = 0 end alias est_phone_process_cursor_move process_cursor_move def process_cursor_move return if $imported["TH_SceneInterpreter"] == true && SceneManager.scene.interpreter.running? est_phone_process_cursor_move end alias est_phone_process_handling process_handling def process_handling return if $imported["TH_SceneInterpreter"] == true && SceneManager.scene.interpreter.running? est_phone_process_handling end#jet and vm mouse addon. but to change page still need use arrow keys.... alias est_jet_vm_update_mouse update_mouse rescue nil def update_mouse return if $imported["TH_SceneInterpreter"] == true && SceneManager.scene.interpreter.running? orig_index = @index est_jet_vm_update_mouse reset_icon_pos if @icons && @index != orig_index end def cursor_left(wrap = false) old_page = @page chk_index = @index chk_page = true if (chk_index % 16) ==0 && @page != 0 @page -= 1 if (chk_index % 16) ==0 && @page != 0 super(wrap = false) reset_icon_pos make_command_list if old_page !=@page refresh if old_page !=@page create_phone_icons(true) if old_page !=@page return unless chk_page select(15) end def cursor_right(wrap = false) old_page = @page chk_index = @index chk_page = true if (chk_index % 16) == 15 && @page != $game_party.phone_page_max @page += 1 if (chk_index % 16) == 15 && @page != $game_party.phone_page_max super(wrap = false) reset_icon_pos make_command_list if old_page !=@page refresh if old_page !=@page create_phone_icons(true) if old_page !=@page return unless chk_page select(0) end def cursor_up(wrap = false) old_page = @page chk_index = @index chk_page = true if (chk_index % 16) >= 0 && (chk_index % 16) <= 3 && @page != 0 @page -= 1 if (chk_index % 16) >= 0 && (chk_index % 16) <= 3 && @page != 0 super(wrap = false) reset_icon_pos make_command_list if old_page !=@page refresh if old_page !=@page create_phone_icons(true) if old_page !=@page return unless chk_page select(chk_index % 16 + 12) if chk_index % 16 >=0 && chk_index % 16 <= 3 end def cursor_down(wrap = false) old_page = @page chk_index = @index chk_page = true if (chk_index % 16) >= 12 && (chk_index % 16) <= 15 && @page != $game_party.phone_page_max @page += 1 if (chk_index % 16) >= 12 && (chk_index % 16) <= 15 && @page != $game_party.phone_page_max super(wrap = false) reset_icon_pos make_command_list if old_page !=@page refresh if old_page !=@page create_phone_icons(true) if old_page !=@page return unless chk_page select([chk_index % 16 - 12,@list.size-1].min) if chk_index % 16 >=12 && chk_index % 16 <= 15 end def make_command_list @list = $game_party.phone_menu(@page) @need_redraw = true end def command_name(index); @list[index]; end def item_width (window_width- 2 * standard_padding) / 4 end def item_height (window_height - 2 * standard_padding) / 4 end def window_width; return @width ;end def window_height; return @height;end def col_max 4 end def spacing return 0 end def standard_padding return 4 end def draw_item(index) change_color(normal_color, command_enabled?(index)) bitmap = Cache.system(FOLDER_PATH+$game_party.phone_menu(@page)[index]+".png") rescue Cache.system(FOLDER_PATH+"#{RESCUE_IMG}.png") rect_text = item_rect(index) rect_text.y += bitmap.height - 14 contents.font.size = 15 contents.font.bold = true draw_text(rect_text, command_name(index), 1) reset_font_settings bitmap.dispose end def current_item_enabled? return command_enabled?(index) end def command_enabled?(index) return true if !PHONE_ENABLE[@list[index]] return true if eval(PHONE_ENABLE[@list[index]]) return false end def ok_enabled? handle?:)ok) end def call_ok_handler;call_handler:)ok);end end#end class window phone commandit might not neat and perfect solution. but that's how i make it work. but you might want to see Yami and Galv implementation instead. because i put the sprite outside the windows. the problem is if i put it inside a window. it might get cutted when the icon animating up and down.
hope this help. -
I'll try to look at this later. Thanks for the help. I want to change my old implementation where I lazily just put the pictures there as planes.