Menu pain...

Need help testing contributed art or code or having trouble getting your newest additions into game compatible format? Confused by changes to data formats? Reading through source and wondering what the developers were thinking when they wrote something? Need "how-to" style guidance for messing with VS internals? This is probably the right forum.
Post Reply
legine
Bounty Hunter
Bounty Hunter
Posts: 139
Joined: Mon Sep 27, 2004 8:40 am
Location: Germany
Contact:

Menu pain...

Post by legine »

hello,

Just to make things sure. The Mission Menues and Load/Save stuff are actually written in C++ Code right? (witin the base_computer or what is it called ;) )

And i cant call a quit function over the base facillity, yes?

I am still useing the 0.4.3 for Linux :P
loki1950
The Shepherd
Posts: 5841
Joined: Fri May 13, 2005 8:37 pm
Location: Ottawa
Contact:

Post by loki1950 »

Python i believe legine that call those functions within base_computer.

Enjoy the Choice :)
my box::HP Envy i5-6400 @2Q70GHzx4 8 Gb ram/1 Tb(Win10 64)/3 Tb Mint 19.2/GTX745 4Gb acer S243HL K222HQL
Q8200/Asus P5QDLX/8 Gb ram/WD 2Tb 2-500 G HD/GF GT640 2Gb Mint 17.3 64 bit Win 10 32 bit acer and Lenovo ideapad 320-15ARB Win 10/Mint 19.2
ace123
Lead Network Developer
Lead Network Developer
Posts: 2560
Joined: Sun Jan 12, 2003 9:13 am
Location: Palo Alto CA
Contact:

Post by ace123 »

There are right now two base computers

One is written in C++, in src/cmd/basecomputer.cpp using the GUI libraries in src/gui/. This one is distinguishable because it has a computer-y background and clicky buttons (that depress as you click them).

The other base computer system (though not as fully-featured) was written for privateer gemini gold, a mod, and is currently used for the main menu (Load,Campaign). The heart of it lies in modules/GUI.py, which wraps around a system designed for use with bases in src/cmd/base_interface.cpp.

If you are interested in the Python code that is used in Gemini Gold, you can find it here:
http://privateer.svn.sourceforge.net/vi ... unk/bases/
under weapons_lib.py and also a few other things.


Now if that wasn't enough already, I am going to commit a new set of code *tonight*, called "dialog_box.py" which is basically a wrapper around GUI.py.
It will allow you to in very simple terms create a dialog box with lists, text inputs and buttons, and by defining a single callback function you can do what you want.
I intend to use that dialog box code to allow the server to ask questions to the user without needing special code to handle each specific thing.

Since this is what I'm working on right now, I'll paste a code fragment for your own enjoyment

Code: Select all

def runComputer(local,cmd,args,id,cp=-1):
        def callback(dialog,result):
                print 'id is: ',id
                action,inputs = dialog_box.fromValues(result)
                if action=='Test':
                        print 'test clicked!!!!'
                ...
        items=['width', 1.0,
                'text', 'Public Computer Menu',0.,
                'textinput','callsign','',
                'height', .1,
                'button', 'Test',
                'button', 'Exit Menu']
        
        id = dialog_box.dialog(items,callback)

I am also going to add a simple "alert" or "confirm" question that will allow you to ask a question... though unfortunately due to the nature of Python code this is done asynchronously, so you will need to pass a callback function. However this is true for all of the GUI procedures.

Hopefully this didn't confuse you too much more.


Also, indeed you can call the quit function from Python. The function is "Base.ExitGame()" (a very simple name). Just for future reference, the Base functions you are allowed to call all exist within src/cmd/base_util.h
ace123
Lead Network Developer
Lead Network Developer
Posts: 2560
Joined: Sun Jan 12, 2003 9:13 am
Location: Palo Alto CA
Contact:

Post by ace123 »

I have committed said library.
You can look at modules/computer.py for an example on how to use it.
You also need to build the latest source as of yesterday to have the text boxes work correctly.

There are a few design decisions that I'm not too sure about...

One such decision was whether to put it in a separate room.

Also, I create the dialog box out of an array of strings, which feels a bit odd, but that's the easiest way to transmit information over the network (the network doesn't know about classes or instances). I guess I could have done XML or pickling but that's probably overcomplicating this.

Anyway the simple functions are dialog_box.alert (one button) and dialog_box.confirm (more than one button).
legine
Bounty Hunter
Bounty Hunter
Posts: 139
Joined: Mon Sep 27, 2004 8:40 am
Location: Germany
Contact:

Post by legine »

I am impressed.

I will look into the latest svn version.

Will that lib show up into 0.5?

[edit]
Well, It looks like the Gui system used by gemini looks enough for what I currentlyhave in mind.
However I am interested to see what you have done. I hope Ill find the time.
ace123
Lead Network Developer
Lead Network Developer
Posts: 2560
Joined: Sun Jan 12, 2003 9:13 am
Location: Palo Alto CA
Contact:

Post by ace123 »

I do intend to include multiplayer support in 5.0, and it would be nice to have the capability to implement new server-side features after 5.0 is released and have it work on the older clients as well.

This will let the server basically say "Make a dialog box with a text box and two buttons and tell me which one was pressed"

The idea came from allowing the user to create custom bounty missions on other players, and there was before now no system of asking a question from the server, or having an easy way to input text.

For most cases the GUI library should indeed be enough (and this system is based on that library)...
pyramid
Expert Mercenary
Expert Mercenary
Posts: 988
Joined: Thu Jun 15, 2006 1:02 am
Location: Somewhere in the vastness of space
Contact:

Re:

Post by pyramid »

ace123 wrote:... base computers. One is written in C++, in src/cmd/basecomputer.cpp using the GUI libraries in src/gui/. This one is distinguishable because it has a computer-y background and clicky buttons (that depress as you click them).
Does this mean that there is no way to write a base computer in python without changing the source?
legine
Bounty Hunter
Bounty Hunter
Posts: 139
Joined: Mon Sep 27, 2004 8:40 am
Location: Germany
Contact:

Re: Menu pain...

Post by legine »

I am dump. Whats the difference between the basecomputer and a base?

You can write a base and menues with the lib created by the privateer guys...
Dono if that is the direction your question is aiming at.
ace123
Lead Network Developer
Lead Network Developer
Posts: 2560
Joined: Sun Jan 12, 2003 9:13 am
Location: Palo Alto CA
Contact:

Re: Menu pain...

Post by ace123 »

"basecomputer" is a c++ interface that has select lists and buy/sell buttons. This is c++ code in src/gui

"base" is code written in python. "GUI.py" is a python library that takes a simple set of Python<-->C++ calls and makes them object-oriented so as to make python code easier to write without worrying about the awful c++ code.

The reason for the distinction is that in the beginning there was only a "basecomputer". Then a XML base system was added. That base system was then ported to run python code. And then many years later people figured out they could reproduce the functionality of the c++ basecomputer with python code, which is what Privateer Gold uses.

So you can use either system now to do what you want. The python GUI system is preferable because it means that you do not need a specific version of the engine in order to run.
Post Reply