diff options
author | Chris Apers | 2003-11-03 16:01:14 +0000 |
---|---|---|
committer | Chris Apers | 2003-11-03 16:01:14 +0000 |
commit | 14c2ae7e360bc091f3188a63e455ee85d4082f80 (patch) | |
tree | 3f220f2ae174afe1ac9ba05ac4c2653784677d6a /backends/PalmOS/Src | |
parent | be080cce0edcccae930ea96b3d0105adfb759c25 (diff) | |
download | scummvm-rg350-14c2ae7e360bc091f3188a63e455ee85d4082f80.tar.gz scummvm-rg350-14c2ae7e360bc091f3188a63e455ee85d4082f80.tar.bz2 scummvm-rg350-14c2ae7e360bc091f3188a63e455ee85d4082f80.zip |
One form in one source file
svn-id: r11095
Diffstat (limited to 'backends/PalmOS/Src')
-rw-r--r-- | backends/PalmOS/Src/forms/formCards.cpp | 281 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/formCards.h | 8 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/formEditGame.cpp | 328 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/formEditGame.h | 14 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/formMisc.cpp | 115 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/formSkins.cpp | 254 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/formSound.cpp | 125 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/formSystem.cpp | 116 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/formUtil.cpp | 60 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/formUtil.h | 21 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/formVolume.cpp | 95 | ||||
-rw-r--r-- | backends/PalmOS/Src/forms/forms.h | 21 |
12 files changed, 1438 insertions, 0 deletions
diff --git a/backends/PalmOS/Src/forms/formCards.cpp b/backends/PalmOS/Src/forms/formCards.cpp new file mode 100644 index 0000000000..4ecb567b48 --- /dev/null +++ b/backends/PalmOS/Src/forms/formCards.cpp @@ -0,0 +1,281 @@ +#include <PalmOS.h> +#include <VFSMgr.h> + +#include "start.h" +#include "forms.h" + +typedef struct { + UInt16 volRefNum; + Char nameP[expCardInfoStringMaxLen+1]; + +} CardInfoType; + +void CardSlotCreateDirs() { + if (gPrefs->card.volRefNum != sysInvalidRefNum) { + VFSDirCreate(gPrefs->card.volRefNum, "/PALM"); + VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs"); + VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM"); + VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM/Games"); + VFSDirCreate(gPrefs->card.volRefNum, "/PALM/Programs/ScummVM/Saved"); + } +} + +static void CardSlotFromShowHideOptions() { + ControlType *cck1P; + FormPtr frmP = FrmGetActiveForm(); + + cck1P = (ControlType *)GetObjectPtr(CardSlotMoveCheckbox); + + if (CtlGetValue(cck1P)) { + FrmShowObject(frmP, FrmGetObjectIndex (frmP, CardSlotDeleteCheckbox)); + FrmShowObject(frmP, FrmGetObjectIndex (frmP, CardSlotConfirmCheckbox)); + } else { + FrmHideObject(frmP, FrmGetObjectIndex (frmP, CardSlotDeleteCheckbox)); + FrmHideObject(frmP, FrmGetObjectIndex (frmP, CardSlotConfirmCheckbox)); + } +} + +static UInt16 CardSlotFormInit(Boolean display, Boolean bDraw) { + Err err; + UInt16 volRefNum; + UInt32 volIterator = vfsIteratorStart; + UInt8 counter = 0; + UInt32 other = 1; + + MemHandle cards = NULL; + CardInfoType *cardsInfo; + + while (volIterator != vfsIteratorStop) { + err = VFSVolumeEnumerate(&volRefNum, &volIterator); + + if (!err) { + Char labelP[expCardInfoStringMaxLen+1]; + err = VFSVolumeGetLabel(volRefNum, labelP, expCardInfoStringMaxLen+1); + + if (err || StrLen(labelP) == 0) { // if no label try to retreive card type + VolumeInfoType volInfo; + err = VFSVolumeInfo(volRefNum, &volInfo); + + if (!err) { + ExpCardInfoType info; + err = ExpCardInfo(volInfo.slotRefNum, &info); + StrCopy(labelP, info.deviceClassStr); + } + + if (err) // if err default name + StrPrintF(labelP,"Other Card %ld", other++); + } + + if (!cards) + cards = MemHandleNew(sizeof(CardInfoType)); + else + MemHandleResize(cards, MemHandleSize(cards) + sizeof(CardInfoType)); + + cardsInfo = (CardInfoType *)MemHandleLock(cards); + cardsInfo[counter].volRefNum = volRefNum; + StrCopy(cardsInfo[counter].nameP, labelP); + MemHandleUnlock(cards); + counter++; + } + } + + if (display) { + FormPtr frmP; + ListPtr listP; + ControlType *cck1P, *cck2P, *cck3P; + UInt16 index; + Int16 selected = -1; + + CardInfoType *cardsInfo; + MemHandle items = NULL; + + listP = (ListType *)GetObjectPtr(CardSlotSlotList); + cck1P = (ControlType *)GetObjectPtr(CardSlotMoveCheckbox); + cck2P = (ControlType *)GetObjectPtr(CardSlotDeleteCheckbox); + cck3P = (ControlType *)GetObjectPtr(CardSlotConfirmCheckbox); + + if (counter > 0) { + cardsInfo = (CardInfoType *)MemHandleLock(cards); + + for (index = 0; index < counter; index++) { + if (!items) + items = MemHandleNew(sizeof(Char *)); + else + MemHandleResize(items, MemHandleSize(items) + sizeof(Char *)); + + itemsText = (Char **)MemHandleLock(items); + itemsText[index] = cardsInfo[index].nameP; + MemHandleUnlock(items); + + if (cardsInfo[index].volRefNum == gPrefs->card.volRefNum) + selected = index; + } + + itemsText = (Char **)MemHandleLock(items); + LstSetListChoices (listP, itemsText, counter); + LstSetSelection(listP, selected); + // save globals and set list + itemsText = (Char **)MemHandleLock(items); + itemsList = (void *)cardsInfo; + itemsType = ITEM_TYPE_CARD; + + } else { + LstSetListChoices(listP, NULL, 0); + // save globals and set list + itemsText = NULL; + itemsList = NULL; + itemsType = ITEM_TYPE_CARD; + } + + // bDraw = true -> draw whole from + // bDraw = false -> redraw list + if (bDraw) { + CtlSetValue(cck1P, gPrefs->card.moveDB); + CtlSetValue(cck2P, gPrefs->card.deleteDB); + CtlSetValue(cck3P, gPrefs->card.confirmMoveDB); + CardSlotFromShowHideOptions(); + frmP = FrmGetActiveForm(); + FrmDrawForm(frmP); + + } else { + WinScreenLock(winLockCopy); + LstDrawList(listP); + WinScreenUnlock(); + } + } else { // if !display, we just want to retreive an avaliable card + if (counter > 0) { + UInt16 volRefNum; + cardsInfo = (CardInfoType *)MemHandleLock(cards); + volRefNum = cardsInfo[0].volRefNum; // return the first volref + MemHandleUnlock(cards); + MemHandleFree(cards); + return volRefNum; + } + } + + return sysInvalidRefNum; // default +} + +static void CardSlotFormExit(Boolean bSave) { + MemHandle cards; + MemHandle items; + CardInfoType *cardsInfo; + UInt16 updateCode = frmRedrawUpdateMS; + + if (itemsText && itemsList) { + cardsInfo = (CardInfoType *)itemsList; + cards = MemPtrRecoverHandle(cardsInfo); + items = MemPtrRecoverHandle(itemsText); + + itemsText = NULL; + itemsList = NULL; + } else { + cards = NULL; + items = NULL; + } + itemsType = ITEM_TYPE_UNKNOWN; + + if (bSave) { + ListType *listP; + ControlType *cck1P, *cck2P, *cck3P; + Int16 selected; + + listP = (ListType *)GetObjectPtr(CardSlotSlotList); + cck1P = (ControlType *)GetObjectPtr(CardSlotMoveCheckbox); + cck2P = (ControlType *)GetObjectPtr(CardSlotDeleteCheckbox); + cck3P = (ControlType *)GetObjectPtr(CardSlotConfirmCheckbox); + selected = LstGetSelection(listP); + + if (selected == -1) { + gPrefs->card.volRefNum = sysInvalidRefNum; + } else if (gPrefs->card.volRefNum != cardsInfo[selected].volRefNum) { + updateCode = frmRedrawUpdateMSImport; + gPrefs->card.volRefNum = cardsInfo[selected].volRefNum; + } + + gPrefs->card.moveDB = CtlGetValue(cck1P); + gPrefs->card.deleteDB = CtlGetValue(cck2P); + gPrefs->card.confirmMoveDB = CtlGetValue(cck3P); + CardSlotCreateDirs(); + } + + FrmReturnToMain(updateCode); + + if (items && cards) { + MemHandleUnlock(items); + MemHandleUnlock(cards); + MemHandleFree(items); + MemHandleFree(cards); + } +} + +void CardSlotFormUpdate() { + if (itemsType == ITEM_TYPE_CARD) { + if (itemsText && itemsList) { + MemHandle cards; + MemHandle items; + ListType *listP; + + listP = (ListType *)GetObjectPtr(CardSlotSlotList); + cards = MemPtrRecoverHandle(itemsList); + items = MemPtrRecoverHandle(itemsText); + + itemsText = NULL; + itemsList = NULL; + itemsType = ITEM_TYPE_UNKNOWN; + + MemHandleUnlock(items); + MemHandleUnlock(cards); + MemHandleFree(items); + MemHandleFree(cards); + } + CardSlotFormInit(true, false); + } +} + +Boolean CardSlotFormHandleEvent(EventPtr eventP) { + Boolean handled = false; + + switch (eventP->eType) { + + case frmOpenEvent: + CardSlotFormInit(true, true); + handled = true; + break; + + case frmCloseEvent: + CardSlotFormExit(false); + handled = true; + break; + + case ctlSelectEvent: + switch (eventP->data.ctlSelect.controlID) + { + case CardSlotOkButton: + CardSlotFormExit(true); + break; + + case CardSlotCancelButton: + CardSlotFormExit(false); + break; + + case CardSlotMoveCheckbox: + CardSlotFromShowHideOptions(); + break; + } + handled = true; + break; + + default: + break; + } + + return handled; +} + +UInt16 parseCards() { + UInt16 volRefNum = CardSlotFormInit(false, false); + CardSlotFormExit(false); + + return volRefNum; +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/forms/formCards.h b/backends/PalmOS/Src/forms/formCards.h new file mode 100644 index 0000000000..69a8dd7828 --- /dev/null +++ b/backends/PalmOS/Src/forms/formCards.h @@ -0,0 +1,8 @@ +#ifndef __FORMCARDS_H__ +#define __FORMCARDS_H__ + +UInt16 parseCards(); +void CardSlotFormUpdate(); +void CardSlotCreateDirs(); + +#endif
\ No newline at end of file diff --git a/backends/PalmOS/Src/forms/formEditGame.cpp b/backends/PalmOS/Src/forms/formEditGame.cpp new file mode 100644 index 0000000000..3bc97c3c97 --- /dev/null +++ b/backends/PalmOS/Src/forms/formEditGame.cpp @@ -0,0 +1,328 @@ +#include <PalmOS.h> + +#include "forms.h" + +#include "start.h" +#include "games.h" +#include "skin.h" + +UInt8 gFormEditMode; + +/*********************************************************************** + * + * FUNCTION: EditGameFormSave + * FUNCTION: EditGameFormInit + * FUNCTION: EditGameFormHandleEvent + * + * DESCRIPTION: + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +void EditGameFormDelete(Boolean direct) { + UInt16 index = GamGetSelected(); + + if (index == dmMaxRecordIndex) { + FrmCustomAlert(FrmWarnAlert, "Select an entry first.",0,0); + return; + + } else if (FrmCustomAlert(FrmConfirmAlert, "Do you really want to delete this entry ?", 0, 0) == FrmConfirmYes) { + DmRemoveRecord(gameDB, index); + if (!direct) + FrmReturnToMain(); + GamSortList(); + SknUpdateList(); + } +} + +static void EditGameFormSave(UInt16 index) { + + FieldType *fld1P, *fld2P, *fld3P, *fld4P, *fld5P, *fld6P; // need to change this with good names + ControlType *cck1P, *cck2P, *cck3P, *cck4P, *cck5P; + ListType *list1P, *list2P, *list3P; + FormPtr frmP; + + MemHandle recordH; + GameInfoType *gameInfo, newGameInfo; +// UInt16 index; + + list1P = (ListType *)GetObjectPtr(EditGameGfxListList); + list2P = (ListType *)GetObjectPtr(EditGameLanguageList); + list3P = (ListType *)GetObjectPtr(EditGamePlatformList); + + fld1P = (FieldType *)GetObjectPtr(EditGameEntryNameField); + fld2P = (FieldType *)GetObjectPtr(EditGamePathField); + fld3P = (FieldType *)GetObjectPtr(EditGameGameField); + fld4P = (FieldType *)GetObjectPtr(EditGameLoadSlotField); + fld5P = (FieldType *)GetObjectPtr(EditGameStartRoomField); + fld6P = (FieldType *)GetObjectPtr(EditGameTalkSpeedField); + + cck1P = (ControlType *)GetObjectPtr(EditGameLoadSlotCheckbox); + cck2P = (ControlType *)GetObjectPtr(EditGameStartRoomCheckbox); + cck3P = (ControlType *)GetObjectPtr(EditGameAmigaCheckbox); + cck4P = (ControlType *)GetObjectPtr(EditGameSubtitlesCheckbox); + cck5P = (ControlType *)GetObjectPtr(EditGameTalkSpeedCheckbox); + + frmP = FrmGetActiveForm(); + + FldTrimText(fld1P); + FldTrimText(fld2P); + FldTrimText(fld3P); + + if (FldGetTextLength(fld1P) == 0) { + FrmCustomAlert(FrmWarnAlert,"You must specified an entry name.",0,0); + FrmSetFocus(frmP, FrmGetObjectIndex(frmP, EditGameEntryNameField)); + return; + } else if (FldGetTextLength(fld2P) == 0) { + FrmCustomAlert(FrmWarnAlert,"You must specified a path.",0,0); + FrmSetFocus(frmP, FrmGetObjectIndex(frmP, EditGamePathField)); + return; + } else if (FldGetTextLength(fld3P) == 0) { + FrmCustomAlert(FrmWarnAlert,"You must specified a game.",0,0); + FrmSetFocus(frmP, FrmGetObjectIndex(frmP, EditGameGameField)); + return; + } else if (FldGetTextLength(fld5P) == 0 && CtlGetValue(cck2P) == 1) { + FrmCustomAlert(FrmWarnAlert,"You must specified a room number.",0,0); + FrmSetFocus(frmP, FrmGetObjectIndex(frmP, EditGameStartRoomField)); + return; + } else if (FldGetTextLength(fld6P) == 0 && CtlGetValue(cck5P) == 1) { + FrmCustomAlert(FrmWarnAlert,"You must specified a talk speed.",0,0); + FrmSetFocus(frmP, FrmGetObjectIndex(frmP, EditGameTalkSpeedField)); + return; + } + +// index = GamGetSelected(); + + if (index != dmMaxRecordIndex) { + recordH = DmGetRecord(gameDB, index); + } else { + index = dmMaxRecordIndex; + GamUnselect(); + recordH = DmNewRecord(gameDB, &index, sizeof(GameInfoType)); + } + + gameInfo = (GameInfoType *)MemHandleLock(recordH); + + StrCopy(newGameInfo.nameP, FldGetTextPtr(fld1P)); + StrCopy(newGameInfo.pathP, FldGetTextPtr(fld2P)); + StrCopy(newGameInfo.gameP, FldGetTextPtr(fld3P)); + + if (newGameInfo.pathP[StrLen(newGameInfo.pathP)-1] != '/') + StrCat(newGameInfo.pathP, "/"); + + newGameInfo.version = curItemVersion; + newGameInfo.icnID = 0xFFFF; + newGameInfo.gfxMode = LstGetSelection(list1P); + newGameInfo.language = LstGetSelection(list2P); + newGameInfo.platform = LstGetSelection(list3P); + newGameInfo.selected = true; + newGameInfo.autoLoad = CtlGetValue(cck1P); + newGameInfo.loadSlot = StrAToI(FldGetTextPtr(fld4P)); + newGameInfo.bootParam = CtlGetValue(cck2P); + newGameInfo.bootValue = StrAToI(FldGetTextPtr(fld5P)); + newGameInfo.setPlatform = CtlGetValue(cck3P); + newGameInfo.subtitles = !(CtlGetValue(cck4P)); + newGameInfo.talkValue = StrAToI(FldGetTextPtr(fld6P)); + newGameInfo.talkSpeed = CtlGetValue(cck5P); + + DmWrite(gameInfo, 0, &newGameInfo, sizeof(GameInfoType)); + + MemHandleUnlock(recordH); + DmReleaseRecord (gameDB, index, 0); + GamSortList(); + // update list position + { + RectangleType rArea; + UInt16 posIndex, maxIndex, maxView; + + // get the sorted index + index = GamGetSelected(); + // if new item is out of the list bounds, change current list pos + SknGetListBounds(&rArea, NULL); + maxView = rArea.extent.y / sknInfoListItemSize; + posIndex = gPrefs->listPosition; + maxIndex = DmNumRecords(gameDB); + + if (index == 0 && posIndex > 0) { + gPrefs->listPosition = 0; + } else if ((maxView + posIndex) <= index) { + posIndex = index - (maxView - posIndex) + 1; + gPrefs->listPosition = posIndex; + } + } + + FrmReturnToMain(); + SknUpdateList(); +} + +static void EditGameFormInit(UInt16 index) { + + FieldType *fld1P, *fld2P, *fld3P, *fld4P, *fld5P, *fld6P; + FormPtr frmP; + ListType *list1P, *list2P, *list3P; + + Char *nameP, *pathP, *gameP, *loadP, *roomP, *talkP; + MemHandle nameH, pathH, gameH, loadH, roomH, talkH; + + MemHandle recordH = NULL; + GameInfoType *game; + + list1P = (ListType *)GetObjectPtr(EditGameGfxListList); + list2P = (ListType *)GetObjectPtr(EditGameLanguageList); + list3P = (ListType *)GetObjectPtr(EditGamePlatformList); + + fld1P = (FieldType *)GetObjectPtr(EditGameEntryNameField); + fld2P = (FieldType *)GetObjectPtr(EditGamePathField); + fld3P = (FieldType *)GetObjectPtr(EditGameGameField); + fld4P = (FieldType *)GetObjectPtr(EditGameLoadSlotField); + fld5P = (FieldType *)GetObjectPtr(EditGameStartRoomField); + fld6P = (FieldType *)GetObjectPtr(EditGameTalkSpeedField); + + nameH = MemHandleNew(FldGetMaxChars(fld1P)+1); + pathH = MemHandleNew(FldGetMaxChars(fld2P)+1); + gameH = MemHandleNew(FldGetMaxChars(fld3P)+1); + loadH = MemHandleNew(FldGetMaxChars(fld4P)+1); + roomH = MemHandleNew(FldGetMaxChars(fld5P)+1); + talkH = MemHandleNew(FldGetMaxChars(fld6P)+1); + + nameP = (Char *)MemHandleLock(nameH); + pathP = (Char *)MemHandleLock(pathH); + gameP = (Char *)MemHandleLock(gameH); + loadP = (Char *)MemHandleLock(loadH); + roomP = (Char *)MemHandleLock(roomH); + talkP = (Char *)MemHandleLock(talkH); + +// index = GamGetSelected(); + + if (index != dmMaxRecordIndex) { + recordH = DmQueryRecord(gameDB, index); + game = (GameInfoType *)MemHandleLock(recordH); + StrCopy(nameP, game->nameP); + StrCopy(pathP, game->pathP); + StrCopy(gameP, game->gameP); + + LstSetSelection(list1P, game->gfxMode); + LstSetSelection(list2P, game->language); + LstSetSelection(list3P, game->platform); + + StrIToA(loadP, game->loadSlot); + StrIToA(roomP, game->bootValue); + StrIToA(talkP, game->talkValue); + + CtlSetValue((ControlType *)GetObjectPtr(EditGameLoadSlotCheckbox), game->autoLoad); + CtlSetValue((ControlType *)GetObjectPtr(EditGameStartRoomCheckbox), game->bootParam); + CtlSetValue((ControlType *)GetObjectPtr(EditGameAmigaCheckbox), game->setPlatform); + CtlSetValue((ControlType *)GetObjectPtr(EditGameSubtitlesCheckbox), !game->subtitles); + CtlSetValue((ControlType *)GetObjectPtr(EditGameTalkSpeedCheckbox), game->talkSpeed); + + MemHandleUnlock(recordH); + CtlSetUsable((ControlType *)GetObjectPtr(EditGameDeleteButton),true); + } + else { + MemSet(nameP,MemHandleSize(nameH),0); + MemSet(pathP,MemHandleSize(pathH),0); + MemSet(gameP,MemHandleSize(gameH),0); + + StrIToA(loadP, 0); + StrIToA(roomP, 0); + StrIToA(talkP, 60); + + CtlSetValue((ControlType *)GetObjectPtr(EditGameLoadSlotCheckbox), 0); + CtlSetValue((ControlType *)GetObjectPtr(EditGameStartRoomCheckbox), 0); + CtlSetValue((ControlType *)GetObjectPtr(EditGameAmigaCheckbox), 0); + CtlSetValue((ControlType *)GetObjectPtr(EditGameSubtitlesCheckbox), 0); + CtlSetValue((ControlType *)GetObjectPtr(EditGameTalkSpeedCheckbox), 0); + + LstSetSelection(list1P, 1); + LstSetSelection(list2P, 0); + LstSetSelection(list3P, 0); + CtlSetUsable((ControlType *)GetObjectPtr(EditGameDeleteButton),false); + } + + MemHandleUnlock(nameH); + MemHandleUnlock(pathH); + MemHandleUnlock(gameH); + MemHandleUnlock(loadH); + MemHandleUnlock(roomH); + MemHandleUnlock(talkH); + + FldSetTextHandle(fld1P, nameH); + FldSetTextHandle(fld2P, pathH); + FldSetTextHandle(fld3P, gameH); + FldSetTextHandle(fld4P, loadH); + FldSetTextHandle(fld5P, roomH); + FldSetTextHandle(fld6P, talkH); + + CtlSetLabel((ControlType *)GetObjectPtr(EditGameGfxPopupPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P))); + CtlSetLabel((ControlType *)GetObjectPtr(EditGameLanguagePopTrigger), LstGetSelectionText(list2P, LstGetSelection(list2P))); + CtlSetLabel((ControlType *)GetObjectPtr(EditGamePlatformPopTrigger), LstGetSelectionText(list3P, LstGetSelection(list3P))); + + frmP = FrmGetActiveForm(); + FrmDrawForm(frmP); +} + +Boolean EditGameFormHandleEvent(EventPtr eventP) +{ + Boolean handled = false; + + switch (eventP->eType) { + case frmOpenEvent: + switch (gFormEditMode) { + case edtModeAdd: + EditGameFormInit(dmMaxRecordIndex); + break; + case edtModeEdit: + case edtModeParams: + default : + EditGameFormInit(GamGetSelected()); + break; + } + handled = true; + break; + + case ctlSelectEvent: + switch (eventP->data.ctlSelect.controlID) + { + case EditGameOKButton: + switch (gFormEditMode) { + case edtModeAdd: + EditGameFormSave(dmMaxRecordIndex); + break; + case edtModeEdit: + case edtModeParams: + default : + EditGameFormSave(GamGetSelected()); + break; + } + break; + + case EditGameCancelButton: + FrmReturnToMain(); + break; + + case EditGameDeleteButton: + EditGameFormDelete(false); + break; + + case EditGameGfxPopupPopTrigger: + FrmList(eventP, EditGameGfxListList); + break; + + case EditGameLanguagePopTrigger: + FrmList(eventP, EditGameLanguageList); + break; + + case EditGamePlatformPopTrigger: + FrmList(eventP, EditGamePlatformList); + break; + } + handled = true; + break; + + default: + break; + } + + return handled; +} diff --git a/backends/PalmOS/Src/forms/formEditGame.h b/backends/PalmOS/Src/forms/formEditGame.h new file mode 100644 index 0000000000..ae29f872ac --- /dev/null +++ b/backends/PalmOS/Src/forms/formEditGame.h @@ -0,0 +1,14 @@ +#ifndef __FORMEDITGAME_H__ +#define __FORMEDITGAME_H__ + +// edit game mode +enum { + edtModeAdd, + edtModeEdit, + edtModeParams +}; + +extern UInt8 gFormEditMode; +void EditGameFormDelete(Boolean direct); + +#endif
\ No newline at end of file diff --git a/backends/PalmOS/Src/forms/formMisc.cpp b/backends/PalmOS/Src/forms/formMisc.cpp new file mode 100644 index 0000000000..f62ef88136 --- /dev/null +++ b/backends/PalmOS/Src/forms/formMisc.cpp @@ -0,0 +1,115 @@ +#include <PalmOS.h> + +#include "start.h" +#include "forms.h" + +/*********************************************************************** + * + * FUNCTION: MiscOptionsFormSave + * FUNCTION: MiscOptionsFormInit + * FUNCTION: MiscOptionsFormHandleEvent + * + * DESCRIPTION: Misc. Options form functions + * + * REVISION HISTORY: + * + * + ***********************************************************************/ + +static void MiscOptionsFormSave() { + + FieldType *fld1P; + ControlType *cck1P, *cck2P, *cck3P, *cck4P, *cck5P, *cck6P, *cck7P, *cck8P; + FormPtr frmP; + + fld1P = (FieldType *)GetObjectPtr(MiscOptionsDebugLevelField); + + cck1P = (ControlType *)GetObjectPtr(MiscOptionsVibratorCheckbox); + cck2P = (ControlType *)GetObjectPtr(MiscOptionsNoAutoOffCheckbox); + cck3P = (ControlType *)GetObjectPtr(MiscOptionsStdPaletteCheckbox); + cck4P = (ControlType *)GetObjectPtr(MiscOptionsDebugCheckbox); + cck5P = (ControlType *)GetObjectPtr(MiscOptionsWriteIniCheckbox); + cck6P = (ControlType *)GetObjectPtr(MiscOptionsAutoResetCheckbox); + cck7P = (ControlType *)GetObjectPtr(MiscOptionsDemoCheckbox); + cck8P = (ControlType *)GetObjectPtr(MiscOptionsFullscreenCheckbox); + + frmP = FrmGetActiveForm(); + + if (FldGetTextLength(fld1P) == 0 && CtlGetValue(cck4P) == 1) { + FrmCustomAlert(FrmWarnAlert,"You must specified a debug level.",0,0); + FrmSetFocus(frmP, FrmGetObjectIndex(frmP, MiscOptionsDebugLevelField)); + return; + } + + gPrefs->vibrator = CtlGetValue(cck1P); + gPrefs->autoOff = !CtlGetValue(cck2P); + gPrefs->stdPalette = CtlGetValue(cck3P); + gPrefs->debug = CtlGetValue(cck4P); + gPrefs->saveConfig = CtlGetValue(cck5P); + gPrefs->autoReset = CtlGetValue(cck6P); + gPrefs->demoMode = CtlGetValue(cck7P); + gPrefs->fullscreen = CtlGetValue(cck8P); + + gPrefs->debugLevel = StrAToI(FldGetTextPtr(fld1P)); + + FrmReturnToMain(); +} + +static void MiscOptionsFormInit() { + + FieldType *fld1P; + FormPtr frmP; + + Char *levelP; + MemHandle levelH; + + CtlSetValue((ControlType *)GetObjectPtr(MiscOptionsVibratorCheckbox), gPrefs->vibrator); + CtlSetValue((ControlType *)GetObjectPtr(MiscOptionsNoAutoOffCheckbox), !gPrefs->autoOff); + CtlSetValue((ControlType *)GetObjectPtr(MiscOptionsStdPaletteCheckbox), gPrefs->stdPalette); + CtlSetValue((ControlType *)GetObjectPtr(MiscOptionsAutoResetCheckbox), gPrefs->autoReset); + CtlSetValue((ControlType *)GetObjectPtr(MiscOptionsDebugCheckbox), gPrefs->debug); + CtlSetValue((ControlType *)GetObjectPtr(MiscOptionsWriteIniCheckbox), gPrefs->saveConfig); + CtlSetValue((ControlType *)GetObjectPtr(MiscOptionsDemoCheckbox), gPrefs->demoMode); + CtlSetValue((ControlType *)GetObjectPtr(MiscOptionsFullscreenCheckbox), gPrefs->fullscreen); + + fld1P = (FieldType *)GetObjectPtr(MiscOptionsDebugLevelField); + + levelH = MemHandleNew(FldGetMaxChars(fld1P)+1); + levelP = (Char *)MemHandleLock(levelH); + StrIToA(levelP, gPrefs->debugLevel); + MemHandleUnlock(levelH); + + FldSetTextHandle(fld1P, levelH); + frmP = FrmGetActiveForm(); + FrmDrawForm(frmP); +} + +Boolean MiscOptionsFormHandleEvent(EventPtr eventP) { + Boolean handled = false; + + switch (eventP->eType) { + case frmOpenEvent: + MiscOptionsFormInit(); + handled = true; + break; + + case ctlSelectEvent: + switch (eventP->data.ctlSelect.controlID) + { + case MiscOptionsOKButton: + MiscOptionsFormSave(); + break; + + case MiscOptionsCancelButton: + FrmReturnToMain(); + break; + } + handled = true; + break; + + default: + break; + } + + return handled; +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/forms/formSkins.cpp b/backends/PalmOS/Src/forms/formSkins.cpp new file mode 100644 index 0000000000..8eae6d7494 --- /dev/null +++ b/backends/PalmOS/Src/forms/formSkins.cpp @@ -0,0 +1,254 @@ +#include <PalmOS.h> + +#include "start.h" +#include "forms.h" +#include "skin.h" + + +static Int16 SkinsFormCompare(SkinInfoType *a, SkinInfoType *b, SortRecordInfoPtr, SortRecordInfoPtr, MemHandle) { + return StrCompare(a->nameP, b->nameP); +} + +static void SkinsFormInit(Boolean bDraw) { + MemHandle skins = NULL; + SkinInfoType *skinsInfo; + UInt16 numSkins = 0; + + FormPtr frmP; + ListType *listP; + MemHandle items = NULL; + ControlType *cck1P; + DmSearchStateType stateInfo; + UInt16 cardNo; + LocalID dbID; + + Err errInfo; + Char nameP[32]; + + itemsText = NULL; + + // parse and save skins + Err err = DmGetNextDatabaseByTypeCreator(true, &stateInfo, 'skin', appFileCreator, false, &cardNo, &dbID); + while (!err && dbID) { + errInfo = DmDatabaseInfo (cardNo, dbID, nameP, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + if (!errInfo) + { + if (!skins) + skins = MemHandleNew(sizeof(SkinInfoType)); + else + MemHandleResize(skins, MemHandleSize(skins) + sizeof(SkinInfoType)); + + skinsInfo = (SkinInfoType *)MemHandleLock(skins); + StrCopy(skinsInfo[numSkins].nameP, nameP); + skinsInfo[numSkins].cardNo = cardNo; + skinsInfo[numSkins].dbID = dbID; + MemHandleUnlock(skins); + numSkins++; + } + err = DmGetNextDatabaseByTypeCreator(false, &stateInfo, 'skin', appFileCreator, false, &cardNo, &dbID); + } + + Int16 selected = -1; + + cck1P = (ControlType *)GetObjectPtr(SkinsSoundClickCheckbox); + CtlSetValue(cck1P, gPrefs->soundClick); + + listP = (ListType *)GetObjectPtr(SkinsSkinList); + skinsInfo = (SkinInfoType *)MemHandleLock(skins); + SysQSort(skinsInfo, numSkins, sizeof(SkinInfoType), (CmpFuncPtr)SkinsFormCompare, 0); + + // create itemsText (TODO: create a custom draw function) + for (UInt16 index=0; index < numSkins; index++) + { + if (!items) + items = MemHandleNew(sizeof(Char *)); + else + MemHandleResize(items, MemHandleSize(items) + sizeof(Char *)); + + itemsText = (Char **)MemHandleLock(items); + itemsText[index] = skinsInfo[index].nameP; + MemHandleUnlock(items); + + if ( gPrefs->skin.cardNo == skinsInfo[index].cardNo && + gPrefs->skin.dbID == skinsInfo[index].dbID && + StrCompare(gPrefs->skin.nameP, skinsInfo[index].nameP) == 0) + selected = index; + } + // save globals and set list + itemsText = (Char **)MemHandleLock(items); + itemsList = (void *)skinsInfo; + itemsType = ITEM_TYPE_SKIN; + + LstSetListChoices (listP, itemsText, numSkins); + LstSetSelection(listP, selected); + + // bDraw = true -> draw whole from + // bDraw = false -> redraw list + if (bDraw) { + frmP = FrmGetActiveForm(); + FrmDrawForm(frmP); + } else { + WinScreenLock(winLockCopy); + LstDrawList(listP); + WinScreenUnlock(); +// LstSetSelection(listP, 0); + } +} + +static void SkinsFormExit(Boolean bSave) { + MemHandle skins; + MemHandle items; + SkinInfoType *skinsInfo; + + ListType *listP; + Int16 selected; + + listP = (ListType *)GetObjectPtr(SkinsSkinList); + selected = LstGetSelection(listP); + + if (bSave && selected == -1) { // may never occured... + FrmCustomAlert(FrmWarnAlert, "You didn't select a skin.", 0, 0); + return; + } + + skinsInfo = (SkinInfoType *)itemsList; + skins = MemPtrRecoverHandle(skinsInfo); + items = MemPtrRecoverHandle(itemsText); + + itemsText = NULL; + itemsList = NULL; + itemsType = ITEM_TYPE_UNKNOWN; + + if (bSave) { + ControlType *cck1P; + + StrCopy(gPrefs->skin.nameP, skinsInfo[selected].nameP); + gPrefs->skin.cardNo = skinsInfo[selected].cardNo; + gPrefs->skin.dbID = skinsInfo[selected].dbID; + + cck1P = (ControlType *)GetObjectPtr(SkinsSoundClickCheckbox); + gPrefs->soundClick = CtlGetValue(cck1P); + } + + FrmReturnToMain(); + + MemHandleUnlock(items); + MemHandleUnlock(skins); + MemHandleFree(items); + MemHandleFree(skins); + + if (bSave) + SknApplySkin(); +} + +static void SkinsFormBeam() { + SkinInfoType *skinsInfo; + + ListType *listP; + Int16 selected; + Err err; + + listP = (ListType *)GetObjectPtr(SkinsSkinList); + selected = LstGetSelection(listP); + + if (selected == -1) { // may never occured... + FrmCustomAlert(FrmWarnAlert, "You didn't select a skin.", 0, 0); + return; + } + + skinsInfo = (SkinInfoType *)itemsList; + err = SendDatabase(0, skinsInfo[selected].dbID, "skin.pdb", "\nScummVM Skin"); + +// if (err) +// FrmCustomAlert(FrmErrorAlert, "Unable to beam this skin.",0,0); +} + +static void SkinsFormDelete() { + MemHandle skins; + MemHandle items; + SkinInfoType *skinsInfo; + + ListType *listP; + Int16 selected; + + listP = (ListType *)GetObjectPtr(SkinsSkinList); + selected = LstGetSelection(listP); + + if (selected == -1) { // may never occured... + FrmCustomAlert(FrmInfoAlert, "You didn't select a skin.", 0, 0); + return; + } + + skinsInfo = (SkinInfoType *)itemsList; + skins = MemPtrRecoverHandle(skinsInfo); + items = MemPtrRecoverHandle(itemsText); + + if ( gPrefs->skin.cardNo == skinsInfo[selected].cardNo && + gPrefs->skin.dbID == skinsInfo[selected].dbID && + StrCompare(gPrefs->skin.nameP, skinsInfo[selected].nameP) == 0) { + FrmCustomAlert(FrmInfoAlert, "You cannot delete the active skin.",0,0); + return; + + } else { + Err err = DmDeleteDatabase(0, skinsInfo[selected].dbID); + if (!err) { + + itemsText = NULL; + itemsList = NULL; + itemsType = ITEM_TYPE_UNKNOWN; + + MemHandleUnlock(items); + MemHandleUnlock(skins); + MemHandleFree(items); + MemHandleFree(skins); + + SkinsFormInit(false); + } else { + FrmCustomAlert(FrmErrorAlert, "Skin deletion failed.",0,0); + } + } + +} +Boolean SkinsFormHandleEvent(EventPtr eventP) { + Boolean handled = false; + + switch (eventP->eType) { + + case frmOpenEvent: + SkinsFormInit(true); + handled = true; + break; + + case frmCloseEvent: + SkinsFormExit(false); + handled = true; + break; + + case ctlSelectEvent: + switch (eventP->data.ctlSelect.controlID) + { + case SkinsOKButton: + SkinsFormExit(true); + break; + + case SkinsCancelButton: + SkinsFormExit(false); + break; + + case SkinsBeamButton: + SkinsFormBeam(); + break; + + case SkinsDeleteButton: + SkinsFormDelete(); + break; + } + handled = true; + break; + + default: + break; + } + + return handled; +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/forms/formSound.cpp b/backends/PalmOS/Src/forms/formSound.cpp new file mode 100644 index 0000000000..9306868d16 --- /dev/null +++ b/backends/PalmOS/Src/forms/formSound.cpp @@ -0,0 +1,125 @@ +#include <PalmOS.h> + +#include "start.h" +#include "forms.h" + +static void SoundFormSave() { + ControlType *cck1P, *cck2P, *cck3P, *cck4P; + ListType *list1P; + FieldType *fld1P, *fld2P, *fld3P; + UInt8 tempo; + UInt16 firstTrack; + + cck1P = (ControlType *)GetObjectPtr(SoundMusicCheckbox); + cck2P = (ControlType *)GetObjectPtr(SoundMultiMidiCheckbox); + cck3P = (ControlType *)GetObjectPtr(SoundMP3Checkbox); + cck4P = (ControlType *)GetObjectPtr(SoundTrackLengthCheckbox); + list1P = (ListType *)GetObjectPtr(SoundDriverList); + fld1P = (FieldType *)GetObjectPtr(SoundTempoField); + fld2P = (FieldType *)GetObjectPtr(SoundLengthSecsField); + fld3P = (FieldType *)GetObjectPtr(SoundFirstTrackField); + + tempo = StrAToI(FldGetTextPtr(fld1P)); + if (tempo < 50 || tempo > 200) { + FrmCustomAlert(FrmErrorAlert, "Invalid tempo value (50...200)", 0, 0); + return; + } + + firstTrack = StrAToI(FldGetTextPtr(fld3P)); + if (firstTrack < 1 || firstTrack > 999) { + FrmCustomAlert(FrmErrorAlert, "Invalid track value (1...999)", 0, 0); + return; + } + + gPrefs->sound.music = CtlGetValue(cck1P); + gPrefs->sound.multiMidi = CtlGetValue(cck2P); + gPrefs->sound.MP3 = CtlGetValue(cck3P); + gPrefs->sound.setDefaultTrackLength = CtlGetValue(cck4P); + + gPrefs->sound.driver = LstGetSelection(list1P); + gPrefs->sound.tempo = tempo; + gPrefs->sound.defaultTrackLength = StrAToI(FldGetTextPtr(fld2P)); + gPrefs->sound.firstTrack = firstTrack; + FrmReturnToMain(); +} + +static void SoundFormInit() { + ControlType *cck1P, *cck2P, *cck3P, *cck4P; + ListType *list1P; + FieldType *fld1P, *fld2P, *fld3P; + FormPtr frmP; + MemHandle tempoH, lengthH, firstTrackH; + Char *tempoP, *lengthP, *firstTrackP; + + cck1P = (ControlType *)GetObjectPtr(SoundMusicCheckbox); + cck2P = (ControlType *)GetObjectPtr(SoundMultiMidiCheckbox); + cck3P = (ControlType *)GetObjectPtr(SoundMP3Checkbox); + cck4P = (ControlType *)GetObjectPtr(SoundTrackLengthCheckbox); + list1P = (ListType *)GetObjectPtr(SoundDriverList); + fld1P = (FieldType *)GetObjectPtr(SoundTempoField); + fld2P = (FieldType *)GetObjectPtr(SoundLengthSecsField); + fld3P = (FieldType *)GetObjectPtr(SoundFirstTrackField); + + CtlSetValue(cck1P, gPrefs->sound.music); + CtlSetValue(cck2P, gPrefs->sound.multiMidi); + CtlSetValue(cck3P, gPrefs->sound.MP3); + CtlSetValue(cck4P, gPrefs->sound.setDefaultTrackLength); + + LstSetSelection(list1P, gPrefs->sound.driver); + CtlSetLabel((ControlType *)GetObjectPtr(SoundDriverPopTrigger), LstGetSelectionText(list1P, LstGetSelection(list1P))); + + tempoH = MemHandleNew(FldGetMaxChars(fld1P)+1); + tempoP = (Char *)MemHandleLock(tempoH); + StrIToA(tempoP, gPrefs->sound.tempo); + MemHandleUnlock(tempoH); + FldSetTextHandle(fld1P, tempoH); + + lengthH = MemHandleNew(FldGetMaxChars(fld2P)+1); + lengthP = (Char *)MemHandleLock(lengthH); + StrIToA(lengthP, gPrefs->sound.defaultTrackLength); + MemHandleUnlock(lengthH); + FldSetTextHandle(fld2P, lengthH); + + firstTrackH = MemHandleNew(FldGetMaxChars(fld3P)+1); + firstTrackP = (Char *)MemHandleLock(firstTrackH); + StrIToA(firstTrackP, gPrefs->sound.firstTrack); + MemHandleUnlock(firstTrackH); + FldSetTextHandle(fld3P, firstTrackH); + + frmP = FrmGetActiveForm(); + FrmDrawForm(frmP); +} + +Boolean SoundFormHandleEvent(EventPtr eventP) { + Boolean handled = false; + + switch (eventP->eType) { + case frmOpenEvent: + SoundFormInit(); + handled = true; + break; + + case ctlSelectEvent: + switch (eventP->data.ctlSelect.controlID) + { + case SoundOKButton: + SoundFormSave(); + break; + + case SoundCancelButton: + FrmReturnToMain(); + break; + + case SoundDriverPopTrigger: + FrmList(eventP, SoundDriverList); + break; + } + handled = true; + break; + + default: + break; + } + + return handled; +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/forms/formSystem.cpp b/backends/PalmOS/Src/forms/formSystem.cpp new file mode 100644 index 0000000000..41a97a8935 --- /dev/null +++ b/backends/PalmOS/Src/forms/formSystem.cpp @@ -0,0 +1,116 @@ +#include <PalmOS.h> + +#include "start.h" +#include "forms.h" + +/*********************************************************************** + * + * FUNCTION: SystemInfoFormInit + * FUNCTION: SystemInfoFormHandleEvent + * + * DESCRIPTION: + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void GetMemory(UInt32* storageMemoryP, UInt32* dynamicMemoryP, UInt32 *storageFreeP, UInt32 *dynamicFreeP) { + UInt32 free, max; + + Int16 i; + Int16 nCards; + UInt16 cardNo; + UInt16 heapID; + + UInt32 storageMemory = 0; + UInt32 dynamicMemory = 0; + UInt32 storageFree = 0; + UInt32 dynamicFree = 0; + + // Iterate through each card to support devices with multiple cards. + nCards = MemNumCards(); + + for (cardNo = 0; cardNo < nCards; cardNo++) { + // Iterate through the RAM heaps on a card (excludes ROM). + for (i=0; i< MemNumRAMHeaps(cardNo); i++) { + // Obtain the ID of the heap. + heapID = MemHeapID(cardNo, i); + // Calculate the total memory and free memory of the heap. + MemHeapFreeBytes(heapID, &free, &max); + + // If the heap is dynamic, increment the dynamic memory total. + if (MemHeapDynamic(heapID)) { + dynamicMemory += MemHeapSize(heapID); + dynamicFree += free; + + // The heap is nondynamic (storage ?). + } else { + storageMemory += MemHeapSize(heapID); + storageFree += free; + } + } + } + // Reduce the stats to KB. Round the results. + dynamicMemory = dynamicMemory / 1024L; + storageMemory = storageMemory / 1024L; + + dynamicFree = dynamicFree / 1024L; + storageFree = storageFree / 1024L; + + if (dynamicMemoryP) *dynamicMemoryP = dynamicMemory; + if (storageMemoryP) *storageMemoryP = storageMemory; + if (dynamicFreeP) *dynamicFreeP = dynamicFree; + if (storageFreeP) *storageFreeP = storageFree; +} + +static void SystemInfoFormInit() { + FormPtr frmP; + Coord x; + UInt32 dm, sm, df, sf; + Char num[10]; + + GetMemory(&sm, &dm, &sf, &df); + frmP = FrmGetActiveForm(); + FrmDrawForm(frmP); + + WinSetTextColor(255); + FntSetFont(stdFont); + + StrIToA(num, dm); + x = 149 - FntCharsWidth(num, StrLen(num)); + WinDrawChars(num, StrLen(num), x, 30); + + StrIToA(num, sm); + x = 149 - FntCharsWidth(num, StrLen(num)); + WinDrawChars(num, StrLen(num), x, 42); + + StrIToA(num, df); + x = 109 - FntCharsWidth(num, StrLen(num)); + WinDrawChars(num, StrLen(num), x, 30); + + StrIToA(num, sf); + x = 109 - FntCharsWidth(num, StrLen(num)); + WinDrawChars(num, StrLen(num), x, 42); +} + +Boolean SystemInfoFormHandleEvent(EventPtr eventP) { + Boolean handled = false; + + switch (eventP->eType) { + case frmOpenEvent: + SystemInfoFormInit(); + handled = true; + break; + + case ctlSelectEvent: + // OK button only + FrmReturnToMain(); + handled = true; + break; + + default: + break; + } + + return handled; +} diff --git a/backends/PalmOS/Src/forms/formUtil.cpp b/backends/PalmOS/Src/forms/formUtil.cpp new file mode 100644 index 0000000000..6d1d55e6e2 --- /dev/null +++ b/backends/PalmOS/Src/forms/formUtil.cpp @@ -0,0 +1,60 @@ +#include <PalmOS.h> +#include <TxtGlue.h> + +#include "forms.h" + +Char **itemsText = NULL; +void *itemsList = NULL; +Char itemsType = ITEM_TYPE_UNKNOWN; + +void FrmReturnToMain(UInt16 updateCode) { + // if there is a form loaded, prevent crash on OS5 + if (FrmGetFirstForm()) { + FrmUpdateForm(MainForm, updateCode); + FrmReturnToForm(MainForm); + } +} + +void FldTrimText(FieldPtr fldP) { + MemHandle tmpH; + Char *tmpP; + + tmpH = FldGetTextHandle(fldP); + FldSetTextHandle(fldP, NULL); + tmpP = (Char *)MemHandleLock(tmpH); + TxtGlueStripSpaces(tmpP, true, true); + MemHandleUnlock(tmpH); + FldSetTextHandle(fldP, tmpH); +} + +/*********************************************************************** + * + * FUNCTION: GetObjectPtr + * + * DESCRIPTION: This routine returns a pointer to an object in the current + * form. + * + * PARAMETERS: formId - id of the form to display + * + * RETURNED: void * + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +void * GetObjectPtr(UInt16 objectID) { + FormPtr frmP; + + frmP = FrmGetActiveForm(); + return FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)); +} + +void FrmList(EventPtr eventP, UInt16 objectID) { + ListType *listP; + UInt16 listItem; + + listP = (ListType *)GetObjectPtr(objectID); + listItem = LstPopupList(listP); + CtlSetLabel(eventP->data.ctlSelect.pControl, LstGetSelectionText(listP, LstGetSelection(listP))); +} + diff --git a/backends/PalmOS/Src/forms/formUtil.h b/backends/PalmOS/Src/forms/formUtil.h new file mode 100644 index 0000000000..be0933bd8c --- /dev/null +++ b/backends/PalmOS/Src/forms/formUtil.h @@ -0,0 +1,21 @@ +#ifndef __FORMUTIL_H__ +#define __FORMUTIL_H__ + +#define frmRedrawUpdateMS (frmRedrawUpdateCode + 1) +#define frmRedrawUpdateMSImport (frmRedrawUpdateCode + 2) + +// form list draw +#define ITEM_TYPE_UNKNOWN 'U' +#define ITEM_TYPE_CARD 'C' +#define ITEM_TYPE_SKIN 'S' + +extern Char **itemsText; +extern void *itemsList; +extern Char itemsType; + +void FrmReturnToMain(UInt16 updateCode = frmRedrawUpdateMS); +void * GetObjectPtr(UInt16 objectID); +void FldTrimText(FieldPtr fldP); +void FrmList(EventPtr eventP, UInt16 objectID); + +#endif
\ No newline at end of file diff --git a/backends/PalmOS/Src/forms/formVolume.cpp b/backends/PalmOS/Src/forms/formVolume.cpp new file mode 100644 index 0000000000..c4c0ec8005 --- /dev/null +++ b/backends/PalmOS/Src/forms/formVolume.cpp @@ -0,0 +1,95 @@ +#include <PalmOS.h> + +#include "start.h" +#include "forms.h" + +/*********************************************************************** + * + * FUNCTION: VolumeFormSave + * FUNCTION: VolumeFormInit + * FUNCTION: VolumeFormHandleEvent + * + * DESCRIPTION: + * + * REVISION HISTORY: + * + * + ***********************************************************************/ + +static void VolumeFormSave() { + SliderControlType *slid1P, *slid2P, *slid3P, *slid4P, *slid5P; + + slid1P = (SliderControlType *)GetObjectPtr(VolumeSpeakerSliderControl); + slid2P = (SliderControlType *)GetObjectPtr(VolumeHeadphoneSliderControl); + + slid3P = (SliderControlType *)GetObjectPtr(VolumeMasterSliderControl); + slid4P = (SliderControlType *)GetObjectPtr(VolumeMusicSliderControl); + slid5P = (SliderControlType *)GetObjectPtr(VolumeSfxSliderControl); + + CtlGetSliderValues ((ControlType *)slid1P, 0, 0, 0, &gPrefs->volume.speaker) ; + CtlGetSliderValues ((ControlType *)slid2P, 0, 0, 0, &gPrefs->volume.headphone) ; + + CtlGetSliderValues ((ControlType *)slid3P, 0, 0, 0, &gPrefs->volume.master); + CtlGetSliderValues ((ControlType *)slid4P, 0, 0, 0, &gPrefs->volume.music); + CtlGetSliderValues ((ControlType *)slid5P, 0, 0, 0, &gPrefs->volume.sfx); + + FrmReturnToMain(); +} + +static void VolumeFormInit() { + SliderControlType *slid1P, *slid2P, *slid3P, *slid4P, *slid5P; + FormPtr frmP; + UInt16 value; + + slid1P = (SliderControlType *)GetObjectPtr(VolumeSpeakerSliderControl); + slid2P = (SliderControlType *)GetObjectPtr(VolumeHeadphoneSliderControl); + + slid3P = (SliderControlType *)GetObjectPtr(VolumeMasterSliderControl); + slid4P = (SliderControlType *)GetObjectPtr(VolumeMusicSliderControl); + slid5P = (SliderControlType *)GetObjectPtr(VolumeSfxSliderControl); + + value = gPrefs->volume.speaker; + CtlSetSliderValues ((ControlType *)slid1P, 0, 0, 0, &value); + value = gPrefs->volume.headphone; + CtlSetSliderValues ((ControlType *)slid2P, 0, 0, 0, &value); + + value = gPrefs->volume.master; + CtlSetSliderValues ((ControlType *)slid3P, 0, 0, 0, &value); + value = gPrefs->volume.music; + CtlSetSliderValues ((ControlType *)slid4P, 0, 0, 0, &value); + value = gPrefs->volume.sfx; + CtlSetSliderValues ((ControlType *)slid5P, 0, 0, 0, &value); + + frmP = FrmGetActiveForm(); + FrmDrawForm(frmP); +} + +Boolean VolumeFormHandleEvent(EventPtr eventP) { + Boolean handled = false; + + switch (eventP->eType) { + case frmOpenEvent: + VolumeFormInit(); + handled = true; + break; + + case ctlSelectEvent: + switch (eventP->data.ctlSelect.controlID) + { + case VolumeOKButton: + VolumeFormSave(); + break; + + case VolumeCancelButton: + FrmReturnToMain(); + break; + } + handled = true; + break; + + default: + break; + } + + return handled; +}
\ No newline at end of file diff --git a/backends/PalmOS/Src/forms/forms.h b/backends/PalmOS/Src/forms/forms.h new file mode 100644 index 0000000000..60a797b3c6 --- /dev/null +++ b/backends/PalmOS/Src/forms/forms.h @@ -0,0 +1,21 @@ +#ifndef __FORMS_H__ +#define __FORMS_H__ + +#include "StarterRsc.h" +#include "formUtil.h" + +#include "formEditGame.h" +#include "formCards.h" + + +#define HANDLER(x) Boolean x##FormHandleEvent(EventPtr eventP); + +HANDLER(EditGame) +HANDLER(Volume) +HANDLER(SystemInfo) +HANDLER(Sound) +HANDLER(MiscOptions) +HANDLER(CardSlot) +HANDLER(Skins) + +#endif
\ No newline at end of file |