Module: Lich::Common
- Defined in:
- documented/games.rb,
documented/vars.rb,
documented/common/gtk.rb,
documented/common/hmr.rb,
documented/common/log.rb,
documented/common/vars.rb,
documented/common/spell.rb,
documented/common/buffer.rb,
documented/common/script.rb,
documented/common/account.rb,
documented/common/eaccess.rb,
documented/common/gameobj.rb,
documented/attributes/char.rb,
documented/common/db_store.rb,
documented/common/settings.rb,
documented/common/uservars.rb,
documented/common/watchfor.rb,
documented/common/front-end.rb,
documented/common/gui-login.rb,
documented/common/xmlparser.rb,
documented/common/map/map_dr.rb,
documented/common/map/map_gs.rb,
documented/common/game-loader.rb,
documented/common/limitedarray.rb,
documented/common/sharedbuffer.rb,
documented/common/upstreamhook.rb,
documented/common/downstreamhook.rb,
documented/common/class_exts/stringproc.rb,
documented/common/settings/charsettings.rb,
documented/common/settings/gamesettings.rb,
documented/common/settings/path_navigator.rb,
documented/common/settings/settings_proxy.rb,
documented/common/settings/database_adapter.rb,
documented/common/class_exts/synchronizedsocket.rb
Overview
Provides common GUI functionality for Lich
Defined Under Namespace
Modules: Account, Buffer, CharSettings, DB_Store, EAccess, Frontend, GameLoader, GameSettings, HMR, Log, Settings, UserVars, Vars Classes: Char, DatabaseAdapter, DownstreamHook, ExecScript, GameObj, LimitedArray, Map, PathNavigator, Room, RoomObj, Script, Scripting, SettingsProxy, SharedBuffer, Spell, StringProc, SynchronizedSocket, UpstreamHook, Watchfor, WizardScript, XMLParser
Constant Summary collapse
- TRUSTED_SCRIPT_BINDING =
A proc that returns a trusted script binding
proc { _script }
Instance Method Summary collapse
- #_script ⇒ Object
-
#gui_login ⇒ void
Initiates the GUI login process for Lich.
Instance Method Details
#_script ⇒ Object
29 30 31 |
# File 'documented/common/script.rb', line 29 def _script Proc.new {}.binding end |
#gui_login ⇒ void
This method returns an undefined value.
Initiates the GUI login process for Lich. Loads entry data, sets up the GUI, and handles user interactions.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'documented/common/gui-login.rb', line 16 def gui_login @autosort_state = Lich.track_autosort_state @tab_layout_state = Lich.track_layout_state @theme_state = Lich.track_dark_mode @launch_data = nil # Checks if the entry data file exists and loads it if available. # @note This method relies on the DATA_DIR constant being defined. if File.exist?(File.join(DATA_DIR, "entry.dat")) @entry_data = File.open(File.join(DATA_DIR, "entry.dat"), 'r') { |file| begin if @autosort_state == true # 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 @entry_data = Array.new end @save_entry_data = false Gtk.queue { @window = nil install_tab_loaded = false # Displays a message dialog with the provided message. # @param msg [String] The message to display in the dialog. # @return [void] # @example Showing an error message # @msgbox.call("An error occurred") @msgbox = proc { |msg| dialog = Gtk::MessageDialog.new(:parent => @window, :flags => Gtk::DialogFlags::DESTROY_WITH_PARENT, :type => Gtk::MessageType::ERROR, :buttons => Gtk::ButtonsType::CLOSE, :message => msg) # dialog.set_icon(default_icon) dialog.run dialog.destroy } # the following files are split out to ease interface design # they have to be included in the method's Gtk queue block to # be used, so they have to be called at this specific point. require_relative 'gui-saved-login' require_relative 'gui-manual-login' # # put it together and show the window # lightgrey = Gdk::RGBA::parse("#d3d3d3") @notebook = Gtk::Notebook.new @notebook.override_background_color(:normal, lightgrey) unless @theme_state == true # Appends a page to the notebook for saved entries. # @note This is part of the GUI setup process. @notebook.append_page(@quick_game_entry_tab, Gtk::Label.new('Saved Entry')) @notebook.append_page(@game_entry_tab, Gtk::Label.new('Manual Entry')) @notebook.signal_connect('switch-page') { |_who, _page, page_num| if (page_num == 2) and not install_tab_loaded .clicked end } # grey = Gdk::RGBA::parse("#d3d3d3") @window = Gtk::Window.new @window.set_icon(@default_icon) # Sets the title of the main window for the application. # @note The title includes the LICH_VERSION constant. @window.title = "Lich v#{LICH_VERSION}" @window.border_width = 5 @window.add(@notebook) @window.signal_connect('delete_event') { @window.destroy; @done = true } @window.default_width = 590 @window.default_height = 550 @window.show_all @custom_launch_entry.visible = false @custom_launch_dir.visible = false @bonded_pair_char.visible = false @bonded_pair_inst.visible = false @slider_box.visible = false @notebook.set_page(1) if @entry_data.empty? } # Waits until the login process is completed. # @note This is a blocking call that halts execution until @done is true. wait_until { @done } # Saves the entry data to a file if the save flag is set. # @note This operation may overwrite existing data. if @save_entry_data File.open(File.join(DATA_DIR, "entry.dat"), 'w') { |file| file.write([Marshal.dump(@entry_data)].pack('m')) } end @entry_data = nil # Checks if there is launch data available before quitting. # @note This ensures the application does not exit prematurely. unless !@launch_data.nil? Gtk.queue { Gtk.main_quit } Lich.log "info: exited without selection" exit end end |