more loading screen stuff, now shows loading screen for connecting clients with progr...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 4 Apr 2009 15:50:31 +0000 (15:50 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 4 Apr 2009 15:50:31 +0000 (15:50 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8856 d7cf8633-e32d-0410-b094-e92efae38249

cl_parse.c
cl_screen.c
model_shared.c
screen.h

index 28c4dda..d3df386 100644 (file)
@@ -1023,17 +1023,34 @@ void CL_BeginDownloads(qboolean aborteddownload)
        if (cl.loadmodel_current < cl.loadmodel_total)
        {
                // loading models
-
+               if(cl.loadmodel_current == 1)
+               {
+                       // worldmodel counts as 16 models (15 + world model setup), for better progress bar
+                       SCR_PushLoadingScreen(false, "Loading precached models", (cl.loadmodel_total + 15) / (float) (cl.loadmodel_total + cl.loadsound_total + 15));
+                       SCR_BeginLoadingPlaque();
+               }
                for (;cl.loadmodel_current < cl.loadmodel_total;cl.loadmodel_current++)
                {
+                       SCR_PushLoadingScreen(true, cl.model_name[cl.loadmodel_current], (cl.loadmodel_current == 1 ? 15.0 : 1.0) / cl.loadmodel_total);
                        if (cl.model_precache[cl.loadmodel_current] && cl.model_precache[cl.loadmodel_current]->Draw)
+                       {
+                               SCR_PopLoadingScreen(false);
+                               if(cl.loadmodel_current == 1)
+                               {
+                                       SCR_PushLoadingScreen(false, cl.model_name[cl.loadmodel_current], 1.0 / cl.loadmodel_total);
+                                       SCR_PopLoadingScreen(false);
+                               }
                                continue;
+                       }
                        CL_KeepaliveMessage(true);
                        cl.model_precache[cl.loadmodel_current] = Mod_ForName(cl.model_name[cl.loadmodel_current], false, false, cl.model_name[cl.loadmodel_current][0] == '*' ? cl.model_name[1] : NULL);
+                       SCR_PopLoadingScreen(false);
                        if (cl.model_precache[cl.loadmodel_current] && cl.model_precache[cl.loadmodel_current]->Draw && cl.loadmodel_current == 1)
                        {
                                // we now have the worldmodel so we can set up the game world
+                               SCR_PushLoadingScreen(true, "world model setup", 1.0 / cl.loadmodel_total);
                                CL_SetupWorldModel();
+                               SCR_PopLoadingScreen(true);
                                if (!cl.loadfinished && cl_joinbeforedownloadsfinish.integer)
                                {
                                        cl.loadfinished = true;
@@ -1043,23 +1060,29 @@ void CL_BeginDownloads(qboolean aborteddownload)
                                }
                        }
                }
-
+               SCR_PopLoadingScreen(false);
                // finished loading models
        }
 
        if (cl.loadsound_current < cl.loadsound_total)
        {
                // loading sounds
-
+               if(cl.loadsound_current == 1)
+                       SCR_PushLoadingScreen(false, "Loading precached sounds", cl.loadsound_total / (float) (cl.loadmodel_total + cl.loadsound_total + 15));
                for (;cl.loadsound_current < cl.loadsound_total;cl.loadsound_current++)
                {
+                       SCR_PushLoadingScreen(true, cl.sound_name[cl.loadsound_current], 1.0 / cl.loadsound_total);
                        if (cl.sound_precache[cl.loadsound_current] && S_IsSoundPrecached(cl.sound_precache[cl.loadsound_current]))
+                       {
+                               SCR_PopLoadingScreen(false);
                                continue;
+                       }
                        CL_KeepaliveMessage(true);
                        // Don't lock the sfx here, S_ServerSounds already did that
                        cl.sound_precache[cl.loadsound_current] = S_PrecacheSound(cl.sound_name[cl.loadsound_current], false, false);
+                       SCR_PopLoadingScreen(false);
                }
-
+               SCR_PopLoadingScreen(false);
                // finished loading sounds
        }
 
@@ -1169,6 +1192,8 @@ void CL_BeginDownloads(qboolean aborteddownload)
                // finished loading sounds
        }
 
+       SCR_PopLoadingScreen(false);
+
        if (!cl.loadfinished)
        {
                cl.loadfinished = true;
@@ -1189,7 +1214,10 @@ void CL_BeginDownloads_f(void)
        if(cl.loadbegun)
                Con_Printf("cl_begindownloads is only valid once per match\n");
        else
+       {
+               SCR_PushLoadingScreen(false, "Loading precaches", 1);
                CL_BeginDownloads(false);
+       }
 }
 
 void CL_StopDownload(int size, int crc)
index 98fc38f..3da12a2 100644 (file)
@@ -1619,8 +1619,9 @@ typedef struct loadingscreenstack_s
 }
 loadingscreenstack_t;
 static loadingscreenstack_t *loadingscreenstack = NULL;
+static double loadingscreentime;
 
-void SCR_PushLoadingScreen (const char *msg, float len_in_parent)
+void SCR_PushLoadingScreen (qboolean redraw, const char *msg, float len_in_parent)
 {
        loadingscreenstack_t *s = (loadingscreenstack_t *) Z_Malloc(sizeof(loadingscreenstack_t));
        s->prev = loadingscreenstack;
@@ -1632,7 +1633,9 @@ void SCR_PushLoadingScreen (const char *msg, float len_in_parent)
        if(s->prev)
        {
                s->absolute_loading_amount_min = s->prev->absolute_loading_amount_min + s->prev->absolute_loading_amount_len * s->prev->relative_completion;
-               s->absolute_loading_amount_len =                                        s->prev->absolute_loading_amount_len * len_in_parent;
+               s->absolute_loading_amount_len = s->prev->absolute_loading_amount_len * len_in_parent;
+               if(s->absolute_loading_amount_len > s->prev->absolute_loading_amount_min + s->prev->absolute_loading_amount_len - s->absolute_loading_amount_min)
+                       s->absolute_loading_amount_len = s->prev->absolute_loading_amount_min + s->prev->absolute_loading_amount_len - s->absolute_loading_amount_min;
        }
        else
        {
@@ -1640,17 +1643,20 @@ void SCR_PushLoadingScreen (const char *msg, float len_in_parent)
                s->absolute_loading_amount_len = 1;
        }
 
-       SCR_UpdateLoadingScreen(true);
+       if(redraw && realtime == loadingscreentime)
+               SCR_UpdateLoadingScreen(true);
 }
 
-void SCR_PopLoadingScreen ()
+void SCR_PopLoadingScreen (qboolean redraw)
 {
        loadingscreenstack_t *s = loadingscreenstack;
        loadingscreenstack = s->prev;
        if(s->prev)
                s->prev->relative_completion = (s->absolute_loading_amount_min + s->absolute_loading_amount_len - s->prev->absolute_loading_amount_min) / s->prev->absolute_loading_amount_len;
        Z_Free(s);
-       SCR_UpdateLoadingScreen(true);
+
+       if(redraw && realtime == loadingscreentime)
+               SCR_UpdateLoadingScreen(true);
 }
 
 static float SCR_DrawLoadingStack_r(loadingscreenstack_t *s, float y)
@@ -1679,11 +1685,27 @@ static float SCR_DrawLoadingStack_r(loadingscreenstack_t *s, float y)
 static void SCR_DrawLoadingStack()
 {
        float height;
+       float verts[12];
+       float colors[16];
        height = SCR_DrawLoadingStack_r(loadingscreenstack, vid_conheight.integer);
        if(loadingscreenstack)
        {
-               height = 32; // sorry, using the normal one is ugly
-               DrawQ_Fill((vid_conwidth.integer + 2) * loadingscreenstack->absolute_loading_amount_min - 2, vid_conheight.integer - height, 2, height, 1, 0, 0, 1, DRAWFLAG_ADDITIVE);
+               // height = 32; // sorry, using the normal one is ugly
+               //DrawQ_Fill((vid_conwidth.integer + 2) * loadingscreenstack->absolute_loading_amount_min - 2, vid_conheight.integer - height, 2, height, 1, 0, 0, 1, DRAWFLAG_ADDITIVE);
+               GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
+               GL_Color(1, 1, 1, 1);
+               R_Mesh_VertexPointer(verts, 0, 0);
+               R_Mesh_ColorPointer(colors, 0, 0);
+               R_Mesh_ResetTextureState();
+               R_SetupGenericShader(false);
+               verts[2] = verts[5] = verts[8] = verts[11] = 0;
+               verts[0] = verts[9] = (vid_conwidth.integer + 2) * loadingscreenstack->absolute_loading_amount_min - 2;
+               verts[1] = verts[4] = vid_conheight.integer - 32;
+               verts[3] = verts[6] = (vid_conwidth.integer + 2) * loadingscreenstack->absolute_loading_amount_min;
+               verts[7] = verts[10] = vid_conheight.integer;
+               colors[0] = colors[1] = colors[2] = colors[4] = colors[5] = colors[6] = colors[8] = colors[9] = colors[10] = colors[11] = colors[12] = colors[13] = colors[14] = colors[15] = 1;
+               colors[3] = colors[7] = 0;
+               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
        }
 }
 
@@ -1694,6 +1716,8 @@ void SCR_UpdateLoadingScreen (qboolean clear)
        float vertex3f[12];
        float texcoord2f[8];
 
+       loadingscreentime = realtime;
+
        // don't do anything if not initialized yet
        if (vid_hidden || !scr_refresh.integer)
                return;
index 3e48438..e7a7164 100644 (file)
@@ -54,7 +54,7 @@ static void mod_start(void)
        int nummodels = Mem_ExpandableArray_IndexRange(&models);
        dp_model_t *mod;
 
-       SCR_PushLoadingScreen("Loading models", 1.0);
+       SCR_PushLoadingScreen(false, "Loading models", 1.0);
        count = 0;
        for (i = 0;i < nummodels;i++)
                if ((mod = (dp_model_t*) Mem_ExpandableArray_RecordAtIndex(&models, i)) && mod->name[0] && mod->name[0] != '*')
@@ -64,11 +64,11 @@ static void mod_start(void)
                if ((mod = (dp_model_t*) Mem_ExpandableArray_RecordAtIndex(&models, i)) && mod->name[0] && mod->name[0] != '*')
                        if (mod->used)
                        {
-                               SCR_PushLoadingScreen(mod->name, 1.0 / count);
+                               SCR_PushLoadingScreen(true, mod->name, 1.0 / count);
                                Mod_LoadModel(mod, true, false);
-                               SCR_PopLoadingScreen();
+                               SCR_PopLoadingScreen(false);
                        }
-       SCR_PopLoadingScreen();
+       SCR_PopLoadingScreen(false);
 }
 
 static void mod_shutdown(void)
@@ -276,7 +276,7 @@ dp_model_t *Mod_LoadModel(dp_model_t *mod, qboolean crash, qboolean checkdisk)
        if (developer_loading.integer)
                Con_Printf("loading model %s\n", mod->name);
        
-       SCR_PushLoadingScreen(mod->name, 1);
+       SCR_PushLoadingScreen(true, mod->name, 1);
 
        // LordHavoc: unload the existing model in this slot (if there is one)
        if (mod->loaded || mod->mempool)
@@ -339,7 +339,7 @@ dp_model_t *Mod_LoadModel(dp_model_t *mod, qboolean crash, qboolean checkdisk)
                Con_Printf ("Mod_LoadModel: %s not found\n", mod->name);
        }
 
-       SCR_PopLoadingScreen();
+       SCR_PopLoadingScreen(false);
 
        return mod;
 }
@@ -443,7 +443,7 @@ void Mod_Reload(void)
        int nummodels = Mem_ExpandableArray_IndexRange(&models);
        dp_model_t *mod;
 
-       SCR_PushLoadingScreen("Reloading models", 1.0);
+       SCR_PushLoadingScreen(false, "Reloading models", 1.0);
        count = 0;
        for (i = 0;i < nummodels;i++)
                if ((mod = (dp_model_t *) Mem_ExpandableArray_RecordAtIndex(&models, i)) && mod->name[0] && mod->name[0] != '*' && mod->used)
@@ -451,11 +451,11 @@ void Mod_Reload(void)
        for (i = 0;i < nummodels;i++)
                if ((mod = (dp_model_t *) Mem_ExpandableArray_RecordAtIndex(&models, i)) && mod->name[0] && mod->name[0] != '*' && mod->used)
                {
-                       SCR_PushLoadingScreen(mod->name, 1.0 / count);
+                       SCR_PushLoadingScreen(true, mod->name, 1.0 / count);
                        Mod_LoadModel(mod, true, true);
-                       SCR_PopLoadingScreen();
+                       SCR_PopLoadingScreen(false);
                }
-       SCR_PopLoadingScreen();
+       SCR_PopLoadingScreen(false);
 }
 
 unsigned char *mod_base;
index db78cbe..ab807cb 100644 (file)
--- a/screen.h
+++ b/screen.h
@@ -32,8 +32,8 @@ void SCR_BeginLoadingPlaque (void);
 void SCR_UpdateLoadingScreen(qboolean clear);
 
 // pushes an item on the loading screen
-void SCR_PushLoadingScreen (const char *msg, float len_in_parent);
-void SCR_PopLoadingScreen ();
+void SCR_PushLoadingScreen (qboolean redraw, const char *msg, float len_in_parent);
+void SCR_PopLoadingScreen (qboolean redraw);
 
 extern float scr_con_current; // current height of displayed console