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

Method UpdateMegacellView

editor/MegacellDialog.cpp:892–960  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

890}
891
892void CMegacellDialog::UpdateMegacellView() {
893 int n = D3EditState.current_megacell;
894 CWnd *texwnd;
895 RECT rect;
896 int x, y, bm_handle, w, h;
897 int megawidth = Megacells[n].width;
898 int megaheight = Megacells[n].height;
899 int i, t;
900
901 Desktop_surf->attach_to_window((unsigned)m_hWnd);
902
903 texwnd = GetDlgItem(IDC_MEGACELL_VIEW);
904 texwnd->GetWindowRect(&rect);
905 ScreenToClient(&rect);
906 w = rect.right - rect.left;
907 h = rect.bottom - rect.top;
908
909 int texwidth = w / megawidth;
910 int texheight = h / megaheight;
911
912 // Don't have to clear if we're overwriting the whole area!
913 // if (megawidth<8 || megaheight<8)
914 // Desktop_surf->clear(rect.left,rect.top,w,h);
915
916 for (i = 0; i < megaheight; i++) {
917 for (t = 0; t < megawidth; t++) {
918 m_TextureSurf.create(texwidth, texheight, BPP_16);
919
920 bm_handle = GetTextureBitmap(Megacells[n].texture_handles[i * MAX_MEGACELL_WIDTH + t], 0);
921 m_TextureSurf.load(bm_handle);
922
923 x = 1 + rect.left + (t * texwidth);
924 y = 1 + rect.top + (i * texheight);
925
926 if (m_CheckForTextureList) {
927
928 if (m_CheckX >= x && m_CheckX <= (x + texwidth) && m_CheckY >= y && m_CheckY <= (y + texheight)) {
929 m_CheckForTextureList = 0;
930 Megacells[n].texture_handles[i * MAX_MEGACELL_WIDTH + t] = D3EditState.texdlg_texture;
931 m_TextureSurf.free();
932 Desktop_surf->attach_to_window((unsigned)NULL);
933 UpdateDialog();
934 return;
935 }
936 }
937
938 // Draw a separation line on the right and bottom side
939 {
940 grViewport *vport = new grViewport(&m_TextureSurf);
941
942 int x = 0, y = 0;
943
944 vport->lock();
945 vport->line(GR_RGB(0, 0, 0), 0, vport->height() - 1, vport->width() - 1, vport->height() - 1);
946 vport->line(GR_RGB(0, 0, 0), vport->width() - 1, 0, vport->width() - 1, vport->height() - 1);
947
948 vport->unlock();
949 delete vport;

Callers

nothing calls this directly

Calls 12

GetTextureBitmapFunction · 0.85
attach_to_windowMethod · 0.80
GR_RGBFunction · 0.50
createMethod · 0.45
loadMethod · 0.45
freeMethod · 0.45
lockMethod · 0.45
lineMethod · 0.45
heightMethod · 0.45
widthMethod · 0.45
unlockMethod · 0.45
bltMethod · 0.45

Tested by

no test coverage detected