Removed unused help_button class and its associated GUI1 components
Looking at this more I realized the help_button was a GUI1 dialog component meant to open the Help dialog. Since all dialogs invoking Help now use GUI2, there's no need for this class anymore. It also allows a bunch of remaining GUI1 stuff to be cleaned up.
This commit is contained in:
parent
7b13c3eb39
commit
194b5ef17d
9 changed files with 0 additions and 294 deletions
|
@ -229,8 +229,6 @@
|
||||||
<Unit filename="../../src/config_cache.cpp" />
|
<Unit filename="../../src/config_cache.cpp" />
|
||||||
<Unit filename="../../src/config_cache.hpp" />
|
<Unit filename="../../src/config_cache.hpp" />
|
||||||
<Unit filename="../../src/configr_assign.hpp" />
|
<Unit filename="../../src/configr_assign.hpp" />
|
||||||
<Unit filename="../../src/construct_dialog.cpp" />
|
|
||||||
<Unit filename="../../src/construct_dialog.hpp" />
|
|
||||||
<Unit filename="../../src/controller_base.cpp" />
|
<Unit filename="../../src/controller_base.cpp" />
|
||||||
<Unit filename="../../src/controller_base.hpp" />
|
<Unit filename="../../src/controller_base.hpp" />
|
||||||
<Unit filename="../../src/countdown_clock.cpp" />
|
<Unit filename="../../src/countdown_clock.cpp" />
|
||||||
|
@ -788,8 +786,6 @@
|
||||||
<Unit filename="../../src/help/help.hpp" />
|
<Unit filename="../../src/help/help.hpp" />
|
||||||
<Unit filename="../../src/help/help_browser.cpp" />
|
<Unit filename="../../src/help/help_browser.cpp" />
|
||||||
<Unit filename="../../src/help/help_browser.hpp" />
|
<Unit filename="../../src/help/help_browser.hpp" />
|
||||||
<Unit filename="../../src/help/help_button.cpp" />
|
|
||||||
<Unit filename="../../src/help/help_button.hpp" />
|
|
||||||
<Unit filename="../../src/help/help_impl.cpp" />
|
<Unit filename="../../src/help/help_impl.cpp" />
|
||||||
<Unit filename="../../src/help/help_impl.hpp" />
|
<Unit filename="../../src/help/help_impl.hpp" />
|
||||||
<Unit filename="../../src/help/help_menu.cpp" />
|
<Unit filename="../../src/help/help_menu.cpp" />
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
arrow.cpp
|
arrow.cpp
|
||||||
construct_dialog.cpp
|
|
||||||
cursor.cpp
|
cursor.cpp
|
||||||
desktop/clipboard.cpp
|
desktop/clipboard.cpp
|
||||||
display.cpp
|
display.cpp
|
||||||
|
|
|
@ -292,7 +292,6 @@ gui/widgets/window.cpp
|
||||||
halo.cpp
|
halo.cpp
|
||||||
help/help.cpp
|
help/help.cpp
|
||||||
help/help_browser.cpp
|
help/help_browser.cpp
|
||||||
help/help_button.cpp
|
|
||||||
help/help_impl.cpp
|
help/help_impl.cpp
|
||||||
help/help_menu.cpp
|
help/help_menu.cpp
|
||||||
help/help_text_area.cpp
|
help/help_text_area.cpp
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (C) 2006 - 2017 by Patrick Parker <patrick_x99@hotmail.com>
|
|
||||||
wesnoth widget Copyright (C) 2003-5 by David White <dave@whitevine.net>
|
|
||||||
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 "construct_dialog.hpp"
|
|
||||||
|
|
||||||
#include "config_assign.hpp"
|
|
||||||
#include "formula/string_utils.hpp"
|
|
||||||
#include "game_config.hpp"
|
|
||||||
#include "gettext.hpp"
|
|
||||||
#include "sound.hpp"
|
|
||||||
#include "log.hpp"
|
|
||||||
#include "font/marked-up_text.hpp"
|
|
||||||
#include "font/standard_colors.hpp"
|
|
||||||
#include "scripting/plugins/context.hpp"
|
|
||||||
#include "scripting/plugins/manager.hpp"
|
|
||||||
#include "sdl/surface.hpp"
|
|
||||||
#include "sdl/rect.hpp"
|
|
||||||
#include "utils/general.hpp"
|
|
||||||
|
|
||||||
#include "utils/functional.hpp"
|
|
||||||
|
|
||||||
namespace gui {
|
|
||||||
|
|
||||||
int dialog_button::action(dialog_process_info &info) {
|
|
||||||
if(handler_ != nullptr) {
|
|
||||||
dialog_button_action::RESULT res = handler_->button_pressed();
|
|
||||||
|
|
||||||
if( res == CLOSE_DIALOG) {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
//reset button-tracking flags so that if the action displays a dialog, a button-press
|
|
||||||
//at the end of the dialog won't be mistaken for a button-press in this dialog.
|
|
||||||
//(We should eventually use a proper event-handling system instead of tracking
|
|
||||||
//flags to avoid problems like this altogether).
|
|
||||||
info.clear_buttons();
|
|
||||||
return CONTINUE_DIALOG;
|
|
||||||
}
|
|
||||||
return simple_result_;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//end namespace gui
|
|
|
@ -1,84 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (C) 2006 - 2017 by Patrick Parker <patrick_x99@hotmail.com>
|
|
||||||
wesnoth widget Copyright (C) 2003-5 by David White <dave@whitevine.net>
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "show_dialog.hpp"
|
|
||||||
|
|
||||||
#include "widgets/label.hpp"
|
|
||||||
#include "widgets/textbox.hpp"
|
|
||||||
#include "key.hpp"
|
|
||||||
|
|
||||||
namespace gui {
|
|
||||||
|
|
||||||
struct dialog_process_info
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
dialog_process_info() :
|
|
||||||
key(),
|
|
||||||
left_button(true),
|
|
||||||
right_button(true),
|
|
||||||
key_down(true),
|
|
||||||
first_time(true),
|
|
||||||
double_clicked(false),
|
|
||||||
new_left_button(false),
|
|
||||||
new_right_button(false),
|
|
||||||
new_key_down(false),
|
|
||||||
selection(-1),
|
|
||||||
clear_buttons_(false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void clear_buttons() {
|
|
||||||
clear_buttons_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cycle() {
|
|
||||||
if(clear_buttons_) {
|
|
||||||
left_button = true;
|
|
||||||
right_button = true;
|
|
||||||
key_down = true;
|
|
||||||
clear_buttons_ = false;
|
|
||||||
} else {
|
|
||||||
left_button = new_left_button;
|
|
||||||
right_button = new_right_button;
|
|
||||||
key_down = new_key_down;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CKey key;
|
|
||||||
bool left_button, right_button, key_down, first_time, double_clicked;
|
|
||||||
bool new_left_button, new_right_button, new_key_down;
|
|
||||||
int selection;
|
|
||||||
private:
|
|
||||||
bool clear_buttons_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class dialog_button : public button {
|
|
||||||
public:
|
|
||||||
dialog_button(CVideo& video, const std::string& label, TYPE type=TYPE_PRESS,
|
|
||||||
int simple_result=CONTINUE_DIALOG, dialog_button_action *handler=nullptr)
|
|
||||||
: button(video,label,type,"",DEFAULT_SPACE,false), simple_result_(simple_result),
|
|
||||||
handler_(handler)
|
|
||||||
{}
|
|
||||||
bool is_option() const {
|
|
||||||
return (type_ == TYPE_CHECK);
|
|
||||||
}
|
|
||||||
virtual int action(dialog_process_info &info);
|
|
||||||
protected:
|
|
||||||
const int simple_result_;
|
|
||||||
private:
|
|
||||||
dialog_button_action *handler_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} //end namespace gui
|
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (C) 2003 - 2017 by David White <dave@whitevine.net>
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "help/help_button.hpp"
|
|
||||||
|
|
||||||
#include "help/help.hpp"
|
|
||||||
#include "gettext.hpp"
|
|
||||||
#include "config.hpp"
|
|
||||||
|
|
||||||
#include "hotkey/command_executor.hpp"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace help {
|
|
||||||
|
|
||||||
help_button::help_button(CVideo& video, const std::string &help_topic)
|
|
||||||
: dialog_button(video, _("Help")), video_(video), topic_(help_topic), help_hand_(nullptr)
|
|
||||||
{}
|
|
||||||
|
|
||||||
help_button::~help_button() {
|
|
||||||
delete help_hand_;
|
|
||||||
}
|
|
||||||
|
|
||||||
int help_button::action(gui::dialog_process_info &info) {
|
|
||||||
if(!topic_.empty()) {
|
|
||||||
show_help();
|
|
||||||
info.clear_buttons();
|
|
||||||
}
|
|
||||||
return gui::CONTINUE_DIALOG;
|
|
||||||
}
|
|
||||||
|
|
||||||
void help_button::show_help()
|
|
||||||
{
|
|
||||||
help::show_help(video_, topic_);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool help_button::can_execute_command(const hotkey::hotkey_command& cmd, int/*index*/) const
|
|
||||||
{
|
|
||||||
hotkey::HOTKEY_COMMAND command = cmd.id;
|
|
||||||
return (topic_.empty() == false && command == hotkey::HOTKEY_HELP) || command == hotkey::HOTKEY_SCREENSHOT;
|
|
||||||
}
|
|
||||||
|
|
||||||
void help_button::join() {
|
|
||||||
dialog_button::join();
|
|
||||||
|
|
||||||
//wait until we join the event context to start a hotkey handler
|
|
||||||
delete help_hand_;
|
|
||||||
help_hand_ = new hotkey::basic_handler(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void help_button::leave() {
|
|
||||||
dialog_button::leave();
|
|
||||||
|
|
||||||
//now kill the hotkey handler
|
|
||||||
delete help_hand_;
|
|
||||||
help_hand_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace help
|
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (C) 2003 - 2017 by David White <dave@whitevine.net>
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "hotkey/command_executor.hpp"
|
|
||||||
#include "construct_dialog.hpp"
|
|
||||||
|
|
||||||
class config;
|
|
||||||
class CVideo;
|
|
||||||
|
|
||||||
namespace help {
|
|
||||||
|
|
||||||
class help_button : public gui::dialog_button, public hotkey::command_executor {
|
|
||||||
public:
|
|
||||||
help_button(CVideo& video, const std::string &help_topic);
|
|
||||||
~help_button();
|
|
||||||
int action(gui::dialog_process_info &info) override;
|
|
||||||
std::string topic() const { return topic_; }
|
|
||||||
void join() override;
|
|
||||||
void leave() override;
|
|
||||||
CVideo& get_video() override { return video_; }
|
|
||||||
private:
|
|
||||||
void show_help() override;
|
|
||||||
bool can_execute_command(const hotkey::hotkey_command& command, int/*index*/ =-1) const override;
|
|
||||||
|
|
||||||
CVideo &video_;
|
|
||||||
const std::string topic_;
|
|
||||||
hotkey::basic_handler *help_hand_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace help
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#include "show_dialog.hpp"
|
#include "show_dialog.hpp"
|
||||||
|
|
||||||
#include "construct_dialog.hpp"
|
|
||||||
#include "floating_label.hpp"
|
#include "floating_label.hpp"
|
||||||
#include "font/sdl_ttf.hpp"
|
#include "font/sdl_ttf.hpp"
|
||||||
#include "image.hpp"
|
#include "image.hpp"
|
||||||
|
|
|
@ -114,38 +114,4 @@ private:
|
||||||
bool dirty_;
|
bool dirty_;
|
||||||
};
|
};
|
||||||
|
|
||||||
//frame_measurements draw_dialog_frame(int x, int y, int w, int h, CVideo &video, const std::string* dialog_style=nullptr, surface_restorer* restorer=nullptr);
|
|
||||||
|
|
||||||
//SDL_Rect draw_dialog_background(int x, int y, int w, int h, CVideo &video, const std::string& dialog_style);
|
|
||||||
|
|
||||||
//given the location of a dialog, will draw its title.
|
|
||||||
//Returns the area the title takes up
|
|
||||||
//SDL_Rect draw_dialog_title(int x, int y, CVideo* disp, const std::string& text, label** label_widget);
|
|
||||||
|
|
||||||
//function to draw a dialog on the screen. x,y,w,h give the dimensions of the client area
|
|
||||||
//of the dialog. 'title' is the title of the dialog. The title will be displayed at the
|
|
||||||
//top of the dialog above the client area. 'dialog_style' if present gives the style of
|
|
||||||
//the dialog to use.
|
|
||||||
//'buttons' contains pointers to standard dialog buttons such as 'ok' and 'cancel' that
|
|
||||||
//will appear on the dialog. If present, they will be located at the bottom of the dialog,
|
|
||||||
//below the client area.
|
|
||||||
//if 'restorer' is present, it will be set to a restorer that will reset the screen area
|
|
||||||
//to its original state after the dialog is drawn.
|
|
||||||
//void draw_dialog(int x, int y, int w, int h, CVideo &video, const std::string& title,
|
|
||||||
// const std::string* dialog_style=nullptr, std::vector<button*>* buttons=nullptr,
|
|
||||||
// surface_restorer* restorer=nullptr, button* help_button=nullptr, label** label_widget);
|
|
||||||
//void draw_dialog(frame_measurements &fm, CVideo &video, const std::string& title,
|
|
||||||
// const std::string* dialog_style=nullptr, std::vector<button*>* buttons=nullptr,
|
|
||||||
// surface_restorer* restorer=nullptr, button* help_button=nullptr, label** label_widget);
|
|
||||||
|
|
||||||
class dialog_button_action
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~dialog_button_action() {}
|
|
||||||
|
|
||||||
typedef DIALOG_RESULT RESULT;
|
|
||||||
|
|
||||||
virtual RESULT button_pressed() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue