mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-19 12:39:11 +00:00
(svn r24742) -Codechange: Remove QueryStringBaseWindow and store QueryStrings per widget instead.
This commit is contained in:
@@ -284,10 +284,11 @@ static void SendChat(const char *buf, DestType type, int dest)
|
||||
}
|
||||
|
||||
/** Window to enter the chat message in. */
|
||||
struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||
struct NetworkChatWindow : public Window {
|
||||
DestType dtype; ///< The type of destination.
|
||||
StringID dest_string; ///< String representation of the destination.
|
||||
int dest; ///< The identifier of the destination.
|
||||
QueryString message_editbox; ///< Message editbox.
|
||||
|
||||
/**
|
||||
* Create a chat input window.
|
||||
@@ -295,13 +296,14 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||
* @param type The type of destination.
|
||||
* @param dest The actual destination index.
|
||||
*/
|
||||
NetworkChatWindow(const WindowDesc *desc, DestType type, int dest) : QueryStringBaseWindow(NETWORK_CHAT_LENGTH)
|
||||
NetworkChatWindow(const WindowDesc *desc, DestType type, int dest) : message_editbox(NETWORK_CHAT_LENGTH)
|
||||
{
|
||||
this->dtype = type;
|
||||
this->dest = dest;
|
||||
this->cancel_button = WID_NC_CLOSE;
|
||||
this->ok_button = WID_NC_SENDBUTTON;
|
||||
this->afilter = CS_ALPHANUMERAL;
|
||||
this->querystrings[WID_NC_TEXTBOX] = &this->message_editbox;
|
||||
this->message_editbox.cancel_button = WID_NC_CLOSE;
|
||||
this->message_editbox.ok_button = WID_NC_SENDBUTTON;
|
||||
this->message_editbox.afilter = CS_ALPHANUMERAL;
|
||||
|
||||
static const StringID chat_captions[] = {
|
||||
STR_NETWORK_CHAT_ALL_CAPTION,
|
||||
@@ -383,9 +385,9 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||
void ChatTabCompletion()
|
||||
{
|
||||
static char _chat_tab_completion_buf[NETWORK_CHAT_LENGTH];
|
||||
assert(this->text.max_bytes == lengthof(_chat_tab_completion_buf));
|
||||
assert(this->message_editbox.text.max_bytes == lengthof(_chat_tab_completion_buf));
|
||||
|
||||
Textbuf *tb = &this->text;
|
||||
Textbuf *tb = &this->message_editbox.text;
|
||||
size_t len, tb_len;
|
||||
uint item;
|
||||
char *tb_buf, *pre_buf;
|
||||
@@ -437,9 +439,9 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||
|
||||
/* Change to the found name. Add ': ' if we are at the start of the line (pretty) */
|
||||
if (pre_buf == tb_buf) {
|
||||
this->text.Print("%s: ", cur_name);
|
||||
this->message_editbox.text.Print("%s: ", cur_name);
|
||||
} else {
|
||||
this->text.Print("%s %s", pre_buf, cur_name);
|
||||
this->message_editbox.text.Print("%s %s", pre_buf, cur_name);
|
||||
}
|
||||
|
||||
this->SetDirty();
|
||||
@@ -450,7 +452,7 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||
|
||||
if (second_scan) {
|
||||
/* We walked all posibilities, and the user presses tab again.. revert to original text */
|
||||
this->text.Assign(_chat_tab_completion_buf);
|
||||
this->message_editbox.text.Assign(_chat_tab_completion_buf);
|
||||
_chat_tab_completion_active = false;
|
||||
|
||||
this->SetDirty();
|
||||
@@ -491,7 +493,7 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||
{
|
||||
switch (widget) {
|
||||
/* Send */
|
||||
case WID_NC_SENDBUTTON: SendChat(this->text.buf, this->dtype, this->dest);
|
||||
case WID_NC_SENDBUTTON: SendChat(this->message_editbox.text.buf, this->dtype, this->dest);
|
||||
/* FALL THROUGH */
|
||||
case WID_NC_CLOSE: /* Cancel */ delete this; break;
|
||||
}
|
||||
|
@@ -276,7 +276,7 @@ public:
|
||||
};
|
||||
|
||||
/** Window that lists the content that's at the content server */
|
||||
class NetworkContentListWindow : public QueryStringBaseWindow, ContentCallback {
|
||||
class NetworkContentListWindow : public Window, ContentCallback {
|
||||
/** List with content infos. */
|
||||
typedef GUIList<const ContentInfo *, StringFilter &> GUIContentList;
|
||||
|
||||
@@ -289,6 +289,7 @@ class NetworkContentListWindow : public QueryStringBaseWindow, ContentCallback {
|
||||
GUIContentList content; ///< List with content
|
||||
bool auto_select; ///< Automatically select all content when the meta-data becomes available
|
||||
StringFilter string_filter; ///< Filter for content list
|
||||
QueryString filter_editbox; ///< Filter editbox;
|
||||
|
||||
const ContentInfo *selected; ///< The selected content info
|
||||
int list_pos; ///< Our position in the list
|
||||
@@ -405,8 +406,8 @@ public:
|
||||
* @param select_all Whether the select all button is allowed or not.
|
||||
*/
|
||||
NetworkContentListWindow(const WindowDesc *desc, bool select_all) :
|
||||
QueryStringBaseWindow(EDITBOX_MAX_SIZE),
|
||||
auto_select(select_all),
|
||||
filter_editbox(EDITBOX_MAX_SIZE),
|
||||
selected(NULL),
|
||||
list_pos(0)
|
||||
{
|
||||
@@ -416,7 +417,8 @@ public:
|
||||
|
||||
this->GetWidget<NWidgetStacked>(WID_NCL_SEL_ALL_UPDATE)->SetDisplayedPlane(select_all);
|
||||
|
||||
this->afilter = CS_ALPHANUMERAL;
|
||||
this->querystrings[WID_NCL_FILTER] = &this->filter_editbox;
|
||||
this->filter_editbox.afilter = CS_ALPHANUMERAL;
|
||||
this->SetFocusedWidget(WID_NCL_FILTER);
|
||||
|
||||
_network_content_client.AddCallback(this);
|
||||
@@ -780,7 +782,7 @@ public:
|
||||
virtual void OnEditboxChanged(int wid)
|
||||
{
|
||||
if (wid == WID_NCL_FILTER) {
|
||||
this->string_filter.SetFilterTerm(this->text.buf);
|
||||
this->string_filter.SetFilterTerm(this->filter_editbox.text.buf);
|
||||
this->content.SetFilterState(!this->string_filter.IsEmpty());
|
||||
this->content.ForceRebuild();
|
||||
this->InvalidateData();
|
||||
|
@@ -209,7 +209,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class NetworkGameWindow : public QueryStringBaseWindow {
|
||||
class NetworkGameWindow : public Window {
|
||||
protected:
|
||||
/* Runtime saved values */
|
||||
static Listing last_sorting;
|
||||
@@ -222,6 +222,7 @@ protected:
|
||||
GUIGameServerList servers; ///< list with game servers.
|
||||
ServerListPosition list_pos; ///< position of the selected server
|
||||
Scrollbar *vscroll;
|
||||
QueryString name_editbox; ///< Client name editbox.
|
||||
|
||||
/**
|
||||
* (Re)build the network game list as its amount has changed because
|
||||
@@ -435,7 +436,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
NetworkGameWindow(const WindowDesc *desc) : QueryStringBaseWindow(NETWORK_CLIENT_NAME_LENGTH)
|
||||
NetworkGameWindow(const WindowDesc *desc) : name_editbox(NETWORK_CLIENT_NAME_LENGTH)
|
||||
{
|
||||
this->list_pos = SLP_INVALID;
|
||||
this->server = NULL;
|
||||
@@ -444,8 +445,9 @@ public:
|
||||
this->vscroll = this->GetScrollbar(WID_NG_SCROLLBAR);
|
||||
this->FinishInitNested(desc, WN_NETWORK_WINDOW_GAME);
|
||||
|
||||
this->text.Assign(_settings_client.network.client_name);
|
||||
this->afilter = CS_ALPHANUMERAL;
|
||||
this->querystrings[WID_NG_CLIENT] = &this->name_editbox;
|
||||
this->name_editbox.text.Assign(_settings_client.network.client_name);
|
||||
this->name_editbox.afilter = CS_ALPHANUMERAL;
|
||||
this->SetFocusedWidget(WID_NG_CLIENT);
|
||||
|
||||
this->last_joined = NetworkGameListAddItem(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port));
|
||||
@@ -850,8 +852,8 @@ public:
|
||||
{
|
||||
if (wid == WID_NG_CLIENT) {
|
||||
/* The name is only allowed when it starts with a letter! */
|
||||
if (!StrEmpty(this->text.buf) && this->text.buf[0] != ' ') {
|
||||
strecpy(_settings_client.network.client_name, this->text.buf, lastof(_settings_client.network.client_name));
|
||||
if (!StrEmpty(this->name_editbox.text.buf) && this->name_editbox.text.buf[0] != ' ') {
|
||||
strecpy(_settings_client.network.client_name, this->name_editbox.text.buf, lastof(_settings_client.network.client_name));
|
||||
} else {
|
||||
strecpy(_settings_client.network.client_name, "Player", lastof(_settings_client.network.client_name));
|
||||
}
|
||||
@@ -998,16 +1000,18 @@ void ShowNetworkGameWindow()
|
||||
new NetworkGameWindow(&_network_game_window_desc);
|
||||
}
|
||||
|
||||
struct NetworkStartServerWindow : public QueryStringBaseWindow {
|
||||
struct NetworkStartServerWindow : public Window {
|
||||
byte widget_id; ///< The widget that has the pop-up input menu
|
||||
QueryString name_editbox; ///< Server name editbox.
|
||||
|
||||
NetworkStartServerWindow(const WindowDesc *desc) : QueryStringBaseWindow(NETWORK_NAME_LENGTH)
|
||||
NetworkStartServerWindow(const WindowDesc *desc) : name_editbox(NETWORK_NAME_LENGTH)
|
||||
{
|
||||
this->InitNested(desc, WN_NETWORK_WINDOW_START);
|
||||
|
||||
this->text.Assign(_settings_client.network.server_name);
|
||||
this->querystrings[WID_NSS_GAMENAME] = &this->name_editbox;
|
||||
this->name_editbox.text.Assign(_settings_client.network.server_name);
|
||||
|
||||
this->afilter = CS_ALPHANUMERAL;
|
||||
this->name_editbox.afilter = CS_ALPHANUMERAL;
|
||||
this->SetFocusedWidget(WID_NSS_GAMENAME);
|
||||
}
|
||||
|
||||
@@ -1171,7 +1175,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
|
||||
virtual void OnEditboxChanged(int wid)
|
||||
{
|
||||
if (wid == WID_NSS_GAMENAME) {
|
||||
strecpy(_settings_client.network.server_name, this->text.buf, lastof(_settings_client.network.server_name));
|
||||
strecpy(_settings_client.network.server_name, this->name_editbox.text.buf, lastof(_settings_client.network.server_name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2101,25 +2105,28 @@ void ShowNetworkNeedPassword(NetworkPasswordType npt)
|
||||
ShowQueryString(STR_EMPTY, caption, NETWORK_PASSWORD_LENGTH, w, CS_ALPHANUMERAL, QSF_NONE);
|
||||
}
|
||||
|
||||
struct NetworkCompanyPasswordWindow : public QueryStringBaseWindow {
|
||||
NetworkCompanyPasswordWindow(const WindowDesc *desc, Window *parent) : QueryStringBaseWindow(lengthof(_settings_client.network.default_company_pass))
|
||||
struct NetworkCompanyPasswordWindow : public Window {
|
||||
QueryString password_editbox; ///< Password editbox.
|
||||
|
||||
NetworkCompanyPasswordWindow(const WindowDesc *desc, Window *parent) : password_editbox(lengthof(_settings_client.network.default_company_pass))
|
||||
{
|
||||
this->InitNested(desc, 0);
|
||||
|
||||
this->parent = parent;
|
||||
this->cancel_button = WID_NCP_CANCEL;
|
||||
this->ok_button = WID_NCP_OK;
|
||||
this->afilter = CS_ALPHANUMERAL;
|
||||
this->querystrings[WID_NCP_PASSWORD] = &this->password_editbox;
|
||||
this->password_editbox.cancel_button = WID_NCP_CANCEL;
|
||||
this->password_editbox.ok_button = WID_NCP_OK;
|
||||
this->password_editbox.afilter = CS_ALPHANUMERAL;
|
||||
this->SetFocusedWidget(WID_NCP_PASSWORD);
|
||||
}
|
||||
|
||||
void OnOk()
|
||||
{
|
||||
if (this->IsWidgetLowered(WID_NCP_SAVE_AS_DEFAULT_PASSWORD)) {
|
||||
strecpy(_settings_client.network.default_company_pass, this->text.buf, lastof(_settings_client.network.default_company_pass));
|
||||
strecpy(_settings_client.network.default_company_pass, this->password_editbox.text.buf, lastof(_settings_client.network.default_company_pass));
|
||||
}
|
||||
|
||||
NetworkChangeCompanyPassword(_local_company, this->text.buf);
|
||||
NetworkChangeCompanyPassword(_local_company, this->password_editbox.text.buf);
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
|
Reference in New Issue
Block a user