[Quake2world-dev] r346 - in quake2world/branches/menu/src: . menu menu/node
mattn at jdolan.dyndns.org
mattn at jdolan.dyndns.org
Fri Apr 17 07:16:37 UTC 2009
Author: mattn
Date: 2009-04-17 07:16:37 +0000 (Fri, 17 Apr 2009)
New Revision: 346
Modified:
quake2world/branches/menu/src/Makefile.am
quake2world/branches/menu/src/cl_input.c
quake2world/branches/menu/src/client.h
quake2world/branches/menu/src/menu/m_draw.c
quake2world/branches/menu/src/menu/m_draw.h
quake2world/branches/menu/src/menu/node/m_node_controls.c
quake2world/branches/menu/src/menu/node/m_node_editor.c
quake2world/branches/menu/src/menu/node/m_node_window.c
quake2world/branches/menu/src/menu/scripts.c
quake2world/branches/menu/src/menu/scripts.h
quake2world/branches/menu/src/r_image.c
quake2world/branches/menu/src/r_image.h
Log:
* reintroduced R_DrawNormPic and fixed some more compile problems
Modified: quake2world/branches/menu/src/Makefile.am
===================================================================
--- quake2world/branches/menu/src/Makefile.am 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/Makefile.am 2009-04-17 07:16:37 UTC (rev 346)
@@ -24,13 +24,13 @@
menu/node/m_node_abstractvalue.h menu/node/m_node_bar.h menu/node/m_node_button.h menu/node/m_node_checkbox.h menu/node/m_node_controls.h \
menu/node/m_node_custombutton.h menu/node/m_node_editor.h menu/node/m_node_image.h \
menu/node/m_node_panel.h menu/node/m_node_radiobutton.h menu/node/m_node_rows.h menu/node/m_node_special.h \
- menu/node/m_node_string.h menu/node/m_node_tab.h menu/node/m_node_tbar.h menu/node/m_node_textentry.h \
+ menu/node/m_node_string.hmenu/node/m_node_textentry.h \
menu/node/m_node_vscrollbar.h menu/node/m_node_window.h menu/node/m_node_zone.h
MENU_NODES = menu/node/m_node_abstractnode.c menu/node/m_node_abstractoption.c menu/node/m_node_abstractscrollbar.c menu/node/m_node_abstractvalue.c \
menu/node/m_node_bar.c menu/node/m_node_button.c menu/node/m_node_checkbox.c menu/node/m_node_controls.c menu/node/m_node_custombutton.c menu/node/m_node_editor.c \
menu/node/m_node_image.c menu/node/m_node_panel.c menu/node/m_node_radiobutton.c menu/node/m_node_rows.c \
- menu/node/m_node_special.c menu/node/m_node_string.c menu/node/m_node_tab.c menu/node/m_node_tbar.c \
+ menu/node/m_node_special.c menu/node/m_node_string.c \
menu/node/m_node_textentry.c menu/node/m_node_vscrollbar.c menu/node/m_node_window.c menu/node/m_node_zone.c
RENDERER_H = images.h r_gl.h r_image.h r_material.h r_model.h r_program.h \
Modified: quake2world/branches/menu/src/cl_input.c
===================================================================
--- quake2world/branches/menu/src/cl_input.c 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/cl_input.c 2009-04-17 07:16:37 UTC (rev 346)
@@ -56,7 +56,7 @@
// mouse vars
static qboolean mouse_active;
-static float mouse_x, mouse_y;
+float mouse_x, mouse_y;
static float old_mouse_x, old_mouse_y;
void Key_SetDest(int dest) {
Modified: quake2world/branches/menu/src/client.h
===================================================================
--- quake2world/branches/menu/src/client.h 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/client.h 2009-04-17 07:16:37 UTC (rev 346)
@@ -67,6 +67,8 @@
extern char cl_weaponmodels[MAX_CLIENTWEAPONMODELS][MAX_QPATH];
extern int num_cl_weaponmodels;
+extern float mouse_x, mouse_y;
+
#define CMD_BACKUP 128 // allow a lot of command backups for very fast systems
#define CMD_MASK (CMD_BACKUP - 1)
Modified: quake2world/branches/menu/src/menu/m_draw.c
===================================================================
--- quake2world/branches/menu/src/menu/m_draw.c 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/menu/m_draw.c 2009-04-17 07:16:37 UTC (rev 346)
@@ -196,13 +196,13 @@
if (node->size[0] && node->size[1]) {
vec2_t pos;
MN_GetNodeAbsPos(node, pos);
- if (node->bgcolor[3] != 0)
+/* if (node->bgcolor[3] != 0)
R_DrawFill(pos[0], pos[1], node->size[0], node->size[1], ALIGN_UL, node->bgcolor);
if (node->border && node->bordercolor[3] != 0) {
R_DrawRect(pos[0], pos[1], node->size[0], node->size[1],
node->bordercolor, node->border, 0xFFFF);
- }
+ }*/
}
/* draw the node */
@@ -217,6 +217,14 @@
}
/**
+ * @brief Generic notice function
+ */
+int MN_DrawNotice (int x, int y, const char *noticeText)
+{
+ return R_DrawString(x, y, noticeText, CON_COLOR_WHITE);
+}
+
+/**
* @brief Draws the menu stack
* @sa SCR_UpdateScreen
*/
Modified: quake2world/branches/menu/src/menu/m_draw.h
===================================================================
--- quake2world/branches/menu/src/menu/m_draw.h 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/menu/m_draw.h 2009-04-17 07:16:37 UTC (rev 346)
@@ -36,5 +36,6 @@
void MN_DisplayNotice(const char *text, int time);
void MN_DrawCursor(void);
void MN_CaptureDrawOver(struct menuNode_s *node);
+int MN_DrawNotice(int x, int y, const char *noticeText);
#endif
Modified: quake2world/branches/menu/src/menu/node/m_node_controls.c
===================================================================
--- quake2world/branches/menu/src/menu/node/m_node_controls.c 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/menu/node/m_node_controls.c 2009-04-17 07:16:37 UTC (rev 346)
@@ -62,15 +62,15 @@
x -= deltaMouseX;
if (x < 0)
x = 0;
- if (x + node->root->size[0] > viddef.virtualWidth)
- x = viddef.virtualWidth - node->root->size[0];
+ if (x + node->root->size[0] > r_view.virtualWidth)
+ x = r_view.virtualWidth - node->root->size[0];
/* compute new y position of the menu */
y -= deltaMouseY;
if (y < 0)
y = 0;
- if (y + node->root->size[1] > viddef.virtualHeight)
- y = viddef.virtualHeight - node->root->size[1];
+ if (y + node->root->size[1] > r_view.virtualHeight)
+ y = r_view.virtualHeight - node->root->size[1];
MN_SetNewMenuPos(node->root, x, y);
}
Modified: quake2world/branches/menu/src/menu/node/m_node_editor.c
===================================================================
--- quake2world/branches/menu/src/menu/node/m_node_editor.c 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/menu/node/m_node_editor.c 2009-04-17 07:16:37 UTC (rev 346)
@@ -47,9 +47,7 @@
vec2_t pos;
MN_GetNodeAbsPos(node, pos);
- R_ColorBlend(color);
- R_FontDrawString("f_small_bold", ALIGN_UL, 20, 50, 20, 50, 400, 400, 0, va("%s (%s)", node->name, node->behaviour->name), 0, 0, NULL, qfalse, LONGLINES_PRETTYCHOP);
- R_ColorBlend(NULL);
+ R_DrawString(20, 50, va("%s (%s)", node->name, node->behaviour->name), CON_COLOR_WHITE);
R_DrawRect(pos[0] - 1, pos[1] - 1, node->size[0] + 2, node->size[1] + 2, color, 1.0, 0x3333);
R_DrawFill(pos[0] - anchorSize, pos[1] - anchorSize, anchorSize, anchorSize, ALIGN_UL, color);
Modified: quake2world/branches/menu/src/menu/node/m_node_window.c
===================================================================
--- quake2world/branches/menu/src/menu/node/m_node_window.c 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/menu/node/m_node_window.c 2009-04-17 07:16:37 UTC (rev 346)
@@ -85,20 +85,20 @@
if (MN_WindowIsFullScreen(node)) {
/* top */
if (pos[1] != 0)
- R_DrawFill(0, 0, viddef.virtualWidth, pos[1], ALIGN_UL, anamorphicBorder);
+ R_DrawFill(0, 0, r_view.virtualWidth, pos[1], ALIGN_UL, anamorphicBorder);
/* left-right */
if (pos[0] != 0)
R_DrawFill(0, pos[1], pos[0], node->size[1], ALIGN_UL, anamorphicBorder);
- if (pos[0] + node->size[0] < viddef.virtualWidth)
- R_DrawFill(viddef.virtualWidth, pos[1], viddef.virtualWidth - (pos[0] + node->size[0]), node->size[1], ALIGN_UR, anamorphicBorder);
+ if (pos[0] + node->size[0] < r_view.virtualWidth)
+ R_DrawFill(r_view.virtualWidth, pos[1], r_view.virtualWidth - (pos[0] + node->size[0]), node->size[1], ALIGN_UR, anamorphicBorder);
/* bottom */
- if (pos[1] + node->size[1] < viddef.virtualHeight)
- R_DrawFill(0, viddef.virtualHeight, viddef.virtualWidth, viddef.virtualHeight - (pos[1] + node->size[1]), ALIGN_LL, anamorphicBorder);
+ if (pos[1] + node->size[1] < r_view.virtualHeight)
+ R_DrawFill(0, r_view.virtualHeight, r_view.virtualWidth, r_view.virtualHeight - (pos[1] + node->size[1]), ALIGN_LL, anamorphicBorder);
}
/* darker background if last window is a modal */
if (node->u.window.modal && mn.menuStack[mn.menuStackPos - 1] == node)
- R_DrawFill(0, 0, viddef.virtualWidth, viddef.virtualHeight, ALIGN_UL, modalBackground);
+ R_DrawFill(0, 0, r_view.virtualWidth, r_view.virtualHeight, ALIGN_UL, modalBackground);
/* draw the background */
image = MN_GetReferenceString(node, node->image);
@@ -187,20 +187,20 @@
/* use a the space */
if (node->u.window.fill) {
- if (node->size[0] != viddef.virtualWidth) {
- node->size[0] = viddef.virtualWidth;
+ if (node->size[0] != r_view.virtualWidth) {
+ node->size[0] = r_view.virtualWidth;
resized = qtrue;
}
- if (node->size[1] != viddef.virtualHeight) {
- node->size[1] = viddef.virtualHeight;
+ if (node->size[1] != r_view.virtualHeight) {
+ node->size[1] = r_view.virtualHeight;
resized = qtrue;
}
}
/* move fullscreen menu on the center of the screen */
if (MN_WindowIsFullScreen(node)) {
- node->pos[0] = (int) ((viddef.virtualWidth - node->size[0]) / 2);
- node->pos[1] = (int) ((viddef.virtualHeight - node->size[1]) / 2);
+ node->pos[0] = (int) ((r_view.virtualWidth - node->size[0]) / 2);
+ node->pos[1] = (int) ((r_view.virtualHeight - node->size[1]) / 2);
}
/** @todo check and fix here window outside the screen */
Modified: quake2world/branches/menu/src/menu/scripts.c
===================================================================
--- quake2world/branches/menu/src/menu/scripts.c 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/menu/scripts.c 2009-04-17 07:16:37 UTC (rev 346)
@@ -594,3 +594,4 @@
else
return NULL;
}
+
Modified: quake2world/branches/menu/src/menu/scripts.h
===================================================================
--- quake2world/branches/menu/src/menu/scripts.h 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/menu/scripts.h 2009-04-17 07:16:37 UTC (rev 346)
@@ -54,6 +54,9 @@
#define COM_Parse Com_Parse
+#define VID_NORM_WIDTH 1024
+#define VID_NORM_HEIGHT 768
+
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap);
void Q_strncpyz(char *dest, const char *src, size_t destsize);
void Q_strcat(char *dest, const char *src, size_t destsize);
@@ -158,6 +161,8 @@
const char *Com_ValueToStr(const void *base, const valueTypes_t type, const int ofs);
int Com_ParseValue(void *base, const char *token, valueTypes_t type, int ofs, size_t size, size_t *writedByte);
+void R_DrawNormPic(float x, float y, float w, float h, float sh, float th, float sl, float tl, int align, qboolean blend, const char *name);
+
#include "mem.h"
#endif
Modified: quake2world/branches/menu/src/r_image.c
===================================================================
--- quake2world/branches/menu/src/r_image.c 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/r_image.c 2009-04-17 07:16:37 UTC (rev 346)
@@ -731,3 +731,144 @@
r_numimages = 0;
}
+
+static float image_texcoords[4 * 2];
+static short image_verts[4 * 2];
+
+/**
+ * @brief Draws an image or parts of it
+ * @param[in] x X position to draw the image to
+ * @param[in] y Y position to draw the image to
+ * @param[in] w Width of the image
+ * @param[in] h Height of the image
+ * @param[in] sh Right x corner coord of the square to draw
+ * @param[in] th Lower y corner coord of the square to draw
+ * @param[in] sl Left x corner coord of the square to draw
+ * @param[in] tl Upper y corner coord of the square to draw
+ * @param[in] align The alignment we should use for placing the image onto the screen (see align_t)
+ * @param[in] blend Enable the blend mode (for alpha channel images)
+ * @param[in] name The name of the image - relative to base/pics
+ * @sa R_RegisterImage
+ * @note All these parameter are normalized to VID_NORM_WIDTH and VID_NORM_HEIGHT
+ * they are adjusted in this function
+ */
+void R_DrawNormPic (float x, float y, float w, float h, float sh, float th, float sl, float tl, int align, qboolean blend, const char *name)
+{
+ float nw, nh, x1, x2, x3, x4, y1, y2, y3, y4;
+ const image_t *image;
+
+ image = R_FindImage(va("pics/%s", name), it_pic);
+ if (!image) {
+ Com_Printf("Can't find pic: %s\n", name);
+ return;
+ }
+
+ /* normalize to the screen resolution */
+ x1 = x * r_view.rx;
+ y1 = y * r_view.ry;
+
+ /* provided width and height (if any) take precedence */
+ if (w)
+ nw = w * r_view.rx;
+ else
+ nw = 0;
+
+ if (h)
+ nh = h * r_view.ry;
+ else
+ nh = 0;
+
+ /* horizontal texture mapping */
+ if (sh) {
+ if (!w)
+ nw = (sh - sl) * r_view.rx;
+ sh /= image->width;
+ } else {
+ if (!w)
+ nw = ((float)image->width - sl) * viddef.rx;
+ sh = 1.0f;
+ }
+ sl /= image->width;
+
+ /* vertical texture mapping */
+ if (th) {
+ if (!h)
+ nh = (th - tl) * viddef.ry;
+ th /= image->height;
+ } else {
+ if (!h)
+ nh = ((float)image->height - tl) * viddef.ry;
+ th = 1.0f;
+ }
+ tl /= image->height;
+
+ /* alignment */
+ if (align > 0 && align < 18) { /* ALIGN_LAST */
+ /* horizontal (0 is left) */
+ switch (align % 3) {
+ case 1:
+ x1 -= nw * 0.5;
+ break;
+ case 2:
+ x1 -= nw;
+ break;
+ }
+
+ /* vertical (0 is upper) */
+ switch ((align % 9) / 3) {
+ case 1:
+ y1 -= nh * 0.5;
+ break;
+ case 2:
+ y1 -= nh;
+ break;
+ }
+ }
+
+ /* fill the rest of the coordinates to make a rectangle */
+ x4 = x1;
+ x3 = x2 = x1 + nw;
+ y2 = y1;
+ y4 = y3 = y1 + nh;
+
+ /* slanting */
+ if (align >= 9 && align < 18) {
+ x1 += nh;
+ x2 += nh;
+ }
+
+ image_texcoords[0] = sl;
+ image_texcoords[1] = tl;
+ image_texcoords[2] = sh;
+ image_texcoords[3] = tl;
+ image_texcoords[4] = sh;
+ image_texcoords[5] = th;
+ image_texcoords[6] = sl;
+ image_texcoords[7] = th;
+ image_verts[0] = x1;
+ image_verts[1] = y1;
+ image_verts[2] = x2;
+ image_verts[3] = y2;
+ image_verts[4] = x3;
+ image_verts[5] = y3;
+ image_verts[6] = x4;
+ image_verts[7] = y4;
+
+ /* alter the array pointers */
+ glVertexPointer(2, GL_SHORT, 0, image_verts);
+ glTexCoordPointer(2, GL_FLOAT, 0, image_texcoords);
+
+ if (blend)
+ R_EnableBlend(true);
+
+ R_BindTexture(image->texnum);
+
+ glDrawArrays(GL_QUADS, 0, 4);
+
+ if (blend)
+ R_EnableBlend(false);
+
+ /* and restore them */
+ R_BindDefaultArray(GL_TEXTURE_COORD_ARRAY);
+ R_BindDefaultArray(GL_VERTEX_ARRAY);
+}
Modified: quake2world/branches/menu/src/r_image.h
===================================================================
--- quake2world/branches/menu/src/r_image.h 2009-04-17 07:03:02 UTC (rev 345)
+++ quake2world/branches/menu/src/r_image.h 2009-04-17 07:16:37 UTC (rev 346)
@@ -99,5 +99,6 @@
void R_FreeImage(image_t *image);
void R_FreeImages(void);
void R_ShutdownImages(void);
+void R_DrawNormPic(float x, float y, float w, float h, float sh, float th, float sl, float tl, int align, qboolean blend, const char *name);
#endif /* __R_IMAGE_H__ */
More information about the Quake2World-dev
mailing list