Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[demo] Add the PortraitWindow #1282

Open
m7600 opened this issue Jun 12, 2021 · 6 comments · May be fixed by #1287
Open

[demo] Add the PortraitWindow #1282

m7600 opened this issue Jun 12, 2021 · 6 comments · May be fixed by #1287
Labels
feature feature request game: demo

Comments

@m7600
Copy link
Contributor

m7600 commented Jun 12, 2021

I'm trying to add the PortraitWindow to the demo. I modified guiw.chu with DLTCEP (added a window and a control button). Here is what I added to MessageWindow.py:

	PortraitWindow = GemRB.LoadWindow(10, GUICommon.GetWindowPack(), WINDOW_RIGHT)
	PortraitWindow.AddAlias("PORTWIN")
	
	PortraitButton = MessageWindow.GetControl (24)

But when I run the demo, only the windows are visible, the player screen is completely black, as you can see in the attached screenshot. In the terminal, I get this error:

[Python/ERROR]: Traceback (most recent call last):
[Python/ERROR]:   File "/usr/local/share/gemrb/GUIScripts/GUICommonWindows.py", line 1721, in UpdatePortraitWindow
[Python/ERROR]:     Button.SetAction(lambda btn, val, pc=pcID: GemRB.GameControlLocateActor(pc), IE_ACT_MOUSE_ENTER);
[Python/ERROR]: AttributeError: 'NoneType' object has no attribute 'SetAction'

I'm obviously doing something wrong.

Here's a screenshot (I need to fine-tune the position of the portrait and the size of the column, it's a work in progress for now).

Screenshot from 2021-06-12 02-10-22

@m7600 m7600 added the feature feature request label Jun 12, 2021
@lynxlynxlynx
Copy link
Member

It just expects a bunch of extra controls, since the common code to run portrait windows detected the window is now present. In this case it expects 6 slots for party members.

@m7600
Copy link
Contributor Author

m7600 commented Jun 13, 2021

I added this to MessageWindow.py:

	PortraitWindow = GemRB.LoadWindow(10, GUICommon.GetWindowPack(), WINDOW_RIGHT)
	PortraitWindow.AddAlias("PORTWIN")
	
	PortraitButton = MessageWindow.GetControl (24)
	PortraitButton = MessageWindow.GetControl (25)
	PortraitButton = MessageWindow.GetControl (26)
	PortraitButton = MessageWindow.GetControl (27)
	PortraitButton = MessageWindow.GetControl (28)
	PortraitButton = MessageWindow.GetControl (29)

What else should I do?

@lynxlynxlynx
Copy link
Member

The CHU file needs the buttons — did you add them there?

@m7600
Copy link
Contributor Author

m7600 commented Jun 13, 2021

Yes, I added the buttons to the .chu file with DLTCEP.

@lynxlynxlynx
Copy link
Member

Are you saying you're getting the same error? And the buttons need to have IDs from 1-6.

@m7600
Copy link
Contributor Author

m7600 commented Jun 13, 2021

I was getting the same error, yes, but now that I've renamed the IDs for the buttons, everything works. Thanks! I didn't know that two or more controls could have the same ID, even if they belonged to different windows. Cool.
Screenshot from 2021-06-13 16-18-15

@m7600 m7600 linked a pull request Jun 13, 2021 that will close this issue
@lynxlynxlynx lynxlynxlynx linked a pull request Jun 13, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature feature request game: demo
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants