mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 18:06:26 +00:00
ULTIMA1: Giving pence to king now working
This commit is contained in:
parent
010fc6cd53
commit
5fb10f662d
@ -75,9 +75,11 @@ bool TextInput::KeypressMsg(CKeypressMsg &msg) {
|
||||
setDirty();
|
||||
}
|
||||
} else if (msg._keyState.keycode == Common::KEYCODE_RETURN || msg._keyState.keycode == Common::KEYCODE_KP_ENTER) {
|
||||
_game->_textCursor->setVisible(false);
|
||||
CTextInputMsg inputMsg(_text, false);
|
||||
inputMsg.execute(_respondTo);
|
||||
} else if (msg._keyState.keycode == Common::KEYCODE_ESCAPE) {
|
||||
_game->_textCursor->setVisible(false);
|
||||
CTextInputMsg inputMsg("", true);
|
||||
inputMsg.execute(_respondTo);
|
||||
}
|
||||
|
@ -666,9 +666,9 @@ const char *const SRC_GROCERY_FIND_PACKS = "Thou dost find %d bags of food!";
|
||||
const char *const SRC_WITH_KING = " with king";
|
||||
const char *const SRC_HE_IS_NOT_HERE = "He is not here!";
|
||||
const char *const SRC_HE_REJECTS_OFFER = "He rejects thine offer!";
|
||||
const char *const SRC_KING_TEXT[11] = {
|
||||
const char *const SRC_KING_TEXT[10] = {
|
||||
"Dost thou offer pence\ror service: ", "neither", "pence", "service", "How much? ",
|
||||
"none", "Thou hast not that much!", "In return I give unto thee %u hit points",
|
||||
"Thou hast not that much!", "In return I give unto\rthee %u hit points",
|
||||
"Thou art on a quest for me already!", "Go now and kill a", "Go forth and find a"
|
||||
};
|
||||
|
||||
@ -801,7 +801,7 @@ GameResources::GameResources(Shared::Resources *resManager) : LocalResourceFile(
|
||||
WITH_KING = SRC_WITH_KING;
|
||||
HE_IS_NOT_HERE = SRC_HE_IS_NOT_HERE;
|
||||
HE_REJECTS_OFFER = SRC_HE_REJECTS_OFFER;
|
||||
Common::copy(&SRC_KING_TEXT[0], &SRC_KING_TEXT[11], KING_TEXT);
|
||||
Common::copy(&SRC_KING_TEXT[0], &SRC_KING_TEXT[10], KING_TEXT);
|
||||
}
|
||||
|
||||
void GameResources::synchronize() {
|
||||
@ -928,7 +928,7 @@ void GameResources::synchronize() {
|
||||
syncString(WITH_KING);
|
||||
syncString(HE_IS_NOT_HERE);
|
||||
syncString(HE_REJECTS_OFFER);
|
||||
syncStrings(KING_TEXT, 11);
|
||||
syncStrings(KING_TEXT, 10);
|
||||
}
|
||||
|
||||
} // End of namespace Ultima1
|
||||
|
@ -159,7 +159,7 @@ public:
|
||||
const char *WITH_KING;
|
||||
const char *HE_IS_NOT_HERE;
|
||||
const char *HE_REJECTS_OFFER;
|
||||
const char *KING_TEXT[11];
|
||||
const char *KING_TEXT[10];
|
||||
|
||||
public:
|
||||
GameResources();
|
||||
|
@ -50,6 +50,13 @@ void Dialog::getKeypress() {
|
||||
msg.execute(infoArea);
|
||||
}
|
||||
|
||||
void Dialog::getInput(bool isNumeric, size_t maxCharacters) {
|
||||
TreeItem *infoArea = _game->findByName("Info");
|
||||
|
||||
Shared::CInfoGetInput msg(this, isNumeric, maxCharacters);
|
||||
msg.execute(infoArea);
|
||||
}
|
||||
|
||||
void Dialog::draw() {
|
||||
// Redraw the game's info area
|
||||
U1Gfx::Info *infoArea = dynamic_cast<U1Gfx::Info *>(_game->findByName("Info"));
|
||||
|
@ -66,6 +66,11 @@ protected:
|
||||
* Prompts for a keypress
|
||||
*/
|
||||
void getKeypress();
|
||||
|
||||
/**
|
||||
* Prompts for an input
|
||||
*/
|
||||
void getInput(bool isNumeric = true, size_t maxCharacters = 4);
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -33,6 +33,7 @@ namespace U1Dialogs {
|
||||
BEGIN_MESSAGE_MAP(King, Dialog)
|
||||
ON_MESSAGE(ShowMsg)
|
||||
ON_MESSAGE(CharacterInputMsg)
|
||||
ON_MESSAGE(TextInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
King::King(Ultima1Game *game) : Dialog(game), _mode(SELECT) {
|
||||
@ -49,7 +50,7 @@ void King::draw() {
|
||||
Dialog::draw();
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
|
||||
if (_mode != SELECT) {
|
||||
if (_mode == SERVICE) {
|
||||
// Draw the background and frame
|
||||
s.clear();
|
||||
s.frameRect(Rect(3, 3, _bounds.width() - 3, _bounds.height() - 3), getGame()->_borderColor);
|
||||
@ -62,18 +63,33 @@ void King::draw() {
|
||||
|
||||
void King::setMode(KingMode mode) {
|
||||
_mode = mode;
|
||||
|
||||
switch (_mode) {
|
||||
case PENCE:
|
||||
addInfoMsg(_game->_res->KING_TEXT[2]); // Pence
|
||||
addInfoMsg(_game->_res->KING_TEXT[4], false); // How much?
|
||||
getInput();
|
||||
break;
|
||||
|
||||
case SERVICE:
|
||||
addInfoMsg(_game->_res->KING_TEXT[3]);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
setDirty();
|
||||
}
|
||||
|
||||
bool King::CharacterInputMsg(CCharacterInputMsg &msg) {
|
||||
switch (_mode) {
|
||||
case SELECT:
|
||||
if (msg._keyState.keycode == Common::KEYCODE_s)
|
||||
setMode(SERVICE);
|
||||
else if (msg._keyState.keycode == Common::KEYCODE_s)
|
||||
if (msg._keyState.keycode == Common::KEYCODE_p)
|
||||
setMode(PENCE);
|
||||
else if (msg._keyState.keycode == Common::KEYCODE_s)
|
||||
setMode(SERVICE);
|
||||
else
|
||||
nothing();
|
||||
neither();
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -83,8 +99,48 @@ bool King::CharacterInputMsg(CCharacterInputMsg &msg) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void King::nothing() {
|
||||
addInfoMsg(_game->_res->NOTHING);
|
||||
bool King::TextInputMsg(CTextInputMsg &msg) {
|
||||
assert(_mode == PENCE);
|
||||
const Shared::Character &c = *_game->_party;
|
||||
uint amount = atoi(msg._text.c_str());
|
||||
|
||||
if (msg._escaped || !amount) {
|
||||
none();
|
||||
} else if (amount > c._coins) {
|
||||
notThatMuch();
|
||||
} else {
|
||||
addInfoMsg(Common::String::format("%u", amount));
|
||||
giveHitPoints(amount * 3 / 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void King::neither() {
|
||||
addInfoMsg(_game->_res->KING_TEXT[1]);
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
void King::none() {
|
||||
addInfoMsg(_game->_res->NONE);
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
void King::notThatMuch() {
|
||||
addInfoMsg(_game->_res->KING_TEXT[5]);
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
void King::giveHitPoints(uint amount) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
assert(amount <= c._coins);
|
||||
c._coins -= amount;
|
||||
c._hitPoints += amount;
|
||||
|
||||
addInfoMsg(Common::String::format(_game->_res->KING_TEXT[6], amount));
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ namespace U1Dialogs {
|
||||
|
||||
using Shared::CShowMsg;
|
||||
using Shared::CCharacterInputMsg;
|
||||
using Shared::CTextInputMsg;
|
||||
|
||||
/**
|
||||
* Dialog for talking to kings
|
||||
@ -40,20 +41,35 @@ class King : public Dialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool ShowMsg(CShowMsg &msg);
|
||||
bool CharacterInputMsg(CCharacterInputMsg &msg);
|
||||
|
||||
bool TextInputMsg(CTextInputMsg &msg);
|
||||
enum KingMode { SELECT, PENCE, SERVICE };
|
||||
private:
|
||||
KingMode _mode;
|
||||
private:
|
||||
/**
|
||||
* Nothing selected
|
||||
*/
|
||||
void nothing();
|
||||
|
||||
/**
|
||||
* Set the mode
|
||||
*/
|
||||
void setMode(KingMode mode);
|
||||
|
||||
/**
|
||||
* Neither option (buy, service) selected
|
||||
*/
|
||||
void neither();
|
||||
|
||||
/**
|
||||
* No pence entered
|
||||
*/
|
||||
void none();
|
||||
|
||||
/**
|
||||
* Not that much
|
||||
*/
|
||||
void notThatMuch();
|
||||
|
||||
/**
|
||||
* Give hit points
|
||||
*/
|
||||
void giveHitPoints(uint amount);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user