Changeset 38 for trunk


Ignore:
Timestamp:
09/01/07 20:56:05 (8 years ago)
Author:
guyru
Message:

check for updates support

Location:
trunk/OpenYahtzee
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/OpenYahtzee/TODO

    r34 r38  
    11TODO FILE 
     2 
     3DONE: 
    24-cleanup code at the end of every scoring button 
    35-cleanup code for the icon settings for the dialogs/frames 
  • trunk/OpenYahtzee/openyahtzee.kdevses

    r37 r38  
    22<!DOCTYPE KDevPrjSession> 
    33<KDevPrjSession> 
    4  <DocsAndViews NumberOfDocuments="13" > 
     4 <DocsAndViews NumberOfDocuments="14" > 
    55  <Doc0 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/SettingsDB.h" > 
    66   <View0 Type="Source" /> 
    77  </Doc0> 
    88  <Doc1 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/openyahtzee.cpp" > 
    9    <View0 line="30" Type="Source" /> 
     9   <View0 Type="Source" /> 
    1010  </Doc1> 
    1111  <Doc2 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/MainFrame.cpp" > 
    12    <View0 line="539" Type="Source" /> 
     12   <View0 line="53" Type="Source" /> 
    1313  </Doc2> 
    1414  <Doc3 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/ObjectsID.h" > 
    15    <View0 Type="Source" /> 
     15   <View0 line="29" Type="Source" /> 
    1616  </Doc3> 
    1717  <Doc4 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/MainFrame.h" > 
    18    <View0 line="71" Type="Source" /> 
     18   <View0 line="51" Type="Source" /> 
    1919  </Doc4> 
    2020  <Doc5 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/DBwrapper.h" > 
     
    2525  </Doc6> 
    2626  <Doc7 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/SettingsDialog.cpp" > 
    27    <View0 Type="Source" /> 
     27   <View0 line="27" Type="Source" /> 
    2828  </Doc7> 
    2929  <Doc8 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/SettingsDB.cpp" > 
     
    3434  </Doc9> 
    3535  <Doc10 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/HighScoreDialog.cpp" > 
    36    <View0 line="32" Type="Source" /> 
     36   <View0 Type="Source" /> 
    3737  </Doc10> 
    3838  <Doc11 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/Icon.h" > 
    39    <View0 line="34" Type="Source" /> 
     39   <View0 Type="Source" /> 
    4040  </Doc11> 
    4141  <Doc12 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/openyahtzee.rc" > 
    42    <View0 line="19" Type="Source" /> 
     42   <View0 Type="Source" /> 
    4343  </Doc12> 
     44  <Doc13 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/HighScoreDialog.h" > 
     45   <View0 line="0" Type="Source" /> 
     46  </Doc13> 
    4447 </DocsAndViews> 
    4548 <pluginList> 
  • trunk/OpenYahtzee/src/MainFrame.cpp

    r37 r38  
    4747 
    4848//include the icon file 
    49 #ifdef WIN32 
    50         #include "icon32.xpm" 
    51 #else 
    52         #include "icon.xpm" 
    53 #endif 
     49#include "Icon.h" 
    5450 
    5551//default values 
    5652#define SPACE_SIZE 1 
    5753#define DEF_HIGHSCORESIZE 16 
     54#define OY_VERSION "1.6.0" 
    5855 
    5956MainFrame::MainFrame(const wxString& title, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE) 
     
    6158{ 
    6259        //give the frame an icon 
    63 #ifdef WIN32 
    64         SetIcon(wxIcon(icon32_xpm)); 
    65 #else 
    66         SetIcon(wxIcon(icon_xpm)); 
    67 #endif 
     60        SetIcon(wxIcon(ICON)); 
     61 
    6862 
    6963        std::ostringstream sstr; 
     
    10296         
    10397        //insert menu items into menu Help 
     98        helpMenu->Append(ID_CHECK_FOR_UPDATES, wxT("&Check for Updates"), 
     99                        wxT("Check for new version of the game via the web")); 
    104100        helpMenu->Append(wxID_ABOUT, wxT("&About...\tF1"), 
    105101                        wxT("Show about dialog")); 
     
    224220        Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnQuit)); 
    225221        Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnAbout)); 
     222        Connect(ID_CHECK_FOR_UPDATES, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnCheckForUpdates)); 
    226223        Connect(ID_NEWGAME, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnNewGame)); 
    227224        Connect(ID_UNDO, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnUndo)); 
     
    256253        wxString msg; 
    257254        wxString sqliteversion = wxString(sqlite3_version,wxConvUTF8); 
    258         msg.Printf(wxT("OpenYahtzee 1.6\nCopyright (C) 2006 by Guy Rutenberg\n\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\n\nOpenYahtzee was built against:\nwxWidgets %i.%i\n"),wxMAJOR_VERSION,wxMINOR_VERSION); 
     255        msg.Printf(wxT("OpenYahtzee %s\nCopyright (C) 2006 by Guy Rutenberg\n\nThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\n\nOpenYahtzee was built against:\nwxWidgets %i.%i\n"),wxT(OY_VERSION),wxMAJOR_VERSION,wxMINOR_VERSION); 
    259256        msg += wxT("SQLite ") + sqliteversion; 
    260257                 
    261258        wxMessageBox(msg, wxT("About Yahtzee"), wxOK | wxICON_INFORMATION, this); 
     259} 
     260 
     261void MainFrame::OnCheckForUpdates (wxCommandEvent& event){ 
     262         
     263        wxString path; 
     264        wxPathList path_list; 
     265        wxString link = wxT("http://openyahtzee.sourceforge.net/update.php?version="); 
     266         
     267        link += wxT(OY_VERSION); 
     268 
     269        if (!wxLaunchDefaultBrowser(link)){ 
     270                 //if builtin function doesn't work search for couple of browsers manually. see 
     271                 //http://linux-consulting.buanzo.com.ar/2006/05/wxwidgets-code-to-launch-browser.html 
     272 
     273                // variable declarations 
     274                wxArrayString browsers; 
     275                wxPathList path_list; 
     276                bool BrowserWasFound = false; 
     277                unsigned int i = 0; 
     278                wxString path; 
     279 
     280                // Add directories to wxPathList's search path from PATH environment variable 
     281                path_list.AddEnvList(wxT("PATH")); 
     282                 
     283                // Add browsers filenames. First item = most priority 
     284                browsers.Add(wxT("firefox")); 
     285                browsers.Add(wxT("firefox-bin")); 
     286                browsers.Add(wxT("mozilla")); 
     287                browsers.Add(wxT("mozilla-bin")); 
     288                browsers.Add(wxT("opera")); 
     289                browsers.Add(wxT("konqueror")); 
     290                browsers.Add(wxT("epiphany")); 
     291                 
     292                for (i = 0; i < browsers.GetCount(); i++) { 
     293                        path = path_list.FindAbsoluteValidPath(browsers[i]); 
     294                        if (path.IsEmpty()) { 
     295                                continue; 
     296                        } else { 
     297                                BrowserWasFound = true; 
     298                                break; 
     299                        } 
     300                } 
     301                 
     302                browsers.Clear(); 
     303                 
     304                if (BrowserWasFound) { 
     305                        path += wxT(" "); 
     306                        path += link; 
     307                        ::wxExecute(path); 
     308                } else { 
     309                        wxMessageBox(wxT("No browser has been found."),wxT("OpenYahtzee")); 
     310                } 
     311        } 
     312 
     313 
    262314} 
    263315 
  • trunk/OpenYahtzee/src/MainFrame.h

    r37 r38  
    5050        void OnShowHighscore (wxCommandEvent& event); 
    5151        void OnSettings (wxCommandEvent& event); 
     52        void OnCheckForUpdates (wxCommandEvent& event); 
    5253 
    5354        void OnRollButton (wxCommandEvent& event); 
  • trunk/OpenYahtzee/src/Makefile.am

    r35 r38  
    11bin_PROGRAMS = openyahtzee 
    22openyahtzee_SOURCES = openyahtzee.cpp MainFrame.cpp five.xpm four.xpm one.xpm \ 
    3                         six.xpm three.xpm two.xpm DBwrapper.cpp DBwrapper.h SettingsDB.cpp \ 
    4                         HighScoreTableDB.cpp HighScoreDialog.cpp SettingsDialog.cpp icon.xpm icon32.xpm 
     3                                six.xpm three.xpm two.xpm DBwrapper.cpp DBwrapper.h SettingsDB.cpp \ 
     4                                HighScoreTableDB.cpp HighScoreDialog.cpp SettingsDialog.cpp icon.xpm icon32.xpm \ 
     5        openyahtzee.rc 
    56 
    67# set the include path found by configure 
     
    1011 
    1112noinst_HEADERS = MainFrame.h ObjectsID.h SettingsDB.h HighScoreTableDB.h \ 
    12                         HighScoreDialog.h SettingsDialog.h Icon.h 
     13                                HighScoreDialog.h SettingsDialog.h Icon.h icon32.ico 
    1314 
    1415openyahtzee_LDFLAGS = `wx-config --libs` -lsqlite3 
  • trunk/OpenYahtzee/src/Makefile.in

    r35 r38  
    185185target_alias = @target_alias@ 
    186186openyahtzee_SOURCES = openyahtzee.cpp MainFrame.cpp five.xpm four.xpm one.xpm \ 
    187                         six.xpm three.xpm two.xpm DBwrapper.cpp DBwrapper.h SettingsDB.cpp \ 
    188                         HighScoreTableDB.cpp HighScoreDialog.cpp SettingsDialog.cpp icon.xpm icon32.xpm 
     187                                six.xpm three.xpm two.xpm DBwrapper.cpp DBwrapper.h SettingsDB.cpp \ 
     188                                HighScoreTableDB.cpp HighScoreDialog.cpp SettingsDialog.cpp icon.xpm icon32.xpm \ 
     189        openyahtzee.rc 
    189190 
    190191 
     
    194195# the library search path. 
    195196noinst_HEADERS = MainFrame.h ObjectsID.h SettingsDB.h HighScoreTableDB.h \ 
    196                         HighScoreDialog.h SettingsDialog.h Icon.h 
     197                                HighScoreDialog.h SettingsDialog.h Icon.h icon32.ico 
    197198 
    198199openyahtzee_LDFLAGS = `wx-config --libs` -lsqlite3 
  • trunk/OpenYahtzee/src/ObjectsID.h

    r20 r38  
    2828        ID_SHOWHIGHSCORE, 
    2929        ID_SETTINGS, 
     30        ID_CHECK_FOR_UPDATES, 
    3031         
    3132        ID_ACES, 
  • trunk/OpenYahtzee/src/openyahtzee.cpp

    r17 r38  
    2727#include "wx/wx.h" 
    2828#include "MainFrame.h" 
     29// #ifdef WIN32  
     30//      #include openyahtzee.rc 
     31// #endif 
    2932 
    3033 
Note: See TracChangeset for help on using the changeset viewer.