TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
loadingscreen.cpp
Go to the documentation of this file.
1/***************************************************************************
2
3 file : loadingscreen.cpp
4 created : Sun Feb 25 00:34:46 /etc/localtime 2001
5 copyright : (C) 2000-2026 by Eric Espié, Bernhard Wymann
6 email : berniw@bluewin.ch
7
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
23
24#include <stdlib.h>
25#ifdef WIN32
26#include <windows.h>
27#endif
28#include <tgfclient.h>
29#include <car.h>
30
31static void *menuHandle = NULL;
32#define TEXTLINES 23
33static int rmTextId[TEXTLINES];
34static char *rmTextLines[TEXTLINES] = {0};
35static int rmCurText;
36
37float black[4] = { 0.0, 0.0, 0.0, 0.0 };
38float white[TEXTLINES][4];
39
40
41
42static void rmDeativate(void)
43{
44}
45
46
52void RmLoadingScreenStart(const char *title, const char *bgimg)
53{
54 int i;
55 int y;
56
58 /* Already active */
59 return;
60 }
61
62 if (menuHandle) {
64 }
66
67 GfuiTitleCreate(menuHandle, title, strlen(title));
68
69 /* create TEXTLINES lines of text */
70 for (i = 0, y = 400; i < TEXTLINES; i++, y -= 16) {
71 white[i][0] = white[i][1] = white[i][2] = 1.0;
72 white[i][3] = (float)i * 0.0421 + 0.2;
74 GFUI_ALIGN_HL_VB, 100);
75 if (rmTextLines[i]) {
76 /* free old text */
77 free(rmTextLines[i]);
78 rmTextLines[i] = NULL;
79 }
80 }
81
82 rmCurText = 0;
83
84 if (bgimg) {
86 }
87
90}
91
92
97{
98 if (menuHandle) {
100 menuHandle = 0;
101 // TODO: release rmTextLines here instead of in RmLoadingScreenStart, or both?
102 }
103}
104
105
110void RmLoadingScreenSetText(const char *text)
111{
112 int i, j;
113
114 GfOut("%s\n", text);
115
116 if (menuHandle) {
117 if (text) {
118 if (rmTextLines[rmCurText]) {
119 free(rmTextLines[rmCurText]);
120 }
121 rmTextLines[rmCurText] = strdup(text);
122 rmCurText = (rmCurText + 1) % TEXTLINES;
123 }
124
125 i = rmCurText;
126 j = 0;
127 do {
128 if (rmTextLines[i]) {
130 }
131 j++;
132 i = (i + 1) % TEXTLINES;
133 } while (i != rmCurText);
134
135 GfuiDisplay();
136 }
137}
static Vector y[4]
Definition Convex.cpp:56
void * GfuiScreenCreateExAction(float *bgColor, const tGfuiAction &onActivate, const tGfuiAction &onDeactivate, int mouseAllowed)
Create a screen.
Definition gui.cpp:619
void GfuiLabelSetText(void *scr, int id, const char *text)
Change the text of a label.
Definition guilabel.cpp:193
void GfuiScreenRelease(void *scr)
Release the given screen.
Definition gui.cpp:670
int GfuiTitleCreate(void *scr, const char *text, int maxlen)
Add a Title to the screen.
Definition guilabel.cpp:150
void GfuiScreenAddBgImg(void *scr, const char *filename)
Add an image background to a screen.
Definition gui.cpp:1058
void GfuiDisplay(void)
Draw the active GUI screen and swap the GLUT buffers.
Definition gui.cpp:175
int GfuiLabelCreateEx(void *scr, const char *text, float *fgColor, int font, int x, int y, int align, int maxlen)
Create a new label (extended version).
Definition guilabel.cpp:51
int GfuiScreenIsActive(void *screen)
Tell if the screen is active or not.
Definition gui.cpp:495
void GfuiScreenActivate(void *screen)
Activate a screen and make it current.
Definition gui.cpp:508
void RmLoadingScreenSetText(const char *text)
Set a new line of text on the loading screen.
void RmShutdownLoadingScreen(void)
Shut down loading screen.
void RmLoadingScreenStart(const char *title, const char *bgimg)
Set up loading screen.
static int rmCurText
float black[4]
static int rmTextId[TEXTLINES]
static char * rmTextLines[TEXTLINES]
#define TEXTLINES
static void rmDeativate(void)
void * menuHandle
Definition mainmenu.cpp:30
static float white[4]
Definition racegl.cpp:42
#define GfOut
Definition tgf.h:372
#define GFUI_FONT_MEDIUM_C
Definition tgfclient.h:253
#define GFUI_ALIGN_HL_VB
Definition tgfclient.h:71
std::function< void()> tGfuiAction
Definition tgfclient.h:107