This repository has been archived by the owner on Nov 28, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Options.cpp
67 lines (58 loc) · 1.83 KB
/
Options.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "Global.h"
#include "Interface.h"
struct shFlags Flags;
struct shOption {
const char *mName;
int *mValue;
int mDefault;
} Options[] = {
{"vikeys", &Flags.mVIKeys, 0 },
{"fadelog", &Flags.mFadeLog, 0 },
{"show line of sight", &Flags.mShowLOS, 0 },
{"autopickup", &Flags.mAutopickup, 0 },
{"Autopickup Types", NULL, 0 },
{"$ money ", &Flags.mAutopickupTypes[kMoney], 1 },
{"+ implants", &Flags.mAutopickupTypes[kImplant], 1 },
{"? floppy disks", &Flags.mAutopickupTypes[kFloppyDisk], 1 },
{"! canisters", &Flags.mAutopickupTypes[kCanister], 1 },
{"( tools", &Flags.mAutopickupTypes[kTool], 0 },
{"] armor", &Flags.mAutopickupTypes[kArmor], 0 },
{") weapons", &Flags.mAutopickupTypes[kWeapon], 0 },
{"= ammunition", &Flags.mAutopickupTypes[kProjectile], 1 },
{"& devices", &Flags.mAutopickupTypes[kDevice], 0 },
{"/ ray guns", &Flags.mAutopickupTypes[kRayGun], 1 },
{"* energy cells", &Flags.mAutopickupTypes[kEnergyCell], 1 },
{NULL, NULL, 0 }
};
void
initializeOptions ()
{
int i;
for (i = 0; Options[i].mName; i++) {
if (Options[i].mValue) {
*Options[i].mValue = Options[i].mDefault;
}
}
}
void
shInterface::editOptions ()
{
unsigned int i;
shMenu menu ("Options", shMenu::kMultiPick);
char letter = 'a';
/* This is kludgey. Only works for boolean options right now */
for (i = 0; Options[i].mName; i++) {
if (Options[i].mValue) {
menu.addItem (letter++, Options[i].mName, (void *) i, 1, *Options[i].mValue);
} else {
menu.addHeader (Options[i].mName);
}
}
for (i = 0; Options[i].mName; i++) {
if (Options[i].mValue)
*Options[i].mValue = 0;
}
while (menu.getResult ((const void **) &i)) {
*Options[i].mValue = 1;
}
}