(Xbox 1) RetroLaunch - complexity cleanups
This commit is contained in:
parent
53c5ff80ed
commit
2240e96b20
|
@ -34,16 +34,11 @@ Font::~Font(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Font::Create()
|
bool Font::Create()
|
||||||
{ //Hardcoded
|
|
||||||
return Create("D:\\Media\\arial.ttf");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Font::Create(const string &szTTFFilename)
|
|
||||||
{
|
{
|
||||||
if (m_pFont)
|
if (m_pFont)
|
||||||
m_pFont->Release();
|
m_pFont->Release();
|
||||||
|
|
||||||
word *wcPathBuf = StringToWChar(szTTFFilename);
|
word *wcPathBuf = StringToWChar("D:\\Media\\arial.ttf");
|
||||||
HRESULT g_hResult = XFONT_OpenTrueTypeFont(wcPathBuf, 256 * 1024, &m_pFont);
|
HRESULT g_hResult = XFONT_OpenTrueTypeFont(wcPathBuf, 256 * 1024, &m_pFont);
|
||||||
|
|
||||||
delete [] wcPathBuf;
|
delete [] wcPathBuf;
|
||||||
|
@ -67,13 +62,9 @@ void Font::Render(const string &str, int x, int y, dword height, dword style, D3
|
||||||
delete [] wcBuf;
|
delete [] wcBuf;
|
||||||
|
|
||||||
if (alignment == Center)
|
if (alignment == Center)
|
||||||
{
|
|
||||||
x -= (dwRequiredWidth / 2);
|
x -= (dwRequiredWidth / 2);
|
||||||
}
|
|
||||||
else if (alignment == Right)
|
else if (alignment == Right)
|
||||||
{
|
|
||||||
x -= dwRequiredWidth;
|
x -= dwRequiredWidth;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
texture.Render(x, y);
|
texture.Render(x, y);
|
||||||
|
@ -102,13 +93,10 @@ void Font::RenderToTexture(CSurface &texture, const string &str, dword height, d
|
||||||
// because the textures are swizzled we make sure
|
// because the textures are swizzled we make sure
|
||||||
// the dimensions are a power of two
|
// the dimensions are a power of two
|
||||||
for(dword wmask = 1; dwTextureWidth &(dwTextureWidth - 1); wmask = (wmask << 1 ) + 1)
|
for(dword wmask = 1; dwTextureWidth &(dwTextureWidth - 1); wmask = (wmask << 1 ) + 1)
|
||||||
{
|
|
||||||
dwTextureWidth = (dwTextureWidth + wmask) & ~wmask;
|
dwTextureWidth = (dwTextureWidth + wmask) & ~wmask;
|
||||||
}
|
|
||||||
for(dword hmask = 1; dwTextureHeight &(dwTextureHeight - 1); hmask = (hmask << 1) + 1)
|
for(dword hmask = 1; dwTextureHeight &(dwTextureHeight - 1); hmask = (hmask << 1) + 1)
|
||||||
{
|
|
||||||
dwTextureHeight = ( dwTextureHeight + hmask ) & ~hmask;
|
dwTextureHeight = ( dwTextureHeight + hmask ) & ~hmask;
|
||||||
}
|
|
||||||
|
|
||||||
// also enforce a minimum pitch of 64 bytes
|
// also enforce a minimum pitch of 64 bytes
|
||||||
dwTextureWidth = max(64 / XGBytesPerPixelFromFormat(D3DFMT_A8R8G8B8), dwTextureWidth);
|
dwTextureWidth = max(64 / XGBytesPerPixelFromFormat(D3DFMT_A8R8G8B8), dwTextureWidth);
|
||||||
|
@ -228,4 +216,4 @@ word *Font::StringToWChar(const string &str)
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,7 +35,6 @@ public:
|
||||||
~Font(void);
|
~Font(void);
|
||||||
|
|
||||||
bool Create();
|
bool Create();
|
||||||
bool Create(const string &szTTFFilename);
|
|
||||||
|
|
||||||
void Render(const string &str, int x, int y, dword height, dword style = XFONT_NORMAL, D3DXCOLOR color = D3DCOLOR_XRGB(0, 0, 0), int dwMaxWidth = -1, bool fade = false, Align alignment = Left);
|
void Render(const string &str, int x, int y, dword height, dword style = XFONT_NORMAL, D3DXCOLOR color = D3DCOLOR_XRGB(0, 0, 0), int dwMaxWidth = -1, bool fade = false, Align alignment = Left);
|
||||||
void RenderToTexture(CSurface &texture, const string &str, dword height, dword style = XFONT_NORMAL, D3DXCOLOR color = D3DCOLOR_XRGB(0, 0, 0), int maxWidth = -1, bool fade = false);
|
void RenderToTexture(CSurface &texture, const string &str, dword height, dword style = XFONT_NORMAL, D3DXCOLOR color = D3DCOLOR_XRGB(0, 0, 0), int maxWidth = -1, bool fade = false);
|
||||||
|
@ -44,10 +43,9 @@ public:
|
||||||
int GetRequiredHeight(const string &str, dword height, dword style);
|
int GetRequiredHeight(const string &str, dword height, dword style);
|
||||||
|
|
||||||
word *StringToWChar(const string &str);
|
word *StringToWChar(const string &str);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XFONT *m_pFont;
|
XFONT *m_pFont;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Font g_font;
|
extern Font g_font;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// IoSupport.cpp: implementation of the CIoSupport class.
|
// IoSupport.cpp: implementation of the CIoSupport class.
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
#ifdef _XBOX
|
|
||||||
#include "iosupport.h"
|
#include "iosupport.h"
|
||||||
#include "undocumented.h"
|
#include "undocumented.h"
|
||||||
|
|
||||||
|
@ -188,74 +187,4 @@ HRESULT CIoSupport::Shutdown()
|
||||||
{
|
{
|
||||||
HalInitiateShutdown();
|
HalInitiateShutdown();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE CIoSupport::CreateFile()
|
|
||||||
{
|
|
||||||
ANSI_STRING filename;
|
|
||||||
OBJECT_ATTRIBUTES attributes;
|
|
||||||
IO_STATUS_BLOCK status;
|
|
||||||
HANDLE hDevice;
|
|
||||||
NTSTATUS error;
|
|
||||||
|
|
||||||
RtlInitAnsiString(&filename, "\\Device\\Cdrom0");
|
|
||||||
InitializeObjectAttributes(&attributes, &filename, OBJ_CASE_INSENSITIVE, NULL);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(error = NtCreateFile(&hDevice, GENERIC_READ |
|
|
||||||
SYNCHRONIZE | FILE_READ_ATTRIBUTES, &attributes, &status, NULL, 0,
|
|
||||||
FILE_SHARE_READ, FILE_OPEN, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT)))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hDevice;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CIoSupport::GetFirstFile(CHAR* szFilename)
|
|
||||||
{
|
|
||||||
ANSI_STRING filename;
|
|
||||||
OBJECT_ATTRIBUTES attributes;
|
|
||||||
IO_STATUS_BLOCK status;
|
|
||||||
HANDLE hDevice;
|
|
||||||
NTSTATUS error;
|
|
||||||
|
|
||||||
RtlInitAnsiString(&filename, "\\Device\\Cdrom0");
|
|
||||||
InitializeObjectAttributes(&attributes, &filename, OBJ_CASE_INSENSITIVE, NULL);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(error = NtCreateFile(&hDevice, GENERIC_READ |
|
|
||||||
SYNCHRONIZE | FILE_READ_ATTRIBUTES, &attributes, &status, NULL, 0,
|
|
||||||
FILE_SHARE_READ, FILE_OPEN, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT)))
|
|
||||||
{
|
|
||||||
OutputDebugString("Unable to open Cdrom0.\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CHAR* szBuffer = new CHAR[2048];
|
|
||||||
DWORD dwRead = 0;
|
|
||||||
|
|
||||||
SetFilePointer(hDevice, 19 * 2048, NULL, FILE_BEGIN);
|
|
||||||
if (!ReadFile(hDevice, szBuffer, 2048, &dwRead, NULL))
|
|
||||||
{
|
|
||||||
OutputDebugString("Unable to read ISO9660 root directory.\n");
|
|
||||||
CloseHandle(hDevice);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hDevice);
|
|
||||||
szBuffer[2047] = 0;
|
|
||||||
|
|
||||||
int offset = 0;
|
|
||||||
while (szBuffer[offset] == 0x22) offset += 0x22;
|
|
||||||
offset += 33; // jump to start of filename
|
|
||||||
|
|
||||||
strcpy(szFilename, "#");
|
|
||||||
strcat(szFilename, &szBuffer[offset]);
|
|
||||||
|
|
||||||
if (szBuffer)
|
|
||||||
delete [] szBuffer;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -38,10 +38,6 @@ public:
|
||||||
HRESULT EjectTray();
|
HRESULT EjectTray();
|
||||||
HRESULT CloseTray();
|
HRESULT CloseTray();
|
||||||
HRESULT Shutdown();
|
HRESULT Shutdown();
|
||||||
|
|
||||||
HANDLE CreateFile();
|
|
||||||
BOOL GetFirstFile(CHAR* szFilename);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DWORD m_dwTrayState;
|
DWORD m_dwTrayState;
|
||||||
DWORD m_dwTrayCount;
|
DWORD m_dwTrayCount;
|
||||||
|
|
|
@ -24,122 +24,108 @@ CMenuMain g_menuMain;
|
||||||
|
|
||||||
CMenuMain::CMenuMain()
|
CMenuMain::CMenuMain()
|
||||||
{
|
{
|
||||||
// we think that the rom list is unloaded until we know otherwise
|
// we think that the rom list is unloaded until we know otherwise
|
||||||
m_bRomListLoadedState = false;
|
m_bRomListLoadedState = false;
|
||||||
|
|
||||||
ifstream stateFile;
|
ifstream stateFile;
|
||||||
stateFile.open("T:\\RomlistState.dat");
|
stateFile.open("T:\\RomlistState.dat");
|
||||||
|
|
||||||
if (stateFile.is_open())
|
if (stateFile.is_open())
|
||||||
{
|
{
|
||||||
int baseIndex;
|
int baseIndex;
|
||||||
int romListMode;
|
|
||||||
|
|
||||||
stateFile >> baseIndex;
|
stateFile >> baseIndex;
|
||||||
stateFile >> romListMode;
|
|
||||||
stateFile >> m_displayMode;
|
|
||||||
|
|
||||||
g_romList.SetRomListMode(romListMode);
|
g_romList.m_iBaseIndex = baseIndex;
|
||||||
g_romList.m_iBaseIndex = baseIndex;
|
|
||||||
|
|
||||||
stateFile.close();
|
stateFile.close();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
m_displayMode = List;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuMain::~CMenuMain()
|
CMenuMain::~CMenuMain()
|
||||||
{
|
{
|
||||||
ofstream stateFile;
|
ofstream stateFile;
|
||||||
stateFile.open("T:\\RomlistState.dat");
|
stateFile.open("T:\\RomlistState.dat");
|
||||||
|
|
||||||
stateFile << g_romList.GetBaseIndex() << endl;
|
stateFile << g_romList.GetBaseIndex() << endl;
|
||||||
stateFile << g_romList.GetRomListMode() << endl;
|
|
||||||
stateFile << m_displayMode << endl;
|
|
||||||
|
|
||||||
stateFile.close();
|
stateFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMenuMain::Create()
|
bool CMenuMain::Create()
|
||||||
{
|
{
|
||||||
RARCH_LOG("CMenuMain::Create().");
|
RARCH_LOG("CMenuMain::Create().");
|
||||||
|
|
||||||
// Title coords with color
|
// Title coords with color
|
||||||
m_menuMainTitle_x = 305;
|
m_menuMainTitle_x = 305;
|
||||||
m_menuMainTitle_y = 30;
|
m_menuMainTitle_y = 30;
|
||||||
m_menuMainTitle_c = 0xFFFFFFFF;
|
m_menuMainTitle_c = 0xFFFFFFFF;
|
||||||
|
|
||||||
// Load background image
|
// Load background image
|
||||||
m_menuMainBG.Create("Media\\menuMainBG.png");
|
m_menuMainBG.Create("Media\\menuMainBG.png");
|
||||||
m_menuMainBG_x = 0;
|
m_menuMainBG_x = 0;
|
||||||
m_menuMainBG_y = 0;
|
m_menuMainBG_y = 0;
|
||||||
m_menuMainBG_w = 640;
|
m_menuMainBG_w = 640;
|
||||||
m_menuMainBG_h = 480;
|
m_menuMainBG_h = 480;
|
||||||
|
|
||||||
// Init rom list coords
|
// Init rom list coords
|
||||||
m_menuMainRomListPos_x = 100;
|
m_menuMainRomListPos_x = 100;
|
||||||
m_menuMainRomListPos_y = 100;
|
m_menuMainRomListPos_y = 100;
|
||||||
m_menuMainRomListSpacing = 20;
|
m_menuMainRomListSpacing = 20;
|
||||||
|
|
||||||
// Load rom selector panel
|
// Load rom selector panel
|
||||||
m_menuMainRomSelectPanel.Create("Media\\menuMainRomSelectPanel.png");
|
m_menuMainRomSelectPanel.Create("Media\\menuMainRomSelectPanel.png");
|
||||||
m_menuMainRomSelectPanel_x = m_menuMainRomListPos_x - 5;
|
m_menuMainRomSelectPanel_x = m_menuMainRomListPos_x - 5;
|
||||||
m_menuMainRomSelectPanel_y = m_menuMainRomListPos_y - 2;
|
m_menuMainRomSelectPanel_y = m_menuMainRomListPos_y - 2;
|
||||||
m_menuMainRomSelectPanel_w = 440;
|
m_menuMainRomSelectPanel_w = 440;
|
||||||
m_menuMainRomSelectPanel_h = 20;
|
m_menuMainRomSelectPanel_h = 20;
|
||||||
|
|
||||||
m_romListSelectedRom = 0;
|
m_romListSelectedRom = 0;
|
||||||
|
|
||||||
//The first element in the romlist to render
|
//The first element in the romlist to render
|
||||||
m_romListBeginRender = 0;
|
m_romListBeginRender = 0;
|
||||||
|
|
||||||
//The last element in the romlist to render
|
//The last element in the romlist to render
|
||||||
m_romListEndRender = 18;
|
m_romListEndRender = 18;
|
||||||
|
|
||||||
//The offset in the romlist
|
//The offset in the romlist
|
||||||
m_romListOffset = 0;
|
m_romListOffset = 0;
|
||||||
|
|
||||||
if(m_romListEndRender > g_romList.GetRomListSize() - 1)
|
if(m_romListEndRender > g_romList.GetRomListSize() - 1)
|
||||||
{
|
m_romListEndRender = g_romList.GetRomListSize() - 1;
|
||||||
m_romListEndRender = g_romList.GetRomListSize() - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Generate the rom list textures only once
|
//Generate the rom list textures only once
|
||||||
vector<Rom *>::iterator i;
|
vector<Rom *>::iterator i;
|
||||||
dword y = 0;
|
dword y = 0;
|
||||||
for (i = g_romList.m_romList.begin(); i != g_romList.m_romList.end(); i++)
|
for (i = g_romList.m_romList.begin(); i != g_romList.m_romList.end(); i++)
|
||||||
{
|
{
|
||||||
Rom *rom = *i;
|
Rom *rom = *i;
|
||||||
g_font.RenderToTexture(rom->GetTexture(), rom->GetFileName(), 18, XFONT_BOLD, 0xff808080, -1, false);
|
g_font.RenderToTexture(rom->GetTexture(), rom->GetFileName(), 18, XFONT_BOLD, 0xff808080, -1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CMenuMain::Render()
|
void CMenuMain::Render()
|
||||||
{
|
{
|
||||||
//CheckRomListState();
|
//Render background image
|
||||||
|
m_menuMainBG.Render(m_menuMainBG_x, m_menuMainBG_y);
|
||||||
|
|
||||||
//Render background image
|
//Display some text
|
||||||
m_menuMainBG.Render(m_menuMainBG_x, m_menuMainBG_y);
|
g_font.Render("Press RSTICK THUMB to exit. Press START and/or A to launch a rom.", 65, 430, 16, XFONT_NORMAL, m_menuMainTitle_c);
|
||||||
|
|
||||||
//Display some text
|
//Begin with the rom selector panel
|
||||||
g_font.Render("Press RSTICK THUMB to exit. Press START and/or A to launch a rom.", 65, 430, 16, XFONT_NORMAL, m_menuMainTitle_c);
|
//FIXME: Width/Height needs to be current Rom texture width/height (or should we just leave it at a fixed size?)
|
||||||
|
m_menuMainRomSelectPanel.Render(m_menuMainRomSelectPanel_x, m_menuMainRomSelectPanel_y, m_menuMainRomSelectPanel_w, m_menuMainRomSelectPanel_h);
|
||||||
|
|
||||||
//Begin with the rom selector panel
|
dword dwSpacing = 0;
|
||||||
//FIXME: Width/Height needs to be current Rom texture width/height (or should we just leave it at a fixed size?)
|
|
||||||
m_menuMainRomSelectPanel.Render(m_menuMainRomSelectPanel_x, m_menuMainRomSelectPanel_y, m_menuMainRomSelectPanel_w, m_menuMainRomSelectPanel_h);
|
|
||||||
|
|
||||||
dword dwSpacing = 0;
|
for (int i = m_romListBeginRender; i <= m_romListEndRender; i++)
|
||||||
|
{
|
||||||
for (int i = m_romListBeginRender; i <= m_romListEndRender; i++)
|
g_romList.GetRomAt(i + m_romListOffset)->GetTexture().Render(m_menuMainRomListPos_x, m_menuMainRomListPos_y + dwSpacing);
|
||||||
{
|
dwSpacing += m_menuMainRomListSpacing;
|
||||||
g_romList.GetRomAt(i + m_romListOffset)->GetTexture().Render(m_menuMainRomListPos_x, m_menuMainRomListPos_y + dwSpacing);
|
}
|
||||||
dwSpacing += m_menuMainRomListSpacing;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t old_input_state = 0;
|
static uint16_t old_input_state = 0;
|
||||||
|
@ -157,79 +143,72 @@ void CMenuMain::ProcessInput()
|
||||||
|
|
||||||
uint16_t trigger_state = input_state & ~old_input_state;
|
uint16_t trigger_state = input_state & ~old_input_state;
|
||||||
|
|
||||||
if(trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_DOWN))
|
if(trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_DOWN))
|
||||||
{
|
{
|
||||||
if(m_romListSelectedRom < g_romList.GetRomListSize())
|
if(m_romListSelectedRom < g_romList.GetRomListSize())
|
||||||
{
|
{
|
||||||
|
if(m_menuMainRomSelectPanel_y < (m_menuMainRomListPos_y + (m_menuMainRomListSpacing * m_romListEndRender)))
|
||||||
|
{
|
||||||
|
m_menuMainRomSelectPanel_y += m_menuMainRomListSpacing;
|
||||||
|
m_romListSelectedRom++;
|
||||||
|
RARCH_LOG("SELECTED ROM: %d.\n", m_romListSelectedRom);
|
||||||
|
}
|
||||||
|
|
||||||
if(m_menuMainRomSelectPanel_y < (m_menuMainRomListPos_y + (m_menuMainRomListSpacing * m_romListEndRender)))
|
if(m_menuMainRomSelectPanel_y > (m_menuMainRomListPos_y + (m_menuMainRomListSpacing * (m_romListEndRender))))
|
||||||
{
|
{
|
||||||
m_menuMainRomSelectPanel_y += m_menuMainRomListSpacing;
|
m_menuMainRomSelectPanel_y -= m_menuMainRomListSpacing;
|
||||||
m_romListSelectedRom++;
|
m_romListSelectedRom++;
|
||||||
RARCH_LOG("SELECTED ROM: %d.\n", m_romListSelectedRom);
|
if(m_romListSelectedRom > g_romList.GetRomListSize() - 1)
|
||||||
}
|
m_romListSelectedRom = g_romList.GetRomListSize() - 1;
|
||||||
|
|
||||||
if(m_menuMainRomSelectPanel_y > (m_menuMainRomListPos_y + (m_menuMainRomListSpacing * (m_romListEndRender))))
|
RARCH_LOG("SELECTED ROM AFTER CORRECTION: %d.\n", m_romListSelectedRom);
|
||||||
{
|
|
||||||
m_menuMainRomSelectPanel_y -= m_menuMainRomListSpacing;
|
|
||||||
m_romListSelectedRom++;
|
|
||||||
if(m_romListSelectedRom > g_romList.GetRomListSize() - 1)
|
|
||||||
{
|
|
||||||
m_romListSelectedRom = g_romList.GetRomListSize() - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(m_romListSelectedRom < g_romList.GetRomListSize() - 1 && m_romListOffset < g_romList.GetRomListSize() - 1 - m_romListEndRender - 1)
|
||||||
|
{
|
||||||
|
m_romListOffset++;
|
||||||
|
RARCH_LOG("OFFSET: %d.\n", m_romListOffset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RARCH_LOG("SELECTED ROM AFTER CORRECTION: %d.\n", m_romListSelectedRom);
|
if(trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_UP))
|
||||||
|
{
|
||||||
|
if(m_romListSelectedRom > -1)
|
||||||
|
{
|
||||||
|
if(m_menuMainRomSelectPanel_y > (m_menuMainRomListPos_y - m_menuMainRomListSpacing))
|
||||||
|
{
|
||||||
|
m_menuMainRomSelectPanel_y -= m_menuMainRomListSpacing;
|
||||||
|
m_romListSelectedRom--;
|
||||||
|
RARCH_LOG("SELECTED ROM: %d.\n", m_romListSelectedRom);
|
||||||
|
}
|
||||||
|
|
||||||
if(m_romListSelectedRom < g_romList.GetRomListSize() - 1 && m_romListOffset < g_romList.GetRomListSize() - 1 - m_romListEndRender - 1) {
|
if(m_menuMainRomSelectPanel_y < (m_menuMainRomListPos_y - m_menuMainRomListSpacing))
|
||||||
m_romListOffset++;
|
{
|
||||||
RARCH_LOG("OFFSET: %d.\n", m_romListOffset);
|
m_menuMainRomSelectPanel_y += m_menuMainRomListSpacing;
|
||||||
}
|
m_romListSelectedRom--;
|
||||||
}
|
if(m_romListSelectedRom < 0)
|
||||||
}
|
m_romListSelectedRom = 0;
|
||||||
}
|
|
||||||
|
|
||||||
if(trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_UP))
|
RARCH_LOG("SELECTED ROM AFTER CORRECTION: %d.\n", m_romListSelectedRom);
|
||||||
{
|
|
||||||
if(m_romListSelectedRom > -1)
|
|
||||||
{
|
|
||||||
if(m_menuMainRomSelectPanel_y > (m_menuMainRomListPos_y - m_menuMainRomListSpacing))
|
|
||||||
{
|
|
||||||
m_menuMainRomSelectPanel_y -= m_menuMainRomListSpacing;
|
|
||||||
m_romListSelectedRom--;
|
|
||||||
RARCH_LOG("SELECTED ROM: %d.\n", m_romListSelectedRom);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_menuMainRomSelectPanel_y < (m_menuMainRomListPos_y - m_menuMainRomListSpacing))
|
if(m_romListSelectedRom > 0 && m_romListOffset > 0)
|
||||||
{
|
{
|
||||||
m_menuMainRomSelectPanel_y += m_menuMainRomListSpacing;
|
m_romListOffset--;
|
||||||
m_romListSelectedRom--;
|
RARCH_LOG("OFFSET: %d.\n", m_romListOffset);
|
||||||
if(m_romListSelectedRom < 0)
|
}
|
||||||
{
|
}
|
||||||
m_romListSelectedRom = 0;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Press A to launch, selected rom filename is saved into T:\\tmp.retro
|
||||||
RARCH_LOG("SELECTED ROM AFTER CORRECTION: %d.\n", m_romListSelectedRom);
|
if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_B) || trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_START))
|
||||||
|
|
||||||
if(m_romListSelectedRom > 0 && m_romListOffset > 0) {
|
|
||||||
m_romListOffset--;
|
|
||||||
RARCH_LOG("OFFSET: %d.\n", m_romListOffset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Press A to launch, selected rom filename is saved into T:\\tmp.retro
|
|
||||||
if(trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_B) || trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_START))
|
|
||||||
{
|
|
||||||
rarch_console_load_game(g_romList.GetRomAt(m_romListSelectedRom)->GetFileName().c_str());
|
rarch_console_load_game(g_romList.GetRomAt(m_romListSelectedRom)->GetFileName().c_str());
|
||||||
}
|
|
||||||
|
|
||||||
if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_R3))
|
if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_R3))
|
||||||
{
|
{
|
||||||
LD_LAUNCH_DASHBOARD LaunchData = { XLD_LAUNCH_DASHBOARD_MAIN_MENU };
|
LD_LAUNCH_DASHBOARD LaunchData = { XLD_LAUNCH_DASHBOARD_MAIN_MENU };
|
||||||
XLaunchNewImage( NULL, (LAUNCH_DATA*)&LaunchData );
|
XLaunchNewImage( NULL, (LAUNCH_DATA*)&LaunchData );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,6 @@
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Surface.h"
|
#include "Surface.h"
|
||||||
|
|
||||||
enum DisplayMode
|
|
||||||
{
|
|
||||||
Box,
|
|
||||||
List
|
|
||||||
};
|
|
||||||
|
|
||||||
class CMenuMain
|
class CMenuMain
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -69,21 +63,6 @@ int m_menuMainRomListPos_x;
|
||||||
int m_menuMainRomListPos_y;
|
int m_menuMainRomListPos_y;
|
||||||
int m_menuMainRomListSpacing;
|
int m_menuMainRomListSpacing;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Rom List menu buttons. The size can be variable so we use a list
|
|
||||||
*/
|
|
||||||
//list<MenuButton *> m_romListButtons;//list<Texture *>
|
|
||||||
//no menu buttons, we will use plain textures
|
|
||||||
list<CSurface *> m_romListButtons;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current mode the rom list is in
|
|
||||||
*/
|
|
||||||
int m_displayMode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current loaded state the rom list is in
|
* The current loaded state the rom list is in
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,42 +31,38 @@ CMenuManager::~CMenuManager()
|
||||||
|
|
||||||
bool CMenuManager::Create()
|
bool CMenuManager::Create()
|
||||||
{
|
{
|
||||||
//Create the MenuManager, set to Main Menu
|
//Create the MenuManager, set to Main Menu
|
||||||
RARCH_LOG("Create MenuManager, set state to MENU_MAIN.\n");
|
RARCH_LOG("Create MenuManager, set state to MENU_MAIN.\n");
|
||||||
SetMenuState(MENU_MAIN);
|
SetMenuState(MENU_MAIN);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMenuManager::SetMenuState(int nMenuID)
|
bool CMenuManager::SetMenuState(int nMenuID)
|
||||||
{
|
{
|
||||||
m_pMenuID = nMenuID;
|
m_pMenuID = nMenuID;
|
||||||
|
|
||||||
switch (m_pMenuID) {
|
switch (m_pMenuID)
|
||||||
case MENU_MAIN:
|
{
|
||||||
//Create the Main Menu
|
case MENU_MAIN:
|
||||||
g_menuMain.Create();
|
//Create the Main Menu
|
||||||
break;
|
g_menuMain.Create();
|
||||||
}
|
break;
|
||||||
return true;
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenuManager::Update()
|
void CMenuManager::Update()
|
||||||
{
|
{
|
||||||
//Process overall input
|
ProcessInput();
|
||||||
ProcessInput();
|
|
||||||
|
|
||||||
switch (m_pMenuID) {
|
|
||||||
case MENU_MAIN:
|
|
||||||
|
|
||||||
// Process menu specific input
|
|
||||||
g_menuMain.ProcessInput();
|
|
||||||
|
|
||||||
// Render the Main Menu
|
|
||||||
g_menuMain.Render();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
switch (m_pMenuID)
|
||||||
|
{
|
||||||
|
case MENU_MAIN:
|
||||||
|
g_menuMain.ProcessInput();
|
||||||
|
g_menuMain.Render();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,10 +70,8 @@ void CMenuManager::ProcessInput()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int CMenuManager::GetMenuState()
|
int CMenuManager::GetMenuState()
|
||||||
{
|
{
|
||||||
return m_pMenuID;
|
return m_pMenuID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ enum eMenuState
|
||||||
MENU_LAUNCHER
|
MENU_LAUNCHER
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CMenuManager
|
class CMenuManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -47,4 +46,4 @@ int m_pMenuID;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CMenuManager g_menuManager;
|
extern CMenuManager g_menuManager;
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Rom.h"
|
#include "Rom.h"
|
||||||
//#include "BoxArtTable.h"
|
|
||||||
|
|
||||||
Rom::Rom()
|
Rom::Rom()
|
||||||
{
|
{
|
||||||
|
@ -25,28 +24,21 @@ Rom::~Rom(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Rom::Load(const string &szFilename)
|
bool Rom::Load(const char *szFilename)
|
||||||
{
|
{
|
||||||
if (m_bLoaded)
|
if (m_bLoaded)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
m_szFilename = szFilename;
|
m_szFilename = szFilename;
|
||||||
|
|
||||||
// get the filename for the box art image
|
|
||||||
//FIXME: Add BoxArtTable.cpp/h, open iso file, grab header, extract ID ie. T-6003G, use for boxartfilename
|
|
||||||
{
|
|
||||||
m_szBoxArtFilename = "D:\\boxart\\default.jpg"; //g_boxArtTable.GetBoxArtFilename(m_dwCrc1);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bLoaded = true;
|
m_bLoaded = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Rom::LoadFromCache(const string &szFilename, const string &szBoxArtFilename)
|
bool Rom::LoadFromCache(const string &szFilename)
|
||||||
{
|
{
|
||||||
m_szFilename = szFilename;
|
m_szFilename = szFilename;
|
||||||
m_szBoxArtFilename = szBoxArtFilename;
|
|
||||||
|
|
||||||
m_bLoaded = true;
|
m_bLoaded = true;
|
||||||
|
|
||||||
|
@ -58,11 +50,6 @@ string Rom::GetFileName()
|
||||||
return m_szFilename;
|
return m_szFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Rom::GetBoxArtFilename()
|
|
||||||
{
|
|
||||||
return m_szBoxArtFilename;
|
|
||||||
}
|
|
||||||
|
|
||||||
string Rom::GetComments()
|
string Rom::GetComments()
|
||||||
{
|
{
|
||||||
//return string(m_iniEntry->szComments);
|
//return string(m_iniEntry->szComments);
|
||||||
|
|
|
@ -24,20 +24,14 @@ public:
|
||||||
Rom();
|
Rom();
|
||||||
~Rom();
|
~Rom();
|
||||||
|
|
||||||
bool Load(const string &szFilename);
|
bool Load(const char *szFilename);
|
||||||
bool LoadFromCache(const string &szFilename, const string &szBoxArtFilename);
|
bool LoadFromCache(const string &szFilename);
|
||||||
|
|
||||||
string GetFileName();
|
string GetFileName();
|
||||||
string GetBoxArtFilename();
|
|
||||||
string GetComments();
|
string GetComments();
|
||||||
|
|
||||||
CSurface &GetTexture();
|
CSurface &GetTexture();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_szFilename;
|
string m_szFilename;
|
||||||
string m_szBoxArtFilename;
|
|
||||||
|
|
||||||
bool m_bLoaded;
|
bool m_bLoaded;
|
||||||
|
|
||||||
CSurface m_texture;
|
CSurface m_texture;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,6 @@ bool RLessThan(Rom *elem1, Rom *elem2)
|
||||||
|
|
||||||
RomList::RomList(void)
|
RomList::RomList(void)
|
||||||
{
|
{
|
||||||
m_romListMode = All;
|
|
||||||
m_iBaseIndex = 0;
|
m_iBaseIndex = 0;
|
||||||
m_bLoaded = false;
|
m_bLoaded = false;
|
||||||
m_szRomPath = "D:\\";
|
m_szRomPath = "D:\\";
|
||||||
|
@ -51,14 +50,12 @@ void RomList::Load()
|
||||||
while (!cacheFile.eof())
|
while (!cacheFile.eof())
|
||||||
{
|
{
|
||||||
string szFilename;
|
string szFilename;
|
||||||
string szBoxArtFilename;
|
|
||||||
|
|
||||||
getline(cacheFile, szFilename);
|
getline(cacheFile, szFilename);
|
||||||
getline(cacheFile, szBoxArtFilename);
|
|
||||||
|
|
||||||
Rom *rom = new Rom();
|
Rom *rom = new Rom();
|
||||||
|
|
||||||
bool bSuccess = rom->LoadFromCache(szFilename, szBoxArtFilename);
|
bool bSuccess = rom->LoadFromCache(szFilename);
|
||||||
|
|
||||||
if (bSuccess)
|
if (bSuccess)
|
||||||
m_romList.push_back(rom);
|
m_romList.push_back(rom);
|
||||||
|
@ -85,7 +82,6 @@ void RomList::Save()
|
||||||
Rom *rom = *i;
|
Rom *rom = *i;
|
||||||
|
|
||||||
cacheFile << rom->GetFileName() << endl;
|
cacheFile << rom->GetFileName() << endl;
|
||||||
cacheFile << rom->GetBoxArtFilename() << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheFile.close();
|
cacheFile.close();
|
||||||
|
@ -103,29 +99,11 @@ bool RomList::IsLoaded()
|
||||||
return m_bLoaded;
|
return m_bLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RomList::SetRomListMode(int mode)
|
|
||||||
{
|
|
||||||
m_iBaseIndex = 0;
|
|
||||||
m_romListMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
int RomList::GetRomListMode()
|
|
||||||
{
|
|
||||||
return m_romListMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RomList::AddRomToList(Rom *rom, int mode)
|
void RomList::AddRomToList(Rom *rom, int mode)
|
||||||
{
|
{
|
||||||
vector<Rom *> *pList;
|
vector<Rom *> *pList;
|
||||||
|
|
||||||
switch (mode)
|
pList = &m_romList;
|
||||||
{
|
|
||||||
case All:
|
|
||||||
pList = &m_romList;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// look to see if the rom is already in the list, we dont want duplicates
|
// look to see if the rom is already in the list, we dont want duplicates
|
||||||
for (int i = 0; i < static_cast<int>(pList->size()); i++)
|
for (int i = 0; i < static_cast<int>(pList->size()); i++)
|
||||||
|
@ -141,15 +119,8 @@ void RomList::AddRomToList(Rom *rom, int mode)
|
||||||
void RomList::RemoveRomFromList(Rom *rom, int mode)
|
void RomList::RemoveRomFromList(Rom *rom, int mode)
|
||||||
{
|
{
|
||||||
vector<Rom *> *pList;
|
vector<Rom *> *pList;
|
||||||
|
|
||||||
switch (mode)
|
pList = &m_romList;
|
||||||
{
|
|
||||||
case All:
|
|
||||||
pList = &m_romList;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<Rom *>::iterator i;
|
vector<Rom *>::iterator i;
|
||||||
|
|
||||||
|
@ -186,38 +157,19 @@ void RomList::SetBaseIndex(int index)
|
||||||
|
|
||||||
int RomList::GetRomListSize()
|
int RomList::GetRomListSize()
|
||||||
{
|
{
|
||||||
switch (m_romListMode)
|
return m_romList.size();
|
||||||
{
|
|
||||||
case All:
|
|
||||||
return m_romList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rom *RomList::GetRomAt(int index)
|
Rom *RomList::GetRomAt(int index)
|
||||||
{
|
{
|
||||||
switch (m_romListMode)
|
return m_romList[index];
|
||||||
{
|
|
||||||
case All:
|
|
||||||
return m_romList[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int RomList::FindRom(Rom *rom, int mode)
|
int RomList::FindRom(Rom *rom, int mode)
|
||||||
{
|
{
|
||||||
vector<Rom *> *pList;
|
vector<Rom *> *pList;
|
||||||
|
|
||||||
switch (mode)
|
pList = &m_romList;
|
||||||
{
|
|
||||||
case All:
|
|
||||||
pList = &m_romList;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < static_cast<int>(pList->size()); i++)
|
for (int i = 0; i < static_cast<int>(pList->size()); i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,11 +18,6 @@
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Rom.h"
|
#include "Rom.h"
|
||||||
|
|
||||||
enum RomListMode
|
|
||||||
{
|
|
||||||
All
|
|
||||||
};
|
|
||||||
|
|
||||||
class RomList
|
class RomList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -35,9 +30,6 @@ public:
|
||||||
|
|
||||||
bool IsLoaded();
|
bool IsLoaded();
|
||||||
|
|
||||||
void SetRomListMode(int mode);
|
|
||||||
int GetRomListMode();
|
|
||||||
|
|
||||||
void AddRomToList(Rom *rom, int mode);
|
void AddRomToList(Rom *rom, int mode);
|
||||||
void RemoveRomFromList(Rom *rom, int mode);
|
void RemoveRomFromList(Rom *rom, int mode);
|
||||||
|
|
||||||
|
@ -61,11 +53,7 @@ private:
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_bLoaded;
|
bool m_bLoaded;
|
||||||
|
|
||||||
int m_romListMode;
|
|
||||||
|
|
||||||
string m_szRomPath;
|
string m_szRomPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -215,13 +215,6 @@ void CSurface::SetOpacity(byte opacity)
|
||||||
m_byOpacity = opacity;
|
m_byOpacity = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSurface::SetTint(byte r, byte g, byte b)
|
|
||||||
{
|
|
||||||
m_byR = r;
|
|
||||||
m_byG = g;
|
|
||||||
m_byB = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSurface::MoveTo(int x, int y)
|
void CSurface::MoveTo(int x, int y)
|
||||||
{
|
{
|
||||||
m_x = x;
|
m_x = x;
|
||||||
|
|
|
@ -43,7 +43,6 @@ public:
|
||||||
* Set functions
|
* Set functions
|
||||||
*/
|
*/
|
||||||
void SetOpacity(byte opacity);
|
void SetOpacity(byte opacity);
|
||||||
void SetTint(byte r, byte g, byte b);
|
|
||||||
|
|
||||||
void MoveTo(int x, int y);
|
void MoveTo(int x, int y);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue