Added an option in advanced preferences

that allows the twelve-hour clock format to be used.
This commit is contained in:
Steven Panek 2011-10-03 11:56:40 +00:00
parent 986310c93d
commit e3a8810756
13 changed files with 71 additions and 27 deletions

View file

@ -18,6 +18,8 @@ Version 1.9.9+svn:
* Added an option to disable the "loading save from a different version"
confirmation dialog.
* Line-wrap author names in the add-on description dialog (bug #18691)
* Added option in advanced preferences that allows the twelve-hour clock
format to be used.
* WML engine:
* Readded the liminal alignment
* Added four-difficulty versions of certain macros: QUANTITY4,

View file

@ -138,6 +138,13 @@
step=1
[/advanced_preference]
[advanced_preference]
field=use_twelve_hour_clock_format
name= _ "Use 12-hour clock format"
type=boolean
default=no
[/advanced_preference]
[advanced_preference]
field=confirm_load_save_from_different_version
name=_"Confirm loading of saves from a different version"

View file

@ -636,12 +636,12 @@
[/change]
[change]
id=timeout-panel
rect="+5,=,+55,="
rect="+5,=,+75,="
[/change]
[change]
id=report_timeout
font_size={DEFAULT_FONT_TINY}
rect="+0,=,+35,+20"
rect="+0,=,+45,+20"
[/change]
[change]
id=status-position

View file

@ -3,7 +3,7 @@
[panel]
id=timeout-panel
image=themes/status-bg.png
rect="+5,=,+70,="
rect="+5,=,+90,="
xanchor=fixed
yanchor=fixed
[/panel]
@ -23,7 +23,7 @@
id=report_timeout
font_size={FONT_SMALL_SIZE}
ref=time-icon
rect="+0,=,+50,+20"
rect="+0,=,+60,+20"
xanchor=fixed
yanchor=fixed
[/report_countdown]

View file

@ -865,12 +865,12 @@
[/change]
[change]
id=timeout-panel
rect="+5,=,+55,="
rect="+5,=,+75,="
[/change]
[change]
id=report_timeout
font_size={DEFAULT_FONT_TINY}
rect="+0,=,+35,+20"
rect="+0,=,+45,+20"
[/change]
[change]
id=status-position

View file

@ -23,6 +23,8 @@ Version 1.9.9+svn:
* User interface:
* Removed waypoints UI feature ('w' key) since the whiteboard provides
similar functionality.
* Added option in advanced preferences that allows the twelve-hour clock
format to be used.
* Miscellaneous and bug fixes:
* Reintroduced the "Liminal" alignment. Liminal units fight best during

View file

@ -461,7 +461,9 @@ void save_preview_pane::draw_contents()
const savegame::save_info& save = *saves_[index_].save_;
tm* tm_l = localtime(&save.time_modified);
if (tm_l) {
const size_t res = strftime(time_buf,sizeof(time_buf),_("%a %b %d %H:%M %Y"),tm_l);
const size_t res = strftime(time_buf,sizeof(time_buf),
(preferences::use_twelve_hour_clock_format() ? _("%a %b %d %I:%M %p %Y") : _("%a %b %d %H:%M %Y")),
tm_l);
if(res == 0) {
time_buf[0] = 0;
}
@ -550,10 +552,20 @@ std::string format_time_summary(time_t t)
const int days_apart = current_time.tm_yday - save_time.tm_yday;
if(days_apart == 0) {
// save is from today
format_string = _("%H:%M");
if(preferences::use_twelve_hour_clock_format() == false) {
format_string = _("%H:%M");
}
else {
format_string = _("%I:%M %p");
}
} else if(days_apart > 0 && days_apart <= current_time.tm_wday) {
// save is from this week
format_string = _("%A, %H:%M");
if(preferences::use_twelve_hour_clock_format() == false) {
format_string = _("%A, %H:%M");
}
else {
format_string = _("%A, %I:%M %p");
}
} else {
// save is from current year
format_string = _("%b %d");

View file

@ -698,15 +698,6 @@ std::string client_type()
return preferences::get("client_type") == "ai" ? "ai" : "human";
}
std::string clock_format()
{
if(preferences::get("clock_format").size())
return preferences::get("clock_format");
else
preferences::set("clock_format", "%H:%M");
return "%H:%M";
}
std::string theme()
{
if(non_interactive()) {
@ -782,7 +773,12 @@ bool startup_effect()
std::string get_chat_timestamp(const time_t& t) {
if (chat_timestamping()) {
return lg::get_timestamp(t, clock_format()) + " ";
if(preferences::use_twelve_hour_clock_format() == false) {
return lg::get_timestamp(t, _("%H:%M")) + " ";
}
else {
return lg::get_timestamp(t, _("%I:%M %p")) + " ";
}
}
return "";
}

View file

@ -212,8 +212,6 @@ namespace preferences {
std::string client_type();
std::string clock_format();
void set_theme(const std::string& theme);
std::string theme();

View file

@ -736,5 +736,15 @@ bool confirm_load_save_from_different_version()
return get("confirm_load_save_from_different_version", true);
}
bool use_twelve_hour_clock_format()
{
return get("use_twelve_hour_clock_format", false);
}
void set_twelve_hour_clock_format(bool value)
{
set("twelve_hour_clock_format", value);
}
} // end namespace preferences

View file

@ -185,6 +185,9 @@ namespace preferences {
bool confirm_load_save_from_different_version();
bool use_twelve_hour_clock_format();
void set_use_twelve_hour_clock_format(bool value);
} // end namespace preferences
#endif

View file

@ -1219,9 +1219,11 @@ REPORT_GENERATOR(report_clock)
struct tm *lt = std::localtime(&t);
if (!lt) return report();
char temp[10];
size_t s = std::strftime(temp, 10, preferences::clock_format().c_str(), lt);
if (!s) return report();
return text_report(temp);
size_t s = std::strftime(temp, 10,
(preferences::use_twelve_hour_clock_format() ? _("%I:%M %p") : _("%H:%M")),
lt);
return s ? text_report(temp) : report();
}
REPORT_GENERATOR(report_countdown)

View file

@ -133,7 +133,9 @@ const std::string save_info::format_time_local() const{
char time_buf[256] = {0};
tm* tm_l = localtime(&time_modified);
if (tm_l) {
const size_t res = strftime(time_buf,sizeof(time_buf),_("%a %b %d %H:%M %Y"),tm_l);
const size_t res = strftime(time_buf,sizeof(time_buf),
(preferences::use_twelve_hour_clock_format() ? _("%a %b %d %I:%M %p %Y") : _("%a %b %d %H:%M %Y")),
tm_l);
if(res == 0) {
time_buf[0] = 0;
}
@ -168,10 +170,20 @@ const std::string save_info::format_time_summary() const
const int days_apart = current_time.tm_yday - save_time.tm_yday;
if(days_apart == 0) {
// save is from today
format_string = _("%H:%M");
if(preferences::use_twelve_hour_clock_format() == false) {
format_string = _("%H:%M");
}
else {
format_string = _("%I:%M %p");
}
} else if(days_apart > 0 && days_apart <= current_time.tm_wday) {
// save is from this week
format_string = _("%A, %H:%M");
if(preferences::use_twelve_hour_clock_format() == false) {
format_string = _("%A, %H:%M");
}
else {
format_string = _("%A, %I:%M %p");
}
} else {
// save is from current year
format_string = _("%b %d");