Update of /cvsroot/netrek/client/netrekxp/src
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv1181/src
Modified Files:
input.c planetlist.c playerlist.c util.c
Log Message:
Te planet list window can now be used with info, lock and certain RCDs.
In other words, you can lock onto planets through the planet list window,
and send planet-related RCDs through the window as well.
Left clicking the planet list window will toggle between a sorted and
unsorted planet list, right clicking will close the planet window. Team's
starting planets are now separated by a white line.
Sorting functionality to come in a later patch.
Index: playerlist.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/playerlist.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- playerlist.c 14 Mar 2007 18:36:07 -0000 1.11
+++ playerlist.c 16 Mar 2007 01:44:24 -0000 1.12
@@ -1506,6 +1506,6 @@
}
}
- // We didn't find player or its state is wrong
+ // We didn't find player or its state is wrong
return (-1);
}
\ No newline at end of file
Index: util.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/util.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- util.c 7 May 2006 16:59:27 -0000 1.3
+++ util.c 16 Mar 2007 01:44:24 -0000 1.4
@@ -67,6 +67,17 @@
targ = &_targ;
return (targ);
}
+ if (ww == planetw)
+ {
+ /* Here we will get planet from planet list */
+ static struct obtype _targ;
+ g_x = (x - 1) / W_Textwidth;
+ g_y = (y - 4) / W_Textheight - 2; // Two header lines
+ _targ.o_type = PLANETTYPE;
+ _targ.o_num = GetPlanetFromPlist (g_x, g_y);
+ targ = &_targ;
+ return (targ);
+ }
if (ww == mapw)
{
Index: input.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/input.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- input.c 14 Mar 2007 18:36:07 -0000 1.27
+++ input.c 16 Mar 2007 01:44:24 -0000 1.28
@@ -1210,7 +1210,7 @@
* fastquit! */
if (data->Window != mapw && data->Window != w && data->Window != infow
- && data->Window != playerw)
+ && data->Window != playerw && data->Window != planetw)
return;
key = data->key;
@@ -1231,6 +1231,12 @@
data->x = x;
data->y = y;
}
+ else if (findMouseInWin (&x, &y, planetw))
+ { /* planet list window */
+ data->Window = planetw;
+ data->x = x;
+ data->y = y;
+ }
else if (findMouseInWin (&x, &y, playerw))
{ /* player list window */
data->Window = playerw;
@@ -1386,9 +1392,9 @@
return;
}
- /* If the mouse is in player list window - enable info and lock */
- /* This part has to be after macros, so point macros will work on */
- /* the players from playerlist */
+ /* If the mouse is in player list window - enable info and lock, as
+ well as certain RCDs. This part has to be after macros, so the RCDs
+ will work on the players from this list */
if (data->Window == playerw)
{
switch (key)
@@ -1410,6 +1416,29 @@
return;
}
}
+ /* If the mouse is in planet list window - enable info and lock, as
+ well as certain RCDs. This part has to be after macros, so that RCDs
+ will work on the planets from this list */
+ if (data->Window == planetw)
+ {
+ switch (key)
+ {
+ case 'i':
+ case 'I':
+ case 'l':
+ case 194: /* ^b */
+ case 195: /* ^c */
+ case 204: /* ^l */
+ case 205: /* ^m */
+ case 212: /* ^t */
+ case 144: /* ^0 */
+ case 145: /* ^1 */
+ case 150: /* ^6 */
+ break;
+ default:
+ return;
+ }
+ }
#ifdef MOTION_MOUSE
if ((data->type == W_EV_CM_BUTTON) && /* KOC - 10/18/95 */
@@ -1496,10 +1525,31 @@
#endif
if (data->Window != w && data->Window != mapw
- && data->Window != infow
- && data->Window != playerw)
+ && data->Window != infow && data->Window != playerw
+ && data->Window != planetw)
return;
+ if (data->Window == planetw)
+ {
+ int x, y;
+
+ if (findMouseInWin (&x, &y, planetw))
+ {
+ data->Window = planetw;
+ data->x = x;
+ data->y = y;
+ }
+ if (data->key == W_LBUTTON)
+ {
+ sortPlanets = !sortPlanets;
+ updatePlanetw();
+ }
+ else if (data->key == W_RBUTTON)
+ W_UnmapWindow (planetw);
+
+ return;
+ }
+
if (data->Window == playerw)
{
int x, y;
Index: planetlist.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/planetlist.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- planetlist.c 12 Dec 2006 04:47:08 -0000 1.4
+++ planetlist.c 16 Mar 2007 01:44:24 -0000 1.5
@@ -32,6 +32,8 @@
"ORI"
};
+int planet_row[MAXPLANETS]; /* planets location in current plist */
+
/* * Open a window which contains all the planets and their current *
* statistics. Players will not know about planets that their team * has not
* orbited. */
@@ -42,8 +44,10 @@
char buf[BUFSIZ];
/* W_ClearWindow(planetw); */
- (void) sprintf (buf, "Planet Name own armies REPAIR FUEL AGRI CORE info");
+ (void) sprintf (buf, "Planet Name Own Armies REPAIR FUEL AGRI CORE Info");
W_WriteText (planetw, 2, 1, textColor, buf, strlen (buf), W_RegularFont);
+ /* Underline heading */
+ W_MakeLine (planetw, 2, 2 + 2 * W_Textheight, 2 + 57 * W_Textwidth , 2 + 2 * W_Textheight, W_White);
/* Initialize planet window string array */
for (i = 0; i < MAXPLANETS; i++)
strcpy(priorplanets[i], "");
@@ -60,6 +64,9 @@
for (i = 0, j = &planets[i]; i < MAXPLANETS; i++, j++)
{
+ /* Fill planet_row to get right planet placement in the list */
+ planet_row[i] = j->pl_no;
+
if (j->pl_info & me->p_team)
{
(void) sprintf (buf, "%-16s %3s %3d %6s %4s %4s %4s %c%c%c%c",
@@ -93,5 +100,34 @@
strcpy(priorplanets[i], buf);
}
}
+ if (i != 0 && (i % 10) == 0)
+ {
+ W_MakeLine (planetw,
+ 2 + 18 * W_Textwidth,
+ 2 + W_Textheight * (i+2),
+ 2 + 39 * W_Textwidth,
+ 2 + W_Textheight * (i+2),
+ W_White);
+ }
+ }
+}
+
+int
+GetPlanetFromPlist (int x, int y)
+{
+ int i;
+ int planet_no;
+
+ /* Let's find what planet sits in poition y in the list */
+ for (i = 0; i < MAXPLANETS; i++)
+ {
+ if (planet_row[i] == y)
+ {
+ planet_no = i;
+ return planet_no;
+ }
}
+
+ // We didn't find planet
+ return (-1);
}
\ No newline at end of file