AgentPaper 1 Report post Posted October 18, 2012 (edited) I need a script that will allow the player to peruse various books, sticky notes, infospheres, scraps of parchment covered in blood, ancient runes, picture vases, or whatever other kind of strange information-carrying object I decide to implement. In the most basic terms, what I need is a script that adds a new option to the menu screen called "Lore", which shows you a list of all the lore items you have collected so far. When you select one of the items (IE: Abdul's Log, Page 4), it brings up a bunch of text that you can read through. Each lore item shouldn't actually be a item you can see through the normal item menu, but just a switch that gets turned on in the lore menu when you find that item. Optional additional features: - Display an icon next to the lore object similar to normal items. - Add the ability to display one or more pictures in the text, using x/y coordinates. - Add the ability to choose whether the picture shows above or below text. - Some way to automatically format text to fit around the aforementioned pictures. - The ability to create in-line pictures. - The ability to control the font, size, and color of text, and also to bold, italicize, and underline text. - The ability to scroll through text. - The ability to control whether pictures scroll with the text or not. - The ability to have multi-page objects. - Extensive comments within the code so I can see how it works and tweak it as needed. - Any other features you're awesome enough to think. For doing this, you will be rewarded with credit in my map and my everlasting love and devotion. Also a kitten. Edited October 18, 2012 by AgentPaper Share this post Link to post Share on other sites
Broken Messiah 20 Report post Posted October 18, 2012 I want this as well for VX, but I couldn't find anything*didn't look much though* but I did find a Book reading script which could cover that if one exists for XP. I don't wanna be that guy an say you can just event it through show text commands, but it is a simple solution and with show picture you can create the effect of picking up a book. I wish you luck in this, lore is so awesome to have in a game, it just makes making the game so much easier in the long run. Share this post Link to post Share on other sites
diagostimo 11 Report post Posted October 18, 2012 (edited) ill have a crack at it, just a few questions with the basics: do you want an image as the windows back or a windowskin, or the choice to configure the back between differnt windowskins and images what is the rough size you would like the windows to be, bearing that rmxp default screen size is 640 X 480, i can also make this configurable if you like do you want the lore menu to be accessible if no items are obtained, then in the lore menu itself do you want items to appear faded if they are not in possession or just not displayed at all also on window size, if its smaller than the games window size, do you want a background image for your lore menu i cant promise this being fast development as i have alot of course work at the moment, but ill do it in my free time Edited October 18, 2012 by diagostimo Share this post Link to post Share on other sites
AgentPaper 1 Report post Posted October 18, 2012 (edited) ill have a crack at it, just a few questions with the basics: 1) do you want an image as the windows back or a windowskin, or the choice to configure the back between differnt windowskins and images 2) what is the rough size you would like the windows to be, bearing that rmxp default screen size is 640 X 480, i can also make this configurable if you like 3) do you want the lore menu to be accessible if no items are obtained, then in the lore menu itself do you want items to appear faded if they are not in possession or just not displayed at all 4) also on window size, if its smaller than the games window size, do you want a background image for your lore menu i cant promise this being fast development as i have alot of course work at the moment, but ill do it in my free time 1) Windowskin. I may want to add a background to various lore objects, but that should be handled by the picture-adding program. (I'd simply add a screen-sized image at 0, 0, set to display below text) 2) It should cover the full screen, just like the other menus. 3) If the player doesn't have any lore items, the Lore button in the menu should be grayed out. Items that haven't been collected should show up as a line, (IE: ---------) so the player can see if he's missing any. 4) No need for a background on the lore menu. And thank you very much for helping me with this. If you don't have much time, don't worry about most of the complex features, at least at first. Just a simple version that's functional without icons or pictures, formatting, multipage, etc. would be very useful. Edited October 18, 2012 by AgentPaper Share this post Link to post Share on other sites
diagostimo 11 Report post Posted October 20, 2012 (edited) thought i would share a little progress, heres what i have so far, it is comented how to call it at the moment: module Lore_Config #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# # * Script Calls: #----------------# # $game_system.possessed_lore_items.push(ID) # * Adds lore items to the possession # * ID can be a single id or mutiple like so : ID, ID, ID # # $scene = Scene_Lore_Items.new # * Calls the lore items scene #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# # * Begin Configuration #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# #setup the array of lore items possessable, this is needed so they can all be #displayed in the choice window, the order you put the id's is the order they #are displayed LORE_ITEMS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] #================================================ # * SETUP FOR ITEMS NAME AND IMAGES # IMAGES MUST BE STORED IN ICONS DIRECTORY #================================================ def self.item_config(id) case id #when ID then [iTEM_NAME, OBTAINED_ICON_NAME, UN-OBTAINED_ICON_NAME] when 0 then ["name 1", "046-Skill03", ""] when 1 then ["name 2", "046-Skill03", ""] when 2 then ["name 3", "", ""] when 3 then ["name 4", "", ""] when 4 then ["name 5", "", ""] when 5 then ["name 6", "", ""] when 6 then ["name 7", "", ""] when 7 then ["name 8", "", ""] when 8 then ["name 9", "", ""] when 9 then ["name 10", "", ""] when 10 then ["name 11", "", ""] when 11 then ["name 12", "", ""] when 12 then ["name 13", "", ""] when 13 then ["name 14", "", ""] when 14 then ["name 15", "", ""] end end #================================================ # * SETUP FOR WINDOW IMAGES # IMAGES MUST BE STORED IN PICTURES DIRECTORY. # A blank array "[]" will result in no images. # To add images just add to the array with a # new image setup. #================================================ def self.lore_window_images(id) case id #when ID then [[X, Y, NAME, OPACITY], [X, Y, NAME, OPACITY] #ECT] when 0 then [[0, 0, "0020", 255], [100, 0, "0020", 255]] when 1 then [] else [] end end #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# # * End Configuration #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# end #============================================================================== # ** Game_System #============================================================================== class Game_System #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :possessed_lore_items #-------------------------------------------------------------------------- # * Initialize #-------------------------------------------------------------------------- alias init_lore_items initialize def initialize init_lore_items @possessed_lore_items = [] end end #============================================================================== # ** Window Lore Choice #============================================================================== class Window_Lore_Choice < Window_Selectable #-------------------------------------------------------------------------- # * Initialize #-------------------------------------------------------------------------- def initialize super(0, 0, 160, 480) @item_max = Lore_Config::LORE_ITEMS.size self.contents = Bitmap.new(width - 32, @item_max * 32) refresh self.index = 0 end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # * Draw item #-------------------------------------------------------------------------- def draw_item(index) rect = Rect.new(4, 32 * index, self.contents.width - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) if $game_system.possessed_lore_items.include?(Lore_Config::LORE_ITEMS[index]) self.contents.font.color = normal_color icon = RPG::Cache.icon(Lore_Config.item_config(Lore_Config::LORE_ITEMS[index])[1]) text = Lore_Config.item_config(Lore_Config::LORE_ITEMS[index])[0] else self.contents.font.color = disabled_color icon = RPG::Cache.icon(Lore_Config.item_config(Lore_Config::LORE_ITEMS[index])[2]) text = "----------------" end opacity = self.contents.font.color == normal_color ? 255 : 128 x = self.contents.width - 26 y = 4 + (index * 32) self.contents.blt(x, y, icon, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(rect, text) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super end end #============================================================================== # ** Window Lore Items #============================================================================== class Window_Lore_Item < Window_Base attr_accessor :lore_id #-------------------------------------------------------------------------- # * Initialize #-------------------------------------------------------------------------- def initialize(x, y, w, h, id) super(x, y, w, h) #get lore window id @lore_id = id #create self.contents self.contents = Bitmap.new(self.width - 32, self.height - 32) #refresh contents refresh end #-------------------------------------------------------------------------- # * Draw Images #-------------------------------------------------------------------------- def draw_images #check for images to be drawn if Lore_Config.lore_window_images(@lore_id) != [] #loop through images for i in 0...Lore_Config.lore_window_images(@lore_id).size #get image settings bitmap = Lore_Config.lore_window_images(@lore_id)[i] #set settings name = RPG::Cache.picture(bitmap[2]) x, y, opacity, width, height = bitmap[0], bitmap[1], bitmap[3], name.width, name.height #draw the image self.contents.blt(x, y, name, Rect.new(0, 0, width, height), opacity) end end end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh #clear content self.contents.clear #draw images draw_images end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super #refresh contents refresh end end #============================================================================== # ** Scene Lore Choice #============================================================================== class Scene_Lore_Items #-------------------------------------------------------------------------- # * Main #-------------------------------------------------------------------------- def main @choice_window = Window_Lore_Choice.new @index = @choice_window.index @lore_item_window = Window_Lore_Item.new(160, 0, 480, 480, Lore_Config::LORE_ITEMS[@index]) Graphics.transition loop { Graphics.update; Input.update; update; break if $scene != self } @choice_window.dispose @lore_item_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update @choice_window.update @index = @choice_window.index @lore_item_window.lore_id = Lore_Config::LORE_ITEMS[@index] @lore_item_window.update end end im going to start making the pages multi window, i think ill show a page marker in the top right or bottom right like: page 1/Amount, how exactly to you want me to enable the switching of pages? i can do it with the L and R input if you like, im also gonna start making the text field, do you want me to create some sort of border for the text field? or i can make it a new window completely over the current, then if the text is overflowing it will show the prompt arrows to scroll down/up like other windows, im trying to figure out the best way to configure the text, im thinking creating a text file for each item and window, and storing them in there own directory Edited October 20, 2012 by diagostimo Share this post Link to post Share on other sites
AgentPaper 1 Report post Posted October 20, 2012 Awesome, I'll test it out later tonight. for changing pages, simply left and right arrows should work fine. For the text field, I'm not sure what you mean, so I can't say which of those choices I'd prefer. Just use your best judgement I suppose Having the ability to scroll sounds good too, I can use that for some and multi-page for others. For the text data itself, a separate .txt file seems the simplest and easiest way to handle it. The text files should be named based on the order they'll show up in the lore file, and then other information like the title, any pictures to include, font, and so on would be set in the text file itself, using whatever format is easiest to implement. Share this post Link to post Share on other sites
Broken Messiah 20 Report post Posted October 20, 2012 For the text data itself, a separate .txt file seems the simplest and easiest way to handle it. Thats how I have my lore set up with this new book reading script. It also has paragraph formatting which really helps. ...I don't suppose this script could be compatible with VX? Share this post Link to post Share on other sites
diagostimo 11 Report post Posted October 20, 2012 to be honest i have never looked into the syntax of rgss2 so i couldnt tell you, the only way to tell would be to test it and find out, although it would not be very likely as all the classes as follows would have to be structured the same, or have same variable names: Window Window_Base Window_Selectable if all of those classes have same variable names as ones in rgss1 then it will work, otherwise it wont, and i cant offer compatibilty as i only use rmxp Share this post Link to post Share on other sites
AgentPaper 1 Report post Posted October 21, 2012 Ok, finally got around to looking at it. I see you've got it set up so that it shows both the list of lore items and the window which I assume will eventually show the text both showing at the same time. Instead, I'd prefer it if those were two separate screens, so that each of them can take up the whole screen if necessary. Then, you can have the list of lore items be 14 tall and 4 wide, and if there's more than 56 lore items (and there will be), it scrolls left and right to show more, rather than up and down. Example: ! Lore Item 1 & Lore Item 15 @ Lore item 2 * Lore Item 16 # Lore item 3 etc... $ Lore Item 4 % Lore Item 5 ^ Lore Item 6 etc... Then, the lore text itself would have it's own full-screen window, which shows the text and such, and they can change pages with left and right, and scroll through text with up and down. Share this post Link to post Share on other sites
diagostimo 11 Report post Posted October 21, 2012 ok i can make those ajustments, i have a quick question, i have been playing with the text files and have been able to convert the text into arrays to use as configuration, my question is do you want me to make the script convert the data from the text file and save it into a new unaccessable file? e.g: the script checks if file "lore (id) (page).data" exists if it exists it gets the data from that file if it doesnt exist it checks for the file "lore (id) (page).txt" if the txt file doesnt exist it will error as your trying to call an item that has no settings if the text file exists, it reads the data and then creates the .data file (or whatever extension it has) the .data file is used from then on allowing you to remove or delete the text files so someone else cant edit them if you need to change the configuration of an item, you can simply delete the data file, then re add the text file to be loaded creating the new file with new settings i think this would be the best way to ensure that others cant come in and change stuff, it would all be automated by the script the only thing you would have to do is call each item at least once so it converts the data Share this post Link to post Share on other sites
AgentPaper 1 Report post Posted October 21, 2012 (edited) That sounds fine, though if the .data file is inaccessible, how would I get to it to delete it? Edit: Actually, I think I've come up with an easier/more secure version: Add a section of code that runs when the game starts, which looks for .txt files for all of the lore items, and then creates .data files for each of them. Then, once I'm done adding lore items, I can comment out that section of code. Simple, and hassle-free. Edited October 21, 2012 by AgentPaper Share this post Link to post Share on other sites
diagostimo 11 Report post Posted October 21, 2012 no the actual file will be visible, but the data will be converted to a format that is inaccessable, converting it all to variables and saving it like a save file, but to a directory so it doesnt clutter your game directory Share this post Link to post Share on other sites
AgentPaper 1 Report post Posted October 22, 2012 (edited) Ah, I see. Anyways, I'd prefer the method that just requires commenting out a section of code once I'm ready to release, rather than needing to find and delete data files whenever I change something. Edited October 22, 2012 by AgentPaper Share this post Link to post Share on other sites
diagostimo 11 Report post Posted October 24, 2012 ok i have made a fair amount of progress on this, here is the up to date script: module Lore_Config #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# # * Script Calls: #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# # $game_system.lore_items.push(ID) # * Adds lore items to the possession # * ID can be a single id or mutiple like so : ID, ID, ID # # $scene = Scene_Lore_Choice.new # * Calls the lore items scene #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# # * End Of Script Calls #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# # * Begin Configuration #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# #setup the array of lore items possessable, this is needed so they can all be #displayed in the choice window, the order you put them is the order they are #displayed #setup is like so: [[id, pages], [id, pages], [id, pages] #ect] LORE_ITEMS = [ [0, 2], #you can indent and make notes like this [1, 4], [2, 4] ] #===============================================# # * SETUP FOR ITEMS NAME AND ICONS # # ICONS MUST BE STORED IN ICONS DIRECTORY # #===============================================# def self.item_config(id) case id #when ID then [iTEM_NAME, OBTAINED_ICON_NAME, UN-OBTAINED_ICON_NAME] when 0 then ["name 1", "046-Skill03", ""] when 1 then ["name 2", "046-Skill03", ""] when 2 then ["name 3", "", ""] else ["name #{id + 1}", "046-Skill03", ""] end end #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# # * End Configuration #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-# end #============================================================================== # ** Game_System #============================================================================== class Game_System #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :lore_items #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- alias init_lore_items initialize def initialize init_lore_items @lore_items = [] end end #============================================================================== # ** Window_Horizontal #------------------------------------------------------------------------------ # This window class contains horizontal cursor movement and scroll functions. #============================================================================== class Window_Horizontal < Window_Base #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :index #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) @item_max = 1 @row_max = 1 @index = -1 @cursor_width = 32 @offset = 32 end #-------------------------------------------------------------------------- # * Set Cursor Position # index : new cursor position #-------------------------------------------------------------------------- def index=(index) @index = index # Update cursor rectangle update_cursor_rect end #-------------------------------------------------------------------------- # * Get Column Count #-------------------------------------------------------------------------- def column_max # Compute columns from number of items and columns return (@item_max + @row_max - 1) / @row_max end #-------------------------------------------------------------------------- # * Get Left Column #-------------------------------------------------------------------------- def left_column # Divide x-coordinate of window contents transfer origin by 1 column # width of cursor width return self.ox / (@cursor_width + @offset) end #-------------------------------------------------------------------------- # * Set Left Column # column : column shown on Left #-------------------------------------------------------------------------- def left_column=(column) # If column is less than 0, change it to 0 if column < 0 column = 0 end # If column exceeds column_max - 1, change it to column_max - 1 if column > column_max - 1 column = column_max - 1 end # Multiply 1 column width by cursor width for x-coordinate of window contents # transfer origin self.ox = column * (@cursor_width + @offset) end #-------------------------------------------------------------------------- # * Get Number of Columns Displayable on 1 Page #-------------------------------------------------------------------------- def page_column_max # Subtract a frame width of 32 from the window width, and divide it by # 1 column width of cursor width return (self.width - 32) / (@cursor_width + @offset) end #-------------------------------------------------------------------------- # * Get Number of Items Displayable on 1 Page #-------------------------------------------------------------------------- def page_item_max # Multiply column count (page_column_max) times column count (@column_max) return page_column_max * @row_max end #-------------------------------------------------------------------------- # * Update Cursor Rectangle #-------------------------------------------------------------------------- def update_cursor_rect # If cursor position is less than 0 if @index < 0 self.cursor_rect.empty return end # Get current column column = @index / @row_max # If current column is before left column if column < self.left_column # Scroll so that current column becomes left column self.left_column = column end # If current column is more to right than right column if column > self.left_column + (self.page_column_max - 1) # Scroll so that current column becomes back column self.left_column = column - (self.page_column_max - 1) end # Calculate cursor coordinates x = 16 + (@index / @row_max * (@cursor_width + @offset) - self.ox) y = @index % @row_max * 32 # Update cursor rectangle self.cursor_rect.set(x, y, @cursor_width, 32) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super # If cursor is movable if self.active and @item_max > 0 and @index >= 0 # If pressing down on the directional buttons if Input.repeat?(Input::DOWN) # If row count is 2 or more, and cursor position is closer to front # than (item count -1) if @row_max >= 2 and @index < @item_max - 1 # Move cursor right $game_system.se_play($data_system.cursor_se) @index += 1 end end # If the up directional button was pressed if Input.repeat?(Input::UP) # If row count is 2 or more, and cursor position is more back than 0 if @row_max >= 2 and @index > 0 # Move cursor left $game_system.se_play($data_system.cursor_se) @index -= 1 end end # If the right directional button was pressed if Input.repeat?(Input::RIGHT) # If row count is 1 and directional button was pressed down with no # repeat, or if cursor position is more to the front than # (item count - row count) if (@row_max == 1 and Input.trigger?(Input::RIGHT)) or @index < @item_max - @row_max # Move cursor down $game_system.se_play($data_system.cursor_se) @index = (@index + @row_max) % @item_max elsif @index >= (@item_max - 1) - @row_max @index = @item_max - 1 end end # If the left directional button was pressed if Input.repeat?(Input::LEFT) # If row count is 1 and directional button was pressed up with no # repeat, or if cursor position is more to the back than row count if (@row_max == 1 and Input.trigger?(Input::LEFT)) or @index >= @row_max # Move cursor up $game_system.se_play($data_system.cursor_se) @index = (@index - @row_max + @item_max) % @item_max end end end # Update cursor rectangle update_cursor_rect end end #============================================================================== # ** Window_Lore_Choice #------------------------------------------------------------------------------ # This window class manages the Lore selection phase #============================================================================== class Window_Lore_Choice < Window_Horizontal #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(index = 0) super(0, 0, 640, 480) @item_max = Lore_Config::LORE_ITEMS.size @row_max = 14 @cursor_width = 120 self.index = index self.contents = Bitmap.new(32 + ((@item_max / @row_max) * (@cursor_width + @offset) + @cursor_width), height - 32) refresh end #-------------------------------------------------------------------------- # * refresh #-------------------------------------------------------------------------- def refresh for i in 0...@item_max x = 16 + (i / @row_max * (@cursor_width + @offset)) y = i % @row_max * 32 rect = Rect.new(x, y, @cursor_width, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) item_config = Lore_Config.item_config(Lore_Config::LORE_ITEMS[i][0]) if $game_system.lore_items.include?(Lore_Config::LORE_ITEMS[i][0]) text = item_config[0] self.contents.font.color = normal_color icon = RPG::Cache.icon(item_config[1]) else text = "--------------" self.contents.font.color = disabled_color icon = RPG::Cache.icon(item_config[2]) end opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.draw_text(x + 32, y, @cursor_width - 32, 32, text) self.contents.blt(x + 4, y + 4, icon, Rect.new(0, 0, 24, 24), opacity) end end end #============================================================================== # ** Scene_Lore_Choice #------------------------------------------------------------------------------ # This Scene displays the lore selection phase #============================================================================== class Scene_Lore_Choice #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(index = 0) @index = index end #-------------------------------------------------------------------------- # * Main Proccessing #-------------------------------------------------------------------------- def main @lore_window = Window_Lore_Choice.new(@index) Graphics.transition loop { Graphics.update; Input.update; update; break if $scene != self } @lore_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update @lore_window.update if Input.trigger?(Input::C) lore_id = Lore_Config::LORE_ITEMS[@lore_window.index][0] if $game_system.lore_items.include?(lore_id) $game_system.se_play($data_system.decision_se) $scene = Scene_Lore_Item.new(@lore_window.index) else $game_system.se_play($data_system.buzzer_se) end end end end #============================================================================== # ** Window Lore Item #------------------------------------------------------------------------------ # this window class manages the lore item display #============================================================================== class Window_Lore_Item < Window_Base #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :lore_index, :page_number #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(index) super(0, 0, 640, 480) #get index called from @lore_index = index #get lore window id @lore_id = Lore_Config::LORE_ITEMS[@lore_index][0] #setup start page number @page_number = 1 #get max page @max_page_number = Lore_Config::LORE_ITEMS[@lore_index][1] #set up page setup_page #create self.contents self.contents = Bitmap.new(width - 32, height - 32) #refresh contents refresh end #-------------------------------------------------------------------------- # *setup page contents #-------------------------------------------------------------------------- def setup_page directory = "lore items" filename = "lore #{@lore_id} #{@page_number}.rxdata" path = ".\\#{directory}\\" + filename if FileTest.exist?(path) file = File.open(path, "r") @picture_config = Marshal.load(file) @text_window_config = Marshal.load(file) @lore_text = Marshal.load(file) file.close else p "the file '#{filename}' does not exist in the directory: '#{directory}'" exit end end #-------------------------------------------------------------------------- # * Draw Images #-------------------------------------------------------------------------- def draw_images (0...@picture_config.size).each {|i| image = @picture_config[i] bmp = RPG::Cache.picture(image[2]) rect = Rect.new(0, 0, bmp.width, bmp.height) self.contents.blt(image[0], image[1], bmp, rect, image[3]) } end #-------------------------------------------------------------------------- # * draw text box #-------------------------------------------------------------------------- def draw_text_box text = [] cg = @text_window_config (0...@lore_text.size).each {|i| sliced_text = self.contents.slice_text(@lore_text[i], cg[2]) sliced_text.each {|t| text.push(t) } } @text_box = Window_Lore_Text.new(cg[0], cg[1], cg[2] + 32, cg[3] + 32, text, cg[4]) end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh #clear content self.contents.clear #draw page number text = "page #{@page_number}/#{@max_page_number}" cx = self.contents.text_size(text).width self.contents.draw_text(self.contents.width - cx, self.contents.height - 32, cx, 32, text) #draw images draw_images #draw text box draw_text_box end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super @text_box.update #refresh contents if Input.trigger?(Input::LEFT) if @page_number > 1 @text_box.dispose $game_system.se_play($data_system.cursor_se) @page_number -= 1 setup_page refresh end elsif Input.trigger?(Input::RIGHT) if @page_number < @max_page_number @text_box.dispose $game_system.se_play($data_system.cursor_se) @page_number += 1 setup_page refresh end end end #-------------------------------------------------------------------------- # * Dispose #-------------------------------------------------------------------------- def dispose super @text_box.dispose end end #============================================================================== # ** Window_Lore_Text #------------------------------------------------------------------------------ # This window class manages the Lore text box display #============================================================================== class Window_Lore_Text < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y, width, height, text, z) super(x, y, width, height) @text = text @height = height - 32 @width = width - 32 self.z = z self.contents = Bitmap.new(width - 32, @text.size * 32) draw_text end #-------------------------------------------------------------------------- # * draw text #-------------------------------------------------------------------------- def draw_text (0...@text.size).each {|i| self.contents.draw_text(0, i * 32, @width, 32, @text[i], 1) } end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update if Input.repeat?(Input::UP) self.oy += 5 if self.oy < self.contents.height - (self.height - 32) self.oy = self.contents.height - (self.height - 32) if self.oy > self.contents.height - (self.height - 32) #p self.oy elsif Input.repeat?(Input::DOWN) self.oy -= 5 if self.oy > 0 end end end #============================================================================== # ** Scene_Lore_Item #------------------------------------------------------------------------------ # This Scene displays the Lore Item window #============================================================================== class Scene_Lore_Item #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(index) @last_index = index end #-------------------------------------------------------------------------- # * Main Proccessing #-------------------------------------------------------------------------- def main @lore_item_window = Window_Lore_Item.new(@last_index) Graphics.transition loop { Graphics.update; Input.update; update; break if $scene != self } @lore_item_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update @lore_item_window.update if Input::trigger?(Input::B) $scene = Scene_Lore_Choice.new(@lore_item_window.lore_index) $game_system.se_play($data_system.cancel_se) end end end #=============================================================================== # ** Bitmap #=============================================================================== class Bitmap # Blizzard's slice_text method. This method can be removed if you have another # script that already uses it. def slice_text(text, width) words = text.split(' ') return words if words.size == 1 result, current_text = [], words.shift words.each_index {|i| if self.text_size("#{current_text} #{words[i]}").width > width result.push(current_text) current_text = words[i] else current_text = "#{current_text} #{words[i]}" end result.push(current_text) if i >= words.size - 1} return result end end the script calls and config within the script have changed slightly so re look over them, now you need to add text files into a directory to be converted, in your main projects folder create a folder called "lore items", spelled exact, then in this folder is where you put txt files to convert, call your text files as follows "lore ID PAGE.txt" with the spaces, obviously compensate the page and id acordingly, so for lore id 1 page 1: "lore 1 1.txt" now how to setup your text files, in a txt file copy and paste this base: #images config[x, y, image_name, opacity] #opacity:255MAX, 0 MIN [0, 0, picture_1, 255], [0, 0, picture_1, 255], [0, 0, picture_1, 255] #text box settings[x, y, width, height, z] [0, 0, 100, 128, 200] then the text for the window then the text for the window then the text for the window ect ect ect ect ect ect ect ect ect ect ect do not add quotation marks "" for anything, the following script converts all the data acordingly, all you need to know is line 1 and 3 are reserved for the comments, line 2 and 4 are the configurations then the rest of the text document is text to be displayed the script to convert data: class Game_System def create_file(id, page) #directory name directory = "lore items" #create directory if it doesnt exist unless File.directory?(directory) Dir.mkdir(directory) end #get source and target target_filename = "lore #{id} #{page}.rxdata" source_filename = "lore #{id} #{page}.txt" target_path = ".\\#{directory}\\" + target_filename source_path = ".\\#{directory}\\" + source_filename #if source text file exists if FileTest.exist?(source_path) #read text file text_file = IO.readlines(source_path) #open/create target file target_file = File.open(target_path, "wb") #create picture config array picture_config = [] #get line in text document for picture config picture_line = text_file[1] #convert the whole picture config into one array converted_config = picture_line.gsub!(/[\[\]]/,'').split(/\s*,\s*/) #loop and sort the picture data into arrays for i in 0...(converted_config.size / 4) #create the images config shell picture_config[i] = [] #loop through each configs string for j in (i * 4)...((i * 4) + 4) #if it is other that the string turn it into an integer if j != (i * 4) + 2 picture_config[i].push(converted_config[j].to_i) #if it is the string leave it as a string else picture_config[i].push(converted_config[j]) end end end #dump pictures config Marshal.dump(picture_config, target_file) #get tet box settings text_settings = [] text_line = text_file[3] converted_text_settings = text_line.gsub!(/[\[\]]/,'').split(/\s*,\s*/) for i in 0...converted_text_settings.size text_settings.push(converted_text_settings[i].to_i) end #dump text settings Marshal.dump(text_settings, target_file) #get text text = [] for i in 4...text_file.size text.push(text_file[i]) end #dump text Marshal.dump(text, target_file) #close target file target_file.close else #print no file if no file print "no target text file found for item/page" end end end the converter will not automaticlly work as of yet, but i will add that feature, for now to convert each document use the following script call in an event: $game_system.create_file(ID, PAGE) i know its a pain to do the script call for every id and page now is a bit of a pain but its just for test purposes for now, after it has converted the txt document in the same dirtectory you will se the encrypted .rxdata files, so you can then delete your text files once you no longer need them, dont wory about deleting the data files there automaticly updated when the script runs let me know what you think :) Share this post Link to post Share on other sites
AgentPaper 1 Report post Posted October 24, 2012 Awesome. I should have a chance to try it out later tonight. Share this post Link to post Share on other sites
diagostimo 11 Report post Posted October 24, 2012 sweet, when testing note that the images are drawn in the order you arrange them in the array, from bottom to top, also i have added scrolling to the text field, so throw lots of text in there and test it out :) Share this post Link to post Share on other sites