Add support for custom pixmaps path

This commit is contained in:
Pali Rohár 2012-07-15 14:10:42 +02:00
parent 2b5c8b997d
commit 54b1a6471f
2 changed files with 44 additions and 22 deletions

View file

@ -621,11 +621,18 @@ set(SBINDIR "sbin" CACHE PATH "Where to install system binaries")
set(GAMEDIR "games" CACHE PATH "Where to install games binaries")
set(DOCDIR "share/doc/stratagus" CACHE PATH "Sets the doc directory to a non-default location.")
set(MANDIR "share/man/man6" CACHE PATH "Sets the man directory to a non-default location.")
set(PIXMAPSDIR "share/pixmaps" CACHE PATH "Sets the pixmaps directory to a non-default location.")
set(STRATAGUS_HEADERS "include" CACHE PATH "Where to install stratagus headers.")
if(NOT IS_ABSOLUTE "${PIXMAPSDIR}")
set(PIXMAPSDIRABS "${CMAKE_INSTALL_PREFIX}/${PIXMAPSDIR}")
else()
set(PIXMAPSDIRABS "${PIXMAPSDIR}")
endif()
# Stratagus definitions
add_definitions(${PNG_DEFINITIONS} -DUSE_ZLIB)
add_definitions(${PNG_DEFINITIONS} -DUSE_ZLIB -DPIXMAPS=\"${PIXMAPSDIRABS}\")
include_directories(${LUA_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${SDL_INCLUDE_DIR} ${TOLUA++_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS})
set(stratagus_LIBS ${stratagus_LIBS} ${LUA_LIBRARIES} ${PNG_LIBRARIES} ${SDL_LIBRARY} ${TOLUA++_LIBRARY} ${ZLIB_LIBRARIES})
@ -874,7 +881,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
endif()
if(WIN32 AND MINGW AND ENABLE_STATIC)
set_target_properties(stratagus PROPERTIES LINK_FLAGS "${LINK_FLAGS} -static-libgcc -Wl,--stack,10485760")
set_target_properties(stratagus PROPERTIES LINK_FLAGS "${LINK_FLAGS} -static-libgcc -static-libstdc++ -Wl,--stack,10485760")
endif()
########### next target ###############
@ -902,7 +909,7 @@ if(SQLITE_FOUND)
target_link_libraries(metaserver ${SDL_LIBRARY} ${SQLITE_LIBRARIES})
if(WIN32 AND MINGW AND ENABLE_STATIC)
set_target_properties(metaserver PROPERTIES LINK_FLAGS "${LINK_FLAGS} -static-libgcc")
set_target_properties(metaserver PROPERTIES LINK_FLAGS "${LINK_FLAGS} -static-libgcc -static-libstdc++")
endif()
endif()
@ -917,7 +924,7 @@ add_executable(png2stratagus ${png2stratagus_SRCS})
target_link_libraries(png2stratagus ${PNG_LIBRARY} ${ZLIB_LIBRARIES})
if(WIN32 AND MINGW AND ENABLE_STATIC)
set_target_properties(png2stratagus PROPERTIES LINK_FLAGS "${LINK_FLAGS} -static-libgcc")
set_target_properties(png2stratagus PROPERTIES LINK_FLAGS "${LINK_FLAGS} -static-libgcc -static-libstdc++")
endif()

View file

@ -42,6 +42,7 @@
#include <map>
#include <string>
#include <vector>
#include <limits.h>
@ -464,10 +465,12 @@ void InitVideoSdl()
signal(SIGABRT, CleanExit);
#endif
// Set WindowManager Title
if (FullGameName.empty()) {
SDL_WM_SetCaption("Stratagus", "Stratagus");
} else {
if (!FullGameName.empty()) {
SDL_WM_SetCaption(FullGameName.c_str(), FullGameName.c_str());
} else if (!Parameters::Instance.applicationName.empty()) {
SDL_WM_SetCaption(Parameters::Instance.applicationName.c_str(), Parameters::Instance.applicationName.c_str());
} else {
SDL_WM_SetCaption("Stratagus", "Stratagus");
}
#if ! defined(USE_WIN32) && ! defined(USE_MAEMO)
@ -479,17 +482,33 @@ void InitVideoSdl()
CGraphic *g = NULL;
struct stat st;
char pixmaps[4][1024];
sprintf(pixmaps[0], "/usr/share/pixmaps/%s.png", FullGameName.c_str());
sprintf(pixmaps[1], "/usr/share/pixmaps/%s.png", FullGameName.c_str());
sprintf(pixmaps[2], "/usr/share/pixmaps/stratagus.png");
sprintf(pixmaps[3], "/usr/share/pixmaps/Stratagus.png");
pixmaps[1][19] = tolower(pixmaps[1][19]);
std::string FullGameNameL = FullGameName;
for (size_t i = 0; i < FullGameNameL.size(); ++i)
FullGameNameL[i] = tolower(FullGameNameL[i]);
for (int i = 0; i < 4; ++i) {
if (stat(pixmaps[i], &st) == 0) {
std::string ApplicationName = Parameters::Instance.applicationName;
std::string ApplicationNameL = ApplicationName;
for (size_t i = 0; i < ApplicationNameL.size(); ++i)
ApplicationNameL[i] = tolower(ApplicationNameL[i]);
std::vector <std::string> pixmaps;
pixmaps.push_back(std::string() + PIXMAPS + "/" + FullGameName + ".png");
pixmaps.push_back(std::string() + PIXMAPS + "/" + FullGameNameL + ".png");
pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + FullGameName + ".png");
pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + FullGameNameL + ".png");
pixmaps.push_back(std::string() + PIXMAPS + "/" + ApplicationName + ".png");
pixmaps.push_back(std::string() + PIXMAPS + "/" + ApplicationNameL + ".png");
pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + ApplicationName + ".png");
pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + ApplicationNameL + ".png");
pixmaps.push_back(std::string() + PIXMAPS + "/" + "Stratagus" + ".png");
pixmaps.push_back(std::string() + PIXMAPS + "/" + "stratagus" + ".png");
pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + "Stratagus" + ".png");
pixmaps.push_back(std::string() + "/usr/share/pixmaps" + "/" + "stratagus" + ".png");
for (size_t i = 0; i < pixmaps.size(); ++i) {
if (stat(pixmaps[i].c_str(), &st) == 0) {
if (g) { CGraphic::Free(g); }
g = CGraphic::New(pixmaps[i]);
g = CGraphic::New(pixmaps[i].c_str());
g->Load();
icon = g->Surface;
if (icon) { break; }
@ -507,21 +526,17 @@ void InitVideoSdl()
UseOpenGL = UseOpenGL_orig;
#endif
#ifdef USE_WIN32
int argc = 0;
LPWSTR *argv = NULL;
HWND hwnd = NULL;
HICON hicon = NULL;
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if (SDL_GetWMInfo(&info)) {
hwnd = info.window;
}
if (hwnd && argc > 0 && argv) {
hicon = ExtractIconW(GetModuleHandle(NULL), argv[0], 0);
if (hwnd) {
hicon = ExtractIcon(GetModuleHandle(NULL), Parameters::Instance.applicationName.c_str(), 0);
}
if (hicon) {