MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / UpdateTextureView

Method UpdateTextureView

editor/MegacellDialog.cpp:697–787  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695#define TEXTURES_PER_ROW 4
696
697void CMegacellDialog::UpdateTextureView() {
698 int n = D3EditState.texdlg_texture;
699 CWnd *texwnd;
700 RECT rect;
701 int x, y, bm_handle, w, h;
702 int update_listbox = 1;
703
704 Desktop_surf->attach_to_window((unsigned)m_hWnd);
705
706 if (1 || update_listbox) {
707
708 texwnd = GetDlgItem(IDC_TEXTURE_LISTBOX);
709 texwnd->GetWindowRect(&rect);
710 ScreenToClient(&rect);
711 w = rect.right - rect.left;
712 h = rect.bottom - rect.top;
713
714 int texwidth = (w - 1) / 4;
715 int texheight = (h - 1) / 8;
716
717 Desktop_surf->clear(rect.left, rect.top, w, h);
718
719 int texnum = m_TexStart;
720 int count = 0, done = 0;
721
722 while (!done) {
723 m_TextureSurf.create(texwidth, texheight, BPP_16);
724
725 bm_handle = GetTextureBitmap(texnum, 0);
726 m_TextureSurf.load(bm_handle);
727
728 x = 1 + rect.left + ((count % TEXTURES_PER_ROW) * texwidth);
729 y = 1 + rect.top + ((count / TEXTURES_PER_ROW) * texheight);
730
731 if (m_CheckForTextureList) {
732
733 if (m_CheckX >= x && m_CheckX <= (x + texwidth) && m_CheckY >= y && m_CheckY <= (y + texheight)) {
734 m_CheckForTextureList = 0;
735 D3EditState.texdlg_texture = texnum;
736 m_TextureSurf.free();
737 Desktop_surf->attach_to_window((unsigned)NULL);
738 UpdateDialog();
739 return;
740 }
741 }
742
743 if (texnum == n) // draw a white box if this is the current texture
744 {
745 grViewport *vport = new grViewport(&m_TextureSurf);
746
747 int x = 0, y = 0;
748
749 vport->lock();
750 vport->line(GR_RGB(255, 255, 255), x, y, x + vport->width() - 1, y);
751 vport->line(GR_RGB(255, 255, 255), x + vport->width() - 1, y, x + vport->width() - 1, y + vport->height() - 1);
752 vport->line(GR_RGB(255, 255, 255), x + vport->width() - 1, y + vport->height() - 1, x, y + vport->height() - 1);
753 vport->line(GR_RGB(255, 255, 255), x, y + vport->height() - 1, x, y);
754 vport->unlock();

Callers

nothing calls this directly

Calls 14

GetTextureBitmapFunction · 0.85
GetNextTextureFunction · 0.85
attach_to_windowMethod · 0.80
GR_RGBFunction · 0.50
clearMethod · 0.45
createMethod · 0.45
loadMethod · 0.45
freeMethod · 0.45
lockMethod · 0.45
lineMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected