1
+ #pragma once
1
2
#ifndef SHADER_XRLC_H
2
3
#define SHADER_XRLC_H
3
- #pragma once
4
4
5
5
struct Shader_xrLC
6
6
{
@@ -57,7 +57,7 @@ class Shader_xrLC_LIB
57
57
public:
58
58
void Load (LPCSTR name)
59
59
{
60
- IReader* fs = FS.r_open (name);
60
+ auto fs = FS.r_open (name);
61
61
if (NULL == fs)
62
62
{
63
63
string256 inf;
@@ -77,40 +77,43 @@ class Shader_xrLC_LIB
77
77
}
78
78
bool Save (LPCSTR name)
79
79
{
80
- IWriter* F = FS.w_open (name);
80
+ auto F = FS.w_open (name);
81
81
if (F)
82
82
{
83
83
F->w (&*library.begin (), (u32 )library.size () * sizeof (Shader_xrLC));
84
84
FS.w_close (F);
85
85
return true ;
86
86
}
87
- else
88
- {
89
- return false ;
90
- }
87
+ return false ;
91
88
}
92
89
void Unload () { library.clear (); }
90
+
93
91
u32 GetID (LPCSTR name) const
94
92
{
95
93
for (auto it = library.begin (); it != library.end (); it++)
96
94
if (0 == stricmp (name, it->Name ))
97
95
return u32 (it - library.begin ());
98
96
return u32 (-1 );
99
97
}
98
+
100
99
Shader_xrLC* Get (LPCSTR name)
101
100
{
102
- for (auto it = library. begin (); it != library. end (); it++ )
103
- if (0 == stricmp (name, it-> Name ))
104
- return &(*it) ;
105
- return NULL ;
101
+ for (auto & shader : library)
102
+ if (0 == stricmp (name, shader. Name ))
103
+ return &shader ;
104
+ return nullptr ;
106
105
}
107
- IC Shader_xrLC* Get (int id) { return &library[id]; }
108
- IC const Shader_xrLC* Get (int id) const { return &library[id]; }
106
+
107
+ Shader_xrLC* Get (int id) { return &library[id]; }
108
+
109
+ const Shader_xrLC* Get (int id) const { return &library[id]; }
110
+
109
111
Shader_xrLC* Append (Shader_xrLC* parent = 0 )
110
112
{
111
113
library.push_back (parent ? Shader_xrLC (*parent) : Shader_xrLC ());
112
114
return &library.back ();
113
115
}
116
+
114
117
void Remove (LPCSTR name)
115
118
{
116
119
for (auto it = library.begin (); it != library.end (); it++)
@@ -120,8 +123,11 @@ class Shader_xrLC_LIB
120
123
break ;
121
124
}
122
125
}
126
+
123
127
void Remove (int id) { library.erase (library.begin () + id); }
128
+
124
129
Shader_xrLCVec& Library () { return library; }
130
+
125
131
const Shader_xrLCVec& Library () const { return library; }
126
132
};
127
133
0 commit comments