Changeset 1313

Show
Ignore:
Timestamp:
11/13/07 01:50:24 (11 months ago)
Author:
calvin
Message:

zonajs patches: "Save", machine view scale is a regular configuration setting.
and some other minor fixes

Location:
trunk/src/buzelib
Files:
8 modified

Legend:

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

    r1307 r1313  
    325325} 
    326326 
    327 void CConfiguration::setMachineSkinVisibility(std::string uri, bool state) { 
     327void CConfiguration::setMachineSkinVisibility(bool state) { 
    328328        setConfigNumber("Settings", "MachineSkin", state?1:0); 
    329329} 
    330330 
    331 bool CConfiguration::getMachineSkinVisibility(std::string uri) { 
     331bool CConfiguration::getMachineSkinVisibility() { 
    332332        DWORD dw = 1; 
    333333        getConfigNumber("Settings", "MachineSkin", &dw); 
     
    354354        return dw; 
    355355} 
     356 
     357void CConfiguration::setMachineScale(double sc) { 
     358        std::string str; 
     359        char pc[10]; 
     360        sprintf(pc, "%.6f", sc); 
     361        str = pc; 
     362        setConfigString("Settings", "MachineScale", str); 
     363} 
     364 
     365double CConfiguration::getMachineScale() { 
     366        string str; 
     367        if (!getConfigString("Settings", "MachineScale", &str)) 
     368                return 1.0; 
     369        return atof(str.c_str()); 
     370} 
  • trunk/src/buzelib/BuzeConfiguration.h

    r1307 r1313  
    5454        int getMachinePatternLength(std::string uri); 
    5555 
    56         void setMachineSkinVisibility(std::string uri, bool state); 
    57         bool getMachineSkinVisibility(std::string uri); 
     56        void setMachineSkinVisibility(bool state); 
     57        bool getMachineSkinVisibility(); 
    5858 
    5959        void setExternalWaveEditor(std::string cmd); 
     
    6565        int getSequencerStepLow(); 
    6666         
     67        void setMachineScale(double sc); 
     68        double getMachineScale(); 
    6769 
    6870}; 
  • trunk/src/buzelib/MachineView.cpp

    r1312 r1313  
    4949        mbuttonState = false; 
    5050        isLButtonDown = false; 
    51         scale = 1.0; 
     51        scale = _Module.configuration->getMachineScale(); 
    5252        moveType = MachineViewMoveNothing; 
    5353        SetRect(&prevDragRect, -1, -1, -1, -1); 
     
    170170 
    171171LRESULT CMachineView::OnFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { 
     172        scale = _Module.configuration->getMachineScale(); 
    172173        mainFrame->setCurrentFocus(m_hWnd); 
    173174        moveType = MachineViewMoveNothing; 
     
    17231724 
    17241725 
     1726 
  • trunk/src/buzelib/MainFrm.cpp

    r1312 r1313  
    16031603} 
    16041604 
     1605LRESULT CMainFrame::saveFile(std::string filename) { 
     1606        char tempPath[MAX_PATH]; 
     1607        char tempFile[MAX_PATH]; 
     1608        GetTempPath(MAX_PATH, tempPath); 
     1609        GetTempFileName(tempPath, "3zE", 0, tempFile); 
     1610        debug("Save temporary " + (std::string)tempFile); 
     1611 
     1612        bool state = false; 
     1613        string ext = ""; 
     1614        size_t lp = filename.find_last_of('.'); 
     1615        if (lp!=string::npos) { 
     1616                ext = filename.substr(lp+1); 
     1617                transform(ext.begin(), ext.end(), ext.begin(), tolower); 
     1618        } 
     1619        if (ext=="bmx" || ext=="bmw") { 
     1620                zzub::file_outstream outf; 
     1621 
     1622                state = outf.create(tempFile); 
     1623                if (state) { 
     1624                        BuzzWriter writer(&outf); 
     1625                        state = writer.writePlayer(player, vector<metaplugin*>(), true); 
     1626                        outf.close(); 
     1627                } 
     1628        } else { 
     1629                CcmWriter writer; 
     1630                state = writer.save(tempFile, player); 
     1631        } 
     1632 
     1633        if (state) { 
     1634                debug("Delete original " + filename); 
     1635                 
     1636                if (PathFileExists(filename.c_str())) 
     1637                        state = DeleteFile(filename.c_str()) != 0; 
     1638 
     1639                debug("Rename temporary to original"); 
     1640                if (state) { 
     1641                        state = MoveFile(tempFile, filename.c_str()); 
     1642                } 
     1643 
     1644                debug("Delete temporary"); 
     1645                DeleteFile(tempFile); 
     1646        } 
     1647 
     1648        if (state) { 
     1649                // update window text 
     1650                document->setCurrentFile(filename); 
     1651                setWindowTitle(document->currentFileName.c_str()); 
     1652                document->lastSaveUndoPosition=document->undoManager.getPosition(); 
     1653                setMostRecent(filename); 
     1654        } else { 
     1655                MessageBox("Cannot save file!", filename.c_str()); 
     1656                debug("Save failed!"); 
     1657        } 
     1658 
     1659        return 0; 
     1660} 
     1661 
    16051662LRESULT CMainFrame::OnFileSave(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled) { 
    1606         return OnFileSaveAs(0, 0, 0, bHandled); 
     1663        if(document->currentFileName.size() && document->currentFileName != "Untitled") 
     1664                return saveFile(document->currentDirectory + "\\" + document->currentFileName + "." + document->currentExtension); 
     1665        else 
     1666                return OnFileSaveAs(0, 0, 0, bHandled); 
    16071667} 
    16081668 
    16091669LRESULT CMainFrame::OnFileSaveAs(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { 
     1670 
    16101671        OPENFILENAME ofn;       // common dialog box structure 
    16111672        char szFile[260];       // buffer for file name 
     
    16391700        if (GetSaveFileName(&ofn)!=TRUE) return 1; 
    16401701 
    1641         string filename = ofn.lpstrFile; 
    1642         string ext = ""; 
    1643         size_t lp = filename.find_last_of('.'); 
    1644         if (lp!=string::npos) { 
    1645                 ext = filename.substr(lp+1); 
    1646                 transform(ext.begin(), ext.end(), ext.begin(), tolower); 
    1647         } 
    1648  
    1649         char tempPath[MAX_PATH]; 
    1650         char tempFile[MAX_PATH]; 
    1651         GetTempPath(MAX_PATH, tempPath); 
    1652         GetTempFileName(tempPath, "3zE", 0, tempFile); 
    1653         debug("Save temporary " + (std::string)tempFile); 
    1654  
    1655         bool state = false; 
    1656         if (ext=="bmx" || ext=="bmw") { 
    1657                 zzub::file_outstream outf; 
    1658  
    1659                 state = outf.create(tempFile); 
    1660                 if (state) { 
    1661                         BuzzWriter writer(&outf); 
    1662                         state = writer.writePlayer(player, vector<metaplugin*>(), true); 
    1663                         outf.close(); 
    1664                 } 
    1665         } else { 
    1666                 CcmWriter writer; 
    1667                 state = writer.save(tempFile, player); 
    1668         } 
    1669  
    1670         if (state) { 
    1671                 debug("Delete original " + (std::string)ofn.lpstrFile); 
    1672                  
    1673                 if (PathFileExists(ofn.lpstrFile)) 
    1674                         state = DeleteFile(ofn.lpstrFile) != 0; 
    1675  
    1676                 debug("Rename temporary to original"); 
    1677                 if (state) { 
    1678                         state = MoveFile(tempFile, ofn.lpstrFile); 
    1679                 } 
    1680  
    1681                 debug("Delete temporary"); 
    1682                 DeleteFile(tempFile); 
    1683         } 
    1684  
    1685         if (state) { 
    1686                 // update window text 
    1687                 document->setCurrentFile(ofn.lpstrFile); 
    1688                 setWindowTitle(document->currentFileName.c_str()); 
    1689                 document->lastSaveUndoPosition=document->undoManager.getPosition(); 
    1690         } else { 
    1691                 MessageBox("Cannot save file!", ofn.lpstrFile); 
    1692                 debug("Save failed!"); 
    1693         } 
    1694  
    1695         return 0; 
     1702        return saveFile(ofn.lpstrFile); 
    16961703} 
    16971704 
     
    27532760 
    27542761MachineSkin* CMainFrame::getSkin(std::string uri) { 
    2755         if (!_Module.configuration->getMachineSkinVisibility(uri)) return 0; // Skin visibility setting 
     2762        if (!_Module.configuration->getMachineSkinVisibility()) return 0; // Skin visibility setting 
    27562763 
    27572764        map<string, MachineSkin>::iterator i = skins.find(uri); 
  • trunk/src/buzelib/MainFrm.h

    r1312 r1313  
    498498        bool openSongFromFile(bool clearAll); 
    499499        bool openSongFromFile(std::string fileName, bool clearAll); 
     500        LRESULT saveFile(std::string filename); 
    500501 
    501502        void updateTick(); 
     
    667668                mainFrame = 0; 
    668669        } 
    669         std::string serialize() {  
    670                 char pc[64]; 
    671                 sprintf(pc, "%.6f", data->scale); 
    672                 return pc;  
    673         } 
     670        std::string serialize() { return ""; } 
    674671        CMachineView* deserialize(std::string str) { 
    675                 CMachineView* view = new CMachineView(mainFrame, mainFrame);  
    676                 double scale = atof(str.c_str()); 
    677                 if (scale != 0.0) 
    678                         view->scale = scale; 
     672                CMachineView* view = new CMachineView(mainFrame, mainFrame); 
    679673                return view; 
    680674        } 
  • trunk/src/buzelib/PatternView.cpp

    r1312 r1313  
    2828        { 12, 3 }, 
    2929        { 12, 4 }, 
     30        { 16, 3 }, 
    3031        { 16, 4 }, 
    3132        { 16, 8 }, 
     
    3334        { 18, 6 }, 
    3435        { 18, 9 }, 
     36        { 24, 4 }, 
     37        { 24, 6 }, 
     38        { 24, 8 }, 
    3539}; 
    3640 
  • trunk/src/buzelib/Preferences/AudioDriverPreferencesView.cpp

    r1292 r1313  
    174174        int nearest = -1; 
    175175        int nearestDist = UINT_MAX; 
    176         for (int i = 0; device->rates.size(); i++) { 
     176        for (int i = 0; i < device->rates.size(); i++) { 
    177177                unsigned int testRate = device->rates[i]; 
    178178                if (testRate == 0) break; 
  • trunk/src/buzelib/buze.rc

    r1307 r1313  
    168168        MENUITEM "&New\tCtrl+N",                ID_FILE_NEW 
    169169        MENUITEM "&Open...\tCtrl+O",            ID_FILE_OPEN 
    170         MENUITEM "&Save As\tCtrl+S",            ID_FILE_SAVE 
     170        MENUITEM "&Save\tCtrl+S",               ID_FILE_SAVE 
    171171        MENUITEM "Save &As...",                 ID_FILE_SAVE_AS 
    172172        MENUITEM SEPARATOR 
     
    12461246 
    12471247 
     1248