1
0
Fork 0
forked from fte/fteqw
fteqw/quakec/menusys/menu/updates.qc

194 lines
6.8 KiB
C++
Raw Normal View History

#include "../menusys/mitem_grid.qc"
enum : int
{
GPMI_NAME, //name of the package, for use with the pkg command.
GPMI_CATEGORY, //category text
GPMI_TITLE, //name of the package, for showing the user.
GPMI_VERSION, //version info (may have multiple with the same name but different versions)
GPMI_DESCRIPTION, //some blurb
GPMI_LICENSE, //what license its distributed under
GPMI_AUTHOR, //name of the person(s) who created it
GPMI_WEBSITE, //where to contribute/find out more info/etc
GPMI_INSTALLED, //current state
GPMI_ACTION, //desired state
GPMI_AVAILABLE, //whether it may be downloaded or not.
GPMI_FILESIZE, //whether it may be downloaded or not.
Added sys_openfile console command(and menu option) to web and flatpak(via cmake+dbus) builds, to 'install' packages on sandboxed systems a bit more easily. Cmake: Add FTE_WERROR option, defaults to true in debug builds and off in release builds (in case future compilers have issues). Cmake: Pull in libXscreensaver so we don't get interrupted by screensavers when playing demos. Make: Added `make webcl-rel` for a web build without server bloat (eg for sites focused on demo playback. Yes, this means you XantoM). fteqcc: Include the decompiler in fteqcc (non-gui) builds ('-d' arg). fteqcc: Decompiler can now mostly handle hexen2 mods without any unknown opcodes. Allow ezHud and OpenSSL to be compiled as in-engine plugins, potentially for web and windows ports respectively. Web: Fix support for ogg vorbis. Add support for voip. Web: Added basic support for WebXR. QTV: Don't try seeking on unseekable qtv streams. Don't spam when developer 1 is set. QTV: add support for some eztv extensions. MVD: added hack to use ktx's vweps in mvd where mvdsv doesn't bother to record the info. qwfwd: hack around a hack in qwfwd, allowing it to work again. recording: favour qwd in single player, instead of mvd. Protocol: reduce client memory used for precache names. Bump maximum precache counts - some people are just abusive, yes you Orl. hexen2: add enough clientside protocol compat to play the demo included with h2mp. lacks effects. in_xflip: restored this setting. fs_hidesyspaths: new cvar, defaults to enabled so you won't find your username or whatever turning up in screenshots or the like. change it to 0 before debuging stuff eg via 'path'. gl_overbright_models: Added cvar to match QS. netchan: Added MTU determination, we'll no longer fail to connect when routers stupidly drop icmp packets. Win: try a few other versions of xinput too. CSQC: Added a CSQC_GenerateMaterial function, to give the csqc a chance to generate custom materials. MenuQC: Added support for the skeletal objects API.
2024-04-09 17:13:59 +00:00
GPMI_GAMEDIR, //whether it may be downloaded or not.
GPMI_MAPS, //whether it may be downloaded or not.
};
class mitem_updategrid : mitem_grid
{
virtual void(vector pos) item_draw =
{ //make sure we see any updates as they're detected...
__using getpackagemanagerinfo, ftoi;
if (getpackagemanagerinfo(grid_numchildren, GPMI_NAME))
{
grid_numchildren++;
while(getpackagemanagerinfo(grid_numchildren, GPMI_NAME))
grid_numchildren++;
item_resized();
}
super::item_draw(pos);
};
virtual void(vector pos, float idx) grid_draw;
virtual float(vector pos, float scan, float char, float down, float idx) grid_keypress;
// virtual void(float olditem, float newitem) grid_selectionchanged;
};
void(vector pos, float idx) mitem_updategrid::grid_draw =
{
__using getpackagemanagerinfo, ftoi;
string text = getpackagemanagerinfo(idx, GPMI_TITLE);
vector col = item_rgb;
if (item_flags & IF_MFOCUSED && idx == grid_mactive)
col_z = 0;
if (item_flags & IF_KFOCUSED && idx == grid_kactive)
col_x = 0;
string status = getpackagemanagerinfo(idx, GPMI_INSTALLED);
string action = getpackagemanagerinfo(idx, GPMI_ACTION);
if (action == "purge") //delete the thing
action = "^&F4 ";
else if (action=="reinstall") //purge then reinstall(the purge status was explicit at least.)
action = "^&F2P";
else if (action=="user") //install(explcitly by user)
action = "^&F2 ";
else if (action=="auto") //install(to satisfy dependancies)
action = "^&FA ";
else if (action=="disable")
action = "^&FE ";
else if (action=="retain")
action = "^&FE ";
else
action = "^&F4 ";
if (status == "0%" || status == "pending")
{
ui.drawfill(pos, [item_size_x, item_scale], '0 0 0.5', 0.1, 0);
action = status = " ";
}
else if (strstrofs(status, "%")>=0)
{
float frac = stof(status)/100;
ui.drawfill(pos, [item_size_x*frac, item_scale], '0 0 0.5', 0.9, 0);
action = status = " ";
}
else if (status == "corrupt")
status = "^&FE?"; //yellow
else if (status == "enabled")
status = "^&F2 "; //green
else if (status == "present")
status = "^&FE "; //yellow
else
status = "^&F4 "; //red
ui.drawstring(pos, strcat(status, action, "^&F-", text), '1 1 0' * item_scale, col, item_alpha, 0);
};
/*void(float olditem, float newitem) mitem_updategrid::grid_selectionchanged =
{
};
*/float(vector pos, float scan, float char, float down, float idx) mitem_updategrid::grid_keypress =
{
__using getpackagemanagerinfo, ftoi;
string text;
if (!down)
return FALSE;
else if (scan == K_DEL||scan == K_BACKSPACE||scan == K_LEFTARROW)
{
text = getpackagemanagerinfo(idx, GPMI_NAME);
if (!text)
return FALSE;
string action = getpackagemanagerinfo(idx, GPMI_ACTION);
if (action == "purge") //delete the thing
action = "rem";
else if (action=="reinstall") //purge then reinstall(the purge status was explicit at least.)
action = "rem";
else if (action=="user") //install(explcitly by user)
action = "rem";
else if (action=="auto") //install(to satisfy dependancies)
action = "rem";
else
action = "del";
text = strcat("pkg quiet_", action, " \"", text, "\"\n");
localcmd(text);
}
else if (scan == K_RIGHTARROW || scan==K_ENTER || scan == K_MOUSE1)
{
text = getpackagemanagerinfo(idx, GPMI_NAME);
if (!text)
return FALSE;
text = strcat("pkg quiet_add \"", text, "\"\n");
localcmd(text);
}
else
return FALSE;
return TRUE;
};
class menu_updates : mitem_exmenu
{
string filter;
mitem_updategrid grid;
virtual string(string key) get =
{
__using getpackagemanagerinfo, ftoi;
if (key == "info")
{
string text=__NULL__, tmp;
tmp = getpackagemanagerinfo(grid.grid_kactive, GPMI_VERSION); text = strcat(text, "^aVersion:^a ", tmp?:"Unspecified");
tmp = getpackagemanagerinfo(grid.grid_kactive, GPMI_AUTHOR); text = strcat(text, "\n^aAuthor:^a ", tmp?:"Unknown");
tmp = getpackagemanagerinfo(grid.grid_kactive, GPMI_LICENSE); text = strcat(text, "\n^aLicense:^a ", tmp?:"Unknown");
tmp = getpackagemanagerinfo(grid.grid_kactive, GPMI_WEBSITE); text = strcat(text, "\n^aWebsite:^a ", tmp?:"Unknown");
tmp = getpackagemanagerinfo(grid.grid_kactive, GPMI_DESCRIPTION); text = strcat(text, "\n^aDescription:^a ", tmp?:"No description specified");
return text;
}
return super::get(key);
};
};
void(mitem_desktop desktop) M_Menu_Updates =
{
mitem it;
float h = (480+240)/2;
if (!checkbuiltin(getpackagemanagerinfo))
return; //not supported in this engine...
localcmd("pkg update\n");
//create the menu, give it focus, and make sure its displayed over everything else.
menu_updates m = spawn(menu_updates, item_text:_("Updates List"), item_flags:IF_SELECTABLE, item_command:"m_main", frame_stdheight:h);
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();
//draw title art above the options
mitem_pic banner = spawn(mitem_pic, item_text:"gfx/ttl_cstm.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_OWN_MIN, [banner.item_size_x*-0.5, h*-0.5], [banner.item_size_x*0.5, 24]);
//spawn our grid for the actual options. this provides a scrollbar if we have too many items.
m.grid = spawn(mitem_updategrid, item_flags: IF_SELECTABLE, item_scale: 8);
m.add(m.grid, RS_X_MIN_PARENT_MID|RS_Y_MIN_PARENT_MID | RS_X_MAX_PARENT_MID|RS_Y_MAX_PARENT_MID, [-160, h*-0.5+32], [40, h*0.5]);
it = spawn(mitem_label, item_text: "info", item_flags: 0, item_scale: 8);
m.add(it, RS_X_MIN_PARENT_MID|RS_Y_MIN_PARENT_MID | RS_X_MAX_PARENT_MAX|RS_Y_MAX_PARENT_MID, [40, h*-0.5+32], [0, h*0.5-16]);
it = spawn(mitem_button, item_text: "Apply", item_command: "pkg apply\n", item_flags: IF_SELECTABLE, item_scale: 8);
m.add(it, RS_X_MIN_PARENT_MID|RS_Y_MIN_PARENT_MID | RS_X_MAX_PARENT_MAX|RS_Y_MAX_PARENT_MID, [40+1, h*0.5-16+1], [0-1, h*0.5-1]);
//and give us a suitable menu tint too, just because.
addmenuback(m);
};