@@ -663,12 +663,14 @@ class RandomInputHandler : public InputHandler
663
663
struct MenuTextures
664
664
{
665
665
std::string current_gameid;
666
+ bool global_textures;
666
667
video::ITexture *background;
667
668
video::ITexture *overlay;
668
669
video::ITexture *header;
669
670
video::ITexture *footer;
670
671
671
672
MenuTextures ():
673
+ global_textures (false ),
672
674
background (NULL ),
673
675
overlay (NULL ),
674
676
header (NULL ),
@@ -678,28 +680,49 @@ struct MenuTextures
678
680
static video::ITexture* getMenuTexture (const std::string &tname,
679
681
video::IVideoDriver* driver, const SubgameSpec *spec)
680
682
{
681
- std::string path;
682
- // eg. minetest_menu_background.png (for texture packs)
683
- std::string pack_tname = spec->id + " _menu_" + tname + " .png" ;
684
- path = getTexturePath (pack_tname);
685
- if (path != " " )
686
- return driver->getTexture (path.c_str ());
687
- // eg. games/minetest_game/menu/background.png
688
- path = getImagePath (spec->path + DIR_DELIM + " menu" + DIR_DELIM + tname + " .png" );
689
- if (path != " " )
690
- return driver->getTexture (path.c_str ());
683
+ if (spec){
684
+ std::string path;
685
+ // eg. minetest_menu_background.png (for texture packs)
686
+ std::string pack_tname = spec->id + " _menu_" + tname + " .png" ;
687
+ path = getTexturePath (pack_tname);
688
+ if (path != " " )
689
+ return driver->getTexture (path.c_str ());
690
+ // eg. games/minetest_game/menu/background.png
691
+ path = getImagePath (spec->path + DIR_DELIM + " menu" + DIR_DELIM + tname + " .png" );
692
+ if (path != " " )
693
+ return driver->getTexture (path.c_str ());
694
+ } else {
695
+ std::string path;
696
+ // eg. menu_background.png
697
+ std::string pack_tname = " menu_" + tname + " .png" ;
698
+ path = getTexturePath (pack_tname);
699
+ if (path != " " )
700
+ return driver->getTexture (path.c_str ());
701
+ }
691
702
return NULL ;
692
703
}
693
704
694
- void update (video::IVideoDriver* driver, const SubgameSpec *spec)
705
+ void update (video::IVideoDriver* driver, const SubgameSpec *spec, int tab )
695
706
{
696
- if (spec->id == current_gameid)
697
- return ;
698
- current_gameid = spec->id ;
699
- background = getMenuTexture (" background" , driver, spec);
700
- overlay = getMenuTexture (" overlay" , driver, spec);
701
- header = getMenuTexture (" header" , driver, spec);
702
- footer = getMenuTexture (" footer" , driver, spec);
707
+ if (tab == TAB_SINGLEPLAYER){
708
+ if (spec->id == current_gameid)
709
+ return ;
710
+ current_gameid = spec->id ;
711
+ global_textures = false ;
712
+ background = getMenuTexture (" background" , driver, spec);
713
+ overlay = getMenuTexture (" overlay" , driver, spec);
714
+ header = getMenuTexture (" header" , driver, spec);
715
+ footer = getMenuTexture (" footer" , driver, spec);
716
+ } else {
717
+ if (global_textures)
718
+ return ;
719
+ current_gameid = " " ;
720
+ global_textures = true ;
721
+ background = getMenuTexture (" background" , driver, NULL );
722
+ overlay = getMenuTexture (" overlay" , driver, NULL );
723
+ header = getMenuTexture (" header" , driver, NULL );
724
+ footer = getMenuTexture (" footer" , driver, NULL );
725
+ }
703
726
}
704
727
};
705
728
@@ -1778,7 +1801,7 @@ int main(int argc, char *argv[])
1778
1801
const SubgameSpec *menugame = getMenuGame (menudata);
1779
1802
1780
1803
MenuTextures menutextures;
1781
- menutextures.update (driver, menugame);
1804
+ menutextures.update (driver, menugame, menudata. selected_tab );
1782
1805
1783
1806
if (skip_main_menu == false )
1784
1807
{
@@ -1839,7 +1862,7 @@ int main(int argc, char *argv[])
1839
1862
1840
1863
// Game can be selected in the menu
1841
1864
menugame = getMenuGame (menudata);
1842
- menutextures.update (driver, menugame);
1865
+ menutextures.update (driver, menugame, menu-> getTab () );
1843
1866
// Clouds for the main menu
1844
1867
bool cloud_menu_background = g_settings->getBool (" menu_clouds" );
1845
1868
if (menugame){
0 commit comments