SBSPSS/source/frontend/options.cpp

996 lines
26 KiB
C++
Raw Normal View History

2000-11-22 17:04:18 +01:00
/*=========================================================================
options.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "frontend\options.h"
#ifndef __MEMORY_HEADER__
#include "mem\memory.h"
#endif
2001-08-06 17:46:53 +02:00
#ifndef __GFX_FONT_H__
#include "gfx\font.h"
#endif
2000-11-22 17:04:18 +01:00
#ifndef __GFX_FADER_H__
#include "gfx\fader.h"
#endif
#ifndef __FRONTEND_SCROLLBG_H__
#include "frontend\scrollbg.h"
#endif
#ifndef __PRIM_HEADER__
#include "gfx\prim.h"
#endif
2000-11-22 23:52:08 +01:00
#ifndef __GUI_GFACTORY_H__
#include "gui\gfactory.h"
2000-11-22 17:04:18 +01:00
#endif
#ifndef __GUI_GFRAME_H__
#include "gui\gframe.h"
#endif
2000-11-23 20:55:33 +01:00
#ifndef __GUI_GTEXTBOX_H__
#include "gui\gtextbox.h"
2000-11-23 18:00:09 +01:00
#endif
2000-11-22 17:04:18 +01:00
#ifndef __LOCALE_TEXTDBASE_H__
#include "locale\textdbase.h"
#endif
2000-11-22 23:52:08 +01:00
#ifndef __SOUND_SOUND_H__
#include "sound\sound.h"
#endif
2000-11-23 20:55:33 +01:00
#ifndef __PAD_PADS_H__
#include "pad\pads.h"
#endif
2000-11-24 17:14:55 +01:00
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
2001-06-28 21:14:44 +02:00
#ifndef __PAD_VIBE_H__
#include "pad\vibe.h"
#endif
2001-07-02 02:40:09 +02:00
#ifndef __MEMCARD_MEMCARD_H__
#include "memcard\memcard.h"
#endif
#ifndef __MEMCARD_SAVELOAD_H__
#include "memcard\saveload.h"
#endif
2000-11-22 17:04:18 +01:00
/* Std Lib
------- */
/* Data
---- */
2001-04-20 16:53:35 +02:00
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
2000-11-23 20:55:33 +01:00
#endif
2000-11-22 17:04:18 +01:00
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
2000-11-23 20:55:33 +01:00
int CFrontEndOptions::s_controlStyleValues[CPadConfig::NUM_PAD_CONFIGS+1]=
2000-11-23 18:00:09 +01:00
{
2001-07-12 18:19:20 +02:00
0,1,2,
2000-11-23 18:00:09 +01:00
-1
};
2000-11-23 20:55:33 +01:00
CGUITextReadout::TextReadoutData CFrontEndOptions::s_controlStyleReadoutText[CPadConfig::NUM_PAD_CONFIGS]=
2000-11-23 18:00:09 +01:00
{
{ 0,STR__FRONTEND__A },
{ 1,STR__FRONTEND__B },
{ 2,STR__FRONTEND__C },
};
2000-11-23 20:55:33 +01:00
2001-06-28 21:14:44 +02:00
int CFrontEndOptions::s_vibrationValues[2+1]=
{
false,true,
-1
};
CGUITextReadout::TextReadoutData CFrontEndOptions::s_vibrationReadoutText[2]=
{
{ false,STR__OFF },
{ true,STR__ON },
};
2000-11-23 20:55:33 +01:00
int CFrontEndOptions::s_buttonOrder[]=
{
CPadConfig::PAD_CFG_UP,
CPadConfig::PAD_CFG_DOWN,
CPadConfig::PAD_CFG_LEFT,
CPadConfig::PAD_CFG_RIGHT,
CPadConfig::PAD_CFG_JUMP,
2001-05-10 00:12:00 +02:00
CPadConfig::PAD_CFG_FIRE,
CPadConfig::PAD_CFG_CATCH,
2001-05-18 23:03:51 +02:00
CPadConfig::PAD_CFG_WEAPONCHANGE,
2000-11-23 20:55:33 +01:00
};
CGUISpriteReadout::SpriteReadoutData CFrontEndOptions::s_controlReadoutSprites[]=
{
{ ICON_UP,FRM__BUTU },
{ ICON_DOWN,FRM__BUTD },
{ ICON_LEFT,FRM__BUTL },
{ ICON_RIGHT,FRM__BUTR },
{ ICON_CROSS,FRM__BUTX },
{ ICON_CIRCLE,FRM__BUTC },
{ ICON_SQUARE,FRM__BUTS },
{ ICON_TRIANGLE,FRM__BUTT },
};
CFrontEndOptions::ButtonToIconMap CFrontEndOptions::s_controlMap[]=
{
{ PAD_UP, ICON_UP },
{ PAD_DOWN, ICON_DOWN },
{ PAD_LEFT, ICON_LEFT },
{ PAD_RIGHT, ICON_RIGHT },
{ PAD_CROSS, ICON_CROSS },
{ PAD_SQUARE, ICON_SQUARE },
{ PAD_CIRCLE, ICON_CIRCLE },
{ PAD_TRIANGLE, ICON_TRIANGLE },
};
2001-03-09 20:57:10 +01:00
// Frame dimensions
static const int OPTIONS_FRAME_W=416;
static const int OPTIONS_FRAME_H=160;
2001-04-24 16:48:00 +02:00
// Backgrounds
int CFrontEndOptions::s_modeBackground[MODE__COUNT]=
{
FRM__BG3,
2001-07-02 02:40:09 +02:00
FRM__BG5,
FRM__BG7,
FRM__BG8,
FRM__BG9,
};
CGUITextBox *m_loadTextBox;
int CFrontEndOptions::s_loadModeTextIds[LOADMODE__COUNT]=
{
STR__MEMCARD__CHECKING_MEM_CARD, // LOADMODE__INIT
STR__MEMCARD__CHECKING_MEM_CARD, // LOADMODE__CHECKING
STR__MEMCARD__UNFORMATTEDCARD, // LOADMODE__UNFORMATTED
STR__MEMCARD__NOFILESONCARD, // LOADMODE__NODATA
STR__MEMCARD__NOCARDINSLOT, // LOADMODE__NOCARD
STR__FRONTEND__CONFIRM_LOAD, // LOADMODE__CONFIRMLOAD
STR__MEMCARD__LOADINGPLEASEWIAT, // LOADMODE__LOADING
STR__MEMCARD__LOADOK, // LOADMODE__LOADOK
STR__MEMCARD__LOADERROR, // LOADMODE__LOADERROR
2001-04-24 16:48:00 +02:00
};
2001-03-09 20:57:10 +01:00
2001-03-11 21:44:42 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params: _hue = 0..4095, _brightness = 0..255, _rgb -> int[3]
Returns:
---------------------------------------------------------------------- */
static void paulColourSpaceToRGB(int _hue,int _brightness,int *_rgb)
{
static const int s_colourTab[16][3]=
{
{ 255, 0, 0 },
{ 255, 97, 0 },
{ 255,192, 0 },
{ 222,255, 0 },
{ 127,255, 0 },
{ 31,255, 0 },
{ 0,255, 67 },
{ 0,255,162 },
{ 0,252,255 },
{ 0,157,255 },
{ 0, 61,255 },
{ 37, 0,255 },
{ 132, 0,255 },
{ 228, 0,255 },
{ 255, 0,186 },
{ 255, 0, 91 },
};
const int *c1,*c2;
int *cr;
int i,component;
c1=&s_colourTab[(_hue>>8)&15][0];
c2=&s_colourTab[((_hue>>8)+1)&15][0];
cr=_rgb;
for(i=0;i<3;i++)
{
component=*c1+(((*c2-*c1)*(_hue&0xff))>>8);
component=(component*_brightness)>>8;
*cr=component;
c1++;
c2++;
cr++;
}
}
2000-11-22 17:04:18 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndOptions::init()
{
2000-11-22 23:52:08 +01:00
int i;
2000-11-23 20:55:33 +01:00
CGUIGroupFrame *fr;
CGUITextBox *tb;
CGUISpriteReadout *sr;
2000-11-22 17:04:18 +01:00
m_background=new ("Options Background") CScrollyBackground();
m_background->init();
2001-01-05 01:17:57 +01:00
m_background->setOt(MAX_OT-2);
2001-06-11 01:20:13 +02:00
m_background->setTheDrawMode(CScrollyBackground::DRAWMODE_ADDITIVE);
m_background->setColour(80,80,80);
m_background->setSpeed(1,-1);
m_background->setSpeedScale(0);
2001-07-02 02:40:09 +02:00
m_background->setFrame(s_modeBackground[MODE__OPTIONS]);
2001-06-11 01:20:13 +02:00
2000-11-22 17:04:18 +01:00
2000-11-22 23:52:08 +01:00
// Create the menu frames
for(i=0;i<MODE__COUNT;i++)
{
CGUIControlFrame **mm=&m_modeMenus[i];
*mm=new ("optionsframe") CGUIControlFrame();
(*mm)->init(NULL);
2001-03-09 20:57:10 +01:00
(*mm)->setObjectXYWH((512-OPTIONS_FRAME_W)/2,(256-OPTIONS_FRAME_H)/2,OPTIONS_FRAME_W,OPTIONS_FRAME_H);
2000-11-22 23:52:08 +01:00
}
// Populate OPTIONS menu
CGUIFactory::createValueButtonFrame(m_modeMenus[MODE__OPTIONS],
2001-03-09 20:57:10 +01:00
X_BORDER,Y_BORDER,OPTIONS_FRAME_W-(X_BORDER*2),20,
2000-11-22 23:52:08 +01:00
STR__FRONTEND__CONTROLS,
&m_nextMode,MODE__CONTROL);
CGUIFactory::createValueButtonFrame(m_modeMenus[MODE__OPTIONS],
2001-07-02 02:40:09 +02:00
X_BORDER,Y_BORDER+20,OPTIONS_FRAME_W-(X_BORDER*2),20,
2000-11-22 23:52:08 +01:00
STR__FRONTEND__SCREEN,
&m_nextMode,MODE__SCREEN);
CGUIFactory::createValueButtonFrame(m_modeMenus[MODE__OPTIONS],
2001-07-02 02:40:09 +02:00
X_BORDER,Y_BORDER+40,OPTIONS_FRAME_W-(X_BORDER*2),20,
2000-11-22 23:52:08 +01:00
STR__FRONTEND__SOUND,
&m_nextMode,MODE__SOUND);
2001-07-02 02:40:09 +02:00
CGUIFactory::createValueButtonFrame(m_modeMenus[MODE__OPTIONS],
X_BORDER,Y_BORDER+60,OPTIONS_FRAME_W-(X_BORDER*2),20,
STR__FRONTEND__LOAD,
&m_nextMode,MODE__LOAD);
2000-11-22 23:52:08 +01:00
CGUIFactory::createValueButtonFrame(m_modeMenus[MODE__OPTIONS],
2001-03-09 20:57:10 +01:00
X_BORDER,OPTIONS_FRAME_H-Y_BORDER-20,OPTIONS_FRAME_W-(X_BORDER*2),20,
2000-11-22 23:52:08 +01:00
STR__FRONTEND__EXIT,
&m_exitFlag,true);
// Populate CONTROLS menu
2000-11-23 18:00:09 +01:00
CGUIFactory::createCycleButtonFrame(m_modeMenus[MODE__CONTROL],
2001-06-28 21:14:44 +02:00
X_BORDER,Y_BORDER,OPTIONS_FRAME_W-(X_BORDER*2),25,
2000-11-23 18:00:09 +01:00
STR__FRONTEND__CONTROL_STYLE,
2000-11-23 20:55:33 +01:00
&m_controlStyle,s_controlStyleValues,s_controlStyleReadoutText);
fr=new ("frame") CGUIGroupFrame();
fr->init(m_modeMenus[MODE__CONTROL]);
2001-06-28 21:14:44 +02:00
fr->setObjectXYWH(X_BORDER,40,OPTIONS_FRAME_W-(X_BORDER*2),60); //292
2000-11-23 20:55:33 +01:00
sr=new ("spritereadout") CGUISpriteReadout();
sr->init(fr);
2001-06-28 21:14:44 +02:00
sr->setObjectXYWH(0,0,26,15); //176
2000-11-23 20:55:33 +01:00
sr->setReadoutTarget(&m_controlIcons[CONTROL_UP]);
sr->setReadoutData(s_controlReadoutSprites);
tb=new ("textbox") CGUITextBox();
tb->init(fr);
2001-06-28 21:14:44 +02:00
tb->setObjectXYWH(26,0,150,15);
2001-07-28 18:45:46 +02:00
tb->setText(STR__FRONTEND__LOOK_UP);
2000-11-23 20:55:33 +01:00
sr=new ("spritereadout") CGUISpriteReadout();
sr->init(fr);
sr->setObjectXYWH(0,15,26,15);
sr->setReadoutTarget(&m_controlIcons[CONTROL_DOWN]);
sr->setReadoutData(s_controlReadoutSprites);
tb=new ("textbox") CGUITextBox();
tb->init(fr);
2001-06-28 21:14:44 +02:00
tb->setObjectXYWH(26,15,150,15);
2001-07-28 18:45:46 +02:00
tb->setText(STR__FRONTEND__LOOK_DOWN);
2000-11-23 20:55:33 +01:00
sr=new ("spritereadout") CGUISpriteReadout();
sr->init(fr);
sr->setObjectXYWH(0,30,26,15);
sr->setReadoutTarget(&m_controlIcons[CONTROL_LEFT]);
sr->setReadoutData(s_controlReadoutSprites);
tb=new ("textbox") CGUITextBox();
tb->init(fr);
2001-06-28 21:14:44 +02:00
tb->setObjectXYWH(26,30,150,15);
2000-11-23 20:55:33 +01:00
tb->setText(STR__FRONTEND__LEFT);
sr=new ("spritereadout") CGUISpriteReadout();
sr->init(fr);
sr->setObjectXYWH(0,45,26,15);
sr->setReadoutTarget(&m_controlIcons[CONTROL_RIGHT]);
sr->setReadoutData(s_controlReadoutSprites);
tb=new ("textbox") CGUITextBox();
tb->init(fr);
2001-06-28 21:14:44 +02:00
tb->setObjectXYWH(26,45,150,15);
2000-11-23 20:55:33 +01:00
tb->setText(STR__FRONTEND__RIGHT);
sr=new ("spritereadout") CGUISpriteReadout();
sr->init(fr);
2001-06-28 21:14:44 +02:00
sr->setObjectXYWH(176,0,26,15);
2000-11-23 20:55:33 +01:00
sr->setReadoutTarget(&m_controlIcons[CONTROL_JUMP]);
sr->setReadoutData(s_controlReadoutSprites);
tb=new ("textbox") CGUITextBox();
tb->init(fr);
2001-06-28 21:14:44 +02:00
tb->setObjectXYWH(176+26,0,150,15);
2000-11-23 20:55:33 +01:00
tb->setText(STR__FRONTEND__JUMP);
sr=new ("spritereadout") CGUISpriteReadout();
sr->init(fr);
2001-06-28 21:14:44 +02:00
sr->setObjectXYWH(176,15,26,15);
2001-05-10 00:12:00 +02:00
sr->setReadoutTarget(&m_controlIcons[CONTROL_FIRE]);
2000-11-23 20:55:33 +01:00
sr->setReadoutData(s_controlReadoutSprites);
tb=new ("textbox") CGUITextBox();
tb->init(fr);
2001-06-28 21:14:44 +02:00
tb->setObjectXYWH(176+26,15,150,15);
2001-05-10 00:12:00 +02:00
tb->setText(STR__FRONTEND__FIRE);
sr=new ("spritereadout") CGUISpriteReadout();
sr->init(fr);
2001-06-28 21:14:44 +02:00
sr->setObjectXYWH(176,30,26,15);
2001-05-10 00:12:00 +02:00
sr->setReadoutTarget(&m_controlIcons[CONTROL_CATCH]);
sr->setReadoutData(s_controlReadoutSprites);
tb=new ("textbox") CGUITextBox();
tb->init(fr);
2001-06-28 21:14:44 +02:00
tb->setObjectXYWH(176+26,30,150,15);
2001-05-10 00:12:00 +02:00
tb->setText(STR__FRONTEND__CATCH);
2001-05-18 23:03:51 +02:00
sr=new ("spritereadout") CGUISpriteReadout();
sr->init(fr);
2001-06-28 21:14:44 +02:00
sr->setObjectXYWH(176,45,26,15);
2001-05-18 23:03:51 +02:00
sr->setReadoutTarget(&m_controlIcons[CONTROL_WEAPONCHANGE]);
sr->setReadoutData(s_controlReadoutSprites);
tb=new ("textbox") CGUITextBox();
tb->init(fr);
2001-06-28 21:14:44 +02:00
tb->setObjectXYWH(176+26,45,150,15);
2001-05-18 23:03:51 +02:00
tb->setText(STR__FRONTEND__WEAPONCHANGE);
2001-07-31 18:01:36 +02:00
m_vibGUIOption=CGUIFactory::createCycleButtonFrame(m_modeMenus[MODE__CONTROL],
X_BORDER,Y_BORDER+90,OPTIONS_FRAME_W-(X_BORDER*2),25,
STR__FRONTEND__VIBRATION,
&m_vibrationStatus,s_vibrationValues,s_vibrationReadoutText);
2000-11-22 23:52:08 +01:00
// Populate SCREEN menu
2000-11-24 17:14:55 +01:00
CGUIFactory::createSliderButtonFrame(m_modeMenus[MODE__SCREEN],
2001-03-09 20:57:10 +01:00
X_BORDER,Y_BORDER,OPTIONS_FRAME_W-(X_BORDER*2),35,
2000-11-24 17:14:55 +01:00
STR__FRONTEND__HORIZONTAL_POSITION,
&m_screenXOff,0,64);
CGUIFactory::createSliderButtonFrame(m_modeMenus[MODE__SCREEN],
2001-03-09 20:57:10 +01:00
X_BORDER,Y_BORDER+40,OPTIONS_FRAME_W-(X_BORDER*2),35,
2000-11-24 17:14:55 +01:00
STR__FRONTEND__VERTICAL_POSITION,
&m_screenYOff,0,32);
2000-11-22 23:52:08 +01:00
// Populate SOUND menu
CGUIFactory::createSliderButtonFrame(m_modeMenus[MODE__SOUND],
2001-03-09 20:57:10 +01:00
X_BORDER,Y_BORDER,OPTIONS_FRAME_W-(X_BORDER*2),35,
2000-11-22 23:52:08 +01:00
STR__FRONTEND__BGM,
&m_bgmVolume,CSoundMediator::MIN_VOLUME,CSoundMediator::MAX_VOLUME);
CGUIFactory::createSliderButtonFrame(m_modeMenus[MODE__SOUND],
2001-03-09 20:57:10 +01:00
X_BORDER,Y_BORDER+35,OPTIONS_FRAME_W-(X_BORDER*2),35,
2000-11-22 23:52:08 +01:00
STR__FRONTEND__SFX,
&m_sfxVolume,CSoundMediator::MIN_VOLUME,CSoundMediator::MAX_VOLUME);
CGUIFactory::createSliderButtonFrame(m_modeMenus[MODE__SOUND],
2001-03-09 20:57:10 +01:00
X_BORDER,Y_BORDER+70,OPTIONS_FRAME_W-(X_BORDER*2),35,
2000-11-22 23:52:08 +01:00
STR__FRONTEND__SPEECH,
&m_speechVolume,CSoundMediator::MIN_VOLUME,CSoundMediator::MAX_VOLUME);
2001-07-02 02:40:09 +02:00
// Memcard menu
m_loadTextBox=new ("textbox") CGUITextBox();
m_loadTextBox->init(m_modeMenus[MODE__LOAD]);
m_loadTextBox->setObjectXYWH(X_BORDER,Y_BORDER,OPTIONS_FRAME_W-(X_BORDER*2),80);
m_loadTextBox->setText(STR__MEMCARD__CHECKING_MEM_CARD);
// Extra memcard frames..
m_loadModeConfirmFrame=new ("loadmodeconfirmframe") CGUIControlFrame();
m_loadModeConfirmFrame->init(NULL);
m_loadModeConfirmFrame->setObjectXYWH(((512-OPTIONS_FRAME_W)/2)+X_BORDER,((256-OPTIONS_FRAME_H)/2)+OPTIONS_FRAME_H-Y_BORDER-40,OPTIONS_FRAME_W-(X_BORDER*2),40);
m_loadModeConfirmFrame->clearFlags(CGUIObject::FLAG_DRAWBORDER);
CGUIFactory::createValueButtonFrame(m_loadModeConfirmFrame,
0,20,OPTIONS_FRAME_W-(X_BORDER*2),20,
STR__NO,
&m_loadUserResponse,USERRESPONSE__NO);
2001-08-07 17:54:36 +02:00
CGUIFactory::createValueButtonFrame(m_loadModeConfirmFrame,
0,0,OPTIONS_FRAME_W-(X_BORDER*2),20,
STR__YES,
&m_loadUserResponse,USERRESPONSE__YES);
2001-07-02 02:40:09 +02:00
m_loadModeOKFrame=new ("loadmodeokframe") CGUIControlFrame();
m_loadModeOKFrame->init(NULL);
m_loadModeOKFrame->setObjectXYWH(((512-OPTIONS_FRAME_W)/2)+X_BORDER,((256-OPTIONS_FRAME_H)/2)+OPTIONS_FRAME_H-Y_BORDER-40,OPTIONS_FRAME_W-(X_BORDER*2),40);
m_loadModeOKFrame->clearFlags(CGUIObject::FLAG_DRAWBORDER);
CGUIFactory::createValueButtonFrame(m_loadModeOKFrame,
0,0,OPTIONS_FRAME_W-(X_BORDER*2),20,
STR__OK,
&m_loadUserResponse,USERRESPONSE__OK);
2000-11-22 23:52:08 +01:00
// Add BACK to all of the sub menus
for(i=1;i<MODE__COUNT;i++)
{
2001-07-02 02:40:09 +02:00
if(i!=MODE__LOAD)
{
CGUIFactory::createValueButtonFrame(m_modeMenus[i],
X_BORDER,OPTIONS_FRAME_H-Y_BORDER-20,OPTIONS_FRAME_W-(X_BORDER*2),20,
STR__FRONTEND__BACK,
&m_nextMode,MODE__OPTIONS);
}
2000-11-22 23:52:08 +01:00
}
2001-07-02 18:03:27 +02:00
getValues();
2001-07-02 02:40:09 +02:00
m_saveLoadDatabase=NULL;
2001-08-06 17:46:53 +02:00
m_fontBank=new ("CGameScene::Init") FontBank();
m_fontBank->initialise( &standardFont );
2001-08-07 18:08:00 +02:00
m_fontBank->setColour(80,80,80);
2001-08-06 17:46:53 +02:00
m_spriteBank=new ("options sprites") SpriteBank();
m_spriteBank->load(SPRITES_SPRITES_SPR);
2000-11-22 18:02:04 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndOptions::shutdown()
{
2000-11-22 23:52:08 +01:00
int i;
2001-08-06 17:46:53 +02:00
m_spriteBank->dump(); delete m_spriteBank;
m_fontBank->dump(); delete m_fontBank;
2001-07-02 04:27:53 +02:00
m_loadModeConfirmFrame->shutdown();
m_loadModeOKFrame->shutdown();
2000-11-22 23:52:08 +01:00
for(i=0;i<MODE__COUNT;i++)
{
2000-11-23 18:00:09 +01:00
m_modeMenus[i]->shutdown();
2000-11-22 23:52:08 +01:00
}
2000-11-22 18:02:04 +01:00
m_background->shutdown(); delete m_background;
}
2000-11-22 17:04:18 +01:00
2000-11-22 18:02:04 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndOptions::select()
{
2000-11-22 23:52:08 +01:00
m_modeMenus[MODE__OPTIONS]->select();
m_mode=m_nextMode=MODE__OPTIONS;
2000-11-22 17:04:18 +01:00
m_exitFlag=false;
m_closingDown=false;
2000-11-22 18:02:04 +01:00
2001-01-19 17:25:05 +01:00
CSoundMediator::setSong(CSoundMediator::SONG_OPTIONS);
2001-07-03 22:28:04 +02:00
m_musicStarted=false;
2001-01-19 17:25:05 +01:00
2000-11-22 17:04:18 +01:00
CFader::setFadingIn();
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2000-11-22 18:02:04 +01:00
void CFrontEndOptions::unselect()
2000-11-22 17:04:18 +01:00
{
2001-01-19 17:25:05 +01:00
CSoundMediator::dumpSong();
2000-11-22 23:52:08 +01:00
m_modeMenus[m_mode]->unselect();
2000-11-22 17:04:18 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-11 21:44:42 +01:00
int rh=0;
int rb=80;
int rspeed=5;
int rstep=1024;
2000-11-22 17:04:18 +01:00
void CFrontEndOptions::render()
{
POLY_G4 *g4;
2001-03-11 21:44:42 +01:00
int rgb[3];
2001-08-07 18:08:00 +02:00
int renderButtons=true;
2001-03-11 21:44:42 +01:00
rh+=rspeed;
rh&=4095;
2001-07-02 02:40:09 +02:00
//paulColourSpaceToRGB(rh,rb,rgb);
2000-11-22 17:04:18 +01:00
g4=GetPrimG4();
setXYWH(g4,0,0,512,256);
2001-03-11 21:44:42 +01:00
paulColourSpaceToRGB(rh,rb,rgb);
setRGB0(g4,rgb[0],rgb[1],rgb[2]);
paulColourSpaceToRGB(rh+(rstep*1),rb,rgb);
setRGB1(g4,rgb[0],rgb[1],rgb[2]);
paulColourSpaceToRGB(rh+(rstep*3),rb,rgb);
setRGB2(g4,rgb[0],rgb[1],rgb[2]);
paulColourSpaceToRGB(rh+(rstep*2),rb,rgb);
setRGB3(g4,rgb[0],rgb[1],rgb[2]);
2001-01-05 01:17:57 +01:00
AddPrimToList(g4,MAX_OT-1);
2000-11-22 17:04:18 +01:00
m_background->render();
2001-08-06 17:46:53 +02:00
// Button prompts
switch(m_mode)
{
case MODE__OPTIONS:
case MODE__CONTROL:
case MODE__SCREEN:
case MODE__SOUND:
break;
case MODE__LOAD:
switch(m_loadMode)
{
case LOADMODE__INIT:
case LOADMODE__CHECKING:
case LOADMODE__LOADING:
renderButtons=false;
break;
case LOADMODE__UNFORMATTED:
case LOADMODE__NODATA:
case LOADMODE__NOCARD:
case LOADMODE__CONFIRMLOAD:
case LOADMODE__LOADOK:
case LOADMODE__LOADERROR:
break;
}
}
if(renderButtons)
{
renderButtonPrompts();
}
2001-08-07 18:08:00 +02:00
// UI
if(m_mode==MODE__LOAD)
{
switch(m_loadMode)
{
case LOADMODE__INIT:
case LOADMODE__CHECKING:
case LOADMODE__LOADING:
break;
case LOADMODE__UNFORMATTED:
case LOADMODE__NODATA:
case LOADMODE__NOCARD:
case LOADMODE__LOADOK:
case LOADMODE__LOADERROR:
m_loadModeOKFrame->render();
break;
case LOADMODE__CONFIRMLOAD:
m_loadModeConfirmFrame->render();
break;
}
}
m_modeMenus[m_mode]->render();
2000-11-22 17:04:18 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndOptions::think(int _frames)
{
2000-11-23 20:55:33 +01:00
int i,j,button;
2001-07-31 18:01:36 +02:00
// Hide the VIBRATION option if vibration not available
if(PadCanVibrate(0))
{
m_vibGUIOption->unhide();
}
else
{
if(m_vibGUIOption->isSelected())
{
m_modeMenus[MODE__CONTROL]->selectPreviousItem();
}
m_vibGUIOption->hide();
}
2000-11-22 17:04:18 +01:00
m_background->think(_frames);
if(!CFader::isFading())
{
2001-07-03 22:28:04 +02:00
if(!m_musicStarted)
{
CSoundMediator::playSong();
m_musicStarted=true;
}
2000-11-22 23:52:08 +01:00
if(m_nextMode!=m_mode)
{
2001-07-02 02:40:09 +02:00
if(m_nextMode==MODE__LOAD)
{
// Entering LOAD option
setLoadMode(LOADMODE__INIT);
}
else if(m_mode==MODE__LOAD)
{
// Leaving LOAD option
MemCard::Stop();
delete m_saveLoadDatabase;
m_saveLoadDatabase=NULL;
}
if(m_mode!=MODE__LOAD)m_modeMenus[m_mode]->unselect();
2000-11-22 23:52:08 +01:00
m_mode=m_nextMode;
2001-07-02 02:40:09 +02:00
if(m_mode!=MODE__LOAD)m_modeMenus[m_mode]->select();
2001-04-24 16:48:00 +02:00
m_background->setFrame(s_modeBackground[m_mode]);
2000-11-22 23:52:08 +01:00
}
2001-07-02 02:40:09 +02:00
if(m_mode!=MODE__LOAD)m_modeMenus[m_mode]->think(_frames);
2000-11-22 23:52:08 +01:00
2001-08-02 20:05:59 +02:00
if(PadGetDown(0)&PAD_TRIANGLE)
{
if(m_mode==MODE__OPTIONS)
{
m_exitFlag=true;
}
else if(m_mode==MODE__LOAD)
{
switch(m_loadMode)
{
case LOADMODE__INIT:
case LOADMODE__CHECKING:
case LOADMODE__LOADING:
default:
break;
case LOADMODE__UNFORMATTED:
case LOADMODE__NODATA:
case LOADMODE__NOCARD:
case LOADMODE__CONFIRMLOAD:
case LOADMODE__LOADOK:
case LOADMODE__LOADERROR:
m_nextMode=MODE__OPTIONS;
break;
}
}
else
{
m_nextMode=MODE__OPTIONS;
}
}
2001-06-28 21:14:44 +02:00
if(m_mode==MODE__CONTROL)
{
if(m_vibrationStatus!=m_lastVibrationStatus)
{
m_lastVibrationStatus=m_vibrationStatus;
PadSetVibrationIsTurnedOn(0,m_vibrationStatus);
if(m_vibrationStatus==true)
{
CPadVibrationManager::setVibration(0,CPadVibrationManager::VIBE_MEDIUM);
}
}
}
2001-07-02 02:40:09 +02:00
else if(m_mode==MODE__SCREEN)
{
VidSetXYOfs(m_screenXOff,m_screenYOff);
}
2001-06-28 21:14:44 +02:00
else if(m_mode==MODE__SOUND)
2000-11-22 23:52:08 +01:00
{
2001-01-03 21:43:49 +01:00
if(m_bgmVolume!=CSoundMediator::getVolume(CSoundMediator::VOL_SONG))
2000-11-22 23:52:08 +01:00
{
2001-01-03 21:43:49 +01:00
CSoundMediator::setVolume(CSoundMediator::VOL_SONG,m_bgmVolume);
2000-11-22 23:52:08 +01:00
}
2001-01-03 21:43:49 +01:00
if(m_sfxVolume!=CSoundMediator::getVolume(CSoundMediator::VOL_SFX))
2000-11-22 23:52:08 +01:00
{
2001-01-03 21:43:49 +01:00
CSoundMediator::setVolume(CSoundMediator::VOL_SFX,m_sfxVolume);
2000-11-22 23:52:08 +01:00
}
2001-01-03 21:43:49 +01:00
if(m_speechVolume!=CSoundMediator::getVolume(CSoundMediator::VOL_SPEECH))
2000-11-22 23:52:08 +01:00
{
2001-01-03 21:43:49 +01:00
CSoundMediator::setVolume(CSoundMediator::VOL_SPEECH,m_speechVolume);
2000-11-22 23:52:08 +01:00
}
}
2001-07-02 02:40:09 +02:00
else if(m_mode==MODE__LOAD)
2000-11-24 17:14:55 +01:00
{
2001-07-02 02:40:09 +02:00
if(m_loadModeConfirmFrame->isSelected())m_loadModeConfirmFrame->think(_frames);
if(m_loadModeOKFrame->isSelected())m_loadModeOKFrame->think(_frames);
switch(m_loadMode)
{
case LOADMODE__INIT:
if(m_loadTimeInMode>10)
{
// If we init the memcard as the load page is selected then there's a small but noticable pause
// This hides it a bit..
MemCard::Start();
m_saveLoadDatabase=new ("saveloaddb") CSaveLoadDatabase();
setLoadMode(LOADMODE__CHECKING);
}
break;
case LOADMODE__CHECKING:
if(MemCard::GetCardStatus(0)==MemCard::CS_CardInserted)
{
// Scanning a new card..
m_loadTimeInMode=0;
}
else if(m_loadTimeInMode>60)
{
2001-07-02 17:46:34 +02:00
// Wait for card status to settle for one second before trusting it
2001-07-02 02:40:09 +02:00
if(MemCard::GetCardStatus(0)==MemCard::CS_NoCard)
{
setLoadMode(LOADMODE__NOCARD);
}
else if(MemCard::GetCardStatus(0)==MemCard::CS_UnformattedCard)
{
setLoadMode(LOADMODE__UNFORMATTED);
}
else if(MemCard::GetFileCountOnCard(0))
{
setLoadMode(LOADMODE__CONFIRMLOAD);
}
else
{
setLoadMode(LOADMODE__NODATA);
}
}
break;
case LOADMODE__UNFORMATTED:
2001-07-02 17:46:34 +02:00
if(MemCard::GetCardStatus(0)!=MemCard::CS_UnformattedCard)
{
setLoadMode(LOADMODE__CHECKING);
}
else if(m_loadUserResponse==USERRESPONSE__OK)
{
m_nextMode=MODE__OPTIONS;
}
break;
2001-07-02 02:40:09 +02:00
case LOADMODE__NODATA:
if(MemCard::GetCardStatus(0)!=MemCard::CS_ValidCard)
{
setLoadMode(LOADMODE__CHECKING);
}
else if(m_loadUserResponse==USERRESPONSE__OK)
{
m_nextMode=MODE__OPTIONS;
}
break;
case LOADMODE__NOCARD:
if(MemCard::GetCardStatus(0)!=MemCard::CS_NoCard)
{
setLoadMode(LOADMODE__CHECKING);
}
else if(m_loadUserResponse==USERRESPONSE__OK)
{
m_nextMode=MODE__OPTIONS;
}
break;
case LOADMODE__CONFIRMLOAD:
if(MemCard::GetCardStatus(0)!=MemCard::CS_ValidCard)
{
setLoadMode(LOADMODE__CHECKING);
}
else if(m_loadUserResponse==USERRESPONSE__YES)
{
setLoadMode(LOADMODE__LOADING);
2001-07-02 17:46:34 +02:00
if(!m_saveLoadDatabase->startLoad(0))
{
setLoadMode(LOADMODE__LOADERROR);
}
2001-07-02 02:40:09 +02:00
}
else if(m_loadUserResponse==USERRESPONSE__NO)
{
m_nextMode=MODE__OPTIONS;
}
break;
case LOADMODE__LOADING:
{
int stat=m_saveLoadDatabase->getLoadStatus();
if(stat==CSaveLoadDatabase::FINISHED_OK)
{
2001-07-02 18:03:27 +02:00
getValues();
2001-07-02 02:40:09 +02:00
setLoadMode(LOADMODE__LOADOK);
}
else if(stat==CSaveLoadDatabase::FAILED)
{
setLoadMode(LOADMODE__LOADERROR);
}
}
break;
case LOADMODE__LOADOK:
if(m_loadUserResponse==USERRESPONSE__OK)
{
m_nextMode=MODE__OPTIONS;
}
break;
case LOADMODE__LOADERROR:
if(m_loadUserResponse==USERRESPONSE__OK)
{
setLoadMode(LOADMODE__CHECKING);
}
break;
}
if(m_saveLoadDatabase)
{
m_saveLoadDatabase->think();
}
m_loadTimeInMode+=_frames;
2000-11-24 17:14:55 +01:00
}
2000-11-22 17:04:18 +01:00
}
if(!m_closingDown&&m_exitFlag)
{
CFader::setFadingOut();
m_closingDown=true;
}
2000-11-22 23:52:08 +01:00
2001-08-02 20:05:59 +02:00
2000-11-23 20:55:33 +01:00
// Change the icons on the control display
CPadConfig::setConfig(m_controlStyle);
for(i=0;i<CONTROL_COUNT;i++)
{
button=CPadConfig::getButton((CPadConfig::PAD_CFG)s_buttonOrder[i]);
for(j=0;j<ICON_COUNT;j++)
{
if(s_controlMap[j].m_padButton==button)
{
m_controlIcons[i]=s_controlMap[j].m_icon;
break;
}
}
}
2000-11-22 17:04:18 +01:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CFrontEndOptions::isReadyToExit()
{
return m_closingDown&&!CFader::isFading();
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
CFrontEndScene::FrontEndMode CFrontEndOptions::getNextMode()
{
return CFrontEndScene::MODE__MAIN_TITLES;
}
2001-07-02 18:03:27 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndOptions::getValues()
{
m_bgmVolume=CSoundMediator::getVolume(CSoundMediator::VOL_SONG);
m_sfxVolume=CSoundMediator::getVolume(CSoundMediator::VOL_SFX);
m_speechVolume=CSoundMediator::getVolume(CSoundMediator::VOL_SPEECH);
m_controlStyle=CPadConfig::getConfig();
m_vibrationStatus=m_lastVibrationStatus=PadGetVibrationIsTurnedOn(0);
m_screenXOff=VidGetXOfs();
m_screenYOff=VidGetYOfs();
}
2001-07-02 02:40:09 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndOptions::setLoadMode(int _newMode)
{
if(m_loadModeConfirmFrame->isSelected())m_loadModeConfirmFrame->unselect();
if(m_loadModeOKFrame->isSelected())m_loadModeOKFrame->unselect();
m_loadTextBox->setText(s_loadModeTextIds[_newMode]);
m_loadMode=_newMode;
m_loadTimeInMode=0;
m_loadUserResponse=USERRESPONSE__NONE;
switch(m_loadMode)
{
case LOADMODE__INIT:
case LOADMODE__CHECKING:
case LOADMODE__LOADING:
break;
case LOADMODE__UNFORMATTED:
case LOADMODE__NODATA:
case LOADMODE__NOCARD:
case LOADMODE__LOADOK:
case LOADMODE__LOADERROR:
m_loadModeOKFrame->select();
break;
case LOADMODE__CONFIRMLOAD:
m_loadModeConfirmFrame->select();
break;
}
}
2001-08-06 17:46:53 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CFrontEndOptions::renderButtonPrompts()
{
sFrameHdr *fh1,*fh2;
int x,y,width;
fh1=m_spriteBank->getFrameHeader(FRM__BUTX);
2001-08-07 18:20:46 +02:00
width=fh1->W+OPTIONS_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT+m_fontBank->getStringWidth(STR__FRONTEND__CROSS_TO_SELECT);
2001-08-06 17:46:53 +02:00
x=128-(width/2);
2001-08-07 18:20:46 +02:00
m_spriteBank->printFT4(fh1,x,OPTIONS_INSTRUCTIONS_Y_POS+OPTIONS_INSTRUCTIONS_BUTTON_Y_OFFSET,0,0,0);
x+=fh1->W+OPTIONS_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT;
m_fontBank->print(x,OPTIONS_INSTRUCTIONS_Y_POS,STR__FRONTEND__CROSS_TO_SELECT);
2001-08-06 17:46:53 +02:00
fh1=m_spriteBank->getFrameHeader(FRM__BUTT);
2001-08-07 18:20:46 +02:00
width=fh1->W+OPTIONS_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT+m_fontBank->getStringWidth(STR__FRONTEND__TRIANGLE_TO_GO_BACK);
2001-08-06 17:46:53 +02:00
x=256+128-(width/2);
2001-08-07 18:20:46 +02:00
m_spriteBank->printFT4(fh1,x,OPTIONS_INSTRUCTIONS_Y_POS+OPTIONS_INSTRUCTIONS_BUTTON_Y_OFFSET,0,0,0);
x+=fh1->W+OPTIONS_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT;
m_fontBank->print(x,OPTIONS_INSTRUCTIONS_Y_POS,STR__FRONTEND__TRIANGLE_TO_GO_BACK);
2001-08-06 17:46:53 +02:00
}
2000-11-22 17:04:18 +01:00
/*===========================================================================
end */