File confec.cpp changed (mode: 100644) (index d3fc62a..4a393ea) |
... |
... |
std::vector<Image> foregrounds; |
196 |
196 |
|
|
197 |
197 |
int bgIndex = -1, fgIndex = -1, choiceIndex = -1; |
int bgIndex = -1, fgIndex = -1, choiceIndex = -1; |
198 |
198 |
|
|
|
199 |
|
// Get the index to the specified background image, or -1 if failure. |
199 |
200 |
int findBackground( std::string imgName ){ |
int findBackground( std::string imgName ){ |
200 |
201 |
if( imgName.length() > 0 ){ |
if( imgName.length() > 0 ){ |
201 |
202 |
for( int i = 0; i < (int)backgrounds.size(); i++ ){ |
for( int i = 0; i < (int)backgrounds.size(); i++ ){ |
|
... |
... |
int findBackground( std::string imgName ){ |
207 |
208 |
return -1; |
return -1; |
208 |
209 |
} |
} |
209 |
210 |
|
|
|
211 |
|
// Get the index to the specified foreground image, or -1 if failure. |
210 |
212 |
int findForeground( std::string imgName ){ |
int findForeground( std::string imgName ){ |
211 |
213 |
if( imgName.length() > 0 ){ |
if( imgName.length() > 0 ){ |
212 |
214 |
for( int i = 0; i < (int)foregrounds.size(); i++ ){ |
for( int i = 0; i < (int)foregrounds.size(); i++ ){ |
|
... |
... |
int findForeground( std::string imgName ){ |
218 |
220 |
return -1; |
return -1; |
219 |
221 |
} |
} |
220 |
222 |
|
|
|
223 |
|
// Remove all loaded backgrounds and foregrounds from video memory. |
|
224 |
|
// These images are loaded from disk again the next time they are used. |
|
225 |
|
void freeImages(){ |
|
226 |
|
for( auto &img : backgrounds ){ |
|
227 |
|
fgl::freeTexture( img.imgTexture ); |
|
228 |
|
} |
|
229 |
|
backgrounds = {}; |
|
230 |
|
for( auto &img : foregrounds ){ |
|
231 |
|
fgl::freeTexture( img.imgTexture ); |
|
232 |
|
} |
|
233 |
|
foregrounds = {}; |
|
234 |
|
} |
|
235 |
|
|
221 |
236 |
// Global sound volume. |
// Global sound volume. |
222 |
237 |
float global_volume = 1.0f; |
float global_volume = 1.0f; |
223 |
238 |
|
|
|
... |
... |
int main( int argc, char* argv[] ){ |
1170 |
1185 |
// Error. The item does not fit in the player's inventory. |
// Error. The item does not fit in the player's inventory. |
1171 |
1186 |
return -2.0; |
return -2.0; |
1172 |
1187 |
} |
} |
|
1188 |
|
if( param.length() >= 16 |
|
1189 |
|
&& param.substr( 0, 9 ) == "ANIMATION" ){ |
|
1190 |
|
// Layer. |
|
1191 |
|
bool is_foreground; |
|
1192 |
|
if( param.substr( 10, 2 ) == "fg" ){ |
|
1193 |
|
is_foreground = true; |
|
1194 |
|
}else if( param.substr( 10, 2 ) == "bg" ){ |
|
1195 |
|
is_foreground = false; |
|
1196 |
|
}else{ |
|
1197 |
|
return 0.0; |
|
1198 |
|
} |
|
1199 |
|
size_t space_at = param.find_first_of( 14, ' ' ); |
|
1200 |
|
if( space_at == std::string::npos |
|
1201 |
|
|| space_at == param.length() - 1 ){ |
|
1202 |
|
return 0.0; |
|
1203 |
|
} |
|
1204 |
|
// Frames per second. |
|
1205 |
|
double f = |
|
1206 |
|
world.safeStold( param.substr( 13, space_at - 13 ) ); |
|
1207 |
|
f = std::min( std::max( f, 0.1 ), 30.0 ); |
|
1208 |
|
// Directory containing frame sequence. |
|
1209 |
|
std::string dir_name = param.substr( space_at + 1 ); |
|
1210 |
|
std::string dir_check = |
|
1211 |
|
data_path + ( is_foreground ? "/fg/" : "/bg/" ) + dir_name; |
|
1212 |
|
// TODO: Check directory for files, load files. |
|
1213 |
|
// Half of conservative VRAM = 64 MB = 24 frames at 1280x533 |
|
1214 |
|
// https://stackoverflow.com/questions/8149569/scan-a-directory-to-find-files-in-c |
|
1215 |
|
//freeImages(); |
|
1216 |
|
// Load stuff here. |
|
1217 |
|
return 0.0; |
|
1218 |
|
} |
1173 |
1219 |
if( param.length() >= 9 |
if( param.length() >= 9 |
1174 |
1220 |
&& param.substr( 0, 9 ) == "SEQUENCER" ){ |
&& param.substr( 0, 9 ) == "SEQUENCER" ){ |
1175 |
1221 |
BeginSequencer( param.length() > 10 ? param.substr( 10 ) : "" ); |
BeginSequencer( param.length() > 10 ? param.substr( 10 ) : "" ); |