This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
CCGrimHaxor's profile picture

Window GUI

Started by CCGrimHaxor, 28 January 2015 - 05:34 PM
CCGrimHaxor #1
Posted 28 January 2015 - 06:34 PM
Hey guys I tried everything but I just can't figure this out. How do I put a program into a small window and draw it but when the program exits the window gets removed. And the previous screen gets restored. How do I do this?

Thanks Grim
Lyqyd #2
Posted 28 January 2015 - 06:37 PM
You'll need to keep the screen contents in a buffer, probably several. Each window is/needs a buffer, plus a buffer for the background. Then you just have to draw the appropriate buffer's content to the screen when things change.
Bomb Bloke #3
Posted 28 January 2015 - 10:57 PM
The window API offers this type of redraw functionality. If you're on something prior to CC 1.6, you'll need to either write your own buffering code, or get one of the pre-written display buffers from the forum's APIs and Utilities section.
CCGrimHaxor #4
Posted 29 January 2015 - 03:59 PM
The window API offers this type of redraw functionality. If you're on something prior to CC 1.6, you'll need to either write your own buffering code, or get one of the pre-written display buffers from the forum's APIs and Utilities section.

Seems like the window API would work. Is it 1.6 and above or no?
Lignum #5
Posted 29 January 2015 - 04:05 PM
Seems like the window API would work. Is it 1.6 and above or no?
You're correct. It's 1.6+ only.
I'd recommend doing something like this:

if not window then
   printError("This program only runs on ComputerCraft 1.6 or newer.")
end
CCGrimHaxor #6
Posted 30 January 2015 - 07:22 PM
The window API offers this type of redraw functionality. If you're on something prior to CC 1.6, you'll need to either write your own buffering code, or get one of the pre-written display buffers from the forum's APIs and Utilities section.

How do you remove the window after the user gave the input?
KingofGamesYami #7
Posted 30 January 2015 - 07:33 PM
The window API offers this type of redraw functionality. If you're on something prior to CC 1.6, you'll need to either write your own buffering code, or get one of the pre-written display buffers from the forum's APIs and Utilities section.

How do you remove the window after the user gave the input?

Stop rendering it.

Generally, you'd clear the screen, then render all other windows you have.
CCGrimHaxor #8
Posted 30 January 2015 - 08:18 PM
The window API offers this type of redraw functionality. If you're on something prior to CC 1.6, you'll need to either write your own buffering code, or get one of the pre-written display buffers from the forum's APIs and Utilities section.

How do you remove the window after the user gave the input?

Stop rendering it.

Generally, you'd clear the screen, then render all other windows you have.

Let me kind of explain this because this reall isn't where I am aiming by this.
Basicly I have 2 programs running 1 of the program is my application the other program is any program the user has chosen and what I want to do is when the program chosen by the user calls a function my programs redners a window that has 2 buttons. When 1 of the buttons is pressed the window dissappears and shows back the user open program without that user opened program having to redraw everything.
Lyqyd #9
Posted 30 January 2015 - 09:33 PM
Yes, we are explaining that to accomplish that, you need to have that program be drawing into a buffer the whole time, so that you can make the buffer re-draw to the screen without that program having to do anything.
Bomb Bloke #10
Posted 30 January 2015 - 10:51 PM
Indeed, the user's program gets a window, but your program gets a window, too. Take another look at the example code for the redraw function I linked above.

Both of these windows will be managed by your script, which'll also be managing the user program's co-routine. You'll likely want to open up a ComputerCraft mod archive and dig up the source for multishell.