summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorPetr Mrázek2011-08-07 04:28:51 +0000
committerPetr Mrázek2011-08-07 04:28:51 +0000
commit9c99824a023a959bb9ff908b2f434e02b8289351 (patch)
tree609ee50e778bae6b2eb10f68bf36e8b96752f3e5 /main.cpp
parent4064cf25797462fc6ac61f578b7e4b6bd31bf6b6 (diff)
downloadstonesense-9c99824a023a959bb9ff908b2f434e02b8289351.tar.gz
stonesense-9c99824a023a959bb9ff908b2f434e02b8289351.tar.bz2
stonesense-9c99824a023a959bb9ff908b2f434e02b8289351.tar.xz
Make stonesense use DF/stonesense for all resources.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp56
1 files changed, 38 insertions, 18 deletions
diff --git a/main.cpp b/main.cpp
index 8e4beab..54d7976 100644
--- a/main.cpp
+++ b/main.cpp
@@ -68,16 +68,18 @@ int32_t viewy = 0;
int32_t viewz = 0;
bool followmode = true;*/
-ALLEGRO_BITMAP* load_bitmap_withWarning(const char* path){
- ALLEGRO_BITMAP* img = 0;
- img = al_load_bitmap(path);
- if(!img){
- DFConsole->printerr("Cannot load image: %s\n", path);
- al_set_thread_should_stop(thread);
- return 0;
- }
- al_convert_mask_to_alpha(img, al_map_rgb(255, 0, 255));
- return img;
+ALLEGRO_BITMAP* load_bitmap_withWarning(const char* path)
+{
+ ALLEGRO_BITMAP* img = 0;
+ img = al_load_bitmap(path);
+ if(!img)
+ {
+ DFConsole->printerr("Cannot load image: %s\n", path);
+ al_set_thread_should_stop(thread);
+ return 0;
+ }
+ al_convert_mask_to_alpha(img, al_map_rgb(255, 0, 255));
+ return img;
}
@@ -140,12 +142,21 @@ void correctBlockForSegmetOffset(int32_t& x, int32_t& y, int32_t& z){
bool loadfont()
{
- font = al_load_font(al_path_cstr(config.font, ALLEGRO_NATIVE_PATH_SEP), config.fontsize, 0);
- if (!font) {
- DFConsole->printerr("Cannot load font: %s\n", al_path_cstr(config.font, ALLEGRO_NATIVE_PATH_SEP));
- return 0;
- }
- return 1;
+ ALLEGRO_PATH * p = al_create_path_for_directory("stonesense");
+ if(!al_join_paths(p, config.font))
+ {
+ al_destroy_path(p);
+ return false;
+ }
+ font = al_load_font(al_path_cstr(p, ALLEGRO_NATIVE_PATH_SEP), config.fontsize, 0);
+ if (!font)
+ {
+ DFConsole->printerr("Cannot load font: %s\n", al_path_cstr(p, ALLEGRO_NATIVE_PATH_SEP));
+ al_destroy_path(p);
+ return false;
+ }
+ al_destroy_path(p);
+ return true;
}
void benchmark(DFHack::Core * c){
@@ -177,10 +188,16 @@ void animUpdateProc()
void drawcredits()
{
+ static ALLEGRO_BITMAP* SplashImage = NULL; // BUG: leaks the image
al_clear_to_color(al_map_rgb(0,0,0));
//centred splash image
{
- static ALLEGRO_BITMAP* SplashImage = load_bitmap_withWarning("splash.png");
+ if(!SplashImage)
+ {
+ ALLEGRO_PATH * p = al_create_path("stonesense/stonesense.png");
+ SplashImage = load_bitmap_withWarning(al_path_cstr(p, ALLEGRO_NATIVE_PATH_SEP));
+ al_destroy_path(p);
+ }
if(!SplashImage)
return;
al_draw_bitmap_region(SplashImage, 0, 0,
@@ -467,9 +484,12 @@ static void * stonesense_thread(ALLEGRO_THREAD * thred, void * parms)
if(config.software)
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP|ALLEGRO_ALPHA_TEST);
- IMGIcon = load_bitmap_withWarning("stonesense.png");
+ ALLEGRO_PATH * p = al_create_path("stonesense/stonesense.png");
+ IMGIcon = load_bitmap_withWarning(al_path_cstr(p, ALLEGRO_NATIVE_PATH_SEP));
+ al_destroy_path(p);
if(!IMGIcon)
{
+ al_destroy_display(display);
stonesense_started = 0;
return NULL;
}