Profile Form

Profile management system for 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

function TProfileForm.GetProfilePath(index: Integer): String;

Constructs the file path for a profile based on its index.


TProfileForm.SaveProfileToFile

procedure TProfileForm.SaveProfileToFile(index: Integer; profile: TProfile);

Saves profile as a JSON file at the specified index.


TProfileForm.LoadProfileFromFile

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

function TProfileForm.GetExistingProfileIndices(): TIntegerArray;

Scans the accounts directory and returns a sorted array of all existing profile indices.


TProfileForm.ReindexProfiles

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

function TProfileForm.ValidateProfile(profile: TProfile): Boolean;

Validates a profile has required fields filled.


TProfileForm.Setup

procedure TProfileForm.Setup();

Sets up the account system and loads existing profiles from config.


TProfileForm.UpdateProfileCombo

procedure TProfileForm.UpdateProfileCombo();

Updates the profile combo box with current profiles.


TProfileForm.AddProfile

function TProfileForm.AddProfile(profile: TProfile): Boolean;

Adds a new profile to the configuration after validation.


TProfileForm.UpdateProfile

function TProfileForm.UpdateProfile(index: Integer; profile: TProfile): Boolean;

Updates an existing profile at the specified index after validation.


TProfileForm.DeleteProfile

function TProfileForm.DeleteProfile(index: Integer): Boolean;

Deletes a profile at the specified index.


TProfileForm.GetSelectedProfile

function TProfileForm.GetSelectedProfile(): TProfile;

Returns the currently selected account profile.


TProfileForm.ValidateInput

function TProfileForm.ValidateInput(profile: TProfile): String;

Validates user input and returns error message if validation fails.


TProfileForm.BuildFilterSettings

function TProfileForm.BuildFilterSettings(): TSettings;

Builds a TSettings record from the current state of all filter UI controls.


TProfileForm.ApplyActivityFilters

procedure TProfileForm.ApplyActivityFilters();

Filters the current world list based on selected specific activity checkboxes.


TProfileForm.GetLocationString

function TProfileForm.GetLocationString(loc: EWorldLocation): String;

Converts a world location enum to its display string.


TProfileForm.GetTypeString

function TProfileForm.GetTypeString(worldType: EWorldType): String;

Converts a world type enum to its display string.


TProfileForm.DisplayResults

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

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

procedure TProfileForm.OnSaveClick(sender: TLazObject);

Handles the Save button click event. Validates and saves the profile data from the edit form.


TProfileForm.OnDeleteClick

procedure TProfileForm.OnDeleteClick(sender: TLazObject);

Handles the Delete button click event. Shows confirmation dialog before deleting the profile.


TProfileForm.OnCloseClick

procedure TProfileForm.OnCloseClick(sender: TLazObject);

Handles the Close button click event. Closes the edit dialog without saving.


TProfileForm.OnGenerateClick

procedure TProfileForm.OnGenerateClick(sender: TLazObject);

Handles the Generate Worlds button click. Applies current filter settings and refreshes the world list.


TProfileForm.OnSelectAllActivitiesClick

procedure TProfileForm.OnSelectAllActivitiesClick(sender: TLazObject);

Handles the Select/Deselect All checkbox click. Toggles all activity checkboxes to match the master checkbox state.


TProfileForm.OnSortChange

procedure TProfileForm.OnSortChange(sender: TLazObject);

Handles sort order combo box change. Re-generates the world list with the new sort order.


TProfileForm.SetupWorldTypePanel

procedure TProfileForm.SetupWorldTypePanel();

Sets up the world type filter panel with F2P and Members checkboxes.


TProfileForm.SetupLocationPanel

procedure TProfileForm.SetupLocationPanel();

Sets up the location filter panel with checkboxes for Germany, UK, USA, and Australia.


TProfileForm.SetupActivityPanel

procedure TProfileForm.SetupActivityPanel();

Sets up the activity type filter panel with checkboxes for Normal, Dangerous, Restricted, and Skill Total worlds.


TProfileForm.SetupSpecificActivityPanel

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

procedure TProfileForm.LoadWorldData();

Fetches all available worlds from the world fetcher and caches them. Automatically generates the initial world list after fetching.


TProfileForm.LoadSavedWorlds

procedure TProfileForm.LoadSavedWorlds(worldsStr: String);

Loads saved world numbers and displays them. Unchecks filter checkboxes but keeps activity options visible.


TProfileForm.SetupEditDialog

procedure TProfileForm.SetupEditDialog(profile: TProfile; isNew: Boolean; editIndex: Integer);

Sets up the modal edit dialog for profile details.


TProfileForm.OnEditClick

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

procedure TProfileForm.SetupUI(combo: TLazComboBox; button: TLazButton);

Sets up the UI components provided by the parent form.