diff UI/UITransition.cpp @ 1298:b97d0cdd6c79

new folder UI
author Ritor1
date Wed, 19 Jun 2013 17:18:35 +0600
parents
children 8c2f689b5f0b
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UI/UITransition.cpp	Wed Jun 19 17:18:35 2013 +0600
@@ -0,0 +1,254 @@
+#ifdef _MSC_VER
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#include <assert.h>
+#include <io.h>
+
+#include "mm7_data.h"
+#include "VideoPlayer.h"
+#include "MapInfo.h"
+#include "GUIWindow.h"
+#include "GUIFont.h"
+#include "GUIProgressBar.h"
+#include "Party.h"
+#include "AudioPlayer.h"
+#include "Outdoor.h"
+#include "LOD.h"
+#include "Time.h"
+#include "stru159.h"
+#include "Events2D.h"
+#include "texts.h"
+#include "UIHouses.h"
+
+
+
+
+
+//----- (00444839) --------------------------------------------------------
+void TransitionUI_Load(uint anim_id, uint exit_pic_id, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName)
+{
+  //unsigned int v9; // ebx@1
+  //int v10; // edi@1
+  //signed int v11; // eax@1
+  unsigned int v12; // eax@6
+  const char *v13; // ST0C_4@6
+  unsigned int v14; // eax@8
+  const char *v15; // eax@14
+  unsigned int v16; // eax@16
+  //unsigned int result; // eax@26
+  const char *v18; // [sp-8h] [bp-40h]@9
+  //const char *v19; // [sp-4h] [bp-3Ch]@2
+  char *v20; // [sp-4h] [bp-3Ch]@9
+  const char *v21; // [sp-4h] [bp-3Ch]@11
+  char pContainer[40]; // [sp+Ch] [bp-2Ch]@1
+  unsigned int v23; // [sp+34h] [bp-4h]@1
+
+  //v9 = a1;
+  //v10 = a2;
+  v23 = IndoorLocation::GetLocationIndex(pLocationName);
+  dword_59117C_teleportx = x;
+  dword_591178_teleporty = y;
+  dword_591174_teleportz = z;
+  dword_591170_teleport_directiony = directiony;
+  dword_59116C_teleport_directionx = directionx;
+  dword_591168_teleport_speedz = a8;
+  dword_591164_teleport_map_name = (char *)pLocationName;
+  uCurrentHouse_Animation = anim_id;
+  pEventTimer->Pause();
+  pAudioPlayer->StopChannels(-1, -1);
+
+  switch (pParty->alignment)
+  {
+    case PartyAlignment_Good:    sprintfex(pContainer, "evt%02d-b", const_2()); break;
+    case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2());   break;
+    case PartyAlignment_Evil:    sprintfex(pContainer, "evt%02d-c", const_2()); break;
+    default: assert(false);
+  }
+
+  v12 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+  v13 = pHouse_ExitPictures[exit_pic_id];
+  pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v12];
+  pTexture_outside = pIcons_LOD->LoadTexturePtr(v13, TEXTURE_16BIT_PALETTE);
+  if (anim_id)
+  {
+    if ( !v23 )
+      //pVideoPlayer->OpenHouseMovie(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_0, 1u);
+      pVideoPlayer->OpenHouseMovie(pAnimatedRooms[p2DEvents[anim_id - 1].uAnimationID].video_name, 1);
+  }
+  else if ( !v23 )
+  {
+      v14 = pMapStats->GetMapInfo(pCurrentMapName.data());
+      if ( v14 )
+      {
+        sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v14].pName); // "Leave %s"
+        goto LABEL_20;
+      }
+      v21 = pGlobalTXT_LocalizationStrings[79];
+      goto LABEL_19;
+  }
+  v15 = pLocationName;
+  if ( *pLocationName == 48 )
+    v15 = pCurrentMapName.data();
+  v16 = pMapStats->GetMapInfo(v15);
+  if ( v16 )
+  {
+    sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[v16].pName);
+    goto LABEL_20;
+  }
+  v21 = pGlobalTXT_LocalizationStrings[73];
+LABEL_19:
+  strcpy(sHouseName.data(), v21);
+LABEL_20:
+  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, sHouseName.data());
+  //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) )
+  if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId )
+    PlayHouseSound(anim_id, HouseSound_Greeting);
+  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
+    pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
+  if ( v23 )
+    uCurrentHouse_Animation = v23;
+}
+
+
+
+
+//----- (00444C8F) --------------------------------------------------------
+void TravelUI_Load()
+{
+  //signed int v0; // eax@1
+  unsigned int v1; // eax@6
+  GUIWindow *result; // eax@9
+  //const char *v3; // [sp-4h] [bp-2Ch]@2
+  char pContainer[32]; // [sp+0h] [bp-28h]@1
+
+  pEventTimer->Pause();
+
+  switch (pParty->alignment)
+  {
+    case PartyAlignment_Good:    sprintfex(pContainer, "evt%02d-b", const_2()); break;
+    case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2());   break;
+    case PartyAlignment_Evil:    sprintfex(pContainer, "evt%02d-c", const_2()); break;
+    default: assert(false);
+  }
+
+  pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
+  pTexture_outside = pIcons_LOD->LoadTexturePtr("outside", TEXTURE_16BIT_PALETTE);
+  v1 = pMapStats->GetMapInfo(pCurrentMapName.data());
+  if ( v1 )
+    sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s"
+  else
+    strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]);// "Exit"
+  pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_ChangeLocation, 0, sHouseName.data());
+}
+
+
+
+//----- (00444DCA) --------------------------------------------------------
+void TravelUI_Draw()
+{
+  unsigned int v0; // edi@1
+  MapInfo *v1; // edi@2
+  signed int v3; // eax@2
+  int v4; // eax@5
+  const char *v5; // [sp-Ch] [bp-90h]@3
+  signed int v6; // [sp-8h] [bp-8Ch]@3
+  GUIWindow v7; // [sp+Ch] [bp-78h]@1
+  char pDestinationMapName[32]; // [sp+60h] [bp-24h]@1
+  unsigned int v9; // [sp+80h] [bp-4h]@1
+
+  memcpy(&v7, pPrimaryWindow, sizeof(v7));
+  v9 = pMapStats->GetMapInfo(pCurrentMapName.data());
+  pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20);
+  v0 = pMapStats->GetMapInfo(pDestinationMapName);
+  pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
+  pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]);
+  pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside);
+  pRenderer->DrawTextureIndexed(0x22Cu, 0x1C3u, pIcons_LOD->GetTexture(uTextureID_x_x_u));
+  pRenderer->DrawTextureIndexed(0x1DCu, 0x1C3u, pIcons_LOD->GetTexture(uTextureID_x_ok_u));
+  if ( v0 )
+  {
+    v1 = &pMapStats->pInfos[v0];
+    v7.uFrameX = 493;
+    v7.uFrameWidth = 126;
+    v7.uFrameZ = 366;
+    v7.DrawTitleText(pFontCreate, 0, 4u, 0, v1->pName, 3);
+    v7.uFrameX = 483;
+    v7.uFrameWidth = 148;
+    v7.uFrameZ = 334;
+    v3 = GetTravelTime();
+    if ( v3 == 1 )
+    {
+      v6 = 1;
+      v5 = pGlobalTXT_LocalizationStrings[663]; // "It will take %d day to cross to %s."
+    }
+    else
+    {
+      v6 = v3;
+      v5 = pGlobalTXT_LocalizationStrings[128]; // "It will take %d days to travel to %s."
+    }
+    sprintfex(pTmpBuf.data(), v5, v6, v1->pName);
+    strcat(pTmpBuf.data(), "\n \n");
+    sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[v9].pName);
+    strcat(pTmpBuf.data(), pTmpBuf2.data());
+    v4 = pFontCreate->CalcTextHeight(pTmpBuf.data(), &v7, 0, 0);
+    v7.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, pTmpBuf.data(), 3);
+    _unused_5B5924_is_travel_ui_drawn = 1;
+  }
+}
+
+
+
+//----- (00444A51) --------------------------------------------------------
+void TransitionUI_Draw()
+{
+  MapInfo *pMapInfo; // esi@5
+  char *v1; // eax@6
+  std::string v3; // [sp-18h] [bp-84h]@11
+  unsigned int v4; // [sp-10h] [bp-7Ch]@12
+  int v5; // [sp-Ch] [bp-78h]@12
+  const char *v6; // [sp-8h] [bp-74h]@11
+  signed int v7; // [sp-4h] [bp-70h]@11
+  GUIWindow v8; // [sp+Ch] [bp-60h]@1
+  unsigned int v9; // [sp+60h] [bp-Ch]@1
+  unsigned int v10; // [sp+64h] [bp-8h]@1
+  int a3; // [sp+6Bh] [bp-1h]@11
+
+  memcpy(&v8, pPrimaryWindow, sizeof(v8));
+  v10 = pMapStats->GetMapInfo(pCurrentMapName.data());
+  v9 = IndoorLocation::GetLocationIndex(dword_591164_teleport_map_name);
+  pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
+  pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, pIcons_LOD->GetTexture(uTextureID_50795C));
+  pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside);
+  uTextureID_right_panel_loop = uTextureID_right_panel;
+  pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel));
+  pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u));
+  pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u));
+  if ( (pVideoPlayer->AnyMovieLoaded() || v9) && *dword_591164_teleport_map_name != ' ' )
+    v10 = pMapStats->GetMapInfo(dword_591164_teleport_map_name);
+  pMapInfo = &pMapStats->pInfos[v10];
+  v8.uFrameX = 493;
+  v8.uFrameWidth = 126;
+  v8.uFrameZ = 366;
+  v8.DrawTitleText(pFontCreate, 0, 5u, 0, pMapInfo->pName, 3);
+  v8.uFrameX = 483;
+  v8.uFrameWidth = 148;
+  v8.uFrameZ = 334;
+
+  v1 = "";
+  if ( uCurrentHouse_Animation )
+  {
+    v1 = pTransitionStrings[uCurrentHouse_Animation];
+    v4 = (212 - pFontCreate->CalcTextHeight(v1, &v8, 0, 0)) / 2 + 101;
+    v8.DrawTitleText(pFontCreate, 0, v4, 0, v1, 3);
+  }
+  else if ( v10 )
+  {
+    sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[409], pMapInfo->pName);// "Do you wish to leave %s?"
+    v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf.data(), &v8, 0, 0)) / 2 + 101;
+    v8.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf.data(), 3);
+  }
+  else assert(false);
+
+  _unused_5B5924_is_travel_ui_drawn = true;
+}