Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A question on using Inform-PE
#1
I'm wanting to use Inform-PE on a couple of projects, so I have a question about how to use it.

The project will need to have several UI's, for instance a menu screen, option screen, game play, inventory etc. So, to switch between these UI's, do I put everything on separate forms and somehow (?) switch forms, or cram all the controls on the same form and hide the controls I'm not using?

Using separate forms make the most sense, but I don't see a obvious way to do it. Have I missed something?
Reply
#2
(Yesterday, 11:43 PM)justsomeguy Wrote: I'm wanting to use Inform-PE on a couple of projects, so I have a question about how to use it.

The project will need to have several UI's, for instance a menu screen, option screen, game play, inventory etc. So, to switch between these UI's, do I put everything on separate forms and somehow (?) switch forms, or cram all the controls on the same form and hide the controls I'm not using?

Using separate forms make the most sense, but I don't see a obvious way to do it. Have I missed something?

No. You are right. Creating multiple forms is currently not possible due to the way QB64 works (i.e. you get only one main graphics window to work with). To work around this, you can:
  1. Cram all controls in the main form and hide the controls that are not being used (this is what the InForm UI Editor does as well).
  2. Write multiple InForm-PE apps (say one for the UI, options etc.) and have them "talk" to each other either using command line arguments or some kind of IPC.
Reply
#3
Yeah or divide and compile into different forms and Run them from central app.
b = b + ...
Reply
#4
@bplus idea is easier than IPC setup to talk between them.

Just use a text file for your comms, and watch it in a loop kinda thing. This is called a semaphore file I believe.
https://en.wikipedia.org/wiki/Semaphore_(programming)

It's clunky until you get it working then it'll just be something behind the scenes. Technically, this is also IPC (Inter-process communication ) because you are doing things with an intermediary (the file).

So you'd have your main program window as one program, your options as another, game play another, inventory another.

I think there might be some questions to answer ahead of the coding though given your question @justsomeguy

Is your project going to be OK with multiple windows? Because that's what it'd turn into. Window juggling on the user.

If not, and you want your entire program in the one window, it might be better to do as @a740g said and put everything in one giant InformPE form and hide/show things as needed.

In my experience, this would be very difficult to handle in the InformPE form designer though - because it would be overwhelming and finnicky to manage all of that stuff in one giant form and then have to remember what is visible where.

I don't think InformPE has a tab controller similar to VB6 for example, wherein the actual form designer hides what isn't clicked on the tab to help the designer focus, etc.

good luck with your project! You might want to mock something up if you're going to do multiple windows to determine how to wrangle them, etc. And you might also want to consider that not all OSes have the same features for the window management, so take that into consideration in your design phase!
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply
#5
There is a way to do this using the Win32 API but this requires a lot of knowledge and patience. I haven't yet made my Win32 GUI code compatible with v4.0 of QB64. It's not super high on my list of to-dos, especially with Christmas and New Year's coming up. It's gotten a little annoying having to redo API code with every update. I did make sort of a skeleton of a library for the Win32 GUI, though. My perfect world is making a library similar to InForm that is easy to use. It's easy for me to use currently, but I know that it is a daunting task for most others. Maybe this will become a big project if I can focus on it. No promises.
Tread on those who tread on you

Reply
#6
Or instead of InForm, simply use GuiTools, which already has this multiple Forms/Windows concept built in (try the "MultiWinDemo"). Although to mention there's no Designer in GuiTools, i.e. make a sketch of what you want and then code the objects accordingly in your program. Also GuiTools is Windows only.
Reply
#7
I've used this semaphore to communicate between dozen instances.
Just start multiple times and type something in one of the instances...

Code: (Select All)
Const SEMFILE = "~semaphore."
Do
  n% = n% + 1
Loop Until Not _FileExists(SEMFILE + _ToStr$(n%))
_Title "Semaphore " + _ToStr$(n%)
Open SEMFILE + _ToStr$(n%) For Binary Access Write As #1

Do
  _Limit 100

  o% = 1
  Do While _FileExists(SEMFILE + _ToStr$(o%))
    If o% <> n% Then
      r$ = sread$(o%)
      If r$ <> "" Then Print o%; r$
    End If
    o% = o% + 1
  Loop
  _Title "Semaphore " + _ToStr$(n%) + "/" + _ToStr$(o% - 1)

  Select Case k$
    Case Chr$(27)
      Exit Do
    Case "l"
      swrite "this is a line, this is a line, this is a line !!!"
    Case Else
      swrite k$
  End Select
  k$ = InKey$

Loop

Close #1
Kill SEMFILE + _ToStr$(n%)
System

Sub swrite (k$)
  Put #1, , k$
End Sub

Function sread$ (o%)
  Static ps&(1000)
  Open SEMFILE + _ToStr$(o%) For Binary Access Read As #2
  new& = LOF(2) - ps&(o%)
  If new& > 0 Then
    k$ = Space$(new&)
    Get #2, ps&(o%) + 1, k$
    ps&(o%) = ps&(o%) + new&
    sread$ = k$
  End If
  Close #2
End Function
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply




Users browsing this thread: jcm, 2 Guest(s)