/* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT * file distributed with this source distribution. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see getLanguage() == Common::DE_DEU ? CREDITS_DEU : (g_engine->getLanguage() == Common::FR_FRA ? CREDITS_FRA : CREDITS_ENG)) void Room904::preload() { _G(player).walker_in_this_scene = false; } void Room904::init() { digi_preload("902music"); digi_preload("904pop1"); digi_preload("904pop2"); digi_preload("904pop3"); digi_preload("904pop4"); digi_preload("904pop5"); _G(kernel).suppress_fadeup = true; pal_fade_set_start(_G(master_palette), 0); pal_fade_init(_G(master_palette), 0, 255, 100, 60, 1); player_set_commands_allowed(false); } void Room904::shutdown() { if (_screen1) TextScrn_Destroy(_screen1); if (_screen2) TextScrn_Destroy(_screen2); _G(player).command_ready = true; } void Room904::daemon() { switch (_G(kernel).trigger) { case 1: player_set_commands_allowed(true); creditsSetup(); break; case 2: if (_currentSection < _numSections) { playRandomSound(2, 1); TextScrn_Add_TextItem(_screen1, 10, (_currentSection - 1) * _fontHeight + 10, _currentSection, TS_CENTRE, getCreditsSectionString(_currentSection), (M4CALLBACK)creditsCallback); TextScrn_Activate(_screen1); } break; case 3: playRandomSound(-1, 2); break; case 4: digi_play_loop("902music", 3, 155, -1); break; case 5: player_set_commands_allowed(false); pal_fade_init(_G(master_palette), 0, 255, 0, 30, 6); break; case 6: _G(game).setRoom(_G(executing) == WHOLE_GAME ? 903 : 901); break; default: break; } } void Room904::parser() { if (player_said("go back")) kernel_trigger_dispatch_now(5); } void Room904::creditsSetup() { _numSections = getCreditsSectionsCount(); gr_font_set(_G(font_inter)); _fontHeight = gr_font_get_height(); _totalWidth = getMaxCreditsHeaderWidth() + 20; _totalHeight = _fontHeight * _numSections + 20; _x1 = 30; _x2 = 30 + _totalWidth; _y1 = (480 - _totalHeight) / 2; _y2 = _y1 + _totalHeight; _screen1 = TextScrn_Create(_x1, _y1, _x2, _y2, 100, 422, 3, 22, 1, 10, 2, 14); for (_currentSection = 1; _currentSection <= _numSections; ++_currentSection) { TextScrn_Add_TextItem(_screen1, 10, (_currentSection - 1) * _fontHeight + 10, _currentSection, TS_CENTRE, getCreditsSectionString(_currentSection), (M4CALLBACK)creditsCallback); } TextScrn_Activate(_screen1); } size_t Room904::getCreditsSectionsCount() const { size_t numSections = 0; for (auto line = CREDITS; *line; ++line) { while (*line) ++line; ++numSections; } return numSections; } int Room904::getCreditsSectionLine(int sectionNum) const { if (sectionNum < 1 || sectionNum > _numSections) error_show(FL, 'Burg', "Bad index to credits"); int lineNum; for (lineNum = 0; sectionNum > 1; --sectionNum, ++lineNum) { while (CREDITS[lineNum]) ++lineNum; } return lineNum; } const char *Room904::getCreditsSectionString(int sectionNum) const { return CREDITS[getCreditsSectionLine(sectionNum)]; } int Room904::getCreditsSectionLines(int sectionNum) const { const int sectionStart = getCreditsSectionLine(sectionNum); int lineNum = sectionStart; while (CREDITS[lineNum]) ++lineNum; return lineNum - sectionStart; } size_t Room904::getMaxCreditsHeaderWidth() const { int32 maxWidth = 0; for (int sectionNum = 1; sectionNum <= _numSections; ++sectionNum) { maxWidth = MAX(maxWidth, gr_font_string_width(getCreditsSectionString(sectionNum))); } return maxWidth; } size_t Room904::getCreditsSectionWidth(int sectionNum) const { int32 maxWidth = 0; for (int lineNum = getCreditsSectionLine(sectionNum); CREDITS[lineNum]; ++lineNum) { maxWidth = MAX(maxWidth, gr_font_string_width(CREDITS[lineNum])); } return maxWidth; } const char *Room904::getLineInCreditsSection(int sectionNum, int lineNum) const { if (lineNum < 1 || lineNum > getCreditsSectionLines(sectionNum)) error_show(FL, 'Burg', "Bad index to names"); return CREDITS[getCreditsSectionLine(sectionNum) + lineNum]; } void Room904::creditsCallback(TextItem *textItem, TextScrn *textScrn) { Room904 *room = dynamic_cast(g_engine->_activeRoom); assert(room); room->updateCredits(textItem, textScrn); } void Room904::updateCredits(TextItem *textItem, TextScrn *textScrn) { const char *credit = textItem->prompt; const int sectionNum = textItem->tag; const int linesCount = getCreditsSectionLines(sectionNum); term_message("credit: %s index: %d names: %d", credit, sectionNum, linesCount); playRandomSound(-1, 2); if (strncmp(credit, "Haupt", 5) && strncmp(credit, "Back ", 5) && strncmp(credit, "Menu ", 5)) { mouse_set_sprite(kArrowCursor); gr_font_set(_G(font_conv)); _fontHeight = gr_font_get_height(); const int sectionWidth = getCreditsSectionWidth(sectionNum) + 20; const int sectionHeight = linesCount * _fontHeight + 20; const int x1 = (640 - _x2 - sectionWidth) / 2 + _x2; const int y1 = (480 - sectionHeight) / 2; const int x2 = x1 + sectionWidth; const int y2 = y1 + sectionHeight; if (_screen2) TextScrn_Destroy(_screen2); _screen2 = TextScrn_Create(x1, y1, x2, y2, 100, 422, 3, 22, 1, 10, 2, 14); for (int lineNum = 1; lineNum <= linesCount; ++lineNum) { const char *line = getLineInCreditsSection(sectionNum, lineNum); TextScrn_Add_Message(_screen2, 10, (lineNum - 1) * _fontHeight + 10, lineNum, TS_GIVEN, line); } TextScrn_Activate(_screen2); TextScrn_Activate(_screen1); } else { kernel_trigger_dispatch_now(5); } } void Room904::playRandomSound(int trigger, int channel) { const Common::String name = Common::String::format("904pop%d", g_engine->getRandomNumber(4) + 1); digi_play(name.c_str(), channel, 255, trigger); } } // namespace Rooms } // namespace Burger } // namespace M4