[Scummvm-cvs-logs] CVS: scummvm/backends/PalmOS/Src/forms formMisc.cpp,1.1,1.2

Chris Apers chrilith at users.sourceforge.net
Fri Nov 28 02:02:04 CET 2003


Update of /cvsroot/scummvm/scummvm/backends/PalmOS/Src/forms
In directory sc8-pr-cvs1:/tmp/cvs-serv7980

Modified Files:
	formMisc.cpp 
Log Message:
New Misc Options form + stack pref option

Index: formMisc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/PalmOS/Src/forms/formMisc.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- formMisc.cpp	3 Nov 2003 16:01:13 -0000	1.1
+++ formMisc.cpp	28 Nov 2003 10:00:53 -0000	1.2
@@ -15,6 +15,34 @@
  *
  *
  ***********************************************************************/
+static Boolean stackChanged = false;
+static UInt8 tabNum;
+
+#define TAB_START	MiscOptionsTabPalmPushButton
+#define TAB_COUNT	2
+
+
+static UInt32 StackSize(UInt32 newSize) {
+	MemHandle pref = DmGetResource('pref',0);
+	UInt32 size = 0;
+	
+	if (pref) {
+		SysAppPrefsType *data = (SysAppPrefsType *)MemHandleLock(pref);
+		size = data->stackSize;
+
+		if (newSize) {
+			SysAppPrefsType newData;
+			MemMove(&newData, data, sizeof(SysAppPrefsType));
+			newData.stackSize = newSize;
+			DmWrite(data, 0, &newData, sizeof(SysAppPrefsType));
+		}
+
+		MemPtrUnlock(data);
+		DmReleaseResource(pref);
+	}
+
+	return size;
+}
 
 static void MiscOptionsFormSave() {
 
@@ -28,7 +56,7 @@
 	cck2P = (ControlType *)GetObjectPtr(MiscOptionsNoAutoOffCheckbox);
 	cck3P = (ControlType *)GetObjectPtr(MiscOptionsStdPaletteCheckbox);
 	cck4P = (ControlType *)GetObjectPtr(MiscOptionsDebugCheckbox);
-	cck5P = (ControlType *)GetObjectPtr(MiscOptionsWriteIniCheckbox);
+	cck5P = (ControlType *)GetObjectPtr(MiscOptionsLargerStackCheckbox);
 	cck6P = (ControlType *)GetObjectPtr(MiscOptionsAutoResetCheckbox);
 	cck7P = (ControlType *)GetObjectPtr(MiscOptionsDemoCheckbox);
 	cck8P = (ControlType *)GetObjectPtr(MiscOptionsFullscreenCheckbox);
@@ -45,30 +73,100 @@
 	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));
+
+	// Larger stack is a global data init at start up
+	StackSize(CtlGetValue(cck5P) ? STACK_LARGER : STACK_DEFAULT);
+	if (stackChanged)
+		FrmCustomAlert(FrmInfoAlert,"You need to restart ScummVM in order for changes to take effect.",0,0);
 	
 	FrmReturnToMain();
 }
 
+static void FrmSetTabSize(const FormPtr frmP, UInt16 objID, Coord newY, Coord newH) {
+	RectangleType r;
+	UInt16 index;
+	
+	index = FrmGetObjectIndex (frmP, objID);
+	FrmGetObjectBounds(frmP, index, &r);
+	r.topLeft.y	= newY;
+	r.extent.y	= newH;
+	FrmSetObjectBounds(frmP, index, &r);
+}
+
+static Boolean FrmSelectTab(const FormPtr frmP, UInt16 objID) {
+	FrmSetControlValue(frmP, FrmGetObjectIndex(frmP, objID), 0);
+
+	if (tabNum != (objID - TAB_START)) {
+		UInt8 color;
+		
+		FrmSetTabSize(frmP, (TAB_START + tabNum), 18, 10);
+		FrmSetTabSize(frmP, objID, 16, 12);
+
+		tabNum = objID - TAB_START;
+		WinScreenLock(winLockDontCare);
+		FrmDrawForm(frmP);
+		color = UIColorGetTableEntryIndex(UIObjectFrame);
+		WinSetForeColor(color);
+		WinDrawLine(1, 28, 154,28);
+		WinScreenUnlock();
+
+		return true;
+	}
+		
+	return false;
+}
+
+static void FrmShowHide(const FormPtr frmP, UInt16 idStart, UInt16 idEnd, Boolean show) {
+	UInt16 item, index;
+	Coord y = 35;
+	
+	for (item = idStart; item <= idEnd;	item++) {
+		index = FrmGetObjectIndex (frmP, item);
+		FrmSetObjectPosition(frmP, index, 4, y);
+		y += 12;
+
+		if (show)
+			FrmShowObject(frmP, index);
+		else
+			FrmHideObject(frmP, index);
+	}
+}
+
+static void MiscOptionsShowPalmOS(const FormPtr frmP, Boolean show) {
+	FrmShowHide(frmP, MiscOptionsTabTitlePalmLabel, MiscOptionsLargerStackCheckbox, show);
+}
+
+static void MiscOptionsShowScummVM(const FormPtr frmP, Boolean show) {
+	FrmShowHide(frmP, MiscOptionsTabTitleScummLabel, MiscOptionsDemoCheckbox, show);
+
+	if (show)
+		FrmShowObject(frmP, FrmGetObjectIndex (frmP, MiscOptionsDebugLevelField));
+	else
+		FrmHideObject(frmP, FrmGetObjectIndex (frmP, MiscOptionsDebugLevelField));
+}
+
 static void MiscOptionsFormInit() {
 
 	FieldType *fld1P;
 	FormPtr frmP;
+	UInt16 item;
+	UInt8 color;
 
 	Char *levelP;
 	MemHandle levelH;
 
+	CtlSetValue((ControlType *)GetObjectPtr(MiscOptionsLargerStackCheckbox), (StackSize(STACK_GET) == STACK_LARGER));
+
 	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);
 
@@ -80,11 +178,27 @@
 	MemHandleUnlock(levelH);
 
 	FldSetTextHandle(fld1P, levelH);
+
 	frmP = FrmGetActiveForm();
+	// set tab size
+	for (item = TAB_START; item < (TAB_START + TAB_COUNT); item++)
+		FrmSetTabSize(frmP, item, 18, 10);
+
+	tabNum = 0;
+	FrmSetTabSize(frmP, (TAB_START + tabNum), 16, 12);
+	MiscOptionsShowScummVM(frmP, false);
+	MiscOptionsShowPalmOS(frmP, true);
+	FrmSetObjectPosition(frmP, FrmGetObjectIndex (frmP, MiscOptionsDebugLevelField), 103, 35 + 12 * 2);
+
 	FrmDrawForm(frmP);
+
+	color = UIColorGetTableEntryIndex(UIObjectFrame);
+	WinSetForeColor(color);
+	WinDrawLine(1, 28, 154,28);
 }
 
 Boolean MiscOptionsFormHandleEvent(EventPtr eventP) {
+	FormPtr frmP = FrmGetActiveForm();
 	Boolean handled = false;
 
 	switch (eventP->eType) {
@@ -96,6 +210,22 @@
 		case ctlSelectEvent:
 			switch (eventP->data.ctlSelect.controlID)
 			{
+				case MiscOptionsTabPalmPushButton:
+					if (FrmSelectTab(frmP, MiscOptionsTabPalmPushButton))
+						MiscOptionsShowScummVM(frmP, false);
+						MiscOptionsShowPalmOS(frmP, true);
+					break;
+
+				case MiscOptionsTabScummPushButton:
+					if (FrmSelectTab(frmP, MiscOptionsTabScummPushButton))
+						MiscOptionsShowPalmOS(frmP, false);
+						MiscOptionsShowScummVM(frmP, true);
+					break;
+				
+				case MiscOptionsLargerStackCheckbox:
+					stackChanged = !stackChanged;
+					break;
+
 				case MiscOptionsOKButton:
 					MiscOptionsFormSave();
 					break;
@@ -112,4 +242,4 @@
 	}
 	
 	return handled;
-}
\ No newline at end of file
+}





More information about the Scummvm-git-logs mailing list