class UserConfig

UserConfig 動的な設定

プログラムから動的に変更される設定。 プラグインの設定ではないので注意。

Public Class Methods

[](key) click to toggle source

設定名 key にたいする値を取り出す 値が設定されていない場合、nilを返す。

# File core/userconfig.rb, line 171
def self.[](key)
  UserConfig.instance.at(key, @@defaults[key.to_sym])
end
[]=(key, val) click to toggle source

設定名 key に値 value を関連付ける

# File core/userconfig.rb, line 176
def self.[]=(key, val)
  watchers = synchronize{
    if not(@@watcher[key].empty?)
      before_val = UserConfig.instance.at(key, @@defaults[key.to_sym])
      @@watcher[key].map{ |id|
        proc = if @@watcher_id.has_key?(id)
                 @@watcher_id[id]
               else
                 @@watcher[key].delete(id)
                 nil end
        lambda{ proc.call(key, val, before_val, id) } if proc } end }
  if watchers.is_a? Enumerable
    watchers.each{ |w| w.call if w } end
  UserConfig.instance.store(key, val)
end
connect(key, &watcher) click to toggle source

設定名 key の値が変更されたときに、ブロック watcher を呼び出す。 watcher_idを返す。

# File core/userconfig.rb, line 194
def self.connect(key, &watcher)
  synchronize{
    id = @@watcher_id_count
    @@watcher_id_count += 1
    @@watcher[key] = @@watcher[key].push(id)
    @@watcher_id[id] = watcher
    id
  }
end
disconnect(id) click to toggle source

watcher idが id のwatcherを削除する。

# File core/userconfig.rb, line 205
def self.disconnect(id)
  synchronize{
    @@watcher_id.delete(id)
  }
end
include?(key) click to toggle source

キーに対応する値が存在するかを調べる。 値が設定されていれば、それが nilfalse であっても true を返す

Args

key

Symbol キー

Return

true

存在する

false

存在しない

# File core/userconfig.rb, line 165
def self.include?(key)
  UserConfig.instance.include?(key) || @@defaults.include?(key)
end
key_add(key, name, slug) click to toggle source
# File core/userconfig.rb, line 240
def self.key_add(key, name, slug)
  type_strict key => String, name => String, slug => Symbol
  keys = UserConfig[:shortcutkey_keybinds].melt
  keys[(keys.keys.max || 0)+1] = {
    :key => key,
    :name => name,
    :slug => slug}
  UserConfig[:shortcutkey_keybinds] = keys end
setup() click to toggle source
# File core/userconfig.rb, line 211
def self.setup
  last_boot_version = UserConfig[:last_boot_version] || [0, 0, 0, 0]
  if last_boot_version < Environment::VERSION.to_a
    UserConfig[:last_boot_version] = Environment::VERSION.to_a
    if last_boot_version == [0, 0, 0, 0]
      key_add "Alt + x", "コンソールを開く", :console_open end
    if last_boot_version < [3, 3, 0, 0]
      UserConfig[:notification_enable] = true
      activity_show_statusbar = (UserConfig[:activity_show_statusbar] || []).map(&:to_s)
      unless activity_show_statusbar.include? 'streaming_status'
        activity_show_statusbar << 'streaming_status'
        UserConfig[:activity_show_statusbar] = activity_show_statusbar end end
    if last_boot_version < [3, 4, 0, 0]
      UserConfig[:replyviewer_background_color] = UserConfig[:mumble_reply_bg]
      UserConfig[:quote_background_color] = UserConfig[:mumble_basic_bg]
      UserConfig[:reply_text_font] = UserConfig[:mumble_reply_font] || 'Sans 8'
      UserConfig[:reply_text_color] = UserConfig[:mumble_reply_color] || [0x6666, 0x6666, 0x6666]
      UserConfig[:reply_icon_size] = 24
      UserConfig[:quote_text_font] = UserConfig[:reply_text_font] || 'Sans 8'
      UserConfig[:quote_text_color] = UserConfig[:reply_text_color]
      UserConfig[:reply_present_policy] = %<icon>
      UserConfig[:quote_edge] = :floating
      UserConfig[:reply_text_max_line_count] = 3
      UserConfig[:reply_clicked_action] = nil
      UserConfig[:quote_clicked_action] = :smartthread
    end
  end
end