mirror of
https://github.com/libretro/devilutionX.git
synced 2026-11-10 17:20:56 -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`
75 lines
1.7 KiB
C++
75 lines
1.7 KiB
C++
#include "DiabloUI/button.h"
|
|
|
|
#include "DiabloUI/diabloui.h"
|
|
#include "engine/clx_sprite.hpp"
|
|
#include "engine/load_clx.hpp"
|
|
#include "engine/load_pcx.hpp"
|
|
#include "engine/render/clx_render.hpp"
|
|
#include "engine/render/text_render.hpp"
|
|
#include "utils/display.h"
|
|
|
|
namespace devilution {
|
|
|
|
namespace {
|
|
|
|
OptionalOwnedClxSpriteList ButtonSprites;
|
|
|
|
} // namespace
|
|
|
|
void LoadDialogButtonGraphics()
|
|
{
|
|
ButtonSprites = LoadOptionalClx("ui_art\\dvl_but_sml.clx");
|
|
if (!ButtonSprites) {
|
|
ButtonSprites = LoadPcxSpriteList("ui_art\\but_sml", 15);
|
|
}
|
|
}
|
|
|
|
void FreeDialogButtonGraphics()
|
|
{
|
|
ButtonSprites = std::nullopt;
|
|
}
|
|
|
|
ClxSprite ButtonSprite(bool pressed)
|
|
{
|
|
return (*ButtonSprites)[pressed ? 1 : 0];
|
|
}
|
|
|
|
void RenderButton(const UiButton &button)
|
|
{
|
|
const Surface &out = Surface(DiabloUiSurface()).subregion(button.m_rect.x, button.m_rect.y, button.m_rect.w, button.m_rect.h);
|
|
RenderClxSprite(out, ButtonSprite(button.IsPressed()), { 0, 0 });
|
|
|
|
Rectangle textRect { { 0, 0 }, { button.m_rect.w, button.m_rect.h } };
|
|
if (!button.IsPressed()) {
|
|
--textRect.position.y;
|
|
}
|
|
|
|
DrawString(out, button.GetText(), textRect, UiFlags::AlignCenter | UiFlags::FontSizeDialog | UiFlags::ColorDialogWhite);
|
|
}
|
|
|
|
bool HandleMouseEventButton(const SDL_Event &event, UiButton *button)
|
|
{
|
|
if (event.button.button != SDL_BUTTON_LEFT)
|
|
return false;
|
|
switch (event.type) {
|
|
case SDL_MOUSEBUTTONUP:
|
|
if (button->IsPressed()) {
|
|
button->Activate();
|
|
return true;
|
|
}
|
|
return false;
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
button->Press();
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
void HandleGlobalMouseUpButton(UiButton *button)
|
|
{
|
|
button->Release();
|
|
}
|
|
|
|
} // namespace devilution
|