UI : Close Button in corner of UI window

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
Jackalo
Non-Subscriber
Posts: 23
Joined: Wed Jun 22, 2005 6:07 pm

UI : Close Button in corner of UI window

Post by Jackalo » Sat Sep 17, 2005 6:55 pm

I believe that there should be a way to script what the X (Close) button does in the corner of the UI window instead of the default behavior of just hiding the window. Perhaps add a <CloseOption> tag to complement <CloseButton> that would allow us to choose Hide (default) or Unload.

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Sat Sep 17, 2005 10:42 pm

You actually can. Any of the controls used can be a descendant of the required type, but must have the same name. Hannibal demonstrated a close button that performs other operations in one of his UIs (actually I dont know if he posted it or not, but he discussed it with me to figure it out and showed me what he did).

So all you do is make a commandbutton named CloseButton or whatever the name is (it might just be Close, I dont recall without looking), and as the command, put whatever you want.

And either way, the title bar is just a frame and can contain whatever you want. Put a check box in there named whatever you want, it doesnt matter. So you can put your own button in there with the same look as the default Close button, and have it do something else. If you dont name it what the normal one is named, it wont even try to hide the window by default :)

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Sat Sep 17, 2005 11:00 pm

Sorry, I should specify since this isnt fully documented yet.

The <CloseButton> toggle in the Window element itself simply controls whether or not the element named "Close" in the Title Bar (which is just a frame), if any, will be available.

The <TitleBar> tag in the Window element is creating a child of the window, which is just a "frame" element. It is allowed to have any properties of a normal frame, and if it has specially named controls within it, they will be specially used. If it does not have those controls, then they will not be specially used. It is not limited to specific controls, or specific placement in the window element.

The default window and title bar appearance and such are set up by the default skin. If you want to override any of the behavior, take a peek at the default skin in DefaultSkin.xml for a better understanding

Jackalo
Non-Subscriber
Posts: 23
Joined: Wed Jun 22, 2005 6:07 pm

Post by Jackalo » Sat Sep 17, 2005 11:40 pm

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<ISUI>
	<Window name='Autofish Config'>
		<Visible>1</Visible>
		<X>375</X>
		<Y>240</Y>
		<Width>240</Width>
		<Height>240</Height>
		<TitleBar>
			<checkbox name='Custom Close Button'>
				<X>0</X>
				<Y>0</Y>
				<Width>10</Width>
				<Height>10</Height>
				<Command>ui -unload .\\Scripts\\miniAutofish\\Interface\\miniAutofish_ConfigUI.xml</Command>
			</checkbox>
		</TitleBar>
		<Children>
			<commandcheckbox name='Use AFKAlarm'>
				<X>10</X>
				<Y>10</Y>
				<Width>100</Width>
				<Height>20</Height>
				<Text> -> Use AFKAlarm</Text>
				<Command>RunScript AFKAlarm</Command>
				<CommandChecked>EndScript AFKAlarm</CommandChecked>
				<Data>$&#123;Script[AFKAlarm]&#125;</Data>
			</commandcheckbox>

			<commandcheckbox name='Show Scoresheet'>
				<X>10</X>
				<Y>30</Y>
				<Width>100</Width>
				<Height>20</Height>
				<Text> -> Display Scoresheet</Text>
				<Command>Script[miniAutofish].Variable[miniAutofish_display_scoresheet]&#58;Toggle</Command>
				<CommandChecked>Script[miniAutofish].Variable[miniAutofish_display_scoresheet]&#58;Toggle</CommandChecked>
				<Data>$&#123;Script[miniAutofish].Variable[miniAutofish_display_scoresheet]&#125;</Data>
			</commandcheckbox>
		</Children>
	</Window>
</ISUI>
I suppose I'm not quite following exactly how to set this up, as with the way you were saying it, the above should work, but I don't even see the titlebar with the code above. =\

Jackalo
Non-Subscriber
Posts: 23
Joined: Wed Jun 22, 2005 6:07 pm

Post by Jackalo » Sat Sep 17, 2005 11:50 pm

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<ISUI>
	<Window name='Autofish Config'>
		<Visible>1</Visible>
		<X>375</X>
		<Y>240</Y>
		<Width>240</Width>
		<Height>240</Height>
		<TitleBar>
			<Height>16</Height>
			<Border>1</Border>
			<BorderColor>FF000033</BorderColor>
			<Width>100%</Width>
			<BackgroundColor>FF000066</BackgroundColor>
			<Children>
				<checkbox name='Custom Close Button' template='window.TitleBar.Close'>
					<X>r13</X>
					<Y>2</Y>
					<Width>11</Width>
					<Height>11</Height>
					<Command>ui -unload .\\Scripts\\miniAutofish\\Interface\\miniAutofish_ConfigUI.xml</Command>
				</checkbox>
			</Children>
		</TitleBar>
		<Children>
			<commandcheckbox name='Use AFKAlarm'>
				<X>10</X>
				<Y>10</Y>
				<Width>100</Width>
				<Height>20</Height>
				<Text> -> Use AFKAlarm</Text>
				<Command>RunScript AFKAlarm</Command>
				<CommandChecked>EndScript AFKAlarm</CommandChecked>
				<Data>$&#123;Script[AFKAlarm]&#125;</Data>
			</commandcheckbox>

			<commandcheckbox name='Show Scoresheet'>
				<X>10</X>
				<Y>30</Y>
				<Width>100</Width>
				<Height>20</Height>
				<Text> -> Display Scoresheet</Text>
				<Command>Script[miniAutofish].Variable[miniAutofish_display_scoresheet]&#58;Toggle</Command>
				<CommandChecked>Script[miniAutofish].Variable[miniAutofish_display_scoresheet]&#58;Toggle</CommandChecked>
				<Data>$&#123;Script[miniAutofish].Variable[miniAutofish_display_scoresheet]&#125;</Data>
			</commandcheckbox>
		</Children>
	</Window>
</ISUI>
Ok, I suppose I'm starting to get the hang of this. I don't like the idea that it blanks the entire TitleBar object if you try to customize one thing, but I see where it would be a good thing.

Thanks for the info (especially pointing me towards the DefaultSkin.xml file!).

Jackalo
Non-Subscriber
Posts: 23
Joined: Wed Jun 22, 2005 6:07 pm

Post by Jackalo » Sat Sep 17, 2005 11:54 pm

I feel like such an idiot now. The code below is my friend.

Code: Select all

<TitleBar template='window.TitleBar'>

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Sat Sep 17, 2005 11:57 pm

Well, the reason the default skin uses templates is so that you can replace whatever portions you want, and keep the rest of the defaults.

Also, a few additions were made that will help you with what you want. 1: A custom XML entity "&file;" which references the current XML filename. 2: "&filepath;" which references the current XML file's PATH, without the filename or the final slash, used like "&filepath;/someother.XML"
And another suggestion for when you're hardcoding paths: Instead of using \\ for paths, start using / instead. It's a bit less confusing-looking. Additionally, the leading .\\ in your path can just be dropped, and the path will be relative.

Code: Select all

<TitleBar Template="window.TitleBar">
         <Children>
            <checkbox name='Custom Close Button' template='window.TitleBar.Close'>
               <Command>ui -unload "&file;"</Command>
            </checkbox>
			<text Name='Title' template='window.TitleBar.title' />
			<button Name='Minimize' template='window.TitleBar.Minimize' />
			<button Name='Maximize' template='window.TitleBar.Maximize' />
         </Children> 
</TitleBar>
Note: The &file; is quoted in the above because the file and path can include spaces, which means it would be interpreted by the UI command as separate parameters. Remove any of the other children you dont want also :)

Jackalo
Non-Subscriber
Posts: 23
Joined: Wed Jun 22, 2005 6:07 pm

Post by Jackalo » Sat Sep 17, 2005 11:58 pm

I figured that I would make one more post in this thread detailing my (hopefully) final code for the custom Close Button.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<ISUI>
	<Window name='Autofish Config'>
		<Visible>1</Visible>
		<X>375</X>
		<Y>240</Y>
		<Width>240</Width>
		<Height>240</Height>
		<TitleBar template='window.TitleBar'>
			<Children>
				<text Name='Title' template='window.TitleBar.title' />
				<button Name='Minimize' template='window.TitleBar.Minimize' />
				<commandbutton name='Custom Close Button' template='window.TitleBar.Close'>
					<Command>ui -unload .\\Scripts\\miniAutofish\\Interface\\miniAutofish_ConfigUI.xml</Command>
				</commandbutton>
			</Children>
		</TitleBar>
		<Children>
			<commandcheckbox name='Use AFKAlarm'>
				<X>10</X>
				<Y>10</Y>
				<Width>100</Width>
				<Height>20</Height>
				<Text> -> Use AFKAlarm</Text>
				<Command>RunScript AFKAlarm</Command>
				<CommandChecked>EndScript AFKAlarm</CommandChecked>
				<Data>$&#123;Script[AFKAlarm]&#125;</Data>
			</commandcheckbox>

			<commandcheckbox name='Show Scoresheet'>
				<X>10</X>
				<Y>30</Y>
				<Width>100</Width>
				<Height>20</Height>
				<Text> -> Display Scoresheet</Text>
				<Command>Script[miniAutofish].Variable[miniAutofish_display_scoresheet]&#58;Toggle</Command>
				<CommandChecked>Script[miniAutofish].Variable[miniAutofish_display_scoresheet]&#58;Toggle</CommandChecked>
				<Data>$&#123;Script[miniAutofish].Variable[miniAutofish_display_scoresheet]&#125;</Data>
			</commandcheckbox>
		</Children>
	</Window>
</ISUI>

Jackalo
Non-Subscriber
Posts: 23
Joined: Wed Jun 22, 2005 6:07 pm

Post by Jackalo » Sun Sep 18, 2005 12:04 am

Code: Select all

<Command>ui -unload "&file;"</Command> 
Didn't work for me, but the following does...

Code: Select all

<Command>ui -unload "&filepath;/miniAutofish_ConfigUI.xml"</Command>

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Sun Sep 18, 2005 12:13 am

My bad, it isnt "&file;" it is "&filename;". Sorry! :)

Post Reply