//--------------------------------------/
//Bit distribution guide
//--------------------------------------/
//stack_state:
//[free 31:30][stack view offset 29:20][stack index max 19:10][stack select index 9:0]
//stack param:
//[free 31:30][main view offset 29:20][main folder index 19:10][main selected index 9:0]
//file_dir:
//[free 31:20][folder index 19:10][file index 9:0]
//file type:
//[hidden bit 31][link bit 30][script index 29:20][folder target 19:10][free 9:0]
//file color:
//[free 31:25][valid bit 24][red 23:16][green 15:8][blue 7:0]
//item properties:
//[type 31:25][subtype 24:15][cost 14:7][param1 6:0]

//--------------------------------------/
//local var names for switches
//--------------------------------------/
const string SW_ILR_ENABLE = "SW_ILR_ENABLE";

//--------------------------------------/
//OBJECT REFERENCES
//--------------------------------------/
//object to store all local variables
object FCB_HOST = GetObjectByTag("CS1_ITEMPROPHELP");
//object to perform temporary item swapping/caching
object FCB_INV = GetObjectByTag("CS1_ITEMPROPHELP");
//object to start conversation with
object FCB_CV = GetObjectByTag("CS1_ITEMPROPHELP");
//listener to pickup commands
object FCB_LIS = GetObjectByTag("CS1_ITEMPROPHELP");
//put an item on this object to customize it
object EXT_PLACEABLE = GetObjectByTag("pAnvilOfWonder");

//--------------------------------------/
//MISC CONSTANTS
//--------------------------------------/
//maximum item level calculated (no enchantment restriction based on level)
const int ITEM_LEVEL_MAX = 60;
//listening numbers
const int ITEM_CHARGE_CNT_MAX = 50;
//delay constant for displaying delayed message
const float INFO_MSG_DELAY = 0.1;
//modify item visual effect
const int MOD_VISUAL_EFFECT = VFX_IMP_LIGHTNING_S;
//max color intensity: 255
const int COLOR_VAL_MAX = 0xFF;
//color string
const string COLOR_STRING = "fcb_color_string";
const int COLOR_STRING_LEN = 17;
const string COLOR_TAG_END = "</c>";
//quote stored as local var
const string CMD_QUOTE = "cmd_txt_quote";
const int LISTEN_NUMBER_STANDARD = 100;
//main conversation file
const string CV_MAIN = "fcb_cv_main";

//--------------------------------------/
//script names
//--------------------------------------/
//local variable text
const string FCB_SCRIPT_PREFIX = "fcb_";
const string SCRIPT_MAIN_OPTION_HANDLER = "_main";

//--------------------------------------/
//LOCAL VAR NAMES
//--------------------------------------/
const string COLOR_STRING_CACHE_ = "COLOR_STRING_CACHE_";
//misc
const string USER = "FCB_USER";
const string SCRIPT_PARAM = "SCRIPT_PARAM";
const string SETNAME_SEL = "SETNAME_SEL";
const string CHARGE_SEL = "CHARGE_SEL";

const string IPRP_SEL_TXT = "IPRP_SEL_TXT";
const string IPRP_PARAM_SEL_0_1 = "IPRP_PARAM_SEL_0_1";
const string IPRP_PARAM_SEL_2_3 = "IPRP_PARAM_SEL_2_3";
const string IPRP_PARAM_INDEX = "IPRP_PARAM_INDEX";

const string ITEM_SEL_TXT = "ITEM_SEL_TXT";
const string ITEM_WORKING_SEL = "ITEM_WORKING_SEL";
const string ITEM_WORKING_SEL_BLANK = "ITEM_WORKING_SEL_BLANK";
const string ITEM_WORKING_SEL_MOD_COST = "ITEM_WORKING_SEL_MOD_COST";

const string ITEM_HEADER_TXT = "ITEM_HEADER_TXT";

const string FOLDER_INDEX_MAINMENU = "MAINMENU";
const string FOLDER_INDEX_IPRP = "IPRP";
const string FOLDER_INDEX_IPRPR = "IPRPR";
const string FOLDER_INDEX_SETNAME = "SETNAME";
const string FOLDER_INDEX_CHARGE = "CHARGE";

//--------------------------------------/
//local variable strings
const string UI_MAIN_LIST_LEN = "UI_MAIN_LIST_LEN";
const string UI_STACK_LIST_LEN = "UI_STACK_LIST_LEN";
//local variable strings
const string UI_DISP_TXT_ = "UI_DISP_TXT_";

//--------------------------------------/
//local variable text
const string MAIN_FOLDER_INDEX = "MAIN_FOLDER_INDEX";
const string MAIN_FOLDER_INDEX_LINK_ = "MAIN_FOLDER_INDEX_LINK_";
const string MAIN_FILE_INDEX_ = "MAIN_FILE_INDEX_";
const string MAIN_FILE_NAME_ = "MAIN_FILE_NAME_";
const string MAIN_FILE_TYPE_ = "MAIN_FILE_TYPE_";
const string MAIN_FILE_PARAM_ = "MAIN_FILE_PARAM_";
const string MAIN_FILE_INDEX_LINK_ = "MAIN_FILE_INDEX_LINK_";
const string MAIN_FILE_NAME_COLOR_ = "MAIN_FILE_NAME_COLOR_";
//local variable text
const string STACK_STATE = "STACK_STATE";
const string STACK_NAME_ = "STACK_NAME_";
const string STACK_PARAM_ = "STACK_PARAM_";
const string STACK_DISP_SEL_ = "STACK_DISP_SEL_";
//local variable text
const string DISP_STATE = "DISP_STATE";

//--------------------------------------/
//bit lengths/filters/related
//--------------------------------------/
//bit lengths
const int BITLEN_FILE_1 = 10;
const int BITLEN_FILE_2 = 20;

const int BITLEN_COLOR_1 = 8;
const int BITLEN_COLOR_2 = 16;

const int BITLEN_IPRP_TYPE = 7;
const int BITLEN_IPRP_SUB = 10;
const int BITLEN_IPRP_COST = 8;
const int BITLEN_IPRP_PARAM1 = 7;

const int BITLEN_2DA_RANGE = 16;

//--------------------------------------/
//filters
const int FILTER_IPRP_TYPE = 0x7F;
const int FILTER_IPRP_SUB = 0x3FF;
const int FILTER_IPRP_COST = 0xFF;
const int FILTER_IPRP_PARAM1 = 0x7F;

//bit to check/set for use color mode
const int INCR_D1000 = 0x1000000; //1000000000000000000000000
const int FILTER_D1 = 0xFF; //11111111
const int FILTER_D10 = 0xFF00; //1111111100000000
const int FILTER_D100 = 0xFF0000; //111111110000000000000000

//useful filters for filtering 10 bit chunks
const int FILTER_F1 = 0x3FF;                //                    1111111111
const int FILTER_F10 = 0xFFC00;             //          11111111110000000000
const int FILTER_F100 = 0x3FF00000;         //111111111100000000000000000000
const int FILTER_F11 = 0xFFFFF;             //          11111111111111111111
const int FILTER_F110 = 0x3FFFFC00;         //111111111111111111110000000000

const int FILTER_R1 = 0xFFFF;
const int FILTER_R10 = 0xFFFF0000;

//--------------------------------------/
//single bit filters/incrementers
//increments folders, etc
const int INCR_F10 = 0x400;     //10000000000
const int INCR_F100 = 0x100000; //100000000000000000000
//high indicates hidden file
const int INCR_HIDDEN = 0x80000000;         //10000000000000000000000000000000
//high indicates link to folder
const int INCR_LINK = 0x40000000;           // 1000000000000000000000000000000
const int INCR_INPUT_MODE = 0x40000000;

//--------------------------------------/
//default main option offset to set to when refreshing UI
const int UI_MAIN_DEFAULT_OFFSET = 1;
//default index selected when refreshing UI (0 = none)
const int UI_MAIN_DEFAULT_SEL = 0;
//default stack option offset to set to when refreshing UI
const int UI_STACK_DEFAULT_OFFSET = 1;
//default index selected when refreshing UI
const int UI_STACK_DEFAULT_SEL = 1;
//number of main options viewed at once
const int UI_MAIN_LIST_SIZE = 20;
//how much to scroll when using scroll up/down
const int UI_MAIN_SCROLL_INCR = 20;
//number of stack options viewed at once
const int UI_STACK_LIST_SIZE = 4;
//how much to scroll when using scroll up/down
const int UI_STACK_SCROLL_INCR = 1;

//--------------------------------------/
//custom token index start
const int UI_TOKEN_MAIN = 400;
const int UI_TOKEN_DISP = 300;

//--------------------------------------/
//folder indeces of significance pregenerated
const int MAIN_FOLDER_INDEX_MAINMENU = 0x400;
const int MAIN_FOLDER_INDEX_IPRP = 0x1000;
const int MAIN_FOLDER_INDEX_IPRPR = 0x1400;
const int MAIN_FOLDER_INDEX_SETNAME = 0x1800;
const int MAIN_FOLDER_INDEX_CHARGE = 0x2000;
const int MAIN_FOLDER_INDEX_DUPE = 0x2400;
const int MAIN_FOLDER_INDEX_COLORGUIDE = 0x2800;
//menu options folders
const int MAIN_FOLDER_INDEX_IPRP_MENU = 0x3400;
const int MAIN_FOLDER_INDEX_IPRPR_MENU = 0x3C00;
const int MAIN_FOLDER_INDEX_CHARGE_MENU = 0x4000;
//index of last pregenerated folder
const int MAIN_FOLDER_RESERVE_INDEX = 0x4000;

//--------------------------------------/
//file executed script indecies - arbitrary numbering
const int SCRIPT_INDEX_IPRP_SEL_0 = 0x300000;
const int SCRIPT_INDEX_IPRP_SEL_1 = 0x400000;

const int SCRIPT_INDEX_IPRPR_SEL_0 = 0x500000;
const int SCRIPT_INDEX_IPRPR_SEL_1 = 0x600000;

const int SCRIPT_INDEX_SETNAME_SEL_1 = 0xE00000;
const int SCRIPT_INDEX_SETNAME_DEFAULT = 0xF00000;

const int SCRIPT_INDEX_CHARGE_SEL_0 = 0x1300000;
const int SCRIPT_INDEX_CHARGE_SEL_1 = 0x1400000;

const int SCRIPT_INDEX_DUPE_SEL_0 = 0x1500000;
const int SCRIPT_INDEX_DUPE_SEL_1 = 0x1600000;

const int SCRIPT_INDEX_COLORGUIDE = 0x1700000;

//display mode toggeling
const int SCRIPT_INDEX_DISP_IPRP = 0x2000000;
const int SCRIPT_INDEX_DISP_HEADER = 0x2100000;
const int SCRIPT_INDEX_DISP_BLANK = 0x2300000;

const int SCRIPT_INDEX_LISTEN_SETNAME = 0x3000000;

//--------------------------------------/
//number of disp option that can be displayed at once
const int DISP_LIST_SIZE = 4;
//indexes for disp view options
//priority order....
const int DISP_INDEX_INFO = 1;
const int DISP_INDEX_HEADER = 2;
const int DISP_INDEX_IPRP = 3;
const int DISP_INDEX_LOCAL1 = 4;
//index position of last disp option
const int DISP_INDEX_POS = 4;

//--------------------------------------/
//UI text
const string UI_TXT_DOWN = "...scroll down...";
const string UI_TXT_UP = "...scroll up...";
const string UI_TXT_STACK_ROOT = "return to mainmenu";
const string UI_TXT_LINK_PREFIX = "";
//general stuff
const string UI_TXT_INDENT = "\n";
const string UI_TXT_INDENT2 = "\n\n";
const string UI_TXT_BRACKET_START = "[";
const string UI_TXT_BRACKET_END = "]";
const string UI_TXT_BRACKET2_START = "(";
const string UI_TXT_BRACKET2_END = ")";
const string UI_TXT_SPACE = " ";
const string UI_TXT_QUOTE = "'";
const string UI_TXT_COMMA = ",";
const string UI_TXT_UNDERSCORE = "_";
//gold unit
const string UI_TXT_UNIT_GP = " gp";
const string UI_TXT_UNIT_LV = "level ";
const string UI_TXT_UNIT_CHARGE = " charge(s)";
const string UI_TXT_UNIT_STACK = "x";

const string UI_TXT_LV0 = "level 0";
const string UI_TXT_LV1 = "level 1";
const string UI_TXT_LV2 = "level 2";
const string UI_TXT_LV3 = "level 3";
const string UI_TXT_LV4 = "level 4";
const string UI_TXT_LV5 = "level 5";
const string UI_TXT_LV6 = "level 6";
const string UI_TXT_LV7 = "level 7";
const string UI_TXT_LV8 = "level 8";
const string UI_TXT_LV9 = "level 9";

//--------------------------------------/
//menu ui texts
const string UI_TXT_EXT_INVALID = "Place a SINGLE item or a SINGLE STACK of items on the anvil and talk to me again."; //change the color in "fcb_cv"
const string UI_TXT_EXT_INFO = ""; //"Welcome to IGIPE 1.27 plugin for PGC3";    //welcome string here if any

const string UI_TXT_ITEM_WORKING_CURRENT = "Now working on:";
const string UI_TXT_IPRP_CURRENT = "Existing item properties:";
const string UI_TXT_IPRP_SEL = "Add property:";
const string UI_TXT_IPRPR_SEL = "Remove property:";
const string UI_TXT_SETNAME_NONE = "Now listening. Enter a new name for your item in the chat bar...";
const string UI_TXT_SETNAME_ENTERED = "Do you accept the following new name for this item?";
const string UI_TXT_CHARGE_SEL = "New item charge count:";
const string UI_TXT_COST = "Modification cost:";
const string UI_TXT_COST_OUTOFBOUND = "(you do not have enough gold for this modification)";
const string UI_TXT_LEVEL = "Resulting item level:";
const string UI_TXT_LEVEL_OUTOFBOUND = "(you are not high enough level to use this item)";
const string UI_TXT_DUPE_COST = "Cost to duplicate this item:";

const string UI_TXT_IPRP_ENTER = "Add properties to item";
const string UI_TXT_IPRPR_ENTER = "Remove properties from item";
const string UI_TXT_SETNAME_ENTER = "Change item name";
const string UI_TXT_CHARGE_ENTER = "Set item charge count";
const string UI_TXT_DUPE_ENTER = "Duplicate this item";
const string UI_TXT_COLORGUIDE_ENTER = "Guide to colored item names";

const string UI_TXT_IPRPR_MENU_REMOVE = "Remove selected property from item";
const string UI_TXT_IPRP_MENU_ADD_NORMAL = "Add selected property to item";
const string UI_TXT_SETNAME_MENU_ACCEPT = "Accept";
const string UI_TXT_SETNAME_MENU_REENTER = "Listen again for a new name";
const string UI_TXT_SETNAME_MENU_DEFAULT = "Restore item's original name";
const string UI_TXT_CHARGE_MENU_SET = "Accept";
const string UI_TXT_DUPE_MENU_ACCEPT = "Create duplicate in my inventory";

const string UI_TXT_HEADER_BASEITEM = "Base item: ";
const string UI_TXT_HEADER_CHARGE = "Charges: ";
const string UI_TXT_HEADER_COST = "GP value: ";

//--------------------------------------/
//parse stuff
const string CMD_TXT_BRACKET_START = "(";
const string CMD_TXT_BRACKET_END = ")";
const string CMD_TXT_SPACE = " ";
const string CMD_TXT_COMMA = ",";
const string CMD_TXT_CMDSTART = "%";
const string CMD_TXT_BLANK = "";

const int INPUT_PARSE_STATE_INIT = 0;
const int INPUT_PARSE_STATE_CMD = 1;

const int VAR_PARSE_STATE_INIT = 0;
const int VAR_PARSE_STATE_STRING = 1;
const int VAR_PARSE_STATE_FUNCTION = 2;
const int VAR_PARSE_STATE_NUM = 3;
const int VAR_PARSE_STATE_ERROR = 4;

const int CMD_PARSE_STATE_INIT = 0;
const int CMD_PARSE_STATE_ARG = 2;
const int CMD_PARSE_STATE_END = 3;
const int CMD_PARSE_STATE_ERROR = 4;

const string CMD_SCRIPT_PREFIX = "_";
const string CMD_FUNCTION_RESULT_ = "CMD_FUNCTION_RESULT_";
const string CMD_FUNCTION_RESP_VALID_ = "CMD_FUNCTION_VALID_";
const string CMD_EXE_INDEX = "CMD_EXE_INDEX";
const string CMD_EXE_REF_INDEX = "CMD_EXE_REF_INDEX";
const string CMD_ARGS_INDEX_ = "CMD_ARGS_INDEX_";
const string CMD_ARGS_ = "CMD_ARGS_";

const string CMD_ERROR_STRING = "#ERROR#";
const string CMD_ERROR_MSG = "#syntax error#";

const int CMD_VALID_BIT = 0x80000000; //10000000000000000000000000000000
const int CMD_NEG_BIT = 0x40000000;
