- Added support for user-defined crosshairs in the Display Options menu. See

xhairs.txt in zdoom.pk3. It's pretty simple.


SVN r679 (trunk)
This commit is contained in:
Randy Heit 2008-01-08 04:00:43 +00:00
parent 2d4b679fcb
commit 761c77d033
5 changed files with 123 additions and 23 deletions

View file

@ -1,4 +1,6 @@
January 7, 2008 January 7, 2008
- Added support for user-defined crosshairs in the Display Options menu. See
xhairs.txt in zdoom.pk3. It's pretty simple.
- Fixed: P_BounceWall() cannot assume that BlockingLine is the line the actor - Fixed: P_BounceWall() cannot assume that BlockingLine is the line the actor
should bounce off of. Since the order lines in a blockmap cell are checked should bounce off of. Since the order lines in a blockmap cell are checked
for collision is essentially undefined, there could be another line closer to for collision is essentially undefined, there could be another line closer to

View file

@ -98,6 +98,7 @@ typedef enum {
absslider, absslider,
inverter, inverter,
discrete, discrete,
discretes,
cdiscrete, cdiscrete,
discrete_guid, discrete_guid,
control, control,
@ -145,6 +146,7 @@ typedef struct menuitem_s {
} d; } d;
union { union {
struct value_s *values; struct value_s *values;
struct valuestring_t *valuestrings;
GUIDName *guidvalues; GUIDName *guidvalues;
char *command; char *command;
void (*cfunc)(FBaseCVar *cvar, float newval); void (*cfunc)(FBaseCVar *cvar, float newval);
@ -174,6 +176,11 @@ typedef struct value_s {
const char *name; const char *name;
} value_t; } value_t;
struct valuestring_t {
float value;
FString name;
};
typedef struct typedef struct
{ {
// -1 = no cursor here, 1 = ok, 2 = arrows ok // -1 = no cursor here, 1 = ok, 2 = arrows ok

View file

@ -76,6 +76,7 @@
#include "m_misc.h" #include "m_misc.h"
#include "hardware.h" #include "hardware.h"
#include "sc_man.h"
// Data. // Data.
#include "m_menu.h" #include "m_menu.h"
@ -442,6 +443,7 @@ menu_t ControlsMenu =
static void StartMessagesMenu (void); static void StartMessagesMenu (void);
static void StartAutomapMenu (void); static void StartAutomapMenu (void);
static void StartScoreboardMenu (void); static void StartScoreboardMenu (void);
static void InitCrosshairsList();
EXTERN_CVAR (Bool, st_scale) EXTERN_CVAR (Bool, st_scale)
EXTERN_CVAR (Int, r_detail) EXTERN_CVAR (Int, r_detail)
@ -456,17 +458,7 @@ EXTERN_CVAR (Bool, vid_palettehack)
EXTERN_CVAR (Bool, vid_attachedsurfaces) EXTERN_CVAR (Bool, vid_attachedsurfaces)
EXTERN_CVAR (Int, screenblocks) EXTERN_CVAR (Int, screenblocks)
static value_t Crosshairs[] = static TArray<valuestring_t> Crosshairs;
{
{ 0.0, "None" },
{ 1.0, "Cross 1" },
{ 2.0, "Cross 2" },
{ 3.0, "X" },
{ 4.0, "Circle" },
{ 5.0, "Angle" },
{ 6.0, "Triangle" },
{ 7.0, "Dot" }
};
static value_t DetailModes[] = static value_t DetailModes[] =
{ {
@ -512,7 +504,7 @@ static menuitem_t VideoItems[] = {
{ redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} }, { redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
{ slider, "Screen size", {&screenblocks}, {3.0}, {12.0}, {1.0}, {NULL} }, { slider, "Screen size", {&screenblocks}, {3.0}, {12.0}, {1.0}, {NULL} },
{ slider, "Brightness", {&Gamma}, {1.0}, {3.0}, {0.1}, {NULL} }, { slider, "Brightness", {&Gamma}, {1.0}, {3.0}, {0.1}, {NULL} },
{ discrete, "Crosshair", {&crosshair}, {8.0}, {0.0}, {0.0}, {Crosshairs} }, { discretes,"Crosshair", {&crosshair}, {8.0}, {0.0}, {0.0}, {NULL} },
{ discrete, "Column render mode", {&r_columnmethod}, {2.0}, {0.0}, {0.0}, {ColumnMethods} }, { discrete, "Column render mode", {&r_columnmethod}, {2.0}, {0.0}, {0.0}, {ColumnMethods} },
{ discrete, "Detail mode", {&r_detail}, {4.0}, {0.0}, {0.0}, {DetailModes} }, { discrete, "Detail mode", {&r_detail}, {4.0}, {0.0}, {0.0}, {DetailModes} },
{ discrete, "Stretch short skies", {&r_stretchsky}, {2.0}, {0.0}, {0.0}, {OnOff} }, { discrete, "Stretch short skies", {&r_stretchsky}, {2.0}, {0.0}, {0.0}, {OnOff} },
@ -1461,6 +1453,17 @@ int M_FindCurVal (float cur, value_t *values, int numvals)
return v; return v;
} }
int M_FindCurVal (float cur, valuestring_t *values, int numvals)
{
int v;
for (v = 0; v < numvals; v++)
if (values[v].value == cur)
break;
return v;
}
int M_FindCurGUID (const GUID &guid, GUIDName *values, int numvals) int M_FindCurGUID (const GUID &guid, GUIDName *values, int numvals)
{ {
int v; int v;
@ -1616,6 +1619,7 @@ void M_OptDrawer ()
} }
break; break;
case discretes:
case discrete: case discrete:
case cdiscrete: case cdiscrete:
case inverter: case inverter:
@ -1632,7 +1636,14 @@ void M_OptDrawer ()
{ {
vals = (int)item->b.numvalues; vals = (int)item->b.numvalues;
} }
if (item->type != discretes)
{
v = M_FindCurVal (value.Float, item->e.values, vals); v = M_FindCurVal (value.Float, item->e.values, vals);
}
else
{
v = M_FindCurVal (value.Float, item->e.valuestrings, vals);
}
if (v == vals) if (v == vals)
{ {
@ -1642,7 +1653,8 @@ void M_OptDrawer ()
else else
{ {
screen->DrawText (item->type == cdiscrete ? v : ValueColor, screen->DrawText (item->type == cdiscrete ? v : ValueColor,
CurrentMenu->indent + 14, y, item->e.values[v].name, CurrentMenu->indent + 14, y,
item->type != discretes ? item->e.values[v].name : item->e.valuestrings[v].name,
DTA_Clean, true, TAG_DONE); DTA_Clean, true, TAG_DONE);
} }
@ -2098,6 +2110,7 @@ void M_OptResponder (event_t *ev)
S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE); S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE);
break; break;
case discretes:
case discrete: case discrete:
case cdiscrete: case cdiscrete:
{ {
@ -2106,11 +2119,18 @@ void M_OptResponder (event_t *ev)
numvals = (int)item->b.min; numvals = (int)item->b.min;
value = item->a.cvar->GetGenericRep (CVAR_Float); value = item->a.cvar->GetGenericRep (CVAR_Float);
if (item->type != discretes)
{
cur = M_FindCurVal (value.Float, item->e.values, numvals); cur = M_FindCurVal (value.Float, item->e.values, numvals);
}
else
{
cur = M_FindCurVal (value.Float, item->e.valuestrings, numvals);
}
if (--cur < 0) if (--cur < 0)
cur = numvals - 1; cur = numvals - 1;
value.Float = item->e.values[cur].value; value.Float = item->type != discretes ? item->e.values[cur].value : item->e.valuestrings[cur].value;
item->a.cvar->SetGenericRep (value, CVAR_Float); item->a.cvar->SetGenericRep (value, CVAR_Float);
// Hack hack. Rebuild list of resolutions // Hack hack. Rebuild list of resolutions
@ -2232,6 +2252,7 @@ void M_OptResponder (event_t *ev)
S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE); S_Sound (CHAN_VOICE, "menu/cursor", 1, ATTN_NONE);
break; break;
case discretes:
case discrete: case discrete:
case cdiscrete: case cdiscrete:
{ {
@ -2240,11 +2261,18 @@ void M_OptResponder (event_t *ev)
numvals = (int)item->b.min; numvals = (int)item->b.min;
value = item->a.cvar->GetGenericRep (CVAR_Float); value = item->a.cvar->GetGenericRep (CVAR_Float);
if (item->type != discretes)
{
cur = M_FindCurVal (value.Float, item->e.values, numvals); cur = M_FindCurVal (value.Float, item->e.values, numvals);
}
else
{
cur = M_FindCurVal (value.Float, item->e.valuestrings, numvals);
}
if (++cur >= numvals) if (++cur >= numvals)
cur = 0; cur = 0;
value.Float = item->e.values[cur].value; value.Float = item->type != discretes ? item->e.values[cur].value : item->e.valuestrings[cur].value;
item->a.cvar->SetGenericRep (value, CVAR_Float); item->a.cvar->SetGenericRep (value, CVAR_Float);
// Hack hack. Rebuild list of resolutions // Hack hack. Rebuild list of resolutions
@ -2398,18 +2426,25 @@ void M_OptResponder (event_t *ev)
item->e.mfunc(); item->e.mfunc();
} }
} }
else if (item->type == discrete || item->type == cdiscrete) else if (item->type == discrete || item->type == cdiscrete || item->type == discretes)
{ {
int cur; int cur;
int numvals; int numvals;
numvals = (int)item->b.min; numvals = (int)item->b.min;
value = item->a.cvar->GetGenericRep (CVAR_Float); value = item->a.cvar->GetGenericRep (CVAR_Float);
if (item->type != discretes)
{
cur = M_FindCurVal (value.Float, item->e.values, numvals); cur = M_FindCurVal (value.Float, item->e.values, numvals);
}
else
{
cur = M_FindCurVal (value.Float, item->e.valuestrings, numvals);
}
if (++cur >= numvals) if (++cur >= numvals)
cur = 0; cur = 0;
value.Float = item->e.values[cur].value; value.Float = item->type != discretes ? item->e.values[cur].value : item->e.valuestrings[cur].value;
item->a.cvar->SetGenericRep (value, CVAR_Float); item->a.cvar->SetGenericRep (value, CVAR_Float);
// Hack hack. Rebuild list of resolutions // Hack hack. Rebuild list of resolutions
@ -2846,6 +2881,7 @@ static void MakeSoundChanges (void)
static void VideoOptions (void) static void VideoOptions (void)
{ {
InitCrosshairsList();
M_SwitchMenu (&VideoMenu); M_SwitchMenu (&VideoMenu);
} }
@ -2853,6 +2889,7 @@ CCMD (menu_display)
{ {
M_StartControlPanel (true); M_StartControlPanel (true);
OptionsActive = true; OptionsActive = true;
InitCrosshairsList();
M_SwitchMenu (&VideoMenu); M_SwitchMenu (&VideoMenu);
} }
@ -3264,3 +3301,51 @@ void M_Deinit ()
M_FreeModesList(); M_FreeModesList();
} }
// Reads any XHAIRS lumps for the names of crosshairs and
// adds them to the display options menu.
void InitCrosshairsList()
{
int lastlump, lump;
valuestring_t value;
lastlump = 0;
Crosshairs.Clear();
value.value = 0;
value.name = "None";
Crosshairs.Push(value);
while ((lump = Wads.FindLump("XHAIRS", &lastlump)) != -1)
{
SC_OpenLumpNum(lump, "XHAIRS");
while (SC_GetNumber())
{
value.value = float(sc_Number);
SC_MustGetString();
value.name = sc_String;
if (value.value != 0)
{ // Check if it already exists. If not, add it.
unsigned int i;
for (i = 1; i < Crosshairs.Size(); ++i)
{
if (Crosshairs[i].value == value.value)
{
break;
}
}
if (i < Crosshairs.Size())
{
Crosshairs[i].name = value.name;
}
else
{
Crosshairs.Push(value);
}
}
}
SC_Close();
}
VideoItems[6].b.numvalues = float(Crosshairs.Size());
VideoItems[6].e.valuestrings = &Crosshairs[0];
}

View file

@ -169,6 +169,10 @@
RelativePath=".\x11r6rgb.txt" RelativePath=".\x11r6rgb.txt"
> >
</File> </File>
<File
RelativePath=".\xhairs.txt"
>
</File>
<Filter <Filter
Name="Map Translators" Name="Map Translators"
> >

View file

@ -110,6 +110,8 @@ graphics/stfbany.lmp stfbany.lmp
======== ========
# Crosshairs # Crosshairs
xhairs.txt xhairs.txt
graphics/xhairs1.imgz xhairs1.imgz graphics/xhairs1.imgz xhairs1.imgz
graphics/xhairs2.imgz xhairs2.imgz graphics/xhairs2.imgz xhairs2.imgz
graphics/xhairs3.imgz xhairs3.imgz graphics/xhairs3.imgz xhairs3.imgz
@ -119,7 +121,7 @@ graphics/xhairs6.imgz xhairs6.imgz
graphics/xhairs7.imgz xhairs7.imgz graphics/xhairs7.imgz xhairs7.imgz
graphics/xhairb1.imgz xhairb1.imgz graphics/xhairb1.imgz xhairb1.imgz
graphics/xhairb2.imgz xhairb2.png graphics/xhairb2.png xhairb2.png
graphics/xhairb3.imgz xhairb3.imgz graphics/xhairb3.imgz xhairb3.imgz
graphics/xhairb4.imgz xhairb4.imgz graphics/xhairb4.imgz xhairb4.imgz
graphics/xhairb5.imgz xhairb5.imgz graphics/xhairb5.imgz xhairb5.imgz