From 55bc341b6107299f9b5b9b285277d2635dc8bd30 Mon Sep 17 00:00:00 2001 From: TimePath Date: Thu, 3 Sep 2015 12:03:48 +1000 Subject: [PATCH] MENUQC loading screen --- qcsrc/menu/classes.inc | 2 ++ qcsrc/menu/menu.qc | 34 ++++++++++++++++++++++++++++- qcsrc/menu/menu.qh | 1 + qcsrc/menu/xonotic/dialog_tip.qc | 25 +++++++++++++++++++++ qcsrc/menu/xonotic/loadingwindow.qc | 33 ++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 qcsrc/menu/xonotic/dialog_tip.qc create mode 100644 qcsrc/menu/xonotic/loadingwindow.qc diff --git a/qcsrc/menu/classes.inc b/qcsrc/menu/classes.inc index 08563a118..a10476ab7 100644 --- a/qcsrc/menu/classes.inc +++ b/qcsrc/menu/classes.inc @@ -101,12 +101,14 @@ #include "xonotic/dialog_singleplayer.qc" #include "xonotic/dialog_singleplayer_winner.qc" #include "xonotic/dialog_teamselect.qc" +#include "xonotic/dialog_tip.qc" #include "xonotic/gametypelist.qc" #include "xonotic/image.qc" #include "xonotic/inputbox.qc" #include "xonotic/keybinder.qc" #include "xonotic/languagelist.qc" #include "xonotic/listbox.qc" +#include "xonotic/loadingwindow.qc" #include "xonotic/mainwindow.qc" #include "xonotic/maplist.qc" #include "xonotic/nexposee.qc" diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 89966dde1..225de873e 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -145,6 +145,7 @@ void UpdateConWidthHeight(float w, float h, float p) { draw_reset_cropped(); main.resizeNotify(main, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight); + loading.resizeNotify(loading, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight); } } else @@ -216,10 +217,13 @@ void m_init_delayed() loadTooltips(); anim = NEW(AnimHost); main = NEW(MainWindow); main.configureMainWindow(main); + loading = NEW(LoadingWindow); unloadTooltips(); main.resizeNotify(main, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight); main.focused = 1; + loading.resizeNotify(loading, '0 0 0', eX * conwidth + eY * conheight, '0 0 0', eX * conwidth + eY * conheight); + loading.focused = true; menuShiftState = 0; menuMousePos = '0.5 0.5 0'; @@ -677,10 +681,11 @@ void m_tooltip(vector pos) } } +float realFrametime; + void m_draw(float width, float height) { float t; - float realFrametime; m_gamestatus(); @@ -1026,3 +1031,30 @@ void m_play_click_sound(string soundfile) if(cvar("menu_sounds")) localsound(soundfile); } + +void m_loading(bool signingon) +{ + if (!menuInitialized) return; + + static float fadetime = 2; + static float a; + a = bound(0, a - 1 / fadetime * realFrametime, 1); + + if (!(gamestatus & GAME_CONNECTED)) return; + if (signingon) a = 1; + cvar_set("scr_loadingscreen_scale", "0"); + if (a) { + drawfill('0 0 0', eX * realconwidth + eY * realconheight, '0 0 0', a, DRAWFLAG_NORMAL); + string s = "gfx/loading"; + string mapshot = cvar_string("cl_worldnamenoextension"); + if (mapshot != "" && precache_pic(mapshot)) s = mapshot; + drawpic('0 0 0', s, eX * realconwidth + eY * realconheight, '1 1 1', a, DRAWFLAG_NORMAL); + + float _draw_alpha = draw_alpha; + draw_alpha = a; + loading.draw(loading); + draw_alpha = _draw_alpha; + } else { + cvar_set("cl_worldnamenoextension", ""); + } +} diff --git a/qcsrc/menu/menu.qh b/qcsrc/menu/menu.qh index 0ece40c88..f12fc0c99 100644 --- a/qcsrc/menu/menu.qh +++ b/qcsrc/menu/menu.qh @@ -31,6 +31,7 @@ float time; entity anim; entity main; +entity loading; void m_hide(); void m_display(); void m_goto(string name); diff --git a/qcsrc/menu/xonotic/dialog_tip.qc b/qcsrc/menu/xonotic/dialog_tip.qc new file mode 100644 index 000000000..93c6d777d --- /dev/null +++ b/qcsrc/menu/xonotic/dialog_tip.qc @@ -0,0 +1,25 @@ +#ifndef DIALOG_TIP_H +#define DIALOG_TIP_H +CLASS(XonoticTipDialog, XonoticDialog) + METHOD(XonoticTipDialog, fill, void(entity)); + ATTRIB(XonoticTipDialog, title, string, _("Tip")) + ATTRIB(XonoticTipDialog, color, vector, SKINCOLOR_DIALOG_FIRSTRUN) + ATTRIB(XonoticTipDialog, intendedWidth, float, 0.7) + ATTRIB(XonoticTipDialog, rows, float, 2) + ATTRIB(XonoticTipDialog, columns, float, 2) + ATTRIB(XonoticTipDialog, name, string, "Tip") + + ATTRIB(XonoticTipDialog, closable, float, 0) + +ENDCLASS(XonoticTipDialog) +#endif + +#ifdef IMPLEMENTATION +void XonoticTipDialog_fill(entity this) +{ + entity e; + this.TR(this); + this.TD(this, 2, 2, e = makeXonoticTextLabel(0, "Loading")); + e.allowWrap = 1; +} +#endif diff --git a/qcsrc/menu/xonotic/loadingwindow.qc b/qcsrc/menu/xonotic/loadingwindow.qc new file mode 100644 index 000000000..9bdfbf3f8 --- /dev/null +++ b/qcsrc/menu/xonotic/loadingwindow.qc @@ -0,0 +1,33 @@ +#ifndef LOADINGWINDOW_H +#define LOADINGWINDOW_H +CLASS(LoadingWindow, ModalController) + METHOD(LoadingWindow, configureLoadingWindow, void(entity)); + METHOD(LoadingWindow, draw, void(entity)); + ATTRIB(LoadingWindow, tipDialog, entity, NULL) + ATTRIB(LoadingWindow, fadedAlpha, float, SKINALPHA_BEHIND) + ATTRIB(LoadingWindow, dialogToShow, entity, NULL) + INIT(LoadingWindow) { + entity e; + + this.tipDialog = e = NEW(XonoticTipDialog); + e.configureDialog(e); + this.addItemCentered(this, e, e.intendedWidth * eX + e.intendedHeight * eY, SKINALPHAS_MAINMENU_z); + + this.dialogToShow = this.tipDialog; + } +ENDCLASS(LoadingWindow) +#endif + +#ifdef IMPLEMENTATION +void LoadingWindow_draw(entity this) +{ + super.draw(this); + + if (this.dialogToShow) + { + DialogOpenButton_Click_withCoords(world, this.dialogToShow, '0 0 0', eX * conwidth + eY * conheight); + this.dialogToShow = NULL; + } +} + +#endif -- 2.39.2