// Modified by Zunath #include "zzdlg_main_inc" #include "key_item_include" const string RESPONSE_PAGE = "keyitem_menu_responses"; const string PAGE_MAIN = "main_page"; const string PAGE_KEY_ITEMS_LIST = "keyitem_list"; // Prototypes void MainPageInit(); void MainPageSelect(); void KeyItemListInit(); void KeyItemListSelect(); void OnInit() { dlgChangeLabelNext("Next page"); dlgChangeLabelPrevious("Previous page"); dlgChangePage(PAGE_MAIN); dlgActivatePreservePageNumberOnSelection(); dlgActivateResetResponse(); } // Create the page void OnPageInit( string sPage ) { DeleteList( RESPONSE_PAGE, dlgGetSpeakingPC() ); if( sPage == PAGE_MAIN ) MainPageInit( ); else if(sPage == PAGE_KEY_ITEMS_LIST) KeyItemListInit(); dlgSetActiveResponseList( RESPONSE_PAGE ); } // Handles any selection. void OnSelection( string sPage ) { if ( sPage == PAGE_MAIN ) MainPageSelect( ); else if(sPage == PAGE_KEY_ITEMS_LIST) KeyItemListSelect(); } void OnReset( string sPage ) { dlgChangePage( PAGE_MAIN ); dlgResetPageNumber( ); } void OnAbort( string sPage ) { DeleteList( RESPONSE_PAGE, dlgGetSpeakingPC() ); // Remove temporary variables dlgClearPlayerDataInt("KEY_ITEM_MENU_CATEGORY_TEMP"); } void OnEnd( string sPage ) { DeleteList( RESPONSE_PAGE, dlgGetSpeakingPC() ); // Remove temporary variables dlgClearPlayerDataInt("KEY_ITEM_MENU_CATEGORY_TEMP"); } void OnContinue( string sPage, int iContinuePage ) { } // Message handler void main() { dlgOnMessage(); } // Specific scripting starts here // MAIN PAGE START void MainPageInit( ) { object oPC = dlgGetSpeakingPC(); dlgSetPrompt("Select a key item category."); dlgAddResponseAction(RESPONSE_PAGE, "Maps"); dlgAddResponseAction(RESPONSE_PAGE, "Quest Items"); dlgAddResponseAction(RESPONSE_PAGE, "Documents"); dlgAddResponseAction(RESPONSE_PAGE, "Main Menu", ColorTokenYellow()); dlgDeactivateResetResponse(); dlgActivateEndResponse( "End" ); } void MainPageSelect( ) { object oPC = dlgGetSpeakingPC(); // Return to main menu if(dlgIsSelectionEqualToName("Main Menu")) { dlgChangeDlgScript(oPC, "rest_menu"); } else { // Store the selected category and move to the key item list page dlgSetPlayerDataInt("KEY_ITEM_MENU_CATEGORY_TEMP", dlgGetSelectionIndex() + 1); dlgChangePage(PAGE_KEY_ITEMS_LIST); } } void KeyItemListInit() { object oPC = dlgGetSpeakingPC(); object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE); int iCategory = dlgGetPlayerDataInt("KEY_ITEM_MENU_CATEGORY_TEMP"); string sSQL = "SELECT ID, Name FROM " + KEYITEM_MYSQL_TABLE + " WHERE Category=" + IntToString(iCategory) + ";"; SQLExecDirect(sSQL); while(SQLFetch() == SQL_SUCCESS) { int iKeyItemID = StringToInt(SQLGetData(1)); // Display only if PC has the key item if(KEYITEM_GetKeyItem(oPC, iKeyItemID)) { dlgAddResponseAction(RESPONSE_PAGE, SQLGetData(2)); } } dlgActivateResetResponse("Back", ColorTokenBlue()); } void KeyItemListSelect() { object oPC = dlgGetSpeakingPC(); object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE); string sName = dlgGetSelectionName(); string sDescription = KEYITEM_GetDescription(-1, sName); // Display description dlgSetPrompt(sDescription); }