# ui_add_portraits function library

Dependencies: alter_effect, ds, lib_2da, lib_2daq, lib_anon, lib_array, lib_class, lib_cre, lib_data, lib_eff, lib_fn, lib_ids, lib_ietool, lib_ini, lib_kit, lib_script, lib_sfo, lib_spl, lib_splconv, lib_ssl, lib_struct, lib_sugar, lib_tools, lib_ui, lib_vtable, resolve_spell, ui_add_subraces, ui_bonus_spells, ui_deolvynize, ui_detect_class_kit, ui_dual_class_kits, ui_externalize_hlas, ui_externalize_proficiencies, ui_extra_spells, ui_on_open, ui_shared_code, ui_spell_system, ui_system_call, ui_virtual_class

## Description

This library contains a single function for adding new portraits into the game, including various forms of UI integration on EE games.

## Public functions

color_finder_tool()=() action

NOT FOR LIVE USE - alter the UI so that the CHARGEN color customization screen displays the numerical values of the chosen colors

ui_add_portraits(force_cd:i, portrait_path:s, portrait_table:s, disable:s, enable:s)=() action

Add some new portraits into the system, or modify existing ones (EE only)

The portraits should be listed in a 2DA table of form

| skin | hair | major | minor | race | sex | class | disabled
| EXAMPLE | INT | INT | INT | INT | human | f | fighter | no

(any of these columns can be missing, in which case defaults are assumed.) The function generates a master table of this form which lives in the 'shared' subdirectory of weidu_external (specifically, at weidu_external/data/shared/dw_portraits.2da)

- 'skin', 'hair', 'major' and 'minor' are the colors - as used by the UI - that should be assigned by default if the portrait is selected. (You can edit these
- 'race' can be any of human, halfelf, elf, dwarf, halfling, gnome, halforc, special (the default).
- 'class' can be fighter, wizard, cleric, thief, bard, barbarian, special (the default).
- 'sex' can be f, m, fm (the default).
- 'disabled' can be yes or no (the default).

The bmps themselves should be named as follows:

- EXAMPLEhires.bmp (for large high-resolution portraits) - copied to the L slot
- EXAMPLE330.bmp - also copied to the L slot
- EXAMPLEL.bmp - copied direct to the L slot
- EXAMPLE269.bmp - copied to the M slot
- EXAMPLEM.bmp - copied to the M slot

The function takes these variables:

- portrait_table: the full path to a new table, of the above form, to be added
- portrait_path: the path to the directory containing any new portrait BMPs listed in the table (or, if no table is given, containing any
- portrait BMPs just to be copied over directly - mostly applies to the core IWD/BG/BG2 portraits)
- disable: a list, separated by spaces, of portrait base names to disable from the system
- enable: a list, separated by spaces, of portrait base names to enable in the systems

On a non-EE install we default to CamDawg's cd_portrait_copy (which is assumed as a dependency); you can force this even on EE by setting INT_VAR force_cd=1.

## Internal functions

These should not be called from outside the library itself.

activate_portrait_coloring()=() action

add_to_portrait_tables_helper(warn_of_repeats:i, to_read:s, to_add_to:s)=() action

install_portraits(lua_loc:s="lua")=() action

read_portrait_data()=(portrait_skin:a, portrait_hair:a, portrait_major:a, portrait_minor:a, portrait_sex:a, portrait_race:a, portrait_class:a) action

sort_portrait_data(sex:s)=(sorted_array:a) action