summaryrefslogtreecommitdiff
path: root/src/misc_gui.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-01-05 18:06:48 +0100
committerPatric Stout <github@truebrain.nl>2021-01-05 21:56:24 +0100
commit62cdadb58207b28dfdf1ab4ceb46278c2561f079 (patch)
treed6e8308cf106daf372ad673d87169f075d3c3a86 /src/misc_gui.cpp
parentd6e15d4943936a89d275354ee59d0e3b7c6a2018 (diff)
downloadopenttd-62cdadb58207b28dfdf1ab4ceb46278c2561f079.tar.xz
Change: move "give money" from client-list to company window
This is a much better location for this button, as you send money from one company to another company, not from player to player. This is based on work done by JGRPP in: https://github.com/JGRennison/OpenTTD-patches/commit/f82054339124cc6b89c5f4f9dac2d9da62f0108b and surrounding commits, which took the work from estys: https://www.tt-forums.net/viewtopic.php?p=1183311#p1183311 We did modify it to fix several bugs and clean up the code while here anyway. The callback was removed, as it meant a modified client could prevent anyone from seeing money was transfered. The message is now generated in the command itself, making that impossible.
Diffstat (limited to 'src/misc_gui.cpp')
-rw-r--r--src/misc_gui.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 17a460bf5..c78bd05ef 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -1047,13 +1047,9 @@ struct QueryStringWindow : public Window
void OnOk()
{
if (this->editbox.orig == nullptr || strcmp(this->editbox.text.buf, this->editbox.orig) != 0) {
- /* If the parent is nullptr, the editbox is handled by general function
- * HandleOnEditText */
- if (this->parent != nullptr) {
- this->parent->OnQueryTextFinished(this->editbox.text.buf);
- } else {
- HandleOnEditText(this->editbox.text.buf);
- }
+ assert(this->parent != nullptr);
+
+ this->parent->OnQueryTextFinished(this->editbox.text.buf);
this->editbox.handled = true;
}
}
@@ -1113,13 +1109,14 @@ static WindowDesc _query_string_desc(
* @param str StringID for the text shown in the textbox
* @param caption StringID of text shown in caption of querywindow
* @param maxsize maximum size in bytes or characters (including terminating '\0') depending on flags
- * @param parent pointer to a Window that will handle the events (ok/cancel) of this
- * window. If nullptr, results are handled by global function HandleOnEditText
+ * @param parent pointer to a Window that will handle the events (ok/cancel) of this window.
* @param afilter filters out unwanted character input
* @param flags various flags, @see QueryStringFlags
*/
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
{
+ assert(parent != nullptr);
+
DeleteWindowByClass(WC_QUERY_STRING);
new QueryStringWindow(str, caption, ((flags & QSF_LEN_IN_CHARS) ? MAX_CHAR_LENGTH : 1) * maxsize, maxsize, &_query_string_desc, parent, afilter, flags);
}