# Profile Form Profile management system for {ref}`TScriptForm`. This module handles all account profile functionality including storage, validation, and UI dialogs. Credits: Developed by TazE Acknowledgements: Thanks to XJ for design concepts and initial prototyping - - - ## TProfileForm The account management system that handles profile storage, validation, and UI. - - - ## TProfileForm.GetProfilePath ```pascal function TProfileForm.GetProfilePath(index: Integer): String; ``` Constructs the file path for a profile based on its index. - - - ## TProfileForm.SaveProfileToFile ```pascal procedure TProfileForm.SaveProfileToFile(index: Integer; profile: TProfile); ``` Saves profile as a JSON file at the specified index. - - - ## TProfileForm.LoadProfileFromFile ```pascal function TProfileForm.LoadProfileFromFile(index: Integer): TProfile; ``` Loads a profile from disk at the specified index. Returns a default profile if the file doesn't exist or is invalid. - - - ## TProfileForm.GetExistingProfileIndices ```pascal function TProfileForm.GetExistingProfileIndices(): TIntegerArray; ``` Scans the accounts directory and returns a sorted array of all existing profile indices. - - - ## TProfileForm.ReindexProfiles ```pascal procedure TProfileForm.ReindexProfiles(fromIndex: Integer); ``` Renumbers profile files after a deletion to maintain sequential indexing. All profiles with indices greater than fromIndex are decremented by 1. - - - ## TProfileForm.ValidateProfile ```pascal function TProfileForm.ValidateProfile(profile: TProfile): Boolean; ``` Validates a profile has required fields filled. - - - ## TProfileForm.Setup ```pascal procedure TProfileForm.Setup(); ``` Sets up the account system and loads existing profiles from config. - - - ## TProfileForm.UpdateProfileCombo ```pascal procedure TProfileForm.UpdateProfileCombo(); ``` Updates the profile combo box with current profiles. - - - ## TProfileForm.AddProfile ```pascal function TProfileForm.AddProfile(profile: TProfile): Boolean; ``` Adds a new profile to the configuration after validation. - - - ## TProfileForm.UpdateProfile ```pascal function TProfileForm.UpdateProfile(index: Integer; profile: TProfile): Boolean; ``` Updates an existing profile at the specified index after validation. - - - ## TProfileForm.DeleteProfile ```pascal function TProfileForm.DeleteProfile(index: Integer): Boolean; ``` Deletes a profile at the specified index. - - - ## TProfileForm.GetSelectedProfile ```pascal function TProfileForm.GetSelectedProfile(): TProfile; ``` Returns the currently selected account profile. - - - ## TProfileForm.ValidateInput ```pascal function TProfileForm.ValidateInput(profile: TProfile): String; ``` Validates user input and returns error message if validation fails. - - - ## TProfileForm.BuildFilterSettings ```pascal function TProfileForm.BuildFilterSettings(): TSettings; ``` Builds a TSettings record from the current state of all filter UI controls. - - - ## TProfileForm.ApplyActivityFilters ```pascal procedure TProfileForm.ApplyActivityFilters(); ``` Filters the current world list based on selected specific activity checkboxes. - - - ## TProfileForm.GetLocationString ```pascal function TProfileForm.GetLocationString(loc: EWorldLocation): String; ``` Converts a world location enum to its display string. - - - ## TProfileForm.GetTypeString ```pascal function TProfileForm.GetTypeString(worldType: EWorldType): String; ``` Converts a world type enum to its display string. - - - ## TProfileForm.DisplayResults ```pascal procedure TProfileForm.DisplayResults(); ``` Formats and displays the filtered world list in the list box with columns for world number, location, type, activity, and player count. - - - ## TProfileForm.RefreshActivities ```pascal procedure TProfileForm.RefreshActivities(); ``` Dynamically creates checkboxes for all unique specific activities found in the currently filtered worlds. Removes previous activity checkboxes before creating new ones. - - - ## TProfileForm.OnSaveClick ```pascal procedure TProfileForm.OnSaveClick(sender: TLazObject); ``` Handles the Save button click event. Validates and saves the profile data from the edit form. - - - ## TProfileForm.OnDeleteClick ```pascal procedure TProfileForm.OnDeleteClick(sender: TLazObject); ``` Handles the Delete button click event. Shows confirmation dialog before deleting the profile. - - - ## TProfileForm.OnCloseClick ```pascal procedure TProfileForm.OnCloseClick(sender: TLazObject); ``` Handles the Close button click event. Closes the edit dialog without saving. - - - ## TProfileForm.OnGenerateClick ```pascal procedure TProfileForm.OnGenerateClick(sender: TLazObject); ``` Handles the Generate Worlds button click. Applies current filter settings and refreshes the world list. - - - ## TProfileForm.OnSelectAllActivitiesClick ```pascal procedure TProfileForm.OnSelectAllActivitiesClick(sender: TLazObject); ``` Handles the Select/Deselect All checkbox click. Toggles all activity checkboxes to match the master checkbox state. - - - ## TProfileForm.OnSortChange ```pascal procedure TProfileForm.OnSortChange(sender: TLazObject); ``` Handles sort order combo box change. Re-generates the world list with the new sort order. - - - ## TProfileForm.SetupWorldTypePanel ```pascal procedure TProfileForm.SetupWorldTypePanel(); ``` Sets up the world type filter panel with F2P and Members checkboxes. - - - ## TProfileForm.SetupLocationPanel ```pascal procedure TProfileForm.SetupLocationPanel(); ``` Sets up the location filter panel with checkboxes for Germany, UK, USA, and Australia. - - - ## TProfileForm.SetupActivityPanel ```pascal procedure TProfileForm.SetupActivityPanel(); ``` Sets up the activity type filter panel with checkboxes for Normal, Dangerous, Restricted, and Skill Total worlds. - - - ## TProfileForm.SetupSpecificActivityPanel ```pascal procedure TProfileForm.SetupSpecificActivityPanel(); ``` Sets up the specific activities panel with a master select/deselect all checkbox. Individual activity checkboxes are added dynamically by RefreshActivities. - - - ## TProfileForm.LoadWorldData ```pascal procedure TProfileForm.LoadWorldData(); ``` Fetches all available worlds from the world fetcher and caches them. Automatically generates the initial world list after fetching. - - - ## TProfileForm.LoadSavedWorlds ```pascal procedure TProfileForm.LoadSavedWorlds(worldsStr: String); ``` Loads saved world numbers and displays them. Unchecks filter checkboxes but keeps activity options visible. - - - ## TProfileForm.SetupEditDialog ```pascal procedure TProfileForm.SetupEditDialog(profile: TProfile; isNew: Boolean; editIndex: Integer); ``` Sets up the modal edit dialog for profile details. - - - ## TProfileForm.OnEditClick ```pascal procedure TProfileForm.OnEditClick(sender: TLazObject); ``` Handles the Edit button click event. Opens the profile edit dialog for the selected profile or creates a new one. - - - ## TProfileForm.SetupUI ```pascal procedure TProfileForm.SetupUI(combo: TLazComboBox; button: TLazButton); ``` Sets up the UI components provided by the parent form.