diff options
| -rw-r--r-- | sword2/controls.cpp | 52 | ||||
| -rw-r--r-- | sword2/controls.h | 1 | ||||
| -rw-r--r-- | sword2/resman.cpp | 6 | ||||
| -rw-r--r-- | sword2/save_rest.cpp | 7 | ||||
| -rw-r--r-- | sword2/sword2.cpp | 16 | ||||
| -rw-r--r-- | sword2/sword2.h | 1 | 
6 files changed, 67 insertions, 16 deletions
| diff --git a/sword2/controls.cpp b/sword2/controls.cpp index 933941bcae..bb1d7bb7e9 100644 --- a/sword2/controls.cpp +++ b/sword2/controls.cpp @@ -148,16 +148,16 @@ public:  	FontRendererGui(Gui *gui, int fontId);  	~FontRendererGui(); -	void fetchText(int textId, uint8 *buf); +	void fetchText(uint32 textId, uint8 *buf);  	int getCharWidth(uint8 c);  	int getCharHeight(uint8 c);  	int getTextWidth(uint8 *text); -	int getTextWidth(int textId); +	int getTextWidth(uint32 textId);  	void drawText(uint8 *text, int x, int y, int alignment = kAlignLeft); -	void drawText(int textId, int x, int y, int alignment = kAlignLeft); +	void drawText(uint32 textId, int x, int y, int alignment = kAlignLeft);  };  FontRendererGui::FontRendererGui(Gui *gui, int fontId) @@ -186,7 +186,7 @@ FontRendererGui::~FontRendererGui() {  		_gui->_vm->_graphics->deleteSurface(_glyph[i]._data);  } -void FontRendererGui::fetchText(int textId, uint8 *buf) { +void FontRendererGui::fetchText(uint32 textId, uint8 *buf) {  	uint8 *data = _gui->_vm->fetchTextLine(_gui->_vm->_resman->openResource(textId / SIZE), textId & 0xffff);  	int i; @@ -220,7 +220,7 @@ int FontRendererGui::getTextWidth(uint8 *text) {  	return textWidth;  } -int FontRendererGui::getTextWidth(int textId) { +int FontRendererGui::getTextWidth(uint32 textId) {  	uint8 text[MAX_STRING_LEN];  	fetchText(textId, text); @@ -259,7 +259,7 @@ void FontRendererGui::drawText(uint8 *text, int x, int y, int alignment) {  	}  } -void FontRendererGui::drawText(int textId, int x, int y, int alignment) { +void FontRendererGui::drawText(uint32 textId, int x, int y, int alignment) {  	uint8 text[MAX_STRING_LEN];  	fetchText(textId, text); @@ -784,20 +784,23 @@ public:  };  /** - * A "mini" dialog is basically a yes/no question. + * A "mini" dialog is usually a yes/no question, but also used for the + * restart/restore dialog at the beginning of the game.   */  class MiniDialog : public Dialog {  private: -	int _textId; +	uint32 _headerTextId; +	uint32 _okTextId; +	uint32 _cancelTextId;  	FontRendererGui *_fr;  	Widget *_panel;  	Button *_okButton;  	Button *_cancelButton;  public: -	MiniDialog(Gui *gui, uint32 textId) -		: Dialog(gui), _textId(textId) { +	MiniDialog(Gui *gui, uint32 headerTextId, uint32 okTextId = 149618688, uint32 cancelTextId = 149618689) +		: Dialog(gui), _headerTextId(headerTextId), _okTextId(okTextId), _cancelTextId(cancelTextId) {  		_fr = new FontRendererGui(_gui, _gui->_vm->_controlsFontId);  		_panel = new Widget(this, 1); @@ -821,9 +824,10 @@ public:  	virtual void paint() {  		Dialog::paint(); -		_fr->drawText(_textId, 310, 134, FontRendererGui::kAlignCenter); -		_fr->drawText(149618688, 270, 214);	// ok -		_fr->drawText(149618689, 270, 276);	// cancel +		if (_headerTextId) +			_fr->drawText(_headerTextId, 310, 134, FontRendererGui::kAlignCenter); +		_fr->drawText(_okTextId, 270, 214); +		_fr->drawText(_cancelTextId, 270, 276);  	}  	virtual void onAction(Widget *widget, int result = 0) { @@ -938,7 +942,7 @@ public:  		int maxWidth = 0;  		int width; -		int alignTextIds[] = { +		uint32 alignTextIds[] = {  			149618700,	// object labels  			149618702,	// music volume  			149618703,	// speech volume @@ -1572,6 +1576,26 @@ void Gui::saveControl(void) {  	_vm->_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);  } +bool Gui::startControl(void) { +	while (1) { +		MiniDialog startDialog(this, 0, 149618693, 149618690); + +		if (startDialog.run()) +			return true; + +		if (_vm->_quit) +			return false; + +		if (restoreControl()) +			return false; + +		if (_vm->_quit) +			return false; +	} + +	return true; +} +  void Gui::quitControl(void) {  	MiniDialog quitDialog(this, 149618692); diff --git a/sword2/controls.h b/sword2/controls.h index d988835588..83d092e3e3 100644 --- a/sword2/controls.h +++ b/sword2/controls.h @@ -43,6 +43,7 @@ public:  	uint32 restoreControl(void);  	void saveControl(void); +	bool startControl(void);  	void quitControl(void);  	void restartControl(void);  	void optionControl(void); diff --git a/sword2/resman.cpp b/sword2/resman.cpp index 02adf6e781..31b5db1eee 100644 --- a/sword2/resman.cpp +++ b/sword2/resman.cpp @@ -65,6 +65,10 @@ struct CdInf {  ResourceManager::ResourceManager(Sword2Engine *vm) {  	_vm = vm; +	// Until proven differently, assume we're on CD 1. This is so the start +	// dialog will be able to play any music at all. +	_curCd = 1; +  	// We read in the resource info which tells us the names of the  	// resource cluster files ultimately, although there might be groups  	// within the clusters at this point it makes no difference. We only @@ -99,7 +103,7 @@ ResourceManager::ResourceManager(Sword2Engine *vm) {  	// all the files now extract the filenames  	do {  		// item must have an #0d0a -		while(temp->ad[j] != 13) { +		while (temp->ad[j] != 13) {  			_resourceFiles[_totalClusters][pos] = temp->ad[j];  			j++;  			pos++; diff --git a/sword2/save_rest.cpp b/sword2/save_rest.cpp index 0671c79d3f..63784aa520 100644 --- a/sword2/save_rest.cpp +++ b/sword2/save_rest.cpp @@ -438,6 +438,13 @@ uint32 Sword2Engine::getSaveDescription(uint16 slotNo, uint8 *description) {  	return SR_OK;  } +bool Sword2Engine::saveExists(void) { +	for (int i = 0; i <= 99; i++) +		if (saveExists(i)) +			return true; +	return false; +} +  bool Sword2Engine::saveExists(uint16 slotNo) {  	char saveFileName[MAX_FILENAME_LEN];  	SaveFileManager *mgr = _system->get_savefile_manager(); diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index 26ec549430..d24090ec91 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -312,11 +312,25 @@ void Sword2Engine::go() {  	if (_saveSlot != -1) {  		if (saveExists(_saveSlot))  			restoreGame(_saveSlot); -		else { // show restore menu +		else {  			setMouse(NORMAL_MOUSE_ID);  			if (!_gui->restoreControl())  				startGame();  		} +	} else if (saveExists()) { +		int32 pars[2] = { 221, FX_LOOP }; +		bool result; + +		setMouse(NORMAL_MOUSE_ID); +		_logic->fnPlayMusic(pars); +		result = _gui->startControl(); +		_logic->fnStopMusic(NULL); + +		if (_quit) +			return; + +		if (result) +			startGame();  	} else  		startGame(); diff --git a/sword2/sword2.h b/sword2/sword2.h index 91c78512ff..58d8c49fcf 100644 --- a/sword2/sword2.h +++ b/sword2/sword2.h @@ -314,6 +314,7 @@ public:  	uint32 saveGame(uint16 slotNo, uint8 *description);  	uint32 restoreGame(uint16 slotNo);  	uint32 getSaveDescription(uint16 slotNo, uint8 *description); +	bool saveExists(void);  	bool saveExists(uint16 slotNo);  	void fillSaveBuffer(Memory *buffer, uint32 size, uint8 *desc);  	uint32 restoreFromBuffer(Memory *buffer, uint32 size); | 
