Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###--------------------------------------------------------------------------###
- # CP Composite Character script #
- # Version 1.0 #
- # #
- # Credits: #
- # Original code by: Neon Black #
- # Modified by: #
- # #
- # This work is licensed under the Creative Commons Attribution-NonCommercial #
- # 3.0 Unported License. To view a copy of this license, visit #
- # http://creativecommons.org/licenses/by-nc/3.0/. #
- # Permissions beyond the scope of this license are available at #
- # http://cphouseset.wordpress.com/liscense-and-terms-of-use/. #
- # #
- # Contact: #
- # NeonBlack - neonblack23@live.com (e-mail) or "neonblack23" on skype #
- ###--------------------------------------------------------------------------###
- ###--------------------------------------------------------------------------###
- # V1.0 - 10.10.2012~10.17.2012 #
- # Wrote and debugged main script #
- ###--------------------------------------------------------------------------###
- ###--------------------------------------------------------------------------###
- # Compatibility: #
- # Alias: - Cache: character, face, clear #
- # Game_Actor: change_equip #
- # DataManager: load_database #
- # New Methods - Cache: create_composite #
- # Composites: refresh?, list, images, hues, reset_refresh, #
- # start_composites, change, clear, refresh #
- # Composite_List: initialize, init_values, male?, refresh?, #
- # refresh=, images, hues, check_image, #
- # check_hue, check_value, change #
- # HueColour: dual_colours, hue_colour_wheel #
- # Game_Actor: actor_comp_list, actor_comp_hues #
- # Game_Interpreter: creation #
- # Window_CCFace: initialize, refresh #
- # Window_CCCharacter: initialize, update, refresh, #
- # draw_character #
- # Window_CCGui: initialize, item_max, contents_height, #
- # item_height, refresh, i, draw_item #
- # Window_CCSelect: initialize, item_max, refresh, draw_item #
- # draw_hue_wheel, show, cursor_right, #
- # cursor_left #
- # Scene_CharacterCreation: prepare, start, gui_ok, gui_cancel, #
- # select_ok, select_cancel #
- # RPG::BaseItem: add_composite_data #
- # DataManager: create_composite_additions #
- ###--------------------------------------------------------------------------###
- ###--------------------------------------------------------------------------###
- # Instructions: #
- # Place this script in the "Materials" section of the scripts above "Main". #
- # To use this script you must have additional composite graphics in a folder #
- # for characters and a folder for faces. Charactersets will use composites #
- # based on their names in the NAMES setting. Some layers of the composite #
- # may also change based on the equipped items on the actor associated with #
- # file name. There are several tags that work with both actors and equips. #
- # They are as follows: #
- # #
- # tag init[File, hue] - Can only be tagged in actors. Changes composite #
- # layer :tag to file "File" with the defined hue. #
- # Do not use colons for layer names or quotes for #
- # file names. #
- # gender[male] - Sets the character's initial gender to "male" or "female" #
- # depending on which you place in the brackets. This can #
- # only tag actors. #
- # tag image[FileM, FileF] - Changes the default images for layer :tag to #
- # file "FileM" for male and file "FileF" for #
- # female. Can tag both actors and equips. If a #
- # tag such as "armor" is used, the tags #
- # "armorRear" and "armorHueless" are #
- # automatically applied. #
- # tag hue[huem, huef] - Changes the hue of layer :tag to huem for male #
- # and huef for female. Can tag actors and equips. #
- # #
- # You can also call the character customization screen with the follow #
- # script call: #
- # creation(id) or creation("file") #
- # You can place either the ID for the actor whose composite you want the #
- # player to alter, or you can place the file name for the composite image #
- # you want the character to alter. #
- ###--------------------------------------------------------------------------###
- ###--------------------------------------------------------------------------###
- # Config: #
- module CP # Do not edit #
- module COMPOSITE # these two lines. #
- # #
- ###----- -----###
- # Determines if facesets are used by the script. If this is set to false, the #
- # face will not be displayed in the customizer and the faceset graphic will #
- # not become a composite if it's name matches the characterset's. #
- USE_FACESETS = true # Default = true #
- # #
- # The folders that store the composite images for charactersets and facesets. #
- # Note that the files contained in them can be named different in case they #
- # need to be on different layers or altered in different ways. #
- CHAR_FOLDER = "Graphics/Composite/Charas/" # D = "Graphics/Composite/Charas/" #
- FACE_FOLDER = "Graphics/Composite/Faces/" # D = "Graphics/Composite/Faces/" #
- # #
- # The width and height of the character window in the character customization #
- # screen. Added in case tall characters are used. This number includes the #
- # window padding. Also remember that the sprite will be zoomed to 200%. #
- WINDOW_WIDTH = 90 # Default = 90 #
- WINDOW_HEIGHT = 112 # Default = 112 #
- # #
- # The text options for the character selection GUI. The PRESET_TEXT refers to #
- # actors who have been tagged with "tag init[]". #
- GUI_CLOSE = "Finish Editing" # Default = "Finish Editing" #
- PRESET_TEXT = "Preset" # Default = "Preset" #
- # #
- # The number of allowed character spaces for names when input from the editor. #
- CHARACTERS = 10 # Default = 6 #
- # #
- ###----- -----###
- # This hash contains the names of the images to create composites from as well #
- # as the actor ID they are tied to. If the linked actor wears armour with #
- # note tags, the composite with this name will change. #
- NAMES ={
- "$Hero1" => 1,
- # "$Hero2" => 2,
- }
- # #
- # This allows switches to be linked to genders. If the gender of the player #
- # is changed, the switch is changed. This can be used for gender based #
- # events. The switch will be ON for female characters. #
- SWITCHES ={
- 1 => 72,
- # 2 => 73,
- }
- # #
- # The names for genders as well as well as which one is default on characters #
- # that do not have pre-defined genders. #
- GENDER_NAMES = ["Male", "Female"] # Default = ["Male", "Female"] #
- MALE_DEFAULT = true # Default = true #
- # #
- # The complete list of layers for a composite. Can contain any number of #
- # layers but they must be in order from LOWEST to HIGHEST. Note that :Gender #
- # is a reserved tag by the system that refers to the composite's gender. Also #
- # note that tags ending in "All", "Rear", and "Hueless" are used specially by #
- # the system. "Rear" tags are automatically searched for from every other #
- # tag, "Hueless" tags will never have a hue, and "All" tags are used from the #
- # options of the GUI below to be present in all selections. #
- ORDER =[
- :hairRear,
- :cape,
- :armorRear,
- :headAll,
- :Gender,
- :race,
- :raceHueless,
- :raceRear,
- :eyes,
- :eyesAll,
- :eyesHueless,
- :armor,
- :hair,
- :glasses,
- :helmet,
- ]
- # #
- # These are the default options for the character creation GUI. Note that the #
- # :Name and :Gender tags are reserved by the system, but may be present here #
- # with no arguments. Other tags follow a certain format as noted below. #
- # :tag - This is the layer the image will show up on. Automatically makes the #
- # :tagRear, :tagHueless, and :tagAll layer tags and images. #
- # "Name" - The name of the menu option in the GUI. Quotes are required. #
- # :opTagMale - The name of the MALE tag to use from the options hash below. #
- # :opTagFem - Same as the tag above, but for female composites. These tags #
- # will get the list of options to populate for that layer of #
- # the composite and that section of the GUI. #
- # true - This determines if the hue of this layer can be changed. Set to #
- # false to disable hue change for the layer. #
- # "TagAll" - The name of the file to place in the :tagAll layer if one exists. #
- GUI ={
- # :tag => ["Name", :opTagMale, :opTagFem, true, "TagAll"], #
- :Name => ["Name"],
- :Gender => ["Gender"],
- :race => ["Race", :opRaceMale, :opRaceFem, false],
- :hair => ["Hair", :opHairMale, :opHairFem, true],
- :eyes => ["Eyes", :opEyesM, :opEyesF, true, "EyeAll"],
- }
- # #
- # These are the options list that will appear when the sections of the GUI are #
- # called from the commands above. Each contains a large array with any number #
- # of smaller, two element arrays. The smaller arrays contain two elements. #
- # The first is the name to display for that graphic option. The second is the #
- # name of the file to use. The "Rear" and "Hueless" files will also be #
- # searched for. For example, if you have a file named "Image" placed on layer #
- # :tag, the script will also search for a file "ImageRear" for layer :tagRear, #
- # and a file "ImageHueless" for layer :tagHueless. #
- OPTIONS ={
- :opHairMale => [["Shaggy", "Hair1M"], ["Slick", "Hair2M"],
- ["Spiked", "Hair3M"], ["Fancy", "Hair4M"],
- ["Short", "Hair1U"], ["Long", "Hair2U"], ["Bald", "BaseM"]],
- :opHairFem => [["Stylish", "Hair1F"], ["Waist Length", "Hair2F"],
- ["Curled", "Hair3F"], ["Pigtails", "Hair4F"],
- ["Short", "Hair1U"], ["Long", "Hair2U"], ["Bald", "BaseM"]],
- :opEyesM => [["Observant", "Eye1M"], ["Intent", "Eye3M"], ["Closed", "Eye2M"]],
- :opEyesF => [["Observant", "Eye1F"], ["Intent", "Eye3F"], ["Closed", "Eye2F"]],
- :opRaceMale => [["Human", "Humanmale1"], ["Elf", "Elfmale1"], ["Dwarf", "Dwarfmale1"], ["Halfling", "Halflingmale1"], ["Orc", "Orcmale1"], ["Drow", "Drowmale1"], ["Tiefling", "Tieflingmale1"], ["Warforged", "Warforgedmale1"]],
- :opRaceFem => [["Human", "Humanfemale1"], ["Elf", "Elffemale1"], ["Dwarf", "Dwarffemale1"], ["Halfling", "Halflingfemale1"], ["Orc", "Orcfemale1"], ["Drow", "Drowfemale1"], ["Tiefling", "Tieflingfemale1"], ["Warforged", "Warforgedfemale1"]],
- }
- # #
- # These are the default images that display for certain layers if they are not #
- # defined in the actor notebox. Note that these will NOT automatically apply #
- # for "Rear" and "Hueless". Also note that you CAN have images for the #
- # :Gender tag. Each item is an array with the male image's name first #
- # followed by the female image's name. #
- STANDARD ={
- :headAll => ["HeadAll", "HeadAll"],
- :Gender => ["FaceM", "FaceF"],
- :armor => ["BaseM", "BaseF"],
- }
- # #
- ###--------------------------------------------------------------------------###
- ###--------------------------------------------------------------------------###
- # The following lines are the actual core code of the script. While you are #
- # certainly invited to look, modifying it may result in undesirable results. #
- # Modify at your own risk! #
- ###--------------------------------------------------------------------------###
- ## These are the regular expressions used later.
- INITI_RE = /(.+) init\[(.+)[,]\s*(\d+)\]/i
- IMAGE_RE = /(.+) image\[(.+)[,]\s*(.+)\]/i
- HUE_RE = /(.+) hue\[(\d+)[,]\s*(\d+)\]/i
- GENDER_RE = /gender\[(male|female){1}\]/i
- end
- end
- $imported = {} if $imported.nil?
- $imported["COMPOSITE"] = 1.0
- module Cache
- class << self ## Alias for the used methods in this module.
- alias cp_cm_character character
- alias cp_cm_face face
- alias cp_cm_clear clear
- end
- def self.character(file, hue = 0) ## Checks if the file is a composite.
- return cp_cm_character(file, hue) unless CP::COMPOSITE::NAMES.include?(file)
- create_composite(file, "Graphics/Characters/")
- load_bitmap("Graphics/Characters/", file)
- end
- def self.face(file)
- return cp_cm_face(file) unless CP::COMPOSITE::NAMES.include?(file)
- create_composite(file, "Graphics/Faces/")
- load_bitmap("Graphics/Faces/", file)
- end
- def self.create_composite(file, f1)
- path = f1 + file ## Gets the default file's path.
- Composites.refresh if @cache[path].disposed? rescue nil
- return unless Composites.refresh?(file)
- consts = [CP::COMPOSITE::CHAR_FOLDER, CP::COMPOSITE::FACE_FOLDER]
- folder = ["Graphics/Characters/", "Graphics/Faces/"]
- consts.each_with_index do |f2, i|
- next if (f2 == CP::COMPOSITE::FACE_FOLDER && !CP::COMPOSITE::USE_FACESETS)
- paths = folder[i] + file
- Composites.images(file).each_with_index do |image, i|
- @temp = Bitmap.new(f2 + image) rescue next
- break
- end
- #temp = Bitmap.new(paths)
- @temp.clear ## Creates the composite layer by layer.
- Composites.images(file).each_with_index do |image, i|
- t = Bitmap.new(f2 + image) rescue next
- t.hue_change(Composites.hues(file)[i]) unless Composites.hues(file)[i] == 0
- @temp.blt(0, 0, t, t.rect)
- t.dispose; t = nil
- end
- Composites.reset_refresh(file)
- @cache[paths] = Bitmap.new(@temp.width, @temp.height)
- @cache[paths].blt(0, 0, @temp, @temp.rect)
- end
- @temp = nil
- end
- def self.clear
- cp_cm_clear
- Composite.clear
- end
- end
- class Game_System ## Adds a variable to game system to get saved.
- attr_accessor :cp_lists
- end
- module Composites
- def self.refresh?(file) ## Check if a certain composite needs refreshing.
- return true if $game_system.cp_lists.nil?
- return $game_system.cp_lists[file].refresh?
- end
- def self.list(key) ## Shows off a composite.
- return $game_system.cp_lists[key]
- end
- def self.images(key) ## Gets all images in a composite.
- start_composites if $game_system.cp_lists.nil?
- return $game_system.cp_lists[key].images
- end
- def self.hues(key) ## Gets all hues in a composite.
- start_composites if $game_system.cp_lists.nil?
- return $game_system.cp_lists[key].hues
- end
- def self.reset_refresh(key) ## Resets a refresh of a composite.
- $game_system.cp_lists[key].refresh = false
- end
- def self.start_composites ## Creates all default composites.
- $game_system.cp_lists = {}
- CP::COMPOSITE::NAMES.each do |name, actor|
- $game_system.cp_lists[name] = Composite_List.new(name, actor)
- end
- end
- def self.change(key, name, image, hue, num)
- $game_system.cp_lists[key].change(name, image, hue, num)
- end ## Changes the settings of a certain composite.
- def self.clear ## Clears all composites.
- $game_system.cp_lists = nil
- end
- def self.refresh ## Refreshes all composites.
- return unless $game_system.cp_lists
- $game_system.cp_lists.each {|i, k| k.refresh = true}
- end
- end
- class Composite_List ## Creates a composite's default values.
- def initialize(name, actor)
- @list = {}
- @hues = {}
- @values = {}
- @name = name
- @actor = actor
- @refresh = true
- init_values
- end
- def init_values(male = nil) ## Holy mother of God. This is the good stuff.
- @male = $data_actors[@actor].gender_base if male.nil?
- @male = male unless male.nil?
- if CP::COMPOSITE::SWITCHES.include?(@actor)
- $game_switches[CP::COMPOSITE::SWITCHES[@actor]] = !@male
- end
- CP::COMPOSITE::ORDER.each do |key|
- @hues[key] = 0
- name = nil
- string = key.to_s
- hueless = string.include?("Hueless") ? true : false
- rear = string.include?("Rear") ? true : false
- all = string.include?("All") ? true : false
- string.gsub!(/(Hueless|All|Rear)/, '')
- line = CP::COMPOSITE::GUI[string.to_sym]
- block = @male ? line[1] : line[2] unless line.nil?
- if $data_actors[@actor].composite_init.include?(key) &&
- @male == $data_actors[@actor].gender_base
- name = $data_actors[@actor].composite_init[key][0]
- hues = $data_actors[@actor].composite_init[key][1]
- @hues[key] = hues
- elsif all && !line.nil?
- name = line[4]
- elsif rear && !line.nil?
- name = CP::COMPOSITE::OPTIONS[block][0][1] + "Rear"
- elsif hueless && !line.nil?
- name = CP::COMPOSITE::OPTIONS[block][0][1] + "Hueless"
- elsif !line.nil? && key != :Gender
- name = CP::COMPOSITE::OPTIONS[block][0][1]
- elsif CP::COMPOSITE::STANDARD.include?(key)
- ml = @male ? 0 : 1
- name = CP::COMPOSITE::STANDARD[key][ml]
- end
- @list[key] = name
- end
- CP::COMPOSITE::GUI.each do |ind, vals|
- next if ind == :Name || ind == :Gender
- @values[ind] = [0, 0]
- if $data_actors[@actor].composite_init.include?(ind) &&
- @male == $data_actors[@actor].gender_base
- @values[ind] = [-1, $data_actors[@actor].composite_init[ind][1]]
- end
- next if @list.include?(ind)
- line = CP::COMPOSITE::GUI[ind]
- block = @male ? line[1] : line[2] unless line.nil?
- @list[ind] = CP::COMPOSITE::OPTIONS[block][0][1]
- @hues[ind] = 0
- end
- @refresh = true
- end ## Yeah, I'm not even gonna try to explain the above.
- def male? ## Check if the composite is male.
- return @male
- end
- def refresh? ## Check if the composite needs refreshing.
- return @refresh
- end
- def refresh=(val) ## Sets the composite's refresh.
- @refresh = val
- end
- def images ## Gets all images from a composite.
- res = []
- g = male? ? 0 : 1
- CP::COMPOSITE::ORDER.each do |key|
- if $game_actors[@actor].actor_comp_list.include?(key)
- val = $game_actors[@actor].actor_comp_list[key][g]
- else
- val = @list[key]
- end
- res.push(val)
- end
- return res
- end
- def hues ## Gets all hues.
- res = []
- g = male? ? 0 : 1
- CP::COMPOSITE::ORDER.each do |key|
- if $game_actors[@actor].actor_comp_hues.include?(key)
- val = $game_actors[@actor].actor_comp_hues[key]
- val = val ? val[g] : 0
- else
- val = @hues[key].nil? ? 0 : @hues[key]
- end
- res.push(val)
- end
- return res
- end
- def check_image
- return @list
- end ## Returns the list of images out of order.
- def check_hue
- return @hues
- end ## Returns the list of hues out of order.
- def check_value
- return @values
- end ## Gets all the values for the GUI.
- def change(name, image, hue, num)
- key = name.to_s
- @list[name] = image
- @hues[name] = hue
- @values[name] = [num, hue]
- ["Rear", "All", "Hueless"].each do |s|
- ind = key + s
- next unless @list.include?(ind.to_sym)
- @list[ind.to_sym] = image + s unless s == "All"
- @hues[ind.to_sym] = hue unless s == "Hueless"
- @values[ind.to_sym] = [num, @hues[ind.to_sym]]
- end ## Changes the values within the composite.
- @refresh = true
- end
- end
- module HueColour ## Colour wheel for getting 1 of 36 hues.
- def self.dual_colours(hue)
- hue /= 12
- c2 = hue_colour_wheel(hue)
- c1 = Color.new(c2.red, c2.green, c2.blue, 0)
- return [c1, c2]
- end
- def self.hue_colour_wheel(hue)
- if @wheel.nil? || @wheel.disposed?
- @wheel = Bitmap.new(30, 1)
- c1 = Color.new(255, 0, 0); c2 = Color.new(255, 255, 0)
- c3 = Color.new( 0, 255, 0); c4 = Color.new( 0, 255, 255)
- c5 = Color.new( 0, 0, 255); c6 = Color.new(255, 0, 255)
- @wheel.gradient_fill_rect( 0, 0, 6, 1, c1, c2)
- @wheel.gradient_fill_rect( 5, 0, 6, 1, c2, c3)
- @wheel.gradient_fill_rect(10, 0, 6, 1, c3, c4)
- @wheel.gradient_fill_rect(15, 0, 6, 1, c4, c5)
- @wheel.gradient_fill_rect(20, 0, 6, 1, c5, c6)
- @wheel.gradient_fill_rect(25, 0, 6, 1, c6, c1)
- end
- return @wheel.get_pixel(hue, 0)
- end
- end
- class Game_Actor < Game_Battler
- alias cp_composite_change_eq change_equip
- def change_equip(slot_id, item)
- cp_composite_change_eq(slot_id, item)
- id = CP::COMPOSITE::NAMES.index(@actor_id)
- return unless id
- Composites.list(id).refresh = true
- end ## Gets all the composites on the actor if equips are changed.
- def actor_comp_list
- list = {}
- equips.each do |eq|
- next unless eq
- eq.composite_hash.each do |key, array|
- list[key] = array
- end
- end
- return list
- end ## The lists. Simple, no?
- def actor_comp_hues
- list = {}
- equips.each do |eq|
- next unless eq
- eq.composite_hues.each do |key, array|
- list[key] = array
- end
- end
- return list
- end
- end
- class Game_Interpreter
- def creation(char) ## Allows for easy calling of the scene.
- return if $game_party.in_battle
- if char.is_a?(Integer)
- return unless CP::COMPOSITE::NAMES.has_value?(char)
- char = CP::COMPOSITE::NAMES.index(char)
- else
- return unless CP::COMPOSITE::NAMES.include?(char)
- end
- SceneManager.call(Scene_CharacterCreation)
- SceneManager.scene.prepare(char)
- Fiber.yield
- end
- end
- ##------
- ## The scene and its windows are below. I'm lazy and don't feel like stating
- ## the obvious on any of those. Besides, I don't really put sufficiant comments
- ## to begin with.
- ##------
- class Window_CCFace < Window_Base
- def initialize(actor, input)
- super(0, 0, 120, 120)
- self.visible = CP::COMPOSITE::USE_FACESETS
- @input_window = input
- self.y = @input_window.y
- self.x = @input_window.x - (self.width + 8)
- @actor = $data_actors[actor]
- refresh
- end
- def refresh
- contents.clear
- draw_face(@actor.face_name, @actor.face_index, 0, 0)
- end
- end
- class Window_CCCharacter < Window_Base
- def initialize(actor, input)
- super(0, 0, CP::COMPOSITE::WINDOW_WIDTH, CP::COMPOSITE::WINDOW_HEIGHT)
- @input_window = input
- self.y = @input_window.y
- self.x = @input_window.x + @input_window.width + 8
- @actor = $data_actors[actor]
- @ticker = 10
- @last_frame = 1
- @frame = 1
- refresh
- end
- def update
- @ticker += 1
- @frame = (@ticker % 40) / 10; @frame = 1 if @frame == 3
- return if @frame == @last_frame
- @last_frame = @frame
- refresh
- end
- def refresh
- contents.clear
- x = contents.width / 2
- y = contents.height - 6
- draw_character(@actor.character_name, @actor.character_index, x, y, @frame)
- end
- def draw_character(character_name, character_index, x, y, frame = 1)
- return unless character_name
- bitmap = Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- if sign && sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = character_index
- src_rect = Rect.new((n%4*3+frame)*cw, (n/4*4)*ch, cw, ch)
- ret_rect = Rect.new(x - cw, y - cw * 2, cw * 2, ch * 2)
- contents.stretch_blt(ret_rect, bitmap, src_rect)
- end
- end
- class Window_CCGui < Window_Selectable
- def initialize(file)
- extra_width = CP::COMPOSITE::WINDOW_WIDTH + 8
- extra_width += 128 if CP::COMPOSITE::USE_FACESETS
- x = (Graphics.width - (180 + extra_width)) / 2
- x += 128 if CP::COMPOSITE::USE_FACESETS
- y = (Graphics.height - fitting_height(item_max * 2)) / 2
- h = [fitting_height(item_max * 2), Graphics.height].min
- super(x, y, 180, h)
- @file = file
- refresh
- end
- def item_max
- CP::COMPOSITE::GUI.size + 1
- end
- def contents_height
- (item_max * 2) * line_height
- end
- def item_height
- line_height * 2
- end
- def refresh
- contents.clear
- draw_all_items
- end
- def i
- res = []
- CP::COMPOSITE::GUI.each {|ind, val| res.push(ind)}
- return res
- end
- def draw_item(index)
- rect = item_rect(index)
- lh = line_height
- if index == CP::COMPOSITE::GUI.size
- text = CP::COMPOSITE::GUI_CLOSE
- change_color(normal_color)
- draw_text(rect.x + 2, rect.y + lh / 2, rect.width - 4, lh, text, 1)
- else
- title = CP::COMPOSITE::GUI[i[index]][0]
- unless i[index] == :Gender || i[index] == :Name
- id = Composites.list(@file).check_value[i[index]][0]
- blk = Composites.list(@file).male? ? 1 : 2
- name = CP::COMPOSITE::OPTIONS[CP::COMPOSITE::GUI[i[index]][blk]][id][0]
- name = CP::COMPOSITE::PRESET_TEXT if id == -1
- hue = Composites.list(@file).check_hue[i[index]]; hue = 0 if hue.nil?
- end
- change_color(system_color)
- draw_text(rect.x + 2, rect.y, rect.width - 4, lh, title)
- case i[index]
- when :Gender
- na = CP::COMPOSITE::GENDER_NAMES
- name = Composites.list(@file).male? ? na[0] : na[1]
- change_color(normal_color)
- draw_text(rect.x + 2, rect.y + lh, rect.width - 6, lh, name, 2)
- when :Name
- name = $game_actors[CP::COMPOSITE::NAMES[@file]].name
- change_color(normal_color)
- draw_text(rect.x + 2, rect.y + lh, rect.width - 6, lh, name, 2)
- else
- if CP::COMPOSITE::GUI[i[index]][3]
- c1, c2 = HueColour.dual_colours(hue)
- r2 = contents.text_size(name).width
- hr = Rect.new(contents.width - (r2 + 6), rect.y + lh + 3, r2 + 1, lh - 6)
- contents.gradient_fill_rect(hr, c1, c2)
- end
- change_color(normal_color)
- draw_text(rect.x + 2, rect.y + lh, rect.width - 6, lh, name, 2)
- end
- end
- end
- end
- class Window_CCSelect < Window_Selectable
- attr_reader :hue
- def initialize(file, input)
- super(0, 0, 160, 0)
- @input_window = input
- @file = file
- @data = nil
- end
- def item_max
- return 1 if @data.nil?
- return 1 if @data.empty?
- return @data.size
- end
- def refresh
- contents.clear
- draw_all_items
- draw_hue_wheel
- end
- def draw_item(index)
- rect = item_rect(index); rect.x += 2; rect.width -= 4
- change_color(normal_color)
- draw_text(rect, @data[index])
- end
- def draw_hue_wheel
- return unless @hue
- rect = item_rect(item_max); contents.clear_rect(rect)
- rect.y += 4; rect.height -= 8; rect.x += 8
- c1 = Color.new(255, 0, 0); c2 = Color.new(255, 255, 0)
- c3 = Color.new( 0, 255, 0); c4 = Color.new( 0, 255, 255)
- c5 = Color.new( 0, 0, 255); c6 = Color.new(255, 0, 255)
- contents.gradient_fill_rect(rect.x + 0, rect.y, 21, rect.height, c1, c2)
- contents.gradient_fill_rect(rect.x + 20, rect.y, 21, rect.height, c2, c3)
- contents.gradient_fill_rect(rect.x + 40, rect.y, 21, rect.height, c3, c4)
- contents.gradient_fill_rect(rect.x + 60, rect.y, 21, rect.height, c4, c5)
- contents.gradient_fill_rect(rect.x + 80, rect.y, 21, rect.height, c5, c6)
- contents.gradient_fill_rect(rect.x + 100, rect.y, 21, rect.height, c6, c1)
- contents.clear_rect(rect.x + 120, rect.y, 1, rect.height)
- bitmap2 = Bitmap.new(7, 20)
- bitmap2.fill_rect(0, 0, 7, 20, Color.new(255, 255, 255))
- bitmap2.fill_rect(1, 2, 5, 16, HueColour.hue_colour_wheel(@hue / 12))
- off = @hue / 3
- contents.blt(rect.x - 3 + off, rect.y - 2, bitmap2, bitmap2.rect)
- end
- def show
- val = @input_window.i[@input_window.index]
- @value = Composites.list(@file).check_value[val]
- @index = val != :Gender ? @value[0] : Composites.list(@file).male? ? 0 : 1
- @index = 0 if @index == -1
- @hue = @value[1] unless val == :Gender
- block = Composites.list(@file).male? ? 1 : 2
- CP::COMPOSITE::GUI.each do |ind, cont|
- next unless ind == val
- if val == :Gender
- @data = CP::COMPOSITE::GENDER_NAMES
- else
- @data = []
- key = CP::COMPOSITE::GUI[val][block]
- for i in 0...CP::COMPOSITE::OPTIONS[key].size
- @data.push(CP::COMPOSITE::OPTIONS[key][i][0])
- end
- end
- end
- add = CP::COMPOSITE::GUI[val][3] ? 1 : 0
- self.height = fitting_height(@data.size + add)
- create_contents
- refresh
- self.x = @input_window.x + 16
- iw = @input_window
- self.y = iw.y + iw.standard_padding + (iw.index * (iw.line_height * 2)) - iw.oy + 28
- self.y = Graphics.height - self.height if y + height > Graphics.height
- super
- activate
- end
- def cursor_right(wrap)
- @hue /= 12 ; @hue *= 12
- @hue += 12; @hue -= 360 if @hue >= 360
- draw_hue_wheel
- end
- def cursor_left(wrap)
- @hue -= 12; @hue += 360 if @hue < 0
- draw_hue_wheel
- end
- end
- class Scene_CharacterCreation < Scene_MenuBase
- def prepare(file)
- @file = file
- end
- def start
- super
- @actor = $data_actors[CP::COMPOSITE::NAMES[@file]]
- @input_window = Window_CCGui.new(@file)
- @chara_window = Window_CCCharacter.new(@actor.id, @input_window)
- @face_window = Window_CCFace.new(@actor.id, @input_window)
- @select_window = Window_CCSelect.new(@file, @input_window)
- @input_window.set_handler(:ok, method(:gui_ok))
- @input_window.set_handler(:cancel, method(:gui_cancel))
- @select_window.set_handler(:ok, method(:select_ok))
- @select_window.set_handler(:cancel, method(:select_cancel))
- @input_window.activate.select(0)
- @select_window.hide
- end
- def gui_ok
- val = @input_window.i[@input_window.index]
- if val == :Name
- SceneManager.call(Scene_Name)
- SceneManager.scene.prepare(CP::COMPOSITE::NAMES[@file], CP::COMPOSITE::CHARACTERS)
- @input_window.refresh
- elsif val == nil
- return_scene
- else
- @select_window.show
- end
- end
- def gui_cancel
- @input_window.activate.select(@input_window.item_max - 1)
- end
- def select_ok
- val = @input_window.i[@input_window.index]
- id = @select_window.index
- if val == :Gender
- if id == 0
- Composites.list(@file).init_values(true)
- elsif id == 1
- Composites.list(@file).init_values(false)
- end
- else
- block = Composites.list(@file).male? ? 1 : 2
- arg = []
- arg.push(@file)
- arg.push(val)
- arg.push(CP::COMPOSITE::OPTIONS[CP::COMPOSITE::GUI[val][block]][id][1])
- arg.push(@select_window.hue)
- arg.push(@select_window.index)
- Composites.change(*arg)
- end
- @select_window.hide
- @chara_window.refresh
- @face_window.refresh
- @input_window.activate.refresh
- end
- def select_cancel
- @select_window.hide
- @input_window.activate
- end
- end
- class RPG::BaseItem
- attr_reader :composite_hash
- attr_reader :composite_hues
- attr_reader :composite_init
- attr_reader :gender_base
- def add_composite_data
- return if @gender_base; @gender_base = CP::COMPOSITE::MALE_DEFAULT
- @composite_hash = {}; @composite_hues = {}; @composite_init = {}
- self.note.split(/[\r\n]+/).each do |line|
- case line
- when CP::COMPOSITE::INITI_RE
- @composite_init[$1.to_sym] = [$2.to_s, $3.to_i]
- s = []
- [$1.to_s, $2.to_s].each {|v| s.push(v + "Rear")}
- @composite_init[s[0].to_sym] = [s[1], $3.to_i]
- s = []
- [$1.to_s, $2.to_s].each {|v| s.push(v + "Hueless")}
- @composite_init[s[0].to_sym] = [s[1], 0]
- when CP::COMPOSITE::IMAGE_RE
- @composite_hash[$1.to_sym] = [$2.to_s, $3.to_s]
- s = []
- [$1.to_s, $2.to_s, $3.to_s].each {|v| s.push(v + "Rear")}
- @composite_hash[s[0].to_sym] = [s[1], s[2]]
- s = []
- [$1.to_s, $2.to_s, $3.to_s].each {|v| s.push(v + "Hueless")}
- @composite_hash[s[0].to_sym] = [s[1], s[2]]
- when CP::COMPOSITE::HUE_RE
- @composite_hues[$1.to_sym] = [$2.to_i, $3.to_i]
- @composite_hues[($1.to_s + "Rear").to_sym] = [$2.to_i, $3.to_i]
- when CP::COMPOSITE::GENDER_RE
- @gender_base = true if $1.to_s.downcase == "male"
- @gender_base = false if $1.to_s.downcase == "female"
- end
- end
- end
- end
- module DataManager
- class << self
- alias cp_composite_load_database load_database
- end
- def self.load_database
- cp_composite_load_database
- create_composite_additions
- end
- def self.create_composite_additions
- groups = [$data_actors, $data_weapons, $data_armors]
- for group in groups
- for obj in group
- next if obj.nil?
- obj.add_composite_data if obj.is_a?(RPG::BaseItem)
- end
- end
- end
- end
- ###--------------------------------------------------------------------------###
- # End of script. #
- ###--------------------------------------------------------------------------###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement