improved XPoitner and XImage, menu advance

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-03-03 17:17:39 +03:00
parent ab391cd1cc
commit 8ff35c6295
13 changed files with 211 additions and 132 deletions

View File

@ -4281,7 +4281,7 @@ InitTheme(
}
// Kill mouse before we invalidate builtin pointer image
KillMouse();
// KillMouse();
// Invalidate BuiltinIcons
// DBG ("Invalidating BuiltinIcons...\n");

View File

@ -65,5 +65,11 @@ int XStringW_tests()
XStringW str4("aŇ𐌾");
if ( str4 != L"aŇ𐌾" ) return 41;
}
XStringW CommonName(L"EFI\\CLOVER\\misc\\screenshot");
for (UINTN Index = 0; Index < 20; Index++) {
XStringW Name = CommonName + SPrintf("%d", Index) + L".png";
DebugLog(2, "XStringW_test shot: %s\n", Name.data());
}
return 0;
}

View File

@ -68,7 +68,14 @@
//#define TAG_EXIT_OLD (101)
//#define TAG_RETURN_OLD ((UINTN)(-1))
typedef VOID(*MENU_STYLE_FUNC)(IN UINTN Function, IN CONST CHAR16 *ParamText);
//typedef VOID(*MENU_STYLE_FUNC)(IN UINTN Function, IN CONST CHAR16 *ParamText);
enum MENU_STYLE_VALUE {
Text,
Options,
Refit,
Vertical,
BootCamp
};
//typedef struct _refit_menu_screen REFIT_MENU_SCREEN;
class REFIT_MENU_SCREEN;
@ -398,13 +405,15 @@ public:
UINTN mItemID;
XPointer *mPointer;
SCROLL_STATE ScrollState;
MENU_STYLE_VALUE StyleValue;
REFIT_MENU_SCREEN()
: ID(0), Title(0), TitleImage(0),
TimeoutSeconds(0), TimeoutText(0), Theme(0), AnimeRun(0),
Once(0), LastDraw(0), CurrentFrame(0),
Frames(0), FrameTime(0), FilmPlace({0,0,0,0}),
Film(0)
Film(0), StyleValue(Text)
{};
REFIT_MENU_SCREEN( UINTN ID_,
@ -428,7 +437,7 @@ public:
TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
Film(Film_)
Film(Film_), StyleValue(Text)
{};
REFIT_MENU_SCREEN( UINTN ID_,
@ -453,7 +462,7 @@ public:
TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
Film(Film_)
Film(Film_), StyleValue(Text)
{
Entries.AddReference(entry, false);
};
@ -481,7 +490,7 @@ public:
TimeoutText(TimeoutText_), Theme(Theme_), AnimeRun(AnimeRun_),
Once(Once_), LastDraw(LastDraw_), CurrentFrame(CurrentFrame_),
Frames(Frames_), FrameTime(FrameTime_), FilmPlace(FilmPlace_),
Film(Film_)
Film(Film_), StyleValue(Text)
{
Entries.AddReference(entry1, false);
Entries.AddReference(entry2, false);
@ -498,15 +507,19 @@ public:
VOID AddMenuEntry(IN REFIT_MENU_ENTRY *Entry, bool freeIt);
VOID FreeMenu();
INTN FindMenuShortcutEntry(IN CHAR16 Shortcut);
UINTN InputDialog(IN MENU_STYLE_FUNC StyleFunc);
UINTN RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INTN *DefaultEntryIndex, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
UINTN InputDialog();
UINTN RunGenericMenu(IN MENU_STYLE_VALUE StyleFunc, IN OUT INTN *DefaultEntryIndex, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
UINTN RunMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
UINTN RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry);
VOID DrawMainMenuLabel(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos);
VOID CountItems();
VOID InitAnime();
BOOLEAN GetAnime();
VOID UpdateAnime(const EG_RECT *Place);
//Style functions
VOID StyleFunc(IN UINTN Function, IN CONST CHAR16 *ParamText);
virtual VOID MainMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
virtual VOID MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
virtual VOID GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);

View File

@ -336,6 +336,9 @@ void XImage::GetArea(INTN x, INTN y, UINTN W, UINTN H)
UgaDraw = NULL;
}
if (W == 0) W = Width;
if (H == 0) H = Height;
INTN AreaWidth = (x + W > Width) ? (Width - x) : W;
INTN AreaHeight = (y + H > Height) ? (Height - y) : H;

View File

@ -1,13 +1,9 @@
/*
* a class for mouse support
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "Library/BaseLib.h"
#ifdef __cplusplus
}
#endif
#include <Platform.h>
#include "XPointer.h"
#include "libegint.h" //this includes platform.h
#include "../refit/screen.h"
@ -49,6 +45,11 @@ void XPointer::Hide()
}
}
bool XPointer::isAlive()
{
return Alive;
}
EFI_STATUS XPointer::MouseBirth()
{
EFI_STATUS Status = EFI_UNSUPPORTED;
@ -59,7 +60,7 @@ EFI_STATUS XPointer::MouseBirth()
if (SimplePointerProtocol) { //do not double
// DBG("DrawPointer\n");
DrawPointer();
Draw();
return EFI_SUCCESS;
}
@ -84,6 +85,7 @@ EFI_STATUS XPointer::MouseBirth()
//this is impossible after BuiltinIcon
DBG("No pointer image!\n");
SimplePointerProtocol = NULL;
Alive = false;
return EFI_NOT_FOUND;
}
LastClickTime = 0; //AsmReadTsc();
@ -96,12 +98,13 @@ EFI_STATUS XPointer::MouseBirth()
//newImage->Fill(&MenuBackgroundPixel),
// egTakeImage(oldImage, oldPlace.XPos, oldPlace.YPos,
// POINTER_WIDTH, POINTER_HEIGHT); // DrawPointer repeats it
DrawPointer();
Draw();
MouseEvent = NoEvents;
Alive = true;
return Status;
}
VOID XPointer::DrawPointer()
VOID XPointer::Draw()
{
// take background image
@ -118,6 +121,7 @@ VOID XPointer::DrawPointer()
VOID XPointer::KillMouse()
{
// EG_PIXEL pi;
Alive = false;
if (!SimplePointerProtocol) {
return;
}

View File

@ -24,9 +24,11 @@ protected:
UINT64 LastClickTime; //not EFI_TIME
EFI_SIMPLE_POINTER_STATE State;
MOUSE_EVENT MouseEvent;
bool Alive;
public:
void Hide();
bool isAlive();
EFI_STATUS MouseBirth();
VOID KillMouse();
UINT64 TimeDiff(UINT64 t0, UINT64 t1);

View File

@ -587,9 +587,9 @@ EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN
// decode it
NewImage = egDecodePNG(FileData, FileDataLength, TRUE);
if (!NewImage) {
NewImage = egDecodeICNS(FileData, FileDataLength, IconSize, TRUE);
}
// if (!NewImage) {
// NewImage = egDecodeICNS(FileData, FileDataLength, IconSize, TRUE);
// }
FreePool(FileData);
return NewImage;

View File

@ -166,18 +166,18 @@ VOID egRawComposeOnFlat(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
IN INTN Width, IN INTN Height,
IN INTN CompLineOffset, IN INTN TopLineOffset);
#define PLPTR(imagevar, colorname) ((UINT8 *) &((imagevar)->PixelData->colorname))
//#define PLPTR(imagevar, colorname) ((UINT8 *) &((imagevar)->PixelData->colorname))
VOID egDecompressIcnsRLE(IN OUT UINT8 **CompData, IN OUT UINTN *CompLen, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
VOID egInsertPlane(IN UINT8 *SrcDataPtr, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
VOID egSetPlane(IN UINT8 *DestPlanePtr, IN UINT8 Value, IN UINT64 PixelCount);
VOID egCopyPlane(IN UINT8 *SrcPlanePtr, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
//VOID egDecompressIcnsRLE(IN OUT UINT8 **CompData, IN OUT UINTN *CompLen, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
//VOID egInsertPlane(IN UINT8 *SrcDataPtr, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
//VOID egSetPlane(IN UINT8 *DestPlanePtr, IN UINT8 Value, IN UINT64 PixelCount);
//VOID egCopyPlane(IN UINT8 *SrcPlanePtr, IN UINT8 *DestPlanePtr, IN UINTN PixelCount);
//EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
//EG_IMAGE * egDecodeICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
EG_IMAGE * egDecodeICNS(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha);
#if defined(LODEPNG)
EG_IMAGE * egDecodePNG(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN WantAlpha);
#endif
//VOID egEncodeBMP(IN EG_IMAGE *Image, OUT UINT8 **FileData, OUT UINTN *FileDataLength);

View File

@ -628,7 +628,35 @@ VOID egTakeImage(IN EG_IMAGE *Image, INTN ScreenPosX, INTN ScreenPosY,
// Make a screenshot
//
CONST CHAR8 ScreenShotName[] = "EFI\\CLOVER\\misc\\screenshot";
#define USE_XIMAGE 1
#if USE_XIMAGE
EFI_STATUS egScreenShot(VOID)
{
EFI_STATUS Status = EFI_NOT_READY;
//take screen
XImage Screen(egScreenWidth, egScreenHeight);
MsgLog("Make screenshot W=%d H=%d\n", egScreenWidth, egScreenHeight);
Screen.GetArea(0, 0, egScreenWidth, egScreenHeight);
//convert to PNG
UINT8 *FileData = NULL;
UINTN FileDataLength = 0U;
Screen.ToPNG(&FileData, FileDataLength);
//save file with a first unoccupied name
XStringW CommonName(L"EFI\\CLOVER\\misc\\screenshot");
for (UINTN Index = 0; Index < 60; Index++) {
// ScreenshotName = PoolPrint(L"%a%d.png", ScreenShotName, Index);
XStringW Name = CommonName + SPrintf("%d", Index) + L".png";
if (!FileExists(SelfRootDir, Name.data())) {
Status = egSaveFile(SelfRootDir, Name.data(), FileData, FileDataLength);
if (!EFI_ERROR(Status)) {
break;
}
}
}
FreePool(FileData);
return Status;
}
#else
EFI_STATUS egScreenShot(VOID)
{
EFI_STATUS Status = EFI_NOT_READY;
@ -743,7 +771,7 @@ EFI_STATUS egScreenShot(VOID)
return Status;
}
#endif
//
// Sets mode via GOP protocol, and reconnects simple text out drivers
//

View File

@ -68,7 +68,7 @@
libeg/BmLib.cpp
libeg/image.cpp
# libeg/load_bmp.cpp
libeg/load_icns.cpp
# libeg/load_icns.cpp
libeg/libscreen.cpp
libeg/lodepng.cpp
libeg/lodepng.h

View File

@ -1079,7 +1079,7 @@ EFI_STATUS WaitForInputEventPoll(REFIT_MENU_SCREEN* ScreenPtr, UINTN TimeoutDefa
CheckSyncSound();
}
TimeoutRemain--;
if (!Screen.mPointer->isEmpty()) {
if (Screen.mPointer->isAlive()) {
Screen.mPointer->UpdatePointer();
Status = Screen.mPointer->CheckMouseEvent(&Screen); //out: gItemID, gAction
if (Status != EFI_TIMEOUT) { //this check should return timeout if no mouse events occured

View File

@ -2243,7 +2243,7 @@ INTN REFIT_MENU_SCREEN::FindMenuShortcutEntry(IN CHAR16 Shortcut)
// generic input menu function
// usr-sse2
//
UINTN REFIT_MENU_SCREEN::InputDialog(IN MENU_STYLE_FUNC StyleFunc)
UINTN REFIT_MENU_SCREEN::InputDialog()
{
if ( !Entries[ScrollState.CurrentSelection].getREFIT_MENU_ITEM_IEM_ABSTRACT() ) {
DebugLog(2, "BUG : InputDialog called with !Entries[ScrollState.CurrentSelection].REFIT_MENU_ITEM_IEM_ABSTRACT()\n");
@ -2450,7 +2450,7 @@ UINTN REFIT_MENU_SCREEN::InputDialog(IN MENU_STYLE_FUNC StyleFunc)
}
UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INTN *DefaultEntryIndex, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_VALUE StyleValue, IN OUT INTN *DefaultEntryIndex, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
{
EFI_STATUS Status;
EFI_INPUT_KEY key;
@ -2562,9 +2562,9 @@ UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INT
ScrollState.LastSelection = ScrollState.CurrentSelection;
ScrollState.CurrentSelection = mItemID;
if ( Entries[mItemID].getREFIT_INPUT_DIALOG() || Entries[mItemID].getREFIT_MENU_CHECKBIT() ) {
MenuExit = InputDialog(StyleFunc);
MenuExit = InputDialog();
} else if (Entries[mItemID].getREFIT_MENU_SWITCH()) {
MenuExit = InputDialog(StyleFunc);
MenuExit = InputDialog();
ScrollState.PaintAll = TRUE;
HidePointer();
} else if (!Entries[mItemID].getREFIT_INFO_DIALOG()) {
@ -2585,7 +2585,7 @@ UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INT
ScrollState.CurrentSelection = mItemID;
if ((Entries[mItemID].getREFIT_INPUT_DIALOG()) ||
(Entries[mItemID].getREFIT_MENU_CHECKBIT())) {
MenuExit = InputDialog(StyleFunc);
MenuExit = InputDialog();
} else if (Entries[mItemID].getREFIT_MENU_SWITCH()) {
MenuExit = InputDialog(StyleFunc);
ScrollState.PaintAll = TRUE;
@ -2738,9 +2738,9 @@ UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INT
case CHAR_CARRIAGE_RETURN:
if ((Entries[ScrollState.CurrentSelection].getREFIT_INPUT_DIALOG()) ||
(Entries[ScrollState.CurrentSelection].getREFIT_MENU_CHECKBIT())) {
MenuExit = InputDialog(StyleFunc);
MenuExit = InputDialog();
} else if (Entries[ScrollState.CurrentSelection].getREFIT_MENU_SWITCH()){
MenuExit = InputDialog(StyleFunc);
MenuExit = InputDialog();
ScrollState.PaintAll = TRUE;
} else if (Entries[ScrollState.CurrentSelection].getREFIT_MENU_ENTRY_CLOVER()){
MenuExit = MENU_EXIT_DETAILS;
@ -2751,9 +2751,9 @@ UINTN REFIT_MENU_SCREEN::RunGenericMenu(IN MENU_STYLE_FUNC StyleFunc, IN OUT INT
case ' ': //CHAR_SPACE
if ((Entries[ScrollState.CurrentSelection].getREFIT_INPUT_DIALOG()) ||
(Entries[ScrollState.CurrentSelection].getREFIT_MENU_CHECKBIT())) {
MenuExit = InputDialog(StyleFunc);
MenuExit = InputDialog();
} else if (Entries[ScrollState.CurrentSelection].getREFIT_MENU_SWITCH()){
MenuExit = InputDialog(StyleFunc);
MenuExit = InputDialog();
ScrollState.PaintAll = TRUE;
HidePointer();
} else if (!Entries[ScrollState.CurrentSelection].getREFIT_INFO_DIALOG()) {
@ -3741,7 +3741,7 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
ScrollStart.YPos = ScrollbarBackground.YPos + ScrollbarBackground.Height * ScrollState.FirstVisible / (ScrollState.MaxIndex + 1);
Scrollbar.YPos = ScrollStart.YPos + ScrollStart.Height;
ScrollEnd.YPos = Scrollbar.YPos + Scrollbar.Height; // ScrollEnd.Height is already subtracted
ScrollingBar(ScrollState);
ScrollingBar(&ScrollState);
break;
}
@ -4031,7 +4031,7 @@ VOID REFIT_MENU_SCREEN::MainMenuVerticalStyle(IN UINTN Function, IN CONST CHAR16
case MENU_FUNCTION_PAINT_ALL:
SetBar(EntriesPosX + EntriesWidth + (int)(10 * GlobalConfig.Scale),
EntriesPosY, UGAHeight - (int)(LAYOUT_Y_EDGE * GlobalConfig.Scale), ScrollState);
EntriesPosY, UGAHeight - (int)(LAYOUT_Y_EDGE * GlobalConfig.Scale), &ScrollState);
for (i = 0; i <= ScrollState.MaxIndex; i++) {
if (Entries[i].Row == 0) {
if ((i >= ScrollState.FirstVisible) && (i <= ScrollState.LastVisible)) {
@ -4324,9 +4324,32 @@ UINTN REFIT_MENU_SCREEN::RunMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
INTN Index = -1;
if (AllowGraphicsMode)
return RunGenericMenu(GraphicsMenuStyle, &Index, ChosenEntry);
StyleValue = Options;
else
return RunGenericMenu(TextMenuStyle, &Index, ChosenEntry);
StyleValue = Text;
return RunGenericMenu(StyleValue, &Index, ChosenEntry);
}
VOID REFIT_MENU_SCREEN::StyleFunc(IN UINTN Function, IN CONST CHAR16 *ParamText)
{
switch (StyleValue) {
case Text:
TextMenuStyle(Function, ParamText);
break;
case Options:
GraphicsMenuStyle(Function, ParamText);
break;
case Refit:
MainMenuStyle(Function, ParamText);
break;
case Vertical:
MainMenuVerticalStyle(Function, ParamText);
break;
default:
GraphicsMenuStyle(Function, ParamText);
break;
}
}
VOID NewEntry_(REFIT_ABSTRACT_MENU_ENTRY *Entry, REFIT_MENU_SCREEN **SubScreen, ACTION AtClick, UINTN ID, CONST CHAR8 *Title)
@ -5454,7 +5477,7 @@ VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry, IN CHAR8 *LastCho
UINTN SubMenuExit;
UINTN NextMenuExit;
//CHAR16* Flags;
MENU_STYLE_FUNC Style = TextMenuStyle;
MENU_STYLE_VALUE Style = Text;
INTN EntryIndex = 0;
INTN SubEntryIndex = -1; //value -1 means old position to remember
INTN NextEntryIndex = -1;
@ -5465,7 +5488,7 @@ VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry, IN CHAR8 *LastCho
GlobalConfig.Proportional = FALSE; //temporary disable proportional
if (AllowGraphicsMode) {
Style = GraphicsMenuStyle;
Style = Options;
}
// remember, if you extended this menu then change procedures
@ -5507,7 +5530,7 @@ VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry, IN CHAR8 *LastCho
}
while (!MenuExit) {
MenuExit = RunGenericMenu(&OptionMenu, Style, &EntryIndex, ChosenEntry);
MenuExit = OptionMenu.RunGenericMenu(Style, &EntryIndex, ChosenEntry);
// MenuExit = RunMenu(&OptionMenu, ChosenEntry);
if ( MenuExit == MENU_EXIT_ESCAPE || (*ChosenEntry)->getREFIT_MENU_ITEM_RETURN() )
break;
@ -5516,7 +5539,7 @@ VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry, IN CHAR8 *LastCho
if ((*ChosenEntry)->SubScreen != NULL) {
SubMenuExit = 0;
while (!SubMenuExit) {
SubMenuExit = RunGenericMenu((*ChosenEntry)->SubScreen, Style, &SubEntryIndex, &TmpChosenEntry);
SubMenuExit = (*ChosenEntry)->SubScreen.RunGenericMenu(Style, &SubEntryIndex, &TmpChosenEntry);
if (SubMenuExit == MENU_EXIT_ESCAPE || TmpChosenEntry->getREFIT_MENU_ITEM_RETURN() ){
ApplyInputs();
ModifyTitles(*ChosenEntry);
@ -5526,7 +5549,7 @@ VOID OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry, IN CHAR8 *LastCho
if (TmpChosenEntry->SubScreen != NULL) {
NextMenuExit = 0;
while (!NextMenuExit) {
NextMenuExit = RunGenericMenu(TmpChosenEntry->SubScreen, Style, &NextEntryIndex, &NextChosenEntry);
NextMenuExit = TmpChosenEntry->SubScreen.RunGenericMenu(Style, &NextEntryIndex, &NextChosenEntry);
if (NextMenuExit == MENU_EXIT_ESCAPE || NextChosenEntry->getREFIT_MENU_ITEM_RETURN() ){
ApplyInputs();
ModifyTitles(TmpChosenEntry);
@ -5615,8 +5638,8 @@ VOID DecodeOptions(REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER *Entry)
UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry)
{
MENU_STYLE_FUNC Style = TextMenuStyle;
MENU_STYLE_FUNC MainStyle = TextMenuStyle;
MENU_STYLE_VALUE Style = Text;
MENU_STYLE_VALUE MainStyle = Text;
REFIT_ABSTRACT_MENU_ENTRY *TempChosenEntry = 0;
REFIT_ABSTRACT_MENU_ENTRY *MainChosenEntry = 0;
REFIT_ABSTRACT_MENU_ENTRY *NextChosenEntry = NULL;
@ -5625,17 +5648,17 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
INTN SubMenuIndex;
if (AllowGraphicsMode) {
Style = GraphicsMenuStyle;
Style = Options;
if (GlobalConfig.VerticalLayout) {
MainStyle = MainMenuVerticalStyle;
MainStyle = Vertical;
} else {
MainStyle = MainMenuStyle;
MainStyle = Refit;
}
}
while (!MenuExit) {
AnimeRun = MainAnime;
MenuExit = RunGenericMenu(Screen, MainStyle, &DefaultEntryIndex, &MainChosenEntry);
MenuExit = RunGenericMenu(MainStyle, &DefaultEntryIndex, &MainChosenEntry);
TimeoutSeconds = 0;
if (MenuExit == MENU_EXIT_DETAILS && MainChosenEntry->SubScreen != NULL) {
@ -5664,7 +5687,7 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
SubMenuExit = 0;
while (!SubMenuExit) {
//running details menu
SubMenuExit = RunGenericMenu(MainChosenEntry->SubScreen, Style, &SubMenuIndex, &TempChosenEntry);
SubMenuExit = MainChosenEntry->SubScreen->RunGenericMenu(Style, &SubMenuIndex, &TempChosenEntry);
if ( MainChosenEntry->getREFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER() ) DecodeOptions(MainChosenEntry->getREFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER());
// DBG("get OptionsBits = 0x%x\n", gSettings.OptionsBits);
// DBG(" TempChosenEntry FlagsBits = 0x%x\n", ((LOADER_ENTRY*)TempChosenEntry)->Flags);
@ -5696,7 +5719,7 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
UINTN NextMenuExit = 0;
INTN NextEntryIndex = -1;
while (!NextMenuExit) {
NextMenuExit = RunGenericMenu(TempChosenEntry->SubScreen, Style, &NextEntryIndex, &NextChosenEntry);
NextMenuExit = TempChosenEntry->SubScreen->RunGenericMenu(Style, &NextEntryIndex, &NextChosenEntry);
if (NextMenuExit == MENU_EXIT_ESCAPE || NextChosenEntry->getREFIT_MENU_ITEM_RETURN() ) {
SubMenuExit = 0;
NextMenuExit = MENU_EXIT_ENTER;
@ -5710,7 +5733,7 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
INTN DeepEntryIndex = -1;
REFIT_ABSTRACT_MENU_ENTRY *DeepChosenEntry = NULL;
while (!DeepMenuExit) {
DeepMenuExit = RunGenericMenu(NextChosenEntry->SubScreen, Style, &DeepEntryIndex, &DeepChosenEntry);
DeepMenuExit = NextChosenEntry->SubScreen->RunGenericMenu(Style, &DeepEntryIndex, &DeepChosenEntry);
if (DeepMenuExit == MENU_EXIT_ESCAPE || DeepChosenEntry->getREFIT_MENU_ITEM_RETURN() ) {
DeepMenuExit = MENU_EXIT_ENTER;
NextMenuExit = 0;

View File

@ -915,7 +915,7 @@ static INTN HybridRepositioning(INTN Edge, INTN Value, INTN ImageDimension, INTN
static EG_IMAGE *AnimeImage = NULL;
VOID UpdateAnime(REFIT_MENU_SCREEN *Screen, const EG_RECT *Place)
VOID REFIT_MENU_SCREEN::UpdateAnime(const EG_RECT *Place)
{
UINT64 Now;
INTN x, y;
@ -923,15 +923,15 @@ VOID UpdateAnime(REFIT_MENU_SCREEN *Screen, const EG_RECT *Place)
//INTN LayoutAnimMoveForMenuX = 0;
INTN MenuWidth = 50;
if (!Screen || !Screen->AnimeRun || !Screen->Film || GlobalConfig.TextOnly) return;
if (!AnimeRun || !Film || GlobalConfig.TextOnly) return;
if (!AnimeImage ||
(AnimeImage->Width != Screen->Film[0]->Width) ||
(AnimeImage->Height != Screen->Film[0]->Height)){
(AnimeImage->Width != Film[0]->Width) ||
(AnimeImage->Height != Film[0]->Height)){
if (AnimeImage) {
egFreeImage(AnimeImage);
}
// DBG("create new AnimeImage [%d,%d]\n", Screen->Film[0]->Width, Screen->Film[0]->Height);
AnimeImage = egCreateImage(Screen->Film[0]->Width, Screen->Film[0]->Height, TRUE);
// DBG("create new AnimeImage [%d,%d]\n", Film[0]->Width, Film[0]->Height);
AnimeImage = egCreateImage(Film[0]->Width, Film[0]->Height, TRUE);
}
// DBG("anime rect pos=[%d,%d] size=[%d,%d]\n", Place->XPos, Place->YPos,
// Place->Width, Place->Height);
@ -941,52 +941,52 @@ VOID UpdateAnime(REFIT_MENU_SCREEN *Screen, const EG_RECT *Place)
x = Place->XPos + (Place->Width - AnimeImage->Width) / 2;
y = Place->YPos + (Place->Height - AnimeImage->Height) / 2;
if (!IsImageWithinScreenLimits(x, Screen->Film[0]->Width, UGAWidth) || !IsImageWithinScreenLimits(y, Screen->Film[0]->Height, UGAHeight)) {
if (!IsImageWithinScreenLimits(x, Film[0]->Width, UGAWidth) || !IsImageWithinScreenLimits(y, Film[0]->Height, UGAHeight)) {
// DBG(") This anime can't be displayed\n");
return;
}
// Check if the theme.plist setting for allowing an anim to be moved horizontally in the quest
// to avoid overlapping the menu text on menu pages at lower resolutions is set.
if ((Screen->ID > 1) && (LayoutAnimMoveForMenuX != 0)) { // these screens have text menus which the anim may interfere with.
if ((ID > 1) && (LayoutAnimMoveForMenuX != 0)) { // these screens have text menus which the anim may interfere with.
MenuWidth = (INTN)(TEXT_XMARGIN * 2 + (50 * GlobalConfig.CharWidth * GlobalConfig.Scale)); // taken from menu.c
if ((x + Screen->Film[0]->Width) > (UGAWidth - MenuWidth) >> 1) {
if ((x + LayoutAnimMoveForMenuX >= 0) || (UGAWidth-(x + LayoutAnimMoveForMenuX + Screen->Film[0]->Width)) <= 100) {
if ((x + Film[0]->Width) > (UGAWidth - MenuWidth) >> 1) {
if ((x + LayoutAnimMoveForMenuX >= 0) || (UGAWidth-(x + LayoutAnimMoveForMenuX + Film[0]->Width)) <= 100) {
x += LayoutAnimMoveForMenuX;
}
}
}
Now = AsmReadTsc();
if (Screen->LastDraw == 0) {
if (LastDraw == 0) {
//first start, we should save background into last frame
egFillImageArea(AnimeImage, 0, 0, AnimeImage->Width, AnimeImage->Height, &MenuBackgroundPixel);
egTakeImage(Screen->Film[Screen->Frames],
egTakeImage(Film[Frames],
x, y,
Screen->Film[Screen->Frames]->Width,
Screen->Film[Screen->Frames]->Height);
Film[Frames]->Width,
Film[Frames]->Height);
}
if (TimeDiff(Screen->LastDraw, Now) < Screen->FrameTime) return;
if (Screen->Film[Screen->CurrentFrame]) {
egRawCopy(AnimeImage->PixelData, Screen->Film[Screen->Frames]->PixelData,
Screen->Film[Screen->Frames]->Width,
Screen->Film[Screen->Frames]->Height,
if (TimeDiff(LastDraw, Now) < FrameTime) return;
if (Film[CurrentFrame]) {
egRawCopy(AnimeImage->PixelData, Film[Frames]->PixelData,
Film[Frames]->Width,
Film[Frames]->Height,
AnimeImage->Width,
Screen->Film[Screen->Frames]->Width);
Film[Frames]->Width);
AnimeImage->HasAlpha = FALSE;
egComposeImage(AnimeImage, Screen->Film[Screen->CurrentFrame], 0, 0); //aaaa
egComposeImage(AnimeImage, Film[CurrentFrame], 0, 0); //aaaa
BltImage(AnimeImage, x, y);
}
Screen->CurrentFrame++;
if (Screen->CurrentFrame >= Screen->Frames) {
Screen->AnimeRun = !Screen->Once;
Screen->CurrentFrame = 0;
CurrentFrame++;
if (CurrentFrame >= Frames) {
AnimeRun = !Once;
CurrentFrame = 0;
}
Screen->LastDraw = Now;
LastDraw = Now;
}
VOID InitAnime(REFIT_MENU_SCREEN *Screen)
VOID REFIT_MENU_SCREEN::InitAnime()
{
CHAR16 FileName[256];
CHAR16 *Path;
@ -994,38 +994,38 @@ VOID InitAnime(REFIT_MENU_SCREEN *Screen)
EG_IMAGE *Last = NULL;
GUI_ANIME *Anime;
if (!Screen || GlobalConfig.TextOnly) return;
if (GlobalConfig.TextOnly) return;
//
for (Anime = GuiAnime; Anime != NULL && Anime->ID != Screen->ID; Anime = Anime->Next);
for (Anime = GuiAnime; Anime != NULL && Anime->ID != ID; Anime = Anime->Next);
// Check if we should clear old film vars (no anime or anime path changed)
//
if (gThemeOptionsChanged || !Anime || !Screen->Film || IsEmbeddedTheme() || !Screen->Theme ||
(/*gThemeChanged && */StriCmp(GlobalConfig.Theme, Screen->Theme) != 0)) {
if (gThemeOptionsChanged || !Anime || !Film || IsEmbeddedTheme() || !Theme ||
(/*gThemeChanged && */StriCmp(GlobalConfig.Theme, Theme) != 0)) {
// DBG(" free screen\n");
if (Screen->Film) {
if (Film) {
//free images in the film
INTN i;
for (i = 0; i <= Screen->Frames; i++) { //really there are N+1 frames
for (i = 0; i <= Frames; i++) { //really there are N+1 frames
// free only last occurrence of repeated frames
if (Screen->Film[i] != NULL && (i == Screen->Frames || Screen->Film[i] != Screen->Film[i+1])) {
FreePool(Screen->Film[i]);
if (Film[i] != NULL && (i == Frames || Film[i] != Film[i+1])) {
FreePool(Film[i]);
}
}
FreePool(Screen->Film);
Screen->Film = NULL;
Screen->Frames = 0;
FreePool(Film);
Film = NULL;
Frames = 0;
}
if (Screen->Theme) {
FreePool(Screen->Theme);
Screen->Theme = NULL;
if (Theme) {
FreePool(Theme);
Theme = NULL;
}
}
// Check if we should load anime files (first run or after theme change)
if (Anime && Screen->Film == NULL) {
if (Anime && Film == NULL) {
Path = Anime->Path;
Screen->Film = (EG_IMAGE**)AllocateZeroPool((Anime->Frames + 1) * sizeof(VOID*));
if ((GlobalConfig.TypeSVG || Path) && Screen->Film) {
Film = (EG_IMAGE**)AllocateZeroPool((Anime->Frames + 1) * sizeof(VOID*));
if ((GlobalConfig.TypeSVG || Path) && Film) {
// Look through contents of the directory
UINTN i;
for (i = 0; i < Anime->Frames; i++) {
@ -1044,17 +1044,17 @@ VOID InitAnime(REFIT_MENU_SCREEN *Screen)
} else {
Last = p;
}
Screen->Film[i] = p;
Film[i] = p;
}
if (Screen->Film[0] != NULL) {
Screen->Frames = i;
if (Film[0] != NULL) {
Frames = i;
DBG(" found %d frames of the anime\n", i);
// Create background frame
Screen->Film[i] = egCreateImage(Screen->Film[0]->Width, Screen->Film[0]->Height, FALSE);
Film[i] = egCreateImage(Film[0]->Width, Film[0]->Height, FALSE);
// Copy some settings from Anime into Screen
Screen->FrameTime = Anime->FrameTime;
Screen->Once = Anime->Once;
Screen->Theme = (__typeof__(Screen->Theme))AllocateCopyPool(StrSize(GlobalConfig.Theme), GlobalConfig.Theme);
FrameTime = Anime->FrameTime;
Once = Anime->Once;
Theme = (__typeof__(Theme))AllocateCopyPool(StrSize(GlobalConfig.Theme), GlobalConfig.Theme);
} /*else {
DBG("Film[0] == NULL\n");
} */
@ -1063,47 +1063,47 @@ VOID InitAnime(REFIT_MENU_SCREEN *Screen)
// Check if a new style placement value has been specified
if (Anime && (Anime->FilmX >=0) && (Anime->FilmX <=100) &&
(Anime->FilmY >=0) && (Anime->FilmY <=100) &&
(Screen->Film != NULL) && (Screen->Film[0] != NULL)) {
(Film != NULL) && (Film[0] != NULL)) {
// 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.
Screen->FilmPlace.XPos = HybridRepositioning(Anime->ScreenEdgeHorizontal, Anime->FilmX, Screen->Film[0]->Width, UGAWidth, GlobalConfig.ThemeDesignWidth );
Screen->FilmPlace.YPos = HybridRepositioning(Anime->ScreenEdgeVertical, Anime->FilmY, Screen->Film[0]->Height, UGAHeight, GlobalConfig.ThemeDesignHeight);
FilmPlace.XPos = HybridRepositioning(Anime->ScreenEdgeHorizontal, Anime->FilmX, Film[0]->Width, UGAWidth, GlobalConfig.ThemeDesignWidth );
FilmPlace.YPos = HybridRepositioning(Anime->ScreenEdgeVertical, Anime->FilmY, Film[0]->Height, UGAHeight, GlobalConfig.ThemeDesignHeight);
// Does the user want to fine tune the placement?
Screen->FilmPlace.XPos = CalculateNudgePosition(Screen->FilmPlace.XPos, Anime->NudgeX, Screen->Film[0]->Width, UGAWidth);
Screen->FilmPlace.YPos = CalculateNudgePosition(Screen->FilmPlace.YPos, Anime->NudgeY, Screen->Film[0]->Height, UGAHeight);
FilmPlace.XPos = CalculateNudgePosition(FilmPlace.XPos, Anime->NudgeX, Film[0]->Width, UGAWidth);
FilmPlace.YPos = CalculateNudgePosition(FilmPlace.YPos, Anime->NudgeY, Film[0]->Height, UGAHeight);
Screen->FilmPlace.Width = Screen->Film[0]->Width;
Screen->FilmPlace.Height = Screen->Film[0]->Height;
DBG("recalculated Screen->Film position\n");
FilmPlace.Width = Film[0]->Width;
FilmPlace.Height = Film[0]->Height;
DBG("recalculated Film position\n");
} 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
Screen->FilmPlace.XPos = 0;
Screen->FilmPlace.YPos = 0;
Screen->FilmPlace.Width = 0;
Screen->FilmPlace.Height = 0;
FilmPlace.XPos = 0;
FilmPlace.YPos = 0;
FilmPlace.Width = 0;
FilmPlace.Height = 0;
}
if (Screen->Film != NULL && Screen->Film[0] != NULL) {
if (Film != NULL && Film[0] != NULL) {
DBG(" Anime seems OK, init it\n");
Screen->AnimeRun = TRUE;
Screen->CurrentFrame = 0;
Screen->LastDraw = 0;
AnimeRun = TRUE;
CurrentFrame = 0;
LastDraw = 0;
} else {
// DBG("not run anime\n");
Screen->AnimeRun = FALSE;
AnimeRun = FALSE;
}
// DBG("anime inited\n");
}
BOOLEAN GetAnime(REFIT_MENU_SCREEN *Screen)
BOOLEAN REFIT_MENU_SCREEN::GetAnime()
{
GUI_ANIME *Anime;
if (!Screen || !GuiAnime) return FALSE;
if (!GuiAnime) return FALSE;
for (Anime = GuiAnime; Anime != NULL && Anime->ID != Screen->ID; Anime = Anime->Next);
for (Anime = GuiAnime; Anime != NULL && Anime->ID != ID; Anime = Anime->Next);
if (Anime == NULL || Anime->Path == NULL) {
return FALSE;
}