1 // -*- Mode: C++; tab-width:2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 // vi:tw=80:et:ts=2:sts=2 3 // 4 // ----------------------------------------------------------------------- 5 // 6 // This file is part of RLVM, a RealLive virtual machine clone. 7 // 8 // ----------------------------------------------------------------------- 9 // 10 // Copyright (C) 2011 Elliot Glaysher 11 // 12 // This program is free software; you can redistribute it and/or modify 13 // it under the terms of the GNU General Public License as published by 14 // the Free Software Foundation; either version 3 of the License, or 15 // (at your option) any later version. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of the GNU General Public License 23 // along with this program; if not, write to the Free Software 24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 25 // ----------------------------------------------------------------------- 26 27 #ifndef SRC_LONG_OPERATIONS_LOAD_GAME_LONG_OPERATION_H_ 28 #define SRC_LONG_OPERATIONS_LOAD_GAME_LONG_OPERATION_H_ 29 30 #include "machine/long_operation.h" 31 32 class RLMachine; 33 34 // Clears the screen and resets the system, performs the specified load 35 // operation, and then fades back in. We let subclasses define what loading 36 // means. 37 // 38 // Internally, load is fairly complex; we very carefully time adding other 39 // LongOperations to the stack to perform sub tasks like clearing the screen 40 // etc because we can't rely on normal flow control because we're going to nuke 41 // the call stack. 42 struct LoadGameLongOperation : public LongOperation { 43 // Sets the callstack up so that we will fade to black, clear the screen and 44 // render, and then enter the next stage. This runs in the during our 45 // caller's RLOperation. 46 // 47 // WARNING: This constructor adds itself to the machine's stack. If I come 48 // back, trying to clean this up, make sure that fadeout on selecting a game 49 // to load still works. 50 explicit LoadGameLongOperation(RLMachine& machine); 51 52 // Actually loads the data and sets up a LongOperation to fade into our new 53 // screen. By the time this method returns, the game state has been thawed 54 // and the previous stack that ran us is invalid. 55 virtual bool operator()(RLMachine& machine); 56 57 // Load operation to be specified by subclasses. 58 virtual void Load(RLMachine& machine) = 0; 59 }; 60 61 #endif // SRC_LONG_OPERATIONS_LOAD_GAME_LONG_OPERATION_H_ 62