Removed editor settings dialog. Custom TOD dialog has replaced it

This commit is contained in:
Charles Dang 2013-06-09 12:42:32 +11:00
parent 3d59e29be6
commit 0ca3f3f268
3 changed files with 0 additions and 642 deletions

View file

@ -1,260 +0,0 @@
#textdomain wesnoth-lib
###
### Definition of the settings window in the editor.
###
[window]
id = "editor_settings"
description = "Editor settings dialog."
[resolution]
definition = "default"
automatic_placement = "true"
vertical_placement = "center"
horizontal_placement = "center"
[tooltip]
id = "tooltip_large"
[/tooltip]
[helptip]
id = "tooltip_large"
[/helptip]
[grid]
[row]
grow_factor = 0
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "title"
label = _ "Editor Settings"
[/label]
[/column]
[/row]
[row]
grow_factor = 0
[column]
horizontal_alignment = "left"
[grid]
[row]
grow_factor = 0
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
vertical_alignment = "top"
[label]
definition = "default"
label = _ "Time of day lighting preset:"
[/label]
[/column]
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[grid]
[row]
[column]
horizontal_alignment = "left"
[label]
id = "current_tod"
definition = "default"
[/label]
[/column]
[/row]
[row]
[column]
border = "top"
border_size = 5
horizontal_alignment = "left"
[button]
id = "next_tod"
definition = "default"
size_text = _ "Next"
label = _ "Next"
[/button]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
grow_factor = 0
[column]
horizontal_grow = "true"
[grid]
[row]
grow_factor = 1
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "custom_tod_toggle"
definition = "default"
label = _ "Custom lighting settings"
[/toggle_button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
id = "custom_tod_auto_refresh"
definition = "default"
label = _ "Automatically update map view"
[/toggle_button]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
grow_factor = 0
[column]
horizontal_grow = "true"
[grid]
[row]
grow_factor = 0
[column]
grow_factor = 0
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "default"
label = _ "Red:"
[/label]
[/column]
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[slider]
id = "custom_tod_red"
definition = "default"
best_slider_length = 512
minimum_value = -255
maximum_value = 255
step_size = 1
[/slider]
[/column]
[/row]
[row]
[column]
grow_factor = 0
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "default"
label = _ "Green:"
[/label]
[/column]
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[slider]
id = "custom_tod_green"
definition = "default"
best_slider_length = 512
minimum_value = -255
maximum_value = 255
step_size = 1
[/slider]
[/column]
[/row]
[row]
[column]
grow_factor = 0
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "default"
label = _ "Blue:"
[/label]
[/column]
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[slider]
id = "custom_tod_blue"
definition = "default"
best_slider_length = 512
minimum_value = -255
maximum_value = 255
step_size = 1
[/slider]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
grow_factor = 0
[column]
[label]
id = "current_tod_image"
definition = "default"
[/label]
[/column]
[/row]
[row]
grow_factor = 0
[column]
horizontal_alignment = "right"
[grid]
[row]
grow_factor = 0
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "ok"
definition = "default"
label = _ "OK"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "cancel"
definition = "default"
label = _ "Cancel"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "apply"
definition = "default"
label = _ "Apply"
[/button]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/grid]
[/resolution]
[/window]

View file

@ -1,277 +0,0 @@
/*
Copyright (C) 2008 - 2013 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-editor"
#include "gui/dialogs/editor_settings.hpp"
#include "editor/editor_preferences.hpp"
#include "editor/editor_display.hpp"
#include "gui/dialogs/field.hpp"
#include "gui/dialogs/helper.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/label.hpp"
#include "gui/widgets/slider.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/toggle_button.hpp"
#include "gettext.hpp"
#include "image.hpp"
#include <boost/bind.hpp>
namespace gui2 {
/*WIKI
* @page = GUIWindowDefinitionWML
* @order = 2_editor_settings
*
* == Editor settings ==
*
* This shows the dialog to set the editor settings.
*
* @begin{table}{dialog_widgets}
*
* current_tod & & label & m &
* Displays the currently selected time of day(ToD) mask. $
*
* current_tod_image & & label & m &
* The image for the ToD mask. $
*
* next_tod & & button & m &
* Selects the next ToD mask. $
*
* custom_tod_toggle & & toggle_button & m &
* Allow to set the ToD mask by selecting the color components
* manually. $
*
* custom_tod_red & & slider & m &
* Sets the red component of the custom ToD mask. $
*
* custom_tod_green & & slider & m &
* Sets the green component of the custom ToD mask. $
*
* custom_tod_blue & & slider & m &
* Sets the blue component of the custom ToD mask. $
*
* custom_tod_auto_refresh & & toggle_button & m &
* Directly update the ToD mask when a component slider is moved. $
*
* use_mdi & & boolean & m &
* Sets whether the user interface should be an MDI interface or not. $
*
* @end{table}
*/
REGISTER_DIALOG(editor_settings)
teditor_settings::teditor_settings(editor::editor_display* display
, const std::vector<time_of_day>& tods)
: tods_(tods)
, current_tod_(0)
, current_tod_label_(NULL)
, current_tod_image_(NULL)
, custom_tod_toggle_(NULL)
, custom_tod_auto_refresh_(NULL)
, custom_tod_toggle_field_(register_bool("custom_tod_toggle", true))
, custom_tod_red_field_(register_integer("custom_tod_red"
, true
, &preferences::editor::tod_r
, &preferences::editor::set_tod_r))
, custom_tod_green_field_(register_integer("custom_tod_green"
, true
, &preferences::editor::tod_g
, &preferences::editor::set_tod_g))
, custom_tod_blue_field_(register_integer("custom_tod_blue"
, true
, &preferences::editor::tod_b
, &preferences::editor::set_tod_b))
, display_(display)
, can_update_display_(false)
{
}
void teditor_settings::do_next_tod(twindow& window)
{
current_tod_++;
current_tod_ %= tods_.size();
custom_tod_toggle_->set_value(false);
update_selected_tod_info(window);
}
const time_of_day& teditor_settings::get_selected_tod() const
{
assert(static_cast<size_t>(current_tod_) < tods_.size());
return tods_[current_tod_];
}
void teditor_settings::update_tod_display(twindow& window)
{
image::set_color_adjustment(
custom_tod_red_field_->get_widget_value(window)
, custom_tod_green_field_->get_widget_value(window)
, custom_tod_blue_field_->get_widget_value(window));
// Prevent a floating slice of window appearing alone over the
// theme UI sidebar after redrawing tiles and before we have a
// chance to redraw the rest of this window.
window.undraw();
if(display_) {
// NOTE: We only really want to re-render the gamemap tiles here.
// Redrawing everything is a significantly more expensive task.
// At this time, tiles are the only elements on which ToD tint is
// meant to have a visible effect. This is very strongly tied to
// the image caching mechanism.
//
// If this ceases to be the case in the future, you'll need to call
// redraw_everything() instead.
// invalidate all tiles so they are redrawn with the new ToD tint next
display_->invalidate_all();
// redraw tiles
display_->draw();
}
// Redraw this window again.
window.set_is_dirty(true);
}
void teditor_settings::slider_update_callback(twindow& window)
{
if (custom_tod_auto_refresh_->get_value()) {
update_tod_display(window);
}
}
void teditor_settings::update_selected_tod_info(twindow& window)
{
bool custom = custom_tod_toggle_->get_value();
if (custom) {
current_tod_label_->set_label(_("Custom setting"));
} else {
std::stringstream ss;
ss << (current_tod_ + 1);
ss << "/" << tods_.size();
ss << ": " << get_selected_tod().name;
current_tod_label_->set_label(ss.str());
/**
* @todo Implement the showing of the ToD icon.
*
* Note at the moment the icon is a label widget, should become an
* image widget.
*/
//current_tod_image_->set_icon_name(get_selected_tod().image);
custom_tod_red_field_->set_widget_value(
window
, get_selected_tod().color.r);
custom_tod_green_field_->set_widget_value(
window
, get_selected_tod().color.g);
custom_tod_blue_field_->set_widget_value(
window
, get_selected_tod().color.b);
}
custom_tod_red_field_->widget()->set_active(custom);
custom_tod_green_field_->widget()->set_active(custom);
custom_tod_blue_field_->widget()->set_active(custom);
current_tod_label_->set_active(!custom);
if(can_update_display_) {
update_tod_display(window);
window.invalidate_layout();
}
}
void teditor_settings::pre_show(CVideo& /*video*/, twindow& window)
{
assert(!tods_.empty());
current_tod_label_ = find_widget<tlabel>(
&window, "current_tod", false, true);
current_tod_image_ = find_widget<tlabel>(
&window, "current_tod_image", false, true);
custom_tod_toggle_ = find_widget<ttoggle_button>(
&window, "custom_tod_toggle", false, true);
custom_tod_auto_refresh_ = find_widget<ttoggle_button>(
&window, "custom_tod_auto_refresh", false, true);
tbutton& next_tod_button = find_widget<tbutton>(
&window, "next_tod", false);
connect_signal_mouse_left_click(next_tod_button, boost::bind(
&teditor_settings::do_next_tod
, this
, boost::ref(window)));
tbutton& apply_button = find_widget<tbutton>(
&window, "apply", false);
connect_signal_mouse_left_click(apply_button, boost::bind(
&teditor_settings::update_tod_display
, this
, boost::ref(window)));
custom_tod_toggle_->set_callback_state_change(
dialog_callback<teditor_settings
, &teditor_settings::update_selected_tod_info>);
connect_signal_notify_modified(*(custom_tod_red_field_->widget())
, boost::bind(
&teditor_settings::slider_update_callback
, this
, boost::ref(window)));
connect_signal_notify_modified(*(custom_tod_green_field_->widget())
, boost::bind(
&teditor_settings::slider_update_callback
, this
, boost::ref(window)));
connect_signal_notify_modified(*(custom_tod_blue_field_->widget())
, boost::bind(
&teditor_settings::slider_update_callback
, this
, boost::ref(window)));
for (size_t i = 0; i < tods_.size(); ++i) {
time_of_day& tod = tods_[i];
const int r = custom_tod_red_field_->get_widget_value(window);
const int g = custom_tod_green_field_->get_widget_value(window);
const int b = custom_tod_blue_field_->get_widget_value(window);
if (tod.color.r == r && tod.color.g == g && tod.color.b == b) {
current_tod_ = i;
custom_tod_toggle_->set_value(false);
update_selected_tod_info(window);
can_update_display_ = true;
return;
}
}
/* custom tod */
custom_tod_toggle_->set_value(true);
update_selected_tod_info(window);
can_update_display_ = true;
}
void teditor_settings::post_show(twindow& window)
{
update_tod_display(window);
can_update_display_ = false;
}
} // namespace gui2

View file

@ -1,105 +0,0 @@
/*
Copyright (C) 2008 - 2013 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_EDITOR_SETTINGS_HPP_INCLUDED
#define GUI_DIALOGS_EDITOR_SETTINGS_HPP_INCLUDED
#include "time_of_day.hpp"
#include "gui/dialogs/dialog.hpp"
#include <vector>
namespace editor {
class editor_display;
} // namespace editor
namespace gui2 {
class tlabel;
class ttoggle_button;
class teditor_settings : public tdialog
{
public:
teditor_settings(editor::editor_display* display
, const std::vector<time_of_day>& tods);
static bool execute(editor::editor_display* display
, const std::vector<time_of_day>& tods
, CVideo& video)
{
return teditor_settings(display, tods).show(video);
}
private:
/** Callback for the next tod button */
void do_next_tod(twindow& window);
void update_tod_display(twindow& window);
void slider_update_callback(twindow& window);
void set_selected_tod(time_of_day tod);
const time_of_day& get_selected_tod() const;
void update_selected_tod_info(twindow& window);
private:
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */
void pre_show(CVideo& video, twindow& window);
/** Inherited from tdialog. */
void post_show(twindow& window);
/** Available time_of_days */
std::vector<time_of_day> tods_;
/** Current map generator index */
int current_tod_;
/** Label for the current tod */
tlabel* current_tod_label_;
/** Label for the current tod image*/
tlabel* current_tod_image_;
ttoggle_button* custom_tod_toggle_;
ttoggle_button* custom_tod_auto_refresh_;
tfield_bool* custom_tod_toggle_field_;
tfield_integer* custom_tod_red_field_;
tfield_integer* custom_tod_green_field_;
tfield_integer* custom_tod_blue_field_;
/**
* The display to update when the ToD changes.
*
* The pointer may be NULL, in the unit tests, but normally it should be a
* pointer to a valid object.
*/
editor::editor_display* display_;
bool can_update_display_;
};
} // namespace gui2
#endif