1. C++ / Говнокод #20284

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    switch (count)
        {
        case 1:
            cout << okonch1 << endl;
            if (okonch1 == okonchanie1)
            {
                cout << slovo_okonch1_1 << endl;
            }
            else
            {
                if (okonch1 == okonchanie2)
                {
                    cout << slovo_okonch2_1 << endl;;
                }
                else
                {
                    if (okonch1 == okonchanie3)
                    {
                        cout << slovo_okonch3_1 << endl;;
                    }
                    else
                    {
                        if (okonch1 == okonchanie4)
                        {
                            cout << slovo_okonch4_1 << endl;
                        }
                        else
                        {
                            if (okonch1 == okonchanie5)
                            {
                                cout << slovo_okonch5_1 << endl;
                            }
                            else
                            {
                                if (okonch1 == okonchanie6)
                                {
                                    cout << slovo_okonch6_1 << endl;
                                }
                                else
                                {
                                    if (okonch1 == okonchanie7)
                                    {
                                        cout << slovo_okonch7_1 << endl;
                                    }
                                    else
                                    {
                                        if (okonch1 == okonchanie8)
                                        {
                                            cout << slovo_okonch8_1 << endl;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

    Создана куча переменных okonch*_* и по ним происходит switch
    Что самое смешное(или ужасное?) - этого кода на 500 строк...

    Rmkek, 27 Июня 2016

    Комментарии (4)
  2. PHP / Говнокод #20283

    +6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    switch ($m->type) {
    			case 'photo':
    				echo sprintf('<div class="fb_photo %s"><a %s href="%s"><div style="background-image: url(\'%s\');"><b>%s</b><br>%s%s<div class="status">%s <img src="%s" /> %s <img src="%s" /></div></div></div>', ($showProfilePic ? 'padding65' : ''), (isset($_GET['nonavbar']) ? 'target="_top"' : 'target="_blank"'), $m->link . (isset($_GET['nonavbar']) ? '&openwithnavigation=1' : ''), str_replace("_s", "_n", $m->picture), $m->from->name, (!empty($m->message) ? $m->message.'<br>' : ''), ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes)  && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				break;
    			case 'video':
    			case 'link':
    				echo sprintf('<div class="fb_link %s"><a %s href="%s"><div style="width: 100%%; padding: 30px;  box-sizing: border-box;border-bottom:1px solid #ccc;border-top:1px solid #ccc;"><img style="max-width: none; width:100px;" src="%s" /><div style="width: 100%%"><b>%s</b><br>%s</div></div><div style="position:absolute; right: 10px; bottom: 10px;" class="status">%s <img style="display: inline-block" src="%s" /> %s <img style="display: inline-block" src="%s" /></div></a></div>', ($showProfilePic ? 'padding65' : ''), (isset($_GET['nonavbar']) ? 'target="_top"' : 'target="_blank"'), $m->link . (isset($_GET['nonavbar']) ? '&openwithnavigation=1' : ''), $m->picture, $m->name, $m->message, ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes) && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				//echo sprintf('<div class="fb_link"><a href="%s"><div><img src="%s" /><b>%s</b><br>%s<div class="status">%s likes, %s comments</div></div></div></div>', $m->link, str_replace("_s", "_n", $m->picture), $m->from->name, $m->message, $m->likes->count, $m->comments->count);
    				break;
    			case 'status':
    				echo sprintf('<div class="fb_link %s"><a %s href="%s"><div style="width: 100%%; padding: 30px;  box-sizing: border-box;border-bottom:1px solid #ccc;border-top:1px solid #ccc;"><img style="max-width: none; width:100px;" src="%s" /><div style="width: 100%%"><b>%s</b><br>%s</div></div><div style="position:absolute; right: 10px; bottom: 10px;" class="status">%s <img style="display: inline-block" src="%s" /> %s <img style="display: inline-block" src="%s" /></div></a></div>', ($showProfilePic ? 'padding65' : ''), '', '', $m->picture, $m->name, $m->message, ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes)  && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
    				break;
    			default:
    				//echo 'TODO: ' . $m->type;
    				//var_dump($m);
    				break;
    		}

    Верстка.
    Уровень - бог.

    valentinlazy, 27 Июня 2016

    Комментарии (1)
  3. PHP / Говнокод #20282

    +3

    1. 1
    session_decode(session_encode());

    что это вообще такое и зачем оно?

    kropotor, 27 Июня 2016

    Комментарии (5)
  4. C++ / Говнокод #20281

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    AnsiString message=IntToStr((int)GetTickCount());
    		if(message.Length()>=3)
    			message=message.SubString(message.Length()-3, 3);
    		else if(message.Length()==2)
    			message="0"+message;
    		else if(message.Length()==1)
    			message="00"+message;
    		message=dt.FormatString("yy")+dt.FormatString("mm")+dt.FormatString("dd")+" "+
    			dt.FormatString("hh")+dt.FormatString("nn")+dt.FormatString("ss")+" "+message;
    		message=message+" "+aMessage;
    		if(FMemoMes){
    			FMemoMes->Lines->Add(message);
    		}

    Выводит сообщение aMessage, вставляя в начало сообщения текущие дату и время с миллисекундами.

    appach, 27 Июня 2016

    Комментарии (1)
  5. PHP / Говнокод #20280

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    <div class='min_content'>
    <?php
    $query_search = '`janr` LIKE "%'.$tip.'%" AND `xarakter_filma` LIKE "%'.$xar.'%" AND `detail_janr` LIKE "%'.$det.'%"';
      $num = 12;
    // Извлекаем из URL текущую страницу
        $page = (int)$_GET['page'];               
    // Определяем общее число сообщений в базе данных
    $count = "SELECT COUNT(*) FROM kino WHERE $query_search";
    $ardyunq = $db->query($count);
    $temp = $ardyunq->fetch(PDO::FETCH_NUM);;
    If ($temp[0] > 0)
    {  
    $tempcount = $temp[0];
    // Находим общее число страниц
    $total = (($tempcount - 1) / $num) + 1;
    $total =  intval($total);
    // Определяем начало сообщений для текущей страницы
    $page = intval($page);
    // Если значение $page меньше единицы или отрицательно
    // переходим на первую страницу
    // А если слишком большое, то переходим на последнюю
    if(empty($page) or $page < 0) $page = 1;
      if($page > $total) $page = $total;  
    // Вычисляем начиная с какого номера
    // следует выводить сообщения
    $start = $page * $num - $num;
    // Выбираем $num сообщений начиная с номера $start
    $qury_start_num = " LIMIT $start, $num"; 
    }  
        $query_search = '`janr` LIKE "%'.$tip.'%" AND `xarakter_filma` LIKE "%'.$xar.'%" AND `detail_janr` LIKE "%'.$det.'%"';
    $sql = "SELECT * FROM kino WHERE $query_search ORDER BY god DESC $qury_start_num";
    $result = $db->query($sql); 
    $rows = $result->fetch(PDO::FETCH_ASSOC);
    if(count($rows) > 0){
    while($row = $result->fetch(PDO::FETCH_ASSOC)) {
         echo "
    <div class='kino'>
    <div class='tkt'>
      <h2 class='namm'><a class='linka' href='index.film.php?id={$row['id']}'>{$row['title']}</a></h2>
      <p class='ab'><span class='tt'>Год:</span> {$row['god']}</p>
      <p class='ab'><span class='tt'>Страна:</span> {$row['country']}</p>
      <p class='ab'><span class='tt'>Жанр:</span> {$row['janr_text']}</p>
      <p class='ab'><span class='tt'>Режиссер:</span> {$row['rezhiser']}</p>
      <p class='ab'><span class='tt'>Краткое описание:</span></p>
      <div class='infoner'>{$row['mini_description']}</div>
      </div>  
     <div class='pick'>
    <a class='link1' href='index.film.php?id={$row['id']}'>{$row['images']}</a>
    <div class='ocenka'>
    <span class='rati'>IMDb :</span><span class='rat'> {$row['imdb']}</span></br>
    <span class='rati'>КиноПоиск :</span><span class='rat'> {$row['kinopoisk']}</span>
    </div>
    </div>
    </div> 
           ";     
    }
    }
    else{
        echo"
        <p class='no_result'>Нет результатов, попробуйте еще!!!</p>
        <div class=''><img src='/images/minion.jpg' /></div>    
        ";    
    };
    ?>
    <?php
    if ($page != 1){ $pstr_prev = '<li><a class="pstr-prev" href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.($page - 1).'">&lt;</a></li>';}
    if ($page != $total) $pstr_next = '<li><a class="pstr-next" href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.($page + 1).'">&gt;</a></li>';
    // Находим две ближайшие станицы с обоих краев, если они есть
    if($page - 3 > 0) $page3left = '<li><a href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.($page - 3).'">'.($page - 3).'</a></li>';
    if($page - 2 > 0) $page2left = '<li><a href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.($page - 2).'">'.($page - 2).'</a></li>';
    if($page - 1 > 0) $page1left = '<li><a href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.($page - 1).'">'.($page - 1).'</a></li>';
    if($page + 6 <= $total) $page6right = '<li><a href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.($page + 6).'">'.($page + 6).'</a></li>';
    if($page + 5 <= $total) $page5right = '<li><a href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.($page + 5).'">'.($page + 5).'</a></li>';
    if($page + 4 <= $total) $page4right = '<li><a href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.($page + 4).'">'.($page + 4).'</a></li>';
    if($page + 3 <= $total) $page3right = '<li><a href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.($page + 3).'">'.($page + 3).'</a></li>';
    if($page + 2 <= $total) $page2right = '<li><a href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.($page + 2).'">'.($page + 2).'</a></li>';
    if($page + 1 <= $total) $page1right = '<li><a href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.($page + 1).'">'.($page + 1).'</a></li>';
    if ($page+7 < $total)
    {
        $strtotal = '<li><p class="nav-point">...</p></li><li><a href="index-search_select_dop.php?xar='."$xar".'&tip='."$tip".'&det='."$det".'&page='.$total.'">'.$total.'</a></li>';
    }else
    {
        $strtotal = ""; 
    }
    
    if ($total > 1)
    {
        echo '
        <div class="pstrnave">
        <ul style="margin-left: -11px;">
        ';
        echo $pstr_prev.$page3left.$page2left.$page1left."<li><a class='pstr-active' href='index-search_select_dop.php?xar='.$xar.'&tip='.$tip.'&det='.$det.'&page=".$page."'>".$page."</a></li>".$page1right.$page2right.$page3right.$page4right.$page5right.$page6right.$strtotal.$pstr_next;
        echo '
        </ul>
        </div>
        ';   
    }    
    ?>
    </div>

    оригинал - https://toster.ru/q/331671

    loki90, 27 Июня 2016

    Комментарии (14)
  6. C++ / Говнокод #20279

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    GUIButton::GUIButton(ResourceManager& resourceManager, const Renderer& renderer,
            const Config& config, std::string name, Action action,
            int x, int y, int width, int height) :
        GUIButton{std::move(name), std::move(action),
            resourceManager.load<Font>("font_button_" + name,
                    config.findValue<std::string>("button", "font"),
                    config.findValue<int>("button", "font_size")),
            resourceManager.load<TextureAtlas>("atlas_button", resourceManager, renderer,
                    Config{config.findValue<std::string>("button", "atlas_config")}), x, y, width, height}
    {
    }

    jangolare, 27 Июня 2016

    Комментарии (3)
  7. C++ / Говнокод #20275

    +2

    1. 1
    https://m.reddit.com/r/cpp/comments/4pmlpz/what_the_iso_c_committee_added_to_the_c17_working/

    Мне остаётся только спросить:

    laMer007, 26 Июня 2016

    Комментарии (68)
  8. C++ / Говнокод #20272

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    void MyZKbMain::keyPressEvent(QKeyEvent* k)
    {
    	QPixmap pm; pm.load("ruleta_usr.png");
    	ZConfig Num(QString("numeros.cfg"), true);
    	ZConfig Hist(QString("historial.cfg"), true);
    
    	switch (k->key())
    	{
    	case 0x1046: //Boton Verde
    	break;
    
    	case 0x1030: //Boton Verde
    	calcular=0;
    	reboot = new ZMessageDlg("zRoulette", 
    		QString("Sistema Ubeda 0.5\nBasado en el Sistema de Cuadros\n\nwww.developermoto.com/es\nwww.modmymoto.com\n\n(C)2009 RacingLocura07, CepiPerez"), 
    		(ZMessageDlg::MessageDlgType)2, 0, this,"about", true, 0);
    	reboot->setTitleIcon(pm); reboot->show();
    	break;
    
    	case 0x1031: //Boton Rojo
    	calcular=0;
    	reboot = new ZMessageDlg("zRoulette", "Desea salir?", 
    			(ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0);
    	reboot->setTitleIcon(pm); reboot->show();
    	if(reboot->exec()==1) { exit(); }
    	else { update(); break; }
    	
    	case 0x1012: //Tecla de Navegacion De Izquierda
    	calcular=0;
    	if (current > 1 ) { --current; update(); break; } else { break; }
    
    	case 0x1013: //Tecla de Navegacion De Arriba
    	calcular=0;
    	if ( current > 3 ) { ------current; update(); break; } else { break; }
    
    	case 0x1014: //Tecla de Navegacion De Derecha
    	calcular=0;
    	if (current < 36 ) { ++current; update(); break; } else { break; }
    
    	case 0x1015: //Tecla de Navegacion De Abajo
    	calcular=0;
    	if (current < 34 ) { ++++++current; update(); break; } else { break; }
    
    	case 0x1038: //Softkey Izquierda
    	calcular=0;
    	reboot = new ZMessageDlg("zRoulette", "Desea reinciar la Ruleta?", (ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0);
    	reboot->setTitleIcon(pm); reboot->show();
    	if(reboot->exec()==1) { system("rm numeros.cfg"); system("rm historial.cfg"); current = 1; jugadas = 0; lista.clear(); update(); break; }
    	else { update(); break; }
    
    	case 0x103a: //Softkey Derecha
    	int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("18"), 0 );
    	if ( temp != 0 ) {
    		reboot = new ZMessageDlg("zRoulette", "Desea limpiar las jugadas dejando las ultimas 18 solamente?", 
    				(ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0); reboot->setTitleIcon(pm); reboot->show();
    		if(reboot->exec()==1) { 
    		  for ( int l=1; l<37; ++l) { Num.writeEntry ( QString("NUMEROS"), QString("%1").arg(l), QString("0") ); }
    		  for ( int j=1; j<19; ++j) {
    			int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j), 0 );
    			if ( temp > 0 ) { Num.writeEntry ( QString("NUMEROS"), QString("%1").arg(temp), QString("1") ); }
    		  }	calcular=1; update(); break; 
    		} else { break; }
    	} else {
    		reboot = new ZMessageDlg("zRoulette", "Deben haber mas de 18 bolas jugadas para el reinicio parcial.", 
    			(ZMessageDlg::MessageDlgType)2, 0, this,"about", true, 0); reboot->setTitleIcon(pm); reboot->show(); break;
    	}
    
    	case 0x1004:  //Boton Central
    	valortemp = Num.readNumEntry(QString("NUMEROS"), QString("%1").arg(current), 0 );
    	if ( valortemp < 1 ) { valortemp=0; } ++valortemp;
    	Num.writeEntry(QString("NUMEROS"), QString("%1").arg(current), valortemp);
    
    	int lugar=0; for ( int j=18; j>0; --j)
    	{ int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j), 0 ); if ( temp==0 ) { lugar=j; } }
    	
    	if ( lugar > 0 ) {
    	  Hist.writeEntry ( QString("HISTORIAL"), QString("%1").arg(lugar), QString("%1").arg(current) );
    	} else {
    	  for ( int j=1; j<18; ++j) {
    		int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j+1), 0 ); 
    		Hist.writeEntry ( QString("HISTORIAL"), QString("%1").arg(j), QString("%1").arg(temp) ); 
    	  }
    	  Hist.writeEntry ( QString("HISTORIAL"), QString("18"), QString("%1").arg(current) ); 
    	}
    	calcular=1;
    	update();
    	}
    }

    Разработчики из солнечной Аргентины. Кусочек кода из кастомного "лаунчера" для телефонов Motorola на платформе MotoMAGX (Linux 2.6.10, Qt 2.3.8, gcc 3.4.3). АДИЩЕ С ЦАРСКИМИ АНРОЛЛАМИ: https://github.com/crutchwalkfactory/motocakerteam/blob/master/Projects/MotoDesk/MyZKbMain.cpp

    Что интересно, это всё как-то работало и даже довольно мило выглядело: http://exlmoto.ru/wp-content/Images/AOne/1.gif

    Tsiklonyashka, 26 Июня 2016

    Комментарии (63)
  9. C++ / Говнокод #20270

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    #include "stdafx.h"
    #include <Windows.h>
    #pragma comment(lib, "gdiplus.lib")
    #include <gdiplus.h>
    #include <vector>
    #include <chrono>
    
    wchar_t* path =
    L"здесь был путь*";
    
    using namespace Gdiplus;
    using namespace std::chrono;
    
    int main()
    {
    	GdiplusStartupInput gdipInput;
    	ULONG_PTR gdipToken;
    	GdiplusStartup(&gdipToken, &gdipInput, NULL);
    	HWND progman = FindWindowW(L"Progman", NULL);
    	HWND workerw = GetWindow(progman, GW_HWNDPREV);
    	HDC dc = GetDC(workerw);
    	
    	std::vector<Bitmap*> images;
    	WIN32_FIND_DATAW fdata = { 0 };
    	HANDLE hFind = FindFirstFileW(path, &fdata);
    	int
    		scrWidth = GetSystemMetrics(SM_CXSCREEN),
    		scrHeight = GetSystemMetrics(SM_CYSCREEN);
    	UINT width, height;
    	bool isInfoRetrieved = false;
    	std::wstring wmp(path);
    	wmp = wmp.substr(0, wmp.length() - 1);
    	do {
    		Bitmap* bmp = Bitmap::FromFile((wmp + fdata.cFileName).c_str());
    		if (bmp->GetLastStatus() != Gdiplus::Ok) continue;
    		int width = bmp->GetWidth();
    		int height = bmp->GetHeight();
    		double ratio = (double)width / height;
    		if (ratio > 1) {
    			width = scrWidth;
    			height = scrWidth / ratio;
    		}
    		else {
    			width = scrHeight * ratio;
    			height = scrHeight;
    		}
    		Bitmap* resized = new Bitmap(width, height, PixelFormat32bppRGB);
    		Graphics* resizedGr = Graphics::FromImage(resized);
    		resizedGr->DrawImage(bmp, 0, 0, width, height);
    		delete resizedGr;
    		delete bmp;
    		images.push_back(resized);
    	} while (FindNextFile(hFind, &fdata));
    	FindClose(hFind);
    	
    	Graphics* mainGr = Graphics::FromHDC(dc);
    	Bitmap* bufBmp = new Bitmap(scrWidth, scrHeight, PixelFormat32bppRGB);
    	Graphics* bufGr = Graphics::FromImage(bufBmp);
    	
    	int count = images.size();
    	int gap = 1000 / count;
    
    	while (true) {
    		for (auto it = images.begin(); it != images.end(); it++) {
    			milliseconds ms1 = duration_cast<milliseconds>(
    				system_clock::now().time_since_epoch());
    			Bitmap* bmp = *it;
    			int width = bmp->GetWidth();
    			int height = bmp->GetHeight();
    			int xOfs = (scrWidth - width) / 2, yOfs = (scrHeight - height) / 2;
    			bufGr->Clear(Color::Black);
    			bufGr->DrawImage(*it, xOfs, yOfs, width, height);
    			mainGr->DrawImage(bufBmp, 0, 0);
    			milliseconds ms2 = duration_cast<milliseconds>(
    				system_clock::now().time_since_epoch());
    			milliseconds delta = ms2 - ms1;
    			if (gap > delta.count())
    				Sleep(gap - delta.count());
    		}
    	}
    	return 0;
    }

    Код для рисования под иконками рабочего стола на винде
    Да, в винде можно так делать

    Нахуй никому не нужно, но выглядит заебись

    cykablyad, 26 Июня 2016

    Комментарии (7)
  10. C# / Говнокод #20267

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Оффтоп
    
    Пишу либу для гуя в консоли. Столкнулся с проблемой медленного вывода в консоль на линуксе.
    На винде есть няшный WriteConsoleOutput, который может вывести буфер разом на консоль, в линупсе ничего подобного не нашел.
    Если использовать Console.WriteLine или libc-шный puts, все лагает неимоверно
    
    Есть идеи?

    cykablyad, 24 Июня 2016

    Комментарии (168)