Module: Lich::Common::GUI::State
- Defined in:
- documented/common/gui/state.rb
Class Method Summary collapse
-
.apply_theme_settings(theme_state) ⇒ void
Applies the theme settings based on the provided state.
-
.load_saved_entries(data_dir, autosort_state) ⇒ Array
Loads saved entries from a specified data directory.
-
.save_entries(data_dir, entry_data) ⇒ Boolean
Saves the given entry data to the specified data directory.
Class Method Details
.apply_theme_settings(theme_state) ⇒ void
This method returns an undefined value.
Applies the theme settings based on the provided state.
59 60 61 |
# File 'documented/common/gui/state.rb', line 59 def self.apply_theme_settings(theme_state) Gtk::Settings.default.gtk_application_prefer_dark_theme = true if theme_state == true end |
.load_saved_entries(data_dir, autosort_state) ⇒ Array
Loads saved entries from a specified data directory.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'documented/common/gui/state.rb', line 13 def self.load_saved_entries(data_dir, autosort_state) if File.exist?(File.join(data_dir, "entry.dat")) File.open(File.join(data_dir, "entry.dat"), 'r') { |file| begin if autosort_state # Sort in list by instance name, account name, and then character name Marshal.load(file.read.unpack('m').first).sort do |a, b| [a[:game_name], a[:user_id], a[:char_name]] <=> [b[:game_name], b[:user_id], b[:char_name]] end else # Sort in list by account name, and then character name (old Lich 4) Marshal.load(file.read.unpack('m').first).sort do |a, b| [a[:user_id].downcase, a[:char_name]] <=> [b[:user_id].downcase, b[:char_name]] end end rescue Array.new end } else Lich.log "Info: No entry.dat file detected, probable new installation." Array.new end end |
.save_entries(data_dir, entry_data) ⇒ Boolean
Saves the given entry data to the specified data directory.
45 46 47 48 49 50 51 52 |
# File 'documented/common/gui/state.rb', line 45 def self.save_entries(data_dir, entry_data) File.open(File.join(data_dir, "entry.dat"), 'w') { |file| file.write([Marshal.dump(entry_data)].pack('m')) } true rescue false end |