From 8ad3bb2e568b6520cc6e2f7b73105d785487467d Mon Sep 17 00:00:00 2001 From: esteel Date: Tue, 3 Mar 2009 18:23:03 +0000 Subject: [PATCH] second part of terencehills patch, colored name preview git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6041 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/menu/classes.c | 1 + data/qcsrc/menu/item/label.c | 16 ++++++++++------ .../nexuiz/dialog_multiplayer_playersetup.c | 13 +++++++++---- .../dialog_multiplayer_playersetup_names.c | 18 ++++++++++++++++++ data/qcsrc/menu/nexuiz/mainwindow.c | 5 +++++ 5 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup_names.c diff --git a/data/qcsrc/menu/classes.c b/data/qcsrc/menu/classes.c index fd032b256..f31af4f65 100644 --- a/data/qcsrc/menu/classes.c +++ b/data/qcsrc/menu/classes.c @@ -78,3 +78,4 @@ #include "nexuiz/colorpicker.c" #include "nexuiz/cvarlist.c" #include "nexuiz/dialog_settings_misc_cvars.c" +#include "nexuiz/dialog_multiplayer_playersetup_names.c" diff --git a/data/qcsrc/menu/item/label.c b/data/qcsrc/menu/item/label.c index be4bb2a7e..a495f07fc 100644 --- a/data/qcsrc/menu/item/label.c +++ b/data/qcsrc/menu/item/label.c @@ -9,6 +9,7 @@ CLASS(Label) EXTENDS(Item) ATTRIB(Label, fontSize, float, 8) ATTRIB(Label, align, float, 0.5) ATTRIB(Label, allowCut, float, 0) + ATTRIB(Label, allowColors, float, 0) ATTRIB(Label, keepspaceLeft, float, 0) // for use by subclasses (radiobuttons for example) ATTRIB(Label, keepspaceRight, float, 0) ATTRIB(Label, marginLeft, float, 0) // alternate way to specify keepspace* (in characters from the font) @@ -32,7 +33,7 @@ string toStringLabel(entity me) void setTextLabel(entity me, string txt) { me.text = txt; - me.realOrigin_x = me.align * (1 - me.keepspaceLeft - me.keepspaceRight - min(me.realFontSize_x * draw_TextWidth(me.text, 0), (1 - me.keepspaceLeft - me.keepspaceRight))) + me.keepspaceLeft; + me.realOrigin_x = me.align * (1 - me.keepspaceLeft - me.keepspaceRight - min(me.realFontSize_x * draw_TextWidth(me.text, me.allowColors), (1 - me.keepspaceLeft - me.keepspaceRight))) + me.keepspaceLeft; } void resizeNotifyLabel(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize) { @@ -43,7 +44,7 @@ void resizeNotifyLabel(entity me, vector relOrigin, vector relSize, vector absOr me.keepspaceLeft = me.marginLeft * me.realFontSize_x; if(me.marginRight) me.keepspaceRight = me.marginRight * me.realFontSize_x; - me.realOrigin_x = me.align * (1 - me.keepspaceLeft - me.keepspaceRight - min(me.realFontSize_x * draw_TextWidth(me.text, 0), (1 - me.keepspaceLeft - me.keepspaceRight))) + me.keepspaceLeft; + me.realOrigin_x = me.align * (1 - me.keepspaceLeft - me.keepspaceRight - min(me.realFontSize_x * draw_TextWidth(me.text, me.allowColors), (1 - me.keepspaceLeft - me.keepspaceRight))) + me.keepspaceLeft; me.realOrigin_y = 0.5 * (1 - me.realFontSize_y); } void configureLabelLabel(entity me, string txt, float sz, float algn) @@ -71,20 +72,23 @@ void drawLabel(entity me) if(t) { if(me.allowCut) // FIXME allowCut incompatible with align != 0 - draw_Text(me.realOrigin, draw_TextShortenToWidth(t, (1 - me.keepspaceLeft - me.keepspaceRight) / me.realFontSize_x, 0), me.realFontSize, me.colorL, me.alpha, 0); + draw_Text(me.realOrigin, draw_TextShortenToWidth(t, (1 - me.keepspaceLeft - me.keepspaceRight) / me.realFontSize_x, me.allowColors), me.realFontSize, me.colorL, me.alpha, me.allowColors); else if(me.allowWrap) // FIXME allowWrap incompatible with align != 0 { getWrappedLine_remaining = t; o = me.realOrigin; while(getWrappedLine_remaining) { - t = getWrappedLine((1 - me.keepspaceLeft - me.keepspaceRight) / me.realFontSize_x, draw_TextWidth_WithoutColors); - draw_Text(o, t, me.realFontSize, me.colorL, me.alpha, 0); + if (me.allowColors) + t = getWrappedLine((1 - me.keepspaceLeft - me.keepspaceRight) / me.realFontSize_x, draw_TextWidth_WithColors); + else + t = getWrappedLine((1 - me.keepspaceLeft - me.keepspaceRight) / me.realFontSize_x, draw_TextWidth_WithoutColors); + draw_Text(o, t, me.realFontSize, me.colorL, me.alpha, me.allowColors); o_y += me.realFontSize_y; } } else - draw_Text(me.realOrigin, t, me.realFontSize, me.colorL, me.alpha, 0); + draw_Text(me.realOrigin, t, me.realFontSize, me.colorL, me.alpha, me.allowColors); } } #endif diff --git a/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c b/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c index 58014a505..61c1b106a 100644 --- a/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c +++ b/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup.c @@ -30,13 +30,19 @@ void drawNexuizPlayerSettingsTab(entity me) } void fillNexuizPlayerSettingsTab(entity me) { - entity e, pms, sl, e0, box; + entity e, pms, sl, eName, e0, box; float i, n; me.TR(me); - me.TD(me, 1, 1, me.playerNameLabel = makeNexuizTextLabel(0, "Player Name:")); + me.TD(me, 1, 0.5, me.playerNameLabel = makeNexuizTextLabel(0, "Name:")); me.playerNameLabelAlpha = me.playerNameLabel.alpha; - me.TD(me, 1, 2, box = makeNexuizInputBox(1, "_cl_name")); + me.TD(me, 1, 2.5, eName = makeNexuizTextLabel(0, string_null)); + eName.textEntity = main.namesDialog; + eName.allowCut = 1; + eName.allowColors = 1; + eName.alpha = 1; + me.TR(me); + me.TD(me, 1, 3.0, box = makeNexuizInputBox(1, "_cl_name")); box.forbiddenCharacters = "\r\n\\\"$"; // don't care, isn't getting saved box.maxLength = 63; me.TR(me); @@ -46,7 +52,6 @@ void fillNexuizPlayerSettingsTab(entity me) me.TR(me); me.TR(me); me.TR(me); - me.TR(me); me.TR(me); pms = makeNexuizPlayerModelSelector(); me.TDempty(me, 0.5); diff --git a/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup_names.c b/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup_names.c new file mode 100644 index 000000000..8afcdbdda --- /dev/null +++ b/data/qcsrc/menu/nexuiz/dialog_multiplayer_playersetup_names.c @@ -0,0 +1,18 @@ +#ifdef INTERFACE +CLASS(NexuizNamesDialog) EXTENDS(NexuizDialog) + METHOD(NexuizNamesDialog, toString, string(entity)) + ATTRIB(NexuizNamesDialog, title, string, "Favorite Names") + ATTRIB(NexuizNamesDialog, color, vector, SKINCOLOR_DIALOG_MUTATORS) // FIXME: replace SKINCOLOR_DIALOG_MUTATORS with something else + ATTRIB(NexuizNamesDialog, intendedWidth, float, 0.45) + ATTRIB(NexuizNamesDialog, rows, float, 5) + ATTRIB(NexuizNamesDialog, columns, float, 6) + ATTRIB(NexuizNamesDialog, refilterEntity, entity, NULL) +ENDCLASS(NexuizNamesDialog) +#endif + +#ifdef IMPLEMENTATION +string toStringNexuizNamesDialog(entity me) +{ + return cvar_string("_cl_name"); +} +#endif diff --git a/data/qcsrc/menu/nexuiz/mainwindow.c b/data/qcsrc/menu/nexuiz/mainwindow.c index d6012de52..439023b21 100644 --- a/data/qcsrc/menu/nexuiz/mainwindow.c +++ b/data/qcsrc/menu/nexuiz/mainwindow.c @@ -3,6 +3,7 @@ CLASS(MainWindow) EXTENDS(ModalController) METHOD(MainWindow, configureMainWindow, void(entity)) ATTRIB(MainWindow, mutatorsDialog, entity, NULL) ATTRIB(MainWindow, weaponsDialog, entity, NULL) + ATTRIB(MainWindow, namesDialog, entity, NULL) ATTRIB(MainWindow, mapInfoDialog, entity, NULL) ATTRIB(MainWindow, userbindEditDialog, entity, NULL) ATTRIB(MainWindow, winnerDialog, entity, NULL) @@ -52,6 +53,10 @@ void configureMainWindowMainWindow(entity me) i.configureDialog(i); me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); + me.namesDialog = i = spawnNexuizNamesDialog(); + i.configureDialog(i); + me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); + me.radarDialog = i = spawnNexuizRadarDialog(); i.configureDialog(i); me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z); -- 2.39.2