Jump to content




Window GUI


  • You cannot reply to this topic
9 replies to this topic

#1 CCGrimHaxor

  • Members
  • 140 posts

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

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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.

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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.

#4 CCGrimHaxor

  • Members
  • 140 posts

Posted 29 January 2015 - 03:59 PM

View PostBomb Bloke, on 28 January 2015 - 10:57 PM, said:

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?

#5 Lignum

  • Members
  • 558 posts

Posted 29 January 2015 - 04:05 PM

View PostCCGrimHaxor, on 29 January 2015 - 03:59 PM, said:

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


#6 CCGrimHaxor

  • Members
  • 140 posts

Posted 30 January 2015 - 07:22 PM

View PostBomb Bloke, on 28 January 2015 - 10:57 PM, said:

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?

#7 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 30 January 2015 - 07:33 PM

View PostCCGrimHaxor, on 30 January 2015 - 07:22 PM, said:

View PostBomb Bloke, on 28 January 2015 - 10:57 PM, said:

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.

#8 CCGrimHaxor

  • Members
  • 140 posts

Posted 30 January 2015 - 08:18 PM

View PostKingofGamesYami, on 30 January 2015 - 07:33 PM, said:

View PostCCGrimHaxor, on 30 January 2015 - 07:22 PM, said:

View PostBomb Bloke, on 28 January 2015 - 10:57 PM, said:

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.

#9 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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.

#10 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users