//NEED TO FIX: //CONDITION WILL ALWAYS BE 1 IT CAUSE INFINITY LOOP void meun(int playerChoose) { int condition = 1; switch (playerChoose) { case 1: condition = gameMode(); //start game break; case 2: //open record mode condition = leaderboardMode(); break; case 3: //option condition = optionMode(); break; case 4: //exit program condition = exitMode(); break; default: condition = 1; break; } }
/* Quit interactive mode, after exiting all active modes. This should be called only if none of the modes in the stack can throw on exit, which seems a reasonable assumption. */ void exitInteractive() { while (modeStack.size()) exitMode(); // applies to mode at top of stack, which is then popped runFlag = false; // this will cause the |run| loop to terminate }
void LevelEditor::changeMode(LevelEditor::EditingMode newMode) { exitMode(); switch(newMode) { case SELECT: { break; } case MOVE: { break; } case SCALE: { break; } case ROTATE: { break; } case CREATE: { createGhostEntity(Vec2f(0,0)); break; } } this->editingMode = newMode; }
/* this function helps "mode changing" functions like "type" to be defined only twice: once in the parent mode where it just activates the mode, and once in the mode itself, where (upon successful obtention of new values for the mode) it drops to the current mode and replaces the values Avoiding the first definition altogether is not possible, since if only the definition in the mode itself would remain, it would have no way to know whether that mode had just been entered as a consequence of its own call (and in which case it would need to avoid immediately changing anything). */ void drop_to(const CommandTree& mode) { while (modeStack.back()!= &mode) { exitMode(); assert(not modeStack.empty()); // not finding |mode| is fatal } }