Changeset 1344

Show
Ignore:
Timestamp:
01/10/08 15:31:35 (9 months ago)
Author:
calvin
Message:

machine right click help

Location:
trunk/src/buzelib
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/buzelib/MachineView.cpp

    r1343 r1344  
    896896 
    897897    menu.InsertMenu(-1, MF_BYPOSITION|MF_POPUP, (UINT_PTR)mixdownMenu.m_hMenu, "Render Output"); 
    898  
    899         pluginloader* loader=machine->loader; 
    900         assert(loader); 
    901  
    902 /*      if (loader && loader->getHelpFile().length()>0) { 
    903 //              menu.InsertMenu(-1, MF_BYPOSITION|MF_SEPARATOR); 
    904                 menu.InsertMenu(-1, MF_BYPOSITION|MF_STRING, (UINT_PTR)ID_MACHINE_HELP, "Help"); 
    905         } 
    906 */ 
    907         CMenu patternMenu; 
    908         patternMenu.CreatePopupMenu(); 
    909  
    910898        // TODO: find a similar way to returning commands and subcommands 
    911899 
     
    948936                                menu.InsertMenu(-1, MF_BYPOSITION|MF_STRING, (UINT_PTR)(ID_MACHINECOMMANDS+i), cmdstr.c_str()); 
    949937                } 
     938        } 
     939 
     940        if (singleSelect && mainFrame->getMachineHelpFile(machine->loader).length()>0) { 
     941                menu.InsertMenu(-1, MF_BYPOSITION|MF_SEPARATOR); 
     942                menu.InsertMenu(-1, MF_BYPOSITION|MF_STRING, (UINT_PTR)ID_MACHINE_HELP, "Help"); 
    950943        } 
    951944 
  • trunk/src/buzelib/MainFrm.cpp

    r1343 r1344  
    968968 
    969969        document->updateAllViews(0, UpdateSelectedMachine, selectedMachine); 
    970 /*      if (machineView.getViews() > 0) 
    971                 machineView.getView(0)->invalidateMachines();*/ 
    972970        return 0; 
    973971} 
     
    978976} 
    979977 
     978std::string findHelpExtension(std::string basePath, std::string name) { 
     979        struct stat st; 
     980        std::string temp; 
     981 
     982        #define tryHelpFile(ext) temp = basePath + name + ext; if (stat(temp.c_str(), &st) == 0) return temp 
     983        tryHelpFile(".html"); 
     984        tryHelpFile(".htm"); 
     985        tryHelpFile(".txt"); 
     986        tryHelpFile(".mht"); 
     987        tryHelpFile(".rtf"); 
     988        return ""; 
     989} 
     990 
     991extern std::string hexencode(const std::string& input); 
     992 
     993std::string CMainFrame::getMachineHelpFile(zzub::pluginloader* loader) { 
     994        std::string uri = loader->plugin_info->uri; 
     995        std::string pluginName = player->getBuzzName(uri); 
     996        std::string fileName; 
     997        if (pluginName == "") { 
     998                fileName = hexencode(uri); 
     999                pluginName = uri; 
     1000        } else 
     1001                fileName = pluginName; 
     1002 
     1003        std::string temp; 
     1004         
     1005        #define tryHelpDirectory(dir) temp = findHelpExtension(dir, fileName); if (temp != "") return temp 
     1006 
     1007        tryHelpDirectory("Gear\\Native\\"); 
     1008        tryHelpDirectory("Gear\\Effects\\"); 
     1009        tryHelpDirectory("Gear\\Generators\\"); 
     1010        return ""; 
     1011} 
     1012 
    9801013LRESULT CMainFrame::OnMachineHelp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { 
    981         return 0; 
    982         /* 
    983         metaplugin* machine=getSelectedMachine(0); 
     1014        metaplugin* machine = document->getSelectedMachine(0); 
    9841015        if (!machine) return 0; 
    985         pluginloader* loader=player->getMachineLoader(machine->getLoaderName()); 
    986         if (!loader) return 0; 
    987         loader->selectPlugin(machine->pluginName); 
    988         const std::string& helpFile=loader->getHelpFile(); 
    989  
    990         MessageBox(helpFile.c_str(), "Help"); 
    991         return 0;*/ 
     1016 
     1017        std::string helpFile = getMachineHelpFile(machine->loader); 
     1018        if (helpFile.length() != 0) { 
     1019                int result = (int)ShellExecute(m_hWnd, "open", helpFile.c_str(), NULL, NULL, SW_SHOWNORMAL);  
     1020                if (result < 33) helpFile = ""; 
     1021        } 
     1022        if (helpFile.length() == 0) { 
     1023                MessageBox("Sorry, no help for this machine.", programName); 
     1024        } 
     1025        return 0; 
    9921026} 
    9931027 
     
    10421076 
    10431077LRESULT CMainFrame::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { 
    1044 /*      if (frame.m_hWnd) { 
    1045                 CFrameWindowImpl<CMainFrame>::OnSize(uMsg, wParam, lParam, bHandled); 
    1046                 frame.setDockSize(DockSplitTab::dockLEFT, 250); 
    1047                 frame.updateLayout(); 
    1048         }*/ 
    10491078        return 0; 
    10501079} 
     
    10751104        document = 0; 
    10761105 
    1077         // DestroyWindow(); 
    1078         // defwindowproc calls destroywindow?? 
    10791106        return DefWindowProc(WM_CLOSE, wParam, lParam); 
    10801107} 
  • trunk/src/buzelib/MainFrm.h

    r1343 r1344  
    569569        void mixdownSong(zzub::metaplugin* plugin, zzub::metaplugin* rec); 
    570570 
    571         // audio driving 
    572  
    573         //void configureAudioDriver(); 
    574  
    575571        // parameter properties 
    576572        void setMachineParameterHidden(zzub::metaplugin* loader, int group, int track, int column, bool state); 
     
    583579        void setPatternToolbarVisibility(int nIndex, WORD wID, BOOL bVisible, BOOL bSave = TRUE, BOOL bUpdate = TRUE); 
    584580        void setMainFrameToolbarVisibility(int nIndex, WORD wID, BOOL bVisible, BOOL bSave = TRUE, BOOL bUpdate = TRUE); 
     581 
     582        std::string getMachineHelpFile(zzub::pluginloader* loader); 
     583 
    585584}; 
    586585