aliens

Author Topic: Embedded PyPy driving OpenXcom's GUI.  (Read 6307 times)

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Embedded PyPy driving OpenXcom's GUI.
« on: June 15, 2017, 01:35:19 pm »


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.

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Embedded PyPy driving OpenXcom's GUI.
« Reply #1 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

The code that shows the above popup:

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()



Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8974
    • View Profile
Re: Embedded PyPy driving OpenXcom's GUI.
« Reply #2 on: June 17, 2017, 11:59:11 pm »
What is the point of this?

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Embedded PyPy driving OpenXcom's GUI.
« Reply #3 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.



Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Embedded PyPy driving OpenXcom's GUI.
« Reply #4 on: June 18, 2017, 11:06:04 am »
interesting

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Embedded PyPy driving OpenXcom's GUI.
« Reply #5 on: September 29, 2018, 01:53:18 am »
A year came by..


 



 


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 :-/


Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: Embedded PyPy driving OpenXcom's GUI.
« Reply #6 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?

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Embedded PyPy driving OpenXcom's GUI.
« Reply #7 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:


 
« Last Edit: October 02, 2018, 08:49:58 pm by Solarius Scorch »

Offline wolfreal

  • Colonel
  • ****
  • Posts: 298
    • View Profile
Re: Embedded PyPy driving OpenXcom's GUI.
« Reply #8 on: October 02, 2018, 08:21:26 pm »
I guess that can make an interesting option for extending the GUI.

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Embedded PyPy driving OpenXcom's GUI.
« Reply #9 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.


 


Three more to go - a TextList, a ComboBox and a TextEdit.
And then, finally, I can get to the actual modding.
« Last Edit: October 05, 2018, 07:15:43 pm by Stoddard »