#==============================================================================# ■ MenuLuna#============================================================================== module MenuLuna module SaveMenu # return array contains text/bitmap data # result = [ # # latter R, G, B, A is for Outline color. # [Text, [X, Y], [Width, Align], [R, G, B(, A)], [FontName, FontSize, FontBold, FontItalic], [R, G, B(, A)]], # ] # replace text with $bitmap[Folder, Filename] for draw bitmap. # Folder must be in Graphics and Filename must be in Folder. # For example: $bitmap[System, GoldIcon] for Graphics/System/GoldIcon.png # Bitmap doesn't need [FontName, FontSize, FontBold, FontItalic] & [R, G, B(, A)] # & [Width, Align] but has an opacity option. # For source rect, use bw for bitmap width, bh for bitmap height. # If Opacity and/or Src_rect, it will take opacity of 255 and bitmap original # rect as values. # ["$bitmap[Folder, FileName]", [X, Y], Opacity, Src_rect] # ["$bitmap[System, GoldIcon]", [128, 0], 255, [0, 0, "bw * 0.5", "bh"]] # ["$bitmap[System, GoldIcon]", [128, 0], 255, [0, 0, 128, 42]] # replace $bitmap[Folder, "Filename"] with $color[R, G, B] # for solid color background. # replace $bitmap[Folder, "Filename"] with $horgrad[R1, G1, B1, R2, G2, B2] # for gradient color background horizontal. # replace $bitmap[Folder, "Filename"] with $vergrad[R1, G1, B1, R2, G2, B2] # for gradient color background vertical. # replace text with $icon[index] for draw icon # icon doesn't need [FontName, FontSize, FontBold, FontItalic] & [R, G, B(, A)] # & [Width, Align] but has an opacity option. # ["$icon[Index]", [X, Y], Opacity] # ["$icon[10]", [128, 0], 255] # contents refers to window's contents bitmap. # Text for Status Window def self.user_save_text(index, contents, enable) result = [] alpha = enable ? 255 : 128 header = DataManager.load_header(index) result = [ ["#{index+1}", [164, 4], [120, 0], [255, 255, 255], ["VL Gothic", 20, false, false], [66, 33, 49,alpha]], ] return result unless header header[:characters].each_with_index do |data, i| x = 356 y = 48 bitmap = Cache.character(data[0]) cw = bitmap.width / 12 ch = bitmap.height / 8 n = data[1] result.push( ["$bitmap[Characters, #{data[0]}]", [x+i*47, y+1], 255, [(n%4*3+1)*cw - 10, (n/4*4)*ch, cw + 20, ch + 20]] ) end result end endend #==============================================================================# ■ DataManager#============================================================================== module DataManager #-------------------------------------------------------------------------- # new method: load_savefile_data #-------------------------------------------------------------------------- def self.load_savefile_data(index) File.open(make_filename(index), "rb") { |file| Marshal.load(file) return Marshal.load(file) } return nil end #-------------------------------------------------------------------------- # new method: get_savefile_data #-------------------------------------------------------------------------- def self.get_savefile_data(index) load_savefile_data(index) rescue nil end end # DataManager