fteqw/quakec/menusys/menu/loadsave.qc

124 lines
3.5 KiB
C++
Raw Normal View History

mvd: cl_autotrack_team cvar locks autotrack to a specific team. getting the team name to match can still be problematic when it contains non-ascii chars however. qw: fix recording mid-map. q2: add support for recording demos on q2 servers. q: fix setattachment not using the correct orientations. q2: now supports splitscreen, as well as increased model and sound limits. cl: fix crosshair not appearing in splitscreen. cl: splitscreen clients now get their own colour tints (like the bf command) snd: tweak audio to be a bit more usable in splitscreen by default. cl: added con_logcenterprint cvar, for shoving a copy of centerprints onto the console. by default only appears in single player. qc: add checkbuiltin builtin. for all those #0 builtins without their own extension name. gl: fix r_dynamic -1 bug that was painfully visible in AD. mdl: validate per-frame bounds of mdl files (stuff that would crash software renderers). sv: fix -port or +sv_port commandline args to override the port correctly. win: attempt to cope with windows symlinks enumerating with the wrong filesizes. gl: fix skyboxes not appearing properly. gl: fix sprite alpha/edge issue resulting in some invisible sprites in AD. gl: fix screenshot_mega, in combination with r_projection. yay for HUGE panoramic screenshots. q2: fix replacement textures issue. qw: fix download demonum/X issue, both in client and server. qw: fix multicast dimensions not always being honoured properly. nq: fix starting angles sometimes being wrong. menusys: I'm finally uploading my menusys library, plus example mod, which I'll now be providing like csaddon is. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4997 fc73d0e0-1445-4013-8a0c-d673dee63da5
2016-01-18 05:22:07 +00:00
#ifndef LOADSAVE_QC
#define LOADSAVE_QC
//I'm feeling lazy, so I'm going to only provide X slots, like quake's menu.
#define NUMSAVESLOTS 10
float selectedsaveslot;
/*
class mitem_savescreeny : mitem
{
virtual void(vector pos) item_draw =
{
string s = sprintf("saves/s%g/screeny.png", selectedsaveslot);
if not(whichpack(s))
if (drawgetimagesize(s) != '0 0 0')
ui.drawpic(pos, s, item_size, item_rgb, item_alpha, 0);
};
};
*/
class mitem_saveoption : mitem_text
{
float slot;
float mode;
virtual void(vector pos) item_draw =
{
//some sort of pulsing if its active.
if (selectedsaveslot == slot)
ui.drawfill(pos, item_size, '1 0 0', sin(cltime)*0.125+0.150, 0);
float w = stringwidth(item_text, TRUE, '1 1 0'*item_scale);
ui.drawstring(pos + [(item_size_x-w)/2, 0], item_text, '1 1 0' * item_scale, menuitem_textcolour(this), item_alpha, 0);
};
virtual float(vector pos, float scan, float char, float down) item_keypress =
{
if (!down)
return FALSE;
if (scan == K_ENTER || (scan == K_MOUSE1 && mouseinbox(pos, this.item_size)))
{
if (selectedsaveslot == slot)
{
switch(mode)
{
case 0:
break; //can't load a slot which is empty.
case 1:
localcmd(sprintf("m_pop;load s%g\n", slot));
break;
case 2:
//FTE has a savegame_legacy command if you want compatibility with other engines.
localcmd(sprintf("m_pop;wait;echo \"%s\";save s%g\n", _("Saving Game"), slot));
//localcmd(sprintf("m_pop;wait;screenshot saves/s%g/screeny.png;echo \"%s\";save s%g\n", slot, _("Saving Game"), slot));
break;
}
}
selectedsaveslot = slot;
return TRUE;
}
return FALSE;
};
};
static string(string savename) scansave =
{
string l;
float f = fopen(sprintf("saves/%s/info.fsv", savename), FILE_READ);
if (f < 0)
f = fopen(sprintf("%s.sav", savename), FILE_READ);
if (f < 0)
return __NULL__; //weird
fgets(f); //should be the version
l = fgets(f); //description
if (l)
l = strreplace("_", " ", l);
fclose(f);
return l;
};
void(mitem_desktop desktop, float mode) M_LoadSave =
{
mitem_exmenu m = spawn(mitem_exmenu, item_text:"Load/Save", item_flags:IF_SELECTABLE, item_command:"m_main");
desktop.add(m, RS_X_MIN_PARENT_MIN|RS_Y_MIN_PARENT_MIN | RS_X_MAX_PARENT_MAX|RS_Y_MAX_PARENT_MAX, '0 0', '0 0');
desktop.item_focuschange(m, IF_KFOCUSED);
m.totop();
string l;
float i;
float smode;
float pos = NUMSAVESLOTS*16/-2;
mitem_pic banner = spawn(mitem_pic, item_text:((mode==2)?"gfx/p_save.lmp":"gfx/p_load.lmp"), item_size_y:24, item_flags:IF_CENTERALIGN);
m.add(banner, RS_X_MIN_PARENT_MID|RS_Y_MIN_PARENT_MID | RS_X_MAX_PARENT_MID|RS_Y_MAX_PARENT_MID, [(banner.item_size_x)*-0.5, pos-32], [(banner.item_size_x)*0.5, pos-8]);
for (i = 0; i < NUMSAVESLOTS; i++)
{
l = scansave(sprintf("s%g", i));
smode = mode;
if (l=="")
{
l = "Empty Slot";
if (mode==1)
smode = 0;
}
m.addm(spawn (mitem_saveoption, item_scale:16, slot:i, mode:smode, item_text:l), [-320, pos+i*16], [320, pos+(i+1)*16]);
}
// m.addm(spawn (mitem_savescreeny), [-320, -240], [320, 240]);
addmenuback(m);
};
void(mitem_desktop desktop) M_Load =
{
M_LoadSave(desktop, 1);
};
void(mitem_desktop desktop) M_Save =
{
if (!(isserver() || dp_workarounds))
M_Main(desktop); //can't save when not connected. this should be rare, but can if you use the console or the main menu options are stale.
else
M_LoadSave(desktop, 2);
};
#endif