OpenXcom Forum

Modding => Work In Progress => Topic started by: Stoddard on June 15, 2017, 01:35:19 pm

Title: Embedded PyPy driving OpenXcom's GUI.
Post by: Stoddard on June 15, 2017, 01:35:19 pm
(http://i.imgur.com/hE6IxRDl.png)

Embedded PyPy driving the GUI.

Now that was hairy, and still has some kinks to straighten out.

Driving most anything else in the game is much simpler.
Title: Re: Embedded PyPy driving OpenXcom's GUI.
Post by: Stoddard on June 17, 2017, 11:56:13 pm
Kinks having been unkinked, here's something to look at code-wise:

The cffi branch https://github.com/StoddardOXC/OpenXcom/tree/cffi (https://github.com/StoddardOXC/OpenXcom/tree/cffi)

The code that shows the above popup:

https://github.com/StoddardOXC/OpenXcom/blob/cffi/python/aboutpy.py#L32 (https://github.com/StoddardOXC/OpenXcom/blob/cffi/python/aboutpy.py#L32)

Code: [Select]

class AboutPyPy(State):
    def __init__(self, parent):
        st_w = 300
        btn_w = 60
        super(AboutPyPy, self).__init__(parent,
            w = st_w, h = 180, x = 10, y = 10,
            popmode = POPUP_BOTH, ui_category = "geoscape", bg = "BACK01.SCR")

        version = "Python " + sys.version.replace(' (', ' \n(' )
        self.add_text(280, 140, 20, 20, "text", "saveMenus", ALIGN_CENTER, ALIGN_MIDDLE, False, False, version)
        btn = TextButton(self, btn_w, 20, st_w/2 - btn_w/2, 160, "button", "saveMenus", self.tr("STR_OK"));
        btn.onMouseClick(self.btnOk, 1)
        btn.onKeyboardPress(self.btnOk) # no keysym = any key
        self.add(btn)

    def btnOk(self, *args):
        self.pop()


Title: Re: Embedded PyPy driving OpenXcom's GUI.
Post by: Meridian on June 17, 2017, 11:59:11 pm
What is the point of this?
Title: Re: Embedded PyPy driving OpenXcom's GUI.
Post by: Stoddard on June 18, 2017, 12:47:05 am
What is the point of this?

At first, fast iteration on the UI.

Right now I'm about even on the time spent on a failed attempt to make 'Supplies Ok' combobox (NewManufactureListState::_cbxFilter) not reset the 'Category' combobox (NewManufactureListState::_cbxCategory) versus the whole of this embedding work. And I don't like much more in the UI than one pitiful misbehaving combobox (all I got for the time wasted is the understanding that it just can't be done with two comboboxes, phew).

This approach doesn't requre recompile after every teeny tiny change, and in a couple of hours won't even require restarting the game for any changes to apply, which means I won't have to waste time staring at the linker having changed a couple of characters in a text string.

The python api is being kept as close to the c++ one as reasonable, so if someone feels like porting anything back, it shouldn't become a total rewrite.


Title: Re: Embedded PyPy driving OpenXcom's GUI.
Post by: Warboy1982 on June 18, 2017, 11:06:04 am
interesting
Title: Re: Embedded PyPy driving OpenXcom's GUI.
Post by: Stoddard on September 29, 2018, 01:53:18 am
A year came by..


  (http://imgur.com/sXwzmRgl.png)
 (http://i.imgur.com/sXwzmRg.png)


  (http://imgur.com/JKumOWkl.png)
 (http://i.imgur.com/JKumOWk.png)

Thanks to Whisper for encouraging further development.

Those are the start of a better inventory management ui.

Better than having it in a cli on a second monitor at least :-/

Title: Re: Embedded PyPy driving OpenXcom's GUI.
Post by: SupSuper on October 01, 2018, 08:33:03 pm
This approach doesn't requre recompile after every teeny tiny change, and in a couple of hours won't even require restarting the game for any changes to apply, which means I won't have to waste time staring at the linker having changed a couple of characters in a text string.
No "Edit and Continue" equivalent on Linux?
Title: Re: Embedded PyPy driving OpenXcom's GUI.
Post by: Stoddard on October 02, 2018, 03:46:45 pm
No "Edit and Continue" equivalent on Linux?

There is for some values of 'is'.

The question is more about that the OXC core has grown too old to be efficiently iterated upon, not about the tools or lack of them.

--- posts merge police to the rescue! ---

Meanwhile the new ui core made the first and most painful step:


  (http://imgur.com/BYWLcbKl.png)
 (http://i.imgur.com/BYWLcbK.png)
Title: Re: Embedded PyPy driving OpenXcom's GUI.
Post by: wolfreal on October 02, 2018, 08:21:26 pm
I guess that can make an interesting option for extending the GUI.
Title: Re: Embedded PyPy driving OpenXcom's GUI.
Post by: Stoddard on October 02, 2018, 08:42:07 pm
I guess that can make an interesting option for extending the GUI.

Yeah, that's the plan.




Next milestone: a button is drawn. And it even produces the button sound when clicked.


  (http://imgur.com/MtAyIMcl.png)
 (http://i.imgur.com/MtAyIMc.png)

Three more to go - a TextList, a ComboBox and a TextEdit.
And then, finally, I can get to the actual modding.