diff UiGame.cpp @ 1038:39f42990698f

Cleanings
author Nomad
date Thu, 23 May 2013 03:29:29 +0200
parents 3a5c8df8381d
children e23a79658fc5
line wrap: on
line diff
--- a/UiGame.cpp	Wed May 22 14:12:51 2013 +0200
+++ b/UiGame.cpp	Thu May 23 03:29:29 2013 +0200
@@ -70,6 +70,257 @@
 
 
 
+//----- (00421D00) --------------------------------------------------------
+void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID)
+{
+  //unsigned int v1; // esi@1
+  //int v2; // eax@2
+  //Player *v3; // ecx@2
+  //Player *v4; // ecx@5
+  unsigned int v5; // [sp-4h] [bp-10h]@21
+
+  //v1 = uPlayerID;
+  auto player = &pParty->pPlayers[uPlayerID - 1];
+  if (pParty->pPickedItem.uItemID)
+  {
+    //v3 = player;
+    if (auto slot = player->AddItem(-1, pParty->pPickedItem.uItemID))
+    {
+      memcpy(&player->pInventoryItems[slot-1], &pParty->pPickedItem, 0x24u);
+      viewparams->bRedrawGameUI = true;
+      pMouse->RemoveHoldingItem();
+      return;
+    }
+
+    if (!player->CanAct())
+    {
+      player = pPlayers[uActiveCharacter];
+    }
+    if(player->CanAct() || !pPlayers[uActiveCharacter]->CanAct())
+		player->PlaySound(SPEECH_NoRoom, 0);
+  }
+
+//LABEL_9:
+  if (pCurrentScreen == SCREEN_GAME)
+  {
+    viewparams->bRedrawGameUI = true;
+    if ( uActiveCharacter != uPlayerID )
+      //goto LABEL_27;
+    {
+      if ( pPlayers[uPlayerID]->uTimeToRecovery )
+        return;
+
+      uActiveCharacter = uPlayerID;
+      return;
+    }
+    v5 = 7;
+//LABEL_22:
+    pGUIWindow_CurrentMenu = CharacterUI_Initialize(v5);
+    return;
+  }
+  if ( pCurrentScreen == SCREEN_SPELL_BOOK )
+    return;
+  if ( pCurrentScreen == SCREEN_CHEST )
+  {
+//LABEL_23:
+    viewparams->bRedrawGameUI = true;
+    if ( uActiveCharacter == uPlayerID )
+    {
+      pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
+      pCurrentScreen = SCREEN_CHEST_INVENTORY;
+      //goto LABEL_28;
+      uActiveCharacter = uPlayerID;
+      return;
+    }
+//LABEL_27:
+    if ( pPlayers[uPlayerID]->uTimeToRecovery )
+      return;
+    //goto LABEL_28;
+    uActiveCharacter = uPlayerID;
+    return;
+  }
+  if ( pCurrentScreen != SCREEN_HOUSE )
+  {
+    if ( pCurrentScreen == SCREEN_E )
+    {
+//LABEL_28:
+      uActiveCharacter = uPlayerID;
+      return;
+    }
+    if ( pCurrentScreen != SCREEN_CHEST_INVENTORY )
+    {
+      viewparams->bRedrawGameUI = true;
+      uActiveCharacter = uPlayerID;
+      if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 102 )
+        FillAwardsData();
+      return;
+    }
+    //goto LABEL_23;
+    viewparams->bRedrawGameUI = true;
+    if ( uActiveCharacter == uPlayerID )
+    {
+      pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
+      pCurrentScreen = SCREEN_CHEST_INVENTORY;
+      //goto LABEL_28;
+      uActiveCharacter = uPlayerID;
+      return;
+    }
+//LABEL_27:
+    if ( pPlayers[uPlayerID]->uTimeToRecovery )
+      return;
+    //goto LABEL_28;
+    uActiveCharacter = uPlayerID;
+    return;
+  }
+  if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
+    return;
+  viewparams->bRedrawGameUI = true;
+  if ( uActiveCharacter != uPlayerID )
+    //goto LABEL_28;
+    uActiveCharacter = uPlayerID;
+    return;
+  if (dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD || dialog_menu_id == HOUSE_DIALOGUE_SHOP_6)
+  {
+    __debugbreak(); // fix indexing
+    pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
+    v5 = 14;
+    //goto LABEL_22;
+    pGUIWindow_CurrentMenu = CharacterUI_Initialize(v5);
+    return;
+  }
+}
+// 4E28F8: using guessed type int pCurrentScreen;
+// F8B19C: using guessed type int dword_F8B19C;
+
+//----- (00416B01) --------------------------------------------------------
+void GameUI_DrawNPCPopup(void *_this)//PopupWindowForBenefitAndJoinText
+{
+  int v1; // edi@2
+  int v2; // ecx@2
+  NPCData *v3; // eax@2
+  NPCData *v4; // esi@7
+  NPCData *v5; // eax@16
+  NPCData *v6; // esi@16
+  const CHAR *v7; // eax@18
+  unsigned int v8; // eax@25
+  unsigned int v9; // eax@25
+  const char *v10; // ST14_4@26
+  char *v11; // esi@26
+  const char *v12; // ST18_4@27
+  unsigned __int16 v13; // ax@28
+  char *v14; // eax@28
+  GUIWindow a1; // [sp+Ch] [bp-60h]@23
+  int a2; // [sp+60h] [bp-Ch]@16
+  void *v17; // [sp+64h] [bp-8h]@1
+  LPCSTR lpsz; // [sp+68h] [bp-4h]@6
+
+  v17 = _this;
+  if ( bNoNPCHiring != 1 )
+  {
+    v1 = 0;
+    v2 = 0;
+    v3 = pParty->pHirelings;
+    /*do
+    {
+      if ( v3->pName )
+        pTmpBuf[v1++] = v2;
+      ++v3;
+      ++v2;
+    }
+    while ( (signed int)v3 < (signed int)&pParty->pPickedItem );*/
+    for (int i = 0; i < 2; ++i)
+    {
+     if (pParty->pHirelings[i].pName)
+        pTmpBuf[v1++] = i;
+    }
+    lpsz = 0;
+    if ( (signed int)pNPCStats->uNumNewNPCs > 0 )
+    {
+      /*v4 = pNPCStats->pNewNPCData;
+      do
+      {
+        if ( v4->uFlags & 0x80
+          && (!pParty->pHirelings[0].pName || strcmp(v4->pName, pParty->pHirelings[0].pName))
+          && (!pParty->pHirelings[1].pName || strcmp(v4->pName, pParty->pHirelings[1].pName)) )
+          pTmpBuf[v1++] = (char)lpsz + 2;
+        ++lpsz;
+        ++v4;
+      }
+      while ( (signed int)lpsz < (signed int)pNPCStats->uNumNewNPCs );*/
+      for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i)
+      {
+        if (pNPCStats->pNewNPCData[i].Hired())
+        {
+          if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName))
+          {
+            if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName))
+              pTmpBuf[v1++] = i + 2;
+          }
+        }
+      }
+    }
+    if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 )
+    {
+      sDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17;
+      v5 = GetNewNPCData(sDialogue_SpeakingActorNPC_ID, (int)&a2);
+      v6 = v5;
+      if ( v5 )
+      {
+        if ( a2 == 57 )
+          v7 = pNPCTopics[512].pText; // Baby dragon
+        else
+          v7 = (const CHAR *)pNPCStats->pProfessions[v5->uProfession].pBenefits;
+        lpsz = v7;
+        if ( !v7 )
+        {
+          lpsz = (LPCSTR)pNPCStats->pProfessions[v5->uProfession].pJoinText;
+          if ( !lpsz )
+            lpsz = "";
+        }
+        a1.Hint = 0;
+        a1.uFrameX = 38;
+        a1.uFrameY = 60;
+        a1.uFrameWidth = 276;
+        a1.uFrameZ = 313;
+        a1.uFrameHeight = pFontArrus->CalcTextHeight(lpsz, &a1, 0, 0)
+                        + 2 * LOBYTE(pFontArrus->uFontHeight)
+                        + 24;
+        if ( (signed int)a1.uFrameHeight < 130 )
+          a1.uFrameHeight = 130;
+        a1.uFrameWidth = 400;
+        a1.uFrameZ = a1.uFrameX + 399;
+        a1.DrawMessageBox(0);
+        sprintfex(pTmpBuf2, "NPC%03d", v6->uPortraitID);
+        v8 = pIcons_LOD->LoadTexture(pTmpBuf2, TEXTURE_16BIT_PALETTE);
+        pRenderer->DrawTextureIndexed(
+          a1.uFrameX + 22,
+          a1.uFrameY + 36,
+          (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
+        v9 = v6->uProfession;
+        if ( v9 )
+        {
+          v10 = v6->pName;
+          v11 = pTmpBuf;
+          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]);
+        }
+        else
+        {
+          v12 = v6->pName;
+          v11 = pTmpBuf;
+          strcpy(pTmpBuf, v12);
+        }
+        v13 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+        a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u);
+        a1.uFrameWidth -= 24;
+        a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
+        v14 = BuilDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0);
+        a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0);
+      }
+    }
+  }
+}
+
+
 
 //----- (00445D4A) --------------------------------------------------------
 void GameUI_InitializeDialogue(Actor *actor, int bPlayerSaysHello)
@@ -559,19 +810,19 @@
   v2 = FitTextInAWindow(byte_5B0938, pFont, &v5, 0xCu, 0);
   pGUIWindow2->DrawText(pFont, 12, 354 - v1, 0, v2, 0, 0, 0);
   pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar);
-  if ( pGUIWindow2->field_40 != 1 )
+  if ( pGUIWindow2->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS)
   {
-    if ( pGUIWindow2->field_40 == 2 )
+    if ( pGUIWindow2->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED)
     {
-      pGUIWindow2->field_40 = 0;
+      pGUIWindow2->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
       strcpy(GameUI_Footer_TimedString, (const char *)pKeyActionMap->pPressedKeysBuffer);
 LABEL_16:
       sub_4452BB();
       return;
     }
-    if ( pGUIWindow2->field_40 != 3 )
+    if ( pGUIWindow2->receives_keyboard_input_2 != WINDOW_INPUT_CANCELLED)
       return;
-    pGUIWindow2->field_40 = 0;
+    pGUIWindow2->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
 LABEL_15:
     memset(GameUI_Footer_TimedString, 0, 0xC8u);
     goto LABEL_16;
@@ -586,7 +837,7 @@
   }
   if ( pKeyActionMap->pPressedKeysBuffer[0] )
   {
-    pKeyActionMap->_459ED1(0);
+    pKeyActionMap->SetWindowInputStatus(0);
     goto LABEL_15;
   }
 }