@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
31
31
#include " sound_openal.h"
32
32
#include " clouds.h"
33
33
#include " httpfetch.h"
34
+ #include " util/numeric.h"
34
35
35
36
#include < IGUIStaticText.h>
36
37
#include < ICameraSceneNode.h>
@@ -140,7 +141,7 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
140
141
{
141
142
// initialize texture pointers
142
143
for (unsigned int i = 0 ; i < TEX_LAYER_MAX; i++) {
143
- m_textures[i] = 0 ;
144
+ m_textures[i]. texture = NULL ;
144
145
}
145
146
// is deleted by guiformspec!
146
147
m_buttonhandler = new TextDestGuiEngine (this );
@@ -238,7 +239,6 @@ bool GUIEngine::loadMainMenuScript()
238
239
/* *****************************************************************************/
239
240
void GUIEngine::run ()
240
241
{
241
-
242
242
// Always create clouds because they may or may not be
243
243
// needed based on the game selected
244
244
video::IVideoDriver* driver = m_device->getVideoDriver ();
@@ -292,8 +292,8 @@ GUIEngine::~GUIEngine()
292
292
293
293
// clean up texture pointers
294
294
for (unsigned int i = 0 ; i < TEX_LAYER_MAX; i++) {
295
- if (m_textures[i] != 0 )
296
- driver->removeTexture (m_textures[i]);
295
+ if (m_textures[i]. texture != NULL )
296
+ driver->removeTexture (m_textures[i]. texture );
297
297
}
298
298
299
299
delete m_texture_source;
@@ -362,7 +362,7 @@ void GUIEngine::drawBackground(video::IVideoDriver* driver)
362
362
{
363
363
v2u32 screensize = driver->getScreenSize ();
364
364
365
- video::ITexture* texture = m_textures[TEX_LAYER_BACKGROUND];
365
+ video::ITexture* texture = m_textures[TEX_LAYER_BACKGROUND]. texture ;
366
366
367
367
/* If no texture, draw background of solid color */
368
368
if (!texture){
@@ -372,8 +372,27 @@ void GUIEngine::drawBackground(video::IVideoDriver* driver)
372
372
return ;
373
373
}
374
374
375
- /* Draw background texture */
376
375
v2u32 sourcesize = texture->getOriginalSize ();
376
+
377
+ if (m_textures[TEX_LAYER_BACKGROUND].tile )
378
+ {
379
+ v2u32 tilesize (
380
+ MYMAX (sourcesize.X ,m_textures[TEX_LAYER_BACKGROUND].minsize ),
381
+ MYMAX (sourcesize.Y ,m_textures[TEX_LAYER_BACKGROUND].minsize ));
382
+ for (unsigned int x = 0 ; x < screensize.X ; x += tilesize.X )
383
+ {
384
+ for (unsigned int y = 0 ; y < screensize.Y ; y += tilesize.Y )
385
+ {
386
+ driver->draw2DImage (texture,
387
+ core::rect<s32>(x, y, x+tilesize.X , y+tilesize.Y ),
388
+ core::rect<s32>(0 , 0 , sourcesize.X , sourcesize.Y ),
389
+ NULL , NULL , true );
390
+ }
391
+ }
392
+ return ;
393
+ }
394
+
395
+ /* Draw background texture */
377
396
driver->draw2DImage (texture,
378
397
core::rect<s32>(0 , 0 , screensize.X , screensize.Y ),
379
398
core::rect<s32>(0 , 0 , sourcesize.X , sourcesize.Y ),
@@ -385,7 +404,7 @@ void GUIEngine::drawOverlay(video::IVideoDriver* driver)
385
404
{
386
405
v2u32 screensize = driver->getScreenSize ();
387
406
388
- video::ITexture* texture = m_textures[TEX_LAYER_OVERLAY];
407
+ video::ITexture* texture = m_textures[TEX_LAYER_OVERLAY]. texture ;
389
408
390
409
/* If no texture, draw background of solid color */
391
410
if (!texture)
@@ -404,7 +423,7 @@ void GUIEngine::drawHeader(video::IVideoDriver* driver)
404
423
{
405
424
core::dimension2d<u32> screensize = driver->getScreenSize ();
406
425
407
- video::ITexture* texture = m_textures[TEX_LAYER_HEADER];
426
+ video::ITexture* texture = m_textures[TEX_LAYER_HEADER]. texture ;
408
427
409
428
/* If no texture, draw nothing */
410
429
if (!texture)
@@ -438,7 +457,7 @@ void GUIEngine::drawFooter(video::IVideoDriver* driver)
438
457
{
439
458
core::dimension2d<u32> screensize = driver->getScreenSize ();
440
459
441
- video::ITexture* texture = m_textures[TEX_LAYER_FOOTER];
460
+ video::ITexture* texture = m_textures[TEX_LAYER_FOOTER]. texture ;
442
461
443
462
/* If no texture, draw nothing */
444
463
if (!texture)
@@ -466,29 +485,38 @@ void GUIEngine::drawFooter(video::IVideoDriver* driver)
466
485
}
467
486
468
487
/* *****************************************************************************/
469
- bool GUIEngine::setTexture (texture_layer layer,std::string texturepath) {
470
-
488
+ bool GUIEngine::setTexture (texture_layer layer, std::string texturepath,
489
+ bool tile_image, unsigned int minsize)
490
+ {
471
491
video::IVideoDriver* driver = m_device->getVideoDriver ();
472
492
assert (driver != 0 );
473
493
474
- if (m_textures[layer] != 0 )
494
+ if (m_textures[layer]. texture != NULL )
475
495
{
476
- driver->removeTexture (m_textures[layer]);
477
- m_textures[layer] = 0 ;
496
+ driver->removeTexture (m_textures[layer]. texture );
497
+ m_textures[layer]. texture = NULL ;
478
498
}
479
499
480
500
if ((texturepath == " " ) || !fs::PathExists (texturepath))
501
+ {
481
502
return false ;
503
+ }
482
504
483
- m_textures[layer] = driver->getTexture (texturepath.c_str ());
505
+ m_textures[layer].texture = driver->getTexture (texturepath.c_str ());
506
+ m_textures[layer].tile = tile_image;
507
+ m_textures[layer].minsize = minsize;
484
508
485
- if (m_textures[layer] == 0 ) return false ;
509
+ if (m_textures[layer].texture == NULL )
510
+ {
511
+ return false ;
512
+ }
486
513
487
514
return true ;
488
515
}
489
516
490
517
/* *****************************************************************************/
491
- bool GUIEngine::downloadFile (std::string url,std::string target) {
518
+ bool GUIEngine::downloadFile (std::string url,std::string target)
519
+ {
492
520
#if USE_CURL
493
521
std::ofstream targetfile (target.c_str (), std::ios::out | std::ios::binary);
494
522
@@ -515,7 +543,8 @@ bool GUIEngine::downloadFile(std::string url,std::string target) {
515
543
}
516
544
517
545
/* *****************************************************************************/
518
- void GUIEngine::setTopleftText (std::string append) {
546
+ void GUIEngine::setTopleftText (std::string append)
547
+ {
519
548
std::string toset = std::string (" Minetest " ) + minetest_version_hash;
520
549
521
550
if (append != " " ) {
@@ -541,7 +570,8 @@ void GUIEngine::stopSound(s32 handle)
541
570
542
571
/* *****************************************************************************/
543
572
unsigned int GUIEngine::queueAsync (std::string serialized_func,
544
- std::string serialized_params) {
573
+ std::string serialized_params)
574
+ {
545
575
return m_script->queueAsync (serialized_func, serialized_params);
546
576
}
547
577
0 commit comments