GUI2: basic dialog definition for a Hotkey Bind dialog (not enabled)
Still need to determine proper event handling.
This commit is contained in:
parent
fcf71a249a
commit
e7cdb76a01
7 changed files with 186 additions and 0 deletions
46
data/gui/window/hotkey_bind.cfg
Normal file
46
data/gui/window/hotkey_bind.cfg
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#textdomain wesnoth-lib
|
||||||
|
###
|
||||||
|
### Hotkey bind dialog.
|
||||||
|
###
|
||||||
|
|
||||||
|
[window]
|
||||||
|
id = "hotkey_bind"
|
||||||
|
description = "Bind action to new hotkey."
|
||||||
|
|
||||||
|
[resolution]
|
||||||
|
definition = "message"
|
||||||
|
|
||||||
|
maximum_width = 600
|
||||||
|
|
||||||
|
[tooltip]
|
||||||
|
id = "tooltip"
|
||||||
|
[/tooltip]
|
||||||
|
|
||||||
|
[helptip]
|
||||||
|
id = "tooltip"
|
||||||
|
[/helptip]
|
||||||
|
|
||||||
|
[grid]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
border = "all"
|
||||||
|
border_size = 10
|
||||||
|
|
||||||
|
horizontal_grow = true
|
||||||
|
|
||||||
|
[label]
|
||||||
|
definition = "default"
|
||||||
|
label = _ "Press desired hotkey (Esc cancels)"
|
||||||
|
[/label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[/grid]
|
||||||
|
|
||||||
|
[/resolution]
|
||||||
|
|
||||||
|
[/window]
|
|
@ -593,6 +593,8 @@
|
||||||
<Unit filename="../../src/gui/dialogs/gamestate_inspector.cpp" />
|
<Unit filename="../../src/gui/dialogs/gamestate_inspector.cpp" />
|
||||||
<Unit filename="../../src/gui/dialogs/gamestate_inspector.hpp" />
|
<Unit filename="../../src/gui/dialogs/gamestate_inspector.hpp" />
|
||||||
<Unit filename="../../src/gui/dialogs/helper.hpp" />
|
<Unit filename="../../src/gui/dialogs/helper.hpp" />
|
||||||
|
<Unit filename="../../src/gui/dialogs/hotkey_bind.cpp" />
|
||||||
|
<Unit filename="../../src/gui/dialogs/hotkey_bind.hpp" />
|
||||||
<Unit filename="../../src/gui/dialogs/label_settings.cpp" />
|
<Unit filename="../../src/gui/dialogs/label_settings.cpp" />
|
||||||
<Unit filename="../../src/gui/dialogs/label_settings.hpp" />
|
<Unit filename="../../src/gui/dialogs/label_settings.hpp" />
|
||||||
<Unit filename="../../src/gui/dialogs/language_selection.cpp" />
|
<Unit filename="../../src/gui/dialogs/language_selection.cpp" />
|
||||||
|
|
|
@ -201,6 +201,7 @@ gui/dialogs/game_save.cpp
|
||||||
gui/dialogs/game_stats.cpp
|
gui/dialogs/game_stats.cpp
|
||||||
gui/dialogs/game_version.cpp
|
gui/dialogs/game_version.cpp
|
||||||
gui/dialogs/gamestate_inspector.cpp
|
gui/dialogs/gamestate_inspector.cpp
|
||||||
|
gui/dialogs/hotkey_bind.cpp
|
||||||
gui/dialogs/label_settings.cpp
|
gui/dialogs/label_settings.cpp
|
||||||
gui/dialogs/language_selection.cpp
|
gui/dialogs/language_selection.cpp
|
||||||
gui/dialogs/loading_screen.cpp
|
gui/dialogs/loading_screen.cpp
|
||||||
|
|
56
src/gui/dialogs/hotkey_bind.cpp
Normal file
56
src/gui/dialogs/hotkey_bind.cpp
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2016 by 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/hotkey_bind.hpp"
|
||||||
|
|
||||||
|
#include "gui/widgets/settings.hpp"
|
||||||
|
#include "gui/widgets/window.hpp"
|
||||||
|
|
||||||
|
namespace gui2
|
||||||
|
{
|
||||||
|
namespace dialogs
|
||||||
|
{
|
||||||
|
|
||||||
|
REGISTER_DIALOG(hotkey_bind)
|
||||||
|
|
||||||
|
hotkey_bind::hotkey_bind(const std::string& hotkey_id)
|
||||||
|
: hotkey_id_(hotkey_id)
|
||||||
|
, new_binding_()
|
||||||
|
{
|
||||||
|
set_restore(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hotkey_bind::pre_show(window& window)
|
||||||
|
{
|
||||||
|
window.connect_signal<event::SDL_KEY_DOWN>(
|
||||||
|
std::bind(&hotkey_bind::key_press_callback, this, _3, _4, _5), event::dispatcher::back_child);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hotkey_bind::key_press_callback(bool&, bool&, const SDL_Keycode key)
|
||||||
|
{
|
||||||
|
UNUSED(key);
|
||||||
|
|
||||||
|
//new_binding_ = hotkey::create_hotkey(hotkey_id_, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hotkey_bind::post_show(window& window)
|
||||||
|
{
|
||||||
|
if(window.get_retval() == window::OK) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace dialogs
|
||||||
|
} // namespace gui2
|
59
src/gui/dialogs/hotkey_bind.hpp
Normal file
59
src/gui/dialogs/hotkey_bind.hpp
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2016 by 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_HOTKEY_BIND_HPP_INCLUDED
|
||||||
|
#define GUI_DIALOGS_HOTKEY_BIND_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include "gui/dialogs/modal_dialog.hpp"
|
||||||
|
#include "hotkey/hotkey_item.hpp"
|
||||||
|
|
||||||
|
#include <SDL_keycode.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace gui2
|
||||||
|
{
|
||||||
|
namespace dialogs
|
||||||
|
{
|
||||||
|
|
||||||
|
class hotkey_bind : public modal_dialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit hotkey_bind(const std::string& hotkey_id);
|
||||||
|
|
||||||
|
hotkey::hotkey_ptr get_new_binding() const
|
||||||
|
{
|
||||||
|
return new_binding_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::string& hotkey_id_;
|
||||||
|
|
||||||
|
hotkey::hotkey_ptr new_binding_;
|
||||||
|
|
||||||
|
void key_press_callback(bool&, bool&, const SDL_Keycode key);
|
||||||
|
|
||||||
|
/** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
|
||||||
|
virtual const std::string& window_id() const;
|
||||||
|
|
||||||
|
/** Inherited from modal_dialog. */
|
||||||
|
void pre_show(window& window);
|
||||||
|
|
||||||
|
/** Inherited from modal_dialog. */
|
||||||
|
void post_show(window& window);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dialogs
|
||||||
|
} // namespace gui2
|
||||||
|
|
||||||
|
#endif /* ! GUI_DIALOGS_HOTKEY_BIND_HPP_INCLUDED */
|
|
@ -33,6 +33,7 @@
|
||||||
// Sub-dialog includes
|
// Sub-dialog includes
|
||||||
#include "gui/dialogs/advanced_graphics_options.hpp"
|
#include "gui/dialogs/advanced_graphics_options.hpp"
|
||||||
#include "gui/dialogs/game_cache_options.hpp"
|
#include "gui/dialogs/game_cache_options.hpp"
|
||||||
|
#include "gui/dialogs/hotkey_bind.hpp"
|
||||||
#include "gui/dialogs/log_settings.hpp"
|
#include "gui/dialogs/log_settings.hpp"
|
||||||
#include "gui/dialogs/multiplayer/mp_alerts_options.hpp"
|
#include "gui/dialogs/multiplayer/mp_alerts_options.hpp"
|
||||||
#include "gui/dialogs/select_orb_colors.hpp"
|
#include "gui/dialogs/select_orb_colors.hpp"
|
||||||
|
@ -818,6 +819,15 @@ void preferences_dialog::add_hotkey_callback(listbox& hotkeys)
|
||||||
CVideo& video = hotkeys.get_window()->video();
|
CVideo& video = hotkeys.get_window()->video();
|
||||||
int row_number = hotkeys.get_selected_row();
|
int row_number = hotkeys.get_selected_row();
|
||||||
const hotkey::hotkey_command& hotkey_item = *visible_hotkeys_[row_number];
|
const hotkey::hotkey_command& hotkey_item = *visible_hotkeys_[row_number];
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
#if 0
|
||||||
|
gui2::dialogs::hotkey_bind bind_dlg(hotkey_item.command);
|
||||||
|
bind_dlg.show(video);
|
||||||
|
|
||||||
|
hotkey::hotkey_ptr newhk = bind_dlg.get_new_binding();
|
||||||
|
#endif
|
||||||
|
|
||||||
hotkey::hotkey_ptr newhk = hotkey::show_binding_dialog(video, hotkey_item.command);
|
hotkey::hotkey_ptr newhk = hotkey::show_binding_dialog(video, hotkey_item.command);
|
||||||
hotkey::hotkey_ptr oldhk;
|
hotkey::hotkey_ptr oldhk;
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
#include "gui/dialogs/game_save.hpp"
|
#include "gui/dialogs/game_save.hpp"
|
||||||
#include "gui/dialogs/game_stats.hpp"
|
#include "gui/dialogs/game_stats.hpp"
|
||||||
#include "gui/dialogs/gamestate_inspector.hpp"
|
#include "gui/dialogs/gamestate_inspector.hpp"
|
||||||
|
#include "gui/dialogs/hotkey_bind.hpp"
|
||||||
#include "gui/dialogs/label_settings.hpp"
|
#include "gui/dialogs/label_settings.hpp"
|
||||||
#include "gui/dialogs/language_selection.hpp"
|
#include "gui/dialogs/language_selection.hpp"
|
||||||
#include "gui/dialogs/loading_screen.hpp"
|
#include "gui/dialogs/loading_screen.hpp"
|
||||||
|
@ -791,6 +792,17 @@ struct dialog_tester<install_dependencies>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct dialog_tester<hotkey_bind>
|
||||||
|
{
|
||||||
|
std::string id = "";
|
||||||
|
|
||||||
|
hotkey_bind* create()
|
||||||
|
{
|
||||||
|
return new hotkey_bind(id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct wesnothd_connection_init
|
struct wesnothd_connection_init
|
||||||
{
|
{
|
||||||
wesnothd_connection_init(wesnothd_connection& conn)
|
wesnothd_connection_init(wesnothd_connection& conn)
|
||||||
|
|
Loading…
Add table
Reference in a new issue