📄 mp3_m.c
字号:
/***********************************************************************/
/* File: */
/* Copyright (c) 2000 ZORAN Corporation, All Rights Reserved */
/* THIS IS PROPRIETARY SOURCE CODE OF ZORAN CORPORATION */
/* */
/* =========== */
/* Descripton: */
/* =========== */
/* */
/* Log: */
/* === */
/* $Name: $
/* $Header: v:/dsg/rcs/dsg/vp2k/CUSTOMER/MENU/nintaus/MP3_M.C 1.13 2001/07/05 01:36:52 adamw Exp $
/* $Log: MP3_M.C $
/* Revision 1.13 2001/07/05 01:36:52 adamw
/* Revision 1.11 2001/04/02 01:44:20 adamw
/* Revision 1.10 2001/03/09 07:59:19 adamw
/* Check in the changes in Nintaus at Mar 7
/* Revision 1.9 2001/02/13 03:42:54 adamw
/* Revision 1.8 2001/02/02 02:23:13 adamw
/* Revision 1.7 2001/01/30 02:49:46 adamw
/* Revision 1.6 2001/01/17 09:17:32 adamw
/* Revision 1.5 2000/12/28 02:42:46 adamw
/* Revision 1.4 2000/12/26 02:32:25 adamw
/* Revision 1.3 2000/12/08 06:07:20 adamw
/* Revision 1.2 2000/11/17 10:25:31 leslie
/* Revision 1.13 2000/11/13 23:33:22 charlie
/* Added status display/numeric selection/time display, button colors;
/* Revision 1.12 2000/11/12 02:00:11 charlie
/* Restored title and dirname positions to upper left; Prevented status
/* message from overwriting them; Improved track and time display
/* format.
/* Revision 1.11 2000/11/11 01:05:11 charlie
/* Added tmp_string, time display; enabled numeric selection
/* Revision 1.10 2000/11/09 04:07:33 cliff
/***********************************************************************/
#include <stdio.h>
#include <string.h>
#include <sysdefs.h>
#include "..\..\..\ui\menu_sys\ms_wdgt.h"
#include "..\..\..\ui\menu_sys\ms_lib.h"
#include "..\..\..\ui\menu_sys\osd_drv.h"
#include "..\..\..\decoder\osdrendr.h"
#include "..\..\..\decoder\osdlayou.h"
#ifdef FONT32X24 //DM0605
#include "..\..\..\customer\dragon\strings\strings.h"
#else
#include "..\..\..\ui\strings\strings.h"
#endif
#include "menu_var.h"
#include "..\..\..\playcore\ps\ps.h"
#ifdef D_NO_KARAOKE_DEFAULT
#else
#include "..\..\playcore\coremain\coregdef.h"
#endif // D_NO_KARAOKE_DEFAULT
#include "..\..\playcore\coremain\coremain.h"
#include "..\..\..\kernel\eventdef.h"
#include "..\..\..\Decoder\decoder.h"
#include "..\..\playcore\fileSys\filesrch.h"
#include "..\..\playcore\ScPad\scmgr.h"
// Bit values for MP3M.wState
#define MP3M_LIST_INITIALIZED 0x0001
#ifdef D_NO_MP3M
typedef struct _dirBounds
{
int iFirstFileIndex;
int iLastFileIndex;
int iLastItemNum;
} DIR_BOUNDS;
typedef struct _itemInfo
{
int iItemNum;
int iFileIndex;
} ITEM_INFO;
#define MAX_DISPLAY_TRACKS 14
#define MAX_TRACK_NUMBER_DIGITS 3
typedef char SZ_BUTTON_NUMBER[MAX_TRACK_NUMBER_DIGITS + 1];
typedef struct _mp3m
{
int iDirNum;
int iButtonNumber;
DIR_BOUNDS dirBounds;
ITEM_INFO firstDisplayed;
ITEM_INFO lastDisplayed;
int wState;
// Track button strings
SZ_BUTTON_NUMBER szButtonNumber[MAX_DISPLAY_TRACKS];
// Track buttons
MS_BUTTON msbTrack[MAX_DISPLAY_TRACKS];
// Track filename items
MS_STATIC mssTrack[MAX_DISPLAY_TRACKS];
} MP3M;
#endif // D_NO_MP3M
#if D_LOCAL_GMP3M
MP3M gmp3m =
{
0, // iDirNum;
0, // iButtonNumber
{-1, -1, -1}, // dirBounds
{-1, -1}, // firstDisplayed
{-1, -1}, // lastDisplayed
0 // wState
};
#else
#define gmp3m gns.cdda.mp3m
#endif // D_NO_MP3M
// Screen and item positions
static const MS_POS screen_pos = {60, 60, 600, MS_MAX_LINES_BIGMM};
#ifdef DISABLE
#define TRACK_1_BUTTON_POS {0, MS_LINE_1, 36, MS_LINE_HEIGHT}
#define TRACK_2_BUTTON_POS {0, MS_LINE_2, 36, MS_LINE_HEIGHT}
#define TRACK_3_BUTTON_POS {0, MS_LINE_3, 36, MS_LINE_HEIGHT}
#define TRACK_1_NAME_POS {200, MS_LINE_1, 240, MS_LINE_HEIGHT}
#define TRACK_2_NAME_POS {200, MS_LINE_2, 240, MS_LINE_HEIGHT}
#define TRACK_3_NAME_POS {200, MS_LINE_3, 240, MS_LINE_HEIGHT}
static const MS_POS file_1_pos = TRACK_1_NAME_POS;
static const MS_POS file_2_pos = TRACK_2_NAME_POS;
static const MS_POS file_3_pos = TRACK_3_NAME_POS;
static void track_1_action(void);
static void track_2_action(void);
static void track_3_action(void);
#endif // DISABLE
MS_UOP override_button_user_op(MS_WIDGET *widget,MS_UOP uop,char param);
MS_UOP dirName_user_op(MS_WIDGET *widget,MS_UOP uop,char param);
void track_any_action(void);
#define MP3M_BUTTON_WIDTH 40
#define MP3M_NAME_WIDTH 232
static const MS_STATIC mssProto =
{
{
MS_ASCII | MS_STRING_ON_SC,
//AW0117:here I think should not use PAD attribt so I just change it to ALIGN_LEFT
// ALIGN_LEFT_PAD,
ALIGN_LEFT,
I_COLOR,
{0, 0, MP3M_NAME_WIDTH, MS_LINE_HEIGHT},
NO_PARENT,
static_user_op,
},
NULL
};
#define MP3M_SPACING 8
#define MP3M_BUTTON_COLUMN_1 MP3M_SPACING
#define MP3M_BUTTON_COLUMN_2 (MP3M_BUTTON_COLUMN_1 + MP3M_BUTTON_WIDTH + MP3M_SPACING + MP3M_NAME_WIDTH + MP3M_SPACING)
#define MP3M_NAME_COLUMN_1 (MP3M_BUTTON_COLUMN_1 + MP3M_BUTTON_WIDTH + MP3M_SPACING)
#define MP3M_NAME_COLUMN_2 (MP3M_BUTTON_COLUMN_2 + MP3M_BUTTON_WIDTH + MP3M_SPACING)
#define ITEMNUM_COLUMN2 (MAX_DISPLAY_TRACKS / 2)
#define BUTTON_POS_X(_iItemNum_) (unsigned short) ( (_iItemNum_) < ITEMNUM_COLUMN2 ? MP3M_BUTTON_COLUMN_1 : MP3M_BUTTON_COLUMN_2 )
unsigned short button_pos_x( int iItemNum )
{
return BUTTON_POS_X(iItemNum);
}
#define BUTTON_POS_Y(_iItemNum_) (unsigned short) ( ( (_iItemNum_) < ITEMNUM_COLUMN2 ? MS_LINE_HEIGHT * (_iItemNum_) : MS_LINE_HEIGHT * ((_iItemNum_) - ITEMNUM_COLUMN2) ) + MS_LINE_HEIGHT )
unsigned short button_pos_y( int iItemNum )
{
return BUTTON_POS_Y(iItemNum);
}
unsigned short name_pos_x( int iItemNum )
{
return (unsigned short) ( iItemNum < ITEMNUM_COLUMN2 ? MP3M_NAME_COLUMN_1 : MP3M_NAME_COLUMN_2 );
}
#define name_pos_y button_pos_y
// return the button number associated with a widget
int button_number( MS_WIDGET *widget )
{
int iButtonNumber = widget->pos.y / MS_LINE_HEIGHT - 1;
if ( widget->pos.x == MP3M_BUTTON_COLUMN_2 )
iButtonNumber += ITEMNUM_COLUMN2;
return iButtonNumber;
}
#define B_SCROLL_FORWARD TRUE
BOOL can_scroll( BOOL backOrForward )
{
if ( backOrForward == B_SCROLL_FORWARD )
{
return ( gmp3m.lastDisplayed.iFileIndex < gmp3m.dirBounds.iLastFileIndex );
}
else
{
return ( gmp3m.firstDisplayed.iFileIndex > gmp3m.dirBounds.iFirstFileIndex );
}
}
static void mp3m_erase_menu(void)
{
MS_WIDGET *widget = (MS_WIDGET *) screen;
OSD_SetOrigin(widget);
OSD_PutRect(0, MS_LINE_HEIGHT, widget->pos.w, widget->pos.h - MS_LINE_HEIGHT, BG_COLOR(widget->color));
}
void SetButton( int iItemNum, int iFileIndex )
{
MS_WIDGET *msw = (MS_WIDGET *) &gmp3m.msbTrack[iItemNum];
if ( iFileIndex < 0 )
{
strcpy( gmp3m.szButtonNumber[iItemNum], "" );
}
else
{
num_to_str(iFileIndex + 1, gmp3m.szButtonNumber[iItemNum], MAX_TRACK_DIGITS);
}
}
#define NAME_OFFSET ((long) go_TmpFileRec.Name - (long) &go_TmpFileRec )
void *file_name_address( int iFileIndex )
{
void *pv;
pv = (void *) (WORD) (gi_FirstRecLoc + (iFileIndex * FILEREC_DWSIZE) + NAME_OFFSET / 4);
return pv;
}
void SetFilename( int iItemNum, int iFileIndex )
{
MS_WIDGET *msw = (MS_WIDGET *) &gmp3m.mssTrack[iItemNum];
if ( iFileIndex < 0 )
((MS_STATIC *) msw)->text = 0;
else
((MS_STATIC *) msw)->text = file_name_address(iFileIndex);
}
void setListItem( int iItemNum, int iFileIndex )
{
SetButton(iItemNum, iFileIndex);
SetFilename(iItemNum, iFileIndex);
}
static const MS_BUTTON msbProto =
{
{ // MS_STATIC
{ // MS_WIDGET
MS_ASCII | MS_HOT_SPOT,
ALIGN_CENTER,
BUTTON_COLOR,
{0, 0, MP3M_BUTTON_WIDTH, MS_LINE_HEIGHT},
NO_PARENT,
override_button_user_op
},
(void *)S_NULL
},
track_any_action
};
static void initButton( int iItemNum )
{
MS_BUTTON *msb = &gmp3m.msbTrack[iItemNum];
MS_WIDGET *msw = (MS_WIDGET *) msb;
memcpy( msb, &msbProto, sizeof(msbProto) );
msw->pos.x = button_pos_x(iItemNum);
msw->pos.y = button_pos_y(iItemNum);
msw->color = 0xb455;
msb->present.text = (void *) gmp3m.szButtonNumber[iItemNum];
MS_add_item((MS_DIALOG *) screen, msw, (iItemNum == 0));
};
void initFilename( int iItemNum )
{
MS_WIDGET *msw = (MS_WIDGET *) &gmp3m.mssTrack[iItemNum];
memcpy( msw, &mssProto, sizeof(mssProto));
msw->pos.x = name_pos_x(iItemNum);
msw->pos.y = name_pos_y(iItemNum);
((MS_STATIC *) msw)->text = 0;
MS_add_item((MS_DIALOG *) screen, msw, 0);
}
void initListItem( int iItemNum )
{
initButton( iItemNum );
initFilename( iItemNum );
}
void hideListItem( int iItemNum )
{
SetButton(iItemNum, -1);
SetFilename(iItemNum, -1);
SET_NONSELECTABLE( &(gmp3m.msbTrack[iItemNum].present) );
}
// -----------------------------------------------------------
//
// List files for the current directory starting at iFileIndex
// All items in the menu will be filled unless the end of
// end of directory is reached.
//
// Updates:
//
// gmp3m.dirBounds.iFirstFileIndex
// gmp3m.dirBounds.iLastFileIndex
// gmp3m.dirBounds.iLastItemNum
//
// gmp3m.firstDisplayed.iFileIndex
// gmp3m.lastDisplayed.iFileIndex
// gmp3m.lastDisplayed.iItemNum
//
void list_files(int iFileIndex)
{
// We always start at the first list item
int iItemNum = 0;
// These are scratch for receiving the return parameters of file_list_get
DWORD dwLbn;
DWORD dwSize;
char *szFilename;
// Initialize so first displayed file will be detected
gmp3m.firstDisplayed.iFileIndex = -1;
// REMINDER rework the structure if this isn't needed:
gmp3m.firstDisplayed.iItemNum = -1;
// These should be invalid until the first file is detected
gmp3m.lastDisplayed.iFileIndex = -1;
gmp3m.lastDisplayed.iItemNum = -1;
// This should be invalid until the first file is detected
gmp3m.dirBounds.iLastItemNum = -1;
// Handle all list items in some manner
while ( iItemNum < MAX_DISPLAY_TRACKS )
{
if ( iFileIndex >= g_file_list_count )
{
hideListItem(iItemNum);
iItemNum++;
continue;
}
// Get the file information from the file list
file_list_get( iFileIndex, &dwLbn, &dwSize, &szFilename );
// If we haven't reached the correct directory yet, skip this file
if ( go_TmpFileRec.DirNum < gmp3m.iDirNum )
{
iFileIndex++;
}
else
// The directory matches, so set the list item and adjust our navigation information
if ( go_TmpFileRec.DirNum == gmp3m.iDirNum )
{
setListItem(iItemNum, iFileIndex);
// Remember the first file in the directory and its item number
if ( gmp3m.dirBounds.iFirstFileIndex < 0 )
{
gmp3m.dirBounds.iFirstFileIndex = iFileIndex;
}
// We must test this because we can scroll backwards
// Remember the last item and file in the directory
if ( gmp3m.dirBounds.iLastFileIndex < iFileIndex )
{
gmp3m.dirBounds.iLastFileIndex = iFileIndex;
gmp3m.dirBounds.iLastItemNum = iItemNum;
}
// Remember the first displayed file and its item number
if ( gmp3m.firstDisplayed.iFileIndex < 0 )
{
gmp3m.firstDisplayed.iFileIndex = iFileIndex;
gmp3m.firstDisplayed.iItemNum = iItemNum;
}
// Always set the last displayed file and its item number
gmp3m.lastDisplayed.iItemNum = iItemNum;
gmp3m.lastDisplayed.iFileIndex = iFileIndex;
SET_SELECTABLE(&(gmp3m.msbTrack[iItemNum].present));
iItemNum++;
iFileIndex++;
}
else
{
hideListItem(iItemNum);
iItemNum++;
}
}
// if (last file in directory < next file) and (all items displayed and more files can be listed)
// look ahead to see if the next file is in the same directory
if ( (gmp3m.dirBounds.iLastFileIndex < iFileIndex) && (gmp3m.lastDisplayed.iItemNum == (MAX_DISPLAY_TRACKS - 1)) && (gmp3m.dirBounds.iLastFileIndex < (g_file_list_count - 1)) )
{
// Get the file information from the file list
file_list_get( iFileIndex, &dwLbn, &dwSize, &szFilename );
// Remember if the next file is in the same directory, adjust the navigation
if ( go_TmpFileRec.DirNum == gmp3m.iDirNum )
{
gmp3m.dirBounds.iLastFileIndex = iFileIndex;
}
}
MS_change_focus((MS_DIALOG *)screen, (MS_WIDGET *) &gmp3m.msbTrack[gmp3m.firstDisplayed.iItemNum]);
}
void update_scroll_statics(void)
{
}
void scroll_forward( void )
{
mp3m_erase_menu();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -