Community

SCI Programming => SCI Syntax Help => Topic started by: Scavenger on February 17, 2017, 09:47:52 AM

Title: So how customisable is the interface in SCI1.1?
Post by: Scavenger on February 17, 2017, 09:47:52 AM
I've been going through SCI, trying to get the hang of each bit of it, but there's something that's bothering me about it that I need to clear up: Is the standard Sierra interface hard coded, or in a script somewhere? I've been looking and looking for it, but I haven't yet found where the interface is defined. I know the top bar is drawn by the script, and you can change it, but I'm not sure about the iconbar, or whether you can create a different interface style that doesn't have the iconbar/right click cycle. Maybe something like Left click interact, right click look? A verb coin? How hard coded is the interface in SCI1.1, and if it isn't, where is the script that controls these things?
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Kawa on February 17, 2017, 09:58:06 AM
It's scripted. Everything you just described can be implemented, and it's a few different scripts.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Scavenger on February 17, 2017, 10:09:52 AM
Can you help to point me to where the mouse handler is, and the iconbar is drawn? That's the main thing I'm having trouble with. Once I find out where everything is, I can probably program it myself, but there are like, 30 scripts and I have no idea where everything is.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Kawa on February 17, 2017, 12:18:33 PM
class IconBar of Set is in script 937 iconi.sc. instance templateIconBar of IconBar in turn is in #0 main.sc. Look for evMOUSEBUTTON to find the various places where mouse input is considered.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Scavenger on February 17, 2017, 12:33:34 PM
Thank you, I'll read these over and see how to create my own interface from it!
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Kawa on February 17, 2017, 05:36:21 PM
Y'know, no offense but considering we have a template to use an iconbar in SCI0, and that SCI0's text parser is entirely optional (much like AGI's, as seen in BC and MH1+2), it strikes me as a little bit silly to ask if you can replace the bar.

(Not to mention SCUMM: Loom and the later games didn't have a verb grid, being mostly done in script.)
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Scavenger on February 18, 2017, 01:45:16 AM
Honestly I think that's a little uncalled for. I'm just here trying to learn an engine with very little documentation or up to date tutorials (half the tutorials on SCI1.1 use a syntax that doesn't compile in what I'm using, it's very confusing), and I'm gonna have to ask a lot of questions you may find silly because you already know the answers to it.

The last time I used SCI0, I asked if the text parser box was done in-engine or in-script, and the consensus was it was hard coded into the engine and you needed to do a lot of workarounds to make it be something else. I am not aware of many games that used a nonstandard interface in SCI1.1 (even the SCI1.1 version of LSL6 used the iconbar and not the interface from the high res version), so I was concerned that the iconbar was the same deal as in SCI0. This engine isn't SCUMM, it's its own thing, and I've worked with a lot of engines with hard coded elements (such as OHRRPGCE, which has a pretty non-customisable battle engine).

I'm just trying to learn this engine. :\ It's difficult, and I don't know enough about it at the moment to know how to ask the "right" questions. I'd appreciate it if you helped me and didn't snipe at me?

Anyway, I've been having a look at it, and it looks like, though I can't be sure, that you use GetPort on the current viewport and SetPort to draw a new window overlay, though I'm not sure exactly how it works. Looking at the status line code, it seems pretty straightforward in that you can draw directly to the screen using the Graph function, but I'm not entirely sure how you draw a button yet. There's no documentation on Get/SetPort that I can find, either. How does that work?

Edit: Ok, I've messed around a little to try and get drawing shit done, and added this to the room instance, but when it's there I can't click on anything and it gives me the error "35979.fon not found" and hangs whenever an interaction is supposed to take place.

Code: [Select]
(method (doit oldPort)
(= oldPort (GetPort))
(SetPort -1)
(Graph grFILL_BOX 20 20 40 40 VISUAL 5 -1 -1)
(Graph grUPDATE_BOX 20 20 40 40 VISUAL)
(SetPort oldPort)
Pretty sure I'm doing something wrong, but I don't know what.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: troflip on February 18, 2017, 04:55:22 AM
Yeah, that was pretty rude, I agree.

SetPort takes a window handle. See the example code in the GetPort documentation: http://scicompanion.com/Documentation/Kernels/GetPort.html

The error you're seeing is because the interpreter is treating -1 like a window handle, and I guess going a bit crazy.

But I don't think you should need to use SetPort/GetPort, unless you're making a new window. If you're trying to make custom buttons, I think you can just override the draw method on DButton, and use the Graph calls there. If you're trying to customize the items in the icon bar, I think that's in the show method of IconItem (not positive about all this, just from a quick glance around).

And it's true, there are still a lot of tutorials on this site that use the old syntax. It would be great if someone had time to convert them.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Kawa on February 18, 2017, 07:29:07 AM
Mmyeah, sorry 'bout that. I was half asleep by then. I'll try not to do that again.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Scavenger on February 18, 2017, 10:28:16 AM
I am trying to make a new window, just to experiment and learn how this works - I don't just want to edit the iconbar but make an entirely new interface. The one I had in AGS looked like this:

(https://dl.dropboxusercontent.com/u/50882197/art/GameStuff/interfacetest_02.PNG)
So I wanna know how to replicate it in SCI. I'm... more of an artist than a game developer really.

I tried using NewWindow, here is my code:

Code: [Select]
(method (doit oldPort hWnd)
(= oldPort (GetPort))
(= hWnd (NewWindow
        20 20 40 40
        "Test Window"
        nwNODRAW
        nwON_TOP
        clBLACK
        clWHITE
))
(SetPort hWnd)
(Graph grFILL_BOX 20 20 40 40 VISUAL 5 -1 -1)
(Graph grUPDATE_BOX 20 20 40 40 VISUAL)
(SetPort oldPort)
)

And here is the, quite honestly baffling, output:

(https://dl.dropboxusercontent.com/u/50882197/art/GameStuff/window_error.PNG)

Today I learnt that SCI1.1 has the full 0-256 range for ASCII, which makes translation a lot easier! But what went wrong here?
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Kawa on February 18, 2017, 12:37:16 PM
To replicate that, don't use windows. Instead, basically have the template game's icon bar draw not on the top but on the bottom of the screen for starters, then find and remove the parts where it can be hidden and shown. There are more bits to adjust, no doubt, but that's good for starters.

Actually, your AGS screenshot reminds me of LSL6's interface (http://www.mobygames.com/images/shots/l/89959-leisure-suit-larry-6-shape-up-or-slip-out-dos-screenshot-the.png) (the low-res version) a lot, being permanently visible on the bottom of the screen, with the inventory and everything. So you might want to decompile and study that. class ButtonBar of Set in #87 BarIconI.sc specifically.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: troflip on February 18, 2017, 12:47:42 PM
Yeah, Kawa made a good suggestion. Find a Sierra game that does something similar and decompile to find out how it works.

As to why you're getting the error message, I suspect it's because you're creating a new window every frame (in the doit method), but never cleaning it up/closing it - so the interpreter keeps making a new window every frame and runs out of space. Generally, you'd be using the SysWindow class, and not the NewWindow kernel directly (although you still need to remember to dispose: these).

But as Kawa said, I doubt you need to use a window at all. Just from glancing over the IconBar code, it saves what was underneath it, then draws on top of the main window. Then when its done, it restores what was underneath.

Does the one in LSL6 also "auto-hide", or is it there all the time? If it's there all the time, then that might be a slightly different implementation (maybe it does use a window).
[edit:] Took a look at it. Looks like it uses an undocumented call to SetPort. If 6 or more parameters are passed, instead of setting the port to a window, it changes the current port's rect.
(SetPort top left bottom right xOrigin yOrigin)

Even for me as an experienced programmer, the "system level" stuff in SCI can be hard to do. It's a low-level language like C... you need to be mindful of memory management. Luckily, if you're just doing actual gameplay stuff, the scripts tend to manage that for you pretty well.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Kawa on February 18, 2017, 12:59:55 PM
LSL6's bar... I think it only hides in handsoff and such, but like GK1 the backgrounds are widescreen -- there's nothing behind it to obscure.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: lskovlun on February 18, 2017, 03:07:49 PM
As to why you're getting the error message, I suspect it's because you're creating a new window every frame (in the doit method), but never cleaning it up/closing it - so the interpreter keeps making a new window every frame and runs out of space. Generally, you'd be using the SysWindow class, and not the NewWindow kernel directly (although you still need to remember to dispose: these).
Seconded. It looks like you're creating a new window on every frame, which will exhaust heap memory... quite quickly, actually.

troflip: The long form of SetPort was discussed here (http://sciprogramming.com/community/index.php?topic=1420.225)
Title: Re: So how customisable is the interface in SCI1.1?
Post by: OmerMor on February 18, 2017, 05:05:52 PM
This file is a good (official) documentation on low-level SCI kernel functions:
https://github.com/OmerMor/SCI16/blob/master/DOC/KERNEL.TXT (https://github.com/OmerMor/SCI16/blob/master/DOC/KERNEL.TXT)

However it covers only SCI0.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Scavenger on February 19, 2017, 01:39:54 PM
Alright! I worked out what was going wrong, I was missing "&tmp" in the variable declaration in the method header.

By running:

Code: [Select]
(instance testDrawingCode of Code
(properties)

(method (doit &tmp oldPort)
(= oldPort (GetPort))
(SetPort -1)
(Graph grFILL_BOX 0 0 40 40 VISUAL 5 -1 -1)
(Graph grUPDATE_BOX 0 0 40 40 VISUAL)
(SetPort oldPort)
)
)

in the room's doit method I managed to draw a solid colour square without destroying the engine! I've been looking through the drawing code for the rest of it to see how to add buttons and stuff, something that makes it more difficult is that most of the variables are labelled tempX and there's very little comments telling me whats happening. I'll keep slogging through it. Running this code in Main.sc doesn't work, but I expect it's just drawing it behind the room's background instead, and if the room was differently shaped to have a hole in it it would work. Progress!
Title: Re: So how customisable is the interface in SCI1.1?
Post by: troflip on February 19, 2017, 06:12:14 PM
Glad you got something working.

FYI, (SetPort -1) looks like it sets the current port to the menu port (which I assume covers the entire screen).

Is there a reason you have this in a doit method of a Code instance, instead of just a procedure?

something that makes it more difficult is that most of the variables are labelled tempX and there's very little comments telling me whats happening.

That's because it was decompiled from the binary. It was a ton of work just to get it into that state.

Running this code in Main.sc doesn't work, but I expect it's just drawing it behind the room's background instead, and if the room was differently shaped to have a hole in it it would work. Progress!

What do you mean by "Running this code in Main.sc"? It matters from what code you're calling it, not what script file it's in.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: Scavenger on February 20, 2017, 01:44:35 AM

Is there a reason you have this in a doit method of a Code instance, instead of just a procedure?

Okay, I'm just following what the template code is doing, because I'm certain that the template code works, so I don't want to step outside of what it's telling me to do. The statusline code I got it from does it that way, so that's what I did. Is it wrong?

That's because it was decompiled from the binary. It was a ton of work just to get it into that state.

That's understandable, I've been going through the code and putting in variable names and comments when I'm sure I know what the code does. Once I'm confident with it I'll probably go back and rename/comment all the code in the template so it's easier for other people. I just need to learn it first.

What do you mean by "Running this code in Main.sc"? It matters from what code you're calling it, not what script file it's in.

Well, I originally had it in main.sc's doit method, directly below (statusLineCode doit:). There was nothing there. But putting it in Rm110's doit method DOES work for some reason. I'm not sure why.

It was:
Code: (Main.sc Line 706) [Select]
(method (doit)
(if (GameIsRestarting)
(if (IsOneOf gRoomNumber TITLEROOM_SCRIPT)
(HideStatus)
else
(statusLineCode doit:)
(testDrawingCode doit:) ;the added code
)
(= gColorDepth (Graph grGET_COLOURS))
)
(super doit: &rest)
)

But I had to put it in Rm110 like:

Code: [Select]
(method (doit)
(testDrawingCode doit:)
)

I'll be honest, I'm not sure why it didn't work the first time.
Title: Re: So how customisable is the interface in SCI1.1?
Post by: OmerMor on February 20, 2017, 02:59:26 AM
That's because it was decompiled from the binary. It was a ton of work just to get it into that state.

That's understandable, I've been going through the code and putting in variable names and comments when I'm sure I know what the code does. Once I'm confident with it I'll probably go back and rename/comment all the code in the template so it's easier for other people. I just need to learn it first.
nest, I'm not sure why it didn't work the first time.

Scavenger,
you might want to read through Sierra's original SCI system scripts instead:
https://github.com/OmerMor/SCI16/tree/master/SYSTEM (https://github.com/OmerMor/SCI16/tree/master/SYSTEM)