2020-04-09 08:04:21 +02:00
|
|
|
//
|
|
|
|
// XCinema.cpp
|
|
|
|
// Clover
|
|
|
|
//
|
|
|
|
// Created by Sergey Isakov on 09/04/2020.
|
|
|
|
// Copyright © 2020 Slice. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2020-04-13 21:01:40 +02:00
|
|
|
|
|
|
|
#include "libegint.h"
|
2020-04-09 08:04:21 +02:00
|
|
|
#include "XCinema.h"
|
2021-02-06 18:16:46 +01:00
|
|
|
//#include "../gui/REFIT_MENU_SCREEN.h"
|
|
|
|
#include "../libeg/XTheme.h"
|
|
|
|
#include "../refit/lib.h"
|
2020-04-13 21:01:40 +02:00
|
|
|
|
2020-04-15 11:13:51 +02:00
|
|
|
#ifndef DEBUG_ALL
|
2020-04-15 18:30:39 +02:00
|
|
|
#define DEBUG_CINEMA 0
|
2020-04-15 11:13:51 +02:00
|
|
|
#else
|
|
|
|
#define DEBUG_CINEMA DEBUG_ALL
|
|
|
|
#endif
|
|
|
|
|
2020-04-15 21:18:53 +02:00
|
|
|
#if DEBUG_CINEMA == 0
|
2020-04-15 11:13:51 +02:00
|
|
|
#define DBG(...)
|
|
|
|
#else
|
|
|
|
#define DBG(...) DebugLog(DEBUG_CINEMA, __VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2020-04-13 21:01:40 +02:00
|
|
|
FILM* XCinema::GetFilm(INTN Id)
|
|
|
|
{
|
2020-04-15 18:30:39 +02:00
|
|
|
// DBG("ask film %lld from total of %lld\n", Id, Cinema.size());
|
2020-04-13 21:01:40 +02:00
|
|
|
for (size_t i = 0; i < Cinema.size(); ++i) {
|
2020-04-15 18:30:39 +02:00
|
|
|
// DBG("check film# %lld\n", Cinema[i].GetIndex());
|
2020-04-14 21:37:44 +02:00
|
|
|
if (Cinema[i].GetIndex() == Id) {
|
2020-04-15 18:30:39 +02:00
|
|
|
// DBG(" found ID\n");
|
2020-04-13 21:01:40 +02:00
|
|
|
return &Cinema[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-04-09 15:04:12 +02:00
|
|
|
|
2020-04-14 18:52:13 +02:00
|
|
|
void XCinema::AddFilm(FILM* NewFilm)
|
|
|
|
{
|
|
|
|
Cinema.AddReference(NewFilm, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static XImage NullImage;
|
|
|
|
const XImage& FILM::GetImage(INTN Index) const
|
2020-04-09 15:04:12 +02:00
|
|
|
{
|
2020-05-10 11:41:34 +02:00
|
|
|
DBG("ask for frame #%lld from total of %zu\n", Index, Frames.size());
|
2020-04-13 21:01:40 +02:00
|
|
|
for (size_t i = 0; i < Frames.size(); ++i) {
|
2020-04-14 21:37:44 +02:00
|
|
|
if (Frames[i].getIndex() == Index) {
|
2020-04-15 11:13:51 +02:00
|
|
|
DBG("...found\n");
|
2020-04-14 18:52:13 +02:00
|
|
|
return Frames[i].getImage();
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 18:30:39 +02:00
|
|
|
DBG("...not found\n");
|
2020-04-14 18:52:13 +02:00
|
|
|
return NullImage;
|
|
|
|
}
|
|
|
|
|
2021-09-28 15:54:31 +02:00
|
|
|
const XImage& FILM::GetImage(XBool *free) const
|
2020-04-14 18:52:13 +02:00
|
|
|
{
|
2020-05-25 05:22:00 +02:00
|
|
|
/*
|
|
|
|
* for SVG anime we have to generate new XImage using CurrentFrame as an argument
|
|
|
|
product(IconToAnime.ImageSVG, CurrentFrame, method); -- ImageSVG will be changed?
|
|
|
|
or
|
|
|
|
XImage *frame = IconToAnime.GetBest(!Daylight, free, CurrentFrame, method);
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
*
|
|
|
|
*/
|
2020-04-14 18:52:13 +02:00
|
|
|
for (size_t i = 0; i < Frames.size(); ++i) {
|
2020-04-14 21:37:44 +02:00
|
|
|
if (Frames[i].getIndex() == CurrentFrame) {
|
2020-05-25 05:22:00 +02:00
|
|
|
if (free) *free = false;
|
2020-04-14 18:52:13 +02:00
|
|
|
return Frames[i].getImage();
|
|
|
|
}
|
|
|
|
}
|
2020-05-25 05:22:00 +02:00
|
|
|
if (free) *free = false;
|
2020-04-14 18:52:13 +02:00
|
|
|
return NullImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FILM::AddFrame(XImage* Frame, INTN Index)
|
|
|
|
{
|
|
|
|
IndexedImage* NewFrame = new IndexedImage(Index);
|
|
|
|
NewFrame->setImage(*Frame);
|
|
|
|
Frames.AddReference(NewFrame, true);
|
2020-04-15 18:30:39 +02:00
|
|
|
DBG("index=%lld last=%lld\n", Index, LastIndex);
|
2020-04-14 18:52:13 +02:00
|
|
|
if (Index > LastIndex) {
|
|
|
|
LastIndex = Index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-08 14:35:22 +01:00
|
|
|
// 2023-11 : this is currently never called when theme is svg
|
2020-04-14 21:37:44 +02:00
|
|
|
void FILM::GetFrames(XTheme& TheTheme /*, const XStringW& Path*/) // Path already exist as a member. Is it the same ?
|
2020-04-14 18:52:13 +02:00
|
|
|
{
|
2020-10-03 19:02:31 +02:00
|
|
|
const EFI_FILE *ThemeDir = &TheTheme.getThemeDir();
|
2020-04-14 18:52:13 +02:00
|
|
|
EFI_STATUS Status;
|
2020-04-15 18:30:39 +02:00
|
|
|
LastIndex = 0;
|
2020-04-14 18:52:13 +02:00
|
|
|
for (INTN Index = 0; Index < NumFrames; Index++) {
|
|
|
|
XImage NewImage;
|
|
|
|
Status = EFI_NOT_FOUND;
|
2023-11-08 14:35:22 +01:00
|
|
|
XStringW Name = SWPrintf("%ls\\%ls_%03lld.png", Path.wc_str(), Path.wc_str(), Index);
|
|
|
|
// DBG("try to load %ls\n", Name.wc_str()); //fine
|
|
|
|
if (FileExists(ThemeDir, Name)) {
|
|
|
|
Status = NewImage.LoadXImage(ThemeDir, Name);
|
|
|
|
}
|
2020-08-25 17:35:19 +02:00
|
|
|
// DBG(" read status=%s\n", efiStrError(Status));
|
2023-11-08 14:35:22 +01:00
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
AddFrame(&NewImage, Index);
|
2020-04-14 18:52:13 +02:00
|
|
|
}
|
2023-11-08 14:35:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2023-11 : this is currently never called
|
|
|
|
// This should be 2 implementations of the same method in 2 different subclass, I think.
|
|
|
|
void FILM::GetFramesSVG(NSVGparser* SVGParser, XTheme& TheTheme /*, const XStringW& Path*/) // Path already exist as a member. Is it the same ?
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LastIndex = 0;
|
|
|
|
for (INTN Index = 0; Index < NumFrames; Index++) {
|
|
|
|
XImage NewImage;
|
|
|
|
Status = TheTheme.LoadSvgFrame(SVGParser, Index, &NewImage);
|
2020-04-14 18:52:13 +02:00
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
AddFrame(&NewImage, Index);
|
2020-04-13 21:01:40 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-09 15:04:12 +02:00
|
|
|
}
|
2021-02-06 18:16:46 +01:00
|
|
|
|
|
|
|
|
2023-11-08 14:35:22 +01:00
|
|
|
|