mirror of
https://github.com/libretro/devilutionX.git
synced 2026-11-10 10:51:25 -10:00
https://github.com/diasurgical/devilutionx-mpq-tools produces an unpacked MPQ with all the graphics converted to CLX and the unused files removed. This is primarily useful on RAM-constrained platforms, such as PS2, because it eliminates the MPQ overhead. Adds a build option to load from such unpacked directories instead of the MPQ. These directories are searched for in the same locations where the MPQs would be searched for otherwise. Example directory layout: * /usr/local/share/diasurgical/devilutionx/diabdat/ -- unpacked and converted diabdat.mpq * /usr/local/share/diasurgical/devilutionx/hellfire/ -- unpacked and converted hellfire MPQs (all of them merged into 1 directory) * /usr/local/share/diasurgical/devilutionx/fonts/ -- unpacked fonts.mpq * /usr/local/share/diasurgical/devilutionx/pl/ -- unpacked pl.mpq These directory structure is produced by calling `unpack_and_minify_mpq`
118 lines
3.5 KiB
C++
118 lines
3.5 KiB
C++
|
|
#include "DiabloUI/diabloui.h"
|
|
#include "DiabloUI/selok.h"
|
|
#include "control.h"
|
|
#include "engine/load_clx.hpp"
|
|
#include "utils/language.h"
|
|
|
|
namespace devilution {
|
|
namespace {
|
|
int mainmenu_attract_time_out; // seconds
|
|
uint32_t dwAttractTicks;
|
|
|
|
std::vector<std::unique_ptr<UiItemBase>> vecMainMenuDialog;
|
|
std::vector<std::unique_ptr<UiListItem>> vecMenuItems;
|
|
|
|
_mainmenu_selections MainMenuResult;
|
|
|
|
void UiMainMenuSelect(int value)
|
|
{
|
|
MainMenuResult = (_mainmenu_selections)vecMenuItems[value]->m_value;
|
|
}
|
|
|
|
#ifndef NOEXIT
|
|
void MainmenuEsc()
|
|
{
|
|
std::size_t last = vecMenuItems.size() - 1;
|
|
if (SelectedItem == last) {
|
|
UiMainMenuSelect(last);
|
|
} else {
|
|
SelectedItem = last;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
void MainmenuLoad(const char *name)
|
|
{
|
|
vecMenuItems.push_back(std::make_unique<UiListItem>(_("Single Player"), MAINMENU_SINGLE_PLAYER));
|
|
vecMenuItems.push_back(std::make_unique<UiListItem>(_("Multi Player"), MAINMENU_MULTIPLAYER));
|
|
vecMenuItems.push_back(std::make_unique<UiListItem>(_("Settings"), MAINMENU_SETTINGS));
|
|
vecMenuItems.push_back(std::make_unique<UiListItem>(_("Support"), MAINMENU_SHOW_SUPPORT));
|
|
vecMenuItems.push_back(std::make_unique<UiListItem>(_("Show Credits"), MAINMENU_SHOW_CREDITS));
|
|
#ifndef NOEXIT
|
|
vecMenuItems.push_back(std::make_unique<UiListItem>(gbIsHellfire ? _("Exit Hellfire") : _("Exit Diablo"), MAINMENU_EXIT_DIABLO));
|
|
#endif
|
|
|
|
if (!gbIsSpawn || gbIsHellfire) {
|
|
if (gbIsHellfire)
|
|
ArtBackgroundWidescreen = LoadOptionalClx("ui_art\\mainmenuw.clx");
|
|
LoadBackgroundArt("ui_art\\mainmenu");
|
|
} else {
|
|
LoadBackgroundArt("ui_art\\swmmenu");
|
|
}
|
|
|
|
UiAddBackground(&vecMainMenuDialog);
|
|
UiAddLogo(&vecMainMenuDialog);
|
|
|
|
const Point uiPosition = GetUIRectangle().position;
|
|
|
|
if (gbIsSpawn && gbIsHellfire) {
|
|
SDL_Rect rect1 = { (Sint16)(uiPosition.x), (Sint16)(uiPosition.y + 145), 640, 30 };
|
|
vecMainMenuDialog.push_back(std::make_unique<UiArtText>(_("Shareware").data(), rect1, UiFlags::FontSize30 | UiFlags::ColorUiSilver | UiFlags::AlignCenter, 8));
|
|
}
|
|
|
|
vecMainMenuDialog.push_back(std::make_unique<UiList>(vecMenuItems, vecMenuItems.size(), uiPosition.x + 64, (uiPosition.y + 192), 510, 43, UiFlags::FontSize42 | UiFlags::ColorUiGold | UiFlags::AlignCenter, 5));
|
|
|
|
SDL_Rect rect2 = { 17, (Sint16)(gnScreenHeight - 36), 605, 21 };
|
|
vecMainMenuDialog.push_back(std::make_unique<UiArtText>(name, rect2, UiFlags::FontSize12 | UiFlags::ColorUiSilverDark));
|
|
|
|
#ifndef NOEXIT
|
|
UiInitList(nullptr, UiMainMenuSelect, MainmenuEsc, vecMainMenuDialog, true);
|
|
#else
|
|
UiInitList(nullptr, UiMainMenuSelect, nullptr, vecMainMenuDialog, true);
|
|
#endif
|
|
}
|
|
|
|
void MainmenuFree()
|
|
{
|
|
ArtBackgroundWidescreen = std::nullopt;
|
|
ArtBackground = std::nullopt;
|
|
|
|
vecMainMenuDialog.clear();
|
|
|
|
vecMenuItems.clear();
|
|
}
|
|
|
|
} // namespace
|
|
|
|
void mainmenu_restart_repintro()
|
|
{
|
|
dwAttractTicks = SDL_GetTicks() + mainmenu_attract_time_out * 1000;
|
|
}
|
|
|
|
bool UiMainMenuDialog(const char *name, _mainmenu_selections *pdwResult, int attractTimeOut)
|
|
{
|
|
MainMenuResult = MAINMENU_NONE;
|
|
while (MainMenuResult == MAINMENU_NONE) {
|
|
mainmenu_attract_time_out = attractTimeOut;
|
|
MainmenuLoad(name);
|
|
|
|
mainmenu_restart_repintro(); // for automatic starts
|
|
|
|
while (MainMenuResult == MAINMENU_NONE) {
|
|
UiClearScreen();
|
|
UiPollAndRender();
|
|
if (SDL_GetTicks() >= dwAttractTicks && (HaveDiabdat() || HaveHellfire())) {
|
|
MainMenuResult = MAINMENU_ATTRACT_MODE;
|
|
}
|
|
}
|
|
|
|
MainmenuFree();
|
|
}
|
|
|
|
*pdwResult = MainMenuResult;
|
|
return true;
|
|
}
|
|
|
|
} // namespace devilution
|