<commit_before>
require_relative 'ui_skeleton_editor'

class SkeletonEditorDialog < Qt::Dialog
  GREY_PEN = Qt::Pen.new(Qt::Brush.new(Qt::Color.new(128, 128, 128)), 2)
  RED_PEN = Qt::Pen.new(Qt::Brush.new(Qt::Color.new(224, 16, 16)), 2)
  GREEN_PEN = Qt::Pen.new(Qt::Brush.new(Qt::Color.new(16, 224, 16)), 2)
  BLUE_PEN = Qt::Pen.new(Qt::Brush.new(Qt::Color.new(16, 16, 224)), 2)
  WHITE_PEN = Qt::Pen.new(Qt::Brush.new(Qt::Color.new(255, 255, 255)), 2)
  
  attr_reader :game, :fs
  
  slots "pose_changed_no_tween(int)"
  slots "toggle_show_skeleton(int)"
  slots "toggle_show_hitboxes(int)"
  slots "toggle_show_points(int)"
  slots "animation_changed(int)"
  slots "animation_keyframe_changed_no_tween(int)"
  slots "toggle_animation_paused()"
  slots "advance_tweenframe()"
  slots "export_to_spriter()"
  slots "button_box_clicked(QAbstractButton*)"
  
  def initialize(parent, sprite_info, fs, renderer)
    super(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
    
    
    @sprite_info = sprite_info
    @fs = fs
    @renderer = renderer
    
    @ui = Ui_SkeletonEditor.new
    @ui.setup_ui(self)
    
    @skeleton_graphics_scene = Qt::GraphicsScene.new
    @skeleton_graphics_scene.setBackgroundBrush(ClickableGraphicsScene::BACKGROUND_BRUSH)
    @ui.skeleton_graphics_view.setScene(@skeleton_graphics_scene)
    
    @animation_timer = Qt::Timer.new()
    @animation_timer.setSingleShot(true)
    connect(@animation_timer, SIGNAL("timeout()"), self, SLOT("advance_tweenframe()"))
    
    set_animation_paused(true)
    
    connect(@ui.pose_index, SIGNAL("activated(int)"), self, SLOT("pose_changed_no_tween(int)"))
    connect(@ui.show_skeleton, SIGNAL("stateChanged(int)"), self, SLOT("toggle_show_skeleton(int)"))
    connect(@ui.show_hitboxes, SIGNAL("stateChanged(int)"), self, SLOT("toggle_show_hitboxes(int)"))
    connect(@ui.show_points, SIGNAL("stateChanged(int)"), self, SLOT("toggle_show_points(int)"))
    connect(@ui.animation_index, SIGNAL("activated(int)"), self, SLOT("animation_changed(int)"))
    connect(@ui.seek_slider, SIGNAL("valueChanged(int)"), self, SLOT("animation_keyframe_changed_no_tween(int)"))
    connect(@ui.toggle_paused_button, SIGNAL("clicked()"), self, SLOT("toggle_animation_paused()"))
    connect(@ui.spriter_export, SIGNAL("clicked()"), self, SLOT("export_to_spriter()"))
    connect(@ui.buttonBox, SIGNAL("clicked(QAbstractButton*)"), self, SLOT("button_box_clicked(QAbstractButton*)"))
    
    self.show()
    
    self.load_skeleton()
  end
  
  def load_skeleton
    @skeleton = SpriteSkeleton.new(@sprite_info.skeleton_file, @fs)
    
    chunky_frames, @min_x, @min_y, _, _, _, _, _ = @renderer.render_sprite(@sprite_info)
    @pixmap_frames = chunky_frames.map do |chunky_image|
      pixmap = Qt::Pixmap.new
      blob = chunky_image.to_blob
      pixmap.loadFromData(blob, blob.length)
      pixmap
    end
    
    @ui.skeleton_file_name.text = @skeleton.skeleton_file
    
    @ui.pose_index.clear()
    @skeleton.poses.each_index do |i|
      @ui.pose_index.addItem("%02X" % i)
    end
    <commit_msg>Skeleton viewer: Hide Spriter export button since it's incomplete<commit_after>
require_relative 'ui_skeleton_editor'

class SkeletonEditorDialog < Qt::Dialog
  GREY_PEN = Qt::Pen.new(Qt::Brush.new(Qt::Color.new(128, 128, 128)), 2)
  RED_PEN = Qt::Pen.new(Qt::Brush.new(Qt::Color.new(224, 16, 16)), 2)
  GREEN_PEN = Qt::Pen.new(Qt::Brush.new(Qt::Color.new(16, 224, 16)), 2)
  BLUE_PEN = Qt::Pen.new(Qt::Brush.new(Qt::Color.new(16, 16, 224)), 2)
  WHITE_PEN = Qt::Pen.new(Qt::Brush.new(Qt::Color.new(255, 255, 255)), 2)
  
  attr_reader :game, :fs
  
  slots "pose_changed_no_tween(int)"
  slots "toggle_show_skeleton(int)"
  slots "toggle_show_hitboxes(int)"
  slots "toggle_show_points(int)"
  slots "animation_changed(int)"
  slots "animation_keyframe_changed_no_tween(int)"
  slots "toggle_animation_paused()"
  slots "advance_tweenframe()"
  slots "export_to_spriter()"
  slots "button_box_clicked(QAbstractButton*)"
  
  def initialize(parent, sprite_info, fs, renderer)
    super(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
    
    
    @sprite_info = sprite_info
    @fs = fs
    @renderer = renderer
    
    @ui = Ui_SkeletonEditor.new
    @ui.setup_ui(self)
    
    @skeleton_graphics_scene = Qt::GraphicsScene.new
    @skeleton_graphics_scene.setBackgroundBrush(ClickableGraphicsScene::BACKGROUND_BRUSH)
    @ui.skeleton_graphics_view.setScene(@skeleton_graphics_scene)
    
    @animation_timer = Qt::Timer.new()
    @animation_timer.setSingleShot(true)
    connect(@animation_timer, SIGNAL("timeout()"), self, SLOT("advance_tweenframe()"))
    
    set_animation_paused(true)
    
    connect(@ui.pose_index, SIGNAL("activated(int)"), self, SLOT("pose_changed_no_tween(int)"))
    connect(@ui.show_skeleton, SIGNAL("stateChanged(int)"), self, SLOT("toggle_show_skeleton(int)"))
    connect(@ui.show_hitboxes, SIGNAL("stateChanged(int)"), self, SLOT("toggle_show_hitboxes(int)"))
    connect(@ui.show_points, SIGNAL("stateChanged(int)"), self, SLOT("toggle_show_points(int)"))
    connect(@ui.animation_index, SIGNAL("activated(int)"), self, SLOT("animation_changed(int)"))
    connect(@ui.seek_slider, SIGNAL("valueChanged(int)"), self, SLOT("animation_keyframe_changed_no_tween(int)"))
    connect(@ui.toggle_paused_button, SIGNAL("clicked()"), self, SLOT("toggle_animation_paused()"))
    connect(@ui.spriter_export, SIGNAL("clicked()"), self, SLOT("export_to_spriter()"))
    connect(@ui.buttonBox, SIGNAL("clicked(QAbstractButton*)"), self, SLOT("button_box_clicked(QAbstractButton*)"))
    
    @ui.spriter_export.hide()
    
    self.show()
    
    self.load_skeleton()
  end
  
  def load_skeleton
    @skeleton = SpriteSkeleton.new(@sprite_info.skeleton_file, @fs)
    
    chunky_frames, @min_x, @min_y, _, _, _, _, _ = @renderer.render_sprite(@sprite_info)
    @pixmap_frames = chunky_frames.map do |chunky_image|
      pixmap = Qt::Pixmap.new
      blob = chunky_image.to_blob
      pixmap.loadFromData(blob, blob.length)
      pixmap
    end
    
    @ui.skeleton_file_name.text = @skeleton.skeleton_file
    
    @ui.pose_index.clear()
    @skeleton.poses.each_index do |i|
      @ui.pose_index.addItem("%02X" % i)
    end
    
{'fraction_non_alphanumeric': 0.14994399103856618, 'fraction_numerical': 0.014722355576892302, 'mean_word_length': 5.109481915933529, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '907756', 'n_tokens_mistral': 2416, 'n_tokens_neox': 2280, 'n_words': 313}