# coding: utf-8 require 'ffi' module LiveSplitCore module Native extend FFI::Library ffi_lib File.expand_path('../liblivesplit_core.so', __FILE__) attach_function :AtomicDateTime_drop, [:pointer], :void attach_function :AtomicDateTime_is_synchronized, [:pointer], :bool attach_function :AtomicDateTime_to_rfc2822, [:pointer], :string attach_function :AtomicDateTime_to_rfc3339, [:pointer], :string attach_function :Attempt_index, [:pointer], :int32 attach_function :Attempt_time, [:pointer], :pointer attach_function :Attempt_pause_time, [:pointer], :pointer attach_function :Attempt_started, [:pointer], :pointer attach_function :Attempt_ended, [:pointer], :pointer attach_function :BlankSpaceComponent_new, [], :pointer attach_function :BlankSpaceComponent_drop, [:pointer], :void attach_function :BlankSpaceComponent_into_generic, [:pointer], :pointer attach_function :BlankSpaceComponent_state_as_json, [:pointer, :pointer], :string attach_function :BlankSpaceComponent_state, [:pointer, :pointer], :pointer attach_function :BlankSpaceComponentState_drop, [:pointer], :void attach_function :BlankSpaceComponentState_height, [:pointer], :uint32 attach_function :Component_drop, [:pointer], :void attach_function :CurrentComparisonComponent_new, [], :pointer attach_function :CurrentComparisonComponent_drop, [:pointer], :void attach_function :CurrentComparisonComponent_into_generic, [:pointer], :pointer attach_function :CurrentComparisonComponent_state_as_json, [:pointer, :pointer], :string attach_function :CurrentComparisonComponent_state, [:pointer, :pointer], :pointer attach_function :CurrentComparisonComponentState_drop, [:pointer], :void attach_function :CurrentComparisonComponentState_text, [:pointer], :string attach_function :CurrentComparisonComponentState_comparison, [:pointer], :string attach_function :CurrentPaceComponent_new, [], :pointer attach_function :CurrentPaceComponent_drop, [:pointer], :void attach_function :CurrentPaceComponent_into_generic, [:pointer], :pointer attach_function :CurrentPaceComponent_state_as_json, [:pointer, :pointer], :string attach_function :CurrentPaceComponent_state, [:pointer, :pointer], :pointer attach_function :CurrentPaceComponentState_drop, [:pointer], :void attach_function :CurrentPaceComponentState_text, [:pointer], :string attach_function :CurrentPaceComponentState_time, [:pointer], :string attach_function :DeltaComponent_new, [], :pointer attach_function :DeltaComponent_drop, [:pointer], :void attach_function :DeltaComponent_into_generic, [:pointer], :pointer attach_function :DeltaComponent_state_as_json, [:pointer, :pointer, :pointer], :string attach_function :DeltaComponent_state, [:pointer, :pointer, :pointer], :pointer attach_function :DeltaComponentState_drop, [:pointer], :void attach_function :DeltaComponentState_text, [:pointer], :string attach_function :DeltaComponentState_time, [:pointer], :string attach_function :DeltaComponentState_semantic_color, [:pointer], :string attach_function :DetailedTimerComponent_new, [], :pointer attach_function :DetailedTimerComponent_drop, [:pointer], :void attach_function :DetailedTimerComponent_into_generic, [:pointer], :pointer attach_function :DetailedTimerComponent_state_as_json, [:pointer, :pointer, :pointer], :string attach_function :DetailedTimerComponent_state, [:pointer, :pointer, :pointer], :pointer attach_function :DetailedTimerComponentState_drop, [:pointer], :void attach_function :DetailedTimerComponentState_timer_time, [:pointer], :string attach_function :DetailedTimerComponentState_timer_fraction, [:pointer], :string attach_function :DetailedTimerComponentState_timer_semantic_color, [:pointer], :string attach_function :DetailedTimerComponentState_segment_timer_time, [:pointer], :string attach_function :DetailedTimerComponentState_segment_timer_fraction, [:pointer], :string attach_function :DetailedTimerComponentState_comparison1_visible, [:pointer], :bool attach_function :DetailedTimerComponentState_comparison1_name, [:pointer], :string attach_function :DetailedTimerComponentState_comparison1_time, [:pointer], :string attach_function :DetailedTimerComponentState_comparison2_visible, [:pointer], :bool attach_function :DetailedTimerComponentState_comparison2_name, [:pointer], :string attach_function :DetailedTimerComponentState_comparison2_time, [:pointer], :string attach_function :DetailedTimerComponentState_icon_change, [:pointer], :string attach_function :DetailedTimerComponentState_segment_name, [:pointer], :string attach_function :GeneralLayoutSettings_default, [], :pointer attach_function :GeneralLayoutSettings_drop, [:pointer], :void attach_function :GraphComponent_new, [], :pointer attach_function :GraphComponent_drop, [:pointer], :void attach_function :GraphComponent_into_generic, [:pointer], :pointer attach_function :GraphComponent_state_as_json, [:pointer, :pointer, :pointer], :string attach_function :GraphComponent_state, [:pointer, :pointer, :pointer], :pointer attach_function :GraphComponentState_drop, [:pointer], :void attach_function :GraphComponentState_points_len, [:pointer], :size_t attach_function :GraphComponentState_point_x, [:pointer, :size_t], :float attach_function :GraphComponentState_point_y, [:pointer, :size_t], :float attach_function :GraphComponentState_point_is_best_segment, [:pointer, :size_t], :bool attach_function :GraphComponentState_horizontal_grid_lines_len, [:pointer], :size_t attach_function :GraphComponentState_horizontal_grid_line, [:pointer, :size_t], :float attach_function :GraphComponentState_vertical_grid_lines_len, [:pointer], :size_t attach_function :GraphComponentState_vertical_grid_line, [:pointer, :size_t], :float attach_function :GraphComponentState_middle, [:pointer], :float attach_function :GraphComponentState_is_live_delta_active, [:pointer], :bool attach_function :GraphComponentState_is_flipped, [:pointer], :bool attach_function :HotkeySystem_new, [:pointer], :pointer attach_function :HotkeySystem_drop, [:pointer], :void attach_function :HotkeySystem_deactivate, [:pointer], :void attach_function :HotkeySystem_activate, [:pointer], :void attach_function :Layout_new, [], :pointer attach_function :Layout_default_layout, [], :pointer attach_function :Layout_parse_json, [:string], :pointer attach_function :Layout_drop, [:pointer], :void attach_function :Layout_clone, [:pointer], :pointer attach_function :Layout_settings_as_json, [:pointer], :string attach_function :Layout_state_as_json, [:pointer, :pointer], :string attach_function :Layout_push, [:pointer, :pointer], :void attach_function :Layout_scroll_up, [:pointer], :void attach_function :Layout_scroll_down, [:pointer], :void attach_function :Layout_remount, [:pointer], :void attach_function :LayoutEditor_new, [:pointer], :pointer attach_function :LayoutEditor_close, [:pointer], :pointer attach_function :LayoutEditor_state_as_json, [:pointer], :string attach_function :LayoutEditor_layout_state_as_json, [:pointer, :pointer], :string attach_function :LayoutEditor_select, [:pointer, :size_t], :void attach_function :LayoutEditor_add_component, [:pointer, :pointer], :void attach_function :LayoutEditor_remove_component, [:pointer], :void attach_function :LayoutEditor_move_component_up, [:pointer], :void attach_function :LayoutEditor_move_component_down, [:pointer], :void attach_function :LayoutEditor_move_component, [:pointer, :size_t], :void attach_function :LayoutEditor_duplicate_component, [:pointer], :void attach_function :LayoutEditor_set_component_settings_value, [:pointer, :size_t, :pointer], :void attach_function :LayoutEditor_set_general_settings_value, [:pointer, :size_t, :pointer], :void attach_function :ParseRunResult_drop, [:pointer], :void attach_function :ParseRunResult_unwrap, [:pointer], :pointer attach_function :ParseRunResult_parsed_successfully, [:pointer], :bool attach_function :ParseRunResult_timer_kind, [:pointer], :string attach_function :PossibleTimeSaveComponent_new, [], :pointer attach_function :PossibleTimeSaveComponent_drop, [:pointer], :void attach_function :PossibleTimeSaveComponent_into_generic, [:pointer], :pointer attach_function :PossibleTimeSaveComponent_state_as_json, [:pointer, :pointer], :string attach_function :PossibleTimeSaveComponent_state, [:pointer, :pointer], :pointer attach_function :PossibleTimeSaveComponentState_drop, [:pointer], :void attach_function :PossibleTimeSaveComponentState_text, [:pointer], :string attach_function :PossibleTimeSaveComponentState_time, [:pointer], :string attach_function :PotentialCleanUp_drop, [:pointer], :void attach_function :PotentialCleanUp_message, [:pointer], :string attach_function :PreviousSegmentComponent_new, [], :pointer attach_function :PreviousSegmentComponent_drop, [:pointer], :void attach_function :PreviousSegmentComponent_into_generic, [:pointer], :pointer attach_function :PreviousSegmentComponent_state_as_json, [:pointer, :pointer, :pointer], :string attach_function :PreviousSegmentComponent_state, [:pointer, :pointer, :pointer], :pointer attach_function :PreviousSegmentComponentState_drop, [:pointer], :void attach_function :PreviousSegmentComponentState_text, [:pointer], :string attach_function :PreviousSegmentComponentState_time, [:pointer], :string attach_function :PreviousSegmentComponentState_semantic_color, [:pointer], :string attach_function :Run_new, [], :pointer attach_function :Run_parse, [:pointer, :size_t, :string, :bool], :pointer attach_function :Run_parse_file_handle, [:int64, :string, :bool], :pointer attach_function :Run_drop, [:pointer], :void attach_function :Run_clone, [:pointer], :pointer attach_function :Run_game_name, [:pointer], :string attach_function :Run_game_icon, [:pointer], :string attach_function :Run_category_name, [:pointer], :string attach_function :Run_extended_file_name, [:pointer, :bool], :string attach_function :Run_extended_name, [:pointer, :bool], :string attach_function :Run_extended_category_name, [:pointer, :bool, :bool, :bool], :string attach_function :Run_attempt_count, [:pointer], :uint32 attach_function :Run_metadata, [:pointer], :pointer attach_function :Run_offset, [:pointer], :pointer attach_function :Run_len, [:pointer], :size_t attach_function :Run_segment, [:pointer, :size_t], :pointer attach_function :Run_attempt_history_len, [:pointer], :size_t attach_function :Run_attempt_history_index, [:pointer, :size_t], :pointer attach_function :Run_save_as_lss, [:pointer], :string attach_function :Run_custom_comparisons_len, [:pointer], :size_t attach_function :Run_custom_comparison, [:pointer, :size_t], :string attach_function :Run_auto_splitter_settings, [:pointer], :string attach_function :Run_push_segment, [:pointer, :pointer], :void attach_function :Run_set_game_name, [:pointer, :string], :void attach_function :Run_set_category_name, [:pointer, :string], :void attach_function :RunEditor_new, [:pointer], :pointer attach_function :RunEditor_close, [:pointer], :pointer attach_function :RunEditor_state_as_json, [:pointer], :string attach_function :RunEditor_select_timing_method, [:pointer, :uint8], :void attach_function :RunEditor_unselect, [:pointer, :size_t], :void attach_function :RunEditor_select_additionally, [:pointer, :size_t], :void attach_function :RunEditor_select_only, [:pointer, :size_t], :void attach_function :RunEditor_set_game_name, [:pointer, :string], :void attach_function :RunEditor_set_category_name, [:pointer, :string], :void attach_function :RunEditor_parse_and_set_offset, [:pointer, :string], :bool attach_function :RunEditor_parse_and_set_attempt_count, [:pointer, :string], :bool attach_function :RunEditor_set_game_icon, [:pointer, :pointer, :size_t], :void attach_function :RunEditor_remove_game_icon, [:pointer], :void attach_function :RunEditor_insert_segment_above, [:pointer], :void attach_function :RunEditor_insert_segment_below, [:pointer], :void attach_function :RunEditor_remove_segments, [:pointer], :void attach_function :RunEditor_move_segments_up, [:pointer], :void attach_function :RunEditor_move_segments_down, [:pointer], :void attach_function :RunEditor_active_set_icon, [:pointer, :pointer, :size_t], :void attach_function :RunEditor_active_remove_icon, [:pointer], :void attach_function :RunEditor_active_set_name, [:pointer, :string], :void attach_function :RunEditor_active_parse_and_set_split_time, [:pointer, :string], :bool attach_function :RunEditor_active_parse_and_set_segment_time, [:pointer, :string], :bool attach_function :RunEditor_active_parse_and_set_best_segment_time, [:pointer, :string], :bool attach_function :RunEditor_active_parse_and_set_comparison_time, [:pointer, :string, :string], :bool attach_function :RunEditor_add_comparison, [:pointer, :string], :bool attach_function :RunEditor_import_comparison, [:pointer, :pointer, :string], :bool attach_function :RunEditor_remove_comparison, [:pointer, :string], :void attach_function :RunEditor_rename_comparison, [:pointer, :string, :string], :bool attach_function :RunEditor_clear_history, [:pointer], :void attach_function :RunEditor_clear_times, [:pointer], :void attach_function :RunEditor_clean_sum_of_best, [:pointer], :pointer attach_function :RunMetadata_run_id, [:pointer], :string attach_function :RunMetadata_platform_name, [:pointer], :string attach_function :RunMetadata_uses_emulator, [:pointer], :bool attach_function :RunMetadata_region_name, [:pointer], :string attach_function :RunMetadata_variables, [:pointer], :pointer attach_function :RunMetadataVariable_drop, [:pointer], :void attach_function :RunMetadataVariable_name, [:pointer], :string attach_function :RunMetadataVariable_value, [:pointer], :string attach_function :RunMetadataVariablesIter_drop, [:pointer], :void attach_function :RunMetadataVariablesIter_next, [:pointer], :pointer attach_function :Segment_new, [:string], :pointer attach_function :Segment_drop, [:pointer], :void attach_function :Segment_name, [:pointer], :string attach_function :Segment_icon, [:pointer], :string attach_function :Segment_comparison, [:pointer, :string], :pointer attach_function :Segment_personal_best_split_time, [:pointer], :pointer attach_function :Segment_best_segment_time, [:pointer], :pointer attach_function :Segment_segment_history, [:pointer], :pointer attach_function :SegmentHistory_iter, [:pointer], :pointer attach_function :SegmentHistoryElement_index, [:pointer], :int32 attach_function :SegmentHistoryElement_time, [:pointer], :pointer attach_function :SegmentHistoryIter_drop, [:pointer], :void attach_function :SegmentHistoryIter_next, [:pointer], :pointer attach_function :SeparatorComponent_new, [], :pointer attach_function :SeparatorComponent_drop, [:pointer], :void attach_function :SeparatorComponent_into_generic, [:pointer], :pointer attach_function :SettingValue_from_bool, [:bool], :pointer attach_function :SettingValue_from_uint, [:uint64], :pointer attach_function :SettingValue_from_int, [:int64], :pointer attach_function :SettingValue_from_string, [:string], :pointer attach_function :SettingValue_from_optional_string, [:string], :pointer attach_function :SettingValue_from_optional_empty_string, [], :pointer attach_function :SettingValue_from_float, [:double], :pointer attach_function :SettingValue_from_accuracy, [:string], :pointer attach_function :SettingValue_from_digits_format, [:string], :pointer attach_function :SettingValue_from_optional_timing_method, [:string], :pointer attach_function :SettingValue_from_optional_empty_timing_method, [], :pointer attach_function :SettingValue_from_color, [:float, :float, :float, :float], :pointer attach_function :SettingValue_from_optional_color, [:float, :float, :float, :float], :pointer attach_function :SettingValue_from_optional_empty_color, [], :pointer attach_function :SettingValue_from_transparent_gradient, [], :pointer attach_function :SettingValue_from_vertical_gradient, [:float, :float, :float, :float, :float, :float, :float, :float], :pointer attach_function :SettingValue_from_horizontal_gradient, [:float, :float, :float, :float, :float, :float, :float, :float], :pointer attach_function :SettingValue_from_alignment, [:string], :pointer attach_function :SettingValue_drop, [:pointer], :void attach_function :SharedTimer_drop, [:pointer], :void attach_function :SharedTimer_share, [:pointer], :pointer attach_function :SharedTimer_read, [:pointer], :pointer attach_function :SharedTimer_write, [:pointer], :pointer attach_function :SharedTimer_replace_inner, [:pointer, :pointer], :void attach_function :SplitsComponent_new, [], :pointer attach_function :SplitsComponent_drop, [:pointer], :void attach_function :SplitsComponent_into_generic, [:pointer], :pointer attach_function :SplitsComponent_state_as_json, [:pointer, :pointer, :pointer], :string attach_function :SplitsComponent_state, [:pointer, :pointer, :pointer], :pointer attach_function :SplitsComponent_scroll_up, [:pointer], :void attach_function :SplitsComponent_scroll_down, [:pointer], :void attach_function :SplitsComponent_set_visual_split_count, [:pointer, :size_t], :void attach_function :SplitsComponent_set_split_preview_count, [:pointer, :size_t], :void attach_function :SplitsComponent_set_always_show_last_split, [:pointer, :bool], :void attach_function :SplitsComponent_set_separator_last_split, [:pointer, :bool], :void attach_function :SplitsComponentState_drop, [:pointer], :void attach_function :SplitsComponentState_final_separator_shown, [:pointer], :bool attach_function :SplitsComponentState_len, [:pointer], :size_t attach_function :SplitsComponentState_icon_change_count, [:pointer], :size_t attach_function :SplitsComponentState_icon_change_segment_index, [:pointer, :size_t], :size_t attach_function :SplitsComponentState_icon_change_icon, [:pointer, :size_t], :string attach_function :SplitsComponentState_name, [:pointer, :size_t], :string attach_function :SplitsComponentState_delta, [:pointer, :size_t], :string attach_function :SplitsComponentState_time, [:pointer, :size_t], :string attach_function :SplitsComponentState_semantic_color, [:pointer, :size_t], :string attach_function :SplitsComponentState_is_current_split, [:pointer, :size_t], :bool attach_function :SumOfBestCleaner_drop, [:pointer], :void attach_function :SumOfBestCleaner_next_potential_clean_up, [:pointer], :pointer attach_function :SumOfBestCleaner_apply, [:pointer, :pointer], :void attach_function :SumOfBestComponent_new, [], :pointer attach_function :SumOfBestComponent_drop, [:pointer], :void attach_function :SumOfBestComponent_into_generic, [:pointer], :pointer attach_function :SumOfBestComponent_state_as_json, [:pointer, :pointer], :string attach_function :SumOfBestComponent_state, [:pointer, :pointer], :pointer attach_function :SumOfBestComponentState_drop, [:pointer], :void attach_function :SumOfBestComponentState_text, [:pointer], :string attach_function :SumOfBestComponentState_time, [:pointer], :string attach_function :TextComponent_new, [], :pointer attach_function :TextComponent_drop, [:pointer], :void attach_function :TextComponent_into_generic, [:pointer], :pointer attach_function :TextComponent_state_as_json, [:pointer], :string attach_function :TextComponent_state, [:pointer], :pointer attach_function :TextComponent_set_center, [:pointer, :string], :void attach_function :TextComponent_set_left, [:pointer, :string], :void attach_function :TextComponent_set_right, [:pointer, :string], :void attach_function :TextComponentState_drop, [:pointer], :void attach_function :TextComponentState_left, [:pointer], :string attach_function :TextComponentState_right, [:pointer], :string attach_function :TextComponentState_center, [:pointer], :string attach_function :TextComponentState_is_split, [:pointer], :bool attach_function :Time_drop, [:pointer], :void attach_function :Time_clone, [:pointer], :pointer attach_function :Time_real_time, [:pointer], :pointer attach_function :Time_game_time, [:pointer], :pointer attach_function :Time_index, [:pointer, :uint8], :pointer attach_function :TimeSpan_from_seconds, [:double], :pointer attach_function :TimeSpan_drop, [:pointer], :void attach_function :TimeSpan_clone, [:pointer], :pointer attach_function :TimeSpan_total_seconds, [:pointer], :double attach_function :Timer_new, [:pointer], :pointer attach_function :Timer_into_shared, [:pointer], :pointer attach_function :Timer_into_run, [:pointer, :bool], :pointer attach_function :Timer_drop, [:pointer], :void attach_function :Timer_current_timing_method, [:pointer], :uint8 attach_function :Timer_current_comparison, [:pointer], :string attach_function :Timer_is_game_time_initialized, [:pointer], :bool attach_function :Timer_is_game_time_paused, [:pointer], :bool attach_function :Timer_loading_times, [:pointer], :pointer attach_function :Timer_current_phase, [:pointer], :uint8 attach_function :Timer_get_run, [:pointer], :pointer attach_function :Timer_print_debug, [:pointer], :void attach_function :Timer_current_time, [:pointer], :pointer attach_function :Timer_replace_run, [:pointer, :pointer, :bool], :bool attach_function :Timer_set_run, [:pointer, :pointer], :pointer attach_function :Timer_start, [:pointer], :void attach_function :Timer_split, [:pointer], :void attach_function :Timer_split_or_start, [:pointer], :void attach_function :Timer_skip_split, [:pointer], :void attach_function :Timer_undo_split, [:pointer], :void attach_function :Timer_reset, [:pointer, :bool], :void attach_function :Timer_pause, [:pointer], :void attach_function :Timer_resume, [:pointer], :void attach_function :Timer_toggle_pause, [:pointer], :void attach_function :Timer_toggle_pause_or_start, [:pointer], :void attach_function :Timer_undo_all_pauses, [:pointer], :void attach_function :Timer_set_current_timing_method, [:pointer, :uint8], :void attach_function :Timer_switch_to_next_comparison, [:pointer], :void attach_function :Timer_switch_to_previous_comparison, [:pointer], :void attach_function :Timer_initialize_game_time, [:pointer], :void attach_function :Timer_deinitialize_game_time, [:pointer], :void attach_function :Timer_pause_game_time, [:pointer], :void attach_function :Timer_resume_game_time, [:pointer], :void attach_function :Timer_set_game_time, [:pointer, :pointer], :void attach_function :Timer_set_loading_times, [:pointer, :pointer], :void attach_function :TimerComponent_new, [], :pointer attach_function :TimerComponent_drop, [:pointer], :void attach_function :TimerComponent_into_generic, [:pointer], :pointer attach_function :TimerComponent_state_as_json, [:pointer, :pointer, :pointer], :string attach_function :TimerComponent_state, [:pointer, :pointer, :pointer], :pointer attach_function :TimerComponentState_drop, [:pointer], :void attach_function :TimerComponentState_time, [:pointer], :string attach_function :TimerComponentState_fraction, [:pointer], :string attach_function :TimerComponentState_semantic_color, [:pointer], :string attach_function :TimerReadLock_drop, [:pointer], :void attach_function :TimerReadLock_timer, [:pointer], :pointer attach_function :TimerWriteLock_drop, [:pointer], :void attach_function :TimerWriteLock_timer, [:pointer], :pointer attach_function :TitleComponent_new, [], :pointer attach_function :TitleComponent_drop, [:pointer], :void attach_function :TitleComponent_into_generic, [:pointer], :pointer attach_function :TitleComponent_state_as_json, [:pointer, :pointer], :string attach_function :TitleComponent_state, [:pointer, :pointer], :pointer attach_function :TitleComponentState_drop, [:pointer], :void attach_function :TitleComponentState_icon_change, [:pointer], :string attach_function :TitleComponentState_line1, [:pointer], :string attach_function :TitleComponentState_line2, [:pointer], :string attach_function :TitleComponentState_is_centered, [:pointer], :bool attach_function :TitleComponentState_shows_finished_runs, [:pointer], :bool attach_function :TitleComponentState_finished_runs, [:pointer], :uint32 attach_function :TitleComponentState_shows_attempts, [:pointer], :bool attach_function :TitleComponentState_attempts, [:pointer], :uint32 attach_function :TotalPlaytimeComponent_new, [], :pointer attach_function :TotalPlaytimeComponent_drop, [:pointer], :void attach_function :TotalPlaytimeComponent_into_generic, [:pointer], :pointer attach_function :TotalPlaytimeComponent_state_as_json, [:pointer, :pointer], :string attach_function :TotalPlaytimeComponent_state, [:pointer, :pointer], :pointer attach_function :TotalPlaytimeComponentState_drop, [:pointer], :void attach_function :TotalPlaytimeComponentState_text, [:pointer], :string attach_function :TotalPlaytimeComponentState_time, [:pointer], :string end class LSCHandle attr_accessor :ptr def initialize(ptr) @ptr = ptr end end # An Atomic Date Time represents a UTC Date Time that tries to be as close to # an atomic clock as possible. class AtomicDateTimeRef attr_accessor :handle # Represents whether the date time is actually properly derived from an # atomic clock. If the synchronization with the atomic clock didn't happen # yet or failed, this is set to false. # @return [Boolean] def is_synchronized() if @handle.ptr == nil raise "this is disposed" end result = Native.AtomicDateTime_is_synchronized(@handle.ptr) result end # Converts this atomic date time into a RFC 2822 formatted date time. # @return [String] def to_rfc2822() if @handle.ptr == nil raise "this is disposed" end result = Native.AtomicDateTime_to_rfc2822(@handle.ptr) result end # Converts this atomic date time into a RFC 3339 formatted date time. # @return [String] def to_rfc3339() if @handle.ptr == nil raise "this is disposed" end result = Native.AtomicDateTime_to_rfc3339(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # An Atomic Date Time represents a UTC Date Time that tries to be as close to # an atomic clock as possible. class AtomicDateTimeRefMut < AtomicDateTimeRef def initialize(ptr) @handle = LSCHandle.new ptr end end # An Atomic Date Time represents a UTC Date Time that tries to be as close to # an atomic clock as possible. class AtomicDateTime < AtomicDateTimeRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.AtomicDateTime_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = AtomicDateTime.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # An Attempt describes information about an attempt to run a specific category # by a specific runner in the past. Every time a new attempt is started and # then reset, an Attempt describing general information about it is created. class AttemptRef attr_accessor :handle # Accesses the unique index of the attempt. This index is unique for the # Run, not for all of them. # @return [Integer] def index() if @handle.ptr == nil raise "this is disposed" end result = Native.Attempt_index(@handle.ptr) result end # Accesses the split time of the last segment. If the attempt got reset # early and didn't finish, this may be empty. # @return [TimeRef] def time() if @handle.ptr == nil raise "this is disposed" end result = TimeRef.new(Native.Attempt_time(@handle.ptr)) result end # Accesses the amount of time the attempt has been paused for. If it is not # known, this returns nil. This means that it may not necessarily be # possible to differentiate whether a Run has not been paused or it simply # wasn't stored. # @return [TimeSpanRef, nil] def pause_time() if @handle.ptr == nil raise "this is disposed" end result = TimeSpanRef.new(Native.Attempt_pause_time(@handle.ptr)) if result.handle.ptr == nil return nil end result end # Accesses the point in time the attempt was started at. This returns nil # if this information is not known. # @return [AtomicDateTime, nil] def started() if @handle.ptr == nil raise "this is disposed" end result = AtomicDateTime.new(Native.Attempt_started(@handle.ptr)) if result.handle.ptr == nil return nil end result end # Accesses the point in time the attempt was ended at. This returns nil if # this information is not known. # @return [AtomicDateTime, nil] def ended() if @handle.ptr == nil raise "this is disposed" end result = AtomicDateTime.new(Native.Attempt_ended(@handle.ptr)) if result.handle.ptr == nil return nil end result end def initialize(ptr) @handle = LSCHandle.new ptr end end # An Attempt describes information about an attempt to run a specific category # by a specific runner in the past. Every time a new attempt is started and # then reset, an Attempt describing general information about it is created. class AttemptRefMut < AttemptRef def initialize(ptr) @handle = LSCHandle.new ptr end end # An Attempt describes information about an attempt to run a specific category # by a specific runner in the past. Every time a new attempt is started and # then reset, an Attempt describing general information about it is created. class Attempt < AttemptRefMut def self.finalize(handle) proc { if handle.ptr != nil handle.ptr = nil end } end def dispose finalizer = Attempt.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Blank Space Component is simply an empty component that doesn't show # anything other than a background. It mostly serves as padding between other # components. class BlankSpaceComponentRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # The Blank Space Component is simply an empty component that doesn't show # anything other than a background. It mostly serves as padding between other # components. class BlankSpaceComponentRefMut < BlankSpaceComponentRef # Encodes the component's state information as JSON. # @param [TimerRef] timer # @return [String] def state_as_json(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = Native.BlankSpaceComponent_state_as_json(@handle.ptr, timer.handle.ptr) result end # Calculates the component's state based on the timer provided. # @param [TimerRef] timer # @return [BlankSpaceComponentState] def state(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = BlankSpaceComponentState.new(Native.BlankSpaceComponent_state(@handle.ptr, timer.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Blank Space Component is simply an empty component that doesn't show # anything other than a background. It mostly serves as padding between other # components. class BlankSpaceComponent < BlankSpaceComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.BlankSpaceComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = BlankSpaceComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Blank Space Component. # @return [BlankSpaceComponent] def self.create() result = BlankSpaceComponent.new(Native.BlankSpaceComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.BlankSpaceComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class BlankSpaceComponentStateRef attr_accessor :handle # The height of the component. # @return [Integer] def height() if @handle.ptr == nil raise "this is disposed" end result = Native.BlankSpaceComponentState_height(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class BlankSpaceComponentStateRefMut < BlankSpaceComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class BlankSpaceComponentState < BlankSpaceComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.BlankSpaceComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = BlankSpaceComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A Component provides information about a run in a way that is easy to # visualize. This type can store any of the components provided by this crate. class ComponentRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # A Component provides information about a run in a way that is easy to # visualize. This type can store any of the components provided by this crate. class ComponentRefMut < ComponentRef def initialize(ptr) @handle = LSCHandle.new ptr end end # A Component provides information about a run in a way that is easy to # visualize. This type can store any of the components provided by this crate. class Component < ComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.Component_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = Component.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Current Comparison Component is a component that shows the name of the # comparison that is currently selected to be compared against. class CurrentComparisonComponentRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # The Current Comparison Component is a component that shows the name of the # comparison that is currently selected to be compared against. class CurrentComparisonComponentRefMut < CurrentComparisonComponentRef # Encodes the component's state information as JSON. # @param [TimerRef] timer # @return [String] def state_as_json(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = Native.CurrentComparisonComponent_state_as_json(@handle.ptr, timer.handle.ptr) result end # Calculates the component's state based on the timer provided. # @param [TimerRef] timer # @return [CurrentComparisonComponentState] def state(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = CurrentComparisonComponentState.new(Native.CurrentComparisonComponent_state(@handle.ptr, timer.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Current Comparison Component is a component that shows the name of the # comparison that is currently selected to be compared against. class CurrentComparisonComponent < CurrentComparisonComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.CurrentComparisonComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = CurrentComparisonComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Current Comparison Component. # @return [CurrentComparisonComponent] def self.create() result = CurrentComparisonComponent.new(Native.CurrentComparisonComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.CurrentComparisonComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class CurrentComparisonComponentStateRef attr_accessor :handle # The label's text. # @return [String] def text() if @handle.ptr == nil raise "this is disposed" end result = Native.CurrentComparisonComponentState_text(@handle.ptr) result end # The name of the comparison that is currently selected to be compared # against. # @return [String] def comparison() if @handle.ptr == nil raise "this is disposed" end result = Native.CurrentComparisonComponentState_comparison(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class CurrentComparisonComponentStateRefMut < CurrentComparisonComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class CurrentComparisonComponentState < CurrentComparisonComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.CurrentComparisonComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = CurrentComparisonComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Current Pace Component is a component that shows a prediction of the # current attempt's final time, if the current attempt's pace matches the # chosen comparison for the remainder of the run. class CurrentPaceComponentRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # The Current Pace Component is a component that shows a prediction of the # current attempt's final time, if the current attempt's pace matches the # chosen comparison for the remainder of the run. class CurrentPaceComponentRefMut < CurrentPaceComponentRef # Encodes the component's state information as JSON. # @param [TimerRef] timer # @return [String] def state_as_json(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = Native.CurrentPaceComponent_state_as_json(@handle.ptr, timer.handle.ptr) result end # Calculates the component's state based on the timer provided. # @param [TimerRef] timer # @return [CurrentPaceComponentState] def state(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = CurrentPaceComponentState.new(Native.CurrentPaceComponent_state(@handle.ptr, timer.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Current Pace Component is a component that shows a prediction of the # current attempt's final time, if the current attempt's pace matches the # chosen comparison for the remainder of the run. class CurrentPaceComponent < CurrentPaceComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.CurrentPaceComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = CurrentPaceComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Current Pace Component. # @return [CurrentPaceComponent] def self.create() result = CurrentPaceComponent.new(Native.CurrentPaceComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.CurrentPaceComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class CurrentPaceComponentStateRef attr_accessor :handle # The label's text. # @return [String] def text() if @handle.ptr == nil raise "this is disposed" end result = Native.CurrentPaceComponentState_text(@handle.ptr) result end # The current pace. # @return [String] def time() if @handle.ptr == nil raise "this is disposed" end result = Native.CurrentPaceComponentState_time(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class CurrentPaceComponentStateRefMut < CurrentPaceComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class CurrentPaceComponentState < CurrentPaceComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.CurrentPaceComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = CurrentPaceComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Delta Component is a component that shows the how far ahead or behind # the current attempt is compared to the chosen comparison. class DeltaComponentRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # The Delta Component is a component that shows the how far ahead or behind # the current attempt is compared to the chosen comparison. class DeltaComponentRefMut < DeltaComponentRef # Encodes the component's state information as JSON. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [String] def state_as_json(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = Native.DeltaComponent_state_as_json(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr) result end # Calculates the component's state based on the timer and the layout # settings provided. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [DeltaComponentState] def state(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = DeltaComponentState.new(Native.DeltaComponent_state(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Delta Component is a component that shows the how far ahead or behind # the current attempt is compared to the chosen comparison. class DeltaComponent < DeltaComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.DeltaComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = DeltaComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Delta Component. # @return [DeltaComponent] def self.create() result = DeltaComponent.new(Native.DeltaComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.DeltaComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class DeltaComponentStateRef attr_accessor :handle # The label's text. # @return [String] def text() if @handle.ptr == nil raise "this is disposed" end result = Native.DeltaComponentState_text(@handle.ptr) result end # The delta. # @return [String] def time() if @handle.ptr == nil raise "this is disposed" end result = Native.DeltaComponentState_time(@handle.ptr) result end # The semantic coloring information the delta time carries. # @return [String] def semantic_color() if @handle.ptr == nil raise "this is disposed" end result = Native.DeltaComponentState_semantic_color(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class DeltaComponentStateRefMut < DeltaComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class DeltaComponentState < DeltaComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.DeltaComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = DeltaComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Detailed Timer Component is a component that shows two timers, one for # the total time of the current attempt and one showing the time of just the # current segment. Other information, like segment times of up to two # comparisons, the segment icon, and the segment's name, can also be shown. class DetailedTimerComponentRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # The Detailed Timer Component is a component that shows two timers, one for # the total time of the current attempt and one showing the time of just the # current segment. Other information, like segment times of up to two # comparisons, the segment icon, and the segment's name, can also be shown. class DetailedTimerComponentRefMut < DetailedTimerComponentRef # Encodes the component's state information as JSON. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [String] def state_as_json(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = Native.DetailedTimerComponent_state_as_json(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr) result end # Calculates the component's state based on the timer and layout settings # provided. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [DetailedTimerComponentState] def state(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = DetailedTimerComponentState.new(Native.DetailedTimerComponent_state(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Detailed Timer Component is a component that shows two timers, one for # the total time of the current attempt and one showing the time of just the # current segment. Other information, like segment times of up to two # comparisons, the segment icon, and the segment's name, can also be shown. class DetailedTimerComponent < DetailedTimerComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.DetailedTimerComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = DetailedTimerComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Detailed Timer Component. # @return [DetailedTimerComponent] def self.create() result = DetailedTimerComponent.new(Native.DetailedTimerComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.DetailedTimerComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class DetailedTimerComponentStateRef attr_accessor :handle # The time shown by the component's main timer without the fractional part. # @return [String] def timer_time() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_timer_time(@handle.ptr) result end # The fractional part of the time shown by the main timer (including the dot). # @return [String] def timer_fraction() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_timer_fraction(@handle.ptr) result end # The semantic coloring information the main timer's time carries. # @return [String] def timer_semantic_color() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_timer_semantic_color(@handle.ptr) result end # The time shown by the component's segment timer without the fractional part. # @return [String] def segment_timer_time() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_segment_timer_time(@handle.ptr) result end # The fractional part of the time shown by the segment timer (including the # dot). # @return [String] def segment_timer_fraction() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_segment_timer_fraction(@handle.ptr) result end # Returns whether the first comparison is visible. # @return [Boolean] def comparison1_visible() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_comparison1_visible(@handle.ptr) result end # Returns the name of the first comparison. You may not call this if the first # comparison is not visible. # @return [String] def comparison1_name() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_comparison1_name(@handle.ptr) result end # Returns the time of the first comparison. You may not call this if the first # comparison is not visible. # @return [String] def comparison1_time() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_comparison1_time(@handle.ptr) result end # Returns whether the second comparison is visible. # @return [Boolean] def comparison2_visible() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_comparison2_visible(@handle.ptr) result end # Returns the name of the second comparison. You may not call this if the # second comparison is not visible. # @return [String] def comparison2_name() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_comparison2_name(@handle.ptr) result end # Returns the time of the second comparison. You may not call this if the # second comparison is not visible. # @return [String] def comparison2_time() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_comparison2_time(@handle.ptr) result end # The segment's icon encoded as a Data URL. This value is only specified # whenever the icon changes. If you explicitly want to query this value, # remount the component. The String itself may be empty. This indicates # that there is no icon. # @return [String, nil] def icon_change() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_icon_change(@handle.ptr) result end # The name of the segment. This may be nil if it's not supposed to be # visualized. # @return [String, nil] def segment_name() if @handle.ptr == nil raise "this is disposed" end result = Native.DetailedTimerComponentState_segment_name(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class DetailedTimerComponentStateRefMut < DetailedTimerComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class DetailedTimerComponentState < DetailedTimerComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.DetailedTimerComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = DetailedTimerComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The general settings of the layout that apply to all components. class GeneralLayoutSettingsRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # The general settings of the layout that apply to all components. class GeneralLayoutSettingsRefMut < GeneralLayoutSettingsRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The general settings of the layout that apply to all components. class GeneralLayoutSettings < GeneralLayoutSettingsRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.GeneralLayoutSettings_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = GeneralLayoutSettings.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a default general layout settings configuration. # @return [GeneralLayoutSettings] def self.default() result = GeneralLayoutSettings.new(Native.GeneralLayoutSettings_default()) result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Graph Component visualizes how far the current attempt has been ahead or # behind the chosen comparison throughout the whole attempt. All the # individual deltas are shown as points in a graph. class GraphComponentRef attr_accessor :handle # Encodes the component's state information as JSON. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [String] def state_as_json(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = Native.GraphComponent_state_as_json(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr) result end # Calculates the component's state based on the timer and layout settings # provided. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [GraphComponentState] def state(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = GraphComponentState.new(Native.GraphComponent_state(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Graph Component visualizes how far the current attempt has been ahead or # behind the chosen comparison throughout the whole attempt. All the # individual deltas are shown as points in a graph. class GraphComponentRefMut < GraphComponentRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The Graph Component visualizes how far the current attempt has been ahead or # behind the chosen comparison throughout the whole attempt. All the # individual deltas are shown as points in a graph. class GraphComponent < GraphComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.GraphComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = GraphComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Graph Component. # @return [GraphComponent] def self.create() result = GraphComponent.new(Native.GraphComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.GraphComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. # All the coordinates are in the range 0..1. class GraphComponentStateRef attr_accessor :handle # Returns the amount of points to visualize. Connect all of them to visualize # the graph. If the live delta is active, the last point is to be interpreted # as a preview of the next split that is about to happen. Use the partial fill # color to visualize the region beneath that graph segment. # @return [Integer] def points_len() if @handle.ptr == nil raise "this is disposed" end result = Native.GraphComponentState_points_len(@handle.ptr) result end # Returns the x coordinate of the point specified. You may not provide an out # of bounds index. # @param [Integer] index # @return [Float] def point_x(index) if @handle.ptr == nil raise "this is disposed" end result = Native.GraphComponentState_point_x(@handle.ptr, index) result end # Returns the y coordinate of the point specified. You may not provide an out # of bounds index. # @param [Integer] index # @return [Float] def point_y(index) if @handle.ptr == nil raise "this is disposed" end result = Native.GraphComponentState_point_y(@handle.ptr, index) result end # Describes whether the segment the point specified is visualizing achieved a # new best segment time. Use the best segment color for it, in that case. You # may not provide an out of bounds index. # @param [Integer] index # @return [Boolean] def point_is_best_segment(index) if @handle.ptr == nil raise "this is disposed" end result = Native.GraphComponentState_point_is_best_segment(@handle.ptr, index) result end # Describes how many horizontal grid lines to visualize. # @return [Integer] def horizontal_grid_lines_len() if @handle.ptr == nil raise "this is disposed" end result = Native.GraphComponentState_horizontal_grid_lines_len(@handle.ptr) result end # Accesses the y coordinate of the horizontal grid line specified. You may not # provide an out of bounds index. # @param [Integer] index # @return [Float] def horizontal_grid_line(index) if @handle.ptr == nil raise "this is disposed" end result = Native.GraphComponentState_horizontal_grid_line(@handle.ptr, index) result end # Describes how many vertical grid lines to visualize. # @return [Integer] def vertical_grid_lines_len() if @handle.ptr == nil raise "this is disposed" end result = Native.GraphComponentState_vertical_grid_lines_len(@handle.ptr) result end # Accesses the x coordinate of the vertical grid line specified. You may not # provide an out of bounds index. # @param [Integer] index # @return [Float] def vertical_grid_line(index) if @handle.ptr == nil raise "this is disposed" end result = Native.GraphComponentState_vertical_grid_line(@handle.ptr, index) result end # The y coordinate that separates the region that shows the times that are # ahead of the comparison and those that are behind. # @return [Float] def middle() if @handle.ptr == nil raise "this is disposed" end result = Native.GraphComponentState_middle(@handle.ptr) result end # If the live delta is active, the last point is to be interpreted as a # preview of the next split that is about to happen. Use the partial fill # color to visualize the region beneath that graph segment. # @return [Boolean] def is_live_delta_active() if @handle.ptr == nil raise "this is disposed" end result = Native.GraphComponentState_is_live_delta_active(@handle.ptr) result end # Describes whether the graph is flipped vertically. For visualizing the # graph, this usually doesn't need to be interpreted, as this information is # entirely encoded into the other variables. # @return [Boolean] def is_flipped() if @handle.ptr == nil raise "this is disposed" end result = Native.GraphComponentState_is_flipped(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. # All the coordinates are in the range 0..1. class GraphComponentStateRefMut < GraphComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. # All the coordinates are in the range 0..1. class GraphComponentState < GraphComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.GraphComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = GraphComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # With a Hotkey System the runner can use hotkeys on their keyboard to control # the Timer. The hotkeys are global, so the application doesn't need to be in # focus. The behavior of the hotkeys depends on the platform and is stubbed # out on platforms that don't support hotkeys. You can turn off a Hotkey # System temporarily. By default the Hotkey System is activated. class HotkeySystemRef attr_accessor :handle # Deactivates the Hotkey System. No hotkeys will go through until it gets # activated again. If it's already deactivated, nothing happens. def deactivate() if @handle.ptr == nil raise "this is disposed" end Native.HotkeySystem_deactivate(@handle.ptr) end # Activates a previously deactivated Hotkey System. If it's already # active, nothing happens. def activate() if @handle.ptr == nil raise "this is disposed" end Native.HotkeySystem_activate(@handle.ptr) end def initialize(ptr) @handle = LSCHandle.new ptr end end # With a Hotkey System the runner can use hotkeys on their keyboard to control # the Timer. The hotkeys are global, so the application doesn't need to be in # focus. The behavior of the hotkeys depends on the platform and is stubbed # out on platforms that don't support hotkeys. You can turn off a Hotkey # System temporarily. By default the Hotkey System is activated. class HotkeySystemRefMut < HotkeySystemRef def initialize(ptr) @handle = LSCHandle.new ptr end end # With a Hotkey System the runner can use hotkeys on their keyboard to control # the Timer. The hotkeys are global, so the application doesn't need to be in # focus. The behavior of the hotkeys depends on the platform and is stubbed # out on platforms that don't support hotkeys. You can turn off a Hotkey # System temporarily. By default the Hotkey System is activated. class HotkeySystem < HotkeySystemRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.HotkeySystem_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = HotkeySystem.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Hotkey System for a Timer with the default hotkeys. # @param [SharedTimer] shared_timer # @return [HotkeySystem, nil] def self.create(shared_timer) if shared_timer.handle.ptr == nil raise "shared_timer is disposed" end result = HotkeySystem.new(Native.HotkeySystem_new(shared_timer.handle.ptr)) shared_timer.handle.ptr = nil if result.handle.ptr == nil return nil end result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A Layout allows you to combine multiple components together to visualize a # variety of information the runner is interested in. class LayoutRef attr_accessor :handle # Clones the layout. # @return [Layout] def clone() if @handle.ptr == nil raise "this is disposed" end result = Layout.new(Native.Layout_clone(@handle.ptr)) result end # Encodes the settings of the layout as JSON. # @return [String] def settings_as_json() if @handle.ptr == nil raise "this is disposed" end result = Native.Layout_settings_as_json(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Layout allows you to combine multiple components together to visualize a # variety of information the runner is interested in. class LayoutRefMut < LayoutRef # Calculates the layout's state based on the timer provided and encodes it as # JSON. You can use this to visualize all of the components of a layout. # @param [TimerRef] timer # @return [String] def state_as_json(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = Native.Layout_state_as_json(@handle.ptr, timer.handle.ptr) result end # Adds a new component to the end of the layout. # @param [Component] component def push(component) if @handle.ptr == nil raise "this is disposed" end if component.handle.ptr == nil raise "component is disposed" end Native.Layout_push(@handle.ptr, component.handle.ptr) component.handle.ptr = nil end # Scrolls up all the components in the layout that can be scrolled up. def scroll_up() if @handle.ptr == nil raise "this is disposed" end Native.Layout_scroll_up(@handle.ptr) end # Scrolls down all the components in the layout that can be scrolled down. def scroll_down() if @handle.ptr == nil raise "this is disposed" end Native.Layout_scroll_down(@handle.ptr) end # Remounts all the components as if they were freshly initialized. Some # components may only provide some information whenever it changes or when # their state is first queried. Remounting returns this information again, # whenever the layout's state is queried the next time. def remount() if @handle.ptr == nil raise "this is disposed" end Native.Layout_remount(@handle.ptr) end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Layout allows you to combine multiple components together to visualize a # variety of information the runner is interested in. class Layout < LayoutRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.Layout_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = Layout.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new empty layout with no components. # @return [Layout] def self.create() result = Layout.new(Native.Layout_new()) result end # Creates a new default layout that contains a default set of components # in order to provide a good default layout for runners. Which components # are provided by this and how they are configured may change in the # future. # @return [Layout] def self.default_layout() result = Layout.new(Native.Layout_default_layout()) result end # Parses a layout from the given JSON description of its settings. nil is # returned if it couldn't be parsed. # @param [String] settings # @return [Layout, nil] def self.parse_json(settings) result = Layout.new(Native.Layout_parse_json(settings)) if result.handle.ptr == nil return nil end result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Layout Editor allows modifying Layouts while ensuring all the different # invariants of the Layout objects are upheld no matter what kind of # operations are being applied. It provides the current state of the editor as # state objects that can be visualized by any kind of User Interface. class LayoutEditorRef attr_accessor :handle # Encodes the Layout Editor's state as JSON in order to visualize it. # @return [String] def state_as_json() if @handle.ptr == nil raise "this is disposed" end result = Native.LayoutEditor_state_as_json(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Layout Editor allows modifying Layouts while ensuring all the different # invariants of the Layout objects are upheld no matter what kind of # operations are being applied. It provides the current state of the editor as # state objects that can be visualized by any kind of User Interface. class LayoutEditorRefMut < LayoutEditorRef # Encodes the layout's state as JSON based on the timer provided. You can use # this to visualize all of the components of a layout, while it is still being # edited by the Layout Editor. # @param [TimerRef] timer # @return [String] def layout_state_as_json(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = Native.LayoutEditor_layout_state_as_json(@handle.ptr, timer.handle.ptr) result end # Selects the component with the given index in order to modify its # settings. Only a single component is selected at any given time. You may # not provide an invalid index. # @param [Integer] index def select(index) if @handle.ptr == nil raise "this is disposed" end Native.LayoutEditor_select(@handle.ptr, index) end # Adds the component provided to the end of the layout. The newly added # component becomes the selected component. # @param [Component] component def add_component(component) if @handle.ptr == nil raise "this is disposed" end if component.handle.ptr == nil raise "component is disposed" end Native.LayoutEditor_add_component(@handle.ptr, component.handle.ptr) component.handle.ptr = nil end # Removes the currently selected component, unless there's only one # component in the layout. The next component becomes the selected # component. If there's none, the previous component becomes the selected # component instead. def remove_component() if @handle.ptr == nil raise "this is disposed" end Native.LayoutEditor_remove_component(@handle.ptr) end # Moves the selected component up, unless the first component is selected. def move_component_up() if @handle.ptr == nil raise "this is disposed" end Native.LayoutEditor_move_component_up(@handle.ptr) end # Moves the selected component down, unless the last component is # selected. def move_component_down() if @handle.ptr == nil raise "this is disposed" end Native.LayoutEditor_move_component_down(@handle.ptr) end # Moves the selected component to the index provided. You may not provide # an invalid index. # @param [Integer] dst_index def move_component(dst_index) if @handle.ptr == nil raise "this is disposed" end Native.LayoutEditor_move_component(@handle.ptr, dst_index) end # Duplicates the currently selected component. The copy gets placed right # after the selected component and becomes the newly selected component. def duplicate_component() if @handle.ptr == nil raise "this is disposed" end Native.LayoutEditor_duplicate_component(@handle.ptr) end # Sets a setting's value of the selected component by its setting index # to the given value. # # This panics if the type of the value to be set is not compatible with # the type of the setting's value. A panic can also occur if the index of # the setting provided is out of bounds. # @param [Integer] index # @param [SettingValue] value def set_component_settings_value(index, value) if @handle.ptr == nil raise "this is disposed" end if value.handle.ptr == nil raise "value is disposed" end Native.LayoutEditor_set_component_settings_value(@handle.ptr, index, value.handle.ptr) value.handle.ptr = nil end # Sets a setting's value of the general settings by its setting index to # the given value. # # This panics if the type of the value to be set is not compatible with # the type of the setting's value. A panic can also occur if the index of # the setting provided is out of bounds. # @param [Integer] index # @param [SettingValue] value def set_general_settings_value(index, value) if @handle.ptr == nil raise "this is disposed" end if value.handle.ptr == nil raise "value is disposed" end Native.LayoutEditor_set_general_settings_value(@handle.ptr, index, value.handle.ptr) value.handle.ptr = nil end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Layout Editor allows modifying Layouts while ensuring all the different # invariants of the Layout objects are upheld no matter what kind of # operations are being applied. It provides the current state of the editor as # state objects that can be visualized by any kind of User Interface. class LayoutEditor < LayoutEditorRefMut def self.finalize(handle) proc { if handle.ptr != nil handle.ptr = nil end } end def dispose finalizer = LayoutEditor.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Layout Editor that modifies the Layout provided. Creation of # the Layout Editor fails when a Layout with no components is provided. In # that case nil is returned instead. # @param [Layout] layout # @return [LayoutEditor, nil] def self.create(layout) if layout.handle.ptr == nil raise "layout is disposed" end result = LayoutEditor.new(Native.LayoutEditor_new(layout.handle.ptr)) layout.handle.ptr = nil if result.handle.ptr == nil return nil end result end # Closes the Layout Editor and gives back access to the modified Layout. In # case you want to implement a Cancel Button, just dispose the Layout object # you get here. # @return [Layout] def close() if @handle.ptr == nil raise "this is disposed" end result = Layout.new(Native.LayoutEditor_close(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A run parsed by the Composite Parser. This contains the Run itself and # information about which parser parsed it. class ParseRunResultRef attr_accessor :handle # Returns true if the Run got parsed successfully. false is returned otherwise. # @return [Boolean] def parsed_successfully() if @handle.ptr == nil raise "this is disposed" end result = Native.ParseRunResult_parsed_successfully(@handle.ptr) result end # Accesses the name of the Parser that parsed the Run. # @return [String] def timer_kind() if @handle.ptr == nil raise "this is disposed" end result = Native.ParseRunResult_timer_kind(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # A run parsed by the Composite Parser. This contains the Run itself and # information about which parser parsed it. class ParseRunResultRefMut < ParseRunResultRef def initialize(ptr) @handle = LSCHandle.new ptr end end # A run parsed by the Composite Parser. This contains the Run itself and # information about which parser parsed it. class ParseRunResult < ParseRunResultRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.ParseRunResult_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = ParseRunResult.finalize @handle finalizer.call end def with yield self self.dispose end # Moves the actual Run object out of the Result. You may not call this if the # Run wasn't parsed successfully. # @return [Run] def unwrap() if @handle.ptr == nil raise "this is disposed" end result = Run.new(Native.ParseRunResult_unwrap(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Possible Time Save Component is a component that shows how much time the # chosen comparison could've saved for the current segment, based on the Best # Segments. This component also allows showing the Total Possible Time Save # for the remainder of the current attempt. class PossibleTimeSaveComponentRef attr_accessor :handle # Encodes the component's state information as JSON. # @param [TimerRef] timer # @return [String] def state_as_json(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = Native.PossibleTimeSaveComponent_state_as_json(@handle.ptr, timer.handle.ptr) result end # Calculates the component's state based on the timer provided. # @param [TimerRef] timer # @return [PossibleTimeSaveComponentState] def state(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = PossibleTimeSaveComponentState.new(Native.PossibleTimeSaveComponent_state(@handle.ptr, timer.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Possible Time Save Component is a component that shows how much time the # chosen comparison could've saved for the current segment, based on the Best # Segments. This component also allows showing the Total Possible Time Save # for the remainder of the current attempt. class PossibleTimeSaveComponentRefMut < PossibleTimeSaveComponentRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The Possible Time Save Component is a component that shows how much time the # chosen comparison could've saved for the current segment, based on the Best # Segments. This component also allows showing the Total Possible Time Save # for the remainder of the current attempt. class PossibleTimeSaveComponent < PossibleTimeSaveComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.PossibleTimeSaveComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = PossibleTimeSaveComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Possible Time Save Component. # @return [PossibleTimeSaveComponent] def self.create() result = PossibleTimeSaveComponent.new(Native.PossibleTimeSaveComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.PossibleTimeSaveComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class PossibleTimeSaveComponentStateRef attr_accessor :handle # The label's text. # @return [String] def text() if @handle.ptr == nil raise "this is disposed" end result = Native.PossibleTimeSaveComponentState_text(@handle.ptr) result end # The current possible time save. # @return [String] def time() if @handle.ptr == nil raise "this is disposed" end result = Native.PossibleTimeSaveComponentState_time(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class PossibleTimeSaveComponentStateRefMut < PossibleTimeSaveComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class PossibleTimeSaveComponentState < PossibleTimeSaveComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.PossibleTimeSaveComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = PossibleTimeSaveComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # Describes a potential clean up that could be applied. You can query a # message describing the details of this potential clean up. A potential clean # up can then be turned into an actual clean up in order to apply it to the # Run. class PotentialCleanUpRef attr_accessor :handle # Accesses the message describing the potential clean up that can be applied # to a Run. # @return [String] def message() if @handle.ptr == nil raise "this is disposed" end result = Native.PotentialCleanUp_message(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # Describes a potential clean up that could be applied. You can query a # message describing the details of this potential clean up. A potential clean # up can then be turned into an actual clean up in order to apply it to the # Run. class PotentialCleanUpRefMut < PotentialCleanUpRef def initialize(ptr) @handle = LSCHandle.new ptr end end # Describes a potential clean up that could be applied. You can query a # message describing the details of this potential clean up. A potential clean # up can then be turned into an actual clean up in order to apply it to the # Run. class PotentialCleanUp < PotentialCleanUpRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.PotentialCleanUp_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = PotentialCleanUp.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Previous Segment Component is a component that shows how much time was # saved or lost during the previous segment based on the chosen comparison. # Additionally, the potential time save for the previous segment can be # displayed. This component switches to a `Live Segment` view that shows # active time loss whenever the runner is losing time on the current segment. class PreviousSegmentComponentRef attr_accessor :handle # Encodes the component's state information as JSON. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [String] def state_as_json(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = Native.PreviousSegmentComponent_state_as_json(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr) result end # Calculates the component's state based on the timer and the layout # settings provided. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [PreviousSegmentComponentState] def state(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = PreviousSegmentComponentState.new(Native.PreviousSegmentComponent_state(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Previous Segment Component is a component that shows how much time was # saved or lost during the previous segment based on the chosen comparison. # Additionally, the potential time save for the previous segment can be # displayed. This component switches to a `Live Segment` view that shows # active time loss whenever the runner is losing time on the current segment. class PreviousSegmentComponentRefMut < PreviousSegmentComponentRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The Previous Segment Component is a component that shows how much time was # saved or lost during the previous segment based on the chosen comparison. # Additionally, the potential time save for the previous segment can be # displayed. This component switches to a `Live Segment` view that shows # active time loss whenever the runner is losing time on the current segment. class PreviousSegmentComponent < PreviousSegmentComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.PreviousSegmentComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = PreviousSegmentComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Previous Segment Component. # @return [PreviousSegmentComponent] def self.create() result = PreviousSegmentComponent.new(Native.PreviousSegmentComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.PreviousSegmentComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class PreviousSegmentComponentStateRef attr_accessor :handle # The label's text. # @return [String] def text() if @handle.ptr == nil raise "this is disposed" end result = Native.PreviousSegmentComponentState_text(@handle.ptr) result end # The delta (and possibly the possible time save). # @return [String] def time() if @handle.ptr == nil raise "this is disposed" end result = Native.PreviousSegmentComponentState_time(@handle.ptr) result end # The semantic coloring information the delta time carries. # @return [String] def semantic_color() if @handle.ptr == nil raise "this is disposed" end result = Native.PreviousSegmentComponentState_semantic_color(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class PreviousSegmentComponentStateRefMut < PreviousSegmentComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class PreviousSegmentComponentState < PreviousSegmentComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.PreviousSegmentComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = PreviousSegmentComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A Run stores the split times for a specific game and category of a runner. class RunRef attr_accessor :handle # Clones the Run object. # @return [Run] def clone() if @handle.ptr == nil raise "this is disposed" end result = Run.new(Native.Run_clone(@handle.ptr)) result end # Accesses the name of the game this Run is for. # @return [String] def game_name() if @handle.ptr == nil raise "this is disposed" end result = Native.Run_game_name(@handle.ptr) result end # Accesses the Data URL storing the game icon's data. If there is no game # icon, this returns an empty string instead of a URL. # @return [String] def game_icon() if @handle.ptr == nil raise "this is disposed" end result = Native.Run_game_icon(@handle.ptr) result end # Accesses the name of the category this Run is for. # @return [String] def category_name() if @handle.ptr == nil raise "this is disposed" end result = Native.Run_category_name(@handle.ptr) result end # Returns a file name (without the extension) suitable for this Run that # is built the following way: # # Game Name - Category Name # # If either is empty, the dash is omitted. Special characters that cause # problems in file names are also omitted. If an extended category name is # used, the variables of the category are appended in a parenthesis. # @param [Boolean] use_extended_category_name # @return [String] def extended_file_name(use_extended_category_name) if @handle.ptr == nil raise "this is disposed" end result = Native.Run_extended_file_name(@handle.ptr, use_extended_category_name) result end # Returns a name suitable for this Run that is built the following way: # # Game Name - Category Name # # If either is empty, the dash is omitted. If an extended category name is # used, the variables of the category are appended in a parenthesis. # @param [Boolean] use_extended_category_name # @return [String] def extended_name(use_extended_category_name) if @handle.ptr == nil raise "this is disposed" end result = Native.Run_extended_name(@handle.ptr, use_extended_category_name) result end # Returns an extended category name that possibly includes the region, # platform and variables, depending on the arguments provided. An extended # category name may look like this: # # Any% (No Tuner, JPN, Wii Emulator) # @param [Boolean] show_region # @param [Boolean] show_platform # @param [Boolean] show_variables # @return [String] def extended_category_name(show_region, show_platform, show_variables) if @handle.ptr == nil raise "this is disposed" end result = Native.Run_extended_category_name(@handle.ptr, show_region, show_platform, show_variables) result end # Returns the amount of runs that have been attempted with these splits. # @return [Integer] def attempt_count() if @handle.ptr == nil raise "this is disposed" end result = Native.Run_attempt_count(@handle.ptr) result end # Accesses additional metadata of this Run, like the platform and region # of the game. # @return [RunMetadataRef] def metadata() if @handle.ptr == nil raise "this is disposed" end result = RunMetadataRef.new(Native.Run_metadata(@handle.ptr)) result end # Accesses the time an attempt of this Run should start at. # @return [TimeSpanRef] def offset() if @handle.ptr == nil raise "this is disposed" end result = TimeSpanRef.new(Native.Run_offset(@handle.ptr)) result end # Returns the amount of segments stored in this Run. # @return [Integer] def len() if @handle.ptr == nil raise "this is disposed" end result = Native.Run_len(@handle.ptr) result end # Accesses a certain segment of this Run. You may not provide an out of bounds # index. # @param [Integer] index # @return [SegmentRef] def segment(index) if @handle.ptr == nil raise "this is disposed" end result = SegmentRef.new(Native.Run_segment(@handle.ptr, index)) result end # Returns the amount attempt history elements are stored in this Run. # @return [Integer] def attempt_history_len() if @handle.ptr == nil raise "this is disposed" end result = Native.Run_attempt_history_len(@handle.ptr) result end # Accesses the an attempt history element by its index. This does not store # the actual segment times, just the overall attempt information. Information # about the individual segments is stored within each segment. You may not # provide an out of bounds index. # @param [Integer] index # @return [AttemptRef] def attempt_history_index(index) if @handle.ptr == nil raise "this is disposed" end result = AttemptRef.new(Native.Run_attempt_history_index(@handle.ptr, index)) result end # Saves the Run as a LiveSplit splits file (*.lss). # @return [String] def save_as_lss() if @handle.ptr == nil raise "this is disposed" end result = Native.Run_save_as_lss(@handle.ptr) result end # Returns the amount of custom comparisons stored in this Run. # @return [Integer] def custom_comparisons_len() if @handle.ptr == nil raise "this is disposed" end result = Native.Run_custom_comparisons_len(@handle.ptr) result end # Accesses a custom comparison stored in this Run by its index. This includes # `Personal Best` but excludes all the other Comparison Generators. You may # not provide an out of bounds index. # @param [Integer] index # @return [String] def custom_comparison(index) if @handle.ptr == nil raise "this is disposed" end result = Native.Run_custom_comparison(@handle.ptr, index) result end # Accesses the Auto Splitter Settings that are encoded as XML. # @return [String] def auto_splitter_settings() if @handle.ptr == nil raise "this is disposed" end result = Native.Run_auto_splitter_settings(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Run stores the split times for a specific game and category of a runner. class RunRefMut < RunRef # Pushes the segment provided to the end of the list of segments of this Run. # @param [Segment] segment def push_segment(segment) if @handle.ptr == nil raise "this is disposed" end if segment.handle.ptr == nil raise "segment is disposed" end Native.Run_push_segment(@handle.ptr, segment.handle.ptr) segment.handle.ptr = nil end # Sets the name of the game this Run is for. # @param [String] game def set_game_name(game) if @handle.ptr == nil raise "this is disposed" end Native.Run_set_game_name(@handle.ptr, game) end # Sets the name of the category this Run is for. # @param [String] category def set_category_name(category) if @handle.ptr == nil raise "this is disposed" end Native.Run_set_category_name(@handle.ptr, category) end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Run stores the split times for a specific game and category of a runner. class Run < RunRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.Run_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = Run.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Run object with no segments. # @return [Run] def self.create() result = Run.new(Native.Run_new()) result end # Attempts to parse a splits file from an array by invoking the corresponding # parser for the file format detected. A path to the splits file can be # provided, which helps saving the splits file again later. Additionally you # need to specify if additional files, like external images are allowed to be # loaded. If you are using livesplit-core in a server-like environment, set # this to false. Only client-side applications should set this to true. # @param [Integer] data # @param [Integer] length # @param [String] path # @param [Boolean] load_files # @return [ParseRunResult] def self.parse(data, length, path, load_files) result = ParseRunResult.new(Native.Run_parse(data, length, path, load_files)) result end # Attempts to parse a splits file from a file by invoking the corresponding # parser for the file format detected. A path to the splits file can be # provided, which helps saving the splits file again later. Additionally you # need to specify if additional files, like external images are allowed to be # loaded. If you are using livesplit-core in a server-like environment, set # this to false. Only client-side applications should set this to true. On # Unix you pass a file descriptor to this function. On Windows you pass a file # handle to this function. The file descriptor / handle does not get closed. # @param [Integer] handle # @param [String] path # @param [Boolean] load_files # @return [ParseRunResult] def self.parse_file_handle(handle, path, load_files) result = ParseRunResult.new(Native.Run_parse_file_handle(handle, path, load_files)) result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Run Editor allows modifying Runs while ensuring that all the different # invariants of the Run objects are upheld no matter what kind of operations # are being applied to the Run. It provides the current state of the editor as # state objects that can be visualized by any kind of User Interface. class RunEditorRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # The Run Editor allows modifying Runs while ensuring that all the different # invariants of the Run objects are upheld no matter what kind of operations # are being applied to the Run. It provides the current state of the editor as # state objects that can be visualized by any kind of User Interface. class RunEditorRefMut < RunEditorRef # Calculates the Run Editor's state and encodes it as # JSON in order to visualize it. # @return [String] def state_as_json() if @handle.ptr == nil raise "this is disposed" end result = Native.RunEditor_state_as_json(@handle.ptr) result end # Selects a different timing method for being modified. # @param [Integer] method def select_timing_method(method) if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_select_timing_method(@handle.ptr, method) end # Unselects the segment with the given index. If it's not selected or the # index is out of bounds, nothing happens. The segment is not unselected, # when it is the only segment that is selected. If the active segment is # unselected, the most recently selected segment remaining becomes the # active segment. # @param [Integer] index def unselect(index) if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_unselect(@handle.ptr, index) end # In addition to the segments that are already selected, the segment with # the given index is being selected. The segment chosen also becomes the # active segment. # # This panics if the index of the segment provided is out of bounds. # @param [Integer] index def select_additionally(index) if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_select_additionally(@handle.ptr, index) end # Selects the segment with the given index. All other segments are # unselected. The segment chosen also becomes the active segment. # # This panics if the index of the segment provided is out of bounds. # @param [Integer] index def select_only(index) if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_select_only(@handle.ptr, index) end # Sets the name of the game. # @param [String] game def set_game_name(game) if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_set_game_name(@handle.ptr, game) end # Sets the name of the category. # @param [String] category def set_category_name(category) if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_set_category_name(@handle.ptr, category) end # Parses and sets the timer offset from the string provided. The timer # offset specifies the time, the timer starts at when starting a new # attempt. # @param [String] offset # @return [Boolean] def parse_and_set_offset(offset) if @handle.ptr == nil raise "this is disposed" end result = Native.RunEditor_parse_and_set_offset(@handle.ptr, offset) result end # Parses and sets the attempt count from the string provided. Changing # this has no affect on the attempt history or the segment history. This # number is mostly just a visual number for the runner. # @param [String] attempts # @return [Boolean] def parse_and_set_attempt_count(attempts) if @handle.ptr == nil raise "this is disposed" end result = Native.RunEditor_parse_and_set_attempt_count(@handle.ptr, attempts) result end # Sets the game's icon. # @param [Integer] data # @param [Integer] length def set_game_icon(data, length) if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_set_game_icon(@handle.ptr, data, length) end # Removes the game's icon. def remove_game_icon() if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_remove_game_icon(@handle.ptr) end # Inserts a new empty segment above the active segment and adjusts the # Run's history information accordingly. The newly created segment is then # the only selected segment and also the active segment. def insert_segment_above() if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_insert_segment_above(@handle.ptr) end # Inserts a new empty segment below the active segment and adjusts the # Run's history information accordingly. The newly created segment is then # the only selected segment and also the active segment. def insert_segment_below() if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_insert_segment_below(@handle.ptr) end # Removes all the selected segments, unless all of them are selected. The # run's information is automatically adjusted properly. The next # not-to-be-removed segment after the active segment becomes the new # active segment. If there's none, then the next not-to-be-removed segment # before the active segment, becomes the new active segment. def remove_segments() if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_remove_segments(@handle.ptr) end # Moves all the selected segments up, unless the first segment is # selected. The run's information is automatically adjusted properly. The # active segment stays the active segment. def move_segments_up() if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_move_segments_up(@handle.ptr) end # Moves all the selected segments down, unless the last segment is # selected. The run's information is automatically adjusted properly. The # active segment stays the active segment. def move_segments_down() if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_move_segments_down(@handle.ptr) end # Sets the icon of the active segment. # @param [Integer] data # @param [Integer] length def active_set_icon(data, length) if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_active_set_icon(@handle.ptr, data, length) end # Removes the icon of the active segment. def active_remove_icon() if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_active_remove_icon(@handle.ptr) end # Sets the name of the active segment. # @param [String] name def active_set_name(name) if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_active_set_name(@handle.ptr, name) end # Parses a split time from a string and sets it for the active segment with # the chosen timing method. # @param [String] time # @return [Boolean] def active_parse_and_set_split_time(time) if @handle.ptr == nil raise "this is disposed" end result = Native.RunEditor_active_parse_and_set_split_time(@handle.ptr, time) result end # Parses a segment time from a string and sets it for the active segment with # the chosen timing method. # @param [String] time # @return [Boolean] def active_parse_and_set_segment_time(time) if @handle.ptr == nil raise "this is disposed" end result = Native.RunEditor_active_parse_and_set_segment_time(@handle.ptr, time) result end # Parses a best segment time from a string and sets it for the active segment # with the chosen timing method. # @param [String] time # @return [Boolean] def active_parse_and_set_best_segment_time(time) if @handle.ptr == nil raise "this is disposed" end result = Native.RunEditor_active_parse_and_set_best_segment_time(@handle.ptr, time) result end # Parses a comparison time for the provided comparison and sets it for the # active active segment with the chosen timing method. # @param [String] comparison # @param [String] time # @return [Boolean] def active_parse_and_set_comparison_time(comparison, time) if @handle.ptr == nil raise "this is disposed" end result = Native.RunEditor_active_parse_and_set_comparison_time(@handle.ptr, comparison, time) result end # Adds a new custom comparison. It can't be added if it starts with # `[Race]` or already exists. # @param [String] comparison # @return [Boolean] def add_comparison(comparison) if @handle.ptr == nil raise "this is disposed" end result = Native.RunEditor_add_comparison(@handle.ptr, comparison) result end # Imports the Personal Best from the provided run as a comparison. The # comparison can't be added if its name starts with `[Race]` or it already # exists. # @param [RunRef] run # @param [String] comparison # @return [Boolean] def import_comparison(run, comparison) if @handle.ptr == nil raise "this is disposed" end if run.handle.ptr == nil raise "run is disposed" end result = Native.RunEditor_import_comparison(@handle.ptr, run.handle.ptr, comparison) result end # Removes the chosen custom comparison. You can't remove a Comparison # Generator's Comparison or the Personal Best. # @param [String] comparison def remove_comparison(comparison) if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_remove_comparison(@handle.ptr, comparison) end # Renames a comparison. The comparison can't be renamed if the new name of # the comparison starts with `[Race]` or it already exists. # @param [String] old_name # @param [String] new_name # @return [Boolean] def rename_comparison(old_name, new_name) if @handle.ptr == nil raise "this is disposed" end result = Native.RunEditor_rename_comparison(@handle.ptr, old_name, new_name) result end # Clears out the Attempt History and the Segment Histories of all the # segments. def clear_history() if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_clear_history(@handle.ptr) end # Clears out the Attempt History, the Segment Histories, all the times, # sets the Attempt Count to 0 and clears the speedrun.com run id # association. All Custom Comparisons other than `Personal Best` are # deleted as well. def clear_times() if @handle.ptr == nil raise "this is disposed" end Native.RunEditor_clear_times(@handle.ptr) end # Creates a Sum of Best Cleaner which allows you to interactively remove # potential issues in the segment history that lead to an inaccurate Sum # of Best. If you skip a split, whenever you will do the next split, the # combined segment time might be faster than the sum of the individual # best segments. The Sum of Best Cleaner will point out all of these and # allows you to delete them individually if any of them seem wrong. # @return [SumOfBestCleaner] def clean_sum_of_best() if @handle.ptr == nil raise "this is disposed" end result = SumOfBestCleaner.new(Native.RunEditor_clean_sum_of_best(@handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Run Editor allows modifying Runs while ensuring that all the different # invariants of the Run objects are upheld no matter what kind of operations # are being applied to the Run. It provides the current state of the editor as # state objects that can be visualized by any kind of User Interface. class RunEditor < RunEditorRefMut def self.finalize(handle) proc { if handle.ptr != nil handle.ptr = nil end } end def dispose finalizer = RunEditor.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Run Editor that modifies the Run provided. Creation of the Run # Editor fails when a Run with no segments is provided. If a Run object with # no segments is provided, the Run Editor creation fails and nil is # returned. # @param [Run] run # @return [RunEditor, nil] def self.create(run) if run.handle.ptr == nil raise "run is disposed" end result = RunEditor.new(Native.RunEditor_new(run.handle.ptr)) run.handle.ptr = nil if result.handle.ptr == nil return nil end result end # Closes the Run Editor and gives back access to the modified Run object. In # case you want to implement a Cancel Button, just dispose the Run object you # get here. # @return [Run] def close() if @handle.ptr == nil raise "this is disposed" end result = Run.new(Native.RunEditor_close(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Run Metadata stores additional information about a run, like the # platform and region of the game. All of this information is optional. class RunMetadataRef attr_accessor :handle # Accesses the speedrun.com Run ID of the run. This Run ID specify which # Record on speedrun.com this run is associated with. This should be # changed once the Personal Best doesn't match up with that record # anymore. This may be empty if there's no association. # @return [String] def run_id() if @handle.ptr == nil raise "this is disposed" end result = Native.RunMetadata_run_id(@handle.ptr) result end # Accesses the name of the platform this game is run on. This may be empty # if it's not specified. # @return [String] def platform_name() if @handle.ptr == nil raise "this is disposed" end result = Native.RunMetadata_platform_name(@handle.ptr) result end # Returns true if this speedrun is done on an emulator. However false # may also indicate that this information is simply not known. # @return [Boolean] def uses_emulator() if @handle.ptr == nil raise "this is disposed" end result = Native.RunMetadata_uses_emulator(@handle.ptr) result end # Accesses the name of the region this game is from. This may be empty if # it's not specified. # @return [String] def region_name() if @handle.ptr == nil raise "this is disposed" end result = Native.RunMetadata_region_name(@handle.ptr) result end # Returns an iterator iterating over all the variables and their values # that have been specified. # @return [RunMetadataVariablesIter] def variables() if @handle.ptr == nil raise "this is disposed" end result = RunMetadataVariablesIter.new(Native.RunMetadata_variables(@handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Run Metadata stores additional information about a run, like the # platform and region of the game. All of this information is optional. class RunMetadataRefMut < RunMetadataRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The Run Metadata stores additional information about a run, like the # platform and region of the game. All of this information is optional. class RunMetadata < RunMetadataRefMut def self.finalize(handle) proc { if handle.ptr != nil handle.ptr = nil end } end def dispose finalizer = RunMetadata.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A Run Metadata variable is an arbitrary key value pair storing additional # information about the category. An example of this may be whether Amiibos # are used in the category. class RunMetadataVariableRef attr_accessor :handle # Accesses the name of this Run Metadata variable. # @return [String] def name() if @handle.ptr == nil raise "this is disposed" end result = Native.RunMetadataVariable_name(@handle.ptr) result end # Accesses the value of this Run Metadata variable. # @return [String] def value() if @handle.ptr == nil raise "this is disposed" end result = Native.RunMetadataVariable_value(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Run Metadata variable is an arbitrary key value pair storing additional # information about the category. An example of this may be whether Amiibos # are used in the category. class RunMetadataVariableRefMut < RunMetadataVariableRef def initialize(ptr) @handle = LSCHandle.new ptr end end # A Run Metadata variable is an arbitrary key value pair storing additional # information about the category. An example of this may be whether Amiibos # are used in the category. class RunMetadataVariable < RunMetadataVariableRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.RunMetadataVariable_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = RunMetadataVariable.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # An iterator iterating over all the Run Metadata variables and their values # that have been specified. class RunMetadataVariablesIterRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # An iterator iterating over all the Run Metadata variables and their values # that have been specified. class RunMetadataVariablesIterRefMut < RunMetadataVariablesIterRef # Accesses the next Run Metadata variable. Returns nil if there are no more # variables. # @return [RunMetadataVariableRef, nil] def next() if @handle.ptr == nil raise "this is disposed" end result = RunMetadataVariableRef.new(Native.RunMetadataVariablesIter_next(@handle.ptr)) if result.handle.ptr == nil return nil end result end def initialize(ptr) @handle = LSCHandle.new ptr end end # An iterator iterating over all the Run Metadata variables and their values # that have been specified. class RunMetadataVariablesIter < RunMetadataVariablesIterRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.RunMetadataVariablesIter_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = RunMetadataVariablesIter.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A Segment describes a point in a speedrun that is suitable for storing a # split time. This stores the name of that segment, an icon, the split times # of different comparisons, and a history of segment times. class SegmentRef attr_accessor :handle # Accesses the name of the segment. # @return [String] def name() if @handle.ptr == nil raise "this is disposed" end result = Native.Segment_name(@handle.ptr) result end # Accesses the icon of the segment encoded as a Data URL storing the image's # data. If the image's data is empty, this returns an empty string instead of # a URL. # @return [String] def icon() if @handle.ptr == nil raise "this is disposed" end result = Native.Segment_icon(@handle.ptr) result end # Accesses the specified comparison's time. If there's none for this # comparison, an empty time is being returned (but not stored in the # segment). # @param [String] comparison # @return [TimeRef] def comparison(comparison) if @handle.ptr == nil raise "this is disposed" end result = TimeRef.new(Native.Segment_comparison(@handle.ptr, comparison)) result end # Accesses the split time of the Personal Best for this segment. If it # doesn't exist, an empty time is returned. # @return [TimeRef] def personal_best_split_time() if @handle.ptr == nil raise "this is disposed" end result = TimeRef.new(Native.Segment_personal_best_split_time(@handle.ptr)) result end # Accesses the Best Segment Time. # @return [TimeRef] def best_segment_time() if @handle.ptr == nil raise "this is disposed" end result = TimeRef.new(Native.Segment_best_segment_time(@handle.ptr)) result end # Accesses the Segment History of this segment. # @return [SegmentHistoryRef] def segment_history() if @handle.ptr == nil raise "this is disposed" end result = SegmentHistoryRef.new(Native.Segment_segment_history(@handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Segment describes a point in a speedrun that is suitable for storing a # split time. This stores the name of that segment, an icon, the split times # of different comparisons, and a history of segment times. class SegmentRefMut < SegmentRef def initialize(ptr) @handle = LSCHandle.new ptr end end # A Segment describes a point in a speedrun that is suitable for storing a # split time. This stores the name of that segment, an icon, the split times # of different comparisons, and a history of segment times. class Segment < SegmentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.Segment_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = Segment.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Segment with the name given. # @param [String] name # @return [Segment] def self.create(name) result = Segment.new(Native.Segment_new(name)) result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # Stores the segment times achieved for a certain segment. Each segment is # tagged with an index. Only segment times with an index larger than 0 are # considered times actually achieved by the runner, while the others are # artifacts of route changes and similar algorithmic changes. class SegmentHistoryRef attr_accessor :handle # Iterates over all the segment times and their indices. # @return [SegmentHistoryIter] def iter() if @handle.ptr == nil raise "this is disposed" end result = SegmentHistoryIter.new(Native.SegmentHistory_iter(@handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # Stores the segment times achieved for a certain segment. Each segment is # tagged with an index. Only segment times with an index larger than 0 are # considered times actually achieved by the runner, while the others are # artifacts of route changes and similar algorithmic changes. class SegmentHistoryRefMut < SegmentHistoryRef def initialize(ptr) @handle = LSCHandle.new ptr end end # Stores the segment times achieved for a certain segment. Each segment is # tagged with an index. Only segment times with an index larger than 0 are # considered times actually achieved by the runner, while the others are # artifacts of route changes and similar algorithmic changes. class SegmentHistory < SegmentHistoryRefMut def self.finalize(handle) proc { if handle.ptr != nil handle.ptr = nil end } end def dispose finalizer = SegmentHistory.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A segment time achieved for a segment. It is tagged with an index. Only # segment times with an index larger than 0 are considered times actually # achieved by the runner, while the others are artifacts of route changes and # similar algorithmic changes. class SegmentHistoryElementRef attr_accessor :handle # Accesses the index of the segment history element. # @return [Integer] def index() if @handle.ptr == nil raise "this is disposed" end result = Native.SegmentHistoryElement_index(@handle.ptr) result end # Accesses the segment time of the segment history element. # @return [TimeRef] def time() if @handle.ptr == nil raise "this is disposed" end result = TimeRef.new(Native.SegmentHistoryElement_time(@handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # A segment time achieved for a segment. It is tagged with an index. Only # segment times with an index larger than 0 are considered times actually # achieved by the runner, while the others are artifacts of route changes and # similar algorithmic changes. class SegmentHistoryElementRefMut < SegmentHistoryElementRef def initialize(ptr) @handle = LSCHandle.new ptr end end # A segment time achieved for a segment. It is tagged with an index. Only # segment times with an index larger than 0 are considered times actually # achieved by the runner, while the others are artifacts of route changes and # similar algorithmic changes. class SegmentHistoryElement < SegmentHistoryElementRefMut def self.finalize(handle) proc { if handle.ptr != nil handle.ptr = nil end } end def dispose finalizer = SegmentHistoryElement.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # Iterates over all the segment times of a segment and their indices. class SegmentHistoryIterRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # Iterates over all the segment times of a segment and their indices. class SegmentHistoryIterRefMut < SegmentHistoryIterRef # Accesses the next Segment History element. Returns nil if there are no # more elements. # @return [SegmentHistoryElementRef, nil] def next() if @handle.ptr == nil raise "this is disposed" end result = SegmentHistoryElementRef.new(Native.SegmentHistoryIter_next(@handle.ptr)) if result.handle.ptr == nil return nil end result end def initialize(ptr) @handle = LSCHandle.new ptr end end # Iterates over all the segment times of a segment and their indices. class SegmentHistoryIter < SegmentHistoryIterRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.SegmentHistoryIter_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = SegmentHistoryIter.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Separator Component is a simple component that only serves to render # separators between components. class SeparatorComponentRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # The Separator Component is a simple component that only serves to render # separators between components. class SeparatorComponentRefMut < SeparatorComponentRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The Separator Component is a simple component that only serves to render # separators between components. class SeparatorComponent < SeparatorComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.SeparatorComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = SeparatorComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Separator Component. # @return [SeparatorComponent] def self.create() result = SeparatorComponent.new(Native.SeparatorComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.SeparatorComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # Describes a setting's value. Such a value can be of a variety of different # types. class SettingValueRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # Describes a setting's value. Such a value can be of a variety of different # types. class SettingValueRefMut < SettingValueRef def initialize(ptr) @handle = LSCHandle.new ptr end end # Describes a setting's value. Such a value can be of a variety of different # types. class SettingValue < SettingValueRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.SettingValue_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = SettingValue.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new setting value from a boolean value. # @param [Boolean] value # @return [SettingValue] def self.from_bool(value) result = SettingValue.new(Native.SettingValue_from_bool(value)) result end # Creates a new setting value from an unsigned integer. # @param [Integer] value # @return [SettingValue] def self.from_uint(value) result = SettingValue.new(Native.SettingValue_from_uint(value)) result end # Creates a new setting value from a signed integer. # @param [Integer] value # @return [SettingValue] def self.from_int(value) result = SettingValue.new(Native.SettingValue_from_int(value)) result end # Creates a new setting value from a string. # @param [String] value # @return [SettingValue] def self.from_string(value) result = SettingValue.new(Native.SettingValue_from_string(value)) result end # Creates a new setting value from a string that has the type `optional string`. # @param [String] value # @return [SettingValue] def self.from_optional_string(value) result = SettingValue.new(Native.SettingValue_from_optional_string(value)) result end # Creates a new empty setting value that has the type `optional string`. # @return [SettingValue] def self.from_optional_empty_string() result = SettingValue.new(Native.SettingValue_from_optional_empty_string()) result end # Creates a new setting value from a floating point number. # @param [Float] value # @return [SettingValue] def self.from_float(value) result = SettingValue.new(Native.SettingValue_from_float(value)) result end # Creates a new setting value from an accuracy name. If it doesn't match a # known accuracy, nil is returned. # @param [String] value # @return [SettingValue, nil] def self.from_accuracy(value) result = SettingValue.new(Native.SettingValue_from_accuracy(value)) if result.handle.ptr == nil return nil end result end # Creates a new setting value from a digits format name. If it doesn't match a # known digits format, nil is returned. # @param [String] value # @return [SettingValue, nil] def self.from_digits_format(value) result = SettingValue.new(Native.SettingValue_from_digits_format(value)) if result.handle.ptr == nil return nil end result end # Creates a new setting value from a timing method name with the type # `optional timing method`. If it doesn't match a known timing method, nil # is returned. # @param [String] value # @return [SettingValue, nil] def self.from_optional_timing_method(value) result = SettingValue.new(Native.SettingValue_from_optional_timing_method(value)) if result.handle.ptr == nil return nil end result end # Creates a new empty setting value with the type `optional timing method`. # @return [SettingValue] def self.from_optional_empty_timing_method() result = SettingValue.new(Native.SettingValue_from_optional_empty_timing_method()) result end # Creates a new setting value from the color provided as RGBA. # @param [Float] r # @param [Float] g # @param [Float] b # @param [Float] a # @return [SettingValue] def self.from_color(r, g, b, a) result = SettingValue.new(Native.SettingValue_from_color(r, g, b, a)) result end # Creates a new setting value from the color provided as RGBA with the type # `optional color`. # @param [Float] r # @param [Float] g # @param [Float] b # @param [Float] a # @return [SettingValue] def self.from_optional_color(r, g, b, a) result = SettingValue.new(Native.SettingValue_from_optional_color(r, g, b, a)) result end # Creates a new empty setting value with the type `optional color`. # @return [SettingValue] def self.from_optional_empty_color() result = SettingValue.new(Native.SettingValue_from_optional_empty_color()) result end # Creates a new setting value that is a transparent gradient. # @return [SettingValue] def self.from_transparent_gradient() result = SettingValue.new(Native.SettingValue_from_transparent_gradient()) result end # Creates a new setting value from the vertical gradient provided as two RGBA colors. # @param [Float] r1 # @param [Float] g1 # @param [Float] b1 # @param [Float] a1 # @param [Float] r2 # @param [Float] g2 # @param [Float] b2 # @param [Float] a2 # @return [SettingValue] def self.from_vertical_gradient(r1, g1, b1, a1, r2, g2, b2, a2) result = SettingValue.new(Native.SettingValue_from_vertical_gradient(r1, g1, b1, a1, r2, g2, b2, a2)) result end # Creates a new setting value from the horizontal gradient provided as two RGBA colors. # @param [Float] r1 # @param [Float] g1 # @param [Float] b1 # @param [Float] a1 # @param [Float] r2 # @param [Float] g2 # @param [Float] b2 # @param [Float] a2 # @return [SettingValue] def self.from_horizontal_gradient(r1, g1, b1, a1, r2, g2, b2, a2) result = SettingValue.new(Native.SettingValue_from_horizontal_gradient(r1, g1, b1, a1, r2, g2, b2, a2)) result end # Creates a new setting value from the alignment name provided. If it doesn't # match a known alignment, nil is returned. # @param [String] value # @return [SettingValue, nil] def self.from_alignment(value) result = SettingValue.new(Native.SettingValue_from_alignment(value)) if result.handle.ptr == nil return nil end result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A Shared Timer that can be used to share a single timer object with multiple # owners. class SharedTimerRef attr_accessor :handle # Creates a new shared timer handle that shares the same timer. The inner # timer object only gets disposed when the final handle gets disposed. # @return [SharedTimer] def share() if @handle.ptr == nil raise "this is disposed" end result = SharedTimer.new(Native.SharedTimer_share(@handle.ptr)) result end # Requests read access to the timer that is being shared. This blocks the # thread as long as there is an active write lock. Dispose the read lock when # you are done using the timer. # @return [TimerReadLock] def read() if @handle.ptr == nil raise "this is disposed" end result = TimerReadLock.new(Native.SharedTimer_read(@handle.ptr)) result end # Requests write access to the timer that is being shared. This blocks the # thread as long as there are active write or read locks. Dispose the write # lock when you are done using the timer. # @return [TimerWriteLock] def write() if @handle.ptr == nil raise "this is disposed" end result = TimerWriteLock.new(Native.SharedTimer_write(@handle.ptr)) result end # Replaces the timer that is being shared by the timer provided. This blocks # the thread as long as there are active write or read locks. Everyone who is # sharing the old timer will share the provided timer after successful # completion. # @param [Timer] timer def replace_inner(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end Native.SharedTimer_replace_inner(@handle.ptr, timer.handle.ptr) timer.handle.ptr = nil end def read_with self.read.wtih do |lock| yield lock.timer end end def write_with self.write.with do |lock| yield lock.timer end end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Shared Timer that can be used to share a single timer object with multiple # owners. class SharedTimerRefMut < SharedTimerRef def initialize(ptr) @handle = LSCHandle.new ptr end end # A Shared Timer that can be used to share a single timer object with multiple # owners. class SharedTimer < SharedTimerRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.SharedTimer_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = SharedTimer.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Splits Component is the main component for visualizing all the split # times. Each segment is shown in a tabular fashion showing the segment icon, # segment name, the delta compared to the chosen comparison, and the split # time. The list provides scrolling functionality, so not every segment needs # to be shown all the time. class SplitsComponentRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # The Splits Component is the main component for visualizing all the split # times. Each segment is shown in a tabular fashion showing the segment icon, # segment name, the delta compared to the chosen comparison, and the split # time. The list provides scrolling functionality, so not every segment needs # to be shown all the time. class SplitsComponentRefMut < SplitsComponentRef # Encodes the component's state information as JSON. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [String] def state_as_json(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = Native.SplitsComponent_state_as_json(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr) result end # Calculates the component's state based on the timer and layout settings # provided. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [SplitsComponentState] def state(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = SplitsComponentState.new(Native.SplitsComponent_state(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr)) result end # Scrolls up the window of the segments that are shown. Doesn't move the # scroll window if it reaches the top of the segments. def scroll_up() if @handle.ptr == nil raise "this is disposed" end Native.SplitsComponent_scroll_up(@handle.ptr) end # Scrolls down the window of the segments that are shown. Doesn't move the # scroll window if it reaches the bottom of the segments. def scroll_down() if @handle.ptr == nil raise "this is disposed" end Native.SplitsComponent_scroll_down(@handle.ptr) end # The amount of segments to show in the list at any given time. If this is # set to 0, all the segments are shown. If this is set to a number lower # than the total amount of segments, only a certain window of all the # segments is shown. This window can scroll up or down. # @param [Integer] count def set_visual_split_count(count) if @handle.ptr == nil raise "this is disposed" end Native.SplitsComponent_set_visual_split_count(@handle.ptr, count) end # If there's more segments than segments that are shown, the window # showing the segments automatically scrolls up and down when the current # segment changes. This count determines the minimum number of future # segments to be shown in this scrolling window when it automatically # scrolls. # @param [Integer] count def set_split_preview_count(count) if @handle.ptr == nil raise "this is disposed" end Native.SplitsComponent_set_split_preview_count(@handle.ptr, count) end # If not every segment is shown in the scrolling window of segments, then # this determines whether the final segment is always to be shown, as it # contains valuable information about the total duration of the chosen # comparison, which is often the runner's Personal Best. # @param [Boolean] always_show_last_split def set_always_show_last_split(always_show_last_split) if @handle.ptr == nil raise "this is disposed" end Native.SplitsComponent_set_always_show_last_split(@handle.ptr, always_show_last_split) end # If the last segment is to always be shown, this determines whether to # show a more pronounced separator in front of the last segment, if it is # not directly adjacent to the segment shown right before it in the # scrolling window. # @param [Boolean] separator_last_split def set_separator_last_split(separator_last_split) if @handle.ptr == nil raise "this is disposed" end Native.SplitsComponent_set_separator_last_split(@handle.ptr, separator_last_split) end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Splits Component is the main component for visualizing all the split # times. Each segment is shown in a tabular fashion showing the segment icon, # segment name, the delta compared to the chosen comparison, and the split # time. The list provides scrolling functionality, so not every segment needs # to be shown all the time. class SplitsComponent < SplitsComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.SplitsComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = SplitsComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Splits Component. # @return [SplitsComponent] def self.create() result = SplitsComponent.new(Native.SplitsComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.SplitsComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object that describes a single segment's information to visualize. class SplitsComponentStateRef attr_accessor :handle # Describes whether a more pronounced separator should be shown in front of # the last segment provided. # @return [Boolean] def final_separator_shown() if @handle.ptr == nil raise "this is disposed" end result = Native.SplitsComponentState_final_separator_shown(@handle.ptr) result end # Returns the amount of segments to visualize. # @return [Integer] def len() if @handle.ptr == nil raise "this is disposed" end result = Native.SplitsComponentState_len(@handle.ptr) result end # Returns the amount of icon changes that happened in this state object. # @return [Integer] def icon_change_count() if @handle.ptr == nil raise "this is disposed" end result = Native.SplitsComponentState_icon_change_count(@handle.ptr) result end # Accesses the index of the segment of the icon change with the specified # index. This is based on the index in the run, not on the index of the # SplitState in the State object. The corresponding index is the index field # of the SplitState object. You may not provide an out of bounds index. # @param [Integer] icon_change_index # @return [Integer] def icon_change_segment_index(icon_change_index) if @handle.ptr == nil raise "this is disposed" end result = Native.SplitsComponentState_icon_change_segment_index(@handle.ptr, icon_change_index) result end # The segment's icon encoded as a Data URL of the icon change with the # specified index. The String itself may be empty. This indicates that there # is no icon. You may not provide an out of bounds index. # @param [Integer] icon_change_index # @return [String] def icon_change_icon(icon_change_index) if @handle.ptr == nil raise "this is disposed" end result = Native.SplitsComponentState_icon_change_icon(@handle.ptr, icon_change_index) result end # The name of the segment with the specified index. You may not provide an out # of bounds index. # @param [Integer] index # @return [String] def name(index) if @handle.ptr == nil raise "this is disposed" end result = Native.SplitsComponentState_name(@handle.ptr, index) result end # The delta to show for the segment with the specified index. You may not # provide an out of bounds index. # @param [Integer] index # @return [String] def delta(index) if @handle.ptr == nil raise "this is disposed" end result = Native.SplitsComponentState_delta(@handle.ptr, index) result end # The split time to show for the segment with the specified index. You may not # provide an out of bounds index. # @param [Integer] index # @return [String] def time(index) if @handle.ptr == nil raise "this is disposed" end result = Native.SplitsComponentState_time(@handle.ptr, index) result end # The semantic coloring information the delta time carries of the segment with # the specified index. You may not provide an out of bounds index. # @param [Integer] index # @return [String] def semantic_color(index) if @handle.ptr == nil raise "this is disposed" end result = Native.SplitsComponentState_semantic_color(@handle.ptr, index) result end # Describes if the segment with the specified index is the segment the active # attempt is currently on. # @param [Integer] index # @return [Boolean] def is_current_split(index) if @handle.ptr == nil raise "this is disposed" end result = Native.SplitsComponentState_is_current_split(@handle.ptr, index) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object that describes a single segment's information to visualize. class SplitsComponentStateRefMut < SplitsComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object that describes a single segment's information to visualize. class SplitsComponentState < SplitsComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.SplitsComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = SplitsComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A Sum of Best Cleaner allows you to interactively remove potential issues in # the Segment History that lead to an inaccurate Sum of Best. If you skip a # split, whenever you get to the next split, the combined segment time might # be faster than the sum of the individual best segments. The Sum of Best # Cleaner will point out all of occurrences of this and allows you to delete # them individually if any of them seem wrong. class SumOfBestCleanerRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # A Sum of Best Cleaner allows you to interactively remove potential issues in # the Segment History that lead to an inaccurate Sum of Best. If you skip a # split, whenever you get to the next split, the combined segment time might # be faster than the sum of the individual best segments. The Sum of Best # Cleaner will point out all of occurrences of this and allows you to delete # them individually if any of them seem wrong. class SumOfBestCleanerRefMut < SumOfBestCleanerRef # Returns the next potential clean up. If there are no more potential # clean ups, nil is returned. # @return [PotentialCleanUp, nil] def next_potential_clean_up() if @handle.ptr == nil raise "this is disposed" end result = PotentialCleanUp.new(Native.SumOfBestCleaner_next_potential_clean_up(@handle.ptr)) if result.handle.ptr == nil return nil end result end # Applies a clean up to the Run. # @param [PotentialCleanUp] clean_up def apply(clean_up) if @handle.ptr == nil raise "this is disposed" end if clean_up.handle.ptr == nil raise "clean_up is disposed" end Native.SumOfBestCleaner_apply(@handle.ptr, clean_up.handle.ptr) clean_up.handle.ptr = nil end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Sum of Best Cleaner allows you to interactively remove potential issues in # the Segment History that lead to an inaccurate Sum of Best. If you skip a # split, whenever you get to the next split, the combined segment time might # be faster than the sum of the individual best segments. The Sum of Best # Cleaner will point out all of occurrences of this and allows you to delete # them individually if any of them seem wrong. class SumOfBestCleaner < SumOfBestCleanerRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.SumOfBestCleaner_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = SumOfBestCleaner.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Sum of Best Segments Component shows the fastest possible time to # complete a run of this category, based on information collected from all the # previous attempts. This often matches up with the sum of the best segment # times of all the segments, but that may not always be the case, as skipped # segments may introduce combined segments that may be faster than the actual # sum of their best segment times. The name is therefore a bit misleading, but # sticks around for historical reasons. class SumOfBestComponentRef attr_accessor :handle # Encodes the component's state information as JSON. # @param [TimerRef] timer # @return [String] def state_as_json(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = Native.SumOfBestComponent_state_as_json(@handle.ptr, timer.handle.ptr) result end # Calculates the component's state based on the timer provided. # @param [TimerRef] timer # @return [SumOfBestComponentState] def state(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = SumOfBestComponentState.new(Native.SumOfBestComponent_state(@handle.ptr, timer.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Sum of Best Segments Component shows the fastest possible time to # complete a run of this category, based on information collected from all the # previous attempts. This often matches up with the sum of the best segment # times of all the segments, but that may not always be the case, as skipped # segments may introduce combined segments that may be faster than the actual # sum of their best segment times. The name is therefore a bit misleading, but # sticks around for historical reasons. class SumOfBestComponentRefMut < SumOfBestComponentRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The Sum of Best Segments Component shows the fastest possible time to # complete a run of this category, based on information collected from all the # previous attempts. This often matches up with the sum of the best segment # times of all the segments, but that may not always be the case, as skipped # segments may introduce combined segments that may be faster than the actual # sum of their best segment times. The name is therefore a bit misleading, but # sticks around for historical reasons. class SumOfBestComponent < SumOfBestComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.SumOfBestComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = SumOfBestComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Sum of Best Segments Component. # @return [SumOfBestComponent] def self.create() result = SumOfBestComponent.new(Native.SumOfBestComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.SumOfBestComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class SumOfBestComponentStateRef attr_accessor :handle # The label's text. # @return [String] def text() if @handle.ptr == nil raise "this is disposed" end result = Native.SumOfBestComponentState_text(@handle.ptr) result end # The sum of best segments. # @return [String] def time() if @handle.ptr == nil raise "this is disposed" end result = Native.SumOfBestComponentState_time(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class SumOfBestComponentStateRefMut < SumOfBestComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class SumOfBestComponentState < SumOfBestComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.SumOfBestComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = SumOfBestComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Text Component simply visualizes any given text. This can either be a # single centered text, or split up into a left and right text, which is # suitable for a situation where you have a label and a value. class TextComponentRef attr_accessor :handle # Encodes the component's state information as JSON. # @return [String] def state_as_json() if @handle.ptr == nil raise "this is disposed" end result = Native.TextComponent_state_as_json(@handle.ptr) result end # Calculates the component's state. # @return [TextComponentState] def state() if @handle.ptr == nil raise "this is disposed" end result = TextComponentState.new(Native.TextComponent_state(@handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Text Component simply visualizes any given text. This can either be a # single centered text, or split up into a left and right text, which is # suitable for a situation where you have a label and a value. class TextComponentRefMut < TextComponentRef # Sets the centered text. If the current mode is split, it is switched to # centered mode. # @param [String] text def set_center(text) if @handle.ptr == nil raise "this is disposed" end Native.TextComponent_set_center(@handle.ptr, text) end # Sets the left text. If the current mode is centered, it is switched to # split mode, with the right text being empty. # @param [String] text def set_left(text) if @handle.ptr == nil raise "this is disposed" end Native.TextComponent_set_left(@handle.ptr, text) end # Sets the right text. If the current mode is centered, it is switched to # split mode, with the left text being empty. # @param [String] text def set_right(text) if @handle.ptr == nil raise "this is disposed" end Native.TextComponent_set_right(@handle.ptr, text) end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Text Component simply visualizes any given text. This can either be a # single centered text, or split up into a left and right text, which is # suitable for a situation where you have a label and a value. class TextComponent < TextComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.TextComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = TextComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Text Component. # @return [TextComponent] def self.create() result = TextComponent.new(Native.TextComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.TextComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class TextComponentStateRef attr_accessor :handle # Accesses the left part of the text. If the text isn't split up, an empty # string is returned instead. # @return [String] def left() if @handle.ptr == nil raise "this is disposed" end result = Native.TextComponentState_left(@handle.ptr) result end # Accesses the right part of the text. If the text isn't split up, an empty # string is returned instead. # @return [String] def right() if @handle.ptr == nil raise "this is disposed" end result = Native.TextComponentState_right(@handle.ptr) result end # Accesses the centered text. If the text isn't centered, an empty string is # returned instead. # @return [String] def center() if @handle.ptr == nil raise "this is disposed" end result = Native.TextComponentState_center(@handle.ptr) result end # Returns whether the text is split up into a left and right part. # @return [Boolean] def is_split() if @handle.ptr == nil raise "this is disposed" end result = Native.TextComponentState_is_split(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class TextComponentStateRefMut < TextComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class TextComponentState < TextComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.TextComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = TextComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A time that can store a Real Time and a Game Time. Both of them are # optional. class TimeRef attr_accessor :handle # Clones the time. # @return [Time] def clone() if @handle.ptr == nil raise "this is disposed" end result = Time.new(Native.Time_clone(@handle.ptr)) result end # The Real Time value. This may be nil if this time has no Real Time value. # @return [TimeSpanRef, nil] def real_time() if @handle.ptr == nil raise "this is disposed" end result = TimeSpanRef.new(Native.Time_real_time(@handle.ptr)) if result.handle.ptr == nil return nil end result end # The Game Time value. This may be nil if this time has no Game Time value. # @return [TimeSpanRef, nil] def game_time() if @handle.ptr == nil raise "this is disposed" end result = TimeSpanRef.new(Native.Time_game_time(@handle.ptr)) if result.handle.ptr == nil return nil end result end # Access the time's value for the timing method specified. # @param [Integer] timing_method # @return [TimeSpanRef, nil] def index(timing_method) if @handle.ptr == nil raise "this is disposed" end result = TimeSpanRef.new(Native.Time_index(@handle.ptr, timing_method)) if result.handle.ptr == nil return nil end result end def initialize(ptr) @handle = LSCHandle.new ptr end end # A time that can store a Real Time and a Game Time. Both of them are # optional. class TimeRefMut < TimeRef def initialize(ptr) @handle = LSCHandle.new ptr end end # A time that can store a Real Time and a Game Time. Both of them are # optional. class Time < TimeRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.Time_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = Time.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A Time Span represents a certain span of time. class TimeSpanRef attr_accessor :handle # Clones the Time Span. # @return [TimeSpan] def clone() if @handle.ptr == nil raise "this is disposed" end result = TimeSpan.new(Native.TimeSpan_clone(@handle.ptr)) result end # Returns the total amount of seconds (including decimals) this Time Span # represents. # @return [Float] def total_seconds() if @handle.ptr == nil raise "this is disposed" end result = Native.TimeSpan_total_seconds(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Time Span represents a certain span of time. class TimeSpanRefMut < TimeSpanRef def initialize(ptr) @handle = LSCHandle.new ptr end end # A Time Span represents a certain span of time. class TimeSpan < TimeSpanRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.TimeSpan_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = TimeSpan.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Time Span from a given amount of seconds. # @param [Float] seconds # @return [TimeSpan] def self.from_seconds(seconds) result = TimeSpan.new(Native.TimeSpan_from_seconds(seconds)) result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A Timer provides all the capabilities necessary for doing speedrun attempts. class TimerRef attr_accessor :handle # Returns the currently selected Timing Method. # @return [Integer] def current_timing_method() if @handle.ptr == nil raise "this is disposed" end result = Native.Timer_current_timing_method(@handle.ptr) result end # Returns the current comparison that is being compared against. This may # be a custom comparison or one of the Comparison Generators. # @return [String] def current_comparison() if @handle.ptr == nil raise "this is disposed" end result = Native.Timer_current_comparison(@handle.ptr) result end # Returns whether Game Time is currently initialized. Game Time # automatically gets uninitialized for each new attempt. # @return [Boolean] def is_game_time_initialized() if @handle.ptr == nil raise "this is disposed" end result = Native.Timer_is_game_time_initialized(@handle.ptr) result end # Returns whether the Game Timer is currently paused. If the Game Timer is # not paused, it automatically increments similar to Real Time. # @return [Boolean] def is_game_time_paused() if @handle.ptr == nil raise "this is disposed" end result = Native.Timer_is_game_time_paused(@handle.ptr) result end # Accesses the loading times. Loading times are defined as Game Time - Real Time. # @return [TimeSpanRef] def loading_times() if @handle.ptr == nil raise "this is disposed" end result = TimeSpanRef.new(Native.Timer_loading_times(@handle.ptr)) result end # Returns the current Timer Phase. # @return [Integer] def current_phase() if @handle.ptr == nil raise "this is disposed" end result = Native.Timer_current_phase(@handle.ptr) result end # Accesses the Run in use by the Timer. # @return [RunRef] def get_run() if @handle.ptr == nil raise "this is disposed" end result = RunRef.new(Native.Timer_get_run(@handle.ptr)) result end # Prints out debug information representing the whole state of the Timer. This # is being written to stdout. def print_debug() if @handle.ptr == nil raise "this is disposed" end Native.Timer_print_debug(@handle.ptr) end # Returns the current time of the Timer. The Game Time is nil if the Game # Time has not been initialized. # @return [TimeRef] def current_time() if @handle.ptr == nil raise "this is disposed" end result = TimeRef.new(Native.Timer_current_time(@handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Timer provides all the capabilities necessary for doing speedrun attempts. class TimerRefMut < TimerRef # Replaces the Run object used by the Timer with the Run object provided. If # the Run provided contains no segments, it can't be used for timing and is # not being modified. Otherwise the Run that was in use by the Timer gets # stored in the Run object provided. Before the Run is returned, the current # attempt is reset and the splits are being updated depending on the # `update_splits` parameter. The return value indicates whether the Run got # replaced successfully. # @param [RunRefMut] run # @param [Boolean] update_splits # @return [Boolean] def replace_run(run, update_splits) if @handle.ptr == nil raise "this is disposed" end if run.handle.ptr == nil raise "run is disposed" end result = Native.Timer_replace_run(@handle.ptr, run.handle.ptr, update_splits) result end # Sets the Run object used by the Timer with the Run object provided. If the # Run provided contains no segments, it can't be used for timing and gets # returned again. If the Run object can be set, the original Run object in use # by the Timer is disposed by this method and nil is returned. # @param [Run] run # @return [Run, nil] def set_run(run) if @handle.ptr == nil raise "this is disposed" end if run.handle.ptr == nil raise "run is disposed" end result = Run.new(Native.Timer_set_run(@handle.ptr, run.handle.ptr)) run.handle.ptr = nil if result.handle.ptr == nil return nil end result end # Starts the Timer if there is no attempt in progress. If that's not the # case, nothing happens. def start() if @handle.ptr == nil raise "this is disposed" end Native.Timer_start(@handle.ptr) end # If an attempt is in progress, stores the current time as the time of the # current split. The attempt ends if the last split time is stored. def split() if @handle.ptr == nil raise "this is disposed" end Native.Timer_split(@handle.ptr) end # Starts a new attempt or stores the current time as the time of the # current split. The attempt ends if the last split time is stored. def split_or_start() if @handle.ptr == nil raise "this is disposed" end Native.Timer_split_or_start(@handle.ptr) end # Skips the current split if an attempt is in progress and the # current split is not the last split. def skip_split() if @handle.ptr == nil raise "this is disposed" end Native.Timer_skip_split(@handle.ptr) end # Removes the split time from the last split if an attempt is in progress # and there is a previous split. The Timer Phase also switches to # `Running` if it previously was `Ended`. def undo_split() if @handle.ptr == nil raise "this is disposed" end Native.Timer_undo_split(@handle.ptr) end # Resets the current attempt if there is one in progress. If the splits # are to be updated, all the information of the current attempt is stored # in the Run's history. Otherwise the current attempt's information is # discarded. # @param [Boolean] update_splits def reset(update_splits) if @handle.ptr == nil raise "this is disposed" end Native.Timer_reset(@handle.ptr, update_splits) end # Pauses an active attempt that is not paused. def pause() if @handle.ptr == nil raise "this is disposed" end Native.Timer_pause(@handle.ptr) end # Resumes an attempt that is paused. def resume() if @handle.ptr == nil raise "this is disposed" end Native.Timer_resume(@handle.ptr) end # Toggles an active attempt between `Paused` and `Running`. def toggle_pause() if @handle.ptr == nil raise "this is disposed" end Native.Timer_toggle_pause(@handle.ptr) end # Toggles an active attempt between `Paused` and `Running` or starts an # attempt if there's none in progress. def toggle_pause_or_start() if @handle.ptr == nil raise "this is disposed" end Native.Timer_toggle_pause_or_start(@handle.ptr) end # Removes all the pause times from the current time. If the current # attempt is paused, it also resumes that attempt. Additionally, if the # attempt is finished, the final split time is adjusted to not include the # pause times as well. # # # Warning # # This behavior is not entirely optimal, as generally only the final split # time is modified, while all other split times are left unmodified, which # may not be what actually happened during the run. def undo_all_pauses() if @handle.ptr == nil raise "this is disposed" end Native.Timer_undo_all_pauses(@handle.ptr) end # Sets the current Timing Method to the Timing Method provided. # @param [Integer] method def set_current_timing_method(method) if @handle.ptr == nil raise "this is disposed" end Native.Timer_set_current_timing_method(@handle.ptr, method) end # Switches the current comparison to the next comparison in the list. def switch_to_next_comparison() if @handle.ptr == nil raise "this is disposed" end Native.Timer_switch_to_next_comparison(@handle.ptr) end # Switches the current comparison to the previous comparison in the list. def switch_to_previous_comparison() if @handle.ptr == nil raise "this is disposed" end Native.Timer_switch_to_previous_comparison(@handle.ptr) end # Initializes Game Time for the current attempt. Game Time automatically # gets uninitialized for each new attempt. def initialize_game_time() if @handle.ptr == nil raise "this is disposed" end Native.Timer_initialize_game_time(@handle.ptr) end # Deinitializes Game Time for the current attempt. def deinitialize_game_time() if @handle.ptr == nil raise "this is disposed" end Native.Timer_deinitialize_game_time(@handle.ptr) end # Pauses the Game Timer such that it doesn't automatically increment # similar to Real Time. def pause_game_time() if @handle.ptr == nil raise "this is disposed" end Native.Timer_pause_game_time(@handle.ptr) end # Resumes the Game Timer such that it automatically increments similar to # Real Time, starting from the Game Time it was paused at. def resume_game_time() if @handle.ptr == nil raise "this is disposed" end Native.Timer_resume_game_time(@handle.ptr) end # Sets the Game Time to the time specified. This also works if the Game # Time is paused, which can be used as away of updating the Game Timer # periodically without it automatically moving forward. This ensures that # the Game Timer never shows any time that is not coming from the game. # @param [TimeSpanRef] time def set_game_time(time) if @handle.ptr == nil raise "this is disposed" end if time.handle.ptr == nil raise "time is disposed" end Native.Timer_set_game_time(@handle.ptr, time.handle.ptr) end # Instead of setting the Game Time directly, this method can be used to # just specify the amount of time the game has been loading. The Game Time # is then automatically determined by Real Time - Loading Times. # @param [TimeSpanRef] time def set_loading_times(time) if @handle.ptr == nil raise "this is disposed" end if time.handle.ptr == nil raise "time is disposed" end Native.Timer_set_loading_times(@handle.ptr, time.handle.ptr) end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Timer provides all the capabilities necessary for doing speedrun attempts. class Timer < TimerRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.Timer_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = Timer.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Timer based on a Run object storing all the information # about the splits. The Run object needs to have at least one segment, so # that the Timer can store the final time. If a Run object with no # segments is provided, the Timer creation fails and nil is returned. # @param [Run] run # @return [Timer, nil] def self.create(run) if run.handle.ptr == nil raise "run is disposed" end result = Timer.new(Native.Timer_new(run.handle.ptr)) run.handle.ptr = nil if result.handle.ptr == nil return nil end result end # Consumes the Timer and creates a Shared Timer that can be shared across # multiple threads with multiple owners. # @return [SharedTimer] def into_shared() if @handle.ptr == nil raise "this is disposed" end result = SharedTimer.new(Native.Timer_into_shared(@handle.ptr)) @handle.ptr = nil result end # Takes out the Run from the Timer and resets the current attempt if there # is one in progress. If the splits are to be updated, all the information # of the current attempt is stored in the Run's history. Otherwise the # current attempt's information is discarded. # @param [Boolean] update_splits # @return [Run] def into_run(update_splits) if @handle.ptr == nil raise "this is disposed" end result = Run.new(Native.Timer_into_run(@handle.ptr, update_splits)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Timer Component is a component that shows the total time of the current # attempt as a digital clock. The color of the time shown is based on a how # well the current attempt is doing compared to the chosen comparison. class TimerComponentRef attr_accessor :handle # Encodes the component's state information as JSON. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [String] def state_as_json(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = Native.TimerComponent_state_as_json(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr) result end # Calculates the component's state based on the timer and the layout # settings provided. # @param [TimerRef] timer # @param [GeneralLayoutSettingsRef] layout_settings # @return [TimerComponentState] def state(timer, layout_settings) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end if layout_settings.handle.ptr == nil raise "layout_settings is disposed" end result = TimerComponentState.new(Native.TimerComponent_state(@handle.ptr, timer.handle.ptr, layout_settings.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Timer Component is a component that shows the total time of the current # attempt as a digital clock. The color of the time shown is based on a how # well the current attempt is doing compared to the chosen comparison. class TimerComponentRefMut < TimerComponentRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The Timer Component is a component that shows the total time of the current # attempt as a digital clock. The color of the time shown is based on a how # well the current attempt is doing compared to the chosen comparison. class TimerComponent < TimerComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.TimerComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = TimerComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Timer Component. # @return [TimerComponent] def self.create() result = TimerComponent.new(Native.TimerComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.TimerComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class TimerComponentStateRef attr_accessor :handle # The time shown by the component without the fractional part. # @return [String] def time() if @handle.ptr == nil raise "this is disposed" end result = Native.TimerComponentState_time(@handle.ptr) result end # The fractional part of the time shown (including the dot). # @return [String] def fraction() if @handle.ptr == nil raise "this is disposed" end result = Native.TimerComponentState_fraction(@handle.ptr) result end # The semantic coloring information the time carries. # @return [String] def semantic_color() if @handle.ptr == nil raise "this is disposed" end result = Native.TimerComponentState_semantic_color(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class TimerComponentStateRefMut < TimerComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class TimerComponentState < TimerComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.TimerComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = TimerComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A Timer Read Lock allows temporary read access to a timer. Dispose this to # release the read lock. class TimerReadLockRef attr_accessor :handle # Accesses the timer. # @return [TimerRef] def timer() if @handle.ptr == nil raise "this is disposed" end result = TimerRef.new(Native.TimerReadLock_timer(@handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Timer Read Lock allows temporary read access to a timer. Dispose this to # release the read lock. class TimerReadLockRefMut < TimerReadLockRef def initialize(ptr) @handle = LSCHandle.new ptr end end # A Timer Read Lock allows temporary read access to a timer. Dispose this to # release the read lock. class TimerReadLock < TimerReadLockRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.TimerReadLock_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = TimerReadLock.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # A Timer Write Lock allows temporary write access to a timer. Dispose this to # release the write lock. class TimerWriteLockRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # A Timer Write Lock allows temporary write access to a timer. Dispose this to # release the write lock. class TimerWriteLockRefMut < TimerWriteLockRef # Accesses the timer. # @return [TimerRefMut] def timer() if @handle.ptr == nil raise "this is disposed" end result = TimerRefMut.new(Native.TimerWriteLock_timer(@handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # A Timer Write Lock allows temporary write access to a timer. Dispose this to # release the write lock. class TimerWriteLock < TimerWriteLockRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.TimerWriteLock_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = TimerWriteLock.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Title Component is a component that shows the name of the game and the # category that is being run. Additionally, the game icon, the attempt count, # and the total number of successfully finished runs can be shown. class TitleComponentRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # The Title Component is a component that shows the name of the game and the # category that is being run. Additionally, the game icon, the attempt count, # and the total number of successfully finished runs can be shown. class TitleComponentRefMut < TitleComponentRef # Encodes the component's state information as JSON. # @param [TimerRef] timer # @return [String] def state_as_json(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = Native.TitleComponent_state_as_json(@handle.ptr, timer.handle.ptr) result end # Calculates the component's state based on the timer provided. # @param [TimerRef] timer # @return [TitleComponentState] def state(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = TitleComponentState.new(Native.TitleComponent_state(@handle.ptr, timer.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Title Component is a component that shows the name of the game and the # category that is being run. Additionally, the game icon, the attempt count, # and the total number of successfully finished runs can be shown. class TitleComponent < TitleComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.TitleComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = TitleComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Title Component. # @return [TitleComponent] def self.create() result = TitleComponent.new(Native.TitleComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.TitleComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class TitleComponentStateRef attr_accessor :handle # The game's icon encoded as a Data URL. This value is only specified whenever # the icon changes. If you explicitly want to query this value, remount the # component. The String itself may be empty. This indicates that there is no # icon. If no change occurred, nil is returned instead. # @return [String, nil] def icon_change() if @handle.ptr == nil raise "this is disposed" end result = Native.TitleComponentState_icon_change(@handle.ptr) result end # The first title line to show. This is either the game's name, or a # combination of the game's name and the category. # @return [String] def line1() if @handle.ptr == nil raise "this is disposed" end result = Native.TitleComponentState_line1(@handle.ptr) result end # By default the category name is shown on the second line. Based on the # settings, it can however instead be shown in a single line together with # the game name. In that case nil is returned instead. # @return [String, nil] def line2() if @handle.ptr == nil raise "this is disposed" end result = Native.TitleComponentState_line2(@handle.ptr) result end # Specifies whether the title should centered or aligned to the left # instead. # @return [Boolean] def is_centered() if @handle.ptr == nil raise "this is disposed" end result = Native.TitleComponentState_is_centered(@handle.ptr) result end # Returns whether the amount of successfully finished attempts is supposed to # be shown. # @return [Boolean] def shows_finished_runs() if @handle.ptr == nil raise "this is disposed" end result = Native.TitleComponentState_shows_finished_runs(@handle.ptr) result end # Returns the amount of successfully finished attempts. # @return [Integer] def finished_runs() if @handle.ptr == nil raise "this is disposed" end result = Native.TitleComponentState_finished_runs(@handle.ptr) result end # Returns whether the amount of total attempts is supposed to be shown. # @return [Boolean] def shows_attempts() if @handle.ptr == nil raise "this is disposed" end result = Native.TitleComponentState_shows_attempts(@handle.ptr) result end # Returns the amount of total attempts. # @return [Integer] def attempts() if @handle.ptr == nil raise "this is disposed" end result = Native.TitleComponentState_attempts(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class TitleComponentStateRefMut < TitleComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class TitleComponentState < TitleComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.TitleComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = TitleComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The Total Playtime Component is a component that shows the total amount of # time that the current category has been played for. class TotalPlaytimeComponentRef attr_accessor :handle def initialize(ptr) @handle = LSCHandle.new ptr end end # The Total Playtime Component is a component that shows the total amount of # time that the current category has been played for. class TotalPlaytimeComponentRefMut < TotalPlaytimeComponentRef # Encodes the component's state information as JSON. # @param [TimerRef] timer # @return [String] def state_as_json(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = Native.TotalPlaytimeComponent_state_as_json(@handle.ptr, timer.handle.ptr) result end # Calculates the component's state based on the timer provided. # @param [TimerRef] timer # @return [TotalPlaytimeComponentState] def state(timer) if @handle.ptr == nil raise "this is disposed" end if timer.handle.ptr == nil raise "timer is disposed" end result = TotalPlaytimeComponentState.new(Native.TotalPlaytimeComponent_state(@handle.ptr, timer.handle.ptr)) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The Total Playtime Component is a component that shows the total amount of # time that the current category has been played for. class TotalPlaytimeComponent < TotalPlaytimeComponentRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.TotalPlaytimeComponent_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = TotalPlaytimeComponent.finalize @handle finalizer.call end def with yield self self.dispose end # Creates a new Total Playtime Component. # @return [TotalPlaytimeComponent] def self.create() result = TotalPlaytimeComponent.new(Native.TotalPlaytimeComponent_new()) result end # Converts the component into a generic component suitable for using with a # layout. # @return [Component] def into_generic() if @handle.ptr == nil raise "this is disposed" end result = Component.new(Native.TotalPlaytimeComponent_into_generic(@handle.ptr)) @handle.ptr = nil result end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end # The state object describes the information to visualize for this component. class TotalPlaytimeComponentStateRef attr_accessor :handle # The label's text. # @return [String] def text() if @handle.ptr == nil raise "this is disposed" end result = Native.TotalPlaytimeComponentState_text(@handle.ptr) result end # The total playtime. # @return [String] def time() if @handle.ptr == nil raise "this is disposed" end result = Native.TotalPlaytimeComponentState_time(@handle.ptr) result end def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class TotalPlaytimeComponentStateRefMut < TotalPlaytimeComponentStateRef def initialize(ptr) @handle = LSCHandle.new ptr end end # The state object describes the information to visualize for this component. class TotalPlaytimeComponentState < TotalPlaytimeComponentStateRefMut def self.finalize(handle) proc { if handle.ptr != nil Native.TotalPlaytimeComponentState_drop handle.ptr handle.ptr = nil end } end def dispose finalizer = TotalPlaytimeComponentState.finalize @handle finalizer.call end def with yield self self.dispose end def initialize(ptr) handle = LSCHandle.new ptr @handle = handle ObjectSpace.define_finalizer(self, self.class.finalize(handle)) end end end