Created
January 25, 2013 13:33
-
-
Save take-cheeze/4634488 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby -Ku | |
| # coding: UTF-8 | |
| class Table | |
| def initialize(x, y = 1, z = 1) | |
| end | |
| end | |
| class Color | |
| def initialize(r,g,b,a) | |
| end | |
| end | |
| def rpg_define_attrs(list) | |
| list.each { |k,v| | |
| attr_accessor k.to_sym | |
| } | |
| @rpg_attr_list = list | |
| define_method(:initialize) { | |
| self.class.instance_variable_get(:@rpg_attr_list).each { |k,v| | |
| # deep clone | |
| self.send((k.to_s + "=").to_sym, Marshal.load(Marshal.dump(v))) | |
| } | |
| } | |
| alias :rpg_initialize :initialize | |
| end | |
| module RPG | |
| class AudioFile | |
| rpg_define_attrs({ | |
| :name => nil, | |
| :volume => nil, | |
| :pitch => nil, | |
| }) | |
| def initialize(name = "", volume = 100, pitch = 100) | |
| @name = name | |
| @volume = volume | |
| @pitch = pitch | |
| end | |
| end | |
| class Map | |
| rpg_define_attrs({ | |
| :tileset_id => 1, | |
| :width => nil, | |
| :height => nil, | |
| :autoplay_bgm => false, | |
| :bgm => RPG::AudioFile.new, | |
| :autoplay_bgs => false, | |
| :bgs => RPG::AudioFile.new("", 80), | |
| :encounter_list => [], | |
| :encounter_step => 30, | |
| :data => nil, | |
| :events => [], | |
| }) | |
| def initialize(w, h) | |
| rpg_initialize | |
| @width = width | |
| @height = height | |
| @data = Table.new(width, height, 3) | |
| end | |
| end | |
| class MapInfo | |
| rpg_define_attrs({ | |
| :name => "", | |
| :parent_id => 0, | |
| :order => 0, | |
| :expanded => false, | |
| :scroll_x => 0, | |
| :scroll_y => 0, | |
| }) | |
| end | |
| class MoveCommand | |
| rpg_define_attrs({ | |
| :code => nil, | |
| :parameters => nil, | |
| }) | |
| def initialize(code = 0, parameters = []) | |
| @code = code | |
| @parameters = parameters | |
| end | |
| end | |
| class MoveRoute | |
| rpg_define_attrs({ | |
| :repeat => true, | |
| :skippable => false, | |
| :list => [RPG::MoveCommand.new], | |
| }) | |
| end | |
| class EventCommand | |
| rpg_define_attrs({ | |
| :code => nil, | |
| :indent => nil, | |
| :parameters => nil, | |
| }) | |
| def initialize(code = 0, indent = 0, parameters = []) | |
| @code = code | |
| @indent = indent | |
| @parameters = parameters | |
| end | |
| end | |
| class Event | |
| class Page | |
| class Condition | |
| rpg_define_attrs({ | |
| :switch1_valid => false, | |
| :switch2_valid => false, | |
| :variable_valid => false, | |
| :self_switch_valid => false, | |
| :switch1_id => 1, | |
| :switch2_id => 1, | |
| :variable_id => 1, | |
| :variable_value => 0, | |
| :self_switch_ch => "A", | |
| }) | |
| end | |
| class Graphic | |
| rpg_define_attrs({ | |
| :tile_id => 0, | |
| :character_name => "", | |
| :character_hue => 0, | |
| :direction => 2, | |
| :pattern => 0, | |
| :opacity => 255, | |
| :blend_type => 0, | |
| }) | |
| end | |
| rpg_define_attrs({ | |
| :condition => RPG::Event::Page::Condition.new, | |
| :graphic => RPG::Event::Page::Graphic.new, | |
| :move_type => 0, | |
| :move_speed => 3, | |
| :move_frequency => 3, | |
| :move_route => RPG::MoveRoute.new, | |
| :walk_anime => true, | |
| :step_anime => false, | |
| :direction_fix => false, | |
| :through => false, | |
| :always_on_top => false, | |
| :trigger => 0, | |
| :list => [RPG::EventCommand.new], | |
| }) | |
| end | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :x => nil, | |
| :y => nil, | |
| :pages => [RPG::Event::Page.new], | |
| }) | |
| def initialize(x, y) | |
| rpg_initialize | |
| @x = x | |
| @y = y | |
| end | |
| end | |
| class Actor | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :class_id => 1, | |
| :initial_level => 1, | |
| :final_level => 99, | |
| :exp_basis => 30, | |
| :exp_inflation => 30, | |
| :character_name => "", | |
| :character_hue => 0, | |
| :battler_name => "", | |
| :battler_hue => 0, | |
| :weapon_id => 0, | |
| :armor1_id => 0, | |
| :armor2_id => 0, | |
| :armor3_id => 0, | |
| :armor4_id => 0, | |
| :weapon_fix => false, | |
| :armor1_fix => false, | |
| :armor2_fix => false, | |
| :armor3_fix => false, | |
| :armor4_fix => false, | |
| :parameters => nil, | |
| }) | |
| def initialize | |
| rpg_initialize | |
| @parameters = Table.new(6,100) | |
| for i in 1..99 | |
| @parameters[0,i] = 500+i*50 | |
| @parameters[1,i] = 500+i*50 | |
| @parameters[2,i] = 50+i*5 | |
| @parameters[3,i] = 50+i*5 | |
| @parameters[4,i] = 50+i*5 | |
| @parameters[5,i] = 50+i*5 | |
| end | |
| end | |
| end | |
| class Class | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :position => 0, | |
| :weapon_set => [], | |
| :armor_set => [], | |
| :element_ranks => Table.new(1), | |
| :state_ranks => Table.new(1), | |
| :learnings => [], | |
| }) | |
| class Learning | |
| rpg_define_attrs({ | |
| :level => 1, | |
| :skill_id => 1, | |
| }) | |
| end | |
| end | |
| class Skill | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :icon_name => "", | |
| :description => "", | |
| :scope => 0, | |
| :occasion => 1, | |
| :animation1_id => 0, | |
| :animation2_id => 0, | |
| :menu_se => RPG::AudioFile.new("", 80), | |
| :common_event_id => 0, | |
| :sp_cost => 0, | |
| :power => 0, | |
| :atk_f => 0, | |
| :eva_f => 0, | |
| :str_f => 0, | |
| :dex_f => 0, | |
| :agi_f => 0, | |
| :int_f => 100, | |
| :hit => 100, | |
| :pdef_f => 0, | |
| :mdef_f => 100, | |
| :variance => 15, | |
| :element_set => [], | |
| :plus_state_set => [], | |
| :minus_state_set => [], | |
| }) | |
| end | |
| class Item | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :icon_name => "", | |
| :description => "", | |
| :scope => 0, | |
| :occasion => 0, | |
| :animation1_id => 0, | |
| :animation2_id => 0, | |
| :menu_se => RPG::AudioFile.new("", 80), | |
| :common_event_id => 0, | |
| :price => 0, | |
| :consumable => true, | |
| :parameter_type => 0, | |
| :parameter_points => 0, | |
| :recover_hp_rate => 0, | |
| :recover_hp => 0, | |
| :recover_sp_rate => 0, | |
| :recover_sp => 0, | |
| :hit => 100, | |
| :pdef_f => 0, | |
| :mdef_f => 0, | |
| :variance => 0, | |
| :element_set => [], | |
| :plus_state_set => [], | |
| :minus_state_set => [], | |
| }) | |
| end | |
| class Weapon | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :icon_name => "", | |
| :description => "", | |
| :animation1_id => 0, | |
| :animation2_id => 0, | |
| :price => 0, | |
| :atk => 0, | |
| :pdef => 0, | |
| :mdef => 0, | |
| :str_plus => 0, | |
| :dex_plus => 0, | |
| :agi_plus => 0, | |
| :int_plus => 0, | |
| :element_set => [], | |
| :plus_state_set => [], | |
| :minus_state_set => [], | |
| }) | |
| end | |
| class Armor | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :icon_name => "", | |
| :description => "", | |
| :kind => 0, | |
| :auto_state_id => 0, | |
| :price => 0, | |
| :pdef => 0, | |
| :mdef => 0, | |
| :eva => 0, | |
| :str_plus => 0, | |
| :dex_plus => 0, | |
| :agi_plus => 0, | |
| :int_plus => 0, | |
| :guard_element_set => [], | |
| :guard_state_set => [], | |
| }) | |
| end | |
| class Enemy | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :icon_name => "", | |
| :description => "", | |
| :kind => 0, | |
| :auto_state_id => 0, | |
| :price => 0, | |
| :pdef => 0, | |
| :mdef => 0, | |
| :eva => 0, | |
| :str_plus => 0, | |
| :dex_plus => 0, | |
| :agi_plus => 0, | |
| :int_plus => 0, | |
| :guard_element_set => [], | |
| :guard_state_set => [], | |
| }) | |
| class Action | |
| rpg_define_attrs({ | |
| :kind => 0, | |
| :basic => 0, | |
| :skill_id => 1, | |
| :condition_turn_a => 0, | |
| :condition_turn_b => 1, | |
| :condition_hp => 100, | |
| :condition_level => 1, | |
| :condition_switch_id => 0, | |
| :rating => 5, | |
| }) | |
| end | |
| end | |
| class Troop | |
| class Page | |
| class Condition | |
| rpg_define_attrs({ | |
| :turn_valid => false, | |
| :enemy_valid => false, | |
| :actor_valid => false, | |
| :switch_valid => false, | |
| :turn_a => 0, | |
| :turn_b => 0, | |
| :enemy_index => 0, | |
| :enemy_hp => 50, | |
| :actor_id => 1, | |
| :actor_hp => 50, | |
| :switch_id => 1, | |
| }) | |
| end | |
| rpg_define_attrs({ | |
| :condition => RPG::Troop::Page::Condition.new, | |
| :span => 0, | |
| :list => [RPG::EventCommand.new], | |
| }) | |
| end | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :members => [], | |
| :pages => [RPG::Troop::Page.new], | |
| }) | |
| class Member | |
| rpg_define_attrs({ | |
| :enemy_id => 1, | |
| :x => 0, | |
| :y => 0, | |
| :hidden => false, | |
| :immortal => false, | |
| }) | |
| end | |
| end | |
| class State | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :animation_id => 0, | |
| :restriction => 0, | |
| :nonresistance => false, | |
| :zero_hp => false, | |
| :cant_get_exp => false, | |
| :cant_evade => false, | |
| :slip_damage => false, | |
| :rating => 5, | |
| :hit_rate => 100, | |
| :maxhp_rate => 100, | |
| :maxsp_rate => 100, | |
| :str_rate => 100, | |
| :dex_rate => 100, | |
| :agi_rate => 100, | |
| :int_rate => 100, | |
| :atk_rate => 100, | |
| :pdef_rate => 100, | |
| :mdef_rate => 100, | |
| :eva => 0, | |
| :battle_only => true, | |
| :hold_turn => 0, | |
| :auto_release_prob => 0, | |
| :shock_release_prob => 0, | |
| :guard_element_set => [], | |
| :plus_state_set => [], | |
| :minus_state_set => [], | |
| }) | |
| end | |
| class Animation | |
| class Frame | |
| rpg_define_attrs({ | |
| :cell_max => 0, | |
| :cell_data => Table.new(0, 0), | |
| }) | |
| end | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :animation_name => "", | |
| :animation_hue => 0, | |
| :position => 1, | |
| :frame_max => 1, | |
| :frames => [RPG::Animation::Frame.new], | |
| :timings => [], | |
| }) | |
| class Timing | |
| rpg_define_attrs({ | |
| :frame => 0, | |
| :se => RPG::AudioFile.new("", 80), | |
| :flash_scope => 0, | |
| :flash_color => Color.new(255,255,255,255), | |
| :flash_duration => 5, | |
| :condition => 0, | |
| }) | |
| end | |
| end | |
| class Tileset | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :tileset_name => "", | |
| :autotile_names => [""]*7, | |
| :panorama_name => "", | |
| :panorama_hue => 0, | |
| :fog_name => "", | |
| :fog_hue => 0, | |
| :fog_opacity => 64, | |
| :fog_blend_type => 0, | |
| :fog_zoom => 200, | |
| :fog_sx => 0, | |
| :fog_sy => 0, | |
| :battleback_name => "", | |
| :passages => Table.new(384), | |
| :priorities => Table.new(384), | |
| :terrain_tags => Table.new(384), | |
| }) | |
| def initialize | |
| rpg_initialize | |
| @priorities[0] = 5 | |
| end | |
| end | |
| class CommonEvent | |
| rpg_define_attrs({ | |
| :id => 0, | |
| :name => "", | |
| :trigger => 0, | |
| :switch_id => 1, | |
| :list => [RPG::EventCommand.new], | |
| }) | |
| end | |
| class System | |
| class Words | |
| rpg_define_attrs({ | |
| :gold => "", | |
| :hp => "", | |
| :sp => "", | |
| :str => "", | |
| :dex => "", | |
| :agi => "", | |
| :int => "", | |
| :atk => "", | |
| :pdef => "", | |
| :mdef => "", | |
| :weapon => "", | |
| :armor1 => "", | |
| :armor2 => "", | |
| :armor3 => "", | |
| :armor4 => "", | |
| :attack => "", | |
| :skill => "", | |
| :guard => "", | |
| :item => "", | |
| :equip => "", | |
| }) | |
| end | |
| rpg_define_attrs({ | |
| :magic_number => 0, | |
| :party_members => [1], | |
| :elements => [nil, ""], | |
| :switches => [nil, ""], | |
| :variables => [nil, ""], | |
| :windowskin_name => "", | |
| :title_name => "", | |
| :gameover_name => "", | |
| :battle_transition => "", | |
| :title_bgm => RPG::AudioFile.new, | |
| :battle_bgm => RPG::AudioFile.new, | |
| :battle_end_me => RPG::AudioFile.new, | |
| :gameover_me => RPG::AudioFile.new, | |
| :cursor_se => RPG::AudioFile.new("", 80), | |
| :decision_se => RPG::AudioFile.new("", 80), | |
| :cancel_se => RPG::AudioFile.new("", 80), | |
| :buzzer_se => RPG::AudioFile.new("", 80), | |
| :equip_se => RPG::AudioFile.new("", 80), | |
| :shop_se => RPG::AudioFile.new("", 80), | |
| :save_se => RPG::AudioFile.new("", 80), | |
| :load_se => RPG::AudioFile.new("", 80), | |
| :battle_start_se => RPG::AudioFile.new("", 80), | |
| :escape_se => RPG::AudioFile.new("", 80), | |
| :actor_collapse_se => RPG::AudioFile.new("", 80), | |
| :enemy_collapse_se => RPG::AudioFile.new("", 80), | |
| :words => RPG::System::Words.new, | |
| :test_battlers => [], | |
| :test_troop_id => 1, | |
| :start_map_id => 1, | |
| :start_x => 0, | |
| :start_y => 0, | |
| :battleback_name => "", | |
| :battler_name => "", | |
| :battler_hue => 0, | |
| :edit_map_id => 1, | |
| }) | |
| class TestBattler | |
| rpg_define_attrs({ | |
| :actor_id => 1, | |
| :level => 1, | |
| :weapon_id => 0, | |
| :armor1_id => 0, | |
| :armor2_id => 0, | |
| :armor3_id => 0, | |
| :armor4_id => 0, | |
| }) | |
| end | |
| end | |
| end | |
| raise "argument error" unless ARGV.length == 1 | |
| p "showing %s" % ARGV[0] | |
| data = Marshal.load(IO.read(ARGV[0])) | |
| require 'rubygems' | |
| require 'Qt' | |
| def add_to_tree(d, parent, name) | |
| Qt::TreeWidgetItem.new([name]) { | |
| @rpg_data = d | |
| still_root = false | |
| if parent.class == Qt::TreeWidgetItem | |
| parent.addChild self | |
| elsif parent.class == Qt::TreeWidget and not @rpg_data.instance_of? Array | |
| parent.addTopLevelItem self | |
| else | |
| still_root = true | |
| end | |
| if @rpg_data.instance_of? Array | |
| @rpg_data.each_index { |i| | |
| v = @rpg_data[i] | |
| if v != nil | |
| add_to_tree(v, still_root ? parent : self, "%05d: %s" % [i, v.name]) | |
| end | |
| } | |
| else | |
| @rpg_data.instance_variables.each { |v| | |
| name = v | |
| v = d.instance_variable_get(name) | |
| if v.instance_variables.length > 0 | |
| add_to_tree(v, self, name) | |
| end | |
| } | |
| end | |
| } | |
| end | |
| Qt::Application.new(ARGV) { | |
| main_win = Qt::Widget.new { | |
| setWindowTitle "RGSS data viewer" | |
| right_side = Qt::Widget.new { | |
| setLayout Qt::HBoxLayout.new | |
| } | |
| tree = Qt::TreeWidget.new { | |
| setHeaderLabel "Name" | |
| @right_side = right_side | |
| add_to_tree(data, self, "data") | |
| connect(self, SIGNAL('currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)')) { |curr,prev| | |
| while not @right_side.layout.isEmpty | |
| target = @right_side.layout.itemAt(0) | |
| target.widget.hide | |
| @right_side.layout.removeItem target | |
| end | |
| rpg_data = curr.instance_variable_get(:@rpg_data) | |
| new_form = Qt::Widget.new { | |
| setLayout Qt::FormLayout.new { | |
| rpg_data.instance_variables.each { |v| | |
| name = v | |
| v = rpg_data.instance_variable_get(name) | |
| item = nil | |
| if v.instance_of? Fixnum | |
| item = Qt::SpinBox.new | |
| item.setValue v | |
| elsif v.instance_of? String | |
| item = Qt::LineEdit.new(v) | |
| elsif v.instance_of? TrueClass | |
| item = Qt::ComboBox.new | |
| item.addItem "true" | |
| item.addItem "false" | |
| item.editable = false | |
| item.setCurrentIndex 0 | |
| elsif v.instance_of? FalseClass | |
| item = Qt::ComboBox.new | |
| item.addItem "true" | |
| item.addItem "false" | |
| item.editable = false | |
| item.setCurrentIndex 1 | |
| end | |
| if item != nil | |
| addRow(name.to_s, item) | |
| end | |
| } | |
| } | |
| } | |
| @right_side.layout.addWidget new_form | |
| @right_side.layout.update | |
| } | |
| setCurrentItem topLevelItem(0) | |
| } | |
| setLayout Qt::HBoxLayout.new { | |
| addWidget(tree) | |
| addWidget(right_side) | |
| } | |
| } | |
| main_win.show | |
| exec | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment