documenting, fixing update feature

This commit is contained in:
dborth 2009-04-01 05:48:01 +00:00
parent 21032905b9
commit 0e1c0985f9
4 changed files with 117 additions and 29 deletions

View File

@ -80,8 +80,8 @@ devicecallback (void *arg)
} }
} }
//InitializeNetwork(SILENT); InitializeNetwork(SILENT);
//UpdateCheck(); UpdateCheck();
#else #else
if(isMounted[METHOD_SD_SLOTA]) if(isMounted[METHOD_SD_SLOTA])
{ {

View File

@ -14,11 +14,9 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <ogcsys.h> #include <ogcsys.h>
#include <network.h> #include <network.h>
#include <ogc/lwp_watchdog.h> #include <ogc/lwp_watchdog.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/errno.h> #include <sys/errno.h>
#include <fcntl.h> #include <fcntl.h>
@ -417,6 +415,7 @@ bool http_request(const char *url, FILE * hfile, u8 * buffer,
ShowProgress("Downloading...", (content_length - bytesLeft), ShowProgress("Downloading...", (content_length - bytesLeft),
content_length); content_length);
} }
CancelAction();
} }
if (!b || !res) if (!b || !res)

View File

@ -57,8 +57,11 @@ static int mapMenuCtrl = 0;
static int mapMenuCtrlNES = 0; static int mapMenuCtrlNES = 0;
static lwp_t guithread = LWP_THREAD_NULL; static lwp_t guithread = LWP_THREAD_NULL;
static bool guiHalt = true;
static lwp_t progressthread = LWP_THREAD_NULL; static lwp_t progressthread = LWP_THREAD_NULL;
#ifdef HW_RVL
static lwp_t updatethread = LWP_THREAD_NULL;
#endif
static bool guiHalt = true;
static int showProgress = 0; static int showProgress = 0;
static char progressTitle[100]; static char progressTitle[100];
@ -66,6 +69,13 @@ static char progressMsg[200];
static int progressDone = 0; static int progressDone = 0;
static int progressTotal = 0; static int progressTotal = 0;
/****************************************************************************
* ResumeGui
*
* Signals the GUI thread to start, and resumes the thread. This is called
* after finishing the removal/insertion of new elements, and after initial
* GUI setup.
***************************************************************************/
static void static void
ResumeGui() ResumeGui()
{ {
@ -73,6 +83,14 @@ ResumeGui()
LWP_ResumeThread (guithread); LWP_ResumeThread (guithread);
} }
/****************************************************************************
* HaltGui
*
* Signals the GUI thread to stop, and waits for GUI thread to stop
* This is necessary whenever removing/inserting new elements into the GUI.
* This eliminates the possibility that the GUI is in the middle of accessing
* an element that is being changed.
***************************************************************************/
static void static void
HaltGui() HaltGui()
{ {
@ -85,8 +103,10 @@ HaltGui()
/**************************************************************************** /****************************************************************************
* WindowPrompt * WindowPrompt
*
* Displays a prompt window to user, with information, an error message, or
* presenting a user with a choice
***************************************************************************/ ***************************************************************************/
int int
WindowPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label) WindowPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label)
{ {
@ -187,8 +207,32 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, const ch
return choice; return choice;
} }
#ifdef HW_RVL
/****************************************************************************
* EmulatorUpdate
*
* Prompts for confirmation, and downloads/installs updates
***************************************************************************/
static void *
EmulatorUpdate (void *arg)
{
sleep(5);
bool installUpdate = WindowPrompt(
"Update Available",
"An update is available!",
"Update now",
"Update later");
if(installUpdate)
if(DownloadUpdate())
ExitRequested = 1;
return NULL;
}
#endif
/**************************************************************************** /****************************************************************************
* UpdateGUI * UpdateGUI
*
* Primary thread to allow GUI to respond to state changes, and draws GUI
***************************************************************************/ ***************************************************************************/
/*static u32 arena1mem = 0; /*static u32 arena1mem = 0;
@ -234,14 +278,8 @@ UpdateGUI (void *arg)
#ifdef HW_RVL #ifdef HW_RVL
if(updateFound) if(updateFound)
{ {
updateFound = WindowPrompt( updateFound = false;
"Update Available", LWP_CreateThread (&updatethread, EmulatorUpdate, NULL, NULL, 0, 70);
"An update is available!",
"Update now",
"Update later");
if(updateFound)
if(DownloadUpdate())
ExitRequested = 1;
} }
#endif #endif
@ -268,8 +306,11 @@ UpdateGUI (void *arg)
/**************************************************************************** /****************************************************************************
* ProgressWindow * ProgressWindow
*
* Opens a window, which displays progress to the user. Can either display a
* progress bar showing % completion, or a throbber that only shows that an
* action is in progress.
***************************************************************************/ ***************************************************************************/
static void static void
ProgressWindow(char *title, char *msg) ProgressWindow(char *title, char *msg)
{ {
@ -385,8 +426,9 @@ static void * ProgressThread (void *arg)
/**************************************************************************** /****************************************************************************
* InitGUIThread * InitGUIThread
*
* Startup GUI threads
***************************************************************************/ ***************************************************************************/
void void
InitGUIThreads() InitGUIThreads()
{ {
@ -395,11 +437,12 @@ InitGUIThreads()
} }
/**************************************************************************** /****************************************************************************
* Progress Bar * CancelAction
* *
* Show the user what's happening * Signals the GUI progress window thread to halt, and waits for it to
* finish. Prevents multiple progress window events from interfering /
* overriding each other.
***************************************************************************/ ***************************************************************************/
void void
CancelAction() CancelAction()
{ {
@ -410,6 +453,12 @@ CancelAction()
usleep(50); usleep(50);
} }
/****************************************************************************
* ShowProgress
*
* Updates the variables used by the progress window for drawing a progress
* bar. Also resumes the progress window thread if it is suspended.
***************************************************************************/
void void
ShowProgress (const char *msg, int done, int total) ShowProgress (const char *msg, int done, int total)
{ {
@ -432,6 +481,12 @@ ShowProgress (const char *msg, int done, int total)
LWP_ResumeThread (progressthread); LWP_ResumeThread (progressthread);
} }
/****************************************************************************
* ShowAction
*
* Shows that an action is underway. Also resumes the progress window thread
* if it is suspended.
***************************************************************************/
void void
ShowAction (const char *msg) ShowAction (const char *msg)
{ {
@ -461,6 +516,11 @@ void InfoPrompt(const char *msg)
WindowPrompt("Information", msg, "OK", NULL); WindowPrompt("Information", msg, "OK", NULL);
} }
/****************************************************************************
* AutoSave
*
* Automatically saves RAM/state when returning from in-game to the menu
***************************************************************************/
void AutoSave() void AutoSave()
{ {
if (GCSettings.AutoSave == 1) if (GCSettings.AutoSave == 1)
@ -482,6 +542,12 @@ void AutoSave()
} }
} }
/****************************************************************************
* OnScreenKeyboard
*
* Opens an on-screen keyboard window, with the data entered being stored
* into the specified variable.
***************************************************************************/
static void OnScreenKeyboard(char * var, u16 maxlen) static void OnScreenKeyboard(char * var, u16 maxlen)
{ {
int save = -1; int save = -1;
@ -556,6 +622,12 @@ static void OnScreenKeyboard(char * var, u16 maxlen)
ResumeGui(); ResumeGui();
} }
/****************************************************************************
* SettingWindow
*
* Opens a new window, with the specified window element appended. Allows
* for a customizable prompted setting.
***************************************************************************/
static int static int
SettingWindow(const char * title, GuiWindow * w) SettingWindow(const char * title, GuiWindow * w)
{ {
@ -642,7 +714,6 @@ SettingWindow(const char * title, GuiWindow * w)
* *
* THIS MUST NOT BE REMOVED OR DISABLED IN ANY DERIVATIVE WORK * THIS MUST NOT BE REMOVED OR DISABLED IN ANY DERIVATIVE WORK
***************************************************************************/ ***************************************************************************/
static void WindowCredits(void * ptr) static void WindowCredits(void * ptr)
{ {
if(btnLogo->GetState() != STATE_CLICKED) if(btnLogo->GetState() != STATE_CLICKED)
@ -774,8 +845,10 @@ static void WindowCredits(void * ptr)
/**************************************************************************** /****************************************************************************
* MenuGameSelection * MenuGameSelection
*
* Displays a list of games on the specified load device, and allows the user
* to browse and select from this list.
***************************************************************************/ ***************************************************************************/
static int MenuGameSelection() static int MenuGameSelection()
{ {
#ifdef HW_RVL #ifdef HW_RVL
@ -924,6 +997,11 @@ static int MenuGameSelection()
return menu; return menu;
} }
/****************************************************************************
* ControllerWindowUpdate
*
* Callback for controller window. Responds to clicks on window elements.
***************************************************************************/
static void ControllerWindowUpdate(void * ptr, int dir) static void ControllerWindowUpdate(void * ptr, int dir)
{ {
GuiButton * b = (GuiButton *)ptr; GuiButton * b = (GuiButton *)ptr;
@ -941,9 +1019,19 @@ static void ControllerWindowUpdate(void * ptr, int dir)
} }
} }
/****************************************************************************
* ControllerWindowLeftClick / ControllerWindowRightsClick
*
* Callbacks for controller window arrows. Responds arrow clicks.
***************************************************************************/
static void ControllerWindowLeftClick(void * ptr) { ControllerWindowUpdate(ptr, -1); } static void ControllerWindowLeftClick(void * ptr) { ControllerWindowUpdate(ptr, -1); }
static void ControllerWindowRightClick(void * ptr) { ControllerWindowUpdate(ptr, +1); } static void ControllerWindowRightClick(void * ptr) { ControllerWindowUpdate(ptr, +1); }
/****************************************************************************
* ControllerWindow
*
* Opens a window to allow the user to select the controller to be used.
***************************************************************************/
static void ControllerWindow() static void ControllerWindow()
{ {
GuiWindow * w = new GuiWindow(300,250); GuiWindow * w = new GuiWindow(300,250);
@ -1004,8 +1092,9 @@ static void ControllerWindow()
/**************************************************************************** /****************************************************************************
* MenuGame * MenuGame
*
* Menu displayed when returning to the menu from in-game.
***************************************************************************/ ***************************************************************************/
static int MenuGame() static int MenuGame()
{ {
int menu = MENU_NONE; int menu = MENU_NONE;
@ -1349,8 +1438,9 @@ static int MenuGame()
/**************************************************************************** /****************************************************************************
* MenuGameSaves * MenuGameSaves
*
* Allows the user to load or save progress.
***************************************************************************/ ***************************************************************************/
static int MenuGameSaves(int action) static int MenuGameSaves(int action)
{ {
int menu = MENU_NONE; int menu = MENU_NONE;
@ -1620,6 +1710,9 @@ static int MenuGameSaves(int action)
/**************************************************************************** /****************************************************************************
* MenuGameCheats * MenuGameCheats
*
* Displays a list of cheats available, and allows the user to enable/disable
* them.
***************************************************************************/ ***************************************************************************/
/* /*
static int MenuGameCheats() static int MenuGameCheats()
@ -1946,7 +2039,6 @@ static int MenuSettings()
/**************************************************************************** /****************************************************************************
* MenuSettingsMappings * MenuSettingsMappings
***************************************************************************/ ***************************************************************************/
static int MenuSettingsMappings() static int MenuSettingsMappings()
{ {
int menu = MENU_NONE; int menu = MENU_NONE;
@ -2221,7 +2313,6 @@ static int MenuSettingsMappingsController()
/**************************************************************************** /****************************************************************************
* ButtonMappingWindow * ButtonMappingWindow
***************************************************************************/ ***************************************************************************/
static u32 static u32
ButtonMappingWindow() ButtonMappingWindow()
{ {
@ -2469,7 +2560,6 @@ static int MenuSettingsMappingsMap()
/**************************************************************************** /****************************************************************************
* MenuSettingsVideo * MenuSettingsVideo
***************************************************************************/ ***************************************************************************/
static void ScreenZoomWindowUpdate(void * ptr, float amount) static void ScreenZoomWindowUpdate(void * ptr, float amount)
{ {
GuiButton * b = (GuiButton *)ptr; GuiButton * b = (GuiButton *)ptr;

View File

@ -18,7 +18,6 @@
#include "unzip.h" #include "unzip.h"
#include "miniunz.h" #include "miniunz.h"
#include "fceugx.h" #include "fceugx.h"
#include "menu.h" #include "menu.h"
#include "fileop.h" #include "fileop.h"
@ -83,8 +82,8 @@ void UpdateCheck()
verMinor >= 0 && verMinor <= 9 && verMinor >= 0 && verMinor <= 9 &&
verPoint >= 0 && verPoint <= 9) && verPoint >= 0 && verPoint <= 9) &&
(verMajor > curMajor || (verMajor > curMajor ||
verMinor > curMinor || (verMajor == curMajor && verMinor > curMinor) ||
verPoint > curPoint)) (verMajor == curMajor && verMinor == curMinor && verPoint > curPoint)))
{ {
item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND); item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND);
if(item) if(item)