Add a new debug clock dialog.
The dialog is used to test the drawing routines. The clock will need some appearance changes later on. It's main goal is to test the drawing routine timing and several other things I want to test in the near future, where I want to see what parts get updated.
This commit is contained in:
parent
9250e0de7d
commit
d8b025e716
11 changed files with 745 additions and 1 deletions
346
data/gui/default/window/debug_clock.cfg
Normal file
346
data/gui/default/window/debug_clock.cfg
Normal file
|
@ -0,0 +1,346 @@
|
|||
#textdomain wesnoth-lib
|
||||
###
|
||||
### Definition of the window to show the debug_clock for testing the drawing
|
||||
### timer.
|
||||
###
|
||||
|
||||
|
||||
#define _GUI_TICK_MARK ANGLE TEXT
|
||||
[text]
|
||||
x = "(round(125 + (100.0 * sin({ANGLE}))))"
|
||||
y = "(round(125 - (100.0 * cos({ANGLE}))))"
|
||||
h = 20
|
||||
w = 30
|
||||
font_size = 10
|
||||
colour = "255,255,255,255"
|
||||
text = "{TEXT}"
|
||||
[/text]
|
||||
#enddef
|
||||
|
||||
[window]
|
||||
id = "debug_clock"
|
||||
description = "Clock dialog to test the drawing timer."
|
||||
|
||||
[resolution]
|
||||
definition = "default"
|
||||
|
||||
click_dismiss = "true"
|
||||
|
||||
automatic_placement = "true"
|
||||
vertical_placement = "top"
|
||||
horizontal_placement = "left"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "title"
|
||||
|
||||
label = "Debug drawing clock"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
vertical_grow = "true"
|
||||
|
||||
[progress_bar]
|
||||
id = "hour_percentage"
|
||||
[/progress_bar]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
vertical_grow = "true"
|
||||
|
||||
[progress_bar]
|
||||
id = "minute_percentage"
|
||||
[/progress_bar]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
vertical_grow = "true"
|
||||
|
||||
[progress_bar]
|
||||
id = "second_percentage"
|
||||
[/progress_bar]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
vertical_grow = "true"
|
||||
|
||||
[slider]
|
||||
id = "hour"
|
||||
definition = "clock"
|
||||
|
||||
minimum_value = 0
|
||||
maximum_value = 86399
|
||||
step_size = 1
|
||||
[/slider]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
vertical_grow = "true"
|
||||
|
||||
[slider]
|
||||
id = "minute"
|
||||
definition = "clock"
|
||||
|
||||
minimum_value = 0
|
||||
maximum_value = 3599
|
||||
step_size = 1
|
||||
label = 3599
|
||||
[/slider]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
vertical_grow = "true"
|
||||
|
||||
[slider]
|
||||
id = "second"
|
||||
definition = "clock"
|
||||
|
||||
minimum_value = 0
|
||||
maximum_value = 59
|
||||
step_size = 1
|
||||
label = 59
|
||||
[/slider]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_align = "center"
|
||||
vertical_align = "center"
|
||||
|
||||
[drawing]
|
||||
id = "clock"
|
||||
definition = "default"
|
||||
|
||||
width = 250
|
||||
height = 280
|
||||
|
||||
[draw]
|
||||
# Add hour ticks.
|
||||
|
||||
{_GUI_TICK_MARK 15.0 1 }
|
||||
{_GUI_TICK_MARK 30.0 2 }
|
||||
{_GUI_TICK_MARK 45.0 3 }
|
||||
{_GUI_TICK_MARK 60.0 4 }
|
||||
{_GUI_TICK_MARK 75.0 5 }
|
||||
{_GUI_TICK_MARK 90.0 6 }
|
||||
{_GUI_TICK_MARK 105.0 7 }
|
||||
{_GUI_TICK_MARK 120.0 8 }
|
||||
{_GUI_TICK_MARK 135.0 9 }
|
||||
{_GUI_TICK_MARK 150.0 10}
|
||||
{_GUI_TICK_MARK 165.0 11}
|
||||
{_GUI_TICK_MARK 180.0 12}
|
||||
{_GUI_TICK_MARK 195.0 13}
|
||||
{_GUI_TICK_MARK 210.0 14}
|
||||
{_GUI_TICK_MARK 225.0 15}
|
||||
{_GUI_TICK_MARK 240.0 16}
|
||||
{_GUI_TICK_MARK 255.0 17}
|
||||
{_GUI_TICK_MARK 270.0 18}
|
||||
{_GUI_TICK_MARK 285.0 19}
|
||||
{_GUI_TICK_MARK 300.0 20}
|
||||
{_GUI_TICK_MARK 315.0 21}
|
||||
{_GUI_TICK_MARK 330.0 22}
|
||||
{_GUI_TICK_MARK 345.0 23}
|
||||
{_GUI_TICK_MARK 360.0 24}
|
||||
|
||||
# Add outer circle.
|
||||
|
||||
# TODO
|
||||
|
||||
# Add the hands.
|
||||
|
||||
[line]
|
||||
x1 = 125
|
||||
y1 = 125
|
||||
x2 = "(round(125 + (90.0 * sin(360.0 * second / 60.0))))"
|
||||
y2 = "(round(125 - (90.0 * cos(360.0 * second / 60.0))))"
|
||||
colour = "255,255,255,255"
|
||||
[/line]
|
||||
|
||||
[line]
|
||||
x1 = 125
|
||||
y1 = 125
|
||||
x2 = "(round(125 + (70.0 * sin(360.0 * minute / (60.0 * 60.0)))))"
|
||||
y2 = "(round(125 - (70.0 * cos(360.0 * minute / (60.0 * 60.0)))))"
|
||||
colour = "128,128,128,255"
|
||||
[/line]
|
||||
|
||||
[line]
|
||||
x1 = 125
|
||||
y1 = 125
|
||||
x2 = "(round(125 + (40.0 * sin(360.0 * hour / (60.0 * 60.0 * 24.0)))))"
|
||||
y2 = "(round(125 - (40.0 * cos(360.0 * hour / (60.0 * 60.0 * 24.0)))))"
|
||||
colour = "64,64,64,255"
|
||||
[/line]
|
||||
|
||||
# Show the time as string.
|
||||
|
||||
[text]
|
||||
x = 0
|
||||
y = 250
|
||||
w = "(width)"
|
||||
h = 30
|
||||
font_size = 20
|
||||
maximum_width = "(width)"
|
||||
text_alignment = "center"
|
||||
colour = "128,128,128,255"
|
||||
text = "(concatenate(
|
||||
substring(concatenate(0, 0, (hour / (60 * 60))), -2)
|
||||
, ':'
|
||||
, substring(concatenate(0, 0, (minute / 60)), -2)
|
||||
, ':'
|
||||
, substring(concatenate(0, 0, second), -2)))"
|
||||
[/text]
|
||||
[/draw]
|
||||
|
||||
[/drawing]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/resolution]
|
||||
|
||||
[/window]
|
||||
|
||||
[slider_definition]
|
||||
id = "clock"
|
||||
description = "Specialized slider to test the clock dialog."
|
||||
|
||||
[resolution]
|
||||
|
||||
min_width = 150
|
||||
min_height = 22
|
||||
|
||||
default_width = 250
|
||||
default_height = 22
|
||||
|
||||
max_width = 0
|
||||
max_height = 22
|
||||
|
||||
minimum_positioner_length = 16
|
||||
maximum_positioner_length = 16
|
||||
|
||||
left_offset = 0
|
||||
right_offset = 0
|
||||
|
||||
text_font_size = 1
|
||||
|
||||
[state_enabled]
|
||||
[draw]
|
||||
[/draw]
|
||||
[/state_enabled]
|
||||
|
||||
[state_disabled]
|
||||
[draw]
|
||||
|
||||
#
|
||||
# Groove
|
||||
#
|
||||
|
||||
[line]
|
||||
x1 = 0
|
||||
y1 = "(height / 2)"
|
||||
x2 = "(width - 1)"
|
||||
y2 = "(height / 2)"
|
||||
|
||||
colour = {GUI__FONT_COLOUR_ENABLED__DEFAULT}
|
||||
thickness = 1
|
||||
[/line]
|
||||
|
||||
#
|
||||
# Slider
|
||||
#
|
||||
|
||||
[image]
|
||||
x = "(positioner_offset)"
|
||||
y = "(if (image_height < height, (height - image_height) / 2, 0))"
|
||||
name = "buttons/slider.png"
|
||||
[/image]
|
||||
|
||||
[/draw]
|
||||
[/state_disabled]
|
||||
|
||||
[state_pressed]
|
||||
[draw]
|
||||
[/draw]
|
||||
[/state_pressed]
|
||||
|
||||
[state_focussed]
|
||||
[draw]
|
||||
[/draw]
|
||||
[/state_focussed]
|
||||
|
||||
[/resolution]
|
||||
|
||||
[/slider_definition]
|
|
@ -230,6 +230,8 @@
|
|||
{_GUI_BUTTON "preferences" _"Preferences" _"Configure the game’s settings"}
|
||||
{_GUI_BUTTON "credits" _"Credits" _"View the credits"}
|
||||
{_GUI_BUTTON "quit" _"Quit" _"Quit the game"}
|
||||
# This debug feature doesn't need to be translated.
|
||||
{_GUI_BUTTON "clock" "Clock" "Show debug clock"}
|
||||
[/grid]
|
||||
|
||||
[/panel]
|
||||
|
|
|
@ -66,6 +66,7 @@ src/gui/dialogs/addon_list.cpp
|
|||
src/gui/dialogs/campaign_difficulty.cpp
|
||||
src/gui/dialogs/campaign_selection.cpp
|
||||
src/gui/dialogs/data_manage.cpp
|
||||
src/gui/dialogs/debug_clock.cpp
|
||||
src/gui/dialogs/dialog.cpp
|
||||
src/gui/dialogs/edit_label.cpp
|
||||
src/gui/dialogs/formula_debugger.cpp
|
||||
|
|
|
@ -408,6 +408,7 @@ set(wesnoth-main_SRC
|
|||
gui/dialogs/campaign_difficulty.cpp
|
||||
gui/dialogs/campaign_selection.cpp
|
||||
gui/dialogs/data_manage.cpp
|
||||
gui/dialogs/debug_clock.cpp
|
||||
gui/dialogs/dialog.cpp
|
||||
gui/dialogs/edit_label.cpp
|
||||
gui/dialogs/formula_debugger.cpp
|
||||
|
|
|
@ -179,6 +179,7 @@ wesnoth_source = \
|
|||
gui/dialogs/campaign_difficulty.cpp \
|
||||
gui/dialogs/campaign_selection.cpp \
|
||||
gui/dialogs/data_manage.cpp \
|
||||
gui/dialogs/debug_clock.cpp \
|
||||
gui/dialogs/dialog.cpp \
|
||||
gui/dialogs/edit_label.cpp \
|
||||
gui/dialogs/formula_debugger.cpp \
|
||||
|
|
|
@ -348,6 +348,7 @@ wesnoth_sources = Split("""
|
|||
gui/dialogs/campaign_difficulty.cpp
|
||||
gui/dialogs/campaign_selection.cpp
|
||||
gui/dialogs/data_manage.cpp
|
||||
gui/dialogs/debug_clock.cpp
|
||||
gui/dialogs/dialog.cpp
|
||||
gui/dialogs/edit_label.cpp
|
||||
gui/dialogs/formula_debugger.cpp
|
||||
|
|
|
@ -498,6 +498,8 @@ game_controller::game_controller(int argc, char** argv) :
|
|||
} else if(val == "--new-widgets") {
|
||||
// This is a hidden option to enable the new widget toolkit.
|
||||
gui2::new_widgets = true;
|
||||
} else if(val == "--clock") {
|
||||
gui2::show_debug_clock_button = true;
|
||||
#ifndef DISABLE_EDITOR
|
||||
} else if(val == "-e" || val == "--editor") {
|
||||
jump_to_editor_ = true;
|
||||
|
@ -1909,6 +1911,8 @@ static int process_command_args(int argc, char** argv) {
|
|||
<< " file bug reports since most are known).\n"
|
||||
<< " Parts of the library are deemed stable and will\n"
|
||||
<< " work without this switch.\n"
|
||||
<< " --clock Adds the option to show a clock for testing the\n"
|
||||
<< " drawing timer.\n"
|
||||
;
|
||||
return 0;
|
||||
} else if(val == "--version" || val == "-v") {
|
||||
|
|
209
src/gui/dialogs/debug_clock.cpp
Normal file
209
src/gui/dialogs/debug_clock.cpp
Normal file
|
@ -0,0 +1,209 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2010 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/dialogs/debug_clock.hpp"
|
||||
|
||||
#include "gui/widgets/integer_selector.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/progress_bar.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/*WIKI
|
||||
* @page = GUIWindowDefinitionWML
|
||||
* @order = 2_clock
|
||||
*
|
||||
* == Clock ==
|
||||
*
|
||||
* This shows the dialog for keeping track of the drawing events related to the
|
||||
* current time. (This window is used for debug purposes only.)
|
||||
*
|
||||
* @begin{table}{dialog_widgets}
|
||||
* hour_percentage & & progress_bar & o &
|
||||
* This shows the hours as a percentage, where 24 hours is 100%. $
|
||||
* minute_percentage & & progress_bar & o &
|
||||
* This shows the minutes as a percentage, where 60 minutes is 100%. $
|
||||
* second_percentage & & progress_bar & o &
|
||||
* This shows the seconds as a percentage, where 60 seconds is 100%. $
|
||||
*
|
||||
* hour & & integer_selector & o &
|
||||
* This shows the seconds since the beginning of the day. The control
|
||||
* should have a ''minimum_value'' of 0 and a ''maximum_value'' of 86399
|
||||
* (24 * 60 * 60 - 1).
|
||||
*
|
||||
* minute & & integer_selector & o &
|
||||
* This shows the seconds since the beginning of the current hour. The
|
||||
* control should have a ''minimum_value'' of 0 and a ''maximum_value'' of
|
||||
* 3599 (60 * 60 - 1).
|
||||
*
|
||||
* minute & & integer_selector & o &
|
||||
* This shows the seconds since the beginning of the current minute. The
|
||||
* control should have a ''minimum_value'' of 0 and a ''maximum_value'' of
|
||||
* 59.
|
||||
*
|
||||
* clock & & control & o &
|
||||
* A control which will have set three variables in its canvas:
|
||||
* @* hour, the same value as the hour integer_selector.
|
||||
* @* minute, the same value as the minute integer_selector.
|
||||
* @* second, the same value as the second integer_selector.
|
||||
* @- the control can then should the time in its own preferred format(s).
|
||||
* @end{table}
|
||||
*/
|
||||
|
||||
REGISTER_WINDOW(debug_clock)
|
||||
|
||||
void tdebug_clock::pre_show(CVideo& /*video*/, twindow& window)
|
||||
{
|
||||
hour_percentage_ = find_widget<tprogress_bar>(
|
||||
&window
|
||||
, "hour_percentage"
|
||||
, false
|
||||
, false);
|
||||
minute_percentage_ = find_widget<tprogress_bar>(
|
||||
&window
|
||||
, "minute_percentage"
|
||||
, false
|
||||
, false);
|
||||
second_percentage_ = find_widget<tprogress_bar>(
|
||||
&window
|
||||
, "second_percentage"
|
||||
, false
|
||||
, false);
|
||||
|
||||
hour_ = find_widget<tinteger_selector_>(&window, "hour", false, false);
|
||||
if(hour_) {
|
||||
dynamic_cast<tcontrol*>(hour_)->set_active(false);
|
||||
}
|
||||
minute_ = find_widget<tinteger_selector_>(&window, "minute", false, false);
|
||||
if(minute_) {
|
||||
dynamic_cast<tcontrol*>(minute_)->set_active(false);
|
||||
}
|
||||
second_ = find_widget<tinteger_selector_>(&window, "second", false, false);
|
||||
if(second_) {
|
||||
dynamic_cast<tcontrol*>(second_)->set_active(false);
|
||||
}
|
||||
|
||||
clock_ = find_widget<tcontrol>(&window, "clock", false, false);
|
||||
|
||||
window_ = &window;
|
||||
|
||||
signal_ = boost::bind(&tdebug_clock::update_time, this, false);
|
||||
window.connect_signal<event::DRAW>(
|
||||
signal_
|
||||
, event::tdispatcher::front_child);
|
||||
|
||||
time_.set_current_time();
|
||||
update_time(true);
|
||||
}
|
||||
|
||||
void tdebug_clock::post_show(CVideo& /*video*/)
|
||||
{
|
||||
window_->disconnect_signal<event::DRAW>(signal_);
|
||||
}
|
||||
|
||||
void tdebug_clock::update_time(const bool force)
|
||||
{
|
||||
if(!time_.step() && !force) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(hour_percentage_) {
|
||||
hour_percentage_->set_percentage(time_.hour / 0.24);
|
||||
}
|
||||
if(minute_percentage_) {
|
||||
minute_percentage_->set_percentage(time_.minute / 0.60);
|
||||
}
|
||||
if(second_percentage_) {
|
||||
second_percentage_->set_percentage(time_.second / 0.60);
|
||||
}
|
||||
|
||||
const int hour_stamp = time_.hour * 3600 + time_.minute * 60 + time_.second;
|
||||
const int minute_stamp = time_.minute * 60 + time_.second;
|
||||
const int second_stamp = time_.second;
|
||||
|
||||
if(hour_) {
|
||||
hour_->set_value(hour_stamp);
|
||||
}
|
||||
if(minute_) {
|
||||
minute_->set_value(minute_stamp);
|
||||
}
|
||||
if(second_) {
|
||||
second_->set_value(second_stamp);
|
||||
}
|
||||
|
||||
if(clock_) {
|
||||
foreach(tcanvas& canvas, clock_->canvas()) {
|
||||
canvas.set_variable("hour", variant(hour_stamp));
|
||||
canvas.set_variable("minute", variant(minute_stamp));
|
||||
canvas.set_variable("second", variant(second_stamp));
|
||||
}
|
||||
clock_->set_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
tdebug_clock::ttime::ttime()
|
||||
: hour(0)
|
||||
, minute(0)
|
||||
, second(0)
|
||||
, millisecond(0)
|
||||
{
|
||||
}
|
||||
|
||||
void tdebug_clock::ttime::set_current_time()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
tm *stamp = localtime(&now);
|
||||
|
||||
hour = stamp->tm_hour;
|
||||
minute = stamp->tm_min;
|
||||
second = stamp->tm_sec;
|
||||
millisecond = 0;
|
||||
}
|
||||
|
||||
bool tdebug_clock::ttime::step(const unsigned milliseconds)
|
||||
{
|
||||
millisecond += milliseconds;
|
||||
|
||||
if(millisecond < 1000) return false;
|
||||
|
||||
millisecond -= 1000;
|
||||
++second;
|
||||
|
||||
if(second < 60) return true;
|
||||
|
||||
second -= 60;
|
||||
++minute;
|
||||
|
||||
if(minute < 60) return true;
|
||||
|
||||
minute -= 60;
|
||||
++hour;
|
||||
|
||||
if(hour < 24) return true;
|
||||
|
||||
hour -= 24;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
149
src/gui/dialogs/debug_clock.hpp
Normal file
149
src/gui/dialogs/debug_clock.hpp
Normal file
|
@ -0,0 +1,149 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2010 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI_DIALOGS_DEBUG_CLOCK_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_DEBUG_CLOCK_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
|
||||
#include "gui/auxiliary/event/dispatcher.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
class tcontrol;
|
||||
class tprogress_bar;
|
||||
class tinteger_selector_;
|
||||
|
||||
/** Clock to test the draw events. */
|
||||
class tdebug_clock
|
||||
: public tdialog
|
||||
{
|
||||
public:
|
||||
tdebug_clock()
|
||||
: tdialog()
|
||||
, hour_percentage_(NULL)
|
||||
, minute_percentage_(NULL)
|
||||
, second_percentage_(NULL)
|
||||
, hour_(NULL)
|
||||
, minute_(NULL)
|
||||
, second_(NULL)
|
||||
, clock_(NULL)
|
||||
, window_(NULL)
|
||||
, signal_()
|
||||
, time_()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Progress bar for displaying the hours as a percentage. */
|
||||
tprogress_bar* hour_percentage_;
|
||||
|
||||
/** Progress bar for displaying the minutes as a percentage. */
|
||||
tprogress_bar* minute_percentage_;
|
||||
|
||||
/** Progress bar for displaying the seconds as a percentage. */
|
||||
tprogress_bar* second_percentage_;
|
||||
|
||||
/** An integer selector to display the total seconds. */
|
||||
tinteger_selector_* hour_;
|
||||
|
||||
/** An integer selector to display the total seconds this hour. */
|
||||
tinteger_selector_* minute_;
|
||||
|
||||
/** An integer selector to display the seconds this minute. */
|
||||
tinteger_selector_* second_;
|
||||
|
||||
/** A widget that can display the time. */
|
||||
tcontrol* clock_;
|
||||
|
||||
/** The window being shown. */
|
||||
twindow* window_;
|
||||
|
||||
/** The signal patched in the drawing routine. */
|
||||
event::tsignal_function signal_;
|
||||
|
||||
/** Helper struct to keep track of the time. */
|
||||
struct ttime
|
||||
{
|
||||
ttime();
|
||||
|
||||
/**
|
||||
* Sets the fields to the current time.
|
||||
*
|
||||
* @note The milliseconds aren't queried and set to zero.
|
||||
*/
|
||||
void set_current_time();
|
||||
|
||||
/**
|
||||
* Moves the clock x milliseconds forward.
|
||||
*
|
||||
* @note The default value of @p milliseconds is the same as the
|
||||
* interval for the drawing routine.
|
||||
*
|
||||
* @pre @p milliseconds < 1000.
|
||||
*
|
||||
* @param milliseconds The number of milliseconds to move ahead.
|
||||
*
|
||||
* @returns Did the number of seconds alter?
|
||||
*/
|
||||
bool step(const unsigned milliseconds = 30);
|
||||
|
||||
/** The number of hours. */
|
||||
unsigned hour;
|
||||
|
||||
/** The number of minutes. */
|
||||
unsigned minute;
|
||||
|
||||
/** The number of seconds. */
|
||||
unsigned second;
|
||||
|
||||
/** The number of milliseconds. */
|
||||
unsigned millisecond;
|
||||
};
|
||||
|
||||
/**
|
||||
* The `current' time.
|
||||
*
|
||||
* @note Since the dialog is used to test the drawing routine by keeping
|
||||
* track of the calls to the drawing routine, the clock might be off.
|
||||
*/
|
||||
ttime time_;
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
|
||||
virtual const std::string& window_id() const;
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void post_show(CVideo& video);
|
||||
|
||||
/**
|
||||
* The callback for the drawing routine.
|
||||
*
|
||||
* It updates the `time' in the various controls.
|
||||
*
|
||||
* @param force Force an update even it the time didn't
|
||||
* change? (This is used to set the clock
|
||||
* initially.)
|
||||
*/
|
||||
void update_time(const bool force);
|
||||
};
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
#include "log.hpp"
|
||||
#include "gui/auxiliary/timer.hpp"
|
||||
#include "gui/auxiliary/tips.hpp"
|
||||
#include "gui/dialogs/debug_clock.hpp"
|
||||
#include "gui/dialogs/language_selection.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
|
@ -86,6 +87,8 @@ namespace gui2 {
|
|||
|
||||
REGISTER_WINDOW(title_screen)
|
||||
|
||||
bool show_debug_clock_button = false;
|
||||
|
||||
static bool hotkey(twindow& window, const ttitle_screen::tresult result)
|
||||
{
|
||||
window.set_retval(static_cast<twindow::tretval>(result));
|
||||
|
@ -256,7 +259,7 @@ void ttitle_screen::post_build(CVideo& video, twindow& window)
|
|||
, QUIT_GAME));
|
||||
}
|
||||
|
||||
void ttitle_screen::pre_show(CVideo&, twindow& window)
|
||||
void ttitle_screen::pre_show(CVideo& video, twindow& window)
|
||||
{
|
||||
set_restore(false);
|
||||
window.set_click_dismiss(false);
|
||||
|
@ -342,6 +345,19 @@ void ttitle_screen::pre_show(CVideo&, twindow& window)
|
|||
, true);
|
||||
}
|
||||
}
|
||||
|
||||
/***** Set the clock button. *****/
|
||||
tbutton& clock = find_widget<tbutton>(&window, "clock", false);
|
||||
clock.set_visible(show_debug_clock_button
|
||||
? twidget::VISIBLE
|
||||
: twidget::INVISIBLE);
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
clock
|
||||
, boost::bind(
|
||||
&ttitle_screen::show_debug_clock_window
|
||||
, this
|
||||
, boost::ref(video)));
|
||||
}
|
||||
|
||||
void ttitle_screen::update_tip(twindow& window, const bool previous)
|
||||
|
@ -367,5 +383,13 @@ void ttitle_screen::update_tip(twindow& window, const bool previous)
|
|||
tips.select_page(page);
|
||||
}
|
||||
|
||||
void ttitle_screen::show_debug_clock_window(CVideo& video)
|
||||
{
|
||||
assert(show_debug_clock_button);
|
||||
|
||||
tdebug_clock dlg;
|
||||
dlg.show(video);
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
|
||||
namespace gui2 {
|
||||
|
||||
/** Do we wish to show the button for the debug clock. */
|
||||
extern bool show_debug_clock_button;
|
||||
|
||||
class ttitle_screen : public tdialog
|
||||
{
|
||||
public:
|
||||
|
@ -82,6 +85,9 @@ private:
|
|||
* one.
|
||||
*/
|
||||
void update_tip(twindow& window, const bool previous);
|
||||
|
||||
/** Shows the debug clock. */
|
||||
void show_debug_clock_window(CVideo& video);
|
||||
};
|
||||
|
||||
} // namespace gui2
|
||||
|
|
Loading…
Add table
Reference in a new issue