File confec.cpp changed (mode: 100644) (index 147c648..2ea12a9) |
... |
... |
std::string language = "en"; |
457 |
457 |
// Whitelist these languages. Generally, every game should support these. |
// Whitelist these languages. Generally, every game should support these. |
458 |
458 |
std::vector<std::string> language_whitelist = { "en", "zh" }; |
std::vector<std::string> language_whitelist = { "en", "zh" }; |
459 |
459 |
|
|
|
460 |
|
// Use these mods. |
|
461 |
|
std::vector<std::string> mod_paths = {}; |
|
462 |
|
|
460 |
463 |
bool recipes_display = false, trading_display = false, |
bool recipes_display = false, trading_display = false, |
461 |
464 |
sequencer_display = false, cake_display = false, |
sequencer_display = false, cake_display = false, |
462 |
465 |
settings_display = false, character_select_display = false; |
settings_display = false, character_select_display = false; |
|
... |
... |
int main( int argc, char* argv[] ){ |
917 |
920 |
|
|
918 |
921 |
for( int i = 1; i < argc; i++ ){ |
for( int i = 1; i < argc; i++ ){ |
919 |
922 |
std::string arg( argv[i] ); |
std::string arg( argv[i] ); |
920 |
|
if( arg.length() >= 2 && arg.substr( 0, 2 ) == "--" ){ |
|
921 |
|
if( arg == "--window" ){ |
|
|
923 |
|
if( arg.length() >= 2 && arg[0] == '-' ){ |
|
924 |
|
if( arg.length() >= 3 && arg.substr( 0, 2 ) == "-m" ){ |
|
925 |
|
// Push the mod path to the front of the vector. |
|
926 |
|
// This gives it a higher priority than other mod paths, |
|
927 |
|
// such that later -m parameters override earlier -m |
|
928 |
|
// parameters. |
|
929 |
|
mod_paths.insert( mod_paths.begin(), arg.substr( 2 ) ); |
|
930 |
|
printf( "Using mod: %s\n", mod_paths[0].c_str() ); |
|
931 |
|
}else if( arg == "--window" ){ |
922 |
932 |
windowed_mode = true; |
windowed_mode = true; |
923 |
933 |
printf( "Starting in windowed mode.\n" ); |
printf( "Starting in windowed mode.\n" ); |
924 |
934 |
}else{ |
}else{ |
925 |
935 |
fprintf( |
fprintf( |
926 |
936 |
stderr, |
stderr, |
927 |
937 |
"Unrecognized argument. Valid arguments are:\n%s\n", |
"Unrecognized argument. Valid arguments are:\n%s\n", |
928 |
|
"--window" |
|
|
938 |
|
"-mModPath --window" |
929 |
939 |
); |
); |
930 |
940 |
} |
} |
931 |
941 |
}else{ |
}else{ |
|
... |
... |
int main( int argc, char* argv[] ){ |
1355 |
1365 |
FILE *FileOpen( const char* filename, const char* modes ){ |
FILE *FileOpen( const char* filename, const char* modes ){ |
1356 |
1366 |
// Check if filename starts with the base data path. |
// Check if filename starts with the base data path. |
1357 |
1367 |
std::string str_file = filename, str_data = data_path + "/"; |
std::string str_file = filename, str_data = data_path + "/"; |
1358 |
|
if( str_file.length() >= str_data.length() |
|
|
1368 |
|
if( str_file.length() > str_data.length() |
1359 |
1369 |
&& str_file.substr( 0, str_data.length() ) == str_data ){ |
&& str_file.substr( 0, str_data.length() ) == str_data ){ |
1360 |
|
// TODO: String replacement and iterate through mod paths. |
|
|
1370 |
|
// Iterate through mod paths. |
|
1371 |
|
std::string suffix = str_file.substr( str_data.length() ); |
|
1372 |
|
for( std::string &path : mod_paths ){ |
|
1373 |
|
// Return the pointer to the first matching file. |
|
1374 |
|
str_file = path + "/" + suffix; |
|
1375 |
|
FILE *result = fopen( str_file.c_str(), modes ); |
|
1376 |
|
if( result ) return result; |
|
1377 |
|
} |
1361 |
1378 |
} |
} |
1362 |
1379 |
// Fall back to open the path specified. |
// Fall back to open the path specified. |
1363 |
1380 |
return fopen( filename, modes ); |
return fopen( filename, modes ); |
File include/fworld.h changed (mode: 100755) (index ede7752..37206c5) |
... |
... |
fgl::Texture World::getTexture( std::string basePath, std::string imageName, boo |
630 |
630 |
#ifdef STBI_INCLUDE_STB_IMAGE_H |
#ifdef STBI_INCLUDE_STB_IMAGE_H |
631 |
631 |
// Load the image from the base path but only record the image's canonical name. |
// Load the image from the base path but only record the image's canonical name. |
632 |
632 |
std::string fileName = basePath + "/" + imageName; |
std::string fileName = basePath + "/" + imageName; |
633 |
|
int imgWidth, imgHeight, imgChannels; |
|
634 |
|
unsigned char *imgData = stbi_load( fileName.c_str(), &imgWidth, &imgHeight, &imgChannels, 0 ); |
|
|
633 |
|
int imgWidth = 0, imgHeight = 0, imgChannels = 0; |
|
634 |
|
unsigned char *imgData = nullptr; |
|
635 |
|
FILE *file = FileOpen( fileName.c_str(), "rb" ); |
|
636 |
|
if( file ){ |
|
637 |
|
imgData = stbi_load_from_file( file, &imgWidth, &imgHeight, &imgChannels, 0 ); |
|
638 |
|
fclose( file ); |
|
639 |
|
} |
635 |
640 |
fgl::Texture imgTexture = fgl::loadTexture( imgData, imgWidth, imgHeight, imgChannels, false, filter ); |
fgl::Texture imgTexture = fgl::loadTexture( imgData, imgWidth, imgHeight, imgChannels, false, filter ); |
636 |
641 |
stbi_image_free( imgData ); |
stbi_image_free( imgData ); |
637 |
642 |
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); |
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); |