changeset 1573:6d759814a817

BankDialog() cleaned
author Ritor1
date Sun, 08 Sep 2013 19:16:37 +0600
parents 19f1735fca80
children 2d9c8f609a3c 1264fce1a17f e6ac4919b22c 061f0e5a284d
files UI/UIHouses.cpp UI/UIHouses.h
diffstat 2 files changed, 113 insertions(+), 135 deletions(-) [+]
line wrap: on
line diff
--- a/UI/UIHouses.cpp	Sun Sep 08 17:07:58 2013 +0600
+++ b/UI/UIHouses.cpp	Sun Sep 08 19:16:37 2013 +0600
@@ -2367,141 +2367,116 @@
 //----- (004B7D7E) --------------------------------------------------------
 void  BankDialog()
 {
-  GUIWindow *v0; // eax@4
-  //int v1; // ecx@5
-  int v2; // eax@6
-  unsigned int v3; // esi@6
-  GUIFont *v4; // ST10_4@12
-  int v5; // eax@12
-  int v6; // eax@19
-  unsigned int v7; // esi@19
-  unsigned __int16 v8; // ax@27
-  unsigned __int16 v9; // ax@29
-  char *v10; // [sp-8h] [bp-70h]@11
-  char *v11; // [sp-4h] [bp-6Ch]@11
-  GUIWindow _this; // [sp+Ch] [bp-5Ch]@1
-  __int16 v13[2]; // [sp+60h] [bp-8h]@1
-  __int16 v14[2]; // [sp+64h] [bp-4h]@1
+  int entered_sum; // eax@19
+  unsigned int takes_sum; // esi@19
+  unsigned __int16 pColorText; // ax@27
+  GUIWindow bank_window; // [sp+Ch] [bp-5Ch]@1
 
-  memcpy(&_this, window_SpeakInHouse, sizeof(_this));
-  _this.uFrameX = 483;
-  _this.uFrameWidth = 148;
-  _this.uFrameZ = 334;
-  *(int *)v13 = TargetColor(0xFFu, 0xFFu, 0xFFu);
-  *(int *)v14 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
-  sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank);
-  _this.DrawTitleText(pFontArrus, 0, 0xDCu, v14[0], pTmpBuf.data(), 3u);
+  memcpy(&bank_window, window_SpeakInHouse, sizeof(bank_window));
+  bank_window.uFrameX = 483;
+  bank_window.uFrameWidth = 148;
+  bank_window.uFrameZ = 334;
+  sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank);//Баланс
+  bank_window.DrawTitleText(pFontArrus, 0, 220, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
   switch(dialog_menu_id)
   {
-	case HOUSE_DIALOGUE_MAIN:
-		{
-		v8 = v14[0];
-		if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
-			v8 = v13[0];
-		_this.DrawTitleText(pFontArrus, 0, 0x92u, v8, pGlobalTXT_LocalizationStrings[60], 3u);
-		v9 = v14[0];
-		if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
-			v9 = v13[0];
-		_this.DrawTitleText(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u);
-		break;
-		}
-	case HOUSE_DIALOGUE_BANK_7:
-		{
-		v0 = window_SpeakInHouse;
-		if ( window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS)
-		{
-			if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED)
-			{
-				v6 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-				v7 = v6;
-				if ( !v6 )
-				{
-					pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-					return;
-				}
-				if ( v6 > pParty->uNumGold )
-				{
-					PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
-					v7 = pParty->uNumGold;
-				}
-				if ( v7 )
-				{
-					Party::TakeGold(v7);
-					pParty->uNumGoldInBank += v7;
-					if ( uActiveCharacter )
-						pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
-				}
-				v0 = window_SpeakInHouse;
-				v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-				pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-				return;
-			}
-			if (window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_CANCELLED)
-				return;
-			v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-			return;      
-		}
-		v11 = pGlobalTXT_LocalizationStrings[112];
-		v10 = pGlobalTXT_LocalizationStrings[60];
-		sprintf(pTmpBuf.data(), "%s\n%s", v10, v11);
-		_this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf.data(), 3u);
-		_this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
-		v4 = pFontArrus;
-		v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
-		_this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4);
-		break;
-		}
-
-	case HOUSE_DIALOGUE_BANK_8:
-		{
-		v0 = window_SpeakInHouse;
-		if ( window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS)
-		{
-			if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED)
-			{
-				window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-				v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-				v3 = v2;
-				if ( v2 )
-				{
-					if ( v2 > pParty->uNumGoldInBank )
-					{
-						PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
-						v3 = pParty->uNumGoldInBank;
-					}
-					if ( v3 )
-					{
-						Party::SetGold(pParty->uNumGold + v3);
-						pParty->uNumGoldInBank -= v3;
-					}
-				}
-                v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-				pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-				return;
-			}
-			if ( window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_CANCELLED)
-				return;
-			v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
-			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-			return;  
-		}
-		v11 = pGlobalTXT_LocalizationStrings[112];
-		v10 = pGlobalTXT_LocalizationStrings[244];
-		sprintfex(pTmpBuf.data(), "%s\n%s", v10, v11);
-		_this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf.data(), 3u);
-		_this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
-		v4 = pFontArrus;
-		v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
-		_this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4);
-		return;
-		break;
-		}
-
-	default:
-		{
-		break;
-		}
+    case HOUSE_DIALOGUE_MAIN:
+    {
+      pColorText = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+      if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
+        pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+      bank_window.DrawTitleText(pFontArrus, 0, 146, pColorText, pGlobalTXT_LocalizationStrings[60], 3);
+      pColorText = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+      if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
+        pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+      bank_window.DrawTitleText(pFontArrus, 0, 176, pColorText, pGlobalTXT_LocalizationStrings[244], 3);
+      break;
+    }
+    case HOUSE_DIALOGUE_BANK_PUT_GOLD:
+    {
+      if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
+      {
+        sprintf(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[60], pGlobalTXT_LocalizationStrings[112]);//"Положить" "Сколько?"
+        bank_window.DrawTitleText(pFontArrus, 0, 146, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+        bank_window.DrawTitleText(pFontArrus, 0, 186, TargetColor(0xFFu, 0xFFu, 0xFFu), (const char *)pKeyActionMap->pPressedKeysBuffer, 3);
+        bank_window.DrawFlashingInputCursor(pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer) / 2 + 80, 185, pFontArrus);
+        return;
+      }
+      if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED)
+      {
+        entered_sum = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+        takes_sum = entered_sum;
+        if ( !entered_sum )
+        {
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+          return;
+        }
+        if ( entered_sum > pParty->uNumGold )
+        {
+          PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
+          takes_sum = pParty->uNumGold;
+        }
+        if ( takes_sum )
+        {
+          Party::TakeGold(takes_sum);
+          pParty->uNumGoldInBank += takes_sum;
+          if ( uActiveCharacter )
+            pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
+        }
+        window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        return;
+      }
+      if (window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED)
+      {
+        window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      }
+      return;
+    }
+    case HOUSE_DIALOGUE_BANK_GET_GOLD:
+    {
+      if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
+      {
+        sprintfex(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[244], pGlobalTXT_LocalizationStrings[112]);//"Снять" "Сколько?"
+        bank_window.DrawTitleText(pFontArrus, 0, 146, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3);
+        bank_window.DrawTitleText(pFontArrus, 0, 186, TargetColor(0xFFu, 0xFFu, 0xFFu), (const char *)pKeyActionMap->pPressedKeysBuffer, 3);
+        bank_window.DrawFlashingInputCursor(pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer) / 2 + 80, 185, pFontArrus);
+        return;
+      }
+      if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED)
+      {
+        window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
+        entered_sum = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+        takes_sum = entered_sum;
+        if ( entered_sum )
+        {
+          if ( entered_sum > pParty->uNumGoldInBank )
+          {
+            PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
+            takes_sum = pParty->uNumGoldInBank;
+          }
+          if ( takes_sum )
+          {
+            Party::SetGold(pParty->uNumGold + takes_sum);
+            pParty->uNumGoldInBank -= takes_sum;
+          }
+        }
+        window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        return;
+      }
+      if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED)
+      {
+        window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE;
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+      }
+      return;
+    }
+    default:
+    {
+      break;
+    }
   }
 }
 // F8B19C: using guessed type int dword_F8B19C;
@@ -4087,7 +4062,10 @@
           goto LABEL_49;
         }
         if ( v28 != 10 )
-          goto LABEL_41;
+        {
+          v15 = "";
+          goto LABEL_49;
+        }
       }
       else
       {
--- a/UI/UIHouses.h	Sun Sep 08 17:07:58 2013 +0600
+++ b/UI/UIHouses.h	Sun Sep 08 19:16:37 2013 +0600
@@ -10,8 +10,8 @@
   HOUSE_DIALOGUE_SHOP_IDENTIFY = 4,
   HOUSE_DIALOGUE_SHOP_REPAIR = 5,
   HOUSE_DIALOGUE_SHOP_6 = 6,
-  HOUSE_DIALOGUE_BANK_7 = 7,
-  HOUSE_DIALOGUE_BANK_8 = 8,
+  HOUSE_DIALOGUE_BANK_PUT_GOLD = 7,
+  HOUSE_DIALOGUE_BANK_GET_GOLD = 8,
   HOUSE_DIALOGUE_9 = 9,
   HOUSE_DIALOGUE_TEMPLE_HEAL = 10,
   HOUSE_DIALOGUE_TEMPLE_DONATE = 11,