赞 | 0 |
VIP | 10 |
好人卡 | 49 |
积分 | 10 |
经验 | 22958 |
最后登录 | 2020-8-1 |
在线时间 | 2161 小时 |
Lv3.寻梦者 酱油的
- 梦石
- 0
- 星屑
- 1020
- 在线时间
- 2161 小时
- 注册时间
- 2007-12-22
- 帖子
- 3271
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
RMVX 用的外挂數據庫編輯器,主要功能可以隨意添加「新的屬性」
http://www.filepub.com/pfiles/7066/Wxdata.rar
使用後記得按下 save,另外如果增加了新的屬性,麻煩手動把相應的拋出代碼加入自己的腳本編輯器當中。
此外,記得備份。由此産生的任何data損害禾西概不負責。
初版發布,具體的修改慢慢來好了 XD
不負責任地逃跑 ——
PS:多謝輪回者前輩跨時空相助
對了,差點忘記開源代碼:
使用工具 : Ruby 與 Wxruby
- require 'Win32API'
- # Error Raise
- class Exception
- alias :ozrmesage :message
- def message
- mes = ozrmesage
- Win32API.new('user32', 'MessageBox', %w(p p p i), 'i').call(0,mes , 'Warning', 0)
- return mes
- end
- end
- Dir.chdir("./sdata")
- Dir["*.rb"].each{|f|require("./"+f)}
- # Create a data instance
- class Rvdata
- def initialize(filename, scriptname)
- @script = Script.new(scriptname, 'o')
- @classname = File.basename(scriptname,'.*')
- p filename
- @data = File.open("../Data/#{filename}", "rb"){|f|Marshal.load(f)}
- @filename = filename
- end
- def read
- return @data
- end
- def control
- return @data
- end
- def inst(index)
- return @data[index].instance_variables
- end
- def init
- @data << eval("RPG::#{@classname}.new")
- @data[-1].id = @data.size - 1
- end
- def write(index, str, val)
- @data[index].instance_variable_set("@#{str}", val)
- end
- def save
- File.open("../Data/#{@filename}", "wb"){|f| Marshal.dump(@data, f)}
- @script.save
- p "Saved #{@filename}"
- end
- def add(bstr, val)
- str = "@#{bstr}"
- @data.each_index do |index|
- next if @data[index].nil?
- next if @data[index].instance_variable_get(str) != nil
- @data[index].instance_variable_set(str, val)
- end
- @script.add(bstr,val)
- end
- def del(bstr)
- str = "@#{bstr}"
- @data.each_index do |index|
- next if @data[index].nil?
- next if @data[index].instance_variable_get(str) == nil
- @data[index].send(:remove_instance_variable, str.to_sym)
- end
- @script.del(bstr)
- end
- end
- # Create a basic Script control data
- class Script
- def initialize(filename, mode)
- case mode
- when 'o'
- @content = File.open(filename,'r'){|f|f.read}
- @filename = filename
- @classname = File.basename(filename,'.*')
- when 'n'
- @content = File.open('Format.rb','r'){|f|f.read}
- @filename = filename
- @classname = File.basename(filename,'.*')
- @content[/class Format/]="class#{@classname}"
- end
- end
- def read
- return @content
- end
- def save
- File.open(@filename, 'w'){|f|f.write(@content)}
- File.open("../#{@classname}.txt", 'w'){|f|f.write(@content)}
- end
- def add(bstr,val)
- return false if eval("defined?(RPG::#{@classname}.new.#{bstr})")
- begin
- @content[/# 1/] =
- if val == ""
- "@#{bstr} = \"\"\n# 1"
- else
- "@#{bstr} = #{val}\n# 1"
- end
- @content[/# 2/]= "attr_accessor :#{bstr}\n# 2"
- rescue
- raise 'Existing undefined Error'
- end
- return true
- end
- def del(bstr)
- return false unless eval("defined?(RPG::#{@classname}.new.#{bstr})")
- @content[/@#{str} = \S*$\n/]=""
- @content[/attr_accessor :#{str}$\n/]=""
- return true
- end
- end
- # Basic Format
- begin
- require 'rubygems'
- rescue LoadError
- end
- require 'wx'
- include Wx
- #=====================================================================================================================
- class DataPage < Panel
- def initialize(parent, log, data, index = 1)
- super(parent, -1)
- # Record All Parameters
- @parent = parent
- @log =log
- @data = data
- @id = index
-
- @list = {}
- @listele = @data.inst(index).map!{|s|s.delete('@')}.sort!
-
- repaint(index)
- fresh(0)
- end
-
- def repaint(index)
-
- #Create Button
- Button.new(self,10,'Save Edit',Point.new(0,0),Size.new(150,50))
- evt_button(10) {|event| on_save}
-
- #Create List
- listdata = ([email protected]).to_a.map!{|s|"#{sprintf("%#03d", s)}: #{@data.read[s].name}"}
- @list[:d] = ListBox.new(self, 20, Point.new(150,0), Size.new(150,450), listdata)
- evt_listbox(20) {|event| on_list_d(event)}
-
- #Initialize a New Element to this class (Button)
- Button.new(self, 30,'Initialize',Point.new(300,0))
- StaticText.new(self, -1,'@', Point.new(380,0))
- n = TextCtrl.new(self, -1,'',Point.new(390,0))
- StaticText.new(self, -1,'=',Point.new(500,0))
- v = TextCtrl.new(self, -1,'',Point.new(520,0))
- evt_button(30){on_cre(n.get_value, v.get_value); n.clear; v.clear}
-
- #Delete a Old Element of this class (Button)
- Button.new(self, 40,'Delete',Point.new(300,30))
- StaticText.new(self, -1,'@', Point.new(380,30))
- e = TextCtrl.new(self, -1,'',Point.new(390,30))
- evt_button(40){on_del(e.get_value); e.clear}
-
- #Change the Name of this Item
- Button.new(self, 50,'Change Name',Point.new(300,60))
- l = TextCtrl.new(self, -1,'',Point.new(400,60), Size.new(220,20))
- evt_button(50){
- @list[:d].set_string(
- (@id-1) , "#{sprintf("%#03d", @id)}: #{l.get_value}"
- )
- @data.read[@id].name = l.get_value
- @text.set_value(l.get_value) if @listele[@index] == 'name'
- l.set_value('')
- }
-
- #Edit the Item's Amout of this Class
- @edit_text = TextCtrl.new(self,-1,'1',Point.new(150,450))
- Button.new(self, 60,'OK',Point.new(250,450),Size.new(50,20))
- evt_button(60) {on_edit}
-
- #The list showing all Elements of this class
- @list[:e] = ListBox.new(self, 70, Point.new(620,0), Size.new(150,300), @listele)
- evt_listbox(@list[:e].get_id) {|event| on_list_e(event)}
-
- #The 2nd list showing all Elements of the Selecting Element(For the instance of Table or a Array Containing Serial instances )
- @list[:e2] = ListBox.new(self, 80, Point.new(450,90), Size.new(170,210), [])
- evt_listbox(@list[:e2].get_id) {|event| on_list_e2(event.get_selection)}
- #The Controling Text
- @text = TextCtrl.new(self,-1,'',Point.new(480,300),Size.new(300,200),TE_MULTILINE)
- end
- def on_cre(nval, vval)
- return if @listele.include?(nval) or nval == ""
- begin
- @data.add(
- nval,
- begin
- eval(vval)
- rescue
- vval
- end
- )
- rescue
- end
- @listele << nval
- @list[:e].append(nval)
- end
- def on_del(str)
- @list[:e2] = nil
- return unless @listele.include?(str) or str != ""
- @data.del(str)
- @list[:e].delete(@listele.index(str))
- @listele.delete(str)
-
- end
- def on_edit
- size = @data.read.size - 1
- begin
- num = @edit_text.get_value.to_i
- rescue
- num = size
- end
- if num > size
- (num - size).times{
- |i|
- @data.init
- @list[:d].append("#{ sprintf("%#03d", @data.read[-1].id) }: #{@data.read[-1].name}")
- }
- else
- while num < size
- size -= 1
- @list[:d].delete(size)
- @data.control.delete_at(-1)
- end
- end
- end
- def on_save
- $data.each_value{|data|data.save}
- end
- def on_list_d(event)
- record
- @id = event.get_selection+1
- fresh(@index)
- end
- def on_list_e(event)
- record
- index = event.get_selection
- fresh(index)
- end
- def on_list_e2(index2)
- if @table != nil
- para = @listele_2[@index2].split(/, /)
- para.map!{|s|s.to_i}
- @table[para[0], para[1], para[2] ] = @text.get_value.to_i
-
- @index2 = index2
-
- para = @listele_2[index2].split(/, /)
- para.map!{|s|s.to_i}
- @text.set_value( @table[para[0], para[1], para[2] ].inspect )
- end
- end
- =begin
- def on_list_e3(index3)
- if @array != nil
- @index3 = index3
- @text.set_value(eval("@array[@index2].#{@listele_3[@index3]}").inspect)
- end
- end
- =end
- def record
- return if @skip
- return if @data.read[@id].nil?
- str = @listele[@index]
- # The resolution to Table instance
- if @table != nil
- on_list_e2(@index2)
- @data.write(@id, str, @table)
- @table = nil
- return
- end
- # The resolution to a Array Containing Serial instances
-
- text = @text.get_value
- # The resolution to a Empty String instance
- if text == ""
- @data.write(@id, str, "")
- return
- end
-
- begin
- val = eval(text)
- rescue SyntaxError, NameError
- val = text
- ensure
- end
-
- @data.write(@id, str, val)
-
- end
- def fresh(index)
- # Element Index
- @index = index
- #=>
- if @data.read[@id].nil?
- return
- end
- #repaint
- text = @data.read[@id].instance_variable_get("@#{@listele[index]}")
- #=>
- if @listele_2 != []
- @listele_2 = []
- @list[:e2].set(@listele_2)
- end
- #=>
- case @listele[index]
- when "name", "id", "learnings", "actions", "drop_item1", "drop_item2", "pages", "members", "list"
- @skip = true
- @text.hide
- return
- end
- #=>
- if @skip
- @skip = false
- @text.show
- end
- #=>
- case text
- when Table
- @index2 = 0
- @listele_2 = []
- @table = text
- text.xsize.times do |x|; text.ysize.times do |y|; text.zsize.times do |z|
- @listele_2 << "#{x}, #{y}, #{z}"
- end; end; end
- @list[:e2].set(@listele_2)
- @text.set_value(text[0,0,0].inspect)
- return
- when Array
- @text.set_value(text.inspect)
- return
- when String
- @text.set_value(text)
- return
- else
- @text.set_value(text.inspect)
- return
- end
-
-
- end
- end
- #=====================================================================================================================
- class NewNotebook < Notebook
- def initialize(parent, id ,log)
- super(parent, id, DEFAULT_POSITION, DEFAULT_SIZE, NB_BOTTOM)
- add_page(DataPage.new(self, -1, $data[:actors]), 'Actor')
- add_page(DataPage.new(self, -1, $data[:classes]), 'Class')
- add_page(DataPage.new(self, -1, $data[:skills]), 'Skill')
- add_page(DataPage.new(self, -1, $data[:items]), 'Item')
- add_page(DataPage.new(self, -1, $data[:weapons]), 'Weapon')
- add_page(DataPage.new(self, -1, $data[:armors]), 'Armor')
- add_page(DataPage.new(self, -1, $data[:enemies]), 'Enemy')
- add_page(DataPage.new(self, -1, $data[:troop]), 'Troop')
- add_page(DataPage.new(self, -1, $data[:states]), 'State')
- add_page(DataPage.new(self, -1, $data[:commonEvents]), 'CommonEvent')
- end
- end
- #=====================================================================================================================
- class NewFrame < Frame
- def initialize(title)
- super(nil, :title => title, :size=>[800, 600])
- $data = {}
-
- $data[:actors] = Rvdata.new('Actors.rvdata', 'Actor.rb')
- $data[:classes] = Rvdata.new('Classes.rvdata', 'Class.rb')
- $data[:skills] = Rvdata.new('Skills.rvdata', 'Skill.rb')
- $data[:items] = Rvdata.new('Items.rvdata', 'Item.rb')
- $data[:weapons] = Rvdata.new('Weapons.rvdata', 'Weapon.rb')
- $data[:armors] = Rvdata.new('Armors.rvdata', 'Armor.rb')
- $data[:enemies] = Rvdata.new('Enemies.rvdata', 'Enemy.rb')
- $data[:troop] = Rvdata.new('Troops.rvdata', 'Troop.rb')
- $data[:states] = Rvdata.new('States.rvdata', 'State.rb')
- $data[:commonEvents] = Rvdata.new('CommonEvents.rvdata', 'CommonEvent.rb')
-
- NewNotebook.new(self, -1, Log.new)
-
- menu_bar =MenuBar.new
- menu = []
-
- menu << [Menu.new(),"&File"]
- menu[-1][0].append(ID_SAVE, "&Save\tAlt-S", "")
- menu[-1][0].append(ID_EXIT, "E&xit\tAlt-X", "")
-
-
- menu << [Menu.new(), "&Help"]
- menu[-1][0].append(ID_ABOUT, "&About...\tF1", "")
-
- menu_bar = MenuBar.new()
- menu.each{|m|menu_bar.append(m[0], m[1])}
- self.menu_bar = menu_bar
- create_status_bar(menu.size)
-
- self.status_text = ""
-
- evt_menu(ID_SAVE, :on_save)
- evt_menu(ID_EXIT, :on_quit)
- evt_menu(ID_ABOUT, :on_about)
-
- evt_close {|evt| evt.skip }
-
- end
-
- def on_save
- $data.each_value{|data|data.save}
- end
- def on_quit
- close()
- end
- def on_about
-
- end
- end
- #=====================================================================================================================
- class NewApp < App
- def on_init
- NewFrame.new("RM Editor").show( )
- end
- end
- NewApp.new().main_loop()
复制代码
同樣功能的東東的介紹= =不要再問我這個是甚麽東東?
http://rpg.blue/viewthread.php?tid=50762 |
|