git @ Cat's Eye Technologies linapple / 0e14d3e
Merge pull request #3 from catseye/set-resource-dir-at-build-time Set resource dir at build time Chris Pressey authored 4 years ago GitHub committed 4 years ago
6 changed file(s) with 24 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
1111 file in this directory: Command-line.md
1212 - recording location of resource files at build time instead of
1313 assuming they always reside in the current directory. This permits
14 the executable to be started from any directory (under development)
14 the executable to be started from any directory.
1515 - treating the configuration file as read-only (planned)
1616
1717 It also contains changes for building and running under OSX, taken from
2929
3030 /* And KREZ */
3131
32 #include "Resources.h"
3233 #include "stdafx.h"
3334 //#pragma hdrstop
3435 #include "MouseInterface.h"
12091210 SDL_WM_SetIcon(apple_icon, NULL);
12101211 printf("Icon was set! Width=%d, height=%d\n", apple_icon->w, apple_icon->h);*/
12111212
1212 apple_icon = SDL_LoadBMP("icon.bmp");
1213 apple_icon = SDL_LoadBMP(RESOURCE_ICON_BMP);
12131214 if(apple_icon != NULL) {
12141215 Uint32 colorkey = SDL_MapRGB(apple_icon->format, 0, 0, 0);
12151216 SDL_SetColorKey(apple_icon, SDL_SRCCOLORKEY, colorkey);
1212 CURL_CFLAGS = $(shell $(CURL_CONFIG) --cflags)
1313 CURL_LIBS = $(shell $(CURL_CONFIG) --libs)
1414
15 # build with `RESOURCE_DIR=. make` to get the legacy behaviour of loading resource files from the current directory
16 RESOURCE_DIR ?= $(shell (cd .. && pwd))
17
1518 CXXFLAGS += $(SDL_CFLAGS)
1619 CXXFLAGS += $(CURL_CFLAGS)
20 CXXFLAGS += -DRESOURCE_DIR=\"$(RESOURCE_DIR)/\"
1721 LDLIBS += $(SDL_LIBS) $(CURL_LIBS) -lz -lzip
1822
1923 # Define executable and installing directory
0 /* Resources.h -- configures locations of resource files that linapple loads on startup */
1
2 #ifndef RESOURCE_DIR
3 #define RESOURCE_DIR "./"
4 #endif
5
6 #define RESOURCE_ICON_BMP RESOURCE_DIR "icon.bmp"
7 #define RESOURCE_SPLASH_BMP RESOURCE_DIR "splash.bmp"
8 #define RESOURCE_CHARSET40_BMP RESOURCE_DIR "charset40.bmp"
9 #define RESOURCE_FONT_BMP RESOURCE_DIR "font.bmp"
2727
2828 /* Adaptation for SDL and POSIX (l) by beom beotiger, Nov-Dec 2007 */
2929
30 #include "Resources.h"
3031 #include "stdafx.h"
3132 #include "wwrapper.h"
3233 //#include "stretch.c" // for SDL_SoftStretch thanx to Sam Lantinga and Tomasz Cejner
18881889 ZeroMemory(vidlastmem,0x10000);
18891890
18901891 // LOAD THE splash screen
1891 tmp_surface = SDL_LoadBMP("splash.bmp");
1892 tmp_surface = SDL_LoadBMP(RESOURCE_SPLASH_BMP);
18921893 if (tmp_surface != NULL) g_hLogoBitmap = SDL_DisplayFormat(tmp_surface);
1893 else fprintf(stderr, "Video: splash.bmp was not loaded\n");
1894 else fprintf(stderr, "Video: " RESOURCE_SPLASH_BMP " was not loaded\n");
18941895 SDL_FreeSurface(tmp_surface);
18951896
18961897 // LOAD APPLE CHARSET40
1897 tmp_surface = SDL_LoadBMP("charset40.bmp");
1898 tmp_surface = SDL_LoadBMP(RESOURCE_CHARSET40_BMP);
18981899 if(tmp_surface != NULL) charset40 = SDL_DisplayFormat(tmp_surface);
1899 else fprintf(stderr, "Video: Apple text is not unavailable: charset40.bmp was not loaded\n");
1900 else fprintf(stderr, "Video: Apple text is not available: " RESOURCE_CHARSET40_BMP " was not loaded\n");
19001901 SDL_FreeSurface(tmp_surface);
19011902
19021903 // CREATE AN IDENTITY PALETTE AND FILL IN THE CORRESPONDING COLORS IN
3333
3434 //static unsigned char copy_row[4096];
3535
36 #include "Resources.h"
3637 #include "stdafx.h"
3738
3839
453454 bool fonts_initialization(void)
454455 {
455456 SDL_Surface *temp_surface;
456 temp_surface = SDL_LoadBMP("font.bmp");
457 temp_surface = SDL_LoadBMP(RESOURCE_FONT_BMP);
457458 if(!temp_surface) return false;
458459 font_sfc = SDL_DisplayFormat(temp_surface);
459460