refactoring anime into xcinema

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-15 19:30:39 +03:00
parent fb6a1b244a
commit 631a024373
14 changed files with 110 additions and 68 deletions

View File

@ -6267,14 +6267,17 @@ GetUserSettings(
} else {
//DBG("\n ConfigName: %ls n", gSettings.ConfigName);
}
if (gThemeChanged && ThemeX.Theme.notEmpty()) {
if (gThemeChanged) {
if (GlobalConfig.Theme) {
FreePool(GlobalConfig.Theme);
}
DictPointer = GetProperty (Dict, "GUI");
if (DictPointer != NULL) {
Prop = GetProperty (DictPointer, "Theme");
if ((Prop != NULL) && (Prop->type == kTagTypeString) && Prop->string) {
// ThemeX.Theme.takeValueFrom(Prop->string);
GlobalConfig.Theme = PoolPrint (L"%a", Prop->string);
DBG ("Theme from new config: %ls\n", ThemeX.Theme.data());
// GlobalConfig.Theme = XStringW().takeValueFrom(Prop->string).forgetDataWithoutFreeing();
GlobalConfig.Theme = PoolPrint(L"%a", Prop->string);
DBG ("Theme from new config: %ls\n", GlobalConfig.Theme);
}
}
}

View File

@ -169,7 +169,8 @@ BOOLEAN AddLegacyEntry(IN const XStringW& FullTitle, IN const XStringW& LoaderTi
SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", LoaderTitle.wc_str(), VolDesc);
SubScreen->TitleImage = Entry->Image;
SubScreen->AnimeRun = SubScreen->GetAnime();
SubScreen->ID = SCREEN_BOOT;
SubScreen->GetAnime();
// default entry
SubEntry = new LEGACY_ENTRY();
SubEntry->Title = L"Boot "_XSW + LoaderTitle;

View File

@ -789,9 +789,9 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
SubScreen->Title.SWPrintf("Options for %ls on %ls", Entry->Title.wc_str(), Entry->VolName);
SubScreen->TitleImage = Entry->Image;
SubScreen->ID = Entry->LoaderType + 20;
// DBG("get anime for os=%d\n", SubScreen->ID);
SubScreen->AnimeRun = SubScreen->GetAnime();
SubScreen->ID = Entry->LoaderType + 20; //wow
DBG("get anime for os=%lld\n", SubScreen->ID);
SubScreen->GetAnime();
VolumeSize = RShiftU64(MultU64x32(Volume->BlockIO->Media->LastBlock, Volume->BlockIO->Media->BlockSize), 20);
SubScreen->AddMenuInfoLine_f("Volume size: %lluMb", VolumeSize);
SubScreen->AddMenuInfoLine_f("%ls", FileDevicePathToStr(Entry->DevicePath));
@ -1991,7 +1991,7 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", (Custom->Title != NULL) ? Custom->Title.wc_str() : CustomPath, Entry->VolName);
SubScreen->TitleImage = Entry->Image;
SubScreen->ID = Custom->Type + 20;
SubScreen->AnimeRun = SubScreen->GetAnime();
SubScreen->GetAnime();
VolumeSize = RShiftU64(MultU64x32(Volume->BlockIO->Media->LastBlock, Volume->BlockIO->Media->BlockSize), 20);
SubScreen->AddMenuInfoLine_f("Volume size: %lldMb", VolumeSize);
SubScreen->AddMenuInfoLine_f("%ls", FileDevicePathToStr(Entry->DevicePath));

View File

@ -150,7 +150,7 @@ STATIC VOID AddCloverEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderT
SubScreen->TitleImage = Entry->Image;
SubScreen->ID = SCREEN_BOOT;
SubScreen->AnimeRun = SubScreen->GetAnime();
SubScreen->GetAnime();
SubScreen->AddMenuInfoLine_f("%ls", FileDevicePathToStr(Volume->DevicePath));
if (gEmuVariableControl != NULL) {

View File

@ -126,7 +126,7 @@ static INTN MaxItemOnScreen = -1;
static CHAR16 ArrowUp[2] = { ARROW_UP, 0 };
static CHAR16 ArrowDown[2] = { ARROW_DOWN, 0 };
//
BOOLEAN MainAnime = FALSE;
//BOOLEAN MainAnime = FALSE;
//
////TODO Scroll variables must be a part of REFIT_SCREEN
////BOOLEAN ScrollEnabled = FALSE;
@ -2533,7 +2533,8 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
}
while (!MenuExit) {
AnimeRun = MainAnime;
GetAnime();
DBG("AnimeRun=%d\n", AnimeRun?1:0);
MenuExit = RunGenericMenu(MainStyle, &DefaultEntryIndex, &MainChosenEntry);
TimeoutSeconds = 0;

View File

@ -222,10 +222,12 @@ public:
VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign);
VOID CountItems();
VOID InitAnime();
BOOLEAN GetAnime(); //same for xcinema
VOID UpdateAnime();
VOID GetAnime(); //same for xcinema
#if XCINEMA
VOID UpdateFilm(); // for future use instead of UpdateAnime
#else
VOID UpdateAnime();
#endif
//Style functions

View File

@ -12,12 +12,12 @@
#include "../gui/REFIT_MENU_SCREEN.h"
#ifndef DEBUG_ALL
#define DEBUG_CINEMA 1
#define DEBUG_CINEMA 0
#else
#define DEBUG_CINEMA DEBUG_ALL
#endif
#if DEBUG_CINEMA == 0
#if DEBUG_CINEMA == 1
#define DBG(...)
#else
#define DBG(...) DebugLog(DEBUG_CINEMA, __VA_ARGS__)
@ -26,24 +26,35 @@
//Screen.UpdateAnime(); called from Menu cycle wait for event
// object XCinema::Cinema is a part of Theme
// object FILM::FilmX is a part or current Screen. Must be initialized from Cinema somewhere on Screen init
// object XCinema Cinema is a part of Theme
// object FILM* FilmC is a part or current Screen. Must be initialized from Cinema somewhere on Screen init
#if XCINEMA
VOID REFIT_MENU_SCREEN::UpdateFilm()
{
if (FilmC == nullptr || !AnimeRun) {
// DBG("no anime -> run=%d\n", AnimeRun?1:0);
return;
}
// here we propose each screen has own link to a Film
INT64 Now = AsmReadTsc();
if (LastDraw == 0) {
//save background into special place
FilmPlaceImage.GetArea(FilmC->FilmPlace);
DBG("=== Update Film ===\n");
DBG("FilmX=%lld\n", FilmC->FilmX);
DBG("ID=%lld\n", FilmC->GetIndex());
DBG("RunOnce=%d\n", FilmC->RunOnce?1:0);
DBG("NumFrames=%lld\n", FilmC->NumFrames);
DBG("FrameTime=%lld\n", FilmC->FrameTime);
DBG("Path=%ls\n", FilmC->Path.wc_str());
DBG("LastFrame=%lld\n\n", FilmC->LastFrameID());
}
if (TimeDiff(LastDraw, Now) < (UINTN)FilmC->FrameTime) return;
XImage Frame = FilmC->GetImage(); //take current image
if (!Frame.isEmpty()) {
Frame.DrawOnBack(FilmC->FilmPlace.XPos, FilmC->FilmPlace.YPos, FilmPlaceImage);
Frame.DrawOnBack(FilmC->FilmPlace.XPos, FilmC->FilmPlace.YPos, ThemeX.Background);
}
FilmC->Advance(); //next frame no matter if previous was not found
if (FilmC->Finished()) { //first loop finished
@ -54,10 +65,11 @@ VOID REFIT_MENU_SCREEN::UpdateFilm()
#endif
FILM* XCinema::GetFilm(INTN Id)
{
DBG("ask film %lld\n", Id);
// DBG("ask film %lld from total of %lld\n", Id, Cinema.size());
for (size_t i = 0; i < Cinema.size(); ++i) {
DBG("check film %lld\n", Cinema[i].GetIndex());
// DBG("check film# %lld\n", Cinema[i].GetIndex());
if (Cinema[i].GetIndex() == Id) {
// DBG(" found ID\n");
return &Cinema[i];
}
}
@ -72,13 +84,14 @@ void XCinema::AddFilm(FILM* NewFilm)
static XImage NullImage;
const XImage& FILM::GetImage(INTN Index) const
{
DBG("ask for frame #%lld\n", Index);
DBG("ask for frame #%lld from total of %lld\n", Index, Frames.size());
for (size_t i = 0; i < Frames.size(); ++i) {
if (Frames[i].getIndex() == Index) {
DBG("...found\n");
return Frames[i].getImage();
}
}
DBG("...not found\n");
return NullImage;
}
@ -97,6 +110,7 @@ void FILM::AddFrame(XImage* Frame, INTN Index)
IndexedImage* NewFrame = new IndexedImage(Index);
NewFrame->setImage(*Frame);
Frames.AddReference(NewFrame, true);
DBG("index=%lld last=%lld\n", Index, LastIndex);
if (Index > LastIndex) {
LastIndex = Index;
}
@ -106,6 +120,7 @@ void FILM::GetFrames(XTheme& TheTheme /*, const XStringW& Path*/) // Path alread
{
EFI_FILE *ThemeDir = TheTheme.ThemeDir;
EFI_STATUS Status;
LastIndex = 0;
for (INTN Index = 0; Index < NumFrames; Index++) {
XImage NewImage;
Status = EFI_NOT_FOUND;

View File

@ -46,7 +46,7 @@ public:
public:
FILM() {}
FILM(INTN Id) : Id(Id), RunOnce(false)
FILM(INTN Id) : Id(Id), RunOnce(false), NumFrames(0)
{}
~FILM() {}
@ -97,7 +97,7 @@ class XCinema
FILM* GetFilm(INTN Id);
void AddFilm(FILM* NewFilm);
void setEmpty() { Cinema.Empty(); }
};
#endif /* XCinema_h */

View File

@ -271,6 +271,8 @@ void XTheme::Init()
FontWidth = 9;
FontHeight = 18;
TextHeight = 19;
Cinema.setEmpty();
}
/*
@ -490,7 +492,7 @@ void XTheme::ClearScreen() //and restore background and banner
}
}
}
DBG("BannerPlace at Clear Screen [%lld,%lld]\n", BannerPlace.XPos, BannerPlace.YPos);
//Then prepare Background from BigBack
if (!Background.isEmpty() && (Background.GetWidth() != UGAWidth || Background.GetHeight() != UGAHeight)) { // should we type UGAWidth and UGAHeight as UINTN to avoid cast ?
// Resolution changed

View File

@ -37,7 +37,7 @@
#ifndef __LIBEG_LIBEG_H__
#define __LIBEG_LIBEG_H__
#define XCINEMA 0
#define XCINEMA 1
#ifdef __cplusplus
extern "C" {

View File

@ -2586,12 +2586,11 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
// font already changed and this message very quirky, clear line here
if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) {
// if (!GlobalConfig.NoEarlyProgress && !GlobalConfig.FastBoot && GlobalConfig.Timeout>0) {
// XStringW Message = L" "_XSW;
BootScreen.EraseTextXY();
// BootScreen.EraseTextXY();
// DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
}
// }
}
// wait for user ACK when there were errors
FinishTextScreen(FALSE);
@ -2614,7 +2613,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
DefaultEntry->getLOADER_ENTRY()
&& OSFLAG_ISSET(DefaultEntry->getLOADER_ENTRY()->Flags, OSFLAG_HIBERNATED)
)
)
)
)
{
if (DefaultEntry->getLOADER_ENTRY()) {
@ -2624,7 +2623,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
GlobalConfig.FastBoot = FALSE; //Hmm... will never be here
}
BOOLEAN MainAnime = MainMenu.GetAnime();
// BOOLEAN MainAnime = MainMenu.GetAnime();
// DBG("MainAnime=%d\n", MainAnime);
AfterTool = FALSE;
gEvent = 0; //clear to cancel loop
@ -2634,7 +2633,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
// go strait to DefaultVolume loading
MenuExit = MENU_EXIT_TIMEOUT;
} else {
MainMenu.AnimeRun = MainAnime;
MainMenu.GetAnime();
MenuExit = MainMenu.RunMainMenu(DefaultIndex, &ChosenEntry);
}
// DBG("exit from MainMenu %llu\n", MenuExit); //MENU_EXIT_ENTER=(1) MENU_EXIT_DETAILS=3

View File

@ -1267,7 +1267,7 @@ VOID AboutRefit(VOID)
#endif
AboutMenu.AddMenuInfo_f(" Firmware: %ls rev %d.%04d", gST->FirmwareVendor, gST->FirmwareRevision >> 16, gST->FirmwareRevision & ((1 << 16) - 1));
AboutMenu.AddMenuInfo_f(" Screen Output: %s", egScreenDescription().c_str());
AboutMenu.AnimeRun = AboutMenu.GetAnime();
AboutMenu.GetAnime();
AboutMenu.AddMenuEntry(&MenuEntryReturn, false);
} else if (AboutMenu.Entries.size() >= 2) {
/*
@ -1645,7 +1645,7 @@ VOID HelpRefit(VOID)
HelpMenu.AddMenuInfo_f("S - Shell");
break;
}
HelpMenu.AnimeRun = HelpMenu.GetAnime();
HelpMenu.GetAnime();
HelpMenu.AddMenuEntry(&MenuEntryReturn, false);
}
@ -1692,7 +1692,7 @@ REFIT_ABSTRACT_MENU_ENTRY* NewEntry_(REFIT_ABSTRACT_MENU_ENTRY *Entry, REFIT_MEN
(*SubScreen)->Title = Entry->Title;
(*SubScreen)->TitleImage = Entry->Image;
(*SubScreen)->ID = ID;
(*SubScreen)->AnimeRun = (*SubScreen)->GetAnime();
(*SubScreen)->GetAnime();
Entry->SubScreen = *SubScreen;
return Entry;
}
@ -1981,7 +1981,7 @@ LOADER_ENTRY *SubMenuKextInjectMgmt(LOADER_ENTRY *Entry)
LOADER_ENTRY *SubEntry;
REFIT_MENU_SCREEN *SubScreen;
CHAR16 *kextDir = NULL;
UINTN i;
// UINTN i;
CHAR8 ShortOSVersion[8];
// CHAR16 *UniSysVer = NULL;
CHAR8 *ChosenOS = Entry->OSVersion;
@ -1992,7 +1992,7 @@ LOADER_ENTRY *SubMenuKextInjectMgmt(LOADER_ENTRY *Entry)
if (ChosenOS) {
// DBG("chosen os %s\n", ChosenOS);
//shorten os version 10.11.6 -> 10.11
for (i = 0; i < 8; i++) {
for (int i = 0; i < 8; i++) {
ShortOSVersion[i] = ChosenOS[i];
if (ShortOSVersion[i] == '\0') {
break;
@ -2770,7 +2770,7 @@ VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
if (OptionMenu.Entries.size() == 0) {
gThemeOptionsChanged = TRUE;
OptionMenu.ID = SCREEN_OPTIONS;
OptionMenu.AnimeRun = OptionMenu.GetAnime(); //FALSE;
OptionMenu.GetAnime(); //FALSE;
OptionMenu.AddMenuItemInput(0, "Boot Args:", TRUE);

View File

@ -79,8 +79,9 @@ EG_IMAGE * LoadSvgFrame(INTN i);
INTN UGAWidth;
INTN UGAHeight;
BOOLEAN AllowGraphicsMode;
#if !XCINEMA
EG_RECT BannerPlace; // default ctor called, so it's zero
#endif
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL StdBackgroundPixel = { 0xbf, 0xbf, 0xbf, 0xff};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL MenuBackgroundPixel = { 0x00, 0x00, 0x00, 0x00};
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL InputBackgroundPixel = { 0xcf, 0xcf, 0xcf, 0x80};
@ -143,7 +144,7 @@ VOID SetupScreen(VOID)
static VOID SwitchToText(IN BOOLEAN CursorEnabled)
{
egSetGraphicsModeEnabled(FALSE);
egSetGraphicsModeEnabled(FALSE);
gST->ConOut->EnableCursor(gST->ConOut, CursorEnabled);
}
@ -151,8 +152,8 @@ static VOID SwitchToGraphics(VOID)
{
if (AllowGraphicsMode && !egIsGraphicsModeEnabled()) {
InitScreen(FALSE);
egSetGraphicsModeEnabled(TRUE);
GraphicsScreenDirty = TRUE;
egSetGraphicsModeEnabled(TRUE);
GraphicsScreenDirty = TRUE;
}
}
@ -479,18 +480,36 @@ INTN HybridRepositioning(INTN Edge, INTN Value, INTN ImageDimension, INTN Screen
return pos;
}
#if XCINEMA
BOOLEAN REFIT_MENU_SCREEN::GetAnime()
void REFIT_MENU_SCREEN::GetAnime()
{
FilmC = ThemeX.Cinema.GetFilm(ID);
DBG("ScreenID=%lld Film found=%d\n", ID, (FilmC != nullptr)?1:0);
return FilmC != nullptr;
// DBG("ScreenID=%lld Film found=%d\n", ID, (FilmC != nullptr)?1:0);
if (FilmC != nullptr) {
AnimeRun = true;
}
}
VOID REFIT_MENU_SCREEN::InitAnime()
{
if (FilmC && (FilmC->FilmX >=0) && (FilmC->FilmX <=100) &&
(FilmC->FilmY >=0) && (FilmC->FilmY <=100)) {
if (gThemeChanged) {
FilmC = nullptr;
}
if (FilmC == nullptr) {
DBG("Screen %lld inited without anime\n", ID);
AnimeRun = FALSE;
return;
}
// DBG("=== Debug Film ===\n");
// DBG("FilmX=%lld\n", FilmC->FilmX);
// DBG("ID=%lld\n", FilmC->GetIndex());
// DBG("RunOnce=%d\n", FilmC->RunOnce?1:0);
// DBG("NumFrames=%lld\n", FilmC->NumFrames);
// DBG("FrameTime=%lld\n", FilmC->FrameTime);
// DBG("Path=%ls\n", FilmC->Path.wc_str());
// DBG("LastFrame=%lld\n\n", FilmC->LastFrameID());
if ((FilmC->FilmX >=0) && (FilmC->FilmX <=100) &&
(FilmC->FilmY >=0) && (FilmC->FilmY <=100)) { //default is 0xFFFF
// Check if screen size being used is different from theme origination size.
// If yes, then recalculate the animation placement % value.
// This is necessary because screen can be a different size, but anim is not scaled.
@ -506,26 +525,22 @@ VOID REFIT_MENU_SCREEN::InitAnime()
FilmC->FilmPlace.Width = CWidth;
FilmC->FilmPlace.Height = CHeight;
DBG("recalculated Film position [%lld, %lld]\n", FilmC->FilmPlace.XPos, FilmC->FilmPlace.YPos);
// DBG("recalculated Film position [%lld, %lld]\n", FilmC->FilmPlace.XPos, FilmC->FilmPlace.YPos);
} else {
// We are here if there is no anime, or if we use oldstyle placement values
// For both these cases, FilmPlace will be set after banner/menutitle positions are known
FilmPlace.XPos = 0;
FilmPlace.YPos = 0;
FilmPlace.Width = 0;
FilmPlace.Height = 0;
// FilmC->FilmPlace.XPos = 0;
// FilmC->FilmPlace.YPos = 0;
// FilmC->FilmPlace.Width = 0;
// FilmC->FilmPlace.Height = 0;
FilmC->FilmPlace = ThemeX.BannerPlace;
}
if (FilmC != NULL && FilmC->NumFrames != 0) {
if (FilmC->NumFrames != 0) {
DBG(" Anime seems OK, init it\n");
AnimeRun = TRUE;
FilmC->Reset();
LastDraw = 0;
} else {
// DBG("not run anime\n");
AnimeRun = FALSE;
}
}
#else
@ -707,20 +722,24 @@ VOID REFIT_MENU_SCREEN::InitAnime()
// DBG("anime inited\n");
}
BOOLEAN REFIT_MENU_SCREEN::GetAnime()
VOID REFIT_MENU_SCREEN::GetAnime()
{
GUI_ANIME *Anime;
if (!GuiAnime) return FALSE;
if (!GuiAnime) {
AnimeRun = FALSE;
return;
}
for (Anime = GuiAnime; Anime != NULL && Anime->ID != ID; Anime = Anime->Next);
if (Anime == NULL || Anime->Path == NULL) {
return FALSE;
AnimeRun = FALSE;
return;
}
DBG("Use anime=%ls frames=%llu\n", Anime->Path, Anime->Frames);
return TRUE;
AnimeRun = TRUE;
return;
}
#endif
//

View File

@ -10,7 +10,7 @@ VOID TerminateScreen(VOID);
VOID SetNextScreenMode(INT32);
//BOOLEAN GetAnime(REFIT_MENU_SCREEN *Screen);
//VOID GetAnime(REFIT_MENU_SCREEN *Screen);
//VOID InitAnime(REFIT_MENU_SCREEN *Screen);
//VOID UpdateAnime(REFIT_MENU_SCREEN *Screen, const EG_RECT *Place);
VOID FreeAnime(GUI_ANIME *Anime);