From ccafc4118942fb81e7f33ff445cf3a856474ab29 Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 5 Oct 2008 11:51:59 +0000 Subject: [PATCH] Weapon sprite scaling, still needs a rotatespritescaled CON command git-svn-id: https://svn.eduke32.com/eduke32@1090 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/config.c | 5 +++ polymer/eduke32/source/duke3d.h | 2 +- polymer/eduke32/source/game.c | 48 ++++++++++++------------- polymer/eduke32/source/gamedef.c | 1 + polymer/eduke32/source/gamedef.h | 1 + polymer/eduke32/source/gamestructures.c | 9 +++++ polymer/eduke32/source/menus.c | 31 ++++++++++------ polymer/eduke32/source/osdcmds.c | 14 ++++++++ polymer/eduke32/source/player.c | 32 +++++++++++++---- 9 files changed, 101 insertions(+), 42 deletions(-) diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 266debac5..71633150c 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -249,6 +249,7 @@ void CONFIG_SetDefaults(void) ud.display_bonus_screen = 1; ud.show_level_text = 1; ud.configversion = 0; + ud.weaponscale = 100; Bstrcpy(ud.rtsname, "DUKE.RTS"); Bstrcpy(myname, "Duke"); @@ -782,6 +783,8 @@ int32 CONFIG_ReadSetup(void) SCRIPT_GetNumber(ud.config.scripthandle, "Misc","AngleInterpolation",&ud.angleinterpolation); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "WeaponScale",&ud.weaponscale); + // weapon choices are defaulted in checkcommandline, which may override them if (!CommandWeaponChoice) for (i=0;i<10;i++) @@ -960,6 +963,8 @@ void CONFIG_WriteSetup(void) SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AltHud",ud.althud,false,false); // SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AngleInterpolation",ud.angleinterpolation,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "WeaponScale",ud.weaponscale,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Detail",ud.detail,false,false); #if defined(POLYMOST) && defined(USE_OPENGL) SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLAnisotropy",glanisotropy,false,false); diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index f6753a00e..d4108fd11 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -404,7 +404,7 @@ typedef struct { int runkey_mode,statusbarscale,mouseaiming,weaponswitch,drawweapon; // JBF 20031125 int democams,color,msgdisptime,statusbarmode; int m_noexits,noexits,autovote,automsg,idplayers; - int team, viewbob, weaponsway, althud; + int team, viewbob, weaponsway, althud, weaponscale; int entered_name,screen_tilting,shadows,fta_on,executions,auto_run; int coords,tickrate,levelstats,m_coop,coop,screen_size,lockout,crosshair; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 6affa5324..e18aacd89 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -232,12 +232,12 @@ static inline int sbarxr(int x) return (((320l<<16) - scale(320l<<16,ud.statusbarscale,100)) >> 1) + scale(x<<16,ud.statusbarscale,100); } -static inline int sbary(int y) +inline int sbary(int y) { return ((200l<<16) - scale(200l<<16,ud.statusbarscale,100) + scale(y<<16,ud.statusbarscale,100)); } -static inline int sbarsc(int sc) +inline int sbarsc(int sc) { return scale(sc,ud.statusbarscale,100); } @@ -609,10 +609,10 @@ void getpackets(void) if (l&64) nsyn[i].bits = ((nsyn[i].bits&0x00ffffff)|((int)packbuf[j++])<<24); if (l&128) nsyn[i].horz = (signed char)packbuf[j++]; if (l&256) nsyn[i].extbits = (unsigned char)packbuf[j++]; -/* if (l&256) nsyn[i].extbits = ((nsyn[i].extbits&0xffffff00)|((int)packbuf[j++])); - if (l&512) nsyn[i].extbits = ((nsyn[i].extbits&0xffff00ff)|((int)packbuf[j++])<<8); - if (l&1024) nsyn[i].extbits = ((nsyn[i].extbits&0xff00ffff)|((int)packbuf[j++])<<16); - if (l&2048) nsyn[i].extbits = ((nsyn[i].extbits&0x00ffffff)|((int)packbuf[j++])<<24); */ + /* if (l&256) nsyn[i].extbits = ((nsyn[i].extbits&0xffffff00)|((int)packbuf[j++])); + if (l&512) nsyn[i].extbits = ((nsyn[i].extbits&0xffff00ff)|((int)packbuf[j++])<<8); + if (l&1024) nsyn[i].extbits = ((nsyn[i].extbits&0xff00ffff)|((int)packbuf[j++])<<16); + if (l&2048) nsyn[i].extbits = ((nsyn[i].extbits&0x00ffffff)|((int)packbuf[j++])<<24); */ if (nsyn[i].bits&(1<<26)) g_player[i].playerquitflag = 0; g_player[i].movefifoend++; @@ -657,10 +657,10 @@ void getpackets(void) if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((int)packbuf[j++])<<24); if (k&128) nsyn[other].horz = (signed char)packbuf[j++]; if (k&256) nsyn[other].extbits = (unsigned char)packbuf[j++]; -/* if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((int)packbuf[j++])); - if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((int)packbuf[j++])<<8); - if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((int)packbuf[j++])<<16); - if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((int)packbuf[j++])<<24); */ + /* if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((int)packbuf[j++])); + if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((int)packbuf[j++])<<8); + if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((int)packbuf[j++])<<16); + if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((int)packbuf[j++])<<24); */ g_player[other].movefifoend++; while (j != packbufleng) @@ -708,10 +708,10 @@ void getpackets(void) if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((int)packbuf[j++])<<24); if (k&128) nsyn[other].horz = (signed char)packbuf[j++]; if (k&256) nsyn[other].extbits = (unsigned char)packbuf[j++]; -/* if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((int)packbuf[j++])); - if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((int)packbuf[j++])<<8); - if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((int)packbuf[j++])<<16); - if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((int)packbuf[j++])<<24); */ + /* if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((int)packbuf[j++])); + if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((int)packbuf[j++])<<8); + if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((int)packbuf[j++])<<16); + if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((int)packbuf[j++])<<24); */ g_player[other].movefifoend++; for (i=movesperpacket-1;i>=1;i--) @@ -1161,10 +1161,10 @@ void faketimerhandler(void) // k++; packbuf[++k] = 0; if (nsyn[0].extbits != osyn[0].extbits) packbuf[j++] = nsyn[0].extbits, packbuf[k] |= 1; -/* if ((nsyn[0].extbits^osyn[0].extbits)&0x000000ff) packbuf[j++] = (nsyn[0].extbits&255), packbuf[k] |= 1; - if ((nsyn[0].extbits^osyn[0].extbits)&0x0000ff00) packbuf[j++] = ((nsyn[0].extbits>>8)&255), packbuf[k] |= 2; - if ((nsyn[0].extbits^osyn[0].extbits)&0x00ff0000) packbuf[j++] = ((nsyn[0].extbits>>16)&255), packbuf[k] |= 4; - if ((nsyn[0].extbits^osyn[0].extbits)&0xff000000) packbuf[j++] = ((nsyn[0].extbits>>24)&255), packbuf[k] |= 8; */ + /* if ((nsyn[0].extbits^osyn[0].extbits)&0x000000ff) packbuf[j++] = (nsyn[0].extbits&255), packbuf[k] |= 1; + if ((nsyn[0].extbits^osyn[0].extbits)&0x0000ff00) packbuf[j++] = ((nsyn[0].extbits>>8)&255), packbuf[k] |= 2; + if ((nsyn[0].extbits^osyn[0].extbits)&0x00ff0000) packbuf[j++] = ((nsyn[0].extbits>>16)&255), packbuf[k] |= 4; + if ((nsyn[0].extbits^osyn[0].extbits)&0xff000000) packbuf[j++] = ((nsyn[0].extbits>>24)&255), packbuf[k] |= 8; */ while (g_player[myconnectindex].syncvalhead != syncvaltail) { @@ -1232,10 +1232,10 @@ void faketimerhandler(void) } packbuf[2] = 0; if (nsyn[0].extbits != osyn[0].extbits) packbuf[j++] = nsyn[0].extbits, packbuf[2] |= 1; -/* if ((nsyn[0].extbits^osyn[0].extbits)&0x000000ff) packbuf[j++] = (nsyn[0].extbits&255), packbuf[2] |= 1; - if ((nsyn[0].extbits^osyn[0].extbits)&0x0000ff00) packbuf[j++] = ((nsyn[0].extbits>>8)&255), packbuf[2] |= 2; - if ((nsyn[0].extbits^osyn[0].extbits)&0x00ff0000) packbuf[j++] = ((nsyn[0].extbits>>16)&255), packbuf[2] |= 4; - if ((nsyn[0].extbits^osyn[0].extbits)&0xff000000) packbuf[j++] = ((nsyn[0].extbits>>24)&255), packbuf[2] |= 8; */ + /* if ((nsyn[0].extbits^osyn[0].extbits)&0x000000ff) packbuf[j++] = (nsyn[0].extbits&255), packbuf[2] |= 1; + if ((nsyn[0].extbits^osyn[0].extbits)&0x0000ff00) packbuf[j++] = ((nsyn[0].extbits>>8)&255), packbuf[2] |= 2; + if ((nsyn[0].extbits^osyn[0].extbits)&0x00ff0000) packbuf[j++] = ((nsyn[0].extbits>>16)&255), packbuf[2] |= 4; + if ((nsyn[0].extbits^osyn[0].extbits)&0xff000000) packbuf[j++] = ((nsyn[0].extbits>>24)&255), packbuf[2] |= 8; */ while (g_player[myconnectindex].syncvalhead != syncvaltail) { @@ -11120,8 +11120,8 @@ void app_main(int argc,const char **argv) ud.last_level = -1; if (Bstrcasecmp(ud.rtsname,"DUKE.RTS") == 0 || - Bstrcasecmp(ud.rtsname,"WW2GI.RTS") == 0 || - Bstrcasecmp(ud.rtsname,"NAM.RTS") == 0) + Bstrcasecmp(ud.rtsname,"WW2GI.RTS") == 0 || + Bstrcasecmp(ud.rtsname,"NAM.RTS") == 0) { // ud.last_level is used as a flag here to reset the string to DUKE.RTS after load if (WW2GI) diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 6fbee15d0..24ed9da40 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -914,6 +914,7 @@ const memberlabel_t userdefslabels[]= { "althud", USERDEFS_ALTHUD, 0, 0 }, { "display_bonus_screen", USERDEFS_DISPLAY_BONUS_SCREEN, 0, 0 }, { "show_level_text", USERDEFS_SHOW_LEVEL_TEXT, 0, 0 }, + { "weaponscale", USERDEFS_WEAPONSCALE, 0, 0 }, { "", -1, 0, 0 } // END OF LIST }; diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index c114dc8a7..fb35e551a 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -369,6 +369,7 @@ enum userdefslabels USERDEFS_ALTHUD, USERDEFS_DISPLAY_BONUS_SCREEN, USERDEFS_SHOW_LEVEL_TEXT, + USERDEFS_WEAPONSCALE, USERDEFS_END }; diff --git a/polymer/eduke32/source/gamestructures.c b/polymer/eduke32/source/gamestructures.c index ebe58c337..6a324ae1f 100644 --- a/polymer/eduke32/source/gamestructures.c +++ b/polymer/eduke32/source/gamestructures.c @@ -886,6 +886,15 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) SetGameVarID(lVar2, ud.show_level_text, g_i, g_p); return; + case USERDEFS_WEAPONSCALE: + if (iSet) + { + ud.weaponscale = lValue; + return; + } + SetGameVarID(lVar2, ud.weaponscale, g_i, g_p); + return; + default: return; } diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 2ac76d0cd..ec4e36116 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -2724,6 +2724,7 @@ cheat_for_port_credits: "-", "Screen size", "Status bar size", + "Weapon size", "Show level stats", "-", "Allow walk with autorun", @@ -2734,8 +2735,6 @@ cheat_for_port_credits: "Show framerate", "Demo recording", "-", - "-", - "-", "More...", NULL }; @@ -2752,7 +2751,7 @@ cheat_for_port_credits: io++; } - onbar = (probey == 2 || probey == 3 || probey == 4); + onbar = (probey >= 2 && probey <= 5); x = probesm(c,yy+5,0,io); if (x == -1) @@ -2825,21 +2824,33 @@ cheat_for_port_credits: } break; case 5: + { + int sbs, sbsl; + sbs = sbsl = ud.weaponscale-37; + barsm(d+8,yy+7, &sbs,4,x==io,MENUHIGHLIGHT(io),0); + if (x == io && sbs != sbsl) + { + sbs += 37; + ud.weaponscale = min(100,max(10,sbs)); + } + } + break; + case 6: if (x==io) ud.levelstats = 1-ud.levelstats; modval(0,1,(int *)&ud.levelstats,1,probey==io); mgametextpal(d,yy, ud.levelstats ? "Yes" : "No", MENUHIGHLIGHT(io), 0); break; - case 6: + case 7: if (x==io) ud.runkey_mode = 1-ud.runkey_mode; modval(0,1,(int *)&ud.runkey_mode,1,probey==io); mgametextpal(d,yy, ud.runkey_mode ? "No" : "Yes", MENUHIGHLIGHT(io), 0); break; - case 7: + case 8: if (x==io) ud.shadows = 1-ud.shadows; modval(0,1,(int *)&ud.shadows,1,probey==io); mgametextpal(d,yy, ud.shadows ? "On" : "Off", MENUHIGHLIGHT(io), 0); break; - case 8: + case 9: if (x==io) ud.screen_tilting = 1-ud.screen_tilting; #ifdef POLYMOST if (!ud.screen_tilting) setrollangle(0); @@ -2847,12 +2858,12 @@ cheat_for_port_credits: modval(0,1,(int *)&ud.screen_tilting,1,probey==io); mgametextpal(d,yy, ud.screen_tilting ? "On" : "Off", MENUHIGHLIGHT(io), 0); break; // original had a 'full' option - case 9: + case 10: if (x==io) ud.tickrate = 1-ud.tickrate; modval(0,1,(int *)&ud.tickrate,1,probey==io); mgametextpal(d,yy, ud.tickrate ? "Yes" : "No", MENUHIGHLIGHT(io), 0); break; - case 10: + case 11: if (x==io) { enabled = !((g_player[myconnectindex].ps->gm&MODE_GAME) && ud.m_recstat != 1); @@ -2863,7 +2874,7 @@ cheat_for_port_credits: enabled = 0; mgametextpal(d,yy,ud.m_recstat?((ud.m_recstat && enabled && g_player[myconnectindex].ps->gm&MODE_GAME)?"Running":"On"):"Off",enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE,enabled?0:1); break; - case 11: + case 12: if (x==io) cmenu(201); break; default: @@ -2930,7 +2941,7 @@ cheat_for_port_credits: if (x == -1) { cmenu(200); - probey = 11; + probey = 12; break; } diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 4e1a88a56..178653c90 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -497,6 +497,19 @@ static int osdcmd_setstatusbarscale(const osdfuncparm_t *parm) return OSDCMD_OK; } +static int osdcmd_setweaponscale(const osdfuncparm_t *parm) +{ + if (parm->numparms == 0) + { + OSD_Printf("\"hud_weaponscale\" is \"%d\"\n", ud.weaponscale); + return OSDCMD_SHOWHELP; + } + else if (parm->numparms != 1) return OSDCMD_SHOWHELP; + ud.weaponscale = min(100,max(10,Batol(parm->parms[0]))); + OSD_Printf("hud_weaponscale %d\n", ud.weaponscale); + return OSDCMD_OK; +} + static int osdcmd_spawn(const osdfuncparm_t *parm) { int x=0,y=0,z=0; @@ -1442,6 +1455,7 @@ int registerosdcommands(void) OSD_RegisterFunction("bind","bind : associates a keypress with a string of console input. Type \"bind showkeys\" for a list of keys and \"listsymbols\" for a list of valid console commands.", osdcmd_bind); OSD_RegisterFunction("hud_scale","hud_scale: changes the hud scale", osdcmd_setstatusbarscale); + OSD_RegisterFunction("hud_weaponscale","hud_weaponscale: changes the weapon scale", osdcmd_setweaponscale); OSD_RegisterFunction("crosshairscale","crosshairscale: changes the crosshair scale", osdcmd_setcrosshairscale); OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes crosshair color", osdcmd_crosshaircolor); OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu); diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index a4161ecaa..a2fa475b0 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -2119,12 +2119,30 @@ static int animateaccess(int gs,int snum) return 1; } +#define weapsc(sc) scale(sc,ud.weaponscale,100) + +static void myospalscaled(int x, int y, int tilenum, int shade, int orientation, int p) +{ + int a = 0; + int xoff = 240; + + if (orientation&4) + { + a = 1024; + xoff = 80; + } + + rotatesprite(weapsc((orientation&256)?x:(x<<16))+((xoff-weapsc(xoff))<<16), + weapsc((orientation&256)?y:(y<<16))+((200-weapsc(200))<<16), + weapsc(65536L),a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); +} + static void myospalw(int x, int y, int tilenum, int shade, int orientation, int p) { if (!ud.drawweapon) return; else if (ud.drawweapon == 1) - myospal(x,y,tilenum,shade,orientation,p); + myospalscaled(x,y,tilenum,shade,orientation,p); else if (ud.drawweapon == 2) { switch (g_currentweapon) @@ -3027,17 +3045,17 @@ void getinput(int snum) if (horiz < -MAXHORIZ) horiz = -MAXHORIZ; if (horiz > MAXHORIZ) horiz = MAXHORIZ; - if(apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEFORWARD]) + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEFORWARD]) loc.extbits = BUTTON(gamefunc_Move_Forward); - if(apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEBACKWARD]) + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEBACKWARD]) loc.extbits |= BUTTON(gamefunc_Move_Backward)<<1; - if(apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFELEFT]) + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFELEFT]) loc.extbits |= BUTTON(gamefunc_Strafe_Left)<<2; - if(apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFERIGHT]) + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFERIGHT]) loc.extbits |= BUTTON(gamefunc_Strafe_Right)<<3; - if(apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNLEFT]) + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNLEFT]) loc.extbits |= BUTTON(gamefunc_Turn_Left)<<4; - if(apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNRIGHT]) + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNRIGHT]) loc.extbits |= BUTTON(gamefunc_Turn_Right)<<5; // used for changing team loc.extbits |= (g_player[snum].pteam != g_player[snum].ps->team)<<6;