diff options
author | Chris Apers | 2004-02-05 14:20:51 +0000 |
---|---|---|
committer | Chris Apers | 2004-02-05 14:20:51 +0000 |
commit | b3a12d51e6ab7b6337b3a21e6b6cb8d40ddadbf9 (patch) | |
tree | c00d2b246f387d11999f2280aa1508d7e2ac7399 /backends | |
parent | 802a301a16ff3f9fe7f25a5a6c337319e27ce7b3 (diff) | |
download | scummvm-rg350-b3a12d51e6ab7b6337b3a21e6b6cb8d40ddadbf9.tar.gz scummvm-rg350-b3a12d51e6ab7b6337b3a21e6b6cb8d40ddadbf9.tar.bz2 scummvm-rg350-b3a12d51e6ab7b6337b3a21e6b6cb8d40ddadbf9.zip |
formMain
svn-id: r12740
Diffstat (limited to 'backends')
-rw-r--r-- | backends/PalmOS/Src/forms/formmain.cpp | 338 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/forms.h | 3 |
2 files changed, 340 insertions, 1 deletions
diff --git a/backends/PalmOS/Src/forms/formmain.cpp b/backends/PalmOS/Src/forms/formmain.cpp new file mode 100644 index 0000000000..124a94d8c8 --- /dev/null +++ b/backends/PalmOS/Src/forms/formmain.cpp @@ -0,0 +1,338 @@ +#include <PalmOS.h> + +#include "StarterRsc.h" +#include "start.h" +#include "skin.h" +#include "games.h" +#include "scumm_globals.h" + +#include "stdafx.h" +#include "engine.h" // version + +#include "formEditGame.h" +#include "formUtil.h" + +static UInt16 sknLastOn = skinButtonNone; + +static Err BeamMe() { + UInt16 cardNo; + LocalID dbID; + Err err; + + err = SysCurAppDatabase(&cardNo, &dbID); + if (dbID) + err = SendDatabase(0, dbID, "ScummVM.prc", "\nPlay your favorite LucasArts games"); + else + err = DmGetLastErr(); + + return err; +} + +/*********************************************************************** + * + * FUNCTION: MainFormInit + * + * DESCRIPTION: This routine initializes the MainForm form. + * + * PARAMETERS: frm - pointer to the MainForm form. + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void MainFormInit() +{ + SknApplySkin(); +} + +/*********************************************************************** + * + * FUNCTION: MainFormDoCommand + * + * DESCRIPTION: This routine performs the menu command specified. + * + * PARAMETERS: command - menu item id + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ + +static void MainFormAbout() { + FormPtr frmP; + FormLabelType *versionP; + + frmP = FrmInitForm(AboutForm); + versionP = FrmNewLabel(&frmP, 1120, gScummVMVersion, 4, 126, stdFont); + versionP = FrmNewLabel(&frmP, 1121, gScummVMBuildDate, 4, 136, stdFont); + FrmDoDialog (frmP); // Display the About Box. + FrmDeleteForm (frmP); +} + +static Boolean MainFormDoCommand(UInt16 command) +{ + Boolean handled = false; + + switch (command) { + case MainGamesMemoryCard: + FrmPopupForm(CardSlotForm); + handled = true; + break; + + case MainGamesViewMemory: + FrmPopupForm(SystemInfoForm); + handled = true; + break; + + case MainGamesNewEdit: + gFormEditMode = edtModeParams; + FrmPopupForm(EditGameForm); + handled = true; + break; + + case MainGamesBeam: + BeamMe(); + //if (BeamMe()) + //FrmCustomAlert(FrmErrorAlert,"Unable to beam ScummVM for PalmOS.",0,0); + handled = true; + break; + + case MainOptionsAbout: + MainFormAbout(); + handled = true; + break; + + case MainOptionsVolumeControl: + FrmPopupForm(VolumeForm); + handled = true; + break; + + case MainOptionsMusic: + FrmPopupForm(SoundForm); + handled = true; + break; + + case MainOptionsSkins: + FrmPopupForm(SkinsForm); + handled = true; + break; + + case MainOptionsMisc: + FrmPopupForm(MiscOptionsForm); + handled = true; + break; + } + + MenuEraseStatus(0); + return handled; +} + +/*********************************************************************** + * + * FUNCTION: MainFormHandleEvent + * + * DESCRIPTION: This routine is the event handler for the + * "MainForm" of this application. + * + * PARAMETERS: eventP - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ + +static Boolean PenDownRepeat() { + Coord x,y; + Boolean penDown, handled = false; + EvtGetPen(&x, &y, &penDown); + + if (penDown && sknLastOn) { + RectangleType r; + DmOpenRef skinDBP; + + skinDBP = SknOpenSkin(); + SknGetObjectBounds(skinDBP, sknLastOn, &r); + + if (RctPtInRectangle(x*2, y*2, &r)) { + if (SknGetState(skinDBP, sknLastOn) != sknStateSelected) { + SknSetState(skinDBP, sknLastOn, sknStateSelected); + SknShowObject(skinDBP, sknLastOn); + } + + switch (sknLastOn) { + case skinSliderUpArrow: + case skinSliderDownArrow: + handled = SknProcessArrowAction(sknLastOn); + break; + } + + } else { + if (SknGetState(skinDBP, sknLastOn) != sknStateNormal) { + SknSetState(skinDBP, sknLastOn, sknStateNormal); + SknShowObject(skinDBP, sknLastOn); + } + } + + SknCloseSkin(skinDBP); + } + + return handled; +} + + +Boolean MainFormHandleEvent(EventPtr eventP) +{ + Boolean handled = false; + FormPtr frmP; + Coord x,y; + DmOpenRef skinDBP; + + switch (eventP->eType) { + case frmUpdateEvent: + frmP = FrmGetFormPtr(MainForm); + if (gPrefs->card.volRefNum != sysInvalidRefNum) + FrmShowObject(frmP, FrmGetObjectIndex (frmP, MainMSBitMap)); + else + FrmShowObject(frmP, FrmGetObjectIndex (frmP, MainMSNoneBitMap)); + if (eventP->data.frmUpdate.updateCode == frmRedrawUpdateMSImport) { + GamImportDatabase(); + SknUpdateList(); + } + handled = true; + break; + + case winDisplayChangedEvent: + if (gVars) { + if (gVars->skinSet) + SknApplySkin(); + } + break; + + case menuEvent: + handled = MainFormDoCommand(eventP->data.menu.itemID); + break; + + case frmOpenEvent: + MainFormInit(); + handled = true; + break; + + case ctlSelectEvent: + switch (eventP->data.ctlSelect.controlID) + { + case MainCardsButton: + //gPrefs->card.volRefNum = parseCards(true); + FrmPopupForm(CardSlotForm); + break; + + case MainAboutButton: + MainFormAbout(); + break; + +// case MainListTypeSelTrigger: +// FrmList(eventP, MainListTypeList); +// break; + } + handled = true; + break; + + case penUpEvent: + x = eventP->screenX; + y = eventP->screenY; + lastIndex = dmMaxRecordIndex; // enable select/unselect list item + + if (sknLastOn != skinButtonNone) { + RectangleType r; + skinDBP = SknOpenSkin(); + SknGetObjectBounds(skinDBP, sknLastOn, &r); + SknSetState(skinDBP, sknLastOn, sknStateNormal); + SknShowObject(skinDBP, sknLastOn); + SknCloseSkin(skinDBP); + + if (RctPtInRectangle(x*2, y*2, &r)) { + switch (sknLastOn) { + case skinButtonGameAdd: + gFormEditMode = edtModeAdd; + FrmPopupForm(EditGameForm); + handled = true; + break; + + case skinButtonGameEdit: + case skinButtonGameParams: + gFormEditMode = edtModeParams; + FrmPopupForm(EditGameForm); + handled = true; + break; + + case skinButtonGameStart: + if (gPrefs->card.volRefNum == sysInvalidRefNum) + FrmCustomAlert(FrmWarnAlert,"Please select/insert a memory card.", 0, 0); + else + bStartScumm = true; + handled = true; + break; + + case skinButtonGameDelete: + EditGameFormDelete(true); + break; + } + } + sknLastOn = skinButtonNone; + } + break; + + case penDownEvent: + case penMoveEvent: + if (sknLastOn == skinButtonNone) { + x = eventP->screenX; + y = eventP->screenY; + skinDBP = SknOpenSkin(); + + switch (sknLastOn = SknCheckClick(skinDBP, x,y)) { + case skinButtonNone: + break; + case skinSliderUpArrow: + case skinSliderDownArrow: + case skinButtonGameAdd: + case skinButtonGameEdit: + case skinButtonGameParams: + case skinButtonGameStart: + case skinButtonGameDelete: + SknSetState(skinDBP, sknLastOn, sknStateSelected); + SknShowObject(skinDBP, sknLastOn); + if (gPrefs->soundClick) + SndPlaySystemSound(sndClick); + handled = true; + break; + default: + FrmCustomAlert(FrmWarnAlert,"Unknown button !",0,0); + } + SknCloseSkin(skinDBP); + SknSelect(x, y); + } + break; + + case keyDownEvent: + if ( (eventP->data.keyDown.chr >= 'a' && eventP->data.keyDown.chr <= 'z') || + (eventP->data.keyDown.chr >= 'A' && eventP->data.keyDown.chr <= 'Z')) { + if (GamJumpTo(eventP->data.keyDown.chr)) { + SknUpdateList(); + handled = true; + } + } + break; + + default: + handled = PenDownRepeat(); + } + + return handled; +} + diff --git a/backends/PalmOS/Src/forms/forms.h b/backends/PalmOS/Src/forms/forms.h index 60a797b3c6..edc54e76b0 100644 --- a/backends/PalmOS/Src/forms/forms.h +++ b/backends/PalmOS/Src/forms/forms.h @@ -10,6 +10,7 @@ #define HANDLER(x) Boolean x##FormHandleEvent(EventPtr eventP); +HANDLER(Main) HANDLER(EditGame) HANDLER(Volume) HANDLER(SystemInfo) @@ -18,4 +19,4 @@ HANDLER(MiscOptions) HANDLER(CardSlot) HANDLER(Skins) -#endif
\ No newline at end of file +#endif |