Have /report show a dialog for entering information. (#6969)
Resolves #5056
This commit is contained in:
parent
e2b1295ac6
commit
0e85fac29c
11 changed files with 477 additions and 8 deletions
|
@ -32,6 +32,7 @@ test_gui2/modal_dialog_test_hotkey_bind
|
|||
test_gui2/modal_dialog_test_install_dependencies
|
||||
test_gui2/modal_dialog_test_language_selection
|
||||
test_gui2/modal_dialog_test_mp_lobby
|
||||
test_gui2/modal_dialog_test_mp_report
|
||||
test_gui2/modal_dialog_test_lobby_player_info
|
||||
test_gui2/modal_dialog_test_log_settings
|
||||
test_gui2/modal_dialog_test_message
|
||||
|
|
266
data/gui/window/mp_report.cfg
Normal file
266
data/gui/window/mp_report.cfg
Normal file
|
@ -0,0 +1,266 @@
|
|||
#textdomain wesnoth-lib
|
||||
###
|
||||
### Definition of the window to provide authentication information when uploading an add-on
|
||||
###
|
||||
|
||||
[window]
|
||||
id = "mp_report"
|
||||
description = "Multiplayer dialog for /report dialog"
|
||||
|
||||
[resolution]
|
||||
definition = "default"
|
||||
|
||||
automatic_placement = true
|
||||
vertical_placement = "center"
|
||||
horizontal_placement = "center"
|
||||
|
||||
maximum_width = 800
|
||||
|
||||
[tooltip]
|
||||
id = "tooltip"
|
||||
[/tooltip]
|
||||
|
||||
[helptip]
|
||||
id = "tooltip"
|
||||
[/helptip]
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
label = _ "* Player being reported:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[text_box]
|
||||
id = "reportee"
|
||||
definition = "default"
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
label = _ "* Reason for report:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[text_box]
|
||||
id = "report_reason"
|
||||
definition = "default"
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
label = _ "Location of occurrence:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[menu_button]
|
||||
id = "occurrence_location"
|
||||
definition = "default"
|
||||
[/menu_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
label = _ "Additional information:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[text_box]
|
||||
id = "additional_information"
|
||||
definition = "default"
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[label]
|
||||
definition = "gold_small"
|
||||
label = _ "* required fields"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[spacer]
|
||||
[/spacer]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "center"
|
||||
|
||||
[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]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/resolution]
|
||||
|
||||
[/window]
|
|
@ -689,6 +689,8 @@
|
|||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_method_selection.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_options_helper.cpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_options_helper.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_report.cpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_report.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_staging.cpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_staging.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/player_info.cpp" />
|
||||
|
|
|
@ -684,6 +684,8 @@
|
|||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_method_selection.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_options_helper.cpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_options_helper.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_report.cpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_report.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_staging.cpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/mp_staging.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/multiplayer/player_info.cpp" />
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
1234567890ABCDEF12345679 /* file_progress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1234567890ABCDEF12345680 /* file_progress.cpp */; };
|
||||
36B146FAA79A55E9F43723B1 /* general.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84234C54BB84519421FD4136 /* general.cpp */; };
|
||||
4291489DA38012477DA3BA7C /* general.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84234C54BB84519421FD4136 /* general.cpp */; };
|
||||
3C254DF5B7DF196F2041955F /* mp_report.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 58C649488B3014E6F7254B62 /* mp_report.cpp */; };
|
||||
460CA6D52143362800B89741 /* apple_version.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46F54C26211DFB7200374A1C /* apple_version.mm */; };
|
||||
460D898624DC7831000B1ABC /* game.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 460D897824DC7830000B1ABC /* game.cpp */; };
|
||||
460D898724DC7831000B1ABC /* ban.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 460D897C24DC7830000B1ABC /* ban.cpp */; };
|
||||
|
@ -630,6 +631,7 @@
|
|||
62D24F2F1519982500350848 /* editor_toolkit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 62D24F2B1519982500350848 /* editor_toolkit.cpp */; };
|
||||
62D24F321519987400350848 /* context_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 62D24F311519987400350848 /* context_manager.cpp */; };
|
||||
62D24F351519995200350848 /* palette_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 62D24F341519995200350848 /* palette_manager.cpp */; };
|
||||
87744447951D17AA38BE5F48 /* mp_report.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 58C649488B3014E6F7254B62 /* mp_report.cpp */; };
|
||||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
|
||||
903F959C1ED5489500F1BDD3 /* credentials.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 903F959B1ED5489500F1BDD3 /* credentials.cpp */; };
|
||||
903F959F1ED5496700F1BDD3 /* hash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B52EE8AD121359A600CFBDAB /* hash.cpp */; };
|
||||
|
@ -2032,6 +2034,7 @@
|
|||
4944F41A1354FBFF0027E614 /* teleport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = teleport.cpp; sourceTree = "<group>"; };
|
||||
49478712172FF6F8002B7ABA /* tristate_button.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tristate_button.cpp; sourceTree = "<group>"; };
|
||||
49478713172FF6F8002B7ABA /* tristate_button.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tristate_button.hpp; sourceTree = "<group>"; };
|
||||
58C649488B3014E6F7254B62 /* mp_report.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mp_report.cpp; path = mp_report.cpp; sourceTree = "<group>"; };
|
||||
620A386215E9364E00A4F513 /* attack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = attack.cpp; sourceTree = "<group>"; };
|
||||
620A386315E9364E00A4F513 /* attack.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = attack.hpp; sourceTree = "<group>"; };
|
||||
620A386415E9364E00A4F513 /* create.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = create.cpp; sourceTree = "<group>"; };
|
||||
|
@ -3785,6 +3788,7 @@
|
|||
46F92CCB2174F6A300602C1C /* plugin_executor.hpp */,
|
||||
46F92CDD2174F6A300602C1C /* synced_choice_wait.cpp */,
|
||||
46F92CC52174F6A300602C1C /* synced_choice_wait.hpp */,
|
||||
58C649488B3014E6F7254B62 /* mp_report.cpp */,
|
||||
);
|
||||
path = multiplayer;
|
||||
sourceTree = "<group>";
|
||||
|
@ -5712,6 +5716,7 @@
|
|||
46F92E232174F6A400602C1C /* lobby.cpp in Sources */,
|
||||
46F92E212174F6A400602C1C /* mp_change_control.cpp in Sources */,
|
||||
36B146FAA79A55E9F43723B1 /* general.cpp in Sources */,
|
||||
3C254DF5B7DF196F2041955F /* mp_report.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -6373,6 +6378,7 @@
|
|||
46F92C172174F5D700602C1C /* help_browser.cpp in Sources */,
|
||||
915C68EC1DF1DCB000594B07 /* color.cpp in Sources */,
|
||||
4291489DA38012477DA3BA7C /* general.cpp in Sources */,
|
||||
87744447951D17AA38BE5F48 /* mp_report.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -202,7 +202,6 @@ gui/dialogs/game_load.cpp
|
|||
gui/dialogs/game_save.cpp
|
||||
gui/dialogs/game_stats.cpp
|
||||
gui/dialogs/game_version_dialog.cpp
|
||||
gui/dialogs/server_info_dialog.cpp
|
||||
gui/dialogs/gamestate_inspector.cpp
|
||||
gui/dialogs/help_browser.cpp
|
||||
gui/dialogs/hotkey_bind.cpp
|
||||
|
@ -229,6 +228,7 @@ gui/dialogs/multiplayer/mp_join_game_password_prompt.cpp
|
|||
gui/dialogs/multiplayer/mp_login.cpp
|
||||
gui/dialogs/multiplayer/mp_method_selection.cpp
|
||||
gui/dialogs/multiplayer/mp_options_helper.cpp
|
||||
gui/dialogs/multiplayer/mp_report.cpp
|
||||
gui/dialogs/multiplayer/mp_staging.cpp
|
||||
gui/dialogs/multiplayer/player_info.cpp
|
||||
gui/dialogs/multiplayer/player_list_helper.cpp
|
||||
|
@ -238,6 +238,7 @@ gui/dialogs/outro.cpp
|
|||
gui/dialogs/preferences_dialog.cpp
|
||||
gui/dialogs/screenshot_notification.cpp
|
||||
gui/dialogs/select_orb_colors.cpp
|
||||
gui/dialogs/server_info_dialog.cpp
|
||||
gui/dialogs/simple_item_selector.cpp
|
||||
gui/dialogs/sp_options_configure.cpp
|
||||
gui/dialogs/statistics_dialog.cpp
|
||||
|
@ -283,6 +284,7 @@ help/help_topic_generators.cpp
|
|||
hotkey/hotkey_handler.cpp
|
||||
hotkey/hotkey_handler_mp.cpp
|
||||
hotkey/hotkey_handler_sp.cpp
|
||||
map_settings.cpp
|
||||
menu_events.cpp
|
||||
mouse_events.cpp
|
||||
mouse_handler_base.cpp
|
||||
|
@ -327,30 +329,29 @@ scripting/lua_cpp_function.cpp
|
|||
scripting/lua_fileops.cpp
|
||||
scripting/lua_formula_bridge.cpp
|
||||
scripting/lua_gui2.cpp
|
||||
scripting/lua_wml.cpp
|
||||
scripting/lua_stringx.cpp
|
||||
scripting/lua_mathx.cpp
|
||||
scripting/lua_kernel_base.cpp
|
||||
scripting/lua_map_location_ops.cpp
|
||||
scripting/lua_mathx.cpp
|
||||
scripting/lua_preferences.cpp
|
||||
scripting/lua_race.cpp
|
||||
scripting/lua_rng.cpp
|
||||
scripting/lua_stringx.cpp
|
||||
scripting/lua_team.cpp
|
||||
scripting/lua_terrainmap.cpp
|
||||
scripting/lua_terrainfilter.cpp
|
||||
scripting/lua_terrainmap.cpp
|
||||
scripting/lua_unit.cpp
|
||||
scripting/lua_unit_attacks.cpp
|
||||
scripting/lua_unit_type.cpp
|
||||
scripting/lua_widget.cpp
|
||||
scripting/lua_widget_attributes.cpp
|
||||
scripting/lua_widget_methods.cpp
|
||||
scripting/lua_wml.cpp
|
||||
scripting/mapgen_lua_kernel.cpp
|
||||
scripting/plugins/context.cpp
|
||||
scripting/plugins/manager.cpp
|
||||
sdl/point.cpp
|
||||
sdl/input.cpp
|
||||
sdl/point.cpp
|
||||
sdl/texture.cpp
|
||||
map_settings.cpp
|
||||
side_filter.cpp
|
||||
statistics.cpp
|
||||
storyscreen/controller.cpp
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "chat_events.hpp"
|
||||
#include "game_initialization/multiplayer.hpp"
|
||||
#include "game_version.hpp"
|
||||
#include "gui/dialogs/multiplayer/mp_report.hpp"
|
||||
#include "gui/dialogs/preferences_dialog.hpp"
|
||||
#include "map_command_handler.hpp"
|
||||
#include "preferences/display.hpp"
|
||||
|
@ -44,6 +45,11 @@ void chat_command_handler::do_network_send()
|
|||
chat_handler_.send_command(get_cmd(), get_data());
|
||||
}
|
||||
|
||||
void chat_command_handler::do_network_send(const std::string& data)
|
||||
{
|
||||
chat_handler_.send_command(get_cmd(), data);
|
||||
}
|
||||
|
||||
void chat_command_handler::do_network_send_req_arg()
|
||||
{
|
||||
if (get_data(1).empty()) return command_failed_need_arg(1);
|
||||
|
@ -139,4 +145,13 @@ void chat_command_handler::do_clear_messages() {
|
|||
chat_handler_.clear_messages();
|
||||
}
|
||||
|
||||
void chat_command_handler::do_mp_report() {
|
||||
std::string report_text;
|
||||
gui2::dialogs::mp_report::execute(report_text);
|
||||
|
||||
if(!report_text.empty()) {
|
||||
do_network_send(report_text);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
protected:
|
||||
void do_emote();
|
||||
void do_network_send();
|
||||
void do_network_send(const std::string& data);
|
||||
void do_network_send_req_arg();
|
||||
void do_whisper();
|
||||
void do_log();
|
||||
|
@ -41,6 +42,7 @@ protected:
|
|||
void do_display();
|
||||
void do_version();
|
||||
void do_clear_messages();
|
||||
void do_mp_report();
|
||||
|
||||
/** Request information about a user from the server. */
|
||||
void do_info();
|
||||
|
@ -88,7 +90,7 @@ protected:
|
|||
_("Mute/Unmute all observers. (toggles)"), "");
|
||||
register_command("ping", &chat_command_handler::do_network_send,
|
||||
_("Send some data to the server. Can be used to verify the network connection and notice disconnects."));
|
||||
register_command("report", &chat_command_handler::do_network_send_req_arg,
|
||||
register_command("report", &chat_command_handler::do_mp_report,
|
||||
_("Report abuse, rule violations, etc. to the server moderators. "
|
||||
"Make sure to mention relevant nicknames, etc."), "");
|
||||
register_alias("report", "adminmsg"); // deprecated
|
||||
|
|
102
src/gui/dialogs/multiplayer/mp_report.cpp
Normal file
102
src/gui/dialogs/multiplayer/mp_report.cpp
Normal file
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
Copyright (C) 2008 - 2022
|
||||
Part of the Battle for Wesnoth Project https://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 <functional>
|
||||
|
||||
#include "gui/dialogs/multiplayer/mp_report.hpp"
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/menu_button.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "preferences/credentials.hpp"
|
||||
|
||||
namespace gui2::dialogs
|
||||
{
|
||||
|
||||
REGISTER_DIALOG(mp_report)
|
||||
|
||||
// static t_string std::array causes a core dump on start
|
||||
const std::array<std::string, 3> mp_report::occurrence_locations = {"Lobby", "Whisper", "Game"};
|
||||
|
||||
mp_report::mp_report(std::string& report_text)
|
||||
: modal_dialog(window_id())
|
||||
, report_text_(report_text)
|
||||
, reportee_empty_(true)
|
||||
, report_reason_empty_(true)
|
||||
{
|
||||
}
|
||||
|
||||
void mp_report::pre_show(window& win)
|
||||
{
|
||||
std::vector<config> occurrence_location_entries;
|
||||
occurrence_location_entries.emplace_back("label", _("Lobby"));
|
||||
occurrence_location_entries.emplace_back("label", _("Whisper"));
|
||||
occurrence_location_entries.emplace_back("label", _("Game"));
|
||||
|
||||
find_widget<menu_button>(&win, "occurrence_location", false).set_values(occurrence_location_entries);
|
||||
|
||||
button& ok = find_widget<button>(&win, "ok", false);
|
||||
ok.set_active(false);
|
||||
|
||||
text_box& reportee = find_widget<text_box>(&win, "reportee", false);
|
||||
reportee.set_text_changed_callback(std::bind(&mp_report::reportee_changed, this, std::placeholders::_2));
|
||||
|
||||
text_box& report_reason = find_widget<text_box>(&win, "report_reason", false);
|
||||
report_reason.set_text_changed_callback(std::bind(&mp_report::report_reason_changed, this, std::placeholders::_2));
|
||||
|
||||
win.set_exit_hook_ok_only([this](window&)->bool { return !reportee_empty_ && !report_reason_empty_; });
|
||||
}
|
||||
|
||||
void mp_report::post_show(window& window)
|
||||
{
|
||||
if(get_retval() == gui2::retval::OK)
|
||||
{
|
||||
const text_box& reportee = find_widget<const text_box>(&window, "reportee", false);
|
||||
const text_box& report_reason = find_widget<const text_box>(&window, "report_reason", false);
|
||||
const menu_button& occurrence_location = find_widget<const menu_button>(&window, "occurrence_location", false);
|
||||
const std::string additional_information = find_widget<const text_box>(&window, "additional_information", false).get_value();
|
||||
|
||||
std::ostringstream report;
|
||||
report << "Reporting player '" << reportee.get_value() << "' for reason '" << report_reason.get_value() << "'."
|
||||
<< " Location of occurrence is '" << occurrence_locations[occurrence_location.get_value()] << "'.";
|
||||
if(additional_information.size() > 0)
|
||||
{
|
||||
report << " Additional information provided: '" << additional_information << "'.";
|
||||
}
|
||||
report_text_ = report.str();
|
||||
}
|
||||
}
|
||||
|
||||
void mp_report::reportee_changed(const std::string& text)
|
||||
{
|
||||
reportee_empty_ = text.empty();
|
||||
|
||||
button& ok = find_widget<button>(get_window(), "ok", false);
|
||||
ok.set_active(!reportee_empty_ && !report_reason_empty_);
|
||||
}
|
||||
|
||||
void mp_report::report_reason_changed(const std::string& text)
|
||||
{
|
||||
report_reason_empty_ = text.empty();
|
||||
|
||||
button& ok = find_widget<button>(get_window(), "ok", false);
|
||||
ok.set_active(!reportee_empty_ && !report_reason_empty_);
|
||||
}
|
||||
|
||||
} // namespace dialogs
|
57
src/gui/dialogs/multiplayer/mp_report.hpp
Normal file
57
src/gui/dialogs/multiplayer/mp_report.hpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
Copyright (C) 2008 - 2022
|
||||
Part of the Battle for Wesnoth Project https://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 "gui/dialogs/modal_dialog.hpp"
|
||||
|
||||
namespace gui2::dialogs
|
||||
{
|
||||
|
||||
/**
|
||||
* @ingroup GUIWindowDefinitionWML
|
||||
*
|
||||
* This shows a dialog to report players on the multiplayer server.
|
||||
*
|
||||
* Key |Type |Mandatory|Description
|
||||
* ----------------------|---------------|---------|-----------
|
||||
* reportee | text_box |yes |The person being reported.
|
||||
* report_reason | text_box |yes |Why they're being reported.
|
||||
* occurrence_location | menu_button |yes |Where in-game it happened.
|
||||
* additional_information| text_box |yes |Any additional information to add.
|
||||
*/
|
||||
class mp_report : public modal_dialog
|
||||
{
|
||||
public:
|
||||
mp_report(std::string& report_text_);
|
||||
|
||||
DEFINE_SIMPLE_EXECUTE_WRAPPER(mp_report)
|
||||
|
||||
private:
|
||||
virtual const std::string& window_id() const override;
|
||||
|
||||
virtual void pre_show(window& window) override;
|
||||
|
||||
virtual void post_show(window& window) override;
|
||||
|
||||
void reportee_changed(const std::string& text);
|
||||
void report_reason_changed(const std::string& text);
|
||||
|
||||
std::string& report_text_;
|
||||
bool reportee_empty_;
|
||||
bool report_reason_empty_;
|
||||
const static std::array<std::string, 3> occurrence_locations;
|
||||
};
|
||||
|
||||
} // namespace gui2::dialogs
|
|
@ -84,6 +84,7 @@
|
|||
#include "gui/dialogs/multiplayer/mp_join_game_password_prompt.hpp"
|
||||
#include "gui/dialogs/multiplayer/mp_login.hpp"
|
||||
#include "gui/dialogs/multiplayer/mp_method_selection.hpp"
|
||||
#include "gui/dialogs/multiplayer/mp_report.hpp"
|
||||
#include "gui/dialogs/multiplayer/mp_staging.hpp"
|
||||
#include "gui/dialogs/multiplayer/player_info.hpp"
|
||||
#include "gui/dialogs/outro.hpp"
|
||||
|
@ -536,6 +537,10 @@ BOOST_AUTO_TEST_CASE(modal_dialog_test_mp_method_selection)
|
|||
{
|
||||
test<mp_method_selection>();
|
||||
}
|
||||
BOOST_AUTO_TEST_CASE(modal_dialog_test_mp_report)
|
||||
{
|
||||
test<mp_report>();
|
||||
}
|
||||
BOOST_AUTO_TEST_CASE(modal_dialog_test_simple_item_selector)
|
||||
{
|
||||
test<simple_item_selector>();
|
||||
|
@ -1036,6 +1041,16 @@ struct dialog_tester<mp_join_game_password_prompt>
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct dialog_tester<mp_report>
|
||||
{
|
||||
std::string report_text;
|
||||
mp_report* create()
|
||||
{
|
||||
return new mp_report(report_text);
|
||||
}
|
||||
};
|
||||
|
||||
static std::vector<std::string> depcheck_mods {"mod_one", "some other", "more"};
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Add table
Reference in a new issue