Ticket #8624: dialog_save_tmpfile.patch
File dialog_save_tmpfile.patch, 6.4 KB (added by , 16 years ago) |
---|
-
engines/scumm/input.cpp
410 410 // Fall back to default behavior 411 411 ScummEngine::processKeyboard(lastKeyHit); 412 412 413 // On Alt-F5 prepare savegame for the original save/load dialog. 414 if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) { 415 prepareSavegame(); 416 } 417 413 418 if (VAR_KEYPRESS != 0xFF && _mouseAndKeyboardStat) { // Key Input 414 419 if (315 <= _mouseAndKeyboardStat && _mouseAndKeyboardStat <= 323) { 415 420 // Convert F-Keys for V1/V2 games (they start at 1) … … 424 429 // Fall back to default behavior 425 430 ScummEngine::processKeyboard(lastKeyHit); 426 431 427 // 'i' brings up an IQ dialog in Indy3 428 if (lastKeyHit.ascii == 'i' && _game.id == GID_INDY3) { 432 // On Alt-F5 prepare savegame for the original save/load dialog. 433 if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) { 434 prepareSavegame(); 435 } 436 437 // 'i' brings up an IQ dialog in Indy3 (disabled in save/load dialog for input) 438 if (lastKeyHit.ascii == 'i' && _game.id == GID_INDY3 && _currentRoom != 14) { 429 439 // SCUMM var 244 is the episode score 430 440 // and var 245 is the series score 431 441 char text[50]; -
engines/scumm/saveload.cpp
131 131 132 132 bool ScummEngine::saveState(int slot, bool compat) { 133 133 Common::String filename; 134 Common::OutSaveFile *out;135 SaveGameHeader hdr;136 134 137 135 if (_saveLoadSlot == 255) { 138 136 // Allow custom filenames for save game system in HE Games … … 140 138 } else { 141 139 filename = makeSavegameName(slot, compat); 142 140 } 141 142 return saveState(filename); 143 } 144 145 bool ScummEngine::saveState(Common::String filename) { 146 Common::OutSaveFile *out; 147 SaveGameHeader hdr; 148 143 149 if (!(out = _saveFileMan->openForSaving(filename.c_str()))) 144 150 return false; 145 151 … … 445 451 return true; 446 452 } 447 453 454 void ScummEngine::prepareSavegame() { 455 saveState("savegame.tmp"); 456 } 457 458 bool ScummEngine::savePreparedSavegame(int slot, char *desc) { 459 return copyPreparedSavegame("savegame.tmp", slot, desc); 460 } 461 462 bool ScummEngine::copyPreparedSavegame(Common::String prepFilename, int slot, char *desc) { 463 bool result; 464 uint32 nread; 465 byte buffer[1024]; 466 Common::String filename; 467 Common::InSaveFile *in; 468 Common::OutSaveFile *out; 469 SaveGameHeader hdr; 470 471 if (!(in = _saveFileMan->openForLoading(prepFilename.c_str()))) 472 return false; 473 474 if (!loadSaveGameHeader(in, hdr)) { 475 warning("Invalid savegame '%s'", prepFilename.c_str()); 476 delete in; 477 return false; 478 } 479 480 if (hdr.ver != CURRENT_VER) { 481 warning("Incompatible savegame '%s'", prepFilename.c_str()); 482 delete in; 483 return false; 484 } 485 486 filename = makeSavegameName(slot, false); 487 if (!(out = _saveFileMan->openForSaving(filename.c_str()))) { 488 delete in; 489 return false; 490 } 491 492 memset(hdr.name, 0, sizeof(hdr.name)); 493 strncpy(hdr.name, desc, sizeof(hdr.name)-1); 494 saveSaveGameHeader(out, hdr); 495 496 // copy bytes 497 result = true; 498 while (nread = in->read(buffer, sizeof(buffer))) { 499 uint32 nwritten = out->write(buffer, nread); 500 if (nwritten < nread) { 501 result = false; 502 break; 503 } 504 } 505 506 out->finalize(); 507 if (out->ioFailed()) { 508 result = false; 509 } 510 delete in; 511 delete out; 512 513 return result; 514 } 515 448 516 Common::String ScummEngine::makeSavegameName(const Common::String &target, int slot, bool temporary) { 449 517 char extension[6]; 450 518 snprintf(extension, sizeof(extension), ".%c%02d", temporary ? 'c' : 's', slot); -
engines/scumm/script_v5.cpp
869 869 // which matches the original Indy3 save/load code. See also the notes 870 870 // on Feature Request #1666521. 871 871 STRINGID_IQ_EPISODE = 7, 872 STRINGID_IQ_SERIES = 9 872 STRINGID_IQ_SERIES = 9, 873 // The string IDs of the first savegame name, used as an offset to determine 874 // the IDs of all savenames. 875 // Loom is the only game whose savenames start with a different ID. 876 STRINGID_SAVENAME1 = 10, 877 STRINGID_SAVENAME1_LOOM = 9 873 878 }; 874 879 875 880 void ScummEngine_v5::o5_saveLoadVars() { … … 1235 1240 result = 100; 1236 1241 break; 1237 1242 case 0x20: // drive 1238 if (_game.id == GID_INDY3) { 1239 // 0 = hard drive 1240 // 1 = disk drive 1241 result = 0; 1243 if (_game.version <= 3) { 1244 // 0 = ??? 1245 // [1,2] = disk drive [A:,B:] 1246 // 3 = hard drive 1247 result = 3; 1242 1248 } else { 1243 1249 // set current drive 1244 1250 result = 1; 1245 1251 } 1246 1252 break; 1247 1253 case 0x40: // load 1248 if (loadState(slot, _saveTemporaryState))1254 if (loadState(slot, false)) 1249 1255 result = 3; // sucess 1250 1256 else 1251 1257 result = 5; // failed to load 1252 1258 break; 1253 1259 case 0x80: // save 1254 //if (saveState(slot, _saveTemporaryState)) 1255 // result = 0; // sucess 1256 //else 1260 if (_game.version <= 3) { 1261 char name[32]; 1262 if (_game.version <= 2) { 1263 // use generic name 1264 sprintf(name, "Game %c", 'A'+slot-1); 1265 } else { 1266 // use name entered by the user 1267 char* ptr; 1268 int firstSlot = (_game.id == GID_LOOM) ? STRINGID_SAVENAME1_LOOM : STRINGID_SAVENAME1; 1269 ptr = (char*)getStringAddress(slot + firstSlot - 1); 1270 strncpy(name, ptr, sizeof(name)); 1271 } 1272 1273 if(savePreparedSavegame(slot, name)) 1274 result = 0; 1275 else 1276 result = 2; 1277 } else { 1257 1278 result = 2; // failed to save 1279 } 1258 1280 break; 1259 1281 case 0xC0: // test if save exists 1260 1282 { -
engines/scumm/scumm.h
626 626 char _saveLoadFileName[32]; 627 627 char _saveLoadName[32]; 628 628 629 bool saveState(Common::String filename); 629 630 bool saveState(int slot, bool compat); 630 631 bool loadState(int slot, bool compat); 631 632 virtual void saveOrLoad(Serializer *s); … … 633 634 void saveResource(Serializer *ser, int type, int index); 634 635 void loadResource(Serializer *ser, int type, int index); 635 636 637 void prepareSavegame(); 638 bool savePreparedSavegame(int slot, char *desc); 639 bool copyPreparedSavegame(Common::String prepFilename, int slot, char *desc); 640 636 641 Common::String makeSavegameName(int slot, bool temporary) const { 637 642 return makeSavegameName(_targetName, slot, temporary); 638 643 }