void Net_ReadServerInfo()
{
- localcmd("\nmenu_cmd directmenu Welcome serverinfo_name \"", ReadString() , "\" serverinfo_ip \"", ReadString(), "\" serverinfo_MOTD \"", ReadString(), "\"\n");
+ localcmd("\nmenu_cmd directmenu Welcome serverinfo_name \"", ReadString(),
+ "\" serverinfo_ip \"", ReadString(),
+ "\" serverinfo_MOTD \"", strreplace("\n", "\\n", ReadString()),
+ "\"\n");
}
// CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
#include "xonotic/dialog_multiplayer_join_serverinfo.c"
#include "xonotic/playerlist.c"
#include "xonotic/listbox.c"
+#include "xonotic/textlistbox.c"
#include "xonotic/serverlist.c"
#include "xonotic/inputbox.c"
#include "xonotic/dialog_quit.c"
m_goto(strcat(filter, argv(1))); // switch to a menu item
else if(argc > 2 && !isdemo())
{
+ float argsbuf = 0;
+ s = strzone(argv(1)); // dialog name
for(i = 0, e = world; (e = nextent(e)); )
- if(e.classname != "vtbl" && e.name == strcat(filter, argv(1)))
+ if(e.classname != "vtbl" && e.name == strcat(filter, s))
+ {
+ argsbuf = buf_create();
+ if(argsbuf >= 0)
if(e.readInputArgs)
{
- e.readInputArgs(e, 2, argc - 1);
- m_goto(strcat(filter, argv(1)));
+ for(i = 2; i < argc; ++i)
+ bufstr_add(argsbuf, argv(i), 1);
+ e.readInputArgs(e, argsbuf);
+ m_goto(strcat(filter, s));
}
+ if(argsbuf >= 0)
+ buf_del(argsbuf);
+ }
}
if(filter)
strunzone(filter);
ATTRIB(XonoticWelcomeDialog, title, string, _("Welcome"))
ATTRIB(XonoticWelcomeDialog, color, vector, SKINCOLOR_DIALOG_WELCOME)
ATTRIB(XonoticWelcomeDialog, intendedWidth, float, 0.7)
- ATTRIB(XonoticWelcomeDialog, rows, float, 16)
+ ATTRIB(XonoticWelcomeDialog, rows, float, 14)
ATTRIB(XonoticWelcomeDialog, columns, float, 4)
ATTRIB(XonoticWelcomeDialog, name, string, "Welcome")
METHOD(XonoticWelcomeDialog, configureDialog, void(entity))
- METHOD(XonoticWelcomeDialog, readInputArgs, void(entity, float, float))
+ METHOD(XonoticWelcomeDialog, readInputArgs, void(entity, float))
ATTRIB(XonoticWelcomeDialog, serverinfo_name, string, string_null)
ATTRIB(XonoticWelcomeDialog, serverinfo_name_ent, entity, world)
ATTRIB(XonoticWelcomeDialog, serverinfo_ip, string, string_null)
welcomeDialog_resetStrings(me);
SUPER(XonoticWelcomeDialog).configureDialog(me);
}
-void XonoticWelcomeDialog_readInputArgs(entity me, float starting_arg, float arg_count)
+void XonoticWelcomeDialog_readInputArgs(entity me, float argsbuf)
{
- float i;
+ float i = 0;
+ string s;
welcomeDialog_resetStrings(me);
- for(i = starting_arg; i < arg_count; ++i)
+ while((s = bufstr_get(argsbuf, i)) != "")
{
- if(argv(i) == "serverinfo_name")
+ if(s == "serverinfo_name")
{
if(me.serverinfo_name)
strunzone(me.serverinfo_name);
- me.serverinfo_name = strzone(argv(i + 1));
- me.serverinfo_name_ent.setText(me.serverinfo_name_ent, me.serverinfo_name);
+ me.serverinfo_name = strzone(bufstr_get(argsbuf, i + 1));
++i;
}
- else if(argv(i) == "serverinfo_ip")
+ else if(s == "serverinfo_ip")
{
if(me.serverinfo_ip)
strunzone(me.serverinfo_ip);
- me.serverinfo_ip = strzone(argv(i + 1));
- me.serverinfo_ip_ent.setText(me.serverinfo_ip_ent, me.serverinfo_ip);
+ me.serverinfo_ip = strzone(bufstr_get(argsbuf, i + 1));
++i;
}
- else if(argv(i) == "serverinfo_MOTD")
+ else if(s == "serverinfo_MOTD")
{
if(me.serverinfo_MOTD)
strunzone(me.serverinfo_MOTD);
- me.serverinfo_MOTD = strzone(argv(i + 1));
- me.serverinfo_MOTD_ent.setText(me.serverinfo_MOTD_ent, me.serverinfo_MOTD);
+ me.serverinfo_MOTD = strzone(bufstr_get(argsbuf, i + 1));
++i;
}
+ ++i;
}
+ me.serverinfo_name_ent.setText(me.serverinfo_name_ent, me.serverinfo_name);
+ me.serverinfo_ip_ent.setText(me.serverinfo_ip_ent, me.serverinfo_ip);
+ me.serverinfo_MOTD_ent.setText(me.serverinfo_MOTD_ent, me.serverinfo_MOTD);
}
void XonoticWelcomeDialog_fill(entity me)
me.TD(me, 1, 4, me.serverinfo_ip_ent = makeXonoticTextLabel(0.5, ""));
me.TR(me);
me.TR(me);
- me.TD(me, 1, 4, e = makeXonoticTextLabel(0.5, _("MOTD")));
- me.TR(me);
- me.TD(me, 1, 4, me.serverinfo_MOTD_ent = makeXonoticTextLabel(0.5, ""));
+ me.TD(me, 10, 4, me.serverinfo_MOTD_ent = makeXonoticTextListBox());
+ me.serverinfo_MOTD_ent.allowColors = 1;
+ me.gotoRC(me, me.rows - 1, 0);
+ me.TDempty(me, 1);
+ me.TD(me, 1, 2, e = makeXonoticCommandButton(_("Disconnect"), '0 0 0', "disconnect", COMMANDBUTTON_CLOSE));
}
#endif
--- /dev/null
+#ifdef INTERFACE
+CLASS(XonoticTextListBox) EXTENDS(ListBox)
+ METHOD(XonoticTextListBox, configureXonoticTextListBox, void(entity))
+ ATTRIB(XonoticTextListBox, fontSize, float, SKINFONTSIZE_NORMAL)
+ ATTRIB(XonoticTextListBox, scrollbarWidth, float, SKINWIDTH_SCROLLBAR)
+ ATTRIB(XonoticTextListBox, src, string, SKINGFX_SCROLLBAR)
+ ATTRIB(XonoticTextListBox, tolerance, vector, SKINTOLERANCE_SLIDER)
+ ATTRIB(XonoticTextListBox, rowsPerItem, float, 1)
+ METHOD(XonoticTextListBox, resizeNotify, void(entity, vector, vector, vector, vector))
+ ATTRIB(XonoticTextListBox, color, vector, SKINCOLOR_SCROLLBAR_N)
+ ATTRIB(XonoticTextListBox, colorF, vector, SKINCOLOR_SCROLLBAR_F)
+ ATTRIB(XonoticTextListBox, color2, vector, SKINCOLOR_SCROLLBAR_S)
+ ATTRIB(XonoticTextListBox, colorC, vector, SKINCOLOR_SCROLLBAR_C)
+ ATTRIB(XonoticTextListBox, colorBG, vector, SKINCOLOR_LISTBOX_BACKGROUND)
+ ATTRIB(XonoticTextListBox, alphaBG, float, SKINALPHA_LISTBOX_BACKGROUND)
+
+ METHOD(XonoticTextListBox, setSelected, void(entity, float))
+ METHOD(XonoticTextListBox, destroy, void(entity))
+ ATTRIB(XonoticTextListBox, textbuf, float, -1)
+ ATTRIB(XonoticTextListBox, allowColors, float, 0)
+ METHOD(XonoticTextListBox, setText, void(entity, string))
+ METHOD(XonoticTextListBox, drawListBoxItem, void(entity, float, vector, float)) // item number, width/height, selected
+ENDCLASS(XonoticTextListBox)
+entity makeXonoticTextListBox();
+#endif
+
+#ifdef IMPLEMENTATION
+entity makeXonoticTextListBox()
+{
+ entity me;
+ me = spawnXonoticTextListBox();
+ me.configureXonoticTextListBox(me);
+ return me;
+}
+void XonoticTextListBox_configureXonoticTextListBox(entity me)
+{
+ me.configureListBox(me, me.scrollbarWidth, 1); // item height gets set up later
+}
+void XonoticTextListBox_setSelected(entity me, float i)
+{
+ // nothing
+}
+void XonoticTextListBox_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+{
+ me.itemHeight = me.rowsPerItem * me.fontSize / absSize_y;
+ SUPER(XonoticTextListBox).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
+
+ me.realFontSize_y = me.fontSize / (absSize_y * me.itemHeight);
+ me.realFontSize_x = me.fontSize / (absSize_x * (1 - me.controlWidth));
+ me.realUpperMargin = 0.5 * (1 - me.realFontSize_y);
+}
+void XonoticTextListBox_setText(entity me, string theText)
+{
+ float i, k;
+ if(me.textbuf >= 0)
+ buf_del(me.textbuf);
+ me.textbuf = buf_create();
+ string s = strzone(theText);
+ k = tokenizebyseparator(s, "\\n");
+ for(i = 0; i < k; ++i)
+ bufstr_add(me.textbuf, argv(i), 1);
+ strunzone(s);
+ me.nItems = k;
+}
+void XonoticTextListBox_destroy(entity me)
+{
+ if(me.textbuf >= 0)
+ buf_del(me.textbuf);
+}
+void XonoticTextListBox_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
+{
+ draw_CenterText(me.realUpperMargin * eY + 0.5 * eX, bufstr_get(me.textbuf, i), me.realFontSize, '1 1 1', 1, me.allowColors);
+}
+#endif
WriteByte(MSG_ONE, TE_CSQC_SERVERINFO);
WriteString(MSG_ONE, "128.03.192.999"); // FIXME: send the real server ip
WriteString(MSG_ONE, autocvar_hostname);
- //WriteString(MSG_ONE, getwelcomemessage());
- WriteString(MSG_ONE, "Welcome to this server. Have fun!");
+ WriteString(MSG_ONE, getwelcomemessage());
}
/*