def _on_submit(_dialog: CommonUiMultiPicker) -> bool: try: if not _dialog.accepted: self.log.debug('Dialog cancelled.') return on_submit(dict(), CommonChoiceOutcome.CANCEL) made_choices: bool = CommonDialogUtils.get_chosen_items(_dialog) if not made_choices: self.log.debug('No choices made. Cancelling dialog.') return on_submit(dict(), CommonChoiceOutcome.CANCEL) self.log.debug('Choices made, combining choices.') index = 0 dialog_choices: Dict[int, Tuple[Any]] = dict() for _sub_dialog_submit_id in _dialog._picker_dialogs: _sub_dialog_submit = _dialog._picker_dialogs[_sub_dialog_submit_id] sub_dialog_choices: List[Any] = list() for choice in CommonDialogUtils.get_chosen_items(_sub_dialog_submit): sub_dialog_choices.append(choice) dialog_choices[index] = tuple(sub_dialog_choices) index += 1 self.log.format_with_message('Choices were made, submitting.', choice=made_choices) result = on_submit(dialog_choices, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message('Finished handling choice.', result=result) return result except Exception as ex: self.log.error('Error occurred on submitting a value.', exception=ex) return False
def _on_item_chosen(dialog: UiObjectPicker): if not dialog.accepted: return on_item_chosen(None, CommonChooseItemResult.DIALOG_CANCELLED) chosen_item = CommonDialogUtils.get_chosen_item(dialog) return on_item_chosen(chosen_item, CommonChooseItemResult.ITEM_CHOSEN)
def _on_submit(dialog: UiDialogTextInput): input_value = CommonDialogUtils.get_input_value(dialog) if not input_value or not dialog.accepted: self.log.debug('Dialog cancelled.') return on_submit(None, CommonChoiceOutcome.CANCEL) self.log.format_with_message( 'Value entered, attempting to convert it to a float.', value=input_value) try: input_value = float(input_value) self.log.debug('Conversion successful.') input_value = max(self.min_value, input_value) input_value = min(self.max_value, input_value) except: self.log.format_with_message('Failed to convert value', value=input_value) return on_submit(None, CommonChoiceOutcome.ERROR) self.log.format_with_message('Value entered.', input_value=input_value) result = on_submit(input_value, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message('Finished handling input.', result=result) return result
def _on_submit(dialog: UiDialogTextInput) -> bool: try: input_text = CommonDialogUtils.get_input_value(dialog) if not input_text or not dialog.accepted: self.log.debug('Dialog cancelled.') return on_submit(None, CommonChoiceOutcome.CANCEL) self.log.format_with_message( 'Value entered, attempting to parse it.', value=input_text) input_text = str(input_text) if self.substitute_characters is not None: for (char, replacement) in self.substitute_characters.items(): input_text = input_text.replace(char, replacement) self.log.format_with_message('Value entered.', input_value=input_text) result = on_submit(input_text, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message('Finished handling input.', result=result) return result except Exception as ex: self.log.error('Error occurred on submitting a value.', exception=ex) return False
def _on_chosen(dialog: UiSimPicker): if not dialog.accepted: self.log.debug('Dialog cancelled.') return on_chosen(None, CommonChoiceOutcome.CANCEL) choices = tuple(CommonDialogUtils.get_chosen_items(dialog)) self.log.format_with_message('Choice made.', choice=choices) result = on_chosen(choices, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message('Finished handling choice.', result=result) return result
def _on_chosen(dialog: UiObjectPicker): self.log.debug('Choice made.') if not dialog.accepted: self.log.debug('Dialog cancelled.') return on_chosen(None, CommonChoiceOutcome.CANCEL) self.log.debug('Choice not made.') choice = CommonDialogUtils.get_chosen_item(dialog) self.log.format_with_message('Choose Object Choice made.', choice=pformat(choice)) result = on_chosen(choice, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message('Finished handling choose object _on_chosen.', result=result) return result
def _on_chosen(dialog: UiSimPicker) -> bool: try: if not dialog.accepted: self.log.debug('Dialog cancelled.') return on_chosen(None, CommonChoiceOutcome.CANCEL) choice = CommonDialogUtils.get_chosen_item(dialog) self.log.format_with_message('Choice made.', choice=choice) result = on_chosen(choice, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message('Finished handling choice.', result=result) return result except Exception as ex: self.log.error('Error occurred on choosing a value.', exception=ex) return False
def _on_chosen(dialog: UiOutfitPicker) -> None: try: self.log.format_with_message('Choice made.', picked_results=dialog.picked_results) if not dialog.accepted: self.log.debug('Dialog cancelled.') on_chosen(None, CommonChoiceOutcome.CANCEL) return self.log.format_with_message('Dialog accepted, checking if choices were made.') choice = CommonDialogUtils.get_chosen_item(dialog) self.log.format_with_message('Outfit choice made.', choice=choice) on_chosen(choice, CommonChoiceOutcome.CHOICE_MADE) self.log.debug('Finished handling outfit items _on_chosen.') return except Exception as ex: self.log.error('Error occurred on choosing a value.', exception=ex)
def _on_submit(dialog: UiDialogTextInput) -> None: try: input_value = CommonDialogUtils.get_input_value(dialog) if not input_value or not dialog.accepted: self.log.debug('Dialog cancelled.') on_submit(None, CommonChoiceOutcome.CANCEL) return self.log.format_with_message('Value entered.', input_value=input_value) result = on_submit(input_value, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message('Finished handling input.', result=result) except Exception as ex: self.log.error('Error occurred on submitting a value.', exception=ex)
def _on_chosen(dialog: UiObjectPicker) -> bool: try: if not dialog.accepted: self.log.debug('Dialog cancelled.') return on_chosen(tuple(), CommonChoiceOutcome.CANCEL) self.log.debug('Choices not made.') choices = CommonDialogUtils.get_chosen_items(dialog) self.log.format_with_message('Choose Object Choice made.', choice=pformat(choices)) result = on_chosen(choices, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message( 'Finished handling choose objects _build_dialog._on_chosen.', result=result) return result except Exception as ex: self.log.error('Error occurred on choosing a value.', exception=ex) return False
def _on_chosen(dialog: UiPurchasePicker) -> bool: try: self.log.format_with_message( 'Choice made.', picked_results=dialog.picked_results) if not dialog.accepted: self.log.debug('Dialog cancelled.') return on_chosen(None, CommonChoiceOutcome.CANCEL) self.log.debug( 'Dialog accepted, checking if choices were made.') choices = CommonDialogUtils.get_chosen_items(dialog) self.log.format_with_message('Purchase Objects choice made.', choice=choices) result = on_chosen(choices, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message( 'Finished handling purchase objects _on_chosen.', result=result) return result except Exception as ex: self.log.error('Error occurred on choosing a value.', exception=ex) return False
def _on_chosen(dialog: UiObjectPicker): if not dialog.accepted: log.debug('Dialog cancelled.') return on_chosen(None, CommonChoiceOutcome.CANCEL) choice = CommonDialogUtils.get_chosen_item(dialog) if choice == 'S4CL_NEXT': log.debug('Next chosen.') self.show(on_chosen=on_chosen, picker_type=picker_type, page=page + 1) return True elif choice == 'S4CL_PREVIOUS': log.debug('Previous chosen.') self.show(on_chosen=on_chosen, picker_type=picker_type, page=page - 1) return True log.format_with_message('Choice made.', choice=choice) result = on_chosen(choice, CommonChoiceOutcome.CHOICE_MADE) log.format_with_message('Finished handling choice.', result=result) return result