Author Topic: Vertically aligned Buttons  (Read 8083 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

Vertically aligned Buttons
« on: June 14, 2017, 08:58:23 PM »
Buttons in the Print command are default horizontal, which usually looks great, but sometimes I'd like them to be vertically aligned.

Anyone know the trick? I imagine it's simple enough, but it eludes me.


Artificial Intelligence Competition

Offline gumby

Re: Vertically aligned Buttons
« Reply #1 on: June 15, 2017, 07:56:07 AM »
Yes, you need to hack up the Print() procedure in Controls.sc.  I did something similar with aligning controls here:  http://sciprogramming.com/community/index.php?topic=1697
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: Vertically aligned Buttons
« Reply #2 on: June 15, 2017, 05:37:07 PM »
Yes, you need to hack up the Print() procedure in Controls.sc.  I did something similar with aligning controls here:  http://sciprogramming.com/community/index.php?topic=1697
I'm really impressed with what you achieved with the edit print. The main reason being after going through the code, I honestly only understand 10% of it at all.

Needless to say, I didn't find the relevant part. I'm not asking you to write the solution for me, but perhaps you could help me zero in on the relevant part(s)

Offline gumby

Re: Vertically aligned Buttons
« Reply #3 on: June 15, 2017, 10:51:11 PM »
No problem.  I think I've found where you want to make some changes - in the Print() procedure, the block below needs to change.

Here's the original code:
Code: [Select]
(while(< paramCnt buttonCnt)
(send hButtons[paramCnt]:moveTo( btnX (send hDialog:nsBottom) ))
(send hDialog:add(hButtons[paramCnt]))
= btnX (+ 4 (send hButtons[paramCnt]:nsRight))
++paramCnt
)

You'll want something like this (completely untested):
Code: [Select]
(while(< paramCnt buttonCnt)
(send hButtons[paramCnt]:moveTo(  (send hDialog:nsLeft) btnY ))
(send hDialog:add(hButtons[paramCnt]))
= btnY (+ 4 (send hButtons[paramCnt]:nsRight))
++paramCnt
)

Basically switch out the btnX variable for a btnY.  So instead of shifting the buttons right on the X-axis, we just shift the buttons down the Y.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Kawa

Re: Vertically aligned Buttons
« Reply #4 on: June 16, 2017, 05:58:41 AM »
= btnY (+ 4 (send hButtons[paramCnt]:nsRight)) should really be nsBottom at the end there I think ;)

Offline Doan Sephim

Re: Vertically aligned Buttons
« Reply #5 on: June 16, 2017, 07:40:07 AM »
EDIT:

Okay. here's what happened. See the attachments. The first is Gumby's untested code. The second is with Kawa's suggested change (which did get all the buttons in the pic in descending order! hooray!) then the 3rd is when I tried to "fix" the problems myself. lol.
« Last Edit: June 16, 2017, 08:07:09 AM by Doan Sephim »
Artificial Intelligence Competition

Offline gumby

Re: Vertically aligned Buttons
« Reply #6 on: June 16, 2017, 07:54:50 AM »
= btnY (+ 4 (send hButtons[paramCnt]:nsRight)) should really be nsBottom at the end there I think ;)

Yes or possibly nsTop.  Either way that line probably needs to change.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: Vertically aligned Buttons
« Reply #7 on: June 16, 2017, 08:47:57 AM »
Actually, It looks like the Restore method has vertical buttons. I may look at that to see if I can find any clues.

Offline Doan Sephim

Re: Vertically aligned Buttons
« Reply #8 on: June 16, 2017, 09:24:15 AM »
Getting closer

Offline Doan Sephim

Re: Vertically aligned Buttons
« Reply #9 on: June 16, 2017, 09:48:28 AM »
I think I know part of the problem.
"btnY" is not a defined variable in the method, so I had to add it into the variables list. Then I ran the code provided by Gumby, but the btnY variable was never defined, so everything was going wonky (as can be seen in the provided pics)
So I looked for where and how "btnX" was defined:
Code: [Select]
(if(> btnsWidth (send hDialog:nsRight))
= btnX 4
)(else
  = btnX (- (send hDialog:nsRight) btnsWidth)
I thought I would be able to troubleshoot from here, by creating a similar way to define btnY, but let's just say things haven't been going very smoothly.

Any ideas?

EDIT: Very close now. It works well when btnY is arbitrarily set to a value of 16, but I know that that will no longer work if the dialog sentence is two lines or more. I'm trying to figure out how to determine the dialog's height value, but coming up empty.
« Last Edit: June 16, 2017, 09:59:12 AM by Doan Sephim »
Artificial Intelligence Competition

Offline MusicallyInspired

Re: Vertically aligned Buttons
« Reply #10 on: June 16, 2017, 11:22:02 AM »
You should give a little margin on the left as well so it's not overlapping the window border. No fresh ideas about height detection, though.
Brass Lantern Prop Competition

Offline troflip

Re: Vertically aligned Buttons
« Reply #11 on: June 16, 2017, 01:04:15 PM »
If this is just a one-off, you could also just build a dialog from scratch, like the inventory dialog does. That way you don't need to mess around with Print.

I think some of the Sierra games even come with a dialog editor that will let you place buttons and text, and then spits out the code. I forget which though...
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline lskovlun

Re: Vertically aligned Buttons
« Reply #12 on: June 16, 2017, 01:06:53 PM »
I think some of the Sierra games even come with a dialog editor that will let you place buttons and text, and then spits out the code. I forget which though...
I had the same thought of basing the code on Inv instead. The dialog editor, unfortunately, is SCI1.1 only.

Offline Kawa

Re: Vertically aligned Buttons
« Reply #13 on: June 16, 2017, 01:25:56 PM »
I had the same thought of basing the code on Inv instead. The dialog editor, unfortunately, is SCI1.1 only.
Not to mention its output is for SCI1x-style Print the object, not Print the method.  :(

Offline Doan Sephim

Re: Vertically aligned Buttons
« Reply #14 on: June 16, 2017, 02:16:10 PM »
Okay. I've got it nailed down and working correctly.

Here's the code I ended up with:
Code: [Select]
= btnY (send hDialog:nsBottom)
        (while(< paramCnt buttonCnt)
  (send hButtons[paramCnt]:moveTo( (+(send hDialog:nsLeft)4) btnY ))
  (send hDialog:add(hButtons[paramCnt]))
            = btnY (+ 4 (send hButtons[paramCnt]:nsBottom))
  ++paramCnt
   )
Setting the value of btnY with (send hDialog:nsBottom) allows here to be multiple lines of text and not having the buttons overlap (that was the problem I had when I had it set to a static number).

Of course, this code instead of the horizontal buttons will lead to all kinds of unintended problems, so I set a global variable to turn this on or off depending on whether I want vertical or horizontal buttons. It will default be off (and so bypass the problems it would cause), but for small things here and there, will work perfectly by just switching the global variable to true when that time comes.

Thanks for all the help.
« Last Edit: June 16, 2017, 02:18:55 PM by Doan Sephim »
Artificial Intelligence Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.031 seconds with 23 queries.