Safer window-icon handling.
Kill set_wm_icon function, since SDL_WM_SetIcon can be called safely only at one place. Clearly hardcode the image's url instead of pretending that we use game_config. Rename the image to "game-icon.png" (since you are forced to use it).
This commit is contained in:
parent
8bc5a68a70
commit
30c52fc7c5
7 changed files with 9 additions and 28 deletions
|
@ -77,7 +77,6 @@
|
|||
[images]
|
||||
game_title="maps/wesnoth.png"
|
||||
game_logo="misc/logo.png"
|
||||
game_icon="wesnoth-icon-small.png"
|
||||
|
||||
moved_orb="misc/orb-moved.png"
|
||||
unmoved_orb="misc/orb-unmoved.png"
|
||||
|
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
13
src/game.cpp
13
src/game.cpp
|
@ -536,8 +536,13 @@ bool game_controller::init_video()
|
|||
return true;
|
||||
}
|
||||
|
||||
//NOTE will use the hardcoded icon, game_config is not ready yet
|
||||
image::set_wm_icon();
|
||||
#if !(defined(__APPLE__))
|
||||
surface icon(image::get_image("game-icon.png", image::UNSCALED));
|
||||
if(icon != NULL) {
|
||||
///must be called after SDL_Init() and before setting video mode
|
||||
::SDL_WM_SetIcon(icon,NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
std::pair<int,int> resolution;
|
||||
int bpp = 0;
|
||||
|
@ -598,10 +603,6 @@ bool game_controller::init_config(const bool force)
|
|||
const config &cfg = game_config().child("game_config");
|
||||
game_config::load_config(cfg ? &cfg : NULL);
|
||||
|
||||
//the game_config icon may be different from the hardcoded one
|
||||
//FIXME SDL seems to segfault when setting twice the same icon
|
||||
//image::set_wm_icon();
|
||||
|
||||
hotkey::deactivate_all_scopes();
|
||||
hotkey::set_scope_active(hotkey::SCOPE_GENERAL);
|
||||
hotkey::set_scope_active(hotkey::SCOPE_GAME);
|
||||
|
|
|
@ -63,9 +63,7 @@ namespace game_config
|
|||
default_defeat_music;
|
||||
|
||||
namespace images {
|
||||
//NOTE hardcode game_icon because used before that game_config is ready
|
||||
std::string game_icon = "wesnoth-icon-small.png",
|
||||
game_title,
|
||||
std::string game_title,
|
||||
game_logo,
|
||||
// orbs and hp/xp bar
|
||||
moved_orb,
|
||||
|
@ -186,7 +184,6 @@ namespace game_config
|
|||
|
||||
if(const config &i = v.child("images")){
|
||||
using namespace game_config::images;
|
||||
game_icon = i["game_icon"].str();
|
||||
game_title = i["game_title"].str();
|
||||
game_logo = i["game_logo"].str();
|
||||
|
||||
|
|
|
@ -70,8 +70,7 @@ namespace game_config
|
|||
default_defeat_music;
|
||||
|
||||
namespace images {
|
||||
extern std::string game_icon,
|
||||
game_title,
|
||||
extern std::string game_title,
|
||||
game_logo,
|
||||
// orbs and hp/xp bar
|
||||
moved_orb,
|
||||
|
|
|
@ -879,16 +879,6 @@ manager::~manager()
|
|||
flush_cache();
|
||||
}
|
||||
|
||||
void set_wm_icon()
|
||||
{
|
||||
#if !(defined(__APPLE__))
|
||||
surface icon(get_image(game_config::images::game_icon,UNSCALED));
|
||||
if(icon != NULL) {
|
||||
::SDL_WM_SetIcon(icon,NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_PixelFormat last_pixel_format;
|
||||
|
||||
void set_pixel_format(SDL_PixelFormat* format)
|
||||
|
|
|
@ -165,11 +165,6 @@ namespace image {
|
|||
~manager();
|
||||
};
|
||||
|
||||
///function to set the program's icon to the window manager.
|
||||
///must be called after SDL_Init() is called, but before setting the
|
||||
///video mode
|
||||
void set_wm_icon();
|
||||
|
||||
///will make all scaled images have these rgb values added to all
|
||||
///their pixels. i.e. add a certain color hint to images. useful
|
||||
///for representing day/night. Invalidates all scaled images.
|
||||
|
|
Loading…
Add table
Reference in a new issue