| Ancien membre du staff |
 |
 |
Inscrit le: 20 Juil 2008, 00:00 Messages: 1726 Niveau RPG Maker: correct Point(s) Fort(s): polyvalent Sexe: Masculin Points d'aide: 0/60
Créations :
- Création d'un sous menu
- Personnalisation des tailles d'icônes et de curseurs
- Affichages des altérations d'état via des icônes
Voir ses créations
|
Présentation :Ce script permet de modifier la taille du curseur et la taille des icônes dans les différents sous-menus de base. La gestion des icônes rectangulaires est prise en compte. Droits :Auteur : Albavor Libre de diffusion et de modification. Dépendance : Aucune Mode d'emploi :Collez ce script au-dessus de main et en-dessous des scripts de type Window. Suivez les instructions en début de script. - Code: Tout sélectionner
#====================================================================== # Cursor_size #---------------------------------------------------------------------- # Auteur : Albavor # Date : novembre 2009 #---------------------------------------------------------------------- # Ce script permet de modifier la taille du curseur et la taille # des icônes dans les différents sous-menus de base. Commencez par # redéfinir les variables en début de script. Les valeurs par défaut # sont celles utilisées dans un projet vierge. #======================================================================
# Largeur et hauteur des icônes ICON_WIDTH = 24 ICON_HEIGHT = 24 # Hauteur du curseur dans un menu quelconque CURSOR_MAIN = 32 # Hauteur du curseur dans un menu d'objets CURSOR_ITEM = 32 # Hauteur du curseur dans un menu de compétences CURSOR_SKILL = 32 # Hauteur du curseur dans un menu de magasin (il est conseillé de mettre # la même valeur que celle des menus d'objets). CURSOR_SHOP = 32
#======================================================================== # Personnalisation avancée #======================================================================== # Il est possible de faire varier la taille des icônes d'un menu à # l'autre. Pour cela prenons l'exemple suivant : seules les icônes # du menu de compétences doivent passer en 32 px par 32 px. Suivez # alors les étapes suivantes : # 1) Définissez deux variables supplémentaires ci-dessus # ICON_WIDTH_SKILL = 32 # ICON_HEIGHT_SKILL = 32 # 2) Changez la valeur de CURSOR_SKILL pour la faire correspondre (40) # 3) Allez voir la partie Window_Skill de ce script et remplacez tous les # ICON_WIDTH et ICON_HEIGHT par des ICON_WIDTH_SKILL et ICON_HEIGHT_SKILL #=========================================================================
#========================================================================= # Mises en garde et conseils #========================================================================= # Le présent script permet de faire varier la taille du curseur en hauteur, # ce qui est assez pratique pour varier la configuration des menus. Il faut # cependant être conscient du fait que certaines tailles de curseur risquent # de poser des problèmes en bas de fenêtre lorsqu'une liste d'objets est # pleine. # La position du nom des objets est automatiquement gérée en fonction # de la taille des icônes, vous n'avez donc pas à vous en soucier. Il est # cependant évident que des icônes larges nécessitent des noms d'ojets ou # de compétences plus courts. # La taille des icônes affichable doit être corrélée à la taille du curseur. # Pour un bon rendu, il est conseillé d'ajouter 8 à la hauteur des icônes # pour obtenir la hauteur du curseur. #===========================================================================
#---------------------------------------------------------------------- class Window_Selectable < Window_Base #----------------------------------------------------------------------
attr_accessor :cursor_height def initialize(x, y, width, height) super(x, y, width, height) @item_max = 1 @column_max = 1 @index = -1 @cursor_height = CURSOR_MAIN end def top_row return self.oy / @cursor_height end def top_row=(row)
if row < 0 row = 0 end
if row > row_max - 1 row = row_max - 1 end
self.oy = row * @cursor_height end def page_row_max
return (self.height - 32) / @cursor_height end def update_cursor_rect
if @index < 0 self.cursor_rect.empty return end
row = @index / @column_max
if row < self.top_row
self.top_row = row end
if row > self.top_row + (self.page_row_max - 1)
self.top_row = row - (self.page_row_max - 1) end
cursor_width = self.width / @column_max - 32
x = @index % @column_max * (cursor_width + 32) y = @index / @column_max * @cursor_height - self.oy
self.cursor_rect.set(x, y, cursor_width, @cursor_height) end end
#------------------------------------------------------------------- class Window_Item < Window_Selectable #------------------------------------------------------------------- def initialize super(0, 64, 640, 416) @column_max = 2 self.cursor_height = CURSOR_ITEM refresh self.index = 0 # 戦闘中の場合はウィンドウを画面中央へ移動し、半透明にする if $game_temp.in_battle self.y = 64 self.height = 256 self.back_opacity = 160 end end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = []
for i in 1...$data_items.size if $game_party.item_number(i) > 0 @data.push($data_items[i]) end end
unless $game_temp.in_battle for i in 1...$data_weapons.size if $game_party.weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 @data.push($data_armors[i]) end end end
@item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * self.cursor_height) self.contents.font.name = $fontface self.contents.font.size = $fontsize for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] case item when RPG::Item number = $game_party.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end if item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id) self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 + index % 2 * (288 + 32) y = index / 2 * self.cursor_height rect = Rect.new(x, y, self.width / @column_max - 32, self.cursor_height) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 a = (self.cursor_height-ICON_HEIGHT)/2 b = ICON_WIDTH - 24 self.contents.blt(x, y + a, bitmap, Rect.new(0, 0, ICON_WIDTH, ICON_HEIGHT), opacity) self.contents.draw_text(x + 32 + b, y, 212, self.cursor_height, item.name, 0) self.contents.draw_text(x + 240 + b, y, 16, self.cursor_height, ":", 1) self.contents.draw_text(x + 256, y, 24, self.cursor_height, number.to_s, 2) end end
#---------------------------------------------------------- class Window_Skill < Window_Selectable #----------------------------------------------------------
def initialize(actor) super(0, 128, 640, 352) @actor = actor @column_max = 2 self.cursor_height = CURSOR_SKILL refresh self.index = 0 # 戦闘中の場合はウィンドウを画面中央へ移動し、半透明にする if $game_temp.in_battle self.y = 64 self.height = 256 self.back_opacity = 160 end end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for i in 0...@actor.skills.size skill = $data_skills[@actor.skills[i]] if skill != nil @data.push(skill) end end # 項目数が 0 でなければビットマップを作成し、全項目を描画 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * self.cursor_height) self.contents.font.name = $fontface self.contents.font.size = $fontsize for i in 0...@item_max draw_item(i) end end end def draw_item(index) skill = @data[index] if @actor.skill_can_use?(skill.id) self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 + index % 2 * (288 + 32) y = index / 2 * self.cursor_height rect = Rect.new(x, y, self.width / @column_max - 32, self.cursor_height) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(skill.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 a = (self.cursor_height-ICON_HEIGHT)/2 b = ICON_WIDTH - 24 self.contents.blt(x, y + a, bitmap, Rect.new(0, 0, ICON_WIDTH, ICON_HEIGHT), opacity) self.contents.draw_text(x + 32 + b, y, 204, self.cursor_height, skill.name, 0) self.contents.draw_text(x + 232, y, 48, self.cursor_height, skill.sp_cost.to_s, 2) end end
#---------------------------------------------- class Window_ShopBuy < Window_Selectable #---------------------------------------------- def initialize(shop_goods) super(0, 128, 368, 352) @shop_goods = shop_goods self.cursor_height = CURSOR_SHOP refresh self.index = 0 end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for goods_item in @shop_goods case goods_item[0] when 0 item = $data_items[goods_item[1]] when 1 item = $data_weapons[goods_item[1]] when 2 item = $data_armors[goods_item[1]] end if item != nil @data.push(item) end end # 項目数が 0 でなければビットマップを作成し、全項目を描画 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * self.cursor_height) self.contents.font.name = $fontface self.contents.font.size = $fontsize for i in 0...@item_max draw_item(i) end end end
def draw_item(index) item = @data[index] # アイテムの所持数を取得 case item when RPG::Item number = $game_party.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end # 価格が所持金以下、かつ所持数が 99 でなければ通常文字色に、 # そうでなければ無効文字色に設定 if item.price <= $game_party.gold and number < 99 self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 y = index * self.cursor_height rect = Rect.new(x, y, self.width - 32, self.cursor_height) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 a = (self.cursor_height-ICON_HEIGHT)/2 b = ICON_WIDTH - 24 self.contents.blt(x, y + a, bitmap, Rect.new(0, 0, ICON_WIDTH, ICON_HEIGHT), opacity) self.contents.draw_text(x + 32 + b, y, 212, self.cursor_height, item.name, 0) self.contents.draw_text(x + 240, y, 88, self.cursor_height, item.price.to_s, 2) end end
#---------------------------------------------------------- class Window_ShopSell < Window_Selectable #---------------------------------------------------------- def initialize super(0, 128, 640, 352) @column_max = 2 self.cursor_height = CURSOR_SHOP refresh self.index = 0 end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for i in 1...$data_items.size if $game_party.item_number(i) > 0 @data.push($data_items[i]) end end for i in 1...$data_weapons.size if $game_party.weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 @data.push($data_armors[i]) end end # 項目数が 0 でなければビットマップを作成し、全項目を描画 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * self.cursor_height) self.contents.font.name = $fontface self.contents.font.size = $fontsize for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] case item when RPG::Item number = $game_party.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end # 売却可能なら通常文字色に、そうでないなら無効文字色に設定 if item.price > 0 self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 + index % 2 * (288 + 32) y = index / 2 * self.cursor_height rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 a = (self.cursor_height-ICON_HEIGHT)/2 b = ICON_WIDTH - 24 self.contents.blt(x, y + a, bitmap, Rect.new(0, 0, ICON_WIDTH, ICON_HEIGHT), opacity) self.contents.draw_text(x + 32 + b, y, 212, self.cursor_height, item.name, 0) self.contents.draw_text(x + 240 + b, y, 16, self.cursor_height, ":", 1) self.contents.draw_text(x + 256, y, 24, self.cursor_height, number.to_s, 2) end end
_________________
|
|