r2860 - in trunk/data: . qcsrc/menu qcsrc/menu-div0test qcsrc/menu-div0test/item qcsrc/menu-div0test/nexuiz qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun Oct 28 06:20:41 EDT 2007
Author: div0
Date: 2007-10-28 06:20:41 -0400 (Sun, 28 Oct 2007)
New Revision: 2860
Added:
trunk/data/qcsrc/menu-div0test/basebutton_d.tga
trunk/data/qcsrc/menu-div0test/basebuttongray_d.tga
trunk/data/qcsrc/menu-div0test/item/dialog.c
trunk/data/qcsrc/menu-div0test/nexuiz/button.c
trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c
Removed:
trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c
Modified:
trunk/data/default.cfg
trunk/data/qcsrc/menu-div0test/classes.c
trunk/data/qcsrc/menu-div0test/item.c
trunk/data/qcsrc/menu-div0test/item/borderimage.c
trunk/data/qcsrc/menu-div0test/item/button.c
trunk/data/qcsrc/menu-div0test/item/container.c
trunk/data/qcsrc/menu-div0test/item/modalcontroller.c
trunk/data/qcsrc/menu-div0test/menu.qc
trunk/data/qcsrc/menu-div0test/nexuiz/commandbutton.c
trunk/data/qcsrc/menu-div0test/nexuiz/dialog_teamselect.c
trunk/data/qcsrc/menu-div0test/skin.qh
trunk/data/qcsrc/menu/mbuiltin.qc
trunk/data/qcsrc/server/cl_client.qc
Log:
support for team select dialog, disabled buttons and grid layout; updated mbuiltin.qc
Modified: trunk/data/default.cfg
===================================================================
--- trunk/data/default.cfg 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/default.cfg 2007-10-28 10:20:41 UTC (rev 2860)
@@ -606,7 +606,7 @@
bind F3 spec
// alias for switching the teamselect menu
-alias menu_showteamselect "set scmenu_directmenu TeamSelect; togglemenu"
+alias menu_showteamselect "menu_cmd directmenu TeamSelect"
alias menu_sync "menu_cmd sync"
bind f5 menu_showteamselect
Modified: trunk/data/qcsrc/menu/mbuiltin.qc
===================================================================
--- trunk/data/qcsrc/menu/mbuiltin.qc 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu/mbuiltin.qc 2007-10-28 10:20:41 UTC (rev 2860)
@@ -180,8 +180,11 @@
float drawcharacter(vector position, float character, vector scale, vector rgb, float alpha, float flag) = #454;
float drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #455;
+float drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag) = #467;
+float stringwidth(string text, float handleColors) = #468;
float drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag) = #456;
+float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #469;
float drawfill(vector position, vector size, vector rgb, float alpha, float flag) = #457;
Added: trunk/data/qcsrc/menu-div0test/basebutton_d.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/qcsrc/menu-div0test/basebutton_d.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/data/qcsrc/menu-div0test/basebuttongray_d.tga
===================================================================
(Binary files differ)
Property changes on: trunk/data/qcsrc/menu-div0test/basebuttongray_d.tga
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/data/qcsrc/menu-div0test/classes.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/classes.c 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu-div0test/classes.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -10,7 +10,9 @@
#include "item/radiobutton.c"
#include "item/borderimage.c"
#include "item/slider.c"
+#include "item/dialog.c"
#include "nexuiz/dialog.c"
#include "nexuiz/mainwindow.c"
+#include "nexuiz/button.c"
#include "nexuiz/commandbutton.c"
#include "nexuiz/dialog_teamselect.c"
Modified: trunk/data/qcsrc/menu-div0test/item/borderimage.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/borderimage.c 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu-div0test/item/borderimage.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -23,6 +23,7 @@
me.closeButton.Container_origin = '1 0 0' * (1 - me.borderVec_x);
me.closeButton.Container_size = me.borderVec;
me.closeButton.color = me.color;
+ print("a: ", vtos(absSize), "\n");
}
}
void configureBorderImageBorderImage(entity me, string theTitle, float sz, vector theColor, string path, float theBorderHeight)
Modified: trunk/data/qcsrc/menu-div0test/item/button.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/button.c 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu-div0test/item/button.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -2,6 +2,7 @@
CLASS(Button) EXTENDS(Label)
METHOD(Button, configureButton, void(entity, string, float, string))
METHOD(Button, draw, void(entity))
+ METHOD(Button, open, void(entity))
METHOD(Button, resizeNotify, void(entity, vector, vector, vector, vector))
METHOD(Button, keyDown, float(entity, float, float, float))
METHOD(Button, mousePress, float(entity, vector))
@@ -14,6 +15,7 @@
ATTRIB(Button, focusable, float, 1)
ATTRIB(Button, pressed, float, 0)
ATTRIB(Button, clickTime, float, 0)
+ ATTRIB(Button, disabled, float, 0)
ATTRIB(Button, forcePressed, float, 0)
ATTRIB(Button, color, vector, '1 1 1')
@@ -62,16 +64,27 @@
me.mouseDrag(me, pos); // verify coordinates
if(me.pressed)
{
- me.onClick(me, me.onClickEntity);
+ if(!me.disabled)
+ me.onClick(me, me.onClickEntity);
me.pressed = 0;
}
return 1;
}
+void openButton(entity me)
+{
+ me.focusable = !me.disabled;
+}
void drawButton(entity me)
{
+ me.focusable = !me.disabled;
+ if(me.disabled)
+ draw_alpha *= 0.5;
+
if(me.srcMulti)
{
- if(me.forcePressed || me.pressed || me.clickTime > 0)
+ if(me.disabled)
+ draw_ButtonPicture('0 0 0', strcat(me.src, "_d"), '1 1 0', '1 1 1', 1);
+ else if(me.forcePressed || me.pressed || me.clickTime > 0)
draw_ButtonPicture('0 0 0', strcat(me.src, "_c"), '1 1 0', me.color, 1);
else if(me.focused)
draw_ButtonPicture('0 0 0', strcat(me.src, "_f"), '1 1 0', me.color, 1);
@@ -80,7 +93,9 @@
}
else
{
- if(me.forcePressed || me.pressed || me.clickTime > 0)
+ if(me.disabled)
+ draw_Picture('0 0 0', strcat(me.src, "_d"), '1 1 0', '1 1 1', 1);
+ else if(me.forcePressed || me.pressed || me.clickTime > 0)
draw_Picture('0 0 0', strcat(me.src, "_c"), '1 1 0', me.color, 1);
else if(me.focused)
draw_Picture('0 0 0', strcat(me.src, "_f"), '1 1 0', me.color, 1);
@@ -92,7 +107,8 @@
if(me.clickTime > 0 && me.clickTime < frametime)
{
// keyboard click timer expired? Fire the event then.
- me.onClick(me, me.onClickEntity);
+ if(!me.disabled)
+ me.onClick(me, me.onClickEntity);
}
me.clickTime -= frametime;
}
Modified: trunk/data/qcsrc/menu-div0test/item/container.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/container.c 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu-div0test/item/container.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -15,6 +15,7 @@
METHOD(Container, removeItem, void(entity, entity))
METHOD(Container, setFocus, void(entity, entity))
METHOD(Container, itemFromPoint, entity(entity, vector))
+ METHOD(Container, open, void(entity))
ATTRIB(Container, focusable, float, 0)
ATTRIB(Container, firstChild, entity, NULL)
ATTRIB(Container, lastChild, entity, NULL)
@@ -29,11 +30,18 @@
.entity nextSibling;
.entity prevSibling;
+void openContainer(entity me)
+{
+ entity e;
+ for(e = me.firstChild; e; e = e.nextSibling)
+ e.open(e);
+}
+
void resizeNotifyLieContainer(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize, .vector originField, .vector sizeField)
{
entity e;
vector o, s;
- for(e = me.lastChild; e; e = e.prevSibling)
+ for(e = me.firstChild; e; e = e.nextSibling)
{
o = e.originField;
s = e.sizeField;
Copied: trunk/data/qcsrc/menu-div0test/item/dialog.c (from rev 2859, trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c)
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/dialog.c (rev 0)
+++ trunk/data/qcsrc/menu-div0test/item/dialog.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -0,0 +1,168 @@
+// Note: this class is called Dialog, but it can also handle a tab under the following conditions:
+// - isTabRoot is 0
+// - backgroundImage is the tab's background
+// - closable is 0
+// - rootDialog is 0
+// - title is ""
+// - marginTop is
+// - intendedHeight ends up to be the tab's actual height, or at least close
+// - titleFontSize is sensible, and so is titleHeight
+// - marginTop cancels out as much of titleHeight as needed (that is, it should be actualMarginTop - titleHeight)
+// To ensure the latter, you best create all tabs FIRST and insert the tabbed
+// control to your dialog THEN - with the right height
+//
+// a subclass may help with using this as a tab
+
+#ifdef INTERFACE
+CLASS(Dialog) EXTENDS(InputContainer)
+ METHOD(Dialog, configureDialog, void(entity)) // no runtime configuration, all parameters are given in the code!
+ METHOD(Dialog, fill, void(entity)) // to be overridden by user to fill the dialog with controls
+ METHOD(Dialog, keyDown, float(entity, float, float, float))
+ METHOD(Dialog, close, void(entity))
+ METHOD(Dialog, addItemSimple, void(entity, float, float, float, float, entity))
+
+ METHOD(Dialog, TD, void(entity, float, float, entity))
+ METHOD(Dialog, TDempty, void(entity, float))
+ METHOD(Dialog, TR, void(entity))
+ METHOD(Dialog, gotoXY, void(entity, float, float))
+
+ ATTRIB(Dialog, isTabRoot, float, 1)
+ ATTRIB(Dialog, closeButton, entity, NULL)
+ ATTRIB(Dialog, intendedHeight, float, 0)
+ ATTRIB(Dialog, itemOrigin, vector, '0 0 0')
+ ATTRIB(Dialog, itemSize, vector, '0 0 0')
+ ATTRIB(Dialog, itemSpacing, vector, '0 0 0')
+ ATTRIB(Dialog, currentRow, float, 0)
+ ATTRIB(Dialog, currentColumn, float, 0)
+
+ // to be customized
+ ATTRIB(Dialog, closable, float, 1)
+ ATTRIB(Dialog, rootDialog, float, 1)
+ ATTRIB(Dialog, title, string, "Form1") // ;)
+ ATTRIB(Dialog, color, vector, '1 0.5 1')
+ ATTRIB(Dialog, intendedWidth, float, 0)
+ ATTRIB(Dialog, rows, float, 3)
+ ATTRIB(Dialog, columns, float, 2)
+
+ ATTRIB(Dialog, marginTop, float, 0) // pixels
+ ATTRIB(Dialog, marginBottom, float, 0) // pixels
+ ATTRIB(Dialog, marginLeft, float, 0) // pixels
+ ATTRIB(Dialog, marginRight, float, 0) // pixels
+ ATTRIB(Dialog, columnSpacing, float, 0) // pixels
+ ATTRIB(Dialog, rowSpacing, float, 0) // pixels
+ ATTRIB(Dialog, rowHeight, float, 0) // pixels
+ ATTRIB(Dialog, titleHeight, float, 0) // pixels
+ ATTRIB(Dialog, titleFontSize, float, 0) // pixels
+
+ ATTRIB(Dialog, backgroundImage, string, "")
+ ATTRIB(Dialog, closeButtonImage, string, "")
+ENDCLASS(Dialog)
+#endif
+
+#ifdef IMPLEMENTATION
+void Dialog_Close(entity button, entity me)
+{
+ me.close(me);
+}
+
+void fillDialog(entity me)
+{
+}
+
+void addItemSimpleDialog(entity me, float row, float col, float rowspan, float colspan, entity e)
+{
+ print(vtos(me.itemSpacing), " ", vtos(me.itemSize), "\n");
+ me.addItem(me, e,
+ me.itemOrigin + eX * ( col * me.itemSpacing_x) + eY * ( row * me.itemSpacing_y),
+ me.itemSize + eX * ((colspan - 1) * me.itemSpacing_x) + eY * ((rowspan - 1) * me.itemSpacing_y),
+ 1);
+}
+
+void gotoXYDialog(entity me, float row, float col)
+{
+ me.currentRow = row;
+ me.currentColumn = col;
+}
+
+void TRDialog(entity me)
+{
+ me.currentRow += 1;
+ me.currentColumn = 0;
+}
+
+void TDDialog(entity me, float rowspan, float colspan, entity e)
+{
+ me.addItemSimple(me, me.currentRow, me.currentColumn, rowspan, colspan, e);
+ me.currentColumn += colspan;
+}
+
+void TDemptyDialog(entity me, float colspan)
+{
+ me.currentColumn += colspan;
+}
+
+void configureDialogDialog(entity me)
+{
+ entity frame, closebutton;
+ float absWidth, absHeight;
+
+ frame = spawnBorderImage();
+ frame.configureBorderImage(frame, me.title, me.titleFontSize, me.color, me.backgroundImage, me.titleHeight / me.titleFontSize);
+ me.addItem(me, frame, '0 0 0', '1 1 0', 1);
+
+ absWidth = me.intendedWidth * cvar("vid_conwidth");
+ absHeight = me.titleHeight + me.marginTop + me.rows * me.rowHeight + (me.rows - 1) * me.rowSpacing + me.marginBottom;
+ me.itemOrigin = eX * (me.marginLeft / absWidth)
+ + eY * ((me.titleHeight + me.marginTop) / absHeight);
+ me.itemSize = eX * ((1 - (me.marginLeft + me.marginRight + me.columnSpacing * (me.columns - 1)) / absWidth) / me.columns)
+ + eY * (me.rowHeight / absHeight);
+ me.itemSpacing = me.itemSize
+ + eX * (me.columnSpacing / absWidth)
+ + eY * (me.rowSpacing / absHeight);
+ me.intendedHeight = absHeight / cvar("vid_conheight");
+ me.currentRow = -1;
+ me.currentColumn = -1;
+
+ me.fill(me);
+
+ if(me.closable)
+ {
+ closebutton = me.closeButton = spawnButton();
+ closebutton.configureButton(closebutton, "", 12, me.closeButtonImage);
+ closebutton.onClick = Dialog_Close; closebutton.onClickEntity = me;
+ closebutton.srcMulti = 0;
+ me.addItem(me, closebutton, '0 0 0', '1 1 0', 1); // put it as LAST
+ }
+
+ frame.closeButton = closebutton;
+}
+
+void closeDialog(entity me)
+{
+ if(me.parent.instanceOfNexposee)
+ {
+ ExposeeCloseButton_Click(me, me.parent);
+ }
+ else if(me.parent.instanceOfModalController)
+ {
+ DialogCloseButton_Click(me, me);
+ }
+ if(me.rootDialog)
+ {
+ m_goto("");
+ }
+}
+
+float keyDownDialog(entity me, float key, float ascii, float shift)
+{
+ if(me.closable)
+ {
+ if(key == K_ESCAPE)
+ {
+ me.close(me);
+ return 1;
+ }
+ }
+ return keyDownInputContainer(me, key, ascii, shift);
+}
+#endif
Modified: trunk/data/qcsrc/menu-div0test/item/modalcontroller.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item/modalcontroller.c 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu-div0test/item/modalcontroller.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -2,6 +2,7 @@
CLASS(ModalController) EXTENDS(Container)
METHOD(ModalController, resizeNotify, void(entity, vector, vector, vector, vector))
METHOD(ModalController, draw, void(entity))
+ METHOD(ModalController, open, void(entity))
METHOD(ModalController, addItem, void(entity, entity, vector, vector, float))
METHOD(ModalController, showChild, void(entity, entity, vector, vector, float))
METHOD(ModalController, hideChild, void(entity, entity, float))
@@ -125,9 +126,13 @@
other.ModalController_factor = 1;
}
+void openModalController(entity me)
+{
+ // just swallow the event; will handle opening another way
+}
+
void drawModalController(entity me)
{
- // TODO set up alpha, sizes and focus
entity e;
entity front;
float animating;
@@ -249,6 +254,7 @@
other.ModalController_buttonOrigin = globalToBox(theOrigin, me.origin, me.size);
other.ModalController_buttonSize = globalToBoxSize(theSize, me.size);
me.switchState(me, other, 1, skipAnimation);
+ other.open(other);
} // zoom in from button (factor increases)
}
Modified: trunk/data/qcsrc/menu-div0test/item.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/item.c 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu-div0test/item.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -11,6 +11,7 @@
METHOD(Item, focusLeave, void(entity))
METHOD(Item, resizeNotify, void(entity, vector, vector, vector, vector))
METHOD(Item, relinquishFocus, void(entity))
+ METHOD(Item, open, void(entity))
ATTRIB(Item, focused, float, 0)
ATTRIB(Item, focusable, float, 0)
ATTRIB(Item, parent, entity, NULL)
@@ -33,6 +34,10 @@
{
}
+void openItem(entity me)
+{
+}
+
float keyDownItem(entity me, float scan, float ascii, float shift)
{
return 0; // unhandled
Modified: trunk/data/qcsrc/menu-div0test/menu.qc
===================================================================
--- trunk/data/qcsrc/menu-div0test/menu.qc 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu-div0test/menu.qc 2007-10-28 10:20:41 UTC (rev 2860)
@@ -94,6 +94,10 @@
realFrametime = frametime = min(0.2, t - menuPrevTime);
menuPrevTime = t;
+ if(Menu_Active)
+ if(getkeydest() != KEY_MENU || getmousetarget() != MT_MENU)
+ m_hide();
+
if(cvar("cl_capturevideo"))
frametime = 1 / cvar("cl_capturevideo_fps"); // make capturevideo work smoothly
Added: trunk/data/qcsrc/menu-div0test/nexuiz/button.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/button.c (rev 0)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/button.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -0,0 +1,32 @@
+#ifdef INTERFACE
+CLASS(NexuizButton) EXTENDS(Button)
+ METHOD(NexuizButton, configureNexuizButton, void(entity, string, vector))
+ ATTRIB(NexuizButton, fontSize, float, SKINFONTSIZE_NORMAL)
+ ATTRIB(NexuizButton, image, string, SKINGFX_BUTTON)
+ ATTRIB(NexuizButton, grayImage, string, SKINGFX_BUTTON_GRAY)
+ENDCLASS(NexuizButton)
+entity makeNexuizButton(string theText, vector theColor);
+#endif
+
+#ifdef IMPLEMENTATION
+entity makeNexuizButton(string theText, vector theColor)
+{
+ entity me;
+ me = spawnNexuizButton();
+ me.configureNexuizButton(me, theText, theColor);
+ return me;
+}
+
+void configureNexuizButtonNexuizButton(entity me, string theText, vector theColor)
+{
+ if(theColor == '0 0 0')
+ {
+ me.configureButton(me, theText, me.fontSize, me.image);
+ }
+ else
+ {
+ me.configureButton(me, theText, me.fontSize, me.grayImage);
+ me.color = theColor;
+ }
+}
+#endif
Modified: trunk/data/qcsrc/menu-div0test/nexuiz/commandbutton.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/commandbutton.c 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/commandbutton.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -1,12 +1,21 @@
#ifdef INTERFACE
-CLASS(CommandButton) EXTENDS(Button)
+CLASS(CommandButton) EXTENDS(NexuizButton)
METHOD(CommandButton, configureCommandButton, void(entity, string, vector, string, float))
ATTRIB(CommandButton, onClickCommand, string, "")
ATTRIB(CommandButton, closes, float, 0)
ENDCLASS(CommandButton)
+entity makeCommandButton(string theText, vector theColor, string theCommand, float closesMenu);
#endif
#ifdef IMPLEMENTATION
+entity makeCommandButton(string theText, vector theColor, string theCommand, float closesMenu)
+{
+ entity me;
+ me = spawnCommandButton();
+ me.configureCommandButton(me, theText, theColor, theCommand, closesMenu);
+ return me;
+}
+
void CommandButton_Click(entity me, entity other)
{
cmd("\n", me.onClickCommand, "\n");
@@ -18,15 +27,7 @@
void configureCommandButtonCommandButton(entity me, string theText, vector theColor, string theCommand, float closesMenu)
{
- if(theColor == '0 0 0')
- {
- me.configureButton(me, theText, SKINFONTSIZE_NORMAL, SKINGFX_BUTTON);
- }
- else
- {
- me.configureButton(me, theText, SKINFONTSIZE_NORMAL, SKINGFX_BUTTON_GRAY);
- me.color = theColor;
- }
+ me.configureNexuizButton(me, theText, theColor);
me.onClickCommand = theCommand;
me.closes = closesMenu;
me.onClick = CommandButton_Click;
Deleted: trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -1,104 +0,0 @@
-#ifdef INTERFACE
-CLASS(Dialog) EXTENDS(InputContainer)
- METHOD(Dialog, configureDialog, void(entity)) // no runtime configuration, all parameters are given in the code!
- METHOD(Dialog, fill, void(entity)) // to be overridden by user to fill the dialog with controls
- METHOD(Dialog, keyDown, float(entity, float, float, float))
- METHOD(Dialog, close, void(entity))
- METHOD(Dialog, addItemSimple, void(entity, float, float, float, entity))
- ATTRIB(Dialog, isTabRoot, float, 1)
- ATTRIB(Dialog, closeButton, entity, NULL)
- ATTRIB(Dialog, firstLine, float, 0)
- ATTRIB(Dialog, lineSpacing, float, 0)
- ATTRIB(Dialog, firstColumn, float, 0)
- ATTRIB(Dialog, columnWidth, float, 0)
- ATTRIB(Dialog, lineHeight, float, 0)
-
- // to be customized
- ATTRIB(Dialog, closable, float, 1)
- ATTRIB(Dialog, rootDialog, float, 1)
- ATTRIB(Dialog, title, string, "Form1") // ;)
- ATTRIB(Dialog, color, vector, '1 0.5 1')
- ATTRIB(Dialog, intendedWidth, float, 0.96)
- ATTRIB(Dialog, intendedHeight, float, 0.96)
- ATTRIB(Dialog, lines, float, 5)
-ENDCLASS(Dialog)
-#endif
-
-#ifdef IMPLEMENTATION
-void Dialog_Close(entity button, entity me)
-{
- me.close(me);
-}
-
-void fillDialog(entity me)
-{
-}
-
-void addItemSimpleDialog(entity me, float line, float col, float cols, entity e)
-{
- me.addItem(me, e, (me.firstLine + (line - 1) * me.lineSpacing) * eY + (me.firstColumn + (col - 1) / cols * me.columnWidth) * eX, me.lineHeight * eY + me.columnWidth / cols * eX, 1);
-}
-
-void configureDialogDialog(entity me)
-{
- entity frame, closebutton;
- float ch, cw;
-
- frame = spawnBorderImage();
- frame.configureBorderImage(frame, me.title, SKINFONTSIZE_TITLE, me.color, SKINGFX_DIALOGBORDER, SKINHEIGHT_TITLE);
- me.addItem(me, frame, '0 0 0', '1 1 0', 1);
-
- ch = me.intendedHeight * cvar("vid_conheight");
- cw = me.intendedWidth * cvar("vid_conwidth");
-
- me.firstLine = (SKINFONTSIZE_TITLE * SKINHEIGHT_TITLE + SKINMARGIN_TOP) / ch;
- me.lineSpacing = SKINFONTSIZE_NORMAL * SKINHEIGHT_NORMAL_WITHSPACING / ch;
- me.lineHeight = SKINFONTSIZE_NORMAL * SKINHEIGHT_NORMAL/ ch;
- me.firstColumn = SKINMARGIN_LEFT / cw;
- me.columnWidth = 1 - 2 * SKINMARGIN_LEFT / cw;
-
- me.lines = (1 - SKINMARGIN_TOP / ch - me.firstLine + me.lineSpacing - me.lineHeight) / me.lineSpacing;
-
- me.fill(me);
-
- if(me.closable)
- {
- closebutton = me.closeButton = spawnButton();
- closebutton.configureButton(closebutton, "", 12, SKINGFX_CLOSEBUTTON);
- closebutton.onClick = Dialog_Close; closebutton.onClickEntity = me;
- closebutton.srcMulti = 0;
- me.addItem(me, closebutton, '0 0 0', '1 1 0', 1); // put it as LAST
- }
-
- frame.closeButton = closebutton;
-}
-
-void closeDialog(entity me)
-{
- if(me.parent.instanceOfNexposee)
- {
- ExposeeCloseButton_Click(me, me.parent);
- }
- else if(me.parent.instanceOfModalController)
- {
- DialogCloseButton_Click(me, me);
- }
- if(me.rootDialog)
- {
- m_goto("");
- }
-}
-
-float keyDownDialog(entity me, float key, float ascii, float shift)
-{
- if(me.closable)
- {
- if(key == K_ESCAPE)
- {
- me.close(me);
- return 1;
- }
- }
- return keyDownInputContainer(me, key, ascii, shift);
-}
-#endif
Added: trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c (rev 0)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/dialog.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -0,0 +1,30 @@
+#ifdef INTERFACE
+CLASS(NexuizDialog) EXTENDS(Dialog)
+ // still to be customized by user
+ /*
+ ATTRIB(NexuizDialog, closable, float, 1)
+ ATTRIB(NexuizDialog, rootNexuizDialog, float, 1)
+ ATTRIB(NexuizDialog, title, string, "Form1") // ;)
+ ATTRIB(NexuizDialog, color, vector, '1 0.5 1')
+ ATTRIB(NexuizDialog, intendedWidth, float, 0)
+ ATTRIB(NexuizDialog, rows, float, 3)
+ ATTRIB(NexuizDialog, columns, float, 2)
+ */
+
+ ATTRIB(NexuizDialog, marginTop, float, SKINMARGIN_TOP) // pixels
+ ATTRIB(NexuizDialog, marginBottom, float, SKINMARGIN_TOP) // pixels
+ ATTRIB(NexuizDialog, marginLeft, float, SKINMARGIN_LEFT) // pixels
+ ATTRIB(NexuizDialog, marginRight, float, SKINMARGIN_LEFT) // pixels
+ ATTRIB(NexuizDialog, columnSpacing, float, SKINMARGIN_COLUMNS) // pixels
+ ATTRIB(NexuizDialog, rowSpacing, float, SKINMARGIN_ROWS) // pixels
+ ATTRIB(NexuizDialog, rowHeight, float, SKINFONTSIZE_NORMAL * SKINHEIGHT_NORMAL) // pixels
+ ATTRIB(NexuizDialog, titleHeight, float, SKINFONTSIZE_TITLE * SKINHEIGHT_TITLE) // pixels
+ ATTRIB(NexuizDialog, titleFontSize, float, SKINFONTSIZE_TITLE) // pixels
+
+ ATTRIB(NexuizDialog, backgroundImage, string, SKINGFX_DIALOGBORDER)
+ ATTRIB(NexuizDialog, closeButtonImage, string, SKINGFX_CLOSEBUTTON)
+ENDCLASS(NexuizDialog)
+#endif
+
+#ifdef IMPLEMENTATION
+#endif
Modified: trunk/data/qcsrc/menu-div0test/nexuiz/dialog_teamselect.c
===================================================================
--- trunk/data/qcsrc/menu-div0test/nexuiz/dialog_teamselect.c 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu-div0test/nexuiz/dialog_teamselect.c 2007-10-28 10:20:41 UTC (rev 2860)
@@ -1,36 +1,52 @@
#ifdef INTERFACE
-CLASS(TeamSelectDialog) EXTENDS(Dialog)
+CLASS(TeamSelectDialog) EXTENDS(NexuizDialog)
METHOD(TeamSelectDialog, fill, void(entity)) // to be overridden by user to fill the dialog with controls
- ATTRIB(TeamSelectDialog, closable, float, 1)
- ATTRIB(TeamSelectDialog, title, string, "Team selection") // ;)
+ METHOD(TeamSelectDialog, open, void(entity))
+ ATTRIB(TeamSelectDialog, title, string, "Team Selection") // ;)
ATTRIB(TeamSelectDialog, color, vector, '1 1 1')
- ATTRIB(TeamSelectDialog, intendedWidth, float, 0.6)
- ATTRIB(TeamSelectDialog, intendedHeight, float, 0.15)
+ ATTRIB(TeamSelectDialog, intendedWidth, float, 0.4)
+ ATTRIB(TeamSelectDialog, rows, float, 5)
+ ATTRIB(TeamSelectDialog, columns, float, 4)
ATTRIB(TeamSelectDialog, name, string, "TeamSelect")
+ ATTRIB(TeamSelectDialog, team1, entity, NULL)
+ ATTRIB(TeamSelectDialog, team2, entity, NULL)
+ ATTRIB(TeamSelectDialog, team3, entity, NULL)
+ ATTRIB(TeamSelectDialog, team4, entity, NULL)
ENDCLASS(TeamSelectDialog)
#endif
#ifdef IMPLEMENTATION
-void fillTeamSelectDialog(entity me)
+entity makeTeamButton(string theName, vector theColor, string commandtheName)
{
- entity e;
+ entity b;
+ b = makeCommandButton(theName, theColor, commandtheName, 1);
+ return b;
+}
- e = spawnCommandButton();
- e.configureCommandButton(e, "Auto", '0 0 0', "cmd selectteam auto; cmd join", 1);
- me.addItemSimple(me, 1, 1, 1, e);
+void openTeamSelectDialog(entity me)
+{
+ float teams, nTeams;
+ teams = cvar("_teams_available");
+ nTeams = 0;
+ me.team1.disabled = !(teams & 1); nTeams += !!(teams & 1);
+ me.team2.disabled = !(teams & 2); nTeams += !!(teams & 2);
+ me.team3.disabled = !(teams & 4); nTeams += !!(teams & 4);
+ me.team4.disabled = !(teams & 8); nTeams += !!(teams & 8);
+}
- e = spawnCommandButton();
- e.configureCommandButton(e, "Red", '1 0 0', "cmd selectteam red; cmd join", 1);
- me.addItemSimple(me, me.lines, 1, 4, e);
- e = spawnCommandButton();
- e.configureCommandButton(e, "Blue", '0 0 1', "cmd selectteam blue; cmd join", 1);
- me.addItemSimple(me, me.lines, 2, 4, e);
- e = spawnCommandButton();
- e.configureCommandButton(e, "Yellow", '1 1 0', "cmd selectteam yellow; cmd join", 1);
- me.addItemSimple(me, me.lines, 3, 4, e);
- e = spawnCommandButton();
- e.configureCommandButton(e, "Pink", '1 0 1', "cmd selectteam pink; cmd join", 1);
- me.addItemSimple(me, me.lines, 4, 4, e);
+void fillTeamSelectDialog(entity me)
+{
+ me.TR(me);
+ me.TD(me, 2, 4, makeTeamButton("auto", '0 0 0', "cmd selectteam auto; cmd join"));
+ me.TR(me);
+ me.TR(me);
+ me.TD(me, 2, 1, me.team1 = makeTeamButton("red", '1 0.5 0.5', "cmd selectteam red; cmd join"));
+ me.TD(me, 2, 1, me.team2 = makeTeamButton("blue", '0.5 0.5 1', "cmd selectteam blue; cmd join"));
+ me.TD(me, 2, 1, me.team3 = makeTeamButton("yellow", '1 1 0.5', "cmd selectteam yellow; cmd join"));
+ me.TD(me, 2, 1, me.team4 = makeTeamButton("pink", '1 0.5 1', "cmd selectteam pink; cmd join"));
+ me.TR(me);
+ me.TR(me);
+ me.TD(me, 1, 4, makeTeamButton("spectate", '0 0 0', "cmd spectate"));
}
#endif
Modified: trunk/data/qcsrc/menu-div0test/skin.qh
===================================================================
--- trunk/data/qcsrc/menu-div0test/skin.qh 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/menu-div0test/skin.qh 2007-10-28 10:20:41 UTC (rev 2860)
@@ -1,4 +1,4 @@
-const float SKINFONTSIZE_TITLE = 12;
+const float SKINFONTSIZE_TITLE = 14;
const float SKINHEIGHT_TITLE = 1.5;
const string SKINGFX_DIALOGBORDER = "qcsrc/menu-div0test/baseborder";
const string SKINGFX_CLOSEBUTTON = "qcsrc/menu-div0test/baseclosebutton";
@@ -7,7 +7,9 @@
const float SKINMARGIN_TOP = 8;
const float SKINMARGIN_LEFT = 8;
+const float SKINMARGIN_COLUMNS = 4;
+const float SKINMARGIN_ROWS = 4;
-const float SKINFONTSIZE_NORMAL = 10;
+const float SKINFONTSIZE_NORMAL = 12;
const float SKINHEIGHT_NORMAL = 1.5;
const float SKINHEIGHT_NORMAL_WITHSPACING = 2;
Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc 2007-10-27 22:44:23 UTC (rev 2859)
+++ trunk/data/qcsrc/server/cl_client.qc 2007-10-28 10:20:41 UTC (rev 2860)
@@ -610,6 +610,7 @@
void FixClientCvars(entity e)
{
+ float t;
// send prediction settings to the client
stuffcmd(e, "\nin_bindmap 0 0\n");
stuffcmd(e, strcat("cl_gravity ", ftos(cvar("sv_gravity")), "\n"));
@@ -625,6 +626,11 @@
stuffcmd(e, strcat("set cl_movement_airaccel_qw ", ftos(cvar("sv_airaccel_qw")), "\n"));
stuffcmd(e, strcat("set cl_movement_airaccel_sideways_friction ", ftos(cvar("sv_airaccel_sideways_friction")), "\n"));
stuffcmd(e, "cl_movement_edgefriction 1\n");
+
+ // notify about available teams
+ CheckAllowedTeams(e);
+ t = 0; if(c1 >= 0) t |= 1; if(c2 >= 0) t |= 2; if(c3 >= 0) t |= 4; if(c4 >= 0) t |= 8;
+ stuffcmd(e, strcat("set _teams_available ", ftos(t), "\n"));
}
/*
More information about the nexuiz-commits
mailing list