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