# HG changeset patch # User Nomad # Date 1361179795 -7200 # Node ID 0b58962bf2290904da59503e6bb602c64381bec0 # Parent ac44e716d0518ddf23e9e45c0167aa769cdff648 done with DrawDialogUI diff -r ac44e716d051 -r 0b58962bf229 mm7_3.cpp --- a/mm7_3.cpp Mon Feb 18 10:55:38 2013 +0200 +++ b/mm7_3.cpp Mon Feb 18 11:29:55 2013 +0200 @@ -15015,7 +15015,7 @@ //----- (00445308) -------------------------------------------------------- -const char *__fastcall sub_445308(int a1) +const char *GetProfessionActionText(int a1) { if ( a1 == 10 || a1 == 11 @@ -15028,7 +15028,7 @@ || a1 == 42 || a1 == 43 || a1 == 52 ) - return (const char *)*(&pNPCStats->field_13A60 + 5 * a1); + return pNPCStats->pProfessions[a1 - 1].pActionText; else return pNPCTopics[407].pTopic; } @@ -15051,11 +15051,11 @@ int v12; // esi@39 char *v13; // eax@41 GUIButton *v14; // eax@43 - GUIButton *v15; // edi@43 + //GUIButton *v15; // edi@43 signed int v16; // eax@44 - unsigned int v23; // eax@53 - const char *v24; // eax@59 - unsigned __int16 v30; // cx@83 + //unsigned int v23; // eax@53 + //const char *v24; // eax@59 + //unsigned __int16 v30; // cx@83 int v31; // ecx@86 int v32; // ebx@93 unsigned int v33; // eax@93 @@ -15079,8 +15079,8 @@ GUIWindow v51; // [sp+58h] [bp-BCh]@2 GUIWindow v52; // [sp+ACh] [bp-68h]@42 char *Str; // [sp+100h] [bp-14h]@104 - int v54; // [sp+104h] [bp-10h]@2 - unsigned __int16 *v55; // [sp+108h] [bp-Ch]@82 + //int v54; // [sp+104h] [bp-10h]@2 + //unsigned __int16 *v55; // [sp+108h] [bp-Ch]@82 GUIFont *pOutString; // [sp+10Ch] [bp-8h]@39 char *pInString=NULL; // [sp+110h] [bp-4h]@32 @@ -15091,7 +15091,7 @@ v1 = sub_445C8B(uDialogue_SpeakingActorNPC_ID); v51.uFrameWidth -= 10; v51.uFrameZ -= 10; - v54 = v1; + //v54 = v1; GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u); v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u); @@ -15154,7 +15154,7 @@ { pInString = (char *)ptr_F8B1E8; } - else if (v54 == 1) + else if (v1 == 1) { if (pNPC->greet) { @@ -15164,7 +15164,7 @@ pInString = pNPCStats->pNPCGreetings[pNPC->greet - 1].pGreeting1; } } - else if (v54 == 2) + else if (v1 == 2) { auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; @@ -15199,143 +15199,141 @@ v52.uFrameX = 483; v52.uFrameWidth = 148; v52.uFrameZ = 334; - for ( pOutString = (GUIFont *)v52.pStartingPosActiveItem; - (signed int)pOutString < v52.pStartingPosActiveItem + v52.pNumPresenceButton; - pOutString = (GUIFont *)((char *)pOutString + 1) ) - { - v14 = v52.GetControl((unsigned int)pOutString); - v15 = v14; + for (int i = v52.pStartingPosActiveItem; + i < v52.pStartingPosActiveItem + v52.pNumPresenceButton; ++i) + { + v14 = v52.GetControl(i); + //v15 = v14; if ( !v14 ) break; v16 = v14->uControlParam; if ( v16 > 88 ) - { - v24 = ""; - } - else if ( v16 == 88 ) - v24 = pGlobalTXT_LocalizationStrings[581]; // Lord - else if ( v16 == 87 ) - v24 = pGlobalTXT_LocalizationStrings[580]; // Knight - else if ( v16 == 86 ) - v24 = pGlobalTXT_LocalizationStrings[579]; // Squire - else if ( v16 == 85 ) - v24 = pGlobalTXT_LocalizationStrings[578]; // Page - else if ( v16 == 77 ) - v24 = pGlobalTXT_LocalizationStrings[407]; // Details - else if ( v16 == 76 ) - { - if (pNPC->Hired()) - { - sprintf(pTmpBuf, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s - v24 = pTmpBuf; - } - else - v24 = pGlobalTXT_LocalizationStrings[406]; // Hire - } - else if ( v16 == 24 ) - { - v23 = pNPC->evtf; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } - } - else if ( v16 == 9 ) - v24 = (const char *)sub_445308(pNPC->uProfession); - else if ( v16 == 19 ) + v14->pButtonName[0] = 0; + else if (v16 == 88) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[581]); // Lord + else if (v16 == 87) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[580]); // Knight + else if (v16 == 86) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[579]); // Squire + else if (v16 == 85) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[578]); // Page + else if (v16 == 77) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[407]); // Details + else if (v16 == 76) + { + if (pNPC->Hired()) + sprintf(v14->pButtonName, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s + else + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[406]); // Hire + } + else if (v16 == 24) + { + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->evtf - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else + strcpy(v14->pButtonName, topic); + } + else if (v16 == 9) + strcpy(v14->pButtonName, GetProfessionActionText(pNPC->uProfession)); + else if (v16 == 19) { - v23 = pNPC->bDrawSomeAnim; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->bDrawSomeAnim - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else strcpy(v14->pButtonName, topic); } - else if ( v16 == 20 ) + else if (v16 == 20) { - v23 = pNPC->_anim_current_time; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->_anim_current_time - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else strcpy(v14->pButtonName, topic); } - else if ( v16 == 21 ) + else if (v16 == 21) { - v23 = pNPC->_anim_end_time; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->_anim_end_time - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else strcpy(v14->pButtonName, topic); } - else if ( v16 == 22 ) + else if (v16 == 22) { - v23 = pNPC->evtd; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->evtd - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else strcpy(v14->pButtonName, topic); } - else if ( v16 == 23 ) + else if (v16 == 23) { - v23 = pNPC->evte; - v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; - if ( !v24 ) - { - v24 = ""; - v15->uControlParam = 0; - } + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->evte - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->uControlParam = 0; + } + else strcpy(v14->pButtonName, topic); } - else if ( v16 == 13 ) + else if (v16 == 13) { - if (pNPC->Hired()) - { - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s - v24 = pTmpBuf; - } - else - v24 = pGlobalTXT_LocalizationStrings[122]; // Join + if (pNPC->Hired()) + sprintf(v14->pButtonName, pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s + else + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[122]); // Join } else - v24 = ""; + v14->pButtonName[0] = 0; - if ( pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1 ) - { + if (pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1) + { + int num_dead_actors = 0; pInString = 0; - if ( (signed int)uNumActors > 0 ) - { - v55 = (unsigned short *)&pActors[0].uAIState; - v54 = uNumActors; - do - { - v30 = *v55; - if ( *v55 == Dead || v30 == Removed || v30 == Disabled || (v31 = *((int *)v55 + 159)) != 0 && (v31 & 7) == OBJECT_Player) - ++pInString; - v55 += 418; - --v54; - } - while ( v54 ); - } - if ( pInString == (char *)uNumActors ) - v24 = pGlobalTXT_LocalizationStrings[658]; - } - strcpy(v15->pButtonName, v24); - } + for (uint i = 0; i < uNumActors; ++i) + { + if (pActors[i].uAIState == Dead || pActors[i].uAIState == Removed || + pActors[i].uAIState == Disabled) + ++num_dead_actors; + else + { + int sumonner_type = pActors[i].uSummonerID & 7;; + if (sumonner_type == OBJECT_Player) + ++num_dead_actors; + } + } + if (num_dead_actors == uNumActors) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[658]); // Collect Prize + } + } + + v32 = 0; - pInString = (char *)GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); + //pInString = (char *)GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); v33 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u); v34 = pDialogueWindow; - v54 = v33; + //v54 = v33; v35 = pDialogueWindow->pStartingPosActiveItem; for ( i = v35 + pDialogueWindow->pNumPresenceButton; v35 < i; i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ) { @@ -15356,7 +15354,7 @@ pOutString = (GUIFont *)((174 - v32) / v39); if ( (174 - v32) / v39 > 32 ) pOutString = (GUIFont *)32; - v55 = (unsigned __int16 *)1; + int v55 = 1; v40 = 174 - (int)pOutString * v39 - v32; v41 = v34->pStartingPosActiveItem; v42 = v40 / 2 - (signed int)pOutString / 2 + 138; @@ -15371,22 +15369,22 @@ Str = v43->pButtonName; v44 = pFontArrus->CalcTextHeight(v43->pButtonName, &v52, 0, 0); v45 = v43->uY; - v46 = v55; + v46 = (unsigned short *)v55; v43->uHeight = v44; v42 = v45 + v44 - 1; v43->uW = v42; - v47 = (short)v54; + v47 = v33; if ( (unsigned __int16 *)pDialogueWindow->pCurrentPosActiveItem != v46 ) - v47 = (unsigned __int16)pInString; + v47 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); v52.DrawTitleText(pFontArrus, 0, v45, v47, Str, 3u); v34 = pDialogueWindow; - v55 = (unsigned __int16 *)((char *)v55 + 1); + ++v55; ++v41; } while ( (signed int)v41 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); } } - pRenderer->DrawTextureIndexed(471, 445, (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); + pRenderer->DrawTextureIndexed(471, 445, (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0)); } //----- (004459F9) -------------------------------------------------------- diff -r ac44e716d051 -r 0b58962bf229 mm7_data.h --- a/mm7_data.h Mon Feb 18 10:55:38 2013 +0200 +++ b/mm7_data.h Mon Feb 18 11:29:55 2013 +0200 @@ -2019,7 +2019,7 @@ void __cdecl DrawBranchlessDialogueUI(); void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4); void __cdecl sub_4452BB(); -const char *__fastcall sub_445308(int a1); +const char *GetProfessionActionText(int a1); void __cdecl DrawDialogueUI(); struct NPCData *__fastcall GetNPCData(unsigned int npcid); struct NPCData *__fastcall GetNewNPCData(signed int npcid, int a2);