Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module IMP_ReadWrite_Excel
- Perform = true
- end
- class Scene_Title
- alias impexcel_start start unless $@
- def start
- if $TEST && IMP_ReadWrite_Excel::Perform
- $scene = Scene_ReadWrite_Excel.new
- else
- impexcel_start
- end
- end
- alias impexcel_terminate terminate unless $@
- def terminate
- impexcel_teminate if !($TEST && IMP_ReadWrite_Excel::Perform)
- end
- end
- class Scene_ReadWrite_Excel < Scene_Base
- def start
- @window = Window_Base.new(0, 0, Graphics.width/2, Graphics.Height)
- text = "Do you want to read data or write data?"
- width = @window.contents.width
- @window.contents.draw_text(0, 0, width, Window_Base::WLH, text, 1)
- @choice = Window_Command.new(128, ["Read","Write"])
- @choice.x = Graphics.width / 2
- @choice.y = Window_Base::WLH + 32
- @choice.active = true
- text = "If you're writing data, don't forget the .rb file needs to be on your desktop."
- y = Graphics.height - Window_Base::WLH
- @window.contents.draw_text(0, y, width, Window_Base::WLH, text, 1)
- end
- def update
- @choice.update if @choice.active
- update_input
- end
- def update_input
- if Input.trigger?(Input::B)
- Sound.play_buzzer
- end
- if Input.trigger?(Input::C)
- case @choice.index
- when 0; read_processing
- when 1; write_processing
- end
- @choice.active = false
- @choice.visible = false
- end
- end
- def write_processing
- file = File.new("C:\\Users\\Public\\Desktop\\" + RPG::System.game_title, "w+")
- Marshal.dump($data_items, file)
- file.close
- @window.contents.clear
- text = "Done."
- width = @window.contents.width
- @window.contents.draw_text(0, 0, width, Window_Base::WLH, text, 1)
- end
- def read_processing
- file = File.open("C:\\Users\\Public\\Desktop\\" + RPG::System.game_title, "w+")
- data_items = Marshal.load(file)
- save_data(data_items, "Data/Actors.rvdata")
- file.close
- @window.contents.clear
- text = "Done."
- width = @window.contents.width
- @window.contents.draw_text(0, 0, width, Window_Base::WLH, text, 1)
- end
- def terminate
- @choice.dispose
- @window.dispose
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement