TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
fileselect.cpp
Go to the documentation of this file.
1/***************************************************************************
2
3 file : fileselect.cpp
4 created : Sun Feb 16 13:09:23 CET 2003
5 copyright : (C) 2003-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
25#include <stdlib.h>
26#include <stdio.h>
27#include <sys/stat.h>
28#ifdef WIN32
29#include <windows.h>
30#endif
31#include <tgfclient.h>
32#include <racescreens.h>
33
34static void *scrHandle = NULL;
35static int fileScrollList;
37static tFList *FileList = NULL;
39
40
41static void rmActivate(void)
42{
43}
44
45
50
51
52static void rmSelect(void)
53{
54 if (FileList) {
55 rmFs->select(FileSelected->name);
56 GfDirFreeList(FileList, NULL, true, false);
57 FileList = NULL;
58 } else {
59 rmFs->select(NULL);
60 }
61}
62
63static void rmDeactivate(void)
64{
65 if (FileList) {
66 GfDirFreeList(FileList, NULL, true, false);
67 FileList = NULL;
68 }
69 GfuiScreenActivate(rmFs->prevScreen);
70}
71
72
79void RmFileSelect(void *vs)
80{
81 tFList *FileCur;
82
83 rmFs = (tRmFileSelect*)vs;
84
85 if (scrHandle) {
87 }
89 GfuiScreenAddBgImg(scrHandle, "data/img/splash-filesel.png");
90 GfuiTitleCreate(scrHandle, rmFs->title, 0);
91
92 /* Scroll List containing the File list */
94 400, 310, GFUI_SB_RIGHT, rmClickOnFile);
95
96 FileList = GfDirGetList(rmFs->path);
97 if (FileList == NULL) {
98 GfuiScreenActivate(rmFs->prevScreen);
99 return;
100 }
101
103 FileCur = FileList;
104 do {
105 FileCur = FileCur->next;
106 GfuiScrollListInsertElement(scrHandle, fileScrollList, FileCur->name, 1000, (void*)FileCur);
107 } while (FileCur != FileList);
108
109 /* Bottom buttons */
112
115
116 /* Default menu keyboard actions */
119}
static void * scrHandle
static tFList * FileList
static void rmClickOnFile(void)
static tFList * FileSelected
static int fileScrollList
static void rmSelect(void)
static void rmDeactivate(void)
static tRmFileSelect * rmFs
static void rmActivate(void)
void GfDirFreeList(tFList *list, tfDirfreeUserData freeUserData, bool freename, bool freedispname)
Free a directory list.
Definition directory.cpp:75
tFList * GfDirGetList(const char *dir)
Get the list of files of a given directory.
Definition directory.cpp:43
void * GfuiScreenCreateExAction(float *bgColor, const tGfuiAction &onActivate, const tGfuiAction &onDeactivate, int mouseAllowed)
Create a screen.
Definition gui.cpp:619
void GfuiMenuDefaultKeysAdd(void *scr)
Add the default menu keyboard callback to a screen.
Definition guimenu.cpp:56
void GfuiScreenRelease(void *scr)
Release the given screen.
Definition gui.cpp:670
int GfuiScrollListCreateAction(void *scr, int font, int x, int y, int align, int width, int height, int scrollBarPos, const tGfuiAction &onSelect)
Create a new scroll list.
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
int GfuiScrollListInsertElement(void *scr, int Id, char *element, int index, void *userData)
Insert an element in a scroll list.
char * GfuiScrollListGetSelectedElement(void *scr, int Id, void **userData)
Get the selected element from the scroll list.
void GfuiScreenActivate(void *screen)
Activate a screen and make it current.
Definition gui.cpp:508
int GfuiButtonCreateAction(void *scr, const char *text, int font, int x, int y, int width, int align, int mouse, const tGfuiAction &onPush, const tGfuiAction &onFocus, const tGfuiAction &onFocusLost)
Add a button to a screen.
void RmFileSelect(void *vs)
File selection.
struct FList * next
Next entry.
Definition tgf.h:230
char * name
File name.
Definition tgf.h:232
Structure for file selection.
Definition racescreens.h:76
struct FList tFList
List of (DLL) files for a Directory.
#define GFUI_FONT_LARGE
Definition tgfclient.h:248
#define GFUI_FONT_MEDIUM_C
Definition tgfclient.h:253
#define GFUI_MOUSE_UP
Definition tgfclient.h:82
std::function< void()> tGfuiAction
Definition tgfclient.h:107
#define GFUI_ALIGN_HC_VB
Definition tgfclient.h:74
#define GFUI_SB_RIGHT
Definition tgfclient.h:91