From 0f30872b79ba1b6c3622cded531ee9071acc2630 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 28 Nov 2019 18:45:16 +0300 Subject: [PATCH] Holiday title screens --- data/title/en.christmas | 21 +++++++++++ data/title/en.easter | 24 +++++++++++++ data/title/en.independence_day | 21 +++++++++++ data/title/en.new_year | 22 ++++++++++++ data/title/en.thanksgiving | 29 +++++++++++++++ src/enums.h | 16 +++++++++ src/main_menu.cpp | 65 ++++++++++++++++++++++++---------- src/main_menu.h | 2 +- src/path_info.cpp | 42 +++++++++++++++++++--- src/path_info.h | 4 ++- 10 files changed, 221 insertions(+), 25 deletions(-) create mode 100644 data/title/en.christmas create mode 100644 data/title/en.easter create mode 100644 data/title/en.independence_day create mode 100644 data/title/en.new_year create mode 100644 data/title/en.thanksgiving diff --git a/data/title/en.christmas b/data/title/en.christmas new file mode 100644 index 0000000000000..25a7d2279b462 --- /dev/null +++ b/data/title/en.christmas @@ -0,0 +1,21 @@ +# The ASCII art must be 18 lines in height (6 lines per ascii art text line). +# Max length of a line is 80 characters; the following line is for reference. +################################################################################ + _________ __ .__ + \_ ___ \ _____ _/ |_ _____ ____ | | ___.__ ______ _____ + / \ \/ \__ \ \ __\\__ \ _/ ___\ | | < | | / ___/ / \ + \ \____ / __ \_ | | / __ \_\ \___ | |__ \___ | \___ \ | Y Y \ + \______ /(____ / |__| (____ / \___ >|____/ / ____|/____ >|__|_| / + \/ \/ \/ \/ \/ \/ \/ + _________ __ _________ .__ + / _____/____ _____/ |______ \_ ___ \| | _____ __ __ ______ + \_____ \\__ \ / \ __\__ \ / \ \/| | \__ \ | | \/ ___/ + / \/ __ \| | \ | / __ \_ \ \___| |__/ __ \| | /\___ \ + /_______ (____ /___| /__| (____ / \______ /____(____ /____//____ > + \/ \/ \/ \/ \/ \/ \/ + _____ .__ .___ + / _ \ | |__ ____ _____ __| _/ + / /_\ \ | | \ _/ __ \ \__ \ / __ | + / | \| Y \\ ___/ / __ \_/ /_/ | + \____|__ /|___| / \___ >(____ /\____ | + \/ \/ \/ \/ \/ diff --git a/data/title/en.easter b/data/title/en.easter new file mode 100644 index 0000000000000..de166ef3f31c2 --- /dev/null +++ b/data/title/en.easter @@ -0,0 +1,24 @@ +# The ASCII art must be 18 lines in height (6 lines per ascii art text line). +# Max length of a line is 80 characters; the following line is for reference. +################################################################################ + _________ __ .__ + \_ ___ \ _____ _/ |_ _____ ____ | | ___.__ ______ _____ + / \ \/ \__ \ \ __\\__ \ _/ ___\ | | < | | / ___/ / \ + \ \____ / __ \_ | | / __ \_\ \___ | |__ \___ | \___ \ | Y Y \ + \______ /(____ / |__| (____ / \___ >|____/ / ____|/____ >|__|_| / + \/ \/ \/ \/ \/ \/ \/ + _______ ___ _ ,---. .--.,---. .--..-./`) .-''-. .-'''-. + \ ____ \ .' | | || \ | || \ | | \.-.') .'_ _ \ / _ \ + | | \ | | .' | || , \ | || , \ | |/ `-' \ / ( ` ) ' (`' )/`--' + | |____/ / .' '_ | || |\_ \| || |\_ \| | `-'`"`. (_ o _) |(_ o _). + | _ _ '. ' ( \.-.|| _( )_\ || _( )_\ | .---. | (_,_)___| (_,_). '. + | ( ' ) \' (`. _` /|| (_ o _) || (_ o _) | | | ' \ .---..---. \ : + | (_{;}_) || (_ (_) _)| (_,_)\ || (_,_)\ | | | \ `-' /\ `-' | + | (_,_) / \ / . \ /| | | || | | | | | \ / \ / + /_______.' ``-'`-'' '--' '--''--' '--' '---' `'-..-' `-...-' + _____ .__ .___ + / _ \ | |__ ____ _____ __| _/ + / /_\ \ | | \ _/ __ \ \__ \ / __ | + / | \| Y \\ ___/ / __ \_/ /_/ | + \____|__ /|___| / \___ >(____ /\____ | + \/ \/ \/ \/ \/ diff --git a/data/title/en.independence_day b/data/title/en.independence_day new file mode 100644 index 0000000000000..d454c129d52d2 --- /dev/null +++ b/data/title/en.independence_day @@ -0,0 +1,21 @@ +# The ASCII art must be 18 lines in height (6 lines per ascii art text line). +# Max length of a line is 80 characters; the following line is for reference. +################################################################################ + _________ __ .__ __ __ .__ + \_ ___ \ ____ ____ _______/ |_|__|/ |_ __ ___/ |_|__| ____ ____ + / \ \/ / _ \ / \ / ___/\ __\ \ __\ | \ __\ |/ _ \ / \ + \ \___( <_> ) | \\___ \ | | | || | | | /| | | ( <_> ) | \ + \______ /\____/|___| /____ > |__| |__||__| |____/ |__| |__|\____/|___| / + \/ \/ \/ \/ + ___________ __________ __ + \__ ___/___ _____ \______ \_____ ________/ |_ ___.__. + | |_/ __ \\__ \ | ___/\__ \\_ __ \ __< | | + | |\ ___/ / __ \_ | | / __ \| | \/| | \___ | + |____| \___ >____ / |____| (____ /__| |__| / ____| + \/ \/ \/ \/ + _____ .__ .___ + ________ / _ \ | |__ ____ _____ __| _/ + |::::====| / /_\ \| | \_/ __ \\__ \ / __ | + |::::====| / | \ Y \ ___/ / __ \_/ /_/ | + |========| \____|__ /___| /\___ >____ /\____ | + \/ \/ \/ \/ \/ diff --git a/data/title/en.new_year b/data/title/en.new_year new file mode 100644 index 0000000000000..1fe2eeb996e88 --- /dev/null +++ b/data/title/en.new_year @@ -0,0 +1,22 @@ +# The ASCII art must be 18 lines in height (6 lines per ascii art text line). +# Max length of a line is 80 characters; the following line is for reference. +################################################################################ + _________ __ .__ + \_ ___ \ _____ _/ |_ _____ ____ | | ___.__ ______ _____ + / \ \/ \__ \ \ __\\__ \ _/ ___\ | | < | | / ___/ / \ + \ \____ / __ \_ | | / __ \_\ \___ | |__ \___ | \___ \ | Y Y \ + \______ /(____ / |__| (____ / \___ >|____/ / ____|/____ >|__|_| / + \/ \/ \/ \/ \/ \/ \/ + ___________.__ ___________ + \_ _____/|__|______ \__ ___/______ ____ ____ + | __) | \_ __ \ | | \_ __ \_/ __ \_/ __ \ + /\ | \ | || | \/ | | | | \/\ ___/\ ___/ + /\*\ \___ / |__||__| |____| |__| \___ >\___ > + /\O\*\ \/ \/ \/ + /*/\/\/\ _____ .__ .___ + /\O\/\*\/\ / _ \ | |__ ____ _____ __| _/ + /\*\/\*\/\/\ / /_\ \ | | \ _/ __ \ \__ \ / __ | +/\O\/\/*/\/O/\ / | \| Y \\ ___/ / __ \_/ /_/ | + || \____|__ /|___| / \___ >(____ /\____ | + || \/ \/ \/ \/ \/ + || diff --git a/data/title/en.thanksgiving b/data/title/en.thanksgiving new file mode 100644 index 0000000000000..c5a048aa8b096 --- /dev/null +++ b/data/title/en.thanksgiving @@ -0,0 +1,29 @@ +# The ASCII art must be 18 lines in height (6 lines per ascii art text line). +# Max length of a line is 80 characters; the following line is for reference. +################################################################################ + _________ __ .__ + \_ ___ \ _____ _/ |_ _____ ____ | | ___.__ ______ _____ + / \ \/ \__ \ \ __\\__ \ _/ ___\ | | < | | / ___/ / \ + \ \____ / __ \_ | | / __ \_\ \___ | |__ \___ | \___ \ | Y Y \ + \______ /(____ / |__| (____ / \___ >|____/ / ____|/____ >|__|_| / + \/ \/ \/ \/ \/ \/ \/ + ___________ __ ________ + \__ ___/_ _________| | __ ____ ___.__. \______ \ _____ ___.__. + | | | | \_ __ \ |/ // __ < | | | | \\__ \< | | + | | | | /| | \/ <\ ___/\___ | | ` \/ __ \\___ | + |____| |____/ |__| |__|_ \\___ > ____| /_______ (____ / ____| + \/ \/\/ \/ \/\/ + _____ .__ .___ + .--. / _ \ | |__ ____ _____ __| _/ + {\ / q {\ / /_\ \ | | \ _/ __ \ \__ \ / __ | + { `\ \ (-(~` / | \| Y \\ ___/ / __ \_/ /_/ | + { '.{`\ \ \ ) \____|__ /|___| / \___ >(____ /\____ | + {'-{ ' \ .-""'-. \ \ \/ \/ \/ \/ \/ + {._{'.' \/ '.) \ + {_.{. {` | + {._{ ' { ;'-=-. | + {-.{.' { ';-=-.` / + {._.{.; '-=- .' + {_.-' `'.__ _,-' + |||` + .='==, diff --git a/src/enums.h b/src/enums.h index 537df3f6746cc..b88b98d0ba766 100644 --- a/src/enums.h +++ b/src/enums.h @@ -10,6 +10,22 @@ constexpr inline int sgn( const T x ) return x < 0 ? -1 : ( x > 0 ? 1 : 0 ); } +enum class holiday : int { + none = 0, + new_year, + easter, + independence_day, + halloween, + thanksgiving, + christmas, + num_holiday +}; + +template<> +struct enum_traits { + static constexpr holiday last = holiday::num_holiday; +}; + enum temperature_flag : int { TEMP_NORMAL = 0, TEMP_HEATER, diff --git a/src/main_menu.cpp b/src/main_menu.cpp index 18b7f48e33e20..624037a57fcbb 100644 --- a/src/main_menu.cpp +++ b/src/main_menu.cpp @@ -42,7 +42,7 @@ #define dbg(x) DebugLog((DebugLevel)(x),D_GAME) << __FILE__ << ":" << __LINE__ << ": " -static const bool halloween_theme = false; +static const holiday current_holiday = holiday::thanksgiving; void main_menu::on_move() const { @@ -142,28 +142,57 @@ void main_menu::print_menu( const catacurses::window &w_open, int iSel, const po const nc_color cColor2 = c_light_blue; const nc_color cColor3 = c_light_blue; - if( halloween_theme ) { - fold_and_print_from( w_open, point_zero, 30, 0, c_white, halloween_spider() ); - fold_and_print_from( w_open, point( getmaxx( w_open ) - 25, offset.y - 8 ), - 25, 0, c_white, halloween_graves() ); + switch( current_holiday ) { + case holiday::new_year: + break; + case holiday::easter: + break; + case holiday::halloween: + fold_and_print_from( w_open, point_zero, 30, 0, c_white, halloween_spider() ); + fold_and_print_from( w_open, point( getmaxx( w_open ) - 25, offset.y - 8 ), + 25, 0, c_white, halloween_graves() ); + break; + case holiday::thanksgiving: + break; + case holiday::christmas: + break; + case holiday::none: + case holiday::num_holiday: + default: + break; } if( mmenu_title.size() > 1 ) { for( size_t i = 0; i < mmenu_title.size(); ++i ) { - if( halloween_theme ) { - static const std::string marker = "█"; - const utf8_wrapper text( mmenu_title[i] ); - for( size_t j = 0; j < text.size(); j++ ) { - std::string temp = text.substr_display( j, 1 ).str(); - if( temp != " " ) { - mvwprintz( w_open, point( iOffsetX + j, iLine ), - ( temp != marker ) ? c_red : ( i < 9 ? cColor1 : cColor2 ), - "%s", ( temp == marker ) ? "▓" : temp ); + switch( current_holiday ) { + case holiday::halloween: { + static const std::string marker = "█"; + const utf8_wrapper text( mmenu_title[i] ); + for( size_t j = 0; j < text.size(); j++ ) { + std::string temp = text.substr_display( j, 1 ).str(); + if( temp != " " ) { + mvwprintz( w_open, point( iOffsetX + j, iLine ), + ( temp != marker ) ? c_red : ( i < 9 ? cColor1 : cColor2 ), + "%s", ( temp == marker ) ? "▓" : temp ); + } } + iLine++; } - iLine++; - } else { - mvwprintz( w_open, point( iOffsetX, iLine++ ), i < 6 ? cColor1 : cColor2, "%s", mmenu_title[i] ); + break; + case holiday::thanksgiving: + case holiday::new_year: + case holiday::easter: + case holiday::christmas: { + nc_color cur_color = c_white; + nc_color base_color = c_white; + print_colored_text( w_open, point( iOffsetX, iLine++ ), cur_color, base_color, mmenu_title[i] ); + } + break; + case holiday::none: + case holiday::num_holiday: + default: + mvwprintz( w_open, point( iOffsetX, iLine++ ), i < 6 ? cColor1 : cColor2, "%s", mmenu_title[i] ); + break; } } } else { @@ -258,7 +287,7 @@ void main_menu::init_windows() void main_menu::init_strings() { // ASCII Art - mmenu_title = load_file( PATH_INFO::title( halloween_theme ), _( "Cataclysm: Dark Days Ahead" ) ); + mmenu_title = load_file( PATH_INFO::title( current_holiday ), _( "Cataclysm: Dark Days Ahead" ) ); // MOTD auto motd = load_file( PATH_INFO::motd(), _( "No message today." ) ); diff --git a/src/main_menu.h b/src/main_menu.h index 7b63c44b78294..a9a8546da8465 100644 --- a/src/main_menu.h +++ b/src/main_menu.h @@ -105,7 +105,7 @@ class main_menu void init_windows(); std::string handle_input_timeout( input_context &ctxt ); - std::string halloween_spider(); + static std::string halloween_spider(); std::string halloween_graves(); }; diff --git a/src/path_info.cpp b/src/path_info.cpp index 7ee9ebe9d5a24..0be20a11e44b3 100644 --- a/src/path_info.cpp +++ b/src/path_info.cpp @@ -4,6 +4,7 @@ #include #include +#include "enums.h" #include "filesystem.h" #include "options.h" @@ -384,11 +385,42 @@ std::string PATH_INFO::motd() return find_translated_file( datadir_value + "motd/", ".motd", motd_value ); } -std::string PATH_INFO::title( const bool halloween_theme ) -{ - return find_translated_file( datadir_value + "title/", halloween_theme ? ".halloween" : ".title", - halloween_theme ? ( datadir_value + "title/" + "en.halloween" ) : ( datadir_value + "title/" + - "en.title" ) ); +std::string PATH_INFO::title( const holiday current_holiday ) +{ + std::string theme_basepath = datadir_value + "title/"; + std::string theme_extension = ".title"; + std::string theme_fallback = theme_basepath + "en.title"; + switch( current_holiday ) { + case holiday::new_year: + theme_extension = ".new_year"; + theme_fallback = datadir_value + "title/" + "en.new_year"; + break; + case holiday::easter: + theme_extension = ".easter"; + theme_fallback = datadir_value + "title/" + "en.easter"; + break; + case holiday::independence_day: + theme_extension = ".independence_day"; + theme_fallback = datadir_value + "title/" + "en.independence_day"; + break; + case holiday::halloween: + theme_extension = ".halloween"; + theme_fallback = datadir_value + "title/" + "en.halloween"; + break; + case holiday::thanksgiving: + theme_extension = ".thanksgiving"; + theme_fallback = datadir_value + "title/" + "en.thanksgiving"; + break; + case holiday::christmas: + theme_extension = ".christmas"; + theme_fallback = datadir_value + "title/" + "en.christmas"; + break; + case holiday::none: + case holiday::num_holiday: + default: + break; + } + return find_translated_file( theme_basepath, theme_extension, theme_fallback ); } std::string PATH_INFO::names() diff --git a/src/path_info.h b/src/path_info.h index 9b054146612ea..2387ff9b4390c 100644 --- a/src/path_info.h +++ b/src/path_info.h @@ -4,6 +4,8 @@ #include +enum class holiday : int; + namespace PATH_INFO { void init_base_path( std::string path ); @@ -66,7 +68,7 @@ std::string soundpack_conf(); std::string credits(); std::string motd(); -std::string title( bool halloween_theme ); +std::string title( holiday current_holiday ); std::string names(); void set_datadir( const std::string &datadir );