668 ttd_strlcpy(this->edit_str_buf, _settings_client.network.server_name, lengthof(this->edit_str_buf)); |
668 ttd_strlcpy(this->edit_str_buf, _settings_client.network.server_name, lengthof(this->edit_str_buf)); |
669 |
669 |
670 _saveload_mode = SLD_NEW_GAME; |
670 _saveload_mode = SLD_NEW_GAME; |
671 BuildFileList(); |
671 BuildFileList(); |
672 this->vscroll.cap = 12; |
672 this->vscroll.cap = 12; |
673 this->vscroll.count = _fios_num + 1; |
673 this->vscroll.count = _fios_items.Length(); |
674 |
674 |
675 this->afilter = CS_ALPHANUMERAL; |
675 this->afilter = CS_ALPHANUMERAL; |
676 InitializeTextBuffer(&this->text, this->edit_str_buf, lengthof(this->edit_str_buf), 160); |
676 InitializeTextBuffer(&this->text, this->edit_str_buf, lengthof(this->edit_str_buf), 160); |
677 |
677 |
678 this->field = NSSW_GAMENAME; |
678 this->field = NSSW_GAMENAME; |
681 this->FindWindowPlacementAndResize(desc); |
681 this->FindWindowPlacementAndResize(desc); |
682 } |
682 } |
683 |
683 |
684 virtual void OnPaint() |
684 virtual void OnPaint() |
685 { |
685 { |
686 int y = NSSWND_START, pos; |
686 int y = NSSWND_START; |
687 const FiosItem *item; |
687 const FiosItem *item; |
688 |
688 |
689 /* draw basic widgets */ |
689 /* draw basic widgets */ |
690 SetDParam(1, _connection_types_dropdown[_network_advertise]); |
690 SetDParam(1, _connection_types_dropdown[_network_advertise]); |
691 SetDParam(2, _network_game_info.clients_max); |
691 SetDParam(2, _network_game_info.clients_max); |
701 if (_network_game_info.use_password) DoDrawString("*", 408, 23, TC_RED); |
701 if (_network_game_info.use_password) DoDrawString("*", 408, 23, TC_RED); |
702 |
702 |
703 /* draw list of maps */ |
703 /* draw list of maps */ |
704 GfxFillRect(11, 63, 258, 215, 0xD7); // black background of maps list |
704 GfxFillRect(11, 63, 258, 215, 0xD7); // black background of maps list |
705 |
705 |
706 pos = this->vscroll.pos; |
706 for (uint pos = this->vscroll.pos; pos < _fios_items.Length() + 1; pos++) { |
707 while (pos < _fios_num + 1) { |
707 item = _fios_items.Get(pos - 1); |
708 item = _fios_list + pos - 1; |
|
709 if (item == this->map || (pos == 0 && this->map == NULL)) |
708 if (item == this->map || (pos == 0 && this->map == NULL)) |
710 GfxFillRect(11, y - 1, 258, y + 10, 155); // show highlighted item with a different colour |
709 GfxFillRect(11, y - 1, 258, y + 10, 155); // show highlighted item with a different colour |
711 |
710 |
712 if (pos == 0) { |
711 if (pos == 0) { |
713 DrawString(14, y, STR_4010_GENERATE_RANDOM_NEW_GAME, TC_DARK_GREEN); |
712 DrawString(14, y, STR_4010_GENERATE_RANDOM_NEW_GAME, TC_DARK_GREEN); |
714 } else { |
713 } else { |
715 DoDrawString(item->title, 14, y, _fios_colors[item->type] ); |
714 DoDrawString(item->title, 14, y, _fios_colors[item->type] ); |
716 } |
715 } |
717 pos++; |
|
718 y += NSSWND_ROWSIZE; |
716 y += NSSWND_ROWSIZE; |
719 |
717 |
720 if (y >= this->vscroll.cap * NSSWND_ROWSIZE + NSSWND_START) break; |
718 if (y >= this->vscroll.cap * NSSWND_ROWSIZE + NSSWND_START) break; |
721 } |
719 } |
722 } |
720 } |
744 int y = (pt.y - NSSWND_START) / NSSWND_ROWSIZE; |
742 int y = (pt.y - NSSWND_START) / NSSWND_ROWSIZE; |
745 |
743 |
746 y += this->vscroll.pos; |
744 y += this->vscroll.pos; |
747 if (y >= this->vscroll.count) return; |
745 if (y >= this->vscroll.count) return; |
748 |
746 |
749 this->map = (y == 0) ? NULL : _fios_list + y - 1; |
747 this->map = (y == 0) ? NULL : _fios_items.Get(y - 1); |
750 this->SetDirty(); |
748 this->SetDirty(); |
751 } break; |
749 } break; |
752 |
750 |
753 case NSSW_CONNTYPE_BTN: // Connection type |
751 case NSSW_CONNTYPE_BTN: // Connection type |
754 ShowDropDownMenu(this, _connection_types_dropdown, _network_advertise, NSSW_CONNTYPE_BTN, 0, 0); // do it for widget NSSW_CONNTYPE_BTN |
752 ShowDropDownMenu(this, _connection_types_dropdown, _network_advertise, NSSW_CONNTYPE_BTN, 0, 0); // do it for widget NSSW_CONNTYPE_BTN |