-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.cpp
More file actions
36 lines (31 loc) · 975 Bytes
/
options.cpp
File metadata and controls
36 lines (31 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <string>
#include <stdexcept>
#include "options.h"
#include "states.h"
using namespace std;
int Options::show() {
/// Display some options for the game (Currently unused)
// options to be set
string text;
int screenwidth;
// show the option values
cout << "::: Options :::" << endl;
// get the new value for screen width
cout << "screen width (" << options.screenwidth << "): ";
cin >> text;
// Try to convert the user input to an integer or set it to 80 if
// the value is not correct
try {
screenwidth = stoi(text);
} catch(invalid_argument e) {
screenwidth = SCREENWIDTH_DEFAULT;
} catch(out_of_range e) {
screenwidth = SCREENWIDTH_DEFAULT;
}
// give some feedback to the user
cout << "set screenwidth to: " << screenwidth << endl;
options.screenwidth = screenwidth;
// return to the menu after all values are set
return menuState;
}