プロジェクト

全般

プロフィール

提案 #1255 » 1255-1.patch

Yuto Tokunaga, 2018-05-27 19:51

差分を表示:

core/plugin/gtk/world_shifter.rb
class Gtk::WorldShifter < Gtk::EventBox
UserConfig[:gtk_accountbox_geometry] ||= 32
UserConfig[:gtk_last_world_slug] ||= nil
def initialize
super
......
refresh
end
pluggaloid_event_listener
restore_last_world
end
def refresh
......
modify_face
end
def restore_last_world
slug = UserConfig[:gtk_last_world_slug]
world = Enumerator.new do |y|
Plugin.filtering :worlds, y
end.select { |w| w.slug == slug } &.first
Plugin.call(:world_change_current, world) if world
end
def save_current_world
world = Plugin.filtering(:world_current, nil).first
UserConfig[:gtk_last_world_slug] = world.slug
end
def open_menu(event)
@menu ||= Gtk::Menu.new.tap do |menu|
Enumerator.new{|y|
......
def pluggaloid_event_listener
tag = Plugin[:gtk].handler_tag(:world_shifter) do
Plugin[:gtk].on_world_change_current{ refresh }
Plugin[:gtk].on_world_change_current do
refresh
save_current_world
end
Plugin[:gtk].on_userconfig_modify do |key, newval|
refresh if key == :world_shifter_visibility
end
Plugin[:gtk].on_world_after_created do |world|
refresh
save_current_world
end
Plugin[:gtk].on_world_destroy do |world|
refresh
save_current_world
end
end
ssc(:destroy) do
(1-1/2)