Script Compability

Mithran

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
404
Reaction score
217
First Language
English
Primarily Uses
Looking much cleaner now  :thumbsup-right:


Some more syntax suggestions:


Use #size to get the number of elements in a hash or array. NOE is just Michael_Wndw_Bg_Ary.size.

if String(type_movement) == nil || 'show_all' || 'center'Always evaluates as true (or rather, 'show_all', which is implicit true for an if statement). String(anything) == nil is always false, since nil is not a string. So basically the statement returns the first object to evaluate as true, which is always 'show_all'. You can't string together evaluations like this, you have to compare each object separately.
Setting object like this (names have probably been changed in your most updated version):


@michael_windows_background_ftw_101 = Windows_Changer::Michael_Windows_Background_ftw_101_Array


You are essentially just copying the pointer to the array object into that variable. Anything done to the array in the instance variable will also be modifying the array in the constant, because it is the same array. The same is true for hash. You can use .dup or .clone to actually create a new copy, but it is a shallow copy (ie, for your hash you would need to dup the actual hash, as well as every array in the hash to avoid pollution). This is just FYI though, since the constant only seems to be used to set the initial value of this variable and never accessed afterwards.


For the interpreter methods, there are ways to shorten or eliminate that iteration, but it is performed so infrequently that it should be okay. I'd be happy to give some alternatives if you like, but you don't need to optimize unless there is an actual performance issue.

And I ended up only finding that those classes properties aren't in object pointers, so I'm stuck there and resorting to the updates since I'm still not sure how the Window / Sprite classes scripted and how versatile can ruby be.
I'm not really sure why you would be having trouble with this as this is exactly how I structured my script the one time I needed to do this. I can say that you wouldn't need to update the properties of your sub-sprites when a value is simply read from the window, only on the assignment methods. Not sure what you mean by object pointers in this context - yes, these properties are not stored in any conventional Ruby variable but in the metadata of the object itself, but there are accessor methods for all of them so that shouldn't be an issue.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Thanks for the input. I was feeling abit lazy with the string thingy. : p

I'll form my appropriate reply tomorrow. Got stuffs coming out.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Looking much cleaner now   :thumbsup-right:
Thanks, I was only doing casual coding, but I don't mind raising the bar a bit. :3

Use #size to get the number of elements in a hash or array. NOE is just Michael_Wndw_Bg_Ary.size.
That's pretty neat, but after looking into the source code, that method is doing more processes before getting into the required value, and since 

Setting object like this (names have probably been changed in your most updated version):@michael_windows_background_ftw_101 = Windows_Changer::Michael_Windows_Background_ftw_101_Array

You are essentially just copying the pointer to the array object into that variable. Anything done to the array in the instance variable will also be modifying the array in the constant, because it is the same array. The same is true for hash. You can use .dup or .clone to actually create a new copy, but it is a shallow copy (ie, for your hash you would need to dup the actual hash, as well as every array in the hash to avoid pollution). This is just FYI though, since the constant only seems to be used to set the initial value of this variable and never accessed afterwards.
I prefer the user to add the array's element manually to be familiar with how each value works, rather than to have the script to automatically detect existing classes and do the .dup / .clone method, which means I would have the user to enter the class type instead of number to use the script. For ex:

Script: window_on(Window_Base, 'test.png') , but then again this is just my philosophy. I might add the feature to let the users to decide which type of input they would like to use later (auto_way::use_object_class or manual_way::use_integer).

static VALUErb_hash_size(VALUE hash){if (!RHASH(hash)->ntbl)return INT2FIX(0);return INT2FIX(RHASH(hash)->ntbl->num_entries);}
Always evaluates as true (or rather, 'show_all', which is implicit true for an if statement). String(anything) == nil is always false, since nil is not a string. So basically the statement returns the first object to evaluate as true, which is always 'show_all'. You can't string together evaluations like this, you have to compare each object separately.
Fixed, thanks for pointing out. I was tripping due to lost of patience. : D

For the interpreter methods, there are ways to shorten or eliminate that iteration, but it is performed so infrequently that it should be okay. I'd be happy to give some alternatives if you like, but you don't need to optimize unless there is an actual performance issue.
Thanks, that would be great, I just skimmed through the available methods of hash class real quick just to find which could work regardless efficiency. I had some thought on reducing the hash simplicity, but I wasn't in the mood to do some trial-error.

I'm not really sure why you would be having trouble with this as this is exactly how I structured my script the one time I needed to do this. I can say that you wouldn't need to update the properties of your sub-sprites when a value is simply read from the window, only on the assignment methods. Not sure what you mean by object pointers in this context - yes, these properties are not stored in any conventional Ruby variable but in the metadata of the object itself, but there are accessor methods for all of them so that shouldn't be an issue. 
Fixed, I forgot to add another property. : D

#==============================================================================## Michael Windows Changer# Last Updated: 2014.01.07# Requirement: RPG Maker VX Ace# -Knowledge of 'how to use scripts'# -Knowledge of Window Designation (basically know which window is# which)##==============================================================================#==============================================================================#Compability: - Script should be compatible with any other script(s).# - If the picture you use doesn't have the right size as the# window's size, then use window_show_all to show picture in full size,# then move it using window_show_all_move.# - Bitmap cannot convert .gif file yet.##==============================================================================#==============================================================================#Credit:# - Big thanks to Mithran for the efficiency check and error analyzis# - Other scripters joining the discussion#==============================================================================#==============================================================================# Biography lol#==============================================================================# 2013.01.07 --FLICKER GOODBYE - flicker bug is fixed. 100% working. Taking a break from this script# 2013.01.06 --Increaseeeeeeeeeeeeddddddd readibility. .______________________.# --File is trimmed down and readibility is increased - Credit to Mithran# 2013.01.05 --File is trimmed down# 2013.01.03 --window_show_all and window_move_origin and their counter-parts# are introduced# --Reforming the arrays# --Increased readibility :/# 2013.01.02 --Naming convention is improved# --Some methods are simplified# --File is trimmed down# --@temp1 & @temp2 variables are removed# --Replacing switch on the windows itself instead of scenes# 2013.01.01 --window_opacity(i, opacity) is introduced# 2013.12.30 --Trimmed down the file size# 2013.12.27 --Fixed window_default(i)# --window_depth(i, depth) is introduced & implemented# --Fixed window_default(i) and window_center(i) is introduced# --Fixed Scene_File# 2013.12.26 --Fixed Scene_Title - Sprite is now in correlation with the window# --Raising Compatibility# --window_move(i, x, y, width, height) is introduced# --window_default(i) is introduced# --All Scenes are overloaded with the new switch# 2013.12.25 --Fixed bugs on local @temp1 and @temp2 disposal# --Scene_MenuBase is added# --Fixed bugs for 'name'# --Fixed bugs on various Scenes# 2013.12.24 --Script is uploaded# 2013.12.23 --Window_Message is completed# 2013.12.22 --Scene_Equip is completed# --Scene_Skill is completed# --Scene_Item is completed# --Scene_ItemBase is completed# --Scene_Menu is completed# --Scene_Map is completed# --Scene_Title is completed# --Scene_Menu is completed# --All Scenes that need to be overloaded have been overloaded# --Updating array to store image name# 2013.12.21 --Installing Game_Interpreter# --Scene_Battle is completed# --Scene_Debug is completed# --Scene_Name is completed# --Scene_Shop is completed# --Scene_End is completed# --Scene_Save and Scene_Load skipped -- No Window yield# --Scene_File is completed# --Scene_Status is completed# 2013.12.20 --Scene_Battle is completed# 2013.12.19 --Works for Windows_BattleStatus# 2013.12.18 --Script is initialized -- Getting know Ruby + RGSS Libraries#==============================================================================# Description#==============================================================================# This script is used to stick image(s) to windows with your desired image(s)# by overloading all windows. You can also edit it's location.##==============================================================================# Installation#==============================================================================# - This script will OVERLOAD all DEFAULT windows.# - To overload additional windows, add them to the big array manually.# - Place this script to be below other overloading windows script. If you are# not sure where, place it to be the lowest of the material section.# - If you have a bust script, put the bust script anywhere below this script.# - Place the window Images (by default) in that folder# <your project>/Graphics/Windows/(type of windows)/##==============================================================================# How to Use:# - window_on(window #, 'file_name.extention_name')# For Example:# window_on(6, 'ex.jpg') -> activate window #6 background(window_gold_changer)# with ex.jpg as the content# -> Btw, window #6 is Window_Gold# -> If you want to change the picture, just do the same# thing, but use different file_name.## - window_off(window #)# For Example:# window_off(5) -> deactivate window #5 background and its content# -> deactivating will hide the background and return the# window rectangle back to the boring blue color with its# redundant white padding.## - window_show_all(i) -> JUST USE THIS COMMAND and window_on if you're confused with# coordination. Basically window_show_all will display# your picture from the center of the window.# -> Do I have to use this for every picture that's oversized?# -> No, just do window_on(6, 'ex.jpg', 'show_all') <<< see the 'show_all'?# (don't forget the quotation mark)# - window_show_all_move(i, x, y) -> To move the fixed position## - window_center(i)# For Example:# window_center(6) -> Move the window #6 background content to center position# Default position is at the center (272,208) of the graphic and# occupy the size of the graphic (if your picture has size# larger than the graphic (544 x 416), it will fill the graphic)# -> Make sure that switch is 'on' or else nothing would happen.## - window_move_full(i, x, y, width, height)# For Example:# window_move_full(6, 24, -24, 400, 400)# -> TIPS: If you are not sure how to adjust, the coordinate, starts with# window_move first.# -> move the window #6 background content to (24,-24) position. Remember that# center coordinate is (0,0) and to move up, y needs to be negative, to move# down, y needs to be positive, to move left, x needs to be negative, to move# right, x needs to be positive.# -> width and height are there as a border to make sure that your picture doesn't# go beyond the given size (400 x 400).# -> TIPS: If you don't want to have border, simply set the border to be the# Graphics' height and width.# To set Graphics' height and width:# window_move(5, 24, -24, Graphics.width, Graphics.height)## - window_default(i)# For Example:# window_default(6) -> Turn off movement switch for window #6 background# -> This will return window #6 to the original position## - window_depth(i, depth)# For Example:# window_depth(6, -1) -> Increases the depthness of window #6 background content# by -1, which means, if there's other window background# in the graphic beside window #6 background, that window# background will appear to be above window #6 background.# -> Make sure that switch is 'on' or else nothing would happen.## - window_opacity(i, opacity)# For Example:# window_opacity(6, 0) -> Set window #6 background opacity to 0 (100% transparent).# -> Opacity value is from 0 (fully see-through) to 255 (solid).# -> Make sure that switch is 'on' or else nothing would happen.# -> Default opacity is 255 when window background is on.## Have Fun!##==============================================================================module Wndw_Cgr #Window Changer #============================================================================ # Windows Changer = USE Game_Interpret for activation (scroll all the way # down for the key words (window_on and window_off)) # Use the element # list below for 'window #'. # # Default Switch = off (switch only available for activate windows) # This is for Original Windows - Scroll Down for Windows from other scripts # the array stores these values: # [window number, # file_name, # file_directory, # sprite.z, # sprite.opacity, # sprite.type_of_movement_change, # sprite.x, # sprite.y, # sprite.src_rect.x, # sprite.src_rect.y, # sprite.src_rect.width, # sprite.src_rect.height] #============================================================================ Michael_Wndw_Bg_Ary = { #Window Background Array Window => [0,"Element #0","Graphics\\Windows",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Base => [1,"Element #1","Graphics\\Windows\\Window_Base",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Selectable => [2,"Element #2","Graphics\\Windows\\Window_Selectable",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Command => [3,"Element #3","Graphics\\Windows\\Window_Command",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_HorzCommand => [4,"Element #4","Graphics\\Windows\\Window_HorzCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Help => [5,"Element #5","Graphics\\Windows\\Window_Help",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Gold => [6,"Element #6","Graphics\\Windows\\Window_Gold",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_MenuCommand => [7,"Element #7","Graphics\\Windows\\Window_MenuCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_MenuStatus => [8,"Element #8","Graphics\\Windows\\Window_MenuStatus",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_MenuActor => [9,"Element #9","Graphics\\Windows\\Window_MenuActor",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ItemCategory => [10,"Element #10","Graphics\\Windows\\Window_ItemCategory",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ItemList => [11,"Element #11","Graphics\\Windows\\Window_ItemList",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_SkillCommand => [12,"Element #12","Graphics\\Windows\\Window_SkillCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_SkillStatus => [13,"Element #13","Graphics\\Windows\\Window_SkillStatus",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_SkillList => [14,"Element #14","Graphics\\Windows\\Window_SkillList",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_EquipStatus => [15,"Element #15","Graphics\\Windows\\Window_EquipStatus",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_EquipCommand => [16,"Element #16","Graphics\\Windows\\Window_EquipCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_EquipSlot => [17,"Element #17","Graphics\\Windows\\Window_EquipSlot",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_EquipItem => [18,"Element #18","Graphics\\Windows\\Window_EquipItem",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Status => [19,"Element #19","Graphics\\Windows\\Window_Status",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_SaveFile => [20,"Element #20","Graphics\\Windows\\Window_SaveFile",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ShopCommand => [21,"Element #21","Graphics\\Windows\\Window_ShopCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ShopBuy => [22,"Element #22","Graphics\\Windows\\Window_ShopBuy",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ShopSell => [23,"Element #23","Graphics\\Windows\\Window_ShopSell",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ShopNumber => [24,"Element #24","Graphics\\Windows\\Window_ShopNumber",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ShopStatus => [25,"Element #25","Graphics\\Windows\\Window_ShopStatus",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_NameEdit => [26,"Element #26","Graphics\\Windows\\Window_NameEdit",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_NameInput => [27,"Element #27","Graphics\\Windows\\Window_NameInput",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ChoiceList => [28,"Element #28","Graphics\\Windows\\Window_ChoiceList",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_NumberInput => [29,"Element #29","Graphics\\Windows\\Window_NumberInput",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_KeyItem => [30,"Element #30","Graphics\\Windows\\Window_KeyItem",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Message => [31,"Element #31","Graphics\\Windows\\Window_Message",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ScrollText => [32,"Element #32","Graphics\\Windows\\Window_ScrollText",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_MapName => [33,"Element #33","Graphics\\Windows\\Window_MapName",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleLog => [34,"Element #34","Graphics\\Windows\\Window_BattleLog",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_PartyCommand => [35,"Element #35","Graphics\\Windows\\Window_PartyCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ActorCommand => [36,"Element #36","Graphics\\Windows\\Window_ActorCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleStatus => [37,"Element #37","Graphics\\Windows\\Window_BattleStatus",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleActor => [38,"Element #38","Graphics\\Windows\\Window_BattleActor",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleEnemy => [39,"Element #39","Graphics\\Windows\\Window_BattleEnemy",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleSkill => [40,"Element #40","Graphics\\Windows\\Window_BattleSkill",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleItem => [41,"Element #41","Graphics\\Windows\\Window_BattleItem",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_TitleCommand => [42,"Element #42","Graphics\\Windows\\Window_TitleCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_GameEnd => [43,"Element #43","Graphics\\Windows\\Window_GameEnd",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_DebugLeft => [44,"Element #44","Graphics\\Windows\\Window_DebugLeft",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_DebugRight => [45,"Element #45","Graphics\\Windows\\Window_DebugRight",nil,nil,nil,nil,nil,nil,nil,nil,nil], } #Add more elements here NOE = 46 #NUMBER_OF_ELEMENT #Modify this number as more elements are added SSP = 500 #STARTING_SWITCH_POINT #Modify this number if script clash with other script(s)end#==============================================================================# Cache#==============================================================================module Cache def self.cache_extended(folder, filename) load_bitmap("#{folder}/", "#{filename}") endend#==============================================================================# Window#==============================================================================class Window attr_accessor :oh_I_got_changed attr_accessor :michael_bg_vp attr_accessor :michael_bg_sp alias michael_Window_initialize initialize alias michael_Window_update update alias michael_Window_dispose dispose def initialize(x, y, width, height) self.oh_I_got_changed = false create_michael_bg_sp michael_Window_initialize(x, y, width, height) create_michael_bg_vp self.michael_bg_sp.michael_sp_updt(self, $game_message.michael_wndw_bg_ary[self.class]) end def create_michael_bg_vp #Naming convention ftw self.michael_bg_vp = Viewport.new #The only locations where new member functions are created self.michael_bg_vp.z = self.z - 1 #are class Window_Base, class Sprite, module Cache end #and class Game_Interpreter. Everything else is aliased. def create_michael_bg_sp self.michael_bg_sp = Sprite.new end #Everything is disposed here def dispose #Basically every window made, self.michael_bg_sp.dispose #1 viewport and 1 sprite are also made self.michael_bg_vp.dispose michael_Window_dispose end def did_I_get_changed? return self.oh_I_got_changed end def change_me_by_michael self.oh_I_got_changed = true end def update michael_Window_update self.michael_bg_sp.michael_sp_updt(self, $game_message.michael_wndw_bg_ary[self.class]) end alias testing_visibility visible= def visible=(arg) self.testing_visibility(arg) self.michael_bg_sp.visible = (self.open? && self.visible) end alias testing_openness openness= def openness=(arg) self.testing_openness(arg) self.michael_bg_sp.visible = (self.open? && self.visible) end alias testing_x x= def x=(arg) self.testing_x(arg) self.michael_bg_sp.x = arg end alias testing_y y= def y=(arg) self.testing_y(arg) self.michael_bg_sp.y = arg end alias testing_width width= def width=(arg) self.testing_width(arg) self.michael_bg_sp.src_rect.width = arg end alias testing_height height= def height=(arg) self.testing_height(arg) self.michael_bg_sp.src_rect.height = arg end alias testing_width123 width def width self.michael_bg_sp.src_rect.width = self.testing_width123 self.testing_width123 end alias testing_height123 height def height self.michael_bg_sp.src_rect.height = self.testing_height123 self.testing_height123 endend#==============================================================================# Sprite#==============================================================================class Sprite #Another hidden script ftw! def michael_sp_updt(window, i) $game_switches[Wndw_Cgr::SSP + i[0]] ? michael_bg_on(window,i) : michael_bg_off(window, i) end def michael_bg_on(window, i) michael_set_self_vp(window) michael_save_wndw_opa(window) unless window.did_I_get_changed? michael_clear_wndw_opa(window) michael_set_self_ppts(window, i) #SET SELF'S PROPERTIES michael_modify_self(window, i) unless i[5].nil? end def michael_set_self_vp(window) self.viewport = (window.viewport) ? window.viewport : window.michael_bg_vp end def michael_save_wndw_opa(window) @michael_wndw_b_opa = window.back_opacity unless window.back_opacity.nil? @michael_wndw_opa = window.opacity unless window.opacity.nil? end def michael_clear_wndw_opa(window) window.back_opacity = 0 unless window.back_opacity.nil? window.opacity = 0 unless window.opacity.nil? window.change_me_by_michael end def michael_set_self_ppts(window, i) self.x = window.x self.y = window.y self.src_rect.width = window.width self.src_rect.height = window.height self.visible = ((window.openness == 255) && (window.visible)) #This is where picture is loaded name = i[1] folder = i[2] self.bitmap = Cache.cache_extended(folder, name) self.z += i[3] unless i[3].nil? self.opacity = i[4] if (self.visible) && !(i[4].nil?) end def michael_modify_self(window, i) case i[5] when 'show_all' self.x -= ((self.bitmap.width - window.width) / 2) self.src_rect.x = 0 if self.x < 0 self.y -= ((self.bitmap.height - window.height) / 2) self.src_rect.y = 0 if self.y < 0 self.src_rect.width = Graphics.width self.src_rect.height = Graphics.height when 'move' self.x += (i[6] - ((self.bitmap.width - window.width) / 2)) self.src_rect.x = 0 if self.x < 0 self.y += (i[7] - ((self.bitmap.height - window.height) / 2)) self.src_rect.y = 0 if self.y < 0 self.src_rect.width = Graphics.width self.src_rect.height = Graphics.height when 'move_origin' self.x += i[6] self.src_rect.x = 0 if self.x < 0 self.y += i[7] self.src_rect.y = 0 if self.y < 0 when 'center' self.x = (Graphics.width - self.bitmap.width) / 2 self.src_rect.x = 0 if self.x < 0 self.y = (Graphics.height - self.bitmap.height) / 2 self.src_rect.y = 0 if self.y < 0 self.src_rect.width = Graphics.width self.src_rect.height = Graphics.height when 'move_all' self.x = i[6] self.y = i[7] self.src_rect.x = i[8] self.src_rect.y = i[9] self.src_rect.width = i[10] self.src_rect.height = i[11] end end def michael_bg_off(window, i) self.visible = false window.oh_I_got_changed = false if ((window.openness == 255) && window.visible) window.back_opacity = @michael_wndw_b_opa unless @michael_wndw_b_opa.nil? window.opacity = @michael_wndw_opa unless @michael_wndw_opa.nil? end endend#==============================================================================# Game_Message#==============================================================================class Game_Message attr_accessor :michael_wndw_bg_ary alias michael_ini initialize def initialize michael_ini @michael_wndw_bg_ary = Wndw_Cgr::Michael_Wndw_Bg_Ary endend#==============================================================================# Creating Directory#==============================================================================module DataManager class << self alias michael_dt_mngr_init init end def self.init michael_dt_mngr_init create_Wndw_Cgr_directory end def self.create_Wndw_Cgr_directory $game_message.michael_wndw_bg_ary.each_value { |value| Dir.mkdir(value[2]) if !File.exists?(value[2]) } endend#===============================================================================# DataManager#===============================================================================module DataManager class << self alias michael_Scene_Battle_create_game_objects create_game_objects end def self.create_game_objects michael_Scene_Battle_create_game_objects #Default setting = false $game_switches[Wndw_Cgr::SSP...Wndw_Cgr::SSP + Wndw_Cgr::NOE] = false endend#===============================================================================# Game Interpreter#===============================================================================class Game_Interpreter def window_off(i) $game_switches[i + Wndw_Cgr::SSP] = false window_default(i) end def window_on(i, name, type_movement = nil) $game_switches[i + Wndw_Cgr::SSP] = true $game_message.michael_wndw_bg_ary.each_value { |value| value[1] = "#{name}" if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = (type_movement.nil?) ? nil : (String(type_movement) == 'show_all' || 'center') ? String(type_movement) : nil if value[0] == i } end def window_depth(i, depth) $game_message.michael_wndw_bg_ary.each_value { |value| value[3] = depth if value[0] == i } end def window_opacity(i, opacity) $game_message.michael_wndw_bg_ary.each_value { |value| value[4] = opacity if value[0] == i } end def window_default(i) $game_message.michael_wndw_bg_ary.each_value { |value| value[3] = nil if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[4] = nil if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = nil if value[0] == i } end def window_show_all(i) $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = 'show_all' if value[0] == i } end def window_show_all_move(i, x, y) $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = 'move' if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[6] = x if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[7] = y if value[0] == i } end def window_move_origin(i,x,y) $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = 'move_origin' if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[6] = x if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[7] = y if value[0] == i } end def window_center(i) $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = 'center' if value[0] == i } end def window_move_all(i, x, y, rect_x, rect_y, rect_width, rect_height) $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = 'move_all'if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[6] = x if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[7] = y if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[8] = rect_x if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[9] = rect_y if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[10] = rect_width if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[11] = rect_height if value[0] == i } endend 
Basically, I missed out the def openness=, but it's there now. : D

I had to include def width, since def width=(arg) doesn't cover all changes on window.width, same goes with height. def x= and def y= work fine though, so I cleared out def x and def y.
 

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
Users would always seek the easiest/fastest way for them... XD
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Dang, man. : p

Oh well, I'll pick this script later to add the auto-detect and auto-create (at least auto-movement is there). I would like to play around with other scripts. Eating the same food everyday would get me sick anyway.

Edit:

I prob. would need to put the show-me-which-window-this-is feature also. How spoiled. (envy) ; _ ;
 
Last edited by a moderator:

Mithran

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
404
Reaction score
217
First Language
English
Primarily Uses
Heh, you'll drive yourself crazy if you worry about every little operation, especially when using Ruby.

I prefer the user to add the array's element manually to be familiar with how each value works, rather than to have the script to automatically detect existing classes and do the .dup / .clone method, which means I would have the user to enter the class type instead of number to use the script. For ex:

Script: window_on(Window_Base, 'test.png')

, but then again this is just my philosophy. I might add the feature to let the users to decide which type of input they would like to use later (auto_way::use_object_class or manual_way::use_integer).
I'm not exactly sure what you mean here. I meant that you should clone your containers when passing them into new variables or any modifications made to the container in the new variable will also happen in the original variable, because they are still the same object.eg., :

a = [1, 2, 3]b = a.dupb[0] = 5print a[0] # => 1vs:
Code:
a = [1, 2, 3]b = ab[0] = 5print a[0] # => 5
It doesn't look to be an issue here, though, because it only sets the initial value of a variable (it would be an issue if you assumed all windows would reset to default specs when you End Game > Return to Title).Having the user manually input the number of elements doesn't really solve anything, either way. It seems the value is only used when setting the initial value of a range of switches, which all start at false anyway, so the user could put the wrong number here and it wouldn't change a thing.

This:

(String(type_movement) == 'show_all' || 'center')Still never considers 'center'. You could compare them separately, or use a regexp:
Code:
(type_movement == 'show_all' || type_movement == 'center')
(removed String since you already handled nil and the user should know if they are passing bad values)
Code:
type_movement =~ /\A(show_all|center)\Z/
(very restrictive regexp)The rest of the expression looks okay, if you want it to dump values other than 'show_all' or 'center'.

As for 'width' and 'height' read methods actually altering the values, I think what is actually happening is that you are not syncing sprite x/y/width/height after initialization. Since create_contents checks both, the sync would happen before the window is visible to you. The actual creation is the only method other than the assignment methods that can alter the metadata where the values are stored, save direct memory manipulation. You could pass the arguments into the sprite creation method and just handle it there.

Anyway, the script has been fine for a while. If you want to resubmit it I will approve it, or if you want I can modify your old submission with the current script and approve that one.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
As for 'width' and 'height' read methods actually altering the values, I think what is actually happening is that you are not syncing sprite x/y/width/height after initialization. Since create_contents checks both, the sync would happen before the window is visible to you. The actual creation is the only method other than the assignment methods that can alter the metadata where the values are stored, save direct memory manipulation. You could pass the arguments into the sprite creation method and just handle it there.
[start_rant]I wish to know what's inside the kitchen so badly now, with the partial library, multiple trial-errors, and guess works had to be done before I could achieve where I want to be, I feel like as if I'm coding blindfolded. May I have the full library version? Moar control please. : (  [\end_rant]

K, I removed the def width, and def height (leaving def width= and def height=), then I tried to do the following:

def initialize(x, y, width, height) self.oh_I_got_changed = false create_michael_bg_sp michael_Window_initialize(x, y, width, height) create_michael_bg_vp self.michael_bg_sp.michael_sp_updt(self, $game_message.michael_wndw_bg_ary[self.class], self.x, self.y, self.width, self.height) endAnd tried again without the self#, it still doesn't show any love to me. My I know which arguments you are referring to?

Anyway, the script has been fine for a while. If you want to resubmit it I will approve it, or if you want I can modify your old submission with the current script and approve that one. Thanks, though I felt like I left this half-done. I need to add the auto-detect-window-functionality using

Window.decendantsthen do dup / clone / push to add/update new element to the hash as I'd be adding more interpreter. I'll figure out how to implement that later. I'll post another version later, you'll see what I meant by the dup/clone method. I'll be adding extra 'layers' functionality with color implementation so that user can just use a blank color picture template and set the color, so that they don't need to make the similar pictures over and over with different color in the picture folder. I feel like as if I'm installing simple photoshop on RM.

Still never considers 'center'. You could compare them separately, or use a regexp:
Haha, thanks for the check, coding with high-level language could make you lazy at times. : D

Above all, please delete my old submission, I don't even know how it looks like now, and beside I'll be adding more features on this script to make it more powerful. I'll keep this thread updated in case I'm confused with RGSS. Thanks for your patience and suggestions, Mithram. It clears up a lot of my doubt on syntax and functionality.
 

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
what I normally do with windows is


self.x = x


self.y = y


@width = width


@height = height


def window_width


@width


end


def window_height


@height


end


though maybe


self.height and self.width might work too... XD
 

Mithran

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
404
Reaction score
217
First Language
English
Primarily Uses
K, I removed the def width, and def height (leaving def width= and def height=), then I tried to do the following:

def initialize(x, y, width, height)

self.oh_I_got_changed = false

create_michael_bg_sp

michael_Window_initialize(x, y, width, height)

create_michael_bg_vp

self.michael_bg_sp.michael_sp_updt(self, $game_message.michael_wndw_bg_ary[self.class], self.x, self.y, self.width, self.height)

end

And tried again without the self#, it still doesn't show any love to me. My I know which arguments you are referring to?
I just meant that when you create the sprite, you should the properties there, too. Eg.,
def initialize(x, y, width, height) self.oh_I_got_changed = false create_michael_bg_sp(x, y, width, height) # passing these arguments since this is before the metadata is initialized michael_Window_initialize(x, y, width, height) create_michael_bg_vp self.michael_bg_sp.michael_sp_updt(self, $game_message.michael_wndw_bg_ary[self.class], self.x, self.y, self.width, self.height) end def create_michael_bg_sp(x, y, width, height) s = self.michael_bg_sp = Sprite.new s.x, s.y, s.width, s.height = x, y, width, height endI don't think there is any funny business with initialize modifying the given values before creating the window, but if that was the case you would want to create the sprite after the alias and instead of passing arguments just use the actual window properties. Also remember that width and height of a Sprite are just the src_rect width and height within the bitmap, so you are still limited by the bitmap and maybe thats why you are not ending up with what you expect. Either way, calling just window.width should never actually change the width of the window, so there is probably some other variable that needs to be isolated there. What behavior is making you think that the read methods are actually altering something? I'll run a test myself to help you isolate it if you tell me what I am looking for.
Thanks, though I felt like I left this half-done. I need to add the auto-detect-window-functionality using

Window.decendants
There is no default functionality to check descendants so you'd have to implement that too. I see what you mean now, though. That would totally deprecate using any kind of id-based system, since there would be no way for a user know what id is associated with what at runtime.
Above all, please delete my old submission.
Removed it from pending approvals as soon as I saw all those rescue blocks and posted here =P. I can restore stuff, though, in case you wanted to save the post formatting.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
I don't think there is any funny business with initialize modifying the given values before creating the window, but if that was the case you would want to create the sprite after the alias and instead of passing arguments just use the actual window properties. Also remember that width and height of a Sprite are just the src_rect width and height within the bitmap, so you are still limited by the bitmap and maybe thats why you are not ending up with what you expect. Either way, calling just window.width should never actually change the width of the window, so there is probably some other variable that needs to be isolated there. What behavior is making you think that the read methods are actually altering something? I'll run a test myself to help you isolate it if you tell me what I am looking for.
It's window_help, and window_gold.

The width doesn't work with window_gold.

The height and width doesn't work on window_help.

The rest seems fine.

Though by adding:

alias testing_width123 width def width self.michael_bg_sp.src_rect.width = self.testing_width123 self.testing_width123 end alias testing_height123 height def height self.michael_bg_sp.src_rect.height = self.testing_height123 self.testing_height123 end It got the size fine. And then I delete them, then tried that initialization before alias, still no luck. :c

Even after modifying the update

def michael_set_self_ppts(window, i) #self.x = window.x #Put as comment to avoid conflict with #self.y = window.y #initialization. #self.src_rect.width = window.width #self.src_rect.height = window.height self.visible = ((window.open?) && (window.visible)) #This is where picture is loaded name = i[1] folder = i[2] self.bitmap = Cache.cache_extended(folder, name) self.z += i[3] unless i[3].nil? self.opacity = i[4] if (self.visible) && !(i[4].nil?) end
There is no default functionality to check descendants so you'd have to implement that too. I see what you mean now, though. That would totally deprecate using any kind of id-based system, since there would be no way for a user know what id is associated with what at runtime.
I'll let the users to use a nickname to access the hash if typing Window_Selectable is too long for them. : 3

Removed it from pending approvals as soon as I saw all those rescue blocks and posted here =P. I can restore stuff, though, in case you wanted to save the post formatting. 
Thanks for letting me know. xD

Editing the old template might takes longer than creating another one though since I've removed some interpreter and change some of the interpreter functionality, which means I gotta re-explain them. So yea. I'll post another version tomorrow. 
 
Last edited by a moderator:

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
what are you actually trying to do? Making a user configurable size set-up for the windows and show pics in it?
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
It will do this. What it has for now is auto-movement setting, opacity, and depth. If you don't want color, then just add any file and set opacity to 0.

http://i.imgur.com/PZqWsCZ.jpg?1

I'll add feature so user can color it, add more frames, and stuffs. And maybe animation. :3

Edit: I might work on the window location, but for now, I'd like to focus on Sprite.

Edit: Tbh, just because I missed to override the def openness=, I just killed a week and a half just trying to find alternative ways to keep the sprite in coordination with the window, which resulting this thread.
 
Last edited by a moderator:

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
what auto-movement?
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Basically, when you set up the image, if it's too large, the default setting will crop the image as the size of the window, but I've enable feature to show picture in full size, but then again, it will be cut a portion of the sprite that overlap the x and y of the sprite, so I put adjustment that they won't be cropped, but the placement doesn't look that great, so I adjust the show all feature so that the center of the picture will be moved at the center of the window by manipulating x and y, and if x and y become negative, Sprite won't be displayed by graphic, so I put a counter on that, but that would be auto-show. : D
 

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
why not just stretch_blt the picture into the bitmap?


or you can also opt to make a new sprite and bitmap for that window that has a size of 544,416 so that you have the whole screen... then just blt or strech_blt the pics into it
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
why not just stretch_blt the picture into the bitmap?

or you can also opt to make a new sprite and bitmap for that window that has a size of 544,416 so that you have the whole screen... then just blt or strech_blt the pics into it
Do blt and stretch_blt let the bitmap pass the x and y limit of the sprite?

Never mind. You mean having sprite.x and sprite.y at 0, and just move the bitmap? Do you have implementation samples?

For Ex:

Window_properties = 50, 100, 200, 200 (x,y,w,h)

bitmap_size = 250 * 400

How would you implement blt / strech_blt?
 
Last edited by a moderator:

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
IDK, but you can always set the x,y to 0,0 (is that even needed or is it defaulted to 0?) and sprite.bitmap size to 544,416 so that you can theoretically print any picture anywhere on the screen


like if you want to put a picture that starts the middle of the screen:


spr = Sprite.new


spr.bitmap = Bitmap.new(544,416)


bit = Cache.pictures(picture file)


rect = Rect.new(0,0,bit.width,bit.height)


spr.bitmap.blt(Graphics.width/2,Graphics.height/2,bit,rect)


then just adjust spr.z if needed
 
Last edited by a moderator:

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
But you're putting the picture at the center of the graphic, not at the center of the 'selected window'.

Edit: Nvm, got what you mean, though I prefer to do to do more calculation rather than initializing new object (rect).

when 'show_all' self.x -= ((self.bitmap.width - window.width) / 2) self.src_rect.x = 0 if self.x < 0 self.y -= ((self.bitmap.height - window.height) / 2) self.src_rect.y = 0 if self.y < 0 self.src_rect.width = Graphics.width self.src_rect.height = Graphics.height when 'center' self.x = (Graphics.width - self.bitmap.width) / 2 self.src_rect.x = 0 if self.x < 0 self.y = (Graphics.height - self.bitmap.height) / 2 self.src_rect.y = 0 if self.y < 0 self.src_rect.width = Graphics.width self.src_rect.height = Graphics.heightEdit: Btw, since x and y  mean the top-left corner of the screen, wouldn't 

spr.bitmap.blt(0,0,bit,rect)fits the bill better since

spr.bitmap.blt(Graphics.width/2,Graphics.height/2,bit,rect)would put the top left corner at the center of the graphic instead of the top-left corner of the graphic.
 
Last edited by a moderator:

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
That is just an EXAMPLE bro... you can always find the center of any window instead of the center of the Game...
 
Last edited by a moderator:

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Yea, I've updated my post shortly after I realized that.

Edit:

Found another way:

Code:
    when 'show_all'      self.x = self.y = 0      self.src_rect.set(window.x - ((self.bitmap.width - window.width) / 2),                        window.y - ((self.bitmap.height - window.height) / 2),                        Graphics.width,                         Graphics.height)    when 'center'      self.x = self.y = 0      self.src_rect.set((Graphics.width - self.bitmap.width) / 2,                        (Graphics.height - self.bitmap.height) / 2,                         Graphics.width,                         Graphics.height)
 
Last edited by a moderator:

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top