ScreenMode Selector

You can post your code snippets here for others to use and learn from
Post Reply
Bugala
Posts: 1330
Joined: Sun Feb 14, 2010 7:11 pm

ScreenMode Selector

Post by Bugala »

I made a screenmde selector which by first tests seems to have fixed the Double Monitor issue: https://forums.hollywood-mal.com/viewtopic.php?t=2400, and which might be otherwise interesting to some of you too.

Notice that I made this code for myself, and I haven't yet updated/cleaned it, just copy-pasting it on its current state, so there is some unnecessary code for you others. I might make more updated version at some point and put it to this same thread:

Code: Select all

ScreenModeSelector = {}

Function ScreenModeSelector.Initialize()
	ScreenModeSelector.Variables = {}
	ScreenModeSelector.Groups = {}
	ScreenModeSelector.ButtonN = 0
	ScreenModeSelector.CurrentY = 20
	ScreenModeSelector.GroupN = 0
	ScreenModeSelector.BoxSize = 20
	ScreenModeSelector.DragBarStartY = 12
	ScreenModeSelector.DragBarIntervalID = 0
	ScreenModeSelector.MaxY = 480
	SetFont(#SANS, 20)
	ScreenModeSelector.Start()
EndFunction

Function ScreenModeSelector.draw()
	Cls()
	Local Y = ScreenModeSelector.CurrentY
	Local X = 20
	For Local n = 0 To TableItems(ScreenModeSelector.Groups)-1
		SingleGroup = ScreenModeSelector.Groups[n]
		If SingleGroup.Show = True
		X = 20
		If LowerStr(SingleGroup.Type) <> "buttongroup"
			TextOut(X, Y, SingleGroup.Text)
			Y = Y + 25
		EndIf
			Switch UpperStr(SingleGroup.Type)		
			Case "CHECKBUTTONGROUP"
				For Local n = 0 To TableItems(SingleGroup.Buttons)-1
					Local CheckButton = SingleGroup.Buttons[n]
					SetFillStyle(#FILLNONE)
					Local Width = TextWidth(CheckButton.text)
					X, Y = ScreenModeSelector.CheckX(X, Y, 30 + Width)
					Box(X, Y, ScreenModeSelector.BoxSize, ScreenModeSelector.BoxSize, #WHITE)
					If ScreenModeSelector.Variables[CheckButton.VariableName] = True 
						SetFillStyle(#FILLCOLOR)
						Box(X+2, Y+2, ScreenModeSelector.BoxSize-4, ScreenModeSelector.BoxSize-4, #WHITE)
					EndIf
					TextOut(X+25, Y, CheckButton.text)
					X, Y = ScreenModeSelector.AddX(X, Y, 50 + Width)
				Next
			Case "RADIOBUTTON"
				For Local n=0 To TableItems(SingleGroup.Options)-1
					Local RadioOption = SingleGroup.Options[n]
					If LowerStr(SingleGroup.Alignment) = LowerStr("Horizontal")
						Local Width=TextWidth(RadioOption.OptionName)
						X, Y = ScreenModeSelector.CheckX(X, Y, 30 + Width)
						SetFillStyle(#FILLNONE)
						Box(X, Y, ScreenModeSelector.BoxSize, ScreenModeSelector.BoxSize, #WHITE)
						If SingleGroup.Selected = n
							SetFillStyle(#FILLCOLOR)
							Box(X+2, Y+2, ScreenModeSelector.BoxSize-4, ScreenModeSelector.BoxSize-4, #WHITE)
						EndIf
						TextOut(X+25, Y, RadioOption.OptionName)
						X, Y = ScreenModeSelector.AddX(X, Y, 50 + Width)
					ElseIf LowerStr(SingleGroup.Alignment) = LowerStr("Vertical")
						SetFillStyle(#FILLNONE)
						Y = Y + 30 /* huomaa tämä, lisää 30 ja jos viimeinen niin päälle tulee YSpaceBetweenGroups 50 yhteensä 80 */
						Box(X, Y, ScreenModeSelector.BoxSize, ScreenModeSelector.BoxSize, #WHITE)
						If SingleGroup.Selected = n
							SetFillStyle(#FILLCOLOR)
							Box(X+2, Y+2, ScreenModeSelector.BoxSize-4, ScreenModeSelector.BoxSize-4, #WHITE)
						EndIf
						TextOut(X+25, Y, RadioOption.OptionName)
					EndIf
				Next
			Case "BUTTONGROUP"
				For Local n = 0 To TableItems(SingleGroup.Buttons)-1
					Local Button = SingleGroup.Buttons[n]
					Local Width = TextWidth(Button.Text)
					X, Y = ScreenModeSelector.CheckX(X, Y, 20 + Width)
					SetFillStyle(#FILLNONE)
					Box(X, Y, Width+10, 20, #WHITE)
					TextOut(X+5, Y, Button.Text)
					X,Y = ScreenModeSelector.AddX(X, Y, 30 + width)
				Next
					
			EndSwitch
			Local YSpaceBetweenGroups = 40
			Y = Y + YSpaceBetweenGroups
		EndIf
	Next
	Local YAmount = Y - ScreenModeSelector.CurrentY
	If YAmount > 480
		SetFillStyle(#FILLNONE)
		Box(615, 10, 20, 460, #WHITE)
		SetFillStyle(#FILLCOLOR)
		Local BoxSizeMultiplier = 480 / Yamount
		ScreenModeSelector.DragBarHeight = 460 * BoxSizeMultiplier
		Box(617, ScreenModeSelector.DragBarStartY, 16, ScreenModeSelector.DragBarHeight, #WHITE)
	EndIf
	Flip()
EndFunction


Function ScreenModeSelector.CheckX(X, Y, N)
	If X + N > 620
		Y = Y + 30
		X = 20
	EndIf
	Return(X, Y)
EndFunction

Function ScreenModeSelector.AddX(X, Y, N)
	X = X + N
	If X > 620
		Y = Y + 30
		X = 20
	EndIf
	Return(X, Y)
EndFunction


Function ScreenModeSelector.UpdateButtons()
	ScreenModeSelector.DeleteButtons()
	Local Y = ScreenModeSelector.CurrentY
	Local X = 20
	For Local n = 0 To TableItems(ScreenModeSelector.Groups)-1
		SingleGroup = ScreenModeSelector.Groups[n]
		If SingleGroup.Show = True
			If LowerStr(SingleGroup.Type) <> "buttongroup" Then Y = Y + 25 /* This is to accomodate that group text is displayed */
			X = 20
			Switch UpperStr(SingleGroup.Type) 
			Case "CHECKBUTTONGROUP"
				For Local n = 0 To TableItems(SingleGroup.Buttons)-1
					CheckButton = SingleGroup.Buttons[n]
					Local Width = TextWidth(CheckButton.text)
					X, Y = ScreenModeSelector.CheckX(X, Y, 30 + Width)
					ScreenModeSelector.ButtonN = ScreenModeSelector.ButtonN + 1
					MakeButton(ScreenModeSelector.ButtonN, #SIMPLEBUTTON, X, Y, ScreenModeSelector.BoxSize, ScreenModeSelector.BoxSize, {OnMouseUp = Function(userdata) 	ScreenModeSelector.Variables[userdata.userdata] = 1 - ScreenModeSelector.Variables[userdata.userdata] EndFunction}, CheckButton.VariableName)
					X, Y = ScreenModeSelector.AddX(X, Y, 50 + Width)
				Next
			Case "RADIOBUTTON"
				For Local n = 0 To TableItems(SingleGroup.Options)-1
					Local RadioOption = SingleGroup.Options[n]
					Local width=TextWidth(RadioOption.OptionName)
					If LowerStr(SingleGroup.Alignment) = LowerStr("Horizontal")
						X, Y = ScreenModeSelector.CheckX(X, Y, 30 + Width)
					ElseIf LowerStr(SingleGroup.Alignment) = LowerStr("Vertical")						
						Y = Y + 30 /* Huomaa tämä*/
					EndIf
					ScreenModeSelector.ButtonN = ScreenModeSelector.ButtonN + 1

					MakeButton(ScreenModeSelector.ButtonN, #SIMPLEBUTTON, X, Y, ScreenModeSelector.BoxSize, ScreenModeSelector.BoxSize, {OnMouseUp = Function(userdata) 
														Local SelectionNumber = userdata.userdata.selectionNumber
														Local RadioButton = userdata.userdata.RadioButton
														Local RadioOption = userdata.userdata.RadioOption
														RadioButton.Selected = SelectionNumber
														ScreenModeSelector.Variables[LowerStr(RadioButton.Name)] = RadioOption.OptionName
														RadioOption.Func()
													EndFunction}, {RadioOption = RadioOption, SelectionNumber=n, RadioButton=SingleGroup} )
													
					If LowerStr(SingleGroup.Alignment) = LowerStr("Horizontal") 
						X, Y = ScreenModeSelector.AddX(X, Y, 50 + Width)
					EndIf						
					
				Next
			Case "BUTTONGROUP"
				For Local n = 0 To TableItems(SingleGroup.Buttons)-1
					Local Button = SingleGroup.Buttons[n]
					Local Width = TextWidth(Button.Text)
					X, Y = ScreenModeSelector.CheckX(X, Y, 20 + Width)
					ScreenModeSelector.ButtonN = ScreenModeSelector.ButtonN + 1
					MakeButton(ScreenModeSelector.ButtonN, #SIMPLEBUTTON, X, Y, Width+10, 20, {OnMouseUp = Function() Button.Func() EndFunction})
					X,Y = ScreenModeSelector.AddX(X, Y, 30 + width)
				Next
			EndSwitch
			Local YSpaceBetweenGroups = 40
			Y = Y + YSpaceBetweenGroups
		EndIf
	Next
	ScreenModeSelector.MaxY = Y - ScreenModeselector.CurrentY
	If ScreenModeSelector.MaxY > 480
		ScreenModeSelector.ButtonN = ScreenModeSelector.ButtonN + 1
		MakeButton(ScreenModeSelector.ButtonN, #SIMPLEBUTTON, 615, 10, 20, 460, {OnMouseDown=Function()
								If ScreenModeSelector.MaxY =< 480 Then Return
								Local MY = MouseY()
								If MY > ScreenModeSelector.DragBarStartY And MY < ScreenModeSelector.DragBarStartY + ScreenModeSelector.DragBarHeight
									ScreenModeSelector.DistanceToDragBarYAtBeginningOfInterval = ScreenModeSelector.DragBarStartY-MY
									ScreenModeSelector.DragBarIntervalID = SetInterval(Nil, Function()
															If IsLeftMouse() = False
																ClearInterval(ScreenModeSelector.DragBarIntervalID)
																ScreenModeSelector.UpdateButtons()
															EndIf
															Local DragYDifference = ScreenModeSelector.DistanceToDragBarYAtBeginningOfInterval
															Local MY = MouseY()
															Local NewDragBarY = MY+DragYDifference
															If NewDragBarY < 12 Then NewDragBarY = 12
															If NewDragBarY + ScreenModeSelector.DragBarHeight > 469 Then NewDragBarY = 469 - ScreenModeSelector.DragBarHeight
															ScreenModeSelector.DragBarStartY = NewDragBarY
															Local YMovementSpace = 456 - ScreenModeSelector.DragBarHeight
															Local Multiplier = (NewDragBarY-12) / YMovementSpace
															
															ScreenModeSelector.CurrentY = 12 - ((ScreenModeSelector.MaxY-480) * Multiplier)
																EndFunction, 20)
								EndIf

										  EndFunction})
	EndIf
	
EndFunction


Function ScreenModeSelector.ShowGroup(GroupName, TrueFalse)
	Local SingleGroup = ScreenModeSelector.GetGroup(LowerStr(GroupName))
	SingleGroup.Show = TrueFalse
	ScreenModeSelector.UpdateButtons()
EndFunction


Function ScreenModeSelector.DeleteButtons()
	
	If ScreenModeSelector.ButtonN > 0
		EndDoubleBuffer()
		For Local n = ScreenModeSelector.ButtonN To 1 Step -1
			DeleteButton(n)
		Next
		ScreenModeSelector.ButtonN = 0
		BeginDoubleBuffer()
	EndIf
EndFunction

Function ScreenModeSelector.ScrollScreen(amount)
	ScreenModeSelector.CurrentY = ScreenModeSelector.CurrentY + Amount*5
	If ScreenModeSelector.CurrentY > 0 Then ScreenModeselector.CurrentY = 0
	If ScreenModeSelector.CurrentY < 0-(ScreenModeSelector.MaxY-480) Then ScreenModeSelector.CurrentY = 0-(ScreenModeSelector.MaxY-480)
	If ScreenModeSelector.MaxY > 480
		Local YMovementSpace = 457 - ScreenModeSelector.DragBarHeight
		Local Multiplier = ScreenModeSelector.CurrentY / (ScreenModeSelector.MaxY-480)
		ScreenModeSelector.DragBarStartY = 0 - (YMovementSpace * Multiplier) + 12
	EndIf
	ScreenModeSelector.UpdateButtons()
EndFunction

Function ScreenModeSelector.AddCheckButtonGroup(GroupName, Text, Showhide)
	ScreenModeSelector.Groups[ScreenModeSelector.GroupN] = {Name=GroupName, Text=Text, type=LowerStr("checkbuttongroup"), Buttons={}, show=Showhide}
	ScreenModeSelector.GroupN = ScreenModeSelector.GroupN + 1
EndFunction

Function ScreenModeSelector.AddCheckButton(GroupName, Text, VariableName, TrueFalse)
	SingleGroup = ScreenModeSelector.GetGroup(GroupName)
	InsertItem(SingleGroup.Buttons, {Text=Text, VariableName=LowerStr(VariableName)} )
	ScreenModeSelector.Variables[VariableName] = TrueFalse
EndFunction

Function ScreenModeSelector.AddRadioButton(Name, Text, showhide, alignment)
	If alignment = Nil Then alignment = "vertical"
	ScreenModeSelector.Groups[ScreenModeSelector.GroupN] = {Name=Name, Text=Text, type=LowerStr("RadioButton"), Options={}, show=Showhide, alignment=alignment, selected=-1, OptionN = 0 }
	ScreenModeSelector.Variables[LowerStr(Name)] = "none"
	ScreenModeselector.GroupN = ScreenModeSelector.GroupN + 1
EndFunction

Function ScreenModeSelector.AddRadioButtonOption(RadioButtonName, OptionName, Func)
	If Func=Nil Then Func=Function() EndFunction
	SingleRadioButton = ScreenModeSelector.GetGroup(RadioButtonName)
	SingleRadioButton.Options[SingleRadioButton.OptionN] = {OptionName = OptionName, Func=Func}
	SingleRadioButton.OptionN = SingleRadioButton.OptionN + 1
EndFunction


Function ScreenModeSelector.AddButtonGroup(ButtonGroupName, TrueFalse)
	ScreenModeSelector.Groups[ScreenModeSelector.GroupN] = {Name=ButtonGroupName, Show=TrueFalse, Type=LowerStr("ButtonGroup"), ButtonN = 0, Buttons={}}
	ScreenModeSelector.GroupN = ScreenModeSelector.GroupN + 1
EndFunction

Function ScreenModeSelector.AddButton(ButtonGroupName, Text, Func)
	ButtonGroup = ScreenModeSelector.GetGroup(ButtonGroupName)
	ButtonGroup.Buttons[ButtonGroup.ButtonN] = {Text=Text, Func=Func}
	ButtonGroup.ButtonN = ButtonGroup.ButtonN + 1
EndFunction

Function ScreenModeSelector.GetGroup(Name)
	Local FoundItem = Nil
	ForEach(ScreenModeSelector.Groups, Function(ID, SingleGroup)
		If p_Compare(SingleGroup.name, name) = True Then FoundItem = SingleGroup
	EndFunction)
	Return(FoundItem)
EndFunction

Function p_Compare(Comp1, Comp2)

	Result = False
	If GetType(Comp1) = GetType(Comp2)
		Switch GetType(Comp1)
			Case #STRING
				If LowerStr(Comp1) = LowerStr(Comp2) Then Result = True
			Case #NUMBER
				If Comp1 = Comp2 Then Result = True
		EndSwitch
	EndIf
	Return(Result)
EndFunction

Function ScreenModeSelector.UpdateMonitorScreenResolutions(MonitorN)
	ScrResRadioButton = ScreenModeSelector.GetGroup("ScreenResolutions")
	ScrResRadioButton.Options = {}
	ScrResRadioButton.OptionN = 0
	Local t = GetDisplayModes(MonitorN)
	Local options = {}
	Local FoundItem = -1
	For Local n = 0 To TableItems(t)-1
		Local SingleOption = ""..t[n].width.."x"..t[n].height
		Options[n+1] = SingleOption
		If LowerStr(SingleOption) = "1920x1080"
			FoundItem = n+1
			Options[0] = SingleOption
		EndIf
	Next
	If FoundItem > -1
		RemoveItem(Options, FoundItem)
	Else
		Options[0] = "1"
		RemoveItem(Options, 0)
	EndIf
	
	For n = 0 To TableItems(Options)-1
		ScreenModeSelector.AddRadioButtonOption("ScreenResolutions", Options[n])
	Next
	ScreenModeSelector.SelectRadioButton("ScreenResolutions", 0)
EndFunction

Function ScreenModeSelector.SelectRadioButton(RadioButtonName, Selection)
	RadioButton = ScreenModeSelector.GetGroup(RadioButtonName)
	RadioButton.Selected = Selection
	ScreenModeSelector.Variables[LowerStr(RadioButton.Name)] = RadioButton.Options[Selection].OptionName
EndFunction


Function ScreenModeSelector.OpenScreen()
	Local ScreenResolution = ScreenModeSelector.Variables["screenresolutions"]
	Local result = SplitStr(ScreenResolution, "x")
	Local W = result[0]
	Local H = Result[1]
	Local scalemode = ScreenModeSelector.Variables["scalemode"]
	Local ScaleSizesVersion = True
	If p_Compare(scalemode, "#SCALEMODE_NONE") 
		ScaleMode = #SCALEMODE_NONE
		ScaleSizesVersion = False
	EndIf
		
	If p_Compare(scalemode, "#SCALEMODE_LAYER") Then ScaleMode = #SCALEMODE_LAYER
	If p_Compare(scalemode, "#SCALEMODE_AUTO") Then ScaleMode = #SCALEMODE_AUTO
	Local sizeable = ScreenModeSelector.Variables["sizeable"]
	Local borderless = ScreenModeSelector.Variables["borderless"]
	Local Mode = ScreenModeSelector.Variables["screenmode"]
	Local Monitor = ScreenModeSelector.Variables["monitor"]
	Local Fixed = ScreenModeSelector.Variables["fixed"]
	Local SmoothScale = ScreenModeSelector.Variables["smoothscale"]
	Local KeepProportions = ScreenModeSelector.Variables["keepproportions"]

	ScreenModeSelector.End()
	If ScaleSizesVersion = True
		CreateDisplay(0, {Width=1920, Height=1080, ScaleWidth=W, ScaleHeight=H, Title = "Rogue Football Cardgame", Sizeable=Sizeable, borderless=Borderless, 
				Mode=Mode, Monitor=Monitor, fixed=Fixed, smoothscale=SmoothScale, KeepProportions = KeepProportions,
				ScaleMode = Scalemode})
	Else
		CreateDisplay(0, {Width=W, Height=H, ScaleWidth="100%", ScaleWidth="100%", Title = "Rogue Football Cardgame", Sizeable=Sizeable, borderless=Borderless, 
				Mode=Mode, Monitor=Monitor, fixed=Fixed, smoothscale=SmoothScale, KeepProportions = KeepProportions,
				ScaleMode = #SCALEMODE_NONE})
	EndIf
	OpenDisplay(0)
	StartSoftware({Width=W, Height=H, Sizeable=Sizeable, Borderless=Borderless, Mode=Mode, Monitor=Monitor, Fixed=Fixed, Smoothscale=Smoothscale, KeepProportions=KeepProportions, ScaleMode = ScaleMode})
EndFunction

Function ScreenModeSelector.End()
	ScreenModeSelector.DeleteButtons()
	ClearInterval(1)
	Cls(#BLACK)
	TextOut(10, 10, "Another Screen or Window should open now. ESC to QUIT", #WHITE)
	InstallEventHandler({OnWheelUp = Function() EndFunction, OnWheelDown = Function() EndFunction})
	ScreenModeSelector = Nil
EndFunction

Function ScreenModeSelector.Start()

	InstallEventHandler({
	  OnWheelUp = Function() ScreenModeSelector.ScrollScreen(5) EndFunction,
	  OnWheelDown = Function() ScreenModeSelector.ScrollScreen(-5) EndFunction})

	ScreenModeSelector.AddButtonGroup("Buttons", True)
	ScreenModeSelector.AddButton("Buttons", "Start", Function() ScreenModeSelector.OpenScreen EndFunction)

	ScreenModeSelector.AddRadioButton("Screenmode", "ScreenMode", True, "horizontal")
	ScreenModeSelector.AddRadioButtonOption("Screenmode", "Fullscreen", Function() ScreenModeSelector.ShowGroup("WindowSelections", False) EndFunction)
	ScreenModeSelector.AddRadioButtonOption("Screenmode", "Windowed", Function() ScreenModeSelector.ShowGroup("WindowSelections", True) EndFunction)
	ScreenModeSelector.SelectRadioButton("Screenmode", 0)

	ScreenModeSelector.AddCheckButtonGroup("WindowSelections", "Window Options", False)
	ScreenModeSelector.AddCheckButton("WindowSelections", "Borderless", "borderless", True)
	ScreenModeSelector.AddCheckButton("WindowSelections", "Sizeable", "sizeable", False)
	ScreenModeSelector.AddCheckButton("WindowSelections", "Keep Proportions", "keepproportions", True)
	ScreenModeSelector.AddCheckButton("WindowSelections", "Fixed", "fixed", False)
	
	ScreenModeSelector.AddCheckButtonGroup("OtherSelections", "Other Selections", True)
	
	If PLATFORMVERSION = "AMIGA"
		ScreenModeSelector.AddRadioButton("ScaleMode", "ScaleMode (In Amiga, normally choose #SCALEMODE_NONE)", True, "horizontal")
		ScreenModeSelector.AddCheckButton("OtherSelections", "SmoothScale (In Amiga, normally leave this unticked)", "smoothscale", False)
	Else
		ScreenModeSelector.AddRadioButton("ScaleMode", "ScaleMode", True, "horizontal")
		ScreenModeSelector.AddCheckButton("OtherSelections", "SmoothScale", "smoothscale", True)
	EndIf
	
	ScreenModeSelector.AddRadioButtonOption("ScaleMode", "#SCALEMODE_AUTO")
	ScreenModeSelector.AddRadioButtonOption("ScaleMode", "#SCALEMODE_NONE")
	ScreenModeSelector.AddRadioButtonOption("ScaleMode", "#SCALEMODE_LAYER")
	Local ScaleModeSelection = 0
	If PLATFORMVERSION = "AMIGA" Then ScaleModeSelection = 1
	ScreenModeSelector.SelectRadioButton("ScaleMode", ScaleModeSelection)

	ScreenModeSelector.AddRadioButton("Monitor", "Which Monitor", True, "horizontal")

	Local t = GetMonitors()
	For Local n = 1 To TableItems(t)
		Local m = n
		ScreenModeSelector.AddRadioButtonOption("Monitor", n, Function() ScreenModeSelector.UpdateMonitorScreenResolutions(m) EndFunction)
	Next
	ScreenModeSelector.SelectRadioButton("Monitor", 0)

	ScreenModeSelector.AddRadioButton("ScreenResolutions", "Select Screen Resolution", True, "Vertical")

	ScreenModeSelector.UpdateMonitorScreenResolutions(1)


	ScreenModeSelector.UpdateButtons()
	BeginDoubleBuffer()
	SetInterval(1, ScreenModeSelector.draw, 20)
EndFunction
How to use:

At simplest:

Code: Select all

Function StartSoftware()
	TextOut(10, 10, "Hello World")
EndFunction

ScreenModeSelector.Initialize()

Repeat
	WaitEvent()
Forever
By other words:
1. You need to use ScreenModeSelector.Initialize() to start the ScreenMode selector.
2. You need to have in your main program a function called StartSoftware(), for after you have chosen your screenmode, Screenmode selector will open your desired display, and then call for StartSoftware() function.
3. You need to have Repeat - WaitEvent() - Forever loop.

This is the minimum.

If you wish to get more control, then here is how to use the commands/functions in code:

Options always reside in GROUPS. You need to add one of the GROUPS:
ScreenModeSelector.AddButtonGroup(ButtonGroupName, TrueFalse)
ScreenModeSelector.AddCheckButtonGroup(GroupName, Text, Showhide)
ScreenModeSelector.AddRadioButton(Name, Text, showhide, alignment)

Each of these have "GroupName", this is the name you will use in future to refer to this group.

CheckButton and RadioButton have "Text" in them. This is the text that will show on top of that group.

showhide is either TRUE or FALSE. This is the initial state if this group should be shown is hidden.

RadioButton also has "alignment" which by default is "vertical" but you can also use "horizontal" for this. This means if radio buttons are put horizontally or vertically.


After you have added a GROUP, you can start adding buttons to them:
ScreenModeSelector.AddButton(ButtonGroupName, Text, Func)
ScreenModeSelector.AddCheckButton(GroupName, Text, VariableName, TrueFalse)
ScreenModeSelector.AddRadioButtonOption(RadioButtonName, OptionName, Func)

AddButton - adds Button to the BUTTONGROUP. TEXT is the text shown on the button, Func is the function to be executed when this button is pressed. "Start"-button is this kind of button.

AddCheckButton - Adds checkbutton to the CHECKBUTTONGROUP, Text is the Text shown AFTER the checkbox, VariableName is the VariableName that this CheckBoxButton will make into TRUE or FALSE state (check GETTING VARIABLES), TrueFalse is either TRUE or FALSE, telling whether this checkbox should be ticked or not by default.

AddRadioButtonOption - Adds new option to the Radio button. RadioButtonName is the GroupName of the RadioButtonGROUP, OptionName is the name used for this option, and Func (optional) is the Function to be executed if this Option is Chosen.


GETTING VARIABLES.

To get the chosen radio button option or state of a checkbox, you can do it the following way:

all variables are stored in ScreenModeSelector.Variables table.
To access for example checkbox option named "Borderless", you can simply use ScreenModeSelector.Variables["Borderless"].

Naturally this checkbox needs to exist first, so as example:

Code: Select all

ScreenModeSelector.AddCheckButtonGroup("MyCheckBoxGroup1", "My Checkboxes 1", True)
ScreenModeSelector.AddCheckButton("MyCheckBoxGroup1", "Tick for Borderless", "Borderless", True)
Local BorderlessVar = ScreenModeSelector.Variables["Borderless"]
In RadioButton case the variable name is the RadioButton GROUPNAME. As example:

Code: Select all

ScreenModeSelector.AddRadioButton("MyRadio", "Choose one of the options", True)
ScreenModeSelector.AddRadioButtonOption("MyRadio", "My fancy option")
Var MyRadioOption = ScreenModeSelector.Variables["MyRadio"]
MyRadioOption variable would now contain string "My fany option".

To control if one of the GROUPS is shown or hidden, you can use:
ScreenModeSelector.ShowGroup(GroupName, TrueFalse)


Couple of other notices:

1. This program opens itself to the Hollywoods default display by purpose, since I originally made this both to have a screenmode selector for a user, but also since I made this in hopes to tackle the double monitor issue. Regarding the Double monitor issue was that while opening the display seemed to work wrong, the default display, however, opened as should. Therefore I made this Screenmode Selector based upon idea that it needs to work completely on the Hollywoods default display that it opens when not opening any display.


2. There are two ways to scroll, either by dragbar, or by using mouse scroll. If you scroll to the top most of the display, you can notice that mouse scroll and dragbar end to different locations. This is such a minor bug I didn't start fixing it yet at least.


3. If you look at the code, there are couple of places where it reads IF PLATFORMVERSION = "AMIGA", you could basically delete all these lines, since they are lines I have made for my own purposes.

Idea is that for example if PLATFORMVERSION is Amiga, then by default ScaleMode is set to "#SCALEMODE_NONE" and "SmoothScale" is ticked off. This is because if using Scaling on AMIGA, it will become very slow as Hollywood uses CPU to do the scaling. And while it is not AMIGA, then ScaleMode is by default set to #SCALEMODE_AUTO and SmoothScale checkbox to TRUE.

You could of course do something similar to your programs, and perhaps you even want to turn off some of the options. Like if you are not using layers in your program, then there is no point in having #SCALEMODE_LAYER options, as it wont work. You could then either outcomment this line, or simply delete it.
Post Reply