Author Topic: OR small change  (Read 9828 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1992
    • zapsolution
OR small change
« on: September 09, 2019, 04:36:22 pm »
Mike

I did a small change into OR, to restore the current static background while switching back from animation (rather than using always "back02.jpg").
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: OR small change
« Reply #1 on: September 09, 2019, 07:17:14 pm »
Why wouldn't you send me your mods then? :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1992
    • zapsolution
Re: OR small change
« Reply #2 on: September 09, 2019, 08:41:31 pm »
Here they are:

void gl_LoadBackgrounds(IN HWND hList, IN BOOL bReset) { // PAT 09-09-2019, new BOOL bReset parameter to restore the current wallpaper rather than "back02.jpg"
    if (IsWindow(hList)) {
        WIN32_FIND_DATAW fd = { 0 };
        WCHAR zTmp[MAX_PATH] = { 0 };

        LVITEM lvi = { 0 };
        lvi.mask = LVIF_TEXT;

        SendMessage(hList, WM_SETREDRAW, FALSE, 0); // else its scrollbars flicker unskinned like hell
        ListView_DeleteAllItems(hList);

        long nCount = 0;
        Path_Combine(zTmp, EXEresource(), L"*.*");
        HANDLE hFind = FindFirstFile(zTmp, &fd);
        if (hFind != INVALID_HANDLE_VALUE) {
            BOOL bFound = TRUE;
            while (bFound) {
                if (!CheckStyle(fd.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY)) {
                    CharLower(fd.cFileName);
                    if (ZI_IsFileImage(fd.cFileName)) {
                        lvi.iItem = nCount++;
                        lvi.iSubItem = 0;
                        lvi.pszText = fd.cFileName;
                        ListView_InsertItem(hList, &lvi);
                    }
                }
                bFound = FindNextFile(hFind, &fd);
            }
            FindClose(hFind);
        }
        if (bReset) { nCount = 0; } // PAT 09-09-2019 restore the current wallpaper rather than "back02.jpg"
        if (nCount) {
            LVFINDINFO lvfi = { 0 };
            lvfi.flags = LVFI_STRING;
            lvfi.psz = L"back02.jpg";
            long nFound = ListView_FindItem(hList, -1, &lvfi);
            if (nFound < 0) { nFound = 0; }
            ListView_SelectPlus(hList, nFound);
        }
        SendMessage(hList, WM_SETREDRAW, TRUE, 0);
        RedrawWindow(hList, NULL, NULL, // this combination of flags seems to do the trick
            RDW_INVALIDATE | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ALLCHILDREN | RDW_UPDATENOW);
    }
}


    case MENU_ANI_BKGND: // MLL 06-01-2019: ani backgrounds
        gP.bAniBkgnd = !gP.bAniBkgnd;
        if (gP.bAniBkgnd) {
            dwStyle = MF_CHECKED;
            resetCurAniShader();
            parseAniShader(L"voronoi.fs"); // default
            if (!gl_LoadAniBackgrounds(GetDlgItem(gP.hMain, IDC_LISTBOX))) {
                CheckMenuItem(gR.hAniMenu, MENU_ANI_BKGND, MF_UNCHECKED);
                EnableMenuItem(gR.hAniMenu, MENU_ANI_BKGND, MF_GRAYED);
                break;
            }
            gP.tCurAniBkgndShader.nShaderID = glsl_LoadShaderFromFile("voronoi.fs");
            rAniStart = GetTickCount64() / 1000.0f;
            StartSync();
        } else {
            dwStyle = MF_UNCHECKED;
            gl_LoadBackgrounds(GetDlgItem(gP.hMain, IDC_LISTBOX), TRUE); // PAT 09-09-2019 use TRUE to restore the current wallpaper rather than "back02.jpg"
            resetCurAniShader();
            //if (!(gP.bGiration | gP.bUseFPS | gP.bAnimateLights | gP.bRotation | gP.bIsLerping))
            //    StopSync(SYNC_OFF);
        }
        CheckMenuItem(gR.hAniMenu, MENU_ANI_BKGND, dwStyle);
        gP.bRedraw = TRUE; // Redraw the OpenGL scene
        break;


// Forward declarations
void gl_DrawScene();
void gl_LoadBackgrounds(IN HWND hList, IN BOOL bReset);
void StopSync(IN long SYNC_MODE);


void backToStaticBkgnd() { // MLL 06-10-2019:
    BKSHADER* cs = &gP.tCurAniBkgndShader;

    gP.bAniBkgnd = FALSE;
    CheckMenuItem(gR.hAniMenu, MENU_ANI_BKGND, MF_UNCHECKED);
    if (cs->nShaderID) {
        for (int idx = 0; idx <= 3; idx++) {
            if (cs->samplerMapID[idx]) {
                glActiveTexture(GL_TEXTURE0 + idx);
                glBindTexture(GL_TEXTURE_2D, 0);
                glDisable(GL_TEXTURE_2D);
            }
        }
        resetCurAniShader();
        glActiveTexture(GL_TEXTURE0);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_LIGHT0);
    }
    gl_LoadBackgrounds(GetDlgItem(gP.hMain, IDC_LISTBOX), FALSE);

    gP.bRedraw = TRUE;
    gl_DrawScene();
}


            Mobj_ReportError("No animated backgrounds available.\nBackground animation disabled.");
            gl_LoadBackgrounds(hList, FALSE);
            return FALSE;


            // Create ListView to select texture from.
            dwStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_NOCOLUMNHEADER;
            hCtrl = CreateWindowEx(0, WC_LISTVIEW, $NULL, dwStyle, dpi(ClientW - 127), dpi(229+20), dpi(120), dpi(120),  gP.hMain, (HMENU)IDC_LISTBOX, gP.hInstance, NULL);
            if (hCtrl) {
                SendMessage(hCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_AUTOSIZECOLUMNS);
                lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
                GetClientRect(hCtrl, &rc);
                lvc.cx = rc.right; // Column width
                lvc.fmt = LVCFMT_LEFT;
                lvc.pszText = $NULL;
                ListView_InsertColumn(hCtrl, 0, &lvc);

                gl_LoadBackgrounds(hCtrl, FALSE);
            }
« Last Edit: September 09, 2019, 08:43:24 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)