(360) Abstracted message queue push code for generating messages -

seems to only work when Rarch is initialized - if not, it will
keep returning the first message that was pushed in the queue.
This commit is contained in:
TwinAphex51224 2012-05-29 16:45:37 +02:00
parent 68af1626d9
commit 1597c5a2cf
4 changed files with 115 additions and 95 deletions

View File

@ -363,13 +363,7 @@ HRESULT CRetroArchQuickMenu::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled
break;
case MENU_ITEM_OVERSCAN_AMOUNT:
if(g_console.info_msg_enable)
{
if(g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "TODO - Not yet implemented.", 1, 180);
}
}
rarch_settings_msg(S_MSG_NOT_IMPLEMENTED, S_DELAY_180);
break;
case MENU_ITEM_ORIENTATION:
switch(g_console.screen_orientation)
@ -396,10 +390,7 @@ HRESULT CRetroArchQuickMenu::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled
case MENU_ITEM_RESIZE_MODE:
g_console.input_loop = INPUT_LOOP_RESIZE_MODE;
if (g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "INFO - Resize the screen by moving around the two analog sticks.\nPress Y to reset to default values, and B to go back.\nTo select the resized screen mode, set Aspect Ratio to: 'Custom'.", 1, 270);
}
rarch_settings_msg(S_MSG_RESIZE_SCREEN, S_DELAY_270);
break;
case MENU_ITEM_FRAME_ADVANCE:
if (g_console.emulator_initialized)
@ -407,10 +398,7 @@ HRESULT CRetroArchQuickMenu::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled
break;
case MENU_ITEM_SCREENSHOT_MODE:
if (g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "TODO - Not yet implemented.", 1, 180);
}
rarch_settings_msg(S_MSG_NOT_IMPLEMENTED, S_DELAY_180);
break;
case MENU_ITEM_RESET:
if (g_console.emulator_initialized)
@ -512,10 +500,7 @@ HRESULT CRetroArchFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandle
filebrowser_new(&browser, "cache:", rarch_console_get_rom_ext());
filebrowser_fetch_directory_entries("cache:", &browser, &m_romlist, &m_rompathtitle);
if (g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "INFO - All the contents of the ZIP files you have selected in the filebrowser\nare extracted to this partition.", 1, 180);
}
rarch_settings_msg(S_MSG_CACHE_PARTITION, S_DELAY_180);
}
bHandled = TRUE;
@ -549,10 +534,7 @@ HRESULT CRetroArchShaderBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHand
}
if (g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "INFO - Shader successfully loaded.", 1, 180);
}
rarch_settings_msg(S_MSG_SHADER_LOADING_SUCCEEDED, S_DELAY_180);
}
else if(tmp_browser.cur[index].d_type == FILE_ATTRIBUTE_DIRECTORY)
{
@ -608,10 +590,7 @@ HRESULT CRetroArchSettings::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled
m_settingslist.SetText(SETTING_EMU_REWIND_ENABLED, g_settings.rewind_enable ? L"Rewind: ON" : L"Rewind: OFF");
if (g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "INFO - You need to restart RetroArch for this change to take effect.", 1, 180);
}
rarch_settings_msg(S_MSG_RESTART_RARCH, S_DELAY_180);
break;
case SETTING_EMU_SHOW_INFO_MSG:
g_console.info_msg_enable = !g_console.info_msg_enable;
@ -625,19 +604,13 @@ HRESULT CRetroArchSettings::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled
g_console.gamma_correction_enable = !g_console.gamma_correction_enable;
m_settingslist.SetText(SETTING_GAMMA_CORRECTION_ENABLED, g_console.gamma_correction_enable ? L"Gamma correction: ON" : L"Gamma correction: OFF");
if(g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "INFO - You need to restart RetroArch for this change to take effect.", 1, 180);
}
rarch_settings_msg(S_MSG_RESTART_RARCH, S_DELAY_180);
break;
case SETTING_COLOR_FORMAT:
g_console.color_format = !g_console.color_format;
m_settingslist.SetText(SETTING_COLOR_FORMAT, g_console.color_format ? L"Color format: 32bit ARGB" : L"Color format: 16bit RGBA");
if(g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "INFO - You need to restart RetroArch for this change to take effect.", 1, 180);
}
rarch_settings_msg(S_MSG_RESTART_RARCH, S_DELAY_180);
break;
case SETTING_SHADER:
set_shader = 1;
@ -650,10 +623,7 @@ HRESULT CRetroArchSettings::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled
hCur = app.hShaderBrowser;
if (g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "INFO - Select a shader from the menu by pressing the A button.", 1, 180);
}
rarch_settings_msg(S_MSG_SELECT_SHADER, S_DELAY_180);
NavigateForward(app.hShaderBrowser);
break;
case SETTING_SHADER_2:
@ -665,10 +635,7 @@ HRESULT CRetroArchSettings::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled
}
hCur = app.hShaderBrowser;
if (g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "INFO - Select a shader from the menu by pressing the A button.", 1, 180);
}
rarch_settings_msg(S_MSG_SELECT_SHADER, S_DELAY_180);
NavigateForward(app.hShaderBrowser);
break;
case SETTING_HW_TEXTURE_FILTER:
@ -728,10 +695,7 @@ HRESULT CRetroArchMain::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled )
hCur = app.hControlsMenu;
if (g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "INFO - Press LEFT/RIGHT to change the controls, and press\nSTART/A to reset a button to default values.", 1, 180);
}
rarch_settings_msg(S_MSG_CHANGE_CONTROLS, S_DELAY_180);
NavigateForward(app.hControlsMenu);
}
else if ( hObjPressed == m_change_libretro_core )
@ -745,10 +709,7 @@ HRESULT CRetroArchMain::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled )
hCur = app.hCoreBrowser;
if (g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "INFO - Select a Libretro core from the menu by pressing the A button.", 1, 180);
}
rarch_settings_msg(S_MSG_SELECT_LIBRETRO_CORE, S_DELAY_180);
NavigateForward(app.hCoreBrowser);
}
else if ( hObjPressed == m_settings )
@ -830,10 +791,14 @@ void menu_loop(void)
do
{
if(!g_console.emulator_initialized)
d3d9->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);
else
if(g_console.emulator_initialized)
{
rarch_render_cached_frame();
}
else
{
d3d9->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);
}
XINPUT_STATE state;
XInputGetState(0, &state);
@ -866,16 +831,15 @@ void menu_loop(void)
SET_TIMER_EXPIRATION(d3d9, 30);
}
const char *msg = msg_queue_pull(g_extern.msg_queue);
const char *message = msg_queue_pull(g_extern.msg_queue);
if (msg)
if (message)
{
if(IS_TIMER_EXPIRED(d3d9))
{
xdk360_console_format(msg);
xdk360_console_format(message);
SET_TIMER_EXPIRATION(d3d9, 30);
}
xdk360_console_draw();
}

View File

@ -201,10 +201,7 @@ int rarch_extract_zipfile(const char *zip_path)
}
if(g_console.info_msg_enable)
{
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, "INFO - ZIP file extracted to cache partition.", 1, 180);
}
rarch_settings_msg(S_MSG_EXTRACTED_ZIPFILE, S_DELAY_180);
return 0;
}

View File

@ -147,3 +147,42 @@ void rarch_settings_default(unsigned setting)
break;
}
}
void rarch_settings_msg(unsigned setting, unsigned delay)
{
char str[PATH_MAX];
msg_queue_clear(g_extern.msg_queue);
switch(setting)
{
case S_MSG_CACHE_PARTITION:
snprintf(str, sizeof(str), "INFO - All the contents of the ZIP files you have selected in the filebrowser\nare extracted to this partition.");
break;
case S_MSG_CHANGE_CONTROLS:
snprintf(str, sizeof(str), "INFO - Press LEFT/RIGHT to change the controls, and press\n[RetroPad Start] to reset a button to default values.");
break;
case S_MSG_EXTRACTED_ZIPFILE:
snprintf(str, sizeof(str), "INFO - ZIP file extracted to cache partition.");
break;
case S_MSG_NOT_IMPLEMENTED:
snprintf(str, sizeof(str), "TODO - Not yet implemented.");
break;
case S_MSG_RESIZE_SCREEN:
snprintf(str, sizeof(str), "INFO - Resize the screen by moving around the two analog sticks.\nPress [RetroPad X] to reset to default values, and [RetroPad A] to go back.\nTo select the resized screen mode, set Aspect Ratio to: 'Custom'.");
break;
case S_MSG_RESTART_RARCH:
snprintf(str, sizeof(str), "INFO - You need to restart RetroArch for this change to take effect.");
break;
case S_MSG_SELECT_LIBRETRO_CORE:
snprintf(str, sizeof(str), "INFO - Select a Libretro core from the menu by pressing [RetroPad B].");
break;
case S_MSG_SELECT_SHADER:
snprintf(str, sizeof(str), "INFO - Select a shader from the menu by pressing [RetroPad A].");
break;
case S_MSG_SHADER_LOADING_SUCCEEDED:
snprintf(str, sizeof(str), "INFO - Shader successfully loaded.");
break;
}
msg_queue_push(g_extern.msg_queue, str, 1, delay);
}

View File

@ -17,6 +17,12 @@
#ifndef CONSOLE_SETTINGS_H
#define CONSOLE_SETTINGS_H
enum
{
S_DELAY_180 = 180,
S_DELAY_270 = 270,
} delays;
enum
{
S_FRAME_ADVANCE = 0,
@ -53,7 +59,21 @@ enum
S_DEF_SCALE_FACTOR,
} default_settings;
enum
{
S_MSG_CACHE_PARTITION = 0,
S_MSG_CHANGE_CONTROLS,
S_MSG_EXTRACTED_ZIPFILE,
S_MSG_NOT_IMPLEMENTED,
S_MSG_RESIZE_SCREEN,
S_MSG_RESTART_RARCH,
S_MSG_SELECT_LIBRETRO_CORE,
S_MSG_SELECT_SHADER,
S_MSG_SHADER_LOADING_SUCCEEDED,
};
void rarch_settings_change (unsigned setting);
void rarch_settings_default (unsigned setting);
void rarch_settings_msg(unsigned setting, unsigned delay);
#endif