1 /*
2 * This file is part of Dune Legacy.
3 *
4 * Dune Legacy is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * Dune Legacy is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Dune Legacy. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <globals.h>
19
20 #include <CutScenes/Meanwhile.h>
21 #include <CutScenes/WSAVideoEvent.h>
22 #include <CutScenes/HoldPictureVideoEvent.h>
23 #include <CutScenes/FadeOutVideoEvent.h>
24 #include <CutScenes/FadeInVideoEvent.h>
25 #include <CutScenes/TextEvent.h>
26 #include <CutScenes/CutSceneMusicTrigger.h>
27
28 #include <FileClasses/FileManager.h>
29 #include <FileClasses/TextManager.h>
30 #include <FileClasses/Pakfile.h>
31 #include <FileClasses/Wsafile.h>
32 #include <FileClasses/IndexedTextFile.h>
33
34 #include <misc/exceptions.h>
35
36 #include <string>
37
Meanwhile(int house,bool firstMeanwhile)38 Meanwhile::Meanwhile(int house, bool firstMeanwhile) : CutScene() {
39
40 if(house != HOUSE_HARKONNEN && house != HOUSE_ATREIDES && house != HOUSE_ORDOS) {
41 THROW(std::invalid_argument, "Invalid house number %d!", house);
42 }
43
44 SDL_RWops* meanwhil_wsa = pFileManager->openFile("MEANWHIL.WSA");
45 pMeanwhile = new Wsafile(meanwhil_wsa);
46 SDL_RWclose(meanwhil_wsa);
47
48 SDL_RWops* efinala_wsa = pFileManager->openFile("EFINALA.WSA");
49 pImperator = new Wsafile(efinala_wsa);
50 SDL_RWclose(efinala_wsa);
51
52 SDL_RWops* dune_lng = pFileManager->openFile("DUNE." + _("LanguageFileExtension"));
53 IndexedTextFile* pDuneText = new IndexedTextFile(dune_lng);
54 SDL_RWclose(dune_lng);
55
56 int textBaseIndex = MeanwhileText_Base + ((house+2)%3) * MeanwhileText_NumTextsPerHouse;
57
58 if(pDuneText->getNumStrings() == 335) {
59 // Dune II 1.0 has 2 ranks less
60 textBaseIndex -= 2;
61 }
62
63 int houseOfVisitor = (house+2)%3;
64 Uint32 color = SDL2RGB(palette[houseToPaletteIndex[house]+1]);
65 Uint32 sardaukarColor = SDL2RGB(palette[PALCOLOR_SARDAUKAR+1]);
66 Uint32 visitorColor = SDL2RGB(palette[houseToPaletteIndex[houseOfVisitor]+1]);
67
68 if(firstMeanwhile == true) {
69 // Meanwhile after level 4
70 static const int meanwhileFrame[] = { 1, 2, 0};
71
72 startNewScene();
73
74 addVideoEvent(new HoldPictureVideoEvent(nullptr, 45, true));
75 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_At_the_Emperor_s_Palace),color,0,42,true,true,true));
76 addTrigger(new CutSceneMusicTrigger(0,MUSIC_MEANWHILE));
77
78 startNewScene();
79
80 addVideoEvent(new HoldPictureVideoEvent(pMeanwhile->getPicture(meanwhileFrame[house]), 75, true));
81 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_You_of_all_people),sardaukarColor,0,45,true,true,false));
82 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_Yes_your_excellency_I),visitorColor,45,30,true,false,false));
83
84 startNewScene();
85
86 addVideoEvent(new WSAVideoEvent(pImperator));
87 addVideoEvent(new HoldPictureVideoEvent(pImperator->getPicture(pImperator->getNumFrames()-1), 3, true));
88 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_You_let_the),sardaukarColor,3,100,false,false,false));
89
90 startNewScene();
91 addVideoEvent(new HoldPictureVideoEvent(pMeanwhile->getPicture(meanwhileFrame[house]), 75, true));
92 addVideoEvent(new FadeOutVideoEvent(pMeanwhile->getPicture(meanwhileFrame[house]), 20, true));
93 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_I_did_not_let),visitorColor,0,35,true,false,false));
94 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_I_will_not_allow),sardaukarColor,37,38,false,true,false));
95
96 } else {
97 // Meanwhile after level 8
98 static const int meanwhileFrame[] = { 3, 5, 4};
99
100 startNewScene();
101
102 addVideoEvent(new HoldPictureVideoEvent(nullptr, 45, true));
103 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_At_the_Emperor_s_Palace_on_Dune),color,0,42,true,true,true));
104 addTrigger(new CutSceneMusicTrigger(0,MUSIC_MEANWHILE));
105
106 if(house == HOUSE_ATREIDES) {
107 startNewScene();
108
109 addVideoEvent(new HoldPictureVideoEvent(pMeanwhile->getPicture(meanwhileFrame[house]), 130, true));
110 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_Fools),sardaukarColor,0,45,true,false,false));
111 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_And_still_you_fail),sardaukarColor,50,45,false,false,false));
112 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_But_excell),visitorColor,100,30,true,false,false));
113
114 startNewScene();
115
116 addVideoEvent(new WSAVideoEvent(pImperator));
117 addVideoEvent(new HoldPictureVideoEvent(pImperator->getPicture(pImperator->getNumFrames()-1), 3, true));
118 addVideoEvent(new FadeOutVideoEvent(pImperator->getPicture(pImperator->getNumFrames()-1), 20, true));
119 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_Enough_Together_we_must),sardaukarColor,3,42,false,true,false));
120 } else {
121 startNewScene();
122
123 addVideoEvent(new HoldPictureVideoEvent(pMeanwhile->getPicture(meanwhileFrame[house]), 80, true));
124 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_The_Ordos_were_not_supposed),sardaukarColor,0,45,true,true,false));
125 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_Your_highness),visitorColor,46,35,true,false,false));
126
127 startNewScene();
128
129 addVideoEvent(new WSAVideoEvent(pImperator));
130 addVideoEvent(new WSAVideoEvent(pImperator));
131 addVideoEvent(new FadeOutVideoEvent(pImperator->getPicture(pImperator->getNumFrames()-1), 20, true));
132
133 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_No_more_explanations),sardaukarColor,3, (house == HOUSE_ORDOS) ? 21 : 11,false,false,false));
134 addTextEvent(new TextEvent(pDuneText->getString(textBaseIndex+MeanwhileText_Only_together_will_we),sardaukarColor,(house == HOUSE_ORDOS) ? 28 : 18,(house == HOUSE_ORDOS) ? 39 : 49,false,true,false));
135 }
136 }
137
138 delete pDuneText;
139 }
140
~Meanwhile()141 Meanwhile::~Meanwhile() {
142 delete pMeanwhile;
143 delete pImperator;
144 }
145