game options WIP2

svn-id: r18282
This commit is contained in:
Andrew Kurushin 2005-05-28 11:06:55 +00:00
parent 9543d99fc4
commit 3d1c969377
7 changed files with 360 additions and 51 deletions

View file

@ -74,15 +74,32 @@ static PanelButton ITE_ConversePanelButtons[] = {
}; };
static PanelButton ITE_OptionPanelButtons[] = { static PanelButton ITE_OptionPanelButtons[] = {
{kPanelButtonSlider, 284,19, 13,75, 0,'-',0, 0,0,0}, //slider-scroller {kPanelButtonOptionSlider, 284,19, 13,75, 0,'-',0, 0,0,0}, //slider-scroller
{kPanelButtonOption, 113,18, 45,17, 13,'r',0, 0,0,0}, //read speed {kPanelButtonOption, 113,18, 45,17, kTextReadingSpeed,'r',0, 0,0,0}, //read speed
{kPanelButtonOption, 113,37, 45,17, 16,'m',0, 0,0,0}, //music {kPanelButtonOption, 113,37, 45,17, kTextMusic,'m',0, 0,0,0}, //music
{kPanelButtonOption, 113,56, 45,17, 16,'n',0, 0,0,0}, //sound-noise {kPanelButtonOption, 113,56, 45,17, kTextSound,'n',0, 0,0,0}, //sound-noise
{kPanelButtonOption, 13,79, 135,17, 12,'q',0, 0,0,0}, //quit {kPanelButtonOption, 13,79, 135,17, kTextQuitGame,'q',0, 0,0,0}, //quit
{kPanelButtonOption, 13,98, 135,17, 17,'c',0, 0,0,0}, //continue {kPanelButtonOption, 13,98, 135,17, kTextContinuePlaying,'c',0, 0,0,0}, //continue
{kPanelButtonOption, 164,98, 57,17, 18,'l',0, 0,0,0}, //load {kPanelButtonOption, 164,98, 57,17, kTextLoad,'l',0, 0,0,0}, //load
{kPanelButtonOption, 241,98, 57,17, 19,'s',0, 0,0,0}, //save {kPanelButtonOption, 241,98, 57,17, kTextSave,'s',0, 0,0,0}, //save
{kPanelButtonOption, 166,20, 112,74, 0,'-',0, 0,0,0}, //slider {kPanelButtonOptionSaveFiles, 166,20, 112,74, 0,'-',0, 0,0,0}, //savefiles
{kPanelButtonOptionText,114,4, 0,0, kTextGameOptions,'-',0, 0,0,0}, // text: game options
{kPanelButtonOptionText,10,22, 0,0, kTextReadingSpeed,'-',0, 0,0,0}, // text: read speed
{kPanelButtonOptionText,73,41, 0,0, kTextMusic,'-',0, 0,0,0}, // text: music
{kPanelButtonOptionText,69,60, 0,0, kTextSound,'-',0, 0,0,0}, // text: noise
};
static PanelButton ITE_QuitPanelButtons[] = {
{kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO
};
static PanelButton ITE_LoadPanelButtons[] = {
{kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO
};
static PanelButton ITE_SavePanelButtons[] = {
{kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO
}; };
static GameDisplayInfo ITE_DisplayInfo = { static GameDisplayInfo ITE_DisplayInfo = {
@ -117,14 +134,27 @@ static GameDisplayInfo ITE_DisplayInfo = {
ITE_MainPanelButtons, ITE_MainPanelButtons,
4, 5, // converse Up & Down button indexies 4, 5, // converse Up & Down button indexies
0, 149, // converse panel offsets 0, 149, // converse panel offsets
ARRAYSIZE(ITE_ConversePanelButtons), ARRAYSIZE(ITE_ConversePanelButtons),
ITE_ConversePanelButtons, ITE_ConversePanelButtons,
8, 0, // save file index
8, // optionSaveFileVisible
8, 8, // option panel offsets 8, 8, // option panel offsets
ARRAYSIZE(ITE_OptionPanelButtons), ARRAYSIZE(ITE_OptionPanelButtons),
ITE_OptionPanelButtons ITE_OptionPanelButtons,
0, 0, // quit panel offsets
ARRAYSIZE(ITE_QuitPanelButtons),
ITE_QuitPanelButtons,
0, 0, // load panel offsets
ARRAYSIZE(ITE_LoadPanelButtons),
ITE_LoadPanelButtons,
0, 0, // save panel offsets
ARRAYSIZE(ITE_SavePanelButtons),
ITE_SavePanelButtons
}; };
static GameResourceDescription ITE_Resources = { static GameResourceDescription ITE_Resources = {
@ -254,6 +284,19 @@ static PanelButton IHNM_OptionPanelButtons[] = {
{kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO
}; };
static PanelButton IHNM_QuitPanelButtons[] = {
{kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO
};
static PanelButton IHNM_LoadPanelButtons[] = {
{kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO
};
static PanelButton IHNM_SavePanelButtons[] = {
{kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO
};
static GameDisplayInfo IHNM_DisplayInfo = { //TODO: fill it all static GameDisplayInfo IHNM_DisplayInfo = { //TODO: fill it all
640, 480, // logical width&height 640, 480, // logical width&height
@ -291,9 +334,23 @@ static GameDisplayInfo IHNM_DisplayInfo = { //TODO: fill it all
ARRAYSIZE(IHNM_ConversePanelButtons), ARRAYSIZE(IHNM_ConversePanelButtons),
IHNM_ConversePanelButtons, IHNM_ConversePanelButtons,
-1, -1, // save file index
0, // optionSaveFileVisible
0, 0, // option panel offsets 0, 0, // option panel offsets
ARRAYSIZE(IHNM_OptionPanelButtons), ARRAYSIZE(IHNM_OptionPanelButtons),
IHNM_OptionPanelButtons IHNM_OptionPanelButtons,
0, 0, // quit panel offsets
ARRAYSIZE(IHNM_QuitPanelButtons),
IHNM_QuitPanelButtons,
0, 0, // load panel offsets
ARRAYSIZE(IHNM_LoadPanelButtons),
IHNM_LoadPanelButtons,
0, 0, // save panel offsets
ARRAYSIZE(IHNM_SavePanelButtons),
IHNM_SavePanelButtons
}; };
static GameResourceDescription IHNM_Resources = { static GameResourceDescription IHNM_Resources = {

View file

@ -104,7 +104,7 @@ int SagaEngine::processInput() {
_render->toggleFlag(RF_RENDERPAUSE); _render->toggleFlag(RF_RENDERPAUSE);
break; break;
default: default:
_interface->processKeyCode(event.kbd.keycode); _interface->processAscii(event.kbd.ascii);
break; break;
} }
break; break;

View file

@ -148,6 +148,8 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) {
_optionPanel.x = _vm->getDisplayInfo().optionPanelXOffset; _optionPanel.x = _vm->getDisplayInfo().optionPanelXOffset;
_optionPanel.y = _vm->getDisplayInfo().optionPanelYOffset; _optionPanel.y = _vm->getDisplayInfo().optionPanelYOffset;
_optionPanel.currentButton = NULL; _optionPanel.currentButton = NULL;
_optionSaveFileSlider = _optionPanel.getButton(_vm->getDisplayInfo().optionSaveFileSliderIndex);
_optionSaveFilePanel = _optionPanel.getButton(_vm->getDisplayInfo().optionSaveFilePanelIndex);
_active = false; _active = false;
_panelMode = _lockedMode = kPanelNull; _panelMode = _lockedMode = kPanelNull;
@ -164,6 +166,8 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) {
_inventorySize = ITE_INVENTORY_SIZE; _inventorySize = ITE_INVENTORY_SIZE;
_saveReminderState = 0; _saveReminderState = 0;
_optionSaveFileTop = 0;
_inventory = (uint16 *)calloc(_inventorySize, sizeof(uint16)); _inventory = (uint16 *)calloc(_inventorySize, sizeof(uint16));
if (_inventory == NULL) { if (_inventory == NULL) {
error("Interface::Interface(): not enough memory"); error("Interface::Interface(): not enough memory");
@ -225,7 +229,7 @@ void Interface::restoreMode() {
void Interface::setMode(int mode, bool force) { void Interface::setMode(int mode, bool force) {
// TODO: Is this where we should hide/show the mouse cursor? // TODO: Is this where we should hide/show the mouse cursor?
debug(0, "Interface::setMode %i", mode);
if (mode == kPanelMain) { if (mode == kPanelMain) {
_inMainMode = true; _inMainMode = true;
_saveReminderState = 1; //TODO: blinking timeout _saveReminderState = 1; //TODO: blinking timeout
@ -255,6 +259,8 @@ void Interface::setMode(int mode, bool force) {
if (_panelMode == kPanelOption) { if (_panelMode == kPanelOption) {
_optionPanel.currentButton = NULL; _optionPanel.currentButton = NULL;
_vm->fillSaveList(); _vm->fillSaveList();
calcOptionSaveSlider();
_optionSaveFileTitleNumber = 0;
} }
} }
} }
@ -262,12 +268,12 @@ void Interface::setMode(int mode, bool force) {
draw(); draw();
} }
bool Interface::processKeyCode(int keyCode) { bool Interface::processAscii(uint16 ascii) {
int i; int i;
PanelButton *panelButton; PanelButton *panelButton;
switch (_panelMode) { switch (_panelMode) {
case kPanelNull: case kPanelNull:
if (keyCode == 27) {// Esc if (ascii == 27) {// Esc
if (_vm->_scene->isInDemo()) { if (_vm->_scene->isInDemo()) {
_vm->_scene->skipScene(); _vm->_scene->skipScene();
} else { } else {
@ -278,10 +284,13 @@ bool Interface::processKeyCode(int keyCode) {
break; break;
case kPanelOption: case kPanelOption:
//TODO: check input dialog keys //TODO: check input dialog keys
if (ascii == 27) {// Esc
ascii = 'c'; //continue
}
for (i = 0; i < _optionPanel.buttonsCount; i++) { for (i = 0; i < _optionPanel.buttonsCount; i++) {
panelButton = &_optionPanel.buttons[i]; panelButton = &_optionPanel.buttons[i];
if(panelButton->type == kPanelButtonOption) { if(panelButton->type == kPanelButtonOption) {
if (panelButton->keyChar == keyCode) { if (panelButton->ascii == ascii) {
setOption(panelButton); setOption(panelButton);
return true; return true;
} }
@ -291,7 +300,7 @@ bool Interface::processKeyCode(int keyCode) {
case kPanelMain: case kPanelMain:
for (i = 0; i < _mainPanel.buttonsCount; i++) { for (i = 0; i < _mainPanel.buttonsCount; i++) {
panelButton = &_mainPanel.buttons[i]; panelButton = &_mainPanel.buttons[i];
if (panelButton->keyChar == keyCode) { if (panelButton->ascii == ascii) {
if (panelButton->type == kPanelButtonVerb) { if (panelButton->type == kPanelButtonVerb) {
_vm->_script->setVerb(panelButton->id); _vm->_script->setVerb(panelButton->id);
} }
@ -301,9 +310,16 @@ bool Interface::processKeyCode(int keyCode) {
return true; return true;
} }
} }
if (ascii == 15) // ctrl-o
{
if (_saveReminderState > 0) {
setMode(kPanelOption);
return true;
}
}
break; break;
case kPanelConverse: case kPanelConverse:
switch (keyCode) { switch (ascii) {
case 'x': case 'x':
setMode(kPanelMain); setMode(kPanelMain);
if (_vm->_puzzle->isActive()) if (_vm->_puzzle->isActive())
@ -322,7 +338,7 @@ bool Interface::processKeyCode(int keyCode) {
case '2': case '2':
case '3': case '3':
case '4': case '4':
converseSetPos(keyCode); converseSetPos(ascii);
break; break;
} }
@ -444,10 +460,52 @@ void Interface::draw() {
drawInventory(backBuffer); drawInventory(backBuffer);
} }
void Interface::calcOptionSaveSlider() {
int totalFiles = _vm->getSaveFileNameCount();
int visibleFiles = _vm->getDisplayInfo().optionSaveFileVisible;
int height = _optionSaveFileSlider->height;
int sliderHeight;
int pos;
if (totalFiles < visibleFiles) {
totalFiles = visibleFiles;
}
sliderHeight = visibleFiles * height / totalFiles;
if (sliderHeight < 7) {
sliderHeight = 7;
}
if (totalFiles - visibleFiles <= 0) {
pos = 0;
} else {
pos = _optionSaveFileTop * (height - sliderHeight) / (totalFiles - visibleFiles);
}
_optionPanel.calcPanelButtonRect(_optionSaveFileSlider, _optionSaveRectTop);
_optionSaveRectBottom = _optionSaveRectSlider = _optionSaveRectTop;
_optionSaveRectTop.bottom = _optionSaveRectTop.top + pos;
_optionSaveRectTop.top++;
_optionSaveRectTop.right--;
_optionSaveRectSlider.top = _optionSaveRectTop.bottom;
_optionSaveRectSlider.bottom = _optionSaveRectSlider.top + sliderHeight;
_optionSaveRectBottom.top = _optionSaveRectSlider.bottom;
_optionSaveRectBottom.right--;
}
void Interface::drawOption() { void Interface::drawOption() {
const char *text;
SURFACE *backBuffer; SURFACE *backBuffer;
int i; int i;
int fontHeight;
uint j, idx;
int fgColor;
int bgColor;
Point origin; Point origin;
Rect rect;
Rect rect2;
PanelButton *panelButton; PanelButton *panelButton;
backBuffer = _vm->_gfx->getBackBuffer(); backBuffer = _vm->_gfx->getBackBuffer();
@ -461,20 +519,82 @@ void Interface::drawOption() {
if(panelButton->type == kPanelButtonOption) { if(panelButton->type == kPanelButtonOption) {
drawOptionPanelButtonText(backBuffer, panelButton); drawOptionPanelButtonText(backBuffer, panelButton);
} }
if (panelButton->type == kPanelButtonOptionText) {
text = _vm->getTextString(panelButton->id);
_optionPanel.calcPanelButtonRect(panelButton, rect);
_vm->_font->draw(MEDIUM_FONT_ID, backBuffer, text, 0, rect.left , rect.top,
_vm->getDisplayInfo().verbTextColor, _vm->getDisplayInfo().verbTextShadowColor, FONT_SHADOW); //TODO: create Option button colors constant
}
}
if(_optionSaveRectTop.height() > 0) {
drawRect(backBuffer, _optionSaveRectTop, kITEColorDarkGrey);
} }
drawButtonBox(backBuffer, _optionSaveRectSlider, true, _optionSaveFileSlider->state > 0);
if(_optionSaveRectBottom.height() > 0) {
drawRect(backBuffer, _optionSaveRectBottom, kITEColorDarkGrey);
}
_optionPanel.calcPanelButtonRect(_optionSaveFilePanel, rect);
rect2 = rect;
fontHeight = _vm->_font->getHeight(SMALL_FONT_ID);
for (j = 0; j < _vm->getDisplayInfo().optionSaveFileVisible; j++) {
bgColor = kITEColorDarkGrey0C;
fgColor = kITEColorBrightWhite;
idx = j + _optionSaveFileTop;
if (idx == _optionSaveFileTitleNumber) {
SWAP(bgColor, fgColor);
}
if (idx < _vm->getSaveFileNameCount()) {
rect2.top = rect.top + j * (fontHeight + 1);
rect2.bottom = rect2.top + fontHeight;
backBuffer->fillRect(rect2, bgColor);
text = _vm->getSaveFileName(idx);
_vm->_font->draw(SMALL_FONT_ID, backBuffer, text, 0,
rect.left + 1, rect2.top, fgColor, 0, 0);
}
}
} }
void Interface::handleOptionUpdate(const Point& mousePoint) { void Interface::handleOptionUpdate(const Point& mousePoint) {
int i; int i;
int16 mouseY;
Rect rect;
int totalFiles = _vm->getSaveFileNameCount();
int visibleFiles = _vm->getDisplayInfo().optionSaveFileVisible;
if (_vm->mouseButtonPressed()) {
if (_optionSaveFileSlider->state > 0) {
_optionPanel.calcPanelButtonRect(_optionSaveFileSlider, rect);
mouseY = mousePoint.y - rect.top -_optionSaveFileMouseOff;
if (totalFiles - visibleFiles <= 0) {
_optionSaveFileTop = 0;
} else {
_optionSaveFileTop = mouseY * (totalFiles - visibleFiles) /
(_optionSaveFileSlider->height - _optionSaveRectSlider.height());
}
_optionSaveFileTop = clamp(0, _optionSaveFileTop, _vm->getSaveFileNameCount() - _vm->getDisplayInfo().optionSaveFileVisible);
calcOptionSaveSlider();
}
}
_optionPanel.currentButton = optionHitTest(mousePoint); _optionPanel.currentButton = optionHitTest(mousePoint);
bool released = (_optionPanel.currentButton != NULL) && (_optionPanel.currentButton->state > 0) && (!_vm->mouseButtonPressed()); bool releasedButton = (_optionPanel.currentButton != NULL) && (_optionPanel.currentButton->state > 0) && (!_vm->mouseButtonPressed());
if (!_vm->mouseButtonPressed()) { if (!_vm->mouseButtonPressed()) {
for (i = 0; i < _optionPanel.buttonsCount; i++) { for (i = 0; i < _optionPanel.buttonsCount; i++) {
_optionPanel.buttons[i].state = 0; _optionPanel.buttons[i].state = 0;
} }
} }
if (released) { if (releasedButton) {
setOption(_optionPanel.currentButton); setOption(_optionPanel.currentButton);
} }
@ -483,6 +603,7 @@ void Interface::handleOptionUpdate(const Point& mousePoint) {
void Interface::handleOptionClick(const Point& mousePoint) { void Interface::handleOptionClick(const Point& mousePoint) {
int i; int i;
Rect rect;
_optionPanel.currentButton = optionHitTest(mousePoint); _optionPanel.currentButton = optionHitTest(mousePoint);
for (i = 0; i < _optionPanel.buttonsCount; i++) { for (i = 0; i < _optionPanel.buttonsCount; i++) {
@ -492,18 +613,50 @@ void Interface::handleOptionClick(const Point& mousePoint) {
if (_optionPanel.currentButton == NULL) { if (_optionPanel.currentButton == NULL) {
return; return;
} }
if (_optionPanel.currentButton == _optionSaveFileSlider) {
if ((_optionSaveRectTop.height() > 0) && (mousePoint.y < _optionSaveRectTop.bottom)) {
_optionSaveFileTop -= _vm->getDisplayInfo().optionSaveFileVisible;
} else {
if ((_optionSaveRectBottom.height() > 0) && (mousePoint.y >= _optionSaveRectBottom.top)) {
_optionSaveFileTop += _vm->getDisplayInfo().optionSaveFileVisible;
} else {
if (_vm->getDisplayInfo().optionSaveFileVisible < _vm->getSaveFileNameCount()) {
_optionSaveFileMouseOff = mousePoint.y - _optionSaveRectSlider.top;
_optionPanel.currentButton->state = 1;
}
}
}
_optionPanel.currentButton->state = 1; _optionSaveFileTop = clamp(0, _optionSaveFileTop, _vm->getSaveFileNameCount() - _vm->getDisplayInfo().optionSaveFileVisible);
calcOptionSaveSlider();
} else {
if (_optionPanel.currentButton == _optionSaveFilePanel) {
_optionPanel.calcPanelButtonRect(_optionSaveFilePanel, rect);
_optionSaveFileTitleNumber = (mousePoint.y - rect.top) / (_vm->_font->getHeight(SMALL_FONT_ID) + 1);
if (_optionSaveFileTitleNumber < 0) {
_optionSaveFileTitleNumber = 0;
}
if (_optionSaveFileTitleNumber >= _vm->getDisplayInfo().optionSaveFileVisible) {
_optionSaveFileTitleNumber = _vm->getDisplayInfo().optionSaveFileVisible - 1;
}
_optionSaveFileTitleNumber += _optionSaveFileTop;
if (_optionSaveFileTitleNumber >= _vm->getSaveFileNameCount()) {
_optionSaveFileTitleNumber = _vm->getSaveFileNameCount() - 1;
}
} else {
_optionPanel.currentButton->state = 1;
}
}
} }
void Interface::setOption(PanelButton *panelButton) { void Interface::setOption(PanelButton *panelButton) {
switch (panelButton->keyChar) { switch (panelButton->id) {
case 'c': case kTextContinuePlaying:
setMode(kPanelMain); setMode(kPanelMain);
break; break;
case 'q': case kTextQuitGame:
_vm->shutDown(); _vm->shutDown();
break; break;
} }
@ -511,7 +664,7 @@ void Interface::setOption(PanelButton *panelButton) {
void Interface::update(const Point& mousePoint, int updateFlag) { void Interface::update(const Point& mousePoint, int updateFlag) {
if (_vm->_scene->isInDemo() || _panelMode == kPanelFade) { if (_vm->_scene->isInDemo() || _panelMode == kPanelFade || !_active) {
return; return;
} }
@ -842,11 +995,37 @@ void Interface::setVerbState(int verb, int state) {
draw(); draw();
} }
void Interface::drawButtonBox(SURFACE *ds, const Rect& rect, bool down) { void Interface::drawButtonBox(SURFACE *ds, const Rect& rect, bool slider, bool down) {
byte cornerColor = 0x8b; byte cornerColor;
byte frameColor = 0x0f; byte frameColor;
byte fillColor = 0x96; byte fillColor;
byte odl = 0x8a, our = 0x94, idl = 0x97, iur = 0x95; byte solidColor;
byte odl, our, idl, iur;
if (slider) {
cornerColor = 0x8b;
frameColor = kITEColorBlack;
fillColor = kITEColorLightBlue96;
odl = kITEColorDarkBlue8a;
our = kITEColorLightBlue92;
idl = 0x89;
iur = 0x94;
solidColor = down ? kITEColorLightBlue94 : kITEColorLightBlue96;
} else {
cornerColor = 0x8b;
frameColor = kITEColorBlack;
solidColor = fillColor = kITEColorLightBlue96;
odl = kITEColorDarkBlue8a;
our = kITEColorLightBlue94;
idl = 0x97;
iur = 0x95;
if (down) {
SWAP(odl, our);
SWAP(idl, iur);
}
}
int x = rect.left; int x = rect.left;
int y = rect.top; int y = rect.top;
int w = rect.width(); int w = rect.width();
@ -863,10 +1042,6 @@ void Interface::drawButtonBox(SURFACE *ds, const Rect& rect, bool down) {
ds->vLine(x, y + 1, y + 1 + h - 2, frameColor); ds->vLine(x, y + 1, y + 1 + h - 2, frameColor);
ds->vLine(xe, y + 1, y + 1 + h - 2, frameColor); ds->vLine(xe, y + 1, y + 1 + h - 2, frameColor);
if (down) {
SWAP(odl, our);
SWAP(idl, iur);
}
x++; x++;
y++; y++;
xe--; xe--;
@ -895,19 +1070,31 @@ void Interface::drawButtonBox(SURFACE *ds, const Rect& rect, bool down) {
w -= 2; h -= 2; w -= 2; h -= 2;
Common::Rect fill(x, y, x + w, y + h); Common::Rect fill(x, y, x + w, y + h);
ds->fillRect(fill, fillColor); ds->fillRect(fill, solidColor);
} }
void Interface::drawOptionPanelButtonText(SURFACE *ds, PanelButton *panelButton) { void Interface::drawOptionPanelButtonText(SURFACE *ds, PanelButton *panelButton) {
const char *text; const char *text;
int textId;
int textWidth; int textWidth;
int textHeight; int textHeight;
Point point; Point point;
int textColor; int textColor;
Rect rect; Rect rect;
//TODO: draw box!
text = _vm->getTextString(panelButton->id); textId = panelButton->id;
switch(panelButton->id) {
case(kTextReadingSpeed):
textId = kTextFast;
break;
case(kTextMusic):
textId = kTextOn;
break;
case(kTextSound):
textId = kTextOn;
break;
}
text = _vm->getTextString(textId);
textWidth = _vm->_font->getStringWidth(MEDIUM_FONT_ID, text, 0, 0); textWidth = _vm->_font->getStringWidth(MEDIUM_FONT_ID, text, 0, 0);
textHeight = _vm->_font->getHeight(MEDIUM_FONT_ID); textHeight = _vm->_font->getHeight(MEDIUM_FONT_ID);
@ -922,7 +1109,7 @@ void Interface::drawOptionPanelButtonText(SURFACE *ds, PanelButton *panelButton)
} }
_optionPanel.calcPanelButtonRect(panelButton, rect); _optionPanel.calcPanelButtonRect(panelButton, rect);
drawButtonBox(ds, rect, panelButton->state > 0); drawButtonBox(ds, rect, false, panelButton->state > 0);
_vm->_font->draw(MEDIUM_FONT_ID, ds, text, 0, point.x , point.y, textColor, _vm->getDisplayInfo().verbTextShadowColor, FONT_SHADOW); //TODO: create Option button colors constant _vm->_font->draw(MEDIUM_FONT_ID, ds, text, 0, point.x , point.y, textColor, _vm->getDisplayInfo().verbTextShadowColor, FONT_SHADOW); //TODO: create Option button colors constant
} }
@ -1207,7 +1394,7 @@ void Interface::handleConverseClick(const Point& mousePoint) {
} }
if (_conversePanel.currentButton->type == kPanelButtonConverseText) { if (_conversePanel.currentButton->type == kPanelButtonConverseText) {
converseSetPos(_conversePanel.currentButton->keyChar); converseSetPos(_conversePanel.currentButton->ascii);
} }
if (_conversePanel.currentButton->type == kPanelButtonArrow) { if (_conversePanel.currentButton->type == kPanelButtonArrow) {

View file

@ -134,10 +134,16 @@ enum ITEColors {
kITEColorLightGrey = 0x04, kITEColorLightGrey = 0x04,
kITEColorGrey = 0x0a, kITEColorGrey = 0x0a,
kITEColorDarkGrey = 0x0b, kITEColorDarkGrey = 0x0b,
kITEColorDarkGrey0C = 0x0C,
kITEColorGreen = 0xba, kITEColorGreen = 0xba,
kITEColorBlack = 0x0f, kITEColorBlack = 0x0f,
kITEColorRed = 0x65, kITEColorRed = 0x65,
kITEColorBlue = 0x93 kITEColorDarkBlue8a = 0x8a,
kITEColorBlue89 = 0x89,
kITEColorLightBlue92 = 0x92,
kITEColorBlue = 0x93,
kITEColorLightBlue94 = 0x94,
kITEColorLightBlue96 = 0x96
}; };
@ -175,7 +181,7 @@ public:
void drawStatusBar(); void drawStatusBar();
void setVerbState(int verb, int state); void setVerbState(int verb, int state);
bool processKeyCode(int keyCode); bool processAscii(uint16 ascii);
private: private:
void drawInventory(SURFACE *backBuffer); void drawInventory(SURFACE *backBuffer);
@ -219,7 +225,7 @@ private:
void handleConverseClick(const Point& mousePoint); // converse panel click void handleConverseClick(const Point& mousePoint); // converse panel click
PanelButton *optionHitTest(const Point& mousePoint) { PanelButton *optionHitTest(const Point& mousePoint) {
return _optionPanel.hitTest(mousePoint, kPanelAllButtons); return _optionPanel.hitTest(mousePoint, kPanelButtonOptionSaveFiles | kPanelButtonOption | kPanelButtonOptionSlider);
} }
void handleOptionUpdate(const Point& mousePoint); // option panel update void handleOptionUpdate(const Point& mousePoint); // option panel update
void handleOptionClick(const Point& mousePoint); // option panel click void handleOptionClick(const Point& mousePoint); // option panel click
@ -230,11 +236,11 @@ private:
void setOption(PanelButton *panelButton); void setOption(PanelButton *panelButton);
void drawOptionPanelButtonText(SURFACE *ds, PanelButton *panelButton); void drawOptionPanelButtonText(SURFACE *ds, PanelButton *panelButton);
void drawButtonBox(SURFACE *ds, const Rect& rect, bool down); void drawButtonBox(SURFACE *ds, const Rect &rect, bool slider, bool down);
void drawPanelButtonArrow(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton); void drawPanelButtonArrow(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton);
void drawVerbPanelText(SURFACE *ds, PanelButton *panelButton, int textColor, int textShadowColor); void drawVerbPanelText(SURFACE *ds, PanelButton *panelButton, int textColor, int textShadowColor);
void drawVerbPanel(SURFACE *backBuffer, PanelButton* panelButton); void drawVerbPanel(SURFACE *backBuffer, PanelButton* panelButton);
void calcOptionSaveSlider();
public: public:
void converseInit(void); void converseInit(void);
void converseClear(void); void converseClear(void);
@ -267,6 +273,8 @@ private:
SpriteList _scenePortraits; SpriteList _scenePortraits;
PanelButton *_verbTypeToPanelButton[kVerbTypesMax]; PanelButton *_verbTypeToPanelButton[kVerbTypesMax];
InterfacePanel _optionPanel; InterfacePanel _optionPanel;
PanelButton * _optionSaveFileSlider;
PanelButton * _optionSaveFilePanel;
int _saveReminderState; int _saveReminderState;
bool _active; bool _active;
@ -296,6 +304,14 @@ private:
int _converseStartPos; int _converseStartPos;
int _converseEndPos; int _converseEndPos;
int _conversePos; int _conversePos;
uint _optionSaveFileTop;
uint _optionSaveFileTitleNumber;
int16 _optionSaveFileMouseOff;
Rect _optionSaveRectTop;
Rect _optionSaveRectSlider;
Rect _optionSaveRectBottom;
}; };
} // End of namespace Saga } // End of namespace Saga

View file

@ -351,7 +351,7 @@ void Puzzle::giveHint(void) {
if (_hintCount < 3) { if (_hintCount < 3) {
_vm->_actor->nonActorSpeech(&hintStr[_lang][_hintCount], 1, 0 ); _vm->_actor->nonActorSpeech(&hintStr[_lang][_hintCount], 1, 0 );
} else { } else {
int piece; int piece = 0;
for (i = PUZZLE_PIECES - 1; i >= 0; i--) { for (i = PUZZLE_PIECES - 1; i >= 0; i--) {
piece = _piecePriority[i]; piece = _piecePriority[i];

View file

@ -151,8 +151,13 @@ enum PanelButtonType {
kPanelButtonArrow = 2, kPanelButtonArrow = 2,
kPanelButtonConverseText = 4, kPanelButtonConverseText = 4,
kPanelButtonInventory = 8, kPanelButtonInventory = 8,
kPanelButtonOption = 0x10, kPanelButtonOption = 0x10,
kPanelButtonSlider = 0x20, kPanelButtonOptionSlider = 0x20,
kPanelButtonOptionSaveFiles = 0x40,
kPanelButtonOptionText = 0x80,
kPanelButtonReserved = 0x100,
kPanelAllButtons = 0xFFFFF kPanelAllButtons = 0xFFFFF
}; };
@ -328,7 +333,7 @@ struct PanelButton {
int width; int width;
int height; int height;
int id; int id;
int keyChar; uint16 ascii;
int state; int state;
int upSpriteNumber; int upSpriteNumber;
int downSpriteNumber; int downSpriteNumber;
@ -384,10 +389,29 @@ struct GameDisplayInfo {
int conversePanelButtonsCount; int conversePanelButtonsCount;
PanelButton *conversePanelButtons; PanelButton *conversePanelButtons;
int optionSaveFilePanelIndex;
int optionSaveFileSliderIndex;
uint optionSaveFileVisible;
int optionPanelXOffset; int optionPanelXOffset;
int optionPanelYOffset; int optionPanelYOffset;
int optionPanelButtonsCount; int optionPanelButtonsCount;
PanelButton *optionPanelButtons; PanelButton *optionPanelButtons;
int quitPanelXOffset;
int quitPanelYOffset;
int quitPanelButtonsCount;
PanelButton *quitPanelButtons;
int loadPanelXOffset;
int loadPanelYOffset;
int loadPanelButtonsCount;
PanelButton *loadPanelButtons;
int savePanelXOffset;
int savePanelYOffset;
int savePanelButtonsCount;
PanelButton *savePanelButtons;
}; };
@ -470,6 +494,12 @@ public:
void fillSaveList(); void fillSaveList();
char *calcSaveFileName(uint slotNumber); char *calcSaveFileName(uint slotNumber);
char *getSaveFileName(uint idx); char *getSaveFileName(uint idx);
bool saveListFull() const {
return _saveFileNamesMaxCount == _saveFileNamesCount;
}
uint getSaveFileNameCount() const {
return saveListFull() ? _saveFileNamesCount : _saveFileNamesCount + 1;
}
int _soundEnabled; int _soundEnabled;
int _musicEnabled; int _musicEnabled;
@ -545,6 +575,7 @@ public:
private: private:
Common::String _targetName; Common::String _targetName;
uint _saveFileNamesMaxCount;
uint _saveFileNamesCount; uint _saveFileNamesCount;
char _saveFileNames[MAX_SAVES][SAVE_TITLE_SIZE]; char _saveFileNames[MAX_SAVES][SAVE_TITLE_SIZE];
Point _mousePos; Point _mousePos;

View file

@ -48,6 +48,8 @@ struct SaveGameHeader {
char name[SAVE_TITLE_SIZE]; char name[SAVE_TITLE_SIZE];
}; };
static char emptySlot[] = "[New Save Game]";
//TODO: //TODO:
// - delete savegame // - delete savegame
@ -61,7 +63,11 @@ char *SagaEngine::getSaveFileName(uint idx) {
if (idx >= MAX_SAVES) { if (idx >= MAX_SAVES) {
error("getSaveFileName wrong idx"); error("getSaveFileName wrong idx");
} }
return _saveFileNames[idx]; if (saveListFull()) {
return _saveFileNames[idx];
} else {
return (idx == 0) ? emptySlot : _saveFileNames[idx - 1];
}
} }
@ -76,11 +82,16 @@ void SagaEngine::fillSaveList() {
name[strlen(name) - 2] = 0; name[strlen(name) - 2] = 0;
_saveFileMan->listSavefiles(name, marks, MAX_SAVES); _saveFileMan->listSavefiles(name, marks, MAX_SAVES);
_saveFileNamesMaxCount = 0;
for (i = 0; i < MAX_SAVES; i++) { for (i = 0; i < MAX_SAVES; i++) {
if (marks[i]) {
_saveFileNamesMaxCount++;
}
_saveFileNames[i][0] = 0; _saveFileNames[i][0] = 0;
} }
_saveFileNamesCount = 0; _saveFileNamesCount = 0;
i = 0; i = 0;
while (i < MAX_SAVES) { while (i < MAX_SAVES) {
if (marks[i]) { if (marks[i]) {
@ -99,6 +110,13 @@ void SagaEngine::fillSaveList() {
} }
i++; i++;
} }
for (i = 0; i < MAX_SAVES; i++) {
sprintf(_saveFileNames[i], "test%i",i);
}
_saveFileNamesCount = 14;
} }