Skip to content

Commit

Permalink
Added Options menu to start menu, updated motd with new links
Browse files Browse the repository at this point in the history
  • Loading branch information
OzoneH3 committed Mar 7, 2013
1 parent 25d88a0 commit de47aee
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 155 deletions.
15 changes: 7 additions & 8 deletions data/motd
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
This branch contains much work by Creidieki, Uzername,
Kevingranade, HerbertJones, Gim, Shades and Origamiwolf.

The game now has configurable options.
You can directly edit options.txt in the data directory, or you
can edit the options via the help menu.
For latest discussions on Cataclysm DDA and its mods, please visit:

For latest discussions on Cataclysm and its mods, please visit:
http://www.cataclysm.glyphgryph.com/smf/index.php
Homepage: http://www.cataclysmdda.com/
Forum: http://www.cataclysmdda.com/smf/
Wiki: http://wiki.cataclysmdda.com/

Check out the options listing by pressing ?2
The game now has new configurable options:
Customizeable Viewport, Spawntype: Classic/Static

As always, please visit the forums at:
http://www.cataclysmdda.com/smf/index.php
Ingame you can access the options via the help menu (?).
79 changes: 35 additions & 44 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,32 @@ void game::setup()
}
}

bool game::opening_screen()
void game::print_menu(WINDOW* w_open, int iSel)
{
WINDOW* w_open = newwin(25, 80, 0, 0);
erase();
for (int i = 0; i < 80; i++)
mvwputch(w_open, 21, i, c_white, LINE_OXOX);
mvwprintz(w_open, 0, 0, c_blue, "Welcome to Cataclysm: Dark Days Ahead!");
mvwprintz(w_open, 1, 0, c_red, "\
Please report bugs to TheDarklingWolf@gmail.com or post on the forums.");
mvwprintz(w_open, 0, 0, c_blue, "Welcome to Cataclysm: Dark Days Ahead!");
mvwprintz(w_open, 1, 0, c_red, "Please report bugs to TheDarklingWolf@gmail.com or post on the forums.");

mvwprintz(w_open, 4, 1, (iSel == 0 ? h_white : c_white), "MOTD");
mvwprintz(w_open, 5, 1, (iSel == 1 ? h_white : c_white), "New Game");
mvwprintz(w_open, 6, 1, (iSel == 2 ? h_white : c_white), "Load Game");
mvwprintz(w_open, 7, 1, (iSel == 3 ? h_white : c_white), "New World");
mvwprintz(w_open, 8, 1, (iSel == 4 ? h_white : c_white), "Special...");
mvwprintz(w_open, 9, 1, (iSel == 5 ? h_white : c_white), "Options");
mvwprintz(w_open, 10, 1, (iSel == 6 ? h_white : c_white), "Help");
mvwprintz(w_open, 11, 1, (iSel == 7 ? h_white : c_white), "Quit");

refresh();
wrefresh(w_open);
refresh();
}

bool game::opening_screen()
{
WINDOW* w_open = newwin(25, 80, 0, 0);
print_menu(w_open, 0);
std::vector<std::string> savegames, templates;
std::string tmp;
dirent *dp;
Expand Down Expand Up @@ -239,61 +253,38 @@ Please report bugs to TheDarklingWolf@gmail.com or post on the forums.");

while(!start) {
if (layer == 1) {
mvwprintz(w_open, 4, 1, (sel1 == 0 ? h_white : c_white), "MOTD");
mvwprintz(w_open, 5, 1, (sel1 == 1 ? h_white : c_white), "New Game");
mvwprintz(w_open, 6, 1, (sel1 == 2 ? h_white : c_white), "Load Game");
mvwprintz(w_open, 7, 1, (sel1 == 3 ? h_white : c_white), "New World");
mvwprintz(w_open, 8, 1, (sel1 == 4 ? h_white : c_white), "Special...");
mvwprintz(w_open, 9, 1, (sel1 == 5 ? h_white : c_white), "Help");
mvwprintz(w_open, 10, 1, (sel1 == 6 ? h_white : c_white), "Quit");

print_menu(w_open, sel1);
if (sel1 == 0) { // Print the MOTD.
for (int i = 0; i < motd.size() && i < 16; i++)
mvwprintz(w_open, i + 4, 12, c_ltred, motd[i].c_str());
} else { // Clear the lines if not viewing MOTD.
for (int i = 4; i < 20; i++) {
for (int j = 12; j < 79; j++)
mvwputch(w_open, i, j, c_black, 'x');
}

wrefresh(w_open);
refresh();
}

wrefresh(w_open);
refresh();
input = get_input();
if (input == DirectionN) {
if (sel1 > 0)
sel1--;
else
sel1 = 6;
sel1 = 7;
} else if (input == DirectionS) {
if (sel1 < 6)
if (sel1 < 7)
sel1++;
else
sel1 = 0;
} else if ((input == DirectionE || input == Confirm) && sel1 > 0) {
if (sel1 == 6) {
if (sel1 == 5) {
show_options();
} else if (sel1 == 6) {
help();
} else if (sel1 == 7) {
uquit = QUIT_MENU;
return false;
} else if (sel1 == 5) {
help();
clear();
mvwprintz(w_open, 0, 1, c_blue, "Welcome to Cataclysm!");
mvwprintz(w_open, 1, 0, c_red, "\
Please report all bugs to TheDarklingWolf@Gmail.com");
refresh();
wrefresh(w_open);
refresh();
} else {
sel2 = 1;
layer = 2;
}
mvwprintz(w_open, 4, 1, (sel1 == 0 ? c_white : c_dkgray), "MOTD");
mvwprintz(w_open, 5, 1, (sel1 == 1 ? c_white : c_dkgray), "New Game");
mvwprintz(w_open, 6, 1, (sel1 == 2 ? c_white : c_dkgray), "Load Game");
mvwprintz(w_open, 7, 1, (sel1 == 3 ? c_white : c_dkgray), "New World");
mvwprintz(w_open, 8, 1, (sel1 == 4 ? c_white : c_dkgray), "Special...");
mvwprintz(w_open, 9, 1, (sel1 == 5 ? c_white : c_dkgray), "Help");
mvwprintz(w_open, 10, 1, (sel1 == 6 ? c_white : c_dkgray), "Quit");
}
} else if (layer == 2) {
if (sel1 == 1) { // New Character
Expand Down Expand Up @@ -358,7 +349,7 @@ Please report all bugs to TheDarklingWolf@Gmail.com");
saveend = (sel2 < 7 ? 14 : sel2 + 7);
for (int i = savestart; i < saveend; i++) {
int line = 6 + i - savestart;
mvwprintz(w_open, line, 12, c_black, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
mvwprintz(w_open, line, 12, c_black, " ");
if (i < savegames.size())
mvwprintz(w_open, line, 12, (sel2 - 1 == i ? h_white : c_white),
savegames[i].c_str());
Expand All @@ -380,7 +371,7 @@ Please report all bugs to TheDarklingWolf@Gmail.com");
} else if (input == DirectionW) {
layer = 1;
for (int i = 0; i < 14; i++)
mvwprintz(w_open, 6 + i, 12, c_black, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
mvwprintz(w_open, 6 + i, 12, c_black, " ");
}
if (input == DirectionE || input == Confirm) {
if (sel2 > 0 && savegames.size() > 0) {
Expand All @@ -399,7 +390,7 @@ Please report all bugs to TheDarklingWolf@Gmail.com");
layer = 1;
} else if (sel1 == 4) { // Special game
for (int i = 1; i < NUM_SPECIAL_GAMES; i++) {
mvwprintz(w_open, 6 + i, 12, c_black, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
mvwprintz(w_open, 6 + i, 12, c_black, " ");
mvwprintz(w_open, 6 + i, 12, (sel2 == i ? h_white : c_white),
special_game_name( special_game_id(i) ).c_str());
}
Expand All @@ -419,7 +410,7 @@ Please report all bugs to TheDarklingWolf@Gmail.com");
} else if (input == DirectionW) {
layer = 1;
for (int i = 6; i < 15; i++)
mvwprintz(w_open, i, 12, c_black, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
mvwprintz(w_open, i, 12, c_black, " ");
}
if (input == DirectionE || input == Confirm) {
if (sel2 >= 1 && sel2 < NUM_SPECIAL_GAMES) {
Expand All @@ -444,7 +435,7 @@ Please report all bugs to TheDarklingWolf@Gmail.com");
tempend = (sel1 < 6 ? 14 : sel1 + 8);
for (int i = tempstart; i < tempend; i++) {
int line = 6 + i - tempstart;
mvwprintz(w_open, line, 29, c_black, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
mvwprintz(w_open, line, 29, c_black, " ");
if (i < templates.size())
mvwprintz(w_open, line, 29, (sel1 == i ? h_white : c_white),
templates[i].c_str());
Expand Down
1 change: 1 addition & 0 deletions game.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ class game
private:
// Game-start procedures
bool opening_screen();// Warn about screen size, then present the main menu
void print_menu(WINDOW* w_open, int iSel);
bool load_master(); // Load the master data file, with factions &c
void load(std::string name); // Load a player-specific save file
void start_game(); // Starts a new game
Expand Down
104 changes: 1 addition & 103 deletions help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,109 +516,7 @@ from frostbite and to keep your distance from large fires.");
} break;

case '2': {
erase();
int offset = 1;
int line = 0;
char ch = ' ';
bool changed_options = false;
bool needs_refresh = true;
do {
// TODO: change instructions
if (needs_refresh) {
erase();
mvprintz(0, 40, c_white, "Use up/down keys to scroll through");
mvprintz(1, 40, c_white, "available options.");
mvprintz(2, 40, c_white, "Use left/right keys to toggle.");
mvprintz(3, 40, c_white, "Press ESC or q to return. ");
// highlight options for option descriptions
std::string tmp = option_desc(option_key(offset + line));
std::string out;
size_t pos;
int displayline = 5;
do {
pos = tmp.find_first_of('\n');
out = tmp.substr(0, pos);
mvprintz(displayline, 40, c_white, out.c_str());
tmp = tmp.substr(pos + 1);
displayline++;
} while (pos != std::string::npos && displayline < 12);
needs_refresh = false;
}

// Clear the lines
for (int i = 0; i < 25; i++)
mvprintz(i, 0, c_black, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
int valid_option_count = 0;

// display options
for (int i = 0; i < 25 && offset + i < NUM_OPTION_KEYS; i++)
{
valid_option_count++;
mvprintz(i, 0, c_white, "%s: ",
option_name( option_key(offset + i) ).c_str());

if (option_is_bool(option_key(offset + i)))
{
bool on = OPTIONS[ option_key(offset + i) ];
if (i == line)
mvprintz(i, 30, hilite(c_ltcyan), (on ? "True" : "False"));
else
mvprintz(i, 30, (on ? c_ltgreen : c_ltred), (on ? "True" : "False"));
} else
{
char option_val = OPTIONS[ option_key(offset + i) ];
if (i == line)
mvprintz(i, 30, hilite(c_ltcyan), "%d", option_val );
else
mvprintz(i, 30, c_ltgreen, "%d", option_val );
}
}
refresh();
ch = input();
needs_refresh = true;
refresh();

switch (ch) {
// move up and down
case 'j':
line++;
if (line == NUM_OPTION_KEYS - 1)
line = 0;
break;
case 'k':
line--;
if (line < 0)
line = NUM_OPTION_KEYS - 2;
break;
// toggle options with left/right keys
case 'h':
if (option_is_bool(option_key(offset + line)))
OPTIONS[ option_key(offset + line) ] = !(OPTIONS[ option_key(offset + line) ]);
else
{
OPTIONS[ option_key(offset + line) ]--;
if ((OPTIONS[ option_key(offset + line) ]) < 0 )
OPTIONS[ option_key(offset + line) ] = option_max_options(option_key(offset + line)) - 1;
}
changed_options = true;
break;
case 'l':
if (option_is_bool(option_key(offset + line)))
OPTIONS[ option_key(offset + line) ] = !(OPTIONS[ option_key(offset + line) ]);
else
{
OPTIONS[ option_key(offset + line) ]++;
if ((OPTIONS[ option_key(offset + line) ]) >= option_max_options(option_key(offset + line)))
OPTIONS[ option_key(offset + line) ] = 0;
}
changed_options = true;
break;
}
} while (ch != 'q' && ch != 'Q' && ch != KEY_ESCAPE);

if (changed_options && query_yn("Save changes?"))
save_options();
erase();
show_options();
} break;

case '3':
Expand Down
Loading

0 comments on commit de47aee

Please sign in to comment.